@contractspec/example.agent-console 3.7.7 → 3.8.2

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