@gaodefa/daocore 2026.5.29 → 2026.5.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abort-DI3P6TIb.js +277 -0
- package/dist/abort.runtime-B6Z7lDEa.js +2 -0
- package/dist/abort.runtime.js +1 -1
- package/dist/account-inspect-BFz7X0TX.js +173 -0
- package/dist/accounts-BoYYrY7x.js +107 -0
- package/dist/accounts-Busq29zW.js +107 -0
- package/dist/accounts-CuvH2tuN.js +119 -0
- package/dist/accounts-DkIcqvf7.js +2 -0
- package/dist/acp-runtime-BA8lzXzf.js +26 -0
- package/dist/acp-spawn-DPz2aX3A.js +2 -0
- package/dist/acp-spawn-DvVCsWYV.js +1275 -0
- package/dist/acp-stateful-target-driver-DcC76aZW.js +89 -0
- package/dist/action-kill-D-dVisIX.js +33 -0
- package/dist/action-runtime-BEiqwxDD.js +469 -0
- package/dist/action-runtime-api-1LzcGjcX.js +2 -0
- package/dist/action-send-c3CnDuPg.js +39 -0
- package/dist/action-spawn-Dj4kwpWs.js +47 -0
- package/dist/actions-qLccmQBc.js +161 -0
- package/dist/actions.runtime-B5vYAgNi.js +5 -0
- package/dist/agent-command-D6Ds198G.js +1367 -0
- package/dist/agent-components.runtime-xquK0B3L.js +10 -0
- package/dist/agent-components.runtime.js +1 -1
- package/dist/agent-harness-runtime-Dq1fCBOM.js +180 -0
- package/dist/agent-harness-task-runtime-DvSEqFkD.js +140 -0
- package/dist/agent-lm5ZYOFy.js +3 -0
- package/dist/agent-runner-execution-Dbh2pDhQ.js +1713 -0
- package/dist/agent-runner-utils-Di3r2T1T.js +266 -0
- package/dist/agent-runner.runtime-BW90EcGW.js +3455 -0
- package/dist/agent-runner.runtime.js +1 -1
- package/dist/agent-runtime-BgIT5Ytc.js +229 -0
- package/dist/agent-via-gateway-DMMS8-hK.js +463 -0
- package/dist/agent-ylolD8-V.js +2 -0
- package/dist/api-BB4vXLtW.js +2 -0
- package/dist/api-CUhM3KNB.js +134 -0
- package/dist/api-CewRHSbT.js +6 -0
- package/dist/api-CfKjNJlW.js +2 -0
- package/dist/api-Rsnqui1u.js +3 -0
- package/dist/api-k7AvxwHr.js +639 -0
- package/dist/apply-DQ4TQNMA.js +54 -0
- package/dist/apply-S_75Py4Y.js +41 -0
- package/dist/approval-handler.runtime-Cthxrstu.js +130 -0
- package/dist/assistant-Cp9pGaBw.js +291 -0
- package/dist/attachment-normalize-5R0bLLOj.js +225 -0
- package/dist/attempt-execution-DuyyZYsU.js +558 -0
- package/dist/attempt-execution.runtime-DF2GPgNh.js +3 -0
- package/dist/attempt-execution.runtime.js +1 -1
- package/dist/attempt-execution.shared-CwdukA3t.js +38 -0
- package/dist/attempt.prompt-helpers-CUqKtIa5.js +475 -0
- package/dist/attempt.tool-run-context-BbN4_BYO.js +2094 -0
- package/dist/binding-routing-C6Ex2Blu.js +113 -0
- package/dist/binding-targets-BqREncSL.js +121 -0
- package/dist/bot-DGMEkaIJ.js +7894 -0
- package/dist/bot-deps-BltYjeMX.js +2 -0
- package/dist/bot-deps-XvGCor9f.js +747 -0
- package/dist/bot-message-context.runtime-kK-xvLV7.js +7 -0
- package/dist/bot-message-context.runtime.js +1 -1
- package/dist/bot-message-context.session.runtime-DpOIJUae.js +12 -0
- package/dist/bot-message-context.session.runtime.js +1 -1
- package/dist/bot-native-commands.delivery.runtime-D49p5Lc1.js +4 -0
- package/dist/bot-native-commands.delivery.runtime.js +1 -1
- package/dist/bot-native-commands.runtime-8XBdSpkQ.js +13 -0
- package/dist/bot-native-commands.runtime.js +1 -1
- package/dist/bridge-server-y_XGduPx.js +113 -0
- package/dist/browser-cli-B2jmmTT3.js +230 -0
- package/dist/browser-cli-actions-input-JQt5ZQcn.js +473 -0
- package/dist/browser-cli-actions-observe-CrfKh6AX.js +81 -0
- package/dist/browser-cli-debug-DQACWlvC.js +137 -0
- package/dist/browser-cli-inspect-DDnxx0Xw.js +104 -0
- package/dist/browser-cli-lEuOnZzs.js +2 -0
- package/dist/browser-cli-manage-DogmwtYt.js +443 -0
- package/dist/browser-cli-resize-BHuV71VZ.js +26 -0
- package/dist/browser-cli-shared-CidShgoF.js +50 -0
- package/dist/browser-cli-state-i8cCGbiQ.js +337 -0
- package/dist/browser-control-auth-CKfXdXWj.js +2 -0
- package/dist/browser-profiles-ATBTvUGh.js +2 -0
- package/dist/browser-runtime-KmCT6FuL.js +384 -0
- package/dist/build-DOOT6f62.js +257 -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/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/capability-cli-DwvrwB-g.js +1782 -0
- package/dist/channel-B-wgK1bK.js +481 -0
- package/dist/channel-B1e_k1P0.js +867 -0
- package/dist/channel-BRDfa5tc.js +1777 -0
- package/dist/channel-BVEO1O4p.js +376 -0
- package/dist/channel-BYlO5l1d.js +508 -0
- package/dist/channel-Bl0sPoNx.js +653 -0
- package/dist/channel-C84xtDBy.js +1134 -0
- package/dist/channel-CLgKq4Ds.js +1556 -0
- package/dist/channel-CZT0qxLh.js +1249 -0
- package/dist/channel-CffBHWkb.js +955 -0
- package/dist/channel-D34ZJvVB.js +2126 -0
- package/dist/channel-DcdXLo_W.js +238 -0
- package/dist/channel-DnK5TrXV.js +362 -0
- package/dist/channel-Dzj4RHY2.js +740 -0
- package/dist/channel-OhZzLZCj.js +562 -0
- package/dist/channel-actions.runtime-Cdvhqc9s.js +265 -0
- package/dist/channel-actions.runtime.js +1 -1
- package/dist/channel-core-Dz9I_R4j.js +5 -0
- package/dist/channel-inbound-COGoV_aS.js +80 -0
- package/dist/channel-mP6HCIMr.js +1496 -0
- package/dist/channel-plugin-runtime-C0R46KeG.js +998 -0
- package/dist/channel-quGdgWel.js +808 -0
- package/dist/channel-runtime-FvPQoIF9.js +408 -0
- package/dist/channel.runtime-2vUz3gij.js +109 -0
- package/dist/channel.runtime-BZLDSNuQ.js +254 -0
- package/dist/channel.runtime-Bo5jO0Hj.js +4 -0
- package/dist/channel.runtime-CDgvrjM2.js +652 -0
- package/dist/channel.runtime-COf8SDFn.js +88 -0
- package/dist/channel.runtime-C_C1f8lu.js +733 -0
- package/dist/channel.runtime-CqPbsg8t.js +2528 -0
- package/dist/channel.runtime-DtV85Khx.js +1008 -0
- package/dist/channel.runtime-Spt1ukGW.js +21009 -0
- package/dist/channel.setup-Bc0LUQS1.js +1098 -0
- package/dist/channel.setup-ChTkj2hq.js +343 -0
- package/dist/channel.setup-CpMD9F8i.js +10 -0
- package/dist/chat-mUsjD5YN.js +2666 -0
- package/dist/chrome-u314zcbM.js +1503 -0
- package/dist/cli/run-main.js +5 -5
- package/dist/cli-CJMoqXrc.js +1341 -0
- package/dist/cli-compaction-qGYB7suI.js +347 -0
- package/dist/cli-metadata-BBJFpNU9.js +22 -0
- package/dist/cli-runner-C0kcts0I.js +540 -0
- package/dist/cli-runner-CTm8K6s8.js +2 -0
- package/dist/cli-runner.runtime-C8deL5FL.js +3 -0
- package/dist/cli-runner.runtime-DDAg1D0L.js +4 -0
- package/dist/cli-runner.runtime.js +1 -1
- package/dist/cli-startup-metadata.json +8 -8
- package/dist/client-CPxpgs4m.js +650 -0
- package/dist/client-adapter-CLlqOqfu.js +897 -0
- package/dist/client-factory-R7Rr2jwn.js +9 -0
- package/dist/command-auth-CkQP1buP.js +135 -0
- package/dist/command-handlers-CJEjFyMk.js +1609 -0
- package/dist/command-registry-BDgyOqDw.js +4 -0
- package/dist/command-registry-BVi5Jn1S.js +9 -0
- package/dist/command-registry-core-JCfsVRtz.js +110 -0
- package/dist/command-status.runtime-CM1JLzi6.js +90 -0
- package/dist/command-status.runtime.js +1 -1
- package/dist/commands-acp-C1-I78U6.js +74 -0
- package/dist/commands-compact.runtime-DOsNavwp.js +10 -0
- package/dist/commands-compact.runtime.js +1 -1
- package/dist/commands-handlers.runtime-BD1n2WGw.js +6154 -0
- package/dist/commands-handlers.runtime.js +1 -1
- package/dist/commands-status-DU_UTQz1.js +16 -0
- package/dist/commands-status-DejfTakp.js +3 -0
- package/dist/commands-status.runtime-DejfTakp.js +3 -0
- package/dist/commands-status.runtime.js +1 -1
- package/dist/commands-subagents-control.runtime-D7vo_2Y_.js +3 -0
- package/dist/commands-subagents-control.runtime-DGybTjJ6.js +2 -0
- package/dist/commands-subagents-control.runtime.js +1 -1
- package/dist/commands-system-prompt-BEBXAMea.js +2 -0
- package/dist/commands-system-prompt-gj3oQpQO.js +162 -0
- package/dist/commands.runtime-CgXX70IN.js +176 -0
- package/dist/commands.runtime.js +1 -1
- package/dist/commitments/runtime.js +1 -1
- package/dist/compact-C41XxMDt.js +480 -0
- package/dist/compact-DUVAF9EC.js +1141 -0
- package/dist/compact.runtime-COMRg6s3.js +12 -0
- package/dist/compact.runtime.js +1 -1
- package/dist/completion-cli-CmEYoB9a.js +315 -0
- package/dist/computer-use-BwJHu1QF.js +367 -0
- package/dist/config-ATBTvUGh.js +2 -0
- package/dist/config-DlNgjF8W.js +373 -0
- package/dist/config-mutations-tl_OqI6d.js +159 -0
- package/dist/context-engine-host-compat-BNPAIK9F.js +288 -0
- package/dist/context-engine-host-compat-C69CK7zS.js +2 -0
- package/dist/context-engine-lifecycle-iQ8f5a_-.js +1274 -0
- package/dist/control-auth-vVxyGKxY.js +114 -0
- package/dist/control-service-73nj79EW.js +145 -0
- package/dist/control-ui/assets/agents-DdWIz8Vk.js +1008 -0
- package/dist/control-ui/assets/channel-config-extras-C7ELhuDi.js +2 -0
- package/dist/control-ui/assets/channels-Bsoj-9BS.js +367 -0
- package/dist/control-ui/assets/cron-BRTEw1tT.js +1013 -0
- package/dist/control-ui/assets/debug-EKl_F8_L.js +97 -0
- package/dist/control-ui/assets/index-DSbSO7ys.js +7370 -0
- package/dist/control-ui/assets/instances-B1AoYwI5.js +57 -0
- package/dist/control-ui/assets/logs-BChOznzh.js +74 -0
- package/dist/control-ui/assets/nodes-5yebKh9k.js +436 -0
- package/dist/control-ui/assets/sessions-BlDYNThc.js +399 -0
- package/dist/control-ui/assets/skills-shared-CNFnf7KU.js +11 -0
- package/dist/control-ui/assets/skills-uxTDRmLx.js +314 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/control-ui/sw.js +1 -1
- package/dist/conversation-binding-runtime-CmoTKcY1.js +4 -0
- package/dist/conversation-runtime-BxOHxuin.js +31 -0
- package/dist/core-D0Y2H55f.js +282 -0
- package/dist/core-api-BKlJUtDt.js +5 -0
- package/dist/core-api-_fiftUHn.js +2 -0
- package/dist/crestodian/crestodian.js +1 -1
- package/dist/crestodian/rescue-message.js +1 -1
- package/dist/crestodian-BJifoQiR.js +55 -0
- package/dist/daocore-tools-BMdF8RwK.js +11727 -0
- package/dist/delivery-e2ci_bcX.js +1002 -0
- package/dist/dialogue-BXayGhnz.js +37 -0
- package/dist/dir-fetch-tool-Cara5mZh.js +565 -0
- package/dist/dir-list-tool-CQ8Bo5Ez.js +100 -0
- package/dist/direct-dm-CPk6Qm9D.js +64 -0
- package/dist/directive-handling.fast-lane-BQ9aXqk8.js +68 -0
- package/dist/directive-handling.impl--a5AGurq.js +818 -0
- package/dist/directive-handling.impl-C4JqMwle.js +2 -0
- package/dist/directive-handling.model-selection-pyTYMIXn.js +122 -0
- package/dist/directive-handling.persist.runtime-B7vWT1r9.js +263 -0
- package/dist/directive-handling.persist.runtime.js +1 -1
- package/dist/dispatch-3Ru_eGq1.js +1640 -0
- package/dist/dispatch-acp-transcript.runtime-CYMP-5oE.js +40 -0
- package/dist/dispatch-acp-transcript.runtime.js +1 -1
- package/dist/dispatch-acp.runtime-BVCiklXk.js +18 -0
- package/dist/dispatch-acp.runtime.js +1 -1
- package/dist/doctor-B8mR3Sgr.js +2 -0
- package/dist/doctor-BJ6DuerV.js +6 -0
- package/dist/doctor-config-flow-BdOGs_zn.js +1741 -0
- package/dist/doctor-core-checks-CDf0stz-.js +2 -0
- package/dist/doctor-core-checks-Cpdnu2XI.js +573 -0
- package/dist/doctor-health-0qv_acBu.js +65 -0
- package/dist/doctor-health-contributions-Db1FQgFw.js +696 -0
- package/dist/doctor-lint-C1g4Llgl.js +94 -0
- package/dist/doctor-state-integrity-C8iXFLJ7.js +1231 -0
- package/dist/doctor-update-CsPu6p3d.js +58 -0
- package/dist/dynamic-tools-YQ0z0YKH.js +486 -0
- package/dist/embedded-backend-S0cahIZw.js +579 -0
- package/dist/embedded-gateway-stub.runtime-Cjw12ALm.js +12 -0
- package/dist/embedded-gateway-stub.runtime.js +1 -1
- package/dist/exec-approvals-ArHHjoE-.js +149 -0
- package/dist/extensionAPI.js +1 -1
- package/dist/extensions/active-memory/index.js +1 -1
- package/dist/extensions/admin-http-rpc/index.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 +1 -1
- package/dist/extensions/browser/browser-profiles.js +2 -2
- package/dist/extensions/browser/browser-runtime-api.js +11 -11
- package/dist/extensions/browser/cli-metadata.js +1 -1
- package/dist/extensions/browser/index.js +1 -1
- package/dist/extensions/browser/plugin-registration.js +1 -1
- package/dist/extensions/browser/register.runtime.js +4 -4
- package/dist/extensions/browser/runtime-api.js +13 -13
- package/dist/extensions/canvas/index.js +1 -1
- package/dist/extensions/clickclack/api.js +2 -2
- package/dist/extensions/clickclack/channel-plugin-api.js +1 -1
- package/dist/extensions/clickclack/runtime-api.js +2 -2
- package/dist/extensions/device-pair/api.js +1 -1
- package/dist/extensions/device-pair/pair-command-approve.js +1 -1
- package/dist/extensions/file-transfer/index.js +4 -4
- package/dist/extensions/imessage/api.js +2 -2
- package/dist/extensions/imessage/channel-plugin-api.js +1 -1
- package/dist/extensions/imessage/message-tool-api.d.ts +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/llm-task/index.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 +2 -2
- package/dist/extensions/mattermost/slash-route-api.js +1 -1
- package/dist/extensions/memory-core/cli-metadata.js +1 -1
- package/dist/extensions/migrate-claude/apply.js +1 -1
- package/dist/extensions/migrate-claude/index.js +1 -1
- package/dist/extensions/migrate-claude/plan.js +1 -1
- package/dist/extensions/migrate-claude/provider.js +1 -1
- package/dist/extensions/migrate-claude/targets.js +1 -1
- package/dist/extensions/migrate-hermes/apply.js +1 -1
- package/dist/extensions/migrate-hermes/index.js +1 -1
- package/dist/extensions/migrate-hermes/model.js +1 -1
- package/dist/extensions/migrate-hermes/plan.js +1 -1
- package/dist/extensions/migrate-hermes/provider.js +1 -1
- package/dist/extensions/migrate-hermes/secrets.js +1 -1
- package/dist/extensions/migrate-hermes/targets.js +1 -1
- package/dist/extensions/policy/api.js +1 -1
- package/dist/extensions/policy/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 +2 -2
- package/dist/extensions/telegram/account-inspect-api.js +1 -1
- package/dist/extensions/telegram/api.js +11 -11
- package/dist/extensions/telegram/channel-plugin-api.js +2 -2
- package/dist/extensions/telegram/contract-api.js +3 -3
- package/dist/extensions/telegram/runtime-api.js +7 -7
- package/dist/extensions/telegram/security-audit-contract-api.js +1 -1
- package/dist/extensions/telegram/setup-plugin-api.js +1 -1
- package/dist/extensions/telegram/test-api.js +2 -2
- package/dist/extensions/webhooks/api.js +1 -1
- package/dist/extensions/webhooks/index.js +1 -1
- package/dist/extensions/xai/index.js +4 -4
- package/dist/extensions/xai/realtime-transcription-provider.js +1 -1
- package/dist/extensions/xai/speech-provider.js +1 -1
- package/dist/extensions/xai/test-api.js +1 -1
- package/dist/extensions/xai/tts.js +1 -1
- package/dist/extensions/xai/web-search.js +1 -1
- package/dist/extensions/xai/xai-oauth.js +1 -1
- package/dist/file-fetch-tool-DQpAtjX4.js +124 -0
- package/dist/file-write-tool-CkB0oYwe.js +127 -0
- package/dist/format-DUJUpMFQ.js +1145 -0
- package/dist/gateway-cli-CQo_E4Ka.js +435 -0
- package/dist/gateway-method-runtime-1QPgVJH7.js +21 -0
- package/dist/get-reply-DfUcsC-O.js +4689 -0
- package/dist/get-reply-from-config.runtime-C95MG73O.js +2 -0
- package/dist/get-reply-from-config.runtime.js +1 -1
- package/dist/graph-users-DPJe0fPs.js +1419 -0
- package/dist/group-access-DefaNJ6L.js +112 -0
- package/dist/handle-action.guild-admin-C1sy1kGJ.js +288 -0
- package/dist/harness-BgPRdmNK.js +61 -0
- package/dist/health-DFR9A1YV.js +4 -0
- package/dist/heartbeat-runner-BiYVPs25.js +5 -0
- package/dist/heartbeat-runner.runtime-Bmaq8WUA.js +4 -0
- package/dist/heartbeat-runner.runtime.js +1 -1
- package/dist/hooks-CNJDuJUm.js +534 -0
- package/dist/inbound-direct-dm-runtime-DFt58p71.js +2 -0
- package/dist/inbound-reply-dispatch-kgSDM8ax.js +148 -0
- package/dist/index.js +1 -1
- package/dist/init-B0zO_U4r.js +59 -0
- package/dist/inline-buttons-B6zgQW3J.js +40 -0
- package/dist/internal-events-C3Q5t6hg.js +90 -0
- package/dist/isolated-agent-CaSU5GCJ.js +2 -0
- package/dist/isolated-agent-CnsD2TmP.js +1118 -0
- package/dist/lifecycle-i3WZDaIn.js +571 -0
- package/dist/list.probe-g0rUiVXW.js +449 -0
- package/dist/list.status-command-DG3PrmeO.js +789 -0
- package/dist/llm-slug-generator-CHlf69FU.js +78 -0
- package/dist/llm-slug-generator.js +1 -1
- package/dist/local-dispatch.runtime-CDeHUp_A.js +9 -0
- package/dist/local-dispatch.runtime.js +1 -1
- package/dist/manager.runtime-BlLMPUTq.js +2714 -0
- package/dist/manager.runtime.js +1 -1
- package/dist/markdown-to-line-r_mBHMdy.js +811 -0
- package/dist/mcp-http-C5UPIJGR.js +555 -0
- package/dist/mcp-http-CTy9gpfA.js +2 -0
- package/dist/media-understanding-provider-BT6TOuVa.js +339 -0
- package/dist/message-actions-BdcjjwFt.js +145 -0
- package/dist/message-handler-B29Tj2p2.js +1715 -0
- package/dist/message-handler-BhHb1FHI.js +384 -0
- package/dist/message-handler.preflight-ouZ_-3o8.js +1125 -0
- package/dist/message-handler.process-CrYiBx_F.js +1484 -0
- package/dist/model-CLbtocQX.js +74 -0
- package/dist/model-selection-BG_vU9Kl.js +272 -0
- package/dist/models-4KERn3ya.js +104 -0
- package/dist/models-BCa-ipxi.js +2 -0
- package/dist/models-cli-DtpGXEsf.js +256 -0
- package/dist/monitor-B-egsvmI.js +1657 -0
- package/dist/monitor-BJX9Yv7k.js +2 -0
- package/dist/monitor-BPrIy3pV.js +715 -0
- package/dist/monitor-BWknZZ7N.js +4377 -0
- package/dist/monitor-C3y_PtI1.js +60 -0
- package/dist/monitor-DCzfdqE4.js +1370 -0
- package/dist/monitor-P24epSwE.js +2788 -0
- package/dist/monitor-auth-CEG_xldE.js +179 -0
- package/dist/monitor-jEePJbbS.js +834 -0
- package/dist/monitor-polling.runtime-BzlHK11u.js +883 -0
- package/dist/monitor-polling.runtime.js +1 -1
- package/dist/monitor-webhook.runtime-vFEhk_Zj.js +387 -0
- package/dist/monitor-webhook.runtime.js +1 -1
- package/dist/monitor.account-BUIfgWXg.js +5233 -0
- package/dist/monitor.runtime-Cp7W4fhb.js +2 -0
- package/dist/monitor.runtime.js +1 -1
- package/dist/monitor.webhook-DzrbeR4T.js +180 -0
- package/dist/node-cli-sessions-CLbI14UA.js +1228 -0
- package/dist/openai-http-BM9BIA_g.js +824 -0
- package/dist/openresponses-http-CNoW9kk8.js +1173 -0
- package/dist/operations-DT4bsxV6.js +805 -0
- package/dist/outbound-adapter-CZRUOgY0.js +543 -0
- package/dist/outbound-session-route-DneMsGNx.js +45 -0
- package/dist/outbound.runtime-CHuoKJJI.js +2 -0
- package/dist/outbound.runtime.js +1 -1
- package/dist/pi-embedded-1-rsueO_.js +3796 -0
- package/dist/pi-embedded-BRfDncVO.js +4 -0
- package/dist/pi-embedded.runtime-DEYoa6bW.js +4 -0
- package/dist/pi-embedded.runtime.js +1 -1
- package/dist/pi-tools-C0P3NgP5.js +2413 -0
- package/dist/plan-BQUkjBMY.js +81 -0
- package/dist/plan-CRO9_2_k.js +112 -0
- package/dist/plugin-BJCmWhnh.js +12396 -0
- package/dist/plugin-app-cache-key-CXAg0F7A.js +46 -0
- package/dist/plugin-enabled-D93Z9LSo.js +233 -0
- package/dist/plugin-registration-BBrTcZnf.js +88 -0
- package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
- package/dist/plugin-sdk/acp-runtime-backend.js +1 -1
- package/dist/plugin-sdk/acp-runtime.js +2 -2
- package/dist/plugin-sdk/agent-harness-runtime.js +6 -6
- package/dist/plugin-sdk/agent-harness-task-runtime.js +1 -1
- package/dist/plugin-sdk/agent-harness.js +7 -7
- package/dist/plugin-sdk/agent-runtime.js +2 -2
- package/dist/plugin-sdk/channel-core.js +2 -2
- package/dist/plugin-sdk/channel-inbound.js +2 -2
- package/dist/plugin-sdk/channel-test-helpers.js +1 -1
- 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 +2 -2
- 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-method-runtime.js +1 -1
- package/dist/plugin-sdk/health.js +2 -2
- package/dist/plugin-sdk/inbound-reply-dispatch.js +1 -1
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/mattermost.js +1 -1
- package/dist/plugin-sdk/plugin-test-contracts.js +2 -2
- package/dist/plugin-sdk/provider-test-contracts.js +4 -4
- package/dist/plugin-sdk/reply-runtime.js +4 -4
- package/dist/plugin-sdk/testing.js +2 -2
- package/dist/plugin-sdk/zalouser.js +1 -1
- package/dist/plugin-service-DnZEPBEA.js +1229 -0
- package/dist/plugins/runtime/index.js +4 -4
- package/dist/policy-CMv5QMPG.js +138 -0
- package/dist/policy-CeoP4t9J.js +680 -0
- package/dist/prepare.runtime-DZ55JiTt.js +732 -0
- package/dist/prepare.runtime.js +1 -1
- package/dist/preview-warnings-O08PZRxu.js +392 -0
- package/dist/probe-C6w3bP8X.js +682 -0
- package/dist/probe-Cs1_X1NA.js +47 -0
- package/dist/probe-Cuee_jyM.js +2204 -0
- package/dist/probe-DZxCnDzn.js +2 -0
- package/dist/program-C2dT8VHB.js +131 -0
- package/dist/provider-C2_vSzYh.js +32 -0
- package/dist/provider-DSfTDQbj.js +152 -0
- package/dist/provider-U8hrm9h-.js +32 -0
- package/dist/provider-_v910H8y.js +8735 -0
- package/dist/provider-dispatcher-C3kmmIEC.js +22 -0
- package/dist/provider-dispatcher.runtime.js +1 -1
- package/dist/provider-session.runtime-Mg0fx5hH.js +9 -0
- package/dist/provider-session.runtime.js +1 -1
- package/dist/provider.runtime-pSTXuHrq.js +2 -0
- package/dist/provider.runtime.js +1 -1
- package/dist/public-surface-loader-09t4TTue.js +114 -0
- package/dist/pw-ai-DjNqHV3_.js +3029 -0
- package/dist/pw-role-snapshot-DoGefdv7.js +333 -0
- package/dist/reaction-level-C8Mqxizo.js +19 -0
- package/dist/reaction-runtime-api-DOP6xOsm.js +116 -0
- package/dist/realtime-transcription-provider-BTGEXXna.js +205 -0
- package/dist/register-CbZPpqI3.js +2178 -0
- package/dist/register.agent-DrBFuPKh.js +156 -0
- package/dist/register.crestodian-DwTbmaK8.js +24 -0
- package/dist/register.maintenance-BIeoYBub.js +83 -0
- package/dist/register.runtime-B5V9_Dwz.js +54 -0
- package/dist/register.subclis-CJE9ISZY.js +31 -0
- package/dist/register.subclis-YQsKas8N.js +3 -0
- package/dist/register.subclis-core-CjwdGeGU.js +273 -0
- package/dist/repair-sequencing-C0jrL5pw.js +640 -0
- package/dist/reply-delivery-B28mTIpb.js +196 -0
- package/dist/reply-runtime-BqQX7HHw.js +11 -0
- package/dist/reply.runtime-C95MG73O.js +2 -0
- package/dist/reply.runtime.js +1 -1
- package/dist/request-BqoMvXxH.js +54 -0
- package/dist/resolve-allowlist-hbKKd_kq.js +220 -0
- package/dist/result-fallback-classifier-BrORPoxj.js +79 -0
- package/dist/route-HHRgSzVy.js +469 -0
- package/dist/route-resolution-C7bafjVc.js +274 -0
- package/dist/routes-86XGeo7a.js +2 -0
- package/dist/routes-BhVGr9ie.js +3602 -0
- package/dist/run-Bb5QP5JV.js +1162 -0
- package/dist/run-attempt-CLi0wV7j.js +7704 -0
- package/dist/run-command-Be6GAxiW.js +2 -0
- package/dist/run-command-Ds4hr3iU.js +23 -0
- package/dist/run-embedded.runtime-wX9ORojX.js +4 -0
- package/dist/run-embedded.runtime.js +1 -1
- package/dist/run-execution-cli.runtime-BmNZVB2N.js +4 -0
- package/dist/run-execution-cli.runtime.js +1 -1
- package/dist/run-executor.runtime.js +1 -1
- package/dist/run-subagent-registry.runtime-Uq5sjftu.js +2 -0
- package/dist/run-subagent-registry.runtime.js +1 -1
- package/dist/runtime-BktLQ75j.js +1287 -0
- package/dist/runtime-C9XdR62_.js +438 -0
- package/dist/runtime-CTvWDPx9.js +6179 -0
- package/dist/runtime-api-BojB3MUw.js +21 -0
- package/dist/runtime-api-C92MlAwp.js +13 -0
- package/dist/runtime-api-CFNZE9Xt.js +13 -0
- package/dist/runtime-api-Cimpgm5_.js +3 -0
- package/dist/runtime-api-D8qG_lUm.js +17 -0
- package/dist/runtime-api-DMDMnQEG.js +4 -0
- package/dist/runtime-api-DupQdIlE.js +24 -0
- package/dist/runtime-api.actions-B8i3elqu.js +3 -0
- package/dist/runtime-api.monitor-BntFzf_M.js +6 -0
- package/dist/runtime-api.send-CPlmi1jc.js +4 -0
- package/dist/runtime-api.threads-D-H_r_Nl.js +2 -0
- package/dist/runtime-channel-BGhTxnXZ.js +150 -0
- package/dist/runtime-channel-CPFxNapZ.js +2 -0
- package/dist/runtime-embedded-pi.runtime-BjnMTurB.js +2 -0
- package/dist/runtime-embedded-pi.runtime.js +1 -1
- package/dist/sanitize-outbound-BMUv1NeS.js +127 -0
- package/dist/sdk-setup-tools-Do3DkQi_.js +8 -0
- package/dist/secrets-B8YVPHhk.js +113 -0
- package/dist/security-audit-7Gg_nL4o.js +122 -0
- package/dist/security-audit-Bk3CREj-.js +118 -0
- package/dist/security-audit.runtime-BmSJrdeq.js +2 -0
- package/dist/security-audit.runtime.js +1 -1
- package/dist/selection-BFGde9-_.js +3 -0
- package/dist/selection-DrLFlbgG.js +16157 -0
- package/dist/send-4dLa-BQo.js +1631 -0
- package/dist/send-CV6gCwYP.js +192 -0
- package/dist/send-aGiK3Efu.js +143 -0
- package/dist/send-dB3CehAN.js +2 -0
- package/dist/send.components-BcG9BlkC.js +2 -0
- package/dist/send.components-rLjDlfYU.js +500 -0
- package/dist/send.runtime-D20k2MSr.js +2 -0
- package/dist/send.runtime.js +1 -1
- package/dist/server-BTRx_U1s.js +73 -0
- package/dist/server-CY0ymhBg.js +24 -0
- package/dist/server-close.runtime.js +1 -1
- package/dist/server-context-BxGT8wbK.js +955 -0
- package/dist/server-context-DYlbhAaT.js +2 -0
- package/dist/server-cron-BB_15lcP.js +2 -0
- package/dist/server-cron-CfyJX_a4.js +2989 -0
- package/dist/server-methods-Ck2ab6TC.js +16494 -0
- package/dist/server-node-events-BdRizF-5.js +596 -0
- package/dist/server-plugin-bootstrap-CPUr8NFE.js +70 -0
- package/dist/server-plugins-__5AxjzH.js +432 -0
- package/dist/server-reload-handlers-BMl9Fx9b.js +714 -0
- package/dist/server-restart-sentinel-D11M_ZsH.js +747 -0
- package/dist/server-restart-sentinel-DGptQ27c.js +2 -0
- package/dist/server-runtime-services-BwtLs-8I.js +2 -0
- package/dist/server-runtime-services-aJydixRu.js +267 -0
- package/dist/server-startup-plugins-m_P3gY4m.js +113 -0
- package/dist/server-startup-post-attach-DuXQ1AXL.js +716 -0
- package/dist/server-ws-runtime-mXmxB1W8.js +349 -0
- package/dist/server.impl-fuV8aKSP.js +2586 -0
- package/dist/service-a8cTFka4.js +1446 -0
- package/dist/session-binding-BIycxo9u.js +2 -0
- package/dist/session-binding-xHwQr9vM.js +219 -0
- package/dist/session-kill-http-DiUZhcoN.js +121 -0
- package/dist/session-reset-service-DkepDoob.js +625 -0
- package/dist/session-route-Ba5u7ecb.js +93 -0
- package/dist/session-status.runtime-Cb1X69Rl.js +2 -0
- package/dist/session-status.runtime.js +1 -1
- package/dist/session-subagent-reactivation.runtime-rbqmto4G.js +2 -0
- package/dist/session-subagent-reactivation.runtime.js +1 -1
- package/dist/session-tab-registry-DSKOoJta.js +521 -0
- package/dist/sessions-history-http-CWP88I_C.js +430 -0
- package/dist/sessions.runtime-1q1OwLn3.js +2 -0
- package/dist/sessions.runtime.js +1 -1
- package/dist/setup-api-DtrOOYeP.js +29 -0
- package/dist/setup-core-DMrJS6LP.js +174 -0
- package/dist/setup-surface-BFPNu1qA.js +405 -0
- package/dist/setup-surface-CedShqhO.js +288 -0
- package/dist/setup-surface-DLOBH1Vf.js +320 -0
- package/dist/setup-surface-MhCeEWSj.js +221 -0
- package/dist/shared-DamL-e8D.js +121 -0
- package/dist/shared-client-B48JoAsz.js +2 -0
- package/dist/shared-client-BoSiDnUo.js +629 -0
- package/dist/side-question-DQoQ_ETb.js +683 -0
- package/dist/skill-tool-dispatch.runtime-CWLloYA8.js +143 -0
- package/dist/skill-tool-dispatch.runtime.js +1 -1
- package/dist/slash-state-DrrWJQfv.js +2166 -0
- package/dist/speech-provider-8Hx1uw41.js +184 -0
- package/dist/src-BbUYOPwU.js +4256 -0
- package/dist/startup-context-opAJAamX.js +313 -0
- package/dist/status-subagents.runtime-DSo7ZK_Z.js +18 -0
- package/dist/status-subagents.runtime.js +1 -1
- package/dist/status-text-AyPuDzrO.js +296 -0
- package/dist/sticker-cache-91Tp8mLP.js +206 -0
- package/dist/sticker-vision.runtime-DjleFXi5.js +17 -0
- package/dist/sticker-vision.runtime.js +1 -1
- package/dist/subagent-announce-delivery-DS_2W9oZ.js +958 -0
- package/dist/subagent-announce-hatA_PZ2.js +354 -0
- package/dist/subagent-control-IyFIvc7T.js +508 -0
- package/dist/subagent-hooks-BCj5eB0Z.js +2 -0
- package/dist/subagent-hooks-BWjTBkox.js +146 -0
- package/dist/subagent-hooks-CdGLK9_3.js +230 -0
- package/dist/subagent-hooks-EH0tBkw9.js +2 -0
- package/dist/subagent-hooks-api-BhYaXQJV.js +23 -0
- package/dist/subagent-hooks-api-uGsV8Xn5.js +22 -0
- package/dist/subagent-hooks-api-wfJFKIPx.js +23 -0
- package/dist/subagent-hooks-l8Xd94dt.js +2 -0
- package/dist/subagent-hooks-m2eHUO_d.js +116 -0
- package/dist/subagent-orphan-recovery-Bq9zvX3L.js +352 -0
- package/dist/subagent-registry-Bcb3zy6b.js +3 -0
- package/dist/subagent-registry-CoZNTFx-.js +2351 -0
- package/dist/subagent-registry.runtime.js +1 -1
- package/dist/subagent-session-cleanup--00EjDLe.js +525 -0
- package/dist/subagent-spawn-ClJJkz3D.js +1164 -0
- package/dist/target-id-BsZLiF3x.js +107 -0
- package/dist/targets-CQMe4AZP.js +44 -0
- package/dist/targets-SmL1AU-H.js +19 -0
- package/dist/targets-Y-roiA47.js +19 -0
- package/dist/task-registry-control.runtime.js +1 -1
- package/dist/telegram/token.js +1 -1
- package/dist/testing-B5hNJDuF.js +267 -0
- package/dist/thread-bindings-BD3eE0kK.js +232 -0
- package/dist/thread-bindings-C9NNiv8K.js +571 -0
- package/dist/thread-bindings-Dl4PN1vZ.js +228 -0
- package/dist/thread-bindings-uK1LLAwy.js +8 -0
- package/dist/thread-bindings.discord-api-BHNEUbnk.js +187 -0
- package/dist/thread-bindings.manager-B0LXiH3F.js +2 -0
- package/dist/thread-bindings.manager-BTlH4XMG.js +536 -0
- package/dist/thread-lifecycle-DG8uyPHd.js +1614 -0
- package/dist/token-BbGCANnE.js +134 -0
- package/dist/tool-actions.runtime-oUUrD8HB.js +534 -0
- package/dist/tool-actions.runtime.js +1 -1
- package/dist/tool-bqg-_vYv.js +139 -0
- package/dist/tool-resolution-CSZsa3kP.js +149 -0
- package/dist/tools-effective-inventory-0CqFp-vq.js +204 -0
- package/dist/tools-invoke-http-DhYHY0Yh.js +67 -0
- package/dist/tools-invoke-shared-CbVJJUj7.js +200 -0
- package/dist/tts-C2qD-ad6.js +66 -0
- package/dist/tui-CzGY254f.js +4709 -0
- package/dist/tui-backend-fzoeoSN0.js +256 -0
- package/dist/tui-cli-B2RWb2gM.js +37 -0
- package/dist/tui-dgS8hdXU.js +2 -0
- package/dist/update-cli-BmiBDf3c.js +3664 -0
- package/dist/update-runner-CM7QVX6u.js +2379 -0
- package/dist/vision-tools-BzoBZnIc.js +1409 -0
- package/dist/web-search-DmfOd66S.js +62 -0
- package/dist/web-search-provider.runtime-3C5-pODD.js +328 -0
- package/dist/web-search-provider.runtime-Doh-Z9We.js +2 -0
- package/dist/web-search-provider.runtime.js +1 -1
- package/dist/xai-oauth-BLvQ43hx.js +479 -0
- package/dist/xai-user-agent-BdMQ_0_O.js +32 -0
- package/package.json +1 -1
- package/dist/abort-DeEb_wKd.js +0 -277
- package/dist/abort.runtime-CoYXQGPK.js +0 -2
- package/dist/account-inspect-D_06-CYS.js +0 -173
- package/dist/accounts-BCTqtj4Y.js +0 -107
- package/dist/accounts-BudLl8P2.js +0 -107
- package/dist/accounts-CUReBDA0.js +0 -2
- package/dist/accounts-PCioSzzr.js +0 -119
- package/dist/acp-runtime-B2t9_BHD.js +0 -26
- package/dist/acp-spawn-0x4Iiu1o.js +0 -2
- package/dist/acp-spawn-B2Ghe0jJ.js +0 -1275
- package/dist/acp-stateful-target-driver-C4VgcSyz.js +0 -89
- package/dist/action-kill-ClYsXEz7.js +0 -33
- package/dist/action-runtime-DrLPkNvU.js +0 -469
- package/dist/action-runtime-api-BqSflr9q.js +0 -2
- package/dist/action-send-CIy9cziD.js +0 -39
- package/dist/action-spawn-BjV6lFnX.js +0 -47
- package/dist/actions-D-QH7wq5.js +0 -161
- package/dist/actions.runtime-hzDtXQGU.js +0 -5
- package/dist/agent-Bb1DTBgv.js +0 -3
- package/dist/agent-Cnqj258q.js +0 -2
- package/dist/agent-command-BRx6ZNgJ.js +0 -1367
- package/dist/agent-components.runtime-D-g6xXJ0.js +0 -10
- package/dist/agent-harness-runtime-dKUQFuOc.js +0 -180
- package/dist/agent-harness-task-runtime-v2crUm3i.js +0 -140
- package/dist/agent-runner-execution-AOzdxvWR.js +0 -1713
- package/dist/agent-runner-utils-Byv50B4Z.js +0 -266
- package/dist/agent-runner.runtime-hhgRE0Z-.js +0 -3455
- package/dist/agent-runtime-BHmh3i0o.js +0 -229
- package/dist/agent-via-gateway-DnCqaK4a.js +0 -463
- package/dist/api-Bzyb8sFU.js +0 -3
- package/dist/api-CIEDFXZs.js +0 -2
- package/dist/api-D_dTQAu8.js +0 -2
- package/dist/api-DilBjZ9Q.js +0 -6
- package/dist/api-E5zoQMmh.js +0 -134
- package/dist/api-OJZug8gQ.js +0 -639
- package/dist/apply-C0eV5T0O.js +0 -41
- package/dist/apply-alsYvxLE.js +0 -54
- package/dist/approval-handler.runtime-C6jqZXSN.js +0 -130
- package/dist/assistant-DDXnAAB5.js +0 -291
- package/dist/attachment-normalize-Cv-_4DWU.js +0 -225
- package/dist/attempt-execution-DECEU59r.js +0 -558
- package/dist/attempt-execution.runtime-kasMxuER.js +0 -3
- package/dist/attempt-execution.shared-ClUxk52p.js +0 -38
- package/dist/attempt.prompt-helpers-Bxlv9VSu.js +0 -475
- package/dist/attempt.tool-run-context-CplQWX6g.js +0 -2094
- package/dist/binding-routing-0Obpp-Ij.js +0 -113
- package/dist/binding-targets-CZHQaZL4.js +0 -121
- package/dist/bot-BPbQ0840.js +0 -7894
- package/dist/bot-deps-Cs1M9USs.js +0 -2
- package/dist/bot-deps-xAcaOtTZ.js +0 -747
- package/dist/bot-message-context.runtime-Bji78Cbn.js +0 -7
- package/dist/bot-message-context.session.runtime-C3dyOIYH.js +0 -12
- package/dist/bot-native-commands.delivery.runtime-WshH99fy.js +0 -4
- package/dist/bot-native-commands.runtime-C1L364gU.js +0 -13
- package/dist/bridge-server-DPlM8_Lk.js +0 -113
- package/dist/browser-cli-DFNQE98N.js +0 -230
- package/dist/browser-cli-Drb5E5--.js +0 -2
- package/dist/browser-cli-actions-input-Dx-1OXmE.js +0 -473
- package/dist/browser-cli-actions-observe-BMDfE7xU.js +0 -81
- package/dist/browser-cli-debug-nu7Ih09g.js +0 -137
- package/dist/browser-cli-inspect-D5X2wohg.js +0 -104
- package/dist/browser-cli-manage-DkzYwph4.js +0 -443
- package/dist/browser-cli-resize-B30Avedl.js +0 -26
- package/dist/browser-cli-shared-cMgQoQzF.js +0 -50
- package/dist/browser-cli-state-CQLDvDy7.js +0 -337
- package/dist/browser-control-auth-D7ArmHUt.js +0 -2
- package/dist/browser-profiles-B39SIZNb.js +0 -2
- package/dist/browser-runtime-DUbSAOOS.js +0 -384
- package/dist/build-D25KqC92.js +0 -257
- package/dist/capability-cli-CuyXrlAB.js +0 -1782
- package/dist/channel-0N3YGMGg.js +0 -1496
- package/dist/channel-1UyKoLyp.js +0 -481
- package/dist/channel-BG87pSEW.js +0 -740
- package/dist/channel-BPGSaZW7.js +0 -1249
- package/dist/channel-BQMPh1J_.js +0 -376
- package/dist/channel-Bd_8V6zn.js +0 -1134
- package/dist/channel-BtBjh_ij.js +0 -362
- package/dist/channel-CpFBlVH6.js +0 -562
- package/dist/channel-CwuTrIrF.js +0 -508
- package/dist/channel-Cxl4sJA-.js +0 -1777
- package/dist/channel-D-VfU4Z2.js +0 -2126
- package/dist/channel-D9q8aYrN.js +0 -867
- package/dist/channel-DKSvVvZh.js +0 -238
- package/dist/channel-DvoFfWLx.js +0 -808
- package/dist/channel-GktTcGHm.js +0 -955
- package/dist/channel-actions.runtime-CKcRA0GW.js +0 -265
- package/dist/channel-core-nm8s1qFZ.js +0 -5
- package/dist/channel-d3t2ESlE.js +0 -653
- package/dist/channel-inbound-DKz40dq-.js +0 -80
- package/dist/channel-plugin-runtime-DKIGZWfW.js +0 -998
- package/dist/channel-runtime-Bh8_GY12.js +0 -408
- package/dist/channel-yQ8jCOb9.js +0 -1556
- package/dist/channel.runtime-BG4mM5cQ.js +0 -652
- package/dist/channel.runtime-BS6PyFFa.js +0 -1008
- package/dist/channel.runtime-CE_xECqN.js +0 -88
- package/dist/channel.runtime-Cd1Sw8U4.js +0 -254
- package/dist/channel.runtime-DIq3XOEe.js +0 -733
- package/dist/channel.runtime-Dy1cx35I.js +0 -21009
- package/dist/channel.runtime-NyIMjLnP.js +0 -109
- package/dist/channel.runtime-Zx5mfE2V.js +0 -4
- package/dist/channel.runtime-rJRibGfN.js +0 -2528
- package/dist/channel.setup--4ACadmF.js +0 -10
- package/dist/channel.setup-DzwqIlo3.js +0 -1098
- package/dist/channel.setup-FKYSJwXR.js +0 -343
- package/dist/chat-CKxSm7r1.js +0 -2666
- package/dist/chrome-rMubJwRG.js +0 -1503
- package/dist/cli-CbTod55I.js +0 -1341
- package/dist/cli-compaction-BbHgjJyW.js +0 -347
- package/dist/cli-metadata-DkOWLC_p.js +0 -22
- package/dist/cli-runner-Cwzv_RKf.js +0 -540
- package/dist/cli-runner-DdnUsgPl.js +0 -2
- package/dist/cli-runner.runtime-BlrSgbEW.js +0 -3
- package/dist/cli-runner.runtime-D8kVfvFH.js +0 -4
- package/dist/client-ClvxsWgL.js +0 -650
- package/dist/client-adapter-CsrIIjK1.js +0 -897
- package/dist/client-factory-DAYClhwm.js +0 -9
- package/dist/command-auth-CCha2ofd.js +0 -135
- package/dist/command-handlers-DCWJzHyB.js +0 -1609
- package/dist/command-registry-BIf61QNz.js +0 -9
- package/dist/command-registry-DJROBy4h.js +0 -4
- package/dist/command-registry-core-BQOWqi6S.js +0 -110
- package/dist/command-status.runtime-D88CUglL.js +0 -90
- package/dist/commands-acp-B-8dHX4Z.js +0 -74
- package/dist/commands-compact.runtime-ComX5mUk.js +0 -10
- package/dist/commands-handlers.runtime-DR3wjXHX.js +0 -6154
- package/dist/commands-status-CDyGrwsI.js +0 -3
- package/dist/commands-status-DV-i_ZIK.js +0 -16
- package/dist/commands-status.runtime-CDyGrwsI.js +0 -3
- package/dist/commands-subagents-control.runtime-B029cXAS.js +0 -3
- package/dist/commands-subagents-control.runtime-DR8Qspe0.js +0 -2
- package/dist/commands-system-prompt-C10ctsG3.js +0 -162
- package/dist/commands-system-prompt-DQlRWwnk.js +0 -2
- package/dist/commands.runtime-BYmIAuN0.js +0 -176
- package/dist/compact-14Ljaaeu.js +0 -480
- package/dist/compact-B--ovdkx.js +0 -1141
- package/dist/compact.runtime-E0Idf2Dq.js +0 -12
- package/dist/completion-cli-DMvvQGSk.js +0 -315
- package/dist/computer-use-CcLwX5SR.js +0 -367
- package/dist/config-B39SIZNb.js +0 -2
- package/dist/config-D4rsGOyV.js +0 -373
- package/dist/config-mutations-CsI3YJu7.js +0 -159
- package/dist/context-engine-host-compat-BZpDFiMJ.js +0 -2
- package/dist/context-engine-host-compat-runUdES5.js +0 -288
- package/dist/context-engine-lifecycle-D6odtNrn.js +0 -1274
- package/dist/control-auth-BPGpPtfz.js +0 -114
- package/dist/control-service-C-OmdPCe.js +0 -145
- package/dist/control-ui/assets/agents-GeyOHPuW.js +0 -1008
- package/dist/control-ui/assets/channel-config-extras-D7en6iUg.js +0 -2
- package/dist/control-ui/assets/channels-DkEyr1w5.js +0 -367
- package/dist/control-ui/assets/cron-C-wThQ1Q.js +0 -1013
- package/dist/control-ui/assets/debug-83AFRtIX.js +0 -97
- package/dist/control-ui/assets/index-CiGEhMOA.js +0 -7370
- package/dist/control-ui/assets/instances-CVl0t-1h.js +0 -57
- package/dist/control-ui/assets/logs-eybVEXxg.js +0 -74
- package/dist/control-ui/assets/nodes-C_A7eoU2.js +0 -436
- package/dist/control-ui/assets/sessions-Cq4Nc69u.js +0 -399
- package/dist/control-ui/assets/skills-ZN6hroIh.js +0 -314
- package/dist/control-ui/assets/skills-shared-DIWGwmdC.js +0 -11
- package/dist/conversation-binding-runtime-C2U1JElL.js +0 -4
- package/dist/conversation-runtime-NmIUd3Zu.js +0 -31
- package/dist/core-DGKJP1dm.js +0 -282
- package/dist/core-api-1fA4sNeC.js +0 -5
- package/dist/core-api-BY822Quq.js +0 -2
- package/dist/crestodian-Bp-NXiBC.js +0 -55
- package/dist/daocore-tools-Defpam0j.js +0 -11727
- package/dist/delivery-CEdVAUGB.js +0 -1002
- package/dist/dialogue-CZ69INPq.js +0 -37
- package/dist/dir-fetch-tool-BCicHhQE.js +0 -565
- package/dist/dir-list-tool-Cv_WktsJ.js +0 -100
- package/dist/direct-dm-Bz89rM8x.js +0 -64
- package/dist/directive-handling.fast-lane-DDnbcc5S.js +0 -68
- package/dist/directive-handling.impl-B0H52Ymr.js +0 -818
- package/dist/directive-handling.impl-CgKpwEW-.js +0 -2
- package/dist/directive-handling.model-selection-_cXAr0vt.js +0 -122
- package/dist/directive-handling.persist.runtime-Dw0mfzXT.js +0 -263
- package/dist/dispatch-C3AeYvyP.js +0 -1640
- package/dist/dispatch-acp-transcript.runtime-CP8pqBwS.js +0 -40
- package/dist/dispatch-acp.runtime-Cdap-AZI.js +0 -18
- package/dist/doctor-BZwVH97p.js +0 -2
- package/dist/doctor-BfkGBii1.js +0 -6
- package/dist/doctor-config-flow-D3JASGDt.js +0 -1741
- package/dist/doctor-core-checks-DH5AIT0Q.js +0 -573
- package/dist/doctor-core-checks-DiNu7VSh.js +0 -2
- package/dist/doctor-health-BDIJ-Nro.js +0 -65
- package/dist/doctor-health-contributions-BgmF7w8X.js +0 -696
- package/dist/doctor-lint-uIxkMUSO.js +0 -94
- package/dist/doctor-state-integrity-ws1b_BGk.js +0 -1231
- package/dist/doctor-update-Cx4CqxaX.js +0 -58
- package/dist/dynamic-tools-DiqOxhJh.js +0 -486
- package/dist/embedded-backend-C634irMl.js +0 -579
- package/dist/embedded-gateway-stub.runtime-CCfrTOeN.js +0 -12
- package/dist/exec-approvals-D85KThSg.js +0 -149
- package/dist/file-fetch-tool-BERaGYCT.js +0 -124
- package/dist/file-write-tool-BjHrMyfe.js +0 -127
- package/dist/format-DE9PuPg1.js +0 -1145
- package/dist/gateway-cli-B5hjhbUy.js +0 -435
- package/dist/gateway-method-runtime-Bu0E9Eki.js +0 -21
- package/dist/get-reply-6PtPz9hv.js +0 -4689
- package/dist/get-reply-from-config.runtime-CwprvhoR.js +0 -2
- package/dist/graph-users-DUp1kgnS.js +0 -1419
- package/dist/group-access-D5GBQ3w6.js +0 -112
- package/dist/handle-action.guild-admin-CA0Y-buD.js +0 -288
- package/dist/harness-B5nOFVfm.js +0 -61
- package/dist/health-D5heIDj3.js +0 -4
- package/dist/heartbeat-runner-BzFkIFHh.js +0 -5
- package/dist/heartbeat-runner.runtime-p6H1_xMV.js +0 -4
- package/dist/hooks-BvTyQ14X.js +0 -534
- package/dist/inbound-direct-dm-runtime-DwiDXi8L.js +0 -2
- package/dist/inbound-reply-dispatch-YoDUOC6C.js +0 -148
- package/dist/init-CPtcV5Xu.js +0 -59
- package/dist/inline-buttons-DeD5d42c.js +0 -40
- package/dist/internal-events-DEb50Sw3.js +0 -90
- package/dist/isolated-agent-CcxFFZ-Z.js +0 -1118
- package/dist/isolated-agent-CpHzq5qr.js +0 -2
- package/dist/lifecycle-DNel-oMe.js +0 -571
- package/dist/list.probe-DCa3N25d.js +0 -449
- package/dist/list.status-command-CyeAJmZW.js +0 -789
- package/dist/llm-slug-generator-CyqTY37Z.js +0 -78
- package/dist/local-dispatch.runtime-nE39kFIP.js +0 -9
- package/dist/manager.runtime-CpAPB8D5.js +0 -2714
- package/dist/markdown-to-line-Ci6TRmoZ.js +0 -811
- package/dist/mcp-http-BR0vmxFL.js +0 -2
- package/dist/mcp-http-C0oniA8h.js +0 -555
- package/dist/media-understanding-provider-BwA0XqC3.js +0 -339
- package/dist/message-actions-C9C_Ngkd.js +0 -145
- package/dist/message-handler-CUUKPC5n.js +0 -384
- package/dist/message-handler-xRTfIXWV.js +0 -1715
- package/dist/message-handler.preflight-Ch2Q7V3M.js +0 -1125
- package/dist/message-handler.process-HM3mK93q.js +0 -1484
- package/dist/model-CB8Ex5xS.js +0 -74
- package/dist/model-selection-2s0Dinux.js +0 -272
- package/dist/models-Cn-6DJ41.js +0 -2
- package/dist/models-CzszJD__.js +0 -104
- package/dist/models-cli-CbhElnA5.js +0 -256
- package/dist/monitor-7aprTsMV.js +0 -715
- package/dist/monitor-BuVhqwDS.js +0 -1370
- package/dist/monitor-C4H_YkgY.js +0 -2
- package/dist/monitor-CPQsMxgv.js +0 -1657
- package/dist/monitor-Ce0V1PiR.js +0 -4377
- package/dist/monitor-D0bcGJWI.js +0 -60
- package/dist/monitor-DEjlJqzh.js +0 -834
- package/dist/monitor-auth-DjJZsjgV.js +0 -179
- package/dist/monitor-ikSYagv3.js +0 -2788
- package/dist/monitor-polling.runtime-D7yEflMM.js +0 -883
- package/dist/monitor-webhook.runtime-CIZt-biI.js +0 -387
- package/dist/monitor.account-C2sMOBCS.js +0 -5233
- package/dist/monitor.runtime-BAi6zmcn.js +0 -2
- package/dist/monitor.webhook-BcjpfRCX.js +0 -180
- package/dist/node-cli-sessions-CIhkJRU4.js +0 -1228
- package/dist/openai-http-Dj21RwSj.js +0 -824
- package/dist/openresponses-http-COnnr1ox.js +0 -1173
- package/dist/operations-H3vUh0lM.js +0 -805
- package/dist/outbound-adapter-WLtWE7wv.js +0 -543
- package/dist/outbound-session-route-CZtd64EH.js +0 -45
- package/dist/outbound.runtime-D98P0sN1.js +0 -2
- package/dist/pi-embedded-BWJzd4mK.js +0 -4
- package/dist/pi-embedded-DeNsSqQQ.js +0 -3796
- package/dist/pi-embedded.runtime-CZnNwFpc.js +0 -4
- package/dist/pi-tools-CNHSpjBa.js +0 -2413
- package/dist/plan-B0reFFlM.js +0 -81
- package/dist/plan-CrfF-TH8.js +0 -112
- package/dist/plugin-DI_8eYOe.js +0 -12396
- package/dist/plugin-app-cache-key-WaTUD3e-.js +0 -46
- package/dist/plugin-enabled-aWLXgGGi.js +0 -233
- package/dist/plugin-registration-ByjRIVJm.js +0 -88
- package/dist/plugin-service-VQm_241d.js +0 -1229
- package/dist/policy-BmJH-swe.js +0 -680
- package/dist/policy-DE-bO1zn.js +0 -138
- package/dist/prepare.runtime-bSj3-res.js +0 -732
- package/dist/preview-warnings-CbuGYsF9.js +0 -392
- package/dist/probe-C_rWg7_m.js +0 -682
- package/dist/probe-CagOFfx6.js +0 -2
- package/dist/probe-thX1HqOh.js +0 -2204
- package/dist/probe-zU6B6gFt.js +0 -47
- package/dist/program-BtVdH743.js +0 -131
- package/dist/provider-CDoD7tO0.js +0 -8735
- package/dist/provider-CK1gMdJ2.js +0 -32
- package/dist/provider-DJqr9djy.js +0 -32
- package/dist/provider-DsOJp5bK.js +0 -152
- package/dist/provider-dispatcher-UNQ-LSx9.js +0 -22
- package/dist/provider-session.runtime-DMrkMb4x.js +0 -9
- package/dist/provider.runtime-C2-t3zm8.js +0 -2
- package/dist/public-surface-loader-hTeyyHcd.js +0 -114
- package/dist/pw-ai-BaL3eVYx.js +0 -3029
- package/dist/pw-role-snapshot-DKeBqhN1.js +0 -333
- package/dist/reaction-level-BV2potsD.js +0 -19
- package/dist/reaction-runtime-api-CCBxgM10.js +0 -116
- package/dist/realtime-transcription-provider-CHYtIXZm.js +0 -205
- package/dist/register-BJf28G9B.js +0 -2178
- package/dist/register.agent-oXAHwNQv.js +0 -156
- package/dist/register.crestodian-CQ0sqdV2.js +0 -24
- package/dist/register.maintenance-CylVRs5M.js +0 -83
- package/dist/register.runtime-CcDgwy0X.js +0 -54
- package/dist/register.subclis-CpBYNw2X.js +0 -3
- package/dist/register.subclis-N2CvieOL.js +0 -31
- package/dist/register.subclis-core-BHaGvbzg.js +0 -273
- package/dist/repair-sequencing-EBBnBdIB.js +0 -640
- package/dist/reply-delivery-BLoPALlI.js +0 -196
- package/dist/reply-runtime-D4asNTSa.js +0 -11
- package/dist/reply.runtime-CwprvhoR.js +0 -2
- package/dist/request-DlWPRUDt.js +0 -54
- package/dist/resolve-allowlist-BukQf58x.js +0 -220
- package/dist/result-fallback-classifier-DyHFnqfV.js +0 -79
- package/dist/route-BMf4keN5.js +0 -469
- package/dist/route-resolution-DWNi1QAu.js +0 -274
- package/dist/routes-C20LC8c4.js +0 -3602
- package/dist/routes-CkK7Vv_m.js +0 -2
- package/dist/run-KDF_AEza.js +0 -1162
- package/dist/run-attempt-JHYCfonU.js +0 -7704
- package/dist/run-command-3PVihYIy.js +0 -2
- package/dist/run-command-QHAXnyKY.js +0 -23
- package/dist/run-embedded.runtime-BJw-2vss.js +0 -4
- package/dist/run-execution-cli.runtime-GHClMn2g.js +0 -4
- package/dist/run-subagent-registry.runtime-BLLMrhtE.js +0 -2
- package/dist/runtime-C2u-dC1r.js +0 -1287
- package/dist/runtime-ClyfkDWT.js +0 -6179
- package/dist/runtime-WXCarlPc.js +0 -438
- package/dist/runtime-api-3QhGLpZf.js +0 -13
- package/dist/runtime-api-DRAu3mjv.js +0 -4
- package/dist/runtime-api-JE07pOem.js +0 -13
- package/dist/runtime-api-JuKylHvw.js +0 -24
- package/dist/runtime-api-bcbk4yax.js +0 -21
- package/dist/runtime-api-dDe9U2_V.js +0 -17
- package/dist/runtime-api-uMexLqGS.js +0 -3
- package/dist/runtime-api.actions-Bo7TLDFl.js +0 -3
- package/dist/runtime-api.monitor-7q78L1Em.js +0 -6
- package/dist/runtime-api.send-Bf9RR4nV.js +0 -4
- package/dist/runtime-api.threads-Dj2QuhHj.js +0 -2
- package/dist/runtime-channel-k1C0Satl.js +0 -2
- package/dist/runtime-channel-qt9t0J-J.js +0 -150
- package/dist/runtime-embedded-pi.runtime-BPB9NlTS.js +0 -2
- package/dist/sanitize-outbound-BLH_SQvg.js +0 -127
- package/dist/sdk-setup-tools-BshlBPau.js +0 -8
- package/dist/secrets-CsHXv7d3.js +0 -113
- package/dist/security-audit-CUXBQXNX.js +0 -122
- package/dist/security-audit-CzdXbRma.js +0 -118
- package/dist/security-audit.runtime-Ca0FMFJG.js +0 -2
- package/dist/selection-BmvQJlSD.js +0 -3
- package/dist/selection-BplDXc9w.js +0 -16157
- package/dist/send--qFg8a9v.js +0 -1631
- package/dist/send-BPdryPPA.js +0 -192
- package/dist/send-Bl4YaRkS.js +0 -143
- package/dist/send-Ccm7RMXC.js +0 -2
- package/dist/send.components-c3OUPSmR.js +0 -2
- package/dist/send.components-rhQJYoXs.js +0 -500
- package/dist/send.runtime-dfUkAp5d.js +0 -2
- package/dist/server-DRhyTMLe.js +0 -73
- package/dist/server-Dv4BzjGn.js +0 -24
- package/dist/server-context-4HRJy2vp.js +0 -955
- package/dist/server-context-DlxYb1G5.js +0 -2
- package/dist/server-cron-Bt8Pkc3i.js +0 -2989
- package/dist/server-cron-CtNWsa4Z.js +0 -2
- package/dist/server-methods-rye_okUW.js +0 -16494
- package/dist/server-node-events-C1yZ5a1u.js +0 -596
- package/dist/server-plugin-bootstrap-DUMyVtlP.js +0 -70
- package/dist/server-plugins-B5ZWWkRE.js +0 -432
- package/dist/server-reload-handlers-CTnMXNjT.js +0 -714
- package/dist/server-restart-sentinel-CAYxtwmY.js +0 -747
- package/dist/server-restart-sentinel-DqrtSIvy.js +0 -2
- package/dist/server-runtime-services-CuptQTe5.js +0 -2
- package/dist/server-runtime-services-aaS2IiW3.js +0 -267
- package/dist/server-startup-plugins-D0ymJgQT.js +0 -113
- package/dist/server-startup-post-attach-DlrN2uyt.js +0 -716
- package/dist/server-ws-runtime-CdpLbv4o.js +0 -349
- package/dist/server.impl-Cb4qcMTg.js +0 -2586
- package/dist/service-qxvDlMQE.js +0 -1446
- package/dist/session-binding-6bLobLHL.js +0 -219
- package/dist/session-binding-Bm6fCpoY.js +0 -2
- package/dist/session-kill-http-B6WjVo8V.js +0 -121
- package/dist/session-reset-service-GUVIhxp4.js +0 -625
- package/dist/session-route-BcRDnvzG.js +0 -93
- package/dist/session-status.runtime-BcjOunV4.js +0 -2
- package/dist/session-subagent-reactivation.runtime-BSmk_KYn.js +0 -2
- package/dist/session-tab-registry-BBYzbSOu.js +0 -521
- package/dist/sessions-history-http-bLJJfgLm.js +0 -430
- package/dist/sessions.runtime-DNRtQzCk.js +0 -2
- package/dist/setup-api-CcolVVJs.js +0 -29
- package/dist/setup-core-eJD18F3B.js +0 -174
- package/dist/setup-surface-B75C2Qtz.js +0 -221
- package/dist/setup-surface-CFuPfVHp.js +0 -405
- package/dist/setup-surface-Dyy-Mzyz.js +0 -288
- package/dist/setup-surface-ZsVF_g8W.js +0 -320
- package/dist/shared-BkCNrcLX.js +0 -121
- package/dist/shared-client-B7zqC9p2.js +0 -2
- package/dist/shared-client-yXjKgZBz.js +0 -629
- package/dist/side-question-DU3gESCb.js +0 -683
- package/dist/skill-tool-dispatch.runtime-CPBuqyvk.js +0 -143
- package/dist/slash-state-Do3bAahA.js +0 -2166
- package/dist/speech-provider-Bg9los3C.js +0 -184
- package/dist/src-D7LzUctH.js +0 -4256
- package/dist/startup-context-CCF2gIOl.js +0 -313
- package/dist/status-subagents.runtime-DX5FTymp.js +0 -18
- package/dist/status-text-B-1u5dSV.js +0 -296
- package/dist/sticker-cache-DwpU_9RJ.js +0 -206
- package/dist/sticker-vision.runtime-Bbldi_YL.js +0 -17
- package/dist/subagent-announce-BCo0VHVL.js +0 -354
- package/dist/subagent-announce-delivery-JcnuDN_N.js +0 -958
- package/dist/subagent-control-BzbA3Suz.js +0 -508
- package/dist/subagent-hooks-BIGZQWrG.js +0 -2
- package/dist/subagent-hooks-Bj4qYZfv.js +0 -230
- package/dist/subagent-hooks-C-rvhVBv.js +0 -2
- package/dist/subagent-hooks-P01_AFl5.js +0 -116
- package/dist/subagent-hooks-VEfak8nl.js +0 -2
- package/dist/subagent-hooks-api-BPnSxxN4.js +0 -23
- package/dist/subagent-hooks-api-DwIAvMoS.js +0 -22
- package/dist/subagent-hooks-api-kgyR9FOb.js +0 -23
- package/dist/subagent-hooks-oED56wqq.js +0 -146
- package/dist/subagent-orphan-recovery-D79ZzwKN.js +0 -352
- package/dist/subagent-registry-D0soBT5j.js +0 -2351
- package/dist/subagent-registry-DRJDkmty.js +0 -3
- package/dist/subagent-session-cleanup-9eAO1aJe.js +0 -525
- package/dist/subagent-spawn-D80vbogm.js +0 -1164
- package/dist/target-id-COLv5LsJ.js +0 -107
- package/dist/targets-CDW5IQ6a.js +0 -44
- package/dist/targets-Ci6O1ZdP.js +0 -19
- package/dist/targets-CsaWFBg1.js +0 -19
- package/dist/testing-BoJit-h1.js +0 -267
- package/dist/thread-bindings-CGCvw0KT.js +0 -571
- package/dist/thread-bindings-ClCTNacX.js +0 -228
- package/dist/thread-bindings-DRb7BMZ6.js +0 -8
- package/dist/thread-bindings-Xc6smav0.js +0 -232
- package/dist/thread-bindings.discord-api-DC467oeF.js +0 -187
- package/dist/thread-bindings.manager-C_mpTDIZ.js +0 -536
- package/dist/thread-bindings.manager-DkCRs612.js +0 -2
- package/dist/thread-lifecycle-DpqCXlx9.js +0 -1614
- package/dist/token-CI6HjbTA.js +0 -134
- package/dist/tool-BMe7hjBK.js +0 -139
- package/dist/tool-actions.runtime-D-h5PI_m.js +0 -534
- package/dist/tool-resolution-CnLx0CHe.js +0 -149
- package/dist/tools-effective-inventory-BR6MUMtE.js +0 -204
- package/dist/tools-invoke-http-CTTs2yMT.js +0 -67
- package/dist/tools-invoke-shared-9B1EjXWf.js +0 -200
- package/dist/tts-eGOviZ5c.js +0 -66
- package/dist/tui-Bw0HqKd7.js +0 -4709
- package/dist/tui-CIZJnPzj.js +0 -2
- package/dist/tui-backend-BJ_r7tcF.js +0 -256
- package/dist/tui-cli-BaSMBpuA.js +0 -37
- package/dist/update-cli-zuCybGNR.js +0 -3664
- package/dist/update-runner-Dek2BHmQ.js +0 -2379
- package/dist/vision-tools-1ps0BEE5.js +0 -1409
- package/dist/web-search-B7EziZXE.js +0 -62
- package/dist/web-search-provider.runtime-DGTCvGch.js +0 -328
- package/dist/web-search-provider.runtime-DWL5t39M.js +0 -2
- package/dist/xai-oauth-CRtsj2Gs.js +0 -479
- package/dist/xai-user-agent-Dndwzw2S.js +0 -32
- /package/dist/{acp-runtime-backend-DSDBcyh9.js → acp-runtime-backend-Cxo7eBHf.js} +0 -0
- /package/dist/{channel-actions-FV66JqtI.js → channel-actions-UDeVjgGz.js} +0 -0
- /package/dist/{command-status-runtime-BRWKSoG7.js → command-status-runtime-CoHd4Fws.js} +0 -0
- /package/dist/{delegate-DGqKhwB4.js → delegate-B-2xZ77o.js} +0 -0
- /package/dist/{dispatch-acp-Ceoxja_Z.js → dispatch-acp-DLPkmK7K.js} +0 -0
- /package/dist/{heartbeat-runner-CJHvr5pG.js → heartbeat-runner-D2j6JwOI.js} +0 -0
- /package/dist/{library-Bq3aDek_.js → library-DBT0cIPP.js} +0 -0
- /package/dist/{run-executor.runtime-DNJhGPbA.js → run-executor.runtime-DE4J7f4M.js} +0 -0
- /package/dist/{shared-CYxmRpq1.js → shared-xeo8Yh5n.js} +0 -0
|
@@ -1,2351 +0,0 @@
|
|
|
1
|
-
import { a as normalizeLowercaseStringOrEmpty } from "./string-coerce-DyL154ka.js";
|
|
2
|
-
import { c as readErrorName, i as formatErrorMessage } from "./errors-D_oyTIw2.js";
|
|
3
|
-
import { n as createLazyPromiseLoader, t as createLazyImportLoader } from "./lazy-promise-Djskx0qC.js";
|
|
4
|
-
import { d as resolveAgentIdFromSessionKey } from "./session-key-Bte0mmcq.js";
|
|
5
|
-
import { n as defaultRuntime } from "./runtime-E_A14BX_.js";
|
|
6
|
-
import { s as toSafeImportPath } from "./plugin-module-loader-cache-BmzxlqNo.js";
|
|
7
|
-
import { t as createSubsystemLogger } from "./subsystem-CppbuBPw.js";
|
|
8
|
-
import { i as getRuntimeConfig } from "./io-Ct2JqgbR.js";
|
|
9
|
-
import "./config-CLrwLpl0.js";
|
|
10
|
-
import { r as callGateway } from "./call-BFqofFc5.js";
|
|
11
|
-
import { t as getGlobalHookRunner } from "./hook-runner-global-RR7B_IHd.js";
|
|
12
|
-
import { c as getAgentRunContext, l as onAgentEvent } from "./agent-events-Cfj53GyA.js";
|
|
13
|
-
import { o as normalizeDeliveryContext } from "./delivery-context.shared-XybGGRNt.js";
|
|
14
|
-
import { u as resolveStorePath } from "./paths-8MFrTNIB.js";
|
|
15
|
-
import { c as registerSessionMaintenancePreserveKeysProvider, t as loadSessionStore } from "./store-load-B817r-3Z.js";
|
|
16
|
-
import { u as updateSessionStore } from "./store-C4uyNaPD.js";
|
|
17
|
-
import "./sessions-4ZNlAnYc.js";
|
|
18
|
-
import { n as resolveRequiredCompletionTerminalResult, r as resolveAgentTimeoutMs, t as resolveRequiredCompletionDeliveryFailureTerminalResult } from "./task-completion-contract-D5t-_eBh.js";
|
|
19
|
-
import { n as extractTextFromChatContent } from "./chat-content-BNTcXm1Z.js";
|
|
20
|
-
import { a as failTaskRunByRunId, i as createRunningTaskRun, l as setDetachedTaskDeliveryStatusByRunId, n as completeTaskRunByRunId } from "./detached-task-runtime-B8jNifvc.js";
|
|
21
|
-
import { a as isSilentReplyText } from "./tokens-D8MVQSp9.js";
|
|
22
|
-
import { A as SUBAGENT_ENDED_REASON_KILLED, C as getSubagentSessionStartedAt, D as SUBAGENT_ENDED_OUTCOME_TIMEOUT, E as SUBAGENT_ENDED_OUTCOME_KILLED, M as subagentRuns, O as SUBAGENT_ENDED_REASON_COMPLETE, S as getSubagentSessionRuntimeMs, T as SUBAGENT_ENDED_OUTCOME_ERROR, b as isStaleUnendedSubagentRun, f as listDescendantRunsForRequesterFromRuns, i as restoreSubagentRunsFromDisk, j as SUBAGENT_TARGET_KIND_SUBAGENT, k as SUBAGENT_ENDED_REASON_ERROR, l as countPendingDescendantRunsFromRuns, n as persistSubagentRunsToDisk, o as countActiveDescendantRunsFromRuns, p as listRunsForControllerFromRuns, r as persistSubagentRunsToDiskOrThrow, s as countActiveRunsForSessionFromRuns, t as getSubagentRunsSnapshotForRead, u as getSubagentRunByChildSessionKeyFromRuns, w as resolveSubagentSessionStatus } from "./subagent-registry-state-IRjqqsbj.js";
|
|
23
|
-
import { c as retireSessionMcpRuntimeForSessionKey } from "./pi-bundle-mcp-runtime-DjzUKrET.js";
|
|
24
|
-
import "./pi-bundle-mcp-tools-CC14PQe1.js";
|
|
25
|
-
import { i as waitForAgentRun, l as formatBlockedLivenessError, t as isRecoverableAgentWaitError, u as isBlockedLivenessState } from "./run-wait-Ba5wh82_.js";
|
|
26
|
-
import { d as withSubagentOutcomeTiming, t as deleteSubagentSessionForCleanup } from "./subagent-session-cleanup-9eAO1aJe.js";
|
|
27
|
-
import { t as emitSessionLifecycleEvent } from "./session-lifecycle-events-CrY3-yco.js";
|
|
28
|
-
import { n as buildAnnounceIdempotencyKey, t as buildAnnounceIdFromChildRun } from "./announce-idempotency-DV6_8Blm.js";
|
|
29
|
-
import { t as configureSubagentRegistrySteerRuntime } from "./subagent-registry-steer-runtime-9Vso0zzU.js";
|
|
30
|
-
import fs, { promises } from "node:fs";
|
|
31
|
-
import path from "node:path";
|
|
32
|
-
//#region src/shared/runtime-import.ts
|
|
33
|
-
function resolveRuntimeImportSpecifier(baseUrl, parts) {
|
|
34
|
-
const joined = parts.join("");
|
|
35
|
-
const safeJoined = toSafeImportPath(joined);
|
|
36
|
-
if (safeJoined !== joined) return safeJoined;
|
|
37
|
-
return new URL(joined, toSafeImportPath(baseUrl)).href;
|
|
38
|
-
}
|
|
39
|
-
async function importRuntimeModule(baseUrl, parts, importModule = (specifier) => import(specifier)) {
|
|
40
|
-
return await importModule(resolveRuntimeImportSpecifier(baseUrl, parts));
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/agents/subagent-registry-completion.ts
|
|
44
|
-
function runOutcomesEqual(a, b) {
|
|
45
|
-
if (!a && !b) return true;
|
|
46
|
-
if (!a || !b) return false;
|
|
47
|
-
if (a.status !== b.status) return false;
|
|
48
|
-
if (a.status === "error" && b.status === "error") {
|
|
49
|
-
if ((a.error ?? "") !== (b.error ?? "")) return false;
|
|
50
|
-
}
|
|
51
|
-
if (!runOutcomeHasTiming(a) || !runOutcomeHasTiming(b)) return true;
|
|
52
|
-
return a.startedAt === b.startedAt && a.endedAt === b.endedAt && a.elapsedMs === b.elapsedMs;
|
|
53
|
-
}
|
|
54
|
-
function runOutcomeHasTiming(outcome) {
|
|
55
|
-
return Number.isFinite(outcome?.startedAt) || Number.isFinite(outcome?.endedAt) || Number.isFinite(outcome?.elapsedMs);
|
|
56
|
-
}
|
|
57
|
-
function shouldUpdateRunOutcome(current, next) {
|
|
58
|
-
return !runOutcomesEqual(current, next) || !runOutcomeHasTiming(current) && runOutcomeHasTiming(next);
|
|
59
|
-
}
|
|
60
|
-
function resolveLifecycleOutcomeFromRunOutcome(outcome) {
|
|
61
|
-
if (outcome?.status === "error") return SUBAGENT_ENDED_OUTCOME_ERROR;
|
|
62
|
-
if (outcome?.status === "timeout") return SUBAGENT_ENDED_OUTCOME_TIMEOUT;
|
|
63
|
-
return "ok";
|
|
64
|
-
}
|
|
65
|
-
async function emitSubagentEndedHookOnce(params) {
|
|
66
|
-
const runId = params.entry.runId.trim();
|
|
67
|
-
if (!runId) return false;
|
|
68
|
-
if (params.entry.endedHookEmittedAt) return false;
|
|
69
|
-
if (params.inFlightRunIds.has(runId)) return false;
|
|
70
|
-
params.inFlightRunIds.add(runId);
|
|
71
|
-
try {
|
|
72
|
-
const hookRunner = getGlobalHookRunner();
|
|
73
|
-
if (!hookRunner) return false;
|
|
74
|
-
if (hookRunner?.hasHooks("subagent_ended")) await hookRunner.runSubagentEnded({
|
|
75
|
-
targetSessionKey: params.entry.childSessionKey,
|
|
76
|
-
targetKind: SUBAGENT_TARGET_KIND_SUBAGENT,
|
|
77
|
-
reason: params.reason,
|
|
78
|
-
sendFarewell: params.sendFarewell,
|
|
79
|
-
accountId: params.accountId,
|
|
80
|
-
runId: params.entry.runId,
|
|
81
|
-
endedAt: params.entry.endedAt,
|
|
82
|
-
outcome: params.outcome,
|
|
83
|
-
error: params.error
|
|
84
|
-
}, {
|
|
85
|
-
runId: params.entry.runId,
|
|
86
|
-
childSessionKey: params.entry.childSessionKey,
|
|
87
|
-
requesterSessionKey: params.entry.requesterSessionKey
|
|
88
|
-
});
|
|
89
|
-
params.entry.endedHookEmittedAt = Date.now();
|
|
90
|
-
params.persist();
|
|
91
|
-
return true;
|
|
92
|
-
} catch {
|
|
93
|
-
return false;
|
|
94
|
-
} finally {
|
|
95
|
-
params.inFlightRunIds.delete(runId);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region src/agents/subagent-registry-helpers.ts
|
|
100
|
-
const MIN_ANNOUNCE_RETRY_DELAY_MS = 1e3;
|
|
101
|
-
const MAX_ANNOUNCE_RETRY_DELAY_MS = 8e3;
|
|
102
|
-
const ANNOUNCE_EXPIRY_MS = 5 * 6e4;
|
|
103
|
-
const ANNOUNCE_COMPLETION_HARD_EXPIRY_MS = 30 * 6e4;
|
|
104
|
-
const FROZEN_RESULT_TEXT_MAX_BYTES = 100 * 1024;
|
|
105
|
-
function capFrozenResultText(resultText) {
|
|
106
|
-
const trimmed = resultText.trim();
|
|
107
|
-
if (!trimmed) return "";
|
|
108
|
-
const totalBytes = Buffer.byteLength(trimmed, "utf8");
|
|
109
|
-
if (totalBytes <= FROZEN_RESULT_TEXT_MAX_BYTES) return trimmed;
|
|
110
|
-
const notice = `\n\n[truncated: frozen completion output exceeded ${Math.round(FROZEN_RESULT_TEXT_MAX_BYTES / 1024)}KB (${Math.round(totalBytes / 1024)}KB)]`;
|
|
111
|
-
const maxPayloadBytes = Math.max(0, FROZEN_RESULT_TEXT_MAX_BYTES - Buffer.byteLength(notice, "utf8"));
|
|
112
|
-
return `${Buffer.from(trimmed, "utf8").subarray(0, maxPayloadBytes).toString("utf8")}${notice}`;
|
|
113
|
-
}
|
|
114
|
-
function resolveAnnounceRetryDelayMs(retryCount) {
|
|
115
|
-
const baseDelay = MIN_ANNOUNCE_RETRY_DELAY_MS * 2 ** Math.max(0, Math.max(0, Math.min(retryCount, 10)) - 1);
|
|
116
|
-
return Math.min(baseDelay, MAX_ANNOUNCE_RETRY_DELAY_MS);
|
|
117
|
-
}
|
|
118
|
-
function formatAnnounceGiveUpLogField(value) {
|
|
119
|
-
const normalized = value.replace(/\s+/g, " ").trim();
|
|
120
|
-
return JSON.stringify(normalized.length > 2e3 ? `${normalized.slice(0, 2e3)}…` : normalized);
|
|
121
|
-
}
|
|
122
|
-
function logAnnounceGiveUp(entry, reason) {
|
|
123
|
-
const retryCount = entry.announceRetryCount ?? 0;
|
|
124
|
-
const endedAgoMs = typeof entry.endedAt === "number" ? Math.max(0, Date.now() - entry.endedAt) : void 0;
|
|
125
|
-
const endedAgoLabel = endedAgoMs != null ? `${Math.round(endedAgoMs / 1e3)}s` : "n/a";
|
|
126
|
-
const deliveryError = entry.lastAnnounceDeliveryError?.trim() ? ` deliveryError=${formatAnnounceGiveUpLogField(entry.lastAnnounceDeliveryError)}` : "";
|
|
127
|
-
defaultRuntime.log(`[warn] Subagent announce give up (${reason}) run=${entry.runId} child=${entry.childSessionKey} requester=${entry.requesterSessionKey} retries=${retryCount} endedAgo=${endedAgoLabel}${deliveryError}`);
|
|
128
|
-
}
|
|
129
|
-
function findSessionEntryByKey$1(store, sessionKey) {
|
|
130
|
-
const direct = store[sessionKey];
|
|
131
|
-
if (direct) return direct;
|
|
132
|
-
const normalized = normalizeLowercaseStringOrEmpty(sessionKey);
|
|
133
|
-
for (const [key, entry] of Object.entries(store)) if (normalizeLowercaseStringOrEmpty(key) === normalized) return entry;
|
|
134
|
-
}
|
|
135
|
-
async function persistSubagentSessionTiming(entry) {
|
|
136
|
-
const childSessionKey = entry.childSessionKey?.trim();
|
|
137
|
-
if (!childSessionKey) return;
|
|
138
|
-
const cfg = getRuntimeConfig();
|
|
139
|
-
const agentId = resolveAgentIdFromSessionKey(childSessionKey);
|
|
140
|
-
const storePath = resolveStorePath(cfg.session?.store, { agentId });
|
|
141
|
-
const startedAt = getSubagentSessionStartedAt(entry);
|
|
142
|
-
const endedAt = typeof entry.endedAt === "number" && Number.isFinite(entry.endedAt) ? entry.endedAt : void 0;
|
|
143
|
-
const runtimeMs = endedAt !== void 0 ? getSubagentSessionRuntimeMs(entry, endedAt) : getSubagentSessionRuntimeMs(entry);
|
|
144
|
-
const status = resolveSubagentSessionStatus(entry);
|
|
145
|
-
await updateSessionStore(storePath, (store) => {
|
|
146
|
-
const sessionEntry = findSessionEntryByKey$1(store, childSessionKey);
|
|
147
|
-
if (!sessionEntry) return;
|
|
148
|
-
if (typeof startedAt === "number" && Number.isFinite(startedAt)) sessionEntry.startedAt = startedAt;
|
|
149
|
-
else delete sessionEntry.startedAt;
|
|
150
|
-
if (typeof endedAt === "number" && Number.isFinite(endedAt)) sessionEntry.endedAt = endedAt;
|
|
151
|
-
else delete sessionEntry.endedAt;
|
|
152
|
-
if (typeof runtimeMs === "number" && Number.isFinite(runtimeMs)) sessionEntry.runtimeMs = runtimeMs;
|
|
153
|
-
else delete sessionEntry.runtimeMs;
|
|
154
|
-
if (status) sessionEntry.status = status;
|
|
155
|
-
else delete sessionEntry.status;
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
function resolveSubagentRunOrphanReason(params) {
|
|
159
|
-
const childSessionKey = params.entry.childSessionKey?.trim();
|
|
160
|
-
if (!childSessionKey) return "missing-session-entry";
|
|
161
|
-
try {
|
|
162
|
-
const cfg = getRuntimeConfig();
|
|
163
|
-
const agentId = resolveAgentIdFromSessionKey(childSessionKey);
|
|
164
|
-
const storePath = resolveStorePath(cfg.session?.store, { agentId });
|
|
165
|
-
let store = params.storeCache?.get(storePath);
|
|
166
|
-
if (!store) {
|
|
167
|
-
store = loadSessionStore(storePath);
|
|
168
|
-
params.storeCache?.set(storePath, store);
|
|
169
|
-
}
|
|
170
|
-
const sessionEntry = findSessionEntryByKey$1(store, childSessionKey);
|
|
171
|
-
if (!sessionEntry) return "missing-session-entry";
|
|
172
|
-
if (typeof sessionEntry.sessionId !== "string" || !sessionEntry.sessionId.trim()) return "missing-session-id";
|
|
173
|
-
if (params.includeStaleUnended === true && sessionEntry.abortedLastRun !== true && isStaleUnendedSubagentRun(params.entry, params.now)) return "stale-unended-run";
|
|
174
|
-
return null;
|
|
175
|
-
} catch {
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function isResolvedChildPath(params) {
|
|
180
|
-
const rootWithSep = params.rootPath.endsWith(path.sep) ? params.rootPath : `${params.rootPath}${path.sep}`;
|
|
181
|
-
return params.childPath.startsWith(rootWithSep);
|
|
182
|
-
}
|
|
183
|
-
async function safeRemoveAttachmentsDir(entry) {
|
|
184
|
-
if (!entry.attachmentsDir || !entry.attachmentsRootDir) return;
|
|
185
|
-
const resolveReal = async (targetPath) => {
|
|
186
|
-
try {
|
|
187
|
-
return await promises.realpath(targetPath);
|
|
188
|
-
} catch (err) {
|
|
189
|
-
if (err?.code === "ENOENT") return null;
|
|
190
|
-
throw err;
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
try {
|
|
194
|
-
const [rootReal, dirReal] = await Promise.all([resolveReal(entry.attachmentsRootDir), resolveReal(entry.attachmentsDir)]);
|
|
195
|
-
if (!dirReal) return;
|
|
196
|
-
const rootBase = rootReal ?? path.resolve(entry.attachmentsRootDir);
|
|
197
|
-
const dirBase = dirReal;
|
|
198
|
-
if (!isResolvedChildPath({
|
|
199
|
-
childPath: dirBase,
|
|
200
|
-
rootPath: rootBase
|
|
201
|
-
})) return;
|
|
202
|
-
await promises.rm(dirBase, {
|
|
203
|
-
recursive: true,
|
|
204
|
-
force: true
|
|
205
|
-
});
|
|
206
|
-
} catch {}
|
|
207
|
-
}
|
|
208
|
-
function safeRemoveAttachmentsDirSync(entry) {
|
|
209
|
-
if (!entry.attachmentsDir || !entry.attachmentsRootDir) return;
|
|
210
|
-
const resolveReal = (targetPath) => {
|
|
211
|
-
try {
|
|
212
|
-
return fs.realpathSync.native(targetPath);
|
|
213
|
-
} catch (err) {
|
|
214
|
-
if (err?.code === "ENOENT") return null;
|
|
215
|
-
throw err;
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
try {
|
|
219
|
-
const rootReal = resolveReal(entry.attachmentsRootDir);
|
|
220
|
-
const dirReal = resolveReal(entry.attachmentsDir);
|
|
221
|
-
if (!dirReal) return;
|
|
222
|
-
if (!isResolvedChildPath({
|
|
223
|
-
childPath: dirReal,
|
|
224
|
-
rootPath: rootReal ?? path.resolve(entry.attachmentsRootDir)
|
|
225
|
-
})) return;
|
|
226
|
-
fs.rmSync(dirReal, {
|
|
227
|
-
recursive: true,
|
|
228
|
-
force: true
|
|
229
|
-
});
|
|
230
|
-
} catch {}
|
|
231
|
-
}
|
|
232
|
-
function reconcileOrphanedRun(params) {
|
|
233
|
-
const now = Date.now();
|
|
234
|
-
let changed = false;
|
|
235
|
-
if (typeof params.entry.endedAt !== "number") {
|
|
236
|
-
params.entry.endedAt = now;
|
|
237
|
-
changed = true;
|
|
238
|
-
}
|
|
239
|
-
const orphanOutcome = withSubagentOutcomeTiming({
|
|
240
|
-
status: "error",
|
|
241
|
-
error: `orphaned subagent run (${params.reason})`
|
|
242
|
-
}, {
|
|
243
|
-
startedAt: params.entry.startedAt,
|
|
244
|
-
endedAt: params.entry.endedAt
|
|
245
|
-
});
|
|
246
|
-
if (shouldUpdateRunOutcome(params.entry.outcome, orphanOutcome)) {
|
|
247
|
-
params.entry.outcome = orphanOutcome;
|
|
248
|
-
changed = true;
|
|
249
|
-
}
|
|
250
|
-
if (params.entry.endedReason !== "subagent-error") {
|
|
251
|
-
params.entry.endedReason = SUBAGENT_ENDED_REASON_ERROR;
|
|
252
|
-
changed = true;
|
|
253
|
-
}
|
|
254
|
-
if (params.entry.cleanupHandled !== true) {
|
|
255
|
-
params.entry.cleanupHandled = true;
|
|
256
|
-
changed = true;
|
|
257
|
-
}
|
|
258
|
-
if (typeof params.entry.cleanupCompletedAt !== "number") {
|
|
259
|
-
params.entry.cleanupCompletedAt = now;
|
|
260
|
-
changed = true;
|
|
261
|
-
}
|
|
262
|
-
if (params.entry.cleanup === "delete" || !params.entry.retainAttachmentsOnKeep) safeRemoveAttachmentsDirSync(params.entry);
|
|
263
|
-
const removed = params.runs.delete(params.runId);
|
|
264
|
-
params.resumedRuns.delete(params.runId);
|
|
265
|
-
if (!removed && !changed) return false;
|
|
266
|
-
defaultRuntime.log(`[warn] Subagent orphan run pruned source=${params.source} run=${params.runId} child=${params.entry.childSessionKey} reason=${params.reason}`);
|
|
267
|
-
return true;
|
|
268
|
-
}
|
|
269
|
-
function reconcileOrphanedRestoredRuns(params) {
|
|
270
|
-
const storeCache = /* @__PURE__ */ new Map();
|
|
271
|
-
const now = Date.now();
|
|
272
|
-
let changed = false;
|
|
273
|
-
for (const [runId, entry] of params.runs.entries()) {
|
|
274
|
-
const orphanReason = resolveSubagentRunOrphanReason({
|
|
275
|
-
entry,
|
|
276
|
-
storeCache,
|
|
277
|
-
includeStaleUnended: true,
|
|
278
|
-
now
|
|
279
|
-
});
|
|
280
|
-
if (!orphanReason) continue;
|
|
281
|
-
if (reconcileOrphanedRun({
|
|
282
|
-
runId,
|
|
283
|
-
entry,
|
|
284
|
-
reason: orphanReason,
|
|
285
|
-
source: "restore",
|
|
286
|
-
runs: params.runs,
|
|
287
|
-
resumedRuns: params.resumedRuns
|
|
288
|
-
})) changed = true;
|
|
289
|
-
}
|
|
290
|
-
return changed;
|
|
291
|
-
}
|
|
292
|
-
function resolveArchiveAfterMs(cfg) {
|
|
293
|
-
const minutes = (cfg ?? getRuntimeConfig()).agents?.defaults?.subagents?.archiveAfterMinutes ?? 60;
|
|
294
|
-
if (!Number.isFinite(minutes) || minutes < 0) return;
|
|
295
|
-
if (minutes === 0) return;
|
|
296
|
-
return Math.max(1, Math.floor(minutes)) * 6e4;
|
|
297
|
-
}
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region src/agents/subagent-registry-cleanup.ts
|
|
300
|
-
function resolveCleanupCompletionReason(entry) {
|
|
301
|
-
return entry.endedReason ?? "subagent-complete";
|
|
302
|
-
}
|
|
303
|
-
function resolveEndedAgoMs(entry, now) {
|
|
304
|
-
return typeof entry.endedAt === "number" ? now - entry.endedAt : 0;
|
|
305
|
-
}
|
|
306
|
-
function resolveDeferredCleanupDecision(params) {
|
|
307
|
-
const endedAgo = resolveEndedAgoMs(params.entry, params.now);
|
|
308
|
-
const isCompletionMessageFlow = params.entry.expectsCompletionMessage === true;
|
|
309
|
-
const completionHardExpiryExceeded = isCompletionMessageFlow && endedAgo > params.announceCompletionHardExpiryMs;
|
|
310
|
-
if (isCompletionMessageFlow && params.activeDescendantRuns > 0) {
|
|
311
|
-
if (completionHardExpiryExceeded) return {
|
|
312
|
-
kind: "give-up",
|
|
313
|
-
reason: "expiry"
|
|
314
|
-
};
|
|
315
|
-
return {
|
|
316
|
-
kind: "defer-descendants",
|
|
317
|
-
delayMs: params.deferDescendantDelayMs
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
const retryCount = (params.entry.announceRetryCount ?? 0) + 1;
|
|
321
|
-
const expiryExceeded = isCompletionMessageFlow ? completionHardExpiryExceeded : endedAgo > params.announceExpiryMs;
|
|
322
|
-
if (retryCount >= params.maxAnnounceRetryCount || expiryExceeded) return {
|
|
323
|
-
kind: "give-up",
|
|
324
|
-
reason: retryCount >= params.maxAnnounceRetryCount ? "retry-limit" : "expiry",
|
|
325
|
-
retryCount
|
|
326
|
-
};
|
|
327
|
-
return {
|
|
328
|
-
kind: "retry",
|
|
329
|
-
retryCount,
|
|
330
|
-
resumeDelayMs: params.resolveAnnounceRetryDelayMs(retryCount)
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
//#endregion
|
|
334
|
-
//#region src/agents/subagent-registry-lifecycle.ts
|
|
335
|
-
const DELIVERY_MIRROR_HISTORY_MAX_CHARS = 128 * 1024;
|
|
336
|
-
const browserCleanupLoader$1 = createLazyImportLoader(() => import("./browser-lifecycle-cleanup-C9X09Vrg.js"));
|
|
337
|
-
async function loadCleanupBrowserSessionsForLifecycleEnd$1() {
|
|
338
|
-
return (await browserCleanupLoader$1.load()).cleanupBrowserSessionsForLifecycleEnd;
|
|
339
|
-
}
|
|
340
|
-
function createSubagentRegistryLifecycleController(params) {
|
|
341
|
-
const scheduledResumeTimers = /* @__PURE__ */ new Set();
|
|
342
|
-
const scheduleResumeSubagentRun = (runId, entry, delayMs) => {
|
|
343
|
-
const timer = setTimeout(() => {
|
|
344
|
-
scheduledResumeTimers.delete(timer);
|
|
345
|
-
if (params.runs.get(runId) !== entry) return;
|
|
346
|
-
params.resumeSubagentRun(runId);
|
|
347
|
-
}, delayMs);
|
|
348
|
-
timer.unref?.();
|
|
349
|
-
scheduledResumeTimers.add(timer);
|
|
350
|
-
};
|
|
351
|
-
const clearScheduledResumeTimers = () => {
|
|
352
|
-
for (const timer of scheduledResumeTimers) clearTimeout(timer);
|
|
353
|
-
scheduledResumeTimers.clear();
|
|
354
|
-
};
|
|
355
|
-
const maskRunId = (runId) => {
|
|
356
|
-
const trimmed = runId.trim();
|
|
357
|
-
if (!trimmed) return "unknown";
|
|
358
|
-
if (trimmed.length <= 8) return "***";
|
|
359
|
-
return `${trimmed.slice(0, 4)}…${trimmed.slice(-4)}`;
|
|
360
|
-
};
|
|
361
|
-
const maskSessionKey = (sessionKey) => {
|
|
362
|
-
const trimmed = sessionKey.trim();
|
|
363
|
-
if (!trimmed) return "unknown";
|
|
364
|
-
return `${trimmed.split(":").slice(0, 2).join(":") || "session"}:…`;
|
|
365
|
-
};
|
|
366
|
-
const buildSafeLifecycleErrorMeta = (err) => {
|
|
367
|
-
const message = formatErrorMessage(err);
|
|
368
|
-
const name = readErrorName(err);
|
|
369
|
-
return name ? {
|
|
370
|
-
name,
|
|
371
|
-
message
|
|
372
|
-
} : { message };
|
|
373
|
-
};
|
|
374
|
-
const formatAnnounceDeliveryError = (delivery) => {
|
|
375
|
-
const errors = [delivery.error, ...(delivery.phases ?? []).map((phase) => phase.error ? `${phase.phase}: ${phase.error}` : void 0)].map((value) => value?.trim()).filter((value) => Boolean(value));
|
|
376
|
-
return errors.length > 0 ? [...new Set(errors)].join("; ") : `delivery path ${delivery.path} did not complete`;
|
|
377
|
-
};
|
|
378
|
-
const recordAnnounceDeliveryResult = (entry, delivery) => {
|
|
379
|
-
if (typeof delivery.enqueuedAt === "number") entry.completionEnqueuedAt ??= delivery.enqueuedAt;
|
|
380
|
-
if (delivery.delivered) {
|
|
381
|
-
entry.completionDeliveredAt = typeof delivery.deliveredAt === "number" ? delivery.deliveredAt : Date.now();
|
|
382
|
-
entry.lastAnnounceDropReason = void 0;
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
const hasPriorRequesterDeliveryMirror = async (entry) => {
|
|
386
|
-
const expectedText = extractTextFromChatContent(entry.frozenResultText, { joinWith: "" });
|
|
387
|
-
if (entry.expectsCompletionMessage !== true || expectedText == null) return false;
|
|
388
|
-
const mirrorNotBefore = entry.startedAt ?? entry.createdAt;
|
|
389
|
-
const mirrorNotAfter = Date.now() + 3e4;
|
|
390
|
-
const expectedIdempotencyKey = buildAnnounceIdempotencyKey(buildAnnounceIdFromChildRun({
|
|
391
|
-
childSessionKey: entry.childSessionKey,
|
|
392
|
-
childRunId: entry.runId
|
|
393
|
-
}));
|
|
394
|
-
const isExpectedMirrorIdempotencyKey = (value) => typeof value === "string" && (value === expectedIdempotencyKey || value.startsWith(`${expectedIdempotencyKey}:internal-source-reply:`) || value.startsWith(`${expectedIdempotencyKey}:message-tool:internal-source-reply:`) || value.startsWith(`${entry.runId}:message-tool:`) || value.startsWith(`${entry.runId}:internal-source-reply:`));
|
|
395
|
-
try {
|
|
396
|
-
const mirror = (await params.callGateway({
|
|
397
|
-
method: "chat.history",
|
|
398
|
-
params: {
|
|
399
|
-
sessionKey: entry.requesterSessionKey,
|
|
400
|
-
limit: 25,
|
|
401
|
-
maxChars: DELIVERY_MIRROR_HISTORY_MAX_CHARS
|
|
402
|
-
},
|
|
403
|
-
timeoutMs: 5e3
|
|
404
|
-
})).messages?.find((message) => {
|
|
405
|
-
if (!message || typeof message !== "object") return false;
|
|
406
|
-
const record = message;
|
|
407
|
-
const timestamp = record.timestamp;
|
|
408
|
-
if (typeof timestamp !== "number" || !Number.isFinite(timestamp) || timestamp < mirrorNotBefore || timestamp > mirrorNotAfter || !isExpectedMirrorIdempotencyKey(record.idempotencyKey)) return false;
|
|
409
|
-
const text = extractTextFromChatContent(record.content, { joinWith: "" });
|
|
410
|
-
return record.role === "assistant" && record.provider === "daocore" && record.model === "delivery-mirror" && text === expectedText;
|
|
411
|
-
});
|
|
412
|
-
if (mirror) entry.completionDeliveredAt = mirror.timestamp;
|
|
413
|
-
return Boolean(mirror);
|
|
414
|
-
} catch {
|
|
415
|
-
return false;
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
const safeSetSubagentTaskDeliveryStatus = (args) => {
|
|
419
|
-
try {
|
|
420
|
-
setDetachedTaskDeliveryStatusByRunId({
|
|
421
|
-
runId: args.runId,
|
|
422
|
-
runtime: "subagent",
|
|
423
|
-
sessionKey: args.childSessionKey,
|
|
424
|
-
deliveryStatus: args.deliveryStatus,
|
|
425
|
-
error: args.deliveryStatus === "failed" ? args.deliveryError : void 0
|
|
426
|
-
});
|
|
427
|
-
} catch (err) {
|
|
428
|
-
params.warn("failed to update subagent background task delivery state", {
|
|
429
|
-
error: buildSafeLifecycleErrorMeta(err),
|
|
430
|
-
runId: maskRunId(args.runId),
|
|
431
|
-
childSessionKey: maskSessionKey(args.childSessionKey),
|
|
432
|
-
deliveryStatus: args.deliveryStatus
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
const safeFinalizeSubagentTaskRun = (args) => {
|
|
437
|
-
const endedAt = args.entry.endedAt ?? Date.now();
|
|
438
|
-
const lastEventAt = endedAt;
|
|
439
|
-
try {
|
|
440
|
-
if (args.outcome.status === "ok") {
|
|
441
|
-
const terminalResult = args.entry.expectsCompletionMessage === true ? resolveRequiredCompletionTerminalResult(args.entry.frozenResultText) : {};
|
|
442
|
-
completeTaskRunByRunId({
|
|
443
|
-
runId: args.entry.runId,
|
|
444
|
-
runtime: "subagent",
|
|
445
|
-
sessionKey: args.entry.childSessionKey,
|
|
446
|
-
endedAt,
|
|
447
|
-
lastEventAt,
|
|
448
|
-
progressSummary: args.entry.frozenResultText ?? void 0,
|
|
449
|
-
terminalSummary: terminalResult.terminalSummary ?? null,
|
|
450
|
-
terminalOutcome: terminalResult.terminalOutcome
|
|
451
|
-
});
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
failTaskRunByRunId({
|
|
455
|
-
runId: args.entry.runId,
|
|
456
|
-
runtime: "subagent",
|
|
457
|
-
sessionKey: args.entry.childSessionKey,
|
|
458
|
-
status: args.outcome.status === "timeout" ? "timed_out" : "failed",
|
|
459
|
-
endedAt,
|
|
460
|
-
lastEventAt,
|
|
461
|
-
error: args.outcome.status === "error" ? args.outcome.error : void 0,
|
|
462
|
-
progressSummary: args.entry.frozenResultText ?? void 0,
|
|
463
|
-
terminalSummary: null
|
|
464
|
-
});
|
|
465
|
-
} catch (err) {
|
|
466
|
-
params.warn("failed to finalize subagent background task state", {
|
|
467
|
-
error: buildSafeLifecycleErrorMeta(err),
|
|
468
|
-
runId: maskRunId(args.entry.runId),
|
|
469
|
-
childSessionKey: maskSessionKey(args.entry.childSessionKey),
|
|
470
|
-
outcomeStatus: args.outcome.status
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
const safeMarkRequiredCompletionDeliveryBlocked = (args) => {
|
|
475
|
-
if (args.entry.expectsCompletionMessage !== true || args.entry.outcome?.status !== "ok") return;
|
|
476
|
-
const endedAt = args.entry.endedAt ?? Date.now();
|
|
477
|
-
const terminalResult = resolveRequiredCompletionDeliveryFailureTerminalResult(args.reason);
|
|
478
|
-
try {
|
|
479
|
-
completeTaskRunByRunId({
|
|
480
|
-
runId: args.entry.runId,
|
|
481
|
-
runtime: "subagent",
|
|
482
|
-
sessionKey: args.entry.childSessionKey,
|
|
483
|
-
endedAt,
|
|
484
|
-
lastEventAt: Date.now(),
|
|
485
|
-
progressSummary: args.entry.frozenResultText ?? void 0,
|
|
486
|
-
terminalSummary: terminalResult.terminalSummary,
|
|
487
|
-
terminalOutcome: terminalResult.terminalOutcome
|
|
488
|
-
});
|
|
489
|
-
} catch (err) {
|
|
490
|
-
params.warn("failed to mark subagent completion delivery blocked", {
|
|
491
|
-
error: buildSafeLifecycleErrorMeta(err),
|
|
492
|
-
runId: maskRunId(args.entry.runId),
|
|
493
|
-
childSessionKey: maskSessionKey(args.entry.childSessionKey)
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
const freezeRunResultAtCompletion = async (entry, outcome) => {
|
|
498
|
-
if (entry.frozenResultText !== void 0) return false;
|
|
499
|
-
if (outcome.status === "error") {
|
|
500
|
-
entry.frozenResultText = null;
|
|
501
|
-
entry.frozenResultCapturedAt = Date.now();
|
|
502
|
-
return true;
|
|
503
|
-
}
|
|
504
|
-
try {
|
|
505
|
-
const captured = await params.captureSubagentCompletionReply(entry.childSessionKey, {
|
|
506
|
-
waitForReply: entry.expectsCompletionMessage === true,
|
|
507
|
-
outcome
|
|
508
|
-
});
|
|
509
|
-
entry.frozenResultText = captured?.trim() ? capFrozenResultText(captured) : null;
|
|
510
|
-
} catch {
|
|
511
|
-
entry.frozenResultText = null;
|
|
512
|
-
}
|
|
513
|
-
entry.frozenResultCapturedAt = Date.now();
|
|
514
|
-
return true;
|
|
515
|
-
};
|
|
516
|
-
const listPendingCompletionRunsForSession = (sessionKey) => {
|
|
517
|
-
const key = sessionKey.trim();
|
|
518
|
-
if (!key) return [];
|
|
519
|
-
const out = [];
|
|
520
|
-
for (const entry of params.runs.values()) {
|
|
521
|
-
if (entry.childSessionKey !== key) continue;
|
|
522
|
-
if (entry.expectsCompletionMessage !== true) continue;
|
|
523
|
-
if (typeof entry.endedAt !== "number") continue;
|
|
524
|
-
if (typeof entry.cleanupCompletedAt === "number") continue;
|
|
525
|
-
out.push(entry);
|
|
526
|
-
}
|
|
527
|
-
return out;
|
|
528
|
-
};
|
|
529
|
-
const refreshFrozenResultFromSession = async (sessionKey) => {
|
|
530
|
-
const candidates = listPendingCompletionRunsForSession(sessionKey).filter((entry) => entry.outcome?.status !== "error");
|
|
531
|
-
if (candidates.length === 0) return false;
|
|
532
|
-
let captured;
|
|
533
|
-
try {
|
|
534
|
-
captured = await params.captureSubagentCompletionReply(sessionKey);
|
|
535
|
-
} catch {
|
|
536
|
-
return false;
|
|
537
|
-
}
|
|
538
|
-
const trimmed = captured?.trim();
|
|
539
|
-
if (!trimmed || isSilentReplyText(trimmed, "NO_REPLY")) return false;
|
|
540
|
-
const nextFrozen = capFrozenResultText(trimmed);
|
|
541
|
-
const capturedAt = Date.now();
|
|
542
|
-
let changed = false;
|
|
543
|
-
for (const entry of candidates) {
|
|
544
|
-
if (entry.frozenResultText === nextFrozen) continue;
|
|
545
|
-
entry.frozenResultText = nextFrozen;
|
|
546
|
-
entry.frozenResultCapturedAt = capturedAt;
|
|
547
|
-
if (entry.pendingFinalDeliveryPayload) entry.pendingFinalDeliveryPayload = {
|
|
548
|
-
...entry.pendingFinalDeliveryPayload,
|
|
549
|
-
frozenResultText: nextFrozen
|
|
550
|
-
};
|
|
551
|
-
changed = true;
|
|
552
|
-
}
|
|
553
|
-
if (changed) params.persist();
|
|
554
|
-
return changed;
|
|
555
|
-
};
|
|
556
|
-
const emitCompletionEndedHookIfNeeded = async (entry, reason) => {
|
|
557
|
-
if (entry.expectsCompletionMessage === true && params.shouldEmitEndedHookForRun({
|
|
558
|
-
entry,
|
|
559
|
-
reason
|
|
560
|
-
})) await params.emitSubagentEndedHookForRun({
|
|
561
|
-
entry,
|
|
562
|
-
reason,
|
|
563
|
-
sendFarewell: true
|
|
564
|
-
});
|
|
565
|
-
};
|
|
566
|
-
const clearPendingFinalDelivery = (entry) => {
|
|
567
|
-
entry.pendingFinalDelivery = void 0;
|
|
568
|
-
entry.pendingFinalDeliveryCreatedAt = void 0;
|
|
569
|
-
entry.pendingFinalDeliveryLastAttemptAt = void 0;
|
|
570
|
-
entry.pendingFinalDeliveryAttemptCount = void 0;
|
|
571
|
-
entry.pendingFinalDeliveryLastError = void 0;
|
|
572
|
-
entry.pendingFinalDeliveryPayload = void 0;
|
|
573
|
-
};
|
|
574
|
-
const loadPendingFinalDeliveryPayload = (entry) => {
|
|
575
|
-
return {
|
|
576
|
-
requesterSessionKey: entry.pendingFinalDeliveryPayload?.requesterSessionKey ?? entry.requesterSessionKey,
|
|
577
|
-
requesterOrigin: entry.pendingFinalDeliveryPayload?.requesterOrigin ?? entry.requesterOrigin,
|
|
578
|
-
requesterDisplayKey: entry.pendingFinalDeliveryPayload?.requesterDisplayKey ?? entry.requesterDisplayKey,
|
|
579
|
-
childSessionKey: entry.pendingFinalDeliveryPayload?.childSessionKey ?? entry.childSessionKey,
|
|
580
|
-
childRunId: entry.pendingFinalDeliveryPayload?.childRunId ?? entry.runId,
|
|
581
|
-
task: entry.pendingFinalDeliveryPayload?.task ?? entry.task,
|
|
582
|
-
label: entry.pendingFinalDeliveryPayload?.label ?? entry.label,
|
|
583
|
-
startedAt: entry.pendingFinalDeliveryPayload?.startedAt ?? entry.startedAt,
|
|
584
|
-
endedAt: entry.pendingFinalDeliveryPayload?.endedAt ?? entry.endedAt,
|
|
585
|
-
outcome: entry.pendingFinalDeliveryPayload?.outcome ?? entry.outcome,
|
|
586
|
-
expectsCompletionMessage: entry.pendingFinalDeliveryPayload?.expectsCompletionMessage ?? entry.expectsCompletionMessage,
|
|
587
|
-
spawnMode: entry.pendingFinalDeliveryPayload?.spawnMode ?? entry.spawnMode,
|
|
588
|
-
frozenResultText: entry.pendingFinalDeliveryPayload?.frozenResultText ?? entry.frozenResultText,
|
|
589
|
-
fallbackFrozenResultText: entry.pendingFinalDeliveryPayload?.fallbackFrozenResultText ?? entry.fallbackFrozenResultText,
|
|
590
|
-
wakeOnDescendantSettle: entry.pendingFinalDeliveryPayload?.wakeOnDescendantSettle ?? entry.wakeOnDescendantSettle
|
|
591
|
-
};
|
|
592
|
-
};
|
|
593
|
-
const markPendingFinalDelivery = (args) => {
|
|
594
|
-
const now = Date.now();
|
|
595
|
-
const payload = loadPendingFinalDeliveryPayload(args.entry);
|
|
596
|
-
args.entry.pendingFinalDelivery = true;
|
|
597
|
-
args.entry.pendingFinalDeliveryCreatedAt ??= now;
|
|
598
|
-
args.entry.pendingFinalDeliveryLastAttemptAt = now;
|
|
599
|
-
args.entry.pendingFinalDeliveryAttemptCount = (args.entry.pendingFinalDeliveryAttemptCount ?? 0) + 1;
|
|
600
|
-
args.entry.pendingFinalDeliveryLastError = args.error ?? null;
|
|
601
|
-
args.entry.pendingFinalDeliveryPayload = payload;
|
|
602
|
-
};
|
|
603
|
-
const suspendPendingFinalDelivery = (args) => {
|
|
604
|
-
markPendingFinalDelivery({
|
|
605
|
-
entry: args.entry,
|
|
606
|
-
error: args.error ?? args.entry.lastAnnounceDeliveryError ?? args.reason
|
|
607
|
-
});
|
|
608
|
-
const now = Date.now();
|
|
609
|
-
args.entry.deliverySuspendedAt ??= now;
|
|
610
|
-
args.entry.deliverySuspendedReason = args.reason;
|
|
611
|
-
args.entry.cleanupHandled = false;
|
|
612
|
-
args.entry.wakeOnDescendantSettle = void 0;
|
|
613
|
-
args.entry.fallbackFrozenResultText = void 0;
|
|
614
|
-
args.entry.fallbackFrozenResultCapturedAt = void 0;
|
|
615
|
-
params.resumedRuns.delete(args.runId);
|
|
616
|
-
safeSetSubagentTaskDeliveryStatus({
|
|
617
|
-
runId: args.runId,
|
|
618
|
-
childSessionKey: args.entry.childSessionKey,
|
|
619
|
-
deliveryStatus: "failed",
|
|
620
|
-
deliveryError: args.entry.lastAnnounceDeliveryError ?? args.reason
|
|
621
|
-
});
|
|
622
|
-
safeMarkRequiredCompletionDeliveryBlocked({
|
|
623
|
-
entry: args.entry,
|
|
624
|
-
reason: args.entry.lastAnnounceDeliveryError ?? args.reason
|
|
625
|
-
});
|
|
626
|
-
logAnnounceGiveUp(args.entry, args.reason);
|
|
627
|
-
params.persist();
|
|
628
|
-
};
|
|
629
|
-
const shouldSuspendPendingFinalDelivery = (entry) => entry.expectsCompletionMessage === true && entry.cleanup === "keep" && entry.endedReason === "subagent-complete" && entry.outcome?.status === "ok";
|
|
630
|
-
const finalizeResumedAnnounceGiveUp = async (giveUpParams) => {
|
|
631
|
-
if (shouldSuspendPendingFinalDelivery(giveUpParams.entry)) {
|
|
632
|
-
suspendPendingFinalDelivery({
|
|
633
|
-
runId: giveUpParams.runId,
|
|
634
|
-
entry: giveUpParams.entry,
|
|
635
|
-
reason: giveUpParams.reason,
|
|
636
|
-
error: giveUpParams.entry.lastAnnounceDeliveryError
|
|
637
|
-
});
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
clearPendingFinalDelivery(giveUpParams.entry);
|
|
641
|
-
safeSetSubagentTaskDeliveryStatus({
|
|
642
|
-
runId: giveUpParams.runId,
|
|
643
|
-
childSessionKey: giveUpParams.entry.childSessionKey,
|
|
644
|
-
deliveryStatus: "failed",
|
|
645
|
-
deliveryError: giveUpParams.entry.lastAnnounceDeliveryError
|
|
646
|
-
});
|
|
647
|
-
safeMarkRequiredCompletionDeliveryBlocked({
|
|
648
|
-
entry: giveUpParams.entry,
|
|
649
|
-
reason: giveUpParams.entry.lastAnnounceDeliveryError ?? giveUpParams.reason
|
|
650
|
-
});
|
|
651
|
-
giveUpParams.entry.wakeOnDescendantSettle = void 0;
|
|
652
|
-
giveUpParams.entry.fallbackFrozenResultText = void 0;
|
|
653
|
-
giveUpParams.entry.fallbackFrozenResultCapturedAt = void 0;
|
|
654
|
-
if (giveUpParams.entry.cleanup === "delete" || !giveUpParams.entry.retainAttachmentsOnKeep) await safeRemoveAttachmentsDir(giveUpParams.entry);
|
|
655
|
-
const completionReason = resolveCleanupCompletionReason(giveUpParams.entry);
|
|
656
|
-
logAnnounceGiveUp(giveUpParams.entry, giveUpParams.reason);
|
|
657
|
-
completeCleanupBookkeeping({
|
|
658
|
-
runId: giveUpParams.runId,
|
|
659
|
-
entry: giveUpParams.entry,
|
|
660
|
-
cleanup: giveUpParams.entry.cleanup,
|
|
661
|
-
completedAt: Date.now()
|
|
662
|
-
});
|
|
663
|
-
await emitCompletionEndedHookIfNeeded(giveUpParams.entry, completionReason);
|
|
664
|
-
};
|
|
665
|
-
const beginSubagentCleanup = (runId) => {
|
|
666
|
-
const entry = params.runs.get(runId);
|
|
667
|
-
if (!entry) return false;
|
|
668
|
-
if (entry.cleanupCompletedAt || entry.cleanupHandled) return false;
|
|
669
|
-
entry.cleanupHandled = true;
|
|
670
|
-
params.persist();
|
|
671
|
-
return true;
|
|
672
|
-
};
|
|
673
|
-
const retryDeferredCompletedAnnounces = (excludeRunId) => {
|
|
674
|
-
const now = Date.now();
|
|
675
|
-
for (const [runId, entry] of params.runs.entries()) {
|
|
676
|
-
if (excludeRunId && runId === excludeRunId) continue;
|
|
677
|
-
if (typeof entry.endedAt !== "number") continue;
|
|
678
|
-
if (entry.cleanupCompletedAt || entry.cleanupHandled) continue;
|
|
679
|
-
if (entry.pendingFinalDelivery === true && typeof entry.deliverySuspendedAt === "number") continue;
|
|
680
|
-
if (params.suppressAnnounceForSteerRestart(entry)) continue;
|
|
681
|
-
const endedAgo = now - (entry.endedAt ?? now);
|
|
682
|
-
if (entry.expectsCompletionMessage !== true && endedAgo > 3e5) {
|
|
683
|
-
if (!beginSubagentCleanup(runId)) continue;
|
|
684
|
-
finalizeResumedAnnounceGiveUp({
|
|
685
|
-
runId,
|
|
686
|
-
entry,
|
|
687
|
-
reason: "expiry"
|
|
688
|
-
}).catch((error) => {
|
|
689
|
-
defaultRuntime.log(`[warn] Subagent expiry finalize failed during deferred retry for run ${runId}: ${String(error)}`);
|
|
690
|
-
const current = params.runs.get(runId);
|
|
691
|
-
if (!current || current.cleanupCompletedAt) return;
|
|
692
|
-
current.cleanupHandled = false;
|
|
693
|
-
params.persist();
|
|
694
|
-
});
|
|
695
|
-
continue;
|
|
696
|
-
}
|
|
697
|
-
params.resumedRuns.delete(runId);
|
|
698
|
-
params.resumeSubagentRun(runId);
|
|
699
|
-
}
|
|
700
|
-
};
|
|
701
|
-
const completeCleanupBookkeeping = (cleanupParams) => {
|
|
702
|
-
if (cleanupParams.entry.spawnMode !== "session") retireSessionMcpRuntimeForSessionKey({
|
|
703
|
-
sessionKey: cleanupParams.entry.childSessionKey,
|
|
704
|
-
reason: "subagent-run-cleanup",
|
|
705
|
-
onError: (error, sessionId) => {
|
|
706
|
-
params.warn("failed to retire subagent bundle MCP runtime", {
|
|
707
|
-
error: buildSafeLifecycleErrorMeta(error),
|
|
708
|
-
sessionId,
|
|
709
|
-
runId: maskRunId(cleanupParams.runId),
|
|
710
|
-
childSessionKey: maskSessionKey(cleanupParams.entry.childSessionKey)
|
|
711
|
-
});
|
|
712
|
-
}
|
|
713
|
-
});
|
|
714
|
-
if (cleanupParams.cleanup === "delete") {
|
|
715
|
-
params.clearPendingLifecycleError(cleanupParams.runId);
|
|
716
|
-
params.notifyContextEngineSubagentEnded({
|
|
717
|
-
childSessionKey: cleanupParams.entry.childSessionKey,
|
|
718
|
-
reason: "deleted",
|
|
719
|
-
agentDir: cleanupParams.entry.agentDir,
|
|
720
|
-
workspaceDir: cleanupParams.entry.workspaceDir
|
|
721
|
-
});
|
|
722
|
-
params.runs.delete(cleanupParams.runId);
|
|
723
|
-
params.persist();
|
|
724
|
-
retryDeferredCompletedAnnounces(cleanupParams.runId);
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
params.notifyContextEngineSubagentEnded({
|
|
728
|
-
childSessionKey: cleanupParams.entry.childSessionKey,
|
|
729
|
-
reason: "completed",
|
|
730
|
-
agentDir: cleanupParams.entry.agentDir,
|
|
731
|
-
workspaceDir: cleanupParams.entry.workspaceDir
|
|
732
|
-
});
|
|
733
|
-
cleanupParams.entry.cleanupCompletedAt = cleanupParams.completedAt;
|
|
734
|
-
params.persist();
|
|
735
|
-
retryDeferredCompletedAnnounces(cleanupParams.runId);
|
|
736
|
-
};
|
|
737
|
-
const retireRunModeBundleMcpRuntime = async (cleanupParams) => {
|
|
738
|
-
if (cleanupParams.entry.spawnMode === "session") return;
|
|
739
|
-
await retireSessionMcpRuntimeForSessionKey({
|
|
740
|
-
sessionKey: cleanupParams.entry.childSessionKey,
|
|
741
|
-
reason: cleanupParams.reason,
|
|
742
|
-
onError: (error, sessionId) => {
|
|
743
|
-
params.warn("failed to retire subagent bundle MCP runtime", {
|
|
744
|
-
error: buildSafeLifecycleErrorMeta(error),
|
|
745
|
-
sessionId,
|
|
746
|
-
runId: maskRunId(cleanupParams.runId),
|
|
747
|
-
childSessionKey: maskSessionKey(cleanupParams.entry.childSessionKey)
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
|
-
};
|
|
752
|
-
const finalizeSubagentCleanup = async (runId, cleanup, didAnnounce, options) => {
|
|
753
|
-
const entry = params.runs.get(runId);
|
|
754
|
-
if (!entry) return;
|
|
755
|
-
if (didAnnounce) {
|
|
756
|
-
if (!options?.skipAnnounce) {
|
|
757
|
-
const deliveredAt = entry.completionDeliveredAt ?? Date.now();
|
|
758
|
-
entry.completionDeliveredAt = deliveredAt;
|
|
759
|
-
entry.completionAnnouncedAt = deliveredAt;
|
|
760
|
-
params.persist();
|
|
761
|
-
}
|
|
762
|
-
clearPendingFinalDelivery(entry);
|
|
763
|
-
entry.deliverySuspendedAt = void 0;
|
|
764
|
-
entry.deliverySuspendedReason = void 0;
|
|
765
|
-
if (!options?.skipDeliveryStatus) safeSetSubagentTaskDeliveryStatus({
|
|
766
|
-
runId,
|
|
767
|
-
childSessionKey: entry.childSessionKey,
|
|
768
|
-
deliveryStatus: "delivered"
|
|
769
|
-
});
|
|
770
|
-
entry.lastAnnounceDeliveryError = void 0;
|
|
771
|
-
entry.lastAnnounceDropReason = void 0;
|
|
772
|
-
entry.wakeOnDescendantSettle = void 0;
|
|
773
|
-
entry.fallbackFrozenResultText = void 0;
|
|
774
|
-
entry.fallbackFrozenResultCapturedAt = void 0;
|
|
775
|
-
await emitCompletionEndedHookIfNeeded(entry, resolveCleanupCompletionReason(entry));
|
|
776
|
-
if (cleanup === "delete" || !entry.retainAttachmentsOnKeep) await safeRemoveAttachmentsDir(entry);
|
|
777
|
-
if (cleanup === "delete") {
|
|
778
|
-
entry.frozenResultText = void 0;
|
|
779
|
-
entry.frozenResultCapturedAt = void 0;
|
|
780
|
-
}
|
|
781
|
-
completeCleanupBookkeeping({
|
|
782
|
-
runId,
|
|
783
|
-
entry,
|
|
784
|
-
cleanup,
|
|
785
|
-
completedAt: Date.now()
|
|
786
|
-
});
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
const now = Date.now();
|
|
790
|
-
const deferredDecision = resolveDeferredCleanupDecision({
|
|
791
|
-
entry,
|
|
792
|
-
now,
|
|
793
|
-
activeDescendantRuns: Math.max(0, params.countPendingDescendantRuns(entry.childSessionKey)),
|
|
794
|
-
announceExpiryMs: ANNOUNCE_EXPIRY_MS,
|
|
795
|
-
announceCompletionHardExpiryMs: ANNOUNCE_COMPLETION_HARD_EXPIRY_MS,
|
|
796
|
-
maxAnnounceRetryCount: 3,
|
|
797
|
-
deferDescendantDelayMs: MIN_ANNOUNCE_RETRY_DELAY_MS,
|
|
798
|
-
resolveAnnounceRetryDelayMs
|
|
799
|
-
});
|
|
800
|
-
if (deferredDecision.kind === "defer-descendants") {
|
|
801
|
-
entry.lastAnnounceRetryAt = now;
|
|
802
|
-
entry.wakeOnDescendantSettle = true;
|
|
803
|
-
entry.cleanupHandled = false;
|
|
804
|
-
params.resumedRuns.delete(runId);
|
|
805
|
-
params.persist();
|
|
806
|
-
scheduleResumeSubagentRun(runId, entry, deferredDecision.delayMs);
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
if (deferredDecision.retryCount != null) {
|
|
810
|
-
entry.announceRetryCount = deferredDecision.retryCount;
|
|
811
|
-
entry.lastAnnounceRetryAt = now;
|
|
812
|
-
}
|
|
813
|
-
if (deferredDecision.kind === "give-up") {
|
|
814
|
-
if (shouldSuspendPendingFinalDelivery(entry)) {
|
|
815
|
-
suspendPendingFinalDelivery({
|
|
816
|
-
runId,
|
|
817
|
-
entry,
|
|
818
|
-
reason: deferredDecision.reason,
|
|
819
|
-
error: entry.lastAnnounceDeliveryError
|
|
820
|
-
});
|
|
821
|
-
return;
|
|
822
|
-
}
|
|
823
|
-
clearPendingFinalDelivery(entry);
|
|
824
|
-
safeSetSubagentTaskDeliveryStatus({
|
|
825
|
-
runId,
|
|
826
|
-
childSessionKey: entry.childSessionKey,
|
|
827
|
-
deliveryStatus: "failed",
|
|
828
|
-
deliveryError: entry.lastAnnounceDeliveryError
|
|
829
|
-
});
|
|
830
|
-
safeMarkRequiredCompletionDeliveryBlocked({
|
|
831
|
-
entry,
|
|
832
|
-
reason: entry.lastAnnounceDeliveryError ?? deferredDecision.reason
|
|
833
|
-
});
|
|
834
|
-
entry.wakeOnDescendantSettle = void 0;
|
|
835
|
-
entry.fallbackFrozenResultText = void 0;
|
|
836
|
-
entry.fallbackFrozenResultCapturedAt = void 0;
|
|
837
|
-
if (cleanup === "delete" || !entry.retainAttachmentsOnKeep) await safeRemoveAttachmentsDir(entry);
|
|
838
|
-
const completionReason = resolveCleanupCompletionReason(entry);
|
|
839
|
-
logAnnounceGiveUp(entry, deferredDecision.reason);
|
|
840
|
-
completeCleanupBookkeeping({
|
|
841
|
-
runId,
|
|
842
|
-
entry,
|
|
843
|
-
cleanup,
|
|
844
|
-
completedAt: now
|
|
845
|
-
});
|
|
846
|
-
await emitCompletionEndedHookIfNeeded(entry, completionReason);
|
|
847
|
-
return;
|
|
848
|
-
}
|
|
849
|
-
markPendingFinalDelivery({
|
|
850
|
-
entry,
|
|
851
|
-
error: didAnnounce ? void 0 : "announce deferred or direct delivery failed"
|
|
852
|
-
});
|
|
853
|
-
entry.cleanupHandled = false;
|
|
854
|
-
params.resumedRuns.delete(runId);
|
|
855
|
-
params.persist();
|
|
856
|
-
if (deferredDecision.resumeDelayMs == null) return;
|
|
857
|
-
scheduleResumeSubagentRun(runId, entry, deferredDecision.resumeDelayMs);
|
|
858
|
-
};
|
|
859
|
-
const startSubagentAnnounceCleanupFlow = (runId, entry) => {
|
|
860
|
-
if (typeof entry.completionAnnouncedAt === "number") {
|
|
861
|
-
if (!beginSubagentCleanup(runId)) return false;
|
|
862
|
-
finalizeSubagentCleanup(runId, entry.cleanup, true, { skipAnnounce: true }).catch((err) => {
|
|
863
|
-
defaultRuntime.log(`[warn] subagent cleanup finalize failed (${runId}): ${String(err)}`);
|
|
864
|
-
const current = params.runs.get(runId);
|
|
865
|
-
if (!current || current.cleanupCompletedAt) return;
|
|
866
|
-
current.cleanupHandled = false;
|
|
867
|
-
params.persist();
|
|
868
|
-
});
|
|
869
|
-
return true;
|
|
870
|
-
}
|
|
871
|
-
if (!beginSubagentCleanup(runId)) return false;
|
|
872
|
-
if (entry.expectsCompletionMessage === false) {
|
|
873
|
-
(async () => {
|
|
874
|
-
if (entry.cleanup === "delete") await deleteSubagentSessionForCleanup({
|
|
875
|
-
callGateway: params.callGateway,
|
|
876
|
-
childSessionKey: entry.childSessionKey,
|
|
877
|
-
spawnMode: entry.spawnMode,
|
|
878
|
-
onError: (error) => params.warn("sessions.delete failed during subagent cleanup", {
|
|
879
|
-
error: buildSafeLifecycleErrorMeta(error),
|
|
880
|
-
runId: maskRunId(runId),
|
|
881
|
-
childSessionKey: maskSessionKey(entry.childSessionKey)
|
|
882
|
-
})
|
|
883
|
-
});
|
|
884
|
-
await finalizeSubagentCleanup(runId, entry.cleanup, true, {
|
|
885
|
-
skipAnnounce: true,
|
|
886
|
-
skipDeliveryStatus: true
|
|
887
|
-
});
|
|
888
|
-
})().catch((err) => {
|
|
889
|
-
defaultRuntime.log(`[warn] subagent cleanup finalize failed (${runId}): ${String(err)}`);
|
|
890
|
-
const current = params.runs.get(runId);
|
|
891
|
-
if (!current || current.cleanupCompletedAt) return;
|
|
892
|
-
current.cleanupHandled = false;
|
|
893
|
-
params.persist();
|
|
894
|
-
});
|
|
895
|
-
return true;
|
|
896
|
-
}
|
|
897
|
-
const pendingPayload = loadPendingFinalDeliveryPayload(entry);
|
|
898
|
-
const requesterOrigin = normalizeDeliveryContext(pendingPayload.requesterOrigin);
|
|
899
|
-
let latestDeliveryError = entry.lastAnnounceDeliveryError;
|
|
900
|
-
const finalizeAnnounceCleanup = async (didAnnounce) => {
|
|
901
|
-
const shouldCreditPriorDelivery = !didAnnounce && await hasPriorRequesterDeliveryMirror(entry);
|
|
902
|
-
if (shouldCreditPriorDelivery) latestDeliveryError = void 0;
|
|
903
|
-
if (!didAnnounce && latestDeliveryError) entry.lastAnnounceDeliveryError = latestDeliveryError;
|
|
904
|
-
finalizeSubagentCleanup(runId, entry.cleanup, didAnnounce || shouldCreditPriorDelivery).catch((err) => {
|
|
905
|
-
defaultRuntime.log(`[warn] subagent cleanup finalize failed (${runId}): ${String(err)}`);
|
|
906
|
-
const current = params.runs.get(runId);
|
|
907
|
-
if (!current || current.cleanupCompletedAt) return;
|
|
908
|
-
current.cleanupHandled = false;
|
|
909
|
-
params.persist();
|
|
910
|
-
});
|
|
911
|
-
};
|
|
912
|
-
params.runSubagentAnnounceFlow({
|
|
913
|
-
childSessionKey: pendingPayload.childSessionKey,
|
|
914
|
-
childRunId: pendingPayload.childRunId,
|
|
915
|
-
requesterSessionKey: pendingPayload.requesterSessionKey,
|
|
916
|
-
requesterOrigin,
|
|
917
|
-
requesterDisplayKey: pendingPayload.requesterDisplayKey,
|
|
918
|
-
task: pendingPayload.task,
|
|
919
|
-
timeoutMs: params.subagentAnnounceTimeoutMs,
|
|
920
|
-
cleanup: entry.cleanup,
|
|
921
|
-
roundOneReply: pendingPayload.frozenResultText ?? void 0,
|
|
922
|
-
fallbackReply: pendingPayload.fallbackFrozenResultText ?? void 0,
|
|
923
|
-
waitForCompletion: false,
|
|
924
|
-
startedAt: pendingPayload.startedAt,
|
|
925
|
-
endedAt: pendingPayload.endedAt,
|
|
926
|
-
label: pendingPayload.label,
|
|
927
|
-
outcome: pendingPayload.outcome,
|
|
928
|
-
spawnMode: pendingPayload.spawnMode,
|
|
929
|
-
expectsCompletionMessage: pendingPayload.expectsCompletionMessage,
|
|
930
|
-
wakeOnDescendantSettle: pendingPayload.wakeOnDescendantSettle === true,
|
|
931
|
-
onDeliveryResult: (delivery) => {
|
|
932
|
-
recordAnnounceDeliveryResult(entry, delivery);
|
|
933
|
-
if (delivery.delivered) {
|
|
934
|
-
if (entry.lastAnnounceDeliveryError !== void 0) {
|
|
935
|
-
entry.lastAnnounceDeliveryError = void 0;
|
|
936
|
-
params.persist();
|
|
937
|
-
}
|
|
938
|
-
latestDeliveryError = void 0;
|
|
939
|
-
return;
|
|
940
|
-
}
|
|
941
|
-
if (delivery.path === "none") entry.lastAnnounceDropReason = "sink_unavailable";
|
|
942
|
-
latestDeliveryError = formatAnnounceDeliveryError(delivery);
|
|
943
|
-
if (entry.lastAnnounceDeliveryError !== latestDeliveryError) {
|
|
944
|
-
entry.lastAnnounceDeliveryError = latestDeliveryError;
|
|
945
|
-
params.persist();
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
}).then((didAnnounce) => {
|
|
949
|
-
finalizeAnnounceCleanup(didAnnounce);
|
|
950
|
-
}).catch((error) => {
|
|
951
|
-
defaultRuntime.log(`[warn] Subagent announce flow failed during cleanup for run ${runId}: ${String(error)}`);
|
|
952
|
-
finalizeAnnounceCleanup(false);
|
|
953
|
-
});
|
|
954
|
-
return true;
|
|
955
|
-
};
|
|
956
|
-
const completeSubagentRun = async (completeParams) => {
|
|
957
|
-
params.clearPendingLifecycleError(completeParams.runId);
|
|
958
|
-
const entry = params.runs.get(completeParams.runId);
|
|
959
|
-
if (!entry) return;
|
|
960
|
-
let mutated = false;
|
|
961
|
-
if (completeParams.reason === "subagent-complete" && entry.suppressAnnounceReason === "killed" && (entry.cleanupHandled || typeof entry.cleanupCompletedAt === "number")) {
|
|
962
|
-
entry.suppressAnnounceReason = void 0;
|
|
963
|
-
entry.cleanupHandled = false;
|
|
964
|
-
entry.cleanupCompletedAt = void 0;
|
|
965
|
-
entry.completionAnnouncedAt = void 0;
|
|
966
|
-
mutated = true;
|
|
967
|
-
}
|
|
968
|
-
const endedAt = typeof completeParams.endedAt === "number" ? completeParams.endedAt : Date.now();
|
|
969
|
-
if (entry.endedAt !== endedAt) {
|
|
970
|
-
entry.endedAt = endedAt;
|
|
971
|
-
mutated = true;
|
|
972
|
-
}
|
|
973
|
-
const outcome = withSubagentOutcomeTiming(completeParams.outcome, {
|
|
974
|
-
startedAt: entry.startedAt,
|
|
975
|
-
endedAt
|
|
976
|
-
});
|
|
977
|
-
if (shouldUpdateRunOutcome(entry.outcome, outcome)) {
|
|
978
|
-
entry.outcome = outcome;
|
|
979
|
-
mutated = true;
|
|
980
|
-
}
|
|
981
|
-
if (entry.endedReason !== completeParams.reason) {
|
|
982
|
-
entry.endedReason = completeParams.reason;
|
|
983
|
-
mutated = true;
|
|
984
|
-
}
|
|
985
|
-
if (entry.pauseReason !== void 0) {
|
|
986
|
-
entry.pauseReason = void 0;
|
|
987
|
-
mutated = true;
|
|
988
|
-
}
|
|
989
|
-
if (await freezeRunResultAtCompletion(entry, outcome)) mutated = true;
|
|
990
|
-
if (mutated) params.persist();
|
|
991
|
-
safeFinalizeSubagentTaskRun({
|
|
992
|
-
entry,
|
|
993
|
-
outcome
|
|
994
|
-
});
|
|
995
|
-
try {
|
|
996
|
-
await persistSubagentSessionTiming(entry);
|
|
997
|
-
} catch (err) {
|
|
998
|
-
params.warn("failed to persist subagent session timing", {
|
|
999
|
-
err,
|
|
1000
|
-
runId: entry.runId,
|
|
1001
|
-
childSessionKey: entry.childSessionKey
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
const suppressedForSteerRestart = params.suppressAnnounceForSteerRestart(entry);
|
|
1005
|
-
if (mutated && !suppressedForSteerRestart) emitSessionLifecycleEvent({
|
|
1006
|
-
sessionKey: entry.childSessionKey,
|
|
1007
|
-
reason: "subagent-status",
|
|
1008
|
-
parentSessionKey: entry.requesterSessionKey,
|
|
1009
|
-
label: entry.label
|
|
1010
|
-
});
|
|
1011
|
-
const shouldEmitEndedHook = !suppressedForSteerRestart && params.shouldEmitEndedHookForRun({
|
|
1012
|
-
entry,
|
|
1013
|
-
reason: completeParams.reason
|
|
1014
|
-
});
|
|
1015
|
-
if (!(shouldEmitEndedHook && completeParams.triggerCleanup && entry.expectsCompletionMessage === true && !suppressedForSteerRestart) && shouldEmitEndedHook) await params.emitSubagentEndedHookForRun({
|
|
1016
|
-
entry,
|
|
1017
|
-
reason: completeParams.reason,
|
|
1018
|
-
sendFarewell: completeParams.sendFarewell,
|
|
1019
|
-
accountId: completeParams.accountId
|
|
1020
|
-
});
|
|
1021
|
-
if (!completeParams.triggerCleanup || suppressedForSteerRestart) return;
|
|
1022
|
-
try {
|
|
1023
|
-
await (params.cleanupBrowserSessionsForLifecycleEnd ?? await loadCleanupBrowserSessionsForLifecycleEnd$1())({
|
|
1024
|
-
sessionKeys: [entry.childSessionKey],
|
|
1025
|
-
onWarn: (msg) => params.warn(msg, { runId: entry.runId })
|
|
1026
|
-
});
|
|
1027
|
-
} catch (error) {
|
|
1028
|
-
params.warn("failed to cleanup browser sessions for completed subagent", {
|
|
1029
|
-
error: buildSafeLifecycleErrorMeta(error),
|
|
1030
|
-
runId: maskRunId(completeParams.runId),
|
|
1031
|
-
childSessionKey: maskSessionKey(entry.childSessionKey)
|
|
1032
|
-
});
|
|
1033
|
-
}
|
|
1034
|
-
try {
|
|
1035
|
-
await retireRunModeBundleMcpRuntime({
|
|
1036
|
-
runId: completeParams.runId,
|
|
1037
|
-
entry,
|
|
1038
|
-
reason: "subagent-run-complete"
|
|
1039
|
-
});
|
|
1040
|
-
} catch (error) {
|
|
1041
|
-
params.warn("failed to retire subagent bundle MCP runtime after completion", {
|
|
1042
|
-
error: buildSafeLifecycleErrorMeta(error),
|
|
1043
|
-
runId: maskRunId(completeParams.runId),
|
|
1044
|
-
childSessionKey: maskSessionKey(entry.childSessionKey)
|
|
1045
|
-
});
|
|
1046
|
-
}
|
|
1047
|
-
startSubagentAnnounceCleanupFlow(completeParams.runId, entry);
|
|
1048
|
-
};
|
|
1049
|
-
return {
|
|
1050
|
-
clearScheduledResumeTimers,
|
|
1051
|
-
completeCleanupBookkeeping,
|
|
1052
|
-
completeSubagentRun,
|
|
1053
|
-
finalizeResumedAnnounceGiveUp,
|
|
1054
|
-
refreshFrozenResultFromSession,
|
|
1055
|
-
startSubagentAnnounceCleanupFlow
|
|
1056
|
-
};
|
|
1057
|
-
}
|
|
1058
|
-
//#endregion
|
|
1059
|
-
//#region src/agents/subagent-registry-run-manager.ts
|
|
1060
|
-
const log$1 = createSubsystemLogger("agents/subagent-registry");
|
|
1061
|
-
const RECOVERABLE_WAIT_RETRY_DELAY_MS = process.env.DAOCORE_TEST_FAST === "1" ? 25 : 5e3;
|
|
1062
|
-
function shouldDeleteAttachments(entry) {
|
|
1063
|
-
return entry.cleanup === "delete" || !entry.retainAttachmentsOnKeep;
|
|
1064
|
-
}
|
|
1065
|
-
function markSubagentRunPausedAfterYield(params) {
|
|
1066
|
-
const { entry } = params;
|
|
1067
|
-
let mutated = false;
|
|
1068
|
-
if (typeof params.startedAt === "number" && entry.startedAt !== params.startedAt) {
|
|
1069
|
-
entry.startedAt = params.startedAt;
|
|
1070
|
-
if (typeof entry.sessionStartedAt !== "number") entry.sessionStartedAt = params.startedAt;
|
|
1071
|
-
mutated = true;
|
|
1072
|
-
}
|
|
1073
|
-
const endedAt = typeof params.endedAt === "number" ? params.endedAt : params.now ?? Date.now();
|
|
1074
|
-
if (entry.endedAt !== endedAt) {
|
|
1075
|
-
entry.endedAt = endedAt;
|
|
1076
|
-
mutated = true;
|
|
1077
|
-
}
|
|
1078
|
-
if (entry.pauseReason !== "sessions_yield") {
|
|
1079
|
-
entry.pauseReason = "sessions_yield";
|
|
1080
|
-
mutated = true;
|
|
1081
|
-
}
|
|
1082
|
-
if (entry.outcome !== void 0) {
|
|
1083
|
-
entry.outcome = void 0;
|
|
1084
|
-
mutated = true;
|
|
1085
|
-
}
|
|
1086
|
-
if (entry.endedReason !== void 0) {
|
|
1087
|
-
entry.endedReason = void 0;
|
|
1088
|
-
mutated = true;
|
|
1089
|
-
}
|
|
1090
|
-
if (entry.cleanupHandled === true) {
|
|
1091
|
-
entry.cleanupHandled = false;
|
|
1092
|
-
mutated = true;
|
|
1093
|
-
}
|
|
1094
|
-
if (entry.frozenResultText !== void 0) {
|
|
1095
|
-
entry.frozenResultText = void 0;
|
|
1096
|
-
entry.frozenResultCapturedAt = void 0;
|
|
1097
|
-
mutated = true;
|
|
1098
|
-
}
|
|
1099
|
-
return mutated;
|
|
1100
|
-
}
|
|
1101
|
-
function createSubagentRunManager(params) {
|
|
1102
|
-
const waitForSubagentCompletion = async (runId, waitTimeoutMs, expectedEntry) => {
|
|
1103
|
-
let completionForRetry;
|
|
1104
|
-
const scheduleWaitRetry = (entry, reason, error) => {
|
|
1105
|
-
params.scheduleOrphanRecovery({ delayMs: 1e3 });
|
|
1106
|
-
const scheduledEntry = entry;
|
|
1107
|
-
setTimeout(() => {
|
|
1108
|
-
const current = params.runs.get(runId);
|
|
1109
|
-
if (!current || current !== scheduledEntry || typeof current.endedAt === "number") return;
|
|
1110
|
-
waitForSubagentCompletion(runId, waitTimeoutMs, scheduledEntry);
|
|
1111
|
-
}, RECOVERABLE_WAIT_RETRY_DELAY_MS).unref?.();
|
|
1112
|
-
log$1.info(reason, {
|
|
1113
|
-
runId,
|
|
1114
|
-
childSessionKey: entry.childSessionKey,
|
|
1115
|
-
...error ? { error } : {}
|
|
1116
|
-
});
|
|
1117
|
-
};
|
|
1118
|
-
try {
|
|
1119
|
-
const wait = await waitForAgentRun({
|
|
1120
|
-
runId,
|
|
1121
|
-
timeoutMs: Math.max(1, Math.floor(waitTimeoutMs)),
|
|
1122
|
-
callGateway: params.callGateway
|
|
1123
|
-
});
|
|
1124
|
-
const entry = params.runs.get(runId);
|
|
1125
|
-
if (!entry || expectedEntry && entry !== expectedEntry) return;
|
|
1126
|
-
if (wait.status === "pending") return;
|
|
1127
|
-
const waitBlocked = isBlockedLivenessState(wait.livenessState);
|
|
1128
|
-
if (wait.yielded === true && !waitBlocked) {
|
|
1129
|
-
if (markSubagentRunPausedAfterYield({
|
|
1130
|
-
entry,
|
|
1131
|
-
startedAt: wait.startedAt,
|
|
1132
|
-
endedAt: wait.endedAt
|
|
1133
|
-
})) params.persist();
|
|
1134
|
-
return;
|
|
1135
|
-
}
|
|
1136
|
-
const waitStatus = waitBlocked ? "error" : wait.status;
|
|
1137
|
-
if (waitStatus === "error" && isRecoverableAgentWaitError(wait.error)) {
|
|
1138
|
-
scheduleWaitRetry(entry, "subagent wait interrupted; scheduling recovery", wait.error);
|
|
1139
|
-
return;
|
|
1140
|
-
}
|
|
1141
|
-
if (waitStatus === "timeout") {
|
|
1142
|
-
const isTerminalWaitTimeout = typeof wait.endedAt === "number" || typeof wait.stopReason === "string" || typeof wait.livenessState === "string";
|
|
1143
|
-
const completion = params.resolveSubagentSessionCompletion({
|
|
1144
|
-
childSessionKey: entry.childSessionKey,
|
|
1145
|
-
fallbackEndedAt: typeof wait.endedAt === "number" ? wait.endedAt : Date.now(),
|
|
1146
|
-
notBeforeMs: entry.startedAt ?? entry.createdAt
|
|
1147
|
-
});
|
|
1148
|
-
if (completion) {
|
|
1149
|
-
completionForRetry = {
|
|
1150
|
-
runId,
|
|
1151
|
-
endedAt: completion.endedAt,
|
|
1152
|
-
outcome: completion.outcome,
|
|
1153
|
-
reason: completion.reason,
|
|
1154
|
-
sendFarewell: true,
|
|
1155
|
-
accountId: entry.requesterOrigin?.accountId,
|
|
1156
|
-
triggerCleanup: true
|
|
1157
|
-
};
|
|
1158
|
-
await params.completeSubagentRun(completionForRetry);
|
|
1159
|
-
return;
|
|
1160
|
-
}
|
|
1161
|
-
if (isTerminalWaitTimeout) {
|
|
1162
|
-
completionForRetry = {
|
|
1163
|
-
runId,
|
|
1164
|
-
endedAt: wait.endedAt,
|
|
1165
|
-
outcome: { status: "timeout" },
|
|
1166
|
-
reason: SUBAGENT_ENDED_REASON_COMPLETE,
|
|
1167
|
-
sendFarewell: true,
|
|
1168
|
-
accountId: entry.requesterOrigin?.accountId,
|
|
1169
|
-
triggerCleanup: true
|
|
1170
|
-
};
|
|
1171
|
-
await params.completeSubagentRun(completionForRetry);
|
|
1172
|
-
return;
|
|
1173
|
-
}
|
|
1174
|
-
scheduleWaitRetry(entry, "subagent wait timed out; deferring terminal state until session reconciliation");
|
|
1175
|
-
return;
|
|
1176
|
-
}
|
|
1177
|
-
let mutated = false;
|
|
1178
|
-
if (typeof wait.startedAt === "number") {
|
|
1179
|
-
entry.startedAt = wait.startedAt;
|
|
1180
|
-
if (typeof entry.sessionStartedAt !== "number") entry.sessionStartedAt = wait.startedAt;
|
|
1181
|
-
mutated = true;
|
|
1182
|
-
}
|
|
1183
|
-
if (typeof wait.endedAt === "number") {
|
|
1184
|
-
entry.endedAt = wait.endedAt;
|
|
1185
|
-
mutated = true;
|
|
1186
|
-
}
|
|
1187
|
-
if (!entry.endedAt) {
|
|
1188
|
-
entry.endedAt = Date.now();
|
|
1189
|
-
mutated = true;
|
|
1190
|
-
}
|
|
1191
|
-
const rawWaitError = typeof wait.error === "string" ? wait.error : void 0;
|
|
1192
|
-
const waitError = waitBlocked ? formatBlockedLivenessError(rawWaitError) : rawWaitError;
|
|
1193
|
-
const outcome = withSubagentOutcomeTiming(waitStatus === "error" ? {
|
|
1194
|
-
status: "error",
|
|
1195
|
-
error: waitError
|
|
1196
|
-
} : { status: "ok" }, {
|
|
1197
|
-
startedAt: entry.startedAt,
|
|
1198
|
-
endedAt: entry.endedAt
|
|
1199
|
-
});
|
|
1200
|
-
if (shouldUpdateRunOutcome(entry.outcome, outcome)) {
|
|
1201
|
-
entry.outcome = outcome;
|
|
1202
|
-
mutated = true;
|
|
1203
|
-
}
|
|
1204
|
-
if (mutated) params.persist();
|
|
1205
|
-
completionForRetry = {
|
|
1206
|
-
runId,
|
|
1207
|
-
endedAt: entry.endedAt,
|
|
1208
|
-
outcome,
|
|
1209
|
-
reason: waitStatus === "error" ? SUBAGENT_ENDED_REASON_ERROR : SUBAGENT_ENDED_REASON_COMPLETE,
|
|
1210
|
-
sendFarewell: true,
|
|
1211
|
-
accountId: entry.requesterOrigin?.accountId,
|
|
1212
|
-
triggerCleanup: true
|
|
1213
|
-
};
|
|
1214
|
-
await params.completeSubagentRun(completionForRetry);
|
|
1215
|
-
} catch (error) {
|
|
1216
|
-
const current = params.runs.get(runId);
|
|
1217
|
-
log$1.warn("failed to complete subagent run; retrying completion", {
|
|
1218
|
-
runId,
|
|
1219
|
-
childSessionKey: current?.childSessionKey ?? expectedEntry?.childSessionKey,
|
|
1220
|
-
error
|
|
1221
|
-
});
|
|
1222
|
-
if (current && typeof current.endedAt === "number" && !current.cleanupCompletedAt && current.pauseReason !== "sessions_yield") {
|
|
1223
|
-
if (completionForRetry) try {
|
|
1224
|
-
await params.completeSubagentRun(completionForRetry);
|
|
1225
|
-
return;
|
|
1226
|
-
} catch (retryError) {
|
|
1227
|
-
log$1.warn("failed to complete subagent run after retry; retrying ended cleanup", {
|
|
1228
|
-
runId,
|
|
1229
|
-
childSessionKey: current.childSessionKey,
|
|
1230
|
-
error: retryError
|
|
1231
|
-
});
|
|
1232
|
-
}
|
|
1233
|
-
current.cleanupHandled = false;
|
|
1234
|
-
params.resumedRuns.delete(runId);
|
|
1235
|
-
params.resumeSubagentRun(runId);
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
};
|
|
1239
|
-
const markSubagentRunForSteerRestart = (runId) => {
|
|
1240
|
-
const key = runId.trim();
|
|
1241
|
-
if (!key) return false;
|
|
1242
|
-
const entry = params.runs.get(key);
|
|
1243
|
-
if (!entry) return false;
|
|
1244
|
-
if (entry.suppressAnnounceReason === "steer-restart") return true;
|
|
1245
|
-
entry.suppressAnnounceReason = "steer-restart";
|
|
1246
|
-
params.persist();
|
|
1247
|
-
return true;
|
|
1248
|
-
};
|
|
1249
|
-
const clearSubagentRunSteerRestart = (runId) => {
|
|
1250
|
-
const key = runId.trim();
|
|
1251
|
-
if (!key) return false;
|
|
1252
|
-
const entry = params.runs.get(key);
|
|
1253
|
-
if (!entry) return false;
|
|
1254
|
-
if (entry.suppressAnnounceReason !== "steer-restart") return true;
|
|
1255
|
-
entry.suppressAnnounceReason = void 0;
|
|
1256
|
-
params.persist();
|
|
1257
|
-
params.resumedRuns.delete(key);
|
|
1258
|
-
if (typeof entry.endedAt === "number" && !entry.cleanupCompletedAt) params.resumeSubagentRun(key);
|
|
1259
|
-
return true;
|
|
1260
|
-
};
|
|
1261
|
-
const replaceSubagentRunAfterSteer = (replaceParams) => {
|
|
1262
|
-
const previousRunId = replaceParams.previousRunId.trim();
|
|
1263
|
-
const nextRunId = replaceParams.nextRunId.trim();
|
|
1264
|
-
if (!previousRunId || !nextRunId) return false;
|
|
1265
|
-
const source = params.runs.get(previousRunId) ?? replaceParams.fallback;
|
|
1266
|
-
if (!source) return false;
|
|
1267
|
-
if (previousRunId !== nextRunId) {
|
|
1268
|
-
params.clearPendingLifecycleError(previousRunId);
|
|
1269
|
-
if (shouldDeleteAttachments(source)) safeRemoveAttachmentsDir(source);
|
|
1270
|
-
params.runs.delete(previousRunId);
|
|
1271
|
-
params.resumedRuns.delete(previousRunId);
|
|
1272
|
-
}
|
|
1273
|
-
const now = Date.now();
|
|
1274
|
-
const cfg = params.getRuntimeConfig();
|
|
1275
|
-
const archiveAfterMs = resolveArchiveAfterMs(cfg);
|
|
1276
|
-
const spawnMode = source.spawnMode === "session" ? "session" : "run";
|
|
1277
|
-
const archiveAtMs = spawnMode === "session" || source.cleanup === "keep" ? void 0 : archiveAfterMs ? now + archiveAfterMs : void 0;
|
|
1278
|
-
const runTimeoutSeconds = replaceParams.runTimeoutSeconds ?? source.runTimeoutSeconds ?? 0;
|
|
1279
|
-
const waitTimeoutMs = params.resolveSubagentWaitTimeoutMs(cfg, runTimeoutSeconds);
|
|
1280
|
-
const preserveFrozenResultFallback = replaceParams.preserveFrozenResultFallback === true;
|
|
1281
|
-
const sessionStartedAt = getSubagentSessionStartedAt(source) ?? now;
|
|
1282
|
-
const accumulatedRuntimeMs = getSubagentSessionRuntimeMs(source, typeof source.endedAt === "number" ? source.endedAt : now) ?? 0;
|
|
1283
|
-
const next = {
|
|
1284
|
-
...source,
|
|
1285
|
-
runId: nextRunId,
|
|
1286
|
-
createdAt: now,
|
|
1287
|
-
startedAt: now,
|
|
1288
|
-
sessionStartedAt,
|
|
1289
|
-
accumulatedRuntimeMs,
|
|
1290
|
-
endedAt: void 0,
|
|
1291
|
-
endedReason: void 0,
|
|
1292
|
-
pauseReason: void 0,
|
|
1293
|
-
endedHookEmittedAt: void 0,
|
|
1294
|
-
wakeOnDescendantSettle: void 0,
|
|
1295
|
-
outcome: void 0,
|
|
1296
|
-
frozenResultText: void 0,
|
|
1297
|
-
frozenResultCapturedAt: void 0,
|
|
1298
|
-
fallbackFrozenResultText: preserveFrozenResultFallback ? source.frozenResultText : void 0,
|
|
1299
|
-
fallbackFrozenResultCapturedAt: preserveFrozenResultFallback ? source.frozenResultCapturedAt : void 0,
|
|
1300
|
-
cleanupCompletedAt: void 0,
|
|
1301
|
-
cleanupHandled: false,
|
|
1302
|
-
completionEnqueuedAt: void 0,
|
|
1303
|
-
completionDeliveredAt: void 0,
|
|
1304
|
-
completionAnnouncedAt: void 0,
|
|
1305
|
-
lastAnnounceDropReason: void 0,
|
|
1306
|
-
suppressAnnounceReason: void 0,
|
|
1307
|
-
announceRetryCount: void 0,
|
|
1308
|
-
lastAnnounceRetryAt: void 0,
|
|
1309
|
-
lastAnnounceDeliveryError: void 0,
|
|
1310
|
-
pendingFinalDelivery: void 0,
|
|
1311
|
-
pendingFinalDeliveryCreatedAt: void 0,
|
|
1312
|
-
pendingFinalDeliveryLastAttemptAt: void 0,
|
|
1313
|
-
pendingFinalDeliveryAttemptCount: void 0,
|
|
1314
|
-
pendingFinalDeliveryLastError: void 0,
|
|
1315
|
-
pendingFinalDeliveryPayload: void 0,
|
|
1316
|
-
deliverySuspendedAt: void 0,
|
|
1317
|
-
deliverySuspendedReason: void 0,
|
|
1318
|
-
deliveryDiscardedAt: void 0,
|
|
1319
|
-
deliveryDiscardReason: void 0,
|
|
1320
|
-
deliveryDiscardedPayloadSummary: void 0,
|
|
1321
|
-
spawnMode,
|
|
1322
|
-
archiveAtMs,
|
|
1323
|
-
runTimeoutSeconds
|
|
1324
|
-
};
|
|
1325
|
-
params.runs.set(nextRunId, next);
|
|
1326
|
-
params.ensureListener();
|
|
1327
|
-
params.persist();
|
|
1328
|
-
params.startSweeper();
|
|
1329
|
-
waitForSubagentCompletion(nextRunId, waitTimeoutMs, next);
|
|
1330
|
-
return true;
|
|
1331
|
-
};
|
|
1332
|
-
const registerSubagentRun = (registerParams) => {
|
|
1333
|
-
const runId = registerParams.runId.trim();
|
|
1334
|
-
const childSessionKey = registerParams.childSessionKey.trim();
|
|
1335
|
-
const requesterSessionKey = registerParams.requesterSessionKey.trim();
|
|
1336
|
-
const controllerSessionKey = registerParams.controllerSessionKey?.trim() || requesterSessionKey;
|
|
1337
|
-
if (!runId || !childSessionKey || !requesterSessionKey) return;
|
|
1338
|
-
const now = Date.now();
|
|
1339
|
-
const cfg = params.getRuntimeConfig();
|
|
1340
|
-
const archiveAfterMs = resolveArchiveAfterMs(cfg);
|
|
1341
|
-
const spawnMode = registerParams.spawnMode === "session" ? "session" : "run";
|
|
1342
|
-
const archiveAtMs = spawnMode === "session" || registerParams.cleanup === "keep" ? void 0 : archiveAfterMs ? now + archiveAfterMs : void 0;
|
|
1343
|
-
const runTimeoutSeconds = registerParams.runTimeoutSeconds ?? 0;
|
|
1344
|
-
const waitTimeoutMs = params.resolveSubagentWaitTimeoutMs(cfg, runTimeoutSeconds);
|
|
1345
|
-
const requesterOrigin = normalizeDeliveryContext(registerParams.requesterOrigin);
|
|
1346
|
-
const entry = {
|
|
1347
|
-
runId,
|
|
1348
|
-
childSessionKey,
|
|
1349
|
-
controllerSessionKey,
|
|
1350
|
-
requesterSessionKey,
|
|
1351
|
-
requesterOrigin,
|
|
1352
|
-
requesterDisplayKey: registerParams.requesterDisplayKey,
|
|
1353
|
-
task: registerParams.task,
|
|
1354
|
-
taskName: registerParams.taskName,
|
|
1355
|
-
cleanup: registerParams.cleanup,
|
|
1356
|
-
expectsCompletionMessage: registerParams.expectsCompletionMessage,
|
|
1357
|
-
spawnMode,
|
|
1358
|
-
label: registerParams.label,
|
|
1359
|
-
model: registerParams.model,
|
|
1360
|
-
agentDir: registerParams.agentDir,
|
|
1361
|
-
workspaceDir: registerParams.workspaceDir,
|
|
1362
|
-
runTimeoutSeconds,
|
|
1363
|
-
createdAt: now,
|
|
1364
|
-
startedAt: now,
|
|
1365
|
-
sessionStartedAt: now,
|
|
1366
|
-
accumulatedRuntimeMs: 0,
|
|
1367
|
-
archiveAtMs,
|
|
1368
|
-
cleanupHandled: false,
|
|
1369
|
-
completionAnnouncedAt: void 0,
|
|
1370
|
-
wakeOnDescendantSettle: void 0,
|
|
1371
|
-
attachmentsDir: registerParams.attachmentsDir,
|
|
1372
|
-
attachmentsRootDir: registerParams.attachmentsRootDir,
|
|
1373
|
-
retainAttachmentsOnKeep: registerParams.retainAttachmentsOnKeep
|
|
1374
|
-
};
|
|
1375
|
-
params.runs.set(runId, entry);
|
|
1376
|
-
try {
|
|
1377
|
-
params.persistOrThrow();
|
|
1378
|
-
} catch (error) {
|
|
1379
|
-
params.runs.delete(runId);
|
|
1380
|
-
throw error;
|
|
1381
|
-
}
|
|
1382
|
-
try {
|
|
1383
|
-
createRunningTaskRun({
|
|
1384
|
-
runtime: "subagent",
|
|
1385
|
-
sourceId: runId,
|
|
1386
|
-
ownerKey: requesterSessionKey,
|
|
1387
|
-
scopeKind: "session",
|
|
1388
|
-
requesterOrigin,
|
|
1389
|
-
childSessionKey,
|
|
1390
|
-
runId,
|
|
1391
|
-
label: registerParams.label,
|
|
1392
|
-
task: registerParams.task,
|
|
1393
|
-
deliveryStatus: registerParams.expectsCompletionMessage === false ? "not_applicable" : "pending",
|
|
1394
|
-
startedAt: now,
|
|
1395
|
-
lastEventAt: now
|
|
1396
|
-
});
|
|
1397
|
-
} catch (error) {
|
|
1398
|
-
log$1.warn("Failed to create background task for subagent run", {
|
|
1399
|
-
runId: registerParams.runId,
|
|
1400
|
-
error
|
|
1401
|
-
});
|
|
1402
|
-
}
|
|
1403
|
-
params.ensureListener();
|
|
1404
|
-
params.persist();
|
|
1405
|
-
params.startSweeper();
|
|
1406
|
-
waitForSubagentCompletion(runId, waitTimeoutMs, entry);
|
|
1407
|
-
};
|
|
1408
|
-
const releaseSubagentRun = (runId) => {
|
|
1409
|
-
params.clearPendingLifecycleError(runId);
|
|
1410
|
-
const entry = params.runs.get(runId);
|
|
1411
|
-
if (entry) {
|
|
1412
|
-
if (shouldDeleteAttachments(entry)) safeRemoveAttachmentsDir(entry);
|
|
1413
|
-
params.notifyContextEngineSubagentEnded({
|
|
1414
|
-
childSessionKey: entry.childSessionKey,
|
|
1415
|
-
reason: "released",
|
|
1416
|
-
agentDir: entry.agentDir,
|
|
1417
|
-
workspaceDir: entry.workspaceDir
|
|
1418
|
-
});
|
|
1419
|
-
}
|
|
1420
|
-
if (params.runs.delete(runId)) params.persist();
|
|
1421
|
-
if (params.runs.size === 0) params.stopSweeper();
|
|
1422
|
-
};
|
|
1423
|
-
const markSubagentRunTerminated = (markParams) => {
|
|
1424
|
-
const runIds = /* @__PURE__ */ new Set();
|
|
1425
|
-
if (typeof markParams.runId === "string" && markParams.runId.trim()) runIds.add(markParams.runId.trim());
|
|
1426
|
-
if (typeof markParams.childSessionKey === "string" && markParams.childSessionKey.trim()) {
|
|
1427
|
-
for (const [runId, entry] of params.runs.entries()) if (entry.childSessionKey === markParams.childSessionKey.trim()) runIds.add(runId);
|
|
1428
|
-
}
|
|
1429
|
-
if (runIds.size === 0) return 0;
|
|
1430
|
-
const now = Date.now();
|
|
1431
|
-
const reason = markParams.reason?.trim() || "killed";
|
|
1432
|
-
let updated = 0;
|
|
1433
|
-
const entriesByChildSessionKey = /* @__PURE__ */ new Map();
|
|
1434
|
-
for (const runId of runIds) {
|
|
1435
|
-
params.clearPendingLifecycleError(runId);
|
|
1436
|
-
const entry = params.runs.get(runId);
|
|
1437
|
-
if (!entry) continue;
|
|
1438
|
-
if (typeof entry.endedAt === "number") continue;
|
|
1439
|
-
entry.endedAt = now;
|
|
1440
|
-
entry.outcome = withSubagentOutcomeTiming({
|
|
1441
|
-
status: "error",
|
|
1442
|
-
error: reason
|
|
1443
|
-
}, {
|
|
1444
|
-
startedAt: entry.startedAt,
|
|
1445
|
-
endedAt: now
|
|
1446
|
-
});
|
|
1447
|
-
entry.endedReason = SUBAGENT_ENDED_REASON_KILLED;
|
|
1448
|
-
entry.cleanupHandled = true;
|
|
1449
|
-
entry.cleanupCompletedAt = now;
|
|
1450
|
-
entry.suppressAnnounceReason = "killed";
|
|
1451
|
-
if (!entriesByChildSessionKey.has(entry.childSessionKey)) entriesByChildSessionKey.set(entry.childSessionKey, entry);
|
|
1452
|
-
updated += 1;
|
|
1453
|
-
}
|
|
1454
|
-
if (updated > 0) {
|
|
1455
|
-
params.persist();
|
|
1456
|
-
for (const entry of entriesByChildSessionKey.values()) {
|
|
1457
|
-
const emitEndedHook = () => emitSubagentEndedHookOnce({
|
|
1458
|
-
entry,
|
|
1459
|
-
reason: SUBAGENT_ENDED_REASON_KILLED,
|
|
1460
|
-
sendFarewell: true,
|
|
1461
|
-
accountId: entry.requesterOrigin?.accountId,
|
|
1462
|
-
outcome: SUBAGENT_ENDED_OUTCOME_KILLED,
|
|
1463
|
-
error: reason,
|
|
1464
|
-
inFlightRunIds: params.endedHookInFlightRunIds,
|
|
1465
|
-
persist: () => params.persist()
|
|
1466
|
-
});
|
|
1467
|
-
persistSubagentSessionTiming(entry).catch((err) => {
|
|
1468
|
-
log$1.warn("failed to persist killed subagent session timing", {
|
|
1469
|
-
err,
|
|
1470
|
-
runId: entry.runId,
|
|
1471
|
-
childSessionKey: entry.childSessionKey
|
|
1472
|
-
});
|
|
1473
|
-
});
|
|
1474
|
-
if (shouldDeleteAttachments(entry)) safeRemoveAttachmentsDir(entry);
|
|
1475
|
-
params.completeCleanupBookkeeping({
|
|
1476
|
-
runId: entry.runId,
|
|
1477
|
-
entry,
|
|
1478
|
-
cleanup: entry.cleanup,
|
|
1479
|
-
completedAt: now
|
|
1480
|
-
});
|
|
1481
|
-
if (getGlobalHookRunner()) {
|
|
1482
|
-
emitEndedHook().catch(() => {});
|
|
1483
|
-
continue;
|
|
1484
|
-
}
|
|
1485
|
-
const cfg = params.getRuntimeConfig();
|
|
1486
|
-
Promise.resolve(params.ensureRuntimePluginsLoaded({
|
|
1487
|
-
config: cfg,
|
|
1488
|
-
workspaceDir: entry.workspaceDir,
|
|
1489
|
-
allowGatewaySubagentBinding: true
|
|
1490
|
-
})).then(emitEndedHook).catch(() => {});
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
return updated;
|
|
1494
|
-
};
|
|
1495
|
-
return {
|
|
1496
|
-
clearSubagentRunSteerRestart,
|
|
1497
|
-
markSubagentRunForSteerRestart,
|
|
1498
|
-
markSubagentRunTerminated,
|
|
1499
|
-
registerSubagentRun,
|
|
1500
|
-
releaseSubagentRun,
|
|
1501
|
-
replaceSubagentRunAfterSteer,
|
|
1502
|
-
waitForSubagentCompletion
|
|
1503
|
-
};
|
|
1504
|
-
}
|
|
1505
|
-
//#endregion
|
|
1506
|
-
//#region src/agents/subagent-session-reconciliation.ts
|
|
1507
|
-
function finiteTimestamp(value) {
|
|
1508
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1509
|
-
}
|
|
1510
|
-
function terminalSessionTimestamp(sessionEntry) {
|
|
1511
|
-
return finiteTimestamp(sessionEntry?.endedAt) ?? finiteTimestamp(sessionEntry?.updatedAt);
|
|
1512
|
-
}
|
|
1513
|
-
function isFreshForRun(sessionEntry, notBeforeMs) {
|
|
1514
|
-
if (notBeforeMs === void 0) return true;
|
|
1515
|
-
const terminalAt = terminalSessionTimestamp(sessionEntry);
|
|
1516
|
-
return terminalAt !== void 0 && terminalAt >= notBeforeMs;
|
|
1517
|
-
}
|
|
1518
|
-
function findSessionEntryByKey(store, sessionKey) {
|
|
1519
|
-
const direct = store[sessionKey];
|
|
1520
|
-
if (direct) return direct;
|
|
1521
|
-
const normalized = sessionKey.trim().toLowerCase();
|
|
1522
|
-
for (const [key, entry] of Object.entries(store)) if (key.trim().toLowerCase() === normalized) return entry;
|
|
1523
|
-
}
|
|
1524
|
-
function loadSubagentSessionEntry(params) {
|
|
1525
|
-
const key = params.childSessionKey.trim();
|
|
1526
|
-
if (!key) return;
|
|
1527
|
-
const agentId = resolveAgentIdFromSessionKey(key);
|
|
1528
|
-
const storePath = resolveStorePath((params.cfg ?? getRuntimeConfig()).session?.store, { agentId });
|
|
1529
|
-
let store = params.storeCache?.get(storePath);
|
|
1530
|
-
if (!store) {
|
|
1531
|
-
store = loadSessionStore(storePath);
|
|
1532
|
-
params.storeCache?.set(storePath, store);
|
|
1533
|
-
}
|
|
1534
|
-
return findSessionEntryByKey(store, key);
|
|
1535
|
-
}
|
|
1536
|
-
function resolveCompletionFromSessionEntry(sessionEntry, fallbackEndedAt, opts) {
|
|
1537
|
-
const status = sessionEntry?.status;
|
|
1538
|
-
const endedAt = finiteTimestamp(sessionEntry?.endedAt) ?? finiteTimestamp(sessionEntry?.updatedAt) ?? fallbackEndedAt;
|
|
1539
|
-
if (status === "done") {
|
|
1540
|
-
if (!isFreshForRun(sessionEntry, opts?.notBeforeMs)) return null;
|
|
1541
|
-
return {
|
|
1542
|
-
endedAt,
|
|
1543
|
-
outcome: { status: "ok" },
|
|
1544
|
-
reason: SUBAGENT_ENDED_REASON_COMPLETE
|
|
1545
|
-
};
|
|
1546
|
-
}
|
|
1547
|
-
if (status === "timeout") {
|
|
1548
|
-
if (!isFreshForRun(sessionEntry, opts?.notBeforeMs)) return null;
|
|
1549
|
-
return {
|
|
1550
|
-
endedAt,
|
|
1551
|
-
outcome: { status: "timeout" },
|
|
1552
|
-
reason: SUBAGENT_ENDED_REASON_COMPLETE
|
|
1553
|
-
};
|
|
1554
|
-
}
|
|
1555
|
-
if (status === "failed") {
|
|
1556
|
-
if (!isFreshForRun(sessionEntry, opts?.notBeforeMs)) return null;
|
|
1557
|
-
return {
|
|
1558
|
-
endedAt,
|
|
1559
|
-
outcome: {
|
|
1560
|
-
status: "error",
|
|
1561
|
-
error: "session completed before registry settled"
|
|
1562
|
-
},
|
|
1563
|
-
reason: SUBAGENT_ENDED_REASON_ERROR
|
|
1564
|
-
};
|
|
1565
|
-
}
|
|
1566
|
-
if (status === "killed") {
|
|
1567
|
-
if (!isFreshForRun(sessionEntry, opts?.notBeforeMs)) return null;
|
|
1568
|
-
return {
|
|
1569
|
-
endedAt,
|
|
1570
|
-
outcome: {
|
|
1571
|
-
status: "error",
|
|
1572
|
-
error: "subagent run terminated"
|
|
1573
|
-
},
|
|
1574
|
-
reason: SUBAGENT_ENDED_REASON_KILLED
|
|
1575
|
-
};
|
|
1576
|
-
}
|
|
1577
|
-
if (status !== "running" && typeof sessionEntry?.endedAt === "number") {
|
|
1578
|
-
if (!isFreshForRun(sessionEntry, opts?.notBeforeMs)) return null;
|
|
1579
|
-
return {
|
|
1580
|
-
endedAt,
|
|
1581
|
-
outcome: { status: "ok" },
|
|
1582
|
-
reason: SUBAGENT_ENDED_REASON_COMPLETE
|
|
1583
|
-
};
|
|
1584
|
-
}
|
|
1585
|
-
return null;
|
|
1586
|
-
}
|
|
1587
|
-
function resolveSubagentSessionCompletion(params) {
|
|
1588
|
-
return resolveCompletionFromSessionEntry(loadSubagentSessionEntry({
|
|
1589
|
-
childSessionKey: params.childSessionKey,
|
|
1590
|
-
storeCache: params.storeCache,
|
|
1591
|
-
cfg: params.cfg
|
|
1592
|
-
}), params.fallbackEndedAt, { notBeforeMs: params.notBeforeMs });
|
|
1593
|
-
}
|
|
1594
|
-
//#endregion
|
|
1595
|
-
//#region src/agents/subagent-registry-maintenance.ts
|
|
1596
|
-
function isCleanupCompleteForMaintenance(entry) {
|
|
1597
|
-
return typeof entry.cleanupCompletedAt === "number";
|
|
1598
|
-
}
|
|
1599
|
-
function isActiveForMaintenance(entry) {
|
|
1600
|
-
return typeof entry.endedAt !== "number";
|
|
1601
|
-
}
|
|
1602
|
-
function isPendingFinalDeliveryForMaintenance(entry) {
|
|
1603
|
-
return entry.pendingFinalDelivery === true;
|
|
1604
|
-
}
|
|
1605
|
-
function isAwaitingCompletionAnnounceForMaintenance(entry) {
|
|
1606
|
-
return entry.expectsCompletionMessage === true && typeof entry.completionAnnouncedAt !== "number";
|
|
1607
|
-
}
|
|
1608
|
-
function shouldPreserveForMaintenance(entry) {
|
|
1609
|
-
if (isCleanupCompleteForMaintenance(entry)) return false;
|
|
1610
|
-
if (isActiveForMaintenance(entry)) return true;
|
|
1611
|
-
return isAwaitingCompletionAnnounceForMaintenance(entry) || isPendingFinalDeliveryForMaintenance(entry);
|
|
1612
|
-
}
|
|
1613
|
-
function listSessionMaintenanceProtectedSubagentSessionKeys() {
|
|
1614
|
-
const keys = /* @__PURE__ */ new Set();
|
|
1615
|
-
for (const entry of getSubagentRunsSnapshotForRead(subagentRuns).values()) {
|
|
1616
|
-
if (!shouldPreserveForMaintenance(entry)) continue;
|
|
1617
|
-
const childSessionKey = entry.childSessionKey.trim();
|
|
1618
|
-
if (childSessionKey) keys.add(childSessionKey);
|
|
1619
|
-
}
|
|
1620
|
-
return [...keys];
|
|
1621
|
-
}
|
|
1622
|
-
registerSessionMaintenancePreserveKeysProvider(listSessionMaintenanceProtectedSubagentSessionKeys);
|
|
1623
|
-
//#endregion
|
|
1624
|
-
//#region src/agents/subagent-registry.ts
|
|
1625
|
-
const log = createSubsystemLogger("agents/subagent-registry");
|
|
1626
|
-
const subagentAnnounceLoader = createLazyImportLoader(() => import("./subagent-announce-BCo0VHVL.js"));
|
|
1627
|
-
const browserCleanupLoader = createLazyImportLoader(() => import("./browser-lifecycle-cleanup-C9X09Vrg.js"));
|
|
1628
|
-
async function loadSubagentAnnounceModule() {
|
|
1629
|
-
return await subagentAnnounceLoader.load();
|
|
1630
|
-
}
|
|
1631
|
-
async function loadCleanupBrowserSessionsForLifecycleEnd() {
|
|
1632
|
-
return (await browserCleanupLoader.load()).cleanupBrowserSessionsForLifecycleEnd;
|
|
1633
|
-
}
|
|
1634
|
-
let subagentRegistryDeps = {
|
|
1635
|
-
callGateway,
|
|
1636
|
-
captureSubagentCompletionReply: async (sessionKey, options) => (await loadSubagentAnnounceModule()).captureSubagentCompletionReply(sessionKey, options),
|
|
1637
|
-
cleanupBrowserSessionsForLifecycleEnd: async (params) => (await loadCleanupBrowserSessionsForLifecycleEnd())(params),
|
|
1638
|
-
getSubagentRunsSnapshotForRead,
|
|
1639
|
-
getRuntimeConfig,
|
|
1640
|
-
onAgentEvent,
|
|
1641
|
-
persistSubagentRunsToDisk,
|
|
1642
|
-
persistSubagentRunsToDiskOrThrow,
|
|
1643
|
-
resolveAgentTimeoutMs,
|
|
1644
|
-
restoreSubagentRunsFromDisk,
|
|
1645
|
-
runSubagentAnnounceFlow: async (params) => (await loadSubagentAnnounceModule()).runSubagentAnnounceFlow(params)
|
|
1646
|
-
};
|
|
1647
|
-
const SUBAGENT_REGISTRY_RUNTIME_SPEC = ["./subagent-registry.runtime", ".js"];
|
|
1648
|
-
const contextEngineInitLoader = createLazyPromiseLoader(() => importRuntimeModule(import.meta.url, SUBAGENT_REGISTRY_RUNTIME_SPEC));
|
|
1649
|
-
const contextEngineRegistryLoader = createLazyPromiseLoader(() => importRuntimeModule(import.meta.url, SUBAGENT_REGISTRY_RUNTIME_SPEC));
|
|
1650
|
-
const runtimePluginsLoader = createLazyPromiseLoader(() => importRuntimeModule(import.meta.url, SUBAGENT_REGISTRY_RUNTIME_SPEC));
|
|
1651
|
-
let sweeper = null;
|
|
1652
|
-
const resumeRetryTimers = /* @__PURE__ */ new Set();
|
|
1653
|
-
let sweepInProgress = false;
|
|
1654
|
-
let listenerStarted = false;
|
|
1655
|
-
let restoreAttempted = false;
|
|
1656
|
-
const ORPHAN_RECOVERY_DEBOUNCE_MS = 1e3;
|
|
1657
|
-
let lastOrphanRecoveryScheduleAt = 0;
|
|
1658
|
-
const SUBAGENT_ANNOUNCE_TIMEOUT_MS = 12e4;
|
|
1659
|
-
/**
|
|
1660
|
-
* Embedded runs can emit transient lifecycle `error` events while provider/model
|
|
1661
|
-
* retry is still in progress. Defer terminal error cleanup briefly so a
|
|
1662
|
-
* subsequent lifecycle `start` / `end` can cancel premature failure announces.
|
|
1663
|
-
*/
|
|
1664
|
-
const LIFECYCLE_ERROR_RETRY_GRACE_MS = 15e3;
|
|
1665
|
-
/**
|
|
1666
|
-
* Embedded runs can also surface an intermediate lifecycle `end` with
|
|
1667
|
-
* `aborted=true` just before the runtime automatically retries the same run.
|
|
1668
|
-
* Give that timeout a short grace window so the parent does not get a stale
|
|
1669
|
-
* `timed out` completion right before the eventual success.
|
|
1670
|
-
*/
|
|
1671
|
-
const LIFECYCLE_TIMEOUT_RETRY_GRACE_MS = 15e3;
|
|
1672
|
-
/** Absolute TTL for session-mode runs after cleanup completes (no archiveAtMs). */
|
|
1673
|
-
const SESSION_RUN_TTL_MS = 5 * 6e4;
|
|
1674
|
-
/** Absolute TTL for orphaned pendingLifecycleError / pendingLifecycleTimeout entries. */
|
|
1675
|
-
const PENDING_LIFECYCLE_TERMINAL_TTL_MS = 5 * 6e4;
|
|
1676
|
-
/** Grace period before treating a "running" subagent without a live run context as stale. */
|
|
1677
|
-
const STALE_ACTIVE_SUBAGENT_GRACE_MS = process.env.DAOCORE_TEST_FAST === "1" ? 1e3 : 6e4;
|
|
1678
|
-
const SUSPENDED_DELIVERY_CRON_EXPIRY_MS = 120 * 6e4;
|
|
1679
|
-
const SUSPENDED_DELIVERY_SUBAGENT_EXPIRY_MS = 360 * 6e4;
|
|
1680
|
-
const SUSPENDED_DELIVERY_INTERACTIVE_EXPIRY_MS = 1440 * 6e4;
|
|
1681
|
-
const SUSPENDED_DELIVERY_SOFT_CAP = 25;
|
|
1682
|
-
const SUSPENDED_DELIVERY_HARD_CAP = 50;
|
|
1683
|
-
const SUSPENDED_DELIVERY_PRESSURE_TARGET = 10;
|
|
1684
|
-
function loadContextEngineInitModule() {
|
|
1685
|
-
return contextEngineInitLoader.load();
|
|
1686
|
-
}
|
|
1687
|
-
function loadContextEngineRegistryModule() {
|
|
1688
|
-
return contextEngineRegistryLoader.load();
|
|
1689
|
-
}
|
|
1690
|
-
function loadRuntimePluginsModule() {
|
|
1691
|
-
return runtimePluginsLoader.load();
|
|
1692
|
-
}
|
|
1693
|
-
async function ensureSubagentRegistryPluginRuntimeLoaded(params) {
|
|
1694
|
-
const ensureRuntimePluginsLoaded = subagentRegistryDeps.ensureRuntimePluginsLoaded;
|
|
1695
|
-
if (ensureRuntimePluginsLoaded) {
|
|
1696
|
-
ensureRuntimePluginsLoaded(params);
|
|
1697
|
-
return;
|
|
1698
|
-
}
|
|
1699
|
-
(await loadRuntimePluginsModule()).ensureRuntimePluginsLoaded(params);
|
|
1700
|
-
}
|
|
1701
|
-
async function resolveSubagentRegistryContextEngine(cfg, options) {
|
|
1702
|
-
const initModule = await loadContextEngineInitModule();
|
|
1703
|
-
const registryModule = await loadContextEngineRegistryModule();
|
|
1704
|
-
const ensureContextEnginesInitialized = subagentRegistryDeps.ensureContextEnginesInitialized ?? initModule.ensureContextEnginesInitialized;
|
|
1705
|
-
const resolveContextEngine = subagentRegistryDeps.resolveContextEngine ?? registryModule.resolveContextEngine;
|
|
1706
|
-
ensureContextEnginesInitialized();
|
|
1707
|
-
return await resolveContextEngine(cfg, options);
|
|
1708
|
-
}
|
|
1709
|
-
function persistSubagentRuns() {
|
|
1710
|
-
subagentRegistryDeps.persistSubagentRunsToDisk(subagentRuns);
|
|
1711
|
-
}
|
|
1712
|
-
function persistSubagentRunsOrThrow() {
|
|
1713
|
-
subagentRegistryDeps.persistSubagentRunsToDiskOrThrow(subagentRuns);
|
|
1714
|
-
}
|
|
1715
|
-
function scheduleSubagentOrphanRecovery(params) {
|
|
1716
|
-
const now = Date.now();
|
|
1717
|
-
if (now - lastOrphanRecoveryScheduleAt < ORPHAN_RECOVERY_DEBOUNCE_MS) return;
|
|
1718
|
-
lastOrphanRecoveryScheduleAt = now;
|
|
1719
|
-
import("./subagent-orphan-recovery-D79ZzwKN.js").then(({ scheduleOrphanRecovery }) => {
|
|
1720
|
-
scheduleOrphanRecovery({
|
|
1721
|
-
getActiveRuns: () => subagentRuns,
|
|
1722
|
-
delayMs: params?.delayMs,
|
|
1723
|
-
maxRetries: params?.maxRetries
|
|
1724
|
-
});
|
|
1725
|
-
}, () => {});
|
|
1726
|
-
}
|
|
1727
|
-
const resumedRuns = /* @__PURE__ */ new Set();
|
|
1728
|
-
const endedHookInFlightRunIds = /* @__PURE__ */ new Set();
|
|
1729
|
-
const pendingLifecycleErrorByRunId = /* @__PURE__ */ new Map();
|
|
1730
|
-
const pendingLifecycleTimeoutByRunId = /* @__PURE__ */ new Map();
|
|
1731
|
-
function clearPendingLifecycleError(runId) {
|
|
1732
|
-
const pending = pendingLifecycleErrorByRunId.get(runId);
|
|
1733
|
-
if (!pending) return;
|
|
1734
|
-
clearTimeout(pending.timer);
|
|
1735
|
-
pendingLifecycleErrorByRunId.delete(runId);
|
|
1736
|
-
}
|
|
1737
|
-
function clearPendingLifecycleTimeout(runId) {
|
|
1738
|
-
const pending = pendingLifecycleTimeoutByRunId.get(runId);
|
|
1739
|
-
if (!pending) return;
|
|
1740
|
-
clearTimeout(pending.timer);
|
|
1741
|
-
pendingLifecycleTimeoutByRunId.delete(runId);
|
|
1742
|
-
}
|
|
1743
|
-
function schedulePendingLifecycleError(params) {
|
|
1744
|
-
clearPendingLifecycleTimeout(params.runId);
|
|
1745
|
-
clearPendingLifecycleError(params.runId);
|
|
1746
|
-
const timer = setTimeout(() => {
|
|
1747
|
-
const pending = pendingLifecycleErrorByRunId.get(params.runId);
|
|
1748
|
-
if (!pending || pending.timer !== timer) return;
|
|
1749
|
-
pendingLifecycleErrorByRunId.delete(params.runId);
|
|
1750
|
-
const entry = subagentRuns.get(params.runId);
|
|
1751
|
-
if (!entry) return;
|
|
1752
|
-
if (entry.endedReason === "subagent-complete" || entry.outcome?.status === "ok") return;
|
|
1753
|
-
completeSubagentRun({
|
|
1754
|
-
runId: params.runId,
|
|
1755
|
-
endedAt: pending.endedAt,
|
|
1756
|
-
outcome: {
|
|
1757
|
-
status: "error",
|
|
1758
|
-
error: pending.error
|
|
1759
|
-
},
|
|
1760
|
-
reason: SUBAGENT_ENDED_REASON_ERROR,
|
|
1761
|
-
sendFarewell: true,
|
|
1762
|
-
accountId: entry.requesterOrigin?.accountId,
|
|
1763
|
-
triggerCleanup: true
|
|
1764
|
-
});
|
|
1765
|
-
}, LIFECYCLE_ERROR_RETRY_GRACE_MS);
|
|
1766
|
-
timer.unref?.();
|
|
1767
|
-
pendingLifecycleErrorByRunId.set(params.runId, {
|
|
1768
|
-
timer,
|
|
1769
|
-
endedAt: params.endedAt,
|
|
1770
|
-
error: params.error
|
|
1771
|
-
});
|
|
1772
|
-
}
|
|
1773
|
-
function schedulePendingLifecycleTimeout(params) {
|
|
1774
|
-
clearPendingLifecycleError(params.runId);
|
|
1775
|
-
clearPendingLifecycleTimeout(params.runId);
|
|
1776
|
-
const timer = setTimeout(() => {
|
|
1777
|
-
const pending = pendingLifecycleTimeoutByRunId.get(params.runId);
|
|
1778
|
-
if (!pending || pending.timer !== timer) return;
|
|
1779
|
-
pendingLifecycleTimeoutByRunId.delete(params.runId);
|
|
1780
|
-
const entry = subagentRuns.get(params.runId);
|
|
1781
|
-
if (!entry) return;
|
|
1782
|
-
if (entry.outcome?.status === "ok") return;
|
|
1783
|
-
completeSubagentRun({
|
|
1784
|
-
runId: params.runId,
|
|
1785
|
-
endedAt: pending.endedAt,
|
|
1786
|
-
outcome: { status: "timeout" },
|
|
1787
|
-
reason: SUBAGENT_ENDED_REASON_COMPLETE,
|
|
1788
|
-
sendFarewell: true,
|
|
1789
|
-
accountId: entry.requesterOrigin?.accountId,
|
|
1790
|
-
triggerCleanup: true
|
|
1791
|
-
});
|
|
1792
|
-
}, LIFECYCLE_TIMEOUT_RETRY_GRACE_MS);
|
|
1793
|
-
timer.unref?.();
|
|
1794
|
-
pendingLifecycleTimeoutByRunId.set(params.runId, {
|
|
1795
|
-
timer,
|
|
1796
|
-
endedAt: params.endedAt
|
|
1797
|
-
});
|
|
1798
|
-
}
|
|
1799
|
-
async function notifyContextEngineSubagentEnded(params) {
|
|
1800
|
-
try {
|
|
1801
|
-
const cfg = subagentRegistryDeps.getRuntimeConfig();
|
|
1802
|
-
await ensureSubagentRegistryPluginRuntimeLoaded({
|
|
1803
|
-
config: cfg,
|
|
1804
|
-
workspaceDir: params.workspaceDir,
|
|
1805
|
-
allowGatewaySubagentBinding: true
|
|
1806
|
-
});
|
|
1807
|
-
const engine = await resolveSubagentRegistryContextEngine(cfg, {
|
|
1808
|
-
agentDir: params.agentDir,
|
|
1809
|
-
workspaceDir: params.workspaceDir
|
|
1810
|
-
});
|
|
1811
|
-
if (!engine.onSubagentEnded) return;
|
|
1812
|
-
await engine.onSubagentEnded(params);
|
|
1813
|
-
} catch (err) {
|
|
1814
|
-
log.warn("context-engine onSubagentEnded failed (best-effort)", { err });
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
|
-
function suppressAnnounceForSteerRestart(entry) {
|
|
1818
|
-
return entry?.suppressAnnounceReason === "steer-restart";
|
|
1819
|
-
}
|
|
1820
|
-
function shouldKeepThreadBindingAfterRun(params) {
|
|
1821
|
-
if (params.reason === "subagent-killed") return false;
|
|
1822
|
-
return params.entry.spawnMode === "session";
|
|
1823
|
-
}
|
|
1824
|
-
function shouldEmitEndedHookForRun(params) {
|
|
1825
|
-
return !shouldKeepThreadBindingAfterRun(params);
|
|
1826
|
-
}
|
|
1827
|
-
async function emitSubagentEndedHookForRun(params) {
|
|
1828
|
-
if (params.entry.endedHookEmittedAt) return;
|
|
1829
|
-
await ensureSubagentRegistryPluginRuntimeLoaded({
|
|
1830
|
-
config: subagentRegistryDeps.getRuntimeConfig(),
|
|
1831
|
-
workspaceDir: params.entry.workspaceDir,
|
|
1832
|
-
allowGatewaySubagentBinding: true
|
|
1833
|
-
});
|
|
1834
|
-
const reason = params.reason ?? params.entry.endedReason ?? "subagent-complete";
|
|
1835
|
-
const outcome = resolveLifecycleOutcomeFromRunOutcome(params.entry.outcome);
|
|
1836
|
-
const error = params.entry.outcome?.status === "error" ? params.entry.outcome.error : void 0;
|
|
1837
|
-
await emitSubagentEndedHookOnce({
|
|
1838
|
-
entry: params.entry,
|
|
1839
|
-
reason,
|
|
1840
|
-
sendFarewell: params.sendFarewell,
|
|
1841
|
-
accountId: params.accountId ?? params.entry.requesterOrigin?.accountId,
|
|
1842
|
-
outcome,
|
|
1843
|
-
error,
|
|
1844
|
-
inFlightRunIds: endedHookInFlightRunIds,
|
|
1845
|
-
persist: persistSubagentRuns
|
|
1846
|
-
});
|
|
1847
|
-
}
|
|
1848
|
-
const { clearScheduledResumeTimers, completeCleanupBookkeeping, completeSubagentRun, finalizeResumedAnnounceGiveUp, refreshFrozenResultFromSession, startSubagentAnnounceCleanupFlow } = createSubagentRegistryLifecycleController({
|
|
1849
|
-
runs: subagentRuns,
|
|
1850
|
-
resumedRuns,
|
|
1851
|
-
subagentAnnounceTimeoutMs: SUBAGENT_ANNOUNCE_TIMEOUT_MS,
|
|
1852
|
-
persist: persistSubagentRuns,
|
|
1853
|
-
clearPendingLifecycleError,
|
|
1854
|
-
countPendingDescendantRuns,
|
|
1855
|
-
suppressAnnounceForSteerRestart,
|
|
1856
|
-
shouldEmitEndedHookForRun,
|
|
1857
|
-
emitSubagentEndedHookForRun,
|
|
1858
|
-
notifyContextEngineSubagentEnded,
|
|
1859
|
-
resumeSubagentRun,
|
|
1860
|
-
callGateway: (request) => subagentRegistryDeps.callGateway(request),
|
|
1861
|
-
captureSubagentCompletionReply: (sessionKey, options) => subagentRegistryDeps.captureSubagentCompletionReply(sessionKey, options),
|
|
1862
|
-
cleanupBrowserSessionsForLifecycleEnd: (args) => subagentRegistryDeps.cleanupBrowserSessionsForLifecycleEnd(args),
|
|
1863
|
-
runSubagentAnnounceFlow: (params) => subagentRegistryDeps.runSubagentAnnounceFlow(params),
|
|
1864
|
-
warn: (message, meta) => log.warn(message, meta)
|
|
1865
|
-
});
|
|
1866
|
-
function resumeSubagentRun(runId) {
|
|
1867
|
-
if (!runId || resumedRuns.has(runId)) return;
|
|
1868
|
-
const entry = subagentRuns.get(runId);
|
|
1869
|
-
if (!entry) return;
|
|
1870
|
-
if (entry.cleanupCompletedAt) return;
|
|
1871
|
-
if (typeof entry.endedAt === "number" && entry.pendingFinalDelivery === true && typeof entry.deliverySuspendedAt === "number") return;
|
|
1872
|
-
if (entry.pauseReason === "sessions_yield") return;
|
|
1873
|
-
if ((entry.announceRetryCount ?? 0) >= 3) {
|
|
1874
|
-
finalizeResumedAnnounceGiveUp({
|
|
1875
|
-
runId,
|
|
1876
|
-
entry,
|
|
1877
|
-
reason: "retry-limit"
|
|
1878
|
-
});
|
|
1879
|
-
return;
|
|
1880
|
-
}
|
|
1881
|
-
if (entry.expectsCompletionMessage !== true && typeof entry.endedAt === "number" && Date.now() - entry.endedAt > 3e5) {
|
|
1882
|
-
finalizeResumedAnnounceGiveUp({
|
|
1883
|
-
runId,
|
|
1884
|
-
entry,
|
|
1885
|
-
reason: "expiry"
|
|
1886
|
-
});
|
|
1887
|
-
return;
|
|
1888
|
-
}
|
|
1889
|
-
const now = Date.now();
|
|
1890
|
-
const delayMs = resolveAnnounceRetryDelayMs(entry.announceRetryCount ?? 0);
|
|
1891
|
-
const earliestRetryAt = (entry.lastAnnounceRetryAt ?? 0) + delayMs;
|
|
1892
|
-
if (entry.expectsCompletionMessage === true && entry.lastAnnounceRetryAt && now < earliestRetryAt) {
|
|
1893
|
-
const waitMs = Math.max(1, earliestRetryAt - now);
|
|
1894
|
-
const scheduledEntry = entry;
|
|
1895
|
-
const timer = setTimeout(() => {
|
|
1896
|
-
resumeRetryTimers.delete(timer);
|
|
1897
|
-
if (subagentRuns.get(runId) !== scheduledEntry) return;
|
|
1898
|
-
resumedRuns.delete(runId);
|
|
1899
|
-
resumeSubagentRun(runId);
|
|
1900
|
-
}, waitMs);
|
|
1901
|
-
timer.unref?.();
|
|
1902
|
-
resumeRetryTimers.add(timer);
|
|
1903
|
-
resumedRuns.add(runId);
|
|
1904
|
-
return;
|
|
1905
|
-
}
|
|
1906
|
-
if (typeof entry.endedAt === "number" && entry.endedAt > 0) {
|
|
1907
|
-
const orphanReason = resolveSubagentRunOrphanReason({ entry });
|
|
1908
|
-
if (orphanReason) {
|
|
1909
|
-
if (reconcileOrphanedRun({
|
|
1910
|
-
runId,
|
|
1911
|
-
entry,
|
|
1912
|
-
reason: orphanReason,
|
|
1913
|
-
source: "resume",
|
|
1914
|
-
runs: subagentRuns,
|
|
1915
|
-
resumedRuns
|
|
1916
|
-
})) persistSubagentRuns();
|
|
1917
|
-
return;
|
|
1918
|
-
}
|
|
1919
|
-
if (suppressAnnounceForSteerRestart(entry)) {
|
|
1920
|
-
resumedRuns.add(runId);
|
|
1921
|
-
return;
|
|
1922
|
-
}
|
|
1923
|
-
if (!startSubagentAnnounceCleanupFlow(runId, entry)) return;
|
|
1924
|
-
resumedRuns.add(runId);
|
|
1925
|
-
return;
|
|
1926
|
-
}
|
|
1927
|
-
const waitTimeoutMs = resolveSubagentWaitTimeoutMs(subagentRegistryDeps.getRuntimeConfig(), entry.runTimeoutSeconds);
|
|
1928
|
-
subagentRunManager.waitForSubagentCompletion(runId, waitTimeoutMs, entry);
|
|
1929
|
-
resumedRuns.add(runId);
|
|
1930
|
-
}
|
|
1931
|
-
function restoreSubagentRunsOnce() {
|
|
1932
|
-
if (restoreAttempted) return;
|
|
1933
|
-
restoreAttempted = true;
|
|
1934
|
-
try {
|
|
1935
|
-
if (subagentRegistryDeps.restoreSubagentRunsFromDisk({
|
|
1936
|
-
runs: subagentRuns,
|
|
1937
|
-
mergeOnly: true
|
|
1938
|
-
}) === 0) return;
|
|
1939
|
-
if (reconcileOrphanedRestoredRuns({
|
|
1940
|
-
runs: subagentRuns,
|
|
1941
|
-
resumedRuns
|
|
1942
|
-
})) persistSubagentRuns();
|
|
1943
|
-
if (subagentRuns.size === 0) return;
|
|
1944
|
-
ensureListener();
|
|
1945
|
-
startSweeper();
|
|
1946
|
-
for (const runId of subagentRuns.keys()) resumeSubagentRun(runId);
|
|
1947
|
-
scheduleSubagentOrphanRecovery();
|
|
1948
|
-
} catch {}
|
|
1949
|
-
}
|
|
1950
|
-
function resolveSubagentWaitTimeoutMs(cfg, runTimeoutSeconds) {
|
|
1951
|
-
return subagentRegistryDeps.resolveAgentTimeoutMs({
|
|
1952
|
-
cfg,
|
|
1953
|
-
overrideSeconds: runTimeoutSeconds ?? 0
|
|
1954
|
-
});
|
|
1955
|
-
}
|
|
1956
|
-
function startSweeper() {
|
|
1957
|
-
if (sweeper) return;
|
|
1958
|
-
sweeper = setInterval(() => {
|
|
1959
|
-
if (sweepInProgress) return;
|
|
1960
|
-
sweepSubagentRuns();
|
|
1961
|
-
}, 6e4);
|
|
1962
|
-
sweeper.unref?.();
|
|
1963
|
-
}
|
|
1964
|
-
function stopSweeper() {
|
|
1965
|
-
if (!sweeper) return;
|
|
1966
|
-
clearInterval(sweeper);
|
|
1967
|
-
sweeper = null;
|
|
1968
|
-
}
|
|
1969
|
-
function isSuspendedPendingFinalDelivery(entry) {
|
|
1970
|
-
return typeof entry.endedAt === "number" && entry.pendingFinalDelivery === true && typeof entry.deliverySuspendedAt === "number";
|
|
1971
|
-
}
|
|
1972
|
-
function resolveSuspendedDeliveryExpiryMs(entry) {
|
|
1973
|
-
const requester = entry.requesterSessionKey;
|
|
1974
|
-
if (requester.includes(":cron:")) return SUSPENDED_DELIVERY_CRON_EXPIRY_MS;
|
|
1975
|
-
if (requester.includes(":subagent:")) return SUSPENDED_DELIVERY_SUBAGENT_EXPIRY_MS;
|
|
1976
|
-
return SUSPENDED_DELIVERY_INTERACTIVE_EXPIRY_MS;
|
|
1977
|
-
}
|
|
1978
|
-
async function discardSuspendedPendingFinalDelivery(runId, entry, now, reason) {
|
|
1979
|
-
const payload = entry.pendingFinalDeliveryPayload;
|
|
1980
|
-
entry.deliveryDiscardedAt = now;
|
|
1981
|
-
entry.deliveryDiscardReason = reason;
|
|
1982
|
-
entry.deliveryDiscardedPayloadSummary = {
|
|
1983
|
-
requesterSessionKey: payload?.requesterSessionKey ?? entry.requesterSessionKey,
|
|
1984
|
-
childSessionKey: payload?.childSessionKey ?? entry.childSessionKey,
|
|
1985
|
-
childRunId: payload?.childRunId ?? entry.runId,
|
|
1986
|
-
endedAt: payload?.endedAt ?? entry.endedAt,
|
|
1987
|
-
status: payload?.outcome?.status ?? entry.outcome?.status,
|
|
1988
|
-
lastError: entry.lastAnnounceDeliveryError ?? entry.pendingFinalDeliveryLastError ?? null
|
|
1989
|
-
};
|
|
1990
|
-
entry.pendingFinalDelivery = void 0;
|
|
1991
|
-
entry.pendingFinalDeliveryCreatedAt = void 0;
|
|
1992
|
-
entry.pendingFinalDeliveryLastAttemptAt = void 0;
|
|
1993
|
-
entry.pendingFinalDeliveryAttemptCount = void 0;
|
|
1994
|
-
entry.pendingFinalDeliveryLastError = void 0;
|
|
1995
|
-
entry.pendingFinalDeliveryPayload = void 0;
|
|
1996
|
-
entry.deliverySuspendedAt = void 0;
|
|
1997
|
-
entry.deliverySuspendedReason = void 0;
|
|
1998
|
-
entry.wakeOnDescendantSettle = void 0;
|
|
1999
|
-
entry.fallbackFrozenResultText = void 0;
|
|
2000
|
-
entry.fallbackFrozenResultCapturedAt = void 0;
|
|
2001
|
-
entry.cleanupHandled = true;
|
|
2002
|
-
entry.completionAnnouncedAt = void 0;
|
|
2003
|
-
resumedRuns.delete(runId);
|
|
2004
|
-
clearPendingLifecycleError(runId);
|
|
2005
|
-
clearPendingLifecycleTimeout(runId);
|
|
2006
|
-
log.warn("subagent suspended delivery discarded", {
|
|
2007
|
-
reason,
|
|
2008
|
-
runId: entry.runId,
|
|
2009
|
-
childSessionKey: entry.childSessionKey,
|
|
2010
|
-
requesterSessionKey: entry.requesterSessionKey
|
|
2011
|
-
});
|
|
2012
|
-
if (entry.cleanup === "delete" || !entry.retainAttachmentsOnKeep) await safeRemoveAttachmentsDir(entry);
|
|
2013
|
-
const completionReason = entry.endedReason ?? "subagent-complete";
|
|
2014
|
-
completeCleanupBookkeeping({
|
|
2015
|
-
runId,
|
|
2016
|
-
entry,
|
|
2017
|
-
cleanup: entry.cleanup,
|
|
2018
|
-
completedAt: now
|
|
2019
|
-
});
|
|
2020
|
-
if (entry.expectsCompletionMessage === true && shouldEmitEndedHookForRun({
|
|
2021
|
-
entry,
|
|
2022
|
-
reason: completionReason
|
|
2023
|
-
})) await emitSubagentEndedHookForRun({
|
|
2024
|
-
entry,
|
|
2025
|
-
reason: completionReason,
|
|
2026
|
-
sendFarewell: true
|
|
2027
|
-
});
|
|
2028
|
-
}
|
|
2029
|
-
async function sweepSubagentRuns() {
|
|
2030
|
-
if (sweepInProgress) return;
|
|
2031
|
-
sweepInProgress = true;
|
|
2032
|
-
try {
|
|
2033
|
-
const now = Date.now();
|
|
2034
|
-
const storeCache = /* @__PURE__ */ new Map();
|
|
2035
|
-
let mutated = false;
|
|
2036
|
-
const suspendedEntries = [...subagentRuns.entries()].filter(([, entry]) => isSuspendedPendingFinalDelivery(entry));
|
|
2037
|
-
const pressureDiscardRunIds = /* @__PURE__ */ new Set();
|
|
2038
|
-
if (suspendedEntries.length > SUSPENDED_DELIVERY_HARD_CAP) {
|
|
2039
|
-
const pressureCount = Math.max(0, suspendedEntries.length - SUSPENDED_DELIVERY_PRESSURE_TARGET);
|
|
2040
|
-
for (const [runId] of suspendedEntries.toSorted((a, b) => (a[1].deliverySuspendedAt ?? 0) - (b[1].deliverySuspendedAt ?? 0)).slice(0, pressureCount)) pressureDiscardRunIds.add(runId);
|
|
2041
|
-
log.warn("subagent suspended delivery backlog exceeded pressure cap", {
|
|
2042
|
-
suspendedCount: suspendedEntries.length,
|
|
2043
|
-
softCap: SUSPENDED_DELIVERY_SOFT_CAP,
|
|
2044
|
-
hardCap: SUSPENDED_DELIVERY_HARD_CAP,
|
|
2045
|
-
pressureTarget: SUSPENDED_DELIVERY_PRESSURE_TARGET,
|
|
2046
|
-
pressureDiscardCount: pressureDiscardRunIds.size
|
|
2047
|
-
});
|
|
2048
|
-
}
|
|
2049
|
-
for (const [runId, entry] of subagentRuns.entries()) {
|
|
2050
|
-
if (isSuspendedPendingFinalDelivery(entry)) {
|
|
2051
|
-
const expired = now - (entry.deliverySuspendedAt ?? now) >= resolveSuspendedDeliveryExpiryMs(entry);
|
|
2052
|
-
if (expired || pressureDiscardRunIds.has(runId)) {
|
|
2053
|
-
await discardSuspendedPendingFinalDelivery(runId, entry, now, expired ? "expired" : "pressure-pruned");
|
|
2054
|
-
mutated = true;
|
|
2055
|
-
}
|
|
2056
|
-
continue;
|
|
2057
|
-
}
|
|
2058
|
-
if (typeof entry.endedAt !== "number") {
|
|
2059
|
-
const hasLiveRunContext = Boolean(getAgentRunContext(runId));
|
|
2060
|
-
const activeAgeMs = now - (entry.startedAt ?? entry.createdAt);
|
|
2061
|
-
if (!hasLiveRunContext && activeAgeMs >= STALE_ACTIVE_SUBAGENT_GRACE_MS) {
|
|
2062
|
-
const orphanReason = resolveSubagentRunOrphanReason({
|
|
2063
|
-
entry,
|
|
2064
|
-
storeCache
|
|
2065
|
-
});
|
|
2066
|
-
if (orphanReason) {
|
|
2067
|
-
if (reconcileOrphanedRun({
|
|
2068
|
-
runId,
|
|
2069
|
-
entry,
|
|
2070
|
-
reason: orphanReason,
|
|
2071
|
-
source: "resume",
|
|
2072
|
-
runs: subagentRuns,
|
|
2073
|
-
resumedRuns
|
|
2074
|
-
})) mutated = true;
|
|
2075
|
-
continue;
|
|
2076
|
-
}
|
|
2077
|
-
const sessionEntry = loadSubagentSessionEntry({
|
|
2078
|
-
childSessionKey: entry.childSessionKey,
|
|
2079
|
-
storeCache
|
|
2080
|
-
});
|
|
2081
|
-
const completion = resolveCompletionFromSessionEntry(sessionEntry, now, { notBeforeMs: entry.startedAt ?? entry.createdAt });
|
|
2082
|
-
if (completion) {
|
|
2083
|
-
await completeSubagentRun({
|
|
2084
|
-
runId,
|
|
2085
|
-
endedAt: completion.endedAt,
|
|
2086
|
-
outcome: completion.outcome,
|
|
2087
|
-
reason: completion.reason,
|
|
2088
|
-
sendFarewell: true,
|
|
2089
|
-
accountId: entry.requesterOrigin?.accountId,
|
|
2090
|
-
triggerCleanup: true
|
|
2091
|
-
});
|
|
2092
|
-
continue;
|
|
2093
|
-
}
|
|
2094
|
-
if (sessionEntry?.abortedLastRun === true) {
|
|
2095
|
-
scheduleSubagentOrphanRecovery({ delayMs: 1e3 });
|
|
2096
|
-
continue;
|
|
2097
|
-
}
|
|
2098
|
-
await completeSubagentRun({
|
|
2099
|
-
runId,
|
|
2100
|
-
endedAt: now,
|
|
2101
|
-
outcome: {
|
|
2102
|
-
status: "error",
|
|
2103
|
-
error: "subagent run lost active execution context"
|
|
2104
|
-
},
|
|
2105
|
-
reason: SUBAGENT_ENDED_REASON_ERROR,
|
|
2106
|
-
sendFarewell: true,
|
|
2107
|
-
accountId: entry.requesterOrigin?.accountId,
|
|
2108
|
-
triggerCleanup: true
|
|
2109
|
-
});
|
|
2110
|
-
continue;
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
if (!entry.archiveAtMs && entry.cleanup === "keep" && entry.spawnMode !== "session") continue;
|
|
2114
|
-
if (!entry.archiveAtMs) {
|
|
2115
|
-
if (typeof entry.cleanupCompletedAt === "number" && now - entry.cleanupCompletedAt > SESSION_RUN_TTL_MS) {
|
|
2116
|
-
clearPendingLifecycleError(runId);
|
|
2117
|
-
notifyContextEngineSubagentEnded({
|
|
2118
|
-
childSessionKey: entry.childSessionKey,
|
|
2119
|
-
reason: "swept",
|
|
2120
|
-
agentDir: entry.agentDir,
|
|
2121
|
-
workspaceDir: entry.workspaceDir
|
|
2122
|
-
});
|
|
2123
|
-
subagentRuns.delete(runId);
|
|
2124
|
-
mutated = true;
|
|
2125
|
-
if (!entry.retainAttachmentsOnKeep) await safeRemoveAttachmentsDir(entry);
|
|
2126
|
-
}
|
|
2127
|
-
continue;
|
|
2128
|
-
}
|
|
2129
|
-
if (entry.archiveAtMs > now) continue;
|
|
2130
|
-
clearPendingLifecycleError(runId);
|
|
2131
|
-
try {
|
|
2132
|
-
await subagentRegistryDeps.callGateway({
|
|
2133
|
-
method: "sessions.delete",
|
|
2134
|
-
params: {
|
|
2135
|
-
key: entry.childSessionKey,
|
|
2136
|
-
deleteTranscript: true,
|
|
2137
|
-
emitLifecycleHooks: false
|
|
2138
|
-
},
|
|
2139
|
-
timeoutMs: 1e4
|
|
2140
|
-
});
|
|
2141
|
-
} catch (err) {
|
|
2142
|
-
log.warn("sessions.delete failed during subagent sweep; keeping run for retry", {
|
|
2143
|
-
runId,
|
|
2144
|
-
childSessionKey: entry.childSessionKey,
|
|
2145
|
-
err
|
|
2146
|
-
});
|
|
2147
|
-
continue;
|
|
2148
|
-
}
|
|
2149
|
-
subagentRuns.delete(runId);
|
|
2150
|
-
mutated = true;
|
|
2151
|
-
await safeRemoveAttachmentsDir(entry);
|
|
2152
|
-
notifyContextEngineSubagentEnded({
|
|
2153
|
-
childSessionKey: entry.childSessionKey,
|
|
2154
|
-
reason: "swept",
|
|
2155
|
-
agentDir: entry.agentDir,
|
|
2156
|
-
workspaceDir: entry.workspaceDir
|
|
2157
|
-
});
|
|
2158
|
-
}
|
|
2159
|
-
for (const [runId, pending] of pendingLifecycleErrorByRunId.entries()) if (now - pending.endedAt > PENDING_LIFECYCLE_TERMINAL_TTL_MS) clearPendingLifecycleError(runId);
|
|
2160
|
-
for (const [runId, pending] of pendingLifecycleTimeoutByRunId.entries()) if (now - pending.endedAt > PENDING_LIFECYCLE_TERMINAL_TTL_MS) clearPendingLifecycleTimeout(runId);
|
|
2161
|
-
if (mutated) persistSubagentRuns();
|
|
2162
|
-
if (subagentRuns.size === 0) stopSweeper();
|
|
2163
|
-
} finally {
|
|
2164
|
-
sweepInProgress = false;
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
function ensureListener() {
|
|
2168
|
-
if (listenerStarted) return;
|
|
2169
|
-
listenerStarted = true;
|
|
2170
|
-
subagentRegistryDeps.onAgentEvent((evt) => {
|
|
2171
|
-
(async () => {
|
|
2172
|
-
if (!evt || evt.stream !== "lifecycle") return;
|
|
2173
|
-
const phase = evt.data?.phase;
|
|
2174
|
-
const entry = subagentRuns.get(evt.runId);
|
|
2175
|
-
if (!entry) {
|
|
2176
|
-
if (phase === "end" && typeof evt.sessionKey === "string") await refreshFrozenResultFromSession(evt.sessionKey);
|
|
2177
|
-
return;
|
|
2178
|
-
}
|
|
2179
|
-
if (phase === "start") {
|
|
2180
|
-
clearPendingLifecycleError(evt.runId);
|
|
2181
|
-
clearPendingLifecycleTimeout(evt.runId);
|
|
2182
|
-
const startedAt = typeof evt.data?.startedAt === "number" ? evt.data.startedAt : void 0;
|
|
2183
|
-
if (startedAt) {
|
|
2184
|
-
entry.startedAt = startedAt;
|
|
2185
|
-
if (typeof entry.sessionStartedAt !== "number") entry.sessionStartedAt = startedAt;
|
|
2186
|
-
persistSubagentRuns();
|
|
2187
|
-
}
|
|
2188
|
-
return;
|
|
2189
|
-
}
|
|
2190
|
-
if (phase !== "end" && phase !== "error") return;
|
|
2191
|
-
const endedAt = typeof evt.data?.endedAt === "number" ? evt.data.endedAt : Date.now();
|
|
2192
|
-
const error = typeof evt.data?.error === "string" ? evt.data.error : void 0;
|
|
2193
|
-
const livenessState = typeof evt.data?.livenessState === "string" ? evt.data.livenessState : void 0;
|
|
2194
|
-
if (phase === "error") {
|
|
2195
|
-
schedulePendingLifecycleError({
|
|
2196
|
-
runId: evt.runId,
|
|
2197
|
-
endedAt,
|
|
2198
|
-
error
|
|
2199
|
-
});
|
|
2200
|
-
return;
|
|
2201
|
-
}
|
|
2202
|
-
if (isBlockedLivenessState(livenessState)) {
|
|
2203
|
-
clearPendingLifecycleError(evt.runId);
|
|
2204
|
-
clearPendingLifecycleTimeout(evt.runId);
|
|
2205
|
-
await completeSubagentRun({
|
|
2206
|
-
runId: evt.runId,
|
|
2207
|
-
endedAt,
|
|
2208
|
-
outcome: {
|
|
2209
|
-
status: "error",
|
|
2210
|
-
error: formatBlockedLivenessError(error)
|
|
2211
|
-
},
|
|
2212
|
-
reason: SUBAGENT_ENDED_REASON_ERROR,
|
|
2213
|
-
sendFarewell: true,
|
|
2214
|
-
accountId: entry.requesterOrigin?.accountId,
|
|
2215
|
-
triggerCleanup: true
|
|
2216
|
-
});
|
|
2217
|
-
return;
|
|
2218
|
-
}
|
|
2219
|
-
if (evt.data?.aborted) {
|
|
2220
|
-
schedulePendingLifecycleTimeout({
|
|
2221
|
-
runId: evt.runId,
|
|
2222
|
-
endedAt
|
|
2223
|
-
});
|
|
2224
|
-
return;
|
|
2225
|
-
}
|
|
2226
|
-
if (evt.data?.yielded === true) {
|
|
2227
|
-
if (markSubagentRunPausedAfterYield({
|
|
2228
|
-
entry,
|
|
2229
|
-
endedAt,
|
|
2230
|
-
startedAt: typeof evt.data?.startedAt === "number" ? evt.data.startedAt : entry.startedAt
|
|
2231
|
-
})) persistSubagentRuns();
|
|
2232
|
-
return;
|
|
2233
|
-
}
|
|
2234
|
-
clearPendingLifecycleError(evt.runId);
|
|
2235
|
-
clearPendingLifecycleTimeout(evt.runId);
|
|
2236
|
-
await completeSubagentRun({
|
|
2237
|
-
runId: evt.runId,
|
|
2238
|
-
endedAt,
|
|
2239
|
-
outcome: { status: "ok" },
|
|
2240
|
-
reason: SUBAGENT_ENDED_REASON_COMPLETE,
|
|
2241
|
-
sendFarewell: true,
|
|
2242
|
-
accountId: entry.requesterOrigin?.accountId,
|
|
2243
|
-
triggerCleanup: true
|
|
2244
|
-
});
|
|
2245
|
-
})();
|
|
2246
|
-
});
|
|
2247
|
-
}
|
|
2248
|
-
const subagentRunManager = createSubagentRunManager({
|
|
2249
|
-
runs: subagentRuns,
|
|
2250
|
-
resumedRuns,
|
|
2251
|
-
endedHookInFlightRunIds,
|
|
2252
|
-
persist: persistSubagentRuns,
|
|
2253
|
-
persistOrThrow: persistSubagentRunsOrThrow,
|
|
2254
|
-
callGateway: (request) => subagentRegistryDeps.callGateway(request),
|
|
2255
|
-
getRuntimeConfig: () => subagentRegistryDeps.getRuntimeConfig(),
|
|
2256
|
-
ensureRuntimePluginsLoaded: (args) => ensureSubagentRegistryPluginRuntimeLoaded(args),
|
|
2257
|
-
ensureListener,
|
|
2258
|
-
startSweeper,
|
|
2259
|
-
stopSweeper,
|
|
2260
|
-
resumeSubagentRun,
|
|
2261
|
-
clearPendingLifecycleError,
|
|
2262
|
-
resolveSubagentWaitTimeoutMs,
|
|
2263
|
-
scheduleOrphanRecovery: (args) => scheduleSubagentOrphanRecovery(args),
|
|
2264
|
-
resolveSubagentSessionCompletion,
|
|
2265
|
-
notifyContextEngineSubagentEnded,
|
|
2266
|
-
completeCleanupBookkeeping,
|
|
2267
|
-
completeSubagentRun
|
|
2268
|
-
});
|
|
2269
|
-
configureSubagentRegistrySteerRuntime({
|
|
2270
|
-
replaceSubagentRunAfterSteer: (params) => subagentRunManager.replaceSubagentRunAfterSteer(params),
|
|
2271
|
-
finalizeInterruptedSubagentRun: async (params) => await finalizeInterruptedSubagentRun(params)
|
|
2272
|
-
});
|
|
2273
|
-
function markSubagentRunForSteerRestart(runId) {
|
|
2274
|
-
return subagentRunManager.markSubagentRunForSteerRestart(runId);
|
|
2275
|
-
}
|
|
2276
|
-
function clearSubagentRunSteerRestart(runId) {
|
|
2277
|
-
return subagentRunManager.clearSubagentRunSteerRestart(runId);
|
|
2278
|
-
}
|
|
2279
|
-
function replaceSubagentRunAfterSteer(params) {
|
|
2280
|
-
return subagentRunManager.replaceSubagentRunAfterSteer(params);
|
|
2281
|
-
}
|
|
2282
|
-
function registerSubagentRun(params) {
|
|
2283
|
-
subagentRunManager.registerSubagentRun(params);
|
|
2284
|
-
}
|
|
2285
|
-
async function finalizeInterruptedSubagentRun(params) {
|
|
2286
|
-
const runIds = /* @__PURE__ */ new Set();
|
|
2287
|
-
if (typeof params.runId === "string" && params.runId.trim()) runIds.add(params.runId.trim());
|
|
2288
|
-
if (typeof params.childSessionKey === "string" && params.childSessionKey.trim()) {
|
|
2289
|
-
const childSessionKey = params.childSessionKey.trim();
|
|
2290
|
-
for (const [runId, entry] of subagentRuns.entries()) if (entry.childSessionKey === childSessionKey) runIds.add(runId);
|
|
2291
|
-
}
|
|
2292
|
-
if (runIds.size === 0) return 0;
|
|
2293
|
-
const endedAt = typeof params.endedAt === "number" && Number.isFinite(params.endedAt) ? params.endedAt : Date.now();
|
|
2294
|
-
let updated = 0;
|
|
2295
|
-
for (const runId of runIds) {
|
|
2296
|
-
clearPendingLifecycleError(runId);
|
|
2297
|
-
clearPendingLifecycleTimeout(runId);
|
|
2298
|
-
const entry = subagentRuns.get(runId);
|
|
2299
|
-
if (!entry || typeof entry.cleanupCompletedAt === "number") continue;
|
|
2300
|
-
await completeSubagentRun({
|
|
2301
|
-
runId,
|
|
2302
|
-
endedAt,
|
|
2303
|
-
outcome: {
|
|
2304
|
-
status: "error",
|
|
2305
|
-
error: params.error
|
|
2306
|
-
},
|
|
2307
|
-
reason: SUBAGENT_ENDED_REASON_ERROR,
|
|
2308
|
-
sendFarewell: true,
|
|
2309
|
-
accountId: entry.requesterOrigin?.accountId,
|
|
2310
|
-
triggerCleanup: true
|
|
2311
|
-
});
|
|
2312
|
-
updated += 1;
|
|
2313
|
-
}
|
|
2314
|
-
return updated;
|
|
2315
|
-
}
|
|
2316
|
-
function markSubagentRunTerminated(params) {
|
|
2317
|
-
return subagentRunManager.markSubagentRunTerminated(params);
|
|
2318
|
-
}
|
|
2319
|
-
function listSubagentRunsForController(controllerSessionKey) {
|
|
2320
|
-
return listRunsForControllerFromRuns(subagentRegistryDeps.getSubagentRunsSnapshotForRead(subagentRuns), controllerSessionKey);
|
|
2321
|
-
}
|
|
2322
|
-
function countActiveRunsForSession(requesterSessionKey) {
|
|
2323
|
-
return countActiveRunsForSessionFromRuns(subagentRegistryDeps.getSubagentRunsSnapshotForRead(subagentRuns), requesterSessionKey);
|
|
2324
|
-
}
|
|
2325
|
-
function countActiveDescendantRuns(rootSessionKey) {
|
|
2326
|
-
return countActiveDescendantRunsFromRuns(subagentRegistryDeps.getSubagentRunsSnapshotForRead(subagentRuns), rootSessionKey);
|
|
2327
|
-
}
|
|
2328
|
-
function countPendingDescendantRuns(rootSessionKey) {
|
|
2329
|
-
return countPendingDescendantRunsFromRuns(subagentRegistryDeps.getSubagentRunsSnapshotForRead(subagentRuns), rootSessionKey);
|
|
2330
|
-
}
|
|
2331
|
-
function listDescendantRunsForRequester(rootSessionKey) {
|
|
2332
|
-
return listDescendantRunsForRequesterFromRuns(subagentRegistryDeps.getSubagentRunsSnapshotForRead(subagentRuns), rootSessionKey);
|
|
2333
|
-
}
|
|
2334
|
-
function getSubagentRunByChildSessionKey(childSessionKey) {
|
|
2335
|
-
return getSubagentRunByChildSessionKeyFromRuns(subagentRegistryDeps.getSubagentRunsSnapshotForRead(subagentRuns), childSessionKey);
|
|
2336
|
-
}
|
|
2337
|
-
function getLatestSubagentRunByChildSessionKey(childSessionKey) {
|
|
2338
|
-
const key = childSessionKey.trim();
|
|
2339
|
-
if (!key) return null;
|
|
2340
|
-
let latest = null;
|
|
2341
|
-
for (const entry of subagentRegistryDeps.getSubagentRunsSnapshotForRead(subagentRuns).values()) {
|
|
2342
|
-
if (entry.childSessionKey !== key) continue;
|
|
2343
|
-
if (!latest || entry.createdAt > latest.createdAt) latest = entry;
|
|
2344
|
-
}
|
|
2345
|
-
return latest;
|
|
2346
|
-
}
|
|
2347
|
-
function initSubagentRegistry() {
|
|
2348
|
-
restoreSubagentRunsOnce();
|
|
2349
|
-
}
|
|
2350
|
-
//#endregion
|
|
2351
|
-
export { finalizeInterruptedSubagentRun as a, initSubagentRegistry as c, markSubagentRunForSteerRestart as d, markSubagentRunTerminated as f, listSessionMaintenanceProtectedSubagentSessionKeys as g, scheduleSubagentOrphanRecovery as h, countPendingDescendantRuns as i, listDescendantRunsForRequester as l, replaceSubagentRunAfterSteer as m, countActiveDescendantRuns as n, getLatestSubagentRunByChildSessionKey as o, registerSubagentRun as p, countActiveRunsForSession as r, getSubagentRunByChildSessionKey as s, clearSubagentRunSteerRestart as t, listSubagentRunsForController as u };
|