@contractspec/example.agent-console 3.7.7 → 3.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/.turbo/turbo-build.log +126 -105
  2. package/AGENTS.md +3 -1
  3. package/CHANGELOG.md +57 -0
  4. package/README.md +46 -9
  5. package/dist/agent/agent.handler.d.ts +3 -0
  6. package/dist/agent/agent.handler.js +730 -1
  7. package/dist/agent/index.js +73 -72
  8. package/dist/agent.feature.js +179 -0
  9. package/dist/browser/agent/agent.handler.js +730 -1
  10. package/dist/browser/agent/index.js +73 -72
  11. package/dist/browser/agent.feature.js +179 -0
  12. package/dist/browser/docs/agent-console.docblock.js +11 -8
  13. package/dist/browser/docs/index.js +11 -8
  14. package/dist/browser/example.js +2 -3
  15. package/dist/browser/handlers/agent.handlers.js +1883 -2
  16. package/dist/browser/handlers/index.js +2142 -8
  17. package/dist/browser/index.js +3347 -2433
  18. package/dist/browser/presentations/index.js +49 -49
  19. package/dist/browser/run/index.js +818 -812
  20. package/dist/browser/run/run.handler.js +666 -1
  21. package/dist/browser/shared/index.js +293 -1
  22. package/dist/browser/shared/mock-runs.js +5 -0
  23. package/dist/browser/tool/index.js +331 -331
  24. package/dist/browser/tool/tool.handler.js +479 -3
  25. package/dist/browser/ui/AgentDashboard.js +1204 -319
  26. package/dist/browser/ui/AgentDashboard.visualizations.js +217 -0
  27. package/dist/browser/ui/AgentRunList.js +359 -127
  28. package/dist/browser/ui/hooks/index.js +468 -18
  29. package/dist/browser/ui/hooks/useAgentMutations.js +443 -8
  30. package/dist/browser/ui/hooks/useRunList.js +25 -10
  31. package/dist/browser/ui/index.js +1293 -390
  32. package/dist/browser/ui/renderers/agent-list.markdown.js +14 -5
  33. package/dist/browser/ui/renderers/dashboard.markdown.js +207 -36
  34. package/dist/browser/ui/renderers/index.js +245 -49
  35. package/dist/browser/ui/renderers/run-list.markdown.js +9 -4
  36. package/dist/browser/ui/renderers/tool-registry.markdown.js +15 -4
  37. package/dist/browser/ui/views/RunDataTable.js +326 -0
  38. package/dist/browser/ui/views/RunListView.js +359 -127
  39. package/dist/browser/ui/views/index.js +406 -174
  40. package/dist/browser/ui/views/run-data-table.columns.js +271 -0
  41. package/dist/browser/ui/views/run-list.shared.js +177 -0
  42. package/dist/browser/visualizations/catalog.js +134 -0
  43. package/dist/browser/visualizations/index.js +187 -0
  44. package/dist/browser/visualizations/selectors.js +181 -0
  45. package/dist/docs/agent-console.docblock.js +11 -8
  46. package/dist/docs/index.js +11 -8
  47. package/dist/example.js +2 -3
  48. package/dist/example.test.d.ts +1 -0
  49. package/dist/handlers/agent.handlers.d.ts +2 -0
  50. package/dist/handlers/agent.handlers.js +1883 -2
  51. package/dist/handlers/index.d.ts +1 -3
  52. package/dist/handlers/index.js +2142 -8
  53. package/dist/handlers/mock-handlers.test.d.ts +1 -0
  54. package/dist/index.d.ts +2 -0
  55. package/dist/index.js +3347 -2433
  56. package/dist/node/agent/agent.handler.js +730 -1
  57. package/dist/node/agent/index.js +73 -72
  58. package/dist/node/agent.feature.js +179 -0
  59. package/dist/node/docs/agent-console.docblock.js +11 -8
  60. package/dist/node/docs/index.js +11 -8
  61. package/dist/node/example.js +2 -3
  62. package/dist/node/handlers/agent.handlers.js +1883 -2
  63. package/dist/node/handlers/index.js +2142 -8
  64. package/dist/node/index.js +3347 -2433
  65. package/dist/node/presentations/index.js +49 -49
  66. package/dist/node/run/index.js +818 -812
  67. package/dist/node/run/run.handler.js +666 -1
  68. package/dist/node/shared/index.js +293 -1
  69. package/dist/node/shared/mock-runs.js +5 -0
  70. package/dist/node/tool/index.js +331 -331
  71. package/dist/node/tool/tool.handler.js +479 -3
  72. package/dist/node/ui/AgentDashboard.js +1204 -319
  73. package/dist/node/ui/AgentDashboard.visualizations.js +217 -0
  74. package/dist/node/ui/AgentRunList.js +359 -127
  75. package/dist/node/ui/hooks/index.js +468 -18
  76. package/dist/node/ui/hooks/useAgentMutations.js +443 -8
  77. package/dist/node/ui/hooks/useRunList.js +25 -10
  78. package/dist/node/ui/index.js +1293 -390
  79. package/dist/node/ui/renderers/agent-list.markdown.js +14 -5
  80. package/dist/node/ui/renderers/dashboard.markdown.js +207 -36
  81. package/dist/node/ui/renderers/index.js +245 -49
  82. package/dist/node/ui/renderers/run-list.markdown.js +9 -4
  83. package/dist/node/ui/renderers/tool-registry.markdown.js +15 -4
  84. package/dist/node/ui/views/RunDataTable.js +326 -0
  85. package/dist/node/ui/views/RunListView.js +359 -127
  86. package/dist/node/ui/views/index.js +406 -174
  87. package/dist/node/ui/views/run-data-table.columns.js +271 -0
  88. package/dist/node/ui/views/run-list.shared.js +177 -0
  89. package/dist/node/visualizations/catalog.js +134 -0
  90. package/dist/node/visualizations/index.js +187 -0
  91. package/dist/node/visualizations/selectors.js +181 -0
  92. package/dist/presentations/index.js +49 -49
  93. package/dist/proof/index.d.ts +2 -0
  94. package/dist/proof/meetup-proof.d.ts +10 -0
  95. package/dist/proof/meetup-proof.runtime.d.ts +22 -0
  96. package/dist/proof/meetup-proof.scenario.d.ts +2 -0
  97. package/dist/proof/meetup-proof.suite.d.ts +1 -0
  98. package/dist/proof/meetup-proof.test.d.ts +1 -0
  99. package/dist/run/index.js +818 -812
  100. package/dist/run/run.handler.d.ts +4 -0
  101. package/dist/run/run.handler.js +666 -1
  102. package/dist/shared/demo-dashboard-data.d.ts +16 -0
  103. package/dist/shared/demo-runtime-seed.d.ts +17 -0
  104. package/dist/shared/demo-runtime.d.ts +8 -0
  105. package/dist/shared/demo-runtime.test.d.ts +1 -0
  106. package/dist/shared/index.d.ts +3 -0
  107. package/dist/shared/index.js +293 -1
  108. package/dist/shared/mock-runs.d.ts +4 -0
  109. package/dist/shared/mock-runs.js +5 -0
  110. package/dist/tool/index.js +331 -331
  111. package/dist/tool/tool.handler.d.ts +4 -1
  112. package/dist/tool/tool.handler.js +479 -3
  113. package/dist/ui/AgentDashboard.js +1204 -319
  114. package/dist/ui/AgentDashboard.sandbox.test.d.ts +1 -0
  115. package/dist/ui/AgentDashboard.visualizations.d.ts +4 -0
  116. package/dist/ui/AgentDashboard.visualizations.js +218 -0
  117. package/dist/ui/AgentRunList.js +359 -127
  118. package/dist/ui/hooks/index.js +468 -18
  119. package/dist/ui/hooks/useAgentMutations.js +443 -8
  120. package/dist/ui/hooks/useRunList.d.ts +8 -2
  121. package/dist/ui/hooks/useRunList.js +25 -10
  122. package/dist/ui/index.js +1293 -390
  123. package/dist/ui/renderers/agent-list.markdown.d.ts +1 -1
  124. package/dist/ui/renderers/agent-list.markdown.js +14 -5
  125. package/dist/ui/renderers/agent-list.renderer.d.ts +1 -1
  126. package/dist/ui/renderers/dashboard.markdown.d.ts +1 -1
  127. package/dist/ui/renderers/dashboard.markdown.js +207 -36
  128. package/dist/ui/renderers/index.js +245 -49
  129. package/dist/ui/renderers/run-list.markdown.d.ts +1 -1
  130. package/dist/ui/renderers/run-list.markdown.js +9 -4
  131. package/dist/ui/renderers/tool-registry.markdown.d.ts +2 -2
  132. package/dist/ui/renderers/tool-registry.markdown.js +15 -4
  133. package/dist/ui/views/RunDataTable.d.ts +18 -0
  134. package/dist/ui/views/RunDataTable.js +327 -0
  135. package/dist/ui/views/RunListView.js +359 -127
  136. package/dist/ui/views/index.js +406 -174
  137. package/dist/ui/views/run-data-table.columns.d.ts +3 -0
  138. package/dist/ui/views/run-data-table.columns.js +272 -0
  139. package/dist/ui/views/run-list.shared.d.ts +14 -0
  140. package/dist/ui/views/run-list.shared.js +178 -0
  141. package/dist/visualizations/catalog.d.ts +10 -0
  142. package/dist/visualizations/catalog.js +135 -0
  143. package/dist/visualizations/index.d.ts +2 -0
  144. package/dist/visualizations/index.js +188 -0
  145. package/dist/visualizations/selectors.d.ts +3 -0
  146. package/dist/visualizations/selectors.js +182 -0
  147. package/dist/visualizations/selectors.test.d.ts +1 -0
  148. package/package.json +114 -11
  149. package/proofs/agent-console-meetup.replay.json +220 -0
  150. package/src/agent/agent.handler.ts +18 -1
  151. package/src/agent.feature.ts +3 -0
  152. package/src/docs/agent-console.docblock.ts +11 -8
  153. package/src/example.test.ts +75 -0
  154. package/src/example.ts +2 -3
  155. package/src/handlers/agent.handlers.ts +55 -2
  156. package/src/handlers/index.ts +18 -2
  157. package/src/handlers/mock-handlers.test.ts +77 -0
  158. package/src/index.ts +2 -0
  159. package/src/proof/index.ts +2 -0
  160. package/src/proof/meetup-proof.runtime.ts +196 -0
  161. package/src/proof/meetup-proof.scenario.ts +99 -0
  162. package/src/proof/meetup-proof.suite.ts +29 -0
  163. package/src/proof/meetup-proof.test.ts +28 -0
  164. package/src/proof/meetup-proof.ts +130 -0
  165. package/src/run/run.handler.ts +17 -1
  166. package/src/shared/demo-dashboard-data.ts +58 -0
  167. package/src/shared/demo-runtime-seed.ts +139 -0
  168. package/src/shared/demo-runtime.test.ts +169 -0
  169. package/src/shared/demo-runtime.ts +260 -0
  170. package/src/shared/index.ts +11 -0
  171. package/src/shared/mock-runs.ts +5 -0
  172. package/src/tool/tool.handler.ts +21 -4
  173. package/src/ui/AgentDashboard.sandbox.test.tsx +312 -0
  174. package/src/ui/AgentDashboard.tsx +4 -1
  175. package/src/ui/AgentDashboard.visualizations.tsx +35 -0
  176. package/src/ui/hooks/useAgentMutations.ts +19 -11
  177. package/src/ui/hooks/useRunList.ts +41 -9
  178. package/src/ui/renderers/agent-list.markdown.ts +32 -13
  179. package/src/ui/renderers/agent-list.renderer.tsx +1 -1
  180. package/src/ui/renderers/dashboard.markdown.ts +38 -43
  181. package/src/ui/renderers/run-list.markdown.ts +17 -9
  182. package/src/ui/renderers/tool-registry.markdown.ts +22 -10
  183. package/src/ui/views/RunDataTable.tsx +74 -0
  184. package/src/ui/views/RunListView.tsx +37 -111
  185. package/src/ui/views/run-data-table.columns.tsx +102 -0
  186. package/src/ui/views/run-list.shared.tsx +139 -0
  187. package/src/visualizations/catalog.ts +132 -0
  188. package/src/visualizations/index.ts +2 -0
  189. package/src/visualizations/selectors.test.ts +12 -0
  190. package/src/visualizations/selectors.ts +70 -0
  191. package/tsdown.config.js +17 -0
@@ -1,4 +1,136 @@
1
1
  // @bun
2
+ // src/agent/agent.enum.ts
3
+ import { defineEnum } from "@contractspec/lib.schema";
4
+ var AgentStatusEnum = defineEnum("AgentStatus", [
5
+ "DRAFT",
6
+ "ACTIVE",
7
+ "PAUSED",
8
+ "ARCHIVED"
9
+ ]);
10
+ var ModelProviderEnum = defineEnum("ModelProvider", [
11
+ "OPENAI",
12
+ "ANTHROPIC",
13
+ "GOOGLE",
14
+ "MISTRAL",
15
+ "CUSTOM"
16
+ ]);
17
+ var ToolChoiceEnum = defineEnum("ToolChoice", [
18
+ "auto",
19
+ "required",
20
+ "none"
21
+ ]);
22
+
23
+ // src/agent/agent.event.ts
24
+ import { defineEvent } from "@contractspec/lib.contracts-spec";
25
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
26
+ var OWNERS = ["@agent-console-team"];
27
+ var AgentCreatedPayload = defineSchemaModel({
28
+ name: "AgentCreatedPayload",
29
+ description: "Payload for agent created event",
30
+ fields: {
31
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
32
+ organizationId: {
33
+ type: ScalarTypeEnum.String_unsecure(),
34
+ isOptional: false
35
+ },
36
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
37
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
38
+ modelProvider: {
39
+ type: ScalarTypeEnum.String_unsecure(),
40
+ isOptional: false
41
+ },
42
+ modelName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
43
+ toolCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
44
+ createdById: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
45
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
46
+ }
47
+ });
48
+ var AgentCreatedEvent = defineEvent({
49
+ meta: {
50
+ key: "agent-console.agent.created",
51
+ version: "1.0.0",
52
+ description: "A new AI agent was configured.",
53
+ stability: "stable",
54
+ owners: [...OWNERS],
55
+ tags: ["agent", "created"]
56
+ },
57
+ payload: AgentCreatedPayload
58
+ });
59
+ var AgentUpdatedPayload = defineSchemaModel({
60
+ name: "AgentUpdatedPayload",
61
+ description: "Payload for agent updated event",
62
+ fields: {
63
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
64
+ organizationId: {
65
+ type: ScalarTypeEnum.String_unsecure(),
66
+ isOptional: false
67
+ },
68
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
69
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
70
+ updatedFields: {
71
+ type: ScalarTypeEnum.String_unsecure(),
72
+ isArray: true,
73
+ isOptional: false
74
+ },
75
+ updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
76
+ }
77
+ });
78
+ var AgentUpdatedEvent = defineEvent({
79
+ meta: {
80
+ key: "agent-console.agent.updated",
81
+ version: "1.0.0",
82
+ description: "An AI agent configuration was updated.",
83
+ stability: "stable",
84
+ owners: [...OWNERS],
85
+ tags: ["agent", "updated"]
86
+ },
87
+ payload: AgentUpdatedPayload
88
+ });
89
+ var AgentToolAssignedPayload = defineSchemaModel({
90
+ name: "AgentToolAssignedPayload",
91
+ description: "Payload for agent tool assigned event",
92
+ fields: {
93
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
94
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
95
+ agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
96
+ toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
97
+ assignedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
98
+ }
99
+ });
100
+ var AgentToolAssignedEvent = defineEvent({
101
+ meta: {
102
+ key: "agent-console.agent.toolAssigned",
103
+ version: "1.0.0",
104
+ description: "A tool was assigned to an agent.",
105
+ stability: "stable",
106
+ owners: [...OWNERS],
107
+ tags: ["agent", "tool", "assigned"]
108
+ },
109
+ payload: AgentToolAssignedPayload
110
+ });
111
+ var AgentToolRemovedPayload = defineSchemaModel({
112
+ name: "AgentToolRemovedPayload",
113
+ description: "Payload for agent tool removed event",
114
+ fields: {
115
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
116
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
117
+ agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
118
+ toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
119
+ removedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
120
+ }
121
+ });
122
+ var AgentToolRemovedEvent = defineEvent({
123
+ meta: {
124
+ key: "agent-console.agent.toolRemoved",
125
+ version: "1.0.0",
126
+ description: "A tool was removed from an agent.",
127
+ stability: "stable",
128
+ owners: [...OWNERS],
129
+ tags: ["agent", "tool", "removed"]
130
+ },
131
+ payload: AgentToolRemovedPayload
132
+ });
133
+
2
134
  // src/shared/mock-agents.ts
3
135
  var MOCK_AGENTS = [
4
136
  {
@@ -223,7 +355,604 @@ var MOCK_TOOLS = [
223
355
  }
224
356
  ];
225
357
 
358
+ // src/agent/agent.schema.ts
359
+ import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
360
+ var AgentModel = defineSchemaModel2({
361
+ name: "Agent",
362
+ description: "AI agent configuration",
363
+ fields: {
364
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
365
+ organizationId: {
366
+ type: ScalarTypeEnum2.String_unsecure(),
367
+ isOptional: false
368
+ },
369
+ name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
370
+ slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
371
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
372
+ status: { type: AgentStatusEnum, isOptional: false },
373
+ modelProvider: { type: ModelProviderEnum, isOptional: false },
374
+ modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
375
+ modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
376
+ systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
377
+ userPromptTemplate: {
378
+ type: ScalarTypeEnum2.String_unsecure(),
379
+ isOptional: true
380
+ },
381
+ toolIds: {
382
+ type: ScalarTypeEnum2.String_unsecure(),
383
+ isArray: true,
384
+ isOptional: true
385
+ },
386
+ toolChoice: {
387
+ type: ToolChoiceEnum,
388
+ isOptional: false,
389
+ defaultValue: "auto"
390
+ },
391
+ maxIterations: {
392
+ type: ScalarTypeEnum2.Int_unsecure(),
393
+ isOptional: false,
394
+ defaultValue: 10
395
+ },
396
+ maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
397
+ timeoutMs: {
398
+ type: ScalarTypeEnum2.Int_unsecure(),
399
+ isOptional: false,
400
+ defaultValue: 120000
401
+ },
402
+ version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
403
+ tags: {
404
+ type: ScalarTypeEnum2.String_unsecure(),
405
+ isArray: true,
406
+ isOptional: true
407
+ },
408
+ createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
409
+ updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
410
+ }
411
+ });
412
+ var AgentSummaryModel = defineSchemaModel2({
413
+ name: "AgentSummary",
414
+ description: "Summary of an agent for list views",
415
+ fields: {
416
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
417
+ name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
418
+ slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
419
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
420
+ status: { type: AgentStatusEnum, isOptional: false },
421
+ modelProvider: { type: ModelProviderEnum, isOptional: false },
422
+ modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
423
+ version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
424
+ createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
425
+ }
426
+ });
427
+ var AgentToolRefModel = defineSchemaModel2({
428
+ name: "AgentToolRef",
429
+ description: "Tool reference in agent context",
430
+ fields: {
431
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
432
+ name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
433
+ slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
434
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
435
+ category: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
436
+ }
437
+ });
438
+ var AgentWithToolsModel = defineSchemaModel2({
439
+ name: "AgentWithTools",
440
+ description: "Agent with associated tools",
441
+ fields: {
442
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
443
+ organizationId: {
444
+ type: ScalarTypeEnum2.String_unsecure(),
445
+ isOptional: false
446
+ },
447
+ name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
448
+ slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
449
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
450
+ status: { type: AgentStatusEnum, isOptional: false },
451
+ modelProvider: { type: ModelProviderEnum, isOptional: false },
452
+ modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
453
+ modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
454
+ systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
455
+ userPromptTemplate: {
456
+ type: ScalarTypeEnum2.String_unsecure(),
457
+ isOptional: true
458
+ },
459
+ toolIds: {
460
+ type: ScalarTypeEnum2.String_unsecure(),
461
+ isArray: true,
462
+ isOptional: true
463
+ },
464
+ toolChoice: { type: ToolChoiceEnum, isOptional: false },
465
+ maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
466
+ maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
467
+ timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
468
+ version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
469
+ tags: {
470
+ type: ScalarTypeEnum2.String_unsecure(),
471
+ isArray: true,
472
+ isOptional: true
473
+ },
474
+ createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
475
+ updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
476
+ tools: { type: AgentToolRefModel, isArray: true, isOptional: true }
477
+ }
478
+ });
479
+ var CreateAgentInputModel = defineSchemaModel2({
480
+ name: "CreateAgentInput",
481
+ description: "Input for creating an agent",
482
+ fields: {
483
+ organizationId: {
484
+ type: ScalarTypeEnum2.String_unsecure(),
485
+ isOptional: false
486
+ },
487
+ name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
488
+ slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
489
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
490
+ modelProvider: { type: ModelProviderEnum, isOptional: false },
491
+ modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
492
+ modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
493
+ systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
494
+ userPromptTemplate: {
495
+ type: ScalarTypeEnum2.String_unsecure(),
496
+ isOptional: true
497
+ },
498
+ toolIds: {
499
+ type: ScalarTypeEnum2.String_unsecure(),
500
+ isArray: true,
501
+ isOptional: true
502
+ },
503
+ toolChoice: { type: ToolChoiceEnum, isOptional: true },
504
+ maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
505
+ maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
506
+ timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
507
+ tags: {
508
+ type: ScalarTypeEnum2.String_unsecure(),
509
+ isArray: true,
510
+ isOptional: true
511
+ }
512
+ }
513
+ });
514
+ var UpdateAgentInputModel = defineSchemaModel2({
515
+ name: "UpdateAgentInput",
516
+ description: "Input for updating an agent",
517
+ fields: {
518
+ agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
519
+ name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: true },
520
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
521
+ status: { type: AgentStatusEnum, isOptional: true },
522
+ modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
523
+ systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
524
+ userPromptTemplate: {
525
+ type: ScalarTypeEnum2.String_unsecure(),
526
+ isOptional: true
527
+ },
528
+ toolIds: {
529
+ type: ScalarTypeEnum2.String_unsecure(),
530
+ isArray: true,
531
+ isOptional: true
532
+ },
533
+ toolChoice: { type: ToolChoiceEnum, isOptional: true },
534
+ maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
535
+ maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
536
+ timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
537
+ tags: {
538
+ type: ScalarTypeEnum2.String_unsecure(),
539
+ isArray: true,
540
+ isOptional: true
541
+ }
542
+ }
543
+ });
544
+
545
+ // src/agent/agent.operation.ts
546
+ import {
547
+ defineCommand,
548
+ defineQuery
549
+ } from "@contractspec/lib.contracts-spec/operations";
550
+ import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
551
+ var OWNERS2 = ["@agent-console-team"];
552
+ var CreateAgentCommand = defineCommand({
553
+ meta: {
554
+ key: "agent-console.agent.create",
555
+ version: "1.0.0",
556
+ stability: "stable",
557
+ owners: [...OWNERS2],
558
+ tags: ["agent", "create"],
559
+ description: "Creates a new AI agent configuration.",
560
+ goal: "Allow users to define new AI agents with specific models and tools.",
561
+ context: "Called from the agent builder UI when creating a new agent."
562
+ },
563
+ io: {
564
+ input: CreateAgentInputModel,
565
+ output: defineSchemaModel3({
566
+ name: "CreateAgentOutput",
567
+ fields: {
568
+ id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
569
+ name: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
570
+ slug: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
571
+ status: { type: AgentStatusEnum, isOptional: false }
572
+ }
573
+ }),
574
+ errors: {
575
+ SLUG_EXISTS: {
576
+ description: "An agent with this slug already exists in the organization",
577
+ http: 409,
578
+ gqlCode: "SLUG_EXISTS",
579
+ when: "Slug is already taken"
580
+ }
581
+ }
582
+ },
583
+ policy: { auth: "user" },
584
+ sideEffects: {
585
+ emits: [
586
+ {
587
+ ref: AgentCreatedEvent.meta,
588
+ when: "Agent is successfully created"
589
+ }
590
+ ],
591
+ audit: ["agent-console.agent.created"]
592
+ },
593
+ acceptance: {
594
+ scenarios: [
595
+ {
596
+ key: "create-agent-happy-path",
597
+ given: ["User is authenticated", "Organization exists"],
598
+ when: ["User submits valid agent configuration"],
599
+ then: [
600
+ "New agent is created with DRAFT status",
601
+ "AgentCreated event is emitted"
602
+ ]
603
+ },
604
+ {
605
+ key: "create-agent-slug-conflict",
606
+ given: ["User is authenticated", "Agent with same slug exists"],
607
+ when: ["User submits agent with duplicate slug"],
608
+ then: ["SLUG_EXISTS error is returned with 409 status"]
609
+ }
610
+ ],
611
+ examples: [
612
+ {
613
+ key: "basic-create",
614
+ input: {
615
+ name: "Support Assistant",
616
+ slug: "support-assistant",
617
+ modelProvider: "openai",
618
+ modelId: "gpt-4"
619
+ },
620
+ output: {
621
+ id: "agent-123",
622
+ name: "Support Assistant",
623
+ slug: "support-assistant",
624
+ status: "draft"
625
+ }
626
+ }
627
+ ]
628
+ }
629
+ });
630
+ var UpdateAgentCommand = defineCommand({
631
+ meta: {
632
+ key: "agent-console.agent.update",
633
+ version: "1.0.0",
634
+ stability: "stable",
635
+ owners: [...OWNERS2],
636
+ tags: ["agent", "update"],
637
+ description: "Updates an existing AI agent configuration.",
638
+ goal: "Allow users to modify agent settings and configuration.",
639
+ context: "Called from the agent settings UI."
640
+ },
641
+ io: {
642
+ input: UpdateAgentInputModel,
643
+ output: defineSchemaModel3({
644
+ name: "UpdateAgentOutput",
645
+ fields: {
646
+ id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
647
+ name: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
648
+ status: { type: AgentStatusEnum, isOptional: false },
649
+ updatedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
650
+ }
651
+ }),
652
+ errors: {
653
+ AGENT_NOT_FOUND: {
654
+ description: "The specified agent does not exist",
655
+ http: 404,
656
+ gqlCode: "AGENT_NOT_FOUND",
657
+ when: "Agent ID is invalid"
658
+ }
659
+ }
660
+ },
661
+ policy: { auth: "user" },
662
+ sideEffects: {
663
+ emits: [
664
+ {
665
+ key: "agent.updated",
666
+ version: "1.0.0",
667
+ stability: "stable",
668
+ owners: [...OWNERS2],
669
+ tags: ["agent", "updated"],
670
+ when: "Agent is updated",
671
+ payload: AgentSummaryModel
672
+ }
673
+ ],
674
+ audit: ["agent.updated"]
675
+ },
676
+ acceptance: {
677
+ scenarios: [
678
+ {
679
+ key: "update-agent-happy-path",
680
+ given: ["Agent exists", "User owns the agent"],
681
+ when: ["User submits updated configuration"],
682
+ then: ["Agent is updated", "AgentUpdated event is emitted"]
683
+ },
684
+ {
685
+ key: "update-agent-not-found",
686
+ given: ["Agent does not exist"],
687
+ when: ["User attempts to update"],
688
+ then: ["AGENT_NOT_FOUND error is returned"]
689
+ }
690
+ ],
691
+ examples: [
692
+ {
693
+ key: "update-name",
694
+ input: {
695
+ agentId: "agent-123",
696
+ name: "Updated Assistant",
697
+ systemPrompt: "You are a helpful assistant."
698
+ },
699
+ output: {
700
+ id: "agent-123",
701
+ name: "Updated Assistant",
702
+ status: "draft",
703
+ updatedAt: "2025-01-01T00:00:00Z"
704
+ }
705
+ }
706
+ ]
707
+ }
708
+ });
709
+ var GetAgentQuery = defineQuery({
710
+ meta: {
711
+ key: "agent-console.agent.get",
712
+ version: "1.0.0",
713
+ stability: "stable",
714
+ owners: [...OWNERS2],
715
+ tags: ["agent", "get"],
716
+ description: "Retrieves an agent by its ID.",
717
+ goal: "View detailed agent configuration.",
718
+ context: "Called when viewing agent details or editing."
719
+ },
720
+ io: {
721
+ input: defineSchemaModel3({
722
+ name: "GetAgentInput",
723
+ fields: {
724
+ agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
725
+ includeTools: { type: ScalarTypeEnum3.Boolean(), isOptional: true }
726
+ }
727
+ }),
728
+ output: AgentWithToolsModel,
729
+ errors: {
730
+ AGENT_NOT_FOUND: {
731
+ description: "The specified agent does not exist",
732
+ http: 404,
733
+ gqlCode: "AGENT_NOT_FOUND",
734
+ when: "Agent ID is invalid"
735
+ }
736
+ }
737
+ },
738
+ policy: { auth: "user" },
739
+ acceptance: {
740
+ scenarios: [
741
+ {
742
+ key: "get-agent-happy-path",
743
+ given: ["Agent exists"],
744
+ when: ["User requests agent by ID"],
745
+ then: ["Agent details are returned"]
746
+ },
747
+ {
748
+ key: "get-agent-with-tools",
749
+ given: ["Agent exists with assigned tools"],
750
+ when: ["User requests agent with includeTools=true"],
751
+ then: ["Agent details with tools list are returned"]
752
+ }
753
+ ],
754
+ examples: [
755
+ {
756
+ key: "get-basic",
757
+ input: { agentId: "agent-123", includeTools: false },
758
+ output: {
759
+ id: "agent-123",
760
+ name: "Support Assistant",
761
+ status: "active",
762
+ tools: []
763
+ }
764
+ }
765
+ ]
766
+ }
767
+ });
768
+ var ListAgentsQuery = defineQuery({
769
+ meta: {
770
+ key: "agent-console.agent.list",
771
+ version: "1.0.0",
772
+ stability: "stable",
773
+ owners: [...OWNERS2],
774
+ tags: ["agent", "list"],
775
+ description: "Lists agents for an organization with optional filtering.",
776
+ goal: "Browse and search available agents.",
777
+ context: "Agent list/dashboard view."
778
+ },
779
+ io: {
780
+ input: defineSchemaModel3({
781
+ name: "ListAgentsInput",
782
+ fields: {
783
+ organizationId: {
784
+ type: ScalarTypeEnum3.String_unsecure(),
785
+ isOptional: false
786
+ },
787
+ status: { type: AgentStatusEnum, isOptional: true },
788
+ modelProvider: { type: ModelProviderEnum, isOptional: true },
789
+ search: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
790
+ limit: {
791
+ type: ScalarTypeEnum3.Int_unsecure(),
792
+ isOptional: true,
793
+ defaultValue: 20
794
+ },
795
+ offset: {
796
+ type: ScalarTypeEnum3.Int_unsecure(),
797
+ isOptional: true,
798
+ defaultValue: 0
799
+ }
800
+ }
801
+ }),
802
+ output: defineSchemaModel3({
803
+ name: "ListAgentsOutput",
804
+ fields: {
805
+ items: { type: AgentSummaryModel, isArray: true, isOptional: false },
806
+ total: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
807
+ hasMore: { type: ScalarTypeEnum3.Boolean(), isOptional: false }
808
+ }
809
+ })
810
+ },
811
+ policy: { auth: "user" },
812
+ acceptance: {
813
+ scenarios: [
814
+ {
815
+ key: "list-agents-happy-path",
816
+ given: ["Organization has agents"],
817
+ when: ["User lists agents"],
818
+ then: ["Paginated list of agents is returned"]
819
+ },
820
+ {
821
+ key: "list-agents-filter-by-status",
822
+ given: ["Organization has agents with mixed statuses"],
823
+ when: ["User filters by status=active"],
824
+ then: ["Only active agents are returned"]
825
+ }
826
+ ],
827
+ examples: [
828
+ {
829
+ key: "list-basic",
830
+ input: { organizationId: "org-123", limit: 10, offset: 0 },
831
+ output: { items: [], total: 0, hasMore: false }
832
+ }
833
+ ]
834
+ }
835
+ });
836
+ var AssignToolToAgentCommand = defineCommand({
837
+ meta: {
838
+ key: "agent-console.agent.assignTool",
839
+ version: "1.0.0",
840
+ stability: "stable",
841
+ owners: [...OWNERS2],
842
+ tags: ["agent", "tool", "assign"],
843
+ description: "Assigns a tool to an agent with optional configuration.",
844
+ goal: "Enable agents to use specific tools.",
845
+ context: "Agent configuration UI - tool selection."
846
+ },
847
+ io: {
848
+ input: defineSchemaModel3({
849
+ name: "AssignToolToAgentInput",
850
+ fields: {
851
+ agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
852
+ toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
853
+ config: { type: ScalarTypeEnum3.JSONObject(), isOptional: true },
854
+ order: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: true }
855
+ }
856
+ }),
857
+ output: defineSchemaModel3({
858
+ name: "AssignToolToAgentOutput",
859
+ fields: {
860
+ agentToolId: {
861
+ type: ScalarTypeEnum3.String_unsecure(),
862
+ isOptional: false
863
+ },
864
+ agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
865
+ toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
866
+ }
867
+ }),
868
+ errors: {
869
+ TOOL_ALREADY_ASSIGNED: {
870
+ description: "This tool is already assigned to the agent",
871
+ http: 409,
872
+ gqlCode: "TOOL_ALREADY_ASSIGNED",
873
+ when: "Tool assignment already exists"
874
+ }
875
+ }
876
+ },
877
+ policy: { auth: "user" },
878
+ sideEffects: { audit: ["agent.tool.assigned"] },
879
+ acceptance: {
880
+ scenarios: [
881
+ {
882
+ key: "assign-tool-happy-path",
883
+ given: ["Agent exists", "Tool exists and is not assigned"],
884
+ when: ["User assigns tool to agent"],
885
+ then: ["Tool is assigned", "Assignment ID is returned"]
886
+ },
887
+ {
888
+ key: "assign-tool-already-assigned",
889
+ given: ["Tool is already assigned to agent"],
890
+ when: ["User attempts to assign again"],
891
+ then: ["TOOL_ALREADY_ASSIGNED error is returned"]
892
+ }
893
+ ],
894
+ examples: [
895
+ {
896
+ key: "assign-basic",
897
+ input: { agentId: "agent-123", toolId: "tool-456" },
898
+ output: {
899
+ agentToolId: "at-789",
900
+ agentId: "agent-123",
901
+ toolId: "tool-456"
902
+ }
903
+ }
904
+ ]
905
+ }
906
+ });
907
+ var RemoveToolFromAgentCommand = defineCommand({
908
+ meta: {
909
+ key: "agent-console.agent.removeTool",
910
+ version: "1.0.0",
911
+ stability: "stable",
912
+ owners: [...OWNERS2],
913
+ tags: ["agent", "tool", "remove"],
914
+ description: "Removes a tool assignment from an agent.",
915
+ goal: "Disable specific tools for an agent.",
916
+ context: "Agent configuration UI - tool management."
917
+ },
918
+ io: {
919
+ input: defineSchemaModel3({
920
+ name: "RemoveToolFromAgentInput",
921
+ fields: {
922
+ agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
923
+ toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
924
+ }
925
+ }),
926
+ output: defineSchemaModel3({
927
+ name: "RemoveToolFromAgentOutput",
928
+ fields: {
929
+ success: { type: ScalarTypeEnum3.Boolean(), isOptional: false }
930
+ }
931
+ })
932
+ },
933
+ policy: { auth: "user" },
934
+ sideEffects: { audit: ["agent.tool.removed"] },
935
+ acceptance: {
936
+ scenarios: [
937
+ {
938
+ key: "remove-tool-happy-path",
939
+ given: ["Agent exists", "Tool is assigned to agent"],
940
+ when: ["User removes tool from agent"],
941
+ then: ["Tool is unassigned", "Success is returned"]
942
+ }
943
+ ],
944
+ examples: [
945
+ {
946
+ key: "remove-basic",
947
+ input: { agentId: "agent-123", toolId: "tool-456" },
948
+ output: { success: true }
949
+ }
950
+ ]
951
+ }
952
+ });
953
+
226
954
  // src/agent/agent.handler.ts
955
+ var nextMockAgentId = MOCK_AGENTS.length + 1;
227
956
  async function mockListAgentsHandler(input) {
228
957
  const {
229
958
  organizationId,
@@ -277,7 +1006,7 @@ async function mockCreateAgentHandler(input) {
277
1006
  if (exists)
278
1007
  throw new Error("SLUG_EXISTS");
279
1008
  return {
280
- id: `agent-${Date.now()}`,
1009
+ id: `agent-${nextMockAgentId++}`,
281
1010
  name: input.name,
282
1011
  slug: input.slug,
283
1012
  status: "DRAFT"