@makaio/framework 1.0.0-dev-1781729394463 → 1.0.0-dev-1781729807808
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.makaio-build.json +2 -2
- package/dist/{account-identity-D5TUafYg.mjs → account-identity-D-9gunfD.mjs} +1 -1
- package/dist/adapter-Cxcqmp04.mjs +1 -0
- package/dist/adapters/config/index.d.mts +1 -1
- package/dist/adapters/config/index.mjs +1 -1
- package/dist/adapters/index.d.mts +2 -2
- package/dist/adapters/index.mjs +1 -1
- package/dist/adapters/node.d.mts +1 -1
- package/dist/adapters/node.mjs +1 -1
- package/dist/adapters/stream-session/index.d.mts +2 -0
- package/dist/await-trigger-Cjfj0yp_.mjs +1 -0
- package/dist/bus/index.d.mts +21 -21
- package/dist/bus/index.mjs +1 -1
- package/dist/canonical-model-C-jhofjd.mjs +1 -0
- package/dist/{client-BO-0jTSV.mjs → client-D24ebgGH.mjs} +1 -1
- package/dist/compression-BPOKUc6y.mjs +1 -0
- 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 +1 -1
- package/dist/contracts/canonical-model/index.d.mts +1 -1
- package/dist/contracts/canonical-model/index.mjs +1 -1
- package/dist/contracts/client/index.d.mts +2 -2
- package/dist/contracts/client/index.mjs +1 -1
- package/dist/contracts/common/index.d.mts +1 -1
- package/dist/contracts/config/index.d.mts +13 -13
- package/dist/contracts/config/index.mjs +1 -1
- package/dist/contracts/extension/index.d.mts +3 -3
- 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 +9913 -206
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/materialization/index.d.mts +3 -3
- package/dist/contracts/materialization/index.mjs +1 -1
- package/dist/contracts/model-registry/index.d.mts +1 -1
- package/dist/contracts/model-registry/index.mjs +1 -1
- package/dist/contracts/native-session-supervisor/index.d.mts +1 -1
- package/dist/contracts/native-session-supervisor/index.mjs +1 -1
- package/dist/contracts/platform/index.d.mts +1 -1
- package/dist/contracts/platform/index.mjs +1 -1
- package/dist/contracts/provider/index.d.mts +2 -2
- package/dist/contracts/session/index.d.mts +2 -2
- package/dist/contracts/session/index.mjs +1 -1
- package/dist/contracts/shared/index.d.mts +1 -2
- 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/toast/index.mjs +1 -1
- package/dist/contracts/variant/index.d.mts +1 -1
- package/dist/contracts/variant/index.mjs +1 -1
- package/dist/{definition-b9jyJqPD.d.mts → definition-CZcVOhXZ.d.mts} +1 -1
- package/dist/{detached-extension-handle-Cx6-0eqg.mjs → detached-extension-handle-BYxNmLfv.mjs} +1 -1
- package/dist/{extension-BJHRahFl.mjs → extension-CTkoi8MV.mjs} +1 -1
- package/dist/{extension-CfL70C5n.mjs → extension-CkU_hqra.mjs} +1 -1
- package/dist/{filesystem-service-Bmyqo6po.mjs → filesystem-service-T8JOIWeP.mjs} +1 -1
- package/dist/git/index.mjs +1 -1
- package/dist/{globby-D4SANVoq.mjs → globby-Bos1vjKj.mjs} +1 -1
- package/dist/{handlers-BAycjV02.mjs → handlers-dnpT_hsm.mjs} +1 -1
- package/dist/{harness-DkUpbsuY.mjs → harness-HEpELa_v.mjs} +1 -1
- package/dist/{index-D9-vOJvZ.d.mts → index-6QvT0ljq.d.mts} +1 -1
- package/dist/{index-BEzRpWsS.d.mts → index-BFW1X6SW.d.mts} +356 -356
- package/dist/{index-DLNRgZPo2.d.mts → index-BQ8H7cvY.d.mts} +1 -1
- package/dist/{index-NkNbYFud.d.mts → index-BZuF4I8O.d.mts} +55 -1
- package/dist/{index-aciWhUWw.d.mts → index-BuaP2Q0b.d.mts} +389 -389
- package/dist/{index-DiifAKRu.d.mts → index-ByRAbcZd.d.mts} +2 -7
- package/dist/{index-CmHdpW0E.d.mts → index-C2XLjebs.d.mts} +4 -4
- package/dist/{index-CZJc-V9L.d.mts → index-CUYDEQvN.d.mts} +4 -4
- package/dist/{index-kwq54nx4.d.mts → index-CkpGuNLe.d.mts} +16 -16
- package/dist/{index-BAQ6QBcU.d.mts → index-Cy75lJ1O.d.mts} +32 -32
- package/dist/{index-mU2lnU7O.d.mts → index-DNmENr9M.d.mts} +6 -6
- package/dist/{index-DTBQOCar.d.mts → index-DUI1W-zN.d.mts} +8 -8
- package/dist/{index-CYHWOXUm.d.mts → index-Dbd0Tgba.d.mts} +2 -2
- package/dist/{index-Dw7ErgWU.d.mts → index-Dn73XrXA.d.mts} +457 -10
- package/dist/{index-D1KPCXBN.d.mts → index-Dpu4e9NK.d.mts} +3 -3
- package/dist/{index-DKNmj2sa.d.mts → index-HiAth5G0.d.mts} +28 -28
- package/dist/{index-DWKCb-eJ.d.mts → index-WWYQEH0q.d.mts} +24 -24
- package/dist/{index-CW_LbXdg.d.mts → index-XcnFGiKL.d.mts} +8 -8
- package/dist/{index-BWIkf5oJ.d.mts → index-cN4DkU5Y2.d.mts} +3 -3
- package/dist/{index-DMz-2ACU.d.mts → index-xeg-bqxO.d.mts} +105 -105
- 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-Ba55od_d.mjs → lib-B-R6VZW0.mjs} +1 -1
- package/dist/{lib-CM_BUxN8.mjs → lib-BwYODPdd.mjs} +1 -1
- package/dist/{load-extensions-DNRIy4zC.d.mts → load-extensions-CQqw0Smr.d.mts} +1 -1
- package/dist/{load-extensions-Cze1RHcG.mjs → load-extensions-D-DyzN4j.mjs} +1 -1
- package/dist/mcp-http-server/index.mjs +2 -2
- package/dist/{namespace-65uwTpbg.d.mts → namespace-B091meTj.d.mts} +6 -6
- package/dist/{namespace-COEUMuHL.d.mts → namespace-BQgZChZl.d.mts} +154 -154
- package/dist/{namespace-3yGm4WF9.d.mts → namespace-Ba1gUpUu.d.mts} +2 -2
- package/dist/{namespace-C-piH3w4.mjs → namespace-BxrHvS5c.mjs} +1 -1
- package/dist/namespace-CH_NWUKW.mjs +1 -0
- package/dist/{namespace-DYJZAGzR.d.mts → namespace-CO3DK1v_.d.mts} +42 -42
- package/dist/{namespace-B95uYmZB.d.mts → namespace-CZgcOQTh.d.mts} +52 -52
- package/dist/{namespace-CTsfVI3H.d.mts → namespace-Daq_-170.d.mts} +6 -6
- package/dist/{native-session-supervisor-7ElwM6Is.mjs → native-session-supervisor-DbrqcFq9.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-Cxk3x8Vs.mjs → orchestrator-shared-yFP8e7d5.mjs} +1 -1
- package/dist/package-DP8lk0-a.mjs +1 -0
- package/dist/{package-MmQvNJ3u.d.mts → package-fwIv7zzj.d.mts} +1 -1
- package/dist/package.json +1 -1
- package/dist/primitive-runtime-Dw6OC8w5.mjs +1 -0
- package/dist/{profile-BMBXUqqh.mjs → profile-r4G32bCH.mjs} +1 -1
- package/dist/{provider-context-DC_eq7es.mjs → provider-context-Ds6GNYnE.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/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 +3 -3
- package/dist/runtime-node/index.mjs +2 -2
- 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-B2bO5Yui.d.mts → schema-DcZifH6p.d.mts} +1 -1
- package/dist/{schema-D6WAI8OL.mjs → schema-atatXwNg.mjs} +1 -1
- package/dist/{schemas-DMMWmWjq.d.mts → schemas-BbFAwUpf.d.mts} +1 -1
- package/dist/{schemas-D4zaFE2p.d.mts → schemas-BqscWIoC.d.mts} +6 -6
- package/dist/{schemas-ByssHRGU2.d.mts → schemas-CTIaU6Rt2.d.mts} +2 -2
- package/dist/{schemas-CscdPqCt.d.mts → schemas-IDGAJ_zv.d.mts} +3 -3
- package/dist/schemas-dNCdjOLB.mjs +1 -0
- package/dist/{schemas-CDBn9MTz.d.mts → schemas-fEoe6H0K.d.mts} +154 -154
- 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 +2 -2
- 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/capability/index.d.mts +1 -1
- package/dist/services/capability/index.mjs +1 -1
- package/dist/services/codebase/index.d.mts +2 -2
- package/dist/services/codebase/namespace.d.mts +1 -1
- package/dist/services/codebase/schemas.d.mts +1 -1
- package/dist/services/compression/index.d.mts +2 -2
- package/dist/services/compression/namespace.d.mts +1 -1
- package/dist/services/compression/schemas.d.mts +1 -1
- package/dist/services/context-rules/index.d.mts +1 -1
- package/dist/services/context-rules/index.mjs +1 -1
- package/dist/services/execution-target/index.d.mts +3 -3
- package/dist/services/execution-target/index.mjs +1 -1
- package/dist/services/execution-target/namespace.d.mts +1 -1
- package/dist/services/execution-target/schemas.d.mts +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.mjs +1 -1
- package/dist/services/git/schemas.mjs +1 -1
- package/dist/services/harness/index.d.mts +6 -6
- package/dist/services/harness/index.mjs +1 -1
- package/dist/services/index.d.mts +150 -150
- package/dist/services/index.mjs +1 -1
- package/dist/services/log-import/browser.d.mts +2 -2
- package/dist/services/log-import/index.d.mts +2 -2
- package/dist/services/log-import/log-import.d.mts +1 -1
- package/dist/services/log-import/log-import.mjs +1 -1
- package/dist/services/log-import/namespace.mjs +1 -1
- package/dist/services/log-import/schemas.mjs +1 -1
- package/dist/services/model-registry/index.d.mts +1 -1
- package/dist/services/model-registry/index.mjs +1 -1
- package/dist/services/preferences/index.d.mts +2 -2
- package/dist/services/preferences/schemas.d.mts +1 -1
- package/dist/services/preferences/storage-namespace.d.mts +2 -2
- package/dist/services/provider-context/index.d.mts +1 -1
- package/dist/services/provider-context/index.mjs +1 -1
- package/dist/services/provider-runtime/index.mjs +1 -1
- package/dist/services/session/handlers/index.d.mts +1 -1
- package/dist/services/session/handlers/index.mjs +1 -1
- package/dist/services/session/index.d.mts +9 -9
- package/dist/services/session/index.mjs +1 -1
- package/dist/services/session/messages/namespace.d.mts +1 -1
- package/dist/services/session/messages/namespace.mjs +1 -1
- package/dist/services/session/orchestrator-testing/index.d.mts +1 -1
- package/dist/services/session/orchestrator-testing/index.mjs +1 -1
- package/dist/services/session/session-events/namespace.d.mts +1 -1
- package/dist/services/session/session-events/namespace.mjs +1 -1
- package/dist/services/session/storage/namespace.d.mts +1 -1
- package/dist/services/session/storage/schema.d.mts +1 -1
- package/dist/services/session/testing/index.mjs +1 -1
- package/dist/services/session/testing/orchestrator-shared.d.mts +1 -1
- package/dist/services/session/testing/orchestrator-shared.mjs +1 -1
- package/dist/services/session/turns/namespace.d.mts +1 -1
- package/dist/services/session/turns/namespace.mjs +1 -1
- package/dist/services/session-editor/index.d.mts +1 -1
- package/dist/services/session-editor/index.mjs +1 -1
- package/dist/services/settings/index.d.mts +3 -3
- package/dist/services/settings/index.mjs +1 -1
- package/dist/services/settings/namespace.d.mts +2 -2
- 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 +6 -6
- 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/{session-Bey-bzcX.mjs → session-DApMcL_0.mjs} +1 -1
- package/dist/{session-0nWT4st6.mjs → session-R-wciAdJ.mjs} +1 -1
- package/dist/{skill-N-ttlp1i.mjs → skill-B_VlGon5.mjs} +1 -1
- package/dist/{src-Ck2sbaDa.mjs → src-6n-8M8EU.mjs} +1 -1
- package/dist/storage/drizzle/client.d.mts +1 -1
- package/dist/storage/drizzle/client.mjs +1 -1
- package/dist/storage/drizzle/index.d.mts +1 -1
- package/dist/storage/drizzle/index.mjs +1 -1
- package/dist/storage/handlers/drizzle/index.d.mts +1 -1
- package/dist/storage/handlers/drizzle/index.mjs +1 -1
- package/dist/storage/handlers/index.d.mts +1 -1
- package/dist/storage/handlers/index.mjs +1 -1
- package/dist/{tool-approval-service-DEQiipxj.mjs → tool-approval-service-DhAqQqev.mjs} +1 -1
- package/dist/tools/index.d.mts +8 -0
- package/dist/tools-DeZIVtxe.mjs +1 -0
- package/dist/{types-BslClRkH.d.mts → types-BB8iIAjZ.d.mts} +1 -1
- package/dist/{types-Cagp7JXb.d.mts → types-CCsvoUTA.d.mts} +254 -255
- package/dist/ui-kernel/index.d.mts +1 -1
- package/dist/ui-kernel/pages/schemas.d.mts +1 -1
- package/dist/{version-DoV_pSzT.mjs → version-SYP_DX4M.mjs} +1 -1
- package/dist/workflow-engine/index.d.mts +29 -35
- 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/workflow-orchestrator.d.mts +1 -3
- package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
- package/dist/{workflow-worker-CojIlB6k.mjs → workflow-worker-DMFhz1q_.mjs} +1 -1
- package/package.json +1 -1
- package/dist/adapter-B5I7Wp4y.mjs +0 -1
- package/dist/await-trigger-DcMVmNW5.mjs +0 -1
- package/dist/canonical-model-BWGkgf3v.mjs +0 -1
- package/dist/compression-DMoeVgKx.mjs +0 -1
- package/dist/contracts/workflow/index.d.mts +0 -3
- package/dist/contracts/workflow/index.mjs +0 -1
- package/dist/index-Cjo24O5I.d.mts +0 -10036
- package/dist/json-value-DtIkQN7g.d.mts +0 -57
- package/dist/loop-gate-handlers-CwU5zAGs.mjs +0 -1
- package/dist/namespace-DibbhCPP.mjs +0 -1
- package/dist/package-rdrXr17q.mjs +0 -1
- package/dist/provider-context-DjSUpHSM.mjs +0 -1
- package/dist/schemas-BWasvfw2.mjs +0 -1
- package/dist/schemas-CE1gbhxu.mjs +0 -1
- package/dist/tools-uAgIrqan.mjs +0 -1
- package/dist/transition-Coowd2dA.d.mts +0 -454
- package/dist/workflow-BCKOJ4UC.mjs +0 -1
- /package/dist/{ajv-B5dPIck0.mjs → ajv-Cx19PP7Q.mjs} +0 -0
- /package/dist/{base-orchestrator-Cw0vpNgB.d.mts → base-orchestrator-BRq4MXa7.d.mts} +0 -0
- /package/dist/{capability-service-XlymTzz1.mjs → capability-service-CHl8rrwb.mjs} +0 -0
- /package/dist/{cleanEnvForAdapter-BooAgM2R.mjs → cleanEnvForAdapter-D32WnVuy.mjs} +0 -0
- /package/dist/{client-CebV_fZc.d.mts → client-D2ZftNb6.d.mts} +0 -0
- /package/dist/{clients-namespace-Bt_VTkEU.d.mts → clients-namespace-CeAB0t06.d.mts} +0 -0
- /package/dist/{config-namespace-CY9leBnE.mjs → config-namespace-DW5KHKPW.mjs} +0 -0
- /package/dist/{config-namespace-DqdFE6zk.d.mts → config-namespace-DloU-hNB.d.mts} +0 -0
- /package/dist/{create-static-mount-DkK28kKW.mjs → create-static-mount-Bi0VpYS8.mjs} +0 -0
- /package/dist/{cross-spawn-CDXy3BjE.mjs → cross-spawn-C58yEvsS.mjs} +0 -0
- /package/dist/{cursor-storage-luQAg7E_.mjs → cursor-storage-CpuT5POU.mjs} +0 -0
- /package/dist/{definition-CuJvtYeG.d.mts → definition-BdxbXbrq.d.mts} +0 -0
- /package/dist/{definition-Cllhr9mi.d.mts → definition-GOb_oOmb.d.mts} +0 -0
- /package/dist/{descriptor-to-package-DdpjpT7n.mjs → descriptor-to-package-D-FNxohm.mjs} +0 -0
- /package/dist/{drizzle-DVTAl7Us.mjs → drizzle-D7dkDEB5.mjs} +0 -0
- /package/dist/{esm-CQG9Pc7n.mjs → esm-CP2zvvlx.mjs} +0 -0
- /package/dist/{event-DguYjV6D.mjs → event-DaXakaHo.mjs} +0 -0
- /package/dist/{execution-target-BR8bLkCR.mjs → execution-target-Da6Vjvba.mjs} +0 -0
- /package/dist/{extension-discovery-CIZn5bkq.d.mts → extension-discovery-Bv5FDtrM.d.mts} +0 -0
- /package/dist/{extension-namespace-v3K0qVry.mjs → extension-namespace-O3sKdnY9.mjs} +0 -0
- /package/dist/{facet-BM4y4aQP.mjs → facet-Q_vgXb23.mjs} +0 -0
- /package/dist/{filesystem-service-Cwp0sWNc.d.mts → filesystem-service-89fN-2Dd.d.mts} +0 -0
- /package/dist/{handler-2bPhRn0u.mjs → handler-BIA3ld4C.mjs} +0 -0
- /package/dist/{host-vY07gek-.mjs → host-DFqmG2qO.mjs} +0 -0
- /package/dist/{identity-BarL3JYI.mjs → identity-CA5MzB19.mjs} +0 -0
- /package/dist/{index-D7Hkmrr3.d.mts → index-BE-yMFTz.d.mts} +0 -0
- /package/dist/{index-Dfi8Rorw.d.mts → index-BUilJdHr.d.mts} +0 -0
- /package/dist/{index-B92mToDo2.d.mts → index-BVhnqzDC2.d.mts} +0 -0
- /package/dist/{index-BvLXySoB2.d.mts → index-BeNVLvtk2.d.mts} +0 -0
- /package/dist/{index-DtwGhFFQ.d.mts → index-BplsE3qw.d.mts} +0 -0
- /package/dist/{index-gAFwNiJT.d.mts → index-BtL_9HBk.d.mts} +0 -0
- /package/dist/{index-CuHqL95P.d.mts → index-CBTp2XuF.d.mts} +0 -0
- /package/dist/{index-DUD7wikz2.d.mts → index-CYZqADXY2.d.mts} +0 -0
- /package/dist/{index-D3ahzHwb.d.mts → index-CfpfkKih.d.mts} +0 -0
- /package/dist/{index-Cr9lh21j.d.mts → index-CkPIPbx9.d.mts} +0 -0
- /package/dist/{index-Y8rMeYYX.d.mts → index-D0RWuwl5.d.mts} +0 -0
- /package/dist/{index-COI1tjAf.d.mts → index-DHHKwLww.d.mts} +0 -0
- /package/dist/{index-C23g_M_J2.d.mts → index-DJSffYTW2.d.mts} +0 -0
- /package/dist/{index-CfIW5biI.d.mts → index-DLPjliGd.d.mts} +0 -0
- /package/dist/{index-OGIC4puQ.d.mts → index-DVgKfgh1.d.mts} +0 -0
- /package/dist/{index-DOOrKin9.d.mts → index-DWqSqcpW.d.mts} +0 -0
- /package/dist/{index-wq7XeqyG.d.mts → index-DdCyeZ59.d.mts} +0 -0
- /package/dist/{index-BjoOSg95.d.mts → index-cFuQpzIm.d.mts} +0 -0
- /package/dist/{index-C4nStEdA.d.mts → index-kOSSuOcK.d.mts} +0 -0
- /package/dist/{index-CpKikwK4.d.mts → index-orAkFukT.d.mts} +0 -0
- /package/dist/{jsonl-transport-CGPgD8iU.mjs → jsonl-transport-Bb8ltqOe.mjs} +0 -0
- /package/dist/{lib-ZKtnbCqH.mjs → lib-BmcGxHXH.mjs} +0 -0
- /package/dist/{materialization-DBXjSiBn.mjs → materialization-DsPIGQP1.mjs} +0 -0
- /package/dist/{model-registry-rYICIwyR.mjs → model-registry-DLeMw3l8.mjs} +0 -0
- /package/dist/{model-registry-C2VXobZj.mjs → model-registry-DQDclqdw.mjs} +0 -0
- /package/dist/{namespace-BsYKEMd8.d.mts → namespace-2G7A4Sza.d.mts} +0 -0
- /package/dist/{namespace-6sIu5nBI2.d.mts → namespace-6u1Uf-iw2.d.mts} +0 -0
- /package/dist/{namespace-KMxsPJwm.d.mts → namespace-B1Bldc48.d.mts} +0 -0
- /package/dist/{namespace-DYSFDC2G.mjs → namespace-CN-Llu7H.mjs} +0 -0
- /package/dist/{namespace-LUNf8zo5.d.mts → namespace-DKnJL0Ja.d.mts} +0 -0
- /package/dist/{namespace-CQ8uza7o.d.mts → namespace-DMhz3yvr.d.mts} +0 -0
- /package/dist/{namespace-Dk4OslmY.d.mts → namespace-DcUwOJ4f.d.mts} +0 -0
- /package/dist/{namespace-BO3tODGC.mjs → namespace-DrpHLJAy.mjs} +0 -0
- /package/dist/{namespace-DBHwyhME.mjs → namespace-FJsnoEQy.mjs} +0 -0
- /package/dist/{namespace-wke7juzy.mjs → namespace-UUw-S7ia.mjs} +0 -0
- /package/dist/{namespace-D2s-4pyg.d.mts → namespace-nQS4XwnT.d.mts} +0 -0
- /package/dist/{namespace-B3ol3pc-.d.mts → namespace-q5dD3acO.d.mts} +0 -0
- /package/dist/{namespace-BdO4e1Fm.mjs → namespace-uGUGfpGQ.mjs} +0 -0
- /package/dist/{namespace-CVMZVqB5.mjs → namespace-zWB-ULrX.mjs} +0 -0
- /package/dist/{orchestrator-shared-ChOdIgh6.d.mts → orchestrator-shared-CbS4ueeq.d.mts} +0 -0
- /package/dist/{out-BoEZjBNz.mjs → out-BUHr98Xe.mjs} +0 -0
- /package/dist/{package-CF_Zm2v4.mjs → package-YQeRE8bV.mjs} +0 -0
- /package/dist/{platform-DnbSvm2u.mjs → platform-CsO-MRJP.mjs} +0 -0
- /package/dist/{providers-Bd7BOZs0.mjs → providers-FEZT2bQG.mjs} +0 -0
- /package/dist/{providers-namespace-5GoTlHXz.d.mts → providers-namespace-B4INLPUc.d.mts} +0 -0
- /package/dist/{quick-lru-6e7I1Bgf.mjs → quick-lru-C7AXdpbU.mjs} +0 -0
- /package/dist/{registry-U_3aYSin.mjs → registry-CwjZvH2s.mjs} +0 -0
- /package/dist/{schema-DHlTAy0N.mjs → schema-Ba64XQjo.mjs} +0 -0
- /package/dist/{schema-introspection-B7xODt4I.mjs → schema-introspection-D5FaI5B_.mjs} +0 -0
- /package/dist/{schemas-CPI00yvh.mjs → schemas-5kegIs9D.mjs} +0 -0
- /package/dist/{schemas-DKncXGnb.d.mts → schemas-9Ifo5zSf.d.mts} +0 -0
- /package/dist/{schemas-ArqQTC0Q.mjs → schemas-9QC3nvYP.mjs} +0 -0
- /package/dist/{schemas-KlH1hB7u.d.mts → schemas-BSAKbVyd.d.mts} +0 -0
- /package/dist/{schemas-DmGRSeIq.d.mts → schemas-BxI5Yq8d.d.mts} +0 -0
- /package/dist/{schemas-BemsLc_V.d.mts → schemas-CRS7tkFP.d.mts} +0 -0
- /package/dist/{schemas-XeIBqwvE.mjs → schemas-DAYPhB5K.mjs} +0 -0
- /package/dist/{schemas-DWfo0wp4.d.mts → schemas-DZfBym73.d.mts} +0 -0
- /package/dist/{schemas-B6tEKf9T.d.mts → schemas-DznsZ0bq.d.mts} +0 -0
- /package/dist/{semver-CIhHqMkw.mjs → semver-ClOD8k8c.mjs} +0 -0
- /package/dist/{server-lifecycle-_AA6EfzL.d.mts → server-lifecycle-5iHxcgBO.d.mts} +0 -0
- /package/dist/{server-lifecycle-C5Z5PSMD.mjs → server-lifecycle-CFQaPTf7.mjs} +0 -0
- /package/dist/{session-lineage-Cht4jbvV.d.mts → session-lineage-D_8W1MI0.d.mts} +0 -0
- /package/dist/{shared-schemas-BEVG96xW.mjs → shared-schemas-jG3EtHZT.mjs} +0 -0
- /package/dist/{src-_VODAJnf.mjs → src-CRDOZl7K.mjs} +0 -0
- /package/dist/{storage-namespace-D5q9CrBp.mjs → storage-namespace-C1JVmZF1.mjs} +0 -0
- /package/dist/{storage-namespace-definition-BffdI5Bz.d.mts → storage-namespace-definition-BPYSLTfN.d.mts} +0 -0
- /package/dist/{storage-namespace-definition-CzXPW45M.mjs → storage-namespace-definition-Df8S3E3r.mjs} +0 -0
- /package/dist/{storage-namespace-Di1A3DMm.d.mts → storage-namespace-gey7EUhM.d.mts} +0 -0
- /package/dist/{supports-color-DcXkvGDF.mjs → supports-color-AnssSSH9.mjs} +0 -0
- /package/dist/{telemetry-Cvi4rxiE.mjs → telemetry-DdbvlZ8s.mjs} +0 -0
- /package/dist/{tray-menu-service-B2AxiQqL.mjs → tray-menu-service-am356993.mjs} +0 -0
- /package/dist/{types-DCvp_swt.d.mts → types-Bj7cOrBQ.d.mts} +0 -0
- /package/dist/{types-CPmOg4X7.d.mts → types-D-GeeSdd.d.mts} +0 -0
- /package/dist/{types-BMS6yfLS.d.mts → types-DhlQpVEb.d.mts} +0 -0
- /package/dist/{types-Bo78h9e3.d.mts → types-xLd-e0wf.d.mts} +0 -0
- /package/dist/{variant-5huHjUTm.mjs → variant-BdNN5edM.mjs} +0 -0
- /package/dist/{window-registry-ofIUQnfo.d.mts → window-registry-CA6AC8n7.d.mts} +0 -0
- /package/dist/{window-registry-PkrFIwX2.mjs → window-registry-LRjWPwr4.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./namespace-
|
|
1
|
+
import{n as e}from"./namespace-BxrHvS5c.mjs";import{MakaioBus as t}from"@makaio/framework/bus";import{AdapterSubjects as n,AgentSubjects as r,SessionSubjects as i}from"@makaio/framework/contracts";function a(){t.__resetHandlers?.()}function o(e=10){return new Promise(t=>setTimeout(t,e))}function s(e,t){let n=Date.now();return{agentId:e,adapterId:`adapter-${e}`,adapterName:`test-adapter`,sessionId:t?.sessionId??`test-session`,role:`member`,status:`idle`,createdAt:n,lastActivityAt:n,...t}}async function c(e,r=e){await t.emit(n.initialized,{adapterName:e,adapterId:r,capabilities:[]})}async function l(n){return(await t.request(e.getEvents,{sessionId:n})).events}function u(e,n,r){let i=[];return r.push(t.on(e,(e=>{let t=e.payload;i.push(n(t))}))),{received:i,clear:()=>{i.length=0}}}function d(e){return u(i.turn.started,e=>({sessionId:e.sessionId,turnId:e.turnId,messageId:e.messageId,agentIds:[...e.agentIds],initiator:e.initiator}),e)}function f(e){return u(i.turn.completed,e=>({sessionId:e.sessionId,turnId:e.turnId,success:e.success,error:e.error,initiator:e.initiator}),e)}function p(e){return u(i.user_message.sent,e=>({sessionId:e.sessionId,turnId:e.turnId,messageId:e.messageId,content:e.content,agentIds:[...e.agentIds],origin:e.origin}),e)}function m(e){return u(i.user_message.acknowledged,e=>({sessionId:e.sessionId,turnId:e.turnId,messageId:e.messageId,agentId:e.agentId}),e)}function h(e){return u(i.user_message.completed,e=>({sessionId:e.sessionId,turnId:e.turnId,messageId:e.messageId,agentId:e.agentId,outcome:e.outcome,error:e.error}),e)}const g=s;function _(e){let t=Date.now();return{sessionId:e.sessionId,createdAt:t,lastActivityAt:t,status:e.status??`active`,agents:e.agents??[],leadAgentId:e.leadAgentId,targetWorkingDirectory:e.targetWorkingDirectory}}function v(e){return t.on(i.create,t=>{let n=t.payload.sessionId??`session-${crypto.randomUUID().slice(0,8)}`;e.set(n,_({sessionId:n,agents:[]})),t.setResult({sessionId:n})})}function y(e){return t.on(i.agent.added,t=>{let n=e.get(t.payload.sessionId);if(!n)return;let r=n.agents.length===0,i=t.payload.role??(r?`lead`:`member`);r&&(n.adapterSessionId=t.payload.adapterSessionId,n.adapterName=t.payload.adapterName,n.adapterId=t.payload.adapterId);let a=Date.now();n.agents.push({agentId:t.payload.agentId,adapterId:t.payload.adapterId,adapterName:t.payload.adapterName,sessionId:t.payload.sessionId,role:i,status:`idle`,createdAt:a,lastActivityAt:a}),i===`lead`&&(n.leadAgentId=t.payload.agentId),n.lastActivityAt=Date.now()})}function b(e){return t.on(i.get,t=>{t.setResult({session:e.get(t.payload.sessionId)??null})})}function x(e){return t.on(n.getAgent,t=>{for(let n of e.values()){let e=n.agents.find(e=>e.agentId===t.payload.agentId);if(e){t.setResult({agent:{agentId:e.agentId,sessionId:n.sessionId,adapterSessionId:``}});return}}t.setResult({agent:null})})}function S(){return t.on(n.rehydrateAgent,e=>{e.setResult({})})}function C(e=`/previous/cwd`){return t.on(r.cwd.change,t=>{t.setResult({success:!0,previousCwd:e})})}function w(){return t.on(r.model.change,e=>{e.setResult({success:!0,swapped:!1})})}function T(e){return t.on(n.startAgent,t=>{let{adapterId:n,initialMessage:r}=t.payload,i=t.payload.sessionId??`session-${crypto.randomUUID().slice(0,8)}`,a=`agent-${crypto.randomUUID().slice(0,8)}`,o=r?`msg-${crypto.randomUUID().slice(0,8)}`:void 0,s=`adapter-session-${i}`;e?.({adapterId:n,sessionId:i,initialMessage:r}),t.setResult({success:!0,agentId:a,adapterId:n,adapterSessionId:s,sessionId:i,...o&&{messageId:o}}),j({sessionId:i,agentId:a,adapterId:n,adapterSessionId:s})})}function E(e){return t.on(n.startAgent,t=>{t.setResult({success:!1,message:e})})}function D(e){return t.on(r.sendMessage,t=>{let{agentId:n,adapterId:r,message:i,messageId:a,sessionContext:o,responseSchema:s}=t.payload,c=a??`msg-${crypto.randomUUID().slice(0,8)}`;e?.({agentId:n,adapterId:r,message:i,messageId:c,sessionContext:o,responseSchema:s}),t.setResult({messageId:c})})}function O(e,n){return t.on(r.sendMessage,t=>{if(e.has(t.payload.agentId))throw Error(n);t.setResult({messageId:t.payload.messageId??`generated-id`})})}async function k(e,n){await t.emit(r.complete,{agentId:e,adapterId:`adapter-${e}`,adapterName:`test-adapter`,adapterSessionId:`adapter-session-${e}`,messageId:n})}async function A(e,n){await t.emit(r.complete,{agentId:e,adapterId:`adapter-${e}`,adapterName:`test-adapter`,adapterSessionId:`adapter-session-${e}`,messageId:`msg-error-${e}`,outcome:`error`,error:n})}function j(e){setImmediate(()=>{t.emit(i.agent.added,{sessionId:e.sessionId,agentId:e.agentId,adapterId:e.adapterId,adapterName:e.adapterId,adapterSessionId:e.adapterSessionId,role:e.role})})}function M(e,r){let i=new Map,a=t.on(n.startAgent,t=>{r.payload=t.payload;let n=`agent-${crypto.randomUUID().slice(0,8)}`,a=t.payload.initialMessage?`msg-${crypto.randomUUID().slice(0,8)}`:void 0,o=`adapter-session-${e}`;i.set(n,{agentId:n,sessionId:e,adapterSessionId:o,adapterId:t.payload.adapterId}),t.setResult({success:!0,agentId:n,adapterId:t.payload.adapterId,adapterSessionId:o,sessionId:e,...a&&{messageId:a}}),j({sessionId:e,agentId:n,adapterId:t.payload.adapterId,adapterSessionId:o})}),o=t.on(n.getAgent,e=>{let t=i.get(e.payload.agentId);e.setResult({agent:t?{agentId:t.agentId,sessionId:t.sessionId,adapterSessionId:t.adapterSessionId}:null})});return()=>{a(),o()}}export{c as C,o as E,p as S,a as T,T as _,A as a,m as b,v as c,E as d,x as f,D as g,S as h,k as i,C as l,w as m,_ as n,y as o,b as p,j as r,M as s,g as t,O as u,f as v,l as w,h as x,d as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,M as f,N as ee,O as te,P as ne,R as re,S as ie,T as ae,U as oe,V as se,W as ce,_ as le,a as ue,b as de,c as fe,f as pe,g as me,h as he,i as ge,j as _e,k as ve,l as ye,m as p,n as be,p as xe,q as Se,s as Ce,t as we,u as Te,v as Ee,w as De,x as m,y as Oe,z as ke}from"./primitive-runtime-Dw6OC8w5.mjs";import{matchesFilter as Ae,matchesSubscription as je}from"@makaio/framework/bus";import{ArtifactSubjects as Me,EXECUTION_LIST_DEFAULT_LIMIT as Ne,EXECUTION_LIST_MAX_LIMIT as h,EXECUTION_LIST_MIN_LIMIT as g,ExecutionHintsSchema as Pe,ExecutionsByArtifactRefsQuerySchema as Fe,JsonPatchOperationSchema as Ie,JsonValueSchema as Le,SessionSubjects as Re,WORKFLOW_CANCELLED_REASON as _,WorkflowError as v,WorkflowErrorCode as ze,WorkflowNamespace as Be,WorkflowSubjects as y,createWorkflowCancelSubject as Ve,dep as He,extensionToken as Ue,serializeArtifactRef as We}from"@makaio/framework/contracts";import{BaseService as Ge}from"@makaio/framework/service-base";import{defineDialectSchema as Ke,executeTransaction as b,getDatabaseDialect as qe,registerDrizzleHandlers as Je,resolveSchema as x}from"@makaio/framework/storage/drizzle";import{and as S,asc as C,count as Ye,desc as w,eq as T,getTableColumns as Xe,gte as Ze,isNotNull as Qe,lt as $e,lte as et,or as tt,sql as E,sum as D}from"drizzle-orm";import{compile as nt}from"@makaio/framework/expression";import*as rt from"node:os";import{SessionToken as it}from"@makaio/framework/services";const at=n.postgres,ot=ee.postgres,st=ae.postgres,ct=a.postgres,lt=ke.postgres,ut=r.postgres,dt=d.postgres,ft=Se.postgres,pt=oe.postgres,mt=se.postgres,ht=o.postgres,gt=ve.postgres,_t=_e.postgres,O=Ke({workflowDefinitions:ie,workflowExecutions:f,workflowExecutionFrames:De,workflowGateInstances:ne,workflowStepSpans:re,workflowExecutionLinks:i,workflowRunContexts:c,worklogSummaries:u,worklogFrameEntries:s,worklogArtifactWrites:t,worklogGateEvents:ce,workflowExecutionState:te,workflowExecutionStateEvents:e},{workflowDefinitions:at,workflowExecutions:ot,workflowExecutionFrames:st,workflowGateInstances:ct,workflowStepSpans:lt,workflowExecutionLinks:ut,workflowRunContexts:dt,worklogSummaries:ft,worklogFrameEntries:pt,worklogArtifactWrites:mt,worklogGateEvents:ht,workflowExecutionState:gt,workflowExecutionStateEvents:_t});function k(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 A(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 vt(e,t){let{scopeType:n,scopeKind:r,scopeId:i}=k(t);return[T(e.scopeType,n),T(e.scopeKind,r),T(e.scopeId,i)]}function j(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:A(e),canvasLayout:e.canvasLayout??void 0,source:e.source??void 0,executionHints:e.executionHints??void 0}}function yt(e,t){let n=k(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,executionHints:e.executionHints??null,createdAt:t,updatedAt:t,...n}}function bt(e,t){let{workflowDefinitions:n}=x(t,O),r=Xe(n),i=e.on(m.get,async e=>{let r=await t.select().from(n).where(T(n.id,e.payload.id)).limit(1);e.setResult({workflow:r[0]?j(r[0]):null})}),a=e.on(m.set,async i=>{let a=i.payload.workflow,o=Date.now(),s=yt(a,o),c=await t.insert(n).values(s).onConflictDoNothing({target:n.id}).returning();if(c.length>0){await e.emit(l.definition.created,j(c[0])),i.setResult({id:a.id});return}let[u]=await t.update(n).set({name:s.name,root:s.root,updatedAt:o,createdAt:E`COALESCE(${r.createdAt}, ${o})`,description:s.description===null?E`${r.description}`:s.description,inputSchema:s.inputSchema===null?E`${r.inputSchema}`:s.inputSchema,configSchema:s.configSchema===null?E`${r.configSchema}`:s.configSchema,outputSchema:s.outputSchema===null?E`${r.outputSchema}`:s.outputSchema,state:s.state,artifact:s.artifact===null?E`${r.artifact}`:s.artifact,triggers:s.triggers===null?E`${r.triggers}`:s.triggers,canvasLayout:s.canvasLayout===null?E`${r.canvasLayout}`:s.canvasLayout,source:s.source===null?E`${r.source}`:s.source,executionHints:s.executionHints===null?E`${r.executionHints}`:s.executionHints,...k(a.scope)}).where(T(n.id,a.id)).returning();u&&await e.emit(l.definition.updated,j(u)),i.setResult({id:a.id})}),o=e.on(m.delete,async r=>{let i=(await t.delete(n).where(T(n.id,r.payload.id)).returning()).length>0;i&&await e.emit(l.definition.deleted,{id:r.payload.id}),r.setResult({deleted:i})}),s=e.on(m.list,async e=>{let r=e.payload,i=r.scope?vt(n,r.scope):[],a=i.length>0?await t.select().from(n).where(S(...i)):await t.select().from(n);e.setResult({workflows:a.map(j)})});return()=>{i(),a(),o(),s()}}function xt(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 St(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 Ct(e,t){let{workflowExecutionFrames:n}=x(t,O),r=e.on(m.setFrame,async e=>{let{executionId:r,frame:i}=e.payload,a=St(r,i);await t.insert(n).values(a).onConflictDoUpdate({target:n.frameId,set:a}),e.setResult({frameId:i.frameId})}),i=e.on(m.getFrame,async e=>{let r=await t.select().from(n).where(T(n.frameId,e.payload.frameId)).limit(1);e.setResult({frame:r[0]?xt(r[0]):null})}),a=e.on(m.listFrames,async e=>{let r=await t.select().from(n).where(T(n.executionId,e.payload.executionId)).orderBy(C(n.startedAt),C(n.frameId));e.setResult({frames:r.map(xt)})});return()=>{r(),i(),a()}}function wt(e){return`${e.executionId}:${e.nodeId}:${e.frameId}`}function M(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 N(e){return{id:wt(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 Tt(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??Ne;if(!Number.isInteger(i)||i<g||i>h)throw Error(`Gate instance list limit must be an integer between ${g} and ${h}.`);return{resolvedLimit:i,predicates:[...e===void 0?[]:[T(r.executionId,e)],...t===void 0?[]:[T(r.status,t)]]}}function Et(e,t){let{workflowExecutions:n,workflowGateInstances:r}=x(t,O),i=e.on(m.setGateInstance,async e=>{let n=e.payload.gate,i=N(n);await t.insert(r).values(i).onConflictDoUpdate({target:r.id,set:i}),e.setResult({id:i.id})}),a=e.on(m.resolveWaitingGateInstance,async e=>{let n=e.payload.gate,i=N(n),a=await t.update(r).set(i).where(S(T(r.id,i.id),T(r.status,`waiting`))).returning({id:r.id});e.setResult({accepted:a.length===1})}),o=e.on(m.getGateInstance,async e=>{let{executionId:n,nodeId:i,frameId:a}=e.payload,o=[T(r.executionId,n),T(r.nodeId,i)];a!==void 0&&o.push(T(r.frameId,a));let s=await t.select().from(r).where(S(...o)).limit(1);e.setResult({gate:s[0]?M(s[0]):null})}),s=e.on(m.listGateInstances,async e=>{let{executionId:n,status:i,limit:a}=e.payload,{resolvedLimit:o,predicates:s}=Tt(n,i,a,r),c=await t.select().from(r).where(S(...s)).orderBy(w(r.createdAt),w(r.id)).limit(o);e.setResult({gates:c.map(M)})}),c=e.on(m.listPausedGateTimeouts,async e=>{let i=await t.select({gate:r}).from(r).innerJoin(n,T(r.executionId,n.id)).where(S(T(r.status,`waiting`),T(n.status,`paused`),Qe(r.timeoutMs)));e.setResult({gates:i.map(e=>M(e.gate))})});return()=>{i(),a(),o(),s(),c()}}function Dt(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 Ot(e){return{sourceExecutionId:e.sourceExecutionId,targetExecutionId:e.targetExecutionId,linkType:e.linkType,metadata:e.metadata??void 0}}function kt(e,t){let{workflowStepSpans:n,workflowExecutionLinks:r}=x(t,O),i=e.on(m.setSpan,async e=>{let{span:r}=e.payload;await t.insert(n).values(r).onConflictDoUpdate({target:[n.executionId,n.frameId],set:r}),e.setResult({id:`${r.executionId}:${r.frameId}`})}),a=e.on(m.listSpans,async e=>{let r=await t.select().from(n).where(T(n.executionId,e.payload.executionId)).orderBy(C(n.startedAt),C(n.stepId),C(n.frameId));e.setResult({spans:r.map(Dt)})}),o=e.on(m.setExecutionLink,async e=>{let{link:n}=e.payload;await t.insert(r).values(n).onConflictDoUpdate({target:[r.sourceExecutionId,r.targetExecutionId],set:n}),e.setResult({id:`${n.sourceExecutionId}:${n.targetExecutionId}`})}),s=e.on(m.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?[]:[T(r.sourceExecutionId,n)],...i===void 0?[]:[T(r.targetExecutionId,i)]],o=t.select().from(r).where(S(...a));e.setResult({links:(await o).map(Ot)})});return()=>{i(),a(),o(),s()}}function At(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 jt(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 Mt(e){return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,source:jt(e),definitionSnapshot:e.definitionSnapshot??void 0,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,...e.artifactRef===null?{}:{artifactRef:e.artifactRef},scope:A(e),...e.executionHints===null?{}:{executionHints:e.executionHints},...e.dispatchMetadata===null?{}:{dispatchMetadata:e.dispatchMetadata},cancelSubject:e.cancelSubject,context:e.context,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy??`wait-in-process`}}function Nt(e){let t=At(e.source),n=k(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,artifactRef:e.artifactRef??null,executionHints:e.executionHints??null,dispatchMetadata:e.dispatchMetadata??null,...n,cancelSubject:e.cancelSubject,context:e.context,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy}}async function Pt(e,t,n){let r=Nt(t);await e.insert(n).values(r).onConflictDoUpdate({target:n.executionId,set:r})}function Ft(e,t){let{workflowRunContexts:n}=x(t,O),r=e.on(m.setRunContext,async e=>{let r=e.payload.runContext;await Pt(t,r,n),e.setResult({executionId:r.executionId})}),i=e.on(m.getRunContext,async e=>{let{executionId:r}=e.payload,i=await t.select().from(n).where(T(n.executionId,r)),a=i[0]?Mt(i[0]):null;e.setResult({runContext:a})});return()=>{r(),i()}}function P(e,t){return t===null?qe(e)===`postgres`?E`'null'::jsonb`:E`'null'`:t}async function It(e,t,n){let{workflowExecutionState:r,workflowExecutionStateEvents:i}=x(e,O),a=Date.now(),o=P(e,n);await b(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 Lt(e,t){let{workflowExecutionState:n}=x(e,O),r=(await e.select().from(n).where(T(n.executionId,t)).limit(1))[0];return r?{executionId:r.executionId,sequence:r.sequence,value:r.value}:null}async function Rt(e,t){let{workflowExecutionState:n,workflowExecutionStateEvents:r}=x(e,O),i=Date.now(),a=P(e,t.nextValue);return b(e,async e=>{let o=(await e.select().from(n).where(T(n.executionId,t.executionId)).limit(1))[0];if(!o)throw Error(`no workflow state for execution ${t.executionId}`);if(t.expectedSequence===void 0)throw Error(`expectedSequence is required to patch workflow state`);let s=o.sequence+1,c=Oe(o.value,t.nextValue);if((await e.update(n).set({sequence:s,value:a,updatedAt:i}).where(S(T(n.executionId,t.executionId),T(n.sequence,t.expectedSequence))).returning()).length===0)throw Error(`state sequence conflict: expected ${String(t.expectedSequence)}, got ${String(o.sequence)}`);return await e.insert(r).values({executionId:t.executionId,sequence:s,patch:c,value:a,createdAt:i}),{executionId:t.executionId,sequence:s,patch:c,value:t.nextValue}})}function zt(e,t){let n=e.on(m.initializeState,async e=>{let{executionId:n,initialValue:r}=e.payload;await It(t,n,r),e.setResult({})}),r=e.on(m.getState,async e=>{let{executionId:n}=e.payload,r=await Lt(t,n);e.setResult({state:r})}),i=e.on(m.patchState,async e=>{let{executionId:n,expectedSequence:r,nextValue:i}=e.payload,a=await Rt(t,{executionId:n,expectedSequence:r,nextValue:i});e.setResult(a)});return()=>{n(),r(),i()}}function Bt(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 F(e,t){let{worklogSummaries:n}=x(e,O);await e.insert(n).values(t).onConflictDoUpdate({target:n.executionId,set:t})}async function I(e,t){let{worklogSummaries:n}=x(e,O),r=await e.select().from(n).where(T(n.executionId,t)).limit(1);return r[0]?Bt(r[0]):null}async function Vt(e,t={}){let{worklogSummaries:n}=x(e,O),{workflowId:r,status:i,limit:a=50,offset:o=0}=t,s=[...r===void 0?[]:[T(n.workflowId,r)],...i===void 0?[]:[T(n.status,i)]],c=s.length>0?S(...s):void 0,[l,u]=await Promise.all([e.select().from(n).where(c).orderBy(w(n.startedAt)).limit(a).offset(o),e.select({count:Ye()}).from(n).where(c)]);return{items:l.map(Bt),total:u[0]?.count??0}}async function L(e,t){let{worklogFrameEntries:n}=x(e,O);await e.insert(n).values(t).onConflictDoUpdate({target:n.frameId,set:t})}async function R(e,t){let{worklogFrameEntries:n}=x(e,O);return(await e.select().from(n).where(T(n.frameId,t)).limit(1))[0]??null}async function Ht(e,t){let{worklogArtifactWrites:n}=x(e,O);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}function Ut(e,t,n,r,i){return`${e}:${t}:${n}:${r}:${i}`}async function z(e,t){let{worklogGateEvents:n}=x(e,O);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}async function Wt(e,t){let{worklogGateEvents:n}=x(e,O);return(await e.select().from(n).where(T(n.id,t)).limit(1))[0]??null}function B(e,t,n){return`${e}:${t}:${n}`}async function Gt(e,t){let{worklogFrameEntries:n}=x(e,O),[r]=await e.select({totalInputTokens:D(n.inputTokens),totalOutputTokens:D(n.outputTokens),totalEstimatedCost:D(n.estimatedCost)}).from(n).where(T(n.executionId,t));return{totalInputTokens:r?.totalInputTokens===null?0:Number(r?.totalInputTokens),totalOutputTokens:r?.totalOutputTokens===null?0:Number(r?.totalOutputTokens),totalEstimatedCost:r?.totalEstimatedCost===null?0:Number(r?.totalEstimatedCost)}}async function Kt(e,t={}){let{worklogSummaries:n}=x(e,O),{workflowId:r,since:i,until:a}=t,o=[...r===void 0?[]:[T(n.workflowId,r)],...i===void 0?[]:[Ze(n.startedAt,i)],...a===void 0?[]:[et(n.startedAt,a)]],s=o.length>0?S(...o):void 0,[c,l]=await Promise.all([e.select({status:n.status,count:Ye()}).from(n).where(s).groupBy(n.status),e.select({totalDurationMs:D(n.durationMs),totalInputTokens:D(n.totalInputTokens),totalOutputTokens:D(n.totalOutputTokens),totalEstimatedCost:D(n.totalEstimatedCost)}).from(n).where(s)]),u={pending:0,running:0,paused: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 qt(e,t,n,r,i){let a=await R(t,n);if(a===null||i===void 0)return null;let o=await e.requestOptional(Me.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 V(e,t){try{await t()}catch(t){console.error(`[WorklogProjection] Write failed (${e}):`,t)}}async function H(e,t){try{await e.emit(l.worklog.changed,{executionId:t})}catch(e){console.error(`[WorklogProjection] worklog.changed emit failed for ${t}:`,e)}}async function Jt(e,t,n){await F(t,{executionId:n.executionId,workflowId:n.workflowId,workflowName:null,status:`running`,startedAt:n.startedAt??Date.now(),completedAt:null,durationMs:null,totalInputTokens:null,totalOutputTokens:null,totalEstimatedCost:null,error:null,failedNodeId:null}),await H(e,n.executionId)}async function Yt(e,t,n){let r=n.completedAt??Date.now(),i=await I(t,n.executionId);await F(t,{executionId:n.executionId,workflowId:i?.workflowId??n.executionId,workflowName:i?.workflowName??null,status:`completed`,startedAt:i?.startedAt??r-n.totalDuration,completedAt:r,durationMs:n.totalDuration,totalInputTokens:i?.totalInputTokens??null,totalOutputTokens:i?.totalOutputTokens??null,totalEstimatedCost:i?.totalEstimatedCost??null,error:null,failedNodeId:null}),await H(e,n.executionId)}async function Xt(e,t,n,r,i,a,o){let s=await I(t,n),c=s?.startedAt??o;await F(t,{executionId:n,workflowId:s?.workflowId??n,workflowName:s?.workflowName??null,status:r,startedAt:c,completedAt:o,durationMs:o-c,totalInputTokens:s?.totalInputTokens??null,totalOutputTokens:s?.totalOutputTokens??null,totalEstimatedCost:s?.totalEstimatedCost??null,error:i,failedNodeId:a}),await H(e,n)}async function Zt(e,t,n){let r=await Gt(t,n);if(r.totalInputTokens>0||r.totalOutputTokens>0||r.totalEstimatedCost>0){let e=await I(t,n);e&&await F(t,{executionId:n,workflowId:e.workflowId,workflowName:e.workflowName??null,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt??null,durationMs:e.durationMs??null,totalInputTokens:r.totalInputTokens,totalOutputTokens:r.totalOutputTokens,totalEstimatedCost:r.totalEstimatedCost,error:e.error??null,failedNodeId:e.failedNodeId??null})}}function Qt(e,t){return[e.on(l.execution.started,async n=>{let{executionId:r}=n.payload;await V(`execution.started[${r}]`,()=>Jt(e,t,n.payload))}),e.on(l.execution.completed,async n=>{let{executionId:r}=n.payload;await V(`execution.completed[${r}]`,()=>Yt(e,t,n.payload))}),e.on(l.execution.failed,async n=>{let{executionId:r,error:i,failedStepId:a}=n.payload,o=n.payload.completedAt??Date.now();await V(`execution.failed[${r}]`,()=>Xt(e,t,r,`failed`,i,a??null,o))}),e.on(l.execution.cancelled,async n=>{let{executionId:r}=n.payload,i=n.payload.completedAt??Date.now();await V(`execution.cancelled[${r}]`,()=>Xt(e,t,r,`cancelled`,null,null,i))})]}function $t(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 en(e,t,n,r,i,a,o){let s=o??Date.now();await L(t,{frameId:r,executionId:n,...$t(await R(t,r),i,a===void 0?null:s-a),status:`completed`,completedAt:s,durationMs:a??null,error:null}),await Zt(e,t,n),await H(e,n)}async function tn(e,t,n,r,i,a,o,s){let c=s??Date.now();await L(t,{frameId:r,executionId:n,...$t(await R(t,r),i,o===void 0?null:c-o),status:`failed`,completedAt:c,durationMs:o??null,error:a}),await H(e,n)}function nn(e,t){return[e.on(l.frame.started,async n=>{let{executionId:r,frameId:i,nodeId:a,nodeType:o,path:s,startedAt:c}=n.payload;await V(`frame.started[${i}]`,async()=>{await L(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 H(e,r)})}),e.on(l.frame.completed,async n=>{let{executionId:r,frameId:i,nodeId:a,duration:o,completedAt:s}=n.payload;await V(`frame.completed[${i}]`,()=>en(e,t,r,i,a,o,s))}),e.on(l.frame.failed,async n=>{let{executionId:r,frameId:i,nodeId:a,error:o,duration:s,completedAt:c}=n.payload;await V(`frame.failed[${i}]`,()=>tn(e,t,r,i,a,o,s,c))})]}const rn={user:`rejected`,timeout:`timed-out`,cancelled:`cancelled`};function an(e,t){return[e.on(l.gate.suspended,async n=>{let{executionId:r,frameId:i,nodeId:a,prompt:o}=n.payload;await V(`gate.suspended[${i}]`,async()=>{await z(t,{id:B(r,a,i),executionId:r,nodeId:a,frameId:i,status:`waiting`,prompt:o??null,openedAt:Date.now(),resolvedAt:null,resumeData:null}),await H(e,r)})}),e.on(l.gate.resumed,async n=>{let{executionId:r,frameId:i,nodeId:a,resumeData:o}=n.payload;await V(`gate.resumed[${i}]`,async()=>{let n=B(r,a,i),s=await Wt(t,n),c=Date.now();await z(t,{id:n,executionId:r,nodeId:a,frameId:i,status:`resumed`,prompt:s?.prompt??null,openedAt:s?.openedAt??c,resolvedAt:c,resumeData:o}),await H(e,r)})}),e.on(l.gate.resolved,async n=>on(n.payload,e,t)),e.on(l.artifact.updated,async n=>{let{executionId:r,frameId:i,artifactRef:a,revision:o}=n.payload;await V(`artifact.updated[${r}:${i}]`,async()=>{let n=await qt(e,t,i,a,o);if(n===null)return;let s=Date.now();await Ht(t,{id:Ut(r,i,a.kind,a.id,s),executionId:r,frameId:i,nodeId:n.nodeId,artifact:n.artifact,revision:o??null,writtenAt:s}),await H(e,r)})})]}async function on(e,t,n){let{executionId:r,frameId:i,stepId:a,source:o}=e;o===`user`&&e.action===`approve`||await V(`gate.resolved[${i}]`,async()=>{let s=B(r,a,i),c=await Wt(n,s),l=Date.now();await z(n,{id:s,executionId:r,nodeId:a,frameId:i,status:o!==`cancelled`&&e.action===`approve`?`resumed`:rn[o],prompt:c?.prompt??null,openedAt:c?.openedAt??l,resolvedAt:l,resumeData:c?.resumeData??null}),await H(t,r)})}function sn(e,t){let n=[...Qt(e,t),...nn(e,t),...an(e,t),e.on(l.worklog.get,async e=>{let{executionId:n}=e.payload,r=await I(t,n);e.setResult({summary:r})}),e.on(l.worklog.list,async e=>{let{workflowId:n,status:r,limit:i,offset:a}=e.payload,o=await Vt(t,{workflowId:n,status:r,limit:i,offset:a});e.setResult(o)}),e.on(l.worklog.stats,async e=>{let{workflowId:n,since:r,until:i}=e.payload,a=await Kt(t,{workflowId:n,since:r,until:i});e.setResult({stats:a})})];return()=>{for(let e of n)e()}}function U(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:A(e)}}function W(e){let t=k(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 cn(e,t,n,r,i,a){let o=[...e?[T(a.workflowId,e)]:[],...n?[T(a.status,n)]:[],...i===void 0?[]:[T(a.artifactKind,i.kind),T(a.artifactId,i.id)]];if(t&&o.push(...vt(a,t)),r){let e=tt($e(a.startedAt,r.startedAt),S(T(a.startedAt,r.startedAt),$e(a.id,r.id)));e&&o.push(e)}return o}async function ln(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}=x(e,O),u=W(t);await b(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(T(o.executionId,n.executionId)).limit(1):[])[0]?.dispatchMetadata;if(await Pt(d,n.dispatchMetadata===void 0&&f!=null?{...n,dispatchMetadata:f}:n,o),r!==void 0){let n=Date.now(),i=P(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 un(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}=x(e,O),a=W(t),o=N(n);await b(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 dn(e,t,n,r){let{workflowExecutions:i,workflowGateInstances:a}=x(e,O);return b(e,async e=>{if((await e.select().from(i).where(T(i.id,t)).limit(1))[0]?.status!==`paused`)return{cancelled:!1,gates:[]};let o=(await e.select().from(a).where(S(T(a.executionId,t),T(a.status,`waiting`)))).map(e=>({...M(e),status:`cancelled`,resolvedAt:n}));await e.update(i).set({status:`cancelled`,completedAt:n,reason:r??null}).where(T(i.id,t));for(let t of o){let n=N(t);await e.update(a).set(n).where(T(a.id,n.id))}return{cancelled:!0,gates:o}})}async function fn(e,t,n,r,i,a){let{workflowExecutions:o}=x(e,O);return b(e,async e=>{if((await e.select({id:o.id}).from(o).where(T(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(T(o.id,t)),!0})}function pn(e,t){let{workflowExecutions:n}=x(t,O),r=e.on(m.getExecution,async e=>{let{executionId:r}=e.payload,i=await t.select().from(n).where(T(n.id,r));e.setResult({execution:i[0]?U(i[0]):null})}),i=e.on(m.setExecution,async e=>{let r=e.payload.execution,i=W(r);await t.insert(n).values(i).onConflictDoUpdate({target:n.id,set:i}),e.setResult({id:r.id})}),a=e.on(m.setExecutionStart,async e=>{let n=e.payload.execution,r=e.payload.runContext;await ln(t,n,r,e.payload.initialState,e.payload.executionLinks),e.setResult({id:n.id,executionId:n.id})}),o=e.on(m.restorePausedGateResumeState,async e=>{let n=e.payload.execution,r=e.payload.gate;await un(t,n,r),e.setResult({executionId:n.id,gateId:r.nodeId})}),s=e.on(m.updateExecution,async e=>{let{executionId:n,status:r,error:i,reason:a,completedAt:o}=e.payload,s=await fn(t,n,r,i,a,o);e.setResult({success:s})}),c=e.on(m.cancelPausedExecution,async e=>{let{executionId:n,completedAt:r,reason:i}=e.payload;e.setResult(await dn(t,n,r,i))});return()=>{r(),i(),a(),o(),s(),c()}}function mn(e,t){let{workflowExecutions:n}=x(t,O),r=e.on(m.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=cn(r,i,a,s,c,n),u=o??Ne;if(!Number.isInteger(u)||u<g||u>h)throw Error(`Execution list limit must be an integer between ${g} and ${h}.`);let d=await t.select().from(n).where(S(...l)).orderBy(w(n.startedAt),w(n.id)).limit(u);e.setResult({executions:d.map(U)})}),i=e.on(m.listExecutionsByArtifactRefs,async e=>{let r=Fe.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(S(T(n.artifactKind,e.kind),T(n.artifactId,e.id))).orderBy(w(n.startedAt),w(n.id)).limit(a);r.length>0&&(o[We(e)]=r.map(U))}e.setResult({executionsByRef:o})});return()=>{r(),i()}}function G(e,t){let n=bt(e,t),r=pn(e,t),i=mn(e,t),a=Ct(e,t),o=Et(e,t),s=kt(e,t),c=Ft(e,t),l=zt(e,t),u=sn(e,t);return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}}function K(e,t){if(e.origin.local)return!0;let n=e.transport?.peer;return n?.authenticated!==!0||n.id!==t?!1:n.kind===`workflow-execution`?!0:n.kind===`e2e`&&n.encrypted===!0}async function hn(e,t){let{runContext:n}=await e.request(m.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(m.get,{id:n.workflowId});return r??void 0}function gn(e){return[e.on(l.getDefinition,async t=>{let n=await e.request(m.get,{id:t.payload.id});t.setResult(n)}),e.on(l.setDefinition,async t=>{let n=await e.request(m.set,{workflow:t.payload.workflow});t.setResult(n)}),e.on(l.deleteDefinition,async t=>{let n=await e.request(m.delete,{id:t.payload.id});t.setResult(n)}),e.on(l.listDefinitions,async t=>{let n=await e.request(m.list,t.payload);t.setResult(n)}),e.on(l.getExecution,async t=>{let n=await e.request(m.getExecution,{executionId:t.payload.executionId});t.setResult(n)}),e.on(l.listExecutions,async t=>{let n=await e.request(m.listExecutions,t.payload);t.setResult(n)}),e.on(l.listExecutionsByArtifactRefs,async t=>{let n=await e.request(m.listExecutionsByArtifactRefs,t.payload);t.setResult(n)}),e.on(l.listSpans,async t=>{let n=await e.request(m.listSpans,{executionId:t.payload.executionId});t.setResult(n)}),e.on(l.listFrames,async t=>{let n=await e.request(m.listFrames,{executionId:t.payload.executionId});t.setResult(n)}),e.on(l.listGateInstances,async t=>{let n=await e.request(m.listGateInstances,t.payload);t.setResult(n)}),e.on(l.setExecutionLink,async t=>{let n=await e.request(m.setExecutionLink,{link:t.payload.link});t.setResult(n)}),e.on(l.listExecutionLinks,async t=>{let n=await e.request(m.listExecutionLinks,t.payload);t.setResult(n)}),e.on(l.getRunContext,async t=>{let{executionId:n}=t.payload;if(!K(t,n))throw Error(`Unauthorized: caller is not permitted to read run context for execution: ${n}`);let{runContext:r}=await e.request(m.getRunContext,{executionId:n});if(!r)throw Error(`Run context not found for execution: ${n}`);t.setResult(r)})]}function _n(e){return[e.on(l.state.get,async t=>{let{executionId:n}=t.payload;if(!K(t,n))throw Error(`Unauthorized: caller is not permitted to read state for execution: ${n}`);let{state:r}=await e.request(m.getState,{executionId:n});if(r===null)throw Error(`no workflow state for execution ${n}`);t.setResult(r)}),e.on(l.state.patch,async t=>{let{executionId:n,expectedSequence:r,patch:i,nextValue:a}=t.payload;if(!K(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 hn(e,n);o!==void 0&&le(o,a,`next`),Ie.array().parse(i);let s=await e.request(m.patchState,{executionId:n,expectedSequence:r,nextValue:a});e.emit(l.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})})]}function vn(e,t){return[e.on(l.listTriggerTypes,e=>{let n=t()?.getAll()??[];e.setResult({triggerTypes:n})})]}async function yn(e,t){let{runContext:n}=await e.bus.request(m.getRunContext,{executionId:t});if(n===null)throw new v(ze.RUN_CONTEXT_NOT_FOUND,`Run context not found for workflow execution '${t}'.`);return n}function bn(e,t){return t===void 0?{mode:e}:{mode:e,reason:t}}async function xn(e,t){let n=await yn(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.executionHints??(t.mode===`snapshot`?n.executionHints:void 0),c=t.scopeOverride??n.scope,l={input:r,config:i,parentSessionId:t.parentSessionId,triggerPayload:a,artifactRef:o,executionHints:s,scopeOverride:c,executionLinks:e=>[{sourceExecutionId:t.executionId,targetExecutionId:e,linkType:`rerun-of`,metadata:bn(t.mode,t.reason)}]};return t.mode===`snapshot`?await Tn(e,n,l):Cn(n)?await En(e,n,l):await Ce(e,n.workflowId,l)}function Sn(e,t){return Cn(e)?t.id:e.workflowId}function Cn(e){return e.source.kind!==`definition`&&e.workflowId===e.executionId}function wn(e){let t=e.definitionSnapshot;if(t===void 0)throw new v(ze.SNAPSHOT_UNAVAILABLE,`Workflow execution '${e.executionId}' does not have a definition snapshot.`);return t}async function Tn(e,t,n){let r=wn(t);return ye(e,Sn(t,r),{workflow:r,executionSource:t.source,definitionSnapshot:r,input:n.input,config:n.config,parentSessionId:n.parentSessionId,triggerPayload:n.triggerPayload,artifactRef:n.artifactRef,executionHints:n.executionHints,scopeOverride:n.scopeOverride,executionLinks:n.executionLinks})}async function En(e,t,n){if(t.definitionSnapshot===void 0&&t.source.kind===`path`)return fe(e,t.source.path,n);let r=wn(t);return ye(e,r.id,{workflow:r,executionSource:t.source,input:n.input,config:n.config,parentSessionId:n.parentSessionId,triggerPayload:n.triggerPayload,artifactRef:n.artifactRef,executionHints:n.executionHints,scopeOverride:n.scopeOverride,executionLinks:n.executionLinks})}var Dn=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(m.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(m.getExecution,{executionId:e.executionId});return n?.status===`running`?`retry`:n?.status===`paused`?(await this.resumePausedExecution(e.executionId),`resumed`):`settled`}};function On(e){if(e!==void 0)return kn(e)?e:{}}function kn(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function An(e){if(e!==void 0)return Le.parse(e)}function jn(e){if(e!==void 0)return Pe.parse(e)}function Mn(e,t){return{repoPath:t,makaioHome:e.makaioHome??process.env.MAKAIO_HOME??`${rt.homedir()}/.makaio`,os:xe(process.platform),arch:process.arch}}function Nn(e,t){return{executionId:e.executionId,workflowId:e.workflowId,source:e.source,...e.definitionSnapshot===void 0?{}:{definitionSnapshot:e.definitionSnapshot},workerManifest:{packages:[]},inputs:e.inputs,config:e.config,scope:e.scope,triggerPayload:e.triggerPayload,...e.artifactRef===void 0?{}:{artifactRef:e.artifactRef},...e.executionHints===void 0?{}:{executionHints:e.executionHints},coordinatorSessionId:e.coordinatorSessionId,cancelSubject:`workflow.${e.executionId}.cancel`,context:Mn(t,e.workspaceRoot),env:t.platformDefaults.env??{},createdAt:Date.now(),suspensionStrategy:e.suspensionStrategy??`wait-in-process`}}function Pn(e){return e?.status===`paused`}function Fn(e){return e?.status===`waiting`}async function In(e,t,n,r,i,a,o){t.delete(i.id),n.delete(i.id),r.delete(i.id);try{await e.request(m.restorePausedGateResumeState,{execution:i,gate:a})}catch(e){console.error(`[WorkflowExecutor] Failed to restore paused gate '${o}' after resume launch failure:`,e)}}async function Ln(e,t){if(t.suspensionStrategy===`wait-in-process`)return;let{frames:n}=await e.request(m.listFrames,{executionId:t.executionId});if(n.length===0)throw Error(`[WorkflowExecutor] Missing resume frames for paused execution: ${t.executionId}`)}function Rn(e){return{executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,timeoutMs:e.timeoutMs,openedAt:e.createdAt}}async function zn(e,t){if(t.frameId!==void 0){let{gate:n}=await e.request(m.getGateInstance,t);return Fn(n)?n:null}let{gates:n}=await e.request(m.listGateInstances,{executionId:t.executionId}),r=n.filter(e=>e.nodeId===t.nodeId&&e.status===`waiting`);return r.length===1?r[0]:null}var Bn=class extends Ge{static storage={drizzle:G};config;activeExecutions=new Map;executionTasks=new Map;shellAbortControllers=new Map;activeRunnerSteps=new Map;gateTimeoutScheduler;resumeDispatches=new Set;workflowAbortControllers=new Map;workflowRunner;triggerTypeRegistry;constructor(e,t,n){super(e),this.config={...Ee,...t},this.workflowRunner=n,this.gateTimeoutScheduler=new Dn(e,e=>this.resumePausedExecution(e))}setTriggerTypeRegistry(e){this.triggerTypeRegistry=e}getTriggerTypeRegistry(){return this.triggerTypeRegistry}async onInit(){this.registerExecutionHandlers();for(let e of gn(this.bus))this.addCleanup(e);for(let e of _n(this.bus))this.addCleanup(e);for(let e of vn(this.bus,()=>this.triggerTypeRegistry))this.addCleanup(e);await this.rehydratePausedGateTimeouts()}async onDestroy(){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());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(){return{bus:this.bus,activeExecutions:this.activeExecutions,shellAbortControllers:this.shellAbortControllers,activeRunnerSteps:this.activeRunnerSteps,cancelTimeoutMs:this.config.cancelTimeoutMs}}buildRunnerTaskDeps(e){return{workflowRunner:e,workflowAbortControllers:this.workflowAbortControllers,executionTasks:this.executionTasks,activeExecutions:this.activeExecutions,buildFinalizerDeps:()=>this.buildFinalizerDeps(),resolveWorkflowContext:e=>Mn(this.config,e),config:this.config}}async resolveExecutionWorkspaceRoot(e){if(!e)return this.config.platformDefaults.cwd;let{session:t}=await this.bus.request(Re.get,{sessionId:e});return t?.targetWorkingDirectory??this.config.platformDefaults.cwd}buildStartDeps(){return{bus:this.bus,config:this.config,activeExecutions:this.activeExecutions,executionTasks:this.executionTasks,workflowRunner:this.workflowRunner,buildRunContext:e=>Nn(e,this.config),buildRunnerTaskDeps:e=>this.buildRunnerTaskDeps(e),buildFinalizerDeps:()=>this.buildFinalizerDeps(),resolveExecutionWorkspaceRoot:e=>this.resolveExecutionWorkspaceRoot(e),runExecution:e=>this.runExecution(e)}}registerExecutionHandlers(){this.registerHandler(l.start,async e=>{let{workflowId:t,input:n,config:r,parentSessionId:i,triggerPayload:a,artifactRef:o,scope:s,executionHints:c}=e.payload;try{let l=await Ce(this.buildStartDeps(),t,{input:An(n),config:On(r)??{},parentSessionId:i,triggerPayload:a,artifactRef:o,executionHints:jn(c),scopeOverride:s});e.setResult({executionId:l})}catch(e){if(e instanceof v)throw e;let t=e instanceof Error?e.message:String(e);throw Error(`Failed to start workflow: ${t}`)}}),this.registerHandler(l.rerun,async e=>{let{executionId:t,mode:n,input:r,config:i,parentSessionId:a,triggerPayload:o,artifactRef:s,scope:c,executionHints:l,reason:u}=e.payload;try{let d=await xn(this.buildStartDeps(),{executionId:t,mode:n,input:An(r),config:On(i),parentSessionId:a,triggerPayload:o,artifactRef:s,executionHints:jn(l),scopeOverride:c,reason:u});e.setResult({executionId:d})}catch(e){if(e instanceof v)throw e;let t=e instanceof Error?e.message:String(e);throw Error(`Failed to rerun workflow: ${t}`)}}),this.registerHandler(l.runFile,async e=>{if(this.workflowRunner===void 0)throw Error(`workflow.runFile requires a workflow runner — configure a ThinWorkflowPiscinaRunner or equivalent.`);let{filePath:t,triggerPayload:n,scope:r}=e.payload;try{let i=await fe(this.buildStartDeps(),t,{triggerPayload:n,scopeOverride:r});e.setResult({executionId:i})}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to start workflow file: ${t}`)}}),this.registerHandler(l.cancel,async e=>{let{executionId:t,reason:n}=e.payload;await this.bus.emit(Ve(`workflow.${t}.cancel`),{executionId:t,reason:n}).catch(e=>{console.error(`[WorkflowExecutor] Failed to emit workflow cancel for ${t}:`,e)});let r=this.workflowAbortControllers.get(t);if(r){r.abort(n??_);let i=await p(this.buildFinalizerDeps(),t,n);e.setResult({cancelled:i});return}let i=await p(this.buildFinalizerDeps(),t,n);e.setResult({cancelled:i})}),this.registerGateTimeoutHandlers(),this.addCleanup(this.bus.on(l.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(l.gate.suspended,e=>{this.gateTimeoutScheduler.schedule(e.payload)})),this.addCleanup(this.bus.on(l.gate.resolved,e=>{this.gateTimeoutScheduler.clear(e.payload.executionId,e.payload.stepId,e.payload.frameId)}))}async rehydratePausedGateTimeouts(){let{gates:e}=await this.bus.request(m.listPausedGateTimeouts,{});for(let t of e)this.gateTimeoutScheduler.schedule(Rn(t))}async runExecution(e){let t=this.activeExecutions.get(e);if(!t)return;let n=new AbortController;this.workflowAbortControllers.set(e,n);try{let r;try{let i=await ge({definition:t.workflow,execution:t.execution,runContext:t.runContext,bus:this.bus}),a=new ue(e,t.workflow.id,t.workflow,t.execution,t.runtimeHandlers,this.bus,n.signal,void 0,i,{context:t.runContext.context,env:t.runContext.env}),o=a.buildExpressionContext();r=await we(t.workflow.root,a,o)}catch(r){if(n.signal.aborted||t.execution.status===`cancelled`){await p(this.buildFinalizerDeps(),e,_);return}let i=r instanceof Error?r.message:String(r);await he(this.buildFinalizerDeps(),t.execution,e,i);return}let i=this.buildFinalizerDeps();r.status===`cancelled`||n.signal.aborted||t.execution.status===`cancelled`?await p(i,e,_):r.status===`failed`?await he(i,t.execution,e,r.error):r.status===`paused`?(t.execution.status=`paused`,await this.bus.request(m.setExecution,{execution:t.execution}),this.activeExecutions.delete(e)):await me(i,t.execution,e,t.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(m.getExecution,{executionId:t});if(!Pn(o))return!1;let s=await zn(this.bus,{executionId:t,nodeId:n,frameId:r});if(s===null||!be(n,s.schema,i).valid)return!1;let{runContext:c}=await this.bus.request(m.getRunContext,{executionId:t});if(c===null)throw Error(`[WorkflowExecutor] Run context not found for paused execution: ${t}`);await Ln(this.bus,c);let{accepted:l}=await this.bus.request(m.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 In(this.bus,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(m.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(m.get,{id:t.workflowId})).workflow??(()=>{throw Error(`[WorkflowExecutor] Workflow definition not found for paused execution: ${e}`)})(),{execution:r}=await this.bus.request(m.getExecution,{executionId:e});if(r===null)throw Error(`[WorkflowExecutor] Execution not found for paused execution: ${e}`);if(r.status!==`paused`)return!1;await Ln(this.bus,t),await this.bus.request(m.setExecution,{execution:{...r,status:`running`}}),this.activeExecutions.set(e,{execution:{...r,status:`running`},workflow:n,runContext:t,runtimeHandlers:new Map});let i=pe(t,n,{resume:!0}),a=Te(this.buildStartDeps(),i).finally(()=>{this.resumeDispatches.delete(e)});return this.executionTasks.set(e,a),!0}};function Vn(e,t){try{return nt(e)}catch(n){console.error(`[BusEventTriggerEvaluator] Invalid trigger.filterExpression for workflow "${t}": "${e}"`,n);return}}function Hn(e){let t=e.indexOf(`.`),n=e.indexOf(`:`),r=t===-1?n:n===-1?t:Math.min(t,n);return r===-1?e:e.slice(0,r)}function Un(e){return{subject:`*`,$meta:{namespace:e,isRequest:!1}}}var Wn=class{bus;cleanupFns=[];initialized=!1;triggerIndex=new Map;subscribedNamespaces=new Set;constructor(e){this.bus=e}async init(){if(!this.initialized)try{this.cleanupFns.push(this.bus.on(y.definition.created,e=>{this.indexWorkflow(e.payload)}),this.bus.on(y.definition.updated,e=>{this.removeWorkflow(e.payload.id),this.indexWorkflow(e.payload)}),this.bus.on(y.definition.deleted,e=>{this.removeWorkflow(e.payload.id)})),await this.loadExistingTriggers(),this.initialized=!0}catch(e){throw this.cleanupFns.forEach(e=>e()),this.cleanupFns.length=0,this.triggerIndex.clear(),this.subscribedNamespaces.clear(),e}}destroy(){this.initialized&&=(this.cleanupFns.forEach(e=>e()),this.cleanupFns.length=0,this.triggerIndex.clear(),this.subscribedNamespaces.clear(),!1)}getTestState(){return{initialized:this.initialized,cleanupFns:[...this.cleanupFns],subscribedNamespaces:new Set(this.subscribedNamespaces)}}async loadExistingTriggers(){let{workflows:e}=await this.bus.request(m.list,{});for(let t of e)this.indexWorkflow(t)}indexWorkflow(e){let t=e.triggers??[],n=[];for(let r of t){if(r.type!==`bus-event`)continue;let t=typeof r.filterExpression==`string`?Vn(r.filterExpression,e.id):void 0;typeof r.filterExpression==`string`&&t===void 0||(n.push({workflowId:e.id,subject:r.subject,filter:r.filter,compiledFilterExpr:t}),this.ensureNamespaceSubscribed(Hn(r.subject)))}n.length>0&&this.triggerIndex.set(e.id,n)}removeWorkflow(e){this.triggerIndex.delete(e)}ensureNamespaceSubscribed(e){if(this.subscribedNamespaces.has(e))return;let t=Un(e),n=this.bus.on(t,e=>{if(e.isRequest)return;let t=typeof e.payload==`object`&&e.payload!==null?e.payload:{};this.handleBusEvent(e.subject,t)});this.cleanupFns.push(n),this.subscribedNamespaces.add(e)}handleBusEvent(e,t){for(let n of this.triggerIndex.values())for(let r of n)if(je(e,r.subject)&&!(r.filter&&!Ae(t,r.filter))){if(r.compiledFilterExpr){let n;try{n=r.compiledFilterExpr.evalSync({payload:t})}catch(n){console.error(`[BusEventTriggerEvaluator] filterExpression eval failed for workflow "${r.workflowId}" on subject "${e}" payload keys: [${Object.keys(t).join(`, `)}]`,n);continue}if(!n)continue}this.bus.request(y.start,{workflowId:r.workflowId,triggerPayload:t}).catch(t=>{console.error(`[BusEventTriggerEvaluator] Failed to start workflow "${r.workflowId}" triggered by "${e}":`,t)})}}};function q(e,t,n,r,i,a,o,s){return q.fromTZ(q.tp(e,t,n,r,i,a,o),s)}q.fromTZISO=(e,t,n)=>q.fromTZ(Gn(e,t),n),q.fromTZ=function(e,t){let n=new Date(Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)),r=J(e.tz,n),i=new Date(n.getTime()-r),a=J(e.tz,i);if(a-r===0)return i;{let r=new Date(n.getTime()-a),o=J(e.tz,r);if(o-a===0||!t&&o-a>0)return r;if(t)throw Error(`Invalid date passed to fromTZ()`);return i}},q.toTZ=function(e,t){let n=e.toLocaleString(`en-US`,{timeZone:t}).replace(/[\u202f]/,` `),r=new Date(n);return{y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate(),h:r.getHours(),i:r.getMinutes(),s:r.getSeconds(),tz:t}},q.tp=(e,t,n,r,i,a,o)=>({y:e,m:t,d:n,h:r,i,s:a,tz:o});function J(e,t=new Date){let n=t.toLocaleString(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).split(` `).slice(-1)[0],r=t.toLocaleString(`en-US`).replace(/[\u202f]/,` `);return Date.parse(`${r} GMT`)-Date.parse(`${r} ${n}`)}function Gn(e,t){let n=new Date(Date.parse(e));if(isNaN(n))throw Error(`minitz: Invalid ISO8601 passed to parser.`);let r=e.substring(9);return e.includes(`Z`)||r.includes(`-`)||r.includes(`+`)?q.tp(n.getUTCFullYear(),n.getUTCMonth()+1,n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),`Etc/UTC`):q.tp(n.getFullYear(),n.getMonth()+1,n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),t)}q.minitz=q;var Kn=32,Y=31|Kn,qn=[1,2,4,8,16],Jn=class{pattern;timezone;second;minute;hour;day;month;dayOfWeek;lastDayOfMonth;starDOM;starDOW;constructor(e,t){this.pattern=e,this.timezone=t,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.lastDayOfMonth=!1,this.starDOM=!1,this.starDOW=!1,this.parse()}parse(){if(!(typeof this.pattern==`string`||this.pattern instanceof String))throw TypeError(`CronPattern: Pattern has to be of type string.`);this.pattern.indexOf(`@`)>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.replace(/\s+/g,` `).split(` `);if(e.length<5||e.length>6)throw TypeError(`CronPattern: invalid configuration format ('`+this.pattern+`'), exactly five or six space separated parts are required.`);if(e.length===5&&e.unshift(`0`),e[3].indexOf(`L`)>=0&&(e[3]=e[3].replace(`L`,``),this.lastDayOfMonth=!0),e[3]==`*`&&(this.starDOM=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.replaceAlphaDays(e[5])),e[5]==`*`&&(this.starDOW=!0),this.pattern.indexOf(`?`)>=0){let t=new Z(new Date,this.timezone).getDate(!0);e[0]=e[0].replace(`?`,t.getSeconds().toString()),e[1]=e[1].replace(`?`,t.getMinutes().toString()),e[2]=e[2].replace(`?`,t.getHours().toString()),this.starDOM||(e[3]=e[3].replace(`?`,t.getDate().toString())),e[4]=e[4].replace(`?`,(t.getMonth()+1).toString()),this.starDOW||(e[5]=e[5].replace(`?`,t.getDay().toString()))}this.throwAtIllegalCharacters(e),this.partToArray(`second`,e[0],0,1),this.partToArray(`minute`,e[1],0,1),this.partToArray(`hour`,e[2],0,1),this.partToArray(`day`,e[3],-1,1),this.partToArray(`month`,e[4],-1,1),this.partToArray(`dayOfWeek`,e[5],0,Y),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,n,r){let i=this[e],a=e===`day`&&this.lastDayOfMonth;if(t===``&&!a)throw TypeError(`CronPattern: configuration entry `+e+` (`+t+`) is empty, check for trailing spaces.`);if(t===`*`)return i.fill(r);let o=t.split(`,`);if(o.length>1)for(let t=0;t<o.length;t++)this.partToArray(e,o[t],n,r);else t.indexOf(`-`)!==-1&&t.indexOf(`/`)!==-1?this.handleRangeWithStepping(t,e,n,r):t.indexOf(`-`)===-1?t.indexOf(`/`)===-1?t!==``&&this.handleNumber(t,e,n,r):this.handleStepping(t,e,n,r):this.handleRange(t,e,n,r)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(e[t]))throw TypeError(`CronPattern: configuration entry `+t+` (`+e[t]+`) contains illegal characters.`)}handleNumber(e,t,n,r){let i=this.extractNth(e,t),a=parseInt(i[0],10)+n;if(isNaN(a))throw TypeError(`CronPattern: `+t+` is not a number: '`+e+`'`);this.setPart(t,a,i[1]||r)}setPart(e,t,n){if(!Object.prototype.hasOwnProperty.call(this,e))throw TypeError(`CronPattern: Invalid part specified: `+e);if(e===`dayOfWeek`){if(t===7&&(t=0),t<0||t>6)throw RangeError(`CronPattern: Invalid value for dayOfWeek: `+t);this.setNthWeekdayOfMonth(t,n);return}if(e===`second`||e===`minute`){if(t<0||t>=60)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`hour`){if(t<0||t>=24)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`day`){if(t<0||t>=31)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`month`&&(t<0||t>=12))throw RangeError(`CronPattern: Invalid value for `+e+`: `+t);this[e][t]=n}handleRangeWithStepping(e,t,n,r){let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw TypeError(`CronPattern: Syntax error, illegal range with stepping: '`+e+`'`);let[,o,s,c]=a,l=parseInt(o,10)+n,u=parseInt(s,10)+n,d=parseInt(c,10);if(isNaN(l))throw TypeError(`CronPattern: Syntax error, illegal lower range (NaN)`);if(isNaN(u))throw TypeError(`CronPattern: Syntax error, illegal upper range (NaN)`);if(isNaN(d))throw TypeError(`CronPattern: Syntax error, illegal stepping: (NaN)`);if(d===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(d>this[t].length)throw TypeError(`CronPattern: Syntax error, steps cannot be greater than maximum value of part (`+this[t].length+`)`);if(l>u)throw TypeError(`CronPattern: From value is larger than to value: '`+e+`'`);for(let e=l;e<=u;e+=d)this.setPart(t,e,i[1]||r)}extractNth(e,t){let n=e,r;if(n.includes(`#`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: nth (#) only allowed in day-of-week field`);r=n.split(`#`)[1],n=n.split(`#`)[0]}return[n,r]}handleRange(e,t,n,r){let i=this.extractNth(e,t),a=i[0].split(`-`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal range: '`+e+`'`);let o=parseInt(a[0],10)+n,s=parseInt(a[1],10)+n;if(isNaN(o))throw TypeError(`CronPattern: Syntax error, illegal lower range (NaN)`);if(isNaN(s))throw TypeError(`CronPattern: Syntax error, illegal upper range (NaN)`);if(o>s)throw TypeError(`CronPattern: From value is larger than to value: '`+e+`'`);for(let e=o;e<=s;e++)this.setPart(t,e,i[1]||r)}handleStepping(e,t,n,r){let i=this.extractNth(e,t),a=i[0].split(`/`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal stepping: '`+e+`'`);a[0]===``&&(a[0]=`*`);let o=0;a[0]!==`*`&&(o=parseInt(a[0],10)+n);let s=parseInt(a[1],10);if(isNaN(s))throw TypeError(`CronPattern: Syntax error, illegal stepping: (NaN)`);if(s===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(s>this[t].length)throw TypeError(`CronPattern: Syntax error, max steps for part is (`+this[t].length+`)`);for(let e=o;e<this[t].length;e+=s)this.setPart(t,e,i[1]||r)}replaceAlphaDays(e){return e.replace(/-sun/gi,`-7`).replace(/sun/gi,`0`).replace(/mon/gi,`1`).replace(/tue/gi,`2`).replace(/wed/gi,`3`).replace(/thu/gi,`4`).replace(/fri/gi,`5`).replace(/sat/gi,`6`)}replaceAlphaMonths(e){return e.replace(/jan/gi,`1`).replace(/feb/gi,`2`).replace(/mar/gi,`3`).replace(/apr/gi,`4`).replace(/may/gi,`5`).replace(/jun/gi,`6`).replace(/jul/gi,`7`).replace(/aug/gi,`8`).replace(/sep/gi,`9`).replace(/oct/gi,`10`).replace(/nov/gi,`11`).replace(/dec/gi,`12`)}handleNicknames(e){let t=e.trim().toLowerCase();return t===`@yearly`||t===`@annually`?`0 0 1 1 *`:t===`@monthly`?`0 0 1 * *`:t===`@weekly`?`0 0 * * 0`:t===`@daily`?`0 0 * * *`:t===`@hourly`?`0 * * * *`:e}setNthWeekdayOfMonth(e,t){if(typeof t!=`number`&&t===`L`)this.dayOfWeek[e]=this.dayOfWeek[e]|Kn;else if(t===Y)this.dayOfWeek[e]=Y;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|qn[t-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}},Yn=[31,28,31,30,31,30,31,31,30,31,30,31],X=[[`month`,`year`,0],[`day`,`month`,-1],[`hour`,`day`,0],[`minute`,`hour`,0],[`second`,`minute`,0]],Z=class e{tz;ms;second;minute;hour;day;month;year;constructor(t,n){if(this.tz=n,t&&t instanceof Date)if(!isNaN(t))this.fromDate(t);else throw TypeError(`CronDate: Invalid date passed to CronDate constructor`);else if(t===void 0)this.fromDate(new Date);else if(t&&typeof t==`string`)this.fromString(t);else if(t instanceof e)this.fromCronDate(t);else throw TypeError(`CronDate: Invalid type (`+typeof t+`) passed to CronDate constructor`)}isNthWeekdayOfMonth(e,t,n,r){let i=new Date(Date.UTC(e,t,n)).getUTCDay(),a=0;for(let r=1;r<=n;r++)new Date(Date.UTC(e,t,r)).getUTCDay()===i&&a++;if(r&Y&&qn[a-1]&r)return!0;if(r&Kn){let r=new Date(Date.UTC(e,t+1,0)).getUTCDate();for(let a=n+1;a<=r;a++)if(new Date(Date.UTC(e,t,a)).getUTCDay()===i)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz==`number`)this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else{let t=q.toTZ(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.day>Yn[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz==`number`){let t=q.fromTZISO(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(q.fromTZISO(e,this.tz))}findNext(e,t,n,r){let i=this[t],a;n.lastDayOfMonth&&(a=this.month===1?new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate():Yn[this.month]);let o=!n.starDOW&&t==`day`?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let s=this[t]+r;s<n[t].length;s++){let c=n[t][s];if(t===`day`&&n.lastDayOfMonth&&s-r==a&&(c=1),t===`day`&&!n.starDOW){let t=n.dayOfWeek[(o+(s-r-1))%7];if(t&&t&Y)t=+!!this.isNthWeekdayOfMonth(this.year,this.month,s-r,t);else if(t)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);e.legacyMode&&!n.starDOM?c||=t:c&&=t}if(c)return this[t]=s-r,i===this[t]?1:2}return 3}recurse(e,t,n){let r=this.findNext(t,X[n][0],e,X[n][2]);if(r>1){let i=n+1;for(;i<X.length;)this[X[i][0]]=-X[i][2],i++;if(r===3)return this[X[n][1]]++,this[X[n][0]]=-X[n][2],this.apply(),this.recurse(e,t,0);if(this.apply())return this.recurse(e,t,n-1)}return n+=1,n>=X.length?this:this.year>=3e3?null:this.recurse(e,t,n)}increment(e,t,n){return this.second+=t.interval!==void 0&&t.interval>1&&n?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz==`number`?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):q.fromTZ(q.tp(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}};function Xn(e){if(e===void 0&&(e={}),delete e.name,e.legacyMode=e.legacyMode===void 0?!0:e.legacyMode,e.paused=e.paused===void 0?!1:e.paused,e.maxRuns=e.maxRuns===void 0?1/0:e.maxRuns,e.catch=e.catch===void 0?!1:e.catch,e.interval=e.interval===void 0?0:parseInt(e.interval.toString(),10),e.utcOffset=e.utcOffset===void 0?void 0:parseInt(e.utcOffset.toString(),10),e.unref=e.unref===void 0?!1:e.unref,e.startAt&&=new Z(e.startAt,e.timezone),e.stopAt&&=new Z(e.stopAt,e.timezone),e.interval!==null){if(isNaN(e.interval))throw Error(`CronOptions: Supplied value for interval is not a number`);if(e.interval<0)throw Error(`CronOptions: Supplied value for interval can not be negative`)}if(e.utcOffset!==void 0){if(isNaN(e.utcOffset))throw Error(`CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.`);if(e.utcOffset<-870||e.utcOffset>870)throw Error(`CronOptions: utcOffset out of bounds.`);if(e.utcOffset!==void 0&&e.timezone)throw Error(`CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.`)}if(e.unref!==!0&&e.unref!==!1)throw Error(`CronOptions: Unref should be either true, false or undefined(false).`);return e}function Q(e){return Object.prototype.toString.call(e)===`[object Function]`||typeof e==`function`||e instanceof Function}function Zn(e){return Q(e)}function Qn(e){typeof Deno<`u`&&typeof Deno.unrefTimer<`u`?Deno.unrefTimer(e):e&&typeof e.unref<`u`&&e.unref()}var $n=30*1e3,$=[],er=class{name;options;_states;fn;constructor(e,t,n){let r,i;if(Q(t))i=t;else if(typeof t==`object`)r=t;else if(t!==void 0)throw Error(`Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).`);if(Q(n))i=n;else if(typeof n==`object`)r=n;else if(n!==void 0)throw Error(`Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).`);if(this.name=r?.name,this.options=Xn(r),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:r?r.maxRuns:void 0,paused:r?r.paused:!1,pattern:new Jn(`* * * * *`)},e&&(e instanceof Date||typeof e==`string`&&e.indexOf(`:`)>0)?this._states.once=new Z(e,this.options.timezone||this.options.utcOffset):this._states.pattern=new Jn(e,this.options.timezone),this.name){if($.find(e=>e.name===this.name))throw Error(`Cron: Tried to initialize new named job '`+this.name+`', but name already taken.`);$.push(this)}return i!==void 0&&Zn(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?t.getDate(!1):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let n=[],r=t||this._states.currentRun||void 0;for(;e--&&(r=this.nextRun(r));)n.push(r);return n}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,n=this.fn!==void 0,r=!this._states.kill;return t&&n&&r&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof Z||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new Z(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=$.indexOf(this);e>=0&&$.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw Error(`Cron: It is not allowed to schedule two functions using the same Croner instance.`);e&&(this.fn=e);let t=this.msToNext(),n=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||n===null?this:(t>$n&&(t=$n),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),t),this._states.currentTimeout&&this.options.unref&&Qn(this._states.currentTimeout),this)}async _trigger(e){if(this._states.blocking=!0,this._states.currentRun=new Z(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){Q(this.options.catch)&&this.options.catch(e,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new Z(e,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,n=!this._states.paused&&t.getTime()>=e.getTime(),r=this._states.blocking&&this.options.protect;n&&!r?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):n&&r&&Q(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),n=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),n=!e),e=new Z(e,this.options.timezone||this.options.utcOffset),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let r=this._states.once||new Z(e,this.options.timezone||this.options.utcOffset);return!n&&r!==this._states.once&&(r=r.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||r===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&r.getTime()>=this.options.stopAt.getTime()?null:r}_calculatePreviousRun(e,t){let n=new Z(void 0,this.options.timezone||this.options.utcOffset),r=e;if(this.options.startAt.getTime()<=n.getTime()){r=this.options.startAt;let e=r.getTime()+this.options.interval*1e3;for(;e<=n.getTime();)r=new Z(r,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),e=r.getTime()+this.options.interval*1e3;t=!0}return r===null&&(r=void 0),[r,t]}};function tr(e,t){return`${e}:${t}`}function nr(e){return e??`UTC`}var rr=class{bus;cleanupFns=[];initialized=!1;jobs=new Map;constructor(e){this.bus=e}async init(){if(!this.initialized)try{this.cleanupFns.push(this.bus.on(y.definition.created,e=>{this.scheduleWorkflow(e.payload)}),this.bus.on(y.definition.updated,e=>{this.unscheduleWorkflow(e.payload.id),this.scheduleWorkflow(e.payload)}),this.bus.on(y.definition.deleted,e=>{this.unscheduleWorkflow(e.payload.id)})),await this.loadExistingTriggers(),this.initialized=!0}catch(e){throw this.cleanupFns.forEach(e=>e()),this.cleanupFns.length=0,this.stopAllJobs(),e}}destroy(){this.initialized&&=(this.cleanupFns.forEach(e=>e()),this.cleanupFns.length=0,this.stopAllJobs(),!1)}activeJobCount(){return this.jobs.size}async loadExistingTriggers(){let{workflows:e}=await this.bus.request(m.list,{});for(let t of e)this.scheduleWorkflow(t)}scheduleWorkflow(e){if(e.scope.type===`global`)return;let t=e.triggers??[];for(let n=0;n<t.length;n++){let r=t[n];if(r.type!==`cron`)continue;let i=tr(e.id,n);this.stopJob(i);try{let t=nr(r.timezone),a=new er(r.schedule,{timezone:t},()=>{this.fireTrigger(e.id,n)});this.jobs.set(i,{workflowId:e.id,triggerIndex:n,job:a})}catch(t){console.warn(`[CronTriggerEvaluator] Skipping invalid cron trigger key="${i}" workflowId="${e.id}" triggerIndex=${n} schedule="${r.schedule}" timezone="${r.timezone??`UTC`}"`,t)}}}unscheduleWorkflow(e){for(let[t,n]of this.jobs)n.workflowId===e&&(n.job.stop(),this.jobs.delete(t))}stopJob(e){let t=this.jobs.get(e);t&&(t.job.stop(),this.jobs.delete(e))}stopAllJobs(){for(let e of this.jobs.values())e.job.stop();this.jobs.clear()}fireTrigger(e,t){this.bus.request(y.start,{workflowId:e,triggerPayload:{firedAt:Date.now(),triggerIndex:t}}).catch(n=>{console.error(`[CronTriggerEvaluator] Failed to start workflow "${e}" for cron trigger index ${t}:`,n)})}},ir=class extends Ge{workflowExecutor;busEventTriggerEvaluator;cronTriggerEvaluator;constructor(e,t){super(e),this.workflowExecutor=new Bn(e,t?.executorConfig,t?.workflowRunner),this.busEventTriggerEvaluator=new Wn(e),this.cronTriggerEvaluator=new rr(e)}get executor(){return this.workflowExecutor}get cronTriggers(){return this.cronTriggerEvaluator}setTriggerTypeRegistry(e){this.workflowExecutor.setTriggerTypeRegistry(e)}getTriggerTypeRegistry(){return this.workflowExecutor.getTriggerTypeRegistry()}async onInit(){this.addCleanup(()=>this.destroyOwnedServices()),await this.workflowExecutor.init(),await this.busEventTriggerEvaluator.init(),await this.cronTriggerEvaluator.init()}async destroyOwnedServices(){let e=[];for(let t of[()=>this.cronTriggerEvaluator.destroy(),()=>this.busEventTriggerEvaluator.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 ar=Ue(`makaio.workflow-engine`);function or(e){return{name:ar.name,displayName:`Workflow Engine`,version:`0.1.0`,dependencies:[He(it.name)],critical:!0,namespaces:[Be,de],storage:{registerHandlers:Je(G)},create:t=>new ir(t.bus,e)}}const sr=or();export{Bn as a,It as c,ir as i,Rt as l,or as n,G as o,sr as r,Lt as s,ar as t};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IMakaioBus } from "@makaio/framework/bus";
|
|
2
2
|
import * as _$_makaio_contracts0 from "@makaio/framework/contracts";
|
|
3
|
-
import { IWorkflowRunner, IWorkflowTriggerTypeRegistry,
|
|
3
|
+
import { IWorkflowRunner, IWorkflowTriggerTypeRegistry, MakaioNodeExtension, StationHandler, StepRunnerBusAuth, StepRunnerPlatformDefaults, WorkflowDefinition } from "@makaio/framework/contracts";
|
|
4
4
|
import { BaseService } from "@makaio/framework/service-base";
|
|
5
5
|
import { MakaioDatabase } from "@makaio/framework/storage/drizzle";
|
|
6
6
|
|
package/dist/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{t}from"./ajv-Cx19PP7Q.mjs";import{z as n}from"zod";import{execFile as r}from"node:child_process";import{isAbsolute as i,relative as a,resolve as o}from"node:path";import{realpathSync as s}from"node:fs";import{localSubject as c}from"@makaio/framework/core";import{NoHandlerError as l}from"@makaio/framework/bus";import{AgentSubjects as u,ArtifactSubjects as d,ExecutionLinkListQuerySchema as f,ExecutionLinkSchema as p,ExecutionListQuerySchema as m,ExecutionStatusSchema as h,ExecutionsByArtifactRefsQuerySchema as g,GateInstanceListQuerySchema as _,JsonPatchOperationSchema as v,JsonValueSchema as y,SessionSubjects as b,SpanRecordSchema as x,SubagentSubjects as S,WORKFLOW_CANCELLED_REASON as ee,WorkerNodeSubjects as te,WorkflowDefinitionSchema as ne,WorkflowError as re,WorkflowErrorCode as ie,WorkflowExecutionSchema as C,WorkflowFrameStateSchema as w,WorkflowGateInstanceSchema as T,WorkflowListQuerySchema as ae,WorkflowRunContextSchema as oe,WorkflowSchemas as se,WorkflowSubjects as ce,WorkflowSubjects as E,WorkflowWorkerSourceSchema as le,createStepCancelSubject as ue}from"@makaio/framework/contracts";import{createStorageNamespaceDefinition as de}from"@makaio/framework/storage";import{index as D,primaryKey as fe,uniqueIndex as pe}from"drizzle-orm/sqlite-core";import{index as O,primaryKey as me,uniqueIndex as he}from"drizzle-orm/pg-core";import{defineDualTable as k}from"@makaio/framework/storage/drizzle";import{sql as ge}from"drizzle-orm";import{evaluateSync as A,resolveTemplate as j}from"@makaio/framework/expression";import*as _e from"node:os";function ve(e){return{scopeType:e.textEnum(`scope_type`,{enum:[`global`,`workspace`,`session`,`external`]}).notNull().$type(),scopeKind:e.text(`scope_kind`).notNull().default(``),scopeId:e.text(`scope_id`).notNull().default(``)}}const ye=k(`workflow_definitions`,e=>({id:e.text(`id`).primaryKey(),name:e.text(`name`).notNull(),description:e.text(`description`),root:e.jsonCol(`root`).notNull(),inputSchema:e.jsonCol(`input_schema`),configSchema:e.jsonCol(`config_schema`),outputSchema:e.jsonCol(`output_schema`),state:e.jsonCol(`state`),artifact:e.jsonCol(`artifact`),triggers:e.jsonCol(`triggers`),...ve(e),createdAt:e.epochMs(`created_at`).notNull(),updatedAt:e.epochMs(`updated_at`).notNull(),canvasLayout:e.jsonCol(`canvas_layout`),source:e.jsonCol(`source`),executionHints:e.jsonCol(`execution_hints`)}),{sqlite:e=>[pe(`uniq_workflow_definitions_name_scope`).on(e.name,e.scopeType,e.scopeKind,e.scopeId),D(`idx_workflow_definitions_scope`).on(e.scopeType,e.scopeKind,e.scopeId)],postgres:e=>[he(`uniq_workflow_definitions_name_scope`).on(e.name,e.scopeType,e.scopeKind,e.scopeId),O(`idx_workflow_definitions_scope`).on(e.scopeType,e.scopeKind,e.scopeId)]}),be=ye.sqlite,M=k(`workflow_executions`,e=>({id:e.text(`id`).primaryKey(),workflowId:e.text(`workflow_id`).notNull(),coordinatorSessionId:e.text(`coordinator_session_id`),status:e.textEnum(`status`,{enum:[`pending`,`running`,`paused`,`completed`,`failed`,`cancelled`]}).notNull(),inputs:e.jsonCol(`inputs`),error:e.text(`error`),reason:e.text(`reason`),startedAt:e.epochMs(`started_at`).notNull(),completedAt:e.epochMs(`completed_at`),triggerPayload:e.jsonCol(`trigger_payload`),artifactKind:e.text(`artifact_kind`),artifactId:e.text(`artifact_id`),...ve(e)}),{sqlite:e=>[D(`idx_workflow_executions_status`).on(e.status),D(`idx_workflow_executions_scope_started`).on(e.scopeType,e.scopeKind,e.scopeId,e.startedAt),D(`idx_workflow_executions_workflow_started`).on(e.workflowId,e.startedAt),D(`idx_workflow_executions_artifact`).on(e.artifactKind,e.artifactId,e.startedAt)],postgres:e=>[O(`idx_workflow_executions_status`).on(e.status),O(`idx_workflow_executions_scope_started`).on(e.scopeType,e.scopeKind,e.scopeId,e.startedAt),O(`idx_workflow_executions_workflow_started`).on(e.workflowId,e.startedAt),O(`idx_workflow_executions_artifact`).on(e.artifactKind,e.artifactId,e.startedAt)]}),xe=M.sqlite,Se=k(`workflow_execution_frames`,e=>({frameId:e.text(`frame_id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>M.columnPair(`id`),{onDelete:`cascade`}),nodeId:e.text(`node_id`).notNull(),nodeType:e.text(`node_type`).notNull().$type(),path:e.jsonCol(`path`).notNull(),parentFrameId:e.text(`parent_frame_id`),status:e.text(`status`).notNull().default(`pending`).$type(),attempt:e.int4(`attempt`).notNull().default(0),iteration:e.int4(`iteration`),branchKey:e.text(`branch_key`),output:e.jsonCol(`output`),outputPresent:e.bool(`output_present`).notNull().default(!1),error:e.text(`error`),startedAt:e.epochMs(`started_at`),completedAt:e.epochMs(`completed_at`)}),{sqlite:e=>[D(`idx_workflow_execution_frames_execution`).on(e.executionId),D(`idx_workflow_execution_frames_parent`).on(e.parentFrameId)],postgres:e=>[O(`idx_workflow_execution_frames_execution`).on(e.executionId),O(`idx_workflow_execution_frames_parent`).on(e.parentFrameId)]}),Ce=Se.sqlite,we=k(`workflow_gate_instances`,e=>({id:e.text(`id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>M.columnPair(`id`),{onDelete:`cascade`}),nodeId:e.text(`node_id`).notNull(),frameId:e.text(`frame_id`).notNull(),schema:e.jsonCol(`schema`).notNull(),prompt:e.text(`prompt`),status:e.text(`status`).notNull().default(`waiting`).$type(),autoAction:e.textEnum(`auto_action`,{enum:[`approve`,`reject`]}).notNull().default(`reject`),timeoutMs:e.int4(`timeout_ms`),resumeData:e.jsonCol(`resume_data`),reason:e.text(`reason`),resumeDataPresent:e.bool(`resume_data_present`).notNull().default(!1),createdAt:e.epochMs(`created_at`).notNull(),resolvedAt:e.epochMs(`resolved_at`)}),{sqlite:e=>[D(`idx_workflow_gate_instances_execution`).on(e.executionId),D(`idx_workflow_gate_instances_frame`).on(e.frameId)],postgres:e=>[O(`idx_workflow_gate_instances_execution`).on(e.executionId),O(`idx_workflow_gate_instances_frame`).on(e.frameId)]}),Te=we.sqlite,Ee=k(`workflow_step_spans`,e=>({executionId:e.text(`execution_id`).notNull().references(()=>M.columnPair(`id`),{onDelete:`cascade`}),frameId:e.text(`frame_id`).notNull(),stepId:e.text(`step_id`).notNull(),stepType:e.text(`step_type`).notNull(),status:e.text(`status`).$type().notNull(),startedAt:e.epochMs(`started_at`),completedAt:e.epochMs(`completed_at`),durationMs:e.int4(`duration_ms`),inputTokens:e.int4(`input_tokens`),outputTokens:e.int4(`output_tokens`),estimatedCost:e.float8(`estimated_cost`),toolCallCount:e.int4(`tool_call_count`),input:e.text(`input`),output:e.text(`output`)}),{sqlite:e=>[fe({columns:[e.executionId,e.frameId]}),D(`idx_workflow_step_spans_status`).on(e.status)],postgres:e=>[me({columns:[e.executionId,e.frameId]}),O(`idx_workflow_step_spans_status`).on(e.status)]}),De=Ee.sqlite,Oe=k(`workflow_execution_links`,e=>({sourceExecutionId:e.text(`source_execution_id`).notNull().references(()=>M.columnPair(`id`),{onDelete:`cascade`}),targetExecutionId:e.text(`target_execution_id`).notNull().references(()=>M.columnPair(`id`),{onDelete:`cascade`}),linkType:e.text(`link_type`).$type().notNull(),metadata:e.jsonCol(`metadata`)}),{sqlite:e=>[fe({columns:[e.sourceExecutionId,e.targetExecutionId]}),D(`idx_workflow_execution_links_target`).on(e.targetExecutionId)],postgres:e=>[me({columns:[e.sourceExecutionId,e.targetExecutionId]}),O(`idx_workflow_execution_links_target`).on(e.targetExecutionId)]}),ke=Oe.sqlite,Ae=k(`workflow_run_contexts`,e=>({executionId:e.text(`execution_id`).primaryKey().references(()=>M.columnPair(`id`),{onDelete:`cascade`}),workflowId:e.text(`workflow_id`).notNull(),coordinatorSessionId:e.text(`coordinator_session_id`).notNull(),sourceKind:e.text(`source_kind`).notNull(),sourcePath:e.text(`source_path`),sourceFilename:e.text(`source_filename`),sourceCode:e.text(`source_code`),definitionSnapshot:e.jsonCol(`definition_snapshot`),workerManifest:e.jsonCol(`worker_manifest`).notNull(),inputs:e.jsonCol(`inputs`),config:e.jsonCol(`config`).notNull().default(ge`'{}'`),triggerPayload:e.jsonCol(`trigger_payload`).notNull(),artifactRef:e.jsonCol(`artifact_ref`),executionHints:e.jsonCol(`execution_hints`),dispatchMetadata:e.jsonCol(`dispatch_metadata`),scopeType:e.textEnum(`scope_type`,{enum:[`global`,`workspace`,`session`,`external`]}).notNull().default(`global`).$type(),scopeKind:e.text(`scope_kind`).notNull().default(``),scopeId:e.text(`scope_id`).notNull().default(``),cancelSubject:e.text(`cancel_subject`).notNull(),context:e.jsonCol(`context`).notNull(),env:e.jsonCol(`env`).notNull(),createdAt:e.epochMs(`created_at`).notNull(),suspensionStrategy:e.text(`suspension_strategy`).$type()}),{sqlite:e=>[D(`idx_run_contexts_workflow`).on(e.workflowId)],postgres:e=>[O(`idx_run_contexts_workflow`).on(e.workflowId)]}),je=Ae.sqlite,Me=k(`worklog_summaries`,e=>({executionId:e.text(`execution_id`).primaryKey().references(()=>M.columnPair(`id`),{onDelete:`cascade`}),workflowId:e.text(`workflow_id`).notNull(),workflowName:e.text(`workflow_name`),status:e.textEnum(`status`,{enum:[`pending`,`running`,`paused`,`completed`,`failed`,`cancelled`]}).notNull(),startedAt:e.epochMs(`started_at`).notNull(),completedAt:e.epochMs(`completed_at`),durationMs:e.int4(`duration_ms`),totalInputTokens:e.int4(`total_input_tokens`),totalOutputTokens:e.int4(`total_output_tokens`),totalEstimatedCost:e.float8(`total_estimated_cost`),error:e.text(`error`),failedNodeId:e.text(`failed_node_id`)}),{sqlite:e=>[D(`idx_worklog_summaries_workflow_started`).on(e.workflowId,e.startedAt),D(`idx_worklog_summaries_status`).on(e.status)],postgres:e=>[O(`idx_worklog_summaries_workflow_started`).on(e.workflowId,e.startedAt),O(`idx_worklog_summaries_status`).on(e.status)]}),Ne=Me.sqlite,Pe=k(`worklog_frame_entries`,e=>({frameId:e.text(`frame_id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>M.columnPair(`id`),{onDelete:`cascade`}),nodeId:e.text(`node_id`).notNull(),nodeType:e.text(`node_type`).notNull().$type(),path:e.jsonCol(`path`).notNull(),status:e.textEnum(`status`,{enum:[`pending`,`running`,`waiting`,`completed`,`failed`,`skipped`,`cancelled`]}).notNull(),attempt:e.int4(`attempt`).notNull().default(0),iteration:e.int4(`iteration`),branchKey:e.text(`branch_key`),startedAt:e.epochMs(`started_at`),completedAt:e.epochMs(`completed_at`),durationMs:e.int4(`duration_ms`),inputTokens:e.int4(`input_tokens`),outputTokens:e.int4(`output_tokens`),estimatedCost:e.float8(`estimated_cost`),error:e.text(`error`)}),{sqlite:e=>[D(`idx_worklog_frame_entries_execution`).on(e.executionId)],postgres:e=>[O(`idx_worklog_frame_entries_execution`).on(e.executionId)]}),Fe=Pe.sqlite,Ie=k(`worklog_artifact_writes`,e=>({id:e.text(`id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>M.columnPair(`id`),{onDelete:`cascade`}),frameId:e.text(`frame_id`).notNull(),nodeId:e.text(`node_id`).notNull(),artifact:e.jsonCol(`artifact`).notNull(),revision:e.text(`revision`),writtenAt:e.epochMs(`written_at`).notNull()}),{sqlite:e=>[D(`idx_worklog_artifact_writes_execution`).on(e.executionId)],postgres:e=>[O(`idx_worklog_artifact_writes_execution`).on(e.executionId)]}),Le=Ie.sqlite,Re=k(`worklog_gate_events`,e=>({id:e.text(`id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>M.columnPair(`id`),{onDelete:`cascade`}),nodeId:e.text(`node_id`).notNull(),frameId:e.text(`frame_id`).notNull(),status:e.textEnum(`status`,{enum:[`waiting`,`resumed`,`rejected`,`timed-out`,`cancelled`]}).notNull().$type(),prompt:e.text(`prompt`),openedAt:e.epochMs(`opened_at`).notNull(),resolvedAt:e.epochMs(`resolved_at`),resumeData:e.jsonCol(`resume_data`)}),{sqlite:e=>[D(`idx_worklog_gate_events_execution`).on(e.executionId),D(`idx_worklog_gate_events_status`).on(e.status)],postgres:e=>[O(`idx_worklog_gate_events_execution`).on(e.executionId),O(`idx_worklog_gate_events_status`).on(e.status)]}),ze=Re.sqlite,Be=k(`workflow_execution_state`,e=>({executionId:e.text(`execution_id`).primaryKey().references(()=>M.columnPair(`id`),{onDelete:`cascade`}),sequence:e.int4(`sequence`).notNull().default(0),value:e.jsonCol(`value`).notNull(),updatedAt:e.epochMs(`updated_at`).notNull()})),Ve=Be.sqlite,He=k(`workflow_execution_state_events`,e=>({executionId:e.text(`execution_id`).notNull().references(()=>M.columnPair(`id`),{onDelete:`cascade`}),sequence:e.int4(`sequence`).notNull(),patch:e.jsonCol(`patch`).notNull(),value:e.jsonCol(`value`).notNull(),createdAt:e.epochMs(`created_at`).notNull()}),{sqlite:e=>[fe({columns:[e.executionId,e.sequence]})],postgres:e=>[me({columns:[e.executionId,e.sequence]})]}),Ue=He.sqlite,We=n.object({executionId:n.string().min(1),status:h.optional(),error:n.string().nullable().optional(),reason:n.string().nullable().optional(),completedAt:n.number().nullable().optional()}),Ge=de(`workflow`,{schemas:{get:{request:n.object({id:n.string()}),response:n.object({workflow:ne.nullable()})},set:{request:n.object({workflow:ne}),response:n.object({id:n.string()})},delete:{request:n.object({id:n.string()}),response:n.object({deleted:n.boolean()})},list:{request:ae,response:n.object({workflows:n.array(ne)})},getExecution:{request:n.object({executionId:n.string()}),response:n.object({execution:C.nullable()})},setExecution:{request:n.object({execution:C}),response:n.object({id:n.string()})},setExecutionStart:{request:n.object({execution:C,runContext:oe,initialState:y.optional(),executionLinks:n.array(p).optional()}),response:n.object({id:n.string(),executionId:n.string()})},updateExecution:{request:We,response:n.object({success:n.boolean()})},cancelPausedExecution:{request:n.object({executionId:n.string().min(1),completedAt:n.number(),reason:n.string().optional()}),response:n.object({cancelled:n.boolean(),gates:n.array(T.extend({status:n.literal(`cancelled`)}))})},listExecutions:{request:m,response:n.object({executions:n.array(C)})},listExecutionsByArtifactRefs:{request:g,response:n.object({executionsByRef:n.record(n.string(),n.array(C))})},setFrame:{request:n.object({executionId:n.string().min(1),frame:w}),response:n.object({frameId:n.string()})},getFrame:{request:n.object({frameId:n.string().min(1)}),response:n.object({frame:w.nullable()})},listFrames:{request:n.object({executionId:n.string().min(1)}),response:n.object({frames:n.array(w)})},setGateInstance:{request:n.object({gate:T}),response:n.object({id:n.string()})},resolveWaitingGateInstance:{request:n.object({gate:T.extend({status:n.enum([`resumed`,`rejected`])})}),response:n.object({accepted:n.boolean()})},restorePausedGateResumeState:{request:n.object({execution:C.extend({status:n.literal(`paused`)}),gate:T.extend({status:n.literal(`waiting`)})}),response:n.object({executionId:n.string(),gateId:n.string()})},getGateInstance:{request:n.object({executionId:n.string().min(1),nodeId:n.string().min(1),frameId:n.string().min(1).optional()}),response:n.object({gate:T.nullable()})},listGateInstances:{request:_,response:n.object({gates:n.array(T)})},listPausedGateTimeouts:c({request:n.object({}),response:n.object({gates:n.array(T)})}),setSpan:{request:n.object({span:x}),response:n.object({id:n.string()})},listSpans:{request:n.object({executionId:n.string()}),response:n.object({spans:n.array(x)})},setExecutionLink:{request:n.object({link:p}),response:n.object({id:n.string()})},listExecutionLinks:{request:f,response:n.object({links:n.array(p)})},setRunContext:c({request:n.object({runContext:oe}),response:n.object({executionId:n.string()})}),getRunContext:c({request:n.object({executionId:n.string().min(1)}),response:n.object({runContext:oe.nullable()})}),initializeState:c({request:n.object({executionId:n.string().min(1),initialValue:y}),response:n.object({})}),getState:c({request:n.object({executionId:n.string().min(1)}),response:n.object({state:n.object({executionId:n.string().min(1),sequence:n.number().int().nonnegative(),value:y}).nullable()})}),patchState:c({request:n.object({executionId:n.string().min(1),expectedSequence:n.number().int().nonnegative(),nextValue:y}),response:n.object({executionId:n.string().min(1),sequence:n.number().int().positive(),patch:n.array(v),value:y})})},extensions:{drizzle:{workflowDefinitions:be,workflowExecutions:xe,workflowExecutionFrames:Ce,workflowGateInstances:Te,workflowStepSpans:De,workflowExecutionLinks:ke,workflowRunContexts:je,worklogSummaries:Ne,worklogFrameEntries:Fe,worklogArtifactWrites:Le,worklogGateEvents:ze,workflowExecutionState:Ve,workflowExecutionStateEvents:Ue}}}),N=Ge.subjects;var Ke=e(t(),1);function qe(e,t){let n=[];return P(n,``,e,t),n}function P(e,t,n,r){if(Array.isArray(n)&&Array.isArray(r)){Ye(e,t,n,r);return}if(Xe(n)&&Xe(r)){Je(e,t,n,r);return}$e(n,r)||e.push({op:`replace`,path:t,value:r})}function Je(e,t,n,r){let i=Array.from(new Set([...Object.keys(n),...Object.keys(r)])).sort();for(let a of i){let i=Ze(n,a),o=Ze(r,a),s=`${t}/${Qe(a)}`;if(!i&&o){e.push({op:`add`,path:s,value:r[a]});continue}if(i&&!o){e.push({op:`remove`,path:s});continue}P(e,s,n[a],r[a])}}function Ye(e,t,n,r){let i=Math.min(n.length,r.length);for(let a=0;a<i;a++)P(e,`${t}/${String(a)}`,n[a],r[a]);for(let i=n.length-1;i>=r.length;i--)e.push({op:`remove`,path:`${t}/${String(i)}`});for(let i=n.length;i<r.length;i++)e.push({op:`add`,path:`${t}/${String(i)}`,value:r[i]})}function Xe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ze(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Qe(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function $e(e,t){return Object.is(e,t)}const et={stepTimeoutMs:300*1e3,stepCooldownMs:500,busAuth:{kind:`none`},platformDefaults:{cwd:process.cwd()},cancelTimeoutMs:1e4},tt=new Ke.default({allErrors:!0,strict:!1}),F=new Map,nt=new Map;function rt(e){let t=e.$id;return typeof t==`string`?t:void 0}function it(e,t,n){let r=rt(t);return r===void 0?`workflow:${e}:${n}`:`schema-id:${r}`}function at(e,t){try{return JSON.stringify(I(t))}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Workflow '${e}' state schema is invalid: ${n}`)}}function I(e){if(Array.isArray(e))return e.map(I);if(typeof e!=`object`||!e)return e;let t=e;return Object.fromEntries(Object.keys(t).sort().map(e=>[e,I(t[e])]))}function ot(e,t,n){let r=nt.get(t);if(r!==void 0&&r!==n)throw Error(`Workflow '${e}' state schema reuses JSON Schema $id '${t}' with different content`);return tt.getSchema(t)}function st(e){return e==null||e.length===0?`schema validation failed`:e.map(e=>`${e.instancePath.length>0?e.instancePath:`<root>`} ${e.message??`is invalid`}`).join(`; `)}function ct(e,t){let n=at(e,t),r=it(e,t,n),i=F.get(r);if(i!==void 0)return i;let a=rt(t);if(a!==void 0){let t=ot(e,a,n);if(t!==void 0)return F.set(r,t),t}try{let e=tt.compile(t);return F.set(r,e),a!==void 0&&nt.set(a,n),e}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Workflow '${e}' state schema is invalid: ${n}`)}}function lt(e,t,n){if(e.state===void 0)return;let r=ct(e.id,e.state.schema);if(r(t))return;let i=n===`initial`?`initial state`:`next state`;throw Error(`Workflow '${e.id}' ${i} does not match workflow state schema: ${st(r.errors)}`)}function ut(e){if(e.state===void 0)return;let t=e.state.initial===void 0?{}:e.state.initial;return lt(e,t,`initial`),t}async function dt(e,t,n){if(!(await e.request(N.updateExecution,{executionId:t.id,status:n.status,error:n.error,reason:n.reason,completedAt:n.completedAt})).success)throw Error(`Workflow execution not found: ${t.id}`)}async function ft(e,t,n,r){t.status=`completed`,t.completedAt=Date.now();try{await dt(e.bus,t,{status:t.status,completedAt:t.completedAt}),await e.bus.emit(E.execution.completed,{executionId:n,workflowId:t.workflowId,totalDuration:t.completedAt-r,completedAt:t.completedAt})}finally{e.activeExecutions.delete(n)}}async function L(e,t,n,r,i){t.status=`failed`,t.error=r,t.completedAt=Date.now();try{await dt(e.bus,t,{status:t.status,error:t.error,completedAt:t.completedAt});try{await i?.()}catch(e){console.error(`[WorkflowFinalizer] Failed to run failure pre-emit hook:`,e)}await e.bus.emit(E.execution.failed,{executionId:n,workflowId:t.workflowId,error:r,completedAt:t.completedAt})}finally{e.activeExecutions.delete(n)}}function pt(e,t,n){let{activeRunnerSteps:r,bus:i}=e,a=`${t}:`;for(let[e,o]of r){if(!e.startsWith(a))continue;let r=e.slice(a.length);o.controller.abort(),i.emit(ue(o.cancelSubject),{executionId:t,stepId:r,reason:n}).catch(t=>{console.error(`[WorkflowFinalizer] Failed to emit cancellation for ${e}:`,t)})}}async function mt(e,t,n){let r=await e.bus.request(N.getExecution,{executionId:t});if(r.execution==null)return!1;let i=r.execution.workflowId;if(i===void 0)throw Error(`Paused execution ${t} is missing stored workflowId`);let a=Date.now(),{cancelled:o,gates:s}=await e.bus.request(N.cancelPausedExecution,{executionId:t,completedAt:a,reason:n});if(!o)return!1;for(let n of s)await e.bus.emit(E.gate.resolved,{executionId:t,stepId:n.nodeId,stepType:`gate`,frameId:n.frameId,source:`cancelled`}).catch(e=>{console.error(`[WorkflowFinalizer] Failed to emit cancelled gate resolution for ${n.frameId}:`,e)});return await e.bus.emit(E.execution.cancelled,{executionId:t,workflowId:i,reason:n,completedAt:a}),e.activeExecutions.delete(t),!0}async function ht(e,t,n){let r=e.activeExecutions.get(t);if(!r||r.execution.status!==`running`)return mt(e,t,n);let{execution:i}=r;i.status=`cancelled`,i.reason=n,i.completedAt=Date.now();try{for(let[n,r]of e.shellAbortControllers)n.startsWith(`${t}:`)&&(r.abort(),e.shellAbortControllers.delete(n));pt(e,t,n),await dt(e.bus,i,{status:i.status,reason:n,completedAt:i.completedAt}),await e.bus.emit(E.execution.cancelled,{executionId:t,workflowId:i.workflowId,reason:n,completedAt:i.completedAt})}finally{e.activeExecutions.delete(t)}return!0}const gt=[`darwin`,`linux`,`win32`];function _t(e){return gt.find(t=>t===e)??`linux`}function vt(e,t){return t}function yt(e,t){return{...t}}function bt(e){return e.reason instanceof Error?e.reason.message:typeof e.reason==`string`&&e.reason.length>0?e.reason:ee}async function xt(e,t,n){let r=e.activeExecutions.get(t);if(!r||r.execution.status!==`running`)return;let i=e.buildFinalizerDeps(),{execution:a}=await i.bus.request(N.getExecution,{executionId:t});a?.status===`running`&&(r.execution=a,await ht(i,t,bt(n))||console.error(`[WorkflowExecutor] Failed to persist runner cancellation for ${t}: execution not active`))}async function St(e,t){if(t.pausedAtGateId===void 0||t.pausedAtFrameId===void 0)throw Error(`Paused runner result for '${t.executionId}' is missing gate identity`);let{bus:n}=e.buildFinalizerDeps(),{execution:r}=await n.request(N.getExecution,{executionId:t.executionId});if(r?.status!==`running`){let n=e.activeExecutions.get(t.executionId);n!==void 0&&r?.status===`paused`&&(n.execution.status=`paused`,e.activeExecutions.delete(t.executionId));return}let i={...r,status:`paused`};await n.request(N.setExecution,{execution:i});let a=e.activeExecutions.get(t.executionId);a!==void 0&&(a.execution=i),await n.emit(E.execution.paused,{executionId:t.executionId,workflowId:t.workflowId,pausedAtGateId:t.pausedAtGateId,pausedAtFrameId:t.pausedAtFrameId}),e.activeExecutions.delete(t.executionId)}async function Ct(e,t){let n=e.activeExecutions.get(t.executionId);if(!n||n.execution.status!==`running`)return;let r=e.buildFinalizerDeps(),{execution:i}=await r.bus.request(N.getExecution,{executionId:t.executionId});if(i?.status===`running`){if(n.execution=i,t.status===`completed`){await ft(r,n.execution,t.executionId,n.execution.startedAt);return}if(t.status===`cancelled`){await ht(r,t.executionId,t.reason??ee);return}if(t.status===`failed`){await L(r,n.execution,t.executionId,t.error);return}}}function wt(e,t){return{source:{kind:`path`,path:t.filePath},executionId:t.executionId,workflowId:t.workflowId,triggerPayload:t.sanitizedTriggerPayload,inputs:t.boundInputs,config:t.boundConfig,...t.artifactRef===void 0?{}:{artifactRef:t.artifactRef},...t.executionHints===void 0?{}:{executionHints:t.executionHints},scope:t.scope,busUrl:e.config.busUrl,busAuth:e.config.busAuth,context:e.resolveWorkflowContext(t.workspaceRoot),env:e.config.platformDefaults.env??{},coordinatorSessionId:t.coordinatorSessionId,cancelSubject:`workflow.${t.executionId}.cancel`,suspensionStrategy:`wait-in-process`}}function Tt(e,t){let{executionId:n}=t,{workflowRunner:r,workflowAbortControllers:i,executionTasks:a,activeExecutions:o}=e,s=new AbortController;i.set(n,s);let c=wt(e,t);return Promise.resolve().then(()=>r.run(c,s.signal)).then(async t=>{if(t.status===`paused`){await St(e,t);return}await Ct(e,t)}).catch(async t=>{if(s.signal.aborted){await xt(e,n,s.signal).catch(e=>{console.error(`[WorkflowExecutor] Failed to persist file runner cancellation for ${n}:`,e)});return}let r=o.get(n);if(r){let i=t instanceof Error?t.message:String(t);await L(e.buildFinalizerDeps(),r.execution,n,i).catch(e=>{console.error(`[WorkflowExecutor] Failed to persist file runner boot failure for ${n}:`,e)})}}).finally(()=>{i.delete(n),a.delete(n),o.delete(n)})}function Et(e,t){let{config:n}=e,r=t.definitionSnapshot??(t.source.kind===`definition`?t.workflow:void 0);return{source:t.source,...r===void 0?{}:{definition:r},executionId:t.executionId,workflowId:t.workflowId,triggerPayload:t.sanitizedTriggerPayload,inputs:t.boundInputs,config:t.boundConfig,...t.artifactRef===void 0?{}:{artifactRef:t.artifactRef},...t.executionHints===void 0?{}:{executionHints:t.executionHints},scope:t.scope,busUrl:n.busUrl,busAuth:n.busAuth,context:e.resolveWorkflowContext(t.workspaceRoot),env:n.platformDefaults.env??{},coordinatorSessionId:t.coordinatorSessionId,cancelSubject:`workflow.${t.executionId}.cancel`,suspensionStrategy:t.suspensionStrategy??`wait-in-process`}}function Dt(e,t){let{executionId:n}=t,{workflowRunner:r,workflowAbortControllers:i,executionTasks:a,activeExecutions:o}=e,s=new AbortController;i.set(n,s);let c=Et(e,t),l=t.dispatchMetadata===void 0?void 0:{dispatchMetadata:t.dispatchMetadata};return Promise.resolve().then(()=>r.run(c,s.signal,void 0,l)).then(async t=>{if(t.status===`paused`){await St(e,t);return}await Ct(e,t)}).catch(async t=>{if(s.signal.aborted){await xt(e,n,s.signal).catch(e=>{console.error(`[WorkflowExecutor] Failed to persist runner cancellation for ${n}:`,e)});return}let r=o.get(n);if(r){let i=t instanceof Error?t.message:String(t);await L(e.buildFinalizerDeps(),r.execution,n,i).catch(e=>{console.error(`[WorkflowExecutor] Failed to persist runner boot failure for ${n}:`,e)})}}).finally(()=>{i.delete(n),a.delete(n),o.delete(n)})}function Ot(e,t,n={}){let r=kt(e,n);return{executionId:e.executionId,workflowId:e.workflowId,workflow:t,...e.definitionSnapshot===void 0?{}:{definitionSnapshot:e.definitionSnapshot},source:e.source,coordinatorSessionId:e.coordinatorSessionId,sanitizedTriggerPayload:e.triggerPayload,boundInputs:e.inputs,boundConfig:e.config??{},...e.artifactRef===void 0?{}:{artifactRef:e.artifactRef},...e.executionHints===void 0?{}:{executionHints:e.executionHints},scope:e.scope,workspaceRoot:e.context.repoPath,suspensionStrategy:e.suspensionStrategy,...r===void 0?{}:{dispatchMetadata:r}}}function kt(e,t){return t.resume===!0?{...e.dispatchMetadata,resume:!0}:e.dispatchMetadata}function At(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function jt(e,t,n){let r=e?j(e,n):t,c=o(t),l=o(i(r)?r:o(t,r)),u,d;try{u=s(c),d=s(l)}catch{return null}let f=a(process.platform===`win32`?u.toLowerCase():u,process.platform===`win32`?d.toLowerCase():d);return f===``||!f.startsWith(`..`)&&!i(f)?d:null}function Mt(e){return e instanceof Error&&(`code`in e||`killed`in e)}function Nt(e){let t=e[0];return t===void 0||t.trim()===``?null:t}function Pt(e){let{command:t,cwd:n,env:i,timeoutMs:a,signal:o}=e,s=Nt(t);if(s===null)return Promise.reject(Error(`Shell step command is empty`));let c=t.slice(1);return new Promise((e,t)=>{let l=null,u=!1,d=r(s,c,{cwd:n,env:{...process.env,...i},timeout:0,maxBuffer:10*1024*1024,shell:!1},(n,r,i)=>{n?t(Object.assign(n,{stdout:r,stderr:i,aborted:u})):e({stdout:r,stderr:i})}),f=()=>{d.exitCode===null&&(d.kill(`SIGTERM`),l=setTimeout(()=>{d.exitCode===null&&d.kill(`SIGKILL`)},5e3))},p=setTimeout(()=>{f()},a);if(d.on(`close`,()=>{clearTimeout(p),l!==null&&clearTimeout(l)}),o){let e=()=>{u=!0,f()};o.aborted?e():(o.addEventListener(`abort`,e,{once:!0}),d.on(`close`,()=>o.removeEventListener(`abort`,e)))}})}async function Ft(e){let{step:t,workspaceRoot:n,expressionContext:r,signal:i}=e,a=jt(t.cwd,n,r);if(a===null)return{status:`failed`,error:`Shell step cwd '${t.cwd}' is outside workspace root '${n}'`};let o=t.command.map(e=>j(e,r));if(Nt(o)===null)return{status:`failed`,error:`Shell step command is empty`};let s=Object.fromEntries(Object.entries(t.env??{}).map(([e,t])=>[e,j(t,r)])),c=t.timeoutMs??3e5;try{let{stdout:e}=await Pt({command:o,cwd:a,env:s,timeoutMs:c,signal:i});return{status:`completed`,stdout:e}}catch(e){if(!Mt(e))return{status:`failed`,error:String(e)};let t=e.aborted===!0,n=!t&&(e.killed===!0||e.signal!=null);return{status:`failed`,error:t?`Command cancelled`:n?`Command timed out after ${c}ms`:e.stderr?.trim()||e.stdout?.trim()||e.message}}}const It=/(?:^|[_-])(authorization|token|cookie|password|set[_-]?cookie|api[_-]?key|secret|credential|private[_-]?key|api[_-]?secret)(?:$|[_-])/i;function Lt(e){if(!e)return;let t={remainingBytes:65536},n={},r=Object.entries(e).slice(0,100);for(let[e,i]of r){if(t.remainingBytes<=0)break;let r=R(e,i,0,t);r!==void 0&&(n[e]=r)}return Object.keys(n).length>0?n:void 0}function R(e,t,n,r){if(!(r.remainingBytes<=0||n>6)&&(r.remainingBytes-=e.length,!(r.remainingBytes<=0))){if(It.test(e))return r.remainingBytes-=10,`[REDACTED]`;if(t===null)return r.remainingBytes-=4,null;if(typeof t==`string`){let e=t.slice(0,2e3);return r.remainingBytes-=e.length,e}if(typeof t==`number`||typeof t==`boolean`)return r.remainingBytes-=String(t).length,t;if(Array.isArray(t)){let i=[];for(let a of t.slice(0,100)){if(r.remainingBytes<=0)break;let t=R(e,a,n+1,r);t!==void 0&&i.push(t)}return i}if(typeof t==`object`){let e={},i=Object.entries(t).slice(0,100);for(let[t,a]of i){if(r.remainingBytes<=0)break;let i=R(t,a,n+1,r);i!==void 0&&(e[t]=i)}return e}}}function Rt(e){return(e?.requirements?.capabilities??[]).length>0}function zt(e,t,n){let r=t?.requirements?.capabilities??[];if(Rt(t))return{run:(t,i)=>e.request(te.dispatch,{config:t,requirements:{customCapabilities:r},...n===void 0?{}:{metadata:n}},{signal:i})}}function Bt(e,t){let n=zt(e.bus,t.executionHints,t.dispatchMetadata);return n===void 0?e.workflowRunner===void 0?e.runExecution(t.executionId).finally(()=>{e.executionTasks.delete(t.executionId)}):Dt(e.buildRunnerTaskDeps(e.workflowRunner),t):Dt(e.buildRunnerTaskDeps(n),t)}async function Vt(e,t,n,r){let i=ut(r);await e.request(N.setExecutionStart,{execution:t,runContext:n,initialState:i})}async function Ht(e,t){try{await e.emit(E.execution.started,t)}catch(e){console.error(`[WorkflowExecutor] execution.started listener failed:`,e)}}async function Ut(e,t){await e.request(b.close,{sessionId:t}).catch(e=>{console.error(`[WorkflowExecutor] Failed to close coordinator session "${t}" after launch failure:`,e)})}function Wt(e,t,n,r,i,a,o,s,c){let l={id:t,workflowId:n.id,coordinatorSessionId:r,status:`running`,inputs:i,config:a,startedAt:Date.now(),triggerPayload:o,...c.artifactRef===void 0?{}:{artifactRef:c.artifactRef},scope:s};return e.set(t,{execution:l,workflow:n,runContext:c,runtimeHandlers:new Map}),l}async function Gt(e,t,n,r,i){await e.request(N.setExecutionStart,{execution:t,runContext:n,...r===void 0?{}:{initialState:r},...i!==void 0&&i.length>0?{executionLinks:[...i]}:{}})}function Kt(e,t){let n=e?.source;if(n===void 0)return;let r=le.parse(n);return r.kind===`path`&&!i(r.path)?{...r,path:o(t,r.path)}:r}function qt(e,t,n){return Kt(t,n)??{kind:`definition`,workflowId:e}}function Jt(e,t,n,r){if(!(t.kind===`definition`||e.workflowRunner!==void 0||Rt(n)))throw new re(ie.NOT_EXECUTABLE,`Workflow source execution '${r}' requires a workflow runner or WorkerNode capability requirements.`)}async function Yt(e,t,n,r){return e.set(t,n),await r,t}async function Xt(e,t){let{workflow:n}=await e.request(N.get,{id:t});if(!n)throw Error(`Workflow not found: ${t}`);return n}function Zt(e,t){if(e===void 0&&t===void 0)return;let n=[...new Set([...e?.capabilities??[],...t?.capabilities??[]])];return{...e,...t,...n.length>0&&{capabilities:n}}}function Qt(e,t){if(e===void 0&&t===void 0)return;let n=Zt(e?.requirements,t?.requirements),r=e?.providers!==void 0||t?.providers!==void 0?{...e?.providers,...t?.providers}:void 0;return{...e,...t,...n!==void 0&&{requirements:n},...r!==void 0&&{providers:r}}}async function $t(e,t,n,r){let{sessionId:i}=await e.request(b.create,{parentSessionId:t,branchKind:`coordinator`,title:`Workflow: ${n}`,targetWorkingDirectory:r});return i}async function en(e,t,n={}){let r=await Xt(e.bus,t);return tn(e,t,{...n,workflow:r})}async function tn(e,t,n){let{bus:r,activeExecutions:i,executionTasks:a}=e,{workflow:o,parentSessionId:s,triggerPayload:c,artifactRef:l,executionHints:u,scopeOverride:d}=n,f=At(`wfx`),p=Lt(c),m=vt(o,n.input===void 0?{}:n.input),h=yt(o,n.config??{}),g=d??o.scope,_=Qt(o.executionHints,u),v=await e.resolveExecutionWorkspaceRoot(s),y=n.executionSource??qt(t,_,v),b=n.definitionSnapshot??(y.kind===`definition`?o:void 0);Jt(e,y,_,t);let x=await $t(r,s,o.name,v),S=!1;try{let s=e.buildRunContext({executionId:f,workflowId:t,coordinatorSessionId:x,source:y,...b===void 0?{}:{definitionSnapshot:b},inputs:m,config:h,scope:g,triggerPayload:p??{},...l===void 0?{}:{artifactRef:l},..._===void 0?{}:{executionHints:_},workspaceRoot:v}),c=Wt(i,f,o,x,m,h,p,g,s);await Gt(r,c,s,y.kind===`definition`?ut(o):void 0,n.executionLinks?.(f));let u=c.startedAt,d=Ht(r,{executionId:f,workflowId:t,coordinatorSessionId:x,startedAt:u,...l===void 0?{}:{artifactRef:l}}),ee=Bt(e,{executionId:f,workflowId:t,workflow:o,...b===void 0?{}:{definitionSnapshot:b},source:y,coordinatorSessionId:x,sanitizedTriggerPayload:p??{},boundInputs:m,boundConfig:h,scope:g,...l===void 0?{}:{artifactRef:l},..._===void 0?{}:{executionHints:_},workspaceRoot:v,suspensionStrategy:s.suspensionStrategy});return S=!0,Yt(a,f,ee,d)}catch(e){throw S||(i.delete(f),a.delete(f),await Ut(r,x)),e}}function nn(e,t,n,r,i){e.set(t.id,{execution:t,workflow:{id:t.workflowId,name:n,scope:r,root:{id:`${t.workflowId}-root`,type:`sequence`,nodes:[]}},runContext:i,runtimeHandlers:new Map})}async function rn(e,t,n,r){let{sessionId:i}=await e.request(b.create,{...t===void 0?{}:{parentSessionId:t},branchKind:`coordinator`,title:`Workflow: ${n}`,targetWorkingDirectory:r});return i}async function an(e,t,n={}){let{bus:r,activeExecutions:i,executionTasks:a}=e,{artifactRef:o,executionHints:s,parentSessionId:c,triggerPayload:l,scopeOverride:u}=n,d=At(`wfx`),f=Lt(l),p=n.input===void 0?{}:n.input,m=n.config??{},h=u??{type:`global`},g=await e.resolveExecutionWorkspaceRoot(c),_=await rn(r,c,t,g),v=d,y={id:d,workflowId:v,coordinatorSessionId:_,status:`running`,inputs:p,config:m,startedAt:Date.now(),triggerPayload:f,...o===void 0?{}:{artifactRef:o},scope:h},b=!1;try{let{workflowRunner:c}=e;if(c===void 0)throw Error(`[WorkflowExecutor] startFileExecution called without a workflow runner`);let l=e.buildRunContext({executionId:d,workflowId:v,coordinatorSessionId:_,source:{kind:`path`,path:t},inputs:p,config:m,scope:h,triggerPayload:f??{},...o===void 0?{}:{artifactRef:o},...s===void 0?{}:{executionHints:s},workspaceRoot:g});await Gt(r,y,l,void 0,n.executionLinks?.(d)),nn(i,y,t,h,l);let u=Ht(r,{executionId:d,workflowId:v,coordinatorSessionId:_,startedAt:y.startedAt,...o===void 0?{}:{artifactRef:o}}),x=Tt(e.buildRunnerTaskDeps(c),{executionId:d,workflowId:v,filePath:t,coordinatorSessionId:_,sanitizedTriggerPayload:f??{},boundInputs:p,boundConfig:m,...o===void 0?{}:{artifactRef:o},...s===void 0?{}:{executionHints:s},scope:h,workspaceRoot:g});return b=!0,Yt(a,d,x,u)}catch(e){throw b||(i.delete(d),a.delete(d),await Ut(r,_)),e}}function on(e){let t={};for(let[n,r]of Object.entries(e))r.status===`completed`?t[n]={status:`completed`,output:r.output}:r.status===`skipped`&&(t[n]={status:`skipped`});return t}function z(e){let t={...e,input:e.inputs,steps:e.frames};return{...t,ctx:t}}function sn(){return{context:{repoPath:process.cwd(),makaioHome:process.env.MAKAIO_HOME??`${_e.homedir()}/.makaio`,os:process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`,arch:process.arch},env:{}}}function cn(e){return{...e,path:[...e.path]}}function ln(e){if(e===`station`||e===`delegate-agent`||e===`delegate-role`||e===`gate`)return e}function un(e,t){let n=ln(t.nodeType);if(n===void 0||t.status!==`running`&&t.status!==`completed`&&t.status!==`failed`&&t.status!==`skipped`)return;let r=t.startedAt!==void 0&&t.completedAt!==void 0?Math.max(0,t.completedAt-t.startedAt):void 0;return{executionId:e,frameId:t.frameId,stepId:t.nodeId,stepType:n,status:t.status,...t.startedAt===void 0?{}:{startedAt:t.startedAt},...t.completedAt===void 0?{}:{completedAt:t.completedAt},...r===void 0?{}:{durationMs:r},...t.output===void 0?{}:{output:JSON.stringify(t.output)}}}var dn=class e{executionId;workflowId;definition;execution;runtimeHandlers;bus;signal;frameRegistry;framePersistenceTasks=new Map;artifactBinding;constructor(e,t,n,r,i,a,o,s,c,l=sn(),u={}){this.executionId=e,this.workflowId=t,this.definition=n,this.execution=r,this.runtimeHandlers=i,this.bus=a,this.signal=o,this.frameRegistry=s??new Map,this.artifactBinding=c,this.platformContext=l.context,this.env=l.env,this.suspensionStrategy=u.suspensionStrategy??`wait-in-process`,this.resumeFrames=u.resumeFrames}platformContext;env;suspensionStrategy;resumeFrames;withSignal(t){return new e(this.executionId,this.workflowId,this.definition,this.execution,this.runtimeHandlers,this.bus,t,this.frameRegistry,this.artifactBinding,{context:this.platformContext,env:this.env},{suspensionStrategy:this.suspensionStrategy,resumeFrames:this.resumeFrames})}buildExpressionContext(){return{inputs:this.execution.inputs,config:this.execution.config??{},trigger:this.execution.triggerPayload??{},frames:{},previousSteps:{}}}createFrame(e){let t=At(`frm`),n=[...e.path,t],r={frameId:t,nodeId:e.nodeId,nodeType:e.nodeType,path:n,parentFrameId:e.parentFrameId,status:`pending`,attempt:0,iteration:e.iteration,branchKey:e.branchKey};return this.frameRegistry.set(t,r),this.persistFrame(r).catch(()=>void 0),r}async persistFrame(e,t={}){let n=t.requireFrameStorage===!0||this.suspensionStrategy!==`wait-in-process`,r=cn(e),i=un(this.executionId,r),a=(this.framePersistenceTasks.get(e.frameId)??Promise.resolve()).catch(()=>void 0).then(async()=>{n?await this.bus.request(N.setFrame,{executionId:this.executionId,frame:r}):await this.bus.requestOptional(N.setFrame,{executionId:this.executionId,frame:r}),i!==void 0&&await this.bus.requestOptional(N.setSpan,{span:i})}).catch(t=>{if(n)throw t;console.warn(`[RuntimeContext] Failed to persist frame ${e.frameId}:`,t)});this.framePersistenceTasks.set(e.frameId,a);try{await a}finally{this.framePersistenceTasks.get(e.frameId)===a&&this.framePersistenceTasks.delete(e.frameId)}}async updateFrame(e,t,n={}){let r=this.frameRegistry.get(e);if(!r)throw Error(`Frame not found: ${e}`);Object.assign(r,t),await this.persistFrame(r,n)}getFrame(e){return this.frameRegistry.get(e)}getFramesByNodeId(e){let t=[];for(let n of this.frameRegistry.values())n.nodeId===e&&t.push(n);return t.sort((e,t)=>(e.startedAt??0)-(t.startedAt??0))}async emitFrameStarted(e){try{await this.bus.emit(E.frame.started,{executionId:this.executionId,frameId:e.frameId,nodeId:e.nodeId,nodeType:e.nodeType,path:e.path,parentFrameId:e.parentFrameId,startedAt:e.startedAt})}catch(t){console.error(`[RuntimeContext] frame.started observer failed for ${e.frameId}:`,t)}}async emitFrameCompleted(e,t){try{await this.bus.emit(E.frame.completed,{executionId:this.executionId,frameId:e.frameId,nodeId:e.nodeId,output:e.output,duration:t,completedAt:e.completedAt})}catch(t){console.error(`[RuntimeContext] frame.completed observer failed for ${e.frameId}:`,t)}}async emitFrameFailed(e,t,n){try{await this.bus.emit(E.frame.failed,{executionId:this.executionId,frameId:e.frameId,nodeId:e.nodeId,error:t,duration:n,completedAt:e.completedAt})}catch(t){console.error(`[RuntimeContext] frame.failed observer failed for ${e.frameId}:`,t)}}};function fn(e){return{kind:`workflow-execution`,id:e,displayName:`Workflow Engine`}}function pn(e,t,n){return{inputs:n.inputs,config:n.config??{},trigger:n.triggerPayload,scope:n.scope,context:n.context,env:n.env,execution:{id:t.id,workflowId:t.workflowId,scope:t.scope},workflow:{id:e.id,name:e.name,scope:e.scope}}}function mn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function hn(e){if(e!=null){if(mn(e)&&typeof e.kind==`string`&&typeof e.id==`string`)return{kind:e.kind,id:e.id};throw Error(`Artifact resolve expression must return an object with string kind and id fields.`)}}function gn(e){if(e!==void 0){if(mn(e))return e;throw Error(`Artifact create expression must return an object.`)}}async function _n(e){let{bindingOptions:t,binding:n,existingArtifactRef:r,executionId:i,scope:a,initialData:o,bus:s}=e,c=null;if(r!==void 0){let e=await s.request(d.query,{kind:r.kind,ids:[r.id],currentOnly:!0});if(e.artifacts.length>0)c=e.artifacts[0];else return}else c=(await s.request(d.create,{kind:n.kind,schemaVersion:n.schemaVersion,scope:a??n.scope,data:o??{},relations:[],actor:fn(i)})).artifact;return{current:c,schemaVersion:n.schemaVersion,statusPath:t.statusPath,zodSchema:t.schema}}async function vn(e){let{definition:t,execution:n,runContext:r,zodSchema:i,bus:a}=e,o=t.artifact;if(o===void 0)return;let s=pn(t,n,r),c=r.artifactRef??(o.resolve===void 0?void 0:hn(A(o.resolve,s))),l=c===void 0&&o.create!==void 0?gn(A(o.create,s)):void 0,u=await _n({bindingOptions:{kind:o.kind,schemaVersion:o.schemaVersion,scope:o.scope,...o.resolve===void 0?{}:{resolve:o.resolve},...o.create===void 0?{}:{create:o.create},...o.statusPath===void 0?{}:{statusPath:o.statusPath},...i===void 0?{}:{schema:i}},binding:o,existingArtifactRef:c,executionId:n.id,scope:o.scope,initialData:l,bus:a});if(u===void 0)throw Error(`Workflow artifact binding could not be resolved for the configured artifact reference.`);return u}const yn=new WeakMap;function bn(e,t){let n=(yn.get(e)??Promise.resolve()).catch(()=>void 0).then(t);return yn.set(e,n.then(()=>void 0,()=>void 0)),n}function xn(e,t){switch(t.operation){case`set`:return t.data;case`merge`:return{...e,...t.data};case`append`:{let n={...e};for(let[r,i]of Object.entries(t.data)){let t=e[r];Array.isArray(t)&&Array.isArray(i)?n[r]=[...t,...i]:n[r]=i}return n}}}function Sn(e,t,n){let[r,...i]=t;if(i.length===0)return{...e,[r]:n};let a=e[r]!==null&&typeof e[r]==`object`&&!Array.isArray(e[r])?e[r]:{};return{...e,[r]:Sn(a,i,n)}}function Cn(e,t,n){return Sn(e,t.startsWith(`/`)?t.slice(1).split(`/`):t.split(`.`),n)}function wn(e,t,n){if(n===`set`||n===`functional`)return[];let r=[];for(let n of Object.keys(t))e[n]!==t[n]&&r.push(`/${n}`);return r}async function Tn(e,t){if(typeof t==`function`)return{nextData:await t(Object.freeze({...e})),operationLabel:`functional`,changedPaths:[]};let n=xn(e,t),r=wn(e,n,t.operation);return{nextData:n,operationLabel:t.operation,changedPaths:r}}function En(e){let{executionId:t,frameId:n,bindingState:r,bus:i}=e,a=Object.freeze({...r.current.data}),o=async e=>bn(r,async()=>{let a=r.current,{nextData:o,operationLabel:s,changedPaths:c}=await Tn(a.data,e);if(r.zodSchema!==void 0){let e=r.zodSchema.safeParse(o);if(!e.success)throw Error(`Artifact data validation failed: ${e.error.message}`)}let l=await i.request(d.revise,{previous:{refClass:`artifact`,kind:a.kind,id:a.id,revision:a.revision},revision:{kind:a.kind,schemaVersion:r.schemaVersion,scope:a.scope,data:o,relations:a.relations,actor:fn(t)}});r.current=l.artifact;let u=l.artifact.revision;return i.emit(ce.artifact.updated,{executionId:t,frameId:n,artifactRef:{kind:l.artifact.kind,id:l.artifact.id},paths:c,operation:s,revision:u}).catch(e=>{console.error(`[ArtifactContext] Failed to emit artifact.updated event:`,e)}),u});return{data:a,updateArtifact:o,updateStatus:async e=>{if(r.statusPath===void 0)throw Error(`updateStatus() called but no statusPath is configured on the artifact binding. Set statusPath in the .artifact() builder call to use updateStatus().`);let t=r.statusPath;return o(n=>Cn(n,t,e))}}}function Dn(e,t){return{async get(){return(await t.request(E.state.get,{executionId:e})).value},async update(n){let r=await t.request(E.state.get,{executionId:e}),i=structuredClone(r.value),a=await n(i),o=a===void 0?i:a,s=qe(r.value,o);return(await t.request(E.state.patch,{executionId:e,expectedSequence:r.sequence,patch:s,nextValue:o})).value}}}async function On(e,t,n){if(t.signal.aborted)return{status:`cancelled`};let r=await t.bus.requestOptional(E.resolveRole,{roleId:e.roleId});if(!r.handled)return{status:`failed`,error:e.unresolvedRoleError};let i=j(e.prompt,z(n)),a=e.completion===void 0?r.data:{...r.data,completion:e.completion};return B({...e,task:i,resolvedConfig:a},t)}async function B(e,t){if(t.signal.aborted)return{status:`cancelled`};let n=await t.bus.requestOptional(S.spawn,{parentSessionId:t.execution.coordinatorSessionId??t.executionId,depth:1,config:Nn(e.task,e.resolvedConfig,e.outputSchema)});if(!n.handled)return{status:`failed`,error:e.unavailableRuntimeError};let r=await kn(e,t,n.data.subagentId,{attempts:5}),i=await Pn(e,t,n.data.subagentId);return i===`aborted`?{status:`cancelled`}:(r||await kn(e,t,n.data.subagentId,{attempts:1}),i.handled?t.signal.aborted||i.data.status===`cancelled`?{status:`cancelled`}:i.data.status===`completed`?{status:`completed`,output:i.data.result??null}:{status:`failed`,error:`${e.nodeLabel} '${e.nodeId}' subagent ${i.data.status}: ${i.data.error??`no result`}`}:{status:`failed`,error:e.unavailableAwaitError})}async function kn(e,t,n,r){if(e.frameId===void 0)return!0;try{let i=await An(t,n,r.attempts);return i===void 0?!1:(await t.bus.emit(E.frame.sessionLinked,{executionId:t.executionId,frameId:e.frameId,sessionId:i}),!0)}catch(t){return console.warn(`[workflow-engine] Failed to emit frame.sessionLinked for frame '${e.frameId}' and subagent '${n}'`,t),!1}}async function An(e,t,n){for(let r=0;r<n;r+=1){if(e.signal?.aborted)return;let i=await jn(e,t);if(i===void 0||!i.handled)return;if(i.data.childSessionId!==void 0)return i.data.childSessionId;if(r<n-1&&!await Mn(e.signal,20))return}}async function jn(e,t){try{return await e.bus.requestOptional(S.getStatus,{subagentId:t},{timeout:25,signal:e.signal})}catch{return}}function Mn(e,t){return e.aborted?Promise.resolve(!1):new Promise(n=>{let r,i=t=>{r!==void 0&&(clearTimeout(r),r=void 0),e.removeEventListener(`abort`,a),n(t)},a=()=>i(!1);r=setTimeout(()=>i(!0),t),e.addEventListener(`abort`,a,{once:!0}),e.aborted&&i(!1)})}function Nn(e,t,n){return{task:e,adapterName:t.adapterName,...t.model===void 0?{}:{model:t.model},...t.reasoningEffort===void 0?{}:{reasoningEffort:t.reasoningEffort},...t.harnessId===void 0?{}:{harnessId:t.harnessId},...t.systemPrompt===void 0?{}:{systemPrompt:t.systemPrompt},...t.contextMode===void 0?{}:{contextMode:t.contextMode},...t.providerContext===void 0?{}:{providerContext:t.providerContext},...t.completion===void 0?{}:{completion:t.completion},...n===void 0?{}:{responseSchema:n}}}async function Pn(e,t,n){if(t.signal.aborted)return await V(e,t,n),`aborted`;let r=t.bus.requestOptional(S.await,{subagentId:n,...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs}},{timeout:0});if(t.signal.aborted)return await V(e,t,n),`aborted`;let i,a=new Promise(e=>{i=()=>e(`aborted`),t.signal.addEventListener(`abort`,i,{once:!0})}),o=await Promise.race([r,a]);return i!==void 0&&t.signal.removeEventListener(`abort`,i),o===`aborted`&&await V(e,t,n),o}async function V(e,t,n){try{await t.bus.requestOptional(S.kill,{subagentId:n,reason:`Workflow execution '${t.executionId}' cancelled ${e.cancellationLabel} '${e.nodeId}'`})}catch(t){console.warn(`[workflow-engine] Best-effort subagent kill failed for '${n}' (${e.cancellationLabel} '${e.nodeId}')`,t)}}async function Fn(e,t,n,r){if(t.signal.aborted)return{status:`cancelled`};let i=on(n.frames),a=t.runtimeHandlers.get(e.id);if(a===void 0)return In(e,t,n,r);let o=t.artifactBinding!==void 0&&r!==void 0?En({executionId:t.executionId,frameId:r,bindingState:t.artifactBinding,bus:t.bus}):void 0,s=t.definition.state===void 0?void 0:Dn(t.executionId,t.bus);async function c(n){if(r===void 0){console.warn(`[station-node] updateProgress called without frameId for node '${e.id}'; skipping emit`);return}let i=se[`execution.progress`].parse({executionId:t.executionId,workflowId:t.workflowId,frameId:r,nodeId:e.id,progress:n,emittedAt:Date.now()});try{await t.bus.emit(E.execution.progress,i)}catch(t){console.error(`[station-node] execution.progress observer failed for ${e.id}:`,t)}}let l;try{l=await a({...t.platformContext,env:t.env,executionId:t.executionId,workflowId:t.workflowId,inputs:t.execution.inputs,config:t.execution.config??{},trigger:t.execution.triggerPayload??{},previousSteps:i,...n.item!==void 0&&{item:n.item},...n.index!==void 0&&{index:n.index},...n.previous!==void 0&&{previous:n.previous},signal:t.signal,...o!==void 0&&{artifact:o},...s!==void 0&&{state:s},bus:t.bus,updateProgress:c})}catch(e){return{status:`failed`,error:e instanceof Error?e.message:String(e)}}return{status:`completed`,output:l}}async function In(e,t,n,r){if(e.role===void 0)return{status:`failed`,error:`No handler registered for station node '${e.id}'`};let i=e.outputSchema===void 0?void 0:{schema:e.outputSchema};return On({nodeId:e.id,nodeLabel:`Station node`,roleId:e.role,prompt:e.prompt,...i===void 0?{}:{outputSchema:i},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.completion===void 0?{}:{completion:e.completion},unresolvedRoleError:`No runtime handler registered for station node '${e.id}', and role '${e.role}' could not be resolved`,unavailableRuntimeError:`Subagent runtime is not available for station node '${e.id}'`,unavailableAwaitError:`Subagent runtime cannot await station node '${e.id}'`,cancellationLabel:`station`,...r===void 0?{}:{frameId:r}},t,n)}async function Ln(e,t,n,r){if(t.signal.aborted)return{status:`cancelled`};let i=await t.bus.requestOptional(E.resolveAgent,{agentId:e.agentId});if(!i.handled)return{status:`failed`,error:`Agent '${e.agentId}' could not be resolved for delegate-agent node '${e.id}'`};if(t.signal.aborted)return{status:`cancelled`};let a=Xn(e,n);if(a.status===`failed`)return a;let o=e.outputSchema===void 0?void 0:{schema:e.outputSchema};return B({nodeId:e.id,nodeLabel:`Delegate-agent node`,task:a.task,resolvedConfig:i.data,...o===void 0?{}:{outputSchema:o},unavailableRuntimeError:`Subagent runtime is not available for delegate-agent node '${e.id}'`,unavailableAwaitError:`Subagent runtime cannot await delegate-agent node '${e.id}'`,cancellationLabel:`delegate-agent`,...r===void 0?{}:{frameId:r}},t)}async function Rn(e,t,n,r){if(t.signal.aborted)return{status:`cancelled`};let i=await t.bus.requestOptional(E.resolveRole,{roleId:e.role});if(!i.handled)return{status:`failed`,error:`Role '${e.role}' could not be resolved for delegate-role node '${e.id}'`};let a=e.outputSchema===void 0?void 0:{schema:e.outputSchema},o=j(e.prompt,z(n)),s=Kn(e,i.data),c={node:e,task:o,resolvedRole:s,...a===void 0?{}:{outputSchema:a},...r===void 0?{}:{frameId:r}};return qn(s)?zn(c,t):B({nodeId:e.id,nodeLabel:`Delegate-role node`,task:o,resolvedConfig:s,...a===void 0?{}:{outputSchema:a},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},unavailableRuntimeError:`Subagent runtime is not available for delegate-role node '${e.id}'`,unavailableAwaitError:`Subagent runtime cannot await delegate-role node '${e.id}'`,cancellationLabel:`delegate-role`,...r===void 0?{}:{frameId:r}},t)}async function zn(e,t){let{node:n}=e,r=n.timeoutMs??3e5,i,a=Yn(t.signal);try{let n=await Bn(e,t);return`status`in n?n:(i=n.sessionId,t.signal.aborted?{status:`cancelled`}:await Vn(e,t,{abortLink:a,childSessionId:i,timeoutMs:r}))}catch(e){if(t.signal.aborted)return{status:`cancelled`};let r=e instanceof Error?e.message:String(e);return{status:`failed`,error:`Delegate-role node '${n.id}' session turn failed: ${r}`}}finally{a.controller.abort(),a.cleanup(),i!==void 0&&await H(t,n.id,i)}}async function Bn(e,t){let n=await t.bus.requestOptional(b.create,{sessionId:Wn(t,e),parentSessionId:t.execution.coordinatorSessionId??t.executionId,branchKind:`subagent`,title:`Workflow delegate-role '${e.node.id}'`});if(!n.handled)return{status:`failed`,error:`Session runtime is not available for delegate-role node '${e.node.id}'`};let r=n.data.sessionId;return await Jn(e,t,r),(await t.bus.requestOptional(b.agent.attachResolved,{sessionId:r,agent:Gn(e.resolvedRole),role:`lead`},{signal:t.signal}).catch(async n=>{throw await H(t,e.node.id,r),n})).handled?{sessionId:r}:(await H(t,e.node.id,r),{status:`failed`,error:`Session runtime cannot attach delegate-role node '${e.node.id}'`})}async function Vn(e,t,n){let r=t.bus.once(u.complete,{timeoutMs:n.timeoutMs,filter:{sessionId:n.childSessionId},signal:n.abortLink.controller.signal});r.catch(()=>void 0);let i=await Hn(e,t,n);if(`status`in i)return i;let a=await Un(e,t,n,i.turnId);if(a.status===`failed`)return a;let o=await r;return t.signal.aborted?{status:`cancelled`}:o.payload.outcome===`error`?{status:`failed`,error:`Delegate-role node '${e.node.id}' agent error: ${o.payload.error??`no result`}`}:{status:`completed`,output:o.payload.message??null}}async function Hn(e,t,n){let r=await t.bus.requestOptional(b.sendMessage,{sessionId:n.childSessionId,message:e.task,...e.outputSchema===void 0?{}:{responseSchema:e.outputSchema},source:`system`},{signal:t.signal});return r.handled?{turnId:r.data.turnId}:(n.abortLink.controller.abort(),{status:`failed`,error:`Session runtime cannot send delegate-role node '${e.node.id}'`})}async function Un(e,t,n,r){let i=await t.bus.requestOptional(b.turn.await,{sessionId:n.childSessionId,turnId:r,timeoutMs:n.timeoutMs},{timeout:0,signal:t.signal});return i.handled?i.data.completion.success?{status:`completed`}:{status:`failed`,error:`Delegate-role node '${e.node.id}' session turn failed: ${i.data.completion.error??`no result`}`}:(n.abortLink.controller.abort(),{status:`failed`,error:`Session runtime cannot await delegate-role node '${e.node.id}'`})}function Wn(e,t){return`session-workflow-${e.executionId}-${t.frameId??t.node.id}`}function Gn(e){return{kind:`adapter`,adapterName:e.adapterName,...e.model===void 0?{}:{model:e.model},...e.reasoningEffort===void 0?{}:{reasoningEffort:e.reasoningEffort},...e.systemPrompt===void 0?{}:{systemPrompt:e.systemPrompt},...e.providerContext===void 0?{}:{providerConfigId:e.providerContext.providerConfigId,providerContext:e.providerContext}}}function Kn(e,t){return e.completion===void 0?t:{...t,completion:e.completion}}function qn(e){return e.completion===`turn`&&e.harnessId===void 0&&e.contextMode===void 0}async function Jn(e,t,n){if(e.frameId!==void 0)try{await t.bus.emit(E.frame.sessionLinked,{executionId:t.executionId,frameId:e.frameId,sessionId:n})}catch(t){console.warn(`[workflow-engine] Failed to emit frame.sessionLinked for frame '${e.frameId}' and session '${n}'`,t)}}async function H(e,t,n){try{await e.bus.requestOptional(b.close,{sessionId:n})}catch(e){console.warn(`[workflow-engine] Failed to close delegate-role session '${n}' for node '${t}'`,e)}}function Yn(e){let t=new AbortController;if(e.aborted)return t.abort(),{controller:t,cleanup:()=>void 0};let n=()=>t.abort();return e.addEventListener(`abort`,n,{once:!0}),{controller:t,cleanup:()=>e.removeEventListener(`abort`,n)}}function Xn(e,t){try{let n=z(t);return{status:`completed`,task:Zn(e.inputExpression===void 0?n:A(e.inputExpression,n))}}catch(t){let n=t instanceof Error?t.message:String(t);return{status:`failed`,error:`delegate-agent node '${e.id}': input expression evaluation failed: ${n}`}}}function Zn(e){if(typeof e==`string`)return e;if(e===void 0)return``;try{return JSON.stringify(e,null,2)??``}catch{return String(e)}}function Qn(e,t,n,r){try{let i=A(n,z(r));return Array.isArray(i)?i:{status:`failed`,error:`${t} node '${e}': collection expression did not resolve to an array (got ${typeof i})`}}catch(n){return{status:`failed`,error:`${t} node '${e}': collection expression evaluation failed: ${n instanceof Error?n.message:String(n)}`}}}function $n(e,t,n){for(let r of[...e.nodes].reverse()){let e=n.getFramesByNodeId(r.id);for(let n of e)if(n.parentFrameId===t&&n.status===`completed`)return n.output}}function er(e,t,n){return $n(e.body,t,n)}function tr(e){if(e.length===0)return;let t=new Map,n=new Map;for(let r of e){n.set(r.frameId,r);let e=t.get(r.nodeId)??[];e.push(r),t.set(r.nodeId,e)}return{byNodeId:t,byFrameId:n}}const nr=new Set([`completed`,`skipped`,`waiting`]);function U(e,t,n){let r=e?.byNodeId.get(t)??[],i=n.statuses??nr;return r.find(e=>e.parentFrameId===n.parentFrameId&&e.branchKey===n.branchKey&&e.iteration===n.iteration&&i.has(e.status))}function W(e,t,n){let r={...e.frames,[t]:n};return{...e,frames:r,previousSteps:on(r),output:n.status===`completed`?n.output:e.output}}function G(e,t){if(typeof AbortSignal.any==`function`)return AbortSignal.any([e,t]);let n=new AbortController,r=()=>n.abort();return e.addEventListener(`abort`,r,{once:!0}),t.addEventListener(`abort`,r,{once:!0}),n.signal}const rr=new Set([`completed`,`running`]);function ir(e,t){return e.status===`running`&&t.pauseSignal?.aborted===!0&&!t.outerSignal.aborted}async function ar(e,t,n,r,i,a,o=`all-settled`){if(t.signal.aborted)return{status:`cancelled`};let s=Object.entries(e.branches);if(s.length===0)return{status:`completed`,output:K({},o)};let c=new AbortController,l=new AbortController,u=t.suspensionStrategy!==`wait-in-process`,d=o===`fail-fast`?G(c.signal,l.signal):u?l.signal:void 0,f=d===void 0?t.signal:G(t.signal,d),p=f===t.signal?t:t.withSignal(f),m=s.map(([s,c])=>or(s,c,e,p,n,r,i,a,{outerSignal:t.signal,pauseSignal:o===`fail-fast`||u?l.signal:void 0}));if(o===`all-settled`){let e=await Promise.all(u?m.map(e=>e.then(e=>(e.status===`paused`&&l.abort(),e))):m),t=e.find(e=>e.status===`paused`);return t===void 0?{status:`completed`,output:K(cr(s,e),o)}:t}let h=await sr(s,m,c,l);return h.type===`cancelled`?{status:`cancelled`}:h.type===`paused`?h.outcome:h.type===`failed`?{status:`failed`,error:h.error}:{status:`completed`,output:K(cr(s,h.outcomes),o)}}async function or(e,t,n,r,i,a,o,s,c){if(r.signal.aborted)return{status:`cancelled`};let l=U(r.resumeFrames,n.id,{parentFrameId:o,branchKey:e,statuses:rr});if(l?.status===`completed`)return{status:`completed`,...l.output===void 0?{}:{output:l.output}};let u=l??r.createFrame({nodeId:n.id,nodeType:`parallel`,path:s,parentFrameId:o,branchKey:e});if(r.signal.aborted)return ir(u,c)||await $(u,r),{status:`cancelled`};l===void 0&&await X(u,r);let d;try{d=await a(t,r,i,u.frameId,u.path)}catch(e){let t=e instanceof Error?e.message:String(e);return await Q(u,r,t),{status:`failed`,error:t}}switch(d.status){case`completed`:{let e=$n(t,u.frameId,r);return await Z(u,r,e),{status:`completed`,output:e}}case`skipped`:return await Z(u,r),{status:`completed`};case`cancelled`:return ir(u,c)||await $(u,r),{status:`cancelled`};case`paused`:return d;case`failed`:return await Q(u,r,d.error),{status:`failed`,error:d.error}}}async function sr(e,t,n,r){let i,a,o=t.map(e=>e.then(e=>(e.status===`failed`&&i===void 0?(i=e.error,n.abort()):e.status===`paused`&&a===void 0&&(a=e,r.abort()),e),e=>{let t=e instanceof Error?e.message:String(e);return i===void 0&&(i=t,n.abort()),{status:`failed`,error:t}})),s=await Promise.all(o);return a===void 0?s.some(e=>e.status===`cancelled`)&&i===void 0?{type:`cancelled`}:i===void 0?{type:`completed`,outcomes:s}:{type:`failed`,error:i}:{type:`paused`,outcome:a}}function K(e,t){return{mode:t,branches:e}}function cr(e,t){let n={};for(let r=0;r<e.length;r++){let[i]=e[r],a=t[r];n[i]=lr(a)}return n}function lr(e){switch(e.status){case`completed`:return{status:`fulfilled`,...e.output===void 0?{}:{value:e.output}};case`skipped`:return{status:`fulfilled`,value:null};case`cancelled`:return{status:`cancelled`};case`paused`:return{status:`paused`,pausedAtGateId:e.pausedAtGateId,pausedAtFrameId:e.pausedAtFrameId};case`failed`:return{status:`rejected`,reason:e.error}}}const ur=new Ke.default({allErrors:!0,strict:!1});function dr(e,t){if(t===void 0)return{status:`ok`};try{return{status:`ok`,validator:ur.compile(t)}}catch(t){return{status:`failed`,error:`Gate '${e}' has an invalid resumeSchema: ${t instanceof Error?t.message:String(t)}`}}}function fr(e,t){return e===void 0||e(t)?{valid:!0}:{valid:!1,error:mr(e.errors??[])}}function pr(e,t,n){let r=dr(e,t);return r.status===`failed`?{valid:!1,error:r.error}:fr(r.validator,n)}function mr(e){return e.length===0?`schema validation failed`:e.map(e=>`${e.instancePath.length>0?e.instancePath:`/`} ${e.message??`is invalid`}`).join(`; `)}const hr={action:`approve`,source:`timeout`};function gr(e){return e===void 0?{}:{reason:e}}async function _r(e,t,n,r){let i=()=>{t.value&&(t.value=!1,e.reject(`cancelled`))};n.addEventListener(`abort`,i,{once:!0}),n.aborted&&i();let a=[e.promise],o;if(r!==null){let e=xr();o=setTimeout(()=>{t.value&&(t.value=!1,n.removeEventListener(`abort`,i),e.reject(`timed-out`))},r),a.push(e.promise)}try{let e=await Promise.race(a);return n.removeEventListener(`abort`,i),o!==void 0&&clearTimeout(o),{action:e.action,resumeData:e.resumeData,timedOut:!1,wasCancelled:!1,reason:e.reason}}catch(e){return o!==void 0&&clearTimeout(o),n.removeEventListener(`abort`,i),e===`timed-out`?{action:`reject`,resumeData:null,timedOut:!0,wasCancelled:!1}:{action:`reject`,resumeData:null,timedOut:!1,wasCancelled:!0}}}async function vr(e,t,n,r,i,a){let o={required:e.suspensionStrategy!==`wait-in-process`};if(a.timedOut){let a=Date.now();if(r.autoAction===`approve`){let s=fr(i,hr);return s.valid?(await q(e,{...r,status:`resumed`,resumeData:hr,resolvedAt:a},o),await J(e,t.id,n,{action:`approve`,source:`timeout`}),{status:`completed`,output:{resumeData:hr}}):(await q(e,{...r,status:`timed-out`,resolvedAt:a},o),await J(e,t.id,n,{action:`reject`,source:`timeout`}),{status:`failed`,error:`Gate '${t.id}' auto-approve timeout resume data does not match resumeSchema: ${s.error}`})}return await q(e,{...r,status:`timed-out`,resolvedAt:a},o),await J(e,t.id,n,{action:`reject`,source:`timeout`}),{status:`failed`,error:`Gate '${t.id}' timed out after ${String(r.timeoutMs)}ms and auto-rejected`}}if(a.wasCancelled||e.signal.aborted)return await q(e,{...r,status:`cancelled`,resolvedAt:Date.now()},o),await J(e,t.id,n,{source:`cancelled`}),{status:`cancelled`};let s=Date.now();await q(e,{...r,status:a.action===`reject`?`rejected`:`resumed`,resumeData:a.resumeData,...gr(a.reason),resolvedAt:s},o);try{await e.bus.emit(E.gate.resumed,{executionId:e.executionId,frameId:n,nodeId:t.id,resumeData:a.resumeData}),await J(e,t.id,n,{action:a.action,source:`user`,...gr(a.reason)})}catch(e){console.error(`[GateNode] gate.resumed emit failed for '${t.id}':`,e)}return{status:`completed`,output:{resumeData:a.resumeData}}}async function yr(e,t,n,r){if(t.signal.aborted)return{status:`cancelled`};let i=e.resumeSchema??{};if(t.suspensionStrategy!==`wait-in-process`){let n=await wr(t,e,r);if(n!==void 0)return n}let a=dr(e.id,e.resumeSchema);return a.status===`failed`?{status:`failed`,error:a.error}:br(t,e,n,r,i,a.validator)}async function br(e,t,n,r,i,a){let o=j(t.prompt,z(n)),s={executionId:e.executionId,nodeId:t.id,frameId:r,schema:i,prompt:o,status:`waiting`,autoAction:t.autoAction,timeoutMs:t.timeoutMs,createdAt:Date.now()},c=e.suspensionStrategy!==`wait-in-process`;if(await q(e,s,{required:c}),await e.updateFrame(r,{status:`waiting`},{requireFrameStorage:c}),c)return await Sr(e,t,r,i,o,s.createdAt),{status:`paused`,pausedAtGateId:t.id,pausedAtFrameId:r};let u={value:!0},d=xr(),f=e.bus.on(E.gate.respond,async n=>{let{executionId:i,gateId:o,frameId:s,action:c,resumeData:f,reason:p}=n.payload;if(i!==e.executionId||o!==t.id||s!==void 0&&s!==r){try{await n.next()}catch(e){if(e instanceof l)n.setResult({accepted:!1});else throw e}return}if(!u.value){n.setResult({accepted:!1});return}if(!fr(a,f).valid){n.setResult({accepted:!1});return}u.value=!1,n.setResult({accepted:!0}),d.resolve({action:c,resumeData:f,reason:p})});await Sr(e,t,r,i,o,s.createdAt);let p=await _r(d,u,e.signal,t.timeoutMs);return f(),vr(e,t,r,s,a,p)}function xr(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}async function Sr(e,t,n,r,i,a){try{await e.bus.emit(E.gate.suspended,{executionId:e.executionId,frameId:n,nodeId:t.id,schema:r,prompt:i,...t.title!==void 0&&{title:t.title},autoAction:t.autoAction,timeoutMs:t.timeoutMs,openedAt:a})}catch(e){console.error(`[GateNode] gate.suspended emit failed for '${t.id}':`,e)}}async function Cr(e,t,n){if(e.suspensionStrategy!==`wait-in-process`)return(await e.bus.request(N.getGateInstance,{executionId:e.executionId,nodeId:t,frameId:n})).gate;let r=await e.bus.requestOptional(N.getGateInstance,{executionId:e.executionId,nodeId:t,frameId:n});return r.handled?r.data.gate:null}async function wr(e,t,n){let r=await Cr(e,t.id,n);if((r?.status===`resumed`||r?.status===`rejected`)&&r.resumeData!==void 0){let i=pr(t.id,r.schema,r.resumeData);if(!i.valid)return{status:`failed`,error:`Gate '${t.id}' persisted resumeData is invalid: ${i.error}`};try{await e.bus.emit(E.gate.resumed,{executionId:e.executionId,frameId:n,nodeId:t.id,resumeData:r.resumeData})}catch(e){console.error(`[GateNode] gate.resumed emit failed for '${t.id}':`,e)}return await J(e,t.id,n,{action:r.status===`rejected`?`reject`:`approve`,source:`user`,...gr(r.reason)}),{status:`completed`,output:{resumeData:r.resumeData}}}if(r?.status===`waiting`){if(r.timeoutMs!==null&&Date.now()>=r.createdAt+r.timeoutMs){let i=dr(t.id,r.schema);return i.status===`failed`?{status:`failed`,error:i.error}:vr(e,t,n,r,i.validator,{action:`reject`,resumeData:null,timedOut:!0,wasCancelled:!1})}return{status:`paused`,pausedAtGateId:t.id,pausedAtFrameId:n}}if((r?.status===`resumed`||r?.status===`rejected`)&&r.resumeData===void 0)return{status:`failed`,error:`Gate '${t.id}' has status '${r.status}' but resumeData is missing — cannot reconstruct output`};if(r!==null)return{status:`failed`,error:`Gate '${t.id}' cannot resume from status '${r.status}'`}}async function q(e,t,n={}){try{n.required===!0?await e.bus.request(N.setGateInstance,{gate:t}):await e.bus.requestOptional(N.setGateInstance,{gate:t})}catch(e){if(n.required===!0)throw e;console.warn(`[GateNode] Failed to upsert gate instance for '${t.nodeId}':`,e)}}async function J(e,t,n,r){try{await e.bus.emit(E.gate.resolved,{executionId:e.executionId,stepId:t,stepType:`gate`,frameId:n,...r})}catch(e){console.error(`[GateNode] gate.resolved emit failed for '${t}':`,e)}}function Y(e){return{status:`fulfilled`,...e===void 0?{}:{value:e}}}const Tr=new Set([`completed`,`running`]);function Er(e,t){return e.status===`running`&&t.pauseSignal?.aborted===!0&&!t.outerSignal.aborted}async function Dr(e,t,n,r,i,a){if(t.signal.aborted)return{status:`cancelled`};let o=Qn(e.id,`iterate`,e.collection,n);if(!Array.isArray(o))return o;let s=o;if(s.length===0)return{status:`completed`,output:jr([])};let c=await Or(s,e,t,n,r,i,a,e.concurrency!==void 0&&e.concurrency>0?e.concurrency:0);if(t.signal.aborted&&c.every(e=>e.status===`cancelled`))return{status:`cancelled`};let l=c.find(e=>e.status===`paused`);return l===void 0?{status:`completed`,output:jr(c)}:{status:`paused`,pausedAtGateId:l.pausedAtGateId,pausedAtFrameId:l.pausedAtFrameId}}async function Or(e,t,n,r,i,a,o,s){let c=new AbortController,l=n.suspensionStrategy!==`wait-in-process`,u=l?G(n.signal,c.signal):n.signal,d=u===n.signal?n:n.withSignal(u),f={outerSignal:n.signal,...l?{pauseSignal:c.signal}:{}};if(s===0){let n=e.map((e,n)=>Ar(e,n,t,d,r,i,a,o,f));return Promise.all(l?n.map(e=>kr(e,c)):n)}let p=Array(e.length);for(let n=0;n<e.length;n+=s){if(d.signal.aborted){for(let t=n;t<e.length;t++)p[t]={status:`cancelled`};break}let u=Math.min(n+s,e.length),m=[];for(let s=n;s<u;s++)m.push(Ar(e[s],s,t,d,r,i,a,o,f));let h=await Promise.all(l?m.map(e=>kr(e,c)):m);for(let e=0;e<h.length;e++)p[n+e]=h[e];if(h.some(e=>e.status===`paused`)){for(let t=u;t<e.length;t++)p[t]={status:`cancelled`};break}}return p}function kr(e,t){return e.then(e=>(e.status===`paused`&&t.abort(),e))}async function Ar(e,t,n,r,i,a,o,s,c){if(r.signal.aborted)return{status:`cancelled`};let l={...i,item:e,index:t},u=U(r.resumeFrames,n.id,{parentFrameId:o,iteration:t,statuses:Tr});if(u?.status===`completed`)return Y(u.output);let d=u??r.createFrame({nodeId:n.id,nodeType:`iterate`,path:s,parentFrameId:o,iteration:t});if(r.signal.aborted)return Er(d,c)||await $(d,r),{status:`cancelled`};u===void 0&&await X(d,r);let f;try{f=await a(n.body,r,l,d.frameId,d.path)}catch(e){let t=e instanceof Error?e.message:String(e);return await Q(d,r,t),{status:`rejected`,reason:t}}switch(f.status){case`completed`:{let e=er(n,d.frameId,r);return await Z(d,r,e),Y(e)}case`skipped`:return await Z(d,r),Y();case`cancelled`:return Er(d,c)||await $(d,r),{status:`cancelled`};case`paused`:return f;case`failed`:return await Q(d,r,f.error),{status:`rejected`,reason:f.error}}}function jr(e){return{items:e}}const Mr=new Set([`completed`,`running`]);async function Nr(e,t,n,r,i,a){if(t.signal.aborted)return{status:`cancelled`};let o=Qn(e.id,`iterate-chain`,e.collection,n);if(!Array.isArray(o))return o;let s=o;if(s.length===0)return{status:`completed`,output:Fr([])};let c=[],l;for(let o=0;o<s.length;o++){if(t.signal.aborted)return{status:`cancelled`};let u=s[o],d=await Pr(u,o,l,e,t,n,r,i,a);switch(c.push(d),d.status){case`fulfilled`:l=d.value;break;case`rejected`:return{status:`failed`,error:d.reason};case`cancelled`:return{status:`cancelled`};case`paused`:return{status:`paused`,pausedAtGateId:d.pausedAtGateId,pausedAtFrameId:d.pausedAtFrameId}}}return{status:`completed`,output:Fr(c)}}async function Pr(e,t,n,r,i,a,o,s,c){if(i.signal.aborted)return{status:`cancelled`};let l={...a,item:e,index:t,...n!==void 0&&{previous:n}},u=U(i.resumeFrames,r.id,{parentFrameId:s,iteration:t,statuses:Mr});if(u?.status===`completed`)return Y(u.output);let d=u??i.createFrame({nodeId:r.id,nodeType:`iterate-chain`,path:c,parentFrameId:s,iteration:t});if(i.signal.aborted)return await $(d,i),{status:`cancelled`};u===void 0&&await X(d,i);let f;try{f=await o(r.body,i,l,d.frameId,d.path)}catch(e){let t=e instanceof Error?e.message:String(e);return await Q(d,i,t),{status:`rejected`,reason:t}}switch(f.status){case`completed`:{let e=er(r,d.frameId,i);return await Z(d,i,e),Y(e)}case`skipped`:return await Z(d,i),Y();case`cancelled`:return await $(d,i),{status:`cancelled`};case`paused`:return f;case`failed`:return await Q(d,i,f.error),{status:`rejected`,reason:f.error}}}function Fr(e){return{items:e}}async function X(e,t){e.status=`running`,e.startedAt=Date.now(),await t.persistFrame(e),await t.emitFrameStarted(e)}async function Z(e,t,n){let r=Date.now(),i=e.startedAt===void 0?void 0:Math.max(0,r-e.startedAt);e.status=`completed`,e.output=n,e.completedAt=r,await t.persistFrame(e),await t.emitFrameCompleted(e,i)}async function Q(e,t,n){let r=Date.now(),i=e.startedAt===void 0?void 0:Math.max(0,r-e.startedAt);e.status=`failed`,e.error=n,e.completedAt=r,await t.persistFrame(e),await t.emitFrameFailed(e,n,i)}async function Ir(e,t){e.status=`skipped`,e.completedAt=Date.now(),await t.persistFrame(e)}async function $(e,t){e.status=`cancelled`,e.completedAt=Date.now(),await t.persistFrame(e)}function Lr(e,t){return!!A(e,z(t))}async function Rr(e,t,n,r,i,a=[]){if(t.signal.aborted)return{status:`cancelled`};switch(e.type){case`sequence`:return r(e,t,n,i,a);case`station`:return Fn(e,t,n,i);case`delegate-agent`:return Ln(e,t,n,i);case`delegate-role`:return Rn(e,t,n,i);case`parallel`:return ar(e,t,n,r,i??``,a,e.mode??`all-settled`);case`gate`:return yr(e,t,n,i??``);case`iterate`:return Dr(e,t,n,r,i??``,a);case`iterate-chain`:return Nr(e,t,n,r,i??``,a);default:return{status:`failed`,error:`Unknown node type: ${String(e.type)}`}}}const zr=new Set([`completed`,`skipped`,`waiting`,`running`]);function Br(e){return e.type===`parallel`||e.type===`iterate`||e.type===`iterate-chain`}function Vr(e,t,n){return U(e.resumeFrames,t.id,{parentFrameId:n,...Br(t)?{statuses:zr}:{}})}function Hr(e,t,n){if(n?.status===`completed`)return W(e,t.id,{status:`completed`,...n.output===void 0?{}:{output:n.output}});if(n?.status===`skipped`)return W(e,t.id,{status:`skipped`})}async function Ur(e,t,n,r,i,a,o){try{return{result:Lr(e,i)}}catch(e){let i=e instanceof Error?e.message:String(e);return await Q(r.createFrame({nodeId:n.id,nodeType:n.type,path:a,parentFrameId:o}),r,`'${t}' condition evaluation failed: ${i}`),{status:`failed`,error:`'${t}' condition evaluation failed for '${n.id}': ${i}`}}}async function Wr(e,t,n,r,i,a){let o=a??t.createFrame({nodeId:e.id,nodeType:e.type,path:r,parentFrameId:i});if(t.signal.aborted)return await $(o,t),{updatedCtx:n,outcome:{status:`cancelled`}};a===void 0&&await X(o,t);let s;try{s=await Rr(e,t,n,Gr,o.frameId,o.path)}catch(e){let r=e instanceof Error?e.message:String(e);return await Q(o,t,r),{updatedCtx:n,outcome:{status:`failed`,error:r}}}switch(s.status){case`completed`:return await Z(o,t,s.output),{updatedCtx:W(n,e.id,{status:`completed`,output:s.output})};case`skipped`:return await Ir(o,t),{updatedCtx:W(n,e.id,{status:`skipped`})};case`cancelled`:return await $(o,t),{updatedCtx:n,outcome:{status:`cancelled`}};case`paused`:return{updatedCtx:n,outcome:s};case`failed`:return await Q(o,t,s.error),{updatedCtx:n,outcome:{status:`failed`,error:s.error}}}}async function Gr(e,t,n,r,i=[]){let a=n;for(let n of e.nodes){if(t.signal.aborted)return{status:`cancelled`};let e=Vr(t,n,r),o=Hr(a,n,e);if(o!==void 0){a=o;continue}if(n.when!==void 0){let e=await Ur(n.when,`when`,n,t,a,i,r);if(`status`in e)return e;if(!e.result){await Ir(t.createFrame({nodeId:n.id,nodeType:n.type,path:i,parentFrameId:r}),t),a=W(a,n.id,{status:`skipped`});continue}}if(n.skip!==void 0){let e=await Ur(n.skip,`skip`,n,t,a,i,r);if(`status`in e)return e;if(e.result){await Ir(t.createFrame({nodeId:n.id,nodeType:n.type,path:i,parentFrameId:r}),t),a=W(a,n.id,{status:`skipped`});continue}}let s=e?.status===`waiting`&&n.type===`gate`||e?.status===`running`&&Br(n)?e:void 0,{updatedCtx:c,outcome:l}=await Wr(n,t,a,i,r,s);if(a=c,l!==void 0)return l}return{status:`completed`}}export{Ue as A,Le as B,ye as C,Oe as D,ke as E,we as F,Re as G,Fe as H,je as I,E as J,Ne as K,Ae as L,xe as M,M as N,Ve as O,Te as P,De as R,be as S,Se as T,Pe as U,Ie as V,ze as W,lt as _,dn as a,Ge as b,an as c,Ft as d,Ot as f,ft as g,L as h,vn as i,He as j,Be as k,tn as l,ht as m,pr as n,Vt as o,_t as p,Me as q,tr as r,en as s,Gr as t,Bt as u,et as v,Ce as w,N as x,qe as y,Ee as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./version-
|
|
1
|
+
import{t as e}from"./version-SYP_DX4M.mjs";import{z as t}from"zod";import*as n from"node:path";const r=t.string().trim().min(1),i=t.number().int().finite().nonnegative().describe(`Unix epoch timestamp in milliseconds`);function a(e){return n.posix.isAbsolute(e)||n.win32.isAbsolute(e)}const o=t.string().trim().min(1).refine(a,{message:`Path must be absolute`}),s=t.string().min(1).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/,`Profile name must be a safe path component`),c=s,l=t.object({id:r,clientId:r,name:s,description:t.string().nullable(),configDir:o,isDefault:t.boolean(),createdAt:i,updatedAt:i}),u=t.record(t.string(),t.string()),d=t.enum([`auth-only`,`full`,`empty`]),f={"profile.create":{request:t.object({clientId:r,name:s,description:t.string().optional()}),response:t.object({profile:l})},"profile.list":{request:t.object({clientId:r}),response:t.object({profiles:t.array(l)})},"profile.get":{request:t.object({clientId:r,name:s}),response:t.object({profile:l.nullable()})},"profile.update":{request:t.object({clientId:r,name:s,description:t.string().optional()}),response:t.object({profile:l})},"profile.delete":{request:t.object({clientId:r,name:s}),response:t.object({success:t.boolean()})},"profile.setDefault":{request:t.object({clientId:r,name:s}),response:t.object({profile:l})}},p={"sessionConfig.create":{request:t.object({clientId:r,sessionId:c,profileName:s.optional(),baseConfigDir:o.optional(),projectDir:o.optional(),configInheritance:d.optional()}),response:t.object({sessionDir:o,env:u})},"sessionConfig.destroy":{request:t.object({clientId:r,sessionId:c}),response:t.object({success:t.boolean()})},"sessionConfig.cleanup":{request:t.object({clientId:r.optional()}),response:t.object({removed:t.array(o)})}},m=t.object({sessionDir:o,baseConfigDir:o,projectDir:o.optional(),platform:t.enum([`darwin`,`linux`,`win32`]),configInheritance:d}),h=t.object({sessionDir:o,platform:t.enum([`darwin`,`linux`,`win32`])}),g=t.object({success:t.boolean()}),_=t.object({env:t.record(t.string(),t.string()).optional()}),v=t.enum([`managed-install`,`profile-create`,`session-create`]),y={request:t.object({clientId:r,configDir:o,phase:v,binaryVersion:e.optional(),adapterName:t.string().min(1).optional(),projectDir:o.optional()}),response:t.object({primed:t.boolean()})};export{a as _,f as a,c,_ as d,h as f,r as g,i as h,l as i,d as l,o as m,y as n,p as o,g as p,s as r,u as s,v as t,m as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./namespace-
|
|
1
|
+
import{n as e}from"./namespace-FJsnoEQy.mjs";import{CredentialSubjects as t}from"@makaio/framework/contracts";async function n(t,n){let{context:r}=await t.request(e.buildProviderContext,{providerConfigId:n});if(!r)throw Error(`[buildProviderContext] ProviderConfig '${n}' not found`);return r}function r(e){return{providerConfigId:e.providerConfigId,definitionId:e.definitionId,credentialRefs:e.credentialRefs}}async function i(e,n){await e.request(t.activate,r(n))}async function a(e,n){try{if(!(await e.requestOptional(t.activate,r(n))).handled)return}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[activateProviderContext] credential.activate handler failed:`,t)}}async function o(e,t){await i(e,t)}export{o as n,n as r,a as t};
|
package/dist/rules/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as RuleSetOptions, S as Rule, _ as JsonObjectShape, a as JsonObjectSchema, b as NotCondition, c as RuleSetOptionsSchema, d as CompoundCondition, f as Condition, g as JsonObject, h as FieldOperator, i as FieldOperatorSchema, l as ScalarValueSchema, m as FieldCondition, n as ExpressionConditionSchema, o as JsonValueSchema, p as ExpressionCondition, r as FieldConditionSchema, s as RuleSchema, t as ConditionSchema, u as AndCondition, v as JsonPrimitive, w as ScalarValue, x as OrCondition, y as JsonValue } from "../schemas-
|
|
1
|
+
import { C as RuleSetOptions, S as Rule, _ as JsonObjectShape, a as JsonObjectSchema, b as NotCondition, c as RuleSetOptionsSchema, d as CompoundCondition, f as Condition, g as JsonObject, h as FieldOperator, i as FieldOperatorSchema, l as ScalarValueSchema, m as FieldCondition, n as ExpressionConditionSchema, o as JsonValueSchema, p as ExpressionCondition, r as FieldConditionSchema, s as RuleSchema, t as ConditionSchema, u as AndCondition, v as JsonPrimitive, w as ScalarValue, x as OrCondition, y as JsonValue } from "../schemas-DznsZ0bq.mjs";
|
|
2
2
|
|
|
3
3
|
//#region packages/rules/src/evaluator.d.ts
|
|
4
4
|
/**
|
package/dist/rules/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../esm-
|
|
1
|
+
import{t as e}from"../esm-CP2zvvlx.mjs";import{ConditionSchema as t,ExpressionConditionSchema as n,FieldConditionSchema as r,FieldOperatorSchema as i,JsonObjectSchema as a,JsonValueSchema as o,RuleSchema as s,RuleSetOptionsSchema as c,ScalarValueSchema as l}from"./schemas.mjs";import{compile as u}from"@makaio/framework/expression";const d=new Map,f=new Map;function p(e,t){if(`$and`in e){for(let n of e.$and)if(!p(n,t))return!1;return!0}if(`$or`in e){for(let n of e.$or)if(p(n,t))return!0;return!1}return`$not`in e?!p(e.$not,t):`$expr`in e?!!_(e.$expr).evalSync(t):h(g(t,e.field),e.operator)}function m(e,t,n={}){let{includeDisabled:r=!1}=n,i=[];for(let n of e)!r&&!n.enabled||p(n.condition,t)&&i.push(n);return i}function h(e,t){if(typeof t!=`object`||!t)return e===t;if(`$eq`in t)return e===t.$eq;if(`$ne`in t)return e!==t.$ne;if(`$in`in t)return t.$in.includes(e);if(`$nin`in t)return!t.$nin.includes(e);if(`$exists`in t){let n=e!==void 0;return t.$exists?n:!n}return`$startsWith`in t?typeof e==`string`&&e.startsWith(t.$startsWith):`$endsWith`in t?typeof e==`string`&&e.endsWith(t.$endsWith):`$glob`in t?typeof e==`string`&&v(t.$glob).match(e):!1}function g(e,t){if(e==null)return;let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return;r=r[e]}return r}function _(e){return y(d,e,()=>u(e))}function v(t){return y(f,t,()=>new e(t))}function y(e,t,n){let r=e.get(t);if(r!==void 0)return e.delete(t),e.set(t,r),r;let i=n();if(e.set(t,i),e.size>256){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return i}export{t as ConditionSchema,n as ExpressionConditionSchema,r as FieldConditionSchema,i as FieldOperatorSchema,a as JsonObjectSchema,o as JsonValueSchema,s as RuleSchema,c as RuleSetOptionsSchema,l as ScalarValueSchema,p as evaluate,m as evaluateRules};
|
package/dist/rules/schemas.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as JsonObjectSchema, c as RuleSetOptionsSchema, i as FieldOperatorSchema, l as ScalarValueSchema, n as ExpressionConditionSchema, o as JsonValueSchema, r as FieldConditionSchema, s as RuleSchema, t as ConditionSchema } from "../schemas-
|
|
1
|
+
import { a as JsonObjectSchema, c as RuleSetOptionsSchema, i as FieldOperatorSchema, l as ScalarValueSchema, n as ExpressionConditionSchema, o as JsonValueSchema, r as FieldConditionSchema, s as RuleSchema, t as ConditionSchema } from "../schemas-DznsZ0bq.mjs";
|
|
2
2
|
export { ConditionSchema, ExpressionConditionSchema, FieldConditionSchema, FieldOperatorSchema, JsonObjectSchema, JsonValueSchema, RuleSchema, RuleSetOptionsSchema, ScalarValueSchema };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DispatchingAuth as e,createWebSocketCloseEvent as t}from"@makaio/framework/node/transports";import{HonoWebSocketBridge as n,startBusServer as r}from"@makaio/framework/node/bus-server";import{ExplicitDescriptorDiscovery as i,FileConfigStorage as a,FileRegistryCache as o,FilesystemDescriptorDiscovery as s,NodeCredentialProvider as c,StoredCredentialProvider as l,bootMakaioRuntimeCore as u,bootMakaioRuntimeCore as d,bridgeExtensionBrowserEntries as f,createHonoRouteGraph as p,createHttpRouteGraphBuilder as m,entrypointStem as h,isCliContributionLike as g,isMakaioExtensionLike as _,isMissingOptionalRuntimePackage as v,isWithinDirectory as y,loadExtensions as b,loadOrCreateMachineIdentity as x,machineKeysExist as S,registerAdapterNameResolver as C,resolveConventionEntrypoint as w,resolveStaticModelRegistryPath as T,runMigrations as E,tryImport as D,validateMachineKeys as O}from"@makaio/framework/runtime-node";import{isIP as k}from"node:net";var A=class{raw;eventListeners={message:new Set,close:new Set,error:new Set,open:new Set};constructor(e){this.raw=e}get readyState(){return this.raw.readyState}send(e){if(typeof e==`string`){this.raw.send(e);return}if(e instanceof Blob){e.arrayBuffer().then(e=>{this.raw.readyState===1&&this.raw.send(new Uint8Array(e))}).catch(()=>{this.dispatchError()});return}if(e instanceof ArrayBuffer){this.raw.send(new Uint8Array(e));return}ArrayBuffer.isView(e)&&this.raw.send(e)}close(e,t){this.raw.close(e,t)}addEventListener(e,t){this.eventListeners[e]?.add(t)}removeEventListener(e,t){this.eventListeners[e]?.delete(t)}dispatchMessage(e){let t=new MessageEvent(`message`,{data:e});for(let e of this.eventListeners.message)e(t)}dispatchClose(e,n){let r=t(e,n);for(let e of this.eventListeners.close)e(r)}dispatchError(){let e=new Event(`error`);for(let t of this.eventListeners.error)t(e)}},j=class{options;bridge;busServer=null;busReady=!1;connecting=!1;constructor(e){this.options=e,this.bridge=new n}get dispatchingAuth(){return this.options.auth instanceof e?this.options.auth:void 0}createWebSocketHandler(){let e=this.bridge,t=()=>this.busReady,n=new WeakMap;return{binaryType:`arraybuffer`,open(r){if(!t()){r.close(1013,`Bus server not ready`);return}let i=new A(r);n.set(r,i),e.accept(i)},message(e,t){n.get(e)?.dispatchMessage(t)},close(e,t,r){n.get(e)?.dispatchClose(t,r),n.delete(e)}}}async connect(e,t){if(this.connecting||this.busServer)throw Error(`[BunBusServerTransport] connect() called while transport is already connected or connecting`);this.connecting=!0;try{this.busServer=await r({websocket:this.bridge,bus:e,auth:this.options.auth,loopbackName:this.options.loopbackName??`bun`}),this.busReady=!0}catch(e){throw await this.stopBusServer(`startup error`),e}finally{this.connecting=!1}}async disconnect(){await this.stopBusServer(`shutdown`),this.bridge.close()}async stopBusServer(e){this.busReady=!1,this.busServer&&=(await this.busServer.stop().catch(t=>{console.error(`[BunBusServerTransport] Failed to stop bus server during ${e}:`,t)}),null)}};function M(e){if(e.headers.get(`upgrade`)?.toLowerCase()!==`websocket`)return!1;let{pathname:t}=new URL(e.url);return t===`/bus`?!0:t===`/`&&e.headers.get(`origin`)===null}function N(e){return(t,n)=>M(t)?n.upgrade(t)?void 0:new Response(`WebSocket upgrade failed`,{status:426,headers:{Upgrade:`websocket`}}):e.fetch(t)}function ee(e){return e.port}async function P(e){let{port:t,hostname:n}=e.bunServer,r=e.createMount??(await import(`../create-static-mount-
|
|
1
|
+
import{DispatchingAuth as e,createWebSocketCloseEvent as t}from"@makaio/framework/node/transports";import{HonoWebSocketBridge as n,startBusServer as r}from"@makaio/framework/node/bus-server";import{ExplicitDescriptorDiscovery as i,FileConfigStorage as a,FileRegistryCache as o,FilesystemDescriptorDiscovery as s,NodeCredentialProvider as c,StoredCredentialProvider as l,bootMakaioRuntimeCore as u,bootMakaioRuntimeCore as d,bridgeExtensionBrowserEntries as f,createHonoRouteGraph as p,createHttpRouteGraphBuilder as m,entrypointStem as h,isCliContributionLike as g,isMakaioExtensionLike as _,isMissingOptionalRuntimePackage as v,isWithinDirectory as y,loadExtensions as b,loadOrCreateMachineIdentity as x,machineKeysExist as S,registerAdapterNameResolver as C,resolveConventionEntrypoint as w,resolveStaticModelRegistryPath as T,runMigrations as E,tryImport as D,validateMachineKeys as O}from"@makaio/framework/runtime-node";import{isIP as k}from"node:net";var A=class{raw;eventListeners={message:new Set,close:new Set,error:new Set,open:new Set};constructor(e){this.raw=e}get readyState(){return this.raw.readyState}send(e){if(typeof e==`string`){this.raw.send(e);return}if(e instanceof Blob){e.arrayBuffer().then(e=>{this.raw.readyState===1&&this.raw.send(new Uint8Array(e))}).catch(()=>{this.dispatchError()});return}if(e instanceof ArrayBuffer){this.raw.send(new Uint8Array(e));return}ArrayBuffer.isView(e)&&this.raw.send(e)}close(e,t){this.raw.close(e,t)}addEventListener(e,t){this.eventListeners[e]?.add(t)}removeEventListener(e,t){this.eventListeners[e]?.delete(t)}dispatchMessage(e){let t=new MessageEvent(`message`,{data:e});for(let e of this.eventListeners.message)e(t)}dispatchClose(e,n){let r=t(e,n);for(let e of this.eventListeners.close)e(r)}dispatchError(){let e=new Event(`error`);for(let t of this.eventListeners.error)t(e)}},j=class{options;bridge;busServer=null;busReady=!1;connecting=!1;constructor(e){this.options=e,this.bridge=new n}get dispatchingAuth(){return this.options.auth instanceof e?this.options.auth:void 0}createWebSocketHandler(){let e=this.bridge,t=()=>this.busReady,n=new WeakMap;return{binaryType:`arraybuffer`,open(r){if(!t()){r.close(1013,`Bus server not ready`);return}let i=new A(r);n.set(r,i),e.accept(i)},message(e,t){n.get(e)?.dispatchMessage(t)},close(e,t,r){n.get(e)?.dispatchClose(t,r),n.delete(e)}}}async connect(e,t){if(this.connecting||this.busServer)throw Error(`[BunBusServerTransport] connect() called while transport is already connected or connecting`);this.connecting=!0;try{this.busServer=await r({websocket:this.bridge,bus:e,auth:this.options.auth,loopbackName:this.options.loopbackName??`bun`}),this.busReady=!0}catch(e){throw await this.stopBusServer(`startup error`),e}finally{this.connecting=!1}}async disconnect(){await this.stopBusServer(`shutdown`),this.bridge.close()}async stopBusServer(e){this.busReady=!1,this.busServer&&=(await this.busServer.stop().catch(t=>{console.error(`[BunBusServerTransport] Failed to stop bus server during ${e}:`,t)}),null)}};function M(e){if(e.headers.get(`upgrade`)?.toLowerCase()!==`websocket`)return!1;let{pathname:t}=new URL(e.url);return t===`/bus`?!0:t===`/`&&e.headers.get(`origin`)===null}function N(e){return(t,n)=>M(t)?n.upgrade(t)?void 0:new Response(`WebSocket upgrade failed`,{status:426,headers:{Upgrade:`websocket`}}):e.fetch(t)}function ee(e){return e.port}async function P(e){let{port:t,hostname:n}=e.bunServer,r=e.createMount??(await import(`../create-static-mount-Bi0VpYS8.mjs`)).defaultCreateMount;return d(e.transport,t,n,{...e,createMount:r})}function F(e,t){let n=e,r=t;return{fetch(e,t){return n(e,t)},websocket:{binaryType:t.binaryType,open(e){r.open(e)},message(e,t){r.message(e,t)},close(e,t,n){r.close(e,t,n)}},activate(i){n=R(e,i),r=z(t,i)}}}function I(e){let t=[];return e.forEachActiveExtension((e,n)=>{B(n)&&t.push(n)}),t}function L(e){return Array.isArray(e)?e.flatMap(e=>L(e)):B(e)?[e]:[]}function R(e,t){return t.reduce((e,t)=>t.bun.createFetch?.(e)??e,e)}function z(e,t){return t.reduce((e,t)=>t.bun.createWebSocketHandler?.(e)??e,e)}function B(e){if(!H(e))return!1;let t=e.bun;return typeof e.name==`string`&&typeof e.displayName==`string`&&V(t)}function V(e){if(!H(e))return!1;let t=e.createFetch,n=e.createWebSocketHandler;return(t===void 0||typeof t==`function`)&&(n===void 0||typeof n==`function`)}function H(e){return typeof e==`object`&&!!e}function U(e){let t=e.timeoutMs??1e4,n=e.exit??(e=>process.exit(e)),r=!1;return async i=>{if(r)return;r=!0,console.info(`[${e.label}] ${i} received, shutting down...`);let a=setTimeout(()=>{console.error(`[${e.label}] Graceful shutdown timed out, forcing exit`),n(1)},t);try{process.env.MAKAIO_DEBUG&&console.info(`[${e.label}] Shutting down runtime...`),await e.runtime.shutdown(),process.env.MAKAIO_DEBUG&&console.info(`[${e.label}] Stopping Bun server...`),W(e.bunServer,e.label),process.env.MAKAIO_DEBUG&&console.info(`[${e.label}] Shutdown complete`),clearTimeout(a),n(0)}catch(t){W(e.bunServer,e.label),clearTimeout(a),console.error(`[${e.label}] Shutdown error:`,t),n(1)}}}function W(e,t){let n=e.stop?.(!0);G(n)&&n.catch(e=>{console.warn(`[${t}] Bun server stop failed during shutdown:`,e)})}function G(e){return typeof e==`object`&&!!e&&typeof e.catch==`function`}const K=/^(?=.{1,253}$)(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;function q(e){let t=e.env??process.env,n=e.defaultPort??3e3,r=e.defaultHost??`0.0.0.0`;return{port:J(t.PORT,n,e),host:Y(t.HOST,r,e)}}function J(e,t,n){let r=e?.trim(),i=r&&/^\d+$/.test(r)?Number.parseInt(r,10):NaN;return Number.isInteger(i)&&i>=1&&i<=65535?i:e===void 0?t:Z(`Invalid PORT: ${e}`,t,n)}function Y(e,t,n){let r=e?.trim();return r&&X(r)?r:e===void 0?t:Q(`Invalid HOST: ${e}`,t,n)}function X(e){return k(e)!==0||e===`localhost`||K.test(e)}function Z(e,t,n){return $(e,String(t),n),t}function Q(e,t,n){return $(e,t,n),t}function $(e,t,n){if((n.invalid??`throw`)===`throw`)throw Error(e);console.warn(`[${n.appName}] ${e}, falling back to ${t}`)}export{j as BunBusServerTransportProvider,i as ExplicitDescriptorDiscovery,a as FileConfigStorage,o as FileRegistryCache,s as FilesystemDescriptorDiscovery,c as NodeCredentialProvider,l as StoredCredentialProvider,P as bootMakaioRuntime,u as bootMakaioRuntimeCore,f as bridgeExtensionBrowserEntries,I as collectActiveBunHostPackages,R as composeBunHostFetch,z as composeBunHostWebSocket,F as createBunHostRouter,N as createBunRouteGraphFetch,U as createGracefulShutdown,p as createHonoRouteGraph,m as createHttpRouteGraphBuilder,h as entrypointStem,g as isCliContributionLike,_ as isMakaioExtensionLike,v as isMissingOptionalRuntimePackage,y as isWithinDirectory,b as loadExtensions,x as loadOrCreateMachineIdentity,S as machineKeysExist,L as normalizeBunHostPackages,q as readBunServerEnv,C as registerAdapterNameResolver,w as resolveConventionEntrypoint,ee as resolveListeningPort,T as resolveStaticModelRegistryPath,E as runMigrations,D as tryImport,O as validateMachineKeys};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as FilesystemDescriptorDiscovery, i as ExtensionEntrypointModule, n as ExplicitDescriptorDiscovery, o as FilesystemDescriptorDiscoveryOptions, r as ExtensionDiscovery, s as MergedDescriptorDiscovery, t as DiscoveredExtension } from "../extension-discovery-
|
|
1
|
+
import { a as FilesystemDescriptorDiscovery, i as ExtensionEntrypointModule, n as ExplicitDescriptorDiscovery, o as FilesystemDescriptorDiscoveryOptions, r as ExtensionDiscovery, s as MergedDescriptorDiscovery, t as DiscoveredExtension } from "../extension-discovery-Bv5FDtrM.mjs";
|
|
2
2
|
export { DiscoveredExtension, ExplicitDescriptorDiscovery, ExtensionDiscovery, ExtensionEntrypointModule, FilesystemDescriptorDiscovery, FilesystemDescriptorDiscoveryOptions, MergedDescriptorDiscovery };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as isMakaioExtensionLike, c as resolveConventionEntrypoint, i as isCliContributionLike, o as isWithinDirectory, r as entrypointStem } from "../load-extensions-
|
|
1
|
+
import { a as isMakaioExtensionLike, c as resolveConventionEntrypoint, i as isCliContributionLike, o as isWithinDirectory, r as entrypointStem } from "../load-extensions-CQqw0Smr.mjs";
|
|
2
2
|
export { entrypointStem, isCliContributionLike, isMakaioExtensionLike, isWithinDirectory, resolveConventionEntrypoint };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,n,o as r,r as i}from"../load-extensions-
|
|
1
|
+
import{a as e,c as t,n,o as r,r as i}from"../load-extensions-D-DyzN4j.mjs";export{n as entrypointStem,i as isCliContributionLike,e as isMakaioExtensionLike,r as isWithinDirectory,t as resolveConventionEntrypoint};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RuntimeSubjects } from "./bus/runtime/namespace.mjs";
|
|
2
|
-
import { a as FilesystemDescriptorDiscovery, n as ExplicitDescriptorDiscovery, o as FilesystemDescriptorDiscoveryOptions, r as ExtensionDiscovery, t as DiscoveredExtension } from "../extension-discovery-
|
|
3
|
-
import { a as isMakaioExtensionLike, c as resolveConventionEntrypoint, i as isCliContributionLike, n as LoadExtensionsOptions, o as isWithinDirectory, r as entrypointStem, s as loadExtensions, t as DescriptorSourcePackageGroup } from "../load-extensions-
|
|
4
|
-
import { A as DatabaseBootOptions, B as NodeFrameworkModuleResolver, C as ServerTransportProvider, D as WorkflowWorkerEntryMode, E as WorkflowRunnerBootOptions, F as normalizeNodeHostCapabilities, G as HttpContributionPhase, H as resolveFrameworkSpecifier, I as selectFrameworkCorePackages, J as HonoRouteGraphOptions, K as HttpRouteContribution, L as ShutdownStep, M as InitializeNodeDatabaseResult, N as initializeNodeDatabase, O as WorkflowWorkerEntryResolverOptions, P as HostCapabilityDeclaration, R as BridgeBrowserOptions, S as MakaioRuntime, T as UpstreamTelemetryBootOptions, U as HttpRouteGraphBuilder, V as NoopFrameworkModuleResolver, W as createHttpRouteGraphBuilder, Y as createHonoRouteGraph, _ as ThinWorkflowPiscinaRunnerOptions, a as InProcessWorkflowRunnerOptions, b as BootMakaioRuntimeOptions, h as IWorkflowRunner, i as InProcessWorkflowRunner, j as InitializeNodeDatabaseOptions, k as resolveWorkflowWorkerEntry, m as ThinWorkflowPiscinaRunner, q as HonoRouteGraph, v as WorkflowRunResult, w as TransportReadyInfo, x as CoreBootOptions, y as BootCoordinatorSetupContext, z as FrameworkModuleResolver } from "../index-
|
|
2
|
+
import { a as FilesystemDescriptorDiscovery, n as ExplicitDescriptorDiscovery, o as FilesystemDescriptorDiscoveryOptions, r as ExtensionDiscovery, t as DiscoveredExtension } from "../extension-discovery-Bv5FDtrM.mjs";
|
|
3
|
+
import { a as isMakaioExtensionLike, c as resolveConventionEntrypoint, i as isCliContributionLike, n as LoadExtensionsOptions, o as isWithinDirectory, r as entrypointStem, s as loadExtensions, t as DescriptorSourcePackageGroup } from "../load-extensions-CQqw0Smr.mjs";
|
|
4
|
+
import { A as DatabaseBootOptions, B as NodeFrameworkModuleResolver, C as ServerTransportProvider, D as WorkflowWorkerEntryMode, E as WorkflowRunnerBootOptions, F as normalizeNodeHostCapabilities, G as HttpContributionPhase, H as resolveFrameworkSpecifier, I as selectFrameworkCorePackages, J as HonoRouteGraphOptions, K as HttpRouteContribution, L as ShutdownStep, M as InitializeNodeDatabaseResult, N as initializeNodeDatabase, O as WorkflowWorkerEntryResolverOptions, P as HostCapabilityDeclaration, R as BridgeBrowserOptions, S as MakaioRuntime, T as UpstreamTelemetryBootOptions, U as HttpRouteGraphBuilder, V as NoopFrameworkModuleResolver, W as createHttpRouteGraphBuilder, Y as createHonoRouteGraph, _ as ThinWorkflowPiscinaRunnerOptions, a as InProcessWorkflowRunnerOptions, b as BootMakaioRuntimeOptions, h as IWorkflowRunner, i as InProcessWorkflowRunner, j as InitializeNodeDatabaseOptions, k as resolveWorkflowWorkerEntry, m as ThinWorkflowPiscinaRunner, q as HonoRouteGraph, v as WorkflowRunResult, w as TransportReadyInfo, x as CoreBootOptions, y as BootCoordinatorSetupContext, z as FrameworkModuleResolver } from "../index-ByRAbcZd.mjs";
|
|
5
5
|
import { ConfiguredRuntimeOptions, LoadMakaioConfigOptions, LoadedMakaioConfig, MAKAIO_CONFIG_FILE_ENV, MAKAIO_HOME_ENV, MakaioConfig, ParseMakaioConfigOptions, ParsedMakaioConfig, WorkflowRunnerConfig, buildConfiguredRuntimeOptions, createMakaioConfigDiscovery, defineMakaioConfig, loadMakaioConfig, parseMakaioConfig, resolveMakaioConfigPath, resolveMakaioHome, shouldIncludeExtension } from "./makaio-config.mjs";
|
|
6
6
|
import { IConfigStorage } from "@makaio/framework/core";
|
|
7
7
|
import { BusTransport, IMakaioBus } from "@makaio/framework/bus";
|