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
|
@@ -12,7 +12,7 @@ import { c as resolveSessionFilePath, f as resolveSessionTranscriptsDirForAgent,
|
|
|
12
12
|
import { n as resolveConversationLabel, r as normalizeChatType } from "./conversation-label-BnH5Yy9T.js";
|
|
13
13
|
import { a as createSlackWebClient, c as validateSlackBlocksArray, d as resolveSlackChannelId, i as normalizeSlackOutboundText, l as buildSlackBlocksFallbackText, o as resolveSlackWebClientOptions, s as parseSlackBlocksInput, t as sendMessageSlack, u as parseSlackTarget } from "./send-BwE4xzrN.js";
|
|
14
14
|
import { $ as fetchChannelPermissionsDiscord, A as unpinMessageDiscord, B as listScheduledEventsDiscord, C as editMessageDiscord, Ct as resolveTimestampMs, D as pinMessageDiscord, Dt as normalizeChannelSlug, E as listThreadsDiscord, Et as buildChannelKeyCandidates, F as fetchMemberInfoDiscord, G as uploadStickerDiscord, H as timeoutMemberDiscord, I as fetchRoleInfoDiscord, J as editChannelDiscord, K as createChannelDiscord, L as fetchVoiceStatusDiscord, M as banMemberDiscord, N as createScheduledEventDiscord, O as readMessagesDiscord, Ot as resolveChannelEntryMatchWithFallback, P as fetchChannelInfoDiscord, Q as stripUndefinedFields, R as kickMemberDiscord, S as deleteMessageDiscord, St as resolveDiscordSystemLocation, T as listPinsDiscord, Tt as applyChannelMatchMeta, U as listGuildEmojisDiscord, V as removeRoleDiscord, W as uploadEmojiDiscord, X as removeChannelPermissionDiscord, Y as moveChannelDiscord, Z as setChannelPermissionDiscord, _ as sendPollDiscord, _t as resolveDiscordShouldRequireMention, a as removeReactionDiscord, at as resolveDiscordChannelId, b as sendWebhookMessageDiscord, bt as formatDiscordReactionEmoji, c as formatDiscordComponentEventText, ct as isDiscordGroupAllowedByPolicy, d as parseDiscordModalCustomId, dt as resolveDiscordAllowListMatch, et as hasAnyGuildPermissionDiscord, f as parseDiscordModalCustomIdForCarbon, ft as resolveDiscordChannelConfigWithFallback, g as sendMessageDiscord, gt as resolveDiscordOwnerAllowFrom, h as resolveDiscordModalEntry, ht as resolveDiscordOwnerAccess, i as removeOwnReactionsDiscord, it as parseDiscordTarget, j as addRoleDiscord, k as searchMessagesDiscord, l as parseDiscordComponentCustomId, lt as normalizeDiscordAllowList, m as resolveDiscordComponentEntry, mt as resolveDiscordMemberAccessState, n as fetchReactionsDiscord, nt as createDiscordClient, o as sendDiscordComponentMessage, ot as listDiscordDirectoryGroupsLive, p as readDiscordComponentSpec, pt as resolveDiscordGuildEntry, q as deleteChannelDiscord, r as reactMessageDiscord, rt as createDiscordRestClient, s as createDiscordFormModal, st as listDiscordDirectoryPeersLive, tt as chunkDiscordTextWithMode, u as parseDiscordComponentCustomIdForCarbon, ut as normalizeDiscordSlug, v as sendStickerDiscord, vt as resolveGroupDmAllow, w as fetchMessageDiscord, wt as fetchDiscord, x as createThreadDiscord, xt as formatDiscordUserTag, y as sendVoiceMessageDiscord, yt as shouldEmitDiscordReactionNotification, z as listGuildChannelsDiscord } from "./send-1CZwevem.js";
|
|
15
|
-
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-
|
|
15
|
+
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-CwI9bK9W.js";
|
|
16
16
|
import { a as stripSilentToken, i as isSilentReplyText, n as SILENT_REPLY_TOKEN, r as isSilentReplyPrefixText, t as HEARTBEAT_TOKEN } from "./tokens-iu44eB15.js";
|
|
17
17
|
import { n as generateSecureUuid, t as generateSecureToken } from "./secure-random-BDA1WAvZ.js";
|
|
18
18
|
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-DW1ttWfz.js";
|
|
@@ -2968,7 +2968,7 @@ async function applyBootstrapHookOverrides(params) {
|
|
|
2968
2968
|
|
|
2969
2969
|
//#endregion
|
|
2970
2970
|
//#region src/agents/system-prompt-config.ts
|
|
2971
|
-
const log$
|
|
2971
|
+
const log$40 = createSubsystemLogger("agents/system-prompt-config");
|
|
2972
2972
|
const DEFAULT_PROMPT_SOURCE_MAX_CHARS = 2e4;
|
|
2973
2973
|
const MAX_PROMPT_SOURCE_FILE_BYTES = 512 * 1024;
|
|
2974
2974
|
const MAX_PROMPT_SOURCE_FILE_BYTES_HARD = 8 * 1024 * 1024;
|
|
@@ -3154,7 +3154,7 @@ async function readPromptSourceFile(params) {
|
|
|
3154
3154
|
if (!opened.ok) {
|
|
3155
3155
|
promptSourceCache.delete(absolutePath);
|
|
3156
3156
|
if (params.optional) {
|
|
3157
|
-
if (opened.reason !== "path") log$
|
|
3157
|
+
if (opened.reason !== "path") log$40.warn("skipping optional systemPrompt source: present but unusable", {
|
|
3158
3158
|
file: params.file,
|
|
3159
3159
|
reason: opened.reason
|
|
3160
3160
|
});
|
|
@@ -3178,7 +3178,7 @@ async function readPromptSourceFile(params) {
|
|
|
3178
3178
|
} catch (error) {
|
|
3179
3179
|
promptSourceCache.delete(opened.path);
|
|
3180
3180
|
if (params.optional) {
|
|
3181
|
-
log$
|
|
3181
|
+
log$40.warn("skipping optional systemPrompt source after read error", {
|
|
3182
3182
|
file: params.file,
|
|
3183
3183
|
error
|
|
3184
3184
|
});
|
|
@@ -3285,7 +3285,7 @@ async function resolveSystemPromptConfigForRun(params) {
|
|
|
3285
3285
|
|
|
3286
3286
|
//#endregion
|
|
3287
3287
|
//#region src/agents/workspace-lanes.ts
|
|
3288
|
-
const log$
|
|
3288
|
+
const log$39 = createSubsystemLogger("agents/workspace-lanes");
|
|
3289
3289
|
const DEFAULT_ROOT_TEMPLATE = "~/.openclaw/agents/{agentId}/lanes/{laneId}/workspace";
|
|
3290
3290
|
const SUPPORTED_STRATEGY = "hybrid";
|
|
3291
3291
|
const DEFAULT_COPIED_ON_CREATE_FILES = ["USER.md", "BOOTSTRAP.md"];
|
|
@@ -3438,7 +3438,7 @@ function resolveWorkspaceLane(params) {
|
|
|
3438
3438
|
actor: params.actor
|
|
3439
3439
|
});
|
|
3440
3440
|
if (!keyResult.ok) {
|
|
3441
|
-
log$
|
|
3441
|
+
log$39.warn("workspace lane key denied", {
|
|
3442
3442
|
agentId,
|
|
3443
3443
|
laneKeySource: keyResult.laneKeySource,
|
|
3444
3444
|
reason: keyResult.reason
|
|
@@ -3459,7 +3459,7 @@ function resolveWorkspaceLane(params) {
|
|
|
3459
3459
|
laneId: key.laneId
|
|
3460
3460
|
});
|
|
3461
3461
|
if (!rootTemplate.ok) {
|
|
3462
|
-
log$
|
|
3462
|
+
log$39.warn("workspace lane root template denied", {
|
|
3463
3463
|
agentId,
|
|
3464
3464
|
laneId: key.laneId,
|
|
3465
3465
|
laneKeySource: key.laneKeySource,
|
|
@@ -3477,7 +3477,7 @@ function resolveWorkspaceLane(params) {
|
|
|
3477
3477
|
}
|
|
3478
3478
|
const effectiveWorkspaceDir = rootTemplate.effectiveWorkspaceDir;
|
|
3479
3479
|
if (strategy !== SUPPORTED_STRATEGY) {
|
|
3480
|
-
log$
|
|
3480
|
+
log$39.warn("workspace lane strategy denied", {
|
|
3481
3481
|
agentId,
|
|
3482
3482
|
strategy
|
|
3483
3483
|
});
|
|
@@ -3572,7 +3572,7 @@ async function resolveWorkspaceLaneForTurn(params) {
|
|
|
3572
3572
|
if ((config?.create ?? "on-first-message") !== "on-first-message") {
|
|
3573
3573
|
const pathState = await getExistingPathState(resolution.effectiveWorkspaceDir);
|
|
3574
3574
|
if (pathState !== "directory") {
|
|
3575
|
-
log$
|
|
3575
|
+
log$39.warn("workspace lane manual creation denied", {
|
|
3576
3576
|
agentId: resolution.agentId,
|
|
3577
3577
|
laneId: resolution.laneId,
|
|
3578
3578
|
laneKeySource: resolution.laneKeySource,
|
|
@@ -3598,7 +3598,7 @@ async function resolveWorkspaceLaneForTurn(params) {
|
|
|
3598
3598
|
targetRoot: resolution.effectiveWorkspaceDir,
|
|
3599
3599
|
relativePath: file
|
|
3600
3600
|
});
|
|
3601
|
-
if (decision === "copied" || !existed) log$
|
|
3601
|
+
if (decision === "copied" || !existed) log$39.info("workspace lane seed file decision", {
|
|
3602
3602
|
agentId: resolution.agentId,
|
|
3603
3603
|
laneId: resolution.laneId,
|
|
3604
3604
|
laneKeySource: resolution.laneKeySource,
|
|
@@ -3607,7 +3607,7 @@ async function resolveWorkspaceLaneForTurn(params) {
|
|
|
3607
3607
|
});
|
|
3608
3608
|
}
|
|
3609
3609
|
const created = !existed;
|
|
3610
|
-
if (created) log$
|
|
3610
|
+
if (created) log$39.info("workspace lane created", {
|
|
3611
3611
|
agentId: resolution.agentId,
|
|
3612
3612
|
laneId: resolution.laneId,
|
|
3613
3613
|
laneKeySource: resolution.laneKeySource
|
|
@@ -4502,7 +4502,7 @@ function resolveExecSafeBinRuntimePolicy(params) {
|
|
|
4502
4502
|
|
|
4503
4503
|
//#endregion
|
|
4504
4504
|
//#region src/plugins/activation-migration.ts
|
|
4505
|
-
const log$
|
|
4505
|
+
const log$38 = createSubsystemLogger("plugins/activation-migration");
|
|
4506
4506
|
/**
|
|
4507
4507
|
* One-time migration from the presence-implies-load model to explicit-enable (ADR 0016).
|
|
4508
4508
|
* Runs synchronously inside loadOpenClawPlugins, before resolveEnableState is applied.
|
|
@@ -4544,7 +4544,7 @@ function runActivationMigrationIfNeeded(config, pluginRecords) {
|
|
|
4544
4544
|
activationMigrationVersion: 1
|
|
4545
4545
|
}
|
|
4546
4546
|
};
|
|
4547
|
-
if (toEnable.size > 0) log$
|
|
4547
|
+
if (toEnable.size > 0) log$38.info(`activation migration v1: auto-enabled ${toEnable.size} previously-active plugin(s)`, { ids: [...toEnable] });
|
|
4548
4548
|
return next;
|
|
4549
4549
|
}
|
|
4550
4550
|
|
|
@@ -4667,7 +4667,7 @@ function estimateUsageCost(params) {
|
|
|
4667
4667
|
|
|
4668
4668
|
//#endregion
|
|
4669
4669
|
//#region src/plugins/runtime/runtime-analysis-direct.ts
|
|
4670
|
-
const log$
|
|
4670
|
+
const log$37 = createSubsystemLogger("plugins/runtime/analysis");
|
|
4671
4671
|
const NEUTRAL_ANALYSIS_SYSTEM_PROMPT = "You are running a focused internal analysis for a WednesdayAI extension. Return only the requested result.";
|
|
4672
4672
|
function isJsonResponseFormat(params) {
|
|
4673
4673
|
return params.responseFormat === "json" || typeof params.responseFormat === "object" && params.responseFormat.type === "json_schema";
|
|
@@ -4727,8 +4727,8 @@ async function runDirectAnalysis(req, overrides) {
|
|
|
4727
4727
|
elapsedMs: full.elapsedMs,
|
|
4728
4728
|
error: full.error
|
|
4729
4729
|
};
|
|
4730
|
-
if (full.status === "ok" || full.status === "empty") log$
|
|
4731
|
-
else log$
|
|
4730
|
+
if (full.status === "ok" || full.status === "empty") log$37.info("direct analysis run", logFields);
|
|
4731
|
+
else log$37.warn("direct analysis run failed", logFields);
|
|
4732
4732
|
return full;
|
|
4733
4733
|
};
|
|
4734
4734
|
const controller = new AbortController();
|
|
@@ -4867,7 +4867,7 @@ async function runDirectAnalysis(req, overrides) {
|
|
|
4867
4867
|
|
|
4868
4868
|
//#endregion
|
|
4869
4869
|
//#region src/plugins/runtime/runtime-analysis.ts
|
|
4870
|
-
const log$
|
|
4870
|
+
const log$36 = createSubsystemLogger("plugins/runtime/analysis");
|
|
4871
4871
|
const DEFAULT_RUN_TIMEOUT_MS = 15e3;
|
|
4872
4872
|
const MIN_TIMEOUT_MS = 250;
|
|
4873
4873
|
const MAX_TIMEOUT_MS = 12e4;
|
|
@@ -4908,7 +4908,7 @@ function finalizeAnalysisResult(result, cfg, transport) {
|
|
|
4908
4908
|
const { costUsd: _untrusted, ...rest } = result;
|
|
4909
4909
|
let usageState = result.usageState;
|
|
4910
4910
|
if (usageState === void 0) {
|
|
4911
|
-
log$
|
|
4911
|
+
log$36.warn("analysis result missing usageState; treating the call as spent", {
|
|
4912
4912
|
transport,
|
|
4913
4913
|
status: result.status,
|
|
4914
4914
|
provider: result.provider,
|
|
@@ -5337,7 +5337,7 @@ async function executeAnalysisTransport(params, deps, fallbackTimeoutMs, lane, c
|
|
|
5337
5337
|
if (err instanceof CommandLaneAbortedError && !providerDispatched) return queuedCancellation();
|
|
5338
5338
|
const message = err instanceof Error ? err.message : String(err);
|
|
5339
5339
|
const status = /timed?\s*out|timeout/i.test(message) ? "timeout" : "error";
|
|
5340
|
-
log$
|
|
5340
|
+
log$36.warn("analysis run failed", {
|
|
5341
5341
|
purpose: params.purpose,
|
|
5342
5342
|
pluginId: params.pluginId,
|
|
5343
5343
|
status,
|
|
@@ -5398,7 +5398,7 @@ function createRuntimeAnalysis(deps = {}, concurrencyConfig) {
|
|
|
5398
5398
|
try {
|
|
5399
5399
|
await onComplete(result);
|
|
5400
5400
|
} catch (err) {
|
|
5401
|
-
log$
|
|
5401
|
+
log$36.warn("analysis enqueue completion failed", {
|
|
5402
5402
|
purpose: params.purpose,
|
|
5403
5403
|
error: err instanceof Error ? err.message : String(err)
|
|
5404
5404
|
});
|
|
@@ -5454,7 +5454,7 @@ function createRuntimeAnalysis(deps = {}, concurrencyConfig) {
|
|
|
5454
5454
|
(async () => {
|
|
5455
5455
|
try {
|
|
5456
5456
|
const result = await executeAnalysis(job.params, mergedDeps, DEFAULT_RUN_TIMEOUT_MS, CommandLane.Analysis);
|
|
5457
|
-
log$
|
|
5457
|
+
log$36.info("analysis run completed", {
|
|
5458
5458
|
pluginId: job.params.pluginId,
|
|
5459
5459
|
purpose: job.params.purpose,
|
|
5460
5460
|
durationMs: result.elapsedMs,
|
|
@@ -5503,7 +5503,7 @@ function createRuntimeAnalysis(deps = {}, concurrencyConfig) {
|
|
|
5503
5503
|
const parallelSlot = activeParallelRuns;
|
|
5504
5504
|
try {
|
|
5505
5505
|
const result = await executeAnalysis(runParams, mergedDeps, DEFAULT_RUN_TIMEOUT_MS, CommandLane.Analysis);
|
|
5506
|
-
log$
|
|
5506
|
+
log$36.info("analysis run completed", {
|
|
5507
5507
|
pluginId: runParams.pluginId,
|
|
5508
5508
|
purpose: params.purpose,
|
|
5509
5509
|
durationMs: result.elapsedMs,
|
|
@@ -5541,7 +5541,7 @@ function createRuntimeAnalysis(deps = {}, concurrencyConfig) {
|
|
|
5541
5541
|
});
|
|
5542
5542
|
}
|
|
5543
5543
|
const admissionBoundary = limitsForPlugin(key).maxSequentialPerPlugin > 0 && readCount(queuedAwaitedAnalysisRunsByPlugin, key) >= limitsForPlugin(key).maxSequentialPerPlugin ? "plugin-queue" : maxSequential > 0 && sequentialQueue.length >= maxSequential ? "global-queue" : readCount(activeAwaitedAnalysisRunsByPlugin, key) >= limitsForPlugin(key).maxParallelPerPlugin ? "plugin-active" : "global-active";
|
|
5544
|
-
log$
|
|
5544
|
+
log$36.info("analysis run rejected", {
|
|
5545
5545
|
pluginId: runParams.pluginId,
|
|
5546
5546
|
purpose: params.purpose,
|
|
5547
5547
|
error: "analysis concurrency limit exceeded",
|
|
@@ -6608,6 +6608,60 @@ async function withAcpRuntimeErrorBoundary(params) {
|
|
|
6608
6608
|
}
|
|
6609
6609
|
}
|
|
6610
6610
|
|
|
6611
|
+
//#endregion
|
|
6612
|
+
//#region src/acp/runtime/registry.ts
|
|
6613
|
+
const ACP_RUNTIME_REGISTRY_STATE_KEY = Symbol.for("openclaw.acpRuntimeRegistryState");
|
|
6614
|
+
function createAcpRuntimeRegistryGlobalState() {
|
|
6615
|
+
return { backendsById: /* @__PURE__ */ new Map() };
|
|
6616
|
+
}
|
|
6617
|
+
function resolveAcpRuntimeRegistryGlobalState() {
|
|
6618
|
+
const runtimeGlobal = globalThis;
|
|
6619
|
+
if (!runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY]) runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY] = createAcpRuntimeRegistryGlobalState();
|
|
6620
|
+
return runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY];
|
|
6621
|
+
}
|
|
6622
|
+
const ACP_BACKENDS_BY_ID = resolveAcpRuntimeRegistryGlobalState().backendsById;
|
|
6623
|
+
function normalizeBackendId(id) {
|
|
6624
|
+
return id?.trim().toLowerCase() || "";
|
|
6625
|
+
}
|
|
6626
|
+
function isBackendHealthy(backend) {
|
|
6627
|
+
if (!backend.healthy) return true;
|
|
6628
|
+
try {
|
|
6629
|
+
return backend.healthy();
|
|
6630
|
+
} catch {
|
|
6631
|
+
return false;
|
|
6632
|
+
}
|
|
6633
|
+
}
|
|
6634
|
+
function getAcpRuntimeBackend(id) {
|
|
6635
|
+
const normalized = normalizeBackendId(id);
|
|
6636
|
+
if (normalized) return ACP_BACKENDS_BY_ID.get(normalized) ?? null;
|
|
6637
|
+
if (ACP_BACKENDS_BY_ID.size === 0) return null;
|
|
6638
|
+
for (const backend of ACP_BACKENDS_BY_ID.values()) if (isBackendHealthy(backend)) return backend;
|
|
6639
|
+
return ACP_BACKENDS_BY_ID.values().next().value ?? null;
|
|
6640
|
+
}
|
|
6641
|
+
function requireAcpRuntimeBackend(id) {
|
|
6642
|
+
const normalized = normalizeBackendId(id);
|
|
6643
|
+
const backend = getAcpRuntimeBackend(normalized || void 0);
|
|
6644
|
+
if (!backend) throw new AcpRuntimeError("ACP_BACKEND_MISSING", "ACP runtime backend is not configured. Install and enable the acpx runtime plugin.");
|
|
6645
|
+
if (!isBackendHealthy(backend)) throw new AcpRuntimeError("ACP_BACKEND_UNAVAILABLE", "ACP runtime backend is currently unavailable. Try again in a moment.");
|
|
6646
|
+
if (normalized && backend.id !== normalized) throw new AcpRuntimeError("ACP_BACKEND_MISSING", `ACP runtime backend "${normalized}" is not registered.`);
|
|
6647
|
+
return backend;
|
|
6648
|
+
}
|
|
6649
|
+
async function waitForAcpRuntimeBackendHealthy(params) {
|
|
6650
|
+
const normalized = normalizeBackendId(params.id);
|
|
6651
|
+
const pollMs = params.pollMs ?? 250;
|
|
6652
|
+
const deadline = Date.now() + params.timeoutMs;
|
|
6653
|
+
for (;;) {
|
|
6654
|
+
const backend = getAcpRuntimeBackend(normalized || void 0);
|
|
6655
|
+
if (!backend) return false;
|
|
6656
|
+
if (isBackendHealthy(backend)) return true;
|
|
6657
|
+
const remainingMs = deadline - Date.now();
|
|
6658
|
+
if (remainingMs <= 0) return false;
|
|
6659
|
+
await new Promise((resolve) => {
|
|
6660
|
+
setTimeout(resolve, Math.min(pollMs, remainingMs)).unref();
|
|
6661
|
+
});
|
|
6662
|
+
}
|
|
6663
|
+
}
|
|
6664
|
+
|
|
6611
6665
|
//#endregion
|
|
6612
6666
|
//#region src/acp/runtime/session-identity.ts
|
|
6613
6667
|
function normalizeText$2(value) {
|
|
@@ -7120,45 +7174,6 @@ async function applyManagerRuntimeControls(params) {
|
|
|
7120
7174
|
if (cached) cached.appliedControlSignature = signature;
|
|
7121
7175
|
}
|
|
7122
7176
|
|
|
7123
|
-
//#endregion
|
|
7124
|
-
//#region src/acp/runtime/registry.ts
|
|
7125
|
-
const ACP_RUNTIME_REGISTRY_STATE_KEY = Symbol.for("openclaw.acpRuntimeRegistryState");
|
|
7126
|
-
function createAcpRuntimeRegistryGlobalState() {
|
|
7127
|
-
return { backendsById: /* @__PURE__ */ new Map() };
|
|
7128
|
-
}
|
|
7129
|
-
function resolveAcpRuntimeRegistryGlobalState() {
|
|
7130
|
-
const runtimeGlobal = globalThis;
|
|
7131
|
-
if (!runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY]) runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY] = createAcpRuntimeRegistryGlobalState();
|
|
7132
|
-
return runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY];
|
|
7133
|
-
}
|
|
7134
|
-
const ACP_BACKENDS_BY_ID = resolveAcpRuntimeRegistryGlobalState().backendsById;
|
|
7135
|
-
function normalizeBackendId(id) {
|
|
7136
|
-
return id?.trim().toLowerCase() || "";
|
|
7137
|
-
}
|
|
7138
|
-
function isBackendHealthy(backend) {
|
|
7139
|
-
if (!backend.healthy) return true;
|
|
7140
|
-
try {
|
|
7141
|
-
return backend.healthy();
|
|
7142
|
-
} catch {
|
|
7143
|
-
return false;
|
|
7144
|
-
}
|
|
7145
|
-
}
|
|
7146
|
-
function getAcpRuntimeBackend(id) {
|
|
7147
|
-
const normalized = normalizeBackendId(id);
|
|
7148
|
-
if (normalized) return ACP_BACKENDS_BY_ID.get(normalized) ?? null;
|
|
7149
|
-
if (ACP_BACKENDS_BY_ID.size === 0) return null;
|
|
7150
|
-
for (const backend of ACP_BACKENDS_BY_ID.values()) if (isBackendHealthy(backend)) return backend;
|
|
7151
|
-
return ACP_BACKENDS_BY_ID.values().next().value ?? null;
|
|
7152
|
-
}
|
|
7153
|
-
function requireAcpRuntimeBackend(id) {
|
|
7154
|
-
const normalized = normalizeBackendId(id);
|
|
7155
|
-
const backend = getAcpRuntimeBackend(normalized || void 0);
|
|
7156
|
-
if (!backend) throw new AcpRuntimeError("ACP_BACKEND_MISSING", "ACP runtime backend is not configured. Install and enable the acpx runtime plugin.");
|
|
7157
|
-
if (!isBackendHealthy(backend)) throw new AcpRuntimeError("ACP_BACKEND_UNAVAILABLE", "ACP runtime backend is currently unavailable. Try again in a moment.");
|
|
7158
|
-
if (normalized && backend.id !== normalized) throw new AcpRuntimeError("ACP_BACKEND_MISSING", `ACP runtime backend "${normalized}" is not registered.`);
|
|
7159
|
-
return backend;
|
|
7160
|
-
}
|
|
7161
|
-
|
|
7162
7177
|
//#endregion
|
|
7163
7178
|
//#region src/agents/session-dirs.ts
|
|
7164
7179
|
async function resolveAgentSessionDirs(stateDir) {
|
|
@@ -7359,6 +7374,9 @@ var SessionActorQueue = class {
|
|
|
7359
7374
|
|
|
7360
7375
|
//#endregion
|
|
7361
7376
|
//#region src/acp/control-plane/manager.core.ts
|
|
7377
|
+
const log$35 = createSubsystemLogger("acp/manager");
|
|
7378
|
+
const STARTUP_RECONCILE_BACKEND_WAIT_MS = 3e4;
|
|
7379
|
+
const STARTUP_RECONCILE_BACKEND_POLL_MS = 250;
|
|
7362
7380
|
var AcpSessionManager = class {
|
|
7363
7381
|
constructor(deps = DEFAULT_DEPS) {
|
|
7364
7382
|
this.deps = deps;
|
|
@@ -7436,34 +7454,54 @@ var AcpSessionManager = class {
|
|
|
7436
7454
|
failed: failed + 1
|
|
7437
7455
|
};
|
|
7438
7456
|
}
|
|
7457
|
+
const logFailure = (sessionKey, acpError) => {
|
|
7458
|
+
const redactedKey = redactIdentifier(sessionKey);
|
|
7459
|
+
log$35.warn(`startup identity reconcile failed for ${redactedKey}: code=${acpError.code} ${acpError.message.replaceAll(sessionKey, redactedKey)}`);
|
|
7460
|
+
};
|
|
7461
|
+
const toReconcileError = (error) => toAcpRuntimeError({
|
|
7462
|
+
error,
|
|
7463
|
+
fallbackCode: "ACP_SESSION_INIT_FAILED",
|
|
7464
|
+
fallbackMessage: "ACP startup identity reconcile failed."
|
|
7465
|
+
});
|
|
7466
|
+
const deferred = [];
|
|
7439
7467
|
for (const session of acpSessions) {
|
|
7440
7468
|
if (!session.acp || !session.sessionKey) continue;
|
|
7441
7469
|
if (!isSessionIdentityPending(resolveSessionIdentityFromMeta(session.acp))) continue;
|
|
7442
7470
|
checked += 1;
|
|
7443
7471
|
try {
|
|
7444
|
-
if (await this.
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
if (resolution.kind !== "ready") return false;
|
|
7450
|
-
const { runtime, handle, meta } = await this.ensureRuntimeHandle({
|
|
7451
|
-
cfg: params.cfg,
|
|
7472
|
+
if (await this.reconcileOneSessionIdentity(params.cfg, session.sessionKey)) resolved += 1;
|
|
7473
|
+
} catch (error) {
|
|
7474
|
+
const acpError = toReconcileError(error);
|
|
7475
|
+
if (acpError.code === "ACP_BACKEND_UNAVAILABLE") {
|
|
7476
|
+
deferred.push({
|
|
7452
7477
|
sessionKey: session.sessionKey,
|
|
7453
|
-
|
|
7478
|
+
backend: (session.acp.backend || params.cfg.acp?.backend || "").trim()
|
|
7454
7479
|
});
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
sessionKey: session.sessionKey,
|
|
7458
|
-
runtime,
|
|
7459
|
-
handle,
|
|
7460
|
-
meta,
|
|
7461
|
-
failOnStatusError: false
|
|
7462
|
-
})).meta));
|
|
7463
|
-
})) resolved += 1;
|
|
7464
|
-
} catch (error) {
|
|
7480
|
+
continue;
|
|
7481
|
+
}
|
|
7465
7482
|
failed += 1;
|
|
7466
|
-
|
|
7483
|
+
logFailure(session.sessionKey, acpError);
|
|
7484
|
+
}
|
|
7485
|
+
}
|
|
7486
|
+
if (deferred.length > 0) {
|
|
7487
|
+
const backendIds = [...new Set(deferred.map(({ backend }) => backend))];
|
|
7488
|
+
const healthyByBackend = new Map(await Promise.all(backendIds.map(async (backend) => [backend, await waitForAcpRuntimeBackendHealthy({
|
|
7489
|
+
id: backend || void 0,
|
|
7490
|
+
timeoutMs: params.backendWaitMs ?? STARTUP_RECONCILE_BACKEND_WAIT_MS,
|
|
7491
|
+
pollMs: params.backendPollMs ?? STARTUP_RECONCILE_BACKEND_POLL_MS
|
|
7492
|
+
})])));
|
|
7493
|
+
for (const { sessionKey, backend } of deferred) {
|
|
7494
|
+
if (!healthyByBackend.get(backend)) {
|
|
7495
|
+
failed += 1;
|
|
7496
|
+
logFailure(sessionKey, new AcpRuntimeError("ACP_BACKEND_UNAVAILABLE", `ACP runtime backend${backend ? ` "${backend}"` : ""} did not become healthy before the startup wait expired.`));
|
|
7497
|
+
continue;
|
|
7498
|
+
}
|
|
7499
|
+
try {
|
|
7500
|
+
if (await this.reconcileOneSessionIdentity(params.cfg, sessionKey)) resolved += 1;
|
|
7501
|
+
} catch (error) {
|
|
7502
|
+
failed += 1;
|
|
7503
|
+
logFailure(sessionKey, toReconcileError(error));
|
|
7504
|
+
}
|
|
7467
7505
|
}
|
|
7468
7506
|
}
|
|
7469
7507
|
return {
|
|
@@ -7472,6 +7510,37 @@ var AcpSessionManager = class {
|
|
|
7472
7510
|
failed
|
|
7473
7511
|
};
|
|
7474
7512
|
}
|
|
7513
|
+
async reconcileOneSessionIdentity(cfg, sessionKey) {
|
|
7514
|
+
return await this.withSessionActor(sessionKey, async () => {
|
|
7515
|
+
const resolution = this.resolveSession({
|
|
7516
|
+
cfg,
|
|
7517
|
+
sessionKey
|
|
7518
|
+
});
|
|
7519
|
+
if (resolution.kind !== "ready") return false;
|
|
7520
|
+
const { runtime, handle, meta } = await this.ensureRuntimeHandle({
|
|
7521
|
+
cfg,
|
|
7522
|
+
sessionKey,
|
|
7523
|
+
meta: resolution.meta
|
|
7524
|
+
});
|
|
7525
|
+
try {
|
|
7526
|
+
return !isSessionIdentityPending(resolveSessionIdentityFromMeta((await this.reconcileRuntimeSessionIdentifiers({
|
|
7527
|
+
cfg,
|
|
7528
|
+
sessionKey,
|
|
7529
|
+
runtime,
|
|
7530
|
+
handle,
|
|
7531
|
+
meta,
|
|
7532
|
+
failOnStatusError: true
|
|
7533
|
+
})).meta));
|
|
7534
|
+
} catch (error) {
|
|
7535
|
+
const stored = this.deps.readSessionEntry({
|
|
7536
|
+
cfg,
|
|
7537
|
+
sessionKey
|
|
7538
|
+
})?.acp;
|
|
7539
|
+
if (stored && !isSessionIdentityPending(resolveSessionIdentityFromMeta(stored))) return true;
|
|
7540
|
+
throw error;
|
|
7541
|
+
}
|
|
7542
|
+
});
|
|
7543
|
+
}
|
|
7475
7544
|
async initializeSession(input) {
|
|
7476
7545
|
const sessionKey = normalizeSessionKey$1(input.sessionKey);
|
|
7477
7546
|
if (!sessionKey) throw new AcpRuntimeError("ACP_SESSION_INIT_FAILED", "ACP session key is required.");
|
|
@@ -18067,7 +18136,7 @@ function stopSweeper$1() {
|
|
|
18067
18136
|
|
|
18068
18137
|
//#endregion
|
|
18069
18138
|
//#region src/infra/exec-approvals.ts
|
|
18070
|
-
const log$
|
|
18139
|
+
const log$34 = createSubsystemLogger("infra/exec-approvals");
|
|
18071
18140
|
const APPROVALS_FILE = join(process.env.HOME ?? "/tmp", ".openclaw", "exec-approvals.json");
|
|
18072
18141
|
const DEFAULT_SECURITY = "deny";
|
|
18073
18142
|
const DEFAULT_ASK = "on-miss";
|
|
@@ -19317,7 +19386,7 @@ function createRunRegistry(options) {
|
|
|
19317
19386
|
|
|
19318
19387
|
//#endregion
|
|
19319
19388
|
//#region src/process/supervisor/supervisor.ts
|
|
19320
|
-
const log$
|
|
19389
|
+
const log$33 = createSubsystemLogger("process/supervisor");
|
|
19321
19390
|
function clampTimeout(value) {
|
|
19322
19391
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return;
|
|
19323
19392
|
return Math.max(1, Math.floor(value));
|
|
@@ -19503,7 +19572,7 @@ function createProcessSupervisor() {
|
|
|
19503
19572
|
exitCode: null,
|
|
19504
19573
|
exitSignal: null
|
|
19505
19574
|
});
|
|
19506
|
-
log$
|
|
19575
|
+
log$33.warn(`spawn failed: runId=${runId} reason=${String(err)}`);
|
|
19507
19576
|
throw err;
|
|
19508
19577
|
}
|
|
19509
19578
|
};
|
|
@@ -20530,7 +20599,7 @@ function normalizeSystemRunApprovalPlan(value) {
|
|
|
20530
20599
|
|
|
20531
20600
|
//#endregion
|
|
20532
20601
|
//#region src/infra/system-run-command.ts
|
|
20533
|
-
const log$
|
|
20602
|
+
const log$32 = createSubsystemLogger("infra/system-run-command");
|
|
20534
20603
|
function formatExecCommand(argv) {
|
|
20535
20604
|
return argv.map((arg) => {
|
|
20536
20605
|
if (arg.length === 0) return "\"\"";
|
|
@@ -25573,7 +25642,7 @@ const FIELD_LABELS = {
|
|
|
25573
25642
|
|
|
25574
25643
|
//#endregion
|
|
25575
25644
|
//#region src/config/schema.hints.ts
|
|
25576
|
-
const log$
|
|
25645
|
+
const log$31 = createSubsystemLogger("config/schema");
|
|
25577
25646
|
const NORMALIZED_SENSITIVE_KEY_WHITELIST_SUFFIXES = [
|
|
25578
25647
|
"maxtokens",
|
|
25579
25648
|
"maxoutputtokens",
|
|
@@ -25614,7 +25683,7 @@ function isSensitiveConfigPath(path) {
|
|
|
25614
25683
|
|
|
25615
25684
|
//#endregion
|
|
25616
25685
|
//#region src/config/redact-snapshot.ts
|
|
25617
|
-
const log$
|
|
25686
|
+
const log$30 = createSubsystemLogger("config/redaction");
|
|
25618
25687
|
const ENV_VAR_PLACEHOLDER_PATTERN = /^\$\{[^}]*\}$/;
|
|
25619
25688
|
function isSensitivePath(path) {
|
|
25620
25689
|
if (path.endsWith("[]")) return isSensitiveConfigPath(path.slice(0, -2));
|
|
@@ -32071,7 +32140,7 @@ async function handleSubagentsLogAction(ctx) {
|
|
|
32071
32140
|
|
|
32072
32141
|
//#endregion
|
|
32073
32142
|
//#region src/agents/pi-embedded-runner/logger.ts
|
|
32074
|
-
const log$
|
|
32143
|
+
const log$29 = createSubsystemLogger("agent/embedded");
|
|
32075
32144
|
|
|
32076
32145
|
//#endregion
|
|
32077
32146
|
//#region src/agents/pi-embedded-runner/run-sender-identity.ts
|
|
@@ -32116,7 +32185,7 @@ function resolveRunSenderIdentity(params) {
|
|
|
32116
32185
|
candidate: params.inheritedCanonicalIdentity
|
|
32117
32186
|
});
|
|
32118
32187
|
if (inherited) {
|
|
32119
|
-
log$
|
|
32188
|
+
log$29.info("runtime identity injected", {
|
|
32120
32189
|
identitySource: "parent-session",
|
|
32121
32190
|
canonicalIdentity: inherited,
|
|
32122
32191
|
trigger: params.trigger,
|
|
@@ -32135,7 +32204,7 @@ function resolveRunSenderIdentity(params) {
|
|
|
32135
32204
|
candidate: params.configuredIdentity
|
|
32136
32205
|
});
|
|
32137
32206
|
if (configured) {
|
|
32138
|
-
log$
|
|
32207
|
+
log$29.info("runtime identity injected", {
|
|
32139
32208
|
identitySource: "job-config",
|
|
32140
32209
|
canonicalIdentity: configured,
|
|
32141
32210
|
trigger: params.trigger,
|
|
@@ -38204,7 +38273,7 @@ const REMINDER_CONTEXT_MESSAGES_MAX = 10;
|
|
|
38204
38273
|
const REMINDER_CONTEXT_PER_MESSAGE_MAX = 220;
|
|
38205
38274
|
const REMINDER_CONTEXT_TOTAL_MAX = 700;
|
|
38206
38275
|
const REMINDER_CONTEXT_MARKER = "\n\nRecent context:\n";
|
|
38207
|
-
const log$
|
|
38276
|
+
const log$28 = createSubsystemLogger("cron-tool");
|
|
38208
38277
|
const AGENT_FORBIDDEN_JOB_FIELDS = new Set(["identity", "state"]);
|
|
38209
38278
|
const JOB_KEYS = new Set([
|
|
38210
38279
|
"name",
|
|
@@ -38340,7 +38409,7 @@ async function buildReminderContextLines(params) {
|
|
|
38340
38409
|
}
|
|
38341
38410
|
return lines;
|
|
38342
38411
|
} catch (err) {
|
|
38343
|
-
log$
|
|
38412
|
+
log$28.warn("reminder context fetch failed", { error: err });
|
|
38344
38413
|
return ["- (context unavailable: gateway unreachable)"];
|
|
38345
38414
|
}
|
|
38346
38415
|
}
|
|
@@ -38896,7 +38965,7 @@ function assertGatewayToolActionAllowed(params) {
|
|
|
38896
38965
|
|
|
38897
38966
|
//#endregion
|
|
38898
38967
|
//#region src/agents/tools/gateway-tool.ts
|
|
38899
|
-
const log$
|
|
38968
|
+
const log$27 = createSubsystemLogger("gateway-tool");
|
|
38900
38969
|
const DEFAULT_UPDATE_TIMEOUT_MS = 20 * 6e4;
|
|
38901
38970
|
const GatewayToolSchema = Type.Object({
|
|
38902
38971
|
action: stringEnum([
|
|
@@ -38964,7 +39033,7 @@ function createGatewayTool(opts) {
|
|
|
38964
39033
|
try {
|
|
38965
39034
|
await writeRestartSentinel(payload);
|
|
38966
39035
|
} catch {}
|
|
38967
|
-
log$
|
|
39036
|
+
log$27.info(`gateway tool: restart requested (delayMs=${delayMs ?? "default"}, reason=${reason ?? "none"})`);
|
|
38968
39037
|
return jsonResult(scheduleGatewaySigusr1Restart({
|
|
38969
39038
|
delayMs,
|
|
38970
39039
|
reason
|
|
@@ -45876,7 +45945,7 @@ async function resolveAnnounceTarget(params) {
|
|
|
45876
45945
|
|
|
45877
45946
|
//#endregion
|
|
45878
45947
|
//#region src/agents/tools/sessions-send-tool.a2a.ts
|
|
45879
|
-
const log$
|
|
45948
|
+
const log$26 = createSubsystemLogger("agents/sessions-send");
|
|
45880
45949
|
async function runSessionsSendA2AFlow(params) {
|
|
45881
45950
|
const runContextId = params.waitRunId ?? "unknown";
|
|
45882
45951
|
try {
|
|
@@ -45971,7 +46040,7 @@ async function runSessionsSendA2AFlow(params) {
|
|
|
45971
46040
|
timeoutMs: 1e4
|
|
45972
46041
|
});
|
|
45973
46042
|
} catch (err) {
|
|
45974
|
-
log$
|
|
46043
|
+
log$26.warn("sessions_send announce delivery failed", {
|
|
45975
46044
|
runId: runContextId,
|
|
45976
46045
|
channel: announceTarget.channel,
|
|
45977
46046
|
to: announceTarget.to,
|
|
@@ -45979,7 +46048,7 @@ async function runSessionsSendA2AFlow(params) {
|
|
|
45979
46048
|
});
|
|
45980
46049
|
}
|
|
45981
46050
|
} catch (err) {
|
|
45982
|
-
log$
|
|
46051
|
+
log$26.warn("sessions_send announce flow failed", {
|
|
45983
46052
|
runId: runContextId,
|
|
45984
46053
|
error: formatErrorMessage(err)
|
|
45985
46054
|
});
|
|
@@ -46759,7 +46828,7 @@ const BACKGROUND_IDLE_RECHECK_MS = 1e3;
|
|
|
46759
46828
|
const BACKGROUND_IDLE_MAX_ATTEMPTS = 30;
|
|
46760
46829
|
const backgroundIdleAttempts = /* @__PURE__ */ new Map();
|
|
46761
46830
|
const SIGNAL_DEADLINE_GRACE_MS = 0;
|
|
46762
|
-
const log$
|
|
46831
|
+
const log$25 = createSubsystemLogger("agent-signals");
|
|
46763
46832
|
function normalizeTrimmed(value) {
|
|
46764
46833
|
return value?.trim() || void 0;
|
|
46765
46834
|
}
|
|
@@ -47045,7 +47114,7 @@ function dispatchHeartbeatSignal(signal, now = Date.now()) {
|
|
|
47045
47114
|
if (!signal.sessionKey) return false;
|
|
47046
47115
|
if (signal.requiresIdle === true) {
|
|
47047
47116
|
if (signal.notBeforeMs !== void 0 && now > signal.notBeforeMs + SIGNAL_DEADLINE_GRACE_MS) {
|
|
47048
|
-
log$
|
|
47117
|
+
log$25.warn("agent-signals: evicting requiresIdle heartbeat signal past its deadline", {
|
|
47049
47118
|
signalId: signal.id,
|
|
47050
47119
|
type: signal.type,
|
|
47051
47120
|
source: signal.source,
|
|
@@ -49945,7 +50014,7 @@ function resolveRunWorkspaceDir(params) {
|
|
|
49945
50014
|
|
|
49946
50015
|
//#endregion
|
|
49947
50016
|
//#region src/agents/cli-runner.ts
|
|
49948
|
-
const log$
|
|
50017
|
+
const log$24 = createSubsystemLogger("agent/claude-cli");
|
|
49949
50018
|
async function runCliAgent(params) {
|
|
49950
50019
|
const started = Date.now();
|
|
49951
50020
|
const workspaceResolution = resolveRunWorkspaceDir({
|
|
@@ -49958,7 +50027,7 @@ async function runCliAgent(params) {
|
|
|
49958
50027
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
49959
50028
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
49960
50029
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
49961
|
-
if (workspaceResolution.usedFallback) log$
|
|
50030
|
+
if (workspaceResolution.usedFallback) log$24.warn(`[workspace-fallback] caller=runCliAgent reason=${workspaceResolution.fallbackReason} run=${params.runId} session=${redactedSessionId} sessionKey=${redactedSessionKey} agent=${workspaceResolution.agentId} workspace=${redactedWorkspace}`);
|
|
49962
50031
|
const workspaceDir = resolvedWorkspace;
|
|
49963
50032
|
const backendResolved = resolveCliBackendConfig(params.provider, params.config);
|
|
49964
50033
|
if (!backendResolved) throw new Error(`Unknown CLI backend: ${params.provider}`);
|
|
@@ -49988,7 +50057,7 @@ async function runCliAgent(params) {
|
|
|
49988
50057
|
resolvedSystemPrompt,
|
|
49989
50058
|
warn: makeBootstrapWarn({
|
|
49990
50059
|
sessionLabel,
|
|
49991
|
-
warn: (message) => log$
|
|
50060
|
+
warn: (message) => log$24.warn(message)
|
|
49992
50061
|
})
|
|
49993
50062
|
});
|
|
49994
50063
|
const heartbeatPrompt = sessionAgentId === defaultAgentId ? resolveHeartbeatPrompt$1(params.config?.agents?.defaults?.heartbeat?.prompt) : void 0;
|
|
@@ -50051,7 +50120,7 @@ async function runCliAgent(params) {
|
|
|
50051
50120
|
const queueKey = backend.serialize ?? true ? backendResolved.id : `${backendResolved.id}:${params.runId}`;
|
|
50052
50121
|
try {
|
|
50053
50122
|
return await enqueueCliRun(queueKey, async () => {
|
|
50054
|
-
log$
|
|
50123
|
+
log$24.info(`cli exec: provider=${params.provider} model=${normalizedModel} promptChars=${params.prompt.length}`);
|
|
50055
50124
|
const logOutputText = isTruthyEnvValue(process.env.OPENCLAW_CLAUDE_CLI_LOG_OUTPUT);
|
|
50056
50125
|
if (logOutputText) {
|
|
50057
50126
|
const logArgs = [];
|
|
@@ -50084,7 +50153,7 @@ async function runCliAgent(params) {
|
|
|
50084
50153
|
const promptIndex = logArgs.indexOf(argsPrompt);
|
|
50085
50154
|
if (promptIndex >= 0) logArgs[promptIndex] = `<prompt:${argsPrompt.length} chars>`;
|
|
50086
50155
|
}
|
|
50087
|
-
log$
|
|
50156
|
+
log$24.info(`cli argv: ${backend.command} ${logArgs.join(" ")}`);
|
|
50088
50157
|
}
|
|
50089
50158
|
const env = (() => {
|
|
50090
50159
|
const next = {
|
|
@@ -50122,17 +50191,17 @@ async function runCliAgent(params) {
|
|
|
50122
50191
|
const stdout = result.stdout.trim();
|
|
50123
50192
|
const stderr = result.stderr.trim();
|
|
50124
50193
|
if (logOutputText) {
|
|
50125
|
-
if (stdout) log$
|
|
50126
|
-
if (stderr) log$
|
|
50194
|
+
if (stdout) log$24.info(`cli stdout:\n${stdout}`);
|
|
50195
|
+
if (stderr) log$24.info(`cli stderr:\n${stderr}`);
|
|
50127
50196
|
}
|
|
50128
50197
|
if (shouldLogVerbose()) {
|
|
50129
|
-
if (stdout) log$
|
|
50130
|
-
if (stderr) log$
|
|
50198
|
+
if (stdout) log$24.debug(`cli stdout:\n${stdout}`);
|
|
50199
|
+
if (stderr) log$24.debug(`cli stderr:\n${stderr}`);
|
|
50131
50200
|
}
|
|
50132
50201
|
if (result.exitCode !== 0 || result.reason !== "exit") {
|
|
50133
50202
|
if (result.reason === "no-output-timeout" || result.noOutputTimedOut) {
|
|
50134
50203
|
const timeoutReason = `CLI produced no output for ${Math.round(noOutputTimeoutMs / 1e3)}s and was terminated.`;
|
|
50135
|
-
log$
|
|
50204
|
+
log$24.warn(`cli watchdog timeout: provider=${params.provider} model=${modelId} session=${resolvedSessionId ?? params.sessionId} noOutputTimeoutMs=${noOutputTimeoutMs} pid=${managedRun.pid ?? "unknown"}`);
|
|
50136
50205
|
throw new FailoverError(timeoutReason, {
|
|
50137
50206
|
reason: "timeout",
|
|
50138
50207
|
provider: params.provider,
|
|
@@ -50186,7 +50255,7 @@ async function runCliAgent(params) {
|
|
|
50186
50255
|
} catch (err) {
|
|
50187
50256
|
if (err instanceof FailoverError) {
|
|
50188
50257
|
if (err.reason === "session_expired" && params.cliSessionId && params.sessionKey) {
|
|
50189
|
-
log$
|
|
50258
|
+
log$24.warn(`CLI session expired, clearing session ID and retrying: provider=${params.provider} session=${redactRunIdentifier(params.cliSessionId)}`);
|
|
50190
50259
|
const output = await executeCliWithSession(void 0);
|
|
50191
50260
|
const text = output.text?.trim();
|
|
50192
50261
|
return {
|
|
@@ -50766,7 +50835,7 @@ function createBlockReplyDeliveryHandler(params) {
|
|
|
50766
50835
|
* every turn the queue-drain path starts later (a `sessions.steer` mode "queue" follow-up and
|
|
50767
50836
|
* every channel follow-up ride the same drain).
|
|
50768
50837
|
*/
|
|
50769
|
-
const log$
|
|
50838
|
+
const log$23 = createSubsystemLogger("auto-reply/session-run-recording");
|
|
50770
50839
|
const NO_RECORDING = {
|
|
50771
50840
|
complete: async () => {},
|
|
50772
50841
|
fail: async () => {},
|
|
@@ -50797,7 +50866,7 @@ async function beginTurnSessionRun(params) {
|
|
|
50797
50866
|
sessionKey
|
|
50798
50867
|
});
|
|
50799
50868
|
} catch (error) {
|
|
50800
|
-
log$
|
|
50869
|
+
log$23.warn("session-run recording unavailable for this turn", {
|
|
50801
50870
|
runId: params.runId,
|
|
50802
50871
|
error: error instanceof Error ? error.message : String(error)
|
|
50803
50872
|
});
|
|
@@ -51630,7 +51699,7 @@ function repairToolUseResultPairing(messages) {
|
|
|
51630
51699
|
|
|
51631
51700
|
//#endregion
|
|
51632
51701
|
//#region src/agents/compaction.ts
|
|
51633
|
-
const log$
|
|
51702
|
+
const log$22 = createSubsystemLogger("compaction");
|
|
51634
51703
|
const BASE_CHUNK_RATIO = .4;
|
|
51635
51704
|
const MIN_CHUNK_RATIO = .15;
|
|
51636
51705
|
const SAFETY_MARGIN = 1.2;
|
|
@@ -51756,7 +51825,7 @@ async function summarizeWithFallback(params) {
|
|
|
51756
51825
|
try {
|
|
51757
51826
|
return await summarizeChunks(params);
|
|
51758
51827
|
} catch (fullError) {
|
|
51759
|
-
log$
|
|
51828
|
+
log$22.warn(`Full summarization failed, trying partial: ${fullError instanceof Error ? fullError.message : String(fullError)}`);
|
|
51760
51829
|
}
|
|
51761
51830
|
const smallMessages = [];
|
|
51762
51831
|
const oversizedNotes = [];
|
|
@@ -51771,7 +51840,7 @@ async function summarizeWithFallback(params) {
|
|
|
51771
51840
|
messages: smallMessages
|
|
51772
51841
|
}) + (oversizedNotes.length > 0 ? `\n\n${oversizedNotes.join("\n")}` : "");
|
|
51773
51842
|
} catch (partialError) {
|
|
51774
|
-
log$
|
|
51843
|
+
log$22.warn(`Partial summarization also failed: ${partialError instanceof Error ? partialError.message : String(partialError)}`);
|
|
51775
51844
|
}
|
|
51776
51845
|
return `Context contained ${messages.length} messages (${oversizedNotes.length} oversized). Summary unavailable due to size limits.`;
|
|
51777
51846
|
}
|
|
@@ -53977,7 +54046,7 @@ async function applyResetModelOverride(params) {
|
|
|
53977
54046
|
//#endregion
|
|
53978
54047
|
//#region src/infra/session-maintenance-warning.ts
|
|
53979
54048
|
const warnedContexts = /* @__PURE__ */ new Map();
|
|
53980
|
-
const log$
|
|
54049
|
+
const log$21 = createSubsystemLogger("session-maintenance-warning");
|
|
53981
54050
|
function shouldSendWarning() {
|
|
53982
54051
|
return !process.env.VITEST && true;
|
|
53983
54052
|
}
|
|
@@ -54048,7 +54117,7 @@ async function deliverSessionMaintenanceWarning(params) {
|
|
|
54048
54117
|
session: outboundSession
|
|
54049
54118
|
});
|
|
54050
54119
|
} catch (err) {
|
|
54051
|
-
log$
|
|
54120
|
+
log$21.warn(`Failed to deliver session maintenance warning: ${String(err)}`);
|
|
54052
54121
|
enqueueSystemEvent(text, { sessionKey: params.sessionKey });
|
|
54053
54122
|
}
|
|
54054
54123
|
}
|
|
@@ -54218,7 +54287,7 @@ function buildSessionEndHookPayload(params) {
|
|
|
54218
54287
|
|
|
54219
54288
|
//#endregion
|
|
54220
54289
|
//#region src/auto-reply/reply/session.ts
|
|
54221
|
-
const log$
|
|
54290
|
+
const log$20 = createSubsystemLogger("session-init");
|
|
54222
54291
|
async function initSessionState(params) {
|
|
54223
54292
|
const { ctx, cfg, commandAuthorized } = params;
|
|
54224
54293
|
const targetSessionKey = ctx.CommandSource === "native" ? ctx.CommandTargetSessionKey?.trim() : void 0;
|
|
@@ -54425,10 +54494,10 @@ async function initSessionState(params) {
|
|
|
54425
54494
|
if (parentSessionKey && parentSessionKey !== sessionKey && sessionStore[parentSessionKey] && !alreadyForked) {
|
|
54426
54495
|
const parentTokens = sessionStore[parentSessionKey].totalTokens ?? 0;
|
|
54427
54496
|
if (parentForkMaxTokens > 0 && parentTokens > parentForkMaxTokens) {
|
|
54428
|
-
log$
|
|
54497
|
+
log$20.warn(`skipping parent fork (parent too large): parentKey=${parentSessionKey} → sessionKey=${sessionKey} parentTokens=${parentTokens} maxTokens=${parentForkMaxTokens}`);
|
|
54429
54498
|
sessionEntry.forkedFromParent = true;
|
|
54430
54499
|
} else {
|
|
54431
|
-
log$
|
|
54500
|
+
log$20.warn(`forking from parent session: parentKey=${parentSessionKey} → sessionKey=${sessionKey} parentTokens=${parentTokens}`);
|
|
54432
54501
|
const forked = await forkSessionFromParent({
|
|
54433
54502
|
parentEntry: sessionStore[parentSessionKey],
|
|
54434
54503
|
agentId,
|
|
@@ -54439,7 +54508,7 @@ async function initSessionState(params) {
|
|
|
54439
54508
|
sessionEntry.sessionId = forked.sessionId;
|
|
54440
54509
|
sessionEntry.sessionFile = forked.sessionFile;
|
|
54441
54510
|
sessionEntry.forkedFromParent = true;
|
|
54442
|
-
log$
|
|
54511
|
+
log$20.warn(`forked session created: file=${forked.sessionFile}`);
|
|
54443
54512
|
}
|
|
54444
54513
|
}
|
|
54445
54514
|
}
|
|
@@ -55314,11 +55383,11 @@ async function getReplyFromConfig(ctx, opts, configOverride) {
|
|
|
55314
55383
|
|
|
55315
55384
|
//#endregion
|
|
55316
55385
|
//#region src/infra/background-run.ts
|
|
55317
|
-
const log$
|
|
55386
|
+
const log$19 = createSubsystemLogger("infra/background-run");
|
|
55318
55387
|
|
|
55319
55388
|
//#endregion
|
|
55320
55389
|
//#region src/infra/heartbeat-active-hours.ts
|
|
55321
|
-
const log$
|
|
55390
|
+
const log$18 = createSubsystemLogger("heartbeat-active-hours");
|
|
55322
55391
|
|
|
55323
55392
|
//#endregion
|
|
55324
55393
|
//#region src/infra/heartbeat-events-filter.ts
|
|
@@ -55371,7 +55440,7 @@ function isCronSystemEvent(evt) {
|
|
|
55371
55440
|
|
|
55372
55441
|
//#endregion
|
|
55373
55442
|
//#region src/infra/heartbeat-events.ts
|
|
55374
|
-
const log$
|
|
55443
|
+
const log$17 = createSubsystemLogger("infra/heartbeat-events");
|
|
55375
55444
|
function resolveIndicatorType(status) {
|
|
55376
55445
|
switch (status) {
|
|
55377
55446
|
case "ok-empty":
|
|
@@ -55393,7 +55462,7 @@ function emitHeartbeatEvent(evt) {
|
|
|
55393
55462
|
for (const listener of listeners) try {
|
|
55394
55463
|
listener(enriched);
|
|
55395
55464
|
} catch (err) {
|
|
55396
|
-
log$
|
|
55465
|
+
log$17.warn("heartbeat event listener threw", { error: err });
|
|
55397
55466
|
}
|
|
55398
55467
|
}
|
|
55399
55468
|
|
|
@@ -55432,7 +55501,7 @@ function resolveHeartbeatVisibility(params) {
|
|
|
55432
55501
|
|
|
55433
55502
|
//#endregion
|
|
55434
55503
|
//#region src/infra/nudge.ts
|
|
55435
|
-
const log$
|
|
55504
|
+
const log$16 = createSubsystemLogger("infra/nudge");
|
|
55436
55505
|
function renderSummary(text, data) {
|
|
55437
55506
|
if (data && Object.keys(data).length > 0) try {
|
|
55438
55507
|
return `${text}\n\nData:\n${JSON.stringify(data, null, 2)}`;
|
|
@@ -55466,14 +55535,14 @@ function requestNudge(input, cfg = loadConfig(), deps) {
|
|
|
55466
55535
|
const enqueue = deps.enqueueAgentTurn;
|
|
55467
55536
|
try {
|
|
55468
55537
|
enqueue(payload).catch((error) => {
|
|
55469
|
-
log$
|
|
55538
|
+
log$16.warn("nudge enqueue failed", {
|
|
55470
55539
|
error,
|
|
55471
55540
|
sessionKey: redactIdentifier(sessionKey),
|
|
55472
55541
|
signalId
|
|
55473
55542
|
});
|
|
55474
55543
|
});
|
|
55475
55544
|
} catch (error) {
|
|
55476
|
-
log$
|
|
55545
|
+
log$16.warn("nudge enqueue failed", {
|
|
55477
55546
|
error,
|
|
55478
55547
|
sessionKey: redactIdentifier(sessionKey),
|
|
55479
55548
|
signalId
|
|
@@ -55496,14 +55565,14 @@ function requestNudge(input, cfg = loadConfig(), deps) {
|
|
|
55496
55565
|
execute: (claim) => runMainAgentTurn(claim.message.payload)
|
|
55497
55566
|
});
|
|
55498
55567
|
})().catch((error) => {
|
|
55499
|
-
log$
|
|
55568
|
+
log$16.warn("nudge claim chain failed", {
|
|
55500
55569
|
error,
|
|
55501
55570
|
sessionKey: redactIdentifier(sessionKey),
|
|
55502
55571
|
signalId
|
|
55503
55572
|
});
|
|
55504
55573
|
});
|
|
55505
55574
|
} catch (error) {
|
|
55506
|
-
log$
|
|
55575
|
+
log$16.warn("nudge enqueue failed", {
|
|
55507
55576
|
error,
|
|
55508
55577
|
sessionKey: redactIdentifier(sessionKey),
|
|
55509
55578
|
signalId
|
|
@@ -55518,7 +55587,7 @@ function requestNudge(input, cfg = loadConfig(), deps) {
|
|
|
55518
55587
|
|
|
55519
55588
|
//#endregion
|
|
55520
55589
|
//#region src/infra/wake-gate.ts
|
|
55521
|
-
const log$
|
|
55590
|
+
const log$15 = createSubsystemLogger("wake-gate");
|
|
55522
55591
|
const DEFAULT_COMMAND_TIMEOUT_MS = 3e4;
|
|
55523
55592
|
const DEFAULT_MODEL_TIMEOUT_MS = 3e4;
|
|
55524
55593
|
const MAX_COMMAND_OUTPUT_BYTES = 64 * 1024;
|
|
@@ -55640,7 +55709,7 @@ async function runWakeGate(spec, ctx) {
|
|
|
55640
55709
|
if (spec.kind === "command") return await runCommandGate(spec, ctx);
|
|
55641
55710
|
else return await runModelGate(spec, ctx);
|
|
55642
55711
|
} catch (err) {
|
|
55643
|
-
log$
|
|
55712
|
+
log$15.error("wake-gate error (no crash)", {
|
|
55644
55713
|
kind: spec.kind,
|
|
55645
55714
|
error: err instanceof Error ? err.message : String(err)
|
|
55646
55715
|
});
|
|
@@ -55651,7 +55720,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
55651
55720
|
try {
|
|
55652
55721
|
const result = await runCommand(spec.command, spec.cwd, spec.timeoutMs, _ctx.abortSignal);
|
|
55653
55722
|
if (result.exit !== 0) {
|
|
55654
|
-
log$
|
|
55723
|
+
log$15.warn("wake gate command non-zero exit", {
|
|
55655
55724
|
kind: "command",
|
|
55656
55725
|
exit: result.exit,
|
|
55657
55726
|
...stdoutShapeForLog(result.stdout)
|
|
@@ -55660,7 +55729,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
55660
55729
|
}
|
|
55661
55730
|
const lines = result.stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
55662
55731
|
if (lines.length === 0) {
|
|
55663
|
-
log$
|
|
55732
|
+
log$15.warn("wake gate command produced no output", {
|
|
55664
55733
|
kind: "command",
|
|
55665
55734
|
exit: result.exit,
|
|
55666
55735
|
...stdoutShapeForLog(result.stdout)
|
|
@@ -55670,7 +55739,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
55670
55739
|
const lastLine = lines[lines.length - 1];
|
|
55671
55740
|
const decision = await parseWakeDecision(lastLine);
|
|
55672
55741
|
if (!decision) {
|
|
55673
|
-
log$
|
|
55742
|
+
log$15.warn("wake gate command output did not parse as a wake decision", {
|
|
55674
55743
|
kind: "command",
|
|
55675
55744
|
exit: result.exit,
|
|
55676
55745
|
...stdoutShapeForLog(result.stdout)
|
|
@@ -55678,14 +55747,14 @@ async function runCommandGate(spec, _ctx) {
|
|
|
55678
55747
|
return { wake: false };
|
|
55679
55748
|
}
|
|
55680
55749
|
if (!decision.wakeAgent) {
|
|
55681
|
-
log$
|
|
55750
|
+
log$15.debug("wake gate command decided not to wake", {
|
|
55682
55751
|
kind: "command",
|
|
55683
55752
|
exit: result.exit,
|
|
55684
55753
|
...stdoutShapeForLog(result.stdout)
|
|
55685
55754
|
});
|
|
55686
55755
|
return { wake: false };
|
|
55687
55756
|
}
|
|
55688
|
-
log$
|
|
55757
|
+
log$15.info("wake gate command decided to wake", {
|
|
55689
55758
|
kind: "command",
|
|
55690
55759
|
exit: result.exit,
|
|
55691
55760
|
hasText: decision.text !== void 0,
|
|
@@ -55696,7 +55765,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
55696
55765
|
if (decision.data !== void 0) res.data = decision.data;
|
|
55697
55766
|
return res;
|
|
55698
55767
|
} catch (err) {
|
|
55699
|
-
log$
|
|
55768
|
+
log$15.warn("command gate error", { error: err instanceof Error ? err.message : String(err) });
|
|
55700
55769
|
return { wake: false };
|
|
55701
55770
|
}
|
|
55702
55771
|
}
|
|
@@ -55734,27 +55803,27 @@ async function runModelGate(spec, ctx) {
|
|
|
55734
55803
|
...ctx.abortSignal ? { abortSignal: ctx.abortSignal } : {}
|
|
55735
55804
|
})).payloads ?? []).filter((payload) => !payload.isError && typeof payload.text === "string").map((payload) => payload.text ?? "").join("\n").trim();
|
|
55736
55805
|
if (!modelOutput) {
|
|
55737
|
-
log$
|
|
55806
|
+
log$15.warn("wake gate model produced no output", { kind: "model" });
|
|
55738
55807
|
return { wake: false };
|
|
55739
55808
|
}
|
|
55740
55809
|
const outputLines = modelOutput.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
55741
55810
|
const lastLine = outputLines[outputLines.length - 1] ?? modelOutput;
|
|
55742
55811
|
const decision = await parseWakeDecision(modelOutput) ?? await parseWakeDecision(lastLine);
|
|
55743
55812
|
if (!decision) {
|
|
55744
|
-
log$
|
|
55813
|
+
log$15.warn("wake gate model output did not parse as a wake decision", {
|
|
55745
55814
|
kind: "model",
|
|
55746
55815
|
tail: tailForLog(modelOutput)
|
|
55747
55816
|
});
|
|
55748
55817
|
return { wake: false };
|
|
55749
55818
|
}
|
|
55750
55819
|
if (!decision.wakeAgent) {
|
|
55751
|
-
log$
|
|
55820
|
+
log$15.debug("wake gate model decided not to wake", {
|
|
55752
55821
|
kind: "model",
|
|
55753
55822
|
tail: tailForLog(modelOutput)
|
|
55754
55823
|
});
|
|
55755
55824
|
return { wake: false };
|
|
55756
55825
|
}
|
|
55757
|
-
log$
|
|
55826
|
+
log$15.info("wake gate model decided to wake", {
|
|
55758
55827
|
kind: "model",
|
|
55759
55828
|
hasText: decision.text !== void 0,
|
|
55760
55829
|
hasData: decision.data !== void 0
|
|
@@ -55764,7 +55833,7 @@ async function runModelGate(spec, ctx) {
|
|
|
55764
55833
|
if (decision.data !== void 0) res.data = decision.data;
|
|
55765
55834
|
return res;
|
|
55766
55835
|
} catch (err) {
|
|
55767
|
-
log$
|
|
55836
|
+
log$15.warn("model gate error", { error: err instanceof Error ? err.message : String(err) });
|
|
55768
55837
|
return { wake: false };
|
|
55769
55838
|
} finally {
|
|
55770
55839
|
if (tmpDir) await fs.rm(tmpDir, {
|
|
@@ -55776,7 +55845,7 @@ async function runModelGate(spec, ctx) {
|
|
|
55776
55845
|
|
|
55777
55846
|
//#endregion
|
|
55778
55847
|
//#region src/infra/heartbeat-runner.ts
|
|
55779
|
-
const log$
|
|
55848
|
+
const log$14 = createSubsystemLogger("gateway/heartbeat");
|
|
55780
55849
|
const DEFAULT_HEARTBEAT_TARGET = "none";
|
|
55781
55850
|
const redactHeartbeatLogIdentifier = (value) => value?.trim() ? redactIdentifier(value) : null;
|
|
55782
55851
|
function isHeartbeatSessionResolutionError(resolution) {
|
|
@@ -55953,7 +56022,7 @@ async function pruneHeartbeatTranscript(params) {
|
|
|
55953
56022
|
throw err;
|
|
55954
56023
|
}
|
|
55955
56024
|
} catch (err) {
|
|
55956
|
-
log$
|
|
56025
|
+
log$14.warn(`pruneHeartbeatTranscript error: ${err instanceof Error ? err.message : String(err)}`, { transcriptPath });
|
|
55957
56026
|
}
|
|
55958
56027
|
}
|
|
55959
56028
|
/**
|
|
@@ -56193,7 +56262,7 @@ async function prepareHeartbeatDeliveryAndPrompt(params) {
|
|
|
56193
56262
|
reason: HEARTBEAT_SKIP_WAKE_GATE_EMPTY,
|
|
56194
56263
|
durationMs: Date.now() - startedAt
|
|
56195
56264
|
});
|
|
56196
|
-
log$
|
|
56265
|
+
log$14.info("heartbeat: wake gate suppressed run", {
|
|
56197
56266
|
agentId: redactHeartbeatLogIdentifier(agentId),
|
|
56198
56267
|
reason: HEARTBEAT_SKIP_WAKE_GATE_EMPTY
|
|
56199
56268
|
});
|
|
@@ -56204,16 +56273,16 @@ async function prepareHeartbeatDeliveryAndPrompt(params) {
|
|
|
56204
56273
|
}
|
|
56205
56274
|
wakeGateText = wakeResult.data !== void 0 ? `${wakeResult.text ?? ""}\n\nData:\n${JSON.stringify(wakeResult.data, null, 2)}`.trim() : wakeResult.text?.trim() || void 0;
|
|
56206
56275
|
}
|
|
56207
|
-
if (delivery.reason === "unknown-account") log$
|
|
56276
|
+
if (delivery.reason === "unknown-account") log$14.warn("heartbeat: unknown accountId", {
|
|
56208
56277
|
accountId: redactHeartbeatLogIdentifier(delivery.accountId ?? heartbeatAccountId),
|
|
56209
56278
|
target: heartbeat?.target ?? "none"
|
|
56210
56279
|
});
|
|
56211
|
-
else if (heartbeatAccountId) log$
|
|
56280
|
+
else if (heartbeatAccountId) log$14.info("heartbeat: using explicit accountId", {
|
|
56212
56281
|
accountId: redactHeartbeatLogIdentifier(delivery.accountId ?? heartbeatAccountId),
|
|
56213
56282
|
target: heartbeat?.target ?? "none",
|
|
56214
56283
|
channel: delivery.channel
|
|
56215
56284
|
});
|
|
56216
|
-
log$
|
|
56285
|
+
log$14.info("heartbeat: resolved plan", {
|
|
56217
56286
|
agentId: redactHeartbeatLogIdentifier(agentId),
|
|
56218
56287
|
sessionKey: redactHeartbeatLogIdentifier(sessionKey),
|
|
56219
56288
|
sessionSource: preflight.session.source,
|
|
@@ -56288,7 +56357,7 @@ async function resolveHeartbeatPreflightOrSkip(params) {
|
|
|
56288
56357
|
durationMs: Date.now() - startedAt,
|
|
56289
56358
|
indicatorType: resolveIndicatorType("failed")
|
|
56290
56359
|
});
|
|
56291
|
-
log$
|
|
56360
|
+
log$14.error(`heartbeat failed: ${publicReason}`, {
|
|
56292
56361
|
error: publicReason,
|
|
56293
56362
|
agentId: redactHeartbeatLogIdentifier(agentId),
|
|
56294
56363
|
sessionSource: preflight.sessionError.source,
|
|
@@ -56307,7 +56376,7 @@ async function resolveHeartbeatPreflightOrSkip(params) {
|
|
|
56307
56376
|
durationMs: Date.now() - startedAt,
|
|
56308
56377
|
indicatorType: resolveIndicatorType("failed")
|
|
56309
56378
|
});
|
|
56310
|
-
log$
|
|
56379
|
+
log$14.error(`heartbeat failed: ${reason}`, {
|
|
56311
56380
|
error: reason,
|
|
56312
56381
|
agentId: redactHeartbeatLogIdentifier(agentId)
|
|
56313
56382
|
});
|
|
@@ -56344,7 +56413,7 @@ async function loadSharedSessionHeartbeatContext(params) {
|
|
|
56344
56413
|
if (present.length === 0) return;
|
|
56345
56414
|
return present.map((file) => `## ${file.path}\n\n${file.content}`).join("\n\n");
|
|
56346
56415
|
} catch (err) {
|
|
56347
|
-
log$
|
|
56416
|
+
log$14.warn("failed to load heartbeat context files for trigger message", { error: err });
|
|
56348
56417
|
return;
|
|
56349
56418
|
}
|
|
56350
56419
|
}
|
|
@@ -56649,7 +56718,7 @@ async function finalizeTurnOutcome(params) {
|
|
|
56649
56718
|
channel: delivery.channel,
|
|
56650
56719
|
accountId: delivery.accountId
|
|
56651
56720
|
});
|
|
56652
|
-
log$
|
|
56721
|
+
log$14.warn("heartbeat: channel not ready", {
|
|
56653
56722
|
channel: delivery.channel,
|
|
56654
56723
|
reason: readiness.reason
|
|
56655
56724
|
});
|
|
@@ -56737,11 +56806,11 @@ async function cleanupIsolatedHeartbeatSession(params) {
|
|
|
56737
56806
|
restrictToStoreDir: true
|
|
56738
56807
|
});
|
|
56739
56808
|
} catch (archiveErr) {
|
|
56740
|
-
log$
|
|
56809
|
+
log$14.warn(`cron: error-path isolated session archive failed: ${formatErrorMessage(archiveErr)}`, { sessionId: isolatedEntry.sessionId });
|
|
56741
56810
|
}
|
|
56742
56811
|
delete store[createdIsolatedSessionKey];
|
|
56743
56812
|
}).catch((cleanupErr) => {
|
|
56744
|
-
log$
|
|
56813
|
+
log$14.warn(`failed to clean up isolated heartbeat session on error: ${String(cleanupErr)}`);
|
|
56745
56814
|
});
|
|
56746
56815
|
}
|
|
56747
56816
|
async function handleHeartbeatError(params) {
|
|
@@ -56761,7 +56830,7 @@ async function handleHeartbeatError(params) {
|
|
|
56761
56830
|
accountId: delivery.accountId,
|
|
56762
56831
|
indicatorType: visibility.useIndicator ? resolveIndicatorType("failed") : void 0
|
|
56763
56832
|
});
|
|
56764
|
-
log$
|
|
56833
|
+
log$14.error(`heartbeat failed: ${reason}`, { error: reason });
|
|
56765
56834
|
return {
|
|
56766
56835
|
status: "failed",
|
|
56767
56836
|
reason
|
|
@@ -56915,7 +56984,7 @@ async function runMainAgentTurn(payload, opts) {
|
|
|
56915
56984
|
|
|
56916
56985
|
//#endregion
|
|
56917
56986
|
//#region src/agents/subagent-announce-turn.ts
|
|
56918
|
-
const log$
|
|
56987
|
+
const log$13 = createSubsystemLogger("agents/subagent-announce-turn");
|
|
56919
56988
|
function clearDelayedReleaseHoldIfNoAnnounceIsParked(sessionKey) {
|
|
56920
56989
|
if (!peekDelayedAgentTurn(sessionKey, (payload) => payload.kind === "announce")) clearDelayedReleaseHold(sessionKey);
|
|
56921
56990
|
}
|
|
@@ -56975,7 +57044,7 @@ async function publishSubagentAnnounceTurn(params) {
|
|
|
56975
57044
|
};
|
|
56976
57045
|
} catch (error) {
|
|
56977
57046
|
clearDelayedReleaseHoldIfNoAnnounceIsParked(params.requesterSessionKey);
|
|
56978
|
-
log$
|
|
57047
|
+
log$13.warn("subagent announce turn failed", { error: String(error) });
|
|
56979
57048
|
return {
|
|
56980
57049
|
status: "failed",
|
|
56981
57050
|
error: String(error)
|
|
@@ -67929,7 +67998,7 @@ function toDiscordModelPickerMessagePayload(view) {
|
|
|
67929
67998
|
|
|
67930
67999
|
//#endregion
|
|
67931
68000
|
//#region src/discord/monitor/native-command.ts
|
|
67932
|
-
const log$
|
|
68001
|
+
const log$12 = createSubsystemLogger("discord/native-command");
|
|
67933
68002
|
function buildDiscordCommandOptions(params) {
|
|
67934
68003
|
const { command, cfg } = params;
|
|
67935
68004
|
const args = command.args;
|
|
@@ -68986,7 +69055,7 @@ async function dispatchDiscordCommandInteraction(params) {
|
|
|
68986
69055
|
},
|
|
68987
69056
|
onError: (err, info) => {
|
|
68988
69057
|
const message = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
68989
|
-
log$
|
|
69058
|
+
log$12.error(`discord slash ${info.kind} reply failed: ${message}`);
|
|
68990
69059
|
}
|
|
68991
69060
|
},
|
|
68992
69061
|
replyOptions: {
|
|
@@ -72467,7 +72536,7 @@ function resolveSession(opts) {
|
|
|
72467
72536
|
|
|
72468
72537
|
//#endregion
|
|
72469
72538
|
//#region src/commands/agent.ts
|
|
72470
|
-
const log$
|
|
72539
|
+
const log$11 = createSubsystemLogger("commands/agent");
|
|
72471
72540
|
const OVERRIDE_FIELDS_CLEARED_BY_DELETE = [
|
|
72472
72541
|
"providerOverride",
|
|
72473
72542
|
"modelOverride",
|
|
@@ -72525,7 +72594,7 @@ function runAgentAttempt(params) {
|
|
|
72525
72594
|
});
|
|
72526
72595
|
return runCliWithSession(cliSessionId).catch(async (err) => {
|
|
72527
72596
|
if (err instanceof FailoverError && err.reason === "session_expired" && cliSessionId && params.sessionKey && params.sessionStore && params.storePath) {
|
|
72528
|
-
log$
|
|
72597
|
+
log$11.warn(`CLI session expired, clearing from session store: provider=${params.providerOverride} sessionKey=${params.sessionKey}`);
|
|
72529
72598
|
const entry = params.sessionStore[params.sessionKey];
|
|
72530
72599
|
if (entry) {
|
|
72531
72600
|
const updatedEntry = { ...entry };
|
|
@@ -90611,7 +90680,7 @@ const TELEGRAM_WEBHOOK_MAX_BODY_BYTES = 1024 * 1024;
|
|
|
90611
90680
|
const TELEGRAM_WEBHOOK_BODY_TIMEOUT_MS = 3e4;
|
|
90612
90681
|
const TELEGRAM_WEBHOOK_CALLBACK_TIMEOUT_MS = 1e4;
|
|
90613
90682
|
const TELEGRAM_WEBHOOK_DEFAULT_MAX_CONNECTIONS = 40;
|
|
90614
|
-
const log$
|
|
90683
|
+
const log$10 = createSubsystemLogger("telegram/webhook");
|
|
90615
90684
|
let webhookOwnerSequence = 0;
|
|
90616
90685
|
let ephemeralWebhookListenerSequence = 0;
|
|
90617
90686
|
let activeWebhookDiagnosticUsers = 0;
|
|
@@ -90941,7 +91010,7 @@ async function startTelegramWebhook(opts) {
|
|
|
90941
91010
|
recordRequest({ outcome: "received" });
|
|
90942
91011
|
const secretHeader = resolveSingleHeaderValue(req.headers["x-telegram-bot-api-secret-token"]);
|
|
90943
91012
|
if (!hasValidTelegramWebhookSecret(secretHeader, secret)) {
|
|
90944
|
-
log$
|
|
91013
|
+
log$10.warn("telegram webhook secret rejected", {
|
|
90945
91014
|
sourceIp: resolveWebhookSourceIp(req),
|
|
90946
91015
|
reason: typeof secretHeader === "string" ? "secret-mismatch" : "missing-header",
|
|
90947
91016
|
path
|
|
@@ -91036,7 +91105,7 @@ async function startTelegramWebhook(opts) {
|
|
|
91036
91105
|
const unauthorized = async () => {
|
|
91037
91106
|
if (replied) return;
|
|
91038
91107
|
replied = true;
|
|
91039
|
-
log$
|
|
91108
|
+
log$10.warn("telegram webhook secret rejected", {
|
|
91040
91109
|
sourceIp: resolveWebhookSourceIp(req),
|
|
91041
91110
|
reason: typeof secretHeader === "string" ? "secret-mismatch" : "missing-header",
|
|
91042
91111
|
path
|
|
@@ -92009,11 +92078,11 @@ function createRuntimeMedia() {
|
|
|
92009
92078
|
|
|
92010
92079
|
//#endregion
|
|
92011
92080
|
//#region src/backbone/authz.ts
|
|
92012
|
-
const log$
|
|
92081
|
+
const log$9 = createSubsystemLogger("backbone/authz");
|
|
92013
92082
|
|
|
92014
92083
|
//#endregion
|
|
92015
92084
|
//#region src/backbone/scoped-plugin-api.ts
|
|
92016
|
-
const log$
|
|
92085
|
+
const log$8 = createSubsystemLogger("backbone/scoped-plugin-api");
|
|
92017
92086
|
|
|
92018
92087
|
//#endregion
|
|
92019
92088
|
//#region src/plugins/runtime/runtime-signals.ts
|
|
@@ -92255,7 +92324,7 @@ function resolveMemoryBackendConfig(params) {
|
|
|
92255
92324
|
|
|
92256
92325
|
//#endregion
|
|
92257
92326
|
//#region src/memory/search-manager.ts
|
|
92258
|
-
const log$
|
|
92327
|
+
const log$7 = createSubsystemLogger("memory");
|
|
92259
92328
|
const QMD_MANAGER_CACHE = /* @__PURE__ */ new Map();
|
|
92260
92329
|
async function getMemorySearchManager(params) {
|
|
92261
92330
|
const resolved = resolveMemoryBackendConfig(params);
|
|
@@ -92292,7 +92361,7 @@ async function getMemorySearchManager(params) {
|
|
|
92292
92361
|
}
|
|
92293
92362
|
} catch (err) {
|
|
92294
92363
|
const message = err instanceof Error ? err.message : String(err);
|
|
92295
|
-
log$
|
|
92364
|
+
log$7.warn(`qmd memory unavailable; falling back to builtin: ${message}`);
|
|
92296
92365
|
}
|
|
92297
92366
|
}
|
|
92298
92367
|
try {
|
|
@@ -92319,7 +92388,7 @@ var FallbackMemoryManager = class {
|
|
|
92319
92388
|
} catch (err) {
|
|
92320
92389
|
this.primaryFailed = true;
|
|
92321
92390
|
this.lastError = err instanceof Error ? err.message : String(err);
|
|
92322
|
-
log$
|
|
92391
|
+
log$7.warn(`qmd memory failed; switching to builtin index: ${this.lastError}`);
|
|
92323
92392
|
await this.deps.primary.close?.().catch(() => {});
|
|
92324
92393
|
this.evictCacheEntry();
|
|
92325
92394
|
}
|
|
@@ -92399,12 +92468,12 @@ var FallbackMemoryManager = class {
|
|
|
92399
92468
|
try {
|
|
92400
92469
|
fallback = await this.deps.fallbackFactory();
|
|
92401
92470
|
if (!fallback) {
|
|
92402
|
-
log$
|
|
92471
|
+
log$7.warn("memory fallback requested but builtin index is unavailable");
|
|
92403
92472
|
return null;
|
|
92404
92473
|
}
|
|
92405
92474
|
} catch (err) {
|
|
92406
92475
|
const message = err instanceof Error ? err.message : String(err);
|
|
92407
|
-
log$
|
|
92476
|
+
log$7.warn(`memory fallback unavailable: ${message}`);
|
|
92408
92477
|
return null;
|
|
92409
92478
|
}
|
|
92410
92479
|
this.fallback = fallback;
|
|
@@ -94119,7 +94188,7 @@ function createPluginLoaderLogger(logger) {
|
|
|
94119
94188
|
|
|
94120
94189
|
//#endregion
|
|
94121
94190
|
//#region src/plugins/tools.ts
|
|
94122
|
-
const log$
|
|
94191
|
+
const log$6 = createSubsystemLogger("plugins");
|
|
94123
94192
|
const pluginToolMeta = /* @__PURE__ */ new WeakMap();
|
|
94124
94193
|
function getPluginToolMeta(tool) {
|
|
94125
94194
|
return pluginToolMeta.get(tool);
|
|
@@ -94141,7 +94210,7 @@ function resolvePluginTools(params) {
|
|
|
94141
94210
|
const registry = loadOpenClawPlugins({
|
|
94142
94211
|
config: effectiveConfig,
|
|
94143
94212
|
workspaceDir: params.context.workspaceDir,
|
|
94144
|
-
logger: createPluginLoaderLogger(log$
|
|
94213
|
+
logger: createPluginLoaderLogger(log$6),
|
|
94145
94214
|
activate: false
|
|
94146
94215
|
});
|
|
94147
94216
|
const tools = [];
|
|
@@ -94156,7 +94225,7 @@ function resolvePluginTools(params) {
|
|
|
94156
94225
|
if (existingNormalized.has(pluginIdKey)) {
|
|
94157
94226
|
const message = `plugin id conflicts with core tool name (${entry.pluginId})`;
|
|
94158
94227
|
if (!params.suppressNameConflicts) {
|
|
94159
|
-
log$
|
|
94228
|
+
log$6.error(message);
|
|
94160
94229
|
registry.diagnostics.push({
|
|
94161
94230
|
level: "error",
|
|
94162
94231
|
code: "PLUGIN_REGISTER_ERROR",
|
|
@@ -94173,7 +94242,7 @@ function resolvePluginTools(params) {
|
|
|
94173
94242
|
try {
|
|
94174
94243
|
resolved = entry.factory(params.context);
|
|
94175
94244
|
} catch (err) {
|
|
94176
|
-
log$
|
|
94245
|
+
log$6.error(`plugin tool failed (${entry.pluginId}): ${String(err)}`);
|
|
94177
94246
|
continue;
|
|
94178
94247
|
}
|
|
94179
94248
|
if (!resolved) continue;
|
|
@@ -94190,7 +94259,7 @@ function resolvePluginTools(params) {
|
|
|
94190
94259
|
if (nameSet.has(tool.name) || existing.has(tool.name)) {
|
|
94191
94260
|
const message = `plugin tool name conflict (${entry.pluginId}): ${tool.name}`;
|
|
94192
94261
|
if (!params.suppressNameConflicts) {
|
|
94193
|
-
log$
|
|
94262
|
+
log$6.error(message);
|
|
94194
94263
|
registry.diagnostics.push({
|
|
94195
94264
|
level: "error",
|
|
94196
94265
|
code: "PLUGIN_REGISTER_ERROR",
|
|
@@ -94223,7 +94292,7 @@ function resolvePluginWebSearchProviders(params) {
|
|
|
94223
94292
|
return [...loadOpenClawPlugins({
|
|
94224
94293
|
config: effectiveConfig,
|
|
94225
94294
|
workspaceDir: params.workspaceDir,
|
|
94226
|
-
logger: createPluginLoaderLogger(log$
|
|
94295
|
+
logger: createPluginLoaderLogger(log$6),
|
|
94227
94296
|
activate: false
|
|
94228
94297
|
}).webSearchProviders].toSorted((a, b) => {
|
|
94229
94298
|
return (a.autoDetectOrder ?? Infinity) - (b.autoDetectOrder ?? Infinity);
|
|
@@ -94835,7 +94904,7 @@ function wrapToolWithAbortSignal(tool, abortSignal) {
|
|
|
94835
94904
|
|
|
94836
94905
|
//#endregion
|
|
94837
94906
|
//#region src/agents/pi-tools.before-tool-call.ts
|
|
94838
|
-
const log$
|
|
94907
|
+
const log$5 = createSubsystemLogger("agents/tools");
|
|
94839
94908
|
const BEFORE_TOOL_CALL_WRAPPED = Symbol("beforeToolCallWrapped");
|
|
94840
94909
|
const adjustedParamsByToolCallId = /* @__PURE__ */ new Map();
|
|
94841
94910
|
const MAX_TRACKED_ADJUSTED_PARAMS = 1024;
|
|
@@ -94873,7 +94942,7 @@ async function recordLoopOutcome(args) {
|
|
|
94873
94942
|
config: args.ctx.loopDetection
|
|
94874
94943
|
});
|
|
94875
94944
|
} catch (err) {
|
|
94876
|
-
log$
|
|
94945
|
+
log$5.warn(`tool loop outcome tracking failed: tool=${args.toolName} error=${String(err)}`);
|
|
94877
94946
|
}
|
|
94878
94947
|
}
|
|
94879
94948
|
var UserCancelledError = class extends Error {
|
|
@@ -94900,7 +94969,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
94900
94969
|
const loopResult = detectToolCallLoop(sessionState, toolName, params, args.ctx.loopDetection);
|
|
94901
94970
|
if (loopResult.stuck) {
|
|
94902
94971
|
if (loopResult.level === "critical") {
|
|
94903
|
-
log$
|
|
94972
|
+
log$5.error(`Blocking ${toolName} due to critical loop: ${loopResult.message}`);
|
|
94904
94973
|
logToolLoopAction({
|
|
94905
94974
|
sessionKey: args.ctx.sessionKey,
|
|
94906
94975
|
sessionId: args.ctx?.agentId,
|
|
@@ -94918,7 +94987,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
94918
94987
|
reason: loopResult.message
|
|
94919
94988
|
};
|
|
94920
94989
|
} else if (shouldEmitLoopWarning(sessionState, loopResult.warningKey ?? `${loopResult.detector}:${toolName}`, loopResult.count)) {
|
|
94921
|
-
log$
|
|
94990
|
+
log$5.warn(`Loop warning for ${toolName}: ${loopResult.message}`);
|
|
94922
94991
|
logToolLoopAction({
|
|
94923
94992
|
sessionKey: args.ctx.sessionKey,
|
|
94924
94993
|
sessionId: args.ctx?.agentId,
|
|
@@ -94977,7 +95046,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
94977
95046
|
}
|
|
94978
95047
|
} catch (err) {
|
|
94979
95048
|
const toolCallId = args.toolCallId ? ` toolCallId=${args.toolCallId}` : "";
|
|
94980
|
-
log$
|
|
95049
|
+
log$5.warn(`before_tool_call hook failed: tool=${toolName}${toolCallId} error=${String(err)}`);
|
|
94981
95050
|
}
|
|
94982
95051
|
return {
|
|
94983
95052
|
blocked: false,
|
|
@@ -96793,7 +96862,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
96793
96862
|
const textLength = getToolResultTextLength(msg);
|
|
96794
96863
|
if (textLength > maxChars) {
|
|
96795
96864
|
oversizedIndices.push(i);
|
|
96796
|
-
log$
|
|
96865
|
+
log$29.info(`[tool-result-truncation] Found oversized tool result: entry=${entry.id} chars=${textLength} maxChars=${maxChars} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
96797
96866
|
}
|
|
96798
96867
|
}
|
|
96799
96868
|
if (oversizedIndices.length === 0) return {
|
|
@@ -96815,7 +96884,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
96815
96884
|
message = truncateToolResultMessage(message, maxChars);
|
|
96816
96885
|
truncatedCount++;
|
|
96817
96886
|
const newLength = getToolResultTextLength(message);
|
|
96818
|
-
log$
|
|
96887
|
+
log$29.info(`[tool-result-truncation] Truncated tool result: originalEntry=${entry.id} newChars=${newLength} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
96819
96888
|
}
|
|
96820
96889
|
sessionManager.appendMessage(message);
|
|
96821
96890
|
} else if (entry.type === "compaction") sessionManager.appendCompaction(entry.summary, entry.firstKeptEntryId, entry.tokensBefore, entry.details, entry.fromHook);
|
|
@@ -96829,14 +96898,14 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
96829
96898
|
if (entry.name) sessionManager.appendSessionInfo(entry.name);
|
|
96830
96899
|
}
|
|
96831
96900
|
}
|
|
96832
|
-
log$
|
|
96901
|
+
log$29.info(`[tool-result-truncation] Truncated ${truncatedCount} tool result(s) in session (contextWindow=${contextWindowTokens} maxChars=${maxChars}) sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
96833
96902
|
return {
|
|
96834
96903
|
truncated: true,
|
|
96835
96904
|
truncatedCount
|
|
96836
96905
|
};
|
|
96837
96906
|
} catch (err) {
|
|
96838
96907
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
96839
|
-
log$
|
|
96908
|
+
log$29.warn(`[tool-result-truncation] Failed to truncate: ${errMsg}`);
|
|
96840
96909
|
return {
|
|
96841
96910
|
truncated: false,
|
|
96842
96911
|
truncatedCount: 0,
|
|
@@ -97210,7 +97279,7 @@ const getCompactionSafeguardRuntime = registry$1.get;
|
|
|
97210
97279
|
|
|
97211
97280
|
//#endregion
|
|
97212
97281
|
//#region src/agents/pi-extensions/compaction-safeguard.ts
|
|
97213
|
-
const log$
|
|
97282
|
+
const log$4 = createSubsystemLogger("compaction-safeguard");
|
|
97214
97283
|
const missedModelWarningSessions = /* @__PURE__ */ new WeakSet();
|
|
97215
97284
|
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.";
|
|
97216
97285
|
const MAX_TOOL_FAILURES = 8;
|
|
@@ -97319,7 +97388,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97319
97388
|
api.on("session_before_compact", async (event, ctx) => {
|
|
97320
97389
|
const { preparation, customInstructions, signal } = event;
|
|
97321
97390
|
if (!preparation.messagesToSummarize.some(isRealConversationMessage)) {
|
|
97322
|
-
log$
|
|
97391
|
+
log$4.warn("Compaction safeguard: cancelling compaction with no real conversation messages to summarize.");
|
|
97323
97392
|
return { cancel: true };
|
|
97324
97393
|
}
|
|
97325
97394
|
const { readFiles, modifiedFiles } = computeFileLists(preparation.fileOps);
|
|
@@ -97327,7 +97396,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97327
97396
|
const toolFailureSection = formatToolFailuresSection(collectToolFailures([...preparation.messagesToSummarize, ...preparation.turnPrefixMessages]));
|
|
97328
97397
|
const runtime = getCompactionSafeguardRuntime(ctx.sessionManager);
|
|
97329
97398
|
if (runtime?.enabled === false) {
|
|
97330
|
-
log$
|
|
97399
|
+
log$4.info("Compaction safeguard: compaction disabled by config; cancelling.");
|
|
97331
97400
|
return { cancel: true };
|
|
97332
97401
|
}
|
|
97333
97402
|
const summarizationInstructions = {
|
|
@@ -97368,7 +97437,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97368
97437
|
});
|
|
97369
97438
|
if (pruned.droppedChunks > 0) {
|
|
97370
97439
|
const newContentRatio = newContentTokens / contextWindowTokens * 100;
|
|
97371
|
-
log$
|
|
97440
|
+
log$4.warn(`Compaction safeguard: new content uses ${newContentRatio.toFixed(1)}% of context; dropped ${pruned.droppedChunks} older chunk(s) (${pruned.droppedMessages} messages) to fit history budget.`);
|
|
97372
97441
|
messagesToSummarize = pruned.messages;
|
|
97373
97442
|
if (pruned.droppedMessagesList.length > 0) try {
|
|
97374
97443
|
const droppedChunkRatio = computeAdaptiveChunkRatio(pruned.droppedMessagesList, contextWindowTokens);
|
|
@@ -97386,7 +97455,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97386
97455
|
previousSummary: preparation.previousSummary
|
|
97387
97456
|
});
|
|
97388
97457
|
} catch (droppedError) {
|
|
97389
|
-
log$
|
|
97458
|
+
log$4.warn(`Compaction safeguard: failed to summarize dropped messages, continuing without: ${droppedError instanceof Error ? droppedError.message : String(droppedError)}`);
|
|
97390
97459
|
}
|
|
97391
97460
|
}
|
|
97392
97461
|
}
|
|
@@ -97434,7 +97503,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97434
97503
|
}
|
|
97435
97504
|
} };
|
|
97436
97505
|
} catch (error) {
|
|
97437
|
-
log$
|
|
97506
|
+
log$4.warn(`Compaction summarization failed; cancelling compaction to preserve history: ${error instanceof Error ? error.message : String(error)}`);
|
|
97438
97507
|
return { cancel: true };
|
|
97439
97508
|
}
|
|
97440
97509
|
});
|
|
@@ -98165,14 +98234,14 @@ function logToolSchemasForGoogle(params) {
|
|
|
98165
98234
|
if (params.provider !== "google-gemini-cli") return;
|
|
98166
98235
|
const toolNames = params.tools.map((tool, index) => `${index}:${tool.name}`);
|
|
98167
98236
|
const tools = sanitizeToolsForGoogle(params);
|
|
98168
|
-
log$
|
|
98237
|
+
log$29.info("google tool schema snapshot", {
|
|
98169
98238
|
provider: params.provider,
|
|
98170
98239
|
toolCount: tools.length,
|
|
98171
98240
|
tools: toolNames
|
|
98172
98241
|
});
|
|
98173
98242
|
for (const [index, tool] of tools.entries()) {
|
|
98174
98243
|
const violations = findUnsupportedSchemaKeywords(tool.parameters, `${tool.name}.parameters`);
|
|
98175
|
-
if (violations.length > 0) log$
|
|
98244
|
+
if (violations.length > 0) log$29.warn("google tool schema has unsupported keywords", {
|
|
98176
98245
|
index,
|
|
98177
98246
|
tool: tool.name,
|
|
98178
98247
|
violations: violations.slice(0, 12),
|
|
@@ -98184,7 +98253,7 @@ const compactionFailureEmitter = new EventEmitter();
|
|
|
98184
98253
|
registerUnhandledRejectionHandler((reason) => {
|
|
98185
98254
|
const message = describeUnknownError(reason);
|
|
98186
98255
|
if (!isCompactionFailureError(message)) return false;
|
|
98187
|
-
log$
|
|
98256
|
+
log$29.error(`Auto-compaction failed (unhandled): ${message}`);
|
|
98188
98257
|
compactionFailureEmitter.emit("failure", message);
|
|
98189
98258
|
return true;
|
|
98190
98259
|
});
|
|
@@ -98236,7 +98305,7 @@ function applyGoogleTurnOrderingFix(params) {
|
|
|
98236
98305
|
const sanitized = sanitizeGoogleTurnOrdering(params.messages);
|
|
98237
98306
|
const didPrepend = sanitized !== params.messages;
|
|
98238
98307
|
if (didPrepend && !hasGoogleTurnOrderingMarker(params.sessionManager)) {
|
|
98239
|
-
(params.warn ?? ((message) => log$
|
|
98308
|
+
(params.warn ?? ((message) => log$29.warn(message)))(`google turn ordering fixup: prepended user bootstrap (sessionId=${params.sessionId})`);
|
|
98240
98309
|
markGoogleTurnOrderingMarker(params.sessionManager);
|
|
98241
98310
|
}
|
|
98242
98311
|
return {
|
|
@@ -98653,6 +98722,57 @@ async function flushPendingToolResultsAfterIdle(opts) {
|
|
|
98653
98722
|
opts.sessionManager?.flushPendingToolResults?.();
|
|
98654
98723
|
}
|
|
98655
98724
|
|
|
98725
|
+
//#endregion
|
|
98726
|
+
//#region src/agents/pi-embedded-runner/workspace-cwd.ts
|
|
98727
|
+
const log$3 = createSubsystemLogger("agents/workspace-cwd");
|
|
98728
|
+
const holders = [];
|
|
98729
|
+
let baselineCwd;
|
|
98730
|
+
function readCwd() {
|
|
98731
|
+
try {
|
|
98732
|
+
return process.cwd();
|
|
98733
|
+
} catch (err) {
|
|
98734
|
+
log$3.warn("process.cwd() failed; the working directory was removed under the process", { error: String(err) });
|
|
98735
|
+
return;
|
|
98736
|
+
}
|
|
98737
|
+
}
|
|
98738
|
+
function tryChdir(target) {
|
|
98739
|
+
if (readCwd() === target) return true;
|
|
98740
|
+
try {
|
|
98741
|
+
process.chdir(target);
|
|
98742
|
+
return true;
|
|
98743
|
+
} catch (err) {
|
|
98744
|
+
log$3.error("cwd restore target is gone", {
|
|
98745
|
+
target,
|
|
98746
|
+
error: String(err)
|
|
98747
|
+
});
|
|
98748
|
+
return false;
|
|
98749
|
+
}
|
|
98750
|
+
}
|
|
98751
|
+
/**
|
|
98752
|
+
* The cwd is process-global while embedded runs overlap (`agents.defaults.maxConcurrent`
|
|
98753
|
+
* defaults to 4). Each holder gets the cwd on acquire; on release the cwd goes to the most
|
|
98754
|
+
* recent surviving holder's workspace, and to the baseline the first holder found once none
|
|
98755
|
+
* remain. The returned release never throws: a throw from a caller's finally would skip the
|
|
98756
|
+
* rest of it (e.g. clearActiveEmbeddedRun) and leak the run registry entry.
|
|
98757
|
+
*/
|
|
98758
|
+
function acquireWorkspaceCwd(workspaceDir) {
|
|
98759
|
+
if (holders.length === 0) baselineCwd = readCwd() ?? os.tmpdir();
|
|
98760
|
+
if (readCwd() !== workspaceDir) process.chdir(workspaceDir);
|
|
98761
|
+
const holder = { workspaceDir };
|
|
98762
|
+
holders.push(holder);
|
|
98763
|
+
let released = false;
|
|
98764
|
+
return () => {
|
|
98765
|
+
if (released) return;
|
|
98766
|
+
released = true;
|
|
98767
|
+
const index = holders.indexOf(holder);
|
|
98768
|
+
if (index !== -1) holders.splice(index, 1);
|
|
98769
|
+
for (let i = holders.length - 1; i >= 0; i -= 1) if (tryChdir(holders[i].workspaceDir)) return;
|
|
98770
|
+
const target = baselineCwd ?? os.tmpdir();
|
|
98771
|
+
if (holders.length === 0) baselineCwd = void 0;
|
|
98772
|
+
if (!tryChdir(target) && !tryChdir(os.tmpdir())) log$3.error("tmpdir chdir failed; leaving the process cwd unchanged");
|
|
98773
|
+
};
|
|
98774
|
+
}
|
|
98775
|
+
|
|
98656
98776
|
//#endregion
|
|
98657
98777
|
//#region src/agents/pi-embedded-runner/compact.ts
|
|
98658
98778
|
function createCompactionDiagId$1() {
|
|
@@ -99063,11 +99183,10 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99063
99183
|
compacted: false,
|
|
99064
99184
|
reason: "compaction deferred by context.prune handler"
|
|
99065
99185
|
};
|
|
99066
|
-
const prevCwd = process.cwd();
|
|
99067
99186
|
const provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
99068
99187
|
const modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
99069
99188
|
const fail = (reason) => {
|
|
99070
|
-
log$
|
|
99189
|
+
log$29.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}`);
|
|
99071
99190
|
return {
|
|
99072
99191
|
ok: false,
|
|
99073
99192
|
compacted: false,
|
|
@@ -99111,7 +99230,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99111
99230
|
cwd: effectiveWorkspace
|
|
99112
99231
|
});
|
|
99113
99232
|
let restoreSkillEnv;
|
|
99114
|
-
|
|
99233
|
+
const releaseWorkspaceCwd = acquireWorkspaceCwd(effectiveWorkspace);
|
|
99115
99234
|
try {
|
|
99116
99235
|
const shouldLoadSkillEntries = !params.skillsSnapshot || !params.skillsSnapshot.resolvedSkills;
|
|
99117
99236
|
const skillEntries = shouldLoadSkillEntries ? loadWorkspaceSkillEntries(effectiveWorkspace) : [];
|
|
@@ -99147,7 +99266,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99147
99266
|
resolvedSystemPrompt,
|
|
99148
99267
|
warn: makeBootstrapWarn({
|
|
99149
99268
|
sessionLabel,
|
|
99150
|
-
warn: (message) => log$
|
|
99269
|
+
warn: (message) => log$29.warn(message)
|
|
99151
99270
|
})
|
|
99152
99271
|
});
|
|
99153
99272
|
const runAbortController = new AbortController();
|
|
@@ -99289,7 +99408,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99289
99408
|
});
|
|
99290
99409
|
try {
|
|
99291
99410
|
if (isPreservationArmed() || !isJsonlSessionBackend()) {
|
|
99292
|
-
log$
|
|
99411
|
+
log$29.warn(`[compaction-diag] refused transcript repair/open runId=${runId} sessionKey=${params.sessionKey ?? params.sessionId} diagId=${diagId} trigger=${trigger} preservationArmed=${isPreservationArmed()} jsonlBackend=${isJsonlSessionBackend()}`);
|
|
99293
99412
|
return {
|
|
99294
99413
|
ok: true,
|
|
99295
99414
|
compacted: false,
|
|
@@ -99298,7 +99417,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99298
99417
|
}
|
|
99299
99418
|
await repairSessionFileIfNeeded({
|
|
99300
99419
|
sessionFile: params.sessionFile,
|
|
99301
|
-
warn: (message) => log$
|
|
99420
|
+
warn: (message) => log$29.warn(message)
|
|
99302
99421
|
});
|
|
99303
99422
|
await prewarmSessionFile(params.sessionFile);
|
|
99304
99423
|
const transcriptPolicy = resolveTranscriptPolicy({
|
|
@@ -99394,7 +99513,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99394
99513
|
const inputStorageCursor = await loadCompactionStorageCursor({
|
|
99395
99514
|
sessionId: params.sessionId,
|
|
99396
99515
|
sessionKey: params.sessionKey,
|
|
99397
|
-
warn: (message) => log$
|
|
99516
|
+
warn: (message) => log$29.warn(message)
|
|
99398
99517
|
});
|
|
99399
99518
|
const truncated = limitHistoryTurns(validated, getDmHistoryLimitFromSessionKey(params.sessionKey, params.config));
|
|
99400
99519
|
const limited = transcriptPolicy.repairToolUseResultPairing ? sanitizeToolUseResultPairing(truncated) : truncated;
|
|
@@ -99406,7 +99525,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99406
99525
|
tokenWindow,
|
|
99407
99526
|
usage,
|
|
99408
99527
|
storageCursor: inputStorageCursor,
|
|
99409
|
-
warn: (message) => log$
|
|
99528
|
+
warn: (message) => log$29.warn(message)
|
|
99410
99529
|
});
|
|
99411
99530
|
const sanitizedHookMessages = await sanitizeHookCompactionMessages({
|
|
99412
99531
|
messages: cloneCompactionMessages(compactionPlan.messages),
|
|
@@ -99429,7 +99548,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99429
99548
|
messages: transcriptPolicy.validateAnthropicTurns ? validateAnthropicTurns(validatedPlannedGemini) : validatedPlannedGemini,
|
|
99430
99549
|
fallbackMessages: limited,
|
|
99431
99550
|
replacedMessages: compactionPlan.replacedMessages,
|
|
99432
|
-
warn: (message) => log$
|
|
99551
|
+
warn: (message) => log$29.warn(message)
|
|
99433
99552
|
});
|
|
99434
99553
|
const compactionInputMessages = compactionInput.messages;
|
|
99435
99554
|
if (compactionInputMessages.length === 0) return fail(compactionInput.abortReason ?? "compaction input is empty");
|
|
@@ -99440,13 +99559,13 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99440
99559
|
messages: preCompactionMessages,
|
|
99441
99560
|
sessionFile: params.sessionFile
|
|
99442
99561
|
}, hookCtx).catch((hookErr) => {
|
|
99443
|
-
log$
|
|
99562
|
+
log$29.warn(`before_compaction hook failed: ${String(hookErr)}`);
|
|
99444
99563
|
});
|
|
99445
|
-
const diagEnabled = log$
|
|
99564
|
+
const diagEnabled = log$29.isEnabled("debug");
|
|
99446
99565
|
const preMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
99447
99566
|
if (diagEnabled && preMetrics) {
|
|
99448
|
-
log$
|
|
99449
|
-
log$
|
|
99567
|
+
log$29.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"}`);
|
|
99568
|
+
log$29.debug(`[compaction-diag] contributors diagId=${diagId} top=${JSON.stringify(preMetrics.contributors)}`);
|
|
99450
99569
|
}
|
|
99451
99570
|
const compactStartedAt = Date.now();
|
|
99452
99571
|
setContextHooksLastCompactionPreparation(sessionManager, void 0);
|
|
@@ -99456,7 +99575,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99456
99575
|
result = await compactWithAbortOnTimeout({
|
|
99457
99576
|
compact: () => session.compact(params.customInstructions),
|
|
99458
99577
|
abort: () => session.abortCompaction(),
|
|
99459
|
-
onAbortSettleTimeout: (err) => log$
|
|
99578
|
+
onAbortSettleTimeout: (err) => log$29.warn(`compaction did not settle after abort: ${String(err)}`)
|
|
99460
99579
|
});
|
|
99461
99580
|
} finally {
|
|
99462
99581
|
setContextHooksPlannedCompaction(sessionManager, void 0);
|
|
@@ -99484,12 +99603,12 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99484
99603
|
compactedCount: compactionInputMessages.length - session.messages.length,
|
|
99485
99604
|
sessionFile: params.sessionFile
|
|
99486
99605
|
}, hookCtx).catch((hookErr) => {
|
|
99487
|
-
log$
|
|
99606
|
+
log$29.warn(`after_compaction hook failed: ${hookErr}`);
|
|
99488
99607
|
});
|
|
99489
99608
|
const outputStorageCursor = await loadCompactionStorageCursor({
|
|
99490
99609
|
sessionId: params.sessionId,
|
|
99491
99610
|
sessionKey: params.sessionKey,
|
|
99492
|
-
warn: (message) => log$
|
|
99611
|
+
warn: (message) => log$29.warn(message)
|
|
99493
99612
|
});
|
|
99494
99613
|
const compactionResult = {
|
|
99495
99614
|
summary: result.summary,
|
|
@@ -99519,10 +99638,10 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99519
99638
|
outputMessageCount: session.messages.length,
|
|
99520
99639
|
replacedMessages: compactionReplacementApplied,
|
|
99521
99640
|
result: compactionResult,
|
|
99522
|
-
warn: (message) => log$
|
|
99641
|
+
warn: (message) => log$29.warn(message)
|
|
99523
99642
|
});
|
|
99524
99643
|
const postMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
99525
|
-
if (diagEnabled && preMetrics && postMetrics) log$
|
|
99644
|
+
if (diagEnabled && preMetrics && postMetrics) log$29.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"}`);
|
|
99526
99645
|
return {
|
|
99527
99646
|
ok: true,
|
|
99528
99647
|
compacted: true,
|
|
@@ -99551,7 +99670,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99551
99670
|
return fail(describeUnknownError(err));
|
|
99552
99671
|
} finally {
|
|
99553
99672
|
restoreSkillEnv?.();
|
|
99554
|
-
|
|
99673
|
+
releaseWorkspaceCwd();
|
|
99555
99674
|
}
|
|
99556
99675
|
}
|
|
99557
99676
|
/**
|
|
@@ -99675,15 +99794,15 @@ function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
|
99675
99794
|
if (transport === "sse" || transport === "websocket" || transport === "auto") streamParams.transport = transport;
|
|
99676
99795
|
else if (transport != null) {
|
|
99677
99796
|
const transportSummary = typeof transport === "string" ? transport : typeof transport;
|
|
99678
|
-
log$
|
|
99797
|
+
log$29.warn(`ignoring invalid transport param: ${transportSummary}`);
|
|
99679
99798
|
}
|
|
99680
99799
|
if (typeof extraParams.openaiWsWarmup === "boolean") streamParams.openaiWsWarmup = extraParams.openaiWsWarmup;
|
|
99681
99800
|
const cacheRetention = resolveCacheRetention(extraParams, provider);
|
|
99682
99801
|
if (cacheRetention) streamParams.cacheRetention = cacheRetention;
|
|
99683
99802
|
const providerRouting = provider === "openrouter" && extraParams.provider != null && typeof extraParams.provider === "object" ? extraParams.provider : void 0;
|
|
99684
99803
|
if (Object.keys(streamParams).length === 0 && !providerRouting) return;
|
|
99685
|
-
log$
|
|
99686
|
-
if (providerRouting) log$
|
|
99804
|
+
log$29.debug(`creating streamFn wrapper with params: ${JSON.stringify(streamParams)}`);
|
|
99805
|
+
if (providerRouting) log$29.debug(`OpenRouter provider routing: ${JSON.stringify(providerRouting)}`);
|
|
99687
99806
|
const underlying = baseStreamFn ?? streamSimple;
|
|
99688
99807
|
const wrappedStreamFn = (model, context, options) => {
|
|
99689
99808
|
return underlying(providerRouting ? {
|
|
@@ -99805,7 +99924,7 @@ function resolveAnthropicBetas(extraParams, provider, modelId) {
|
|
|
99805
99924
|
for (const beta of configured) if (typeof beta === "string" && beta.trim()) betas.add(beta.trim());
|
|
99806
99925
|
}
|
|
99807
99926
|
if (extraParams?.context1m === true) if (isAnthropic1MModel(modelId)) betas.add(ANTHROPIC_CONTEXT_1M_BETA);
|
|
99808
|
-
else log$
|
|
99927
|
+
else log$29.warn(`ignoring context1m for non-opus/sonnet model: ${provider}/${modelId}`);
|
|
99809
99928
|
return betas.size > 0 ? [...betas] : void 0;
|
|
99810
99929
|
}
|
|
99811
99930
|
function mergeAnthropicBetaHeader(headers, betas) {
|
|
@@ -99832,7 +99951,7 @@ function createAnthropicBetaHeadersWrapper(baseStreamFn, betas) {
|
|
|
99832
99951
|
const isOauth = isAnthropicOAuthApiKey(options?.apiKey);
|
|
99833
99952
|
const requestedContext1m = betas.includes(ANTHROPIC_CONTEXT_1M_BETA);
|
|
99834
99953
|
const effectiveBetas = isOauth && requestedContext1m ? betas.filter((beta) => beta !== ANTHROPIC_CONTEXT_1M_BETA) : betas;
|
|
99835
|
-
if (isOauth && requestedContext1m) log$
|
|
99954
|
+
if (isOauth && requestedContext1m) log$29.warn(`ignoring context1m for OAuth token auth on ${model.provider}/${model.id}; Anthropic rejects context-1m beta with OAuth auth`);
|
|
99836
99955
|
const piAiBetas = isOauth ? PI_AI_OAUTH_ANTHROPIC_BETAS : PI_AI_DEFAULT_ANTHROPIC_BETAS;
|
|
99837
99956
|
const allBetas = [...new Set([...piAiBetas, ...effectiveBetas])];
|
|
99838
99957
|
return underlying(model, context, {
|
|
@@ -100193,12 +100312,12 @@ function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverr
|
|
|
100193
100312
|
};
|
|
100194
100313
|
const wrappedStreamFn = createStreamFnWithExtraParams(agent.streamFn, merged, provider);
|
|
100195
100314
|
if (wrappedStreamFn) {
|
|
100196
|
-
log$
|
|
100315
|
+
log$29.debug(`applying extraParams to agent streamFn for ${provider}/${modelId}`);
|
|
100197
100316
|
agent.streamFn = wrappedStreamFn;
|
|
100198
100317
|
}
|
|
100199
100318
|
const anthropicBetas = resolveAnthropicBetas(merged, provider, modelId);
|
|
100200
100319
|
if (anthropicBetas?.length) {
|
|
100201
|
-
log$
|
|
100320
|
+
log$29.debug(`applying Anthropic beta header for ${provider}/${modelId}: ${anthropicBetas.join(",")}`);
|
|
100202
100321
|
agent.streamFn = createAnthropicBetaHeadersWrapper(agent.streamFn, anthropicBetas);
|
|
100203
100322
|
}
|
|
100204
100323
|
if (shouldApplySiliconFlowThinkingOffCompat({
|
|
@@ -100206,7 +100325,7 @@ function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverr
|
|
|
100206
100325
|
modelId,
|
|
100207
100326
|
thinkingLevel
|
|
100208
100327
|
})) {
|
|
100209
|
-
log$
|
|
100328
|
+
log$29.debug(`normalizing thinking=off to thinking=null for SiliconFlow compatibility (${provider}/${modelId})`);
|
|
100210
100329
|
agent.streamFn = createSiliconFlowThinkingWrapper(agent.streamFn);
|
|
100211
100330
|
}
|
|
100212
100331
|
if (provider === "moonshot") {
|
|
@@ -100214,22 +100333,22 @@ function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverr
|
|
|
100214
100333
|
configuredThinking: merged?.thinking,
|
|
100215
100334
|
thinkingLevel
|
|
100216
100335
|
});
|
|
100217
|
-
if (moonshotThinkingType) log$
|
|
100336
|
+
if (moonshotThinkingType) log$29.debug(`applying Moonshot thinking=${moonshotThinkingType} payload wrapper for ${provider}/${modelId}`);
|
|
100218
100337
|
agent.streamFn = createMoonshotThinkingWrapper(agent.streamFn, moonshotThinkingType);
|
|
100219
100338
|
}
|
|
100220
100339
|
if (provider === "openrouter") {
|
|
100221
|
-
log$
|
|
100340
|
+
log$29.debug(`applying OpenRouter app attribution headers for ${provider}/${modelId}`);
|
|
100222
100341
|
const openRouterThinkingLevel = modelId === "auto" || isOpenRouterReasoningUnsupported(modelId) ? void 0 : thinkingLevel;
|
|
100223
100342
|
agent.streamFn = createOpenRouterWrapper(agent.streamFn, openRouterThinkingLevel);
|
|
100224
100343
|
agent.streamFn = createOpenRouterSystemCacheWrapper(agent.streamFn);
|
|
100225
100344
|
}
|
|
100226
100345
|
if (provider === "amazon-bedrock" && !isAnthropicBedrockModel(modelId)) {
|
|
100227
|
-
log$
|
|
100346
|
+
log$29.debug(`disabling prompt caching for non-Anthropic Bedrock model ${provider}/${modelId}`);
|
|
100228
100347
|
agent.streamFn = createBedrockNoCacheWrapper(agent.streamFn);
|
|
100229
100348
|
}
|
|
100230
100349
|
if (provider === "zai" || provider === "z-ai") {
|
|
100231
100350
|
if (merged?.tool_stream !== false) {
|
|
100232
|
-
log$
|
|
100351
|
+
log$29.debug(`enabling Z.AI tool_stream for ${provider}/${modelId}`);
|
|
100233
100352
|
agent.streamFn = createZaiToolStreamWrapper(agent.streamFn, true);
|
|
100234
100353
|
}
|
|
100235
100354
|
}
|
|
@@ -100921,7 +101040,7 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
100921
101040
|
if (!session.manager.isConnected() && !session.broken) try {
|
|
100922
101041
|
await session.manager.connect(apiKey);
|
|
100923
101042
|
session.everConnected = true;
|
|
100924
|
-
log$
|
|
101043
|
+
log$29.debug(`[ws-stream] connected for session=${sessionId}`);
|
|
100925
101044
|
} catch (connErr) {
|
|
100926
101045
|
try {
|
|
100927
101046
|
session.manager.close();
|
|
@@ -100929,12 +101048,12 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
100929
101048
|
session.broken = true;
|
|
100930
101049
|
wsRegistry.delete(sessionId);
|
|
100931
101050
|
if (transport === "websocket") throw connErr instanceof Error ? connErr : new Error(String(connErr));
|
|
100932
|
-
log$
|
|
101051
|
+
log$29.warn(`[ws-stream] WebSocket connect failed for session=${sessionId}; falling back to HTTP. error=${String(connErr)}`);
|
|
100933
101052
|
return fallbackToHttp(model, context, options, eventStream, apiKey, opts.signal);
|
|
100934
101053
|
}
|
|
100935
101054
|
if (session.broken || !session.manager.isConnected()) {
|
|
100936
101055
|
if (transport === "websocket") throw new Error("WebSocket session disconnected");
|
|
100937
|
-
log$
|
|
101056
|
+
log$29.warn(`[ws-stream] session=${sessionId} broken/disconnected; falling back to HTTP`);
|
|
100938
101057
|
try {
|
|
100939
101058
|
session.manager.close();
|
|
100940
101059
|
} catch {}
|
|
@@ -100952,10 +101071,10 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
100952
101071
|
instructions: context.systemPrompt ?? void 0,
|
|
100953
101072
|
signal
|
|
100954
101073
|
});
|
|
100955
|
-
log$
|
|
101074
|
+
log$29.debug(`[ws-stream] warm-up completed for session=${sessionId}`);
|
|
100956
101075
|
} catch (warmErr) {
|
|
100957
101076
|
if (signal?.aborted) throw warmErr instanceof Error ? warmErr : new Error(String(warmErr));
|
|
100958
|
-
log$
|
|
101077
|
+
log$29.warn(`[ws-stream] warm-up failed for session=${sessionId}; continuing without warm-up. error=${String(warmErr)}`);
|
|
100959
101078
|
}
|
|
100960
101079
|
}
|
|
100961
101080
|
const prevResponseId = session.manager.previousResponseId;
|
|
@@ -100963,13 +101082,13 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
100963
101082
|
if (prevResponseId && session.lastContextLength > 0) {
|
|
100964
101083
|
const toolResults = context.messages.slice(session.lastContextLength).filter((m) => m.role === "toolResult");
|
|
100965
101084
|
if (toolResults.length === 0) {
|
|
100966
|
-
log$
|
|
101085
|
+
log$29.debug(`[ws-stream] session=${sessionId}: no new tool results found; sending full context`);
|
|
100967
101086
|
inputItems = buildFullInput(context);
|
|
100968
101087
|
} else inputItems = convertMessagesToInputItems(toolResults);
|
|
100969
|
-
log$
|
|
101088
|
+
log$29.debug(`[ws-stream] session=${sessionId}: incremental send (${inputItems.length} tool results) previous_response_id=${prevResponseId}`);
|
|
100970
101089
|
} else {
|
|
100971
101090
|
inputItems = buildFullInput(context);
|
|
100972
|
-
log$
|
|
101091
|
+
log$29.debug(`[ws-stream] session=${sessionId}: full context send (${inputItems.length} items)`);
|
|
100973
101092
|
}
|
|
100974
101093
|
const tools = convertTools(context.tools);
|
|
100975
101094
|
const streamOpts = options;
|
|
@@ -100999,7 +101118,7 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
100999
101118
|
session.manager.send(payload);
|
|
101000
101119
|
} catch (sendErr) {
|
|
101001
101120
|
if (transport === "websocket") throw sendErr instanceof Error ? sendErr : new Error(String(sendErr));
|
|
101002
|
-
log$
|
|
101121
|
+
log$29.warn(`[ws-stream] send failed for session=${sessionId}; falling back to HTTP. error=${String(sendErr)}`);
|
|
101003
101122
|
try {
|
|
101004
101123
|
session.manager.close();
|
|
101005
101124
|
} catch {}
|
|
@@ -101079,7 +101198,7 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
101079
101198
|
};
|
|
101080
101199
|
queueMicrotask(() => run().catch((err) => {
|
|
101081
101200
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
101082
|
-
log$
|
|
101201
|
+
log$29.warn(`[ws-stream] session=${sessionId} run error: ${errorMessage}`);
|
|
101083
101202
|
eventStream.push({
|
|
101084
101203
|
type: "error",
|
|
101085
101204
|
reason: "error",
|
|
@@ -103129,7 +103248,7 @@ function normalizeRefForDedupe(raw) {
|
|
|
103129
103248
|
}
|
|
103130
103249
|
async function sanitizeImagesWithLog(images, label, imageSanitization) {
|
|
103131
103250
|
const { images: sanitized, dropped } = await sanitizeImageBlocks(images, label, imageSanitization);
|
|
103132
|
-
if (dropped > 0) log$
|
|
103251
|
+
if (dropped > 0) log$29.warn(`Native image: dropped ${dropped} image(s) after sanitization (${label}).`);
|
|
103133
103252
|
return sanitized;
|
|
103134
103253
|
}
|
|
103135
103254
|
/**
|
|
@@ -103216,7 +103335,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
103216
103335
|
mediaPath: targetPath
|
|
103217
103336
|
})).resolved;
|
|
103218
103337
|
} catch (err) {
|
|
103219
|
-
log$
|
|
103338
|
+
log$29.debug(`Native image: sandbox validation failed for ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
103220
103339
|
return null;
|
|
103221
103340
|
}
|
|
103222
103341
|
else if (!path.isAbsolute(targetPath)) targetPath = path.resolve(workspaceDir, targetPath);
|
|
@@ -103234,7 +103353,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
103234
103353
|
readFile: createSandboxBridgeReadFile({ sandbox: options.sandbox })
|
|
103235
103354
|
}) : await loadWebMedia(targetPath, options?.maxBytes);
|
|
103236
103355
|
if (media.kind !== "image") {
|
|
103237
|
-
log$
|
|
103356
|
+
log$29.debug(`Native image: not an image file: ${targetPath} (got ${media.kind})`);
|
|
103238
103357
|
return null;
|
|
103239
103358
|
}
|
|
103240
103359
|
const mimeType = media.contentType ?? "image/jpeg";
|
|
@@ -103244,7 +103363,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
103244
103363
|
mimeType
|
|
103245
103364
|
};
|
|
103246
103365
|
} catch (err) {
|
|
103247
|
-
log$
|
|
103366
|
+
log$29.debug(`Native image: failed to load ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
103248
103367
|
return null;
|
|
103249
103368
|
}
|
|
103250
103369
|
}
|
|
@@ -103281,7 +103400,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
103281
103400
|
loadedCount: 0,
|
|
103282
103401
|
skippedCount: 0
|
|
103283
103402
|
};
|
|
103284
|
-
log$
|
|
103403
|
+
log$29.debug(`Native image: detected ${allRefs.length} image refs in prompt`);
|
|
103285
103404
|
const promptImages = [...params.existingImages ?? []];
|
|
103286
103405
|
let loadedCount = 0;
|
|
103287
103406
|
let skippedCount = 0;
|
|
@@ -103294,7 +103413,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
103294
103413
|
if (image) {
|
|
103295
103414
|
promptImages.push(image);
|
|
103296
103415
|
loadedCount++;
|
|
103297
|
-
log$
|
|
103416
|
+
log$29.debug(`Native image: loaded ${ref.type} ${ref.resolved}`);
|
|
103298
103417
|
} else skippedCount++;
|
|
103299
103418
|
}
|
|
103300
103419
|
return {
|
|
@@ -103909,7 +104028,7 @@ async function buildStreamFn(params) {
|
|
|
103909
104028
|
const wsApiKey = await params.authStorage.getApiKey(params.provider);
|
|
103910
104029
|
if (wsApiKey) streamFn = createOpenAIWebSocketStreamFn(wsApiKey, params.sessionId, { signal: params.abortSignal });
|
|
103911
104030
|
else {
|
|
103912
|
-
log$
|
|
104031
|
+
log$29.warn(`[ws-stream] no API key for provider=${params.provider}; using HTTP transport`);
|
|
103913
104032
|
streamFn = streamSimple;
|
|
103914
104033
|
}
|
|
103915
104034
|
} else {
|
|
@@ -104012,13 +104131,13 @@ async function resolvePromptBuildHookResult(params) {
|
|
|
104012
104131
|
messages: params.messages,
|
|
104013
104132
|
systemPrompt: params.systemPrompt
|
|
104014
104133
|
}, params.hookCtx).catch((hookErr) => {
|
|
104015
|
-
log$
|
|
104134
|
+
log$29.warn(`before_prompt_build hook failed: ${String(hookErr)}`);
|
|
104016
104135
|
}) : void 0;
|
|
104017
104136
|
const legacyResult = params.legacyBeforeAgentStartResult ?? (params.hookRunner?.hasHooks("before_agent_start") ? await params.hookRunner.runBeforeAgentStart({
|
|
104018
104137
|
prompt: params.prompt,
|
|
104019
104138
|
messages: params.messages
|
|
104020
104139
|
}, params.hookCtx).catch((hookErr) => {
|
|
104021
|
-
log$
|
|
104140
|
+
log$29.warn(`before_agent_start hook (legacy prompt build path) failed: ${String(hookErr)}`);
|
|
104022
104141
|
}) : void 0);
|
|
104023
104142
|
return {
|
|
104024
104143
|
systemPrompt: promptBuildResult?.systemPrompt ?? legacyResult?.systemPrompt,
|
|
@@ -104156,7 +104275,7 @@ async function collectAttemptPromptContribution(params) {
|
|
|
104156
104275
|
messages: params.messages,
|
|
104157
104276
|
envelope: params.envelope
|
|
104158
104277
|
}, params.lifecycleCtx).catch((hookErr) => {
|
|
104159
|
-
log$
|
|
104278
|
+
log$29.warn(`context.collect hook failed: ${String(hookErr)}`);
|
|
104160
104279
|
}) : void 0;
|
|
104161
104280
|
return mergePromptContributions([promptBuildResultToContribution(legacyResult), contextCollectResult]);
|
|
104162
104281
|
}
|
|
@@ -104171,7 +104290,7 @@ async function runContextProjectionAndPruningHooks(params) {
|
|
|
104171
104290
|
contributions: params.contributions,
|
|
104172
104291
|
envelope: params.envelope
|
|
104173
104292
|
}, params.lifecycleCtx).catch((hookErr) => {
|
|
104174
|
-
log$
|
|
104293
|
+
log$29.warn(`context.project hook failed: ${String(hookErr)}`);
|
|
104175
104294
|
});
|
|
104176
104295
|
if (result?.messages) currentMessages = result.messages;
|
|
104177
104296
|
if (result?.projection) projection = {
|
|
@@ -104187,7 +104306,7 @@ async function runContextProjectionAndPruningHooks(params) {
|
|
|
104187
104306
|
tokenWindow: params.lifecycleCtx.tokenWindow,
|
|
104188
104307
|
usage: params.lifecycleCtx.usage
|
|
104189
104308
|
}, params.lifecycleCtx).catch((hookErr) => {
|
|
104190
|
-
log$
|
|
104309
|
+
log$29.warn(`context.prune hook failed: ${String(hookErr)}`);
|
|
104191
104310
|
});
|
|
104192
104311
|
if (result?.messages) currentMessages = result.messages;
|
|
104193
104312
|
if (result?.dropped) dropped.push(...result.dropped);
|
|
@@ -104289,7 +104408,7 @@ function installAttemptInputTransform(params) {
|
|
|
104289
104408
|
runtime: params.projectionRuntime,
|
|
104290
104409
|
timeoutMs: params.projectionArtifactTimeoutMs
|
|
104291
104410
|
}).catch((err) => {
|
|
104292
|
-
log$
|
|
104411
|
+
log$29.warn(`context projection artifact persist failed: ${String(err)}`);
|
|
104293
104412
|
});
|
|
104294
104413
|
const finalMessages = await runTransformLlmInputHooks({
|
|
104295
104414
|
messages: currentMessages,
|
|
@@ -104298,7 +104417,7 @@ function installAttemptInputTransform(params) {
|
|
|
104298
104417
|
provider: params.provider,
|
|
104299
104418
|
modelId: params.modelId
|
|
104300
104419
|
}).catch((err) => {
|
|
104301
|
-
log$
|
|
104420
|
+
log$29.warn(`transform_llm_input hook failed: ${String(err)}`);
|
|
104302
104421
|
}) ?? currentMessages;
|
|
104303
104422
|
params.onFinalInputMessages?.(finalMessages);
|
|
104304
104423
|
return finalMessages;
|
|
@@ -104416,11 +104535,10 @@ function summarizeSessionContext(messages) {
|
|
|
104416
104535
|
}
|
|
104417
104536
|
async function runEmbeddedAttempt(params) {
|
|
104418
104537
|
const resolvedWorkspace = resolveUserPath(params.workspaceDir);
|
|
104419
|
-
const prevCwd = process.cwd();
|
|
104420
104538
|
let pendingClearActiveEmbeddedRun;
|
|
104421
104539
|
const runAbortController = new AbortController();
|
|
104422
104540
|
const currentUserTurnForStorage = resolveCurrentUserTurnForStorage(params);
|
|
104423
|
-
log$
|
|
104541
|
+
log$29.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"}`);
|
|
104424
104542
|
await fs.mkdir(resolvedWorkspace, { recursive: true });
|
|
104425
104543
|
const sandboxSessionKey = params.sessionKey?.trim() || params.sessionId;
|
|
104426
104544
|
const toolSessionKey = params.toolSessionKey?.trim() || sandboxSessionKey;
|
|
@@ -104433,7 +104551,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
104433
104551
|
const effectiveWorkspace = sandbox?.enabled ? sandbox.workspaceAccess === "rw" ? resolvedWorkspace : sandbox.workspaceDir : resolvedWorkspace;
|
|
104434
104552
|
await fs.mkdir(effectiveWorkspace, { recursive: true });
|
|
104435
104553
|
let restoreSkillEnv;
|
|
104436
|
-
|
|
104554
|
+
const releaseWorkspaceCwd = params.skipCwdChange ? void 0 : acquireWorkspaceCwd(effectiveWorkspace);
|
|
104437
104555
|
try {
|
|
104438
104556
|
const skillWorkspace = params.skillWorkspaceDir ?? effectiveWorkspace;
|
|
104439
104557
|
const shouldLoadSkillEntries = !params.skipSkillEnv && (!params.skillsSnapshot || !params.skillsSnapshot.resolvedSkills);
|
|
@@ -104475,7 +104593,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
104475
104593
|
resolvedSystemPrompt,
|
|
104476
104594
|
warn: makeBootstrapWarn({
|
|
104477
104595
|
sessionLabel,
|
|
104478
|
-
warn: (message) => log$
|
|
104596
|
+
warn: (message) => log$29.warn(message)
|
|
104479
104597
|
}),
|
|
104480
104598
|
contextMode: params.bootstrapContextMode,
|
|
104481
104599
|
runKind: params.bootstrapContextRunKind,
|
|
@@ -104717,7 +104835,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
104717
104835
|
if (queue != null) {
|
|
104718
104836
|
await drainPendingPrimaryWrites(queue, 3e4, storage?.config.fallbackToJsonlOnError ?? false);
|
|
104719
104837
|
if (storage?.runtime?.conversation?.upsertTurn) await storage.runtime.conversation.upsertTurn(params.sessionId).catch((err) => {
|
|
104720
|
-
log$
|
|
104838
|
+
log$29.warn("turn upsert failed (non-fatal)", {
|
|
104721
104839
|
sessionId: params.sessionId,
|
|
104722
104840
|
err
|
|
104723
104841
|
});
|
|
@@ -104785,14 +104903,14 @@ async function runEmbeddedAttempt(params) {
|
|
|
104785
104903
|
sessionManager = _wrapped.sm;
|
|
104786
104904
|
_primaryWriteQueue = _wrapped.queue;
|
|
104787
104905
|
}
|
|
104788
|
-
} else log$
|
|
104906
|
+
} else log$29.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", {
|
|
104789
104907
|
sessionId: params.sessionId,
|
|
104790
104908
|
backend: _configuredStorage?.runtime?.backend
|
|
104791
104909
|
});
|
|
104792
104910
|
} else {
|
|
104793
104911
|
await repairSessionFileIfNeeded({
|
|
104794
104912
|
sessionFile: params.sessionFile,
|
|
104795
|
-
warn: (message) => log$
|
|
104913
|
+
warn: (message) => log$29.warn(message)
|
|
104796
104914
|
});
|
|
104797
104915
|
const hadSessionFile = await fs.stat(params.sessionFile).then(() => true).catch(() => false);
|
|
104798
104916
|
if (!params.skipSessionManagerCache) await prewarmSessionFile(params.sessionFile);
|
|
@@ -104933,7 +105051,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
104933
105051
|
const wsApiKey = await params.authStorage.getApiKey(params.provider);
|
|
104934
105052
|
if (wsApiKey) activeSession.agent.streamFn = createOpenAIWebSocketStreamFn(wsApiKey, params.sessionId, { signal: runAbortController.signal });
|
|
104935
105053
|
else {
|
|
104936
|
-
log$
|
|
105054
|
+
log$29.warn(`[ws-stream] no API key for provider=${params.provider}; using HTTP transport`);
|
|
104937
105055
|
activeSession.agent.streamFn = streamSimple;
|
|
104938
105056
|
}
|
|
104939
105057
|
} else {
|
|
@@ -105133,7 +105251,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105133
105251
|
let abortWarnTimer;
|
|
105134
105252
|
const isProbeSession = params.sessionId?.startsWith("probe-") ?? false;
|
|
105135
105253
|
const abortTimer = setTimeout(() => {
|
|
105136
|
-
if (!isProbeSession) log$
|
|
105254
|
+
if (!isProbeSession) log$29.warn(`embedded run timeout: runId=${params.runId} sessionId=${params.sessionId} timeoutMs=${params.timeoutMs}`);
|
|
105137
105255
|
if (shouldFlagCompactionTimeout({
|
|
105138
105256
|
isTimeout: true,
|
|
105139
105257
|
isCompactionPendingOrRetrying: subscription.isCompacting(),
|
|
@@ -105142,7 +105260,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105142
105260
|
abortRun(true);
|
|
105143
105261
|
if (!abortWarnTimer) abortWarnTimer = setTimeout(() => {
|
|
105144
105262
|
if (!activeSession.isStreaming) return;
|
|
105145
|
-
if (!isProbeSession) log$
|
|
105263
|
+
if (!isProbeSession) log$29.warn(`embedded run abort still streaming: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105146
105264
|
}, 1e4);
|
|
105147
105265
|
}, Math.max(1, params.timeoutMs));
|
|
105148
105266
|
let messagesSnapshot = [];
|
|
@@ -105176,7 +105294,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105176
105294
|
let timeoutHandle;
|
|
105177
105295
|
const timeout = new Promise((resolve) => {
|
|
105178
105296
|
timeoutHandle = setTimeout(() => {
|
|
105179
|
-
log$
|
|
105297
|
+
log$29.warn(`${label} timed out after ${metaTimeoutMs}ms`);
|
|
105180
105298
|
resolve(void 0);
|
|
105181
105299
|
}, metaTimeoutMs);
|
|
105182
105300
|
timeoutHandle.unref?.();
|
|
@@ -105184,7 +105302,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105184
105302
|
try {
|
|
105185
105303
|
return await Promise.race([p, timeout]);
|
|
105186
105304
|
} catch (err) {
|
|
105187
|
-
log$
|
|
105305
|
+
log$29.warn(`${label} failed: ${String(err)}`);
|
|
105188
105306
|
return;
|
|
105189
105307
|
} finally {
|
|
105190
105308
|
if (timeoutHandle !== void 0) clearTimeout(timeoutHandle);
|
|
@@ -105209,14 +105327,14 @@ async function runEmbeddedAttempt(params) {
|
|
|
105209
105327
|
senderIdentity,
|
|
105210
105328
|
workspaceLane: params.workspaceLane
|
|
105211
105329
|
});
|
|
105212
|
-
log$
|
|
105330
|
+
log$29.debug(`embedded run prompt start: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105213
105331
|
const leafEntry = sessionManager.getLeafEntry();
|
|
105214
105332
|
if (leafEntry?.type === "message" && leafEntry.message.role === "user") {
|
|
105215
105333
|
if (leafEntry.parentId) sessionManager.branch(leafEntry.parentId);
|
|
105216
105334
|
else sessionManager.resetLeaf();
|
|
105217
105335
|
const sessionContext = sessionManager.buildSessionContext();
|
|
105218
105336
|
activeSession.agent.state.messages = sessionContext.messages;
|
|
105219
|
-
log$
|
|
105337
|
+
log$29.warn(`Removed orphaned user message to prevent consecutive user turns. runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105220
105338
|
}
|
|
105221
105339
|
const cleanUserMessage = createCleanUserMessageFromPrompt(params.prompt);
|
|
105222
105340
|
const baseEnvelope = createCurrentUserPromptEnvelope({ cleanUserMessage });
|
|
@@ -105245,7 +105363,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105245
105363
|
const contributedSystemPrompt = applySystemPromptContribution(systemPromptText, promptContribution);
|
|
105246
105364
|
if (contributedSystemPrompt !== systemPromptText) {
|
|
105247
105365
|
applySystemPromptOverrideToSession(activeSession, contributedSystemPrompt);
|
|
105248
|
-
log$
|
|
105366
|
+
log$29.debug(`hooks: augmented system prompt (+${contributedSystemPrompt.length - systemPromptText.length} chars)`);
|
|
105249
105367
|
systemPromptText = contributedSystemPrompt;
|
|
105250
105368
|
}
|
|
105251
105369
|
cacheTrace?.recordStage("prompt:before", {
|
|
@@ -105277,12 +105395,12 @@ async function runEmbeddedAttempt(params) {
|
|
|
105277
105395
|
messages: activeSession.messages,
|
|
105278
105396
|
note: `images: prompt=${imageResult.images.length}`
|
|
105279
105397
|
});
|
|
105280
|
-
if (log$
|
|
105398
|
+
if (log$29.isEnabled("debug")) {
|
|
105281
105399
|
const msgCount = activeSession.messages.length;
|
|
105282
105400
|
const systemLen = systemPromptText?.length ?? 0;
|
|
105283
105401
|
const promptLen = effectivePrompt.length;
|
|
105284
105402
|
const sessionSummary = summarizeSessionContext(activeSession.messages);
|
|
105285
|
-
log$
|
|
105403
|
+
log$29.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}`);
|
|
105286
105404
|
}
|
|
105287
105405
|
if (hookRunner?.hasHooks("llm_input")) hookRunner.runLlmInput({
|
|
105288
105406
|
runId: params.runId,
|
|
@@ -105294,7 +105412,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105294
105412
|
historyMessages: activeSession.messages,
|
|
105295
105413
|
imagesCount: imageResult.images.length
|
|
105296
105414
|
}, hookCtx).catch((err) => {
|
|
105297
|
-
log$
|
|
105415
|
+
log$29.warn(`llm_input hook failed: ${String(err)}`);
|
|
105298
105416
|
});
|
|
105299
105417
|
const modelUserMessage = appendPromptImagesToUserMessage(renderedCurrentUserPrompt.modelUserMessage, imageResult.images);
|
|
105300
105418
|
const currentPromptIndex = activeSession.messages.length;
|
|
@@ -105337,7 +105455,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105337
105455
|
errorType: String(err instanceof Error ? err.name : "UnknownError")
|
|
105338
105456
|
});
|
|
105339
105457
|
} finally {
|
|
105340
|
-
log$
|
|
105458
|
+
log$29.debug(`embedded run prompt end: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - promptStartedAt}`);
|
|
105341
105459
|
}
|
|
105342
105460
|
const wasCompactingBefore = activeSession.isCompacting;
|
|
105343
105461
|
const snapshot = activeSession.messages.slice();
|
|
@@ -105352,7 +105470,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105352
105470
|
promptError = err;
|
|
105353
105471
|
promptErrorSource = "compaction";
|
|
105354
105472
|
}
|
|
105355
|
-
if (!isProbeSession) log$
|
|
105473
|
+
if (!isProbeSession) log$29.debug(`compaction wait aborted: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105356
105474
|
} else throw err;
|
|
105357
105475
|
}
|
|
105358
105476
|
const compactionOccurredThisAttempt = getCompactionCount() > 0;
|
|
@@ -105371,7 +105489,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105371
105489
|
currentSessionId: activeSession.sessionId
|
|
105372
105490
|
});
|
|
105373
105491
|
if (timedOutDuringCompaction) {
|
|
105374
|
-
if (!isProbeSession) log$
|
|
105492
|
+
if (!isProbeSession) log$29.warn(`using ${snapshotSelection.source} snapshot: timed out during compaction runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105375
105493
|
}
|
|
105376
105494
|
messagesSnapshot = snapshotSelection.messagesSnapshot;
|
|
105377
105495
|
sessionIdUsed = snapshotSelection.sessionIdUsed;
|
|
@@ -105386,7 +105504,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105386
105504
|
error: describeUnknownError(promptError)
|
|
105387
105505
|
});
|
|
105388
105506
|
} catch (entryErr) {
|
|
105389
|
-
log$
|
|
105507
|
+
log$29.warn(`failed to persist prompt error entry: ${String(entryErr)}`);
|
|
105390
105508
|
}
|
|
105391
105509
|
if (!params.skipTranscriptSync) await drainOrSyncTranscript(_primaryWriteQueue, _isDbBackend, _configuredStorage, {
|
|
105392
105510
|
agentId: hookAgentIdForTranscript,
|
|
@@ -105406,16 +105524,16 @@ async function runEmbeddedAttempt(params) {
|
|
|
105406
105524
|
error: promptError ? describeUnknownError(promptError) : void 0,
|
|
105407
105525
|
durationMs: Date.now() - promptStartedAt
|
|
105408
105526
|
}, hookCtx).catch((err) => {
|
|
105409
|
-
log$
|
|
105527
|
+
log$29.warn(`agent_end hook failed: ${err}`);
|
|
105410
105528
|
});
|
|
105411
105529
|
} finally {
|
|
105412
105530
|
clearTimeout(abortTimer);
|
|
105413
105531
|
if (abortWarnTimer) clearTimeout(abortWarnTimer);
|
|
105414
|
-
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$
|
|
105532
|
+
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$29.debug(`run cleanup: runId=${params.runId} sessionId=${params.sessionId} aborted=${aborted} timedOut=${timedOut}`);
|
|
105415
105533
|
try {
|
|
105416
105534
|
unsubscribe();
|
|
105417
105535
|
} catch (err) {
|
|
105418
|
-
log$
|
|
105536
|
+
log$29.error(`CRITICAL: unsubscribe failed, possible resource leak: runId=${params.runId} ${String(err)}`);
|
|
105419
105537
|
}
|
|
105420
105538
|
pendingClearActiveEmbeddedRun = () => clearActiveEmbeddedRun(params.sessionId, queueHandle, params.sessionKey, !aborted && !timedOut && !promptError);
|
|
105421
105539
|
params.abortSignal?.removeEventListener?.("abort", onAbort);
|
|
@@ -105453,7 +105571,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105453
105571
|
workspaceLane: params.workspaceLane,
|
|
105454
105572
|
runId: params.runId
|
|
105455
105573
|
})).catch((err) => {
|
|
105456
|
-
log$
|
|
105574
|
+
log$29.warn(`model_call_ended hook failed: ${String(err)}`);
|
|
105457
105575
|
});
|
|
105458
105576
|
proxyMetadataFromHook = modelCallEndedEvent.proxyMetadata;
|
|
105459
105577
|
}
|
|
@@ -105477,7 +105595,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105477
105595
|
workspaceLane: params.workspaceLane,
|
|
105478
105596
|
runId: params.runId
|
|
105479
105597
|
})).catch((err) => {
|
|
105480
|
-
log$
|
|
105598
|
+
log$29.warn(`llm_output hook failed: ${String(err)}`);
|
|
105481
105599
|
});
|
|
105482
105600
|
return {
|
|
105483
105601
|
aborted,
|
|
@@ -105520,7 +105638,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105520
105638
|
if (_primaryWriteQueue != null && _primaryWriteQueue.length > 0) try {
|
|
105521
105639
|
await drainPendingPrimaryWrites(_primaryWriteQueue, 5e3, _configuredStorage?.config.fallbackToJsonlOnError ?? false);
|
|
105522
105640
|
} catch (cleanupDrainErr) {
|
|
105523
|
-
log$
|
|
105641
|
+
log$29.error("cleanup drain failed in finally; session entries may be lost", {
|
|
105524
105642
|
sessionId: params.sessionId,
|
|
105525
105643
|
error: cleanupDrainErr
|
|
105526
105644
|
});
|
|
@@ -105532,7 +105650,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105532
105650
|
}
|
|
105533
105651
|
} finally {
|
|
105534
105652
|
restoreSkillEnv?.();
|
|
105535
|
-
|
|
105653
|
+
releaseWorkspaceCwd?.();
|
|
105536
105654
|
pendingClearActiveEmbeddedRun?.();
|
|
105537
105655
|
}
|
|
105538
105656
|
}
|
|
@@ -105808,8 +105926,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
105808
105926
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
105809
105927
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
105810
105928
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
105811
|
-
if (workspaceResolution.usedFallback) log$
|
|
105812
|
-
const prevCwd = process.cwd();
|
|
105929
|
+
if (workspaceResolution.usedFallback) log$29.warn(`[workspace-fallback] caller=runEmbeddedPiAgent reason=${workspaceResolution.fallbackReason} run=${params.runId} session=${redactedSessionId} sessionKey=${redactedSessionKey} agent=${workspaceResolution.agentId} workspace=${redactedWorkspace}`);
|
|
105813
105930
|
let provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
105814
105931
|
let modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
105815
105932
|
const agentDir = params.agentDir ?? resolveOpenClawAgentDir();
|
|
@@ -105849,7 +105966,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
105849
105966
|
if (hookRunner?.hasHooks("before_model_resolve")) try {
|
|
105850
105967
|
modelResolveOverride = await hookRunner.runBeforeModelResolve({ prompt: params.prompt }, hookCtx);
|
|
105851
105968
|
} catch (hookErr) {
|
|
105852
|
-
log$
|
|
105969
|
+
log$29.warn(`before_model_resolve hook failed: ${String(hookErr)}`);
|
|
105853
105970
|
}
|
|
105854
105971
|
if (hookRunner?.hasHooks("before_agent_start")) try {
|
|
105855
105972
|
legacyBeforeAgentStartResult = await hookRunner.runBeforeAgentStart({ prompt: params.prompt }, hookCtx);
|
|
@@ -105858,15 +105975,15 @@ async function runEmbeddedPiAgent(params) {
|
|
|
105858
105975
|
modelOverride: modelResolveOverride?.modelOverride ?? legacyBeforeAgentStartResult?.modelOverride
|
|
105859
105976
|
};
|
|
105860
105977
|
} catch (hookErr) {
|
|
105861
|
-
log$
|
|
105978
|
+
log$29.warn(`before_agent_start hook (legacy model resolve path) failed: ${String(hookErr)}`);
|
|
105862
105979
|
}
|
|
105863
105980
|
if (modelResolveOverride?.providerOverride) {
|
|
105864
105981
|
provider = modelResolveOverride.providerOverride;
|
|
105865
|
-
log$
|
|
105982
|
+
log$29.info(`[hooks] provider overridden to ${provider}`);
|
|
105866
105983
|
}
|
|
105867
105984
|
if (modelResolveOverride?.modelOverride) {
|
|
105868
105985
|
modelId = modelResolveOverride.modelOverride;
|
|
105869
|
-
log$
|
|
105986
|
+
log$29.info(`[hooks] model overridden to ${modelId}`);
|
|
105870
105987
|
}
|
|
105871
105988
|
const { model, error, authStorage, modelRegistry } = resolveModel(provider, modelId, agentDir, params.config);
|
|
105872
105989
|
if (!model) throw new FailoverError(error ?? `Unknown model: ${provider}/${modelId}`, {
|
|
@@ -105886,9 +106003,9 @@ async function runEmbeddedPiAgent(params) {
|
|
|
105886
106003
|
warnBelowTokens: CONTEXT_WINDOW_WARN_BELOW_TOKENS,
|
|
105887
106004
|
hardMinTokens: CONTEXT_WINDOW_HARD_MIN_TOKENS
|
|
105888
106005
|
});
|
|
105889
|
-
if (ctxGuard.shouldWarn) log$
|
|
106006
|
+
if (ctxGuard.shouldWarn) log$29.warn(`low context window: ${provider}/${modelId} ctx=${ctxGuard.tokens} (warn<${CONTEXT_WINDOW_WARN_BELOW_TOKENS}) source=${ctxGuard.source}`);
|
|
105890
106007
|
if (ctxGuard.shouldBlock) {
|
|
105891
|
-
log$
|
|
106008
|
+
log$29.error(`blocked model (context window too small): ${provider}/${modelId} ctx=${ctxGuard.tokens} (min=${CONTEXT_WINDOW_HARD_MIN_TOKENS}) source=${ctxGuard.source}`);
|
|
105892
106009
|
throw new FailoverError(`Model context window too small (${ctxGuard.tokens} tokens). Minimum is ${CONTEXT_WINDOW_HARD_MIN_TOKENS}.`, {
|
|
105893
106010
|
reason: "unknown",
|
|
105894
106011
|
provider,
|
|
@@ -105942,14 +106059,14 @@ async function runEmbeddedPiAgent(params) {
|
|
|
105942
106059
|
copilotTokenState.refreshInFlight = (async () => {
|
|
105943
106060
|
const githubToken = copilotTokenState.githubToken.trim();
|
|
105944
106061
|
if (!githubToken) throw new Error("Copilot refresh requires a GitHub token.");
|
|
105945
|
-
log$
|
|
106062
|
+
log$29.debug(`Refreshing GitHub Copilot token (${reason})...`);
|
|
105946
106063
|
const copilotToken = await resolveCopilotApiToken({ githubToken });
|
|
105947
106064
|
authStorage.setRuntimeApiKey(model.provider, copilotToken.token);
|
|
105948
106065
|
copilotTokenState.expiresAt = copilotToken.expiresAt;
|
|
105949
106066
|
const remaining = copilotToken.expiresAt - Date.now();
|
|
105950
|
-
log$
|
|
106067
|
+
log$29.debug(`Copilot token refreshed; expires in ${Math.max(0, Math.floor(remaining / 1e3))}s.`);
|
|
105951
106068
|
})().catch((err) => {
|
|
105952
|
-
log$
|
|
106069
|
+
log$29.warn(`Copilot token refresh failed: ${describeUnknownError(err)}`);
|
|
105953
106070
|
throw err;
|
|
105954
106071
|
}).finally(() => {
|
|
105955
106072
|
copilotTokenState.refreshInFlight = void 0;
|
|
@@ -105959,7 +106076,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
105959
106076
|
const scheduleCopilotRefresh = () => {
|
|
105960
106077
|
if (!copilotTokenState || copilotRefreshCancelled) return;
|
|
105961
106078
|
if (!hasCopilotGithubToken()) {
|
|
105962
|
-
log$
|
|
106079
|
+
log$29.warn("Skipping Copilot refresh scheduling; GitHub token missing.");
|
|
105963
106080
|
return;
|
|
105964
106081
|
}
|
|
105965
106082
|
clearCopilotRefreshTimer();
|
|
@@ -106121,7 +106238,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106121
106238
|
while (true) {
|
|
106122
106239
|
if (runLoopIterations >= MAX_RUN_LOOP_ITERATIONS) {
|
|
106123
106240
|
const message = `Exceeded retry limit after ${runLoopIterations} attempts (max=${MAX_RUN_LOOP_ITERATIONS}).`;
|
|
106124
|
-
log$
|
|
106241
|
+
log$29.error(`[run-retry-limit] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} attempts=${runLoopIterations} maxAttempts=${MAX_RUN_LOOP_ITERATIONS}`);
|
|
106125
106242
|
logRunCompleted({
|
|
106126
106243
|
runId: params.runId,
|
|
106127
106244
|
sessionKey: params.sessionKey,
|
|
@@ -106285,21 +106402,21 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106285
106402
|
const errorText = contextOverflowError.text;
|
|
106286
106403
|
const overflowStorage = getConfiguredSessionStorageRuntime();
|
|
106287
106404
|
const msgCount = attempt.messagesSnapshot?.length ?? 0;
|
|
106288
|
-
log$
|
|
106405
|
+
log$29.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)}`);
|
|
106289
106406
|
const isCompactionFailure = isCompactionFailureError(errorText);
|
|
106290
106407
|
const hadAttemptLevelCompaction = attemptCompactionCount > 0;
|
|
106291
106408
|
const explicitOverflowCompactionAllowed = params.trigger !== "analysis" && !params.disablePluginHooks && !params.skipTranscriptSync;
|
|
106292
106409
|
if (explicitOverflowCompactionAllowed && !isCompactionFailure && hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
106293
106410
|
overflowCompactionAttempts++;
|
|
106294
|
-
log$
|
|
106411
|
+
log$29.warn(`context overflow persisted after in-attempt compaction (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); retrying prompt without additional compaction for ${provider}/${modelId}`);
|
|
106295
106412
|
continue;
|
|
106296
106413
|
}
|
|
106297
106414
|
if (explicitOverflowCompactionAllowed && !isCompactionFailure && !hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
106298
|
-
if (log$
|
|
106415
|
+
if (log$29.isEnabled("debug")) log$29.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=compact isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts + 1} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
106299
106416
|
overflowCompactionAttempts++;
|
|
106300
|
-
log$
|
|
106417
|
+
log$29.warn(`context overflow detected (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); attempting auto-compaction for ${provider}/${modelId}`);
|
|
106301
106418
|
const _overflowIsDb = (overflowStorage?.runtime?.backend ?? "fs-jsonl") !== "fs-jsonl";
|
|
106302
|
-
if (_overflowIsDb) log$
|
|
106419
|
+
if (_overflowIsDb) log$29.warn(`context overflow compaction skipped for DB backend session ${params.sessionId}; compact.ts does not yet support DB-backend sessions`);
|
|
106303
106420
|
const compactResult = _overflowIsDb ? {
|
|
106304
106421
|
compacted: false,
|
|
106305
106422
|
reason: "db-backend-not-supported"
|
|
@@ -106332,10 +106449,10 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106332
106449
|
});
|
|
106333
106450
|
if (compactResult.compacted) {
|
|
106334
106451
|
autoCompactionCount += 1;
|
|
106335
|
-
log$
|
|
106452
|
+
log$29.info(`auto-compaction succeeded for ${provider}/${modelId}; retrying prompt`);
|
|
106336
106453
|
continue;
|
|
106337
106454
|
}
|
|
106338
|
-
log$
|
|
106455
|
+
log$29.warn(`auto-compaction failed for ${provider}/${modelId}: ${compactResult.reason ?? "nothing to compact"}`);
|
|
106339
106456
|
}
|
|
106340
106457
|
if (!toolResultTruncationAttempted) {
|
|
106341
106458
|
const contextWindowTokens = ctxInfo.tokens;
|
|
@@ -106344,11 +106461,11 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106344
106461
|
contextWindowTokens
|
|
106345
106462
|
}) : false;
|
|
106346
106463
|
if (hasOversized) {
|
|
106347
|
-
if (log$
|
|
106464
|
+
if (log$29.isEnabled("debug")) log$29.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=truncate_tool_results isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=${hasOversized} attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
106348
106465
|
toolResultTruncationAttempted = true;
|
|
106349
|
-
if ((overflowStorage?.runtime?.backend ?? "fs-jsonl") !== "fs-jsonl") log$
|
|
106466
|
+
if ((overflowStorage?.runtime?.backend ?? "fs-jsonl") !== "fs-jsonl") log$29.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`);
|
|
106350
106467
|
else {
|
|
106351
|
-
log$
|
|
106468
|
+
log$29.warn(`[context-overflow-recovery] Attempting tool result truncation for ${provider}/${modelId} (contextWindow=${contextWindowTokens} tokens)`);
|
|
106352
106469
|
const truncResult = await truncateOversizedToolResultsInSession({
|
|
106353
106470
|
sessionFile: params.sessionFile,
|
|
106354
106471
|
contextWindowTokens,
|
|
@@ -106356,14 +106473,14 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106356
106473
|
sessionKey: params.sessionKey
|
|
106357
106474
|
});
|
|
106358
106475
|
if (truncResult.truncated) {
|
|
106359
|
-
log$
|
|
106476
|
+
log$29.info(`[context-overflow-recovery] Truncated ${truncResult.truncatedCount} tool result(s); retrying prompt`);
|
|
106360
106477
|
continue;
|
|
106361
106478
|
}
|
|
106362
|
-
log$
|
|
106479
|
+
log$29.warn(`[context-overflow-recovery] Tool result truncation did not help: ${truncResult.reason ?? "unknown"}`);
|
|
106363
106480
|
}
|
|
106364
|
-
} else if (log$
|
|
106481
|
+
} else if (log$29.isEnabled("debug")) log$29.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=give_up isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=${hasOversized} attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
106365
106482
|
}
|
|
106366
|
-
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS || toolResultTruncationAttempted) && log$
|
|
106483
|
+
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS || toolResultTruncationAttempted) && log$29.isEnabled("debug")) log$29.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=give_up isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
106367
106484
|
const kind = isCompactionFailure ? "compaction_failure" : "context_overflow";
|
|
106368
106485
|
logRunCompleted({
|
|
106369
106486
|
runId: params.runId,
|
|
@@ -106469,7 +106586,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106469
106586
|
attempted: attemptedThinking
|
|
106470
106587
|
});
|
|
106471
106588
|
if (fallbackThinking) {
|
|
106472
|
-
log$
|
|
106589
|
+
log$29.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
106473
106590
|
thinkLevel = fallbackThinking;
|
|
106474
106591
|
continue;
|
|
106475
106592
|
}
|
|
@@ -106487,7 +106604,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106487
106604
|
attempted: attemptedThinking
|
|
106488
106605
|
});
|
|
106489
106606
|
if (fallbackThinking && !aborted) {
|
|
106490
|
-
log$
|
|
106607
|
+
log$29.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
106491
106608
|
thinkLevel = fallbackThinking;
|
|
106492
106609
|
continue;
|
|
106493
106610
|
}
|
|
@@ -106508,7 +106625,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106508
106625
|
imageDimensionError.contentIndex !== void 0 ? `content=${imageDimensionError.contentIndex}` : null,
|
|
106509
106626
|
imageDimensionError.maxDimensionPx !== void 0 ? `limit=${imageDimensionError.maxDimensionPx}px` : null
|
|
106510
106627
|
].filter(Boolean).join(" ");
|
|
106511
|
-
log$
|
|
106628
|
+
log$29.warn(`Profile ${lastProfileId} rejected image payload${details ? ` (${details})` : ""}.`);
|
|
106512
106629
|
}
|
|
106513
106630
|
if (!aborted && failoverFailure || timedOut && !timedOutDuringCompaction) {
|
|
106514
106631
|
if (lastProfileId) {
|
|
@@ -106516,8 +106633,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106516
106633
|
profileId: lastProfileId,
|
|
106517
106634
|
reason: timedOut || assistantFailoverReason === "timeout" ? "timeout" : assistantFailoverReason ?? "unknown"
|
|
106518
106635
|
});
|
|
106519
|
-
if (timedOut && !isProbeSession) log$
|
|
106520
|
-
if (cloudCodeAssistFormatError) log$
|
|
106636
|
+
if (timedOut && !isProbeSession) log$29.warn(`Profile ${lastProfileId} timed out. Trying next account...`);
|
|
106637
|
+
if (cloudCodeAssistFormatError) log$29.warn(`Profile ${lastProfileId} hit Cloud Code Assist format error. Tool calls will be sanitized on retry.`);
|
|
106521
106638
|
}
|
|
106522
106639
|
if (await advanceAuthProfile()) continue;
|
|
106523
106640
|
if (fallbackConfigured) {
|
|
@@ -106562,7 +106679,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106562
106679
|
}, hookCtx);
|
|
106563
106680
|
if (transformResult?.assistantTexts) finalAssistantTexts = transformResult.assistantTexts;
|
|
106564
106681
|
} catch (err) {
|
|
106565
|
-
log$
|
|
106682
|
+
log$29.warn(`transform_llm_output hook failed: ${String(err)}`);
|
|
106566
106683
|
}
|
|
106567
106684
|
const payloads = buildEmbeddedRunPayloads({
|
|
106568
106685
|
assistantTexts: finalAssistantTexts,
|
|
@@ -106613,7 +106730,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106613
106730
|
durationMs: Date.now() - started,
|
|
106614
106731
|
exitStatus: aborted || timedOut ? "error" : void 0
|
|
106615
106732
|
});
|
|
106616
|
-
log$
|
|
106733
|
+
log$29.debug(`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`);
|
|
106617
106734
|
if (lastProfileId) {
|
|
106618
106735
|
await markAuthProfileGood({
|
|
106619
106736
|
store: authStore,
|
|
@@ -106650,7 +106767,6 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106650
106767
|
}
|
|
106651
106768
|
} finally {
|
|
106652
106769
|
stopCopilotRefreshTimer();
|
|
106653
|
-
if (!params.skipCwdChange) process.chdir(prevCwd);
|
|
106654
106770
|
}
|
|
106655
106771
|
}));
|
|
106656
106772
|
}
|