@contractspec/example.agent-console 3.8.8 → 3.8.10

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 +34 -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 +29 -13
  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,1249 +1,2 @@
1
1
  // @bun
2
- // src/agent/agent.entity.ts
3
- import {
4
- defineEntity,
5
- defineEntityEnum,
6
- field,
7
- index
8
- } from "@contractspec/lib.schema";
9
- var AgentStatusEntityEnum = defineEntityEnum({
10
- name: "AgentStatus",
11
- values: ["DRAFT", "ACTIVE", "PAUSED", "ARCHIVED"],
12
- description: "Lifecycle status of the agent"
13
- });
14
- var ModelProviderEntityEnum = defineEntityEnum({
15
- name: "ModelProvider",
16
- values: ["OPENAI", "ANTHROPIC", "GOOGLE", "MISTRAL", "CUSTOM"],
17
- description: "AI model provider"
18
- });
19
- var AgentEntity = defineEntity({
20
- name: "Agent",
21
- schema: "agent_console",
22
- description: "Represents an AI agent configuration with assigned tools and parameters.",
23
- fields: {
24
- id: field.id(),
25
- organizationId: field.string({
26
- description: "Organization that owns this agent"
27
- }),
28
- name: field.string({ description: "Agent name (1-100 chars)" }),
29
- slug: field.string({
30
- description: "URL-safe identifier (lowercase, numbers, hyphens)"
31
- }),
32
- description: field.string({
33
- isOptional: true,
34
- description: "Agent description (max 1000 chars)"
35
- }),
36
- status: field.enum("AgentStatus", { default: "DRAFT" }),
37
- modelProvider: field.enum("ModelProvider", { default: "OPENAI" }),
38
- modelName: field.string({
39
- description: "Model identifier: 'gpt-4', 'claude-3-opus', etc."
40
- }),
41
- modelConfig: field.json({
42
- isOptional: true,
43
- description: "Model parameters: temperature, max_tokens, etc."
44
- }),
45
- systemPrompt: field.string({ description: "System prompt for the agent" }),
46
- userPromptTemplate: field.string({
47
- isOptional: true,
48
- description: "Template for user prompts"
49
- }),
50
- toolIds: field.string({
51
- isArray: true,
52
- isOptional: true,
53
- description: "IDs of assigned tools"
54
- }),
55
- toolChoice: field.string({
56
- default: "auto",
57
- description: "Tool selection mode: 'auto', 'required', 'none'"
58
- }),
59
- maxIterations: field.int({
60
- default: 10,
61
- description: "Maximum iterations per run"
62
- }),
63
- maxTokensPerRun: field.int({
64
- isOptional: true,
65
- description: "Maximum tokens per run"
66
- }),
67
- timeoutMs: field.int({
68
- default: 120000,
69
- description: "Execution timeout in milliseconds"
70
- }),
71
- version: field.string({ default: "1.0.0", description: "Agent version" }),
72
- tags: field.string({
73
- isArray: true,
74
- isOptional: true,
75
- description: "Tags for categorization"
76
- }),
77
- createdAt: field.createdAt(),
78
- updatedAt: field.updatedAt(),
79
- createdById: field.string({
80
- isOptional: true,
81
- description: "User who created this agent"
82
- }),
83
- tools: field.hasMany("Tool", {
84
- description: "Tools assigned to this agent"
85
- })
86
- },
87
- indexes: [
88
- index.unique(["organizationId", "slug"]),
89
- index.on(["organizationId", "status"]),
90
- index.on(["modelProvider", "modelName"])
91
- ],
92
- enums: [AgentStatusEntityEnum, ModelProviderEntityEnum]
93
- });
94
- var AgentToolEntity = defineEntity({
95
- name: "AgentTool",
96
- schema: "agent_console",
97
- description: "Links an agent to its assigned tools with configuration.",
98
- fields: {
99
- id: field.id(),
100
- agentId: field.foreignKey({ description: "Agent ID" }),
101
- toolId: field.foreignKey({ description: "Tool ID" }),
102
- config: field.json({
103
- isOptional: true,
104
- description: "Tool-specific configuration for this agent"
105
- }),
106
- order: field.int({
107
- default: 0,
108
- description: "Order of tool in agent tool list"
109
- }),
110
- isEnabled: field.boolean({
111
- default: true,
112
- description: "Whether tool is enabled for this agent"
113
- }),
114
- createdAt: field.createdAt(),
115
- agent: field.belongsTo("Agent", ["agentId"], ["id"]),
116
- tool: field.belongsTo("Tool", ["toolId"], ["id"])
117
- },
118
- indexes: [
119
- index.unique(["agentId", "toolId"]),
120
- index.on(["agentId", "order"])
121
- ]
122
- });
123
-
124
- // src/agent/agent.enum.ts
125
- import { defineEnum } from "@contractspec/lib.schema";
126
- var AgentStatusEnum = defineEnum("AgentStatus", [
127
- "DRAFT",
128
- "ACTIVE",
129
- "PAUSED",
130
- "ARCHIVED"
131
- ]);
132
- var ModelProviderEnum = defineEnum("ModelProvider", [
133
- "OPENAI",
134
- "ANTHROPIC",
135
- "GOOGLE",
136
- "MISTRAL",
137
- "CUSTOM"
138
- ]);
139
- var ToolChoiceEnum = defineEnum("ToolChoice", [
140
- "auto",
141
- "required",
142
- "none"
143
- ]);
144
-
145
- // src/agent/agent.event.ts
146
- import { defineEvent } from "@contractspec/lib.contracts-spec";
147
- import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
148
- var OWNERS = ["@agent-console-team"];
149
- var AgentCreatedPayload = defineSchemaModel({
150
- name: "AgentCreatedPayload",
151
- description: "Payload for agent created event",
152
- fields: {
153
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
154
- organizationId: {
155
- type: ScalarTypeEnum.String_unsecure(),
156
- isOptional: false
157
- },
158
- name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
159
- slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
160
- modelProvider: {
161
- type: ScalarTypeEnum.String_unsecure(),
162
- isOptional: false
163
- },
164
- modelName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
165
- toolCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
166
- createdById: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
167
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
168
- }
169
- });
170
- var AgentCreatedEvent = defineEvent({
171
- meta: {
172
- key: "agent-console.agent.created",
173
- version: "1.0.0",
174
- description: "A new AI agent was configured.",
175
- stability: "stable",
176
- owners: [...OWNERS],
177
- tags: ["agent", "created"]
178
- },
179
- payload: AgentCreatedPayload
180
- });
181
- var AgentUpdatedPayload = defineSchemaModel({
182
- name: "AgentUpdatedPayload",
183
- description: "Payload for agent updated event",
184
- fields: {
185
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
186
- organizationId: {
187
- type: ScalarTypeEnum.String_unsecure(),
188
- isOptional: false
189
- },
190
- name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
191
- status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
192
- updatedFields: {
193
- type: ScalarTypeEnum.String_unsecure(),
194
- isArray: true,
195
- isOptional: false
196
- },
197
- updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
198
- }
199
- });
200
- var AgentUpdatedEvent = defineEvent({
201
- meta: {
202
- key: "agent-console.agent.updated",
203
- version: "1.0.0",
204
- description: "An AI agent configuration was updated.",
205
- stability: "stable",
206
- owners: [...OWNERS],
207
- tags: ["agent", "updated"]
208
- },
209
- payload: AgentUpdatedPayload
210
- });
211
- var AgentToolAssignedPayload = defineSchemaModel({
212
- name: "AgentToolAssignedPayload",
213
- description: "Payload for agent tool assigned event",
214
- fields: {
215
- agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
216
- toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
217
- agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
218
- toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
219
- assignedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
220
- }
221
- });
222
- var AgentToolAssignedEvent = defineEvent({
223
- meta: {
224
- key: "agent-console.agent.toolAssigned",
225
- version: "1.0.0",
226
- description: "A tool was assigned to an agent.",
227
- stability: "stable",
228
- owners: [...OWNERS],
229
- tags: ["agent", "tool", "assigned"]
230
- },
231
- payload: AgentToolAssignedPayload
232
- });
233
- var AgentToolRemovedPayload = defineSchemaModel({
234
- name: "AgentToolRemovedPayload",
235
- description: "Payload for agent tool removed event",
236
- fields: {
237
- agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
238
- toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
239
- agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
240
- toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
241
- removedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
242
- }
243
- });
244
- var AgentToolRemovedEvent = defineEvent({
245
- meta: {
246
- key: "agent-console.agent.toolRemoved",
247
- version: "1.0.0",
248
- description: "A tool was removed from an agent.",
249
- stability: "stable",
250
- owners: [...OWNERS],
251
- tags: ["agent", "tool", "removed"]
252
- },
253
- payload: AgentToolRemovedPayload
254
- });
255
-
256
- // src/shared/mock-agents.ts
257
- var MOCK_AGENTS = [
258
- {
259
- id: "agent-1",
260
- organizationId: "demo-org",
261
- name: "Customer Support Bot",
262
- slug: "customer-support-bot",
263
- description: "Handles tier-1 customer inquiries and routes complex issues.",
264
- status: "ACTIVE",
265
- modelProvider: "OPENAI",
266
- modelName: "gpt-4o-mini",
267
- modelConfig: { temperature: 0.7 },
268
- systemPrompt: "You are a helpful customer support assistant.",
269
- toolChoice: "auto",
270
- maxIterations: 10,
271
- timeoutMs: 120000,
272
- version: "1.0.0",
273
- tags: ["support", "tier-1"],
274
- createdAt: new Date("2024-01-15T10:00:00Z"),
275
- updatedAt: new Date("2024-03-20T14:30:00Z")
276
- },
277
- {
278
- id: "agent-2",
279
- organizationId: "demo-org",
280
- name: "Code Review Assistant",
281
- slug: "code-review-assistant",
282
- description: "Reviews pull requests and provides actionable feedback.",
283
- status: "ACTIVE",
284
- modelProvider: "ANTHROPIC",
285
- modelName: "claude-sonnet-4-20250514",
286
- modelConfig: { temperature: 0.3 },
287
- systemPrompt: "You are a code review expert.",
288
- toolChoice: "auto",
289
- maxIterations: 15,
290
- timeoutMs: 180000,
291
- version: "2.1.0",
292
- tags: ["code", "review", "dev"],
293
- createdAt: new Date("2024-02-10T09:00:00Z"),
294
- updatedAt: new Date("2024-04-05T11:15:00Z")
295
- },
296
- {
297
- id: "agent-3",
298
- organizationId: "demo-org",
299
- name: "Data Analyst",
300
- slug: "data-analyst",
301
- description: "Queries databases and generates insights from data.",
302
- status: "PAUSED",
303
- modelProvider: "OPENAI",
304
- modelName: "gpt-4o",
305
- modelConfig: { temperature: 0.5 },
306
- systemPrompt: "You are a data analyst expert in SQL and analytics.",
307
- toolChoice: "required",
308
- maxIterations: 20,
309
- timeoutMs: 300000,
310
- version: "1.2.0",
311
- tags: ["data", "analytics", "sql"],
312
- createdAt: new Date("2024-03-01T08:00:00Z"),
313
- updatedAt: new Date("2024-04-10T16:45:00Z")
314
- },
315
- {
316
- id: "agent-4",
317
- organizationId: "demo-org",
318
- name: "Meeting Scheduler",
319
- slug: "meeting-scheduler",
320
- description: "Schedules meetings and manages calendar conflicts.",
321
- status: "DRAFT",
322
- modelProvider: "GOOGLE",
323
- modelName: "gemini-2.0-flash",
324
- modelConfig: { temperature: 0.2 },
325
- systemPrompt: "You help schedule and organize meetings efficiently.",
326
- toolChoice: "auto",
327
- maxIterations: 5,
328
- timeoutMs: 60000,
329
- version: "0.1.0",
330
- tags: ["calendar", "scheduling"],
331
- createdAt: new Date("2024-04-01T12:00:00Z"),
332
- updatedAt: new Date("2024-04-01T12:00:00Z")
333
- }
334
- ];
335
-
336
- // src/shared/mock-tools.ts
337
- var MOCK_TOOLS = [
338
- {
339
- id: "tool-1",
340
- organizationId: "demo-org",
341
- name: "Web Search",
342
- slug: "web-search",
343
- description: "Search the web for real-time information using Brave API.",
344
- category: "RETRIEVAL",
345
- status: "ACTIVE",
346
- parametersSchema: {
347
- type: "object",
348
- properties: {
349
- query: { type: "string", description: "Search query" },
350
- numResults: { type: "number", default: 10 }
351
- },
352
- required: ["query"]
353
- },
354
- outputSchema: { type: "array", items: { type: "object" } },
355
- implementationType: "http",
356
- implementationConfig: {
357
- url: "https://api.brave.com/search",
358
- method: "GET"
359
- },
360
- maxInvocationsPerMinute: 60,
361
- timeoutMs: 30000,
362
- version: "1.0.0",
363
- tags: ["search", "web"],
364
- createdAt: new Date("2024-01-01T00:00:00Z"),
365
- updatedAt: new Date("2024-02-15T10:00:00Z")
366
- },
367
- {
368
- id: "tool-2",
369
- organizationId: "demo-org",
370
- name: "SQL Query",
371
- slug: "sql-query",
372
- description: "Execute read-only SQL queries against the data warehouse.",
373
- category: "RETRIEVAL",
374
- status: "ACTIVE",
375
- parametersSchema: {
376
- type: "object",
377
- properties: {
378
- query: { type: "string", description: "SQL query" },
379
- maxRows: { type: "number", default: 100 }
380
- },
381
- required: ["query"]
382
- },
383
- outputSchema: { type: "object" },
384
- implementationType: "function",
385
- implementationConfig: { handler: "executeSqlQuery" },
386
- maxInvocationsPerMinute: 30,
387
- timeoutMs: 60000,
388
- version: "1.1.0",
389
- tags: ["sql", "database"],
390
- createdAt: new Date("2024-01-05T00:00:00Z"),
391
- updatedAt: new Date("2024-03-10T14:00:00Z")
392
- },
393
- {
394
- id: "tool-3",
395
- organizationId: "demo-org",
396
- name: "Email Sender",
397
- slug: "email-sender",
398
- description: "Send emails via SMTP or API.",
399
- category: "COMMUNICATION",
400
- status: "ACTIVE",
401
- parametersSchema: {
402
- type: "object",
403
- properties: {
404
- to: { type: "string" },
405
- subject: { type: "string" },
406
- body: { type: "string" }
407
- },
408
- required: ["to", "subject", "body"]
409
- },
410
- implementationType: "http",
411
- implementationConfig: { url: "/api/send-email", method: "POST" },
412
- maxInvocationsPerMinute: 10,
413
- timeoutMs: 30000,
414
- version: "1.0.0",
415
- tags: ["email", "communication"],
416
- createdAt: new Date("2024-02-01T00:00:00Z"),
417
- updatedAt: new Date("2024-02-01T00:00:00Z")
418
- },
419
- {
420
- id: "tool-4",
421
- organizationId: "demo-org",
422
- name: "GitHub Integration",
423
- slug: "github-integration",
424
- description: "Interact with GitHub repositories, PRs, and issues.",
425
- category: "INTEGRATION",
426
- status: "ACTIVE",
427
- parametersSchema: {
428
- type: "object",
429
- properties: {
430
- action: {
431
- type: "string",
432
- enum: ["list_prs", "get_pr", "create_comment"]
433
- },
434
- repo: { type: "string" },
435
- params: { type: "object" }
436
- },
437
- required: ["action", "repo"]
438
- },
439
- implementationType: "http",
440
- implementationConfig: { url: "https://api.github.com", auth: "token" },
441
- maxInvocationsPerMinute: 100,
442
- timeoutMs: 15000,
443
- version: "2.0.0",
444
- tags: ["github", "integration", "code"],
445
- createdAt: new Date("2024-02-20T00:00:00Z"),
446
- updatedAt: new Date("2024-04-01T09:00:00Z")
447
- },
448
- {
449
- id: "tool-5",
450
- organizationId: "demo-org",
451
- name: "Calculator",
452
- slug: "calculator",
453
- description: "Perform mathematical calculations.",
454
- category: "COMPUTATION",
455
- status: "ACTIVE",
456
- parametersSchema: {
457
- type: "object",
458
- properties: {
459
- expression: {
460
- type: "string",
461
- description: "Math expression to evaluate"
462
- }
463
- },
464
- required: ["expression"]
465
- },
466
- outputSchema: {
467
- type: "object",
468
- properties: { result: { type: "number" } }
469
- },
470
- implementationType: "function",
471
- implementationConfig: { handler: "evaluateMath" },
472
- timeoutMs: 5000,
473
- version: "1.0.0",
474
- tags: ["math", "utility"],
475
- createdAt: new Date("2024-01-10T00:00:00Z"),
476
- updatedAt: new Date("2024-01-10T00:00:00Z")
477
- }
478
- ];
479
-
480
- // src/agent/agent.schema.ts
481
- import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
482
- var AgentModel = defineSchemaModel2({
483
- name: "Agent",
484
- description: "AI agent configuration",
485
- fields: {
486
- id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
487
- organizationId: {
488
- type: ScalarTypeEnum2.String_unsecure(),
489
- isOptional: false
490
- },
491
- name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
492
- slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
493
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
494
- status: { type: AgentStatusEnum, isOptional: false },
495
- modelProvider: { type: ModelProviderEnum, isOptional: false },
496
- modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
497
- modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
498
- systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
499
- userPromptTemplate: {
500
- type: ScalarTypeEnum2.String_unsecure(),
501
- isOptional: true
502
- },
503
- toolIds: {
504
- type: ScalarTypeEnum2.String_unsecure(),
505
- isArray: true,
506
- isOptional: true
507
- },
508
- toolChoice: {
509
- type: ToolChoiceEnum,
510
- isOptional: false,
511
- defaultValue: "auto"
512
- },
513
- maxIterations: {
514
- type: ScalarTypeEnum2.Int_unsecure(),
515
- isOptional: false,
516
- defaultValue: 10
517
- },
518
- maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
519
- timeoutMs: {
520
- type: ScalarTypeEnum2.Int_unsecure(),
521
- isOptional: false,
522
- defaultValue: 120000
523
- },
524
- version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
525
- tags: {
526
- type: ScalarTypeEnum2.String_unsecure(),
527
- isArray: true,
528
- isOptional: true
529
- },
530
- createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
531
- updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
532
- }
533
- });
534
- var AgentSummaryModel = defineSchemaModel2({
535
- name: "AgentSummary",
536
- description: "Summary of an agent for list views",
537
- fields: {
538
- id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
539
- name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
540
- slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
541
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
542
- status: { type: AgentStatusEnum, isOptional: false },
543
- modelProvider: { type: ModelProviderEnum, isOptional: false },
544
- modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
545
- version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
546
- createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
547
- }
548
- });
549
- var AgentToolRefModel = defineSchemaModel2({
550
- name: "AgentToolRef",
551
- description: "Tool reference in agent context",
552
- fields: {
553
- id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
554
- name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
555
- slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
556
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
557
- category: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
558
- }
559
- });
560
- var AgentWithToolsModel = defineSchemaModel2({
561
- name: "AgentWithTools",
562
- description: "Agent with associated tools",
563
- fields: {
564
- id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
565
- organizationId: {
566
- type: ScalarTypeEnum2.String_unsecure(),
567
- isOptional: false
568
- },
569
- name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
570
- slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
571
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
572
- status: { type: AgentStatusEnum, isOptional: false },
573
- modelProvider: { type: ModelProviderEnum, isOptional: false },
574
- modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
575
- modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
576
- systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
577
- userPromptTemplate: {
578
- type: ScalarTypeEnum2.String_unsecure(),
579
- isOptional: true
580
- },
581
- toolIds: {
582
- type: ScalarTypeEnum2.String_unsecure(),
583
- isArray: true,
584
- isOptional: true
585
- },
586
- toolChoice: { type: ToolChoiceEnum, isOptional: false },
587
- maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
588
- maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
589
- timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
590
- version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
591
- tags: {
592
- type: ScalarTypeEnum2.String_unsecure(),
593
- isArray: true,
594
- isOptional: true
595
- },
596
- createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
597
- updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
598
- tools: { type: AgentToolRefModel, isArray: true, isOptional: true }
599
- }
600
- });
601
- var CreateAgentInputModel = defineSchemaModel2({
602
- name: "CreateAgentInput",
603
- description: "Input for creating an agent",
604
- fields: {
605
- organizationId: {
606
- type: ScalarTypeEnum2.String_unsecure(),
607
- isOptional: false
608
- },
609
- name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
610
- slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
611
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
612
- modelProvider: { type: ModelProviderEnum, isOptional: false },
613
- modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
614
- modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
615
- systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
616
- userPromptTemplate: {
617
- type: ScalarTypeEnum2.String_unsecure(),
618
- isOptional: true
619
- },
620
- toolIds: {
621
- type: ScalarTypeEnum2.String_unsecure(),
622
- isArray: true,
623
- isOptional: true
624
- },
625
- toolChoice: { type: ToolChoiceEnum, isOptional: true },
626
- maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
627
- maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
628
- timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
629
- tags: {
630
- type: ScalarTypeEnum2.String_unsecure(),
631
- isArray: true,
632
- isOptional: true
633
- }
634
- }
635
- });
636
- var UpdateAgentInputModel = defineSchemaModel2({
637
- name: "UpdateAgentInput",
638
- description: "Input for updating an agent",
639
- fields: {
640
- agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
641
- name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: true },
642
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
643
- status: { type: AgentStatusEnum, isOptional: true },
644
- modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
645
- systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
646
- userPromptTemplate: {
647
- type: ScalarTypeEnum2.String_unsecure(),
648
- isOptional: true
649
- },
650
- toolIds: {
651
- type: ScalarTypeEnum2.String_unsecure(),
652
- isArray: true,
653
- isOptional: true
654
- },
655
- toolChoice: { type: ToolChoiceEnum, isOptional: true },
656
- maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
657
- maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
658
- timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
659
- tags: {
660
- type: ScalarTypeEnum2.String_unsecure(),
661
- isArray: true,
662
- isOptional: true
663
- }
664
- }
665
- });
666
-
667
- // src/agent/agent.operation.ts
668
- import {
669
- defineCommand,
670
- defineQuery
671
- } from "@contractspec/lib.contracts-spec/operations";
672
- import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
673
- var OWNERS2 = ["@agent-console-team"];
674
- var CreateAgentCommand = defineCommand({
675
- meta: {
676
- key: "agent-console.agent.create",
677
- version: "1.0.0",
678
- stability: "stable",
679
- owners: [...OWNERS2],
680
- tags: ["agent", "create"],
681
- description: "Creates a new AI agent configuration.",
682
- goal: "Allow users to define new AI agents with specific models and tools.",
683
- context: "Called from the agent builder UI when creating a new agent."
684
- },
685
- io: {
686
- input: CreateAgentInputModel,
687
- output: defineSchemaModel3({
688
- name: "CreateAgentOutput",
689
- fields: {
690
- id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
691
- name: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
692
- slug: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
693
- status: { type: AgentStatusEnum, isOptional: false }
694
- }
695
- }),
696
- errors: {
697
- SLUG_EXISTS: {
698
- description: "An agent with this slug already exists in the organization",
699
- http: 409,
700
- gqlCode: "SLUG_EXISTS",
701
- when: "Slug is already taken"
702
- }
703
- }
704
- },
705
- policy: { auth: "user" },
706
- sideEffects: {
707
- emits: [
708
- {
709
- ref: AgentCreatedEvent.meta,
710
- when: "Agent is successfully created"
711
- }
712
- ],
713
- audit: ["agent-console.agent.created"]
714
- },
715
- acceptance: {
716
- scenarios: [
717
- {
718
- key: "create-agent-happy-path",
719
- given: ["User is authenticated", "Organization exists"],
720
- when: ["User submits valid agent configuration"],
721
- then: [
722
- "New agent is created with DRAFT status",
723
- "AgentCreated event is emitted"
724
- ]
725
- },
726
- {
727
- key: "create-agent-slug-conflict",
728
- given: ["User is authenticated", "Agent with same slug exists"],
729
- when: ["User submits agent with duplicate slug"],
730
- then: ["SLUG_EXISTS error is returned with 409 status"]
731
- }
732
- ],
733
- examples: [
734
- {
735
- key: "basic-create",
736
- input: {
737
- name: "Support Assistant",
738
- slug: "support-assistant",
739
- modelProvider: "openai",
740
- modelId: "gpt-4"
741
- },
742
- output: {
743
- id: "agent-123",
744
- name: "Support Assistant",
745
- slug: "support-assistant",
746
- status: "draft"
747
- }
748
- }
749
- ]
750
- }
751
- });
752
- var UpdateAgentCommand = defineCommand({
753
- meta: {
754
- key: "agent-console.agent.update",
755
- version: "1.0.0",
756
- stability: "stable",
757
- owners: [...OWNERS2],
758
- tags: ["agent", "update"],
759
- description: "Updates an existing AI agent configuration.",
760
- goal: "Allow users to modify agent settings and configuration.",
761
- context: "Called from the agent settings UI."
762
- },
763
- io: {
764
- input: UpdateAgentInputModel,
765
- output: defineSchemaModel3({
766
- name: "UpdateAgentOutput",
767
- fields: {
768
- id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
769
- name: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
770
- status: { type: AgentStatusEnum, isOptional: false },
771
- updatedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
772
- }
773
- }),
774
- errors: {
775
- AGENT_NOT_FOUND: {
776
- description: "The specified agent does not exist",
777
- http: 404,
778
- gqlCode: "AGENT_NOT_FOUND",
779
- when: "Agent ID is invalid"
780
- }
781
- }
782
- },
783
- policy: { auth: "user" },
784
- sideEffects: {
785
- emits: [
786
- {
787
- key: "agent.updated",
788
- version: "1.0.0",
789
- stability: "stable",
790
- owners: [...OWNERS2],
791
- tags: ["agent", "updated"],
792
- when: "Agent is updated",
793
- payload: AgentSummaryModel
794
- }
795
- ],
796
- audit: ["agent.updated"]
797
- },
798
- acceptance: {
799
- scenarios: [
800
- {
801
- key: "update-agent-happy-path",
802
- given: ["Agent exists", "User owns the agent"],
803
- when: ["User submits updated configuration"],
804
- then: ["Agent is updated", "AgentUpdated event is emitted"]
805
- },
806
- {
807
- key: "update-agent-not-found",
808
- given: ["Agent does not exist"],
809
- when: ["User attempts to update"],
810
- then: ["AGENT_NOT_FOUND error is returned"]
811
- }
812
- ],
813
- examples: [
814
- {
815
- key: "update-name",
816
- input: {
817
- agentId: "agent-123",
818
- name: "Updated Assistant",
819
- systemPrompt: "You are a helpful assistant."
820
- },
821
- output: {
822
- id: "agent-123",
823
- name: "Updated Assistant",
824
- status: "draft",
825
- updatedAt: "2025-01-01T00:00:00Z"
826
- }
827
- }
828
- ]
829
- }
830
- });
831
- var GetAgentQuery = defineQuery({
832
- meta: {
833
- key: "agent-console.agent.get",
834
- version: "1.0.0",
835
- stability: "stable",
836
- owners: [...OWNERS2],
837
- tags: ["agent", "get"],
838
- description: "Retrieves an agent by its ID.",
839
- goal: "View detailed agent configuration.",
840
- context: "Called when viewing agent details or editing."
841
- },
842
- io: {
843
- input: defineSchemaModel3({
844
- name: "GetAgentInput",
845
- fields: {
846
- agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
847
- includeTools: { type: ScalarTypeEnum3.Boolean(), isOptional: true }
848
- }
849
- }),
850
- output: AgentWithToolsModel,
851
- errors: {
852
- AGENT_NOT_FOUND: {
853
- description: "The specified agent does not exist",
854
- http: 404,
855
- gqlCode: "AGENT_NOT_FOUND",
856
- when: "Agent ID is invalid"
857
- }
858
- }
859
- },
860
- policy: { auth: "user" },
861
- acceptance: {
862
- scenarios: [
863
- {
864
- key: "get-agent-happy-path",
865
- given: ["Agent exists"],
866
- when: ["User requests agent by ID"],
867
- then: ["Agent details are returned"]
868
- },
869
- {
870
- key: "get-agent-with-tools",
871
- given: ["Agent exists with assigned tools"],
872
- when: ["User requests agent with includeTools=true"],
873
- then: ["Agent details with tools list are returned"]
874
- }
875
- ],
876
- examples: [
877
- {
878
- key: "get-basic",
879
- input: { agentId: "agent-123", includeTools: false },
880
- output: {
881
- id: "agent-123",
882
- name: "Support Assistant",
883
- status: "active",
884
- tools: []
885
- }
886
- }
887
- ]
888
- }
889
- });
890
- var ListAgentsQuery = defineQuery({
891
- meta: {
892
- key: "agent-console.agent.list",
893
- version: "1.0.0",
894
- stability: "stable",
895
- owners: [...OWNERS2],
896
- tags: ["agent", "list"],
897
- description: "Lists agents for an organization with optional filtering.",
898
- goal: "Browse and search available agents.",
899
- context: "Agent list/dashboard view."
900
- },
901
- io: {
902
- input: defineSchemaModel3({
903
- name: "ListAgentsInput",
904
- fields: {
905
- organizationId: {
906
- type: ScalarTypeEnum3.String_unsecure(),
907
- isOptional: false
908
- },
909
- status: { type: AgentStatusEnum, isOptional: true },
910
- modelProvider: { type: ModelProviderEnum, isOptional: true },
911
- search: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
912
- limit: {
913
- type: ScalarTypeEnum3.Int_unsecure(),
914
- isOptional: true,
915
- defaultValue: 20
916
- },
917
- offset: {
918
- type: ScalarTypeEnum3.Int_unsecure(),
919
- isOptional: true,
920
- defaultValue: 0
921
- }
922
- }
923
- }),
924
- output: defineSchemaModel3({
925
- name: "ListAgentsOutput",
926
- fields: {
927
- items: { type: AgentSummaryModel, isArray: true, isOptional: false },
928
- total: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
929
- hasMore: { type: ScalarTypeEnum3.Boolean(), isOptional: false }
930
- }
931
- })
932
- },
933
- policy: { auth: "user" },
934
- acceptance: {
935
- scenarios: [
936
- {
937
- key: "list-agents-happy-path",
938
- given: ["Organization has agents"],
939
- when: ["User lists agents"],
940
- then: ["Paginated list of agents is returned"]
941
- },
942
- {
943
- key: "list-agents-filter-by-status",
944
- given: ["Organization has agents with mixed statuses"],
945
- when: ["User filters by status=active"],
946
- then: ["Only active agents are returned"]
947
- }
948
- ],
949
- examples: [
950
- {
951
- key: "list-basic",
952
- input: { organizationId: "org-123", limit: 10, offset: 0 },
953
- output: { items: [], total: 0, hasMore: false }
954
- }
955
- ]
956
- }
957
- });
958
- var AssignToolToAgentCommand = defineCommand({
959
- meta: {
960
- key: "agent-console.agent.assignTool",
961
- version: "1.0.0",
962
- stability: "stable",
963
- owners: [...OWNERS2],
964
- tags: ["agent", "tool", "assign"],
965
- description: "Assigns a tool to an agent with optional configuration.",
966
- goal: "Enable agents to use specific tools.",
967
- context: "Agent configuration UI - tool selection."
968
- },
969
- io: {
970
- input: defineSchemaModel3({
971
- name: "AssignToolToAgentInput",
972
- fields: {
973
- agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
974
- toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
975
- config: { type: ScalarTypeEnum3.JSONObject(), isOptional: true },
976
- order: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: true }
977
- }
978
- }),
979
- output: defineSchemaModel3({
980
- name: "AssignToolToAgentOutput",
981
- fields: {
982
- agentToolId: {
983
- type: ScalarTypeEnum3.String_unsecure(),
984
- isOptional: false
985
- },
986
- agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
987
- toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
988
- }
989
- }),
990
- errors: {
991
- TOOL_ALREADY_ASSIGNED: {
992
- description: "This tool is already assigned to the agent",
993
- http: 409,
994
- gqlCode: "TOOL_ALREADY_ASSIGNED",
995
- when: "Tool assignment already exists"
996
- }
997
- }
998
- },
999
- policy: { auth: "user" },
1000
- sideEffects: { audit: ["agent.tool.assigned"] },
1001
- acceptance: {
1002
- scenarios: [
1003
- {
1004
- key: "assign-tool-happy-path",
1005
- given: ["Agent exists", "Tool exists and is not assigned"],
1006
- when: ["User assigns tool to agent"],
1007
- then: ["Tool is assigned", "Assignment ID is returned"]
1008
- },
1009
- {
1010
- key: "assign-tool-already-assigned",
1011
- given: ["Tool is already assigned to agent"],
1012
- when: ["User attempts to assign again"],
1013
- then: ["TOOL_ALREADY_ASSIGNED error is returned"]
1014
- }
1015
- ],
1016
- examples: [
1017
- {
1018
- key: "assign-basic",
1019
- input: { agentId: "agent-123", toolId: "tool-456" },
1020
- output: {
1021
- agentToolId: "at-789",
1022
- agentId: "agent-123",
1023
- toolId: "tool-456"
1024
- }
1025
- }
1026
- ]
1027
- }
1028
- });
1029
- var RemoveToolFromAgentCommand = defineCommand({
1030
- meta: {
1031
- key: "agent-console.agent.removeTool",
1032
- version: "1.0.0",
1033
- stability: "stable",
1034
- owners: [...OWNERS2],
1035
- tags: ["agent", "tool", "remove"],
1036
- description: "Removes a tool assignment from an agent.",
1037
- goal: "Disable specific tools for an agent.",
1038
- context: "Agent configuration UI - tool management."
1039
- },
1040
- io: {
1041
- input: defineSchemaModel3({
1042
- name: "RemoveToolFromAgentInput",
1043
- fields: {
1044
- agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1045
- toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
1046
- }
1047
- }),
1048
- output: defineSchemaModel3({
1049
- name: "RemoveToolFromAgentOutput",
1050
- fields: {
1051
- success: { type: ScalarTypeEnum3.Boolean(), isOptional: false }
1052
- }
1053
- })
1054
- },
1055
- policy: { auth: "user" },
1056
- sideEffects: { audit: ["agent.tool.removed"] },
1057
- acceptance: {
1058
- scenarios: [
1059
- {
1060
- key: "remove-tool-happy-path",
1061
- given: ["Agent exists", "Tool is assigned to agent"],
1062
- when: ["User removes tool from agent"],
1063
- then: ["Tool is unassigned", "Success is returned"]
1064
- }
1065
- ],
1066
- examples: [
1067
- {
1068
- key: "remove-basic",
1069
- input: { agentId: "agent-123", toolId: "tool-456" },
1070
- output: { success: true }
1071
- }
1072
- ]
1073
- }
1074
- });
1075
-
1076
- // src/agent/agent.handler.ts
1077
- var nextMockAgentId = MOCK_AGENTS.length + 1;
1078
- async function mockListAgentsHandler(input) {
1079
- const {
1080
- organizationId,
1081
- status,
1082
- modelProvider,
1083
- search,
1084
- limit = 20,
1085
- offset = 0
1086
- } = input;
1087
- let filtered = MOCK_AGENTS.filter((a) => a.organizationId === organizationId);
1088
- if (status)
1089
- filtered = filtered.filter((a) => a.status === status);
1090
- if (modelProvider)
1091
- filtered = filtered.filter((a) => a.modelProvider === modelProvider);
1092
- if (search) {
1093
- const q = search.toLowerCase();
1094
- filtered = filtered.filter((a) => a.name.toLowerCase().includes(q) || a.description?.toLowerCase().includes(q) || a.tags?.some((t) => t.toLowerCase().includes(q)));
1095
- }
1096
- const total = filtered.length;
1097
- const items = filtered.slice(offset, offset + limit).map((a) => ({
1098
- id: a.id,
1099
- name: a.name,
1100
- slug: a.slug,
1101
- description: a.description,
1102
- status: a.status,
1103
- modelProvider: a.modelProvider,
1104
- modelName: a.modelName,
1105
- version: a.version,
1106
- createdAt: a.createdAt
1107
- }));
1108
- return { items, total, hasMore: offset + limit < total };
1109
- }
1110
- async function mockGetAgentHandler(input) {
1111
- const agent = MOCK_AGENTS.find((a) => a.id === input.agentId);
1112
- if (!agent)
1113
- throw new Error("AGENT_NOT_FOUND");
1114
- const result = { ...agent, toolIds: ["tool-1", "tool-2"] };
1115
- if (input.includeTools) {
1116
- result.tools = MOCK_TOOLS.slice(0, 2).map((t) => ({
1117
- id: t.id,
1118
- name: t.name,
1119
- slug: t.slug,
1120
- description: t.description,
1121
- category: t.category
1122
- }));
1123
- }
1124
- return result;
1125
- }
1126
- async function mockCreateAgentHandler(input) {
1127
- const exists = MOCK_AGENTS.some((a) => a.organizationId === input.organizationId && a.slug === input.slug);
1128
- if (exists)
1129
- throw new Error("SLUG_EXISTS");
1130
- return {
1131
- id: `agent-${nextMockAgentId++}`,
1132
- name: input.name,
1133
- slug: input.slug,
1134
- status: "DRAFT"
1135
- };
1136
- }
1137
- async function mockUpdateAgentHandler(input) {
1138
- const agent = MOCK_AGENTS.find((a) => a.id === input.agentId);
1139
- if (!agent)
1140
- throw new Error("AGENT_NOT_FOUND");
1141
- return {
1142
- id: agent.id,
1143
- name: input.name ?? agent.name,
1144
- status: input.status ?? agent.status,
1145
- updatedAt: new Date
1146
- };
1147
- }
1148
-
1149
- // src/agent/agent.presentation.ts
1150
- import {
1151
- definePresentation,
1152
- StabilityEnum
1153
- } from "@contractspec/lib.contracts-spec";
1154
- var AgentListPresentation = definePresentation({
1155
- meta: {
1156
- key: "agent-console.agent.viewList",
1157
- version: "1.0.0",
1158
- title: "Agent List",
1159
- description: "List view of AI agents with status, model provider, and version info",
1160
- goal: "Provide an overview of all agents in an organization.",
1161
- context: "Main landing page for agent management.",
1162
- domain: "agent-console",
1163
- owners: ["@agent-console-team"],
1164
- tags: ["agent", "list", "dashboard"],
1165
- stability: StabilityEnum.Experimental
1166
- },
1167
- source: {
1168
- type: "component",
1169
- framework: "react",
1170
- componentKey: "AgentListView",
1171
- props: AgentSummaryModel
1172
- },
1173
- targets: ["react", "markdown", "application/json"],
1174
- policy: { flags: ["agent-console.enabled"] }
1175
- });
1176
- var AgentDetailPresentation = definePresentation({
1177
- meta: {
1178
- key: "agent-console.agent.detail",
1179
- version: "1.0.0",
1180
- title: "Agent Details",
1181
- description: "Detailed view of an AI agent with configuration, tools, and recent runs",
1182
- goal: "Allow users to inspect and configure a specific agent.",
1183
- context: "Detailed view of an agent.",
1184
- domain: "agent-console",
1185
- owners: ["@agent-console-team"],
1186
- tags: ["agent", "detail"],
1187
- stability: StabilityEnum.Experimental
1188
- },
1189
- source: {
1190
- type: "component",
1191
- framework: "react",
1192
- componentKey: "AgentDetailView"
1193
- },
1194
- targets: ["react", "markdown"],
1195
- policy: { flags: ["agent-console.enabled"] }
1196
- });
1197
- var AgentConsoleDashboardPresentation = definePresentation({
1198
- meta: {
1199
- key: "agent-console.dashboard",
1200
- version: "1.0.0",
1201
- title: "Agent Console Dashboard",
1202
- description: "Dashboard overview of AI agents, runs, and tools",
1203
- goal: "Provide a high-level overview of the AI platform health and usage.",
1204
- context: "Root dashboard of the Agent Console.",
1205
- domain: "agent-console",
1206
- owners: ["@agent-console-team"],
1207
- tags: ["dashboard", "overview"],
1208
- stability: StabilityEnum.Experimental
1209
- },
1210
- source: {
1211
- type: "component",
1212
- framework: "react",
1213
- componentKey: "AgentConsoleDashboard"
1214
- },
1215
- targets: ["react", "markdown"],
1216
- policy: { flags: ["agent-console.enabled"] }
1217
- });
1218
- export {
1219
- mockUpdateAgentHandler,
1220
- mockListAgentsHandler,
1221
- mockGetAgentHandler,
1222
- mockCreateAgentHandler,
1223
- UpdateAgentInputModel,
1224
- UpdateAgentCommand,
1225
- ToolChoiceEnum,
1226
- RemoveToolFromAgentCommand,
1227
- ModelProviderEnum,
1228
- ModelProviderEntityEnum,
1229
- ListAgentsQuery,
1230
- GetAgentQuery,
1231
- CreateAgentInputModel,
1232
- CreateAgentCommand,
1233
- AssignToolToAgentCommand,
1234
- AgentWithToolsModel,
1235
- AgentUpdatedEvent,
1236
- AgentToolRemovedEvent,
1237
- AgentToolRefModel,
1238
- AgentToolEntity,
1239
- AgentToolAssignedEvent,
1240
- AgentSummaryModel,
1241
- AgentStatusEnum,
1242
- AgentStatusEntityEnum,
1243
- AgentModel,
1244
- AgentListPresentation,
1245
- AgentEntity,
1246
- AgentDetailPresentation,
1247
- AgentCreatedEvent,
1248
- AgentConsoleDashboardPresentation
1249
- };
2
+ import{defineEntity as X,defineEntityEnum as $,field as o,index as h}from"@contractspec/lib.schema";var _=$({name:"AgentStatus",values:["DRAFT","ACTIVE","PAUSED","ARCHIVED"],description:"Lifecycle status of the agent"}),N=$({name:"ModelProvider",values:["OPENAI","ANTHROPIC","GOOGLE","MISTRAL","CUSTOM"],description:"AI model provider"}),f=X({name:"Agent",schema:"agent_console",description:"Represents an AI agent configuration with assigned tools and parameters.",fields:{id:o.id(),organizationId:o.string({description:"Organization that owns this agent"}),name:o.string({description:"Agent name (1-100 chars)"}),slug:o.string({description:"URL-safe identifier (lowercase, numbers, hyphens)"}),description:o.string({isOptional:!0,description:"Agent description (max 1000 chars)"}),status:o.enum("AgentStatus",{default:"DRAFT"}),modelProvider:o.enum("ModelProvider",{default:"OPENAI"}),modelName:o.string({description:"Model identifier: 'gpt-4', 'claude-3-opus', etc."}),modelConfig:o.json({isOptional:!0,description:"Model parameters: temperature, max_tokens, etc."}),systemPrompt:o.string({description:"System prompt for the agent"}),userPromptTemplate:o.string({isOptional:!0,description:"Template for user prompts"}),toolIds:o.string({isArray:!0,isOptional:!0,description:"IDs of assigned tools"}),toolChoice:o.string({default:"auto",description:"Tool selection mode: 'auto', 'required', 'none'"}),maxIterations:o.int({default:10,description:"Maximum iterations per run"}),maxTokensPerRun:o.int({isOptional:!0,description:"Maximum tokens per run"}),timeoutMs:o.int({default:120000,description:"Execution timeout in milliseconds"}),version:o.string({default:"1.0.0",description:"Agent version"}),tags:o.string({isArray:!0,isOptional:!0,description:"Tags for categorization"}),createdAt:o.createdAt(),updatedAt:o.updatedAt(),createdById:o.string({isOptional:!0,description:"User who created this agent"}),tools:o.hasMany("Tool",{description:"Tools assigned to this agent"})},indexes:[h.unique(["organizationId","slug"]),h.on(["organizationId","status"]),h.on(["modelProvider","modelName"])],enums:[_,N]}),a=X({name:"AgentTool",schema:"agent_console",description:"Links an agent to its assigned tools with configuration.",fields:{id:o.id(),agentId:o.foreignKey({description:"Agent ID"}),toolId:o.foreignKey({description:"Tool ID"}),config:o.json({isOptional:!0,description:"Tool-specific configuration for this agent"}),order:o.int({default:0,description:"Order of tool in agent tool list"}),isEnabled:o.boolean({default:!0,description:"Whether tool is enabled for this agent"}),createdAt:o.createdAt(),agent:o.belongsTo("Agent",["agentId"],["id"]),tool:o.belongsTo("Tool",["toolId"],["id"])},indexes:[h.unique(["agentId","toolId"]),h.on(["agentId","order"])]});import{defineEnum as Q}from"@contractspec/lib.schema";var w=Q("AgentStatus",["DRAFT","ACTIVE","PAUSED","ARCHIVED"]),b=Q("ModelProvider",["OPENAI","ANTHROPIC","GOOGLE","MISTRAL","CUSTOM"]),C=Q("ToolChoice",["auto","required","none"]);import{defineEvent as P}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as j,ScalarTypeEnum as s}from"@contractspec/lib.schema";var L=["@agent-console-team"],y=j({name:"AgentCreatedPayload",description:"Payload for agent created event",fields:{id:{type:s.String_unsecure(),isOptional:!1},organizationId:{type:s.String_unsecure(),isOptional:!1},name:{type:s.String_unsecure(),isOptional:!1},slug:{type:s.String_unsecure(),isOptional:!1},modelProvider:{type:s.String_unsecure(),isOptional:!1},modelName:{type:s.String_unsecure(),isOptional:!1},toolCount:{type:s.Int_unsecure(),isOptional:!1},createdById:{type:s.String_unsecure(),isOptional:!0},createdAt:{type:s.DateTime(),isOptional:!1}}}),G=P({meta:{key:"agent-console.agent.created",version:"1.0.0",description:"A new AI agent was configured.",stability:"stable",owners:[...L],tags:["agent","created"]},payload:y}),T=j({name:"AgentUpdatedPayload",description:"Payload for agent updated event",fields:{id:{type:s.String_unsecure(),isOptional:!1},organizationId:{type:s.String_unsecure(),isOptional:!1},name:{type:s.String_unsecure(),isOptional:!1},status:{type:s.String_unsecure(),isOptional:!1},updatedFields:{type:s.String_unsecure(),isArray:!0,isOptional:!1},updatedAt:{type:s.DateTime(),isOptional:!1}}}),l=P({meta:{key:"agent-console.agent.updated",version:"1.0.0",description:"An AI agent configuration was updated.",stability:"stable",owners:[...L],tags:["agent","updated"]},payload:T}),E=j({name:"AgentToolAssignedPayload",description:"Payload for agent tool assigned event",fields:{agentId:{type:s.String_unsecure(),isOptional:!1},toolId:{type:s.String_unsecure(),isOptional:!1},agentName:{type:s.String_unsecure(),isOptional:!1},toolName:{type:s.String_unsecure(),isOptional:!1},assignedAt:{type:s.DateTime(),isOptional:!1}}}),S=P({meta:{key:"agent-console.agent.toolAssigned",version:"1.0.0",description:"A tool was assigned to an agent.",stability:"stable",owners:[...L],tags:["agent","tool","assigned"]},payload:E}),tt=j({name:"AgentToolRemovedPayload",description:"Payload for agent tool removed event",fields:{agentId:{type:s.String_unsecure(),isOptional:!1},toolId:{type:s.String_unsecure(),isOptional:!1},agentName:{type:s.String_unsecure(),isOptional:!1},toolName:{type:s.String_unsecure(),isOptional:!1},removedAt:{type:s.DateTime(),isOptional:!1}}}),ot=P({meta:{key:"agent-console.agent.toolRemoved",version:"1.0.0",description:"A tool was removed from an agent.",stability:"stable",owners:[...L],tags:["agent","tool","removed"]},payload:tt});var Z=[{id:"agent-1",organizationId:"demo-org",name:"Customer Support Bot",slug:"customer-support-bot",description:"Handles tier-1 customer inquiries and routes complex issues.",status:"ACTIVE",modelProvider:"OPENAI",modelName:"gpt-4o-mini",modelConfig:{temperature:0.7},systemPrompt:"You are a helpful customer support assistant.",toolChoice:"auto",maxIterations:10,timeoutMs:120000,version:"1.0.0",tags:["support","tier-1"],createdAt:new Date("2024-01-15T10:00:00Z"),updatedAt:new Date("2024-03-20T14:30:00Z")},{id:"agent-2",organizationId:"demo-org",name:"Code Review Assistant",slug:"code-review-assistant",description:"Reviews pull requests and provides actionable feedback.",status:"ACTIVE",modelProvider:"ANTHROPIC",modelName:"claude-sonnet-4-20250514",modelConfig:{temperature:0.3},systemPrompt:"You are a code review expert.",toolChoice:"auto",maxIterations:15,timeoutMs:180000,version:"2.1.0",tags:["code","review","dev"],createdAt:new Date("2024-02-10T09:00:00Z"),updatedAt:new Date("2024-04-05T11:15:00Z")},{id:"agent-3",organizationId:"demo-org",name:"Data Analyst",slug:"data-analyst",description:"Queries databases and generates insights from data.",status:"PAUSED",modelProvider:"OPENAI",modelName:"gpt-4o",modelConfig:{temperature:0.5},systemPrompt:"You are a data analyst expert in SQL and analytics.",toolChoice:"required",maxIterations:20,timeoutMs:300000,version:"1.2.0",tags:["data","analytics","sql"],createdAt:new Date("2024-03-01T08:00:00Z"),updatedAt:new Date("2024-04-10T16:45:00Z")},{id:"agent-4",organizationId:"demo-org",name:"Meeting Scheduler",slug:"meeting-scheduler",description:"Schedules meetings and manages calendar conflicts.",status:"DRAFT",modelProvider:"GOOGLE",modelName:"gemini-2.0-flash",modelConfig:{temperature:0.2},systemPrompt:"You help schedule and organize meetings efficiently.",toolChoice:"auto",maxIterations:5,timeoutMs:60000,version:"0.1.0",tags:["calendar","scheduling"],createdAt:new Date("2024-04-01T12:00:00Z"),updatedAt:new Date("2024-04-01T12:00:00Z")}];var O=[{id:"tool-1",organizationId:"demo-org",name:"Web Search",slug:"web-search",description:"Search the web for real-time information using Brave API.",category:"RETRIEVAL",status:"ACTIVE",parametersSchema:{type:"object",properties:{query:{type:"string",description:"Search query"},numResults:{type:"number",default:10}},required:["query"]},outputSchema:{type:"array",items:{type:"object"}},implementationType:"http",implementationConfig:{url:"https://api.brave.com/search",method:"GET"},maxInvocationsPerMinute:60,timeoutMs:30000,version:"1.0.0",tags:["search","web"],createdAt:new Date("2024-01-01T00:00:00Z"),updatedAt:new Date("2024-02-15T10:00:00Z")},{id:"tool-2",organizationId:"demo-org",name:"SQL Query",slug:"sql-query",description:"Execute read-only SQL queries against the data warehouse.",category:"RETRIEVAL",status:"ACTIVE",parametersSchema:{type:"object",properties:{query:{type:"string",description:"SQL query"},maxRows:{type:"number",default:100}},required:["query"]},outputSchema:{type:"object"},implementationType:"function",implementationConfig:{handler:"executeSqlQuery"},maxInvocationsPerMinute:30,timeoutMs:60000,version:"1.1.0",tags:["sql","database"],createdAt:new Date("2024-01-05T00:00:00Z"),updatedAt:new Date("2024-03-10T14:00:00Z")},{id:"tool-3",organizationId:"demo-org",name:"Email Sender",slug:"email-sender",description:"Send emails via SMTP or API.",category:"COMMUNICATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{to:{type:"string"},subject:{type:"string"},body:{type:"string"}},required:["to","subject","body"]},implementationType:"http",implementationConfig:{url:"/api/send-email",method:"POST"},maxInvocationsPerMinute:10,timeoutMs:30000,version:"1.0.0",tags:["email","communication"],createdAt:new Date("2024-02-01T00:00:00Z"),updatedAt:new Date("2024-02-01T00:00:00Z")},{id:"tool-4",organizationId:"demo-org",name:"GitHub Integration",slug:"github-integration",description:"Interact with GitHub repositories, PRs, and issues.",category:"INTEGRATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{action:{type:"string",enum:["list_prs","get_pr","create_comment"]},repo:{type:"string"},params:{type:"object"}},required:["action","repo"]},implementationType:"http",implementationConfig:{url:"https://api.github.com",auth:"token"},maxInvocationsPerMinute:100,timeoutMs:15000,version:"2.0.0",tags:["github","integration","code"],createdAt:new Date("2024-02-20T00:00:00Z"),updatedAt:new Date("2024-04-01T09:00:00Z")},{id:"tool-5",organizationId:"demo-org",name:"Calculator",slug:"calculator",description:"Perform mathematical calculations.",category:"COMPUTATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{expression:{type:"string",description:"Math expression to evaluate"}},required:["expression"]},outputSchema:{type:"object",properties:{result:{type:"number"}}},implementationType:"function",implementationConfig:{handler:"evaluateMath"},timeoutMs:5000,version:"1.0.0",tags:["math","utility"],createdAt:new Date("2024-01-10T00:00:00Z"),updatedAt:new Date("2024-01-10T00:00:00Z")}];import{defineSchemaModel as q,ScalarTypeEnum as t}from"@contractspec/lib.schema";var st=q({name:"Agent",description:"AI agent configuration",fields:{id:{type:t.String_unsecure(),isOptional:!1},organizationId:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!0},status:{type:w,isOptional:!1},modelProvider:{type:b,isOptional:!1},modelName:{type:t.NonEmptyString(),isOptional:!1},modelConfig:{type:t.JSONObject(),isOptional:!0},systemPrompt:{type:t.String_unsecure(),isOptional:!1},userPromptTemplate:{type:t.String_unsecure(),isOptional:!0},toolIds:{type:t.String_unsecure(),isArray:!0,isOptional:!0},toolChoice:{type:C,isOptional:!1,defaultValue:"auto"},maxIterations:{type:t.Int_unsecure(),isOptional:!1,defaultValue:10},maxTokensPerRun:{type:t.Int_unsecure(),isOptional:!0},timeoutMs:{type:t.Int_unsecure(),isOptional:!1,defaultValue:120000},version:{type:t.NonEmptyString(),isOptional:!1},tags:{type:t.String_unsecure(),isArray:!0,isOptional:!0},createdAt:{type:t.DateTime(),isOptional:!1},updatedAt:{type:t.DateTime(),isOptional:!1}}}),d=q({name:"AgentSummary",description:"Summary of an agent for list views",fields:{id:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!0},status:{type:w,isOptional:!1},modelProvider:{type:b,isOptional:!1},modelName:{type:t.NonEmptyString(),isOptional:!1},version:{type:t.NonEmptyString(),isOptional:!1},createdAt:{type:t.DateTime(),isOptional:!1}}}),K=q({name:"AgentToolRef",description:"Tool reference in agent context",fields:{id:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!1},category:{type:t.String_unsecure(),isOptional:!1}}}),Y=q({name:"AgentWithTools",description:"Agent with associated tools",fields:{id:{type:t.String_unsecure(),isOptional:!1},organizationId:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!0},status:{type:w,isOptional:!1},modelProvider:{type:b,isOptional:!1},modelName:{type:t.NonEmptyString(),isOptional:!1},modelConfig:{type:t.JSONObject(),isOptional:!0},systemPrompt:{type:t.String_unsecure(),isOptional:!1},userPromptTemplate:{type:t.String_unsecure(),isOptional:!0},toolIds:{type:t.String_unsecure(),isArray:!0,isOptional:!0},toolChoice:{type:C,isOptional:!1},maxIterations:{type:t.Int_unsecure(),isOptional:!1},maxTokensPerRun:{type:t.Int_unsecure(),isOptional:!0},timeoutMs:{type:t.Int_unsecure(),isOptional:!1},version:{type:t.NonEmptyString(),isOptional:!1},tags:{type:t.String_unsecure(),isArray:!0,isOptional:!0},createdAt:{type:t.DateTime(),isOptional:!1},updatedAt:{type:t.DateTime(),isOptional:!1},tools:{type:K,isArray:!0,isOptional:!0}}}),k=q({name:"CreateAgentInput",description:"Input for creating an agent",fields:{organizationId:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!0},modelProvider:{type:b,isOptional:!1},modelName:{type:t.NonEmptyString(),isOptional:!1},modelConfig:{type:t.JSONObject(),isOptional:!0},systemPrompt:{type:t.String_unsecure(),isOptional:!1},userPromptTemplate:{type:t.String_unsecure(),isOptional:!0},toolIds:{type:t.String_unsecure(),isArray:!0,isOptional:!0},toolChoice:{type:C,isOptional:!0},maxIterations:{type:t.Int_unsecure(),isOptional:!0},maxTokensPerRun:{type:t.Int_unsecure(),isOptional:!0},timeoutMs:{type:t.Int_unsecure(),isOptional:!0},tags:{type:t.String_unsecure(),isArray:!0,isOptional:!0}}}),R=q({name:"UpdateAgentInput",description:"Input for updating an agent",fields:{agentId:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!0},description:{type:t.String_unsecure(),isOptional:!0},status:{type:w,isOptional:!0},modelConfig:{type:t.JSONObject(),isOptional:!0},systemPrompt:{type:t.String_unsecure(),isOptional:!0},userPromptTemplate:{type:t.String_unsecure(),isOptional:!0},toolIds:{type:t.String_unsecure(),isArray:!0,isOptional:!0},toolChoice:{type:C,isOptional:!0},maxIterations:{type:t.Int_unsecure(),isOptional:!0},maxTokensPerRun:{type:t.Int_unsecure(),isOptional:!0},timeoutMs:{type:t.Int_unsecure(),isOptional:!0},tags:{type:t.String_unsecure(),isArray:!0,isOptional:!0}}});import{defineCommand as z,defineQuery as M}from"@contractspec/lib.contracts-spec/operations";import{defineSchemaModel as D,ScalarTypeEnum as e}from"@contractspec/lib.schema";var x=["@agent-console-team"],W=z({meta:{key:"agent-console.agent.create",version:"1.0.0",stability:"stable",owners:[...x],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:k,output:D({name:"CreateAgentOutput",fields:{id:{type:e.String_unsecure(),isOptional:!1},name:{type:e.NonEmptyString(),isOptional:!1},slug:{type:e.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:G.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=z({meta:{key:"agent-console.agent.update",version:"1.0.0",stability:"stable",owners:[...x],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:R,output:D({name:"UpdateAgentOutput",fields:{id:{type:e.String_unsecure(),isOptional:!1},name:{type:e.NonEmptyString(),isOptional:!1},status:{type:w,isOptional:!1},updatedAt:{type:e.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:[...x],tags:["agent","updated"],when:"Agent is updated",payload:d}],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"}}]}}),m=M({meta:{key:"agent-console.agent.get",version:"1.0.0",stability:"stable",owners:[...x],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:D({name:"GetAgentInput",fields:{agentId:{type:e.String_unsecure(),isOptional:!1},includeTools:{type:e.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:[]}}]}}),u=M({meta:{key:"agent-console.agent.list",version:"1.0.0",stability:"stable",owners:[...x],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:D({name:"ListAgentsInput",fields:{organizationId:{type:e.String_unsecure(),isOptional:!1},status:{type:w,isOptional:!0},modelProvider:{type:b,isOptional:!0},search:{type:e.String_unsecure(),isOptional:!0},limit:{type:e.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:e.Int_unsecure(),isOptional:!0,defaultValue:0}}}),output:D({name:"ListAgentsOutput",fields:{items:{type:d,isArray:!0,isOptional:!1},total:{type:e.Int_unsecure(),isOptional:!1},hasMore:{type:e.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}}]}}),et=z({meta:{key:"agent-console.agent.assignTool",version:"1.0.0",stability:"stable",owners:[...x],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:D({name:"AssignToolToAgentInput",fields:{agentId:{type:e.String_unsecure(),isOptional:!1},toolId:{type:e.String_unsecure(),isOptional:!1},config:{type:e.JSONObject(),isOptional:!0},order:{type:e.Int_unsecure(),isOptional:!0}}}),output:D({name:"AssignToolToAgentOutput",fields:{agentToolId:{type:e.String_unsecure(),isOptional:!1},agentId:{type:e.String_unsecure(),isOptional:!1},toolId:{type:e.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"}}]}}),it=z({meta:{key:"agent-console.agent.removeTool",version:"1.0.0",stability:"stable",owners:[...x],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:D({name:"RemoveToolFromAgentInput",fields:{agentId:{type:e.String_unsecure(),isOptional:!1},toolId:{type:e.String_unsecure(),isOptional:!1}}}),output:D({name:"RemoveToolFromAgentOutput",fields:{success:{type:e.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}}]}});var gt=Z.length+1;async function rt(g){let{organizationId:r,status:A,modelProvider:I,search:F,limit:n=20,offset:V=0}=g,v=Z.filter((i)=>i.organizationId===r);if(A)v=v.filter((i)=>i.status===A);if(I)v=v.filter((i)=>i.modelProvider===I);if(F){let i=F.toLowerCase();v=v.filter((H)=>H.name.toLowerCase().includes(i)||H.description?.toLowerCase().includes(i)||H.tags?.some((c)=>c.toLowerCase().includes(i)))}let J=v.length;return{items:v.slice(V,V+n).map((i)=>({id:i.id,name:i.name,slug:i.slug,description:i.description,status:i.status,modelProvider:i.modelProvider,modelName:i.modelName,version:i.version,createdAt:i.createdAt})),total:J,hasMore:V+n<J}}async function At(g){let r=Z.find((I)=>I.id===g.agentId);if(!r)throw Error("AGENT_NOT_FOUND");let A={...r,toolIds:["tool-1","tool-2"]};if(g.includeTools)A.tools=O.slice(0,2).map((I)=>({id:I.id,name:I.name,slug:I.slug,description:I.description,category:I.category}));return A}async function It(g){if(Z.some((A)=>A.organizationId===g.organizationId&&A.slug===g.slug))throw Error("SLUG_EXISTS");return{id:`agent-${gt++}`,name:g.name,slug:g.slug,status:"DRAFT"}}async function wt(g){let r=Z.find((A)=>A.id===g.agentId);if(!r)throw Error("AGENT_NOT_FOUND");return{id:r.id,name:g.name??r.name,status:g.status??r.status,updatedAt:new Date}}import{definePresentation as U,StabilityEnum as B}from"@contractspec/lib.contracts-spec";var Dt=U({meta:{key:"agent-console.agent.viewList",version:"1.0.0",title:"Agent List",description:"List view of AI agents with status, model provider, and version info",goal:"Provide an overview of all agents in an organization.",context:"Main landing page for agent management.",domain:"agent-console",owners:["@agent-console-team"],tags:["agent","list","dashboard"],stability:B.Experimental},source:{type:"component",framework:"react",componentKey:"AgentListView",props:d},targets:["react","markdown","application/json"],policy:{flags:["agent-console.enabled"]}}),vt=U({meta:{key:"agent-console.agent.detail",version:"1.0.0",title:"Agent Details",description:"Detailed view of an AI agent with configuration, tools, and recent runs",goal:"Allow users to inspect and configure a specific agent.",context:"Detailed view of an agent.",domain:"agent-console",owners:["@agent-console-team"],tags:["agent","detail"],stability:B.Experimental},source:{type:"component",framework:"react",componentKey:"AgentDetailView"},targets:["react","markdown"],policy:{flags:["agent-console.enabled"]}}),bt=U({meta:{key:"agent-console.dashboard",version:"1.0.0",title:"Agent Console Dashboard",description:"Dashboard overview of AI agents, runs, and tools",goal:"Provide a high-level overview of the AI platform health and usage.",context:"Root dashboard of the Agent Console.",domain:"agent-console",owners:["@agent-console-team"],tags:["dashboard","overview"],stability:B.Experimental},source:{type:"component",framework:"react",componentKey:"AgentConsoleDashboard"},targets:["react","markdown"],policy:{flags:["agent-console.enabled"]}});export{wt as mockUpdateAgentHandler,rt as mockListAgentsHandler,At as mockGetAgentHandler,It as mockCreateAgentHandler,R as UpdateAgentInputModel,p as UpdateAgentCommand,C as ToolChoiceEnum,it as RemoveToolFromAgentCommand,b as ModelProviderEnum,N as ModelProviderEntityEnum,u as ListAgentsQuery,m as GetAgentQuery,k as CreateAgentInputModel,W as CreateAgentCommand,et as AssignToolToAgentCommand,Y as AgentWithToolsModel,l as AgentUpdatedEvent,ot as AgentToolRemovedEvent,K as AgentToolRefModel,a as AgentToolEntity,S as AgentToolAssignedEvent,d as AgentSummaryModel,w as AgentStatusEnum,_ as AgentStatusEntityEnum,st as AgentModel,Dt as AgentListPresentation,f as AgentEntity,vt as AgentDetailPresentation,G as AgentCreatedEvent,bt as AgentConsoleDashboardPresentation};