wednesdayai 0.4.12-dev.706 → 0.4.12-dev.707
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/{agent-turn-enqueue-V0Vpu538.js → agent-turn-enqueue-B5Uv68lP.js} +4 -4
- package/dist/{agent-turn-enqueue-DUTkQGZf.js → agent-turn-enqueue-DYZlZypS.js} +4 -4
- package/dist/{agent-turn-execute-ykPmYmYL.js → agent-turn-execute-BjsMs4-_.js} +363 -262
- package/dist/{agent-turn-recovery-adapter-DswEzfh0.js → agent-turn-recovery-adapter-B8ZbwTXv.js} +1 -1
- package/dist/{agent-turn-recovery-adapter-Dz8mFaxx.js → agent-turn-recovery-adapter-D3gYLzXI.js} +1 -1
- package/dist/{agent-turn-runner-C2XXPavj.js → agent-turn-runner-BB0xkzVk.js} +1 -1
- package/dist/{agent-turn-runner-Cl_8XxxV.js → agent-turn-runner-ByKxuh9g.js} +1 -1
- package/dist/{agent-turn-runner-Bq0mff7h.js → agent-turn-runner-CIynRYol.js} +1 -1
- package/dist/{agent-turn-runner-D3ztngQh.js → agent-turn-runner-CwI9bK9W.js} +1 -1
- package/dist/{agents-CR6WyXm2.js → agents-BkFCu1XK.js} +4 -4
- package/dist/{agents.config-DftJxDHx.js → agents.config-D7EkOh-d.js} +1 -1
- package/dist/{agents.config-BkP_dcZ1.js → agents.config-M3p53YVD.js} +1 -1
- package/dist/{audio-preflight-BU9oazCN.js → audio-preflight-DKIH97xz.js} +6 -6
- package/dist/{audio-preflight-BadT0aZp.js → audio-preflight-DanEnt5T.js} +6 -6
- package/dist/{audio-transcription-runner-C_D6-5s-.js → audio-transcription-runner-CgQwIVTA.js} +1 -1
- package/dist/{audio-transcription-runner-CRmRAqAD.js → audio-transcription-runner-CsYhC8Ez.js} +1 -1
- package/dist/{audit-DvZv0_HI.js → audit-Ca5lrM3A.js} +3 -3
- package/dist/{audit-9ONcBlGJ.js → audit-DDpr92zr.js} +3 -3
- package/dist/{auth-choice-C92Ys9fl.js → auth-choice-D3xpq5gM.js} +1 -1
- package/dist/{auth-choice-B48ajlb2.js → auth-choice-DfetB5RW.js} +1 -1
- package/dist/{banner-DJ-dtPt4.js → banner-B-eXLAzF.js} +1 -1
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +2 -2
- package/dist/bundled/session-journal/handler.js +2 -2
- package/dist/bundled/session-memory/handler.js +2 -2
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{channel-options-D0GZl_RV.js → channel-options-BG4Rn7Cf.js} +1 -1
- package/dist/{channel-options-BPy0Kst-.js → channel-options-C8TApl-P.js} +1 -1
- package/dist/{channels-cli-Dw5yfM6M.js → channels-cli-AJKtdDZv.js} +24 -24
- package/dist/{channels-cli-CbqhrPdc.js → channels-cli-DMGDUr_7.js} +24 -24
- package/dist/{cli-DSW3Zmm8.js → cli-Budx9d3_.js} +18 -18
- package/dist/{cli-U-A_086W.js → cli-D9fcfVIN.js} +18 -18
- package/dist/{command-queue-CEw2WosY.js → command-queue-DkA7Zwf6.js} +1 -1
- package/dist/{command-queue-CyYu7b_w.js → command-queue-M5JKutHg.js} +1 -1
- package/dist/{command-registry-BHPuoNDn.js → command-registry-CtaGgjQ_.js} +9 -9
- package/dist/{completion-cli-CJv5xpIh.js → completion-cli-DIZtemFg.js} +2 -2
- package/dist/{completion-cli-CzIqonVH.js → completion-cli-DNprwGQo.js} +1 -1
- package/dist/{config-cli-L99oyek8.js → config-cli-CyvoGF2Q.js} +1 -1
- package/dist/{config-cli-DMQJYHN-.js → config-cli-pWHg8KzQ.js} +1 -1
- package/dist/{configure-BNSgiLsj.js → configure-CWbqSsCT.js} +3 -3
- package/dist/{configure-DF1qbQ90.js → configure-CYuOl1Si.js} +3 -3
- package/dist/{deliver-P4Wm3vMm.js → deliver-B59Njn4n.js} +1 -1
- package/dist/{deliver-0qdgaedO.js → deliver-DNaGsPae.js} +1 -1
- package/dist/{diagnostic-CoiuQPKH.js → diagnostic-DGVkVcyC.js} +1 -1
- package/dist/{diagnostic-DvldRqw-.js → diagnostic-NcPdstx1.js} +1 -1
- package/dist/{dm-policy-shared-BmRyXZxk.js → dm-policy-shared-Cj47AVma.js} +1 -1
- package/dist/{doctor-completion-B187YGTQ.js → doctor-completion-CJWv6Yi8.js} +1 -1
- package/dist/{doctor-completion-CAEqilfu.js → doctor-completion-DRaTmi2S.js} +1 -1
- package/dist/entry.js +2 -2
- package/dist/extensionAPI.js +2 -2
- package/dist/{gateway-cli-CATpS5M1.js → gateway-cli-150xYy7i.js} +41 -41
- package/dist/{gateway-cli-DBisp6Sd.js → gateway-cli-C16Blh0G.js} +41 -41
- package/dist/{health-35lnX8CS.js → health-DVsJWPiL.js} +2 -2
- package/dist/{health-6ASvBiS6.js → health-W07SjXhL.js} +2 -2
- package/dist/{hooks-cli-BdYcpGP0.js → hooks-cli-CjOCv70u.js} +20 -20
- package/dist/{hooks-cli-B03jJjHI.js → hooks-cli-wPb-TiF3.js} +20 -20
- package/dist/index.js +22 -22
- package/dist/{installs-BXhHyHr_.js → installs-BNVJjjgD.js} +1 -1
- package/dist/{installs-qT9b5lFd.js → installs-CIkXZokY.js} +1 -1
- package/dist/llm-slug-generator.js +2 -2
- package/dist/{models-C4cGhUIs.js → models-D20r2c1n.js} +1 -1
- package/dist/{models-cli-CUYwfgEx.js → models-cli-B1DpYwXy.js} +18 -18
- package/dist/{models-cli-AjQALynv.js → models-cli-X4_Uz35o.js} +19 -19
- package/dist/{node-cli-CLMUlFlb.js → node-cli-C5ICC0Mw.js} +3 -3
- package/dist/{node-cli-BWO29Vre.js → node-cli-Cd0KdDZ9.js} +3 -3
- package/dist/{npm-pack-install-CxjdCOiC.js → npm-pack-install-BRQXGSn4.js} +1 -1
- package/dist/{npm-pack-install-Cjg7iStO.js → npm-pack-install-QvhMk_eH.js} +1 -1
- package/dist/{npm-resolution-mcbTS08o.js → npm-resolution-DY6WGqlq.js} +2 -2
- package/dist/{npm-resolution-DmLZ8cl4.js → npm-resolution-DYiXBCBw.js} +2 -2
- package/dist/{onboard-zA8zx3Hs.js → onboard-BJohRNgh.js} +2 -2
- package/dist/{onboard-J9emscLN.js → onboard-CiRt1pZ3.js} +2 -2
- package/dist/{onboard-channels-Bl0KftbA.js → onboard-channels-BkVimqff.js} +2 -2
- package/dist/{onboard-channels-DqkyYqJs.js → onboard-channels-BnWamZcq.js} +2 -2
- package/dist/{onboarding-BHKv8PVj.js → onboarding-CtkXxZ4V.js} +3 -3
- package/dist/{onboarding-BqiFS9np.js → onboarding-DwwhgN_-.js} +3 -3
- package/dist/{onboarding.finalize-OY8Vyswd.js → onboarding.finalize-4JTNGG18.js} +24 -24
- package/dist/{onboarding.finalize-LBEiEThV.js → onboarding.finalize-DqmyK2Zl.js} +23 -23
- package/dist/{operator-commands-Dbvj2iQf.js → operator-commands-CzL-9HCy.js} +2 -2
- package/dist/{operator-commands-DIhjFfW0.js → operator-commands-DIqBfjYT.js} +2 -2
- package/dist/{pi-embedded-CFHNN9oJ.js → pi-embedded-Drx3qiDz.js} +433 -317
- package/dist/{pi-embedded-ByHs-kU2.js → pi-embedded-egNcTcn8.js} +433 -317
- package/dist/{pi-embedded-helpers-BRTG_o2E.js → pi-embedded-helpers-Bdf0msT2.js} +1 -1
- package/dist/{pi-embedded-helpers-DseTaaIm.js → pi-embedded-helpers-D5ZuAV5B.js} +1 -1
- package/dist/{pi-embedded-recovery-adapter-D2_htVri.js → pi-embedded-recovery-adapter-BYsig4Ad.js} +8 -8
- package/dist/{pi-embedded-recovery-adapter-BPT9lnPW.js → pi-embedded-recovery-adapter-Cf6q8n5i.js} +8 -8
- package/dist/{pi-embedded-recovery-adapter-DF3o-MqA.js → pi-embedded-recovery-adapter-DgdLtOGf.js} +2 -2
- package/dist/{pi-embedded-recovery-adapter-0-0NJRF_.js → pi-embedded-recovery-adapter-SvxRUnvP.js} +2 -2
- package/dist/{pi-embedded-utils-BntQ-0Oh.js → pi-embedded-utils-DDGSjA3F.js} +1 -1
- package/dist/{pi-embedded-utils-BCk2SD5y.js → pi-embedded-utils-DWIHcGJr.js} +1 -1
- package/dist/{pi-tools.policy-C3NlA3sD.js → pi-tools.policy-Bx7WTWRE.js} +1 -1
- package/dist/{plugin-registry-BRRnIEGy.js → plugin-registry-BLriGqtI.js} +1 -1
- package/dist/{plugin-registry-BRo7T59U.js → plugin-registry-Mpi7Xbyd.js} +1 -1
- package/dist/plugin-sdk/{agent-turn-execute-CoUpaQcG.js → agent-turn-execute-B_zIGst3.js} +2 -2
- package/dist/plugin-sdk/{agent-turn-execute-D4iQv80C.js → agent-turn-execute-CBIog9rc.js} +2 -2
- package/dist/plugin-sdk/{agent-turn-runner-BUs9rb63.js → agent-turn-runner-BZLZVte0.js} +1 -1
- package/dist/plugin-sdk/{agent-turn-runner-BR2uUVeR.js → agent-turn-runner-BuZraB-G.js} +2 -2
- package/dist/plugin-sdk/{agent-turn-runner-BN0V4J__.js → agent-turn-runner-CKrIkJOo.js} +1 -1
- package/dist/plugin-sdk/{command-detection-wfAMmToR.js → command-detection-rvLsAfnZ.js} +404 -288
- package/dist/plugin-sdk/index.js +2 -2
- package/dist/plugin-sdk/{provider-dispatcher-CCZ0U3qv.js → provider-dispatcher-B4JYNdjt.js} +2 -2
- package/dist/plugin-sdk/{provider-dispatcher-D0-S69GS.js → provider-dispatcher-CkSHbuj1.js} +2 -2
- package/dist/plugin-sdk/provider-media-understanding.js +7 -7
- package/dist/plugin-sdk/src/acp/control-plane/manager.core.d.ts +3 -0
- package/dist/plugin-sdk/src/acp/runtime/registry.d.ts +5 -0
- package/dist/plugin-sdk/src/agents/pi-embedded-runner/workspace-cwd.d.ts +8 -0
- package/dist/plugin-sdk/{subagent-registry-BWIHOyvI.js → subagent-registry-CoP2z-4v.js} +2 -2
- package/dist/plugin-sdk/{subagent-registry-DKnQ_BVA.js → subagent-registry-D22XEgZh.js} +2 -2
- package/dist/plugin-sdk/testing.js +2 -2
- package/dist/plugin-sdk/{tools-C7fDpDC6.js → tools-C53gbWae.js} +407 -291
- package/dist/{plugins-cli-DiXc82SO.js → plugins-cli-CRIdw7Dz.js} +23 -23
- package/dist/{plugins-cli-UCAwk-rk.js → plugins-cli-mCmR3CEl.js} +23 -23
- package/dist/{program-context-BZozJaWV.js → program-context-B3w4xI0v.js} +22 -22
- package/dist/{program-CSHsM0mN.js → program-fvpSjRjQ.js} +24 -24
- package/dist/{prompt-select-styled-C7nKqbr4.js → prompt-select-styled-BGt9dOlR.js} +6 -6
- package/dist/{prompt-select-styled-rjARBru7.js → prompt-select-styled-NkXfaDS4.js} +6 -6
- package/dist/{provider-image-aQISUutb.js → provider-image-22SjivgZ.js} +1 -1
- package/dist/{provider-image-DO_HznGf.js → provider-image-DG4nAiir.js} +1 -1
- package/dist/{push-apns-U-YvRZcJ.js → push-apns-CXMW3CER.js} +2 -2
- package/dist/{push-apns-CUAi4UyY.js → push-apns-y01wF05Z.js} +2 -2
- package/dist/{pw-ai-B5A4Lp_k.js → pw-ai-BbEcMtWh.js} +1 -1
- package/dist/{pw-ai-CqZVjQbv.js → pw-ai-CXdekfq6.js} +1 -1
- package/dist/{reconcile-bundled-AxnVZKWX.js → reconcile-bundled-CL5VFAik.js} +1 -1
- package/dist/{reconcile-bundled-D7d6qLAp.js → reconcile-bundled-O19uQbox.js} +1 -1
- package/dist/{recovery-adapter-BbCCIPN_.js → recovery-adapter-BfGUqpLB.js} +9 -9
- package/dist/{recovery-adapter-DuTIL78B.js → recovery-adapter-CJQVSGCl.js} +1 -1
- package/dist/{recovery-adapter-4iEJpxSF.js → recovery-adapter-D0rTiPKP.js} +9 -9
- package/dist/{recovery-adapter-lM9hSWjB.js → recovery-adapter-KsikWawR.js} +1 -1
- package/dist/{register.agent-qA-oTdaW.js → register.agent-CHURaTpg.js} +23 -23
- package/dist/{register.agent-CkEHSfPv.js → register.agent-CnplxuAf.js} +24 -24
- package/dist/{register.configure-EWwV941Y.js → register.configure-Cuwmu7Px.js} +24 -24
- package/dist/{register.configure-DwcPrhde.js → register.configure-DPZtEcgJ.js} +24 -24
- package/dist/{register.maintenance-BhJi1UgM.js → register.maintenance-ClFkSxzA.js} +25 -25
- package/dist/{register.maintenance-DQtq6l1_.js → register.maintenance-D_tszGHP.js} +24 -24
- package/dist/{register.message-auX519c8.js → register.message-1J6_e4dR.js} +19 -19
- package/dist/{register.message-DC5Kti11.js → register.message-CuxbjIDq.js} +19 -19
- package/dist/{register.onboard-By1QKqJU.js → register.onboard-CkQjScfF.js} +2 -2
- package/dist/{register.onboard-YFYLph6I.js → register.onboard-CwDGzL5G.js} +2 -2
- package/dist/{register.setup-GQV8tSLb.js → register.setup-BZG_BcO1.js} +2 -2
- package/dist/{register.setup-B9mW-na1.js → register.setup-BgYZpfET.js} +2 -2
- package/dist/{register.status-health-sessions-yoSujx0N.js → register.status-health-sessions-CBB4OKN-.js} +21 -21
- package/dist/{register.status-health-sessions-8w9ozxZu.js → register.status-health-sessions-D6zw9jEo.js} +21 -21
- package/dist/{register.subclis-CVoUut4t.js → register.subclis-wD5LH765.js} +14 -14
- package/dist/{registry-CgglAnC7.js → registry-D9ygkK-J.js} +16 -1
- package/dist/{registry-BCJPzWx_.js → registry-DXmhuMNN.js} +16 -1
- package/dist/{reply-CpkHy3wV.js → reply-BPyGc21s.js} +353 -252
- package/dist/{run-main-DVyW2mVM.js → run-main-BO3usZ-A.js} +31 -31
- package/dist/{runs-iCVe22VF.js → runs-CtVQdtCv.js} +3 -3
- package/dist/{runs-Bun_kfif.js → runs-DjV90EYQ.js} +3 -3
- package/dist/{sandbox-pyeWrCaV.js → sandbox-Ccrfvb4b.js} +1 -1
- package/dist/{sandbox-CXLDlrIZ.js → sandbox-DBFMSva5.js} +1 -1
- package/dist/{sandbox-cli-nBppHONP.js → sandbox-cli-DxInKUJI.js} +2 -2
- package/dist/{sandbox-cli-CMnng7eJ.js → sandbox-cli-OTGBxEm_.js} +2 -2
- package/dist/{security-cli-DuNJZ-Ei.js → security-cli-Co10dXWR.js} +4 -4
- package/dist/{security-cli-BpflDIfE.js → security-cli-DSgesPkw.js} +4 -4
- package/dist/{send-CL3duJwW.js → send-BtRCVZMD.js} +1 -1
- package/dist/{send-BwFFAjWq.js → send-BxEC6ayq.js} +1 -1
- package/dist/{server-CMJV3f4W.js → server-BGy6Q3Ax.js} +4 -4
- package/dist/{server-5xIglB3V.js → server-C3Vsqd_E.js} +4 -4
- package/dist/{server-context-Cx2NYfSp.js → server-context-DiEIfJy2.js} +2 -2
- package/dist/{server-context-daohIOGc.js → server-context-r5GX0zkd.js} +2 -2
- package/dist/{server-lifecycle-D0-_LBBT.js → server-lifecycle-BDErerYF.js} +1 -1
- package/dist/{server-lifecycle-CKBiEtss.js → server-lifecycle-DqbPo314.js} +1 -1
- package/dist/{server-node-events-vW0YHKwt.js → server-node-events-ChUVYwTP.js} +19 -19
- package/dist/{server-node-events-BQQYrHHB.js → server-node-events-Db-E97pM.js} +19 -19
- package/dist/{sessions-Dcih4bpg.js → sessions-Dn5cV2Pf.js} +4 -4
- package/dist/{sessions-DchHZ7Jk.js → sessions-DzJqAydH.js} +4 -4
- package/dist/{status-mrMAbwVG.js → status-Bf4zCRwM.js} +4 -4
- package/dist/{status-BjoY6IRI.js → status-CAV6ho-G.js} +4 -4
- package/dist/{task-pipeline-boot-BnDb_vd5.js → task-pipeline-boot-BKmOoIXl.js} +18 -18
- package/dist/{task-pipeline-boot-Dz-2vl8h.js → task-pipeline-boot-pOb3fzno.js} +18 -18
- package/dist/{tui-D38RxYz7.js → tui-CsUcRlyO.js} +1 -1
- package/dist/{tui-cli-BkKp2XZs.js → tui-cli-Cq1Tx-Vn.js} +4 -4
- package/dist/{tui-cli-Is0rb0gd.js → tui-cli-FOxD0i98.js} +4 -4
- package/dist/{tui-CJp8jICV.js → tui-zuajkssQ.js} +1 -1
- package/dist/{update-BUduR5-s.js → update-CACBGz8F.js} +1 -1
- package/dist/{update-cli-BBtLigXU.js → update-cli-Bp7ecypG.js} +27 -27
- package/dist/{update-cli-ClRpFc93.js → update-cli-ClagbSmM.js} +28 -28
- package/dist/{update-ChZwR6OQ.js → update-lhW3ysS7.js} +1 -1
- package/dist/{update-runner-CQ4RhlO2.js → update-runner-BsEMwbDG.js} +1 -1
- package/dist/{update-runner-CjxlBtRb.js → update-runner-DUxab4MB.js} +1 -1
- package/dist/{validation-cli-DK_AzuGz.js → validation-cli-Ct5O6YX2.js} +19 -19
- package/dist/{validation-cli-C2vEL_mG.js → validation-cli-CwePEn-0.js} +19 -19
- package/dist/{with-timeout-kxY3Q2kO.js → with-timeout-DAeX1wSi.js} +2 -2
- package/dist/{with-timeout-B8tTesnN.js → with-timeout-Ef5FGyJ7.js} +2 -2
- package/extensions/acpx/openclaw.plugin.json +1 -1
- package/extensions/acpx/package.json +1 -1
- package/extensions/acpx/src/bundled-acpx.e2e.test.ts +32 -0
- package/extensions/acpx/src/config.pin.test.ts +77 -0
- package/extensions/acpx/src/config.test.ts +14 -0
- package/extensions/acpx/src/config.ts +14 -2
- package/extensions/anthropic/package.json +1 -1
- package/extensions/bifrost/package.json +1 -1
- package/extensions/bluebubbles/package.json +1 -1
- package/extensions/copilot-proxy/package.json +1 -1
- package/extensions/deepgram/package.json +1 -1
- package/extensions/deepinfra/package.json +1 -1
- package/extensions/diagnostics-otel/package.json +1 -1
- package/extensions/diffs/package.json +1 -1
- package/extensions/discord/package.json +1 -1
- package/extensions/dream-cycle/package.json +1 -1
- package/extensions/elevenlabs/package.json +1 -1
- package/extensions/feishu/package.json +1 -1
- package/extensions/gemini-search/package.json +1 -1
- package/extensions/google/package.json +1 -1
- package/extensions/google-gemini-cli-auth/package.json +1 -1
- package/extensions/googlechat/package.json +1 -1
- package/extensions/grok-search/package.json +1 -1
- package/extensions/groq/package.json +1 -1
- package/extensions/imessage/package.json +1 -1
- package/extensions/irc/package.json +1 -1
- package/extensions/kimi-search/package.json +1 -1
- package/extensions/learning-core/package.json +1 -1
- package/extensions/line/package.json +1 -1
- package/extensions/llm-task/package.json +1 -1
- package/extensions/lobster/package.json +1 -1
- package/extensions/matrix/CHANGELOG.md +1 -1
- package/extensions/matrix/package.json +1 -1
- package/extensions/mattermost/package.json +1 -1
- package/extensions/memory-core/package.json +1 -1
- package/extensions/memory-lancedb/package.json +1 -1
- package/extensions/minimax/package.json +1 -1
- package/extensions/minimax-portal-auth/package.json +1 -1
- package/extensions/mistral/package.json +1 -1
- package/extensions/moonshot/package.json +1 -1
- package/extensions/msteams/CHANGELOG.md +1 -1
- package/extensions/msteams/package.json +1 -1
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nostr/CHANGELOG.md +1 -1
- package/extensions/nostr/package.json +1 -1
- package/extensions/open-prose/package.json +1 -1
- package/extensions/openai/package.json +1 -1
- package/extensions/openai-realtime/package.json +1 -1
- package/extensions/openrouter/package.json +1 -1
- package/extensions/perplexity-search/package.json +1 -1
- package/extensions/searxng-search/package.json +1 -1
- package/extensions/signal/package.json +1 -1
- package/extensions/slack/package.json +1 -1
- package/extensions/synology-chat/package.json +1 -1
- package/extensions/telegram/package.json +1 -1
- package/extensions/tlon/package.json +1 -1
- package/extensions/twitch/CHANGELOG.md +1 -1
- package/extensions/twitch/package.json +1 -1
- package/extensions/voice-call/CHANGELOG.md +1 -1
- package/extensions/voice-call/package.json +1 -1
- package/extensions/whatsapp/package.json +1 -1
- package/extensions/zai/package.json +1 -1
- package/extensions/zalo/CHANGELOG.md +1 -1
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalouser/CHANGELOG.md +1 -1
- package/extensions/zalouser/package.json +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ import { i as logWarn, n as logError, r as logInfo, t as logDebug } from "./logg
|
|
|
10
10
|
import { a as validateSlackBlocksArray, c as resolveSlackWebClientOptions, i as parseSlackBlocksInput, l as parseSlackTarget, o as buildSlackBlocksFallbackText, r as normalizeSlackOutboundText, s as createSlackWebClient, t as sendMessageSlack, u as resolveSlackChannelId } from "./send-BepXbnVG.js";
|
|
11
11
|
import { $ as fetchChannelPermissionsDiscord, A as addRoleDiscord, B as removeRoleDiscord, C as fetchMessageDiscord, Ct as resolveDiscordSystemLocation, D as readMessagesDiscord, Dt as buildChannelKeyCandidates, E as pinMessageDiscord, Et as applyChannelMatchMeta, F as fetchRoleInfoDiscord, G as createChannelDiscord, H as listGuildEmojisDiscord, I as fetchVoiceStatusDiscord, J as moveChannelDiscord, K as deleteChannelDiscord, L as kickMemberDiscord, M as createScheduledEventDiscord, N as fetchChannelInfoDiscord, O as searchMessagesDiscord, Ot as normalizeChannelSlug, P as fetchMemberInfoDiscord, R as listGuildChannelsDiscord, S as editMessageDiscord, St as formatDiscordUserTag, T as listThreadsDiscord, Tt as fetchDiscord, U as uploadEmojiDiscord, V as timeoutMemberDiscord, W as uploadStickerDiscord, X as setChannelPermissionDiscord, Y as removeChannelPermissionDiscord, Z as stripUndefinedFields, _ as sendStickerDiscord, _t as resolveDiscordOwnerAllowFrom, a as sendDiscordComponentMessage, at as parseDiscordTarget, b as createThreadDiscord, bt as shouldEmitDiscordReactionNotification, c as parseDiscordComponentCustomId, ct as listDiscordDirectoryPeersLive, d as parseDiscordModalCustomIdForCarbon, dt as normalizeDiscordSlug, f as readDiscordComponentSpec, ft as resolveDiscordAllowListMatch, g as sendPollDiscord, gt as resolveDiscordOwnerAccess, h as sendMessageDiscord, ht as resolveDiscordMemberAccessState, i as removeReactionDiscord, it as createDiscordRestClient, j as banMemberDiscord, k as unpinMessageDiscord, kt as resolveChannelEntryMatchWithFallback, l as parseDiscordComponentCustomIdForCarbon, lt as isDiscordGroupAllowedByPolicy, m as resolveDiscordModalEntry, mt as resolveDiscordGuildEntry, n as reactMessageDiscord, nt as chunkDiscordTextWithMode, o as createDiscordFormModal, ot as resolveDiscordChannelId, p as resolveDiscordComponentEntry, pt as resolveDiscordChannelConfigWithFallback, q as editChannelDiscord, r as removeOwnReactionsDiscord, rt as createDiscordClient, s as formatDiscordComponentEventText, st as listDiscordDirectoryGroupsLive, t as fetchReactionsDiscord, tt as hasAnyGuildPermissionDiscord, u as parseDiscordModalCustomId, ut as normalizeDiscordAllowList, v as sendVoiceMessageDiscord, vt as resolveDiscordShouldRequireMention, w as listPinsDiscord, wt as resolveTimestampMs, x as deleteMessageDiscord, xt as formatDiscordReactionEmoji, y as sendWebhookMessageDiscord, yt as resolveGroupDmAllow, z as listScheduledEventsDiscord } from "./send-BQC0ol0I.js";
|
|
12
12
|
import { a as saveJsonFile, i as loadJsonFile, r as resolveCopilotApiToken } from "./github-copilot-token-pUhYl0t8.js";
|
|
13
|
-
import { a as clearDelayedReleaseHold, c as mergeDelayedAgentTurn, d as KeyedAsyncQueue, i as agentTurnIdempotencyKey, l as peekDelayedAgentTurn, n as getAgentTurnRuntime, o as enqueueAgentTurn, r as tryGetAgentTurnRuntime, s as isClaimableAgentTurnWorkId, u as setDelayedReleaseHold } from "./agent-turn-runner-
|
|
13
|
+
import { a as clearDelayedReleaseHold, c as mergeDelayedAgentTurn, d as KeyedAsyncQueue, i as agentTurnIdempotencyKey, l as peekDelayedAgentTurn, n as getAgentTurnRuntime, o as enqueueAgentTurn, r as tryGetAgentTurnRuntime, s as isClaimableAgentTurnWorkId, u as setDelayedReleaseHold } from "./agent-turn-runner-CKrIkJOo.js";
|
|
14
14
|
import { $ as resolveSandboxConfigForAgent, A as isFailoverAssistantError, B as isTimeoutErrorMessage, C as formatRawAssistantErrorForUi, D as isCloudCodeAssistFormatError, E as isBillingAssistantError, F as isTransientHttpError, G as registerBrowserRoutes, H as resolveSandboxContext, I as parseImageDimensionError, J as getBridgeAuthForPort, K as resolveBrowserConfig, L as parseImageSizeError, M as isLikelyContextOverflowError, N as isRateLimitAssistantError, O as isCompactionFailureError, P as isRawApiErrorPayload, Q as trimToUndefined$1, R as sanitizeUserFacingText, S as formatBillingErrorMessage, T as isAuthAssistantError, U as resolveSandboxRuntimeStatus, V as ensureSandboxWorkspaceForSession, W as createBrowserRouteContext, X as resolveBrowserControlAuth, Y as ensureBrowserControlAuth, Z as resolveGatewayCredentialsFromConfig, _ as downgradeOpenAIReasoningBlocks, a as isMessagingToolDuplicateNormalized, at as resolveBootstrapTotalMaxChars, b as classifyFailoverReason, c as sanitizeImageBlocks, ct as buildPluginToolGroups, d as canonicalizeBase64, dt as mergeAlsoAllowPolicy, et as compileGlobPatterns, f as estimateBase64DecodedBytes, ft as stripPluginOnlyAllowlist, g as downgradeOpenAIFunctionCallReasoningPairs, h as sanitizeToolCallIdsForCloudCodeAssist, ht as resolveToolProfilePolicy, it as resolveBootstrapMaxChars, j as isFailoverErrorMessage, k as isContextOverflowError, l as sanitizeToolResultImages, lt as collectExplicitAllowlist, m as extractToolResultId, mt as normalizeToolName, n as validateGeminiTurns, nt as buildBootstrapContextFiles, o as normalizeTextForComparison, ot as sanitizeGoogleTurnOrdering, p as extractToolCallsFromAssistant, pt as expandToolGroups, q as resolveProfile, r as pickFallbackThinkingLevel, rt as ensureSessionHeader, s as sanitizeSessionMessagesImages, st as applyOwnerOnlyToolPolicy, t as validateAnthropicTurns, tt as matchesAnyGlobPattern, u as resolveImageSanitizationLimits, ut as expandPolicyWithPluginGroups, v as isGoogleModelApi, w as getApiErrorPayloadFingerprint, x as formatAssistantErrorText, y as BILLING_ERROR_USER_MESSAGE, z as isAuthPermanentErrorMessage } from "./pi-embedded-helpers-CpchdPKn.js";
|
|
15
15
|
import { a as toInternalMessageReceivedContext, c as toPluginMessageReceivedEvent, d as initializeGlobalHookRunner, f as promptBuildResultToContribution, g as resolveProviderRuntimeIdentity, h as resolveProviderPromptCacheKey, i as toInternalMessagePreprocessedContext, l as fireAndForgetHook, m as buildPluginTurnIdentity, n as createMessageSentEmitter, o as toInternalMessageTranscribedContext, p as buildPluginRuntimeIdentity, r as deriveInboundMessageHookContext, s as toPluginMessageContext, t as applyMessageSendingHook, u as getGlobalHookRunner } from "./outbound-message-hooks-Bym4ElEd.js";
|
|
16
16
|
import { t as resolveNetworkSsrFPolicy } from "./ssrf-config-DTYnjeA4.js";
|
|
@@ -134,7 +134,7 @@ function resolveAllowListSet(allowList) {
|
|
|
134
134
|
|
|
135
135
|
//#endregion
|
|
136
136
|
//#region src/plugins/activation-migration.ts
|
|
137
|
-
const log$
|
|
137
|
+
const log$40 = createSubsystemLogger("plugins/activation-migration");
|
|
138
138
|
/**
|
|
139
139
|
* One-time migration from the presence-implies-load model to explicit-enable (ADR 0016).
|
|
140
140
|
* Runs synchronously inside loadOpenClawPlugins, before resolveEnableState is applied.
|
|
@@ -176,7 +176,7 @@ function runActivationMigrationIfNeeded(config, pluginRecords) {
|
|
|
176
176
|
activationMigrationVersion: 1
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
|
-
if (toEnable.size > 0) log$
|
|
179
|
+
if (toEnable.size > 0) log$40.info(`activation migration v1: auto-enabled ${toEnable.size} previously-active plugin(s)`, { ids: [...toEnable] });
|
|
180
180
|
return next;
|
|
181
181
|
}
|
|
182
182
|
|
|
@@ -3081,7 +3081,7 @@ async function applyBootstrapHookOverrides(params) {
|
|
|
3081
3081
|
|
|
3082
3082
|
//#endregion
|
|
3083
3083
|
//#region src/agents/system-prompt-config.ts
|
|
3084
|
-
const log$
|
|
3084
|
+
const log$39 = createSubsystemLogger("agents/system-prompt-config");
|
|
3085
3085
|
const DEFAULT_PROMPT_SOURCE_MAX_CHARS = 2e4;
|
|
3086
3086
|
const MAX_PROMPT_SOURCE_FILE_BYTES = 512 * 1024;
|
|
3087
3087
|
const MAX_PROMPT_SOURCE_FILE_BYTES_HARD = 8 * 1024 * 1024;
|
|
@@ -3267,7 +3267,7 @@ async function readPromptSourceFile(params) {
|
|
|
3267
3267
|
if (!opened.ok) {
|
|
3268
3268
|
promptSourceCache.delete(absolutePath);
|
|
3269
3269
|
if (params.optional) {
|
|
3270
|
-
if (opened.reason !== "path") log$
|
|
3270
|
+
if (opened.reason !== "path") log$39.warn("skipping optional systemPrompt source: present but unusable", {
|
|
3271
3271
|
file: params.file,
|
|
3272
3272
|
reason: opened.reason
|
|
3273
3273
|
});
|
|
@@ -3291,7 +3291,7 @@ async function readPromptSourceFile(params) {
|
|
|
3291
3291
|
} catch (error) {
|
|
3292
3292
|
promptSourceCache.delete(opened.path);
|
|
3293
3293
|
if (params.optional) {
|
|
3294
|
-
log$
|
|
3294
|
+
log$39.warn("skipping optional systemPrompt source after read error", {
|
|
3295
3295
|
file: params.file,
|
|
3296
3296
|
error
|
|
3297
3297
|
});
|
|
@@ -3398,7 +3398,7 @@ async function resolveSystemPromptConfigForRun(params) {
|
|
|
3398
3398
|
|
|
3399
3399
|
//#endregion
|
|
3400
3400
|
//#region src/agents/workspace-lanes.ts
|
|
3401
|
-
const log$
|
|
3401
|
+
const log$38 = createSubsystemLogger("agents/workspace-lanes");
|
|
3402
3402
|
const DEFAULT_ROOT_TEMPLATE = "~/.openclaw/agents/{agentId}/lanes/{laneId}/workspace";
|
|
3403
3403
|
const SUPPORTED_STRATEGY = "hybrid";
|
|
3404
3404
|
const DEFAULT_COPIED_ON_CREATE_FILES = ["USER.md", "BOOTSTRAP.md"];
|
|
@@ -3551,7 +3551,7 @@ function resolveWorkspaceLane(params) {
|
|
|
3551
3551
|
actor: params.actor
|
|
3552
3552
|
});
|
|
3553
3553
|
if (!keyResult.ok) {
|
|
3554
|
-
log$
|
|
3554
|
+
log$38.warn("workspace lane key denied", {
|
|
3555
3555
|
agentId,
|
|
3556
3556
|
laneKeySource: keyResult.laneKeySource,
|
|
3557
3557
|
reason: keyResult.reason
|
|
@@ -3572,7 +3572,7 @@ function resolveWorkspaceLane(params) {
|
|
|
3572
3572
|
laneId: key.laneId
|
|
3573
3573
|
});
|
|
3574
3574
|
if (!rootTemplate.ok) {
|
|
3575
|
-
log$
|
|
3575
|
+
log$38.warn("workspace lane root template denied", {
|
|
3576
3576
|
agentId,
|
|
3577
3577
|
laneId: key.laneId,
|
|
3578
3578
|
laneKeySource: key.laneKeySource,
|
|
@@ -3590,7 +3590,7 @@ function resolveWorkspaceLane(params) {
|
|
|
3590
3590
|
}
|
|
3591
3591
|
const effectiveWorkspaceDir = rootTemplate.effectiveWorkspaceDir;
|
|
3592
3592
|
if (strategy !== SUPPORTED_STRATEGY) {
|
|
3593
|
-
log$
|
|
3593
|
+
log$38.warn("workspace lane strategy denied", {
|
|
3594
3594
|
agentId,
|
|
3595
3595
|
strategy
|
|
3596
3596
|
});
|
|
@@ -3685,7 +3685,7 @@ async function resolveWorkspaceLaneForTurn(params) {
|
|
|
3685
3685
|
if ((config?.create ?? "on-first-message") !== "on-first-message") {
|
|
3686
3686
|
const pathState = await getExistingPathState(resolution.effectiveWorkspaceDir);
|
|
3687
3687
|
if (pathState !== "directory") {
|
|
3688
|
-
log$
|
|
3688
|
+
log$38.warn("workspace lane manual creation denied", {
|
|
3689
3689
|
agentId: resolution.agentId,
|
|
3690
3690
|
laneId: resolution.laneId,
|
|
3691
3691
|
laneKeySource: resolution.laneKeySource,
|
|
@@ -3711,7 +3711,7 @@ async function resolveWorkspaceLaneForTurn(params) {
|
|
|
3711
3711
|
targetRoot: resolution.effectiveWorkspaceDir,
|
|
3712
3712
|
relativePath: file
|
|
3713
3713
|
});
|
|
3714
|
-
if (decision === "copied" || !existed) log$
|
|
3714
|
+
if (decision === "copied" || !existed) log$38.info("workspace lane seed file decision", {
|
|
3715
3715
|
agentId: resolution.agentId,
|
|
3716
3716
|
laneId: resolution.laneId,
|
|
3717
3717
|
laneKeySource: resolution.laneKeySource,
|
|
@@ -3720,7 +3720,7 @@ async function resolveWorkspaceLaneForTurn(params) {
|
|
|
3720
3720
|
});
|
|
3721
3721
|
}
|
|
3722
3722
|
const created = !existed;
|
|
3723
|
-
if (created) log$
|
|
3723
|
+
if (created) log$38.info("workspace lane created", {
|
|
3724
3724
|
agentId: resolution.agentId,
|
|
3725
3725
|
laneId: resolution.laneId,
|
|
3726
3726
|
laneKeySource: resolution.laneKeySource
|
|
@@ -5176,7 +5176,7 @@ function parseUpdateFileChunk(lines, lineNumber, allowMissingContext) {
|
|
|
5176
5176
|
|
|
5177
5177
|
//#endregion
|
|
5178
5178
|
//#region src/infra/exec-approvals.ts
|
|
5179
|
-
const log$
|
|
5179
|
+
const log$37 = createSubsystemLogger("infra/exec-approvals");
|
|
5180
5180
|
const APPROVALS_FILE = join(process.env.HOME ?? "/tmp", ".openclaw", "exec-approvals.json");
|
|
5181
5181
|
const DEFAULT_SECURITY = "deny";
|
|
5182
5182
|
const DEFAULT_ASK = "on-miss";
|
|
@@ -6729,7 +6729,7 @@ function createRunRegistry(options) {
|
|
|
6729
6729
|
|
|
6730
6730
|
//#endregion
|
|
6731
6731
|
//#region src/process/supervisor/supervisor.ts
|
|
6732
|
-
const log$
|
|
6732
|
+
const log$36 = createSubsystemLogger("process/supervisor");
|
|
6733
6733
|
function clampTimeout(value) {
|
|
6734
6734
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return;
|
|
6735
6735
|
return Math.max(1, Math.floor(value));
|
|
@@ -6915,7 +6915,7 @@ function createProcessSupervisor() {
|
|
|
6915
6915
|
exitCode: null,
|
|
6916
6916
|
exitSignal: null
|
|
6917
6917
|
});
|
|
6918
|
-
log$
|
|
6918
|
+
log$36.warn(`spawn failed: runId=${runId} reason=${String(err)}`);
|
|
6919
6919
|
throw err;
|
|
6920
6920
|
}
|
|
6921
6921
|
};
|
|
@@ -11420,7 +11420,7 @@ function normalizeSystemRunApprovalPlan(value) {
|
|
|
11420
11420
|
|
|
11421
11421
|
//#endregion
|
|
11422
11422
|
//#region src/infra/system-run-command.ts
|
|
11423
|
-
const log$
|
|
11423
|
+
const log$35 = createSubsystemLogger("infra/system-run-command");
|
|
11424
11424
|
function formatExecCommand(argv) {
|
|
11425
11425
|
return argv.map((arg) => {
|
|
11426
11426
|
if (arg.length === 0) return "\"\"";
|
|
@@ -15401,6 +15401,60 @@ async function withAcpRuntimeErrorBoundary(params) {
|
|
|
15401
15401
|
}
|
|
15402
15402
|
}
|
|
15403
15403
|
|
|
15404
|
+
//#endregion
|
|
15405
|
+
//#region src/acp/runtime/registry.ts
|
|
15406
|
+
const ACP_RUNTIME_REGISTRY_STATE_KEY = Symbol.for("openclaw.acpRuntimeRegistryState");
|
|
15407
|
+
function createAcpRuntimeRegistryGlobalState() {
|
|
15408
|
+
return { backendsById: /* @__PURE__ */ new Map() };
|
|
15409
|
+
}
|
|
15410
|
+
function resolveAcpRuntimeRegistryGlobalState() {
|
|
15411
|
+
const runtimeGlobal = globalThis;
|
|
15412
|
+
if (!runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY]) runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY] = createAcpRuntimeRegistryGlobalState();
|
|
15413
|
+
return runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY];
|
|
15414
|
+
}
|
|
15415
|
+
const ACP_BACKENDS_BY_ID = resolveAcpRuntimeRegistryGlobalState().backendsById;
|
|
15416
|
+
function normalizeBackendId(id) {
|
|
15417
|
+
return id?.trim().toLowerCase() || "";
|
|
15418
|
+
}
|
|
15419
|
+
function isBackendHealthy(backend) {
|
|
15420
|
+
if (!backend.healthy) return true;
|
|
15421
|
+
try {
|
|
15422
|
+
return backend.healthy();
|
|
15423
|
+
} catch {
|
|
15424
|
+
return false;
|
|
15425
|
+
}
|
|
15426
|
+
}
|
|
15427
|
+
function getAcpRuntimeBackend(id) {
|
|
15428
|
+
const normalized = normalizeBackendId(id);
|
|
15429
|
+
if (normalized) return ACP_BACKENDS_BY_ID.get(normalized) ?? null;
|
|
15430
|
+
if (ACP_BACKENDS_BY_ID.size === 0) return null;
|
|
15431
|
+
for (const backend of ACP_BACKENDS_BY_ID.values()) if (isBackendHealthy(backend)) return backend;
|
|
15432
|
+
return ACP_BACKENDS_BY_ID.values().next().value ?? null;
|
|
15433
|
+
}
|
|
15434
|
+
function requireAcpRuntimeBackend(id) {
|
|
15435
|
+
const normalized = normalizeBackendId(id);
|
|
15436
|
+
const backend = getAcpRuntimeBackend(normalized || void 0);
|
|
15437
|
+
if (!backend) throw new AcpRuntimeError("ACP_BACKEND_MISSING", "ACP runtime backend is not configured. Install and enable the acpx runtime plugin.");
|
|
15438
|
+
if (!isBackendHealthy(backend)) throw new AcpRuntimeError("ACP_BACKEND_UNAVAILABLE", "ACP runtime backend is currently unavailable. Try again in a moment.");
|
|
15439
|
+
if (normalized && backend.id !== normalized) throw new AcpRuntimeError("ACP_BACKEND_MISSING", `ACP runtime backend "${normalized}" is not registered.`);
|
|
15440
|
+
return backend;
|
|
15441
|
+
}
|
|
15442
|
+
async function waitForAcpRuntimeBackendHealthy(params) {
|
|
15443
|
+
const normalized = normalizeBackendId(params.id);
|
|
15444
|
+
const pollMs = params.pollMs ?? 250;
|
|
15445
|
+
const deadline = Date.now() + params.timeoutMs;
|
|
15446
|
+
for (;;) {
|
|
15447
|
+
const backend = getAcpRuntimeBackend(normalized || void 0);
|
|
15448
|
+
if (!backend) return false;
|
|
15449
|
+
if (isBackendHealthy(backend)) return true;
|
|
15450
|
+
const remainingMs = deadline - Date.now();
|
|
15451
|
+
if (remainingMs <= 0) return false;
|
|
15452
|
+
await new Promise((resolve) => {
|
|
15453
|
+
setTimeout(resolve, Math.min(pollMs, remainingMs)).unref();
|
|
15454
|
+
});
|
|
15455
|
+
}
|
|
15456
|
+
}
|
|
15457
|
+
|
|
15404
15458
|
//#endregion
|
|
15405
15459
|
//#region src/acp/runtime/session-identity.ts
|
|
15406
15460
|
function normalizeText$2(value) {
|
|
@@ -15913,45 +15967,6 @@ async function applyManagerRuntimeControls(params) {
|
|
|
15913
15967
|
if (cached) cached.appliedControlSignature = signature;
|
|
15914
15968
|
}
|
|
15915
15969
|
|
|
15916
|
-
//#endregion
|
|
15917
|
-
//#region src/acp/runtime/registry.ts
|
|
15918
|
-
const ACP_RUNTIME_REGISTRY_STATE_KEY = Symbol.for("openclaw.acpRuntimeRegistryState");
|
|
15919
|
-
function createAcpRuntimeRegistryGlobalState() {
|
|
15920
|
-
return { backendsById: /* @__PURE__ */ new Map() };
|
|
15921
|
-
}
|
|
15922
|
-
function resolveAcpRuntimeRegistryGlobalState() {
|
|
15923
|
-
const runtimeGlobal = globalThis;
|
|
15924
|
-
if (!runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY]) runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY] = createAcpRuntimeRegistryGlobalState();
|
|
15925
|
-
return runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY];
|
|
15926
|
-
}
|
|
15927
|
-
const ACP_BACKENDS_BY_ID = resolveAcpRuntimeRegistryGlobalState().backendsById;
|
|
15928
|
-
function normalizeBackendId(id) {
|
|
15929
|
-
return id?.trim().toLowerCase() || "";
|
|
15930
|
-
}
|
|
15931
|
-
function isBackendHealthy(backend) {
|
|
15932
|
-
if (!backend.healthy) return true;
|
|
15933
|
-
try {
|
|
15934
|
-
return backend.healthy();
|
|
15935
|
-
} catch {
|
|
15936
|
-
return false;
|
|
15937
|
-
}
|
|
15938
|
-
}
|
|
15939
|
-
function getAcpRuntimeBackend(id) {
|
|
15940
|
-
const normalized = normalizeBackendId(id);
|
|
15941
|
-
if (normalized) return ACP_BACKENDS_BY_ID.get(normalized) ?? null;
|
|
15942
|
-
if (ACP_BACKENDS_BY_ID.size === 0) return null;
|
|
15943
|
-
for (const backend of ACP_BACKENDS_BY_ID.values()) if (isBackendHealthy(backend)) return backend;
|
|
15944
|
-
return ACP_BACKENDS_BY_ID.values().next().value ?? null;
|
|
15945
|
-
}
|
|
15946
|
-
function requireAcpRuntimeBackend(id) {
|
|
15947
|
-
const normalized = normalizeBackendId(id);
|
|
15948
|
-
const backend = getAcpRuntimeBackend(normalized || void 0);
|
|
15949
|
-
if (!backend) throw new AcpRuntimeError("ACP_BACKEND_MISSING", "ACP runtime backend is not configured. Install and enable the acpx runtime plugin.");
|
|
15950
|
-
if (!isBackendHealthy(backend)) throw new AcpRuntimeError("ACP_BACKEND_UNAVAILABLE", "ACP runtime backend is currently unavailable. Try again in a moment.");
|
|
15951
|
-
if (normalized && backend.id !== normalized) throw new AcpRuntimeError("ACP_BACKEND_MISSING", `ACP runtime backend "${normalized}" is not registered.`);
|
|
15952
|
-
return backend;
|
|
15953
|
-
}
|
|
15954
|
-
|
|
15955
15970
|
//#endregion
|
|
15956
15971
|
//#region src/agents/session-dirs.ts
|
|
15957
15972
|
async function resolveAgentSessionDirs(stateDir) {
|
|
@@ -16152,6 +16167,9 @@ var SessionActorQueue = class {
|
|
|
16152
16167
|
|
|
16153
16168
|
//#endregion
|
|
16154
16169
|
//#region src/acp/control-plane/manager.core.ts
|
|
16170
|
+
const log$34 = createSubsystemLogger("acp/manager");
|
|
16171
|
+
const STARTUP_RECONCILE_BACKEND_WAIT_MS = 3e4;
|
|
16172
|
+
const STARTUP_RECONCILE_BACKEND_POLL_MS = 250;
|
|
16155
16173
|
var AcpSessionManager = class {
|
|
16156
16174
|
constructor(deps = DEFAULT_DEPS) {
|
|
16157
16175
|
this.deps = deps;
|
|
@@ -16229,34 +16247,54 @@ var AcpSessionManager = class {
|
|
|
16229
16247
|
failed: failed + 1
|
|
16230
16248
|
};
|
|
16231
16249
|
}
|
|
16250
|
+
const logFailure = (sessionKey, acpError) => {
|
|
16251
|
+
const redactedKey = redactIdentifier(sessionKey);
|
|
16252
|
+
log$34.warn(`startup identity reconcile failed for ${redactedKey}: code=${acpError.code} ${acpError.message.replaceAll(sessionKey, redactedKey)}`);
|
|
16253
|
+
};
|
|
16254
|
+
const toReconcileError = (error) => toAcpRuntimeError({
|
|
16255
|
+
error,
|
|
16256
|
+
fallbackCode: "ACP_SESSION_INIT_FAILED",
|
|
16257
|
+
fallbackMessage: "ACP startup identity reconcile failed."
|
|
16258
|
+
});
|
|
16259
|
+
const deferred = [];
|
|
16232
16260
|
for (const session of acpSessions) {
|
|
16233
16261
|
if (!session.acp || !session.sessionKey) continue;
|
|
16234
16262
|
if (!isSessionIdentityPending(resolveSessionIdentityFromMeta(session.acp))) continue;
|
|
16235
16263
|
checked += 1;
|
|
16236
16264
|
try {
|
|
16237
|
-
if (await this.
|
|
16238
|
-
|
|
16239
|
-
|
|
16240
|
-
|
|
16241
|
-
|
|
16242
|
-
if (resolution.kind !== "ready") return false;
|
|
16243
|
-
const { runtime, handle, meta } = await this.ensureRuntimeHandle({
|
|
16244
|
-
cfg: params.cfg,
|
|
16265
|
+
if (await this.reconcileOneSessionIdentity(params.cfg, session.sessionKey)) resolved += 1;
|
|
16266
|
+
} catch (error) {
|
|
16267
|
+
const acpError = toReconcileError(error);
|
|
16268
|
+
if (acpError.code === "ACP_BACKEND_UNAVAILABLE") {
|
|
16269
|
+
deferred.push({
|
|
16245
16270
|
sessionKey: session.sessionKey,
|
|
16246
|
-
|
|
16271
|
+
backend: (session.acp.backend || params.cfg.acp?.backend || "").trim()
|
|
16247
16272
|
});
|
|
16248
|
-
|
|
16249
|
-
|
|
16250
|
-
sessionKey: session.sessionKey,
|
|
16251
|
-
runtime,
|
|
16252
|
-
handle,
|
|
16253
|
-
meta,
|
|
16254
|
-
failOnStatusError: false
|
|
16255
|
-
})).meta));
|
|
16256
|
-
})) resolved += 1;
|
|
16257
|
-
} catch (error) {
|
|
16273
|
+
continue;
|
|
16274
|
+
}
|
|
16258
16275
|
failed += 1;
|
|
16259
|
-
|
|
16276
|
+
logFailure(session.sessionKey, acpError);
|
|
16277
|
+
}
|
|
16278
|
+
}
|
|
16279
|
+
if (deferred.length > 0) {
|
|
16280
|
+
const backendIds = [...new Set(deferred.map(({ backend }) => backend))];
|
|
16281
|
+
const healthyByBackend = new Map(await Promise.all(backendIds.map(async (backend) => [backend, await waitForAcpRuntimeBackendHealthy({
|
|
16282
|
+
id: backend || void 0,
|
|
16283
|
+
timeoutMs: params.backendWaitMs ?? STARTUP_RECONCILE_BACKEND_WAIT_MS,
|
|
16284
|
+
pollMs: params.backendPollMs ?? STARTUP_RECONCILE_BACKEND_POLL_MS
|
|
16285
|
+
})])));
|
|
16286
|
+
for (const { sessionKey, backend } of deferred) {
|
|
16287
|
+
if (!healthyByBackend.get(backend)) {
|
|
16288
|
+
failed += 1;
|
|
16289
|
+
logFailure(sessionKey, new AcpRuntimeError("ACP_BACKEND_UNAVAILABLE", `ACP runtime backend${backend ? ` "${backend}"` : ""} did not become healthy before the startup wait expired.`));
|
|
16290
|
+
continue;
|
|
16291
|
+
}
|
|
16292
|
+
try {
|
|
16293
|
+
if (await this.reconcileOneSessionIdentity(params.cfg, sessionKey)) resolved += 1;
|
|
16294
|
+
} catch (error) {
|
|
16295
|
+
failed += 1;
|
|
16296
|
+
logFailure(sessionKey, toReconcileError(error));
|
|
16297
|
+
}
|
|
16260
16298
|
}
|
|
16261
16299
|
}
|
|
16262
16300
|
return {
|
|
@@ -16265,6 +16303,37 @@ var AcpSessionManager = class {
|
|
|
16265
16303
|
failed
|
|
16266
16304
|
};
|
|
16267
16305
|
}
|
|
16306
|
+
async reconcileOneSessionIdentity(cfg, sessionKey) {
|
|
16307
|
+
return await this.withSessionActor(sessionKey, async () => {
|
|
16308
|
+
const resolution = this.resolveSession({
|
|
16309
|
+
cfg,
|
|
16310
|
+
sessionKey
|
|
16311
|
+
});
|
|
16312
|
+
if (resolution.kind !== "ready") return false;
|
|
16313
|
+
const { runtime, handle, meta } = await this.ensureRuntimeHandle({
|
|
16314
|
+
cfg,
|
|
16315
|
+
sessionKey,
|
|
16316
|
+
meta: resolution.meta
|
|
16317
|
+
});
|
|
16318
|
+
try {
|
|
16319
|
+
return !isSessionIdentityPending(resolveSessionIdentityFromMeta((await this.reconcileRuntimeSessionIdentifiers({
|
|
16320
|
+
cfg,
|
|
16321
|
+
sessionKey,
|
|
16322
|
+
runtime,
|
|
16323
|
+
handle,
|
|
16324
|
+
meta,
|
|
16325
|
+
failOnStatusError: true
|
|
16326
|
+
})).meta));
|
|
16327
|
+
} catch (error) {
|
|
16328
|
+
const stored = this.deps.readSessionEntry({
|
|
16329
|
+
cfg,
|
|
16330
|
+
sessionKey
|
|
16331
|
+
})?.acp;
|
|
16332
|
+
if (stored && !isSessionIdentityPending(resolveSessionIdentityFromMeta(stored))) return true;
|
|
16333
|
+
throw error;
|
|
16334
|
+
}
|
|
16335
|
+
});
|
|
16336
|
+
}
|
|
16268
16337
|
async initializeSession(input) {
|
|
16269
16338
|
const sessionKey = normalizeSessionKey$1(input.sessionKey);
|
|
16270
16339
|
if (!sessionKey) throw new AcpRuntimeError("ACP_SESSION_INIT_FAILED", "ACP session key is required.");
|
|
@@ -23905,7 +23974,7 @@ const FIELD_LABELS = {
|
|
|
23905
23974
|
|
|
23906
23975
|
//#endregion
|
|
23907
23976
|
//#region src/config/schema.hints.ts
|
|
23908
|
-
const log$
|
|
23977
|
+
const log$33 = createSubsystemLogger("config/schema");
|
|
23909
23978
|
const NORMALIZED_SENSITIVE_KEY_WHITELIST_SUFFIXES = [
|
|
23910
23979
|
"maxtokens",
|
|
23911
23980
|
"maxoutputtokens",
|
|
@@ -23946,7 +24015,7 @@ function isSensitiveConfigPath(path) {
|
|
|
23946
24015
|
|
|
23947
24016
|
//#endregion
|
|
23948
24017
|
//#region src/config/redact-snapshot.ts
|
|
23949
|
-
const log$
|
|
24018
|
+
const log$32 = createSubsystemLogger("config/redaction");
|
|
23950
24019
|
const ENV_VAR_PLACEHOLDER_PATTERN = /^\$\{[^}]*\}$/;
|
|
23951
24020
|
function isSensitivePath(path) {
|
|
23952
24021
|
if (path.endsWith("[]")) return isSensitiveConfigPath(path.slice(0, -2));
|
|
@@ -30645,7 +30714,7 @@ async function handleSubagentsLogAction(ctx) {
|
|
|
30645
30714
|
|
|
30646
30715
|
//#endregion
|
|
30647
30716
|
//#region src/agents/pi-embedded-runner/logger.ts
|
|
30648
|
-
const log$
|
|
30717
|
+
const log$31 = createSubsystemLogger("agent/embedded");
|
|
30649
30718
|
|
|
30650
30719
|
//#endregion
|
|
30651
30720
|
//#region src/agents/pi-embedded-runner/run-sender-identity.ts
|
|
@@ -30690,7 +30759,7 @@ function resolveRunSenderIdentity(params) {
|
|
|
30690
30759
|
candidate: params.inheritedCanonicalIdentity
|
|
30691
30760
|
});
|
|
30692
30761
|
if (inherited) {
|
|
30693
|
-
log$
|
|
30762
|
+
log$31.info("runtime identity injected", {
|
|
30694
30763
|
identitySource: "parent-session",
|
|
30695
30764
|
canonicalIdentity: inherited,
|
|
30696
30765
|
trigger: params.trigger,
|
|
@@ -30709,7 +30778,7 @@ function resolveRunSenderIdentity(params) {
|
|
|
30709
30778
|
candidate: params.configuredIdentity
|
|
30710
30779
|
});
|
|
30711
30780
|
if (configured) {
|
|
30712
|
-
log$
|
|
30781
|
+
log$31.info("runtime identity injected", {
|
|
30713
30782
|
identitySource: "job-config",
|
|
30714
30783
|
canonicalIdentity: configured,
|
|
30715
30784
|
trigger: params.trigger,
|
|
@@ -36778,7 +36847,7 @@ const REMINDER_CONTEXT_MESSAGES_MAX = 10;
|
|
|
36778
36847
|
const REMINDER_CONTEXT_PER_MESSAGE_MAX = 220;
|
|
36779
36848
|
const REMINDER_CONTEXT_TOTAL_MAX = 700;
|
|
36780
36849
|
const REMINDER_CONTEXT_MARKER = "\n\nRecent context:\n";
|
|
36781
|
-
const log$
|
|
36850
|
+
const log$30 = createSubsystemLogger("cron-tool");
|
|
36782
36851
|
const AGENT_FORBIDDEN_JOB_FIELDS = new Set(["identity", "state"]);
|
|
36783
36852
|
const JOB_KEYS = new Set([
|
|
36784
36853
|
"name",
|
|
@@ -36914,7 +36983,7 @@ async function buildReminderContextLines(params) {
|
|
|
36914
36983
|
}
|
|
36915
36984
|
return lines;
|
|
36916
36985
|
} catch (err) {
|
|
36917
|
-
log$
|
|
36986
|
+
log$30.warn("reminder context fetch failed", { error: err });
|
|
36918
36987
|
return ["- (context unavailable: gateway unreachable)"];
|
|
36919
36988
|
}
|
|
36920
36989
|
}
|
|
@@ -37470,7 +37539,7 @@ function assertGatewayToolActionAllowed(params) {
|
|
|
37470
37539
|
|
|
37471
37540
|
//#endregion
|
|
37472
37541
|
//#region src/agents/tools/gateway-tool.ts
|
|
37473
|
-
const log$
|
|
37542
|
+
const log$29 = createSubsystemLogger("gateway-tool");
|
|
37474
37543
|
const DEFAULT_UPDATE_TIMEOUT_MS = 20 * 6e4;
|
|
37475
37544
|
const GatewayToolSchema = Type.Object({
|
|
37476
37545
|
action: stringEnum([
|
|
@@ -37538,7 +37607,7 @@ function createGatewayTool(opts) {
|
|
|
37538
37607
|
try {
|
|
37539
37608
|
await writeRestartSentinel(payload);
|
|
37540
37609
|
} catch {}
|
|
37541
|
-
log$
|
|
37610
|
+
log$29.info(`gateway tool: restart requested (delayMs=${delayMs ?? "default"}, reason=${reason ?? "none"})`);
|
|
37542
37611
|
return jsonResult(scheduleGatewaySigusr1Restart({
|
|
37543
37612
|
delayMs,
|
|
37544
37613
|
reason
|
|
@@ -44450,7 +44519,7 @@ async function resolveAnnounceTarget(params) {
|
|
|
44450
44519
|
|
|
44451
44520
|
//#endregion
|
|
44452
44521
|
//#region src/agents/tools/sessions-send-tool.a2a.ts
|
|
44453
|
-
const log$
|
|
44522
|
+
const log$28 = createSubsystemLogger("agents/sessions-send");
|
|
44454
44523
|
async function runSessionsSendA2AFlow(params) {
|
|
44455
44524
|
const runContextId = params.waitRunId ?? "unknown";
|
|
44456
44525
|
try {
|
|
@@ -44545,7 +44614,7 @@ async function runSessionsSendA2AFlow(params) {
|
|
|
44545
44614
|
timeoutMs: 1e4
|
|
44546
44615
|
});
|
|
44547
44616
|
} catch (err) {
|
|
44548
|
-
log$
|
|
44617
|
+
log$28.warn("sessions_send announce delivery failed", {
|
|
44549
44618
|
runId: runContextId,
|
|
44550
44619
|
channel: announceTarget.channel,
|
|
44551
44620
|
to: announceTarget.to,
|
|
@@ -44553,7 +44622,7 @@ async function runSessionsSendA2AFlow(params) {
|
|
|
44553
44622
|
});
|
|
44554
44623
|
}
|
|
44555
44624
|
} catch (err) {
|
|
44556
|
-
log$
|
|
44625
|
+
log$28.warn("sessions_send announce flow failed", {
|
|
44557
44626
|
runId: runContextId,
|
|
44558
44627
|
error: formatErrorMessage(err)
|
|
44559
44628
|
});
|
|
@@ -45333,7 +45402,7 @@ const BACKGROUND_IDLE_RECHECK_MS = 1e3;
|
|
|
45333
45402
|
const BACKGROUND_IDLE_MAX_ATTEMPTS = 30;
|
|
45334
45403
|
const backgroundIdleAttempts = /* @__PURE__ */ new Map();
|
|
45335
45404
|
const SIGNAL_DEADLINE_GRACE_MS = 0;
|
|
45336
|
-
const log$
|
|
45405
|
+
const log$27 = createSubsystemLogger("agent-signals");
|
|
45337
45406
|
function normalizeTrimmed(value) {
|
|
45338
45407
|
return value?.trim() || void 0;
|
|
45339
45408
|
}
|
|
@@ -45619,7 +45688,7 @@ function dispatchHeartbeatSignal(signal, now = Date.now()) {
|
|
|
45619
45688
|
if (!signal.sessionKey) return false;
|
|
45620
45689
|
if (signal.requiresIdle === true) {
|
|
45621
45690
|
if (signal.notBeforeMs !== void 0 && now > signal.notBeforeMs + SIGNAL_DEADLINE_GRACE_MS) {
|
|
45622
|
-
log$
|
|
45691
|
+
log$27.warn("agent-signals: evicting requiresIdle heartbeat signal past its deadline", {
|
|
45623
45692
|
signalId: signal.id,
|
|
45624
45693
|
type: signal.type,
|
|
45625
45694
|
source: signal.source,
|
|
@@ -48563,7 +48632,7 @@ function resolveRunWorkspaceDir(params) {
|
|
|
48563
48632
|
|
|
48564
48633
|
//#endregion
|
|
48565
48634
|
//#region src/agents/cli-runner.ts
|
|
48566
|
-
const log$
|
|
48635
|
+
const log$26 = createSubsystemLogger("agent/claude-cli");
|
|
48567
48636
|
async function runCliAgent(params) {
|
|
48568
48637
|
const started = Date.now();
|
|
48569
48638
|
const workspaceResolution = resolveRunWorkspaceDir({
|
|
@@ -48576,7 +48645,7 @@ async function runCliAgent(params) {
|
|
|
48576
48645
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
48577
48646
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
48578
48647
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
48579
|
-
if (workspaceResolution.usedFallback) log$
|
|
48648
|
+
if (workspaceResolution.usedFallback) log$26.warn(`[workspace-fallback] caller=runCliAgent reason=${workspaceResolution.fallbackReason} run=${params.runId} session=${redactedSessionId} sessionKey=${redactedSessionKey} agent=${workspaceResolution.agentId} workspace=${redactedWorkspace}`);
|
|
48580
48649
|
const workspaceDir = resolvedWorkspace;
|
|
48581
48650
|
const backendResolved = resolveCliBackendConfig(params.provider, params.config);
|
|
48582
48651
|
if (!backendResolved) throw new Error(`Unknown CLI backend: ${params.provider}`);
|
|
@@ -48606,7 +48675,7 @@ async function runCliAgent(params) {
|
|
|
48606
48675
|
resolvedSystemPrompt,
|
|
48607
48676
|
warn: makeBootstrapWarn({
|
|
48608
48677
|
sessionLabel,
|
|
48609
|
-
warn: (message) => log$
|
|
48678
|
+
warn: (message) => log$26.warn(message)
|
|
48610
48679
|
})
|
|
48611
48680
|
});
|
|
48612
48681
|
const heartbeatPrompt = sessionAgentId === defaultAgentId ? resolveHeartbeatPrompt$1(params.config?.agents?.defaults?.heartbeat?.prompt) : void 0;
|
|
@@ -48669,7 +48738,7 @@ async function runCliAgent(params) {
|
|
|
48669
48738
|
const queueKey = backend.serialize ?? true ? backendResolved.id : `${backendResolved.id}:${params.runId}`;
|
|
48670
48739
|
try {
|
|
48671
48740
|
return await enqueueCliRun(queueKey, async () => {
|
|
48672
|
-
log$
|
|
48741
|
+
log$26.info(`cli exec: provider=${params.provider} model=${normalizedModel} promptChars=${params.prompt.length}`);
|
|
48673
48742
|
const logOutputText = isTruthyEnvValue(process.env.OPENCLAW_CLAUDE_CLI_LOG_OUTPUT);
|
|
48674
48743
|
if (logOutputText) {
|
|
48675
48744
|
const logArgs = [];
|
|
@@ -48702,7 +48771,7 @@ async function runCliAgent(params) {
|
|
|
48702
48771
|
const promptIndex = logArgs.indexOf(argsPrompt);
|
|
48703
48772
|
if (promptIndex >= 0) logArgs[promptIndex] = `<prompt:${argsPrompt.length} chars>`;
|
|
48704
48773
|
}
|
|
48705
|
-
log$
|
|
48774
|
+
log$26.info(`cli argv: ${backend.command} ${logArgs.join(" ")}`);
|
|
48706
48775
|
}
|
|
48707
48776
|
const env = (() => {
|
|
48708
48777
|
const next = {
|
|
@@ -48740,17 +48809,17 @@ async function runCliAgent(params) {
|
|
|
48740
48809
|
const stdout = result.stdout.trim();
|
|
48741
48810
|
const stderr = result.stderr.trim();
|
|
48742
48811
|
if (logOutputText) {
|
|
48743
|
-
if (stdout) log$
|
|
48744
|
-
if (stderr) log$
|
|
48812
|
+
if (stdout) log$26.info(`cli stdout:\n${stdout}`);
|
|
48813
|
+
if (stderr) log$26.info(`cli stderr:\n${stderr}`);
|
|
48745
48814
|
}
|
|
48746
48815
|
if (shouldLogVerbose()) {
|
|
48747
|
-
if (stdout) log$
|
|
48748
|
-
if (stderr) log$
|
|
48816
|
+
if (stdout) log$26.debug(`cli stdout:\n${stdout}`);
|
|
48817
|
+
if (stderr) log$26.debug(`cli stderr:\n${stderr}`);
|
|
48749
48818
|
}
|
|
48750
48819
|
if (result.exitCode !== 0 || result.reason !== "exit") {
|
|
48751
48820
|
if (result.reason === "no-output-timeout" || result.noOutputTimedOut) {
|
|
48752
48821
|
const timeoutReason = `CLI produced no output for ${Math.round(noOutputTimeoutMs / 1e3)}s and was terminated.`;
|
|
48753
|
-
log$
|
|
48822
|
+
log$26.warn(`cli watchdog timeout: provider=${params.provider} model=${modelId} session=${resolvedSessionId ?? params.sessionId} noOutputTimeoutMs=${noOutputTimeoutMs} pid=${managedRun.pid ?? "unknown"}`);
|
|
48754
48823
|
throw new FailoverError(timeoutReason, {
|
|
48755
48824
|
reason: "timeout",
|
|
48756
48825
|
provider: params.provider,
|
|
@@ -48804,7 +48873,7 @@ async function runCliAgent(params) {
|
|
|
48804
48873
|
} catch (err) {
|
|
48805
48874
|
if (err instanceof FailoverError) {
|
|
48806
48875
|
if (err.reason === "session_expired" && params.cliSessionId && params.sessionKey) {
|
|
48807
|
-
log$
|
|
48876
|
+
log$26.warn(`CLI session expired, clearing session ID and retrying: provider=${params.provider} session=${redactRunIdentifier(params.cliSessionId)}`);
|
|
48808
48877
|
const output = await executeCliWithSession(void 0);
|
|
48809
48878
|
const text = output.text?.trim();
|
|
48810
48879
|
return {
|
|
@@ -49384,7 +49453,7 @@ function createBlockReplyDeliveryHandler(params) {
|
|
|
49384
49453
|
* every turn the queue-drain path starts later (a `sessions.steer` mode "queue" follow-up and
|
|
49385
49454
|
* every channel follow-up ride the same drain).
|
|
49386
49455
|
*/
|
|
49387
|
-
const log$
|
|
49456
|
+
const log$25 = createSubsystemLogger("auto-reply/session-run-recording");
|
|
49388
49457
|
const NO_RECORDING = {
|
|
49389
49458
|
complete: async () => {},
|
|
49390
49459
|
fail: async () => {},
|
|
@@ -49415,7 +49484,7 @@ async function beginTurnSessionRun(params) {
|
|
|
49415
49484
|
sessionKey
|
|
49416
49485
|
});
|
|
49417
49486
|
} catch (error) {
|
|
49418
|
-
log$
|
|
49487
|
+
log$25.warn("session-run recording unavailable for this turn", {
|
|
49419
49488
|
runId: params.runId,
|
|
49420
49489
|
error: error instanceof Error ? error.message : String(error)
|
|
49421
49490
|
});
|
|
@@ -50248,7 +50317,7 @@ function repairToolUseResultPairing(messages) {
|
|
|
50248
50317
|
|
|
50249
50318
|
//#endregion
|
|
50250
50319
|
//#region src/agents/compaction.ts
|
|
50251
|
-
const log$
|
|
50320
|
+
const log$24 = createSubsystemLogger("compaction");
|
|
50252
50321
|
const BASE_CHUNK_RATIO = .4;
|
|
50253
50322
|
const MIN_CHUNK_RATIO = .15;
|
|
50254
50323
|
const SAFETY_MARGIN = 1.2;
|
|
@@ -50374,7 +50443,7 @@ async function summarizeWithFallback(params) {
|
|
|
50374
50443
|
try {
|
|
50375
50444
|
return await summarizeChunks(params);
|
|
50376
50445
|
} catch (fullError) {
|
|
50377
|
-
log$
|
|
50446
|
+
log$24.warn(`Full summarization failed, trying partial: ${fullError instanceof Error ? fullError.message : String(fullError)}`);
|
|
50378
50447
|
}
|
|
50379
50448
|
const smallMessages = [];
|
|
50380
50449
|
const oversizedNotes = [];
|
|
@@ -50389,7 +50458,7 @@ async function summarizeWithFallback(params) {
|
|
|
50389
50458
|
messages: smallMessages
|
|
50390
50459
|
}) + (oversizedNotes.length > 0 ? `\n\n${oversizedNotes.join("\n")}` : "");
|
|
50391
50460
|
} catch (partialError) {
|
|
50392
|
-
log$
|
|
50461
|
+
log$24.warn(`Partial summarization also failed: ${partialError instanceof Error ? partialError.message : String(partialError)}`);
|
|
50393
50462
|
}
|
|
50394
50463
|
return `Context contained ${messages.length} messages (${oversizedNotes.length} oversized). Summary unavailable due to size limits.`;
|
|
50395
50464
|
}
|
|
@@ -52595,7 +52664,7 @@ async function applyResetModelOverride(params) {
|
|
|
52595
52664
|
//#endregion
|
|
52596
52665
|
//#region src/infra/session-maintenance-warning.ts
|
|
52597
52666
|
const warnedContexts = /* @__PURE__ */ new Map();
|
|
52598
|
-
const log$
|
|
52667
|
+
const log$23 = createSubsystemLogger("session-maintenance-warning");
|
|
52599
52668
|
function shouldSendWarning() {
|
|
52600
52669
|
return !process.env.VITEST && true;
|
|
52601
52670
|
}
|
|
@@ -52666,7 +52735,7 @@ async function deliverSessionMaintenanceWarning(params) {
|
|
|
52666
52735
|
session: outboundSession
|
|
52667
52736
|
});
|
|
52668
52737
|
} catch (err) {
|
|
52669
|
-
log$
|
|
52738
|
+
log$23.warn(`Failed to deliver session maintenance warning: ${String(err)}`);
|
|
52670
52739
|
enqueueSystemEvent(text, { sessionKey: params.sessionKey });
|
|
52671
52740
|
}
|
|
52672
52741
|
}
|
|
@@ -52836,7 +52905,7 @@ function buildSessionEndHookPayload(params) {
|
|
|
52836
52905
|
|
|
52837
52906
|
//#endregion
|
|
52838
52907
|
//#region src/auto-reply/reply/session.ts
|
|
52839
|
-
const log$
|
|
52908
|
+
const log$22 = createSubsystemLogger("session-init");
|
|
52840
52909
|
async function initSessionState(params) {
|
|
52841
52910
|
const { ctx, cfg, commandAuthorized } = params;
|
|
52842
52911
|
const targetSessionKey = ctx.CommandSource === "native" ? ctx.CommandTargetSessionKey?.trim() : void 0;
|
|
@@ -53043,10 +53112,10 @@ async function initSessionState(params) {
|
|
|
53043
53112
|
if (parentSessionKey && parentSessionKey !== sessionKey && sessionStore[parentSessionKey] && !alreadyForked) {
|
|
53044
53113
|
const parentTokens = sessionStore[parentSessionKey].totalTokens ?? 0;
|
|
53045
53114
|
if (parentForkMaxTokens > 0 && parentTokens > parentForkMaxTokens) {
|
|
53046
|
-
log$
|
|
53115
|
+
log$22.warn(`skipping parent fork (parent too large): parentKey=${parentSessionKey} → sessionKey=${sessionKey} parentTokens=${parentTokens} maxTokens=${parentForkMaxTokens}`);
|
|
53047
53116
|
sessionEntry.forkedFromParent = true;
|
|
53048
53117
|
} else {
|
|
53049
|
-
log$
|
|
53118
|
+
log$22.warn(`forking from parent session: parentKey=${parentSessionKey} → sessionKey=${sessionKey} parentTokens=${parentTokens}`);
|
|
53050
53119
|
const forked = await forkSessionFromParent({
|
|
53051
53120
|
parentEntry: sessionStore[parentSessionKey],
|
|
53052
53121
|
agentId,
|
|
@@ -53057,7 +53126,7 @@ async function initSessionState(params) {
|
|
|
53057
53126
|
sessionEntry.sessionId = forked.sessionId;
|
|
53058
53127
|
sessionEntry.sessionFile = forked.sessionFile;
|
|
53059
53128
|
sessionEntry.forkedFromParent = true;
|
|
53060
|
-
log$
|
|
53129
|
+
log$22.warn(`forked session created: file=${forked.sessionFile}`);
|
|
53061
53130
|
}
|
|
53062
53131
|
}
|
|
53063
53132
|
}
|
|
@@ -53932,11 +54001,11 @@ async function getReplyFromConfig(ctx, opts, configOverride) {
|
|
|
53932
54001
|
|
|
53933
54002
|
//#endregion
|
|
53934
54003
|
//#region src/infra/background-run.ts
|
|
53935
|
-
const log$
|
|
54004
|
+
const log$21 = createSubsystemLogger("infra/background-run");
|
|
53936
54005
|
|
|
53937
54006
|
//#endregion
|
|
53938
54007
|
//#region src/infra/heartbeat-active-hours.ts
|
|
53939
|
-
const log$
|
|
54008
|
+
const log$20 = createSubsystemLogger("heartbeat-active-hours");
|
|
53940
54009
|
|
|
53941
54010
|
//#endregion
|
|
53942
54011
|
//#region src/infra/heartbeat-events-filter.ts
|
|
@@ -53989,7 +54058,7 @@ function isCronSystemEvent(evt) {
|
|
|
53989
54058
|
|
|
53990
54059
|
//#endregion
|
|
53991
54060
|
//#region src/infra/heartbeat-events.ts
|
|
53992
|
-
const log$
|
|
54061
|
+
const log$19 = createSubsystemLogger("infra/heartbeat-events");
|
|
53993
54062
|
function resolveIndicatorType(status) {
|
|
53994
54063
|
switch (status) {
|
|
53995
54064
|
case "ok-empty":
|
|
@@ -54011,7 +54080,7 @@ function emitHeartbeatEvent(evt) {
|
|
|
54011
54080
|
for (const listener of listeners) try {
|
|
54012
54081
|
listener(enriched);
|
|
54013
54082
|
} catch (err) {
|
|
54014
|
-
log$
|
|
54083
|
+
log$19.warn("heartbeat event listener threw", { error: err });
|
|
54015
54084
|
}
|
|
54016
54085
|
}
|
|
54017
54086
|
|
|
@@ -54050,7 +54119,7 @@ function resolveHeartbeatVisibility(params) {
|
|
|
54050
54119
|
|
|
54051
54120
|
//#endregion
|
|
54052
54121
|
//#region src/infra/nudge.ts
|
|
54053
|
-
const log$
|
|
54122
|
+
const log$18 = createSubsystemLogger("infra/nudge");
|
|
54054
54123
|
function renderSummary(text, data) {
|
|
54055
54124
|
if (data && Object.keys(data).length > 0) try {
|
|
54056
54125
|
return `${text}\n\nData:\n${JSON.stringify(data, null, 2)}`;
|
|
@@ -54084,14 +54153,14 @@ function requestNudge(input, cfg = loadConfig(), deps) {
|
|
|
54084
54153
|
const enqueue = deps.enqueueAgentTurn;
|
|
54085
54154
|
try {
|
|
54086
54155
|
enqueue(payload).catch((error) => {
|
|
54087
|
-
log$
|
|
54156
|
+
log$18.warn("nudge enqueue failed", {
|
|
54088
54157
|
error,
|
|
54089
54158
|
sessionKey: redactIdentifier(sessionKey),
|
|
54090
54159
|
signalId
|
|
54091
54160
|
});
|
|
54092
54161
|
});
|
|
54093
54162
|
} catch (error) {
|
|
54094
|
-
log$
|
|
54163
|
+
log$18.warn("nudge enqueue failed", {
|
|
54095
54164
|
error,
|
|
54096
54165
|
sessionKey: redactIdentifier(sessionKey),
|
|
54097
54166
|
signalId
|
|
@@ -54108,20 +54177,20 @@ function requestNudge(input, cfg = loadConfig(), deps) {
|
|
|
54108
54177
|
const { backbone, runner } = getAgentTurnRuntime();
|
|
54109
54178
|
const id = await enqueueAgentTurn(backbone, payload);
|
|
54110
54179
|
if (!isClaimableAgentTurnWorkId(id)) return;
|
|
54111
|
-
const { runMainAgentTurn } = await import("./agent-turn-execute-
|
|
54180
|
+
const { runMainAgentTurn } = await import("./agent-turn-execute-B_zIGst3.js");
|
|
54112
54181
|
await runner.claimAndExecute({
|
|
54113
54182
|
workId: id,
|
|
54114
54183
|
execute: (claim) => runMainAgentTurn(claim.message.payload)
|
|
54115
54184
|
});
|
|
54116
54185
|
})().catch((error) => {
|
|
54117
|
-
log$
|
|
54186
|
+
log$18.warn("nudge claim chain failed", {
|
|
54118
54187
|
error,
|
|
54119
54188
|
sessionKey: redactIdentifier(sessionKey),
|
|
54120
54189
|
signalId
|
|
54121
54190
|
});
|
|
54122
54191
|
});
|
|
54123
54192
|
} catch (error) {
|
|
54124
|
-
log$
|
|
54193
|
+
log$18.warn("nudge enqueue failed", {
|
|
54125
54194
|
error,
|
|
54126
54195
|
sessionKey: redactIdentifier(sessionKey),
|
|
54127
54196
|
signalId
|
|
@@ -54136,7 +54205,7 @@ function requestNudge(input, cfg = loadConfig(), deps) {
|
|
|
54136
54205
|
|
|
54137
54206
|
//#endregion
|
|
54138
54207
|
//#region src/infra/wake-gate.ts
|
|
54139
|
-
const log$
|
|
54208
|
+
const log$17 = createSubsystemLogger("wake-gate");
|
|
54140
54209
|
const DEFAULT_COMMAND_TIMEOUT_MS = 3e4;
|
|
54141
54210
|
const DEFAULT_MODEL_TIMEOUT_MS = 3e4;
|
|
54142
54211
|
const MAX_COMMAND_OUTPUT_BYTES = 64 * 1024;
|
|
@@ -54258,7 +54327,7 @@ async function runWakeGate(spec, ctx) {
|
|
|
54258
54327
|
if (spec.kind === "command") return await runCommandGate(spec, ctx);
|
|
54259
54328
|
else return await runModelGate(spec, ctx);
|
|
54260
54329
|
} catch (err) {
|
|
54261
|
-
log$
|
|
54330
|
+
log$17.error("wake-gate error (no crash)", {
|
|
54262
54331
|
kind: spec.kind,
|
|
54263
54332
|
error: err instanceof Error ? err.message : String(err)
|
|
54264
54333
|
});
|
|
@@ -54269,7 +54338,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
54269
54338
|
try {
|
|
54270
54339
|
const result = await runCommand(spec.command, spec.cwd, spec.timeoutMs, _ctx.abortSignal);
|
|
54271
54340
|
if (result.exit !== 0) {
|
|
54272
|
-
log$
|
|
54341
|
+
log$17.warn("wake gate command non-zero exit", {
|
|
54273
54342
|
kind: "command",
|
|
54274
54343
|
exit: result.exit,
|
|
54275
54344
|
...stdoutShapeForLog(result.stdout)
|
|
@@ -54278,7 +54347,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
54278
54347
|
}
|
|
54279
54348
|
const lines = result.stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
54280
54349
|
if (lines.length === 0) {
|
|
54281
|
-
log$
|
|
54350
|
+
log$17.warn("wake gate command produced no output", {
|
|
54282
54351
|
kind: "command",
|
|
54283
54352
|
exit: result.exit,
|
|
54284
54353
|
...stdoutShapeForLog(result.stdout)
|
|
@@ -54288,7 +54357,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
54288
54357
|
const lastLine = lines[lines.length - 1];
|
|
54289
54358
|
const decision = await parseWakeDecision(lastLine);
|
|
54290
54359
|
if (!decision) {
|
|
54291
|
-
log$
|
|
54360
|
+
log$17.warn("wake gate command output did not parse as a wake decision", {
|
|
54292
54361
|
kind: "command",
|
|
54293
54362
|
exit: result.exit,
|
|
54294
54363
|
...stdoutShapeForLog(result.stdout)
|
|
@@ -54296,14 +54365,14 @@ async function runCommandGate(spec, _ctx) {
|
|
|
54296
54365
|
return { wake: false };
|
|
54297
54366
|
}
|
|
54298
54367
|
if (!decision.wakeAgent) {
|
|
54299
|
-
log$
|
|
54368
|
+
log$17.debug("wake gate command decided not to wake", {
|
|
54300
54369
|
kind: "command",
|
|
54301
54370
|
exit: result.exit,
|
|
54302
54371
|
...stdoutShapeForLog(result.stdout)
|
|
54303
54372
|
});
|
|
54304
54373
|
return { wake: false };
|
|
54305
54374
|
}
|
|
54306
|
-
log$
|
|
54375
|
+
log$17.info("wake gate command decided to wake", {
|
|
54307
54376
|
kind: "command",
|
|
54308
54377
|
exit: result.exit,
|
|
54309
54378
|
hasText: decision.text !== void 0,
|
|
@@ -54314,7 +54383,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
54314
54383
|
if (decision.data !== void 0) res.data = decision.data;
|
|
54315
54384
|
return res;
|
|
54316
54385
|
} catch (err) {
|
|
54317
|
-
log$
|
|
54386
|
+
log$17.warn("command gate error", { error: err instanceof Error ? err.message : String(err) });
|
|
54318
54387
|
return { wake: false };
|
|
54319
54388
|
}
|
|
54320
54389
|
}
|
|
@@ -54352,27 +54421,27 @@ async function runModelGate(spec, ctx) {
|
|
|
54352
54421
|
...ctx.abortSignal ? { abortSignal: ctx.abortSignal } : {}
|
|
54353
54422
|
})).payloads ?? []).filter((payload) => !payload.isError && typeof payload.text === "string").map((payload) => payload.text ?? "").join("\n").trim();
|
|
54354
54423
|
if (!modelOutput) {
|
|
54355
|
-
log$
|
|
54424
|
+
log$17.warn("wake gate model produced no output", { kind: "model" });
|
|
54356
54425
|
return { wake: false };
|
|
54357
54426
|
}
|
|
54358
54427
|
const outputLines = modelOutput.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
54359
54428
|
const lastLine = outputLines[outputLines.length - 1] ?? modelOutput;
|
|
54360
54429
|
const decision = await parseWakeDecision(modelOutput) ?? await parseWakeDecision(lastLine);
|
|
54361
54430
|
if (!decision) {
|
|
54362
|
-
log$
|
|
54431
|
+
log$17.warn("wake gate model output did not parse as a wake decision", {
|
|
54363
54432
|
kind: "model",
|
|
54364
54433
|
tail: tailForLog(modelOutput)
|
|
54365
54434
|
});
|
|
54366
54435
|
return { wake: false };
|
|
54367
54436
|
}
|
|
54368
54437
|
if (!decision.wakeAgent) {
|
|
54369
|
-
log$
|
|
54438
|
+
log$17.debug("wake gate model decided not to wake", {
|
|
54370
54439
|
kind: "model",
|
|
54371
54440
|
tail: tailForLog(modelOutput)
|
|
54372
54441
|
});
|
|
54373
54442
|
return { wake: false };
|
|
54374
54443
|
}
|
|
54375
|
-
log$
|
|
54444
|
+
log$17.info("wake gate model decided to wake", {
|
|
54376
54445
|
kind: "model",
|
|
54377
54446
|
hasText: decision.text !== void 0,
|
|
54378
54447
|
hasData: decision.data !== void 0
|
|
@@ -54382,7 +54451,7 @@ async function runModelGate(spec, ctx) {
|
|
|
54382
54451
|
if (decision.data !== void 0) res.data = decision.data;
|
|
54383
54452
|
return res;
|
|
54384
54453
|
} catch (err) {
|
|
54385
|
-
log$
|
|
54454
|
+
log$17.warn("model gate error", { error: err instanceof Error ? err.message : String(err) });
|
|
54386
54455
|
return { wake: false };
|
|
54387
54456
|
} finally {
|
|
54388
54457
|
if (tmpDir) await fs$1.rm(tmpDir, {
|
|
@@ -54394,7 +54463,7 @@ async function runModelGate(spec, ctx) {
|
|
|
54394
54463
|
|
|
54395
54464
|
//#endregion
|
|
54396
54465
|
//#region src/infra/heartbeat-runner.ts
|
|
54397
|
-
const log$
|
|
54466
|
+
const log$16 = createSubsystemLogger("gateway/heartbeat");
|
|
54398
54467
|
const DEFAULT_HEARTBEAT_TARGET = "none";
|
|
54399
54468
|
const redactHeartbeatLogIdentifier = (value) => value?.trim() ? redactIdentifier(value) : null;
|
|
54400
54469
|
function isHeartbeatSessionResolutionError(resolution) {
|
|
@@ -54571,7 +54640,7 @@ async function pruneHeartbeatTranscript(params) {
|
|
|
54571
54640
|
throw err;
|
|
54572
54641
|
}
|
|
54573
54642
|
} catch (err) {
|
|
54574
|
-
log$
|
|
54643
|
+
log$16.warn(`pruneHeartbeatTranscript error: ${err instanceof Error ? err.message : String(err)}`, { transcriptPath });
|
|
54575
54644
|
}
|
|
54576
54645
|
}
|
|
54577
54646
|
/**
|
|
@@ -54811,7 +54880,7 @@ async function prepareHeartbeatDeliveryAndPrompt(params) {
|
|
|
54811
54880
|
reason: HEARTBEAT_SKIP_WAKE_GATE_EMPTY,
|
|
54812
54881
|
durationMs: Date.now() - startedAt
|
|
54813
54882
|
});
|
|
54814
|
-
log$
|
|
54883
|
+
log$16.info("heartbeat: wake gate suppressed run", {
|
|
54815
54884
|
agentId: redactHeartbeatLogIdentifier(agentId),
|
|
54816
54885
|
reason: HEARTBEAT_SKIP_WAKE_GATE_EMPTY
|
|
54817
54886
|
});
|
|
@@ -54822,16 +54891,16 @@ async function prepareHeartbeatDeliveryAndPrompt(params) {
|
|
|
54822
54891
|
}
|
|
54823
54892
|
wakeGateText = wakeResult.data !== void 0 ? `${wakeResult.text ?? ""}\n\nData:\n${JSON.stringify(wakeResult.data, null, 2)}`.trim() : wakeResult.text?.trim() || void 0;
|
|
54824
54893
|
}
|
|
54825
|
-
if (delivery.reason === "unknown-account") log$
|
|
54894
|
+
if (delivery.reason === "unknown-account") log$16.warn("heartbeat: unknown accountId", {
|
|
54826
54895
|
accountId: redactHeartbeatLogIdentifier(delivery.accountId ?? heartbeatAccountId),
|
|
54827
54896
|
target: heartbeat?.target ?? "none"
|
|
54828
54897
|
});
|
|
54829
|
-
else if (heartbeatAccountId) log$
|
|
54898
|
+
else if (heartbeatAccountId) log$16.info("heartbeat: using explicit accountId", {
|
|
54830
54899
|
accountId: redactHeartbeatLogIdentifier(delivery.accountId ?? heartbeatAccountId),
|
|
54831
54900
|
target: heartbeat?.target ?? "none",
|
|
54832
54901
|
channel: delivery.channel
|
|
54833
54902
|
});
|
|
54834
|
-
log$
|
|
54903
|
+
log$16.info("heartbeat: resolved plan", {
|
|
54835
54904
|
agentId: redactHeartbeatLogIdentifier(agentId),
|
|
54836
54905
|
sessionKey: redactHeartbeatLogIdentifier(sessionKey),
|
|
54837
54906
|
sessionSource: preflight.session.source,
|
|
@@ -54906,7 +54975,7 @@ async function resolveHeartbeatPreflightOrSkip(params) {
|
|
|
54906
54975
|
durationMs: Date.now() - startedAt,
|
|
54907
54976
|
indicatorType: resolveIndicatorType("failed")
|
|
54908
54977
|
});
|
|
54909
|
-
log$
|
|
54978
|
+
log$16.error(`heartbeat failed: ${publicReason}`, {
|
|
54910
54979
|
error: publicReason,
|
|
54911
54980
|
agentId: redactHeartbeatLogIdentifier(agentId),
|
|
54912
54981
|
sessionSource: preflight.sessionError.source,
|
|
@@ -54925,7 +54994,7 @@ async function resolveHeartbeatPreflightOrSkip(params) {
|
|
|
54925
54994
|
durationMs: Date.now() - startedAt,
|
|
54926
54995
|
indicatorType: resolveIndicatorType("failed")
|
|
54927
54996
|
});
|
|
54928
|
-
log$
|
|
54997
|
+
log$16.error(`heartbeat failed: ${reason}`, {
|
|
54929
54998
|
error: reason,
|
|
54930
54999
|
agentId: redactHeartbeatLogIdentifier(agentId)
|
|
54931
55000
|
});
|
|
@@ -54962,7 +55031,7 @@ async function loadSharedSessionHeartbeatContext(params) {
|
|
|
54962
55031
|
if (present.length === 0) return;
|
|
54963
55032
|
return present.map((file) => `## ${file.path}\n\n${file.content}`).join("\n\n");
|
|
54964
55033
|
} catch (err) {
|
|
54965
|
-
log$
|
|
55034
|
+
log$16.warn("failed to load heartbeat context files for trigger message", { error: err });
|
|
54966
55035
|
return;
|
|
54967
55036
|
}
|
|
54968
55037
|
}
|
|
@@ -55267,7 +55336,7 @@ async function finalizeTurnOutcome(params) {
|
|
|
55267
55336
|
channel: delivery.channel,
|
|
55268
55337
|
accountId: delivery.accountId
|
|
55269
55338
|
});
|
|
55270
|
-
log$
|
|
55339
|
+
log$16.warn("heartbeat: channel not ready", {
|
|
55271
55340
|
channel: delivery.channel,
|
|
55272
55341
|
reason: readiness.reason
|
|
55273
55342
|
});
|
|
@@ -55355,11 +55424,11 @@ async function cleanupIsolatedHeartbeatSession(params) {
|
|
|
55355
55424
|
restrictToStoreDir: true
|
|
55356
55425
|
});
|
|
55357
55426
|
} catch (archiveErr) {
|
|
55358
|
-
log$
|
|
55427
|
+
log$16.warn(`cron: error-path isolated session archive failed: ${formatErrorMessage(archiveErr)}`, { sessionId: isolatedEntry.sessionId });
|
|
55359
55428
|
}
|
|
55360
55429
|
delete store[createdIsolatedSessionKey];
|
|
55361
55430
|
}).catch((cleanupErr) => {
|
|
55362
|
-
log$
|
|
55431
|
+
log$16.warn(`failed to clean up isolated heartbeat session on error: ${String(cleanupErr)}`);
|
|
55363
55432
|
});
|
|
55364
55433
|
}
|
|
55365
55434
|
async function handleHeartbeatError(params) {
|
|
@@ -55379,7 +55448,7 @@ async function handleHeartbeatError(params) {
|
|
|
55379
55448
|
accountId: delivery.accountId,
|
|
55380
55449
|
indicatorType: visibility.useIndicator ? resolveIndicatorType("failed") : void 0
|
|
55381
55450
|
});
|
|
55382
|
-
log$
|
|
55451
|
+
log$16.error(`heartbeat failed: ${reason}`, { error: reason });
|
|
55383
55452
|
return {
|
|
55384
55453
|
status: "failed",
|
|
55385
55454
|
reason
|
|
@@ -55391,7 +55460,7 @@ async function handleHeartbeatError(params) {
|
|
|
55391
55460
|
const AGENT_TURN_PROMPT = "Process the pending system events for this session.";
|
|
55392
55461
|
async function ackAnnounceExecuted(payload) {
|
|
55393
55462
|
if (payload.kind !== "announce") return;
|
|
55394
|
-
const { markSubagentAnnounceExecuted } = await import("./subagent-registry-
|
|
55463
|
+
const { markSubagentAnnounceExecuted } = await import("./subagent-registry-CoP2z-4v.js");
|
|
55395
55464
|
for (const runId of [payload.runId, ...payload.mergedRunIds ?? []]) try {
|
|
55396
55465
|
await markSubagentAnnounceExecuted(runId);
|
|
55397
55466
|
} catch {}
|
|
@@ -55532,7 +55601,7 @@ async function runMainAgentTurn(payload, opts) {
|
|
|
55532
55601
|
|
|
55533
55602
|
//#endregion
|
|
55534
55603
|
//#region src/agents/subagent-announce-turn.ts
|
|
55535
|
-
const log$
|
|
55604
|
+
const log$15 = createSubsystemLogger("agents/subagent-announce-turn");
|
|
55536
55605
|
function clearDelayedReleaseHoldIfNoAnnounceIsParked(sessionKey) {
|
|
55537
55606
|
if (!peekDelayedAgentTurn(sessionKey, (payload) => payload.kind === "announce")) clearDelayedReleaseHold(sessionKey);
|
|
55538
55607
|
}
|
|
@@ -55592,7 +55661,7 @@ async function publishSubagentAnnounceTurn(params) {
|
|
|
55592
55661
|
};
|
|
55593
55662
|
} catch (error) {
|
|
55594
55663
|
clearDelayedReleaseHoldIfNoAnnounceIsParked(params.requesterSessionKey);
|
|
55595
|
-
log$
|
|
55664
|
+
log$15.warn("subagent announce turn failed", { error: String(error) });
|
|
55596
55665
|
return {
|
|
55597
55666
|
status: "failed",
|
|
55598
55667
|
error: String(error)
|
|
@@ -55639,7 +55708,7 @@ const DIRECT_ANNOUNCE_TRANSIENT_RETRY_DELAYS_MS = FAST_TEST_MODE ? [
|
|
|
55639
55708
|
let subagentRegistryAccessPromise;
|
|
55640
55709
|
const STALLED_SIBLING_ANNOUNCE_HOLD_MS = 5 * 6e4;
|
|
55641
55710
|
function loadSubagentRegistryAccess() {
|
|
55642
|
-
if (!subagentRegistryAccessPromise) subagentRegistryAccessPromise = import("./subagent-registry-
|
|
55711
|
+
if (!subagentRegistryAccessPromise) subagentRegistryAccessPromise = import("./subagent-registry-CoP2z-4v.js").catch((err) => {
|
|
55643
55712
|
const message = err instanceof Error && err.message ? err.message : String(err);
|
|
55644
55713
|
defaultRuntime.log(`[warn] subagent registry access import failed: ${message}`);
|
|
55645
55714
|
subagentRegistryAccessPromise = void 0;
|
|
@@ -58188,7 +58257,7 @@ function wrapToolWithAbortSignal(tool, abortSignal) {
|
|
|
58188
58257
|
|
|
58189
58258
|
//#endregion
|
|
58190
58259
|
//#region src/agents/pi-tools.before-tool-call.ts
|
|
58191
|
-
const log$
|
|
58260
|
+
const log$14 = createSubsystemLogger("agents/tools");
|
|
58192
58261
|
const BEFORE_TOOL_CALL_WRAPPED = Symbol("beforeToolCallWrapped");
|
|
58193
58262
|
const adjustedParamsByToolCallId = /* @__PURE__ */ new Map();
|
|
58194
58263
|
const MAX_TRACKED_ADJUSTED_PARAMS = 1024;
|
|
@@ -58226,7 +58295,7 @@ async function recordLoopOutcome(args) {
|
|
|
58226
58295
|
config: args.ctx.loopDetection
|
|
58227
58296
|
});
|
|
58228
58297
|
} catch (err) {
|
|
58229
|
-
log$
|
|
58298
|
+
log$14.warn(`tool loop outcome tracking failed: tool=${args.toolName} error=${String(err)}`);
|
|
58230
58299
|
}
|
|
58231
58300
|
}
|
|
58232
58301
|
var UserCancelledError = class extends Error {
|
|
@@ -58253,7 +58322,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
58253
58322
|
const loopResult = detectToolCallLoop(sessionState, toolName, params, args.ctx.loopDetection);
|
|
58254
58323
|
if (loopResult.stuck) {
|
|
58255
58324
|
if (loopResult.level === "critical") {
|
|
58256
|
-
log$
|
|
58325
|
+
log$14.error(`Blocking ${toolName} due to critical loop: ${loopResult.message}`);
|
|
58257
58326
|
logToolLoopAction({
|
|
58258
58327
|
sessionKey: args.ctx.sessionKey,
|
|
58259
58328
|
sessionId: args.ctx?.agentId,
|
|
@@ -58271,7 +58340,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
58271
58340
|
reason: loopResult.message
|
|
58272
58341
|
};
|
|
58273
58342
|
} else if (shouldEmitLoopWarning(sessionState, loopResult.warningKey ?? `${loopResult.detector}:${toolName}`, loopResult.count)) {
|
|
58274
|
-
log$
|
|
58343
|
+
log$14.warn(`Loop warning for ${toolName}: ${loopResult.message}`);
|
|
58275
58344
|
logToolLoopAction({
|
|
58276
58345
|
sessionKey: args.ctx.sessionKey,
|
|
58277
58346
|
sessionId: args.ctx?.agentId,
|
|
@@ -58330,7 +58399,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
58330
58399
|
}
|
|
58331
58400
|
} catch (err) {
|
|
58332
58401
|
const toolCallId = args.toolCallId ? ` toolCallId=${args.toolCallId}` : "";
|
|
58333
|
-
log$
|
|
58402
|
+
log$14.warn(`before_tool_call hook failed: tool=${toolName}${toolCallId} error=${String(err)}`);
|
|
58334
58403
|
}
|
|
58335
58404
|
return {
|
|
58336
58405
|
blocked: false,
|
|
@@ -60146,7 +60215,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
60146
60215
|
const textLength = getToolResultTextLength(msg);
|
|
60147
60216
|
if (textLength > maxChars) {
|
|
60148
60217
|
oversizedIndices.push(i);
|
|
60149
|
-
log$
|
|
60218
|
+
log$31.info(`[tool-result-truncation] Found oversized tool result: entry=${entry.id} chars=${textLength} maxChars=${maxChars} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
60150
60219
|
}
|
|
60151
60220
|
}
|
|
60152
60221
|
if (oversizedIndices.length === 0) return {
|
|
@@ -60168,7 +60237,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
60168
60237
|
message = truncateToolResultMessage(message, maxChars);
|
|
60169
60238
|
truncatedCount++;
|
|
60170
60239
|
const newLength = getToolResultTextLength(message);
|
|
60171
|
-
log$
|
|
60240
|
+
log$31.info(`[tool-result-truncation] Truncated tool result: originalEntry=${entry.id} newChars=${newLength} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
60172
60241
|
}
|
|
60173
60242
|
sessionManager.appendMessage(message);
|
|
60174
60243
|
} else if (entry.type === "compaction") sessionManager.appendCompaction(entry.summary, entry.firstKeptEntryId, entry.tokensBefore, entry.details, entry.fromHook);
|
|
@@ -60182,14 +60251,14 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
60182
60251
|
if (entry.name) sessionManager.appendSessionInfo(entry.name);
|
|
60183
60252
|
}
|
|
60184
60253
|
}
|
|
60185
|
-
log$
|
|
60254
|
+
log$31.info(`[tool-result-truncation] Truncated ${truncatedCount} tool result(s) in session (contextWindow=${contextWindowTokens} maxChars=${maxChars}) sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
60186
60255
|
return {
|
|
60187
60256
|
truncated: true,
|
|
60188
60257
|
truncatedCount
|
|
60189
60258
|
};
|
|
60190
60259
|
} catch (err) {
|
|
60191
60260
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
60192
|
-
log$
|
|
60261
|
+
log$31.warn(`[tool-result-truncation] Failed to truncate: ${errMsg}`);
|
|
60193
60262
|
return {
|
|
60194
60263
|
truncated: false,
|
|
60195
60264
|
truncatedCount: 0,
|
|
@@ -60563,7 +60632,7 @@ const getCompactionSafeguardRuntime = registry$1.get;
|
|
|
60563
60632
|
|
|
60564
60633
|
//#endregion
|
|
60565
60634
|
//#region src/agents/pi-extensions/compaction-safeguard.ts
|
|
60566
|
-
const log$
|
|
60635
|
+
const log$13 = createSubsystemLogger("compaction-safeguard");
|
|
60567
60636
|
const missedModelWarningSessions = /* @__PURE__ */ new WeakSet();
|
|
60568
60637
|
const TURN_PREFIX_INSTRUCTIONS = "This summary covers the prefix of a split turn. Focus on the original request, early progress, and any details needed to understand the retained suffix.";
|
|
60569
60638
|
const MAX_TOOL_FAILURES = 8;
|
|
@@ -60672,7 +60741,7 @@ function compactionSafeguardExtension(api) {
|
|
|
60672
60741
|
api.on("session_before_compact", async (event, ctx) => {
|
|
60673
60742
|
const { preparation, customInstructions, signal } = event;
|
|
60674
60743
|
if (!preparation.messagesToSummarize.some(isRealConversationMessage)) {
|
|
60675
|
-
log$
|
|
60744
|
+
log$13.warn("Compaction safeguard: cancelling compaction with no real conversation messages to summarize.");
|
|
60676
60745
|
return { cancel: true };
|
|
60677
60746
|
}
|
|
60678
60747
|
const { readFiles, modifiedFiles } = computeFileLists(preparation.fileOps);
|
|
@@ -60680,7 +60749,7 @@ function compactionSafeguardExtension(api) {
|
|
|
60680
60749
|
const toolFailureSection = formatToolFailuresSection(collectToolFailures([...preparation.messagesToSummarize, ...preparation.turnPrefixMessages]));
|
|
60681
60750
|
const runtime = getCompactionSafeguardRuntime(ctx.sessionManager);
|
|
60682
60751
|
if (runtime?.enabled === false) {
|
|
60683
|
-
log$
|
|
60752
|
+
log$13.info("Compaction safeguard: compaction disabled by config; cancelling.");
|
|
60684
60753
|
return { cancel: true };
|
|
60685
60754
|
}
|
|
60686
60755
|
const summarizationInstructions = {
|
|
@@ -60721,7 +60790,7 @@ function compactionSafeguardExtension(api) {
|
|
|
60721
60790
|
});
|
|
60722
60791
|
if (pruned.droppedChunks > 0) {
|
|
60723
60792
|
const newContentRatio = newContentTokens / contextWindowTokens * 100;
|
|
60724
|
-
log$
|
|
60793
|
+
log$13.warn(`Compaction safeguard: new content uses ${newContentRatio.toFixed(1)}% of context; dropped ${pruned.droppedChunks} older chunk(s) (${pruned.droppedMessages} messages) to fit history budget.`);
|
|
60725
60794
|
messagesToSummarize = pruned.messages;
|
|
60726
60795
|
if (pruned.droppedMessagesList.length > 0) try {
|
|
60727
60796
|
const droppedChunkRatio = computeAdaptiveChunkRatio(pruned.droppedMessagesList, contextWindowTokens);
|
|
@@ -60739,7 +60808,7 @@ function compactionSafeguardExtension(api) {
|
|
|
60739
60808
|
previousSummary: preparation.previousSummary
|
|
60740
60809
|
});
|
|
60741
60810
|
} catch (droppedError) {
|
|
60742
|
-
log$
|
|
60811
|
+
log$13.warn(`Compaction safeguard: failed to summarize dropped messages, continuing without: ${droppedError instanceof Error ? droppedError.message : String(droppedError)}`);
|
|
60743
60812
|
}
|
|
60744
60813
|
}
|
|
60745
60814
|
}
|
|
@@ -60787,7 +60856,7 @@ function compactionSafeguardExtension(api) {
|
|
|
60787
60856
|
}
|
|
60788
60857
|
} };
|
|
60789
60858
|
} catch (error) {
|
|
60790
|
-
log$
|
|
60859
|
+
log$13.warn(`Compaction summarization failed; cancelling compaction to preserve history: ${error instanceof Error ? error.message : String(error)}`);
|
|
60791
60860
|
return { cancel: true };
|
|
60792
60861
|
}
|
|
60793
60862
|
});
|
|
@@ -61518,14 +61587,14 @@ function logToolSchemasForGoogle(params) {
|
|
|
61518
61587
|
if (params.provider !== "google-gemini-cli") return;
|
|
61519
61588
|
const toolNames = params.tools.map((tool, index) => `${index}:${tool.name}`);
|
|
61520
61589
|
const tools = sanitizeToolsForGoogle(params);
|
|
61521
|
-
log$
|
|
61590
|
+
log$31.info("google tool schema snapshot", {
|
|
61522
61591
|
provider: params.provider,
|
|
61523
61592
|
toolCount: tools.length,
|
|
61524
61593
|
tools: toolNames
|
|
61525
61594
|
});
|
|
61526
61595
|
for (const [index, tool] of tools.entries()) {
|
|
61527
61596
|
const violations = findUnsupportedSchemaKeywords(tool.parameters, `${tool.name}.parameters`);
|
|
61528
|
-
if (violations.length > 0) log$
|
|
61597
|
+
if (violations.length > 0) log$31.warn("google tool schema has unsupported keywords", {
|
|
61529
61598
|
index,
|
|
61530
61599
|
tool: tool.name,
|
|
61531
61600
|
violations: violations.slice(0, 12),
|
|
@@ -61537,7 +61606,7 @@ const compactionFailureEmitter = new EventEmitter();
|
|
|
61537
61606
|
registerUnhandledRejectionHandler((reason) => {
|
|
61538
61607
|
const message = describeUnknownError(reason);
|
|
61539
61608
|
if (!isCompactionFailureError(message)) return false;
|
|
61540
|
-
log$
|
|
61609
|
+
log$31.error(`Auto-compaction failed (unhandled): ${message}`);
|
|
61541
61610
|
compactionFailureEmitter.emit("failure", message);
|
|
61542
61611
|
return true;
|
|
61543
61612
|
});
|
|
@@ -61589,7 +61658,7 @@ function applyGoogleTurnOrderingFix(params) {
|
|
|
61589
61658
|
const sanitized = sanitizeGoogleTurnOrdering(params.messages);
|
|
61590
61659
|
const didPrepend = sanitized !== params.messages;
|
|
61591
61660
|
if (didPrepend && !hasGoogleTurnOrderingMarker(params.sessionManager)) {
|
|
61592
|
-
(params.warn ?? ((message) => log$
|
|
61661
|
+
(params.warn ?? ((message) => log$31.warn(message)))(`google turn ordering fixup: prepended user bootstrap (sessionId=${params.sessionId})`);
|
|
61593
61662
|
markGoogleTurnOrderingMarker(params.sessionManager);
|
|
61594
61663
|
}
|
|
61595
61664
|
return {
|
|
@@ -62020,6 +62089,57 @@ async function flushPendingToolResultsAfterIdle(opts) {
|
|
|
62020
62089
|
opts.sessionManager?.flushPendingToolResults?.();
|
|
62021
62090
|
}
|
|
62022
62091
|
|
|
62092
|
+
//#endregion
|
|
62093
|
+
//#region src/agents/pi-embedded-runner/workspace-cwd.ts
|
|
62094
|
+
const log$12 = createSubsystemLogger("agents/workspace-cwd");
|
|
62095
|
+
const holders = [];
|
|
62096
|
+
let baselineCwd;
|
|
62097
|
+
function readCwd() {
|
|
62098
|
+
try {
|
|
62099
|
+
return process.cwd();
|
|
62100
|
+
} catch (err) {
|
|
62101
|
+
log$12.warn("process.cwd() failed; the working directory was removed under the process", { error: String(err) });
|
|
62102
|
+
return;
|
|
62103
|
+
}
|
|
62104
|
+
}
|
|
62105
|
+
function tryChdir(target) {
|
|
62106
|
+
if (readCwd() === target) return true;
|
|
62107
|
+
try {
|
|
62108
|
+
process.chdir(target);
|
|
62109
|
+
return true;
|
|
62110
|
+
} catch (err) {
|
|
62111
|
+
log$12.error("cwd restore target is gone", {
|
|
62112
|
+
target,
|
|
62113
|
+
error: String(err)
|
|
62114
|
+
});
|
|
62115
|
+
return false;
|
|
62116
|
+
}
|
|
62117
|
+
}
|
|
62118
|
+
/**
|
|
62119
|
+
* The cwd is process-global while embedded runs overlap (`agents.defaults.maxConcurrent`
|
|
62120
|
+
* defaults to 4). Each holder gets the cwd on acquire; on release the cwd goes to the most
|
|
62121
|
+
* recent surviving holder's workspace, and to the baseline the first holder found once none
|
|
62122
|
+
* remain. The returned release never throws: a throw from a caller's finally would skip the
|
|
62123
|
+
* rest of it (e.g. clearActiveEmbeddedRun) and leak the run registry entry.
|
|
62124
|
+
*/
|
|
62125
|
+
function acquireWorkspaceCwd(workspaceDir) {
|
|
62126
|
+
if (holders.length === 0) baselineCwd = readCwd() ?? os.tmpdir();
|
|
62127
|
+
if (readCwd() !== workspaceDir) process.chdir(workspaceDir);
|
|
62128
|
+
const holder = { workspaceDir };
|
|
62129
|
+
holders.push(holder);
|
|
62130
|
+
let released = false;
|
|
62131
|
+
return () => {
|
|
62132
|
+
if (released) return;
|
|
62133
|
+
released = true;
|
|
62134
|
+
const index = holders.indexOf(holder);
|
|
62135
|
+
if (index !== -1) holders.splice(index, 1);
|
|
62136
|
+
for (let i = holders.length - 1; i >= 0; i -= 1) if (tryChdir(holders[i].workspaceDir)) return;
|
|
62137
|
+
const target = baselineCwd ?? os.tmpdir();
|
|
62138
|
+
if (holders.length === 0) baselineCwd = void 0;
|
|
62139
|
+
if (!tryChdir(target) && !tryChdir(os.tmpdir())) log$12.error("tmpdir chdir failed; leaving the process cwd unchanged");
|
|
62140
|
+
};
|
|
62141
|
+
}
|
|
62142
|
+
|
|
62023
62143
|
//#endregion
|
|
62024
62144
|
//#region src/agents/pi-embedded-runner/compact.ts
|
|
62025
62145
|
function createCompactionDiagId$1() {
|
|
@@ -62430,11 +62550,10 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62430
62550
|
compacted: false,
|
|
62431
62551
|
reason: "compaction deferred by context.prune handler"
|
|
62432
62552
|
};
|
|
62433
|
-
const prevCwd = process.cwd();
|
|
62434
62553
|
const provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
62435
62554
|
const modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
62436
62555
|
const fail = (reason) => {
|
|
62437
|
-
log$
|
|
62556
|
+
log$31.warn(`[compaction-diag] end runId=${runId} sessionKey=${params.sessionKey ?? params.sessionId} diagId=${diagId} trigger=${trigger} provider=${provider}/${modelId} attempt=${attempt} maxAttempts=${maxAttempts} outcome=failed reason=${classifyCompactionReason(reason)} durationMs=${Date.now() - startedAt}`);
|
|
62438
62557
|
return {
|
|
62439
62558
|
ok: false,
|
|
62440
62559
|
compacted: false,
|
|
@@ -62478,7 +62597,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62478
62597
|
cwd: effectiveWorkspace
|
|
62479
62598
|
});
|
|
62480
62599
|
let restoreSkillEnv;
|
|
62481
|
-
|
|
62600
|
+
const releaseWorkspaceCwd = acquireWorkspaceCwd(effectiveWorkspace);
|
|
62482
62601
|
try {
|
|
62483
62602
|
const shouldLoadSkillEntries = !params.skillsSnapshot || !params.skillsSnapshot.resolvedSkills;
|
|
62484
62603
|
const skillEntries = shouldLoadSkillEntries ? loadWorkspaceSkillEntries(effectiveWorkspace) : [];
|
|
@@ -62514,7 +62633,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62514
62633
|
resolvedSystemPrompt,
|
|
62515
62634
|
warn: makeBootstrapWarn({
|
|
62516
62635
|
sessionLabel,
|
|
62517
|
-
warn: (message) => log$
|
|
62636
|
+
warn: (message) => log$31.warn(message)
|
|
62518
62637
|
})
|
|
62519
62638
|
});
|
|
62520
62639
|
const runAbortController = new AbortController();
|
|
@@ -62656,7 +62775,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62656
62775
|
});
|
|
62657
62776
|
try {
|
|
62658
62777
|
if (isPreservationArmed() || !isJsonlSessionBackend()) {
|
|
62659
|
-
log$
|
|
62778
|
+
log$31.warn(`[compaction-diag] refused transcript repair/open runId=${runId} sessionKey=${params.sessionKey ?? params.sessionId} diagId=${diagId} trigger=${trigger} preservationArmed=${isPreservationArmed()} jsonlBackend=${isJsonlSessionBackend()}`);
|
|
62660
62779
|
return {
|
|
62661
62780
|
ok: true,
|
|
62662
62781
|
compacted: false,
|
|
@@ -62665,7 +62784,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62665
62784
|
}
|
|
62666
62785
|
await repairSessionFileIfNeeded({
|
|
62667
62786
|
sessionFile: params.sessionFile,
|
|
62668
|
-
warn: (message) => log$
|
|
62787
|
+
warn: (message) => log$31.warn(message)
|
|
62669
62788
|
});
|
|
62670
62789
|
await prewarmSessionFile(params.sessionFile);
|
|
62671
62790
|
const transcriptPolicy = resolveTranscriptPolicy({
|
|
@@ -62761,7 +62880,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62761
62880
|
const inputStorageCursor = await loadCompactionStorageCursor({
|
|
62762
62881
|
sessionId: params.sessionId,
|
|
62763
62882
|
sessionKey: params.sessionKey,
|
|
62764
|
-
warn: (message) => log$
|
|
62883
|
+
warn: (message) => log$31.warn(message)
|
|
62765
62884
|
});
|
|
62766
62885
|
const truncated = limitHistoryTurns(validated, getDmHistoryLimitFromSessionKey(params.sessionKey, params.config));
|
|
62767
62886
|
const limited = transcriptPolicy.repairToolUseResultPairing ? sanitizeToolUseResultPairing(truncated) : truncated;
|
|
@@ -62773,7 +62892,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62773
62892
|
tokenWindow,
|
|
62774
62893
|
usage,
|
|
62775
62894
|
storageCursor: inputStorageCursor,
|
|
62776
|
-
warn: (message) => log$
|
|
62895
|
+
warn: (message) => log$31.warn(message)
|
|
62777
62896
|
});
|
|
62778
62897
|
const sanitizedHookMessages = await sanitizeHookCompactionMessages({
|
|
62779
62898
|
messages: cloneCompactionMessages(compactionPlan.messages),
|
|
@@ -62796,7 +62915,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62796
62915
|
messages: transcriptPolicy.validateAnthropicTurns ? validateAnthropicTurns(validatedPlannedGemini) : validatedPlannedGemini,
|
|
62797
62916
|
fallbackMessages: limited,
|
|
62798
62917
|
replacedMessages: compactionPlan.replacedMessages,
|
|
62799
|
-
warn: (message) => log$
|
|
62918
|
+
warn: (message) => log$31.warn(message)
|
|
62800
62919
|
});
|
|
62801
62920
|
const compactionInputMessages = compactionInput.messages;
|
|
62802
62921
|
if (compactionInputMessages.length === 0) return fail(compactionInput.abortReason ?? "compaction input is empty");
|
|
@@ -62807,13 +62926,13 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62807
62926
|
messages: preCompactionMessages,
|
|
62808
62927
|
sessionFile: params.sessionFile
|
|
62809
62928
|
}, hookCtx).catch((hookErr) => {
|
|
62810
|
-
log$
|
|
62929
|
+
log$31.warn(`before_compaction hook failed: ${String(hookErr)}`);
|
|
62811
62930
|
});
|
|
62812
|
-
const diagEnabled = log$
|
|
62931
|
+
const diagEnabled = log$31.isEnabled("debug");
|
|
62813
62932
|
const preMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
62814
62933
|
if (diagEnabled && preMetrics) {
|
|
62815
|
-
log$
|
|
62816
|
-
log$
|
|
62934
|
+
log$31.debug(`[compaction-diag] start runId=${runId} sessionKey=${params.sessionKey ?? params.sessionId} diagId=${diagId} trigger=${trigger} provider=${provider}/${modelId} attempt=${attempt} maxAttempts=${maxAttempts} pre.messages=${preMetrics.messages} pre.historyTextChars=${preMetrics.historyTextChars} pre.toolResultChars=${preMetrics.toolResultChars} pre.estTokens=${preMetrics.estTokens ?? "unknown"}`);
|
|
62935
|
+
log$31.debug(`[compaction-diag] contributors diagId=${diagId} top=${JSON.stringify(preMetrics.contributors)}`);
|
|
62817
62936
|
}
|
|
62818
62937
|
const compactStartedAt = Date.now();
|
|
62819
62938
|
setContextHooksLastCompactionPreparation(sessionManager, void 0);
|
|
@@ -62823,7 +62942,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62823
62942
|
result = await compactWithAbortOnTimeout({
|
|
62824
62943
|
compact: () => session.compact(params.customInstructions),
|
|
62825
62944
|
abort: () => session.abortCompaction(),
|
|
62826
|
-
onAbortSettleTimeout: (err) => log$
|
|
62945
|
+
onAbortSettleTimeout: (err) => log$31.warn(`compaction did not settle after abort: ${String(err)}`)
|
|
62827
62946
|
});
|
|
62828
62947
|
} finally {
|
|
62829
62948
|
setContextHooksPlannedCompaction(sessionManager, void 0);
|
|
@@ -62851,12 +62970,12 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62851
62970
|
compactedCount: compactionInputMessages.length - session.messages.length,
|
|
62852
62971
|
sessionFile: params.sessionFile
|
|
62853
62972
|
}, hookCtx).catch((hookErr) => {
|
|
62854
|
-
log$
|
|
62973
|
+
log$31.warn(`after_compaction hook failed: ${hookErr}`);
|
|
62855
62974
|
});
|
|
62856
62975
|
const outputStorageCursor = await loadCompactionStorageCursor({
|
|
62857
62976
|
sessionId: params.sessionId,
|
|
62858
62977
|
sessionKey: params.sessionKey,
|
|
62859
|
-
warn: (message) => log$
|
|
62978
|
+
warn: (message) => log$31.warn(message)
|
|
62860
62979
|
});
|
|
62861
62980
|
const compactionResult = {
|
|
62862
62981
|
summary: result.summary,
|
|
@@ -62886,10 +63005,10 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62886
63005
|
outputMessageCount: session.messages.length,
|
|
62887
63006
|
replacedMessages: compactionReplacementApplied,
|
|
62888
63007
|
result: compactionResult,
|
|
62889
|
-
warn: (message) => log$
|
|
63008
|
+
warn: (message) => log$31.warn(message)
|
|
62890
63009
|
});
|
|
62891
63010
|
const postMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
62892
|
-
if (diagEnabled && preMetrics && postMetrics) log$
|
|
63011
|
+
if (diagEnabled && preMetrics && postMetrics) log$31.debug(`[compaction-diag] end runId=${runId} sessionKey=${params.sessionKey ?? params.sessionId} diagId=${diagId} trigger=${trigger} provider=${provider}/${modelId} attempt=${attempt} maxAttempts=${maxAttempts} outcome=compacted reason=none durationMs=${Date.now() - compactStartedAt} retrying=false post.messages=${postMetrics.messages} post.historyTextChars=${postMetrics.historyTextChars} post.toolResultChars=${postMetrics.toolResultChars} post.estTokens=${postMetrics.estTokens ?? "unknown"} delta.messages=${postMetrics.messages - preMetrics.messages} delta.historyTextChars=${postMetrics.historyTextChars - preMetrics.historyTextChars} delta.toolResultChars=${postMetrics.toolResultChars - preMetrics.toolResultChars} delta.estTokens=${typeof preMetrics.estTokens === "number" && typeof postMetrics.estTokens === "number" ? postMetrics.estTokens - preMetrics.estTokens : "unknown"}`);
|
|
62893
63012
|
return {
|
|
62894
63013
|
ok: true,
|
|
62895
63014
|
compacted: true,
|
|
@@ -62918,7 +63037,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
62918
63037
|
return fail(describeUnknownError(err));
|
|
62919
63038
|
} finally {
|
|
62920
63039
|
restoreSkillEnv?.();
|
|
62921
|
-
|
|
63040
|
+
releaseWorkspaceCwd();
|
|
62922
63041
|
}
|
|
62923
63042
|
}
|
|
62924
63043
|
/**
|
|
@@ -63053,15 +63172,15 @@ function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
|
63053
63172
|
if (transport === "sse" || transport === "websocket" || transport === "auto") streamParams.transport = transport;
|
|
63054
63173
|
else if (transport != null) {
|
|
63055
63174
|
const transportSummary = typeof transport === "string" ? transport : typeof transport;
|
|
63056
|
-
log$
|
|
63175
|
+
log$31.warn(`ignoring invalid transport param: ${transportSummary}`);
|
|
63057
63176
|
}
|
|
63058
63177
|
if (typeof extraParams.openaiWsWarmup === "boolean") streamParams.openaiWsWarmup = extraParams.openaiWsWarmup;
|
|
63059
63178
|
const cacheRetention = resolveCacheRetention(extraParams, provider);
|
|
63060
63179
|
if (cacheRetention) streamParams.cacheRetention = cacheRetention;
|
|
63061
63180
|
const providerRouting = provider === "openrouter" && extraParams.provider != null && typeof extraParams.provider === "object" ? extraParams.provider : void 0;
|
|
63062
63181
|
if (Object.keys(streamParams).length === 0 && !providerRouting) return;
|
|
63063
|
-
log$
|
|
63064
|
-
if (providerRouting) log$
|
|
63182
|
+
log$31.debug(`creating streamFn wrapper with params: ${JSON.stringify(streamParams)}`);
|
|
63183
|
+
if (providerRouting) log$31.debug(`OpenRouter provider routing: ${JSON.stringify(providerRouting)}`);
|
|
63065
63184
|
const underlying = baseStreamFn ?? streamSimple;
|
|
63066
63185
|
const wrappedStreamFn = (model, context, options) => {
|
|
63067
63186
|
return underlying(providerRouting ? {
|
|
@@ -63183,7 +63302,7 @@ function resolveAnthropicBetas(extraParams, provider, modelId) {
|
|
|
63183
63302
|
for (const beta of configured) if (typeof beta === "string" && beta.trim()) betas.add(beta.trim());
|
|
63184
63303
|
}
|
|
63185
63304
|
if (extraParams?.context1m === true) if (isAnthropic1MModel(modelId)) betas.add(ANTHROPIC_CONTEXT_1M_BETA);
|
|
63186
|
-
else log$
|
|
63305
|
+
else log$31.warn(`ignoring context1m for non-opus/sonnet model: ${provider}/${modelId}`);
|
|
63187
63306
|
return betas.size > 0 ? [...betas] : void 0;
|
|
63188
63307
|
}
|
|
63189
63308
|
function mergeAnthropicBetaHeader(headers, betas) {
|
|
@@ -63210,7 +63329,7 @@ function createAnthropicBetaHeadersWrapper(baseStreamFn, betas) {
|
|
|
63210
63329
|
const isOauth = isAnthropicOAuthApiKey(options?.apiKey);
|
|
63211
63330
|
const requestedContext1m = betas.includes(ANTHROPIC_CONTEXT_1M_BETA);
|
|
63212
63331
|
const effectiveBetas = isOauth && requestedContext1m ? betas.filter((beta) => beta !== ANTHROPIC_CONTEXT_1M_BETA) : betas;
|
|
63213
|
-
if (isOauth && requestedContext1m) log$
|
|
63332
|
+
if (isOauth && requestedContext1m) log$31.warn(`ignoring context1m for OAuth token auth on ${model.provider}/${model.id}; Anthropic rejects context-1m beta with OAuth auth`);
|
|
63214
63333
|
const piAiBetas = isOauth ? PI_AI_OAUTH_ANTHROPIC_BETAS : PI_AI_DEFAULT_ANTHROPIC_BETAS;
|
|
63215
63334
|
const allBetas = [...new Set([...piAiBetas, ...effectiveBetas])];
|
|
63216
63335
|
return underlying(model, context, {
|
|
@@ -63571,12 +63690,12 @@ function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverr
|
|
|
63571
63690
|
};
|
|
63572
63691
|
const wrappedStreamFn = createStreamFnWithExtraParams(agent.streamFn, merged, provider);
|
|
63573
63692
|
if (wrappedStreamFn) {
|
|
63574
|
-
log$
|
|
63693
|
+
log$31.debug(`applying extraParams to agent streamFn for ${provider}/${modelId}`);
|
|
63575
63694
|
agent.streamFn = wrappedStreamFn;
|
|
63576
63695
|
}
|
|
63577
63696
|
const anthropicBetas = resolveAnthropicBetas(merged, provider, modelId);
|
|
63578
63697
|
if (anthropicBetas?.length) {
|
|
63579
|
-
log$
|
|
63698
|
+
log$31.debug(`applying Anthropic beta header for ${provider}/${modelId}: ${anthropicBetas.join(",")}`);
|
|
63580
63699
|
agent.streamFn = createAnthropicBetaHeadersWrapper(agent.streamFn, anthropicBetas);
|
|
63581
63700
|
}
|
|
63582
63701
|
if (shouldApplySiliconFlowThinkingOffCompat({
|
|
@@ -63584,7 +63703,7 @@ function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverr
|
|
|
63584
63703
|
modelId,
|
|
63585
63704
|
thinkingLevel
|
|
63586
63705
|
})) {
|
|
63587
|
-
log$
|
|
63706
|
+
log$31.debug(`normalizing thinking=off to thinking=null for SiliconFlow compatibility (${provider}/${modelId})`);
|
|
63588
63707
|
agent.streamFn = createSiliconFlowThinkingWrapper(agent.streamFn);
|
|
63589
63708
|
}
|
|
63590
63709
|
if (provider === "moonshot") {
|
|
@@ -63592,22 +63711,22 @@ function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverr
|
|
|
63592
63711
|
configuredThinking: merged?.thinking,
|
|
63593
63712
|
thinkingLevel
|
|
63594
63713
|
});
|
|
63595
|
-
if (moonshotThinkingType) log$
|
|
63714
|
+
if (moonshotThinkingType) log$31.debug(`applying Moonshot thinking=${moonshotThinkingType} payload wrapper for ${provider}/${modelId}`);
|
|
63596
63715
|
agent.streamFn = createMoonshotThinkingWrapper(agent.streamFn, moonshotThinkingType);
|
|
63597
63716
|
}
|
|
63598
63717
|
if (provider === "openrouter") {
|
|
63599
|
-
log$
|
|
63718
|
+
log$31.debug(`applying OpenRouter app attribution headers for ${provider}/${modelId}`);
|
|
63600
63719
|
const openRouterThinkingLevel = modelId === "auto" || isOpenRouterReasoningUnsupported(modelId) ? void 0 : thinkingLevel;
|
|
63601
63720
|
agent.streamFn = createOpenRouterWrapper(agent.streamFn, openRouterThinkingLevel);
|
|
63602
63721
|
agent.streamFn = createOpenRouterSystemCacheWrapper(agent.streamFn);
|
|
63603
63722
|
}
|
|
63604
63723
|
if (provider === "amazon-bedrock" && !isAnthropicBedrockModel(modelId)) {
|
|
63605
|
-
log$
|
|
63724
|
+
log$31.debug(`disabling prompt caching for non-Anthropic Bedrock model ${provider}/${modelId}`);
|
|
63606
63725
|
agent.streamFn = createBedrockNoCacheWrapper(agent.streamFn);
|
|
63607
63726
|
}
|
|
63608
63727
|
if (provider === "zai" || provider === "z-ai") {
|
|
63609
63728
|
if (merged?.tool_stream !== false) {
|
|
63610
|
-
log$
|
|
63729
|
+
log$31.debug(`enabling Z.AI tool_stream for ${provider}/${modelId}`);
|
|
63611
63730
|
agent.streamFn = createZaiToolStreamWrapper(agent.streamFn, true);
|
|
63612
63731
|
}
|
|
63613
63732
|
}
|
|
@@ -64299,7 +64418,7 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
64299
64418
|
if (!session.manager.isConnected() && !session.broken) try {
|
|
64300
64419
|
await session.manager.connect(apiKey);
|
|
64301
64420
|
session.everConnected = true;
|
|
64302
|
-
log$
|
|
64421
|
+
log$31.debug(`[ws-stream] connected for session=${sessionId}`);
|
|
64303
64422
|
} catch (connErr) {
|
|
64304
64423
|
try {
|
|
64305
64424
|
session.manager.close();
|
|
@@ -64307,12 +64426,12 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
64307
64426
|
session.broken = true;
|
|
64308
64427
|
wsRegistry.delete(sessionId);
|
|
64309
64428
|
if (transport === "websocket") throw connErr instanceof Error ? connErr : new Error(String(connErr));
|
|
64310
|
-
log$
|
|
64429
|
+
log$31.warn(`[ws-stream] WebSocket connect failed for session=${sessionId}; falling back to HTTP. error=${String(connErr)}`);
|
|
64311
64430
|
return fallbackToHttp(model, context, options, eventStream, apiKey, opts.signal);
|
|
64312
64431
|
}
|
|
64313
64432
|
if (session.broken || !session.manager.isConnected()) {
|
|
64314
64433
|
if (transport === "websocket") throw new Error("WebSocket session disconnected");
|
|
64315
|
-
log$
|
|
64434
|
+
log$31.warn(`[ws-stream] session=${sessionId} broken/disconnected; falling back to HTTP`);
|
|
64316
64435
|
try {
|
|
64317
64436
|
session.manager.close();
|
|
64318
64437
|
} catch {}
|
|
@@ -64330,10 +64449,10 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
64330
64449
|
instructions: context.systemPrompt ?? void 0,
|
|
64331
64450
|
signal
|
|
64332
64451
|
});
|
|
64333
|
-
log$
|
|
64452
|
+
log$31.debug(`[ws-stream] warm-up completed for session=${sessionId}`);
|
|
64334
64453
|
} catch (warmErr) {
|
|
64335
64454
|
if (signal?.aborted) throw warmErr instanceof Error ? warmErr : new Error(String(warmErr));
|
|
64336
|
-
log$
|
|
64455
|
+
log$31.warn(`[ws-stream] warm-up failed for session=${sessionId}; continuing without warm-up. error=${String(warmErr)}`);
|
|
64337
64456
|
}
|
|
64338
64457
|
}
|
|
64339
64458
|
const prevResponseId = session.manager.previousResponseId;
|
|
@@ -64341,13 +64460,13 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
64341
64460
|
if (prevResponseId && session.lastContextLength > 0) {
|
|
64342
64461
|
const toolResults = context.messages.slice(session.lastContextLength).filter((m) => m.role === "toolResult");
|
|
64343
64462
|
if (toolResults.length === 0) {
|
|
64344
|
-
log$
|
|
64463
|
+
log$31.debug(`[ws-stream] session=${sessionId}: no new tool results found; sending full context`);
|
|
64345
64464
|
inputItems = buildFullInput(context);
|
|
64346
64465
|
} else inputItems = convertMessagesToInputItems(toolResults);
|
|
64347
|
-
log$
|
|
64466
|
+
log$31.debug(`[ws-stream] session=${sessionId}: incremental send (${inputItems.length} tool results) previous_response_id=${prevResponseId}`);
|
|
64348
64467
|
} else {
|
|
64349
64468
|
inputItems = buildFullInput(context);
|
|
64350
|
-
log$
|
|
64469
|
+
log$31.debug(`[ws-stream] session=${sessionId}: full context send (${inputItems.length} items)`);
|
|
64351
64470
|
}
|
|
64352
64471
|
const tools = convertTools(context.tools);
|
|
64353
64472
|
const streamOpts = options;
|
|
@@ -64377,7 +64496,7 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
64377
64496
|
session.manager.send(payload);
|
|
64378
64497
|
} catch (sendErr) {
|
|
64379
64498
|
if (transport === "websocket") throw sendErr instanceof Error ? sendErr : new Error(String(sendErr));
|
|
64380
|
-
log$
|
|
64499
|
+
log$31.warn(`[ws-stream] send failed for session=${sessionId}; falling back to HTTP. error=${String(sendErr)}`);
|
|
64381
64500
|
try {
|
|
64382
64501
|
session.manager.close();
|
|
64383
64502
|
} catch {}
|
|
@@ -64457,7 +64576,7 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
64457
64576
|
};
|
|
64458
64577
|
queueMicrotask(() => run().catch((err) => {
|
|
64459
64578
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
64460
|
-
log$
|
|
64579
|
+
log$31.warn(`[ws-stream] session=${sessionId} run error: ${errorMessage}`);
|
|
64461
64580
|
eventStream.push({
|
|
64462
64581
|
type: "error",
|
|
64463
64582
|
reason: "error",
|
|
@@ -66730,7 +66849,7 @@ function normalizeRefForDedupe(raw) {
|
|
|
66730
66849
|
}
|
|
66731
66850
|
async function sanitizeImagesWithLog(images, label, imageSanitization) {
|
|
66732
66851
|
const { images: sanitized, dropped } = await sanitizeImageBlocks(images, label, imageSanitization);
|
|
66733
|
-
if (dropped > 0) log$
|
|
66852
|
+
if (dropped > 0) log$31.warn(`Native image: dropped ${dropped} image(s) after sanitization (${label}).`);
|
|
66734
66853
|
return sanitized;
|
|
66735
66854
|
}
|
|
66736
66855
|
/**
|
|
@@ -66817,7 +66936,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
66817
66936
|
mediaPath: targetPath
|
|
66818
66937
|
})).resolved;
|
|
66819
66938
|
} catch (err) {
|
|
66820
|
-
log$
|
|
66939
|
+
log$31.debug(`Native image: sandbox validation failed for ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
66821
66940
|
return null;
|
|
66822
66941
|
}
|
|
66823
66942
|
else if (!path.isAbsolute(targetPath)) targetPath = path.resolve(workspaceDir, targetPath);
|
|
@@ -66835,7 +66954,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
66835
66954
|
readFile: createSandboxBridgeReadFile({ sandbox: options.sandbox })
|
|
66836
66955
|
}) : await loadWebMedia(targetPath, options?.maxBytes);
|
|
66837
66956
|
if (media.kind !== "image") {
|
|
66838
|
-
log$
|
|
66957
|
+
log$31.debug(`Native image: not an image file: ${targetPath} (got ${media.kind})`);
|
|
66839
66958
|
return null;
|
|
66840
66959
|
}
|
|
66841
66960
|
const mimeType = media.contentType ?? "image/jpeg";
|
|
@@ -66845,7 +66964,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
66845
66964
|
mimeType
|
|
66846
66965
|
};
|
|
66847
66966
|
} catch (err) {
|
|
66848
|
-
log$
|
|
66967
|
+
log$31.debug(`Native image: failed to load ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
66849
66968
|
return null;
|
|
66850
66969
|
}
|
|
66851
66970
|
}
|
|
@@ -66882,7 +67001,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
66882
67001
|
loadedCount: 0,
|
|
66883
67002
|
skippedCount: 0
|
|
66884
67003
|
};
|
|
66885
|
-
log$
|
|
67004
|
+
log$31.debug(`Native image: detected ${allRefs.length} image refs in prompt`);
|
|
66886
67005
|
const promptImages = [...params.existingImages ?? []];
|
|
66887
67006
|
let loadedCount = 0;
|
|
66888
67007
|
let skippedCount = 0;
|
|
@@ -66895,7 +67014,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
66895
67014
|
if (image) {
|
|
66896
67015
|
promptImages.push(image);
|
|
66897
67016
|
loadedCount++;
|
|
66898
|
-
log$
|
|
67017
|
+
log$31.debug(`Native image: loaded ${ref.type} ${ref.resolved}`);
|
|
66899
67018
|
} else skippedCount++;
|
|
66900
67019
|
}
|
|
66901
67020
|
return {
|
|
@@ -67510,7 +67629,7 @@ async function buildStreamFn(params) {
|
|
|
67510
67629
|
const wsApiKey = await params.authStorage.getApiKey(params.provider);
|
|
67511
67630
|
if (wsApiKey) streamFn = createOpenAIWebSocketStreamFn(wsApiKey, params.sessionId, { signal: params.abortSignal });
|
|
67512
67631
|
else {
|
|
67513
|
-
log$
|
|
67632
|
+
log$31.warn(`[ws-stream] no API key for provider=${params.provider}; using HTTP transport`);
|
|
67514
67633
|
streamFn = streamSimple;
|
|
67515
67634
|
}
|
|
67516
67635
|
} else {
|
|
@@ -67613,13 +67732,13 @@ async function resolvePromptBuildHookResult(params) {
|
|
|
67613
67732
|
messages: params.messages,
|
|
67614
67733
|
systemPrompt: params.systemPrompt
|
|
67615
67734
|
}, params.hookCtx).catch((hookErr) => {
|
|
67616
|
-
log$
|
|
67735
|
+
log$31.warn(`before_prompt_build hook failed: ${String(hookErr)}`);
|
|
67617
67736
|
}) : void 0;
|
|
67618
67737
|
const legacyResult = params.legacyBeforeAgentStartResult ?? (params.hookRunner?.hasHooks("before_agent_start") ? await params.hookRunner.runBeforeAgentStart({
|
|
67619
67738
|
prompt: params.prompt,
|
|
67620
67739
|
messages: params.messages
|
|
67621
67740
|
}, params.hookCtx).catch((hookErr) => {
|
|
67622
|
-
log$
|
|
67741
|
+
log$31.warn(`before_agent_start hook (legacy prompt build path) failed: ${String(hookErr)}`);
|
|
67623
67742
|
}) : void 0);
|
|
67624
67743
|
return {
|
|
67625
67744
|
systemPrompt: promptBuildResult?.systemPrompt ?? legacyResult?.systemPrompt,
|
|
@@ -67757,7 +67876,7 @@ async function collectAttemptPromptContribution(params) {
|
|
|
67757
67876
|
messages: params.messages,
|
|
67758
67877
|
envelope: params.envelope
|
|
67759
67878
|
}, params.lifecycleCtx).catch((hookErr) => {
|
|
67760
|
-
log$
|
|
67879
|
+
log$31.warn(`context.collect hook failed: ${String(hookErr)}`);
|
|
67761
67880
|
}) : void 0;
|
|
67762
67881
|
return mergePromptContributions([promptBuildResultToContribution(legacyResult), contextCollectResult]);
|
|
67763
67882
|
}
|
|
@@ -67772,7 +67891,7 @@ async function runContextProjectionAndPruningHooks(params) {
|
|
|
67772
67891
|
contributions: params.contributions,
|
|
67773
67892
|
envelope: params.envelope
|
|
67774
67893
|
}, params.lifecycleCtx).catch((hookErr) => {
|
|
67775
|
-
log$
|
|
67894
|
+
log$31.warn(`context.project hook failed: ${String(hookErr)}`);
|
|
67776
67895
|
});
|
|
67777
67896
|
if (result?.messages) currentMessages = result.messages;
|
|
67778
67897
|
if (result?.projection) projection = {
|
|
@@ -67788,7 +67907,7 @@ async function runContextProjectionAndPruningHooks(params) {
|
|
|
67788
67907
|
tokenWindow: params.lifecycleCtx.tokenWindow,
|
|
67789
67908
|
usage: params.lifecycleCtx.usage
|
|
67790
67909
|
}, params.lifecycleCtx).catch((hookErr) => {
|
|
67791
|
-
log$
|
|
67910
|
+
log$31.warn(`context.prune hook failed: ${String(hookErr)}`);
|
|
67792
67911
|
});
|
|
67793
67912
|
if (result?.messages) currentMessages = result.messages;
|
|
67794
67913
|
if (result?.dropped) dropped.push(...result.dropped);
|
|
@@ -67890,7 +68009,7 @@ function installAttemptInputTransform(params) {
|
|
|
67890
68009
|
runtime: params.projectionRuntime,
|
|
67891
68010
|
timeoutMs: params.projectionArtifactTimeoutMs
|
|
67892
68011
|
}).catch((err) => {
|
|
67893
|
-
log$
|
|
68012
|
+
log$31.warn(`context projection artifact persist failed: ${String(err)}`);
|
|
67894
68013
|
});
|
|
67895
68014
|
const finalMessages = await runTransformLlmInputHooks({
|
|
67896
68015
|
messages: currentMessages,
|
|
@@ -67899,7 +68018,7 @@ function installAttemptInputTransform(params) {
|
|
|
67899
68018
|
provider: params.provider,
|
|
67900
68019
|
modelId: params.modelId
|
|
67901
68020
|
}).catch((err) => {
|
|
67902
|
-
log$
|
|
68021
|
+
log$31.warn(`transform_llm_input hook failed: ${String(err)}`);
|
|
67903
68022
|
}) ?? currentMessages;
|
|
67904
68023
|
params.onFinalInputMessages?.(finalMessages);
|
|
67905
68024
|
return finalMessages;
|
|
@@ -68017,11 +68136,10 @@ function summarizeSessionContext(messages) {
|
|
|
68017
68136
|
}
|
|
68018
68137
|
async function runEmbeddedAttempt(params) {
|
|
68019
68138
|
const resolvedWorkspace = resolveUserPath(params.workspaceDir);
|
|
68020
|
-
const prevCwd = process.cwd();
|
|
68021
68139
|
let pendingClearActiveEmbeddedRun;
|
|
68022
68140
|
const runAbortController = new AbortController();
|
|
68023
68141
|
const currentUserTurnForStorage = resolveCurrentUserTurnForStorage(params);
|
|
68024
|
-
log$
|
|
68142
|
+
log$31.debug(`embedded run start: runId=${params.runId} sessionId=${params.sessionId} provider=${params.provider} model=${params.modelId} thinking=${params.thinkLevel} messageChannel=${params.messageChannel ?? params.messageProvider ?? "unknown"}`);
|
|
68025
68143
|
await fs$1.mkdir(resolvedWorkspace, { recursive: true });
|
|
68026
68144
|
const sandboxSessionKey = params.sessionKey?.trim() || params.sessionId;
|
|
68027
68145
|
const toolSessionKey = params.toolSessionKey?.trim() || sandboxSessionKey;
|
|
@@ -68034,7 +68152,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68034
68152
|
const effectiveWorkspace = sandbox?.enabled ? sandbox.workspaceAccess === "rw" ? resolvedWorkspace : sandbox.workspaceDir : resolvedWorkspace;
|
|
68035
68153
|
await fs$1.mkdir(effectiveWorkspace, { recursive: true });
|
|
68036
68154
|
let restoreSkillEnv;
|
|
68037
|
-
|
|
68155
|
+
const releaseWorkspaceCwd = params.skipCwdChange ? void 0 : acquireWorkspaceCwd(effectiveWorkspace);
|
|
68038
68156
|
try {
|
|
68039
68157
|
const skillWorkspace = params.skillWorkspaceDir ?? effectiveWorkspace;
|
|
68040
68158
|
const shouldLoadSkillEntries = !params.skipSkillEnv && (!params.skillsSnapshot || !params.skillsSnapshot.resolvedSkills);
|
|
@@ -68076,7 +68194,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68076
68194
|
resolvedSystemPrompt,
|
|
68077
68195
|
warn: makeBootstrapWarn({
|
|
68078
68196
|
sessionLabel,
|
|
68079
|
-
warn: (message) => log$
|
|
68197
|
+
warn: (message) => log$31.warn(message)
|
|
68080
68198
|
}),
|
|
68081
68199
|
contextMode: params.bootstrapContextMode,
|
|
68082
68200
|
runKind: params.bootstrapContextRunKind,
|
|
@@ -68318,7 +68436,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68318
68436
|
if (queue != null) {
|
|
68319
68437
|
await drainPendingPrimaryWrites(queue, 3e4, storage?.config.fallbackToJsonlOnError ?? false);
|
|
68320
68438
|
if (storage?.runtime?.conversation?.upsertTurn) await storage.runtime.conversation.upsertTurn(params.sessionId).catch((err) => {
|
|
68321
|
-
log$
|
|
68439
|
+
log$31.warn("turn upsert failed (non-fatal)", {
|
|
68322
68440
|
sessionId: params.sessionId,
|
|
68323
68441
|
err
|
|
68324
68442
|
});
|
|
@@ -68386,14 +68504,14 @@ async function runEmbeddedAttempt(params) {
|
|
|
68386
68504
|
sessionManager = _wrapped.sm;
|
|
68387
68505
|
_primaryWriteQueue = _wrapped.queue;
|
|
68388
68506
|
}
|
|
68389
|
-
} else log$
|
|
68507
|
+
} else log$31.error("DB backend detected but conversation store is unavailable — turn will run without history and DB write-through; check that the DB runtime initialised correctly", {
|
|
68390
68508
|
sessionId: params.sessionId,
|
|
68391
68509
|
backend: _configuredStorage?.runtime?.backend
|
|
68392
68510
|
});
|
|
68393
68511
|
} else {
|
|
68394
68512
|
await repairSessionFileIfNeeded({
|
|
68395
68513
|
sessionFile: params.sessionFile,
|
|
68396
|
-
warn: (message) => log$
|
|
68514
|
+
warn: (message) => log$31.warn(message)
|
|
68397
68515
|
});
|
|
68398
68516
|
const hadSessionFile = await fs$1.stat(params.sessionFile).then(() => true).catch(() => false);
|
|
68399
68517
|
if (!params.skipSessionManagerCache) await prewarmSessionFile(params.sessionFile);
|
|
@@ -68534,7 +68652,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68534
68652
|
const wsApiKey = await params.authStorage.getApiKey(params.provider);
|
|
68535
68653
|
if (wsApiKey) activeSession.agent.streamFn = createOpenAIWebSocketStreamFn(wsApiKey, params.sessionId, { signal: runAbortController.signal });
|
|
68536
68654
|
else {
|
|
68537
|
-
log$
|
|
68655
|
+
log$31.warn(`[ws-stream] no API key for provider=${params.provider}; using HTTP transport`);
|
|
68538
68656
|
activeSession.agent.streamFn = streamSimple;
|
|
68539
68657
|
}
|
|
68540
68658
|
} else {
|
|
@@ -68734,7 +68852,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68734
68852
|
let abortWarnTimer;
|
|
68735
68853
|
const isProbeSession = params.sessionId?.startsWith("probe-") ?? false;
|
|
68736
68854
|
const abortTimer = setTimeout(() => {
|
|
68737
|
-
if (!isProbeSession) log$
|
|
68855
|
+
if (!isProbeSession) log$31.warn(`embedded run timeout: runId=${params.runId} sessionId=${params.sessionId} timeoutMs=${params.timeoutMs}`);
|
|
68738
68856
|
if (shouldFlagCompactionTimeout({
|
|
68739
68857
|
isTimeout: true,
|
|
68740
68858
|
isCompactionPendingOrRetrying: subscription.isCompacting(),
|
|
@@ -68743,7 +68861,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68743
68861
|
abortRun(true);
|
|
68744
68862
|
if (!abortWarnTimer) abortWarnTimer = setTimeout(() => {
|
|
68745
68863
|
if (!activeSession.isStreaming) return;
|
|
68746
|
-
if (!isProbeSession) log$
|
|
68864
|
+
if (!isProbeSession) log$31.warn(`embedded run abort still streaming: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
68747
68865
|
}, 1e4);
|
|
68748
68866
|
}, Math.max(1, params.timeoutMs));
|
|
68749
68867
|
let messagesSnapshot = [];
|
|
@@ -68777,7 +68895,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68777
68895
|
let timeoutHandle;
|
|
68778
68896
|
const timeout = new Promise((resolve) => {
|
|
68779
68897
|
timeoutHandle = setTimeout(() => {
|
|
68780
|
-
log$
|
|
68898
|
+
log$31.warn(`${label} timed out after ${metaTimeoutMs}ms`);
|
|
68781
68899
|
resolve(void 0);
|
|
68782
68900
|
}, metaTimeoutMs);
|
|
68783
68901
|
timeoutHandle.unref?.();
|
|
@@ -68785,7 +68903,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68785
68903
|
try {
|
|
68786
68904
|
return await Promise.race([p, timeout]);
|
|
68787
68905
|
} catch (err) {
|
|
68788
|
-
log$
|
|
68906
|
+
log$31.warn(`${label} failed: ${String(err)}`);
|
|
68789
68907
|
return;
|
|
68790
68908
|
} finally {
|
|
68791
68909
|
if (timeoutHandle !== void 0) clearTimeout(timeoutHandle);
|
|
@@ -68810,14 +68928,14 @@ async function runEmbeddedAttempt(params) {
|
|
|
68810
68928
|
senderIdentity,
|
|
68811
68929
|
workspaceLane: params.workspaceLane
|
|
68812
68930
|
});
|
|
68813
|
-
log$
|
|
68931
|
+
log$31.debug(`embedded run prompt start: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
68814
68932
|
const leafEntry = sessionManager.getLeafEntry();
|
|
68815
68933
|
if (leafEntry?.type === "message" && leafEntry.message.role === "user") {
|
|
68816
68934
|
if (leafEntry.parentId) sessionManager.branch(leafEntry.parentId);
|
|
68817
68935
|
else sessionManager.resetLeaf();
|
|
68818
68936
|
const sessionContext = sessionManager.buildSessionContext();
|
|
68819
68937
|
activeSession.agent.state.messages = sessionContext.messages;
|
|
68820
|
-
log$
|
|
68938
|
+
log$31.warn(`Removed orphaned user message to prevent consecutive user turns. runId=${params.runId} sessionId=${params.sessionId}`);
|
|
68821
68939
|
}
|
|
68822
68940
|
const cleanUserMessage = createCleanUserMessageFromPrompt(params.prompt);
|
|
68823
68941
|
const baseEnvelope = createCurrentUserPromptEnvelope({ cleanUserMessage });
|
|
@@ -68846,7 +68964,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68846
68964
|
const contributedSystemPrompt = applySystemPromptContribution(systemPromptText, promptContribution);
|
|
68847
68965
|
if (contributedSystemPrompt !== systemPromptText) {
|
|
68848
68966
|
applySystemPromptOverrideToSession(activeSession, contributedSystemPrompt);
|
|
68849
|
-
log$
|
|
68967
|
+
log$31.debug(`hooks: augmented system prompt (+${contributedSystemPrompt.length - systemPromptText.length} chars)`);
|
|
68850
68968
|
systemPromptText = contributedSystemPrompt;
|
|
68851
68969
|
}
|
|
68852
68970
|
cacheTrace?.recordStage("prompt:before", {
|
|
@@ -68878,12 +68996,12 @@ async function runEmbeddedAttempt(params) {
|
|
|
68878
68996
|
messages: activeSession.messages,
|
|
68879
68997
|
note: `images: prompt=${imageResult.images.length}`
|
|
68880
68998
|
});
|
|
68881
|
-
if (log$
|
|
68999
|
+
if (log$31.isEnabled("debug")) {
|
|
68882
69000
|
const msgCount = activeSession.messages.length;
|
|
68883
69001
|
const systemLen = systemPromptText?.length ?? 0;
|
|
68884
69002
|
const promptLen = effectivePrompt.length;
|
|
68885
69003
|
const sessionSummary = summarizeSessionContext(activeSession.messages);
|
|
68886
|
-
log$
|
|
69004
|
+
log$31.debug(`[context-diag] pre-prompt: sessionKey=${params.sessionKey ?? params.sessionId} messages=${msgCount} roleCounts=${sessionSummary.roleCounts} historyTextChars=${sessionSummary.totalTextChars} maxMessageTextChars=${sessionSummary.maxMessageTextChars} historyImageBlocks=${sessionSummary.totalImageBlocks} systemPromptChars=${systemLen} promptChars=${promptLen} promptImages=${imageResult.images.length} provider=${params.provider}/${params.modelId} sessionFile=${params.sessionFile}`);
|
|
68887
69005
|
}
|
|
68888
69006
|
if (hookRunner?.hasHooks("llm_input")) hookRunner.runLlmInput({
|
|
68889
69007
|
runId: params.runId,
|
|
@@ -68895,7 +69013,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68895
69013
|
historyMessages: activeSession.messages,
|
|
68896
69014
|
imagesCount: imageResult.images.length
|
|
68897
69015
|
}, hookCtx).catch((err) => {
|
|
68898
|
-
log$
|
|
69016
|
+
log$31.warn(`llm_input hook failed: ${String(err)}`);
|
|
68899
69017
|
});
|
|
68900
69018
|
const modelUserMessage = appendPromptImagesToUserMessage(renderedCurrentUserPrompt.modelUserMessage, imageResult.images);
|
|
68901
69019
|
const currentPromptIndex = activeSession.messages.length;
|
|
@@ -68938,7 +69056,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68938
69056
|
errorType: String(err instanceof Error ? err.name : "UnknownError")
|
|
68939
69057
|
});
|
|
68940
69058
|
} finally {
|
|
68941
|
-
log$
|
|
69059
|
+
log$31.debug(`embedded run prompt end: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - promptStartedAt}`);
|
|
68942
69060
|
}
|
|
68943
69061
|
const wasCompactingBefore = activeSession.isCompacting;
|
|
68944
69062
|
const snapshot = activeSession.messages.slice();
|
|
@@ -68953,7 +69071,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68953
69071
|
promptError = err;
|
|
68954
69072
|
promptErrorSource = "compaction";
|
|
68955
69073
|
}
|
|
68956
|
-
if (!isProbeSession) log$
|
|
69074
|
+
if (!isProbeSession) log$31.debug(`compaction wait aborted: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
68957
69075
|
} else throw err;
|
|
68958
69076
|
}
|
|
68959
69077
|
const compactionOccurredThisAttempt = getCompactionCount() > 0;
|
|
@@ -68972,7 +69090,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68972
69090
|
currentSessionId: activeSession.sessionId
|
|
68973
69091
|
});
|
|
68974
69092
|
if (timedOutDuringCompaction) {
|
|
68975
|
-
if (!isProbeSession) log$
|
|
69093
|
+
if (!isProbeSession) log$31.warn(`using ${snapshotSelection.source} snapshot: timed out during compaction runId=${params.runId} sessionId=${params.sessionId}`);
|
|
68976
69094
|
}
|
|
68977
69095
|
messagesSnapshot = snapshotSelection.messagesSnapshot;
|
|
68978
69096
|
sessionIdUsed = snapshotSelection.sessionIdUsed;
|
|
@@ -68987,7 +69105,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
68987
69105
|
error: describeUnknownError(promptError)
|
|
68988
69106
|
});
|
|
68989
69107
|
} catch (entryErr) {
|
|
68990
|
-
log$
|
|
69108
|
+
log$31.warn(`failed to persist prompt error entry: ${String(entryErr)}`);
|
|
68991
69109
|
}
|
|
68992
69110
|
if (!params.skipTranscriptSync) await drainOrSyncTranscript(_primaryWriteQueue, _isDbBackend, _configuredStorage, {
|
|
68993
69111
|
agentId: hookAgentIdForTranscript,
|
|
@@ -69007,16 +69125,16 @@ async function runEmbeddedAttempt(params) {
|
|
|
69007
69125
|
error: promptError ? describeUnknownError(promptError) : void 0,
|
|
69008
69126
|
durationMs: Date.now() - promptStartedAt
|
|
69009
69127
|
}, hookCtx).catch((err) => {
|
|
69010
|
-
log$
|
|
69128
|
+
log$31.warn(`agent_end hook failed: ${err}`);
|
|
69011
69129
|
});
|
|
69012
69130
|
} finally {
|
|
69013
69131
|
clearTimeout(abortTimer);
|
|
69014
69132
|
if (abortWarnTimer) clearTimeout(abortWarnTimer);
|
|
69015
|
-
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$
|
|
69133
|
+
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$31.debug(`run cleanup: runId=${params.runId} sessionId=${params.sessionId} aborted=${aborted} timedOut=${timedOut}`);
|
|
69016
69134
|
try {
|
|
69017
69135
|
unsubscribe();
|
|
69018
69136
|
} catch (err) {
|
|
69019
|
-
log$
|
|
69137
|
+
log$31.error(`CRITICAL: unsubscribe failed, possible resource leak: runId=${params.runId} ${String(err)}`);
|
|
69020
69138
|
}
|
|
69021
69139
|
pendingClearActiveEmbeddedRun = () => clearActiveEmbeddedRun(params.sessionId, queueHandle, params.sessionKey, !aborted && !timedOut && !promptError);
|
|
69022
69140
|
params.abortSignal?.removeEventListener?.("abort", onAbort);
|
|
@@ -69054,7 +69172,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
69054
69172
|
workspaceLane: params.workspaceLane,
|
|
69055
69173
|
runId: params.runId
|
|
69056
69174
|
})).catch((err) => {
|
|
69057
|
-
log$
|
|
69175
|
+
log$31.warn(`model_call_ended hook failed: ${String(err)}`);
|
|
69058
69176
|
});
|
|
69059
69177
|
proxyMetadataFromHook = modelCallEndedEvent.proxyMetadata;
|
|
69060
69178
|
}
|
|
@@ -69078,7 +69196,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
69078
69196
|
workspaceLane: params.workspaceLane,
|
|
69079
69197
|
runId: params.runId
|
|
69080
69198
|
})).catch((err) => {
|
|
69081
|
-
log$
|
|
69199
|
+
log$31.warn(`llm_output hook failed: ${String(err)}`);
|
|
69082
69200
|
});
|
|
69083
69201
|
return {
|
|
69084
69202
|
aborted,
|
|
@@ -69121,7 +69239,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
69121
69239
|
if (_primaryWriteQueue != null && _primaryWriteQueue.length > 0) try {
|
|
69122
69240
|
await drainPendingPrimaryWrites(_primaryWriteQueue, 5e3, _configuredStorage?.config.fallbackToJsonlOnError ?? false);
|
|
69123
69241
|
} catch (cleanupDrainErr) {
|
|
69124
|
-
log$
|
|
69242
|
+
log$31.error("cleanup drain failed in finally; session entries may be lost", {
|
|
69125
69243
|
sessionId: params.sessionId,
|
|
69126
69244
|
error: cleanupDrainErr
|
|
69127
69245
|
});
|
|
@@ -69133,7 +69251,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
69133
69251
|
}
|
|
69134
69252
|
} finally {
|
|
69135
69253
|
restoreSkillEnv?.();
|
|
69136
|
-
|
|
69254
|
+
releaseWorkspaceCwd?.();
|
|
69137
69255
|
pendingClearActiveEmbeddedRun?.();
|
|
69138
69256
|
}
|
|
69139
69257
|
}
|
|
@@ -69409,8 +69527,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
69409
69527
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
69410
69528
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
69411
69529
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
69412
|
-
if (workspaceResolution.usedFallback) log$
|
|
69413
|
-
const prevCwd = process.cwd();
|
|
69530
|
+
if (workspaceResolution.usedFallback) log$31.warn(`[workspace-fallback] caller=runEmbeddedPiAgent reason=${workspaceResolution.fallbackReason} run=${params.runId} session=${redactedSessionId} sessionKey=${redactedSessionKey} agent=${workspaceResolution.agentId} workspace=${redactedWorkspace}`);
|
|
69414
69531
|
let provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
69415
69532
|
let modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
69416
69533
|
const agentDir = params.agentDir ?? resolveOpenClawAgentDir();
|
|
@@ -69450,7 +69567,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
69450
69567
|
if (hookRunner?.hasHooks("before_model_resolve")) try {
|
|
69451
69568
|
modelResolveOverride = await hookRunner.runBeforeModelResolve({ prompt: params.prompt }, hookCtx);
|
|
69452
69569
|
} catch (hookErr) {
|
|
69453
|
-
log$
|
|
69570
|
+
log$31.warn(`before_model_resolve hook failed: ${String(hookErr)}`);
|
|
69454
69571
|
}
|
|
69455
69572
|
if (hookRunner?.hasHooks("before_agent_start")) try {
|
|
69456
69573
|
legacyBeforeAgentStartResult = await hookRunner.runBeforeAgentStart({ prompt: params.prompt }, hookCtx);
|
|
@@ -69459,15 +69576,15 @@ async function runEmbeddedPiAgent(params) {
|
|
|
69459
69576
|
modelOverride: modelResolveOverride?.modelOverride ?? legacyBeforeAgentStartResult?.modelOverride
|
|
69460
69577
|
};
|
|
69461
69578
|
} catch (hookErr) {
|
|
69462
|
-
log$
|
|
69579
|
+
log$31.warn(`before_agent_start hook (legacy model resolve path) failed: ${String(hookErr)}`);
|
|
69463
69580
|
}
|
|
69464
69581
|
if (modelResolveOverride?.providerOverride) {
|
|
69465
69582
|
provider = modelResolveOverride.providerOverride;
|
|
69466
|
-
log$
|
|
69583
|
+
log$31.info(`[hooks] provider overridden to ${provider}`);
|
|
69467
69584
|
}
|
|
69468
69585
|
if (modelResolveOverride?.modelOverride) {
|
|
69469
69586
|
modelId = modelResolveOverride.modelOverride;
|
|
69470
|
-
log$
|
|
69587
|
+
log$31.info(`[hooks] model overridden to ${modelId}`);
|
|
69471
69588
|
}
|
|
69472
69589
|
const { model, error, authStorage, modelRegistry } = resolveModel(provider, modelId, agentDir, params.config);
|
|
69473
69590
|
if (!model) throw new FailoverError(error ?? `Unknown model: ${provider}/${modelId}`, {
|
|
@@ -69487,9 +69604,9 @@ async function runEmbeddedPiAgent(params) {
|
|
|
69487
69604
|
warnBelowTokens: CONTEXT_WINDOW_WARN_BELOW_TOKENS,
|
|
69488
69605
|
hardMinTokens: CONTEXT_WINDOW_HARD_MIN_TOKENS
|
|
69489
69606
|
});
|
|
69490
|
-
if (ctxGuard.shouldWarn) log$
|
|
69607
|
+
if (ctxGuard.shouldWarn) log$31.warn(`low context window: ${provider}/${modelId} ctx=${ctxGuard.tokens} (warn<${CONTEXT_WINDOW_WARN_BELOW_TOKENS}) source=${ctxGuard.source}`);
|
|
69491
69608
|
if (ctxGuard.shouldBlock) {
|
|
69492
|
-
log$
|
|
69609
|
+
log$31.error(`blocked model (context window too small): ${provider}/${modelId} ctx=${ctxGuard.tokens} (min=${CONTEXT_WINDOW_HARD_MIN_TOKENS}) source=${ctxGuard.source}`);
|
|
69493
69610
|
throw new FailoverError(`Model context window too small (${ctxGuard.tokens} tokens). Minimum is ${CONTEXT_WINDOW_HARD_MIN_TOKENS}.`, {
|
|
69494
69611
|
reason: "unknown",
|
|
69495
69612
|
provider,
|
|
@@ -69543,14 +69660,14 @@ async function runEmbeddedPiAgent(params) {
|
|
|
69543
69660
|
copilotTokenState.refreshInFlight = (async () => {
|
|
69544
69661
|
const githubToken = copilotTokenState.githubToken.trim();
|
|
69545
69662
|
if (!githubToken) throw new Error("Copilot refresh requires a GitHub token.");
|
|
69546
|
-
log$
|
|
69663
|
+
log$31.debug(`Refreshing GitHub Copilot token (${reason})...`);
|
|
69547
69664
|
const copilotToken = await resolveCopilotApiToken({ githubToken });
|
|
69548
69665
|
authStorage.setRuntimeApiKey(model.provider, copilotToken.token);
|
|
69549
69666
|
copilotTokenState.expiresAt = copilotToken.expiresAt;
|
|
69550
69667
|
const remaining = copilotToken.expiresAt - Date.now();
|
|
69551
|
-
log$
|
|
69668
|
+
log$31.debug(`Copilot token refreshed; expires in ${Math.max(0, Math.floor(remaining / 1e3))}s.`);
|
|
69552
69669
|
})().catch((err) => {
|
|
69553
|
-
log$
|
|
69670
|
+
log$31.warn(`Copilot token refresh failed: ${describeUnknownError(err)}`);
|
|
69554
69671
|
throw err;
|
|
69555
69672
|
}).finally(() => {
|
|
69556
69673
|
copilotTokenState.refreshInFlight = void 0;
|
|
@@ -69560,7 +69677,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
69560
69677
|
const scheduleCopilotRefresh = () => {
|
|
69561
69678
|
if (!copilotTokenState || copilotRefreshCancelled) return;
|
|
69562
69679
|
if (!hasCopilotGithubToken()) {
|
|
69563
|
-
log$
|
|
69680
|
+
log$31.warn("Skipping Copilot refresh scheduling; GitHub token missing.");
|
|
69564
69681
|
return;
|
|
69565
69682
|
}
|
|
69566
69683
|
clearCopilotRefreshTimer();
|
|
@@ -69722,7 +69839,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
69722
69839
|
while (true) {
|
|
69723
69840
|
if (runLoopIterations >= MAX_RUN_LOOP_ITERATIONS) {
|
|
69724
69841
|
const message = `Exceeded retry limit after ${runLoopIterations} attempts (max=${MAX_RUN_LOOP_ITERATIONS}).`;
|
|
69725
|
-
log$
|
|
69842
|
+
log$31.error(`[run-retry-limit] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} attempts=${runLoopIterations} maxAttempts=${MAX_RUN_LOOP_ITERATIONS}`);
|
|
69726
69843
|
logRunCompleted({
|
|
69727
69844
|
runId: params.runId,
|
|
69728
69845
|
sessionKey: params.sessionKey,
|
|
@@ -69886,21 +70003,21 @@ async function runEmbeddedPiAgent(params) {
|
|
|
69886
70003
|
const errorText = contextOverflowError.text;
|
|
69887
70004
|
const overflowStorage = getConfiguredSessionStorageRuntime();
|
|
69888
70005
|
const msgCount = attempt.messagesSnapshot?.length ?? 0;
|
|
69889
|
-
log$
|
|
70006
|
+
log$31.warn(`[context-overflow-diag] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} source=${contextOverflowError.source} messages=${msgCount} sessionFile=${params.sessionFile} diagId=${overflowDiagId} compactionAttempts=${overflowCompactionAttempts} error=${errorText.slice(0, 200)}`);
|
|
69890
70007
|
const isCompactionFailure = isCompactionFailureError(errorText);
|
|
69891
70008
|
const hadAttemptLevelCompaction = attemptCompactionCount > 0;
|
|
69892
70009
|
const explicitOverflowCompactionAllowed = params.trigger !== "analysis" && !params.disablePluginHooks && !params.skipTranscriptSync;
|
|
69893
70010
|
if (explicitOverflowCompactionAllowed && !isCompactionFailure && hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
69894
70011
|
overflowCompactionAttempts++;
|
|
69895
|
-
log$
|
|
70012
|
+
log$31.warn(`context overflow persisted after in-attempt compaction (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); retrying prompt without additional compaction for ${provider}/${modelId}`);
|
|
69896
70013
|
continue;
|
|
69897
70014
|
}
|
|
69898
70015
|
if (explicitOverflowCompactionAllowed && !isCompactionFailure && !hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
69899
|
-
if (log$
|
|
70016
|
+
if (log$31.isEnabled("debug")) log$31.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=compact isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts + 1} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
69900
70017
|
overflowCompactionAttempts++;
|
|
69901
|
-
log$
|
|
70018
|
+
log$31.warn(`context overflow detected (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); attempting auto-compaction for ${provider}/${modelId}`);
|
|
69902
70019
|
const _overflowIsDb = (overflowStorage?.runtime?.backend ?? "fs-jsonl") !== "fs-jsonl";
|
|
69903
|
-
if (_overflowIsDb) log$
|
|
70020
|
+
if (_overflowIsDb) log$31.warn(`context overflow compaction skipped for DB backend session ${params.sessionId}; compact.ts does not yet support DB-backend sessions`);
|
|
69904
70021
|
const compactResult = _overflowIsDb ? {
|
|
69905
70022
|
compacted: false,
|
|
69906
70023
|
reason: "db-backend-not-supported"
|
|
@@ -69933,10 +70050,10 @@ async function runEmbeddedPiAgent(params) {
|
|
|
69933
70050
|
});
|
|
69934
70051
|
if (compactResult.compacted) {
|
|
69935
70052
|
autoCompactionCount += 1;
|
|
69936
|
-
log$
|
|
70053
|
+
log$31.info(`auto-compaction succeeded for ${provider}/${modelId}; retrying prompt`);
|
|
69937
70054
|
continue;
|
|
69938
70055
|
}
|
|
69939
|
-
log$
|
|
70056
|
+
log$31.warn(`auto-compaction failed for ${provider}/${modelId}: ${compactResult.reason ?? "nothing to compact"}`);
|
|
69940
70057
|
}
|
|
69941
70058
|
if (!toolResultTruncationAttempted) {
|
|
69942
70059
|
const contextWindowTokens = ctxInfo.tokens;
|
|
@@ -69945,11 +70062,11 @@ async function runEmbeddedPiAgent(params) {
|
|
|
69945
70062
|
contextWindowTokens
|
|
69946
70063
|
}) : false;
|
|
69947
70064
|
if (hasOversized) {
|
|
69948
|
-
if (log$
|
|
70065
|
+
if (log$31.isEnabled("debug")) log$31.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=truncate_tool_results isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=${hasOversized} attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
69949
70066
|
toolResultTruncationAttempted = true;
|
|
69950
|
-
if ((overflowStorage?.runtime?.backend ?? "fs-jsonl") !== "fs-jsonl") log$
|
|
70067
|
+
if ((overflowStorage?.runtime?.backend ?? "fs-jsonl") !== "fs-jsonl") log$31.warn(`[context-overflow-recovery] Tool result truncation skipped for DB backend session ${params.sessionId}; tool-result-truncation.ts does not yet support DB-backend sessions`);
|
|
69951
70068
|
else {
|
|
69952
|
-
log$
|
|
70069
|
+
log$31.warn(`[context-overflow-recovery] Attempting tool result truncation for ${provider}/${modelId} (contextWindow=${contextWindowTokens} tokens)`);
|
|
69953
70070
|
const truncResult = await truncateOversizedToolResultsInSession({
|
|
69954
70071
|
sessionFile: params.sessionFile,
|
|
69955
70072
|
contextWindowTokens,
|
|
@@ -69957,14 +70074,14 @@ async function runEmbeddedPiAgent(params) {
|
|
|
69957
70074
|
sessionKey: params.sessionKey
|
|
69958
70075
|
});
|
|
69959
70076
|
if (truncResult.truncated) {
|
|
69960
|
-
log$
|
|
70077
|
+
log$31.info(`[context-overflow-recovery] Truncated ${truncResult.truncatedCount} tool result(s); retrying prompt`);
|
|
69961
70078
|
continue;
|
|
69962
70079
|
}
|
|
69963
|
-
log$
|
|
70080
|
+
log$31.warn(`[context-overflow-recovery] Tool result truncation did not help: ${truncResult.reason ?? "unknown"}`);
|
|
69964
70081
|
}
|
|
69965
|
-
} else if (log$
|
|
70082
|
+
} else if (log$31.isEnabled("debug")) log$31.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=give_up isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=${hasOversized} attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
69966
70083
|
}
|
|
69967
|
-
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS || toolResultTruncationAttempted) && log$
|
|
70084
|
+
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS || toolResultTruncationAttempted) && log$31.isEnabled("debug")) log$31.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=give_up isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
69968
70085
|
const kind = isCompactionFailure ? "compaction_failure" : "context_overflow";
|
|
69969
70086
|
logRunCompleted({
|
|
69970
70087
|
runId: params.runId,
|
|
@@ -70070,7 +70187,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
70070
70187
|
attempted: attemptedThinking
|
|
70071
70188
|
});
|
|
70072
70189
|
if (fallbackThinking) {
|
|
70073
|
-
log$
|
|
70190
|
+
log$31.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
70074
70191
|
thinkLevel = fallbackThinking;
|
|
70075
70192
|
continue;
|
|
70076
70193
|
}
|
|
@@ -70088,7 +70205,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
70088
70205
|
attempted: attemptedThinking
|
|
70089
70206
|
});
|
|
70090
70207
|
if (fallbackThinking && !aborted) {
|
|
70091
|
-
log$
|
|
70208
|
+
log$31.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
70092
70209
|
thinkLevel = fallbackThinking;
|
|
70093
70210
|
continue;
|
|
70094
70211
|
}
|
|
@@ -70109,7 +70226,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
70109
70226
|
imageDimensionError.contentIndex !== void 0 ? `content=${imageDimensionError.contentIndex}` : null,
|
|
70110
70227
|
imageDimensionError.maxDimensionPx !== void 0 ? `limit=${imageDimensionError.maxDimensionPx}px` : null
|
|
70111
70228
|
].filter(Boolean).join(" ");
|
|
70112
|
-
log$
|
|
70229
|
+
log$31.warn(`Profile ${lastProfileId} rejected image payload${details ? ` (${details})` : ""}.`);
|
|
70113
70230
|
}
|
|
70114
70231
|
if (!aborted && failoverFailure || timedOut && !timedOutDuringCompaction) {
|
|
70115
70232
|
if (lastProfileId) {
|
|
@@ -70117,8 +70234,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
70117
70234
|
profileId: lastProfileId,
|
|
70118
70235
|
reason: timedOut || assistantFailoverReason === "timeout" ? "timeout" : assistantFailoverReason ?? "unknown"
|
|
70119
70236
|
});
|
|
70120
|
-
if (timedOut && !isProbeSession) log$
|
|
70121
|
-
if (cloudCodeAssistFormatError) log$
|
|
70237
|
+
if (timedOut && !isProbeSession) log$31.warn(`Profile ${lastProfileId} timed out. Trying next account...`);
|
|
70238
|
+
if (cloudCodeAssistFormatError) log$31.warn(`Profile ${lastProfileId} hit Cloud Code Assist format error. Tool calls will be sanitized on retry.`);
|
|
70122
70239
|
}
|
|
70123
70240
|
if (await advanceAuthProfile()) continue;
|
|
70124
70241
|
if (fallbackConfigured) {
|
|
@@ -70163,7 +70280,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
70163
70280
|
}, hookCtx);
|
|
70164
70281
|
if (transformResult?.assistantTexts) finalAssistantTexts = transformResult.assistantTexts;
|
|
70165
70282
|
} catch (err) {
|
|
70166
|
-
log$
|
|
70283
|
+
log$31.warn(`transform_llm_output hook failed: ${String(err)}`);
|
|
70167
70284
|
}
|
|
70168
70285
|
const payloads = buildEmbeddedRunPayloads({
|
|
70169
70286
|
assistantTexts: finalAssistantTexts,
|
|
@@ -70214,7 +70331,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
70214
70331
|
durationMs: Date.now() - started,
|
|
70215
70332
|
exitStatus: aborted || timedOut ? "error" : void 0
|
|
70216
70333
|
});
|
|
70217
|
-
log$
|
|
70334
|
+
log$31.debug(`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`);
|
|
70218
70335
|
if (lastProfileId) {
|
|
70219
70336
|
await markAuthProfileGood({
|
|
70220
70337
|
store: authStore,
|
|
@@ -70251,7 +70368,6 @@ async function runEmbeddedPiAgent(params) {
|
|
|
70251
70368
|
}
|
|
70252
70369
|
} finally {
|
|
70253
70370
|
stopCopilotRefreshTimer();
|
|
70254
|
-
if (!params.skipCwdChange) process.chdir(prevCwd);
|
|
70255
70371
|
}
|
|
70256
70372
|
}));
|
|
70257
70373
|
}
|
|
@@ -97096,7 +97212,7 @@ async function registerSlackMonitorSlashCommands(params) {
|
|
|
97096
97212
|
const [{ resolveAgentRoute }, { finalizeInboundContext }, { dispatchReplyWithDispatcher }] = await Promise.all([
|
|
97097
97213
|
import("./resolve-route-DgcwkR0G.js").then((n) => n.r),
|
|
97098
97214
|
import("./inbound-context-BG7BNrcT.js").then((n) => n.n),
|
|
97099
|
-
import("./provider-dispatcher-
|
|
97215
|
+
import("./provider-dispatcher-CkSHbuj1.js")
|
|
97100
97216
|
]);
|
|
97101
97217
|
const [{ resolveConversationLabel }, { createReplyPrefixOptions }, { recordInboundSessionMetaSafe }] = await Promise.all([
|
|
97102
97218
|
import("./conversation-label-BXGlixeO.js"),
|