@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,99 @@
1
+ import {
2
+ defineEntity,
3
+ defineEntityEnum,
4
+ field,
5
+ index,
6
+ } from '@contractspec/lib.schema';
7
+
8
+ /**
9
+ * Tool category enum for entities.
10
+ */
11
+ export const ToolCategoryEntityEnum = defineEntityEnum({
12
+ name: 'ToolCategory',
13
+ values: [
14
+ 'RETRIEVAL',
15
+ 'COMPUTATION',
16
+ 'COMMUNICATION',
17
+ 'INTEGRATION',
18
+ 'UTILITY',
19
+ 'CUSTOM',
20
+ ],
21
+ description: 'Category of tool',
22
+ });
23
+
24
+ /**
25
+ * Tool status enum for entities.
26
+ */
27
+ export const ToolStatusEntityEnum = defineEntityEnum({
28
+ name: 'ToolStatus',
29
+ values: ['DRAFT', 'ACTIVE', 'DEPRECATED', 'DISABLED'],
30
+ description: 'Status of tool',
31
+ });
32
+
33
+ /**
34
+ * Implementation type enum for entities.
35
+ */
36
+ export const ImplementationTypeEntityEnum = defineEntityEnum({
37
+ name: 'ImplementationType',
38
+ values: ['http', 'function', 'workflow'],
39
+ description: 'How the tool is implemented',
40
+ });
41
+
42
+ /**
43
+ * Tool entity - Represents an AI tool definition.
44
+ */
45
+ export const ToolEntity = defineEntity({
46
+ name: 'Tool',
47
+ schema: 'agent_console',
48
+ description: 'An AI tool that can be used by agents.',
49
+ fields: {
50
+ id: field.id(),
51
+ organizationId: field.string({
52
+ description: 'Organization that owns this tool',
53
+ }),
54
+ name: field.string({ description: 'Tool name' }),
55
+ slug: field.string({ description: 'URL-safe identifier' }),
56
+ description: field.string({ description: 'Tool description' }),
57
+ category: field.enum('ToolCategory', { default: 'CUSTOM' }),
58
+ status: field.enum('ToolStatus', { default: 'DRAFT' }),
59
+ parametersSchema: field.json({
60
+ description: 'JSON Schema for tool parameters',
61
+ }),
62
+ outputSchema: field.json({
63
+ isOptional: true,
64
+ description: 'JSON Schema for tool output',
65
+ }),
66
+ implementationType: field.enum('ImplementationType'),
67
+ implementationConfig: field.json({
68
+ description: 'Implementation configuration',
69
+ }),
70
+ maxInvocationsPerMinute: field.int({
71
+ isOptional: true,
72
+ description: 'Rate limit',
73
+ }),
74
+ timeoutMs: field.int({ default: 30000, description: 'Execution timeout' }),
75
+ version: field.string({ default: '1.0.0', description: 'Tool version' }),
76
+ tags: field.string({
77
+ isArray: true,
78
+ isOptional: true,
79
+ description: 'Tags for categorization',
80
+ }),
81
+ createdAt: field.createdAt(),
82
+ updatedAt: field.updatedAt(),
83
+ createdById: field.string({
84
+ isOptional: true,
85
+ description: 'User who created this tool',
86
+ }),
87
+ agents: field.hasMany('Agent', { description: 'Agents using this tool' }),
88
+ },
89
+ indexes: [
90
+ index.unique(['organizationId', 'slug']),
91
+ index.on(['organizationId', 'category']),
92
+ index.on(['organizationId', 'status']),
93
+ ],
94
+ enums: [
95
+ ToolCategoryEntityEnum,
96
+ ToolStatusEntityEnum,
97
+ ImplementationTypeEntityEnum,
98
+ ],
99
+ });
@@ -0,0 +1,32 @@
1
+ import { defineEnum } from '@contractspec/lib.schema';
2
+
3
+ /**
4
+ * Tool category enum.
5
+ */
6
+ export const ToolCategoryEnum = defineEnum('ToolCategory', [
7
+ 'RETRIEVAL',
8
+ 'COMPUTATION',
9
+ 'COMMUNICATION',
10
+ 'INTEGRATION',
11
+ 'UTILITY',
12
+ 'CUSTOM',
13
+ ]);
14
+
15
+ /**
16
+ * Tool status enum.
17
+ */
18
+ export const ToolStatusEnum = defineEnum('ToolStatus', [
19
+ 'DRAFT',
20
+ 'ACTIVE',
21
+ 'DEPRECATED',
22
+ 'DISABLED',
23
+ ]);
24
+
25
+ /**
26
+ * Implementation type enum.
27
+ */
28
+ export const ImplementationTypeEnum = defineEnum('ImplementationType', [
29
+ 'http',
30
+ 'function',
31
+ 'workflow',
32
+ ]);
@@ -0,0 +1,119 @@
1
+ import { defineEvent, defineSchemaModel } from '@contractspec/lib.contracts';
2
+ import { ScalarTypeEnum } from '@contractspec/lib.schema';
3
+
4
+ const OWNERS = ['@agent-console-team'] as const;
5
+
6
+ /**
7
+ * Payload for tool created event.
8
+ */
9
+ const ToolCreatedPayload = defineSchemaModel({
10
+ name: 'ToolCreatedPayload',
11
+ description: 'Payload for tool created event',
12
+ fields: {
13
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
14
+ organizationId: {
15
+ type: ScalarTypeEnum.String_unsecure(),
16
+ isOptional: false,
17
+ },
18
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
19
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
20
+ category: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
21
+ implementationType: {
22
+ type: ScalarTypeEnum.String_unsecure(),
23
+ isOptional: false,
24
+ },
25
+ createdById: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
26
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
27
+ },
28
+ });
29
+
30
+ /**
31
+ * ToolCreatedEvent - A new tool was created.
32
+ */
33
+ export const ToolCreatedEvent = defineEvent({
34
+ meta: {
35
+ key: 'agent.tool.created',
36
+ version: '1.0.0',
37
+ description: 'A new AI tool was created.',
38
+ stability: 'stable',
39
+ owners: [...OWNERS],
40
+ tags: ['tool', 'created'],
41
+ },
42
+ payload: ToolCreatedPayload,
43
+ });
44
+
45
+ /**
46
+ * Payload for tool updated event.
47
+ */
48
+ const ToolUpdatedPayload = defineSchemaModel({
49
+ name: 'ToolUpdatedPayload',
50
+ description: 'Payload for tool updated event',
51
+ fields: {
52
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
53
+ organizationId: {
54
+ type: ScalarTypeEnum.String_unsecure(),
55
+ isOptional: false,
56
+ },
57
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
58
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
59
+ updatedFields: {
60
+ type: ScalarTypeEnum.String_unsecure(),
61
+ isArray: true,
62
+ isOptional: false,
63
+ },
64
+ updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
65
+ },
66
+ });
67
+
68
+ /**
69
+ * ToolUpdatedEvent - A tool was updated.
70
+ */
71
+ export const ToolUpdatedEvent = defineEvent({
72
+ meta: {
73
+ key: 'agent.tool.updated',
74
+ version: '1.0.0',
75
+ description: 'An AI tool configuration was updated.',
76
+ stability: 'stable',
77
+ owners: [...OWNERS],
78
+ tags: ['tool', 'updated'],
79
+ },
80
+ payload: ToolUpdatedPayload,
81
+ });
82
+
83
+ /**
84
+ * Payload for tool status changed event.
85
+ */
86
+ const ToolStatusChangedPayload = defineSchemaModel({
87
+ name: 'ToolStatusChangedPayload',
88
+ description: 'Payload for tool status changed event',
89
+ fields: {
90
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
91
+ organizationId: {
92
+ type: ScalarTypeEnum.String_unsecure(),
93
+ isOptional: false,
94
+ },
95
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
96
+ previousStatus: {
97
+ type: ScalarTypeEnum.String_unsecure(),
98
+ isOptional: false,
99
+ },
100
+ newStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
101
+ changedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
102
+ },
103
+ });
104
+
105
+ /**
106
+ * ToolStatusChangedEvent - A tool's status was changed.
107
+ */
108
+ export const ToolStatusChangedEvent = defineEvent({
109
+ meta: {
110
+ key: 'agent.tool.statusChanged',
111
+ version: '1.0.0',
112
+ description:
113
+ 'An AI tool status was changed (activated, deprecated, disabled).',
114
+ stability: 'stable',
115
+ owners: [...OWNERS],
116
+ tags: ['tool', 'status'],
117
+ },
118
+ payload: ToolStatusChangedPayload,
119
+ });
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Mock handlers for Tool contracts.
3
+ */
4
+ import { MOCK_TOOLS } from '../shared/mock-tools';
5
+
6
+ export interface ListToolsInput {
7
+ organizationId: string;
8
+ category?:
9
+ | 'RETRIEVAL'
10
+ | 'COMPUTATION'
11
+ | 'COMMUNICATION'
12
+ | 'INTEGRATION'
13
+ | 'UTILITY'
14
+ | 'CUSTOM';
15
+ status?: 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'DISABLED';
16
+ search?: string;
17
+ limit?: number;
18
+ offset?: number;
19
+ }
20
+
21
+ export interface ToolSummary {
22
+ id: string;
23
+ name: string;
24
+ slug: string;
25
+ description: string;
26
+ category:
27
+ | 'RETRIEVAL'
28
+ | 'COMPUTATION'
29
+ | 'COMMUNICATION'
30
+ | 'INTEGRATION'
31
+ | 'UTILITY'
32
+ | 'CUSTOM';
33
+ status: 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'DISABLED';
34
+ version: string;
35
+ createdAt: Date;
36
+ }
37
+
38
+ export interface ListToolsOutput {
39
+ items: ToolSummary[];
40
+ total: number;
41
+ hasMore: boolean;
42
+ }
43
+
44
+ /**
45
+ * Mock handler for ListToolsQuery.
46
+ */
47
+ export async function mockListToolsHandler(
48
+ input: ListToolsInput
49
+ ): Promise<ListToolsOutput> {
50
+ const {
51
+ organizationId,
52
+ category,
53
+ status,
54
+ search,
55
+ limit = 20,
56
+ offset = 0,
57
+ } = input;
58
+
59
+ let filtered = MOCK_TOOLS.filter((t) => t.organizationId === organizationId);
60
+ if (category) filtered = filtered.filter((t) => t.category === category);
61
+ if (status) filtered = filtered.filter((t) => t.status === status);
62
+ if (search) {
63
+ const q = search.toLowerCase();
64
+ filtered = filtered.filter(
65
+ (t) =>
66
+ t.name.toLowerCase().includes(q) ||
67
+ t.description.toLowerCase().includes(q)
68
+ );
69
+ }
70
+
71
+ const total = filtered.length;
72
+ const items = filtered.slice(offset, offset + limit).map((t) => ({
73
+ id: t.id,
74
+ name: t.name,
75
+ slug: t.slug,
76
+ description: t.description,
77
+ category: t.category,
78
+ status: t.status,
79
+ version: t.version,
80
+ createdAt: t.createdAt,
81
+ }));
82
+
83
+ return { items, total, hasMore: offset + limit < total };
84
+ }
85
+
86
+ /**
87
+ * Mock handler for GetToolQuery.
88
+ */
89
+ export async function mockGetToolHandler(input: { toolId: string }) {
90
+ const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
91
+ if (!tool) throw new Error('TOOL_NOT_FOUND');
92
+ return tool;
93
+ }
94
+
95
+ /**
96
+ * Mock handler for CreateToolCommand.
97
+ */
98
+ export async function mockCreateToolHandler(input: {
99
+ organizationId: string;
100
+ name: string;
101
+ slug: string;
102
+ description: string;
103
+ implementationType: 'http' | 'function' | 'workflow';
104
+ }) {
105
+ const exists = MOCK_TOOLS.some(
106
+ (t) => t.organizationId === input.organizationId && t.slug === input.slug
107
+ );
108
+ if (exists) throw new Error('SLUG_EXISTS');
109
+ return {
110
+ id: `tool-${Date.now()}`,
111
+ name: input.name,
112
+ slug: input.slug,
113
+ status: 'DRAFT' as const,
114
+ };
115
+ }
116
+
117
+ /**
118
+ * Mock handler for UpdateToolCommand.
119
+ */
120
+ export async function mockUpdateToolHandler(input: {
121
+ toolId: string;
122
+ name?: string;
123
+ status?: 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'DISABLED';
124
+ }) {
125
+ const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
126
+ if (!tool) throw new Error('TOOL_NOT_FOUND');
127
+ return {
128
+ id: tool.id,
129
+ name: input.name ?? tool.name,
130
+ status: input.status ?? tool.status,
131
+ updatedAt: new Date(),
132
+ };
133
+ }
134
+
135
+ /**
136
+ * Mock handler for TestToolCommand.
137
+ */
138
+ export async function mockTestToolHandler(input: {
139
+ toolId: string;
140
+ testInput: Record<string, unknown>;
141
+ }) {
142
+ const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
143
+ if (!tool) throw new Error('TOOL_NOT_FOUND');
144
+
145
+ // Simulate tool execution
146
+ const startTime = Date.now();
147
+ await new Promise((resolve) => setTimeout(resolve, 100));
148
+
149
+ return {
150
+ success: true,
151
+ output: { result: 'Test successful', input: input.testInput },
152
+ durationMs: Date.now() - startTime,
153
+ };
154
+ }