@contractspec/example.agent-console 0.0.0-canary-20260113170453

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 (306) hide show
  1. package/.turbo/turbo-build$colon$bundle.log +280 -0
  2. package/.turbo/turbo-build.log +281 -0
  3. package/CHANGELOG.md +368 -0
  4. package/LICENSE +21 -0
  5. package/README.md +86 -0
  6. package/dist/agent/agent.entity.d.ts +55 -0
  7. package/dist/agent/agent.entity.d.ts.map +1 -0
  8. package/dist/agent/agent.entity.js +136 -0
  9. package/dist/agent/agent.entity.js.map +1 -0
  10. package/dist/agent/agent.enum.d.ts +18 -0
  11. package/dist/agent/agent.enum.d.ts.map +1 -0
  12. package/dist/agent/agent.enum.js +34 -0
  13. package/dist/agent/agent.enum.js.map +1 -0
  14. package/dist/agent/agent.event.d.ts +128 -0
  15. package/dist/agent/agent.event.d.ts.map +1 -0
  16. package/dist/agent/agent.event.js +210 -0
  17. package/dist/agent/agent.event.js.map +1 -0
  18. package/dist/agent/agent.handler.d.ts +100 -0
  19. package/dist/agent/agent.handler.d.ts.map +1 -0
  20. package/dist/agent/agent.handler.js +84 -0
  21. package/dist/agent/agent.handler.js.map +1 -0
  22. package/dist/agent/agent.operation.d.ts +471 -0
  23. package/dist/agent/agent.operation.d.ts.map +1 -0
  24. package/dist/agent/agent.operation.js +486 -0
  25. package/dist/agent/agent.operation.js.map +1 -0
  26. package/dist/agent/agent.presentation.d.ts +18 -0
  27. package/dist/agent/agent.presentation.d.ts.map +1 -0
  28. package/dist/agent/agent.presentation.js +89 -0
  29. package/dist/agent/agent.presentation.js.map +1 -0
  30. package/dist/agent/agent.schema.d.ts +401 -0
  31. package/dist/agent/agent.schema.d.ts.map +1 -0
  32. package/dist/agent/agent.schema.js +406 -0
  33. package/dist/agent/agent.schema.js.map +1 -0
  34. package/dist/agent/agent.test-spec.d.ts +8 -0
  35. package/dist/agent/agent.test-spec.d.ts.map +1 -0
  36. package/dist/agent/agent.test-spec.js +65 -0
  37. package/dist/agent/agent.test-spec.js.map +1 -0
  38. package/dist/agent/index.d.ts +8 -0
  39. package/dist/agent/index.js +9 -0
  40. package/dist/agent.capability.d.ts +7 -0
  41. package/dist/agent.capability.d.ts.map +1 -0
  42. package/dist/agent.capability.js +20 -0
  43. package/dist/agent.capability.js.map +1 -0
  44. package/dist/agent.feature.d.ts +12 -0
  45. package/dist/agent.feature.d.ts.map +1 -0
  46. package/dist/agent.feature.js +305 -0
  47. package/dist/agent.feature.js.map +1 -0
  48. package/dist/docs/agent-console.docblock.d.ts +1 -0
  49. package/dist/docs/agent-console.docblock.js +113 -0
  50. package/dist/docs/agent-console.docblock.js.map +1 -0
  51. package/dist/docs/index.d.ts +1 -0
  52. package/dist/docs/index.js +1 -0
  53. package/dist/example.d.ts +7 -0
  54. package/dist/example.d.ts.map +1 -0
  55. package/dist/example.js +58 -0
  56. package/dist/example.js.map +1 -0
  57. package/dist/handlers/agent.handlers.d.ts +135 -0
  58. package/dist/handlers/agent.handlers.d.ts.map +1 -0
  59. package/dist/handlers/agent.handlers.js +263 -0
  60. package/dist/handlers/agent.handlers.js.map +1 -0
  61. package/dist/handlers/index.d.ts +5 -0
  62. package/dist/handlers/index.js +6 -0
  63. package/dist/index.d.ts +48 -0
  64. package/dist/index.js +50 -0
  65. package/dist/presentations/index.d.ts +4 -0
  66. package/dist/presentations/index.js +5 -0
  67. package/dist/run/index.d.ts +8 -0
  68. package/dist/run/index.js +9 -0
  69. package/dist/run/run.entity.d.ts +82 -0
  70. package/dist/run/run.entity.d.ts.map +1 -0
  71. package/dist/run/run.entity.js +205 -0
  72. package/dist/run/run.entity.js.map +1 -0
  73. package/dist/run/run.enum.d.ts +22 -0
  74. package/dist/run/run.enum.d.ts.map +1 -0
  75. package/dist/run/run.enum.js +45 -0
  76. package/dist/run/run.enum.js.map +1 -0
  77. package/dist/run/run.event.d.ts +290 -0
  78. package/dist/run/run.event.d.ts.map +1 -0
  79. package/dist/run/run.event.js +434 -0
  80. package/dist/run/run.event.js.map +1 -0
  81. package/dist/run/run.handler.d.ts +203 -0
  82. package/dist/run/run.handler.d.ts.map +1 -0
  83. package/dist/run/run.handler.js +83 -0
  84. package/dist/run/run.handler.js.map +1 -0
  85. package/dist/run/run.operation.d.ts +720 -0
  86. package/dist/run/run.operation.d.ts.map +1 -0
  87. package/dist/run/run.operation.js +626 -0
  88. package/dist/run/run.operation.js.map +1 -0
  89. package/dist/run/run.presentation.d.ts +14 -0
  90. package/dist/run/run.presentation.d.ts.map +1 -0
  91. package/dist/run/run.presentation.js +65 -0
  92. package/dist/run/run.presentation.js.map +1 -0
  93. package/dist/run/run.schema.d.ts +416 -0
  94. package/dist/run/run.schema.d.ts.map +1 -0
  95. package/dist/run/run.schema.js +338 -0
  96. package/dist/run/run.schema.js.map +1 -0
  97. package/dist/run/run.test-spec.d.ts +8 -0
  98. package/dist/run/run.test-spec.d.ts.map +1 -0
  99. package/dist/run/run.test-spec.js +65 -0
  100. package/dist/run/run.test-spec.js.map +1 -0
  101. package/dist/seeders/index.d.ts +10 -0
  102. package/dist/seeders/index.d.ts.map +1 -0
  103. package/dist/seeders/index.js +20 -0
  104. package/dist/seeders/index.js.map +1 -0
  105. package/dist/shared/index.d.ts +4 -0
  106. package/dist/shared/index.js +5 -0
  107. package/dist/shared/mock-agents.d.ts +88 -0
  108. package/dist/shared/mock-agents.d.ts.map +1 -0
  109. package/dist/shared/mock-agents.js +94 -0
  110. package/dist/shared/mock-agents.js.map +1 -0
  111. package/dist/shared/mock-runs.d.ts +120 -0
  112. package/dist/shared/mock-runs.d.ts.map +1 -0
  113. package/dist/shared/mock-runs.js +118 -0
  114. package/dist/shared/mock-runs.js.map +1 -0
  115. package/dist/shared/mock-tools.d.ts +244 -0
  116. package/dist/shared/mock-tools.d.ts.map +1 -0
  117. package/dist/shared/mock-tools.js +181 -0
  118. package/dist/shared/mock-tools.js.map +1 -0
  119. package/dist/shared/overlay-types.d.ts +34 -0
  120. package/dist/shared/overlay-types.d.ts.map +1 -0
  121. package/dist/shared/overlay-types.js +0 -0
  122. package/dist/tool/index.d.ts +8 -0
  123. package/dist/tool/index.js +9 -0
  124. package/dist/tool/tool.entity.d.ts +42 -0
  125. package/dist/tool/tool.entity.d.ts.map +1 -0
  126. package/dist/tool/tool.entity.js +105 -0
  127. package/dist/tool/tool.entity.js.map +1 -0
  128. package/dist/tool/tool.enum.d.ts +18 -0
  129. package/dist/tool/tool.enum.d.ts.map +1 -0
  130. package/dist/tool/tool.enum.js +35 -0
  131. package/dist/tool/tool.enum.js.map +1 -0
  132. package/dist/tool/tool.event.d.ts +103 -0
  133. package/dist/tool/tool.event.d.ts.map +1 -0
  134. package/dist/tool/tool.event.js +159 -0
  135. package/dist/tool/tool.event.js.map +1 -0
  136. package/dist/tool/tool.handler.d.ts +315 -0
  137. package/dist/tool/tool.handler.d.ts.map +1 -0
  138. package/dist/tool/tool.handler.js +87 -0
  139. package/dist/tool/tool.handler.js.map +1 -0
  140. package/dist/tool/tool.operation.d.ts +411 -0
  141. package/dist/tool/tool.operation.d.ts.map +1 -0
  142. package/dist/tool/tool.operation.js +406 -0
  143. package/dist/tool/tool.operation.js.map +1 -0
  144. package/dist/tool/tool.presentation.d.ts +14 -0
  145. package/dist/tool/tool.presentation.d.ts.map +1 -0
  146. package/dist/tool/tool.presentation.js +65 -0
  147. package/dist/tool/tool.presentation.js.map +1 -0
  148. package/dist/tool/tool.schema.d.ts +218 -0
  149. package/dist/tool/tool.schema.d.ts.map +1 -0
  150. package/dist/tool/tool.schema.js +236 -0
  151. package/dist/tool/tool.schema.js.map +1 -0
  152. package/dist/tool/tool.test-spec.d.ts +8 -0
  153. package/dist/tool/tool.test-spec.d.ts.map +1 -0
  154. package/dist/tool/tool.test-spec.js +65 -0
  155. package/dist/tool/tool.test-spec.js.map +1 -0
  156. package/dist/ui/AgentDashboard.d.ts +7 -0
  157. package/dist/ui/AgentDashboard.d.ts.map +1 -0
  158. package/dist/ui/AgentDashboard.js +420 -0
  159. package/dist/ui/AgentDashboard.js.map +1 -0
  160. package/dist/ui/AgentRunList.d.ts +2 -0
  161. package/dist/ui/AgentRunList.js +5 -0
  162. package/dist/ui/AgentToolRegistry.d.ts +2 -0
  163. package/dist/ui/AgentToolRegistry.js +5 -0
  164. package/dist/ui/hooks/index.d.ts +6 -0
  165. package/dist/ui/hooks/index.js +8 -0
  166. package/dist/ui/hooks/useAgentList.d.ts +28 -0
  167. package/dist/ui/hooks/useAgentList.d.ts.map +1 -0
  168. package/dist/ui/hooks/useAgentList.js +66 -0
  169. package/dist/ui/hooks/useAgentList.js.map +1 -0
  170. package/dist/ui/hooks/useAgentMutations.d.ts +29 -0
  171. package/dist/ui/hooks/useAgentMutations.d.ts.map +1 -0
  172. package/dist/ui/hooks/useAgentMutations.js +124 -0
  173. package/dist/ui/hooks/useAgentMutations.js.map +1 -0
  174. package/dist/ui/hooks/useRunList.d.ts +24 -0
  175. package/dist/ui/hooks/useRunList.d.ts.map +1 -0
  176. package/dist/ui/hooks/useRunList.js +66 -0
  177. package/dist/ui/hooks/useRunList.js.map +1 -0
  178. package/dist/ui/hooks/useToolList.d.ts +40 -0
  179. package/dist/ui/hooks/useToolList.d.ts.map +1 -0
  180. package/dist/ui/hooks/useToolList.js +96 -0
  181. package/dist/ui/hooks/useToolList.js.map +1 -0
  182. package/dist/ui/index.d.ts +24 -0
  183. package/dist/ui/index.js +24 -0
  184. package/dist/ui/modals/AgentActionsModal.d.ts +27 -0
  185. package/dist/ui/modals/AgentActionsModal.d.ts.map +1 -0
  186. package/dist/ui/modals/AgentActionsModal.js +262 -0
  187. package/dist/ui/modals/AgentActionsModal.js.map +1 -0
  188. package/dist/ui/modals/CreateAgentModal.d.ts +25 -0
  189. package/dist/ui/modals/CreateAgentModal.d.ts.map +1 -0
  190. package/dist/ui/modals/CreateAgentModal.js +214 -0
  191. package/dist/ui/modals/CreateAgentModal.js.map +1 -0
  192. package/dist/ui/modals/index.d.ts +3 -0
  193. package/dist/ui/modals/index.js +4 -0
  194. package/dist/ui/overlays/demo-overlays.d.ts +19 -0
  195. package/dist/ui/overlays/demo-overlays.d.ts.map +1 -0
  196. package/dist/ui/overlays/demo-overlays.js +73 -0
  197. package/dist/ui/overlays/demo-overlays.js.map +1 -0
  198. package/dist/ui/overlays/index.d.ts +2 -0
  199. package/dist/ui/overlays/index.js +3 -0
  200. package/dist/ui/renderers/agent-list.markdown.d.ts +15 -0
  201. package/dist/ui/renderers/agent-list.markdown.d.ts.map +1 -0
  202. package/dist/ui/renderers/agent-list.markdown.js +51 -0
  203. package/dist/ui/renderers/agent-list.markdown.js.map +1 -0
  204. package/dist/ui/renderers/agent-list.renderer.d.ts +11 -0
  205. package/dist/ui/renderers/agent-list.renderer.d.ts.map +1 -0
  206. package/dist/ui/renderers/agent-list.renderer.js +19 -0
  207. package/dist/ui/renderers/agent-list.renderer.js.map +1 -0
  208. package/dist/ui/renderers/dashboard.markdown.d.ts +15 -0
  209. package/dist/ui/renderers/dashboard.markdown.d.ts.map +1 -0
  210. package/dist/ui/renderers/dashboard.markdown.js +100 -0
  211. package/dist/ui/renderers/dashboard.markdown.js.map +1 -0
  212. package/dist/ui/renderers/index.d.ts +6 -0
  213. package/dist/ui/renderers/index.js +7 -0
  214. package/dist/ui/renderers/run-list.markdown.d.ts +15 -0
  215. package/dist/ui/renderers/run-list.markdown.d.ts.map +1 -0
  216. package/dist/ui/renderers/run-list.markdown.js +44 -0
  217. package/dist/ui/renderers/run-list.markdown.js.map +1 -0
  218. package/dist/ui/renderers/tool-registry.markdown.d.ts +15 -0
  219. package/dist/ui/renderers/tool-registry.markdown.d.ts.map +1 -0
  220. package/dist/ui/renderers/tool-registry.markdown.js +55 -0
  221. package/dist/ui/renderers/tool-registry.markdown.js.map +1 -0
  222. package/dist/ui/views/AgentListView.d.ts +7 -0
  223. package/dist/ui/views/AgentListView.d.ts.map +1 -0
  224. package/dist/ui/views/AgentListView.js +93 -0
  225. package/dist/ui/views/AgentListView.js.map +1 -0
  226. package/dist/ui/views/RunListView.d.ts +14 -0
  227. package/dist/ui/views/RunListView.d.ts.map +1 -0
  228. package/dist/ui/views/RunListView.js +165 -0
  229. package/dist/ui/views/RunListView.js.map +1 -0
  230. package/dist/ui/views/ToolRegistryView.d.ts +14 -0
  231. package/dist/ui/views/ToolRegistryView.d.ts.map +1 -0
  232. package/dist/ui/views/ToolRegistryView.js +97 -0
  233. package/dist/ui/views/ToolRegistryView.js.map +1 -0
  234. package/dist/ui/views/index.d.ts +4 -0
  235. package/dist/ui/views/index.js +5 -0
  236. package/example.ts +1 -0
  237. package/package.json +155 -0
  238. package/src/agent/agent.entity.ts +137 -0
  239. package/src/agent/agent.enum.ts +31 -0
  240. package/src/agent/agent.event.ts +142 -0
  241. package/src/agent/agent.handler.ts +178 -0
  242. package/src/agent/agent.operation.ts +444 -0
  243. package/src/agent/agent.presentation.ts +80 -0
  244. package/src/agent/agent.schema.ts +214 -0
  245. package/src/agent/agent.test-spec.ts +55 -0
  246. package/src/agent/index.ts +67 -0
  247. package/src/agent.capability.ts +13 -0
  248. package/src/agent.feature.ts +147 -0
  249. package/src/docs/agent-console.docblock.ts +97 -0
  250. package/src/docs/index.ts +1 -0
  251. package/src/example.ts +41 -0
  252. package/src/handlers/agent.handlers.ts +572 -0
  253. package/src/handlers/index.ts +30 -0
  254. package/src/index.ts +32 -0
  255. package/src/presentations/index.ts +26 -0
  256. package/src/run/index.ts +68 -0
  257. package/src/run/run.entity.ts +175 -0
  258. package/src/run/run.enum.ts +43 -0
  259. package/src/run/run.event.ts +264 -0
  260. package/src/run/run.handler.ts +138 -0
  261. package/src/run/run.operation.ts +524 -0
  262. package/src/run/run.presentation.ts +54 -0
  263. package/src/run/run.schema.ts +169 -0
  264. package/src/run/run.test-spec.ts +55 -0
  265. package/src/seeders/index.ts +29 -0
  266. package/src/shared/index.ts +6 -0
  267. package/src/shared/mock-agents.ts +81 -0
  268. package/src/shared/mock-runs.ts +107 -0
  269. package/src/shared/mock-tools.ts +145 -0
  270. package/src/shared/overlay-types.ts +39 -0
  271. package/src/tool/index.ts +60 -0
  272. package/src/tool/tool.entity.ts +99 -0
  273. package/src/tool/tool.enum.ts +32 -0
  274. package/src/tool/tool.event.ts +119 -0
  275. package/src/tool/tool.handler.ts +154 -0
  276. package/src/tool/tool.operation.ts +366 -0
  277. package/src/tool/tool.presentation.ts +55 -0
  278. package/src/tool/tool.schema.ts +133 -0
  279. package/src/tool/tool.test-spec.ts +55 -0
  280. package/src/ui/AgentDashboard.tsx +416 -0
  281. package/src/ui/AgentRunList.tsx +8 -0
  282. package/src/ui/AgentToolRegistry.tsx +8 -0
  283. package/src/ui/hooks/index.ts +14 -0
  284. package/src/ui/hooks/useAgentList.ts +80 -0
  285. package/src/ui/hooks/useAgentMutations.ts +156 -0
  286. package/src/ui/hooks/useRunList.ts +81 -0
  287. package/src/ui/hooks/useToolList.ts +122 -0
  288. package/src/ui/index.ts +21 -0
  289. package/src/ui/modals/AgentActionsModal.tsx +306 -0
  290. package/src/ui/modals/CreateAgentModal.tsx +257 -0
  291. package/src/ui/modals/index.ts +2 -0
  292. package/src/ui/overlays/demo-overlays.ts +77 -0
  293. package/src/ui/overlays/index.ts +1 -0
  294. package/src/ui/renderers/agent-list.markdown.ts +84 -0
  295. package/src/ui/renderers/agent-list.renderer.tsx +27 -0
  296. package/src/ui/renderers/dashboard.markdown.ts +169 -0
  297. package/src/ui/renderers/index.ts +12 -0
  298. package/src/ui/renderers/run-list.markdown.ts +75 -0
  299. package/src/ui/renderers/tool-registry.markdown.ts +91 -0
  300. package/src/ui/views/AgentListView.tsx +113 -0
  301. package/src/ui/views/RunListView.tsx +173 -0
  302. package/src/ui/views/ToolRegistryView.tsx +140 -0
  303. package/src/ui/views/index.ts +6 -0
  304. package/tsconfig.json +10 -0
  305. package/tsconfig.tsbuildinfo +1 -0
  306. package/tsdown.config.js +7 -0
@@ -0,0 +1,366 @@
1
+ import {
2
+ defineCommand,
3
+ defineQuery,
4
+ } from '@contractspec/lib.contracts/operations';
5
+ import { defineSchemaModel, ScalarTypeEnum } from '@contractspec/lib.schema';
6
+ import { ToolCategoryEnum, ToolStatusEnum } from './tool.enum';
7
+ import {
8
+ CreateToolInputModel,
9
+ ToolModel,
10
+ ToolSummaryModel,
11
+ UpdateToolInputModel,
12
+ } from './tool.schema';
13
+
14
+ const OWNERS = ['@agent-console-team'] as const;
15
+
16
+ /**
17
+ * CreateToolCommand - Creates a new tool definition.
18
+ */
19
+ export const CreateToolCommand = defineCommand({
20
+ meta: {
21
+ key: 'agent.tool.create',
22
+ version: '1.0.0',
23
+ stability: 'stable',
24
+ owners: [...OWNERS],
25
+ tags: ['tool', 'create'],
26
+ description: 'Creates a new AI tool definition.',
27
+ goal: 'Allow users to define new tools that agents can use.',
28
+ context: 'Called from the tool builder UI when creating a new tool.',
29
+ },
30
+ io: {
31
+ input: CreateToolInputModel,
32
+ output: defineSchemaModel({
33
+ name: 'CreateToolOutput',
34
+ fields: {
35
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
36
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
37
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
38
+ status: { type: ToolStatusEnum, isOptional: false },
39
+ },
40
+ }),
41
+ errors: {
42
+ SLUG_EXISTS: {
43
+ description: 'A tool with this slug already exists in the organization',
44
+ http: 409,
45
+ gqlCode: 'SLUG_EXISTS',
46
+ when: 'Slug is already taken',
47
+ },
48
+ },
49
+ },
50
+ policy: { auth: 'user' },
51
+ sideEffects: {
52
+ emits: [
53
+ {
54
+ key: 'tool.created',
55
+ version: '1.0.0',
56
+ stability: 'stable',
57
+ owners: [...OWNERS],
58
+ tags: ['tool', 'created'],
59
+ when: 'Tool is successfully created',
60
+ payload: ToolSummaryModel,
61
+ },
62
+ ],
63
+ audit: ['tool.created'],
64
+ },
65
+ acceptance: {
66
+ scenarios: [
67
+ {
68
+ key: 'create-tool-happy-path',
69
+ given: ['User is authenticated', 'Organization exists'],
70
+ when: ['User submits valid tool configuration'],
71
+ then: ['New tool is created', 'ToolCreated event is emitted'],
72
+ },
73
+ {
74
+ key: 'create-tool-slug-conflict',
75
+ given: ['Tool with same slug exists'],
76
+ when: ['User submits tool with duplicate slug'],
77
+ then: ['SLUG_EXISTS error is returned'],
78
+ },
79
+ ],
80
+ examples: [
81
+ {
82
+ key: 'create-api-tool',
83
+ input: {
84
+ name: 'Weather API',
85
+ slug: 'weather-api',
86
+ category: 'api',
87
+ description: 'Fetches weather data',
88
+ },
89
+ output: {
90
+ id: 'tool-123',
91
+ name: 'Weather API',
92
+ slug: 'weather-api',
93
+ status: 'draft',
94
+ },
95
+ },
96
+ ],
97
+ },
98
+ });
99
+
100
+ /**
101
+ * UpdateToolCommand - Updates an existing tool.
102
+ */
103
+ export const UpdateToolCommand = defineCommand({
104
+ meta: {
105
+ key: 'agent.tool.update',
106
+ version: '1.0.0',
107
+ stability: 'stable',
108
+ owners: [...OWNERS],
109
+ tags: ['tool', 'update'],
110
+ description: 'Updates an existing AI tool definition.',
111
+ goal: 'Allow users to modify tool settings and configuration.',
112
+ context: 'Called from the tool settings UI.',
113
+ },
114
+ io: {
115
+ input: UpdateToolInputModel,
116
+ output: defineSchemaModel({
117
+ name: 'UpdateToolOutput',
118
+ fields: {
119
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
120
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
121
+ status: { type: ToolStatusEnum, isOptional: false },
122
+ updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
123
+ },
124
+ }),
125
+ errors: {
126
+ TOOL_NOT_FOUND: {
127
+ description: 'The specified tool does not exist',
128
+ http: 404,
129
+ gqlCode: 'TOOL_NOT_FOUND',
130
+ when: 'Tool ID is invalid',
131
+ },
132
+ },
133
+ },
134
+ policy: { auth: 'user' },
135
+ sideEffects: {
136
+ emits: [
137
+ {
138
+ key: 'tool.updated',
139
+ version: '1.0.0',
140
+ stability: 'stable',
141
+ owners: [...OWNERS],
142
+ tags: ['tool', 'updated'],
143
+ when: 'Tool is updated',
144
+ payload: ToolSummaryModel,
145
+ },
146
+ ],
147
+ audit: ['tool.updated'],
148
+ },
149
+ acceptance: {
150
+ scenarios: [
151
+ {
152
+ key: 'update-tool-happy-path',
153
+ given: ['Tool exists', 'User owns the tool'],
154
+ when: ['User submits updated configuration'],
155
+ then: ['Tool is updated', 'ToolUpdated event is emitted'],
156
+ },
157
+ ],
158
+ examples: [
159
+ {
160
+ key: 'update-description',
161
+ input: { toolId: 'tool-123', description: 'Updated weather API tool' },
162
+ output: {
163
+ id: 'tool-123',
164
+ name: 'Weather API',
165
+ status: 'draft',
166
+ updatedAt: '2025-01-01T00:00:00Z',
167
+ },
168
+ },
169
+ ],
170
+ },
171
+ });
172
+
173
+ /**
174
+ * GetToolQuery - Retrieves a tool by ID.
175
+ */
176
+ export const GetToolQuery = defineQuery({
177
+ meta: {
178
+ key: 'agent.tool.get',
179
+ version: '1.0.0',
180
+ stability: 'stable',
181
+ owners: [...OWNERS],
182
+ tags: ['tool', 'get'],
183
+ description: 'Retrieves a tool by its ID.',
184
+ goal: 'View detailed tool configuration.',
185
+ context: 'Called when viewing tool details or editing.',
186
+ },
187
+ io: {
188
+ input: defineSchemaModel({
189
+ name: 'GetToolInput',
190
+ fields: {
191
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
192
+ },
193
+ }),
194
+ output: ToolModel,
195
+ errors: {
196
+ TOOL_NOT_FOUND: {
197
+ description: 'The specified tool does not exist',
198
+ http: 404,
199
+ gqlCode: 'TOOL_NOT_FOUND',
200
+ when: 'Tool ID is invalid',
201
+ },
202
+ },
203
+ },
204
+ policy: { auth: 'user' },
205
+ acceptance: {
206
+ scenarios: [
207
+ {
208
+ key: 'get-tool-happy-path',
209
+ given: ['Tool exists'],
210
+ when: ['User requests tool by ID'],
211
+ then: ['Tool details are returned'],
212
+ },
213
+ ],
214
+ examples: [
215
+ {
216
+ key: 'get-basic',
217
+ input: { toolId: 'tool-123' },
218
+ output: {
219
+ id: 'tool-123',
220
+ name: 'Weather API',
221
+ status: 'active',
222
+ category: 'api',
223
+ },
224
+ },
225
+ ],
226
+ },
227
+ });
228
+
229
+ /**
230
+ * ListToolsQuery - Lists tools for an organization.
231
+ */
232
+ export const ListToolsQuery = defineQuery({
233
+ meta: {
234
+ key: 'agent.tool.list',
235
+ version: '1.0.0',
236
+ stability: 'stable',
237
+ owners: [...OWNERS],
238
+ tags: ['tool', 'list'],
239
+ description: 'Lists tools for an organization with optional filtering.',
240
+ goal: 'Browse and search available tools.',
241
+ context: 'Tool list/dashboard view.',
242
+ },
243
+ io: {
244
+ input: defineSchemaModel({
245
+ name: 'ListToolsInput',
246
+ fields: {
247
+ organizationId: {
248
+ type: ScalarTypeEnum.String_unsecure(),
249
+ isOptional: false,
250
+ },
251
+ category: { type: ToolCategoryEnum, isOptional: true },
252
+ status: { type: ToolStatusEnum, isOptional: true },
253
+ search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
254
+ limit: {
255
+ type: ScalarTypeEnum.Int_unsecure(),
256
+ isOptional: true,
257
+ defaultValue: 20,
258
+ },
259
+ offset: {
260
+ type: ScalarTypeEnum.Int_unsecure(),
261
+ isOptional: true,
262
+ defaultValue: 0,
263
+ },
264
+ },
265
+ }),
266
+ output: defineSchemaModel({
267
+ name: 'ListToolsOutput',
268
+ fields: {
269
+ items: { type: ToolSummaryModel, isArray: true, isOptional: false },
270
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
271
+ hasMore: { type: ScalarTypeEnum.Boolean(), isOptional: false },
272
+ },
273
+ }),
274
+ },
275
+ policy: { auth: 'user' },
276
+ acceptance: {
277
+ scenarios: [
278
+ {
279
+ key: 'list-tools-happy-path',
280
+ given: ['Organization has tools'],
281
+ when: ['User lists tools'],
282
+ then: ['Paginated list of tools is returned'],
283
+ },
284
+ ],
285
+ examples: [
286
+ {
287
+ key: 'list-by-category',
288
+ input: { organizationId: 'org-123', category: 'api', limit: 10 },
289
+ output: { items: [], total: 0, hasMore: false },
290
+ },
291
+ ],
292
+ },
293
+ });
294
+
295
+ /**
296
+ * TestToolCommand - Tests a tool with sample input.
297
+ */
298
+ export const TestToolCommand = defineCommand({
299
+ meta: {
300
+ key: 'agent.tool.test',
301
+ version: '1.0.0',
302
+ stability: 'stable',
303
+ owners: [...OWNERS],
304
+ tags: ['tool', 'test'],
305
+ description: 'Tests a tool with sample input to verify it works correctly.',
306
+ goal: 'Validate tool configuration before deployment.',
307
+ context: 'Tool builder UI - test panel.',
308
+ },
309
+ io: {
310
+ input: defineSchemaModel({
311
+ name: 'TestToolInput',
312
+ fields: {
313
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
314
+ testInput: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
315
+ },
316
+ }),
317
+ output: defineSchemaModel({
318
+ name: 'TestToolOutput',
319
+ fields: {
320
+ success: { type: ScalarTypeEnum.Boolean(), isOptional: false },
321
+ output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
322
+ error: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
323
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
324
+ },
325
+ }),
326
+ errors: {
327
+ TOOL_NOT_FOUND: {
328
+ description: 'The specified tool does not exist',
329
+ http: 404,
330
+ gqlCode: 'TOOL_NOT_FOUND',
331
+ when: 'Tool ID is invalid',
332
+ },
333
+ TOOL_EXECUTION_ERROR: {
334
+ description: 'Tool execution failed',
335
+ http: 500,
336
+ gqlCode: 'TOOL_EXECUTION_ERROR',
337
+ when: 'Tool returns an error',
338
+ },
339
+ },
340
+ },
341
+ policy: { auth: 'user' },
342
+ sideEffects: { audit: ['tool.tested'] },
343
+ acceptance: {
344
+ scenarios: [
345
+ {
346
+ key: 'test-tool-success',
347
+ given: ['Tool exists', 'Tool is configured correctly'],
348
+ when: ['User runs test with valid input'],
349
+ then: ['Tool executes successfully', 'Output is returned'],
350
+ },
351
+ {
352
+ key: 'test-tool-failure',
353
+ given: ['Tool exists', 'Tool has configuration error'],
354
+ when: ['User runs test'],
355
+ then: ['TOOL_EXECUTION_ERROR is returned'],
356
+ },
357
+ ],
358
+ examples: [
359
+ {
360
+ key: 'test-weather-api',
361
+ input: { toolId: 'tool-123', testInput: { city: 'Paris' } },
362
+ output: { success: true, output: { temperature: 22 }, durationMs: 150 },
363
+ },
364
+ ],
365
+ },
366
+ });
@@ -0,0 +1,55 @@
1
+ import { StabilityEnum, definePresentation } from '@contractspec/lib.contracts';
2
+ import { ToolSummaryModel } from './tool.schema';
3
+
4
+ /**
5
+ * Presentation for displaying a list of tools.
6
+ */
7
+ export const ToolListPresentation = definePresentation({
8
+ meta: {
9
+ key: 'agent-console.tool.list',
10
+ version: '1.0.0',
11
+ title: 'Tool List',
12
+ description:
13
+ 'List view of AI tools with category, status, and version info',
14
+ goal: 'Provide an overview of all available tools for agents.',
15
+ context: 'Tool management dashboard.',
16
+ domain: 'agent-console',
17
+ owners: ['@agent-console-team'],
18
+ tags: ['tool', 'list', 'dashboard'],
19
+ stability: StabilityEnum.Experimental,
20
+ },
21
+ source: {
22
+ type: 'component',
23
+ framework: 'react',
24
+ componentKey: 'ToolListView',
25
+ props: ToolSummaryModel,
26
+ },
27
+ targets: ['react', 'markdown', 'application/json'],
28
+ policy: { flags: ['agent-console.enabled'] },
29
+ });
30
+
31
+ /**
32
+ * Presentation for tool detail view.
33
+ */
34
+ export const ToolDetailPresentation = definePresentation({
35
+ meta: {
36
+ key: 'agent-console.tool.detail',
37
+ version: '1.0.0',
38
+ title: 'Tool Details',
39
+ description:
40
+ 'Detailed view of an AI tool with configuration and test panel',
41
+ goal: 'Allow users to inspect and test a specific tool.',
42
+ context: 'Detailed view of a tool.',
43
+ domain: 'agent-console',
44
+ owners: ['@agent-console-team'],
45
+ tags: ['tool', 'detail'],
46
+ stability: StabilityEnum.Experimental,
47
+ },
48
+ source: {
49
+ type: 'component',
50
+ framework: 'react',
51
+ componentKey: 'ToolDetailView',
52
+ },
53
+ targets: ['react', 'markdown'],
54
+ policy: { flags: ['agent-console.enabled'] },
55
+ });
@@ -0,0 +1,133 @@
1
+ import { defineSchemaModel, ScalarTypeEnum } from '@contractspec/lib.schema';
2
+ import {
3
+ ToolCategoryEnum,
4
+ ToolStatusEnum,
5
+ ImplementationTypeEnum,
6
+ } from './tool.enum';
7
+
8
+ /**
9
+ * AI tool definition.
10
+ */
11
+ export const ToolModel = defineSchemaModel({
12
+ name: 'Tool',
13
+ description: 'AI tool definition',
14
+ fields: {
15
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
16
+ organizationId: {
17
+ type: ScalarTypeEnum.String_unsecure(),
18
+ isOptional: false,
19
+ },
20
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
21
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
22
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
23
+ category: { type: ToolCategoryEnum, isOptional: false },
24
+ status: { type: ToolStatusEnum, isOptional: false },
25
+ parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
26
+ outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
27
+ implementationType: { type: ImplementationTypeEnum, isOptional: false },
28
+ implementationConfig: {
29
+ type: ScalarTypeEnum.JSONObject(),
30
+ isOptional: false,
31
+ },
32
+ maxInvocationsPerMinute: {
33
+ type: ScalarTypeEnum.Int_unsecure(),
34
+ isOptional: true,
35
+ },
36
+ timeoutMs: {
37
+ type: ScalarTypeEnum.Int_unsecure(),
38
+ isOptional: false,
39
+ defaultValue: 30000,
40
+ },
41
+ version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
42
+ tags: {
43
+ type: ScalarTypeEnum.String_unsecure(),
44
+ isArray: true,
45
+ isOptional: true,
46
+ },
47
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
48
+ updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
49
+ },
50
+ });
51
+
52
+ /**
53
+ * Summary of a tool for list views.
54
+ */
55
+ export const ToolSummaryModel = defineSchemaModel({
56
+ name: 'ToolSummary',
57
+ description: 'Summary of a tool for list views',
58
+ fields: {
59
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
60
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
61
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
62
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
63
+ category: { type: ToolCategoryEnum, isOptional: false },
64
+ status: { type: ToolStatusEnum, isOptional: false },
65
+ version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
66
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
67
+ },
68
+ });
69
+
70
+ /**
71
+ * Input for creating a tool.
72
+ */
73
+ export const CreateToolInputModel = defineSchemaModel({
74
+ name: 'CreateToolInput',
75
+ description: 'Input for creating a tool',
76
+ fields: {
77
+ organizationId: {
78
+ type: ScalarTypeEnum.String_unsecure(),
79
+ isOptional: false,
80
+ },
81
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
82
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
83
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
84
+ category: { type: ToolCategoryEnum, isOptional: true },
85
+ parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
86
+ outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
87
+ implementationType: { type: ImplementationTypeEnum, isOptional: false },
88
+ implementationConfig: {
89
+ type: ScalarTypeEnum.JSONObject(),
90
+ isOptional: false,
91
+ },
92
+ maxInvocationsPerMinute: {
93
+ type: ScalarTypeEnum.Int_unsecure(),
94
+ isOptional: true,
95
+ },
96
+ timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
97
+ tags: {
98
+ type: ScalarTypeEnum.String_unsecure(),
99
+ isArray: true,
100
+ isOptional: true,
101
+ },
102
+ },
103
+ });
104
+
105
+ /**
106
+ * Input for updating a tool.
107
+ */
108
+ export const UpdateToolInputModel = defineSchemaModel({
109
+ name: 'UpdateToolInput',
110
+ description: 'Input for updating a tool',
111
+ fields: {
112
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
113
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: true },
114
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
115
+ status: { type: ToolStatusEnum, isOptional: true },
116
+ parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
117
+ outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
118
+ implementationConfig: {
119
+ type: ScalarTypeEnum.JSONObject(),
120
+ isOptional: true,
121
+ },
122
+ maxInvocationsPerMinute: {
123
+ type: ScalarTypeEnum.Int_unsecure(),
124
+ isOptional: true,
125
+ },
126
+ timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
127
+ tags: {
128
+ type: ScalarTypeEnum.String_unsecure(),
129
+ isArray: true,
130
+ isOptional: true,
131
+ },
132
+ },
133
+ });
@@ -0,0 +1,55 @@
1
+ import { defineTestSpec } from '@contractspec/lib.contracts';
2
+
3
+ export const toolListTest = defineTestSpec({
4
+ meta: {
5
+ key: 'test.agent.tool.list',
6
+ version: '1.0.0',
7
+ owners: ['@agent-console-team'],
8
+ description: 'Test for listing tools',
9
+ stability: 'stable',
10
+ tags: ['test'],
11
+ },
12
+ target: {
13
+ type: 'operation',
14
+ operation: { key: 'agent.tool.list', version: '1.0.0' },
15
+ },
16
+ scenarios: [
17
+ {
18
+ key: 'success',
19
+ when: { operation: { key: 'agent.tool.list' } },
20
+ then: [{ type: 'expectOutput', match: {} }],
21
+ },
22
+ {
23
+ key: 'error',
24
+ when: { operation: { key: 'agent.tool.list' } },
25
+ then: [{ type: 'expectError' }],
26
+ },
27
+ ],
28
+ });
29
+
30
+ export const toolGetTest = defineTestSpec({
31
+ meta: {
32
+ key: 'test.agent.tool.get',
33
+ version: '1.0.0',
34
+ owners: ['@agent-console-team'],
35
+ description: 'Test for getting tool',
36
+ stability: 'stable',
37
+ tags: ['test'],
38
+ },
39
+ target: {
40
+ type: 'operation',
41
+ operation: { key: 'agent.tool.get', version: '1.0.0' },
42
+ },
43
+ scenarios: [
44
+ {
45
+ key: 'success',
46
+ when: { operation: { key: 'agent.tool.get' } },
47
+ then: [{ type: 'expectOutput', match: {} }],
48
+ },
49
+ {
50
+ key: 'error',
51
+ when: { operation: { key: 'agent.tool.get' } },
52
+ then: [{ type: 'expectError' }],
53
+ },
54
+ ],
55
+ });