@makaio/framework 1.0.0-dev-1788955549564 → 1.0.0-dev-1788966380232
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/{2020-Bl3Yx3In.mjs → 2020-CpDjcHDh.mjs} +1 -1
- package/dist/{account-identity-B0NsOILM.mjs → account-identity-D00LLclm.mjs} +1 -1
- package/dist/{adapter-DYE_oWjj.mjs → adapter-D92pfm_b.mjs} +1 -1
- package/dist/{adapter-auth-runtime-BnPqQChk.mjs → adapter-auth-runtime-46Y9WKcB.mjs} +1 -1
- package/dist/adapter-subsystem/index.d.mts +1 -1
- package/dist/adapter-subsystem/index.mjs +1 -1
- package/dist/adapters/claude/index.d.mts +2 -2
- package/dist/adapters/claude/testing.mjs +1 -1
- package/dist/adapters/config/index.d.mts +2 -2
- package/dist/adapters/config/index.mjs +1 -1
- package/dist/adapters/index.d.mts +3 -3
- package/dist/adapters/index.mjs +6 -6
- package/dist/adapters/node.d.mts +1 -1
- package/dist/adapters/node.mjs +2 -2
- package/dist/adapters/stream-session/index.d.mts +1 -1
- package/dist/adapters/stream-session/index.mjs +1 -1
- package/dist/artifact-_pN73_7c.mjs +1 -0
- package/dist/{attempt-record-codec-6jpayBMY.mjs → attempt-record-codec-D2Gb_epJ.mjs} +1 -1
- package/dist/{auth-CeH3w2fi.mjs → auth-CB4an9bh.mjs} +1 -1
- package/dist/authority-state-bootstrap-DgoHPc9J.mjs +1 -0
- package/dist/{automation-trigger-CZfH94Fr.mjs → automation-trigger-xNDX0Am_.mjs} +1 -1
- package/dist/bootstrap-start-client-rW55mDI-.mjs +1 -0
- package/dist/bus/index.mjs +1 -1
- package/dist/{caller-owned-adapter-stub-B-Sq7ZvF.mjs → caller-owned-adapter-stub-oM1G1KvC.mjs} +1 -1
- package/dist/{canonical-model-oFNty7hj.mjs → canonical-model-D7Cg0l2R.mjs} +1 -1
- package/dist/{capabilities-BhJ3wzI8.mjs → capabilities-D2ggcMem.mjs} +1 -1
- package/dist/{capability-service-23Ot2J9A.d.mts → capability-service-Cpkonrc0.d.mts} +1 -1
- package/dist/{client-DJMzCHRm.mjs → client-CpUVfDxa.mjs} +1 -1
- package/dist/clients/index.d.mts +2 -2
- 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-B9wr0b972.mjs → code-execution-ByLSAlEg2.mjs} +1 -1
- package/dist/{code-execution-BMmUATcc.mjs → code-execution-CMqsHnGg.mjs} +1 -1
- package/dist/{code-execution-DRCzkGzO.mjs → code-execution-xn9-x3VO.mjs} +1 -1
- package/dist/common-CylczUIW.mjs +1 -0
- package/dist/{compression-nZhMDRTA.mjs → compression-Civ-rf-O.mjs} +1 -1
- package/dist/{config-namespace-MjFuIPyL.mjs → config-namespace-CQnsvr77.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 +2 -2
- package/dist/contracts/common/index.mjs +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 +73 -73
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/materialization/index.d.mts +2 -2
- 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 +2 -2
- 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-B4t0OXKs.d.mts → contribution-BfEEQ8YZ.d.mts} +2 -2
- package/dist/{definition-Bs5hzhsT.d.mts → definition-6d5JBi55.d.mts} +1 -1
- package/dist/{definition-YGj42UeO.mjs → definition-Dqw0YJdi.mjs} +1 -1
- package/dist/{detached-extension-handle-CgJiXaqv.mjs → detached-extension-handle-BJnk3WEh.mjs} +1 -1
- package/dist/{dist-CfANkKSb.mjs → dist-DeI9zYMP.mjs} +1 -1
- package/dist/evidence/git-file/index.d.mts +54 -0
- package/dist/evidence/git-file/index.mjs +4 -0
- package/dist/{execution-attempt-owner-recovery-CdH04iwP.mjs → execution-attempt-owner-recovery-D4APLAvt.mjs} +1 -1
- package/dist/{execution-attempt-repository-CJVlPFMM.d.mts → execution-attempt-repository--RVils5-.d.mts} +273 -189
- package/dist/execution-attempt-repository-CWbgCTwA.mjs +1 -0
- package/dist/{execution-target-B9jZgDQz.mjs → execution-target-_oVNW6Zm.mjs} +1 -1
- package/dist/{extension-B51JzHJu.mjs → extension-CAi7bbyv.mjs} +1 -1
- package/dist/{extension-C1CwxkCN.mjs → extension-CrghVa93.mjs} +1 -1
- package/dist/{filesystem-service-yB8KhUGz.mjs → filesystem-service-hdz3oYti.mjs} +1 -1
- package/dist/{framework-packages-25GUGzJ-.mjs → framework-packages-BOPhhtK7.mjs} +1 -1
- package/dist/git/index.mjs +1 -1
- package/dist/{globby-z2SR0jRo.mjs → globby-Begk3aIP.mjs} +1 -1
- package/dist/{handlers-CBbFzDHc.mjs → handlers-YPTyZDhF.mjs} +1 -1
- package/dist/{harness-GNtHsoh4.mjs → harness-Ds1I4smU.mjs} +1 -1
- package/dist/{hook-responses-chgDiS8D.d.mts → hook-responses-CpEfxEmG.d.mts} +1 -1
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/{index-BtPZcp4M2.d.mts → index-09eal6WI2.d.mts} +11 -11
- package/dist/{index-GNRWZONO.d.mts → index-6kg8YFYt.d.mts} +1 -1
- package/dist/{index-B6aoVzdA.d.mts → index-B3G-Hzwn.d.mts} +1 -1
- package/dist/{index-SDXlgq07.d.mts → index-B7wjmaev.d.mts} +24 -14
- package/dist/{index-DzeUtJtE.d.mts → index-BKwYE1Qk.d.mts} +5 -5
- package/dist/{index-CKjFFP6W2.d.mts → index-BM-FPWjs2.d.mts} +1 -1
- package/dist/{index-Bak5iKWv2.d.mts → index-BT5qcsEf2.d.mts} +24 -15
- package/dist/{index-BjELPYLF2.d.mts → index-BfzuauBt2.d.mts} +1 -1
- package/dist/{index-D2sbGoGS.d.mts → index-Bj2JCo9V.d.mts} +2 -2
- package/dist/{index-OXuby-ee.d.mts → index-BkQlL0Pl.d.mts} +13 -13
- package/dist/{index-CuPq_ap8.d.mts → index-BlHq_Ksb.d.mts} +2 -2
- package/dist/{index-D3RZEEE3.d.mts → index-Bn6sN1op.d.mts} +2 -2
- package/dist/{index-ConotXyG.d.mts → index-Bnm0QvJ4.d.mts} +15 -15
- package/dist/{index-Bxs-oIo4.d.mts → index-BpsurXEW.d.mts} +1 -1
- package/dist/{index-C9J8wBLV.d.mts → index-BqR2xDu6.d.mts} +655 -111
- package/dist/{index-DX_2kGSg.d.mts → index-Bxq_zO2E.d.mts} +4 -4
- package/dist/{index-CcgI6r0K.d.mts → index-C742b1FV.d.mts} +2 -2
- package/dist/{index-B6Kq1BtL.d.mts → index-C8oBOTl_.d.mts} +1 -1
- package/dist/{index-CuLDybz3.d.mts → index-CDhbUjUH.d.mts} +2 -2
- package/dist/{index-CDeN0mdC.d.mts → index-CWeWBh-_.d.mts} +1 -1
- package/dist/{index-SIP-fI28.d.mts → index-D4XNkbM4.d.mts} +1 -1
- package/dist/{index-C6eJrtTA.d.mts → index-D7IZQNhD.d.mts} +2 -2
- package/dist/{index-CU_HMaeC.d.mts → index-DCfYa3cF.d.mts} +39 -1
- package/dist/{index-VbqrC9qf.d.mts → index-DO633_D-.d.mts} +40 -40
- package/dist/{index-CVx7li6B2.d.mts → index-DU9Y9tes2.d.mts} +12 -12
- package/dist/{index-99Gz8ezO.d.mts → index-DY_0TRvM.d.mts} +3 -3
- package/dist/{index-DfJNJYPV.d.mts → index-DzlGAEws.d.mts} +4 -4
- package/dist/{index-DOkenapA.d.mts → index-LjLUr3Dm.d.mts} +10 -10
- package/dist/{index-CwJaE0fT.d.mts → index-MtDz_goH.d.mts} +125 -77
- package/dist/{index-CyB6POkH.d.mts → index-nJvYTAbD.d.mts} +1 -1
- package/dist/{index-BrelUXBT.d.mts → index-ud9i9pue.d.mts} +16 -16
- package/dist/{index-OUtnmQ8t2.d.mts → index-v9TbeVee2.d.mts} +5 -5
- 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/{lib-0MqNtDuH.mjs → lib-BmXBuE-w.mjs} +1 -1
- package/dist/{lib-dlyJT26K.mjs → lib-R-c_q77C.mjs} +1 -1
- package/dist/{load-extensions-DM1PgW4a.d.mts → load-extensions-Bu10B5B1.d.mts} +1 -1
- package/dist/{load-extensions-BHTj3d_P.mjs → load-extensions-s4YmICgn.mjs} +1 -1
- package/dist/{materialization-BQuh_gaE.mjs → materialization-BwC7pVg2.mjs} +1 -1
- package/dist/mcp-http-server/index.d.mts +1 -1
- package/dist/mcp-http-server/index.mjs +1 -1
- package/dist/model-Cn1IFEP8.mjs +1 -0
- package/dist/{namespace-c5XPzbf3.d.mts → namespace-BYsKOw-g.d.mts} +2 -2
- package/dist/{namespace-ZAIFBrIy.mjs → namespace-CnRcpgJ8.mjs} +1 -1
- package/dist/namespace-DFc1nkal.mjs +1 -0
- package/dist/{namespace-Cb0XKb4v.d.mts → namespace-KTRWfIPy.d.mts} +2 -2
- package/dist/{namespace-DiTFR4Zt.d.mts → namespace-wuGMWlyz.d.mts} +2 -2
- package/dist/{native-session-supervisor-BlGzmZrH.mjs → native-session-supervisor-B0rziwHI.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-5vhs4wvU.mjs → orchestrator-shared-CmS8iU9_.mjs} +1 -1
- package/dist/{orchestrator-shared-BRNZ6it3.d.mts → orchestrator-shared-Cwc6JKkV.d.mts} +1 -1
- package/dist/{ownership-memory-handler-BCu1EjFO.mjs → ownership-memory-handler-DMirNILL.mjs} +1 -1
- package/dist/package-B-xpYKe8.mjs +7 -0
- package/dist/{package-x2wRhcUt.d.mts → package-Bl0mcGb8.d.mts} +13 -3
- package/dist/{package-BiZ6ehWk.mjs → package-Co36_pRw.mjs} +1 -1
- package/dist/{package-BUSXHPOT.mjs → package-D2zvQO7X.mjs} +1 -1
- package/dist/package.json +1 -1
- package/dist/{packages-Dhgmy_LJ.mjs → packages-COqPg5TI.mjs} +1 -1
- package/dist/{packages-BSVxszLf.d.mts → packages-DTz_1dCa.d.mts} +1 -1
- package/dist/{profile-DBDvy9uc.mjs → profile-C9RV7ao-.mjs} +1 -1
- package/dist/{provider-context-CSb0qX1c.mjs → provider-context-BPITm0cn.mjs} +1 -1
- package/dist/{provider-context-CTOrOW54.mjs → provider-context-CyGvwXPz.mjs} +1 -1
- package/dist/providers/index.d.mts +1 -1
- package/dist/{reaction-6e4v007b.mjs → reaction-aQJGWUWl.mjs} +1 -1
- package/dist/repo-context-Dy6eE9cg.mjs +1 -0
- package/dist/{resolved-ONt3rOMh.mjs → resolved-M6PyrgFr.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 +4 -4
- 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 +1 -1
- package/dist/runtime-node/workflow-worker/index.mjs +1 -1
- package/dist/runtime-node/workflow-worker/worker-entry.mjs +1 -1
- package/dist/{schema-B8jinlbH.mjs → schema-DrHrto2J.mjs} +1 -1
- package/dist/{schemas-BFwNBMIj.d.mts → schemas-BYyT43gX.d.mts} +4 -4
- package/dist/{schemas-BIU9Org_.mjs → schemas-CQKfd2Xd.mjs} +1 -1
- package/dist/{schemas-Di_kpQ0C.d.mts → schemas-CvUe_yff.d.mts} +13 -4
- package/dist/{schemas-BZabEyEV.d.mts → schemas-D2HmGmCt.d.mts} +1 -1
- package/dist/schemas-DRho446W.mjs +1 -0
- package/dist/{schemas-I9dZtAkj.d.mts → schemas-DwqibWUL.d.mts} +2 -2
- package/dist/{schemas-abY5VbS4.mjs → schemas-DyZNwquY.mjs} +1 -1
- package/dist/{selection-7SkHsmWs.mjs → selection-BDs7K53w.mjs} +1 -1
- package/dist/{server-lifecycle-hNz8U-QJ.mjs → server-lifecycle-C5Vl58sN.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.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 +4 -4
- 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/filesystem/namespace.d.mts +6 -6
- package/dist/services/filesystem/schemas.d.mts +3 -3
- package/dist/services/git/namespace.d.mts +2 -2
- package/dist/services/git/namespace.mjs +1 -1
- package/dist/services/git/schemas.d.mts +1 -1
- package/dist/services/git/schemas.mjs +1 -1
- package/dist/services/harness/index.d.mts +4 -4
- package/dist/services/harness/index.mjs +1 -1
- package/dist/services/index.d.mts +49 -49
- 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 +3 -3
- package/dist/services/log-import/index.mjs +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 +1 -1
- 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 +2 -2
- 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.d.mts +4 -4
- 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/extension-configs/namespace.d.mts +3 -3
- 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-A-h_Dwcs.mjs → session-9C42TPQq.mjs} +1 -1
- package/dist/{session-BDFNAcuY.mjs → session-Cn8z1hxD.mjs} +6 -6
- package/dist/{session-lineage-BzlpfLgC.d.mts → session-lineage-CEyJWg_J.d.mts} +1 -1
- package/dist/{shared-BZf2zoxL.mjs → shared-DqvfJVYk.mjs} +1 -1
- package/dist/{skill-1gU2q1KT.mjs → skill-BmRp8GhW.mjs} +1 -1
- package/dist/{src-Dlpw-Gh5.mjs → src-CmLn6zYj.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 +2 -2
- 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/testing/index.d.mts +1 -1
- package/dist/{tool-approval-service-rpV94znP.mjs → tool-approval-service-DchkAdAr.mjs} +1 -1
- package/dist/tools/index.d.mts +1 -1
- package/dist/{tools-oQPsY7v2.mjs → tools-r50UBPJ9.mjs} +1 -1
- package/dist/{transition-BeWq5nKg.d.mts → transition-CgsrmsfE.d.mts} +2 -2
- package/dist/{types-FNVbwd7z2.d.mts → types-Bnc-pdB12.d.mts} +1 -1
- package/dist/{types-D4N56a4O.d.mts → types-Dswhi1L9.d.mts} +1 -1
- package/dist/{types-CIEJ91wm.d.mts → types-ZvPhKp3j.d.mts} +8 -8
- package/dist/ui-kernel/index.d.mts +2 -2
- package/dist/ui-kernel/pages/schemas.d.mts +1 -1
- package/dist/{version-3xWJDCeF.mjs → version-sDSWOMn_.mjs} +1 -1
- package/dist/{view-builder-BwGugMWz.d.mts → view-builder-D54kvyf7.d.mts} +10 -10
- package/dist/{visibility-C5sLzqyS.mjs → visibility-syKffo3e.mjs} +1 -1
- package/dist/{worker-qgJToDTN.mjs → worker-DRQGyWAS.mjs} +1 -1
- package/dist/{worker-Csadr_du.mjs → worker-DzbPk2YI.mjs} +1 -1
- package/dist/{workflow-Cb2Pj1h3.mjs → workflow-D-yrAZW8.mjs} +1 -1
- 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 +62 -62
- 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 +2 -2
- package/dist/workflow-engine/testing/index.d.mts +3 -1
- 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 +66 -61
- package/dist/workflow-engine/workflow-orchestrator.d.mts +1 -1
- package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
- package/dist/{workflow-transitions-BI7PbrXv.mjs → workflow-transitions-D5RvMSnf.mjs} +1 -1
- package/dist/workflow-worker-CrnDwpkP.mjs +2 -0
- package/package.json +5 -1
- package/dist/artifact-nArLAotB.mjs +0 -1
- package/dist/authority-state-bootstrap-DnwkMieA.mjs +0 -1
- package/dist/bootstrap-start-client-Bdv-_2Q9.mjs +0 -1
- package/dist/execution-attempt-repository-DXyh1hgz.mjs +0 -1
- package/dist/model-B6t_-_sp.mjs +0 -1
- package/dist/namespace-D4zmxaC4.mjs +0 -1
- package/dist/package-DKfzsJVl.mjs +0 -7
- package/dist/schemas-FiFC_DI6.mjs +0 -1
- package/dist/workflow-worker-Db7EBUgh.mjs +0 -2
- /package/dist/{adapter-binding-BU7STlfd.d.mts → adapter-binding-DhANVB-O.d.mts} +0 -0
- /package/dist/{ajv-Dtk5hCZS.mjs → ajv-IlnfOGAj.mjs} +0 -0
- /package/dist/{attach-error-B-vXQFLQ.mjs → attach-error-DOlUtquX.mjs} +0 -0
- /package/dist/{attempt-fixtures-C-jQE_7B.mjs → attempt-fixtures-CMx-2OlG.mjs} +0 -0
- /package/dist/{base-orchestrator-DXiejwQ3.d.mts → base-orchestrator-tAgnJAKu.d.mts} +0 -0
- /package/dist/{capability-Bw4tsDQu.mjs → capability-BQHyskJB.mjs} +0 -0
- /package/dist/{client-BwFqO0cG.d.mts → client-At2zn3yg.d.mts} +0 -0
- /package/dist/{client-binary-version-verifier-DHBAzg3-.mjs → client-binary-version-verifier-DLziUQhw.mjs} +0 -0
- /package/dist/{client-binary-version-verifier-DySlUy9m.d.mts → client-binary-version-verifier-EOj8xXqm.d.mts} +0 -0
- /package/dist/{clients-namespace-Dh0SNZcQ.d.mts → clients-namespace-CVRwXq8f.d.mts} +0 -0
- /package/dist/{config-namespace-CZqPIAWt.d.mts → config-namespace-D7GbrasR.d.mts} +0 -0
- /package/dist/{create-static-mount-GSdckRQx.mjs → create-static-mount-BIH26VH8.mjs} +0 -0
- /package/dist/{cross-spawn-Bx_VEdpd.mjs → cross-spawn-Bi05YtQQ.mjs} +0 -0
- /package/dist/{cursor-storage-Co4itf44.mjs → cursor-storage-88xtgVAd.mjs} +0 -0
- /package/dist/{definition-D3HjoK-4.d.mts → definition-VK1rERAp.d.mts} +0 -0
- /package/dist/{definitions-CYZTuMdL.mjs → definitions-2T95Q-y6.mjs} +0 -0
- /package/dist/{descriptor-to-package-CZLujoiv.mjs → descriptor-to-package-GVZk9ZGT.mjs} +0 -0
- /package/dist/{drizzle-me-95ICP.mjs → drizzle-BrlzkYoe.mjs} +0 -0
- /package/dist/{esm-DILYVXmW.mjs → esm-B3t30-13.mjs} +0 -0
- /package/dist/{event-DmQPb5MB.mjs → event-DFI0F1Ws.mjs} +0 -0
- /package/dist/{extension-context-Cx8CetW3.d.mts → extension-context-Cpf_n5FH.d.mts} +0 -0
- /package/dist/{extension-discovery-CZkaPQBo.d.mts → extension-discovery-B0ZL076T.d.mts} +0 -0
- /package/dist/{extension-namespace-twXNwE4R.mjs → extension-namespace-CWfV3IiR.mjs} +0 -0
- /package/dist/{extension-package-provenance-BzvG6rDO.mjs → extension-package-provenance-Dr7JXjLS.mjs} +0 -0
- /package/dist/{facet-Cly0VpTI.mjs → facet-6tnSbjXc.mjs} +0 -0
- /package/dist/{filesystem-service-UYYyRL2y.d.mts → filesystem-service-BWoNtujU.d.mts} +0 -0
- /package/dist/{handler-BYQPNm8O.mjs → handler-CFT7_osu.mjs} +0 -0
- /package/dist/{host-CiHn8Yog.mjs → host-D7v3YlDG.mjs} +0 -0
- /package/dist/{identity-BULrIHmo.mjs → identity-CxMRRAXx.mjs} +0 -0
- /package/dist/{index-B5kqAW7h.d.mts → index-8a41yDOl.d.mts} +0 -0
- /package/dist/{index-Dmwnhnio2.d.mts → index-BBkJsViX2.d.mts} +0 -0
- /package/dist/{index-DNp9DP6W.d.mts → index-BL1F1xYB.d.mts} +0 -0
- /package/dist/{index-BCKhrNLC.d.mts → index-BTHdi23O.d.mts} +0 -0
- /package/dist/{index-BU8uFswE.d.mts → index-BcPO9w0j.d.mts} +0 -0
- /package/dist/{index-DcG3r0VL.d.mts → index-Bk0Xjk-B.d.mts} +0 -0
- /package/dist/{index-DGlSbpgS2.d.mts → index-Bn1JTbn_2.d.mts} +0 -0
- /package/dist/{index-CYUhTE552.d.mts → index-C75h1xHF2.d.mts} +0 -0
- /package/dist/{index-DB4Xggtt.d.mts → index-CDA33y5A.d.mts} +0 -0
- /package/dist/{index-B9-1l1oh.d.mts → index-CSJOBx3H.d.mts} +0 -0
- /package/dist/{index-BAL1FiaJ.d.mts → index-CVh7ZP2I.d.mts} +0 -0
- /package/dist/{index-6wmqw_ng.d.mts → index-Ccaqmi0J.d.mts} +0 -0
- /package/dist/{index-zvoiT54b.d.mts → index-CjazerMN.d.mts} +0 -0
- /package/dist/{index-C_R6ifn9.d.mts → index-DXSVC0bM.d.mts} +0 -0
- /package/dist/{index-D3_QOfke.d.mts → index-Du-eXjEN.d.mts} +0 -0
- /package/dist/{index-DbYjMWlj.d.mts → index-DwKPj8jD.d.mts} +0 -0
- /package/dist/{index-LsZNB_gb.d.mts → index-DwY1Mt9a.d.mts} +0 -0
- /package/dist/{index-C-6g2xzN.d.mts → index-DzHc6hsJ.d.mts} +0 -0
- /package/dist/{index-DQbcfjIb2.d.mts → index-krTCFThl2.d.mts} +0 -0
- /package/dist/{json-value-DyMQrwGz.d.mts → json-value-BKUDMT7k.d.mts} +0 -0
- /package/dist/{jsonl-transport-Dfv3RLzi.mjs → jsonl-transport-3yp3clGp.mjs} +0 -0
- /package/dist/{lib-BdfAJKDj.mjs → lib-DF6sgNx_.mjs} +0 -0
- /package/dist/{model-registry-B7ThN_s3.mjs → model-registry-BTjKBCCw.mjs} +0 -0
- /package/dist/{model-registry-DlUErRRt.mjs → model-registry-CAqJYbXg.mjs} +0 -0
- /package/dist/{modes-CyG4sgs_.mjs → modes-Bo9Vv5c9.mjs} +0 -0
- /package/dist/{namespace-ChjzkJIl.mjs → namespace-0TfAY2J7.mjs} +0 -0
- /package/dist/{namespace-JqvomFSV.d.mts → namespace-B1sjokHd.d.mts} +0 -0
- /package/dist/{namespace-De25c2ds.d.mts → namespace-B3MnuAqp.d.mts} +0 -0
- /package/dist/{namespace-BFlSY040.mjs → namespace-BCSJz417.mjs} +0 -0
- /package/dist/{namespace-DAbT1F_n.d.mts → namespace-BHb_9sh4.d.mts} +0 -0
- /package/dist/{namespace-BQ7eiQwr.d.mts → namespace-BNNFD-ul.d.mts} +0 -0
- /package/dist/{namespace-69c5HXtL.d.mts → namespace-BgaVgd00.d.mts} +0 -0
- /package/dist/{namespace-CBf5xG_A.d.mts → namespace-BiEV44Mk.d.mts} +0 -0
- /package/dist/{namespace-B8kUQpwo.mjs → namespace-CDoyzyV4.mjs} +0 -0
- /package/dist/{namespace-B7fMkHmy.d.mts → namespace-CjmNxtr1.d.mts} +0 -0
- /package/dist/{namespace-BoOLmi67.d.mts → namespace-Cy62a3YP.d.mts} +0 -0
- /package/dist/{namespace-CIF_1OWi.d.mts → namespace-Czr38fiF.d.mts} +0 -0
- /package/dist/{namespace-C9d0aoYT.mjs → namespace-DORNUF0_.mjs} +0 -0
- /package/dist/{namespace-QXCaZK3I.mjs → namespace-DX3QsYpv.mjs} +0 -0
- /package/dist/{namespace-ZN49zpqw.mjs → namespace-Dyxpur8_.mjs} +0 -0
- /package/dist/{namespace-CUXZS_Ia.d.mts → namespace-btfJrUf6.d.mts} +0 -0
- /package/dist/{namespace-DAW4OY3-.d.mts → namespace-fEBskugJ.d.mts} +0 -0
- /package/dist/{out-Cn6vBxlH.mjs → out-og8659Ny.mjs} +0 -0
- /package/dist/{ownership-recovery-guard-Ce9-C5Sa.mjs → ownership-recovery-guard-CYA5CsiO.mjs} +0 -0
- /package/dist/{package-D4eLGGv4.mjs → package-BecmlOXC.mjs} +0 -0
- /package/dist/{platform-C-fDsuEl.mjs → platform-BdLHWgVc.mjs} +0 -0
- /package/dist/{providers-DVlsnJaY.mjs → providers-DGTA-lki.mjs} +0 -0
- /package/dist/{providers-namespace-DcPil5uz.d.mts → providers-namespace-Bming6U8.d.mts} +0 -0
- /package/dist/{quick-lru-CVryNCTx.mjs → quick-lru-bVGGo5bq.mjs} +0 -0
- /package/dist/{registry-Q9gCZtxz.mjs → registry-Cu3eD3UY.mjs} +0 -0
- /package/dist/{runtime-inputs-CMjGjK7W.d.mts → runtime-inputs-DeOea-ab.d.mts} +0 -0
- /package/dist/{schema-DIgKUfuF.d.mts → schema-DFCBjTB7.d.mts} +0 -0
- /package/dist/{schema-introspection-CSnLZJpC.mjs → schema-introspection-BsWP1vGC.mjs} +0 -0
- /package/dist/{schema-DIHGEQx3.mjs → schema-mXXJcaQT.mjs} +0 -0
- /package/dist/{schemas-BKnJj2i-.mjs → schemas-7fHmNUQc.mjs} +0 -0
- /package/dist/{schemas-BFgsIiSb.mjs → schemas-BE-gfjGI.mjs} +0 -0
- /package/dist/{schemas-CM3Ejp-n.d.mts → schemas-BLy33xay.d.mts} +0 -0
- /package/dist/{schemas-Ge_bamoP.d.mts → schemas-BkCqhK3X.d.mts} +0 -0
- /package/dist/{schemas-NwKrrrPF.d.mts → schemas-Cz7H2f7S.d.mts} +0 -0
- /package/dist/{schemas-DYeS-mtz.d.mts → schemas-DGKWi7mk.d.mts} +0 -0
- /package/dist/{schemas-Vv0GtBaZ.d.mts → schemas-DTBWnWjN.d.mts} +0 -0
- /package/dist/{schemas-COnD70WD.d.mts → schemas-DYIVJDlx.d.mts} +0 -0
- /package/dist/{schemas-qbaSxHDL.d.mts → schemas-DqWwz4eR.d.mts} +0 -0
- /package/dist/{schemas-DTyZjKQf2.d.mts → schemas-GyKYcV-Z2.d.mts} +0 -0
- /package/dist/{schemas-CnFVygzI.mjs → schemas-HffXbw8C.mjs} +0 -0
- /package/dist/{schemas-CbhvgFQs.mjs → schemas-MIYusvwn.mjs} +0 -0
- /package/dist/{schemas-BapfTRqp.mjs → schemas-NYUz8K9Q.mjs} +0 -0
- /package/dist/{semver-D_D2mA48.mjs → semver-_h8-BJ8k.mjs} +0 -0
- /package/dist/{server-lifecycle-BPAN-b0i.d.mts → server-lifecycle-_m_x1_TC.d.mts} +0 -0
- /package/dist/{shared-schemas-kUho6Kmw.mjs → shared-schemas-CaL1iEk6.mjs} +0 -0
- /package/dist/{src-Du_285FN.mjs → src-DdaPoQOD.mjs} +0 -0
- /package/dist/{storage-namespace-Dtz2G1if.mjs → storage-namespace-DBuKMBth.mjs} +0 -0
- /package/dist/{storage-namespace-definition-BJCbqVWz.mjs → storage-namespace-definition-4UYuij1r.mjs} +0 -0
- /package/dist/{storage-namespace-definition-D6soSjKE.d.mts → storage-namespace-definition-CsaZPU3n.d.mts} +0 -0
- /package/dist/{storage-namespace-C9oFExfb.d.mts → storage-namespace-zRXWqAfO.d.mts} +0 -0
- /package/dist/{supports-color-BNmyqLq0.mjs → supports-color-DG_rcVqJ.mjs} +0 -0
- /package/dist/{telemetry-CUkZrhW6.mjs → telemetry-BLYrkonr.mjs} +0 -0
- /package/dist/{timeout-DeBYTGBR.mjs → timeout-d0dzIY3V.mjs} +0 -0
- /package/dist/{tray-menu-service-TWrmvXSo.mjs → tray-menu-service-BGwXKJYr.mjs} +0 -0
- /package/dist/{types-D9GJ7FyQ.mjs → types-Bh2fQoxM.mjs} +0 -0
- /package/dist/{types-BOsf2SVm.d.mts → types-CccTiXH2.d.mts} +0 -0
- /package/dist/{types-DZvkUmHS.d.mts → types-DXGVwrQn.d.mts} +0 -0
- /package/dist/{types-BZnJ_4e2.d.mts → types-DjxvRcX6.d.mts} +0 -0
- /package/dist/{types-CWgYlxjU.d.mts → types-nor1SQLZ.d.mts} +0 -0
- /package/dist/{ui-config-9hlZAJOS.mjs → ui-config-CsH94fwa.mjs} +0 -0
- /package/dist/{variant-73kFgYBK.mjs → variant-BZ9UcJBi.mjs} +0 -0
- /package/dist/{window-registry-Bvjvpwhn.d.mts → window-registry-DQ7udUzI.d.mts} +0 -0
- /package/dist/{window-registry-CzAwaPKL.mjs → window-registry-DQkv5wM9.mjs} +0 -0
- /package/dist/{zod-json-schema-B1mZz7S4.mjs → zod-json-schema-DGWHUOK0.mjs} +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{$ as e,A as t,B as n,D as r,F as i,G as a,H as o,I as s,J as c,K as l,M as u,N as d,O as f,P as p,Q as ee,R as te,U as ne,V as m,W as h,X as re,Y as ie,Z as ae,_t as oe,a as se,at as ce,bt as g,c as le,ct as ue,dt as de,et as fe,f as pe,ft as me,g as he,gt as ge,h as _e,ht as ve,i as ye,it as be,j as xe,k as _,l as Se,lt as Ce,m as we,mt as Te,n as Ee,nt as De,o as Oe,ot as ke,p as Ae,pt as je,q as Me,r as Ne,rt as Pe,st as Fe,tt as Ie,u as Le,ut as Re,v as ze,vt as Be,yt as Ve,z as He}from"./authority-state-bootstrap-DnwkMieA.mjs";import{a as Ue}from"./execution-attempt-repository-DXyh1hgz.mjs";import{assertWorkflowTriggerPayload as We,compileWorkflowTriggerBindingFilter as Ge}from"./workflow-engine/workflow-trigger-binding-consumer.mjs";import{a as Ke,r as qe}from"./execution-attempt-owner-recovery-CdH04iwP.mjs";import{SerialLane as Je}from"@makaio/framework/utils";import{ArtifactSubjects as Ye,AutomationTriggerSubjects as Xe,CRON_AUTOMATION_TRIGGER_KIND as Ze,EXECUTION_LIST_DEFAULT_LIMIT as Qe,EXECUTION_LIST_MAX_LIMIT as v,EXECUTION_LIST_MIN_LIMIT as y,EXTERNAL_EXECUTION_ID_PREFIX as b,ExecutionAttemptSchemas as x,ExecutionAttemptSubjects as S,ExecutionsByArtifactRefsQuerySchema as $e,JsonPatchOperationSchema as et,JsonValueSchema as tt,SessionSubjects as nt,WORKFLOW_CANCELLED_REASON as rt,WorkLogFrameEntrySchema as it,WorkerSubjects as at,WorkflowAutomationTriggerBindingSchema as ot,WorkflowError as C,WorkflowErrorCode as st,WorkflowNamespace as ct,WorkflowRunContextSchema as lt,WorkflowRunResultSchema as ut,WorkflowStepTypeSchema as dt,WorkflowSubjects as w,createWorkflowCancelSubject as ft,createWorkflowDelegateResultFinalizerNamespace as pt,createWorkflowFinalizerNamespace as mt,dep as ht,extensionToken as gt,serializeArtifactRef as _t,walkWorkflowDefinition as vt}from"@makaio/framework/contracts";import{BaseService as yt}from"@makaio/framework/service-base";import{defineDialectSchema as bt,executeTransaction as T,getDatabaseDialect as xt,registerDrizzleHandlers as St,resolveSchema as E,serializeDatabaseOperation as D}from"@makaio/framework/storage/drizzle";import{and as O,asc as k,count as A,desc as j,eq as M,getTableColumns as Ct,gte as wt,isNotNull as Tt,isNull as N,lt as Et,lte as Dt,notInArray as Ot,or as kt,sql as P,sum as F}from"drizzle-orm";import{SessionToken as At}from"@makaio/framework/services";import{AutomationTriggerBindingRuntimeToken as jt}from"@makaio/framework/services/automation-trigger";const Mt=l.postgres,Nt=De.postgres,Pt=c.postgres,Ft=be.postgres,It=ue.postgres,Lt=re.postgres,Rt=ke.postgres,zt=ge.postgres,Bt=me.postgres,Vt=Re.postgres,Ht=Te.postgres,Ut=ee.postgres,Wt=fe.postgres,Gt=Be.postgres,I=bt({workflowDefinitions:a,workflowExecutions:Ie,workflowExecutionFrames:Me,workflowGateInstances:Pe,workflowStepSpans:Fe,workflowExecutionLinks:ie,workflowRunContexts:ce,worklogSummaries:ve,worklogFrameEntries:de,worklogArtifactWrites:Ce,worklogGateEvents:je,workflowExecutionState:ae,workflowExecutionStateEvents:e,workflowFinalizations:oe},{workflowDefinitions:Mt,workflowExecutions:Nt,workflowExecutionFrames:Pt,workflowGateInstances:Ft,workflowStepSpans:It,workflowExecutionLinks:Lt,workflowRunContexts:Rt,worklogSummaries:zt,worklogFrameEntries:Bt,worklogArtifactWrites:Vt,worklogGateEvents:Ht,workflowExecutionState:Ut,workflowExecutionStateEvents:Wt,workflowFinalizations:Gt});function L(e){return e.type===`global`?{scopeType:`global`,scopeKind:``,scopeId:``}:e.type===`external`?{scopeType:`external`,scopeKind:e.kind,scopeId:e.id}:{scopeType:e.type,scopeKind:``,scopeId:e.id}}function R(e){switch(e.scopeType){case`global`:return{type:`global`};case`external`:if(!e.scopeKind||!e.scopeId)throw Error(`Invalid external workflow scope row: scopeKind and scopeId are required`);return{type:`external`,kind:e.scopeKind,id:e.scopeId};case`workspace`:case`session`:if(!e.scopeId)throw Error(`Invalid ${e.scopeType} workflow scope row: scopeId is required`);return{type:e.scopeType,id:e.scopeId};default:{let t=e.scopeType;throw Error(`Unknown scope type: ${String(t)}`)}}}function Kt(e,t){let{scopeType:n,scopeKind:r,scopeId:i}=L(t);return[M(e.scopeType,n),M(e.scopeKind,r),M(e.scopeId,i)]}function z(e){return{id:e.id,name:e.name,description:e.description??void 0,root:e.root,inputSchema:e.inputSchema??void 0,configSchema:e.configSchema??void 0,outputSchema:e.outputSchema??void 0,state:e.state??void 0,artifact:e.artifact??void 0,triggers:e.triggers??void 0,scope:R(e),canvasLayout:e.canvasLayout??void 0,source:e.source??void 0,executableSource:e.executableSource??void 0,requirements:e.requirements??void 0,successFinalizerId:e.successFinalizerId??void 0}}function qt(e,t){let n=L(e.scope);return{id:e.id,name:e.name??e.id,root:e.root,description:e.description??null,inputSchema:e.inputSchema??null,configSchema:e.configSchema??null,outputSchema:e.outputSchema??null,state:e.state??null,artifact:e.artifact??null,triggers:e.triggers??null,canvasLayout:e.canvasLayout??null,source:e.source??null,executableSource:e.executableSource??null,requirements:e.requirements??null,successFinalizerId:e.successFinalizerId??null,createdAt:t,updatedAt:t,...n}}function Jt(e,t){let{workflowDefinitions:n}=E(t,I),r=Ct(n),i=e.on(h.get,async e=>{let r=await t.select().from(n).where(M(n.id,e.payload.id)).limit(1);e.setResult({workflow:r[0]?z(r[0]):null})}),a=e.on(h.set,async i=>{let a=i.payload.workflow,o=Date.now(),s=qt(a,o),c=await D(t,async()=>{let e=await t.insert(n).values(s).onConflictDoNothing({target:n.id}).returning();if(e.length>0)return{kind:`created`,row:e[0]};let[i]=await t.update(n).set({name:s.name,root:s.root,updatedAt:o,createdAt:P`COALESCE(${r.createdAt}, ${o})`,description:s.description===null?P`${r.description}`:s.description,inputSchema:s.inputSchema===null?P`${r.inputSchema}`:s.inputSchema,configSchema:s.configSchema===null?P`${r.configSchema}`:s.configSchema,outputSchema:s.outputSchema===null?P`${r.outputSchema}`:s.outputSchema,state:s.state,artifact:s.artifact===null?P`${r.artifact}`:s.artifact,triggers:s.triggers===null?P`${r.triggers}`:s.triggers,canvasLayout:s.canvasLayout===null?P`${r.canvasLayout}`:s.canvasLayout,source:s.source===null?P`${r.source}`:s.source,executableSource:s.executableSource,requirements:s.requirements,successFinalizerId:s.successFinalizerId,...L(a.scope)}).where(M(n.id,a.id)).returning();return i?{kind:`updated`,row:i}:void 0});c&&await e.emit(c.kind===`created`?g.definition.created:g.definition.updated,z(c.row)),i.setResult({id:a.id})}),o=e.on(h.delete,async r=>{let i=(await D(t,()=>t.delete(n).where(M(n.id,r.payload.id)).returning())).length>0;i&&await e.emit(g.definition.deleted,{id:r.payload.id}),r.setResult({deleted:i})}),s=e.on(h.list,async e=>{let r=e.payload,i=r.scope?Kt(n,r.scope):[],a=i.length>0?await t.select().from(n).where(O(...i)):await t.select().from(n);e.setResult({workflows:a.map(z)})});return()=>{i(),a(),o(),s()}}function Yt(e){return{frameId:e.frameId,nodeId:e.nodeId,nodeType:e.nodeType,path:e.path,parentFrameId:e.parentFrameId??void 0,status:e.status,attempt:e.attempt,iteration:e.iteration??void 0,branchKey:e.branchKey??void 0,...e.outputPresent?{output:e.output}:{},error:e.error??void 0,startedAt:e.startedAt??void 0,completedAt:e.completedAt??void 0}}function Xt(e,t){return{frameId:t.frameId,executionId:e,nodeId:t.nodeId,nodeType:t.nodeType,path:t.path,parentFrameId:t.parentFrameId??null,status:t.status,attempt:t.attempt,iteration:t.iteration??null,branchKey:t.branchKey??null,output:t.output===void 0?null:t.output,outputPresent:t.output!==void 0,error:t.error??null,startedAt:t.startedAt??null,completedAt:t.completedAt??null}}function Zt(e,t){let{workflowExecutionFrames:n}=E(t,I),r=e.on(h.setFrame,async e=>{let{executionId:r,frame:i}=e.payload;if(!m(e,r))throw Error(`Unauthorized: caller is not permitted to write frames for execution: ${r}`);let a=Xt(r,i);await D(t,()=>t.insert(n).values(a).onConflictDoUpdate({target:n.frameId,set:a})),e.setResult({frameId:i.frameId})}),i=e.on(h.getFrame,async e=>{let r=await t.select().from(n).where(M(n.frameId,e.payload.frameId)).limit(1);e.setResult({frame:r[0]?Yt(r[0]):null})}),a=e.on(h.listFrames,async e=>{if(!m(e,e.payload.executionId))throw Error(`Unauthorized: caller is not permitted to list frames for execution: ${e.payload.executionId}`);let r=await t.select().from(n).where(M(n.executionId,e.payload.executionId)).orderBy(k(n.startedAt),k(n.frameId));e.setResult({frames:r.map(Yt)})});return()=>{r(),i(),a()}}function Qt(e){return`${e.executionId}:${e.nodeId}:${e.frameId}`}function B(e){return{executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,schema:e.schema,prompt:e.prompt??void 0,status:e.status,autoAction:e.autoAction,timeoutMs:e.timeoutMs??null,...e.resumeDataPresent?{resumeData:e.resumeData}:{},...e.reason===null?{}:{reason:e.reason},createdAt:e.createdAt,resolvedAt:e.resolvedAt??void 0}}function V(e){return{id:Qt(e),executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,schema:e.schema,prompt:e.prompt??null,status:e.status,autoAction:e.autoAction,timeoutMs:e.timeoutMs,resumeData:e.resumeData===void 0?null:e.resumeData,reason:e.reason??null,resumeDataPresent:e.resumeData!==void 0,createdAt:e.createdAt,resolvedAt:e.resolvedAt??null}}function $t(e,t,n,r){if(e===void 0&&t===void 0)throw Error(`Either executionId or status is required to list gate instances.`);let i=n??Qe;if(!Number.isInteger(i)||i<y||i>v)throw Error(`Gate instance list limit must be an integer between ${y} and ${v}.`);return{resolvedLimit:i,predicates:[...e===void 0?[]:[M(r.executionId,e)],...t===void 0?[]:[M(r.status,t)]]}}function en(e,t){let{workflowExecutions:n,workflowGateInstances:r}=E(t,I),i=e.on(h.setGateInstance,async e=>{let n=e.payload.gate;if(!m(e,n.executionId))throw Error(`Unauthorized: caller is not permitted to write gates for execution: ${n.executionId}`);let i=V(n);await D(t,()=>t.insert(r).values(i).onConflictDoUpdate({target:r.id,set:i})),e.setResult({id:i.id})}),a=e.on(h.resolveWaitingGateInstance,async e=>{let n=e.payload.gate,i=V(n),a=await D(t,()=>t.update(r).set(i).where(O(M(r.id,i.id),M(r.status,`waiting`))).returning({id:r.id}));e.setResult({accepted:a.length===1})}),o=e.on(h.getGateInstance,async e=>{let{executionId:n,nodeId:i,frameId:a}=e.payload;if(!m(e,n))throw Error(`Unauthorized: caller is not permitted to read gates for execution: ${n}`);let o=[M(r.executionId,n),M(r.nodeId,i)];a!==void 0&&o.push(M(r.frameId,a));let s=await t.select().from(r).where(O(...o)).limit(1);e.setResult({gate:s[0]?B(s[0]):null})}),s=e.on(h.listGateInstances,async e=>{let{executionId:n,status:i,limit:a}=e.payload,{resolvedLimit:o,predicates:s}=$t(n,i,a,r),c=await t.select().from(r).where(O(...s)).orderBy(j(r.createdAt),j(r.id)).limit(o);e.setResult({gates:c.map(B)})}),c=e.on(h.listPausedGateTimeouts,async e=>{let i=await t.select({gate:r}).from(r).innerJoin(n,M(r.executionId,n.id)).where(O(M(r.status,`waiting`),M(n.status,`paused`),Tt(r.timeoutMs)));e.setResult({gates:i.map(e=>B(e.gate))})});return()=>{i(),a(),o(),s(),c()}}function tn(e){return{executionId:e.executionId,frameId:e.frameId,stepId:e.stepId,stepType:e.stepType,status:e.status,startedAt:e.startedAt??void 0,completedAt:e.completedAt??void 0,durationMs:e.durationMs??void 0,inputTokens:e.inputTokens??void 0,outputTokens:e.outputTokens??void 0,estimatedCost:e.estimatedCost??void 0,toolCallCount:e.toolCallCount??void 0,input:e.input??void 0,output:e.output??void 0}}function nn(e){return{sourceExecutionId:e.sourceExecutionId,targetExecutionId:e.targetExecutionId,linkType:e.linkType,metadata:e.metadata??void 0}}function rn(e,t){let{workflowStepSpans:n,workflowExecutionLinks:r}=E(t,I),i=e.on(h.setSpan,async e=>{let{span:r}=e.payload;if(!m(e,r.executionId))throw Error(`Unauthorized: caller is not permitted to write spans for execution: ${r.executionId}`);await D(t,()=>t.insert(n).values(r).onConflictDoUpdate({target:[n.executionId,n.frameId],set:r})),e.setResult({id:`${r.executionId}:${r.frameId}`})}),a=e.on(h.listSpans,async e=>{let r=await t.select().from(n).where(M(n.executionId,e.payload.executionId)).orderBy(k(n.startedAt),k(n.stepId),k(n.frameId));e.setResult({spans:r.map(tn)})}),o=e.on(h.setExecutionLink,async e=>{let{link:n}=e.payload;await D(t,()=>t.insert(r).values(n).onConflictDoUpdate({target:[r.sourceExecutionId,r.targetExecutionId],set:n})),e.setResult({id:`${n.sourceExecutionId}:${n.targetExecutionId}`})}),s=e.on(h.listExecutionLinks,async e=>{let{sourceExecutionId:n,targetExecutionId:i}=e.payload;if(n===void 0&&i===void 0)throw Error(`Either sourceExecutionId or targetExecutionId is required to list execution links.`);let a=[...n===void 0?[]:[M(r.sourceExecutionId,n)],...i===void 0?[]:[M(r.targetExecutionId,i)]],o=t.select().from(r).where(O(...a));e.setResult({links:(await o).map(nn)})});return()=>{i(),a(),o(),s()}}function H(e,t){return t===null?xt(e)===`postgres`?P`'null'::jsonb`:P`'null'`:t}function an(e){switch(e.kind){case`path`:return{sourceKind:`path`,sourcePath:e.path,sourceFilename:null,sourceCode:null};case`source`:return{sourceKind:`source`,sourcePath:null,sourceFilename:e.filename,sourceCode:e.source};case`definition`:return{sourceKind:`definition`,sourcePath:null,sourceFilename:null,sourceCode:null}}}function on(e){switch(e.sourceKind){case`path`:if(!e.sourcePath)throw Error(`Invalid run context row: sourcePath required for kind=path`);return{kind:`path`,path:e.sourcePath};case`source`:if(!e.sourceFilename)throw Error(`Invalid run context row: sourceFilename required for kind=source`);return{kind:`source`,filename:e.sourceFilename,source:e.sourceCode??``};case`definition`:return{kind:`definition`,workflowId:e.workflowId};default:throw Error(`Unknown run context source kind: ${String(e.sourceKind)}`)}}function sn(e){return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,source:on(e),definitionSnapshot:e.definitionSnapshot??void 0,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,triggerMode:e.triggerMode,...e.artifactRef===null?{}:{artifactRef:e.artifactRef},scope:R(e),...e.dispatchMetadata===null?{}:{dispatchMetadata:e.dispatchMetadata},cancelSubject:e.cancelSubject,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy??`wait-in-process`,...e.terminalAuthority===null?{}:{terminalAuthority:e.terminalAuthority},...e.materializationSpec===null?{}:{materializationSpec:e.materializationSpec}}}function cn(e){let t=an(e.source),n=L(e.scope);return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,...t,definitionSnapshot:e.definitionSnapshot??null,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,triggerMode:e.triggerMode??`immediate`,artifactRef:e.artifactRef??null,dispatchMetadata:e.dispatchMetadata??null,...n,cancelSubject:e.cancelSubject,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy,terminalAuthority:e.terminalAuthority??null,materializationSpec:e.materializationSpec??null}}async function ln(e,t,n){let r=cn(t);await e.insert(n).values(r).onConflictDoUpdate({target:n.executionId,set:r})}function un(e,t){let{workflowRunContexts:n,workflowExecutionState:r,workflowExecutionStateEvents:i}=E(t,I),a=e.on(h.setRunContext,async e=>{let a=e.payload.runContext,o=e.payload.initialState;await T(t,async e=>{if(await ln(e,a,n),o===void 0)return;let s=Date.now(),c=H(t,o);await e.insert(r).values({executionId:a.executionId,sequence:0,value:c,updatedAt:s}).onConflictDoNothing(),await e.insert(i).values({executionId:a.executionId,sequence:0,patch:[],value:c,createdAt:s}).onConflictDoNothing()}),e.setResult({executionId:a.executionId})}),o=e.on(h.getRunContext,async e=>{let{executionId:r}=e.payload,i=await t.select().from(n).where(M(n.executionId,r)),a=i[0]?sn(i[0]):null;e.setResult({runContext:a})});return()=>{a(),o()}}async function dn(e,t,n){let{workflowExecutionState:r,workflowExecutionStateEvents:i}=E(e,I),a=Date.now(),o=H(e,n);await T(e,async e=>{await e.insert(r).values({executionId:t,sequence:0,value:o,updatedAt:a}).onConflictDoNothing(),await e.insert(i).values({executionId:t,sequence:0,patch:[],value:o,createdAt:a}).onConflictDoNothing()})}async function fn(e,t){let{workflowExecutionState:n}=E(e,I),r=(await e.select().from(n).where(M(n.executionId,t)).limit(1))[0];return r?{executionId:r.executionId,sequence:r.sequence,value:r.value}:null}async function pn(e,t){let{workflowExecutionState:r,workflowExecutionStateEvents:i}=E(e,I),a=Date.now(),o=H(e,t.nextValue);return T(e,async e=>{let s=(await e.select().from(r).where(M(r.executionId,t.executionId)).limit(1))[0];if(!s)throw Error(`no workflow state for execution ${t.executionId}`);if(t.expectedSequence===void 0)throw Error(`expectedSequence is required to patch workflow state`);let c=s.sequence+1,l=n(s.value,t.nextValue);if((await e.update(r).set({sequence:c,value:o,updatedAt:a}).where(O(M(r.executionId,t.executionId),M(r.sequence,t.expectedSequence))).returning()).length===0)throw Error(`state sequence conflict: expected ${String(t.expectedSequence)}, got ${String(s.sequence)}`);return await e.insert(i).values({executionId:t.executionId,sequence:c,patch:l,value:o,createdAt:a}),{executionId:t.executionId,sequence:c,patch:l,value:t.nextValue}})}function mn(e,t){let n=e.on(h.initializeState,async e=>{let{executionId:n,initialValue:r}=e.payload;await dn(t,n,r),e.setResult({})}),r=e.on(h.getState,async e=>{let{executionId:n}=e.payload,r=await fn(t,n);e.setResult({state:r})}),i=e.on(h.patchState,async e=>{let{executionId:n,expectedSequence:r,nextValue:i}=e.payload,a=await pn(t,{executionId:n,expectedSequence:r,nextValue:i});e.setResult(a)});return()=>{n(),r(),i()}}function hn(e){return{executionId:e.executionId,workflowId:e.workflowId,workflowName:e.workflowName??void 0,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt??void 0,durationMs:e.durationMs??void 0,totalInputTokens:e.totalInputTokens??void 0,totalOutputTokens:e.totalOutputTokens??void 0,totalEstimatedCost:e.totalEstimatedCost??void 0,error:e.error??void 0,failedNodeId:e.failedNodeId??void 0}}async function gn(e,t){let{worklogSummaries:n}=E(e,I);await e.insert(n).values(t).onConflictDoNothing()}async function _n(e,t){let{worklogSummaries:n}=E(e,I);await e.insert(n).values(t).onConflictDoUpdate({target:n.executionId,set:vn(t),setWhere:Ot(n.status,[`completed`,`failed`,`cancelled`])})}function vn(e){return{workflowId:e.workflowId,workflowName:e.workflowName,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt,durationMs:e.durationMs,error:e.error,failedNodeId:e.failedNodeId}}async function U(e,t){let{worklogSummaries:n}=E(e,I),r=await e.select().from(n).where(M(n.executionId,t)).limit(1);return r[0]?hn(r[0]):null}async function yn(e,t={}){let{worklogSummaries:n}=E(e,I),{workflowId:r,status:i,limit:a=50,offset:o=0}=t,s=[...r===void 0?[]:[M(n.workflowId,r)],...i===void 0?[]:[M(n.status,i)]],c=s.length>0?O(...s):void 0,[l,u]=await Promise.all([e.select().from(n).where(c).orderBy(j(n.startedAt)).limit(a).offset(o),e.select({count:A()}).from(n).where(c)]);return{items:l.map(hn),total:u[0]?.count??0}}async function bn(e,t){let{worklogFrameEntries:n}=E(e,I);await e.insert(n).values(t).onConflictDoNothing()}async function xn(e,t){let{worklogFrameEntries:n}=E(e,I);await e.insert(n).values(t).onConflictDoUpdate({target:n.frameId,set:t,setWhere:Ot(n.status,[`completed`,`failed`,`skipped`,`cancelled`])})}async function W(e,t){let{worklogFrameEntries:n}=E(e,I);return(await e.select().from(n).where(M(n.frameId,t)).limit(1))[0]??null}async function Sn(e,t){let n=await W(e,t);return n===null?null:it.parse({executionId:n.executionId,frameId:n.frameId,nodeId:n.nodeId,nodeType:n.nodeType,path:n.path,status:n.status,attempt:n.attempt,iteration:n.iteration??void 0,branchKey:n.branchKey??void 0,startedAt:n.startedAt??void 0,completedAt:n.completedAt??void 0,durationMs:n.durationMs??void 0,inputTokens:n.inputTokens??void 0,outputTokens:n.outputTokens??void 0,estimatedCost:n.estimatedCost??void 0,error:n.error??void 0})}async function Cn(e,t){let{worklogArtifactWrites:n}=E(e,I);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}function wn(e,t,n,r,i){return`${e}:${t}:${n}:${r}:${i}`}async function G(e,t){let{worklogGateEvents:n}=E(e,I);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}async function Tn(e,t){let{worklogGateEvents:n}=E(e,I);return(await e.select().from(n).where(M(n.id,t)).limit(1))[0]??null}function K(e,t,n){return`${e}:${t}:${n}`}async function En(e,t,n){let[r]=await e.update(t).set({totalInputTokens:t.totalInputTokens}).where(M(t.executionId,n)).returning();return r}async function Dn(e,t,n){let[r]=await e.select({totalInputTokens:F(t.inputTokens),totalOutputTokens:F(t.outputTokens),totalEstimatedCost:F(t.estimatedCost),measuredInputTokens:A(t.inputTokens),measuredOutputTokens:A(t.outputTokens),measuredCosts:A(t.estimatedCost)}).from(t).where(M(t.executionId,n));return{totalInputTokens:Number(r?.totalInputTokens??0),totalOutputTokens:Number(r?.totalOutputTokens??0),totalEstimatedCost:Number(r?.totalEstimatedCost??0),hasMeasurements:Number(r?.measuredInputTokens??0)>0||Number(r?.measuredOutputTokens??0)>0||Number(r?.measuredCosts??0)>0}}function On(e){return e.hasMeasurements}async function kn(e,t,n,r){await e.update(t).set({totalInputTokens:r.totalInputTokens,totalOutputTokens:r.totalOutputTokens,totalEstimatedCost:r.totalEstimatedCost}).where(M(t.executionId,n))}async function An(e,t,n,r){let i=P`coalesce((select sum(${n.inputTokens}) from ${n} where ${n.executionId} = ${r}), 0)`,a=P`coalesce((select sum(${n.outputTokens}) from ${n} where ${n.executionId} = ${r}), 0)`,o=P`coalesce((select sum(${n.estimatedCost}) from ${n} where ${n.executionId} = ${r}), 0)`,s=P`exists(
|
|
2
|
-
select 1 from ${n}
|
|
3
|
-
where ${n.executionId} = ${r}
|
|
4
|
-
and (${n.inputTokens} is not null
|
|
5
|
-
or ${n.outputTokens} is not null
|
|
6
|
-
or ${n.estimatedCost} is not null)
|
|
7
|
-
)`;await e.update(t).set({totalInputTokens:i,totalOutputTokens:a,totalEstimatedCost:o}).where(O(M(t.executionId,r),s))}async function jn(e,t){let{worklogSummaries:n,worklogFrameEntries:r}=E(e,I);if(xt(e)===`sqlite`){await An(e,n,r,t);return}await T(e,async e=>{if(await En(e,n,t)===void 0)return;let i=await Dn(e,r,t);On(i)&&await kn(e,n,t,i)})}async function Mn(e,t={}){let{worklogSummaries:n}=E(e,I),{workflowId:r,since:i,until:a}=t,o=[...r===void 0?[]:[M(n.workflowId,r)],...i===void 0?[]:[wt(n.startedAt,i)],...a===void 0?[]:[Dt(n.startedAt,a)]],s=o.length>0?O(...o):void 0,[c,l]=await Promise.all([e.select({status:n.status,count:A()}).from(n).where(s).groupBy(n.status),e.select({totalDurationMs:F(n.durationMs),totalInputTokens:F(n.totalInputTokens),totalOutputTokens:F(n.totalOutputTokens),totalEstimatedCost:F(n.totalEstimatedCost)}).from(n).where(s)]),u={pending:0,running:0,paused:0,finalizing:0,completed:0,failed:0,cancelled:0},d=0;for(let e of c)u[e.status]=e.count,d+=e.count;let f=l[0];return{total:d,byStatus:u,totalDurationMs:Number(f?.totalDurationMs??0),totalInputTokens:Number(f?.totalInputTokens??0),totalOutputTokens:Number(f?.totalOutputTokens??0),totalEstimatedCost:Number(f?.totalEstimatedCost??0)}}async function Nn(e,t,n,r,i){let a=await W(t,n);if(a===null||i===void 0)return null;let o=await e.requestOptional(Ye.resolve,{ref:{refClass:`artifact`,kind:r.kind,id:r.id,revision:i}}).catch(()=>void 0);if(o===void 0||!o.handled||o.data.artifact===null)return null;let{kind:s,schemaVersion:c,scope:l}=o.data.artifact;return{nodeId:a.nodeId,artifact:{kind:s,schemaVersion:c,scope:l}}}async function q(e,t){try{await t()}catch(t){console.error(`[WorklogProjection] Write failed (${e}):`,t)}}async function J(e,t){try{await e.emit(g.worklog.changed,{executionId:t})}catch(e){console.error(`[WorklogProjection] worklog.changed emit failed for ${t}:`,e)}}const Pn=new Set([`completed`,`failed`,`cancelled`]);function Fn(e){return Pn.has(e)}async function In(e,t){return await gn(e,{executionId:t.executionId,workflowId:t.workflowId,workflowName:null,status:`running`,startedAt:t.startedAt??Date.now(),completedAt:null,durationMs:null,totalInputTokens:null,totalOutputTokens:null,totalEstimatedCost:null,error:null,failedNodeId:null}),!0}async function Ln(e,t){let n=t.completedAt??Date.now(),r=await U(e,t.executionId);return r!==null&&Fn(r.status)?!1:(await _n(e,{executionId:t.executionId,workflowId:r?.workflowId??t.executionId,workflowName:r?.workflowName??null,status:`completed`,startedAt:r?.startedAt??n-t.totalDuration,completedAt:n,durationMs:t.totalDuration,totalInputTokens:r?.totalInputTokens??null,totalOutputTokens:r?.totalOutputTokens??null,totalEstimatedCost:r?.totalEstimatedCost??null,error:null,failedNodeId:null}),!0)}async function Rn(e,t,n,r,i,a){let o=await U(e,t);if(o!==null&&Fn(o.status))return!1;let s=o?.startedAt??a;return await _n(e,{executionId:t,workflowId:o?.workflowId??t,workflowName:o?.workflowName??null,status:n,startedAt:s,completedAt:a,durationMs:a-s,totalInputTokens:o?.totalInputTokens??null,totalOutputTokens:o?.totalOutputTokens??null,totalEstimatedCost:o?.totalEstimatedCost??null,error:r,failedNodeId:i}),!0}function zn(e,t){return[e.on(g.execution.started,async n=>{let{executionId:r}=n.payload;await q(`execution.started[${r}]`,async()=>{await D(t,()=>In(t,n.payload))&&await J(e,r)})}),e.on(g.execution.completed,async n=>{let{executionId:r}=n.payload;await q(`execution.completed[${r}]`,async()=>{await D(t,()=>Ln(t,n.payload))&&await J(e,r)})}),e.on(g.execution.failed,async n=>{let{executionId:r,error:i,failedStepId:a}=n.payload,o=n.payload.completedAt??Date.now();await q(`execution.failed[${r}]`,async()=>{await D(t,()=>Rn(t,r,`failed`,i,a??null,o))&&await J(e,r)})}),e.on(g.execution.cancelled,async n=>{let{executionId:r}=n.payload,i=n.payload.completedAt??Date.now();await q(`execution.cancelled[${r}]`,async()=>{await D(t,()=>Rn(t,r,`cancelled`,null,null,i))&&await J(e,r)})})]}const Bn=new Set([`completed`,`failed`,`skipped`,`cancelled`]);function Vn(e){return Bn.has(e)}function Hn(e,t,n){return e===null?{nodeId:t,nodeType:`station`,path:[],attempt:0,iteration:null,branchKey:null,startedAt:n,inputTokens:null,outputTokens:null,estimatedCost:null}:{nodeId:e.nodeId,nodeType:e.nodeType,path:e.path,attempt:e.attempt,iteration:e.iteration,branchKey:e.branchKey,startedAt:e.startedAt,inputTokens:e.inputTokens,outputTokens:e.outputTokens,estimatedCost:e.estimatedCost}}async function Un(e,t,n,r,i,a,o){let s=o??Date.now(),c=await W(t,r);c!==null&&Vn(c.status)||(await xn(t,{frameId:r,executionId:n,...Hn(c,i,a===void 0?null:s-a),status:`completed`,completedAt:s,durationMs:a??null,error:null}),await jn(t,n),await J(e,n))}async function Wn(e,t,n,r,i,a,o,s){let c=s??Date.now(),l=await W(t,r);l!==null&&Vn(l.status)||(await xn(t,{frameId:r,executionId:n,...Hn(l,i,o===void 0?null:c-o),status:`failed`,completedAt:c,durationMs:o??null,error:a}),await J(e,n))}function Gn(e,t){return[e.on(g.frame.started,async n=>{let{executionId:r,frameId:i,nodeId:a,nodeType:o,path:s,startedAt:c}=n.payload;await q(`frame.started[${i}]`,async()=>{await bn(t,{frameId:i,executionId:r,nodeId:a,nodeType:o,path:s,status:`running`,attempt:0,iteration:null,branchKey:null,startedAt:c??Date.now(),completedAt:null,durationMs:null,inputTokens:null,outputTokens:null,estimatedCost:null,error:null}),await J(e,r)})}),e.on(g.frame.completed,async n=>{let{executionId:r,frameId:i,nodeId:a,duration:o,completedAt:s}=n.payload;await q(`frame.completed[${i}]`,()=>Un(e,t,r,i,a,o,s))}),e.on(g.frame.failed,async n=>{let{executionId:r,frameId:i,nodeId:a,error:o,duration:s,completedAt:c}=n.payload;await q(`frame.failed[${i}]`,()=>Wn(e,t,r,i,a,o,s,c))})]}const Kn={user:`rejected`,timeout:`timed-out`,cancelled:`cancelled`};function qn(e,t){return[e.on(g.gate.suspended,async n=>{let{executionId:r,frameId:i,nodeId:a,prompt:o}=n.payload;await q(`gate.suspended[${i}]`,async()=>{await G(t,{id:K(r,a,i),executionId:r,nodeId:a,frameId:i,status:`waiting`,prompt:o??null,openedAt:Date.now(),resolvedAt:null,resumeData:null}),await J(e,r)})}),e.on(g.gate.resumed,async n=>{let{executionId:r,frameId:i,nodeId:a,resumeData:o}=n.payload;await q(`gate.resumed[${i}]`,async()=>{let n=K(r,a,i),s=await Tn(t,n),c=Date.now();await G(t,{id:n,executionId:r,nodeId:a,frameId:i,status:`resumed`,prompt:s?.prompt??null,openedAt:s?.openedAt??c,resolvedAt:c,resumeData:o}),await J(e,r)})}),e.on(g.gate.resolved,async n=>Jn(n.payload,e,t)),e.on(g.artifact.updated,async n=>{let{executionId:r,frameId:i,artifactRef:a,revision:o}=n.payload;await q(`artifact.updated[${r}:${i}]`,async()=>{let n=await Nn(e,t,i,a,o);if(n===null)return;let s=Date.now();await Cn(t,{id:wn(r,i,a.kind,a.id,s),executionId:r,frameId:i,nodeId:n.nodeId,artifact:n.artifact,revision:o??null,writtenAt:s}),await J(e,r)})})]}async function Jn(e,t,n){let{executionId:r,frameId:i,stepId:a,source:o}=e;o===`user`&&e.action===`approve`||await q(`gate.resolved[${i}]`,async()=>{let s=K(r,a,i),c=await Tn(n,s),l=Date.now();await G(n,{id:s,executionId:r,nodeId:a,frameId:i,status:o!==`cancelled`&&e.action===`approve`?`resumed`:Kn[o],prompt:c?.prompt??null,openedAt:c?.openedAt??l,resolvedAt:l,resumeData:c?.resumeData??null}),await J(t,r)})}function Yn(e,t){let n=[...zn(e,t),...Gn(e,t),...qn(e,t),e.on(g.worklog.get,async e=>{let{executionId:n}=e.payload,r=await U(t,n);e.setResult({summary:r})}),e.on(g.worklog.frame.get,async e=>{let{frameId:n}=e.payload,r=await Sn(t,n);e.setResult({frame:r})}),e.on(g.worklog.list,async e=>{let{workflowId:n,status:r,limit:i,offset:a}=e.payload,o=await yn(t,{workflowId:n,status:r,limit:i,offset:a});e.setResult(o)}),e.on(g.worklog.stats,async e=>{let{workflowId:n,since:r,until:i}=e.payload,a=await Mn(t,{workflowId:n,since:r,until:i});e.setResult({stats:a})})];return()=>{for(let e of n)e()}}function Y(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>Y(e,t[n]));if(e===null||t===null||typeof e!=`object`||typeof t!=`object`)return!1;let n=e,r=t,i=Object.keys(n).sort(),a=Object.keys(r).sort();return i.length===a.length&&i.every((e,t)=>e===a[t]&&Y(n[e],r[e]))}function Xn(e){return{executionId:e.executionId,frameId:e.frameId,nodeId:e.nodeId,nodeType:e.nodeType,path:e.path,status:e.status,attempt:e.attempt,iteration:e.iteration??null,branchKey:e.branchKey??null,startedAt:e.startedAt??null,completedAt:e.completedAt??null,durationMs:e.durationMs??null,inputTokens:e.inputTokens??null,outputTokens:e.outputTokens??null,estimatedCost:e.estimatedCost??null,error:e.error??null}}function Zn(e,t){let n=e.frame;if(n!==void 0){let r=e.status===`failed`?e.error??null:null;if(n.executionId!==e.executionId)throw Error(`settleExternalExecution requires frame.executionId to match executionId`);if(n.status!==e.status)throw Error(`settleExternalExecution requires frame.status to match status`);if(n.completedAt!==t)throw Error(`settleExternalExecution requires frame.completedAt to match completedAt`);if(n.durationMs!==t-n.startedAt)throw Error(`settleExternalExecution requires frame.durationMs to match its timestamps`);if((n.error??null)!==r)throw Error(`settleExternalExecution requires frame.error to match terminal error metadata`)}return JSON.stringify({version:1,status:e.status,completedAt:t,error:e.status===`failed`?e.error??null:null,reason:e.status===`cancelled`?e.reason??null:null,frame:n===void 0?null:{executionId:n.executionId,frameId:n.frameId,nodeId:n.nodeId,nodeType:n.nodeType,path:n.path,status:n.status,attempt:n.attempt,iteration:n.iteration??null,branchKey:n.branchKey??null,startedAt:n.startedAt,completedAt:n.completedAt,durationMs:n.durationMs,error:n.status===`failed`?n.error??null:null}})}function Qn(e,t,n){if(e!==t)throw Error(`settleExternalExecution: execution "${n}" conflicts with an existing terminal settlement fingerprint`)}async function $n(e,t,n,r,i){let a=Zn(r,i);if(n.externalSettlementFingerprint!==null){Qn(n.externalSettlementFingerprint,a,r.executionId);return}if(r.frame!==void 0)throw Error(`settleExternalExecution: frame presence conflicts with the legacy frame-less settlement for execution "${r.executionId}"`);let o=r.status===`failed`?r.error??null:null,s=r.status===`cancelled`?r.reason??null:null;if((await e.update(t).set({externalSettlementFingerprint:a}).where(O(M(t.id,r.executionId),N(t.externalSettlementFingerprint),M(t.status,r.status),M(t.completedAt,i),o===null?N(t.error):M(t.error,o),s===null?N(t.reason):M(t.reason,s))).returning({fingerprint:t.externalSettlementFingerprint})).length>0)return;let[c]=await e.select().from(t).where(M(t.id,r.executionId)).limit(1);if(c===void 0)throw Error(`settleExternalExecution: execution "${r.executionId}" disappeared`);if(tr(c,r,i),c.externalSettlementFingerprint===null)throw Error(`settleExternalExecution: failed to adopt terminal settlement fingerprint for execution "${r.executionId}"`);Qn(c.externalSettlementFingerprint,a,r.executionId)}function er(e,t){if(e.executionId!==t.executionId||e.nodeId!==t.nodeId||e.nodeType!==t.nodeType||!Y(e.path,t.path)||e.attempt!==t.attempt||e.iteration!==(t.iteration??null)||e.branchKey!==(t.branchKey??null)||e.startedAt!==t.startedAt)throw Error(`settleExternalExecution: frame "${t.frameId}" conflicts with its registered metadata`)}function tr(e,t,n){let r=t.status===`failed`?t.error??null:null,i=t.status===`cancelled`?t.reason??null:null;if(e.status!==t.status||e.completedAt!==n||e.error!==r||e.reason!==i)throw e.status===t.status?Error(`settleExternalExecution: execution "${t.executionId}" conflicts with an existing terminal settlement`):Error(`settleExternalExecution: execution "${t.executionId}" cannot transition from status "${e.status}"`)}async function nr(e,t,n){let r=await e.select().from(t).where(M(t.executionId,n.executionId)),i=r.find(e=>e.frameId===n.frame.frameId);if(i!==void 0)return i;if(r.length>0)throw Error(`settleExternalExecution: frame "${n.frame.frameId}" conflicts with the registered frame identity`);let[a]=await e.select().from(t).where(M(t.frameId,n.frame.frameId)).limit(1);if(a!==void 0)throw Error(`settleExternalExecution: frame "${n.frame.frameId}" belongs to another execution`)}function rr(e,t,n,r){let i=Math.min(e.startedAt,r);return{executionId:e.id,workflowId:e.workflowId,workflowName:t?.workflowName??null,status:n.status,startedAt:i,completedAt:r,durationMs:r-i,totalInputTokens:t?.totalInputTokens??null,totalOutputTokens:t?.totalOutputTokens??null,totalEstimatedCost:t?.totalEstimatedCost??null,error:n.status===`failed`?n.error??null:null,failedNodeId:n.status===`failed`?n.frame?.nodeId??t?.failedNodeId??null:null}}function ir(e,t){return Xn({...e,inputTokens:e.inputTokens??t?.inputTokens??void 0,outputTokens:e.outputTokens??t?.outputTokens??void 0,estimatedCost:e.estimatedCost??t?.estimatedCost??void 0})}function ar(e,t){if(e.externalRegistrationFrameId!==(t.externalRegistrationFrameId??null))throw Error(`setExternalExecutionStart: frame metadata conflicts for execution "${t.id}"`);if(!(e.id===t.id&&e.workflowId===t.workflowId&&e.coordinatorSessionId===t.coordinatorSessionId&&e.startedAt===t.startedAt&&e.scopeType===t.scopeType&&e.scopeKind===t.scopeKind&&e.scopeId===t.scopeId&&e.artifactKind===t.artifactKind&&e.artifactId===t.artifactId&&Y(e.inputs,t.inputs)&&Y(e.triggerPayload,t.triggerPayload)))throw Error(`setExternalExecutionStart: registration conflicts for execution "${t.id}"`)}function or(e,t){if(e.workflowId!==t.workflowId||e.startedAt!==t.startedAt||e.executionId!==t.executionId)throw Error(`setExternalExecutionStart: WorkLog summary conflicts for execution "${t.executionId}"`)}function sr(e,t){if(e.executionId!==t.executionId||e.frameId!==t.frameId||e.nodeId!==t.nodeId||e.nodeType!==t.nodeType||!Y(e.path,t.path)||e.attempt!==t.attempt||e.iteration!==(t.iteration??null)||e.branchKey!==(t.branchKey??null)||e.startedAt!==t.startedAt)throw Error(`setExternalExecutionStart: WorkLog frame conflicts for frame "${t.frameId}"`)}async function cr(e,t,n,r){if(!t.id.startsWith(b))throw Error(`setExternalExecutionStart: execution "${t.id}" is not an external execution ID`);if(n!==void 0&&n.executionId!==t.id)throw Error(`setExternalExecutionStart requires frame.executionId to match execution.id`);let{workflowExecutions:i,worklogSummaries:a,worklogFrameEntries:o}=E(e,I),s={...r(t),externalRegistrationFrameId:n?.frameId??null},c={executionId:t.id,workflowId:t.workflowId,workflowName:null,status:`running`,startedAt:t.startedAt,completedAt:null,durationMs:null,totalInputTokens:null,totalOutputTokens:null,totalEstimatedCost:null,error:null,failedNodeId:null};await T(e,async e=>{let r=(await e.insert(i).values(s).onConflictDoNothing().returning({id:i.id})).length===0;if(r){let[n]=await e.select().from(i).where(M(i.id,t.id)).limit(1);if(n===void 0)throw Error(`setExternalExecutionStart: execution "${t.id}" disappeared`);ar(n,s)}let[l]=await e.select().from(a).where(M(a.executionId,t.id)).limit(1);if(l===void 0?await e.insert(a).values(c):or(l,c),n!==void 0){let[i]=await e.select().from(o).where(M(o.frameId,n.frameId)).limit(1);if(i===void 0){if(r)throw Error(`setExternalExecutionStart: frame metadata conflicts for execution "${t.id}"`);await e.insert(o).values(Xn(n))}else sr(i,n)}})}async function lr(e,t,n,r,i){if(r.frame!==void 0){let n=await nr(e,t,r);return n!==void 0&&er(n,r.frame),{frame:r.frame,existing:n}}if(n.externalRegistrationFrameId===null)return;let[a]=await e.select().from(t).where(M(t.frameId,n.externalRegistrationFrameId)).limit(1);if(a===void 0||a.executionId!==n.id)throw Error(`settleExternalExecution: registered frame "${n.externalRegistrationFrameId}" is unavailable for execution "${n.id}"`);if(a.startedAt===null)throw Error(`settleExternalExecution: registered frame "${a.frameId}" has no start timestamp`);if(i<a.startedAt)throw Error(`settleExternalExecution: completedAt must not precede the registered frame start timestamp`);let o=dt.parse(a.nodeType);return{frame:{executionId:a.executionId,frameId:a.frameId,nodeId:a.nodeId,nodeType:o,path:a.path,status:r.status,attempt:a.attempt,...a.iteration===null?{}:{iteration:a.iteration},...a.branchKey===null?{}:{branchKey:a.branchKey},startedAt:a.startedAt,completedAt:i,durationMs:i-a.startedAt,...r.status===`failed`&&r.error!==void 0?{error:r.error}:{}},existing:a}}async function ur(e,t,n,r,i){let{worklogSummaries:a,worklogFrameEntries:o}=t,s=await En(e,a,n.id),c=await lr(e,o,n,r,i),l=c===void 0?r:{...r,frame:c.frame};if(c!==void 0){let t=ir(c.frame,c.existing);await e.insert(o).values(t).onConflictDoUpdate({target:o.frameId,set:t})}let u=await Dn(e,o,n.id),d=On(u),f={totalInputTokens:u.totalInputTokens,totalOutputTokens:u.totalOutputTokens,totalEstimatedCost:u.totalEstimatedCost},p={...rr(n,s,l,i),...d?f:{}};await e.insert(a).values(p).onConflictDoUpdate({target:a.executionId,set:vn(p)}),d&&await kn(e,a,n.id,u)}async function dr(e,t){if(!t.executionId.startsWith(b))throw Error(`settleExternalExecution: execution "${t.executionId}" is engine-owned and must use the engine finalizer`);if(t.frame!==void 0&&t.frame.executionId!==t.executionId)throw Error(`settleExternalExecution requires frame.executionId to match executionId`);let{workflowExecutions:n,worklogSummaries:r,worklogFrameEntries:i}=E(e,I);return T(e,async e=>{let[a]=await e.select().from(n).where(M(n.id,t.executionId)).limit(1);if(a===void 0)throw Error(`settleExternalExecution: execution "${t.executionId}" was not registered`);let o=t.completedAt??a.completedAt??Date.now();if(a.status===`running`){let r=Zn(t,o);if((await e.update(n).set({status:t.status,completedAt:o,error:t.status===`failed`?t.error??null:null,reason:t.status===`cancelled`?t.reason??null:null,externalSettlementFingerprint:r}).where(O(M(n.id,t.executionId),M(n.status,`running`),N(n.externalSettlementFingerprint))).returning({id:n.id})).length===0){let[r]=await e.select().from(n).where(M(n.id,t.executionId)).limit(1);if(r===void 0)throw Error(`settleExternalExecution: execution "${t.executionId}" disappeared`);t.completedAt===void 0&&r.completedAt!==null&&(o=r.completedAt),tr(r,t,o),await $n(e,n,r,t,o)}}else tr(a,t,o),await $n(e,n,a,t,o);return await ur(e,{worklogSummaries:r,worklogFrameEntries:i},a,t,o),!0})}function fr(e,t,n){let r=e.on(h.setExternalExecutionStart,async r=>{let i=r.payload.execution,a=r.payload.frame;await cr(t,i,a,n),await J(e,i.id),r.setResult({executionId:i.id,...a===void 0?{}:{frameId:a.frameId}})}),i=e.on(h.settleExternalExecution,async n=>{let r=await dr(t,n.payload);await J(e,n.payload.executionId),n.setResult({success:r})});return()=>{r(),i()}}function X(e){return{executionId:e.executionId,workflowId:e.workflowId,finalizerId:e.finalizerId,transitionKey:e.transitionKey,claimToken:e.claimToken,intent:e.intent,claimedAt:e.claimedAt}}function pr(e,t){return e.state===`claimed`&&e.executionId===t.executionId&&e.workflowId===t.workflowId&&e.finalizerId===t.finalizerId&&e.transitionKey===t.transitionKey&&e.claimToken===t.claimToken&&e.intent.status===t.intent.status&&e.intent.completedAt===t.intent.completedAt&&e.intent.error===t.intent.error&&e.intent.reason===t.intent.reason}function mr(e,t){if(e.executionId!==t.executionId||e.workflowId!==t.workflowId||e.finalizerId!==t.finalizerId||e.transitionKey!==t.transitionKey||e.claimToken!==t.claimToken)throw Error(`workflow finalization publication claim does not match durable transition ${t.executionId}`)}async function hr(e,t){let{workflowExecutions:n,workflowFinalizations:r}=E(e,I);return T(e,async e=>{let i=await e.select().from(r).where(M(r.executionId,t.executionId)).limit(1);return i[0]?pr(i[0],t):(await e.update(n).set({status:`finalizing`}).where(O(M(n.id,t.executionId),M(n.workflowId,t.workflowId),M(n.status,`running`))).returning({id:n.id})).length===0?!1:(await e.insert(r).values({...t,state:`claimed`}),!0)})}function gr(e){return{status:e.status,completedAt:e.completedAt,error:e.status===`failed`?e.error??`Workflow finalization failed`:null,reason:e.status===`cancelled`?e.reason??null:null}}async function _r(e,t,n,r){let{workflowExecutions:i,workflowFinalizations:a}=E(e,I);return T(e,async e=>{let o=(await e.select().from(a).where(M(a.executionId,t)).limit(1))[0];return!o||o.claimToken!==n||o.state===`failed`?!1:o.state===`acknowledged`?!0:(await e.update(i).set(gr(o.intent)).where(O(M(i.id,t),M(i.status,`finalizing`))).returning({id:i.id})).length===0?!1:(await e.update(a).set({state:`acknowledged`,settledAt:r}).where(O(M(a.executionId,t),M(a.claimToken,n),M(a.state,`claimed`))),!0)})}async function vr(e,t,n,r,i){let{workflowExecutions:a,workflowFinalizations:o}=E(e,I);return T(e,async e=>{let s=(await e.select().from(o).where(M(o.executionId,t)).limit(1))[0];return!s||s.claimToken!==n||s.state===`acknowledged`?!1:s.state===`failed`?!0:(await e.update(a).set({status:`failed`,error:r,reason:null,completedAt:i}).where(O(M(a.id,t),M(a.status,`finalizing`))).returning({id:a.id})).length===0?!1:(await e.update(o).set({state:`failed`,failure:r,settledAt:i}).where(O(M(o.executionId,t),M(o.claimToken,n),M(o.state,`claimed`))),!0)})}async function yr(e,t,n){let{workflowExecutions:r,workflowFinalizations:i}=E(t,I),a=(await t.select().from(i).where(M(i.executionId,n.executionId)).limit(1))[0];if(!a||(mr(a,n),a.state===`claimed`||a.publishedAt!==null))return;let o=(await t.select({startedAt:r.startedAt,status:r.status,error:r.error,reason:r.reason,completedAt:r.completedAt}).from(r).where(M(r.id,a.executionId)).limit(1))[0];if(!(!o||o.completedAt==null)){if(o.status===`completed`)await e.emit(g.execution.completed,{executionId:a.executionId,workflowId:a.workflowId,totalDuration:o.completedAt-o.startedAt,completedAt:o.completedAt,transitionKey:a.transitionKey});else if(o.status===`failed`)await e.emit(g.execution.failed,{executionId:a.executionId,workflowId:a.workflowId,error:o.error??`Workflow finalization failed`,completedAt:o.completedAt,transitionKey:a.transitionKey});else if(o.status===`cancelled`)await e.emit(g.execution.cancelled,{executionId:a.executionId,workflowId:a.workflowId,reason:o.reason??void 0,completedAt:o.completedAt,transitionKey:a.transitionKey});else return;await D(t,()=>t.update(i).set({publishedAt:Date.now()}).where(O(M(i.executionId,a.executionId),N(i.publishedAt))))}}function br(e,t){let n=new Map;return async r=>{let i=(n.get(r.executionId)??Promise.resolve()).catch(()=>void 0).then(()=>yr(e,t,r));n.set(r.executionId,i);try{await i}finally{n.get(r.executionId)===i&&n.delete(r.executionId)}}}function xr(e,t){let n=br(e,t),r=e.on(h.claimFinalization,async e=>{e.setResult({claimed:await hr(t,e.payload.claim)})}),i=e.on(h.listClaimedFinalizations,async e=>{let{workflowFinalizations:n}=E(t,I),r=await t.select().from(n).where(O(M(n.finalizerId,e.payload.finalizerId),M(n.state,`claimed`)));e.setResult({claims:r.map(X)})}),a=e.on(h.listUnpublishedFinalizations,async e=>{let{workflowFinalizations:n}=E(t,I),r=await t.select().from(n).where(O(kt(M(n.state,`acknowledged`),M(n.state,`failed`)),M(n.finalizerId,e.payload.finalizerId),N(n.publishedAt)));e.setResult({claims:r.map(X)})}),o=e.on(h.publishFinalization,async e=>{await n(e.payload.claim),e.setResult({})}),s=e.on(h.acknowledgeFinalization,async e=>{let{executionId:r,claimToken:i,settledAt:a}=e.payload,o=await _r(t,r,i,a);if(e.setResult({acknowledged:o}),!o)return;let{workflowFinalizations:s}=E(t,I),c=await t.select().from(s).where(M(s.executionId,r)).limit(1);c[0]&&await n(X(c[0]))}),c=e.on(h.failFinalization,async e=>{let{executionId:r,claimToken:i,error:a,settledAt:o}=e.payload,s=await vr(t,r,i,a,o);if(e.setResult({failed:s}),!s)return;let{workflowFinalizations:c}=E(t,I),l=await t.select().from(c).where(M(c.executionId,r)).limit(1);l[0]&&await n(X(l[0]))});return()=>{r(),i(),a(),o(),s(),c()}}function Sr(e){return{id:e.id,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId??void 0,status:e.status,inputs:e.inputs,config:{},error:e.error??void 0,reason:e.reason??void 0,startedAt:e.startedAt,completedAt:e.completedAt??void 0,triggerPayload:e.triggerPayload??void 0,...e.artifactKind!==null&&e.artifactId!==null?{artifactRef:{kind:e.artifactKind,id:e.artifactId}}:{},scope:R(e)}}function Z(e){let t=L(e.scope);return{id:e.id,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId??null,status:e.status,inputs:e.inputs,error:e.error??null,reason:e.reason??null,startedAt:e.startedAt,completedAt:e.completedAt??null,triggerPayload:e.triggerPayload??null,artifactKind:e.artifactRef?.kind??null,artifactId:e.artifactRef?.id??null,...t}}function Cr(e,t,n,r,i,a){let o=[...e?[M(a.workflowId,e)]:[],...n?[M(a.status,n)]:[],...i===void 0?[]:[M(a.artifactKind,i.kind),M(a.artifactId,i.id)]];if(t&&o.push(...Kt(a,t)),r){let e=kt(Et(a.startedAt,r.startedAt),O(M(a.startedAt,r.startedAt),Et(a.id,r.id)));e&&o.push(e)}return o}async function wr(e,t,n,r,i){if(n.executionId!==t.id)throw Error(`setExecutionStart requires execution.id to match runContext.executionId`);for(let e of i??[])if(e.targetExecutionId!==t.id)throw Error(`setExecutionStart requires executionLinks.targetExecutionId to match execution.id`);let{workflowExecutions:a,workflowRunContexts:o,workflowExecutionState:s,workflowExecutionStateEvents:c,workflowExecutionLinks:l}=E(e,I),u=Z(t);await T(e,async d=>{await d.insert(a).values(u).onConflictDoUpdate({target:a.id,set:u});let f=(n.dispatchMetadata===void 0?await d.select({dispatchMetadata:o.dispatchMetadata}).from(o).where(M(o.executionId,n.executionId)).limit(1):[])[0]?.dispatchMetadata;if(await ln(d,n.dispatchMetadata===void 0&&f!=null?{...n,dispatchMetadata:f}:n,o),r!==void 0){let n=Date.now(),i=H(e,r);await d.insert(s).values({executionId:t.id,sequence:0,value:i,updatedAt:n}).onConflictDoNothing(),await d.insert(c).values({executionId:t.id,sequence:0,patch:[],value:i,createdAt:n}).onConflictDoNothing()}for(let e of i??[])await d.insert(l).values(e).onConflictDoUpdate({target:[l.sourceExecutionId,l.targetExecutionId],set:e})})}async function Tr(e,t,n){if(n.executionId!==t.id)throw Error(`restorePausedGateResumeState requires execution.id to match gate.executionId`);if(t.status!==`paused`||n.status!==`waiting`)throw Error(`restorePausedGateResumeState requires a paused execution and waiting gate`);let{workflowExecutions:r,workflowGateInstances:i}=E(e,I),a=Z(t),o=V(n);await T(e,async e=>{await e.insert(r).values(a).onConflictDoUpdate({target:r.id,set:a}),await e.insert(i).values(o).onConflictDoUpdate({target:i.id,set:o})})}async function Er(e,t,n,r){let{workflowExecutions:i,workflowGateInstances:a}=E(e,I);return T(e,async e=>{if((await e.select().from(i).where(M(i.id,t)).limit(1))[0]?.status!==`paused`)return{cancelled:!1,gates:[]};let o=(await e.select().from(a).where(O(M(a.executionId,t),M(a.status,`waiting`)))).map(e=>({...B(e),status:`cancelled`,resolvedAt:n}));await e.update(i).set({status:`cancelled`,completedAt:n,reason:r??null}).where(M(i.id,t));for(let t of o){let n=V(t);await e.update(a).set(n).where(M(a.id,n.id))}return{cancelled:!0,gates:o}})}async function Dr(e,t,n,r,i,a){let{workflowExecutions:o}=E(e,I);return T(e,async e=>{if((await e.select({id:o.id}).from(o).where(M(o.id,t)).limit(1))[0]===void 0)return!1;let s={};return n!==void 0&&(s.status=n),r!==void 0&&(s.error=r),i!==void 0&&(s.reason=i),a!==void 0&&(s.completedAt=a),Object.keys(s).length>0&&await e.update(o).set(s).where(M(o.id,t)),!0})}function Or(e,t){let{workflowExecutions:n}=E(t,I),r=e.on(h.getExecution,async e=>{let{executionId:r}=e.payload;if(!m(e,r))throw Error(`Unauthorized execution read: ${r}`);let i=await t.select().from(n).where(M(n.id,r));e.setResult({execution:i[0]?Sr(i[0]):null})}),i=e.on(h.setExecution,async e=>{let r=e.payload.execution,i=Z(r);await D(t,()=>t.insert(n).values(i).onConflictDoUpdate({target:n.id,set:i})),e.setResult({id:r.id})}),a=e.on(h.setExecutionStart,async e=>{let n=e.payload.execution,r=e.payload.runContext;await wr(t,n,r,e.payload.initialState,e.payload.executionLinks),e.setResult({id:n.id,executionId:n.id})}),o=e.on(h.restorePausedGateResumeState,async e=>{let n=e.payload.execution,r=e.payload.gate;await Tr(t,n,r),e.setResult({executionId:n.id,gateId:r.nodeId})}),s=e.on(h.updateExecution,async e=>{let{executionId:n,status:r,error:i,reason:a,completedAt:o}=e.payload,s=await Dr(t,n,r,i,a,o);e.setResult({success:s})}),c=e.on(h.pauseRunningExecution,async e=>{let{workflowExecutions:n}=E(t,I),r=await D(t,()=>t.update(n).set({status:`paused`}).where(O(M(n.id,e.payload.executionId),M(n.status,`running`))).returning({id:n.id}));e.setResult({paused:r.length===1})}),l=e.on(h.cancelPausedExecution,async e=>{let{executionId:n,completedAt:r,reason:i}=e.payload;e.setResult(await Er(t,n,r,i))});return()=>{r(),i(),a(),o(),s(),c(),l()}}function kr(e,t){let{workflowExecutions:n}=E(t,I),r=e.on(h.listExecutions,async e=>{let{workflowId:r,scope:i,status:a,limit:o,cursor:s,artifactRef:c}=e.payload;if(r===void 0&&i===void 0&&c===void 0)throw Error(`Either workflowId, scope, or artifactRef is required to list executions.`);let l=Cr(r,i,a,s,c,n),u=o??Qe;if(!Number.isInteger(u)||u<y||u>v)throw Error(`Execution list limit must be an integer between ${y} and ${v}.`);let d=await t.select().from(n).where(O(...l)).orderBy(j(n.startedAt),j(n.id)).limit(u);e.setResult({executions:d.map(Sr)})}),i=e.on(h.listExecutionsByArtifactRefs,async e=>{let r=$e.safeParse(e.payload);if(!r.success)throw Error(`Invalid listExecutionsByArtifactRefs query: ${r.error.message}`);let{refs:i,limitPerRef:a}=r.data,o={};for(let e of i){let r=await t.select().from(n).where(O(M(n.artifactKind,e.kind),M(n.artifactId,e.id))).orderBy(j(n.startedAt),j(n.id)).limit(a);r.length>0&&(o[_t(e)]=r.map(Sr))}e.setResult({executionsByRef:o})});return()=>{r(),i()}}function Ar(e,t){let n=Jt(e,t),r=Or(e,t),i=kr(e,t),a=Zt(e,t),o=en(e,t),s=rn(e,t),c=un(e,t),l=mn(e,t),u=Yn(e,t),d=fr(e,t,Z),f=xr(e,t);return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u(),d(),f()}}function jr(e){return e.startsWith(b)}function Mr(e){let t={};return e.artifactRef!==void 0&&(t.artifactRef=e.artifactRef),e.triggerPayload!==void 0&&(t.triggerPayload=e.triggerPayload),t}function Nr(e){if(e.status===`failed`){if(e.error===void 0)throw Error(`status 'failed' requires a non-empty 'error' message`);return{error:e.error}}if(e.status===`cancelled`){if(e.reason===void 0)throw Error(`status 'cancelled' requires a non-empty 'reason' string`);return{reason:e.reason}}return{}}async function Pr(e,t){let{runContext:n}=await e.request(h.getRunContext,{executionId:t});if(n===null)throw Error(`Run context not found for execution: ${t}`);if(n.definitionSnapshot!==void 0)return n.definitionSnapshot;let{workflow:r}=await e.request(h.get,{id:n.workflowId});return r??void 0}function Fr(e){return[e.on(g.getDefinition,async t=>{let n=await e.request(h.get,{id:t.payload.id});t.setResult(n)}),e.on(g.setDefinition,async t=>{let n=await e.request(h.set,{workflow:t.payload.workflow});t.setResult(n)}),e.on(g.deleteDefinition,async t=>{let n=await e.request(h.delete,{id:t.payload.id});t.setResult(n)}),e.on(g.listDefinitions,async t=>{let n=await e.request(h.list,t.payload);t.setResult(n)}),e.on(g.getExecution,async t=>{let n=await e.request(h.getExecution,{executionId:t.payload.executionId});t.setResult(n)}),e.on(g.listExecutions,async t=>{let n=await e.request(h.listExecutions,t.payload);t.setResult(n)}),e.on(g.listExecutionsByArtifactRefs,async t=>{let n=await e.request(h.listExecutionsByArtifactRefs,t.payload);t.setResult(n)}),e.on(g.listSpans,async t=>{let n=await e.request(h.listSpans,{executionId:t.payload.executionId});t.setResult(n)}),e.on(g.listFrames,async t=>{let n=await e.request(h.listFrames,{executionId:t.payload.executionId});t.setResult(n)}),e.on(g.listGateInstances,async t=>{let n=await e.request(h.listGateInstances,t.payload);t.setResult(n)}),e.on(g.setExecutionLink,async t=>{let n=await e.request(h.setExecutionLink,{link:t.payload.link});t.setResult(n)}),e.on(g.listExecutionLinks,async t=>{let n=await e.request(h.listExecutionLinks,t.payload);t.setResult(n)}),e.on(g.getRunContext,async t=>{let{executionId:n}=t.payload;if(!m(t,n))throw Error(`Unauthorized: caller is not permitted to read run context for execution: ${n}`);let{runContext:r}=await e.request(h.getRunContext,{executionId:n});if(!r)throw Error(`Run context not found for execution: ${n}`);t.setResult(r)}),...Ir(e)]}function Ir(e){return[e.on(g.registerExternalExecution,async t=>{let n=Ve.registerExternalExecution.request.parse(t.payload),{name:r,scope:i,input:a}=n;if(n.executionId!==void 0&&!t.origin.local)throw Error(`registerExternalExecution: caller-supplied executionId is restricted to local callers`);let o=n.executionId??s(`wfx-ext`);if(!jr(o))throw Error(`registerExternalExecution: executionId must use the wfx-ext- prefix`);let c=n.startedAt??Date.now(),l={id:o,workflowId:r,status:`running`,inputs:a===void 0?{}:a,startedAt:c,scope:i??{type:`global`},...Mr(n)},u=Lr(o,c,n.frame),d=await e.request(h.setExternalExecutionStart,{execution:l,...u===void 0?{}:{frame:u}});t.setResult(d)}),e.on(g.completeExternalExecution,async t=>{let n=Ve.completeExternalExecution.request.parse(t.payload),{executionId:r,status:i}=n;if(!m(t,r))throw Error(`Unauthorized: caller is not permitted to settle execution: ${r}`);if(!jr(r))throw Error(`completeExternalExecution: execution "${r}" is engine-owned and must be completed through the engine finalizer, not this API`);let a=Rr(n),o=await e.request(h.settleExternalExecution,{executionId:r,status:i,...Nr(n),...n.completedAt===void 0?{}:{completedAt:n.completedAt},...a===void 0?{}:{frame:a}});t.setResult({success:o.success})})]}function Lr(e,t,n){if(n===void 0)return;let r=n.frameId??`${e}:${n.nodeId}`;return{executionId:e,frameId:r,nodeId:n.nodeId,nodeType:n.nodeType,path:n.path??[r],status:`running`,attempt:n.attempt,...n.iteration===void 0?{}:{iteration:n.iteration},...n.branchKey===void 0?{}:{branchKey:n.branchKey},startedAt:n.startedAt??t}}function Rr(e){if(e.frame===void 0)return;if(e.completedAt===void 0)throw Error(`completedAt is required when frame metadata is supplied`);let t=e.completedAt-e.frame.startedAt;if(t<0)throw Error(`completedAt must not precede frame.startedAt`);if(e.frame.durationMs!==void 0&&e.frame.durationMs!==t)throw Error(`frame.durationMs must equal completedAt - frame.startedAt`);return{executionId:e.executionId,frameId:e.frame.frameId,nodeId:e.frame.nodeId,nodeType:e.frame.nodeType,path:e.frame.path,status:e.status,attempt:e.frame.attempt,...e.frame.iteration===void 0?{}:{iteration:e.frame.iteration},...e.frame.branchKey===void 0?{}:{branchKey:e.frame.branchKey},startedAt:e.frame.startedAt,completedAt:e.completedAt,durationMs:t,...e.status===`failed`&&e.error!==void 0?{error:e.error}:{}}}function zr(e){return[e.on(g.state.get,async t=>{let{executionId:n}=t.payload;if(!m(t,n))throw Error(`Unauthorized: caller is not permitted to read state for execution: ${n}`);let{state:r}=await e.request(h.getState,{executionId:n});if(r===null)throw Error(`no workflow state for execution ${n}`);t.setResult(r)}),e.on(g.state.patch,async t=>{let{executionId:n,expectedSequence:r,patch:i,nextValue:a}=t.payload;if(!m(t,n))throw Error(`Unauthorized: caller is not permitted to patch state for execution: ${n}`);if(r===void 0)throw Error(`expectedSequence is required to patch workflow state`);let o=await Pr(e,n);o!==void 0&&te(o,a,`next`),et.array().parse(i);let s=await e.request(h.patchState,{executionId:n,expectedSequence:r,nextValue:a});e.emit(g.state.updated,{executionId:s.executionId,sequence:s.sequence,patch:s.patch,value:s.value,updatedAt:Date.now()}).catch(()=>{}),t.setResult({executionId:s.executionId,sequence:s.sequence,value:s.value})})]}async function Br(e,t){let{runContext:n}=await e.bus.request(h.getRunContext,{executionId:t});if(n===null)throw new C(st.RUN_CONTEXT_NOT_FOUND,`Run context not found for workflow execution '${t}'.`);return n}function Vr(e,t){return t===void 0?{mode:e}:{mode:e,reason:t}}async function Hr(e,t){let n=await Br(e,t.executionId),r=t.input===void 0?n.inputs:t.input,i=t.config??n.config??{},a=t.triggerPayload??n.triggerPayload,o=t.artifactRef??n.artifactRef,s=t.scopeOverride??n.scope,c={input:r,config:i,parentSessionId:t.parentSessionId,triggerPayload:a,artifactRef:o,scopeOverride:s,executionLinks:e=>[{sourceExecutionId:t.executionId,targetExecutionId:e,linkType:`rerun-of`,metadata:Vr(t.mode,t.reason)}]};return t.mode===`snapshot`?await Kr(e,n,c):Wr(n)?await qr(e,n,c):await pe(e,n.workflowId,c)}function Ur(e,t){return Wr(e)?t.id:e.workflowId}function Wr(e){return e.source.kind!==`definition`&&e.workflowId===e.executionId}function Gr(e){let t=e.definitionSnapshot;if(t===void 0)throw new C(st.SNAPSHOT_UNAVAILABLE,`Workflow execution '${e.executionId}' does not have a definition snapshot.`);return t}async function Kr(e,t,n){let r=Gr(t);return we(e,Ur(t,r),{workflow:r,executionSource:t.source,definitionSnapshot:r,input:n.input,config:n.config,parentSessionId:n.parentSessionId,triggerPayload:n.triggerPayload,artifactRef:n.artifactRef,scopeOverride:n.scopeOverride,executionLinks:n.executionLinks,...t.materializationSpec===void 0?{}:{materializationSpec:t.materializationSpec}})}async function qr(e,t,n){if(t.definitionSnapshot===void 0&&t.source.kind===`path`){let{materializationSpec:r}=t;if(r===void 0)throw Error(`Invalid persisted path-backed run context: materializationSpec is required`);return Ae(e,t.source.path,{...n,materializationSpec:r})}let r=Gr(t);return we(e,r.id,{workflow:r,executionSource:t.source,input:n.input,config:n.config,parentSessionId:n.parentSessionId,triggerPayload:n.triggerPayload,artifactRef:n.artifactRef,scopeOverride:n.scopeOverride,executionLinks:n.executionLinks,...t.materializationSpec===void 0?{}:{materializationSpec:t.materializationSpec}})}var Jr=class{bus;resumePausedExecution;handles=new Map;constructor(e,t){this.bus=e,this.resumePausedExecution=t}dispose(){for(let e of this.handles.values())clearTimeout(e);this.handles.clear()}clear(e,t,n){let r=this.makeKey(e,t,n),i=this.handles.get(r);i!==void 0&&(clearTimeout(i),this.handles.delete(r))}schedule(e){e.timeoutMs!==null&&(this.clear(e.executionId,e.nodeId,e.frameId),this.scheduleNextWakeup({...e,timeoutMs:e.timeoutMs}))}scheduleNextWakeup(e){let t=this.makeKey(e.executionId,e.nodeId,e.frameId),n=Math.max(0,e.openedAt+e.timeoutMs-Date.now()),r=setTimeout(()=>{if(this.handles.delete(t),Date.now()<e.openedAt+e.timeoutMs){this.scheduleNextWakeup(e);return}this.handleExpiredWakeup(e)},Math.min(n,2147483647));this.handles.set(t,r)}scheduleNextWakeupAfterDelay(e,t){let n=this.makeKey(e.executionId,e.nodeId,e.frameId),r=setTimeout(()=>{this.handles.delete(n),this.handleExpiredWakeup(e)},t);this.handles.set(n,r)}async handleExpiredWakeup(e){try{await this.resumeTimedOutPausedGate(e)===`retry`&&this.scheduleNextWakeupAfterDelay(e,25)}catch(t){this.scheduleFailedWakeupRetry(e,t)}}scheduleFailedWakeupRetry(e,t){let n=(e.failedWakeupAttempts??0)+1;if(n>4){console.error(`[WorkflowExecutor] Giving up on timed-out gate '${e.nodeId}' after 4 failed wakeup retries:`,t);return}let r=Math.min(250*2**(n-1),2e3);console.error(`[WorkflowExecutor] Failed to resume timed-out gate '${e.nodeId}', retrying in ${r} ms:`,t),this.scheduleNextWakeupAfterDelay({...e,failedWakeupAttempts:n},r)}makeKey(e,t,n){return`${e}:${t}:${n}`}async resumeTimedOutPausedGate(e){this.clear(e.executionId,e.nodeId,e.frameId);let{gate:t}=await this.bus.request(h.getGateInstance,{executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId});if(t===null||t.status!==`waiting`)return`settled`;let{execution:n}=await this.bus.request(h.getExecution,{executionId:e.executionId});return n?.status===`running`?`retry`:n?.status===`paused`?(await this.resumePausedExecution(e.executionId),`resumed`):`settled`}};function Yr(e){if(e!==void 0)return Xr(e)?e:{}}function Xr(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Zr(e){if(e!==void 0)return tt.parse(e)}function Qr(e,t){return lt.parse({executionId:e.executionId,workflowId:e.workflowId,source:e.source,...e.definitionSnapshot===void 0?{}:{definitionSnapshot:e.definitionSnapshot},workerManifest:{contributionRefs:[]},inputs:e.inputs,config:e.config,scope:e.scope,triggerPayload:e.triggerPayload,triggerMode:e.triggerMode??`immediate`,...e.artifactRef===void 0?{}:{artifactRef:e.artifactRef},coordinatorSessionId:e.coordinatorSessionId,cancelSubject:`workflow.${e.executionId}.cancel`,env:t.platformDefaults.env??{},createdAt:Date.now(),suspensionStrategy:e.suspensionStrategy??`wait-in-process`,...e.terminalAuthority===void 0?{}:{terminalAuthority:e.terminalAuthority},...e.materializationSpec===void 0?{}:{materializationSpec:e.materializationSpec}})}function $r(e){return e?.status===`paused`}function ei(e){return e?.status===`waiting`}async function ti(e,t,n,r,a,o,s){try{await i(e,a.id,async()=>{let i=await e.bus.request(h.getExecution,{executionId:a.id});i.execution?.status!==`paused`&&i.execution?.status!==`running`||(t.delete(a.id),n.delete(a.id),r.delete(a.id),await e.bus.request(h.restorePausedGateResumeState,{execution:a,gate:o}))})}catch(e){console.error(`[WorkflowExecutor] Failed to restore paused gate '${s}' after resume launch failure:`,e)}}async function ni(e,t){if(t.suspensionStrategy===`wait-in-process`)return;let{frames:n}=await e.request(h.listFrames,{executionId:t.executionId});if(n.length===0)throw Error(`[WorkflowExecutor] Missing resume frames for paused execution: ${t.executionId}`)}function ri(e){return{executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,timeoutMs:e.timeoutMs,openedAt:e.createdAt}}async function ii(e,t){if(t.frameId!==void 0){let{gate:n}=await e.request(h.getGateInstance,t);return ei(n)?n:null}let{gates:n}=await e.request(h.listGateInstances,{executionId:t.executionId}),r=n.filter(e=>e.nodeId===t.nodeId&&e.status===`waiting`);return r.length===1?r[0]:null}async function ai(e,t){let n=e.authority.canonicalizeOutcome(t.outcome),r=t.runtimeFence===void 0?void 0:{...t.runtimeFence};await e.validation?.validate(t.executionId,n.outcome);let i=await e.authority.commitOutcome(t.executionAttemptId,t.executionId,n,r);return(i.kind===`accepted`||i.kind===`duplicate`)&&(await e.convergence.converge({executionId:t.executionId,executionAttemptId:t.executionAttemptId,outcome:i.outcome,decision:i.kind}),e.authority.settleOutcome(t.executionAttemptId,{kind:i.kind,outcome:e.authority.decodeOutcome(i.text),text:i.text})),i.kind}function oi(e,t){let n=o(e);if(n===null)throw Error(`Attempt requests require an authenticated workflow-execution-attempt peer`);if(n.executionAttemptId!==t)throw Error(`Request executionAttemptId does not match authenticated peer identity`);return n}function si(e,t){if(e===null||e.runtimeGeneration!==t.runtimeGeneration)return!1;if(t.outcome.kind===`cancelled`&&t.operationId===void 0)return e.activeOperationId===null;let n=t.outcome.kind===`technical-failure`?t.outcome.stage:t.outcome.kind===`cancelled`?e.activeOperationKind:`workload-invocation`;return n===`startup`?t.operationId===void 0&&e.activeOperationId===null:!(e.activeOperationId!==t.operationId||e.activeOperationGeneration!==t.runtimeGeneration||e.activeOperationKind!==n||n!==`workspace-preparation`&&n!==`workload-invocation`)}function ci(e,t){return e.on(S.instruction.get,async e=>{let n=x[`instruction.get`].request.parse(e.payload),r=oi(e,n.executionAttemptId),i=await t.getInstruction(r);if(i===null){e.setResult({decision:`refused`,refusalReason:`not-found`});return}if((await t.getAttemptControlState(r.executionAttemptId))?.runtimeGeneration!==n.runtimeGeneration){e.setResult({decision:`refused`,refusalReason:`stale-generation`});return}e.setResult({decision:`found`,instruction:i})})}function li(e,t){let n=[ci(e,t.authority),e.on(S.operation.report,async e=>{let n=x[`operation.report`].request.parse(e.payload),r=oi(e,n.executionAttemptId),i=await t.authority.reportOperation({...n,executionId:r.executionId});i.kind===`accepted`||i.kind===`duplicate`?e.setResult({decision:i.kind,binding:i.binding}):e.setResult({decision:`refused`,refusalReason:i.kind})}),e.on(S.outcome.submit,async e=>{let n=x[`outcome.submit`].request.parse(e.payload),r=oi(e,n.executionAttemptId),i=await t.authority.getInstruction(r);if(i===null)throw Error(`No instruction belongs to this authenticated Attempt`);if(!si(await t.authority.getAttemptControlState(r.executionAttemptId),n)){e.setResult({decision:`fenced`});return}let a={runtimeGeneration:n.runtimeGeneration,operationId:n.operationId??null},o=await t.decodeOutcome({instruction:i,outcome:n.outcome});try{let n=await ai(t,{...r,outcome:o,runtimeFence:a});e.setResult({decision:n})}catch(t){if(!(t instanceof Ue))throw t;e.setResult({decision:`fenced`})}})];return()=>{for(let e of n)e()}}function ui(e,t){return e.origin.local?{executionAttemptId:t.executionAttemptId,executionId:t.executionId}:o(e)}async function di(e,t,n){if(n.pausedAtGateId===void 0||n.pausedAtFrameId===void 0)throw Error(`Paused outcome for '${t}' is missing gate identity`);let{paused:r}=await e.request(h.pauseRunningExecution,{executionId:t});if(!r){let{execution:n}=await e.request(h.getExecution,{executionId:t});if(n?.status!==`paused`)throw Error(`Failed to park execution '${t}': status is '${n?.status??`missing`}'`);return}await e.emit(g.execution.paused,{executionId:t,workflowId:n.workflowId,pausedAtGateId:n.pausedAtGateId,pausedAtFrameId:n.pausedAtFrameId})}var fi=class{bus;acceptTerminalResult;acceptTechnicalFailure;acceptCancellation;constructor(e,t,n,r){this.bus=e,this.acceptTerminalResult=t,this.acceptTechnicalFailure=n,this.acceptCancellation=r}async converge(e){if(`kind`in e.outcome){if(e.outcome.kind===`cancelled`){let t=await this.acceptCancellation(e.executionId,e.outcome);if(!t.accepted||t.status!==`cancelled`)throw Error(`Cancellation did not converge workflow execution '${e.executionId}'`);return}let t=await this.acceptTechnicalFailure(e.executionId,e.outcome);if(!t.accepted||t.status!==`failed`&&t.status!==`cancelled`)throw Error(`Technical failure did not converge workflow execution '${e.executionId}'`);return}if(e.outcome.status===`paused`){await di(this.bus,e.executionId,e.outcome);return}let t=await this.acceptTerminalResult(e.executionId,e.outcome);if(!t.accepted||!u(t.status,e.outcome.status))throw Error(`Workflow result did not converge execution '${e.executionId}'`)}};function pi(e,t){return{authority:t.authority,decodeOutcome:ze,convergence:new fi(e,t.acceptTerminalResult,t.acceptTechnicalFailure,t.acceptCancellation)}}function mi(e,t){let n=pi(e,t),r=li(e,n),i=e.on(at.control.outcome.submit,async e=>{let r=ui(e,e.payload);if(r===null)throw Error(`Outcome submission requires an authenticated workflow-execution-attempt peer`);let{result:i}=e.payload;if(!e.origin.local){if(e.payload.executionId!==r.executionId)throw Error(`Outcome payload executionId '${e.payload.executionId}' does not match authenticated peer claim '${r.executionId}'`);if(e.payload.executionAttemptId!==r.executionAttemptId)throw Error(`Outcome payload executionAttemptId '${e.payload.executionAttemptId}' does not match authenticated peer identity '${r.executionAttemptId}'`)}if(i.executionId!==r.executionId)throw Error(`Nested result.executionId '${i.executionId}' does not match trusted identity '${r.executionId}'`);let a=ut.parse(i),o=await t.authority.getInstruction(r);if(o===null)throw Error(`No instruction belongs to this workflow Attempt`);let s=await n.decodeOutcome({instruction:o,outcome:{kind:`workload-result`,result:a}}),c=await ai(n,{executionId:r.executionId,executionAttemptId:r.executionAttemptId,outcome:s});e.setResult({decision:hi(c)})});return()=>{i(),r()}}function hi(e){return e}function gi(e,t){return e.on(S.operation.admit,async e=>{let n=o(e);if(n===null)throw Error(`Operation admission requires an authenticated workflow-execution-attempt peer`);let{executionAttemptId:r,operationKind:i,admissionKey:a,runtimeGeneration:s}=x[`operation.admit`].request.parse(e.payload);if(r!==n.executionAttemptId)throw Error(`Admission payload executionAttemptId '${r}' does not match authenticated peer identity '${n.executionAttemptId}'`);if(i===`runtime-probe`)throw Error(`Operation admission does not accept 'runtime-probe' (executionAttemptId='${r}'): the bounded probe is admitted only by runtime registration`);let c=await t.authority.admitOperation({executionAttemptId:r,executionId:n.executionId,operationKind:i,admissionKey:a,runtimeGeneration:s});if(c.kind===`admitted`||c.kind===`duplicate`){await t.bus.emit(S.operation.admitted,{executionAttemptId:r,operationId:c.operationId,operationKind:i,runtimeGeneration:c.runtimeGeneration,admittedAt:c.admittedAt}),e.setResult({decision:c.kind,operationId:c.operationId});return}e.setResult({decision:`refused`,refusalReason:c.kind})})}const _i=1e4;function vi(e,t){let n=t.probeDeliveryTimeoutMs??1e4;return e.on(S.runtime.register,async e=>{let r=o(e);if(r===null)throw Error(`Runtime registration requires an authenticated workflow-execution-attempt peer`);let{executionAttemptId:i,runtimeIncarnationId:a}=x[`runtime.register`].request.parse(e.payload);if(i!==r.executionAttemptId)throw Error(`Registration payload executionAttemptId '${i}' does not match authenticated peer identity '${r.executionAttemptId}'`);let s=await t.authority.registerRuntime({executionAttemptId:i,executionId:r.executionId,runtimeIncarnationId:a});if(s.kind===`duplicate`&&s.runtimeReadyAt!==null){await yi(t,i,s.runtimeGeneration),e.setResult({decision:`duplicate`,runtimeGeneration:s.runtimeGeneration});return}if(s.kind!==`registered`&&s.kind!==`duplicate`){e.setResult(Si(s.kind));return}let c=s.runtimeGeneration;if(await bi(t,n,{executionAttemptId:i,executionId:r.executionId,runtimeIncarnationId:a,runtimeGeneration:c})===null){e.setResult(Si(`probe-failed`));return}await yi(t,i,c),e.setResult({decision:`ready`,runtimeGeneration:c})})}async function yi(e,t,n){let r=await e.authority.getAttemptControlState(t);r===null||r.runtimeGeneration!==n||r.runtimeReadyAt===null||await e.bus.emit(S.runtime.ready,{executionAttemptId:t,runtimeGeneration:n,acceptedAt:r.runtimeReadyAt})}async function bi(e,t,n){let{executionAttemptId:r,executionId:i,runtimeIncarnationId:a,runtimeGeneration:o}=n,s=await e.authority.admitOperation({executionAttemptId:r,executionId:i,operationKind:`runtime-probe`,admissionKey:`probe:${a}`,runtimeGeneration:o});if(s.kind!==`admitted`&&s.kind!==`duplicate`)return null;let c=s.operationId,l=()=>xi(e,{executionAttemptId:r,operationId:c,runtimeGeneration:o}),u;try{u=(await e.bus.request(S.operation.deliver,{executionAttemptId:r,runtimeIncarnationId:a,operationId:c,operationKind:`runtime-probe`,runtimeGeneration:o},{timeout:t})).receipt}catch{return await l(),null}if(u!==`completed`&&u!==`duplicate`)return await l(),null;let d=await e.authority.completeOperation({executionAttemptId:r,operationId:c,runtimeGeneration:o});if(d.kind!==`completed`&&d.kind!==`duplicate`)return null;let f=await e.authority.markRuntimeReady({executionAttemptId:r,executionId:i,runtimeGeneration:o,readyAt:new Date().toISOString()});return f.kind!==`ready`&&f.kind!==`duplicate`?null:{kind:f.kind,acceptedAt:f.acceptedAt}}async function xi(e,t){try{await e.authority.completeOperation(t)}catch{}}function Si(e){return{decision:`refused`,runtimeGeneration:0,refusalReason:e}}function Ci(e,t,n){n(vi(e,{bus:e,authority:t})),n(gi(e,{bus:e,authority:t}))}function wi(e,t){let n=new AbortController,r=e.on(S.bootstrap.awaitStart,async e=>{let r=o(e);if(r===null)throw Error(`Bootstrap start requires an authenticated workflow-execution-attempt peer`);let{executionAttemptId:i}=x[`bootstrap.awaitStart`].request.parse(e.payload);if(i!==r.executionAttemptId)throw Error(`Bootstrap start executionAttemptId does not match authenticated peer identity`);let a=e.signal?AbortSignal.any([e.signal,n.signal]):n.signal;e.setResult(await t.awaitBootstrapStart({executionAttemptId:i,executionId:r.executionId},{signal:a,deadline:e.deadline??Date.now()+31e3}))});return()=>{n.signal.aborted||(n.abort(Error(`Bootstrap start handler shut down`)),r())}}function Ti(e){return e.on(g.finalizeDelegateResult,async t=>{let n=t.payload;Ei(t,n.executionId);let{execution:r}=await e.request(h.getExecution,{executionId:n.executionId});if(r===null||r.workflowId!==n.workflowId)throw Error(`delegate result finalization execution does not own the requested workflow`);let{runContext:i}=await e.request(h.getRunContext,{executionId:n.executionId});if(i===null||i.executionId!==n.executionId||i.workflowId!==n.workflowId)throw Error(`delegate result finalization run context does not own the requested workflow execution`);if(i.definitionSnapshot===void 0)throw Error(`delegate result finalization requires an Authority-owned definition snapshot`);Di(i.definitionSnapshot,n.nodeId,n.nodeType,n.finalizerId);let{subjects:a}=pt(n.finalizerId),o=await e.request(a.finalize,{executionId:n.executionId,workflowId:n.workflowId,frameId:n.frameId,nodeId:n.nodeId,nodeType:n.nodeType,rawResult:n.rawResult,toolObservations:n.toolObservations,...n.economics===void 0?{}:{economics:n.economics}});t.setResult(o)})}function Ei(e,t){if(!m(e,t))throw Error(`delegate result finalization requires its authenticated workflow-execution-attempt peer`)}function Di(e,t,n,r){let i=!1;if(vt(e.root,{enter(e){if(!(e.type!==`delegate-agent`&&e.type!==`delegate-role`||e.id!==t||e.type!==n))return e.resultFinalizerId===r&&(i=!0),!1}}),!i)throw Error(`delegate result finalizer is not selected by the requested durable delegate node`)}async function Oi(e,n,r){let[{execution:i},{runContext:a}]=await Promise.all([e.bus.request(h.getExecution,{executionId:n}),e.bus.request(h.getRunContext,{executionId:n})]);if(!i)throw Error(`Authority execution not found: ${n}`);if(a?.executionId!==n||a.workflowId!==i.workflowId)throw Error(`authority technical failure run context identity mismatch`);if(a.terminalAuthority!==`authority`)throw Error(`authority technical failure requires terminalAuthority=authority`);if(i.status===`failed`||i.status===`cancelled`)return{accepted:!0,status:i.status};if(i.status!==`running`)throw Error(`Authority technical failure conflicts with execution status: ${i.status}`);await t(e,i,n,`${r.stage}: ${r.message}`);let o=await e.bus.request(h.getExecution,{executionId:n});if(o.execution?.status!==`failed`&&o.execution?.status!==`cancelled`)throw Error(`Authority technical failure did not settle as failed or cancelled`);return{accepted:!0,status:o.execution.status}}async function ki(e,t,n){let[{execution:r},{runContext:i}]=await Promise.all([e.bus.request(h.getExecution,{executionId:t}),e.bus.request(h.getRunContext,{executionId:t})]);if(!r)throw Error(`Authority execution not found: ${t}`);if(i?.executionId!==t||i.workflowId!==r.workflowId)throw Error(`authority cancellation run context identity mismatch`);if(i.terminalAuthority!==`authority`)throw Error(`authority cancellation requires terminalAuthority=authority`);if(r.status===`cancelled`)return{accepted:!0,status:`cancelled`};if(r.status!==`running`)throw Error(`Authority cancellation conflicts with execution status: ${r.status}`);if(await _(e,t,n.reason),(await e.bus.request(h.getExecution,{executionId:t})).execution?.status!==`cancelled`)throw Error(`Authority cancellation did not settle as cancelled`);return{accepted:!0,status:`cancelled`}}var Ai=class extends yt{workflowRunner;executionAttemptAuthority;static storage={drizzle:Ar};config;stopBootstrapWaits;activeExecutions=new Map;executionTasks=new Map;shellAbortControllers=new Map;activeRunnerSteps=new Map;gateTimeoutScheduler;resumeDispatches=new Set;workflowAbortControllers=new Map;successFinalizers=new Map;durableLifecycleTransitions=new Map;lifecyclePublications=new Map;publishingLifecycleExecutions=new Set;materializationSpecResolvers=new Set;constructor(e,t,n,r){super(e),this.workflowRunner=n,this.executionAttemptAuthority=r,this.config={...He,...t},this.gateTimeoutScheduler=new Jr(e,e=>this.resumePausedExecution(e))}registerWorkflowMaterializationSpecResolver(e){return this.materializationSpecResolvers.add(e),()=>this.materializationSpecResolvers.delete(e)}async registerSuccessFinalizer(e){if(!this.initialized)throw Error(`[WorkflowExecutor] Initialize the executor before registering success finalizers`);if(this.successFinalizers.has(e))throw Error(`[WorkflowExecutor] Success finalizer already registered: ${e}`);let{namespace:t,subjects:n}=mt(e);this.bus.registerNamespace(t);let r={finalizerId:e,finalizeSubject:n.finalize};this.successFinalizers.set(e,r);try{await d(this.buildFinalizerDeps())}catch(t){throw this.successFinalizers.get(e)===r&&this.successFinalizers.delete(e),t}let i=!1;return()=>{i||(i=!0,this.successFinalizers.get(e)===r&&this.successFinalizers.delete(e))}}async acceptAuthorityRunnerResult(e,t){if(t.status===`paused`)throw Error(`authority runner result must be terminal`);if(t.executionId!==e)throw Error(`authority runner result execution identity mismatch`);let{execution:n}=await this.bus.request(h.getExecution,{executionId:e});if(!n)throw Error(`Authority runner execution not found: ${e}`);if(n.workflowId!==t.workflowId)throw Error(`authority runner result workflow identity mismatch`);let r;if(n.status===`finalizing`){let{workflow:n}=await this.loadAuthorityRunnerContext(e,t.workflowId);r=await this.registerAuthorityResultFinalizer(n)}let i=await this.resolveAuthorityRunnerReplay(n,t).finally(()=>r?.());if(i!==void 0)return{accepted:!0,status:i};if(n.status!==`running`)throw Error(`Authority runner execution is ${n.status}`);let{runContext:a,workflow:o}=await this.loadAuthorityRunnerContext(e,t.workflowId),s=await this.registerAuthorityResultFinalizer(o),c=this.activeExecutions.get(e),l=!1;if(!c)this.activeExecutions.set(e,{execution:n,workflow:o,runContext:a,runtimeHandlers:new Map,runtimeLoopGates:new Map}),l=!0;else if(c.execution.workflowId!==t.workflowId)throw Error(`authority runner active execution identity mismatch`);try{await f({activeExecutions:this.activeExecutions,buildFinalizerDeps:()=>this.buildFinalizerDeps()},t)}finally{l&&this.activeExecutions.delete(e),s?.()}let d=await this.bus.request(h.getExecution,{executionId:e});if(!d.execution||!u(d.execution.status,t.status))throw Error(`Authority runner result did not settle compatibly with ${t.status}`);return{accepted:!0,status:d.execution.status}}acceptAuthorityTechnicalFailure=(e,t)=>Oi(this.buildFinalizerDeps(),e,t);acceptAuthorityCancellation=(e,t)=>ki(this.buildFinalizerDeps(),e,t);async resolveAuthorityRunnerReplay(e,t){if(e.status===`finalizing`){if(t.status!==`completed`)throw Error(`authority runner result conflicts with terminal execution`);await d(this.buildFinalizerDeps());let n=await this.bus.request(h.getExecution,{executionId:e.id});if(!n.execution)throw Error(`Authority runner success finalization execution is missing`);if(!u(n.execution.status,t.status))throw Error(`authority runner result conflicts with terminal execution`);return n.execution.status}if(!(e.status!==`completed`&&e.status!==`failed`&&e.status!==`cancelled`)){if(!u(e.status,t.status))throw Error(`authority runner result conflicts with terminal execution`);return e.status}}async loadAuthorityRunnerContext(e,t){let{runContext:n}=await this.bus.request(h.getRunContext,{executionId:e});if(!n)throw Error(`Authority runner run context not found: ${e}`);if(n.executionId!==e||n.workflowId!==t)throw Error(`authority runner run context identity mismatch`);if(n.terminalAuthority!==`authority`)throw Error(`authority runner result requires terminalAuthority=authority`);let r=n.definitionSnapshot??(await this.bus.request(h.get,{id:n.workflowId})).workflow;if(!r||r.id!==t)throw Error(`authority runner workflow definition is unavailable or mismatched`);return{runContext:n,workflow:r}}registerAuthorityResultFinalizer(e){return!e.successFinalizerId||this.successFinalizers.has(e.successFinalizerId)?Promise.resolve(void 0):this.registerSuccessFinalizer(e.successFinalizerId)}async onInit(){this.registerExecutionHandlers(),this.addCleanup(Ee(this.bus,(e,t)=>{let n=this.activeExecutions.get(e);n!==void 0&&(n.workflow=t)})),this.addCleanup(Ti(this.bus)),this.executionAttemptAuthority!==void 0&&(this.stopBootstrapWaits=wi(this.bus,this.executionAttemptAuthority),this.addCleanup(this.stopBootstrapWaits),this.addCleanup(mi(this.bus,{bus:this.bus,authority:this.executionAttemptAuthority,acceptTerminalResult:(e,t)=>this.acceptAuthorityRunnerResult(e,t),acceptTechnicalFailure:this.acceptAuthorityTechnicalFailure,acceptCancellation:this.acceptAuthorityCancellation})),Ci(this.bus,this.executionAttemptAuthority,e=>this.addCleanup(e))),Fr(this.bus).forEach(e=>this.addCleanup(e)),zr(this.bus).forEach(e=>this.addCleanup(e)),await this.rehydratePausedGateTimeouts()}async onDestroy(){this.stopBootstrapWaits?.();let e=this.buildFinalizerDeps();await Promise.allSettled([...this.activeExecutions.keys()].map(async t=>{await p(e,t,`Workflow engine shutdown`)&&(this.workflowAbortControllers.get(t)?.abort(),this.workflowAbortControllers.delete(t))}));for(let e of this.workflowAbortControllers.values())e.abort();this.workflowAbortControllers.clear(),await Promise.allSettled(this.executionTasks.values()),await Promise.allSettled(this.durableLifecycleTransitions.values()),await Promise.allSettled(this.lifecyclePublications.values());for(let e of this.shellAbortControllers.values())e.abort();this.shellAbortControllers.clear();for(let e of this.activeRunnerSteps.values())e.hardKillTimer&&clearTimeout(e.hardKillTimer);this.activeRunnerSteps.clear(),this.gateTimeoutScheduler.dispose(),await this.workflowRunner?.dispose?.(),this.activeExecutions.clear()}buildFinalizerDeps(){let e=this.executionAttemptAuthority;return{bus:this.bus,activeExecutions:this.activeExecutions,shellAbortControllers:this.shellAbortControllers,activeRunnerSteps:this.activeRunnerSteps,cancelTimeoutMs:this.config.cancelTimeoutMs,requestAttemptCancellation:e===void 0?void 0:(t,n)=>e.requestCancellation({executionId:t,reason:n}),notifyAttemptCancellation:(e,t)=>this.notifyAttemptCancellation(e,t),successFinalizers:this.successFinalizers,resolveSuccessFinalizerId:e=>this.activeExecutions.get(e)?.workflow.successFinalizerId,durableLifecycleTransitions:this.durableLifecycleTransitions,lifecyclePublications:this.lifecyclePublications,publishingLifecycleExecutions:this.publishingLifecycleExecutions}}async notifyAttemptCancellation(e,t){this.workflowAbortControllers.get(e)?.abort(t??rt),await this.bus.emit(ft(`workflow.${e}.cancel`),{executionId:e,reason:t}).catch(t=>{console.error(`[WorkflowExecutor] Failed to emit workflow cancel for ${e}:`,t)})}buildRunnerTaskDeps(e){return{workflowRunner:e,workflowAbortControllers:this.workflowAbortControllers,executionTasks:this.executionTasks,activeExecutions:this.activeExecutions,buildFinalizerDeps:()=>this.buildFinalizerDeps(),config:this.config}}async resolveExecutionWorkspaceRoot(e){if(!e)return this.config.platformDefaults.cwd;let{session:t}=await this.bus.request(nt.get,{sessionId:e});if(t===null)throw Error(`[WorkflowExecutor] Parent session not found: ${e}`);return t.targetWorkingDirectory??this.config.platformDefaults.cwd}resolveEphemeralPlatformFields(){return Le(this.config.platformDefaults.cwd,this.config.makaioHome)}buildStartDeps(){return{bus:this.bus,config:this.config,activeExecutions:this.activeExecutions,executionTasks:this.executionTasks,workflowRunner:this.workflowRunner,buildRunContext:e=>Qr(e,this.config),buildRunnerTaskDeps:e=>this.buildRunnerTaskDeps(e),buildFinalizerDeps:()=>this.buildFinalizerDeps(),resolveExecutionWorkspaceRoot:e=>this.resolveExecutionWorkspaceRoot(e),runExecution:e=>this.runExecution(e),executionAttemptAuthority:this.executionAttemptAuthority,materializationSpecResolvers:this.materializationSpecResolvers}}registerExecutionHandlers(){this.registerHandler(g.acceptAuthorityRunnerResult,async e=>{if(!e.origin.local)throw Error(`authority runner result acceptance is local-authority only`);let{executionId:t,result:n}=e.payload;e.setResult(await this.acceptAuthorityRunnerResult(t,n))}),this.registerHandler(g.start,async e=>{let{workflowId:t,input:n,config:r,parentSessionId:i,triggerPayload:a,artifactRef:o,scope:s}=e.payload;try{let c=await pe(this.buildStartDeps(),t,{input:Zr(n),config:Yr(r)??{},parentSessionId:i,triggerPayload:a,artifactRef:o,scopeOverride:s});e.setResult({executionId:c})}catch(e){if(e instanceof C)throw e;let t=e instanceof Error?e.message:String(e);throw Error(`Failed to start workflow: ${t}`)}}),this.registerHandler(g.rerun,async e=>{let{executionId:t,mode:n,input:r,config:i,parentSessionId:a,triggerPayload:o,artifactRef:s,scope:c,reason:l}=e.payload;try{let u=await Hr(this.buildStartDeps(),{executionId:t,mode:n,input:Zr(r),config:Yr(i),parentSessionId:a,triggerPayload:o,artifactRef:s,scopeOverride:c,reason:l});e.setResult({executionId:u})}catch(e){if(e instanceof C)throw e;let t=e instanceof Error?e.message:String(e);throw Error(`Failed to rerun workflow: ${t}`)}}),this.registerHandler(g.runFile,async e=>{if(this.workflowRunner===void 0)throw Error(`workflow.runFile requires a workflow runner — configure a ThinWorkflowPiscinaRunner or equivalent.`);let{filePath:t,materializationSpec:n,triggerPayload:r,triggerMode:i,scope:a}=e.payload;try{let o=await Ae(this.buildStartDeps(),t,{...n===void 0?{}:{materializationSpec:n},triggerPayload:r,triggerMode:i,scopeOverride:a});e.setResult({executionId:o})}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to start workflow file: ${t}`)}}),this.registerHandler(g.cancel,async e=>{let{executionId:t,reason:n}=e.payload,r=await p(this.buildFinalizerDeps(),t,n);e.setResult({cancelled:r})}),this.registerGateTimeoutHandlers(),this.addCleanup(this.bus.on(g.gate.respond,async e=>{let{executionId:t,gateId:n,frameId:r,action:i,resumeData:a,reason:o}=e.payload,s=await this.respondToPausedGate({executionId:t,gateId:n,frameId:r,action:i,resumeData:a,reason:o});e.setResult({accepted:s})},{priority:-100}))}registerGateTimeoutHandlers(){this.addCleanup(this.bus.on(g.gate.suspended,e=>{this.gateTimeoutScheduler.schedule(e.payload)})),this.addCleanup(this.bus.on(g.gate.resolved,e=>{this.gateTimeoutScheduler.clear(e.payload.executionId,e.payload.stepId,e.payload.frameId)}))}async rehydratePausedGateTimeouts(){let{gates:e}=await this.bus.request(h.listPausedGateTimeouts,{});for(let t of e)this.gateTimeoutScheduler.schedule(ri(t))}async runExecution(e){let n=this.activeExecutions.get(e);if(!n)return;let r=new AbortController;this.workflowAbortControllers.set(e,r);try{let i;try{let t=await le({definition:n.workflow,execution:n.execution,runContext:n.runContext,bus:this.bus}),a=new Se(e,n.workflow.id,n.workflow,n.execution,n.runtimeHandlers,this.bus,r.signal,void 0,t,{context:this.resolveEphemeralPlatformFields(),env:n.runContext.env},{runtimeLoopGates:n.runtimeLoopGates});Ne(n.workflow,n.runtimeLoopGates);let o=a.buildExpressionContext();i=await ye(n.workflow.root,a,o)}catch(i){if(r.signal.aborted||n.execution.status===`cancelled`){await _(this.buildFinalizerDeps(),e,rt);return}let a=i instanceof Error?i.message:String(i);await t(this.buildFinalizerDeps(),n.execution,e,a);return}let a=this.buildFinalizerDeps();i.status===`cancelled`||r.signal.aborted||n.execution.status===`cancelled`?await _(a,e,rt):i.status===`failed`?await t(a,n.execution,e,i.error):i.status===`paused`?(n.execution.status=`paused`,await this.bus.request(h.setExecution,{execution:n.execution}),this.activeExecutions.delete(e)):await xe(a,n.execution,e,n.execution.startedAt)}finally{this.workflowAbortControllers.delete(e)}}async respondToPausedGate(e){let{executionId:t,gateId:n,frameId:r,resumeData:i,reason:a}=e,{execution:o}=await this.bus.request(h.getExecution,{executionId:t});if(!$r(o))return!1;let s=await ii(this.bus,{executionId:t,nodeId:n,frameId:r});if(s===null||!Oe(n,s.schema,i).valid)return!1;let{runContext:c}=await this.bus.request(h.getRunContext,{executionId:t});if(c===null)throw Error(`[WorkflowExecutor] Run context not found for paused execution: ${t}`);await ni(this.bus,c);let{accepted:l}=await this.bus.request(h.resolveWaitingGateInstance,{gate:{...s,status:e.action===`reject`?`rejected`:`resumed`,resumeData:i,...a===void 0?{}:{reason:a},resolvedAt:Date.now()}});if(!l)return!1;try{await this.resumePausedExecution(o.id)}catch(e){throw await ti(this.buildFinalizerDeps(),this.activeExecutions,this.executionTasks,this.workflowAbortControllers,o,s,n),e}return this.gateTimeoutScheduler.clear(t,n,s.frameId),!0}async resumePausedExecution(e){if(!this.resumeDispatches.has(e)){this.resumeDispatches.add(e);try{await this.dispatchPausedExecutionResume(e)||this.resumeDispatches.delete(e)}catch(t){throw this.resumeDispatches.delete(e),t}}}async dispatchPausedExecutionResume(e){let{runContext:t}=await this.bus.request(h.getRunContext,{executionId:e});if(t===null)throw Error(`[WorkflowExecutor] Run context not found for paused execution: ${e}`);let n=t.definitionSnapshot??(await this.bus.request(h.get,{id:t.workflowId})).workflow??(()=>{throw Error(`[WorkflowExecutor] Workflow definition not found for paused execution: ${e}`)})();await ni(this.bus,t);let a=r(t,n,{resume:!0}),o=he(this.buildStartDeps(),a);return i(this.buildFinalizerDeps(),e,async()=>{let{execution:r}=await this.bus.request(h.getExecution,{executionId:e});if(r===null)throw Error(`[WorkflowExecutor] Execution not found for paused execution: ${e}`);if(r.status!==`paused`)return!1;await this.bus.request(h.setExecution,{execution:{...r,status:`running`}}),this.activeExecutions.set(e,{execution:{...r,status:`running`},workflow:n,runContext:t,runtimeHandlers:new Map,runtimeLoopGates:new Map});let i=_e(this.buildStartDeps(),a,o).finally(()=>this.resumeDispatches.delete(e));return this.executionTasks.set(e,i),!0})}};const Q=`[WorkflowTriggerReconciler]`;function ji(e){return e.map(Mi)}function Mi(e){let t=ot.parse(e);return{binding:t,matches:Ge(t),subscription:void 0}}function Ni(e,t,n){let r=e.triggers??[];try{return n===void 0?ji(r):r.map(e=>n.has(e.kind)?Mi(e):void 0)}catch(i){if(t){console.error(`${Q} keeping last-good triggers for workflow "${e.id}": its trigger bindings are invalid`,i);return}return r.map((t,r)=>{if(!(n!==void 0&&!n.has(t.kind)))try{return Mi(t)}catch(t){console.error(`${Q} leaving invalid trigger ${r} of workflow "${e.id}" inactive`,t);return}})}}function Pi(e,t){return e.scope.type!==`global`||t.kind!==Ze}async function Fi(e,t,n,r){if(r!==void 0)for(let[i,a]of Array.from(r)){let o=e.triggers?.[i];if(o!==void 0&&n!==void 0&&!n.has(o.kind))continue;let s=t[i];s!==void 0&&Pi(e,s.binding)||(r.delete(i),await $(a.subscription))}}async function $(e){if(e!==void 0)try{await e.detach()}catch(t){console.error(`${Q} detach failed for '${e.bindingKey}':`,t)}}var Ii=class{bus;resolveRuntime;consumers=new Map;cleanupFns=[];initialized=!1;initialization;lane=new Je;pendingChanges=[];constructor(e,t){this.bus=e,this.resolveRuntime=t}async init(){if(this.initialized)return;if(this.initialization!==void 0)return this.initialization;let e=this.initialize();return this.initialization=e,e.then(()=>this.clearInitialization(e),()=>this.clearInitialization(e)),e}clearInitialization(e){this.initialization===e&&(this.initialization=void 0)}async initialize(){try{let e=({payload:e})=>{this.onSignal(`refresh of workflow "${e.id}"`,()=>this.refreshDefinition(e.id))};this.cleanupFns.push(this.bus.on(w.definition.created,e),this.bus.on(w.definition.updated,e),this.bus.on(w.definition.deleted,e),this.bus.on(Xe.changed,e=>{this.scheduleRegistryReconcile(e.payload)})),await this.reconcileStored(`keep-last-good`),this.initialized=!0}catch(e){throw await this.teardown(),e}}async destroy(){await this.teardown(),this.initialized=!1}activeConsumerCount(){let e=0;for(let t of this.consumers.values())e+=t.size;return e}onSignal(e,t){t().catch(t=>{console.error(`${Q} ${e} failed:`,t)})}scheduleRegistryReconcile(e){let t=this.pendingChanges.length>0;this.pendingChanges.push(e),!t&&queueMicrotask(()=>{if(this.pendingChanges.length===0)return;let e=this.pendingChanges.splice(0),t=new Set(e.flatMap(({kinds:e})=>e)),n=e.map(({owner:e,revision:t})=>`${e}@${t}`).join(`, `);this.onSignal(`reconciliation after trigger registry changes (${n})`,()=>this.reconcileStored(`drop-unavailable`,t))})}async reconcileStored(e,t){await this.lane.run(async()=>{let{workflows:n}=await this.bus.request(h.list,{}),r=new Set(n.map(e=>e.id));for(let r of n){let n=r.triggers??[];t!==void 0&&!n.some(e=>t.has(e.kind))||await this.applyDefinitionWithinLane(r,e,t)}for(let e of Array.from(this.consumers.keys()))r.has(e)||await this.forgetWorkflowWithinLane(e)})}async refreshDefinition(e){await this.lane.run(async()=>{let{workflow:t}=await this.bus.request(h.get,{id:e});if(t===null){await this.forgetWorkflowWithinLane(e);return}await this.applyDefinitionWithinLane(t,`keep-last-good`)})}async applyDefinitionWithinLane(e,t,n){let r=Ni(e,(this.consumers.get(e.id)?.size??0)>0,n);if(r===void 0)return;let i=this.consumers.get(e.id);if(await Fi(e,r,n,i),i?.size===0&&this.consumers.delete(e.id),!r.some(t=>t!==void 0&&Pi(e,t.binding)&&(n===void 0||n.has(t.binding.kind))))return;let a=this.resolveRuntime();if(a===void 0){r.length>0&&console.warn(`${Q} no automation trigger binding runtime is available; declarative triggers of workflow "${e.id}" stay inactive`);return}let o=this.consumers.get(e.id);o===void 0&&(o=new Map,this.consumers.set(e.id,o));for(let[i,s]of r.entries())s!==void 0&&Pi(e,s.binding)&&(n!==void 0&&!n.has(s.binding.kind)||await this.refreshConsumerWithinLane(a,e.id,i,s,o,t));o.size===0&&this.consumers.delete(e.id)}async refreshConsumerWithinLane(e,t,n,r,i,a){let o=i.get(n),s=this.createListener(t,n,r);try{let t=o?.subscription?.bindingKey,a=e.prepareBinding(r.binding);if(a===void 0)throw Error(`Automation trigger kind '${r.binding.kind}' is not registered`);if(!a.workflowCompatible)throw Error(`Automation trigger kind '${r.binding.kind}' does not emit an object-root payload`);(t===void 0||t!==a.bindingKey)&&i.set(n,r),r.subscription=await a.subscribe(s),i.set(n,r),await $(o?.subscription);return}catch(e){if(o===void 0?i.delete(n):i.set(n,o),a===`keep-last-good`){console.error(`${Q} keeping last-good trigger ${n} of workflow "${t}": binding '${r.binding.kind}' could not be activated`,e);return}console.warn(`${Q} dropping trigger ${n} of workflow "${t}": binding '${r.binding.kind}' is no longer available`,e),i.delete(n),await $(o?.subscription)}}async forgetWorkflowWithinLane(e){let t=this.consumers.get(e);if(t!==void 0){this.consumers.delete(e);for(let e of t.values())await $(e.subscription)}}createListener(e,t,n){let r=`trigger ${t} ('${n.binding.kind}') of workflow "${e}"`;return async i=>{if(this.consumers.get(e)?.get(t)!==n)return;let a;try{a=n.matches(i.payload)}catch(e){console.error(`${Q} filter evaluation failed for ${r}:`,e);return}if(a)try{await this.bus.request(w.start,{workflowId:e,triggerPayload:We(i.payload)})}catch(t){console.error(`${Q} failed to start workflow "${e}" from ${r}:`,t)}}}async teardown(){this.cleanupFns.forEach(e=>e()),this.cleanupFns.length=0,this.pendingChanges.length=0,await this.lane.run(async()=>{for(let e of Array.from(this.consumers.keys()))await this.forgetWorkflowWithinLane(e)})}};const Li=1e3;function Ri(e){if(e===null)return{status:`refused`,reason:`not-found`};if(e.settled)return{status:`refused`,reason:`resolved`};if(!e.active)return{status:`refused`,reason:`fenced`};if(e.allocationTerminated)return{status:`refused`,reason:`allocation-terminated`};if(e.operationStartGate===`closed`)return{status:`refused`,reason:`gate-closed`};let t=e.bootstrapDeadlineAt===null?NaN:Date.parse(e.bootstrapDeadlineAt);return!Number.isFinite(t)||t<=Date.now()?{status:`refused`,reason:`bootstrap-expired`}:{status:e.allocated?`permitted`:`pending`}}function zi(e,t){return new Promise((n,r)=>{let i=()=>{t.removeEventListener(`abort`,i),r(t.reason)};t.addEventListener(`abort`,i,{once:!0}),t.aborted&&i(),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}function Bi(e,t){return new Promise((n,r)=>{let i=()=>{clearTimeout(o),t.removeEventListener(`abort`,a),n()},a=()=>{clearTimeout(o),t.removeEventListener(`abort`,a),r(t.reason)},o=setTimeout(i,e);t.addEventListener(`abort`,a,{once:!0}),t.aborted&&a()})}function Vi(e,t){return setTimeout(()=>e.abort(Error(`Bootstrap start observation timed out`)),Math.max(0,t-Date.now()))}async function Hi(e,t,n){if(n.signal.throwIfAborted(),!Number.isFinite(n.deadline))throw Error(`Bootstrap start request requires a finite deadline`);let r=Math.min(Date.now()+3e4,n.deadline-Li),i=new AbortController,a=AbortSignal.any([n.signal,i.signal]),o=Math.min(n.deadline,r+Li),s=Vi(i,o);try{for(;;){a.throwIfAborted();let n=await zi(e.readBootstrapStartState(t),a);a.throwIfAborted();let c=Ri(n);if(c.status!==`pending`)return c;let l=Date.parse(n?.bootstrapDeadlineAt??``);clearTimeout(s),s=Vi(i,Math.min(o,l+Li));let u=Math.min(r,l)-Date.now();if(u<=0)return c;await Bi(Math.min(100,u),a)}}finally{clearTimeout(s)}}var Ui=class{repository;bootstrapTimeoutMs;waiters=new Map;constructor(e,t){if(!Number.isSafeInteger(t?.bootstrapTimeoutMs)||t.bootstrapTimeoutMs<=0)throw Error(`ExecutionAttemptAuthority requires an explicit positive safe-integer bootstrapTimeoutMs`);this.repository=e,this.bootstrapTimeoutMs=t.bootstrapTimeoutMs}awaitBootstrapStart(e,t){return Hi(this.repository,e,t)}async createAttempt(e,t){let n=crypto.randomUUID(),r=await this.repository.createAttempt({executionAttemptId:n,executionId:e,instruction:t,bootstrapTimeoutMs:this.bootstrapTimeoutMs});return this.installWaiter(n),r}async ensureAttempt(e){let t=qe(e);return this.repository.ensureAttempt({...t,executionAttemptId:crypto.randomUUID(),bootstrapTimeoutMs:this.bootstrapTimeoutMs})}async readAttemptSettlement(e){return this.repository.readAttemptSettlement(Ke(e))}async getInstruction(e){return this.repository.getInstruction(e)}async requestCancellation(e){return this.repository.requestCancellation({...e})}async readCancellation(e){return this.repository.readCancellation(e)}async reportOperation(e){return this.repository.reportOperation(e)}async beginProvisioning(e){return this.repository.beginProvisioning(e)}async getProviderOperation(e){return this.repository.getProviderOperation(e)}async renewProviderOperationClaim(e){return this.repository.renewProviderOperationClaim(e)}async takeOverProviderOperation(e){return this.repository.takeOverProviderOperation(e)}async handoffProviderOperation(e){return this.repository.handoffProviderOperation(e)}async recordProviderOperationUncertainty(e){return this.repository.recordProviderOperationUncertainty(e)}async completeProviderOperation(e){return this.repository.completeProviderOperation(e)}async recordAllocation(e){return this.repository.recordAllocation(e)}async recordProvisioningAbsent(e){let t=await this.repository.recordProvisioningAbsent(e);return t.kind===`recorded`&&this.rejectWaiterWith(e.claim.executionAttemptId,()=>Error(`Attempt '${e.claim.executionAttemptId}' provisioning produced no allocation: ${e.evidence.source} reported '${e.evidence.summary}'`)),t}async recordProvisionerIncarnationLost(e){let t=await this.repository.recordProvisionerIncarnationLost(e);if(t.kind===`recorded`){let{evidence:t,provisionerIncarnationId:n}=e.proof;this.rejectWaiterWith(e.claim.executionAttemptId,()=>Error(`Attempt '${e.claim.executionAttemptId}' lost the provisioner incarnation '${n}' its allocation was bound to: ${t.source} reported '${t.summary}'`))}return t}async recordAllocationTerminated(e){return this.repository.recordAllocationTerminated(e)}async registerRuntime(e){return this.repository.registerRuntime(e)}async admitOperation(e){return this.repository.admitOperation(e)}async completeOperation(e){return this.repository.completeOperation(e)}async markRuntimeReady(e){return this.repository.markRuntimeReady(e)}async getAttemptControlState(e){return this.repository.getAttemptControlState(e)}async getActiveAttempt(e,t){return this.repository.getActiveAttempt(e,t)}canonicalizeOutcome(e){return this.repository.canonicalizeOutcome(e)}decodeOutcome(e){return this.repository.decodeOutcome(e)}async commitOutcome(e,t,n,r){let i=await this.repository.commitOutcome({executionAttemptId:e,executionId:t,result:n,...r===void 0?{}:{runtimeFence:r}});return(i.kind===`conflict`||i.kind===`fenced`)&&this.settleWaiterInternal(e,i),i}waitForOutcome(e){return this.waiters.get(e)?.promise}settleOutcome(e,t){this.settleWaiterInternal(e,t)}discardWaiter(e){this.waiters.delete(e)}rejectAndDiscardWaiter(e,t){this.rejectWaiterWith(e,()=>t)}rejectWaiterWith(e,t){let n=this.waiters.get(e);n!==void 0&&(n.promise.catch(()=>void 0),n.reject(t()),this.waiters.delete(e))}get supportsRecovery(){return this.repository.recovery!==void 0}async getAttemptWithAllocation(e){return this.requireRecovery(`getAttemptWithAllocation`).getAttemptWithAllocation(e)}async recordDiscoveredAllocation(e){return this.requireRecovery(`recordDiscoveredAllocation`).recordDiscoveredAllocation(e)}async evolveAllocationRef(e){let t=this.requireRecovery(`evolveAllocationRef`);if(e.currentRef.providerId!==e.nextRef.providerId)throw Error(`Provider identity mismatch in allocation ref evolution: currentRef.providerId '${e.currentRef.providerId}' !== nextRef.providerId '${e.nextRef.providerId}'. Provider identity must not change during correlation.`);return t.evolveAllocationRef(e)}async getRecoverableAttempts(e){return this.requireRecovery(`getRecoverableAttempts`).getRecoverableAttempts(e)}async listOpenProviderOperations(e){return this.requireRecovery(`listOpenProviderOperations`).listOpenProviderOperations(e)}async recordInfrastructureFailure(e){let t=await this.repository.recordInfrastructureFailure(e);return t.kind===`recorded`&&this.rejectWaiterWith(e.claim.executionAttemptId,()=>Error(`Attempt '${e.claim.executionAttemptId}' suffered infrastructure failure: the provider allocation terminated without an acknowledged outcome`)),t}async abandonPendingAttempt(e,t){let n=await this.repository.abandonPendingAttempt(e,t);return(n.kind===`abandoned`||n.kind===`already-abandoned`)&&this.waiters.delete(e),n}requireRecovery(e){let{recovery:t}=this.repository;if(t===void 0)throw Error(`Recovery operation '${e}' requires a repository that exposes recovery operations. The injected repository does not support recovery.`);return t}installWaiter(e){this.waiters.set(e,se())}settleWaiterInternal(e,t){let n=this.waiters.get(e);if(n){switch(t.kind){case`accepted`:case`duplicate`:n.resolve(t.outcome);break;case`conflict`:n.reject(Error(`Outcome conflict for attempt '${e}': a different outcome was already committed`));break;case`fenced`:n.reject(Error(`Attempt '${e}' has been fenced: it is no longer the active attempt for this execution`));break}this.waiters.delete(e)}}},Wi=class extends yt{workflowExecutor;triggerReconcilerInstance;attemptAuthority;workspaceRootResolvers=new Set;constructor(e,t){super(e);let n=t?.executionAttemptAuthority;if(!n&&t?.executionAttemptRepository){let e=t.executionAttemptBootstrapTimeoutMs;if(e===void 0)throw Error(`An ExecutionAttemptRepository requires executionAttemptBootstrapTimeoutMs`);n=new Ui(t.executionAttemptRepository,{bootstrapTimeoutMs:e})}this.attemptAuthority=n,this.workflowExecutor=new Ai(e,t?.executorConfig,t?.workflowRunner,this.attemptAuthority);for(let e of t?.workflowMaterializationSpecResolvers??[])this.workflowExecutor.registerWorkflowMaterializationSpecResolver(e);let r=t?.automationTriggerBindingRuntime;this.triggerReconcilerInstance=new Ii(e,()=>r?.())}get executor(){return this.workflowExecutor}get executionAttemptAuthority(){return this.attemptAuthority}registerSuccessFinalizer(e){return this.workflowExecutor.registerSuccessFinalizer(e)}acceptAuthorityRunnerResult(e,t){return this.workflowExecutor.acceptAuthorityRunnerResult(e,t)}get triggerReconciler(){return this.triggerReconcilerInstance}registerWorkflowMaterializationSpecResolver(e){return this.workflowExecutor.registerWorkflowMaterializationSpecResolver(e)}registerWorkspaceRootResolver(e){return this.workspaceRootResolvers.add(e),()=>{this.workspaceRootResolvers.delete(e)}}async resolveWorkspaceRoot(e){for(let t of this.workspaceRootResolvers){let n=await t(e);if(n!==void 0)return n}}async onInit(){this.addCleanup(()=>this.destroyOwnedServices()),await this.workflowExecutor.init(),await this.triggerReconcilerInstance.init()}async destroyOwnedServices(){let e=[];for(let t of[()=>this.triggerReconcilerInstance.destroy(),()=>this.workflowExecutor.destroy()])try{await t()}catch(t){e.push(t)}if(e.length===1)throw e[0];if(e.length>1)throw AggregateError(e,`Workflow engine service teardown failed`)}};const Gi=gt(`makaio.workflow-engine`);function Ki(e){return{name:Gi.name,displayName:`Workflow Engine`,version:`0.1.0`,dependencies:[ht(At.name),ht(jt.name,void 0,!0)],critical:!0,namespaces:[ct,ne],storage:{registerHandlers:St(Ar)},create:t=>new Wi(t.bus,{...e,automationTriggerBindingRuntime:()=>t.getService(jt)})}}const qi=Ki();export{pn as _,Ui as a,wi as c,gi as d,li as f,dn as g,fn as h,Wi as i,_i as l,Ar as m,Ki as n,Ii as o,ai as p,qi as r,Ai as s,Gi as t,vi as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t}from"./json-value-DM-EjTC1.mjs";import{c as n,r}from"./kind-registration-DggkrLkv.mjs";import{z as i}from"zod";const a=i.string().min(1).regex(/\S/),o=i.strictObject({refClass:i.literal(`artifact`),kind:a,id:a,revision:a}),s=`x-makaio-value-type`,c=`evidence/v1`,l=i.string().min(1).regex(/\S/),u=i.strictObject({kind:i.literal(`whole-source`)}),d=i.strictObject({kind:i.literal(`lines`),startLine:i.number().int().positive(),lineCount:i.number().int().positive()}),f=i.strictObject({kind:i.literal(`data-path`),path:r}),p=i.strictObject({kind:i.literal(`git-file`),repository:l,path:l,commit:i.string().regex(/^(?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64})$/)}),m=i.strictObject({kind:i.literal(`confluence-page`),site:l,pageId:l,version:i.number().int().positive()}),h=i.strictObject({kind:i.literal(`artifact`),reference:o}),g=i.union([i.strictObject({source:p,location:i.union([u,d]),excerpt:i.string().optional()}),i.strictObject({source:m,location:u,excerpt:i.string().optional()}),i.strictObject({source:h,location:i.union([u,f]),excerpt:i.string().optional()})]).meta({title:`EvidenceValue`,description:`An immutable, directly cited source and its source-specific location.`,[s]:c}),_=i.object({kind:i.string().min(1),id:i.string().min(1),displayName:i.string().optional()}),v=i.object({level:i.string().min(1),ids:i.record(i.string().min(1),i.string().min(1)).optional()}).superRefine((e,t)=>{e.level!==`global`&&(!e.ids||Object.keys(e.ids).length===0)&&t.addIssue({code:i.ZodIssueCode.custom,path:[`ids`],message:`ids is required when scope level is not 'global'`})}),y=i.object({level:i.string().min(1),ids:i.record(i.string().min(1),i.string().min(1)).optional()}),b=i.object({refClass:i.literal(`local`).default(`local`),artifact:o,localId:i.string().min(1)}),x=i.object({refClass:i.literal(`evidence`).default(`evidence`),kind:i.string().min(1),id:i.string().min(1),revision:i.string().min(1).optional(),locator:i.string().min(1).optional()}),S=i.strictObject({refClass:i.literal(`entity`),entityType:i.string().min(1),id:i.string().min(1)}),C=i.discriminatedUnion(`refClass`,[o,b,x,S]);function w(e){return!e||typeof e!=`object`||Array.isArray(e)||`refClass`in e?e:`artifact`in e&&`localId`in e?{...e,refClass:`local`}:`locator`in e||!(`revision`in e)?{...e,refClass:`evidence`}:{...e,refClass:`artifact`}}const T=i.preprocess(w,C),E=i.discriminatedUnion(`refClass`,[o.extend({revision:o.shape.revision.optional()}),b,x,S]);function D(e){return!e||typeof e!=`object`||Array.isArray(e)||`refClass`in e?e:`artifact`in e&&`localId`in e?{...e,refClass:`local`}:`locator`in e?{...e,refClass:`evidence`}:{...e,refClass:`artifact`}}const O=i.preprocess(D,E),k=i.object({type:i.string().min(1),target:T}),A=i.enum([`assumed`,`inferred`,`stated`,`confirmed`,`verified`]),j=i.object({kind:i.string().min(1),actor:_,timestamp:i.number().int().nonnegative(),detail:i.string().optional(),evidenceRef:T.optional()}),M=i.object({level:A,basis:i.array(j)}),N=i.object({id:i.string().min(1),kind:i.string().min(1),summary:i.string().min(1),detail:i.string().optional(),severity:i.enum([`info`,`warning`,`blocker`]).optional(),tags:i.array(i.string().min(1)).optional(),regarding:i.union([o,b]).optional(),evidence:i.union([o,x]).optional(),actor:_,timestamp:i.number().int().nonnegative()}),P=i.object({markdown:i.string().optional(),summary:i.string().optional(),plaintext:i.string().optional()}),F=i.object({kind:o.shape.kind,id:o.shape.id,revision:o.shape.revision,scope:v,schemaVersion:n,data:e,relations:i.array(k),evidence:i.array(g).optional(),confidence:M.optional(),representations:P.optional(),actor:_,timestamp:i.number().int().nonnegative(),createdAt:i.number().int().nonnegative().optional()}),I=i.object({type:i.string().min(1),symmetry:i.enum([`asymmetric`,`symmetric`]),implication:i.string().min(1).optional(),sourceKinds:i.array(i.string().min(1)).optional(),targetKinds:i.array(i.string().min(1)).optional(),targetRefClasses:i.array(i.enum([`artifact`,`local`,`evidence`,`entity`])).optional()}),L=i.object({kind:i.string().min(1).optional(),scope:y.optional(),ids:i.array(i.string().min(1)).optional(),currentOnly:i.boolean().optional(),search:i.string().optional(),relation:i.object({type:i.string().min(1).optional(),target:O.optional()}).optional(),confidence:i.object({maxLevel:A.optional(),minLevel:A.optional()}).optional(),indexed:i.record(i.string(),t).optional(),limit:i.number().int().min(1).optional()}),R=i.object({base:o,target:o}),z=i.object({base:F,target:F,changedPaths:i.array(i.string())});export{o as C,g as S,x as _,L as a,s as b,k as c,F as d,v as f,S as g,M as h,N as i,T as l,A as m,R as n,y as o,j as p,z as r,O as s,_ as t,P as u,b as v,c as x,I as y};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{resolveMakaioHome as e}from"./runtime-node/makaio-config.mjs";import{t}from"./extension-package-provenance-BzvG6rDO.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-Bdv-_2Q9.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 h}from"node:fs/promises";import*as g from"node:path";import{basename as ee,isAbsolute as te,join as ne,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 oe,isRequestCancellation as se,waitForSubscriptionPropagation as ce}from"@makaio/framework/bus";import{AdapterSubjects as le,BoundedRecoveryEvidenceSchema as ue,ExecutionAttemptSchemas as y,ExecutionAttemptSubjects as b,FrameworkContractNamespaces as de,FrameworkStorageNamespaces as fe,JsonValueSchema as pe,PROVIDER_ALLOCATION_REF_VERSION as me,ProviderAllocationRefSchema as he,RECOVERY_EVIDENCE_LIMITS as x,WorkerCapabilitiesSchema as ge,WorkerSchemas as _e,WorkerSubjects as S,WorkflowRunContextSchema as ve,WorkflowRunResultSchema as ye,WorkflowWorkerConfigSchema as C,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(le.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`?g.extname(e)===``?i:[``,...i]:[``];for(let t of r.split(g.delimiter)){let n=t.replace(/^"|"$/gu,``),r=g.resolve(n||process.cwd());for(let t of a){let n=g.join(r,`${e}${t}`);try{return await h(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=g.resolve(t)+g.sep,i=g.resolve(e);if(i!==g.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+g.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(g.join(e,t)),m.lstat(g.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=g.join(t,a.name);if(a.isSymbolicLink())throw new H(`Contribution package contains a symbolic link: ${g.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(g.relative(e,n));continue}throw new H(`Contribution package contains an unsupported filesystem entry: ${g.relative(e,n)}`,`contribution-integrity-mismatch`)}}await i(e),r.sort();for(let t of r)n.update(t.split(g.sep).join(`/`)),n.update(`\0`),n.update(await m.readFile(g.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=g.join(t,a.name);if(!await yt(t,a.name)){if(a.isDirectory()){await i(n);continue}if(a.isFile()){r.push(g.relative(e,n));continue}throw a.isSymbolicLink()?new H(`Workspace root contains a symbolic link: ${g.relative(e,n)}`,`symlink-escape`):new H(`Workspace root contains an unsupported filesystem entry: ${g.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(g.join(e,t));n.update(r),n.update(`\0`)}return`${t}-${n.digest(`base64`)}`}async function wt(e,t,n){let r=g.join(t,`node_modules`,e.packageName);U(r,t,`Contribution package directory`),await W(r,t,`Contribution package directory`,n);let i=g.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=g.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=g.resolve(r,e.sourcePath);if(U(a,r,`Source path`),g.relative(r,a).split(g.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`?ne(e.moduleDir,`workflow-worker`,`worker-entry.ts`):ne(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,withAttemptCreation:r?.withAttemptCreation,dispatch:e=>this.options.dispatch({executionAttemptId:e,config:i,...a!==void 0&&{manifest:a},...o!==void 0&&{requirements:o},...s!==void 0&&{metadata:s}},t)}),e)}}},kt=class{#e;constructor(e){this.#e=e.bus}async run(e,t,n){let r=C.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=ee(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(S.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(S.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(b.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`]},Wt={code:`outcome-acknowledged`,summary:`Piscina runner settled and the Authority acknowledged its workflow outcome`},Gt={code:`outcome-delivery-ended`,summary:`Piscina runner settled and its bounded workflow outcome delivery ended`};function J(e){let t=new Set,n;return{publish:r=>{if(n!==void 0)return;let i=r();n=i;let a=[...t];t.clear();for(let t of a)try{t(i)}catch(t){console.error(`${e} observer failed:`,t)}},observe:e=>n===void 0?(t.add(e),()=>t.delete(e)):(e(n),()=>void 0)}}function Kt(e){let t=J(`[PiscinaThinWorkflowProvider] Infrastructure-conclusion`);return{conclude:n=>{t.publish(()=>({evidence:ue.parse({source:e.slice(0,x.source),summary:n.slice(0,x.summary),observedAt:new Date().toISOString()})}))},observe:t.observe}}function qt(e,t){let n=J(`[PiscinaThinWorkflowProvider] Provider-completion`),r=J(`[PiscinaThinWorkflowProvider] Local-observation-loss`),i;return{completion:{complete:r=>{i===void 0&&n.publish(()=>{let n=ue.parse({source:e.slice(0,x.source),code:r.code,summary:r.summary,observedAt:new Date().toISOString()});return t(),i=`completion`,n})},observe:n.observe},localObservationLoss:{lose:()=>{i===void 0&&r.publish(()=>(i=`local-observation-loss`,{}))},observe:e=>r.observe(()=>e())}}}var Jt=class{executionAttemptId;controller;detachCallerAbort;infrastructure;completion;localObservationLoss;revokeBusIdentity;constructor(e,t,n,r,i,a,o){this.executionAttemptId=e,this.controller=t,this.detachCallerAbort=n,this.infrastructure=r,this.completion=i,this.localObservationLoss=a,this.revokeBusIdentity=o}cancel(e){return this.controller.abort(e??`Worker cancelled`),this.detachCallerAbort(),Promise.resolve()}terminate(){return this.controller.abort(`Worker terminated`),this.detachCallerAbort(),this.revokeBusIdentity(),Promise.resolve()}release(){return this.detachCallerAbort(),Promise.resolve()}observeInfrastructureConclusion(e){return this.infrastructure.observe(e)}observeProviderCompletion(e){return this.completion.observe(e)}observeLocalObservationLoss(e){return this.localObservationLoss.observe(e)}},Yt=class{options;environment=`piscina`;allocationLifetime=`provisioner-process-bound`;baseCapabilities;constructor(e){this.options=e,this.baseCapabilities=ge.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=Kt(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}=e,c=await this.options.launchResolver(e,t);if(t.throwIfAborted(),!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}),f=!1,p=()=>{f||(f=!0,d.cleanup())};o=p;let m=qt(this.id,p),h=new Jt(i,n,a,r,m.completion,m.localObservationLoss,p);t.throwIfAborted();let g=this.options.runner.runWithReadiness({...c,busAuth:{kind:`hmac`,secret:d.secret}},n.signal,e.runtimeInputs.workerManifest,{executionAttemptId:i,bootstrapDeadlineAt:e.bootstrapDeadlineAt});return g.ready.then(()=>this.submitOutcomeOnSettlement(g.result,s,i,c.workflowId,r.conclude,m.completion.complete),e=>{n.abort(e),g.result.catch(()=>void 0),o?.(),r.conclude(`Piscina worker for attempt '${i}' was refused before its workflow run was admitted: `+(e instanceof Error?e.message:String(e))),m.localObservationLoss.lose()}),{kind:`allocated`,allocationRef:u,handle:h}}catch(e){throw n.abort(e),a(),o?.(),e}}async submitOutcomeOnSettlement(e,t,n,r,i,a){let o;try{o=await e}catch(e){o={executionId:t,workflowId:r,status:`failed`,error:e instanceof Error?e.message:String(e)}}try{let e={...Ht,...this.options.outcomeRetry};await Bt(this.options.bus,{executionAttemptId:n,executionId:t,result:o},{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`),a(Gt);return}a(Wt)}buildAllocationRef(e){let t={version:me,providerId:this.id,providerData:{executionAttemptId:e,allocatedAt:Date.now()}};return he.parse(t)}};function Xt(e){return async(t,n)=>{n.throwIfAborted();let r=await e({executionId:t.executionId,executionAttemptId:t.executionAttemptId});if(n.throwIfAborted(),r===null)throw Error(`Workflow launch instruction is unavailable for execution '${t.executionId}' attempt '${t.executionAttemptId}'`);let i=D(r);if(i.executionId!==t.executionId)throw Error(`Workflow instruction execution '${i.executionId}' does not match Worker request '${t.executionId}'`);return C.parse({source:i.source,...i.definitionSnapshot===void 0?{}:{definition:i.definitionSnapshot},executionId:i.executionId,workflowId:i.workflowId,triggerPayload:i.triggerPayload,...i.triggerMode===void 0?{}:{triggerMode:i.triggerMode},inputs:i.inputs,...i.config===void 0?{}:{config:i.config},...i.artifactRef===void 0?{}:{artifactRef:i.artifactRef},scope:i.scope,...t.connection.busUrl===void 0?{}:{busUrl:t.connection.busUrl},busAuth:t.connection.busAuth,...t.connection.env===void 0?{}:{env:t.connection.env},coordinatorSessionId:i.coordinatorSessionId,cancelSubject:i.cancelSubject,suspensionStrategy:t.runtimeInputs.suspensionStrategy,terminalAuthority:i.terminalAuthority,...i.materializationSpec===void 0?{}:{materializationSpec:i.materializationSpec}})}}const Zt=[Re,Fe,Le];function Qt(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 $t(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 en(e){let t=oe();t.registerNamespaces([...de,...fe]);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=Qt(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=[...Zt,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=$t(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 tn(e){return Number.isInteger(e)&&e>=1&&e<=2147483647}function Y(e,t){try{process.kill(-e,t)}catch(e){if(e.code!==`ESRCH`)throw e}}async function nn(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 rn(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 rn(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 an(e){if(e===void 0)return!0;try{try{Y(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 nn(e,Math.min(1e3,n)))return!0;await tt(20)}}catch{}return!1}async function on(e){if(e.signal?.aborted)return{status:`cancelled`,exitCode:null};if(!tn(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 sn(e)}catch{return{status:`spawn-failed`,exitCode:null,message:`Could not start the setup command`}}}function sn(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{Y(n.pid,`SIGTERM`)}catch(e){if(e.code!==`EPERM`){r=`stop-failed`;return}}i=setTimeout(()=>{try{n.pid!==void 0&&Y(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),an(n.pid).then(e=>{t({status:e?r??(a===0?`completed`:`failed`):`stop-failed`,exitCode:a})})})})}async function cn(e,t,n){if(g.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=g.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 ln(e){e.signal?.throwIfAborted();let{requirement:t}=e,n=g.resolve(e.workspaceRoot);if(!g.isAbsolute(e.workspaceRoot)||n===g.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 cn(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 un(t,{workspaceRoot:r,sourceRoots:i})}function un(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 on({...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?se(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 dn(e,t,n,r){let i=y[`instruction.get`].response.parse(await e.request(b.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 fn(e,t,n,r){let{executionAttemptId:i,runtimeGeneration:a}=t,o=y[`operation.admit`].response.parse(await Rt(async t=>await e.request(b.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 pn(e,t){return e.find(e=>e.kind===t.workload.kind&&e.version===t.workload.version)}function mn(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 hn(e,t,n,r){let i=y[`operation.report`].response.parse(await Rt(async i=>await e.request(b.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 gn(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 _n(e,t,n,r){if(r.aborted)return await Q(e,t,n,{kind:`cancelled`},void 0,void 0);let i=await fn(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:ln}).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=gn(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 hn(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 vn(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 _n(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 fn(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:pe.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 yn(e,t){let n;try{n=await dn(e,t.executionAttemptId,t.runtimeGeneration,t.signal)}catch(n){if(se(n,t.signal))return await Q(e,t,void 0,{kind:`cancelled`},void 0,void 0);throw n}let r=pn(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})??mn(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 vn(e,t,n,r,i)}finally{try{i.release()}catch{console.warn(`[makaio-worker] Workload control release failed.`)}}}async function bn(e,t,n,r,i){let a=_e[`runtime.inputs.get`].response.parse(await e.request(S.runtime.inputs.get,{executionAttemptId:t},{signal:i}));if(a.runtimeInputs===null)throw Error(`Selected Worker Runtime inputs are unavailable`);return ve.parse({...n,...a.runtimeInputs,createdAt:0,env:r})}function xn(e,t){let n=(e,t)=>{let n=re(e,t);return n===``||!te(n)&&n!==`..`&&!n.startsWith(`../`)&&!n.startsWith(`..\\`)};return n(e,t)||n(t,e)}async function Sn(t,n,r,i){let a=await t.loadContributions(r,i);i.throwIfAborted();let o=e();return await en({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 Cn(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 ce(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 bn(n,e.executionAttemptId,l,r,u),o=await e.materialize(a,u);(s===void 0||!xn(o.context.workspaceRoot,s.workspaceRoot))&&(i=o.cleanup);let c=wn(o.context,s);return u.throwIfAborted(),d=await Sn(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 wn(e,t){return t===void 0?e:{...e,workspaceRoot:t.workspaceRoot}}async function Tn(e,t){if(!(t.outcome.kind!==`workload-result`||e.onPostCommit===void 0))try{let n=ye.parse(t.outcome.result);await e.onPostCommit(n,t.decision)}catch{}}async function En(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:()=>Dn(e,a)}),u=s.bus,d=Cn({...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 yn(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 Tn(e,f),f}finally{try{await d.releaseExecutable(f)}finally{l.cleanup(),await s.close()}}}function Dn(e,t){let n=oe();return n.registerNamespaces([...de,...fe]),{bus:n,async connect(r){try{await e.connectBus(n,t,r),r.throwIfAborted()}catch(e){throw n.disconnect(),e}},close:()=>n.disconnect()}}const On=p(d),$=[`-c`,`core.attributesFile=${w}`],kn=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 An(e,t,n){try{let r=await e.resolveRepository(t,n);if(!g.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 jn(e,t,n,r,i){let a;try{a=(await On(`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 Mn(e){if(!tn(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=kn.parse(t.input),a=await An(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 jn(n,i.revision,o,e.timeoutMs,r);let a=await on({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 Nn(e){let t=Mn(e);return{prepare:e=>ln({...e,realizeSource:t})}}export{ut as A,k as B,Ct as C,wt as D,gt as E,mt as F,F as I,j as L,B as M,L as N,lt as O,dt as P,M as R,St as S,Tt as T,O as V,Dt as _,Xt as a,U as b,Pt as c,Vt as d,Bt as f,Ot as g,kt as h,en as i,ht as j,I as k,Nt as l,jt as m,En as n,Yt as o,Mt as p,yn as r,q as s,Nn as t,K as u,Et as v,_t as w,W as x,H as y,A as z};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{ownership-recovery-guard-Ce9-C5Sa.mjs → ownership-recovery-guard-CYA5CsiO.mjs}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|