@makaio/framework 1.0.0-dev-1781117225170 → 1.0.0-dev-1781354548379
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 +29 -0
- package/dist/.makaio-build.json +2 -2
- package/dist/adapter-UpcpZDOv.mjs +1 -0
- package/dist/adapters/config/index.d.mts +1 -1
- package/dist/adapters/config/index.mjs +1 -1
- package/dist/adapters/index.d.mts +13 -5
- package/dist/adapters/index.mjs +2 -2
- package/dist/adapters/node.d.mts +1 -1
- package/dist/adapters/node.mjs +1 -1
- package/dist/bus/index.mjs +1 -1
- package/dist/client-BJVDImPV.d.mts +175 -0
- package/dist/clients/index.d.mts +101 -1
- package/dist/clients/index.mjs +2 -2
- package/dist/contracts/adapter/index.d.mts +2 -2
- package/dist/contracts/adapter/index.mjs +1 -1
- package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
- package/dist/contracts/artifact/index.d.mts +1 -1
- package/dist/contracts/client/index.d.mts +2 -2
- package/dist/contracts/common/index.d.mts +1 -1
- package/dist/contracts/config/index.d.mts +1 -1
- package/dist/contracts/extension/index.d.mts +4 -4
- package/dist/contracts/extension/index.mjs +1 -1
- package/dist/contracts/facet/index.d.mts +1 -1
- package/dist/contracts/harness/index.d.mts +1 -1
- package/dist/contracts/host/index.d.mts +1 -1
- package/dist/contracts/index.d.mts +786 -108
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/materialization/index.d.mts +3 -3
- package/dist/contracts/model-registry/index.d.mts +1 -1
- package/dist/contracts/native-session-supervisor/index.d.mts +1 -1
- package/dist/contracts/platform/index.d.mts +1 -1
- package/dist/contracts/provider/index.d.mts +2 -2
- package/dist/contracts/session/index.d.mts +3 -3
- package/dist/contracts/session/index.mjs +1 -1
- package/dist/contracts/shared/index.d.mts +1 -1
- package/dist/contracts/skill/index.d.mts +1 -1
- package/dist/contracts/telemetry/index.d.mts +1 -1
- package/dist/contracts/timeout/index.d.mts +1 -1
- package/dist/contracts/variant/index.d.mts +1 -1
- package/dist/{definition-Cp-5xJp_.d.mts → definition-DqJOg6Lv.d.mts} +1 -1
- package/dist/{detached-extension-handle-oXbjv1tA.mjs → detached-extension-handle-Diiwgm13.mjs} +1 -1
- package/dist/drizzle/0001_messages_content_tsv.na.md +18 -0
- package/dist/drizzle/0012_legal_kate_bishop.sql +3 -0
- package/dist/drizzle/0013_eager_rhodey.sql +56 -0
- package/dist/drizzle/0014_fancy_ultimo.sql +1 -0
- package/dist/drizzle/0015_m_mqbh8q5b.sql +1 -0
- package/dist/drizzle/0016_m_mqbmq8h7.sql +1 -0
- package/dist/drizzle/0017_m_mqbnf924.sql +1 -0
- package/dist/drizzle/meta/0012_snapshot.json +2934 -0
- package/dist/drizzle/meta/0013_snapshot.json +2954 -0
- package/dist/drizzle/meta/0014_snapshot.json +2959 -0
- package/dist/drizzle/meta/0015_snapshot.json +2966 -0
- package/dist/drizzle/meta/0016_snapshot.json +2973 -0
- package/dist/drizzle/meta/0017_snapshot.json +2980 -0
- package/dist/drizzle/meta/_journal.json +42 -0
- package/dist/drizzle-wjquQK2m.mjs +1 -0
- package/dist/extension-DfNcE0zm.mjs +1 -0
- package/dist/extension-ZBN4BGre.mjs +1 -0
- package/dist/{filesystem-service-CBJT7A5w.mjs → filesystem-service-BjfrUmGS.mjs} +1 -1
- package/dist/{globby-C0lgTOUl.mjs → globby-BIH65cbN.mjs} +1 -1
- package/dist/handler-DqpiV9eA.mjs +1 -0
- package/dist/handlers-BAB4fQNH.mjs +41 -0
- package/dist/{index-uQl_1wQO.d.mts → index-BAhJKQLX.d.mts} +8 -8
- package/dist/{index-i7o6FtS0.d.mts → index-BDRKAxIV.d.mts} +129 -2
- package/dist/{index-CXfWW8cP.d.mts → index-BHAOu6Hs.d.mts} +20 -20
- package/dist/{index-t9Vt4Jbb.d.mts → index-BHzgDuRE.d.mts} +20 -3
- package/dist/{index-SFkbbDxs.d.mts → index-BYkOUd0x.d.mts} +1 -1
- package/dist/{index-CmGvjpUG.d.mts → index-BheaEhyI.d.mts} +6 -6
- package/dist/{index-Dsu1tPHm.d.mts → index-Bibt5jAX.d.mts} +8 -8
- package/dist/{index-Bw8SkcWG.d.mts → index-Bw_zL7Rs.d.mts} +1 -1
- package/dist/{index-ClgVA8Rz.d.mts → index-C3zfJg6s.d.mts} +6 -6
- package/dist/{index-v2kRZnfw2.d.mts → index-CH5U3zSA2.d.mts} +20 -10
- package/dist/{index-hWzUQtDn.d.mts → index-CTn_Xi-p.d.mts} +92 -19
- package/dist/{index-BY-fz0Jy.d.mts → index-DPIdX6kb.d.mts} +358 -110
- package/dist/{index-kLBWooVu.d.mts → index-Da4ABgRq.d.mts} +12 -12
- package/dist/{index-C1uZLARQ.d.mts → index-DrGLAuZc.d.mts} +1409 -72
- package/dist/{index-CT-zFurA.d.mts → index-Drz_a7kW.d.mts} +1 -1
- package/dist/{index-BELri1Hy.d.mts → index-IekAD8Gp.d.mts} +8 -8
- package/dist/{index-C_jIVT40.d.mts → index-fVgKVvta.d.mts} +1 -1
- package/dist/{index-BFaeVdsn2.d.mts → index-zgm2j9V92.d.mts} +44 -2
- package/dist/kernel/cli/index.d.mts +2 -2
- package/dist/kernel/cli/register.d.mts +1 -1
- package/dist/kernel/extension/index.d.mts +1 -1
- package/dist/kernel/extension/index.mjs +1 -1
- package/dist/kernel/index.d.mts +5 -5
- package/dist/kernel/index.mjs +1 -1
- package/dist/kernel/namespace/index.d.mts +1 -1
- package/dist/kernel/observability/index.d.mts +1 -1
- package/dist/kernel/providers/index.d.mts +1 -1
- package/dist/kernel/window/index.d.mts +1 -1
- package/dist/{lib-zuQKc8ym.mjs → lib-Cq5R6Tx9.mjs} +1 -1
- package/dist/{lib-IkUYa2Qs.mjs → lib-nlcl5kRW.mjs} +1 -1
- package/dist/{load-extensions-DE8qDIqi.d.mts → load-extensions-D9nbDIiW.d.mts} +1 -1
- package/dist/{load-extensions-CwxilDj1.mjs → load-extensions-wELQ4BBN.mjs} +1 -1
- package/dist/mcp-http-server/index.d.mts +132 -19
- package/dist/mcp-http-server/index.mjs +2 -2
- package/dist/{namespace-Dik_dNeE.d.mts → namespace--s0d86h-.d.mts} +144 -0
- package/dist/{namespace-ffepZB8Y.d.mts → namespace-B73Sxj5L.d.mts} +6 -6
- package/dist/{namespace-CZPu_jvy.d.mts → namespace-Boe6l5n9.d.mts} +82 -46
- package/dist/{namespace-Da_dHfdm.d.mts → namespace-BxxBhcV_.d.mts} +2 -2
- package/dist/namespace-Dfq6MDN9.mjs +1 -0
- package/dist/{namespace-DvHoeMUV.d.mts → namespace-aJJfBJU5.d.mts} +173 -3
- package/dist/node/bus-server/index.d.mts +1 -1
- package/dist/node/bus-server/index.mjs +1 -1
- package/dist/node/bus-server/server-lifecycle.d.mts +1 -1
- package/dist/node/bus-server/server-lifecycle.mjs +1 -1
- package/dist/{orchestrator-shared-FnWrPS09.mjs → orchestrator-shared-BKFXaKPL.mjs} +1 -1
- package/dist/{package-B2HkKyRz.d.mts → package--RZnpN2J.d.mts} +2 -3
- package/dist/package-BzJvtM5O.mjs +1 -0
- package/dist/package-DzN_jdqd.mjs +1 -0
- package/dist/package.json +1 -1
- package/dist/primitive-runtime-CNC_bSac.mjs +1 -0
- package/dist/registry-RG-bkw3c.mjs +146 -0
- package/dist/rules/index.d.mts +1 -1
- package/dist/rules/index.mjs +1 -1
- package/dist/rules/schemas.d.mts +1 -1
- package/dist/runtime-bun/index.mjs +1 -1
- package/dist/runtime-node/bus/runtime/namespace.d.mts +8 -8
- package/dist/runtime-node/bus/runtime/schemas.d.mts +11 -4
- package/dist/runtime-node/bus/runtime/schemas.mjs +1 -1
- package/dist/runtime-node/extension-discovery.d.mts +1 -1
- package/dist/runtime-node/extension-validation.d.mts +1 -1
- package/dist/runtime-node/extension-validation.mjs +1 -1
- package/dist/runtime-node/index.d.mts +77 -38
- package/dist/runtime-node/index.mjs +26 -53
- 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-C3TgjrsV.mjs +1 -0
- package/dist/schema-CzhOc7TV.mjs +1 -0
- package/dist/{schema-CfuF2cXW.d.mts → schema-DGMLvVoQ.d.mts} +237 -11
- package/dist/schemas-CuKayWhA.mjs +1 -0
- package/dist/{schemas-SPI-Y87l2.d.mts → schemas-kVcJMjjn2.d.mts} +6 -6
- package/dist/{schemas-BiMxSTUx.d.mts → schemas-t1VR6_b_.d.mts} +3 -3
- package/dist/services/adapter-runtime/index.d.mts +3 -3
- package/dist/services/adapter-runtime/namespace.d.mts +1 -1
- package/dist/services/adapter-runtime/schemas.d.mts +1 -1
- package/dist/services/adapter-subsystem/index.d.mts +2 -2
- package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
- package/dist/services/agent-runtime/index.d.mts +2 -2
- package/dist/services/agent-runtime/namespace.d.mts +1 -1
- package/dist/services/agent-runtime/schemas.d.mts +1 -1
- package/dist/services/capability/index.d.mts +1 -1
- package/dist/services/codebase/index.d.mts +2 -2
- package/dist/services/codebase/namespace.d.mts +1 -1
- package/dist/services/codebase/schemas.d.mts +1 -1
- package/dist/services/compression/index.d.mts +2 -2
- package/dist/services/compression/namespace.d.mts +1 -1
- package/dist/services/compression/schemas.d.mts +1 -1
- package/dist/services/context-rules/index.d.mts +4 -4
- package/dist/services/execution-target/index.d.mts +3 -3
- package/dist/services/execution-target/namespace.d.mts +1 -1
- package/dist/services/execution-target/schemas.d.mts +1 -1
- package/dist/services/filesystem/index.d.mts +1 -1
- package/dist/services/filesystem/index.mjs +1 -1
- package/dist/services/filesystem/namespace.d.mts +6 -6
- package/dist/services/filesystem/schemas.d.mts +3 -3
- package/dist/services/harness/index.d.mts +31 -20
- package/dist/services/harness/index.mjs +1 -1
- package/dist/services/harness/storage/schema.d.mts +60 -16
- package/dist/services/harness/storage/schema.mjs +1 -1
- package/dist/services/index.d.mts +166 -69
- 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 +9 -15
- package/dist/services/log-import/index.mjs +2 -2
- package/dist/services/log-import/log-import.d.mts +1 -1
- package/dist/services/model-registry/index.d.mts +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/session/handlers/index.d.mts +1 -1
- 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 +18 -2
- package/dist/services/session/testing/index.mjs +54 -3
- 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/settings/index.d.mts +3 -3
- package/dist/services/settings/index.mjs +1 -1
- package/dist/services/settings/namespace.d.mts +6 -6
- 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/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/turn/schemas.d.mts +72 -0
- package/dist/services/turn/schemas.mjs +1 -1
- package/dist/{session-C1Cami7U.mjs → session-BwX5_k47.mjs} +1 -1
- package/dist/session-P4nX60Xx.mjs +39 -0
- package/dist/{src-DI5TcYUW.mjs → src-CBG3IHUl.mjs} +1 -1
- package/dist/storage/drizzle/client.d.mts +2 -78
- package/dist/storage/drizzle/client.mjs +1 -1
- package/dist/storage/drizzle/columns/postgres.d.mts +88 -0
- package/dist/storage/drizzle/columns/postgres.mjs +1 -0
- package/dist/storage/drizzle/columns/sqlite.d.mts +81 -0
- package/dist/storage/drizzle/columns/sqlite.mjs +1 -0
- package/dist/storage/drizzle/index.d.mts +976 -23
- package/dist/storage/drizzle/index.mjs +1 -1
- package/dist/storage/handlers/drizzle/index.d.mts +1 -1
- package/dist/storage/handlers/drizzle/index.mjs +1 -1
- package/dist/storage/handlers/index.d.mts +1 -1
- package/dist/storage/handlers/index.mjs +1 -1
- package/dist/testing/drizzle-harness.d.mts +52 -6
- package/dist/testing/drizzle-harness.mjs +1 -1
- package/dist/testing/index.d.mts +34 -2
- package/dist/testing/index.mjs +1 -1
- package/dist/{tool-approval-service-BgNcJvKx.mjs → tool-approval-service-DNHV5x0M.mjs} +1 -1
- package/dist/tools-CQImrHAp.mjs +1 -0
- package/dist/{types-CZHV05Lu.d.mts → types-BpuLMR2m.d.mts} +616 -433
- package/dist/{types-C5Uy3WEy.d.mts → types-D0fPFh-D.d.mts} +1 -1
- package/dist/{types-0u6hpELc.d.mts → types-D6jnDjP2.d.mts} +18 -5
- package/dist/ui-components/index.d.mts +36 -37
- package/dist/ui-kernel/index.d.mts +1 -1
- package/dist/ui-kernel/pages/schemas.d.mts +1 -1
- package/dist/ui-views/index.d.mts +2 -2
- package/dist/workflow-engine/index.d.mts +539 -110
- package/dist/workflow-engine/index.mjs +1 -1
- package/dist/workflow-engine/package.d.mts +1 -1
- package/dist/workflow-engine/package.mjs +1 -1
- package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
- package/dist/{workflow-worker-hDaQzTBl.mjs → workflow-worker-CK9Sqj7D.mjs} +1 -1
- package/package.json +49 -1
- package/dist/adapter-Dt2FDMs4.mjs +0 -1
- package/dist/drizzle-DpjZFY_j.mjs +0 -1
- package/dist/extension--5Q190u_.mjs +0 -1
- package/dist/extension-DFIZ3FCJ.mjs +0 -1
- package/dist/handlers-Bev7-xjL.mjs +0 -41
- package/dist/namespace-CDiM5Bcr.mjs +0 -1
- package/dist/namespace-h0HIuqx0.mjs +0 -1
- package/dist/package-C9wOiMK9.mjs +0 -1
- package/dist/package-OE9dMQsq.mjs +0 -1
- package/dist/primitive-runtime-1Z3JbRUj.mjs +0 -1
- package/dist/schema-DCJyzRHe.mjs +0 -1
- package/dist/schema-DOnJmAPw.mjs +0 -1
- package/dist/schemas-CSUwpaNm.mjs +0 -1
- package/dist/session-BnfsJoZi.mjs +0 -134
- package/dist/tools-B8d8Iqqx.mjs +0 -1
- package/dist/types-yTKQTAok.d.mts +0 -31
- /package/dist/{ajv-0JG5NFEd.mjs → ajv-BA2z5ztb.mjs} +0 -0
- /package/dist/{await-trigger-CHuOd5co.mjs → await-trigger-DREnXCEJ.mjs} +0 -0
- /package/dist/{base-orchestrator-D-S9v5VY.d.mts → base-orchestrator-M5mAB5-w.d.mts} +0 -0
- /package/dist/{cleanEnvForAdapter-BlpmyXYk.mjs → cleanEnvForAdapter-vZfPGi0X.mjs} +0 -0
- /package/dist/{clients-namespace-E97p_GKF.d.mts → clients-namespace-SFk7OTop.d.mts} +0 -0
- /package/dist/{config-namespace-R_34Wfps.d.mts → config-namespace-BzAvE2nY.d.mts} +0 -0
- /package/dist/{create-static-mount-B9Szo_7y.mjs → create-static-mount-BB1MIQ9J.mjs} +0 -0
- /package/dist/{cross-spawn-CTptpCy4.mjs → cross-spawn-BL6EvJBv.mjs} +0 -0
- /package/dist/{cursor-storage-YikwAZR5.mjs → cursor-storage-CmKjSvKY.mjs} +0 -0
- /package/dist/{definition-CYzWS2eR.d.mts → definition-BSghHJpQ.d.mts} +0 -0
- /package/dist/{definition-CvOuzWNT.d.mts → definition-q6iLw11H.d.mts} +0 -0
- /package/dist/{descriptor-to-package-9nrAH_D5.mjs → descriptor-to-package-CY8oc2gl.mjs} +0 -0
- /package/dist/{esm-CglYG5aA.mjs → esm-CQVFKEW5.mjs} +0 -0
- /package/dist/{extension-discovery-BD1-oNU_.d.mts → extension-discovery-CkV_VRdJ.d.mts} +0 -0
- /package/dist/{filesystem-service-BcwRp4k1.d.mts → filesystem-service-Ddngll0j.d.mts} +0 -0
- /package/dist/{index-DJQew2k-.d.mts → index-9IDJUJ4X.d.mts} +0 -0
- /package/dist/{index-CNYPKkyH.d.mts → index-BBvcP-P0.d.mts} +0 -0
- /package/dist/{index-DfUBcVtG.d.mts → index-BCKRUuI2.d.mts} +0 -0
- /package/dist/{index-Dn9Uum3F.d.mts → index-BMpRB6iE.d.mts} +0 -0
- /package/dist/{index-CdNDnxXR.d.mts → index-BbCjtc3h.d.mts} +0 -0
- /package/dist/{index-B6RGNugn.d.mts → index-BnQSPC6c.d.mts} +0 -0
- /package/dist/{index-DUPZKsd3.d.mts → index-BpXX9WZJ.d.mts} +0 -0
- /package/dist/{index-DUhXk_q6.d.mts → index-BpniJgxu.d.mts} +0 -0
- /package/dist/{index-ChG8ZUNP.d.mts → index-Bsp0O_sI.d.mts} +0 -0
- /package/dist/{index-CF7dnqQj.d.mts → index-Buo9H8RK.d.mts} +0 -0
- /package/dist/{index-9KnLzPYu.d.mts → index-BxFA1XcP.d.mts} +0 -0
- /package/dist/{index-AZ4iLe7O2.d.mts → index-C33Tq1ei2.d.mts} +0 -0
- /package/dist/{index--0CnhN0g.d.mts → index-C6BhKRnH.d.mts} +0 -0
- /package/dist/{index-BV8rSmDZ.d.mts → index-CDU_s69P.d.mts} +0 -0
- /package/dist/{index-BDlpFEsp2.d.mts → index-CGJjA-hR2.d.mts} +0 -0
- /package/dist/{index-DNGUXQGC.d.mts → index-Cz9JMjZK.d.mts} +0 -0
- /package/dist/{index-C-YBGCCG.d.mts → index-D0SUjZmU.d.mts} +0 -0
- /package/dist/{index-yNb7G73-.d.mts → index-D6Iyvz9T.d.mts} +0 -0
- /package/dist/{index-ziQTLYUO.d.mts → index-DOfq0qqv.d.mts} +0 -0
- /package/dist/{index-BYxgW2i0.d.mts → index-DSV1aFgK.d.mts} +0 -0
- /package/dist/{index-Dbwm5Y-Q.d.mts → index-Dsq2zKvu.d.mts} +0 -0
- /package/dist/{jsonl-transport-DBHQgcIm.mjs → jsonl-transport-C21tpVfe.mjs} +0 -0
- /package/dist/{lib-CaOdTS9F.mjs → lib-CNOQJtgs.mjs} +0 -0
- /package/dist/{namespace-DnZ4rS6T2.d.mts → namespace-B60mn8J-2.d.mts} +0 -0
- /package/dist/{namespace-DfYutvMT.d.mts → namespace-BBVtD1gu.d.mts} +0 -0
- /package/dist/{namespace-BaJJxBsI.d.mts → namespace-CHMszppN.d.mts} +0 -0
- /package/dist/{namespace-uGw5nK6d.d.mts → namespace-CqUGzG53.d.mts} +0 -0
- /package/dist/{namespace-13uMtVGj.d.mts → namespace-DRFJN-_z.d.mts} +0 -0
- /package/dist/{namespace-TfZGCy7N.d.mts → namespace-DzVf1hVH.d.mts} +0 -0
- /package/dist/{namespace-QTFnJWHC.d.mts → namespace-XTGCaSXj.d.mts} +0 -0
- /package/dist/{namespace-CTrNKkxY.d.mts → namespace-nlsvvMtD.d.mts} +0 -0
- /package/dist/{namespace-DkDvQJhB.d.mts → namespace-uuR0Fg5r.d.mts} +0 -0
- /package/dist/{orchestrator-shared-BZVeoRfr.d.mts → orchestrator-shared-D91Wk7z-.d.mts} +0 -0
- /package/dist/{out-CiFds_ap.mjs → out-C1JFb2Bp.mjs} +0 -0
- /package/dist/{provider-context-lfG0BpqX.mjs → provider-context-wp4VSJFI.mjs} +0 -0
- /package/dist/{providers-namespace-Cc9FQ-Zt.d.mts → providers-namespace-BqWYkydw.d.mts} +0 -0
- /package/dist/{schemas-BD-1NGmS.d.mts → schemas-B5ToLwIs.d.mts} +0 -0
- /package/dist/{schemas-Hy-lsBpg.d.mts → schemas-B77Gi8Xr.d.mts} +0 -0
- /package/dist/{schemas-BzK1I1eX.d.mts → schemas-C792eVAZ.d.mts} +0 -0
- /package/dist/{schemas-CYS6bkht.d.mts → schemas-Chyj6HuZ.d.mts} +0 -0
- /package/dist/{schemas-DL_bGYyZ.d.mts → schemas-DZUaRcYl.d.mts} +0 -0
- /package/dist/{schemas-DdZwjeF0.d.mts → schemas-Dv5FxHDT.d.mts} +0 -0
- /package/dist/{schemas-CsjB6gel.d.mts → schemas-Dyk7JuVl.d.mts} +0 -0
- /package/dist/{schemas-DFWGb4uj.d.mts → schemas-Kq33MTPY.d.mts} +0 -0
- /package/dist/{schemas-BFeP62V4.d.mts → schemas-lqvZ6UpK.d.mts} +0 -0
- /package/dist/{server-lifecycle-DVAbXQzg.d.mts → server-lifecycle-47mygK3E.d.mts} +0 -0
- /package/dist/{server-lifecycle-JTFuSJhg.mjs → server-lifecycle-Cg47L59Q.mjs} +0 -0
- /package/dist/{session-lineage-CxHc3_bm.d.mts → session-lineage-CKg6mErA.d.mts} +0 -0
- /package/dist/{shared-schemas-CKe2uN4-.mjs → shared-schemas-DYL7a-No.mjs} +0 -0
- /package/dist/{src-4_2jBceX.mjs → src-DedDL9iv.mjs} +0 -0
- /package/dist/{storage-namespace-I30TaZP7.d.mts → storage-namespace-BXmMUd7a.d.mts} +0 -0
- /package/dist/{storage-namespace-definition-ZNBL3v2h.d.mts → storage-namespace-definition-C3XbpiP8.d.mts} +0 -0
- /package/dist/{types-11QnNmpW.d.mts → types-5Gw3iVpK.d.mts} +0 -0
- /package/dist/{types-BKNpS4Xw.d.mts → types-B0BtvVAq.d.mts} +0 -0
- /package/dist/{types-BtMNh2FS.d.mts → types-D-bP8RRE.d.mts} +0 -0
- /package/dist/{window-registry-QD1rTk_f.d.mts → window-registry-CfEi_Ji4.d.mts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{t}from"./ajv-BA2z5ztb.mjs";import{z as n}from"zod";import{execFile as r}from"node:child_process";import{isAbsolute as i,relative as a,resolve as o}from"node:path";import{realpathSync as s}from"node:fs";import{localSubject as c}from"@makaio/framework/core";import{NoHandlerError as l}from"@makaio/framework/bus";import{ArtifactSubjects as u,ExecutionLinkListQuerySchema as d,ExecutionLinkSchema as f,ExecutionListQuerySchema as p,ExecutionStatusSchema as m,GateInstanceListQuerySchema as h,SpanRecordSchema as ee,SubagentSubjects as g,WorkflowDefinitionSchema as _,WorkflowExecutionSchema as v,WorkflowFrameStateSchema as y,WorkflowGateInstanceSchema as b,WorkflowListQuerySchema as te,WorkflowRunContextSchema as x,WorkflowSchemas as ne,WorkflowSubjects as re,WorkflowSubjects as S,createStepCancelSubject as ie}from"@makaio/framework/contracts";import{createStorageNamespaceDefinition as ae}from"@makaio/framework/storage";import{index as C,primaryKey as oe,uniqueIndex as se}from"drizzle-orm/sqlite-core";import{index as w,primaryKey as ce,uniqueIndex as le}from"drizzle-orm/pg-core";import{defineDualTable as T}from"@makaio/framework/storage/drizzle";import{sql as ue}from"drizzle-orm";import{evaluateSync as E,resolveTemplate as D}from"@makaio/framework/expression";import*as de from"node:os";function fe(e){return{scopeType:e.textEnum(`scope_type`,{enum:[`global`,`workspace`,`session`,`external`]}).notNull().$type(),scopeKind:e.text(`scope_kind`).notNull().default(``),scopeId:e.text(`scope_id`).notNull().default(``)}}const pe=T(`workflow_definitions`,e=>({id:e.text(`id`).primaryKey(),name:e.text(`name`).notNull(),description:e.text(`description`),root:e.jsonCol(`root`).notNull(),inputSchema:e.jsonCol(`input_schema`),configSchema:e.jsonCol(`config_schema`),outputSchema:e.jsonCol(`output_schema`),artifact:e.jsonCol(`artifact`),triggers:e.jsonCol(`triggers`),...fe(e),createdAt:e.epochMs(`created_at`).notNull(),updatedAt:e.epochMs(`updated_at`).notNull(),canvasLayout:e.jsonCol(`canvas_layout`),source:e.jsonCol(`source`),executionHints:e.jsonCol(`execution_hints`)}),{sqlite:e=>[se(`uniq_workflow_definitions_name_scope`).on(e.name,e.scopeType,e.scopeKind,e.scopeId),C(`idx_workflow_definitions_scope`).on(e.scopeType,e.scopeKind,e.scopeId)],postgres:e=>[le(`uniq_workflow_definitions_name_scope`).on(e.name,e.scopeType,e.scopeKind,e.scopeId),w(`idx_workflow_definitions_scope`).on(e.scopeType,e.scopeKind,e.scopeId)]}),me=pe.sqlite,O=T(`workflow_executions`,e=>({id:e.text(`id`).primaryKey(),workflowId:e.text(`workflow_id`).notNull(),coordinatorSessionId:e.text(`coordinator_session_id`),status:e.textEnum(`status`,{enum:[`pending`,`running`,`paused`,`completed`,`failed`,`cancelled`]}).notNull(),inputs:e.jsonCol(`inputs`),error:e.text(`error`),reason:e.text(`reason`),startedAt:e.epochMs(`started_at`).notNull(),completedAt:e.epochMs(`completed_at`),triggerPayload:e.jsonCol(`trigger_payload`),artifactKind:e.text(`artifact_kind`),artifactId:e.text(`artifact_id`),...fe(e)}),{sqlite:e=>[C(`idx_workflow_executions_status`).on(e.status),C(`idx_workflow_executions_scope_started`).on(e.scopeType,e.scopeKind,e.scopeId,e.startedAt),C(`idx_workflow_executions_workflow_started`).on(e.workflowId,e.startedAt),C(`idx_workflow_executions_artifact`).on(e.artifactKind,e.artifactId,e.startedAt)],postgres:e=>[w(`idx_workflow_executions_status`).on(e.status),w(`idx_workflow_executions_scope_started`).on(e.scopeType,e.scopeKind,e.scopeId,e.startedAt),w(`idx_workflow_executions_workflow_started`).on(e.workflowId,e.startedAt),w(`idx_workflow_executions_artifact`).on(e.artifactKind,e.artifactId,e.startedAt)]}),he=O.sqlite,ge=T(`workflow_execution_frames`,e=>({frameId:e.text(`frame_id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>O.columnPair(`id`),{onDelete:`cascade`}),nodeId:e.text(`node_id`).notNull(),nodeType:e.text(`node_type`).notNull().$type(),path:e.jsonCol(`path`).notNull(),parentFrameId:e.text(`parent_frame_id`),status:e.text(`status`).notNull().default(`pending`).$type(),attempt:e.int4(`attempt`).notNull().default(0),iteration:e.int4(`iteration`),branchKey:e.text(`branch_key`),output:e.jsonCol(`output`),outputPresent:e.bool(`output_present`).notNull().default(!1),error:e.text(`error`),startedAt:e.epochMs(`started_at`),completedAt:e.epochMs(`completed_at`)}),{sqlite:e=>[C(`idx_workflow_execution_frames_execution`).on(e.executionId),C(`idx_workflow_execution_frames_parent`).on(e.parentFrameId)],postgres:e=>[w(`idx_workflow_execution_frames_execution`).on(e.executionId),w(`idx_workflow_execution_frames_parent`).on(e.parentFrameId)]}),_e=ge.sqlite,ve=T(`workflow_gate_instances`,e=>({id:e.text(`id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>O.columnPair(`id`),{onDelete:`cascade`}),nodeId:e.text(`node_id`).notNull(),frameId:e.text(`frame_id`).notNull(),schema:e.jsonCol(`schema`).notNull(),prompt:e.text(`prompt`),status:e.text(`status`).notNull().default(`waiting`).$type(),autoAction:e.textEnum(`auto_action`,{enum:[`approve`,`reject`]}).notNull().default(`reject`),timeoutMs:e.int4(`timeout_ms`),resumeData:e.jsonCol(`resume_data`),reason:e.text(`reason`),resumeDataPresent:e.bool(`resume_data_present`).notNull().default(!1),createdAt:e.epochMs(`created_at`).notNull(),resolvedAt:e.epochMs(`resolved_at`)}),{sqlite:e=>[C(`idx_workflow_gate_instances_execution`).on(e.executionId),C(`idx_workflow_gate_instances_frame`).on(e.frameId)],postgres:e=>[w(`idx_workflow_gate_instances_execution`).on(e.executionId),w(`idx_workflow_gate_instances_frame`).on(e.frameId)]}),ye=ve.sqlite,be=T(`workflow_step_spans`,e=>({executionId:e.text(`execution_id`).notNull().references(()=>O.columnPair(`id`),{onDelete:`cascade`}),frameId:e.text(`frame_id`).notNull(),stepId:e.text(`step_id`).notNull(),stepType:e.text(`step_type`).notNull(),status:e.text(`status`).$type().notNull(),startedAt:e.epochMs(`started_at`),completedAt:e.epochMs(`completed_at`),durationMs:e.int4(`duration_ms`),inputTokens:e.int4(`input_tokens`),outputTokens:e.int4(`output_tokens`),estimatedCost:e.float8(`estimated_cost`),toolCallCount:e.int4(`tool_call_count`),input:e.text(`input`),output:e.text(`output`)}),{sqlite:e=>[oe({columns:[e.executionId,e.frameId]}),C(`idx_workflow_step_spans_status`).on(e.status)],postgres:e=>[ce({columns:[e.executionId,e.frameId]}),w(`idx_workflow_step_spans_status`).on(e.status)]}),xe=be.sqlite,k=T(`workflow_execution_links`,e=>({sourceExecutionId:e.text(`source_execution_id`).notNull().references(()=>O.columnPair(`id`),{onDelete:`cascade`}),targetExecutionId:e.text(`target_execution_id`).notNull().references(()=>O.columnPair(`id`),{onDelete:`cascade`}),linkType:e.text(`link_type`).$type().notNull(),metadata:e.jsonCol(`metadata`)}),{sqlite:e=>[oe({columns:[e.sourceExecutionId,e.targetExecutionId]}),C(`idx_workflow_execution_links_target`).on(e.targetExecutionId)],postgres:e=>[ce({columns:[e.sourceExecutionId,e.targetExecutionId]}),w(`idx_workflow_execution_links_target`).on(e.targetExecutionId)]}),A=k.sqlite,j=T(`workflow_run_contexts`,e=>({executionId:e.text(`execution_id`).primaryKey().references(()=>O.columnPair(`id`),{onDelete:`cascade`}),workflowId:e.text(`workflow_id`).notNull(),coordinatorSessionId:e.text(`coordinator_session_id`).notNull(),sourceKind:e.text(`source_kind`).notNull(),sourcePath:e.text(`source_path`),sourceFilename:e.text(`source_filename`),sourceCode:e.text(`source_code`),definitionSnapshot:e.jsonCol(`definition_snapshot`),workerManifest:e.jsonCol(`worker_manifest`).notNull(),inputs:e.jsonCol(`inputs`),config:e.jsonCol(`config`).notNull().default(ue`'{}'`),triggerPayload:e.jsonCol(`trigger_payload`).notNull(),artifactRef:e.jsonCol(`artifact_ref`),executionHints:e.jsonCol(`execution_hints`),dispatchMetadata:e.jsonCol(`dispatch_metadata`),scopeType:e.textEnum(`scope_type`,{enum:[`global`,`workspace`,`session`,`external`]}).notNull().default(`global`).$type(),scopeKind:e.text(`scope_kind`).notNull().default(``),scopeId:e.text(`scope_id`).notNull().default(``),cancelSubject:e.text(`cancel_subject`).notNull(),context:e.jsonCol(`context`).notNull(),env:e.jsonCol(`env`).notNull(),createdAt:e.epochMs(`created_at`).notNull(),suspensionStrategy:e.text(`suspension_strategy`).$type()}),{sqlite:e=>[C(`idx_run_contexts_workflow`).on(e.workflowId)],postgres:e=>[w(`idx_run_contexts_workflow`).on(e.workflowId)]}),Se=j.sqlite,M=T(`worklog_summaries`,e=>({executionId:e.text(`execution_id`).primaryKey().references(()=>O.columnPair(`id`),{onDelete:`cascade`}),workflowId:e.text(`workflow_id`).notNull(),workflowName:e.text(`workflow_name`),status:e.textEnum(`status`,{enum:[`pending`,`running`,`paused`,`completed`,`failed`,`cancelled`]}).notNull(),startedAt:e.epochMs(`started_at`).notNull(),completedAt:e.epochMs(`completed_at`),durationMs:e.int4(`duration_ms`),totalInputTokens:e.int4(`total_input_tokens`),totalOutputTokens:e.int4(`total_output_tokens`),totalEstimatedCost:e.float8(`total_estimated_cost`),error:e.text(`error`),failedNodeId:e.text(`failed_node_id`)}),{sqlite:e=>[C(`idx_worklog_summaries_workflow_started`).on(e.workflowId,e.startedAt),C(`idx_worklog_summaries_status`).on(e.status)],postgres:e=>[w(`idx_worklog_summaries_workflow_started`).on(e.workflowId,e.startedAt),w(`idx_worklog_summaries_status`).on(e.status)]}),Ce=M.sqlite,we=T(`worklog_frame_entries`,e=>({frameId:e.text(`frame_id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>O.columnPair(`id`),{onDelete:`cascade`}),nodeId:e.text(`node_id`).notNull(),nodeType:e.text(`node_type`).notNull().$type(),path:e.jsonCol(`path`).notNull(),status:e.textEnum(`status`,{enum:[`pending`,`running`,`waiting`,`completed`,`failed`,`skipped`,`cancelled`]}).notNull(),attempt:e.int4(`attempt`).notNull().default(0),iteration:e.int4(`iteration`),branchKey:e.text(`branch_key`),startedAt:e.epochMs(`started_at`),completedAt:e.epochMs(`completed_at`),durationMs:e.int4(`duration_ms`),inputTokens:e.int4(`input_tokens`),outputTokens:e.int4(`output_tokens`),estimatedCost:e.float8(`estimated_cost`),error:e.text(`error`)}),{sqlite:e=>[C(`idx_worklog_frame_entries_execution`).on(e.executionId)],postgres:e=>[w(`idx_worklog_frame_entries_execution`).on(e.executionId)]}),Te=we.sqlite,Ee=T(`worklog_artifact_writes`,e=>({id:e.text(`id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>O.columnPair(`id`),{onDelete:`cascade`}),frameId:e.text(`frame_id`).notNull(),nodeId:e.text(`node_id`).notNull(),artifact:e.jsonCol(`artifact`).notNull(),revision:e.text(`revision`),writtenAt:e.epochMs(`written_at`).notNull()}),{sqlite:e=>[C(`idx_worklog_artifact_writes_execution`).on(e.executionId)],postgres:e=>[w(`idx_worklog_artifact_writes_execution`).on(e.executionId)]}),De=Ee.sqlite,Oe=T(`worklog_gate_events`,e=>({id:e.text(`id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>O.columnPair(`id`),{onDelete:`cascade`}),nodeId:e.text(`node_id`).notNull(),frameId:e.text(`frame_id`).notNull(),status:e.textEnum(`status`,{enum:[`waiting`,`resumed`,`rejected`,`timed-out`,`cancelled`]}).notNull().$type(),prompt:e.text(`prompt`),openedAt:e.epochMs(`opened_at`).notNull(),resolvedAt:e.epochMs(`resolved_at`),resumeData:e.jsonCol(`resume_data`)}),{sqlite:e=>[C(`idx_worklog_gate_events_execution`).on(e.executionId),C(`idx_worklog_gate_events_status`).on(e.status)],postgres:e=>[w(`idx_worklog_gate_events_execution`).on(e.executionId),w(`idx_worklog_gate_events_status`).on(e.status)]}),ke=Oe.sqlite,Ae=n.object({executionId:n.string().min(1),status:m.optional(),error:n.string().nullable().optional(),reason:n.string().nullable().optional(),completedAt:n.number().nullable().optional()}),je=ae(`workflow`,{schemas:{get:{request:n.object({id:n.string()}),response:n.object({workflow:_.nullable()})},set:{request:n.object({workflow:_}),response:n.object({id:n.string()})},delete:{request:n.object({id:n.string()}),response:n.object({deleted:n.boolean()})},list:{request:te,response:n.object({workflows:n.array(_)})},getExecution:{request:n.object({executionId:n.string()}),response:n.object({execution:v.nullable()})},setExecution:{request:n.object({execution:v}),response:n.object({id:n.string()})},setExecutionStart:{request:n.object({execution:v,runContext:x}),response:n.object({id:n.string(),executionId:n.string()})},updateExecution:{request:Ae,response:n.object({success:n.boolean()})},cancelPausedExecution:{request:n.object({executionId:n.string().min(1),completedAt:n.number(),reason:n.string().optional()}),response:n.object({cancelled:n.boolean(),gates:n.array(b.extend({status:n.literal(`cancelled`)}))})},listExecutions:{request:p,response:n.object({executions:n.array(v)})},setFrame:{request:n.object({executionId:n.string().min(1),frame:y}),response:n.object({frameId:n.string()})},getFrame:{request:n.object({frameId:n.string().min(1)}),response:n.object({frame:y.nullable()})},listFrames:{request:n.object({executionId:n.string().min(1)}),response:n.object({frames:n.array(y)})},setGateInstance:{request:n.object({gate:b}),response:n.object({id:n.string()})},resolveWaitingGateInstance:{request:n.object({gate:b.extend({status:n.enum([`resumed`,`rejected`])})}),response:n.object({accepted:n.boolean()})},restorePausedGateResumeState:{request:n.object({execution:v.extend({status:n.literal(`paused`)}),gate:b.extend({status:n.literal(`waiting`)})}),response:n.object({executionId:n.string(),gateId:n.string()})},getGateInstance:{request:n.object({executionId:n.string().min(1),nodeId:n.string().min(1),frameId:n.string().min(1).optional()}),response:n.object({gate:b.nullable()})},listGateInstances:{request:h,response:n.object({gates:n.array(b)})},listPausedGateTimeouts:c({request:n.object({}),response:n.object({gates:n.array(b)})}),setSpan:{request:n.object({span:ee}),response:n.object({id:n.string()})},listSpans:{request:n.object({executionId:n.string()}),response:n.object({spans:n.array(ee)})},setExecutionLink:{request:n.object({link:f}),response:n.object({id:n.string()})},listExecutionLinks:{request:d,response:n.object({links:n.array(f)})},setRunContext:c({request:n.object({runContext:x}),response:n.object({executionId:n.string()})}),getRunContext:c({request:n.object({executionId:n.string().min(1)}),response:n.object({runContext:x.nullable()})})},extensions:{drizzle:{workflowDefinitions:me,workflowExecutions:he,workflowExecutionFrames:_e,workflowGateInstances:ye,workflowStepSpans:xe,workflowExecutionLinks:A,workflowRunContexts:Se,worklogSummaries:Ce,worklogFrameEntries:Te,worklogArtifactWrites:De,worklogGateEvents:ke}}}),N=je.subjects,Me={stepTimeoutMs:300*1e3,stepCooldownMs:500,busAuth:{kind:`none`},platformDefaults:{cwd:process.cwd()},cancelTimeoutMs:1e4};async function P(e,t,n){if(!(await e.request(N.updateExecution,{executionId:t.id,status:n.status,error:n.error,reason:n.reason,completedAt:n.completedAt})).success)throw Error(`Workflow execution not found: ${t.id}`)}async function Ne(e,t,n,r){t.status=`completed`,t.completedAt=Date.now();try{await P(e.bus,t,{status:t.status,completedAt:t.completedAt}),await e.bus.emit(S.execution.completed,{executionId:n,workflowId:t.workflowId,totalDuration:t.completedAt-r,completedAt:t.completedAt})}finally{e.activeExecutions.delete(n)}}async function Pe(e,t,n,r,i){t.status=`failed`,t.error=r,t.completedAt=Date.now();try{await P(e.bus,t,{status:t.status,error:t.error,completedAt:t.completedAt});try{await i?.()}catch(e){console.error(`[WorkflowFinalizer] Failed to run failure pre-emit hook:`,e)}await e.bus.emit(S.execution.failed,{executionId:n,workflowId:t.workflowId,error:r,completedAt:t.completedAt})}finally{e.activeExecutions.delete(n)}}function Fe(e,t,n){let{activeRunnerSteps:r,bus:i}=e,a=`${t}:`;for(let[e,o]of r){if(!e.startsWith(a))continue;let r=e.slice(a.length);o.controller.abort(),i.emit(ie(o.cancelSubject),{executionId:t,stepId:r,reason:n}).catch(t=>{console.error(`[WorkflowFinalizer] Failed to emit cancellation for ${e}:`,t)})}}async function Ie(e,t,n){let r=await e.bus.request(N.getExecution,{executionId:t});if(r.execution==null)return!1;let i=r.execution.workflowId;if(i===void 0)throw Error(`Paused execution ${t} is missing stored workflowId`);let a=Date.now(),{cancelled:o,gates:s}=await e.bus.request(N.cancelPausedExecution,{executionId:t,completedAt:a,reason:n});if(!o)return!1;for(let n of s)await e.bus.emit(S.gate.resolved,{executionId:t,stepId:n.nodeId,stepType:`gate`,frameId:n.frameId,source:`cancelled`}).catch(e=>{console.error(`[WorkflowFinalizer] Failed to emit cancelled gate resolution for ${n.frameId}:`,e)});return await e.bus.emit(S.execution.cancelled,{executionId:t,workflowId:i,reason:n,completedAt:a}),e.activeExecutions.delete(t),!0}async function Le(e,t,n){let r=e.activeExecutions.get(t);if(!r||r.execution.status!==`running`)return Ie(e,t,n);let{execution:i}=r;i.status=`cancelled`,i.reason=n,i.completedAt=Date.now();try{for(let[n,r]of e.shellAbortControllers)n.startsWith(`${t}:`)&&(r.abort(),e.shellAbortControllers.delete(n));Fe(e,t,n),await P(e.bus,i,{status:i.status,reason:n,completedAt:i.completedAt}),await e.bus.emit(S.execution.cancelled,{executionId:t,workflowId:i.workflowId,reason:n,completedAt:i.completedAt})}finally{e.activeExecutions.delete(t)}return!0}function Re(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function ze(e,t,n){let r=e?D(e,n):t,c=o(t),l=o(i(r)?r:o(t,r)),u,d;try{u=s(c),d=s(l)}catch{return null}let f=a(process.platform===`win32`?u.toLowerCase():u,process.platform===`win32`?d.toLowerCase():d);return f===``||!f.startsWith(`..`)&&!i(f)?d:null}function Be(e){return e instanceof Error&&(`code`in e||`killed`in e)}function Ve(e){let t=e[0];return t===void 0||t.trim()===``?null:t}function He(e){let{command:t,cwd:n,env:i,timeoutMs:a,signal:o}=e,s=Ve(t);if(s===null)return Promise.reject(Error(`Shell step command is empty`));let c=t.slice(1);return new Promise((e,t)=>{let l=null,u=!1,d=r(s,c,{cwd:n,env:{...process.env,...i},timeout:0,maxBuffer:10*1024*1024,shell:!1},(n,r,i)=>{n?t(Object.assign(n,{stdout:r,stderr:i,aborted:u})):e({stdout:r,stderr:i})}),f=()=>{d.exitCode===null&&(d.kill(`SIGTERM`),l=setTimeout(()=>{d.exitCode===null&&d.kill(`SIGKILL`)},5e3))},p=setTimeout(()=>{f()},a);if(d.on(`close`,()=>{clearTimeout(p),l!==null&&clearTimeout(l)}),o){let e=()=>{u=!0,f()};o.aborted?e():(o.addEventListener(`abort`,e,{once:!0}),d.on(`close`,()=>o.removeEventListener(`abort`,e)))}})}async function Ue(e){let{step:t,workspaceRoot:n,expressionContext:r,signal:i}=e,a=ze(t.cwd,n,r);if(a===null)return{status:`failed`,error:`Shell step cwd '${t.cwd}' is outside workspace root '${n}'`};let o=t.command.map(e=>D(e,r));if(Ve(o)===null)return{status:`failed`,error:`Shell step command is empty`};let s=Object.fromEntries(Object.entries(t.env??{}).map(([e,t])=>[e,D(t,r)])),c=t.timeoutMs??3e5;try{let{stdout:e}=await He({command:o,cwd:a,env:s,timeoutMs:c,signal:i});return{status:`completed`,stdout:e}}catch(e){if(!Be(e))return{status:`failed`,error:String(e)};let t=e.aborted===!0,n=!t&&(e.killed===!0||e.signal!=null);return{status:`failed`,error:t?`Command cancelled`:n?`Command timed out after ${c}ms`:e.stderr?.trim()||e.stdout?.trim()||e.message}}}function We(e){let t={};for(let[n,r]of Object.entries(e))r.status===`completed`?t[n]={status:`completed`,output:r.output}:r.status===`skipped`&&(t[n]={status:`skipped`});return t}function F(e){let t={...e,input:e.inputs,steps:e.frames};return{...t,ctx:t}}function Ge(){return{context:{repoPath:process.cwd(),makaioHome:process.env.MAKAIO_HOME??`${de.homedir()}/.makaio`,os:process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`,arch:process.arch},env:{}}}function Ke(e){return{...e,path:[...e.path]}}function qe(e){if(e===`station`||e===`delegate-agent`||e===`delegate-role`||e===`gate`)return e}function Je(e,t){let n=qe(t.nodeType);if(n===void 0||t.status!==`running`&&t.status!==`completed`&&t.status!==`failed`&&t.status!==`skipped`)return;let r=t.startedAt!==void 0&&t.completedAt!==void 0?Math.max(0,t.completedAt-t.startedAt):void 0;return{executionId:e,frameId:t.frameId,stepId:t.nodeId,stepType:n,status:t.status,...t.startedAt===void 0?{}:{startedAt:t.startedAt},...t.completedAt===void 0?{}:{completedAt:t.completedAt},...r===void 0?{}:{durationMs:r},...t.output===void 0?{}:{output:JSON.stringify(t.output)}}}var Ye=class e{executionId;workflowId;definition;execution;runtimeHandlers;bus;signal;frameRegistry;framePersistenceTasks=new Map;artifactBinding;constructor(e,t,n,r,i,a,o,s,c,l=Ge(),u={}){this.executionId=e,this.workflowId=t,this.definition=n,this.execution=r,this.runtimeHandlers=i,this.bus=a,this.signal=o,this.frameRegistry=s??new Map,this.artifactBinding=c,this.platformContext=l.context,this.env=l.env,this.suspensionStrategy=u.suspensionStrategy??`wait-in-process`,this.resumeFrames=u.resumeFrames}platformContext;env;suspensionStrategy;resumeFrames;withSignal(t){return new e(this.executionId,this.workflowId,this.definition,this.execution,this.runtimeHandlers,this.bus,t,this.frameRegistry,this.artifactBinding,{context:this.platformContext,env:this.env},{suspensionStrategy:this.suspensionStrategy,resumeFrames:this.resumeFrames})}buildExpressionContext(){return{inputs:this.execution.inputs,config:this.execution.config??{},trigger:this.execution.triggerPayload??{},frames:{},previousSteps:{}}}createFrame(e){let t=Re(`frm`),n=[...e.path,t],r={frameId:t,nodeId:e.nodeId,nodeType:e.nodeType,path:n,parentFrameId:e.parentFrameId,status:`pending`,attempt:0,iteration:e.iteration,branchKey:e.branchKey};return this.frameRegistry.set(t,r),this.persistFrame(r).catch(()=>void 0),r}async persistFrame(e,t={}){let n=t.requireFrameStorage===!0||this.suspensionStrategy!==`wait-in-process`,r=Ke(e),i=Je(this.executionId,r),a=(this.framePersistenceTasks.get(e.frameId)??Promise.resolve()).catch(()=>void 0).then(async()=>{n?await this.bus.request(N.setFrame,{executionId:this.executionId,frame:r}):await this.bus.requestOptional(N.setFrame,{executionId:this.executionId,frame:r}),i!==void 0&&await this.bus.requestOptional(N.setSpan,{span:i})}).catch(t=>{if(n)throw t;console.warn(`[RuntimeContext] Failed to persist frame ${e.frameId}:`,t)});this.framePersistenceTasks.set(e.frameId,a);try{await a}finally{this.framePersistenceTasks.get(e.frameId)===a&&this.framePersistenceTasks.delete(e.frameId)}}async updateFrame(e,t,n={}){let r=this.frameRegistry.get(e);if(!r)throw Error(`Frame not found: ${e}`);Object.assign(r,t),await this.persistFrame(r,n)}getFrame(e){return this.frameRegistry.get(e)}getFramesByNodeId(e){let t=[];for(let n of this.frameRegistry.values())n.nodeId===e&&t.push(n);return t.sort((e,t)=>(e.startedAt??0)-(t.startedAt??0))}async emitFrameStarted(e){try{await this.bus.emit(S.frame.started,{executionId:this.executionId,frameId:e.frameId,nodeId:e.nodeId,nodeType:e.nodeType,path:e.path,parentFrameId:e.parentFrameId,startedAt:e.startedAt})}catch(t){console.error(`[RuntimeContext] frame.started observer failed for ${e.frameId}:`,t)}}async emitFrameCompleted(e,t){try{await this.bus.emit(S.frame.completed,{executionId:this.executionId,frameId:e.frameId,nodeId:e.nodeId,output:e.output,duration:t,completedAt:e.completedAt})}catch(t){console.error(`[RuntimeContext] frame.completed observer failed for ${e.frameId}:`,t)}}async emitFrameFailed(e,t,n){try{await this.bus.emit(S.frame.failed,{executionId:this.executionId,frameId:e.frameId,nodeId:e.nodeId,error:t,duration:n,completedAt:e.completedAt})}catch(t){console.error(`[RuntimeContext] frame.failed observer failed for ${e.frameId}:`,t)}}};function Xe(e){return{kind:`workflow-execution`,id:e,displayName:`Workflow Engine`}}function Ze(e,t,n){return{inputs:n.inputs,config:n.config??{},trigger:n.triggerPayload,scope:n.scope,context:n.context,env:n.env,execution:{id:t.id,workflowId:t.workflowId,scope:t.scope},workflow:{id:e.id,name:e.name,scope:e.scope}}}function Qe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $e(e){if(e!=null){if(Qe(e)&&typeof e.kind==`string`&&typeof e.id==`string`)return{kind:e.kind,id:e.id};throw Error(`Artifact resolve expression must return an object with string kind and id fields.`)}}function et(e){if(e!==void 0){if(Qe(e))return e;throw Error(`Artifact create expression must return an object.`)}}async function tt(e){let{bindingOptions:t,binding:n,existingArtifactRef:r,executionId:i,scope:a,initialData:o,bus:s}=e,c=null;if(r!==void 0){let e=await s.request(u.query,{kind:r.kind,ids:[r.id],currentOnly:!0});if(e.artifacts.length>0)c=e.artifacts[0];else return}else c=(await s.request(u.create,{kind:n.kind,schemaVersion:n.schemaVersion,scope:a??n.scope,data:o??{},relations:[],actor:Xe(i)})).artifact;return{current:c,schemaVersion:n.schemaVersion,statusPath:t.statusPath,zodSchema:t.schema}}async function nt(e){let{definition:t,execution:n,runContext:r,zodSchema:i,bus:a}=e,o=t.artifact;if(o===void 0)return;let s=Ze(t,n,r),c=r.artifactRef??(o.resolve===void 0?void 0:$e(E(o.resolve,s))),l=c===void 0&&o.create!==void 0?et(E(o.create,s)):void 0,u=await tt({bindingOptions:{kind:o.kind,schemaVersion:o.schemaVersion,scope:o.scope,...o.resolve===void 0?{}:{resolve:o.resolve},...o.create===void 0?{}:{create:o.create},...o.statusPath===void 0?{}:{statusPath:o.statusPath},...i===void 0?{}:{schema:i}},binding:o,existingArtifactRef:c,executionId:n.id,scope:o.scope,initialData:l,bus:a});if(u===void 0)throw Error(`Workflow artifact binding could not be resolved for the configured artifact reference.`);return u}const rt=new WeakMap;function it(e,t){let n=(rt.get(e)??Promise.resolve()).catch(()=>void 0).then(t);return rt.set(e,n.then(()=>void 0,()=>void 0)),n}function at(e,t){switch(t.operation){case`set`:return t.data;case`merge`:return{...e,...t.data};case`append`:{let n={...e};for(let[r,i]of Object.entries(t.data)){let t=e[r];Array.isArray(t)&&Array.isArray(i)?n[r]=[...t,...i]:n[r]=i}return n}}}function ot(e,t,n){let[r,...i]=t;if(i.length===0)return{...e,[r]:n};let a=e[r]!==null&&typeof e[r]==`object`&&!Array.isArray(e[r])?e[r]:{};return{...e,[r]:ot(a,i,n)}}function st(e,t,n){return ot(e,t.startsWith(`/`)?t.slice(1).split(`/`):t.split(`.`),n)}function ct(e,t,n){if(n===`set`||n===`functional`)return[];let r=[];for(let n of Object.keys(t))e[n]!==t[n]&&r.push(`/${n}`);return r}async function lt(e,t){if(typeof t==`function`)return{nextData:await t(Object.freeze({...e})),operationLabel:`functional`,changedPaths:[]};let n=at(e,t),r=ct(e,n,t.operation);return{nextData:n,operationLabel:t.operation,changedPaths:r}}function ut(e){let{executionId:t,frameId:n,bindingState:r,bus:i}=e,a=Object.freeze({...r.current.data}),o=async e=>it(r,async()=>{let a=r.current,{nextData:o,operationLabel:s,changedPaths:c}=await lt(a.data,e);if(r.zodSchema!==void 0){let e=r.zodSchema.safeParse(o);if(!e.success)throw Error(`Artifact data validation failed: ${e.error.message}`)}let l=await i.request(u.revise,{previous:{refClass:`artifact`,kind:a.kind,id:a.id,revision:a.revision},revision:{kind:a.kind,schemaVersion:r.schemaVersion,scope:a.scope,data:o,relations:a.relations,actor:Xe(t)}});r.current=l.artifact;let d=l.artifact.revision;return i.emit(re.artifact.updated,{executionId:t,frameId:n,artifactRef:{kind:l.artifact.kind,id:l.artifact.id},paths:c,operation:s,revision:d}).catch(e=>{console.error(`[ArtifactContext] Failed to emit artifact.updated event:`,e)}),d});return{data:a,updateArtifact:o,updateStatus:async e=>{if(r.statusPath===void 0)throw Error(`updateStatus() called but no statusPath is configured on the artifact binding. Set statusPath in the .artifact() builder call to use updateStatus().`);let t=r.statusPath;return o(n=>st(n,t,e))}}}async function dt(e,t,n){if(t.signal.aborted)return{status:`cancelled`};let r=await t.bus.requestOptional(S.resolveRole,{roleId:e.roleId});if(!r.handled)return{status:`failed`,error:e.unresolvedRoleError};let i=D(e.prompt,F(n));return ft({...e,task:i,resolvedConfig:r.data},t)}async function ft(e,t){if(t.signal.aborted)return{status:`cancelled`};let n=await t.bus.requestOptional(g.spawn,{parentSessionId:t.execution.coordinatorSessionId??t.executionId,depth:1,config:gt(e.task,e.resolvedConfig,e.outputSchema)});if(!n.handled)return{status:`failed`,error:e.unavailableRuntimeError};let r=await I(e,t,n.data.subagentId,{attempts:5}),i=await _t(e,t,n.data.subagentId);return i===`aborted`?{status:`cancelled`}:(r||await I(e,t,n.data.subagentId,{attempts:1}),i.handled?t.signal.aborted||i.data.status===`cancelled`?{status:`cancelled`}:i.data.status===`completed`?{status:`completed`,output:i.data.result??null}:{status:`failed`,error:`${e.nodeLabel} '${e.nodeId}' subagent ${i.data.status}: ${i.data.error??`no result`}`}:{status:`failed`,error:e.unavailableAwaitError})}async function I(e,t,n,r){if(e.frameId===void 0)return!0;try{let i=await pt(t,n,r.attempts);return i===void 0?!1:(await t.bus.emit(S.frame.sessionLinked,{executionId:t.executionId,frameId:e.frameId,sessionId:i}),!0)}catch(t){return console.warn(`[workflow-engine] Failed to emit frame.sessionLinked for frame '${e.frameId}' and subagent '${n}'`,t),!1}}async function pt(e,t,n){for(let r=0;r<n;r+=1){if(e.signal?.aborted)return;let i=await mt(e,t);if(i===void 0||!i.handled)return;if(i.data.childSessionId!==void 0)return i.data.childSessionId;if(r<n-1&&!await ht(e.signal,20))return}}async function mt(e,t){try{return await e.bus.requestOptional(g.getStatus,{subagentId:t},{timeout:25,signal:e.signal})}catch{return}}function ht(e,t){return e.aborted?Promise.resolve(!1):new Promise(n=>{let r,i=t=>{r!==void 0&&(clearTimeout(r),r=void 0),e.removeEventListener(`abort`,a),n(t)},a=()=>i(!1);r=setTimeout(()=>i(!0),t),e.addEventListener(`abort`,a,{once:!0}),e.aborted&&i(!1)})}function gt(e,t,n){return{task:e,adapterName:t.adapterName,...t.model===void 0?{}:{model:t.model},...t.reasoningEffort===void 0?{}:{reasoningEffort:t.reasoningEffort},...t.harnessId===void 0?{}:{harnessId:t.harnessId},...t.systemPrompt===void 0?{}:{systemPrompt:t.systemPrompt},...t.contextMode===void 0?{}:{contextMode:t.contextMode},...t.providerContext===void 0?{}:{providerContext:t.providerContext},...n===void 0?{}:{responseSchema:n}}}async function _t(e,t,n){if(t.signal.aborted)return await L(e,t,n),`aborted`;let r=t.bus.requestOptional(g.await,{subagentId:n,...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs}},{timeout:0});if(t.signal.aborted)return await L(e,t,n),`aborted`;let i,a=new Promise(e=>{i=()=>e(`aborted`),t.signal.addEventListener(`abort`,i,{once:!0})}),o=await Promise.race([r,a]);return i!==void 0&&t.signal.removeEventListener(`abort`,i),o===`aborted`&&await L(e,t,n),o}async function L(e,t,n){try{await t.bus.requestOptional(g.kill,{subagentId:n,reason:`Workflow execution '${t.executionId}' cancelled ${e.cancellationLabel} '${e.nodeId}'`})}catch(t){console.warn(`[workflow-engine] Best-effort subagent kill failed for '${n}' (${e.cancellationLabel} '${e.nodeId}')`,t)}}async function vt(e,t,n,r){if(t.signal.aborted)return{status:`cancelled`};let i=We(n.frames),a=t.runtimeHandlers.get(e.id);if(a===void 0)return yt(e,t,n,r);let o=t.artifactBinding!==void 0&&r!==void 0?ut({executionId:t.executionId,frameId:r,bindingState:t.artifactBinding,bus:t.bus}):void 0;async function s(n){if(r===void 0){console.warn(`[station-node] updateProgress called without frameId for node '${e.id}'; skipping emit`);return}let i=ne[`execution.progress`].parse({executionId:t.executionId,workflowId:t.workflowId,frameId:r,nodeId:e.id,progress:n,emittedAt:Date.now()});try{await t.bus.emit(S.execution.progress,i)}catch(t){console.error(`[station-node] execution.progress observer failed for ${e.id}:`,t)}}let c;try{c=await a({...t.platformContext,env:t.env,executionId:t.executionId,workflowId:t.workflowId,inputs:t.execution.inputs,config:t.execution.config??{},trigger:t.execution.triggerPayload??{},previousSteps:i,...n.item!==void 0&&{item:n.item},...n.index!==void 0&&{index:n.index},...n.previous!==void 0&&{previous:n.previous},signal:t.signal,...o!==void 0&&{artifact:o},bus:t.bus,updateProgress:s})}catch(e){return{status:`failed`,error:e instanceof Error?e.message:String(e)}}return{status:`completed`,output:c}}async function yt(e,t,n,r){if(e.role===void 0)return{status:`failed`,error:`No handler registered for station node '${e.id}'`};let i=e.outputSchema===void 0?void 0:{schema:e.outputSchema};return dt({nodeId:e.id,nodeLabel:`Station node`,roleId:e.role,prompt:e.prompt,...i===void 0?{}:{outputSchema:i},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},unresolvedRoleError:`No runtime handler registered for station node '${e.id}', and role '${e.role}' could not be resolved`,unavailableRuntimeError:`Subagent runtime is not available for station node '${e.id}'`,unavailableAwaitError:`Subagent runtime cannot await station node '${e.id}'`,cancellationLabel:`station`,...r===void 0?{}:{frameId:r}},t,n)}async function bt(e,t,n,r){if(t.signal.aborted)return{status:`cancelled`};let i=await t.bus.requestOptional(S.resolveAgent,{agentId:e.agentId});if(!i.handled)return{status:`failed`,error:`Agent '${e.agentId}' could not be resolved for delegate-agent node '${e.id}'`};if(t.signal.aborted)return{status:`cancelled`};let a=St(e,n);if(a.status===`failed`)return a;let o=e.outputSchema===void 0?void 0:{schema:e.outputSchema};return ft({nodeId:e.id,nodeLabel:`Delegate-agent node`,task:a.task,resolvedConfig:i.data,...o===void 0?{}:{outputSchema:o},unavailableRuntimeError:`Subagent runtime is not available for delegate-agent node '${e.id}'`,unavailableAwaitError:`Subagent runtime cannot await delegate-agent node '${e.id}'`,cancellationLabel:`delegate-agent`,...r===void 0?{}:{frameId:r}},t)}async function xt(e,t,n,r){if(t.signal.aborted)return{status:`cancelled`};let i=e.outputSchema===void 0?void 0:{schema:e.outputSchema};return dt({nodeId:e.id,nodeLabel:`Delegate-role node`,roleId:e.role,prompt:e.prompt,...i===void 0?{}:{outputSchema:i},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},unresolvedRoleError:`Role '${e.role}' could not be resolved for delegate-role node '${e.id}'`,unavailableRuntimeError:`Subagent runtime is not available for delegate-role node '${e.id}'`,unavailableAwaitError:`Subagent runtime cannot await delegate-role node '${e.id}'`,cancellationLabel:`delegate-role`,...r===void 0?{}:{frameId:r}},t,n)}function St(e,t){try{let n=F(t);return{status:`completed`,task:Ct(e.inputExpression===void 0?n:E(e.inputExpression,n))}}catch(t){let n=t instanceof Error?t.message:String(t);return{status:`failed`,error:`delegate-agent node '${e.id}': input expression evaluation failed: ${n}`}}}function Ct(e){if(typeof e==`string`)return e;if(e===void 0)return``;try{return JSON.stringify(e,null,2)??``}catch{return String(e)}}function wt(e,t,n,r){try{let i=E(n,F(r));return Array.isArray(i)?i:{status:`failed`,error:`${t} node '${e}': collection expression did not resolve to an array (got ${typeof i})`}}catch(n){return{status:`failed`,error:`${t} node '${e}': collection expression evaluation failed: ${n instanceof Error?n.message:String(n)}`}}}function Tt(e,t,n){for(let r of[...e.nodes].reverse()){let e=n.getFramesByNodeId(r.id);for(let n of e)if(n.parentFrameId===t&&n.status===`completed`)return n.output}}function Et(e,t,n){return Tt(e.body,t,n)}function Dt(e){if(e.length===0)return;let t=new Map,n=new Map;for(let r of e){n.set(r.frameId,r);let e=t.get(r.nodeId)??[];e.push(r),t.set(r.nodeId,e)}return{byNodeId:t,byFrameId:n}}const Ot=new Set([`completed`,`skipped`,`waiting`]);function R(e,t,n){let r=e?.byNodeId.get(t)??[],i=n.statuses??Ot;return r.find(e=>e.parentFrameId===n.parentFrameId&&e.branchKey===n.branchKey&&e.iteration===n.iteration&&i.has(e.status))}function z(e,t,n){let r={...e.frames,[t]:n};return{...e,frames:r,previousSteps:We(r),output:n.status===`completed`?n.output:e.output}}function B(e,t){if(typeof AbortSignal.any==`function`)return AbortSignal.any([e,t]);let n=new AbortController,r=()=>n.abort();return e.addEventListener(`abort`,r,{once:!0}),t.addEventListener(`abort`,r,{once:!0}),n.signal}const kt=new Set([`completed`,`running`]);function At(e,t){return e.status===`running`&&t.pauseSignal?.aborted===!0&&!t.outerSignal.aborted}async function jt(e,t,n,r,i,a,o=`all-settled`){if(t.signal.aborted)return{status:`cancelled`};let s=Object.entries(e.branches);if(s.length===0)return{status:`completed`,output:V({},o)};let c=new AbortController,l=new AbortController,u=t.suspensionStrategy!==`wait-in-process`,d=o===`fail-fast`?B(c.signal,l.signal):u?l.signal:void 0,f=d===void 0?t.signal:B(t.signal,d),p=f===t.signal?t:t.withSignal(f),m=s.map(([s,c])=>Mt(s,c,e,p,n,r,i,a,{outerSignal:t.signal,pauseSignal:o===`fail-fast`||u?l.signal:void 0}));if(o===`all-settled`){let e=await Promise.all(u?m.map(e=>e.then(e=>(e.status===`paused`&&l.abort(),e))):m),t=e.find(e=>e.status===`paused`);return t===void 0?{status:`completed`,output:V(Pt(s,e),o)}:t}let h=await Nt(s,m,c,l);return h.type===`cancelled`?{status:`cancelled`}:h.type===`paused`?h.outcome:h.type===`failed`?{status:`failed`,error:h.error}:{status:`completed`,output:V(Pt(s,h.outcomes),o)}}async function Mt(e,t,n,r,i,a,o,s,c){if(r.signal.aborted)return{status:`cancelled`};let l=R(r.resumeFrames,n.id,{parentFrameId:o,branchKey:e,statuses:kt});if(l?.status===`completed`)return{status:`completed`,...l.output===void 0?{}:{output:l.output}};let u=l??r.createFrame({nodeId:n.id,nodeType:`parallel`,path:s,parentFrameId:o,branchKey:e});if(r.signal.aborted)return At(u,c)||await $(u,r),{status:`cancelled`};l===void 0&&await Y(u,r);let d;try{d=await a(t,r,i,u.frameId,u.path)}catch(e){let t=e instanceof Error?e.message:String(e);return await Z(u,r,t),{status:`failed`,error:t}}switch(d.status){case`completed`:{let e=Tt(t,u.frameId,r);return await X(u,r,e),{status:`completed`,output:e}}case`skipped`:return await X(u,r),{status:`completed`};case`cancelled`:return At(u,c)||await $(u,r),{status:`cancelled`};case`paused`:return d;case`failed`:return await Z(u,r,d.error),{status:`failed`,error:d.error}}}async function Nt(e,t,n,r){let i,a,o=t.map(e=>e.then(e=>(e.status===`failed`&&i===void 0?(i=e.error,n.abort()):e.status===`paused`&&a===void 0&&(a=e,r.abort()),e),e=>{let t=e instanceof Error?e.message:String(e);return i===void 0&&(i=t,n.abort()),{status:`failed`,error:t}})),s=await Promise.all(o);return a===void 0?s.some(e=>e.status===`cancelled`)&&i===void 0?{type:`cancelled`}:i===void 0?{type:`completed`,outcomes:s}:{type:`failed`,error:i}:{type:`paused`,outcome:a}}function V(e,t){return{mode:t,branches:e}}function Pt(e,t){let n={};for(let r=0;r<e.length;r++){let[i]=e[r],a=t[r];n[i]=Ft(a)}return n}function Ft(e){switch(e.status){case`completed`:return{status:`fulfilled`,...e.output===void 0?{}:{value:e.output}};case`skipped`:return{status:`fulfilled`,value:null};case`cancelled`:return{status:`cancelled`};case`paused`:return{status:`paused`,pausedAtGateId:e.pausedAtGateId,pausedAtFrameId:e.pausedAtFrameId};case`failed`:return{status:`rejected`,reason:e.error}}}const It=new(e(t(),1)).default({allErrors:!0,strict:!1});function H(e,t){if(t===void 0)return{status:`ok`};try{return{status:`ok`,validator:It.compile(t)}}catch(t){return{status:`failed`,error:`Gate '${e}' has an invalid resumeSchema: ${t instanceof Error?t.message:String(t)}`}}}function U(e,t){return e===void 0||e(t)?{valid:!0}:{valid:!1,error:Rt(e.errors??[])}}function Lt(e,t,n){let r=H(e,t);return r.status===`failed`?{valid:!1,error:r.error}:U(r.validator,n)}function Rt(e){return e.length===0?`schema validation failed`:e.map(e=>`${e.instancePath.length>0?e.instancePath:`/`} ${e.message??`is invalid`}`).join(`; `)}const W={action:`approve`,source:`timeout`};function G(e){return e===void 0?{}:{reason:e}}async function zt(e,t,n,r){let i=()=>{t.value&&(t.value=!1,e.reject(`cancelled`))};n.addEventListener(`abort`,i,{once:!0}),n.aborted&&i();let a=[e.promise],o;if(r!==null){let e=Ut();o=setTimeout(()=>{t.value&&(t.value=!1,n.removeEventListener(`abort`,i),e.reject(`timed-out`))},r),a.push(e.promise)}try{let e=await Promise.race(a);return n.removeEventListener(`abort`,i),o!==void 0&&clearTimeout(o),{action:e.action,resumeData:e.resumeData,timedOut:!1,wasCancelled:!1,reason:e.reason}}catch(e){return o!==void 0&&clearTimeout(o),n.removeEventListener(`abort`,i),e===`timed-out`?{action:`reject`,resumeData:null,timedOut:!0,wasCancelled:!1}:{action:`reject`,resumeData:null,timedOut:!1,wasCancelled:!0}}}async function Bt(e,t,n,r,i,a){let o={required:e.suspensionStrategy!==`wait-in-process`};if(a.timedOut){let a=Date.now();if(r.autoAction===`approve`){let s=U(i,W);return s.valid?(await K(e,{...r,status:`resumed`,resumeData:W,resolvedAt:a},o),await q(e,t.id,n,{action:`approve`,source:`timeout`}),{status:`completed`,output:{resumeData:W}}):(await K(e,{...r,status:`timed-out`,resolvedAt:a},o),await q(e,t.id,n,{action:`reject`,source:`timeout`}),{status:`failed`,error:`Gate '${t.id}' auto-approve timeout resume data does not match resumeSchema: ${s.error}`})}return await K(e,{...r,status:`timed-out`,resolvedAt:a},o),await q(e,t.id,n,{action:`reject`,source:`timeout`}),{status:`failed`,error:`Gate '${t.id}' timed out after ${String(r.timeoutMs)}ms and auto-rejected`}}if(a.wasCancelled||e.signal.aborted)return await K(e,{...r,status:`cancelled`,resolvedAt:Date.now()},o),await q(e,t.id,n,{source:`cancelled`}),{status:`cancelled`};let s=Date.now();await K(e,{...r,status:a.action===`reject`?`rejected`:`resumed`,resumeData:a.resumeData,...G(a.reason),resolvedAt:s},o);try{await e.bus.emit(S.gate.resumed,{executionId:e.executionId,frameId:n,nodeId:t.id,resumeData:a.resumeData}),await q(e,t.id,n,{action:a.action,source:`user`,...G(a.reason)})}catch(e){console.error(`[GateNode] gate.resumed emit failed for '${t.id}':`,e)}return{status:`completed`,output:{resumeData:a.resumeData}}}async function Vt(e,t,n,r){if(t.signal.aborted)return{status:`cancelled`};let i=e.resumeSchema??{};if(t.suspensionStrategy!==`wait-in-process`){let n=await Kt(t,e,r);if(n!==void 0)return n}let a=H(e.id,e.resumeSchema);return a.status===`failed`?{status:`failed`,error:a.error}:Ht(t,e,n,r,i,a.validator)}async function Ht(e,t,n,r,i,a){let o=D(t.prompt,F(n)),s={executionId:e.executionId,nodeId:t.id,frameId:r,schema:i,prompt:o,status:`waiting`,autoAction:t.autoAction,timeoutMs:t.timeoutMs,createdAt:Date.now()},c=e.suspensionStrategy!==`wait-in-process`;if(await K(e,s,{required:c}),await e.updateFrame(r,{status:`waiting`},{requireFrameStorage:c}),c)return await Wt(e,t,r,i,o,s.createdAt),{status:`paused`,pausedAtGateId:t.id,pausedAtFrameId:r};let u={value:!0},d=Ut(),f=e.bus.on(S.gate.respond,async n=>{let{executionId:i,gateId:o,frameId:s,action:c,resumeData:f,reason:p}=n.payload;if(i!==e.executionId||o!==t.id||s!==void 0&&s!==r){try{await n.next()}catch(e){if(e instanceof l)n.setResult({accepted:!1});else throw e}return}if(!u.value){n.setResult({accepted:!1});return}if(!U(a,f).valid){n.setResult({accepted:!1});return}u.value=!1,n.setResult({accepted:!0}),d.resolve({action:c,resumeData:f,reason:p})});await Wt(e,t,r,i,o,s.createdAt);let p=await zt(d,u,e.signal,t.timeoutMs);return f(),Bt(e,t,r,s,a,p)}function Ut(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}async function Wt(e,t,n,r,i,a){try{await e.bus.emit(S.gate.suspended,{executionId:e.executionId,frameId:n,nodeId:t.id,schema:r,prompt:i,...t.title!==void 0&&{title:t.title},autoAction:t.autoAction,timeoutMs:t.timeoutMs,openedAt:a})}catch(e){console.error(`[GateNode] gate.suspended emit failed for '${t.id}':`,e)}}async function Gt(e,t,n){if(e.suspensionStrategy!==`wait-in-process`)return(await e.bus.request(N.getGateInstance,{executionId:e.executionId,nodeId:t,frameId:n})).gate;let r=await e.bus.requestOptional(N.getGateInstance,{executionId:e.executionId,nodeId:t,frameId:n});return r.handled?r.data.gate:null}async function Kt(e,t,n){let r=await Gt(e,t.id,n);if((r?.status===`resumed`||r?.status===`rejected`)&&r.resumeData!==void 0){let i=Lt(t.id,r.schema,r.resumeData);if(!i.valid)return{status:`failed`,error:`Gate '${t.id}' persisted resumeData is invalid: ${i.error}`};try{await e.bus.emit(S.gate.resumed,{executionId:e.executionId,frameId:n,nodeId:t.id,resumeData:r.resumeData})}catch(e){console.error(`[GateNode] gate.resumed emit failed for '${t.id}':`,e)}return await q(e,t.id,n,{action:r.status===`rejected`?`reject`:`approve`,source:`user`,...G(r.reason)}),{status:`completed`,output:{resumeData:r.resumeData}}}if(r?.status===`waiting`){if(r.timeoutMs!==null&&Date.now()>=r.createdAt+r.timeoutMs){let i=H(t.id,r.schema);return i.status===`failed`?{status:`failed`,error:i.error}:Bt(e,t,n,r,i.validator,{action:`reject`,resumeData:null,timedOut:!0,wasCancelled:!1})}return{status:`paused`,pausedAtGateId:t.id,pausedAtFrameId:n}}if((r?.status===`resumed`||r?.status===`rejected`)&&r.resumeData===void 0)return{status:`failed`,error:`Gate '${t.id}' has status '${r.status}' but resumeData is missing — cannot reconstruct output`};if(r!==null)return{status:`failed`,error:`Gate '${t.id}' cannot resume from status '${r.status}'`}}async function K(e,t,n={}){try{n.required===!0?await e.bus.request(N.setGateInstance,{gate:t}):await e.bus.requestOptional(N.setGateInstance,{gate:t})}catch(e){if(n.required===!0)throw e;console.warn(`[GateNode] Failed to upsert gate instance for '${t.nodeId}':`,e)}}async function q(e,t,n,r){try{await e.bus.emit(S.gate.resolved,{executionId:e.executionId,stepId:t,stepType:`gate`,frameId:n,...r})}catch(e){console.error(`[GateNode] gate.resolved emit failed for '${t}':`,e)}}function J(e){return{status:`fulfilled`,...e===void 0?{}:{value:e}}}const qt=new Set([`completed`,`running`]);function Jt(e,t){return e.status===`running`&&t.pauseSignal?.aborted===!0&&!t.outerSignal.aborted}async function Yt(e,t,n,r,i,a){if(t.signal.aborted)return{status:`cancelled`};let o=wt(e.id,`iterate`,e.collection,n);if(!Array.isArray(o))return o;let s=o;if(s.length===0)return{status:`completed`,output:$t([])};let c=await Xt(s,e,t,n,r,i,a,e.concurrency!==void 0&&e.concurrency>0?e.concurrency:0);if(t.signal.aborted&&c.every(e=>e.status===`cancelled`))return{status:`cancelled`};let l=c.find(e=>e.status===`paused`);return l===void 0?{status:`completed`,output:$t(c)}:{status:`paused`,pausedAtGateId:l.pausedAtGateId,pausedAtFrameId:l.pausedAtFrameId}}async function Xt(e,t,n,r,i,a,o,s){let c=new AbortController,l=n.suspensionStrategy!==`wait-in-process`,u=l?B(n.signal,c.signal):n.signal,d=u===n.signal?n:n.withSignal(u),f={outerSignal:n.signal,...l?{pauseSignal:c.signal}:{}};if(s===0){let n=e.map((e,n)=>Qt(e,n,t,d,r,i,a,o,f));return Promise.all(l?n.map(e=>Zt(e,c)):n)}let p=Array(e.length);for(let n=0;n<e.length;n+=s){if(d.signal.aborted){for(let t=n;t<e.length;t++)p[t]={status:`cancelled`};break}let u=Math.min(n+s,e.length),m=[];for(let s=n;s<u;s++)m.push(Qt(e[s],s,t,d,r,i,a,o,f));let h=await Promise.all(l?m.map(e=>Zt(e,c)):m);for(let e=0;e<h.length;e++)p[n+e]=h[e];if(h.some(e=>e.status===`paused`)){for(let t=u;t<e.length;t++)p[t]={status:`cancelled`};break}}return p}function Zt(e,t){return e.then(e=>(e.status===`paused`&&t.abort(),e))}async function Qt(e,t,n,r,i,a,o,s,c){if(r.signal.aborted)return{status:`cancelled`};let l={...i,item:e,index:t},u=R(r.resumeFrames,n.id,{parentFrameId:o,iteration:t,statuses:qt});if(u?.status===`completed`)return J(u.output);let d=u??r.createFrame({nodeId:n.id,nodeType:`iterate`,path:s,parentFrameId:o,iteration:t});if(r.signal.aborted)return Jt(d,c)||await $(d,r),{status:`cancelled`};u===void 0&&await Y(d,r);let f;try{f=await a(n.body,r,l,d.frameId,d.path)}catch(e){let t=e instanceof Error?e.message:String(e);return await Z(d,r,t),{status:`rejected`,reason:t}}switch(f.status){case`completed`:{let e=Et(n,d.frameId,r);return await X(d,r,e),J(e)}case`skipped`:return await X(d,r),J();case`cancelled`:return Jt(d,c)||await $(d,r),{status:`cancelled`};case`paused`:return f;case`failed`:return await Z(d,r,f.error),{status:`rejected`,reason:f.error}}}function $t(e){return{items:e}}const en=new Set([`completed`,`running`]);async function tn(e,t,n,r,i,a){if(t.signal.aborted)return{status:`cancelled`};let o=wt(e.id,`iterate-chain`,e.collection,n);if(!Array.isArray(o))return o;let s=o;if(s.length===0)return{status:`completed`,output:rn([])};let c=[],l;for(let o=0;o<s.length;o++){if(t.signal.aborted)return{status:`cancelled`};let u=s[o],d=await nn(u,o,l,e,t,n,r,i,a);switch(c.push(d),d.status){case`fulfilled`:l=d.value;break;case`rejected`:return{status:`failed`,error:d.reason};case`cancelled`:return{status:`cancelled`};case`paused`:return{status:`paused`,pausedAtGateId:d.pausedAtGateId,pausedAtFrameId:d.pausedAtFrameId}}}return{status:`completed`,output:rn(c)}}async function nn(e,t,n,r,i,a,o,s,c){if(i.signal.aborted)return{status:`cancelled`};let l={...a,item:e,index:t,...n!==void 0&&{previous:n}},u=R(i.resumeFrames,r.id,{parentFrameId:s,iteration:t,statuses:en});if(u?.status===`completed`)return J(u.output);let d=u??i.createFrame({nodeId:r.id,nodeType:`iterate-chain`,path:c,parentFrameId:s,iteration:t});if(i.signal.aborted)return await $(d,i),{status:`cancelled`};u===void 0&&await Y(d,i);let f;try{f=await o(r.body,i,l,d.frameId,d.path)}catch(e){let t=e instanceof Error?e.message:String(e);return await Z(d,i,t),{status:`rejected`,reason:t}}switch(f.status){case`completed`:{let e=Et(r,d.frameId,i);return await X(d,i,e),J(e)}case`skipped`:return await X(d,i),J();case`cancelled`:return await $(d,i),{status:`cancelled`};case`paused`:return f;case`failed`:return await Z(d,i,f.error),{status:`rejected`,reason:f.error}}}function rn(e){return{items:e}}async function Y(e,t){e.status=`running`,e.startedAt=Date.now(),await t.persistFrame(e),await t.emitFrameStarted(e)}async function X(e,t,n){let r=Date.now(),i=e.startedAt===void 0?void 0:Math.max(0,r-e.startedAt);e.status=`completed`,e.output=n,e.completedAt=r,await t.persistFrame(e),await t.emitFrameCompleted(e,i)}async function Z(e,t,n){let r=Date.now(),i=e.startedAt===void 0?void 0:Math.max(0,r-e.startedAt);e.status=`failed`,e.error=n,e.completedAt=r,await t.persistFrame(e),await t.emitFrameFailed(e,n,i)}async function Q(e,t){e.status=`skipped`,e.completedAt=Date.now(),await t.persistFrame(e)}async function $(e,t){e.status=`cancelled`,e.completedAt=Date.now(),await t.persistFrame(e)}function an(e,t){return!!E(e,F(t))}async function on(e,t,n,r,i,a=[]){if(t.signal.aborted)return{status:`cancelled`};switch(e.type){case`sequence`:return r(e,t,n,i,a);case`station`:return vt(e,t,n,i);case`delegate-agent`:return bt(e,t,n,i);case`delegate-role`:return xt(e,t,n,i);case`parallel`:return jt(e,t,n,r,i??``,a,e.mode??`all-settled`);case`gate`:return Vt(e,t,n,i??``);case`iterate`:return Yt(e,t,n,r,i??``,a);case`iterate-chain`:return tn(e,t,n,r,i??``,a);default:return{status:`failed`,error:`Unknown node type: ${String(e.type)}`}}}const sn=new Set([`completed`,`skipped`,`waiting`,`running`]);function cn(e){return e.type===`parallel`||e.type===`iterate`||e.type===`iterate-chain`}function ln(e,t,n){return R(e.resumeFrames,t.id,{parentFrameId:n,...cn(t)?{statuses:sn}:{}})}function un(e,t,n){if(n?.status===`completed`)return z(e,t.id,{status:`completed`,...n.output===void 0?{}:{output:n.output}});if(n?.status===`skipped`)return z(e,t.id,{status:`skipped`})}async function dn(e,t,n,r,i,a,o){try{return{result:an(e,i)}}catch(e){let i=e instanceof Error?e.message:String(e);return await Z(r.createFrame({nodeId:n.id,nodeType:n.type,path:a,parentFrameId:o}),r,`'${t}' condition evaluation failed: ${i}`),{status:`failed`,error:`'${t}' condition evaluation failed for '${n.id}': ${i}`}}}async function fn(e,t,n,r,i,a){let o=a??t.createFrame({nodeId:e.id,nodeType:e.type,path:r,parentFrameId:i});if(t.signal.aborted)return await $(o,t),{updatedCtx:n,outcome:{status:`cancelled`}};a===void 0&&await Y(o,t);let s;try{s=await on(e,t,n,pn,o.frameId,o.path)}catch(e){let r=e instanceof Error?e.message:String(e);return await Z(o,t,r),{updatedCtx:n,outcome:{status:`failed`,error:r}}}switch(s.status){case`completed`:return await X(o,t,s.output),{updatedCtx:z(n,e.id,{status:`completed`,output:s.output})};case`skipped`:return await Q(o,t),{updatedCtx:z(n,e.id,{status:`skipped`})};case`cancelled`:return await $(o,t),{updatedCtx:n,outcome:{status:`cancelled`}};case`paused`:return{updatedCtx:n,outcome:s};case`failed`:return await Z(o,t,s.error),{updatedCtx:n,outcome:{status:`failed`,error:s.error}}}}async function pn(e,t,n,r,i=[]){let a=n;for(let n of e.nodes){if(t.signal.aborted)return{status:`cancelled`};let e=ln(t,n,r),o=un(a,n,e);if(o!==void 0){a=o;continue}if(n.when!==void 0){let e=await dn(n.when,`when`,n,t,a,i,r);if(`status`in e)return e;if(!e.result){await Q(t.createFrame({nodeId:n.id,nodeType:n.type,path:i,parentFrameId:r}),t),a=z(a,n.id,{status:`skipped`});continue}}if(n.skip!==void 0){let e=await dn(n.skip,`skip`,n,t,a,i,r);if(`status`in e)return e;if(e.result){await Q(t.createFrame({nodeId:n.id,nodeType:n.type,path:i,parentFrameId:r}),t),a=z(a,n.id,{status:`skipped`});continue}}let s=e?.status===`waiting`&&n.type===`gate`||e?.status===`running`&&cn(n)?e:void 0,{updatedCtx:c,outcome:l}=await fn(n,t,a,i,r,s);if(a=c,l!==void 0)return l}return{status:`completed`}}export{Te as A,ve as C,be as D,xe as E,M as F,S as I,ke as M,Oe as N,De as O,Ce as P,ye as S,j as T,ge as _,Ye as a,he as b,Le as c,Me as d,je as f,_e as g,pe as h,nt as i,we as j,Ee as k,Pe as l,me as m,Lt as n,Re as o,N as p,Dt as r,Ue as s,pn as t,Ne as u,A as v,Se as w,O as x,k as y};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import{fileURLToPath as e}from"node:url";import{sql as t}from"drizzle-orm";import{isBunRuntime as n}from"@makaio/framework/utils";const r=Symbol.for(`makaio.storage.dialect`);function i(e){return e[r]??`sqlite`}function a(e){return e.rowsAffected??e.changes??e.rowCount??0}function o(e){return a(e)>0}const s=Symbol.for(`makaio.storage.rawSqlExecutor`);function c(e,t,n){if(n.dialect!==t)throw Error(`brandDatabase: executor dialect '${n.dialect}' does not match the brand dialect '${t}'`);return Object.defineProperty(e,r,{value:t,enumerable:!1,writable:!1,configurable:!1}),Object.defineProperty(e,s,{value:n,enumerable:!1,writable:!1,configurable:!1}),e}function l(e){return typeof e!=`object`||!e?0:a(e)}function u(e){let t={async run(t){return{rowsAffected:l(await e.run(t))}},async all(t){return await e.all(t)}};return{dialect:`sqlite`,run:t.run,all:t.all,async withSession(e){return e(t)}}}function d(e){let t=e;return typeof t.run==`function`&&typeof t.all==`function`}function f(e){let t=e[s];if(t!==void 0)return t;if(d(e))return u(e);throw Error(`getRawSqlExecutor: database handle carries no raw SQL executor and exposes no native SQLite run/all API. Create handles with createDatabaseClient() from @makaio/storage-drizzle/client, which attaches the executor.`)}function p(e){return import(e)}function m(e){return`"${e.replaceAll(`"`,`""`)}"`}const h=[{dialect:`postgres`,packageName:`@makaio/storage-pg`,matchesUrl:e=>/^postgres(ql)?:\/\//i.test(e)}];function g(e){return h.find(t=>t.matchesUrl(e))}function _(e){return h.find(t=>t.dialect===e)}function v(e,t){return`No storage engine is registered for dialect '${e}'. Install ${t} and pass its exported storageEngine via the boot 'database.engines' option or register it with registerStorageEngine(). Node runtime hosts auto-register it for recognized database URLs.`}function y(e,t){let n=e;for(;n instanceof Error;){if(t(n))return!0;n=n.cause}return!1}function b(e){let{code:t}=e;return typeof t==`string`?t:void 0}function x(e){return y(e,e=>/already exists/i.test(e.message))}function S(e){return y(e,e=>/UNIQUE constraint failed/i.test(e.message))}function C(e){return e.startsWith(`file:`)||e===`:memory:`}const w=[`PRAGMA journal_mode = WAL`,`PRAGMA busy_timeout = 5000`,`PRAGMA foreign_keys = ON`],T=[`PRAGMA foreign_keys = ON`];async function E(n){let{Database:r}=await p(`bun:sqlite`),{drizzle:i}=await p(`drizzle-orm/bun-sqlite`),a=new r(n===`:memory:`?`:memory:`:n.startsWith(`file://`)?e(n):n.replace(/^file:/,``)),o=i(a);for(let e of k(n))o.run(t.raw(e));c(o,`sqlite`,u(o));let s=!1;return{db:o,dialect:`sqlite`,close:()=>{s||(s=!0,a.close())}}}async function D(e,n){let{drizzle:r}=await import(`drizzle-orm/libsql`),i=r({connection:{url:e,authToken:n}});if(C(e))for(let n of k(e))await i.run(t.raw(n));c(i,`sqlite`,u(i));let a=!1;return{db:i,dialect:`sqlite`,close:()=>{a||(a=!0,i.$client.close())}}}function O(e){return e.startsWith(`file:`)}function k(e){return O(e)?w:T}async function A(e){let{url:t=`file:./makaio.db`,authToken:r}=e;return n()&&C(t)?E(t):D(t,r)}function j(e,n){let r=[...new Set(e)];return t`
|
|
2
|
+
SELECT m.session_id as "sessionId", m.content_text as preview
|
|
3
|
+
FROM messages m
|
|
4
|
+
WHERE m.role = 'user'
|
|
5
|
+
AND m.session_id IN (${t.join(r.map(e=>t`${e}`),t`, `)})
|
|
6
|
+
AND NOT EXISTS (
|
|
7
|
+
SELECT 1
|
|
8
|
+
FROM messages m2
|
|
9
|
+
WHERE m2.session_id = m.session_id
|
|
10
|
+
AND m2.role = 'user'
|
|
11
|
+
AND (m2.timestamp < m.timestamp OR (m2.timestamp = m.timestamp AND ${n}))
|
|
12
|
+
)
|
|
13
|
+
`}function M(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?`""`:t.map(e=>`"${e.replace(/"/g,`""`)}"`).join(` `)}function N(e){let n=[];return e.status!==void 0&&n.push(t`s.status = ${e.status}`),e.isImported!==void 0&&n.push(e.isImported?t`s.is_imported = 1`:t`COALESCE(s.is_imported, 0) = 0`),n.length===0?t``:t` AND ${t.join(n,t` AND `)}`}async function P(e,n,r,i){let a=t`
|
|
14
|
+
m.message_id AS message_id,
|
|
15
|
+
fts.session_id AS session_id,
|
|
16
|
+
-bm25(messages_fts) AS score,
|
|
17
|
+
snippet(messages_fts, 1, '<mark>', '</mark>', '...', 40) AS excerpt
|
|
18
|
+
FROM messages_fts fts
|
|
19
|
+
JOIN messages m ON m.rowid = fts.rowid`,o=f(e);return i===void 0?o.all(t`
|
|
20
|
+
SELECT ${a}
|
|
21
|
+
WHERE messages_fts MATCH ${n}
|
|
22
|
+
ORDER BY score DESC
|
|
23
|
+
LIMIT ${r}
|
|
24
|
+
`):o.all(t`
|
|
25
|
+
SELECT ${a}
|
|
26
|
+
WHERE messages_fts MATCH ${n}
|
|
27
|
+
AND fts.session_id = ${i}
|
|
28
|
+
ORDER BY score DESC
|
|
29
|
+
LIMIT ${r}
|
|
30
|
+
`)}async function F(e,n,r){let i=f(e);return(await(r===void 0?i.all(t`
|
|
31
|
+
SELECT COUNT(*) AS total
|
|
32
|
+
FROM messages_fts
|
|
33
|
+
WHERE messages_fts MATCH ${n}
|
|
34
|
+
`):i.all(t`
|
|
35
|
+
SELECT COUNT(*) AS total
|
|
36
|
+
FROM messages_fts
|
|
37
|
+
WHERE messages_fts MATCH ${n}
|
|
38
|
+
AND session_id = ${r}
|
|
39
|
+
`)))[0]?.total??0}const I={dialect:`sqlite`,async provisionSearchIndex(e){let n=f(e);await n.run(t`
|
|
40
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS messages_fts USING fts5(
|
|
41
|
+
session_id,
|
|
42
|
+
content_text,
|
|
43
|
+
content='messages',
|
|
44
|
+
content_rowid='rowid',
|
|
45
|
+
tokenize='porter unicode61'
|
|
46
|
+
)
|
|
47
|
+
`),await n.run(t`
|
|
48
|
+
CREATE TRIGGER IF NOT EXISTS messages_ai AFTER INSERT ON messages BEGIN
|
|
49
|
+
INSERT INTO messages_fts(rowid, session_id, content_text)
|
|
50
|
+
VALUES (NEW.rowid, NEW.session_id, NEW.content_text);
|
|
51
|
+
END
|
|
52
|
+
`),await n.run(t`
|
|
53
|
+
CREATE TRIGGER IF NOT EXISTS messages_ad AFTER DELETE ON messages BEGIN
|
|
54
|
+
INSERT INTO messages_fts(messages_fts, rowid, session_id, content_text)
|
|
55
|
+
VALUES('delete', OLD.rowid, OLD.session_id, OLD.content_text);
|
|
56
|
+
END
|
|
57
|
+
`),await n.run(t`
|
|
58
|
+
CREATE TRIGGER IF NOT EXISTS messages_au AFTER UPDATE ON messages BEGIN
|
|
59
|
+
INSERT INTO messages_fts(messages_fts, rowid, session_id, content_text)
|
|
60
|
+
VALUES('delete', OLD.rowid, OLD.session_id, OLD.content_text);
|
|
61
|
+
INSERT INTO messages_fts(rowid, session_id, content_text)
|
|
62
|
+
VALUES (NEW.rowid, NEW.session_id, NEW.content_text);
|
|
63
|
+
END
|
|
64
|
+
`),await n.run(t`INSERT INTO messages_fts(messages_fts) VALUES ('rebuild')`)},async searchMessages(e,n,r){let{sessionId:i,limit:a}=r,o=M(r.query),s=t`
|
|
65
|
+
m.message_id AS messageId,
|
|
66
|
+
m.turn_id AS turnId,
|
|
67
|
+
m.session_id AS sessionId,
|
|
68
|
+
m.role AS role,
|
|
69
|
+
m.content_text AS contentText,
|
|
70
|
+
m.blocks AS blocks,
|
|
71
|
+
m.agent_id AS agentId,
|
|
72
|
+
m.adapter_session_id AS adapterSessionId,
|
|
73
|
+
m.adapter_message_id AS adapterMessageId,
|
|
74
|
+
m.timestamp AS timestamp,
|
|
75
|
+
m.edit_of AS editOf,
|
|
76
|
+
m.origin AS origin
|
|
77
|
+
`,c=i?t`
|
|
78
|
+
SELECT ${s}
|
|
79
|
+
FROM messages m
|
|
80
|
+
JOIN messages_fts fts ON m.rowid = fts.rowid
|
|
81
|
+
WHERE messages_fts MATCH ${o}
|
|
82
|
+
AND fts.session_id = ${i}
|
|
83
|
+
ORDER BY bm25(messages_fts)
|
|
84
|
+
LIMIT ${a}
|
|
85
|
+
`:t`
|
|
86
|
+
SELECT ${s}
|
|
87
|
+
FROM messages m
|
|
88
|
+
JOIN messages_fts fts ON m.rowid = fts.rowid
|
|
89
|
+
WHERE messages_fts MATCH ${o}
|
|
90
|
+
ORDER BY bm25(messages_fts)
|
|
91
|
+
LIMIT ${a}
|
|
92
|
+
`,l=f(e),u=await l.all(c),d=i?t`
|
|
93
|
+
SELECT COUNT(*) as count FROM messages_fts
|
|
94
|
+
WHERE messages_fts MATCH ${o}
|
|
95
|
+
AND session_id = ${i}
|
|
96
|
+
`:t`
|
|
97
|
+
SELECT COUNT(*) as count FROM messages_fts
|
|
98
|
+
WHERE messages_fts MATCH ${o}
|
|
99
|
+
`,[p]=await l.all(d);return{rows:u,total:p?.count??0}},async searchMessageExcerpts(e,t,n){let r=M(n.query),[i,a]=await Promise.all([P(e,r,n.limit,n.sessionId),F(e,r,n.sessionId)]);return{results:i.map(e=>({messageId:e.message_id,sessionId:e.session_id,score:e.score,excerpt:e.excerpt})),total:a}},async searchSessionRows(e,n){let r=N(n);return f(e).all(t`
|
|
100
|
+
SELECT DISTINCT
|
|
101
|
+
s.session_id,
|
|
102
|
+
s.created_at,
|
|
103
|
+
s.last_activity_at,
|
|
104
|
+
s.status,
|
|
105
|
+
s.title,
|
|
106
|
+
s.lead_agent_id,
|
|
107
|
+
s.parent_session_id,
|
|
108
|
+
s.root_session_id,
|
|
109
|
+
s.fork_point_message_id,
|
|
110
|
+
s.branch_kind,
|
|
111
|
+
s.adapter_name,
|
|
112
|
+
s.adapter_session_id,
|
|
113
|
+
s.adapter_id,
|
|
114
|
+
s.is_orchestrated,
|
|
115
|
+
s.is_imported,
|
|
116
|
+
s.summary,
|
|
117
|
+
s.summary_updated_at,
|
|
118
|
+
s.fork_transforms,
|
|
119
|
+
s.target_working_directory
|
|
120
|
+
FROM sessions s
|
|
121
|
+
WHERE (
|
|
122
|
+
s.session_id IN (
|
|
123
|
+
SELECT session_id FROM messages_fts
|
|
124
|
+
WHERE messages_fts MATCH ${n.query}
|
|
125
|
+
)
|
|
126
|
+
OR LOWER(s.title) LIKE ${n.likePattern}
|
|
127
|
+
)
|
|
128
|
+
${r}
|
|
129
|
+
ORDER BY s.last_activity_at DESC
|
|
130
|
+
LIMIT ${n.limit}
|
|
131
|
+
`)},async countSessionMatches(e,n){let r=N(n),[i]=await f(e).all(t`
|
|
132
|
+
SELECT COUNT(DISTINCT s.session_id) as total
|
|
133
|
+
FROM sessions s
|
|
134
|
+
WHERE (
|
|
135
|
+
s.session_id IN (
|
|
136
|
+
SELECT session_id FROM messages_fts
|
|
137
|
+
WHERE messages_fts MATCH ${n.query}
|
|
138
|
+
)
|
|
139
|
+
OR LOWER(s.title) LIKE ${n.likePattern}
|
|
140
|
+
)
|
|
141
|
+
${r}
|
|
142
|
+
`);return i?.total??0},async fetchFirstUserMessagePreviews(e,n){if(n.length===0)return new Map;let r=await f(e).all(j(n,t`m2.rowid < m.rowid`)),i=new Map;for(let e of r)i.set(e.sessionId,e.preview);return i}},L={dialect:`sqlite`,createClient:A,errors:{isDuplicateObjectError:x,isUniqueViolationError:(e,t)=>S(e)},capabilities:{binaryColumnType:`BLOB`,maxCounterAssignmentRaces:!1,async tableExists(e,n){return(await e.all(t`SELECT name FROM sqlite_master WHERE type='table' AND name=${n}`)).length>0}},migrations:{defaultLedgerTable:`__drizzle_migrations`,journalDialect:`sqlite`,chainDirName:`drizzle`,buildLedgerDdl(e){return`CREATE TABLE IF NOT EXISTS ${m(e)} (
|
|
143
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
144
|
+
hash text NOT NULL,
|
|
145
|
+
created_at numeric
|
|
146
|
+
)`},beginTransactionStatement:`BEGIN`,extensionLedgerName:e=>`__drizzle_migrations_${e}`},fts:I},R=Symbol.for(`makaio.storage.engineRegistry`);function z(){let e=globalThis,t=e[R];return t===void 0&&(t=new Map,Object.defineProperty(e,R,{value:t,enumerable:!1,writable:!1,configurable:!1})),t.has(L.dialect)||t.set(L.dialect,L),t}function B(e){let t=z(),n=t.get(e.dialect);if(n!==e){if(n!==void 0)throw Error(`registerStorageEngine: a different engine is already registered for dialect '${e.dialect}'. One dialect has exactly one engine per process; check for duplicated package installations.`);t.set(e.dialect,e)}}function V(e){let t=z().get(e);if(t!==void 0)return t;let n=_(e);throw Error(n===void 0?`getStorageEngine: no storage engine is registered for dialect '${e}'. Register one with registerStorageEngine() before resolving it.`:v(e,n.packageName))}function H(e){return z().get(e)}function U(e){return V(i(e))}function W(e){let t=z();for(let n of t.values())if(n.matchesUrl!==void 0&&n.matchesUrl(e))return{kind:`engine`,engine:n};let n=g(e);if(n!==void 0){let e=t.get(n.dialect);return e===void 0?{kind:`missing-engine`,dialect:n.dialect,packageName:n.packageName}:{kind:`engine`,engine:e}}return{kind:`default`}}export{i as C,r as S,p as _,W as a,a as b,M as c,S as d,b as f,m as g,v as h,U as i,j as l,h as m,V as n,L as o,y as p,B as r,I as s,H as t,x as u,c as v,o as x,f as y};
|
package/dist/rules/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as RuleSetOptions, S as Rule, _ as JsonObjectShape, a as JsonObjectSchema, b as NotCondition, c as RuleSetOptionsSchema, d as CompoundCondition, f as Condition, g as JsonObject, h as FieldOperator, i as FieldOperatorSchema, l as ScalarValueSchema, m as FieldCondition, n as ExpressionConditionSchema, o as JsonValueSchema, p as ExpressionCondition, r as FieldConditionSchema, s as RuleSchema, t as ConditionSchema, u as AndCondition, v as JsonPrimitive, w as ScalarValue, x as OrCondition, y as JsonValue } from "../schemas-
|
|
1
|
+
import { C as RuleSetOptions, S as Rule, _ as JsonObjectShape, a as JsonObjectSchema, b as NotCondition, c as RuleSetOptionsSchema, d as CompoundCondition, f as Condition, g as JsonObject, h as FieldOperator, i as FieldOperatorSchema, l as ScalarValueSchema, m as FieldCondition, n as ExpressionConditionSchema, o as JsonValueSchema, p as ExpressionCondition, r as FieldConditionSchema, s as RuleSchema, t as ConditionSchema, u as AndCondition, v as JsonPrimitive, w as ScalarValue, x as OrCondition, y as JsonValue } from "../schemas-C792eVAZ.mjs";
|
|
2
2
|
|
|
3
3
|
//#region packages/rules/src/evaluator.d.ts
|
|
4
4
|
/**
|
package/dist/rules/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../esm-
|
|
1
|
+
import{t as e}from"../esm-CQVFKEW5.mjs";import{ConditionSchema as t,ExpressionConditionSchema as n,FieldConditionSchema as r,FieldOperatorSchema as i,JsonObjectSchema as a,JsonValueSchema as o,RuleSchema as s,RuleSetOptionsSchema as c,ScalarValueSchema as l}from"./schemas.mjs";import{compile as u}from"@makaio/framework/expression";const d=new Map,f=new Map;function p(e,t){if(`$and`in e){for(let n of e.$and)if(!p(n,t))return!1;return!0}if(`$or`in e){for(let n of e.$or)if(p(n,t))return!0;return!1}return`$not`in e?!p(e.$not,t):`$expr`in e?!!_(e.$expr).evalSync(t):h(g(t,e.field),e.operator)}function m(e,t,n={}){let{includeDisabled:r=!1}=n,i=[];for(let n of e)!r&&!n.enabled||p(n.condition,t)&&i.push(n);return i}function h(e,t){if(typeof t!=`object`||!t)return e===t;if(`$eq`in t)return e===t.$eq;if(`$ne`in t)return e!==t.$ne;if(`$in`in t)return t.$in.includes(e);if(`$nin`in t)return!t.$nin.includes(e);if(`$exists`in t){let n=e!==void 0;return t.$exists?n:!n}return`$startsWith`in t?typeof e==`string`&&e.startsWith(t.$startsWith):`$endsWith`in t?typeof e==`string`&&e.endsWith(t.$endsWith):`$glob`in t?typeof e==`string`&&v(t.$glob).match(e):!1}function g(e,t){if(e==null)return;let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return;r=r[e]}return r}function _(e){return y(d,e,()=>u(e))}function v(t){return y(f,t,()=>new e(t))}function y(e,t,n){let r=e.get(t);if(r!==void 0)return e.delete(t),e.set(t,r),r;let i=n();if(e.set(t,i),e.size>256){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return i}export{t as ConditionSchema,n as ExpressionConditionSchema,r as FieldConditionSchema,i as FieldOperatorSchema,a as JsonObjectSchema,o as JsonValueSchema,s as RuleSchema,c as RuleSetOptionsSchema,l as ScalarValueSchema,p as evaluate,m as evaluateRules};
|
package/dist/rules/schemas.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as JsonObjectSchema, c as RuleSetOptionsSchema, i as FieldOperatorSchema, l as ScalarValueSchema, n as ExpressionConditionSchema, o as JsonValueSchema, r as FieldConditionSchema, s as RuleSchema, t as ConditionSchema } from "../schemas-
|
|
1
|
+
import { a as JsonObjectSchema, c as RuleSetOptionsSchema, i as FieldOperatorSchema, l as ScalarValueSchema, n as ExpressionConditionSchema, o as JsonValueSchema, r as FieldConditionSchema, s as RuleSchema, t as ConditionSchema } from "../schemas-C792eVAZ.mjs";
|
|
2
2
|
export { ConditionSchema, ExpressionConditionSchema, FieldConditionSchema, FieldOperatorSchema, JsonObjectSchema, JsonValueSchema, RuleSchema, RuleSetOptionsSchema, ScalarValueSchema };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DispatchingAuth as e,createWebSocketCloseEvent as t}from"@makaio/framework/node/transports";import{HonoWebSocketBridge as n,startBusServer as r}from"@makaio/framework/node/bus-server";import{ExplicitDescriptorDiscovery as i,FileConfigStorage as a,FileRegistryCache as o,FilesystemDescriptorDiscovery as s,NodeCredentialProvider as c,StoredCredentialProvider as l,bootMakaioRuntimeCore as u,bootMakaioRuntimeCore as d,bridgeExtensionBrowserEntries as f,createHonoRouteGraph as p,createHttpRouteGraphBuilder as m,entrypointStem as h,isCliContributionLike as g,isMakaioExtensionLike as _,isMissingOptionalRuntimePackage as v,isWithinDirectory as y,loadExtensions as b,loadOrCreateMachineIdentity as x,machineKeysExist as S,registerAdapterNameResolver as C,resolveConventionEntrypoint as w,resolveStaticModelRegistryPath as T,runMigrations as E,tryImport as D,validateMachineKeys as O}from"@makaio/framework/runtime-node";import{isIP as k}from"node:net";var A=class{raw;eventListeners={message:new Set,close:new Set,error:new Set,open:new Set};constructor(e){this.raw=e}get readyState(){return this.raw.readyState}send(e){if(typeof e==`string`){this.raw.send(e);return}if(e instanceof Blob){e.arrayBuffer().then(e=>{this.raw.readyState===1&&this.raw.send(new Uint8Array(e))}).catch(()=>{this.dispatchError()});return}if(e instanceof ArrayBuffer){this.raw.send(new Uint8Array(e));return}ArrayBuffer.isView(e)&&this.raw.send(e)}close(e,t){this.raw.close(e,t)}addEventListener(e,t){this.eventListeners[e]?.add(t)}removeEventListener(e,t){this.eventListeners[e]?.delete(t)}dispatchMessage(e){let t=new MessageEvent(`message`,{data:e});for(let e of this.eventListeners.message)e(t)}dispatchClose(e,n){let r=t(e,n);for(let e of this.eventListeners.close)e(r)}dispatchError(){let e=new Event(`error`);for(let t of this.eventListeners.error)t(e)}},j=class{options;bridge;busServer=null;busReady=!1;connecting=!1;constructor(e){this.options=e,this.bridge=new n}get dispatchingAuth(){return this.options.auth instanceof e?this.options.auth:void 0}createWebSocketHandler(){let e=this.bridge,t=()=>this.busReady,n=new WeakMap;return{binaryType:`arraybuffer`,open(r){if(!t()){r.close(1013,`Bus server not ready`);return}let i=new A(r);n.set(r,i),e.accept(i)},message(e,t){n.get(e)?.dispatchMessage(t)},close(e,t,r){n.get(e)?.dispatchClose(t,r),n.delete(e)}}}async connect(e,t){if(this.connecting||this.busServer)throw Error(`[BunBusServerTransport] connect() called while transport is already connected or connecting`);this.connecting=!0;try{this.busServer=await r({websocket:this.bridge,bus:e,auth:this.options.auth,loopbackName:this.options.loopbackName??`bun`}),this.busReady=!0}catch(e){throw await this.stopBusServer(`startup error`),e}finally{this.connecting=!1}}async disconnect(){await this.stopBusServer(`shutdown`),this.bridge.close()}async stopBusServer(e){this.busReady=!1,this.busServer&&=(await this.busServer.stop().catch(t=>{console.error(`[BunBusServerTransport] Failed to stop bus server during ${e}:`,t)}),null)}};function M(e){if(e.headers.get(`upgrade`)?.toLowerCase()!==`websocket`)return!1;let{pathname:t}=new URL(e.url);return t===`/bus`?!0:t===`/`&&e.headers.get(`origin`)===null}function N(e){return(t,n)=>M(t)?n.upgrade(t)?void 0:new Response(`WebSocket upgrade failed`,{status:426,headers:{Upgrade:`websocket`}}):e.fetch(t)}function ee(e){return e.port}async function P(e){let{port:t,hostname:n}=e.bunServer,r=e.createMount??(await import(`../create-static-mount-
|
|
1
|
+
import{DispatchingAuth as e,createWebSocketCloseEvent as t}from"@makaio/framework/node/transports";import{HonoWebSocketBridge as n,startBusServer as r}from"@makaio/framework/node/bus-server";import{ExplicitDescriptorDiscovery as i,FileConfigStorage as a,FileRegistryCache as o,FilesystemDescriptorDiscovery as s,NodeCredentialProvider as c,StoredCredentialProvider as l,bootMakaioRuntimeCore as u,bootMakaioRuntimeCore as d,bridgeExtensionBrowserEntries as f,createHonoRouteGraph as p,createHttpRouteGraphBuilder as m,entrypointStem as h,isCliContributionLike as g,isMakaioExtensionLike as _,isMissingOptionalRuntimePackage as v,isWithinDirectory as y,loadExtensions as b,loadOrCreateMachineIdentity as x,machineKeysExist as S,registerAdapterNameResolver as C,resolveConventionEntrypoint as w,resolveStaticModelRegistryPath as T,runMigrations as E,tryImport as D,validateMachineKeys as O}from"@makaio/framework/runtime-node";import{isIP as k}from"node:net";var A=class{raw;eventListeners={message:new Set,close:new Set,error:new Set,open:new Set};constructor(e){this.raw=e}get readyState(){return this.raw.readyState}send(e){if(typeof e==`string`){this.raw.send(e);return}if(e instanceof Blob){e.arrayBuffer().then(e=>{this.raw.readyState===1&&this.raw.send(new Uint8Array(e))}).catch(()=>{this.dispatchError()});return}if(e instanceof ArrayBuffer){this.raw.send(new Uint8Array(e));return}ArrayBuffer.isView(e)&&this.raw.send(e)}close(e,t){this.raw.close(e,t)}addEventListener(e,t){this.eventListeners[e]?.add(t)}removeEventListener(e,t){this.eventListeners[e]?.delete(t)}dispatchMessage(e){let t=new MessageEvent(`message`,{data:e});for(let e of this.eventListeners.message)e(t)}dispatchClose(e,n){let r=t(e,n);for(let e of this.eventListeners.close)e(r)}dispatchError(){let e=new Event(`error`);for(let t of this.eventListeners.error)t(e)}},j=class{options;bridge;busServer=null;busReady=!1;connecting=!1;constructor(e){this.options=e,this.bridge=new n}get dispatchingAuth(){return this.options.auth instanceof e?this.options.auth:void 0}createWebSocketHandler(){let e=this.bridge,t=()=>this.busReady,n=new WeakMap;return{binaryType:`arraybuffer`,open(r){if(!t()){r.close(1013,`Bus server not ready`);return}let i=new A(r);n.set(r,i),e.accept(i)},message(e,t){n.get(e)?.dispatchMessage(t)},close(e,t,r){n.get(e)?.dispatchClose(t,r),n.delete(e)}}}async connect(e,t){if(this.connecting||this.busServer)throw Error(`[BunBusServerTransport] connect() called while transport is already connected or connecting`);this.connecting=!0;try{this.busServer=await r({websocket:this.bridge,bus:e,auth:this.options.auth,loopbackName:this.options.loopbackName??`bun`}),this.busReady=!0}catch(e){throw await this.stopBusServer(`startup error`),e}finally{this.connecting=!1}}async disconnect(){await this.stopBusServer(`shutdown`),this.bridge.close()}async stopBusServer(e){this.busReady=!1,this.busServer&&=(await this.busServer.stop().catch(t=>{console.error(`[BunBusServerTransport] Failed to stop bus server during ${e}:`,t)}),null)}};function M(e){if(e.headers.get(`upgrade`)?.toLowerCase()!==`websocket`)return!1;let{pathname:t}=new URL(e.url);return t===`/bus`?!0:t===`/`&&e.headers.get(`origin`)===null}function N(e){return(t,n)=>M(t)?n.upgrade(t)?void 0:new Response(`WebSocket upgrade failed`,{status:426,headers:{Upgrade:`websocket`}}):e.fetch(t)}function ee(e){return e.port}async function P(e){let{port:t,hostname:n}=e.bunServer,r=e.createMount??(await import(`../create-static-mount-BB1MIQ9J.mjs`)).defaultCreateMount;return d(e.transport,t,n,{...e,createMount:r})}function F(e,t){let n=e,r=t;return{fetch(e,t){return n(e,t)},websocket:{binaryType:t.binaryType,open(e){r.open(e)},message(e,t){r.message(e,t)},close(e,t,n){r.close(e,t,n)}},activate(i){n=R(e,i),r=z(t,i)}}}function I(e){let t=[];return e.forEachActiveExtension((e,n)=>{B(n)&&t.push(n)}),t}function L(e){return Array.isArray(e)?e.flatMap(e=>L(e)):B(e)?[e]:[]}function R(e,t){return t.reduce((e,t)=>t.bun.createFetch?.(e)??e,e)}function z(e,t){return t.reduce((e,t)=>t.bun.createWebSocketHandler?.(e)??e,e)}function B(e){if(!H(e))return!1;let t=e.bun;return typeof e.name==`string`&&typeof e.displayName==`string`&&V(t)}function V(e){if(!H(e))return!1;let t=e.createFetch,n=e.createWebSocketHandler;return(t===void 0||typeof t==`function`)&&(n===void 0||typeof n==`function`)}function H(e){return typeof e==`object`&&!!e}function U(e){let t=e.timeoutMs??1e4,n=e.exit??(e=>process.exit(e)),r=!1;return async i=>{if(r)return;r=!0,console.info(`[${e.label}] ${i} received, shutting down...`);let a=setTimeout(()=>{console.error(`[${e.label}] Graceful shutdown timed out, forcing exit`),n(1)},t);try{process.env.MAKAIO_DEBUG&&console.info(`[${e.label}] Shutting down runtime...`),await e.runtime.shutdown(),process.env.MAKAIO_DEBUG&&console.info(`[${e.label}] Stopping Bun server...`),W(e.bunServer,e.label),process.env.MAKAIO_DEBUG&&console.info(`[${e.label}] Shutdown complete`),clearTimeout(a),n(0)}catch(t){W(e.bunServer,e.label),clearTimeout(a),console.error(`[${e.label}] Shutdown error:`,t),n(1)}}}function W(e,t){let n=e.stop?.(!0);G(n)&&n.catch(e=>{console.warn(`[${t}] Bun server stop failed during shutdown:`,e)})}function G(e){return typeof e==`object`&&!!e&&typeof e.catch==`function`}const K=/^(?=.{1,253}$)(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;function q(e){let t=e.env??process.env,n=e.defaultPort??3e3,r=e.defaultHost??`0.0.0.0`;return{port:J(t.PORT,n,e),host:Y(t.HOST,r,e)}}function J(e,t,n){let r=e?.trim(),i=r&&/^\d+$/.test(r)?Number.parseInt(r,10):NaN;return Number.isInteger(i)&&i>=1&&i<=65535?i:e===void 0?t:Z(`Invalid PORT: ${e}`,t,n)}function Y(e,t,n){let r=e?.trim();return r&&X(r)?r:e===void 0?t:Q(`Invalid HOST: ${e}`,t,n)}function X(e){return k(e)!==0||e===`localhost`||K.test(e)}function Z(e,t,n){return $(e,String(t),n),t}function Q(e,t,n){return $(e,t,n),t}function $(e,t,n){if((n.invalid??`throw`)===`throw`)throw Error(e);console.warn(`[${n.appName}] ${e}, falling back to ${t}`)}export{j as BunBusServerTransportProvider,i as ExplicitDescriptorDiscovery,a as FileConfigStorage,o as FileRegistryCache,s as FilesystemDescriptorDiscovery,c as NodeCredentialProvider,l as StoredCredentialProvider,P as bootMakaioRuntime,u as bootMakaioRuntimeCore,f as bridgeExtensionBrowserEntries,I as collectActiveBunHostPackages,R as composeBunHostFetch,z as composeBunHostWebSocket,F as createBunHostRouter,N as createBunRouteGraphFetch,U as createGracefulShutdown,p as createHonoRouteGraph,m as createHttpRouteGraphBuilder,h as entrypointStem,g as isCliContributionLike,_ as isMakaioExtensionLike,v as isMissingOptionalRuntimePackage,y as isWithinDirectory,b as loadExtensions,x as loadOrCreateMachineIdentity,S as machineKeysExist,L as normalizeBunHostPackages,q as readBunServerEnv,C as registerAdapterNameResolver,w as resolveConventionEntrypoint,ee as resolveListeningPort,T as resolveStaticModelRegistryPath,E as runMigrations,D as tryImport,O as validateMachineKeys};
|
|
@@ -10,18 +10,18 @@ import * as _$zod_v4_core0 from "zod/v4/core";
|
|
|
10
10
|
* Registered globally so lifecycle files can import subjects.
|
|
11
11
|
*/
|
|
12
12
|
declare const RuntimeNamespace: _$_makaio_core0.BusNamespaceDefinition<"runtime", {
|
|
13
|
-
database: {
|
|
13
|
+
database: _$_makaio_core0.LocalSubjectSchema<{
|
|
14
14
|
request: _$zod.ZodObject<{}, _$zod_v4_core0.$strip>;
|
|
15
15
|
response: _$zod.ZodObject<{
|
|
16
16
|
db: _$zod.ZodUnknown;
|
|
17
17
|
}, _$zod_v4_core0.$strip>;
|
|
18
|
-
}
|
|
19
|
-
machineIdentity: {
|
|
18
|
+
}>;
|
|
19
|
+
machineIdentity: _$_makaio_core0.LocalSubjectSchema<{
|
|
20
20
|
request: _$zod.ZodObject<{}, _$zod_v4_core0.$strip>;
|
|
21
21
|
response: _$zod.ZodObject<{
|
|
22
22
|
identity: _$zod.ZodUnknown;
|
|
23
23
|
}, _$zod_v4_core0.$strip>;
|
|
24
|
-
}
|
|
24
|
+
}>;
|
|
25
25
|
busPort: {
|
|
26
26
|
request: _$zod.ZodObject<{}, _$zod_v4_core0.$strip>;
|
|
27
27
|
response: _$zod.ZodObject<{
|
|
@@ -38,18 +38,18 @@ declare const RuntimeNamespace: _$_makaio_core0.BusNamespaceDefinition<"runtime"
|
|
|
38
38
|
* - busPort: Query for the bus server WebSocket port
|
|
39
39
|
*/
|
|
40
40
|
declare const RuntimeSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.FlatSubjectDefinitions<"runtime", {
|
|
41
|
-
database: {
|
|
41
|
+
database: _$_makaio_core0.LocalSubjectSchema<{
|
|
42
42
|
request: _$zod.ZodObject<{}, _$zod_v4_core0.$strip>;
|
|
43
43
|
response: _$zod.ZodObject<{
|
|
44
44
|
db: _$zod.ZodUnknown;
|
|
45
45
|
}, _$zod_v4_core0.$strip>;
|
|
46
|
-
}
|
|
47
|
-
machineIdentity: {
|
|
46
|
+
}>;
|
|
47
|
+
machineIdentity: _$_makaio_core0.LocalSubjectSchema<{
|
|
48
48
|
request: _$zod.ZodObject<{}, _$zod_v4_core0.$strip>;
|
|
49
49
|
response: _$zod.ZodObject<{
|
|
50
50
|
identity: _$zod.ZodUnknown;
|
|
51
51
|
}, _$zod_v4_core0.$strip>;
|
|
52
|
-
}
|
|
52
|
+
}>;
|
|
53
53
|
busPort: {
|
|
54
54
|
request: _$zod.ZodObject<{}, _$zod_v4_core0.$strip>;
|
|
55
55
|
response: _$zod.ZodObject<{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import * as _$_makaio_core0 from "@makaio/framework/core";
|
|
2
3
|
|
|
3
4
|
//#region runtimes/node/src/bus/runtime/schemas.d.ts
|
|
4
5
|
/**
|
|
@@ -13,28 +14,34 @@ declare const RuntimeSchemas: {
|
|
|
13
14
|
* Query for database handle.
|
|
14
15
|
* Registered by NodeRuntime. Absent in memory-only runtimes.
|
|
15
16
|
*
|
|
17
|
+
* Local-only: the response carries a live database handle that cannot be
|
|
18
|
+
* serialized across a transport. Use `getRuntimeDatabase` for typed access.
|
|
19
|
+
*
|
|
16
20
|
* Subject: `runtime.database`
|
|
17
21
|
* Type: Request (RPC)
|
|
18
22
|
*/
|
|
19
|
-
database: {
|
|
23
|
+
database: _$_makaio_core0.LocalSubjectSchema<{
|
|
20
24
|
request: z.ZodObject<{}, z.core.$strip>;
|
|
21
25
|
response: z.ZodObject<{
|
|
22
26
|
db: z.ZodUnknown;
|
|
23
27
|
}, z.core.$strip>;
|
|
24
|
-
}
|
|
28
|
+
}>;
|
|
25
29
|
/**
|
|
26
30
|
* Query for machine identity (E2E encryption keys).
|
|
27
31
|
* Registered by NodeRuntime. Absent in memory-only runtimes.
|
|
28
32
|
*
|
|
33
|
+
* Local-only: the response carries private key material that must never
|
|
34
|
+
* cross a transport.
|
|
35
|
+
*
|
|
29
36
|
* Subject: `runtime.machineIdentity`
|
|
30
37
|
* Type: Request (RPC)
|
|
31
38
|
*/
|
|
32
|
-
machineIdentity: {
|
|
39
|
+
machineIdentity: _$_makaio_core0.LocalSubjectSchema<{
|
|
33
40
|
request: z.ZodObject<{}, z.core.$strip>;
|
|
34
41
|
response: z.ZodObject<{
|
|
35
42
|
identity: z.ZodUnknown;
|
|
36
43
|
}, z.core.$strip>;
|
|
37
|
-
}
|
|
44
|
+
}>;
|
|
38
45
|
/**
|
|
39
46
|
* Query for the bus server WebSocket port.
|
|
40
47
|
* Registered at the app entry point (Electron main, CLI) where the bus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";const
|
|
1
|
+
import{z as e}from"zod";import{localSubject as t}from"@makaio/framework/core";const n={database:t({request:e.object({}),response:e.object({db:e.unknown()})}),machineIdentity:t({request:e.object({}),response:e.object({identity:e.unknown()})}),busPort:{request:e.object({}),response:e.object({port:e.number()})}};export{n as RuntimeSchemas};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as FilesystemDescriptorDiscovery, i as ExtensionEntrypointModule, n as ExplicitDescriptorDiscovery, o as FilesystemDescriptorDiscoveryOptions, r as ExtensionDiscovery, s as MergedDescriptorDiscovery, t as DiscoveredExtension } from "../extension-discovery-
|
|
1
|
+
import { a as FilesystemDescriptorDiscovery, i as ExtensionEntrypointModule, n as ExplicitDescriptorDiscovery, o as FilesystemDescriptorDiscoveryOptions, r as ExtensionDiscovery, s as MergedDescriptorDiscovery, t as DiscoveredExtension } from "../extension-discovery-CkV_VRdJ.mjs";
|
|
2
2
|
export { DiscoveredExtension, ExplicitDescriptorDiscovery, ExtensionDiscovery, ExtensionEntrypointModule, FilesystemDescriptorDiscovery, FilesystemDescriptorDiscoveryOptions, MergedDescriptorDiscovery };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as isMakaioExtensionLike, c as resolveConventionEntrypoint, i as isCliContributionLike, o as isWithinDirectory, r as entrypointStem } from "../load-extensions-
|
|
1
|
+
import { a as isMakaioExtensionLike, c as resolveConventionEntrypoint, i as isCliContributionLike, o as isWithinDirectory, r as entrypointStem } from "../load-extensions-D9nbDIiW.mjs";
|
|
2
2
|
export { entrypointStem, isCliContributionLike, isMakaioExtensionLike, isWithinDirectory, resolveConventionEntrypoint };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,n,o as r,r as i}from"../load-extensions-
|
|
1
|
+
import{a as e,c as t,n,o as r,r as i}from"../load-extensions-wELQ4BBN.mjs";export{n as entrypointStem,i as isCliContributionLike,e as isMakaioExtensionLike,r as isWithinDirectory,t as resolveConventionEntrypoint};
|