@pixelzx/genesis 2026.5.3-5 → 2026.5.5
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/CHANGELOG.md +8 -0
- package/dist/.buildstamp +1 -1
- package/dist/abort-t5XiT6Yl.js +201 -0
- package/dist/abort.runtime-C_xk0DkL.js +2 -0
- package/dist/abort.runtime.js +1 -1
- package/dist/accounts-B7yDKwxi.js +104 -0
- package/dist/accounts-CS7VL356.js +107 -0
- package/dist/accounts-XvHcAtMf.js +2 -0
- package/dist/acp-cli-B5H0nvID.js +2193 -0
- package/dist/acp-spawn-BRTMqPlq.js +2 -0
- package/dist/acp-spawn-Dsw3dzWY.js +1093 -0
- package/dist/acp-stateful-target-driver-BYhkJnyh.js +89 -0
- package/dist/action-agents-Ca9kTFvv.js +67 -0
- package/dist/action-focus-D4pT0hra.js +132 -0
- package/dist/action-help-DMzMxFEQ.js +7 -0
- package/dist/action-info-Dzn_fn6G.js +101 -0
- package/dist/action-kill-2AQuhnLy.js +33 -0
- package/dist/action-list-DI1M2pKU.js +21 -0
- package/dist/action-log-BVKGgOki.js +30 -0
- package/dist/action-send-CZ2wciMW.js +39 -0
- package/dist/action-spawn-BdclQLrK.js +47 -0
- package/dist/action-unfocus-DfQuRf8d.js +29 -0
- package/dist/actions.runtime-B2-oz_B6.js +5 -0
- package/dist/actions.runtime-BoUxrcw3.js +18 -0
- package/dist/actions.runtime.js +1 -1
- package/dist/agent-CnQ3yCIw.js +2 -0
- package/dist/agent-command-C4H_9c2N.js +874 -0
- package/dist/agent-harness-runtime-D2oXzgyL.js +144 -0
- package/dist/agent-runner-utils-CWgPcOYn.js +239 -0
- package/dist/agent-runner.runtime-DvK-HQhq.js +3455 -0
- package/dist/agent-runner.runtime.js +1 -1
- package/dist/agent-runtime-BDslXtCf.js +18 -0
- package/dist/agents-4T7YaeKy.js +953 -0
- package/dist/agents-C_Gty_RK.js +5 -0
- package/dist/aliases-BkVpehd-.js +96 -0
- package/dist/aliases-DWkJWJ5A.js +2 -0
- package/dist/api-CgW6fcU2.js +3 -0
- package/dist/api-DYPaGKUj.js +5 -0
- package/dist/api-DdoV90Cn.js +139 -0
- package/dist/approval-gateway-resolver-Ba_2kb3B.js +29 -0
- package/dist/approval-gateway-runtime-7VMivk0A.js +2 -0
- package/dist/approval-handler-runtime-DUDpOwG7.js +439 -0
- package/dist/approval-native-runtime-KkmX9gwQ.js +729 -0
- package/dist/attempt-execution.runtime-CQkeVpDx.js +509 -0
- package/dist/attempt-execution.runtime.js +1 -1
- package/dist/attempt.prompt-helpers-MoT6VaD0.js +221 -0
- package/dist/attempt.tool-run-context-B53GhX-d.js +933 -0
- package/dist/audit-CvHcVVb-.js +939 -0
- package/dist/audit.runtime-C7n442Rc.js +7 -0
- package/dist/audit.runtime.js +1 -1
- package/dist/auth-CAnSldtM.js +2 -0
- package/dist/auth-Czf_o5iE.js +383 -0
- package/dist/auth-order-Cu9Vj7lA.js +96 -0
- package/dist/auth-order-q1IFw7L3.js +2 -0
- package/dist/bash-tools-BS4TrA4X.js +2824 -0
- package/dist/bash-tools-DbHYuk8O.js +3 -0
- package/dist/binding-routing-CnNQE65Q.js +85 -0
- package/dist/binding-targets-DW0ScIRI.js +121 -0
- package/dist/bridge-server-BGS08n2f.js +113 -0
- package/dist/browser-control-auth-DMlQOsyN.js +2 -0
- package/dist/browser-node-runtime-CF32scUO.js +12 -0
- package/dist/browser-profiles-CmER65eh.js +2 -0
- package/dist/browser-runtime-D73M9fg3.js +387 -0
- package/dist/browser-setup-tools-Cr0UI1rf.js +13 -0
- package/dist/build-BL7WirDF.js +550 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +2 -2
- package/dist/bundled/session-memory/handler.js +1 -1
- package/dist/call-Ckws4Nlw.js +3 -0
- package/dist/call-DkGNVvLy.js +331 -0
- package/dist/call.runtime-DfLBtAIr.js +2 -0
- package/dist/call.runtime.js +1 -1
- package/dist/capability-cli-tSqSJf2o.js +1401 -0
- package/dist/catchup-Dp2L1RcY.js +300 -0
- package/dist/channel-BIFp1GJd.js +1320 -0
- package/dist/channel-BZMzoXhw.js +840 -0
- package/dist/channel-BtPZ0i4g.js +297 -0
- package/dist/channel-DDd7xwLG.js +226 -0
- package/dist/channel-DLezQPqR.js +350 -0
- package/dist/channel-DcYHXn_7.js +1100 -0
- package/dist/channel-DzKtLfJj.js +1802 -0
- package/dist/channel-LlY18tI5.js +595 -0
- package/dist/channel-NjZviHcJ.js +1174 -0
- package/dist/channel-core-Cg1mFpva.js +5 -0
- package/dist/channel-inbound-CZpi-vp5.js +31 -0
- package/dist/channel-pDXIWFS4.js +453 -0
- package/dist/channel-plugin-runtime-DHl81Ror.js +771 -0
- package/dist/channel-runtime-CtYrrwow.js +425 -0
- package/dist/channel-wMkGGyIY.js +491 -0
- package/dist/channel.runtime-B1n0hvUI.js +430 -0
- package/dist/channel.runtime-B9iR26l_.js +576 -0
- package/dist/channel.runtime-C8eBQk67.js +4 -0
- package/dist/channel.runtime-Db8g8JCg.js +89 -0
- package/dist/channel.runtime-DfRfisV2.js +34702 -0
- package/dist/channel.runtime-gPdBMu3V.js +109 -0
- package/dist/channel.runtime-rG9pJ5NO.js +2364 -0
- package/dist/channel.runtime.js +1 -1
- package/dist/channel.setup-CWblUOhD.js +10 -0
- package/dist/channels-B4dYRKsI.js +733 -0
- package/dist/channels-cli-GMAOUYU3.js +268 -0
- package/dist/chat-D2XaZNiP.js +2758 -0
- package/dist/clawbot-cli-CSmdcIMT.js +9 -0
- package/dist/cli/daemon-cli.js +3 -3
- package/dist/cli-2u5IZTMS.js +219 -0
- package/dist/cli-Bk8uXnyc.js +72 -0
- package/dist/cli-DBfw9jCz.js +2 -0
- package/dist/cli-runner-BEqvX1ky.js +286 -0
- package/dist/cli-runner.runtime-BIUcUGDa.js +4 -0
- package/dist/cli-runner.runtime-D2u3Yw0W.js +3 -0
- package/dist/cli-runner.runtime.js +1 -1
- package/dist/cli-startup-metadata.json +2 -2
- package/dist/cli-waH8839u.js +2 -0
- package/dist/cli.runtime-mKvJpLwI.js +1261 -0
- package/dist/cli.runtime.js +1 -1
- package/dist/client-CKizOsGp.js +138 -0
- package/dist/client-CrPccv7a.js +713 -0
- package/dist/command-auth-DPkjKHdv.js +76 -0
- package/dist/command-config-resolution-BTjtnAp2.js +2 -0
- package/dist/command-config-resolution-Be3KZA_l.js +23 -0
- package/dist/command-config-resolution.runtime-DXgL8cm7.js +2 -0
- package/dist/command-config-resolution.runtime.js +1 -1
- package/dist/command-registry-BL1Z4Cen.js +4 -0
- package/dist/command-registry-BMePAw9w.js +9 -0
- package/dist/command-registry-core-CAay55-n.js +104 -0
- package/dist/command-secret-gateway-jj1Qmk9L.js +528 -0
- package/dist/command-status.runtime-BVcCm9_0.js +87 -0
- package/dist/command-status.runtime.js +1 -1
- package/dist/commands-acp-COdUW69f.js +77 -0
- package/dist/commands-compact.runtime-C0Fedews.js +10 -0
- package/dist/commands-compact.runtime.js +1 -1
- package/dist/commands-handlers.runtime-BXVM3PWG.js +4597 -0
- package/dist/commands-handlers.runtime.js +1 -1
- package/dist/commands-status-DaApOLoQ.js +16 -0
- package/dist/commands-status.runtime-CxSjrKne.js +3 -0
- package/dist/commands-status.runtime.js +1 -1
- package/dist/commands-subagents-control.runtime-BEfW44br.js +2 -0
- package/dist/commands-subagents-control.runtime-DB3AROHI.js +3 -0
- package/dist/commands-subagents-control.runtime.js +1 -1
- package/dist/commands-system-prompt-CCrUy7xq.js +158 -0
- package/dist/commands-system-prompt-CN56TtaC.js +2 -0
- package/dist/commands.runtime-Bee6dM3V.js +166 -0
- package/dist/commands.runtime.js +1 -1
- package/dist/compact-7YtEe1kG.js +1118 -0
- package/dist/compact.runtime-4gW_cs7D.js +12 -0
- package/dist/compact.runtime.js +1 -1
- package/dist/completion-cli-COv-r8_h.js +313 -0
- package/dist/config-DSsLlg8J.js +251 -0
- package/dist/config-cli-C9oGe9gl.js +1078 -0
- package/dist/configure-Bfy9tVmS.js +2 -0
- package/dist/configure-DpIFRaAD.js +1245 -0
- package/dist/connect-options-CPixzqP_.js +699 -0
- package/dist/control-auth-L7U2ivRJ.js +125 -0
- package/dist/control-service-CbUz8qU5.js +156 -0
- package/dist/conversation-id-BroDIGeT.js +38 -0
- package/dist/conversation-id-CuVi0tWe.js +235 -0
- package/dist/conversation-runtime-weaahZQN.js +31 -0
- package/dist/core-PXv1nsc-.js +275 -0
- package/dist/cron-cli-DZNSQBuA.js +713 -0
- package/dist/daemon-cli-C_9CNoZA.js +12 -0
- package/dist/delegate-B8wh-jjf.js +64 -0
- package/dist/detached-task-runtime-BTq-jIGw.js +73 -0
- package/dist/devices-cli-C_amY-AS.js +496 -0
- package/dist/diagnostics-Bw-fd0ug.js +154 -0
- package/dist/direct-dm-Dvqjch3O.js +64 -0
- package/dist/dispatch-DHPQS49Q.js +1131 -0
- package/dist/dispatch-acp-manager.runtime-y-oykPUz.js +3 -0
- package/dist/dispatch-acp-manager.runtime.js +1 -1
- package/dist/dispatch-acp-taSuJD5W.js +981 -0
- package/dist/dispatch-acp.runtime-DgyaFFNX.js +19 -0
- package/dist/dispatch-acp.runtime.js +1 -1
- package/dist/doctor-device-pairing-rxwogzYF.js +307 -0
- package/dist/doctor-gateway-daemon-flow-Dm4wxnTt.js +250 -0
- package/dist/doctor-gateway-health-wJVW5xUW.js +60 -0
- package/dist/doctor-health-DaodspKU.js +59 -0
- package/dist/doctor-health-contributions-CBVyN6ju.js +486 -0
- package/dist/doctor-prompter-vO6LPeXZ.js +56 -0
- package/dist/doctor-workspace-status-BnXA04-6.js +75 -0
- package/dist/dreaming-1RLie1iF.js +1574 -0
- package/dist/dreaming-narrative-BRtTdpbt.js +595 -0
- package/dist/embedded-gateway-stub.runtime-GMix51Tf.js +9 -0
- package/dist/embedded-gateway-stub.runtime.js +1 -1
- package/dist/entry.js +2 -2
- package/dist/exec-approvals-cli-R6jgupQH.js +498 -0
- package/dist/extensionAPI.js +1 -1
- package/dist/extensions/active-memory/index.js +1 -1
- package/dist/extensions/bluebubbles/api.js +3 -3
- package/dist/extensions/bluebubbles/channel-plugin-api.js +1 -1
- package/dist/extensions/browser/browser-bridge.js +1 -1
- package/dist/extensions/browser/browser-config.js +4 -4
- package/dist/extensions/browser/browser-control-auth.js +2 -2
- package/dist/extensions/browser/browser-doctor.js +2 -2
- package/dist/extensions/browser/browser-maintenance.js +2 -2
- package/dist/extensions/browser/browser-profiles.js +2 -2
- package/dist/extensions/browser/browser-runtime-api.js +10 -10
- package/dist/extensions/browser/index.js +1 -1
- package/dist/extensions/browser/plugin-registration.js +1 -1
- package/dist/extensions/browser/register.runtime.js +3 -3
- package/dist/extensions/browser/runtime-api.js +11 -11
- package/dist/extensions/browser/test-support.js +1 -1
- package/dist/extensions/device-pair/api.js +1 -1
- package/dist/extensions/device-pair/index.js +3 -3
- package/dist/extensions/device-pair/notify.js +1 -1
- package/dist/extensions/device-pair/pair-command-approve.js +1 -1
- package/dist/extensions/google-meet/index.js +2 -2
- package/dist/extensions/imessage/api.js +3 -3
- package/dist/extensions/imessage/channel-plugin-api.js +1 -1
- package/dist/extensions/imessage/runtime-api.js +3 -3
- package/dist/extensions/irc/api.js +2 -2
- package/dist/extensions/irc/channel-plugin-api.js +1 -1
- package/dist/extensions/line/api.js +2 -2
- package/dist/extensions/line/channel-plugin-api.js +1 -1
- package/dist/extensions/line/contract-api.js +1 -1
- package/dist/extensions/line/runtime-api.js +4 -4
- package/dist/extensions/line/setup-api.js +1 -1
- package/dist/extensions/llm-task/index.js +2 -2
- package/dist/extensions/lobster/index.js +3 -3
- package/dist/extensions/lobster/runtime-api.js +1 -1
- package/dist/extensions/mattermost/api.js +1 -1
- package/dist/extensions/mattermost/channel-plugin-api.js +1 -1
- package/dist/extensions/mattermost/channel-plugin-runtime.js +1 -1
- package/dist/extensions/mattermost/policy-api.js +1 -1
- package/dist/extensions/mattermost/runtime-api.js +4 -4
- package/dist/extensions/mattermost/slash-route-api.js +1 -1
- package/dist/extensions/memory-core/api.js +1 -1
- package/dist/extensions/memory-core/cli-metadata.js +2 -2
- package/dist/extensions/memory-core/index.js +3 -3
- package/dist/extensions/memory-lancedb/cli-metadata.js +1 -1
- package/dist/extensions/msteams/api.js +1 -1
- package/dist/extensions/msteams/channel-plugin-api.js +1 -1
- package/dist/extensions/msteams/runtime-api.js +3 -3
- package/dist/extensions/msteams/test-api.js +1 -1
- package/dist/extensions/nextcloud-talk/api.js +1 -1
- package/dist/extensions/nextcloud-talk/channel-plugin-api.js +1 -1
- package/dist/extensions/nextcloud-talk/runtime-api.js +2 -2
- package/dist/extensions/openshell/index.js +2 -2
- package/dist/extensions/signal/api.js +6 -6
- package/dist/extensions/signal/channel-plugin-api.js +1 -1
- package/dist/extensions/signal/reaction-runtime-api.js +1 -1
- package/dist/extensions/signal/runtime-api.js +7 -7
- package/dist/extensions/skill-workshop/api.js +1 -1
- package/dist/extensions/skill-workshop/index.js +1 -1
- package/dist/extensions/synology-chat/api.js +1 -1
- package/dist/extensions/synology-chat/channel-plugin-api.js +1 -1
- package/dist/extensions/tlon/api.js +2 -2
- package/dist/extensions/tlon/channel-plugin-api.js +1 -1
- package/dist/extensions/tlon/runtime-api.js +1 -1
- package/dist/extensions/tlon/test-api.js +1 -1
- package/dist/extensions/twitch/api.js +1 -1
- package/dist/extensions/twitch/channel-plugin-api.js +1 -1
- package/dist/extensions/twitch/setup-plugin-api.js +1 -1
- package/dist/extensions/zalo/api.js +3 -3
- package/dist/extensions/zalo/channel-plugin-api.js +1 -1
- package/dist/extensions/zalo/runtime-api.js +2 -2
- package/dist/extensions/zalo/setup-api.js +2 -2
- package/dist/extensions/zalouser/api.js +3 -3
- package/dist/extensions/zalouser/channel-plugin-api.js +1 -1
- package/dist/extensions/zalouser/runtime-api.js +6 -6
- package/dist/extensions/zalouser/setup-plugin-api.js +1 -1
- package/dist/extensions/zalouser/test-api.js +1 -1
- package/dist/fallbacks-Cckv3nng.js +2 -0
- package/dist/fallbacks-Y_nNY8_a.js +31 -0
- package/dist/fallbacks-shared-DZiG1Gr_.js +111 -0
- package/dist/gateway-CDfn0J87.js +115 -0
- package/dist/gateway-cli-D197U6l0.js +1325 -0
- package/dist/gateway-rpc-Bomz8HKq.js +14 -0
- package/dist/gateway-rpc.runtime-597tksmo.js +23 -0
- package/dist/gateway-rpc.runtime.js +1 -1
- package/dist/gateway-runtime-Bm2_MhFn.js +15 -0
- package/dist/gateway-status-Cr4UJKUx.js +584 -0
- package/dist/genesis-tools-DCRaVVjY.js +8999 -0
- package/dist/genesis-tools.runtime-idgd5fjy.js +2 -0
- package/dist/genesis-tools.runtime.js +1 -1
- package/dist/get-reply-BF_7bR5f.js +3879 -0
- package/dist/get-reply-from-config.runtime-DEq5XM_s.js +2 -0
- package/dist/get-reply-from-config.runtime.js +1 -1
- package/dist/graph-users-Bhlw-_4i.js +1337 -0
- package/dist/health-9ifMvGZN.js +3 -0
- package/dist/health-CzOJa6SX.js +469 -0
- package/dist/heartbeat-runner-B2Tkbj5e.js +5 -0
- package/dist/heartbeat-runner-B63G8dbO.js +1292 -0
- package/dist/heartbeat-runner.runtime-QJ_2AMjN.js +4 -0
- package/dist/heartbeat-runner.runtime.js +1 -1
- package/dist/hooks-cli-ZWI1iJnh.js +433 -0
- package/dist/image-fallbacks-BpTfBvbi.js +2 -0
- package/dist/image-fallbacks-DpVwnB41.js +31 -0
- package/dist/inbound-reply-dispatch-mKybIcNA.js +73 -0
- package/dist/index.js +2 -2
- package/dist/infra-runtime-CvwvzUfM.js +39 -0
- package/dist/init-CWeM0DfJ.js +59 -0
- package/dist/library-ClQalZ3x.js +45 -0
- package/dist/lifecycle-CgV7Cgt-.js +571 -0
- package/dist/lifecycle-DVWaxj-A.js +229 -0
- package/dist/lifecycle.runtime-DErLwVJ_.js +2 -0
- package/dist/lifecycle.runtime.js +1 -1
- package/dist/list-5RIS3LMG.js +2 -0
- package/dist/list-BNesYDN2.js +2 -0
- package/dist/list-Dk1hCKis.js +1201 -0
- package/dist/list-eUjt_6__.js +131 -0
- package/dist/list.probe-C51ceJSY.js +419 -0
- package/dist/llm-slug-generator-D64IMUoy.js +79 -0
- package/dist/llm-slug-generator.js +1 -1
- package/dist/load-config-Ccss2uTi.js +35 -0
- package/dist/local-dispatch.runtime-u7Ir1N07.js +8 -0
- package/dist/local-dispatch.runtime.js +1 -1
- package/dist/logs-cli-BYHTboPa.js +265 -0
- package/dist/logs-cli.runtime-CQwNptr-.js +2 -0
- package/dist/logs-cli.runtime.js +1 -1
- package/dist/main-session-restart-recovery-CA9bvC1W.js +206 -0
- package/dist/managed-image-attachments-B_gpkI1u.js +635 -0
- package/dist/managed-image-attachments-C0Y6nAP2.js +2 -0
- package/dist/manager-DZGFArgz.js +2 -0
- package/dist/manager-Df8TC4rX.js +2057 -0
- package/dist/markdown-to-line-xXLdnzcE.js +790 -0
- package/dist/mcp/plugin-tools-serve.js +1 -1
- package/dist/mcp-cli-B50W9Pkc.js +725 -0
- package/dist/mcp-http-BiUGVpJ4.js +529 -0
- package/dist/memory-core-host-runtime-cli-UgLo6ezC.js +9 -0
- package/dist/message-C95gttLd.js +232 -0
- package/dist/message-action-runner-0KAp6ccG.js +1407 -0
- package/dist/message-action-runner-BSUDvECO.js +2 -0
- package/dist/message-actions-Be4Ob151.js +143 -0
- package/dist/message.gateway.runtime-DMMRMIln.js +2 -0
- package/dist/message.gateway.runtime.js +1 -1
- package/dist/models-auth-status-DhYxBz7G.js +201 -0
- package/dist/models-cli-C2prinXb.js +219 -0
- package/dist/monitor-BEI21vNQ.js +1661 -0
- package/dist/monitor-BUgTAJvZ.js +1237 -0
- package/dist/monitor-BdJRIhi1.js +2 -0
- package/dist/monitor-C7wuttQJ.js +1459 -0
- package/dist/monitor-DMumiWnt.js +788 -0
- package/dist/monitor-IQo2ExmV.js +671 -0
- package/dist/monitor-auth-DW0lvfm3.js +207 -0
- package/dist/monitor-processing-DTrsRdyz.js +1974 -0
- package/dist/monitor.runtime-DwqyCQcb.js +2 -0
- package/dist/monitor.runtime.js +1 -1
- package/dist/monitor.webhook-D11nrUh9.js +180 -0
- package/dist/msteams-DO-PW98M.js +35 -0
- package/dist/native-hook-relay-CNZrcPIw.js +519 -0
- package/dist/nextcloud-talk-BeYFnATY.js +17 -0
- package/dist/node-cli-BFrdTPdH.js +2506 -0
- package/dist/nodes-cli-B3Wj_MvP.js +1046 -0
- package/dist/nodes-utils-AsgrCa7K.js +84 -0
- package/dist/nodes.helpers-CMXxavTs.js +34 -0
- package/dist/notify-CNS0kRWM.js +315 -0
- package/dist/onboard-D4ehf66t.js +632 -0
- package/dist/onboard-helpers-DWxdMyCs.js +6 -0
- package/dist/onboard-helpers-o78s0lR1.js +204 -0
- package/dist/onboard-remote-Cc1XlRzr.js +193 -0
- package/dist/onboard-remote-D8THwo3P.js +2 -0
- package/dist/onboard-skills-B2VoCq7v.js +134 -0
- package/dist/onboard-skills-DtOgSJZo.js +2 -0
- package/dist/openai-http-DKQZWsqY.js +500 -0
- package/dist/openresponses-http-C4kol41X.js +1128 -0
- package/dist/operator-approvals-client-BoN_VmkB.js +68 -0
- package/dist/outbound.runtime-D-L8FN8E.js +2 -0
- package/dist/outbound.runtime.js +1 -1
- package/dist/pair-command-approve-DMeQ6uD4.js +44 -0
- package/dist/persistent-bindings.lifecycle-O-RnoTW4.js +2 -0
- package/dist/persistent-bindings.lifecycle-bptWQEFT.js +85 -0
- package/dist/pi-embedded-BM79sXqb.js +2905 -0
- package/dist/pi-embedded-BUDWcDt8.js +4 -0
- package/dist/pi-embedded.runtime-D53bCPOr.js +4 -0
- package/dist/pi-embedded.runtime.js +1 -1
- package/dist/pi-tool-definition-adapter-DdYQtumi.js +217 -0
- package/dist/pi-tools-ihbjTP0K.js +1057 -0
- package/dist/pi-tools.before-tool-call-DrEqr96j.js +433 -0
- package/dist/pi-tools.before-tool-call-VB9YEPOv.js +2 -0
- package/dist/plugin-DwNULpmw.js +12195 -0
- package/dist/plugin-enabled-DbO9GyRJ.js +140 -0
- package/dist/plugin-registration-Du6hgUkp.js +23 -0
- package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
- package/dist/plugin-sdk/acp-binding-runtime.js +1 -1
- package/dist/plugin-sdk/acp-runtime.js +2 -2
- package/dist/plugin-sdk/agent-harness-runtime.js +5 -5
- package/dist/plugin-sdk/agent-harness.js +6 -6
- package/dist/plugin-sdk/agent-runtime.js +2 -2
- package/dist/plugin-sdk/approval-gateway-runtime.js +2 -2
- package/dist/plugin-sdk/approval-handler-runtime.js +3 -3
- package/dist/plugin-sdk/approval-runtime.js +1 -1
- package/dist/plugin-sdk/browser-node-runtime.js +4 -4
- package/dist/plugin-sdk/browser-setup-tools.js +3 -3
- package/dist/plugin-sdk/browser-support.js +7 -7
- package/dist/plugin-sdk/channel-core.js +2 -2
- package/dist/plugin-sdk/channel-inbound.js +2 -2
- package/dist/plugin-sdk/command-auth.js +1 -1
- package/dist/plugin-sdk/command-status-runtime.js +1 -1
- package/dist/plugin-sdk/compat.js +1 -1
- package/dist/plugin-sdk/conversation-binding-runtime.js +1 -1
- package/dist/plugin-sdk/conversation-runtime.js +3 -3
- package/dist/plugin-sdk/core.js +2 -2
- package/dist/plugin-sdk/direct-dm.js +1 -1
- package/dist/plugin-sdk/gateway-runtime.js +3 -3
- package/dist/plugin-sdk/inbound-reply-dispatch.js +1 -1
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/infra-runtime.js +2 -2
- package/dist/plugin-sdk/irc.js +2 -2
- package/dist/plugin-sdk/matrix.js +1 -1
- package/dist/plugin-sdk/memory-core-host-runtime-cli.js +2 -2
- package/dist/plugin-sdk/memory-core.js +2 -2
- package/dist/plugin-sdk/msteams.js +2 -2
- package/dist/plugin-sdk/nextcloud-talk.js +2 -2
- package/dist/plugin-sdk/nostr.js +1 -1
- package/dist/plugin-sdk/reply-dispatch-runtime.js +1 -1
- package/dist/plugin-sdk/reply-runtime.js +4 -4
- package/dist/plugin-sdk/runtime-secret-resolution.js +1 -1
- package/dist/plugin-sdk/runtime.js +2 -2
- package/dist/plugin-sdk/session-visibility.js +1 -1
- package/dist/plugin-sdk/testing.js +4 -4
- package/dist/plugin-sdk/tlon.js +1 -1
- package/dist/plugin-sdk/zalo.js +1 -1
- package/dist/plugin-sdk/zalouser.js +1 -1
- package/dist/plugin-service-DcSnRF5x.js +2890 -0
- package/dist/plugins/runtime/index.js +1 -1
- package/dist/policy-uc224usV.js +328 -0
- package/dist/postinstall-inventory.json +407 -407
- package/dist/prepare.runtime-BPA6jMiM.js +815 -0
- package/dist/prepare.runtime.js +1 -1
- package/dist/probe-5ToseFjd.js +1443 -0
- package/dist/probe-BdCXAH_u.js +2 -0
- package/dist/probe-ByVoZEdq.js +45 -0
- package/dist/probe-D-D_1oc4.js +241 -0
- package/dist/probe-D6s_1Z5k.js +2 -0
- package/dist/probe-DIMAmSsO.js +74 -0
- package/dist/probe-DYuL-s4A.js +2205 -0
- package/dist/program-DDTWTh6g.js +111 -0
- package/dist/prompt-select-styled-kf1dPqNa.js +20 -0
- package/dist/protocol-Batc2DmY.js +2234 -0
- package/dist/provider-dispatcher-DdUqCa6H.js +2 -0
- package/dist/provider-dispatcher-uioW38XW.js +22 -0
- package/dist/qr-cli-B1WUe8Eb.js +2 -0
- package/dist/qr-cli-DmPti3xe.js +349 -0
- package/dist/reaction-runtime-api-5G3e9J0C.js +116 -0
- package/dist/reactions-x7VH-B95.js +998 -0
- package/dist/register-service-commands-DcW5qPTu.js +71 -0
- package/dist/register.agent-Dtj4HC7R.js +248 -0
- package/dist/register.configure-CJHb84Ce.js +15 -0
- package/dist/register.maintenance-BUkPfMcX.js +438 -0
- package/dist/register.message-DGFpyYBl.js +329 -0
- package/dist/register.onboard-D3v3xIfF.js +81 -0
- package/dist/register.runtime-DI4QxYdj.js +81 -0
- package/dist/register.runtime.js +1 -1
- package/dist/register.setup-CXTyuIFM.js +150 -0
- package/dist/register.status-health-sessions-CYUnRi97.js +1215 -0
- package/dist/register.subclis-DKMVrwRc.js +3 -0
- package/dist/register.subclis-NWRi2XKp.js +29 -0
- package/dist/register.subclis-core-De6qmQkr.js +243 -0
- package/dist/reply-dispatch-runtime-B8_j6pJi.js +13 -0
- package/dist/reply-runtime-DGHQDC9d.js +11 -0
- package/dist/reply.runtime-BCfqw2Co.js +2 -0
- package/dist/reply.runtime.js +1 -1
- package/dist/restart-health-6cjrRBpF.js +202 -0
- package/dist/restart-health-b6Qw43Tj.js +2 -0
- package/dist/root-help-BTIH_eUe.js +44 -0
- package/dist/routes-C3J2GfHR.js +3341 -0
- package/dist/routes-SMmfW6k8.js +2 -0
- package/dist/rpc-DQbAcIKu.js +61 -0
- package/dist/rpc.runtime-Q3qyofLf.js +21 -0
- package/dist/rpc.runtime.js +1 -1
- package/dist/run-delivery.runtime-BsLouK3f.js +530 -0
- package/dist/run-delivery.runtime.js +1 -1
- package/dist/run-embedded.runtime-CXd0oZQP.js +4 -0
- package/dist/run-embedded.runtime.js +1 -1
- package/dist/run-execution-cli.runtime-D-MKbq8r.js +4 -0
- package/dist/run-execution-cli.runtime.js +1 -1
- package/dist/run-executor.runtime-Cz0I8mDt.js +277 -0
- package/dist/run-executor.runtime.js +1 -1
- package/dist/run-main-CkXBTQut.js +516 -0
- package/dist/run-subagent-registry.runtime-Cyb8amrH.js +2 -0
- package/dist/run-subagent-registry.runtime.js +1 -1
- package/dist/run-wait-KlS0pdIK.js +135 -0
- package/dist/runtime-3niXLiFY.js +9 -0
- package/dist/runtime-api-B79e2jL2.js +4 -0
- package/dist/runtime-api-CM2c2bSC.js +9 -0
- package/dist/runtime-api-CnOFFN5q.js +14 -0
- package/dist/runtime-api-TnwM-EZH.js +9 -0
- package/dist/runtime-embedded-pi.runtime-9csGjukF.js +2 -0
- package/dist/runtime-embedded-pi.runtime.js +1 -1
- package/dist/runtime-internal-CQX4Zehn.js +2 -0
- package/dist/runtime-options-C0qP2VlT.js +275 -0
- package/dist/runtime-schema-DanWbDoL.js +27780 -0
- package/dist/runtime-vycfMfew.js +973 -0
- package/dist/scan-Bs5zROOQ.js +2 -0
- package/dist/scan-CP2zJb_w.js +523 -0
- package/dist/secrets-cli-YFTlIMmq.js +2101 -0
- package/dist/security-cli-B2WBRU9C.js +486 -0
- package/dist/selection-DSZGsU6m.js +2 -0
- package/dist/selection-hUGDnCgX.js +7736 -0
- package/dist/send-B3Ygb3r3.js +156 -0
- package/dist/send-DMwqnu6K.js +102 -0
- package/dist/send.runtime-D86atcfW.js +2 -0
- package/dist/send.runtime.js +1 -1
- package/dist/server-4gQCBM3M.js +77 -0
- package/dist/server-CK9eCPCG.js +13 -0
- package/dist/server-context-ih3GaGaI.js +847 -0
- package/dist/server-context-kZ_QADic.js +2 -0
- package/dist/server-node-events-CMlHOIKa.js +481 -0
- package/dist/server-plugin-bootstrap-B0XitldT.js +11333 -0
- package/dist/server-plugin-bootstrap-CHlVF8XB.js +2 -0
- package/dist/server-restart-sentinel-TpXCoiYX.js +697 -0
- package/dist/server.impl-B6at3Orl.js +12734 -0
- package/dist/session-kill-http-DvYp5h-j.js +110 -0
- package/dist/session-reset-service-C9rIVqF7.js +471 -0
- package/dist/session-route-FaMcEc7I.js +93 -0
- package/dist/session-status.runtime-BfPn8qA8.js +2 -0
- package/dist/session-status.runtime.js +1 -1
- package/dist/session-subagent-reactivation.runtime-C1fGNaiM.js +2 -0
- package/dist/session-subagent-reactivation.runtime.js +1 -1
- package/dist/session-tab-registry-BDK2AlxL.js +491 -0
- package/dist/session-visibility-BkrL2kFF.js +147 -0
- package/dist/sessions-helpers-YOu_5tl0.js +304 -0
- package/dist/sessions-history-http-DxNaoDfb.js +383 -0
- package/dist/sessions-patch-BPtlF0Lu.js +309 -0
- package/dist/sessions-resolve-B2rpvSka.js +174 -0
- package/dist/sessions.runtime-DEk_x65_.js +2 -0
- package/dist/sessions.runtime.js +1 -1
- package/dist/setup-DZJZF2R6.js +495 -0
- package/dist/setup-api-BkYWhB-B.js +29 -0
- package/dist/setup-core-BXBabSEx.js +171 -0
- package/dist/setup-core-eahC1DXh.js +176 -0
- package/dist/setup-surface-BEf8reey.js +286 -0
- package/dist/setup-surface-DAOKJ-ai.js +219 -0
- package/dist/setup-surface-b6gu0S8l.js +403 -0
- package/dist/setup.finalize-DXUCLT5O.js +539 -0
- package/dist/setup.gateway-config-BH4xbjcX.js +250 -0
- package/dist/shared-BhHdyXun.js +198 -0
- package/dist/shared-CKv38qsN.js +121 -0
- package/dist/shared-DUw9Q4Lf.js +76 -0
- package/dist/slash-state-BQgmhum1.js +1911 -0
- package/dist/src-C1B3uJMu.js +3974 -0
- package/dist/startup-context-DTpThe3H.js +312 -0
- package/dist/status-63GZxfe4.js +2 -0
- package/dist/status-C6qTe-QQ.js +397 -0
- package/dist/status-CSIGAUly.js +190 -0
- package/dist/status-DOW91Kcx.js +2 -0
- package/dist/status-all-7hqTcvxr.js +498 -0
- package/dist/status-json-CUzzv8An.js +14 -0
- package/dist/status-json-command-DwWlqvoV.js +84 -0
- package/dist/status-p4yx6E3C.js +209 -0
- package/dist/status-runtime-shared-yrzbsOR8.js +257 -0
- package/dist/status-subagents.runtime-CuRGoNNn.js +18 -0
- package/dist/status-subagents.runtime.js +1 -1
- package/dist/status-text-BrcRsCFE.js +237 -0
- package/dist/status-zV1BflCE.js +3 -0
- package/dist/status.gateway-connection.runtime-BKd4Zivg.js +2 -0
- package/dist/status.gateway-connection.runtime.js +1 -1
- package/dist/status.gather-B7WlHpIR.js +292 -0
- package/dist/status.gather-Ccewg4ce.js +2 -0
- package/dist/status.runtime-BFru2C4v.js +2 -0
- package/dist/status.runtime.js +1 -1
- package/dist/status.scan-mEKnAmP3.js +65 -0
- package/dist/status.scan-overview-B0qQVJd0.js +379 -0
- package/dist/status.scan.fast-json-CsU-fWhj.js +132 -0
- package/dist/status.scan.fast-json-tEc36TAC.js +2 -0
- package/dist/status.summary-Bvgry977.js +214 -0
- package/dist/status.summary-DRolowE_.js +2 -0
- package/dist/subagent-announce-Bhe55Ktf.js +351 -0
- package/dist/subagent-announce-delivery-NDBIRwuZ.js +726 -0
- package/dist/subagent-announce-output-DsmGO7Oi.js +364 -0
- package/dist/subagent-control-Bn8n-535.js +506 -0
- package/dist/subagent-followup.runtime-C7s-lOGN.js +68 -0
- package/dist/subagent-followup.runtime.js +1 -1
- package/dist/subagent-orphan-recovery-CJEhSvFZ.js +305 -0
- package/dist/subagent-registry-BgQA8eP1.js +1753 -0
- package/dist/subagent-registry-DAm-N9-O.js +3 -0
- package/dist/subagent-registry.runtime.js +1 -1
- package/dist/subagent-spawn-EXtecXVT.js +1005 -0
- package/dist/system-cli-CFS_PN8R.js +59 -0
- package/dist/targets-BXWH2MfM.js +67 -0
- package/dist/task-executor-DfugjJEq.js +360 -0
- package/dist/task-owner-access-CSwIy-v-.js +74 -0
- package/dist/task-registry-B-kQGKt_.js +2366 -0
- package/dist/task-registry-delivery-runtime-DD1_7xUF.js +3 -0
- package/dist/task-registry-delivery-runtime-DIsasFa1.js +2 -0
- package/dist/task-registry.maintenance-CxAx195T.js +2 -0
- package/dist/task-registry.maintenance-DIFuNnzy.js +416 -0
- package/dist/telegram/token.js +1 -1
- package/dist/testing-C7oUBiZL.js +575 -0
- package/dist/text-report-hYiQ_Kcv.js +587 -0
- package/dist/tool-resolution-CnnOHyxg.js +90 -0
- package/dist/tools-effective-inventory-DqYXIS6R.js +152 -0
- package/dist/tools-invoke-http-zop5qWa_.js +206 -0
- package/dist/trash-DZRlsk_R.js +24 -0
- package/dist/tui-cli-2cKXF0J8.js +4575 -0
- package/dist/update-cli-DP1KXasM.js +1759 -0
- package/dist/upgrade-DPFxH2YB.js +1226 -0
- package/dist/video-generation-task-status-BEgeadFu.js +163 -0
- package/dist/wait-for-idle-before-flush-CmSNfAco.js +5986 -0
- package/dist/wizard-models-BJGn0RnU.js +161 -0
- package/package.json +1 -1
- package/dist/abort-ca8hDmJr.js +0 -201
- package/dist/abort.runtime-BrChEuUS.js +0 -2
- package/dist/accounts-C1ECKXaw.js +0 -107
- package/dist/accounts-DH8HU_Fu.js +0 -104
- package/dist/accounts-DWQpG06j.js +0 -2
- package/dist/acp-cli-BLpWVnc7.js +0 -2193
- package/dist/acp-spawn-D1p6b1gk.js +0 -2
- package/dist/acp-spawn-qoyl9NiU.js +0 -1093
- package/dist/acp-stateful-target-driver-NL9txhIM.js +0 -89
- package/dist/action-agents-C729fJ_P.js +0 -67
- package/dist/action-focus-53k9XP4K.js +0 -132
- package/dist/action-help-bIJZBYLz.js +0 -7
- package/dist/action-info-BBzvYFX_.js +0 -101
- package/dist/action-kill-C4fa3E9I.js +0 -33
- package/dist/action-list-BEiIbwP1.js +0 -21
- package/dist/action-log-Cq7RLW2T.js +0 -30
- package/dist/action-send-DyiHgRwh.js +0 -39
- package/dist/action-spawn-CEZfDvXU.js +0 -47
- package/dist/action-unfocus-CpAw3JOi.js +0 -29
- package/dist/actions.runtime-BKEwPyo7.js +0 -18
- package/dist/actions.runtime-Bp0UusIf.js +0 -5
- package/dist/agent-C2hwJefQ.js +0 -2
- package/dist/agent-command-BAAeGRql.js +0 -874
- package/dist/agent-harness-runtime-Czrx53YL.js +0 -144
- package/dist/agent-runner-utils-DzShckNa.js +0 -239
- package/dist/agent-runner.runtime-d_EtNxBK.js +0 -3455
- package/dist/agent-runtime-DNgz7AOP.js +0 -18
- package/dist/agents-CZmpon7q.js +0 -5
- package/dist/agents-Cs9je_gQ.js +0 -953
- package/dist/aliases-CZemdpTj.js +0 -2
- package/dist/aliases-KefnmoaT.js +0 -96
- package/dist/api-CO05iXNH.js +0 -139
- package/dist/api-CyjlApHT.js +0 -3
- package/dist/api-DArm1ECd.js +0 -5
- package/dist/approval-gateway-resolver-URpDQMld.js +0 -29
- package/dist/approval-gateway-runtime-B087BMms.js +0 -2
- package/dist/approval-handler-runtime-BgRQnG4g.js +0 -439
- package/dist/approval-native-runtime-DAsraihr.js +0 -729
- package/dist/attempt-execution.runtime-D_FGkDQz.js +0 -509
- package/dist/attempt.prompt-helpers-CDzDUi1C.js +0 -221
- package/dist/attempt.tool-run-context-DitxaTPJ.js +0 -933
- package/dist/audit-Bq8vlxok.js +0 -939
- package/dist/audit.runtime-CU42yh1v.js +0 -7
- package/dist/auth-CQfwC-AH.js +0 -383
- package/dist/auth-DyWcaG4X.js +0 -2
- package/dist/auth-order-C3zGI0s9.js +0 -96
- package/dist/auth-order-XQ9ZGPd9.js +0 -2
- package/dist/bash-tools-BBRtIa6j.js +0 -2824
- package/dist/bash-tools-BI0d1TdC.js +0 -3
- package/dist/binding-routing-Cvm5c1IV.js +0 -85
- package/dist/binding-targets-DSs4NXbd.js +0 -121
- package/dist/bridge-server-CwWzSgv8.js +0 -113
- package/dist/browser-control-auth-y1f-9HRI.js +0 -2
- package/dist/browser-node-runtime-3UAeP8a6.js +0 -12
- package/dist/browser-profiles-BzzxphNW.js +0 -2
- package/dist/browser-runtime-jj11LR-E.js +0 -387
- package/dist/browser-setup-tools-CFB52yQc.js +0 -13
- package/dist/build-TlobwpQW.js +0 -550
- package/dist/call-Bx8lENb2.js +0 -3
- package/dist/call-jYRpeAWm.js +0 -331
- package/dist/call.runtime-BRluUZbD.js +0 -2
- package/dist/capability-cli-Iyj9Zi3g.js +0 -1401
- package/dist/catchup-CtxTwzY8.js +0 -300
- package/dist/channel-BJKHBfnq.js +0 -491
- package/dist/channel-BNNnYzwK.js +0 -1100
- package/dist/channel-BXS-Hd8p.js +0 -226
- package/dist/channel-C4XWpowe.js +0 -1174
- package/dist/channel-CJQdQgPr.js +0 -840
- package/dist/channel-C_zWAu4D.js +0 -595
- package/dist/channel-CtGzrF-K.js +0 -1802
- package/dist/channel-O9DE4IIq.js +0 -350
- package/dist/channel-WHUOtJme.js +0 -297
- package/dist/channel-WoDWDxqx.js +0 -1320
- package/dist/channel-core-BJjq9SOq.js +0 -5
- package/dist/channel-inbound-DLs-YfUs.js +0 -31
- package/dist/channel-plugin-runtime-CMG8ac2K.js +0 -771
- package/dist/channel-runtime-4UjeDmDI.js +0 -425
- package/dist/channel-ys2FFqi1.js +0 -453
- package/dist/channel.runtime-B38Ky3R9.js +0 -109
- package/dist/channel.runtime-Bl8WYZvF.js +0 -576
- package/dist/channel.runtime-D3kAsCsR.js +0 -89
- package/dist/channel.runtime-DEQ-anMf.js +0 -2364
- package/dist/channel.runtime-DG-EUnSC.js +0 -4
- package/dist/channel.runtime-IfV1Md6p.js +0 -430
- package/dist/channel.runtime-w1tHjTOa.js +0 -34702
- package/dist/channel.setup-dXwiMlyi.js +0 -10
- package/dist/channels-B2G1Y-iD.js +0 -733
- package/dist/channels-cli-YintLKAt.js +0 -268
- package/dist/chat-DdKbu8CA.js +0 -2758
- package/dist/clawbot-cli-CnHERFYk.js +0 -9
- package/dist/cli-CSNAd6Sz.js +0 -72
- package/dist/cli-CdRioBfN.js +0 -2
- package/dist/cli-DMPwqYqc.js +0 -219
- package/dist/cli-ctyAqh0j.js +0 -2
- package/dist/cli-runner-CNlk7xmx.js +0 -286
- package/dist/cli-runner.runtime-BK4sQk1m.js +0 -3
- package/dist/cli-runner.runtime-BT8ZZn-R.js +0 -4
- package/dist/cli.runtime-DU7swpBI.js +0 -1261
- package/dist/client-CQdcTPUf.js +0 -138
- package/dist/client-Vx7pseEY.js +0 -713
- package/dist/command-auth-DkJWb2HE.js +0 -76
- package/dist/command-config-resolution-CIRWRfR8.js +0 -23
- package/dist/command-config-resolution-DYZWj6Zm.js +0 -2
- package/dist/command-config-resolution.runtime-CUtVJOf0.js +0 -2
- package/dist/command-registry-CHy5EH0v.js +0 -4
- package/dist/command-registry-CyKgELQP.js +0 -9
- package/dist/command-registry-core-DQeRIuot.js +0 -104
- package/dist/command-secret-gateway-BNnWdAlq.js +0 -528
- package/dist/command-status.runtime-CKgimR6Y.js +0 -87
- package/dist/commands-acp-DSm97O5v.js +0 -77
- package/dist/commands-compact.runtime-BXhP6WJ6.js +0 -10
- package/dist/commands-handlers.runtime-FzK-n0L8.js +0 -4597
- package/dist/commands-status-BQnB5OSX.js +0 -16
- package/dist/commands-status.runtime-B6GcfEDm.js +0 -3
- package/dist/commands-subagents-control.runtime-CByd528A.js +0 -2
- package/dist/commands-subagents-control.runtime-CqI4LMYa.js +0 -3
- package/dist/commands-system-prompt-BD_LeeZk.js +0 -2
- package/dist/commands-system-prompt-C2Md_Ia1.js +0 -158
- package/dist/commands.runtime-CwiPf7Cc.js +0 -166
- package/dist/compact-B_4bMVpw.js +0 -1118
- package/dist/compact.runtime-BhRqiBXG.js +0 -12
- package/dist/completion-cli-D07hGGMI.js +0 -313
- package/dist/config-B1lvYOd7.js +0 -251
- package/dist/config-cli-BgepNwob.js +0 -1078
- package/dist/configure-CEfl0ORM.js +0 -2
- package/dist/configure-TsykzQqM.js +0 -1245
- package/dist/connect-options-zqTIEl6K.js +0 -699
- package/dist/control-auth-CNa_KHpo.js +0 -125
- package/dist/control-service-CZl5wFdZ.js +0 -156
- package/dist/conversation-id-BLY9ffjm.js +0 -38
- package/dist/conversation-id-DVeOM5Jh.js +0 -235
- package/dist/conversation-runtime-gJt7AAg2.js +0 -31
- package/dist/core-BtmNtOpS.js +0 -275
- package/dist/cron-cli-s9SF4__G.js +0 -713
- package/dist/daemon-cli-TCubZfI_.js +0 -12
- package/dist/delegate-DyITI93V.js +0 -64
- package/dist/detached-task-runtime-CTUQj84i.js +0 -73
- package/dist/devices-cli-SXcLjGmh.js +0 -496
- package/dist/diagnostics-waSemGnZ.js +0 -154
- package/dist/direct-dm-CiSjkmkL.js +0 -64
- package/dist/dispatch-BnQSIx2G.js +0 -1131
- package/dist/dispatch-acp-CaNQyl2L.js +0 -981
- package/dist/dispatch-acp-manager.runtime-DJK1eHYX.js +0 -3
- package/dist/dispatch-acp.runtime-Bl5cvtX4.js +0 -19
- package/dist/doctor-device-pairing-DBhEA-8G.js +0 -307
- package/dist/doctor-gateway-daemon-flow-Ds47Er3Y.js +0 -250
- package/dist/doctor-gateway-health-EWwTw5JR.js +0 -60
- package/dist/doctor-health-C6muRn7t.js +0 -59
- package/dist/doctor-health-contributions-B984415a.js +0 -486
- package/dist/doctor-prompter-BpOi4ndi.js +0 -56
- package/dist/doctor-workspace-status-CiEWZXrx.js +0 -75
- package/dist/dreaming-DFPenC85.js +0 -1574
- package/dist/dreaming-narrative-6A27_Gft.js +0 -595
- package/dist/embedded-gateway-stub.runtime-UVgfXZzk.js +0 -9
- package/dist/exec-approvals-cli-Cc_GG9ZT.js +0 -498
- package/dist/fallbacks-DX4YcmAx.js +0 -2
- package/dist/fallbacks-inTaaG-m.js +0 -31
- package/dist/fallbacks-shared-ow1la-U2.js +0 -111
- package/dist/gateway-D4iWwu3_.js +0 -115
- package/dist/gateway-cli-D6j0Aj3R.js +0 -1325
- package/dist/gateway-rpc-Dd_x2GX5.js +0 -14
- package/dist/gateway-rpc.runtime-Btnvsv-7.js +0 -23
- package/dist/gateway-runtime-DctMRv_p.js +0 -15
- package/dist/gateway-status-DJCtvUVn.js +0 -584
- package/dist/genesis-tools-CvMcpUvH.js +0 -8999
- package/dist/genesis-tools.runtime-Ch3NDEDq.js +0 -2
- package/dist/get-reply-Cm39MCyU.js +0 -3879
- package/dist/get-reply-from-config.runtime-CSqCYatb.js +0 -2
- package/dist/graph-users-BJxYqA3A.js +0 -1337
- package/dist/health-C14jIilQ.js +0 -469
- package/dist/health-C6yJSCMc.js +0 -3
- package/dist/heartbeat-runner-C6-gFnyC.js +0 -5
- package/dist/heartbeat-runner-yUYjgzIM.js +0 -1292
- package/dist/heartbeat-runner.runtime-DZzyrUNB.js +0 -4
- package/dist/hooks-cli-CCRaHheu.js +0 -433
- package/dist/image-fallbacks-BH9qLbBG.js +0 -31
- package/dist/image-fallbacks-DUOPO1ic.js +0 -2
- package/dist/inbound-reply-dispatch-DPf_IrbV.js +0 -73
- package/dist/infra-runtime-CLND6LJ0.js +0 -39
- package/dist/init-CzWob-9v.js +0 -59
- package/dist/library-C0a9Bz2M.js +0 -45
- package/dist/lifecycle-B_B_jt3r.js +0 -571
- package/dist/lifecycle-DuqKKZop.js +0 -229
- package/dist/lifecycle.runtime-DoosWTnK.js +0 -2
- package/dist/list-Bly8XeOF.js +0 -2
- package/dist/list-C5HvtbwZ.js +0 -2
- package/dist/list-CHIiamt1.js +0 -131
- package/dist/list-CMmJiacX.js +0 -1201
- package/dist/list.probe-kmHRFlrP.js +0 -419
- package/dist/llm-slug-generator-C3u6Ptgq.js +0 -79
- package/dist/load-config-CXvIGI7N.js +0 -35
- package/dist/local-dispatch.runtime-BNQF4rqW.js +0 -8
- package/dist/logs-cli-DEy1GPk2.js +0 -265
- package/dist/logs-cli.runtime-jWShKzQC.js +0 -2
- package/dist/main-session-restart-recovery-CzfY6Cd8.js +0 -206
- package/dist/managed-image-attachments-BGPKA7Mn.js +0 -2
- package/dist/managed-image-attachments-CTrq9ym-.js +0 -635
- package/dist/manager-C_ZGa9x8.js +0 -2057
- package/dist/manager-DIHLRzYF.js +0 -2
- package/dist/markdown-to-line-CRbbXtJK.js +0 -790
- package/dist/mcp-cli-FMJb3T4k.js +0 -725
- package/dist/mcp-http-b6UMoE_J.js +0 -529
- package/dist/memory-core-host-runtime-cli-CquxELNj.js +0 -9
- package/dist/message-CmjuvIFf.js +0 -232
- package/dist/message-action-runner-CiY3rhqt.js +0 -1407
- package/dist/message-action-runner-Do4P0h5i.js +0 -2
- package/dist/message-actions-BYREqFJA.js +0 -143
- package/dist/message.gateway.runtime-gkoWzaYV.js +0 -2
- package/dist/models-auth-status-B_Pcr0tl.js +0 -201
- package/dist/models-cli-BZSuW2gw.js +0 -219
- package/dist/monitor-22LY8y6z.js +0 -788
- package/dist/monitor-BZdf_CEm.js +0 -1237
- package/dist/monitor-CTVDlTs2.js +0 -671
- package/dist/monitor-Cfv-KGAl.js +0 -1661
- package/dist/monitor-DuA69-8E.js +0 -2
- package/dist/monitor-auth-BNDlfcw7.js +0 -207
- package/dist/monitor-cmWeDVxf.js +0 -1459
- package/dist/monitor-processing-D9Xcsagt.js +0 -1974
- package/dist/monitor.runtime-zWvcbNim.js +0 -2
- package/dist/monitor.webhook-BYWQa5lY.js +0 -180
- package/dist/msteams-n9HDT4O-.js +0 -35
- package/dist/native-hook-relay-CKyIfLOm.js +0 -519
- package/dist/nextcloud-talk-BuJVVP0J.js +0 -17
- package/dist/node-cli-DBK2TIEH.js +0 -2506
- package/dist/nodes-cli-D5Y1_ZVD.js +0 -1046
- package/dist/nodes-utils-C6IKaTjm.js +0 -84
- package/dist/nodes.helpers-CkJO5i0d.js +0 -34
- package/dist/notify-v0zoiI-O.js +0 -315
- package/dist/onboard-BCaLBJor.js +0 -632
- package/dist/onboard-helpers-Ba7ES7kB.js +0 -204
- package/dist/onboard-helpers-D5qdyBIj.js +0 -6
- package/dist/onboard-remote-BaHm_VrY.js +0 -2
- package/dist/onboard-remote-DbGAo_Ad.js +0 -193
- package/dist/onboard-skills-BA7c4li1.js +0 -2
- package/dist/onboard-skills-upyHp6T9.js +0 -134
- package/dist/openai-http-DwCqhEcX.js +0 -500
- package/dist/openresponses-http-tJr67vC1.js +0 -1128
- package/dist/operator-approvals-client-C0t_-2xC.js +0 -68
- package/dist/outbound.runtime-nXA4k1xA.js +0 -2
- package/dist/pair-command-approve-G5y-rKn9.js +0 -44
- package/dist/persistent-bindings.lifecycle-C56aKBVc.js +0 -2
- package/dist/persistent-bindings.lifecycle-CfBqvz9L.js +0 -85
- package/dist/pi-embedded-B1wvxHXL.js +0 -2905
- package/dist/pi-embedded-DmDb-oUB.js +0 -4
- package/dist/pi-embedded.runtime-D5xqw9Ko.js +0 -4
- package/dist/pi-tool-definition-adapter-CAxlo-Va.js +0 -217
- package/dist/pi-tools-C69yvznf.js +0 -1057
- package/dist/pi-tools.before-tool-call-BDeCmoAy.js +0 -2
- package/dist/pi-tools.before-tool-call-DG7VVNBn.js +0 -433
- package/dist/plugin-B9Ld0CUs.js +0 -12195
- package/dist/plugin-enabled-BguUplCN.js +0 -140
- package/dist/plugin-registration-DPBnSoak.js +0 -23
- package/dist/plugin-service-CdNFnRyN.js +0 -2890
- package/dist/policy-DgfegT_Y.js +0 -328
- package/dist/prepare.runtime-C_sRmuFC.js +0 -815
- package/dist/probe-8vb_Ssot.js +0 -45
- package/dist/probe-BjmKFiz1.js +0 -2205
- package/dist/probe-CVlOo8Hr.js +0 -74
- package/dist/probe-CakOsrSu.js +0 -241
- package/dist/probe-CbOoVumf.js +0 -2
- package/dist/probe-D6yFcZpK.js +0 -1443
- package/dist/probe-OcOYm1bj.js +0 -2
- package/dist/program-BJnTb7UE.js +0 -111
- package/dist/prompt-select-styled-C8kGHNpY.js +0 -20
- package/dist/protocol-C40iRm9c.js +0 -2234
- package/dist/provider-dispatcher-BIOPYzb9.js +0 -2
- package/dist/provider-dispatcher-CpwviX0O.js +0 -22
- package/dist/qr-cli-CJXKCj0L.js +0 -2
- package/dist/qr-cli-kSU9X-N0.js +0 -349
- package/dist/reaction-runtime-api-3XFmruJA.js +0 -116
- package/dist/reactions-By-nqZC6.js +0 -998
- package/dist/register-service-commands-fwB-T6mW.js +0 -71
- package/dist/register.agent-CpScU3CV.js +0 -248
- package/dist/register.configure-DpD3_BCK.js +0 -15
- package/dist/register.maintenance-ByoQXpk9.js +0 -438
- package/dist/register.message-BTXNOZMD.js +0 -329
- package/dist/register.onboard-B83CAOYy.js +0 -81
- package/dist/register.runtime-Doz01zcH.js +0 -81
- package/dist/register.setup-BKI5rwWy.js +0 -150
- package/dist/register.status-health-sessions-DRPszDQ-.js +0 -1215
- package/dist/register.subclis-DeXklyQL.js +0 -3
- package/dist/register.subclis-YkmoZoxl.js +0 -29
- package/dist/register.subclis-core-BPo4hV1Q.js +0 -243
- package/dist/reply-dispatch-runtime-DjIuN_dr.js +0 -13
- package/dist/reply-runtime-5TFidLR3.js +0 -11
- package/dist/reply.runtime-6d1e0INl.js +0 -2
- package/dist/restart-health-BWUPc4R-.js +0 -202
- package/dist/restart-health-CWvsjHVN.js +0 -2
- package/dist/root-help-D2YiFpS6.js +0 -44
- package/dist/routes-BdYdVpe7.js +0 -3341
- package/dist/routes-jYoN_qOU.js +0 -2
- package/dist/rpc-5tMjebZH.js +0 -61
- package/dist/rpc.runtime-BzAHjcm4.js +0 -21
- package/dist/run-delivery.runtime-qZIB76oE.js +0 -530
- package/dist/run-embedded.runtime-nHunVmCv.js +0 -4
- package/dist/run-execution-cli.runtime-CMT7La6D.js +0 -4
- package/dist/run-executor.runtime-BG6SDi3f.js +0 -277
- package/dist/run-main-CNf_LLX7.js +0 -516
- package/dist/run-subagent-registry.runtime-D0RcqcJr.js +0 -2
- package/dist/run-wait--kou3jZ7.js +0 -135
- package/dist/runtime-BvxkGJm2.js +0 -9
- package/dist/runtime-DgQ5oUKq.js +0 -973
- package/dist/runtime-api-6SzMK-FZ.js +0 -4
- package/dist/runtime-api-BAMrcB-5.js +0 -9
- package/dist/runtime-api-DLSrxS5O.js +0 -9
- package/dist/runtime-api-DsPleWQg.js +0 -14
- package/dist/runtime-embedded-pi.runtime-eyjaJfAz.js +0 -2
- package/dist/runtime-internal-BTfGDlHi.js +0 -2
- package/dist/runtime-options-B5_eZxMV.js +0 -275
- package/dist/runtime-schema-BB3QzGXJ.js +0 -27780
- package/dist/scan-D0fsxqed.js +0 -2
- package/dist/scan-DrjjN66Z.js +0 -523
- package/dist/secrets-cli-B7-qbfn-.js +0 -2101
- package/dist/security-cli-CYTPgL67.js +0 -486
- package/dist/selection-DEAdLh1Q.js +0 -2
- package/dist/selection-zPPyzfBX.js +0 -7736
- package/dist/send-CYKfZTCJ.js +0 -156
- package/dist/send-Di1tRwJD.js +0 -102
- package/dist/send.runtime-Bw22DBkL.js +0 -2
- package/dist/server-BIF5dPI_.js +0 -13
- package/dist/server-BJK0Q4xw.js +0 -77
- package/dist/server-context-CiVVCQNp.js +0 -847
- package/dist/server-context-DXvk5Tdy.js +0 -2
- package/dist/server-node-events-CdZP3Kok.js +0 -481
- package/dist/server-plugin-bootstrap-Di15EOt4.js +0 -11333
- package/dist/server-plugin-bootstrap-dboO44LL.js +0 -2
- package/dist/server-restart-sentinel-BWiOzljY.js +0 -697
- package/dist/server.impl-Ph8YCQpT.js +0 -12734
- package/dist/session-kill-http-B_J1fJ4-.js +0 -110
- package/dist/session-reset-service-DPgw70iw.js +0 -471
- package/dist/session-route-B0h6MEyB.js +0 -93
- package/dist/session-status.runtime-DCvgI1pG.js +0 -2
- package/dist/session-subagent-reactivation.runtime-BgsCnI-h.js +0 -2
- package/dist/session-tab-registry-FyN6CWh5.js +0 -491
- package/dist/session-visibility-CZjMA1SL.js +0 -147
- package/dist/sessions-helpers-B3W7MdIb.js +0 -304
- package/dist/sessions-history-http-Bw5J6HQ-.js +0 -383
- package/dist/sessions-patch-2sBcHc9a.js +0 -309
- package/dist/sessions-resolve-C-VZh_56.js +0 -174
- package/dist/sessions.runtime-cLuc67tJ.js +0 -2
- package/dist/setup-FW8xH-S-.js +0 -495
- package/dist/setup-api-Culp0Usf.js +0 -29
- package/dist/setup-core-CaTBS6Tz.js +0 -171
- package/dist/setup-core-youmXvW_.js +0 -176
- package/dist/setup-surface-BeMn-9hU.js +0 -403
- package/dist/setup-surface-CUd-s0wh.js +0 -286
- package/dist/setup-surface-DtscjAY3.js +0 -219
- package/dist/setup.finalize-BWyA4f4q.js +0 -539
- package/dist/setup.gateway-config-CvzMdftA.js +0 -250
- package/dist/shared-B3Pz1Xcr.js +0 -121
- package/dist/shared-Bc3x3THS.js +0 -76
- package/dist/shared-CxbLx0Ww.js +0 -198
- package/dist/slash-state-XfeMEeuI.js +0 -1911
- package/dist/src-BiDxQvtV.js +0 -3974
- package/dist/startup-context-CXQi-7YB.js +0 -312
- package/dist/status-Ch3bm70K.js +0 -2
- package/dist/status-CiQSxvY-.js +0 -3
- package/dist/status-DY0DlWlw.js +0 -190
- package/dist/status-DjdByQv-.js +0 -209
- package/dist/status-MT62_Jgw.js +0 -2
- package/dist/status-all-BD2viQD9.js +0 -498
- package/dist/status-json-CWS2oYON.js +0 -14
- package/dist/status-json-command-B6lZefoe.js +0 -84
- package/dist/status-pujDHwRb.js +0 -397
- package/dist/status-runtime-shared-Bu9Zhd7x.js +0 -257
- package/dist/status-subagents.runtime-B4UXD0lL.js +0 -18
- package/dist/status-text-myqmk4OL.js +0 -237
- package/dist/status.gateway-connection.runtime-B0Iwl2iZ.js +0 -2
- package/dist/status.gather-C51Ja0wP.js +0 -292
- package/dist/status.gather-DQ7WZp3H.js +0 -2
- package/dist/status.runtime-Cxyb3wHZ.js +0 -2
- package/dist/status.scan-C1aqDsy2.js +0 -65
- package/dist/status.scan-overview-BerlJz2l.js +0 -379
- package/dist/status.scan.fast-json-BXY82vu2.js +0 -2
- package/dist/status.scan.fast-json-DJqgEbzZ.js +0 -132
- package/dist/status.summary-CCdLUph8.js +0 -214
- package/dist/status.summary-CHAn0_FS.js +0 -2
- package/dist/subagent-announce-D4jG75Ub.js +0 -351
- package/dist/subagent-announce-delivery-BkQYzDcy.js +0 -726
- package/dist/subagent-announce-output-C3pkuu-t.js +0 -364
- package/dist/subagent-control-DVVK8du2.js +0 -506
- package/dist/subagent-followup.runtime-CdeweG-S.js +0 -68
- package/dist/subagent-orphan-recovery-ZQanOHb4.js +0 -305
- package/dist/subagent-registry-BcPa3ho0.js +0 -3
- package/dist/subagent-registry-hJUso5eL.js +0 -1753
- package/dist/subagent-spawn-DTaeQc9q.js +0 -1005
- package/dist/system-cli-CT8VaSDY.js +0 -59
- package/dist/targets-BPdSjnQH.js +0 -67
- package/dist/task-executor-B62Qzfi-.js +0 -360
- package/dist/task-owner-access-BBMrMOlN.js +0 -74
- package/dist/task-registry-BD-ew2bT.js +0 -2366
- package/dist/task-registry-delivery-runtime-B2WyGY0d.js +0 -3
- package/dist/task-registry-delivery-runtime-MFJszOHI.js +0 -2
- package/dist/task-registry.maintenance-0D2Yxl49.js +0 -416
- package/dist/task-registry.maintenance-OPlfB5W9.js +0 -2
- package/dist/testing-DmxZ16UC.js +0 -575
- package/dist/text-report-BwIpU54R.js +0 -587
- package/dist/tool-resolution-vn72hwMo.js +0 -90
- package/dist/tools-effective-inventory-DII_pOSr.js +0 -152
- package/dist/tools-invoke-http-DdthGR52.js +0 -206
- package/dist/trash-BVZu6rU7.js +0 -24
- package/dist/tui-cli-Bz51WCAi.js +0 -4575
- package/dist/update-cli-DkH8vHQP.js +0 -1759
- package/dist/upgrade-Dvj8K4WB.js +0 -1226
- package/dist/video-generation-task-status-CHYB_IeZ.js +0 -163
- package/dist/wait-for-idle-before-flush-DJMxeE2X.js +0 -5986
- package/dist/wizard-models-BNQQ7fvr.js +0 -161
|
@@ -0,0 +1,2366 @@
|
|
|
1
|
+
import { i as formatErrorMessage } from "./errors-Jbvi20TW.js";
|
|
2
|
+
import { c as normalizeOptionalString } from "./string-coerce-C1IzJjqi.js";
|
|
3
|
+
import { t as createSubsystemLogger } from "./subsystem-DTMy5YmO.js";
|
|
4
|
+
import { _ as resolveStateDir } from "./paths-DmR9mjUX.js";
|
|
5
|
+
import { o as parseAgentSessionKey } from "./session-key-utils-BT0y7mVK.js";
|
|
6
|
+
import { s as isDeliverableMessageChannel } from "./message-channel-BbI8d0sw.js";
|
|
7
|
+
import { i as normalizeDeliveryContext } from "./delivery-context.shared-Bddxu9DN.js";
|
|
8
|
+
import { l as onAgentEvent } from "./agent-events-CrZzR8Z1.js";
|
|
9
|
+
import { t as requireNodeSqlite } from "./node-sqlite-La-FqsVK.js";
|
|
10
|
+
import { n as requestHeartbeatNow } from "./heartbeat-wake-CrIAzATu.js";
|
|
11
|
+
import { i as enqueueSystemEvent } from "./system-events-CXxVc5Du.js";
|
|
12
|
+
import { a as sanitizeTaskStatusText, i as formatTaskStatusTitleText } from "./task-status-LIWTrTqj.js";
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
import { chmodSync, existsSync, mkdirSync } from "node:fs";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import os from "node:os";
|
|
17
|
+
import crypto from "node:crypto";
|
|
18
|
+
import { isMainThread, threadId } from "node:worker_threads";
|
|
19
|
+
//#region src/tasks/task-executor-policy.ts
|
|
20
|
+
function isTerminalTaskStatus(status) {
|
|
21
|
+
return status === "succeeded" || status === "failed" || status === "timed_out" || status === "cancelled" || status === "lost";
|
|
22
|
+
}
|
|
23
|
+
function resolveTaskDisplayTitle(task) {
|
|
24
|
+
return formatTaskStatusTitleText(task.label?.trim() || (task.runtime === "acp" ? "ACP background task" : task.runtime === "subagent" ? "Subagent task" : task.task.trim() || "Background task"));
|
|
25
|
+
}
|
|
26
|
+
function resolveTaskRunLabel(task) {
|
|
27
|
+
return task.runId ? ` (run ${task.runId.slice(0, 8)})` : "";
|
|
28
|
+
}
|
|
29
|
+
function formatTaskTerminalMessage(task) {
|
|
30
|
+
const title = resolveTaskDisplayTitle(task);
|
|
31
|
+
const runLabel = resolveTaskRunLabel(task);
|
|
32
|
+
const summary = sanitizeTaskStatusText(task.terminalSummary, { errorContext: task.status !== "succeeded" || task.terminalOutcome === "blocked" });
|
|
33
|
+
if (task.status === "succeeded") {
|
|
34
|
+
if (task.terminalOutcome === "blocked") return summary ? `Background task blocked: ${title}${runLabel}. ${summary}` : `Background task blocked: ${title}${runLabel}.`;
|
|
35
|
+
return summary ? `Background task done: ${title}${runLabel}. ${summary}` : `Background task done: ${title}${runLabel}.`;
|
|
36
|
+
}
|
|
37
|
+
if (task.status === "timed_out") return `Background task timed out: ${title}${runLabel}.`;
|
|
38
|
+
if (task.status === "lost") {
|
|
39
|
+
const error = sanitizeTaskStatusText(task.error, { errorContext: true });
|
|
40
|
+
const fallbackSummary = sanitizeTaskStatusText(task.terminalSummary, { errorContext: true });
|
|
41
|
+
return `Background task lost: ${title}${runLabel}. ${error || fallbackSummary || "Backing session disappeared."}`;
|
|
42
|
+
}
|
|
43
|
+
if (task.status === "cancelled") return `Background task cancelled: ${title}${runLabel}.`;
|
|
44
|
+
const error = sanitizeTaskStatusText(task.error, { errorContext: true });
|
|
45
|
+
const fallbackSummary = sanitizeTaskStatusText(task.terminalSummary, { errorContext: true });
|
|
46
|
+
return error ? `Background task failed: ${title}${runLabel}. ${error}` : fallbackSummary ? `Background task failed: ${title}${runLabel}. ${fallbackSummary}` : `Background task failed: ${title}${runLabel}.`;
|
|
47
|
+
}
|
|
48
|
+
function formatTaskBlockedFollowupMessage(task) {
|
|
49
|
+
if (task.status !== "succeeded" || task.terminalOutcome !== "blocked") return null;
|
|
50
|
+
return `Task needs follow-up: ${resolveTaskDisplayTitle(task)}${resolveTaskRunLabel(task)}. ${sanitizeTaskStatusText(task.terminalSummary, { errorContext: true }) || "Task is blocked and needs follow-up."}`;
|
|
51
|
+
}
|
|
52
|
+
function formatTaskStateChangeMessage(task, event) {
|
|
53
|
+
const title = resolveTaskDisplayTitle(task);
|
|
54
|
+
if (event.kind === "running") return `Background task started: ${title}.`;
|
|
55
|
+
if (event.kind === "progress") {
|
|
56
|
+
const summary = sanitizeTaskStatusText(event.summary);
|
|
57
|
+
return summary ? `Background task update: ${title}. ${summary}` : null;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
function shouldAutoDeliverTaskTerminalUpdate(task) {
|
|
62
|
+
if (task.notifyPolicy === "silent") return false;
|
|
63
|
+
if (task.runtime === "subagent" && task.status !== "cancelled") return false;
|
|
64
|
+
if (!isTerminalTaskStatus(task.status)) return false;
|
|
65
|
+
return task.deliveryStatus === "pending";
|
|
66
|
+
}
|
|
67
|
+
function shouldAutoDeliverTaskStateChange(task) {
|
|
68
|
+
return task.notifyPolicy === "state_changes" && task.deliveryStatus === "pending" && !isTerminalTaskStatus(task.status);
|
|
69
|
+
}
|
|
70
|
+
function shouldSuppressDuplicateTerminalDelivery(params) {
|
|
71
|
+
if (params.task.runtime !== "acp" || !params.task.runId?.trim()) return false;
|
|
72
|
+
return Boolean(params.preferredTaskId && params.preferredTaskId !== params.task.taskId);
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/tasks/task-registry.paths.ts
|
|
76
|
+
function resolveTaskStateDir(env = process.env) {
|
|
77
|
+
if (env.GENESIS_STATE_DIR?.trim()) return resolveStateDir(env);
|
|
78
|
+
if (env.VITEST || env.NODE_ENV === "test") {
|
|
79
|
+
const workerIdRaw = env.VITEST_WORKER_ID ?? env.VITEST_POOL_ID ?? "";
|
|
80
|
+
const workerId = Number.parseInt(workerIdRaw, 10);
|
|
81
|
+
const shardSuffix = Number.isFinite(workerId) ? `${process.pid}-${workerId}` : isMainThread ? String(process.pid) : `${process.pid}-${threadId}`;
|
|
82
|
+
return path.join(os.tmpdir(), "genesis-test-state", shardSuffix);
|
|
83
|
+
}
|
|
84
|
+
return resolveStateDir(env);
|
|
85
|
+
}
|
|
86
|
+
function resolveTaskRegistryDir(env = process.env) {
|
|
87
|
+
return path.join(resolveTaskStateDir(env), "tasks");
|
|
88
|
+
}
|
|
89
|
+
function resolveTaskRegistrySqlitePath(env = process.env) {
|
|
90
|
+
return path.join(resolveTaskRegistryDir(env), "runs.sqlite");
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/tasks/task-flow-registry.paths.ts
|
|
94
|
+
function resolveTaskFlowRegistryDir(env = process.env) {
|
|
95
|
+
return path.join(resolveTaskStateDir(env), "flows");
|
|
96
|
+
}
|
|
97
|
+
function resolveTaskFlowRegistrySqlitePath(env = process.env) {
|
|
98
|
+
return path.join(resolveTaskFlowRegistryDir(env), "registry.sqlite");
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/tasks/task-flow-registry.store.sqlite.ts
|
|
102
|
+
let cachedDatabase$1 = null;
|
|
103
|
+
const FLOW_REGISTRY_DIR_MODE = 448;
|
|
104
|
+
const FLOW_REGISTRY_FILE_MODE = 384;
|
|
105
|
+
const FLOW_REGISTRY_SIDECAR_SUFFIXES = [
|
|
106
|
+
"",
|
|
107
|
+
"-shm",
|
|
108
|
+
"-wal"
|
|
109
|
+
];
|
|
110
|
+
function normalizeNumber$1(value) {
|
|
111
|
+
if (typeof value === "bigint") return Number(value);
|
|
112
|
+
return typeof value === "number" ? value : void 0;
|
|
113
|
+
}
|
|
114
|
+
function serializeJson$1(value) {
|
|
115
|
+
return value === void 0 ? null : JSON.stringify(value);
|
|
116
|
+
}
|
|
117
|
+
function parseJsonValue$1(raw) {
|
|
118
|
+
if (!raw?.trim()) return;
|
|
119
|
+
try {
|
|
120
|
+
return JSON.parse(raw);
|
|
121
|
+
} catch {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function rowToSyncMode(row) {
|
|
126
|
+
if (row.sync_mode === "task_mirrored" || row.sync_mode === "managed") return row.sync_mode;
|
|
127
|
+
return row.shape === "single_task" ? "task_mirrored" : "managed";
|
|
128
|
+
}
|
|
129
|
+
function rowToFlowRecord(row) {
|
|
130
|
+
const endedAt = normalizeNumber$1(row.ended_at);
|
|
131
|
+
const cancelRequestedAt = normalizeNumber$1(row.cancel_requested_at);
|
|
132
|
+
const requesterOrigin = parseJsonValue$1(row.requester_origin_json);
|
|
133
|
+
const stateJson = parseJsonValue$1(row.state_json);
|
|
134
|
+
const waitJson = parseJsonValue$1(row.wait_json);
|
|
135
|
+
return {
|
|
136
|
+
flowId: row.flow_id,
|
|
137
|
+
syncMode: rowToSyncMode(row),
|
|
138
|
+
ownerKey: row.owner_key,
|
|
139
|
+
...requesterOrigin ? { requesterOrigin } : {},
|
|
140
|
+
...row.controller_id ? { controllerId: row.controller_id } : {},
|
|
141
|
+
revision: normalizeNumber$1(row.revision) ?? 0,
|
|
142
|
+
status: row.status,
|
|
143
|
+
notifyPolicy: row.notify_policy,
|
|
144
|
+
goal: row.goal,
|
|
145
|
+
...row.current_step ? { currentStep: row.current_step } : {},
|
|
146
|
+
...row.blocked_task_id ? { blockedTaskId: row.blocked_task_id } : {},
|
|
147
|
+
...row.blocked_summary ? { blockedSummary: row.blocked_summary } : {},
|
|
148
|
+
...stateJson !== void 0 ? { stateJson } : {},
|
|
149
|
+
...waitJson !== void 0 ? { waitJson } : {},
|
|
150
|
+
...cancelRequestedAt != null ? { cancelRequestedAt } : {},
|
|
151
|
+
createdAt: normalizeNumber$1(row.created_at) ?? 0,
|
|
152
|
+
updatedAt: normalizeNumber$1(row.updated_at) ?? 0,
|
|
153
|
+
...endedAt != null ? { endedAt } : {}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function bindFlowRecord(record) {
|
|
157
|
+
return {
|
|
158
|
+
flow_id: record.flowId,
|
|
159
|
+
sync_mode: record.syncMode,
|
|
160
|
+
owner_key: record.ownerKey,
|
|
161
|
+
requester_origin_json: serializeJson$1(record.requesterOrigin),
|
|
162
|
+
controller_id: record.controllerId ?? null,
|
|
163
|
+
revision: record.revision,
|
|
164
|
+
status: record.status,
|
|
165
|
+
notify_policy: record.notifyPolicy,
|
|
166
|
+
goal: record.goal,
|
|
167
|
+
current_step: record.currentStep ?? null,
|
|
168
|
+
blocked_task_id: record.blockedTaskId ?? null,
|
|
169
|
+
blocked_summary: record.blockedSummary ?? null,
|
|
170
|
+
state_json: serializeJson$1(record.stateJson),
|
|
171
|
+
wait_json: serializeJson$1(record.waitJson),
|
|
172
|
+
cancel_requested_at: record.cancelRequestedAt ?? null,
|
|
173
|
+
created_at: record.createdAt,
|
|
174
|
+
updated_at: record.updatedAt,
|
|
175
|
+
ended_at: record.endedAt ?? null
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function createStatements$1(db) {
|
|
179
|
+
return {
|
|
180
|
+
selectAll: db.prepare(`
|
|
181
|
+
SELECT
|
|
182
|
+
flow_id,
|
|
183
|
+
sync_mode,
|
|
184
|
+
shape,
|
|
185
|
+
owner_key,
|
|
186
|
+
requester_origin_json,
|
|
187
|
+
controller_id,
|
|
188
|
+
revision,
|
|
189
|
+
status,
|
|
190
|
+
notify_policy,
|
|
191
|
+
goal,
|
|
192
|
+
current_step,
|
|
193
|
+
blocked_task_id,
|
|
194
|
+
blocked_summary,
|
|
195
|
+
state_json,
|
|
196
|
+
wait_json,
|
|
197
|
+
cancel_requested_at,
|
|
198
|
+
created_at,
|
|
199
|
+
updated_at,
|
|
200
|
+
ended_at
|
|
201
|
+
FROM flow_runs
|
|
202
|
+
ORDER BY created_at ASC, flow_id ASC
|
|
203
|
+
`),
|
|
204
|
+
upsertRow: db.prepare(`
|
|
205
|
+
INSERT INTO flow_runs (
|
|
206
|
+
flow_id,
|
|
207
|
+
sync_mode,
|
|
208
|
+
owner_key,
|
|
209
|
+
requester_origin_json,
|
|
210
|
+
controller_id,
|
|
211
|
+
revision,
|
|
212
|
+
status,
|
|
213
|
+
notify_policy,
|
|
214
|
+
goal,
|
|
215
|
+
current_step,
|
|
216
|
+
blocked_task_id,
|
|
217
|
+
blocked_summary,
|
|
218
|
+
state_json,
|
|
219
|
+
wait_json,
|
|
220
|
+
cancel_requested_at,
|
|
221
|
+
created_at,
|
|
222
|
+
updated_at,
|
|
223
|
+
ended_at
|
|
224
|
+
) VALUES (
|
|
225
|
+
@flow_id,
|
|
226
|
+
@sync_mode,
|
|
227
|
+
@owner_key,
|
|
228
|
+
@requester_origin_json,
|
|
229
|
+
@controller_id,
|
|
230
|
+
@revision,
|
|
231
|
+
@status,
|
|
232
|
+
@notify_policy,
|
|
233
|
+
@goal,
|
|
234
|
+
@current_step,
|
|
235
|
+
@blocked_task_id,
|
|
236
|
+
@blocked_summary,
|
|
237
|
+
@state_json,
|
|
238
|
+
@wait_json,
|
|
239
|
+
@cancel_requested_at,
|
|
240
|
+
@created_at,
|
|
241
|
+
@updated_at,
|
|
242
|
+
@ended_at
|
|
243
|
+
)
|
|
244
|
+
ON CONFLICT(flow_id) DO UPDATE SET
|
|
245
|
+
sync_mode = excluded.sync_mode,
|
|
246
|
+
owner_key = excluded.owner_key,
|
|
247
|
+
requester_origin_json = excluded.requester_origin_json,
|
|
248
|
+
controller_id = excluded.controller_id,
|
|
249
|
+
revision = excluded.revision,
|
|
250
|
+
status = excluded.status,
|
|
251
|
+
notify_policy = excluded.notify_policy,
|
|
252
|
+
goal = excluded.goal,
|
|
253
|
+
current_step = excluded.current_step,
|
|
254
|
+
blocked_task_id = excluded.blocked_task_id,
|
|
255
|
+
blocked_summary = excluded.blocked_summary,
|
|
256
|
+
state_json = excluded.state_json,
|
|
257
|
+
wait_json = excluded.wait_json,
|
|
258
|
+
cancel_requested_at = excluded.cancel_requested_at,
|
|
259
|
+
created_at = excluded.created_at,
|
|
260
|
+
updated_at = excluded.updated_at,
|
|
261
|
+
ended_at = excluded.ended_at
|
|
262
|
+
`),
|
|
263
|
+
deleteRow: db.prepare(`DELETE FROM flow_runs WHERE flow_id = ?`),
|
|
264
|
+
clearRows: db.prepare(`DELETE FROM flow_runs`)
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function hasFlowRunsColumn(db, columnName) {
|
|
268
|
+
return db.prepare(`PRAGMA table_info(flow_runs)`).all().some((row) => row.name === columnName);
|
|
269
|
+
}
|
|
270
|
+
function ensureSchema$1(db) {
|
|
271
|
+
db.exec(`
|
|
272
|
+
CREATE TABLE IF NOT EXISTS flow_runs (
|
|
273
|
+
flow_id TEXT PRIMARY KEY,
|
|
274
|
+
shape TEXT,
|
|
275
|
+
sync_mode TEXT NOT NULL DEFAULT 'managed',
|
|
276
|
+
owner_key TEXT NOT NULL,
|
|
277
|
+
requester_origin_json TEXT,
|
|
278
|
+
controller_id TEXT,
|
|
279
|
+
revision INTEGER NOT NULL DEFAULT 0,
|
|
280
|
+
status TEXT NOT NULL,
|
|
281
|
+
notify_policy TEXT NOT NULL,
|
|
282
|
+
goal TEXT NOT NULL,
|
|
283
|
+
current_step TEXT,
|
|
284
|
+
blocked_task_id TEXT,
|
|
285
|
+
blocked_summary TEXT,
|
|
286
|
+
state_json TEXT,
|
|
287
|
+
wait_json TEXT,
|
|
288
|
+
cancel_requested_at INTEGER,
|
|
289
|
+
created_at INTEGER NOT NULL,
|
|
290
|
+
updated_at INTEGER NOT NULL,
|
|
291
|
+
ended_at INTEGER
|
|
292
|
+
);
|
|
293
|
+
`);
|
|
294
|
+
if (!hasFlowRunsColumn(db, "owner_key") && hasFlowRunsColumn(db, "owner_session_key")) {
|
|
295
|
+
db.exec(`ALTER TABLE flow_runs ADD COLUMN owner_key TEXT;`);
|
|
296
|
+
db.exec(`
|
|
297
|
+
UPDATE flow_runs
|
|
298
|
+
SET owner_key = owner_session_key
|
|
299
|
+
WHERE owner_key IS NULL
|
|
300
|
+
`);
|
|
301
|
+
}
|
|
302
|
+
if (!hasFlowRunsColumn(db, "shape")) db.exec(`ALTER TABLE flow_runs ADD COLUMN shape TEXT;`);
|
|
303
|
+
if (!hasFlowRunsColumn(db, "sync_mode")) {
|
|
304
|
+
db.exec(`ALTER TABLE flow_runs ADD COLUMN sync_mode TEXT;`);
|
|
305
|
+
if (hasFlowRunsColumn(db, "shape")) db.exec(`
|
|
306
|
+
UPDATE flow_runs
|
|
307
|
+
SET sync_mode = CASE
|
|
308
|
+
WHEN shape = 'single_task' THEN 'task_mirrored'
|
|
309
|
+
ELSE 'managed'
|
|
310
|
+
END
|
|
311
|
+
WHERE sync_mode IS NULL
|
|
312
|
+
`);
|
|
313
|
+
else db.exec(`
|
|
314
|
+
UPDATE flow_runs
|
|
315
|
+
SET sync_mode = 'managed'
|
|
316
|
+
WHERE sync_mode IS NULL
|
|
317
|
+
`);
|
|
318
|
+
}
|
|
319
|
+
if (!hasFlowRunsColumn(db, "controller_id")) db.exec(`ALTER TABLE flow_runs ADD COLUMN controller_id TEXT;`);
|
|
320
|
+
db.exec(`
|
|
321
|
+
UPDATE flow_runs
|
|
322
|
+
SET controller_id = 'core/legacy-restored'
|
|
323
|
+
WHERE sync_mode = 'managed'
|
|
324
|
+
AND (controller_id IS NULL OR trim(controller_id) = '')
|
|
325
|
+
`);
|
|
326
|
+
if (!hasFlowRunsColumn(db, "revision")) {
|
|
327
|
+
db.exec(`ALTER TABLE flow_runs ADD COLUMN revision INTEGER;`);
|
|
328
|
+
db.exec(`
|
|
329
|
+
UPDATE flow_runs
|
|
330
|
+
SET revision = 0
|
|
331
|
+
WHERE revision IS NULL
|
|
332
|
+
`);
|
|
333
|
+
}
|
|
334
|
+
if (!hasFlowRunsColumn(db, "blocked_task_id")) db.exec(`ALTER TABLE flow_runs ADD COLUMN blocked_task_id TEXT;`);
|
|
335
|
+
if (!hasFlowRunsColumn(db, "blocked_summary")) db.exec(`ALTER TABLE flow_runs ADD COLUMN blocked_summary TEXT;`);
|
|
336
|
+
if (!hasFlowRunsColumn(db, "state_json")) db.exec(`ALTER TABLE flow_runs ADD COLUMN state_json TEXT;`);
|
|
337
|
+
if (!hasFlowRunsColumn(db, "wait_json")) db.exec(`ALTER TABLE flow_runs ADD COLUMN wait_json TEXT;`);
|
|
338
|
+
if (!hasFlowRunsColumn(db, "cancel_requested_at")) db.exec(`ALTER TABLE flow_runs ADD COLUMN cancel_requested_at INTEGER;`);
|
|
339
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_flow_runs_status ON flow_runs(status);`);
|
|
340
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_flow_runs_owner_key ON flow_runs(owner_key);`);
|
|
341
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_flow_runs_updated_at ON flow_runs(updated_at);`);
|
|
342
|
+
}
|
|
343
|
+
function ensureFlowRegistryPermissions(pathname) {
|
|
344
|
+
const dir = resolveTaskFlowRegistryDir(process.env);
|
|
345
|
+
mkdirSync(dir, {
|
|
346
|
+
recursive: true,
|
|
347
|
+
mode: FLOW_REGISTRY_DIR_MODE
|
|
348
|
+
});
|
|
349
|
+
chmodSync(dir, FLOW_REGISTRY_DIR_MODE);
|
|
350
|
+
for (const suffix of FLOW_REGISTRY_SIDECAR_SUFFIXES) {
|
|
351
|
+
const candidate = `${pathname}${suffix}`;
|
|
352
|
+
if (!existsSync(candidate)) continue;
|
|
353
|
+
chmodSync(candidate, FLOW_REGISTRY_FILE_MODE);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
function openFlowRegistryDatabase() {
|
|
357
|
+
const pathname = resolveTaskFlowRegistrySqlitePath(process.env);
|
|
358
|
+
if (cachedDatabase$1 && cachedDatabase$1.path === pathname) return cachedDatabase$1;
|
|
359
|
+
if (cachedDatabase$1) {
|
|
360
|
+
cachedDatabase$1.db.close();
|
|
361
|
+
cachedDatabase$1 = null;
|
|
362
|
+
}
|
|
363
|
+
ensureFlowRegistryPermissions(pathname);
|
|
364
|
+
const { DatabaseSync } = requireNodeSqlite();
|
|
365
|
+
const db = new DatabaseSync(pathname);
|
|
366
|
+
db.exec(`PRAGMA journal_mode = WAL;`);
|
|
367
|
+
db.exec(`PRAGMA synchronous = NORMAL;`);
|
|
368
|
+
db.exec(`PRAGMA busy_timeout = 5000;`);
|
|
369
|
+
ensureSchema$1(db);
|
|
370
|
+
ensureFlowRegistryPermissions(pathname);
|
|
371
|
+
cachedDatabase$1 = {
|
|
372
|
+
db,
|
|
373
|
+
path: pathname,
|
|
374
|
+
statements: createStatements$1(db)
|
|
375
|
+
};
|
|
376
|
+
return cachedDatabase$1;
|
|
377
|
+
}
|
|
378
|
+
function withWriteTransaction$1(write) {
|
|
379
|
+
const { db, path, statements } = openFlowRegistryDatabase();
|
|
380
|
+
db.exec("BEGIN IMMEDIATE");
|
|
381
|
+
try {
|
|
382
|
+
write(statements);
|
|
383
|
+
db.exec("COMMIT");
|
|
384
|
+
ensureFlowRegistryPermissions(path);
|
|
385
|
+
} catch (error) {
|
|
386
|
+
db.exec("ROLLBACK");
|
|
387
|
+
throw error;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function loadTaskFlowRegistryStateFromSqlite() {
|
|
391
|
+
const { statements } = openFlowRegistryDatabase();
|
|
392
|
+
const rows = statements.selectAll.all();
|
|
393
|
+
return { flows: new Map(rows.map((row) => [row.flow_id, rowToFlowRecord(row)])) };
|
|
394
|
+
}
|
|
395
|
+
function saveTaskFlowRegistryStateToSqlite(snapshot) {
|
|
396
|
+
withWriteTransaction$1((statements) => {
|
|
397
|
+
statements.clearRows.run();
|
|
398
|
+
for (const flow of snapshot.flows.values()) statements.upsertRow.run(bindFlowRecord(flow));
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
function upsertTaskFlowRegistryRecordToSqlite(flow) {
|
|
402
|
+
const store = openFlowRegistryDatabase();
|
|
403
|
+
store.statements.upsertRow.run(bindFlowRecord(flow));
|
|
404
|
+
ensureFlowRegistryPermissions(store.path);
|
|
405
|
+
}
|
|
406
|
+
function deleteTaskFlowRegistryRecordFromSqlite(flowId) {
|
|
407
|
+
const store = openFlowRegistryDatabase();
|
|
408
|
+
store.statements.deleteRow.run(flowId);
|
|
409
|
+
ensureFlowRegistryPermissions(store.path);
|
|
410
|
+
}
|
|
411
|
+
function closeTaskFlowRegistrySqliteStore() {
|
|
412
|
+
if (!cachedDatabase$1) return;
|
|
413
|
+
cachedDatabase$1.db.close();
|
|
414
|
+
cachedDatabase$1 = null;
|
|
415
|
+
}
|
|
416
|
+
let configuredFlowRegistryStore = {
|
|
417
|
+
loadSnapshot: loadTaskFlowRegistryStateFromSqlite,
|
|
418
|
+
saveSnapshot: saveTaskFlowRegistryStateToSqlite,
|
|
419
|
+
upsertFlow: upsertTaskFlowRegistryRecordToSqlite,
|
|
420
|
+
deleteFlow: deleteTaskFlowRegistryRecordFromSqlite,
|
|
421
|
+
close: closeTaskFlowRegistrySqliteStore
|
|
422
|
+
};
|
|
423
|
+
let configuredFlowRegistryObservers = null;
|
|
424
|
+
function getTaskFlowRegistryStore() {
|
|
425
|
+
return configuredFlowRegistryStore;
|
|
426
|
+
}
|
|
427
|
+
function getTaskFlowRegistryObservers() {
|
|
428
|
+
return configuredFlowRegistryObservers;
|
|
429
|
+
}
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/tasks/task-flow-registry.ts
|
|
432
|
+
const log$1 = createSubsystemLogger("tasks/task-flow-registry");
|
|
433
|
+
const flows = /* @__PURE__ */ new Map();
|
|
434
|
+
let restoreAttempted$1 = false;
|
|
435
|
+
let restoreFailureMessage = null;
|
|
436
|
+
function cloneStructuredValue(value) {
|
|
437
|
+
if (value === void 0) return;
|
|
438
|
+
return structuredClone(value);
|
|
439
|
+
}
|
|
440
|
+
function cloneFlowRecord(record) {
|
|
441
|
+
return {
|
|
442
|
+
...record,
|
|
443
|
+
...record.requesterOrigin ? { requesterOrigin: cloneStructuredValue(record.requesterOrigin) } : {},
|
|
444
|
+
...record.stateJson !== void 0 ? { stateJson: cloneStructuredValue(record.stateJson) } : {},
|
|
445
|
+
...record.waitJson !== void 0 ? { waitJson: cloneStructuredValue(record.waitJson) } : {}
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
function normalizeRestoredFlowRecord(record) {
|
|
449
|
+
const syncMode = record.syncMode === "task_mirrored" ? "task_mirrored" : "managed";
|
|
450
|
+
const controllerId = syncMode === "managed" ? normalizeOptionalString(record.controllerId) ?? "core/legacy-restored" : void 0;
|
|
451
|
+
return {
|
|
452
|
+
...record,
|
|
453
|
+
syncMode,
|
|
454
|
+
ownerKey: assertFlowOwnerKey(record.ownerKey),
|
|
455
|
+
...record.requesterOrigin ? { requesterOrigin: cloneStructuredValue(record.requesterOrigin) } : {},
|
|
456
|
+
...controllerId ? { controllerId } : {},
|
|
457
|
+
currentStep: normalizeOptionalString(record.currentStep),
|
|
458
|
+
blockedTaskId: normalizeOptionalString(record.blockedTaskId),
|
|
459
|
+
blockedSummary: normalizeOptionalString(record.blockedSummary),
|
|
460
|
+
...record.stateJson !== void 0 ? { stateJson: cloneStructuredValue(record.stateJson) } : {},
|
|
461
|
+
...record.waitJson !== void 0 ? { waitJson: cloneStructuredValue(record.waitJson) } : {},
|
|
462
|
+
revision: Math.max(0, record.revision),
|
|
463
|
+
cancelRequestedAt: record.cancelRequestedAt ?? void 0,
|
|
464
|
+
endedAt: record.endedAt ?? void 0
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
function snapshotFlowRecords(source) {
|
|
468
|
+
return [...source.values()].map((record) => cloneFlowRecord(record));
|
|
469
|
+
}
|
|
470
|
+
function emitFlowRegistryObserverEvent(createEvent) {
|
|
471
|
+
const observers = getTaskFlowRegistryObservers();
|
|
472
|
+
if (!observers?.onEvent) return;
|
|
473
|
+
try {
|
|
474
|
+
observers.onEvent(createEvent());
|
|
475
|
+
} catch {}
|
|
476
|
+
}
|
|
477
|
+
function ensureNotifyPolicy$1(notifyPolicy) {
|
|
478
|
+
return notifyPolicy ?? "done_only";
|
|
479
|
+
}
|
|
480
|
+
function normalizeJsonBlob(value) {
|
|
481
|
+
return value === void 0 ? void 0 : cloneStructuredValue(value);
|
|
482
|
+
}
|
|
483
|
+
function assertFlowOwnerKey(ownerKey) {
|
|
484
|
+
const normalized = normalizeOptionalString(ownerKey);
|
|
485
|
+
if (!normalized) throw new Error("Flow ownerKey is required.");
|
|
486
|
+
return normalized;
|
|
487
|
+
}
|
|
488
|
+
function assertControllerId(controllerId) {
|
|
489
|
+
const normalized = normalizeOptionalString(controllerId);
|
|
490
|
+
if (!normalized) throw new Error("Managed flow controllerId is required.");
|
|
491
|
+
return normalized;
|
|
492
|
+
}
|
|
493
|
+
function resolveFlowBlockedSummary(task) {
|
|
494
|
+
if (task.status !== "succeeded" || task.terminalOutcome !== "blocked") return;
|
|
495
|
+
return normalizeOptionalString(task.terminalSummary) ?? normalizeOptionalString(task.progressSummary);
|
|
496
|
+
}
|
|
497
|
+
function deriveTaskFlowStatusFromTask(task) {
|
|
498
|
+
if (task.status === "queued") return "queued";
|
|
499
|
+
if (task.status === "running") return "running";
|
|
500
|
+
if (task.status === "succeeded") return task.terminalOutcome === "blocked" ? "blocked" : "succeeded";
|
|
501
|
+
if (task.status === "cancelled") return "cancelled";
|
|
502
|
+
if (task.status === "lost") return "lost";
|
|
503
|
+
return "failed";
|
|
504
|
+
}
|
|
505
|
+
function ensureFlowRegistryReady() {
|
|
506
|
+
if (restoreAttempted$1) return;
|
|
507
|
+
restoreAttempted$1 = true;
|
|
508
|
+
try {
|
|
509
|
+
const restored = getTaskFlowRegistryStore().loadSnapshot();
|
|
510
|
+
flows.clear();
|
|
511
|
+
for (const [flowId, flow] of restored.flows) flows.set(flowId, normalizeRestoredFlowRecord(flow));
|
|
512
|
+
restoreFailureMessage = null;
|
|
513
|
+
} catch (error) {
|
|
514
|
+
flows.clear();
|
|
515
|
+
restoreFailureMessage = formatErrorMessage(error);
|
|
516
|
+
log$1.warn("Failed to restore task-flow registry", { error });
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
emitFlowRegistryObserverEvent(() => ({
|
|
520
|
+
kind: "restored",
|
|
521
|
+
flows: snapshotFlowRecords(flows)
|
|
522
|
+
}));
|
|
523
|
+
}
|
|
524
|
+
function getTaskFlowRegistryRestoreFailure() {
|
|
525
|
+
ensureFlowRegistryReady();
|
|
526
|
+
return restoreFailureMessage;
|
|
527
|
+
}
|
|
528
|
+
function persistFlowRegistry() {
|
|
529
|
+
getTaskFlowRegistryStore().saveSnapshot({ flows: new Map(snapshotFlowRecords(flows).map((flow) => [flow.flowId, flow])) });
|
|
530
|
+
}
|
|
531
|
+
function persistFlowUpsert(flow) {
|
|
532
|
+
const store = getTaskFlowRegistryStore();
|
|
533
|
+
if (store.upsertFlow) {
|
|
534
|
+
store.upsertFlow(cloneFlowRecord(flow));
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
persistFlowRegistry();
|
|
538
|
+
}
|
|
539
|
+
function persistFlowDelete(flowId) {
|
|
540
|
+
const store = getTaskFlowRegistryStore();
|
|
541
|
+
if (store.deleteFlow) {
|
|
542
|
+
store.deleteFlow(flowId);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
persistFlowRegistry();
|
|
546
|
+
}
|
|
547
|
+
function buildFlowRecord(params) {
|
|
548
|
+
const now = params.createdAt ?? Date.now();
|
|
549
|
+
const syncMode = params.syncMode ?? "managed";
|
|
550
|
+
const controllerId = syncMode === "managed" ? assertControllerId(params.controllerId) : void 0;
|
|
551
|
+
return {
|
|
552
|
+
flowId: crypto.randomUUID(),
|
|
553
|
+
syncMode,
|
|
554
|
+
ownerKey: assertFlowOwnerKey(params.ownerKey),
|
|
555
|
+
...params.requesterOrigin ? { requesterOrigin: cloneStructuredValue(params.requesterOrigin) } : {},
|
|
556
|
+
...controllerId ? { controllerId } : {},
|
|
557
|
+
revision: Math.max(0, params.revision ?? 0),
|
|
558
|
+
status: params.status ?? "queued",
|
|
559
|
+
notifyPolicy: ensureNotifyPolicy$1(params.notifyPolicy),
|
|
560
|
+
goal: params.goal,
|
|
561
|
+
currentStep: normalizeOptionalString(params.currentStep),
|
|
562
|
+
blockedTaskId: normalizeOptionalString(params.blockedTaskId),
|
|
563
|
+
blockedSummary: normalizeOptionalString(params.blockedSummary),
|
|
564
|
+
...normalizeJsonBlob(params.stateJson) !== void 0 ? { stateJson: normalizeJsonBlob(params.stateJson) } : {},
|
|
565
|
+
...normalizeJsonBlob(params.waitJson) !== void 0 ? { waitJson: normalizeJsonBlob(params.waitJson) } : {},
|
|
566
|
+
...params.cancelRequestedAt != null ? { cancelRequestedAt: params.cancelRequestedAt } : {},
|
|
567
|
+
createdAt: now,
|
|
568
|
+
updatedAt: params.updatedAt ?? now,
|
|
569
|
+
...params.endedAt != null ? { endedAt: params.endedAt } : {}
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function applyFlowPatch(current, patch) {
|
|
573
|
+
const controllerId = patch.controllerId === void 0 ? current.controllerId : normalizeOptionalString(patch.controllerId);
|
|
574
|
+
if (current.syncMode === "managed") assertControllerId(controllerId);
|
|
575
|
+
return {
|
|
576
|
+
...current,
|
|
577
|
+
...patch.status ? { status: patch.status } : {},
|
|
578
|
+
...patch.notifyPolicy ? { notifyPolicy: patch.notifyPolicy } : {},
|
|
579
|
+
...patch.goal ? { goal: patch.goal } : {},
|
|
580
|
+
controllerId,
|
|
581
|
+
currentStep: patch.currentStep === void 0 ? current.currentStep : normalizeOptionalString(patch.currentStep),
|
|
582
|
+
blockedTaskId: patch.blockedTaskId === void 0 ? current.blockedTaskId : normalizeOptionalString(patch.blockedTaskId),
|
|
583
|
+
blockedSummary: patch.blockedSummary === void 0 ? current.blockedSummary : normalizeOptionalString(patch.blockedSummary),
|
|
584
|
+
stateJson: patch.stateJson === void 0 ? current.stateJson : normalizeJsonBlob(patch.stateJson),
|
|
585
|
+
waitJson: patch.waitJson === void 0 ? current.waitJson : normalizeJsonBlob(patch.waitJson),
|
|
586
|
+
cancelRequestedAt: patch.cancelRequestedAt === void 0 ? current.cancelRequestedAt : patch.cancelRequestedAt ?? void 0,
|
|
587
|
+
revision: current.revision + 1,
|
|
588
|
+
updatedAt: patch.updatedAt ?? Date.now(),
|
|
589
|
+
endedAt: patch.endedAt === void 0 ? current.endedAt : patch.endedAt ?? void 0
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
function writeFlowRecord(next, previous) {
|
|
593
|
+
flows.set(next.flowId, next);
|
|
594
|
+
persistFlowUpsert(next);
|
|
595
|
+
emitFlowRegistryObserverEvent(() => ({
|
|
596
|
+
kind: "upserted",
|
|
597
|
+
flow: cloneFlowRecord(next),
|
|
598
|
+
...previous ? { previous: cloneFlowRecord(previous) } : {}
|
|
599
|
+
}));
|
|
600
|
+
return cloneFlowRecord(next);
|
|
601
|
+
}
|
|
602
|
+
function createFlowRecord(params) {
|
|
603
|
+
ensureFlowRegistryReady();
|
|
604
|
+
return writeFlowRecord(buildFlowRecord(params));
|
|
605
|
+
}
|
|
606
|
+
function createManagedTaskFlow(params) {
|
|
607
|
+
return createFlowRecord({
|
|
608
|
+
...params,
|
|
609
|
+
syncMode: "managed",
|
|
610
|
+
controllerId: assertControllerId(params.controllerId)
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
function createTaskFlowForTask(params) {
|
|
614
|
+
const terminalFlowStatus = deriveTaskFlowStatusFromTask(params.task);
|
|
615
|
+
const endedAt = terminalFlowStatus === "succeeded" || terminalFlowStatus === "blocked" || terminalFlowStatus === "failed" || terminalFlowStatus === "cancelled" || terminalFlowStatus === "lost" ? params.task.endedAt ?? params.task.lastEventAt ?? params.task.createdAt : void 0;
|
|
616
|
+
return createFlowRecord({
|
|
617
|
+
syncMode: "task_mirrored",
|
|
618
|
+
ownerKey: params.task.ownerKey,
|
|
619
|
+
requesterOrigin: params.requesterOrigin,
|
|
620
|
+
status: terminalFlowStatus,
|
|
621
|
+
notifyPolicy: params.task.notifyPolicy,
|
|
622
|
+
goal: normalizeOptionalString(params.task.label) ?? (params.task.task.trim() || "Background task"),
|
|
623
|
+
blockedTaskId: terminalFlowStatus === "blocked" ? normalizeOptionalString(params.task.taskId) : void 0,
|
|
624
|
+
blockedSummary: resolveFlowBlockedSummary(params.task),
|
|
625
|
+
createdAt: params.task.createdAt,
|
|
626
|
+
updatedAt: params.task.lastEventAt ?? params.task.createdAt,
|
|
627
|
+
...endedAt !== void 0 ? { endedAt } : {}
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
function updateFlowRecordByIdUnchecked(flowId, patch) {
|
|
631
|
+
ensureFlowRegistryReady();
|
|
632
|
+
const current = flows.get(flowId);
|
|
633
|
+
if (!current) return null;
|
|
634
|
+
return writeFlowRecord(applyFlowPatch(current, patch), current);
|
|
635
|
+
}
|
|
636
|
+
function updateFlowRecordByIdExpectedRevision(params) {
|
|
637
|
+
ensureFlowRegistryReady();
|
|
638
|
+
const current = flows.get(params.flowId);
|
|
639
|
+
if (!current) return {
|
|
640
|
+
applied: false,
|
|
641
|
+
reason: "not_found"
|
|
642
|
+
};
|
|
643
|
+
if (current.revision !== params.expectedRevision) return {
|
|
644
|
+
applied: false,
|
|
645
|
+
reason: "revision_conflict",
|
|
646
|
+
current: cloneFlowRecord(current)
|
|
647
|
+
};
|
|
648
|
+
return {
|
|
649
|
+
applied: true,
|
|
650
|
+
flow: writeFlowRecord(applyFlowPatch(current, params.patch), current)
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
function setFlowWaiting(params) {
|
|
654
|
+
return updateFlowRecordByIdExpectedRevision({
|
|
655
|
+
flowId: params.flowId,
|
|
656
|
+
expectedRevision: params.expectedRevision,
|
|
657
|
+
patch: {
|
|
658
|
+
status: normalizeOptionalString(params.blockedTaskId) || normalizeOptionalString(params.blockedSummary) ? "blocked" : "waiting",
|
|
659
|
+
currentStep: params.currentStep,
|
|
660
|
+
stateJson: params.stateJson,
|
|
661
|
+
waitJson: params.waitJson,
|
|
662
|
+
blockedTaskId: params.blockedTaskId,
|
|
663
|
+
blockedSummary: params.blockedSummary,
|
|
664
|
+
endedAt: null,
|
|
665
|
+
updatedAt: params.updatedAt
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
function resumeFlow(params) {
|
|
670
|
+
return updateFlowRecordByIdExpectedRevision({
|
|
671
|
+
flowId: params.flowId,
|
|
672
|
+
expectedRevision: params.expectedRevision,
|
|
673
|
+
patch: {
|
|
674
|
+
status: params.status ?? "queued",
|
|
675
|
+
currentStep: params.currentStep,
|
|
676
|
+
stateJson: params.stateJson,
|
|
677
|
+
waitJson: null,
|
|
678
|
+
blockedTaskId: null,
|
|
679
|
+
blockedSummary: null,
|
|
680
|
+
endedAt: null,
|
|
681
|
+
updatedAt: params.updatedAt
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
function finishFlow(params) {
|
|
686
|
+
const endedAt = params.endedAt ?? params.updatedAt ?? Date.now();
|
|
687
|
+
return updateFlowRecordByIdExpectedRevision({
|
|
688
|
+
flowId: params.flowId,
|
|
689
|
+
expectedRevision: params.expectedRevision,
|
|
690
|
+
patch: {
|
|
691
|
+
status: "succeeded",
|
|
692
|
+
currentStep: params.currentStep,
|
|
693
|
+
stateJson: params.stateJson,
|
|
694
|
+
waitJson: null,
|
|
695
|
+
blockedTaskId: null,
|
|
696
|
+
blockedSummary: null,
|
|
697
|
+
endedAt,
|
|
698
|
+
updatedAt: params.updatedAt ?? endedAt
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
function failFlow(params) {
|
|
703
|
+
const endedAt = params.endedAt ?? params.updatedAt ?? Date.now();
|
|
704
|
+
return updateFlowRecordByIdExpectedRevision({
|
|
705
|
+
flowId: params.flowId,
|
|
706
|
+
expectedRevision: params.expectedRevision,
|
|
707
|
+
patch: {
|
|
708
|
+
status: "failed",
|
|
709
|
+
currentStep: params.currentStep,
|
|
710
|
+
stateJson: params.stateJson,
|
|
711
|
+
waitJson: null,
|
|
712
|
+
blockedTaskId: params.blockedTaskId,
|
|
713
|
+
blockedSummary: params.blockedSummary,
|
|
714
|
+
endedAt,
|
|
715
|
+
updatedAt: params.updatedAt ?? endedAt
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
function requestFlowCancel(params) {
|
|
720
|
+
return updateFlowRecordByIdExpectedRevision({
|
|
721
|
+
flowId: params.flowId,
|
|
722
|
+
expectedRevision: params.expectedRevision,
|
|
723
|
+
patch: {
|
|
724
|
+
cancelRequestedAt: params.cancelRequestedAt ?? params.updatedAt ?? Date.now(),
|
|
725
|
+
updatedAt: params.updatedAt
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
function syncFlowFromTask(task) {
|
|
730
|
+
const flowId = task.parentFlowId?.trim();
|
|
731
|
+
if (!flowId) return null;
|
|
732
|
+
const flow = getTaskFlowById(flowId);
|
|
733
|
+
if (!flow) return null;
|
|
734
|
+
if (flow.syncMode !== "task_mirrored") return flow;
|
|
735
|
+
const terminalFlowStatus = deriveTaskFlowStatusFromTask(task);
|
|
736
|
+
const isTerminal = terminalFlowStatus === "succeeded" || terminalFlowStatus === "blocked" || terminalFlowStatus === "failed" || terminalFlowStatus === "cancelled" || terminalFlowStatus === "lost";
|
|
737
|
+
return updateFlowRecordByIdUnchecked(flowId, {
|
|
738
|
+
status: terminalFlowStatus,
|
|
739
|
+
notifyPolicy: task.notifyPolicy,
|
|
740
|
+
goal: normalizeOptionalString(task.label) ?? (task.task.trim() || "Background task"),
|
|
741
|
+
blockedTaskId: terminalFlowStatus === "blocked" ? task.taskId.trim() || null : null,
|
|
742
|
+
blockedSummary: terminalFlowStatus === "blocked" ? resolveFlowBlockedSummary(task) ?? null : null,
|
|
743
|
+
waitJson: null,
|
|
744
|
+
updatedAt: task.lastEventAt ?? Date.now(),
|
|
745
|
+
...isTerminal ? { endedAt: task.endedAt ?? task.lastEventAt ?? Date.now() } : { endedAt: null }
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
function getTaskFlowById(flowId) {
|
|
749
|
+
ensureFlowRegistryReady();
|
|
750
|
+
const flow = flows.get(flowId);
|
|
751
|
+
return flow ? cloneFlowRecord(flow) : void 0;
|
|
752
|
+
}
|
|
753
|
+
function listTaskFlowsForOwnerKey(ownerKey) {
|
|
754
|
+
ensureFlowRegistryReady();
|
|
755
|
+
const normalizedOwnerKey = ownerKey.trim();
|
|
756
|
+
if (!normalizedOwnerKey) return [];
|
|
757
|
+
return [...flows.values()].filter((flow) => flow.ownerKey.trim() === normalizedOwnerKey).map((flow) => cloneFlowRecord(flow)).toSorted((left, right) => right.createdAt - left.createdAt);
|
|
758
|
+
}
|
|
759
|
+
function findLatestTaskFlowForOwnerKey(ownerKey) {
|
|
760
|
+
const flow = listTaskFlowsForOwnerKey(ownerKey)[0];
|
|
761
|
+
return flow ? cloneFlowRecord(flow) : void 0;
|
|
762
|
+
}
|
|
763
|
+
function resolveTaskFlowForLookupToken(token) {
|
|
764
|
+
const lookup = token.trim();
|
|
765
|
+
if (!lookup) return;
|
|
766
|
+
return getTaskFlowById(lookup) ?? findLatestTaskFlowForOwnerKey(lookup);
|
|
767
|
+
}
|
|
768
|
+
function listTaskFlowRecords() {
|
|
769
|
+
ensureFlowRegistryReady();
|
|
770
|
+
return [...flows.values()].map((flow) => cloneFlowRecord(flow)).toSorted((left, right) => right.createdAt - left.createdAt);
|
|
771
|
+
}
|
|
772
|
+
function deleteTaskFlowRecordById(flowId) {
|
|
773
|
+
ensureFlowRegistryReady();
|
|
774
|
+
const current = flows.get(flowId);
|
|
775
|
+
if (!current) return false;
|
|
776
|
+
flows.delete(flowId);
|
|
777
|
+
persistFlowDelete(flowId);
|
|
778
|
+
emitFlowRegistryObserverEvent(() => ({
|
|
779
|
+
kind: "deleted",
|
|
780
|
+
flowId,
|
|
781
|
+
previous: cloneFlowRecord(current)
|
|
782
|
+
}));
|
|
783
|
+
return true;
|
|
784
|
+
}
|
|
785
|
+
//#endregion
|
|
786
|
+
//#region src/tasks/task-registry.store.sqlite.ts
|
|
787
|
+
let cachedDatabase = null;
|
|
788
|
+
const TASK_REGISTRY_DIR_MODE = 448;
|
|
789
|
+
const TASK_REGISTRY_FILE_MODE = 384;
|
|
790
|
+
const TASK_REGISTRY_SIDECAR_SUFFIXES = [
|
|
791
|
+
"",
|
|
792
|
+
"-shm",
|
|
793
|
+
"-wal"
|
|
794
|
+
];
|
|
795
|
+
function normalizeNumber(value) {
|
|
796
|
+
if (typeof value === "bigint") return Number(value);
|
|
797
|
+
return typeof value === "number" ? value : void 0;
|
|
798
|
+
}
|
|
799
|
+
function serializeJson(value) {
|
|
800
|
+
return value == null ? null : JSON.stringify(value);
|
|
801
|
+
}
|
|
802
|
+
function parseJsonValue(raw) {
|
|
803
|
+
if (!raw?.trim()) return;
|
|
804
|
+
try {
|
|
805
|
+
return JSON.parse(raw);
|
|
806
|
+
} catch {
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
function rowToTaskRecord(row) {
|
|
811
|
+
const startedAt = normalizeNumber(row.started_at);
|
|
812
|
+
const endedAt = normalizeNumber(row.ended_at);
|
|
813
|
+
const lastEventAt = normalizeNumber(row.last_event_at);
|
|
814
|
+
const cleanupAfter = normalizeNumber(row.cleanup_after);
|
|
815
|
+
const requesterSessionKey = row.scope_kind === "system" ? "" : row.requester_session_key?.trim() || row.owner_key;
|
|
816
|
+
return {
|
|
817
|
+
taskId: row.task_id,
|
|
818
|
+
runtime: row.runtime,
|
|
819
|
+
...row.task_kind ? { taskKind: row.task_kind } : {},
|
|
820
|
+
...row.source_id ? { sourceId: row.source_id } : {},
|
|
821
|
+
requesterSessionKey,
|
|
822
|
+
ownerKey: row.owner_key,
|
|
823
|
+
scopeKind: row.scope_kind,
|
|
824
|
+
...row.child_session_key ? { childSessionKey: row.child_session_key } : {},
|
|
825
|
+
...row.parent_flow_id ? { parentFlowId: row.parent_flow_id } : {},
|
|
826
|
+
...row.parent_task_id ? { parentTaskId: row.parent_task_id } : {},
|
|
827
|
+
...row.agent_id ? { agentId: row.agent_id } : {},
|
|
828
|
+
...row.run_id ? { runId: row.run_id } : {},
|
|
829
|
+
...row.label ? { label: row.label } : {},
|
|
830
|
+
task: row.task,
|
|
831
|
+
status: row.status,
|
|
832
|
+
deliveryStatus: row.delivery_status,
|
|
833
|
+
notifyPolicy: row.notify_policy,
|
|
834
|
+
createdAt: normalizeNumber(row.created_at) ?? 0,
|
|
835
|
+
...startedAt != null ? { startedAt } : {},
|
|
836
|
+
...endedAt != null ? { endedAt } : {},
|
|
837
|
+
...lastEventAt != null ? { lastEventAt } : {},
|
|
838
|
+
...cleanupAfter != null ? { cleanupAfter } : {},
|
|
839
|
+
...row.error ? { error: row.error } : {},
|
|
840
|
+
...row.progress_summary ? { progressSummary: row.progress_summary } : {},
|
|
841
|
+
...row.terminal_summary ? { terminalSummary: row.terminal_summary } : {},
|
|
842
|
+
...row.terminal_outcome ? { terminalOutcome: row.terminal_outcome } : {}
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
function rowToTaskDeliveryState(row) {
|
|
846
|
+
const requesterOrigin = parseJsonValue(row.requester_origin_json);
|
|
847
|
+
const lastNotifiedEventAt = normalizeNumber(row.last_notified_event_at);
|
|
848
|
+
return {
|
|
849
|
+
taskId: row.task_id,
|
|
850
|
+
...requesterOrigin ? { requesterOrigin } : {},
|
|
851
|
+
...lastNotifiedEventAt != null ? { lastNotifiedEventAt } : {}
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
function bindTaskRecordBase(record) {
|
|
855
|
+
return {
|
|
856
|
+
task_id: record.taskId,
|
|
857
|
+
runtime: record.runtime,
|
|
858
|
+
task_kind: record.taskKind ?? null,
|
|
859
|
+
source_id: record.sourceId ?? null,
|
|
860
|
+
requester_session_key: record.scopeKind === "system" ? "" : record.requesterSessionKey,
|
|
861
|
+
owner_key: record.ownerKey,
|
|
862
|
+
scope_kind: record.scopeKind,
|
|
863
|
+
child_session_key: record.childSessionKey ?? null,
|
|
864
|
+
parent_flow_id: record.parentFlowId ?? null,
|
|
865
|
+
parent_task_id: record.parentTaskId ?? null,
|
|
866
|
+
agent_id: record.agentId ?? null,
|
|
867
|
+
run_id: record.runId ?? null,
|
|
868
|
+
label: record.label ?? null,
|
|
869
|
+
task: record.task,
|
|
870
|
+
status: record.status,
|
|
871
|
+
delivery_status: record.deliveryStatus,
|
|
872
|
+
notify_policy: record.notifyPolicy,
|
|
873
|
+
created_at: record.createdAt,
|
|
874
|
+
started_at: record.startedAt ?? null,
|
|
875
|
+
ended_at: record.endedAt ?? null,
|
|
876
|
+
last_event_at: record.lastEventAt ?? null,
|
|
877
|
+
cleanup_after: record.cleanupAfter ?? null,
|
|
878
|
+
error: record.error ?? null,
|
|
879
|
+
progress_summary: record.progressSummary ?? null,
|
|
880
|
+
terminal_summary: record.terminalSummary ?? null,
|
|
881
|
+
terminal_outcome: record.terminalOutcome ?? null
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
function bindTaskDeliveryState(state) {
|
|
885
|
+
return {
|
|
886
|
+
task_id: state.taskId,
|
|
887
|
+
requester_origin_json: serializeJson(state.requesterOrigin),
|
|
888
|
+
last_notified_event_at: state.lastNotifiedEventAt ?? null
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
function createStatements(db) {
|
|
892
|
+
return {
|
|
893
|
+
selectAll: db.prepare(`
|
|
894
|
+
SELECT
|
|
895
|
+
task_id,
|
|
896
|
+
runtime,
|
|
897
|
+
task_kind,
|
|
898
|
+
source_id,
|
|
899
|
+
requester_session_key,
|
|
900
|
+
owner_key,
|
|
901
|
+
scope_kind,
|
|
902
|
+
child_session_key,
|
|
903
|
+
parent_flow_id,
|
|
904
|
+
parent_task_id,
|
|
905
|
+
agent_id,
|
|
906
|
+
run_id,
|
|
907
|
+
label,
|
|
908
|
+
task,
|
|
909
|
+
status,
|
|
910
|
+
delivery_status,
|
|
911
|
+
notify_policy,
|
|
912
|
+
created_at,
|
|
913
|
+
started_at,
|
|
914
|
+
ended_at,
|
|
915
|
+
last_event_at,
|
|
916
|
+
cleanup_after,
|
|
917
|
+
error,
|
|
918
|
+
progress_summary,
|
|
919
|
+
terminal_summary,
|
|
920
|
+
terminal_outcome
|
|
921
|
+
FROM task_runs
|
|
922
|
+
ORDER BY created_at ASC, task_id ASC
|
|
923
|
+
`),
|
|
924
|
+
selectAllDeliveryStates: db.prepare(`
|
|
925
|
+
SELECT
|
|
926
|
+
task_id,
|
|
927
|
+
requester_origin_json,
|
|
928
|
+
last_notified_event_at
|
|
929
|
+
FROM task_delivery_state
|
|
930
|
+
ORDER BY task_id ASC
|
|
931
|
+
`),
|
|
932
|
+
upsertRow: db.prepare(`
|
|
933
|
+
INSERT INTO task_runs (
|
|
934
|
+
task_id,
|
|
935
|
+
runtime,
|
|
936
|
+
task_kind,
|
|
937
|
+
source_id,
|
|
938
|
+
requester_session_key,
|
|
939
|
+
owner_key,
|
|
940
|
+
scope_kind,
|
|
941
|
+
child_session_key,
|
|
942
|
+
parent_flow_id,
|
|
943
|
+
parent_task_id,
|
|
944
|
+
agent_id,
|
|
945
|
+
run_id,
|
|
946
|
+
label,
|
|
947
|
+
task,
|
|
948
|
+
status,
|
|
949
|
+
delivery_status,
|
|
950
|
+
notify_policy,
|
|
951
|
+
created_at,
|
|
952
|
+
started_at,
|
|
953
|
+
ended_at,
|
|
954
|
+
last_event_at,
|
|
955
|
+
cleanup_after,
|
|
956
|
+
error,
|
|
957
|
+
progress_summary,
|
|
958
|
+
terminal_summary,
|
|
959
|
+
terminal_outcome
|
|
960
|
+
) VALUES (
|
|
961
|
+
@task_id,
|
|
962
|
+
@runtime,
|
|
963
|
+
@task_kind,
|
|
964
|
+
@source_id,
|
|
965
|
+
@requester_session_key,
|
|
966
|
+
@owner_key,
|
|
967
|
+
@scope_kind,
|
|
968
|
+
@child_session_key,
|
|
969
|
+
@parent_flow_id,
|
|
970
|
+
@parent_task_id,
|
|
971
|
+
@agent_id,
|
|
972
|
+
@run_id,
|
|
973
|
+
@label,
|
|
974
|
+
@task,
|
|
975
|
+
@status,
|
|
976
|
+
@delivery_status,
|
|
977
|
+
@notify_policy,
|
|
978
|
+
@created_at,
|
|
979
|
+
@started_at,
|
|
980
|
+
@ended_at,
|
|
981
|
+
@last_event_at,
|
|
982
|
+
@cleanup_after,
|
|
983
|
+
@error,
|
|
984
|
+
@progress_summary,
|
|
985
|
+
@terminal_summary,
|
|
986
|
+
@terminal_outcome
|
|
987
|
+
)
|
|
988
|
+
ON CONFLICT(task_id) DO UPDATE SET
|
|
989
|
+
runtime = excluded.runtime,
|
|
990
|
+
task_kind = excluded.task_kind,
|
|
991
|
+
source_id = excluded.source_id,
|
|
992
|
+
requester_session_key = excluded.requester_session_key,
|
|
993
|
+
owner_key = excluded.owner_key,
|
|
994
|
+
scope_kind = excluded.scope_kind,
|
|
995
|
+
child_session_key = excluded.child_session_key,
|
|
996
|
+
parent_flow_id = excluded.parent_flow_id,
|
|
997
|
+
parent_task_id = excluded.parent_task_id,
|
|
998
|
+
agent_id = excluded.agent_id,
|
|
999
|
+
run_id = excluded.run_id,
|
|
1000
|
+
label = excluded.label,
|
|
1001
|
+
task = excluded.task,
|
|
1002
|
+
status = excluded.status,
|
|
1003
|
+
delivery_status = excluded.delivery_status,
|
|
1004
|
+
notify_policy = excluded.notify_policy,
|
|
1005
|
+
created_at = excluded.created_at,
|
|
1006
|
+
started_at = excluded.started_at,
|
|
1007
|
+
ended_at = excluded.ended_at,
|
|
1008
|
+
last_event_at = excluded.last_event_at,
|
|
1009
|
+
cleanup_after = excluded.cleanup_after,
|
|
1010
|
+
error = excluded.error,
|
|
1011
|
+
progress_summary = excluded.progress_summary,
|
|
1012
|
+
terminal_summary = excluded.terminal_summary,
|
|
1013
|
+
terminal_outcome = excluded.terminal_outcome
|
|
1014
|
+
`),
|
|
1015
|
+
replaceDeliveryState: db.prepare(`
|
|
1016
|
+
INSERT OR REPLACE INTO task_delivery_state (
|
|
1017
|
+
task_id,
|
|
1018
|
+
requester_origin_json,
|
|
1019
|
+
last_notified_event_at
|
|
1020
|
+
) VALUES (
|
|
1021
|
+
@task_id,
|
|
1022
|
+
@requester_origin_json,
|
|
1023
|
+
@last_notified_event_at
|
|
1024
|
+
)
|
|
1025
|
+
`),
|
|
1026
|
+
deleteRow: db.prepare(`DELETE FROM task_runs WHERE task_id = ?`),
|
|
1027
|
+
deleteDeliveryState: db.prepare(`DELETE FROM task_delivery_state WHERE task_id = ?`),
|
|
1028
|
+
clearRows: db.prepare(`DELETE FROM task_runs`),
|
|
1029
|
+
clearDeliveryStates: db.prepare(`DELETE FROM task_delivery_state`)
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
function hasTaskRunsColumn(db, columnName) {
|
|
1033
|
+
return db.prepare(`PRAGMA table_info(task_runs)`).all().some((row) => row.name === columnName);
|
|
1034
|
+
}
|
|
1035
|
+
function migrateLegacyOwnerColumns(db) {
|
|
1036
|
+
if (!hasTaskRunsColumn(db, "owner_key")) db.exec(`ALTER TABLE task_runs ADD COLUMN owner_key TEXT;`);
|
|
1037
|
+
if (!hasTaskRunsColumn(db, "requester_session_key")) db.exec(`ALTER TABLE task_runs ADD COLUMN requester_session_key TEXT;`);
|
|
1038
|
+
if (!hasTaskRunsColumn(db, "scope_kind")) db.exec(`ALTER TABLE task_runs ADD COLUMN scope_kind TEXT NOT NULL DEFAULT 'session';`);
|
|
1039
|
+
if (hasTaskRunsColumn(db, "requester_session_key")) db.exec(`
|
|
1040
|
+
UPDATE task_runs
|
|
1041
|
+
SET owner_key = requester_session_key
|
|
1042
|
+
WHERE owner_key IS NULL
|
|
1043
|
+
`);
|
|
1044
|
+
db.exec(`
|
|
1045
|
+
UPDATE task_runs
|
|
1046
|
+
SET owner_key = CASE
|
|
1047
|
+
WHEN trim(COALESCE(owner_key, '')) <> '' THEN trim(owner_key)
|
|
1048
|
+
ELSE 'system:' || runtime || ':' || COALESCE(NULLIF(source_id, ''), task_id)
|
|
1049
|
+
END
|
|
1050
|
+
`);
|
|
1051
|
+
db.exec(`
|
|
1052
|
+
UPDATE task_runs
|
|
1053
|
+
SET scope_kind = CASE
|
|
1054
|
+
WHEN scope_kind = 'system' THEN 'system'
|
|
1055
|
+
WHEN owner_key LIKE 'system:%' THEN 'system'
|
|
1056
|
+
ELSE 'session'
|
|
1057
|
+
END
|
|
1058
|
+
`);
|
|
1059
|
+
db.exec(`
|
|
1060
|
+
UPDATE task_runs
|
|
1061
|
+
SET requester_session_key = CASE
|
|
1062
|
+
WHEN scope_kind = 'system' THEN ''
|
|
1063
|
+
WHEN trim(COALESCE(requester_session_key, '')) <> '' THEN trim(requester_session_key)
|
|
1064
|
+
ELSE owner_key
|
|
1065
|
+
END
|
|
1066
|
+
`);
|
|
1067
|
+
}
|
|
1068
|
+
function ensureSchema(db) {
|
|
1069
|
+
db.exec(`
|
|
1070
|
+
CREATE TABLE IF NOT EXISTS task_runs (
|
|
1071
|
+
task_id TEXT PRIMARY KEY,
|
|
1072
|
+
runtime TEXT NOT NULL,
|
|
1073
|
+
task_kind TEXT,
|
|
1074
|
+
source_id TEXT,
|
|
1075
|
+
requester_session_key TEXT,
|
|
1076
|
+
owner_key TEXT NOT NULL,
|
|
1077
|
+
scope_kind TEXT NOT NULL,
|
|
1078
|
+
child_session_key TEXT,
|
|
1079
|
+
parent_flow_id TEXT,
|
|
1080
|
+
parent_task_id TEXT,
|
|
1081
|
+
agent_id TEXT,
|
|
1082
|
+
run_id TEXT,
|
|
1083
|
+
label TEXT,
|
|
1084
|
+
task TEXT NOT NULL,
|
|
1085
|
+
status TEXT NOT NULL,
|
|
1086
|
+
delivery_status TEXT NOT NULL,
|
|
1087
|
+
notify_policy TEXT NOT NULL,
|
|
1088
|
+
created_at INTEGER NOT NULL,
|
|
1089
|
+
started_at INTEGER,
|
|
1090
|
+
ended_at INTEGER,
|
|
1091
|
+
last_event_at INTEGER,
|
|
1092
|
+
cleanup_after INTEGER,
|
|
1093
|
+
error TEXT,
|
|
1094
|
+
progress_summary TEXT,
|
|
1095
|
+
terminal_summary TEXT,
|
|
1096
|
+
terminal_outcome TEXT
|
|
1097
|
+
);
|
|
1098
|
+
`);
|
|
1099
|
+
migrateLegacyOwnerColumns(db);
|
|
1100
|
+
if (!hasTaskRunsColumn(db, "task_kind")) db.exec(`ALTER TABLE task_runs ADD COLUMN task_kind TEXT;`);
|
|
1101
|
+
if (!hasTaskRunsColumn(db, "parent_flow_id")) db.exec(`ALTER TABLE task_runs ADD COLUMN parent_flow_id TEXT;`);
|
|
1102
|
+
db.exec(`
|
|
1103
|
+
CREATE TABLE IF NOT EXISTS task_delivery_state (
|
|
1104
|
+
task_id TEXT PRIMARY KEY,
|
|
1105
|
+
requester_origin_json TEXT,
|
|
1106
|
+
last_notified_event_at INTEGER
|
|
1107
|
+
);
|
|
1108
|
+
`);
|
|
1109
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_task_runs_run_id ON task_runs(run_id);`);
|
|
1110
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_task_runs_status ON task_runs(status);`);
|
|
1111
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_task_runs_runtime_status ON task_runs(runtime, status);`);
|
|
1112
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_task_runs_cleanup_after ON task_runs(cleanup_after);`);
|
|
1113
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_task_runs_last_event_at ON task_runs(last_event_at);`);
|
|
1114
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_task_runs_owner_key ON task_runs(owner_key);`);
|
|
1115
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_task_runs_parent_flow_id ON task_runs(parent_flow_id);`);
|
|
1116
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_task_runs_child_session_key ON task_runs(child_session_key);`);
|
|
1117
|
+
}
|
|
1118
|
+
function ensureTaskRegistryPermissions(pathname) {
|
|
1119
|
+
const dir = resolveTaskRegistryDir(process.env);
|
|
1120
|
+
mkdirSync(dir, {
|
|
1121
|
+
recursive: true,
|
|
1122
|
+
mode: TASK_REGISTRY_DIR_MODE
|
|
1123
|
+
});
|
|
1124
|
+
chmodSync(dir, TASK_REGISTRY_DIR_MODE);
|
|
1125
|
+
for (const suffix of TASK_REGISTRY_SIDECAR_SUFFIXES) {
|
|
1126
|
+
const candidate = `${pathname}${suffix}`;
|
|
1127
|
+
if (!existsSync(candidate)) continue;
|
|
1128
|
+
chmodSync(candidate, TASK_REGISTRY_FILE_MODE);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
function openTaskRegistryDatabase() {
|
|
1132
|
+
const pathname = resolveTaskRegistrySqlitePath(process.env);
|
|
1133
|
+
if (cachedDatabase && cachedDatabase.path === pathname) return cachedDatabase;
|
|
1134
|
+
if (cachedDatabase) {
|
|
1135
|
+
cachedDatabase.db.close();
|
|
1136
|
+
cachedDatabase = null;
|
|
1137
|
+
}
|
|
1138
|
+
ensureTaskRegistryPermissions(pathname);
|
|
1139
|
+
const { DatabaseSync } = requireNodeSqlite();
|
|
1140
|
+
const db = new DatabaseSync(pathname);
|
|
1141
|
+
db.exec(`PRAGMA journal_mode = WAL;`);
|
|
1142
|
+
db.exec(`PRAGMA synchronous = NORMAL;`);
|
|
1143
|
+
db.exec(`PRAGMA busy_timeout = 5000;`);
|
|
1144
|
+
ensureSchema(db);
|
|
1145
|
+
ensureTaskRegistryPermissions(pathname);
|
|
1146
|
+
cachedDatabase = {
|
|
1147
|
+
db,
|
|
1148
|
+
path: pathname,
|
|
1149
|
+
statements: createStatements(db)
|
|
1150
|
+
};
|
|
1151
|
+
return cachedDatabase;
|
|
1152
|
+
}
|
|
1153
|
+
function withWriteTransaction(write) {
|
|
1154
|
+
const { db, path, statements } = openTaskRegistryDatabase();
|
|
1155
|
+
db.exec("BEGIN IMMEDIATE");
|
|
1156
|
+
try {
|
|
1157
|
+
write(statements);
|
|
1158
|
+
db.exec("COMMIT");
|
|
1159
|
+
ensureTaskRegistryPermissions(path);
|
|
1160
|
+
} catch (error) {
|
|
1161
|
+
db.exec("ROLLBACK");
|
|
1162
|
+
throw error;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
function loadTaskRegistryStateFromSqlite() {
|
|
1166
|
+
const { statements } = openTaskRegistryDatabase();
|
|
1167
|
+
const taskRows = statements.selectAll.all();
|
|
1168
|
+
const deliveryRows = statements.selectAllDeliveryStates.all();
|
|
1169
|
+
return {
|
|
1170
|
+
tasks: new Map(taskRows.map((row) => [row.task_id, rowToTaskRecord(row)])),
|
|
1171
|
+
deliveryStates: new Map(deliveryRows.map((row) => [row.task_id, rowToTaskDeliveryState(row)]))
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
function saveTaskRegistryStateToSqlite(snapshot) {
|
|
1175
|
+
withWriteTransaction((statements) => {
|
|
1176
|
+
statements.clearDeliveryStates.run();
|
|
1177
|
+
statements.clearRows.run();
|
|
1178
|
+
for (const task of snapshot.tasks.values()) statements.upsertRow.run(bindTaskRecordBase(task));
|
|
1179
|
+
for (const state of snapshot.deliveryStates.values()) statements.replaceDeliveryState.run(bindTaskDeliveryState(state));
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
function upsertTaskRegistryRecordToSqlite(task) {
|
|
1183
|
+
openTaskRegistryDatabase().statements.upsertRow.run(bindTaskRecordBase(task));
|
|
1184
|
+
}
|
|
1185
|
+
function upsertTaskWithDeliveryStateToSqlite(params) {
|
|
1186
|
+
withWriteTransaction((statements) => {
|
|
1187
|
+
statements.upsertRow.run(bindTaskRecordBase(params.task));
|
|
1188
|
+
if (params.deliveryState) statements.replaceDeliveryState.run(bindTaskDeliveryState(params.deliveryState));
|
|
1189
|
+
else statements.deleteDeliveryState.run(params.task.taskId);
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
function deleteTaskRegistryRecordFromSqlite(taskId) {
|
|
1193
|
+
const store = openTaskRegistryDatabase();
|
|
1194
|
+
store.statements.deleteRow.run(taskId);
|
|
1195
|
+
store.statements.deleteDeliveryState.run(taskId);
|
|
1196
|
+
}
|
|
1197
|
+
function deleteTaskAndDeliveryStateFromSqlite(taskId) {
|
|
1198
|
+
withWriteTransaction((statements) => {
|
|
1199
|
+
statements.deleteRow.run(taskId);
|
|
1200
|
+
statements.deleteDeliveryState.run(taskId);
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
function upsertTaskDeliveryStateToSqlite(state) {
|
|
1204
|
+
openTaskRegistryDatabase().statements.replaceDeliveryState.run(bindTaskDeliveryState(state));
|
|
1205
|
+
}
|
|
1206
|
+
function deleteTaskDeliveryStateFromSqlite(taskId) {
|
|
1207
|
+
openTaskRegistryDatabase().statements.deleteDeliveryState.run(taskId);
|
|
1208
|
+
}
|
|
1209
|
+
function closeTaskRegistrySqliteStore() {
|
|
1210
|
+
if (!cachedDatabase) return;
|
|
1211
|
+
cachedDatabase.db.close();
|
|
1212
|
+
cachedDatabase = null;
|
|
1213
|
+
}
|
|
1214
|
+
let configuredTaskRegistryStore = {
|
|
1215
|
+
loadSnapshot: loadTaskRegistryStateFromSqlite,
|
|
1216
|
+
saveSnapshot: saveTaskRegistryStateToSqlite,
|
|
1217
|
+
upsertTaskWithDeliveryState: upsertTaskWithDeliveryStateToSqlite,
|
|
1218
|
+
upsertTask: upsertTaskRegistryRecordToSqlite,
|
|
1219
|
+
deleteTaskWithDeliveryState: deleteTaskAndDeliveryStateFromSqlite,
|
|
1220
|
+
deleteTask: deleteTaskRegistryRecordFromSqlite,
|
|
1221
|
+
upsertDeliveryState: upsertTaskDeliveryStateToSqlite,
|
|
1222
|
+
deleteDeliveryState: deleteTaskDeliveryStateFromSqlite,
|
|
1223
|
+
close: closeTaskRegistrySqliteStore
|
|
1224
|
+
};
|
|
1225
|
+
let configuredTaskRegistryObservers = null;
|
|
1226
|
+
function getTaskRegistryStore() {
|
|
1227
|
+
return configuredTaskRegistryStore;
|
|
1228
|
+
}
|
|
1229
|
+
function getTaskRegistryObservers() {
|
|
1230
|
+
return configuredTaskRegistryObservers;
|
|
1231
|
+
}
|
|
1232
|
+
//#endregion
|
|
1233
|
+
//#region src/tasks/task-registry.ts
|
|
1234
|
+
const log = createSubsystemLogger("tasks/registry");
|
|
1235
|
+
const DEFAULT_TASK_RETENTION_MS = 10080 * 6e4;
|
|
1236
|
+
const tasks = /* @__PURE__ */ new Map();
|
|
1237
|
+
const taskDeliveryStates = /* @__PURE__ */ new Map();
|
|
1238
|
+
const taskIdsByRunId = /* @__PURE__ */ new Map();
|
|
1239
|
+
const taskIdsByOwnerKey = /* @__PURE__ */ new Map();
|
|
1240
|
+
const taskIdsByParentFlowId = /* @__PURE__ */ new Map();
|
|
1241
|
+
const taskIdsByRelatedSessionKey = /* @__PURE__ */ new Map();
|
|
1242
|
+
const tasksWithPendingDelivery = /* @__PURE__ */ new Set();
|
|
1243
|
+
let listenerStarted = false;
|
|
1244
|
+
let restoreAttempted = false;
|
|
1245
|
+
const TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY = Symbol.for("genesis.taskRegistry.deliveryRuntimeOverride");
|
|
1246
|
+
const TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY = Symbol.for("genesis.taskRegistry.controlRuntimeOverride");
|
|
1247
|
+
const require = createRequire(import.meta.url);
|
|
1248
|
+
const TASK_REGISTRY_CONTROL_RUNTIME_CANDIDATES = ["./task-registry-control.runtime.js", "./task-registry-control.runtime.ts"];
|
|
1249
|
+
let deliveryRuntimePromise = null;
|
|
1250
|
+
let controlRuntimePromise = null;
|
|
1251
|
+
var ParentFlowLinkError = class extends Error {
|
|
1252
|
+
constructor(code, message, details) {
|
|
1253
|
+
super(message);
|
|
1254
|
+
this.code = code;
|
|
1255
|
+
this.details = details;
|
|
1256
|
+
this.name = "ParentFlowLinkError";
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
function isParentFlowLinkError(error) {
|
|
1260
|
+
return error instanceof ParentFlowLinkError;
|
|
1261
|
+
}
|
|
1262
|
+
function isActiveTaskStatus(status) {
|
|
1263
|
+
return status === "queued" || status === "running";
|
|
1264
|
+
}
|
|
1265
|
+
function isTerminalFlowStatus(status) {
|
|
1266
|
+
return status === "succeeded" || status === "failed" || status === "cancelled" || status === "lost";
|
|
1267
|
+
}
|
|
1268
|
+
function assertTaskOwner(params) {
|
|
1269
|
+
if (!params.ownerKey.trim() && params.scopeKind !== "system") throw new Error("Task ownerKey is required.");
|
|
1270
|
+
}
|
|
1271
|
+
function assertParentFlowLinkAllowed(params) {
|
|
1272
|
+
const flowId = params.parentFlowId?.trim();
|
|
1273
|
+
if (!flowId) return;
|
|
1274
|
+
if (params.scopeKind !== "session") throw new ParentFlowLinkError("scope_kind_not_session", "Only session-scoped tasks can link to flows.", { flowId });
|
|
1275
|
+
const flow = getTaskFlowById(flowId);
|
|
1276
|
+
if (!flow) throw new ParentFlowLinkError("parent_flow_not_found", `Parent flow not found: ${flowId}`, { flowId });
|
|
1277
|
+
if (normalizeOptionalString(flow.ownerKey) !== normalizeOptionalString(params.ownerKey)) throw new ParentFlowLinkError("owner_key_mismatch", "Task ownerKey must match parent flow ownerKey.", { flowId });
|
|
1278
|
+
if (flow.cancelRequestedAt != null) throw new ParentFlowLinkError("cancel_requested", "Parent flow cancellation has already been requested.", {
|
|
1279
|
+
flowId,
|
|
1280
|
+
status: flow.status
|
|
1281
|
+
});
|
|
1282
|
+
if (isTerminalFlowStatus(flow.status)) throw new ParentFlowLinkError("terminal", `Parent flow is already ${flow.status}.`, {
|
|
1283
|
+
flowId,
|
|
1284
|
+
status: flow.status
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
function cloneTaskRecord(record) {
|
|
1288
|
+
return { ...record };
|
|
1289
|
+
}
|
|
1290
|
+
function cloneTaskDeliveryState(state) {
|
|
1291
|
+
return {
|
|
1292
|
+
...state,
|
|
1293
|
+
...state.requesterOrigin ? { requesterOrigin: { ...state.requesterOrigin } } : {}
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
function snapshotTaskRecords(source) {
|
|
1297
|
+
return [...source.values()].map((record) => cloneTaskRecord(record));
|
|
1298
|
+
}
|
|
1299
|
+
function emitTaskRegistryObserverEvent(createEvent) {
|
|
1300
|
+
const observers = getTaskRegistryObservers();
|
|
1301
|
+
if (!observers?.onEvent) return;
|
|
1302
|
+
try {
|
|
1303
|
+
observers.onEvent(createEvent());
|
|
1304
|
+
} catch (error) {
|
|
1305
|
+
log.warn("Task registry observer failed", {
|
|
1306
|
+
event: "task-registry",
|
|
1307
|
+
error
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
function persistTaskUpsert(task) {
|
|
1312
|
+
const store = getTaskRegistryStore();
|
|
1313
|
+
const deliveryState = taskDeliveryStates.get(task.taskId);
|
|
1314
|
+
if (store.upsertTaskWithDeliveryState) {
|
|
1315
|
+
store.upsertTaskWithDeliveryState({
|
|
1316
|
+
task,
|
|
1317
|
+
...deliveryState ? { deliveryState } : {}
|
|
1318
|
+
});
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
if (store.upsertTask) {
|
|
1322
|
+
store.upsertTask(task);
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
store.saveSnapshot({
|
|
1326
|
+
tasks,
|
|
1327
|
+
deliveryStates: taskDeliveryStates
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1330
|
+
function persistTaskDelete(taskId) {
|
|
1331
|
+
const store = getTaskRegistryStore();
|
|
1332
|
+
if (store.deleteTaskWithDeliveryState) {
|
|
1333
|
+
store.deleteTaskWithDeliveryState(taskId);
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
if (store.deleteTask) {
|
|
1337
|
+
store.deleteTask(taskId);
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
store.saveSnapshot({
|
|
1341
|
+
tasks,
|
|
1342
|
+
deliveryStates: taskDeliveryStates
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
function persistTaskDeliveryStateUpsert(state) {
|
|
1346
|
+
const store = getTaskRegistryStore();
|
|
1347
|
+
if (store.upsertDeliveryState) {
|
|
1348
|
+
store.upsertDeliveryState(state);
|
|
1349
|
+
return;
|
|
1350
|
+
}
|
|
1351
|
+
store.saveSnapshot({
|
|
1352
|
+
tasks,
|
|
1353
|
+
deliveryStates: taskDeliveryStates
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
function persistTaskDeliveryStateDelete(taskId) {
|
|
1357
|
+
const store = getTaskRegistryStore();
|
|
1358
|
+
if (store.deleteDeliveryState) {
|
|
1359
|
+
store.deleteDeliveryState(taskId);
|
|
1360
|
+
return;
|
|
1361
|
+
}
|
|
1362
|
+
store.saveSnapshot({
|
|
1363
|
+
tasks,
|
|
1364
|
+
deliveryStates: taskDeliveryStates
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
function ensureDeliveryStatus(params) {
|
|
1368
|
+
if (params.scopeKind === "system") return "not_applicable";
|
|
1369
|
+
return params.ownerKey.trim() ? "pending" : "parent_missing";
|
|
1370
|
+
}
|
|
1371
|
+
function ensureNotifyPolicy(params) {
|
|
1372
|
+
if (params.notifyPolicy) return params.notifyPolicy;
|
|
1373
|
+
return (params.deliveryStatus ?? ensureDeliveryStatus({
|
|
1374
|
+
ownerKey: params.ownerKey,
|
|
1375
|
+
scopeKind: params.scopeKind
|
|
1376
|
+
})) === "not_applicable" ? "silent" : "done_only";
|
|
1377
|
+
}
|
|
1378
|
+
function resolveTaskScopeKind(params) {
|
|
1379
|
+
if (params.scopeKind) return params.scopeKind;
|
|
1380
|
+
return params.requesterSessionKey.trim() ? "session" : "system";
|
|
1381
|
+
}
|
|
1382
|
+
function resolveTaskRequesterSessionKey(params) {
|
|
1383
|
+
const requesterSessionKey = params.requesterSessionKey?.trim();
|
|
1384
|
+
if (requesterSessionKey) return requesterSessionKey;
|
|
1385
|
+
if (params.scopeKind === "system") return "";
|
|
1386
|
+
return params.ownerKey?.trim() ?? "";
|
|
1387
|
+
}
|
|
1388
|
+
function resolveTaskOwnerKey(params) {
|
|
1389
|
+
return params.ownerKey?.trim() || params.requesterSessionKey.trim();
|
|
1390
|
+
}
|
|
1391
|
+
function normalizeTaskSummary(value) {
|
|
1392
|
+
return value?.replace(/\s+/g, " ").trim() || void 0;
|
|
1393
|
+
}
|
|
1394
|
+
function normalizeTaskStatus(value) {
|
|
1395
|
+
return value === "running" || value === "queued" || value === "succeeded" || value === "failed" || value === "timed_out" || value === "cancelled" || value === "lost" ? value : "queued";
|
|
1396
|
+
}
|
|
1397
|
+
function normalizeTaskTerminalOutcome(value) {
|
|
1398
|
+
return value === "succeeded" || value === "blocked" ? value : void 0;
|
|
1399
|
+
}
|
|
1400
|
+
function resolveTaskTerminalOutcome(params) {
|
|
1401
|
+
const normalized = normalizeTaskTerminalOutcome(params.terminalOutcome);
|
|
1402
|
+
if (normalized) return normalized;
|
|
1403
|
+
return params.status === "succeeded" ? "succeeded" : void 0;
|
|
1404
|
+
}
|
|
1405
|
+
function appendTaskEvent(event) {
|
|
1406
|
+
const summary = normalizeTaskSummary(event.summary);
|
|
1407
|
+
return {
|
|
1408
|
+
at: event.at,
|
|
1409
|
+
kind: event.kind,
|
|
1410
|
+
...summary ? { summary } : {}
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
function loadTaskRegistryDeliveryRuntime() {
|
|
1414
|
+
const deliveryRuntimeOverride = globalThis[TASK_REGISTRY_DELIVERY_RUNTIME_OVERRIDE_KEY];
|
|
1415
|
+
if (deliveryRuntimeOverride) return Promise.resolve(deliveryRuntimeOverride);
|
|
1416
|
+
deliveryRuntimePromise ??= import("./task-registry-delivery-runtime-DD1_7xUF.js");
|
|
1417
|
+
return deliveryRuntimePromise;
|
|
1418
|
+
}
|
|
1419
|
+
function loadTaskRegistryControlRuntime() {
|
|
1420
|
+
const controlRuntimeOverride = globalThis[TASK_REGISTRY_CONTROL_RUNTIME_OVERRIDE_KEY];
|
|
1421
|
+
if (controlRuntimeOverride) return Promise.resolve(controlRuntimeOverride);
|
|
1422
|
+
controlRuntimePromise ??= Promise.resolve().then(() => {
|
|
1423
|
+
for (const candidate of TASK_REGISTRY_CONTROL_RUNTIME_CANDIDATES) try {
|
|
1424
|
+
return require(candidate);
|
|
1425
|
+
} catch {}
|
|
1426
|
+
throw new Error("Failed to load task registry control runtime.");
|
|
1427
|
+
});
|
|
1428
|
+
return controlRuntimePromise;
|
|
1429
|
+
}
|
|
1430
|
+
function addRunIdIndex(taskId, runId) {
|
|
1431
|
+
const trimmed = runId?.trim();
|
|
1432
|
+
if (!trimmed) return;
|
|
1433
|
+
let ids = taskIdsByRunId.get(trimmed);
|
|
1434
|
+
if (!ids) {
|
|
1435
|
+
ids = /* @__PURE__ */ new Set();
|
|
1436
|
+
taskIdsByRunId.set(trimmed, ids);
|
|
1437
|
+
}
|
|
1438
|
+
ids.add(taskId);
|
|
1439
|
+
}
|
|
1440
|
+
function addIndexedKey(index, key, taskId) {
|
|
1441
|
+
let ids = index.get(key);
|
|
1442
|
+
if (!ids) {
|
|
1443
|
+
ids = /* @__PURE__ */ new Set();
|
|
1444
|
+
index.set(key, ids);
|
|
1445
|
+
}
|
|
1446
|
+
ids.add(taskId);
|
|
1447
|
+
}
|
|
1448
|
+
function deleteIndexedKey(index, key, taskId) {
|
|
1449
|
+
const ids = index.get(key);
|
|
1450
|
+
if (!ids) return;
|
|
1451
|
+
ids.delete(taskId);
|
|
1452
|
+
if (ids.size === 0) index.delete(key);
|
|
1453
|
+
}
|
|
1454
|
+
function getTaskRelatedSessionIndexKeys(task) {
|
|
1455
|
+
return [...new Set([normalizeOptionalString(task.ownerKey), normalizeOptionalString(task.childSessionKey)].filter(Boolean))];
|
|
1456
|
+
}
|
|
1457
|
+
function addOwnerKeyIndex(taskId, task) {
|
|
1458
|
+
const key = normalizeOptionalString(task.ownerKey);
|
|
1459
|
+
if (!key) return;
|
|
1460
|
+
addIndexedKey(taskIdsByOwnerKey, key, taskId);
|
|
1461
|
+
}
|
|
1462
|
+
function deleteOwnerKeyIndex(taskId, task) {
|
|
1463
|
+
const key = normalizeOptionalString(task.ownerKey);
|
|
1464
|
+
if (!key) return;
|
|
1465
|
+
deleteIndexedKey(taskIdsByOwnerKey, key, taskId);
|
|
1466
|
+
}
|
|
1467
|
+
function addParentFlowIdIndex(taskId, task) {
|
|
1468
|
+
const key = task.parentFlowId?.trim();
|
|
1469
|
+
if (!key) return;
|
|
1470
|
+
addIndexedKey(taskIdsByParentFlowId, key, taskId);
|
|
1471
|
+
}
|
|
1472
|
+
function deleteParentFlowIdIndex(taskId, task) {
|
|
1473
|
+
const key = task.parentFlowId?.trim();
|
|
1474
|
+
if (!key) return;
|
|
1475
|
+
deleteIndexedKey(taskIdsByParentFlowId, key, taskId);
|
|
1476
|
+
}
|
|
1477
|
+
function addRelatedSessionKeyIndex(taskId, task) {
|
|
1478
|
+
for (const sessionKey of getTaskRelatedSessionIndexKeys(task)) addIndexedKey(taskIdsByRelatedSessionKey, sessionKey, taskId);
|
|
1479
|
+
}
|
|
1480
|
+
function deleteRelatedSessionKeyIndex(taskId, task) {
|
|
1481
|
+
for (const sessionKey of getTaskRelatedSessionIndexKeys(task)) deleteIndexedKey(taskIdsByRelatedSessionKey, sessionKey, taskId);
|
|
1482
|
+
}
|
|
1483
|
+
function rebuildRunIdIndex() {
|
|
1484
|
+
taskIdsByRunId.clear();
|
|
1485
|
+
for (const [taskId, task] of tasks.entries()) addRunIdIndex(taskId, task.runId);
|
|
1486
|
+
}
|
|
1487
|
+
function rebuildOwnerKeyIndex() {
|
|
1488
|
+
taskIdsByOwnerKey.clear();
|
|
1489
|
+
for (const [taskId, task] of tasks.entries()) addOwnerKeyIndex(taskId, task);
|
|
1490
|
+
}
|
|
1491
|
+
function rebuildParentFlowIdIndex() {
|
|
1492
|
+
taskIdsByParentFlowId.clear();
|
|
1493
|
+
for (const [taskId, task] of tasks.entries()) addParentFlowIdIndex(taskId, task);
|
|
1494
|
+
}
|
|
1495
|
+
function rebuildRelatedSessionKeyIndex() {
|
|
1496
|
+
taskIdsByRelatedSessionKey.clear();
|
|
1497
|
+
for (const [taskId, task] of tasks.entries()) addRelatedSessionKeyIndex(taskId, task);
|
|
1498
|
+
}
|
|
1499
|
+
function getTasksByRunId(runId) {
|
|
1500
|
+
const ids = taskIdsByRunId.get(runId.trim());
|
|
1501
|
+
if (!ids || ids.size === 0) return [];
|
|
1502
|
+
return [...ids].map((taskId) => tasks.get(taskId)).filter((task) => Boolean(task));
|
|
1503
|
+
}
|
|
1504
|
+
function taskRunScopeKey(task) {
|
|
1505
|
+
return [
|
|
1506
|
+
task.runtime,
|
|
1507
|
+
task.scopeKind,
|
|
1508
|
+
normalizeOptionalString(task.ownerKey) ?? "",
|
|
1509
|
+
normalizeOptionalString(task.childSessionKey) ?? ""
|
|
1510
|
+
].join("\0");
|
|
1511
|
+
}
|
|
1512
|
+
function getTasksByRunScope(params) {
|
|
1513
|
+
const matches = getTasksByRunId(params.runId).filter((task) => !params.runtime || task.runtime === params.runtime);
|
|
1514
|
+
const sessionKey = normalizeOptionalString(params.sessionKey);
|
|
1515
|
+
if (sessionKey) {
|
|
1516
|
+
const childMatches = matches.filter((task) => normalizeOptionalString(task.childSessionKey) === sessionKey);
|
|
1517
|
+
if (childMatches.length > 0) return childMatches;
|
|
1518
|
+
return matches.filter((task) => task.scopeKind === "session" && normalizeOptionalString(task.ownerKey) === sessionKey);
|
|
1519
|
+
}
|
|
1520
|
+
return new Set(matches.map((task) => taskRunScopeKey(task))).size <= 1 ? matches : [];
|
|
1521
|
+
}
|
|
1522
|
+
function getPeerTasksForDelivery(task) {
|
|
1523
|
+
if (!task.runId?.trim()) return [];
|
|
1524
|
+
return getTasksByRunId(task.runId).filter((candidate) => candidate.runtime === task.runtime && candidate.scopeKind === task.scopeKind && (normalizeOptionalString(candidate.ownerKey) ?? "") === (normalizeOptionalString(task.ownerKey) ?? "") && (normalizeOptionalString(candidate.childSessionKey) ?? "") === (normalizeOptionalString(task.childSessionKey) ?? ""));
|
|
1525
|
+
}
|
|
1526
|
+
function taskLookupPriority(task) {
|
|
1527
|
+
return task.runtime === "cli" ? 1 : 0;
|
|
1528
|
+
}
|
|
1529
|
+
function pickPreferredRunIdTask(matches) {
|
|
1530
|
+
return [...matches].toSorted((left, right) => {
|
|
1531
|
+
const priorityDiff = taskLookupPriority(left) - taskLookupPriority(right);
|
|
1532
|
+
if (priorityDiff !== 0) return priorityDiff;
|
|
1533
|
+
return left.createdAt - right.createdAt;
|
|
1534
|
+
})[0];
|
|
1535
|
+
}
|
|
1536
|
+
function compareTasksNewestFirst(left, right) {
|
|
1537
|
+
const createdAtDiff = right.createdAt - left.createdAt;
|
|
1538
|
+
if (createdAtDiff !== 0) return createdAtDiff;
|
|
1539
|
+
return (right.insertionIndex ?? 0) - (left.insertionIndex ?? 0);
|
|
1540
|
+
}
|
|
1541
|
+
function findExistingTaskForCreate(params) {
|
|
1542
|
+
const runId = params.runId?.trim();
|
|
1543
|
+
const runScopeMatches = runId ? getTasksByRunId(runId).filter((task) => task.runtime === params.runtime && task.scopeKind === params.scopeKind && (normalizeOptionalString(task.ownerKey) ?? "") === (normalizeOptionalString(params.ownerKey) ?? "") && (normalizeOptionalString(task.childSessionKey) ?? "") === (normalizeOptionalString(params.childSessionKey) ?? "") && (normalizeOptionalString(task.parentFlowId) ?? "") === (normalizeOptionalString(params.parentFlowId) ?? "")) : [];
|
|
1544
|
+
const exact = runId ? runScopeMatches.find((task) => (normalizeOptionalString(task.label) ?? "") === (normalizeOptionalString(params.label) ?? "") && (normalizeOptionalString(task.task) ?? "") === (normalizeOptionalString(params.task) ?? "")) : void 0;
|
|
1545
|
+
if (exact) return exact;
|
|
1546
|
+
if (!runId || params.runtime !== "acp") return;
|
|
1547
|
+
if (runScopeMatches.length === 0) return;
|
|
1548
|
+
return pickPreferredRunIdTask(runScopeMatches);
|
|
1549
|
+
}
|
|
1550
|
+
function mergeExistingTaskForCreate(existing, params) {
|
|
1551
|
+
const patch = {};
|
|
1552
|
+
const requesterOrigin = normalizeDeliveryContext(params.requesterOrigin);
|
|
1553
|
+
const currentDeliveryState = taskDeliveryStates.get(existing.taskId);
|
|
1554
|
+
if (requesterOrigin && !currentDeliveryState?.requesterOrigin) upsertTaskDeliveryState({
|
|
1555
|
+
taskId: existing.taskId,
|
|
1556
|
+
requesterOrigin,
|
|
1557
|
+
lastNotifiedEventAt: currentDeliveryState?.lastNotifiedEventAt
|
|
1558
|
+
});
|
|
1559
|
+
if (params.sourceId?.trim() && !existing.sourceId?.trim()) patch.sourceId = params.sourceId.trim();
|
|
1560
|
+
if (params.taskKind?.trim() && !existing.taskKind?.trim()) patch.taskKind = params.taskKind.trim();
|
|
1561
|
+
if (params.parentFlowId?.trim() && !existing.parentFlowId?.trim()) {
|
|
1562
|
+
assertParentFlowLinkAllowed({
|
|
1563
|
+
ownerKey: existing.ownerKey,
|
|
1564
|
+
scopeKind: existing.scopeKind,
|
|
1565
|
+
parentFlowId: params.parentFlowId
|
|
1566
|
+
});
|
|
1567
|
+
patch.parentFlowId = params.parentFlowId.trim();
|
|
1568
|
+
}
|
|
1569
|
+
if (params.parentTaskId?.trim() && !existing.parentTaskId?.trim()) patch.parentTaskId = params.parentTaskId.trim();
|
|
1570
|
+
if (params.agentId?.trim() && !existing.agentId?.trim()) patch.agentId = params.agentId.trim();
|
|
1571
|
+
const nextLabel = params.label?.trim();
|
|
1572
|
+
if (params.preferMetadata) {
|
|
1573
|
+
if (nextLabel && (normalizeOptionalString(existing.label) ?? "") !== nextLabel) patch.label = nextLabel;
|
|
1574
|
+
const nextTask = params.task.trim();
|
|
1575
|
+
if (nextTask && (normalizeOptionalString(existing.task) ?? "") !== nextTask) patch.task = nextTask;
|
|
1576
|
+
} else if (nextLabel && !existing.label?.trim()) patch.label = nextLabel;
|
|
1577
|
+
if (params.deliveryStatus === "pending" && existing.deliveryStatus !== "delivered") patch.deliveryStatus = "pending";
|
|
1578
|
+
const notifyPolicy = ensureNotifyPolicy({
|
|
1579
|
+
notifyPolicy: params.notifyPolicy,
|
|
1580
|
+
deliveryStatus: params.deliveryStatus,
|
|
1581
|
+
ownerKey: existing.ownerKey,
|
|
1582
|
+
scopeKind: existing.scopeKind
|
|
1583
|
+
});
|
|
1584
|
+
if (notifyPolicy !== existing.notifyPolicy && existing.notifyPolicy === "silent") patch.notifyPolicy = notifyPolicy;
|
|
1585
|
+
if (Object.keys(patch).length === 0) return cloneTaskRecord(existing);
|
|
1586
|
+
return updateTask(existing.taskId, patch) ?? cloneTaskRecord(existing);
|
|
1587
|
+
}
|
|
1588
|
+
function taskTerminalDeliveryIdempotencyKey(task) {
|
|
1589
|
+
const outcome = task.status === "succeeded" ? task.terminalOutcome ?? "default" : "default";
|
|
1590
|
+
return `task-terminal:${task.taskId}:${task.status}:${outcome}`;
|
|
1591
|
+
}
|
|
1592
|
+
function resolveTaskStateChangeIdempotencyKey(params) {
|
|
1593
|
+
if (params.owner.flowId) return `flow-event:${params.owner.flowId}:${params.task.taskId}:${params.latestEvent.at}:${params.latestEvent.kind}`;
|
|
1594
|
+
return `task-event:${params.task.taskId}:${params.latestEvent.at}:${params.latestEvent.kind}`;
|
|
1595
|
+
}
|
|
1596
|
+
function resolveTaskTerminalIdempotencyKey(task) {
|
|
1597
|
+
const owner = resolveTaskDeliveryOwner(task);
|
|
1598
|
+
if (owner.flowId) {
|
|
1599
|
+
const outcome = task.status === "succeeded" ? task.terminalOutcome ?? "default" : "default";
|
|
1600
|
+
return `flow-terminal:${owner.flowId}:${task.taskId}:${task.status}:${outcome}`;
|
|
1601
|
+
}
|
|
1602
|
+
return taskTerminalDeliveryIdempotencyKey(task);
|
|
1603
|
+
}
|
|
1604
|
+
function getLinkedFlowForDelivery(task) {
|
|
1605
|
+
const flowId = task.parentFlowId?.trim();
|
|
1606
|
+
if (!flowId || task.scopeKind !== "session") return;
|
|
1607
|
+
const flow = getTaskFlowById(flowId);
|
|
1608
|
+
if (!flow) return;
|
|
1609
|
+
if (normalizeOptionalString(flow.ownerKey) !== normalizeOptionalString(task.ownerKey)) return;
|
|
1610
|
+
return flow;
|
|
1611
|
+
}
|
|
1612
|
+
function resolveTaskDeliveryOwner(task) {
|
|
1613
|
+
const flow = getLinkedFlowForDelivery(task);
|
|
1614
|
+
if (flow) return {
|
|
1615
|
+
sessionKey: flow.ownerKey.trim(),
|
|
1616
|
+
requesterOrigin: normalizeDeliveryContext(flow.requesterOrigin ?? taskDeliveryStates.get(task.taskId)?.requesterOrigin),
|
|
1617
|
+
flowId: flow.flowId
|
|
1618
|
+
};
|
|
1619
|
+
if (task.scopeKind !== "session") return {};
|
|
1620
|
+
return {
|
|
1621
|
+
sessionKey: task.ownerKey.trim(),
|
|
1622
|
+
requesterOrigin: normalizeDeliveryContext(taskDeliveryStates.get(task.taskId)?.requesterOrigin)
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
function syncManagedFlowCancellationFromTask(task) {
|
|
1626
|
+
const flowId = task.parentFlowId?.trim();
|
|
1627
|
+
if (!flowId) return;
|
|
1628
|
+
let flow = getTaskFlowById(flowId);
|
|
1629
|
+
if (!flow || flow.syncMode !== "managed" || flow.cancelRequestedAt == null || isTerminalFlowStatus(flow.status)) return;
|
|
1630
|
+
if (listTasksForFlowId(flowId).some((candidate) => isActiveTaskStatus(candidate.status))) return;
|
|
1631
|
+
const endedAt = task.endedAt ?? task.lastEventAt ?? Date.now();
|
|
1632
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
1633
|
+
const result = updateFlowRecordByIdExpectedRevision({
|
|
1634
|
+
flowId,
|
|
1635
|
+
expectedRevision: flow.revision,
|
|
1636
|
+
patch: {
|
|
1637
|
+
status: "cancelled",
|
|
1638
|
+
blockedTaskId: null,
|
|
1639
|
+
blockedSummary: null,
|
|
1640
|
+
waitJson: null,
|
|
1641
|
+
endedAt,
|
|
1642
|
+
updatedAt: endedAt
|
|
1643
|
+
}
|
|
1644
|
+
});
|
|
1645
|
+
if (result.applied || result.reason === "not_found") return;
|
|
1646
|
+
flow = result.current;
|
|
1647
|
+
if (!flow || flow.syncMode !== "managed" || flow.cancelRequestedAt == null || isTerminalFlowStatus(flow.status)) return;
|
|
1648
|
+
if (listTasksForFlowId(flowId).some((candidate) => isActiveTaskStatus(candidate.status))) return;
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
function restoreTaskRegistryOnce() {
|
|
1652
|
+
if (restoreAttempted) return;
|
|
1653
|
+
restoreAttempted = true;
|
|
1654
|
+
try {
|
|
1655
|
+
const restored = getTaskRegistryStore().loadSnapshot();
|
|
1656
|
+
if (restored.tasks.size === 0 && restored.deliveryStates.size === 0) return;
|
|
1657
|
+
for (const [taskId, task] of restored.tasks.entries()) tasks.set(taskId, task);
|
|
1658
|
+
for (const [taskId, state] of restored.deliveryStates.entries()) taskDeliveryStates.set(taskId, state);
|
|
1659
|
+
rebuildRunIdIndex();
|
|
1660
|
+
rebuildOwnerKeyIndex();
|
|
1661
|
+
rebuildParentFlowIdIndex();
|
|
1662
|
+
rebuildRelatedSessionKeyIndex();
|
|
1663
|
+
emitTaskRegistryObserverEvent(() => ({
|
|
1664
|
+
kind: "restored",
|
|
1665
|
+
tasks: snapshotTaskRecords(tasks)
|
|
1666
|
+
}));
|
|
1667
|
+
} catch (error) {
|
|
1668
|
+
log.warn("Failed to restore task registry", { error });
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
function ensureTaskRegistryReady() {
|
|
1672
|
+
restoreTaskRegistryOnce();
|
|
1673
|
+
ensureListener();
|
|
1674
|
+
}
|
|
1675
|
+
function updateTask(taskId, patch) {
|
|
1676
|
+
const current = tasks.get(taskId);
|
|
1677
|
+
if (!current) return null;
|
|
1678
|
+
const next = {
|
|
1679
|
+
...current,
|
|
1680
|
+
...patch
|
|
1681
|
+
};
|
|
1682
|
+
if (isTerminalTaskStatus(next.status) && typeof next.cleanupAfter !== "number") next.cleanupAfter = (next.endedAt ?? next.lastEventAt ?? Date.now()) + DEFAULT_TASK_RETENTION_MS;
|
|
1683
|
+
const sessionIndexChanged = normalizeOptionalString(current.ownerKey) !== normalizeOptionalString(next.ownerKey) || normalizeOptionalString(current.childSessionKey) !== normalizeOptionalString(next.childSessionKey);
|
|
1684
|
+
const parentFlowIndexChanged = current.parentFlowId?.trim() !== next.parentFlowId?.trim();
|
|
1685
|
+
tasks.set(taskId, next);
|
|
1686
|
+
if (patch.runId && patch.runId !== current.runId) rebuildRunIdIndex();
|
|
1687
|
+
if (sessionIndexChanged) {
|
|
1688
|
+
deleteOwnerKeyIndex(taskId, current);
|
|
1689
|
+
addOwnerKeyIndex(taskId, next);
|
|
1690
|
+
deleteRelatedSessionKeyIndex(taskId, current);
|
|
1691
|
+
addRelatedSessionKeyIndex(taskId, next);
|
|
1692
|
+
}
|
|
1693
|
+
if (parentFlowIndexChanged) {
|
|
1694
|
+
deleteParentFlowIdIndex(taskId, current);
|
|
1695
|
+
addParentFlowIdIndex(taskId, next);
|
|
1696
|
+
}
|
|
1697
|
+
persistTaskUpsert(next);
|
|
1698
|
+
try {
|
|
1699
|
+
syncFlowFromTask(next);
|
|
1700
|
+
} catch (error) {
|
|
1701
|
+
log.warn("Failed to sync parent flow from task update", {
|
|
1702
|
+
taskId,
|
|
1703
|
+
flowId: next.parentFlowId,
|
|
1704
|
+
error
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
try {
|
|
1708
|
+
syncManagedFlowCancellationFromTask(next);
|
|
1709
|
+
} catch (error) {
|
|
1710
|
+
log.warn("Failed to finalize managed flow cancellation from task update", {
|
|
1711
|
+
taskId,
|
|
1712
|
+
flowId: next.parentFlowId,
|
|
1713
|
+
error
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
emitTaskRegistryObserverEvent(() => ({
|
|
1717
|
+
kind: "upserted",
|
|
1718
|
+
task: cloneTaskRecord(next),
|
|
1719
|
+
previous: cloneTaskRecord(current)
|
|
1720
|
+
}));
|
|
1721
|
+
return cloneTaskRecord(next);
|
|
1722
|
+
}
|
|
1723
|
+
function upsertTaskDeliveryState(state) {
|
|
1724
|
+
const current = taskDeliveryStates.get(state.taskId);
|
|
1725
|
+
const next = {
|
|
1726
|
+
taskId: state.taskId,
|
|
1727
|
+
...state.requesterOrigin ? { requesterOrigin: normalizeDeliveryContext(state.requesterOrigin) } : {},
|
|
1728
|
+
...state.lastNotifiedEventAt != null ? { lastNotifiedEventAt: state.lastNotifiedEventAt } : {}
|
|
1729
|
+
};
|
|
1730
|
+
if (!next.requesterOrigin && typeof next.lastNotifiedEventAt !== "number" && !current) return cloneTaskDeliveryState({ taskId: state.taskId });
|
|
1731
|
+
taskDeliveryStates.set(state.taskId, next);
|
|
1732
|
+
persistTaskDeliveryStateUpsert(next);
|
|
1733
|
+
return cloneTaskDeliveryState(next);
|
|
1734
|
+
}
|
|
1735
|
+
function getTaskDeliveryState(taskId) {
|
|
1736
|
+
const state = taskDeliveryStates.get(taskId);
|
|
1737
|
+
return state ? cloneTaskDeliveryState(state) : void 0;
|
|
1738
|
+
}
|
|
1739
|
+
function canDeliverTaskToRequesterOrigin(task) {
|
|
1740
|
+
const origin = resolveTaskDeliveryOwner(task).requesterOrigin;
|
|
1741
|
+
const channel = origin?.channel?.trim();
|
|
1742
|
+
const to = origin?.to?.trim();
|
|
1743
|
+
return Boolean(channel && to && isDeliverableMessageChannel(channel));
|
|
1744
|
+
}
|
|
1745
|
+
function resolveMissingOwnerDeliveryStatus(task) {
|
|
1746
|
+
return task.scopeKind === "system" ? "not_applicable" : "parent_missing";
|
|
1747
|
+
}
|
|
1748
|
+
function queueTaskSystemEvent(task, text) {
|
|
1749
|
+
const owner = resolveTaskDeliveryOwner(task);
|
|
1750
|
+
const ownerKey = owner.sessionKey?.trim();
|
|
1751
|
+
if (!ownerKey) return false;
|
|
1752
|
+
enqueueSystemEvent(text, {
|
|
1753
|
+
sessionKey: ownerKey,
|
|
1754
|
+
contextKey: `task:${task.taskId}`,
|
|
1755
|
+
deliveryContext: owner.requesterOrigin
|
|
1756
|
+
});
|
|
1757
|
+
requestHeartbeatNow({
|
|
1758
|
+
reason: "background-task",
|
|
1759
|
+
sessionKey: ownerKey
|
|
1760
|
+
});
|
|
1761
|
+
return true;
|
|
1762
|
+
}
|
|
1763
|
+
function queueBlockedTaskFollowup(task) {
|
|
1764
|
+
const followupText = formatTaskBlockedFollowupMessage(task);
|
|
1765
|
+
if (!followupText) return false;
|
|
1766
|
+
const owner = resolveTaskDeliveryOwner(task);
|
|
1767
|
+
const ownerKey = owner.sessionKey?.trim();
|
|
1768
|
+
if (!ownerKey) return false;
|
|
1769
|
+
enqueueSystemEvent(followupText, {
|
|
1770
|
+
sessionKey: ownerKey,
|
|
1771
|
+
contextKey: `task:${task.taskId}:blocked-followup`,
|
|
1772
|
+
deliveryContext: owner.requesterOrigin
|
|
1773
|
+
});
|
|
1774
|
+
requestHeartbeatNow({
|
|
1775
|
+
reason: "background-task-blocked",
|
|
1776
|
+
sessionKey: ownerKey
|
|
1777
|
+
});
|
|
1778
|
+
return true;
|
|
1779
|
+
}
|
|
1780
|
+
async function maybeDeliverTaskTerminalUpdate(taskId) {
|
|
1781
|
+
ensureTaskRegistryReady();
|
|
1782
|
+
const current = tasks.get(taskId);
|
|
1783
|
+
if (!current || !shouldAutoDeliverTaskTerminalUpdate(current)) return current ? cloneTaskRecord(current) : null;
|
|
1784
|
+
if (tasksWithPendingDelivery.has(taskId)) return cloneTaskRecord(current);
|
|
1785
|
+
tasksWithPendingDelivery.add(taskId);
|
|
1786
|
+
try {
|
|
1787
|
+
const latest = tasks.get(taskId);
|
|
1788
|
+
if (!latest || !shouldAutoDeliverTaskTerminalUpdate(latest)) return latest ? cloneTaskRecord(latest) : null;
|
|
1789
|
+
if (shouldSuppressDuplicateTerminalDelivery({
|
|
1790
|
+
task: latest,
|
|
1791
|
+
preferredTaskId: (latest.runId ? pickPreferredRunIdTask(getPeerTasksForDelivery(latest)) : void 0)?.taskId
|
|
1792
|
+
})) return updateTask(taskId, {
|
|
1793
|
+
deliveryStatus: "not_applicable",
|
|
1794
|
+
lastEventAt: Date.now()
|
|
1795
|
+
});
|
|
1796
|
+
const owner = resolveTaskDeliveryOwner(latest);
|
|
1797
|
+
const ownerSessionKey = owner.sessionKey?.trim();
|
|
1798
|
+
if (!ownerSessionKey) return updateTask(taskId, {
|
|
1799
|
+
deliveryStatus: resolveMissingOwnerDeliveryStatus(latest),
|
|
1800
|
+
lastEventAt: Date.now()
|
|
1801
|
+
});
|
|
1802
|
+
const eventText = formatTaskTerminalMessage(latest);
|
|
1803
|
+
if (!canDeliverTaskToRequesterOrigin(latest)) try {
|
|
1804
|
+
queueTaskSystemEvent(latest, eventText);
|
|
1805
|
+
if (latest.terminalOutcome === "blocked") queueBlockedTaskFollowup(latest);
|
|
1806
|
+
return updateTask(taskId, {
|
|
1807
|
+
deliveryStatus: "session_queued",
|
|
1808
|
+
lastEventAt: Date.now()
|
|
1809
|
+
});
|
|
1810
|
+
} catch (error) {
|
|
1811
|
+
log.warn("Failed to queue background task session delivery", {
|
|
1812
|
+
taskId,
|
|
1813
|
+
ownerKey: latest.ownerKey,
|
|
1814
|
+
error
|
|
1815
|
+
});
|
|
1816
|
+
return updateTask(taskId, {
|
|
1817
|
+
deliveryStatus: "failed",
|
|
1818
|
+
lastEventAt: Date.now()
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
try {
|
|
1822
|
+
const { sendMessage } = await loadTaskRegistryDeliveryRuntime();
|
|
1823
|
+
const requesterAgentId = parseAgentSessionKey(ownerSessionKey)?.agentId;
|
|
1824
|
+
const idempotencyKey = resolveTaskTerminalIdempotencyKey(latest);
|
|
1825
|
+
await sendMessage({
|
|
1826
|
+
channel: owner.requesterOrigin?.channel,
|
|
1827
|
+
to: owner.requesterOrigin?.to ?? "",
|
|
1828
|
+
accountId: owner.requesterOrigin?.accountId,
|
|
1829
|
+
threadId: owner.requesterOrigin?.threadId,
|
|
1830
|
+
content: eventText,
|
|
1831
|
+
agentId: requesterAgentId,
|
|
1832
|
+
idempotencyKey,
|
|
1833
|
+
mirror: {
|
|
1834
|
+
sessionKey: ownerSessionKey,
|
|
1835
|
+
agentId: requesterAgentId,
|
|
1836
|
+
idempotencyKey
|
|
1837
|
+
}
|
|
1838
|
+
});
|
|
1839
|
+
if (latest.terminalOutcome === "blocked") queueBlockedTaskFollowup(latest);
|
|
1840
|
+
return updateTask(taskId, {
|
|
1841
|
+
deliveryStatus: "delivered",
|
|
1842
|
+
lastEventAt: Date.now()
|
|
1843
|
+
});
|
|
1844
|
+
} catch (error) {
|
|
1845
|
+
log.warn("Failed to deliver background task update", {
|
|
1846
|
+
taskId,
|
|
1847
|
+
ownerKey: ownerSessionKey,
|
|
1848
|
+
requesterOrigin: owner.requesterOrigin,
|
|
1849
|
+
error
|
|
1850
|
+
});
|
|
1851
|
+
try {
|
|
1852
|
+
queueTaskSystemEvent(latest, eventText);
|
|
1853
|
+
if (latest.terminalOutcome === "blocked") queueBlockedTaskFollowup(latest);
|
|
1854
|
+
} catch (fallbackError) {
|
|
1855
|
+
log.warn("Failed to queue background task fallback event", {
|
|
1856
|
+
taskId,
|
|
1857
|
+
ownerKey: latest.ownerKey,
|
|
1858
|
+
error: fallbackError
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1861
|
+
return updateTask(taskId, {
|
|
1862
|
+
deliveryStatus: "failed",
|
|
1863
|
+
lastEventAt: Date.now()
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
} finally {
|
|
1867
|
+
tasksWithPendingDelivery.delete(taskId);
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
async function maybeDeliverTaskStateChangeUpdate(taskId, latestEvent) {
|
|
1871
|
+
ensureTaskRegistryReady();
|
|
1872
|
+
const current = tasks.get(taskId);
|
|
1873
|
+
if (!current || !shouldAutoDeliverTaskStateChange(current)) return current ? cloneTaskRecord(current) : null;
|
|
1874
|
+
const deliveryState = getTaskDeliveryState(taskId);
|
|
1875
|
+
if (!latestEvent || (deliveryState?.lastNotifiedEventAt ?? 0) >= latestEvent.at) return cloneTaskRecord(current);
|
|
1876
|
+
const eventText = formatTaskStateChangeMessage(current, latestEvent);
|
|
1877
|
+
if (!eventText) return cloneTaskRecord(current);
|
|
1878
|
+
try {
|
|
1879
|
+
const owner = resolveTaskDeliveryOwner(current);
|
|
1880
|
+
const ownerSessionKey = owner.sessionKey?.trim();
|
|
1881
|
+
if (!ownerSessionKey) return updateTask(taskId, {
|
|
1882
|
+
deliveryStatus: resolveMissingOwnerDeliveryStatus(current),
|
|
1883
|
+
lastEventAt: Date.now()
|
|
1884
|
+
});
|
|
1885
|
+
if (!canDeliverTaskToRequesterOrigin(current)) {
|
|
1886
|
+
queueTaskSystemEvent(current, eventText);
|
|
1887
|
+
upsertTaskDeliveryState({
|
|
1888
|
+
taskId,
|
|
1889
|
+
requesterOrigin: deliveryState?.requesterOrigin,
|
|
1890
|
+
lastNotifiedEventAt: latestEvent.at
|
|
1891
|
+
});
|
|
1892
|
+
return updateTask(taskId, { lastEventAt: Date.now() });
|
|
1893
|
+
}
|
|
1894
|
+
const { sendMessage } = await loadTaskRegistryDeliveryRuntime();
|
|
1895
|
+
const requesterAgentId = parseAgentSessionKey(ownerSessionKey)?.agentId;
|
|
1896
|
+
const idempotencyKey = resolveTaskStateChangeIdempotencyKey({
|
|
1897
|
+
task: current,
|
|
1898
|
+
latestEvent,
|
|
1899
|
+
owner
|
|
1900
|
+
});
|
|
1901
|
+
await sendMessage({
|
|
1902
|
+
channel: owner.requesterOrigin?.channel,
|
|
1903
|
+
to: owner.requesterOrigin?.to ?? "",
|
|
1904
|
+
accountId: owner.requesterOrigin?.accountId,
|
|
1905
|
+
threadId: owner.requesterOrigin?.threadId,
|
|
1906
|
+
content: eventText,
|
|
1907
|
+
agentId: requesterAgentId,
|
|
1908
|
+
idempotencyKey,
|
|
1909
|
+
mirror: {
|
|
1910
|
+
sessionKey: ownerSessionKey,
|
|
1911
|
+
agentId: requesterAgentId,
|
|
1912
|
+
idempotencyKey
|
|
1913
|
+
}
|
|
1914
|
+
});
|
|
1915
|
+
upsertTaskDeliveryState({
|
|
1916
|
+
taskId,
|
|
1917
|
+
requesterOrigin: deliveryState?.requesterOrigin,
|
|
1918
|
+
lastNotifiedEventAt: latestEvent.at
|
|
1919
|
+
});
|
|
1920
|
+
return updateTask(taskId, { lastEventAt: Date.now() });
|
|
1921
|
+
} catch (error) {
|
|
1922
|
+
log.warn("Failed to deliver background task state change", {
|
|
1923
|
+
taskId,
|
|
1924
|
+
ownerKey: current.ownerKey,
|
|
1925
|
+
error
|
|
1926
|
+
});
|
|
1927
|
+
return cloneTaskRecord(current);
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
function setTaskCleanupAfterById(params) {
|
|
1931
|
+
ensureTaskRegistryReady();
|
|
1932
|
+
return updateTask(params.taskId, { cleanupAfter: params.cleanupAfter });
|
|
1933
|
+
}
|
|
1934
|
+
function markTaskTerminalById(params) {
|
|
1935
|
+
ensureTaskRegistryReady();
|
|
1936
|
+
return updateTask(params.taskId, {
|
|
1937
|
+
status: params.status,
|
|
1938
|
+
endedAt: params.endedAt,
|
|
1939
|
+
lastEventAt: params.lastEventAt ?? params.endedAt,
|
|
1940
|
+
...params.error !== void 0 ? { error: params.error } : {},
|
|
1941
|
+
...params.terminalSummary !== void 0 ? { terminalSummary: normalizeTaskSummary(params.terminalSummary) } : {},
|
|
1942
|
+
...params.terminalOutcome !== void 0 ? { terminalOutcome: resolveTaskTerminalOutcome({
|
|
1943
|
+
status: params.status,
|
|
1944
|
+
terminalOutcome: params.terminalOutcome
|
|
1945
|
+
}) } : {}
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
function markTaskLostById(params) {
|
|
1949
|
+
ensureTaskRegistryReady();
|
|
1950
|
+
return updateTask(params.taskId, {
|
|
1951
|
+
status: "lost",
|
|
1952
|
+
endedAt: params.endedAt,
|
|
1953
|
+
lastEventAt: params.lastEventAt ?? params.endedAt,
|
|
1954
|
+
...params.error !== void 0 ? { error: params.error } : {},
|
|
1955
|
+
...params.cleanupAfter !== void 0 ? { cleanupAfter: params.cleanupAfter } : {}
|
|
1956
|
+
});
|
|
1957
|
+
}
|
|
1958
|
+
function updateTasksByRunId(params) {
|
|
1959
|
+
const matches = getTasksByRunScope(params);
|
|
1960
|
+
if (matches.length === 0) return [];
|
|
1961
|
+
const updated = [];
|
|
1962
|
+
for (const match of matches) {
|
|
1963
|
+
const task = updateTask(match.taskId, params.patch);
|
|
1964
|
+
if (task) updated.push(task);
|
|
1965
|
+
}
|
|
1966
|
+
return updated;
|
|
1967
|
+
}
|
|
1968
|
+
function ensureListener() {
|
|
1969
|
+
if (listenerStarted) return;
|
|
1970
|
+
listenerStarted = true;
|
|
1971
|
+
onAgentEvent((evt) => {
|
|
1972
|
+
restoreTaskRegistryOnce();
|
|
1973
|
+
const scopedTasks = getTasksByRunScope({
|
|
1974
|
+
runId: evt.runId,
|
|
1975
|
+
sessionKey: evt.sessionKey
|
|
1976
|
+
});
|
|
1977
|
+
if (scopedTasks.length === 0) return;
|
|
1978
|
+
const now = evt.ts || Date.now();
|
|
1979
|
+
for (const current of scopedTasks) {
|
|
1980
|
+
if (isTerminalTaskStatus(current.status)) continue;
|
|
1981
|
+
const patch = { lastEventAt: now };
|
|
1982
|
+
if (evt.stream === "lifecycle") {
|
|
1983
|
+
const phase = typeof evt.data?.phase === "string" ? evt.data.phase : void 0;
|
|
1984
|
+
const startedAt = typeof evt.data?.startedAt === "number" ? evt.data.startedAt : current.startedAt;
|
|
1985
|
+
const endedAt = typeof evt.data?.endedAt === "number" ? evt.data.endedAt : void 0;
|
|
1986
|
+
if (startedAt) patch.startedAt = startedAt;
|
|
1987
|
+
if (phase === "start") patch.status = "running";
|
|
1988
|
+
else if (phase === "end") {
|
|
1989
|
+
patch.status = evt.data?.aborted === true ? "timed_out" : "succeeded";
|
|
1990
|
+
patch.endedAt = endedAt ?? now;
|
|
1991
|
+
} else if (phase === "error") {
|
|
1992
|
+
patch.status = "failed";
|
|
1993
|
+
patch.endedAt = endedAt ?? now;
|
|
1994
|
+
patch.error = typeof evt.data?.error === "string" ? evt.data.error : current.error;
|
|
1995
|
+
}
|
|
1996
|
+
} else if (evt.stream === "error") patch.error = typeof evt.data?.error === "string" ? evt.data.error : current.error;
|
|
1997
|
+
const stateChangeEvent = patch.status && patch.status !== current.status ? appendTaskEvent({
|
|
1998
|
+
at: now,
|
|
1999
|
+
kind: patch.status,
|
|
2000
|
+
summary: patch.status === "failed" ? patch.error ?? current.error : patch.status === "succeeded" ? current.terminalSummary : void 0
|
|
2001
|
+
}) : void 0;
|
|
2002
|
+
if (updateTask(current.taskId, patch)) {
|
|
2003
|
+
maybeDeliverTaskStateChangeUpdate(current.taskId, stateChangeEvent);
|
|
2004
|
+
maybeDeliverTaskTerminalUpdate(current.taskId);
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
function createTaskRecord(params) {
|
|
2010
|
+
ensureTaskRegistryReady();
|
|
2011
|
+
const requesterSessionKey = resolveTaskRequesterSessionKey(params);
|
|
2012
|
+
const scopeKind = resolveTaskScopeKind({
|
|
2013
|
+
scopeKind: params.scopeKind,
|
|
2014
|
+
requesterSessionKey
|
|
2015
|
+
});
|
|
2016
|
+
const ownerKey = resolveTaskOwnerKey({
|
|
2017
|
+
requesterSessionKey,
|
|
2018
|
+
ownerKey: params.ownerKey
|
|
2019
|
+
});
|
|
2020
|
+
assertTaskOwner({
|
|
2021
|
+
ownerKey,
|
|
2022
|
+
scopeKind
|
|
2023
|
+
});
|
|
2024
|
+
assertParentFlowLinkAllowed({
|
|
2025
|
+
ownerKey,
|
|
2026
|
+
scopeKind,
|
|
2027
|
+
parentFlowId: params.parentFlowId
|
|
2028
|
+
});
|
|
2029
|
+
const existing = findExistingTaskForCreate({
|
|
2030
|
+
runtime: params.runtime,
|
|
2031
|
+
ownerKey,
|
|
2032
|
+
scopeKind,
|
|
2033
|
+
childSessionKey: params.childSessionKey,
|
|
2034
|
+
parentFlowId: params.parentFlowId,
|
|
2035
|
+
runId: params.runId,
|
|
2036
|
+
label: params.label,
|
|
2037
|
+
task: params.task
|
|
2038
|
+
});
|
|
2039
|
+
if (existing) return mergeExistingTaskForCreate(existing, params);
|
|
2040
|
+
const now = Date.now();
|
|
2041
|
+
const taskId = crypto.randomUUID();
|
|
2042
|
+
const status = normalizeTaskStatus(params.status);
|
|
2043
|
+
const deliveryStatus = params.deliveryStatus ?? ensureDeliveryStatus({
|
|
2044
|
+
ownerKey,
|
|
2045
|
+
scopeKind
|
|
2046
|
+
});
|
|
2047
|
+
const notifyPolicy = ensureNotifyPolicy({
|
|
2048
|
+
notifyPolicy: params.notifyPolicy,
|
|
2049
|
+
deliveryStatus,
|
|
2050
|
+
ownerKey,
|
|
2051
|
+
scopeKind
|
|
2052
|
+
});
|
|
2053
|
+
const lastEventAt = params.lastEventAt ?? params.startedAt ?? now;
|
|
2054
|
+
const record = {
|
|
2055
|
+
taskId,
|
|
2056
|
+
runtime: params.runtime,
|
|
2057
|
+
taskKind: normalizeOptionalString(params.taskKind),
|
|
2058
|
+
sourceId: normalizeOptionalString(params.sourceId),
|
|
2059
|
+
requesterSessionKey,
|
|
2060
|
+
ownerKey,
|
|
2061
|
+
scopeKind,
|
|
2062
|
+
childSessionKey: params.childSessionKey,
|
|
2063
|
+
parentFlowId: normalizeOptionalString(params.parentFlowId),
|
|
2064
|
+
parentTaskId: normalizeOptionalString(params.parentTaskId),
|
|
2065
|
+
agentId: normalizeOptionalString(params.agentId),
|
|
2066
|
+
runId: normalizeOptionalString(params.runId),
|
|
2067
|
+
label: normalizeOptionalString(params.label),
|
|
2068
|
+
task: params.task,
|
|
2069
|
+
status,
|
|
2070
|
+
deliveryStatus,
|
|
2071
|
+
notifyPolicy,
|
|
2072
|
+
createdAt: now,
|
|
2073
|
+
startedAt: params.startedAt,
|
|
2074
|
+
lastEventAt,
|
|
2075
|
+
cleanupAfter: params.cleanupAfter,
|
|
2076
|
+
progressSummary: normalizeTaskSummary(params.progressSummary),
|
|
2077
|
+
terminalSummary: normalizeTaskSummary(params.terminalSummary),
|
|
2078
|
+
terminalOutcome: resolveTaskTerminalOutcome({
|
|
2079
|
+
status,
|
|
2080
|
+
terminalOutcome: params.terminalOutcome
|
|
2081
|
+
})
|
|
2082
|
+
};
|
|
2083
|
+
if (isTerminalTaskStatus(record.status) && typeof record.cleanupAfter !== "number") record.cleanupAfter = (record.endedAt ?? record.lastEventAt ?? record.createdAt) + DEFAULT_TASK_RETENTION_MS;
|
|
2084
|
+
tasks.set(taskId, record);
|
|
2085
|
+
upsertTaskDeliveryState({
|
|
2086
|
+
taskId,
|
|
2087
|
+
requesterOrigin: normalizeDeliveryContext(params.requesterOrigin)
|
|
2088
|
+
});
|
|
2089
|
+
addRunIdIndex(taskId, record.runId);
|
|
2090
|
+
addOwnerKeyIndex(taskId, record);
|
|
2091
|
+
addParentFlowIdIndex(taskId, record);
|
|
2092
|
+
addRelatedSessionKeyIndex(taskId, record);
|
|
2093
|
+
persistTaskUpsert(record);
|
|
2094
|
+
try {
|
|
2095
|
+
syncFlowFromTask(record);
|
|
2096
|
+
} catch (error) {
|
|
2097
|
+
log.warn("Failed to sync parent flow from task create", {
|
|
2098
|
+
taskId: record.taskId,
|
|
2099
|
+
flowId: record.parentFlowId,
|
|
2100
|
+
error
|
|
2101
|
+
});
|
|
2102
|
+
}
|
|
2103
|
+
emitTaskRegistryObserverEvent(() => ({
|
|
2104
|
+
kind: "upserted",
|
|
2105
|
+
task: cloneTaskRecord(record)
|
|
2106
|
+
}));
|
|
2107
|
+
if (isTerminalTaskStatus(record.status)) maybeDeliverTaskTerminalUpdate(taskId);
|
|
2108
|
+
return cloneTaskRecord(record);
|
|
2109
|
+
}
|
|
2110
|
+
function updateTaskStateByRunId(params) {
|
|
2111
|
+
ensureTaskRegistryReady();
|
|
2112
|
+
const matches = getTasksByRunScope(params);
|
|
2113
|
+
if (matches.length === 0) return [];
|
|
2114
|
+
const updated = [];
|
|
2115
|
+
for (const current of matches) {
|
|
2116
|
+
const patch = {};
|
|
2117
|
+
const nextStatus = params.status ? normalizeTaskStatus(params.status) : current.status;
|
|
2118
|
+
const eventAt = params.lastEventAt ?? params.endedAt ?? Date.now();
|
|
2119
|
+
if (params.status) patch.status = normalizeTaskStatus(params.status);
|
|
2120
|
+
if (params.startedAt != null) patch.startedAt = params.startedAt;
|
|
2121
|
+
if (params.endedAt != null) patch.endedAt = params.endedAt;
|
|
2122
|
+
if (params.lastEventAt != null) patch.lastEventAt = params.lastEventAt;
|
|
2123
|
+
if (params.error !== void 0) patch.error = params.error;
|
|
2124
|
+
if (params.progressSummary !== void 0) patch.progressSummary = normalizeTaskSummary(params.progressSummary);
|
|
2125
|
+
if (params.terminalSummary !== void 0) patch.terminalSummary = normalizeTaskSummary(params.terminalSummary);
|
|
2126
|
+
if (params.terminalOutcome !== void 0) patch.terminalOutcome = resolveTaskTerminalOutcome({
|
|
2127
|
+
status: nextStatus,
|
|
2128
|
+
terminalOutcome: params.terminalOutcome
|
|
2129
|
+
});
|
|
2130
|
+
const eventSummary = normalizeTaskSummary(params.eventSummary) ?? (nextStatus === "failed" ? normalizeTaskSummary(params.error ?? current.error) : nextStatus === "succeeded" ? normalizeTaskSummary(params.terminalSummary ?? current.terminalSummary) : void 0);
|
|
2131
|
+
const nextEvent = params.status && params.status !== current.status || Boolean(normalizeTaskSummary(params.eventSummary)) ? appendTaskEvent({
|
|
2132
|
+
at: eventAt,
|
|
2133
|
+
kind: params.status && normalizeTaskStatus(params.status) !== current.status ? normalizeTaskStatus(params.status) : "progress",
|
|
2134
|
+
summary: eventSummary
|
|
2135
|
+
}) : void 0;
|
|
2136
|
+
const task = updateTask(current.taskId, patch);
|
|
2137
|
+
if (task) {
|
|
2138
|
+
updated.push(task);
|
|
2139
|
+
maybeDeliverTaskStateChangeUpdate(task.taskId, nextEvent);
|
|
2140
|
+
maybeDeliverTaskTerminalUpdate(task.taskId);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
return updated;
|
|
2144
|
+
}
|
|
2145
|
+
function updateTaskDeliveryByRunId(params) {
|
|
2146
|
+
ensureTaskRegistryReady();
|
|
2147
|
+
return updateTasksByRunId({
|
|
2148
|
+
runId: params.runId,
|
|
2149
|
+
runtime: params.runtime,
|
|
2150
|
+
sessionKey: params.sessionKey,
|
|
2151
|
+
patch: { deliveryStatus: params.deliveryStatus }
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2154
|
+
function markTaskRunningByRunId(params) {
|
|
2155
|
+
return updateTaskStateByRunId({
|
|
2156
|
+
runId: params.runId,
|
|
2157
|
+
runtime: params.runtime,
|
|
2158
|
+
sessionKey: params.sessionKey,
|
|
2159
|
+
status: "running",
|
|
2160
|
+
startedAt: params.startedAt,
|
|
2161
|
+
lastEventAt: params.lastEventAt,
|
|
2162
|
+
progressSummary: params.progressSummary,
|
|
2163
|
+
eventSummary: params.eventSummary
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
function recordTaskProgressByRunId(params) {
|
|
2167
|
+
return updateTaskStateByRunId({
|
|
2168
|
+
runId: params.runId,
|
|
2169
|
+
runtime: params.runtime,
|
|
2170
|
+
sessionKey: params.sessionKey,
|
|
2171
|
+
lastEventAt: params.lastEventAt,
|
|
2172
|
+
progressSummary: params.progressSummary,
|
|
2173
|
+
eventSummary: params.eventSummary
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
function markTaskTerminalByRunId(params) {
|
|
2177
|
+
return updateTaskStateByRunId({
|
|
2178
|
+
runId: params.runId,
|
|
2179
|
+
runtime: params.runtime,
|
|
2180
|
+
sessionKey: params.sessionKey,
|
|
2181
|
+
status: params.status,
|
|
2182
|
+
startedAt: params.startedAt,
|
|
2183
|
+
endedAt: params.endedAt,
|
|
2184
|
+
lastEventAt: params.lastEventAt,
|
|
2185
|
+
error: params.error,
|
|
2186
|
+
progressSummary: params.progressSummary,
|
|
2187
|
+
terminalSummary: params.terminalSummary,
|
|
2188
|
+
terminalOutcome: params.terminalOutcome
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
function setTaskRunDeliveryStatusByRunId(params) {
|
|
2192
|
+
return updateTaskDeliveryByRunId(params);
|
|
2193
|
+
}
|
|
2194
|
+
function updateTaskNotifyPolicyById(params) {
|
|
2195
|
+
ensureTaskRegistryReady();
|
|
2196
|
+
return updateTask(params.taskId, {
|
|
2197
|
+
notifyPolicy: params.notifyPolicy,
|
|
2198
|
+
lastEventAt: Date.now()
|
|
2199
|
+
});
|
|
2200
|
+
}
|
|
2201
|
+
function linkTaskToFlowById(params) {
|
|
2202
|
+
ensureTaskRegistryReady();
|
|
2203
|
+
const flowId = params.flowId.trim();
|
|
2204
|
+
if (!flowId) return null;
|
|
2205
|
+
const current = tasks.get(params.taskId);
|
|
2206
|
+
if (!current) return null;
|
|
2207
|
+
if (current.parentFlowId?.trim()) return cloneTaskRecord(current);
|
|
2208
|
+
assertParentFlowLinkAllowed({
|
|
2209
|
+
ownerKey: current.ownerKey,
|
|
2210
|
+
scopeKind: current.scopeKind,
|
|
2211
|
+
parentFlowId: flowId
|
|
2212
|
+
});
|
|
2213
|
+
return updateTask(params.taskId, { parentFlowId: flowId });
|
|
2214
|
+
}
|
|
2215
|
+
async function cancelTaskById(params) {
|
|
2216
|
+
ensureTaskRegistryReady();
|
|
2217
|
+
const task = tasks.get(params.taskId.trim());
|
|
2218
|
+
if (!task) return {
|
|
2219
|
+
found: false,
|
|
2220
|
+
cancelled: false,
|
|
2221
|
+
reason: "Task not found."
|
|
2222
|
+
};
|
|
2223
|
+
if (task.status === "succeeded" || task.status === "failed" || task.status === "timed_out" || task.status === "lost" || task.status === "cancelled") return {
|
|
2224
|
+
found: true,
|
|
2225
|
+
cancelled: false,
|
|
2226
|
+
reason: "Task is already terminal.",
|
|
2227
|
+
task: cloneTaskRecord(task)
|
|
2228
|
+
};
|
|
2229
|
+
const childSessionKey = task.childSessionKey?.trim();
|
|
2230
|
+
try {
|
|
2231
|
+
if (task.runtime !== "cli") {
|
|
2232
|
+
if (!childSessionKey) return {
|
|
2233
|
+
found: true,
|
|
2234
|
+
cancelled: false,
|
|
2235
|
+
reason: "Task has no cancellable child session.",
|
|
2236
|
+
task: cloneTaskRecord(task)
|
|
2237
|
+
};
|
|
2238
|
+
if (task.runtime === "acp") {
|
|
2239
|
+
const { getAcpSessionManager } = await loadTaskRegistryControlRuntime();
|
|
2240
|
+
await getAcpSessionManager().cancelSession({
|
|
2241
|
+
cfg: params.cfg,
|
|
2242
|
+
sessionKey: childSessionKey,
|
|
2243
|
+
reason: "task-cancel"
|
|
2244
|
+
});
|
|
2245
|
+
} else if (task.runtime === "subagent") {
|
|
2246
|
+
const { killSubagentRunAdmin } = await loadTaskRegistryControlRuntime();
|
|
2247
|
+
const result = await killSubagentRunAdmin({
|
|
2248
|
+
cfg: params.cfg,
|
|
2249
|
+
sessionKey: childSessionKey
|
|
2250
|
+
});
|
|
2251
|
+
if (!result.found || !result.killed) return {
|
|
2252
|
+
found: true,
|
|
2253
|
+
cancelled: false,
|
|
2254
|
+
reason: result.found ? "Subagent was not running." : "Subagent task not found.",
|
|
2255
|
+
task: cloneTaskRecord(task)
|
|
2256
|
+
};
|
|
2257
|
+
} else return {
|
|
2258
|
+
found: true,
|
|
2259
|
+
cancelled: false,
|
|
2260
|
+
reason: "Task runtime does not support cancellation yet.",
|
|
2261
|
+
task: cloneTaskRecord(task)
|
|
2262
|
+
};
|
|
2263
|
+
}
|
|
2264
|
+
const updated = updateTask(task.taskId, {
|
|
2265
|
+
status: "cancelled",
|
|
2266
|
+
endedAt: Date.now(),
|
|
2267
|
+
lastEventAt: Date.now(),
|
|
2268
|
+
error: "Cancelled by operator."
|
|
2269
|
+
});
|
|
2270
|
+
if (updated) maybeDeliverTaskTerminalUpdate(updated.taskId);
|
|
2271
|
+
return {
|
|
2272
|
+
found: true,
|
|
2273
|
+
cancelled: true,
|
|
2274
|
+
task: updated ?? cloneTaskRecord(task)
|
|
2275
|
+
};
|
|
2276
|
+
} catch (error) {
|
|
2277
|
+
return {
|
|
2278
|
+
found: true,
|
|
2279
|
+
cancelled: false,
|
|
2280
|
+
reason: formatErrorMessage(error),
|
|
2281
|
+
task: cloneTaskRecord(task)
|
|
2282
|
+
};
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
function listTaskRecords() {
|
|
2286
|
+
ensureTaskRegistryReady();
|
|
2287
|
+
return [...tasks.values()].map((task, insertionIndex) => Object.assign({}, cloneTaskRecord(task), { insertionIndex })).toSorted(compareTasksNewestFirst).map(({ insertionIndex: _, ...task }) => task);
|
|
2288
|
+
}
|
|
2289
|
+
function getTaskById(taskId) {
|
|
2290
|
+
ensureTaskRegistryReady();
|
|
2291
|
+
const task = tasks.get(taskId.trim());
|
|
2292
|
+
return task ? cloneTaskRecord(task) : void 0;
|
|
2293
|
+
}
|
|
2294
|
+
function findTaskByRunId(runId) {
|
|
2295
|
+
ensureTaskRegistryReady();
|
|
2296
|
+
const task = pickPreferredRunIdTask(getTasksByRunId(runId));
|
|
2297
|
+
return task ? cloneTaskRecord(task) : void 0;
|
|
2298
|
+
}
|
|
2299
|
+
function listTasksFromIndex(index, key) {
|
|
2300
|
+
const ids = index.get(key);
|
|
2301
|
+
if (!ids || ids.size === 0) return [];
|
|
2302
|
+
return [...ids].map((taskId, insertionIndex) => {
|
|
2303
|
+
const task = tasks.get(taskId);
|
|
2304
|
+
return task ? Object.assign({}, cloneTaskRecord(task), { insertionIndex }) : null;
|
|
2305
|
+
}).filter((task) => Boolean(task)).toSorted(compareTasksNewestFirst).map(({ insertionIndex: _, ...task }) => task);
|
|
2306
|
+
}
|
|
2307
|
+
function listTasksForSessionKey(sessionKey) {
|
|
2308
|
+
ensureTaskRegistryReady();
|
|
2309
|
+
const key = normalizeOptionalString(sessionKey);
|
|
2310
|
+
if (!key) return [];
|
|
2311
|
+
return listTasksFromIndex(taskIdsByRelatedSessionKey, key);
|
|
2312
|
+
}
|
|
2313
|
+
function listTasksForAgentId(agentId) {
|
|
2314
|
+
ensureTaskRegistryReady();
|
|
2315
|
+
const lookup = agentId.trim();
|
|
2316
|
+
if (!lookup) return [];
|
|
2317
|
+
return snapshotTaskRecords(tasks).filter((task) => task.agentId?.trim() === lookup).toSorted(compareTasksNewestFirst);
|
|
2318
|
+
}
|
|
2319
|
+
function listTasksForOwnerKey(ownerKey) {
|
|
2320
|
+
ensureTaskRegistryReady();
|
|
2321
|
+
const key = normalizeOptionalString(ownerKey);
|
|
2322
|
+
if (!key) return [];
|
|
2323
|
+
return listTasksFromIndex(taskIdsByOwnerKey, key);
|
|
2324
|
+
}
|
|
2325
|
+
function listTasksForFlowId(flowId) {
|
|
2326
|
+
ensureTaskRegistryReady();
|
|
2327
|
+
const key = flowId.trim();
|
|
2328
|
+
if (!key) return [];
|
|
2329
|
+
return listTasksFromIndex(taskIdsByParentFlowId, key);
|
|
2330
|
+
}
|
|
2331
|
+
function findLatestTaskForRelatedSessionKey(sessionKey) {
|
|
2332
|
+
const task = listTasksForRelatedSessionKey(sessionKey)[0];
|
|
2333
|
+
return task ? cloneTaskRecord(task) : void 0;
|
|
2334
|
+
}
|
|
2335
|
+
function listTasksForRelatedSessionKey(sessionKey) {
|
|
2336
|
+
ensureTaskRegistryReady();
|
|
2337
|
+
const key = normalizeOptionalString(sessionKey);
|
|
2338
|
+
if (!key) return [];
|
|
2339
|
+
return listTasksFromIndex(taskIdsByRelatedSessionKey, key);
|
|
2340
|
+
}
|
|
2341
|
+
function resolveTaskForLookupToken(token) {
|
|
2342
|
+
const lookup = token.trim();
|
|
2343
|
+
if (!lookup) return;
|
|
2344
|
+
return getTaskById(lookup) ?? findTaskByRunId(lookup) ?? findLatestTaskForRelatedSessionKey(lookup);
|
|
2345
|
+
}
|
|
2346
|
+
function deleteTaskRecordById(taskId) {
|
|
2347
|
+
ensureTaskRegistryReady();
|
|
2348
|
+
const current = tasks.get(taskId);
|
|
2349
|
+
if (!current) return false;
|
|
2350
|
+
deleteOwnerKeyIndex(taskId, current);
|
|
2351
|
+
deleteParentFlowIdIndex(taskId, current);
|
|
2352
|
+
deleteRelatedSessionKeyIndex(taskId, current);
|
|
2353
|
+
tasks.delete(taskId);
|
|
2354
|
+
taskDeliveryStates.delete(taskId);
|
|
2355
|
+
rebuildRunIdIndex();
|
|
2356
|
+
persistTaskDelete(taskId);
|
|
2357
|
+
persistTaskDeliveryStateDelete(taskId);
|
|
2358
|
+
emitTaskRegistryObserverEvent(() => ({
|
|
2359
|
+
kind: "deleted",
|
|
2360
|
+
taskId: current.taskId,
|
|
2361
|
+
previous: cloneTaskRecord(current)
|
|
2362
|
+
}));
|
|
2363
|
+
return true;
|
|
2364
|
+
}
|
|
2365
|
+
//#endregion
|
|
2366
|
+
export { finishFlow as A, setTaskRunDeliveryStatusByRunId as C, deleteTaskFlowRecordById as D, createTaskFlowForTask as E, requestFlowCancel as F, resolveTaskFlowForLookupToken as I, resumeFlow as L, getTaskFlowRegistryRestoreFailure as M, listTaskFlowRecords as N, failFlow as O, listTaskFlowsForOwnerKey as P, setFlowWaiting as R, setTaskCleanupAfterById as S, createManagedTaskFlow as T, markTaskTerminalById as _, findTaskByRunId as a, recordTaskProgressByRunId as b, linkTaskToFlowById as c, listTasksForFlowId as d, listTasksForOwnerKey as f, markTaskRunningByRunId as g, markTaskLostById as h, ensureTaskRegistryReady as i, getTaskFlowById as j, findLatestTaskFlowForOwnerKey as k, listTaskRecords as l, listTasksForSessionKey as m, createTaskRecord as n, getTaskById as o, listTasksForRelatedSessionKey as p, deleteTaskRecordById as r, isParentFlowLinkError as s, cancelTaskById as t, listTasksForAgentId as u, markTaskTerminalByRunId as v, updateTaskNotifyPolicyById as w, resolveTaskForLookupToken as x, maybeDeliverTaskTerminalUpdate as y, updateFlowRecordByIdExpectedRevision as z };
|