@contractspec/example.agent-console 3.7.7 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/.turbo/turbo-build.log +126 -105
  2. package/AGENTS.md +3 -1
  3. package/CHANGELOG.md +29 -0
  4. package/README.md +46 -9
  5. package/dist/agent/agent.handler.d.ts +3 -0
  6. package/dist/agent/agent.handler.js +730 -1
  7. package/dist/agent/index.js +73 -72
  8. package/dist/agent.feature.js +179 -0
  9. package/dist/browser/agent/agent.handler.js +730 -1
  10. package/dist/browser/agent/index.js +73 -72
  11. package/dist/browser/agent.feature.js +179 -0
  12. package/dist/browser/docs/agent-console.docblock.js +11 -8
  13. package/dist/browser/docs/index.js +11 -8
  14. package/dist/browser/example.js +2 -3
  15. package/dist/browser/handlers/agent.handlers.js +1883 -2
  16. package/dist/browser/handlers/index.js +2142 -8
  17. package/dist/browser/index.js +3347 -2433
  18. package/dist/browser/presentations/index.js +49 -49
  19. package/dist/browser/run/index.js +818 -812
  20. package/dist/browser/run/run.handler.js +666 -1
  21. package/dist/browser/shared/index.js +293 -1
  22. package/dist/browser/shared/mock-runs.js +5 -0
  23. package/dist/browser/tool/index.js +331 -331
  24. package/dist/browser/tool/tool.handler.js +479 -3
  25. package/dist/browser/ui/AgentDashboard.js +1204 -319
  26. package/dist/browser/ui/AgentDashboard.visualizations.js +217 -0
  27. package/dist/browser/ui/AgentRunList.js +359 -127
  28. package/dist/browser/ui/hooks/index.js +468 -18
  29. package/dist/browser/ui/hooks/useAgentMutations.js +443 -8
  30. package/dist/browser/ui/hooks/useRunList.js +25 -10
  31. package/dist/browser/ui/index.js +1293 -390
  32. package/dist/browser/ui/renderers/agent-list.markdown.js +14 -5
  33. package/dist/browser/ui/renderers/dashboard.markdown.js +207 -36
  34. package/dist/browser/ui/renderers/index.js +245 -49
  35. package/dist/browser/ui/renderers/run-list.markdown.js +9 -4
  36. package/dist/browser/ui/renderers/tool-registry.markdown.js +15 -4
  37. package/dist/browser/ui/views/RunDataTable.js +326 -0
  38. package/dist/browser/ui/views/RunListView.js +359 -127
  39. package/dist/browser/ui/views/index.js +406 -174
  40. package/dist/browser/ui/views/run-data-table.columns.js +271 -0
  41. package/dist/browser/ui/views/run-list.shared.js +177 -0
  42. package/dist/browser/visualizations/catalog.js +134 -0
  43. package/dist/browser/visualizations/index.js +187 -0
  44. package/dist/browser/visualizations/selectors.js +181 -0
  45. package/dist/docs/agent-console.docblock.js +11 -8
  46. package/dist/docs/index.js +11 -8
  47. package/dist/example.js +2 -3
  48. package/dist/example.test.d.ts +1 -0
  49. package/dist/handlers/agent.handlers.d.ts +2 -0
  50. package/dist/handlers/agent.handlers.js +1883 -2
  51. package/dist/handlers/index.d.ts +1 -3
  52. package/dist/handlers/index.js +2142 -8
  53. package/dist/handlers/mock-handlers.test.d.ts +1 -0
  54. package/dist/index.d.ts +2 -0
  55. package/dist/index.js +3347 -2433
  56. package/dist/node/agent/agent.handler.js +730 -1
  57. package/dist/node/agent/index.js +73 -72
  58. package/dist/node/agent.feature.js +179 -0
  59. package/dist/node/docs/agent-console.docblock.js +11 -8
  60. package/dist/node/docs/index.js +11 -8
  61. package/dist/node/example.js +2 -3
  62. package/dist/node/handlers/agent.handlers.js +1883 -2
  63. package/dist/node/handlers/index.js +2142 -8
  64. package/dist/node/index.js +3347 -2433
  65. package/dist/node/presentations/index.js +49 -49
  66. package/dist/node/run/index.js +818 -812
  67. package/dist/node/run/run.handler.js +666 -1
  68. package/dist/node/shared/index.js +293 -1
  69. package/dist/node/shared/mock-runs.js +5 -0
  70. package/dist/node/tool/index.js +331 -331
  71. package/dist/node/tool/tool.handler.js +479 -3
  72. package/dist/node/ui/AgentDashboard.js +1204 -319
  73. package/dist/node/ui/AgentDashboard.visualizations.js +217 -0
  74. package/dist/node/ui/AgentRunList.js +359 -127
  75. package/dist/node/ui/hooks/index.js +468 -18
  76. package/dist/node/ui/hooks/useAgentMutations.js +443 -8
  77. package/dist/node/ui/hooks/useRunList.js +25 -10
  78. package/dist/node/ui/index.js +1293 -390
  79. package/dist/node/ui/renderers/agent-list.markdown.js +14 -5
  80. package/dist/node/ui/renderers/dashboard.markdown.js +207 -36
  81. package/dist/node/ui/renderers/index.js +245 -49
  82. package/dist/node/ui/renderers/run-list.markdown.js +9 -4
  83. package/dist/node/ui/renderers/tool-registry.markdown.js +15 -4
  84. package/dist/node/ui/views/RunDataTable.js +326 -0
  85. package/dist/node/ui/views/RunListView.js +359 -127
  86. package/dist/node/ui/views/index.js +406 -174
  87. package/dist/node/ui/views/run-data-table.columns.js +271 -0
  88. package/dist/node/ui/views/run-list.shared.js +177 -0
  89. package/dist/node/visualizations/catalog.js +134 -0
  90. package/dist/node/visualizations/index.js +187 -0
  91. package/dist/node/visualizations/selectors.js +181 -0
  92. package/dist/presentations/index.js +49 -49
  93. package/dist/proof/index.d.ts +2 -0
  94. package/dist/proof/meetup-proof.d.ts +10 -0
  95. package/dist/proof/meetup-proof.runtime.d.ts +22 -0
  96. package/dist/proof/meetup-proof.scenario.d.ts +2 -0
  97. package/dist/proof/meetup-proof.suite.d.ts +1 -0
  98. package/dist/proof/meetup-proof.test.d.ts +1 -0
  99. package/dist/run/index.js +818 -812
  100. package/dist/run/run.handler.d.ts +4 -0
  101. package/dist/run/run.handler.js +666 -1
  102. package/dist/shared/demo-dashboard-data.d.ts +16 -0
  103. package/dist/shared/demo-runtime-seed.d.ts +17 -0
  104. package/dist/shared/demo-runtime.d.ts +8 -0
  105. package/dist/shared/demo-runtime.test.d.ts +1 -0
  106. package/dist/shared/index.d.ts +3 -0
  107. package/dist/shared/index.js +293 -1
  108. package/dist/shared/mock-runs.d.ts +4 -0
  109. package/dist/shared/mock-runs.js +5 -0
  110. package/dist/tool/index.js +331 -331
  111. package/dist/tool/tool.handler.d.ts +4 -1
  112. package/dist/tool/tool.handler.js +479 -3
  113. package/dist/ui/AgentDashboard.js +1204 -319
  114. package/dist/ui/AgentDashboard.sandbox.test.d.ts +1 -0
  115. package/dist/ui/AgentDashboard.visualizations.d.ts +4 -0
  116. package/dist/ui/AgentDashboard.visualizations.js +218 -0
  117. package/dist/ui/AgentRunList.js +359 -127
  118. package/dist/ui/hooks/index.js +468 -18
  119. package/dist/ui/hooks/useAgentMutations.js +443 -8
  120. package/dist/ui/hooks/useRunList.d.ts +8 -2
  121. package/dist/ui/hooks/useRunList.js +25 -10
  122. package/dist/ui/index.js +1293 -390
  123. package/dist/ui/renderers/agent-list.markdown.js +14 -5
  124. package/dist/ui/renderers/dashboard.markdown.js +207 -36
  125. package/dist/ui/renderers/index.js +245 -49
  126. package/dist/ui/renderers/run-list.markdown.js +9 -4
  127. package/dist/ui/renderers/tool-registry.markdown.d.ts +1 -1
  128. package/dist/ui/renderers/tool-registry.markdown.js +15 -4
  129. package/dist/ui/views/RunDataTable.d.ts +18 -0
  130. package/dist/ui/views/RunDataTable.js +327 -0
  131. package/dist/ui/views/RunListView.js +359 -127
  132. package/dist/ui/views/index.js +406 -174
  133. package/dist/ui/views/run-data-table.columns.d.ts +3 -0
  134. package/dist/ui/views/run-data-table.columns.js +272 -0
  135. package/dist/ui/views/run-list.shared.d.ts +14 -0
  136. package/dist/ui/views/run-list.shared.js +178 -0
  137. package/dist/visualizations/catalog.d.ts +10 -0
  138. package/dist/visualizations/catalog.js +135 -0
  139. package/dist/visualizations/index.d.ts +2 -0
  140. package/dist/visualizations/index.js +188 -0
  141. package/dist/visualizations/selectors.d.ts +3 -0
  142. package/dist/visualizations/selectors.js +182 -0
  143. package/dist/visualizations/selectors.test.d.ts +1 -0
  144. package/package.json +112 -10
  145. package/proofs/agent-console-meetup.replay.json +220 -0
  146. package/src/agent/agent.handler.ts +18 -1
  147. package/src/agent.feature.ts +3 -0
  148. package/src/docs/agent-console.docblock.ts +11 -8
  149. package/src/example.test.ts +75 -0
  150. package/src/example.ts +2 -3
  151. package/src/handlers/agent.handlers.ts +55 -2
  152. package/src/handlers/index.ts +18 -2
  153. package/src/handlers/mock-handlers.test.ts +77 -0
  154. package/src/index.ts +2 -0
  155. package/src/proof/index.ts +2 -0
  156. package/src/proof/meetup-proof.runtime.ts +196 -0
  157. package/src/proof/meetup-proof.scenario.ts +99 -0
  158. package/src/proof/meetup-proof.suite.ts +29 -0
  159. package/src/proof/meetup-proof.test.ts +28 -0
  160. package/src/proof/meetup-proof.ts +130 -0
  161. package/src/run/run.handler.ts +17 -1
  162. package/src/shared/demo-dashboard-data.ts +58 -0
  163. package/src/shared/demo-runtime-seed.ts +139 -0
  164. package/src/shared/demo-runtime.test.ts +169 -0
  165. package/src/shared/demo-runtime.ts +260 -0
  166. package/src/shared/index.ts +11 -0
  167. package/src/shared/mock-runs.ts +5 -0
  168. package/src/tool/tool.handler.ts +21 -4
  169. package/src/ui/AgentDashboard.sandbox.test.tsx +312 -0
  170. package/src/ui/AgentDashboard.tsx +4 -1
  171. package/src/ui/AgentDashboard.visualizations.tsx +35 -0
  172. package/src/ui/hooks/useAgentMutations.ts +19 -11
  173. package/src/ui/hooks/useRunList.ts +41 -9
  174. package/src/ui/renderers/agent-list.markdown.ts +31 -12
  175. package/src/ui/renderers/dashboard.markdown.ts +37 -42
  176. package/src/ui/renderers/run-list.markdown.ts +16 -8
  177. package/src/ui/renderers/tool-registry.markdown.ts +21 -9
  178. package/src/ui/views/RunDataTable.tsx +74 -0
  179. package/src/ui/views/RunListView.tsx +37 -111
  180. package/src/ui/views/run-data-table.columns.tsx +102 -0
  181. package/src/ui/views/run-list.shared.tsx +139 -0
  182. package/src/visualizations/catalog.ts +132 -0
  183. package/src/visualizations/index.ts +2 -0
  184. package/src/visualizations/selectors.test.ts +12 -0
  185. package/src/visualizations/selectors.ts +70 -0
  186. package/tsdown.config.js +17 -0
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Mock handlers for Tool contracts.
3
+ */
1
4
  export interface ListToolsInput {
2
5
  organizationId: string;
3
6
  category?: 'RETRIEVAL' | 'COMPUTATION' | 'COMMUNICATION' | 'INTEGRATION' | 'UTILITY' | 'CUSTOM';
@@ -292,7 +295,7 @@ export declare function mockUpdateToolHandler(input: {
292
295
  }): Promise<{
293
296
  id: string;
294
297
  name: string;
295
- status: "DRAFT" | "ACTIVE" | "DISABLED" | "DEPRECATED";
298
+ status: "DRAFT" | "ACTIVE" | "DEPRECATED" | "DISABLED";
296
299
  updatedAt: Date;
297
300
  }>;
298
301
  /**
@@ -143,7 +143,484 @@ var MOCK_TOOLS = [
143
143
  }
144
144
  ];
145
145
 
146
+ // src/tool/tool.enum.ts
147
+ import { defineEnum } from "@contractspec/lib.schema";
148
+ var ToolCategoryEnum = defineEnum("ToolCategory", [
149
+ "RETRIEVAL",
150
+ "COMPUTATION",
151
+ "COMMUNICATION",
152
+ "INTEGRATION",
153
+ "UTILITY",
154
+ "CUSTOM"
155
+ ]);
156
+ var ToolStatusEnum = defineEnum("ToolStatus", [
157
+ "DRAFT",
158
+ "ACTIVE",
159
+ "DEPRECATED",
160
+ "DISABLED"
161
+ ]);
162
+ var ImplementationTypeEnum = defineEnum("ImplementationType", [
163
+ "http",
164
+ "function",
165
+ "workflow"
166
+ ]);
167
+
168
+ // src/tool/tool.schema.ts
169
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
170
+ var ToolModel = defineSchemaModel({
171
+ name: "Tool",
172
+ description: "AI tool definition",
173
+ fields: {
174
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
175
+ organizationId: {
176
+ type: ScalarTypeEnum.String_unsecure(),
177
+ isOptional: false
178
+ },
179
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
180
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
181
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
182
+ category: { type: ToolCategoryEnum, isOptional: false },
183
+ status: { type: ToolStatusEnum, isOptional: false },
184
+ parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
185
+ outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
186
+ implementationType: { type: ImplementationTypeEnum, isOptional: false },
187
+ implementationConfig: {
188
+ type: ScalarTypeEnum.JSONObject(),
189
+ isOptional: false
190
+ },
191
+ maxInvocationsPerMinute: {
192
+ type: ScalarTypeEnum.Int_unsecure(),
193
+ isOptional: true
194
+ },
195
+ timeoutMs: {
196
+ type: ScalarTypeEnum.Int_unsecure(),
197
+ isOptional: false,
198
+ defaultValue: 30000
199
+ },
200
+ version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
201
+ tags: {
202
+ type: ScalarTypeEnum.String_unsecure(),
203
+ isArray: true,
204
+ isOptional: true
205
+ },
206
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
207
+ updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
208
+ }
209
+ });
210
+ var ToolSummaryModel = defineSchemaModel({
211
+ name: "ToolSummary",
212
+ description: "Summary of a tool for list views",
213
+ fields: {
214
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
215
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
216
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
217
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
218
+ category: { type: ToolCategoryEnum, isOptional: false },
219
+ status: { type: ToolStatusEnum, isOptional: false },
220
+ version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
221
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
222
+ }
223
+ });
224
+ var CreateToolInputModel = defineSchemaModel({
225
+ name: "CreateToolInput",
226
+ description: "Input for creating a tool",
227
+ fields: {
228
+ organizationId: {
229
+ type: ScalarTypeEnum.String_unsecure(),
230
+ isOptional: false
231
+ },
232
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
233
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
234
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
235
+ category: { type: ToolCategoryEnum, isOptional: true },
236
+ parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
237
+ outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
238
+ implementationType: { type: ImplementationTypeEnum, isOptional: false },
239
+ implementationConfig: {
240
+ type: ScalarTypeEnum.JSONObject(),
241
+ isOptional: false
242
+ },
243
+ maxInvocationsPerMinute: {
244
+ type: ScalarTypeEnum.Int_unsecure(),
245
+ isOptional: true
246
+ },
247
+ timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
248
+ tags: {
249
+ type: ScalarTypeEnum.String_unsecure(),
250
+ isArray: true,
251
+ isOptional: true
252
+ }
253
+ }
254
+ });
255
+ var UpdateToolInputModel = defineSchemaModel({
256
+ name: "UpdateToolInput",
257
+ description: "Input for updating a tool",
258
+ fields: {
259
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
260
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: true },
261
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
262
+ status: { type: ToolStatusEnum, isOptional: true },
263
+ parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
264
+ outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
265
+ implementationConfig: {
266
+ type: ScalarTypeEnum.JSONObject(),
267
+ isOptional: true
268
+ },
269
+ maxInvocationsPerMinute: {
270
+ type: ScalarTypeEnum.Int_unsecure(),
271
+ isOptional: true
272
+ },
273
+ timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
274
+ tags: {
275
+ type: ScalarTypeEnum.String_unsecure(),
276
+ isArray: true,
277
+ isOptional: true
278
+ }
279
+ }
280
+ });
281
+
282
+ // src/tool/tool.operation.ts
283
+ import {
284
+ defineCommand,
285
+ defineQuery
286
+ } from "@contractspec/lib.contracts-spec/operations";
287
+ import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
288
+ var OWNERS = ["@agent-console-team"];
289
+ var CreateToolCommand = defineCommand({
290
+ meta: {
291
+ key: "agent.tool.create",
292
+ version: "1.0.0",
293
+ stability: "stable",
294
+ owners: [...OWNERS],
295
+ tags: ["tool", "create"],
296
+ description: "Creates a new AI tool definition.",
297
+ goal: "Allow users to define new tools that agents can use.",
298
+ context: "Called from the tool builder UI when creating a new tool."
299
+ },
300
+ io: {
301
+ input: CreateToolInputModel,
302
+ output: defineSchemaModel2({
303
+ name: "CreateToolOutput",
304
+ fields: {
305
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
306
+ name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
307
+ slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
308
+ status: { type: ToolStatusEnum, isOptional: false }
309
+ }
310
+ }),
311
+ errors: {
312
+ SLUG_EXISTS: {
313
+ description: "A tool with this slug already exists in the organization",
314
+ http: 409,
315
+ gqlCode: "SLUG_EXISTS",
316
+ when: "Slug is already taken"
317
+ }
318
+ }
319
+ },
320
+ policy: { auth: "user" },
321
+ sideEffects: {
322
+ emits: [
323
+ {
324
+ key: "tool.created",
325
+ version: "1.0.0",
326
+ stability: "stable",
327
+ owners: [...OWNERS],
328
+ tags: ["tool", "created"],
329
+ when: "Tool is successfully created",
330
+ payload: ToolSummaryModel
331
+ }
332
+ ],
333
+ audit: ["tool.created"]
334
+ },
335
+ acceptance: {
336
+ scenarios: [
337
+ {
338
+ key: "create-tool-happy-path",
339
+ given: ["User is authenticated", "Organization exists"],
340
+ when: ["User submits valid tool configuration"],
341
+ then: ["New tool is created", "ToolCreated event is emitted"]
342
+ },
343
+ {
344
+ key: "create-tool-slug-conflict",
345
+ given: ["Tool with same slug exists"],
346
+ when: ["User submits tool with duplicate slug"],
347
+ then: ["SLUG_EXISTS error is returned"]
348
+ }
349
+ ],
350
+ examples: [
351
+ {
352
+ key: "create-api-tool",
353
+ input: {
354
+ name: "Weather API",
355
+ slug: "weather-api",
356
+ category: "api",
357
+ description: "Fetches weather data"
358
+ },
359
+ output: {
360
+ id: "tool-123",
361
+ name: "Weather API",
362
+ slug: "weather-api",
363
+ status: "draft"
364
+ }
365
+ }
366
+ ]
367
+ }
368
+ });
369
+ var UpdateToolCommand = defineCommand({
370
+ meta: {
371
+ key: "agent.tool.update",
372
+ version: "1.0.0",
373
+ stability: "stable",
374
+ owners: [...OWNERS],
375
+ tags: ["tool", "update"],
376
+ description: "Updates an existing AI tool definition.",
377
+ goal: "Allow users to modify tool settings and configuration.",
378
+ context: "Called from the tool settings UI."
379
+ },
380
+ io: {
381
+ input: UpdateToolInputModel,
382
+ output: defineSchemaModel2({
383
+ name: "UpdateToolOutput",
384
+ fields: {
385
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
386
+ name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
387
+ status: { type: ToolStatusEnum, isOptional: false },
388
+ updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
389
+ }
390
+ }),
391
+ errors: {
392
+ TOOL_NOT_FOUND: {
393
+ description: "The specified tool does not exist",
394
+ http: 404,
395
+ gqlCode: "TOOL_NOT_FOUND",
396
+ when: "Tool ID is invalid"
397
+ }
398
+ }
399
+ },
400
+ policy: { auth: "user" },
401
+ sideEffects: {
402
+ emits: [
403
+ {
404
+ key: "tool.updated",
405
+ version: "1.0.0",
406
+ stability: "stable",
407
+ owners: [...OWNERS],
408
+ tags: ["tool", "updated"],
409
+ when: "Tool is updated",
410
+ payload: ToolSummaryModel
411
+ }
412
+ ],
413
+ audit: ["tool.updated"]
414
+ },
415
+ acceptance: {
416
+ scenarios: [
417
+ {
418
+ key: "update-tool-happy-path",
419
+ given: ["Tool exists", "User owns the tool"],
420
+ when: ["User submits updated configuration"],
421
+ then: ["Tool is updated", "ToolUpdated event is emitted"]
422
+ }
423
+ ],
424
+ examples: [
425
+ {
426
+ key: "update-description",
427
+ input: { toolId: "tool-123", description: "Updated weather API tool" },
428
+ output: {
429
+ id: "tool-123",
430
+ name: "Weather API",
431
+ status: "draft",
432
+ updatedAt: "2025-01-01T00:00:00Z"
433
+ }
434
+ }
435
+ ]
436
+ }
437
+ });
438
+ var GetToolQuery = defineQuery({
439
+ meta: {
440
+ key: "agent.tool.get",
441
+ version: "1.0.0",
442
+ stability: "stable",
443
+ owners: [...OWNERS],
444
+ tags: ["tool", "get"],
445
+ description: "Retrieves a tool by its ID.",
446
+ goal: "View detailed tool configuration.",
447
+ context: "Called when viewing tool details or editing."
448
+ },
449
+ io: {
450
+ input: defineSchemaModel2({
451
+ name: "GetToolInput",
452
+ fields: {
453
+ toolId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
454
+ }
455
+ }),
456
+ output: ToolModel,
457
+ errors: {
458
+ TOOL_NOT_FOUND: {
459
+ description: "The specified tool does not exist",
460
+ http: 404,
461
+ gqlCode: "TOOL_NOT_FOUND",
462
+ when: "Tool ID is invalid"
463
+ }
464
+ }
465
+ },
466
+ policy: { auth: "user" },
467
+ acceptance: {
468
+ scenarios: [
469
+ {
470
+ key: "get-tool-happy-path",
471
+ given: ["Tool exists"],
472
+ when: ["User requests tool by ID"],
473
+ then: ["Tool details are returned"]
474
+ }
475
+ ],
476
+ examples: [
477
+ {
478
+ key: "get-basic",
479
+ input: { toolId: "tool-123" },
480
+ output: {
481
+ id: "tool-123",
482
+ name: "Weather API",
483
+ status: "active",
484
+ category: "api"
485
+ }
486
+ }
487
+ ]
488
+ }
489
+ });
490
+ var ListToolsQuery = defineQuery({
491
+ meta: {
492
+ key: "agent.tool.list",
493
+ version: "1.0.0",
494
+ stability: "stable",
495
+ owners: [...OWNERS],
496
+ tags: ["tool", "list"],
497
+ description: "Lists tools for an organization with optional filtering.",
498
+ goal: "Browse and search available tools.",
499
+ context: "Tool list/dashboard view."
500
+ },
501
+ io: {
502
+ input: defineSchemaModel2({
503
+ name: "ListToolsInput",
504
+ fields: {
505
+ organizationId: {
506
+ type: ScalarTypeEnum2.String_unsecure(),
507
+ isOptional: false
508
+ },
509
+ category: { type: ToolCategoryEnum, isOptional: true },
510
+ status: { type: ToolStatusEnum, isOptional: true },
511
+ search: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
512
+ limit: {
513
+ type: ScalarTypeEnum2.Int_unsecure(),
514
+ isOptional: true,
515
+ defaultValue: 20
516
+ },
517
+ offset: {
518
+ type: ScalarTypeEnum2.Int_unsecure(),
519
+ isOptional: true,
520
+ defaultValue: 0
521
+ }
522
+ }
523
+ }),
524
+ output: defineSchemaModel2({
525
+ name: "ListToolsOutput",
526
+ fields: {
527
+ items: { type: ToolSummaryModel, isArray: true, isOptional: false },
528
+ total: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
529
+ hasMore: { type: ScalarTypeEnum2.Boolean(), isOptional: false }
530
+ }
531
+ })
532
+ },
533
+ policy: { auth: "user" },
534
+ acceptance: {
535
+ scenarios: [
536
+ {
537
+ key: "list-tools-happy-path",
538
+ given: ["Organization has tools"],
539
+ when: ["User lists tools"],
540
+ then: ["Paginated list of tools is returned"]
541
+ }
542
+ ],
543
+ examples: [
544
+ {
545
+ key: "list-by-category",
546
+ input: { organizationId: "org-123", category: "api", limit: 10 },
547
+ output: { items: [], total: 0, hasMore: false }
548
+ }
549
+ ]
550
+ }
551
+ });
552
+ var TestToolCommand = defineCommand({
553
+ meta: {
554
+ key: "agent.tool.test",
555
+ version: "1.0.0",
556
+ stability: "stable",
557
+ owners: [...OWNERS],
558
+ tags: ["tool", "test"],
559
+ description: "Tests a tool with sample input to verify it works correctly.",
560
+ goal: "Validate tool configuration before deployment.",
561
+ context: "Tool builder UI - test panel."
562
+ },
563
+ io: {
564
+ input: defineSchemaModel2({
565
+ name: "TestToolInput",
566
+ fields: {
567
+ toolId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
568
+ testInput: { type: ScalarTypeEnum2.JSONObject(), isOptional: false }
569
+ }
570
+ }),
571
+ output: defineSchemaModel2({
572
+ name: "TestToolOutput",
573
+ fields: {
574
+ success: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
575
+ output: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
576
+ error: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
577
+ durationMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false }
578
+ }
579
+ }),
580
+ errors: {
581
+ TOOL_NOT_FOUND: {
582
+ description: "The specified tool does not exist",
583
+ http: 404,
584
+ gqlCode: "TOOL_NOT_FOUND",
585
+ when: "Tool ID is invalid"
586
+ },
587
+ TOOL_EXECUTION_ERROR: {
588
+ description: "Tool execution failed",
589
+ http: 500,
590
+ gqlCode: "TOOL_EXECUTION_ERROR",
591
+ when: "Tool returns an error"
592
+ }
593
+ }
594
+ },
595
+ policy: { auth: "user" },
596
+ sideEffects: { audit: ["tool.tested"] },
597
+ acceptance: {
598
+ scenarios: [
599
+ {
600
+ key: "test-tool-success",
601
+ given: ["Tool exists", "Tool is configured correctly"],
602
+ when: ["User runs test with valid input"],
603
+ then: ["Tool executes successfully", "Output is returned"]
604
+ },
605
+ {
606
+ key: "test-tool-failure",
607
+ given: ["Tool exists", "Tool has configuration error"],
608
+ when: ["User runs test"],
609
+ then: ["TOOL_EXECUTION_ERROR is returned"]
610
+ }
611
+ ],
612
+ examples: [
613
+ {
614
+ key: "test-weather-api",
615
+ input: { toolId: "tool-123", testInput: { city: "Paris" } },
616
+ output: { success: true, output: { temperature: 22 }, durationMs: 150 }
617
+ }
618
+ ]
619
+ }
620
+ });
621
+
146
622
  // src/tool/tool.handler.ts
623
+ var nextMockToolId = MOCK_TOOLS.length + 1;
147
624
  async function mockListToolsHandler(input) {
148
625
  const {
149
626
  organizationId,
@@ -186,7 +663,7 @@ async function mockCreateToolHandler(input) {
186
663
  if (exists)
187
664
  throw new Error("SLUG_EXISTS");
188
665
  return {
189
- id: `tool-${Date.now()}`,
666
+ id: `tool-${nextMockToolId++}`,
190
667
  name: input.name,
191
668
  slug: input.slug,
192
669
  status: "DRAFT"
@@ -207,12 +684,11 @@ async function mockTestToolHandler(input) {
207
684
  const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
208
685
  if (!tool)
209
686
  throw new Error("TOOL_NOT_FOUND");
210
- const startTime = Date.now();
211
687
  await new Promise((resolve) => setTimeout(resolve, 100));
212
688
  return {
213
689
  success: true,
214
690
  output: { result: "Test successful", input: input.testInput },
215
- durationMs: Date.now() - startTime
691
+ durationMs: 100
216
692
  };
217
693
  }
218
694
  export {