@contractspec/example.agent-console 3.8.9 → 3.8.11

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 (228) hide show
  1. package/.turbo/turbo-build.log +225 -222
  2. package/CHANGELOG.md +30 -0
  3. package/dist/agent/agent.entity.js +1 -127
  4. package/dist/agent/agent.enum.js +1 -25
  5. package/dist/agent/agent.event.js +1 -116
  6. package/dist/agent/agent.handler.js +1 -1030
  7. package/dist/agent/agent.operation.js +1 -735
  8. package/dist/agent/agent.presentation.js +1 -282
  9. package/dist/agent/agent.schema.js +1 -215
  10. package/dist/agent/agent.test-spec.js +1 -58
  11. package/dist/agent/index.js +1 -1248
  12. package/dist/agent.capability.js +1 -19
  13. package/dist/agent.feature.js +1 -305
  14. package/dist/browser/agent/agent.entity.js +1 -127
  15. package/dist/browser/agent/agent.enum.js +1 -25
  16. package/dist/browser/agent/agent.event.js +1 -116
  17. package/dist/browser/agent/agent.handler.js +1 -1030
  18. package/dist/browser/agent/agent.operation.js +1 -735
  19. package/dist/browser/agent/agent.presentation.js +1 -282
  20. package/dist/browser/agent/agent.schema.js +1 -215
  21. package/dist/browser/agent/agent.test-spec.js +1 -58
  22. package/dist/browser/agent/index.js +1 -1248
  23. package/dist/browser/agent.capability.js +1 -19
  24. package/dist/browser/agent.feature.js +1 -305
  25. package/dist/browser/docs/agent-console.docblock.js +5 -49
  26. package/dist/browser/docs/index.js +5 -49
  27. package/dist/browser/example.js +1 -41
  28. package/dist/browser/handlers/agent.handlers.js +6 -2143
  29. package/dist/browser/handlers/index.js +6 -2943
  30. package/dist/browser/index.js +14 -6828
  31. package/dist/browser/presentations/index.js +1 -693
  32. package/dist/browser/run/index.js +1 -1363
  33. package/dist/browser/run/run.entity.js +1 -160
  34. package/dist/browser/run/run.enum.js +1 -34
  35. package/dist/browser/run/run.event.js +1 -217
  36. package/dist/browser/run/run.handler.js +1 -919
  37. package/dist/browser/run/run.operation.js +1 -667
  38. package/dist/browser/run/run.presentation.js +1 -223
  39. package/dist/browser/run/run.schema.js +1 -179
  40. package/dist/browser/run/run.test-spec.js +1 -58
  41. package/dist/browser/seeders/index.js +2 -21
  42. package/dist/browser/shared/index.js +1 -626
  43. package/dist/browser/shared/mock-agents.js +1 -82
  44. package/dist/browser/shared/mock-runs.js +1 -113
  45. package/dist/browser/shared/mock-tools.js +1 -146
  46. package/dist/browser/tool/index.js +1 -949
  47. package/dist/browser/tool/tool.entity.js +1 -90
  48. package/dist/browser/tool/tool.enum.js +1 -26
  49. package/dist/browser/tool/tool.event.js +1 -99
  50. package/dist/browser/tool/tool.handler.js +1 -699
  51. package/dist/browser/tool/tool.operation.js +1 -482
  52. package/dist/browser/tool/tool.presentation.js +1 -188
  53. package/dist/browser/tool/tool.schema.js +1 -141
  54. package/dist/browser/tool/tool.test-spec.js +1 -58
  55. package/dist/browser/ui/AgentDashboard.js +1 -2527
  56. package/dist/browser/ui/AgentDashboard.visualizations.js +1 -217
  57. package/dist/browser/ui/AgentRunList.js +1 -482
  58. package/dist/browser/ui/AgentToolRegistry.js +1 -212
  59. package/dist/browser/ui/ExecutionConsoleHost.js +1 -0
  60. package/dist/browser/ui/hooks/index.js +1 -740
  61. package/dist/browser/ui/hooks/useAgentList.js +1 -55
  62. package/dist/browser/ui/hooks/useAgentMutations.js +1 -530
  63. package/dist/browser/ui/hooks/useRunList.js +1 -70
  64. package/dist/browser/ui/hooks/useToolList.js +1 -85
  65. package/dist/browser/ui/index.js +5 -3018
  66. package/dist/browser/ui/modals/AgentActionsModal.js +1 -304
  67. package/dist/browser/ui/modals/CreateAgentModal.js +1 -243
  68. package/dist/browser/ui/modals/index.js +1 -546
  69. package/dist/browser/ui/overlays/demo-overlays.js +1 -64
  70. package/dist/browser/ui/overlays/index.js +1 -64
  71. package/dist/browser/ui/renderers/agent-list.markdown.js +2 -64
  72. package/dist/browser/ui/renderers/agent-list.renderer.js +1 -180
  73. package/dist/browser/ui/renderers/dashboard.markdown.js +2 -288
  74. package/dist/browser/ui/renderers/index.js +5 -642
  75. package/dist/browser/ui/renderers/run-list.markdown.js +2 -50
  76. package/dist/browser/ui/renderers/tool-registry.markdown.js +2 -64
  77. package/dist/browser/ui/views/AgentListView.js +1 -165
  78. package/dist/browser/ui/views/RunDataTable.js +1 -326
  79. package/dist/browser/ui/views/RunListView.js +1 -479
  80. package/dist/browser/ui/views/ToolRegistryView.js +1 -209
  81. package/dist/browser/ui/views/index.js +1 -851
  82. package/dist/browser/ui/views/run-data-table.columns.js +1 -271
  83. package/dist/browser/ui/views/run-list.shared.js +1 -177
  84. package/dist/browser/visualizations/catalog.js +1 -134
  85. package/dist/browser/visualizations/index.js +1 -187
  86. package/dist/browser/visualizations/selectors.js +1 -181
  87. package/dist/docs/agent-console.docblock.js +5 -49
  88. package/dist/docs/index.js +5 -49
  89. package/dist/example.js +1 -41
  90. package/dist/handlers/agent.handlers.js +6 -2143
  91. package/dist/handlers/index.js +6 -2943
  92. package/dist/index.js +14 -6828
  93. package/dist/node/agent/agent.entity.js +1 -127
  94. package/dist/node/agent/agent.enum.js +1 -25
  95. package/dist/node/agent/agent.event.js +1 -116
  96. package/dist/node/agent/agent.handler.js +1 -1030
  97. package/dist/node/agent/agent.operation.js +1 -735
  98. package/dist/node/agent/agent.presentation.js +1 -282
  99. package/dist/node/agent/agent.schema.js +1 -215
  100. package/dist/node/agent/agent.test-spec.js +1 -58
  101. package/dist/node/agent/index.js +1 -1248
  102. package/dist/node/agent.capability.js +1 -19
  103. package/dist/node/agent.feature.js +1 -305
  104. package/dist/node/docs/agent-console.docblock.js +5 -49
  105. package/dist/node/docs/index.js +5 -49
  106. package/dist/node/example.js +1 -41
  107. package/dist/node/handlers/agent.handlers.js +6 -2143
  108. package/dist/node/handlers/index.js +6 -2943
  109. package/dist/node/index.js +14 -6828
  110. package/dist/node/presentations/index.js +1 -693
  111. package/dist/node/run/index.js +1 -1363
  112. package/dist/node/run/run.entity.js +1 -160
  113. package/dist/node/run/run.enum.js +1 -34
  114. package/dist/node/run/run.event.js +1 -217
  115. package/dist/node/run/run.handler.js +1 -919
  116. package/dist/node/run/run.operation.js +1 -667
  117. package/dist/node/run/run.presentation.js +1 -223
  118. package/dist/node/run/run.schema.js +1 -179
  119. package/dist/node/run/run.test-spec.js +1 -58
  120. package/dist/node/seeders/index.js +2 -21
  121. package/dist/node/shared/index.js +1 -626
  122. package/dist/node/shared/mock-agents.js +1 -82
  123. package/dist/node/shared/mock-runs.js +1 -113
  124. package/dist/node/shared/mock-tools.js +1 -146
  125. package/dist/node/tool/index.js +1 -949
  126. package/dist/node/tool/tool.entity.js +1 -90
  127. package/dist/node/tool/tool.enum.js +1 -26
  128. package/dist/node/tool/tool.event.js +1 -99
  129. package/dist/node/tool/tool.handler.js +1 -699
  130. package/dist/node/tool/tool.operation.js +1 -482
  131. package/dist/node/tool/tool.presentation.js +1 -188
  132. package/dist/node/tool/tool.schema.js +1 -141
  133. package/dist/node/tool/tool.test-spec.js +1 -58
  134. package/dist/node/ui/AgentDashboard.js +1 -2527
  135. package/dist/node/ui/AgentDashboard.visualizations.js +1 -217
  136. package/dist/node/ui/AgentRunList.js +1 -482
  137. package/dist/node/ui/AgentToolRegistry.js +1 -212
  138. package/dist/node/ui/ExecutionConsoleHost.js +1 -0
  139. package/dist/node/ui/hooks/index.js +1 -740
  140. package/dist/node/ui/hooks/useAgentList.js +1 -55
  141. package/dist/node/ui/hooks/useAgentMutations.js +1 -530
  142. package/dist/node/ui/hooks/useRunList.js +1 -70
  143. package/dist/node/ui/hooks/useToolList.js +1 -85
  144. package/dist/node/ui/index.js +5 -3018
  145. package/dist/node/ui/modals/AgentActionsModal.js +1 -304
  146. package/dist/node/ui/modals/CreateAgentModal.js +1 -243
  147. package/dist/node/ui/modals/index.js +1 -546
  148. package/dist/node/ui/overlays/demo-overlays.js +1 -64
  149. package/dist/node/ui/overlays/index.js +1 -64
  150. package/dist/node/ui/renderers/agent-list.markdown.js +2 -64
  151. package/dist/node/ui/renderers/agent-list.renderer.js +1 -180
  152. package/dist/node/ui/renderers/dashboard.markdown.js +2 -288
  153. package/dist/node/ui/renderers/index.js +5 -642
  154. package/dist/node/ui/renderers/run-list.markdown.js +2 -50
  155. package/dist/node/ui/renderers/tool-registry.markdown.js +2 -64
  156. package/dist/node/ui/views/AgentListView.js +1 -165
  157. package/dist/node/ui/views/RunDataTable.js +1 -326
  158. package/dist/node/ui/views/RunListView.js +1 -479
  159. package/dist/node/ui/views/ToolRegistryView.js +1 -209
  160. package/dist/node/ui/views/index.js +1 -851
  161. package/dist/node/ui/views/run-data-table.columns.js +1 -271
  162. package/dist/node/ui/views/run-list.shared.js +1 -177
  163. package/dist/node/visualizations/catalog.js +1 -134
  164. package/dist/node/visualizations/index.js +1 -187
  165. package/dist/node/visualizations/selectors.js +1 -181
  166. package/dist/presentations/index.js +1 -693
  167. package/dist/run/index.js +1 -1363
  168. package/dist/run/run.entity.js +1 -160
  169. package/dist/run/run.enum.js +1 -34
  170. package/dist/run/run.event.js +1 -217
  171. package/dist/run/run.handler.js +1 -919
  172. package/dist/run/run.operation.js +1 -667
  173. package/dist/run/run.presentation.js +1 -223
  174. package/dist/run/run.schema.js +1 -179
  175. package/dist/run/run.test-spec.js +1 -58
  176. package/dist/seeders/index.js +2 -21
  177. package/dist/shared/index.js +1 -626
  178. package/dist/shared/mock-agents.js +1 -82
  179. package/dist/shared/mock-runs.js +1 -113
  180. package/dist/shared/mock-tools.js +1 -146
  181. package/dist/tool/index.js +1 -949
  182. package/dist/tool/tool.entity.js +1 -90
  183. package/dist/tool/tool.enum.js +1 -26
  184. package/dist/tool/tool.event.js +1 -99
  185. package/dist/tool/tool.handler.js +1 -699
  186. package/dist/tool/tool.operation.js +1 -482
  187. package/dist/tool/tool.presentation.js +1 -188
  188. package/dist/tool/tool.schema.js +1 -141
  189. package/dist/tool/tool.test-spec.js +1 -58
  190. package/dist/ui/AgentDashboard.js +1 -2527
  191. package/dist/ui/AgentDashboard.visualizations.js +1 -217
  192. package/dist/ui/AgentRunList.js +1 -482
  193. package/dist/ui/AgentToolRegistry.js +1 -212
  194. package/dist/ui/ExecutionConsoleHost.d.ts +1 -0
  195. package/dist/ui/ExecutionConsoleHost.js +2 -0
  196. package/dist/ui/ExecutionConsoleHost.test.d.ts +1 -0
  197. package/dist/ui/hooks/index.js +1 -740
  198. package/dist/ui/hooks/useAgentList.js +1 -55
  199. package/dist/ui/hooks/useAgentMutations.js +1 -530
  200. package/dist/ui/hooks/useRunList.js +1 -70
  201. package/dist/ui/hooks/useToolList.js +1 -85
  202. package/dist/ui/index.d.ts +1 -0
  203. package/dist/ui/index.js +5 -3018
  204. package/dist/ui/modals/AgentActionsModal.js +1 -304
  205. package/dist/ui/modals/CreateAgentModal.js +1 -243
  206. package/dist/ui/modals/index.js +1 -546
  207. package/dist/ui/overlays/demo-overlays.js +1 -64
  208. package/dist/ui/overlays/index.js +1 -64
  209. package/dist/ui/renderers/agent-list.markdown.js +2 -64
  210. package/dist/ui/renderers/agent-list.renderer.js +1 -180
  211. package/dist/ui/renderers/dashboard.markdown.js +2 -288
  212. package/dist/ui/renderers/index.js +5 -642
  213. package/dist/ui/renderers/run-list.markdown.js +2 -50
  214. package/dist/ui/renderers/tool-registry.markdown.js +2 -64
  215. package/dist/ui/views/AgentListView.js +1 -165
  216. package/dist/ui/views/RunDataTable.js +1 -326
  217. package/dist/ui/views/RunListView.js +1 -479
  218. package/dist/ui/views/ToolRegistryView.js +1 -209
  219. package/dist/ui/views/index.js +1 -851
  220. package/dist/ui/views/run-data-table.columns.js +1 -271
  221. package/dist/ui/views/run-list.shared.js +1 -177
  222. package/dist/visualizations/catalog.js +1 -134
  223. package/dist/visualizations/index.js +1 -187
  224. package/dist/visualizations/selectors.js +1 -181
  225. package/package.json +26 -10
  226. package/src/ui/ExecutionConsoleHost.test.tsx +110 -0
  227. package/src/ui/ExecutionConsoleHost.tsx +14 -0
  228. package/src/ui/index.ts +1 -1
@@ -1,736 +1,2 @@
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
-
134
- // src/agent/agent.schema.ts
135
- import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
136
- var AgentModel = defineSchemaModel2({
137
- name: "Agent",
138
- description: "AI agent configuration",
139
- fields: {
140
- id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
141
- organizationId: {
142
- type: ScalarTypeEnum2.String_unsecure(),
143
- isOptional: false
144
- },
145
- name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
146
- slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
147
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
148
- status: { type: AgentStatusEnum, isOptional: false },
149
- modelProvider: { type: ModelProviderEnum, isOptional: false },
150
- modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
151
- modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
152
- systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
153
- userPromptTemplate: {
154
- type: ScalarTypeEnum2.String_unsecure(),
155
- isOptional: true
156
- },
157
- toolIds: {
158
- type: ScalarTypeEnum2.String_unsecure(),
159
- isArray: true,
160
- isOptional: true
161
- },
162
- toolChoice: {
163
- type: ToolChoiceEnum,
164
- isOptional: false,
165
- defaultValue: "auto"
166
- },
167
- maxIterations: {
168
- type: ScalarTypeEnum2.Int_unsecure(),
169
- isOptional: false,
170
- defaultValue: 10
171
- },
172
- maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
173
- timeoutMs: {
174
- type: ScalarTypeEnum2.Int_unsecure(),
175
- isOptional: false,
176
- defaultValue: 120000
177
- },
178
- version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
179
- tags: {
180
- type: ScalarTypeEnum2.String_unsecure(),
181
- isArray: true,
182
- isOptional: true
183
- },
184
- createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
185
- updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
186
- }
187
- });
188
- var AgentSummaryModel = defineSchemaModel2({
189
- name: "AgentSummary",
190
- description: "Summary of an agent for list views",
191
- fields: {
192
- id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
193
- name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
194
- slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
195
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
196
- status: { type: AgentStatusEnum, isOptional: false },
197
- modelProvider: { type: ModelProviderEnum, isOptional: false },
198
- modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
199
- version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
200
- createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
201
- }
202
- });
203
- var AgentToolRefModel = defineSchemaModel2({
204
- name: "AgentToolRef",
205
- description: "Tool reference in agent context",
206
- fields: {
207
- id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
208
- name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
209
- slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
210
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
211
- category: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
212
- }
213
- });
214
- var AgentWithToolsModel = defineSchemaModel2({
215
- name: "AgentWithTools",
216
- description: "Agent with associated tools",
217
- fields: {
218
- id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
219
- organizationId: {
220
- type: ScalarTypeEnum2.String_unsecure(),
221
- isOptional: false
222
- },
223
- name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
224
- slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
225
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
226
- status: { type: AgentStatusEnum, isOptional: false },
227
- modelProvider: { type: ModelProviderEnum, isOptional: false },
228
- modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
229
- modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
230
- systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
231
- userPromptTemplate: {
232
- type: ScalarTypeEnum2.String_unsecure(),
233
- isOptional: true
234
- },
235
- toolIds: {
236
- type: ScalarTypeEnum2.String_unsecure(),
237
- isArray: true,
238
- isOptional: true
239
- },
240
- toolChoice: { type: ToolChoiceEnum, isOptional: false },
241
- maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
242
- maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
243
- timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
244
- version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
245
- tags: {
246
- type: ScalarTypeEnum2.String_unsecure(),
247
- isArray: true,
248
- isOptional: true
249
- },
250
- createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
251
- updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
252
- tools: { type: AgentToolRefModel, isArray: true, isOptional: true }
253
- }
254
- });
255
- var CreateAgentInputModel = defineSchemaModel2({
256
- name: "CreateAgentInput",
257
- description: "Input for creating an agent",
258
- fields: {
259
- organizationId: {
260
- type: ScalarTypeEnum2.String_unsecure(),
261
- isOptional: false
262
- },
263
- name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
264
- slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
265
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
266
- modelProvider: { type: ModelProviderEnum, isOptional: false },
267
- modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
268
- modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
269
- systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
270
- userPromptTemplate: {
271
- type: ScalarTypeEnum2.String_unsecure(),
272
- isOptional: true
273
- },
274
- toolIds: {
275
- type: ScalarTypeEnum2.String_unsecure(),
276
- isArray: true,
277
- isOptional: true
278
- },
279
- toolChoice: { type: ToolChoiceEnum, isOptional: true },
280
- maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
281
- maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
282
- timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
283
- tags: {
284
- type: ScalarTypeEnum2.String_unsecure(),
285
- isArray: true,
286
- isOptional: true
287
- }
288
- }
289
- });
290
- var UpdateAgentInputModel = defineSchemaModel2({
291
- name: "UpdateAgentInput",
292
- description: "Input for updating an agent",
293
- fields: {
294
- agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
295
- name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: true },
296
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
297
- status: { type: AgentStatusEnum, isOptional: true },
298
- modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
299
- systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
300
- userPromptTemplate: {
301
- type: ScalarTypeEnum2.String_unsecure(),
302
- isOptional: true
303
- },
304
- toolIds: {
305
- type: ScalarTypeEnum2.String_unsecure(),
306
- isArray: true,
307
- isOptional: true
308
- },
309
- toolChoice: { type: ToolChoiceEnum, isOptional: true },
310
- maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
311
- maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
312
- timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
313
- tags: {
314
- type: ScalarTypeEnum2.String_unsecure(),
315
- isArray: true,
316
- isOptional: true
317
- }
318
- }
319
- });
320
-
321
- // src/agent/agent.operation.ts
322
- import {
323
- defineCommand,
324
- defineQuery
325
- } from "@contractspec/lib.contracts-spec/operations";
326
- import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
327
- var OWNERS2 = ["@agent-console-team"];
328
- var CreateAgentCommand = defineCommand({
329
- meta: {
330
- key: "agent-console.agent.create",
331
- version: "1.0.0",
332
- stability: "stable",
333
- owners: [...OWNERS2],
334
- tags: ["agent", "create"],
335
- description: "Creates a new AI agent configuration.",
336
- goal: "Allow users to define new AI agents with specific models and tools.",
337
- context: "Called from the agent builder UI when creating a new agent."
338
- },
339
- io: {
340
- input: CreateAgentInputModel,
341
- output: defineSchemaModel3({
342
- name: "CreateAgentOutput",
343
- fields: {
344
- id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
345
- name: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
346
- slug: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
347
- status: { type: AgentStatusEnum, isOptional: false }
348
- }
349
- }),
350
- errors: {
351
- SLUG_EXISTS: {
352
- description: "An agent with this slug already exists in the organization",
353
- http: 409,
354
- gqlCode: "SLUG_EXISTS",
355
- when: "Slug is already taken"
356
- }
357
- }
358
- },
359
- policy: { auth: "user" },
360
- sideEffects: {
361
- emits: [
362
- {
363
- ref: AgentCreatedEvent.meta,
364
- when: "Agent is successfully created"
365
- }
366
- ],
367
- audit: ["agent-console.agent.created"]
368
- },
369
- acceptance: {
370
- scenarios: [
371
- {
372
- key: "create-agent-happy-path",
373
- given: ["User is authenticated", "Organization exists"],
374
- when: ["User submits valid agent configuration"],
375
- then: [
376
- "New agent is created with DRAFT status",
377
- "AgentCreated event is emitted"
378
- ]
379
- },
380
- {
381
- key: "create-agent-slug-conflict",
382
- given: ["User is authenticated", "Agent with same slug exists"],
383
- when: ["User submits agent with duplicate slug"],
384
- then: ["SLUG_EXISTS error is returned with 409 status"]
385
- }
386
- ],
387
- examples: [
388
- {
389
- key: "basic-create",
390
- input: {
391
- name: "Support Assistant",
392
- slug: "support-assistant",
393
- modelProvider: "openai",
394
- modelId: "gpt-4"
395
- },
396
- output: {
397
- id: "agent-123",
398
- name: "Support Assistant",
399
- slug: "support-assistant",
400
- status: "draft"
401
- }
402
- }
403
- ]
404
- }
405
- });
406
- var UpdateAgentCommand = defineCommand({
407
- meta: {
408
- key: "agent-console.agent.update",
409
- version: "1.0.0",
410
- stability: "stable",
411
- owners: [...OWNERS2],
412
- tags: ["agent", "update"],
413
- description: "Updates an existing AI agent configuration.",
414
- goal: "Allow users to modify agent settings and configuration.",
415
- context: "Called from the agent settings UI."
416
- },
417
- io: {
418
- input: UpdateAgentInputModel,
419
- output: defineSchemaModel3({
420
- name: "UpdateAgentOutput",
421
- fields: {
422
- id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
423
- name: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
424
- status: { type: AgentStatusEnum, isOptional: false },
425
- updatedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
426
- }
427
- }),
428
- errors: {
429
- AGENT_NOT_FOUND: {
430
- description: "The specified agent does not exist",
431
- http: 404,
432
- gqlCode: "AGENT_NOT_FOUND",
433
- when: "Agent ID is invalid"
434
- }
435
- }
436
- },
437
- policy: { auth: "user" },
438
- sideEffects: {
439
- emits: [
440
- {
441
- key: "agent.updated",
442
- version: "1.0.0",
443
- stability: "stable",
444
- owners: [...OWNERS2],
445
- tags: ["agent", "updated"],
446
- when: "Agent is updated",
447
- payload: AgentSummaryModel
448
- }
449
- ],
450
- audit: ["agent.updated"]
451
- },
452
- acceptance: {
453
- scenarios: [
454
- {
455
- key: "update-agent-happy-path",
456
- given: ["Agent exists", "User owns the agent"],
457
- when: ["User submits updated configuration"],
458
- then: ["Agent is updated", "AgentUpdated event is emitted"]
459
- },
460
- {
461
- key: "update-agent-not-found",
462
- given: ["Agent does not exist"],
463
- when: ["User attempts to update"],
464
- then: ["AGENT_NOT_FOUND error is returned"]
465
- }
466
- ],
467
- examples: [
468
- {
469
- key: "update-name",
470
- input: {
471
- agentId: "agent-123",
472
- name: "Updated Assistant",
473
- systemPrompt: "You are a helpful assistant."
474
- },
475
- output: {
476
- id: "agent-123",
477
- name: "Updated Assistant",
478
- status: "draft",
479
- updatedAt: "2025-01-01T00:00:00Z"
480
- }
481
- }
482
- ]
483
- }
484
- });
485
- var GetAgentQuery = defineQuery({
486
- meta: {
487
- key: "agent-console.agent.get",
488
- version: "1.0.0",
489
- stability: "stable",
490
- owners: [...OWNERS2],
491
- tags: ["agent", "get"],
492
- description: "Retrieves an agent by its ID.",
493
- goal: "View detailed agent configuration.",
494
- context: "Called when viewing agent details or editing."
495
- },
496
- io: {
497
- input: defineSchemaModel3({
498
- name: "GetAgentInput",
499
- fields: {
500
- agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
501
- includeTools: { type: ScalarTypeEnum3.Boolean(), isOptional: true }
502
- }
503
- }),
504
- output: AgentWithToolsModel,
505
- errors: {
506
- AGENT_NOT_FOUND: {
507
- description: "The specified agent does not exist",
508
- http: 404,
509
- gqlCode: "AGENT_NOT_FOUND",
510
- when: "Agent ID is invalid"
511
- }
512
- }
513
- },
514
- policy: { auth: "user" },
515
- acceptance: {
516
- scenarios: [
517
- {
518
- key: "get-agent-happy-path",
519
- given: ["Agent exists"],
520
- when: ["User requests agent by ID"],
521
- then: ["Agent details are returned"]
522
- },
523
- {
524
- key: "get-agent-with-tools",
525
- given: ["Agent exists with assigned tools"],
526
- when: ["User requests agent with includeTools=true"],
527
- then: ["Agent details with tools list are returned"]
528
- }
529
- ],
530
- examples: [
531
- {
532
- key: "get-basic",
533
- input: { agentId: "agent-123", includeTools: false },
534
- output: {
535
- id: "agent-123",
536
- name: "Support Assistant",
537
- status: "active",
538
- tools: []
539
- }
540
- }
541
- ]
542
- }
543
- });
544
- var ListAgentsQuery = defineQuery({
545
- meta: {
546
- key: "agent-console.agent.list",
547
- version: "1.0.0",
548
- stability: "stable",
549
- owners: [...OWNERS2],
550
- tags: ["agent", "list"],
551
- description: "Lists agents for an organization with optional filtering.",
552
- goal: "Browse and search available agents.",
553
- context: "Agent list/dashboard view."
554
- },
555
- io: {
556
- input: defineSchemaModel3({
557
- name: "ListAgentsInput",
558
- fields: {
559
- organizationId: {
560
- type: ScalarTypeEnum3.String_unsecure(),
561
- isOptional: false
562
- },
563
- status: { type: AgentStatusEnum, isOptional: true },
564
- modelProvider: { type: ModelProviderEnum, isOptional: true },
565
- search: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
566
- limit: {
567
- type: ScalarTypeEnum3.Int_unsecure(),
568
- isOptional: true,
569
- defaultValue: 20
570
- },
571
- offset: {
572
- type: ScalarTypeEnum3.Int_unsecure(),
573
- isOptional: true,
574
- defaultValue: 0
575
- }
576
- }
577
- }),
578
- output: defineSchemaModel3({
579
- name: "ListAgentsOutput",
580
- fields: {
581
- items: { type: AgentSummaryModel, isArray: true, isOptional: false },
582
- total: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
583
- hasMore: { type: ScalarTypeEnum3.Boolean(), isOptional: false }
584
- }
585
- })
586
- },
587
- policy: { auth: "user" },
588
- acceptance: {
589
- scenarios: [
590
- {
591
- key: "list-agents-happy-path",
592
- given: ["Organization has agents"],
593
- when: ["User lists agents"],
594
- then: ["Paginated list of agents is returned"]
595
- },
596
- {
597
- key: "list-agents-filter-by-status",
598
- given: ["Organization has agents with mixed statuses"],
599
- when: ["User filters by status=active"],
600
- then: ["Only active agents are returned"]
601
- }
602
- ],
603
- examples: [
604
- {
605
- key: "list-basic",
606
- input: { organizationId: "org-123", limit: 10, offset: 0 },
607
- output: { items: [], total: 0, hasMore: false }
608
- }
609
- ]
610
- }
611
- });
612
- var AssignToolToAgentCommand = defineCommand({
613
- meta: {
614
- key: "agent-console.agent.assignTool",
615
- version: "1.0.0",
616
- stability: "stable",
617
- owners: [...OWNERS2],
618
- tags: ["agent", "tool", "assign"],
619
- description: "Assigns a tool to an agent with optional configuration.",
620
- goal: "Enable agents to use specific tools.",
621
- context: "Agent configuration UI - tool selection."
622
- },
623
- io: {
624
- input: defineSchemaModel3({
625
- name: "AssignToolToAgentInput",
626
- fields: {
627
- agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
628
- toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
629
- config: { type: ScalarTypeEnum3.JSONObject(), isOptional: true },
630
- order: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: true }
631
- }
632
- }),
633
- output: defineSchemaModel3({
634
- name: "AssignToolToAgentOutput",
635
- fields: {
636
- agentToolId: {
637
- type: ScalarTypeEnum3.String_unsecure(),
638
- isOptional: false
639
- },
640
- agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
641
- toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
642
- }
643
- }),
644
- errors: {
645
- TOOL_ALREADY_ASSIGNED: {
646
- description: "This tool is already assigned to the agent",
647
- http: 409,
648
- gqlCode: "TOOL_ALREADY_ASSIGNED",
649
- when: "Tool assignment already exists"
650
- }
651
- }
652
- },
653
- policy: { auth: "user" },
654
- sideEffects: { audit: ["agent.tool.assigned"] },
655
- acceptance: {
656
- scenarios: [
657
- {
658
- key: "assign-tool-happy-path",
659
- given: ["Agent exists", "Tool exists and is not assigned"],
660
- when: ["User assigns tool to agent"],
661
- then: ["Tool is assigned", "Assignment ID is returned"]
662
- },
663
- {
664
- key: "assign-tool-already-assigned",
665
- given: ["Tool is already assigned to agent"],
666
- when: ["User attempts to assign again"],
667
- then: ["TOOL_ALREADY_ASSIGNED error is returned"]
668
- }
669
- ],
670
- examples: [
671
- {
672
- key: "assign-basic",
673
- input: { agentId: "agent-123", toolId: "tool-456" },
674
- output: {
675
- agentToolId: "at-789",
676
- agentId: "agent-123",
677
- toolId: "tool-456"
678
- }
679
- }
680
- ]
681
- }
682
- });
683
- var RemoveToolFromAgentCommand = defineCommand({
684
- meta: {
685
- key: "agent-console.agent.removeTool",
686
- version: "1.0.0",
687
- stability: "stable",
688
- owners: [...OWNERS2],
689
- tags: ["agent", "tool", "remove"],
690
- description: "Removes a tool assignment from an agent.",
691
- goal: "Disable specific tools for an agent.",
692
- context: "Agent configuration UI - tool management."
693
- },
694
- io: {
695
- input: defineSchemaModel3({
696
- name: "RemoveToolFromAgentInput",
697
- fields: {
698
- agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
699
- toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
700
- }
701
- }),
702
- output: defineSchemaModel3({
703
- name: "RemoveToolFromAgentOutput",
704
- fields: {
705
- success: { type: ScalarTypeEnum3.Boolean(), isOptional: false }
706
- }
707
- })
708
- },
709
- policy: { auth: "user" },
710
- sideEffects: { audit: ["agent.tool.removed"] },
711
- acceptance: {
712
- scenarios: [
713
- {
714
- key: "remove-tool-happy-path",
715
- given: ["Agent exists", "Tool is assigned to agent"],
716
- when: ["User removes tool from agent"],
717
- then: ["Tool is unassigned", "Success is returned"]
718
- }
719
- ],
720
- examples: [
721
- {
722
- key: "remove-basic",
723
- input: { agentId: "agent-123", toolId: "tool-456" },
724
- output: { success: true }
725
- }
726
- ]
727
- }
728
- });
729
- export {
730
- UpdateAgentCommand,
731
- RemoveToolFromAgentCommand,
732
- ListAgentsQuery,
733
- GetAgentQuery,
734
- CreateAgentCommand,
735
- AssignToolToAgentCommand
736
- };
2
+ import{defineEnum as L}from"@contractspec/lib.schema";var w=L("AgentStatus",["DRAFT","ACTIVE","PAUSED","ARCHIVED"]),z=L("ModelProvider",["OPENAI","ANTHROPIC","GOOGLE","MISTRAL","CUSTOM"]),F=L("ToolChoice",["auto","required","none"]);import{defineEvent as G}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as H,ScalarTypeEnum as k}from"@contractspec/lib.schema";var J=["@agent-console-team"],Q=H({name:"AgentCreatedPayload",description:"Payload for agent created event",fields:{id:{type:k.String_unsecure(),isOptional:!1},organizationId:{type:k.String_unsecure(),isOptional:!1},name:{type:k.String_unsecure(),isOptional:!1},slug:{type:k.String_unsecure(),isOptional:!1},modelProvider:{type:k.String_unsecure(),isOptional:!1},modelName:{type:k.String_unsecure(),isOptional:!1},toolCount:{type:k.Int_unsecure(),isOptional:!1},createdById:{type:k.String_unsecure(),isOptional:!0},createdAt:{type:k.DateTime(),isOptional:!1}}}),X=G({meta:{key:"agent-console.agent.created",version:"1.0.0",description:"A new AI agent was configured.",stability:"stable",owners:[...J],tags:["agent","created"]},payload:Q}),U=H({name:"AgentUpdatedPayload",description:"Payload for agent updated event",fields:{id:{type:k.String_unsecure(),isOptional:!1},organizationId:{type:k.String_unsecure(),isOptional:!1},name:{type:k.String_unsecure(),isOptional:!1},status:{type:k.String_unsecure(),isOptional:!1},updatedFields:{type:k.String_unsecure(),isArray:!0,isOptional:!1},updatedAt:{type:k.DateTime(),isOptional:!1}}}),W=G({meta:{key:"agent-console.agent.updated",version:"1.0.0",description:"An AI agent configuration was updated.",stability:"stable",owners:[...J],tags:["agent","updated"]},payload:U}),I=H({name:"AgentToolAssignedPayload",description:"Payload for agent tool assigned event",fields:{agentId:{type:k.String_unsecure(),isOptional:!1},toolId:{type:k.String_unsecure(),isOptional:!1},agentName:{type:k.String_unsecure(),isOptional:!1},toolName:{type:k.String_unsecure(),isOptional:!1},assignedAt:{type:k.DateTime(),isOptional:!1}}}),R=G({meta:{key:"agent-console.agent.toolAssigned",version:"1.0.0",description:"A tool was assigned to an agent.",stability:"stable",owners:[...J],tags:["agent","tool","assigned"]},payload:I}),b=H({name:"AgentToolRemovedPayload",description:"Payload for agent tool removed event",fields:{agentId:{type:k.String_unsecure(),isOptional:!1},toolId:{type:k.String_unsecure(),isOptional:!1},agentName:{type:k.String_unsecure(),isOptional:!1},toolName:{type:k.String_unsecure(),isOptional:!1},removedAt:{type:k.DateTime(),isOptional:!1}}}),A=G({meta:{key:"agent-console.agent.toolRemoved",version:"1.0.0",description:"A tool was removed from an agent.",stability:"stable",owners:[...J],tags:["agent","tool","removed"]},payload:b});import{defineSchemaModel as D,ScalarTypeEnum as j}from"@contractspec/lib.schema";var M=D({name:"Agent",description:"AI agent configuration",fields:{id:{type:j.String_unsecure(),isOptional:!1},organizationId:{type:j.String_unsecure(),isOptional:!1},name:{type:j.NonEmptyString(),isOptional:!1},slug:{type:j.String_unsecure(),isOptional:!1},description:{type:j.String_unsecure(),isOptional:!0},status:{type:w,isOptional:!1},modelProvider:{type:z,isOptional:!1},modelName:{type:j.NonEmptyString(),isOptional:!1},modelConfig:{type:j.JSONObject(),isOptional:!0},systemPrompt:{type:j.String_unsecure(),isOptional:!1},userPromptTemplate:{type:j.String_unsecure(),isOptional:!0},toolIds:{type:j.String_unsecure(),isArray:!0,isOptional:!0},toolChoice:{type:F,isOptional:!1,defaultValue:"auto"},maxIterations:{type:j.Int_unsecure(),isOptional:!1,defaultValue:10},maxTokensPerRun:{type:j.Int_unsecure(),isOptional:!0},timeoutMs:{type:j.Int_unsecure(),isOptional:!1,defaultValue:120000},version:{type:j.NonEmptyString(),isOptional:!1},tags:{type:j.String_unsecure(),isArray:!0,isOptional:!0},createdAt:{type:j.DateTime(),isOptional:!1},updatedAt:{type:j.DateTime(),isOptional:!1}}}),V=D({name:"AgentSummary",description:"Summary of an agent for list views",fields:{id:{type:j.String_unsecure(),isOptional:!1},name:{type:j.NonEmptyString(),isOptional:!1},slug:{type:j.String_unsecure(),isOptional:!1},description:{type:j.String_unsecure(),isOptional:!0},status:{type:w,isOptional:!1},modelProvider:{type:z,isOptional:!1},modelName:{type:j.NonEmptyString(),isOptional:!1},version:{type:j.NonEmptyString(),isOptional:!1},createdAt:{type:j.DateTime(),isOptional:!1}}}),P=D({name:"AgentToolRef",description:"Tool reference in agent context",fields:{id:{type:j.String_unsecure(),isOptional:!1},name:{type:j.NonEmptyString(),isOptional:!1},slug:{type:j.String_unsecure(),isOptional:!1},description:{type:j.String_unsecure(),isOptional:!1},category:{type:j.String_unsecure(),isOptional:!1}}}),Y=D({name:"AgentWithTools",description:"Agent with associated tools",fields:{id:{type:j.String_unsecure(),isOptional:!1},organizationId:{type:j.String_unsecure(),isOptional:!1},name:{type:j.NonEmptyString(),isOptional:!1},slug:{type:j.String_unsecure(),isOptional:!1},description:{type:j.String_unsecure(),isOptional:!0},status:{type:w,isOptional:!1},modelProvider:{type:z,isOptional:!1},modelName:{type:j.NonEmptyString(),isOptional:!1},modelConfig:{type:j.JSONObject(),isOptional:!0},systemPrompt:{type:j.String_unsecure(),isOptional:!1},userPromptTemplate:{type:j.String_unsecure(),isOptional:!0},toolIds:{type:j.String_unsecure(),isArray:!0,isOptional:!0},toolChoice:{type:F,isOptional:!1},maxIterations:{type:j.Int_unsecure(),isOptional:!1},maxTokensPerRun:{type:j.Int_unsecure(),isOptional:!0},timeoutMs:{type:j.Int_unsecure(),isOptional:!1},version:{type:j.NonEmptyString(),isOptional:!1},tags:{type:j.String_unsecure(),isArray:!0,isOptional:!0},createdAt:{type:j.DateTime(),isOptional:!1},updatedAt:{type:j.DateTime(),isOptional:!1},tools:{type:P,isArray:!0,isOptional:!0}}}),Z=D({name:"CreateAgentInput",description:"Input for creating an agent",fields:{organizationId:{type:j.String_unsecure(),isOptional:!1},name:{type:j.NonEmptyString(),isOptional:!1},slug:{type:j.String_unsecure(),isOptional:!1},description:{type:j.String_unsecure(),isOptional:!0},modelProvider:{type:z,isOptional:!1},modelName:{type:j.NonEmptyString(),isOptional:!1},modelConfig:{type:j.JSONObject(),isOptional:!0},systemPrompt:{type:j.String_unsecure(),isOptional:!1},userPromptTemplate:{type:j.String_unsecure(),isOptional:!0},toolIds:{type:j.String_unsecure(),isArray:!0,isOptional:!0},toolChoice:{type:F,isOptional:!0},maxIterations:{type:j.Int_unsecure(),isOptional:!0},maxTokensPerRun:{type:j.Int_unsecure(),isOptional:!0},timeoutMs:{type:j.Int_unsecure(),isOptional:!0},tags:{type:j.String_unsecure(),isArray:!0,isOptional:!0}}}),_=D({name:"UpdateAgentInput",description:"Input for updating an agent",fields:{agentId:{type:j.String_unsecure(),isOptional:!1},name:{type:j.NonEmptyString(),isOptional:!0},description:{type:j.String_unsecure(),isOptional:!0},status:{type:w,isOptional:!0},modelConfig:{type:j.JSONObject(),isOptional:!0},systemPrompt:{type:j.String_unsecure(),isOptional:!0},userPromptTemplate:{type:j.String_unsecure(),isOptional:!0},toolIds:{type:j.String_unsecure(),isArray:!0,isOptional:!0},toolChoice:{type:F,isOptional:!0},maxIterations:{type:j.Int_unsecure(),isOptional:!0},maxTokensPerRun:{type:j.Int_unsecure(),isOptional:!0},timeoutMs:{type:j.Int_unsecure(),isOptional:!0},tags:{type:j.String_unsecure(),isArray:!0,isOptional:!0}}});import{defineCommand as K,defineQuery as $}from"@contractspec/lib.contracts-spec/operations";import{defineSchemaModel as x,ScalarTypeEnum as q}from"@contractspec/lib.schema";var B=["@agent-console-team"],T=K({meta:{key:"agent-console.agent.create",version:"1.0.0",stability:"stable",owners:[...B],tags:["agent","create"],description:"Creates a new AI agent configuration.",goal:"Allow users to define new AI agents with specific models and tools.",context:"Called from the agent builder UI when creating a new agent."},io:{input:Z,output:x({name:"CreateAgentOutput",fields:{id:{type:q.String_unsecure(),isOptional:!1},name:{type:q.NonEmptyString(),isOptional:!1},slug:{type:q.String_unsecure(),isOptional:!1},status:{type:w,isOptional:!1}}}),errors:{SLUG_EXISTS:{description:"An agent with this slug already exists in the organization",http:409,gqlCode:"SLUG_EXISTS",when:"Slug is already taken"}}},policy:{auth:"user"},sideEffects:{emits:[{ref:X.meta,when:"Agent is successfully created"}],audit:["agent-console.agent.created"]},acceptance:{scenarios:[{key:"create-agent-happy-path",given:["User is authenticated","Organization exists"],when:["User submits valid agent configuration"],then:["New agent is created with DRAFT status","AgentCreated event is emitted"]},{key:"create-agent-slug-conflict",given:["User is authenticated","Agent with same slug exists"],when:["User submits agent with duplicate slug"],then:["SLUG_EXISTS error is returned with 409 status"]}],examples:[{key:"basic-create",input:{name:"Support Assistant",slug:"support-assistant",modelProvider:"openai",modelId:"gpt-4"},output:{id:"agent-123",name:"Support Assistant",slug:"support-assistant",status:"draft"}}]}}),p=K({meta:{key:"agent-console.agent.update",version:"1.0.0",stability:"stable",owners:[...B],tags:["agent","update"],description:"Updates an existing AI agent configuration.",goal:"Allow users to modify agent settings and configuration.",context:"Called from the agent settings UI."},io:{input:_,output:x({name:"UpdateAgentOutput",fields:{id:{type:q.String_unsecure(),isOptional:!1},name:{type:q.NonEmptyString(),isOptional:!1},status:{type:w,isOptional:!1},updatedAt:{type:q.DateTime(),isOptional:!1}}}),errors:{AGENT_NOT_FOUND:{description:"The specified agent does not exist",http:404,gqlCode:"AGENT_NOT_FOUND",when:"Agent ID is invalid"}}},policy:{auth:"user"},sideEffects:{emits:[{key:"agent.updated",version:"1.0.0",stability:"stable",owners:[...B],tags:["agent","updated"],when:"Agent is updated",payload:V}],audit:["agent.updated"]},acceptance:{scenarios:[{key:"update-agent-happy-path",given:["Agent exists","User owns the agent"],when:["User submits updated configuration"],then:["Agent is updated","AgentUpdated event is emitted"]},{key:"update-agent-not-found",given:["Agent does not exist"],when:["User attempts to update"],then:["AGENT_NOT_FOUND error is returned"]}],examples:[{key:"update-name",input:{agentId:"agent-123",name:"Updated Assistant",systemPrompt:"You are a helpful assistant."},output:{id:"agent-123",name:"Updated Assistant",status:"draft",updatedAt:"2025-01-01T00:00:00Z"}}]}}),r=$({meta:{key:"agent-console.agent.get",version:"1.0.0",stability:"stable",owners:[...B],tags:["agent","get"],description:"Retrieves an agent by its ID.",goal:"View detailed agent configuration.",context:"Called when viewing agent details or editing."},io:{input:x({name:"GetAgentInput",fields:{agentId:{type:q.String_unsecure(),isOptional:!1},includeTools:{type:q.Boolean(),isOptional:!0}}}),output:Y,errors:{AGENT_NOT_FOUND:{description:"The specified agent does not exist",http:404,gqlCode:"AGENT_NOT_FOUND",when:"Agent ID is invalid"}}},policy:{auth:"user"},acceptance:{scenarios:[{key:"get-agent-happy-path",given:["Agent exists"],when:["User requests agent by ID"],then:["Agent details are returned"]},{key:"get-agent-with-tools",given:["Agent exists with assigned tools"],when:["User requests agent with includeTools=true"],then:["Agent details with tools list are returned"]}],examples:[{key:"get-basic",input:{agentId:"agent-123",includeTools:!1},output:{id:"agent-123",name:"Support Assistant",status:"active",tools:[]}}]}}),E=$({meta:{key:"agent-console.agent.list",version:"1.0.0",stability:"stable",owners:[...B],tags:["agent","list"],description:"Lists agents for an organization with optional filtering.",goal:"Browse and search available agents.",context:"Agent list/dashboard view."},io:{input:x({name:"ListAgentsInput",fields:{organizationId:{type:q.String_unsecure(),isOptional:!1},status:{type:w,isOptional:!0},modelProvider:{type:z,isOptional:!0},search:{type:q.String_unsecure(),isOptional:!0},limit:{type:q.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:q.Int_unsecure(),isOptional:!0,defaultValue:0}}}),output:x({name:"ListAgentsOutput",fields:{items:{type:V,isArray:!0,isOptional:!1},total:{type:q.Int_unsecure(),isOptional:!1},hasMore:{type:q.Boolean(),isOptional:!1}}})},policy:{auth:"user"},acceptance:{scenarios:[{key:"list-agents-happy-path",given:["Organization has agents"],when:["User lists agents"],then:["Paginated list of agents is returned"]},{key:"list-agents-filter-by-status",given:["Organization has agents with mixed statuses"],when:["User filters by status=active"],then:["Only active agents are returned"]}],examples:[{key:"list-basic",input:{organizationId:"org-123",limit:10,offset:0},output:{items:[],total:0,hasMore:!1}}]}}),u=K({meta:{key:"agent-console.agent.assignTool",version:"1.0.0",stability:"stable",owners:[...B],tags:["agent","tool","assign"],description:"Assigns a tool to an agent with optional configuration.",goal:"Enable agents to use specific tools.",context:"Agent configuration UI - tool selection."},io:{input:x({name:"AssignToolToAgentInput",fields:{agentId:{type:q.String_unsecure(),isOptional:!1},toolId:{type:q.String_unsecure(),isOptional:!1},config:{type:q.JSONObject(),isOptional:!0},order:{type:q.Int_unsecure(),isOptional:!0}}}),output:x({name:"AssignToolToAgentOutput",fields:{agentToolId:{type:q.String_unsecure(),isOptional:!1},agentId:{type:q.String_unsecure(),isOptional:!1},toolId:{type:q.String_unsecure(),isOptional:!1}}}),errors:{TOOL_ALREADY_ASSIGNED:{description:"This tool is already assigned to the agent",http:409,gqlCode:"TOOL_ALREADY_ASSIGNED",when:"Tool assignment already exists"}}},policy:{auth:"user"},sideEffects:{audit:["agent.tool.assigned"]},acceptance:{scenarios:[{key:"assign-tool-happy-path",given:["Agent exists","Tool exists and is not assigned"],when:["User assigns tool to agent"],then:["Tool is assigned","Assignment ID is returned"]},{key:"assign-tool-already-assigned",given:["Tool is already assigned to agent"],when:["User attempts to assign again"],then:["TOOL_ALREADY_ASSIGNED error is returned"]}],examples:[{key:"assign-basic",input:{agentId:"agent-123",toolId:"tool-456"},output:{agentToolId:"at-789",agentId:"agent-123",toolId:"tool-456"}}]}}),S=K({meta:{key:"agent-console.agent.removeTool",version:"1.0.0",stability:"stable",owners:[...B],tags:["agent","tool","remove"],description:"Removes a tool assignment from an agent.",goal:"Disable specific tools for an agent.",context:"Agent configuration UI - tool management."},io:{input:x({name:"RemoveToolFromAgentInput",fields:{agentId:{type:q.String_unsecure(),isOptional:!1},toolId:{type:q.String_unsecure(),isOptional:!1}}}),output:x({name:"RemoveToolFromAgentOutput",fields:{success:{type:q.Boolean(),isOptional:!1}}})},policy:{auth:"user"},sideEffects:{audit:["agent.tool.removed"]},acceptance:{scenarios:[{key:"remove-tool-happy-path",given:["Agent exists","Tool is assigned to agent"],when:["User removes tool from agent"],then:["Tool is unassigned","Success is returned"]}],examples:[{key:"remove-basic",input:{agentId:"agent-123",toolId:"tool-456"},output:{success:!0}}]}});export{p as UpdateAgentCommand,S as RemoveToolFromAgentCommand,E as ListAgentsQuery,r as GetAgentQuery,T as CreateAgentCommand,u as AssignToolToAgentCommand};