@makaio/framework 1.0.0-dev-1789168267790 → 1.0.0-dev-1789178369476

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 (497) hide show
  1. package/dist/.makaio-build.json +2 -2
  2. package/dist/{2020-DvDj4r_K.mjs → 2020-CRfgqanb.mjs} +1 -1
  3. package/dist/{account-identity-BdGGjBuZ.mjs → account-identity-C-v4mHq3.mjs} +1 -1
  4. package/dist/{adapter-BLivHuUi.mjs → adapter-C4v_gNTI.mjs} +1 -1
  5. package/dist/adapters/config/index.d.mts +1 -1
  6. package/dist/adapters/config/index.mjs +1 -1
  7. package/dist/adapters/index.d.mts +2 -2
  8. package/dist/adapters/index.mjs +1 -1
  9. package/dist/adapters/node.d.mts +1 -1
  10. package/dist/adapters/node.mjs +1 -1
  11. package/dist/artifact-DGxKwbHE.mjs +1 -0
  12. package/dist/{attempt-record-codec-BrungudT.mjs → attempt-record-codec-DaQ3WHUs.mjs} +1 -1
  13. package/dist/{auth-BIgwGHp-.mjs → auth-D9BQV8b_.mjs} +1 -1
  14. package/dist/authority-state-bootstrap-CV7HpB4v.mjs +1 -0
  15. package/dist/{automation-trigger-CQNQpzkA.mjs → automation-trigger-Bs-AAN1I.mjs} +1 -1
  16. package/dist/bus/index.d.mts +11 -15
  17. package/dist/bus/index.mjs +1 -1
  18. package/dist/bus-CyrTcF8F.mjs +9 -0
  19. package/dist/{caller-owned-adapter-stub-NiR7KT2N.mjs → caller-owned-adapter-stub-D8RZEdRn.mjs} +1 -1
  20. package/dist/{canonical-model-yXnm9QTn.mjs → canonical-model-RhhrFer9.mjs} +1 -1
  21. package/dist/{capabilities-CEwSeTB3.mjs → capabilities-cWI1WpCq.mjs} +1 -1
  22. package/dist/{client-BsY0rMlE.mjs → client-CgtNXGXg.mjs} +1 -1
  23. package/dist/clients/index.d.mts +1 -1
  24. package/dist/clients/index.mjs +1 -1
  25. package/dist/clients/managed-install.d.mts +1 -1
  26. package/dist/clients/managed-install.mjs +1 -1
  27. package/dist/code-execution/worker-entry.d.mts +1 -1
  28. package/dist/code-execution/worker-entry.mjs +1 -1
  29. package/dist/{code-execution-xn9-x3VO.mjs → code-execution-BspFbEdT.mjs} +1 -1
  30. package/dist/{code-execution-BhUo84eg.mjs → code-execution-D3kZBdY4.mjs} +1 -1
  31. package/dist/{code-execution-ByLSAlEg2.mjs → code-execution-pUF4IO462.mjs} +1 -1
  32. package/dist/common-BnDruIuW.mjs +1 -0
  33. package/dist/{compression-odwEUBWb.mjs → compression-CPrVeC42.mjs} +1 -1
  34. package/dist/{config-namespace-CE3KasJn.mjs → config-namespace-BpvgI5UF.mjs} +1 -1
  35. package/dist/contracts/adapter/index.d.mts +2 -2
  36. package/dist/contracts/adapter/index.mjs +1 -1
  37. package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
  38. package/dist/contracts/artifact/index.d.mts +3 -3
  39. package/dist/contracts/artifact/index.mjs +1 -1
  40. package/dist/contracts/auth/index.d.mts +2 -2
  41. package/dist/contracts/auth/index.mjs +1 -1
  42. package/dist/contracts/automation-trigger/index.d.mts +3 -3
  43. package/dist/contracts/automation-trigger/index.mjs +1 -1
  44. package/dist/contracts/canonical-model/index.d.mts +1 -1
  45. package/dist/contracts/canonical-model/index.mjs +1 -1
  46. package/dist/contracts/capabilities/index.d.mts +1 -1
  47. package/dist/contracts/capabilities/index.mjs +1 -1
  48. package/dist/contracts/client/index.d.mts +2 -2
  49. package/dist/contracts/client/index.mjs +1 -1
  50. package/dist/contracts/code-execution/index.d.mts +1 -1
  51. package/dist/contracts/code-execution/index.mjs +1 -1
  52. package/dist/contracts/common/index.d.mts +1 -1
  53. package/dist/contracts/common/index.mjs +1 -1
  54. package/dist/contracts/config/index.d.mts +1 -1
  55. package/dist/contracts/config/index.mjs +1 -1
  56. package/dist/contracts/extension/index.d.mts +5 -5
  57. package/dist/contracts/extension/index.mjs +1 -1
  58. package/dist/contracts/facet/index.d.mts +1 -1
  59. package/dist/contracts/facet/index.mjs +1 -1
  60. package/dist/contracts/harness/index.d.mts +1 -1
  61. package/dist/contracts/harness/index.mjs +1 -1
  62. package/dist/contracts/host/index.d.mts +1 -1
  63. package/dist/contracts/host/index.mjs +1 -1
  64. package/dist/contracts/index.d.mts +65 -53
  65. package/dist/contracts/index.mjs +1 -1
  66. package/dist/contracts/materialization/index.d.mts +2 -2
  67. package/dist/contracts/materialization/index.mjs +1 -1
  68. package/dist/contracts/model-registry/index.d.mts +1 -1
  69. package/dist/contracts/model-registry/index.mjs +1 -1
  70. package/dist/contracts/native-session-supervisor/index.d.mts +1 -1
  71. package/dist/contracts/native-session-supervisor/index.mjs +1 -1
  72. package/dist/contracts/platform/index.d.mts +1 -1
  73. package/dist/contracts/platform/index.mjs +1 -1
  74. package/dist/contracts/provider/index.d.mts +2 -2
  75. package/dist/contracts/provider/index.mjs +1 -1
  76. package/dist/contracts/reaction/index.d.mts +1 -1
  77. package/dist/contracts/reaction/index.mjs +1 -1
  78. package/dist/contracts/session/index.d.mts +2 -2
  79. package/dist/contracts/session/index.mjs +1 -1
  80. package/dist/contracts/shared/index.d.mts +2 -2
  81. package/dist/contracts/shared/index.mjs +1 -1
  82. package/dist/contracts/skill/index.d.mts +1 -1
  83. package/dist/contracts/skill/index.mjs +1 -1
  84. package/dist/contracts/telemetry/index.d.mts +1 -1
  85. package/dist/contracts/telemetry/index.mjs +1 -1
  86. package/dist/contracts/timeout/index.d.mts +1 -1
  87. package/dist/contracts/timeout/index.mjs +1 -1
  88. package/dist/contracts/toast/index.mjs +1 -1
  89. package/dist/contracts/variant/index.d.mts +1 -1
  90. package/dist/contracts/variant/index.mjs +1 -1
  91. package/dist/contracts/worker/index.d.mts +2 -2
  92. package/dist/contracts/worker/index.mjs +1 -1
  93. package/dist/contracts/workflow/index.d.mts +2 -2
  94. package/dist/contracts/workflow/index.mjs +1 -1
  95. package/dist/{contribution-Cdz5WTYk.d.mts → contribution-DDbHzCPF.d.mts} +2 -2
  96. package/dist/{definition-DQNFO-Qz.d.mts → definition-CuaBQyde.d.mts} +1 -1
  97. package/dist/{definition-o5Dfg5j-.mjs → definition-Dd7bDWpP.mjs} +1 -1
  98. package/dist/{detached-extension-handle-BNvRSUVO.mjs → detached-extension-handle-DN3aqLyq.mjs} +1 -1
  99. package/dist/{dist-DMIaE8sg.mjs → dist-onY7e-pd.mjs} +1 -1
  100. package/dist/{execution-attempt-owner-recovery-D4APLAvt.mjs → execution-attempt-owner-recovery-CE_rvHKE.mjs} +1 -1
  101. package/dist/{execution-target-Ba7b_UmX.mjs → execution-target-CDeIBu4b.mjs} +1 -1
  102. package/dist/{extension-D9D8tJQY.mjs → extension-CnNcY1hR.mjs} +1 -1
  103. package/dist/{extension-DYBu49NH.mjs → extension-D8uLQSDc.mjs} +1 -1
  104. package/dist/{filesystem-service-hdz3oYti.mjs → filesystem-service-ClZEAw7E.mjs} +1 -1
  105. package/dist/{framework-packages-DdCJ4JsE.mjs → framework-packages-CCIReKIe.mjs} +1 -1
  106. package/dist/git/index.mjs +1 -1
  107. package/dist/{globby-Begk3aIP.mjs → globby-CxGKRBGC.mjs} +1 -1
  108. package/dist/{handlers-CqL2TWbk.mjs → handlers-mjky_fP2.mjs} +1 -1
  109. package/dist/{harness-CYzkReGi.mjs → harness-DBxywOGi.mjs} +1 -1
  110. package/dist/{hook-responses-DVjMuGh9.d.mts → hook-responses-Dq16X3Cb.d.mts} +1 -1
  111. package/dist/{index-Bp8ZljrJ.d.mts → index-B3fuld9X.d.mts} +13 -13
  112. package/dist/{index-OLGGmjgd.d.mts → index-B4pPwpKk.d.mts} +1 -1
  113. package/dist/{index-CjOJLtH7.d.mts → index-BqtdO-uk.d.mts} +20 -20
  114. package/dist/{index-BTwMms1p.d.mts → index-C1nSuiG0.d.mts} +1 -1
  115. package/dist/{index-BgKU1PuR2.d.mts → index-C87P0WpY2.d.mts} +1 -1
  116. package/dist/{index-DUdGqxHD.d.mts → index-CIzvBH8O.d.mts} +1 -1
  117. package/dist/{index-DPBh4QNY.d.mts → index-CdgRoaey.d.mts} +41 -41
  118. package/dist/{index-ZBm6F5_h.d.mts → index-D0xS-mYt.d.mts} +7 -7
  119. package/dist/{index-DnZksNTM.d.mts → index-DQKVQPUS.d.mts} +1 -1
  120. package/dist/{index-DUH2eTyC.d.mts → index-DWANFpTG.d.mts} +1 -1
  121. package/dist/{index-BZrlHkpM2.d.mts → index-De_oh9M-2.d.mts} +1 -1
  122. package/dist/{index-DS1mI9GP.d.mts → index-Dm3d490n.d.mts} +1 -1
  123. package/dist/{index-LRAmVQLj.d.mts → index-DtCVHx8-.d.mts} +1 -1
  124. package/dist/{index-Cp9olTr7.d.mts → index-Du4wUv9q.d.mts} +2 -2
  125. package/dist/{index-D__FyAg62.d.mts → index-DyVXhEBC2.d.mts} +7 -7
  126. package/dist/{index-qal7TzGP2.d.mts → index-GFf4oKBg2.d.mts} +3 -3
  127. package/dist/{index-BXair-QK.d.mts → index-U--ajOHy.d.mts} +1 -1
  128. package/dist/{index-DOVT8mU7.d.mts → index-a_peDAyG.d.mts} +421 -64
  129. package/dist/{index-kC3LKZYJ.d.mts → index-gu4mzfTr.d.mts} +3 -3
  130. package/dist/{index-D6_5slJp.d.mts → index-oxZt93RL.d.mts} +2 -2
  131. package/dist/{index-CTNGL-cq2.d.mts → index-zmDRR8gv2.d.mts} +1 -1
  132. package/dist/json-tree-Cmb_BzHr.mjs +1 -0
  133. package/dist/kernel/cli/index.d.mts +2 -2
  134. package/dist/kernel/cli/index.mjs +1 -1
  135. package/dist/kernel/cli/register.d.mts +1 -1
  136. package/dist/kernel/cli/register.mjs +1 -1
  137. package/dist/kernel/cli/schemas.mjs +1 -1
  138. package/dist/kernel/extension/index.d.mts +1 -1
  139. package/dist/kernel/extension/index.mjs +1 -1
  140. package/dist/kernel/index.d.mts +5 -5
  141. package/dist/kernel/index.mjs +1 -1
  142. package/dist/kernel/namespace/index.d.mts +1 -1
  143. package/dist/kernel/namespace/index.mjs +1 -1
  144. package/dist/kernel/observability/index.d.mts +1 -1
  145. package/dist/kernel/observability/index.mjs +1 -1
  146. package/dist/kernel/providers/index.d.mts +1 -1
  147. package/dist/kernel/providers/index.mjs +1 -1
  148. package/dist/kernel/window/index.d.mts +1 -1
  149. package/dist/kernel/window/index.mjs +1 -1
  150. package/dist/kind-registration-BcNuwXPC.mjs +1 -0
  151. package/dist/{lib-D1-cvcTz.mjs → lib-BF5XBSfw.mjs} +1 -1
  152. package/dist/{lib-B1Mvm4hQ.mjs → lib-Dljw2Cqh.mjs} +1 -1
  153. package/dist/{load-extensions-bwisKaW0.mjs → load-extensions-BVgxTj_y.mjs} +1 -1
  154. package/dist/{load-extensions-D6SVKBPw.d.mts → load-extensions-DGstT4_p.d.mts} +1 -1
  155. package/dist/{materialization-DRr6CSXV.mjs → materialization-kP_vEXV3.mjs} +1 -1
  156. package/dist/mcp-http-server/index.mjs +1 -1
  157. package/dist/model-BPKGygMv.mjs +1 -0
  158. package/dist/namespace-BPf6AbBO.mjs +1 -0
  159. package/dist/{namespace-CD9mJGhU.mjs → namespace-CMntzAPI.mjs} +1 -1
  160. package/dist/{native-session-supervisor-i3PeijHn.mjs → native-session-supervisor-DtuN1Dgs.mjs} +1 -1
  161. package/dist/node/bus-server/index.d.mts +1 -1
  162. package/dist/node/bus-server/index.mjs +1 -1
  163. package/dist/node/bus-server/server-lifecycle.d.mts +1 -1
  164. package/dist/node/bus-server/server-lifecycle.mjs +1 -1
  165. package/dist/{orchestrator-shared-DMldWEah.mjs → orchestrator-shared-CtPB6PAr.mjs} +1 -1
  166. package/dist/{ownership-memory-handler-LXaweX6V.mjs → ownership-memory-handler-xex7sLiX.mjs} +1 -1
  167. package/dist/{package-BFto8lbP.mjs → package-BSz4hbav.mjs} +1 -1
  168. package/dist/{package-tvzH3A0x.mjs → package-Bn4iwDm3.mjs} +1 -1
  169. package/dist/{package-CnR_tOsW.d.mts → package-DdymauE9.d.mts} +1 -1
  170. package/dist/package.json +1 -1
  171. package/dist/{profile-Cjq4QnUQ.mjs → profile-1fvMljlJ.mjs} +1 -1
  172. package/dist/{provider-context-CYUUoI6x.mjs → provider-context-D6GIZ5DC.mjs} +1 -1
  173. package/dist/{provider-context-BpabfMlj.mjs → provider-context-DFTB8rsU.mjs} +1 -1
  174. package/dist/{reaction-Cev6JNcb.mjs → reaction-C8WbJqLk.mjs} +1 -1
  175. package/dist/{resolved-XQTiHgrA.mjs → resolved-BAbiCSV4.mjs} +1 -1
  176. package/dist/rules/index.d.mts +1 -1
  177. package/dist/rules/index.mjs +1 -1
  178. package/dist/rules/schemas.d.mts +1 -1
  179. package/dist/runtime-bun/index.mjs +1 -1
  180. package/dist/runtime-node/code-execution/index.d.mts +2 -2
  181. package/dist/runtime-node/code-execution/index.mjs +1 -1
  182. package/dist/runtime-node/extension-discovery.d.mts +1 -1
  183. package/dist/runtime-node/extension-validation.d.mts +1 -1
  184. package/dist/runtime-node/extension-validation.mjs +1 -1
  185. package/dist/runtime-node/index.d.mts +5 -5
  186. package/dist/runtime-node/index.mjs +2 -2
  187. package/dist/runtime-node/makaio-config.d.mts +1 -1
  188. package/dist/runtime-node/makaio-config.mjs +1 -1
  189. package/dist/runtime-node/workflow-worker/index.d.mts +1 -1
  190. package/dist/runtime-node/workflow-worker/index.mjs +1 -1
  191. package/dist/runtime-node/workflow-worker/worker-entry.mjs +1 -1
  192. package/dist/{schema-BVbkNHVQ.mjs → schema-Cz6-4_Dn.mjs} +1 -1
  193. package/dist/{schemas-CXCdmM5K.d.mts → schemas-CKVm28Oy.d.mts} +12 -1
  194. package/dist/{schemas-D0ZZdGmV.d.mts → schemas-CPNdGMLf.d.mts} +4 -4
  195. package/dist/{schemas-D9_OPuLB.mjs → schemas-ClkcU_N5.mjs} +1 -1
  196. package/dist/{schemas-pBrUJEN6.mjs → schemas-D-i0IAtA.mjs} +1 -1
  197. package/dist/schemas-rlb0IQ-G.mjs +1 -0
  198. package/dist/{selection-D7V0wyHX.mjs → selection-DLN6l5iK.mjs} +1 -1
  199. package/dist/services/adapter-runtime/index.d.mts +3 -3
  200. package/dist/services/adapter-runtime/index.mjs +1 -1
  201. package/dist/services/adapter-runtime/namespace.d.mts +1 -1
  202. package/dist/services/adapter-runtime/schemas.d.mts +1 -1
  203. package/dist/services/adapter-subsystem/index.d.mts +3 -3
  204. package/dist/services/adapter-subsystem/index.mjs +1 -1
  205. package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
  206. package/dist/services/adapter-subsystem/namespace.mjs +1 -1
  207. package/dist/services/agent-runtime/index.d.mts +2 -2
  208. package/dist/services/agent-runtime/namespace.d.mts +1 -1
  209. package/dist/services/agent-runtime/schemas.d.mts +1 -1
  210. package/dist/services/automation-trigger/index.mjs +1 -1
  211. package/dist/services/capability/index.d.mts +2 -2
  212. package/dist/services/capability/index.mjs +1 -1
  213. package/dist/services/code-execution/index.d.mts +1 -1
  214. package/dist/services/code-execution/index.mjs +1 -1
  215. package/dist/services/codebase/index.d.mts +2 -2
  216. package/dist/services/codebase/namespace.d.mts +1 -1
  217. package/dist/services/codebase/schemas.d.mts +1 -1
  218. package/dist/services/compression/index.d.mts +2 -2
  219. package/dist/services/compression/namespace.d.mts +1 -1
  220. package/dist/services/compression/schemas.d.mts +1 -1
  221. package/dist/services/context-rules/index.d.mts +1 -1
  222. package/dist/services/context-rules/index.mjs +1 -1
  223. package/dist/services/execution-target/index.d.mts +3 -3
  224. package/dist/services/execution-target/index.mjs +1 -1
  225. package/dist/services/execution-target/namespace.d.mts +1 -1
  226. package/dist/services/execution-target/namespace.mjs +1 -1
  227. package/dist/services/execution-target/schemas.d.mts +1 -1
  228. package/dist/services/execution-target/schemas.mjs +1 -1
  229. package/dist/services/filesystem/index.d.mts +1 -1
  230. package/dist/services/filesystem/index.mjs +1 -1
  231. package/dist/services/git/namespace.mjs +1 -1
  232. package/dist/services/git/schemas.mjs +1 -1
  233. package/dist/services/harness/index.mjs +1 -1
  234. package/dist/services/index.d.mts +41 -41
  235. package/dist/services/index.mjs +1 -1
  236. package/dist/services/log-import/browser.d.mts +2 -2
  237. package/dist/services/log-import/index.d.mts +2 -2
  238. package/dist/services/log-import/log-import.d.mts +1 -1
  239. package/dist/services/log-import/log-import.mjs +1 -1
  240. package/dist/services/log-import/namespace.mjs +1 -1
  241. package/dist/services/log-import/schemas.mjs +1 -1
  242. package/dist/services/materialization/index.d.mts +1 -1
  243. package/dist/services/materialization/index.mjs +1 -1
  244. package/dist/services/model-registry/index.d.mts +1 -1
  245. package/dist/services/model-registry/index.mjs +1 -1
  246. package/dist/services/preferences/index.d.mts +2 -2
  247. package/dist/services/preferences/schemas.d.mts +1 -1
  248. package/dist/services/preferences/storage-namespace.d.mts +2 -2
  249. package/dist/services/provider-context/index.d.mts +1 -1
  250. package/dist/services/provider-context/index.mjs +1 -1
  251. package/dist/services/provider-runtime/index.mjs +1 -1
  252. package/dist/services/session/handlers/index.d.mts +1 -1
  253. package/dist/services/session/handlers/index.mjs +1 -1
  254. package/dist/services/session/index.d.mts +9 -9
  255. package/dist/services/session/index.mjs +1 -1
  256. package/dist/services/session/messages/namespace.d.mts +1 -1
  257. package/dist/services/session/messages/namespace.mjs +1 -1
  258. package/dist/services/session/orchestrator-testing/index.d.mts +1 -1
  259. package/dist/services/session/orchestrator-testing/index.mjs +1 -1
  260. package/dist/services/session/session-events/namespace.d.mts +1 -1
  261. package/dist/services/session/session-events/namespace.mjs +1 -1
  262. package/dist/services/session/storage/namespace.d.mts +1 -1
  263. package/dist/services/session/storage/schema.d.mts +1 -1
  264. package/dist/services/session/testing/index.mjs +1 -1
  265. package/dist/services/session/testing/orchestrator-shared.d.mts +1 -1
  266. package/dist/services/session/testing/orchestrator-shared.mjs +1 -1
  267. package/dist/services/session/turns/namespace.d.mts +1 -1
  268. package/dist/services/session/turns/namespace.mjs +1 -1
  269. package/dist/services/session-editor/index.d.mts +1 -1
  270. package/dist/services/session-editor/index.mjs +1 -1
  271. package/dist/services/settings/index.d.mts +3 -3
  272. package/dist/services/settings/index.mjs +1 -1
  273. package/dist/services/settings/namespace.d.mts +4 -4
  274. package/dist/services/settings/namespace.mjs +1 -1
  275. package/dist/services/settings/storage/clients-namespace.d.mts +1 -1
  276. package/dist/services/settings/storage/clients-namespace.mjs +1 -1
  277. package/dist/services/settings/storage/index.d.mts +3 -3
  278. package/dist/services/settings/storage/index.mjs +1 -1
  279. package/dist/services/settings/storage/providers-namespace.d.mts +1 -1
  280. package/dist/services/settings/storage/providers-namespace.mjs +1 -1
  281. package/dist/services/subagent/index.d.mts +1 -1
  282. package/dist/services/subagent/index.mjs +1 -1
  283. package/dist/services/subagent-template/index.d.mts +2 -2
  284. package/dist/services/subagent-template/namespace.d.mts +1 -1
  285. package/dist/services/subagent-template/schemas.d.mts +1 -1
  286. package/dist/services/tool-approval/index.d.mts +1 -1
  287. package/dist/services/tool-approval/index.mjs +1 -1
  288. package/dist/services/tools/index.d.mts +1 -1
  289. package/dist/services/tools/index.mjs +1 -1
  290. package/dist/services/tray-menu/index.d.mts +3 -3
  291. package/dist/services/tray-menu/index.mjs +1 -1
  292. package/dist/services/tray-menu/namespace.d.mts +1 -1
  293. package/dist/services/tray-menu/schemas.d.mts +1 -1
  294. package/dist/services/turn/index.d.mts +1 -1
  295. package/dist/services/turn/namespace.d.mts +1 -1
  296. package/dist/services/workflow-transitions/index.d.mts +1 -1
  297. package/dist/services/workflow-transitions/index.mjs +1 -1
  298. package/dist/{session-CAKfa5o8.mjs → session-6UG5udTX.mjs} +1 -1
  299. package/dist/{session-BsQst2fC.mjs → session-BB0s7c2B.mjs} +1 -1
  300. package/dist/shared-Gb3kTtHs.mjs +1 -0
  301. package/dist/{skill-91kZNQnF.mjs → skill-B0jSQDvb.mjs} +1 -1
  302. package/dist/{src-BZdlyUxT.mjs → src-CbAw9kjJ.mjs} +1 -1
  303. package/dist/storage/drizzle/client.d.mts +1 -1
  304. package/dist/storage/drizzle/client.mjs +1 -1
  305. package/dist/storage/drizzle/index.d.mts +1 -1
  306. package/dist/storage/drizzle/index.mjs +1 -1
  307. package/dist/storage/handlers/drizzle/index.d.mts +1 -1
  308. package/dist/storage/handlers/drizzle/index.mjs +1 -1
  309. package/dist/storage/handlers/index.d.mts +1 -1
  310. package/dist/storage/handlers/index.mjs +1 -1
  311. package/dist/{tool-approval-service-BV3WxxX6.mjs → tool-approval-service-pbkGcAV8.mjs} +1 -1
  312. package/dist/{tools-CElCajoS.mjs → tools-Dj_ImUQ8.mjs} +1 -1
  313. package/dist/{transition-B8XDvfD7.d.mts → transition-B-YmSK-s.d.mts} +2 -2
  314. package/dist/{types-6PHSlnbx.d.mts → types-7QB81mzR.d.mts} +3 -3
  315. package/dist/{types-DafDuOcH2.d.mts → types-CjYcHDPo2.d.mts} +1 -1
  316. package/dist/ui-kernel/index.d.mts +1 -1
  317. package/dist/ui-kernel/pages/schemas.d.mts +1 -1
  318. package/dist/{version-DdGhNoY5.mjs → version-PuU2KG3I.mjs} +1 -1
  319. package/dist/{view-builder--qgYM35J.d.mts → view-builder-BUZoNyEQ.d.mts} +1 -1
  320. package/dist/{visibility-cMXbf9nY.mjs → visibility-DCcfB817.mjs} +1 -1
  321. package/dist/{worker-B0xwfo9-.mjs → worker-Cgql5Xsm.mjs} +1 -1
  322. package/dist/{worker-Bw2UYlVO.mjs → worker-DWEma08Q.mjs} +1 -1
  323. package/dist/{workflow-pOvprFKW.mjs → workflow-DA2yJJK-.mjs} +1 -1
  324. package/dist/workflow-engine/execution-attempt-repository.d.mts +1 -1
  325. package/dist/workflow-engine/execution-attempt-repository.mjs +1 -1
  326. package/dist/workflow-engine/index.d.mts +25 -25
  327. package/dist/workflow-engine/index.mjs +1 -1
  328. package/dist/workflow-engine/package.d.mts +1 -1
  329. package/dist/workflow-engine/package.mjs +1 -1
  330. package/dist/workflow-engine/provider-operation.d.mts +1 -1
  331. package/dist/workflow-engine/testing/conformance.d.mts +1 -1
  332. package/dist/workflow-engine/testing/conformance.mjs +1 -1
  333. package/dist/workflow-engine/testing/index.d.mts +1 -1
  334. package/dist/workflow-engine/testing/index.mjs +1 -1
  335. package/dist/workflow-engine/testing/sqlite.d.mts +1 -1
  336. package/dist/workflow-engine/testing/sqlite.mjs +1 -1
  337. package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
  338. package/dist/{workflow-transitions-DH246j6E.mjs → workflow-transitions-t6jn_pR_.mjs} +1 -1
  339. package/dist/{workflow-worker-BDA-E_pm.mjs → workflow-worker-C3ZbuhyA.mjs} +1 -1
  340. package/package.json +1 -1
  341. package/dist/artifact-BGy1hXuP.mjs +0 -1
  342. package/dist/authority-state-bootstrap-DVFYemDL.mjs +0 -1
  343. package/dist/bus-KqRHrusX.mjs +0 -9
  344. package/dist/common-Bta2ivrd.mjs +0 -1
  345. package/dist/kind-registration-CyMf-vey.mjs +0 -1
  346. package/dist/model-Dya0clsM.mjs +0 -1
  347. package/dist/namespace-D53UGrP6.mjs +0 -1
  348. package/dist/schemas-BhkprYU1.mjs +0 -1
  349. package/dist/shared-m6jgT2a3.mjs +0 -1
  350. /package/dist/{adapter-auth-runtime-46Y9WKcB.mjs → adapter-auth-runtime-B6yX_QfG.mjs} +0 -0
  351. /package/dist/{adapter-binding-CZTWlcp9.d.mts → adapter-binding-BxjUfkOn.d.mts} +0 -0
  352. /package/dist/{ajv-Dz-0DD7m.mjs → ajv-Cvnmw2yn.mjs} +0 -0
  353. /package/dist/{attach-error-D5BWfaBO.mjs → attach-error-wNJ8Q5uU.mjs} +0 -0
  354. /package/dist/{attempt-control-evidence-BKw1U3wL.mjs → attempt-control-evidence-7lwRG73Y.mjs} +0 -0
  355. /package/dist/{attempt-fixtures-B8FSy_vs.mjs → attempt-fixtures-DHdYmr3o.mjs} +0 -0
  356. /package/dist/{base-orchestrator-C5Z9Aowq.d.mts → base-orchestrator-CrXiMJzf.d.mts} +0 -0
  357. /package/dist/{bootstrap-start-client-D7t7d9ty.mjs → bootstrap-start-client-C1ZHbv6e.mjs} +0 -0
  358. /package/dist/{capability-BnQx1BWc.mjs → capability-DXHYfKK0.mjs} +0 -0
  359. /package/dist/{capability-service-DX3wLjdt.d.mts → capability-service-CQ1aw_p-.d.mts} +0 -0
  360. /package/dist/{client-BsXMxeCN.d.mts → client-ByjHcS78.d.mts} +0 -0
  361. /package/dist/{client-binary-version-verifier-uMFQoKZj.d.mts → client-binary-version-verifier-C4fEAUdo.d.mts} +0 -0
  362. /package/dist/{client-binary-version-verifier-DLziUQhw.mjs → client-binary-version-verifier-DcHCFmsI.mjs} +0 -0
  363. /package/dist/{clients-namespace-1hXA6qNd.d.mts → clients-namespace-D4BxF2Nw.d.mts} +0 -0
  364. /package/dist/{config-namespace-Bpq9WOY4.d.mts → config-namespace-B1zyOYwH.d.mts} +0 -0
  365. /package/dist/{create-static-mount-Cr24q94C.mjs → create-static-mount-Dgxgi4W3.mjs} +0 -0
  366. /package/dist/{cross-spawn-Bi05YtQQ.mjs → cross-spawn-BMCAyqrN.mjs} +0 -0
  367. /package/dist/{cursor-storage-88xtgVAd.mjs → cursor-storage-BvjxwBW6.mjs} +0 -0
  368. /package/dist/{definition-Ckt_WmJw.d.mts → definition-ClWxAKQ2.d.mts} +0 -0
  369. /package/dist/{definitions-CyFaNG_c.mjs → definitions-Do7bP-u7.mjs} +0 -0
  370. /package/dist/{descriptor-to-package-GVZk9ZGT.mjs → descriptor-to-package-Dw8dnl5E.mjs} +0 -0
  371. /package/dist/{drizzle-BrlzkYoe.mjs → drizzle-_w6sUR8p.mjs} +0 -0
  372. /package/dist/{esm-B3t30-13.mjs → esm-Ccx-3z8E.mjs} +0 -0
  373. /package/dist/{event-DFI0F1Ws.mjs → event-D5_UaIBZ.mjs} +0 -0
  374. /package/dist/{execution-attempt-repository-BoNwNybg.d.mts → execution-attempt-repository-BUah8hma.d.mts} +0 -0
  375. /package/dist/{execution-attempt-repository-CWbgCTwA.mjs → execution-attempt-repository-aabFKcXN.mjs} +0 -0
  376. /package/dist/{extension-context-BGNUn34r.d.mts → extension-context-BH31eOMv.d.mts} +0 -0
  377. /package/dist/{extension-discovery-Dx118u_N.d.mts → extension-discovery-CA2IhDRo.d.mts} +0 -0
  378. /package/dist/{extension-namespace-AaHKv6tQ.mjs → extension-namespace-Ct9L6SKr.mjs} +0 -0
  379. /package/dist/{extension-package-provenance-Dr7JXjLS.mjs → extension-package-provenance-C7oO5JAE.mjs} +0 -0
  380. /package/dist/{facet-De-2AP_o.mjs → facet-DE2NhSjl.mjs} +0 -0
  381. /package/dist/{filesystem-service-DtApanQk.d.mts → filesystem-service-CDYoiwWY.d.mts} +0 -0
  382. /package/dist/{handler-CFT7_osu.mjs → handler-Cc1MhaR4.mjs} +0 -0
  383. /package/dist/{host-CbaJg6D4.mjs → host-efiCv7-R.mjs} +0 -0
  384. /package/dist/{identity-B6RqbCn7.mjs → identity-DgTjgflr.mjs} +0 -0
  385. /package/dist/{index-DqS8eCAT.d.mts → index-B78CRVi9.d.mts} +0 -0
  386. /package/dist/{index-BNgNBDuW2.d.mts → index-B8v1-2-V2.d.mts} +0 -0
  387. /package/dist/{index-1AKlC3kZ.d.mts → index-BCU5oByg.d.mts} +0 -0
  388. /package/dist/{index-CIl66QhT.d.mts → index-BFS-2kcS.d.mts} +0 -0
  389. /package/dist/{index-Dv5aNxoa.d.mts → index-BGnQ0EyD.d.mts} +0 -0
  390. /package/dist/{index-qLkIGcgv2.d.mts → index-BPNfYEA22.d.mts} +0 -0
  391. /package/dist/{index-B4lidHiL.d.mts → index-BZoOYV-y.d.mts} +0 -0
  392. /package/dist/{index-C3n8beRR.d.mts → index-BbkcbY6d.d.mts} +0 -0
  393. /package/dist/{index-B7VWSBm72.d.mts → index-C6e9cwAl2.d.mts} +0 -0
  394. /package/dist/{index-DSRxn5Zr2.d.mts → index-CVRT01082.d.mts} +0 -0
  395. /package/dist/{index-C0zo4Id_.d.mts → index-CjDQn6lw.d.mts} +0 -0
  396. /package/dist/{index-CUcEfh31.d.mts → index-D6liU_KS.d.mts} +0 -0
  397. /package/dist/{index-DLsopffG.d.mts → index-D6p17KPs.d.mts} +0 -0
  398. /package/dist/{index-DxxORQny.d.mts → index-D8ELwT5y.d.mts} +0 -0
  399. /package/dist/{index-5KVPGsig.d.mts → index-DAaQ--ki.d.mts} +0 -0
  400. /package/dist/{index-DK8lSIvY.d.mts → index-DM72_93s.d.mts} +0 -0
  401. /package/dist/{index-Dfv9hyZE.d.mts → index-DXQTkwLB.d.mts} +0 -0
  402. /package/dist/{index-DNN9jOVO.d.mts → index-DdVpWkaI.d.mts} +0 -0
  403. /package/dist/{index-C86rKLPD.d.mts → index-DfU8s_xP.d.mts} +0 -0
  404. /package/dist/{index-CrDp6vHG.d.mts → index-DiZ4LmyE.d.mts} +0 -0
  405. /package/dist/{index-CzKJC3Bt.d.mts → index-DjSUOMlr.d.mts} +0 -0
  406. /package/dist/{index-DO0QO0ux2.d.mts → index-DmX9W3xH2.d.mts} +0 -0
  407. /package/dist/{index-lLuIAmRB.d.mts → index-F7cVpFJ9.d.mts} +0 -0
  408. /package/dist/{index-DtlZ4hw62.d.mts → index-HMb0RcTG2.d.mts} +0 -0
  409. /package/dist/{index-D4FE3jHM2.d.mts → index-Htfr-K5U2.d.mts} +0 -0
  410. /package/dist/{index-tCFckLG6.d.mts → index-KdlZRuTp.d.mts} +0 -0
  411. /package/dist/{index-yapYXeah.d.mts → index-T-aAKybB.d.mts} +0 -0
  412. /package/dist/{index-Bw7benCh.d.mts → index-gAyARaKS.d.mts} +0 -0
  413. /package/dist/{index-fpGFhEmI.d.mts → index-nkix3hP7.d.mts} +0 -0
  414. /package/dist/{index-DyBuGOvY.d.mts → index-tbjIqwa3.d.mts} +0 -0
  415. /package/dist/{json-value-DyMQrwGz.d.mts → json-value-Ymw2f8i_.d.mts} +0 -0
  416. /package/dist/{jsonl-transport-D4ch0vsf.mjs → jsonl-transport-Bg033Ng0.mjs} +0 -0
  417. /package/dist/{lib-BLdnqIFF.mjs → lib-BizqbepU.mjs} +0 -0
  418. /package/dist/{model-registry-CAqJYbXg.mjs → model-registry-CeDu27XL.mjs} +0 -0
  419. /package/dist/{model-registry-DVTFd0RF.mjs → model-registry-Cmregilq.mjs} +0 -0
  420. /package/dist/{modes-Dc9_sSbr.mjs → modes-DpHQos5B.mjs} +0 -0
  421. /package/dist/{namespace-CYYFqmtJ.d.mts → namespace-B5IFLQc-.d.mts} +0 -0
  422. /package/dist/{namespace-C-4xI2rm.d.mts → namespace-BCVKdu-U.d.mts} +0 -0
  423. /package/dist/{namespace-0TfAY2J7.mjs → namespace-BMdYJN_t.mjs} +0 -0
  424. /package/dist/{namespace-BZ7UQmW4.mjs → namespace-Bjr04AUK.mjs} +0 -0
  425. /package/dist/{namespace-BnNBM94X.mjs → namespace-Bo6-o_rW.mjs} +0 -0
  426. /package/dist/{namespace-E4ajXk0W.d.mts → namespace-C1pPZKtI.d.mts} +0 -0
  427. /package/dist/{namespace-CDoyzyV4.mjs → namespace-C9xmGXbW.mjs} +0 -0
  428. /package/dist/{namespace-Dwf7aOLt.d.mts → namespace-COHHDh2I.d.mts} +0 -0
  429. /package/dist/{namespace-CjFT0wBT.d.mts → namespace-CPGTaFqO.d.mts} +0 -0
  430. /package/dist/{namespace-CZJQrexB.d.mts → namespace-C_tttgJ8.d.mts} +0 -0
  431. /package/dist/{namespace-CvCk6Y9i.d.mts → namespace-Cmu-5_P9.d.mts} +0 -0
  432. /package/dist/{namespace-DGi7tw_W.mjs → namespace-CnRQ8tCJ.mjs} +0 -0
  433. /package/dist/{namespace-DXrdGpbs.d.mts → namespace-CvK86QFk.d.mts} +0 -0
  434. /package/dist/{namespace-Bivbsfms.d.mts → namespace-DM5vykb7.d.mts} +0 -0
  435. /package/dist/{namespace-KYIbWPvl.mjs → namespace-J87EeVTm.mjs} +0 -0
  436. /package/dist/{namespace-BYBMtQUy.d.mts → namespace-LSHmxtMn.d.mts} +0 -0
  437. /package/dist/{namespace-CfNNUjVv.d.mts → namespace-UFcDEBJB.d.mts} +0 -0
  438. /package/dist/{namespace-BHkEHrUG.d.mts → namespace-f6Kz5cwX.d.mts} +0 -0
  439. /package/dist/{namespace-l1Rcc4mp.d.mts → namespace-rJ3ycPMg.d.mts} +0 -0
  440. /package/dist/{namespace-XUB3XnBK.d.mts → namespace-s0e215xO.d.mts} +0 -0
  441. /package/dist/{orchestrator-shared-D2I9gyOl.d.mts → orchestrator-shared--srEeSaY.d.mts} +0 -0
  442. /package/dist/{out-og8659Ny.mjs → out-EjlaPopg.mjs} +0 -0
  443. /package/dist/{ownership-recovery-guard-BIB5uqgz.mjs → ownership-recovery-guard-C9h8K1jo.mjs} +0 -0
  444. /package/dist/{package-BecmlOXC.mjs → package-BCKYMTYG.mjs} +0 -0
  445. /package/dist/{package-D2zvQO7X.mjs → package-BwlW7N32.mjs} +0 -0
  446. /package/dist/{packages-Dj9Nul23.d.mts → packages-B98-WETs.d.mts} +0 -0
  447. /package/dist/{packages-DAw3Z011.mjs → packages-G3bMStlV.mjs} +0 -0
  448. /package/dist/{platform-BObC-WJA.mjs → platform-Cojuulx8.mjs} +0 -0
  449. /package/dist/{providers-BysYiNMO.mjs → providers-CahjB0Kh.mjs} +0 -0
  450. /package/dist/{providers-namespace-BA0JT--_.d.mts → providers-namespace-DRcl03bo.d.mts} +0 -0
  451. /package/dist/{quick-lru-bVGGo5bq.mjs → quick-lru-C1yB5RCQ.mjs} +0 -0
  452. /package/dist/{registry-Cu3eD3UY.mjs → registry-DNMjJ-Oj.mjs} +0 -0
  453. /package/dist/{repo-context-Dy6eE9cg.mjs → repo-context-cO-TLEGN.mjs} +0 -0
  454. /package/dist/{runtime-inputs-CIYLDuBM.d.mts → runtime-inputs-DBtVIy9h.d.mts} +0 -0
  455. /package/dist/{schema-B098Jz9p.d.mts → schema-BA1cHBbc.d.mts} +0 -0
  456. /package/dist/{schema-bfw9nz8B.mjs → schema-BnuyCklU.mjs} +0 -0
  457. /package/dist/{schema-introspection-BTS7FZT_.mjs → schema-introspection-_Yw9L_mB.mjs} +0 -0
  458. /package/dist/{schemas-BE-gfjGI.mjs → schemas-BNRFKQdz.mjs} +0 -0
  459. /package/dist/{schemas-A2hlgeNu.mjs → schemas-BmoFWBdh.mjs} +0 -0
  460. /package/dist/{schemas-DKy_XYjq.d.mts → schemas-CEJe8O6P.d.mts} +0 -0
  461. /package/dist/{schemas-DNUfTOJ0.d.mts → schemas-CJKDu4Kt.d.mts} +0 -0
  462. /package/dist/{schemas-DNvDh0eE2.d.mts → schemas-Ca5RILd-2.d.mts} +0 -0
  463. /package/dist/{schemas-COQUToGQ.d.mts → schemas-CeItAAQM.d.mts} +0 -0
  464. /package/dist/{schemas-DChhgfU0.d.mts → schemas-Cj6Gbqch.d.mts} +0 -0
  465. /package/dist/{schemas-D6JvwH-h.d.mts → schemas-Cq1d5tid.d.mts} +0 -0
  466. /package/dist/{schemas-BZyi7v9g.d.mts → schemas-CtzZDp29.d.mts} +0 -0
  467. /package/dist/{schemas-ADuQFkhH.d.mts → schemas-DJ2vMsgm.d.mts} +0 -0
  468. /package/dist/{schemas-DMxM4U1A.d.mts → schemas-D_-iXLQ9.d.mts} +0 -0
  469. /package/dist/{schemas-BEDq3Psz.mjs → schemas-DekYSXka.mjs} +0 -0
  470. /package/dist/{schemas-B3UNnzKG.mjs → schemas-Djjq4LLs.mjs} +0 -0
  471. /package/dist/{schemas-DYtUc2WA.d.mts → schemas-LiiyNNpr.d.mts} +0 -0
  472. /package/dist/{schemas-mLjTSUvJ.mjs → schemas-hTUdjOh7.mjs} +0 -0
  473. /package/dist/{semver-ByPlHR3P.mjs → semver-Cb5Um3tU.mjs} +0 -0
  474. /package/dist/{server-lifecycle-C5Vl58sN.mjs → server-lifecycle-BjbuCO-s.mjs} +0 -0
  475. /package/dist/{server-lifecycle-B8UabaW3.d.mts → server-lifecycle-DUKp1Fbf.d.mts} +0 -0
  476. /package/dist/{session-lineage-CoNs4WZy.d.mts → session-lineage-C3myyt5x.d.mts} +0 -0
  477. /package/dist/{shared-schemas-CKsgVsGX.mjs → shared-schemas-CnOyMY42.mjs} +0 -0
  478. /package/dist/{src-D9PYcdDS.mjs → src-Xn6SS74f.mjs} +0 -0
  479. /package/dist/{storage-namespace-DITavhRL.d.mts → storage-namespace-IvLOIP7j.d.mts} +0 -0
  480. /package/dist/{storage-namespace-DBuKMBth.mjs → storage-namespace-TBX8VgK3.mjs} +0 -0
  481. /package/dist/{storage-namespace-definition-Ct9ohqU0.mjs → storage-namespace-definition-BUpCw171.mjs} +0 -0
  482. /package/dist/{storage-namespace-definition-1uCuoHvM.d.mts → storage-namespace-definition-Cv0XiTXb.d.mts} +0 -0
  483. /package/dist/{supports-color-DG_rcVqJ.mjs → supports-color-CjiFmM1U.mjs} +0 -0
  484. /package/dist/{telemetry-Be3u4I7b.mjs → telemetry-DXMqxYcv.mjs} +0 -0
  485. /package/dist/{timeout-Bscg1B-y.mjs → timeout-CATUeNuL.mjs} +0 -0
  486. /package/dist/{tray-menu-service-BGwXKJYr.mjs → tray-menu-service-BRrnoqaY.mjs} +0 -0
  487. /package/dist/{types-nY8yr3th.d.mts → types-BRM1AZaP.d.mts} +0 -0
  488. /package/dist/{types-RWRXplnM.d.mts → types-BYEybzjX.d.mts} +0 -0
  489. /package/dist/{types-Bh2fQoxM.mjs → types-CsmvIK25.mjs} +0 -0
  490. /package/dist/{types-CbXf822E.d.mts → types-QRSc2AUU.d.mts} +0 -0
  491. /package/dist/{types-BlaguWul.d.mts → types-QsyX4H21.d.mts} +0 -0
  492. /package/dist/{types-KF8zuMhi.d.mts → types-hkExapGH.d.mts} +0 -0
  493. /package/dist/{ui-config-Bl2Wbkr-.mjs → ui-config-D1jxR-dU.mjs} +0 -0
  494. /package/dist/{variant-B5j5wR2p.mjs → variant-CmSVU3LE.mjs} +0 -0
  495. /package/dist/{window-registry-DWHz8TA5.mjs → window-registry-2MZdZPdA.mjs} +0 -0
  496. /package/dist/{window-registry-Dq5uOWpH.d.mts → window-registry-DeG37kt8.d.mts} +0 -0
  497. /package/dist/{zod-json-schema-DGWHUOK0.mjs → zod-json-schema-ZUmGtQhT.mjs} +0 -0
@@ -1 +1 @@
1
- import{SessionStorageSubjects as e}from"./services/session/storage/namespace.mjs";import{ExecutionTargetSubjects as t}from"./services/execution-target/namespace.mjs";import{r as n}from"./attach-error-D5BWfaBO.mjs";import{AdapterSubjects as r,AgentSubjects as i,DEFAULT_CONSTRAINTS as a,SessionSubjects as o,SpawnSubagentRpcRequestSchema as s,SubagentConfigSchema as c,SubagentError as l,SubagentErrorCode as u,SubagentSubjects as d,dep as f,extensionToken as p}from"@makaio/framework/contracts";import{MakaioBus as m}from"@makaio/framework/bus";import{BaseService as h}from"@makaio/framework/service-base";import{RuntimeProviderContextResolutionError as g,resolveRuntimeProviderContext as _}from"@makaio/framework/services/provider-context";function v(e,t){return`${e}:${t}`}function y(e,t){return e?.authenticated!==!0||!e.id?!1:e.kind===`workflow-execution`?!0:t.size===0?!1:t.has(v(e.kind,e.id))}var b=class{maxSize;items=[];constructor(e=50){this.maxSize=e}push(e){this.items.push(e),this.items.length>this.maxSize&&this.items.shift()}toArray(){return[...this.items]}get length(){return this.items.length}clear(){this.items=[]}};const x=[`completed`,`failed`,`cancelled`];function S(e){return x.includes(e)}var C=class{constraints;subagents=new Map;awaiters=new Map;constructor(e){this.constraints=e}track(e){let t=Date.now(),n={subagentId:e.subagentId,parentSessionId:e.parentSessionId,childSessionId:void 0,status:`spawning`,config:e.config,depth:e.depth,progressUpdates:new b(50),toolObservations:[],completedTurnUsage:new Map,completedTurnSuccess:new Map,toolCallIds:new Set,startTime:t,lastActivityAt:t};return this.subagents.set(e.subagentId,n),n}setChildSessionId(e,t){let n=this.subagents.get(e);n&&(n.childSessionId=t,n.lastActivityAt=Date.now())}markStarted(e){let t=this.subagents.get(e);t&&t.status===`spawning`&&this.applyStatus(t,`running`)}get(e){return this.subagents.get(e)}getByChildSessionId(e){return[...this.subagents.values()].find(t=>t.childSessionId===e)}recordTurnStarted(e,t){let n=this.getByChildSessionId(e);n===void 0||S(n.status)||(n.activeTurnId=t,n.lastActivityAt=Date.now())}recordTurnCompleted(e,t){let n=this.getByChildSessionId(e);n===void 0||S(n.status)||(n.activeTurnId===t&&(n.activeTurnId=void 0),n.lastActivityAt=Date.now())}recordToolObservation(e,t,n){let r=this.getByChildSessionId(e);if(!(r===void 0||S(r.status))){if(n!==void 0){if(r.toolCallIds.has(n))return;r.toolCallIds.add(n)}r.toolObservations.push(t),r.lastActivityAt=Date.now()}}getAllNonTerminal(){let e=[];for(let t of this.subagents.values())S(t.status)||e.push(t);return e}countActiveBySession(e){let t=0;for(let n of this.subagents.values())n.parentSessionId===e&&!S(n.status)&&t++;return t}countTotalActive(){let e=0;for(let t of this.subagents.values())S(t.status)||e++;return e}updateStatus(e,t){let n=this.subagents.get(e);n&&this.applyStatus(n,t)}applyStatus(e,t){let n=Date.now();e.status=t,e.lastActivityAt=n,S(t)&&(e.activeTurnId=void 0,e.endTime=n)}addProgress(e,t){let n=this.subagents.get(e);n&&(n.progressUpdates.push(t),n.lastActivityAt=Date.now())}setPendingRequest(e,t){let n=this.subagents.get(e);if(!n)throw new l(u.NOT_FOUND,`Subagent ${e} not found`);if(n.pendingRequest)throw new l(u.REQUEST_PENDING,`Cannot call request_input while another request is pending`);if(n.completionCandidate!==void 0)throw new l(u.INVALID_STATE,`Cannot request input while completion is pending`);n.pendingRequest=t,n.status=`waiting_input`,n.lastActivityAt=Date.now()}resolvePendingRequest(e,t){let n=this.subagents.get(e);n?.pendingRequest&&(n.pendingRequest.resolver(t),n.pendingRequest=void 0,n.lastActivityAt=Date.now(),n.status===`waiting_input`&&(n.status=`running`))}markCompleted(e,t,n,r){let i=this.subagents.get(e);if(!i)throw new l(u.NOT_FOUND,`Subagent ${e} not found`);if(S(i.status))throw new l(u.ALREADY_TERMINAL,`Subagent already in terminal state: ${i.status}`);this.applyStatus(i,`completed`),i.result=t,i.summary=n,i.completionSource=r,this.resolveAwaiters(e)}recordCompletionCandidate(e,t,n,r,i){let a=this.subagents.get(e);if(!a)throw new l(u.NOT_FOUND,`Subagent ${e} not found`);let o=a.completionCandidate;if(o!==void 0){if(o.turnId===t&&o.result===n&&o.summary===r&&o.source===i)return;throw new l(u.INVALID_STATE,`Conflicting subagent completion candidate`)}if(S(a.status))throw new l(u.ALREADY_TERMINAL,`Subagent already in terminal state: ${a.status}`);if(a.pendingRequest!==void 0)throw new l(u.INVALID_STATE,`Cannot complete while an input request is pending`);a.completionCandidate={turnId:t,result:n,summary:r,source:i},a.status=`completing`,a.lastActivityAt=Date.now()}recordCompletedTurn(e,t,n,r=!0,i){let a=this.subagents.get(e);a===void 0||S(a.status)||(a.completedTurnUsage.has(t)||(a.completedTurnUsage.set(t,n===void 0?void 0:{total:{...n.total},...n.byAgent===void 0?{}:{byAgent:Object.fromEntries(Object.entries(n.byAgent).map(([e,t])=>[e,{...t}]))}}),a.completedTurnSuccess.set(t,{success:r,...i!==void 0&&{error:i}})),a.lastActivityAt=Date.now())}finalizeCompletionIfReady(e){let t=this.subagents.get(e);if(!t)throw new l(u.NOT_FOUND,`Subagent ${e} not found`);if(S(t.status))return!1;let n=t.completionCandidate;if(n===void 0||!t.completedTurnUsage.has(n.turnId))return!1;let r=t.completedTurnSuccess.get(n.turnId);if(r?.success===!1)return this.markFailed(e,r.error??`child turn failed`),!0;let i=this.freezeUsage(t);return this.applyStatus(t,`completed`),t.result=n.result,t.summary=n.summary,t.completionSource=n.source,t.usage=i,this.resolveAwaiters(e),!0}freezeUsage(e){let t=0,n=0,r=0,i=!1;for(let a of e.completedTurnUsage.values())a!==void 0&&(i=!0,t+=a.total.inputTokens,n+=a.total.cachedInputTokens??0,r+=a.total.outputTokens);return Object.freeze({...i?{inputTokens:t,cachedInputTokens:n,outputTokens:r}:{},toolCallCount:e.toolCallIds.size})}markFailed(e,t){let n=this.subagents.get(e);!n||S(n.status)||(this.applyStatus(n,`failed`),n.error=t,this.resolveAwaiters(e))}markCancelled(e){let t=this.subagents.get(e);return!t||S(t.status)?!1:(this.applyStatus(t,`cancelled`),t.pendingRequest&&=(t.pendingRequest.resolver(null),void 0),this.resolveAwaiters(e),!0)}addAwaiter(e,t){let n=this.awaiters.get(e)??[];n.push(t),this.awaiters.set(e,n)}removeAwaiter(e,t){let n=this.awaiters.get(e);if(!n)return!1;let r=n.indexOf(t);return r===-1?!1:(n.splice(r,1),n.length===0&&this.awaiters.delete(e),!0)}resolveAwaiters(e){let t=this.subagents.get(e),n=this.awaiters.get(e);if(!n||!t)return;let r={status:t.status,result:t.result,error:t.error,completionSource:t.completionSource,usage:t.usage,toolObservations:[...t.toolObservations]};for(let e of n)e(r);this.awaiters.delete(e)}cleanup(){let e=Date.now(),t=0;for(let[n,r]of this.subagents)S(r.status)&&r.endTime&&e-r.endTime>this.constraints.stateRetentionMs&&(this.subagents.delete(n),t++);return t}sweepHung(e){if(e<=0)return 0;let t=Date.now(),n=0;for(let r of this.subagents.values())S(r.status)||r.status!==`spawning`&&r.status!==`waiting_input`&&r.status!==`hung`&&t-r.lastActivityAt>=e&&(r.status=`hung`,r.lastActivityAt=t,n++);return n}};async function w(e,t,n){let r=n?.trim();if(r)return r;let{session:i}=await e.request(o.get,{sessionId:t});return(i?.agents.find(e=>e.agentId===i.leadAgentId)??i?.agents[0])?.adapterName?.trim()}function T(e,t){let n=e.manager.get(t.subagentId);if(!n)throw Error(`Subagent not found: ${t.subagentId}`);return{status:n.status,childSessionId:n.childSessionId,pendingRequest:n.pendingRequest?{messageId:n.pendingRequest.messageId,question:n.pendingRequest.question,context:n.pendingRequest.context}:void 0,progress:n.progressUpdates.toArray(),result:n.result,summary:n.summary,error:n.error,usage:n.usage}}async function E(e,t){let{parentSessionId:n,config:r,depth:i,spawningToolCallId:a}=t,{constraints:o}=e.manager,s=Math.min(r.maxDepth??o.maxDepth,o.maxDepth);if(i>s)throw new l(u.DEPTH_EXCEEDED,`Maximum subagent depth (${s}) exceeded`);if(e.manager.countActiveBySession(n)>=o.maxConcurrentPerSession)throw new l(u.SESSION_LIMIT,`Maximum concurrent subagents per session (${o.maxConcurrentPerSession}) reached`);if(e.manager.countTotalActive()>=o.maxTotalActive)throw new l(u.GLOBAL_LIMIT,`Maximum total active subagents (${o.maxTotalActive}) reached`);let c=await w(e.bus,n,r.adapterName);if(!c)throw new l(u.ADAPTER_NOT_ALLOWED,`adapterName is required for subagent spawn when parent session has no inheritable adapter`);if(o.allowedAdapters.length>0&&!o.allowedAdapters.includes(c))throw new l(u.ADAPTER_NOT_ALLOWED,`Adapter '${c}' is not allowed`);if(r.model&&o.allowedModels.length>0&&!o.allowedModels.includes(r.model))throw new l(u.MODEL_NOT_ALLOWED,`Model '${r.model}' is not allowed`);let f={...r,adapterName:c},p=crypto.randomUUID();return e.manager.track({subagentId:p,parentSessionId:n,config:f,depth:i}),await e.bus.emit(d.spawned,{subagentId:p,parentSessionId:n,task:f.task,config:f,depth:i,...e.executionOwnerId!==void 0&&{executionOwnerId:e.executionOwnerId},...a!==void 0&&{spawningToolCallId:a}}),{subagentId:p,status:`spawning`}}async function D(e,t){let{subagentId:n,timeoutMs:r}=t,i=e.manager.get(n);if(!i)throw Error(`Subagent not found: ${n}`);if([`completed`,`failed`,`cancelled`].includes(i.status))return{status:i.status,result:i.result,error:i.error,completionSource:i.completionSource,toolObservations:[...i.toolObservations],usage:i.usage};if(i.status===`waiting_input`&&i.pendingRequest)return{status:`waiting_input`,pendingRequest:{messageId:i.pendingRequest.messageId,question:i.pendingRequest.question,context:i.pendingRequest.context}};let a=r??e.manager.constraints.defaultAwaitTimeoutMs;return new Promise(t=>{let r=!1,i,o=e=>{r||(r=!0,i&&clearTimeout(i),t({status:e.status,result:e.result,error:e.error,pendingRequest:e.pendingRequest,completionSource:e.completionSource,toolObservations:e.toolObservations,usage:e.usage}))};e.manager.addAwaiter(n,o),a>0&&(i=setTimeout(()=>{r||(r=!0,e.manager.removeAwaiter(n,o),t({status:`timeout`}))},a))})}async function O(e,t){let{subagentId:n,content:r,inResponseTo:i}=t,a=e.manager.get(n);if(!a)throw Error(`Subagent not found: ${n}`);if(a.status===`spawning`)throw new l(u.INVALID_STATE,`Cannot send to a subagent before startup completes`);if(a.completionCandidate!==void 0)throw new l(u.INVALID_STATE,`Cannot send to a subagent while completion is pending`);let o=!1;return i&&a.pendingRequest?.messageId===i&&(e.manager.resolvePendingRequest(n,r),o=!0),await e.bus.emit(d.toChild,{subagentId:n,messageId:crypto.randomUUID(),content:r,inResponseTo:i}),{sent:!0,resolvedPending:o}}async function k(e,t){let{subagentId:n,reason:r}=t,i=e.manager.markCancelled(n);return i&&await e.bus.emit(d.cancelled,{subagentId:n,reason:r??`Killed by parent`}),{killed:i}}async function A(e,t){let{subagentId:n,update:r,percentComplete:i}=t;if(!e.manager.get(n))throw Error(`Subagent not found: ${n}`);let a=i===void 0?r:`[${i}%] ${r}`;return e.manager.addProgress(n,a),await e.bus.emit(d.toParent,{subagentId:n,messageId:crypto.randomUUID(),type:`progress`,content:a}),{reported:!0}}async function j(e,t){let{subagentId:n,question:r,context:i,timeoutMs:a}=t,o=e.manager.get(n);if(!o)throw Error(`Subagent not found: ${n}`);if(o.completionCandidate!==void 0)throw new l(u.INVALID_STATE,`Cannot request input while completion is pending`);let s=crypto.randomUUID(),c=a??e.manager.constraints.defaultRequestTimeoutMs,f=!1,p,m,h=new Promise(e=>{m=e});e.manager.setPendingRequest(n,{messageId:s,question:r,context:i,resolver:e=>{f||(f=!0,p&&clearTimeout(p),m(e===null?{responded:!1,timedOut:!0}:{responded:!0,response:e,timedOut:!1}))}}),c>0&&(p=setTimeout(()=>{f||e.manager.resolvePendingRequest(n,null)},c));let g=e.bus.emit(d.toParent,{subagentId:n,messageId:s,type:`request_input`,content:r,context:i}).then(()=>({published:!0}),e=>({published:!1,error:e})),_=await Promise.race([h.then(e=>({response:e})),g]);if(`response`in _)return _.response;if(!_.published)throw e.manager.resolvePendingRequest(n,null),_.error;return h}async function M(e,t){let{sessionId:n,turnId:r,result:i,summary:a}=t,o=e.manager.getByChildSessionId(n);if(o===void 0)throw new l(u.NOT_FOUND,`No subagent owns this child session`);if(o.status===`completed`||o.status===`failed`||o.status===`cancelled`)throw new l(u.ALREADY_TERMINAL,`Subagent already in terminal state: ${o.status}`);let s=o.activeTurnId;if(s===void 0)throw new l(u.INVALID_STATE,`No active turn exists for this child session`);if(r!==void 0&&r!==s)throw new l(u.INVALID_STATE,`Completion turn does not match the active child turn`);return e.manager.recordCompletionCandidate(o.subagentId,s,i,a,`tool`),await e.onCompletionCandidate?.(o.subagentId),{completed:!0}}function N(e,t){let{parentSessionId:n}=t;return{subagents:e.manager.getAllNonTerminal().filter(e=>e.parentSessionId===n).map(e=>({subagentId:e.subagentId,task:e.config.task,status:e.status}))}}function P(e,t,n,r){return{kind:`adapter`,adapterName:e,...n!==void 0&&{providerContext:n},...t.model!==void 0&&{model:t.model},...t.reasoningEffort!==void 0&&{reasoningEffort:t.reasoningEffort},...t.systemPrompt!==void 0&&{systemPrompt:t.systemPrompt},...t.adapterConfig!==void 0&&{adapterConfig:t.adapterConfig},...r!==void 0&&{cwd:r},...t.tools!==void 0&&{allowedTools:t.tools},...t.disallowedTools!==void 0&&{disallowedTools:t.disallowedTools},...t.allowedDirectories!==void 0&&{allowedDirectories:t.allowedDirectories}}}async function F(e,t){let{subagentId:n,adapterName:r,config:i,sessionId:a,task:s,targetWorkingDirectory:c,assertAdmission:l}=t,u=i.providerContext;if(u?.state===`resolved`&&i.providerConfigId!==void 0&&i.providerConfigId!==u.providerConfigId)throw Error(`Subagent providerConfigId "${i.providerConfigId}" does not match its resolved provider context "${u.providerConfigId}".`);if(u?.state===`unresolved`&&i.providerConfigId!==void 0)throw new g(`provider-context-unresolved`,r,i.providerConfigId);let d=u??(i.providerConfigId?await _(e,{adapterName:r,providerConfigId:i.providerConfigId}):void 0);await e.request(o.agent.attachResolved,{sessionId:a,role:`lead`,initialMessage:s,source:`system`,assertInitialMessageAdmission:()=>{try{l()}catch{throw Error(`Subagent startup was cancelled before initial task admission: ${n}`)}},...i.responseSchema!==void 0&&{responseSchema:i.responseSchema},...i.harnessId!==void 0&&{harnessId:i.harnessId},agent:P(r,i,d,c)},{timeout:0})}const I={id:`system:local`,name:`Local`,description:`Default local process execution`,type:`local`,scope:`default`,enabled:!0,createdAt:Date.now(),updatedAt:Date.now()};var L=class extends Error{code;constructor(e){super(`Subagent failure finalization failed (${e}).`),this.code=e,this.name=`SubagentFailureFinalizationError`}},R=class extends h{delegationAllowSet;requestHandlerPriority;executionOwnerId;manager;pendingChildSessionClose=new Set;spawningExecutions=new Set;constructor(e=m,t=a,n=new Set,r=0,i=crypto.randomUUID()){super(e),this.delegationAllowSet=n,this.requestHandlerPriority=r,this.executionOwnerId=i,this.manager=new C(t)}grantDelegation(e,t){this.delegationAllowSet.add(`${e}:${t}`)}revokeDelegation(e,t){this.delegationAllowSet.delete(`${e}:${t}`)}onInit(){this.registerHandler(d.spawned,async e=>{e.payload.executionOwnerId!==void 0&&e.payload.executionOwnerId!==this.executionOwnerId||this.handleSpawned(e.payload).catch(e=>{console.error(`[SubagentService] handleSpawned error:`,e)})}),this.registerHandler(d.execute,async e=>{if(!this.isRemoteDelegationAllowed(e))return;let t=await this.handleExecute(e.payload);e.setResult(t)}),this.registerHandler(d.toChild,async e=>{await this.handleToChild(e.payload)}),this.registerHandler(d.completed,async e=>{await this.handleCompleted(e.payload.subagentId)}),this.registerHandler(d.cancelled,async e=>{await this.handleCancelled(e.payload.subagentId)}),this.registerHandler(r.session.closed,e=>{this.handleAdapterSessionClosed(e.payload.sessionId)}),this.registerHandler(i.complete,async e=>{await this.handleAgentComplete(e.payload)}),this.registerHandler(o.turn.completed,async e=>{await this.handleSessionTurnCompleted(e.payload)}),this.registerHandler(o.turn.started,e=>{this.handleSessionTurnStarted(e.payload)}),this.registerHandler(i.tool.completed,e=>{e.payload._import||e.payload.sessionId===void 0||e.payload.success===void 0||this.manager.recordToolObservation(e.payload.sessionId,{toolName:e.payload.toolName,outcome:e.payload.success?`success`:`failure`,...e.payload.success===!0&&e.payload.artifactResult!==void 0?{artifact:e.payload.artifactResult}:{}},e.payload.toolCallId)}),this.registerRpcHandlers(),this.wirePeriodicSweep()}wirePeriodicSweep(){let{inactivityTimeoutMs:e,sweepIntervalMs:t}=this.manager.constraints;if(t<=0)return;let n=setInterval(()=>{let t=this.manager.sweepHung(e);t>0&&console.warn(`[SubagentService] Swept ${t} hung subagent(s) due to inactivity`),this.manager.cleanup()},t);this.addCleanup(()=>clearInterval(n))}registerRpcHandlers(){let e={manager:this.manager,bus:this.bus,executionOwnerId:this.executionOwnerId,onCompletionCandidate:e=>this.finalizeSubagentIfReady(e)};this.registerHandler(d.getStatus,t=>{let n=T(e,t.payload);t.setResult(n)},{priority:this.requestHandlerPriority}),this.registerHandler(d.spawn,async t=>{if(!this.isRemoteDelegationAllowed(t))return;let n=await E(e,s.parse(t.payload));t.setResult(n)},{priority:this.requestHandlerPriority}),this.registerHandler(d.await,async t=>{let n=await D(e,t.payload);t.setResult(n)},{priority:this.requestHandlerPriority}),this.registerHandler(d.send,async t=>{let n=await O(e,t.payload);t.setResult(n)}),this.registerHandler(d.kill,async t=>{let n=await k(e,t.payload);t.setResult(n)},{priority:this.requestHandlerPriority}),this.registerHandler(d.reportProgress,async t=>{let n=await A(e,t.payload);t.setResult(n)}),this.registerHandler(d.requestInput,async t=>{let n=await j(e,t.payload);t.setResult(n)}),this.registerHandler(d.completeTask,async t=>{let n=await M(e,t.payload);t.setResult(n)}),this.registerHandler(d.listBySession,t=>{let n=N(e,t.payload);t.setResult(n)})}onDestroy(){this.pendingChildSessionClose.clear(),this.spawningExecutions.clear()}async handleSpawned(e){let{subagentId:t,parentSessionId:n,task:r,spawningToolCallId:i}=e,a=this.manager.get(t);if(!(a&&a.status!==`spawning`)&&!this.spawningExecutions.has(t)){this.spawningExecutions.add(t);try{return await this.executeSpawned(e,n,r,i)}finally{this.spawningExecutions.delete(t)}}}async executeSpawned(e,n,r,i){let{subagentId:a}=e,o=()=>this.shouldAbortSpawn(this.manager.get(a)?.status),s=c.parse({...e.config,task:r}),l=s.adapterName?.trim();if(!l)return this.failSpawn(a,n,`adapter_start`,`Subagent spawn requires a non-empty adapterName`);this.manager.get(a)||this.manager.track({subagentId:a,parentSessionId:n,config:s,depth:e.depth??1});let u,d;try{d=await this.buildExecutionTargetResolutionParams(n,s.executionTargetId);let e=await this.bus.requestOptional(t.resolve,d),r;if(e.handled)r=e.data.executionTarget;else if(d.executionTargetId!=null)throw Error(`Execution target resolver unavailable for explicit target '${d.executionTargetId}'`);else r=I;if(r.type!==`local`)return this.failSpawn(a,n,`adapter_start`,`Execution target type '${r.type}' is not yet supported for subagents`);u=d.executionTargetId??void 0}catch(e){return this.failSpawn(a,n,`adapter_start`,e)}let f;try{f=await this.createChildSessionForSpawn(a,n,s,u,d,i)}catch(e){return this.failSpawn(a,n,`session_create`,e)}if(!o())return this.attachSpawnedSubagent({subagentId:a,parentSessionId:n,adapterName:l,config:s,sessionId:f,task:r,targetWorkingDirectory:d.targetWorkingDirectory,shouldAbort:o})}async attachSpawnedSubagent(e){let{subagentId:t,parentSessionId:r,adapterName:i,config:a,sessionId:o,task:s,targetWorkingDirectory:c,shouldAbort:l}=e;try{await F(this.bus,{subagentId:t,adapterName:i,config:a,sessionId:o,task:s,targetWorkingDirectory:c,assertAdmission:()=>{if(this.shouldAbortSpawn(this.manager.get(t)?.status))throw Error(`startup cancelled`)}})}catch(e){if(l())return;let i=n(e);return this.failSpawn(t,r,i?.stage===`initial_message`?`agent_start`:`adapter_start`,e)}l()||this.manager.markStarted(t)}async createChildSessionForSpawn(e,t,n,r,i,a){let{sessionId:s}=await this.bus.request(o.create,this.buildChildSessionCreatePayload(t,n,r,i.targetWorkingDirectory,a));return this.manager.setChildSessionId(e,s),this.pendingChildSessionClose.has(e)&&await this.closeChildSession(e),s}async failSpawn(e,t,n,r){let i=r instanceof Error?r:Error(String(r));this.manager.markFailed(e,i.message);let[a,o]=await Promise.allSettled([this.manager.get(e)?.childSessionId===void 0?Promise.resolve():this.requestChildSessionClose(e),this.emitExecutionFailed(e,t,n,i)]),s=[];if(a.status===`rejected`&&s.push(new L(`child-session-close-failed`)),o.status===`rejected`&&s.push(new L(`failure-publication-failed`)),s.length>0)throw AggregateError([i,...s],`Subagent spawn failed and failure finalization also failed.`);return i.message}async buildExecutionTargetResolutionParams(t,n){if(n!==void 0)return{executionTargetId:n};let{session:r}=await this.bus.request(e.get,{sessionId:t});if(!r)throw Error(`Parent session not found: ${t}`);return{...r.executionTargetId!==void 0&&{executionTargetId:r.executionTargetId},...r.targetWorkingDirectory!==void 0&&{targetWorkingDirectory:r.targetWorkingDirectory}}}buildChildSessionCreatePayload(e,t,n,r,i){return{branchKind:`subagent`,parentSessionId:e,contextInheritance:t.contextMode===`fork`?`parent-history`:`none`,...n!==void 0&&{executionTargetId:n},...r!==void 0&&{targetWorkingDirectory:r},...i!==void 0&&{spawningToolCallId:i}}}async handleExecute(e){let t=c.parse({...e.config,task:e.task});this.manager.track({subagentId:e.subagentId,parentSessionId:e.parentSessionId,config:t,depth:e.depth});let n=await this.handleSpawned({subagentId:e.subagentId,parentSessionId:e.parentSessionId,task:e.task,config:t,depth:e.depth});return n?{success:!1,error:n}:{success:!0}}async handleToChild(e){let{subagentId:t,content:n}=e,r=this.manager.get(t);if(!r){console.warn(`[SubagentService] No subagent found: ${t}`);return}if(!r.childSessionId){console.warn(`[SubagentService] No child session for subagent: ${t}`);return}try{await this.bus.request(o.sendMessage,{sessionId:r.childSessionId,message:n,source:`system`})}catch(e){console.error(`[SubagentService] Failed to route message to child session:`,e)}}async handleCompleted(e){await this.closeChildSession(e)}async handleCancelled(e){await this.closeChildSession(e)}async closeChildSession(e){try{await this.requestChildSessionClose(e)}catch{console.error(`[SubagentService] Failed to close child session for subagent ${e}:`,new L(`child-session-close-failed`))}}async requestChildSessionClose(e){let t=this.manager.get(e);if(t){if(!t.childSessionId){this.pendingChildSessionClose.add(e);return}this.pendingChildSessionClose.delete(e),await this.bus.request(o.close,{sessionId:t.childSessionId})}}shouldAbortSpawn(e){return e===void 0||e===`completed`||e===`failed`||e===`cancelled`}handleAdapterSessionClosed(e){for(let t of this.manager.getAllNonTerminal())if(t.childSessionId===e){console.warn(`[SubagentService] Adapter session closed for subagent ${t.subagentId}: ${e}`),this.manager.markFailed(t.subagentId,`adapter-session-closed`);return}}async handleAgentComplete(e){let{sessionId:t,turnId:n,outcome:r,message:i,error:a}=e;if(!(!t||!n))for(let e of this.manager.getAllNonTerminal()){if(e.childSessionId!==t)continue;if((e.config.completion??`tool`)!==`turn`||e.status===`waiting_input`)return;let o=r??`completed`;if(o===`completed`)try{this.manager.recordCompletionCandidate(e.subagentId,n,i??``,void 0,`turn`),await this.finalizeSubagentIfReady(e.subagentId)}catch{return}else if(o===`error`)try{this.manager.recordCompletionCandidate(e.subagentId,n,a??`child turn failed`,void 0,`turn`),await this.finalizeSubagentIfReady(e.subagentId)}catch{return}return}}async handleSessionTurnCompleted(e){if(e.ingestionMarker!==`backfill`){for(let t of this.manager.getAllNonTerminal())if(t.childSessionId===e.sessionId){if(this.manager.recordTurnCompleted(e.sessionId,e.turnId),this.manager.recordCompletedTurn(t.subagentId,e.turnId,e.usage,e.success,e.error),t.completionCandidate?.turnId!==e.turnId)return;await this.finalizeSubagentIfReady(t.subagentId);return}}}handleSessionTurnStarted(e){e.ingestionMarker!==`backfill`&&this.manager.recordTurnStarted(e.sessionId,e.turnId)}async finalizeSubagentIfReady(e){if(!this.manager.finalizeCompletionIfReady(e))return;let t=this.manager.get(e);await this.bus.emit(d.completed,{subagentId:e,success:t?.status===`completed`,...t?.status===`completed`?{result:t.summary?`${t.summary}\n\n${t.result??``}`:t?.result,usage:t.usage}:{error:t?.error??`child turn failed`}})}isRemoteDelegationAllowed(e){return e.origin.local||y(e.transport?.peer,this.delegationAllowSet)}async emitExecutionFailed(e,t,n,r){let i=r instanceof Error?r.message:String(r);await this.bus.emit(d.executionFailed,{subagentId:e,parentSessionId:t,phase:n,error:i})}};const z=p(`subagent-service`);function B(e=0){return{name:z.name,displayName:`Subagent Service`,version:`0.1.0`,critical:!0,surface:`headless`,dependencies:[f(`session`)],create:t=>new R(t.bus,a,new Set,e)}}const V=B();export{R as a,L as i,B as n,C as o,V as r,y as s,z as t};
1
+ import{SessionStorageSubjects as e}from"./services/session/storage/namespace.mjs";import{ExecutionTargetSubjects as t}from"./services/execution-target/namespace.mjs";import{r as n}from"./attach-error-wNJ8Q5uU.mjs";import{AdapterSubjects as r,AgentSubjects as i,DEFAULT_CONSTRAINTS as a,SessionSubjects as o,SpawnSubagentRpcRequestSchema as s,SubagentConfigSchema as c,SubagentError as l,SubagentErrorCode as u,SubagentSubjects as d,dep as f,extensionToken as p}from"@makaio/framework/contracts";import{MakaioBus as m}from"@makaio/framework/bus";import{BaseService as h}from"@makaio/framework/service-base";import{RuntimeProviderContextResolutionError as g,resolveRuntimeProviderContext as _}from"@makaio/framework/services/provider-context";function v(e,t){return`${e}:${t}`}function y(e,t){return e?.authenticated!==!0||!e.id?!1:e.kind===`workflow-execution`?!0:t.size===0?!1:t.has(v(e.kind,e.id))}var b=class{maxSize;items=[];constructor(e=50){this.maxSize=e}push(e){this.items.push(e),this.items.length>this.maxSize&&this.items.shift()}toArray(){return[...this.items]}get length(){return this.items.length}clear(){this.items=[]}};const x=[`completed`,`failed`,`cancelled`];function S(e){return x.includes(e)}var C=class{constraints;subagents=new Map;awaiters=new Map;constructor(e){this.constraints=e}track(e){let t=Date.now(),n={subagentId:e.subagentId,parentSessionId:e.parentSessionId,childSessionId:void 0,status:`spawning`,config:e.config,depth:e.depth,progressUpdates:new b(50),toolObservations:[],completedTurnUsage:new Map,completedTurnSuccess:new Map,toolCallIds:new Set,startTime:t,lastActivityAt:t};return this.subagents.set(e.subagentId,n),n}setChildSessionId(e,t){let n=this.subagents.get(e);n&&(n.childSessionId=t,n.lastActivityAt=Date.now())}markStarted(e){let t=this.subagents.get(e);t&&t.status===`spawning`&&this.applyStatus(t,`running`)}get(e){return this.subagents.get(e)}getByChildSessionId(e){return[...this.subagents.values()].find(t=>t.childSessionId===e)}recordTurnStarted(e,t){let n=this.getByChildSessionId(e);n===void 0||S(n.status)||(n.activeTurnId=t,n.lastActivityAt=Date.now())}recordTurnCompleted(e,t){let n=this.getByChildSessionId(e);n===void 0||S(n.status)||(n.activeTurnId===t&&(n.activeTurnId=void 0),n.lastActivityAt=Date.now())}recordToolObservation(e,t,n){let r=this.getByChildSessionId(e);if(!(r===void 0||S(r.status))){if(n!==void 0){if(r.toolCallIds.has(n))return;r.toolCallIds.add(n)}r.toolObservations.push(t),r.lastActivityAt=Date.now()}}getAllNonTerminal(){let e=[];for(let t of this.subagents.values())S(t.status)||e.push(t);return e}countActiveBySession(e){let t=0;for(let n of this.subagents.values())n.parentSessionId===e&&!S(n.status)&&t++;return t}countTotalActive(){let e=0;for(let t of this.subagents.values())S(t.status)||e++;return e}updateStatus(e,t){let n=this.subagents.get(e);n&&this.applyStatus(n,t)}applyStatus(e,t){let n=Date.now();e.status=t,e.lastActivityAt=n,S(t)&&(e.activeTurnId=void 0,e.endTime=n)}addProgress(e,t){let n=this.subagents.get(e);n&&(n.progressUpdates.push(t),n.lastActivityAt=Date.now())}setPendingRequest(e,t){let n=this.subagents.get(e);if(!n)throw new l(u.NOT_FOUND,`Subagent ${e} not found`);if(n.pendingRequest)throw new l(u.REQUEST_PENDING,`Cannot call request_input while another request is pending`);if(n.completionCandidate!==void 0)throw new l(u.INVALID_STATE,`Cannot request input while completion is pending`);n.pendingRequest=t,n.status=`waiting_input`,n.lastActivityAt=Date.now()}resolvePendingRequest(e,t){let n=this.subagents.get(e);n?.pendingRequest&&(n.pendingRequest.resolver(t),n.pendingRequest=void 0,n.lastActivityAt=Date.now(),n.status===`waiting_input`&&(n.status=`running`))}markCompleted(e,t,n,r){let i=this.subagents.get(e);if(!i)throw new l(u.NOT_FOUND,`Subagent ${e} not found`);if(S(i.status))throw new l(u.ALREADY_TERMINAL,`Subagent already in terminal state: ${i.status}`);this.applyStatus(i,`completed`),i.result=t,i.summary=n,i.completionSource=r,this.resolveAwaiters(e)}recordCompletionCandidate(e,t,n,r,i){let a=this.subagents.get(e);if(!a)throw new l(u.NOT_FOUND,`Subagent ${e} not found`);let o=a.completionCandidate;if(o!==void 0){if(o.turnId===t&&o.result===n&&o.summary===r&&o.source===i)return;throw new l(u.INVALID_STATE,`Conflicting subagent completion candidate`)}if(S(a.status))throw new l(u.ALREADY_TERMINAL,`Subagent already in terminal state: ${a.status}`);if(a.pendingRequest!==void 0)throw new l(u.INVALID_STATE,`Cannot complete while an input request is pending`);a.completionCandidate={turnId:t,result:n,summary:r,source:i},a.status=`completing`,a.lastActivityAt=Date.now()}recordCompletedTurn(e,t,n,r=!0,i){let a=this.subagents.get(e);a===void 0||S(a.status)||(a.completedTurnUsage.has(t)||(a.completedTurnUsage.set(t,n===void 0?void 0:{total:{...n.total},...n.byAgent===void 0?{}:{byAgent:Object.fromEntries(Object.entries(n.byAgent).map(([e,t])=>[e,{...t}]))}}),a.completedTurnSuccess.set(t,{success:r,...i!==void 0&&{error:i}})),a.lastActivityAt=Date.now())}finalizeCompletionIfReady(e){let t=this.subagents.get(e);if(!t)throw new l(u.NOT_FOUND,`Subagent ${e} not found`);if(S(t.status))return!1;let n=t.completionCandidate;if(n===void 0||!t.completedTurnUsage.has(n.turnId))return!1;let r=t.completedTurnSuccess.get(n.turnId);if(r?.success===!1)return this.markFailed(e,r.error??`child turn failed`),!0;let i=this.freezeUsage(t);return this.applyStatus(t,`completed`),t.result=n.result,t.summary=n.summary,t.completionSource=n.source,t.usage=i,this.resolveAwaiters(e),!0}freezeUsage(e){let t=0,n=0,r=0,i=!1;for(let a of e.completedTurnUsage.values())a!==void 0&&(i=!0,t+=a.total.inputTokens,n+=a.total.cachedInputTokens??0,r+=a.total.outputTokens);return Object.freeze({...i?{inputTokens:t,cachedInputTokens:n,outputTokens:r}:{},toolCallCount:e.toolCallIds.size})}markFailed(e,t){let n=this.subagents.get(e);!n||S(n.status)||(this.applyStatus(n,`failed`),n.error=t,this.resolveAwaiters(e))}markCancelled(e){let t=this.subagents.get(e);return!t||S(t.status)?!1:(this.applyStatus(t,`cancelled`),t.pendingRequest&&=(t.pendingRequest.resolver(null),void 0),this.resolveAwaiters(e),!0)}addAwaiter(e,t){let n=this.awaiters.get(e)??[];n.push(t),this.awaiters.set(e,n)}removeAwaiter(e,t){let n=this.awaiters.get(e);if(!n)return!1;let r=n.indexOf(t);return r===-1?!1:(n.splice(r,1),n.length===0&&this.awaiters.delete(e),!0)}resolveAwaiters(e){let t=this.subagents.get(e),n=this.awaiters.get(e);if(!n||!t)return;let r={status:t.status,result:t.result,error:t.error,completionSource:t.completionSource,usage:t.usage,toolObservations:[...t.toolObservations]};for(let e of n)e(r);this.awaiters.delete(e)}cleanup(){let e=Date.now(),t=0;for(let[n,r]of this.subagents)S(r.status)&&r.endTime&&e-r.endTime>this.constraints.stateRetentionMs&&(this.subagents.delete(n),t++);return t}sweepHung(e){if(e<=0)return 0;let t=Date.now(),n=0;for(let r of this.subagents.values())S(r.status)||r.status!==`spawning`&&r.status!==`waiting_input`&&r.status!==`hung`&&t-r.lastActivityAt>=e&&(r.status=`hung`,r.lastActivityAt=t,n++);return n}};async function w(e,t,n){let r=n?.trim();if(r)return r;let{session:i}=await e.request(o.get,{sessionId:t});return(i?.agents.find(e=>e.agentId===i.leadAgentId)??i?.agents[0])?.adapterName?.trim()}function T(e,t){let n=e.manager.get(t.subagentId);if(!n)throw Error(`Subagent not found: ${t.subagentId}`);return{status:n.status,childSessionId:n.childSessionId,pendingRequest:n.pendingRequest?{messageId:n.pendingRequest.messageId,question:n.pendingRequest.question,context:n.pendingRequest.context}:void 0,progress:n.progressUpdates.toArray(),result:n.result,summary:n.summary,error:n.error,usage:n.usage}}async function E(e,t){let{parentSessionId:n,config:r,depth:i,spawningToolCallId:a}=t,{constraints:o}=e.manager,s=Math.min(r.maxDepth??o.maxDepth,o.maxDepth);if(i>s)throw new l(u.DEPTH_EXCEEDED,`Maximum subagent depth (${s}) exceeded`);if(e.manager.countActiveBySession(n)>=o.maxConcurrentPerSession)throw new l(u.SESSION_LIMIT,`Maximum concurrent subagents per session (${o.maxConcurrentPerSession}) reached`);if(e.manager.countTotalActive()>=o.maxTotalActive)throw new l(u.GLOBAL_LIMIT,`Maximum total active subagents (${o.maxTotalActive}) reached`);let c=await w(e.bus,n,r.adapterName);if(!c)throw new l(u.ADAPTER_NOT_ALLOWED,`adapterName is required for subagent spawn when parent session has no inheritable adapter`);if(o.allowedAdapters.length>0&&!o.allowedAdapters.includes(c))throw new l(u.ADAPTER_NOT_ALLOWED,`Adapter '${c}' is not allowed`);if(r.model&&o.allowedModels.length>0&&!o.allowedModels.includes(r.model))throw new l(u.MODEL_NOT_ALLOWED,`Model '${r.model}' is not allowed`);let f={...r,adapterName:c},p=crypto.randomUUID();return e.manager.track({subagentId:p,parentSessionId:n,config:f,depth:i}),await e.bus.emit(d.spawned,{subagentId:p,parentSessionId:n,task:f.task,config:f,depth:i,...e.executionOwnerId!==void 0&&{executionOwnerId:e.executionOwnerId},...a!==void 0&&{spawningToolCallId:a}}),{subagentId:p,status:`spawning`}}async function D(e,t){let{subagentId:n,timeoutMs:r}=t,i=e.manager.get(n);if(!i)throw Error(`Subagent not found: ${n}`);if([`completed`,`failed`,`cancelled`].includes(i.status))return{status:i.status,result:i.result,error:i.error,completionSource:i.completionSource,toolObservations:[...i.toolObservations],usage:i.usage};if(i.status===`waiting_input`&&i.pendingRequest)return{status:`waiting_input`,pendingRequest:{messageId:i.pendingRequest.messageId,question:i.pendingRequest.question,context:i.pendingRequest.context}};let a=r??e.manager.constraints.defaultAwaitTimeoutMs;return new Promise(t=>{let r=!1,i,o=e=>{r||(r=!0,i&&clearTimeout(i),t({status:e.status,result:e.result,error:e.error,pendingRequest:e.pendingRequest,completionSource:e.completionSource,toolObservations:e.toolObservations,usage:e.usage}))};e.manager.addAwaiter(n,o),a>0&&(i=setTimeout(()=>{r||(r=!0,e.manager.removeAwaiter(n,o),t({status:`timeout`}))},a))})}async function O(e,t){let{subagentId:n,content:r,inResponseTo:i}=t,a=e.manager.get(n);if(!a)throw Error(`Subagent not found: ${n}`);if(a.status===`spawning`)throw new l(u.INVALID_STATE,`Cannot send to a subagent before startup completes`);if(a.completionCandidate!==void 0)throw new l(u.INVALID_STATE,`Cannot send to a subagent while completion is pending`);let o=!1;return i&&a.pendingRequest?.messageId===i&&(e.manager.resolvePendingRequest(n,r),o=!0),await e.bus.emit(d.toChild,{subagentId:n,messageId:crypto.randomUUID(),content:r,inResponseTo:i}),{sent:!0,resolvedPending:o}}async function k(e,t){let{subagentId:n,reason:r}=t,i=e.manager.markCancelled(n);return i&&await e.bus.emit(d.cancelled,{subagentId:n,reason:r??`Killed by parent`}),{killed:i}}async function A(e,t){let{subagentId:n,update:r,percentComplete:i}=t;if(!e.manager.get(n))throw Error(`Subagent not found: ${n}`);let a=i===void 0?r:`[${i}%] ${r}`;return e.manager.addProgress(n,a),await e.bus.emit(d.toParent,{subagentId:n,messageId:crypto.randomUUID(),type:`progress`,content:a}),{reported:!0}}async function j(e,t){let{subagentId:n,question:r,context:i,timeoutMs:a}=t,o=e.manager.get(n);if(!o)throw Error(`Subagent not found: ${n}`);if(o.completionCandidate!==void 0)throw new l(u.INVALID_STATE,`Cannot request input while completion is pending`);let s=crypto.randomUUID(),c=a??e.manager.constraints.defaultRequestTimeoutMs,f=!1,p,m,h=new Promise(e=>{m=e});e.manager.setPendingRequest(n,{messageId:s,question:r,context:i,resolver:e=>{f||(f=!0,p&&clearTimeout(p),m(e===null?{responded:!1,timedOut:!0}:{responded:!0,response:e,timedOut:!1}))}}),c>0&&(p=setTimeout(()=>{f||e.manager.resolvePendingRequest(n,null)},c));let g=e.bus.emit(d.toParent,{subagentId:n,messageId:s,type:`request_input`,content:r,context:i}).then(()=>({published:!0}),e=>({published:!1,error:e})),_=await Promise.race([h.then(e=>({response:e})),g]);if(`response`in _)return _.response;if(!_.published)throw e.manager.resolvePendingRequest(n,null),_.error;return h}async function M(e,t){let{sessionId:n,turnId:r,result:i,summary:a}=t,o=e.manager.getByChildSessionId(n);if(o===void 0)throw new l(u.NOT_FOUND,`No subagent owns this child session`);if(o.status===`completed`||o.status===`failed`||o.status===`cancelled`)throw new l(u.ALREADY_TERMINAL,`Subagent already in terminal state: ${o.status}`);let s=o.activeTurnId;if(s===void 0)throw new l(u.INVALID_STATE,`No active turn exists for this child session`);if(r!==void 0&&r!==s)throw new l(u.INVALID_STATE,`Completion turn does not match the active child turn`);return e.manager.recordCompletionCandidate(o.subagentId,s,i,a,`tool`),await e.onCompletionCandidate?.(o.subagentId),{completed:!0}}function N(e,t){let{parentSessionId:n}=t;return{subagents:e.manager.getAllNonTerminal().filter(e=>e.parentSessionId===n).map(e=>({subagentId:e.subagentId,task:e.config.task,status:e.status}))}}function P(e,t,n,r){return{kind:`adapter`,adapterName:e,...n!==void 0&&{providerContext:n},...t.model!==void 0&&{model:t.model},...t.reasoningEffort!==void 0&&{reasoningEffort:t.reasoningEffort},...t.systemPrompt!==void 0&&{systemPrompt:t.systemPrompt},...t.adapterConfig!==void 0&&{adapterConfig:t.adapterConfig},...r!==void 0&&{cwd:r},...t.tools!==void 0&&{allowedTools:t.tools},...t.disallowedTools!==void 0&&{disallowedTools:t.disallowedTools},...t.allowedDirectories!==void 0&&{allowedDirectories:t.allowedDirectories}}}async function F(e,t){let{subagentId:n,adapterName:r,config:i,sessionId:a,task:s,targetWorkingDirectory:c,assertAdmission:l}=t,u=i.providerContext;if(u?.state===`resolved`&&i.providerConfigId!==void 0&&i.providerConfigId!==u.providerConfigId)throw Error(`Subagent providerConfigId "${i.providerConfigId}" does not match its resolved provider context "${u.providerConfigId}".`);if(u?.state===`unresolved`&&i.providerConfigId!==void 0)throw new g(`provider-context-unresolved`,r,i.providerConfigId);let d=u??(i.providerConfigId?await _(e,{adapterName:r,providerConfigId:i.providerConfigId}):void 0);await e.request(o.agent.attachResolved,{sessionId:a,role:`lead`,initialMessage:s,source:`system`,assertInitialMessageAdmission:()=>{try{l()}catch{throw Error(`Subagent startup was cancelled before initial task admission: ${n}`)}},...i.responseSchema!==void 0&&{responseSchema:i.responseSchema},...i.harnessId!==void 0&&{harnessId:i.harnessId},agent:P(r,i,d,c)},{timeout:0})}const I={id:`system:local`,name:`Local`,description:`Default local process execution`,type:`local`,scope:`default`,enabled:!0,createdAt:Date.now(),updatedAt:Date.now()};var L=class extends Error{code;constructor(e){super(`Subagent failure finalization failed (${e}).`),this.code=e,this.name=`SubagentFailureFinalizationError`}},R=class extends h{delegationAllowSet;requestHandlerPriority;executionOwnerId;manager;pendingChildSessionClose=new Set;spawningExecutions=new Set;constructor(e=m,t=a,n=new Set,r=0,i=crypto.randomUUID()){super(e),this.delegationAllowSet=n,this.requestHandlerPriority=r,this.executionOwnerId=i,this.manager=new C(t)}grantDelegation(e,t){this.delegationAllowSet.add(`${e}:${t}`)}revokeDelegation(e,t){this.delegationAllowSet.delete(`${e}:${t}`)}onInit(){this.registerHandler(d.spawned,async e=>{e.payload.executionOwnerId!==void 0&&e.payload.executionOwnerId!==this.executionOwnerId||this.handleSpawned(e.payload).catch(e=>{console.error(`[SubagentService] handleSpawned error:`,e)})}),this.registerHandler(d.execute,async e=>{if(!this.isRemoteDelegationAllowed(e))return;let t=await this.handleExecute(e.payload);e.setResult(t)}),this.registerHandler(d.toChild,async e=>{await this.handleToChild(e.payload)}),this.registerHandler(d.completed,async e=>{await this.handleCompleted(e.payload.subagentId)}),this.registerHandler(d.cancelled,async e=>{await this.handleCancelled(e.payload.subagentId)}),this.registerHandler(r.session.closed,e=>{this.handleAdapterSessionClosed(e.payload.sessionId)}),this.registerHandler(i.complete,async e=>{await this.handleAgentComplete(e.payload)}),this.registerHandler(o.turn.completed,async e=>{await this.handleSessionTurnCompleted(e.payload)}),this.registerHandler(o.turn.started,e=>{this.handleSessionTurnStarted(e.payload)}),this.registerHandler(i.tool.completed,e=>{e.payload._import||e.payload.sessionId===void 0||e.payload.success===void 0||this.manager.recordToolObservation(e.payload.sessionId,{toolName:e.payload.toolName,outcome:e.payload.success?`success`:`failure`,...e.payload.success===!0&&e.payload.artifactResult!==void 0?{artifact:e.payload.artifactResult}:{}},e.payload.toolCallId)}),this.registerRpcHandlers(),this.wirePeriodicSweep()}wirePeriodicSweep(){let{inactivityTimeoutMs:e,sweepIntervalMs:t}=this.manager.constraints;if(t<=0)return;let n=setInterval(()=>{let t=this.manager.sweepHung(e);t>0&&console.warn(`[SubagentService] Swept ${t} hung subagent(s) due to inactivity`),this.manager.cleanup()},t);this.addCleanup(()=>clearInterval(n))}registerRpcHandlers(){let e={manager:this.manager,bus:this.bus,executionOwnerId:this.executionOwnerId,onCompletionCandidate:e=>this.finalizeSubagentIfReady(e)};this.registerHandler(d.getStatus,t=>{let n=T(e,t.payload);t.setResult(n)},{priority:this.requestHandlerPriority}),this.registerHandler(d.spawn,async t=>{if(!this.isRemoteDelegationAllowed(t))return;let n=await E(e,s.parse(t.payload));t.setResult(n)},{priority:this.requestHandlerPriority}),this.registerHandler(d.await,async t=>{let n=await D(e,t.payload);t.setResult(n)},{priority:this.requestHandlerPriority}),this.registerHandler(d.send,async t=>{let n=await O(e,t.payload);t.setResult(n)}),this.registerHandler(d.kill,async t=>{let n=await k(e,t.payload);t.setResult(n)},{priority:this.requestHandlerPriority}),this.registerHandler(d.reportProgress,async t=>{let n=await A(e,t.payload);t.setResult(n)}),this.registerHandler(d.requestInput,async t=>{let n=await j(e,t.payload);t.setResult(n)}),this.registerHandler(d.completeTask,async t=>{let n=await M(e,t.payload);t.setResult(n)}),this.registerHandler(d.listBySession,t=>{let n=N(e,t.payload);t.setResult(n)})}onDestroy(){this.pendingChildSessionClose.clear(),this.spawningExecutions.clear()}async handleSpawned(e){let{subagentId:t,parentSessionId:n,task:r,spawningToolCallId:i}=e,a=this.manager.get(t);if(!(a&&a.status!==`spawning`)&&!this.spawningExecutions.has(t)){this.spawningExecutions.add(t);try{return await this.executeSpawned(e,n,r,i)}finally{this.spawningExecutions.delete(t)}}}async executeSpawned(e,n,r,i){let{subagentId:a}=e,o=()=>this.shouldAbortSpawn(this.manager.get(a)?.status),s=c.parse({...e.config,task:r}),l=s.adapterName?.trim();if(!l)return this.failSpawn(a,n,`adapter_start`,`Subagent spawn requires a non-empty adapterName`);this.manager.get(a)||this.manager.track({subagentId:a,parentSessionId:n,config:s,depth:e.depth??1});let u,d;try{d=await this.buildExecutionTargetResolutionParams(n,s.executionTargetId);let e=await this.bus.requestOptional(t.resolve,d),r;if(e.handled)r=e.data.executionTarget;else if(d.executionTargetId!=null)throw Error(`Execution target resolver unavailable for explicit target '${d.executionTargetId}'`);else r=I;if(r.type!==`local`)return this.failSpawn(a,n,`adapter_start`,`Execution target type '${r.type}' is not yet supported for subagents`);u=d.executionTargetId??void 0}catch(e){return this.failSpawn(a,n,`adapter_start`,e)}let f;try{f=await this.createChildSessionForSpawn(a,n,s,u,d,i)}catch(e){return this.failSpawn(a,n,`session_create`,e)}if(!o())return this.attachSpawnedSubagent({subagentId:a,parentSessionId:n,adapterName:l,config:s,sessionId:f,task:r,targetWorkingDirectory:d.targetWorkingDirectory,shouldAbort:o})}async attachSpawnedSubagent(e){let{subagentId:t,parentSessionId:r,adapterName:i,config:a,sessionId:o,task:s,targetWorkingDirectory:c,shouldAbort:l}=e;try{await F(this.bus,{subagentId:t,adapterName:i,config:a,sessionId:o,task:s,targetWorkingDirectory:c,assertAdmission:()=>{if(this.shouldAbortSpawn(this.manager.get(t)?.status))throw Error(`startup cancelled`)}})}catch(e){if(l())return;let i=n(e);return this.failSpawn(t,r,i?.stage===`initial_message`?`agent_start`:`adapter_start`,e)}l()||this.manager.markStarted(t)}async createChildSessionForSpawn(e,t,n,r,i,a){let{sessionId:s}=await this.bus.request(o.create,this.buildChildSessionCreatePayload(t,n,r,i.targetWorkingDirectory,a));return this.manager.setChildSessionId(e,s),this.pendingChildSessionClose.has(e)&&await this.closeChildSession(e),s}async failSpawn(e,t,n,r){let i=r instanceof Error?r:Error(String(r));this.manager.markFailed(e,i.message);let[a,o]=await Promise.allSettled([this.manager.get(e)?.childSessionId===void 0?Promise.resolve():this.requestChildSessionClose(e),this.emitExecutionFailed(e,t,n,i)]),s=[];if(a.status===`rejected`&&s.push(new L(`child-session-close-failed`)),o.status===`rejected`&&s.push(new L(`failure-publication-failed`)),s.length>0)throw AggregateError([i,...s],`Subagent spawn failed and failure finalization also failed.`);return i.message}async buildExecutionTargetResolutionParams(t,n){if(n!==void 0)return{executionTargetId:n};let{session:r}=await this.bus.request(e.get,{sessionId:t});if(!r)throw Error(`Parent session not found: ${t}`);return{...r.executionTargetId!==void 0&&{executionTargetId:r.executionTargetId},...r.targetWorkingDirectory!==void 0&&{targetWorkingDirectory:r.targetWorkingDirectory}}}buildChildSessionCreatePayload(e,t,n,r,i){return{branchKind:`subagent`,parentSessionId:e,contextInheritance:t.contextMode===`fork`?`parent-history`:`none`,...n!==void 0&&{executionTargetId:n},...r!==void 0&&{targetWorkingDirectory:r},...i!==void 0&&{spawningToolCallId:i}}}async handleExecute(e){let t=c.parse({...e.config,task:e.task});this.manager.track({subagentId:e.subagentId,parentSessionId:e.parentSessionId,config:t,depth:e.depth});let n=await this.handleSpawned({subagentId:e.subagentId,parentSessionId:e.parentSessionId,task:e.task,config:t,depth:e.depth});return n?{success:!1,error:n}:{success:!0}}async handleToChild(e){let{subagentId:t,content:n}=e,r=this.manager.get(t);if(!r){console.warn(`[SubagentService] No subagent found: ${t}`);return}if(!r.childSessionId){console.warn(`[SubagentService] No child session for subagent: ${t}`);return}try{await this.bus.request(o.sendMessage,{sessionId:r.childSessionId,message:n,source:`system`})}catch(e){console.error(`[SubagentService] Failed to route message to child session:`,e)}}async handleCompleted(e){await this.closeChildSession(e)}async handleCancelled(e){await this.closeChildSession(e)}async closeChildSession(e){try{await this.requestChildSessionClose(e)}catch{console.error(`[SubagentService] Failed to close child session for subagent ${e}:`,new L(`child-session-close-failed`))}}async requestChildSessionClose(e){let t=this.manager.get(e);if(t){if(!t.childSessionId){this.pendingChildSessionClose.add(e);return}this.pendingChildSessionClose.delete(e),await this.bus.request(o.close,{sessionId:t.childSessionId})}}shouldAbortSpawn(e){return e===void 0||e===`completed`||e===`failed`||e===`cancelled`}handleAdapterSessionClosed(e){for(let t of this.manager.getAllNonTerminal())if(t.childSessionId===e){console.warn(`[SubagentService] Adapter session closed for subagent ${t.subagentId}: ${e}`),this.manager.markFailed(t.subagentId,`adapter-session-closed`);return}}async handleAgentComplete(e){let{sessionId:t,turnId:n,outcome:r,message:i,error:a}=e;if(!(!t||!n))for(let e of this.manager.getAllNonTerminal()){if(e.childSessionId!==t)continue;if((e.config.completion??`tool`)!==`turn`||e.status===`waiting_input`)return;let o=r??`completed`;if(o===`completed`)try{this.manager.recordCompletionCandidate(e.subagentId,n,i??``,void 0,`turn`),await this.finalizeSubagentIfReady(e.subagentId)}catch{return}else if(o===`error`)try{this.manager.recordCompletionCandidate(e.subagentId,n,a??`child turn failed`,void 0,`turn`),await this.finalizeSubagentIfReady(e.subagentId)}catch{return}return}}async handleSessionTurnCompleted(e){if(e.ingestionMarker!==`backfill`){for(let t of this.manager.getAllNonTerminal())if(t.childSessionId===e.sessionId){if(this.manager.recordTurnCompleted(e.sessionId,e.turnId),this.manager.recordCompletedTurn(t.subagentId,e.turnId,e.usage,e.success,e.error),t.completionCandidate?.turnId!==e.turnId)return;await this.finalizeSubagentIfReady(t.subagentId);return}}}handleSessionTurnStarted(e){e.ingestionMarker!==`backfill`&&this.manager.recordTurnStarted(e.sessionId,e.turnId)}async finalizeSubagentIfReady(e){if(!this.manager.finalizeCompletionIfReady(e))return;let t=this.manager.get(e);await this.bus.emit(d.completed,{subagentId:e,success:t?.status===`completed`,...t?.status===`completed`?{result:t.summary?`${t.summary}\n\n${t.result??``}`:t?.result,usage:t.usage}:{error:t?.error??`child turn failed`}})}isRemoteDelegationAllowed(e){return e.origin.local||y(e.transport?.peer,this.delegationAllowSet)}async emitExecutionFailed(e,t,n,r){let i=r instanceof Error?r.message:String(r);await this.bus.emit(d.executionFailed,{subagentId:e,parentSessionId:t,phase:n,error:i})}};const z=p(`subagent-service`);function B(e=0){return{name:z.name,displayName:`Subagent Service`,version:`0.1.0`,critical:!0,surface:`headless`,dependencies:[f(`session`)],create:t=>new R(t.bus,a,new Set,e)}}const V=B();export{R as a,L as i,B as n,C as o,V as r,y as s,z as t};
@@ -1,4 +1,4 @@
1
- import{$ as e,A as t,Ct as n,F as r,G as i,H as a,I as o,J as s,K as c,L as l,M as u,N as d,P as f,Q as p,R as m,St as ee,U as te,V as ne,W as h,X as re,Y as ie,Z as ae,_ as oe,_t as se,a as ce,at as le,bt as ue,c as de,ct as fe,dt as pe,et as me,f as he,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as xe,it as Se,j as Ce,k as we,l as Te,lt as Ee,m as De,mt as Oe,n as ke,nt as Ae,o as je,ot as Me,p as Ne,pt as Pe,q as g,r as Fe,rt as Ie,st as Le,tt as Re,u as ze,ut as Be,vt as Ve,xt as He,y as Ue,yt as We,z as Ge}from"./authority-state-bootstrap-DVFYemDL.mjs";import{d as Ke,f as qe,p as Je}from"./execution-attempt-repository-CWbgCTwA.mjs";import{assertWorkflowTriggerPayload as Ye,compileWorkflowTriggerBindingFilter as Xe}from"./workflow-engine/workflow-trigger-binding-consumer.mjs";import{a as Ze,r as Qe}from"./execution-attempt-owner-recovery-D4APLAvt.mjs";import{SerialLane as $e}from"@makaio/framework/utils";import{ArtifactSubjects as et,AutomationTriggerSubjects as tt,CRON_AUTOMATION_TRIGGER_KIND as nt,EXECUTION_LIST_DEFAULT_LIMIT as rt,EXECUTION_LIST_MAX_LIMIT as _,EXECUTION_LIST_MIN_LIMIT as v,EXTERNAL_EXECUTION_ID_PREFIX as y,ExecutionAttemptSchemas as b,ExecutionAttemptSubjects as x,ExecutionsByArtifactRefsQuerySchema as it,JsonPatchOperationSchema as at,JsonValueSchema as ot,SessionSubjects as st,WORKFLOW_CANCELLED_REASON as ct,WorkLogFrameEntrySchema as lt,WorkerSubjects as ut,WorkflowAutomationTriggerBindingSchema as dt,WorkflowError as S,WorkflowErrorCode as ft,WorkflowNamespace as pt,WorkflowRunContextSchema as mt,WorkflowRunResultSchema as ht,WorkflowStepTypeSchema as gt,WorkflowSubjects as C,createWorkflowCancelSubject as _t,createWorkflowDelegateResultFinalizerNamespace as vt,createWorkflowFinalizerNamespace as yt,dep as bt,extensionToken as xt,serializeArtifactRef as St,walkWorkflowDefinition as Ct}from"@makaio/framework/contracts";import{BaseService as wt}from"@makaio/framework/service-base";import{defineDialectSchema as Tt,executeTransaction as w,getDatabaseDialect as Et,registerDrizzleHandlers as Dt,resolveSchema as T,serializeDatabaseOperation as E}from"@makaio/framework/storage/drizzle";import{and as D,asc as O,count as k,desc as A,eq as j,getTableColumns as Ot,gte as kt,isNotNull as At,isNull as M,lt as jt,lte as Mt,notInArray as Nt,or as Pt,sql as N,sum as P}from"drizzle-orm";import{SessionToken as Ft}from"@makaio/framework/services";import{AutomationTriggerBindingRuntimeToken as It}from"@makaio/framework/services/automation-trigger";const Lt=ie.postgres,Rt=le.postgres,zt=ae.postgres,Bt=Le.postgres,Vt=pe.postgres,Ht=e.postgres,Ut=Ee.postgres,Wt=We.postgres,Gt=be.postgres,Kt=Pe.postgres,qt=se.postgres,Jt=Re.postgres,Yt=Ie.postgres,Xt=He.postgres,F=Tt({workflowDefinitions:s,workflowExecutions:Se,workflowExecutionFrames:re,workflowGateInstances:Me,workflowStepSpans:Be,workflowExecutionLinks:p,workflowRunContexts:fe,worklogSummaries:Ve,worklogFrameEntries:Oe,worklogArtifactWrites:ge,worklogGateEvents:ve,workflowExecutionState:me,workflowExecutionStateEvents:Ae,workflowFinalizations:ue},{workflowDefinitions:Lt,workflowExecutions:Rt,workflowExecutionFrames:zt,workflowGateInstances:Bt,workflowStepSpans:Vt,workflowExecutionLinks:Ht,workflowRunContexts:Ut,worklogSummaries:Wt,worklogFrameEntries:Gt,worklogArtifactWrites:Kt,worklogGateEvents:qt,workflowExecutionState:Jt,workflowExecutionStateEvents:Yt,workflowFinalizations:Xt});function I(e){return e.type===`global`?{scopeType:`global`,scopeKind:``,scopeId:``}:e.type===`external`?{scopeType:`external`,scopeKind:e.kind,scopeId:e.id}:{scopeType:e.type,scopeKind:``,scopeId:e.id}}function L(e){switch(e.scopeType){case`global`:return{type:`global`};case`external`:if(!e.scopeKind||!e.scopeId)throw Error(`Invalid external workflow scope row: scopeKind and scopeId are required`);return{type:`external`,kind:e.scopeKind,id:e.scopeId};case`workspace`:case`session`:if(!e.scopeId)throw Error(`Invalid ${e.scopeType} workflow scope row: scopeId is required`);return{type:e.scopeType,id:e.scopeId};default:{let t=e.scopeType;throw Error(`Unknown scope type: ${String(t)}`)}}}function Zt(e,t){let{scopeType:n,scopeKind:r,scopeId:i}=I(t);return[j(e.scopeType,n),j(e.scopeKind,r),j(e.scopeId,i)]}function R(e){return{id:e.id,name:e.name,description:e.description??void 0,root:e.root,inputSchema:e.inputSchema??void 0,configSchema:e.configSchema??void 0,outputSchema:e.outputSchema??void 0,state:e.state??void 0,artifact:e.artifact??void 0,triggers:e.triggers??void 0,scope:L(e),canvasLayout:e.canvasLayout??void 0,source:e.source??void 0,executableSource:e.executableSource??void 0,requirements:e.requirements??void 0,successFinalizerId:e.successFinalizerId??void 0}}function Qt(e,t){let n=I(e.scope);return{id:e.id,name:e.name??e.id,root:e.root,description:e.description??null,inputSchema:e.inputSchema??null,configSchema:e.configSchema??null,outputSchema:e.outputSchema??null,state:e.state??null,artifact:e.artifact??null,triggers:e.triggers??null,canvasLayout:e.canvasLayout??null,source:e.source??null,executableSource:e.executableSource??null,requirements:e.requirements??null,successFinalizerId:e.successFinalizerId??null,createdAt:t,updatedAt:t,...n}}function $t(e,t){let{workflowDefinitions:r}=T(t,F),i=Ot(r),a=e.on(g.get,async e=>{let n=await t.select().from(r).where(j(r.id,e.payload.id)).limit(1);e.setResult({workflow:n[0]?R(n[0]):null})}),o=e.on(g.set,async a=>{let o=a.payload.workflow,s=Date.now(),c=Qt(o,s),l=await E(t,async()=>{let e=await t.insert(r).values(c).onConflictDoNothing({target:r.id}).returning();if(e.length>0)return{kind:`created`,row:e[0]};let[n]=await t.update(r).set({name:c.name,root:c.root,updatedAt:s,createdAt:N`COALESCE(${i.createdAt}, ${s})`,description:c.description===null?N`${i.description}`:c.description,inputSchema:c.inputSchema===null?N`${i.inputSchema}`:c.inputSchema,configSchema:c.configSchema===null?N`${i.configSchema}`:c.configSchema,outputSchema:c.outputSchema===null?N`${i.outputSchema}`:c.outputSchema,state:c.state,artifact:c.artifact===null?N`${i.artifact}`:c.artifact,triggers:c.triggers===null?N`${i.triggers}`:c.triggers,canvasLayout:c.canvasLayout===null?N`${i.canvasLayout}`:c.canvasLayout,source:c.source===null?N`${i.source}`:c.source,executableSource:c.executableSource,requirements:c.requirements,successFinalizerId:c.successFinalizerId,...I(o.scope)}).where(j(r.id,o.id)).returning();return n?{kind:`updated`,row:n}:void 0});l&&await e.emit(l.kind===`created`?n.definition.created:n.definition.updated,R(l.row)),a.setResult({id:o.id})}),s=e.on(g.delete,async i=>{let a=(await E(t,()=>t.delete(r).where(j(r.id,i.payload.id)).returning())).length>0;a&&await e.emit(n.definition.deleted,{id:i.payload.id}),i.setResult({deleted:a})}),c=e.on(g.list,async e=>{let n=e.payload,i=n.scope?Zt(r,n.scope):[],a=i.length>0?await t.select().from(r).where(D(...i)):await t.select().from(r);e.setResult({workflows:a.map(R)})});return()=>{a(),o(),s(),c()}}function en(e){return{frameId:e.frameId,nodeId:e.nodeId,nodeType:e.nodeType,path:e.path,parentFrameId:e.parentFrameId??void 0,status:e.status,attempt:e.attempt,iteration:e.iteration??void 0,branchKey:e.branchKey??void 0,...e.outputPresent?{output:e.output}:{},error:e.error??void 0,startedAt:e.startedAt??void 0,completedAt:e.completedAt??void 0}}function tn(e,t){return{frameId:t.frameId,executionId:e,nodeId:t.nodeId,nodeType:t.nodeType,path:t.path,parentFrameId:t.parentFrameId??null,status:t.status,attempt:t.attempt,iteration:t.iteration??null,branchKey:t.branchKey??null,output:t.output===void 0?null:t.output,outputPresent:t.output!==void 0,error:t.error??null,startedAt:t.startedAt??null,completedAt:t.completedAt??null}}function nn(e,t){let{workflowExecutionFrames:n}=T(t,F),r=e.on(g.setFrame,async e=>{let{executionId:r,frame:i}=e.payload;if(!h(e,r))throw Error(`Unauthorized: caller is not permitted to write frames for execution: ${r}`);let a=tn(r,i);await E(t,()=>t.insert(n).values(a).onConflictDoUpdate({target:n.frameId,set:a})),e.setResult({frameId:i.frameId})}),i=e.on(g.getFrame,async e=>{let r=await t.select().from(n).where(j(n.frameId,e.payload.frameId)).limit(1);e.setResult({frame:r[0]?en(r[0]):null})}),a=e.on(g.listFrames,async e=>{if(!h(e,e.payload.executionId))throw Error(`Unauthorized: caller is not permitted to list frames for execution: ${e.payload.executionId}`);let r=await t.select().from(n).where(j(n.executionId,e.payload.executionId)).orderBy(O(n.startedAt),O(n.frameId));e.setResult({frames:r.map(en)})});return()=>{r(),i(),a()}}function rn(e){return`${e.executionId}:${e.nodeId}:${e.frameId}`}function z(e){return{executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,schema:e.schema,prompt:e.prompt??void 0,status:e.status,autoAction:e.autoAction,timeoutMs:e.timeoutMs??null,...e.resumeDataPresent?{resumeData:e.resumeData}:{},...e.reason===null?{}:{reason:e.reason},createdAt:e.createdAt,resolvedAt:e.resolvedAt??void 0}}function B(e){return{id:rn(e),executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,schema:e.schema,prompt:e.prompt??null,status:e.status,autoAction:e.autoAction,timeoutMs:e.timeoutMs,resumeData:e.resumeData===void 0?null:e.resumeData,reason:e.reason??null,resumeDataPresent:e.resumeData!==void 0,createdAt:e.createdAt,resolvedAt:e.resolvedAt??null}}function an(e,t,n,r){if(e===void 0&&t===void 0)throw Error(`Either executionId or status is required to list gate instances.`);let i=n??rt;if(!Number.isInteger(i)||i<v||i>_)throw Error(`Gate instance list limit must be an integer between ${v} and ${_}.`);return{resolvedLimit:i,predicates:[...e===void 0?[]:[j(r.executionId,e)],...t===void 0?[]:[j(r.status,t)]]}}function on(e,t){let{workflowExecutions:n,workflowGateInstances:r}=T(t,F),i=e.on(g.setGateInstance,async e=>{let n=e.payload.gate;if(!h(e,n.executionId))throw Error(`Unauthorized: caller is not permitted to write gates for execution: ${n.executionId}`);let i=B(n);await E(t,()=>t.insert(r).values(i).onConflictDoUpdate({target:r.id,set:i})),e.setResult({id:i.id})}),a=e.on(g.resolveWaitingGateInstance,async e=>{let n=e.payload.gate,i=B(n),a=await E(t,()=>t.update(r).set(i).where(D(j(r.id,i.id),j(r.status,`waiting`))).returning({id:r.id}));e.setResult({accepted:a.length===1})}),o=e.on(g.getGateInstance,async e=>{let{executionId:n,nodeId:i,frameId:a}=e.payload;if(!h(e,n))throw Error(`Unauthorized: caller is not permitted to read gates for execution: ${n}`);let o=[j(r.executionId,n),j(r.nodeId,i)];a!==void 0&&o.push(j(r.frameId,a));let s=await t.select().from(r).where(D(...o)).limit(1);e.setResult({gate:s[0]?z(s[0]):null})}),s=e.on(g.listGateInstances,async e=>{let{executionId:n,status:i,limit:a}=e.payload,{resolvedLimit:o,predicates:s}=an(n,i,a,r),c=await t.select().from(r).where(D(...s)).orderBy(A(r.createdAt),A(r.id)).limit(o);e.setResult({gates:c.map(z)})}),c=e.on(g.listPausedGateTimeouts,async e=>{let i=await t.select({gate:r}).from(r).innerJoin(n,j(r.executionId,n.id)).where(D(j(r.status,`waiting`),j(n.status,`paused`),At(r.timeoutMs)));e.setResult({gates:i.map(e=>z(e.gate))})});return()=>{i(),a(),o(),s(),c()}}function sn(e){return{executionId:e.executionId,frameId:e.frameId,stepId:e.stepId,stepType:e.stepType,status:e.status,startedAt:e.startedAt??void 0,completedAt:e.completedAt??void 0,durationMs:e.durationMs??void 0,inputTokens:e.inputTokens??void 0,outputTokens:e.outputTokens??void 0,estimatedCost:e.estimatedCost??void 0,toolCallCount:e.toolCallCount??void 0,input:e.input??void 0,output:e.output??void 0}}function cn(e){return{sourceExecutionId:e.sourceExecutionId,targetExecutionId:e.targetExecutionId,linkType:e.linkType,metadata:e.metadata??void 0}}function ln(e,t){let{workflowStepSpans:n,workflowExecutionLinks:r}=T(t,F),i=e.on(g.setSpan,async e=>{let{span:r}=e.payload;if(!h(e,r.executionId))throw Error(`Unauthorized: caller is not permitted to write spans for execution: ${r.executionId}`);await E(t,()=>t.insert(n).values(r).onConflictDoUpdate({target:[n.executionId,n.frameId],set:r})),e.setResult({id:`${r.executionId}:${r.frameId}`})}),a=e.on(g.listSpans,async e=>{let r=await t.select().from(n).where(j(n.executionId,e.payload.executionId)).orderBy(O(n.startedAt),O(n.stepId),O(n.frameId));e.setResult({spans:r.map(sn)})}),o=e.on(g.setExecutionLink,async e=>{let{link:n}=e.payload;await E(t,()=>t.insert(r).values(n).onConflictDoUpdate({target:[r.sourceExecutionId,r.targetExecutionId],set:n})),e.setResult({id:`${n.sourceExecutionId}:${n.targetExecutionId}`})}),s=e.on(g.listExecutionLinks,async e=>{let{sourceExecutionId:n,targetExecutionId:i}=e.payload;if(n===void 0&&i===void 0)throw Error(`Either sourceExecutionId or targetExecutionId is required to list execution links.`);let a=[...n===void 0?[]:[j(r.sourceExecutionId,n)],...i===void 0?[]:[j(r.targetExecutionId,i)]],o=t.select().from(r).where(D(...a));e.setResult({links:(await o).map(cn)})});return()=>{i(),a(),o(),s()}}function V(e,t){return t===null?Et(e)===`postgres`?N`'null'::jsonb`:N`'null'`:t}function un(e){switch(e.kind){case`path`:return{sourceKind:`path`,sourcePath:e.path,sourceFilename:null,sourceCode:null};case`source`:return{sourceKind:`source`,sourcePath:null,sourceFilename:e.filename,sourceCode:e.source};case`definition`:return{sourceKind:`definition`,sourcePath:null,sourceFilename:null,sourceCode:null}}}function dn(e){switch(e.sourceKind){case`path`:if(!e.sourcePath)throw Error(`Invalid run context row: sourcePath required for kind=path`);return{kind:`path`,path:e.sourcePath};case`source`:if(!e.sourceFilename)throw Error(`Invalid run context row: sourceFilename required for kind=source`);return{kind:`source`,filename:e.sourceFilename,source:e.sourceCode??``};case`definition`:return{kind:`definition`,workflowId:e.workflowId};default:throw Error(`Unknown run context source kind: ${String(e.sourceKind)}`)}}function fn(e){return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,source:dn(e),definitionSnapshot:e.definitionSnapshot??void 0,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,triggerMode:e.triggerMode,...e.artifactRef===null?{}:{artifactRef:e.artifactRef},scope:L(e),...e.dispatchMetadata===null?{}:{dispatchMetadata:e.dispatchMetadata},cancelSubject:e.cancelSubject,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy??`wait-in-process`,...e.terminalAuthority===null?{}:{terminalAuthority:e.terminalAuthority},...e.materializationSpec===null?{}:{materializationSpec:e.materializationSpec}}}function pn(e){let t=un(e.source),n=I(e.scope);return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,...t,definitionSnapshot:e.definitionSnapshot??null,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,triggerMode:e.triggerMode??`immediate`,artifactRef:e.artifactRef??null,dispatchMetadata:e.dispatchMetadata??null,...n,cancelSubject:e.cancelSubject,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy,terminalAuthority:e.terminalAuthority??null,materializationSpec:e.materializationSpec??null}}async function mn(e,t,n){let r=pn(t);await e.insert(n).values(r).onConflictDoUpdate({target:n.executionId,set:r})}function hn(e,t){let{workflowRunContexts:n,workflowExecutionState:r,workflowExecutionStateEvents:i}=T(t,F),a=e.on(g.setRunContext,async e=>{let a=e.payload.runContext,o=e.payload.initialState;await w(t,async e=>{if(await mn(e,a,n),o===void 0)return;let s=Date.now(),c=V(t,o);await e.insert(r).values({executionId:a.executionId,sequence:0,value:c,updatedAt:s}).onConflictDoNothing(),await e.insert(i).values({executionId:a.executionId,sequence:0,patch:[],value:c,createdAt:s}).onConflictDoNothing()}),e.setResult({executionId:a.executionId})}),o=e.on(g.getRunContext,async e=>{let{executionId:r}=e.payload,i=await t.select().from(n).where(j(n.executionId,r)),a=i[0]?fn(i[0]):null;e.setResult({runContext:a})});return()=>{a(),o()}}async function gn(e,t,n){let{workflowExecutionState:r,workflowExecutionStateEvents:i}=T(e,F),a=Date.now(),o=V(e,n);await w(e,async e=>{await e.insert(r).values({executionId:t,sequence:0,value:o,updatedAt:a}).onConflictDoNothing(),await e.insert(i).values({executionId:t,sequence:0,patch:[],value:o,createdAt:a}).onConflictDoNothing()})}async function _n(e,t){let{workflowExecutionState:n}=T(e,F),r=(await e.select().from(n).where(j(n.executionId,t)).limit(1))[0];return r?{executionId:r.executionId,sequence:r.sequence,value:r.value}:null}async function vn(e,t){let{workflowExecutionState:n,workflowExecutionStateEvents:r}=T(e,F),i=Date.now(),a=V(e,t.nextValue);return w(e,async e=>{let o=(await e.select().from(n).where(j(n.executionId,t.executionId)).limit(1))[0];if(!o)throw Error(`no workflow state for execution ${t.executionId}`);if(t.expectedSequence===void 0)throw Error(`expectedSequence is required to patch workflow state`);let s=o.sequence+1,c=te(o.value,t.nextValue);if((await e.update(n).set({sequence:s,value:a,updatedAt:i}).where(D(j(n.executionId,t.executionId),j(n.sequence,t.expectedSequence))).returning()).length===0)throw Error(`state sequence conflict: expected ${String(t.expectedSequence)}, got ${String(o.sequence)}`);return await e.insert(r).values({executionId:t.executionId,sequence:s,patch:c,value:a,createdAt:i}),{executionId:t.executionId,sequence:s,patch:c,value:t.nextValue}})}function yn(e,t){let n=e.on(g.initializeState,async e=>{let{executionId:n,initialValue:r}=e.payload;await gn(t,n,r),e.setResult({})}),r=e.on(g.getState,async e=>{let{executionId:n}=e.payload,r=await _n(t,n);e.setResult({state:r})}),i=e.on(g.patchState,async e=>{let{executionId:n,expectedSequence:r,nextValue:i}=e.payload,a=await vn(t,{executionId:n,expectedSequence:r,nextValue:i});e.setResult(a)});return()=>{n(),r(),i()}}function bn(e){return{executionId:e.executionId,workflowId:e.workflowId,workflowName:e.workflowName??void 0,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt??void 0,durationMs:e.durationMs??void 0,totalInputTokens:e.totalInputTokens??void 0,totalOutputTokens:e.totalOutputTokens??void 0,totalEstimatedCost:e.totalEstimatedCost??void 0,error:e.error??void 0,failedNodeId:e.failedNodeId??void 0}}async function xn(e,t){let{worklogSummaries:n}=T(e,F);await e.insert(n).values(t).onConflictDoNothing()}async function Sn(e,t){let{worklogSummaries:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.executionId,set:Cn(t),setWhere:Nt(n.status,[`completed`,`failed`,`cancelled`])})}function Cn(e){return{workflowId:e.workflowId,workflowName:e.workflowName,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt,durationMs:e.durationMs,error:e.error,failedNodeId:e.failedNodeId}}async function H(e,t){let{worklogSummaries:n}=T(e,F),r=await e.select().from(n).where(j(n.executionId,t)).limit(1);return r[0]?bn(r[0]):null}async function wn(e,t={}){let{worklogSummaries:n}=T(e,F),{workflowId:r,status:i,limit:a=50,offset:o=0}=t,s=[...r===void 0?[]:[j(n.workflowId,r)],...i===void 0?[]:[j(n.status,i)]],c=s.length>0?D(...s):void 0,[l,u]=await Promise.all([e.select().from(n).where(c).orderBy(A(n.startedAt)).limit(a).offset(o),e.select({count:k()}).from(n).where(c)]);return{items:l.map(bn),total:u[0]?.count??0}}async function Tn(e,t){let{worklogFrameEntries:n}=T(e,F);await e.insert(n).values(t).onConflictDoNothing()}async function En(e,t){let{worklogFrameEntries:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.frameId,set:t,setWhere:Nt(n.status,[`completed`,`failed`,`skipped`,`cancelled`])})}async function U(e,t){let{worklogFrameEntries:n}=T(e,F);return(await e.select().from(n).where(j(n.frameId,t)).limit(1))[0]??null}async function Dn(e,t){let n=await U(e,t);return n===null?null:lt.parse({executionId:n.executionId,frameId:n.frameId,nodeId:n.nodeId,nodeType:n.nodeType,path:n.path,status:n.status,attempt:n.attempt,iteration:n.iteration??void 0,branchKey:n.branchKey??void 0,startedAt:n.startedAt??void 0,completedAt:n.completedAt??void 0,durationMs:n.durationMs??void 0,inputTokens:n.inputTokens??void 0,outputTokens:n.outputTokens??void 0,estimatedCost:n.estimatedCost??void 0,error:n.error??void 0})}async function On(e,t){let{worklogArtifactWrites:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}function kn(e,t,n,r,i){return`${e}:${t}:${n}:${r}:${i}`}async function W(e,t){let{worklogGateEvents:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}async function An(e,t){let{worklogGateEvents:n}=T(e,F);return(await e.select().from(n).where(j(n.id,t)).limit(1))[0]??null}function G(e,t,n){return`${e}:${t}:${n}`}async function jn(e,t,n){let[r]=await e.update(t).set({totalInputTokens:t.totalInputTokens}).where(j(t.executionId,n)).returning();return r}async function Mn(e,t,n){let[r]=await e.select({totalInputTokens:P(t.inputTokens),totalOutputTokens:P(t.outputTokens),totalEstimatedCost:P(t.estimatedCost),measuredInputTokens:k(t.inputTokens),measuredOutputTokens:k(t.outputTokens),measuredCosts:k(t.estimatedCost)}).from(t).where(j(t.executionId,n));return{totalInputTokens:Number(r?.totalInputTokens??0),totalOutputTokens:Number(r?.totalOutputTokens??0),totalEstimatedCost:Number(r?.totalEstimatedCost??0),hasMeasurements:Number(r?.measuredInputTokens??0)>0||Number(r?.measuredOutputTokens??0)>0||Number(r?.measuredCosts??0)>0}}function Nn(e){return e.hasMeasurements}async function Pn(e,t,n,r){await e.update(t).set({totalInputTokens:r.totalInputTokens,totalOutputTokens:r.totalOutputTokens,totalEstimatedCost:r.totalEstimatedCost}).where(j(t.executionId,n))}async function Fn(e,t,n,r){let i=N`coalesce((select sum(${n.inputTokens}) from ${n} where ${n.executionId} = ${r}), 0)`,a=N`coalesce((select sum(${n.outputTokens}) from ${n} where ${n.executionId} = ${r}), 0)`,o=N`coalesce((select sum(${n.estimatedCost}) from ${n} where ${n.executionId} = ${r}), 0)`,s=N`exists(
1
+ import{$ as e,A as t,Ct as n,F as r,G as i,H as a,I as o,J as s,K as c,L as l,M as u,N as d,P as f,Q as p,R as m,St as ee,U as te,V as ne,W as h,X as re,Y as ie,Z as ae,_ as oe,_t as se,a as ce,at as le,bt as ue,c as de,ct as fe,dt as pe,et as me,f as he,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as xe,it as Se,j as Ce,k as we,l as Te,lt as Ee,m as De,mt as Oe,n as ke,nt as Ae,o as je,ot as Me,p as Ne,pt as Pe,q as g,r as Fe,rt as Ie,st as Le,tt as Re,u as ze,ut as Be,vt as Ve,xt as He,y as Ue,yt as We,z as Ge}from"./authority-state-bootstrap-CV7HpB4v.mjs";import{d as Ke,f as qe,p as Je}from"./execution-attempt-repository-aabFKcXN.mjs";import{assertWorkflowTriggerPayload as Ye,compileWorkflowTriggerBindingFilter as Xe}from"./workflow-engine/workflow-trigger-binding-consumer.mjs";import{a as Ze,r as Qe}from"./execution-attempt-owner-recovery-CE_rvHKE.mjs";import{SerialLane as $e}from"@makaio/framework/utils";import{ArtifactSubjects as et,AutomationTriggerSubjects as tt,CRON_AUTOMATION_TRIGGER_KIND as nt,EXECUTION_LIST_DEFAULT_LIMIT as rt,EXECUTION_LIST_MAX_LIMIT as _,EXECUTION_LIST_MIN_LIMIT as v,EXTERNAL_EXECUTION_ID_PREFIX as y,ExecutionAttemptSchemas as b,ExecutionAttemptSubjects as x,ExecutionsByArtifactRefsQuerySchema as it,JsonPatchOperationSchema as at,JsonValueSchema as ot,SessionSubjects as st,WORKFLOW_CANCELLED_REASON as ct,WorkLogFrameEntrySchema as lt,WorkerSubjects as ut,WorkflowAutomationTriggerBindingSchema as dt,WorkflowError as S,WorkflowErrorCode as ft,WorkflowNamespace as pt,WorkflowRunContextSchema as mt,WorkflowRunResultSchema as ht,WorkflowStepTypeSchema as gt,WorkflowSubjects as C,createWorkflowCancelSubject as _t,createWorkflowDelegateResultFinalizerNamespace as vt,createWorkflowFinalizerNamespace as yt,dep as bt,extensionToken as xt,serializeArtifactRef as St,walkWorkflowDefinition as Ct}from"@makaio/framework/contracts";import{BaseService as wt}from"@makaio/framework/service-base";import{defineDialectSchema as Tt,executeTransaction as w,getDatabaseDialect as Et,registerDrizzleHandlers as Dt,resolveSchema as T,serializeDatabaseOperation as E}from"@makaio/framework/storage/drizzle";import{and as D,asc as O,count as k,desc as A,eq as j,getTableColumns as Ot,gte as kt,isNotNull as At,isNull as M,lt as jt,lte as Mt,notInArray as Nt,or as Pt,sql as N,sum as P}from"drizzle-orm";import{SessionToken as Ft}from"@makaio/framework/services";import{AutomationTriggerBindingRuntimeToken as It}from"@makaio/framework/services/automation-trigger";const Lt=ie.postgres,Rt=le.postgres,zt=ae.postgres,Bt=Le.postgres,Vt=pe.postgres,Ht=e.postgres,Ut=Ee.postgres,Wt=We.postgres,Gt=be.postgres,Kt=Pe.postgres,qt=se.postgres,Jt=Re.postgres,Yt=Ie.postgres,Xt=He.postgres,F=Tt({workflowDefinitions:s,workflowExecutions:Se,workflowExecutionFrames:re,workflowGateInstances:Me,workflowStepSpans:Be,workflowExecutionLinks:p,workflowRunContexts:fe,worklogSummaries:Ve,worklogFrameEntries:Oe,worklogArtifactWrites:ge,worklogGateEvents:ve,workflowExecutionState:me,workflowExecutionStateEvents:Ae,workflowFinalizations:ue},{workflowDefinitions:Lt,workflowExecutions:Rt,workflowExecutionFrames:zt,workflowGateInstances:Bt,workflowStepSpans:Vt,workflowExecutionLinks:Ht,workflowRunContexts:Ut,worklogSummaries:Wt,worklogFrameEntries:Gt,worklogArtifactWrites:Kt,worklogGateEvents:qt,workflowExecutionState:Jt,workflowExecutionStateEvents:Yt,workflowFinalizations:Xt});function I(e){return e.type===`global`?{scopeType:`global`,scopeKind:``,scopeId:``}:e.type===`external`?{scopeType:`external`,scopeKind:e.kind,scopeId:e.id}:{scopeType:e.type,scopeKind:``,scopeId:e.id}}function L(e){switch(e.scopeType){case`global`:return{type:`global`};case`external`:if(!e.scopeKind||!e.scopeId)throw Error(`Invalid external workflow scope row: scopeKind and scopeId are required`);return{type:`external`,kind:e.scopeKind,id:e.scopeId};case`workspace`:case`session`:if(!e.scopeId)throw Error(`Invalid ${e.scopeType} workflow scope row: scopeId is required`);return{type:e.scopeType,id:e.scopeId};default:{let t=e.scopeType;throw Error(`Unknown scope type: ${String(t)}`)}}}function Zt(e,t){let{scopeType:n,scopeKind:r,scopeId:i}=I(t);return[j(e.scopeType,n),j(e.scopeKind,r),j(e.scopeId,i)]}function R(e){return{id:e.id,name:e.name,description:e.description??void 0,root:e.root,inputSchema:e.inputSchema??void 0,configSchema:e.configSchema??void 0,outputSchema:e.outputSchema??void 0,state:e.state??void 0,artifact:e.artifact??void 0,triggers:e.triggers??void 0,scope:L(e),canvasLayout:e.canvasLayout??void 0,source:e.source??void 0,executableSource:e.executableSource??void 0,requirements:e.requirements??void 0,successFinalizerId:e.successFinalizerId??void 0}}function Qt(e,t){let n=I(e.scope);return{id:e.id,name:e.name??e.id,root:e.root,description:e.description??null,inputSchema:e.inputSchema??null,configSchema:e.configSchema??null,outputSchema:e.outputSchema??null,state:e.state??null,artifact:e.artifact??null,triggers:e.triggers??null,canvasLayout:e.canvasLayout??null,source:e.source??null,executableSource:e.executableSource??null,requirements:e.requirements??null,successFinalizerId:e.successFinalizerId??null,createdAt:t,updatedAt:t,...n}}function $t(e,t){let{workflowDefinitions:r}=T(t,F),i=Ot(r),a=e.on(g.get,async e=>{let n=await t.select().from(r).where(j(r.id,e.payload.id)).limit(1);e.setResult({workflow:n[0]?R(n[0]):null})}),o=e.on(g.set,async a=>{let o=a.payload.workflow,s=Date.now(),c=Qt(o,s),l=await E(t,async()=>{let e=await t.insert(r).values(c).onConflictDoNothing({target:r.id}).returning();if(e.length>0)return{kind:`created`,row:e[0]};let[n]=await t.update(r).set({name:c.name,root:c.root,updatedAt:s,createdAt:N`COALESCE(${i.createdAt}, ${s})`,description:c.description===null?N`${i.description}`:c.description,inputSchema:c.inputSchema===null?N`${i.inputSchema}`:c.inputSchema,configSchema:c.configSchema===null?N`${i.configSchema}`:c.configSchema,outputSchema:c.outputSchema===null?N`${i.outputSchema}`:c.outputSchema,state:c.state,artifact:c.artifact===null?N`${i.artifact}`:c.artifact,triggers:c.triggers===null?N`${i.triggers}`:c.triggers,canvasLayout:c.canvasLayout===null?N`${i.canvasLayout}`:c.canvasLayout,source:c.source===null?N`${i.source}`:c.source,executableSource:c.executableSource,requirements:c.requirements,successFinalizerId:c.successFinalizerId,...I(o.scope)}).where(j(r.id,o.id)).returning();return n?{kind:`updated`,row:n}:void 0});l&&await e.emit(l.kind===`created`?n.definition.created:n.definition.updated,R(l.row)),a.setResult({id:o.id})}),s=e.on(g.delete,async i=>{let a=(await E(t,()=>t.delete(r).where(j(r.id,i.payload.id)).returning())).length>0;a&&await e.emit(n.definition.deleted,{id:i.payload.id}),i.setResult({deleted:a})}),c=e.on(g.list,async e=>{let n=e.payload,i=n.scope?Zt(r,n.scope):[],a=i.length>0?await t.select().from(r).where(D(...i)):await t.select().from(r);e.setResult({workflows:a.map(R)})});return()=>{a(),o(),s(),c()}}function en(e){return{frameId:e.frameId,nodeId:e.nodeId,nodeType:e.nodeType,path:e.path,parentFrameId:e.parentFrameId??void 0,status:e.status,attempt:e.attempt,iteration:e.iteration??void 0,branchKey:e.branchKey??void 0,...e.outputPresent?{output:e.output}:{},error:e.error??void 0,startedAt:e.startedAt??void 0,completedAt:e.completedAt??void 0}}function tn(e,t){return{frameId:t.frameId,executionId:e,nodeId:t.nodeId,nodeType:t.nodeType,path:t.path,parentFrameId:t.parentFrameId??null,status:t.status,attempt:t.attempt,iteration:t.iteration??null,branchKey:t.branchKey??null,output:t.output===void 0?null:t.output,outputPresent:t.output!==void 0,error:t.error??null,startedAt:t.startedAt??null,completedAt:t.completedAt??null}}function nn(e,t){let{workflowExecutionFrames:n}=T(t,F),r=e.on(g.setFrame,async e=>{let{executionId:r,frame:i}=e.payload;if(!h(e,r))throw Error(`Unauthorized: caller is not permitted to write frames for execution: ${r}`);let a=tn(r,i);await E(t,()=>t.insert(n).values(a).onConflictDoUpdate({target:n.frameId,set:a})),e.setResult({frameId:i.frameId})}),i=e.on(g.getFrame,async e=>{let r=await t.select().from(n).where(j(n.frameId,e.payload.frameId)).limit(1);e.setResult({frame:r[0]?en(r[0]):null})}),a=e.on(g.listFrames,async e=>{if(!h(e,e.payload.executionId))throw Error(`Unauthorized: caller is not permitted to list frames for execution: ${e.payload.executionId}`);let r=await t.select().from(n).where(j(n.executionId,e.payload.executionId)).orderBy(O(n.startedAt),O(n.frameId));e.setResult({frames:r.map(en)})});return()=>{r(),i(),a()}}function rn(e){return`${e.executionId}:${e.nodeId}:${e.frameId}`}function z(e){return{executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,schema:e.schema,prompt:e.prompt??void 0,status:e.status,autoAction:e.autoAction,timeoutMs:e.timeoutMs??null,...e.resumeDataPresent?{resumeData:e.resumeData}:{},...e.reason===null?{}:{reason:e.reason},createdAt:e.createdAt,resolvedAt:e.resolvedAt??void 0}}function B(e){return{id:rn(e),executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,schema:e.schema,prompt:e.prompt??null,status:e.status,autoAction:e.autoAction,timeoutMs:e.timeoutMs,resumeData:e.resumeData===void 0?null:e.resumeData,reason:e.reason??null,resumeDataPresent:e.resumeData!==void 0,createdAt:e.createdAt,resolvedAt:e.resolvedAt??null}}function an(e,t,n,r){if(e===void 0&&t===void 0)throw Error(`Either executionId or status is required to list gate instances.`);let i=n??rt;if(!Number.isInteger(i)||i<v||i>_)throw Error(`Gate instance list limit must be an integer between ${v} and ${_}.`);return{resolvedLimit:i,predicates:[...e===void 0?[]:[j(r.executionId,e)],...t===void 0?[]:[j(r.status,t)]]}}function on(e,t){let{workflowExecutions:n,workflowGateInstances:r}=T(t,F),i=e.on(g.setGateInstance,async e=>{let n=e.payload.gate;if(!h(e,n.executionId))throw Error(`Unauthorized: caller is not permitted to write gates for execution: ${n.executionId}`);let i=B(n);await E(t,()=>t.insert(r).values(i).onConflictDoUpdate({target:r.id,set:i})),e.setResult({id:i.id})}),a=e.on(g.resolveWaitingGateInstance,async e=>{let n=e.payload.gate,i=B(n),a=await E(t,()=>t.update(r).set(i).where(D(j(r.id,i.id),j(r.status,`waiting`))).returning({id:r.id}));e.setResult({accepted:a.length===1})}),o=e.on(g.getGateInstance,async e=>{let{executionId:n,nodeId:i,frameId:a}=e.payload;if(!h(e,n))throw Error(`Unauthorized: caller is not permitted to read gates for execution: ${n}`);let o=[j(r.executionId,n),j(r.nodeId,i)];a!==void 0&&o.push(j(r.frameId,a));let s=await t.select().from(r).where(D(...o)).limit(1);e.setResult({gate:s[0]?z(s[0]):null})}),s=e.on(g.listGateInstances,async e=>{let{executionId:n,status:i,limit:a}=e.payload,{resolvedLimit:o,predicates:s}=an(n,i,a,r),c=await t.select().from(r).where(D(...s)).orderBy(A(r.createdAt),A(r.id)).limit(o);e.setResult({gates:c.map(z)})}),c=e.on(g.listPausedGateTimeouts,async e=>{let i=await t.select({gate:r}).from(r).innerJoin(n,j(r.executionId,n.id)).where(D(j(r.status,`waiting`),j(n.status,`paused`),At(r.timeoutMs)));e.setResult({gates:i.map(e=>z(e.gate))})});return()=>{i(),a(),o(),s(),c()}}function sn(e){return{executionId:e.executionId,frameId:e.frameId,stepId:e.stepId,stepType:e.stepType,status:e.status,startedAt:e.startedAt??void 0,completedAt:e.completedAt??void 0,durationMs:e.durationMs??void 0,inputTokens:e.inputTokens??void 0,outputTokens:e.outputTokens??void 0,estimatedCost:e.estimatedCost??void 0,toolCallCount:e.toolCallCount??void 0,input:e.input??void 0,output:e.output??void 0}}function cn(e){return{sourceExecutionId:e.sourceExecutionId,targetExecutionId:e.targetExecutionId,linkType:e.linkType,metadata:e.metadata??void 0}}function ln(e,t){let{workflowStepSpans:n,workflowExecutionLinks:r}=T(t,F),i=e.on(g.setSpan,async e=>{let{span:r}=e.payload;if(!h(e,r.executionId))throw Error(`Unauthorized: caller is not permitted to write spans for execution: ${r.executionId}`);await E(t,()=>t.insert(n).values(r).onConflictDoUpdate({target:[n.executionId,n.frameId],set:r})),e.setResult({id:`${r.executionId}:${r.frameId}`})}),a=e.on(g.listSpans,async e=>{let r=await t.select().from(n).where(j(n.executionId,e.payload.executionId)).orderBy(O(n.startedAt),O(n.stepId),O(n.frameId));e.setResult({spans:r.map(sn)})}),o=e.on(g.setExecutionLink,async e=>{let{link:n}=e.payload;await E(t,()=>t.insert(r).values(n).onConflictDoUpdate({target:[r.sourceExecutionId,r.targetExecutionId],set:n})),e.setResult({id:`${n.sourceExecutionId}:${n.targetExecutionId}`})}),s=e.on(g.listExecutionLinks,async e=>{let{sourceExecutionId:n,targetExecutionId:i}=e.payload;if(n===void 0&&i===void 0)throw Error(`Either sourceExecutionId or targetExecutionId is required to list execution links.`);let a=[...n===void 0?[]:[j(r.sourceExecutionId,n)],...i===void 0?[]:[j(r.targetExecutionId,i)]],o=t.select().from(r).where(D(...a));e.setResult({links:(await o).map(cn)})});return()=>{i(),a(),o(),s()}}function V(e,t){return t===null?Et(e)===`postgres`?N`'null'::jsonb`:N`'null'`:t}function un(e){switch(e.kind){case`path`:return{sourceKind:`path`,sourcePath:e.path,sourceFilename:null,sourceCode:null};case`source`:return{sourceKind:`source`,sourcePath:null,sourceFilename:e.filename,sourceCode:e.source};case`definition`:return{sourceKind:`definition`,sourcePath:null,sourceFilename:null,sourceCode:null}}}function dn(e){switch(e.sourceKind){case`path`:if(!e.sourcePath)throw Error(`Invalid run context row: sourcePath required for kind=path`);return{kind:`path`,path:e.sourcePath};case`source`:if(!e.sourceFilename)throw Error(`Invalid run context row: sourceFilename required for kind=source`);return{kind:`source`,filename:e.sourceFilename,source:e.sourceCode??``};case`definition`:return{kind:`definition`,workflowId:e.workflowId};default:throw Error(`Unknown run context source kind: ${String(e.sourceKind)}`)}}function fn(e){return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,source:dn(e),definitionSnapshot:e.definitionSnapshot??void 0,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,triggerMode:e.triggerMode,...e.artifactRef===null?{}:{artifactRef:e.artifactRef},scope:L(e),...e.dispatchMetadata===null?{}:{dispatchMetadata:e.dispatchMetadata},cancelSubject:e.cancelSubject,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy??`wait-in-process`,...e.terminalAuthority===null?{}:{terminalAuthority:e.terminalAuthority},...e.materializationSpec===null?{}:{materializationSpec:e.materializationSpec}}}function pn(e){let t=un(e.source),n=I(e.scope);return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,...t,definitionSnapshot:e.definitionSnapshot??null,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,triggerMode:e.triggerMode??`immediate`,artifactRef:e.artifactRef??null,dispatchMetadata:e.dispatchMetadata??null,...n,cancelSubject:e.cancelSubject,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy,terminalAuthority:e.terminalAuthority??null,materializationSpec:e.materializationSpec??null}}async function mn(e,t,n){let r=pn(t);await e.insert(n).values(r).onConflictDoUpdate({target:n.executionId,set:r})}function hn(e,t){let{workflowRunContexts:n,workflowExecutionState:r,workflowExecutionStateEvents:i}=T(t,F),a=e.on(g.setRunContext,async e=>{let a=e.payload.runContext,o=e.payload.initialState;await w(t,async e=>{if(await mn(e,a,n),o===void 0)return;let s=Date.now(),c=V(t,o);await e.insert(r).values({executionId:a.executionId,sequence:0,value:c,updatedAt:s}).onConflictDoNothing(),await e.insert(i).values({executionId:a.executionId,sequence:0,patch:[],value:c,createdAt:s}).onConflictDoNothing()}),e.setResult({executionId:a.executionId})}),o=e.on(g.getRunContext,async e=>{let{executionId:r}=e.payload,i=await t.select().from(n).where(j(n.executionId,r)),a=i[0]?fn(i[0]):null;e.setResult({runContext:a})});return()=>{a(),o()}}async function gn(e,t,n){let{workflowExecutionState:r,workflowExecutionStateEvents:i}=T(e,F),a=Date.now(),o=V(e,n);await w(e,async e=>{await e.insert(r).values({executionId:t,sequence:0,value:o,updatedAt:a}).onConflictDoNothing(),await e.insert(i).values({executionId:t,sequence:0,patch:[],value:o,createdAt:a}).onConflictDoNothing()})}async function _n(e,t){let{workflowExecutionState:n}=T(e,F),r=(await e.select().from(n).where(j(n.executionId,t)).limit(1))[0];return r?{executionId:r.executionId,sequence:r.sequence,value:r.value}:null}async function vn(e,t){let{workflowExecutionState:n,workflowExecutionStateEvents:r}=T(e,F),i=Date.now(),a=V(e,t.nextValue);return w(e,async e=>{let o=(await e.select().from(n).where(j(n.executionId,t.executionId)).limit(1))[0];if(!o)throw Error(`no workflow state for execution ${t.executionId}`);if(t.expectedSequence===void 0)throw Error(`expectedSequence is required to patch workflow state`);let s=o.sequence+1,c=te(o.value,t.nextValue);if((await e.update(n).set({sequence:s,value:a,updatedAt:i}).where(D(j(n.executionId,t.executionId),j(n.sequence,t.expectedSequence))).returning()).length===0)throw Error(`state sequence conflict: expected ${String(t.expectedSequence)}, got ${String(o.sequence)}`);return await e.insert(r).values({executionId:t.executionId,sequence:s,patch:c,value:a,createdAt:i}),{executionId:t.executionId,sequence:s,patch:c,value:t.nextValue}})}function yn(e,t){let n=e.on(g.initializeState,async e=>{let{executionId:n,initialValue:r}=e.payload;await gn(t,n,r),e.setResult({})}),r=e.on(g.getState,async e=>{let{executionId:n}=e.payload,r=await _n(t,n);e.setResult({state:r})}),i=e.on(g.patchState,async e=>{let{executionId:n,expectedSequence:r,nextValue:i}=e.payload,a=await vn(t,{executionId:n,expectedSequence:r,nextValue:i});e.setResult(a)});return()=>{n(),r(),i()}}function bn(e){return{executionId:e.executionId,workflowId:e.workflowId,workflowName:e.workflowName??void 0,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt??void 0,durationMs:e.durationMs??void 0,totalInputTokens:e.totalInputTokens??void 0,totalOutputTokens:e.totalOutputTokens??void 0,totalEstimatedCost:e.totalEstimatedCost??void 0,error:e.error??void 0,failedNodeId:e.failedNodeId??void 0}}async function xn(e,t){let{worklogSummaries:n}=T(e,F);await e.insert(n).values(t).onConflictDoNothing()}async function Sn(e,t){let{worklogSummaries:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.executionId,set:Cn(t),setWhere:Nt(n.status,[`completed`,`failed`,`cancelled`])})}function Cn(e){return{workflowId:e.workflowId,workflowName:e.workflowName,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt,durationMs:e.durationMs,error:e.error,failedNodeId:e.failedNodeId}}async function H(e,t){let{worklogSummaries:n}=T(e,F),r=await e.select().from(n).where(j(n.executionId,t)).limit(1);return r[0]?bn(r[0]):null}async function wn(e,t={}){let{worklogSummaries:n}=T(e,F),{workflowId:r,status:i,limit:a=50,offset:o=0}=t,s=[...r===void 0?[]:[j(n.workflowId,r)],...i===void 0?[]:[j(n.status,i)]],c=s.length>0?D(...s):void 0,[l,u]=await Promise.all([e.select().from(n).where(c).orderBy(A(n.startedAt)).limit(a).offset(o),e.select({count:k()}).from(n).where(c)]);return{items:l.map(bn),total:u[0]?.count??0}}async function Tn(e,t){let{worklogFrameEntries:n}=T(e,F);await e.insert(n).values(t).onConflictDoNothing()}async function En(e,t){let{worklogFrameEntries:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.frameId,set:t,setWhere:Nt(n.status,[`completed`,`failed`,`skipped`,`cancelled`])})}async function U(e,t){let{worklogFrameEntries:n}=T(e,F);return(await e.select().from(n).where(j(n.frameId,t)).limit(1))[0]??null}async function Dn(e,t){let n=await U(e,t);return n===null?null:lt.parse({executionId:n.executionId,frameId:n.frameId,nodeId:n.nodeId,nodeType:n.nodeType,path:n.path,status:n.status,attempt:n.attempt,iteration:n.iteration??void 0,branchKey:n.branchKey??void 0,startedAt:n.startedAt??void 0,completedAt:n.completedAt??void 0,durationMs:n.durationMs??void 0,inputTokens:n.inputTokens??void 0,outputTokens:n.outputTokens??void 0,estimatedCost:n.estimatedCost??void 0,error:n.error??void 0})}async function On(e,t){let{worklogArtifactWrites:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}function kn(e,t,n,r,i){return`${e}:${t}:${n}:${r}:${i}`}async function W(e,t){let{worklogGateEvents:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}async function An(e,t){let{worklogGateEvents:n}=T(e,F);return(await e.select().from(n).where(j(n.id,t)).limit(1))[0]??null}function G(e,t,n){return`${e}:${t}:${n}`}async function jn(e,t,n){let[r]=await e.update(t).set({totalInputTokens:t.totalInputTokens}).where(j(t.executionId,n)).returning();return r}async function Mn(e,t,n){let[r]=await e.select({totalInputTokens:P(t.inputTokens),totalOutputTokens:P(t.outputTokens),totalEstimatedCost:P(t.estimatedCost),measuredInputTokens:k(t.inputTokens),measuredOutputTokens:k(t.outputTokens),measuredCosts:k(t.estimatedCost)}).from(t).where(j(t.executionId,n));return{totalInputTokens:Number(r?.totalInputTokens??0),totalOutputTokens:Number(r?.totalOutputTokens??0),totalEstimatedCost:Number(r?.totalEstimatedCost??0),hasMeasurements:Number(r?.measuredInputTokens??0)>0||Number(r?.measuredOutputTokens??0)>0||Number(r?.measuredCosts??0)>0}}function Nn(e){return e.hasMeasurements}async function Pn(e,t,n,r){await e.update(t).set({totalInputTokens:r.totalInputTokens,totalOutputTokens:r.totalOutputTokens,totalEstimatedCost:r.totalEstimatedCost}).where(j(t.executionId,n))}async function Fn(e,t,n,r){let i=N`coalesce((select sum(${n.inputTokens}) from ${n} where ${n.executionId} = ${r}), 0)`,a=N`coalesce((select sum(${n.outputTokens}) from ${n} where ${n.executionId} = ${r}), 0)`,o=N`coalesce((select sum(${n.estimatedCost}) from ${n} where ${n.executionId} = ${r}), 0)`,s=N`exists(
2
2
  select 1 from ${n}
3
3
  where ${n.executionId} = ${r}
4
4
  and (${n.inputTokens} is not null
@@ -1,4 +1,4 @@
1
- import { A as OperationReportDecision, B as RecordProvisioningAbsentInput, D as MarkRuntimeReadyInput, E as InfrastructureFailureDecision, F as ReadBootstrapStartStateInput, Ft as RequestAttemptCancellationInput, G as RuntimeRegistrationDecision, Gt as ReadAttemptCancellationControlInput, H as RegisterRuntimeInput, I as RecordAllocationInput, It as RequestExecutionCancellationInput, Kt as RecordAttemptControlReceiptInput, L as RecordAllocationTerminatedInput, M as PendingAttemptAbandonmentDecision, Nt as ExecutionAttemptCancellationDecision, O as OperationAdmissionDecision, P as ProvisioningClaimDecision, Pt as ExecutionAttemptCancellationIntent$1, Qt as AttemptSettlementRead, R as RecordInfrastructureFailureInput, St as RuntimeOutcomeFence, T as GetInstructionInput, U as ReportOperationInput, Ut as AttemptControlEvidenceDecision, V as RecoverableAttemptRecord, Vt as AttemptCancellationControlState, W as RuntimeReadinessDecision, X as CompleteProviderOperationInput, Z as HandoffProviderOperationInput, a as AllocationRefEvolutionDecision, at as ProviderOperationClaimDecision, dt as ProviderOperationOwnershipRecord, en as EnsureExecutionAttemptDecision, et as ListOpenProviderOperationsInput, f as CompleteOperationInput, ft as ProvisionerIncarnationLossDecision, gt as TakeOverProviderOperationInput, h as DurableOutcome, ht as RenewProviderOperationClaimInput, i as AllocationRefEvolution, j as OutcomeCodec, k as OperationCompletionDecision, lt as ProviderOperationMutationDecision, mt as RecordProviderOperationUncertaintyInput, n as AdmitOperationInput, o as AllocationTerminationDecision, ot as ProviderOperationCompletionDecision, p as DiscoveredAllocationDecision, pt as ProvisioningAbsenceDecision, qt as ReportAttemptControlInput, r as AllocationRecordingDecision, rn as ReadAttemptSettlementInput, s as AttemptControlState, tn as EnsureExecutionAttemptInput, tt as OpenProviderOperationRecord, u as BeginProvisioningInput, w as ExecutionOwnerId, x as ExecutionAttemptRepository, y as ExecutionAttemptRecord, yt as ExecutionAttemptOutcomeDecision, z as RecordProvisionerIncarnationLostInput } from "./execution-attempt-repository-BoNwNybg.mjs";
1
+ import { A as OperationReportDecision, B as RecordProvisioningAbsentInput, D as MarkRuntimeReadyInput, E as InfrastructureFailureDecision, F as ReadBootstrapStartStateInput, Ft as RequestAttemptCancellationInput, G as RuntimeRegistrationDecision, Gt as ReadAttemptCancellationControlInput, H as RegisterRuntimeInput, I as RecordAllocationInput, It as RequestExecutionCancellationInput, Kt as RecordAttemptControlReceiptInput, L as RecordAllocationTerminatedInput, M as PendingAttemptAbandonmentDecision, Nt as ExecutionAttemptCancellationDecision, O as OperationAdmissionDecision, P as ProvisioningClaimDecision, Pt as ExecutionAttemptCancellationIntent$1, Qt as AttemptSettlementRead, R as RecordInfrastructureFailureInput, St as RuntimeOutcomeFence, T as GetInstructionInput, U as ReportOperationInput, Ut as AttemptControlEvidenceDecision, V as RecoverableAttemptRecord, Vt as AttemptCancellationControlState, W as RuntimeReadinessDecision, X as CompleteProviderOperationInput, Z as HandoffProviderOperationInput, a as AllocationRefEvolutionDecision, at as ProviderOperationClaimDecision, dt as ProviderOperationOwnershipRecord, en as EnsureExecutionAttemptDecision, et as ListOpenProviderOperationsInput, f as CompleteOperationInput, ft as ProvisionerIncarnationLossDecision, gt as TakeOverProviderOperationInput, h as DurableOutcome, ht as RenewProviderOperationClaimInput, i as AllocationRefEvolution, j as OutcomeCodec, k as OperationCompletionDecision, lt as ProviderOperationMutationDecision, mt as RecordProviderOperationUncertaintyInput, n as AdmitOperationInput, o as AllocationTerminationDecision, ot as ProviderOperationCompletionDecision, p as DiscoveredAllocationDecision, pt as ProvisioningAbsenceDecision, qt as ReportAttemptControlInput, r as AllocationRecordingDecision, rn as ReadAttemptSettlementInput, s as AttemptControlState, tn as EnsureExecutionAttemptInput, tt as OpenProviderOperationRecord, u as BeginProvisioningInput, w as ExecutionOwnerId, x as ExecutionAttemptRepository, y as ExecutionAttemptRecord, yt as ExecutionAttemptOutcomeDecision, z as RecordProvisionerIncarnationLostInput } from "./execution-attempt-repository-BUah8hma.mjs";
2
2
  import { z } from "zod";
3
3
  import * as _$_makaio_contracts0 from "@makaio/framework/contracts";
4
4
  import { AcceptedAttemptOutcome, AcceptedAttemptOutcome as AcceptedAttemptOutcome$1, AttemptOutcomeControlObservation, ExecutionAttemptBootstrapAwaitStartResponse, ExecutionAttemptInstruction, ExecutionAttemptOutcome, IWorkflowRunner, LoopGateHandler, MakaioNodeExtension, OutcomeAcceptance, OutcomeAcceptance as OutcomeAcceptance$1, StationHandler, StepRunnerBusAuth, StepRunnerPlatformDefaults, WorkerMaterializationSpec, WorkflowAttemptCancellation, WorkflowAttemptOutcome, WorkflowAttemptOutcome as WorkflowAttemptOutcome$1, WorkflowAttemptTechnicalFailure, WorkflowDefinition, WorkflowExecution, WorkflowRunContext, WorkflowRunResult, WorkflowRunnerCompletion } from "@makaio/framework/contracts";
package/dist/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@makaio/framework",
3
- "version": "1.0.0-dev-1789168267790",
3
+ "version": "1.0.0-dev-1789178369476",
4
4
  "type": "module"
5
5
  }
@@ -1 +1 @@
1
- import{t as e}from"./version-DdGhNoY5.mjs";import{z as t}from"zod";import*as n from"node:path";const r=t.string().trim().min(1),i=t.number().int().finite().nonnegative().describe(`Unix epoch timestamp in milliseconds`);function a(e){return n.posix.isAbsolute(e)||n.win32.isAbsolute(e)}const o=t.string().trim().min(1).refine(a,{message:`Path must be absolute`}),s=t.string().min(1).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/,`Profile name must be a safe path component`),c=s,l=t.object({id:r,clientId:r,name:s,description:t.string().nullable(),configDir:o,isDefault:t.boolean(),createdAt:i,updatedAt:i}),u=t.record(t.string(),t.string()),d=t.enum([`auth-only`,`full`,`empty`]),f={"profile.create":{request:t.object({clientId:r,name:s,description:t.string().optional()}),response:t.object({profile:l})},"profile.list":{request:t.object({clientId:r}),response:t.object({profiles:t.array(l)})},"profile.get":{request:t.object({clientId:r,name:s}),response:t.object({profile:l.nullable()})},"profile.update":{request:t.object({clientId:r,name:s,description:t.string().optional()}),response:t.object({profile:l})},"profile.delete":{request:t.object({clientId:r,name:s}),response:t.object({success:t.boolean()})},"profile.setDefault":{request:t.object({clientId:r,name:s}),response:t.object({profile:l})}},p={"sessionConfig.create":{request:t.object({clientId:r,leaseId:c,ownerSessionId:r.optional(),profileName:s.optional(),baseConfigDir:o.optional(),projectDir:o.optional(),configInheritance:d.optional()}),response:t.object({sessionDir:o,env:u,authMaterialized:t.boolean()})},"sessionConfig.destroy":{request:t.object({clientId:r,leaseId:c}),response:t.object({success:t.boolean()})},"sessionConfig.cleanup":{request:t.object({clientId:r.optional()}),response:t.object({removed:t.array(o)})}},m=t.object({sessionDir:o,baseConfigDir:o,projectDir:o.optional(),platform:t.enum([`darwin`,`linux`,`win32`]),configInheritance:d}),h=t.object({sessionDir:o,platform:t.enum([`darwin`,`linux`,`win32`])}),g=t.object({success:t.boolean()}),_=t.object({env:t.record(t.string(),t.string()).optional(),authMaterialized:t.boolean()}),v=t.enum([`managed-install`,`profile-create`,`session-create`]),y={request:t.object({clientId:r,configDir:o,phase:v,binaryVersion:e.optional(),adapterName:t.string().min(1).optional(),projectDir:o.optional()}),response:t.object({primed:t.boolean()})};export{a as _,f as a,d as c,_ as d,h as f,r as g,i as h,l as i,c as l,o as m,y as n,p as o,g as p,s as r,u as s,v as t,m as u};
1
+ import{t as e}from"./version-PuU2KG3I.mjs";import{z as t}from"zod";import*as n from"node:path";const r=t.string().trim().min(1),i=t.number().int().finite().nonnegative().describe(`Unix epoch timestamp in milliseconds`);function a(e){return n.posix.isAbsolute(e)||n.win32.isAbsolute(e)}const o=t.string().trim().min(1).refine(a,{message:`Path must be absolute`}),s=t.string().min(1).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/,`Profile name must be a safe path component`),c=s,l=t.object({id:r,clientId:r,name:s,description:t.string().nullable(),configDir:o,isDefault:t.boolean(),createdAt:i,updatedAt:i}),u=t.record(t.string(),t.string()),d=t.enum([`auth-only`,`full`,`empty`]),f={"profile.create":{request:t.object({clientId:r,name:s,description:t.string().optional()}),response:t.object({profile:l})},"profile.list":{request:t.object({clientId:r}),response:t.object({profiles:t.array(l)})},"profile.get":{request:t.object({clientId:r,name:s}),response:t.object({profile:l.nullable()})},"profile.update":{request:t.object({clientId:r,name:s,description:t.string().optional()}),response:t.object({profile:l})},"profile.delete":{request:t.object({clientId:r,name:s}),response:t.object({success:t.boolean()})},"profile.setDefault":{request:t.object({clientId:r,name:s}),response:t.object({profile:l})}},p={"sessionConfig.create":{request:t.object({clientId:r,leaseId:c,ownerSessionId:r.optional(),profileName:s.optional(),baseConfigDir:o.optional(),projectDir:o.optional(),configInheritance:d.optional()}),response:t.object({sessionDir:o,env:u,authMaterialized:t.boolean()})},"sessionConfig.destroy":{request:t.object({clientId:r,leaseId:c}),response:t.object({success:t.boolean()})},"sessionConfig.cleanup":{request:t.object({clientId:r.optional()}),response:t.object({removed:t.array(o)})}},m=t.object({sessionDir:o,baseConfigDir:o,projectDir:o.optional(),platform:t.enum([`darwin`,`linux`,`win32`]),configInheritance:d}),h=t.object({sessionDir:o,platform:t.enum([`darwin`,`linux`,`win32`])}),g=t.object({success:t.boolean()}),_=t.object({env:t.record(t.string(),t.string()).optional(),authMaterialized:t.boolean()}),v=t.enum([`managed-install`,`profile-create`,`session-create`]),y={request:t.object({clientId:r,configDir:o,phase:v,binaryVersion:e.optional(),adapterName:t.string().min(1).optional(),projectDir:o.optional()}),response:t.object({primed:t.boolean()})};export{a as _,f as a,d as c,_ as d,h as f,r as g,i as h,l as i,c as l,o as m,y as n,p as o,g as p,s as r,u as s,v as t,m as u};
@@ -1 +1 @@
1
- import{r as e}from"./namespace-KYIbWPvl.mjs";import{CredentialSubjects as t}from"@makaio/framework/contracts";var n=class extends Error{code;adapterName;providerConfigId;constructor(e,t,n){super(`Provider context resolution failed (${e}) for adapter "${t}".`),this.code=e,this.adapterName=t,this.providerConfigId=n,this.name=`RuntimeProviderContextResolutionError`}};async function r(t,r){let i=await t.request(e.resolveAdapterRuntimeSnapshot,r);if(i.status===`error`)throw new n(i.code,r.adapterName,r.providerConfigId);let a=i.runtime;if(a.adapterName!==r.adapterName||a.snapshot.context.providerConfigId!==r.providerConfigId)throw new n(`snapshot-identity-mismatch`,r.adapterName,r.providerConfigId);let o=a.snapshot.context;if(o.state!==`resolved`)throw new n(`provider-context-unresolved`,r.adapterName,r.providerConfigId);return o}var i=class extends Error{code;constructor(e){super(`[activateProviderContext] ${e===`manager-unavailable`?`the selected account manager is unavailable`:e===`account-not-found`?`the selected account no longer exists`:`the selected account could not be activated`}.`),this.code=e,this.name=`ProviderContextActivationError`}},a=class extends Error{constructor(){super(`Provider context account activation rollback failed.`),this.name=`ProviderContextActivationRollbackError`}},o=class{bus;transactionId;finalization;constructor(e,t){this.bus=e,this.transactionId=t}commit(){return this.finalize(`commit`)}rollback(){return this.finalize(`rollback`)}finalize(e){if(this.finalization!==void 0)return this.finalization.action===e?this.finalization.promise:Promise.reject(new i(`activation-failed`));let t=this.requestFinalization(e);return this.finalization={action:e,promise:t},t}async requestFinalization(e){try{if(e===`commit`){let e=await this.bus.requestOptional(t.activation.commit,{transactionId:this.transactionId});if(!e.handled)throw new i(`activation-failed`);if(!e.data.success)throw e.data.code===`commit-rollback-failed`?new a:new i(`activation-failed`);return}let n=await this.bus.requestOptional(t.activation.rollback,{transactionId:this.transactionId});if(!n.handled)throw new i(`activation-failed`);if(!n.data.success)throw n.data.code===`rollback-failed`?new a:new i(`activation-failed`)}catch(e){throw e instanceof i||e instanceof a?e:new i(`activation-failed`)}}};function s(e){return e.state!==`resolved`||e.auth.mode!==`inferred`||e.auth.account===void 0?null:e}async function c(e,n){let r=s(n);if(r)try{let n=await e.requestOptional(t.activate,{providerContext:r});if(!n.handled)throw new i(`manager-unavailable`);if(!n.data.success)throw new i(n.data.code)}catch(e){throw e instanceof i?e:new i(`activation-failed`)}}async function l(e,n){let r=s(n);if(r)try{let n=await e.requestOptional(t.activation.prepare,{providerContext:r});if(!n.handled)throw new i(`manager-unavailable`);if(!n.data.success)throw new i(n.data.code);return new o(e,n.data.transactionId)}catch(e){throw e instanceof i?e:new i(`activation-failed`)}}export{n as a,l as i,a as n,r as o,c as r,i as t};
1
+ import{r as e}from"./namespace-J87EeVTm.mjs";import{CredentialSubjects as t}from"@makaio/framework/contracts";var n=class extends Error{code;adapterName;providerConfigId;constructor(e,t,n){super(`Provider context resolution failed (${e}) for adapter "${t}".`),this.code=e,this.adapterName=t,this.providerConfigId=n,this.name=`RuntimeProviderContextResolutionError`}};async function r(t,r){let i=await t.request(e.resolveAdapterRuntimeSnapshot,r);if(i.status===`error`)throw new n(i.code,r.adapterName,r.providerConfigId);let a=i.runtime;if(a.adapterName!==r.adapterName||a.snapshot.context.providerConfigId!==r.providerConfigId)throw new n(`snapshot-identity-mismatch`,r.adapterName,r.providerConfigId);let o=a.snapshot.context;if(o.state!==`resolved`)throw new n(`provider-context-unresolved`,r.adapterName,r.providerConfigId);return o}var i=class extends Error{code;constructor(e){super(`[activateProviderContext] ${e===`manager-unavailable`?`the selected account manager is unavailable`:e===`account-not-found`?`the selected account no longer exists`:`the selected account could not be activated`}.`),this.code=e,this.name=`ProviderContextActivationError`}},a=class extends Error{constructor(){super(`Provider context account activation rollback failed.`),this.name=`ProviderContextActivationRollbackError`}},o=class{bus;transactionId;finalization;constructor(e,t){this.bus=e,this.transactionId=t}commit(){return this.finalize(`commit`)}rollback(){return this.finalize(`rollback`)}finalize(e){if(this.finalization!==void 0)return this.finalization.action===e?this.finalization.promise:Promise.reject(new i(`activation-failed`));let t=this.requestFinalization(e);return this.finalization={action:e,promise:t},t}async requestFinalization(e){try{if(e===`commit`){let e=await this.bus.requestOptional(t.activation.commit,{transactionId:this.transactionId});if(!e.handled)throw new i(`activation-failed`);if(!e.data.success)throw e.data.code===`commit-rollback-failed`?new a:new i(`activation-failed`);return}let n=await this.bus.requestOptional(t.activation.rollback,{transactionId:this.transactionId});if(!n.handled)throw new i(`activation-failed`);if(!n.data.success)throw n.data.code===`rollback-failed`?new a:new i(`activation-failed`)}catch(e){throw e instanceof i||e instanceof a?e:new i(`activation-failed`)}}};function s(e){return e.state!==`resolved`||e.auth.mode!==`inferred`||e.auth.account===void 0?null:e}async function c(e,n){let r=s(n);if(r)try{let n=await e.requestOptional(t.activate,{providerContext:r});if(!n.handled)throw new i(`manager-unavailable`);if(!n.data.success)throw new i(n.data.code)}catch(e){throw e instanceof i?e:new i(`activation-failed`)}}async function l(e,n){let r=s(n);if(r)try{let n=await e.requestOptional(t.activation.prepare,{providerContext:r});if(!n.handled)throw new i(`manager-unavailable`);if(!n.data.success)throw new i(n.data.code);return new o(e,n.data.transactionId)}catch(e){throw e instanceof i?e:new i(`activation-failed`)}}export{n as a,l as i,a as n,r as o,c as r,i as t};
@@ -1 +1 @@
1
- import{t as e}from"./resolved-XQTiHgrA.mjs";import{r as t,t as n}from"./definition-o5Dfg5j-.mjs";import{z as r}from"zod";const i=r.object({state:r.literal(`resolved`),providerConfigId:r.string().trim().min(1),definitionId:r.string().trim().min(1),endpointOverrides:n.optional(),auth:e,capabilities:t.optional()}).strict().superRefine((e,t)=>{e.auth.method.owner===`provider`&&e.auth.method.providerDefinitionId!==e.definitionId&&t.addIssue({code:r.ZodIssueCode.custom,message:`Provider-owned authentication must belong to the resolved provider definition.`,path:[`auth`,`method`,`providerDefinitionId`]})}),a=r.object({state:r.literal(`unresolved`)}).strict(),o=r.discriminatedUnion(`state`,[i,a]);export{i as n,a as r,o as t};
1
+ import{t as e}from"./resolved-BAbiCSV4.mjs";import{r as t,t as n}from"./definition-Dd7bDWpP.mjs";import{z as r}from"zod";const i=r.object({state:r.literal(`resolved`),providerConfigId:r.string().trim().min(1),definitionId:r.string().trim().min(1),endpointOverrides:n.optional(),auth:e,capabilities:t.optional()}).strict().superRefine((e,t)=>{e.auth.method.owner===`provider`&&e.auth.method.providerDefinitionId!==e.definitionId&&t.addIssue({code:r.ZodIssueCode.custom,message:`Provider-owned authentication must belong to the resolved provider definition.`,path:[`auth`,`method`,`providerDefinitionId`]})}),a=r.object({state:r.literal(`unresolved`)}).strict(),o=r.discriminatedUnion(`state`,[i,a]);export{i as n,a as r,o as t};
@@ -1 +1 @@
1
- import{a as e}from"./json-value-DM-EjTC1.mjs";import{t}from"./zod-json-schema-DGWHUOK0.mjs";import{z as n}from"zod";const r=n.object({kind:n.string().min(1),description:n.string().min(1),parameterSchema:e}),i=n.discriminatedUnion(`success`,[n.object({success:n.literal(!0)}),n.object({success:n.literal(!1),error:n.object({message:n.string()})})]);function a(e){return e}function o(e){let{kind:n,description:i,parameterSchema:a,handler:o}=e,s=r.parse({kind:n,description:i,parameterSchema:t(a,`input`)});return{kind:n,description:i,parameterSchema:a,handler:o,toDescriptor:()=>structuredClone(s)}}export{i,a as n,r,o as t};
1
+ import{a as e}from"./json-value-DM-EjTC1.mjs";import{t}from"./zod-json-schema-ZUmGtQhT.mjs";import{z as n}from"zod";const r=n.object({kind:n.string().min(1),description:n.string().min(1),parameterSchema:e}),i=n.discriminatedUnion(`success`,[n.object({success:n.literal(!0)}),n.object({success:n.literal(!1),error:n.object({message:n.string()})})]);function a(e){return e}function o(e){let{kind:n,description:i,parameterSchema:a,handler:o}=e,s=r.parse({kind:n,description:i,parameterSchema:t(a,`input`)});return{kind:n,description:i,parameterSchema:a,handler:o,toDescriptor:()=>structuredClone(s)}}export{i,a as n,r,o as t};
@@ -1 +1 @@
1
- import{c as e,i as t,l as n,u as r}from"./definitions-CyFaNG_c.mjs";import{i,n as a,r as o,t as s}from"./selection-D7V0wyHX.mjs";import{z as c}from"zod";const l=c.object({mode:c.literal(`explicit`),method:a,definition:e,credentialRefs:c.record(t,s)}).strict(),u=c.object({mode:c.literal(`inferred`),method:o,definition:n,account:i.optional()}).strict(),d=c.object({mode:c.literal(`none`),method:a,definition:r}).strict(),f=c.discriminatedUnion(`mode`,[l,u,d]).superRefine((e,t)=>{if(e.method.methodId!==e.definition.id&&t.addIssue({code:c.ZodIssueCode.custom,message:`Resolved auth method reference must match the resolved method definition ID.`,path:[`definition`,`id`]}),e.mode!==`explicit`)return;let n=new Set(e.definition.fields.map(({id:e})=>e));for(let n of e.definition.fields)n.required&&!Object.prototype.hasOwnProperty.call(e.credentialRefs,n.id)&&t.addIssue({code:c.ZodIssueCode.custom,message:`Missing required credential ref for field "${n.id}".`,path:[`credentialRefs`,n.id]});for(let r of Object.keys(e.credentialRefs))n.has(r)||t.addIssue({code:c.ZodIssueCode.custom,message:`Credential ref field "${r}" is not declared by the resolved auth method.`,path:[`credentialRefs`,r]})});export{f as t};
1
+ import{c as e,i as t,l as n,u as r}from"./definitions-Do7bP-u7.mjs";import{i,n as a,r as o,t as s}from"./selection-DLN6l5iK.mjs";import{z as c}from"zod";const l=c.object({mode:c.literal(`explicit`),method:a,definition:e,credentialRefs:c.record(t,s)}).strict(),u=c.object({mode:c.literal(`inferred`),method:o,definition:n,account:i.optional()}).strict(),d=c.object({mode:c.literal(`none`),method:a,definition:r}).strict(),f=c.discriminatedUnion(`mode`,[l,u,d]).superRefine((e,t)=>{if(e.method.methodId!==e.definition.id&&t.addIssue({code:c.ZodIssueCode.custom,message:`Resolved auth method reference must match the resolved method definition ID.`,path:[`definition`,`id`]}),e.mode!==`explicit`)return;let n=new Set(e.definition.fields.map(({id:e})=>e));for(let n of e.definition.fields)n.required&&!Object.prototype.hasOwnProperty.call(e.credentialRefs,n.id)&&t.addIssue({code:c.ZodIssueCode.custom,message:`Missing required credential ref for field "${n.id}".`,path:[`credentialRefs`,n.id]});for(let r of Object.keys(e.credentialRefs))n.has(r)||t.addIssue({code:c.ZodIssueCode.custom,message:`Credential ref field "${r}" is not declared by the resolved auth method.`,path:[`credentialRefs`,r]})});export{f as t};
@@ -1,4 +1,4 @@
1
- import { C as RuleSetOptions, S as Rule, _ as JsonObjectShape, a as JsonObjectSchema, b as NotCondition, c as RuleSetOptionsSchema, d as CompoundCondition, f as Condition, g as JsonObject, h as FieldOperator, i as FieldOperatorSchema, l as ScalarValueSchema, m as FieldCondition, n as ExpressionConditionSchema, o as JsonValueSchema, p as ExpressionCondition, r as FieldConditionSchema, s as RuleSchema, t as ConditionSchema, u as AndCondition, v as JsonPrimitive, w as ScalarValue, x as OrCondition, y as JsonValue } from "../schemas-BZyi7v9g.mjs";
1
+ import { C as RuleSetOptions, S as Rule, _ as JsonObjectShape, a as JsonObjectSchema, b as NotCondition, c as RuleSetOptionsSchema, d as CompoundCondition, f as Condition, g as JsonObject, h as FieldOperator, i as FieldOperatorSchema, l as ScalarValueSchema, m as FieldCondition, n as ExpressionConditionSchema, o as JsonValueSchema, p as ExpressionCondition, r as FieldConditionSchema, s as RuleSchema, t as ConditionSchema, u as AndCondition, v as JsonPrimitive, w as ScalarValue, x as OrCondition, y as JsonValue } from "../schemas-CtzZDp29.mjs";
2
2
 
3
3
  //#region packages/rules/src/evaluator.d.ts
4
4
  /**
@@ -1 +1 @@
1
- import{t as e}from"../esm-B3t30-13.mjs";import{ConditionSchema as t,ExpressionConditionSchema as n,FieldConditionSchema as r,FieldOperatorSchema as i,JsonObjectSchema as a,JsonValueSchema as o,RuleSchema as s,RuleSetOptionsSchema as c,ScalarValueSchema as l}from"./schemas.mjs";import{compile as u}from"@makaio/framework/expression";const d=new Map,f=new Map;function p(e,t){if(`$and`in e){for(let n of e.$and)if(!p(n,t))return!1;return!0}if(`$or`in e){for(let n of e.$or)if(p(n,t))return!0;return!1}return`$not`in e?!p(e.$not,t):`$expr`in e?!!_(e.$expr).evalSync(t):h(g(t,e.field),e.operator)}function m(e,t,n={}){let{includeDisabled:r=!1}=n,i=[];for(let n of e)!r&&!n.enabled||p(n.condition,t)&&i.push(n);return i}function h(e,t){if(typeof t!=`object`||!t)return e===t;if(`$eq`in t)return e===t.$eq;if(`$ne`in t)return e!==t.$ne;if(`$in`in t)return t.$in.includes(e);if(`$nin`in t)return!t.$nin.includes(e);if(`$contains`in t)return Array.isArray(e)&&e.includes(t.$contains);if(`$containsPrefix`in t)return Array.isArray(e)&&e.some(e=>typeof e==`string`&&e.startsWith(t.$containsPrefix));if(`$exists`in t){let n=e!==void 0;return t.$exists?n:!n}return`$startsWith`in t?typeof e==`string`&&e.startsWith(t.$startsWith):`$endsWith`in t?typeof e==`string`&&e.endsWith(t.$endsWith):`$glob`in t?typeof e==`string`&&v(t.$glob).match(e):!1}function g(e,t){if(e==null)return;let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return;r=r[e]}return r}function _(e){return y(d,e,()=>u(e))}function v(t){return y(f,t,()=>new e(t))}function y(e,t,n){let r=e.get(t);if(r!==void 0)return e.delete(t),e.set(t,r),r;let i=n();if(e.set(t,i),e.size>256){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return i}export{t as ConditionSchema,n as ExpressionConditionSchema,r as FieldConditionSchema,i as FieldOperatorSchema,a as JsonObjectSchema,o as JsonValueSchema,s as RuleSchema,c as RuleSetOptionsSchema,l as ScalarValueSchema,p as evaluate,m as evaluateRules};
1
+ import{t as e}from"../esm-Ccx-3z8E.mjs";import{ConditionSchema as t,ExpressionConditionSchema as n,FieldConditionSchema as r,FieldOperatorSchema as i,JsonObjectSchema as a,JsonValueSchema as o,RuleSchema as s,RuleSetOptionsSchema as c,ScalarValueSchema as l}from"./schemas.mjs";import{compile as u}from"@makaio/framework/expression";const d=new Map,f=new Map;function p(e,t){if(`$and`in e){for(let n of e.$and)if(!p(n,t))return!1;return!0}if(`$or`in e){for(let n of e.$or)if(p(n,t))return!0;return!1}return`$not`in e?!p(e.$not,t):`$expr`in e?!!_(e.$expr).evalSync(t):h(g(t,e.field),e.operator)}function m(e,t,n={}){let{includeDisabled:r=!1}=n,i=[];for(let n of e)!r&&!n.enabled||p(n.condition,t)&&i.push(n);return i}function h(e,t){if(typeof t!=`object`||!t)return e===t;if(`$eq`in t)return e===t.$eq;if(`$ne`in t)return e!==t.$ne;if(`$in`in t)return t.$in.includes(e);if(`$nin`in t)return!t.$nin.includes(e);if(`$contains`in t)return Array.isArray(e)&&e.includes(t.$contains);if(`$containsPrefix`in t)return Array.isArray(e)&&e.some(e=>typeof e==`string`&&e.startsWith(t.$containsPrefix));if(`$exists`in t){let n=e!==void 0;return t.$exists?n:!n}return`$startsWith`in t?typeof e==`string`&&e.startsWith(t.$startsWith):`$endsWith`in t?typeof e==`string`&&e.endsWith(t.$endsWith):`$glob`in t?typeof e==`string`&&v(t.$glob).match(e):!1}function g(e,t){if(e==null)return;let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return;r=r[e]}return r}function _(e){return y(d,e,()=>u(e))}function v(t){return y(f,t,()=>new e(t))}function y(e,t,n){let r=e.get(t);if(r!==void 0)return e.delete(t),e.set(t,r),r;let i=n();if(e.set(t,i),e.size>256){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return i}export{t as ConditionSchema,n as ExpressionConditionSchema,r as FieldConditionSchema,i as FieldOperatorSchema,a as JsonObjectSchema,o as JsonValueSchema,s as RuleSchema,c as RuleSetOptionsSchema,l as ScalarValueSchema,p as evaluate,m as evaluateRules};
@@ -1,2 +1,2 @@
1
- import { a as JsonObjectSchema, c as RuleSetOptionsSchema, i as FieldOperatorSchema, l as ScalarValueSchema, n as ExpressionConditionSchema, o as JsonValueSchema, r as FieldConditionSchema, s as RuleSchema, t as ConditionSchema } from "../schemas-BZyi7v9g.mjs";
1
+ import { a as JsonObjectSchema, c as RuleSetOptionsSchema, i as FieldOperatorSchema, l as ScalarValueSchema, n as ExpressionConditionSchema, o as JsonValueSchema, r as FieldConditionSchema, s as RuleSchema, t as ConditionSchema } from "../schemas-CtzZDp29.mjs";
2
2
  export { ConditionSchema, ExpressionConditionSchema, FieldConditionSchema, FieldOperatorSchema, JsonObjectSchema, JsonValueSchema, RuleSchema, RuleSetOptionsSchema, ScalarValueSchema };
@@ -1 +1 @@
1
- import{DispatchingAuth as e,createWebSocketCloseEvent as t}from"@makaio/framework/node/transports";import{HonoWebSocketBridge as n,startBusServer as r}from"@makaio/framework/node/bus-server";import{ExplicitDescriptorDiscovery as i,FileConfigStorage as a,FileRegistryCache as o,FilesystemDescriptorDiscovery as s,MergedDescriptorDiscovery as c,NodeCredentialProvider as l,StoredCredentialProvider as u,bootMakaioRuntimeCore as d,bootMakaioRuntimeCore as f,bridgeExtensionBrowserEntries as ee,createHonoRouteGraph as p,createHttpRouteGraphBuilder as m,entrypointStem as h,isCliContributionLike as g,isMakaioExtensionLike as _,isMissingOptionalRuntimePackage as v,isWithinDirectory as y,loadExtensions as b,loadOrCreateMachineIdentity as x,machineKeysExist as S,registerAdapterNameResolver as C,resolveConventionEntrypoint as w,resolveStaticModelRegistryPath as T,runMigrations as E,tryImport as D,validateMachineKeys as O}from"@makaio/framework/runtime-node";import{isIP as k}from"node:net";var A=class{raw;eventListeners={message:new Set,close:new Set,error:new Set,open:new Set};constructor(e){this.raw=e}get readyState(){return this.raw.readyState}send(e){if(typeof e==`string`){this.raw.send(e);return}if(e instanceof Blob){e.arrayBuffer().then(e=>{this.raw.readyState===1&&this.raw.send(new Uint8Array(e))}).catch(()=>{this.dispatchError()});return}if(e instanceof ArrayBuffer){this.raw.send(new Uint8Array(e));return}ArrayBuffer.isView(e)&&this.raw.send(e)}close(e,t){this.raw.close(e,t)}addEventListener(e,t){this.eventListeners[e]?.add(t)}removeEventListener(e,t){this.eventListeners[e]?.delete(t)}dispatchMessage(e){let t=new MessageEvent(`message`,{data:e});for(let e of this.eventListeners.message)e(t)}dispatchClose(e,n){let r=t(e,n);for(let e of this.eventListeners.close)e(r)}dispatchError(){let e=new Event(`error`);for(let t of this.eventListeners.error)t(e)}},j=class{options;bridge;busServer=null;busReady=!1;connecting=!1;constructor(e){this.options=e,this.bridge=new n}get dispatchingAuth(){return this.options.auth instanceof e?this.options.auth:void 0}createWebSocketHandler(){let e=this.bridge,t=()=>this.busReady,n=new WeakMap;return{binaryType:`arraybuffer`,open(r){if(!t()){r.close(1013,`Bus server not ready`);return}let i=new A(r);n.set(r,i),e.accept(i)},message(e,t){n.get(e)?.dispatchMessage(t)},close(e,t,r){n.get(e)?.dispatchClose(t,r),n.delete(e)}}}async connect(e,t){if(this.connecting||this.busServer)throw Error(`[BunBusServerTransport] connect() called while transport is already connected or connecting`);this.connecting=!0;try{this.busServer=await r({websocket:this.bridge,bus:e,auth:this.options.auth,loopbackName:this.options.loopbackName??`bun`}),this.busReady=!0}catch(e){throw await this.stopBusServer(`startup error`),e}finally{this.connecting=!1}}async disconnect(){await this.stopBusServer(`shutdown`),this.bridge.close()}async stopBusServer(e){this.busReady=!1,this.busServer&&=(await this.busServer.stop().catch(t=>{console.error(`[BunBusServerTransport] Failed to stop bus server during ${e}:`,t)}),null)}};function M(e){if(e.headers.get(`upgrade`)?.toLowerCase()!==`websocket`)return!1;let{pathname:t}=new URL(e.url);return t===`/bus`?!0:t===`/`&&e.headers.get(`origin`)===null}function te(e){return(t,n)=>M(t)?n.upgrade(t)?void 0:new Response(`WebSocket upgrade failed`,{status:426,headers:{Upgrade:`websocket`}}):e.fetch(t)}function N(e){return e.port}async function P(e){let{port:t,hostname:n}=e.bunServer,r=e.createMount??(await import(`../create-static-mount-Cr24q94C.mjs`)).defaultCreateMount;return f(e.transport,t,n,{...e,createMount:r})}function F(e,t){let n=e,r=t;return{fetch(e,t){return n(e,t)},websocket:{binaryType:t.binaryType,open(e){r.open(e)},message(e,t){r.message(e,t)},close(e,t,n){r.close(e,t,n)}},activate(i){n=R(e,i),r=z(t,i)}}}function I(e){let t=[];return e.forEachActiveExtension((e,n)=>{B(n)&&t.push(n)}),t}function L(e){return Array.isArray(e)?e.flatMap(e=>L(e)):B(e)?[e]:[]}function R(e,t){return t.reduce((e,t)=>t.bun.createFetch?.(e)??e,e)}function z(e,t){return t.reduce((e,t)=>t.bun.createWebSocketHandler?.(e)??e,e)}function B(e){if(!H(e))return!1;let t=e.bun;return typeof e.name==`string`&&typeof e.displayName==`string`&&V(t)}function V(e){if(!H(e))return!1;let t=e.createFetch,n=e.createWebSocketHandler;return(t===void 0||typeof t==`function`)&&(n===void 0||typeof n==`function`)}function H(e){return typeof e==`object`&&!!e}function U(e){let t=e.timeoutMs??1e4,n=e.exit??(e=>process.exit(e)),r=!1;return async i=>{if(r)return;r=!0,console.info(`[${e.label}] ${i} received, shutting down...`);let a=setTimeout(()=>{console.error(`[${e.label}] Graceful shutdown timed out, forcing exit`),n(1)},t);try{process.env.MAKAIO_DEBUG&&console.info(`[${e.label}] Shutting down runtime...`),await e.runtime.shutdown(),process.env.MAKAIO_DEBUG&&console.info(`[${e.label}] Stopping Bun server...`),W(e.bunServer,e.label),process.env.MAKAIO_DEBUG&&console.info(`[${e.label}] Shutdown complete`),clearTimeout(a),n(0)}catch(t){W(e.bunServer,e.label),clearTimeout(a),console.error(`[${e.label}] Shutdown error:`,t),n(1)}}}function W(e,t){let n=e.stop?.(!0);G(n)&&n.catch(e=>{console.warn(`[${t}] Bun server stop failed during shutdown:`,e)})}function G(e){return typeof e==`object`&&!!e&&typeof e.catch==`function`}const K=/^(?=.{1,253}$)(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;function q(e){let t=e.env??process.env,n=e.defaultPort??3e3,r=e.defaultHost??`0.0.0.0`;return{port:J(t.PORT,n,e),host:Y(t.HOST,r,e)}}function J(e,t,n){let r=e?.trim(),i=r&&/^\d+$/.test(r)?Number.parseInt(r,10):NaN;return Number.isInteger(i)&&i>=1&&i<=65535?i:e===void 0?t:Z(`Invalid PORT: ${e}`,t,n)}function Y(e,t,n){let r=e?.trim();return r&&X(r)?r:e===void 0?t:Q(`Invalid HOST: ${e}`,t,n)}function X(e){return k(e)!==0||e===`localhost`||K.test(e)}function Z(e,t,n){return $(e,String(t),n),t}function Q(e,t,n){return $(e,t,n),t}function $(e,t,n){if((n.invalid??`throw`)===`throw`)throw Error(e);console.warn(`[${n.appName}] ${e}, falling back to ${t}`)}export{j as BunBusServerTransportProvider,i as ExplicitDescriptorDiscovery,a as FileConfigStorage,o as FileRegistryCache,s as FilesystemDescriptorDiscovery,c as MergedDescriptorDiscovery,l as NodeCredentialProvider,u as StoredCredentialProvider,P as bootMakaioRuntime,d as bootMakaioRuntimeCore,ee as bridgeExtensionBrowserEntries,I as collectActiveBunHostPackages,R as composeBunHostFetch,z as composeBunHostWebSocket,F as createBunHostRouter,te as createBunRouteGraphFetch,U as createGracefulShutdown,p as createHonoRouteGraph,m as createHttpRouteGraphBuilder,h as entrypointStem,g as isCliContributionLike,_ as isMakaioExtensionLike,v as isMissingOptionalRuntimePackage,y as isWithinDirectory,b as loadExtensions,x as loadOrCreateMachineIdentity,S as machineKeysExist,L as normalizeBunHostPackages,q as readBunServerEnv,C as registerAdapterNameResolver,w as resolveConventionEntrypoint,N as resolveListeningPort,T as resolveStaticModelRegistryPath,E as runMigrations,D as tryImport,O as validateMachineKeys};
1
+ import{DispatchingAuth as e,createWebSocketCloseEvent as t}from"@makaio/framework/node/transports";import{HonoWebSocketBridge as n,startBusServer as r}from"@makaio/framework/node/bus-server";import{ExplicitDescriptorDiscovery as i,FileConfigStorage as a,FileRegistryCache as o,FilesystemDescriptorDiscovery as s,MergedDescriptorDiscovery as c,NodeCredentialProvider as l,StoredCredentialProvider as u,bootMakaioRuntimeCore as d,bootMakaioRuntimeCore as f,bridgeExtensionBrowserEntries as ee,createHonoRouteGraph as p,createHttpRouteGraphBuilder as m,entrypointStem as h,isCliContributionLike as g,isMakaioExtensionLike as _,isMissingOptionalRuntimePackage as v,isWithinDirectory as y,loadExtensions as b,loadOrCreateMachineIdentity as x,machineKeysExist as S,registerAdapterNameResolver as C,resolveConventionEntrypoint as w,resolveStaticModelRegistryPath as T,runMigrations as E,tryImport as D,validateMachineKeys as O}from"@makaio/framework/runtime-node";import{isIP as k}from"node:net";var A=class{raw;eventListeners={message:new Set,close:new Set,error:new Set,open:new Set};constructor(e){this.raw=e}get readyState(){return this.raw.readyState}send(e){if(typeof e==`string`){this.raw.send(e);return}if(e instanceof Blob){e.arrayBuffer().then(e=>{this.raw.readyState===1&&this.raw.send(new Uint8Array(e))}).catch(()=>{this.dispatchError()});return}if(e instanceof ArrayBuffer){this.raw.send(new Uint8Array(e));return}ArrayBuffer.isView(e)&&this.raw.send(e)}close(e,t){this.raw.close(e,t)}addEventListener(e,t){this.eventListeners[e]?.add(t)}removeEventListener(e,t){this.eventListeners[e]?.delete(t)}dispatchMessage(e){let t=new MessageEvent(`message`,{data:e});for(let e of this.eventListeners.message)e(t)}dispatchClose(e,n){let r=t(e,n);for(let e of this.eventListeners.close)e(r)}dispatchError(){let e=new Event(`error`);for(let t of this.eventListeners.error)t(e)}},j=class{options;bridge;busServer=null;busReady=!1;connecting=!1;constructor(e){this.options=e,this.bridge=new n}get dispatchingAuth(){return this.options.auth instanceof e?this.options.auth:void 0}createWebSocketHandler(){let e=this.bridge,t=()=>this.busReady,n=new WeakMap;return{binaryType:`arraybuffer`,open(r){if(!t()){r.close(1013,`Bus server not ready`);return}let i=new A(r);n.set(r,i),e.accept(i)},message(e,t){n.get(e)?.dispatchMessage(t)},close(e,t,r){n.get(e)?.dispatchClose(t,r),n.delete(e)}}}async connect(e,t){if(this.connecting||this.busServer)throw Error(`[BunBusServerTransport] connect() called while transport is already connected or connecting`);this.connecting=!0;try{this.busServer=await r({websocket:this.bridge,bus:e,auth:this.options.auth,loopbackName:this.options.loopbackName??`bun`}),this.busReady=!0}catch(e){throw await this.stopBusServer(`startup error`),e}finally{this.connecting=!1}}async disconnect(){await this.stopBusServer(`shutdown`),this.bridge.close()}async stopBusServer(e){this.busReady=!1,this.busServer&&=(await this.busServer.stop().catch(t=>{console.error(`[BunBusServerTransport] Failed to stop bus server during ${e}:`,t)}),null)}};function M(e){if(e.headers.get(`upgrade`)?.toLowerCase()!==`websocket`)return!1;let{pathname:t}=new URL(e.url);return t===`/bus`?!0:t===`/`&&e.headers.get(`origin`)===null}function te(e){return(t,n)=>M(t)?n.upgrade(t)?void 0:new Response(`WebSocket upgrade failed`,{status:426,headers:{Upgrade:`websocket`}}):e.fetch(t)}function N(e){return e.port}async function P(e){let{port:t,hostname:n}=e.bunServer,r=e.createMount??(await import(`../create-static-mount-Dgxgi4W3.mjs`)).defaultCreateMount;return f(e.transport,t,n,{...e,createMount:r})}function F(e,t){let n=e,r=t;return{fetch(e,t){return n(e,t)},websocket:{binaryType:t.binaryType,open(e){r.open(e)},message(e,t){r.message(e,t)},close(e,t,n){r.close(e,t,n)}},activate(i){n=R(e,i),r=z(t,i)}}}function I(e){let t=[];return e.forEachActiveExtension((e,n)=>{B(n)&&t.push(n)}),t}function L(e){return Array.isArray(e)?e.flatMap(e=>L(e)):B(e)?[e]:[]}function R(e,t){return t.reduce((e,t)=>t.bun.createFetch?.(e)??e,e)}function z(e,t){return t.reduce((e,t)=>t.bun.createWebSocketHandler?.(e)??e,e)}function B(e){if(!H(e))return!1;let t=e.bun;return typeof e.name==`string`&&typeof e.displayName==`string`&&V(t)}function V(e){if(!H(e))return!1;let t=e.createFetch,n=e.createWebSocketHandler;return(t===void 0||typeof t==`function`)&&(n===void 0||typeof n==`function`)}function H(e){return typeof e==`object`&&!!e}function U(e){let t=e.timeoutMs??1e4,n=e.exit??(e=>process.exit(e)),r=!1;return async i=>{if(r)return;r=!0,console.info(`[${e.label}] ${i} received, shutting down...`);let a=setTimeout(()=>{console.error(`[${e.label}] Graceful shutdown timed out, forcing exit`),n(1)},t);try{process.env.MAKAIO_DEBUG&&console.info(`[${e.label}] Shutting down runtime...`),await e.runtime.shutdown(),process.env.MAKAIO_DEBUG&&console.info(`[${e.label}] Stopping Bun server...`),W(e.bunServer,e.label),process.env.MAKAIO_DEBUG&&console.info(`[${e.label}] Shutdown complete`),clearTimeout(a),n(0)}catch(t){W(e.bunServer,e.label),clearTimeout(a),console.error(`[${e.label}] Shutdown error:`,t),n(1)}}}function W(e,t){let n=e.stop?.(!0);G(n)&&n.catch(e=>{console.warn(`[${t}] Bun server stop failed during shutdown:`,e)})}function G(e){return typeof e==`object`&&!!e&&typeof e.catch==`function`}const K=/^(?=.{1,253}$)(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;function q(e){let t=e.env??process.env,n=e.defaultPort??3e3,r=e.defaultHost??`0.0.0.0`;return{port:J(t.PORT,n,e),host:Y(t.HOST,r,e)}}function J(e,t,n){let r=e?.trim(),i=r&&/^\d+$/.test(r)?Number.parseInt(r,10):NaN;return Number.isInteger(i)&&i>=1&&i<=65535?i:e===void 0?t:Z(`Invalid PORT: ${e}`,t,n)}function Y(e,t,n){let r=e?.trim();return r&&X(r)?r:e===void 0?t:Q(`Invalid HOST: ${e}`,t,n)}function X(e){return k(e)!==0||e===`localhost`||K.test(e)}function Z(e,t,n){return $(e,String(t),n),t}function Q(e,t,n){return $(e,t,n),t}function $(e,t,n){if((n.invalid??`throw`)===`throw`)throw Error(e);console.warn(`[${n.appName}] ${e}, falling back to ${t}`)}export{j as BunBusServerTransportProvider,i as ExplicitDescriptorDiscovery,a as FileConfigStorage,o as FileRegistryCache,s as FilesystemDescriptorDiscovery,c as MergedDescriptorDiscovery,l as NodeCredentialProvider,u as StoredCredentialProvider,P as bootMakaioRuntime,d as bootMakaioRuntimeCore,ee as bridgeExtensionBrowserEntries,I as collectActiveBunHostPackages,R as composeBunHostFetch,z as composeBunHostWebSocket,F as createBunHostRouter,te as createBunRouteGraphFetch,U as createGracefulShutdown,p as createHonoRouteGraph,m as createHttpRouteGraphBuilder,h as entrypointStem,g as isCliContributionLike,_ as isMakaioExtensionLike,v as isMissingOptionalRuntimePackage,y as isWithinDirectory,b as loadExtensions,x as loadOrCreateMachineIdentity,S as machineKeysExist,L as normalizeBunHostPackages,q as readBunServerEnv,C as registerAdapterNameResolver,w as resolveConventionEntrypoint,N as resolveListeningPort,T as resolveStaticModelRegistryPath,E as runMigrations,D as tryImport,O as validateMachineKeys};
@@ -1,3 +1,3 @@
1
- import { a as CODE_EXECUTION_DEFAULT_MAX_PROGRAM_FILES, c as CODE_EXECUTION_DEFAULT_MAX_SOURCE_BYTES, d as PiscinaCodeExecutionProviderOptions, i as CODE_EXECUTION_DEFAULT_MAX_INVOCATIONS_PER_WORKER, n as CODE_EXECUTION_DEFAULT_MAX_ARGUMENT_BYTES, o as CODE_EXECUTION_DEFAULT_MAX_QUEUED_INVOCATIONS, r as CODE_EXECUTION_DEFAULT_MAX_CONCURRENCY, s as CODE_EXECUTION_DEFAULT_MAX_RESULT_BYTES, t as CODE_EXECUTION_DEFAULT_IDLE_TIMEOUT_MS } from "../../types-KF8zuMhi.mjs";
2
- import { t as PiscinaCodeExecutionProvider } from "../../index-DnZksNTM.mjs";
1
+ import { a as CODE_EXECUTION_DEFAULT_MAX_PROGRAM_FILES, c as CODE_EXECUTION_DEFAULT_MAX_SOURCE_BYTES, d as PiscinaCodeExecutionProviderOptions, i as CODE_EXECUTION_DEFAULT_MAX_INVOCATIONS_PER_WORKER, n as CODE_EXECUTION_DEFAULT_MAX_ARGUMENT_BYTES, o as CODE_EXECUTION_DEFAULT_MAX_QUEUED_INVOCATIONS, r as CODE_EXECUTION_DEFAULT_MAX_CONCURRENCY, s as CODE_EXECUTION_DEFAULT_MAX_RESULT_BYTES, t as CODE_EXECUTION_DEFAULT_IDLE_TIMEOUT_MS } from "../../types-hkExapGH.mjs";
2
+ import { t as PiscinaCodeExecutionProvider } from "../../index-DQKVQPUS.mjs";
3
3
  export { CODE_EXECUTION_DEFAULT_IDLE_TIMEOUT_MS, CODE_EXECUTION_DEFAULT_MAX_ARGUMENT_BYTES, CODE_EXECUTION_DEFAULT_MAX_CONCURRENCY, CODE_EXECUTION_DEFAULT_MAX_INVOCATIONS_PER_WORKER, CODE_EXECUTION_DEFAULT_MAX_PROGRAM_FILES, CODE_EXECUTION_DEFAULT_MAX_QUEUED_INVOCATIONS, CODE_EXECUTION_DEFAULT_MAX_RESULT_BYTES, CODE_EXECUTION_DEFAULT_MAX_SOURCE_BYTES, PiscinaCodeExecutionProvider, PiscinaCodeExecutionProviderOptions };
@@ -1 +1 @@
1
- import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"../../types-Bh2fQoxM.mjs";import{t as c}from"../../code-execution-ByLSAlEg2.mjs";export{s as CODE_EXECUTION_DEFAULT_IDLE_TIMEOUT_MS,r as CODE_EXECUTION_DEFAULT_MAX_ARGUMENT_BYTES,a as CODE_EXECUTION_DEFAULT_MAX_CONCURRENCY,n as CODE_EXECUTION_DEFAULT_MAX_INVOCATIONS_PER_WORKER,e as CODE_EXECUTION_DEFAULT_MAX_PROGRAM_FILES,i as CODE_EXECUTION_DEFAULT_MAX_QUEUED_INVOCATIONS,o as CODE_EXECUTION_DEFAULT_MAX_RESULT_BYTES,t as CODE_EXECUTION_DEFAULT_MAX_SOURCE_BYTES,c as PiscinaCodeExecutionProvider};
1
+ import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"../../types-CsmvIK25.mjs";import{t as c}from"../../code-execution-pUF4IO462.mjs";export{s as CODE_EXECUTION_DEFAULT_IDLE_TIMEOUT_MS,r as CODE_EXECUTION_DEFAULT_MAX_ARGUMENT_BYTES,a as CODE_EXECUTION_DEFAULT_MAX_CONCURRENCY,n as CODE_EXECUTION_DEFAULT_MAX_INVOCATIONS_PER_WORKER,e as CODE_EXECUTION_DEFAULT_MAX_PROGRAM_FILES,i as CODE_EXECUTION_DEFAULT_MAX_QUEUED_INVOCATIONS,o as CODE_EXECUTION_DEFAULT_MAX_RESULT_BYTES,t as CODE_EXECUTION_DEFAULT_MAX_SOURCE_BYTES,c as PiscinaCodeExecutionProvider};
@@ -1,2 +1,2 @@
1
- import { a as FilesystemDescriptorDiscovery, c as enumerateDescriptorPaths, i as ExtensionEntrypointModule, n as ExplicitDescriptorDiscovery, o as FilesystemDescriptorDiscoveryOptions, r as ExtensionDiscovery, s as MergedDescriptorDiscovery, t as DiscoveredExtension } from "../extension-discovery-Dx118u_N.mjs";
1
+ import { a as FilesystemDescriptorDiscovery, c as enumerateDescriptorPaths, i as ExtensionEntrypointModule, n as ExplicitDescriptorDiscovery, o as FilesystemDescriptorDiscoveryOptions, r as ExtensionDiscovery, s as MergedDescriptorDiscovery, t as DiscoveredExtension } from "../extension-discovery-CA2IhDRo.mjs";
2
2
  export { DiscoveredExtension, ExplicitDescriptorDiscovery, ExtensionDiscovery, ExtensionEntrypointModule, FilesystemDescriptorDiscovery, FilesystemDescriptorDiscoveryOptions, MergedDescriptorDiscovery, enumerateDescriptorPaths };
@@ -1,2 +1,2 @@
1
- import { a as isMakaioExtensionLike, c as resolveConventionEntrypoint, i as isCliContributionLike, o as isWithinDirectory, r as entrypointStem } from "../load-extensions-D6SVKBPw.mjs";
1
+ import { a as isMakaioExtensionLike, c as resolveConventionEntrypoint, i as isCliContributionLike, o as isWithinDirectory, r as entrypointStem } from "../load-extensions-DGstT4_p.mjs";
2
2
  export { entrypointStem, isCliContributionLike, isMakaioExtensionLike, isWithinDirectory, resolveConventionEntrypoint };
@@ -1 +1 @@
1
- import{i as e,l as t,o as n,r,s as i}from"../load-extensions-bwisKaW0.mjs";export{r as entrypointStem,e as isCliContributionLike,n as isMakaioExtensionLike,i as isWithinDirectory,t as resolveConventionEntrypoint};
1
+ import{i as e,l as t,o as n,r,s as i}from"../load-extensions-BVgxTj_y.mjs";export{r as entrypointStem,e as isCliContributionLike,n as isMakaioExtensionLike,i as isWithinDirectory,t as resolveConventionEntrypoint};
@@ -1,10 +1,10 @@
1
1
  import { RuntimeSubjects } from "./bus/runtime/namespace.mjs";
2
2
  import { NodeClientBinaryStrategyDependencyOptions, createNodeClientBinaryStrategyDependencies } from "./client-binary-strategy-dependencies.mjs";
3
- import { a as CODE_EXECUTION_DEFAULT_MAX_PROGRAM_FILES, c as CODE_EXECUTION_DEFAULT_MAX_SOURCE_BYTES, d as PiscinaCodeExecutionProviderOptions, i as CODE_EXECUTION_DEFAULT_MAX_INVOCATIONS_PER_WORKER, n as CODE_EXECUTION_DEFAULT_MAX_ARGUMENT_BYTES, o as CODE_EXECUTION_DEFAULT_MAX_QUEUED_INVOCATIONS, r as CODE_EXECUTION_DEFAULT_MAX_CONCURRENCY, s as CODE_EXECUTION_DEFAULT_MAX_RESULT_BYTES, t as CODE_EXECUTION_DEFAULT_IDLE_TIMEOUT_MS } from "../types-KF8zuMhi.mjs";
4
- import { t as PiscinaCodeExecutionProvider } from "../index-DnZksNTM.mjs";
5
- import { a as FilesystemDescriptorDiscovery, n as ExplicitDescriptorDiscovery, o as FilesystemDescriptorDiscoveryOptions, r as ExtensionDiscovery, s as MergedDescriptorDiscovery, t as DiscoveredExtension } from "../extension-discovery-Dx118u_N.mjs";
6
- import { a as isMakaioExtensionLike, c as resolveConventionEntrypoint, i as isCliContributionLike, n as LoadExtensionsOptions, o as isWithinDirectory, r as entrypointStem, s as loadExtensions, t as DescriptorSourcePackageGroup } from "../load-extensions-D6SVKBPw.mjs";
7
- import { $ as WorkflowRuntimeAuthorityConnector, A as createLocalGitWorkspacePreparation, An as prepareAdapterRuntime, B as HeadlessWorkflowWorkerResult, Bt as ServerTransportProvider, C as admitWorkflowRunOperation, Cn as HonoRouteGraphOptions, Dn as PrepareAdapterRuntimeInput, E as registerWorkerRuntime, En as ActivatedAdapterRuntimeIdentity, F as HeadlessWorkerContributionLoader, Ft as WorkflowRunResult, G as WorkloadControlBinding, H as runHeadlessWorkflowWorker, Ht as UpstreamTelemetryBootOptions, I as HeadlessWorkerExecutor, It as BootCoordinatorSetupContext, J as runWorkloadInvocation, K as WorkloadInvocationPreparation, L as HeadlessWorkerMaterializer, Lt as BootMakaioRuntimeOptions, M as HeadlessWorkerBootstrap, Mt as IWorkflowRunner, N as HeadlessWorkerBootstrapCredentials, On as PreparedAdapterRuntime, P as HeadlessWorkerBusConnector, Pt as ThinWorkflowPiscinaRunnerOptions, Q as IsolatedWorkflowRuntimeContext, R as HeadlessWorkerPostCommitObserver, Rt as CoreBootOptions, S as RuntimeRegistrationRefusedError, Sn as HonoRouteGraph, T as registerAndAdmitWorkflowRun, Tn as ActivateAdapterRuntimeIdentityInput, U as InstalledWorkloadAdapter, Ut as WorkflowRunnerBootOptions, Vt as TransportReadyInfo, W as RunWorkloadInvocationOptions, X as CreateIsolatedWorkflowRuntimeOptions, Y as SetupProcessGroupObservation, Z as IsolatedWorkflowRuntime, _ as OperationDeliveryEndpointIdentity, _n as resolveFrameworkSpecifier, _t as submitAttemptOutcomeWithAck, a as InstalledAttemptControlEndpoint, an as DatabaseBootOptions, b as RegisterAndAdmitWorkflowRunOptions, bn as HttpContributionPhase, c as BootstrapStartRefusedError, cn as initializeNodeDatabase, d as bootstrapWorkerRuntime, dn as selectFrameworkCorePackages, dt as AuthorityRequestDeliveryError, et as WorkflowRuntimeContributionLoader, f as AdmitWorkflowRunOperationOptions, fn as ShutdownStep, g as OperationDeliveryEndpoint, gn as NoopFrameworkModuleResolver, h as OperationAdmissionRefusedError, hn as NodeFrameworkModuleResolver, i as AttemptControlReportOptions, in as resolveWorkflowWorkerEntry, j as LocalGitSourceOptions, jt as ThinWorkflowPiscinaRunner, kn as activateAdapterRuntimeIdentity, l as BootstrapWorkerRuntimeOptions, ln as HostCapabilityDeclaration, lt as AttemptOutcomeDeliveryError, m as DeliverableOperationKind, mn as FrameworkModuleResolver, n as AttemptControlEndpointIdentity, nn as WorkflowWorkerEntryMode, nt as InProcessWorkflowRunner, o as installAttemptControlEndpoint, on as InitializeNodeDatabaseOptions, p as AdmittedWorkflowRun, pn as BridgeBrowserOptions, pt as OutcomeDeliveryError, q as WorkloadInvocationResult, r as AttemptControlLastReport, rn as WorkflowWorkerEntryResolverOptions, rt as InProcessWorkflowRunnerOptions, s as BootstrapRuntimeConnection, sn as InitializeNodeDatabaseResult, t as AttemptControlEndpointDeps, tt as createIsolatedWorkflowRuntime, u as StartedWorkerRuntime, un as normalizeNodeHostCapabilities, v as OperationDeliveryHandler, vn as HttpRouteGraphBuilder, w as installOperationDeliveryEndpoint, wn as createHonoRouteGraph, x as RegisterWorkerRuntimeOptions, xn as HttpRouteContribution, y as OperationDeliveryHandlers, yn as createHttpRouteGraphBuilder, z as HeadlessWorkflowWorkerDeps, zt as MakaioRuntime } from "../index-LRAmVQLj.mjs";
3
+ import { a as CODE_EXECUTION_DEFAULT_MAX_PROGRAM_FILES, c as CODE_EXECUTION_DEFAULT_MAX_SOURCE_BYTES, d as PiscinaCodeExecutionProviderOptions, i as CODE_EXECUTION_DEFAULT_MAX_INVOCATIONS_PER_WORKER, n as CODE_EXECUTION_DEFAULT_MAX_ARGUMENT_BYTES, o as CODE_EXECUTION_DEFAULT_MAX_QUEUED_INVOCATIONS, r as CODE_EXECUTION_DEFAULT_MAX_CONCURRENCY, s as CODE_EXECUTION_DEFAULT_MAX_RESULT_BYTES, t as CODE_EXECUTION_DEFAULT_IDLE_TIMEOUT_MS } from "../types-hkExapGH.mjs";
4
+ import { t as PiscinaCodeExecutionProvider } from "../index-DQKVQPUS.mjs";
5
+ import { a as FilesystemDescriptorDiscovery, n as ExplicitDescriptorDiscovery, o as FilesystemDescriptorDiscoveryOptions, r as ExtensionDiscovery, s as MergedDescriptorDiscovery, t as DiscoveredExtension } from "../extension-discovery-CA2IhDRo.mjs";
6
+ import { a as isMakaioExtensionLike, c as resolveConventionEntrypoint, i as isCliContributionLike, n as LoadExtensionsOptions, o as isWithinDirectory, r as entrypointStem, s as loadExtensions, t as DescriptorSourcePackageGroup } from "../load-extensions-DGstT4_p.mjs";
7
+ import { $ as WorkflowRuntimeAuthorityConnector, A as createLocalGitWorkspacePreparation, An as prepareAdapterRuntime, B as HeadlessWorkflowWorkerResult, Bt as ServerTransportProvider, C as admitWorkflowRunOperation, Cn as HonoRouteGraphOptions, Dn as PrepareAdapterRuntimeInput, E as registerWorkerRuntime, En as ActivatedAdapterRuntimeIdentity, F as HeadlessWorkerContributionLoader, Ft as WorkflowRunResult, G as WorkloadControlBinding, H as runHeadlessWorkflowWorker, Ht as UpstreamTelemetryBootOptions, I as HeadlessWorkerExecutor, It as BootCoordinatorSetupContext, J as runWorkloadInvocation, K as WorkloadInvocationPreparation, L as HeadlessWorkerMaterializer, Lt as BootMakaioRuntimeOptions, M as HeadlessWorkerBootstrap, Mt as IWorkflowRunner, N as HeadlessWorkerBootstrapCredentials, On as PreparedAdapterRuntime, P as HeadlessWorkerBusConnector, Pt as ThinWorkflowPiscinaRunnerOptions, Q as IsolatedWorkflowRuntimeContext, R as HeadlessWorkerPostCommitObserver, Rt as CoreBootOptions, S as RuntimeRegistrationRefusedError, Sn as HonoRouteGraph, T as registerAndAdmitWorkflowRun, Tn as ActivateAdapterRuntimeIdentityInput, U as InstalledWorkloadAdapter, Ut as WorkflowRunnerBootOptions, Vt as TransportReadyInfo, W as RunWorkloadInvocationOptions, X as CreateIsolatedWorkflowRuntimeOptions, Y as SetupProcessGroupObservation, Z as IsolatedWorkflowRuntime, _ as OperationDeliveryEndpointIdentity, _n as resolveFrameworkSpecifier, _t as submitAttemptOutcomeWithAck, a as InstalledAttemptControlEndpoint, an as DatabaseBootOptions, b as RegisterAndAdmitWorkflowRunOptions, bn as HttpContributionPhase, c as BootstrapStartRefusedError, cn as initializeNodeDatabase, d as bootstrapWorkerRuntime, dn as selectFrameworkCorePackages, dt as AuthorityRequestDeliveryError, et as WorkflowRuntimeContributionLoader, f as AdmitWorkflowRunOperationOptions, fn as ShutdownStep, g as OperationDeliveryEndpoint, gn as NoopFrameworkModuleResolver, h as OperationAdmissionRefusedError, hn as NodeFrameworkModuleResolver, i as AttemptControlReportOptions, in as resolveWorkflowWorkerEntry, j as LocalGitSourceOptions, jt as ThinWorkflowPiscinaRunner, kn as activateAdapterRuntimeIdentity, l as BootstrapWorkerRuntimeOptions, ln as HostCapabilityDeclaration, lt as AttemptOutcomeDeliveryError, m as DeliverableOperationKind, mn as FrameworkModuleResolver, n as AttemptControlEndpointIdentity, nn as WorkflowWorkerEntryMode, nt as InProcessWorkflowRunner, o as installAttemptControlEndpoint, on as InitializeNodeDatabaseOptions, p as AdmittedWorkflowRun, pn as BridgeBrowserOptions, pt as OutcomeDeliveryError, q as WorkloadInvocationResult, r as AttemptControlLastReport, rn as WorkflowWorkerEntryResolverOptions, rt as InProcessWorkflowRunnerOptions, s as BootstrapRuntimeConnection, sn as InitializeNodeDatabaseResult, t as AttemptControlEndpointDeps, tt as createIsolatedWorkflowRuntime, u as StartedWorkerRuntime, un as normalizeNodeHostCapabilities, v as OperationDeliveryHandler, vn as HttpRouteGraphBuilder, w as installOperationDeliveryEndpoint, wn as createHonoRouteGraph, x as RegisterWorkerRuntimeOptions, xn as HttpRouteContribution, y as OperationDeliveryHandlers, yn as createHttpRouteGraphBuilder, z as HeadlessWorkflowWorkerDeps, zt as MakaioRuntime } from "../index-DtCVHx8-.mjs";
8
8
  import { ConfiguredRuntimeOptions, LoadMakaioConfigOptions, LoadedMakaioConfig, MAKAIO_CONFIG_FILE_ENV, MAKAIO_HOME_ENV, MakaioConfig, ParseMakaioConfigOptions, ParsedMakaioConfig, WorkflowRunnerConfig, buildConfiguredRuntimeOptions, createMakaioConfigDiscovery, defineMakaioConfig, loadMakaioConfig, parseMakaioConfig, resolveMakaioConfigPath, resolveMakaioHome, shouldIncludeExtension } from "./makaio-config.mjs";
9
9
  import { RotateWorkflowExecutionBusSecretParams, captureWorkflowExecutionBusSecretCleanup } from "./workflow-execution-bus-access.mjs";
10
10
  import { z } from "zod";