@makaio/framework 1.0.0-dev-1789609124644 → 1.0.0-dev-1790066089222

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 (361) hide show
  1. package/dist/.makaio-build.json +2 -2
  2. package/dist/{adapter-C4v_gNTI.mjs → adapter-DSRgsh2d.mjs} +1 -1
  3. package/dist/adapter-subsystem/index.d.mts +15 -7
  4. package/dist/adapter-subsystem/index.mjs +1 -1
  5. package/dist/adapters/claude/index.mjs +3 -3
  6. package/dist/adapters/config/index.d.mts +1 -1
  7. package/dist/adapters/index.d.mts +2 -2
  8. package/dist/adapters/node.d.mts +1 -1
  9. package/dist/{attempt-record-codec-DaQ3WHUs.mjs → attempt-record-codec-DXpdMgyI.mjs} +1 -1
  10. package/dist/bus/index.d.mts +120 -8
  11. package/dist/bus/index.mjs +1 -1
  12. package/dist/bus-ceMF9rsq.mjs +9 -0
  13. package/dist/client-DWSwtFyI.mjs +1 -0
  14. package/dist/clients/index.d.mts +179 -12
  15. package/dist/clients/index.mjs +1 -1
  16. package/dist/clients/managed-install.d.mts +1 -1
  17. package/dist/code-execution/worker-entry.d.mts +1 -1
  18. package/dist/code-execution/worker-entry.mjs +1 -1
  19. package/dist/{code-execution-pUF4IO462.mjs → code-execution-DWSux6k1.mjs} +1 -1
  20. package/dist/contracts/adapter/index.d.mts +2 -2
  21. package/dist/contracts/adapter/index.mjs +1 -1
  22. package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
  23. package/dist/contracts/artifact/index.d.mts +2 -2
  24. package/dist/contracts/auth/index.d.mts +2 -2
  25. package/dist/contracts/automation-trigger/index.d.mts +3 -3
  26. package/dist/contracts/canonical-model/index.d.mts +1 -1
  27. package/dist/contracts/capabilities/index.d.mts +1 -1
  28. package/dist/contracts/client/index.d.mts +3 -3
  29. package/dist/contracts/client/index.mjs +1 -1
  30. package/dist/contracts/code-execution/index.d.mts +1 -1
  31. package/dist/contracts/common/index.d.mts +1 -1
  32. package/dist/contracts/config/index.d.mts +2 -47
  33. package/dist/contracts/context-projection/index.d.mts +232 -0
  34. package/dist/contracts/context-projection/index.mjs +1 -0
  35. package/dist/contracts/extension/index.d.mts +6 -6
  36. package/dist/contracts/extension/index.mjs +1 -1
  37. package/dist/contracts/facet/index.d.mts +1 -1
  38. package/dist/contracts/harness/index.d.mts +1 -1
  39. package/dist/contracts/host/index.d.mts +1 -1
  40. package/dist/contracts/index.d.mts +43 -43
  41. package/dist/contracts/index.mjs +1 -1
  42. package/dist/contracts/materialization/index.d.mts +2 -2
  43. package/dist/contracts/model-registry/index.d.mts +1 -1
  44. package/dist/contracts/native-session-supervisor/index.d.mts +1 -1
  45. package/dist/contracts/platform/index.d.mts +1 -1
  46. package/dist/contracts/provider/index.d.mts +2 -2
  47. package/dist/contracts/reaction/index.d.mts +1 -1
  48. package/dist/contracts/session/index.d.mts +3 -3
  49. package/dist/contracts/session/index.mjs +1 -1
  50. package/dist/contracts/shared/index.d.mts +2 -2
  51. package/dist/contracts/skill/index.d.mts +1 -1
  52. package/dist/contracts/telemetry/index.d.mts +1 -1
  53. package/dist/contracts/timeout/index.d.mts +1 -1
  54. package/dist/contracts/variant/index.d.mts +1 -1
  55. package/dist/contracts/worker/index.d.mts +2 -2
  56. package/dist/contracts/workflow/index.d.mts +2 -2
  57. package/dist/{contribution-DDbHzCPF.d.mts → contribution-1GL7Rjaq.d.mts} +2 -2
  58. package/dist/credential-ref-w4ZYpYW0.d.mts +49 -0
  59. package/dist/{definition-CuaBQyde.d.mts → definition-DeIGoROj.d.mts} +1 -1
  60. package/dist/{descriptor-to-package-Dw8dnl5E.mjs → descriptor-to-package-BPIArq6N.mjs} +1 -1
  61. package/dist/{detached-extension-handle-DN3aqLyq.mjs → detached-extension-handle-W5_yfCyE.mjs} +1 -1
  62. package/dist/drizzle/0040_session_generation.sql +1 -0
  63. package/dist/drizzle/0041_session_principal_owner.sql +1 -0
  64. package/dist/drizzle/meta/_journal.json +14 -0
  65. package/dist/{execution-attempt-owner-recovery-CE_rvHKE.mjs → execution-attempt-owner-recovery-BZOEVYFH.mjs} +1 -1
  66. package/dist/extension-C6ANjR33.mjs +1 -0
  67. package/dist/{extension-context-BH31eOMv.d.mts → extension-context-pQ7Uio_s.d.mts} +44 -1
  68. package/dist/{extension-discovery-CA2IhDRo.d.mts → extension-discovery-Rup-gANp.d.mts} +114 -15
  69. package/dist/extension-kOwzAMud.mjs +1 -0
  70. package/dist/extension-namespace-CeRpt6C8.mjs +1 -0
  71. package/dist/{framework-packages-Bg4edkkM.mjs → framework-packages-U4Xhouxe.mjs} +1 -1
  72. package/dist/{hook-responses-Dq16X3Cb.d.mts → hook-responses-B882RcQc.d.mts} +48 -5
  73. package/dist/{index-Dm3d490n.d.mts → index-B2bxgKiK.d.mts} +1 -1
  74. package/dist/{index-7CVumCjj.d.mts → index-BTpkpHIS.d.mts} +65 -9
  75. package/dist/{index-Bh57xARQ.d.mts → index-BUv9gfRT.d.mts} +3 -3
  76. package/dist/{index-C6e9cwAl2.d.mts → index-BjQtqMxP2.d.mts} +4 -4
  77. package/dist/{index-B-u0Tu8X.d.mts → index-Bqi44ODz.d.mts} +37 -37
  78. package/dist/{index-CIzvBH8O.d.mts → index-C8two8wz.d.mts} +1 -1
  79. package/dist/{index-oxZt93RL.d.mts → index-CESqYf8a.d.mts} +2 -2
  80. package/dist/{index-C87P0WpY2.d.mts → index-CmCLAMNs.d.mts} +1 -1
  81. package/dist/index-CyEE1RI5.d.mts +869 -0
  82. package/dist/{index-De_oh9M-2.d.mts → index-D6Uq1btG.d.mts} +87 -10
  83. package/dist/{index-CRZ1jrxp.d.mts → index-DDSt0uS2.d.mts} +160 -12
  84. package/dist/{index-B6WkHnCQ.d.mts → index-DRxgmrad.d.mts} +1 -1
  85. package/dist/{index-U--ajOHy.d.mts → index-DUYjTfHD.d.mts} +1 -1
  86. package/dist/{index-HJkz7i4E.d.mts → index-DdJKsdya.d.mts} +188 -10
  87. package/dist/{index-B4pPwpKk.d.mts → index-DfREUyAk.d.mts} +1 -1
  88. package/dist/{index-ClKwF6LE.d.mts → index-Di-R1gmo.d.mts} +2 -2
  89. package/dist/{index-DWANFpTG.d.mts → index-Jdju2W3y.d.mts} +1 -1
  90. package/dist/{index-DQKVQPUS.d.mts → index-L6mssyeZ.d.mts} +1 -1
  91. package/dist/{index-B8v1-2-V2.d.mts → index-anIxF_eT.d.mts} +1 -1
  92. package/dist/{index-iVisrVdC2.d.mts → index-bYBnDBl32.d.mts} +539 -4
  93. package/dist/{index-Bg3WVL8n.d.mts → index-gNdH1F6r.d.mts} +531 -26
  94. package/dist/{index-zmDRR8gv2.d.mts → index-m5ZQFglW2.d.mts} +1 -1
  95. package/dist/{index-mTaFX2HH2.d.mts → index-uk8icWON2.d.mts} +419 -19
  96. package/dist/kernel/cli/index.d.mts +2 -2
  97. package/dist/kernel/cli/register.d.mts +1 -1
  98. package/dist/kernel/extension/index.d.mts +3 -2
  99. package/dist/kernel/extension/index.mjs +1 -1
  100. package/dist/kernel/index.d.mts +6 -6
  101. package/dist/kernel/index.mjs +1 -1
  102. package/dist/kernel/namespace/index.d.mts +1 -1
  103. package/dist/kernel/observability/index.d.mts +2 -2
  104. package/dist/kernel/observability/index.mjs +1 -1
  105. package/dist/kernel/providers/index.d.mts +1 -1
  106. package/dist/kernel/window/index.d.mts +1 -1
  107. package/dist/{lib-BF5XBSfw.mjs → lib-BdyGVjpO.mjs} +1 -1
  108. package/dist/{lib-Dljw2Cqh.mjs → lib-DxP3tPm9.mjs} +1 -1
  109. package/dist/load-extensions-BGfSWW_R.mjs +1 -0
  110. package/dist/{load-extensions-DGstT4_p.d.mts → load-extensions-Be_lOjm_.d.mts} +27 -14
  111. package/dist/mcp-http-server/index.mjs +1 -1
  112. package/dist/{namespace-BMdYJN_t.mjs → namespace-CqJhR19O.mjs} +1 -1
  113. package/dist/{namespace-Cmu-5_P9.d.mts → namespace-DudchWPb.d.mts} +457 -0
  114. package/dist/{namespace-BEbQb19g.d.mts → namespace-Eir1wQ_r.d.mts} +2 -2
  115. package/dist/node/bus-server/index.d.mts +1 -1
  116. package/dist/node/bus-server/server-lifecycle.d.mts +1 -1
  117. package/dist/node/transports/index.d.mts +102 -4
  118. package/dist/node/transports/index.mjs +2 -2
  119. package/dist/{orchestrator-shared-CtPB6PAr.mjs → orchestrator-shared-CF-jPH91.mjs} +1 -1
  120. package/dist/ownership-memory-handler-C-y9zQf8.mjs +1 -0
  121. package/dist/package-AlsbnlSt.mjs +159 -0
  122. package/dist/{package-CDj3F-L3.d.mts → package-CwyC-Krg.d.mts} +1 -1
  123. package/dist/{package-DYScYC0D.mjs → package-kkPGlxMm.mjs} +1 -1
  124. package/dist/package.json +1 -1
  125. package/dist/{registry-DNMjJ-Oj.mjs → registry-DtaRGU8i.mjs} +1 -0
  126. package/dist/rules/index.d.mts +1 -1
  127. package/dist/rules/index.mjs +1 -1
  128. package/dist/rules/schemas.d.mts +1 -1
  129. package/dist/runtime-bun/index.d.mts +2 -2
  130. package/dist/runtime-bun/index.mjs +1 -1
  131. package/dist/runtime-node/boot-config.d.mts +45 -0
  132. package/dist/runtime-node/boot-config.mjs +1 -0
  133. package/dist/runtime-node/code-execution/index.d.mts +2 -2
  134. package/dist/runtime-node/code-execution/index.mjs +1 -1
  135. package/dist/runtime-node/extension-discovery.d.mts +2 -2
  136. package/dist/runtime-node/extension-discovery.mjs +1 -1
  137. package/dist/runtime-node/extension-validation.d.mts +1 -1
  138. package/dist/runtime-node/extension-validation.mjs +1 -1
  139. package/dist/runtime-node/index.d.mts +345 -27
  140. package/dist/runtime-node/index.mjs +21 -24
  141. package/dist/runtime-node/makaio-config.d.mts +1 -1
  142. package/dist/runtime-node/makaio-config.mjs +1 -1
  143. package/dist/runtime-node/workflow-worker/index.d.mts +1 -1
  144. package/dist/runtime-node/workflow-worker/index.mjs +1 -1
  145. package/dist/runtime-node/workflow-worker/worker-entry.mjs +1 -1
  146. package/dist/{schema-BA1cHBbc.d.mts → schema-FY0EakKe.d.mts} +56 -0
  147. package/dist/schemas-CkxAK13D.mjs +1 -0
  148. package/dist/{schemas-CaYEFzK_.d.mts → schemas-FgVQek-j.d.mts} +2 -2
  149. package/dist/services/adapter-runtime/index.d.mts +3 -3
  150. package/dist/services/adapter-runtime/namespace.d.mts +1 -1
  151. package/dist/services/adapter-runtime/schemas.d.mts +1 -1
  152. package/dist/services/adapter-subsystem/index.d.mts +3 -3
  153. package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
  154. package/dist/services/agent-runtime/index.d.mts +2 -2
  155. package/dist/services/agent-runtime/namespace.d.mts +1 -1
  156. package/dist/services/agent-runtime/schemas.d.mts +1 -1
  157. package/dist/services/automation-trigger/index.d.mts +19 -0
  158. package/dist/services/capability/index.d.mts +2 -2
  159. package/dist/services/code-execution/index.d.mts +1 -1
  160. package/dist/services/codebase/index.d.mts +2 -2
  161. package/dist/services/codebase/namespace.d.mts +1 -1
  162. package/dist/services/codebase/schemas.d.mts +1 -1
  163. package/dist/services/compression/index.d.mts +2 -2
  164. package/dist/services/compression/namespace.d.mts +1 -1
  165. package/dist/services/compression/schemas.d.mts +1 -1
  166. package/dist/services/context-projection/index.d.mts +94 -0
  167. package/dist/services/context-projection/index.mjs +1 -0
  168. package/dist/services/context-rules/index.d.mts +1 -1
  169. package/dist/services/execution-target/index.d.mts +3 -3
  170. package/dist/services/execution-target/namespace.d.mts +1 -1
  171. package/dist/services/execution-target/schemas.d.mts +1 -1
  172. package/dist/services/filesystem/index.d.mts +1 -1
  173. package/dist/services/index.d.mts +45 -40
  174. package/dist/services/index.mjs +1 -1
  175. package/dist/services/log-import/browser.d.mts +2 -2
  176. package/dist/services/log-import/index.d.mts +2 -2
  177. package/dist/services/log-import/log-import.d.mts +1 -1
  178. package/dist/services/materialization/index.d.mts +1 -1
  179. package/dist/services/model-registry/index.d.mts +1 -1
  180. package/dist/services/preferences/index.d.mts +2 -2
  181. package/dist/services/preferences/schemas.d.mts +1 -1
  182. package/dist/services/preferences/storage-namespace.d.mts +2 -2
  183. package/dist/services/provider-context/index.d.mts +1 -1
  184. package/dist/services/session/handlers/index.d.mts +1 -1
  185. package/dist/services/session/index.d.mts +9 -9
  186. package/dist/services/session/index.mjs +1 -1
  187. package/dist/services/session/messages/namespace.d.mts +1 -1
  188. package/dist/services/session/orchestrator-testing/index.d.mts +1 -1
  189. package/dist/services/session/orchestrator-testing/index.mjs +1 -1
  190. package/dist/services/session/session-events/namespace.d.mts +1 -1
  191. package/dist/services/session/storage/namespace.d.mts +1 -1
  192. package/dist/services/session/storage/schema.d.mts +1 -1
  193. package/dist/services/session/storage/schema.mjs +1 -1
  194. package/dist/services/session/testing/index.mjs +4 -2
  195. package/dist/services/session/testing/orchestrator-shared.d.mts +1 -1
  196. package/dist/services/session/testing/orchestrator-shared.mjs +1 -1
  197. package/dist/services/session/turns/namespace.d.mts +1 -1
  198. package/dist/services/session-editor/index.d.mts +1 -1
  199. package/dist/services/settings/index.d.mts +3 -3
  200. package/dist/services/settings/namespace.d.mts +232 -3
  201. package/dist/services/settings/namespace.mjs +1 -1
  202. package/dist/services/settings/storage/clients-namespace.d.mts +1 -1
  203. package/dist/services/settings/storage/index.d.mts +3 -3
  204. package/dist/services/settings/storage/providers-namespace.d.mts +1 -1
  205. package/dist/services/subagent/index.d.mts +1 -1
  206. package/dist/services/subagent-template/index.d.mts +2 -2
  207. package/dist/services/subagent-template/namespace.d.mts +1 -1
  208. package/dist/services/subagent-template/schemas.d.mts +1 -1
  209. package/dist/services/tool-approval/index.d.mts +1 -1
  210. package/dist/services/tool-approval/index.mjs +1 -1
  211. package/dist/services/tools/index.d.mts +1 -1
  212. package/dist/services/tools/index.mjs +1 -1
  213. package/dist/services/tray-menu/index.d.mts +3 -3
  214. package/dist/services/tray-menu/namespace.d.mts +1 -1
  215. package/dist/services/tray-menu/schemas.d.mts +1 -1
  216. package/dist/services/turn/index.d.mts +1 -1
  217. package/dist/services/turn/namespace.d.mts +1 -1
  218. package/dist/services/workflow-transitions/index.d.mts +1 -1
  219. package/dist/services/workflow-transitions/index.mjs +1 -1
  220. package/dist/session-BNiMZnfF.mjs +1 -0
  221. package/dist/session-CMbztxNO.mjs +95 -0
  222. package/dist/src-BZdw54VU.mjs +1 -0
  223. package/dist/{src-CbAw9kjJ.mjs → src-C0sw_Vs_.mjs} +1 -1
  224. package/dist/{src-Xn6SS74f.mjs → src-CqQSqLQI.mjs} +1 -1
  225. package/dist/storage/drizzle/client.d.mts +1 -1
  226. package/dist/storage/drizzle/client.mjs +1 -1
  227. package/dist/storage/drizzle/index.d.mts +1 -1
  228. package/dist/storage/drizzle/index.mjs +1 -1
  229. package/dist/storage/handlers/drizzle/index.d.mts +1 -1
  230. package/dist/storage/handlers/index.d.mts +1 -1
  231. package/dist/{tool-approval-service-pbkGcAV8.mjs → tool-approval-service-CRo3fZRF.mjs} +1 -1
  232. package/dist/{tools-C5Gy0IQG.mjs → tools-CKaxi3Mb.mjs} +1 -1
  233. package/dist/{transition-D-Lgbp1j.d.mts → transition-DMv8cgEd.d.mts} +2 -2
  234. package/dist/{types-CjYcHDPo2.d.mts → types-7L3BrU9m2.d.mts} +1 -1
  235. package/dist/{types-DhbllltK.d.mts → types-DNYO_Rxj.d.mts} +12 -3
  236. package/dist/ui-hooks/index.d.mts +17 -24
  237. package/dist/ui-hooks/index.mjs +1 -1
  238. package/dist/ui-kernel/index.d.mts +11 -2
  239. package/dist/ui-kernel/index.mjs +1 -1
  240. package/dist/ui-kernel/pages/schemas.d.mts +1 -1
  241. package/dist/ui-views/index.mjs +1 -1
  242. package/dist/utils/index.d.mts +31 -1
  243. package/dist/utils/index.mjs +2 -2
  244. package/dist/{view-builder-CHUTXJDl.d.mts → view-builder-DJGz9I-u.d.mts} +2 -2
  245. package/dist/workflow-engine/execution-attempt-repository.d.mts +1 -1
  246. package/dist/workflow-engine/execution-attempt-repository.mjs +1 -1
  247. package/dist/workflow-engine/index.d.mts +2 -2
  248. package/dist/workflow-engine/index.mjs +1 -1
  249. package/dist/workflow-engine/package.d.mts +1 -1
  250. package/dist/workflow-engine/package.mjs +1 -1
  251. package/dist/workflow-engine/provider-operation.d.mts +1 -1
  252. package/dist/workflow-engine/testing/conformance.d.mts +1 -1
  253. package/dist/workflow-engine/testing/conformance.mjs +1 -1
  254. package/dist/workflow-engine/testing/index.d.mts +1 -1
  255. package/dist/workflow-engine/testing/index.mjs +1 -1
  256. package/dist/workflow-engine/testing/sqlite.d.mts +1 -1
  257. package/dist/workflow-engine/testing/sqlite.mjs +1 -1
  258. package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
  259. package/dist/{workflow-transitions-C0sg3kar.mjs → workflow-transitions-t0ORS1F5.mjs} +1 -1
  260. package/dist/workflow-worker-DXCXb3g-.mjs +3 -0
  261. package/package.json +9 -1
  262. package/dist/bus-BQ64i3DN.mjs +0 -9
  263. package/dist/client-Bg3_IdaF.mjs +0 -1
  264. package/dist/extension-CfrTp3rC.mjs +0 -1
  265. package/dist/extension-CnNcY1hR.mjs +0 -1
  266. package/dist/extension-namespace-Ct9L6SKr.mjs +0 -1
  267. package/dist/index-D_j_T3nS.d.mts +0 -435
  268. package/dist/load-extensions-BVgxTj_y.mjs +0 -1
  269. package/dist/ownership-memory-handler-xex7sLiX.mjs +0 -1
  270. package/dist/schemas-ClkcU_N5.mjs +0 -1
  271. package/dist/session-6UG5udTX.mjs +0 -95
  272. package/dist/session-BB0s7c2B.mjs +0 -1
  273. package/dist/workflow-worker-ChrMIcKm.mjs +0 -2
  274. /package/dist/{adapter-binding-BxjUfkOn.d.mts → adapter-binding-CaYBrIkL.d.mts} +0 -0
  275. /package/dist/{attempt-control-evidence-7lwRG73Y.mjs → attempt-control-evidence-CHBnJoqN.mjs} +0 -0
  276. /package/dist/{attempt-fixtures-DHdYmr3o.mjs → attempt-fixtures-D3IsP0KH.mjs} +0 -0
  277. /package/dist/{authority-state-bootstrap-CvuWPywM.mjs → authority-state-bootstrap-4F5Wc_6l.mjs} +0 -0
  278. /package/dist/{base-orchestrator-CrXiMJzf.d.mts → base-orchestrator-1ofFsqUz.d.mts} +0 -0
  279. /package/dist/{bootstrap-start-client-C1ZHbv6e.mjs → bootstrap-start-client-9nOdeDYl.mjs} +0 -0
  280. /package/dist/{capability-service-CQ1aw_p-.d.mts → capability-service-CUN0MIS7.d.mts} +0 -0
  281. /package/dist/{client-ByjHcS78.d.mts → client-BY3sBW2L.d.mts} +0 -0
  282. /package/dist/{client-binary-version-verifier-C4fEAUdo.d.mts → client-binary-version-verifier-BeO4Eptw.d.mts} +0 -0
  283. /package/dist/{clients-namespace-D4BxF2Nw.d.mts → clients-namespace-D92YsbKI.d.mts} +0 -0
  284. /package/dist/{config-namespace-B1zyOYwH.d.mts → config-namespace-OEckUfVE.d.mts} +0 -0
  285. /package/dist/{create-static-mount-Dgxgi4W3.mjs → create-static-mount-4B-mNtx1.mjs} +0 -0
  286. /package/dist/{cross-spawn-BMCAyqrN.mjs → cross-spawn-DGqEuNyT.mjs} +0 -0
  287. /package/dist/{definition-ClWxAKQ2.d.mts → definition-DLJg-P4G.d.mts} +0 -0
  288. /package/dist/{esm-Ccx-3z8E.mjs → esm-DwiWcwH0.mjs} +0 -0
  289. /package/dist/{execution-attempt-repository-aabFKcXN.mjs → execution-attempt-repository-CY289HlC.mjs} +0 -0
  290. /package/dist/{execution-attempt-repository-BUah8hma.d.mts → execution-attempt-repository-DOb5V4N2.d.mts} +0 -0
  291. /package/dist/{extension-package-provenance-C7oO5JAE.mjs → extension-package-provenance-ClpN3GHp.mjs} +0 -0
  292. /package/dist/{filesystem-service-CDYoiwWY.d.mts → filesystem-service-BmavE-uO.d.mts} +0 -0
  293. /package/dist/{index-BbkcbY6d.d.mts → index--gbsE1W0.d.mts} +0 -0
  294. /package/dist/{index-DdVpWkaI.d.mts → index-B36rL4gp.d.mts} +0 -0
  295. /package/dist/{index-DM72_93s.d.mts → index-BD1SbHpP.d.mts} +0 -0
  296. /package/dist/{index-KdlZRuTp.d.mts → index-BDcK7jqJ2.d.mts} +0 -0
  297. /package/dist/{index-DAaQ--ki.d.mts → index-BQYGOXY5.d.mts} +0 -0
  298. /package/dist/{index-gAyARaKS.d.mts → index-BneZFJ7x.d.mts} +0 -0
  299. /package/dist/{index-D8ELwT5y.d.mts → index-BujgCaKt.d.mts} +0 -0
  300. /package/dist/{index-DfU8s_xP.d.mts → index-C2StVLk4.d.mts} +0 -0
  301. /package/dist/{index-BGnQ0EyD.d.mts → index-CCTzitBA.d.mts} +0 -0
  302. /package/dist/{index-CVRT01082.d.mts → index-Cj_V1aRL.d.mts} +0 -0
  303. /package/dist/{index-nkix3hP7.d.mts → index-CpN2C9jq.d.mts} +0 -0
  304. /package/dist/{index-D6p17KPs.d.mts → index-CsRPJ9FV.d.mts} +0 -0
  305. /package/dist/{index-BPNfYEA22.d.mts → index-CvdvuhTL2.d.mts} +0 -0
  306. /package/dist/{index-DmX9W3xH2.d.mts → index-D3peNmHN2.d.mts} +0 -0
  307. /package/dist/{index-DiZ4LmyE.d.mts → index-D7smT-YD.d.mts} +0 -0
  308. /package/dist/{index-B78CRVi9.d.mts → index-DEx4ZFkz.d.mts} +0 -0
  309. /package/dist/{index-CjDQn6lw.d.mts → index-DGoJayJg.d.mts} +0 -0
  310. /package/dist/{index-F7cVpFJ9.d.mts → index-DTvYp2GT.d.mts} +0 -0
  311. /package/dist/{index-Htfr-K5U2.d.mts → index-DqliLe_D2.d.mts} +0 -0
  312. /package/dist/{index-BCU5oByg.d.mts → index-DubyRZD9.d.mts} +0 -0
  313. /package/dist/{index-DjSUOMlr.d.mts → index-DwOpaQAE.d.mts} +0 -0
  314. /package/dist/{index-BZoOYV-y.d.mts → index-DxkSkszz.d.mts} +0 -0
  315. /package/dist/{index-tbjIqwa3.d.mts → index-TBJ1kIGA.d.mts} +0 -0
  316. /package/dist/{index-DXQTkwLB.d.mts → index-YOXWpZAS.d.mts} +0 -0
  317. /package/dist/{index-CXpgL3gz2.d.mts → index-aIJ7A4DC2.d.mts} +0 -0
  318. /package/dist/{index-D6liU_KS.d.mts → index-fxh7TB0q.d.mts} +0 -0
  319. /package/dist/{index-xsaaa85T.d.mts → index-qczb9Yx3.d.mts} +0 -0
  320. /package/dist/{index-C_kOkO3E.d.mts → index-zqo2mX_Z.d.mts} +0 -0
  321. /package/dist/{json-value-Ymw2f8i_.d.mts → json-value-Bjl8jzom.d.mts} +0 -0
  322. /package/dist/{jsonl-transport-Bg033Ng0.mjs → jsonl-transport-Ct1RWs0h.mjs} +0 -0
  323. /package/dist/{lib-BizqbepU.mjs → lib-DomKag_k.mjs} +0 -0
  324. /package/dist/{namespace-rJ3ycPMg.d.mts → namespace-Bhx72V7S.d.mts} +0 -0
  325. /package/dist/{namespace-BCVKdu-U.d.mts → namespace-CxEQv9iZ.d.mts} +0 -0
  326. /package/dist/{namespace-COHHDh2I.d.mts → namespace-D09uQ231.d.mts} +0 -0
  327. /package/dist/{namespace-UFcDEBJB.d.mts → namespace-D5DkpaaN.d.mts} +0 -0
  328. /package/dist/{namespace-CvK86QFk.d.mts → namespace-DHLwz4o3.d.mts} +0 -0
  329. /package/dist/{namespace-B5IFLQc-.d.mts → namespace-DHbrNQYD.d.mts} +0 -0
  330. /package/dist/{namespace-s0e215xO.d.mts → namespace-DyD06b5-.d.mts} +0 -0
  331. /package/dist/{namespace-C1pPZKtI.d.mts → namespace-Dz5_Hrz7.d.mts} +0 -0
  332. /package/dist/{namespace-Phxf0Lep.d.mts → namespace-Lkv2nyzb.d.mts} +0 -0
  333. /package/dist/{namespace-DM5vykb7.d.mts → namespace-hlhPqSsw.d.mts} +0 -0
  334. /package/dist/{namespace-DlOQmhgX.d.mts → namespace-x-gk5SmK.d.mts} +0 -0
  335. /package/dist/{namespace-f6Kz5cwX.d.mts → namespace-zusFEJPh.d.mts} +0 -0
  336. /package/dist/{orchestrator-shared--srEeSaY.d.mts → orchestrator-shared-ChU5qRSe.d.mts} +0 -0
  337. /package/dist/{packages-B98-WETs.d.mts → packages-D2s51nGU.d.mts} +0 -0
  338. /package/dist/{providers-namespace-DRcl03bo.d.mts → providers-namespace-BLVt8OyP.d.mts} +0 -0
  339. /package/dist/{runtime-inputs-DBtVIy9h.d.mts → runtime-inputs-BU_kBrP7.d.mts} +0 -0
  340. /package/dist/{schemas-CEJe8O6P.d.mts → schemas-3KTmPuZg.d.mts} +0 -0
  341. /package/dist/{schemas-D_-iXLQ9.d.mts → schemas-B-5_Dp4_.d.mts} +0 -0
  342. /package/dist/{schemas-CeItAAQM.d.mts → schemas-BLxdGZkr.d.mts} +0 -0
  343. /package/dist/{schemas-Cj6Gbqch.d.mts → schemas-BegArpU_.d.mts} +0 -0
  344. /package/dist/{schemas-Ca5RILd-2.d.mts → schemas-BzB6z9oX2.d.mts} +0 -0
  345. /package/dist/{schemas-CtzZDp29.d.mts → schemas-CBBzvIh0.d.mts} +0 -0
  346. /package/dist/{schemas-Cq1d5tid.d.mts → schemas-CD3Mq-jC.d.mts} +0 -0
  347. /package/dist/{schemas-LiiyNNpr.d.mts → schemas-Cl7fPlRv.d.mts} +0 -0
  348. /package/dist/{schemas-DJ2vMsgm.d.mts → schemas-CqawCYTY.d.mts} +0 -0
  349. /package/dist/{schemas-2_D4iVbb.d.mts → schemas-DEg6R9ph.d.mts} +0 -0
  350. /package/dist/{schemas-JjyFxrC0.d.mts → schemas-rMUsvzeJ.d.mts} +0 -0
  351. /package/dist/{server-lifecycle-DUKp1Fbf.d.mts → server-lifecycle-CTJvpdeL.d.mts} +0 -0
  352. /package/dist/{session-lineage-C3myyt5x.d.mts → session-lineage-BuGN3RZs.d.mts} +0 -0
  353. /package/dist/{storage-namespace-IvLOIP7j.d.mts → storage-namespace-B5r_ScUz.d.mts} +0 -0
  354. /package/dist/{storage-namespace-definition-Cv0XiTXb.d.mts → storage-namespace-definition-DiYr8UNl.d.mts} +0 -0
  355. /package/dist/{types-hkExapGH.d.mts → types-BSx8YYlc.d.mts} +0 -0
  356. /package/dist/{types-BYEybzjX.d.mts → types-CpEoQapk.d.mts} +0 -0
  357. /package/dist/{types-QRSc2AUU.d.mts → types-Cuhnt15L.d.mts} +0 -0
  358. /package/dist/{types-QsyX4H21.d.mts → types-DEGuc-fn.d.mts} +0 -0
  359. /package/dist/{types-BRM1AZaP.d.mts → types-DciLiPMd.d.mts} +0 -0
  360. /package/dist/{types-CsmvIK25.mjs → types-wwuw7RkB.mjs} +0 -0
  361. /package/dist/{window-registry-DeG37kt8.d.mts → window-registry-C3W2wtlX.d.mts} +0 -0
@@ -1,4 +1,4 @@
1
- import { Ht as AttemptControlEvidence, I as RecordAllocationInput, Mt as AttemptOutcomeControlObservation$1, P as ProvisioningClaimDecision, Pt as ExecutionAttemptCancellationIntent$1, dt as ProviderOperationOwnershipRecord, it as ProviderOperationClaim, j as OutcomeCodec, r as AllocationRecordingDecision, rt as ProcessBoundProvisionerLossProof, s as AttemptControlState, u as BeginProvisioningInput, w as ExecutionOwnerId, x as ExecutionAttemptRepository, y as ExecutionAttemptRecord, yt as ExecutionAttemptOutcomeDecision } from "../../execution-attempt-repository-BUah8hma.mjs";
1
+ import { Ht as AttemptControlEvidence, I as RecordAllocationInput, Mt as AttemptOutcomeControlObservation$1, P as ProvisioningClaimDecision, Pt as ExecutionAttemptCancellationIntent$1, dt as ProviderOperationOwnershipRecord, it as ProviderOperationClaim, j as OutcomeCodec, r as AllocationRecordingDecision, rt as ProcessBoundProvisionerLossProof, s as AttemptControlState, u as BeginProvisioningInput, w as ExecutionOwnerId, x as ExecutionAttemptRepository, y as ExecutionAttemptRecord, yt as ExecutionAttemptOutcomeDecision } from "../../execution-attempt-repository-DOb5V4N2.mjs";
2
2
  import { BoundedRecoveryEvidence, ExecutionAttemptInstruction, ExecutionAttemptPreparationResult, ProviderAllocationRef, WorkerAllocationLifetime, WorkflowRunResult } from "@makaio/framework/contracts";
3
3
 
4
4
  //#region subsystems/workflow-engine/src/testing/attempt-record-codec.d.ts
@@ -1 +1 @@
1
- import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,l as c,m as l,n as u,o as ee,s as d,u as f,v as p,x as m,y as h}from"../../execution-attempt-repository-aabFKcXN.mjs";import{a as g,i as _,n as v,o as y,t as te}from"../../execution-attempt-owner-recovery-CE_rvHKE.mjs";import{i as b,n as x,r as ne,t as S}from"../../attempt-control-evidence-7lwRG73Y.mjs";import{isProviderOperationResolved as C}from"../provider-operation.mjs";import{a as w,c as T,d as E,f as D,i as O,l as k,n as A,o as j,p as re,r as ie,s as M,t as N,u as P}from"../../attempt-record-codec-DaQ3WHUs.mjs";import{a as F,c as I,d as L,f as R,i as z,l as B,m as V,n as H,o as U,p as W,r as G,s as K,t as q,u as J}from"../../attempt-fixtures-DHdYmr3o.mjs";import{randomUUID as ae}from"node:crypto";import{BoundedRecoveryEvidenceSchema as Y}from"@makaio/framework/contracts";function X(e){if(e.kind===`accepted`||e.kind===`duplicate`)return e;throw Error(`Expected a committed test outcome, received ${e.kind}`)}function Z(e,t){return{...e,status:`settled`,settlementKind:t,claimable:!1,operationStartGate:`closed`}}function Q(F,I={}){let L=I.attempts??new Map,R=I.operations??new Map,z=e=>R.get(e)?.obligation===`terminal-convergence`,B=I.committedOutcomes??new Map,V=I.outcomeControlObservations??new Map,H=I.activeAttempts??new Map,U=I.requestBindings??new Map,W=I.cancellations??new Map,G=I.controlEvidence??new Map,K=e=>{let t=e.settlementKind!=null,n=!t&&H.get(e.executionId)===e.executionAttemptId;return s({matchesExecution:!0,settled:t,active:n,allocated:n&&e.allocationRef!==null&&!z(e.executionAttemptId)})},q=e=>{let t=L.get(e.executionAttemptId),n=R.get(e.executionAttemptId);return!t||!n?{kind:`not-found`}:C(t,n)?{kind:`resolved`,attempt:t}:n.token===null||n.token!==e.token||n.generation!==e.generation||n.ownerId!==e.ownerId?{kind:`stale`,attempt:t}:{kind:`authorized`,attempt:t,operation:n}},J=(e,t)=>{e.completionEvidence===null&&R.set(e.executionAttemptId,{...e,completionEvidence:t})},X=(e,t)=>{let n=M(e.allocationRef),r=q(e.claim);if(r.kind!==`not-found`&&E(r.attempt,n),r.kind===`resolved`)return{kind:`resolved`,allocationRef:r.attempt.allocationRef};if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i,operation:a}=r;if(i.allocationRef!==null)return d(i.allocationRef,n)?{kind:`duplicate`,allocationRef:i.allocationRef}:{kind:`conflict`,allocationRef:i.allocationRef};let o=H.get(i.executionId)===i.executionAttemptId;return L.set(i.executionAttemptId,{...i,status:i.settlementKind===null?`allocated`:i.status,allocationRef:n,claimable:i.settlementKind===null&&t&&o}),R.set(a.executionAttemptId,{...a,obligation:`allocation-control`}),{kind:`recorded`}},Q={async getAttemptWithAllocation(e){return L.get(e)??null},async recordDiscoveredAllocation(e){return X(e,!1)},async evolveAllocationRef(e){let{currentRef:t,nextRef:n}=T(e),r=q(e.claim);if(r.kind===`stale`)return{kind:`stale`,storedRef:r.attempt.allocationRef};if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i}=r;return i.executionId===e.executionId?i.allocationRef===null?{kind:`not-allocated`}:d(i.allocationRef,t)?(L.set(i.executionAttemptId,{...i,allocationRef:n}),{kind:`evolved`}):{kind:`stale`,storedRef:i.allocationRef}:{kind:`not-found`}},async getRecoverableAttempts(e){let t=O(new Date().toISOString()),n=[];for(let r of L.values())r.executionId===e&&r.status===`allocated`&&r.allocationRef!==null&&r.claimable===!0&&r.settlementKind==null&&(r.claimExpiresAt!=null&&O(r.claimExpiresAt)<t||n.push(re(r)));return n.sort(A)},async listOpenProviderOperations(e){if(!Number.isSafeInteger(e.limit)||e.limit<=0)throw RangeError(`limit must be a positive safe integer`);let t=O(e.observedAt),n=[];for(let e of R.values()){let r=L.get(e.executionAttemptId);!r||C(r,e)||e.ownerId!==null&&e.leaseExpiresAt!==null&&O(e.leaseExpiresAt)>t||n.push({attempt:r,operation:e})}return n.sort((e,t)=>A(e.attempt,t.attempt)).slice(0,e.limit)}},$=e=>{let t=ie(e.bootstrapTimeoutMs);if(L.has(e.executionAttemptId))throw new u(e.executionAttemptId);let n={executionAttemptId:e.executionAttemptId,executionId:e.executionId,instruction:e.instruction,preparationReceipts:Object.freeze([]),status:`pending`,allocationRef:null,...t,providerId:null,allocationLifetime:null,provisionerIncarnationId:null,settlementKind:null,claimable:!1,claimExpiresAt:null,...N},r=H.get(e.executionId),i=r===void 0?void 0:L.get(r);return i!==void 0&&L.set(i.executionAttemptId,{...i,claimable:i.status===`allocated`?!1:i.claimable,operationStartGate:`closed`}),L.set(e.executionAttemptId,n),H.set(e.executionId,e.executionAttemptId),n};return{async createAttempt(e){return $({...e,instruction:y(e.instruction)})},async ensureAttempt(e){let t=_(e),n=U.get(t.executionId),r=n?.get(t.requestKey);if(r!==void 0)return v(t,L.get(r)??null);let i=$(t),a=n??new Map;return a.set(t.requestKey,i.executionAttemptId),U.set(t.executionId,a),{kind:`created`,attempt:structuredClone(i)}},async readAttemptSettlement(e){let t=g(e);return te(t,{attempt:L.get(t.executionAttemptId)??null,activeAttemptId:H.get(t.executionId)??null,outcomeText:B.get(t.executionAttemptId)??null,controlObservation:V.get(t.executionAttemptId)??null},F)},async readBootstrapStartState(e){let t=L.get(e.executionAttemptId);return!t||t.executionId!==e.executionId?null:{settled:t.settlementKind!=null,active:H.get(e.executionId)===e.executionAttemptId,allocated:t.allocationRef!==null,allocationTerminated:z(e.executionAttemptId),operationStartGate:t.operationStartGate,bootstrapDeadlineAt:t.bootstrapDeadlineAt??null}},async beginProvisioning(e){let t=j(e.allocationLifetime),n=L.get(e.executionAttemptId);if(!n||n.executionId!==e.executionId)return{kind:`not-found`};if(H.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};if(n.settlementKind!=null)return{kind:`resolved`,allocationRef:n.allocationRef};if(n.allocationRef!==null)return{kind:`allocated`,allocationRef:n.allocationRef};if(n.operationStartGate===`closed`)return{kind:`fenced`};if(n.status!==`pending`)return{kind:`already-provisioning`};L.set(e.executionAttemptId,{...n,status:`provisioning`,providerId:e.providerId,allocationLifetime:t,provisionerIncarnationId:e.provisionerIncarnationId});let r={executionAttemptId:e.executionAttemptId,generation:1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:w(e.leaseExpiresAt)};return R.set(e.executionAttemptId,{executionAttemptId:e.executionAttemptId,generation:r.generation,ownerId:r.ownerId,token:r.token,leaseExpiresAt:r.leaseExpiresAt,obligation:`provisioning-resolution`,failureCount:0,lastFailure:null,completionEvidence:null}),{kind:`started`,claim:r}},async getProviderOperation(e){return R.get(e)??null},async renewProviderOperationClaim(e){let t=q(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let n=w(e.leaseExpiresAt);return R.set(e.claim.executionAttemptId,{...t.operation,leaseExpiresAt:n}),{kind:`claimed`,claim:{...e.claim,leaseExpiresAt:n}}},async takeOverProviderOperation(e){let t=L.get(e.executionAttemptId),n=R.get(e.executionAttemptId);if(!t||!n)return{kind:`not-found`};if(C(t,n))return{kind:`resolved`};if(n.ownerId!==null&&n.leaseExpiresAt!==null&&O(n.leaseExpiresAt)>O(e.observedAt))return{kind:`stale`};let r={executionAttemptId:e.executionAttemptId,generation:n.generation+1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:w(e.leaseExpiresAt)};return R.set(e.executionAttemptId,{...n,generation:r.generation,ownerId:r.ownerId,token:r.token,leaseExpiresAt:r.leaseExpiresAt}),{kind:`claimed`,claim:r}},async handoffProviderOperation(e){let t=e.evidence===void 0?void 0:Y.parse(e.evidence),n=q(e.claim);return n.kind===`authorized`?(R.set(e.claim.executionAttemptId,{...n.operation,ownerId:null,token:null,leaseExpiresAt:null,lastFailure:t??n.operation.lastFailure}),{kind:`recorded`}):{kind:n.kind}},async recordProviderOperationUncertainty(e){let t=Y.parse(e.evidence),n=q(e.claim);return n.kind===`authorized`?(R.set(e.claim.executionAttemptId,{...n.operation,failureCount:n.operation.failureCount+1,lastFailure:t}),{kind:`recorded`}):{kind:n.kind}},async completeProviderOperation(e){let t=Y.parse(e.evidence),n=L.get(e.claim.executionAttemptId),r=R.get(e.claim.executionAttemptId);return!n||!r?{kind:`not-found`}:r.token!==e.claim.token||r.generation!==e.claim.generation||r.ownerId!==e.claim.ownerId?{kind:`stale`}:C(n,r)?{kind:`already-completed`}:r.completionEvidence===null?(J(r,t),n.settlementKind===null?{kind:`evidence-recorded`}:{kind:`completed`}):{kind:`evidence-recorded`}},async recordAllocation(e){return X(e,!0)},async recordProvisioningAbsent(e){let t=Y.parse(e.evidence),n=q(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.allocationRef===null?r.settlementKind===null?(L.set(r.executionAttemptId,Z(r,`abandoned`)),J(i,t),{kind:`recorded`}):(J(i,t),{kind:`completed`}):{kind:`allocated`,allocationRef:r.allocationRef}:{kind:`not-found`}},async recordProvisionerIncarnationLost(e){let t=Y.parse(e.proof.evidence),n=q(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n,a=h(r,e);return a===null?r.settlementKind===null?(L.set(r.executionAttemptId,Z(r,`abandoned`)),J(i,t),{kind:`recorded`}):(J(i,t),{kind:`completed`}):a},async recordAllocationTerminated(e){let t=Y.parse(e.evidence),n=q(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.allocationRef===null?{kind:`not-allocated`}:(R.set(i.executionAttemptId,{...i,obligation:`terminal-convergence`,lastFailure:t}),{kind:`recorded`})},async recordInfrastructureFailure(e){let t=q(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let{attempt:n,operation:r}=t;return n.executionId===e.executionId?n.settlementKind===null?n.allocationRef===null?{kind:`not-allocated`}:r.obligation===`terminal-convergence`?(L.set(n.executionAttemptId,Z(n,`infrastructure-failure`)),{kind:`recorded`}):{kind:`not-terminated`}:{kind:`resolved`}:{kind:`not-found`}},async registerRuntime(e){let t=L.get(e.executionAttemptId);if(t===void 0||t.executionId!==e.executionId)return{kind:`not-found`};let n=K(t)??m(t,e);if(n!==null)return n;let r=t.runtimeGeneration+1;return L.set(t.executionAttemptId,{...t,runtimeGeneration:r,runtimeIncarnationId:e.runtimeIncarnationId,runtimeReadyAt:null,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null}),{kind:`registered`,runtimeGeneration:r}},async admitOperation(e){let t=L.get(e.executionAttemptId);if(t===void 0||t.executionId!==e.executionId)return{kind:`not-found`};let n=K(t);if(n!==null)return n;let r=o(t,e,t.activeOperationId!==null&&t.activeOperationKey===e.admissionKey&&t.activeOperationAdmittedAt===null?w(new Date().toISOString()):``,t);if(r!==null)return r;let i=crypto.randomUUID(),a=w(new Date().toISOString());return L.set(t.executionAttemptId,{...t,activeOperationId:i,activeOperationKind:e.operationKind,activeOperationKey:e.admissionKey,activeOperationGeneration:t.runtimeGeneration,activeOperationAdmittedAt:a}),{kind:`admitted`,operationId:i,runtimeGeneration:t.runtimeGeneration,admittedAt:a}},async getInstruction(e){let t=L.get(e.executionAttemptId);return t?.executionId===e.executionId?t.instruction:null},async reportOperation(e){let t=P(e.result),n=L.get(e.executionAttemptId);if(n===void 0||n.executionId!==e.executionId)return{kind:`not-found`};let r=p({matchesExecution:!0,settled:n.settlementKind!=null,active:H.get(e.executionId)===e.executionAttemptId,allocated:n.allocationRef!==null&&!z(e.executionAttemptId)},n,n,{...e,result:t});if(r!==null)return r;let i=k([...n.preparationReceipts,{operationId:e.operationId,runtimeGeneration:e.runtimeGeneration,result:t}]);return L.set(e.executionAttemptId,{...n,preparationReceipts:i,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null,lastCompletedOperationId:e.operationId}),{kind:`accepted`,binding:t.binding}},async completeOperation(t){let n=L.get(t.executionAttemptId);if(n===void 0)return{kind:`not-found`};if(n.settlementKind!=null)return{kind:`resolved`};let r=e(n,t);return r===null?(L.set(n.executionAttemptId,{...n,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null,lastCompletedOperationId:t.operationId}),{kind:`completed`}):r},async markRuntimeReady(e){let t=w(e.readyAt),r=L.get(e.executionAttemptId);if(r===void 0||r.executionId!==e.executionId)return{kind:`not-found`};let i=K(r)??n(r,e);return i===null?(L.set(r.executionAttemptId,{...r,runtimeReadyAt:t}),{kind:`ready`,acceptedAt:t}):i},async getAttemptControlState(e){let t=L.get(e);return t===void 0?null:D(t)},async requestAttemptCancellation(e){let t=i(e),n=L.get(t.executionAttemptId);if(n===void 0||n.executionId!==t.executionId)return{kind:`not-found`};let r=c(W.get(t.executionAttemptId)??null,t,new Date().toISOString());return r.kind===`conflict`?r:(W.set(t.executionAttemptId,{...r.intent}),L.set(t.executionAttemptId,{...n,operationStartGate:`closed`}),r)},async requestCancellation(e){let t=a(e),n={...t,requestKey:ae()},r=new Date().toISOString(),i=[...L].filter(([,e])=>e.executionId===t.executionId).map(([e,t])=>{let i=c(W.get(e)??null,n,r);if(i.kind===`conflict`)throw Error(`Conflicting generated cancellation request key`);return{id:e,attempt:t,intent:i.intent}});for(let{id:e,attempt:t,intent:n}of i)W.set(e,{...n}),L.set(e,{...t,operationStartGate:`closed`})},async readCancellation(e){let t=W.get(e);return t===void 0?null:{...t}},async readAttemptCancellationControl(e){let{executionId:t,executionAttemptId:n}=e,r=L.get(n);return r===void 0||r.executionId!==t?null:structuredClone({control:D(r),cancellation:W.get(n)??null,evidence:[...G.get(n)?.values()??[]].sort((e,t)=>e.controlRevision-t.controlRevision||e.runtimeGeneration-t.runtimeGeneration)})},async recordAttemptControlReceipt(e){let t=ne(e),{executionId:n,...r}=t,{executionAttemptId:i,controlRevision:a,runtimeGeneration:o}=t,s=`${a}:${o}`,c=G.get(i)??new Map,l=c.get(s),u=S(L.get(i)??null,W.get(i)??null,l?.receipt??null,t);return u.kind===`accepted`&&(c.set(s,{controlRevision:a,runtimeGeneration:o,receipt:r,report:l?.report??null}),G.set(i,c)),u},async reportAttemptControl(e){let t=b(e),{executionId:n,...r}=t,{executionAttemptId:i,controlRevision:a,runtimeGeneration:o}=t,s=`${a}:${o}`,c=G.get(i)??new Map,l=c.get(s),u=x(L.get(i)??null,W.get(i)??null,l?.report??null,t);return u.kind===`accepted`&&(c.set(s,{controlRevision:a,runtimeGeneration:o,receipt:l?.receipt??null,report:r}),G.set(i,c)),u},async getActiveAttempt(e,t){return H.get(e)===t?L.get(t)??null:null},canonicalizeOutcome(e){return ee(F,e)},decodeOutcome(e){return t(F,e)},async commitOutcome(e){let n=e.result;if(H.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};let i=L.get(e.executionAttemptId);if(i===void 0)return{kind:`fenced`};let a=B.get(e.executionAttemptId);if(a!==void 0){let i=t(F,a);return r(a,n.text)?{kind:`duplicate`,outcome:i,text:a,controlObservation:structuredClone(V.get(e.executionAttemptId)??null)}:{kind:`conflict`}}if(i.settlementKind!=null)return{kind:`conflict`};l(i,e.runtimeFence);let o=f(W.get(e.executionAttemptId)??null);return B.set(e.executionAttemptId,n.text),V.set(e.executionAttemptId,o),L.set(e.executionAttemptId,Z(i,`outcome`)),{kind:`accepted`,outcome:t(F,n.text),text:n.text,controlObservation:structuredClone(o)}},async abandonPendingAttempt(e,t){if(H.get(t)!==e)return{kind:`fenced`};let n=L.get(e);return n?n.status===`allocated`?{kind:`allocated`}:n.status===`provisioning`?{kind:`provisioning`}:n.status===`settled`?{kind:n.settlementKind===`abandoned`?`already-abandoned`:`already-settled`}:(L.set(e,Z(n,`abandoned`)),{kind:`abandoned`}):{kind:`fenced`}},recovery:Q,attempts:L,operations:R,committedOutcomes:B,outcomeControlObservations:V,activeAttempts:H,requestBindings:U,cancellations:W,controlEvidence:G}}export{N as INITIAL_ATTEMPT_CONTROL_STATE,q as TEST_OWNER_ID,H as TEST_PROVIDER_ID,G as TEST_PROVISIONER_INCARNATION_ID,z as allocateTestAttempt,F as beginTestProvisioning,Q as createInMemoryAttemptRepository,U as driveTestAttemptToAllocated,K as leaseAt,I as makeBeginProvisioningInput,B as makeEvidence,J as makeProcessLossProof,L as makeTestAllocationRef,R as makeTestInstruction,W as makeTestWorkflowResult,X as requireCommittedOutcome,V as workflowRunResultOutcomeCodec};
1
+ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,l as c,m as l,n as u,o as ee,s as d,u as f,v as p,x as m,y as h}from"../../execution-attempt-repository-CY289HlC.mjs";import{a as g,i as _,n as v,o as y,t as te}from"../../execution-attempt-owner-recovery-BZOEVYFH.mjs";import{i as b,n as x,r as ne,t as S}from"../../attempt-control-evidence-CHBnJoqN.mjs";import{isProviderOperationResolved as C}from"../provider-operation.mjs";import{a as w,c as T,d as E,f as D,i as O,l as k,n as A,o as j,p as re,r as ie,s as M,t as N,u as P}from"../../attempt-record-codec-DXpdMgyI.mjs";import{a as F,c as I,d as L,f as R,i as z,l as B,m as V,n as H,o as U,p as W,r as G,s as K,t as q,u as J}from"../../attempt-fixtures-D3IsP0KH.mjs";import{randomUUID as ae}from"node:crypto";import{BoundedRecoveryEvidenceSchema as Y}from"@makaio/framework/contracts";function X(e){if(e.kind===`accepted`||e.kind===`duplicate`)return e;throw Error(`Expected a committed test outcome, received ${e.kind}`)}function Z(e,t){return{...e,status:`settled`,settlementKind:t,claimable:!1,operationStartGate:`closed`}}function Q(F,I={}){let L=I.attempts??new Map,R=I.operations??new Map,z=e=>R.get(e)?.obligation===`terminal-convergence`,B=I.committedOutcomes??new Map,V=I.outcomeControlObservations??new Map,H=I.activeAttempts??new Map,U=I.requestBindings??new Map,W=I.cancellations??new Map,G=I.controlEvidence??new Map,K=e=>{let t=e.settlementKind!=null,n=!t&&H.get(e.executionId)===e.executionAttemptId;return s({matchesExecution:!0,settled:t,active:n,allocated:n&&e.allocationRef!==null&&!z(e.executionAttemptId)})},q=e=>{let t=L.get(e.executionAttemptId),n=R.get(e.executionAttemptId);return!t||!n?{kind:`not-found`}:C(t,n)?{kind:`resolved`,attempt:t}:n.token===null||n.token!==e.token||n.generation!==e.generation||n.ownerId!==e.ownerId?{kind:`stale`,attempt:t}:{kind:`authorized`,attempt:t,operation:n}},J=(e,t)=>{e.completionEvidence===null&&R.set(e.executionAttemptId,{...e,completionEvidence:t})},X=(e,t)=>{let n=M(e.allocationRef),r=q(e.claim);if(r.kind!==`not-found`&&E(r.attempt,n),r.kind===`resolved`)return{kind:`resolved`,allocationRef:r.attempt.allocationRef};if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i,operation:a}=r;if(i.allocationRef!==null)return d(i.allocationRef,n)?{kind:`duplicate`,allocationRef:i.allocationRef}:{kind:`conflict`,allocationRef:i.allocationRef};let o=H.get(i.executionId)===i.executionAttemptId;return L.set(i.executionAttemptId,{...i,status:i.settlementKind===null?`allocated`:i.status,allocationRef:n,claimable:i.settlementKind===null&&t&&o}),R.set(a.executionAttemptId,{...a,obligation:`allocation-control`}),{kind:`recorded`}},Q={async getAttemptWithAllocation(e){return L.get(e)??null},async recordDiscoveredAllocation(e){return X(e,!1)},async evolveAllocationRef(e){let{currentRef:t,nextRef:n}=T(e),r=q(e.claim);if(r.kind===`stale`)return{kind:`stale`,storedRef:r.attempt.allocationRef};if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i}=r;return i.executionId===e.executionId?i.allocationRef===null?{kind:`not-allocated`}:d(i.allocationRef,t)?(L.set(i.executionAttemptId,{...i,allocationRef:n}),{kind:`evolved`}):{kind:`stale`,storedRef:i.allocationRef}:{kind:`not-found`}},async getRecoverableAttempts(e){let t=O(new Date().toISOString()),n=[];for(let r of L.values())r.executionId===e&&r.status===`allocated`&&r.allocationRef!==null&&r.claimable===!0&&r.settlementKind==null&&(r.claimExpiresAt!=null&&O(r.claimExpiresAt)<t||n.push(re(r)));return n.sort(A)},async listOpenProviderOperations(e){if(!Number.isSafeInteger(e.limit)||e.limit<=0)throw RangeError(`limit must be a positive safe integer`);let t=O(e.observedAt),n=[];for(let e of R.values()){let r=L.get(e.executionAttemptId);!r||C(r,e)||e.ownerId!==null&&e.leaseExpiresAt!==null&&O(e.leaseExpiresAt)>t||n.push({attempt:r,operation:e})}return n.sort((e,t)=>A(e.attempt,t.attempt)).slice(0,e.limit)}},$=e=>{let t=ie(e.bootstrapTimeoutMs);if(L.has(e.executionAttemptId))throw new u(e.executionAttemptId);let n={executionAttemptId:e.executionAttemptId,executionId:e.executionId,instruction:e.instruction,preparationReceipts:Object.freeze([]),status:`pending`,allocationRef:null,...t,providerId:null,allocationLifetime:null,provisionerIncarnationId:null,settlementKind:null,claimable:!1,claimExpiresAt:null,...N},r=H.get(e.executionId),i=r===void 0?void 0:L.get(r);return i!==void 0&&L.set(i.executionAttemptId,{...i,claimable:i.status===`allocated`?!1:i.claimable,operationStartGate:`closed`}),L.set(e.executionAttemptId,n),H.set(e.executionId,e.executionAttemptId),n};return{async createAttempt(e){return $({...e,instruction:y(e.instruction)})},async ensureAttempt(e){let t=_(e),n=U.get(t.executionId),r=n?.get(t.requestKey);if(r!==void 0)return v(t,L.get(r)??null);let i=$(t),a=n??new Map;return a.set(t.requestKey,i.executionAttemptId),U.set(t.executionId,a),{kind:`created`,attempt:structuredClone(i)}},async readAttemptSettlement(e){let t=g(e);return te(t,{attempt:L.get(t.executionAttemptId)??null,activeAttemptId:H.get(t.executionId)??null,outcomeText:B.get(t.executionAttemptId)??null,controlObservation:V.get(t.executionAttemptId)??null},F)},async readBootstrapStartState(e){let t=L.get(e.executionAttemptId);return!t||t.executionId!==e.executionId?null:{settled:t.settlementKind!=null,active:H.get(e.executionId)===e.executionAttemptId,allocated:t.allocationRef!==null,allocationTerminated:z(e.executionAttemptId),operationStartGate:t.operationStartGate,bootstrapDeadlineAt:t.bootstrapDeadlineAt??null}},async beginProvisioning(e){let t=j(e.allocationLifetime),n=L.get(e.executionAttemptId);if(!n||n.executionId!==e.executionId)return{kind:`not-found`};if(H.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};if(n.settlementKind!=null)return{kind:`resolved`,allocationRef:n.allocationRef};if(n.allocationRef!==null)return{kind:`allocated`,allocationRef:n.allocationRef};if(n.operationStartGate===`closed`)return{kind:`fenced`};if(n.status!==`pending`)return{kind:`already-provisioning`};L.set(e.executionAttemptId,{...n,status:`provisioning`,providerId:e.providerId,allocationLifetime:t,provisionerIncarnationId:e.provisionerIncarnationId});let r={executionAttemptId:e.executionAttemptId,generation:1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:w(e.leaseExpiresAt)};return R.set(e.executionAttemptId,{executionAttemptId:e.executionAttemptId,generation:r.generation,ownerId:r.ownerId,token:r.token,leaseExpiresAt:r.leaseExpiresAt,obligation:`provisioning-resolution`,failureCount:0,lastFailure:null,completionEvidence:null}),{kind:`started`,claim:r}},async getProviderOperation(e){return R.get(e)??null},async renewProviderOperationClaim(e){let t=q(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let n=w(e.leaseExpiresAt);return R.set(e.claim.executionAttemptId,{...t.operation,leaseExpiresAt:n}),{kind:`claimed`,claim:{...e.claim,leaseExpiresAt:n}}},async takeOverProviderOperation(e){let t=L.get(e.executionAttemptId),n=R.get(e.executionAttemptId);if(!t||!n)return{kind:`not-found`};if(C(t,n))return{kind:`resolved`};if(n.ownerId!==null&&n.leaseExpiresAt!==null&&O(n.leaseExpiresAt)>O(e.observedAt))return{kind:`stale`};let r={executionAttemptId:e.executionAttemptId,generation:n.generation+1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:w(e.leaseExpiresAt)};return R.set(e.executionAttemptId,{...n,generation:r.generation,ownerId:r.ownerId,token:r.token,leaseExpiresAt:r.leaseExpiresAt}),{kind:`claimed`,claim:r}},async handoffProviderOperation(e){let t=e.evidence===void 0?void 0:Y.parse(e.evidence),n=q(e.claim);return n.kind===`authorized`?(R.set(e.claim.executionAttemptId,{...n.operation,ownerId:null,token:null,leaseExpiresAt:null,lastFailure:t??n.operation.lastFailure}),{kind:`recorded`}):{kind:n.kind}},async recordProviderOperationUncertainty(e){let t=Y.parse(e.evidence),n=q(e.claim);return n.kind===`authorized`?(R.set(e.claim.executionAttemptId,{...n.operation,failureCount:n.operation.failureCount+1,lastFailure:t}),{kind:`recorded`}):{kind:n.kind}},async completeProviderOperation(e){let t=Y.parse(e.evidence),n=L.get(e.claim.executionAttemptId),r=R.get(e.claim.executionAttemptId);return!n||!r?{kind:`not-found`}:r.token!==e.claim.token||r.generation!==e.claim.generation||r.ownerId!==e.claim.ownerId?{kind:`stale`}:C(n,r)?{kind:`already-completed`}:r.completionEvidence===null?(J(r,t),n.settlementKind===null?{kind:`evidence-recorded`}:{kind:`completed`}):{kind:`evidence-recorded`}},async recordAllocation(e){return X(e,!0)},async recordProvisioningAbsent(e){let t=Y.parse(e.evidence),n=q(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.allocationRef===null?r.settlementKind===null?(L.set(r.executionAttemptId,Z(r,`abandoned`)),J(i,t),{kind:`recorded`}):(J(i,t),{kind:`completed`}):{kind:`allocated`,allocationRef:r.allocationRef}:{kind:`not-found`}},async recordProvisionerIncarnationLost(e){let t=Y.parse(e.proof.evidence),n=q(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n,a=h(r,e);return a===null?r.settlementKind===null?(L.set(r.executionAttemptId,Z(r,`abandoned`)),J(i,t),{kind:`recorded`}):(J(i,t),{kind:`completed`}):a},async recordAllocationTerminated(e){let t=Y.parse(e.evidence),n=q(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.allocationRef===null?{kind:`not-allocated`}:(R.set(i.executionAttemptId,{...i,obligation:`terminal-convergence`,lastFailure:t}),{kind:`recorded`})},async recordInfrastructureFailure(e){let t=q(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let{attempt:n,operation:r}=t;return n.executionId===e.executionId?n.settlementKind===null?n.allocationRef===null?{kind:`not-allocated`}:r.obligation===`terminal-convergence`?(L.set(n.executionAttemptId,Z(n,`infrastructure-failure`)),{kind:`recorded`}):{kind:`not-terminated`}:{kind:`resolved`}:{kind:`not-found`}},async registerRuntime(e){let t=L.get(e.executionAttemptId);if(t===void 0||t.executionId!==e.executionId)return{kind:`not-found`};let n=K(t)??m(t,e);if(n!==null)return n;let r=t.runtimeGeneration+1;return L.set(t.executionAttemptId,{...t,runtimeGeneration:r,runtimeIncarnationId:e.runtimeIncarnationId,runtimeReadyAt:null,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null}),{kind:`registered`,runtimeGeneration:r}},async admitOperation(e){let t=L.get(e.executionAttemptId);if(t===void 0||t.executionId!==e.executionId)return{kind:`not-found`};let n=K(t);if(n!==null)return n;let r=o(t,e,t.activeOperationId!==null&&t.activeOperationKey===e.admissionKey&&t.activeOperationAdmittedAt===null?w(new Date().toISOString()):``,t);if(r!==null)return r;let i=crypto.randomUUID(),a=w(new Date().toISOString());return L.set(t.executionAttemptId,{...t,activeOperationId:i,activeOperationKind:e.operationKind,activeOperationKey:e.admissionKey,activeOperationGeneration:t.runtimeGeneration,activeOperationAdmittedAt:a}),{kind:`admitted`,operationId:i,runtimeGeneration:t.runtimeGeneration,admittedAt:a}},async getInstruction(e){let t=L.get(e.executionAttemptId);return t?.executionId===e.executionId?t.instruction:null},async reportOperation(e){let t=P(e.result),n=L.get(e.executionAttemptId);if(n===void 0||n.executionId!==e.executionId)return{kind:`not-found`};let r=p({matchesExecution:!0,settled:n.settlementKind!=null,active:H.get(e.executionId)===e.executionAttemptId,allocated:n.allocationRef!==null&&!z(e.executionAttemptId)},n,n,{...e,result:t});if(r!==null)return r;let i=k([...n.preparationReceipts,{operationId:e.operationId,runtimeGeneration:e.runtimeGeneration,result:t}]);return L.set(e.executionAttemptId,{...n,preparationReceipts:i,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null,lastCompletedOperationId:e.operationId}),{kind:`accepted`,binding:t.binding}},async completeOperation(t){let n=L.get(t.executionAttemptId);if(n===void 0)return{kind:`not-found`};if(n.settlementKind!=null)return{kind:`resolved`};let r=e(n,t);return r===null?(L.set(n.executionAttemptId,{...n,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null,lastCompletedOperationId:t.operationId}),{kind:`completed`}):r},async markRuntimeReady(e){let t=w(e.readyAt),r=L.get(e.executionAttemptId);if(r===void 0||r.executionId!==e.executionId)return{kind:`not-found`};let i=K(r)??n(r,e);return i===null?(L.set(r.executionAttemptId,{...r,runtimeReadyAt:t}),{kind:`ready`,acceptedAt:t}):i},async getAttemptControlState(e){let t=L.get(e);return t===void 0?null:D(t)},async requestAttemptCancellation(e){let t=i(e),n=L.get(t.executionAttemptId);if(n===void 0||n.executionId!==t.executionId)return{kind:`not-found`};let r=c(W.get(t.executionAttemptId)??null,t,new Date().toISOString());return r.kind===`conflict`?r:(W.set(t.executionAttemptId,{...r.intent}),L.set(t.executionAttemptId,{...n,operationStartGate:`closed`}),r)},async requestCancellation(e){let t=a(e),n={...t,requestKey:ae()},r=new Date().toISOString(),i=[...L].filter(([,e])=>e.executionId===t.executionId).map(([e,t])=>{let i=c(W.get(e)??null,n,r);if(i.kind===`conflict`)throw Error(`Conflicting generated cancellation request key`);return{id:e,attempt:t,intent:i.intent}});for(let{id:e,attempt:t,intent:n}of i)W.set(e,{...n}),L.set(e,{...t,operationStartGate:`closed`})},async readCancellation(e){let t=W.get(e);return t===void 0?null:{...t}},async readAttemptCancellationControl(e){let{executionId:t,executionAttemptId:n}=e,r=L.get(n);return r===void 0||r.executionId!==t?null:structuredClone({control:D(r),cancellation:W.get(n)??null,evidence:[...G.get(n)?.values()??[]].sort((e,t)=>e.controlRevision-t.controlRevision||e.runtimeGeneration-t.runtimeGeneration)})},async recordAttemptControlReceipt(e){let t=ne(e),{executionId:n,...r}=t,{executionAttemptId:i,controlRevision:a,runtimeGeneration:o}=t,s=`${a}:${o}`,c=G.get(i)??new Map,l=c.get(s),u=S(L.get(i)??null,W.get(i)??null,l?.receipt??null,t);return u.kind===`accepted`&&(c.set(s,{controlRevision:a,runtimeGeneration:o,receipt:r,report:l?.report??null}),G.set(i,c)),u},async reportAttemptControl(e){let t=b(e),{executionId:n,...r}=t,{executionAttemptId:i,controlRevision:a,runtimeGeneration:o}=t,s=`${a}:${o}`,c=G.get(i)??new Map,l=c.get(s),u=x(L.get(i)??null,W.get(i)??null,l?.report??null,t);return u.kind===`accepted`&&(c.set(s,{controlRevision:a,runtimeGeneration:o,receipt:l?.receipt??null,report:r}),G.set(i,c)),u},async getActiveAttempt(e,t){return H.get(e)===t?L.get(t)??null:null},canonicalizeOutcome(e){return ee(F,e)},decodeOutcome(e){return t(F,e)},async commitOutcome(e){let n=e.result;if(H.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};let i=L.get(e.executionAttemptId);if(i===void 0)return{kind:`fenced`};let a=B.get(e.executionAttemptId);if(a!==void 0){let i=t(F,a);return r(a,n.text)?{kind:`duplicate`,outcome:i,text:a,controlObservation:structuredClone(V.get(e.executionAttemptId)??null)}:{kind:`conflict`}}if(i.settlementKind!=null)return{kind:`conflict`};l(i,e.runtimeFence);let o=f(W.get(e.executionAttemptId)??null);return B.set(e.executionAttemptId,n.text),V.set(e.executionAttemptId,o),L.set(e.executionAttemptId,Z(i,`outcome`)),{kind:`accepted`,outcome:t(F,n.text),text:n.text,controlObservation:structuredClone(o)}},async abandonPendingAttempt(e,t){if(H.get(t)!==e)return{kind:`fenced`};let n=L.get(e);return n?n.status===`allocated`?{kind:`allocated`}:n.status===`provisioning`?{kind:`provisioning`}:n.status===`settled`?{kind:n.settlementKind===`abandoned`?`already-abandoned`:`already-settled`}:(L.set(e,Z(n,`abandoned`)),{kind:`abandoned`}):{kind:`fenced`}},recovery:Q,attempts:L,operations:R,committedOutcomes:B,outcomeControlObservations:V,activeAttempts:H,requestBindings:U,cancellations:W,controlEvidence:G}}export{N as INITIAL_ATTEMPT_CONTROL_STATE,q as TEST_OWNER_ID,H as TEST_PROVIDER_ID,G as TEST_PROVISIONER_INCARNATION_ID,z as allocateTestAttempt,F as beginTestProvisioning,Q as createInMemoryAttemptRepository,U as driveTestAttemptToAllocated,K as leaseAt,I as makeBeginProvisioningInput,B as makeEvidence,J as makeProcessLossProof,L as makeTestAllocationRef,R as makeTestInstruction,W as makeTestWorkflowResult,X as requireCommittedOutcome,V as workflowRunResultOutcomeCodec};
@@ -1,4 +1,4 @@
1
- import { j as OutcomeCodec, x as ExecutionAttemptRepository } from "../../execution-attempt-repository-BUah8hma.mjs";
1
+ import { j as OutcomeCodec, x as ExecutionAttemptRepository } from "../../execution-attempt-repository-DOb5V4N2.mjs";
2
2
  import { MakaioDatabase } from "@makaio/framework/storage/drizzle";
3
3
 
4
4
  //#region subsystems/workflow-engine/src/testing/sqlite-attempt-repository.d.ts
@@ -1,4 +1,4 @@
1
- import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,n as te,o as ne,r as u,s as d,t as f,u as re,v as ie,x as ae,y as oe}from"../../execution-attempt-repository-aabFKcXN.mjs";import{a as se,i as ce,n as le,o as p,t as ue}from"../../execution-attempt-owner-recovery-CE_rvHKE.mjs";import{i as de,n as fe,r as pe,t as me}from"../../attempt-control-evidence-7lwRG73Y.mjs";import{PROVIDER_OPERATION_OBLIGATIONS as m,isProviderOperationResolved as h}from"../provider-operation.mjs";import{a as g,c as he,d as ge,i as _,l as v,o as _e,p as ve,r as y,s as ye,t as be,u as xe}from"../../attempt-record-codec-DaQ3WHUs.mjs";import{z as b}from"zod";import{BoundedRecoveryEvidenceSchema as x,ExecutionAttemptControlReceiptSchema as Se,ExecutionAttemptControlReportSchema as Ce,ExecutionAttemptOperationKindSchema as S,ProviderAllocationRefSchema as C,WorkerAllocationLifetimeSchema as w}from"@makaio/framework/contracts";import{getRawSqlExecutor as we,isSqliteUniqueViolationError as Te,serializeByKey as T,serializeDatabaseOperation as Ee}from"@makaio/framework/storage/drizzle";import{sql as E}from"drizzle-orm";const De=[`CREATE TABLE IF NOT EXISTS test_execution_attempt_control_evidence (
1
+ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,n as te,o as ne,r as u,s as d,t as f,u as re,v as ie,x as ae,y as oe}from"../../execution-attempt-repository-CY289HlC.mjs";import{a as se,i as ce,n as le,o as p,t as ue}from"../../execution-attempt-owner-recovery-BZOEVYFH.mjs";import{i as de,n as fe,r as pe,t as me}from"../../attempt-control-evidence-CHBnJoqN.mjs";import{PROVIDER_OPERATION_OBLIGATIONS as m,isProviderOperationResolved as h}from"../provider-operation.mjs";import{a as g,c as he,d as ge,i as _,l as v,o as _e,p as ve,r as y,s as ye,t as be,u as xe}from"../../attempt-record-codec-DXpdMgyI.mjs";import{z as b}from"zod";import{BoundedRecoveryEvidenceSchema as x,ExecutionAttemptControlReceiptSchema as Se,ExecutionAttemptControlReportSchema as Ce,ExecutionAttemptOperationKindSchema as S,ProviderAllocationRefSchema as C,WorkerAllocationLifetimeSchema as w}from"@makaio/framework/contracts";import{getRawSqlExecutor as we,isSqliteUniqueViolationError as Te,serializeByKey as T,serializeDatabaseOperation as Ee}from"@makaio/framework/storage/drizzle";import{sql as E}from"drizzle-orm";const De=[`CREATE TABLE IF NOT EXISTS test_execution_attempt_control_evidence (
2
2
  execution_attempt_id TEXT NOT NULL,
3
3
  control_revision INTEGER NOT NULL,
4
4
  runtime_generation INTEGER NOT NULL,
@@ -1 +1 @@
1
- import{Ft as e,H as t,M as n,c as r,d as i,i as a,l as o,q as s,r as c,s as l,t as u}from"../authority-state-bootstrap-CvuWPywM.mjs";import{WORKFLOW_CANCELLED_REASON as d,WorkflowRunContextSchema as f}from"@makaio/framework/contracts";import*as p from"node:os";async function m(t,n,r,i){let a=await y(t,n,r);return await t.request(s.setExecution,{execution:a}),r===`completed`?await t.emit(e.execution.completed,{executionId:n.executionId,workflowId:n.workflowId,totalDuration:0,completedAt:a.completedAt}):await t.emit(e.execution.cancelled,{executionId:n.executionId,workflowId:n.workflowId,reason:i,completedAt:a.completedAt}),r===`cancelled`?{executionId:n.executionId,workflowId:n.workflowId,status:`cancelled`,...i===void 0?{}:{reason:i}}:{executionId:n.executionId,workflowId:n.workflowId,status:`completed`}}function h(e,t){return t.status===`completed`?{executionId:e.executionId,workflowId:e.workflowId,status:`completed`,...t.artifact===void 0?{}:{artifact:t.artifact}}:t.status===`cancelled`?{executionId:e.executionId,workflowId:e.workflowId,status:`cancelled`,...t.reason===void 0?{}:{reason:t.reason}}:t.status===`paused`?{executionId:e.executionId,workflowId:e.workflowId,status:`paused`,pausedAtGateId:t.pausedAtGateId,pausedAtFrameId:t.pausedAtFrameId}:{executionId:e.executionId,workflowId:e.workflowId,status:`failed`,error:t.error}}function g(e){let r,i=()=>{r=n({bus:e.bus,activeExecutions:e.activeExecutions,shellAbortControllers:e.shellAbortControllers,activeRunnerSteps:e.activeRunnerSteps,durableLifecycleTransitions:e.durableLifecycleTransitions,lifecyclePublications:e.lifecyclePublications,publishingLifecycleExecutions:e.publishingLifecycleExecutions,cancelTimeoutMs:t.cancelTimeoutMs},e.executionId,d).catch(t=>(console.error(`[WorkflowOrchestrator] Failed to persist cancellation for ${e.executionId}:`,t),!1))};return e.signal.addEventListener(`abort`,i,{once:!0}),e.signal.aborted&&i(),async()=>(e.signal.removeEventListener(`abort`,i),r??!1)}async function _(e,t){let n=await e.requestOptional(s.getExecution,{executionId:t});return n.handled?n.data.execution?.startedAt??void 0:void 0}async function v(e,t){return{id:t.executionId,workflowId:t.workflowId,coordinatorSessionId:t.coordinatorSessionId,status:`running`,inputs:t.inputs,config:t.config??{},startedAt:await _(e,t.executionId)??Date.now(),triggerPayload:t.triggerPayload,...t.artifactRef===void 0?{}:{artifactRef:t.artifactRef},scope:t.scope}}async function y(e,t,n){let r=Date.now();return{id:t.executionId,workflowId:t.workflowId,coordinatorSessionId:t.coordinatorSessionId,status:n,inputs:t.inputs,config:t.config??{},startedAt:await _(e,t.executionId)??r,completedAt:r,triggerPayload:t.triggerPayload,...t.artifactRef===void 0?{}:{artifactRef:t.artifactRef},scope:t.scope}}async function b(e,t,n,i,s,c,l,u,f){let{executionAttemptId:m,suspensionStrategy:h}=e,g=h===`wait-in-process`?void 0:await x(e.executionId,l,{required:!0}),_=await r({definition:t,execution:n,runContext:i,zodSchema:f?.artifact,bus:l}),v=new o(e.executionId,e.workflowId,t,n,s,l,u,void 0,_,{context:{repoPath:process.cwd(),makaioHome:process.env.MAKAIO_HOME??`${p.homedir()}/.makaio`,os:process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`,arch:process.arch},env:e.env},{executionAttemptId:m,suspensionStrategy:h,resumeFrames:g,runtimeLoopGates:c}),y=v.buildExpressionContext(),b=await a(t.root,v,y);return b.status===`failed`?{status:`failed`,error:b.error}:b.status===`paused`?{status:`paused`,pausedAtGateId:b.pausedAtGateId,pausedAtFrameId:b.pausedAtFrameId}:b.status===`cancelled`||u.aborted?{status:`cancelled`,reason:d}:{status:`completed`,artifact:_?.current}}async function x(e,t,n={}){try{let r=await t.requestOptional(s.listFrames,{executionId:e});if(!r.handled){if(n.required===!0)throw Error(`Frame storage handler is required to resume execution '${e}'.`);return}return r.data.frames.length===0?void 0:l(r.data.frames)}catch(e){if(n.required===!0)throw e;return}}function S(e,t){return f.parse({executionId:e.executionId,workflowId:e.workflowId,source:e.source.kind===`path`?{kind:`path`,path:e.materializationSpec?.sourcePath??``}:e.source,definitionSnapshot:e.source.kind===`definition`?e.definition??t:t,workerManifest:{contributionRefs:[]},inputs:e.inputs,config:e.config??{},scope:e.scope,triggerPayload:e.triggerPayload,...e.artifactRef===void 0?{}:{artifactRef:e.artifactRef},coordinatorSessionId:e.coordinatorSessionId,cancelSubject:e.cancelSubject,env:e.env,createdAt:Date.now(),suspensionStrategy:e.suspensionStrategy,...e.terminalAuthority===void 0?{}:{terminalAuthority:e.terminalAuthority},...e.materializationSpec===void 0?{}:{materializationSpec:e.materializationSpec}})}async function C(t,n,r,i,a){r.status=`paused`,await t.request(s.setExecution,{execution:r}),await t.emit(e.execution.paused,{executionId:n.executionId,workflowId:n.workflowId,pausedAtGateId:i,pausedAtFrameId:a})}async function w(t,n,r,i,a,o){r===`completed`?await t.emit(e.execution.completed,{executionId:n.executionId,workflowId:n.workflowId,totalDuration:a-i.startedAt,completedAt:a}):r===`cancelled`?await t.emit(e.execution.cancelled,{executionId:n.executionId,workflowId:n.workflowId,reason:d,completedAt:a}):await t.emit(e.execution.failed,{executionId:n.executionId,workflowId:n.workflowId,error:o??`Workflow execution failed`,completedAt:a})}async function T(e){let{config:t,loaded:n,bus:r,signal:a}=e,{definition:o}=n;if(a.aborted)return t.terminalAuthority===`authority`?{executionId:t.executionId,workflowId:t.workflowId,status:`cancelled`,reason:d}:m(r,t,`cancelled`,d);let l=await v(r,t),f=S(t,o);t.terminalAuthority===`authority`?await u(r,f,o):await i(r,l,f,o);let p=new Map(n.runtimeHandlers),_=n.runtimeLoopGates??new Map,y=new Map,x=new Map,T=new Map,E=new Map,D=new Map,O=new Set;y.set(t.executionId,{execution:l,workflow:o,runContext:f,runtimeHandlers:p,runtimeLoopGates:new Map(_)});let k=t.terminalAuthority===`authority`?async()=>!1:g({signal:a,executionId:t.executionId,bus:r,activeExecutions:y,shellAbortControllers:x,activeRunnerSteps:T,durableLifecycleTransitions:E,lifecyclePublications:D,publishingLifecycleExecutions:O}),A={status:`completed`},j=!1;try{o.root.nodes.length>0&&(c(o,_),A=await b(t,o,l,f,p,_,r,a,n.zodSchemas))}catch(e){A={status:`failed`,error:e instanceof Error?e.message:String(e)}}finally{j=await k(),y.clear()}if(j)return h(t,{status:`cancelled`,reason:d});if((a.aborted||l.status===`cancelled`)&&(A={status:`cancelled`,reason:d}),A.status===`paused`)return t.terminalAuthority!==`authority`&&await C(r,t,l,A.pausedAtGateId,A.pausedAtFrameId),h(t,A);if(t.terminalAuthority===`authority`)return h(t,A);let M=Date.now(),N=A.status===`failed`?A.error:void 0;return l.status=A.status,l.completedAt=M,l.error=N,await r.request(s.setExecution,{execution:l}),await w(r,t,A.status,l,M,N),h(t,A)}export{T as runWorkflowOrchestrator};
1
+ import{Ft as e,H as t,M as n,c as r,d as i,i as a,l as o,q as s,r as c,s as l,t as u}from"../authority-state-bootstrap-4F5Wc_6l.mjs";import{WORKFLOW_CANCELLED_REASON as d,WorkflowRunContextSchema as f}from"@makaio/framework/contracts";import*as p from"node:os";async function m(t,n,r,i){let a=await y(t,n,r);return await t.request(s.setExecution,{execution:a}),r===`completed`?await t.emit(e.execution.completed,{executionId:n.executionId,workflowId:n.workflowId,totalDuration:0,completedAt:a.completedAt}):await t.emit(e.execution.cancelled,{executionId:n.executionId,workflowId:n.workflowId,reason:i,completedAt:a.completedAt}),r===`cancelled`?{executionId:n.executionId,workflowId:n.workflowId,status:`cancelled`,...i===void 0?{}:{reason:i}}:{executionId:n.executionId,workflowId:n.workflowId,status:`completed`}}function h(e,t){return t.status===`completed`?{executionId:e.executionId,workflowId:e.workflowId,status:`completed`,...t.artifact===void 0?{}:{artifact:t.artifact}}:t.status===`cancelled`?{executionId:e.executionId,workflowId:e.workflowId,status:`cancelled`,...t.reason===void 0?{}:{reason:t.reason}}:t.status===`paused`?{executionId:e.executionId,workflowId:e.workflowId,status:`paused`,pausedAtGateId:t.pausedAtGateId,pausedAtFrameId:t.pausedAtFrameId}:{executionId:e.executionId,workflowId:e.workflowId,status:`failed`,error:t.error}}function g(e){let r,i=()=>{r=n({bus:e.bus,activeExecutions:e.activeExecutions,shellAbortControllers:e.shellAbortControllers,activeRunnerSteps:e.activeRunnerSteps,durableLifecycleTransitions:e.durableLifecycleTransitions,lifecyclePublications:e.lifecyclePublications,publishingLifecycleExecutions:e.publishingLifecycleExecutions,cancelTimeoutMs:t.cancelTimeoutMs},e.executionId,d).catch(t=>(console.error(`[WorkflowOrchestrator] Failed to persist cancellation for ${e.executionId}:`,t),!1))};return e.signal.addEventListener(`abort`,i,{once:!0}),e.signal.aborted&&i(),async()=>(e.signal.removeEventListener(`abort`,i),r??!1)}async function _(e,t){let n=await e.requestOptional(s.getExecution,{executionId:t});return n.handled?n.data.execution?.startedAt??void 0:void 0}async function v(e,t){return{id:t.executionId,workflowId:t.workflowId,coordinatorSessionId:t.coordinatorSessionId,status:`running`,inputs:t.inputs,config:t.config??{},startedAt:await _(e,t.executionId)??Date.now(),triggerPayload:t.triggerPayload,...t.artifactRef===void 0?{}:{artifactRef:t.artifactRef},scope:t.scope}}async function y(e,t,n){let r=Date.now();return{id:t.executionId,workflowId:t.workflowId,coordinatorSessionId:t.coordinatorSessionId,status:n,inputs:t.inputs,config:t.config??{},startedAt:await _(e,t.executionId)??r,completedAt:r,triggerPayload:t.triggerPayload,...t.artifactRef===void 0?{}:{artifactRef:t.artifactRef},scope:t.scope}}async function b(e,t,n,i,s,c,l,u,f){let{executionAttemptId:m,suspensionStrategy:h}=e,g=h===`wait-in-process`?void 0:await x(e.executionId,l,{required:!0}),_=await r({definition:t,execution:n,runContext:i,zodSchema:f?.artifact,bus:l}),v=new o(e.executionId,e.workflowId,t,n,s,l,u,void 0,_,{context:{repoPath:process.cwd(),makaioHome:process.env.MAKAIO_HOME??`${p.homedir()}/.makaio`,os:process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`,arch:process.arch},env:e.env},{executionAttemptId:m,suspensionStrategy:h,resumeFrames:g,runtimeLoopGates:c}),y=v.buildExpressionContext(),b=await a(t.root,v,y);return b.status===`failed`?{status:`failed`,error:b.error}:b.status===`paused`?{status:`paused`,pausedAtGateId:b.pausedAtGateId,pausedAtFrameId:b.pausedAtFrameId}:b.status===`cancelled`||u.aborted?{status:`cancelled`,reason:d}:{status:`completed`,artifact:_?.current}}async function x(e,t,n={}){try{let r=await t.requestOptional(s.listFrames,{executionId:e});if(!r.handled){if(n.required===!0)throw Error(`Frame storage handler is required to resume execution '${e}'.`);return}return r.data.frames.length===0?void 0:l(r.data.frames)}catch(e){if(n.required===!0)throw e;return}}function S(e,t){return f.parse({executionId:e.executionId,workflowId:e.workflowId,source:e.source.kind===`path`?{kind:`path`,path:e.materializationSpec?.sourcePath??``}:e.source,definitionSnapshot:e.source.kind===`definition`?e.definition??t:t,workerManifest:{contributionRefs:[]},inputs:e.inputs,config:e.config??{},scope:e.scope,triggerPayload:e.triggerPayload,...e.artifactRef===void 0?{}:{artifactRef:e.artifactRef},coordinatorSessionId:e.coordinatorSessionId,cancelSubject:e.cancelSubject,env:e.env,createdAt:Date.now(),suspensionStrategy:e.suspensionStrategy,...e.terminalAuthority===void 0?{}:{terminalAuthority:e.terminalAuthority},...e.materializationSpec===void 0?{}:{materializationSpec:e.materializationSpec}})}async function C(t,n,r,i,a){r.status=`paused`,await t.request(s.setExecution,{execution:r}),await t.emit(e.execution.paused,{executionId:n.executionId,workflowId:n.workflowId,pausedAtGateId:i,pausedAtFrameId:a})}async function w(t,n,r,i,a,o){r===`completed`?await t.emit(e.execution.completed,{executionId:n.executionId,workflowId:n.workflowId,totalDuration:a-i.startedAt,completedAt:a}):r===`cancelled`?await t.emit(e.execution.cancelled,{executionId:n.executionId,workflowId:n.workflowId,reason:d,completedAt:a}):await t.emit(e.execution.failed,{executionId:n.executionId,workflowId:n.workflowId,error:o??`Workflow execution failed`,completedAt:a})}async function T(e){let{config:t,loaded:n,bus:r,signal:a}=e,{definition:o}=n;if(a.aborted)return t.terminalAuthority===`authority`?{executionId:t.executionId,workflowId:t.workflowId,status:`cancelled`,reason:d}:m(r,t,`cancelled`,d);let l=await v(r,t),f=S(t,o);t.terminalAuthority===`authority`?await u(r,f,o):await i(r,l,f,o);let p=new Map(n.runtimeHandlers),_=n.runtimeLoopGates??new Map,y=new Map,x=new Map,T=new Map,E=new Map,D=new Map,O=new Set;y.set(t.executionId,{execution:l,workflow:o,runContext:f,runtimeHandlers:p,runtimeLoopGates:new Map(_)});let k=t.terminalAuthority===`authority`?async()=>!1:g({signal:a,executionId:t.executionId,bus:r,activeExecutions:y,shellAbortControllers:x,activeRunnerSteps:T,durableLifecycleTransitions:E,lifecyclePublications:D,publishingLifecycleExecutions:O}),A={status:`completed`},j=!1;try{o.root.nodes.length>0&&(c(o,_),A=await b(t,o,l,f,p,_,r,a,n.zodSchemas))}catch(e){A={status:`failed`,error:e instanceof Error?e.message:String(e)}}finally{j=await k(),y.clear()}if(j)return h(t,{status:`cancelled`,reason:d});if((a.aborted||l.status===`cancelled`)&&(A={status:`cancelled`,reason:d}),A.status===`paused`)return t.terminalAuthority!==`authority`&&await C(r,t,l,A.pausedAtGateId,A.pausedAtFrameId),h(t,A);if(t.terminalAuthority===`authority`)return h(t,A);let M=Date.now(),N=A.status===`failed`?A.error:void 0;return l.status=A.status,l.completedAt=M,l.error=N,await r.request(s.setExecution,{execution:l}),await w(r,t,A.status,l,M,N),h(t,A)}export{T as runWorkflowOrchestrator};
@@ -1 +1 @@
1
- import{u as e}from"./framework-packages-Bg4edkkM.mjs";function t(){let t=new Map;return{filter:e=>!!(e.transitionRules?.rules?.length||e.transitionActions?.actions),async processActivated(i,a,o){let s=o.getService(e);if(!s)throw Error(`TransitionContributionProcessor: TransitionPipelineService is not available — ensure '${e.name}' is started before extensions with transitionRules or transitionActions.`);let c=a.transitionRules?.rules??[],l=a.transitionActions?.actions,u=c.length>0,d=l!==void 0;u&&n(i,c),d&&r(i,l);let f=!1,p=!1;try{u&&(s.ruleRegistry.register(i,c),f=!0),d&&(s.actionRegistry.register(i,l),p=!0)}catch(e){throw f&&s.ruleRegistry.deregister(i),p&&s.actionRegistry.deregister(i),e}t.set(i,()=>{u&&s.ruleRegistry.deregister(i),d&&s.actionRegistry.deregister(i)})},async processStopped(e){let n=t.get(e);if(n){try{n()}catch(t){console.error(`[TransitionContributionProcessor] Deregister error for "${e}":`,t)}t.delete(e)}}}}function n(e,t){let n=`${e}.`;for(let e of t)if(!e.id.startsWith(n))throw Error(`TransitionContributionProcessor: rule '${e.id}' must be namespaced by extension '${n}'`)}function r(e,t){let n=`${e}.`;for(let e of Object.keys(t))if(!e.startsWith(n))throw Error(`TransitionContributionProcessor: action type '${e}' must be namespaced by extension '${n}'`)}export{t};
1
+ import{u as e}from"./framework-packages-U4Xhouxe.mjs";function t(){let t=new Map;return{filter:e=>!!(e.transitionRules?.rules?.length||e.transitionActions?.actions),async processActivated(i,a,o){let s=o.getService(e);if(!s)throw Error(`TransitionContributionProcessor: TransitionPipelineService is not available — ensure '${e.name}' is started before extensions with transitionRules or transitionActions.`);let c=a.transitionRules?.rules??[],l=a.transitionActions?.actions,u=c.length>0,d=l!==void 0;u&&n(i,c),d&&r(i,l);let f=!1,p=!1;try{u&&(s.ruleRegistry.register(i,c),f=!0),d&&(s.actionRegistry.register(i,l),p=!0)}catch(e){throw f&&s.ruleRegistry.deregister(i),p&&s.actionRegistry.deregister(i),e}t.set(i,()=>{u&&s.ruleRegistry.deregister(i),d&&s.actionRegistry.deregister(i)})},async processStopped(e){let n=t.get(e);if(n){try{n()}catch(t){console.error(`[TransitionContributionProcessor] Deregister error for "${e}":`,t)}t.delete(e)}}}}function n(e,t){let n=`${e}.`;for(let e of t)if(!e.id.startsWith(n))throw Error(`TransitionContributionProcessor: rule '${e.id}' must be namespaced by extension '${n}'`)}function r(e,t){let n=`${e}.`;for(let e of Object.keys(t))if(!e.startsWith(n))throw Error(`TransitionContributionProcessor: action type '${e}' must be namespaced by extension '${n}'`)}export{t};
@@ -0,0 +1,3 @@
1
+ import{i as e,t}from"./chunk-DTipWd-i.mjs";import{t as n}from"./extension-package-provenance-ClpN3GHp.mjs";import{resolveMakaioHome as r}from"./runtime-node/makaio-config.mjs";import{_ as i,d as a,l as o,n as s,o as c,r as l,u,x as d,y as f}from"./bootstrap-start-client-9nOdeDYl.mjs";import{mintOrRotateWorkflowExecutionBusSecret as p}from"./runtime-node/workflow-execution-bus-access.mjs";import{z as m}from"zod";import{execFile as h,spawn as g}from"node:child_process";import{promisify as _}from"node:util";import*as v from"node:fs/promises";import y,{access as b}from"node:fs/promises";import*as x from"node:path";import{basename as ee,isAbsolute as S,join as C,relative as te}from"node:path";import*as w from"node:crypto";import{randomUUID as T}from"node:crypto";import{constants as E}from"node:fs";import{summarizeDiagnosticText as ne}from"@makaio/framework/utils";import{AdapterSubjects as re,BoundedRecoveryEvidenceSchema as D,CredentialSubjects as O,ExecutionAttemptSchemas as k,ExecutionAttemptSubjects as A,FrameworkContractNamespaces as ie,FrameworkStorageNamespaces as ae,JsonValueSchema as oe,PRE_REQUEST_REJECTION_CODE as se,PROVIDER_ALLOCATION_REF_VERSION as ce,ProviderAllocationRefSchema as le,RECOVERY_EVIDENCE_LIMITS as j,WorkerCapabilitiesSchema as ue,WorkerSchemas as de,WorkerSubjects as M,WorkflowRunContextSchema as fe,WorkflowRunResultSchema as pe,WorkflowWorkerConfigSchema as me,createWorkflowCancelSubject as he,isRuntimeOwnershipFieldClaimed as ge}from"@makaio/framework/contracts";import{BusAbortError as _e,ChannelClosedError as ve,createBusInstance as ye,isRequestCancellation as be,openChannel as xe,waitForSubscriptionPropagation as Se}from"@makaio/framework/bus";import{ExtensionCoordinator as Ce,KernelSubjects as we,coalesceExtensionOverrides as Te,filterEligibleExtensions as Ee}from"@makaio/framework/kernel";import{BaseService as De}from"@makaio/framework/service-base";import{parseStoredCredentialRef as Oe}from"@makaio/framework/contracts/config";import{AdapterRuntimeSubjects as ke,registerAdapterRuntimeIdentityHandlers as Ae}from"@makaio/framework/services/adapter-runtime";import{devNull as N}from"node:os";import{CLIDetectionNamespace as je,CLIDetectionSubjects as Me}from"@makaio/framework/services/cli-detection/namespace";import{SessionOrchestratorToken as Ne,ToolRegistryToken as Pe,canonicalModelPackage as Fe,createSubagentServicePackage as Ie,createToolContributionProcessor as Le,frameworkCorePackages as Re,sessionBridgePackage as ze,sessionOrchestratorPackage as Be,sessionPackage as Ve,sessionStoragePackage as He,toolRegistryPackage as Ue}from"@makaio/framework/services";import{AdapterSubsystemSubjects as We}from"@makaio/framework/services/adapter-subsystem";import{createClientsCorePackage as Ge}from"@makaio/framework/clients";import{resolveCredentialRef as Ke}from"@makaio/framework/adapters/config";import{AdapterSubsystemToken as P,createAdapterSubsystemContributionProcessor as qe,createAdapterSubsystemPackage as Je,orderAfterAdapterSubsystem as Ye}from"@makaio/framework/adapter-subsystem";import{execa as Xe}from"execa";import Ze from"piscina";import{ExecutionAttemptAuthority as Qe,WORKFLOW_WORKLOAD_KIND as $e,WORKFLOW_WORKLOAD_VERSION as et,WorkflowStorageSubjects as tt,buildWorkflowAttemptInstruction as nt,parseWorkflowAttemptInstruction as F,runAuthorityDispatchedAttempt as rt,toCommittedWorkflowRunnerCompletion as it}from"@makaio/framework/workflow-engine";import{runWorkflowOrchestrator as at}from"@makaio/framework/workflow-engine/workflow-orchestrator";import{setTimeout as ot}from"node:timers/promises";function st(e){return e.on(re.getCapabilities,async t=>{let{adapterName:n,adapterId:r}=t.payload;if(r){await t.next();return}if(n){let r=await e.requestOptional(ke.resolveId,{adapterName:n}),i=r.handled?r.data.adapterId:void 0;i&&(t.payload.adapterId=i)}await t.next()},{priority:20})}function ct(e){let{coordinator:t,configRepository:n,platformDefaults:r,prepareAuthRuntime:i,runtimeSnapshotHandlerPriority:a,runtimeDefinitionHandlerPriority:o}=e,s=Je({configRepository:n,coordinator:t,platformDefaults:r,...i!==void 0&&{prepareAuthRuntime:i},...a!==void 0&&{runtimeSnapshotHandlerPriority:a},...o!==void 0&&{runtimeDefinitionHandlerPriority:o}});return t.registerContributionProcessor(qe({getAdapterSubsystemService:()=>t.getExtensionService(P)})),{adapterSubsystemPackage:s}}function lt(e){let{bus:t,currentMachineId:n}=e,r=Ae(t,{currentMachineId:n,listKnownAdapterNames:e.listKnownAdapterNames??(async()=>{let{configs:e}=await t.request(We.listAdapterConfigs,{});return e.map(e=>e.name)}),...e.resolveLiveAdapterId!==void 0&&{resolveLiveAdapterId:e.resolveLiveAdapterId},...e.resolveLiveAdapterIdentity!==void 0&&{resolveLiveAdapterIdentity:e.resolveLiveAdapterIdentity},...e.listLiveAdapterIdentities!==void 0&&{listLiveAdapterIdentities:e.listLiveAdapterIdentities}}),i=st(t);return{cleanup:()=>{r.cleanup(),i()}}}function ut(e,t){if(!(e instanceof Error))return!1;let{rootPackageName:n,subpath:r}=ft(t),i=(r===void 0?[t]:[t,n]).flatMap(e=>[`Cannot find package '${e}'`,`Cannot find module '${e}'`,`Cannot find package "${e}"`,`Cannot find module "${e}"`]),a=e;return(a.code===`ERR_MODULE_NOT_FOUND`||a.code===`MODULE_NOT_FOUND`)&&i.some(t=>e.message.includes(t))||a.code===`ERR_PACKAGE_PATH_NOT_EXPORTED`&&r!==void 0&&e.message.includes(`Package subpath '${r}' is not defined by "exports"`)&&pt(e.message,n)?!0:i.some(t=>e.message.includes(t))}async function dt(e){try{return await import(e)}catch(t){if(ut(t,e))return null;throw t}}function ft(e){let t=e.split(`/`);return e.startsWith(`@`)?{rootPackageName:t.slice(0,2).join(`/`),subpath:t.length>2?`./${t.slice(2).join(`/`)}`:void 0}:{rootPackageName:t[0]??e,subpath:t.length>1?`./${t.slice(1).join(`/`)}`:void 0}}function pt(e,t){let n=t,r=t.replaceAll(`/`,`\\`);return e.includes(`/${n}/package.json`)||e.includes(`\\${r}\\package.json`)}async function mt(e,t=process.env,n=process.platform){let r=t[Object.keys(t).find(e=>e.toUpperCase()===`PATH`)??`PATH`]??``,i=(t.PATHEXT??`.EXE;.CMD;.BAT;.COM`).split(`;`).filter(Boolean),a=n===`win32`?x.extname(e)===``?i:[``,...i]:[``];for(let t of r.split(x.delimiter)){let n=t.replace(/^"|"$/gu,``),r=x.resolve(n||process.cwd());for(let t of a){let n=x.join(r,`${e}${t}`);try{return await b(n,E.X_OK),n}catch{}}}}async function ht(e,t=5e3,n=1e3){let{stdout:r}=await Xe(e,[`--version`],{forceKillAfterDelay:n,timeout:t});return r}function gt(e){return e.match(/(\d+\.\d+\.\d+)/u)?.[1]??`unknown`}async function _t(e,t=mt,n=ht){try{let r=await t(e);if(r===void 0)return{binary:e,found:!1};let i=await n(r);return i.length===0?{binary:e,found:!1}:{binary:e,found:!0,path:r,version:gt(i)}}catch{return{binary:e,found:!1}}}async function vt(e,t=mt,n=ht){return Promise.all(e.map(e=>_t(e,t,n)))}var yt=class extends De{constructor(e){super(e)}onInit(){this.registerHandler(Me.scan,async e=>{let t=await vt(e.payload.binaries);e.setResult({results:t})})}};const bt={name:`makaio.cli-detection`,displayName:`CLI Detection`,version:`0.1.0`,critical:!0,surface:`any`,namespaces:[je],create:e=>new yt(e.bus)};var xt=t(((t,n)=>{var r=e(`constants`),i=process.cwd,a=null,o=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return a||=i.call(process),a};try{process.cwd()}catch{}if(typeof process.chdir==`function`){var s=process.chdir;process.chdir=function(e){a=null,s.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,s)}n.exports=c;function c(e){r.hasOwnProperty(`O_SYMLINK`)&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=s(e.chown),e.fchown=s(e.fchown),e.lchown=s(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=a(e.chmodSync),e.fchmodSync=a(e.fchmodSync),e.lchmodSync=a(e.lchmodSync),e.stat=l(e.stat),e.fstat=l(e.fstat),e.lstat=l(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){}),o===`win32`&&(e.rename=typeof e.rename==`function`?(function(t){function n(n,r,i){var a=Date.now(),o=0;t(n,r,function s(c){if(c&&(c.code===`EACCES`||c.code===`EPERM`||c.code===`EBUSY`)&&Date.now()-a<6e4){setTimeout(function(){e.stat(r,function(e,a){e&&e.code===`ENOENT`?t(n,r,s):i(c)})},o),o<100&&(o+=10);return}i&&i(c)})}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.rename):e.rename),e.read=typeof e.read==`function`?(function(t){function n(n,r,i,a,o,s){var c;if(s&&typeof s==`function`){var l=0;c=function(u,d,f){if(u&&u.code===`EAGAIN`&&l<10)return l++,t.call(e,n,r,i,a,o,c);s.apply(this,arguments)}}return t.call(e,n,r,i,a,o,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.read):e.read,e.readSync=typeof e.readSync==`function`?(function(t){return function(n,r,i,a,o){for(var s=0;;)try{return t.call(e,n,r,i,a,o)}catch(e){if(e.code===`EAGAIN`&&s<10){s++;continue}throw e}}})(e.readSync):e.readSync;function t(e){e.lchmod=function(t,n,i){e.open(t,r.O_WRONLY|r.O_SYMLINK,n,function(t,r){if(t){i&&i(t);return}e.fchmod(r,n,function(t){e.close(r,function(e){i&&i(t||e)})})})},e.lchmodSync=function(t,n){var i=e.openSync(t,r.O_WRONLY|r.O_SYMLINK,n),a=!0,o;try{o=e.fchmodSync(i,n),a=!1}finally{if(a)try{e.closeSync(i)}catch{}else e.closeSync(i)}return o}}function n(e){r.hasOwnProperty(`O_SYMLINK`)&&e.futimes?(e.lutimes=function(t,n,i,a){e.open(t,r.O_SYMLINK,function(t,r){if(t){a&&a(t);return}e.futimes(r,n,i,function(t){e.close(r,function(e){a&&a(t||e)})})})},e.lutimesSync=function(t,n,i){var a=e.openSync(t,r.O_SYMLINK),o,s=!0;try{o=e.futimesSync(a,n,i),s=!1}finally{if(s)try{e.closeSync(a)}catch{}else e.closeSync(a)}return o}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}function i(t){return t&&function(n,r,i){return t.call(e,n,r,function(e){d(e)&&(e=null),i&&i.apply(this,arguments)})}}function a(t){return t&&function(n,r){try{return t.call(e,n,r)}catch(e){if(!d(e))throw e}}}function s(t){return t&&function(n,r,i,a){return t.call(e,n,r,i,function(e){d(e)&&(e=null),a&&a.apply(this,arguments)})}}function c(t){return t&&function(n,r,i){try{return t.call(e,n,r,i)}catch(e){if(!d(e))throw e}}}function l(t){return t&&function(n,r,i){typeof r==`function`&&(i=r,r=null);function a(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),i&&i.apply(this,arguments)}return r?t.call(e,n,r,a):t.call(e,n,a)}}function u(t){return t&&function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}}function d(e){return!e||e.code===`ENOSYS`||(!process.getuid||process.getuid()!==0)&&(e.code===`EINVAL`||e.code===`EPERM`)}}})),St=t(((t,n)=>{var r=e(`stream`).Stream;n.exports=i;function i(e){return{ReadStream:t,WriteStream:n};function t(n,i){if(!(this instanceof t))return new t(n,i);r.call(this);var a=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags=`r`,this.mode=438,this.bufferSize=64*1024,i||={};for(var o=Object.keys(i),s=0,c=o.length;s<c;s++){var l=o[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.end===void 0)this.end=1/0;else if(typeof this.end!=`number`)throw TypeError(`end must be a Number`);if(this.start>this.end)throw Error(`start must be <= end`);this.pos=this.start}if(this.fd!==null){process.nextTick(function(){a._read()});return}e.open(this.path,this.flags,this.mode,function(e,t){if(e){a.emit(`error`,e),a.readable=!1;return}a.fd=t,a.emit(`open`,t),a._read()})}function n(t,i){if(!(this instanceof n))return new n(t,i);r.call(this),this.path=t,this.fd=null,this.writable=!0,this.flags=`w`,this.encoding=`binary`,this.mode=438,this.bytesWritten=0,i||={};for(var a=Object.keys(i),o=0,s=a.length;o<s;o++){var c=a[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.start<0)throw Error(`start must be >= zero`);this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}})),Ct=t(((e,t)=>{t.exports=r;var n=Object.getPrototypeOf||function(e){return e.__proto__};function r(e){if(typeof e!=`object`||!e)return e;if(e instanceof Object)var t={__proto__:n(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}})),wt=t(((t,n)=>{var r=e(`fs`),i=xt(),a=St(),o=Ct(),s=e(`util`),c,l;typeof Symbol==`function`&&typeof Symbol.for==`function`?(c=Symbol.for(`graceful-fs.queue`),l=Symbol.for(`graceful-fs.previous`)):(c=`___graceful-fs.queue`,l=`___graceful-fs.previous`);function u(){}function d(e,t){Object.defineProperty(e,c,{get:function(){return t}})}var f=u;s.debuglog?f=s.debuglog(`gfs4`):/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&(f=function(){var e=s.format.apply(s,arguments);e=`GFS4: `+e.split(/\n/).join(`
2
+ GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){function t(t,n){return e.call(r,t,function(e){e||g(),typeof n==`function`&&n.apply(this,arguments)})}return Object.defineProperty(t,l,{value:e}),t})(r.close),r.closeSync=(function(e){function t(t){e.apply(r,arguments),g()}return Object.defineProperty(t,l,{value:e}),t})(r.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&process.on(`exit`,function(){f(r[c]),e(`assert`).equal(r[c].length,0)})),global[c]||d(global,r[c]),n.exports=p(o(r)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!r.__patched&&(n.exports=p(r),r.__patched=!0);function p(e){i(e),e.gracefulify=p,e.createReadStream=te,e.createWriteStream=w;var t=e.readFile;e.readFile=n;function n(e,n,r){return typeof n==`function`&&(r=n,n=null),i(e,n,r);function i(e,n,r,a){return t(e,n,function(t){t&&(t.code===`EMFILE`||t.code===`ENFILE`)?m([i,[e,n,r],t,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=o;function o(e,t,n,i){return typeof n==`function`&&(i=n,n=null),a(e,t,n,i);function a(e,t,n,i,o){return r(e,t,n,function(r){r&&(r.code===`EMFILE`||r.code===`ENFILE`)?m([a,[e,t,n,i],r,o||Date.now(),Date.now()]):typeof i==`function`&&i.apply(this,arguments)})}}var s=e.appendFile;s&&(e.appendFile=c);function c(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return s(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var l=e.copyFile;l&&(e.copyFile=u);function u(e,t,n,r){return typeof n==`function`&&(r=n,n=0),i(e,t,n,r);function i(e,t,n,r,a){return l(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var d=e.readdir;e.readdir=h;var f=/^v[0-5]\./;function h(e,t,n){typeof t==`function`&&(n=t,t=null);var r=f.test(process.version)?function(e,t,n,r){return d(e,i(e,t,n,r))}:function(e,t,n,r){return d(e,t,i(e,t,n,r))};return r(e,t,n);function i(e,t,n,i){return function(a,o){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?m([r,[e,t,n],a,i||Date.now(),Date.now()]):(o&&o.sort&&o.sort(),typeof n==`function`&&n.call(this,a,o))}}}if(process.version.substr(0,4)===`v0.8`){var g=a(e);x=g.ReadStream,S=g.WriteStream}var _=e.ReadStream;_&&(x.prototype=Object.create(_.prototype),x.prototype.open=ee);var v=e.WriteStream;v&&(S.prototype=Object.create(v.prototype),S.prototype.open=C),Object.defineProperty(e,`ReadStream`,{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,`WriteStream`,{get:function(){return S},set:function(e){S=e},enumerable:!0,configurable:!0});var y=x;Object.defineProperty(e,`FileReadStream`,{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var b=S;Object.defineProperty(e,`FileWriteStream`,{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0});function x(e,t){return this instanceof x?(_.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function ee(){var e=this;E(e.path,e.flags,e.mode,function(t,n){t?(e.autoClose&&e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n),e.read())})}function S(e,t){return this instanceof S?(v.apply(this,arguments),this):S.apply(Object.create(S.prototype),arguments)}function C(){var e=this;E(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function te(t,n){return new e.ReadStream(t,n)}function w(t,n){return new e.WriteStream(t,n)}var T=e.open;e.open=E;function E(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return T(e,t,n,function(o,s){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}return e}function m(e){f(`ENQUEUE`,e[0].name,e[1]),r[c].push(e),_()}var h;function g(){for(var e=Date.now(),t=0;t<r[c].length;++t)r[c][t].length>2&&(r[c][t][3]=e,r[c][t][4]=e);_()}function _(){if(clearTimeout(h),h=void 0,r[c].length!==0){var e=r[c].shift(),t=e[0],n=e[1],i=e[2],a=e[3],o=e[4];if(a===void 0)f(`RETRY`,t.name,n),t.apply(null,n);else if(Date.now()-a>=6e4){f(`TIMEOUT`,t.name,n);var s=n.pop();typeof s==`function`&&s.call(null,i)}else{var l=Date.now()-o,u=Math.max(o-a,1);l>=Math.min(u*1.2,100)?(f(`RETRY`,t.name,n),t.apply(null,n.concat([a]))):r[c].push(e)}h===void 0&&(h=setTimeout(_,0))}}})),Tt=t(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),Et=t((e=>{var t=Tt();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&n.forever,unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),Dt=t(((e,t)=>{t.exports=Et()})),Ot=t(((e,t)=>{t.exports=[`SIGABRT`,`SIGALRM`,`SIGHUP`,`SIGINT`,`SIGTERM`],process.platform!==`win32`&&t.exports.push(`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&t.exports.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`,`SIGUNUSED`)})),kt=t(((t,n)=>{var r=global.process;let i=function(e){return e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`};if(!i(r))n.exports=function(){return function(){}};else{var a=e(`assert`),o=Ot(),s=/^win/i.test(r.platform),c=e(`events`);typeof c!=`function`&&(c=c.EventEmitter);var l;r.__signal_exit_emitter__?l=r.__signal_exit_emitter__:(l=r.__signal_exit_emitter__=new c,l.count=0,l.emitted={}),l.infinite||(l.setMaxListeners(1/0),l.infinite=!0),n.exports=function(e,t){if(!i(global.process))return function(){};a.equal(typeof e,`function`,`a callback must be provided for exit handler`),p===!1&&m();var n=`exit`;return t&&t.alwaysLast&&(n=`afterexit`),l.on(n,e),function(){l.removeListener(n,e),l.listeners(`exit`).length===0&&l.listeners(`afterexit`).length===0&&u()}};var u=function(){!p||!i(global.process)||(p=!1,o.forEach(function(e){try{r.removeListener(e,f[e])}catch{}}),r.emit=_,r.reallyExit=h,--l.count)};n.exports.unload=u;var d=function(e,t,n){l.emitted[e]||(l.emitted[e]=!0,l.emit(e,t,n))},f={};o.forEach(function(e){f[e]=function(){i(global.process)&&r.listeners(e).length===l.count&&(u(),d(`exit`,null,e),d(`afterexit`,null,e),s&&e===`SIGHUP`&&(e=`SIGINT`),r.kill(r.pid,e))}}),n.exports.signals=function(){return o};var p=!1,m=function(){p||!i(global.process)||(p=!0,l.count+=1,o=o.filter(function(e){try{return r.on(e,f[e]),!0}catch{return!1}}),r.emit=v,r.reallyExit=g)};n.exports.load=m;var h=r.reallyExit,g=function(e){i(global.process)&&(r.exitCode=e||0,d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),h.call(r,r.exitCode))},_=r.emit,v=function(e,t){if(e===`exit`&&i(global.process)){t!==void 0&&(r.exitCode=t);var n=_.apply(this,arguments);return d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),n}else return _.apply(this,arguments)}}})),At=t(((e,t)=>{let n=Symbol();function r(e,t,r){let i=t[n];if(i)return t.stat(e,(e,t)=>{if(e)return r(e);r(null,t.mtime,i)});let a=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,a,a,i=>{if(i)return r(i);t.stat(e,(e,i)=>{if(e)return r(e);let a=i.mtime.getTime()%1e3==0?`s`:`ms`;Object.defineProperty(t,n,{value:a}),r(null,i.mtime,a)})})}function i(e){let t=Date.now();return e===`s`&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}t.exports.probe=r,t.exports.getMtime=i})),jt=t(((t,n)=>{let r=e(`path`),i=wt(),a=Dt(),o=kt(),s=At(),c={};function l(e,t){return t.lockfilePath||`${e}.lock`}function u(e,t,n){if(!t.realpath)return n(null,r.resolve(e));t.fs.realpath(e,n)}function d(e,t,n){let r=l(e,t);t.fs.mkdir(r,i=>{if(!i)return s.probe(r,t.fs,(e,i,a)=>{if(e)return t.fs.rmdir(r,()=>{}),n(e);n(null,i,a)});if(i.code!==`EEXIST`)return n(i);if(t.stale<=0)return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));t.fs.stat(r,(r,i)=>{if(r)return r.code===`ENOENT`?d(e,{...t,stale:0},n):n(r);if(!f(i,t))return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));p(e,t,r=>{if(r)return n(r);d(e,{...t,stale:0},n)})})})}function f(e,t){return e.mtime.getTime()<Date.now()-t.stale}function p(e,t,n){t.fs.rmdir(l(e,t),e=>{if(e&&e.code!==`ENOENT`)return n(e);n()})}function m(e,t){let n=c[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(r,i)=>{let a=n.lastUpdate+t.stale<Date.now();if(r)return r.code===`ENOENT`||a?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));if(n.mtime.getTime()!==i.mtime.getTime())return h(e,n,Object.assign(Error(`Unable to update lock within the stale threshold`),{code:`ECOMPROMISED`}));let o=s.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,o,o,r=>{let i=n.lastUpdate+t.stale<Date.now();if(!n.released){if(r)return r.code===`ENOENT`||i?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));n.mtime=o,n.lastUpdate=Date.now(),n.updateDelay=null,m(e,t)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function h(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),c[e]===t&&delete c[e],t.options.onCompromised(n)}function g(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:i,onCompromised:e=>{throw e},...t},t.retries=t.retries||0,t.retries=typeof t.retries==`number`?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),u(e,t,(e,r)=>{if(e)return n(e);let i=a.operation(t.retries);i.attempt(()=>{d(r,t,(e,a,o)=>{if(i.retry(e))return;if(e)return n(i.mainError());let s=c[r]={lockfilePath:l(r,t),mtime:a,mtimePrecision:o,options:t,lastUpdate:Date.now()};m(r,t),n(null,e=>{if(s.released)return e&&e(Object.assign(Error(`Lock is already released`),{code:`ERELEASED`}));_(r,{...t,realpath:!1},e)})})})})}function _(e,t,n){t={fs:i,realpath:!0,...t},u(e,t,(e,r)=>{if(e)return n(e);let i=c[r];if(!i)return n(Object.assign(Error(`Lock is not acquired/owned by you`),{code:`ENOTACQUIRED`}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete c[r],p(r,t,n)})}function v(e,t,n){t={stale:1e4,realpath:!0,fs:i,...t},t.stale=Math.max(t.stale||0,2e3),u(e,t,(e,r)=>{if(e)return n(e);t.fs.stat(l(r,t),(e,r)=>e?e.code===`ENOENT`?n(null,!1):n(e):n(null,!f(r,t)))})}function y(){return c}o(()=>{for(let e in c){let t=c[e].options;try{t.fs.rmdirSync(l(e,t))}catch{}}}),n.exports.lock=g,n.exports.unlock=_,n.exports.check=v,n.exports.getLocks=y})),Mt=t(((e,t)=>{let n=wt();function r(e){let t=[`mkdir`,`realpath`,`stat`,`rmdir`,`utimes`],n={...e};return t.forEach(t=>{n[t]=(...n)=>{let r=n.pop(),i;try{i=e[`${t}Sync`](...n)}catch(e){return r(e)}r(null,i)}}),n}function i(e){return(...t)=>new Promise((n,r)=>{t.push((e,t)=>{e?r(e):n(t)}),e(...t)})}function a(e){return(...t)=>{let n,r;if(t.push((e,t)=>{n=e,r=t}),e(...t),n)throw n;return r}}function o(e){if(e={...e},e.fs=r(e.fs||n),typeof e.retries==`number`&&e.retries>0||e.retries&&typeof e.retries.retries==`number`&&e.retries.retries>0)throw Object.assign(Error(`Cannot use retries with the sync api`),{code:`ESYNC`});return e}t.exports={toPromise:i,toSync:a,toSyncOptions:o}})),Nt=t(((e,t)=>{let n=jt(),{toPromise:r,toSync:i,toSyncOptions:a}=Mt();async function o(e,t){return r(await r(n.lock)(e,t))}function s(e,t){return i(i(n.lock)(e,a(t)))}function c(e,t){return r(n.unlock)(e,t)}function l(e,t){return i(n.unlock)(e,a(t))}function u(e,t){return r(n.check)(e,t)}function d(e,t){return i(n.check)(e,a(t))}t.exports=o,t.exports.lock=o,t.exports.unlock=c,t.exports.lockSync=s,t.exports.unlockSync=l,t.exports.check=u,t.exports.checkSync=d}))();const Pt=[`config`,`extensions.json`],Ft={realpath:!1,stale:1e4,retries:{retries:50,factor:1.2,minTimeout:20,maxTimeout:200}},It=1024*1024;function I(e,t,n){return e.loadEnabled?.(t)!==!1||(n.critical??!1)}function Lt(e,t){return e.loadEnabled?.(t)===!1}function Rt(e){return x.join(e,...Pt)}async function zt(e){let t=Rt(e),{disabled:n,readFailure:r}=await Bt(t),i=new Set(n),a=Promise.resolve();return{readFailure:r,loadEnabled(e){return i.has(e)?!1:void 0},persistEnabled(e,n){let r=async()=>{await v.mkdir(x.dirname(t),{recursive:!0});let r=await(0,Nt.lock)(t,Ft);try{let{disabled:r,readFailure:i}=await Bt(t);if(i)throw Error(`Refusing to persist extension enablement for "${e}": the existing file at "${t}" could not be read (${i.reason}): ${i.diagnostic} Repair or delete the file, then retry.`);let a=new Set(r);n?a.delete(e):a.add(e),await Vt(t,[...a])}finally{await r()}n?i.delete(e):i.add(e)},o=a.then(r,r);return a=o.catch(()=>void 0),o}}}async function Bt(e){let t;try{let n=await v.stat(e);if(!n.isFile())return{disabled:[],readFailure:{reason:`unreadable`,diagnostic:`Enablement path at "${e}" is not a regular file; treating all extensions as enabled.`}};if(n.size>1048576)return{disabled:[],readFailure:{reason:`too-large`,diagnostic:`Enablement file at "${e}" exceeds ${It} bytes (${n.size} bytes); treating all extensions as enabled.`}};t=await v.readFile(e,`utf-8`)}catch(t){return t?.code===`ENOENT`?{disabled:[],readFailure:void 0}:{disabled:[],readFailure:{reason:`unreadable`,diagnostic:`Could not read enablement file at "${e}": ${ne(String(t))}`}}}let n;try{n=JSON.parse(t)}catch{return{disabled:[],readFailure:{reason:`not-json`,diagnostic:`Enablement file at "${e}" contains invalid JSON; treating all extensions as enabled.`}}}if(typeof n!=`object`||!n||Array.isArray(n))return{disabled:[],readFailure:{reason:`not-object`,diagnostic:`Enablement file at "${e}" is not a JSON object; treating all extensions as enabled.`}};let r=n;if(!(`disabled`in r))return{disabled:[],readFailure:void 0};let i=r.disabled;return!Array.isArray(i)||i.some(e=>typeof e!=`string`)?{disabled:[],readFailure:{reason:`invalid-disabled-field`,diagnostic:`Enablement file at "${e}" has a "disabled" field that is not a string array; treating all extensions as enabled.`}}:{disabled:i,readFailure:void 0}}async function Vt(e,t){let n=x.dirname(e);await v.mkdir(n,{recursive:!0});let r=t.length>0?{disabled:t}:{},i=`${JSON.stringify(r,null,2)}\n`,a=x.join(n,`.extensions-${process.pid}-${Date.now()}.json.tmp`);try{await v.writeFile(a,i,`utf-8`),await v.rename(a,e)}catch(e){throw await v.unlink(a).catch(()=>void 0),e}}function Ht(e,t){e.push(...Ut(t))}function Ut(e){return e===void 0?[]:typeof e==`function`?[e]:[...e]}function Wt(e,t=[]){let n=new Set([e]),r=new Set,i=new Map;for(let e of t)typeof e==`string`?n.add(e):(r.add(e.id),e.version!==void 0&&i.set(e.id,e.version));return{hosts:n,capabilities:r,...i.size>0?{capabilityVersions:i}:{}}}function Gt(e=[]){return e.some(e=>typeof e==`string`&&e===`node`)?e:[`node`,...e]}function Kt(e){return Te(Ee(e.packages,e.surface,e.runtimeEnvironment))}function qt(e,t,r){let i=r??Jt(t),a=new Set(i.map(n));return e.filter(({ownerPackage:e})=>a.has(e)).map(({package:e})=>e)}function Jt(e){let{configProvider:t}=e,n=Kt(e);return L(t?n.filter(e=>I(t,e.name,e)):n,n)}function L(e,t){let n=new Set(t.map(e=>e.name)),r=new Map(e.map(e=>[e.name,e])),i=!0;for(;i;){i=!1;for(let e of r.values()){let t=(e.dependencies??[]).filter(e=>!e.optional&&n.has(e.name)&&!r.has(e.name));t.length!==0&&(r.delete(e.name),i=!0,console.warn(`[boot] Excluding extension "%s" from boot composition: required dependency %s is disabled`,e.name,t.map(e=>e.name).join(`, `)))}}return[...r.values()]}function Yt(e,t,n){return e.filter(e=>!t.has(e.name)||n.has(e.name)?!0:(console.warn(`[boot] Excluding extension "%s": a disabled override would replace core package %s; the core package stays active; the override applies after enabling and restart`,e.name,e.name),!1))}function Xt(e){let{bootEligibleExtensionPackages:t,configProvider:n,frameworkPackageNames:r}=e,i=n?t.filter(e=>I(n,e.name,e)):t,a=Yt(t,r,new Set(L(i,t).map(e=>e.name))),o=new Set(a.map(e=>e.name)),s=L(i.filter(e=>o.has(e.name)),a);return{mergeableExtensionPackages:a,extensionManagedPackageNames:o,effectiveEnabledBootPackages:s,effectiveEnabledPackageNames:new Set(s.map(e=>e.name))}}function Zt(e,t,n){return e.filter(e=>!t.has(e.name)||n.has(e.name))}function R(e,t){return e.filter(e=>ge(e.runtimeOwnership,t)).map(e=>e.name)}function Qt(e,t){let n=R(e,t);if(n.length>1)throw Error(`Multiple extensions own runtimeOwnership.${t}: ${n.join(`, `)}`)}function $t(e){return Qt(e,`sessionOrchestrator`),R(e,`sessionOrchestrator`).length===0}function en(e){return e===!0||$t(e)?Re:Re.filter(e=>e.name!==Ne.name)}function tn(e,t,n){let r=[];try{for(let i of e){let e=i.runtimeBoot;e&&Ht(r,e.configure({bus:t,registerContributionProcessor:e=>{r.push(n.registerContributionProcessor(e))},forEachActiveExtension:e=>{n.forEachActiveExtension(e)}}))}}catch(e){let t=[];for(let e of[...r].reverse())try{e()}catch(e){t.push(e)}throw t.length>0?AggregateError([e,...t],`Extension boot contribution failed and rollback cleanup reported additional errors`,{cause:e}):e}return r}function nn(){let e=process.env.MAKAIO_SKIP_EXTENSIONS;if(!e)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(t)}const rn=_(h);var z=class{async resolve(e){return e.startsWith(`stored:`)?(console.warn(`[NodeCredentialProvider] Cannot resolve "stored:" credential ref "${e}": Register a credential service handler on this host to enable stored credential resolution.`),null):Ke(e,{resolveKeychain:this.resolveKeychain,readFile:async e=>{try{return await y.readFile(e,`utf-8`)}catch(t){let n=t.code??`unknown error`;return console.warn(`[NodeCredentialProvider] Cannot read file credential at "${e}" (${n}). Returning null.`),``}}})}async resolveKeychain(e,t){try{let{stdout:n}=await rn(`security`,[`find-generic-password`,`-s`,e,`-a`,t,`-w`]);return n.trim()||null}catch{return null}}},an=class{bus;fallbackProvider=new z;channelPromise;constructor(e){this.bus=e}async resolve(e){let t=Oe(e);if(t){let{configId:n,key:r}=t;for(let t=0;t<2;t++){let i=this.getChannel();try{let t=await i;return t?(await t.request(O.get,{configId:n})).credentials?.[r]??null:(console.warn(`[StoredCredentialProvider] Cannot resolve "stored:" credential ref "${e}": Register a credential service handler on this host to enable stored credential resolution.`),null)}catch(e){if(e instanceof ve&&(this.channelPromise===i&&(this.channelPromise=void 0),t===0))continue;throw e}}}return e.startsWith(`stored:`)?(console.warn(`[StoredCredentialProvider] Unresolvable credential ref "${e}". Only the "stored:providerConfig:" format is supported. Re-save the credential using the current format.`),null):this.fallbackProvider.resolve(e)}close(){let e=this.channelPromise;this.channelPromise=void 0,e!==void 0&&e.then(e=>{e?.close()}).catch(()=>{})}getChannel(){return this.channelPromise??=this.openCredentialChannel().then(e=>(e===null&&(this.channelPromise=void 0),e),e=>{throw this.channelPromise=void 0,e}),this.channelPromise}async openCredentialChannel(){let e=await this.bus.requestOptional(O.getChannelToken,{});if(!e.handled)return null;let{token:t}=e.data;return xe(this.bus.getContext(),`credentials`,{token:t,transports:[]})}},on=class{pool;constructor(e){this.pool=new Ze({filename:e.workerEntry,maxThreads:e.maxConcurrency??4,idleTimeout:e.idleTimeoutMs??3e4})}async run(e,t,n){return this.pool.run(e,{signal:t,transferList:n})}onMessage(e){return this.pool.on(`message`,e),()=>this.pool.off(`message`,e)}async dispose(){await this.pool.destroy()}},B=class extends Error{code;constructor(e,t){super(e),this.code=t,this.name=`MaterializationError`}};function V(e,t,n){let r=x.resolve(t)+x.sep,i=x.resolve(e);if(i!==x.resolve(t)&&!i.startsWith(r))throw new B(`${n} escapes allowed root: ${e} is not within ${t}`,`containment-violation`)}async function H(e,t,n,r){let i=r??await v.realpath(t),a;try{a=await v.realpath(e)}catch{return e}let o=i+x.sep;if(a!==i&&!a.startsWith(o))throw new B(`${n} escapes allowed root via symlink: real path ${a} is not within ${i}`,`symlink-escape`);return a}function sn(e){let t=e.indexOf(`-`);if(t===-1)throw new B(`Invalid SRI integrity format: ${e}`,`contribution-integrity-mismatch`);return{algorithm:e.slice(0,t),digest:e.slice(t+1)}}async function cn(e,t){let n=await v.readFile(e);return w.createHash(t).update(n).digest(`base64`)}const U=new Set([`.git`,`node_modules`]);function ln(e){return U.has(e.toLowerCase())}async function un(e,t){let n=t.toLowerCase();if(!U.has(n))return!1;if(t===n)return!0;try{let[r,i]=await Promise.all([v.lstat(x.join(e,t)),v.lstat(x.join(e,n))]);return r.dev===i.dev&&r.ino===i.ino}catch(e){if(e.code===`ENOENT`)return!1;throw e}}const dn=U,fn=new Set([`.DS_Store`]);async function pn(e,t){let n=w.createHash(t),r=[];async function i(t){let n=await v.readdir(t,{withFileTypes:!0});for(let a of n){let n=x.join(t,a.name);if(a.isSymbolicLink())throw new B(`Contribution package contains a symbolic link: ${x.relative(e,n)}`,`symlink-escape`);if(a.isDirectory()){dn.has(a.name)||await i(n);continue}if(a.isFile()){fn.has(a.name)||r.push(x.relative(e,n));continue}throw new B(`Contribution package contains an unsupported filesystem entry: ${x.relative(e,n)}`,`contribution-integrity-mismatch`)}}await i(e),r.sort();for(let t of r)n.update(t.split(x.sep).join(`/`)),n.update(`\0`),n.update(await v.readFile(x.join(e,t))),n.update(`\0`);return`${t}-${n.digest(`base64`)}`}async function mn(e,t=`sha256`){let n=w.createHash(t),r=[];async function i(t){let n=await v.readdir(t,{withFileTypes:!0});for(let a of n){let n=x.join(t,a.name);if(!await un(t,a.name)){if(a.isDirectory()){await i(n);continue}if(a.isFile()){r.push(x.relative(e,n));continue}throw a.isSymbolicLink()?new B(`Workspace root contains a symbolic link: ${x.relative(e,n)}`,`symlink-escape`):new B(`Workspace root contains an unsupported filesystem entry: ${x.relative(e,n)}`,`unsupported-filesystem-entry`)}}}await i(e),r.sort();for(let t of r){n.update(t),n.update(`\0`);let r=await v.readFile(x.join(e,t));n.update(r),n.update(`\0`)}return`${t}-${n.digest(`base64`)}`}async function hn(e,t,n){let r=x.join(t,`node_modules`,e.packageName);V(r,t,`Contribution package directory`),await H(r,t,`Contribution package directory`,n);let i=x.join(r,`package.json`),a;try{a=await v.readFile(i,`utf-8`)}catch{throw new B(`Contribution package not found: ${e.packageName} (expected at ${r})`,`contribution-missing`)}let o=JSON.parse(a);if(o.name!==e.packageName)throw new B(`Contribution identity mismatch: expected ${e.packageName}, found ${o.name??`<none>`}`,`contribution-missing`);if(o.version!==e.version)throw new B(`Contribution version mismatch for ${e.packageName}: expected ${e.version}, found ${o.version??`<none>`}`,`contribution-version-mismatch`);let s=x.join(r,e.entrypoint);V(s,r,`Contribution entrypoint`),await H(s,t,`Contribution entrypoint`,n);try{await v.access(s)}catch{throw new B(`Contribution entrypoint not found for ${e.packageName}: ${e.entrypoint}`,`contribution-entrypoint-mismatch`)}let{algorithm:c}=sn(e.integrity),l;try{l=await pn(r,c)}catch(t){if(t instanceof B)throw t;let n=typeof t==`object`&&t&&`code`in t&&typeof t.code==`string`?t.code:void 0;throw n!==void 0&&!n.startsWith(`ERR_`)?new B(`Contribution package cannot be read for ${e.packageName}`,`contribution-entrypoint-mismatch`):t}if(l!==e.integrity)throw new B(`Contribution integrity mismatch for ${e.packageName}: expected ${e.integrity}, computed ${l}`,`contribution-integrity-mismatch`);return s}async function gn(e,t,n){let r=await n.resolveWorkspaceRoot(e.workspaceId);if(r===void 0)throw new B(`Unknown workspace ID: ${e.workspaceId}`,`unknown-workspace`);try{if(!(await v.stat(r)).isDirectory())throw new B(`Workspace root is not a directory: ${r}`,`containment-violation`)}catch(e){throw e instanceof B?e:new B(`Workspace root does not exist: ${r}`,`containment-violation`)}let i=await v.realpath(r),a=x.resolve(r,e.sourcePath);if(V(a,r,`Source path`),x.relative(r,a).split(x.sep).some(ln))throw new B(`Workflow source path selects excluded workspace content: ${e.sourcePath}`,`source-path-mismatch`);await H(a,r,`Source path`,i);let o=await mn(r);if(o!==e.rootDigest)throw new B(`Workspace root digest mismatch: expected ${e.rootDigest}, computed ${o}`,`digest-mismatch`);try{await v.access(a)}catch{throw new B(`Workflow source file not found: ${a}`,`source-missing`)}return{workspaceRoot:r,sourcePath:a,contributionEntrypoints:await Promise.all(t.map(e=>hn(e,r,i))),platform:process.platform,arch:process.arch}}var _n=class{options;manifest;pool;constructor(e){this.options=e,this.manifest=e.manifest}async run(e,t,n){this.pool??=new on(this.options);let r=n??this.manifest,i=await this.materializeTask(e,r,t);return{state:`uncommitted`,result:await this.pool.run(i,t)}}runWithReadiness(e,t,n,r){this.pool??=new on(this.options);let a=this.pool,o,s=!1,c,l=new Promise((t,n)=>{c=n,o=a.onMessage(n=>{d(n)&&n.executionAttemptId===r.executionAttemptId&&(n.executionId!==e.executionId||n.cancelSubject!==e.cancelSubject||(s=!0,o?.(),t(n)))})}),u=n??this.manifest,f=i(r.bootstrapDeadlineAt,t,async(t,n)=>{let i=await this.materializeTask(e,u,n);return a.run({...i,kind:`attempt-bound`,executionAttemptId:r.executionAttemptId,bootstrapDeadlineAt:r.bootstrapDeadlineAt,bootstrapPort:t},n,[t])});return f.then(()=>{s||(s=!0,o?.(),c(Error(`Workflow worker completed before ready signal: ${e.executionId}`)))},e=>{s||(s=!0,o?.(),c(e instanceof Error?e:Error(String(e))))}),{result:f,ready:l}}async dispose(){await this.pool?.dispose()}async materializeTask(e,t,n){if(n.throwIfAborted(),!(e.source.kind===`path`||t.contributionRefs.length>0))return{kind:`unbound`,config:e,manifest:t,contributionEntrypoints:[]};let r=e.materializationSpec;if(r?.kind!==`local-directory`)throw Error(`ThinWorkflowPiscinaRunner requires a local-directory materialization spec for path-backed workflows or declared contributions.`);if(this.options.resolveWorkspaceRoot===void 0)throw Error(`ThinWorkflowPiscinaRunner requires a host workspace-root resolver for local-directory materialization.`);let i=await gn(r,t.contributionRefs,{resolveWorkspaceRoot:this.options.resolveWorkspaceRoot});if(n.throwIfAborted(),e.source.kind!==`path`)throw Error(`local-directory materialization requires a path-backed workflow source.`);return{kind:`unbound`,config:{...e,source:{kind:`path`,path:i.sourcePath}},manifest:t,contributionEntrypoints:i.contributionEntrypoints}}};function vn(e){return e.mode===`source`?C(e.moduleDir,`workflow-worker`,`worker-entry.ts`):C(e.moduleDir,`workflow-worker`,`worker-entry.mjs`)}var yn=class{options;terminalAuthority=`authority`;constructor(e){this.options=e}async run(e,t,n,r){let i={...e,terminalAuthority:`authority`},a=n??this.options.manifest,o=this.options.requirements,s=r?.dispatchMetadata;t.throwIfAborted();let c=e.source.kind===`path`?await this.options.readRunContext?.(e.executionId,t):void 0;t.throwIfAborted();let l=nt({id:T(),revision:`1`,config:e,...c==null?{}:{runContext:c},preservation:{required:[]}});return it(await rt({authority:this.options.authority,executionId:e.executionId,instruction:l,withAttemptCreation:r?.withAttemptCreation,dispatch:e=>this.options.dispatch({executionAttemptId:e,config:i,...a!==void 0&&{manifest:a},...o!==void 0&&{requirements:o},...s!==void 0&&{metadata:s}},t)}),e)}},bn=class{#e;constructor(e){this.#e=e.bus}async run(e,t,n){let r=me.parse(e),i=await a(r);return{state:`uncommitted`,result:await at({config:await u(r,i,this.#e,t),loaded:i,bus:this.#e,signal:t})}}};function xn(){return{contributionRefs:[]}}function Sn(e){if(e.workflowRunner?.mode===`worker`&&!e.executionAttemptRepository)throw Error(`Worker dispatch mode requires an ExecutionAttemptRepository. Pass 'executionAttemptRepository' to createNodeWorkflowRunnerPackageOptions when workflowRunner.mode is 'worker'.`);let t;if(e.executionAttemptRepository){let n=e.executionAttemptBootstrapTimeoutMs;if(n===void 0)throw Error(`An ExecutionAttemptRepository requires executionAttemptBootstrapTimeoutMs`);t=new Qe(e.executionAttemptRepository,{bootstrapTimeoutMs:n})}let n=ee(e.runtimeModuleDir)===`src`?`source`:`dist`,r=Cn({moduleDir:e.runtimeModuleDir,defaultWorkerEntryMode:n,runner:e.workflowRunner,bus:e.bus,authority:t});return{...r!==void 0&&{workflowRunner:r},executorConfig:{busUrl:e.busUrl,busAuth:{kind:`none`},platformDefaults:e.platformDefaults,makaioHome:e.makaioHome},...e.executionAttemptRepository!==void 0&&{executionAttemptRepository:e.executionAttemptRepository},...t!==void 0&&{executionAttemptAuthority:t},...e.workflowMaterializationSpecResolvers!==void 0&&{workflowMaterializationSpecResolvers:e.workflowMaterializationSpecResolvers}}}function Cn(e){let{runner:t}=e;if(t)switch(t.mode){case void 0:case`in-process`:if(e.bus===void 0)throw Error(`InProcessWorkflowRunner requires a bus instance. Pass 'bus' to createNodeWorkflowRunner when runner.mode is 'in-process'.`);return new bn({bus:e.bus});case`worker`:{if(e.authority===void 0)throw Error(`WorkerRunner requires an ExecutionAttemptAuthority. Pass 'authority' to createNodeWorkflowRunner when runner.mode is 'worker'.`);let n=e.bus,r=t.dispatch??(n===void 0?void 0:(e,t)=>n.request(M.dispatch,{executionAttemptId:e.executionAttemptId,config:e.config,manifest:e.manifest,requirements:e.requirements,metadata:e.metadata},{signal:t}));if(r===void 0)throw Error(`WorkerRunner requires either a dispatch function or a bus instance. Pass 'bus' to createNodeWorkflowRunner when runner.mode is 'worker'.`);return new yn({dispatch:r,authority:e.authority,...n!==void 0&&{readRunContext:async(e,t)=>(await n.request(tt.getRunContext,{executionId:e},{signal:t})).runContext},...t.manifest!==void 0&&{manifest:t.manifest},...t.requirements!==void 0&&{requirements:t.requirements}})}case`piscina`:return new _n({workerEntry:t.workerEntry??vn({moduleDir:e.moduleDir,mode:t.workerEntryMode??e.defaultWorkerEntryMode}),manifest:t.manifest??xn(),...t.resolveWorkspaceRoot!==void 0&&{resolveWorkspaceRoot:t.resolveWorkspaceRoot},maxConcurrency:t.maxConcurrency,idleTimeoutMs:t.idleTimeoutMs})}}const wn=new Set([`accepted`,`duplicate`]);var W=class extends Error{decision;result;reason;constructor(e,t,n=`authority-rejected`){super(`Outcome delivery ${n===`deadline-exceeded`?`deadline exceeded`:`rejected by Authority`} (decision=${e}, executionId=${t.executionId}, status=${t.status})`),this.decision=e,this.result=t,this.reason=n,this.name=`OutcomeDeliveryError`}},G=class extends Error{decision;payload;reason;constructor(e,t,n=`authority-rejected`){super(`Attempt outcome delivery ${n===`deadline-exceeded`?`deadline exceeded`:`rejected by Authority`} (decision=${e}, executionAttemptId=${t.executionAttemptId}, outcome=${t.outcome.kind})`),this.decision=e,this.payload=t,this.reason=n,this.name=`AttemptOutcomeDeliveryError`}},Tn=class extends Error{reason;constructor(e=`deadline-exceeded`){super(`Authority request delivery deadline exceeded`),this.reason=e,this.name=`AuthorityRequestDeliveryError`}};function En(e){let t={maxRetries:e?.maxRetries??7,baseDelayMs:e?.baseDelayMs??1e3,maxDelayMs:e?.maxDelayMs??3e4,deadlineMs:e?.deadlineMs??12e4};if(!Number.isSafeInteger(t.maxRetries)||t.maxRetries<0)throw TypeError(`Outcome submission maxRetries must be a non-negative safe integer, got ${t.maxRetries}`);for(let[e,n]of Object.entries({baseDelayMs:t.baseDelayMs,maxDelayMs:t.maxDelayMs,deadlineMs:t.deadlineMs}))if(!Number.isFinite(n)||n<=0)throw TypeError(`Outcome submission ${e} must be a positive finite number, got ${n}`);return t}async function Dn(e,t){if(t===void 0){await new Promise(t=>setTimeout(t,e));return}let n=t;n.throwIfAborted(),await new Promise((t,r)=>{let i=setTimeout(o,e),a=()=>o(n.reason);function o(e){clearTimeout(i),n.removeEventListener(`abort`,a),e===void 0?t():r(e)}n.addEventListener(`abort`,a,{once:!0})})}async function On(e,t,n){n?.throwIfAborted();let r;try{r=e()}catch{return}await new Promise((e,i)=>{let a=setTimeout(s,t),o=()=>s(n?.reason);function s(t){clearTimeout(a),n?.removeEventListener(`abort`,o),t===void 0?e():i(t)}r.then(()=>s(),()=>s()),n?.addEventListener(`abort`,o,{once:!0}),n?.aborted&&o()})}async function kn(e,t,n,r,i){let a=t.baseDelayMs*2**(e-1),o=n-Date.now();await Dn(Math.min(a,t.maxDelayMs,o),i);let s=n-Date.now();if(s<=0)return!1;if(r!==void 0)try{await On(r,s,i)}catch{i?.throwIfAborted()}return Date.now()<n}async function An(e,t,n,r){let i=En(n?.retry),a=n?.reconnect,o=n?.signal,s=Date.now()+i.deadlineMs,c;for(let n=0;n<=i.maxRetries;n++){if(o?.throwIfAborted(),s-Date.now()<=0||n>0&&!await kn(n,i,s,a,o))throw t();try{let n=s-Date.now();if(n<=0)throw t();return await e(n,o)}catch(e){if(o?.throwIfAborted(),r(e))throw e;if(c=e,Date.now()>=s)throw t()}}throw c??t()}async function K(e,t){return await An(e,()=>new Tn,t,()=>!1)}async function jn(e,t,n){return await An(async(n,r)=>{let i=await e(n,r);if(wn.has(i))return i;throw t(i)},()=>t(`deadline-exceeded`,`deadline-exceeded`),n,e=>e instanceof W||e instanceof G)}async function Mn(e,t,n){return await jn(async(n,r)=>(await e.request(M.control.outcome.submit,{executionAttemptId:t.executionAttemptId,executionId:t.executionId,result:t.result},r===void 0?{timeout:n}:{timeout:n,signal:r})).decision,(e,n)=>n===void 0?new W(e,t.result):new W(e,t.result,n),n)}async function Nn(e,t,n){return await jn(async(n,r)=>(await e.request(A.outcome.submit,t,r===void 0?{timeout:n}:{timeout:n,signal:r})).decision,(e,n)=>n===void 0?new G(e,t):new G(e,t,n),n)}const Pn={maxRetries:3,baseDelayMs:200,maxDelayMs:2e3,deadlineMs:1e4},Fn={persistentStorage:!0,customCapabilities:[`workflow.local-runtime`,`workflow.thin-runner`],suspensionStrategy:`wait-in-process`,supportsRecovery:!1,materializationModes:[`local-directory`]},In={code:`outcome-acknowledged`,summary:`Piscina runner settled and the Authority acknowledged its workflow outcome`},Ln={code:`outcome-delivery-ended`,summary:`Piscina runner settled and its bounded workflow outcome delivery ended`};function q(e){let t=new Set,n;return{publish:r=>{if(n!==void 0)return;let i=r();n=i;let a=[...t];t.clear();for(let t of a)try{t(i)}catch(t){console.error(`${e} observer failed:`,t)}},observe:e=>n===void 0?(t.add(e),()=>t.delete(e)):(e(n),()=>void 0)}}function Rn(e){let t=q(`[PiscinaThinWorkflowProvider] Infrastructure-conclusion`);return{conclude:n=>{t.publish(()=>({evidence:D.parse({source:e.slice(0,j.source),summary:n.slice(0,j.summary),observedAt:new Date().toISOString()})}))},observe:t.observe}}function zn(e,t){let n=q(`[PiscinaThinWorkflowProvider] Provider-completion`),r=q(`[PiscinaThinWorkflowProvider] Local-observation-loss`),i;return{completion:{complete:r=>{i===void 0&&n.publish(()=>{let n=D.parse({source:e.slice(0,j.source),code:r.code,summary:r.summary,observedAt:new Date().toISOString()});return t(),i=`completion`,n})},observe:n.observe},localObservationLoss:{lose:()=>{i===void 0&&r.publish(()=>(i=`local-observation-loss`,{}))},observe:e=>r.observe(()=>e())}}}var Bn=class{executionAttemptId;controller;detachCallerAbort;infrastructure;completion;localObservationLoss;revokeBusIdentity;constructor(e,t,n,r,i,a,o){this.executionAttemptId=e,this.controller=t,this.detachCallerAbort=n,this.infrastructure=r,this.completion=i,this.localObservationLoss=a,this.revokeBusIdentity=o}cancel(e){return this.controller.abort(e??`Worker cancelled`),this.detachCallerAbort(),Promise.resolve()}terminate(){return this.controller.abort(`Worker terminated`),this.detachCallerAbort(),this.revokeBusIdentity(),Promise.resolve()}release(){return this.detachCallerAbort(),Promise.resolve()}observeInfrastructureConclusion(e){return this.infrastructure.observe(e)}observeProviderCompletion(e){return this.completion.observe(e)}observeLocalObservationLoss(e){return this.localObservationLoss.observe(e)}},Vn=class{options;environment=`piscina`;allocationLifetime=`provisioner-process-bound`;baseCapabilities;constructor(e){this.options=e,this.baseCapabilities=ue.parse({...Fn,...e.baseCapabilities,suspensionStrategy:e.baseCapabilities?.suspensionStrategy??Fn.suspensionStrategy,supportsRecovery:!1})}get id(){return this.options.id}get displayName(){return this.options.displayName}async provision(e,t){t.throwIfAborted();let n=await this.resolveLaunchBeforeAllocation(e,t);if(t.throwIfAborted(),`kind`in n)return n;let r=n,i=new AbortController,a=Rn(this.id),o=()=>{i.abort(t.reason)};t.addEventListener(`abort`,o,{once:!0});let s=()=>t.removeEventListener(`abort`,o),c;try{let{executionAttemptId:n,executionId:o}=e,l=this.buildAllocationRef(n),u=p({executionAttemptId:n,executionId:o}),d=!1,f=()=>{d||(d=!0,u.cleanup())};c=f;let m=zn(this.id,f),h=new Bn(n,i,s,a,m.completion,m.localObservationLoss,f);t.throwIfAborted();let g=this.options.runner.runWithReadiness({...r,busAuth:{kind:`hmac`,secret:u.secret}},i.signal,e.runtimeInputs.workerManifest,{executionAttemptId:n,bootstrapDeadlineAt:e.bootstrapDeadlineAt});return g.ready.then(()=>this.submitOutcomeOnSettlement(g.result,o,n,r.workflowId,a.conclude,m.completion.complete),e=>{i.abort(e),g.result.catch(()=>void 0),c?.(),a.conclude(`Piscina worker for attempt '${n}' was refused before its workflow run was admitted: `+(e instanceof Error?e.message:String(e))),m.localObservationLoss.lose()}),{kind:`allocated`,allocationRef:l,handle:h}}catch(e){throw i.abort(e),s(),c?.(),e}}async resolveLaunchBeforeAllocation(e,t){try{let n=await this.options.launchResolver(e,t);return t.throwIfAborted(),n.busUrl?n:this.confirmedAbsent(`Piscina workflow configuration has no bus URL before local allocation setup`)}catch{return t.throwIfAborted(),this.confirmedAbsent(`Workflow launch resolution failed before Piscina local allocation setup`)}}confirmedAbsent(e){return{kind:`confirmed-absent`,evidence:D.parse({source:`piscina-thin-workflow-provider`,code:se,summary:e,observedAt:new Date().toISOString()})}}async submitOutcomeOnSettlement(e,t,n,r,i,a){let o;try{o=await e}catch(e){o={executionId:t,workflowId:r,status:`failed`,error:e instanceof Error?e.message:String(e)}}try{let e={...Pn,...this.options.outcomeRetry};await Mn(this.options.bus,{executionAttemptId:n,executionId:t,result:o},{retry:e})}catch(e){e instanceof W?console.error(`[PiscinaThinWorkflowProvider] Outcome rejected for execution '${t}' attempt '${n}' (decision=${e.decision}):`,e):console.error(`[PiscinaThinWorkflowProvider] Failed to submit outcome for execution '${t}' attempt '${n}':`,e),i(`Piscina worker for attempt '${n}' ended without an acknowledged outcome because outcome submission could not be completed`),a(Ln);return}a(In)}buildAllocationRef(e){let t={version:ce,providerId:this.id,providerData:{executionAttemptId:e,allocatedAt:Date.now()}};return le.parse(t)}};function Hn(e){return async(t,n)=>{n.throwIfAborted();let r=await e({executionId:t.executionId,executionAttemptId:t.executionAttemptId});if(n.throwIfAborted(),r===null)throw Error(`Workflow launch instruction is unavailable for execution '${t.executionId}' attempt '${t.executionAttemptId}'`);let i=F(r);if(i.executionId!==t.executionId)throw Error(`Workflow instruction execution '${i.executionId}' does not match Worker request '${t.executionId}'`);return me.parse({source:i.source,...i.definitionSnapshot===void 0?{}:{definition:i.definitionSnapshot},executionId:i.executionId,executionAttemptId:t.executionAttemptId,workflowId:i.workflowId,triggerPayload:i.triggerPayload,...i.triggerMode===void 0?{}:{triggerMode:i.triggerMode},inputs:i.inputs,...i.config===void 0?{}:{config:i.config},...i.artifactRef===void 0?{}:{artifactRef:i.artifactRef},scope:i.scope,...t.connection.busUrl===void 0?{}:{busUrl:t.connection.busUrl},busAuth:t.connection.busAuth,...t.connection.env===void 0?{}:{env:t.connection.env},coordinatorSessionId:i.coordinatorSessionId,cancelSubject:i.cancelSubject,suspensionStrategy:t.runtimeInputs.suspensionStrategy,terminalAuthority:i.terminalAuthority,...i.materializationSpec===void 0?{}:{materializationSpec:i.materializationSpec}})}}const Un=[He,ze,Ve];function Wn(e){let t;return()=>(t??=(async()=>{let t=[];for(let n of[...e].reverse())try{await n()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Isolated workflow runtime shutdown reported errors`)})(),t)}function Gn(e,t,n){return lt({bus:e,currentMachineId:n,resolveLiveAdapterId:e=>t.getExtensionService(P)?.resolveLiveAdapterId(e),resolveLiveAdapterIdentity:e=>t.getExtensionService(P)?.resolveLiveAdapterIdentity(e),listLiveAdapterIdentities:()=>t.getExtensionService(P)?.getLiveAdapterIdentities()??[]})}async function Kn(e){let t=ye();t.registerNamespaces([...ie,...ae]);let{context:n}=e,r=new Ce(t,{surface:`headless`,extensionContextBase:{cwd:n.cwd,platform:n.platform,homedir:n.homedir,makaioHome:n.makaioHome,username:n.username,machineId:n.machineId,tryImport:dt,credentials:new z}}),i,a=[()=>t.disconnect()],o=Wn(a);try{await e.connectAuthority(t);let s=[...e.contributedPackages,...await e.loadContributedPackages?.(t)??[]],{adapterSubsystemPackage:c}=ct({coordinator:r,configRepository:e.configRepository,platformDefaults:{cwd:n.cwd},runtimeSnapshotHandlerPriority:1,runtimeDefinitionHandlerPriority:1,...e.prepareAuthRuntime!==void 0&&{prepareAuthRuntime:e.prepareAuthRuntime}}),l=Ge({definitions:s.flatMap(e=>e.clients??[]),binaryResolutionPolicy:`global-only`});r.registerContributionProcessor(Le());let u=[...Un,c,Fe,...$t(s)?[Be]:[],Ie(1),Ue,bt,l,...Ye(s)],d=r.load(u);a.push(...tn(d,t,r)),a.push(()=>r.shutdown()),await r.startAll(),i=Gn(t,r,n.machineId),a.push(()=>{i?.cleanup(),i=void 0});let f=r.getExtensionService(Pe);if(f===void 0)throw Error(`Isolated workflow tool registry did not start.`);for(let t of e.toolsets)await f.register(t);return await t.emit(we.ready,{machineId:n.machineId}),{bus:t,coordinator:r,machineId:n.machineId,shutdown:o}}catch(e){throw await o().catch(()=>void 0),e}}function qn(e){return Number.isInteger(e)&&e>=1&&e<=2147483647}function J(e,t){try{return process.kill(-e,t),`signalled`}catch(e){if(e.code!==`ESRCH`)throw e;return`absent`}}function Jn(e){return typeof e==`object`&&!!e&&e.code===`ENOENT`}async function Yn(e,t,n){try{process.kill(-e,0)}catch(e){if(e.code===`ESRCH`)return{alive:!1};if(e.code!==`EPERM`)throw e}if(n)return{alive:!0};let r;try{r=await Xn(t)}catch(e){return Jn(e)?{alive:!0,psMissing:!0}:{alive:!0}}let i=!1;for(let t of r.trim().split(`
3
+ `)){let[n,r,a]=t.trim().split(/\s+/);if(n===``||r===void 0||a!==void 0||!/^\d+$/.test(n)||r===``||Number(n)===e&&(i=!0,!r.startsWith(`Z`)))return{alive:!0}}return i?{alive:!1}:{alive:!0}}function Xn(e){return new Promise((t,n)=>{h(`ps`,[`-A`,`-o`,`pgid=,stat=`],{timeout:e,maxBuffer:1024*1024},(e,r)=>{if(e!==null){n(e);return}t(r)})})}async function Zn(e){if(e===void 0)return{quiesced:!0,signalledLiveGroup:!1};let t=!1;try{try{t=J(e,`SIGKILL`)===`signalled`}catch(e){if(e.code!==`EPERM`)throw e}let n=Date.now()+2e3,r=!1;for(;Date.now()<n;){let i=n-Date.now();if(i<=0)break;let a=await Yn(e,Math.min(1e3,i),r);if(!a.alive)return{quiesced:!0,signalledLiveGroup:t};r||=a.psMissing===!0,await ot(20)}return{quiesced:!1,cause:r?`ps-unavailable`:`poll-timeout`,signalledLiveGroup:t}}catch{return{quiesced:!1,cause:`signal-error`,signalledLiveGroup:t}}}function Qn(e,t,n){let r=new Date;return n.quiesced?t||n.signalledLiveGroup?{pid:e,outcome:`signalled-and-quiesced`,observedAt:r}:{pid:e,outcome:`exited`,observedAt:r}:{pid:e,outcome:t||n.signalledLiveGroup?`signalled-unconfirmed`:`unsignalled-unconfirmed`,cause:n.cause,observedAt:r}}async function $n(e){if(e.signal?.aborted)return{status:`cancelled`,exitCode:null};if(!qn(e.recipe.timeoutMs))return{status:`spawn-failed`,exitCode:null,message:`Setup timeout must be an integer between 1 and 2147483647 milliseconds`};if(process.platform===`win32`)return{status:`spawn-failed`,exitCode:null,message:`Setup process groups require a POSIX host`};try{return await er(e)}catch{return{status:`spawn-failed`,exitCode:null,message:`Could not start the setup command`}}}function er(e){return new Promise(t=>{let n=g(e.recipe.command,e.recipe.args,{cwd:e.workspaceRoot,env:{...process.env,...e.recipe.env,...e.env},shell:!1,detached:!0,stdio:`ignore`}),r,i,a=!1,o=e=>{if(r===void 0&&(r=e,n.pid!==void 0)){try{J(n.pid,`SIGTERM`)===`signalled`&&(a=!0)}catch(e){if(e.code!==`EPERM`){r=`stop-failed`;return}}i=setTimeout(()=>{try{n.pid!==void 0&&J(n.pid,`SIGKILL`)===`signalled`&&(a=!0)}catch(e){e.code!==`EPERM`&&(r=`stop-failed`)}},200)}},s=()=>o(`cancelled`),c=setTimeout(()=>o(`timed-out`),e.recipe.timeoutMs);e.signal?.addEventListener(`abort`,s,{once:!0}),e.signal?.aborted&&s(),n.once(`error`,()=>{r=`spawn-failed`}),n.once(`close`,o=>{clearTimeout(c),clearTimeout(i),e.signal?.removeEventListener(`abort`,s),Zn(n.pid).then(e=>{t({status:e.quiesced?r??(o===0?`completed`:`failed`):`stop-failed`,exitCode:o,processGroup:n.pid===void 0?void 0:Qn(n.pid,a,e)})})})})}async function tr(e,t,n){if(x.isAbsolute(t)||t.includes(`\\`)||t.split(`/`).includes(`..`))throw Error(`Source root must be workspace-relative`);let r=e;for(let i of t.split(`/`).filter(e=>e!==``&&e!==`.`))if(r=x.join(r,i),V(r,e,`Source root`),await H(r,e,`Source root`,e),n&&await v.mkdir(r).catch(e=>{if(e.code!==`EEXIST`)throw e}),!(await v.stat(r)).isDirectory())throw Error(`Source root must be a directory`);return H(r,e,`Source root`,e)}async function nr(e){e.signal?.throwIfAborted();let{requirement:t}=e,n=x.resolve(e.workspaceRoot);if(!x.isAbsolute(e.workspaceRoot)||n===x.parse(n).root)throw Error(`Workspace root must be an absolute, non-filesystem-root directory`);if(t.sourceRoots.length>1)throw Error(`Multiple source roots are not implemented`);if(t.sourceRoots.some(e=>e.source!==void 0)){if(e.realizeSource===void 0)throw Error(`Source acquisition requires an installed strategy`);if(t.provisioning!==`create`||t.custody!==`disposable`)throw Error(`Source acquisition currently requires a created disposable workspace`)}if(t.provisioning===`create`&&await v.mkdir(n),!(await v.lstat(n)).isDirectory())throw Error(`Workspace root must be a directory, not a symlink`);let r=await v.realpath(n),i=[];for(let n of t.sourceRoots){let a=await tr(r,n.path,t.provisioning===`create`);n.source!==void 0&&(await e.realizeSource({source:n.source,destination:a,signal:e.signal}),e.signal?.throwIfAborted()),i.push({id:n.id,path:a})}return rr(t,{workspaceRoot:r,sourceRoots:i})}function rr(e,t){let n=t.workspaceRoot,r=e.custody,i=!1,a=!0,o;return{binding:t,async runSetup(t={}){if(o!==void 0||i||!a)throw Error(`Workspace setup is unavailable`);if(t.signal?.aborted)return{status:`cancelled`,exitCode:null};i=!0;try{let r;for(let[i,o]of e.setup.entries()){let e=await $n({...t,recipe:o,workspaceRoot:n});if(r=e,a=e.status!==`stop-failed`,e.status!==`completed`)return{...e,commandIndex:i}}let i=r?.processGroup;return i===void 0?{status:`completed`,exitCode:0}:{status:`completed`,exitCode:0,processGroup:i}}finally{i=!1}},release(){return i||!a?Promise.reject(Error(`Workspace commands have not stopped`)):(o??=r===`external`?Promise.resolve():v.rm(n,{recursive:!0,force:!0}),o)}}}function Y(e,t){return e instanceof _e?be(e,t):t?.aborted===!0?e===t.reason||e instanceof DOMException&&e.name===`AbortError`?!0:e instanceof Error&&e.name===`AbortError`&&`code`in e&&e.code===`ABORT_ERR`&&Object.is(e.cause,t.reason):!1}function X(e){return(e instanceof Error?e.message:String(e)).slice(0,8192)||`Local execution failed without a diagnostic message`}function ir(e){if(e.status!==`completed`)return e.status===`cancelled`?{kind:`cancelled`}:e.status===`stop-failed`?{kind:`technical-failure`,stage:`workspace-preparation`,message:`Workspace setup stop-failed`}:{kind:`technical-failure`,stage:`workspace-preparation`,message:`Workspace setup ${e.status}`}}function ar(e,t){return Y(e,t)?{kind:`cancelled`}:{kind:`technical-failure`,stage:`workspace-preparation`,message:X(e)}}async function or(e,t,n,r){let i=k[`instruction.get`].response.parse(await e.request(A.instruction.get,{executionAttemptId:t,runtimeGeneration:n},{signal:r}));if(i.decision===`found`)return i.instruction;throw Error(`Attempt instruction read refused: ${i.refusalReason}`)}async function sr(e,t,n,r){let{executionAttemptId:i,runtimeGeneration:a}=t;t.control?.admissionPending();let o=k[`operation.admit`].response.parse(await K(async t=>await e.request(A.operation.admit,{executionAttemptId:i,runtimeGeneration:a,operationKind:n,admissionKey:r},{timeout:t}),{retry:t.retry,reconnect:t.reconnect}));if(o.decision===`refused`)throw t.control?.admissionSettled(o.refusalReason),new l(t.executionAttemptId,r,o.refusalReason);if(o.operationId===void 0)throw Error(`Attempt ${n} admission decision '${o.decision}' named no operation (executionAttemptId=${i}, admissionKey=${r})`);return t.control?.operationAdmitted(n,o.operationId),o.operationId}async function cr(e,t,n){try{return{operationId:await sr(e,t,n.operationKind,n.admissionKey)}}catch(r){if(!(r instanceof l&&r.refusalReason===`gate-closed`&&n.signal.aborted))throw r;return await Z(e,t,n.instruction,{kind:`cancelled`},void 0,n.workspace)}}function lr(e,t){return e.find(e=>e.kind===t.workload.kind&&e.version===t.workload.version)}function ur(e){return{signal:e??new AbortController().signal,release:()=>{}}}async function Z(e,t,n,r,i,a){i!==void 0&&t.control?.operationConcluded(i);let o=await Nn(e,{executionAttemptId:t.executionAttemptId,runtimeGeneration:t.runtimeGeneration,...i===void 0?{}:{operationId:i.operationId},outcome:r},{retry:t.retry,reconnect:t.reconnect});if(a!==void 0&&n!==void 0&&r.kind===`workload-result`&&n.preservation.required.length===0)try{await a.release()}catch{console.warn(`[makaio-worker] Acknowledged workspace cleanup failed.`)}return{outcome:r,decision:o}}async function dr(e,t,n,r){let i=k[`operation.report`].response.parse(await K(async i=>await e.request(A.operation.report,{executionAttemptId:t.executionAttemptId,runtimeGeneration:t.runtimeGeneration,operationId:n,result:{kind:`workspace-prepared`,binding:r.binding}},{timeout:i}),{retry:t.retry,reconnect:t.reconnect}));return i.decision===`refused`?void 0:i.binding}async function fr(e,t,n,r){if(r.aborted)return await Z(e,t,n,{kind:`cancelled`},void 0,void 0);let i=await cr(e,t,{operationKind:`workspace-preparation`,admissionKey:`workspace-preparation:${n.id}:${t.runtimeGeneration}`,signal:r,instruction:n});if(`outcome`in i)return i;let a=i.operationId;if(r.aborted)return await Z(e,t,n,{kind:`cancelled`},Q(a,`not-started`),void 0);let o,s,c=!1;try{if(t.workspaceRoot===void 0)throw Error(`Workspace preparation requires an explicit local root`);let e=await(t.preparation??{prepare:nr}).prepare({requirement:n.workspace,workspaceRoot:t.workspaceRoot,signal:r});o=e,c=!0,s=await e.runSetup({signal:r,env:t.setupEnv})}catch(i){return await Z(e,t,n,ar(i,r),Q(a,c?`no-observation`:`not-started`),o)}let l=Q(a,s.processGroup??`no-spawn`);t.control?.operationConcluded(l);let u=ir(s);if(u!==void 0)return await Z(e,t,n,u,l,o);if(r.aborted)return await Z(e,t,n,{kind:`cancelled`},l,o);let d=await dr(e,t,a,o);return d===void 0?await Z(e,t,n,{kind:`technical-failure`,stage:`workspace-preparation`,message:`Workspace preparation report refused by the Authority`},l,o):r.aborted?await Z(e,t,n,{kind:`cancelled`},void 0,o):{handle:o,binding:d}}function Q(e,t){return{kind:`workspace-preparation`,operationId:e,setup:t}}async function pr(e,t,n,r,i){if(i.signal.aborted)return await Z(e,t,n,{kind:`cancelled`},void 0,void 0);let a,o;if(n.workspace!==void 0){let r=await fr(e,t,n,i.signal);if(`outcome`in r)return r;a=r.handle,o=r.binding}if(i.signal.aborted)return await Z(e,t,n,{kind:`cancelled`},void 0,a);let s=await cr(e,t,{operationKind:`workload-invocation`,admissionKey:`workload-invocation:${n.id}:${t.runtimeGeneration}`,signal:i.signal,instruction:n,...a===void 0?{}:{workspace:a}});if(`outcome`in s)return s;let c={kind:`workload-invocation`,operationId:s.operationId};if(i.signal.aborted)return await Z(e,t,n,{kind:`cancelled`},c,a);let l;try{l={kind:`workload-result`,result:oe.parse(await r.invoke({instruction:n,...o===void 0?{}:{workspace:o},signal:i.signal}))}}catch(e){l=Y(e,i.signal)?{kind:`cancelled`}:{kind:`technical-failure`,stage:`workload-invocation`,message:X(e)}}return await Z(e,t,n,l,c,a)}async function mr(e,t){let n;try{n=await or(e,t.executionAttemptId,t.runtimeGeneration,t.signal)}catch(n){if(be(n,t.signal))return await Z(e,t,void 0,{kind:`cancelled`},void 0,void 0);throw n}let r=lr(t.adapters,n);if(r===void 0)return await Z(e,t,n,{kind:`technical-failure`,stage:`startup`,message:`Required adapter '${n.workload.kind}' version '${n.workload.version}' is unavailable`},void 0,void 0);let i;try{i=await(r.bindControl?.({instruction:n,signal:t.signal})??ur(t.signal))}catch(r){let i=Y(r,t.signal)?{kind:`cancelled`}:{kind:`technical-failure`,stage:`startup`,message:X(r)};return await Z(e,t,n,i,void 0,void 0)}try{return await pr(e,t,n,r,i)}finally{try{i.release()}catch{console.warn(`[makaio-worker] Workload control release failed.`)}}}const hr={exited:`setup process group leader exited; whole group proven quiescent`,"signalled-and-quiesced":`setup process group signalled; group proven quiescent afterwards`,"signalled-unconfirmed":`setup process group signalled; quiescence not proven`,"unsignalled-unconfirmed":`setup process group could not be signalled; quiescence not proven`},gr={"poll-timeout":`quiescence poll timed out`,"ps-unavailable":`ps unavailable on this host`,"signal-error":`a cleanup signal failed`};function _r(e){let t=hr[e.outcome];return e.cause===void 0?t:`${t} (${gr[e.cause]})`}function $(e){return{...e.operationId===void 0?{}:{operationId:e.operationId},conclusion:{status:e.status,boundary:e.boundary,evidence:{source:e.source,summary:e.summary,observedAt:e.observedAt.toISOString(),...e.code===void 0?{}:{code:e.code}}}}}function vr(e,t){if(!e.cancelReceived||e.admissionPending)return`pending`;let n=e.admittedOperation;if(n===null)return!e.admissionSettled&&!e.finished?`pending`:$({status:`achieved`,boundary:`admission-closed`,source:`headless-runtime`,summary:yr(e.admissionRefusalReason),observedAt:t});if(n.kind===`workload-invocation`)return $({operationId:n.operationId,status:`unsupported`,boundary:`workload`,source:`headless-runtime`,summary:`generic workload adapter offers no stop evidence`,observedAt:t});let r=e.conclusion;return r===null||r.kind!==`workspace-preparation`||r.operationId!==n.operationId?`pending`:br(n.operationId,r.setup,t)}function yr(e){let t=`no mutating operation admitted before cancellation`;return e===null?t:`${t}; admission refused (${e})`}function br(e,t,n){return $(t===`not-started`?{operationId:e,status:`achieved`,boundary:`setup-process-group`,source:`headless-runtime`,summary:`preparation admitted; setup never started before cancellation`,observedAt:n}:t===`no-spawn`?{operationId:e,status:`achieved`,boundary:`setup-process-group`,source:`setup-driver`,summary:`no live setup process group remains under this operation`,observedAt:n}:t===`no-observation`?{operationId:e,status:`unsupported`,boundary:`setup-process-group`,source:`setup-driver`,summary:`setup driver supplied no process-group observation`,observedAt:n}:{operationId:e,status:t.outcome===`signalled-unconfirmed`||t.outcome===`unsignalled-unconfirmed`?`unconfirmed`:`achieved`,boundary:`setup-process-group`,source:`setup-driver`,summary:_r(t),observedAt:t.observedAt,code:t.outcome})}var xr=class{state={cancelReceived:!1,admissionPending:!1,admissionSettled:!1,admissionRefusalReason:null,admittedOperation:null,conclusion:null,finished:!1};onUpdate;constructor(e){this.onUpdate=e}markCancelReceived(){this.state.cancelReceived=!0,this.onUpdate()}admissionPending(){this.state.admissionPending=!0,this.onUpdate()}admissionSettled(e){this.state.admissionPending=!1,this.state.admissionSettled=!0,e!==void 0&&(this.state.admissionRefusalReason=e),this.onUpdate()}operationAdmitted(e,t){this.state.admissionPending=!1,this.state.admittedOperation={kind:e,operationId:t},this.onUpdate()}operationConcluded(e){this.state.conclusion=e,this.onUpdate()}finished(){this.state.finished=!0,this.onUpdate()}snapshot(){return{...this.state}}};function Sr(e){return!e.reportPending&&(e.lastReportStatus===void 0||e.lastReportStatus===`error`)}function Cr(e,t){return{executionAttemptId:e.executionAttemptId,runtimeIncarnationId:e.runtimeIncarnationId,runtimeGeneration:e.runtimeGeneration,controlRevision:e.cancellation.controlRevision,requestKey:e.cancellation.requestKey,receivedAt:t.toISOString()}}async function wr(e,t,n,r,i){let a={executionAttemptId:t.executionAttemptId,runtimeIncarnationId:t.runtimeIncarnationId,runtimeGeneration:t.runtimeGeneration,controlRevision:t.controlRevision,requestKey:t.requestKey,...n.operationId===void 0?{}:{operationId:n.operationId},conclusion:n.conclusion};try{let t=await K((t,n)=>e.request(A.control.report,a,{timeout:t,signal:n}),i===void 0?r:{...r,signal:i}),n=k[`control.report`].response.parse(t);return n.decision===`accepted`||n.decision===`duplicate`?{status:n.decision,response:n}:{status:`refused`,response:n}}catch(e){return{status:`error`,error:e}}}function Tr(e,t,n){let r=new Set,i;return{dispatch(a,o,s){if(n?.aborted===!0)return!1;let c=wr(e,a,o,t,n).then(e=>{i=e,r.delete(c),s(e)});return r.add(c),!0},async settle(){for(await new Promise(e=>setImmediate(e));r.size>0;)await Promise.allSettled([...r])},get lastReport(){return i}}}async function Er(e,t,n={}){let r=n.now??(()=>new Date),i=new Map,a=new AbortController,o=Tr(e,n.reportOptions,n.reportSignal);function s(e){if(!Sr(e))return;let t=vr(u.snapshot(),r());t!==`pending`&&o.dispatch(e.receipt,t,t=>{e.reportPending=!1,e.lastReportStatus=t.status})&&(e.reportPending=!0)}function l(e){let{controlRevision:t}=e.cancellation,n=i.get(t);if(n!==void 0)return setImmediate(()=>s(n)),n.receipt;let o={receipt:Cr(e,r()),reportPending:!1,lastReportStatus:void 0};return i.set(t,o),setImmediate(()=>{a.abort(),u.markCancelReceived(),s(o)}),o.receipt}let u=new xr(()=>{for(let e of i.values())s(e)}),d=await c(e,t,e=>e.bus.on(A.control.deliver,async t=>{let n=k[`control.deliver`].request.safeParse(t.payload);if(!n.success){t.setResult({decision:`refused`,reason:`unsupported`});return}let r=n.data,i=e.acceptedGeneration??await e.awaitGeneration();if(i===void 0||r.runtimeGeneration!==i){t.setResult({decision:`refused`,reason:`stale-generation`});return}t.setResult({decision:`received`,receipt:l(r)})}),n.signal);return{bindGeneration:e=>d.bindGeneration(e),cleanup:()=>d.cleanup(),signal:a.signal,observer:u,settle:()=>o.settle(),get lastReport(){return o.lastReport}}}async function Dr(e,t){t.throwIfAborted();let n=T(),r=await f(e.bootstrapDeadlineAt,t,t=>e.bootstrap(t)),{connection:i,endpoint:a}=await s({executionAttemptId:e.executionAttemptId,runtimeIncarnationId:n,bootstrapDeadlineAt:e.bootstrapDeadlineAt,signal:t,createConnection:()=>Or(e,r)}),c=i.bus,l=new AbortController,u,d;try{d=await Er(c,{executionAttemptId:e.executionAttemptId,runtimeIncarnationId:n},{reportOptions:{retry:e.outcomeRetry,reconnect:()=>c.reconnect()},reportSignal:l.signal,signal:t});let r=await o(c,{executionAttemptId:e.executionAttemptId,runtimeIncarnationId:n,signal:t});return a.bindGeneration(r),d.bindGeneration(r),u=await mr(c,{executionAttemptId:e.executionAttemptId,runtimeGeneration:r,workspaceRoot:e.workspaceRoot,setupEnv:e.setupEnv,preparation:e.preparation,adapters:e.adapters,signal:AbortSignal.any([t,d.signal]),control:d.observer,retry:e.outcomeRetry,reconnect:()=>c.reconnect()}),u}finally{try{d?.observer.finished(),d?.cleanup();let e,t=setTimeout(()=>{l.abort(),e=Promise.resolve(i.close()),e.catch(()=>{})},5e3);try{await d?.settle()}finally{clearTimeout(t)}a.cleanup(),await(e??i.close())}catch{}}}function Or(e,t){let n=ye();return n.registerNamespaces([...ie,...ae]),{bus:n,async connect(r){try{await e.connectBus(n,t,r),r.throwIfAborted()}catch(e){throw n.disconnect(),e}},close:()=>n.disconnect()}}async function kr(e,t,n,r,i){let a=de[`runtime.inputs.get`].response.parse(await e.request(M.runtime.inputs.get,{executionAttemptId:t},{signal:i}));if(a.runtimeInputs===null)throw Error(`Selected Worker Runtime inputs are unavailable`);return fe.parse({...n,...a.runtimeInputs,createdAt:0,env:r})}function Ar(e,t){let n=(e,t)=>{let n=te(e,t);return n===``||!S(n)&&n!==`..`&&!n.startsWith(`../`)&&!n.startsWith(`..\\`)};return n(e,t)||n(t,e)}async function jr(e,t,n,i){let a=await e.loadContributions(n,i);i.throwIfAborted();let o=r();return await Kn({connectAuthority:n=>e.connectBus(n,t,i),contributedPackages:[...a],configRepository:e.configRepository,context:{cwd:n.workspaceRoot,platform:n.platform,homedir:o,makaioHome:o,username:`workflow-worker`,machineId:`headless-worker-${e.executionAttemptId}`},toolsets:[...e.toolsets],...e.prepareAuthRuntime!==void 0&&{prepareAuthRuntime:e.prepareAuthRuntime}})}function Mr(e,t,n){let r={...e.workflowEnv},i,a=!0;return{adapter:{kind:$e,version:et,async bindControl({instruction:t,signal:r}){let i=F(t);if(i.executionId!==e.executionId)throw Error(`Workflow instruction execution identity mismatch`);let a=new AbortController,o=n.on(he(i.cancelSubject),()=>a.abort());try{return await Se(o),{signal:AbortSignal.any([...r===void 0?[]:[r],a.signal]),release:o}}catch(e){throw o(),e}},async invoke({instruction:o,workspace:s,signal:c}){let l=F(o);a=o.preservation.required.length!==0;let u=c??new AbortController().signal,d;try{u.throwIfAborted();let a=await kr(n,e.executionAttemptId,l,r,u),o=await e.materialize(a,u);(s===void 0||!Ar(o.context.workspaceRoot,s.workspaceRoot))&&(i=o.cleanup);let c=Nr(o.context,s);return u.throwIfAborted(),d=await jr(e,t,c,u),u.throwIfAborted(),await e.execute(d.bus,a,c,u)}finally{await d?.shutdown()}}},async releaseExecutable(e){e===void 0||a||e.outcome.kind===`workload-result`&&(e.decision!==`accepted`&&e.decision!==`duplicate`||await i?.().catch(()=>void 0))}}}function Nr(e,t){return t===void 0?e:{...e,workspaceRoot:t.workspaceRoot}}async function Pr(e,t){if(!(t.outcome.kind!==`workload-result`||e.onPostCommit===void 0))try{let n=pe.parse(t.outcome.result);await e.onPostCommit(n,t.decision)}catch{}}async function Fr(e,t){t.throwIfAborted();let n={...e.workflowEnv},r,i,a,o,s=async(t,n,a)=>{r=t,i=n,await e.connectBus(t,n,a)},c={kind:$e,version:et,async bindControl(t){if(r===void 0||i===void 0)throw Error(`Bus not yet connected when adapter control was bound`);return a=Mr({...e,workflowEnv:n},i,r),a.adapter.bindControl(t)},async invoke(e){if(a===void 0)throw Error(`Workflow adapter was not initialized via bindControl`);return a.adapter.invoke(e)}};try{return o=await Dr({executionId:e.executionId,executionAttemptId:e.executionAttemptId,bootstrapDeadlineAt:e.bootstrapDeadlineAt,workflowEnv:e.workflowEnv,setupEnv:e.setupEnv,bootstrap:e.bootstrap,connectBus:s,workspaceRoot:e.workspaceRoot,preparation:e.preparation,adapters:[c],outcomeRetry:e.outcomeRetry},t),await Pr(e,o),o}finally{await a?.releaseExecutable(o)}}const Ir=_(h),Lr=[`-c`,`core.attributesFile=${N}`],Rr=m.object({repositoryId:m.string().min(1),revision:m.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i,`Git source revision must be a full commit object ID`)}).strict();async function zr(e,t,n){try{let r=await e.resolveRepository(t,n);if(!x.isAbsolute(r))throw Error(`Repository access did not return an absolute path`);return await v.realpath(r)}catch(e){throw Y(e,n)?e:Error(`Git source access failed`)}}async function Br(e,t,n,r,i){let a;try{a=(await Ir(`git`,[...Lr,`cat-file`,`-t`,t],{cwd:e,env:{...process.env,...n},signal:i,timeout:r,maxBuffer:1024,shell:!1,killSignal:`SIGKILL`,encoding:`utf8`})).stdout.trim()}catch(e){throw Y(e,i)?e:Error(`Git source object inspection failed`)}if(a!==`commit`)throw Error(`Git source revision must identify a commit object`)}function Vr(e){if(!qn(e.timeoutMs))throw Error(`Git command timeout must be an integer between 1 and 2147483647 milliseconds`);if(process.platform===`win32`)throw Error(`Local Git source preparation requires a POSIX host`);return async({source:t,destination:n,signal:r})=>{if(r?.throwIfAborted(),t.kind!==`git`)throw Error(`Unsupported local Git source kind`);let i=Rr.parse(t.input),a=await zr(e,i.repositoryId,r);r?.throwIfAborted();let o={...Object.fromEntries(Object.keys(process.env).filter(e=>/^git_/i.test(e)).map(e=>[e,void 0])),GIT_CONFIG_GLOBAL:N,GIT_CONFIG_SYSTEM:N,GIT_ATTR_NOSYSTEM:`1`},s=[[`init`,`--object-format=${i.revision.length===64?`sha256`:`sha1`}`],[`fetch`,`--no-tags`,`--no-write-fetch-head`,`--update-shallow`,`--`,a,i.revision],[`checkout`,`--detach`,i.revision,`--`]];for(let t of s){t[0]===`checkout`&&await Br(n,i.revision,o,e.timeoutMs,r);let a=await $n({workspaceRoot:n,signal:r,env:o,recipe:{command:`git`,args:[...Lr,...t],env:{},timeoutMs:e.timeoutMs}});if(a.status===`cancelled`&&r?.throwIfAborted(),a.status!==`completed`)throw Error(`Git source ${t[0]} ${a.status}`)}}}function Hr(e){let t=Vr(e);return{prepare:e=>nr({...e,realizeSource:t})}}export{z as A,Zt as B,H as C,gn as D,cn as E,Gt as F,zt as G,It as H,nn as I,ut as J,Rt as K,tn as L,Wt as M,Ht as N,sn as O,Xt as P,st as Q,Kt as R,V as S,mn as T,Lt as U,en as V,I as W,lt as X,dt as Y,ct as Z,bn as _,mr as a,_n as b,Vn as c,wn as d,W as f,Sn as g,Cn as h,Er as i,an as j,hn as k,G as l,Mn as m,Fr as n,Kn as o,Nn as p,bt as q,Dr as r,Hn as s,Hr as t,Tn as u,yn as v,pn as w,B as x,vn as y,qt as z};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makaio/framework",
3
- "version": "1.0.0-dev-1789609124644",
3
+ "version": "1.0.0-dev-1790066089222",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/makaio-ai/makaio-framework.git",
@@ -140,6 +140,10 @@
140
140
  "types": "./dist/contracts/capabilities/index.d.mts",
141
141
  "default": "./dist/contracts/capabilities/index.mjs"
142
142
  },
143
+ "./contracts/context-projection": {
144
+ "types": "./dist/contracts/context-projection/index.d.mts",
145
+ "default": "./dist/contracts/context-projection/index.mjs"
146
+ },
143
147
  "./contracts/extension": {
144
148
  "types": "./dist/contracts/extension/index.d.mts",
145
149
  "default": "./dist/contracts/extension/index.mjs"
@@ -252,6 +256,10 @@
252
256
  "types": "./dist/services/code-execution/index.d.mts",
253
257
  "default": "./dist/services/code-execution/index.mjs"
254
258
  },
259
+ "./services/context-projection": {
260
+ "types": "./dist/services/context-projection/index.d.mts",
261
+ "default": "./dist/services/context-projection/index.mjs"
262
+ },
255
263
  "./services/materialization": {
256
264
  "types": "./dist/services/materialization/index.d.mts",
257
265
  "default": "./dist/services/materialization/index.mjs"