@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
package/dist/run/index.js CHANGED
@@ -1,9 +1,1351 @@
1
- import { GranularityEnum, LogLevelEnum, RunStatusEnum, RunStepTypeEnum } from "./run.enum.js";
2
- import { RunAgentRefModel, RunInputModel, RunLogModel, RunModel, RunStepModel, RunSummaryModel, TimelineDataPointModel } from "./run.schema.js";
3
- import { CancelRunCommand, ExecuteAgentCommand, GetRunLogsQuery, GetRunMetricsQuery, GetRunQuery, GetRunStepsQuery, ListRunsQuery } from "./run.operation.js";
4
- import { MessageGeneratedEvent, RunCancelledEvent, RunCompletedEvent, RunFailedEvent, RunStartedEvent, ToolCompletedEvent, ToolInvokedEvent } from "./run.event.js";
5
- import { LogLevelEntityEnum, RunEntity, RunLogEntity, RunStatusEntityEnum, RunStepEntity, RunStepTypeEntityEnum } from "./run.entity.js";
6
- import { RunDetailPresentation, RunListPresentation } from "./run.presentation.js";
7
- import { mockCancelRunHandler, mockExecuteAgentHandler, mockGetRunHandler, mockListRunsHandler } from "./run.handler.js";
8
-
9
- export { CancelRunCommand, ExecuteAgentCommand, GetRunLogsQuery, GetRunMetricsQuery, GetRunQuery, GetRunStepsQuery, GranularityEnum, ListRunsQuery, LogLevelEntityEnum, LogLevelEnum, MessageGeneratedEvent, RunAgentRefModel, RunCancelledEvent, RunCompletedEvent, RunDetailPresentation, RunEntity, RunFailedEvent, RunInputModel, RunListPresentation, RunLogEntity, RunLogModel, RunModel, RunStartedEvent, RunStatusEntityEnum, RunStatusEnum, RunStepEntity, RunStepModel, RunStepTypeEntityEnum, RunStepTypeEnum, RunSummaryModel, TimelineDataPointModel, ToolCompletedEvent, ToolInvokedEvent, mockCancelRunHandler, mockExecuteAgentHandler, mockGetRunHandler, mockListRunsHandler };
1
+ // @bun
2
+ // src/shared/mock-agents.ts
3
+ var MOCK_AGENTS = [
4
+ {
5
+ id: "agent-1",
6
+ organizationId: "demo-org",
7
+ name: "Customer Support Bot",
8
+ slug: "customer-support-bot",
9
+ description: "Handles tier-1 customer inquiries and routes complex issues.",
10
+ status: "ACTIVE",
11
+ modelProvider: "OPENAI",
12
+ modelName: "gpt-4o-mini",
13
+ modelConfig: { temperature: 0.7 },
14
+ systemPrompt: "You are a helpful customer support assistant.",
15
+ toolChoice: "auto",
16
+ maxIterations: 10,
17
+ timeoutMs: 120000,
18
+ version: "1.0.0",
19
+ tags: ["support", "tier-1"],
20
+ createdAt: new Date("2024-01-15T10:00:00Z"),
21
+ updatedAt: new Date("2024-03-20T14:30:00Z")
22
+ },
23
+ {
24
+ id: "agent-2",
25
+ organizationId: "demo-org",
26
+ name: "Code Review Assistant",
27
+ slug: "code-review-assistant",
28
+ description: "Reviews pull requests and provides actionable feedback.",
29
+ status: "ACTIVE",
30
+ modelProvider: "ANTHROPIC",
31
+ modelName: "claude-sonnet-4-20250514",
32
+ modelConfig: { temperature: 0.3 },
33
+ systemPrompt: "You are a code review expert.",
34
+ toolChoice: "auto",
35
+ maxIterations: 15,
36
+ timeoutMs: 180000,
37
+ version: "2.1.0",
38
+ tags: ["code", "review", "dev"],
39
+ createdAt: new Date("2024-02-10T09:00:00Z"),
40
+ updatedAt: new Date("2024-04-05T11:15:00Z")
41
+ },
42
+ {
43
+ id: "agent-3",
44
+ organizationId: "demo-org",
45
+ name: "Data Analyst",
46
+ slug: "data-analyst",
47
+ description: "Queries databases and generates insights from data.",
48
+ status: "PAUSED",
49
+ modelProvider: "OPENAI",
50
+ modelName: "gpt-4o",
51
+ modelConfig: { temperature: 0.5 },
52
+ systemPrompt: "You are a data analyst expert in SQL and analytics.",
53
+ toolChoice: "required",
54
+ maxIterations: 20,
55
+ timeoutMs: 300000,
56
+ version: "1.2.0",
57
+ tags: ["data", "analytics", "sql"],
58
+ createdAt: new Date("2024-03-01T08:00:00Z"),
59
+ updatedAt: new Date("2024-04-10T16:45:00Z")
60
+ },
61
+ {
62
+ id: "agent-4",
63
+ organizationId: "demo-org",
64
+ name: "Meeting Scheduler",
65
+ slug: "meeting-scheduler",
66
+ description: "Schedules meetings and manages calendar conflicts.",
67
+ status: "DRAFT",
68
+ modelProvider: "GOOGLE",
69
+ modelName: "gemini-2.0-flash",
70
+ modelConfig: { temperature: 0.2 },
71
+ systemPrompt: "You help schedule and organize meetings efficiently.",
72
+ toolChoice: "auto",
73
+ maxIterations: 5,
74
+ timeoutMs: 60000,
75
+ version: "0.1.0",
76
+ tags: ["calendar", "scheduling"],
77
+ createdAt: new Date("2024-04-01T12:00:00Z"),
78
+ updatedAt: new Date("2024-04-01T12:00:00Z")
79
+ }
80
+ ];
81
+
82
+ // src/shared/mock-runs.ts
83
+ var MOCK_RUNS = [
84
+ {
85
+ id: "run-1",
86
+ organizationId: "demo-org",
87
+ agentId: "agent-1",
88
+ agentName: "Customer Support Bot",
89
+ userId: "user-1",
90
+ sessionId: "session-1",
91
+ input: { message: "How do I reset my password?", context: {} },
92
+ output: { response: "You can reset your password by clicking..." },
93
+ status: "COMPLETED",
94
+ totalTokens: 1250,
95
+ promptTokens: 800,
96
+ completionTokens: 450,
97
+ totalIterations: 3,
98
+ durationMs: 4500,
99
+ estimatedCostUsd: 0.0025,
100
+ queuedAt: new Date("2024-04-15T10:00:00Z"),
101
+ startedAt: new Date("2024-04-15T10:00:01Z"),
102
+ completedAt: new Date("2024-04-15T10:00:05Z"),
103
+ steps: [],
104
+ logs: []
105
+ },
106
+ {
107
+ id: "run-2",
108
+ organizationId: "demo-org",
109
+ agentId: "agent-2",
110
+ agentName: "Code Review Assistant",
111
+ userId: "user-2",
112
+ input: { message: "Review PR #123", context: { prNumber: 123 } },
113
+ status: "IN_PROGRESS",
114
+ totalTokens: 3500,
115
+ promptTokens: 3000,
116
+ completionTokens: 500,
117
+ totalIterations: 5,
118
+ queuedAt: new Date("2024-04-15T10:30:00Z"),
119
+ startedAt: new Date("2024-04-15T10:30:02Z"),
120
+ steps: [],
121
+ logs: []
122
+ },
123
+ {
124
+ id: "run-3",
125
+ organizationId: "demo-org",
126
+ agentId: "agent-1",
127
+ agentName: "Customer Support Bot",
128
+ userId: "user-1",
129
+ input: { message: "What are your business hours?" },
130
+ output: { response: "Our business hours are 9 AM to 5 PM EST..." },
131
+ status: "COMPLETED",
132
+ totalTokens: 800,
133
+ promptTokens: 500,
134
+ completionTokens: 300,
135
+ totalIterations: 2,
136
+ durationMs: 2100,
137
+ estimatedCostUsd: 0.0012,
138
+ queuedAt: new Date("2024-04-15T09:00:00Z"),
139
+ startedAt: new Date("2024-04-15T09:00:01Z"),
140
+ completedAt: new Date("2024-04-15T09:00:03Z"),
141
+ steps: [],
142
+ logs: []
143
+ },
144
+ {
145
+ id: "run-4",
146
+ organizationId: "demo-org",
147
+ agentId: "agent-3",
148
+ agentName: "Data Analyst",
149
+ userId: "user-3",
150
+ input: { message: "Generate sales report for Q1" },
151
+ status: "FAILED",
152
+ errorMessage: "Database connection timeout",
153
+ errorCode: "DB_TIMEOUT",
154
+ totalTokens: 2000,
155
+ promptTokens: 1500,
156
+ completionTokens: 500,
157
+ totalIterations: 8,
158
+ durationMs: 45000,
159
+ queuedAt: new Date("2024-04-14T15:00:00Z"),
160
+ startedAt: new Date("2024-04-14T15:00:05Z"),
161
+ completedAt: new Date("2024-04-14T15:00:50Z"),
162
+ steps: [],
163
+ logs: []
164
+ },
165
+ {
166
+ id: "run-5",
167
+ organizationId: "demo-org",
168
+ agentId: "agent-2",
169
+ agentName: "Code Review Assistant",
170
+ userId: "user-2",
171
+ input: { message: "Review PR #120" },
172
+ output: { response: "Code review complete. 3 suggestions..." },
173
+ status: "COMPLETED",
174
+ totalTokens: 5200,
175
+ promptTokens: 4000,
176
+ completionTokens: 1200,
177
+ totalIterations: 7,
178
+ durationMs: 15000,
179
+ estimatedCostUsd: 0.0156,
180
+ queuedAt: new Date("2024-04-14T11:00:00Z"),
181
+ startedAt: new Date("2024-04-14T11:00:03Z"),
182
+ completedAt: new Date("2024-04-14T11:00:18Z"),
183
+ steps: [],
184
+ logs: []
185
+ }
186
+ ];
187
+
188
+ // src/run/run.handler.ts
189
+ async function mockListRunsHandler(input) {
190
+ const { agentId, status, limit = 20, offset = 0 } = input;
191
+ let filtered = [...MOCK_RUNS];
192
+ if (agentId)
193
+ filtered = filtered.filter((r) => r.agentId === agentId);
194
+ if (status)
195
+ filtered = filtered.filter((r) => r.status === status);
196
+ const total = filtered.length;
197
+ const items = filtered.slice(offset, offset + limit).map((r) => {
198
+ const agent = MOCK_AGENTS.find((a) => a.id === r.agentId);
199
+ return {
200
+ id: r.id,
201
+ agentId: r.agentId,
202
+ agentName: agent?.name ?? "Unknown",
203
+ status: r.status,
204
+ totalTokens: r.totalTokens,
205
+ durationMs: r.durationMs,
206
+ estimatedCostUsd: r.estimatedCostUsd,
207
+ queuedAt: r.queuedAt,
208
+ completedAt: r.completedAt
209
+ };
210
+ });
211
+ return { items, total, hasMore: offset + limit < total };
212
+ }
213
+ async function mockGetRunHandler(input) {
214
+ const run = MOCK_RUNS.find((r) => r.id === input.runId);
215
+ if (!run)
216
+ throw new Error("RUN_NOT_FOUND");
217
+ const agent = MOCK_AGENTS.find((a) => a.id === run.agentId);
218
+ return {
219
+ ...run,
220
+ agent: agent ? {
221
+ id: agent.id,
222
+ name: agent.name,
223
+ modelProvider: agent.modelProvider,
224
+ modelName: agent.modelName
225
+ } : undefined,
226
+ steps: input.includeSteps ? run.steps : undefined,
227
+ logs: input.includeLogs ? run.logs : undefined
228
+ };
229
+ }
230
+ async function mockExecuteAgentHandler(input) {
231
+ const agent = MOCK_AGENTS.find((a) => a.id === input.agentId);
232
+ if (!agent)
233
+ throw new Error("AGENT_NOT_FOUND");
234
+ if (agent.status !== "ACTIVE")
235
+ throw new Error("AGENT_NOT_ACTIVE");
236
+ return {
237
+ runId: `run-${Date.now()}`,
238
+ status: "QUEUED",
239
+ estimatedWaitMs: 500
240
+ };
241
+ }
242
+ async function mockCancelRunHandler(input) {
243
+ const run = MOCK_RUNS.find((r) => r.id === input.runId);
244
+ if (!run)
245
+ throw new Error("RUN_NOT_FOUND");
246
+ if (!["QUEUED", "IN_PROGRESS"].includes(run.status))
247
+ throw new Error("RUN_NOT_CANCELLABLE");
248
+ return { success: true, status: "CANCELLED" };
249
+ }
250
+
251
+ // src/run/run.enum.ts
252
+ import { defineEnum } from "@contractspec/lib.schema";
253
+ var RunStatusEnum = defineEnum("RunStatus", [
254
+ "QUEUED",
255
+ "IN_PROGRESS",
256
+ "COMPLETED",
257
+ "FAILED",
258
+ "CANCELLED",
259
+ "EXPIRED"
260
+ ]);
261
+ var RunStepTypeEnum = defineEnum("RunStepType", [
262
+ "MESSAGE_CREATION",
263
+ "TOOL_CALL",
264
+ "TOOL_RESULT",
265
+ "ERROR"
266
+ ]);
267
+ var LogLevelEnum = defineEnum("LogLevel", [
268
+ "DEBUG",
269
+ "INFO",
270
+ "WARN",
271
+ "ERROR"
272
+ ]);
273
+ var GranularityEnum = defineEnum("Granularity", [
274
+ "hour",
275
+ "day",
276
+ "week",
277
+ "month"
278
+ ]);
279
+
280
+ // src/run/run.schema.ts
281
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
282
+ var RunInputModel = defineSchemaModel({
283
+ name: "RunInput",
284
+ description: "Input data for agent execution",
285
+ fields: {
286
+ message: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
287
+ context: { type: ScalarTypeEnum.JSONObject(), isOptional: true }
288
+ }
289
+ });
290
+ var RunStepModel = defineSchemaModel({
291
+ name: "RunStep",
292
+ description: "Individual step within a run",
293
+ fields: {
294
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
295
+ stepNumber: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
296
+ type: { type: RunStepTypeEnum, isOptional: false },
297
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
298
+ toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
299
+ input: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
300
+ output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
301
+ status: { type: RunStatusEnum, isOptional: false },
302
+ errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
303
+ tokensUsed: {
304
+ type: ScalarTypeEnum.Int_unsecure(),
305
+ isOptional: false,
306
+ defaultValue: 0
307
+ },
308
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
309
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
310
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
311
+ }
312
+ });
313
+ var RunLogModel = defineSchemaModel({
314
+ name: "RunLog",
315
+ description: "Execution log entry",
316
+ fields: {
317
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
318
+ stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
319
+ level: { type: LogLevelEnum, isOptional: false },
320
+ message: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
321
+ data: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
322
+ source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
323
+ traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
324
+ spanId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
325
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
326
+ }
327
+ });
328
+ var RunAgentRefModel = defineSchemaModel({
329
+ name: "RunAgentRef",
330
+ description: "Agent reference in a run",
331
+ fields: {
332
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
333
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
334
+ modelProvider: {
335
+ type: ScalarTypeEnum.String_unsecure(),
336
+ isOptional: false
337
+ },
338
+ modelName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
339
+ }
340
+ });
341
+ var RunModel = defineSchemaModel({
342
+ name: "Run",
343
+ description: "Agent execution instance",
344
+ fields: {
345
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
346
+ organizationId: {
347
+ type: ScalarTypeEnum.String_unsecure(),
348
+ isOptional: false
349
+ },
350
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
351
+ userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
352
+ sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
353
+ input: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
354
+ output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
355
+ status: { type: RunStatusEnum, isOptional: false },
356
+ errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
357
+ errorCode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
358
+ totalTokens: {
359
+ type: ScalarTypeEnum.Int_unsecure(),
360
+ isOptional: false,
361
+ defaultValue: 0
362
+ },
363
+ promptTokens: {
364
+ type: ScalarTypeEnum.Int_unsecure(),
365
+ isOptional: false,
366
+ defaultValue: 0
367
+ },
368
+ completionTokens: {
369
+ type: ScalarTypeEnum.Int_unsecure(),
370
+ isOptional: false,
371
+ defaultValue: 0
372
+ },
373
+ totalIterations: {
374
+ type: ScalarTypeEnum.Int_unsecure(),
375
+ isOptional: false,
376
+ defaultValue: 0
377
+ },
378
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
379
+ estimatedCostUsd: {
380
+ type: ScalarTypeEnum.Float_unsecure(),
381
+ isOptional: true
382
+ },
383
+ queuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
384
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
385
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
386
+ metadata: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
387
+ steps: { type: RunStepModel, isArray: true, isOptional: true },
388
+ logs: { type: RunLogModel, isArray: true, isOptional: true },
389
+ agent: { type: RunAgentRefModel, isOptional: true }
390
+ }
391
+ });
392
+ var RunSummaryModel = defineSchemaModel({
393
+ name: "RunSummary",
394
+ description: "Summary of a run for list views",
395
+ fields: {
396
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
397
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
398
+ agentName: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
399
+ status: { type: RunStatusEnum, isOptional: false },
400
+ totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
401
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
402
+ estimatedCostUsd: {
403
+ type: ScalarTypeEnum.Float_unsecure(),
404
+ isOptional: true
405
+ },
406
+ queuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
407
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
408
+ }
409
+ });
410
+ var TimelineDataPointModel = defineSchemaModel({
411
+ name: "TimelineDataPoint",
412
+ description: "Timeline data point for metrics",
413
+ fields: {
414
+ period: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
415
+ runs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
416
+ tokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
417
+ costUsd: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
418
+ avgDurationMs: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
419
+ }
420
+ });
421
+
422
+ // src/run/run.operation.ts
423
+ import {
424
+ defineCommand,
425
+ defineQuery
426
+ } from "@contractspec/lib.contracts/operations";
427
+ import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
428
+ var OWNERS = ["@agent-console-team"];
429
+ var ExecuteAgentCommand = defineCommand({
430
+ meta: {
431
+ key: "agent.run.execute",
432
+ version: "1.0.0",
433
+ stability: "stable",
434
+ owners: [...OWNERS],
435
+ tags: ["run", "execute"],
436
+ description: "Starts a new agent run with the given input.",
437
+ goal: "Execute an AI agent with user input.",
438
+ context: "Called from chat interface or API."
439
+ },
440
+ io: {
441
+ input: defineSchemaModel2({
442
+ name: "ExecuteAgentInput",
443
+ fields: {
444
+ agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
445
+ input: { type: RunInputModel, isOptional: false },
446
+ sessionId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
447
+ metadata: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
448
+ stream: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
449
+ maxIterations: {
450
+ type: ScalarTypeEnum2.Int_unsecure(),
451
+ isOptional: true
452
+ },
453
+ timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true }
454
+ }
455
+ }),
456
+ output: defineSchemaModel2({
457
+ name: "ExecuteAgentOutput",
458
+ fields: {
459
+ runId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
460
+ status: { type: RunStatusEnum, isOptional: false },
461
+ estimatedWaitMs: {
462
+ type: ScalarTypeEnum2.Int_unsecure(),
463
+ isOptional: true
464
+ }
465
+ }
466
+ }),
467
+ errors: {
468
+ AGENT_NOT_FOUND: {
469
+ description: "The specified agent does not exist",
470
+ http: 404,
471
+ gqlCode: "AGENT_NOT_FOUND",
472
+ when: "Agent ID is invalid"
473
+ },
474
+ AGENT_NOT_ACTIVE: {
475
+ description: "The specified agent is not active",
476
+ http: 400,
477
+ gqlCode: "AGENT_NOT_ACTIVE",
478
+ when: "Agent is in draft/paused/archived state"
479
+ }
480
+ }
481
+ },
482
+ policy: { auth: "user" },
483
+ sideEffects: {
484
+ emits: [
485
+ {
486
+ key: "run.started",
487
+ version: "1.0.0",
488
+ stability: "stable",
489
+ owners: [...OWNERS],
490
+ tags: ["run", "started"],
491
+ when: "Run is queued",
492
+ payload: RunSummaryModel
493
+ }
494
+ ],
495
+ audit: ["run.started"]
496
+ },
497
+ acceptance: {
498
+ scenarios: [
499
+ {
500
+ key: "execute-agent-happy-path",
501
+ given: ["Agent exists", "Agent is active"],
502
+ when: ["User submits execution request"],
503
+ then: ["Run is created", "RunStarted event is emitted"]
504
+ },
505
+ {
506
+ key: "execute-agent-not-active",
507
+ given: ["Agent exists but is not active"],
508
+ when: ["User attempts to execute"],
509
+ then: ["AGENT_NOT_ACTIVE error is returned"]
510
+ }
511
+ ],
512
+ examples: [
513
+ {
514
+ key: "basic-execute",
515
+ input: { agentId: "agent-123", input: { message: "Hello" } },
516
+ output: { runId: "run-456", status: "pending", estimatedWaitMs: 5000 }
517
+ }
518
+ ]
519
+ }
520
+ });
521
+ var CancelRunCommand = defineCommand({
522
+ meta: {
523
+ key: "agent.run.cancel",
524
+ version: "1.0.0",
525
+ stability: "stable",
526
+ owners: [...OWNERS],
527
+ tags: ["run", "cancel"],
528
+ description: "Cancels an in-progress agent run.",
529
+ goal: "Stop a running agent execution.",
530
+ context: "Called when user wants to abort a long-running task."
531
+ },
532
+ io: {
533
+ input: defineSchemaModel2({
534
+ name: "CancelRunInput",
535
+ fields: {
536
+ runId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
537
+ reason: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
538
+ }
539
+ }),
540
+ output: defineSchemaModel2({
541
+ name: "CancelRunOutput",
542
+ fields: {
543
+ success: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
544
+ status: { type: RunStatusEnum, isOptional: false }
545
+ }
546
+ }),
547
+ errors: {
548
+ RUN_NOT_FOUND: {
549
+ description: "The specified run does not exist",
550
+ http: 404,
551
+ gqlCode: "RUN_NOT_FOUND",
552
+ when: "Run ID is invalid"
553
+ },
554
+ RUN_NOT_CANCELLABLE: {
555
+ description: "The run cannot be cancelled",
556
+ http: 400,
557
+ gqlCode: "RUN_NOT_CANCELLABLE",
558
+ when: "Run is already completed/failed/cancelled"
559
+ }
560
+ }
561
+ },
562
+ policy: { auth: "user" },
563
+ sideEffects: {
564
+ emits: [
565
+ {
566
+ key: "run.cancelled",
567
+ version: "1.0.0",
568
+ stability: "stable",
569
+ owners: [...OWNERS],
570
+ tags: ["run", "cancelled"],
571
+ when: "Run is cancelled",
572
+ payload: RunSummaryModel
573
+ }
574
+ ],
575
+ audit: ["run.cancelled"]
576
+ },
577
+ acceptance: {
578
+ scenarios: [
579
+ {
580
+ key: "cancel-run-happy-path",
581
+ given: ["Run exists", "Run is in progress"],
582
+ when: ["User cancels run"],
583
+ then: ["Run is cancelled", "RunCancelled event is emitted"]
584
+ },
585
+ {
586
+ key: "cancel-run-already-completed",
587
+ given: ["Run exists but is already completed"],
588
+ when: ["User attempts to cancel"],
589
+ then: ["RUN_NOT_CANCELLABLE error is returned"]
590
+ }
591
+ ],
592
+ examples: [
593
+ {
594
+ key: "cancel-basic",
595
+ input: { runId: "run-456", reason: "User requested" },
596
+ output: { success: true, status: "cancelled" }
597
+ }
598
+ ]
599
+ }
600
+ });
601
+ var GetRunQuery = defineQuery({
602
+ meta: {
603
+ key: "agent.run.get",
604
+ version: "1.0.0",
605
+ stability: "stable",
606
+ owners: [...OWNERS],
607
+ tags: ["run", "get"],
608
+ description: "Retrieves a run by its ID with optional details.",
609
+ goal: "View detailed run information.",
610
+ context: "Run details page or monitoring."
611
+ },
612
+ io: {
613
+ input: defineSchemaModel2({
614
+ name: "GetRunInput",
615
+ fields: {
616
+ runId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
617
+ includeSteps: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
618
+ includeLogs: { type: ScalarTypeEnum2.Boolean(), isOptional: true }
619
+ }
620
+ }),
621
+ output: RunModel,
622
+ errors: {
623
+ RUN_NOT_FOUND: {
624
+ description: "The specified run does not exist",
625
+ http: 404,
626
+ gqlCode: "RUN_NOT_FOUND",
627
+ when: "Run ID is invalid"
628
+ }
629
+ }
630
+ },
631
+ policy: { auth: "user" },
632
+ acceptance: {
633
+ scenarios: [
634
+ {
635
+ key: "get-run-happy-path",
636
+ given: ["Run exists"],
637
+ when: ["User requests run by ID"],
638
+ then: ["Run details are returned"]
639
+ }
640
+ ],
641
+ examples: [
642
+ {
643
+ key: "get-with-steps",
644
+ input: { runId: "run-456", includeSteps: true, includeLogs: false },
645
+ output: { id: "run-456", status: "completed", steps: [] }
646
+ }
647
+ ]
648
+ }
649
+ });
650
+ var ListRunsQuery = defineQuery({
651
+ meta: {
652
+ key: "agent.run.list",
653
+ version: "1.0.0",
654
+ stability: "stable",
655
+ owners: [...OWNERS],
656
+ tags: ["run", "list"],
657
+ description: "Lists runs with optional filtering.",
658
+ goal: "Browse and search run history.",
659
+ context: "Run history/dashboard view."
660
+ },
661
+ io: {
662
+ input: defineSchemaModel2({
663
+ name: "ListRunsInput",
664
+ fields: {
665
+ organizationId: {
666
+ type: ScalarTypeEnum2.String_unsecure(),
667
+ isOptional: true
668
+ },
669
+ agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
670
+ userId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
671
+ sessionId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
672
+ status: { type: RunStatusEnum, isOptional: true },
673
+ startDate: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
674
+ endDate: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
675
+ limit: {
676
+ type: ScalarTypeEnum2.Int_unsecure(),
677
+ isOptional: true,
678
+ defaultValue: 20
679
+ },
680
+ offset: {
681
+ type: ScalarTypeEnum2.Int_unsecure(),
682
+ isOptional: true,
683
+ defaultValue: 0
684
+ }
685
+ }
686
+ }),
687
+ output: defineSchemaModel2({
688
+ name: "ListRunsOutput",
689
+ fields: {
690
+ items: { type: RunSummaryModel, isArray: true, isOptional: false },
691
+ total: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
692
+ hasMore: { type: ScalarTypeEnum2.Boolean(), isOptional: false }
693
+ }
694
+ })
695
+ },
696
+ policy: { auth: "user" },
697
+ acceptance: {
698
+ scenarios: [
699
+ {
700
+ key: "list-runs-happy-path",
701
+ given: ["Organization has runs"],
702
+ when: ["User lists runs"],
703
+ then: ["Paginated list of runs is returned"]
704
+ }
705
+ ],
706
+ examples: [
707
+ {
708
+ key: "list-by-agent",
709
+ input: { agentId: "agent-123", limit: 20, offset: 0 },
710
+ output: { items: [], total: 0, hasMore: false }
711
+ }
712
+ ]
713
+ }
714
+ });
715
+ var GetRunStepsQuery = defineQuery({
716
+ meta: {
717
+ key: "agent.run.getSteps",
718
+ version: "1.0.0",
719
+ stability: "stable",
720
+ owners: [...OWNERS],
721
+ tags: ["run", "steps"],
722
+ description: "Retrieves all steps for a specific run.",
723
+ goal: "View step-by-step execution details.",
724
+ context: "Run details page - steps tab."
725
+ },
726
+ io: {
727
+ input: defineSchemaModel2({
728
+ name: "GetRunStepsInput",
729
+ fields: {
730
+ runId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
731
+ }
732
+ }),
733
+ output: defineSchemaModel2({
734
+ name: "GetRunStepsOutput",
735
+ fields: {
736
+ steps: { type: RunStepModel, isArray: true, isOptional: false }
737
+ }
738
+ })
739
+ },
740
+ policy: { auth: "user" },
741
+ acceptance: {
742
+ scenarios: [
743
+ {
744
+ key: "get-run-steps-happy-path",
745
+ given: ["Run exists with steps"],
746
+ when: ["User requests steps"],
747
+ then: ["Steps list is returned"]
748
+ }
749
+ ],
750
+ examples: [
751
+ {
752
+ key: "get-steps-basic",
753
+ input: { runId: "run-456" },
754
+ output: { steps: [] }
755
+ }
756
+ ]
757
+ }
758
+ });
759
+ var GetRunLogsQuery = defineQuery({
760
+ meta: {
761
+ key: "agent.run.getLogs",
762
+ version: "1.0.0",
763
+ stability: "stable",
764
+ owners: [...OWNERS],
765
+ tags: ["run", "logs"],
766
+ description: "Retrieves all logs for a specific run.",
767
+ goal: "Debug and audit run execution.",
768
+ context: "Run details page - logs tab."
769
+ },
770
+ io: {
771
+ input: defineSchemaModel2({
772
+ name: "GetRunLogsInput",
773
+ fields: {
774
+ runId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
775
+ level: { type: LogLevelEnum, isOptional: true },
776
+ stepId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
777
+ limit: {
778
+ type: ScalarTypeEnum2.Int_unsecure(),
779
+ isOptional: true,
780
+ defaultValue: 100
781
+ },
782
+ offset: {
783
+ type: ScalarTypeEnum2.Int_unsecure(),
784
+ isOptional: true,
785
+ defaultValue: 0
786
+ }
787
+ }
788
+ }),
789
+ output: defineSchemaModel2({
790
+ name: "GetRunLogsOutput",
791
+ fields: {
792
+ items: { type: RunLogModel, isArray: true, isOptional: false },
793
+ total: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
794
+ hasMore: { type: ScalarTypeEnum2.Boolean(), isOptional: false }
795
+ }
796
+ })
797
+ },
798
+ policy: { auth: "user" },
799
+ acceptance: {
800
+ scenarios: [
801
+ {
802
+ key: "get-run-logs-happy-path",
803
+ given: ["Run exists with logs"],
804
+ when: ["User requests logs"],
805
+ then: ["Paginated logs list is returned"]
806
+ }
807
+ ],
808
+ examples: [
809
+ {
810
+ key: "get-logs-filtered",
811
+ input: { runId: "run-456", level: "error", limit: 50 },
812
+ output: { items: [], total: 0, hasMore: false }
813
+ }
814
+ ]
815
+ }
816
+ });
817
+ var GetRunMetricsQuery = defineQuery({
818
+ meta: {
819
+ key: "agent.run.getMetrics",
820
+ version: "1.0.0",
821
+ stability: "stable",
822
+ owners: [...OWNERS],
823
+ tags: ["run", "metrics"],
824
+ description: "Retrieves aggregated metrics for runs within a time period.",
825
+ goal: "Monitor and analyze agent usage.",
826
+ context: "Analytics dashboard."
827
+ },
828
+ io: {
829
+ input: defineSchemaModel2({
830
+ name: "GetRunMetricsInput",
831
+ fields: {
832
+ organizationId: {
833
+ type: ScalarTypeEnum2.String_unsecure(),
834
+ isOptional: false
835
+ },
836
+ agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
837
+ startDate: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
838
+ endDate: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
839
+ granularity: {
840
+ type: GranularityEnum,
841
+ isOptional: true,
842
+ defaultValue: "day"
843
+ }
844
+ }
845
+ }),
846
+ output: defineSchemaModel2({
847
+ name: "GetRunMetricsOutput",
848
+ fields: {
849
+ totalRuns: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
850
+ completedRuns: {
851
+ type: ScalarTypeEnum2.Int_unsecure(),
852
+ isOptional: false
853
+ },
854
+ failedRuns: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
855
+ totalTokens: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
856
+ totalCostUsd: {
857
+ type: ScalarTypeEnum2.Float_unsecure(),
858
+ isOptional: false
859
+ },
860
+ averageDurationMs: {
861
+ type: ScalarTypeEnum2.Float_unsecure(),
862
+ isOptional: false
863
+ },
864
+ successRate: {
865
+ type: ScalarTypeEnum2.Float_unsecure(),
866
+ isOptional: false
867
+ },
868
+ timeline: {
869
+ type: TimelineDataPointModel,
870
+ isArray: true,
871
+ isOptional: false
872
+ }
873
+ }
874
+ })
875
+ },
876
+ policy: { auth: "user" },
877
+ acceptance: {
878
+ scenarios: [
879
+ {
880
+ key: "get-run-metrics-happy-path",
881
+ given: ["Organization has run history"],
882
+ when: ["User requests metrics for date range"],
883
+ then: ["Aggregated metrics are returned"]
884
+ }
885
+ ],
886
+ examples: [
887
+ {
888
+ key: "get-daily-metrics",
889
+ input: {
890
+ organizationId: "org-123",
891
+ startDate: "2025-01-01",
892
+ endDate: "2025-01-31",
893
+ granularity: "day"
894
+ },
895
+ output: {
896
+ totalRuns: 100,
897
+ completedRuns: 90,
898
+ failedRuns: 10,
899
+ totalTokens: 50000,
900
+ totalCostUsd: 5,
901
+ averageDurationMs: 2500,
902
+ successRate: 0.9,
903
+ timeline: []
904
+ }
905
+ }
906
+ ]
907
+ }
908
+ });
909
+
910
+ // src/run/run.event.ts
911
+ import { defineEvent, defineSchemaModel as defineSchemaModel3 } from "@contractspec/lib.contracts";
912
+ import { ScalarTypeEnum as ScalarTypeEnum3, defineEnum as defineEnum2 } from "@contractspec/lib.schema";
913
+ var OWNERS2 = ["@agent-console-team"];
914
+ var RunStartedPayload = defineSchemaModel3({
915
+ name: "RunStartedPayload",
916
+ description: "Payload for run started event",
917
+ fields: {
918
+ runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
919
+ organizationId: {
920
+ type: ScalarTypeEnum3.String_unsecure(),
921
+ isOptional: false
922
+ },
923
+ agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
924
+ agentName: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
925
+ userId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
926
+ sessionId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
927
+ input: { type: ScalarTypeEnum3.JSONObject(), isOptional: false },
928
+ startedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
929
+ }
930
+ });
931
+ var RunStartedEvent = defineEvent({
932
+ meta: {
933
+ key: "agent.run.started",
934
+ version: "1.0.0",
935
+ description: "An agent run was started.",
936
+ stability: "stable",
937
+ owners: [...OWNERS2],
938
+ tags: ["run", "started"]
939
+ },
940
+ payload: RunStartedPayload
941
+ });
942
+ var RunCompletedPayload = defineSchemaModel3({
943
+ name: "RunCompletedPayload",
944
+ description: "Payload for run completed event",
945
+ fields: {
946
+ runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
947
+ organizationId: {
948
+ type: ScalarTypeEnum3.String_unsecure(),
949
+ isOptional: false
950
+ },
951
+ agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
952
+ agentName: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
953
+ userId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
954
+ output: { type: ScalarTypeEnum3.JSONObject(), isOptional: false },
955
+ totalTokens: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
956
+ promptTokens: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
957
+ completionTokens: {
958
+ type: ScalarTypeEnum3.Int_unsecure(),
959
+ isOptional: false
960
+ },
961
+ totalIterations: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
962
+ durationMs: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
963
+ estimatedCostUsd: {
964
+ type: ScalarTypeEnum3.Float_unsecure(),
965
+ isOptional: true
966
+ },
967
+ completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
968
+ }
969
+ });
970
+ var RunCompletedEvent = defineEvent({
971
+ meta: {
972
+ key: "agent.run.completed",
973
+ version: "1.0.0",
974
+ description: "An agent run completed successfully.",
975
+ stability: "stable",
976
+ owners: [...OWNERS2],
977
+ tags: ["run", "completed"]
978
+ },
979
+ payload: RunCompletedPayload
980
+ });
981
+ var RunFailedPayload = defineSchemaModel3({
982
+ name: "RunFailedPayload",
983
+ description: "Payload for run failed event",
984
+ fields: {
985
+ runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
986
+ organizationId: {
987
+ type: ScalarTypeEnum3.String_unsecure(),
988
+ isOptional: false
989
+ },
990
+ agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
991
+ agentName: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
992
+ userId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
993
+ errorMessage: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
994
+ errorCode: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
995
+ totalTokens: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
996
+ totalIterations: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
997
+ durationMs: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: true },
998
+ failedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
999
+ }
1000
+ });
1001
+ var RunFailedEvent = defineEvent({
1002
+ meta: {
1003
+ key: "agent.run.failed",
1004
+ version: "1.0.0",
1005
+ description: "An agent run encountered an error.",
1006
+ stability: "stable",
1007
+ owners: [...OWNERS2],
1008
+ tags: ["run", "failed"]
1009
+ },
1010
+ payload: RunFailedPayload
1011
+ });
1012
+ var RunCancelledPayload = defineSchemaModel3({
1013
+ name: "RunCancelledPayload",
1014
+ description: "Payload for run cancelled event",
1015
+ fields: {
1016
+ runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1017
+ organizationId: {
1018
+ type: ScalarTypeEnum3.String_unsecure(),
1019
+ isOptional: false
1020
+ },
1021
+ agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1022
+ userId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1023
+ cancelledBy: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1024
+ reason: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1025
+ totalTokens: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
1026
+ totalIterations: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
1027
+ cancelledAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
1028
+ }
1029
+ });
1030
+ var RunCancelledEvent = defineEvent({
1031
+ meta: {
1032
+ key: "agent.run.cancelled",
1033
+ version: "1.0.0",
1034
+ description: "An agent run was cancelled by the user.",
1035
+ stability: "stable",
1036
+ owners: [...OWNERS2],
1037
+ tags: ["run", "cancelled"]
1038
+ },
1039
+ payload: RunCancelledPayload
1040
+ });
1041
+ var ToolInvokedPayload = defineSchemaModel3({
1042
+ name: "ToolInvokedPayload",
1043
+ description: "Payload for tool invoked event",
1044
+ fields: {
1045
+ runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1046
+ stepId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1047
+ toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1048
+ toolName: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1049
+ input: { type: ScalarTypeEnum3.JSONObject(), isOptional: false },
1050
+ invokedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
1051
+ }
1052
+ });
1053
+ var ToolInvokedEvent = defineEvent({
1054
+ meta: {
1055
+ key: "agent.run.toolInvoked",
1056
+ version: "1.0.0",
1057
+ description: "A tool was invoked during an agent run.",
1058
+ stability: "stable",
1059
+ owners: [...OWNERS2],
1060
+ tags: ["run", "tool", "invoked"]
1061
+ },
1062
+ payload: ToolInvokedPayload
1063
+ });
1064
+ var ToolCompletedPayload = defineSchemaModel3({
1065
+ name: "ToolCompletedPayload",
1066
+ description: "Payload for tool completed event",
1067
+ fields: {
1068
+ runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1069
+ stepId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1070
+ toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1071
+ toolName: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1072
+ success: { type: ScalarTypeEnum3.Boolean(), isOptional: false },
1073
+ output: { type: ScalarTypeEnum3.JSONObject(), isOptional: true },
1074
+ errorMessage: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1075
+ durationMs: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
1076
+ completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
1077
+ }
1078
+ });
1079
+ var ToolCompletedEvent = defineEvent({
1080
+ meta: {
1081
+ key: "agent.run.toolCompleted",
1082
+ version: "1.0.0",
1083
+ description: "A tool invocation completed during an agent run.",
1084
+ stability: "stable",
1085
+ owners: [...OWNERS2],
1086
+ tags: ["run", "tool", "completed"]
1087
+ },
1088
+ payload: ToolCompletedPayload
1089
+ });
1090
+ var MessageTypeEnum = defineEnum2("MessageType", ["assistant", "system"]);
1091
+ var MessageGeneratedPayload = defineSchemaModel3({
1092
+ name: "MessageGeneratedPayload",
1093
+ description: "Payload for message generated event",
1094
+ fields: {
1095
+ runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1096
+ stepId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1097
+ messageType: { type: MessageTypeEnum, isOptional: false },
1098
+ content: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1099
+ tokensUsed: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
1100
+ generatedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
1101
+ }
1102
+ });
1103
+ var MessageGeneratedEvent = defineEvent({
1104
+ meta: {
1105
+ key: "agent.run.messageGenerated",
1106
+ version: "1.0.0",
1107
+ description: "An agent generated a message during a run.",
1108
+ stability: "stable",
1109
+ owners: [...OWNERS2],
1110
+ tags: ["run", "message", "generated"]
1111
+ },
1112
+ payload: MessageGeneratedPayload
1113
+ });
1114
+
1115
+ // src/run/run.entity.ts
1116
+ import {
1117
+ defineEntity,
1118
+ defineEntityEnum,
1119
+ field,
1120
+ index
1121
+ } from "@contractspec/lib.schema";
1122
+ var RunStatusEntityEnum = defineEntityEnum({
1123
+ name: "RunStatus",
1124
+ values: [
1125
+ "QUEUED",
1126
+ "IN_PROGRESS",
1127
+ "COMPLETED",
1128
+ "FAILED",
1129
+ "CANCELLED",
1130
+ "EXPIRED"
1131
+ ],
1132
+ description: "Status of an agent run"
1133
+ });
1134
+ var RunStepTypeEntityEnum = defineEntityEnum({
1135
+ name: "RunStepType",
1136
+ values: ["MESSAGE_CREATION", "TOOL_CALL", "TOOL_RESULT", "ERROR"],
1137
+ description: "Type of run step"
1138
+ });
1139
+ var LogLevelEntityEnum = defineEntityEnum({
1140
+ name: "LogLevel",
1141
+ values: ["DEBUG", "INFO", "WARN", "ERROR"],
1142
+ description: "Log level"
1143
+ });
1144
+ var RunEntity = defineEntity({
1145
+ name: "Run",
1146
+ schema: "agent_console",
1147
+ description: "An execution of an agent with input/output and metrics.",
1148
+ fields: {
1149
+ id: field.id(),
1150
+ organizationId: field.string({ description: "Organization ID" }),
1151
+ agentId: field.foreignKey({ description: "Agent being executed" }),
1152
+ userId: field.string({
1153
+ isOptional: true,
1154
+ description: "User who initiated the run"
1155
+ }),
1156
+ sessionId: field.string({
1157
+ isOptional: true,
1158
+ description: "Conversation session ID"
1159
+ }),
1160
+ input: field.json({ description: "Input data for the run" }),
1161
+ output: field.json({
1162
+ isOptional: true,
1163
+ description: "Output result from the run"
1164
+ }),
1165
+ status: field.enum("RunStatus", { default: "QUEUED" }),
1166
+ errorMessage: field.string({
1167
+ isOptional: true,
1168
+ description: "Error message if failed"
1169
+ }),
1170
+ errorCode: field.string({
1171
+ isOptional: true,
1172
+ description: "Error code if failed"
1173
+ }),
1174
+ totalTokens: field.int({ default: 0, description: "Total tokens used" }),
1175
+ promptTokens: field.int({ default: 0, description: "Prompt tokens used" }),
1176
+ completionTokens: field.int({
1177
+ default: 0,
1178
+ description: "Completion tokens used"
1179
+ }),
1180
+ totalIterations: field.int({
1181
+ default: 0,
1182
+ description: "Number of iterations"
1183
+ }),
1184
+ durationMs: field.int({
1185
+ isOptional: true,
1186
+ description: "Execution duration in ms"
1187
+ }),
1188
+ estimatedCostUsd: field.float({
1189
+ isOptional: true,
1190
+ description: "Estimated cost in USD"
1191
+ }),
1192
+ queuedAt: field.dateTime({ description: "When run was queued" }),
1193
+ startedAt: field.dateTime({
1194
+ isOptional: true,
1195
+ description: "When run started executing"
1196
+ }),
1197
+ completedAt: field.dateTime({
1198
+ isOptional: true,
1199
+ description: "When run completed"
1200
+ }),
1201
+ metadata: field.json({
1202
+ isOptional: true,
1203
+ description: "Additional metadata"
1204
+ }),
1205
+ agent: field.belongsTo("Agent", ["agentId"], ["id"]),
1206
+ steps: field.hasMany("RunStep", { description: "Execution steps" }),
1207
+ logs: field.hasMany("RunLog", { description: "Execution logs" })
1208
+ },
1209
+ indexes: [
1210
+ index.on(["organizationId", "agentId", "queuedAt"]),
1211
+ index.on(["organizationId", "status"]),
1212
+ index.on(["agentId", "status"]),
1213
+ index.on(["sessionId"])
1214
+ ],
1215
+ enums: [RunStatusEntityEnum]
1216
+ });
1217
+ var RunStepEntity = defineEntity({
1218
+ name: "RunStep",
1219
+ schema: "agent_console",
1220
+ description: "An individual step in an agent run.",
1221
+ fields: {
1222
+ id: field.id(),
1223
+ runId: field.foreignKey({ description: "Parent run" }),
1224
+ stepNumber: field.int({ description: "Step sequence number" }),
1225
+ type: field.enum("RunStepType"),
1226
+ toolId: field.string({
1227
+ isOptional: true,
1228
+ description: "Tool used in this step"
1229
+ }),
1230
+ toolName: field.string({ isOptional: true, description: "Tool name" }),
1231
+ input: field.json({ isOptional: true, description: "Step input" }),
1232
+ output: field.json({ isOptional: true, description: "Step output" }),
1233
+ status: field.enum("RunStatus"),
1234
+ errorMessage: field.string({ isOptional: true }),
1235
+ tokensUsed: field.int({ default: 0 }),
1236
+ durationMs: field.int({ isOptional: true }),
1237
+ startedAt: field.dateTime(),
1238
+ completedAt: field.dateTime({ isOptional: true }),
1239
+ run: field.belongsTo("Run", ["runId"], ["id"])
1240
+ },
1241
+ indexes: [index.on(["runId", "stepNumber"])],
1242
+ enums: [RunStepTypeEntityEnum]
1243
+ });
1244
+ var RunLogEntity = defineEntity({
1245
+ name: "RunLog",
1246
+ schema: "agent_console",
1247
+ description: "A log entry for an agent run.",
1248
+ fields: {
1249
+ id: field.id(),
1250
+ runId: field.foreignKey({ description: "Parent run" }),
1251
+ stepId: field.string({ isOptional: true, description: "Related step" }),
1252
+ level: field.enum("LogLevel"),
1253
+ message: field.string({ description: "Log message" }),
1254
+ data: field.json({ isOptional: true, description: "Additional log data" }),
1255
+ source: field.string({
1256
+ isOptional: true,
1257
+ description: "Log source component"
1258
+ }),
1259
+ traceId: field.string({ isOptional: true }),
1260
+ spanId: field.string({ isOptional: true }),
1261
+ timestamp: field.dateTime(),
1262
+ run: field.belongsTo("Run", ["runId"], ["id"])
1263
+ },
1264
+ indexes: [index.on(["runId", "timestamp"]), index.on(["runId", "level"])],
1265
+ enums: [LogLevelEntityEnum]
1266
+ });
1267
+
1268
+ // src/run/run.presentation.ts
1269
+ import { StabilityEnum, definePresentation } from "@contractspec/lib.contracts";
1270
+ var RunListPresentation = definePresentation({
1271
+ meta: {
1272
+ key: "agent-console.run.list",
1273
+ version: "1.0.0",
1274
+ title: "Run List",
1275
+ description: "List view of agent runs with status, tokens, and duration info",
1276
+ goal: "Provide an overview of agent execution history and performance.",
1277
+ context: "Run history dashboard.",
1278
+ domain: "agent-console",
1279
+ owners: ["@agent-console-team"],
1280
+ tags: ["run", "list", "dashboard"],
1281
+ stability: StabilityEnum.Experimental
1282
+ },
1283
+ source: {
1284
+ type: "component",
1285
+ framework: "react",
1286
+ componentKey: "RunListView",
1287
+ props: RunSummaryModel
1288
+ },
1289
+ targets: ["react", "markdown", "application/json"],
1290
+ policy: { flags: ["agent-console.enabled"] }
1291
+ });
1292
+ var RunDetailPresentation = definePresentation({
1293
+ meta: {
1294
+ key: "agent-console.run.detail",
1295
+ version: "1.0.0",
1296
+ title: "Run Details",
1297
+ description: "Detailed view of an agent run with steps, logs, and metrics",
1298
+ goal: "Allow users to inspect and debug a specific agent run.",
1299
+ context: "Detailed view of an agent run.",
1300
+ domain: "agent-console",
1301
+ owners: ["@agent-console-team"],
1302
+ tags: ["run", "detail"],
1303
+ stability: StabilityEnum.Experimental
1304
+ },
1305
+ source: {
1306
+ type: "component",
1307
+ framework: "react",
1308
+ componentKey: "RunDetailView"
1309
+ },
1310
+ targets: ["react", "markdown"],
1311
+ policy: { flags: ["agent-console.enabled"] }
1312
+ });
1313
+ export {
1314
+ mockListRunsHandler,
1315
+ mockGetRunHandler,
1316
+ mockExecuteAgentHandler,
1317
+ mockCancelRunHandler,
1318
+ ToolInvokedEvent,
1319
+ ToolCompletedEvent,
1320
+ TimelineDataPointModel,
1321
+ RunSummaryModel,
1322
+ RunStepTypeEnum,
1323
+ RunStepTypeEntityEnum,
1324
+ RunStepModel,
1325
+ RunStepEntity,
1326
+ RunStatusEnum,
1327
+ RunStatusEntityEnum,
1328
+ RunStartedEvent,
1329
+ RunModel,
1330
+ RunLogModel,
1331
+ RunLogEntity,
1332
+ RunListPresentation,
1333
+ RunInputModel,
1334
+ RunFailedEvent,
1335
+ RunEntity,
1336
+ RunDetailPresentation,
1337
+ RunCompletedEvent,
1338
+ RunCancelledEvent,
1339
+ RunAgentRefModel,
1340
+ MessageGeneratedEvent,
1341
+ LogLevelEnum,
1342
+ LogLevelEntityEnum,
1343
+ ListRunsQuery,
1344
+ GranularityEnum,
1345
+ GetRunStepsQuery,
1346
+ GetRunQuery,
1347
+ GetRunMetricsQuery,
1348
+ GetRunLogsQuery,
1349
+ ExecuteAgentCommand,
1350
+ CancelRunCommand
1351
+ };