@contractspec/example.agent-console 1.57.0 → 1.58.0

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 (386) hide show
  1. package/.turbo/turbo-build.log +210 -278
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +16 -0
  4. package/dist/agent/agent.entity.d.ts +35 -40
  5. package/dist/agent/agent.entity.d.ts.map +1 -1
  6. package/dist/agent/agent.entity.js +124 -132
  7. package/dist/agent/agent.enum.d.ts +3 -8
  8. package/dist/agent/agent.enum.d.ts.map +1 -1
  9. package/dist/agent/agent.enum.js +22 -30
  10. package/dist/agent/agent.event.d.ts +105 -111
  11. package/dist/agent/agent.event.d.ts.map +1 -1
  12. package/dist/agent/agent.event.js +107 -200
  13. package/dist/agent/agent.handler.d.ts +74 -77
  14. package/dist/agent/agent.handler.d.ts.map +1 -1
  15. package/dist/agent/agent.handler.js +293 -75
  16. package/dist/agent/agent.operation.d.ts +424 -430
  17. package/dist/agent/agent.operation.d.ts.map +1 -1
  18. package/dist/agent/agent.operation.js +728 -478
  19. package/dist/agent/agent.presentation.d.ts +3 -8
  20. package/dist/agent/agent.presentation.d.ts.map +1 -1
  21. package/dist/agent/agent.presentation.js +275 -84
  22. package/dist/agent/agent.schema.d.ts +371 -376
  23. package/dist/agent/agent.schema.d.ts.map +1 -1
  24. package/dist/agent/agent.schema.js +209 -399
  25. package/dist/agent/agent.test-spec.d.ts +2 -7
  26. package/dist/agent/agent.test-spec.d.ts.map +1 -1
  27. package/dist/agent/agent.test-spec.js +56 -62
  28. package/dist/agent/index.d.ts +11 -8
  29. package/dist/agent/index.d.ts.map +1 -0
  30. package/dist/agent/index.js +1245 -9
  31. package/dist/agent.capability.d.ts +1 -6
  32. package/dist/agent.capability.d.ts.map +1 -1
  33. package/dist/agent.capability.js +17 -20
  34. package/dist/agent.feature.d.ts +7 -6
  35. package/dist/agent.feature.d.ts.map +1 -1
  36. package/dist/agent.feature.js +117 -303
  37. package/dist/browser/agent/agent.entity.js +127 -0
  38. package/dist/browser/agent/agent.enum.js +25 -0
  39. package/dist/browser/agent/agent.event.js +116 -0
  40. package/dist/browser/agent/agent.handler.js +301 -0
  41. package/dist/browser/agent/agent.operation.js +735 -0
  42. package/dist/browser/agent/agent.presentation.js +279 -0
  43. package/dist/browser/agent/agent.schema.js +215 -0
  44. package/dist/browser/agent/agent.test-spec.js +58 -0
  45. package/dist/browser/agent/index.js +1244 -0
  46. package/dist/browser/agent.capability.js +16 -0
  47. package/dist/browser/agent.feature.js +118 -0
  48. package/dist/browser/docs/agent-console.docblock.js +93 -0
  49. package/dist/browser/docs/index.js +93 -0
  50. package/dist/browser/example.js +42 -0
  51. package/dist/browser/handlers/agent.handlers.js +252 -0
  52. package/dist/browser/handlers/index.js +799 -0
  53. package/dist/browser/index.js +5895 -0
  54. package/dist/browser/presentations/index.js +684 -0
  55. package/dist/browser/run/index.js +1350 -0
  56. package/dist/browser/run/run.entity.js +160 -0
  57. package/dist/browser/run/run.enum.js +34 -0
  58. package/dist/browser/run/run.event.js +213 -0
  59. package/dist/browser/run/run.handler.js +254 -0
  60. package/dist/browser/run/run.operation.js +667 -0
  61. package/dist/browser/run/run.presentation.js +220 -0
  62. package/dist/browser/run/run.schema.js +179 -0
  63. package/dist/browser/run/run.test-spec.js +58 -0
  64. package/dist/browser/seeders/index.js +21 -0
  65. package/dist/browser/shared/index.js +334 -0
  66. package/dist/browser/shared/mock-agents.js +82 -0
  67. package/dist/browser/shared/mock-runs.js +108 -0
  68. package/dist/browser/shared/mock-tools.js +146 -0
  69. package/dist/browser/shared/overlay-types.js +0 -0
  70. package/dist/browser/tool/index.js +946 -0
  71. package/dist/browser/tool/tool.entity.js +90 -0
  72. package/dist/browser/tool/tool.enum.js +26 -0
  73. package/dist/browser/tool/tool.event.js +99 -0
  74. package/dist/browser/tool/tool.handler.js +223 -0
  75. package/dist/browser/tool/tool.operation.js +482 -0
  76. package/dist/browser/tool/tool.presentation.js +185 -0
  77. package/dist/browser/tool/tool.schema.js +141 -0
  78. package/dist/browser/tool/tool.test-spec.js +58 -0
  79. package/dist/browser/ui/AgentDashboard.js +1607 -0
  80. package/dist/browser/ui/AgentRunList.js +250 -0
  81. package/dist/browser/ui/AgentToolRegistry.js +212 -0
  82. package/dist/browser/ui/hooks/index.js +271 -0
  83. package/dist/browser/ui/hooks/useAgentList.js +55 -0
  84. package/dist/browser/ui/hooks/useAgentMutations.js +76 -0
  85. package/dist/browser/ui/hooks/useRunList.js +55 -0
  86. package/dist/browser/ui/hooks/useToolList.js +85 -0
  87. package/dist/browser/ui/index.js +2080 -0
  88. package/dist/browser/ui/modals/AgentActionsModal.js +304 -0
  89. package/dist/browser/ui/modals/CreateAgentModal.js +229 -0
  90. package/dist/browser/ui/modals/index.js +532 -0
  91. package/dist/browser/ui/overlays/demo-overlays.js +64 -0
  92. package/dist/browser/ui/overlays/index.js +64 -0
  93. package/dist/browser/ui/renderers/agent-list.markdown.js +55 -0
  94. package/dist/browser/ui/renderers/agent-list.renderer.js +180 -0
  95. package/dist/browser/ui/renderers/dashboard.markdown.js +117 -0
  96. package/dist/browser/ui/renderers/index.js +446 -0
  97. package/dist/browser/ui/renderers/run-list.markdown.js +45 -0
  98. package/dist/browser/ui/renderers/tool-registry.markdown.js +53 -0
  99. package/dist/browser/ui/views/AgentListView.js +165 -0
  100. package/dist/browser/ui/views/RunListView.js +247 -0
  101. package/dist/browser/ui/views/ToolRegistryView.js +209 -0
  102. package/dist/browser/ui/views/index.js +619 -0
  103. package/dist/docs/agent-console.docblock.d.ts +2 -1
  104. package/dist/docs/agent-console.docblock.d.ts.map +1 -0
  105. package/dist/docs/agent-console.docblock.js +45 -64
  106. package/dist/docs/index.d.ts +2 -1
  107. package/dist/docs/index.d.ts.map +1 -0
  108. package/dist/docs/index.js +94 -1
  109. package/dist/example.d.ts +2 -6
  110. package/dist/example.d.ts.map +1 -1
  111. package/dist/example.js +41 -55
  112. package/dist/handlers/agent.handlers.d.ts +121 -120
  113. package/dist/handlers/agent.handlers.d.ts.map +1 -1
  114. package/dist/handlers/agent.handlers.js +235 -245
  115. package/dist/handlers/index.d.ts +8 -5
  116. package/dist/handlers/index.d.ts.map +1 -0
  117. package/dist/handlers/index.js +799 -5
  118. package/dist/index.d.ts +26 -48
  119. package/dist/index.d.ts.map +1 -0
  120. package/dist/index.js +5896 -50
  121. package/dist/node/agent/agent.entity.js +127 -0
  122. package/dist/node/agent/agent.enum.js +25 -0
  123. package/dist/node/agent/agent.event.js +116 -0
  124. package/dist/node/agent/agent.handler.js +301 -0
  125. package/dist/node/agent/agent.operation.js +735 -0
  126. package/dist/node/agent/agent.presentation.js +279 -0
  127. package/dist/node/agent/agent.schema.js +215 -0
  128. package/dist/node/agent/agent.test-spec.js +58 -0
  129. package/dist/node/agent/index.js +1244 -0
  130. package/dist/node/agent.capability.js +16 -0
  131. package/dist/node/agent.feature.js +118 -0
  132. package/dist/node/docs/agent-console.docblock.js +93 -0
  133. package/dist/node/docs/index.js +93 -0
  134. package/dist/node/example.js +42 -0
  135. package/dist/node/handlers/agent.handlers.js +252 -0
  136. package/dist/node/handlers/index.js +799 -0
  137. package/dist/node/index.js +5895 -0
  138. package/dist/node/presentations/index.js +684 -0
  139. package/dist/node/run/index.js +1350 -0
  140. package/dist/node/run/run.entity.js +160 -0
  141. package/dist/node/run/run.enum.js +34 -0
  142. package/dist/node/run/run.event.js +213 -0
  143. package/dist/node/run/run.handler.js +254 -0
  144. package/dist/node/run/run.operation.js +667 -0
  145. package/dist/node/run/run.presentation.js +220 -0
  146. package/dist/node/run/run.schema.js +179 -0
  147. package/dist/node/run/run.test-spec.js +58 -0
  148. package/dist/node/seeders/index.js +21 -0
  149. package/dist/node/shared/index.js +334 -0
  150. package/dist/node/shared/mock-agents.js +82 -0
  151. package/dist/node/shared/mock-runs.js +108 -0
  152. package/dist/node/shared/mock-tools.js +146 -0
  153. package/dist/node/shared/overlay-types.js +0 -0
  154. package/dist/node/tool/index.js +946 -0
  155. package/dist/node/tool/tool.entity.js +90 -0
  156. package/dist/node/tool/tool.enum.js +26 -0
  157. package/dist/node/tool/tool.event.js +99 -0
  158. package/dist/node/tool/tool.handler.js +223 -0
  159. package/dist/node/tool/tool.operation.js +482 -0
  160. package/dist/node/tool/tool.presentation.js +185 -0
  161. package/dist/node/tool/tool.schema.js +141 -0
  162. package/dist/node/tool/tool.test-spec.js +58 -0
  163. package/dist/node/ui/AgentDashboard.js +1607 -0
  164. package/dist/node/ui/AgentRunList.js +250 -0
  165. package/dist/node/ui/AgentToolRegistry.js +212 -0
  166. package/dist/node/ui/hooks/index.js +271 -0
  167. package/dist/node/ui/hooks/useAgentList.js +55 -0
  168. package/dist/node/ui/hooks/useAgentMutations.js +76 -0
  169. package/dist/node/ui/hooks/useRunList.js +55 -0
  170. package/dist/node/ui/hooks/useToolList.js +85 -0
  171. package/dist/node/ui/index.js +2080 -0
  172. package/dist/node/ui/modals/AgentActionsModal.js +304 -0
  173. package/dist/node/ui/modals/CreateAgentModal.js +229 -0
  174. package/dist/node/ui/modals/index.js +532 -0
  175. package/dist/node/ui/overlays/demo-overlays.js +64 -0
  176. package/dist/node/ui/overlays/index.js +64 -0
  177. package/dist/node/ui/renderers/agent-list.markdown.js +55 -0
  178. package/dist/node/ui/renderers/agent-list.renderer.js +180 -0
  179. package/dist/node/ui/renderers/dashboard.markdown.js +117 -0
  180. package/dist/node/ui/renderers/index.js +446 -0
  181. package/dist/node/ui/renderers/run-list.markdown.js +45 -0
  182. package/dist/node/ui/renderers/tool-registry.markdown.js +53 -0
  183. package/dist/node/ui/views/AgentListView.js +165 -0
  184. package/dist/node/ui/views/RunListView.js +247 -0
  185. package/dist/node/ui/views/ToolRegistryView.js +209 -0
  186. package/dist/node/ui/views/index.js +619 -0
  187. package/dist/presentations/index.d.ts +9 -4
  188. package/dist/presentations/index.d.ts.map +1 -0
  189. package/dist/presentations/index.js +684 -4
  190. package/dist/run/index.d.ts +11 -8
  191. package/dist/run/index.d.ts.map +1 -0
  192. package/dist/run/index.js +1351 -9
  193. package/dist/run/run.entity.d.ts +55 -60
  194. package/dist/run/run.entity.d.ts.map +1 -1
  195. package/dist/run/run.entity.js +155 -199
  196. package/dist/run/run.enum.d.ts +4 -9
  197. package/dist/run/run.enum.d.ts.map +1 -1
  198. package/dist/run/run.enum.js +30 -40
  199. package/dist/run/run.event.d.ts +255 -261
  200. package/dist/run/run.event.d.ts.map +1 -1
  201. package/dist/run/run.event.js +198 -418
  202. package/dist/run/run.handler.d.ts +169 -172
  203. package/dist/run/run.handler.d.ts.map +1 -1
  204. package/dist/run/run.handler.js +246 -74
  205. package/dist/run/run.operation.d.ts +658 -664
  206. package/dist/run/run.operation.d.ts.map +1 -1
  207. package/dist/run/run.operation.js +659 -617
  208. package/dist/run/run.presentation.d.ts +2 -7
  209. package/dist/run/run.presentation.d.ts.map +1 -1
  210. package/dist/run/run.presentation.js +217 -61
  211. package/dist/run/run.schema.d.ts +367 -372
  212. package/dist/run/run.schema.d.ts.map +1 -1
  213. package/dist/run/run.schema.js +172 -330
  214. package/dist/run/run.test-spec.d.ts +2 -7
  215. package/dist/run/run.test-spec.d.ts.map +1 -1
  216. package/dist/run/run.test-spec.js +56 -62
  217. package/dist/seeders/index.d.ts +4 -8
  218. package/dist/seeders/index.d.ts.map +1 -1
  219. package/dist/seeders/index.js +19 -17
  220. package/dist/shared/index.d.ts +7 -4
  221. package/dist/shared/index.d.ts.map +1 -0
  222. package/dist/shared/index.js +334 -4
  223. package/dist/shared/mock-agents.d.ts +77 -80
  224. package/dist/shared/mock-agents.d.ts.map +1 -1
  225. package/dist/shared/mock-agents.js +82 -93
  226. package/dist/shared/mock-runs.d.ts +107 -110
  227. package/dist/shared/mock-runs.d.ts.map +1 -1
  228. package/dist/shared/mock-runs.js +108 -117
  229. package/dist/shared/mock-tools.d.ts +217 -220
  230. package/dist/shared/mock-tools.d.ts.map +1 -1
  231. package/dist/shared/mock-tools.js +146 -180
  232. package/dist/shared/overlay-types.d.ts +25 -28
  233. package/dist/shared/overlay-types.d.ts.map +1 -1
  234. package/dist/shared/overlay-types.js +1 -0
  235. package/dist/tool/index.d.ts +11 -8
  236. package/dist/tool/index.d.ts.map +1 -0
  237. package/dist/tool/index.js +947 -9
  238. package/dist/tool/tool.entity.d.ts +23 -28
  239. package/dist/tool/tool.entity.d.ts.map +1 -1
  240. package/dist/tool/tool.entity.js +87 -101
  241. package/dist/tool/tool.enum.d.ts +3 -8
  242. package/dist/tool/tool.enum.d.ts.map +1 -1
  243. package/dist/tool/tool.enum.js +23 -31
  244. package/dist/tool/tool.event.d.ts +84 -90
  245. package/dist/tool/tool.event.d.ts.map +1 -1
  246. package/dist/tool/tool.event.js +92 -151
  247. package/dist/tool/tool.handler.d.ts +266 -269
  248. package/dist/tool/tool.handler.d.ts.map +1 -1
  249. package/dist/tool/tool.handler.js +213 -76
  250. package/dist/tool/tool.operation.d.ts +359 -365
  251. package/dist/tool/tool.operation.d.ts.map +1 -1
  252. package/dist/tool/tool.operation.js +477 -400
  253. package/dist/tool/tool.presentation.d.ts +2 -7
  254. package/dist/tool/tool.presentation.d.ts.map +1 -1
  255. package/dist/tool/tool.presentation.js +182 -61
  256. package/dist/tool/tool.schema.d.ts +196 -201
  257. package/dist/tool/tool.schema.d.ts.map +1 -1
  258. package/dist/tool/tool.schema.js +137 -231
  259. package/dist/tool/tool.test-spec.d.ts +2 -7
  260. package/dist/tool/tool.test-spec.d.ts.map +1 -1
  261. package/dist/tool/tool.test-spec.js +56 -62
  262. package/dist/ui/AgentDashboard.d.ts +1 -6
  263. package/dist/ui/AgentDashboard.d.ts.map +1 -1
  264. package/dist/ui/AgentDashboard.js +1598 -410
  265. package/dist/ui/AgentRunList.d.ts +7 -2
  266. package/dist/ui/AgentRunList.d.ts.map +1 -0
  267. package/dist/ui/AgentRunList.js +249 -3
  268. package/dist/ui/AgentToolRegistry.d.ts +7 -2
  269. package/dist/ui/AgentToolRegistry.d.ts.map +1 -0
  270. package/dist/ui/AgentToolRegistry.js +211 -3
  271. package/dist/ui/hooks/index.d.ts +8 -6
  272. package/dist/ui/hooks/index.d.ts.map +1 -0
  273. package/dist/ui/hooks/index.js +270 -6
  274. package/dist/ui/hooks/useAgentList.d.ts +21 -25
  275. package/dist/ui/hooks/useAgentList.d.ts.map +1 -1
  276. package/dist/ui/hooks/useAgentList.js +52 -62
  277. package/dist/ui/hooks/useAgentMutations.d.ts +22 -25
  278. package/dist/ui/hooks/useAgentMutations.d.ts.map +1 -1
  279. package/dist/ui/hooks/useAgentMutations.js +73 -120
  280. package/dist/ui/hooks/useRunList.d.ts +17 -21
  281. package/dist/ui/hooks/useRunList.d.ts.map +1 -1
  282. package/dist/ui/hooks/useRunList.js +52 -62
  283. package/dist/ui/hooks/useToolList.d.ts +32 -36
  284. package/dist/ui/hooks/useToolList.d.ts.map +1 -1
  285. package/dist/ui/hooks/useToolList.js +82 -92
  286. package/dist/ui/index.d.ts +9 -24
  287. package/dist/ui/index.d.ts.map +1 -0
  288. package/dist/ui/index.js +2081 -24
  289. package/dist/ui/modals/AgentActionsModal.d.ts +11 -24
  290. package/dist/ui/modals/AgentActionsModal.d.ts.map +1 -1
  291. package/dist/ui/modals/AgentActionsModal.js +300 -257
  292. package/dist/ui/modals/CreateAgentModal.d.ts +12 -21
  293. package/dist/ui/modals/CreateAgentModal.d.ts.map +1 -1
  294. package/dist/ui/modals/CreateAgentModal.js +226 -210
  295. package/dist/ui/modals/index.d.ts +3 -3
  296. package/dist/ui/modals/index.d.ts.map +1 -0
  297. package/dist/ui/modals/index.js +532 -3
  298. package/dist/ui/overlays/demo-overlays.d.ts +10 -8
  299. package/dist/ui/overlays/demo-overlays.d.ts.map +1 -1
  300. package/dist/ui/overlays/demo-overlays.js +63 -71
  301. package/dist/ui/overlays/index.d.ts +2 -2
  302. package/dist/ui/overlays/index.d.ts.map +1 -0
  303. package/dist/ui/overlays/index.js +65 -3
  304. package/dist/ui/renderers/agent-list.markdown.d.ts +9 -8
  305. package/dist/ui/renderers/agent-list.markdown.d.ts.map +1 -1
  306. package/dist/ui/renderers/agent-list.markdown.js +55 -50
  307. package/dist/ui/renderers/agent-list.renderer.d.ts +5 -6
  308. package/dist/ui/renderers/agent-list.renderer.d.ts.map +1 -1
  309. package/dist/ui/renderers/agent-list.renderer.js +179 -17
  310. package/dist/ui/renderers/dashboard.markdown.d.ts +9 -8
  311. package/dist/ui/renderers/dashboard.markdown.d.ts.map +1 -1
  312. package/dist/ui/renderers/dashboard.markdown.js +115 -97
  313. package/dist/ui/renderers/index.d.ts +9 -6
  314. package/dist/ui/renderers/index.d.ts.map +1 -0
  315. package/dist/ui/renderers/index.js +446 -6
  316. package/dist/ui/renderers/run-list.markdown.d.ts +9 -8
  317. package/dist/ui/renderers/run-list.markdown.d.ts.map +1 -1
  318. package/dist/ui/renderers/run-list.markdown.js +42 -40
  319. package/dist/ui/renderers/tool-registry.markdown.d.ts +9 -8
  320. package/dist/ui/renderers/tool-registry.markdown.d.ts.map +1 -1
  321. package/dist/ui/renderers/tool-registry.markdown.js +52 -53
  322. package/dist/ui/views/AgentListView.d.ts +1 -6
  323. package/dist/ui/views/AgentListView.d.ts.map +1 -1
  324. package/dist/ui/views/AgentListView.js +161 -88
  325. package/dist/ui/views/RunListView.d.ts +4 -11
  326. package/dist/ui/views/RunListView.d.ts.map +1 -1
  327. package/dist/ui/views/RunListView.js +237 -154
  328. package/dist/ui/views/ToolRegistryView.d.ts +4 -11
  329. package/dist/ui/views/ToolRegistryView.d.ts.map +1 -1
  330. package/dist/ui/views/ToolRegistryView.js +205 -92
  331. package/dist/ui/views/index.d.ts +7 -4
  332. package/dist/ui/views/index.d.ts.map +1 -0
  333. package/dist/ui/views/index.js +619 -4
  334. package/package.json +656 -118
  335. package/tsdown.config.js +1 -2
  336. package/.turbo/turbo-build$colon$bundle.log +0 -285
  337. package/dist/agent/agent.entity.js.map +0 -1
  338. package/dist/agent/agent.enum.js.map +0 -1
  339. package/dist/agent/agent.event.js.map +0 -1
  340. package/dist/agent/agent.handler.js.map +0 -1
  341. package/dist/agent/agent.operation.js.map +0 -1
  342. package/dist/agent/agent.presentation.js.map +0 -1
  343. package/dist/agent/agent.schema.js.map +0 -1
  344. package/dist/agent/agent.test-spec.js.map +0 -1
  345. package/dist/agent.capability.js.map +0 -1
  346. package/dist/agent.feature.js.map +0 -1
  347. package/dist/docs/agent-console.docblock.js.map +0 -1
  348. package/dist/example.js.map +0 -1
  349. package/dist/handlers/agent.handlers.js.map +0 -1
  350. package/dist/run/run.entity.js.map +0 -1
  351. package/dist/run/run.enum.js.map +0 -1
  352. package/dist/run/run.event.js.map +0 -1
  353. package/dist/run/run.handler.js.map +0 -1
  354. package/dist/run/run.operation.js.map +0 -1
  355. package/dist/run/run.presentation.js.map +0 -1
  356. package/dist/run/run.schema.js.map +0 -1
  357. package/dist/run/run.test-spec.js.map +0 -1
  358. package/dist/seeders/index.js.map +0 -1
  359. package/dist/shared/mock-agents.js.map +0 -1
  360. package/dist/shared/mock-runs.js.map +0 -1
  361. package/dist/shared/mock-tools.js.map +0 -1
  362. package/dist/tool/tool.entity.js.map +0 -1
  363. package/dist/tool/tool.enum.js.map +0 -1
  364. package/dist/tool/tool.event.js.map +0 -1
  365. package/dist/tool/tool.handler.js.map +0 -1
  366. package/dist/tool/tool.operation.js.map +0 -1
  367. package/dist/tool/tool.presentation.js.map +0 -1
  368. package/dist/tool/tool.schema.js.map +0 -1
  369. package/dist/tool/tool.test-spec.js.map +0 -1
  370. package/dist/ui/AgentDashboard.js.map +0 -1
  371. package/dist/ui/hooks/useAgentList.js.map +0 -1
  372. package/dist/ui/hooks/useAgentMutations.js.map +0 -1
  373. package/dist/ui/hooks/useRunList.js.map +0 -1
  374. package/dist/ui/hooks/useToolList.js.map +0 -1
  375. package/dist/ui/modals/AgentActionsModal.js.map +0 -1
  376. package/dist/ui/modals/CreateAgentModal.js.map +0 -1
  377. package/dist/ui/overlays/demo-overlays.js.map +0 -1
  378. package/dist/ui/renderers/agent-list.markdown.js.map +0 -1
  379. package/dist/ui/renderers/agent-list.renderer.js.map +0 -1
  380. package/dist/ui/renderers/dashboard.markdown.js.map +0 -1
  381. package/dist/ui/renderers/run-list.markdown.js.map +0 -1
  382. package/dist/ui/renderers/tool-registry.markdown.js.map +0 -1
  383. package/dist/ui/views/AgentListView.js.map +0 -1
  384. package/dist/ui/views/RunListView.js.map +0 -1
  385. package/dist/ui/views/ToolRegistryView.js.map +0 -1
  386. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,16 @@
1
+ // src/agent.capability.ts
2
+ import { defineCapability, StabilityEnum } from "@contractspec/lib.contracts";
3
+ var AgentCapability = defineCapability({
4
+ meta: {
5
+ key: "agent",
6
+ version: "1.0.0",
7
+ kind: "ui",
8
+ stability: StabilityEnum.Experimental,
9
+ description: "AI agent management and console capability",
10
+ owners: ["platform.core"],
11
+ tags: ["agent", "ai", "console"]
12
+ }
13
+ });
14
+ export {
15
+ AgentCapability
16
+ };
@@ -0,0 +1,118 @@
1
+ // src/agent.feature.ts
2
+ import { defineFeature } from "@contractspec/lib.contracts";
3
+ var AgentConsoleFeature = defineFeature({
4
+ meta: {
5
+ key: "agent-console",
6
+ version: "1.0.0",
7
+ title: "AI Agent Console",
8
+ description: "AI agent orchestration with tools, runs, and logs management",
9
+ domain: "ai-ops",
10
+ owners: ["@agent-console-team"],
11
+ tags: ["ai", "agents", "orchestration"],
12
+ stability: "stable"
13
+ },
14
+ operations: [
15
+ { key: "agent-console.agent.create", version: "1.0.0" },
16
+ { key: "agent-console.agent.update", version: "1.0.0" },
17
+ { key: "agent-console.agent.get", version: "1.0.0" },
18
+ { key: "agent-console.agent.list", version: "1.0.0" },
19
+ { key: "agent-console.agent.assignTool", version: "1.0.0" },
20
+ { key: "agent-console.agent.removeTool", version: "1.0.0" },
21
+ { key: "agent.tool.create", version: "1.0.0" },
22
+ { key: "agent.tool.update", version: "1.0.0" },
23
+ { key: "agent.tool.get", version: "1.0.0" },
24
+ { key: "agent.tool.list", version: "1.0.0" },
25
+ { key: "agent.tool.test", version: "1.0.0" },
26
+ { key: "agent.run.execute", version: "1.0.0" },
27
+ { key: "agent.run.cancel", version: "1.0.0" },
28
+ { key: "agent.run.get", version: "1.0.0" },
29
+ { key: "agent.run.list", version: "1.0.0" },
30
+ { key: "agent.run.getSteps", version: "1.0.0" },
31
+ { key: "agent.run.getLogs", version: "1.0.0" },
32
+ { key: "agent.run.getMetrics", version: "1.0.0" }
33
+ ],
34
+ events: [
35
+ { key: "agent-console.agent.created", version: "1.0.0" },
36
+ { key: "agent-console.agent.updated", version: "1.0.0" },
37
+ { key: "agent-console.agent.toolAssigned", version: "1.0.0" },
38
+ { key: "agent-console.agent.toolRemoved", version: "1.0.0" },
39
+ { key: "agent.tool.created", version: "1.0.0" },
40
+ { key: "agent.tool.updated", version: "1.0.0" },
41
+ { key: "agent.tool.statusChanged", version: "1.0.0" },
42
+ { key: "agent.run.started", version: "1.0.0" },
43
+ { key: "agent.run.completed", version: "1.0.0" },
44
+ { key: "agent.run.failed", version: "1.0.0" },
45
+ { key: "agent.run.cancelled", version: "1.0.0" },
46
+ { key: "agent.run.toolInvoked", version: "1.0.0" },
47
+ { key: "agent.run.toolCompleted", version: "1.0.0" },
48
+ { key: "agent.run.messageGenerated", version: "1.0.0" }
49
+ ],
50
+ presentations: [
51
+ { key: "agent-console.dashboard", version: "1.0.0" },
52
+ { key: "agent-console.agent.viewList", version: "1.0.0" },
53
+ { key: "agent-console.agent.detail", version: "1.0.0" },
54
+ { key: "agent-console.run.list", version: "1.0.0" },
55
+ { key: "agent-console.run.detail", version: "1.0.0" },
56
+ { key: "agent-console.tool.list", version: "1.0.0" },
57
+ { key: "agent-console.tool.detail", version: "1.0.0" }
58
+ ],
59
+ opToPresentation: [
60
+ {
61
+ op: { key: "agent-console.agent.list", version: "1.0.0" },
62
+ pres: { key: "agent-console.agent.viewList", version: "1.0.0" }
63
+ },
64
+ {
65
+ op: { key: "agent-console.agent.get", version: "1.0.0" },
66
+ pres: { key: "agent-console.agent.detail", version: "1.0.0" }
67
+ },
68
+ {
69
+ op: { key: "agent.run.list", version: "1.0.0" },
70
+ pres: { key: "agent-console.run.list", version: "1.0.0" }
71
+ },
72
+ {
73
+ op: { key: "agent.run.get", version: "1.0.0" },
74
+ pres: { key: "agent-console.run.detail", version: "1.0.0" }
75
+ },
76
+ {
77
+ op: { key: "agent.tool.list", version: "1.0.0" },
78
+ pres: { key: "agent-console.tool.list", version: "1.0.0" }
79
+ },
80
+ {
81
+ op: { key: "agent.tool.get", version: "1.0.0" },
82
+ pres: { key: "agent-console.tool.detail", version: "1.0.0" }
83
+ }
84
+ ],
85
+ presentationsTargets: [
86
+ {
87
+ key: "agent-console.dashboard",
88
+ version: "1.0.0",
89
+ targets: ["react", "markdown"]
90
+ },
91
+ {
92
+ key: "agent-console.agent.viewList",
93
+ version: "1.0.0",
94
+ targets: ["react", "markdown", "application/json"]
95
+ },
96
+ {
97
+ key: "agent-console.run.list",
98
+ version: "1.0.0",
99
+ targets: ["react", "markdown", "application/json"]
100
+ },
101
+ {
102
+ key: "agent-console.tool.list",
103
+ version: "1.0.0",
104
+ targets: ["react", "markdown", "application/json"]
105
+ }
106
+ ],
107
+ capabilities: {
108
+ requires: [
109
+ { key: "identity", version: "1.0.0" },
110
+ { key: "audit-trail", version: "1.0.0" },
111
+ { key: "jobs", version: "1.0.0" }
112
+ ],
113
+ provides: [{ key: "agent", version: "1.0.0" }]
114
+ }
115
+ });
116
+ export {
117
+ AgentConsoleFeature
118
+ };
@@ -0,0 +1,93 @@
1
+ // src/docs/agent-console.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var agentConsoleDocBlocks = [
4
+ {
5
+ id: "docs.examples.agent-console.goal",
6
+ title: "Agent Console — Goal",
7
+ summary: "AI agent ops console: tools, agents, runs, logs, and metrics.",
8
+ kind: "goal",
9
+ visibility: "public",
10
+ route: "/docs/examples/agent-console/goal",
11
+ tags: ["ai", "agents", "goal"],
12
+ body: `## Why it matters
13
+ - Provides a regenerable agent operations surface with tool registry and run history.
14
+ - Prevents drift between tool schemas, agent configs, and execution logs.
15
+
16
+ ## Business/Product goal
17
+ - Safely manage tools/agents/runs with auditability and observability.
18
+ - Enable staged rollout of tools and metrics via feature flags.
19
+
20
+ ## Success criteria
21
+ - Tool/agent/run specs regenerate UI/API/events cleanly.
22
+ - Logs/metrics stay aligned and PII is scoped.`
23
+ },
24
+ {
25
+ id: "docs.examples.agent-console.usage",
26
+ title: "Agent Console — Usage",
27
+ summary: "How to operate, extend, and regenerate the agent console safely.",
28
+ kind: "usage",
29
+ visibility: "public",
30
+ route: "/docs/examples/agent-console/usage",
31
+ tags: ["ai", "agents", "usage"],
32
+ body: `## Setup
33
+ 1) Seed (if available) or create tools and agents; define run configs.
34
+ 2) Configure Notifications for run completion/failure; Audit for changes.
35
+
36
+ ## Extend & regenerate
37
+ 1) Adjust tool schemas (inputs/outputs), agent configs, run metrics in spec.
38
+ 2) Regenerate to sync UI/API/events/logs; mark PII paths for run payloads.
39
+ 3) Use Feature Flags to gate risky tools or execution policies.
40
+
41
+ ## Guardrails
42
+ - Emit events for run lifecycle; store logs with redaction where needed.
43
+ - Enforce tool input validation; avoid unsafe arbitrary code exec in handlers.
44
+ - Keep tenant/user scoping explicit for ops data.`
45
+ },
46
+ {
47
+ id: "docs.examples.agent-console.reference",
48
+ title: "Agent Console — Reference",
49
+ summary: "Entities, contracts, events, and presentations for the agent console.",
50
+ kind: "reference",
51
+ visibility: "public",
52
+ route: "/docs/examples/agent-console",
53
+ tags: ["ai", "agents", "reference"],
54
+ body: `## Entities
55
+ - Tool, Agent, AgentTool, Run, RunStep, RunLog, RunMetric.
56
+
57
+ ## Contracts
58
+ - tool/create, agent/create, agent/execute, run/get, run/logs, run/metrics.
59
+
60
+ ## Events
61
+ - tool.created, agent.created, run.started/completed/failed, tool.invoked.
62
+
63
+ ## Presentations
64
+ - Tool registry, agent list/detail, run list/detail, metrics dashboards.
65
+
66
+ ## Notes
67
+ - Keep tool schemas explicit; enforce validation in spec.
68
+ - Use Audit Trail for agent/run changes; Notifications for run outcomes.`
69
+ },
70
+ {
71
+ id: "docs.examples.agent-console.constraints",
72
+ title: "Agent Console — Constraints & Safety",
73
+ summary: "Internal guardrails for tool/agent/run safety, PII, and regeneration.",
74
+ kind: "reference",
75
+ visibility: "internal",
76
+ route: "/docs/examples/agent-console/constraints",
77
+ tags: ["ai", "agents", "constraints", "internal"],
78
+ body: `## Constraints
79
+ - Tool schemas (inputs/outputs) must be explicit in spec; no arbitrary untyped payloads.
80
+ - Events to emit: tool.created, agent.created, run.started/completed/failed, tool.invoked.
81
+ - Regeneration must not loosen execution policies or logging without explicit spec diff.
82
+
83
+ ## Safety & PII
84
+ - Mark PII in run payloads/logs; redact in markdown/JSON targets.
85
+ - Avoid exposing raw tool outputs to MCP/web without policy checks.
86
+
87
+ ## Verification
88
+ - Add fixtures for tool schema changes and run lifecycle.
89
+ - Ensure Audit/Notifications remain wired for runs; metrics collection unchanged.
90
+ - Use Feature Flags to gate risky tools; default safe/off.`
91
+ }
92
+ ];
93
+ registerDocBlocks(agentConsoleDocBlocks);
@@ -0,0 +1,93 @@
1
+ // src/docs/agent-console.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var agentConsoleDocBlocks = [
4
+ {
5
+ id: "docs.examples.agent-console.goal",
6
+ title: "Agent Console — Goal",
7
+ summary: "AI agent ops console: tools, agents, runs, logs, and metrics.",
8
+ kind: "goal",
9
+ visibility: "public",
10
+ route: "/docs/examples/agent-console/goal",
11
+ tags: ["ai", "agents", "goal"],
12
+ body: `## Why it matters
13
+ - Provides a regenerable agent operations surface with tool registry and run history.
14
+ - Prevents drift between tool schemas, agent configs, and execution logs.
15
+
16
+ ## Business/Product goal
17
+ - Safely manage tools/agents/runs with auditability and observability.
18
+ - Enable staged rollout of tools and metrics via feature flags.
19
+
20
+ ## Success criteria
21
+ - Tool/agent/run specs regenerate UI/API/events cleanly.
22
+ - Logs/metrics stay aligned and PII is scoped.`
23
+ },
24
+ {
25
+ id: "docs.examples.agent-console.usage",
26
+ title: "Agent Console — Usage",
27
+ summary: "How to operate, extend, and regenerate the agent console safely.",
28
+ kind: "usage",
29
+ visibility: "public",
30
+ route: "/docs/examples/agent-console/usage",
31
+ tags: ["ai", "agents", "usage"],
32
+ body: `## Setup
33
+ 1) Seed (if available) or create tools and agents; define run configs.
34
+ 2) Configure Notifications for run completion/failure; Audit for changes.
35
+
36
+ ## Extend & regenerate
37
+ 1) Adjust tool schemas (inputs/outputs), agent configs, run metrics in spec.
38
+ 2) Regenerate to sync UI/API/events/logs; mark PII paths for run payloads.
39
+ 3) Use Feature Flags to gate risky tools or execution policies.
40
+
41
+ ## Guardrails
42
+ - Emit events for run lifecycle; store logs with redaction where needed.
43
+ - Enforce tool input validation; avoid unsafe arbitrary code exec in handlers.
44
+ - Keep tenant/user scoping explicit for ops data.`
45
+ },
46
+ {
47
+ id: "docs.examples.agent-console.reference",
48
+ title: "Agent Console — Reference",
49
+ summary: "Entities, contracts, events, and presentations for the agent console.",
50
+ kind: "reference",
51
+ visibility: "public",
52
+ route: "/docs/examples/agent-console",
53
+ tags: ["ai", "agents", "reference"],
54
+ body: `## Entities
55
+ - Tool, Agent, AgentTool, Run, RunStep, RunLog, RunMetric.
56
+
57
+ ## Contracts
58
+ - tool/create, agent/create, agent/execute, run/get, run/logs, run/metrics.
59
+
60
+ ## Events
61
+ - tool.created, agent.created, run.started/completed/failed, tool.invoked.
62
+
63
+ ## Presentations
64
+ - Tool registry, agent list/detail, run list/detail, metrics dashboards.
65
+
66
+ ## Notes
67
+ - Keep tool schemas explicit; enforce validation in spec.
68
+ - Use Audit Trail for agent/run changes; Notifications for run outcomes.`
69
+ },
70
+ {
71
+ id: "docs.examples.agent-console.constraints",
72
+ title: "Agent Console — Constraints & Safety",
73
+ summary: "Internal guardrails for tool/agent/run safety, PII, and regeneration.",
74
+ kind: "reference",
75
+ visibility: "internal",
76
+ route: "/docs/examples/agent-console/constraints",
77
+ tags: ["ai", "agents", "constraints", "internal"],
78
+ body: `## Constraints
79
+ - Tool schemas (inputs/outputs) must be explicit in spec; no arbitrary untyped payloads.
80
+ - Events to emit: tool.created, agent.created, run.started/completed/failed, tool.invoked.
81
+ - Regeneration must not loosen execution policies or logging without explicit spec diff.
82
+
83
+ ## Safety & PII
84
+ - Mark PII in run payloads/logs; redact in markdown/JSON targets.
85
+ - Avoid exposing raw tool outputs to MCP/web without policy checks.
86
+
87
+ ## Verification
88
+ - Add fixtures for tool schema changes and run lifecycle.
89
+ - Ensure Audit/Notifications remain wired for runs; metrics collection unchanged.
90
+ - Use Feature Flags to gate risky tools; default safe/off.`
91
+ }
92
+ ];
93
+ registerDocBlocks(agentConsoleDocBlocks);
@@ -0,0 +1,42 @@
1
+ // src/example.ts
2
+ import { defineExample } from "@contractspec/lib.contracts";
3
+ var example = defineExample({
4
+ meta: {
5
+ key: "agent-console",
6
+ version: "1.0.0",
7
+ title: "Agent Console",
8
+ description: "AI agent ops console: tools, agents, runs, logs, and metrics (spec-first, regenerable).",
9
+ kind: "template",
10
+ visibility: "public",
11
+ stability: "experimental",
12
+ owners: ["@platform.core"],
13
+ tags: ["ai", "agents", "tools", "orchestration"]
14
+ },
15
+ docs: {
16
+ rootDocId: "docs.examples.agent-console.reference",
17
+ goalDocId: "docs.examples.agent-console.goal",
18
+ usageDocId: "docs.examples.agent-console.usage",
19
+ constraintsDocId: "docs.examples.agent-console.constraints"
20
+ },
21
+ entrypoints: {
22
+ packageName: "@contractspec/example.agent-console",
23
+ feature: "./feature",
24
+ contracts: "./contracts",
25
+ presentations: "./presentations",
26
+ handlers: "./handlers",
27
+ docs: "./docs"
28
+ },
29
+ surfaces: {
30
+ templates: true,
31
+ sandbox: {
32
+ enabled: true,
33
+ modes: ["playground", "specs", "builder", "markdown", "evolution"]
34
+ },
35
+ studio: { enabled: true, installable: true },
36
+ mcp: { enabled: true }
37
+ }
38
+ });
39
+ var example_default = example;
40
+ export {
41
+ example_default as default
42
+ };
@@ -0,0 +1,252 @@
1
+ // src/handlers/agent.handlers.ts
2
+ import { web } from "@contractspec/lib.runtime-sandbox";
3
+ var { generateId } = web;
4
+ function rowToAgent(row) {
5
+ return {
6
+ id: row.id,
7
+ projectId: row.projectId,
8
+ organizationId: row.organizationId,
9
+ name: row.name,
10
+ description: row.description ?? undefined,
11
+ modelProvider: row.modelProvider,
12
+ modelName: row.modelName,
13
+ systemPrompt: row.systemPrompt ?? undefined,
14
+ temperature: row.temperature,
15
+ maxTokens: row.maxTokens,
16
+ status: row.status,
17
+ createdAt: new Date(row.createdAt),
18
+ updatedAt: new Date(row.updatedAt)
19
+ };
20
+ }
21
+ function rowToTool(row) {
22
+ return {
23
+ id: row.id,
24
+ projectId: row.projectId,
25
+ organizationId: row.organizationId,
26
+ name: row.name,
27
+ description: row.description ?? undefined,
28
+ version: row.version,
29
+ category: row.category,
30
+ status: row.status,
31
+ inputSchema: row.inputSchema ?? undefined,
32
+ outputSchema: row.outputSchema ?? undefined,
33
+ endpoint: row.endpoint ?? undefined,
34
+ createdAt: new Date(row.createdAt),
35
+ updatedAt: new Date(row.updatedAt)
36
+ };
37
+ }
38
+ function rowToRun(row, agentName) {
39
+ return {
40
+ id: row.id,
41
+ projectId: row.projectId,
42
+ agentId: row.agentId,
43
+ agentName,
44
+ status: row.status,
45
+ input: row.input ?? undefined,
46
+ output: row.output ?? undefined,
47
+ totalTokens: row.totalTokens,
48
+ promptTokens: row.promptTokens,
49
+ completionTokens: row.completionTokens,
50
+ estimatedCostUsd: row.estimatedCostUsd,
51
+ durationMs: row.durationMs ?? undefined,
52
+ errorMessage: row.errorMessage ?? undefined,
53
+ queuedAt: new Date(row.queuedAt),
54
+ startedAt: row.startedAt ? new Date(row.startedAt) : undefined,
55
+ completedAt: row.completedAt ? new Date(row.completedAt) : undefined
56
+ };
57
+ }
58
+ function createAgentHandlers(db) {
59
+ async function listAgents(input) {
60
+ const {
61
+ projectId,
62
+ organizationId,
63
+ status,
64
+ search,
65
+ limit = 20,
66
+ offset = 0
67
+ } = input;
68
+ let whereClause = "WHERE projectId = ?";
69
+ const params = [projectId];
70
+ if (organizationId) {
71
+ whereClause += " AND organizationId = ?";
72
+ params.push(organizationId);
73
+ }
74
+ if (status && status !== "all") {
75
+ whereClause += " AND status = ?";
76
+ params.push(status);
77
+ }
78
+ if (search) {
79
+ whereClause += " AND (name LIKE ? OR description LIKE ?)";
80
+ params.push(`%${search}%`, `%${search}%`);
81
+ }
82
+ const countResult = (await db.query(`SELECT COUNT(*) as count FROM agent_definition ${whereClause}`, params)).rows;
83
+ const total = countResult[0]?.count ?? 0;
84
+ const rows = (await db.query(`SELECT * FROM agent_definition ${whereClause} ORDER BY createdAt DESC LIMIT ? OFFSET ?`, [...params, limit, offset])).rows;
85
+ return {
86
+ items: rows.map(rowToAgent),
87
+ total,
88
+ hasMore: offset + rows.length < total
89
+ };
90
+ }
91
+ async function getAgent(id) {
92
+ const rows = (await db.query(`SELECT * FROM agent_definition WHERE id = ?`, [id])).rows;
93
+ return rows[0] ? rowToAgent(rows[0]) : null;
94
+ }
95
+ async function createAgent(input, context) {
96
+ const id = generateId("agent");
97
+ const now = new Date().toISOString();
98
+ await db.execute(`INSERT INTO agent_definition (id, projectId, organizationId, name, description, modelProvider, modelName, systemPrompt, temperature, maxTokens, status, createdAt, updatedAt)
99
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
100
+ id,
101
+ context.projectId,
102
+ context.organizationId,
103
+ input.name,
104
+ input.description ?? null,
105
+ input.modelProvider ?? "openai",
106
+ input.modelName ?? "gpt-4",
107
+ input.systemPrompt ?? null,
108
+ input.temperature ?? 0.7,
109
+ input.maxTokens ?? 4096,
110
+ "DRAFT",
111
+ now,
112
+ now
113
+ ]);
114
+ const rows = (await db.query(`SELECT * FROM agent_definition WHERE id = ?`, [id])).rows;
115
+ const row = rows[0];
116
+ if (!row) {
117
+ throw new Error("Failed to retrieve created agent");
118
+ }
119
+ return rowToAgent(row);
120
+ }
121
+ async function updateAgent(input) {
122
+ const now = new Date().toISOString();
123
+ const updates = ["updatedAt = ?"];
124
+ const params = [now];
125
+ if (input.name !== undefined) {
126
+ updates.push("name = ?");
127
+ params.push(input.name);
128
+ }
129
+ if (input.description !== undefined) {
130
+ updates.push("description = ?");
131
+ params.push(input.description);
132
+ }
133
+ if (input.status !== undefined) {
134
+ updates.push("status = ?");
135
+ params.push(input.status);
136
+ }
137
+ params.push(input.id);
138
+ await db.execute(`UPDATE agent_definition SET ${updates.join(", ")} WHERE id = ?`, params);
139
+ const rows = (await db.query(`SELECT * FROM agent_definition WHERE id = ?`, [input.id])).rows;
140
+ if (!rows[0]) {
141
+ throw new Error("NOT_FOUND");
142
+ }
143
+ return rowToAgent(rows[0]);
144
+ }
145
+ async function listTools(input) {
146
+ const {
147
+ projectId,
148
+ organizationId,
149
+ category,
150
+ status,
151
+ search,
152
+ limit = 50,
153
+ offset = 0
154
+ } = input;
155
+ let whereClause = "WHERE projectId = ?";
156
+ const params = [projectId];
157
+ if (organizationId) {
158
+ whereClause += " AND organizationId = ?";
159
+ params.push(organizationId);
160
+ }
161
+ if (category && category !== "all") {
162
+ whereClause += " AND category = ?";
163
+ params.push(category);
164
+ }
165
+ if (status && status !== "all") {
166
+ whereClause += " AND status = ?";
167
+ params.push(status);
168
+ }
169
+ if (search) {
170
+ whereClause += " AND (name LIKE ? OR description LIKE ?)";
171
+ params.push(`%${search}%`, `%${search}%`);
172
+ }
173
+ const countResult = (await db.query(`SELECT COUNT(*) as count FROM agent_tool ${whereClause}`, params)).rows;
174
+ const total = countResult[0]?.count ?? 0;
175
+ const rows = (await db.query(`SELECT * FROM agent_tool ${whereClause} ORDER BY name ASC LIMIT ? OFFSET ?`, [...params, limit, offset])).rows;
176
+ return {
177
+ items: rows.map(rowToTool),
178
+ total,
179
+ hasMore: offset + rows.length < total
180
+ };
181
+ }
182
+ async function listRuns(input) {
183
+ const { projectId, agentId, status, limit = 20, offset = 0 } = input;
184
+ let whereClause = "WHERE r.projectId = ?";
185
+ const params = [projectId];
186
+ if (agentId) {
187
+ whereClause += " AND r.agentId = ?";
188
+ params.push(agentId);
189
+ }
190
+ if (status && status !== "all") {
191
+ whereClause += " AND r.status = ?";
192
+ params.push(status);
193
+ }
194
+ const countResult = (await db.query(`SELECT COUNT(*) as count FROM agent_run r ${whereClause}`, params)).rows;
195
+ const total = countResult[0]?.count ?? 0;
196
+ const rows = (await db.query(`SELECT r.*, a.name as agentName
197
+ FROM agent_run r
198
+ LEFT JOIN agent_definition a ON r.agentId = a.id
199
+ ${whereClause}
200
+ ORDER BY r.queuedAt DESC LIMIT ? OFFSET ?`, [...params, limit, offset])).rows;
201
+ return {
202
+ items: rows.map((r) => rowToRun(r, r.agentName)),
203
+ total,
204
+ hasMore: offset + rows.length < total
205
+ };
206
+ }
207
+ async function getRunMetrics(input) {
208
+ let whereClause = "WHERE projectId = ?";
209
+ const params = [input.projectId];
210
+ if (input.agentId) {
211
+ whereClause += " AND agentId = ?";
212
+ params.push(input.agentId);
213
+ }
214
+ if (input.startDate) {
215
+ whereClause += " AND queuedAt >= ?";
216
+ params.push(input.startDate.toISOString());
217
+ }
218
+ if (input.endDate) {
219
+ whereClause += " AND queuedAt <= ?";
220
+ params.push(input.endDate.toISOString());
221
+ }
222
+ const result = (await db.query(`SELECT
223
+ COUNT(*) as totalRuns,
224
+ SUM(CASE WHEN status = 'COMPLETED' THEN 1 ELSE 0 END) as completedRuns,
225
+ AVG(CASE WHEN status = 'COMPLETED' THEN durationMs ELSE NULL END) as avgDuration,
226
+ COALESCE(SUM(totalTokens), 0) as totalTokens,
227
+ COALESCE(SUM(estimatedCostUsd), 0) as totalCost
228
+ FROM agent_run ${whereClause}`, params)).rows;
229
+ const data = result[0];
230
+ const totalRuns = data?.totalRuns ?? 0;
231
+ const completedRuns = data?.completedRuns ?? 0;
232
+ return {
233
+ totalRuns,
234
+ successRate: totalRuns > 0 ? completedRuns / totalRuns : 0,
235
+ averageDurationMs: data?.avgDuration ?? 0,
236
+ totalTokens: data?.totalTokens ?? 0,
237
+ totalCostUsd: data?.totalCost ?? 0
238
+ };
239
+ }
240
+ return {
241
+ listAgents,
242
+ getAgent,
243
+ createAgent,
244
+ updateAgent,
245
+ listTools,
246
+ listRuns,
247
+ getRunMetrics
248
+ };
249
+ }
250
+ export {
251
+ createAgentHandlers
252
+ };