@contractspec/example.agent-console 3.7.6 → 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 (288) hide show
  1. package/.turbo/turbo-build.log +126 -105
  2. package/AGENTS.md +52 -31
  3. package/CHANGELOG.md +29 -0
  4. package/README.md +112 -83
  5. package/dist/agent/agent.event.js +1 -1
  6. package/dist/agent/agent.handler.d.ts +3 -0
  7. package/dist/agent/agent.handler.js +730 -1
  8. package/dist/agent/agent.operation.js +1 -1
  9. package/dist/agent/index.d.ts +5 -5
  10. package/dist/agent/index.js +74 -73
  11. package/dist/agent.feature.js +179 -0
  12. package/dist/browser/agent/agent.event.js +1 -1
  13. package/dist/browser/agent/agent.handler.js +730 -1
  14. package/dist/browser/agent/agent.operation.js +1 -1
  15. package/dist/browser/agent/index.js +74 -73
  16. package/dist/browser/agent.feature.js +179 -0
  17. package/dist/browser/docs/agent-console.docblock.js +11 -8
  18. package/dist/browser/docs/index.js +11 -8
  19. package/dist/browser/example.js +2 -3
  20. package/dist/browser/handlers/agent.handlers.js +1883 -2
  21. package/dist/browser/handlers/index.js +2142 -8
  22. package/dist/browser/index.js +4075 -3161
  23. package/dist/browser/presentations/index.js +51 -51
  24. package/dist/browser/run/index.js +380 -374
  25. package/dist/browser/run/run.event.js +2 -2
  26. package/dist/browser/run/run.handler.js +666 -1
  27. package/dist/browser/run/run.presentation.js +2 -2
  28. package/dist/browser/shared/index.js +293 -1
  29. package/dist/browser/shared/mock-runs.js +5 -0
  30. package/dist/browser/tool/index.js +161 -161
  31. package/dist/browser/tool/tool.event.js +1 -1
  32. package/dist/browser/tool/tool.handler.js +479 -3
  33. package/dist/browser/tool/tool.presentation.js +2 -2
  34. package/dist/browser/ui/AgentDashboard.js +1816 -931
  35. package/dist/browser/ui/AgentDashboard.visualizations.js +217 -0
  36. package/dist/browser/ui/AgentRunList.js +360 -128
  37. package/dist/browser/ui/AgentToolRegistry.js +9 -9
  38. package/dist/browser/ui/hooks/index.js +611 -161
  39. package/dist/browser/ui/hooks/useAgentList.js +1 -1
  40. package/dist/browser/ui/hooks/useAgentMutations.js +444 -9
  41. package/dist/browser/ui/hooks/useRunList.js +26 -11
  42. package/dist/browser/ui/hooks/useToolList.js +1 -1
  43. package/dist/browser/ui/index.js +2161 -1258
  44. package/dist/browser/ui/modals/AgentActionsModal.js +13 -13
  45. package/dist/browser/ui/modals/CreateAgentModal.js +15 -15
  46. package/dist/browser/ui/modals/index.js +297 -297
  47. package/dist/browser/ui/renderers/agent-list.markdown.js +14 -5
  48. package/dist/browser/ui/renderers/agent-list.renderer.js +7 -7
  49. package/dist/browser/ui/renderers/dashboard.markdown.js +207 -36
  50. package/dist/browser/ui/renderers/index.js +359 -163
  51. package/dist/browser/ui/renderers/run-list.markdown.js +9 -4
  52. package/dist/browser/ui/renderers/tool-registry.markdown.js +15 -4
  53. package/dist/browser/ui/views/AgentListView.js +7 -7
  54. package/dist/browser/ui/views/RunDataTable.js +326 -0
  55. package/dist/browser/ui/views/RunListView.js +360 -128
  56. package/dist/browser/ui/views/ToolRegistryView.js +9 -9
  57. package/dist/browser/ui/views/index.js +478 -246
  58. package/dist/browser/ui/views/run-data-table.columns.js +271 -0
  59. package/dist/browser/ui/views/run-list.shared.js +177 -0
  60. package/dist/browser/visualizations/catalog.js +134 -0
  61. package/dist/browser/visualizations/index.js +187 -0
  62. package/dist/browser/visualizations/selectors.js +181 -0
  63. package/dist/docs/agent-console.docblock.js +11 -8
  64. package/dist/docs/index.js +11 -8
  65. package/dist/example.js +2 -3
  66. package/dist/example.test.d.ts +1 -0
  67. package/dist/handlers/agent.handlers.d.ts +2 -0
  68. package/dist/handlers/agent.handlers.js +1883 -2
  69. package/dist/handlers/index.d.ts +2 -4
  70. package/dist/handlers/index.js +2142 -8
  71. package/dist/handlers/mock-handlers.test.d.ts +1 -0
  72. package/dist/index.d.ts +6 -4
  73. package/dist/index.js +4075 -3161
  74. package/dist/node/agent/agent.event.js +1 -1
  75. package/dist/node/agent/agent.handler.js +730 -1
  76. package/dist/node/agent/agent.operation.js +1 -1
  77. package/dist/node/agent/index.js +74 -73
  78. package/dist/node/agent.feature.js +179 -0
  79. package/dist/node/docs/agent-console.docblock.js +11 -8
  80. package/dist/node/docs/index.js +11 -8
  81. package/dist/node/example.js +2 -3
  82. package/dist/node/handlers/agent.handlers.js +1883 -2
  83. package/dist/node/handlers/index.js +2142 -8
  84. package/dist/node/index.js +4075 -3161
  85. package/dist/node/presentations/index.js +51 -51
  86. package/dist/node/run/index.js +380 -374
  87. package/dist/node/run/run.event.js +2 -2
  88. package/dist/node/run/run.handler.js +666 -1
  89. package/dist/node/run/run.presentation.js +2 -2
  90. package/dist/node/shared/index.js +293 -1
  91. package/dist/node/shared/mock-runs.js +5 -0
  92. package/dist/node/tool/index.js +161 -161
  93. package/dist/node/tool/tool.event.js +1 -1
  94. package/dist/node/tool/tool.handler.js +479 -3
  95. package/dist/node/tool/tool.presentation.js +2 -2
  96. package/dist/node/ui/AgentDashboard.js +1816 -931
  97. package/dist/node/ui/AgentDashboard.visualizations.js +217 -0
  98. package/dist/node/ui/AgentRunList.js +360 -128
  99. package/dist/node/ui/AgentToolRegistry.js +9 -9
  100. package/dist/node/ui/hooks/index.js +611 -161
  101. package/dist/node/ui/hooks/useAgentList.js +1 -1
  102. package/dist/node/ui/hooks/useAgentMutations.js +444 -9
  103. package/dist/node/ui/hooks/useRunList.js +26 -11
  104. package/dist/node/ui/hooks/useToolList.js +1 -1
  105. package/dist/node/ui/index.js +2161 -1258
  106. package/dist/node/ui/modals/AgentActionsModal.js +13 -13
  107. package/dist/node/ui/modals/CreateAgentModal.js +15 -15
  108. package/dist/node/ui/modals/index.js +297 -297
  109. package/dist/node/ui/renderers/agent-list.markdown.js +14 -5
  110. package/dist/node/ui/renderers/agent-list.renderer.js +7 -7
  111. package/dist/node/ui/renderers/dashboard.markdown.js +207 -36
  112. package/dist/node/ui/renderers/index.js +359 -163
  113. package/dist/node/ui/renderers/run-list.markdown.js +9 -4
  114. package/dist/node/ui/renderers/tool-registry.markdown.js +15 -4
  115. package/dist/node/ui/views/AgentListView.js +7 -7
  116. package/dist/node/ui/views/RunDataTable.js +326 -0
  117. package/dist/node/ui/views/RunListView.js +360 -128
  118. package/dist/node/ui/views/ToolRegistryView.js +9 -9
  119. package/dist/node/ui/views/index.js +478 -246
  120. package/dist/node/ui/views/run-data-table.columns.js +271 -0
  121. package/dist/node/ui/views/run-list.shared.js +177 -0
  122. package/dist/node/visualizations/catalog.js +134 -0
  123. package/dist/node/visualizations/index.js +187 -0
  124. package/dist/node/visualizations/selectors.js +181 -0
  125. package/dist/presentations/index.d.ts +3 -5
  126. package/dist/presentations/index.js +51 -51
  127. package/dist/proof/index.d.ts +2 -0
  128. package/dist/proof/meetup-proof.d.ts +10 -0
  129. package/dist/proof/meetup-proof.runtime.d.ts +22 -0
  130. package/dist/proof/meetup-proof.scenario.d.ts +2 -0
  131. package/dist/proof/meetup-proof.suite.d.ts +1 -0
  132. package/dist/proof/meetup-proof.test.d.ts +1 -0
  133. package/dist/run/index.d.ts +7 -7
  134. package/dist/run/index.js +380 -374
  135. package/dist/run/run.event.js +2 -2
  136. package/dist/run/run.handler.d.ts +7 -0
  137. package/dist/run/run.handler.js +666 -1
  138. package/dist/run/run.presentation.js +2 -2
  139. package/dist/shared/demo-dashboard-data.d.ts +16 -0
  140. package/dist/shared/demo-runtime-seed.d.ts +17 -0
  141. package/dist/shared/demo-runtime.d.ts +8 -0
  142. package/dist/shared/demo-runtime.test.d.ts +1 -0
  143. package/dist/shared/index.d.ts +4 -1
  144. package/dist/shared/index.js +293 -1
  145. package/dist/shared/mock-runs.d.ts +4 -0
  146. package/dist/shared/mock-runs.js +5 -0
  147. package/dist/tool/index.d.ts +7 -7
  148. package/dist/tool/index.js +161 -161
  149. package/dist/tool/tool.event.js +1 -1
  150. package/dist/tool/tool.handler.d.ts +3 -0
  151. package/dist/tool/tool.handler.js +479 -3
  152. package/dist/tool/tool.presentation.js +2 -2
  153. package/dist/ui/AgentDashboard.js +1816 -931
  154. package/dist/ui/AgentDashboard.sandbox.test.d.ts +1 -0
  155. package/dist/ui/AgentDashboard.visualizations.d.ts +4 -0
  156. package/dist/ui/AgentDashboard.visualizations.js +218 -0
  157. package/dist/ui/AgentRunList.js +360 -128
  158. package/dist/ui/AgentToolRegistry.js +9 -9
  159. package/dist/ui/hooks/index.d.ts +4 -4
  160. package/dist/ui/hooks/index.js +611 -161
  161. package/dist/ui/hooks/useAgentList.d.ts +5 -0
  162. package/dist/ui/hooks/useAgentList.js +1 -1
  163. package/dist/ui/hooks/useAgentMutations.d.ts +9 -2
  164. package/dist/ui/hooks/useAgentMutations.js +444 -9
  165. package/dist/ui/hooks/useRunList.d.ts +13 -2
  166. package/dist/ui/hooks/useRunList.js +26 -11
  167. package/dist/ui/hooks/useToolList.d.ts +5 -0
  168. package/dist/ui/hooks/useToolList.js +1 -1
  169. package/dist/ui/index.d.ts +3 -3
  170. package/dist/ui/index.js +2161 -1258
  171. package/dist/ui/modals/AgentActionsModal.js +13 -13
  172. package/dist/ui/modals/CreateAgentModal.js +15 -15
  173. package/dist/ui/modals/index.d.ts +1 -1
  174. package/dist/ui/modals/index.js +297 -297
  175. package/dist/ui/renderers/agent-list.markdown.d.ts +5 -0
  176. package/dist/ui/renderers/agent-list.markdown.js +14 -5
  177. package/dist/ui/renderers/agent-list.renderer.js +7 -7
  178. package/dist/ui/renderers/dashboard.markdown.d.ts +5 -0
  179. package/dist/ui/renderers/dashboard.markdown.js +207 -36
  180. package/dist/ui/renderers/index.d.ts +2 -2
  181. package/dist/ui/renderers/index.js +359 -163
  182. package/dist/ui/renderers/run-list.markdown.d.ts +5 -0
  183. package/dist/ui/renderers/run-list.markdown.js +9 -4
  184. package/dist/ui/renderers/tool-registry.markdown.d.ts +6 -1
  185. package/dist/ui/renderers/tool-registry.markdown.js +15 -4
  186. package/dist/ui/views/AgentListView.js +7 -7
  187. package/dist/ui/views/RunDataTable.d.ts +18 -0
  188. package/dist/ui/views/RunDataTable.js +327 -0
  189. package/dist/ui/views/RunListView.js +360 -128
  190. package/dist/ui/views/ToolRegistryView.js +9 -9
  191. package/dist/ui/views/index.js +478 -246
  192. package/dist/ui/views/run-data-table.columns.d.ts +3 -0
  193. package/dist/ui/views/run-data-table.columns.js +272 -0
  194. package/dist/ui/views/run-list.shared.d.ts +14 -0
  195. package/dist/ui/views/run-list.shared.js +178 -0
  196. package/dist/visualizations/catalog.d.ts +10 -0
  197. package/dist/visualizations/catalog.js +135 -0
  198. package/dist/visualizations/index.d.ts +2 -0
  199. package/dist/visualizations/index.js +188 -0
  200. package/dist/visualizations/selectors.d.ts +3 -0
  201. package/dist/visualizations/selectors.js +182 -0
  202. package/dist/visualizations/selectors.test.d.ts +1 -0
  203. package/package.json +114 -12
  204. package/proofs/agent-console-meetup.replay.json +220 -0
  205. package/src/agent/agent.entity.ts +111 -111
  206. package/src/agent/agent.enum.ts +12 -12
  207. package/src/agent/agent.event.ts +91 -91
  208. package/src/agent/agent.handler.ts +144 -127
  209. package/src/agent/agent.operation.ts +400 -400
  210. package/src/agent/agent.presentation.ts +62 -62
  211. package/src/agent/agent.schema.ts +175 -175
  212. package/src/agent/agent.test-spec.ts +48 -48
  213. package/src/agent/index.ts +46 -51
  214. package/src/agent.capability.ts +11 -11
  215. package/src/agent.feature.ts +134 -131
  216. package/src/docs/agent-console.docblock.ts +52 -49
  217. package/src/example.test.ts +75 -0
  218. package/src/example.ts +34 -35
  219. package/src/handlers/agent.handlers.ts +576 -522
  220. package/src/handlers/index.ts +30 -14
  221. package/src/handlers/mock-handlers.test.ts +77 -0
  222. package/src/index.ts +10 -9
  223. package/src/presentations/index.ts +11 -13
  224. package/src/proof/index.ts +2 -0
  225. package/src/proof/meetup-proof.runtime.ts +196 -0
  226. package/src/proof/meetup-proof.scenario.ts +99 -0
  227. package/src/proof/meetup-proof.suite.ts +29 -0
  228. package/src/proof/meetup-proof.test.ts +28 -0
  229. package/src/proof/meetup-proof.ts +130 -0
  230. package/src/run/index.ts +49 -54
  231. package/src/run/run.entity.ts +137 -137
  232. package/src/run/run.enum.ts +18 -18
  233. package/src/run/run.event.ts +174 -174
  234. package/src/run/run.handler.ts +113 -96
  235. package/src/run/run.operation.ts +474 -474
  236. package/src/run/run.presentation.ts +42 -42
  237. package/src/run/run.schema.ts +126 -126
  238. package/src/run/run.test-spec.ts +48 -48
  239. package/src/seeders/index.ts +21 -21
  240. package/src/shared/demo-dashboard-data.ts +58 -0
  241. package/src/shared/demo-runtime-seed.ts +139 -0
  242. package/src/shared/demo-runtime.test.ts +169 -0
  243. package/src/shared/demo-runtime.ts +260 -0
  244. package/src/shared/index.ts +12 -1
  245. package/src/shared/mock-agents.ts +76 -76
  246. package/src/shared/mock-runs.ts +107 -102
  247. package/src/shared/mock-tools.ts +140 -140
  248. package/src/shared/overlay-types.ts +23 -23
  249. package/src/tool/index.ts +39 -44
  250. package/src/tool/tool.entity.ts +73 -73
  251. package/src/tool/tool.enum.ts +13 -13
  252. package/src/tool/tool.event.ts +80 -80
  253. package/src/tool/tool.handler.ts +124 -107
  254. package/src/tool/tool.operation.ts +328 -328
  255. package/src/tool/tool.presentation.ts +43 -43
  256. package/src/tool/tool.schema.ts +106 -106
  257. package/src/tool/tool.test-spec.ts +48 -48
  258. package/src/ui/AgentDashboard.sandbox.test.tsx +312 -0
  259. package/src/ui/AgentDashboard.tsx +351 -348
  260. package/src/ui/AgentDashboard.visualizations.tsx +35 -0
  261. package/src/ui/hooks/index.ts +7 -7
  262. package/src/ui/hooks/useAgentList.ts +57 -56
  263. package/src/ui/hooks/useAgentMutations.ts +168 -159
  264. package/src/ui/hooks/useRunList.ts +90 -57
  265. package/src/ui/hooks/useToolList.ts +102 -101
  266. package/src/ui/index.ts +6 -9
  267. package/src/ui/modals/AgentActionsModal.tsx +262 -262
  268. package/src/ui/modals/CreateAgentModal.tsx +232 -232
  269. package/src/ui/modals/index.ts +1 -1
  270. package/src/ui/overlays/demo-overlays.ts +52 -52
  271. package/src/ui/renderers/agent-list.markdown.ts +81 -61
  272. package/src/ui/renderers/agent-list.renderer.tsx +14 -14
  273. package/src/ui/renderers/dashboard.markdown.ts +135 -139
  274. package/src/ui/renderers/index.ts +3 -4
  275. package/src/ui/renderers/run-list.markdown.ts +56 -47
  276. package/src/ui/renderers/tool-registry.markdown.ts +79 -66
  277. package/src/ui/views/AgentListView.tsx +90 -90
  278. package/src/ui/views/RunDataTable.tsx +74 -0
  279. package/src/ui/views/RunListView.tsx +84 -158
  280. package/src/ui/views/ToolRegistryView.tsx +113 -113
  281. package/src/ui/views/run-data-table.columns.tsx +102 -0
  282. package/src/ui/views/run-list.shared.tsx +139 -0
  283. package/src/visualizations/catalog.ts +132 -0
  284. package/src/visualizations/index.ts +2 -0
  285. package/src/visualizations/selectors.test.ts +12 -0
  286. package/src/visualizations/selectors.ts +70 -0
  287. package/tsconfig.json +7 -8
  288. package/tsdown.config.js +24 -3
@@ -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 {
@@ -137,8 +137,8 @@ var UpdateToolInputModel = defineSchemaModel({
137
137
 
138
138
  // src/tool/tool.presentation.ts
139
139
  import {
140
- StabilityEnum,
141
- definePresentation
140
+ definePresentation,
141
+ StabilityEnum
142
142
  } from "@contractspec/lib.contracts-spec";
143
143
  var ToolListPresentation = definePresentation({
144
144
  meta: {