@makaio/framework 1.0.0-dev-1785409369816 → 1.0.0-dev-1787670071418
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/README.md +2 -0
- package/dist/.makaio-build.json +4 -3
- package/dist/{account-identity-DFx8pwKL.mjs → account-identity-B3vLwm9O.mjs} +1 -1
- package/dist/adapter-Dz1fX5Wa.mjs +1 -0
- package/dist/adapter-subsystem/index.d.mts +194 -20
- package/dist/adapter-subsystem/index.mjs +1 -1
- package/dist/adapters/acp-client/index.d.mts +105 -7
- package/dist/adapters/acp-client/index.mjs +2 -2
- package/dist/adapters/claude/index.d.mts +5 -5
- package/dist/adapters/config/index.d.mts +1 -1
- package/dist/adapters/config/index.mjs +1 -1
- package/dist/adapters/index.d.mts +405 -824
- package/dist/adapters/index.mjs +6 -6
- package/dist/adapters/node.d.mts +1 -1
- package/dist/adapters/node.mjs +1 -1
- package/dist/adapters/stream-session/index.d.mts +28 -7
- package/dist/adapters/stream-session/index.mjs +1 -1
- package/dist/{ajv-DD3SIL2i.mjs → ajv-krzJXh1X.mjs} +2 -2
- package/dist/artifact-Btbuib48.mjs +1 -0
- package/dist/attach-error-Cb3GbeKe.mjs +1 -0
- package/dist/{auth-DGEdiHF6.mjs → auth-C6tVtaOX.mjs} +1 -1
- package/dist/authority-state-bootstrap-CLYus369.mjs +1 -0
- package/dist/automation-trigger-ByjNlClm.mjs +1 -0
- package/dist/await-trigger-Bkg2BQfg.mjs +1 -0
- package/dist/bus/index.d.mts +41 -9
- package/dist/bus/index.mjs +1 -1
- package/dist/bus-D6NoBhIV.mjs +2 -0
- package/dist/bus-UgFdHybD.mjs +1 -0
- package/dist/caller-owned-adapter-stub-C1M7FKrv.mjs +1 -0
- package/dist/{canonical-model-BAytQ4NV.mjs → canonical-model-DXOvCaVg.mjs} +1 -1
- package/dist/capabilities-BUwuA7XX.mjs +1 -0
- package/dist/capability-j3NekkIu.mjs +1 -0
- package/dist/{client-DbS847wW.mjs → client-BkznbdsO.mjs} +1 -1
- package/dist/clients/index.d.mts +2 -2
- package/dist/clients/index.mjs +1 -1
- package/dist/clients/managed-install.d.mts +1 -1
- package/dist/clients/managed-install.mjs +1 -1
- package/dist/code-execution/worker-entry.d.mts +21 -0
- package/dist/code-execution/worker-entry.mjs +1 -0
- package/dist/code-execution-Ckmn8OZu.mjs +1 -0
- package/dist/code-execution-CweDSWco.mjs +1 -0
- package/dist/code-execution-DqkQjKa1.mjs +1 -0
- package/dist/{compression-74fFeBha.mjs → compression-CtgeVLpP.mjs} +1 -1
- package/dist/{config-namespace-TVX-hG4I.mjs → config-namespace-CjWvw8ij.mjs} +1 -1
- package/dist/{context-resolution-DdyhpH4L.d.mts → context-resolution-841T7jBI.d.mts} +11 -11
- package/dist/contracts/adapter/index.d.mts +3 -3
- package/dist/contracts/adapter/index.mjs +1 -1
- package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
- package/dist/contracts/artifact/index.d.mts +3 -3
- package/dist/contracts/artifact/index.mjs +1 -1
- package/dist/contracts/auth/index.d.mts +2 -2
- package/dist/contracts/auth/index.mjs +1 -1
- package/dist/contracts/automation-trigger/index.d.mts +4 -0
- package/dist/contracts/automation-trigger/index.mjs +1 -0
- package/dist/contracts/canonical-model/index.d.mts +1 -1
- package/dist/contracts/canonical-model/index.mjs +1 -1
- package/dist/contracts/capabilities/index.d.mts +1 -1
- package/dist/contracts/capabilities/index.mjs +1 -1
- package/dist/contracts/client/index.d.mts +2 -2
- package/dist/contracts/client/index.mjs +1 -1
- package/dist/contracts/code-execution/index.d.mts +2 -0
- package/dist/contracts/code-execution/index.mjs +1 -0
- package/dist/contracts/common/index.d.mts +1 -1
- package/dist/contracts/config/index.d.mts +1 -1
- package/dist/contracts/config/index.mjs +1 -1
- package/dist/contracts/extension/index.d.mts +6 -5
- package/dist/contracts/extension/index.mjs +1 -1
- package/dist/contracts/facet/index.d.mts +1 -1
- package/dist/contracts/facet/index.mjs +1 -1
- package/dist/contracts/harness/index.d.mts +1 -1
- package/dist/contracts/harness/index.mjs +1 -1
- package/dist/contracts/host/index.d.mts +1 -1
- package/dist/contracts/host/index.mjs +1 -1
- package/dist/contracts/index.d.mts +171 -100
- 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/provider/index.mjs +1 -1
- package/dist/contracts/reaction/index.d.mts +2 -0
- package/dist/contracts/reaction/index.mjs +1 -0
- package/dist/contracts/session/index.d.mts +3 -3
- package/dist/contracts/session/index.mjs +1 -1
- package/dist/contracts/shared/index.d.mts +3 -3
- package/dist/contracts/shared/index.mjs +1 -1
- package/dist/contracts/skill/index.d.mts +1 -1
- package/dist/contracts/skill/index.mjs +1 -1
- package/dist/contracts/telemetry/index.d.mts +1 -1
- package/dist/contracts/telemetry/index.mjs +1 -1
- package/dist/contracts/timeout/index.d.mts +1 -1
- package/dist/contracts/timeout/index.mjs +1 -1
- package/dist/contracts/toast/index.mjs +1 -1
- package/dist/contracts/variant/index.d.mts +1 -1
- package/dist/contracts/variant/index.mjs +1 -1
- package/dist/contracts/worker-node/index.d.mts +1 -1
- package/dist/contracts/worker-node/index.mjs +1 -1
- package/dist/contracts/workflow/index.d.mts +3 -3
- package/dist/contracts/workflow/index.mjs +1 -1
- package/dist/contribution-CUHLVLsT.d.mts +35 -0
- package/dist/core/index.d.mts +84 -2
- package/dist/core/index.mjs +1 -1
- package/dist/{definition-CJfiv8xm.mjs → definition-BH4QLGLI.mjs} +1 -1
- package/dist/definition-DyGImhyi.d.mts +375 -0
- package/dist/{detached-extension-handle-Ddfquy5_.mjs → detached-extension-handle-D0aI0pJA.mjs} +1 -1
- package/dist/drizzle/0031_adapter_session_currency.sql +66 -0
- package/dist/drizzle/0032_native_session_ownership.sql +77 -0
- package/dist/drizzle/0033_m_msf3hu2s.sql +1 -0
- package/dist/drizzle/0034_m_msha1388.sql +41 -0
- package/dist/drizzle/0035_m_mshgj6x7.sql +40 -0
- package/dist/drizzle/0036_m_msivwbgm.sql +1 -0
- package/dist/drizzle/0037_runtime_instance_incarnation_counter.sql +6 -0
- package/dist/drizzle/meta/_journal.json +49 -0
- package/dist/event-B8ELuk6k.mjs +1 -0
- package/dist/{execution-attempt-repository-DWXKY41_.d.mts → execution-attempt-repository-BJ2W6wwx.d.mts} +1 -1
- package/dist/{execution-target-Cf645pDj.mjs → execution-target-H0RWV7Py.mjs} +1 -1
- package/dist/extension-Bfkr2DBs.mjs +1 -0
- package/dist/extension-Cz39YNXy.mjs +1 -0
- package/dist/extension-context-QmFuHdq5.d.mts +295 -0
- package/dist/{extension-discovery-CQRdbVQ6.d.mts → extension-discovery-Dhu3WplO.d.mts} +11 -1
- package/dist/{extension-namespace-Yu41YepM.mjs → extension-namespace-QoTTwKPt.mjs} +1 -1
- package/dist/extension-package-provenance-aYrZuS4W.mjs +1 -0
- package/dist/{filesystem-service-DlP2HfDg.mjs → filesystem-service-CiUw0YN5.mjs} +1 -1
- package/dist/framework-packages-BHgul8Kl.mjs +1 -0
- package/dist/git/index.mjs +2 -2
- package/dist/{globby-1yCVCk8s.mjs → globby-QBDqstzq.mjs} +1 -1
- package/dist/handlers-BsHAFtye.mjs +57 -0
- package/dist/{harness-DpwsFsE7.mjs → harness-YQ2ewID9.mjs} +1 -1
- package/dist/{hook-responses-Dh1PWXqJ.d.mts → hook-responses-9Ywsqzzq.d.mts} +2 -293
- package/dist/identity-OjRlG6dZ.mjs +1 -0
- package/dist/{index-CMgLxw14.d.mts → index-8NdPPzUh2.d.mts} +2 -2
- package/dist/{index-Ds5_rDEJ.d.mts → index-8y4hT9WL.d.mts} +1 -12
- package/dist/{index-BVlXneHH.d.mts → index-B-3I98nw.d.mts} +14 -10
- package/dist/index-B0VO0rAl.d.mts +302 -0
- package/dist/{index-gUhidukN.d.mts → index-B0yMCJW8.d.mts} +324 -2
- package/dist/index-BM56936c.d.mts +165 -0
- package/dist/{index-CLvQsL6s2.d.mts → index-BNzUyVwV.d.mts} +2105 -320
- package/dist/{index-BaZeoZoS.d.mts → index-BTEJfzjE.d.mts} +1 -1
- package/dist/{index-B0Kf_OWi.d.mts → index-BfV8U4XX.d.mts} +1 -1
- package/dist/{index-DCZ8BX9S.d.mts → index-BkbnC65b.d.mts} +487 -85
- package/dist/{index-GHASUiem.d.mts → index-BmevAPME2.d.mts} +1 -1
- package/dist/index-Bqk0pJBQ2.d.mts +138 -0
- package/dist/{index-B9UW_vPM.d.mts → index-C146Eq_J.d.mts} +2465 -273
- package/dist/{index-BAXkicoQ.d.mts → index-CIEycZrt.d.mts} +1 -1
- package/dist/{index-DkiTJM5p.d.mts → index-CMekqu_D.d.mts} +44 -10
- package/dist/{index-SsBHjUqA.d.mts → index-CPRQ4dWX.d.mts} +0 -23
- package/dist/{index-EjsSBQXy2.d.mts → index-CPi0UpRh.d.mts} +1 -1
- package/dist/{index-DSBT83c0.d.mts → index-CYjgoYeX.d.mts} +24 -3
- package/dist/{index-DnG-QFpG.d.mts → index-CmwAJ8-5.d.mts} +18 -1
- package/dist/index-Cny5RvjO.d.mts +800 -0
- package/dist/{index-BNMnIe-j.d.mts → index-D-4jv_66.d.mts} +434 -863
- package/dist/{index-brqfk9JQ.d.mts → index-D8D-yibS2.d.mts} +4 -4
- package/dist/index-DHnSLGP4.d.mts +268 -0
- package/dist/{index-D5Nb7IEP.d.mts → index-DI2lS7VT.d.mts} +79 -41
- package/dist/{index-D_ODXsBv.d.mts → index-DJ2KgJDJ2.d.mts} +51 -95
- package/dist/{index-cqLS1eFV.d.mts → index-DNI6UF9h.d.mts} +133 -134
- package/dist/index-DQ8o3JGi.d.mts +132 -0
- package/dist/index-DWBkiiXH.d.mts +18 -0
- package/dist/{index-DlsHL9Jg.d.mts → index-DXtQRehh.d.mts} +12 -12
- package/dist/{index-4VfqCjl2.d.mts → index-D_4K3Tf_.d.mts} +79 -194
- package/dist/index-Dg11JxKZ.d.mts +496 -0
- package/dist/json-value-BBZ6uGwc.mjs +1 -0
- package/dist/json-value-DPqb-SJ8.d.mts +177 -0
- 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 +9 -9
- package/dist/kernel/index.mjs +1 -1
- package/dist/kernel/namespace/index.d.mts +2 -2
- 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-DErgth_E.mjs → lib-BpGvHZye.mjs} +2 -2
- package/dist/{lib-C7-s68uf.mjs → lib-Cm-uEoC1.mjs} +1 -1
- package/dist/{load-extensions-BxsDB87B.d.mts → load-extensions-BQoXaHhR.d.mts} +17 -13
- package/dist/load-extensions-DG5LvPyM.mjs +1 -0
- package/dist/{materialization-Jd198K3y.mjs → materialization-lVd9_-jr.mjs} +1 -1
- package/dist/mcp-http-server/index.mjs +1 -1
- package/dist/model-DrzPt3ou.mjs +1 -0
- package/dist/{namespace-BqxtpNAn.mjs → namespace-BL7lHlmg.mjs} +1 -1
- package/dist/{namespace-CjjFvrIA2.d.mts → namespace-BNp7n_gu.d.mts} +25 -25
- package/dist/{namespace-g_mbIZq_.d.mts → namespace-BRuHzhPo.d.mts} +564 -28
- package/dist/{namespace-DV-Hr9sZ.d.mts → namespace-C06lJSuj.d.mts} +17 -7
- package/dist/{namespace-TseEI3Pu.d.mts → namespace-DOezqDti.d.mts} +18 -10
- package/dist/{namespace-CErHuXtb.d.mts → namespace-DknCutQZ.d.mts} +50 -0
- package/dist/{namespace-B8uKAzWJ.mjs → namespace-Du0accdE.mjs} +1 -1
- package/dist/{namespace-CWUDFGOy.mjs → namespace-NXm_zvL1.mjs} +1 -1
- package/dist/{namespace-CupOzbRv.d.mts → namespace-l-HG1rLF.d.mts} +24 -20
- package/dist/namespace-sCPb79-7.mjs +1 -0
- package/dist/{native-session-supervisor-DRx0MX-d.mjs → native-session-supervisor-LKio8XZn.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/npm-package-name-DuTYVICk.mjs +1 -0
- package/dist/orchestrator-shared-BGlN-m-V.mjs +1 -0
- package/dist/{orchestrator-shared-BHCv-l2O.d.mts → orchestrator-shared-CNHSImNY.d.mts} +10 -10
- package/dist/ownership-memory-handler-BpGdR_uG.mjs +1 -0
- package/dist/ownership-recovery-guard-DyW5vGBr.mjs +1 -0
- package/dist/package-B01gmu75.mjs +7 -0
- package/dist/{package-DWMxGfzK.d.mts → package-BNFTUFLB.d.mts} +234 -84
- package/dist/package-DttKA9wN.mjs +1 -0
- package/dist/package-EGTn-Ng1.mjs +1 -0
- package/dist/package-JtjbO-Oi.mjs +1 -0
- package/dist/package.json +1 -1
- package/dist/{profile-BTAI31Nt.mjs → profile-N5qGUpF0.mjs} +1 -1
- package/dist/{provider-context-PZIQWcqQ.mjs → provider-context-CG42JlP9.mjs} +1 -1
- package/dist/{provider-context-Dq53Cgzz.mjs → provider-context-zTDSH2x9.mjs} +1 -1
- package/dist/reaction-D3TNwPK8.mjs +1 -0
- package/dist/{registry-wfF2uTty.mjs → registry-Dk12tAfv.mjs} +2 -2
- package/dist/{resolved-DZgqql2Z.mjs → resolved-sq8RXNDf.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/rules/schemas.mjs +1 -1
- package/dist/runtime-bun/index.mjs +1 -1
- package/dist/runtime-node/code-execution/index.d.mts +3 -0
- package/dist/runtime-node/code-execution/index.mjs +1 -0
- package/dist/runtime-node/extension-discovery.d.mts +2 -2
- package/dist/runtime-node/extension-discovery.mjs +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 +7 -5
- package/dist/runtime-node/index.mjs +24 -24
- 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-DKUb4rkr.d.mts → schema-B3Pf7JP7.d.mts} +778 -21
- package/dist/{schema-Dd-e89MO.mjs → schema-Dq-7si8u.mjs} +1 -1
- package/dist/{schemas-B1NWNASS.d.mts → schemas-BXc9qOpl.d.mts} +2 -0
- package/dist/schemas-BfO5jkrL.mjs +1 -0
- package/dist/{schemas-CR8hSqTy.d.mts → schemas-C1mxTfd7.d.mts} +60 -4
- package/dist/schemas-C3kyQWGf.mjs +1 -0
- package/dist/{schemas-DnYiAvfz.d.mts → schemas-D7ScxLrf.d.mts} +24 -20
- package/dist/{schemas-BsVYZviy.d.mts → schemas-OWvBn7AH.d.mts} +4 -4
- package/dist/{schemas-DaHQzpgm.mjs → schemas-QWDnauKX.mjs} +1 -1
- package/dist/schemas-TK29KWx-.mjs +1 -0
- package/dist/schemas-_2Syo_01.mjs +1 -0
- package/dist/scoped-bus-DoPmCJeM.mjs +1 -0
- package/dist/{selection-BNwTKEVT.mjs → selection-DL3ric7K.mjs} +1 -1
- package/dist/services/adapter-runtime/index.d.mts +4 -4
- 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 +2 -2
- package/dist/services/adapter-runtime/schemas.mjs +1 -1
- package/dist/services/adapter-subsystem/index.d.mts +4 -4
- package/dist/services/adapter-subsystem/index.mjs +1 -1
- package/dist/services/adapter-subsystem/namespace.d.mts +2 -2
- package/dist/services/adapter-subsystem/namespace.mjs +1 -1
- package/dist/services/agent-runtime/index.d.mts +2 -2
- package/dist/services/agent-runtime/namespace.d.mts +1 -1
- package/dist/services/agent-runtime/schemas.d.mts +1 -1
- package/dist/services/automation-trigger/index.d.mts +943 -0
- package/dist/services/automation-trigger/index.mjs +1 -0
- package/dist/services/capability/index.d.mts +3 -2
- package/dist/services/capability/index.mjs +1 -1
- package/dist/services/code-execution/index.d.mts +2 -0
- package/dist/services/code-execution/index.mjs +1 -0
- package/dist/services/codebase/index.d.mts +2 -2
- package/dist/services/codebase/namespace.d.mts +1 -1
- package/dist/services/codebase/schemas.d.mts +1 -1
- package/dist/services/compression/index.d.mts +2 -2
- package/dist/services/compression/namespace.d.mts +1 -1
- package/dist/services/compression/schemas.d.mts +1 -1
- package/dist/services/context-rules/index.d.mts +1 -1
- package/dist/services/context-rules/index.mjs +1 -1
- package/dist/services/execution-target/index.d.mts +3 -3
- package/dist/services/execution-target/index.mjs +1 -1
- package/dist/services/execution-target/namespace.d.mts +1 -1
- package/dist/services/execution-target/namespace.mjs +1 -1
- package/dist/services/execution-target/schemas.d.mts +1 -1
- package/dist/services/execution-target/schemas.mjs +1 -1
- package/dist/services/filesystem/index.d.mts +1 -1
- package/dist/services/filesystem/index.mjs +1 -1
- package/dist/services/filesystem/namespace.d.mts +6 -6
- package/dist/services/filesystem/schemas.d.mts +3 -3
- package/dist/services/git/namespace.d.mts +18 -0
- package/dist/services/git/namespace.mjs +1 -1
- package/dist/services/git/schemas.d.mts +10 -1
- package/dist/services/git/schemas.mjs +1 -1
- package/dist/services/harness/index.mjs +1 -1
- package/dist/services/index.d.mts +567 -101
- package/dist/services/index.mjs +1 -1
- package/dist/services/log-import/browser.d.mts +2 -2
- package/dist/services/log-import/index.d.mts +3 -3
- package/dist/services/log-import/log-import.d.mts +1 -1
- package/dist/services/log-import/log-import.mjs +1 -1
- package/dist/services/log-import/namespace.mjs +1 -1
- package/dist/services/log-import/schemas.mjs +1 -1
- package/dist/services/materialization/index.d.mts +1 -1
- package/dist/services/materialization/index.mjs +1 -1
- package/dist/services/model-registry/index.d.mts +1 -1
- package/dist/services/model-registry/index.mjs +1 -1
- package/dist/services/preferences/index.d.mts +2 -2
- package/dist/services/preferences/schemas.d.mts +1 -1
- package/dist/services/preferences/storage-namespace.d.mts +2 -2
- package/dist/services/provider-context/index.d.mts +1 -1
- package/dist/services/provider-context/index.mjs +1 -1
- package/dist/services/provider-runtime/index.mjs +1 -1
- package/dist/services/session/handlers/index.d.mts +2 -2
- package/dist/services/session/handlers/index.mjs +1 -1
- package/dist/services/session/index.d.mts +10 -10
- 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 +2 -2
- package/dist/services/session/storage/schema.mjs +1 -1
- package/dist/services/session/testing/index.d.mts +33 -4
- package/dist/services/session/testing/index.mjs +68 -12
- package/dist/services/session/testing/orchestrator-shared.d.mts +1 -1
- package/dist/services/session/testing/orchestrator-shared.mjs +1 -1
- package/dist/services/session/turns/namespace.d.mts +1 -1
- package/dist/services/session/turns/namespace.mjs +1 -1
- package/dist/services/session-editor/index.d.mts +1 -1
- package/dist/services/session-editor/index.mjs +1 -1
- package/dist/services/settings/index.d.mts +3 -3
- package/dist/services/settings/index.mjs +1 -1
- package/dist/services/settings/namespace.mjs +1 -1
- package/dist/services/settings/storage/clients-namespace.d.mts +1 -1
- package/dist/services/settings/storage/clients-namespace.mjs +1 -1
- package/dist/services/settings/storage/index.d.mts +3 -3
- package/dist/services/settings/storage/index.mjs +1 -1
- package/dist/services/settings/storage/providers-namespace.d.mts +1 -1
- package/dist/services/settings/storage/providers-namespace.mjs +1 -1
- package/dist/services/subagent/index.d.mts +1 -1
- package/dist/services/subagent/index.mjs +1 -1
- package/dist/services/subagent-template/index.d.mts +2 -2
- package/dist/services/subagent-template/namespace.d.mts +1 -1
- package/dist/services/subagent-template/schemas.d.mts +1 -1
- package/dist/services/tool-approval/index.d.mts +1 -1
- package/dist/services/tool-approval/index.mjs +1 -1
- package/dist/services/tools/index.d.mts +1 -1
- package/dist/services/tools/index.mjs +1 -1
- package/dist/services/tray-menu/index.d.mts +3 -3
- package/dist/services/tray-menu/index.mjs +1 -1
- package/dist/services/tray-menu/namespace.d.mts +1 -1
- package/dist/services/tray-menu/schemas.d.mts +1 -1
- package/dist/services/turn/index.d.mts +1 -1
- package/dist/services/turn/namespace.d.mts +1 -1
- package/dist/services/workflow-transitions/index.d.mts +1 -1
- package/dist/services/workflow-transitions/index.mjs +1 -1
- package/dist/session-BOpTI79g.mjs +1 -0
- package/dist/session-CXOPk3yg.mjs +95 -0
- package/dist/shared-B9AWRm9A.mjs +1 -0
- package/dist/{skill-BR6rkfLe.mjs → skill-DGNtc_ww.mjs} +1 -1
- package/dist/{src-DD0v-nIj.mjs → src-BmSQ3rlz.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 +81 -2
- package/dist/storage/drizzle/index.mjs +1 -1
- package/dist/storage/handlers/drizzle/index.d.mts +1 -1
- package/dist/storage/handlers/drizzle/index.mjs +1 -1
- package/dist/storage/handlers/index.d.mts +1 -1
- package/dist/storage/handlers/index.mjs +1 -1
- package/dist/tool-approval-service-BFDOFUGC.mjs +1 -0
- package/dist/{tools-PdG9fO1M.mjs → tools-DWKWX3eV.mjs} +1 -1
- package/dist/{transition-Du3MQzJV.d.mts → transition-D3zUBTPc.d.mts} +11 -38
- package/dist/{types-D7_kevBK.d.mts → types-BlB23n4f.d.mts} +1 -1
- package/dist/{types-DMLDHFR9.d.mts → types-CtDGkyLx2.d.mts} +1 -1
- package/dist/types-Cwza95hS.mjs +1 -0
- package/dist/{types-Dzrwa1GY.d.mts → types-DcxBYlPA.d.mts} +5834 -1436
- package/dist/types-DnK6Wa_Y.d.mts +260 -0
- package/dist/types-OKJCOjme.d.mts +2937 -0
- package/dist/ui-hooks/index.d.mts +29 -2
- package/dist/ui-hooks/index.mjs +1 -1
- package/dist/ui-kernel/index.d.mts +2 -2
- package/dist/ui-kernel/pages/schemas.d.mts +1 -1
- package/dist/ui-views/index.d.mts +1 -1
- package/dist/utils/index.d.mts +98 -1
- package/dist/utils/index.mjs +2 -2
- package/dist/utils/project-manifest.mjs +1 -1
- package/dist/{version-CoCeMxDT.mjs → version-BYeVh1pI.mjs} +1 -1
- package/dist/{view-builder-DeFd-k7C.d.mts → view-builder-B0j9p5C0.d.mts} +4 -4
- package/dist/{visibility-qhGWmpSJ.mjs → visibility-DtDLRBdr.mjs} +1 -1
- package/dist/worker-node-CjuQb9hl.mjs +1 -0
- package/dist/{worker-node-DZTuT1DS.mjs → worker-node-Dtf9ilsR.mjs} +1 -1
- package/dist/workflow-C4mck_NW.mjs +1 -0
- package/dist/workflow-engine/execution-attempt-repository.d.mts +1 -1
- package/dist/workflow-engine/index.d.mts +237 -518
- package/dist/workflow-engine/index.mjs +1 -1
- package/dist/workflow-engine/package.d.mts +1 -1
- package/dist/workflow-engine/package.mjs +1 -1
- package/dist/workflow-engine/provider-operation.d.mts +1 -1
- package/dist/workflow-engine/testing/index.d.mts +2 -2
- package/dist/workflow-engine/testing/index.mjs +1 -1
- package/dist/workflow-engine/testing/sqlite.d.mts +1 -1
- package/dist/workflow-engine/testing/sqlite.mjs +27 -27
- package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
- package/dist/workflow-engine/workflow-trigger-binding-consumer.d.mts +46 -0
- package/dist/workflow-engine/workflow-trigger-binding-consumer.mjs +1 -0
- package/dist/{workflow-transitions-DSc45ixc.mjs → workflow-transitions-c_VQbyV0.mjs} +1 -1
- package/dist/workflow-worker-aNbdgqml.mjs +1 -0
- package/dist/zod-json-schema-Dixc-B1T.mjs +1 -0
- package/package.json +46 -1
- package/dist/adapter-D5c5LrPN.mjs +0 -1
- package/dist/artifact-DGiXqb11.mjs +0 -1
- package/dist/attach-error-C3tngg6J.mjs +0 -1
- package/dist/authority-state-bootstrap-GPL_tqaT.mjs +0 -1
- package/dist/await-trigger-I3lrepb8.mjs +0 -1
- package/dist/bus-B6SAjgOC.mjs +0 -2
- package/dist/bus-C2l3K74u.mjs +0 -1
- package/dist/capabilities-BQEp34ir.mjs +0 -1
- package/dist/capability-service-BqiLlRGA.mjs +0 -1
- package/dist/event-CmVjR6Ib.mjs +0 -1
- package/dist/extension-DCA4pYrY.mjs +0 -1
- package/dist/extension-hjOPs10e.mjs +0 -1
- package/dist/framework-packages-C3RWfJDk.mjs +0 -1
- package/dist/handlers-CfnLyLfE.mjs +0 -57
- package/dist/identity-D6guMtmi.mjs +0 -1
- package/dist/index-CRvpVIqA.d.mts +0 -89
- package/dist/json-value-Brslhqbm.d.mts +0 -57
- package/dist/json-value-DmU8ibo_.mjs +0 -1
- package/dist/load-extensions-D0DfjYLC.mjs +0 -1
- package/dist/model-BGgVmRnN.mjs +0 -1
- package/dist/namespace-DJfUADSV.mjs +0 -1
- package/dist/orchestrator-shared-BxmHCPvx.mjs +0 -1
- package/dist/package-CNUPPcU1.mjs +0 -7
- package/dist/package-Dft_RItb.mjs +0 -1
- package/dist/schemas-CRB2O5zo.mjs +0 -1
- package/dist/schemas-Cm09dXL4.mjs +0 -1
- package/dist/schemas-tDf_WiC8.mjs +0 -1
- package/dist/scoped-bus-C9BdNwfM.mjs +0 -1
- package/dist/session-BOGCd18q.mjs +0 -1
- package/dist/session-BTFiDoGz.mjs +0 -76
- package/dist/shared-BQ0CHIVy.mjs +0 -1
- package/dist/tool-approval-service-kBA0fRzm.mjs +0 -1
- package/dist/types-CJ_QZ1yW.d.mts +0 -1487
- package/dist/worker-node-Bl9_vqYi.mjs +0 -1
- package/dist/workflow-BfDbgtIQ.mjs +0 -1
- package/dist/workflow-worker-BN9XPxQO.mjs +0 -1
- package/dist/{adapter-auth-runtime-DO-FVTXg.mjs → adapter-auth-runtime-DHHppU4f.mjs} +0 -0
- package/dist/{adapter-binding-DQchUtrK.d.mts → adapter-binding-CATvmGuz.d.mts} +0 -0
- package/dist/{attempt-record-codec-CqO1_XnE.mjs → attempt-record-codec-BYfYkj4M.mjs} +0 -0
- package/dist/{base-orchestrator-BilsQNW1.d.mts → base-orchestrator-B4YW6z_Q.d.mts} +0 -0
- package/dist/{index-DN4NOCqN2.d.mts → capability-service-BW1-teFU.d.mts} +0 -0
- package/dist/{client-B--e2qcU.d.mts → client-BG0WX5Vz.d.mts} +0 -0
- package/dist/{client-binary-version-verifier-taewmKTY.mjs → client-binary-version-verifier-0lCKZOTg.mjs} +0 -0
- package/dist/{client-binary-version-verifier-CgjM_vGF.d.mts → client-binary-version-verifier-lcv83Hq3.d.mts} +0 -0
- package/dist/{clients-namespace-DfxjG2ZP.d.mts → clients-namespace-DLAjOTTb.d.mts} +0 -0
- package/dist/{config-namespace-BCqvufbD.d.mts → config-namespace-CH7sJZ4f.d.mts} +0 -0
- package/dist/{create-static-mount-bbQhTt6W.mjs → create-static-mount-DxuixuLZ.mjs} +0 -0
- package/dist/{cross-spawn-B57KZuns.mjs → cross-spawn-CZygZJMH.mjs} +0 -0
- package/dist/{cursor-storage-DIFK_9hg.mjs → cursor-storage-bsc9lZKk.mjs} +0 -0
- package/dist/{definition-gnKgXU91.d.mts → definition-BrgzUuFk.d.mts} +0 -0
- package/dist/{definitions-xrrY0wgz.mjs → definitions-CRpdnHYM.mjs} +0 -0
- package/dist/{descriptor-to-package-DvF08krT.mjs → descriptor-to-package-CcjdoWP4.mjs} +0 -0
- package/dist/{drizzle-z_0SiGY8.mjs → drizzle-Bzc-OGVI.mjs} +0 -0
- package/dist/{esm-CltRnX8_.mjs → esm-i-S5TW72.mjs} +0 -0
- package/dist/{facet-BCI00njh.mjs → facet-BnMh7Jyc.mjs} +0 -0
- package/dist/{filesystem-service-CQ9yVkSz.d.mts → filesystem-service-ZJ43SbBi.d.mts} +0 -0
- package/dist/{handler-Cbv9FqDO.mjs → handler-DF1fVDpf.mjs} +0 -0
- package/dist/{host-Caq6ZfSJ.mjs → host-B-_ntOMH.mjs} +0 -0
- package/dist/{index-ye0oklfU.d.mts → index-B2Y1Wvbh.d.mts} +0 -0
- package/dist/{index-Cv-o5Krs.d.mts → index-B4svZC6L.d.mts} +0 -0
- package/dist/{index-DZunhZec.d.mts → index-B5dP8rj6.d.mts} +0 -0
- package/dist/{index-jTaAHsul.d.mts → index-BC-6qNeo.d.mts} +0 -0
- package/dist/{index-ByKi34v5.d.mts → index-BFWvT0NG.d.mts} +0 -0
- package/dist/{index-vA--0lOM.d.mts → index-BMRB9yhF.d.mts} +0 -0
- package/dist/{index-BskPjMet.d.mts → index-BuMsrli0.d.mts} +0 -0
- package/dist/{index-DR40QWlw.d.mts → index-C4V8Pmi4.d.mts} +0 -0
- package/dist/{index-BIdsFcQs2.d.mts → index-CL0Jo1b92.d.mts} +0 -0
- package/dist/{index-CjdRdsd0.d.mts → index-CVpaGijY.d.mts} +0 -0
- package/dist/{index-vcSj12YQ.d.mts → index-CmbkCxj-.d.mts} +0 -0
- package/dist/{index-sS6KUlrx.d.mts → index-CqdMbYmR.d.mts} +0 -0
- package/dist/{index-CnMu8BQl.d.mts → index-D037TVsm.d.mts} +0 -0
- package/dist/{index-CGZQVTid.d.mts → index-DgspOUa72.d.mts} +0 -0
- package/dist/{index-dtsLKOID.d.mts → index-Ek4y8M9J2.d.mts} +0 -0
- package/dist/{index-DjgLchuQ.d.mts → index-VzLAV0Yt.d.mts} +0 -0
- package/dist/{index-DXN_L5D6.d.mts → index-jxPncqWZ2.d.mts} +0 -0
- package/dist/{index-BVRQEpAg.d.mts → index-kzIjbrS02.d.mts} +6 -6
- /package/dist/{index-Dm1nUxCF.d.mts → index-l01zsChf.d.mts} +0 -0
- /package/dist/{index-CWHfOz6d.d.mts → index-pvX-BIpr2.d.mts} +0 -0
- /package/dist/{jsonl-transport-bQl3JwIu.mjs → jsonl-transport-Cyyh5Wje.mjs} +0 -0
- /package/dist/{lib-DOBXZmYX.mjs → lib-BqV8hYtk.mjs} +0 -0
- /package/dist/{model-registry-xyBKSye-.mjs → model-registry-C9rFu3kV.mjs} +0 -0
- /package/dist/{model-registry-CmgcPDH3.mjs → model-registry-Cixxx2jv.mjs} +0 -0
- /package/dist/{modes-BheyN7SS.mjs → modes-DwsJ3yVl.mjs} +0 -0
- /package/dist/{namespace-BOkKoq34.d.mts → namespace-B0ftHlK3.d.mts} +0 -0
- /package/dist/{namespace-YytVKIgI.d.mts → namespace-BGRHcrmp.d.mts} +0 -0
- /package/dist/{namespace-jDhZjw-i.d.mts → namespace-BUYDmd0r.d.mts} +0 -0
- /package/dist/{namespace-YxU1xf-K.mjs → namespace-BW3Bfu9h.mjs} +0 -0
- /package/dist/{namespace-DWCEo-9M.d.mts → namespace-BdAK0lD8.d.mts} +0 -0
- /package/dist/{namespace-Cv1RFP7n.d.mts → namespace-CPG6u60N.d.mts} +0 -0
- /package/dist/{namespace-GPA7zots.d.mts → namespace-CVFaZv8x.d.mts} +0 -0
- /package/dist/{namespace-Blp4c8GK.d.mts → namespace-DBO1OzYB.d.mts} +0 -0
- /package/dist/{namespace-C-9si-fV.mjs → namespace-DiwqpB-c.mjs} +0 -0
- /package/dist/{namespace-tGRAod3o.d.mts → namespace-DqZweTbX.d.mts} +0 -0
- /package/dist/{namespace-HO2J9sO8.mjs → namespace-jVTsuZHX.mjs} +0 -0
- /package/dist/{namespace-CWGKCNZm.mjs → namespace-tjoxekmf.mjs} +0 -0
- /package/dist/{out-CvjtANXN.mjs → out-8bOYN6EF.mjs} +0 -0
- /package/dist/{packages-DtEEP0Vt.mjs → packages-Bp124-gx.mjs} +0 -0
- /package/dist/{packages-BZ6pzFIq.d.mts → packages-CxPMEg8D.d.mts} +0 -0
- /package/dist/{platform-Bv8llU9c.mjs → platform-CxyYPrkf.mjs} +0 -0
- /package/dist/{provider-operation-Cxoe2SUr.d.mts → provider-operation-DbdyFwNm.d.mts} +0 -0
- /package/dist/{providers-Co5UszRH.mjs → providers-C-eekMxD.mjs} +0 -0
- /package/dist/{providers-namespace-DjFkmvBR.d.mts → providers-namespace-CfZKp-C0.d.mts} +0 -0
- /package/dist/{quick-lru-CrOpWwrf.mjs → quick-lru-CCEnf7y6.mjs} +0 -0
- /package/dist/{schema-Db-y-09L.mjs → schema-C0opCPww.mjs} +0 -0
- /package/dist/{schema-introspection-DgWQCpwx.mjs → schema-introspection-6-r_KEJQ.mjs} +0 -0
- /package/dist/{schemas-N6x2z7Lf.d.mts → schemas-B50oWBuj.d.mts} +0 -0
- /package/dist/{schemas-BO7uOum6.d.mts → schemas-B6Q-qdmn.d.mts} +0 -0
- /package/dist/{schemas-BGExwp3j.mjs → schemas-B8hKbBwI.mjs} +0 -0
- /package/dist/{schemas-miYxK_Z1.d.mts → schemas-BGvkTiCx.d.mts} +0 -0
- /package/dist/{schemas-CqRm0i9a.mjs → schemas-BivbWRkG.mjs} +0 -0
- /package/dist/{schemas-CwbYk_kZ.d.mts → schemas-ChmQldVH.d.mts} +0 -0
- /package/dist/{schemas-DrVg4aQQ.d.mts → schemas-Dd13TMgU.d.mts} +0 -0
- /package/dist/{schemas-BtZqovRH.d.mts → schemas-Pe892GgN.d.mts} +0 -0
- /package/dist/{schemas-CQyRBqD6.d.mts → schemas-bfZNpl0B.d.mts} +0 -0
- /package/dist/{schemas-Bfxskx_2.mjs → schemas-scyC2tFF.mjs} +0 -0
- /package/dist/{semver-DlM8znk4.mjs → semver-BI7kTNsY.mjs} +0 -0
- /package/dist/{server-lifecycle-kmQ5PUDv.mjs → server-lifecycle-B_OZnoe-.mjs} +0 -0
- /package/dist/{server-lifecycle-Dsq56aqC.d.mts → server-lifecycle-L8zja8t8.d.mts} +0 -0
- /package/dist/{session-lineage-B_JW5LpF.d.mts → session-lineage-bUkd3fqx.d.mts} +0 -0
- /package/dist/{shared-schemas-DXwyMCwZ.mjs → shared-schemas-CQ6blrEW.mjs} +0 -0
- /package/dist/{src-CCu8TwL6.mjs → src-BacfeiI4.mjs} +0 -0
- /package/dist/{storage-namespace-BSrv0vXR.mjs → storage-namespace-BZce8kkW.mjs} +0 -0
- /package/dist/{storage-namespace-dfywhXR3.d.mts → storage-namespace-YmE8XCCL.d.mts} +0 -0
- /package/dist/{storage-namespace-definition-BvlX0QV_.d.mts → storage-namespace-definition-BsnYAPot.d.mts} +0 -0
- /package/dist/{storage-namespace-definition-CkMKt7-I.mjs → storage-namespace-definition-Cca-zwXU.mjs} +0 -0
- /package/dist/{supports-color-DUugCQsK.mjs → supports-color-SV_FgSN2.mjs} +0 -0
- /package/dist/{telemetry-Pr3oP2rk.mjs → telemetry-BqoC87F-.mjs} +0 -0
- /package/dist/{timeout-DWDhddRJ.mjs → timeout-DVlN2Zhy.mjs} +0 -0
- /package/dist/{tray-menu-service-BBLa-Rcv.mjs → tray-menu-service-eVVxgPLc.mjs} +0 -0
- /package/dist/{types-BrcjaNPZ.d.mts → types-DdpSEmTO.d.mts} +0 -0
- /package/dist/{types-b54n1o57.d.mts → types-tyv0B605.d.mts} +0 -0
- /package/dist/{ui-config-CyCdlns_.mjs → ui-config-B35GloSX.mjs} +0 -0
- /package/dist/{variant-krjlTdJt.mjs → variant-Dwnge3J_.mjs} +0 -0
- /package/dist/{window-registry-I-imZHV_.mjs → window-registry-CKiMJjId.mjs} +0 -0
- /package/dist/{window-registry-BDnZLPVx.d.mts → window-registry-Pcf35cac.d.mts} +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { l as ProviderOperationOwnershipRecord, o as ProviderOperationClaimDecision, s as ProviderOperationMutationDecision } from "./provider-operation-
|
|
2
|
-
import { A as RecoverableAttemptRecord, C as ProvisioningClaimDecision, D as RecordProviderOperationUncertaintyInput, E as RecordInfrastructureFailureInput, M as TakeOverProviderOperationInput, O as RecordProvisionerIncarnationLostInput, S as ProvisioningAbsenceDecision, T as RecordAllocationTerminatedInput, a as BeginProvisioningInput, b as PendingAttemptAbandonmentDecision, f as ExecutionAttemptOutcomeDecision, h as ExecutionAttemptRepository, i as AllocationTerminationDecision, j as RenewProviderOperationClaimInput, k as RecordProvisioningAbsentInput, n as AllocationRefEvolution, o as DiscoveredAllocationDecision, p as ExecutionAttemptRecord, r as AllocationRefEvolutionDecision, t as AllocationRecordingDecision, v as HandoffProviderOperationInput, w as RecordAllocationInput, x as ProvisionerIncarnationLossDecision, y as InfrastructureFailureDecision } from "./execution-attempt-repository-
|
|
1
|
+
import { l as ProviderOperationOwnershipRecord, o as ProviderOperationClaimDecision, s as ProviderOperationMutationDecision } from "./provider-operation-DbdyFwNm.mjs";
|
|
2
|
+
import { A as RecoverableAttemptRecord, C as ProvisioningClaimDecision, D as RecordProviderOperationUncertaintyInput, E as RecordInfrastructureFailureInput, M as TakeOverProviderOperationInput, O as RecordProvisionerIncarnationLostInput, S as ProvisioningAbsenceDecision, T as RecordAllocationTerminatedInput, a as BeginProvisioningInput, b as PendingAttemptAbandonmentDecision, f as ExecutionAttemptOutcomeDecision, h as ExecutionAttemptRepository, i as AllocationTerminationDecision, j as RenewProviderOperationClaimInput, k as RecordProvisioningAbsentInput, n as AllocationRefEvolution, o as DiscoveredAllocationDecision, p as ExecutionAttemptRecord, r as AllocationRefEvolutionDecision, t as AllocationRecordingDecision, v as HandoffProviderOperationInput, w as RecordAllocationInput, x as ProvisionerIncarnationLossDecision, y as InfrastructureFailureDecision } from "./execution-attempt-repository-BJ2W6wwx.mjs";
|
|
3
3
|
import { IMakaioBus } from "@makaio/framework/bus";
|
|
4
4
|
import * as _$_makaio_contracts0 from "@makaio/framework/contracts";
|
|
5
|
-
import { IWorkflowRunner,
|
|
5
|
+
import { IWorkflowRunner, LoopGateHandler, MakaioNodeExtension, StationHandler, StepRunnerBusAuth, StepRunnerPlatformDefaults, WorkerMaterializationSpec, WorkflowDefinition, WorkflowExecution, WorkflowRunContext, WorkflowRunResult } from "@makaio/framework/contracts";
|
|
6
6
|
import { BaseService } from "@makaio/framework/service-base";
|
|
7
7
|
import { MakaioDatabase } from "@makaio/framework/storage/drizzle";
|
|
8
|
+
import { AutomationTriggerBindingRuntime } from "@makaio/framework/services/automation-trigger";
|
|
8
9
|
|
|
9
10
|
//#region subsystems/workflow-engine/src/storage/handler.d.ts
|
|
10
11
|
/**
|
|
@@ -413,7 +414,6 @@ declare class WorkflowExecutor extends BaseService {
|
|
|
413
414
|
private readonly workflowRunner?;
|
|
414
415
|
private readonly executionAttemptAuthority?;
|
|
415
416
|
private readonly materializationSpecResolvers;
|
|
416
|
-
private triggerTypeRegistry?;
|
|
417
417
|
/**
|
|
418
418
|
* Create a new workflow executor.
|
|
419
419
|
* @param bus - The message bus for communication
|
|
@@ -422,19 +422,6 @@ declare class WorkflowExecutor extends BaseService {
|
|
|
422
422
|
* @param executionAttemptAuthority - Optional Authority for WorkerNode dispatch runners
|
|
423
423
|
*/
|
|
424
424
|
constructor(bus: IMakaioBus, config?: Partial<ExecutorConfig>, workflowRunner?: IWorkflowRunner, executionAttemptAuthority?: ExecutionAttemptAuthority);
|
|
425
|
-
/**
|
|
426
|
-
* Set the trigger type registry for listTriggerTypes support.
|
|
427
|
-
* @param registry - Trigger type registry instance
|
|
428
|
-
*/
|
|
429
|
-
setTriggerTypeRegistry(registry: IWorkflowTriggerTypeRegistry): void;
|
|
430
|
-
/**
|
|
431
|
-
* Retrieve the registry set via {@link setTriggerTypeRegistry}.
|
|
432
|
-
*
|
|
433
|
-
* The composition root calls this after boot to wire
|
|
434
|
-
* `setWorkflowTriggerTypeRegistry` from `@makaio/kernel`.
|
|
435
|
-
* @returns The trigger type registry, or `undefined` if not yet set.
|
|
436
|
-
*/
|
|
437
|
-
getTriggerTypeRegistry(): IWorkflowTriggerTypeRegistry | undefined;
|
|
438
425
|
/**
|
|
439
426
|
* Register a host resolver used to freeze workspace materialization before a
|
|
440
427
|
* path-backed execution is persisted.
|
|
@@ -580,87 +567,241 @@ declare class WorkflowExecutor extends BaseService {
|
|
|
580
567
|
private dispatchPausedExecutionResume;
|
|
581
568
|
}
|
|
582
569
|
//#endregion
|
|
583
|
-
//#region subsystems/workflow-engine/src/
|
|
570
|
+
//#region subsystems/workflow-engine/src/workflow-trigger-reconciler.d.ts
|
|
584
571
|
/**
|
|
585
|
-
*
|
|
572
|
+
* Keeps declarative workflow triggers subscribed to the automation trigger
|
|
573
|
+
* binding runtime.
|
|
586
574
|
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
575
|
+
* The reconciler is the workflow engine's only consumer of automation triggers.
|
|
576
|
+
* It owns no trigger sources and no timers: every persisted
|
|
577
|
+
* {@link WorkflowAutomationTriggerBinding} becomes one listener on the shared
|
|
578
|
+
* runtime, and the runtime decides how many live sources that requires.
|
|
590
579
|
*
|
|
591
|
-
*
|
|
592
|
-
* a `triggerPayload` containing the scheduled fire time.
|
|
580
|
+
* Four invariants define it:
|
|
593
581
|
*
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
*
|
|
582
|
+
* 1. **Storage is the source of truth.** Reconciliation always reads the
|
|
583
|
+
* persisted definitions. Workflow CRUD events and
|
|
584
|
+
* `automation-triggers.changed` events are refresh *signals*, never the state
|
|
585
|
+
* itself, which is why an extension re-enable restores a binding with no
|
|
586
|
+
* workflow CRUD event of its own.
|
|
587
|
+
* 2. **Stable consumer keys.** A consumer is identified by `workflowId` plus the
|
|
588
|
+
* binding's index in the definition's `triggers` array, so a refresh replaces
|
|
589
|
+
* exactly the consumer it belongs to and leaves that workflow's other
|
|
590
|
+
* bindings untouched.
|
|
591
|
+
* 3. **Acquire, designate, release.** Every refresh of a live consumer subscribes
|
|
592
|
+
* the replacement **before** releasing the previous handle, so a source both
|
|
593
|
+
* bindings share is never torn down and re-activated, and a failed acquisition
|
|
594
|
+
* cannot leave a gap. Re-acquiring an unchanged binding is deliberately not
|
|
595
|
+
* special-cased: canonical sharing means it joins the activation it already
|
|
596
|
+
* holds, so the refresh is churn-free by construction. Because the overlap
|
|
597
|
+
* leaves two listeners of the same consumer briefly attached, exactly one of
|
|
598
|
+
* them is *designated* — see {@link ConsumerRecord} — so one event still
|
|
599
|
+
* produces exactly one workflow start. Which one is designated during the
|
|
600
|
+
* overlap follows from whether the replacement resolves to the activation its
|
|
601
|
+
* predecessor's handle already holds, not from timing: a replacement that
|
|
602
|
+
* shares its predecessor's activation
|
|
603
|
+
* stays undesignated until it is live (the outgoing listener is already on
|
|
604
|
+
* that activation and covers every event), while a replacement targeting a
|
|
605
|
+
* *different* activation is designated **before** `subscribe` — its new source
|
|
606
|
+
* may emit from inside `activate`, and the outgoing listener cannot cover an
|
|
607
|
+
* event of an activation it is not attached to. Either way designation moves
|
|
608
|
+
* strictly **before** the previous handle is released, so the release — whose
|
|
609
|
+
* extension-owned cleanup may take arbitrarily long — can never leave a window
|
|
610
|
+
* in which the outgoing listener is already detached while the incoming one is
|
|
611
|
+
* not yet allowed to start. One residual window remains, and is theoretical
|
|
612
|
+
* rather than reachable through storage: for a *changed* binding, events the
|
|
613
|
+
* outgoing source emits between the early designation and the completed
|
|
614
|
+
* acquisition are dropped. They belong to the binding the definition just
|
|
615
|
+
* replaced, so dropping them is the intended reading of a changed binding; if
|
|
616
|
+
* the acquisition then fails, `keep-last-good` restores that designation and
|
|
617
|
+
* the outgoing listener resumes starting the workflow.
|
|
618
|
+
* Acquiring the replacement through {@link AutomationTriggerBindingRuntime}'s
|
|
619
|
+
* `subscribe`/`detach` pair rather than a single combined swap is what makes
|
|
620
|
+
* that ordering expressible, and it is also what lets a refresh survive a
|
|
621
|
+
* runtime restart: the previous handle is released against the runtime that
|
|
622
|
+
* issued it, while the replacement is acquired from the one resolved now.
|
|
623
|
+
* 4. **Availability is probed, not tracked.** The reconciler keeps no record of
|
|
624
|
+
* which trigger kinds are currently registered. A kind that has gone away
|
|
625
|
+
* surfaces as a failed acquisition during the refresh that the registry's
|
|
626
|
+
* `changed` event triggers, and the consumer is dropped there — which is also
|
|
627
|
+
* what guarantees no executable closure survives a deregistration. Probing is
|
|
628
|
+
* scoped by the exact old/new kind union the event carries: only bindings
|
|
629
|
+
* whose registration may have changed are re-acquired. Owner prefixes are
|
|
630
|
+
* deliberately not used as identity because owner names may overlap.
|
|
607
631
|
*/
|
|
608
|
-
declare class
|
|
632
|
+
declare class WorkflowTriggerReconciler {
|
|
609
633
|
private readonly bus;
|
|
634
|
+
private readonly resolveRuntime;
|
|
635
|
+
/** Live consumers: workflow id → trigger index → subscription record. */
|
|
636
|
+
private readonly consumers;
|
|
637
|
+
/** Bus subscription cleanups registered by {@link init}. */
|
|
610
638
|
private readonly cleanupFns;
|
|
639
|
+
/** Records whether a completed initialization is currently live. */
|
|
611
640
|
private initialized;
|
|
641
|
+
/** Shared in-flight initialization, cleared after success or rollback. */
|
|
642
|
+
private initialization;
|
|
612
643
|
/**
|
|
613
|
-
*
|
|
644
|
+
* FIFO reconciliation lane.
|
|
645
|
+
*
|
|
646
|
+
* Refresh signals arrive concurrently — a CRUD event can land while a registry
|
|
647
|
+
* change is still acquiring — and reconciliation is asynchronous because
|
|
648
|
+
* activation is. Serializing every mutation keeps the consumer index and the
|
|
649
|
+
* runtime's reference counts consistent.
|
|
614
650
|
*/
|
|
615
|
-
private readonly
|
|
651
|
+
private readonly lane;
|
|
616
652
|
/**
|
|
617
|
-
*
|
|
653
|
+
* Registry `changed` events whose reconciliation is still pending.
|
|
654
|
+
*
|
|
655
|
+
* A registry change identifies the exact union of one owner's old and new
|
|
656
|
+
* batches, and a contributor replay emits one such event per owner within a
|
|
657
|
+
* single turn. Collecting the events here and flushing on a trailing microtask
|
|
658
|
+
* turns that burst into one pass over the union of their kinds — one storage
|
|
659
|
+
* read instead of one per event. Retaining the complete payload also keeps the
|
|
660
|
+
* owner and revision visible in reconciliation diagnostics.
|
|
661
|
+
*
|
|
662
|
+
* Non-empty exactly while a flush is scheduled, which is also what lets
|
|
663
|
+
* {@link teardown} cancel a pending flush by clearing it.
|
|
618
664
|
*/
|
|
619
|
-
|
|
665
|
+
private readonly pendingChanges;
|
|
620
666
|
/**
|
|
621
|
-
*
|
|
667
|
+
* @param bus - Shared runtime bus.
|
|
668
|
+
* @param resolveRuntime - Resolves the currently live binding runtime.
|
|
669
|
+
* Consulted per reconciliation rather than captured, so a runtime that
|
|
670
|
+
* restarts is picked up by the next refresh instead of leaving the engine
|
|
671
|
+
* holding a dead reference.
|
|
672
|
+
*/
|
|
673
|
+
constructor(bus: IMakaioBus, resolveRuntime: () => AutomationTriggerBindingRuntime | undefined);
|
|
674
|
+
/**
|
|
675
|
+
* Subscribes to refresh signals and reconciles the persisted definitions.
|
|
622
676
|
*
|
|
623
|
-
* Idempotent
|
|
677
|
+
* Idempotent across concurrent and completed calls. A failure while loading
|
|
678
|
+
* the persisted definitions rolls back the signal subscriptions so a later
|
|
679
|
+
* attempt can initialize from a clean state.
|
|
680
|
+
* @returns Resolves once the initial reconciliation has settled.
|
|
681
|
+
* @throws When the persisted definitions cannot be loaded.
|
|
624
682
|
*/
|
|
625
683
|
init(): Promise<void>;
|
|
626
684
|
/**
|
|
627
|
-
*
|
|
685
|
+
* Clears the matching completed initialization attempt.
|
|
686
|
+
* @param initialization - Initialization attempt whose completion is being cleared.
|
|
687
|
+
*/
|
|
688
|
+
private clearInitialization;
|
|
689
|
+
/**
|
|
690
|
+
* Performs one initialization attempt after {@link init} has made it exclusive.
|
|
691
|
+
* @returns Resolves once the initial reconciliation has settled.
|
|
692
|
+
* @throws When the persisted definitions cannot be loaded.
|
|
693
|
+
*/
|
|
694
|
+
private initialize;
|
|
695
|
+
/**
|
|
696
|
+
* Detaches every consumer subscription and stops listening for refreshes.
|
|
697
|
+
*
|
|
698
|
+
* Idempotent, and safe to call on a reconciler that never initialized.
|
|
699
|
+
* @returns Resolves once every detach has settled.
|
|
700
|
+
*/
|
|
701
|
+
destroy(): Promise<void>;
|
|
702
|
+
/**
|
|
703
|
+
* Number of live consumer subscriptions across all workflows.
|
|
628
704
|
*
|
|
629
|
-
*
|
|
705
|
+
* Consumer count, not activation count: two workflows sharing one source
|
|
706
|
+
* report two consumers.
|
|
707
|
+
* @returns Count of live consumers.
|
|
630
708
|
*/
|
|
631
|
-
|
|
632
|
-
activeJobCount(): number;
|
|
709
|
+
activeConsumerCount(): number;
|
|
633
710
|
/**
|
|
634
|
-
*
|
|
711
|
+
* Runs one refresh signal detached from the bus handler that raised it.
|
|
712
|
+
*
|
|
713
|
+
* Bus handlers must not be delayed by reconciliation, and a reconciliation that
|
|
714
|
+
* fails must not surface as a failure of the emitter that signalled it — so the
|
|
715
|
+
* work is detached and its failure logged here, in the one place every signal
|
|
716
|
+
* passes through.
|
|
717
|
+
* @param describe - What was being reconciled, used in the failure log.
|
|
718
|
+
* @param operation - Reconciliation to run.
|
|
719
|
+
*/
|
|
720
|
+
private onSignal;
|
|
721
|
+
/**
|
|
722
|
+
* Records one registry `changed` event and schedules the coalesced pass.
|
|
723
|
+
*
|
|
724
|
+
* The flush runs on a trailing microtask, so every kind named within the turn
|
|
725
|
+
* that raised the first event is reconciled by one pass — see
|
|
726
|
+
* {@link pendingChanges}.
|
|
727
|
+
* @param change - Exact changed-kind scope plus owner/revision diagnostics.
|
|
728
|
+
*/
|
|
729
|
+
private scheduleRegistryReconcile;
|
|
730
|
+
/**
|
|
731
|
+
* Reconciles the persisted workflow definitions and forgets consumers whose
|
|
732
|
+
* workflow no longer exists.
|
|
733
|
+
* @param onFailure - Policy applied when a consumer cannot be acquired.
|
|
734
|
+
* @param kinds - When given, restricts reconciliation to the exact trigger
|
|
735
|
+
* kinds whose registration may have changed; a workflow declaring none of
|
|
736
|
+
* them is left untouched. Omitted at startup, where every binding still has
|
|
737
|
+
* to be acquired.
|
|
738
|
+
* @returns Resolves once every workflow in scope has been reconciled.
|
|
739
|
+
* @throws When the persisted definitions cannot be listed.
|
|
635
740
|
*/
|
|
636
|
-
private
|
|
741
|
+
private reconcileStored;
|
|
637
742
|
/**
|
|
638
|
-
*
|
|
639
|
-
*
|
|
743
|
+
* Reconciles one workflow against storage after a CRUD event named it.
|
|
744
|
+
*
|
|
745
|
+
* The event supplies identity only. The definition is re-read inside the lane,
|
|
746
|
+
* so what is applied is the workflow as it stands when the refresh actually
|
|
747
|
+
* runs — which is also why a deletion needs no separate signal path: a workflow
|
|
748
|
+
* storage no longer holds is simply forgotten.
|
|
749
|
+
* @param workflowId - Workflow named by the event.
|
|
750
|
+
* @returns Resolves once the refresh has settled.
|
|
751
|
+
* @throws When the definition cannot be read.
|
|
640
752
|
*/
|
|
641
|
-
private
|
|
753
|
+
private refreshDefinition;
|
|
642
754
|
/**
|
|
643
|
-
*
|
|
644
|
-
* @param
|
|
755
|
+
* Brings one workflow's consumers in line with its definition. Lane-internal.
|
|
756
|
+
* @param workflow - Definition to apply.
|
|
757
|
+
* @param onFailure - Policy applied when a consumer cannot be acquired.
|
|
758
|
+
* @param kinds - When given, only consumers whose binding has an exact kind in
|
|
759
|
+
* this changed set are refreshed. Bindings outside the scope keep the
|
|
760
|
+
* subscriptions they hold — nothing about them changed.
|
|
761
|
+
* @returns Resolves once every consumer of this workflow in scope has settled.
|
|
645
762
|
*/
|
|
646
|
-
private
|
|
763
|
+
private applyDefinitionWithinLane;
|
|
647
764
|
/**
|
|
648
|
-
*
|
|
649
|
-
* @param
|
|
765
|
+
* Acquires or replaces one consumer subscription. Lane-internal.
|
|
766
|
+
* @param runtime - Live binding runtime.
|
|
767
|
+
* @param workflowId - Workflow owning this consumer.
|
|
768
|
+
* @param triggerIndex - Position of the binding in the definition.
|
|
769
|
+
* @param next - Prepared consumer record to install.
|
|
770
|
+
* @param consumers - Mutable consumer index of this workflow.
|
|
771
|
+
* @param onFailure - Policy applied when the acquisition fails.
|
|
772
|
+
* @returns Resolves once the consumer has settled.
|
|
650
773
|
*/
|
|
651
|
-
private
|
|
774
|
+
private refreshConsumerWithinLane;
|
|
652
775
|
/**
|
|
653
|
-
*
|
|
776
|
+
* Releases every consumer of one workflow. Lane-internal.
|
|
777
|
+
* @param workflowId - Workflow to forget.
|
|
778
|
+
* @returns Resolves once every detach has settled.
|
|
654
779
|
*/
|
|
655
|
-
private
|
|
780
|
+
private forgetWorkflowWithinLane;
|
|
656
781
|
/**
|
|
657
|
-
*
|
|
782
|
+
* Builds the listener that turns one trigger event into a workflow start.
|
|
783
|
+
*
|
|
784
|
+
* The listener first checks that its own record is still the designated one for
|
|
785
|
+
* this consumer key, so a listener that has been superseded or dropped can
|
|
786
|
+
* neither double-start a workflow during a refresh overlap nor start one after
|
|
787
|
+
* its trigger type went away. Consumer-owned filters run next, then the payload
|
|
788
|
+
* is projected onto the `triggerPayload` contract.
|
|
658
789
|
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
*
|
|
790
|
+
* Every failure is logged against this consumer's identity and swallowed: a
|
|
791
|
+
* listener rejection would otherwise surface as a failure of the unrelated
|
|
792
|
+
* source that emitted the event.
|
|
793
|
+
* @param workflowId - Workflow to start on a match.
|
|
794
|
+
* @param triggerIndex - Consumer position, used in diagnostics.
|
|
795
|
+
* @param record - Consumer record this listener belongs to.
|
|
796
|
+
* @returns Listener to attach to the binding runtime.
|
|
797
|
+
*/
|
|
798
|
+
private createListener;
|
|
799
|
+
/**
|
|
800
|
+
* Removes signal subscriptions, cancels a pending coalesced pass, and releases
|
|
801
|
+
* every consumer.
|
|
802
|
+
* @returns Resolves once every detach has settled.
|
|
662
803
|
*/
|
|
663
|
-
private
|
|
804
|
+
private teardown;
|
|
664
805
|
}
|
|
665
806
|
//#endregion
|
|
666
807
|
//#region subsystems/workflow-engine/src/workflow-engine-service.d.ts
|
|
@@ -707,17 +848,29 @@ interface WorkflowEngineServiceOptions {
|
|
|
707
848
|
executionAttemptAuthority?: ExecutionAttemptAuthority;
|
|
708
849
|
/** Host-owned resolvers that create portable specs for path-backed starts. */
|
|
709
850
|
workflowMaterializationSpecResolvers?: readonly WorkflowMaterializationSpecResolver[];
|
|
851
|
+
/**
|
|
852
|
+
* Resolves the host-owned automation trigger binding runtime.
|
|
853
|
+
*
|
|
854
|
+
* Declarative workflow triggers are consumer subscriptions on that runtime, so
|
|
855
|
+
* this is the seam through which the engine reaches trigger sources it does not
|
|
856
|
+
* own. Resolved per reconciliation rather than captured, so a runtime that
|
|
857
|
+
* restarts is picked up by the next refresh.
|
|
858
|
+
*
|
|
859
|
+
* When omitted — or when the resolver returns `undefined` — the engine runs
|
|
860
|
+
* without declarative triggers: direct `WorkflowSubjects.start` requests still
|
|
861
|
+
* work, which is the invocation-only mode a workflow with `triggers: []` uses.
|
|
862
|
+
*/
|
|
863
|
+
automationTriggerBindingRuntime?: () => AutomationTriggerBindingRuntime | undefined;
|
|
710
864
|
}
|
|
711
865
|
/**
|
|
712
866
|
* Workflow engine package service.
|
|
713
867
|
*
|
|
714
|
-
* Owns the boot lifecycle for the workflow executor and trigger
|
|
868
|
+
* Owns the boot lifecycle for the workflow executor and the trigger reconciler so
|
|
715
869
|
* stored triggers become active during normal runtime package startup.
|
|
716
870
|
*/
|
|
717
871
|
declare class WorkflowEngineService extends BaseService {
|
|
718
872
|
private readonly workflowExecutor;
|
|
719
|
-
private readonly
|
|
720
|
-
private readonly cronTriggerEvaluator;
|
|
873
|
+
private readonly triggerReconcilerInstance;
|
|
721
874
|
private readonly attemptAuthority;
|
|
722
875
|
private readonly workspaceRootResolvers;
|
|
723
876
|
/**
|
|
@@ -757,20 +910,10 @@ declare class WorkflowEngineService extends BaseService {
|
|
|
757
910
|
*/
|
|
758
911
|
acceptAuthorityRunnerResult(executionId: string, result: Parameters<WorkflowExecutor['acceptAuthorityRunnerResult']>[1]): ReturnType<WorkflowExecutor['acceptAuthorityRunnerResult']>;
|
|
759
912
|
/**
|
|
760
|
-
*
|
|
761
|
-
* @returns
|
|
913
|
+
* Declarative trigger reconciler owned by this package service.
|
|
914
|
+
* @returns Workflow trigger reconciler instance.
|
|
762
915
|
*/
|
|
763
|
-
get
|
|
764
|
-
/**
|
|
765
|
-
* Set the trigger type registry used by executor request handlers.
|
|
766
|
-
* @param registry - Trigger type registry instance.
|
|
767
|
-
*/
|
|
768
|
-
setTriggerTypeRegistry(registry: IWorkflowTriggerTypeRegistry): void;
|
|
769
|
-
/**
|
|
770
|
-
* Retrieve the executor trigger type registry.
|
|
771
|
-
* @returns Trigger type registry, or `undefined` when none is set.
|
|
772
|
-
*/
|
|
773
|
-
getTriggerTypeRegistry(): IWorkflowTriggerTypeRegistry | undefined;
|
|
916
|
+
get triggerReconciler(): WorkflowTriggerReconciler;
|
|
774
917
|
/**
|
|
775
918
|
* Register a host resolver used to freeze a path-backed workflow's workspace
|
|
776
919
|
* reference before the durable run context is written.
|
|
@@ -791,7 +934,7 @@ declare class WorkflowEngineService extends BaseService {
|
|
|
791
934
|
*/
|
|
792
935
|
resolveWorkspaceRoot(workspaceId: string): Promise<string | undefined>;
|
|
793
936
|
/**
|
|
794
|
-
* Initialize executor handlers before trigger
|
|
937
|
+
* Initialize executor handlers before the trigger reconciler can fire starts.
|
|
795
938
|
* @returns Promise that resolves once all child services are initialized.
|
|
796
939
|
*/
|
|
797
940
|
protected onInit(): Promise<void>;
|
|
@@ -812,6 +955,13 @@ declare const WorkflowEngineToken: _$_makaio_contracts0.ExtensionToken<WorkflowE
|
|
|
812
955
|
* service, wires Drizzle storage handlers, and forwards the provided options
|
|
813
956
|
* to the executor so that composition roots can inject a workflow-level runner
|
|
814
957
|
* or executor configuration (e.g. busUrl, busAuth, platformDefaults).
|
|
958
|
+
*
|
|
959
|
+
* Declarative triggers are reached through the automation trigger binding
|
|
960
|
+
* runtime, resolved lazily from the extension context. The dependency on that
|
|
961
|
+
* runtime is declared **optional**: it orders startup so the runtime is present
|
|
962
|
+
* by the time the engine reconciles stored triggers, without making the runtime
|
|
963
|
+
* undisableable while the engine is active. A host that runs without it keeps
|
|
964
|
+
* invocation-mode workflow starts.
|
|
815
965
|
* @param options - Optional workflow runner and executor config overrides.
|
|
816
966
|
* @returns A `MakaioNodeExtension` manifest for the workflow engine subsystem.
|
|
817
967
|
*/
|
|
@@ -824,4 +974,4 @@ declare function createWorkflowEnginePackage(options?: WorkflowEngineServiceOpti
|
|
|
824
974
|
*/
|
|
825
975
|
declare const workflowEnginePackage: MakaioNodeExtension<IMakaioBus>;
|
|
826
976
|
//#endregion
|
|
827
|
-
export { WorkflowEngineServiceOptions as a,
|
|
977
|
+
export { WorkflowEngineServiceOptions as a, ExecutionAttemptAuthority as c, WorkflowWorkspaceRootResolver as d, registerDrizzleWorkflowStorage as f, WorkflowEngineService as i, WorkflowMaterializationSpecResolution as l, createWorkflowEnginePackage as n, WorkflowTriggerReconciler as o, workflowEnginePackage as r, WorkflowExecutor as s, WorkflowEngineToken as t, WorkflowMaterializationSpecResolver as u };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CapabilitySubjects as e,extensionToken as t}from"@makaio/framework/contracts";import{BaseService as n}from"@makaio/framework/service-base";var r=class extends n{providers=new Map;constructor(e){super(e)}async onInit(){this.registerHandler(e.register,e=>{this.handleRegister(e.payload)}),this.registerHandler(e.unregister,e=>{this.handleUnregister(e.payload)}),this.registerHandler(e.listProviders,e=>{let{capabilityId:t}=e.payload,n=this.getProviders(t);e.setResult({providers:n.map(e=>({id:e.id,displayName:e.displayName,providerKey:e.providerKey}))})}),this.registerHandler(e.validate,async e=>{let{capabilityId:t}=e.payload,n=await this.validateAll(t);e.setResult({results:n})})}handleRegister(e){let{capabilityId:t}=e,n=e.provider,r=this.providers.get(t)??[],i=r.findIndex(e=>e.id===n.id);if(i>=0){r[i]=n;return}r.push(n),this.providers.set(t,r)}handleUnregister(e){this.unregisterProvider(e.capabilityId,e.providerId)}unregisterProvider(e,t){let n=this.providers.get(e);if(!n)return;let r=n.filter(e=>e.id!==t);if(r.length===0){this.providers.delete(e);return}this.providers.set(e,r)}getProviders(e){return this.providers.get(e)??[]}hasProviders(e){let t=this.providers.get(e);return t!==void 0&&t.length>0}getCapabilities(){return[...this.providers.keys()]}async validateAll(e){let t=this.getProviders(e);return Promise.all(t.map(async e=>{if(e.validate){let t=await e.validate();return{id:e.id,...t}}return{id:e.id,valid:!0}}))}onDestroy(){this.providers.clear()}clear(){this.providers.clear()}};const i=t(`capability`),a={name:i.name,displayName:`Capability`,version:`0.1.0`,critical:!0,create:e=>new r(e.bus)};export{a as n,r,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";import{SerialLane as t,canonicalStringify as n,deepFreeze as r}from"@makaio/framework/utils";import{createNamespaceWildcardSubject as i,splitSubjectKey as a}from"@makaio/framework/core";import{matchesSubscription as o}from"@makaio/framework/bus";import{AutomationTriggerLocalNameSchema as s,AutomationTriggerSubjects as c,BUS_EVENT_AUTOMATION_TRIGGER_KIND as l,CRON_AUTOMATION_TRIGGER_KIND as u,CronAutomationTriggerParamsSchema as d,JsonRecordSchema as f,JsonValueSchema as p,createAutomationTriggerDescriptor as m,defineAutomationTrigger as h,dep as g,extensionToken as _,toAutomationTriggerType as v}from"@makaio/framework/contracts";import{BaseService as ee}from"@makaio/framework/service-base";var y=class extends ee{typesByOwner=new Map;typesByKind=new Map;revision=0;mutations=new t;catalog;constructor(e){super(e)}onInit(){this.registerHandler(c.list,e=>{e.setResult({triggers:[...this.list()]})})}onDestroy(){this.typesByOwner=new Map,this.typesByKind=new Map}register(e,t){return this.mutations.run(()=>this.registerWithinLane(e,t))}async registerWithinLane(e,t){let n=this.validateBatch(e,t),r=this.typesByOwner.get(e);if(n.length===0&&r===void 0)return;let i=new Map(this.typesByOwner);n.length===0?i.delete(e):i.set(e,n),this.typesByOwner=i,this.typesByKind=b(this.typesByKind,r??[],n),this.revision+=1;let a=n.length>0?`registered`:`deregistered`,o=Array.from(new Set([...(r??[]).map(({type:e})=>e.kind),...n.map(({type:e})=>e.kind)]));await this.bus.emit(c.changed,{owner:e,revision:this.revision,kinds:o,reason:a}).catch(e=>{console.error(`[AutomationTriggerRegistry] Failed to emit automation-triggers.changed:`,e)})}deregister(e){return this.mutations.run(()=>this.registerWithinLane(e,[]))}resolveRegistration(e){let t=this.typesByKind.get(e);if(t!==void 0)return{owner:t.owner,type:t.type}}list(){let e=this.typesByKind;if(this.catalog?.source===e)return this.catalog.value;let t=Object.freeze(Array.from(e.values(),({descriptor:e})=>e));return this.catalog={source:e,value:t},t}validateBatch(e,t){let n=`${e}.`,i=new Set,a=new Set(this.typesByOwner.get(e)?.map(e=>e.type.kind)),o=[];for(let c of t){let t=c.kind.startsWith(n)?c.kind.slice(n.length):void 0;if(t===void 0||!s.safeParse(t).success)throw Error(`Automation trigger kind '${c.kind}' must be namespaced by owner '${n}'`);if(i.has(c.kind))throw Error(`Duplicate automation trigger kind '${c.kind}' in batch from '${e}'`);if(this.typesByKind.has(c.kind)&&!a.has(c.kind))throw Error(`Automation trigger kind '${c.kind}' is already registered; owner '${e}' cannot claim it`);i.add(c.kind);let l={kind:c.kind,label:c.label,description:c.description,categories:[...c.categories],paramsSchema:c.paramsSchema,eventSchema:c.eventSchema,activate:c.activate},u=r(m(Object.isFrozen(c)?c:l));o.push({owner:e,type:l,descriptor:u})}return o}};function b(e,t,n){let r=new Map(e);for(let e of t)r.delete(e.type.kind);for(let e of n)r.set(e.type.kind,e);return r}function x(e){return JSON.parse(n(e))}function S(e,t){return`${e}:${n(t)}`}const C=`[AutomationTriggerBindingRuntime]`;var w=class{resolver;bindings=new Map;records=new WeakMap;lane=new t;subscriptionCounter=0;closed=!1;constructor(e){this.resolver=e}async subscribe(e,t){let n=this.prepareBinding(e);if(n===void 0)throw Error(`Automation trigger kind '${e.kind}' is not registered`);return n.subscribe(t)}prepareBinding(e){let t=this.resolver.resolveRegistration(e.kind);if(t===void 0)return;let n=T(t.type,e),r={kind:e.kind,owner:t.owner,type:t.type,params:n,bindingKey:S(e.kind,n)};return{bindingKey:r.bindingKey,workflowCompatible:m(t.type).workflowCompatible,subscribe:e=>this.subscribePrepared(r,e)}}async subscribePrepared(e,t){let{entry:n,subscriptionId:r,retired:i}=await this.lane.run(()=>this.admitWithinLane(e,t));i!==void 0&&await this.runCleanup(i);try{await n.activated}catch(e){throw await this.lane.run(async()=>{this.retireWithinLane(n)}),e}return this.lane.run(async()=>{if(this.bindings.get(n.bindingKey)!==n||!n.listeners.has(r))throw Error(`Automation trigger acquisition for '${n.bindingKey}' was retired before it completed`);return this.issueHandle({bindingKey:n.bindingKey,subscriptionId:r})})}resolveBindingKey(e){return this.prepareBinding(e)?.bindingKey}stopOwner(e){return this.retireMatching(t=>t.owner===e)}stopKind(e){return this.retireMatching(t=>t.kind===e)}destroy(){return this.close()}close(){return this.retireMatching(()=>!0,()=>{this.closed=!0})}async admitWithinLane(e,t){if(this.closed)throw Error(`Automation trigger binding runtime is closed; cannot activate '${e.kind}'`);let n=this.resolver.resolveRegistration(e.kind);if(n===void 0)throw Error(`Automation trigger kind '${e.kind}' is not registered`);if(n.owner!==e.owner||n.type!==e.type)throw Error(`Automation trigger registration for '${e.kind}' changed after binding preparation`);this.subscriptionCounter+=1;let r=`s${this.subscriptionCounter}`,i=this.bindings.get(e.bindingKey);if(i?.type===n.type)return i.listeners.set(r,t),{entry:i,subscriptionId:r};let a=i===void 0?void 0:this.retireWithinLane(i),o=Promise.withResolvers(),s={bindingKey:e.bindingKey,kind:e.kind,owner:n.owner,type:n.type,controller:new AbortController,listeners:new Map([[r,t]]),activated:o.promise};return this.bindings.set(e.bindingKey,s),s.activated.catch(()=>void 0),this.startActivation(s,n.type,e.params,o),{entry:s,subscriptionId:r,...a===void 0?{}:{retired:a}}}async startActivation(e,t,n,r){try{r.resolve(await t.activate(this.createContext(e),n))}catch(e){r.reject(e)}}async release(e){let t=await this.lane.run(()=>this.releaseWithinLane(e));t!==void 0&&await this.runCleanup(t)}async releaseWithinLane(e){let t=this.records.get(e);if(t===void 0)throw Error(`${C} subscription handle was not issued by this runtime`);let n=this.bindings.get(t.bindingKey);if(n!==void 0&&n.listeners.delete(t.subscriptionId)&&!(n.listeners.size>0))return this.retireWithinLane(n)}async retireMatching(e,t){let n=await this.lane.run(async()=>{t?.();let n=[];for(let t of Array.from(this.bindings.values())){if(!e(t))continue;let r=this.retireWithinLane(t);r!==void 0&&n.push(r)}return n});await Promise.all(n.map(e=>this.runCleanup(e)))}retireWithinLane(e){if(this.bindings.get(e.bindingKey)===e)return this.bindings.delete(e.bindingKey),e.listeners.clear(),e.controller.abort(),e}async runCleanup(e){let t;try{t=await e.activated}catch{return}try{await t()}catch(t){console.error(`${C} cleanup failed for '${e.bindingKey}':`,t)}}issueHandle(e){let t={bindingKey:e.bindingKey,detach:()=>this.release(t)};return this.records.set(t,e),t}createContext(e){return{bindingKey:e.bindingKey,signal:e.controller.signal,emit:(t,n)=>this.dispatch(e,t,n?.correlationId)}}async dispatch(e,t,n){if(this.bindings.get(e.bindingKey)!==e)return;let r;try{let n=e.type.eventSchema.parse(t);r=e.type.eventSchema===p||e.type.eventSchema===f?n:p.parse(n)}catch(t){throw console.error(`${C} rejected invalid payload from '${e.kind}':`,t),t}let i={kind:e.kind,payload:r,observedAt:Date.now(),...n===void 0?{}:{correlationId:n}},a=Array.from(e.listeners.values()),o=await Promise.allSettled(a.map(async e=>e(i)));for(let t of o)t.status===`rejected`&&console.error(`${C} listener failed for '${e.kind}':`,t.reason)}};function T(e,t){let n=e.paramsSchema.parse(t.params);return x(f.parse(n))}const E=_(`automation-trigger-registry`),D=_(`automation-trigger-runtime`),te={name:E.name,displayName:`Automation Trigger Registry`,version:`0.1.0`,critical:!0,create:e=>new y(e.bus)},O={name:D.name,displayName:`Automation Trigger Binding Runtime`,version:`0.1.0`,critical:!0,create:e=>new w({resolveRegistration:t=>e.getService(E)?.resolveRegistration(t)})};function k(e){return Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)}function A(e,t){return e.y===t.y&&e.m===t.m&&e.d===t.d&&e.h===t.h&&e.i===t.i&&e.s===t.s}function j(e,t){let n=new Date(Date.parse(e));if(isNaN(n))throw Error(`Invalid ISO8601 passed to timezone parser.`);let r=e.substring(9);return r.includes(`Z`)||r.includes(`+`)||r.includes(`-`)?F(n.getUTCFullYear(),n.getUTCMonth()+1,n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),`Etc/UTC`):F(n.getFullYear(),n.getMonth()+1,n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),t)}function M(e,t,n){return N(j(e,t),n)}function N(e,t){let n=new Date(k(e)),r=P(n,e.tz),i=k(e)-k(r),a=new Date(n.getTime()+i),o=P(a,e.tz);if(A(o,e)){let t=new Date(a.getTime()-36e5);return A(P(t,e.tz),e)?t:a}let s=new Date(a.getTime()+k(e)-k(o));if(A(P(s,e.tz),e))return s;if(t)throw Error(`Invalid date passed to fromTZ()`);return a.getTime()>s.getTime()?a:s}function P(e,t){let n,r;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,hour12:!1}),r=n.formatToParts(e)}catch(e){let n=e instanceof Error?e.message:String(e);throw RangeError(`toTZ: Invalid timezone '${t}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${n}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let e of r)(e.type===`year`||e.type===`month`||e.type===`day`||e.type===`hour`||e.type===`minute`||e.type===`second`)&&(i[e.type]=parseInt(e.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw Error(`toTZ: Failed to parse all date components from timezone '${t}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return i.hour===24&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:t}}function F(e,t,n,r,i,a,o){return{y:e,m:t,d:n,h:r,i,s:a,tz:o}}var I=[1,2,4,8,16],L=class{pattern;timezone;mode;alternativeWeekdays;sloppyRanges;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;lastWeekday;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,n){this.pattern=e,this.timezone=t,this.mode=n?.mode??`auto`,this.alternativeWeekdays=n?.alternativeWeekdays??!1,this.sloppyRanges=n?.sloppyRanges??!1,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.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.lastWeekday=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!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.match(/\S+/g)||[``],t=e.length;if(e.length<5||e.length>7)throw TypeError(`CronPattern: invalid configuration format ('`+this.pattern+`'), exactly five, six, or seven space separated parts are required.`);if(this.mode!==`auto`){let e;switch(this.mode){case`5-part`:e=5;break;case`6-part`:e=6;break;case`7-part`:e=7;break;case`5-or-6-parts`:e=[5,6];break;case`6-or-7-parts`:e=[6,7];break;default:e=0}if(!(Array.isArray(e)?e.includes(t):t===e)){let n=Array.isArray(e)?e.join(` or `):e.toString();throw TypeError(`CronPattern: mode '${this.mode}' requires exactly ${n} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift(`0`),e.length===6&&e.push(`*`),e[3].toUpperCase()===`LW`?(this.lastWeekday=!0,e[3]=``):e[3].toUpperCase().indexOf(`L`)>=0&&(e[3]=e[3].replace(/L/gi,``),this.lastDayOfMonth=!0),e[3]==`*`&&(this.starDOM=!0),e[6]==`*`&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.alternativeWeekdays?this.replaceAlphaDaysQuartz(e[5]):this.replaceAlphaDays(e[5])),e[5].startsWith(`+`)&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===``))throw TypeError(`CronPattern: Day-of-week field cannot be empty after '+' modifier.`);switch(e[5]==`*`&&(this.starDOW=!0),this.pattern.indexOf(`?`)>=0&&(e[0]=e[0].replace(/\?/g,`*`),e[1]=e[1].replace(/\?/g,`*`),e[2]=e[2].replace(/\?/g,`*`),e[3]=e[3].replace(/\?/g,`*`),e[4]=e[4].replace(/\?/g,`*`),e[5]=e[5].replace(/\?/g,`*`),e[6]&&=e[6].replace(/\?/g,`*`)),this.mode){case`5-part`:e[0]=`0`,e[6]=`*`;break;case`6-part`:e[6]=`*`;break;case`5-or-6-parts`:e[6]=`*`;break;case`6-or-7-parts`:break;case`7-part`:case`auto`:break}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);let n=this.alternativeWeekdays?-1:0;this.partToArray(`dayOfWeek`,e[5],n,63),this.partToArray(`year`,e[6],0,1),!this.alternativeWeekdays&&this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,n,r){let i=this[e],a=e===`day`&&this.lastDayOfMonth,o=e===`day`&&this.lastWeekday;if(t===``&&!a&&!o)throw TypeError(`CronPattern: configuration entry `+e+` (`+t+`) is empty, check for trailing spaces.`);if(t===`*`)return i.fill(r);let s=t.split(`,`);if(s.length>1)for(let t=0;t<s.length;t++)this.partToArray(e,s[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===3?/[^/*0-9,\-WwLl]+/:t===5?/[^/*0-9,\-#Ll]+/:/[^/*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=e.toUpperCase().includes(`W`);if(t!==`day`&&a)throw TypeError(`CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.`);a&&(t=`nearestWeekdays`);let o=parseInt(i[0],10)+n;if(isNaN(o))throw TypeError(`CronPattern: `+t+` is not a number: '`+e+`'`);this.setPart(t,o,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`||e===`nearestWeekdays`){if(t<0||t>=31)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`month`){if(t<0||t>=12)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`year`&&(t<1||t>=1e4))throw RangeError(`CronPattern: Invalid value for `+e+`: `+t+` (supported range: 1-9999)`);this[e][t]=n}validateNotNaN(e,t){if(isNaN(e))throw TypeError(t)}validateRange(e,t,n,r,i){if(e>t)throw TypeError(`CronPattern: From value is larger than to value: '`+i+`'`);if(n!==void 0){if(n===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(n>this[r].length)throw TypeError(`CronPattern: Syntax error, steps cannot be greater than maximum value of part (`+this[r].length+`)`)}}handleRangeWithStepping(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in ranges with stepping.`);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);this.validateNotNaN(l,`CronPattern: Syntax error, illegal lower range (NaN)`),this.validateNotNaN(u,`CronPattern: Syntax error, illegal upper range (NaN)`),this.validateNotNaN(d,`CronPattern: Syntax error, illegal stepping: (NaN)`),this.validateRange(l,u,d,t,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]}else if(n.toUpperCase().endsWith(`L`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)`);r=`L`,n=n.slice(0,-1)}return[n,r]}handleRange(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in a range.`);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;this.validateNotNaN(o,`CronPattern: Syntax error, illegal lower range (NaN)`),this.validateNotNaN(s,`CronPattern: Syntax error, illegal upper range (NaN)`),this.validateRange(o,s,void 0,t,e);for(let e=o;e<=s;e++)this.setPart(t,e,i[1]||r)}handleStepping(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in parts with stepping.`);let i=this.extractNth(e,t),a=i[0].split(`/`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal stepping: '`+e+`'`);if(this.sloppyRanges)a[0]===``&&(a[0]=`*`);else{if(a[0]===``)throw TypeError(`CronPattern: Syntax error, stepping with missing prefix ('`+e+`') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.`);if(a[0]!==`*`)throw TypeError(`CronPattern: Syntax error, stepping with numeric prefix ('`+e+`') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.`)}let o=0;a[0]!==`*`&&(o=parseInt(a[0],10)+n);let s=parseInt(a[1],10);this.validateNotNaN(s,`CronPattern: Syntax error, illegal stepping: (NaN)`),this.validateRange(0,this[t].length-1,s,t,e);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`)}replaceAlphaDaysQuartz(e){return e.replace(/sun/gi,`1`).replace(/mon/gi,`2`).replace(/tue/gi,`3`).replace(/wed/gi,`4`).replace(/thu/gi,`5`).replace(/fri/gi,`6`).replace(/sat/gi,`7`)}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();if(t===`@yearly`||t===`@annually`)return`0 0 1 1 *`;if(t===`@monthly`)return`0 0 1 * *`;if(t===`@weekly`)return`0 0 * * 0`;if(t===`@daily`||t===`@midnight`)return`0 0 * * *`;if(t===`@hourly`)return`0 * * * *`;if(t===`@reboot`)throw TypeError(`CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.`);return e}setNthWeekdayOfMonth(e,t){if(typeof t!=`number`&&t.toUpperCase()===`L`)this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|I[t-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}},R=[31,28,31,30,31,30,31,31,30,31,30,31],z=[[`month`,`year`,0],[`day`,`month`,-1],[`hour`,`day`,0],[`minute`,`hour`,0],[`second`,`minute`,0]],B=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==null)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`)}getLastDayOfMonth(e,t){return t===1?new Date(Date.UTC(e,t+1,0)).getUTCDate():R[t]}getLastWeekday(e,t){let n=this.getLastDayOfMonth(e,t),r=new Date(Date.UTC(e,t,n)).getUTCDay();return r===0?n-2:r===6?n-1:n}getNearestWeekday(e,t,n){let r=this.getLastDayOfMonth(e,t);if(n>r)return-1;let i=new Date(Date.UTC(e,t,n)).getUTCDay();return i===0?n===r?n-2:n+1:i===6?n===1?n+2:n-1:n}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&63&&I[a-1]&r)return!0;if(r&32){let r=this.getLastDayOfMonth(e,t);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 try{let t=P(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}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${t}`)}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.month<0||this.day>R[this.month]||this.day<1||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=M(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(M(e,this.tz))}findNext(e,t,n,r){return this._findMatch(e,t,n,r,1)}_findMatch(e,t,n,r,i){let a=this[t],o;n.lastDayOfMonth&&(o=this.getLastDayOfMonth(this.year,this.month));let s=!n.starDOW&&t==`day`?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0,c=this[t]+r,l=i===1?e=>e<n[t].length:e=>e>=0;for(let u=c;l(u);u+=i){let i=n[t][u];if(t===`day`&&!i){for(let e=0;e<n.nearestWeekdays.length;e++)if(n.nearestWeekdays[e]){let t=this.getNearestWeekday(this.year,this.month,e-r);if(t===-1)continue;if(t===u-r){i=1;break}}}if(t===`day`&&n.lastWeekday){let e=this.getLastWeekday(this.year,this.month);u-r===e&&(i=1)}if(t===`day`&&n.lastDayOfMonth&&u-r==o&&(i=1),t===`day`&&!n.starDOW){let t=n.dayOfWeek[(s+(u-r-1))%7];if(t&&t&63)t=+!!this.isNthWeekdayOfMonth(this.year,this.month,u-r,t);else if(t)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);n.useAndLogic?i&&=t:!e.domAndDow&&!n.starDOM?i||=t:i&&=t}if(i)return this[t]=u-r,a===this[t]?1:2}return 3}recurse(e,t,n){if(n===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let t=-1;for(let n=this.year+1;n<e.year.length&&n<1e4;n++)if(e.year[n]===1){t=n;break}if(t===-1)return null;this.year=t,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let r=this.findNext(t,z[n][0],e,z[n][2]);if(r>1){let i=n+1;for(;i<z.length;)this[z[i][0]]=-z[i][2],i++;if(r===3){if(this[z[n][1]]++,this[z[n][0]]=-z[n][2],this.apply(),n===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}else if(this.apply())return this.recurse(e,t,n-1)}return n+=1,n>=z.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?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)}decrement(e,t){return this.second-=t.interval!==void 0&&t.interval>1?t.interval:1,this.ms=0,this.apply(),this.recurseBackward(e,t,0,0)}recurseBackward(e,t,n,r=0){if(r>1e4)return null;if(n===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let t=-1;for(let n=this.year-1;n>=0;n--)if(e.year[n]===1){t=n;break}if(t===-1)return null;this.year=t,this.month=11,this.day=31,this.hour=23,this.minute=59,this.second=59,this.ms=0}if(this.year<0)return null}let i=this.findPrevious(t,z[n][0],e,z[n][2]);if(i>1){let a=n+1;for(;a<z.length;){let t=z[a][0],n=z[a][2],r=this.getMaxPatternValue(t,e,n);this[t]=r,a++}if(i===3){if(this[z[n][1]]--,n===0){let e=this.getLastDayOfMonth(this.year,this.month);this.day>e&&(this.day=e)}if(n===1)if(this.day<=0)this.day=1;else{let e=this.year,t=this.month;for(;t<0;)t+=12,e--;for(;t>11;)t-=12,e++;let n=t===1?new Date(Date.UTC(e,t+1,0)).getUTCDate():R[t];this.day>n&&(this.day=n)}this.apply();let i=z[n][0],a=z[n][2],o=this.getMaxPatternValue(i,e,a);if(i===`day`){let e=this.getLastDayOfMonth(this.year,this.month);this[i]=Math.min(o,e)}else this[i]=o;if(this.apply(),n===0){let t=z[1][2],n=this.getMaxPatternValue(`day`,e,t),r=this.getLastDayOfMonth(this.year,this.month),i=Math.min(n,r);i!==this.day&&(this.day=i,this.hour=this.getMaxPatternValue(`hour`,e,z[2][2]),this.minute=this.getMaxPatternValue(`minute`,e,z[3][2]),this.second=this.getMaxPatternValue(`second`,e,z[4][2]))}if(n===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0;)this.year--;if(this.year<0)return null}return this.recurseBackward(e,t,0,r+1)}else if(this.apply())return this.recurseBackward(e,t,n-1,r+1)}return n+=1,n>=z.length?this:this.year<0?null:this.recurseBackward(e,t,n,r+1)}getMaxPatternValue(e,t,n){if(e===`day`&&t.lastDayOfMonth||e===`day`&&!t.starDOW)return this.getLastDayOfMonth(this.year,this.month);for(let r=t[e].length-1;r>=0;r--)if(t[e][r])return r-n;return t[e].length-1-n}findPrevious(e,t,n,r){return this._findMatch(e,t,n,r,-1)}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)):N(F(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}match(e,t){if(!e.starYear&&(this.year<0||this.year>=e.year.length||e.year[this.year]===0))return!1;for(let n=0;n<z.length;n++){let r=z[n][0],i=z[n][2],a=this[r];if(a+i<0||a+i>=e[r].length)return!1;let o=e[r][a+i];if(r===`day`){if(!o){for(let t=0;t<e.nearestWeekdays.length;t++)if(e.nearestWeekdays[t]){let e=this.getNearestWeekday(this.year,this.month,t-i);if(e!==-1&&e===a){o=1;break}}}if(e.lastWeekday&&a===this.getLastWeekday(this.year,this.month)&&(o=1),e.lastDayOfMonth&&a===this.getLastDayOfMonth(this.year,this.month)&&(o=1),!e.starDOW){let n=new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),r=e.dayOfWeek[(n+(a-1))%7];r&&r&63&&(r=+!!this.isNthWeekdayOfMonth(this.year,this.month,a,r)),e.useAndLogic?o&&=r:!t.domAndDow&&!e.starDOM?o||=r:o&&=r}}if(!o)return!1}return!0}};function ne(e){if(e===void 0&&(e={}),delete e.name,e.legacyMode!==void 0&&e.domAndDow===void 0?e.domAndDow=!e.legacyMode:e.domAndDow===void 0&&(e.domAndDow=!1),e.legacyMode=!e.domAndDow,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.dayOffset=e.dayOffset===void 0?0:parseInt(e.dayOffset.toString(),10),e.unref=e.unref===void 0?!1:e.unref,e.mode=e.mode===void 0?`auto`:e.mode,e.alternativeWeekdays=e.alternativeWeekdays===void 0?!1:e.alternativeWeekdays,e.sloppyRanges=e.sloppyRanges===void 0?!1:e.sloppyRanges,![`auto`,`5-part`,`6-part`,`7-part`,`5-or-6-parts`,`6-or-7-parts`].includes(e.mode))throw Error(`CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.`);if(e.startAt&&=new B(e.startAt,e.timezone),e.stopAt&&=new B(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).`);if(e.dayOffset!==void 0&&e.dayOffset!==0&&isNaN(e.dayOffset))throw Error(`CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.`);return e}function V(e){return Object.prototype.toString.call(e)===`[object Function]`||typeof e==`function`||e instanceof Function}function re(e){return V(e)}function H(e){typeof Deno<`u`&&typeof Deno.unrefTimer<`u`?Deno.unrefTimer(e):e&&typeof e.unref<`u`&&e.unref()}var U=30*1e3,W=[],G=class{name;options;_states;fn;getTz(){return this.options.timezone||this.options.utcOffset}applyDayOffset(e){if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let t=this.options.dayOffset*24*60*60*1e3;return new Date(e.getTime()+t)}return e}constructor(e,t,n){let r,i;if(V(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(V(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=ne(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 L(`* * * * *`,void 0,{mode:`auto`})},e&&(e instanceof Date||typeof e==`string`&&e.indexOf(`:`)>0)?this._states.once=new B(e,this.getTz()):this._states.pattern=new L(e,this.options.timezone,{mode:this.options.mode,alternativeWeekdays:this.options.alternativeWeekdays,sloppyRanges:this.options.sloppyRanges}),this.name){if(W.find(e=>e.name===this.name))throw Error(`Cron: Tried to initialize new named job '`+this.name+`', but name already taken.`);W.push(this)}return i!==void 0&&re(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?this.applyDayOffset(t.getDate(!1)):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let n=t||this._states.currentRun||void 0;return this._enumerateRuns(e,n,`next`)}previousRuns(e,t){return this._enumerateRuns(e,t||void 0,`previous`)}_enumerateRuns(e,t,n){let r=[],i=t?new B(t,this.getTz()):null,a=n===`next`?this._next:this._previous;for(;e--;){let e=a.call(this,i);if(!e)break;let t=e.getDate(!1);r.push(this.applyDayOffset(t)),i=e}return r}match(e){if(this._states.once){let t=new B(e,this.getTz());t.ms=0;let n=new B(this._states.once,this.getTz());return n.ms=0,t.getTime()===n.getTime()}let t=new B(e,this.getTz());return t.ms=0,t.match(this._states.pattern,this.options)}getPattern(){if(!this._states.once)return this._states.pattern?this._states.pattern.pattern:void 0}getOnce(){return this._states.once?this._states.once.getDate():null}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 B||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new B(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=W.indexOf(this);e>=0&&W.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>U&&(t=U),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),t),this._states.currentTimeout&&this.options.unref&&H(this._states.currentTimeout),this)}async _trigger(e){this._states.blocking=!0,this._states.currentRun=new B(void 0,this.getTz());try{if(this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){if(V(this.options.catch))try{this.options.catch(e,this)}catch{}}else this.fn!==void 0&&await this.fn(this,this.options.context)}finally{this._states.previousRun=new B(e,this.getTz()),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&&V(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 B(e,this.getTz()),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let r=this._states.once||new B(e,this.getTz());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}_previous(e){let t=new B(e,this.getTz());this.options.stopAt&&t.getTime()>this.options.stopAt.getTime()&&(t=this.options.stopAt);let n=new B(t,this.getTz());return this._states.once?this._states.once.getTime()<t.getTime()?this._states.once:null:(n=n.decrement(this._states.pattern,this.options),n===null||this.options.startAt&&n.getTime()<this.options.startAt.getTime()?null:n)}_calculatePreviousRun(e,t){let n=new B(void 0,this.getTz()),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 B(r,this.getTz()).increment(this._states.pattern,this.options,!0),e=r.getTime()+this.options.interval*1e3;t=!0}return r===null&&(r=void 0),[r,t]}};const K=_(`automation-cron-scheduler`);function q(e){try{new G(e.schedule,{timezone:e.timezone,paused:!0}).nextRun()}catch(t){throw Error(`Invalid cron schedule '${e.schedule}' in timezone '${e.timezone}' for binding '${e.bindingKey}'`,{cause:t})}}const J=`[BusEventAutomationTrigger]`,Y=e.object({subject:e.string().regex(/^[^.]+\.[\s\S]+$/,`Bus-event subject must be '<namespace>.<subject>' with both segments non-empty.`)});function X(e){return v(h({kind:l,label:`Bus Event`,description:`Fires when a matching event is emitted on the Makaio bus.`,categories:[`Bus`],paramsSchema:Y,eventSchema:f,activate:async(t,n)=>{let r=a(n.subject);if(r===void 0)throw Error(`Bus-event parameter schema admitted an unobservable subject: '${n.subject}'`);return e.on(i(r.namespace),e=>{if(e.isRequest||!o(e.subject,n.subject))return;let r=f.safeParse(e.payload);if(!r.success){console.warn(`${J} skipped non-object JSON payload on '${e.subject}':`,r.error);return}let{correlationId:i}=e;t.emit(r.data,i===void 0?void 0:{correlationId:i}).catch(t=>{console.error(`${J} emit failed for '${e.subject}':`,t)})},{handlerKind:`event`})}}))}function Z(e){return[X(e)]}const ie=e.object({scheduledFor:e.number().finite()});function Q(e){return v(h({kind:u,label:`Schedule`,description:`Fires on a cron schedule in a fixed timezone.`,categories:[`Schedule`],paramsSchema:d,eventSchema:ie,activate:async(t,n)=>{let r=e();if(!r)throw Error(`Automation trigger '${u}' requires the '${K.name}' service; no cron scheduler provider is registered.`);return r.schedule({bindingKey:t.bindingKey,schedule:n.schedule,timezone:n.timezone,emit:e=>t.emit(e)})}}))}const $=`makaio`,ae={name:$,displayName:`Makaio Built-in Automation Triggers`,version:`0.1.0`,dependencies:[g(K.name,void 0,!0)],critical:!0,automationTriggers:{createAutomationTriggers:e=>[...Z(e.bus),Q(()=>e.getService(K))]}};export{X as a,G as c,O as d,te as f,y as g,S as h,Z as i,D as l,x as m,ae as n,K as o,w as p,Q as r,q as s,$ as t,E as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SessionStorageSubjects as e}from"./services/session/storage/namespace.mjs";import{ExecutionTargetSubjects as t}from"./services/execution-target/namespace.mjs";import{r as n}from"./attach-error-Cb3GbeKe.mjs";import{MakaioBus as r}from"@makaio/framework/bus";import{AdapterSubjects as i,AgentSubjects as a,DEFAULT_CONSTRAINTS as o,SessionSubjects as s,SpawnSubagentRpcRequestSchema as c,SubagentConfigSchema as l,SubagentError as u,SubagentErrorCode as d,SubagentSubjects as f,dep as p,extensionToken as m}from"@makaio/framework/contracts";import{BaseService as h}from"@makaio/framework/service-base";import{RuntimeProviderContextResolutionError as g,resolveRuntimeProviderContext as _}from"@makaio/framework/services/provider-context";function v(e,t){return`${e}:${t}`}function y(e,t){return e?.authenticated!==!0||!e.id?!1:e.kind===`workflow-execution`?!0:t.size===0?!1:t.has(v(e.kind,e.id))}var b=class{maxSize;items=[];constructor(e=50){this.maxSize=e}push(e){this.items.push(e),this.items.length>this.maxSize&&this.items.shift()}toArray(){return[...this.items]}get length(){return this.items.length}clear(){this.items=[]}};const x=[`completed`,`failed`,`cancelled`];function S(e){return x.includes(e)}var C=class{constraints;subagents=new Map;awaiters=new Map;constructor(e){this.constraints=e}track(e){let t=Date.now(),n={subagentId:e.subagentId,parentSessionId:e.parentSessionId,childSessionId:void 0,status:`spawning`,config:e.config,depth:e.depth,progressUpdates:new b(50),toolObservations:[],completedTurnUsage:new Map,completedTurnSuccess:new Map,toolCallIds:new Set,startTime:t,lastActivityAt:t};return this.subagents.set(e.subagentId,n),n}setChildSessionId(e,t){let n=this.subagents.get(e);n&&(n.childSessionId=t,n.lastActivityAt=Date.now())}markStarted(e){let t=this.subagents.get(e);t&&t.status===`spawning`&&this.applyStatus(t,`running`)}get(e){return this.subagents.get(e)}getByChildSessionId(e){return[...this.subagents.values()].find(t=>t.childSessionId===e)}recordTurnStarted(e,t){let n=this.getByChildSessionId(e);n===void 0||S(n.status)||(n.activeTurnId=t,n.lastActivityAt=Date.now())}recordTurnCompleted(e,t){let n=this.getByChildSessionId(e);n===void 0||S(n.status)||(n.activeTurnId===t&&(n.activeTurnId=void 0),n.lastActivityAt=Date.now())}recordToolObservation(e,t,n){let r=this.getByChildSessionId(e);if(!(r===void 0||S(r.status))){if(n!==void 0){if(r.toolCallIds.has(n))return;r.toolCallIds.add(n)}r.toolObservations.push(t),r.lastActivityAt=Date.now()}}getAllNonTerminal(){let e=[];for(let t of this.subagents.values())S(t.status)||e.push(t);return e}countActiveBySession(e){let t=0;for(let n of this.subagents.values())n.parentSessionId===e&&!S(n.status)&&t++;return t}countTotalActive(){let e=0;for(let t of this.subagents.values())S(t.status)||e++;return e}updateStatus(e,t){let n=this.subagents.get(e);n&&this.applyStatus(n,t)}applyStatus(e,t){let n=Date.now();e.status=t,e.lastActivityAt=n,S(t)&&(e.activeTurnId=void 0,e.endTime=n)}addProgress(e,t){let n=this.subagents.get(e);n&&(n.progressUpdates.push(t),n.lastActivityAt=Date.now())}setPendingRequest(e,t){let n=this.subagents.get(e);if(!n)throw new u(d.NOT_FOUND,`Subagent ${e} not found`);if(n.pendingRequest)throw new u(d.REQUEST_PENDING,`Cannot call request_input while another request is pending`);if(n.completionCandidate!==void 0)throw new u(d.INVALID_STATE,`Cannot request input while completion is pending`);n.pendingRequest=t,n.status=`waiting_input`,n.lastActivityAt=Date.now()}resolvePendingRequest(e,t){let n=this.subagents.get(e);n?.pendingRequest&&(n.pendingRequest.resolver(t),n.pendingRequest=void 0,n.lastActivityAt=Date.now(),n.status===`waiting_input`&&(n.status=`running`))}markCompleted(e,t,n,r){let i=this.subagents.get(e);if(!i)throw new u(d.NOT_FOUND,`Subagent ${e} not found`);if(S(i.status))throw new u(d.ALREADY_TERMINAL,`Subagent already in terminal state: ${i.status}`);this.applyStatus(i,`completed`),i.result=t,i.summary=n,i.completionSource=r,this.resolveAwaiters(e)}recordCompletionCandidate(e,t,n,r,i){let a=this.subagents.get(e);if(!a)throw new u(d.NOT_FOUND,`Subagent ${e} not found`);let o=a.completionCandidate;if(o!==void 0){if(o.turnId===t&&o.result===n&&o.summary===r&&o.source===i)return;throw new u(d.INVALID_STATE,`Conflicting subagent completion candidate`)}if(S(a.status))throw new u(d.ALREADY_TERMINAL,`Subagent already in terminal state: ${a.status}`);if(a.pendingRequest!==void 0)throw new u(d.INVALID_STATE,`Cannot complete while an input request is pending`);a.completionCandidate={turnId:t,result:n,summary:r,source:i},a.status=`completing`,a.lastActivityAt=Date.now()}recordCompletedTurn(e,t,n,r=!0,i){let a=this.subagents.get(e);a===void 0||S(a.status)||(a.completedTurnUsage.has(t)||(a.completedTurnUsage.set(t,n===void 0?void 0:{total:{...n.total},...n.byAgent===void 0?{}:{byAgent:Object.fromEntries(Object.entries(n.byAgent).map(([e,t])=>[e,{...t}]))}}),a.completedTurnSuccess.set(t,{success:r,...i!==void 0&&{error:i}})),a.lastActivityAt=Date.now())}finalizeCompletionIfReady(e){let t=this.subagents.get(e);if(!t)throw new u(d.NOT_FOUND,`Subagent ${e} not found`);if(S(t.status))return!1;let n=t.completionCandidate;if(n===void 0||!t.completedTurnUsage.has(n.turnId))return!1;let r=t.completedTurnSuccess.get(n.turnId);if(r?.success===!1)return this.markFailed(e,r.error??`child turn failed`),!0;let i=this.freezeUsage(t);return this.applyStatus(t,`completed`),t.result=n.result,t.summary=n.summary,t.completionSource=n.source,t.usage=i,this.resolveAwaiters(e),!0}freezeUsage(e){let t=0,n=0,r=0,i=!1;for(let a of e.completedTurnUsage.values())a!==void 0&&(i=!0,t+=a.total.inputTokens,n+=a.total.cachedInputTokens??0,r+=a.total.outputTokens);return Object.freeze({...i?{inputTokens:t,cachedInputTokens:n,outputTokens:r}:{},toolCallCount:e.toolCallIds.size})}markFailed(e,t){let n=this.subagents.get(e);!n||S(n.status)||(this.applyStatus(n,`failed`),n.error=t,this.resolveAwaiters(e))}markCancelled(e){let t=this.subagents.get(e);return!t||S(t.status)?!1:(this.applyStatus(t,`cancelled`),t.pendingRequest&&=(t.pendingRequest.resolver(null),void 0),this.resolveAwaiters(e),!0)}addAwaiter(e,t){let n=this.awaiters.get(e)??[];n.push(t),this.awaiters.set(e,n)}removeAwaiter(e,t){let n=this.awaiters.get(e);if(!n)return!1;let r=n.indexOf(t);return r===-1?!1:(n.splice(r,1),n.length===0&&this.awaiters.delete(e),!0)}resolveAwaiters(e){let t=this.subagents.get(e),n=this.awaiters.get(e);if(!n||!t)return;let r={status:t.status,result:t.result,error:t.error,completionSource:t.completionSource,usage:t.usage,toolObservations:[...t.toolObservations]};for(let e of n)e(r);this.awaiters.delete(e)}cleanup(){let e=Date.now(),t=0;for(let[n,r]of this.subagents)S(r.status)&&r.endTime&&e-r.endTime>this.constraints.stateRetentionMs&&(this.subagents.delete(n),t++);return t}sweepHung(e){if(e<=0)return 0;let t=Date.now(),n=0;for(let r of this.subagents.values())S(r.status)||r.status!==`spawning`&&r.status!==`waiting_input`&&r.status!==`hung`&&t-r.lastActivityAt>=e&&(r.status=`hung`,r.lastActivityAt=t,n++);return n}};async function w(e,t,n){let r=n?.trim();if(r)return r;let{session:i}=await e.request(s.get,{sessionId:t});return(i?.agents.find(e=>e.agentId===i.leadAgentId)??i?.agents[0])?.adapterName?.trim()}function T(e,t){let n=e.manager.get(t.subagentId);if(!n)throw Error(`Subagent not found: ${t.subagentId}`);return{status:n.status,childSessionId:n.childSessionId,pendingRequest:n.pendingRequest?{messageId:n.pendingRequest.messageId,question:n.pendingRequest.question,context:n.pendingRequest.context}:void 0,progress:n.progressUpdates.toArray(),result:n.result,summary:n.summary,error:n.error,usage:n.usage}}async function E(e,t){let{parentSessionId:n,config:r,depth:i,spawningToolCallId:a}=t,{constraints:o}=e.manager,s=Math.min(r.maxDepth??o.maxDepth,o.maxDepth);if(i>s)throw new u(d.DEPTH_EXCEEDED,`Maximum subagent depth (${s}) exceeded`);if(e.manager.countActiveBySession(n)>=o.maxConcurrentPerSession)throw new u(d.SESSION_LIMIT,`Maximum concurrent subagents per session (${o.maxConcurrentPerSession}) reached`);if(e.manager.countTotalActive()>=o.maxTotalActive)throw new u(d.GLOBAL_LIMIT,`Maximum total active subagents (${o.maxTotalActive}) reached`);let c=await w(e.bus,n,r.adapterName);if(!c)throw new u(d.ADAPTER_NOT_ALLOWED,`adapterName is required for subagent spawn when parent session has no inheritable adapter`);if(o.allowedAdapters.length>0&&!o.allowedAdapters.includes(c))throw new u(d.ADAPTER_NOT_ALLOWED,`Adapter '${c}' is not allowed`);if(r.model&&o.allowedModels.length>0&&!o.allowedModels.includes(r.model))throw new u(d.MODEL_NOT_ALLOWED,`Model '${r.model}' is not allowed`);let l={...r,adapterName:c},p=crypto.randomUUID();return e.manager.track({subagentId:p,parentSessionId:n,config:l,depth:i}),await e.bus.emit(f.spawned,{subagentId:p,parentSessionId:n,task:l.task,config:l,depth:i,...e.executionOwnerId!==void 0&&{executionOwnerId:e.executionOwnerId},...a!==void 0&&{spawningToolCallId:a}}),{subagentId:p,status:`spawning`}}async function D(e,t){let{subagentId:n,timeoutMs:r}=t,i=e.manager.get(n);if(!i)throw Error(`Subagent not found: ${n}`);if([`completed`,`failed`,`cancelled`].includes(i.status))return{status:i.status,result:i.result,error:i.error,completionSource:i.completionSource,toolObservations:[...i.toolObservations],usage:i.usage};if(i.status===`waiting_input`&&i.pendingRequest)return{status:`waiting_input`,pendingRequest:{messageId:i.pendingRequest.messageId,question:i.pendingRequest.question,context:i.pendingRequest.context}};let a=r??e.manager.constraints.defaultAwaitTimeoutMs;return new Promise(t=>{let r=!1,i,o=e=>{r||(r=!0,i&&clearTimeout(i),t({status:e.status,result:e.result,error:e.error,pendingRequest:e.pendingRequest,completionSource:e.completionSource,toolObservations:e.toolObservations,usage:e.usage}))};e.manager.addAwaiter(n,o),a>0&&(i=setTimeout(()=>{r||(r=!0,e.manager.removeAwaiter(n,o),t({status:`timeout`}))},a))})}async function O(e,t){let{subagentId:n,content:r,inResponseTo:i}=t,a=e.manager.get(n);if(!a)throw Error(`Subagent not found: ${n}`);if(a.status===`spawning`)throw new u(d.INVALID_STATE,`Cannot send to a subagent before startup completes`);if(a.completionCandidate!==void 0)throw new u(d.INVALID_STATE,`Cannot send to a subagent while completion is pending`);let o=!1;return i&&a.pendingRequest?.messageId===i&&(e.manager.resolvePendingRequest(n,r),o=!0),await e.bus.emit(f.toChild,{subagentId:n,messageId:crypto.randomUUID(),content:r,inResponseTo:i}),{sent:!0,resolvedPending:o}}async function k(e,t){let{subagentId:n,reason:r}=t,i=e.manager.markCancelled(n);return i&&await e.bus.emit(f.cancelled,{subagentId:n,reason:r??`Killed by parent`}),{killed:i}}async function A(e,t){let{subagentId:n,update:r,percentComplete:i}=t;if(!e.manager.get(n))throw Error(`Subagent not found: ${n}`);let a=i===void 0?r:`[${i}%] ${r}`;return e.manager.addProgress(n,a),await e.bus.emit(f.toParent,{subagentId:n,messageId:crypto.randomUUID(),type:`progress`,content:a}),{reported:!0}}async function j(e,t){let{subagentId:n,question:r,context:i,timeoutMs:a}=t,o=e.manager.get(n);if(!o)throw Error(`Subagent not found: ${n}`);if(o.completionCandidate!==void 0)throw new u(d.INVALID_STATE,`Cannot request input while completion is pending`);let s=crypto.randomUUID(),c=a??e.manager.constraints.defaultRequestTimeoutMs,l=!1,p,m,h=new Promise(e=>{m=e});e.manager.setPendingRequest(n,{messageId:s,question:r,context:i,resolver:e=>{l||(l=!0,p&&clearTimeout(p),m(e===null?{responded:!1,timedOut:!0}:{responded:!0,response:e,timedOut:!1}))}}),c>0&&(p=setTimeout(()=>{l||e.manager.resolvePendingRequest(n,null)},c));let g=e.bus.emit(f.toParent,{subagentId:n,messageId:s,type:`request_input`,content:r,context:i}).then(()=>({published:!0}),e=>({published:!1,error:e})),_=await Promise.race([h.then(e=>({response:e})),g]);if(`response`in _)return _.response;if(!_.published)throw e.manager.resolvePendingRequest(n,null),_.error;return h}async function M(e,t){let{sessionId:n,turnId:r,result:i,summary:a}=t,o=e.manager.getByChildSessionId(n);if(o===void 0)throw new u(d.NOT_FOUND,`No subagent owns this child session`);if(o.status===`completed`||o.status===`failed`||o.status===`cancelled`)throw new u(d.ALREADY_TERMINAL,`Subagent already in terminal state: ${o.status}`);let s=o.activeTurnId;if(s===void 0)throw new u(d.INVALID_STATE,`No active turn exists for this child session`);if(r!==void 0&&r!==s)throw new u(d.INVALID_STATE,`Completion turn does not match the active child turn`);return e.manager.recordCompletionCandidate(o.subagentId,s,i,a,`tool`),await e.onCompletionCandidate?.(o.subagentId),{completed:!0}}function N(e,t){let{parentSessionId:n}=t;return{subagents:e.manager.getAllNonTerminal().filter(e=>e.parentSessionId===n).map(e=>({subagentId:e.subagentId,task:e.config.task,status:e.status}))}}function P(e,t,n,r){return{kind:`adapter`,adapterName:e,...n!==void 0&&{providerContext:n},...t.model!==void 0&&{model:t.model},...t.reasoningEffort!==void 0&&{reasoningEffort:t.reasoningEffort},...t.systemPrompt!==void 0&&{systemPrompt:t.systemPrompt},...t.adapterConfig!==void 0&&{adapterConfig:t.adapterConfig},...r!==void 0&&{cwd:r},...t.tools!==void 0&&{allowedTools:t.tools},...t.disallowedTools!==void 0&&{disallowedTools:t.disallowedTools},...t.allowedDirectories!==void 0&&{allowedDirectories:t.allowedDirectories}}}async function F(e,t){let{subagentId:n,adapterName:r,config:i,sessionId:a,task:o,targetWorkingDirectory:c,assertAdmission:l}=t,u=i.providerContext;if(u?.state===`resolved`&&i.providerConfigId!==void 0&&i.providerConfigId!==u.providerConfigId)throw Error(`Subagent providerConfigId "${i.providerConfigId}" does not match its resolved provider context "${u.providerConfigId}".`);if(u?.state===`unresolved`&&i.providerConfigId!==void 0)throw new g(`provider-context-unresolved`,r,i.providerConfigId);let d=u??(i.providerConfigId?await _(e,{adapterName:r,providerConfigId:i.providerConfigId}):void 0);await e.request(s.agent.attachResolved,{sessionId:a,role:`lead`,initialMessage:o,source:`system`,assertInitialMessageAdmission:()=>{try{l()}catch{throw Error(`Subagent startup was cancelled before initial task admission: ${n}`)}},...i.responseSchema!==void 0&&{responseSchema:i.responseSchema},...i.harnessId!==void 0&&{harnessId:i.harnessId},agent:P(r,i,d,c)},{timeout:0})}const I={id:`system:local`,name:`Local`,description:`Default local process execution`,type:`local`,scope:`default`,enabled:!0,createdAt:Date.now(),updatedAt:Date.now()};var L=class extends Error{code;constructor(e){super(`Subagent failure finalization failed (${e}).`),this.code=e,this.name=`SubagentFailureFinalizationError`}},R=class extends h{delegationAllowSet;requestHandlerPriority;executionOwnerId;manager;pendingChildSessionClose=new Set;spawningExecutions=new Set;constructor(e=r,t=o,n=new Set,i=0,a=crypto.randomUUID()){super(e),this.delegationAllowSet=n,this.requestHandlerPriority=i,this.executionOwnerId=a,this.manager=new C(t)}grantDelegation(e,t){this.delegationAllowSet.add(`${e}:${t}`)}revokeDelegation(e,t){this.delegationAllowSet.delete(`${e}:${t}`)}onInit(){this.registerHandler(f.spawned,async e=>{e.payload.executionOwnerId!==void 0&&e.payload.executionOwnerId!==this.executionOwnerId||this.handleSpawned(e.payload).catch(e=>{console.error(`[SubagentService] handleSpawned error:`,e)})}),this.registerHandler(f.execute,async e=>{if(!this.isRemoteDelegationAllowed(e))return;let t=await this.handleExecute(e.payload);e.setResult(t)}),this.registerHandler(f.toChild,async e=>{await this.handleToChild(e.payload)}),this.registerHandler(f.completed,async e=>{await this.handleCompleted(e.payload.subagentId)}),this.registerHandler(f.cancelled,async e=>{await this.handleCancelled(e.payload.subagentId)}),this.registerHandler(i.session.closed,e=>{this.handleAdapterSessionClosed(e.payload.sessionId)}),this.registerHandler(a.complete,async e=>{await this.handleAgentComplete(e.payload)}),this.registerHandler(s.turn.completed,async e=>{await this.handleSessionTurnCompleted(e.payload)}),this.registerHandler(s.turn.started,e=>{this.handleSessionTurnStarted(e.payload)}),this.registerHandler(a.tool.completed,e=>{e.payload._import||e.payload.sessionId===void 0||e.payload.success===void 0||this.manager.recordToolObservation(e.payload.sessionId,{toolName:e.payload.toolName,outcome:e.payload.success?`success`:`failure`,...e.payload.success===!0&&e.payload.artifactResult!==void 0?{artifact:e.payload.artifactResult}:{}},e.payload.toolCallId)}),this.registerRpcHandlers(),this.wirePeriodicSweep()}wirePeriodicSweep(){let{inactivityTimeoutMs:e,sweepIntervalMs:t}=this.manager.constraints;if(t<=0)return;let n=setInterval(()=>{let t=this.manager.sweepHung(e);t>0&&console.warn(`[SubagentService] Swept ${t} hung subagent(s) due to inactivity`),this.manager.cleanup()},t);this.addCleanup(()=>clearInterval(n))}registerRpcHandlers(){let e={manager:this.manager,bus:this.bus,executionOwnerId:this.executionOwnerId,onCompletionCandidate:e=>this.finalizeSubagentIfReady(e)};this.registerHandler(f.getStatus,t=>{let n=T(e,t.payload);t.setResult(n)},{priority:this.requestHandlerPriority}),this.registerHandler(f.spawn,async t=>{if(!this.isRemoteDelegationAllowed(t))return;let n=await E(e,c.parse(t.payload));t.setResult(n)},{priority:this.requestHandlerPriority}),this.registerHandler(f.await,async t=>{let n=await D(e,t.payload);t.setResult(n)},{priority:this.requestHandlerPriority}),this.registerHandler(f.send,async t=>{let n=await O(e,t.payload);t.setResult(n)}),this.registerHandler(f.kill,async t=>{let n=await k(e,t.payload);t.setResult(n)},{priority:this.requestHandlerPriority}),this.registerHandler(f.reportProgress,async t=>{let n=await A(e,t.payload);t.setResult(n)}),this.registerHandler(f.requestInput,async t=>{let n=await j(e,t.payload);t.setResult(n)}),this.registerHandler(f.completeTask,async t=>{let n=await M(e,t.payload);t.setResult(n)}),this.registerHandler(f.listBySession,t=>{let n=N(e,t.payload);t.setResult(n)})}onDestroy(){this.pendingChildSessionClose.clear(),this.spawningExecutions.clear()}async handleSpawned(e){let{subagentId:t,parentSessionId:n,task:r,spawningToolCallId:i}=e,a=this.manager.get(t);if(!(a&&a.status!==`spawning`)&&!this.spawningExecutions.has(t)){this.spawningExecutions.add(t);try{return await this.executeSpawned(e,n,r,i)}finally{this.spawningExecutions.delete(t)}}}async executeSpawned(e,n,r,i){let{subagentId:a}=e,o=()=>this.shouldAbortSpawn(this.manager.get(a)?.status),s=l.parse({...e.config,task:r}),c=s.adapterName?.trim();if(!c)return this.failSpawn(a,n,`adapter_start`,`Subagent spawn requires a non-empty adapterName`);this.manager.get(a)||this.manager.track({subagentId:a,parentSessionId:n,config:s,depth:e.depth??1});let u,d;try{d=await this.buildExecutionTargetResolutionParams(n,s.executionTargetId);let e=await this.bus.requestOptional(t.resolve,d),r;if(e.handled)r=e.data.executionTarget;else if(d.executionTargetId!=null)throw Error(`Execution target resolver unavailable for explicit target '${d.executionTargetId}'`);else r=I;if(r.type!==`local`)return this.failSpawn(a,n,`adapter_start`,`Execution target type '${r.type}' is not yet supported for subagents`);u=d.executionTargetId??void 0}catch(e){return this.failSpawn(a,n,`adapter_start`,e)}let f;try{f=await this.createChildSessionForSpawn(a,n,s,u,d,i)}catch(e){return this.failSpawn(a,n,`session_create`,e)}if(!o())return this.attachSpawnedSubagent({subagentId:a,parentSessionId:n,adapterName:c,config:s,sessionId:f,task:r,targetWorkingDirectory:d.targetWorkingDirectory,shouldAbort:o})}async attachSpawnedSubagent(e){let{subagentId:t,parentSessionId:r,adapterName:i,config:a,sessionId:o,task:s,targetWorkingDirectory:c,shouldAbort:l}=e;try{await F(this.bus,{subagentId:t,adapterName:i,config:a,sessionId:o,task:s,targetWorkingDirectory:c,assertAdmission:()=>{if(this.shouldAbortSpawn(this.manager.get(t)?.status))throw Error(`startup cancelled`)}})}catch(e){if(l())return;let i=n(e);return this.failSpawn(t,r,i?.stage===`initial_message`?`agent_start`:`adapter_start`,e)}l()||this.manager.markStarted(t)}async createChildSessionForSpawn(e,t,n,r,i,a){let{sessionId:o}=await this.bus.request(s.create,this.buildChildSessionCreatePayload(t,n,r,i.targetWorkingDirectory,a));return this.manager.setChildSessionId(e,o),this.pendingChildSessionClose.has(e)&&await this.closeChildSession(e),o}async failSpawn(e,t,n,r){let i=r instanceof Error?r:Error(String(r));this.manager.markFailed(e,i.message);let[a,o]=await Promise.allSettled([this.manager.get(e)?.childSessionId===void 0?Promise.resolve():this.requestChildSessionClose(e),this.emitExecutionFailed(e,t,n,i)]),s=[];if(a.status===`rejected`&&s.push(new L(`child-session-close-failed`)),o.status===`rejected`&&s.push(new L(`failure-publication-failed`)),s.length>0)throw AggregateError([i,...s],`Subagent spawn failed and failure finalization also failed.`);return i.message}async buildExecutionTargetResolutionParams(t,n){if(n!==void 0)return{executionTargetId:n};let{session:r}=await this.bus.request(e.get,{sessionId:t});if(!r)throw Error(`Parent session not found: ${t}`);return{...r.executionTargetId!==void 0&&{executionTargetId:r.executionTargetId},...r.targetWorkingDirectory!==void 0&&{targetWorkingDirectory:r.targetWorkingDirectory}}}buildChildSessionCreatePayload(e,t,n,r,i){return{branchKind:`subagent`,parentSessionId:e,contextInheritance:t.contextMode===`fork`?`parent-history`:`none`,...n!==void 0&&{executionTargetId:n},...r!==void 0&&{targetWorkingDirectory:r},...i!==void 0&&{spawningToolCallId:i}}}async handleExecute(e){let t=l.parse({...e.config,task:e.task});this.manager.track({subagentId:e.subagentId,parentSessionId:e.parentSessionId,config:t,depth:e.depth});let n=await this.handleSpawned({subagentId:e.subagentId,parentSessionId:e.parentSessionId,task:e.task,config:t,depth:e.depth});return n?{success:!1,error:n}:{success:!0}}async handleToChild(e){let{subagentId:t,content:n}=e,r=this.manager.get(t);if(!r){console.warn(`[SubagentService] No subagent found: ${t}`);return}if(!r.childSessionId){console.warn(`[SubagentService] No child session for subagent: ${t}`);return}try{await this.bus.request(s.sendMessage,{sessionId:r.childSessionId,message:n,source:`system`})}catch(e){console.error(`[SubagentService] Failed to route message to child session:`,e)}}async handleCompleted(e){await this.closeChildSession(e)}async handleCancelled(e){await this.closeChildSession(e)}async closeChildSession(e){try{await this.requestChildSessionClose(e)}catch{console.error(`[SubagentService] Failed to close child session for subagent ${e}:`,new L(`child-session-close-failed`))}}async requestChildSessionClose(e){let t=this.manager.get(e);if(t){if(!t.childSessionId){this.pendingChildSessionClose.add(e);return}this.pendingChildSessionClose.delete(e),await this.bus.request(s.close,{sessionId:t.childSessionId})}}shouldAbortSpawn(e){return e===void 0||e===`completed`||e===`failed`||e===`cancelled`}handleAdapterSessionClosed(e){for(let t of this.manager.getAllNonTerminal())if(t.childSessionId===e){console.warn(`[SubagentService] Adapter session closed for subagent ${t.subagentId}: ${e}`),this.manager.markFailed(t.subagentId,`adapter-session-closed`);return}}async handleAgentComplete(e){let{sessionId:t,turnId:n,outcome:r,message:i,error:a}=e;if(!(!t||!n))for(let e of this.manager.getAllNonTerminal()){if(e.childSessionId!==t)continue;if((e.config.completion??`tool`)!==`turn`||e.status===`waiting_input`)return;let o=r??`completed`;if(o===`completed`)try{this.manager.recordCompletionCandidate(e.subagentId,n,i??``,void 0,`turn`),await this.finalizeSubagentIfReady(e.subagentId)}catch{return}else if(o===`error`)try{this.manager.recordCompletionCandidate(e.subagentId,n,a??`child turn failed`,void 0,`turn`),await this.finalizeSubagentIfReady(e.subagentId)}catch{return}return}}async handleSessionTurnCompleted(e){if(e.ingestionMarker!==`backfill`){for(let t of this.manager.getAllNonTerminal())if(t.childSessionId===e.sessionId){if(this.manager.recordTurnCompleted(e.sessionId,e.turnId),this.manager.recordCompletedTurn(t.subagentId,e.turnId,e.usage,e.success,e.error),t.completionCandidate?.turnId!==e.turnId)return;await this.finalizeSubagentIfReady(t.subagentId);return}}}handleSessionTurnStarted(e){e.ingestionMarker!==`backfill`&&this.manager.recordTurnStarted(e.sessionId,e.turnId)}async finalizeSubagentIfReady(e){if(!this.manager.finalizeCompletionIfReady(e))return;let t=this.manager.get(e);await this.bus.emit(f.completed,{subagentId:e,success:t?.status===`completed`,...t?.status===`completed`?{result:t.summary?`${t.summary}\n\n${t.result??``}`:t?.result,usage:t.usage}:{error:t?.error??`child turn failed`}})}isRemoteDelegationAllowed(e){return e.origin.local||y(e.transport?.peer,this.delegationAllowSet)}async emitExecutionFailed(e,t,n,r){let i=r instanceof Error?r.message:String(r);await this.bus.emit(f.executionFailed,{subagentId:e,parentSessionId:t,phase:n,error:i})}};const z=m(`subagent-service`);function B(e=0){return{name:z.name,displayName:`Subagent Service`,version:`0.1.0`,critical:!0,surface:`headless`,dependencies:[p(`session`)],create:t=>new R(t.bus,o,new Set,e)}}const V=B();export{R as a,L as i,B as n,C as o,V as r,y as s,z as t};
|
package/dist/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./version-
|
|
1
|
+
import{t as e}from"./version-BYeVh1pI.mjs";import{z as t}from"zod";import*as n from"node:path";const r=t.string().trim().min(1),i=t.number().int().finite().nonnegative().describe(`Unix epoch timestamp in milliseconds`);function a(e){return n.posix.isAbsolute(e)||n.win32.isAbsolute(e)}const o=t.string().trim().min(1).refine(a,{message:`Path must be absolute`}),s=t.string().min(1).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/,`Profile name must be a safe path component`),c=s,l=t.object({id:r,clientId:r,name:s,description:t.string().nullable(),configDir:o,isDefault:t.boolean(),createdAt:i,updatedAt:i}),u=t.record(t.string(),t.string()),d=t.enum([`auth-only`,`full`,`empty`]),f={"profile.create":{request:t.object({clientId:r,name:s,description:t.string().optional()}),response:t.object({profile:l})},"profile.list":{request:t.object({clientId:r}),response:t.object({profiles:t.array(l)})},"profile.get":{request:t.object({clientId:r,name:s}),response:t.object({profile:l.nullable()})},"profile.update":{request:t.object({clientId:r,name:s,description:t.string().optional()}),response:t.object({profile:l})},"profile.delete":{request:t.object({clientId:r,name:s}),response:t.object({success:t.boolean()})},"profile.setDefault":{request:t.object({clientId:r,name:s}),response:t.object({profile:l})}},p={"sessionConfig.create":{request:t.object({clientId:r,leaseId:c,ownerSessionId:r.optional(),profileName:s.optional(),baseConfigDir:o.optional(),projectDir:o.optional(),configInheritance:d.optional()}),response:t.object({sessionDir:o,env:u,authMaterialized:t.boolean()})},"sessionConfig.destroy":{request:t.object({clientId:r,leaseId:c}),response:t.object({success:t.boolean()})},"sessionConfig.cleanup":{request:t.object({clientId:r.optional()}),response:t.object({removed:t.array(o)})}},m=t.object({sessionDir:o,baseConfigDir:o,projectDir:o.optional(),platform:t.enum([`darwin`,`linux`,`win32`]),configInheritance:d}),h=t.object({sessionDir:o,platform:t.enum([`darwin`,`linux`,`win32`])}),g=t.object({success:t.boolean()}),_=t.object({env:t.record(t.string(),t.string()).optional(),authMaterialized:t.boolean()}),v=t.enum([`managed-install`,`profile-create`,`session-create`]),y={request:t.object({clientId:r,configDir:o,phase:v,binaryVersion:e.optional(),adapterName:t.string().min(1).optional(),projectDir:o.optional()}),response:t.object({primed:t.boolean()})};export{a as _,f as a,d as c,_ as d,h as f,r as g,i as h,l as i,c as l,o as m,y as n,p as o,g as p,s as r,u as s,v as t,m as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{r as e}from"./namespace-NXm_zvL1.mjs";import{CredentialSubjects as t}from"@makaio/framework/contracts";var n=class extends Error{code;adapterName;providerConfigId;constructor(e,t,n){super(`Provider context resolution failed (${e}) for adapter "${t}".`),this.code=e,this.adapterName=t,this.providerConfigId=n,this.name=`RuntimeProviderContextResolutionError`}};async function r(t,r){let i=await t.request(e.resolveAdapterRuntimeSnapshot,r);if(i.status===`error`)throw new n(i.code,r.adapterName,r.providerConfigId);let a=i.runtime;if(a.adapterName!==r.adapterName||a.snapshot.context.providerConfigId!==r.providerConfigId)throw new n(`snapshot-identity-mismatch`,r.adapterName,r.providerConfigId);let o=a.snapshot.context;if(o.state!==`resolved`)throw new n(`provider-context-unresolved`,r.adapterName,r.providerConfigId);return o}var i=class extends Error{code;constructor(e){super(`[activateProviderContext] ${e===`manager-unavailable`?`the selected account manager is unavailable`:e===`account-not-found`?`the selected account no longer exists`:`the selected account could not be activated`}.`),this.code=e,this.name=`ProviderContextActivationError`}},a=class extends Error{constructor(){super(`Provider context account activation rollback failed.`),this.name=`ProviderContextActivationRollbackError`}},o=class{bus;transactionId;finalization;constructor(e,t){this.bus=e,this.transactionId=t}commit(){return this.finalize(`commit`)}rollback(){return this.finalize(`rollback`)}finalize(e){if(this.finalization!==void 0)return this.finalization.action===e?this.finalization.promise:Promise.reject(new i(`activation-failed`));let t=this.requestFinalization(e);return this.finalization={action:e,promise:t},t}async requestFinalization(e){try{if(e===`commit`){let e=await this.bus.requestOptional(t.activation.commit,{transactionId:this.transactionId});if(!e.handled)throw new i(`activation-failed`);if(!e.data.success)throw e.data.code===`commit-rollback-failed`?new a:new i(`activation-failed`);return}let n=await this.bus.requestOptional(t.activation.rollback,{transactionId:this.transactionId});if(!n.handled)throw new i(`activation-failed`);if(!n.data.success)throw n.data.code===`rollback-failed`?new a:new i(`activation-failed`)}catch(e){throw e instanceof i||e instanceof a?e:new i(`activation-failed`)}}};function s(e){return e.state!==`resolved`||e.auth.mode!==`inferred`||e.auth.account===void 0?null:e}async function c(e,n){let r=s(n);if(r)try{let n=await e.requestOptional(t.activate,{providerContext:r});if(!n.handled)throw new i(`manager-unavailable`);if(!n.data.success)throw new i(n.data.code)}catch(e){throw e instanceof i?e:new i(`activation-failed`)}}async function l(e,n){let r=s(n);if(r)try{let n=await e.requestOptional(t.activation.prepare,{providerContext:r});if(!n.handled)throw new i(`manager-unavailable`);if(!n.data.success)throw new i(n.data.code);return new o(e,n.data.transactionId)}catch(e){throw e instanceof i?e:new i(`activation-failed`)}}export{n as a,l as i,a as n,r as o,c as r,i as t};
|