@makaio/framework 1.0.0-dev-1788832451167 → 1.0.0-dev-1788897280508
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.
- package/dist/.makaio-build.json +2 -2
- package/dist/{account-identity-B3vLwm9O.mjs → account-identity-DCBpVurJ.mjs} +1 -1
- package/dist/{adapter-Dz1fX5Wa.mjs → adapter-D6IpEDIo.mjs} +1 -1
- package/dist/adapters/config/index.d.mts +1 -1
- package/dist/adapters/config/index.mjs +1 -1
- package/dist/adapters/index.d.mts +2 -2
- package/dist/adapters/index.mjs +1 -1
- package/dist/adapters/node.d.mts +1 -1
- package/dist/adapters/node.mjs +1 -1
- package/dist/artifact-OnwP6uaD.mjs +1 -0
- package/dist/attempt-record-codec-CqKq0NIB.mjs +1 -0
- package/dist/{auth-C6tVtaOX.mjs → auth-CeH3w2fi.mjs} +1 -1
- package/dist/authority-state-bootstrap-rnsTk0u7.mjs +1 -0
- package/dist/{automation-trigger-ByjNlClm.mjs → automation-trigger-D_xKqEoV.mjs} +1 -1
- package/dist/bus/index.mjs +1 -1
- package/dist/{caller-owned-adapter-stub-C1M7FKrv.mjs → caller-owned-adapter-stub-egWCuKcE.mjs} +1 -1
- package/dist/{canonical-model-DXOvCaVg.mjs → canonical-model-DwuFQ02A.mjs} +1 -1
- package/dist/{capabilities-DEvmD9VJ.mjs → capabilities-DGqMG9M3.mjs} +1 -1
- package/dist/{client-BkznbdsO.mjs → client-CTqzLpVx.mjs} +1 -1
- package/dist/clients/index.d.mts +1 -1
- package/dist/clients/index.mjs +1 -1
- package/dist/clients/managed-install.d.mts +1 -1
- package/dist/clients/managed-install.mjs +1 -1
- package/dist/code-execution/worker-entry.d.mts +1 -1
- package/dist/code-execution/worker-entry.mjs +1 -1
- package/dist/{code-execution-Ckmn8OZu.mjs → code-execution-BMmUATcc.mjs} +1 -1
- package/dist/{code-execution-CweDSWco.mjs → code-execution-C2PgBdmE.mjs} +1 -1
- package/dist/{code-execution-DqkQjKa1.mjs → code-execution-Mo1jztUH.mjs} +1 -1
- package/dist/{compression-CtgeVLpP.mjs → compression-3DauETKU.mjs} +1 -1
- package/dist/{config-namespace-CjWvw8ij.mjs → config-namespace-MjFuIPyL.mjs} +1 -1
- package/dist/contracts/adapter/index.d.mts +2 -2
- package/dist/contracts/adapter/index.mjs +1 -1
- package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
- package/dist/contracts/artifact/index.d.mts +3 -3
- package/dist/contracts/artifact/index.mjs +1 -1
- package/dist/contracts/auth/index.d.mts +2 -2
- package/dist/contracts/auth/index.mjs +1 -1
- package/dist/contracts/automation-trigger/index.d.mts +3 -3
- package/dist/contracts/automation-trigger/index.mjs +1 -1
- package/dist/contracts/canonical-model/index.d.mts +1 -1
- package/dist/contracts/canonical-model/index.mjs +1 -1
- package/dist/contracts/capabilities/index.d.mts +1 -1
- package/dist/contracts/capabilities/index.mjs +1 -1
- package/dist/contracts/client/index.d.mts +2 -2
- package/dist/contracts/client/index.mjs +1 -1
- package/dist/contracts/code-execution/index.d.mts +1 -1
- package/dist/contracts/code-execution/index.mjs +1 -1
- package/dist/contracts/common/index.d.mts +1 -1
- package/dist/contracts/config/index.d.mts +1 -1
- package/dist/contracts/config/index.mjs +1 -1
- package/dist/contracts/extension/index.d.mts +5 -5
- package/dist/contracts/extension/index.mjs +1 -1
- package/dist/contracts/facet/index.d.mts +1 -1
- package/dist/contracts/facet/index.mjs +1 -1
- package/dist/contracts/harness/index.d.mts +1 -1
- package/dist/contracts/harness/index.mjs +1 -1
- package/dist/contracts/host/index.d.mts +1 -1
- package/dist/contracts/host/index.mjs +1 -1
- package/dist/contracts/index.d.mts +102 -102
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/materialization/index.d.mts +2 -3
- package/dist/contracts/materialization/index.mjs +1 -1
- package/dist/contracts/model-registry/index.d.mts +1 -1
- package/dist/contracts/model-registry/index.mjs +1 -1
- package/dist/contracts/native-session-supervisor/index.d.mts +1 -1
- package/dist/contracts/native-session-supervisor/index.mjs +1 -1
- package/dist/contracts/platform/index.d.mts +1 -1
- package/dist/contracts/platform/index.mjs +1 -1
- package/dist/contracts/provider/index.d.mts +2 -2
- package/dist/contracts/provider/index.mjs +1 -1
- package/dist/contracts/reaction/index.d.mts +1 -1
- package/dist/contracts/reaction/index.mjs +1 -1
- package/dist/contracts/session/index.d.mts +2 -2
- package/dist/contracts/session/index.mjs +1 -1
- package/dist/contracts/shared/index.d.mts +2 -2
- package/dist/contracts/shared/index.mjs +1 -1
- package/dist/contracts/skill/index.d.mts +1 -1
- package/dist/contracts/skill/index.mjs +1 -1
- package/dist/contracts/telemetry/index.d.mts +1 -1
- package/dist/contracts/telemetry/index.mjs +1 -1
- package/dist/contracts/timeout/index.d.mts +1 -1
- package/dist/contracts/timeout/index.mjs +1 -1
- package/dist/contracts/toast/index.mjs +1 -1
- package/dist/contracts/variant/index.d.mts +1 -1
- package/dist/contracts/variant/index.mjs +1 -1
- package/dist/contracts/worker/index.d.mts +1 -1
- package/dist/contracts/worker/index.mjs +1 -1
- package/dist/contracts/workflow/index.d.mts +2 -2
- package/dist/contracts/workflow/index.mjs +1 -1
- package/dist/{contribution-Crm-mctl.d.mts → contribution-BoTMoHVB.d.mts} +2 -2
- package/dist/{definition-u_5rYQtc.d.mts → definition-BgY763Q4.d.mts} +1 -1
- package/dist/{definition-BH4QLGLI.mjs → definition-YGj42UeO.mjs} +1 -1
- package/dist/{detached-extension-handle-DAXKQT9c.mjs → detached-extension-handle-B9c_6Pcb.mjs} +1 -1
- package/dist/execution-attempt-owner-recovery-BNERIDH0.mjs +1 -0
- package/dist/{execution-attempt-repository-CgB7uiYD.d.mts → execution-attempt-repository-CtFZfBfp.d.mts} +111 -3
- package/dist/{execution-target-BcoF_oDB.mjs → execution-target-CqaBmnvX.mjs} +1 -1
- package/dist/{extension-Bfkr2DBs.mjs → extension-B51JzHJu.mjs} +1 -1
- package/dist/extension-C4lFc8-j.mjs +1 -0
- package/dist/{filesystem-service-CiUw0YN5.mjs → filesystem-service-DGqU-6x-.mjs} +1 -1
- package/dist/framework-packages-CZJDukan.mjs +1 -0
- package/dist/git/index.mjs +1 -1
- package/dist/{globby-QBDqstzq.mjs → globby-BT0rrriG.mjs} +1 -1
- package/dist/{handlers-BsHAFtye.mjs → handlers-CBbFzDHc.mjs} +1 -1
- package/dist/{harness-YQ2ewID9.mjs → harness-GNtHsoh4.mjs} +1 -1
- package/dist/{hook-responses-DcapjzLb.d.mts → hook-responses-BSCAdJ3i.d.mts} +1 -1
- package/dist/{index-QJW9g1mG.d.mts → index-BVRQOZbm.d.mts} +1 -1
- package/dist/{index-LryUXslm.d.mts → index-BZlmWCcW.d.mts} +3 -3
- package/dist/{index-rygpcDBV.d.mts → index-BZtasAZP.d.mts} +1 -1
- package/dist/{index-Bsr4rZl0.d.mts → index-BdbYIlDL.d.mts} +18 -18
- package/dist/{index-BxOFB25y.d.mts → index-BkY6zO7p.d.mts} +138 -115
- package/dist/{index-DZXpKlyB.d.mts → index-CDLHgV7v.d.mts} +14 -14
- package/dist/{index-CfJKwWJa.d.mts → index-CQtttPGm.d.mts} +1 -1
- package/dist/{index-BADuMxcP.d.mts → index-CYmQt2lF.d.mts} +100 -100
- package/dist/{index-J-kv32zv.d.mts → index-CYwbfa0_.d.mts} +2 -2
- package/dist/{index-DZnb56vt2.d.mts → index-C_OLvAr_.d.mts} +1 -1
- package/dist/{index-BvgLFm-U.d.mts → index-Cau0jTTM.d.mts} +1 -1
- package/dist/{index-BwccWakG.d.mts → index-D0DfEO45.d.mts} +1 -1
- package/dist/{index-COOM1j_L2.d.mts → index-DIYgFhTZ2.d.mts} +4 -4
- package/dist/{index-LOh6AEqx.d.mts → index-DJ0Muy2s.d.mts} +4 -4
- package/dist/{index-C1PfDEIV.d.mts → index-F6hV4tWI.d.mts} +35 -35
- package/dist/{index-CiKzWCW02.d.mts → index-LwOw7ZLk2.d.mts} +19 -19
- package/dist/{index-BakMNLkB.d.mts → index-PTp68NH1.d.mts} +92 -92
- package/dist/{index-vXmPEZ5O.d.mts → index-R2BZejEz.d.mts} +591 -726
- package/dist/{index-DIhkK4Y0.d.mts → index-RpG4EP3u.d.mts} +1 -1
- package/dist/{index-Bo3LRb2u.d.mts → index-dL0Oet1j.d.mts} +1 -1
- package/dist/{index-Cbv_3Xi12.d.mts → index-mylsCg6V2.d.mts} +1 -1
- package/dist/{index-BDzqNCXs.d.mts → index-nPpqnP7P.d.mts} +1 -1
- package/dist/kernel/cli/index.d.mts +2 -2
- package/dist/kernel/cli/index.mjs +1 -1
- package/dist/kernel/cli/register.d.mts +1 -1
- package/dist/kernel/cli/register.mjs +1 -1
- package/dist/kernel/cli/schemas.mjs +1 -1
- package/dist/kernel/extension/index.d.mts +1 -1
- package/dist/kernel/extension/index.mjs +1 -1
- package/dist/kernel/index.d.mts +5 -5
- package/dist/kernel/index.mjs +1 -1
- package/dist/kernel/namespace/index.d.mts +1 -1
- package/dist/kernel/namespace/index.mjs +1 -1
- package/dist/kernel/observability/index.d.mts +1 -1
- package/dist/kernel/observability/index.mjs +1 -1
- package/dist/kernel/providers/index.d.mts +1 -1
- package/dist/kernel/providers/index.mjs +1 -1
- package/dist/kernel/window/index.d.mts +1 -1
- package/dist/kernel/window/index.mjs +1 -1
- package/dist/kind-registration-BNhVCSaT.mjs +1 -0
- package/dist/{lib-271rPR7A.mjs → lib-B8Yv4IY-.mjs} +1 -1
- package/dist/{lib-RFpLjUda.mjs → lib-hwdGyO-m.mjs} +1 -1
- package/dist/{load-extensions-D9inWcDy.mjs → load-extensions-CNT2Nd9h.mjs} +1 -1
- package/dist/{load-extensions-CY8ELnCp.d.mts → load-extensions-D0yT_Kta.d.mts} +1 -1
- package/dist/materialization-Dx1z_MDj.mjs +1 -0
- package/dist/mcp-http-server/index.mjs +1 -1
- package/dist/model-B6t_-_sp.mjs +1 -0
- package/dist/{namespace-BymM0nl_.d.mts → namespace-C7wggVcn.d.mts} +9 -9
- package/dist/namespace-D4zmxaC4.mjs +1 -0
- package/dist/{namespace-DdqVQSyc.d.mts → namespace-Dh5fTXYt.d.mts} +2 -2
- package/dist/{namespace-DlrX8feY.d.mts → namespace-WeSQXdAL.d.mts} +45 -45
- package/dist/{namespace-BL7lHlmg.mjs → namespace-ZAIFBrIy.mjs} +1 -1
- package/dist/{native-session-supervisor-LKio8XZn.mjs → native-session-supervisor-BlGzmZrH.mjs} +1 -1
- package/dist/node/bus-server/index.d.mts +1 -1
- package/dist/node/bus-server/index.mjs +1 -1
- package/dist/node/bus-server/server-lifecycle.d.mts +1 -1
- package/dist/node/bus-server/server-lifecycle.mjs +1 -1
- package/dist/{orchestrator-shared-BGlN-m-V.mjs → orchestrator-shared-BKMtjTE9.mjs} +1 -1
- package/dist/{ownership-memory-handler-BpGdR_uG.mjs → ownership-memory-handler-BCu1EjFO.mjs} +1 -1
- package/dist/{package-DkpF17X_.d.mts → package-C9XYuN9J.d.mts} +20 -6
- package/dist/{package-CzKoZ1k0.mjs → package-D7c2HC-S.mjs} +2 -2
- package/dist/{package-JtjbO-Oi.mjs → package-buHQFmTH.mjs} +1 -1
- package/dist/package.json +1 -1
- package/dist/packages-BhhBcPgz.mjs +1 -0
- package/dist/{packages-Cx-BwSZr.d.mts → packages-DAqep89i.d.mts} +12 -39
- package/dist/{profile-N5qGUpF0.mjs → profile-DBDvy9uc.mjs} +1 -1
- package/dist/{provider-context-zTDSH2x9.mjs → provider-context-CSb0qX1c.mjs} +1 -1
- package/dist/{provider-context-CG42JlP9.mjs → provider-context-CTOrOW54.mjs} +1 -1
- package/dist/{reaction-D3TNwPK8.mjs → reaction-OQibmmDW.mjs} +1 -1
- package/dist/{resolved-sq8RXNDf.mjs → resolved-ONt3rOMh.mjs} +1 -1
- package/dist/rules/index.d.mts +1 -1
- package/dist/rules/index.mjs +1 -1
- package/dist/rules/schemas.d.mts +1 -1
- package/dist/runtime-bun/index.mjs +1 -1
- package/dist/runtime-node/code-execution/index.d.mts +2 -2
- package/dist/runtime-node/code-execution/index.mjs +1 -1
- package/dist/runtime-node/extension-discovery.d.mts +1 -1
- package/dist/runtime-node/extension-validation.d.mts +1 -1
- package/dist/runtime-node/extension-validation.mjs +1 -1
- package/dist/runtime-node/index.d.mts +6 -6
- package/dist/runtime-node/index.mjs +20 -20
- package/dist/runtime-node/makaio-config.d.mts +1 -1
- package/dist/runtime-node/makaio-config.mjs +1 -1
- package/dist/runtime-node/workflow-worker/index.d.mts +2 -2
- package/dist/runtime-node/workflow-worker/index.mjs +1 -1
- package/dist/runtime-node/workflow-worker/worker-entry.mjs +1 -1
- package/dist/{schema-Dq-7si8u.mjs → schema-B8jinlbH.mjs} +1 -1
- package/dist/{schema-C9PauHXt.d.mts → schema-wArHaxA9.d.mts} +2 -2
- package/dist/{schemas-QWDnauKX.mjs → schemas-BUK9I-Oz.mjs} +1 -1
- package/dist/{schemas-BDZFd3Wb.d.mts → schemas-BjNlwTDl.d.mts} +2 -2
- package/dist/{context-resolution-BrtoXnez.d.mts → schemas-C5FreSE0.d.mts} +133 -539
- package/dist/{schemas-_2Syo_01.mjs → schemas-CSDiTBsU.mjs} +1 -1
- package/dist/{schemas-BfO5jkrL.mjs → schemas-CbhvgFQs.mjs} +1 -1
- package/dist/schemas-hzbKeyyt.mjs +1 -0
- package/dist/{selection-DL3ric7K.mjs → selection-7SkHsmWs.mjs} +1 -1
- package/dist/services/adapter-runtime/index.d.mts +3 -3
- package/dist/services/adapter-runtime/index.mjs +1 -1
- package/dist/services/adapter-runtime/namespace.d.mts +1 -1
- package/dist/services/adapter-runtime/schemas.d.mts +1 -1
- package/dist/services/adapter-subsystem/index.d.mts +3 -3
- package/dist/services/adapter-subsystem/index.mjs +1 -1
- package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
- package/dist/services/adapter-subsystem/namespace.mjs +1 -1
- package/dist/services/agent-runtime/index.d.mts +2 -2
- package/dist/services/agent-runtime/namespace.d.mts +1 -1
- package/dist/services/agent-runtime/schemas.d.mts +1 -1
- package/dist/services/automation-trigger/index.mjs +1 -1
- package/dist/services/capability/index.d.mts +2 -2
- package/dist/services/capability/index.mjs +1 -1
- package/dist/services/code-execution/index.d.mts +1 -1
- package/dist/services/code-execution/index.mjs +1 -1
- package/dist/services/codebase/index.d.mts +2 -2
- package/dist/services/codebase/namespace.d.mts +1 -1
- package/dist/services/codebase/schemas.d.mts +1 -1
- package/dist/services/compression/index.d.mts +2 -2
- package/dist/services/compression/namespace.d.mts +1 -1
- package/dist/services/compression/schemas.d.mts +1 -1
- package/dist/services/context-rules/index.d.mts +1 -1
- package/dist/services/context-rules/index.mjs +1 -1
- package/dist/services/execution-target/index.d.mts +3 -3
- package/dist/services/execution-target/index.mjs +1 -1
- package/dist/services/execution-target/namespace.d.mts +1 -1
- package/dist/services/execution-target/namespace.mjs +1 -1
- package/dist/services/execution-target/schemas.d.mts +1 -1
- package/dist/services/execution-target/schemas.mjs +1 -1
- package/dist/services/filesystem/index.d.mts +1 -1
- package/dist/services/filesystem/index.mjs +1 -1
- package/dist/services/git/namespace.mjs +1 -1
- package/dist/services/git/schemas.mjs +1 -1
- package/dist/services/harness/index.mjs +1 -1
- package/dist/services/index.d.mts +45 -66
- package/dist/services/index.mjs +1 -1
- package/dist/services/log-import/browser.d.mts +2 -2
- package/dist/services/log-import/index.d.mts +2 -2
- package/dist/services/log-import/log-import.d.mts +1 -1
- package/dist/services/log-import/log-import.mjs +1 -1
- package/dist/services/log-import/namespace.mjs +1 -1
- package/dist/services/log-import/schemas.mjs +1 -1
- package/dist/services/materialization/index.d.mts +13 -34
- package/dist/services/materialization/index.mjs +1 -1
- package/dist/services/model-registry/index.d.mts +1 -1
- package/dist/services/model-registry/index.mjs +1 -1
- package/dist/services/preferences/index.d.mts +2 -2
- package/dist/services/preferences/schemas.d.mts +1 -1
- package/dist/services/preferences/storage-namespace.d.mts +2 -2
- package/dist/services/provider-context/index.d.mts +1 -1
- package/dist/services/provider-context/index.mjs +1 -1
- package/dist/services/provider-runtime/index.mjs +1 -1
- package/dist/services/session/handlers/index.d.mts +1 -1
- package/dist/services/session/handlers/index.mjs +1 -1
- package/dist/services/session/index.d.mts +9 -9
- package/dist/services/session/index.mjs +1 -1
- package/dist/services/session/messages/namespace.d.mts +1 -1
- package/dist/services/session/messages/namespace.mjs +1 -1
- package/dist/services/session/orchestrator-testing/index.d.mts +1 -1
- package/dist/services/session/orchestrator-testing/index.mjs +1 -1
- package/dist/services/session/session-events/namespace.d.mts +1 -1
- package/dist/services/session/session-events/namespace.mjs +1 -1
- package/dist/services/session/storage/namespace.d.mts +1 -1
- package/dist/services/session/storage/schema.d.mts +1 -1
- package/dist/services/session/testing/index.mjs +1 -1
- package/dist/services/session/testing/orchestrator-shared.d.mts +1 -1
- package/dist/services/session/testing/orchestrator-shared.mjs +1 -1
- package/dist/services/session/turns/namespace.d.mts +1 -1
- package/dist/services/session/turns/namespace.mjs +1 -1
- package/dist/services/session-editor/index.d.mts +1 -1
- package/dist/services/session-editor/index.mjs +1 -1
- package/dist/services/settings/index.d.mts +3 -3
- package/dist/services/settings/index.mjs +1 -1
- package/dist/services/settings/namespace.mjs +1 -1
- package/dist/services/settings/storage/clients-namespace.d.mts +1 -1
- package/dist/services/settings/storage/clients-namespace.mjs +1 -1
- package/dist/services/settings/storage/index.d.mts +3 -3
- package/dist/services/settings/storage/index.mjs +1 -1
- package/dist/services/settings/storage/providers-namespace.d.mts +1 -1
- package/dist/services/settings/storage/providers-namespace.mjs +1 -1
- package/dist/services/subagent/index.d.mts +1 -1
- package/dist/services/subagent/index.mjs +1 -1
- package/dist/services/subagent-template/index.d.mts +2 -2
- package/dist/services/subagent-template/namespace.d.mts +1 -1
- package/dist/services/subagent-template/schemas.d.mts +1 -1
- package/dist/services/tool-approval/index.d.mts +1 -1
- package/dist/services/tool-approval/index.mjs +1 -1
- package/dist/services/tools/index.d.mts +1 -1
- package/dist/services/tools/index.mjs +1 -1
- package/dist/services/tray-menu/index.d.mts +3 -3
- package/dist/services/tray-menu/index.mjs +1 -1
- package/dist/services/tray-menu/namespace.d.mts +1 -1
- package/dist/services/tray-menu/schemas.d.mts +1 -1
- package/dist/services/turn/index.d.mts +1 -1
- package/dist/services/turn/namespace.d.mts +1 -1
- package/dist/services/workflow-transitions/index.d.mts +1 -1
- package/dist/services/workflow-transitions/index.mjs +1 -1
- package/dist/{session-CXOPk3yg.mjs → session-BDFNAcuY.mjs} +1 -1
- package/dist/{session-BOpTI79g.mjs → session-CQAuApxe.mjs} +1 -1
- package/dist/{shared-B9AWRm9A.mjs → shared-BYP7z9xy.mjs} +1 -1
- package/dist/{skill-DGNtc_ww.mjs → skill-1gU2q1KT.mjs} +1 -1
- package/dist/{src-DEgV239R.mjs → src-D4Gx0QHf.mjs} +1 -1
- package/dist/storage/drizzle/client.d.mts +1 -1
- package/dist/storage/drizzle/client.mjs +1 -1
- package/dist/storage/drizzle/index.d.mts +1 -1
- package/dist/storage/drizzle/index.mjs +1 -1
- package/dist/storage/handlers/drizzle/index.d.mts +1 -1
- package/dist/storage/handlers/drizzle/index.mjs +1 -1
- package/dist/storage/handlers/index.d.mts +1 -1
- package/dist/storage/handlers/index.mjs +1 -1
- package/dist/{tool-approval-service-BFDOFUGC.mjs → tool-approval-service-7mzJVMo_.mjs} +1 -1
- package/dist/{tools-DWKWX3eV.mjs → tools-Cyo6BuGM.mjs} +1 -1
- package/dist/{transition-DFA_ckdP.d.mts → transition-CwMPKBjz.d.mts} +2 -2
- package/dist/{types-p55qvq922.d.mts → types-BOF825V52.d.mts} +1 -1
- package/dist/{types-DkfDRSTr.d.mts → types-Dg_acP9p.d.mts} +36 -36
- package/dist/ui-kernel/index.d.mts +1 -1
- package/dist/ui-kernel/pages/schemas.d.mts +1 -1
- package/dist/{version-BYeVh1pI.mjs → version-3xWJDCeF.mjs} +1 -1
- package/dist/{view-builder-CYW_9n4A.d.mts → view-builder-D76L0Db8.d.mts} +209 -15
- package/dist/{visibility-DtDLRBdr.mjs → visibility-C5sLzqyS.mjs} +1 -1
- package/dist/{worker-B4nD_Erm.mjs → worker-9X0QNB1k.mjs} +1 -1
- package/dist/{worker-CLsRbzpk.mjs → worker-BwUhRg7i.mjs} +1 -1
- package/dist/workflow-B3MWrYhG.mjs +1 -0
- package/dist/workflow-engine/execution-attempt-repository.d.mts +2 -2
- package/dist/workflow-engine/execution-attempt-repository.mjs +1 -1
- package/dist/workflow-engine/index.d.mts +52 -52
- package/dist/workflow-engine/index.mjs +1 -1
- package/dist/workflow-engine/package.d.mts +1 -1
- package/dist/workflow-engine/package.mjs +1 -1
- package/dist/workflow-engine/provider-operation.d.mts +1 -1
- package/dist/workflow-engine/testing/conformance.d.mts +1 -1
- package/dist/workflow-engine/testing/conformance.mjs +3 -1
- package/dist/workflow-engine/testing/index.d.mts +9 -6
- package/dist/workflow-engine/testing/index.mjs +1 -1
- package/dist/workflow-engine/testing/sqlite.d.mts +1 -1
- package/dist/workflow-engine/testing/sqlite.mjs +63 -55
- package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
- package/dist/{workflow-transitions-c_VQbyV0.mjs → workflow-transitions-B7HtjuAn.mjs} +1 -1
- package/dist/workflow-worker-zYb2UguP.mjs +2 -0
- package/package.json +1 -1
- package/dist/artifact-ClvHqL3w.mjs +0 -1
- package/dist/attempt-record-codec-B32Whx75.mjs +0 -1
- package/dist/authority-state-bootstrap-7Cgb9TR2.mjs +0 -1
- package/dist/extension-Cz39YNXy.mjs +0 -1
- package/dist/framework-packages-BHgul8Kl.mjs +0 -1
- package/dist/materialization-B_LA9pfy.mjs +0 -1
- package/dist/model-DrzPt3ou.mjs +0 -1
- package/dist/namespace-sCPb79-7.mjs +0 -1
- package/dist/packages-Bp124-gx.mjs +0 -1
- package/dist/schemas-CNkUEbIr.mjs +0 -1
- package/dist/workflow-H8hsEikC.mjs +0 -1
- package/dist/workflow-worker-CmIkKnpF.mjs +0 -2
- /package/dist/{adapter-auth-runtime-DHHppU4f.mjs → adapter-auth-runtime-DGY1CDxj.mjs} +0 -0
- /package/dist/{adapter-binding-D68U_Hmh.d.mts → adapter-binding-fGIz-ss3.d.mts} +0 -0
- /package/dist/{ajv-krzJXh1X.mjs → ajv-DWgn_plp.mjs} +0 -0
- /package/dist/{attach-error-Cb3GbeKe.mjs → attach-error-B-vXQFLQ.mjs} +0 -0
- /package/dist/{attempt-fixtures-CnrnF5_4.mjs → attempt-fixtures-Dpfgqll0.mjs} +0 -0
- /package/dist/{base-orchestrator-DA95InJU.d.mts → base-orchestrator-BeLqYKJG.d.mts} +0 -0
- /package/dist/{bootstrap-start-client-DrvofWwi.mjs → bootstrap-start-client-BYoxrgMk.mjs} +0 -0
- /package/dist/{capability-j3NekkIu.mjs → capability-Bw4tsDQu.mjs} +0 -0
- /package/dist/{capability-service-s4ZYSEWc.d.mts → capability-service-BlYnun2M.d.mts} +0 -0
- /package/dist/{client-f5A-6La5.d.mts → client-CtOWHpFB.d.mts} +0 -0
- /package/dist/{client-binary-version-verifier-kd9LP9AQ.d.mts → client-binary-version-verifier-BwmToeS1.d.mts} +0 -0
- /package/dist/{client-binary-version-verifier-0lCKZOTg.mjs → client-binary-version-verifier-sv-Uv0lB.mjs} +0 -0
- /package/dist/{clients-namespace-q4PqU1cA.d.mts → clients-namespace-Bf73bcZh.d.mts} +0 -0
- /package/dist/{config-namespace-Cp71zTT0.d.mts → config-namespace-BbLLd4V0.d.mts} +0 -0
- /package/dist/{create-static-mount-CmQgA0jq.mjs → create-static-mount-BQnyEUH1.mjs} +0 -0
- /package/dist/{cross-spawn-CZygZJMH.mjs → cross-spawn-DPrJR9Nq.mjs} +0 -0
- /package/dist/{cursor-storage-bsc9lZKk.mjs → cursor-storage-iJ6vBOWd.mjs} +0 -0
- /package/dist/{definition-BHSzhrUf.d.mts → definition-aS9AM2ht.d.mts} +0 -0
- /package/dist/{definitions-CRpdnHYM.mjs → definitions-CYZTuMdL.mjs} +0 -0
- /package/dist/{descriptor-to-package-CcjdoWP4.mjs → descriptor-to-package-FBkLjHZo.mjs} +0 -0
- /package/dist/{drizzle-Bzc-OGVI.mjs → drizzle-CIf_jdYI.mjs} +0 -0
- /package/dist/{esm-i-S5TW72.mjs → esm-BH4Kmq3r.mjs} +0 -0
- /package/dist/{event-B8ELuk6k.mjs → event-m7_IdhOS.mjs} +0 -0
- /package/dist/{execution-attempt-repository-D0cCU7dI.mjs → execution-attempt-repository-D_qR7NyG.mjs} +0 -0
- /package/dist/{extension-context-BmU5XKjI.d.mts → extension-context-41A1ZUus.d.mts} +0 -0
- /package/dist/{extension-discovery-DnO7bINK.d.mts → extension-discovery-DNB1VVsV.d.mts} +0 -0
- /package/dist/{extension-namespace-QoTTwKPt.mjs → extension-namespace-twXNwE4R.mjs} +0 -0
- /package/dist/{extension-package-provenance-aYrZuS4W.mjs → extension-package-provenance-CTYdo0yF.mjs} +0 -0
- /package/dist/{facet-BnMh7Jyc.mjs → facet-Cly0VpTI.mjs} +0 -0
- /package/dist/{filesystem-service-BBArEDPL.d.mts → filesystem-service-DOrm4Llq.d.mts} +0 -0
- /package/dist/{handler-DF1fVDpf.mjs → handler-COkV00I9.mjs} +0 -0
- /package/dist/{host-B-_ntOMH.mjs → host-CiHn8Yog.mjs} +0 -0
- /package/dist/{identity-OjRlG6dZ.mjs → identity-BULrIHmo.mjs} +0 -0
- /package/dist/{index-xaBSwHxJ.d.mts → index-BB4EWIf3.d.mts} +0 -0
- /package/dist/{index-DYHxzwok2.d.mts → index-BBq5I7SB2.d.mts} +0 -0
- /package/dist/{index-NhW2h2wH2.d.mts → index-BJjdUzfw2.d.mts} +0 -0
- /package/dist/{index-CsFN2nv7.d.mts → index-BKvzOrbF.d.mts} +0 -0
- /package/dist/{index-D-JbTXIH.d.mts → index-BO8n7zAS.d.mts} +0 -0
- /package/dist/{index-Co1da7YK.d.mts → index-BbAqoQmv.d.mts} +0 -0
- /package/dist/{index-DSLTgc7h2.d.mts → index-BcTwLu9C2.d.mts} +0 -0
- /package/dist/{index-Dn_SGTgp.d.mts → index-Bg5iXHk5.d.mts} +0 -0
- /package/dist/{index-CPWBGotQ.d.mts → index-BiXqOfhl.d.mts} +0 -0
- /package/dist/{index-DSN2t48K.d.mts → index-BjaQsfAr.d.mts} +0 -0
- /package/dist/{index-mK-rgiit.d.mts → index-Bk865qJX.d.mts} +0 -0
- /package/dist/{index-CkpR5sIH.d.mts → index-Bq4PHWe9.d.mts} +0 -0
- /package/dist/{index-DW4SE_sH.d.mts → index-CUHWylh4.d.mts} +0 -0
- /package/dist/{index-CcrXttC02.d.mts → index-CavvxFdG2.d.mts} +0 -0
- /package/dist/{index-CDLf3Fka2.d.mts → index-Cb3NfGSV2.d.mts} +0 -0
- /package/dist/{index-Df1c_2PF.d.mts → index-Ce_l029J.d.mts} +0 -0
- /package/dist/{index-D94yE5Dr.d.mts → index-CgVdz5IV.d.mts} +0 -0
- /package/dist/{index-KAAnSRZt.d.mts → index-Ck5amD5_.d.mts} +0 -0
- /package/dist/{index-BB0HypzC.d.mts → index-ClJjlOox.d.mts} +0 -0
- /package/dist/{index-CGJgZGqN.d.mts → index-CoGo6HFE.d.mts} +0 -0
- /package/dist/{index-CrcfeFOo.d.mts → index-DR9-fFwc.d.mts} +0 -0
- /package/dist/{index-B-zl-O-Y.d.mts → index-Q29tcu5N.d.mts} +0 -0
- /package/dist/{index-DQD2-jcL.d.mts → index-VVJqONaI.d.mts} +0 -0
- /package/dist/{index-D6RMsZko.d.mts → index-gK54T8Am.d.mts} +0 -0
- /package/dist/{index-D_sMzTvv.d.mts → index-jW7MJ2_q.d.mts} +0 -0
- /package/dist/{index-CBixkF0n.d.mts → index-l5HeyxKn.d.mts} +0 -0
- /package/dist/{index-BDAfOYSw2.d.mts → index-oucWFlFP2.d.mts} +0 -0
- /package/dist/{index-Bf2MgOni.d.mts → index-z-YJG2cw.d.mts} +0 -0
- /package/dist/{index-C9xVZ-gt.d.mts → index-zvgQ8ErF.d.mts} +0 -0
- /package/dist/{json-value-pX6xnLGw.d.mts → json-value-C57MkQrB.d.mts} +0 -0
- /package/dist/{json-value-BBZ6uGwc.mjs → json-value-DM-EjTC1.mjs} +0 -0
- /package/dist/{jsonl-transport-DQIlRX_y.mjs → jsonl-transport-QQuABrN7.mjs} +0 -0
- /package/dist/{lib-6eNAiNK7.mjs → lib-Sx8gBJvV.mjs} +0 -0
- /package/dist/{model-registry-C9rFu3kV.mjs → model-registry-B7ThN_s3.mjs} +0 -0
- /package/dist/{model-registry-Cixxx2jv.mjs → model-registry-DNHDnyvs.mjs} +0 -0
- /package/dist/{modes-DwsJ3yVl.mjs → modes-CyG4sgs_.mjs} +0 -0
- /package/dist/{namespace-NXm_zvL1.mjs → namespace-BFlSY040.mjs} +0 -0
- /package/dist/{namespace-DiwqpB-c.mjs → namespace-BGgY903U.mjs} +0 -0
- /package/dist/{namespace-BMG3RCdr.d.mts → namespace-BY5-nA4j.d.mts} +0 -0
- /package/dist/{namespace-CVg_cpkh.d.mts → namespace-Bn-ryJn5.d.mts} +0 -0
- /package/dist/{namespace-Cs-cOyrn.d.mts → namespace-By3nEmBH.d.mts} +0 -0
- /package/dist/{namespace-Du0accdE.mjs → namespace-C9d0aoYT.mjs} +0 -0
- /package/dist/{namespace-Dw5H_KCF.d.mts → namespace-CPC1vbOu.d.mts} +0 -0
- /package/dist/{namespace-CPR2xem0.d.mts → namespace-Ca4sQ8X-.d.mts} +0 -0
- /package/dist/{namespace-BoyqQiW9.d.mts → namespace-D1qK-Ed3.d.mts} +0 -0
- /package/dist/{namespace-9ychTEk_.d.mts → namespace-DE3oGhaN.d.mts} +0 -0
- /package/dist/{namespace-DG0hjPcx.d.mts → namespace-DENdNdK0.d.mts} +0 -0
- /package/dist/{namespace-jVTsuZHX.mjs → namespace-DHrItZyM.mjs} +0 -0
- /package/dist/{namespace-DykqxEyX.d.mts → namespace-DInMixc8.d.mts} +0 -0
- /package/dist/{namespace-CQEYu8az.d.mts → namespace-DP0WWpTO.d.mts} +0 -0
- /package/dist/{namespace-BGDq7HmW.d.mts → namespace-DkAlBY9o.d.mts} +0 -0
- /package/dist/{namespace-BW3Bfu9h.mjs → namespace-QXCaZK3I.mjs} +0 -0
- /package/dist/{namespace-tjoxekmf.mjs → namespace-ZN49zpqw.mjs} +0 -0
- /package/dist/{orchestrator-shared-BzqqcY2z.d.mts → orchestrator-shared-2vuCvljs.d.mts} +0 -0
- /package/dist/{out-8bOYN6EF.mjs → out-Rz-t3WeC.mjs} +0 -0
- /package/dist/{ownership-recovery-guard-DyW5vGBr.mjs → ownership-recovery-guard-Ce9-C5Sa.mjs} +0 -0
- /package/dist/{package-DttKA9wN.mjs → package-DfjGt5oK.mjs} +0 -0
- /package/dist/{package-EGTn-Ng1.mjs → package-Tt2uoAFf.mjs} +0 -0
- /package/dist/{platform-CxyYPrkf.mjs → platform-C-fDsuEl.mjs} +0 -0
- /package/dist/{provider-operation-B2wQST6N.d.mts → provider-operation-BwrIrOeY.d.mts} +0 -0
- /package/dist/{providers-C-eekMxD.mjs → providers-DVlsnJaY.mjs} +0 -0
- /package/dist/{providers-namespace-DsKTnuO1.d.mts → providers-namespace-C56pGeTO.d.mts} +0 -0
- /package/dist/{quick-lru-CCEnf7y6.mjs → quick-lru-uXa2PNb5.mjs} +0 -0
- /package/dist/{registry-Dk12tAfv.mjs → registry-CZf8VGBh.mjs} +0 -0
- /package/dist/{schema-C0opCPww.mjs → schema-DIHGEQx3.mjs} +0 -0
- /package/dist/{schema-introspection-6-r_KEJQ.mjs → schema-introspection-CSnLZJpC.mjs} +0 -0
- /package/dist/{schemas-Dxvjq-Bi.d.mts → schemas-B0zhTfet.d.mts} +0 -0
- /package/dist/{schemas-ClGDFa44.d.mts → schemas-B2Q284-G.d.mts} +0 -0
- /package/dist/{schemas--LAbwXvw.d.mts → schemas-BJKx29Sp.d.mts} +0 -0
- /package/dist/{schemas-BivbWRkG.mjs → schemas-BKnJj2i-.mjs} +0 -0
- /package/dist/{schemas-DmULJ7Jk.d.mts → schemas-BMGJLkdK2.d.mts} +0 -0
- /package/dist/{schemas-B2UbGJpJ.d.mts → schemas-BSBb1KFq.d.mts} +0 -0
- /package/dist/{schemas-CeHU889f.mjs → schemas-BapfTRqp.mjs} +0 -0
- /package/dist/{schemas-Bk50UoMA.d.mts → schemas-BsZJHdvY.d.mts} +0 -0
- /package/dist/{schemas-CzGN0eqW.d.mts → schemas-CITR9cWN.d.mts} +0 -0
- /package/dist/{schemas-B8hKbBwI.mjs → schemas-CnFVygzI.mjs} +0 -0
- /package/dist/{schemas-scyC2tFF.mjs → schemas-DDCAGKRi.mjs} +0 -0
- /package/dist/{schemas-CBpjAhut.d.mts → schemas-DmE-a0kN.d.mts} +0 -0
- /package/dist/{schemas-Wqo3_F6-.d.mts → schemas-gfrOgGau.d.mts} +0 -0
- /package/dist/{schemas-CHRuwe18.d.mts → schemas-wPB7RnHB.d.mts} +0 -0
- /package/dist/{semver-BI7kTNsY.mjs → semver-D_D2mA48.mjs} +0 -0
- /package/dist/{server-lifecycle-B_OZnoe-.mjs → server-lifecycle-AvBVeCFR.mjs} +0 -0
- /package/dist/{server-lifecycle-WFZcCMwF.d.mts → server-lifecycle-CREtXADx.d.mts} +0 -0
- /package/dist/{session-lineage-C9kppcCa.d.mts → session-lineage-CRLvurB-.d.mts} +0 -0
- /package/dist/{shared-schemas-CQ6blrEW.mjs → shared-schemas-kUho6Kmw.mjs} +0 -0
- /package/dist/{src-DIyWekjW.mjs → src-DnLncoLg.mjs} +0 -0
- /package/dist/{storage-namespace-BZce8kkW.mjs → storage-namespace-CH4j0_Zs.mjs} +0 -0
- /package/dist/{storage-namespace-BWU-8rvj.d.mts → storage-namespace-JBh9nkKw.d.mts} +0 -0
- /package/dist/{storage-namespace-definition-Cca-zwXU.mjs → storage-namespace-definition-BJCbqVWz.mjs} +0 -0
- /package/dist/{storage-namespace-definition-B-8JKvzm.d.mts → storage-namespace-definition-C0mnpnC_.d.mts} +0 -0
- /package/dist/{supports-color-SV_FgSN2.mjs → supports-color-BBMFnbC4.mjs} +0 -0
- /package/dist/{telemetry-BqoC87F-.mjs → telemetry-CUkZrhW6.mjs} +0 -0
- /package/dist/{timeout-DVlN2Zhy.mjs → timeout-DeBYTGBR.mjs} +0 -0
- /package/dist/{tray-menu-service-eVVxgPLc.mjs → tray-menu-service-thAhpcPA.mjs} +0 -0
- /package/dist/{types-BnPJa-C_.d.mts → types-9ldZyQTb.d.mts} +0 -0
- /package/dist/{types-DQTCNM2i.d.mts → types-BMkn9jOe.d.mts} +0 -0
- /package/dist/{types-Cwza95hS.mjs → types-CjjNAiHa.mjs} +0 -0
- /package/dist/{types-DxHeL0pF.d.mts → types-DJuxNrac.d.mts} +0 -0
- /package/dist/{types-BFeWU3WM.d.mts → types-eCGV_g6P.d.mts} +0 -0
- /package/dist/{types-8rMNe3AS.d.mts → types-xXv0lUeU.d.mts} +0 -0
- /package/dist/{ui-config-B35GloSX.mjs → ui-config-9hlZAJOS.mjs} +0 -0
- /package/dist/{variant-Dwnge3J_.mjs → variant-73kFgYBK.mjs} +0 -0
- /package/dist/{window-registry-DQP5P2_0.d.mts → window-registry-CGaYVD7l.d.mts} +0 -0
- /package/dist/{window-registry-CKiMJjId.mjs → window-registry-CzAwaPKL.mjs} +0 -0
- /package/dist/{zod-json-schema-Dixc-B1T.mjs → zod-json-schema-B9TYYq3e.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,c as t,d as n,f as r,g as i,h as a,l as o,m as s,n as c,o as l,p as u,s as d,u as f}from"../../execution-attempt-repository-D0cCU7dI.mjs";import{a as p,c as m,d as h,f as g,i as _,l as v,m as y,n as b,o as x,p as S,r as C,s as w,t as T,u as E}from"../../attempt-record-codec-B32Whx75.mjs";import{a as D,c as O,d as k,f as A,i as j,l as M,m as N,n as P,o as F,p as I,r as L,s as R,t as z,u as B}from"../../attempt-fixtures-CnrnF5_4.mjs";import{BoundedRecoveryEvidenceSchema as V}from"@makaio/framework/contracts";function H(e,t){return{...e,status:`settled`,settlementKind:t,claimable:!1,operationStartGate:`closed`}}function U(D,O={}){let k=O.attempts??new Map,A=O.operations??new Map,j=e=>A.get(e)?.obligation===`terminal-convergence`,M=O.committedOutcomes??new Map,N=O.activeAttempts??new Map,P=e=>{let t=e.settlementKind!=null,r=!t&&N.get(e.executionId)===e.executionAttemptId;return n({matchesExecution:!0,settled:t,active:r,allocated:r&&e.allocationRef!==null&&!j(e.executionAttemptId)})},F=e=>{let t=k.get(e.executionAttemptId),n=A.get(e.executionAttemptId);return!t||!n?{kind:`not-found`}:t.settlementKind==null?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}:{kind:`resolved`,attempt:t}},I=(e,t)=>{A.set(e.executionAttemptId,{...e,ownerId:null,token:null,leaseExpiresAt:null,lastFailure:t})},L=(e,t)=>{let n=w(e.allocationRef),r=F(e.claim);if(r.kind!==`not-found`&&g(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 o(i.allocationRef,n)?{kind:`duplicate`,allocationRef:i.allocationRef}:{kind:`conflict`,allocationRef:i.allocationRef};let s=N.get(i.executionId)===i.executionAttemptId;return k.set(i.executionAttemptId,{...i,status:`allocated`,allocationRef:n,claimable:t&&s}),A.set(a.executionAttemptId,{...a,obligation:`allocation-control`}),{kind:`recorded`}};return{async createAttempt(e){let t=v(e.instruction),n=C(e.bootstrapTimeoutMs);if(k.has(e.executionAttemptId))throw new c(e.executionAttemptId);let r={executionAttemptId:e.executionAttemptId,executionId:e.executionId,instruction:t,preparationReceipts:Object.freeze([]),status:`pending`,allocationRef:null,...n,providerId:null,allocationLifetime:null,provisionerIncarnationId:null,settlementKind:null,claimable:!1,claimExpiresAt:null,...T},i=N.get(e.executionId),a=i===void 0?void 0:k.get(i);return a!==void 0&&k.set(a.executionAttemptId,{...a,claimable:a.status===`allocated`?!1:a.claimable,operationStartGate:`closed`}),k.set(e.executionAttemptId,r),N.set(e.executionId,e.executionAttemptId),r},async readBootstrapStartState(e){let t=k.get(e.executionAttemptId);return!t||t.executionId!==e.executionId?null:{settled:t.settlementKind!=null,active:N.get(e.executionId)===e.executionAttemptId,allocated:t.allocationRef!==null,allocationTerminated:j(e.executionAttemptId),operationStartGate:t.operationStartGate,bootstrapDeadlineAt:t.bootstrapDeadlineAt??null}},async beginProvisioning(e){let t=x(e.allocationLifetime),n=k.get(e.executionAttemptId);if(!n||n.executionId!==e.executionId)return{kind:`not-found`};if(N.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.status!==`pending`)return{kind:`already-provisioning`};k.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:p(e.leaseExpiresAt)};return A.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}),{kind:`started`,claim:r}},async getProviderOperation(e){return A.get(e)??null},async renewProviderOperationClaim(e){let t=F(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let n=p(e.leaseExpiresAt);return A.set(e.claim.executionAttemptId,{...t.operation,leaseExpiresAt:n}),{kind:`claimed`,claim:{...e.claim,leaseExpiresAt:n}}},async takeOverProviderOperation(e){let t=k.get(e.executionAttemptId),n=A.get(e.executionAttemptId);if(!t||!n)return{kind:`not-found`};if(t.settlementKind!=null)return{kind:`resolved`};if(n.ownerId!==null&&n.leaseExpiresAt!==null&&_(n.leaseExpiresAt)>_(e.observedAt))return{kind:`stale`};let r={executionAttemptId:e.executionAttemptId,generation:n.generation+1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:p(e.leaseExpiresAt)};return A.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:V.parse(e.evidence),n=F(e.claim);return n.kind===`authorized`?(A.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=V.parse(e.evidence),n=F(e.claim);return n.kind===`authorized`?(A.set(e.claim.executionAttemptId,{...n.operation,failureCount:n.operation.failureCount+1,lastFailure:t}),{kind:`recorded`}):{kind:n.kind}},async recordAllocation(e){return L(e,!0)},async recordProvisioningAbsent(e){let t=V.parse(e.evidence),n=F(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.allocationRef===null?(k.set(r.executionAttemptId,H(r,`abandoned`)),I(i,t),{kind:`recorded`}):{kind:`allocated`,allocationRef:r.allocationRef}:{kind:`not-found`}},async recordProvisionerIncarnationLost(e){let t=V.parse(e.proof.evidence),n=F(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n,o=a(r,e);return o===null?(k.set(r.executionAttemptId,H(r,`abandoned`)),I(i,t),{kind:`recorded`}):o},async recordAllocationTerminated(e){let t=V.parse(e.evidence),n=F(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.allocationRef===null?{kind:`not-allocated`}:(A.set(i.executionAttemptId,{...i,obligation:`terminal-convergence`,lastFailure:t}),{kind:`recorded`})},async recordInfrastructureFailure(e){let t=F(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let{attempt:n,operation:r}=t;return n.executionId===e.executionId?n.allocationRef===null?{kind:`not-allocated`}:r.obligation===`terminal-convergence`?(k.set(n.executionAttemptId,H(n,`infrastructure-failure`)),I(r,r.lastFailure),{kind:`recorded`}):{kind:`not-terminated`}:{kind:`not-found`}},async registerRuntime(t){let n=k.get(t.executionAttemptId);if(n===void 0||n.executionId!==t.executionId)return{kind:`not-found`};let r=P(n)??e(n,t);if(r!==null)return r;let i=n.runtimeGeneration+1;return k.set(n.executionAttemptId,{...n,runtimeGeneration:i,runtimeIncarnationId:t.runtimeIncarnationId,runtimeReadyAt:null,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null}),{kind:`registered`,runtimeGeneration:i}},async admitOperation(e){let t=k.get(e.executionAttemptId);if(t===void 0||t.executionId!==e.executionId)return{kind:`not-found`};let n=P(t);if(n!==null)return n;let i=r(t,e,t.activeOperationId!==null&&t.activeOperationKey===e.admissionKey&&t.activeOperationAdmittedAt===null?p(new Date().toISOString()):``,t);if(i!==null)return i;let a=crypto.randomUUID(),o=p(new Date().toISOString());return k.set(t.executionAttemptId,{...t,activeOperationId:a,activeOperationKind:e.operationKind,activeOperationKey:e.admissionKey,activeOperationGeneration:t.runtimeGeneration,activeOperationAdmittedAt:o}),{kind:`admitted`,operationId:a,runtimeGeneration:t.runtimeGeneration,admittedAt:o}},async getInstruction(e){let t=k.get(e.executionAttemptId);return t?.executionId===e.executionId?t.instruction:null},async reportOperation(e){let t=h(e.result),n=k.get(e.executionAttemptId);if(n===void 0||n.executionId!==e.executionId)return{kind:`not-found`};let r=s({matchesExecution:!0,settled:n.settlementKind!=null,active:N.get(e.executionId)===e.executionAttemptId,allocated:n.allocationRef!==null&&!j(e.executionAttemptId)},n,n,{...e,result:t});if(r!==null)return r;let i=E([...n.preparationReceipts,{operationId:e.operationId,runtimeGeneration:e.runtimeGeneration,result:t}]);return k.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(e){let t=k.get(e.executionAttemptId);if(t===void 0)return{kind:`not-found`};if(t.settlementKind!=null)return{kind:`resolved`};let n=u(t,e);return n===null?(k.set(t.executionAttemptId,{...t,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null,lastCompletedOperationId:e.operationId}),{kind:`completed`}):n},async markRuntimeReady(e){let t=p(e.readyAt),n=k.get(e.executionAttemptId);if(n===void 0||n.executionId!==e.executionId)return{kind:`not-found`};let r=P(n)??i(n,e);return r===null?(k.set(n.executionAttemptId,{...n,runtimeReadyAt:t}),{kind:`ready`,acceptedAt:t}):r},async getAttemptControlState(e){let t=k.get(e);return t===void 0?null:S(t)},async getActiveAttempt(e,t){return N.get(e)===t?k.get(t)??null:null},canonicalizeOutcome(e){return t(D,e)},decodeOutcome(e){return d(D,e)},async commitOutcome(e){let t=e.result;if(N.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};let n=k.get(e.executionAttemptId);if(n===void 0)return{kind:`fenced`};let r=M.get(e.executionAttemptId);if(r!==void 0){let e=d(D,r);return f(r,t.text)?{kind:`duplicate`,outcome:e,text:r}:{kind:`conflict`}}if(n.settlementKind!=null)return{kind:`conflict`};l(n,e.runtimeFence),M.set(e.executionAttemptId,t.text),k.set(e.executionAttemptId,H(n,`outcome`));let i=A.get(e.executionAttemptId);return i&&I(i,i.lastFailure),{kind:`accepted`,outcome:d(D,t.text),text:t.text}},async abandonPendingAttempt(e,t){if(N.get(t)!==e)return{kind:`fenced`};let n=k.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`}:(k.set(e,H(n,`abandoned`)),{kind:`abandoned`}):{kind:`fenced`}},recovery:{async getAttemptWithAllocation(e){return k.get(e)??null},async recordDiscoveredAllocation(e){return L(e,!1)},async evolveAllocationRef(e){let{currentRef:t,nextRef:n}=m(e),r=F(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`}:o(i.allocationRef,t)?(k.set(i.executionAttemptId,{...i,allocationRef:n}),{kind:`evolved`}):{kind:`stale`,storedRef:i.allocationRef}:{kind:`not-found`}},async getRecoverableAttempts(e){let t=_(new Date().toISOString()),n=[];for(let r of k.values())r.executionId===e&&r.status===`allocated`&&r.allocationRef!==null&&r.claimable===!0&&r.settlementKind==null&&(r.claimExpiresAt!=null&&_(r.claimExpiresAt)<t||n.push(y(r)));return n.sort(b)}},attempts:k,operations:A,committedOutcomes:M,activeAttempts:N}}export{T as INITIAL_ATTEMPT_CONTROL_STATE,z as TEST_OWNER_ID,P as TEST_PROVIDER_ID,L as TEST_PROVISIONER_INCARNATION_ID,j as allocateTestAttempt,D as beginTestProvisioning,U as createInMemoryAttemptRepository,F as driveTestAttemptToAllocated,R as leaseAt,O as makeBeginProvisioningInput,M as makeEvidence,B as makeProcessLossProof,k as makeTestAllocationRef,A as makeTestInstruction,I as makeTestWorkflowResult,N as workflowRunResultOutcomeCodec};
|
|
1
|
+
import{_ as e,c as t,d as n,f as r,g as i,h as a,l as o,m as s,n as c,o as l,p as u,s as d,u as f}from"../../execution-attempt-repository-D_qR7NyG.mjs";import{a as p,i as m,n as h,o as g,t as _}from"../../execution-attempt-owner-recovery-BNERIDH0.mjs";import{a as v,c as y,d as b,f as x,i as S,l as C,n as w,o as T,p as E,r as D,s as O,t as k,u as A}from"../../attempt-record-codec-CqKq0NIB.mjs";import{a as j,c as M,d as N,f as P,i as F,l as I,m as L,n as R,o as z,p as B,r as V,s as H,t as U,u as W}from"../../attempt-fixtures-Dpfgqll0.mjs";import{BoundedRecoveryEvidenceSchema as G}from"@makaio/framework/contracts";function K(e,t){return{...e,status:`settled`,settlementKind:t,claimable:!1,operationStartGate:`closed`}}function q(j,M={}){let N=M.attempts??new Map,P=M.operations??new Map,F=e=>P.get(e)?.obligation===`terminal-convergence`,I=M.committedOutcomes??new Map,L=M.activeAttempts??new Map,R=M.requestBindings??new Map,z=e=>{let t=e.settlementKind!=null,r=!t&&L.get(e.executionId)===e.executionAttemptId;return n({matchesExecution:!0,settled:t,active:r,allocated:r&&e.allocationRef!==null&&!F(e.executionAttemptId)})},B=e=>{let t=N.get(e.executionAttemptId),n=P.get(e.executionAttemptId);return!t||!n?{kind:`not-found`}:t.settlementKind==null?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}:{kind:`resolved`,attempt:t}},V=(e,t)=>{P.set(e.executionAttemptId,{...e,ownerId:null,token:null,leaseExpiresAt:null,lastFailure:t})},H=(e,t)=>{let n=O(e.allocationRef),r=B(e.claim);if(r.kind!==`not-found`&&b(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 o(i.allocationRef,n)?{kind:`duplicate`,allocationRef:i.allocationRef}:{kind:`conflict`,allocationRef:i.allocationRef};let s=L.get(i.executionId)===i.executionAttemptId;return N.set(i.executionAttemptId,{...i,status:`allocated`,allocationRef:n,claimable:t&&s}),P.set(a.executionAttemptId,{...a,obligation:`allocation-control`}),{kind:`recorded`}},U={async getAttemptWithAllocation(e){return N.get(e)??null},async recordDiscoveredAllocation(e){return H(e,!1)},async evolveAllocationRef(e){let{currentRef:t,nextRef:n}=y(e),r=B(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`}:o(i.allocationRef,t)?(N.set(i.executionAttemptId,{...i,allocationRef:n}),{kind:`evolved`}):{kind:`stale`,storedRef:i.allocationRef}:{kind:`not-found`}},async getRecoverableAttempts(e){let t=S(new Date().toISOString()),n=[];for(let r of N.values())r.executionId===e&&r.status===`allocated`&&r.allocationRef!==null&&r.claimable===!0&&r.settlementKind==null&&(r.claimExpiresAt!=null&&S(r.claimExpiresAt)<t||n.push(E(r)));return n.sort(w)}},W=e=>{let t=D(e.bootstrapTimeoutMs);if(N.has(e.executionAttemptId))throw new c(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,...k},r=L.get(e.executionId),i=r===void 0?void 0:N.get(r);return i!==void 0&&N.set(i.executionAttemptId,{...i,claimable:i.status===`allocated`?!1:i.claimable,operationStartGate:`closed`}),N.set(e.executionAttemptId,n),L.set(e.executionId,e.executionAttemptId),n};return{async createAttempt(e){return W({...e,instruction:g(e.instruction)})},async ensureAttempt(e){let t=m(e),n=R.get(t.executionId),r=n?.get(t.requestKey);if(r!==void 0)return h(t,N.get(r)??null);let i=W(t),a=n??new Map;return a.set(t.requestKey,i.executionAttemptId),R.set(t.executionId,a),{kind:`created`,attempt:structuredClone(i)}},async readAttemptSettlement(e){let t=p(e);return _(t,{attempt:N.get(t.executionAttemptId)??null,activeAttemptId:L.get(t.executionId)??null,outcomeText:I.get(t.executionAttemptId)??null},j)},async readBootstrapStartState(e){let t=N.get(e.executionAttemptId);return!t||t.executionId!==e.executionId?null:{settled:t.settlementKind!=null,active:L.get(e.executionId)===e.executionAttemptId,allocated:t.allocationRef!==null,allocationTerminated:F(e.executionAttemptId),operationStartGate:t.operationStartGate,bootstrapDeadlineAt:t.bootstrapDeadlineAt??null}},async beginProvisioning(e){let t=T(e.allocationLifetime),n=N.get(e.executionAttemptId);if(!n||n.executionId!==e.executionId)return{kind:`not-found`};if(L.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.status!==`pending`)return{kind:`already-provisioning`};N.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:v(e.leaseExpiresAt)};return P.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}),{kind:`started`,claim:r}},async getProviderOperation(e){return P.get(e)??null},async renewProviderOperationClaim(e){let t=B(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let n=v(e.leaseExpiresAt);return P.set(e.claim.executionAttemptId,{...t.operation,leaseExpiresAt:n}),{kind:`claimed`,claim:{...e.claim,leaseExpiresAt:n}}},async takeOverProviderOperation(e){let t=N.get(e.executionAttemptId),n=P.get(e.executionAttemptId);if(!t||!n)return{kind:`not-found`};if(t.settlementKind!=null)return{kind:`resolved`};if(n.ownerId!==null&&n.leaseExpiresAt!==null&&S(n.leaseExpiresAt)>S(e.observedAt))return{kind:`stale`};let r={executionAttemptId:e.executionAttemptId,generation:n.generation+1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:v(e.leaseExpiresAt)};return P.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:G.parse(e.evidence),n=B(e.claim);return n.kind===`authorized`?(P.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=G.parse(e.evidence),n=B(e.claim);return n.kind===`authorized`?(P.set(e.claim.executionAttemptId,{...n.operation,failureCount:n.operation.failureCount+1,lastFailure:t}),{kind:`recorded`}):{kind:n.kind}},async recordAllocation(e){return H(e,!0)},async recordProvisioningAbsent(e){let t=G.parse(e.evidence),n=B(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.allocationRef===null?(N.set(r.executionAttemptId,K(r,`abandoned`)),V(i,t),{kind:`recorded`}):{kind:`allocated`,allocationRef:r.allocationRef}:{kind:`not-found`}},async recordProvisionerIncarnationLost(e){let t=G.parse(e.proof.evidence),n=B(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n,o=a(r,e);return o===null?(N.set(r.executionAttemptId,K(r,`abandoned`)),V(i,t),{kind:`recorded`}):o},async recordAllocationTerminated(e){let t=G.parse(e.evidence),n=B(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.allocationRef===null?{kind:`not-allocated`}:(P.set(i.executionAttemptId,{...i,obligation:`terminal-convergence`,lastFailure:t}),{kind:`recorded`})},async recordInfrastructureFailure(e){let t=B(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let{attempt:n,operation:r}=t;return n.executionId===e.executionId?n.allocationRef===null?{kind:`not-allocated`}:r.obligation===`terminal-convergence`?(N.set(n.executionAttemptId,K(n,`infrastructure-failure`)),V(r,r.lastFailure),{kind:`recorded`}):{kind:`not-terminated`}:{kind:`not-found`}},async registerRuntime(t){let n=N.get(t.executionAttemptId);if(n===void 0||n.executionId!==t.executionId)return{kind:`not-found`};let r=z(n)??e(n,t);if(r!==null)return r;let i=n.runtimeGeneration+1;return N.set(n.executionAttemptId,{...n,runtimeGeneration:i,runtimeIncarnationId:t.runtimeIncarnationId,runtimeReadyAt:null,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null}),{kind:`registered`,runtimeGeneration:i}},async admitOperation(e){let t=N.get(e.executionAttemptId);if(t===void 0||t.executionId!==e.executionId)return{kind:`not-found`};let n=z(t);if(n!==null)return n;let i=r(t,e,t.activeOperationId!==null&&t.activeOperationKey===e.admissionKey&&t.activeOperationAdmittedAt===null?v(new Date().toISOString()):``,t);if(i!==null)return i;let a=crypto.randomUUID(),o=v(new Date().toISOString());return N.set(t.executionAttemptId,{...t,activeOperationId:a,activeOperationKind:e.operationKind,activeOperationKey:e.admissionKey,activeOperationGeneration:t.runtimeGeneration,activeOperationAdmittedAt:o}),{kind:`admitted`,operationId:a,runtimeGeneration:t.runtimeGeneration,admittedAt:o}},async getInstruction(e){let t=N.get(e.executionAttemptId);return t?.executionId===e.executionId?t.instruction:null},async reportOperation(e){let t=A(e.result),n=N.get(e.executionAttemptId);if(n===void 0||n.executionId!==e.executionId)return{kind:`not-found`};let r=s({matchesExecution:!0,settled:n.settlementKind!=null,active:L.get(e.executionId)===e.executionAttemptId,allocated:n.allocationRef!==null&&!F(e.executionAttemptId)},n,n,{...e,result:t});if(r!==null)return r;let i=C([...n.preparationReceipts,{operationId:e.operationId,runtimeGeneration:e.runtimeGeneration,result:t}]);return N.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(e){let t=N.get(e.executionAttemptId);if(t===void 0)return{kind:`not-found`};if(t.settlementKind!=null)return{kind:`resolved`};let n=u(t,e);return n===null?(N.set(t.executionAttemptId,{...t,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null,lastCompletedOperationId:e.operationId}),{kind:`completed`}):n},async markRuntimeReady(e){let t=v(e.readyAt),n=N.get(e.executionAttemptId);if(n===void 0||n.executionId!==e.executionId)return{kind:`not-found`};let r=z(n)??i(n,e);return r===null?(N.set(n.executionAttemptId,{...n,runtimeReadyAt:t}),{kind:`ready`,acceptedAt:t}):r},async getAttemptControlState(e){let t=N.get(e);return t===void 0?null:x(t)},async getActiveAttempt(e,t){return L.get(e)===t?N.get(t)??null:null},canonicalizeOutcome(e){return t(j,e)},decodeOutcome(e){return d(j,e)},async commitOutcome(e){let t=e.result;if(L.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};let n=N.get(e.executionAttemptId);if(n===void 0)return{kind:`fenced`};let r=I.get(e.executionAttemptId);if(r!==void 0){let e=d(j,r);return f(r,t.text)?{kind:`duplicate`,outcome:e,text:r}:{kind:`conflict`}}if(n.settlementKind!=null)return{kind:`conflict`};l(n,e.runtimeFence),I.set(e.executionAttemptId,t.text),N.set(e.executionAttemptId,K(n,`outcome`));let i=P.get(e.executionAttemptId);return i&&V(i,i.lastFailure),{kind:`accepted`,outcome:d(j,t.text),text:t.text}},async abandonPendingAttempt(e,t){if(L.get(t)!==e)return{kind:`fenced`};let n=N.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`}:(N.set(e,K(n,`abandoned`)),{kind:`abandoned`}):{kind:`fenced`}},recovery:U,attempts:N,operations:P,committedOutcomes:I,activeAttempts:L,requestBindings:R}}export{k as INITIAL_ATTEMPT_CONTROL_STATE,U as TEST_OWNER_ID,R as TEST_PROVIDER_ID,V as TEST_PROVISIONER_INCARNATION_ID,F as allocateTestAttempt,j as beginTestProvisioning,q as createInMemoryAttemptRepository,z as driveTestAttemptToAllocated,H as leaseAt,M as makeBeginProvisioningInput,I as makeEvidence,W as makeProcessLossProof,N as makeTestAllocationRef,P as makeTestInstruction,B as makeTestWorkflowResult,L as workflowRunResultOutcomeCodec};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ExecutionAttemptRepository, P as OutcomeCodec } from "../../execution-attempt-repository-
|
|
1
|
+
import { C as ExecutionAttemptRepository, P as OutcomeCodec } from "../../execution-attempt-repository-CtFZfBfp.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,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as
|
|
1
|
+
import{_ as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as ee,o as te,p as ne,r as l,s as u,t as d,u as f}from"../../execution-attempt-repository-D_qR7NyG.mjs";import{a as re,i as ie,n as ae,o as p,t as oe}from"../../execution-attempt-owner-recovery-BNERIDH0.mjs";import{PROVIDER_OPERATION_OBLIGATIONS as m}from"../provider-operation.mjs";import{a as h,c as g,d as se,i as _,l as v,o as y,p as b,r as x,s as ce,t as le,u as ue}from"../../attempt-record-codec-CqKq0NIB.mjs";import{BoundedRecoveryEvidenceSchema as S,ExecutionAttemptOperationKindSchema as C,ProviderAllocationRefSchema as w,WorkerAllocationLifetimeSchema as T}from"@makaio/framework/contracts";import{getRawSqlExecutor as de,isSqliteUniqueViolationError as E,serializeByKey as D,serializeDatabaseOperation as O}from"@makaio/framework/storage/drizzle";import{sql as k}from"drizzle-orm";const A=[`CREATE TABLE IF NOT EXISTS test_execution_attempt (
|
|
2
2
|
execution_attempt_id TEXT PRIMARY KEY,
|
|
3
3
|
execution_id TEXT NOT NULL,
|
|
4
4
|
instruction TEXT NOT NULL,
|
|
@@ -28,6 +28,12 @@ import{_ as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o a
|
|
|
28
28
|
execution_id TEXT PRIMARY KEY,
|
|
29
29
|
execution_attempt_id TEXT NOT NULL
|
|
30
30
|
REFERENCES test_execution_attempt(execution_attempt_id)
|
|
31
|
+
)`,`CREATE TABLE IF NOT EXISTS test_execution_attempt_request (
|
|
32
|
+
execution_id TEXT NOT NULL,
|
|
33
|
+
request_key TEXT NOT NULL,
|
|
34
|
+
execution_attempt_id TEXT NOT NULL
|
|
35
|
+
REFERENCES test_execution_attempt(execution_attempt_id),
|
|
36
|
+
PRIMARY KEY (execution_id, request_key)
|
|
31
37
|
)`,`CREATE TABLE IF NOT EXISTS test_provider_operation (
|
|
32
38
|
execution_attempt_id TEXT PRIMARY KEY
|
|
33
39
|
REFERENCES test_execution_attempt(execution_attempt_id),
|
|
@@ -38,50 +44,63 @@ import{_ as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o a
|
|
|
38
44
|
obligation TEXT NOT NULL,
|
|
39
45
|
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
40
46
|
last_failure TEXT
|
|
41
|
-
)`];function
|
|
47
|
+
)`];function j(e,t,n){let r=e.find(e=>e===t);if(r===void 0)throw Error(`Stored '${n}' value '${t}' is not part of the port's vocabulary`);return r}function M(e,t){return e===null?null:t(JSON.parse(e))}function N(e){return{runtimeGeneration:e.runtime_generation,runtimeIncarnationId:e.runtime_incarnation_id,runtimeReadyAt:e.runtime_ready_at,operationStartGate:j(d,e.operation_start_gate,`operation_start_gate`),activeOperationId:e.active_operation_id,activeOperationKind:e.active_operation_kind===null?null:C.parse(e.active_operation_kind),activeOperationKey:e.active_operation_key,activeOperationGeneration:e.active_operation_generation,activeOperationAdmittedAt:e.active_operation_admitted_at,lastCompletedOperationId:e.last_completed_operation_id}}function P(e){return{...N(e),executionAttemptId:e.execution_attempt_id,executionId:e.execution_id,instruction:p(JSON.parse(e.instruction)),preparationReceipts:v(JSON.parse(e.preparation_receipts)),status:j(o,e.status,`status`),allocationRef:M(e.allocation_ref,e=>w.parse(e)),createdAt:e.created_at,bootstrapDeadlineAt:e.bootstrap_deadline_at,providerId:e.provider_id,allocationLifetime:e.allocation_lifetime===null?null:T.parse(e.allocation_lifetime),provisionerIncarnationId:e.provisioner_incarnation_id,settlementKind:e.settlement_kind===null?null:j(l,e.settlement_kind,`settlement_kind`),claimable:e.claimable!==0,claimExpiresAt:e.claim_expires_at}}function fe(e){return{executionAttemptId:e.execution_attempt_id,generation:e.generation,ownerId:e.owner_id,token:e.token,leaseExpiresAt:e.lease_expires_at,obligation:j(m,e.obligation,`obligation`),failureCount:e.failure_count,lastFailure:M(e.last_failure,e=>S.parse(e))}}const F=new Map,I=new Map;function L(e){if(typeof e!=`object`||!e)return!1;let t=e,n=typeof t.message==`string`?t.message:``;return n.includes(`SQLITE_BUSY`)||n.startsWith(`Failed query: BEGIN IMMEDIATE`)||n.startsWith(`Failed query: COMMIT`)||L(t.cause)}function R(e){if(typeof e!=`object`||!e)return!1;let t=e;return(typeof t.message==`string`?t.message:``).includes(`no transaction is active`)||R(t.cause)}async function z(){await new Promise(e=>setImmediate(e))}async function B(e){for(let t=0;;t+=1)try{await e.run(k.raw(`COMMIT`));return}catch(e){if(!L(e)||t===100)throw e;await z()}}async function pe(e,t){return D(F,e,t)}async function me(e,t){return D(I,e,t)}const V=new WeakMap;async function he(e,t){let n=(await t.all(k.raw(`PRAGMA database_list`))).find(e=>e.name===`main`)?.file??null;if(n!==null&&n!==``)return`file:${n}`;let r=V.get(e);if(r!==void 0)return r;let i=`connection:${crypto.randomUUID()}`;return V.set(e,i),i}async function H(e,t){let n=await e();if(typeof n!=`function`)return n;if((await n()).rowsAffected>0)return t;let r=await e();if(typeof r!=`function`)return r;throw Error(`A guarded transition affected no rows while durable state still permitted it`)}function U(e){return k`EXISTS (SELECT 1 FROM test_provider_operation
|
|
42
48
|
WHERE execution_attempt_id = ${e.executionAttemptId}
|
|
43
49
|
AND generation = ${e.generation}
|
|
44
50
|
AND owner_id = ${e.ownerId}
|
|
45
|
-
AND token = ${e.token})`}function
|
|
46
|
-
WHERE execution_attempt_id = ${e} AND settlement_kind IS NULL)`}function
|
|
51
|
+
AND token = ${e.token})`}function W(e){return k`EXISTS (SELECT 1 FROM test_execution_attempt
|
|
52
|
+
WHERE execution_attempt_id = ${e} AND settlement_kind IS NULL)`}function G(e){return k`${U(e)} AND ${W(e.executionAttemptId)}`}function K(e){return k`EXISTS (SELECT 1 FROM test_provider_operation
|
|
47
53
|
WHERE execution_attempt_id = ${e}
|
|
48
|
-
AND obligation = ${`terminal-convergence`})`}function
|
|
54
|
+
AND obligation = ${`terminal-convergence`})`}function q(){return k`EXISTS (SELECT 1 FROM test_active_execution_attempt
|
|
49
55
|
WHERE execution_id = test_execution_attempt.execution_id
|
|
50
|
-
AND execution_attempt_id = test_execution_attempt.execution_attempt_id)`}async function
|
|
56
|
+
AND execution_attempt_id = test_execution_attempt.execution_attempt_id)`}async function J(o,l){let C=de(o);await C.run(k.raw(`PRAGMA busy_timeout = 0`));let w=await he(o,C);await pe(w,async()=>{for(let e of A)await C.run(k.raw(e));(await C.all(k.raw(`PRAGMA table_info(test_execution_attempt)`))).some(e=>e.name===`bootstrap_deadline_at`)||await C.run(k.raw(`ALTER TABLE test_execution_attempt ADD COLUMN bootstrap_deadline_at TEXT`))});let T,D=async e=>O(o,()=>me(w,async()=>{if(T!==void 0)throw Error(`This repository was retired by a failed transaction rollback`,{cause:T});for(let t=0;;t+=1)try{return await C.withSession(async t=>{let n=!1;try{await t.run(k.raw(`BEGIN IMMEDIATE`)),n=!0;let r=await e(t);return await B(t),r}catch(e){try{await t.run(k.raw(`ROLLBACK`))}catch(t){throw!n&&R(t)?e:(T=AggregateError([e,t],`Transaction rollback failed`),T)}throw e}})}catch(e){if(!L(e)||t===100)throw e;await z()}})),M=async(e,t)=>(await e.all(k`SELECT * FROM test_execution_attempt WHERE execution_attempt_id = ${t}`))[0],F=async(e,t)=>(await e.all(k`SELECT * FROM test_provider_operation WHERE execution_attempt_id = ${t}`))[0],I=async(e,t)=>(await F(e,t))?.obligation===`terminal-convergence`,V=async(e,t)=>(await e.all(k`SELECT execution_attempt_id FROM test_active_execution_attempt WHERE execution_id = ${t}`))[0]?.execution_attempt_id??null,J=async(e,t)=>{let r=t.settlement_kind!==null,i=!r&&await V(e,t.execution_id)===t.execution_attempt_id;return n({matchesExecution:!0,settled:r,active:i,allocated:i&&t.allocation_ref!==null&&!await I(e,t.execution_attempt_id)})},Y=async(e,t)=>{let n=await M(e,t.executionAttemptId),r=await F(e,t.executionAttemptId);if(n===void 0||r===void 0)return{kind:`not-found`};let i=P(n);return i.settlementKind==null?r.token===null||r.token!==t.token||r.generation!==t.generation||r.owner_id!==t.ownerId?{kind:`stale`,attempt:i}:{kind:`authorized`,attempt:i,attemptRow:n,operation:r}:{kind:`resolved`,attempt:i}},X=async(e,t)=>{let n=await Y(e,t);return n.kind===`authorized`?void 0:{kind:n.kind}},Z=async(e,t,n,r,i)=>{let a=await e.run(k`UPDATE test_execution_attempt
|
|
51
57
|
SET status = ${`settled`}, settlement_kind = ${n}, claimable = ${0},
|
|
52
58
|
operation_start_gate = ${`closed`}
|
|
53
59
|
WHERE execution_attempt_id = ${t}
|
|
54
60
|
AND settlement_kind IS NULL
|
|
55
|
-
AND ${r}`);return a.rowsAffected===0||await e.run(i===void 0?
|
|
61
|
+
AND ${r}`);return a.rowsAffected===0||await e.run(i===void 0?k`UPDATE test_provider_operation
|
|
56
62
|
SET owner_id = NULL, token = NULL, lease_expires_at = NULL
|
|
57
|
-
WHERE execution_attempt_id = ${t}`:
|
|
63
|
+
WHERE execution_attempt_id = ${t}`:k`UPDATE test_provider_operation
|
|
58
64
|
SET owner_id = NULL, token = NULL, lease_expires_at = NULL, last_failure = ${JSON.stringify(i)}
|
|
59
|
-
WHERE execution_attempt_id = ${t}`),a}
|
|
65
|
+
WHERE execution_attempt_id = ${t}`),a},Q=(e,t)=>{let n=ce(e.allocationRef),r=t?k`CASE WHEN ${q()} THEN 1 ELSE 0 END`:k`${0}`;return D(t=>H(async()=>{let i=await Y(t,e.claim);if(i.kind!==`not-found`&&se(i.attempt,n),i.kind===`resolved`)return{kind:`resolved`,allocationRef:i.attempt.allocationRef};if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:a}=i;return a.allocationRef===null?async()=>{let i=await t.run(k`UPDATE test_execution_attempt
|
|
60
66
|
SET status = ${`allocated`},
|
|
61
67
|
allocation_ref = ${JSON.stringify(n)},
|
|
62
68
|
claimable = ${r}
|
|
63
69
|
WHERE execution_attempt_id = ${a.executionAttemptId}
|
|
64
70
|
AND allocation_ref IS NULL
|
|
65
|
-
AND ${
|
|
66
|
-
WHERE execution_attempt_id = ${a.executionAttemptId}`),i}:s(a.allocationRef,n)?{kind:`duplicate`,allocationRef:a.allocationRef}:{kind:`conflict`,allocationRef:a.allocationRef}},{kind:`recorded`}))}
|
|
71
|
+
AND ${G(e.claim)}`);return i.rowsAffected===0||await t.run(k`UPDATE test_provider_operation SET obligation = ${`allocation-control`}
|
|
72
|
+
WHERE execution_attempt_id = ${a.executionAttemptId}`),i}:s(a.allocationRef,n)?{kind:`duplicate`,allocationRef:a.allocationRef}:{kind:`conflict`,allocationRef:a.allocationRef}},{kind:`recorded`}))},ge={async getAttemptWithAllocation(e){return D(async t=>{let n=await M(t,e);return n===void 0?null:P(n)})},async recordDiscoveredAllocation(e){return Q(e,!1)},async evolveAllocationRef(e){let{currentRef:t,nextRef:n}=g(e);return D(r=>H(async()=>{let i=await Y(r,e.claim);if(i.kind===`stale`)return{kind:`stale`,storedRef:i.attempt.allocationRef};if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:a,attemptRow:o}=i;return a.executionId===e.executionId?a.allocationRef===null?{kind:`not-allocated`}:s(a.allocationRef,t)?()=>r.run(k`UPDATE test_execution_attempt SET allocation_ref = ${JSON.stringify(n)}
|
|
73
|
+
WHERE execution_attempt_id = ${a.executionAttemptId}
|
|
74
|
+
AND execution_id = ${e.executionId}
|
|
75
|
+
AND allocation_ref = ${o.allocation_ref}
|
|
76
|
+
AND ${G(e.claim)}`):{kind:`stale`,storedRef:a.allocationRef}:{kind:`not-found`}},{kind:`evolved`}))},async getRecoverableAttempts(e){return D(async t=>{let n=new Date().toISOString();return(await t.all(k`SELECT * FROM test_execution_attempt
|
|
77
|
+
WHERE execution_id = ${e}
|
|
78
|
+
AND status = ${`allocated`}
|
|
79
|
+
AND settlement_kind IS NULL
|
|
80
|
+
AND allocation_ref IS NOT NULL
|
|
81
|
+
AND claimable = ${1}
|
|
82
|
+
AND (claim_expires_at IS NULL OR claim_expires_at >= ${n})
|
|
83
|
+
ORDER BY created_at ASC, execution_attempt_id ASC`)).map(e=>b(P(e)))})}},$=async(e,t,n)=>{let{instruction:r}=t,{createdAt:i,bootstrapDeadlineAt:a}=n;try{await e.run(k`INSERT INTO test_execution_attempt
|
|
67
84
|
(execution_attempt_id, execution_id, instruction, status, claimable, created_at, bootstrap_deadline_at)
|
|
68
|
-
VALUES (${
|
|
85
|
+
VALUES (${t.executionAttemptId}, ${t.executionId}, ${JSON.stringify(r)}, ${`pending`}, ${0}, ${i}, ${a})`)}catch(e){throw E(e)?new ee(t.executionAttemptId,{cause:e}):e}return await e.run(k`UPDATE test_execution_attempt
|
|
69
86
|
SET claimable = ${0}
|
|
70
87
|
WHERE execution_attempt_id = (
|
|
71
88
|
SELECT execution_attempt_id
|
|
72
89
|
FROM test_active_execution_attempt
|
|
73
|
-
WHERE execution_id = ${
|
|
90
|
+
WHERE execution_id = ${t.executionId}
|
|
74
91
|
)
|
|
75
|
-
AND status = ${`allocated`}`),await
|
|
92
|
+
AND status = ${`allocated`}`),await e.run(k`UPDATE test_execution_attempt
|
|
76
93
|
SET operation_start_gate = ${`closed`}
|
|
77
94
|
WHERE execution_attempt_id = (
|
|
78
95
|
SELECT execution_attempt_id
|
|
79
96
|
FROM test_active_execution_attempt
|
|
80
|
-
WHERE execution_id = ${
|
|
81
|
-
)`),await
|
|
82
|
-
VALUES (${
|
|
97
|
+
WHERE execution_id = ${t.executionId}
|
|
98
|
+
)`),await e.run(k`INSERT INTO test_active_execution_attempt (execution_id, execution_attempt_id)
|
|
99
|
+
VALUES (${t.executionId}, ${t.executionAttemptId})
|
|
83
100
|
ON CONFLICT(execution_id)
|
|
84
|
-
DO UPDATE SET execution_attempt_id = excluded.execution_attempt_id`),{...
|
|
101
|
+
DO UPDATE SET execution_attempt_id = excluded.execution_attempt_id`),{...le,executionAttemptId:t.executionAttemptId,executionId:t.executionId,instruction:r,preparationReceipts:Object.freeze([]),status:`pending`,allocationRef:null,createdAt:i,bootstrapDeadlineAt:a,providerId:null,allocationLifetime:null,provisionerIncarnationId:null,settlementKind:null,claimable:!1,claimExpiresAt:null}};return{async createAttempt(e){let t={...e,instruction:p(e.instruction)},n=x(e.bootstrapTimeoutMs);return D(e=>$(e,t,n))},async ensureAttempt(e){let t=ie(e);return D(async e=>{let n=(await e.all(k`SELECT execution_attempt_id FROM test_execution_attempt_request
|
|
102
|
+
WHERE execution_id = ${t.executionId} AND request_key = ${t.requestKey}`))[0];if(n!==void 0){let r=await M(e,n.execution_attempt_id);return ae(t,r===void 0?null:P(r))}let r=await $(e,t,x(t.bootstrapTimeoutMs));return await e.run(k`INSERT INTO test_execution_attempt_request (execution_id, request_key, execution_attempt_id)
|
|
103
|
+
VALUES (${t.executionId}, ${t.requestKey}, ${r.executionAttemptId})`),{kind:`created`,attempt:structuredClone(r)}})},async readAttemptSettlement(e){let t=re(e);return D(async e=>{let n=await M(e,t.executionAttemptId);return n===void 0||n.execution_id!==t.executionId?{kind:`not-found`}:oe(t,{attempt:P(n),activeAttemptId:await V(e,t.executionId),outcomeText:n.workflow_result},l)})},async readBootstrapStartState(e){return D(async t=>{let n=await M(t,e.executionAttemptId);return n===void 0||n.execution_id!==e.executionId?null:{settled:n.settlement_kind!==null,active:await V(t,e.executionId)===e.executionAttemptId,allocated:n.allocation_ref!==null,allocationTerminated:await I(t,e.executionAttemptId),operationStartGate:j(d,n.operation_start_gate,`operation_start_gate`),bootstrapDeadlineAt:n.bootstrap_deadline_at}})},async beginProvisioning(e){let t=y(e.allocationLifetime),n={executionAttemptId:e.executionAttemptId,generation:1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:h(e.leaseExpiresAt)};return D(r=>H(async()=>{let i=await M(r,e.executionAttemptId);if(i===void 0||i.execution_id!==e.executionId)return{kind:`not-found`};let a=P(i);return await V(r,e.executionId)===e.executionAttemptId?a.settlementKind==null?a.allocationRef===null?a.status===`pending`?async()=>{let i=await r.run(k`UPDATE test_execution_attempt
|
|
85
104
|
SET status = ${`provisioning`},
|
|
86
105
|
provider_id = ${e.providerId},
|
|
87
106
|
allocation_lifetime = ${t},
|
|
@@ -91,42 +110,42 @@ import{_ as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o a
|
|
|
91
110
|
AND status = ${`pending`}
|
|
92
111
|
AND allocation_ref IS NULL
|
|
93
112
|
AND settlement_kind IS NULL
|
|
94
|
-
AND ${
|
|
113
|
+
AND ${q()}`);return i.rowsAffected===0||await r.run(k`INSERT INTO test_provider_operation
|
|
95
114
|
(execution_attempt_id, generation, owner_id, token, lease_expires_at, obligation, failure_count)
|
|
96
115
|
VALUES (${e.executionAttemptId}, ${n.generation}, ${n.ownerId}, ${n.token},
|
|
97
|
-
${n.leaseExpiresAt}, ${`provisioning-resolution`}, ${0})`),i}:{kind:`already-provisioning`}:{kind:`allocated`,allocationRef:a.allocationRef}:{kind:`resolved`,allocationRef:a.allocationRef}:{kind:`fenced`}},{kind:`started`,claim:n}))},async getProviderOperation(e){return D(async t=>{let n=await F(t,e);return n===void 0?null:
|
|
116
|
+
${n.leaseExpiresAt}, ${`provisioning-resolution`}, ${0})`),i}:{kind:`already-provisioning`}:{kind:`allocated`,allocationRef:a.allocationRef}:{kind:`resolved`,allocationRef:a.allocationRef}:{kind:`fenced`}},{kind:`started`,claim:n}))},async getProviderOperation(e){return D(async t=>{let n=await F(t,e);return n===void 0?null:fe(n)})},async renewProviderOperationClaim(e){let t=h(e.leaseExpiresAt);return D(n=>H(async()=>await X(n,e.claim)??(()=>n.run(k`UPDATE test_provider_operation SET lease_expires_at = ${t}
|
|
98
117
|
WHERE execution_attempt_id = ${e.claim.executionAttemptId}
|
|
99
|
-
AND ${
|
|
118
|
+
AND ${G(e.claim)}`)),{kind:`claimed`,claim:{...e.claim,leaseExpiresAt:t}}))},async takeOverProviderOperation(e){return D(async t=>{let n=await M(t,e.executionAttemptId),r=await F(t,e.executionAttemptId);if(n===void 0||r===void 0)return{kind:`not-found`};if(n.settlement_kind!==null)return{kind:`resolved`};if(r.owner_id!==null&&r.lease_expires_at!==null&&_(r.lease_expires_at)>_(e.observedAt))return{kind:`stale`};let i={executionAttemptId:e.executionAttemptId,generation:r.generation+1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:h(e.leaseExpiresAt)},{rowsAffected:a}=await t.run(k`UPDATE test_provider_operation
|
|
100
119
|
SET generation = ${i.generation}, owner_id = ${i.ownerId}, token = ${i.token},
|
|
101
120
|
lease_expires_at = ${i.leaseExpiresAt}
|
|
102
121
|
WHERE execution_attempt_id = ${e.executionAttemptId}
|
|
103
122
|
AND generation = ${r.generation}
|
|
104
|
-
AND ${
|
|
123
|
+
AND ${W(e.executionAttemptId)}`);return a===0?{kind:`stale`}:{kind:`claimed`,claim:i}})},async handoffProviderOperation(e){let t=e.evidence===void 0?null:S.parse(e.evidence);return D(n=>H(async()=>await X(n,e.claim)??(()=>n.run(t===null?k`UPDATE test_provider_operation
|
|
105
124
|
SET owner_id = NULL, token = NULL, lease_expires_at = NULL
|
|
106
125
|
WHERE execution_attempt_id = ${e.claim.executionAttemptId}
|
|
107
|
-
AND ${
|
|
126
|
+
AND ${G(e.claim)}`:k`UPDATE test_provider_operation
|
|
108
127
|
SET owner_id = NULL, token = NULL, lease_expires_at = NULL,
|
|
109
128
|
last_failure = ${JSON.stringify(t)}
|
|
110
129
|
WHERE execution_attempt_id = ${e.claim.executionAttemptId}
|
|
111
|
-
AND ${
|
|
130
|
+
AND ${G(e.claim)}`)),{kind:`recorded`}))},async recordProviderOperationUncertainty(e){let t=S.parse(e.evidence);return D(n=>H(async()=>await X(n,e.claim)??(()=>n.run(k`UPDATE test_provider_operation
|
|
112
131
|
SET failure_count = failure_count + 1, last_failure = ${JSON.stringify(t)}
|
|
113
132
|
WHERE execution_attempt_id = ${e.claim.executionAttemptId}
|
|
114
|
-
AND ${
|
|
133
|
+
AND ${G(e.claim)}`)),{kind:`recorded`}))},async recordAllocation(e){return Q(e,!0)},async recordProvisioningAbsent(e){let t=S.parse(e.evidence);return D(n=>H(async()=>{let r=await Y(n,e.claim);if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i}=r;return i.executionId===e.executionId?i.allocationRef===null?()=>Z(n,i.executionAttemptId,`abandoned`,k`execution_id = ${e.executionId}
|
|
115
134
|
AND allocation_ref IS NULL
|
|
116
|
-
AND ${
|
|
135
|
+
AND ${U(e.claim)}`,t):{kind:`allocated`,allocationRef:i.allocationRef}:{kind:`not-found`}},{kind:`recorded`}))},async recordProvisionerIncarnationLost(e){let t=S.parse(e.proof.evidence);return D(n=>H(async()=>{let r=await Y(n,e.claim);if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i}=r,o=a(i,e);return o===null?()=>Z(n,i.executionAttemptId,`abandoned`,k`execution_id = ${e.executionId}
|
|
117
136
|
AND allocation_ref IS NULL
|
|
118
137
|
AND allocation_lifetime = ${`provisioner-process-bound`}
|
|
119
138
|
AND provisioner_incarnation_id = ${e.proof.provisionerIncarnationId}
|
|
120
|
-
AND ${
|
|
139
|
+
AND ${U(e.claim)}`,t):o},{kind:`recorded`}))},async recordAllocationTerminated(e){let t=S.parse(e.evidence);return D(n=>H(async()=>{let r=await Y(n,e.claim);if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i}=r;return i.allocationRef===null?{kind:`not-allocated`}:()=>n.run(k`UPDATE test_provider_operation
|
|
121
140
|
SET obligation = ${`terminal-convergence`}, last_failure = ${JSON.stringify(t)}
|
|
122
141
|
WHERE execution_attempt_id = ${i.executionAttemptId}
|
|
123
|
-
AND ${
|
|
142
|
+
AND ${G(e.claim)}
|
|
124
143
|
AND EXISTS (SELECT 1 FROM test_execution_attempt
|
|
125
144
|
WHERE execution_attempt_id = ${i.executionAttemptId}
|
|
126
|
-
AND allocation_ref IS NOT NULL)`)},{kind:`recorded`}))},async recordInfrastructureFailure(e){return D(t=>
|
|
145
|
+
AND allocation_ref IS NOT NULL)`)},{kind:`recorded`}))},async recordInfrastructureFailure(e){return D(t=>H(async()=>{let n=await Y(t,e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.allocationRef===null?{kind:`not-allocated`}:j(m,i.obligation,`obligation`)===`terminal-convergence`?()=>Z(t,r.executionAttemptId,`infrastructure-failure`,k`execution_id = ${e.executionId}
|
|
127
146
|
AND allocation_ref IS NOT NULL
|
|
128
|
-
AND ${
|
|
129
|
-
AND ${
|
|
147
|
+
AND ${K(r.executionAttemptId)}
|
|
148
|
+
AND ${U(e.claim)}`):{kind:`not-terminated`}:{kind:`not-found`}},{kind:`recorded`}))},async registerRuntime(t){return D(async n=>{let r=0,i=await H(async()=>{let i=await M(n,t.executionAttemptId);if(i===void 0||i.execution_id!==t.executionId)return{kind:`not-found`};let a=await J(n,i);if(a!==null)return a;let o=N(i),s=e(o,t);return s===null?(r=o.runtimeGeneration+1,()=>n.run(k`UPDATE test_execution_attempt
|
|
130
149
|
SET runtime_generation = ${r},
|
|
131
150
|
runtime_incarnation_id = ${t.runtimeIncarnationId},
|
|
132
151
|
runtime_ready_at = NULL,
|
|
@@ -141,8 +160,8 @@ import{_ as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o a
|
|
|
141
160
|
AND settlement_kind IS NULL
|
|
142
161
|
AND (active_operation_id IS NULL OR active_operation_kind = ${`runtime-probe`})
|
|
143
162
|
AND allocation_ref IS NOT NULL
|
|
144
|
-
AND NOT ${
|
|
145
|
-
AND ${
|
|
163
|
+
AND NOT ${K(t.executionAttemptId)}
|
|
164
|
+
AND ${q()}`)):s},{kind:`applied`});return i.kind===`applied`?{kind:`registered`,runtimeGeneration:r}:i})},async admitOperation(e){let t=crypto.randomUUID(),n=h(new Date().toISOString()),i=e.operationKind===`runtime-probe`?k`1 = 1`:k`runtime_ready_at IS NOT NULL`;return D(a=>H(async()=>{let o=await M(a,e.executionAttemptId);if(o===void 0||o.execution_id!==e.executionId)return{kind:`not-found`};let s=await J(a,o);if(s!==null)return s;let c=r(N(o),e,n,P(o));return c===null?()=>a.run(k`UPDATE test_execution_attempt
|
|
146
165
|
SET active_operation_id = ${t},
|
|
147
166
|
active_operation_kind = ${e.operationKind},
|
|
148
167
|
active_operation_key = ${e.admissionKey},
|
|
@@ -157,9 +176,9 @@ import{_ as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o a
|
|
|
157
176
|
AND preparation_receipts = ${o.preparation_receipts}
|
|
158
177
|
AND settlement_kind IS NULL
|
|
159
178
|
AND allocation_ref IS NOT NULL
|
|
160
|
-
AND NOT ${
|
|
179
|
+
AND NOT ${K(e.executionAttemptId)}
|
|
161
180
|
AND ${i}
|
|
162
|
-
AND ${
|
|
181
|
+
AND ${q()}`):c},{kind:`admitted`,operationId:t,runtimeGeneration:e.runtimeGeneration,admittedAt:n}))},async getInstruction(e){return D(async t=>{let n=await M(t,e.executionAttemptId);return n?.execution_id===e.executionId?p(JSON.parse(n.instruction)):null})},async reportOperation(e){let t=ue(e.result);return D(n=>H(async()=>{let r=await M(n,e.executionAttemptId);if(r===void 0||r.execution_id!==e.executionId)return{kind:`not-found`};let i=P(r),a=c({matchesExecution:!0,settled:r.settlement_kind!==null,active:await V(n,e.executionId)===e.executionAttemptId,allocated:r.allocation_ref!==null&&!await I(n,e.executionAttemptId)},i,i,{...e,result:t});if(a!==null)return a;let o=v([...i.preparationReceipts,{operationId:e.operationId,runtimeGeneration:e.runtimeGeneration,result:t}]);return()=>n.run(k`UPDATE test_execution_attempt
|
|
163
182
|
SET preparation_receipts = ${JSON.stringify(o)},
|
|
164
183
|
active_operation_id = NULL,
|
|
165
184
|
active_operation_kind = NULL,
|
|
@@ -177,8 +196,8 @@ import{_ as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o a
|
|
|
177
196
|
AND instruction = ${r.instruction}
|
|
178
197
|
AND preparation_receipts = ${r.preparation_receipts}
|
|
179
198
|
AND allocation_ref IS NOT NULL
|
|
180
|
-
AND NOT ${
|
|
181
|
-
AND ${
|
|
199
|
+
AND NOT ${K(e.executionAttemptId)}
|
|
200
|
+
AND ${q()}`)},{kind:`accepted`,binding:t.binding}))},async completeOperation(e){return D(t=>H(async()=>{let n=await M(t,e.executionAttemptId);if(n===void 0)return{kind:`not-found`};if(n.settlement_kind!==null)return{kind:`resolved`};let r=ne(N(n),e);return r===null?()=>t.run(k`UPDATE test_execution_attempt
|
|
182
201
|
SET active_operation_id = NULL,
|
|
183
202
|
active_operation_kind = NULL,
|
|
184
203
|
active_operation_key = NULL,
|
|
@@ -189,7 +208,7 @@ import{_ as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o a
|
|
|
189
208
|
AND settlement_kind IS NULL
|
|
190
209
|
AND active_operation_id = ${e.operationId}
|
|
191
210
|
AND active_operation_kind IN (${`runtime-probe`}, ${`workflow-run`})
|
|
192
|
-
AND active_operation_generation = ${e.runtimeGeneration}`):r},{kind:`completed`}))},async markRuntimeReady(e){let t=h(e.readyAt);return D(n=>
|
|
211
|
+
AND active_operation_generation = ${e.runtimeGeneration}`):r},{kind:`completed`}))},async markRuntimeReady(e){let t=h(e.readyAt);return D(n=>H(async()=>{let r=await M(n,e.executionAttemptId);if(r===void 0||r.execution_id!==e.executionId)return{kind:`not-found`};let a=await J(n,r);if(a!==null)return a;let o=i(N(r),e);return o===null?()=>n.run(k`UPDATE test_execution_attempt SET runtime_ready_at = ${t}
|
|
193
212
|
WHERE execution_attempt_id = ${e.executionAttemptId}
|
|
194
213
|
AND execution_id = ${e.executionId}
|
|
195
214
|
AND settlement_kind IS NULL
|
|
@@ -197,31 +216,20 @@ import{_ as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o a
|
|
|
197
216
|
AND runtime_ready_at IS NULL
|
|
198
217
|
AND active_operation_id IS NULL
|
|
199
218
|
AND allocation_ref IS NOT NULL
|
|
200
|
-
AND NOT ${
|
|
201
|
-
AND ${
|
|
219
|
+
AND NOT ${K(e.executionAttemptId)}
|
|
220
|
+
AND ${q()}`):o},{kind:`ready`,acceptedAt:t}))},async getAttemptControlState(e){return D(async t=>{let n=await M(t,e);return n===void 0?null:N(n)})},async getActiveAttempt(e,t){return D(async n=>{if(await V(n,e)!==t)return null;let r=await M(n,t);return r===void 0?null:P(r)})},canonicalizeOutcome(e){return t(l,e)},decodeOutcome(e){return u(l,e)},async commitOutcome(e){let t=e.result,n=e.runtimeFence,r=n===void 0?k`1 = 1`:k`
|
|
202
221
|
runtime_generation = ${n.runtimeGeneration}
|
|
203
|
-
AND ${n.operationId===null?
|
|
204
|
-
AND active_operation_generation = ${n.runtimeGeneration}`}`;return D(i=>
|
|
222
|
+
AND ${n.operationId===null?k`active_operation_id IS NULL`:k`active_operation_id = ${n.operationId}
|
|
223
|
+
AND active_operation_generation = ${n.runtimeGeneration}`}`;return D(i=>H(async()=>{if(await V(i,e.executionId)!==e.executionAttemptId)return{kind:`fenced`};let a=await M(i,e.executionAttemptId);if(a===void 0)return{kind:`fenced`};let o=a.workflow_result;if(o!==null){let e=u(l,o);return f(o,t.text)?{kind:`duplicate`,outcome:e,text:o}:{kind:`conflict`}}return a.settlement_kind===null?(n!==void 0&&te(N(a),n),async()=>{let n=await i.run(k`UPDATE test_execution_attempt SET workflow_result = ${t.text}
|
|
205
224
|
WHERE execution_attempt_id = ${e.executionAttemptId}
|
|
206
225
|
AND workflow_result IS NULL
|
|
207
226
|
AND settlement_kind IS NULL
|
|
208
227
|
AND ${r}
|
|
209
|
-
AND ${
|
|
228
|
+
AND ${q()}`);return n.rowsAffected===0?n:Z(i,e.executionAttemptId,`outcome`,k`workflow_result IS NOT NULL`)}):{kind:`conflict`}},{kind:`accepted`,outcome:u(l,t.text),text:t.text}))},async abandonPendingAttempt(e,t){return D(n=>H(async()=>{if(await V(n,t)!==e)return{kind:`fenced`};let r=await M(n,e);if(r===void 0)return{kind:`fenced`};let i=P(r);return i.status===`allocated`?{kind:`allocated`}:i.status===`provisioning`?{kind:`provisioning`}:i.status===`settled`?{kind:i.settlementKind===`abandoned`?`already-abandoned`:`already-settled`}:()=>n.run(k`UPDATE test_execution_attempt
|
|
210
229
|
SET status = ${`settled`}, settlement_kind = ${`abandoned`}, claimable = ${0},
|
|
211
230
|
operation_start_gate = ${`closed`}
|
|
212
231
|
WHERE execution_attempt_id = ${e}
|
|
213
232
|
AND execution_id = ${t}
|
|
214
233
|
AND status = ${`pending`}
|
|
215
234
|
AND settlement_kind IS NULL
|
|
216
|
-
AND ${
|
|
217
|
-
WHERE execution_attempt_id = ${a.executionAttemptId}
|
|
218
|
-
AND execution_id = ${e.executionId}
|
|
219
|
-
AND allocation_ref = ${o.allocation_ref}
|
|
220
|
-
AND ${K(e.claim)}`):{kind:`stale`,storedRef:a.allocationRef}:{kind:`not-found`}},{kind:`evolved`}))},async getRecoverableAttempts(e){return D(async t=>{let n=new Date().toISOString();return(await t.all(O`SELECT * FROM test_execution_attempt
|
|
221
|
-
WHERE execution_id = ${e}
|
|
222
|
-
AND status = ${`allocated`}
|
|
223
|
-
AND settlement_kind IS NULL
|
|
224
|
-
AND allocation_ref IS NOT NULL
|
|
225
|
-
AND claimable = ${1}
|
|
226
|
-
AND (claim_expires_at IS NULL OR claim_expires_at >= ${n})
|
|
227
|
-
ORDER BY created_at ASC, execution_attempt_id ASC`)).map(e=>v(N(e)))})}}}}export{Y as createSqliteAttemptRepository};
|
|
235
|
+
AND ${q()}`)},{kind:`abandoned`}))},recovery:ge}}export{J as createSqliteAttemptRepository};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as e,L as t,c as n,d as r,i,k as a,l as o,r as s,s as c,t as l,vt as u}from"../authority-state-bootstrap-
|
|
1
|
+
import{H as e,L as t,c as n,d as r,i,k as a,l as o,r as s,s as c,t as l,vt as u}from"../authority-state-bootstrap-rnsTk0u7.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(e.setExecution,{execution:a}),r===`completed`?await t.emit(u.execution.completed,{executionId:n.executionId,workflowId:n.workflowId,totalDuration:0,completedAt:a.completedAt}):await t.emit(u.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 n,r=()=>{n=a({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`,r,{once:!0}),e.signal.aborted&&r(),async()=>(e.signal.removeEventListener(`abort`,r),n??!1)}async function _(t,n){let r=await t.requestOptional(e.getExecution,{executionId:n});return r.handled?r.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,r,a,s,c,l,u,f){let m=e.suspensionStrategy===`wait-in-process`?void 0:await x(e.executionId,l,{required:!0}),h=await n({definition:t,execution:r,runContext:a,zodSchema:f?.artifact,bus:l}),g=new o(e.executionId,e.workflowId,t,r,s,l,u,void 0,h,{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},{suspensionStrategy:e.suspensionStrategy,resumeFrames:m,runtimeLoopGates:c}),_=g.buildExpressionContext(),v=await i(t.root,g,_);return v.status===`failed`?{status:`failed`,error:v.error}:v.status===`paused`?{status:`paused`,pausedAtGateId:v.pausedAtGateId,pausedAtFrameId:v.pausedAtFrameId}:v.status===`cancelled`||u.aborted?{status:`cancelled`,reason:d}:{status:`completed`,artifact:h?.current}}async function x(t,n,r={}){try{let i=await n.requestOptional(e.listFrames,{executionId:t});if(!i.handled){if(r.required===!0)throw Error(`Frame storage handler is required to resume execution '${t}'.`);return}return i.data.frames.length===0?void 0:c(i.data.frames)}catch(e){if(r.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(e.setExecution,{execution:r}),await t.emit(u.execution.paused,{executionId:n.executionId,workflowId:n.workflowId,pausedAtGateId:i,pausedAtFrameId:a})}async function w(e,t,n,r,i,a){n===`completed`?await e.emit(u.execution.completed,{executionId:t.executionId,workflowId:t.workflowId,totalDuration:i-r.startedAt,completedAt:i}):n===`cancelled`?await e.emit(u.execution.cancelled,{executionId:t.executionId,workflowId:t.workflowId,reason:d,completedAt:i}):await e.emit(u.execution.failed,{executionId:t.executionId,workflowId:t.workflowId,error:a??`Workflow execution failed`,completedAt:i})}async function T(t){let{config:n,loaded:i,bus:a,signal:o}=t,{definition:c}=i;if(o.aborted)return n.terminalAuthority===`authority`?{executionId:n.executionId,workflowId:n.workflowId,status:`cancelled`,reason:d}:m(a,n,`cancelled`,d);let u=await v(a,n),f=S(n,c);n.terminalAuthority===`authority`?await l(a,f,c):await r(a,u,f,c);let p=new Map(i.runtimeHandlers),_=i.runtimeLoopGates??new Map,y=new Map,x=new Map,T=new Map,E=new Map,D=new Map,O=new Set;y.set(n.executionId,{execution:u,workflow:c,runContext:f,runtimeHandlers:p,runtimeLoopGates:new Map(_)});let k=n.terminalAuthority===`authority`?async()=>!1:g({signal:o,executionId:n.executionId,bus:a,activeExecutions:y,shellAbortControllers:x,activeRunnerSteps:T,durableLifecycleTransitions:E,lifecyclePublications:D,publishingLifecycleExecutions:O}),A={status:`completed`},j=!1;try{c.root.nodes.length>0&&(s(c,_),A=await b(n,c,u,f,p,_,a,o,i.zodSchemas))}catch(e){A={status:`failed`,error:e instanceof Error?e.message:String(e)}}finally{j=await k(),y.clear()}if(j)return h(n,{status:`cancelled`,reason:d});if((o.aborted||u.status===`cancelled`)&&(A={status:`cancelled`,reason:d}),A.status===`paused`)return n.terminalAuthority!==`authority`&&await C(a,n,u,A.pausedAtGateId,A.pausedAtFrameId),h(n,A);if(n.terminalAuthority===`authority`)return h(n,A);let M=Date.now(),N=A.status===`failed`?A.error:void 0;return u.status=A.status,u.completedAt=M,u.error=N,await a.request(e.setExecution,{execution:u}),await w(a,n,A.status,u,M,N),h(n,A)}export{T as runWorkflowOrchestrator};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as e}from"./framework-packages-
|
|
1
|
+
import{u as e}from"./framework-packages-CZJDukan.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,2 @@
|
|
|
1
|
+
import{resolveMakaioHome as e}from"./runtime-node/makaio-config.mjs";import{t}from"./extension-package-provenance-CTYdo0yF.mjs";import{b as n,c as r,g as i,l as a,n as o,u as s,v as c}from"./bootstrap-start-client-BYoxrgMk.mjs";import{mintOrRotateWorkflowExecutionBusSecret as l}from"./runtime-node/workflow-execution-bus-access.mjs";import{z as u}from"zod";import{execFile as d,spawn as f}from"node:child_process";import{promisify as p}from"node:util";import*as m from"node:fs/promises";import{access as ee}from"node:fs/promises";import*as h from"node:path";import{basename as te,isAbsolute as ne,join as g,relative as re}from"node:path";import*as _ from"node:crypto";import{randomUUID as v}from"node:crypto";import{constants as ie}from"node:fs";import{BusAbortError as ae,createBusInstance as y,isRequestCancellation as oe,waitForSubscriptionPropagation as se}from"@makaio/framework/bus";import{AdapterSubjects as ce,BoundedRecoveryEvidenceSchema as le,ExecutionAttemptSchemas as b,ExecutionAttemptSubjects as x,FrameworkContractNamespaces as ue,FrameworkStorageNamespaces as de,JsonValueSchema as fe,PROVIDER_ALLOCATION_REF_VERSION as pe,ProviderAllocationRefSchema as me,RECOVERY_EVIDENCE_LIMITS as S,WorkerCapabilitiesSchema as he,WorkerSchemas as ge,WorkerSubjects as C,WorkflowRunContextSchema as _e,WorkflowRunResultSchema as ve,WorkflowWorkerConfigSchema as ye,createWorkflowCancelSubject as be}from"@makaio/framework/contracts";import{ExtensionCoordinator as xe,KernelSubjects as Se,coalesceExtensionOverrides as Ce,filterEligibleExtensions as we}from"@makaio/framework/kernel";import{BaseService as Te}from"@makaio/framework/service-base";import{AdapterRuntimeSubjects as Ee,registerAdapterRuntimeIdentityHandlers as De}from"@makaio/framework/services/adapter-runtime";import{devNull as w}from"node:os";import{CLIDetectionNamespace as Oe,CLIDetectionSubjects as ke}from"@makaio/framework/services/cli-detection/namespace";import{SessionOrchestratorToken as Ae,ToolRegistryToken as je,canonicalModelPackage as Me,createSubagentServicePackage as Ne,createToolContributionProcessor as Pe,frameworkCorePackages as T,sessionBridgePackage as Fe,sessionOrchestratorPackage as Ie,sessionPackage as Le,sessionStoragePackage as Re,toolRegistryPackage as ze}from"@makaio/framework/services";import{AdapterSubsystemSubjects as Be}from"@makaio/framework/services/adapter-subsystem";import{createClientsCorePackage as Ve}from"@makaio/framework/clients";import{AdapterSubsystemToken as E,createAdapterSubsystemContributionProcessor as He,createAdapterSubsystemPackage as Ue,orderAfterAdapterSubsystem as We}from"@makaio/framework/adapter-subsystem";import{execa as Ge}from"execa";import Ke from"piscina";import{ExecutionAttemptAuthority as qe,WORKFLOW_WORKLOAD_KIND as Je,WORKFLOW_WORKLOAD_VERSION as Ye,WorkflowStorageSubjects as Xe,buildWorkflowAttemptInstruction as Ze,parseWorkflowAttemptInstruction as D,runAuthorityDispatchedAttempt as Qe,toCommittedWorkflowRunnerResult as $e}from"@makaio/framework/workflow-engine";import{runWorkflowOrchestrator as et}from"@makaio/framework/workflow-engine/workflow-orchestrator";import{setTimeout as tt}from"node:timers/promises";function O(e){return e.on(ce.getCapabilities,async t=>{let{adapterName:n,adapterId:r}=t.payload;if(r){await t.next();return}if(n){let r=await e.requestOptional(Ee.resolveId,{adapterName:n}),i=r.handled?r.data.adapterId:void 0;i&&(t.payload.adapterId=i)}await t.next()},{priority:20})}function k(e){let{coordinator:t,configRepository:n,platformDefaults:r,prepareAuthRuntime:i,runtimeSnapshotHandlerPriority:a,runtimeDefinitionHandlerPriority:o}=e,s=Ue({configRepository:n,coordinator:t,platformDefaults:r,...i!==void 0&&{prepareAuthRuntime:i},...a!==void 0&&{runtimeSnapshotHandlerPriority:a},...o!==void 0&&{runtimeDefinitionHandlerPriority:o}});return t.registerContributionProcessor(He({getAdapterSubsystemService:()=>t.getExtensionService(E)})),{adapterSubsystemPackage:s}}function A(e){let{bus:t,currentMachineId:n}=e,r=De(t,{currentMachineId:n,listKnownAdapterNames:e.listKnownAdapterNames??(async()=>{let{configs:e}=await t.request(Be.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=O(t);return{cleanup:()=>{r.cleanup(),i()}}}function j(e,t){if(!(e instanceof Error))return!1;let{rootPackageName:n,subpath:r}=nt(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"`)&&rt(e.message,n)?!0:i.some(t=>e.message.includes(t))}async function M(e){try{return await import(e)}catch(t){if(j(t,e))return null;throw t}}function nt(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 rt(e,t){let n=t,r=t.replaceAll(`/`,`\\`);return e.includes(`/${n}/package.json`)||e.includes(`\\${r}\\package.json`)}async function N(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`?h.extname(e)===``?i:[``,...i]:[``];for(let t of r.split(h.delimiter)){let n=t.replace(/^"|"$/gu,``),r=h.resolve(n||process.cwd());for(let t of a){let n=h.join(r,`${e}${t}`);try{return await ee(n,ie.X_OK),n}catch{}}}}async function P(e,t=5e3,n=1e3){let{stdout:r}=await Ge(e,[`--version`],{forceKillAfterDelay:n,timeout:t});return r}function it(e){return e.match(/(\d+\.\d+\.\d+)/u)?.[1]??`unknown`}async function at(e,t=N,n=P){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:it(i)}}catch{return{binary:e,found:!1}}}async function ot(e,t=N,n=P){return Promise.all(e.map(e=>at(e,t,n)))}var st=class extends Te{constructor(e){super(e)}onInit(){this.registerHandler(ke.scan,async e=>{let t=await ot(e.payload.binaries);e.setResult({results:t})})}};const F={name:`makaio.cli-detection`,displayName:`CLI Detection`,version:`0.1.0`,critical:!0,surface:`any`,namespaces:[Oe],create:e=>new st(e.bus)};function I(e,t){e.push(...ct(t))}function ct(e){return e===void 0?[]:typeof e==`function`?[e]:[...e]}function lt(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 ut(e=[]){return e.some(e=>typeof e==`string`&&e===`node`)?e:[`node`,...e]}function L(e){return Ce(we(ft(e.packages,e.configProvider),e.surface,e.runtimeEnvironment))}function dt(e,n){let r=L(n),i=new Set(r.map(t));return e.filter(({ownerPackage:e})=>i.has(e)).map(({package:e})=>e)}function ft(e,t){return t?e.filter(e=>t.loadEnabled(e.name)!==!1):e}function R(e,t){return e.filter(e=>e.runtimeOwnership?.[t]===!0).map(e=>e.name)}function pt(e,t){let n=R(e,t);if(n.length>1)throw Error(`Multiple extensions own runtimeOwnership.${t}: ${n.join(`, `)}`)}function z(e){return pt(e,`sessionOrchestrator`),R(e,`sessionOrchestrator`).length===0}function mt(e){return e===!0||z(e)?T:T.filter(e=>e.name!==Ae.name)}function B(e,t,n){let r=[];try{for(let i of e){let e=i.runtimeBoot;e&&I(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 ht(){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)}var V=class{pool;constructor(e){this.pool=new Ke({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()}},H=class extends Error{code;constructor(e,t){super(e),this.code=t,this.name=`MaterializationError`}};function U(e,t,n){let r=h.resolve(t)+h.sep,i=h.resolve(e);if(i!==h.resolve(t)&&!i.startsWith(r))throw new H(`${n} escapes allowed root: ${e} is not within ${t}`,`containment-violation`)}async function W(e,t,n,r){let i=r??await m.realpath(t),a;try{a=await m.realpath(e)}catch{return e}let o=i+h.sep;if(a!==i&&!a.startsWith(o))throw new H(`${n} escapes allowed root via symlink: real path ${a} is not within ${i}`,`symlink-escape`);return a}function gt(e){let t=e.indexOf(`-`);if(t===-1)throw new H(`Invalid SRI integrity format: ${e}`,`contribution-integrity-mismatch`);return{algorithm:e.slice(0,t),digest:e.slice(t+1)}}async function _t(e,t){let n=await m.readFile(e);return _.createHash(t).update(n).digest(`base64`)}const G=new Set([`.git`,`node_modules`]);function vt(e){return G.has(e.toLowerCase())}async function yt(e,t){let n=t.toLowerCase();if(!G.has(n))return!1;if(t===n)return!0;try{let[r,i]=await Promise.all([m.lstat(h.join(e,t)),m.lstat(h.join(e,n))]);return r.dev===i.dev&&r.ino===i.ino}catch(e){if(e.code===`ENOENT`)return!1;throw e}}const bt=G,xt=new Set([`.DS_Store`]);async function St(e,t){let n=_.createHash(t),r=[];async function i(t){let n=await m.readdir(t,{withFileTypes:!0});for(let a of n){let n=h.join(t,a.name);if(a.isSymbolicLink())throw new H(`Contribution package contains a symbolic link: ${h.relative(e,n)}`,`symlink-escape`);if(a.isDirectory()){bt.has(a.name)||await i(n);continue}if(a.isFile()){xt.has(a.name)||r.push(h.relative(e,n));continue}throw new H(`Contribution package contains an unsupported filesystem entry: ${h.relative(e,n)}`,`contribution-integrity-mismatch`)}}await i(e),r.sort();for(let t of r)n.update(t.split(h.sep).join(`/`)),n.update(`\0`),n.update(await m.readFile(h.join(e,t))),n.update(`\0`);return`${t}-${n.digest(`base64`)}`}async function Ct(e,t=`sha256`){let n=_.createHash(t),r=[];async function i(t){let n=await m.readdir(t,{withFileTypes:!0});for(let a of n){let n=h.join(t,a.name);if(!await yt(t,a.name)){if(a.isDirectory()){await i(n);continue}if(a.isFile()){r.push(h.relative(e,n));continue}throw a.isSymbolicLink()?new H(`Workspace root contains a symbolic link: ${h.relative(e,n)}`,`symlink-escape`):new H(`Workspace root contains an unsupported filesystem entry: ${h.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 m.readFile(h.join(e,t));n.update(r),n.update(`\0`)}return`${t}-${n.digest(`base64`)}`}async function wt(e,t,n){let r=h.join(t,`node_modules`,e.packageName);U(r,t,`Contribution package directory`),await W(r,t,`Contribution package directory`,n);let i=h.join(r,`package.json`),a;try{a=await m.readFile(i,`utf-8`)}catch{throw new H(`Contribution package not found: ${e.packageName} (expected at ${r})`,`contribution-missing`)}let o=JSON.parse(a);if(o.name!==e.packageName)throw new H(`Contribution identity mismatch: expected ${e.packageName}, found ${o.name??`<none>`}`,`contribution-missing`);if(o.version!==e.version)throw new H(`Contribution version mismatch for ${e.packageName}: expected ${e.version}, found ${o.version??`<none>`}`,`contribution-version-mismatch`);let s=h.join(r,e.entrypoint);U(s,r,`Contribution entrypoint`),await W(s,t,`Contribution entrypoint`,n);try{await m.access(s)}catch{throw new H(`Contribution entrypoint not found for ${e.packageName}: ${e.entrypoint}`,`contribution-entrypoint-mismatch`)}let{algorithm:c}=gt(e.integrity),l;try{l=await St(r,c)}catch(t){if(t instanceof H)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 H(`Contribution package cannot be read for ${e.packageName}`,`contribution-entrypoint-mismatch`):t}if(l!==e.integrity)throw new H(`Contribution integrity mismatch for ${e.packageName}: expected ${e.integrity}, computed ${l}`,`contribution-integrity-mismatch`);return s}async function Tt(e,t,n){let r=await n.resolveWorkspaceRoot(e.workspaceId);if(r===void 0)throw new H(`Unknown workspace ID: ${e.workspaceId}`,`unknown-workspace`);try{if(!(await m.stat(r)).isDirectory())throw new H(`Workspace root is not a directory: ${r}`,`containment-violation`)}catch(e){throw e instanceof H?e:new H(`Workspace root does not exist: ${r}`,`containment-violation`)}let i=await m.realpath(r),a=h.resolve(r,e.sourcePath);if(U(a,r,`Source path`),h.relative(r,a).split(h.sep).some(vt))throw new H(`Workflow source path selects excluded workspace content: ${e.sourcePath}`,`source-path-mismatch`);await W(a,r,`Source path`,i);let o=await Ct(r);if(o!==e.rootDigest)throw new H(`Workspace root digest mismatch: expected ${e.rootDigest}, computed ${o}`,`digest-mismatch`);try{await m.access(a)}catch{throw new H(`Workflow source file not found: ${a}`,`source-missing`)}return{workspaceRoot:r,sourcePath:a,contributionEntrypoints:await Promise.all(t.map(e=>wt(e,r,i))),platform:process.platform,arch:process.arch}}var Et=class{options;manifest;pool;constructor(e){this.options=e,this.manifest=e.manifest}async run(e,t,n){this.pool??=new V(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,r,a){this.pool??=new V(this.options);let o=this.pool,s,c=!1,l,u=new Promise((t,r)=>{l=r,s=o.onMessage(r=>{n(r)&&r.executionAttemptId===a.executionAttemptId&&(r.executionId!==e.executionId||r.cancelSubject!==e.cancelSubject||(c=!0,s?.(),t(r)))})}),d=r??this.manifest,f=i(a.bootstrapDeadlineAt,t,async(t,n)=>{let r=await this.materializeTask(e,d,n);return o.run({...r,kind:`attempt-bound`,executionAttemptId:a.executionAttemptId,bootstrapDeadlineAt:a.bootstrapDeadlineAt,bootstrapPort:t},n,[t])});return f.then(()=>{c||(c=!0,s?.(),l(Error(`Workflow worker completed before ready signal: ${e.executionId}`)))},e=>{c||(c=!0,s?.(),l(e instanceof Error?e:Error(String(e))))}),{result:f,ready:u}}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 Tt(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 Dt(e){return e.mode===`source`?g(e.moduleDir,`workflow-worker`,`worker-entry.ts`):g(e.moduleDir,`workflow-worker`,`worker-entry.mjs`)}var Ot=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=Ze({id:v(),revision:`1`,config:e,...c==null?{}:{runContext:c},preservation:{required:[]}});return{state:`authority-committed`,result:$e(await Qe({authority:this.options.authority,executionId:e.executionId,instruction:l,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)}}},kt=class{#e;constructor(e){this.#e=e.bus}async run(e,t,n){let r=ye.parse(e),i=await s(r);return{state:`uncommitted`,result:await et({config:await a(r,i,this.#e,t),loaded:i,bus:this.#e,signal:t})}}};function At(){return{contributionRefs:[]}}function jt(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=te(e.runtimeModuleDir)===`src`?`source`:`dist`,r=Mt({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 Mt(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 kt({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(C.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 Ot({dispatch:r,authority:e.authority,...n!==void 0&&{readRunContext:async(e,t)=>(await n.request(Xe.getRunContext,{executionId:e},{signal:t})).runContext},...t.manifest!==void 0&&{manifest:t.manifest},...t.requirements!==void 0&&{requirements:t.requirements}})}case`piscina`:return new Et({workerEntry:t.workerEntry??Dt({moduleDir:e.moduleDir,mode:t.workerEntryMode??e.defaultWorkerEntryMode}),manifest:t.manifest??At(),...t.resolveWorkspaceRoot!==void 0&&{resolveWorkspaceRoot:t.resolveWorkspaceRoot},maxConcurrency:t.maxConcurrency,idleTimeoutMs:t.idleTimeoutMs})}}const Nt=new Set([`accepted`,`duplicate`]);var K=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`}},q=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`}},Pt=class extends Error{reason;constructor(e=`deadline-exceeded`){super(`Authority request delivery deadline exceeded`),this.reason=e,this.name=`AuthorityRequestDeliveryError`}};function Ft(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 It(e,t,n,r){let i=t.baseDelayMs*2**(e-1),a=n-Date.now(),o=Math.min(i,t.maxDelayMs,a);await new Promise(e=>setTimeout(e,o));let s=n-Date.now();if(s<=0)return!1;if(r!==void 0){let e;try{await Promise.race([r(),new Promise(t=>{e=setTimeout(t,s)})])}catch{}finally{e!==void 0&&clearTimeout(e)}}return Date.now()<n}async function Lt(e,t,n,r){let i=Ft(n?.retry),a=n?.reconnect,o=Date.now()+i.deadlineMs,s;for(let n=0;n<=i.maxRetries;n++){if(o-Date.now()<=0||n>0&&!await It(n,i,o,a))throw t();try{let n=o-Date.now();if(n<=0)throw t();return await e(n)}catch(e){if(r(e))throw e;if(s=e,Date.now()>=o)throw t()}}throw s??t()}async function Rt(e,t){return await Lt(e,()=>new Pt,t,()=>!1)}async function zt(e,t,n){return await Lt(async n=>{let r=await e(n);if(Nt.has(r))return r;throw t(r)},()=>t(`deadline-exceeded`,`deadline-exceeded`),n,e=>e instanceof K||e instanceof q)}async function Bt(e,t,n){return await zt(async n=>(await e.request(C.control.outcome.submit,{executionAttemptId:t.executionAttemptId,executionId:t.executionId,result:t.result},{timeout:n})).decision,(e,n)=>n===void 0?new K(e,t.result):new K(e,t.result,n),n)}async function Vt(e,t,n){return await zt(async n=>(await e.request(x.outcome.submit,t,{timeout:n})).decision,(e,n)=>n===void 0?new q(e,t):new q(e,t,n),n)}const Ht={maxRetries:3,baseDelayMs:200,maxDelayMs:2e3,deadlineMs:1e4},Ut={persistentStorage:!0,customCapabilities:[`workflow.local-runtime`,`workflow.thin-runner`],suspensionStrategy:`wait-in-process`,supportsRecovery:!1,materializationModes:[`local-directory`]};function Wt(e){let t=new Set,n;return{conclude:r=>{if(n!==void 0)return;n={evidence:le.parse({source:e.slice(0,S.source),summary:r.slice(0,S.summary),observedAt:new Date().toISOString()})};let i=[...t];t.clear();for(let e of i)try{e(n)}catch(e){console.error(`[PiscinaThinWorkflowProvider] Infrastructure-conclusion observer failed:`,e)}},observe:e=>n===void 0?(t.add(e),()=>t.delete(e)):(e(n),()=>void 0)}}var Gt=class{executionAttemptId;controller;detachCallerAbort;infrastructure;revokeBusIdentity;constructor(e,t,n,r,i){this.executionAttemptId=e,this.controller=t,this.detachCallerAbort=n,this.infrastructure=r,this.revokeBusIdentity=i}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(),this.revokeBusIdentity(),Promise.resolve()}observeInfrastructureConclusion(e){return this.infrastructure.observe(e)}},Kt=class{options;environment=`piscina`;allocationLifetime=`provisioner-process-bound`;baseCapabilities;constructor(e){this.options=e,this.baseCapabilities=he.parse({...Ut,...e.baseCapabilities,suspensionStrategy:e.baseCapabilities?.suspensionStrategy??Ut.suspensionStrategy,supportsRecovery:!1})}get id(){return this.options.id}get displayName(){return this.options.displayName}async provision(e,t){t.throwIfAborted();let n=new AbortController,r=Wt(this.id),i=()=>{n.abort(t.reason)};t.addEventListener(`abort`,i,{once:!0});let a=()=>t.removeEventListener(`abort`,i),o;try{let{executionAttemptId:i,executionId:s,workerConfig:c}=e;if(!c.busUrl)throw Error(`PiscinaThinWorkflowProvider requires a bus URL to provision an execution attempt (executionAttemptId=${i}, executionId=${s})`);let u=this.buildAllocationRef(i),d=l({executionAttemptId:i,executionId:s});o=d.cleanup;let f=new Gt(i,n,a,r,d.cleanup);t.throwIfAborted();let p=this.options.runner.runWithReadiness({...c,busAuth:{kind:`hmac`,secret:d.secret}},n.signal,e.workerManifest,{executionAttemptId:i,bootstrapDeadlineAt:e.bootstrapDeadlineAt});return p.ready.then(()=>this.submitOutcomeOnSettlement(p.result,s,i,c.workflowId,r.conclude),e=>{n.abort(e),p.result.catch(()=>void 0),r.conclude(`Piscina worker for attempt '${i}' was refused before its workflow run was admitted: `+(e instanceof Error?e.message:String(e)))}),{kind:`allocated`,allocationRef:u,handle:f}}catch(e){throw n.abort(e),a(),o?.(),e}}async submitOutcomeOnSettlement(e,t,n,r,i){let a;try{a=await e}catch(e){a={executionId:t,workflowId:r,status:`failed`,error:e instanceof Error?e.message:String(e)}}try{let e={...Ht,...this.options.outcomeRetry};await Bt(this.options.bus,{executionAttemptId:n,executionId:t,result:a},{retry:e})}catch(e){e instanceof K?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`)}}buildAllocationRef(e){let t={version:pe,providerId:this.id,providerData:{executionAttemptId:e,allocatedAt:Date.now()}};return me.parse(t)}};const qt=[Re,Fe,Le];function Jt(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 Yt(e,t,n){return A({bus:e,currentMachineId:n,resolveLiveAdapterId:e=>t.getExtensionService(E)?.resolveLiveAdapterId(e),resolveLiveAdapterIdentity:e=>t.getExtensionService(E)?.resolveLiveAdapterIdentity(e),listLiveAdapterIdentities:()=>t.getExtensionService(E)?.getLiveAdapterIdentities()??[]})}async function Xt(e){let t=y();t.registerNamespaces([...ue,...de]);let{context:n}=e,r=new xe(t,{surface:`headless`,extensionContextBase:{cwd:n.cwd,platform:n.platform,homedir:n.homedir,makaioHome:n.makaioHome,username:n.username,machineId:n.machineId,tryImport:M}}),i,a=[()=>t.disconnect()],o=Jt(a);try{await e.connectAuthority(t);let s=[...e.contributedPackages,...await e.loadContributedPackages?.(t)??[]],{adapterSubsystemPackage:c}=k({coordinator:r,configRepository:e.configRepository,platformDefaults:{cwd:n.cwd},runtimeSnapshotHandlerPriority:1,runtimeDefinitionHandlerPriority:1,...e.prepareAuthRuntime!==void 0&&{prepareAuthRuntime:e.prepareAuthRuntime}}),l=Ve({definitions:s.flatMap(e=>e.clients??[]),binaryResolutionPolicy:`global-only`});r.registerContributionProcessor(Pe());let u=[...qt,c,Me,...z(s)?[Ie]:[],Ne(1),ze,F,l,...We(s)];r.load(u),a.push(...B(u,t,r)),a.push(()=>r.shutdown()),await r.startAll(),i=Yt(t,r,n.machineId),a.push(()=>{i?.cleanup(),i=void 0});let d=r.getExtensionService(je);if(d===void 0)throw Error(`Isolated workflow tool registry did not start.`);for(let t of e.toolsets)await d.register(t);return await t.emit(Se.ready,{machineId:n.machineId}),{bus:t,coordinator:r,machineId:n.machineId,shutdown:o}}catch(e){throw await o().catch(()=>void 0),e}}function Zt(e){return Number.isInteger(e)&&e>=1&&e<=2147483647}function J(e,t){try{process.kill(-e,t)}catch(e){if(e.code!==`ESRCH`)throw e}}async function Qt(e,t){try{process.kill(-e,0)}catch(e){if(e.code===`ESRCH`)return!1;if(e.code!==`EPERM`)throw e}let n;try{n=await $t(t)}catch{return!0}let r=!1;for(let t of n.trim().split(`
|
|
2
|
+
`)){let[n,i,a]=t.trim().split(/\s+/);if(n===``||i===void 0||a!==void 0||!/^\d+$/.test(n)||i===``||Number(n)===e&&(r=!0,!i.startsWith(`Z`)))return!0}return!r}function $t(e){return new Promise((t,n)=>{d(`ps`,[`-A`,`-o`,`pgid=,stat=`],{timeout:e,maxBuffer:1024*1024},(e,r)=>{if(e!==null){n(e);return}t(r)})})}async function en(e){if(e===void 0)return!0;try{try{J(e,`SIGKILL`)}catch(e){if(e.code!==`EPERM`)throw e}let t=Date.now()+2e3;for(;Date.now()<t;){let n=t-Date.now();if(n<=0)break;if(!await Qt(e,Math.min(1e3,n)))return!0;await tt(20)}}catch{}return!1}async function tn(e){if(e.signal?.aborted)return{status:`cancelled`,exitCode:null};if(!Zt(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 nn(e)}catch{return{status:`spawn-failed`,exitCode:null,message:`Could not start the setup command`}}}function nn(e){return new Promise(t=>{let n=f(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=e=>{if(r===void 0&&(r=e,n.pid!==void 0)){try{J(n.pid,`SIGTERM`)}catch(e){if(e.code!==`EPERM`){r=`stop-failed`;return}}i=setTimeout(()=>{try{n.pid!==void 0&&J(n.pid,`SIGKILL`)}catch(e){e.code!==`EPERM`&&(r=`stop-failed`)}},200)}},o=()=>a(`cancelled`),s=setTimeout(()=>a(`timed-out`),e.recipe.timeoutMs);e.signal?.addEventListener(`abort`,o,{once:!0}),e.signal?.aborted&&o(),n.once(`error`,()=>{r=`spawn-failed`}),n.once(`close`,a=>{clearTimeout(s),clearTimeout(i),e.signal?.removeEventListener(`abort`,o),en(n.pid).then(e=>{t({status:e?r??(a===0?`completed`:`failed`):`stop-failed`,exitCode:a})})})})}async function rn(e,t,n){if(h.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=h.join(r,i),U(r,e,`Source root`),await W(r,e,`Source root`,e),n&&await m.mkdir(r).catch(e=>{if(e.code!==`EEXIST`)throw e}),!(await m.stat(r)).isDirectory())throw Error(`Source root must be a directory`);return W(r,e,`Source root`,e)}async function Y(e){e.signal?.throwIfAborted();let{requirement:t}=e,n=h.resolve(e.workspaceRoot);if(!h.isAbsolute(e.workspaceRoot)||n===h.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 m.mkdir(n),!(await m.lstat(n)).isDirectory())throw Error(`Workspace root must be a directory, not a symlink`);let r=await m.realpath(n),i=[];for(let n of t.sourceRoots){let a=await rn(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 an(t,{workspaceRoot:r,sourceRoots:i})}function an(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{for(let[r,i]of e.setup.entries()){let e=await tn({...t,recipe:i,workspaceRoot:n});if(a=e.status!==`stop-failed`,e.status!==`completed`)return{...e,commandIndex:r}}return{status:`completed`,exitCode:0}}finally{i=!1}},release(){return i||!a?Promise.reject(Error(`Workspace commands have not stopped`)):(o??=r===`external`?Promise.resolve():m.rm(n,{recursive:!0,force:!0}),o)}}}function X(e,t){return e instanceof ae?oe(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}async function on(e,t,n,r){let i=b[`instruction.get`].response.parse(await e.request(x.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 sn(e,t,n,r){let{executionAttemptId:i,runtimeGeneration:a}=t,o=b[`operation.admit`].response.parse(await Rt(async t=>await e.request(x.operation.admit,{executionAttemptId:i,runtimeGeneration:a,operationKind:n,admissionKey:r},{timeout:t}),{retry:t.retry,reconnect:t.reconnect}));if(o.decision===`refused`||o.operationId===void 0)throw Error(`Attempt ${n} admission refused: ${o.refusalReason??`missing-operation-id`}`);return o.operationId}function Z(e){return(e instanceof Error?e.message:String(e)).slice(0,8192)||`Local execution failed without a diagnostic message`}function cn(e,t){return e.find(e=>e.kind===t.workload.kind&&e.version===t.workload.version)}function ln(e){return{signal:e??new AbortController().signal,release:()=>{}}}async function Q(e,t,n,r,i,a){let o=await Vt(e,{executionAttemptId:t.executionAttemptId,runtimeGeneration:t.runtimeGeneration,...i===void 0?{}:{operationId:i},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 un(e,t,n,r){let i=b[`operation.report`].response.parse(await Rt(async i=>await e.request(x.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}function dn(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}`}}async function fn(e,t,n,r){if(r.aborted)return await Q(e,t,n,{kind:`cancelled`},void 0,void 0);let i=await sn(e,t,`workspace-preparation`,`workspace-preparation:${n.id}:${t.runtimeGeneration}`);if(r.aborted)return await Q(e,t,n,{kind:`cancelled`},i,void 0);let a,o;try{if(t.workspaceRoot===void 0)throw Error(`Workspace preparation requires an explicit local root`);let e=await(t.preparation??{prepare:Y}).prepare({requirement:n.workspace,workspaceRoot:t.workspaceRoot,signal:r});a=e,o=await e.runSetup({signal:r,env:t.setupEnv})}catch(o){return await Q(e,t,n,X(o,r)?{kind:`cancelled`}:{kind:`technical-failure`,stage:`workspace-preparation`,message:Z(o)},i,a)}let s=dn(o);if(s!==void 0)return await Q(e,t,n,s,i,a);if(r.aborted)return await Q(e,t,n,{kind:`cancelled`},i,a);let c=await un(e,t,i,a);return c===void 0?await Q(e,t,n,{kind:`technical-failure`,stage:`workspace-preparation`,message:`Workspace preparation report refused by the Authority`},i,a):r.aborted?await Q(e,t,n,{kind:`cancelled`},void 0,a):{handle:a,binding:c}}async function pn(e,t,n,r,i){if(i.signal.aborted)return await Q(e,t,n,{kind:`cancelled`},void 0,void 0);let a,o;if(n.workspace!==void 0){let r=await fn(e,t,n,i.signal);if(`outcome`in r)return r;a=r.handle,o=r.binding}if(i.signal.aborted)return await Q(e,t,n,{kind:`cancelled`},void 0,a);let s=await sn(e,t,`workload-invocation`,`workload-invocation:${n.id}:${t.runtimeGeneration}`);if(i.signal.aborted)return await Q(e,t,n,{kind:`cancelled`},s,a);let c;try{c={kind:`workload-result`,result:fe.parse(await r.invoke({instruction:n,...o===void 0?{}:{workspace:o},signal:i.signal}))}}catch(e){c=X(e,i.signal)?{kind:`cancelled`}:{kind:`technical-failure`,stage:`workload-invocation`,message:Z(e)}}return await Q(e,t,n,c,s,a)}async function mn(e,t){let n;try{n=await on(e,t.executionAttemptId,t.runtimeGeneration,t.signal)}catch(n){if(oe(n,t.signal))return await Q(e,t,void 0,{kind:`cancelled`},void 0,void 0);throw n}let r=cn(t.adapters,n);if(r===void 0)return await Q(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})??ln(t.signal))}catch(r){let i=X(r,t.signal)?{kind:`cancelled`}:{kind:`technical-failure`,stage:`startup`,message:Z(r)};return await Q(e,t,n,i,void 0,void 0)}try{return await pn(e,t,n,r,i)}finally{try{i.release()}catch{console.warn(`[makaio-worker] Workload control release failed.`)}}}async function hn(e,t,n,r,i){let a=ge[`runtime.inputs.get`].response.parse(await e.request(C.runtime.inputs.get,{executionAttemptId:t},{signal:i}));if(a.runtimeInputs===null)throw Error(`Selected Worker Runtime inputs are unavailable`);return _e.parse({...n,...a.runtimeInputs,createdAt:0,env:r})}function gn(e,t){let n=(e,t)=>{let n=re(e,t);return n===``||!ne(n)&&n!==`..`&&!n.startsWith(`../`)&&!n.startsWith(`..\\`)};return n(e,t)||n(t,e)}async function _n(t,n,r,i){let a=await t.loadContributions(r,i);i.throwIfAborted();let o=e();return await Xt({connectAuthority:e=>t.connectBus(e,n,i),contributedPackages:[...a],configRepository:t.configRepository,context:{cwd:r.workspaceRoot,platform:r.platform,homedir:o,makaioHome:o,username:`workflow-worker`,machineId:`headless-worker-${t.executionAttemptId}`},toolsets:[...t.toolsets],...t.prepareAuthRuntime!==void 0&&{prepareAuthRuntime:t.prepareAuthRuntime}})}function vn(e,t,n){let r={...e.workflowEnv},i,a=!0;return{adapter:{kind:Je,version:Ye,async bindControl({instruction:t,signal:r}){let i=D(t);if(i.executionId!==e.executionId)throw Error(`Workflow instruction execution identity mismatch`);let a=new AbortController,o=n.on(be(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=D(o);a=o.preservation.required.length!==0;let u=c??new AbortController().signal,d;try{u.throwIfAborted();let a=await hn(n,e.executionAttemptId,l,r,u),o=await e.materialize(a,u);(s===void 0||!gn(o.context.workspaceRoot,s.workspaceRoot))&&(i=o.cleanup);let c=yn(o.context,s);return u.throwIfAborted(),d=await _n(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 yn(e,t){return t===void 0?e:{...e,workspaceRoot:t.workspaceRoot}}async function bn(e,t){if(!(t.outcome.kind!==`workload-result`||e.onPostCommit===void 0))try{let n=ve.parse(t.outcome.result);await e.onPostCommit(n,t.decision)}catch{}}async function xn(e,t){t.throwIfAborted();let n={...e.workflowEnv},i=v(),a=await c(e.bootstrapDeadlineAt,t,t=>e.bootstrap(t)),{connection:s,endpoint:l}=await o({executionAttemptId:e.executionAttemptId,runtimeIncarnationId:i,bootstrapDeadlineAt:e.bootstrapDeadlineAt,signal:t,createConnection:()=>Sn(e,a)}),u=s.bus,d=vn({...e,workflowEnv:n},a,u),f;try{let n=await r(u,{executionAttemptId:e.executionAttemptId,runtimeIncarnationId:i,signal:t});return l.bindGeneration(n),f=await mn(u,{executionAttemptId:e.executionAttemptId,runtimeGeneration:n,workspaceRoot:e.workspaceRoot,setupEnv:e.setupEnv,preparation:e.preparation,adapters:[d.adapter],signal:t,retry:e.outcomeRetry,reconnect:()=>u.reconnect()}),await bn(e,f),f}finally{try{await d.releaseExecutable(f)}finally{l.cleanup(),await s.close()}}}function Sn(e,t){let n=y();return n.registerNamespaces([...ue,...de]),{bus:n,async connect(r){try{await e.connectBus(n,t,r),r.throwIfAborted()}catch(e){throw n.disconnect(),e}},close:()=>n.disconnect()}}const Cn=p(d),$=[`-c`,`core.attributesFile=${w}`],wn=u.object({repositoryId:u.string().min(1),revision:u.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i,`Git source revision must be a full commit object ID`)}).strict();async function Tn(e,t,n){try{let r=await e.resolveRepository(t,n);if(!h.isAbsolute(r))throw Error(`Repository access did not return an absolute path`);return await m.realpath(r)}catch(e){throw X(e,n)?e:Error(`Git source access failed`)}}async function En(e,t,n,r,i){let a;try{a=(await Cn(`git`,[...$,`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 X(e,i)?e:Error(`Git source object inspection failed`)}if(a!==`commit`)throw Error(`Git source revision must identify a commit object`)}function Dn(e){if(!Zt(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=wn.parse(t.input),a=await Tn(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:w,GIT_CONFIG_SYSTEM:w,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 En(n,i.revision,o,e.timeoutMs,r);let a=await tn({workspaceRoot:n,signal:r,env:o,recipe:{command:`git`,args:[...$,...t],env:{},timeoutMs:e.timeoutMs}});if(a.status===`cancelled`&&r?.throwIfAborted(),a.status!==`completed`)throw Error(`Git source ${t[0]} ${a.status}`)}}}function On(e){let t=Dn(e);return{prepare:e=>Y({...e,realizeSource:t})}}export{ht as A,O as B,_t as C,lt as D,wt as E,F,j as I,M as L,L as M,dt as N,I as O,mt as P,A as R,Ct as S,gt as T,Et as _,Kt as a,W as b,Nt as c,Bt as d,Mt as f,Dt as g,Ot as h,Xt as i,B as j,ut as k,K as l,kt as m,xn as n,q as o,jt as p,mn as r,Pt as s,On as t,Vt as u,H as v,Tt as w,St as x,U as y,k as z};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,Q as t,S as n,a as r,d as i,f as a,l as o,m as s,n as c,o as l,r as u,s as d}from"./schemas-CNkUEbIr.mjs";import{t as f}from"./zod-json-schema-Dixc-B1T.mjs";import{z as p}from"zod";import{createBusNamespace as m}from"@makaio/framework/core";function h(e){return{...e,toRegistration:()=>({kind:e.kind,description:e.description,schemaVersion:e.schemaVersion,dataSchema:f(e.dataSchema),...e.scopeSchema?{scopeSchema:f(e.scopeSchema)}:{},...e.observationSchema?{observationSchema:f(e.observationSchema)}:{},...e.discriminator===void 0?{}:{discriminator:typeof e.discriminator==`string`?e.discriminator:Array.from(e.discriminator)},conflictPolicy:e.conflictPolicy,...e.status?{status:{...e.status,...e.status.values?{values:[...e.status.values]}:{}}}:{},...e.lifecycle?{lifecycle:e.lifecycle}:{},...e.indexedFields?{indexedFields:[...e.indexedFields]}:{},...e.searchableFields?{searchableFields:[...e.searchableFields]}:{},...e.projection?{projection:{...e.projection,...e.projection.semanticEvents?{semanticEvents:[...e.projection.semanticEvents]}:{},...e.projection.projectedFields?{projectedFields:e.projection.projectedFields.map(e=>({...e}))}:{},...e.projection.affordances?{affordances:e.projection.affordances.map(e=>structuredClone(e))}:{}}}:{},...e.defaultContext?{defaultContext:structuredClone(e.defaultContext)}:{}})}}function g(e){return{hooks:[...e.hooks]}}function _(e){return JSON.stringify([e.kind,e.id,e.revision])}const v=p.enum([`not-selected`,`not-found`,`depth-exceeded`,`unsupported-ref-class`,`cycle-detected`]),y=p.object({target:a,sourceRef:o,relationType:p.string().min(1),hint:t,status:p.enum([`resolved`,`unresolved`]),reason:v.optional()}).superRefine((e,t)=>{e.status===`unresolved`&&e.reason===void 0&&t.addIssue({code:p.ZodIssueCode.custom,path:[`reason`],message:`reason is required for unresolved artifact context refs`}),e.status===`resolved`&&e.reason!==void 0&&t.addIssue({code:p.ZodIssueCode.custom,path:[`reason`],message:`reason must be omitted for resolved artifact context refs`}),e.status===`resolved`&&e.target.refClass!==`artifact`&&t.addIssue({code:p.ZodIssueCode.custom,path:[`target`],message:`resolved artifact context refs must target an artifact revision`})}),b=p.object({rootRef:o,refs:p.array(y),resolved:p.array(s)}).superRefine((e,t)=>{let n=new Set(e.resolved.map(_));n.has(_(e.rootRef))||t.addIssue({code:p.ZodIssueCode.custom,path:[`resolved`],message:`resolved artifact context wire payloads must include the root artifact revision`}),e.refs.forEach((e,r)=>{n.has(_(e.sourceRef))||t.addIssue({code:p.ZodIssueCode.custom,path:[`refs`,r,`sourceRef`],message:`artifact context ref sources must have a matching revision in resolved`}),!(e.status!==`resolved`||e.target.refClass!==`artifact`)&&(n.has(_(e.target))||t.addIssue({code:p.ZodIssueCode.custom,path:[`refs`,r,`target`],message:`resolved artifact context refs must have a matching revision in resolved`}))})});function x(e){let t=b.parse(e),n=new Map(t.resolved.map(e=>[E(e),e])),r=new Map;for(let e of t.refs){let t=E(e.sourceRef),n=r.get(t);n||(n=[],r.set(t,n)),n.push(e)}let i=n.get(E(t.rootRef));if(!i)throw Error(`Resolved artifact context is missing root artifact '${E(t.rootRef)}'`);let a=S(t.rootRef,i,`inline`,r,n);return{root:a,flatten(){let e=[];return T(a,e),e}}}function S(e,t,n,r,i){return{status:`resolved`,ref:e,artifact:t,hint:n,children:w(e,r,i,new Set([E(e)]))}}function C(e,t,n,r,i,a,o){let s=E(e),c=new Set(o);return c.add(s),{status:`resolved`,ref:e,artifact:t,relation:n,hint:r,children:w(e,i,a,c)}}function w(e,t,n,r){return(t.get(E(e))??[]).map(e=>{if(e.status===`unresolved`)return{status:`unresolved`,target:e.target,relation:e.relationType,hint:e.hint,reason:e.reason};if(e.target.refClass!==`artifact`)throw Error(`Resolved artifact context refs must target an artifact revision`);let i=E(e.target),a=n.get(i);if(!a)throw Error(`Resolved artifact context is missing target artifact '${i}'`);return r.has(i)?{status:`unresolved`,target:e.target,relation:e.relationType,hint:e.hint,reason:`cycle-detected`}:C(e.target,a,e.relationType,e.hint,t,n,r)})}function T(e,t){if(e.status!==`unresolved`){t.push(e.artifact);for(let n of e.children)T(n,t)}}function E(e){return JSON.stringify([e.kind,e.id,e.revision])}const D={"kind.register":{request:r,response:p.object({registered:p.boolean()})},"kind.list":{request:p.object({kind:p.string().min(1).optional()}),response:p.object({kinds:p.array(r)})},"relation-type.register":{request:n,response:p.object({registered:p.boolean()})},"relation-type.list":{request:p.object({type:p.string().min(1).optional()}),response:p.object({relationTypes:p.array(n)})},create:{request:s.omit({id:!0,revision:!0,timestamp:!0}),response:p.object({artifact:s})},revise:{request:p.object({previous:o,revision:s.omit({id:!0,revision:!0,timestamp:!0})}),response:p.object({artifact:s})},resolve:{request:p.object({ref:o}),response:p.object({artifact:s.nullable()})},query:{request:d,response:p.object({artifacts:p.array(s)})},compare:{request:c,response:u},resolveContext:{request:p.object({ref:o,selectors:e.optional(),maxDepth:p.number().int().min(1).max(20).default(5)}),response:p.object({context:b})},created:p.object({artifact:s}),revised:p.object({previous:o,artifact:s}),"relation.added":p.object({artifact:o,relation:i}),"observation.added":p.object({artifact:o,observation:l}),"status.changed":p.object({artifact:o,path:p.string().min(1),previous:p.unknown().optional(),current:p.unknown().optional()}),"kind.changed":p.object({kind:p.string().min(1),schemaVersion:p.string().min(1)})},O=m(`artifact`,D),k=O.subjects;export{y as a,g as c,x as i,h as l,D as n,v as o,k as r,b as s,O as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{z as e}from"zod";import{ExecutionAttemptInstructionSchema as t,ExecutionAttemptPreparationResultSchema as n,ProviderAllocationRefSchema as r,WorkerAllocationLifetimeSchema as i}from"@makaio/framework/contracts";function a(e){let t=Date.parse(e);if(Number.isNaN(t))throw Error(`Expected an ISO-8601 timestamp, received '${e}'`);return t}function o(e){return new Date(a(e)).toISOString()}function s(e){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`bootstrapTimeoutMs must be a positive safe integer`);let t=Date.now(),n=t+e;if(!Number.isSafeInteger(n)||!Number.isFinite(new Date(n).getTime()))throw RangeError(`bootstrapTimeoutMs produces an unrepresentable bootstrap deadline`);return{createdAt:new Date(t).toISOString(),bootstrapDeadlineAt:new Date(n).toISOString()}}function c(e){return typeof e==`object`&&!!e}function l(e){if(!(!c(e)||Object.isFrozen(e))){Object.freeze(e);for(let t of Object.values(e))l(t)}}function u(e,t){let n=t(structuredClone(e));return l(n),n}function d(e){return u(e,e=>t.parse(e))}function f(e){return u(e,e=>n.parse(e))}const p=e.array(e.object({operationId:e.string().min(1),runtimeGeneration:e.number().int().positive(),result:n}).strict());function m(e){return u(e,e=>p.parse(e))}function h(e){return u(e,e=>r.parse(e))}function g(e){return i.parse(e)}function _(e){let t=r.parse(e.currentRef),n=h(e.nextRef);if(t.providerId!==n.providerId)throw Error(`Allocation reference evolution must keep one provider, received '${t.providerId}' and '${n.providerId}'`);return{currentRef:t,nextRef:n}}function v(e,t){if(e.providerId!==t.providerId)throw Error(`Allocation reference for attempt '${e.executionAttemptId}' names provider '${t.providerId}' but the attempt is bound to '${e.providerId??`no provider`}'`)}const y={runtimeGeneration:0,runtimeIncarnationId:null,runtimeReadyAt:null,operationStartGate:`open`,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null,lastCompletedOperationId:null};function b(e){return{runtimeGeneration:e.runtimeGeneration,runtimeIncarnationId:e.runtimeIncarnationId,runtimeReadyAt:e.runtimeReadyAt,operationStartGate:e.operationStartGate,activeOperationId:e.activeOperationId,activeOperationKind:e.activeOperationKind,activeOperationKey:e.activeOperationKey,activeOperationGeneration:e.activeOperationGeneration,activeOperationAdmittedAt:e.activeOperationAdmittedAt,lastCompletedOperationId:e.lastCompletedOperationId}}function x(e,t){let n=a(e.createdAt)-a(t.createdAt);return n===0?e.executionAttemptId<t.executionAttemptId?-1:+(e.executionAttemptId>t.executionAttemptId):n}function S(e){let{status:t,claimable:n,settlementKind:r,allocationRef:i,providerId:a}=e,{allocationLifetime:o,provisionerIncarnationId:s}=e;if(t!==`allocated`||n!==!0||r!=null||i===null||a===null||o===null||s===null)throw Error(`Attempt '${e.executionAttemptId}' was selected as recoverable but is not: status '${t}', claimable '${String(n)}', settlement '${String(r)}', allocation '${i===null?`none`:`present`}', provider '${String(a)}', lifetime '${String(o)}', provisioner '${String(s)}'`);return{...e,status:t,claimable:!0,settlementKind:null,allocationRef:i,providerId:a,allocationLifetime:o,provisionerIncarnationId:s}}export{o as a,_ as c,f as d,v as f,a as i,d as l,S as m,x as n,g as o,b as p,s as r,h as s,y as t,m as u};
|