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
|
@@ -11,7 +11,7 @@ import { c as resolveSessionFilePath, f as resolveSessionTranscriptsDirForAgent,
|
|
|
11
11
|
import { n as resolveConversationLabel, r as normalizeChatType } from "./conversation-label-CrORLc0j.js";
|
|
12
12
|
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-t1FqsCS3.js";
|
|
13
13
|
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-CoH2cLQP.js";
|
|
14
|
-
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-
|
|
14
|
+
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-BB0xkzVk.js";
|
|
15
15
|
import { a as stripSilentToken, i as isSilentReplyText, n as SILENT_REPLY_TOKEN, r as isSilentReplyPrefixText, t as HEARTBEAT_TOKEN } from "./tokens-CAPNeQwS.js";
|
|
16
16
|
import { n as generateSecureUuid, t as generateSecureToken } from "./secure-random-CXrBi7Jq.js";
|
|
17
17
|
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-CY-6tL8W.js";
|
|
@@ -2966,7 +2966,7 @@ async function applyBootstrapHookOverrides(params) {
|
|
|
2966
2966
|
|
|
2967
2967
|
//#endregion
|
|
2968
2968
|
//#region src/agents/system-prompt-config.ts
|
|
2969
|
-
const log$
|
|
2969
|
+
const log$40 = createSubsystemLogger("agents/system-prompt-config");
|
|
2970
2970
|
const DEFAULT_PROMPT_SOURCE_MAX_CHARS = 2e4;
|
|
2971
2971
|
const MAX_PROMPT_SOURCE_FILE_BYTES = 512 * 1024;
|
|
2972
2972
|
const MAX_PROMPT_SOURCE_FILE_BYTES_HARD = 8 * 1024 * 1024;
|
|
@@ -3152,7 +3152,7 @@ async function readPromptSourceFile(params) {
|
|
|
3152
3152
|
if (!opened.ok) {
|
|
3153
3153
|
promptSourceCache.delete(absolutePath);
|
|
3154
3154
|
if (params.optional) {
|
|
3155
|
-
if (opened.reason !== "path") log$
|
|
3155
|
+
if (opened.reason !== "path") log$40.warn("skipping optional systemPrompt source: present but unusable", {
|
|
3156
3156
|
file: params.file,
|
|
3157
3157
|
reason: opened.reason
|
|
3158
3158
|
});
|
|
@@ -3176,7 +3176,7 @@ async function readPromptSourceFile(params) {
|
|
|
3176
3176
|
} catch (error) {
|
|
3177
3177
|
promptSourceCache.delete(opened.path);
|
|
3178
3178
|
if (params.optional) {
|
|
3179
|
-
log$
|
|
3179
|
+
log$40.warn("skipping optional systemPrompt source after read error", {
|
|
3180
3180
|
file: params.file,
|
|
3181
3181
|
error
|
|
3182
3182
|
});
|
|
@@ -3283,7 +3283,7 @@ async function resolveSystemPromptConfigForRun(params) {
|
|
|
3283
3283
|
|
|
3284
3284
|
//#endregion
|
|
3285
3285
|
//#region src/agents/workspace-lanes.ts
|
|
3286
|
-
const log$
|
|
3286
|
+
const log$39 = createSubsystemLogger("agents/workspace-lanes");
|
|
3287
3287
|
const DEFAULT_ROOT_TEMPLATE = "~/.openclaw/agents/{agentId}/lanes/{laneId}/workspace";
|
|
3288
3288
|
const SUPPORTED_STRATEGY = "hybrid";
|
|
3289
3289
|
const DEFAULT_COPIED_ON_CREATE_FILES = ["USER.md", "BOOTSTRAP.md"];
|
|
@@ -3436,7 +3436,7 @@ function resolveWorkspaceLane(params) {
|
|
|
3436
3436
|
actor: params.actor
|
|
3437
3437
|
});
|
|
3438
3438
|
if (!keyResult.ok) {
|
|
3439
|
-
log$
|
|
3439
|
+
log$39.warn("workspace lane key denied", {
|
|
3440
3440
|
agentId,
|
|
3441
3441
|
laneKeySource: keyResult.laneKeySource,
|
|
3442
3442
|
reason: keyResult.reason
|
|
@@ -3457,7 +3457,7 @@ function resolveWorkspaceLane(params) {
|
|
|
3457
3457
|
laneId: key.laneId
|
|
3458
3458
|
});
|
|
3459
3459
|
if (!rootTemplate.ok) {
|
|
3460
|
-
log$
|
|
3460
|
+
log$39.warn("workspace lane root template denied", {
|
|
3461
3461
|
agentId,
|
|
3462
3462
|
laneId: key.laneId,
|
|
3463
3463
|
laneKeySource: key.laneKeySource,
|
|
@@ -3475,7 +3475,7 @@ function resolveWorkspaceLane(params) {
|
|
|
3475
3475
|
}
|
|
3476
3476
|
const effectiveWorkspaceDir = rootTemplate.effectiveWorkspaceDir;
|
|
3477
3477
|
if (strategy !== SUPPORTED_STRATEGY) {
|
|
3478
|
-
log$
|
|
3478
|
+
log$39.warn("workspace lane strategy denied", {
|
|
3479
3479
|
agentId,
|
|
3480
3480
|
strategy
|
|
3481
3481
|
});
|
|
@@ -3570,7 +3570,7 @@ async function resolveWorkspaceLaneForTurn(params) {
|
|
|
3570
3570
|
if ((config?.create ?? "on-first-message") !== "on-first-message") {
|
|
3571
3571
|
const pathState = await getExistingPathState(resolution.effectiveWorkspaceDir);
|
|
3572
3572
|
if (pathState !== "directory") {
|
|
3573
|
-
log$
|
|
3573
|
+
log$39.warn("workspace lane manual creation denied", {
|
|
3574
3574
|
agentId: resolution.agentId,
|
|
3575
3575
|
laneId: resolution.laneId,
|
|
3576
3576
|
laneKeySource: resolution.laneKeySource,
|
|
@@ -3596,7 +3596,7 @@ async function resolveWorkspaceLaneForTurn(params) {
|
|
|
3596
3596
|
targetRoot: resolution.effectiveWorkspaceDir,
|
|
3597
3597
|
relativePath: file
|
|
3598
3598
|
});
|
|
3599
|
-
if (decision === "copied" || !existed) log$
|
|
3599
|
+
if (decision === "copied" || !existed) log$39.info("workspace lane seed file decision", {
|
|
3600
3600
|
agentId: resolution.agentId,
|
|
3601
3601
|
laneId: resolution.laneId,
|
|
3602
3602
|
laneKeySource: resolution.laneKeySource,
|
|
@@ -3605,7 +3605,7 @@ async function resolveWorkspaceLaneForTurn(params) {
|
|
|
3605
3605
|
});
|
|
3606
3606
|
}
|
|
3607
3607
|
const created = !existed;
|
|
3608
|
-
if (created) log$
|
|
3608
|
+
if (created) log$39.info("workspace lane created", {
|
|
3609
3609
|
agentId: resolution.agentId,
|
|
3610
3610
|
laneId: resolution.laneId,
|
|
3611
3611
|
laneKeySource: resolution.laneKeySource
|
|
@@ -4500,7 +4500,7 @@ function resolveExecSafeBinRuntimePolicy(params) {
|
|
|
4500
4500
|
|
|
4501
4501
|
//#endregion
|
|
4502
4502
|
//#region src/plugins/activation-migration.ts
|
|
4503
|
-
const log$
|
|
4503
|
+
const log$38 = createSubsystemLogger("plugins/activation-migration");
|
|
4504
4504
|
/**
|
|
4505
4505
|
* One-time migration from the presence-implies-load model to explicit-enable (ADR 0016).
|
|
4506
4506
|
* Runs synchronously inside loadOpenClawPlugins, before resolveEnableState is applied.
|
|
@@ -4542,7 +4542,7 @@ function runActivationMigrationIfNeeded(config, pluginRecords) {
|
|
|
4542
4542
|
activationMigrationVersion: 1
|
|
4543
4543
|
}
|
|
4544
4544
|
};
|
|
4545
|
-
if (toEnable.size > 0) log$
|
|
4545
|
+
if (toEnable.size > 0) log$38.info(`activation migration v1: auto-enabled ${toEnable.size} previously-active plugin(s)`, { ids: [...toEnable] });
|
|
4546
4546
|
return next;
|
|
4547
4547
|
}
|
|
4548
4548
|
|
|
@@ -4665,7 +4665,7 @@ function estimateUsageCost(params) {
|
|
|
4665
4665
|
|
|
4666
4666
|
//#endregion
|
|
4667
4667
|
//#region src/plugins/runtime/runtime-analysis-direct.ts
|
|
4668
|
-
const log$
|
|
4668
|
+
const log$37 = createSubsystemLogger("plugins/runtime/analysis");
|
|
4669
4669
|
const NEUTRAL_ANALYSIS_SYSTEM_PROMPT = "You are running a focused internal analysis for a WednesdayAI extension. Return only the requested result.";
|
|
4670
4670
|
function isJsonResponseFormat(params) {
|
|
4671
4671
|
return params.responseFormat === "json" || typeof params.responseFormat === "object" && params.responseFormat.type === "json_schema";
|
|
@@ -4725,8 +4725,8 @@ async function runDirectAnalysis(req, overrides) {
|
|
|
4725
4725
|
elapsedMs: full.elapsedMs,
|
|
4726
4726
|
error: full.error
|
|
4727
4727
|
};
|
|
4728
|
-
if (full.status === "ok" || full.status === "empty") log$
|
|
4729
|
-
else log$
|
|
4728
|
+
if (full.status === "ok" || full.status === "empty") log$37.info("direct analysis run", logFields);
|
|
4729
|
+
else log$37.warn("direct analysis run failed", logFields);
|
|
4730
4730
|
return full;
|
|
4731
4731
|
};
|
|
4732
4732
|
const controller = new AbortController();
|
|
@@ -4865,7 +4865,7 @@ async function runDirectAnalysis(req, overrides) {
|
|
|
4865
4865
|
|
|
4866
4866
|
//#endregion
|
|
4867
4867
|
//#region src/plugins/runtime/runtime-analysis.ts
|
|
4868
|
-
const log$
|
|
4868
|
+
const log$36 = createSubsystemLogger("plugins/runtime/analysis");
|
|
4869
4869
|
const DEFAULT_RUN_TIMEOUT_MS = 15e3;
|
|
4870
4870
|
const MIN_TIMEOUT_MS = 250;
|
|
4871
4871
|
const MAX_TIMEOUT_MS = 12e4;
|
|
@@ -4906,7 +4906,7 @@ function finalizeAnalysisResult(result, cfg, transport) {
|
|
|
4906
4906
|
const { costUsd: _untrusted, ...rest } = result;
|
|
4907
4907
|
let usageState = result.usageState;
|
|
4908
4908
|
if (usageState === void 0) {
|
|
4909
|
-
log$
|
|
4909
|
+
log$36.warn("analysis result missing usageState; treating the call as spent", {
|
|
4910
4910
|
transport,
|
|
4911
4911
|
status: result.status,
|
|
4912
4912
|
provider: result.provider,
|
|
@@ -5335,7 +5335,7 @@ async function executeAnalysisTransport(params, deps, fallbackTimeoutMs, lane, c
|
|
|
5335
5335
|
if (err instanceof CommandLaneAbortedError && !providerDispatched) return queuedCancellation();
|
|
5336
5336
|
const message = err instanceof Error ? err.message : String(err);
|
|
5337
5337
|
const status = /timed?\s*out|timeout/i.test(message) ? "timeout" : "error";
|
|
5338
|
-
log$
|
|
5338
|
+
log$36.warn("analysis run failed", {
|
|
5339
5339
|
purpose: params.purpose,
|
|
5340
5340
|
pluginId: params.pluginId,
|
|
5341
5341
|
status,
|
|
@@ -5396,7 +5396,7 @@ function createRuntimeAnalysis(deps = {}, concurrencyConfig) {
|
|
|
5396
5396
|
try {
|
|
5397
5397
|
await onComplete(result);
|
|
5398
5398
|
} catch (err) {
|
|
5399
|
-
log$
|
|
5399
|
+
log$36.warn("analysis enqueue completion failed", {
|
|
5400
5400
|
purpose: params.purpose,
|
|
5401
5401
|
error: err instanceof Error ? err.message : String(err)
|
|
5402
5402
|
});
|
|
@@ -5452,7 +5452,7 @@ function createRuntimeAnalysis(deps = {}, concurrencyConfig) {
|
|
|
5452
5452
|
(async () => {
|
|
5453
5453
|
try {
|
|
5454
5454
|
const result = await executeAnalysis(job.params, mergedDeps, DEFAULT_RUN_TIMEOUT_MS, CommandLane.Analysis);
|
|
5455
|
-
log$
|
|
5455
|
+
log$36.info("analysis run completed", {
|
|
5456
5456
|
pluginId: job.params.pluginId,
|
|
5457
5457
|
purpose: job.params.purpose,
|
|
5458
5458
|
durationMs: result.elapsedMs,
|
|
@@ -5501,7 +5501,7 @@ function createRuntimeAnalysis(deps = {}, concurrencyConfig) {
|
|
|
5501
5501
|
const parallelSlot = activeParallelRuns;
|
|
5502
5502
|
try {
|
|
5503
5503
|
const result = await executeAnalysis(runParams, mergedDeps, DEFAULT_RUN_TIMEOUT_MS, CommandLane.Analysis);
|
|
5504
|
-
log$
|
|
5504
|
+
log$36.info("analysis run completed", {
|
|
5505
5505
|
pluginId: runParams.pluginId,
|
|
5506
5506
|
purpose: params.purpose,
|
|
5507
5507
|
durationMs: result.elapsedMs,
|
|
@@ -5539,7 +5539,7 @@ function createRuntimeAnalysis(deps = {}, concurrencyConfig) {
|
|
|
5539
5539
|
});
|
|
5540
5540
|
}
|
|
5541
5541
|
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";
|
|
5542
|
-
log$
|
|
5542
|
+
log$36.info("analysis run rejected", {
|
|
5543
5543
|
pluginId: runParams.pluginId,
|
|
5544
5544
|
purpose: params.purpose,
|
|
5545
5545
|
error: "analysis concurrency limit exceeded",
|
|
@@ -6606,6 +6606,60 @@ async function withAcpRuntimeErrorBoundary(params) {
|
|
|
6606
6606
|
}
|
|
6607
6607
|
}
|
|
6608
6608
|
|
|
6609
|
+
//#endregion
|
|
6610
|
+
//#region src/acp/runtime/registry.ts
|
|
6611
|
+
const ACP_RUNTIME_REGISTRY_STATE_KEY = Symbol.for("openclaw.acpRuntimeRegistryState");
|
|
6612
|
+
function createAcpRuntimeRegistryGlobalState() {
|
|
6613
|
+
return { backendsById: /* @__PURE__ */ new Map() };
|
|
6614
|
+
}
|
|
6615
|
+
function resolveAcpRuntimeRegistryGlobalState() {
|
|
6616
|
+
const runtimeGlobal = globalThis;
|
|
6617
|
+
if (!runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY]) runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY] = createAcpRuntimeRegistryGlobalState();
|
|
6618
|
+
return runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY];
|
|
6619
|
+
}
|
|
6620
|
+
const ACP_BACKENDS_BY_ID = resolveAcpRuntimeRegistryGlobalState().backendsById;
|
|
6621
|
+
function normalizeBackendId(id) {
|
|
6622
|
+
return id?.trim().toLowerCase() || "";
|
|
6623
|
+
}
|
|
6624
|
+
function isBackendHealthy(backend) {
|
|
6625
|
+
if (!backend.healthy) return true;
|
|
6626
|
+
try {
|
|
6627
|
+
return backend.healthy();
|
|
6628
|
+
} catch {
|
|
6629
|
+
return false;
|
|
6630
|
+
}
|
|
6631
|
+
}
|
|
6632
|
+
function getAcpRuntimeBackend(id) {
|
|
6633
|
+
const normalized = normalizeBackendId(id);
|
|
6634
|
+
if (normalized) return ACP_BACKENDS_BY_ID.get(normalized) ?? null;
|
|
6635
|
+
if (ACP_BACKENDS_BY_ID.size === 0) return null;
|
|
6636
|
+
for (const backend of ACP_BACKENDS_BY_ID.values()) if (isBackendHealthy(backend)) return backend;
|
|
6637
|
+
return ACP_BACKENDS_BY_ID.values().next().value ?? null;
|
|
6638
|
+
}
|
|
6639
|
+
function requireAcpRuntimeBackend(id) {
|
|
6640
|
+
const normalized = normalizeBackendId(id);
|
|
6641
|
+
const backend = getAcpRuntimeBackend(normalized || void 0);
|
|
6642
|
+
if (!backend) throw new AcpRuntimeError("ACP_BACKEND_MISSING", "ACP runtime backend is not configured. Install and enable the acpx runtime plugin.");
|
|
6643
|
+
if (!isBackendHealthy(backend)) throw new AcpRuntimeError("ACP_BACKEND_UNAVAILABLE", "ACP runtime backend is currently unavailable. Try again in a moment.");
|
|
6644
|
+
if (normalized && backend.id !== normalized) throw new AcpRuntimeError("ACP_BACKEND_MISSING", `ACP runtime backend "${normalized}" is not registered.`);
|
|
6645
|
+
return backend;
|
|
6646
|
+
}
|
|
6647
|
+
async function waitForAcpRuntimeBackendHealthy(params) {
|
|
6648
|
+
const normalized = normalizeBackendId(params.id);
|
|
6649
|
+
const pollMs = params.pollMs ?? 250;
|
|
6650
|
+
const deadline = Date.now() + params.timeoutMs;
|
|
6651
|
+
for (;;) {
|
|
6652
|
+
const backend = getAcpRuntimeBackend(normalized || void 0);
|
|
6653
|
+
if (!backend) return false;
|
|
6654
|
+
if (isBackendHealthy(backend)) return true;
|
|
6655
|
+
const remainingMs = deadline - Date.now();
|
|
6656
|
+
if (remainingMs <= 0) return false;
|
|
6657
|
+
await new Promise((resolve) => {
|
|
6658
|
+
setTimeout(resolve, Math.min(pollMs, remainingMs)).unref();
|
|
6659
|
+
});
|
|
6660
|
+
}
|
|
6661
|
+
}
|
|
6662
|
+
|
|
6609
6663
|
//#endregion
|
|
6610
6664
|
//#region src/acp/runtime/session-identity.ts
|
|
6611
6665
|
function normalizeText$2(value) {
|
|
@@ -7118,45 +7172,6 @@ async function applyManagerRuntimeControls(params) {
|
|
|
7118
7172
|
if (cached) cached.appliedControlSignature = signature;
|
|
7119
7173
|
}
|
|
7120
7174
|
|
|
7121
|
-
//#endregion
|
|
7122
|
-
//#region src/acp/runtime/registry.ts
|
|
7123
|
-
const ACP_RUNTIME_REGISTRY_STATE_KEY = Symbol.for("openclaw.acpRuntimeRegistryState");
|
|
7124
|
-
function createAcpRuntimeRegistryGlobalState() {
|
|
7125
|
-
return { backendsById: /* @__PURE__ */ new Map() };
|
|
7126
|
-
}
|
|
7127
|
-
function resolveAcpRuntimeRegistryGlobalState() {
|
|
7128
|
-
const runtimeGlobal = globalThis;
|
|
7129
|
-
if (!runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY]) runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY] = createAcpRuntimeRegistryGlobalState();
|
|
7130
|
-
return runtimeGlobal[ACP_RUNTIME_REGISTRY_STATE_KEY];
|
|
7131
|
-
}
|
|
7132
|
-
const ACP_BACKENDS_BY_ID = resolveAcpRuntimeRegistryGlobalState().backendsById;
|
|
7133
|
-
function normalizeBackendId(id) {
|
|
7134
|
-
return id?.trim().toLowerCase() || "";
|
|
7135
|
-
}
|
|
7136
|
-
function isBackendHealthy(backend) {
|
|
7137
|
-
if (!backend.healthy) return true;
|
|
7138
|
-
try {
|
|
7139
|
-
return backend.healthy();
|
|
7140
|
-
} catch {
|
|
7141
|
-
return false;
|
|
7142
|
-
}
|
|
7143
|
-
}
|
|
7144
|
-
function getAcpRuntimeBackend(id) {
|
|
7145
|
-
const normalized = normalizeBackendId(id);
|
|
7146
|
-
if (normalized) return ACP_BACKENDS_BY_ID.get(normalized) ?? null;
|
|
7147
|
-
if (ACP_BACKENDS_BY_ID.size === 0) return null;
|
|
7148
|
-
for (const backend of ACP_BACKENDS_BY_ID.values()) if (isBackendHealthy(backend)) return backend;
|
|
7149
|
-
return ACP_BACKENDS_BY_ID.values().next().value ?? null;
|
|
7150
|
-
}
|
|
7151
|
-
function requireAcpRuntimeBackend(id) {
|
|
7152
|
-
const normalized = normalizeBackendId(id);
|
|
7153
|
-
const backend = getAcpRuntimeBackend(normalized || void 0);
|
|
7154
|
-
if (!backend) throw new AcpRuntimeError("ACP_BACKEND_MISSING", "ACP runtime backend is not configured. Install and enable the acpx runtime plugin.");
|
|
7155
|
-
if (!isBackendHealthy(backend)) throw new AcpRuntimeError("ACP_BACKEND_UNAVAILABLE", "ACP runtime backend is currently unavailable. Try again in a moment.");
|
|
7156
|
-
if (normalized && backend.id !== normalized) throw new AcpRuntimeError("ACP_BACKEND_MISSING", `ACP runtime backend "${normalized}" is not registered.`);
|
|
7157
|
-
return backend;
|
|
7158
|
-
}
|
|
7159
|
-
|
|
7160
7175
|
//#endregion
|
|
7161
7176
|
//#region src/agents/session-dirs.ts
|
|
7162
7177
|
async function resolveAgentSessionDirs(stateDir) {
|
|
@@ -7357,6 +7372,9 @@ var SessionActorQueue = class {
|
|
|
7357
7372
|
|
|
7358
7373
|
//#endregion
|
|
7359
7374
|
//#region src/acp/control-plane/manager.core.ts
|
|
7375
|
+
const log$35 = createSubsystemLogger("acp/manager");
|
|
7376
|
+
const STARTUP_RECONCILE_BACKEND_WAIT_MS = 3e4;
|
|
7377
|
+
const STARTUP_RECONCILE_BACKEND_POLL_MS = 250;
|
|
7360
7378
|
var AcpSessionManager = class {
|
|
7361
7379
|
constructor(deps = DEFAULT_DEPS) {
|
|
7362
7380
|
this.deps = deps;
|
|
@@ -7434,34 +7452,54 @@ var AcpSessionManager = class {
|
|
|
7434
7452
|
failed: failed + 1
|
|
7435
7453
|
};
|
|
7436
7454
|
}
|
|
7455
|
+
const logFailure = (sessionKey, acpError) => {
|
|
7456
|
+
const redactedKey = redactIdentifier(sessionKey);
|
|
7457
|
+
log$35.warn(`startup identity reconcile failed for ${redactedKey}: code=${acpError.code} ${acpError.message.replaceAll(sessionKey, redactedKey)}`);
|
|
7458
|
+
};
|
|
7459
|
+
const toReconcileError = (error) => toAcpRuntimeError({
|
|
7460
|
+
error,
|
|
7461
|
+
fallbackCode: "ACP_SESSION_INIT_FAILED",
|
|
7462
|
+
fallbackMessage: "ACP startup identity reconcile failed."
|
|
7463
|
+
});
|
|
7464
|
+
const deferred = [];
|
|
7437
7465
|
for (const session of acpSessions) {
|
|
7438
7466
|
if (!session.acp || !session.sessionKey) continue;
|
|
7439
7467
|
if (!isSessionIdentityPending(resolveSessionIdentityFromMeta(session.acp))) continue;
|
|
7440
7468
|
checked += 1;
|
|
7441
7469
|
try {
|
|
7442
|
-
if (await this.
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
if (resolution.kind !== "ready") return false;
|
|
7448
|
-
const { runtime, handle, meta } = await this.ensureRuntimeHandle({
|
|
7449
|
-
cfg: params.cfg,
|
|
7470
|
+
if (await this.reconcileOneSessionIdentity(params.cfg, session.sessionKey)) resolved += 1;
|
|
7471
|
+
} catch (error) {
|
|
7472
|
+
const acpError = toReconcileError(error);
|
|
7473
|
+
if (acpError.code === "ACP_BACKEND_UNAVAILABLE") {
|
|
7474
|
+
deferred.push({
|
|
7450
7475
|
sessionKey: session.sessionKey,
|
|
7451
|
-
|
|
7476
|
+
backend: (session.acp.backend || params.cfg.acp?.backend || "").trim()
|
|
7452
7477
|
});
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
sessionKey: session.sessionKey,
|
|
7456
|
-
runtime,
|
|
7457
|
-
handle,
|
|
7458
|
-
meta,
|
|
7459
|
-
failOnStatusError: false
|
|
7460
|
-
})).meta));
|
|
7461
|
-
})) resolved += 1;
|
|
7462
|
-
} catch (error) {
|
|
7478
|
+
continue;
|
|
7479
|
+
}
|
|
7463
7480
|
failed += 1;
|
|
7464
|
-
|
|
7481
|
+
logFailure(session.sessionKey, acpError);
|
|
7482
|
+
}
|
|
7483
|
+
}
|
|
7484
|
+
if (deferred.length > 0) {
|
|
7485
|
+
const backendIds = [...new Set(deferred.map(({ backend }) => backend))];
|
|
7486
|
+
const healthyByBackend = new Map(await Promise.all(backendIds.map(async (backend) => [backend, await waitForAcpRuntimeBackendHealthy({
|
|
7487
|
+
id: backend || void 0,
|
|
7488
|
+
timeoutMs: params.backendWaitMs ?? STARTUP_RECONCILE_BACKEND_WAIT_MS,
|
|
7489
|
+
pollMs: params.backendPollMs ?? STARTUP_RECONCILE_BACKEND_POLL_MS
|
|
7490
|
+
})])));
|
|
7491
|
+
for (const { sessionKey, backend } of deferred) {
|
|
7492
|
+
if (!healthyByBackend.get(backend)) {
|
|
7493
|
+
failed += 1;
|
|
7494
|
+
logFailure(sessionKey, new AcpRuntimeError("ACP_BACKEND_UNAVAILABLE", `ACP runtime backend${backend ? ` "${backend}"` : ""} did not become healthy before the startup wait expired.`));
|
|
7495
|
+
continue;
|
|
7496
|
+
}
|
|
7497
|
+
try {
|
|
7498
|
+
if (await this.reconcileOneSessionIdentity(params.cfg, sessionKey)) resolved += 1;
|
|
7499
|
+
} catch (error) {
|
|
7500
|
+
failed += 1;
|
|
7501
|
+
logFailure(sessionKey, toReconcileError(error));
|
|
7502
|
+
}
|
|
7465
7503
|
}
|
|
7466
7504
|
}
|
|
7467
7505
|
return {
|
|
@@ -7470,6 +7508,37 @@ var AcpSessionManager = class {
|
|
|
7470
7508
|
failed
|
|
7471
7509
|
};
|
|
7472
7510
|
}
|
|
7511
|
+
async reconcileOneSessionIdentity(cfg, sessionKey) {
|
|
7512
|
+
return await this.withSessionActor(sessionKey, async () => {
|
|
7513
|
+
const resolution = this.resolveSession({
|
|
7514
|
+
cfg,
|
|
7515
|
+
sessionKey
|
|
7516
|
+
});
|
|
7517
|
+
if (resolution.kind !== "ready") return false;
|
|
7518
|
+
const { runtime, handle, meta } = await this.ensureRuntimeHandle({
|
|
7519
|
+
cfg,
|
|
7520
|
+
sessionKey,
|
|
7521
|
+
meta: resolution.meta
|
|
7522
|
+
});
|
|
7523
|
+
try {
|
|
7524
|
+
return !isSessionIdentityPending(resolveSessionIdentityFromMeta((await this.reconcileRuntimeSessionIdentifiers({
|
|
7525
|
+
cfg,
|
|
7526
|
+
sessionKey,
|
|
7527
|
+
runtime,
|
|
7528
|
+
handle,
|
|
7529
|
+
meta,
|
|
7530
|
+
failOnStatusError: true
|
|
7531
|
+
})).meta));
|
|
7532
|
+
} catch (error) {
|
|
7533
|
+
const stored = this.deps.readSessionEntry({
|
|
7534
|
+
cfg,
|
|
7535
|
+
sessionKey
|
|
7536
|
+
})?.acp;
|
|
7537
|
+
if (stored && !isSessionIdentityPending(resolveSessionIdentityFromMeta(stored))) return true;
|
|
7538
|
+
throw error;
|
|
7539
|
+
}
|
|
7540
|
+
});
|
|
7541
|
+
}
|
|
7473
7542
|
async initializeSession(input) {
|
|
7474
7543
|
const sessionKey = normalizeSessionKey$1(input.sessionKey);
|
|
7475
7544
|
if (!sessionKey) throw new AcpRuntimeError("ACP_SESSION_INIT_FAILED", "ACP session key is required.");
|
|
@@ -18065,7 +18134,7 @@ function stopSweeper$1() {
|
|
|
18065
18134
|
|
|
18066
18135
|
//#endregion
|
|
18067
18136
|
//#region src/infra/exec-approvals.ts
|
|
18068
|
-
const log$
|
|
18137
|
+
const log$34 = createSubsystemLogger("infra/exec-approvals");
|
|
18069
18138
|
const APPROVALS_FILE = join(process.env.HOME ?? "/tmp", ".openclaw", "exec-approvals.json");
|
|
18070
18139
|
const DEFAULT_SECURITY = "deny";
|
|
18071
18140
|
const DEFAULT_ASK = "on-miss";
|
|
@@ -19315,7 +19384,7 @@ function createRunRegistry(options) {
|
|
|
19315
19384
|
|
|
19316
19385
|
//#endregion
|
|
19317
19386
|
//#region src/process/supervisor/supervisor.ts
|
|
19318
|
-
const log$
|
|
19387
|
+
const log$33 = createSubsystemLogger("process/supervisor");
|
|
19319
19388
|
function clampTimeout(value) {
|
|
19320
19389
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return;
|
|
19321
19390
|
return Math.max(1, Math.floor(value));
|
|
@@ -19501,7 +19570,7 @@ function createProcessSupervisor() {
|
|
|
19501
19570
|
exitCode: null,
|
|
19502
19571
|
exitSignal: null
|
|
19503
19572
|
});
|
|
19504
|
-
log$
|
|
19573
|
+
log$33.warn(`spawn failed: runId=${runId} reason=${String(err)}`);
|
|
19505
19574
|
throw err;
|
|
19506
19575
|
}
|
|
19507
19576
|
};
|
|
@@ -20528,7 +20597,7 @@ function normalizeSystemRunApprovalPlan(value) {
|
|
|
20528
20597
|
|
|
20529
20598
|
//#endregion
|
|
20530
20599
|
//#region src/infra/system-run-command.ts
|
|
20531
|
-
const log$
|
|
20600
|
+
const log$32 = createSubsystemLogger("infra/system-run-command");
|
|
20532
20601
|
function formatExecCommand(argv) {
|
|
20533
20602
|
return argv.map((arg) => {
|
|
20534
20603
|
if (arg.length === 0) return "\"\"";
|
|
@@ -25571,7 +25640,7 @@ const FIELD_LABELS = {
|
|
|
25571
25640
|
|
|
25572
25641
|
//#endregion
|
|
25573
25642
|
//#region src/config/schema.hints.ts
|
|
25574
|
-
const log$
|
|
25643
|
+
const log$31 = createSubsystemLogger("config/schema");
|
|
25575
25644
|
const NORMALIZED_SENSITIVE_KEY_WHITELIST_SUFFIXES = [
|
|
25576
25645
|
"maxtokens",
|
|
25577
25646
|
"maxoutputtokens",
|
|
@@ -25612,7 +25681,7 @@ function isSensitiveConfigPath(path) {
|
|
|
25612
25681
|
|
|
25613
25682
|
//#endregion
|
|
25614
25683
|
//#region src/config/redact-snapshot.ts
|
|
25615
|
-
const log$
|
|
25684
|
+
const log$30 = createSubsystemLogger("config/redaction");
|
|
25616
25685
|
const ENV_VAR_PLACEHOLDER_PATTERN = /^\$\{[^}]*\}$/;
|
|
25617
25686
|
function isSensitivePath(path) {
|
|
25618
25687
|
if (path.endsWith("[]")) return isSensitiveConfigPath(path.slice(0, -2));
|
|
@@ -32069,7 +32138,7 @@ async function handleSubagentsLogAction(ctx) {
|
|
|
32069
32138
|
|
|
32070
32139
|
//#endregion
|
|
32071
32140
|
//#region src/agents/pi-embedded-runner/logger.ts
|
|
32072
|
-
const log$
|
|
32141
|
+
const log$29 = createSubsystemLogger("agent/embedded");
|
|
32073
32142
|
|
|
32074
32143
|
//#endregion
|
|
32075
32144
|
//#region src/agents/pi-embedded-runner/run-sender-identity.ts
|
|
@@ -32114,7 +32183,7 @@ function resolveRunSenderIdentity(params) {
|
|
|
32114
32183
|
candidate: params.inheritedCanonicalIdentity
|
|
32115
32184
|
});
|
|
32116
32185
|
if (inherited) {
|
|
32117
|
-
log$
|
|
32186
|
+
log$29.info("runtime identity injected", {
|
|
32118
32187
|
identitySource: "parent-session",
|
|
32119
32188
|
canonicalIdentity: inherited,
|
|
32120
32189
|
trigger: params.trigger,
|
|
@@ -32133,7 +32202,7 @@ function resolveRunSenderIdentity(params) {
|
|
|
32133
32202
|
candidate: params.configuredIdentity
|
|
32134
32203
|
});
|
|
32135
32204
|
if (configured) {
|
|
32136
|
-
log$
|
|
32205
|
+
log$29.info("runtime identity injected", {
|
|
32137
32206
|
identitySource: "job-config",
|
|
32138
32207
|
canonicalIdentity: configured,
|
|
32139
32208
|
trigger: params.trigger,
|
|
@@ -38202,7 +38271,7 @@ const REMINDER_CONTEXT_MESSAGES_MAX = 10;
|
|
|
38202
38271
|
const REMINDER_CONTEXT_PER_MESSAGE_MAX = 220;
|
|
38203
38272
|
const REMINDER_CONTEXT_TOTAL_MAX = 700;
|
|
38204
38273
|
const REMINDER_CONTEXT_MARKER = "\n\nRecent context:\n";
|
|
38205
|
-
const log$
|
|
38274
|
+
const log$28 = createSubsystemLogger("cron-tool");
|
|
38206
38275
|
const AGENT_FORBIDDEN_JOB_FIELDS = new Set(["identity", "state"]);
|
|
38207
38276
|
const JOB_KEYS = new Set([
|
|
38208
38277
|
"name",
|
|
@@ -38338,7 +38407,7 @@ async function buildReminderContextLines(params) {
|
|
|
38338
38407
|
}
|
|
38339
38408
|
return lines;
|
|
38340
38409
|
} catch (err) {
|
|
38341
|
-
log$
|
|
38410
|
+
log$28.warn("reminder context fetch failed", { error: err });
|
|
38342
38411
|
return ["- (context unavailable: gateway unreachable)"];
|
|
38343
38412
|
}
|
|
38344
38413
|
}
|
|
@@ -38894,7 +38963,7 @@ function assertGatewayToolActionAllowed(params) {
|
|
|
38894
38963
|
|
|
38895
38964
|
//#endregion
|
|
38896
38965
|
//#region src/agents/tools/gateway-tool.ts
|
|
38897
|
-
const log$
|
|
38966
|
+
const log$27 = createSubsystemLogger("gateway-tool");
|
|
38898
38967
|
const DEFAULT_UPDATE_TIMEOUT_MS = 20 * 6e4;
|
|
38899
38968
|
const GatewayToolSchema = Type.Object({
|
|
38900
38969
|
action: stringEnum([
|
|
@@ -38962,7 +39031,7 @@ function createGatewayTool(opts) {
|
|
|
38962
39031
|
try {
|
|
38963
39032
|
await writeRestartSentinel(payload);
|
|
38964
39033
|
} catch {}
|
|
38965
|
-
log$
|
|
39034
|
+
log$27.info(`gateway tool: restart requested (delayMs=${delayMs ?? "default"}, reason=${reason ?? "none"})`);
|
|
38966
39035
|
return jsonResult(scheduleGatewaySigusr1Restart({
|
|
38967
39036
|
delayMs,
|
|
38968
39037
|
reason
|
|
@@ -45874,7 +45943,7 @@ async function resolveAnnounceTarget(params) {
|
|
|
45874
45943
|
|
|
45875
45944
|
//#endregion
|
|
45876
45945
|
//#region src/agents/tools/sessions-send-tool.a2a.ts
|
|
45877
|
-
const log$
|
|
45946
|
+
const log$26 = createSubsystemLogger("agents/sessions-send");
|
|
45878
45947
|
async function runSessionsSendA2AFlow(params) {
|
|
45879
45948
|
const runContextId = params.waitRunId ?? "unknown";
|
|
45880
45949
|
try {
|
|
@@ -45969,7 +46038,7 @@ async function runSessionsSendA2AFlow(params) {
|
|
|
45969
46038
|
timeoutMs: 1e4
|
|
45970
46039
|
});
|
|
45971
46040
|
} catch (err) {
|
|
45972
|
-
log$
|
|
46041
|
+
log$26.warn("sessions_send announce delivery failed", {
|
|
45973
46042
|
runId: runContextId,
|
|
45974
46043
|
channel: announceTarget.channel,
|
|
45975
46044
|
to: announceTarget.to,
|
|
@@ -45977,7 +46046,7 @@ async function runSessionsSendA2AFlow(params) {
|
|
|
45977
46046
|
});
|
|
45978
46047
|
}
|
|
45979
46048
|
} catch (err) {
|
|
45980
|
-
log$
|
|
46049
|
+
log$26.warn("sessions_send announce flow failed", {
|
|
45981
46050
|
runId: runContextId,
|
|
45982
46051
|
error: formatErrorMessage(err)
|
|
45983
46052
|
});
|
|
@@ -46757,7 +46826,7 @@ const BACKGROUND_IDLE_RECHECK_MS = 1e3;
|
|
|
46757
46826
|
const BACKGROUND_IDLE_MAX_ATTEMPTS = 30;
|
|
46758
46827
|
const backgroundIdleAttempts = /* @__PURE__ */ new Map();
|
|
46759
46828
|
const SIGNAL_DEADLINE_GRACE_MS = 0;
|
|
46760
|
-
const log$
|
|
46829
|
+
const log$25 = createSubsystemLogger("agent-signals");
|
|
46761
46830
|
function normalizeTrimmed(value) {
|
|
46762
46831
|
return value?.trim() || void 0;
|
|
46763
46832
|
}
|
|
@@ -47043,7 +47112,7 @@ function dispatchHeartbeatSignal(signal, now = Date.now()) {
|
|
|
47043
47112
|
if (!signal.sessionKey) return false;
|
|
47044
47113
|
if (signal.requiresIdle === true) {
|
|
47045
47114
|
if (signal.notBeforeMs !== void 0 && now > signal.notBeforeMs + SIGNAL_DEADLINE_GRACE_MS) {
|
|
47046
|
-
log$
|
|
47115
|
+
log$25.warn("agent-signals: evicting requiresIdle heartbeat signal past its deadline", {
|
|
47047
47116
|
signalId: signal.id,
|
|
47048
47117
|
type: signal.type,
|
|
47049
47118
|
source: signal.source,
|
|
@@ -49943,7 +50012,7 @@ function resolveRunWorkspaceDir(params) {
|
|
|
49943
50012
|
|
|
49944
50013
|
//#endregion
|
|
49945
50014
|
//#region src/agents/cli-runner.ts
|
|
49946
|
-
const log$
|
|
50015
|
+
const log$24 = createSubsystemLogger("agent/claude-cli");
|
|
49947
50016
|
async function runCliAgent(params) {
|
|
49948
50017
|
const started = Date.now();
|
|
49949
50018
|
const workspaceResolution = resolveRunWorkspaceDir({
|
|
@@ -49956,7 +50025,7 @@ async function runCliAgent(params) {
|
|
|
49956
50025
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
49957
50026
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
49958
50027
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
49959
|
-
if (workspaceResolution.usedFallback) log$
|
|
50028
|
+
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}`);
|
|
49960
50029
|
const workspaceDir = resolvedWorkspace;
|
|
49961
50030
|
const backendResolved = resolveCliBackendConfig(params.provider, params.config);
|
|
49962
50031
|
if (!backendResolved) throw new Error(`Unknown CLI backend: ${params.provider}`);
|
|
@@ -49986,7 +50055,7 @@ async function runCliAgent(params) {
|
|
|
49986
50055
|
resolvedSystemPrompt,
|
|
49987
50056
|
warn: makeBootstrapWarn({
|
|
49988
50057
|
sessionLabel,
|
|
49989
|
-
warn: (message) => log$
|
|
50058
|
+
warn: (message) => log$24.warn(message)
|
|
49990
50059
|
})
|
|
49991
50060
|
});
|
|
49992
50061
|
const heartbeatPrompt = sessionAgentId === defaultAgentId ? resolveHeartbeatPrompt$1(params.config?.agents?.defaults?.heartbeat?.prompt) : void 0;
|
|
@@ -50049,7 +50118,7 @@ async function runCliAgent(params) {
|
|
|
50049
50118
|
const queueKey = backend.serialize ?? true ? backendResolved.id : `${backendResolved.id}:${params.runId}`;
|
|
50050
50119
|
try {
|
|
50051
50120
|
return await enqueueCliRun(queueKey, async () => {
|
|
50052
|
-
log$
|
|
50121
|
+
log$24.info(`cli exec: provider=${params.provider} model=${normalizedModel} promptChars=${params.prompt.length}`);
|
|
50053
50122
|
const logOutputText = isTruthyEnvValue(process.env.OPENCLAW_CLAUDE_CLI_LOG_OUTPUT);
|
|
50054
50123
|
if (logOutputText) {
|
|
50055
50124
|
const logArgs = [];
|
|
@@ -50082,7 +50151,7 @@ async function runCliAgent(params) {
|
|
|
50082
50151
|
const promptIndex = logArgs.indexOf(argsPrompt);
|
|
50083
50152
|
if (promptIndex >= 0) logArgs[promptIndex] = `<prompt:${argsPrompt.length} chars>`;
|
|
50084
50153
|
}
|
|
50085
|
-
log$
|
|
50154
|
+
log$24.info(`cli argv: ${backend.command} ${logArgs.join(" ")}`);
|
|
50086
50155
|
}
|
|
50087
50156
|
const env = (() => {
|
|
50088
50157
|
const next = {
|
|
@@ -50120,17 +50189,17 @@ async function runCliAgent(params) {
|
|
|
50120
50189
|
const stdout = result.stdout.trim();
|
|
50121
50190
|
const stderr = result.stderr.trim();
|
|
50122
50191
|
if (logOutputText) {
|
|
50123
|
-
if (stdout) log$
|
|
50124
|
-
if (stderr) log$
|
|
50192
|
+
if (stdout) log$24.info(`cli stdout:\n${stdout}`);
|
|
50193
|
+
if (stderr) log$24.info(`cli stderr:\n${stderr}`);
|
|
50125
50194
|
}
|
|
50126
50195
|
if (shouldLogVerbose()) {
|
|
50127
|
-
if (stdout) log$
|
|
50128
|
-
if (stderr) log$
|
|
50196
|
+
if (stdout) log$24.debug(`cli stdout:\n${stdout}`);
|
|
50197
|
+
if (stderr) log$24.debug(`cli stderr:\n${stderr}`);
|
|
50129
50198
|
}
|
|
50130
50199
|
if (result.exitCode !== 0 || result.reason !== "exit") {
|
|
50131
50200
|
if (result.reason === "no-output-timeout" || result.noOutputTimedOut) {
|
|
50132
50201
|
const timeoutReason = `CLI produced no output for ${Math.round(noOutputTimeoutMs / 1e3)}s and was terminated.`;
|
|
50133
|
-
log$
|
|
50202
|
+
log$24.warn(`cli watchdog timeout: provider=${params.provider} model=${modelId} session=${resolvedSessionId ?? params.sessionId} noOutputTimeoutMs=${noOutputTimeoutMs} pid=${managedRun.pid ?? "unknown"}`);
|
|
50134
50203
|
throw new FailoverError(timeoutReason, {
|
|
50135
50204
|
reason: "timeout",
|
|
50136
50205
|
provider: params.provider,
|
|
@@ -50184,7 +50253,7 @@ async function runCliAgent(params) {
|
|
|
50184
50253
|
} catch (err) {
|
|
50185
50254
|
if (err instanceof FailoverError) {
|
|
50186
50255
|
if (err.reason === "session_expired" && params.cliSessionId && params.sessionKey) {
|
|
50187
|
-
log$
|
|
50256
|
+
log$24.warn(`CLI session expired, clearing session ID and retrying: provider=${params.provider} session=${redactRunIdentifier(params.cliSessionId)}`);
|
|
50188
50257
|
const output = await executeCliWithSession(void 0);
|
|
50189
50258
|
const text = output.text?.trim();
|
|
50190
50259
|
return {
|
|
@@ -50764,7 +50833,7 @@ function createBlockReplyDeliveryHandler(params) {
|
|
|
50764
50833
|
* every turn the queue-drain path starts later (a `sessions.steer` mode "queue" follow-up and
|
|
50765
50834
|
* every channel follow-up ride the same drain).
|
|
50766
50835
|
*/
|
|
50767
|
-
const log$
|
|
50836
|
+
const log$23 = createSubsystemLogger("auto-reply/session-run-recording");
|
|
50768
50837
|
const NO_RECORDING = {
|
|
50769
50838
|
complete: async () => {},
|
|
50770
50839
|
fail: async () => {},
|
|
@@ -50795,7 +50864,7 @@ async function beginTurnSessionRun(params) {
|
|
|
50795
50864
|
sessionKey
|
|
50796
50865
|
});
|
|
50797
50866
|
} catch (error) {
|
|
50798
|
-
log$
|
|
50867
|
+
log$23.warn("session-run recording unavailable for this turn", {
|
|
50799
50868
|
runId: params.runId,
|
|
50800
50869
|
error: error instanceof Error ? error.message : String(error)
|
|
50801
50870
|
});
|
|
@@ -51628,7 +51697,7 @@ function repairToolUseResultPairing(messages) {
|
|
|
51628
51697
|
|
|
51629
51698
|
//#endregion
|
|
51630
51699
|
//#region src/agents/compaction.ts
|
|
51631
|
-
const log$
|
|
51700
|
+
const log$22 = createSubsystemLogger("compaction");
|
|
51632
51701
|
const BASE_CHUNK_RATIO = .4;
|
|
51633
51702
|
const MIN_CHUNK_RATIO = .15;
|
|
51634
51703
|
const SAFETY_MARGIN = 1.2;
|
|
@@ -51754,7 +51823,7 @@ async function summarizeWithFallback(params) {
|
|
|
51754
51823
|
try {
|
|
51755
51824
|
return await summarizeChunks(params);
|
|
51756
51825
|
} catch (fullError) {
|
|
51757
|
-
log$
|
|
51826
|
+
log$22.warn(`Full summarization failed, trying partial: ${fullError instanceof Error ? fullError.message : String(fullError)}`);
|
|
51758
51827
|
}
|
|
51759
51828
|
const smallMessages = [];
|
|
51760
51829
|
const oversizedNotes = [];
|
|
@@ -51769,7 +51838,7 @@ async function summarizeWithFallback(params) {
|
|
|
51769
51838
|
messages: smallMessages
|
|
51770
51839
|
}) + (oversizedNotes.length > 0 ? `\n\n${oversizedNotes.join("\n")}` : "");
|
|
51771
51840
|
} catch (partialError) {
|
|
51772
|
-
log$
|
|
51841
|
+
log$22.warn(`Partial summarization also failed: ${partialError instanceof Error ? partialError.message : String(partialError)}`);
|
|
51773
51842
|
}
|
|
51774
51843
|
return `Context contained ${messages.length} messages (${oversizedNotes.length} oversized). Summary unavailable due to size limits.`;
|
|
51775
51844
|
}
|
|
@@ -53975,7 +54044,7 @@ async function applyResetModelOverride(params) {
|
|
|
53975
54044
|
//#endregion
|
|
53976
54045
|
//#region src/infra/session-maintenance-warning.ts
|
|
53977
54046
|
const warnedContexts = /* @__PURE__ */ new Map();
|
|
53978
|
-
const log$
|
|
54047
|
+
const log$21 = createSubsystemLogger("session-maintenance-warning");
|
|
53979
54048
|
function shouldSendWarning() {
|
|
53980
54049
|
return !process.env.VITEST && true;
|
|
53981
54050
|
}
|
|
@@ -54046,7 +54115,7 @@ async function deliverSessionMaintenanceWarning(params) {
|
|
|
54046
54115
|
session: outboundSession
|
|
54047
54116
|
});
|
|
54048
54117
|
} catch (err) {
|
|
54049
|
-
log$
|
|
54118
|
+
log$21.warn(`Failed to deliver session maintenance warning: ${String(err)}`);
|
|
54050
54119
|
enqueueSystemEvent(text, { sessionKey: params.sessionKey });
|
|
54051
54120
|
}
|
|
54052
54121
|
}
|
|
@@ -54216,7 +54285,7 @@ function buildSessionEndHookPayload(params) {
|
|
|
54216
54285
|
|
|
54217
54286
|
//#endregion
|
|
54218
54287
|
//#region src/auto-reply/reply/session.ts
|
|
54219
|
-
const log$
|
|
54288
|
+
const log$20 = createSubsystemLogger("session-init");
|
|
54220
54289
|
async function initSessionState(params) {
|
|
54221
54290
|
const { ctx, cfg, commandAuthorized } = params;
|
|
54222
54291
|
const targetSessionKey = ctx.CommandSource === "native" ? ctx.CommandTargetSessionKey?.trim() : void 0;
|
|
@@ -54423,10 +54492,10 @@ async function initSessionState(params) {
|
|
|
54423
54492
|
if (parentSessionKey && parentSessionKey !== sessionKey && sessionStore[parentSessionKey] && !alreadyForked) {
|
|
54424
54493
|
const parentTokens = sessionStore[parentSessionKey].totalTokens ?? 0;
|
|
54425
54494
|
if (parentForkMaxTokens > 0 && parentTokens > parentForkMaxTokens) {
|
|
54426
|
-
log$
|
|
54495
|
+
log$20.warn(`skipping parent fork (parent too large): parentKey=${parentSessionKey} → sessionKey=${sessionKey} parentTokens=${parentTokens} maxTokens=${parentForkMaxTokens}`);
|
|
54427
54496
|
sessionEntry.forkedFromParent = true;
|
|
54428
54497
|
} else {
|
|
54429
|
-
log$
|
|
54498
|
+
log$20.warn(`forking from parent session: parentKey=${parentSessionKey} → sessionKey=${sessionKey} parentTokens=${parentTokens}`);
|
|
54430
54499
|
const forked = await forkSessionFromParent({
|
|
54431
54500
|
parentEntry: sessionStore[parentSessionKey],
|
|
54432
54501
|
agentId,
|
|
@@ -54437,7 +54506,7 @@ async function initSessionState(params) {
|
|
|
54437
54506
|
sessionEntry.sessionId = forked.sessionId;
|
|
54438
54507
|
sessionEntry.sessionFile = forked.sessionFile;
|
|
54439
54508
|
sessionEntry.forkedFromParent = true;
|
|
54440
|
-
log$
|
|
54509
|
+
log$20.warn(`forked session created: file=${forked.sessionFile}`);
|
|
54441
54510
|
}
|
|
54442
54511
|
}
|
|
54443
54512
|
}
|
|
@@ -55312,11 +55381,11 @@ async function getReplyFromConfig(ctx, opts, configOverride) {
|
|
|
55312
55381
|
|
|
55313
55382
|
//#endregion
|
|
55314
55383
|
//#region src/infra/background-run.ts
|
|
55315
|
-
const log$
|
|
55384
|
+
const log$19 = createSubsystemLogger("infra/background-run");
|
|
55316
55385
|
|
|
55317
55386
|
//#endregion
|
|
55318
55387
|
//#region src/infra/heartbeat-active-hours.ts
|
|
55319
|
-
const log$
|
|
55388
|
+
const log$18 = createSubsystemLogger("heartbeat-active-hours");
|
|
55320
55389
|
|
|
55321
55390
|
//#endregion
|
|
55322
55391
|
//#region src/infra/heartbeat-events-filter.ts
|
|
@@ -55369,7 +55438,7 @@ function isCronSystemEvent(evt) {
|
|
|
55369
55438
|
|
|
55370
55439
|
//#endregion
|
|
55371
55440
|
//#region src/infra/heartbeat-events.ts
|
|
55372
|
-
const log$
|
|
55441
|
+
const log$17 = createSubsystemLogger("infra/heartbeat-events");
|
|
55373
55442
|
function resolveIndicatorType(status) {
|
|
55374
55443
|
switch (status) {
|
|
55375
55444
|
case "ok-empty":
|
|
@@ -55391,7 +55460,7 @@ function emitHeartbeatEvent(evt) {
|
|
|
55391
55460
|
for (const listener of listeners) try {
|
|
55392
55461
|
listener(enriched);
|
|
55393
55462
|
} catch (err) {
|
|
55394
|
-
log$
|
|
55463
|
+
log$17.warn("heartbeat event listener threw", { error: err });
|
|
55395
55464
|
}
|
|
55396
55465
|
}
|
|
55397
55466
|
|
|
@@ -55430,7 +55499,7 @@ function resolveHeartbeatVisibility(params) {
|
|
|
55430
55499
|
|
|
55431
55500
|
//#endregion
|
|
55432
55501
|
//#region src/infra/nudge.ts
|
|
55433
|
-
const log$
|
|
55502
|
+
const log$16 = createSubsystemLogger("infra/nudge");
|
|
55434
55503
|
function renderSummary(text, data) {
|
|
55435
55504
|
if (data && Object.keys(data).length > 0) try {
|
|
55436
55505
|
return `${text}\n\nData:\n${JSON.stringify(data, null, 2)}`;
|
|
@@ -55464,14 +55533,14 @@ function requestNudge(input, cfg = loadConfig(), deps) {
|
|
|
55464
55533
|
const enqueue = deps.enqueueAgentTurn;
|
|
55465
55534
|
try {
|
|
55466
55535
|
enqueue(payload).catch((error) => {
|
|
55467
|
-
log$
|
|
55536
|
+
log$16.warn("nudge enqueue failed", {
|
|
55468
55537
|
error,
|
|
55469
55538
|
sessionKey: redactIdentifier(sessionKey),
|
|
55470
55539
|
signalId
|
|
55471
55540
|
});
|
|
55472
55541
|
});
|
|
55473
55542
|
} catch (error) {
|
|
55474
|
-
log$
|
|
55543
|
+
log$16.warn("nudge enqueue failed", {
|
|
55475
55544
|
error,
|
|
55476
55545
|
sessionKey: redactIdentifier(sessionKey),
|
|
55477
55546
|
signalId
|
|
@@ -55494,14 +55563,14 @@ function requestNudge(input, cfg = loadConfig(), deps) {
|
|
|
55494
55563
|
execute: (claim) => runMainAgentTurn(claim.message.payload)
|
|
55495
55564
|
});
|
|
55496
55565
|
})().catch((error) => {
|
|
55497
|
-
log$
|
|
55566
|
+
log$16.warn("nudge claim chain failed", {
|
|
55498
55567
|
error,
|
|
55499
55568
|
sessionKey: redactIdentifier(sessionKey),
|
|
55500
55569
|
signalId
|
|
55501
55570
|
});
|
|
55502
55571
|
});
|
|
55503
55572
|
} catch (error) {
|
|
55504
|
-
log$
|
|
55573
|
+
log$16.warn("nudge enqueue failed", {
|
|
55505
55574
|
error,
|
|
55506
55575
|
sessionKey: redactIdentifier(sessionKey),
|
|
55507
55576
|
signalId
|
|
@@ -55516,7 +55585,7 @@ function requestNudge(input, cfg = loadConfig(), deps) {
|
|
|
55516
55585
|
|
|
55517
55586
|
//#endregion
|
|
55518
55587
|
//#region src/infra/wake-gate.ts
|
|
55519
|
-
const log$
|
|
55588
|
+
const log$15 = createSubsystemLogger("wake-gate");
|
|
55520
55589
|
const DEFAULT_COMMAND_TIMEOUT_MS = 3e4;
|
|
55521
55590
|
const DEFAULT_MODEL_TIMEOUT_MS = 3e4;
|
|
55522
55591
|
const MAX_COMMAND_OUTPUT_BYTES = 64 * 1024;
|
|
@@ -55638,7 +55707,7 @@ async function runWakeGate(spec, ctx) {
|
|
|
55638
55707
|
if (spec.kind === "command") return await runCommandGate(spec, ctx);
|
|
55639
55708
|
else return await runModelGate(spec, ctx);
|
|
55640
55709
|
} catch (err) {
|
|
55641
|
-
log$
|
|
55710
|
+
log$15.error("wake-gate error (no crash)", {
|
|
55642
55711
|
kind: spec.kind,
|
|
55643
55712
|
error: err instanceof Error ? err.message : String(err)
|
|
55644
55713
|
});
|
|
@@ -55649,7 +55718,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
55649
55718
|
try {
|
|
55650
55719
|
const result = await runCommand(spec.command, spec.cwd, spec.timeoutMs, _ctx.abortSignal);
|
|
55651
55720
|
if (result.exit !== 0) {
|
|
55652
|
-
log$
|
|
55721
|
+
log$15.warn("wake gate command non-zero exit", {
|
|
55653
55722
|
kind: "command",
|
|
55654
55723
|
exit: result.exit,
|
|
55655
55724
|
...stdoutShapeForLog(result.stdout)
|
|
@@ -55658,7 +55727,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
55658
55727
|
}
|
|
55659
55728
|
const lines = result.stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
55660
55729
|
if (lines.length === 0) {
|
|
55661
|
-
log$
|
|
55730
|
+
log$15.warn("wake gate command produced no output", {
|
|
55662
55731
|
kind: "command",
|
|
55663
55732
|
exit: result.exit,
|
|
55664
55733
|
...stdoutShapeForLog(result.stdout)
|
|
@@ -55668,7 +55737,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
55668
55737
|
const lastLine = lines[lines.length - 1];
|
|
55669
55738
|
const decision = await parseWakeDecision(lastLine);
|
|
55670
55739
|
if (!decision) {
|
|
55671
|
-
log$
|
|
55740
|
+
log$15.warn("wake gate command output did not parse as a wake decision", {
|
|
55672
55741
|
kind: "command",
|
|
55673
55742
|
exit: result.exit,
|
|
55674
55743
|
...stdoutShapeForLog(result.stdout)
|
|
@@ -55676,14 +55745,14 @@ async function runCommandGate(spec, _ctx) {
|
|
|
55676
55745
|
return { wake: false };
|
|
55677
55746
|
}
|
|
55678
55747
|
if (!decision.wakeAgent) {
|
|
55679
|
-
log$
|
|
55748
|
+
log$15.debug("wake gate command decided not to wake", {
|
|
55680
55749
|
kind: "command",
|
|
55681
55750
|
exit: result.exit,
|
|
55682
55751
|
...stdoutShapeForLog(result.stdout)
|
|
55683
55752
|
});
|
|
55684
55753
|
return { wake: false };
|
|
55685
55754
|
}
|
|
55686
|
-
log$
|
|
55755
|
+
log$15.info("wake gate command decided to wake", {
|
|
55687
55756
|
kind: "command",
|
|
55688
55757
|
exit: result.exit,
|
|
55689
55758
|
hasText: decision.text !== void 0,
|
|
@@ -55694,7 +55763,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
55694
55763
|
if (decision.data !== void 0) res.data = decision.data;
|
|
55695
55764
|
return res;
|
|
55696
55765
|
} catch (err) {
|
|
55697
|
-
log$
|
|
55766
|
+
log$15.warn("command gate error", { error: err instanceof Error ? err.message : String(err) });
|
|
55698
55767
|
return { wake: false };
|
|
55699
55768
|
}
|
|
55700
55769
|
}
|
|
@@ -55732,27 +55801,27 @@ async function runModelGate(spec, ctx) {
|
|
|
55732
55801
|
...ctx.abortSignal ? { abortSignal: ctx.abortSignal } : {}
|
|
55733
55802
|
})).payloads ?? []).filter((payload) => !payload.isError && typeof payload.text === "string").map((payload) => payload.text ?? "").join("\n").trim();
|
|
55734
55803
|
if (!modelOutput) {
|
|
55735
|
-
log$
|
|
55804
|
+
log$15.warn("wake gate model produced no output", { kind: "model" });
|
|
55736
55805
|
return { wake: false };
|
|
55737
55806
|
}
|
|
55738
55807
|
const outputLines = modelOutput.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
55739
55808
|
const lastLine = outputLines[outputLines.length - 1] ?? modelOutput;
|
|
55740
55809
|
const decision = await parseWakeDecision(modelOutput) ?? await parseWakeDecision(lastLine);
|
|
55741
55810
|
if (!decision) {
|
|
55742
|
-
log$
|
|
55811
|
+
log$15.warn("wake gate model output did not parse as a wake decision", {
|
|
55743
55812
|
kind: "model",
|
|
55744
55813
|
tail: tailForLog(modelOutput)
|
|
55745
55814
|
});
|
|
55746
55815
|
return { wake: false };
|
|
55747
55816
|
}
|
|
55748
55817
|
if (!decision.wakeAgent) {
|
|
55749
|
-
log$
|
|
55818
|
+
log$15.debug("wake gate model decided not to wake", {
|
|
55750
55819
|
kind: "model",
|
|
55751
55820
|
tail: tailForLog(modelOutput)
|
|
55752
55821
|
});
|
|
55753
55822
|
return { wake: false };
|
|
55754
55823
|
}
|
|
55755
|
-
log$
|
|
55824
|
+
log$15.info("wake gate model decided to wake", {
|
|
55756
55825
|
kind: "model",
|
|
55757
55826
|
hasText: decision.text !== void 0,
|
|
55758
55827
|
hasData: decision.data !== void 0
|
|
@@ -55762,7 +55831,7 @@ async function runModelGate(spec, ctx) {
|
|
|
55762
55831
|
if (decision.data !== void 0) res.data = decision.data;
|
|
55763
55832
|
return res;
|
|
55764
55833
|
} catch (err) {
|
|
55765
|
-
log$
|
|
55834
|
+
log$15.warn("model gate error", { error: err instanceof Error ? err.message : String(err) });
|
|
55766
55835
|
return { wake: false };
|
|
55767
55836
|
} finally {
|
|
55768
55837
|
if (tmpDir) await fs.rm(tmpDir, {
|
|
@@ -55774,7 +55843,7 @@ async function runModelGate(spec, ctx) {
|
|
|
55774
55843
|
|
|
55775
55844
|
//#endregion
|
|
55776
55845
|
//#region src/infra/heartbeat-runner.ts
|
|
55777
|
-
const log$
|
|
55846
|
+
const log$14 = createSubsystemLogger("gateway/heartbeat");
|
|
55778
55847
|
const DEFAULT_HEARTBEAT_TARGET = "none";
|
|
55779
55848
|
const redactHeartbeatLogIdentifier = (value) => value?.trim() ? redactIdentifier(value) : null;
|
|
55780
55849
|
function isHeartbeatSessionResolutionError(resolution) {
|
|
@@ -55951,7 +56020,7 @@ async function pruneHeartbeatTranscript(params) {
|
|
|
55951
56020
|
throw err;
|
|
55952
56021
|
}
|
|
55953
56022
|
} catch (err) {
|
|
55954
|
-
log$
|
|
56023
|
+
log$14.warn(`pruneHeartbeatTranscript error: ${err instanceof Error ? err.message : String(err)}`, { transcriptPath });
|
|
55955
56024
|
}
|
|
55956
56025
|
}
|
|
55957
56026
|
/**
|
|
@@ -56191,7 +56260,7 @@ async function prepareHeartbeatDeliveryAndPrompt(params) {
|
|
|
56191
56260
|
reason: HEARTBEAT_SKIP_WAKE_GATE_EMPTY,
|
|
56192
56261
|
durationMs: Date.now() - startedAt
|
|
56193
56262
|
});
|
|
56194
|
-
log$
|
|
56263
|
+
log$14.info("heartbeat: wake gate suppressed run", {
|
|
56195
56264
|
agentId: redactHeartbeatLogIdentifier(agentId),
|
|
56196
56265
|
reason: HEARTBEAT_SKIP_WAKE_GATE_EMPTY
|
|
56197
56266
|
});
|
|
@@ -56202,16 +56271,16 @@ async function prepareHeartbeatDeliveryAndPrompt(params) {
|
|
|
56202
56271
|
}
|
|
56203
56272
|
wakeGateText = wakeResult.data !== void 0 ? `${wakeResult.text ?? ""}\n\nData:\n${JSON.stringify(wakeResult.data, null, 2)}`.trim() : wakeResult.text?.trim() || void 0;
|
|
56204
56273
|
}
|
|
56205
|
-
if (delivery.reason === "unknown-account") log$
|
|
56274
|
+
if (delivery.reason === "unknown-account") log$14.warn("heartbeat: unknown accountId", {
|
|
56206
56275
|
accountId: redactHeartbeatLogIdentifier(delivery.accountId ?? heartbeatAccountId),
|
|
56207
56276
|
target: heartbeat?.target ?? "none"
|
|
56208
56277
|
});
|
|
56209
|
-
else if (heartbeatAccountId) log$
|
|
56278
|
+
else if (heartbeatAccountId) log$14.info("heartbeat: using explicit accountId", {
|
|
56210
56279
|
accountId: redactHeartbeatLogIdentifier(delivery.accountId ?? heartbeatAccountId),
|
|
56211
56280
|
target: heartbeat?.target ?? "none",
|
|
56212
56281
|
channel: delivery.channel
|
|
56213
56282
|
});
|
|
56214
|
-
log$
|
|
56283
|
+
log$14.info("heartbeat: resolved plan", {
|
|
56215
56284
|
agentId: redactHeartbeatLogIdentifier(agentId),
|
|
56216
56285
|
sessionKey: redactHeartbeatLogIdentifier(sessionKey),
|
|
56217
56286
|
sessionSource: preflight.session.source,
|
|
@@ -56286,7 +56355,7 @@ async function resolveHeartbeatPreflightOrSkip(params) {
|
|
|
56286
56355
|
durationMs: Date.now() - startedAt,
|
|
56287
56356
|
indicatorType: resolveIndicatorType("failed")
|
|
56288
56357
|
});
|
|
56289
|
-
log$
|
|
56358
|
+
log$14.error(`heartbeat failed: ${publicReason}`, {
|
|
56290
56359
|
error: publicReason,
|
|
56291
56360
|
agentId: redactHeartbeatLogIdentifier(agentId),
|
|
56292
56361
|
sessionSource: preflight.sessionError.source,
|
|
@@ -56305,7 +56374,7 @@ async function resolveHeartbeatPreflightOrSkip(params) {
|
|
|
56305
56374
|
durationMs: Date.now() - startedAt,
|
|
56306
56375
|
indicatorType: resolveIndicatorType("failed")
|
|
56307
56376
|
});
|
|
56308
|
-
log$
|
|
56377
|
+
log$14.error(`heartbeat failed: ${reason}`, {
|
|
56309
56378
|
error: reason,
|
|
56310
56379
|
agentId: redactHeartbeatLogIdentifier(agentId)
|
|
56311
56380
|
});
|
|
@@ -56342,7 +56411,7 @@ async function loadSharedSessionHeartbeatContext(params) {
|
|
|
56342
56411
|
if (present.length === 0) return;
|
|
56343
56412
|
return present.map((file) => `## ${file.path}\n\n${file.content}`).join("\n\n");
|
|
56344
56413
|
} catch (err) {
|
|
56345
|
-
log$
|
|
56414
|
+
log$14.warn("failed to load heartbeat context files for trigger message", { error: err });
|
|
56346
56415
|
return;
|
|
56347
56416
|
}
|
|
56348
56417
|
}
|
|
@@ -56647,7 +56716,7 @@ async function finalizeTurnOutcome(params) {
|
|
|
56647
56716
|
channel: delivery.channel,
|
|
56648
56717
|
accountId: delivery.accountId
|
|
56649
56718
|
});
|
|
56650
|
-
log$
|
|
56719
|
+
log$14.warn("heartbeat: channel not ready", {
|
|
56651
56720
|
channel: delivery.channel,
|
|
56652
56721
|
reason: readiness.reason
|
|
56653
56722
|
});
|
|
@@ -56735,11 +56804,11 @@ async function cleanupIsolatedHeartbeatSession(params) {
|
|
|
56735
56804
|
restrictToStoreDir: true
|
|
56736
56805
|
});
|
|
56737
56806
|
} catch (archiveErr) {
|
|
56738
|
-
log$
|
|
56807
|
+
log$14.warn(`cron: error-path isolated session archive failed: ${formatErrorMessage(archiveErr)}`, { sessionId: isolatedEntry.sessionId });
|
|
56739
56808
|
}
|
|
56740
56809
|
delete store[createdIsolatedSessionKey];
|
|
56741
56810
|
}).catch((cleanupErr) => {
|
|
56742
|
-
log$
|
|
56811
|
+
log$14.warn(`failed to clean up isolated heartbeat session on error: ${String(cleanupErr)}`);
|
|
56743
56812
|
});
|
|
56744
56813
|
}
|
|
56745
56814
|
async function handleHeartbeatError(params) {
|
|
@@ -56759,7 +56828,7 @@ async function handleHeartbeatError(params) {
|
|
|
56759
56828
|
accountId: delivery.accountId,
|
|
56760
56829
|
indicatorType: visibility.useIndicator ? resolveIndicatorType("failed") : void 0
|
|
56761
56830
|
});
|
|
56762
|
-
log$
|
|
56831
|
+
log$14.error(`heartbeat failed: ${reason}`, { error: reason });
|
|
56763
56832
|
return {
|
|
56764
56833
|
status: "failed",
|
|
56765
56834
|
reason
|
|
@@ -56913,7 +56982,7 @@ async function runMainAgentTurn(payload, opts) {
|
|
|
56913
56982
|
|
|
56914
56983
|
//#endregion
|
|
56915
56984
|
//#region src/agents/subagent-announce-turn.ts
|
|
56916
|
-
const log$
|
|
56985
|
+
const log$13 = createSubsystemLogger("agents/subagent-announce-turn");
|
|
56917
56986
|
function clearDelayedReleaseHoldIfNoAnnounceIsParked(sessionKey) {
|
|
56918
56987
|
if (!peekDelayedAgentTurn(sessionKey, (payload) => payload.kind === "announce")) clearDelayedReleaseHold(sessionKey);
|
|
56919
56988
|
}
|
|
@@ -56973,7 +57042,7 @@ async function publishSubagentAnnounceTurn(params) {
|
|
|
56973
57042
|
};
|
|
56974
57043
|
} catch (error) {
|
|
56975
57044
|
clearDelayedReleaseHoldIfNoAnnounceIsParked(params.requesterSessionKey);
|
|
56976
|
-
log$
|
|
57045
|
+
log$13.warn("subagent announce turn failed", { error: String(error) });
|
|
56977
57046
|
return {
|
|
56978
57047
|
status: "failed",
|
|
56979
57048
|
error: String(error)
|
|
@@ -67927,7 +67996,7 @@ function toDiscordModelPickerMessagePayload(view) {
|
|
|
67927
67996
|
|
|
67928
67997
|
//#endregion
|
|
67929
67998
|
//#region src/discord/monitor/native-command.ts
|
|
67930
|
-
const log$
|
|
67999
|
+
const log$12 = createSubsystemLogger("discord/native-command");
|
|
67931
68000
|
function buildDiscordCommandOptions(params) {
|
|
67932
68001
|
const { command, cfg } = params;
|
|
67933
68002
|
const args = command.args;
|
|
@@ -68984,7 +69053,7 @@ async function dispatchDiscordCommandInteraction(params) {
|
|
|
68984
69053
|
},
|
|
68985
69054
|
onError: (err, info) => {
|
|
68986
69055
|
const message = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
68987
|
-
log$
|
|
69056
|
+
log$12.error(`discord slash ${info.kind} reply failed: ${message}`);
|
|
68988
69057
|
}
|
|
68989
69058
|
},
|
|
68990
69059
|
replyOptions: {
|
|
@@ -72465,7 +72534,7 @@ function resolveSession(opts) {
|
|
|
72465
72534
|
|
|
72466
72535
|
//#endregion
|
|
72467
72536
|
//#region src/commands/agent.ts
|
|
72468
|
-
const log$
|
|
72537
|
+
const log$11 = createSubsystemLogger("commands/agent");
|
|
72469
72538
|
const OVERRIDE_FIELDS_CLEARED_BY_DELETE = [
|
|
72470
72539
|
"providerOverride",
|
|
72471
72540
|
"modelOverride",
|
|
@@ -72523,7 +72592,7 @@ function runAgentAttempt(params) {
|
|
|
72523
72592
|
});
|
|
72524
72593
|
return runCliWithSession(cliSessionId).catch(async (err) => {
|
|
72525
72594
|
if (err instanceof FailoverError && err.reason === "session_expired" && cliSessionId && params.sessionKey && params.sessionStore && params.storePath) {
|
|
72526
|
-
log$
|
|
72595
|
+
log$11.warn(`CLI session expired, clearing from session store: provider=${params.providerOverride} sessionKey=${params.sessionKey}`);
|
|
72527
72596
|
const entry = params.sessionStore[params.sessionKey];
|
|
72528
72597
|
if (entry) {
|
|
72529
72598
|
const updatedEntry = { ...entry };
|
|
@@ -90603,7 +90672,7 @@ const TELEGRAM_WEBHOOK_MAX_BODY_BYTES = 1024 * 1024;
|
|
|
90603
90672
|
const TELEGRAM_WEBHOOK_BODY_TIMEOUT_MS = 3e4;
|
|
90604
90673
|
const TELEGRAM_WEBHOOK_CALLBACK_TIMEOUT_MS = 1e4;
|
|
90605
90674
|
const TELEGRAM_WEBHOOK_DEFAULT_MAX_CONNECTIONS = 40;
|
|
90606
|
-
const log$
|
|
90675
|
+
const log$10 = createSubsystemLogger("telegram/webhook");
|
|
90607
90676
|
let webhookOwnerSequence = 0;
|
|
90608
90677
|
let ephemeralWebhookListenerSequence = 0;
|
|
90609
90678
|
let activeWebhookDiagnosticUsers = 0;
|
|
@@ -90933,7 +91002,7 @@ async function startTelegramWebhook(opts) {
|
|
|
90933
91002
|
recordRequest({ outcome: "received" });
|
|
90934
91003
|
const secretHeader = resolveSingleHeaderValue(req.headers["x-telegram-bot-api-secret-token"]);
|
|
90935
91004
|
if (!hasValidTelegramWebhookSecret(secretHeader, secret)) {
|
|
90936
|
-
log$
|
|
91005
|
+
log$10.warn("telegram webhook secret rejected", {
|
|
90937
91006
|
sourceIp: resolveWebhookSourceIp(req),
|
|
90938
91007
|
reason: typeof secretHeader === "string" ? "secret-mismatch" : "missing-header",
|
|
90939
91008
|
path
|
|
@@ -91028,7 +91097,7 @@ async function startTelegramWebhook(opts) {
|
|
|
91028
91097
|
const unauthorized = async () => {
|
|
91029
91098
|
if (replied) return;
|
|
91030
91099
|
replied = true;
|
|
91031
|
-
log$
|
|
91100
|
+
log$10.warn("telegram webhook secret rejected", {
|
|
91032
91101
|
sourceIp: resolveWebhookSourceIp(req),
|
|
91033
91102
|
reason: typeof secretHeader === "string" ? "secret-mismatch" : "missing-header",
|
|
91034
91103
|
path
|
|
@@ -92001,11 +92070,11 @@ function createRuntimeMedia() {
|
|
|
92001
92070
|
|
|
92002
92071
|
//#endregion
|
|
92003
92072
|
//#region src/backbone/authz.ts
|
|
92004
|
-
const log$
|
|
92073
|
+
const log$9 = createSubsystemLogger("backbone/authz");
|
|
92005
92074
|
|
|
92006
92075
|
//#endregion
|
|
92007
92076
|
//#region src/backbone/scoped-plugin-api.ts
|
|
92008
|
-
const log$
|
|
92077
|
+
const log$8 = createSubsystemLogger("backbone/scoped-plugin-api");
|
|
92009
92078
|
|
|
92010
92079
|
//#endregion
|
|
92011
92080
|
//#region src/plugins/runtime/runtime-signals.ts
|
|
@@ -92247,7 +92316,7 @@ function resolveMemoryBackendConfig(params) {
|
|
|
92247
92316
|
|
|
92248
92317
|
//#endregion
|
|
92249
92318
|
//#region src/memory/search-manager.ts
|
|
92250
|
-
const log$
|
|
92319
|
+
const log$7 = createSubsystemLogger("memory");
|
|
92251
92320
|
const QMD_MANAGER_CACHE = /* @__PURE__ */ new Map();
|
|
92252
92321
|
async function getMemorySearchManager(params) {
|
|
92253
92322
|
const resolved = resolveMemoryBackendConfig(params);
|
|
@@ -92284,7 +92353,7 @@ async function getMemorySearchManager(params) {
|
|
|
92284
92353
|
}
|
|
92285
92354
|
} catch (err) {
|
|
92286
92355
|
const message = err instanceof Error ? err.message : String(err);
|
|
92287
|
-
log$
|
|
92356
|
+
log$7.warn(`qmd memory unavailable; falling back to builtin: ${message}`);
|
|
92288
92357
|
}
|
|
92289
92358
|
}
|
|
92290
92359
|
try {
|
|
@@ -92311,7 +92380,7 @@ var FallbackMemoryManager = class {
|
|
|
92311
92380
|
} catch (err) {
|
|
92312
92381
|
this.primaryFailed = true;
|
|
92313
92382
|
this.lastError = err instanceof Error ? err.message : String(err);
|
|
92314
|
-
log$
|
|
92383
|
+
log$7.warn(`qmd memory failed; switching to builtin index: ${this.lastError}`);
|
|
92315
92384
|
await this.deps.primary.close?.().catch(() => {});
|
|
92316
92385
|
this.evictCacheEntry();
|
|
92317
92386
|
}
|
|
@@ -92391,12 +92460,12 @@ var FallbackMemoryManager = class {
|
|
|
92391
92460
|
try {
|
|
92392
92461
|
fallback = await this.deps.fallbackFactory();
|
|
92393
92462
|
if (!fallback) {
|
|
92394
|
-
log$
|
|
92463
|
+
log$7.warn("memory fallback requested but builtin index is unavailable");
|
|
92395
92464
|
return null;
|
|
92396
92465
|
}
|
|
92397
92466
|
} catch (err) {
|
|
92398
92467
|
const message = err instanceof Error ? err.message : String(err);
|
|
92399
|
-
log$
|
|
92468
|
+
log$7.warn(`memory fallback unavailable: ${message}`);
|
|
92400
92469
|
return null;
|
|
92401
92470
|
}
|
|
92402
92471
|
this.fallback = fallback;
|
|
@@ -94111,7 +94180,7 @@ function createPluginLoaderLogger(logger) {
|
|
|
94111
94180
|
|
|
94112
94181
|
//#endregion
|
|
94113
94182
|
//#region src/plugins/tools.ts
|
|
94114
|
-
const log$
|
|
94183
|
+
const log$6 = createSubsystemLogger("plugins");
|
|
94115
94184
|
const pluginToolMeta = /* @__PURE__ */ new WeakMap();
|
|
94116
94185
|
function getPluginToolMeta(tool) {
|
|
94117
94186
|
return pluginToolMeta.get(tool);
|
|
@@ -94133,7 +94202,7 @@ function resolvePluginTools(params) {
|
|
|
94133
94202
|
const registry = loadOpenClawPlugins({
|
|
94134
94203
|
config: effectiveConfig,
|
|
94135
94204
|
workspaceDir: params.context.workspaceDir,
|
|
94136
|
-
logger: createPluginLoaderLogger(log$
|
|
94205
|
+
logger: createPluginLoaderLogger(log$6),
|
|
94137
94206
|
activate: false
|
|
94138
94207
|
});
|
|
94139
94208
|
const tools = [];
|
|
@@ -94148,7 +94217,7 @@ function resolvePluginTools(params) {
|
|
|
94148
94217
|
if (existingNormalized.has(pluginIdKey)) {
|
|
94149
94218
|
const message = `plugin id conflicts with core tool name (${entry.pluginId})`;
|
|
94150
94219
|
if (!params.suppressNameConflicts) {
|
|
94151
|
-
log$
|
|
94220
|
+
log$6.error(message);
|
|
94152
94221
|
registry.diagnostics.push({
|
|
94153
94222
|
level: "error",
|
|
94154
94223
|
code: "PLUGIN_REGISTER_ERROR",
|
|
@@ -94165,7 +94234,7 @@ function resolvePluginTools(params) {
|
|
|
94165
94234
|
try {
|
|
94166
94235
|
resolved = entry.factory(params.context);
|
|
94167
94236
|
} catch (err) {
|
|
94168
|
-
log$
|
|
94237
|
+
log$6.error(`plugin tool failed (${entry.pluginId}): ${String(err)}`);
|
|
94169
94238
|
continue;
|
|
94170
94239
|
}
|
|
94171
94240
|
if (!resolved) continue;
|
|
@@ -94182,7 +94251,7 @@ function resolvePluginTools(params) {
|
|
|
94182
94251
|
if (nameSet.has(tool.name) || existing.has(tool.name)) {
|
|
94183
94252
|
const message = `plugin tool name conflict (${entry.pluginId}): ${tool.name}`;
|
|
94184
94253
|
if (!params.suppressNameConflicts) {
|
|
94185
|
-
log$
|
|
94254
|
+
log$6.error(message);
|
|
94186
94255
|
registry.diagnostics.push({
|
|
94187
94256
|
level: "error",
|
|
94188
94257
|
code: "PLUGIN_REGISTER_ERROR",
|
|
@@ -94215,7 +94284,7 @@ function resolvePluginWebSearchProviders(params) {
|
|
|
94215
94284
|
return [...loadOpenClawPlugins({
|
|
94216
94285
|
config: effectiveConfig,
|
|
94217
94286
|
workspaceDir: params.workspaceDir,
|
|
94218
|
-
logger: createPluginLoaderLogger(log$
|
|
94287
|
+
logger: createPluginLoaderLogger(log$6),
|
|
94219
94288
|
activate: false
|
|
94220
94289
|
}).webSearchProviders].toSorted((a, b) => {
|
|
94221
94290
|
return (a.autoDetectOrder ?? Infinity) - (b.autoDetectOrder ?? Infinity);
|
|
@@ -94827,7 +94896,7 @@ function wrapToolWithAbortSignal(tool, abortSignal) {
|
|
|
94827
94896
|
|
|
94828
94897
|
//#endregion
|
|
94829
94898
|
//#region src/agents/pi-tools.before-tool-call.ts
|
|
94830
|
-
const log$
|
|
94899
|
+
const log$5 = createSubsystemLogger("agents/tools");
|
|
94831
94900
|
const BEFORE_TOOL_CALL_WRAPPED = Symbol("beforeToolCallWrapped");
|
|
94832
94901
|
const adjustedParamsByToolCallId = /* @__PURE__ */ new Map();
|
|
94833
94902
|
const MAX_TRACKED_ADJUSTED_PARAMS = 1024;
|
|
@@ -94865,7 +94934,7 @@ async function recordLoopOutcome(args) {
|
|
|
94865
94934
|
config: args.ctx.loopDetection
|
|
94866
94935
|
});
|
|
94867
94936
|
} catch (err) {
|
|
94868
|
-
log$
|
|
94937
|
+
log$5.warn(`tool loop outcome tracking failed: tool=${args.toolName} error=${String(err)}`);
|
|
94869
94938
|
}
|
|
94870
94939
|
}
|
|
94871
94940
|
var UserCancelledError = class extends Error {
|
|
@@ -94892,7 +94961,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
94892
94961
|
const loopResult = detectToolCallLoop(sessionState, toolName, params, args.ctx.loopDetection);
|
|
94893
94962
|
if (loopResult.stuck) {
|
|
94894
94963
|
if (loopResult.level === "critical") {
|
|
94895
|
-
log$
|
|
94964
|
+
log$5.error(`Blocking ${toolName} due to critical loop: ${loopResult.message}`);
|
|
94896
94965
|
logToolLoopAction({
|
|
94897
94966
|
sessionKey: args.ctx.sessionKey,
|
|
94898
94967
|
sessionId: args.ctx?.agentId,
|
|
@@ -94910,7 +94979,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
94910
94979
|
reason: loopResult.message
|
|
94911
94980
|
};
|
|
94912
94981
|
} else if (shouldEmitLoopWarning(sessionState, loopResult.warningKey ?? `${loopResult.detector}:${toolName}`, loopResult.count)) {
|
|
94913
|
-
log$
|
|
94982
|
+
log$5.warn(`Loop warning for ${toolName}: ${loopResult.message}`);
|
|
94914
94983
|
logToolLoopAction({
|
|
94915
94984
|
sessionKey: args.ctx.sessionKey,
|
|
94916
94985
|
sessionId: args.ctx?.agentId,
|
|
@@ -94969,7 +95038,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
94969
95038
|
}
|
|
94970
95039
|
} catch (err) {
|
|
94971
95040
|
const toolCallId = args.toolCallId ? ` toolCallId=${args.toolCallId}` : "";
|
|
94972
|
-
log$
|
|
95041
|
+
log$5.warn(`before_tool_call hook failed: tool=${toolName}${toolCallId} error=${String(err)}`);
|
|
94973
95042
|
}
|
|
94974
95043
|
return {
|
|
94975
95044
|
blocked: false,
|
|
@@ -96785,7 +96854,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
96785
96854
|
const textLength = getToolResultTextLength(msg);
|
|
96786
96855
|
if (textLength > maxChars) {
|
|
96787
96856
|
oversizedIndices.push(i);
|
|
96788
|
-
log$
|
|
96857
|
+
log$29.info(`[tool-result-truncation] Found oversized tool result: entry=${entry.id} chars=${textLength} maxChars=${maxChars} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
96789
96858
|
}
|
|
96790
96859
|
}
|
|
96791
96860
|
if (oversizedIndices.length === 0) return {
|
|
@@ -96807,7 +96876,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
96807
96876
|
message = truncateToolResultMessage(message, maxChars);
|
|
96808
96877
|
truncatedCount++;
|
|
96809
96878
|
const newLength = getToolResultTextLength(message);
|
|
96810
|
-
log$
|
|
96879
|
+
log$29.info(`[tool-result-truncation] Truncated tool result: originalEntry=${entry.id} newChars=${newLength} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
96811
96880
|
}
|
|
96812
96881
|
sessionManager.appendMessage(message);
|
|
96813
96882
|
} else if (entry.type === "compaction") sessionManager.appendCompaction(entry.summary, entry.firstKeptEntryId, entry.tokensBefore, entry.details, entry.fromHook);
|
|
@@ -96821,14 +96890,14 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
96821
96890
|
if (entry.name) sessionManager.appendSessionInfo(entry.name);
|
|
96822
96891
|
}
|
|
96823
96892
|
}
|
|
96824
|
-
log$
|
|
96893
|
+
log$29.info(`[tool-result-truncation] Truncated ${truncatedCount} tool result(s) in session (contextWindow=${contextWindowTokens} maxChars=${maxChars}) sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
96825
96894
|
return {
|
|
96826
96895
|
truncated: true,
|
|
96827
96896
|
truncatedCount
|
|
96828
96897
|
};
|
|
96829
96898
|
} catch (err) {
|
|
96830
96899
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
96831
|
-
log$
|
|
96900
|
+
log$29.warn(`[tool-result-truncation] Failed to truncate: ${errMsg}`);
|
|
96832
96901
|
return {
|
|
96833
96902
|
truncated: false,
|
|
96834
96903
|
truncatedCount: 0,
|
|
@@ -97202,7 +97271,7 @@ const getCompactionSafeguardRuntime = registry$1.get;
|
|
|
97202
97271
|
|
|
97203
97272
|
//#endregion
|
|
97204
97273
|
//#region src/agents/pi-extensions/compaction-safeguard.ts
|
|
97205
|
-
const log$
|
|
97274
|
+
const log$4 = createSubsystemLogger("compaction-safeguard");
|
|
97206
97275
|
const missedModelWarningSessions = /* @__PURE__ */ new WeakSet();
|
|
97207
97276
|
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.";
|
|
97208
97277
|
const MAX_TOOL_FAILURES = 8;
|
|
@@ -97311,7 +97380,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97311
97380
|
api.on("session_before_compact", async (event, ctx) => {
|
|
97312
97381
|
const { preparation, customInstructions, signal } = event;
|
|
97313
97382
|
if (!preparation.messagesToSummarize.some(isRealConversationMessage)) {
|
|
97314
|
-
log$
|
|
97383
|
+
log$4.warn("Compaction safeguard: cancelling compaction with no real conversation messages to summarize.");
|
|
97315
97384
|
return { cancel: true };
|
|
97316
97385
|
}
|
|
97317
97386
|
const { readFiles, modifiedFiles } = computeFileLists(preparation.fileOps);
|
|
@@ -97319,7 +97388,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97319
97388
|
const toolFailureSection = formatToolFailuresSection(collectToolFailures([...preparation.messagesToSummarize, ...preparation.turnPrefixMessages]));
|
|
97320
97389
|
const runtime = getCompactionSafeguardRuntime(ctx.sessionManager);
|
|
97321
97390
|
if (runtime?.enabled === false) {
|
|
97322
|
-
log$
|
|
97391
|
+
log$4.info("Compaction safeguard: compaction disabled by config; cancelling.");
|
|
97323
97392
|
return { cancel: true };
|
|
97324
97393
|
}
|
|
97325
97394
|
const summarizationInstructions = {
|
|
@@ -97360,7 +97429,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97360
97429
|
});
|
|
97361
97430
|
if (pruned.droppedChunks > 0) {
|
|
97362
97431
|
const newContentRatio = newContentTokens / contextWindowTokens * 100;
|
|
97363
|
-
log$
|
|
97432
|
+
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.`);
|
|
97364
97433
|
messagesToSummarize = pruned.messages;
|
|
97365
97434
|
if (pruned.droppedMessagesList.length > 0) try {
|
|
97366
97435
|
const droppedChunkRatio = computeAdaptiveChunkRatio(pruned.droppedMessagesList, contextWindowTokens);
|
|
@@ -97378,7 +97447,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97378
97447
|
previousSummary: preparation.previousSummary
|
|
97379
97448
|
});
|
|
97380
97449
|
} catch (droppedError) {
|
|
97381
|
-
log$
|
|
97450
|
+
log$4.warn(`Compaction safeguard: failed to summarize dropped messages, continuing without: ${droppedError instanceof Error ? droppedError.message : String(droppedError)}`);
|
|
97382
97451
|
}
|
|
97383
97452
|
}
|
|
97384
97453
|
}
|
|
@@ -97426,7 +97495,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97426
97495
|
}
|
|
97427
97496
|
} };
|
|
97428
97497
|
} catch (error) {
|
|
97429
|
-
log$
|
|
97498
|
+
log$4.warn(`Compaction summarization failed; cancelling compaction to preserve history: ${error instanceof Error ? error.message : String(error)}`);
|
|
97430
97499
|
return { cancel: true };
|
|
97431
97500
|
}
|
|
97432
97501
|
});
|
|
@@ -98157,14 +98226,14 @@ function logToolSchemasForGoogle(params) {
|
|
|
98157
98226
|
if (params.provider !== "google-gemini-cli") return;
|
|
98158
98227
|
const toolNames = params.tools.map((tool, index) => `${index}:${tool.name}`);
|
|
98159
98228
|
const tools = sanitizeToolsForGoogle(params);
|
|
98160
|
-
log$
|
|
98229
|
+
log$29.info("google tool schema snapshot", {
|
|
98161
98230
|
provider: params.provider,
|
|
98162
98231
|
toolCount: tools.length,
|
|
98163
98232
|
tools: toolNames
|
|
98164
98233
|
});
|
|
98165
98234
|
for (const [index, tool] of tools.entries()) {
|
|
98166
98235
|
const violations = findUnsupportedSchemaKeywords(tool.parameters, `${tool.name}.parameters`);
|
|
98167
|
-
if (violations.length > 0) log$
|
|
98236
|
+
if (violations.length > 0) log$29.warn("google tool schema has unsupported keywords", {
|
|
98168
98237
|
index,
|
|
98169
98238
|
tool: tool.name,
|
|
98170
98239
|
violations: violations.slice(0, 12),
|
|
@@ -98176,7 +98245,7 @@ const compactionFailureEmitter = new EventEmitter();
|
|
|
98176
98245
|
registerUnhandledRejectionHandler((reason) => {
|
|
98177
98246
|
const message = describeUnknownError(reason);
|
|
98178
98247
|
if (!isCompactionFailureError(message)) return false;
|
|
98179
|
-
log$
|
|
98248
|
+
log$29.error(`Auto-compaction failed (unhandled): ${message}`);
|
|
98180
98249
|
compactionFailureEmitter.emit("failure", message);
|
|
98181
98250
|
return true;
|
|
98182
98251
|
});
|
|
@@ -98228,7 +98297,7 @@ function applyGoogleTurnOrderingFix(params) {
|
|
|
98228
98297
|
const sanitized = sanitizeGoogleTurnOrdering(params.messages);
|
|
98229
98298
|
const didPrepend = sanitized !== params.messages;
|
|
98230
98299
|
if (didPrepend && !hasGoogleTurnOrderingMarker(params.sessionManager)) {
|
|
98231
|
-
(params.warn ?? ((message) => log$
|
|
98300
|
+
(params.warn ?? ((message) => log$29.warn(message)))(`google turn ordering fixup: prepended user bootstrap (sessionId=${params.sessionId})`);
|
|
98232
98301
|
markGoogleTurnOrderingMarker(params.sessionManager);
|
|
98233
98302
|
}
|
|
98234
98303
|
return {
|
|
@@ -98645,6 +98714,57 @@ async function flushPendingToolResultsAfterIdle(opts) {
|
|
|
98645
98714
|
opts.sessionManager?.flushPendingToolResults?.();
|
|
98646
98715
|
}
|
|
98647
98716
|
|
|
98717
|
+
//#endregion
|
|
98718
|
+
//#region src/agents/pi-embedded-runner/workspace-cwd.ts
|
|
98719
|
+
const log$3 = createSubsystemLogger("agents/workspace-cwd");
|
|
98720
|
+
const holders = [];
|
|
98721
|
+
let baselineCwd;
|
|
98722
|
+
function readCwd() {
|
|
98723
|
+
try {
|
|
98724
|
+
return process.cwd();
|
|
98725
|
+
} catch (err) {
|
|
98726
|
+
log$3.warn("process.cwd() failed; the working directory was removed under the process", { error: String(err) });
|
|
98727
|
+
return;
|
|
98728
|
+
}
|
|
98729
|
+
}
|
|
98730
|
+
function tryChdir(target) {
|
|
98731
|
+
if (readCwd() === target) return true;
|
|
98732
|
+
try {
|
|
98733
|
+
process.chdir(target);
|
|
98734
|
+
return true;
|
|
98735
|
+
} catch (err) {
|
|
98736
|
+
log$3.error("cwd restore target is gone", {
|
|
98737
|
+
target,
|
|
98738
|
+
error: String(err)
|
|
98739
|
+
});
|
|
98740
|
+
return false;
|
|
98741
|
+
}
|
|
98742
|
+
}
|
|
98743
|
+
/**
|
|
98744
|
+
* The cwd is process-global while embedded runs overlap (`agents.defaults.maxConcurrent`
|
|
98745
|
+
* defaults to 4). Each holder gets the cwd on acquire; on release the cwd goes to the most
|
|
98746
|
+
* recent surviving holder's workspace, and to the baseline the first holder found once none
|
|
98747
|
+
* remain. The returned release never throws: a throw from a caller's finally would skip the
|
|
98748
|
+
* rest of it (e.g. clearActiveEmbeddedRun) and leak the run registry entry.
|
|
98749
|
+
*/
|
|
98750
|
+
function acquireWorkspaceCwd(workspaceDir) {
|
|
98751
|
+
if (holders.length === 0) baselineCwd = readCwd() ?? os.tmpdir();
|
|
98752
|
+
if (readCwd() !== workspaceDir) process.chdir(workspaceDir);
|
|
98753
|
+
const holder = { workspaceDir };
|
|
98754
|
+
holders.push(holder);
|
|
98755
|
+
let released = false;
|
|
98756
|
+
return () => {
|
|
98757
|
+
if (released) return;
|
|
98758
|
+
released = true;
|
|
98759
|
+
const index = holders.indexOf(holder);
|
|
98760
|
+
if (index !== -1) holders.splice(index, 1);
|
|
98761
|
+
for (let i = holders.length - 1; i >= 0; i -= 1) if (tryChdir(holders[i].workspaceDir)) return;
|
|
98762
|
+
const target = baselineCwd ?? os.tmpdir();
|
|
98763
|
+
if (holders.length === 0) baselineCwd = void 0;
|
|
98764
|
+
if (!tryChdir(target) && !tryChdir(os.tmpdir())) log$3.error("tmpdir chdir failed; leaving the process cwd unchanged");
|
|
98765
|
+
};
|
|
98766
|
+
}
|
|
98767
|
+
|
|
98648
98768
|
//#endregion
|
|
98649
98769
|
//#region src/agents/pi-embedded-runner/compact.ts
|
|
98650
98770
|
function createCompactionDiagId$1() {
|
|
@@ -99055,11 +99175,10 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99055
99175
|
compacted: false,
|
|
99056
99176
|
reason: "compaction deferred by context.prune handler"
|
|
99057
99177
|
};
|
|
99058
|
-
const prevCwd = process.cwd();
|
|
99059
99178
|
const provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
99060
99179
|
const modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
99061
99180
|
const fail = (reason) => {
|
|
99062
|
-
log$
|
|
99181
|
+
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}`);
|
|
99063
99182
|
return {
|
|
99064
99183
|
ok: false,
|
|
99065
99184
|
compacted: false,
|
|
@@ -99103,7 +99222,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99103
99222
|
cwd: effectiveWorkspace
|
|
99104
99223
|
});
|
|
99105
99224
|
let restoreSkillEnv;
|
|
99106
|
-
|
|
99225
|
+
const releaseWorkspaceCwd = acquireWorkspaceCwd(effectiveWorkspace);
|
|
99107
99226
|
try {
|
|
99108
99227
|
const shouldLoadSkillEntries = !params.skillsSnapshot || !params.skillsSnapshot.resolvedSkills;
|
|
99109
99228
|
const skillEntries = shouldLoadSkillEntries ? loadWorkspaceSkillEntries(effectiveWorkspace) : [];
|
|
@@ -99139,7 +99258,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99139
99258
|
resolvedSystemPrompt,
|
|
99140
99259
|
warn: makeBootstrapWarn({
|
|
99141
99260
|
sessionLabel,
|
|
99142
|
-
warn: (message) => log$
|
|
99261
|
+
warn: (message) => log$29.warn(message)
|
|
99143
99262
|
})
|
|
99144
99263
|
});
|
|
99145
99264
|
const runAbortController = new AbortController();
|
|
@@ -99281,7 +99400,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99281
99400
|
});
|
|
99282
99401
|
try {
|
|
99283
99402
|
if (isPreservationArmed() || !isJsonlSessionBackend()) {
|
|
99284
|
-
log$
|
|
99403
|
+
log$29.warn(`[compaction-diag] refused transcript repair/open runId=${runId} sessionKey=${params.sessionKey ?? params.sessionId} diagId=${diagId} trigger=${trigger} preservationArmed=${isPreservationArmed()} jsonlBackend=${isJsonlSessionBackend()}`);
|
|
99285
99404
|
return {
|
|
99286
99405
|
ok: true,
|
|
99287
99406
|
compacted: false,
|
|
@@ -99290,7 +99409,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99290
99409
|
}
|
|
99291
99410
|
await repairSessionFileIfNeeded({
|
|
99292
99411
|
sessionFile: params.sessionFile,
|
|
99293
|
-
warn: (message) => log$
|
|
99412
|
+
warn: (message) => log$29.warn(message)
|
|
99294
99413
|
});
|
|
99295
99414
|
await prewarmSessionFile(params.sessionFile);
|
|
99296
99415
|
const transcriptPolicy = resolveTranscriptPolicy({
|
|
@@ -99386,7 +99505,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99386
99505
|
const inputStorageCursor = await loadCompactionStorageCursor({
|
|
99387
99506
|
sessionId: params.sessionId,
|
|
99388
99507
|
sessionKey: params.sessionKey,
|
|
99389
|
-
warn: (message) => log$
|
|
99508
|
+
warn: (message) => log$29.warn(message)
|
|
99390
99509
|
});
|
|
99391
99510
|
const truncated = limitHistoryTurns(validated, getDmHistoryLimitFromSessionKey(params.sessionKey, params.config));
|
|
99392
99511
|
const limited = transcriptPolicy.repairToolUseResultPairing ? sanitizeToolUseResultPairing(truncated) : truncated;
|
|
@@ -99398,7 +99517,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99398
99517
|
tokenWindow,
|
|
99399
99518
|
usage,
|
|
99400
99519
|
storageCursor: inputStorageCursor,
|
|
99401
|
-
warn: (message) => log$
|
|
99520
|
+
warn: (message) => log$29.warn(message)
|
|
99402
99521
|
});
|
|
99403
99522
|
const sanitizedHookMessages = await sanitizeHookCompactionMessages({
|
|
99404
99523
|
messages: cloneCompactionMessages(compactionPlan.messages),
|
|
@@ -99421,7 +99540,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99421
99540
|
messages: transcriptPolicy.validateAnthropicTurns ? validateAnthropicTurns(validatedPlannedGemini) : validatedPlannedGemini,
|
|
99422
99541
|
fallbackMessages: limited,
|
|
99423
99542
|
replacedMessages: compactionPlan.replacedMessages,
|
|
99424
|
-
warn: (message) => log$
|
|
99543
|
+
warn: (message) => log$29.warn(message)
|
|
99425
99544
|
});
|
|
99426
99545
|
const compactionInputMessages = compactionInput.messages;
|
|
99427
99546
|
if (compactionInputMessages.length === 0) return fail(compactionInput.abortReason ?? "compaction input is empty");
|
|
@@ -99432,13 +99551,13 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99432
99551
|
messages: preCompactionMessages,
|
|
99433
99552
|
sessionFile: params.sessionFile
|
|
99434
99553
|
}, hookCtx).catch((hookErr) => {
|
|
99435
|
-
log$
|
|
99554
|
+
log$29.warn(`before_compaction hook failed: ${String(hookErr)}`);
|
|
99436
99555
|
});
|
|
99437
|
-
const diagEnabled = log$
|
|
99556
|
+
const diagEnabled = log$29.isEnabled("debug");
|
|
99438
99557
|
const preMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
99439
99558
|
if (diagEnabled && preMetrics) {
|
|
99440
|
-
log$
|
|
99441
|
-
log$
|
|
99559
|
+
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"}`);
|
|
99560
|
+
log$29.debug(`[compaction-diag] contributors diagId=${diagId} top=${JSON.stringify(preMetrics.contributors)}`);
|
|
99442
99561
|
}
|
|
99443
99562
|
const compactStartedAt = Date.now();
|
|
99444
99563
|
setContextHooksLastCompactionPreparation(sessionManager, void 0);
|
|
@@ -99448,7 +99567,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99448
99567
|
result = await compactWithAbortOnTimeout({
|
|
99449
99568
|
compact: () => session.compact(params.customInstructions),
|
|
99450
99569
|
abort: () => session.abortCompaction(),
|
|
99451
|
-
onAbortSettleTimeout: (err) => log$
|
|
99570
|
+
onAbortSettleTimeout: (err) => log$29.warn(`compaction did not settle after abort: ${String(err)}`)
|
|
99452
99571
|
});
|
|
99453
99572
|
} finally {
|
|
99454
99573
|
setContextHooksPlannedCompaction(sessionManager, void 0);
|
|
@@ -99476,12 +99595,12 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99476
99595
|
compactedCount: compactionInputMessages.length - session.messages.length,
|
|
99477
99596
|
sessionFile: params.sessionFile
|
|
99478
99597
|
}, hookCtx).catch((hookErr) => {
|
|
99479
|
-
log$
|
|
99598
|
+
log$29.warn(`after_compaction hook failed: ${hookErr}`);
|
|
99480
99599
|
});
|
|
99481
99600
|
const outputStorageCursor = await loadCompactionStorageCursor({
|
|
99482
99601
|
sessionId: params.sessionId,
|
|
99483
99602
|
sessionKey: params.sessionKey,
|
|
99484
|
-
warn: (message) => log$
|
|
99603
|
+
warn: (message) => log$29.warn(message)
|
|
99485
99604
|
});
|
|
99486
99605
|
const compactionResult = {
|
|
99487
99606
|
summary: result.summary,
|
|
@@ -99511,10 +99630,10 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99511
99630
|
outputMessageCount: session.messages.length,
|
|
99512
99631
|
replacedMessages: compactionReplacementApplied,
|
|
99513
99632
|
result: compactionResult,
|
|
99514
|
-
warn: (message) => log$
|
|
99633
|
+
warn: (message) => log$29.warn(message)
|
|
99515
99634
|
});
|
|
99516
99635
|
const postMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
99517
|
-
if (diagEnabled && preMetrics && postMetrics) log$
|
|
99636
|
+
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"}`);
|
|
99518
99637
|
return {
|
|
99519
99638
|
ok: true,
|
|
99520
99639
|
compacted: true,
|
|
@@ -99543,7 +99662,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99543
99662
|
return fail(describeUnknownError(err));
|
|
99544
99663
|
} finally {
|
|
99545
99664
|
restoreSkillEnv?.();
|
|
99546
|
-
|
|
99665
|
+
releaseWorkspaceCwd();
|
|
99547
99666
|
}
|
|
99548
99667
|
}
|
|
99549
99668
|
/**
|
|
@@ -99667,15 +99786,15 @@ function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
|
99667
99786
|
if (transport === "sse" || transport === "websocket" || transport === "auto") streamParams.transport = transport;
|
|
99668
99787
|
else if (transport != null) {
|
|
99669
99788
|
const transportSummary = typeof transport === "string" ? transport : typeof transport;
|
|
99670
|
-
log$
|
|
99789
|
+
log$29.warn(`ignoring invalid transport param: ${transportSummary}`);
|
|
99671
99790
|
}
|
|
99672
99791
|
if (typeof extraParams.openaiWsWarmup === "boolean") streamParams.openaiWsWarmup = extraParams.openaiWsWarmup;
|
|
99673
99792
|
const cacheRetention = resolveCacheRetention(extraParams, provider);
|
|
99674
99793
|
if (cacheRetention) streamParams.cacheRetention = cacheRetention;
|
|
99675
99794
|
const providerRouting = provider === "openrouter" && extraParams.provider != null && typeof extraParams.provider === "object" ? extraParams.provider : void 0;
|
|
99676
99795
|
if (Object.keys(streamParams).length === 0 && !providerRouting) return;
|
|
99677
|
-
log$
|
|
99678
|
-
if (providerRouting) log$
|
|
99796
|
+
log$29.debug(`creating streamFn wrapper with params: ${JSON.stringify(streamParams)}`);
|
|
99797
|
+
if (providerRouting) log$29.debug(`OpenRouter provider routing: ${JSON.stringify(providerRouting)}`);
|
|
99679
99798
|
const underlying = baseStreamFn ?? streamSimple;
|
|
99680
99799
|
const wrappedStreamFn = (model, context, options) => {
|
|
99681
99800
|
return underlying(providerRouting ? {
|
|
@@ -99797,7 +99916,7 @@ function resolveAnthropicBetas(extraParams, provider, modelId) {
|
|
|
99797
99916
|
for (const beta of configured) if (typeof beta === "string" && beta.trim()) betas.add(beta.trim());
|
|
99798
99917
|
}
|
|
99799
99918
|
if (extraParams?.context1m === true) if (isAnthropic1MModel(modelId)) betas.add(ANTHROPIC_CONTEXT_1M_BETA);
|
|
99800
|
-
else log$
|
|
99919
|
+
else log$29.warn(`ignoring context1m for non-opus/sonnet model: ${provider}/${modelId}`);
|
|
99801
99920
|
return betas.size > 0 ? [...betas] : void 0;
|
|
99802
99921
|
}
|
|
99803
99922
|
function mergeAnthropicBetaHeader(headers, betas) {
|
|
@@ -99824,7 +99943,7 @@ function createAnthropicBetaHeadersWrapper(baseStreamFn, betas) {
|
|
|
99824
99943
|
const isOauth = isAnthropicOAuthApiKey(options?.apiKey);
|
|
99825
99944
|
const requestedContext1m = betas.includes(ANTHROPIC_CONTEXT_1M_BETA);
|
|
99826
99945
|
const effectiveBetas = isOauth && requestedContext1m ? betas.filter((beta) => beta !== ANTHROPIC_CONTEXT_1M_BETA) : betas;
|
|
99827
|
-
if (isOauth && requestedContext1m) log$
|
|
99946
|
+
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`);
|
|
99828
99947
|
const piAiBetas = isOauth ? PI_AI_OAUTH_ANTHROPIC_BETAS : PI_AI_DEFAULT_ANTHROPIC_BETAS;
|
|
99829
99948
|
const allBetas = [...new Set([...piAiBetas, ...effectiveBetas])];
|
|
99830
99949
|
return underlying(model, context, {
|
|
@@ -100185,12 +100304,12 @@ function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverr
|
|
|
100185
100304
|
};
|
|
100186
100305
|
const wrappedStreamFn = createStreamFnWithExtraParams(agent.streamFn, merged, provider);
|
|
100187
100306
|
if (wrappedStreamFn) {
|
|
100188
|
-
log$
|
|
100307
|
+
log$29.debug(`applying extraParams to agent streamFn for ${provider}/${modelId}`);
|
|
100189
100308
|
agent.streamFn = wrappedStreamFn;
|
|
100190
100309
|
}
|
|
100191
100310
|
const anthropicBetas = resolveAnthropicBetas(merged, provider, modelId);
|
|
100192
100311
|
if (anthropicBetas?.length) {
|
|
100193
|
-
log$
|
|
100312
|
+
log$29.debug(`applying Anthropic beta header for ${provider}/${modelId}: ${anthropicBetas.join(",")}`);
|
|
100194
100313
|
agent.streamFn = createAnthropicBetaHeadersWrapper(agent.streamFn, anthropicBetas);
|
|
100195
100314
|
}
|
|
100196
100315
|
if (shouldApplySiliconFlowThinkingOffCompat({
|
|
@@ -100198,7 +100317,7 @@ function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverr
|
|
|
100198
100317
|
modelId,
|
|
100199
100318
|
thinkingLevel
|
|
100200
100319
|
})) {
|
|
100201
|
-
log$
|
|
100320
|
+
log$29.debug(`normalizing thinking=off to thinking=null for SiliconFlow compatibility (${provider}/${modelId})`);
|
|
100202
100321
|
agent.streamFn = createSiliconFlowThinkingWrapper(agent.streamFn);
|
|
100203
100322
|
}
|
|
100204
100323
|
if (provider === "moonshot") {
|
|
@@ -100206,22 +100325,22 @@ function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverr
|
|
|
100206
100325
|
configuredThinking: merged?.thinking,
|
|
100207
100326
|
thinkingLevel
|
|
100208
100327
|
});
|
|
100209
|
-
if (moonshotThinkingType) log$
|
|
100328
|
+
if (moonshotThinkingType) log$29.debug(`applying Moonshot thinking=${moonshotThinkingType} payload wrapper for ${provider}/${modelId}`);
|
|
100210
100329
|
agent.streamFn = createMoonshotThinkingWrapper(agent.streamFn, moonshotThinkingType);
|
|
100211
100330
|
}
|
|
100212
100331
|
if (provider === "openrouter") {
|
|
100213
|
-
log$
|
|
100332
|
+
log$29.debug(`applying OpenRouter app attribution headers for ${provider}/${modelId}`);
|
|
100214
100333
|
const openRouterThinkingLevel = modelId === "auto" || isOpenRouterReasoningUnsupported(modelId) ? void 0 : thinkingLevel;
|
|
100215
100334
|
agent.streamFn = createOpenRouterWrapper(agent.streamFn, openRouterThinkingLevel);
|
|
100216
100335
|
agent.streamFn = createOpenRouterSystemCacheWrapper(agent.streamFn);
|
|
100217
100336
|
}
|
|
100218
100337
|
if (provider === "amazon-bedrock" && !isAnthropicBedrockModel(modelId)) {
|
|
100219
|
-
log$
|
|
100338
|
+
log$29.debug(`disabling prompt caching for non-Anthropic Bedrock model ${provider}/${modelId}`);
|
|
100220
100339
|
agent.streamFn = createBedrockNoCacheWrapper(agent.streamFn);
|
|
100221
100340
|
}
|
|
100222
100341
|
if (provider === "zai" || provider === "z-ai") {
|
|
100223
100342
|
if (merged?.tool_stream !== false) {
|
|
100224
|
-
log$
|
|
100343
|
+
log$29.debug(`enabling Z.AI tool_stream for ${provider}/${modelId}`);
|
|
100225
100344
|
agent.streamFn = createZaiToolStreamWrapper(agent.streamFn, true);
|
|
100226
100345
|
}
|
|
100227
100346
|
}
|
|
@@ -100913,7 +101032,7 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
100913
101032
|
if (!session.manager.isConnected() && !session.broken) try {
|
|
100914
101033
|
await session.manager.connect(apiKey);
|
|
100915
101034
|
session.everConnected = true;
|
|
100916
|
-
log$
|
|
101035
|
+
log$29.debug(`[ws-stream] connected for session=${sessionId}`);
|
|
100917
101036
|
} catch (connErr) {
|
|
100918
101037
|
try {
|
|
100919
101038
|
session.manager.close();
|
|
@@ -100921,12 +101040,12 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
100921
101040
|
session.broken = true;
|
|
100922
101041
|
wsRegistry.delete(sessionId);
|
|
100923
101042
|
if (transport === "websocket") throw connErr instanceof Error ? connErr : new Error(String(connErr));
|
|
100924
|
-
log$
|
|
101043
|
+
log$29.warn(`[ws-stream] WebSocket connect failed for session=${sessionId}; falling back to HTTP. error=${String(connErr)}`);
|
|
100925
101044
|
return fallbackToHttp(model, context, options, eventStream, apiKey, opts.signal);
|
|
100926
101045
|
}
|
|
100927
101046
|
if (session.broken || !session.manager.isConnected()) {
|
|
100928
101047
|
if (transport === "websocket") throw new Error("WebSocket session disconnected");
|
|
100929
|
-
log$
|
|
101048
|
+
log$29.warn(`[ws-stream] session=${sessionId} broken/disconnected; falling back to HTTP`);
|
|
100930
101049
|
try {
|
|
100931
101050
|
session.manager.close();
|
|
100932
101051
|
} catch {}
|
|
@@ -100944,10 +101063,10 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
100944
101063
|
instructions: context.systemPrompt ?? void 0,
|
|
100945
101064
|
signal
|
|
100946
101065
|
});
|
|
100947
|
-
log$
|
|
101066
|
+
log$29.debug(`[ws-stream] warm-up completed for session=${sessionId}`);
|
|
100948
101067
|
} catch (warmErr) {
|
|
100949
101068
|
if (signal?.aborted) throw warmErr instanceof Error ? warmErr : new Error(String(warmErr));
|
|
100950
|
-
log$
|
|
101069
|
+
log$29.warn(`[ws-stream] warm-up failed for session=${sessionId}; continuing without warm-up. error=${String(warmErr)}`);
|
|
100951
101070
|
}
|
|
100952
101071
|
}
|
|
100953
101072
|
const prevResponseId = session.manager.previousResponseId;
|
|
@@ -100955,13 +101074,13 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
100955
101074
|
if (prevResponseId && session.lastContextLength > 0) {
|
|
100956
101075
|
const toolResults = context.messages.slice(session.lastContextLength).filter((m) => m.role === "toolResult");
|
|
100957
101076
|
if (toolResults.length === 0) {
|
|
100958
|
-
log$
|
|
101077
|
+
log$29.debug(`[ws-stream] session=${sessionId}: no new tool results found; sending full context`);
|
|
100959
101078
|
inputItems = buildFullInput(context);
|
|
100960
101079
|
} else inputItems = convertMessagesToInputItems(toolResults);
|
|
100961
|
-
log$
|
|
101080
|
+
log$29.debug(`[ws-stream] session=${sessionId}: incremental send (${inputItems.length} tool results) previous_response_id=${prevResponseId}`);
|
|
100962
101081
|
} else {
|
|
100963
101082
|
inputItems = buildFullInput(context);
|
|
100964
|
-
log$
|
|
101083
|
+
log$29.debug(`[ws-stream] session=${sessionId}: full context send (${inputItems.length} items)`);
|
|
100965
101084
|
}
|
|
100966
101085
|
const tools = convertTools(context.tools);
|
|
100967
101086
|
const streamOpts = options;
|
|
@@ -100991,7 +101110,7 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
100991
101110
|
session.manager.send(payload);
|
|
100992
101111
|
} catch (sendErr) {
|
|
100993
101112
|
if (transport === "websocket") throw sendErr instanceof Error ? sendErr : new Error(String(sendErr));
|
|
100994
|
-
log$
|
|
101113
|
+
log$29.warn(`[ws-stream] send failed for session=${sessionId}; falling back to HTTP. error=${String(sendErr)}`);
|
|
100995
101114
|
try {
|
|
100996
101115
|
session.manager.close();
|
|
100997
101116
|
} catch {}
|
|
@@ -101071,7 +101190,7 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
101071
101190
|
};
|
|
101072
101191
|
queueMicrotask(() => run().catch((err) => {
|
|
101073
101192
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
101074
|
-
log$
|
|
101193
|
+
log$29.warn(`[ws-stream] session=${sessionId} run error: ${errorMessage}`);
|
|
101075
101194
|
eventStream.push({
|
|
101076
101195
|
type: "error",
|
|
101077
101196
|
reason: "error",
|
|
@@ -103121,7 +103240,7 @@ function normalizeRefForDedupe(raw) {
|
|
|
103121
103240
|
}
|
|
103122
103241
|
async function sanitizeImagesWithLog(images, label, imageSanitization) {
|
|
103123
103242
|
const { images: sanitized, dropped } = await sanitizeImageBlocks(images, label, imageSanitization);
|
|
103124
|
-
if (dropped > 0) log$
|
|
103243
|
+
if (dropped > 0) log$29.warn(`Native image: dropped ${dropped} image(s) after sanitization (${label}).`);
|
|
103125
103244
|
return sanitized;
|
|
103126
103245
|
}
|
|
103127
103246
|
/**
|
|
@@ -103208,7 +103327,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
103208
103327
|
mediaPath: targetPath
|
|
103209
103328
|
})).resolved;
|
|
103210
103329
|
} catch (err) {
|
|
103211
|
-
log$
|
|
103330
|
+
log$29.debug(`Native image: sandbox validation failed for ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
103212
103331
|
return null;
|
|
103213
103332
|
}
|
|
103214
103333
|
else if (!path.isAbsolute(targetPath)) targetPath = path.resolve(workspaceDir, targetPath);
|
|
@@ -103226,7 +103345,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
103226
103345
|
readFile: createSandboxBridgeReadFile({ sandbox: options.sandbox })
|
|
103227
103346
|
}) : await loadWebMedia(targetPath, options?.maxBytes);
|
|
103228
103347
|
if (media.kind !== "image") {
|
|
103229
|
-
log$
|
|
103348
|
+
log$29.debug(`Native image: not an image file: ${targetPath} (got ${media.kind})`);
|
|
103230
103349
|
return null;
|
|
103231
103350
|
}
|
|
103232
103351
|
const mimeType = media.contentType ?? "image/jpeg";
|
|
@@ -103236,7 +103355,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
103236
103355
|
mimeType
|
|
103237
103356
|
};
|
|
103238
103357
|
} catch (err) {
|
|
103239
|
-
log$
|
|
103358
|
+
log$29.debug(`Native image: failed to load ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
103240
103359
|
return null;
|
|
103241
103360
|
}
|
|
103242
103361
|
}
|
|
@@ -103273,7 +103392,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
103273
103392
|
loadedCount: 0,
|
|
103274
103393
|
skippedCount: 0
|
|
103275
103394
|
};
|
|
103276
|
-
log$
|
|
103395
|
+
log$29.debug(`Native image: detected ${allRefs.length} image refs in prompt`);
|
|
103277
103396
|
const promptImages = [...params.existingImages ?? []];
|
|
103278
103397
|
let loadedCount = 0;
|
|
103279
103398
|
let skippedCount = 0;
|
|
@@ -103286,7 +103405,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
103286
103405
|
if (image) {
|
|
103287
103406
|
promptImages.push(image);
|
|
103288
103407
|
loadedCount++;
|
|
103289
|
-
log$
|
|
103408
|
+
log$29.debug(`Native image: loaded ${ref.type} ${ref.resolved}`);
|
|
103290
103409
|
} else skippedCount++;
|
|
103291
103410
|
}
|
|
103292
103411
|
return {
|
|
@@ -103901,7 +104020,7 @@ async function buildStreamFn(params) {
|
|
|
103901
104020
|
const wsApiKey = await params.authStorage.getApiKey(params.provider);
|
|
103902
104021
|
if (wsApiKey) streamFn = createOpenAIWebSocketStreamFn(wsApiKey, params.sessionId, { signal: params.abortSignal });
|
|
103903
104022
|
else {
|
|
103904
|
-
log$
|
|
104023
|
+
log$29.warn(`[ws-stream] no API key for provider=${params.provider}; using HTTP transport`);
|
|
103905
104024
|
streamFn = streamSimple;
|
|
103906
104025
|
}
|
|
103907
104026
|
} else {
|
|
@@ -104004,13 +104123,13 @@ async function resolvePromptBuildHookResult(params) {
|
|
|
104004
104123
|
messages: params.messages,
|
|
104005
104124
|
systemPrompt: params.systemPrompt
|
|
104006
104125
|
}, params.hookCtx).catch((hookErr) => {
|
|
104007
|
-
log$
|
|
104126
|
+
log$29.warn(`before_prompt_build hook failed: ${String(hookErr)}`);
|
|
104008
104127
|
}) : void 0;
|
|
104009
104128
|
const legacyResult = params.legacyBeforeAgentStartResult ?? (params.hookRunner?.hasHooks("before_agent_start") ? await params.hookRunner.runBeforeAgentStart({
|
|
104010
104129
|
prompt: params.prompt,
|
|
104011
104130
|
messages: params.messages
|
|
104012
104131
|
}, params.hookCtx).catch((hookErr) => {
|
|
104013
|
-
log$
|
|
104132
|
+
log$29.warn(`before_agent_start hook (legacy prompt build path) failed: ${String(hookErr)}`);
|
|
104014
104133
|
}) : void 0);
|
|
104015
104134
|
return {
|
|
104016
104135
|
systemPrompt: promptBuildResult?.systemPrompt ?? legacyResult?.systemPrompt,
|
|
@@ -104148,7 +104267,7 @@ async function collectAttemptPromptContribution(params) {
|
|
|
104148
104267
|
messages: params.messages,
|
|
104149
104268
|
envelope: params.envelope
|
|
104150
104269
|
}, params.lifecycleCtx).catch((hookErr) => {
|
|
104151
|
-
log$
|
|
104270
|
+
log$29.warn(`context.collect hook failed: ${String(hookErr)}`);
|
|
104152
104271
|
}) : void 0;
|
|
104153
104272
|
return mergePromptContributions([promptBuildResultToContribution(legacyResult), contextCollectResult]);
|
|
104154
104273
|
}
|
|
@@ -104163,7 +104282,7 @@ async function runContextProjectionAndPruningHooks(params) {
|
|
|
104163
104282
|
contributions: params.contributions,
|
|
104164
104283
|
envelope: params.envelope
|
|
104165
104284
|
}, params.lifecycleCtx).catch((hookErr) => {
|
|
104166
|
-
log$
|
|
104285
|
+
log$29.warn(`context.project hook failed: ${String(hookErr)}`);
|
|
104167
104286
|
});
|
|
104168
104287
|
if (result?.messages) currentMessages = result.messages;
|
|
104169
104288
|
if (result?.projection) projection = {
|
|
@@ -104179,7 +104298,7 @@ async function runContextProjectionAndPruningHooks(params) {
|
|
|
104179
104298
|
tokenWindow: params.lifecycleCtx.tokenWindow,
|
|
104180
104299
|
usage: params.lifecycleCtx.usage
|
|
104181
104300
|
}, params.lifecycleCtx).catch((hookErr) => {
|
|
104182
|
-
log$
|
|
104301
|
+
log$29.warn(`context.prune hook failed: ${String(hookErr)}`);
|
|
104183
104302
|
});
|
|
104184
104303
|
if (result?.messages) currentMessages = result.messages;
|
|
104185
104304
|
if (result?.dropped) dropped.push(...result.dropped);
|
|
@@ -104281,7 +104400,7 @@ function installAttemptInputTransform(params) {
|
|
|
104281
104400
|
runtime: params.projectionRuntime,
|
|
104282
104401
|
timeoutMs: params.projectionArtifactTimeoutMs
|
|
104283
104402
|
}).catch((err) => {
|
|
104284
|
-
log$
|
|
104403
|
+
log$29.warn(`context projection artifact persist failed: ${String(err)}`);
|
|
104285
104404
|
});
|
|
104286
104405
|
const finalMessages = await runTransformLlmInputHooks({
|
|
104287
104406
|
messages: currentMessages,
|
|
@@ -104290,7 +104409,7 @@ function installAttemptInputTransform(params) {
|
|
|
104290
104409
|
provider: params.provider,
|
|
104291
104410
|
modelId: params.modelId
|
|
104292
104411
|
}).catch((err) => {
|
|
104293
|
-
log$
|
|
104412
|
+
log$29.warn(`transform_llm_input hook failed: ${String(err)}`);
|
|
104294
104413
|
}) ?? currentMessages;
|
|
104295
104414
|
params.onFinalInputMessages?.(finalMessages);
|
|
104296
104415
|
return finalMessages;
|
|
@@ -104408,11 +104527,10 @@ function summarizeSessionContext(messages) {
|
|
|
104408
104527
|
}
|
|
104409
104528
|
async function runEmbeddedAttempt(params) {
|
|
104410
104529
|
const resolvedWorkspace = resolveUserPath(params.workspaceDir);
|
|
104411
|
-
const prevCwd = process.cwd();
|
|
104412
104530
|
let pendingClearActiveEmbeddedRun;
|
|
104413
104531
|
const runAbortController = new AbortController();
|
|
104414
104532
|
const currentUserTurnForStorage = resolveCurrentUserTurnForStorage(params);
|
|
104415
|
-
log$
|
|
104533
|
+
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"}`);
|
|
104416
104534
|
await fs.mkdir(resolvedWorkspace, { recursive: true });
|
|
104417
104535
|
const sandboxSessionKey = params.sessionKey?.trim() || params.sessionId;
|
|
104418
104536
|
const toolSessionKey = params.toolSessionKey?.trim() || sandboxSessionKey;
|
|
@@ -104425,7 +104543,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
104425
104543
|
const effectiveWorkspace = sandbox?.enabled ? sandbox.workspaceAccess === "rw" ? resolvedWorkspace : sandbox.workspaceDir : resolvedWorkspace;
|
|
104426
104544
|
await fs.mkdir(effectiveWorkspace, { recursive: true });
|
|
104427
104545
|
let restoreSkillEnv;
|
|
104428
|
-
|
|
104546
|
+
const releaseWorkspaceCwd = params.skipCwdChange ? void 0 : acquireWorkspaceCwd(effectiveWorkspace);
|
|
104429
104547
|
try {
|
|
104430
104548
|
const skillWorkspace = params.skillWorkspaceDir ?? effectiveWorkspace;
|
|
104431
104549
|
const shouldLoadSkillEntries = !params.skipSkillEnv && (!params.skillsSnapshot || !params.skillsSnapshot.resolvedSkills);
|
|
@@ -104467,7 +104585,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
104467
104585
|
resolvedSystemPrompt,
|
|
104468
104586
|
warn: makeBootstrapWarn({
|
|
104469
104587
|
sessionLabel,
|
|
104470
|
-
warn: (message) => log$
|
|
104588
|
+
warn: (message) => log$29.warn(message)
|
|
104471
104589
|
}),
|
|
104472
104590
|
contextMode: params.bootstrapContextMode,
|
|
104473
104591
|
runKind: params.bootstrapContextRunKind,
|
|
@@ -104709,7 +104827,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
104709
104827
|
if (queue != null) {
|
|
104710
104828
|
await drainPendingPrimaryWrites(queue, 3e4, storage?.config.fallbackToJsonlOnError ?? false);
|
|
104711
104829
|
if (storage?.runtime?.conversation?.upsertTurn) await storage.runtime.conversation.upsertTurn(params.sessionId).catch((err) => {
|
|
104712
|
-
log$
|
|
104830
|
+
log$29.warn("turn upsert failed (non-fatal)", {
|
|
104713
104831
|
sessionId: params.sessionId,
|
|
104714
104832
|
err
|
|
104715
104833
|
});
|
|
@@ -104777,14 +104895,14 @@ async function runEmbeddedAttempt(params) {
|
|
|
104777
104895
|
sessionManager = _wrapped.sm;
|
|
104778
104896
|
_primaryWriteQueue = _wrapped.queue;
|
|
104779
104897
|
}
|
|
104780
|
-
} else log$
|
|
104898
|
+
} 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", {
|
|
104781
104899
|
sessionId: params.sessionId,
|
|
104782
104900
|
backend: _configuredStorage?.runtime?.backend
|
|
104783
104901
|
});
|
|
104784
104902
|
} else {
|
|
104785
104903
|
await repairSessionFileIfNeeded({
|
|
104786
104904
|
sessionFile: params.sessionFile,
|
|
104787
|
-
warn: (message) => log$
|
|
104905
|
+
warn: (message) => log$29.warn(message)
|
|
104788
104906
|
});
|
|
104789
104907
|
const hadSessionFile = await fs.stat(params.sessionFile).then(() => true).catch(() => false);
|
|
104790
104908
|
if (!params.skipSessionManagerCache) await prewarmSessionFile(params.sessionFile);
|
|
@@ -104925,7 +105043,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
104925
105043
|
const wsApiKey = await params.authStorage.getApiKey(params.provider);
|
|
104926
105044
|
if (wsApiKey) activeSession.agent.streamFn = createOpenAIWebSocketStreamFn(wsApiKey, params.sessionId, { signal: runAbortController.signal });
|
|
104927
105045
|
else {
|
|
104928
|
-
log$
|
|
105046
|
+
log$29.warn(`[ws-stream] no API key for provider=${params.provider}; using HTTP transport`);
|
|
104929
105047
|
activeSession.agent.streamFn = streamSimple;
|
|
104930
105048
|
}
|
|
104931
105049
|
} else {
|
|
@@ -105125,7 +105243,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105125
105243
|
let abortWarnTimer;
|
|
105126
105244
|
const isProbeSession = params.sessionId?.startsWith("probe-") ?? false;
|
|
105127
105245
|
const abortTimer = setTimeout(() => {
|
|
105128
|
-
if (!isProbeSession) log$
|
|
105246
|
+
if (!isProbeSession) log$29.warn(`embedded run timeout: runId=${params.runId} sessionId=${params.sessionId} timeoutMs=${params.timeoutMs}`);
|
|
105129
105247
|
if (shouldFlagCompactionTimeout({
|
|
105130
105248
|
isTimeout: true,
|
|
105131
105249
|
isCompactionPendingOrRetrying: subscription.isCompacting(),
|
|
@@ -105134,7 +105252,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105134
105252
|
abortRun(true);
|
|
105135
105253
|
if (!abortWarnTimer) abortWarnTimer = setTimeout(() => {
|
|
105136
105254
|
if (!activeSession.isStreaming) return;
|
|
105137
|
-
if (!isProbeSession) log$
|
|
105255
|
+
if (!isProbeSession) log$29.warn(`embedded run abort still streaming: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105138
105256
|
}, 1e4);
|
|
105139
105257
|
}, Math.max(1, params.timeoutMs));
|
|
105140
105258
|
let messagesSnapshot = [];
|
|
@@ -105168,7 +105286,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105168
105286
|
let timeoutHandle;
|
|
105169
105287
|
const timeout = new Promise((resolve) => {
|
|
105170
105288
|
timeoutHandle = setTimeout(() => {
|
|
105171
|
-
log$
|
|
105289
|
+
log$29.warn(`${label} timed out after ${metaTimeoutMs}ms`);
|
|
105172
105290
|
resolve(void 0);
|
|
105173
105291
|
}, metaTimeoutMs);
|
|
105174
105292
|
timeoutHandle.unref?.();
|
|
@@ -105176,7 +105294,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105176
105294
|
try {
|
|
105177
105295
|
return await Promise.race([p, timeout]);
|
|
105178
105296
|
} catch (err) {
|
|
105179
|
-
log$
|
|
105297
|
+
log$29.warn(`${label} failed: ${String(err)}`);
|
|
105180
105298
|
return;
|
|
105181
105299
|
} finally {
|
|
105182
105300
|
if (timeoutHandle !== void 0) clearTimeout(timeoutHandle);
|
|
@@ -105201,14 +105319,14 @@ async function runEmbeddedAttempt(params) {
|
|
|
105201
105319
|
senderIdentity,
|
|
105202
105320
|
workspaceLane: params.workspaceLane
|
|
105203
105321
|
});
|
|
105204
|
-
log$
|
|
105322
|
+
log$29.debug(`embedded run prompt start: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105205
105323
|
const leafEntry = sessionManager.getLeafEntry();
|
|
105206
105324
|
if (leafEntry?.type === "message" && leafEntry.message.role === "user") {
|
|
105207
105325
|
if (leafEntry.parentId) sessionManager.branch(leafEntry.parentId);
|
|
105208
105326
|
else sessionManager.resetLeaf();
|
|
105209
105327
|
const sessionContext = sessionManager.buildSessionContext();
|
|
105210
105328
|
activeSession.agent.state.messages = sessionContext.messages;
|
|
105211
|
-
log$
|
|
105329
|
+
log$29.warn(`Removed orphaned user message to prevent consecutive user turns. runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105212
105330
|
}
|
|
105213
105331
|
const cleanUserMessage = createCleanUserMessageFromPrompt(params.prompt);
|
|
105214
105332
|
const baseEnvelope = createCurrentUserPromptEnvelope({ cleanUserMessage });
|
|
@@ -105237,7 +105355,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105237
105355
|
const contributedSystemPrompt = applySystemPromptContribution(systemPromptText, promptContribution);
|
|
105238
105356
|
if (contributedSystemPrompt !== systemPromptText) {
|
|
105239
105357
|
applySystemPromptOverrideToSession(activeSession, contributedSystemPrompt);
|
|
105240
|
-
log$
|
|
105358
|
+
log$29.debug(`hooks: augmented system prompt (+${contributedSystemPrompt.length - systemPromptText.length} chars)`);
|
|
105241
105359
|
systemPromptText = contributedSystemPrompt;
|
|
105242
105360
|
}
|
|
105243
105361
|
cacheTrace?.recordStage("prompt:before", {
|
|
@@ -105269,12 +105387,12 @@ async function runEmbeddedAttempt(params) {
|
|
|
105269
105387
|
messages: activeSession.messages,
|
|
105270
105388
|
note: `images: prompt=${imageResult.images.length}`
|
|
105271
105389
|
});
|
|
105272
|
-
if (log$
|
|
105390
|
+
if (log$29.isEnabled("debug")) {
|
|
105273
105391
|
const msgCount = activeSession.messages.length;
|
|
105274
105392
|
const systemLen = systemPromptText?.length ?? 0;
|
|
105275
105393
|
const promptLen = effectivePrompt.length;
|
|
105276
105394
|
const sessionSummary = summarizeSessionContext(activeSession.messages);
|
|
105277
|
-
log$
|
|
105395
|
+
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}`);
|
|
105278
105396
|
}
|
|
105279
105397
|
if (hookRunner?.hasHooks("llm_input")) hookRunner.runLlmInput({
|
|
105280
105398
|
runId: params.runId,
|
|
@@ -105286,7 +105404,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105286
105404
|
historyMessages: activeSession.messages,
|
|
105287
105405
|
imagesCount: imageResult.images.length
|
|
105288
105406
|
}, hookCtx).catch((err) => {
|
|
105289
|
-
log$
|
|
105407
|
+
log$29.warn(`llm_input hook failed: ${String(err)}`);
|
|
105290
105408
|
});
|
|
105291
105409
|
const modelUserMessage = appendPromptImagesToUserMessage(renderedCurrentUserPrompt.modelUserMessage, imageResult.images);
|
|
105292
105410
|
const currentPromptIndex = activeSession.messages.length;
|
|
@@ -105329,7 +105447,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105329
105447
|
errorType: String(err instanceof Error ? err.name : "UnknownError")
|
|
105330
105448
|
});
|
|
105331
105449
|
} finally {
|
|
105332
|
-
log$
|
|
105450
|
+
log$29.debug(`embedded run prompt end: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - promptStartedAt}`);
|
|
105333
105451
|
}
|
|
105334
105452
|
const wasCompactingBefore = activeSession.isCompacting;
|
|
105335
105453
|
const snapshot = activeSession.messages.slice();
|
|
@@ -105344,7 +105462,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105344
105462
|
promptError = err;
|
|
105345
105463
|
promptErrorSource = "compaction";
|
|
105346
105464
|
}
|
|
105347
|
-
if (!isProbeSession) log$
|
|
105465
|
+
if (!isProbeSession) log$29.debug(`compaction wait aborted: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105348
105466
|
} else throw err;
|
|
105349
105467
|
}
|
|
105350
105468
|
const compactionOccurredThisAttempt = getCompactionCount() > 0;
|
|
@@ -105363,7 +105481,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105363
105481
|
currentSessionId: activeSession.sessionId
|
|
105364
105482
|
});
|
|
105365
105483
|
if (timedOutDuringCompaction) {
|
|
105366
|
-
if (!isProbeSession) log$
|
|
105484
|
+
if (!isProbeSession) log$29.warn(`using ${snapshotSelection.source} snapshot: timed out during compaction runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105367
105485
|
}
|
|
105368
105486
|
messagesSnapshot = snapshotSelection.messagesSnapshot;
|
|
105369
105487
|
sessionIdUsed = snapshotSelection.sessionIdUsed;
|
|
@@ -105378,7 +105496,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105378
105496
|
error: describeUnknownError(promptError)
|
|
105379
105497
|
});
|
|
105380
105498
|
} catch (entryErr) {
|
|
105381
|
-
log$
|
|
105499
|
+
log$29.warn(`failed to persist prompt error entry: ${String(entryErr)}`);
|
|
105382
105500
|
}
|
|
105383
105501
|
if (!params.skipTranscriptSync) await drainOrSyncTranscript(_primaryWriteQueue, _isDbBackend, _configuredStorage, {
|
|
105384
105502
|
agentId: hookAgentIdForTranscript,
|
|
@@ -105398,16 +105516,16 @@ async function runEmbeddedAttempt(params) {
|
|
|
105398
105516
|
error: promptError ? describeUnknownError(promptError) : void 0,
|
|
105399
105517
|
durationMs: Date.now() - promptStartedAt
|
|
105400
105518
|
}, hookCtx).catch((err) => {
|
|
105401
|
-
log$
|
|
105519
|
+
log$29.warn(`agent_end hook failed: ${err}`);
|
|
105402
105520
|
});
|
|
105403
105521
|
} finally {
|
|
105404
105522
|
clearTimeout(abortTimer);
|
|
105405
105523
|
if (abortWarnTimer) clearTimeout(abortWarnTimer);
|
|
105406
|
-
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$
|
|
105524
|
+
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$29.debug(`run cleanup: runId=${params.runId} sessionId=${params.sessionId} aborted=${aborted} timedOut=${timedOut}`);
|
|
105407
105525
|
try {
|
|
105408
105526
|
unsubscribe();
|
|
105409
105527
|
} catch (err) {
|
|
105410
|
-
log$
|
|
105528
|
+
log$29.error(`CRITICAL: unsubscribe failed, possible resource leak: runId=${params.runId} ${String(err)}`);
|
|
105411
105529
|
}
|
|
105412
105530
|
pendingClearActiveEmbeddedRun = () => clearActiveEmbeddedRun(params.sessionId, queueHandle, params.sessionKey, !aborted && !timedOut && !promptError);
|
|
105413
105531
|
params.abortSignal?.removeEventListener?.("abort", onAbort);
|
|
@@ -105445,7 +105563,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105445
105563
|
workspaceLane: params.workspaceLane,
|
|
105446
105564
|
runId: params.runId
|
|
105447
105565
|
})).catch((err) => {
|
|
105448
|
-
log$
|
|
105566
|
+
log$29.warn(`model_call_ended hook failed: ${String(err)}`);
|
|
105449
105567
|
});
|
|
105450
105568
|
proxyMetadataFromHook = modelCallEndedEvent.proxyMetadata;
|
|
105451
105569
|
}
|
|
@@ -105469,7 +105587,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105469
105587
|
workspaceLane: params.workspaceLane,
|
|
105470
105588
|
runId: params.runId
|
|
105471
105589
|
})).catch((err) => {
|
|
105472
|
-
log$
|
|
105590
|
+
log$29.warn(`llm_output hook failed: ${String(err)}`);
|
|
105473
105591
|
});
|
|
105474
105592
|
return {
|
|
105475
105593
|
aborted,
|
|
@@ -105512,7 +105630,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105512
105630
|
if (_primaryWriteQueue != null && _primaryWriteQueue.length > 0) try {
|
|
105513
105631
|
await drainPendingPrimaryWrites(_primaryWriteQueue, 5e3, _configuredStorage?.config.fallbackToJsonlOnError ?? false);
|
|
105514
105632
|
} catch (cleanupDrainErr) {
|
|
105515
|
-
log$
|
|
105633
|
+
log$29.error("cleanup drain failed in finally; session entries may be lost", {
|
|
105516
105634
|
sessionId: params.sessionId,
|
|
105517
105635
|
error: cleanupDrainErr
|
|
105518
105636
|
});
|
|
@@ -105524,7 +105642,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105524
105642
|
}
|
|
105525
105643
|
} finally {
|
|
105526
105644
|
restoreSkillEnv?.();
|
|
105527
|
-
|
|
105645
|
+
releaseWorkspaceCwd?.();
|
|
105528
105646
|
pendingClearActiveEmbeddedRun?.();
|
|
105529
105647
|
}
|
|
105530
105648
|
}
|
|
@@ -105800,8 +105918,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
105800
105918
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
105801
105919
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
105802
105920
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
105803
|
-
if (workspaceResolution.usedFallback) log$
|
|
105804
|
-
const prevCwd = process.cwd();
|
|
105921
|
+
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}`);
|
|
105805
105922
|
let provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
105806
105923
|
let modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
105807
105924
|
const agentDir = params.agentDir ?? resolveOpenClawAgentDir();
|
|
@@ -105841,7 +105958,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
105841
105958
|
if (hookRunner?.hasHooks("before_model_resolve")) try {
|
|
105842
105959
|
modelResolveOverride = await hookRunner.runBeforeModelResolve({ prompt: params.prompt }, hookCtx);
|
|
105843
105960
|
} catch (hookErr) {
|
|
105844
|
-
log$
|
|
105961
|
+
log$29.warn(`before_model_resolve hook failed: ${String(hookErr)}`);
|
|
105845
105962
|
}
|
|
105846
105963
|
if (hookRunner?.hasHooks("before_agent_start")) try {
|
|
105847
105964
|
legacyBeforeAgentStartResult = await hookRunner.runBeforeAgentStart({ prompt: params.prompt }, hookCtx);
|
|
@@ -105850,15 +105967,15 @@ async function runEmbeddedPiAgent(params) {
|
|
|
105850
105967
|
modelOverride: modelResolveOverride?.modelOverride ?? legacyBeforeAgentStartResult?.modelOverride
|
|
105851
105968
|
};
|
|
105852
105969
|
} catch (hookErr) {
|
|
105853
|
-
log$
|
|
105970
|
+
log$29.warn(`before_agent_start hook (legacy model resolve path) failed: ${String(hookErr)}`);
|
|
105854
105971
|
}
|
|
105855
105972
|
if (modelResolveOverride?.providerOverride) {
|
|
105856
105973
|
provider = modelResolveOverride.providerOverride;
|
|
105857
|
-
log$
|
|
105974
|
+
log$29.info(`[hooks] provider overridden to ${provider}`);
|
|
105858
105975
|
}
|
|
105859
105976
|
if (modelResolveOverride?.modelOverride) {
|
|
105860
105977
|
modelId = modelResolveOverride.modelOverride;
|
|
105861
|
-
log$
|
|
105978
|
+
log$29.info(`[hooks] model overridden to ${modelId}`);
|
|
105862
105979
|
}
|
|
105863
105980
|
const { model, error, authStorage, modelRegistry } = resolveModel(provider, modelId, agentDir, params.config);
|
|
105864
105981
|
if (!model) throw new FailoverError(error ?? `Unknown model: ${provider}/${modelId}`, {
|
|
@@ -105878,9 +105995,9 @@ async function runEmbeddedPiAgent(params) {
|
|
|
105878
105995
|
warnBelowTokens: CONTEXT_WINDOW_WARN_BELOW_TOKENS,
|
|
105879
105996
|
hardMinTokens: CONTEXT_WINDOW_HARD_MIN_TOKENS
|
|
105880
105997
|
});
|
|
105881
|
-
if (ctxGuard.shouldWarn) log$
|
|
105998
|
+
if (ctxGuard.shouldWarn) log$29.warn(`low context window: ${provider}/${modelId} ctx=${ctxGuard.tokens} (warn<${CONTEXT_WINDOW_WARN_BELOW_TOKENS}) source=${ctxGuard.source}`);
|
|
105882
105999
|
if (ctxGuard.shouldBlock) {
|
|
105883
|
-
log$
|
|
106000
|
+
log$29.error(`blocked model (context window too small): ${provider}/${modelId} ctx=${ctxGuard.tokens} (min=${CONTEXT_WINDOW_HARD_MIN_TOKENS}) source=${ctxGuard.source}`);
|
|
105884
106001
|
throw new FailoverError(`Model context window too small (${ctxGuard.tokens} tokens). Minimum is ${CONTEXT_WINDOW_HARD_MIN_TOKENS}.`, {
|
|
105885
106002
|
reason: "unknown",
|
|
105886
106003
|
provider,
|
|
@@ -105934,14 +106051,14 @@ async function runEmbeddedPiAgent(params) {
|
|
|
105934
106051
|
copilotTokenState.refreshInFlight = (async () => {
|
|
105935
106052
|
const githubToken = copilotTokenState.githubToken.trim();
|
|
105936
106053
|
if (!githubToken) throw new Error("Copilot refresh requires a GitHub token.");
|
|
105937
|
-
log$
|
|
106054
|
+
log$29.debug(`Refreshing GitHub Copilot token (${reason})...`);
|
|
105938
106055
|
const copilotToken = await resolveCopilotApiToken({ githubToken });
|
|
105939
106056
|
authStorage.setRuntimeApiKey(model.provider, copilotToken.token);
|
|
105940
106057
|
copilotTokenState.expiresAt = copilotToken.expiresAt;
|
|
105941
106058
|
const remaining = copilotToken.expiresAt - Date.now();
|
|
105942
|
-
log$
|
|
106059
|
+
log$29.debug(`Copilot token refreshed; expires in ${Math.max(0, Math.floor(remaining / 1e3))}s.`);
|
|
105943
106060
|
})().catch((err) => {
|
|
105944
|
-
log$
|
|
106061
|
+
log$29.warn(`Copilot token refresh failed: ${describeUnknownError(err)}`);
|
|
105945
106062
|
throw err;
|
|
105946
106063
|
}).finally(() => {
|
|
105947
106064
|
copilotTokenState.refreshInFlight = void 0;
|
|
@@ -105951,7 +106068,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
105951
106068
|
const scheduleCopilotRefresh = () => {
|
|
105952
106069
|
if (!copilotTokenState || copilotRefreshCancelled) return;
|
|
105953
106070
|
if (!hasCopilotGithubToken()) {
|
|
105954
|
-
log$
|
|
106071
|
+
log$29.warn("Skipping Copilot refresh scheduling; GitHub token missing.");
|
|
105955
106072
|
return;
|
|
105956
106073
|
}
|
|
105957
106074
|
clearCopilotRefreshTimer();
|
|
@@ -106113,7 +106230,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106113
106230
|
while (true) {
|
|
106114
106231
|
if (runLoopIterations >= MAX_RUN_LOOP_ITERATIONS) {
|
|
106115
106232
|
const message = `Exceeded retry limit after ${runLoopIterations} attempts (max=${MAX_RUN_LOOP_ITERATIONS}).`;
|
|
106116
|
-
log$
|
|
106233
|
+
log$29.error(`[run-retry-limit] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} attempts=${runLoopIterations} maxAttempts=${MAX_RUN_LOOP_ITERATIONS}`);
|
|
106117
106234
|
logRunCompleted({
|
|
106118
106235
|
runId: params.runId,
|
|
106119
106236
|
sessionKey: params.sessionKey,
|
|
@@ -106277,21 +106394,21 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106277
106394
|
const errorText = contextOverflowError.text;
|
|
106278
106395
|
const overflowStorage = getConfiguredSessionStorageRuntime();
|
|
106279
106396
|
const msgCount = attempt.messagesSnapshot?.length ?? 0;
|
|
106280
|
-
log$
|
|
106397
|
+
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)}`);
|
|
106281
106398
|
const isCompactionFailure = isCompactionFailureError(errorText);
|
|
106282
106399
|
const hadAttemptLevelCompaction = attemptCompactionCount > 0;
|
|
106283
106400
|
const explicitOverflowCompactionAllowed = params.trigger !== "analysis" && !params.disablePluginHooks && !params.skipTranscriptSync;
|
|
106284
106401
|
if (explicitOverflowCompactionAllowed && !isCompactionFailure && hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
106285
106402
|
overflowCompactionAttempts++;
|
|
106286
|
-
log$
|
|
106403
|
+
log$29.warn(`context overflow persisted after in-attempt compaction (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); retrying prompt without additional compaction for ${provider}/${modelId}`);
|
|
106287
106404
|
continue;
|
|
106288
106405
|
}
|
|
106289
106406
|
if (explicitOverflowCompactionAllowed && !isCompactionFailure && !hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
106290
|
-
if (log$
|
|
106407
|
+
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}`);
|
|
106291
106408
|
overflowCompactionAttempts++;
|
|
106292
|
-
log$
|
|
106409
|
+
log$29.warn(`context overflow detected (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); attempting auto-compaction for ${provider}/${modelId}`);
|
|
106293
106410
|
const _overflowIsDb = (overflowStorage?.runtime?.backend ?? "fs-jsonl") !== "fs-jsonl";
|
|
106294
|
-
if (_overflowIsDb) log$
|
|
106411
|
+
if (_overflowIsDb) log$29.warn(`context overflow compaction skipped for DB backend session ${params.sessionId}; compact.ts does not yet support DB-backend sessions`);
|
|
106295
106412
|
const compactResult = _overflowIsDb ? {
|
|
106296
106413
|
compacted: false,
|
|
106297
106414
|
reason: "db-backend-not-supported"
|
|
@@ -106324,10 +106441,10 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106324
106441
|
});
|
|
106325
106442
|
if (compactResult.compacted) {
|
|
106326
106443
|
autoCompactionCount += 1;
|
|
106327
|
-
log$
|
|
106444
|
+
log$29.info(`auto-compaction succeeded for ${provider}/${modelId}; retrying prompt`);
|
|
106328
106445
|
continue;
|
|
106329
106446
|
}
|
|
106330
|
-
log$
|
|
106447
|
+
log$29.warn(`auto-compaction failed for ${provider}/${modelId}: ${compactResult.reason ?? "nothing to compact"}`);
|
|
106331
106448
|
}
|
|
106332
106449
|
if (!toolResultTruncationAttempted) {
|
|
106333
106450
|
const contextWindowTokens = ctxInfo.tokens;
|
|
@@ -106336,11 +106453,11 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106336
106453
|
contextWindowTokens
|
|
106337
106454
|
}) : false;
|
|
106338
106455
|
if (hasOversized) {
|
|
106339
|
-
if (log$
|
|
106456
|
+
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}`);
|
|
106340
106457
|
toolResultTruncationAttempted = true;
|
|
106341
|
-
if ((overflowStorage?.runtime?.backend ?? "fs-jsonl") !== "fs-jsonl") log$
|
|
106458
|
+
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`);
|
|
106342
106459
|
else {
|
|
106343
|
-
log$
|
|
106460
|
+
log$29.warn(`[context-overflow-recovery] Attempting tool result truncation for ${provider}/${modelId} (contextWindow=${contextWindowTokens} tokens)`);
|
|
106344
106461
|
const truncResult = await truncateOversizedToolResultsInSession({
|
|
106345
106462
|
sessionFile: params.sessionFile,
|
|
106346
106463
|
contextWindowTokens,
|
|
@@ -106348,14 +106465,14 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106348
106465
|
sessionKey: params.sessionKey
|
|
106349
106466
|
});
|
|
106350
106467
|
if (truncResult.truncated) {
|
|
106351
|
-
log$
|
|
106468
|
+
log$29.info(`[context-overflow-recovery] Truncated ${truncResult.truncatedCount} tool result(s); retrying prompt`);
|
|
106352
106469
|
continue;
|
|
106353
106470
|
}
|
|
106354
|
-
log$
|
|
106471
|
+
log$29.warn(`[context-overflow-recovery] Tool result truncation did not help: ${truncResult.reason ?? "unknown"}`);
|
|
106355
106472
|
}
|
|
106356
|
-
} else if (log$
|
|
106473
|
+
} 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}`);
|
|
106357
106474
|
}
|
|
106358
|
-
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS || toolResultTruncationAttempted) && log$
|
|
106475
|
+
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}`);
|
|
106359
106476
|
const kind = isCompactionFailure ? "compaction_failure" : "context_overflow";
|
|
106360
106477
|
logRunCompleted({
|
|
106361
106478
|
runId: params.runId,
|
|
@@ -106461,7 +106578,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106461
106578
|
attempted: attemptedThinking
|
|
106462
106579
|
});
|
|
106463
106580
|
if (fallbackThinking) {
|
|
106464
|
-
log$
|
|
106581
|
+
log$29.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
106465
106582
|
thinkLevel = fallbackThinking;
|
|
106466
106583
|
continue;
|
|
106467
106584
|
}
|
|
@@ -106479,7 +106596,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106479
106596
|
attempted: attemptedThinking
|
|
106480
106597
|
});
|
|
106481
106598
|
if (fallbackThinking && !aborted) {
|
|
106482
|
-
log$
|
|
106599
|
+
log$29.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
106483
106600
|
thinkLevel = fallbackThinking;
|
|
106484
106601
|
continue;
|
|
106485
106602
|
}
|
|
@@ -106500,7 +106617,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106500
106617
|
imageDimensionError.contentIndex !== void 0 ? `content=${imageDimensionError.contentIndex}` : null,
|
|
106501
106618
|
imageDimensionError.maxDimensionPx !== void 0 ? `limit=${imageDimensionError.maxDimensionPx}px` : null
|
|
106502
106619
|
].filter(Boolean).join(" ");
|
|
106503
|
-
log$
|
|
106620
|
+
log$29.warn(`Profile ${lastProfileId} rejected image payload${details ? ` (${details})` : ""}.`);
|
|
106504
106621
|
}
|
|
106505
106622
|
if (!aborted && failoverFailure || timedOut && !timedOutDuringCompaction) {
|
|
106506
106623
|
if (lastProfileId) {
|
|
@@ -106508,8 +106625,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106508
106625
|
profileId: lastProfileId,
|
|
106509
106626
|
reason: timedOut || assistantFailoverReason === "timeout" ? "timeout" : assistantFailoverReason ?? "unknown"
|
|
106510
106627
|
});
|
|
106511
|
-
if (timedOut && !isProbeSession) log$
|
|
106512
|
-
if (cloudCodeAssistFormatError) log$
|
|
106628
|
+
if (timedOut && !isProbeSession) log$29.warn(`Profile ${lastProfileId} timed out. Trying next account...`);
|
|
106629
|
+
if (cloudCodeAssistFormatError) log$29.warn(`Profile ${lastProfileId} hit Cloud Code Assist format error. Tool calls will be sanitized on retry.`);
|
|
106513
106630
|
}
|
|
106514
106631
|
if (await advanceAuthProfile()) continue;
|
|
106515
106632
|
if (fallbackConfigured) {
|
|
@@ -106554,7 +106671,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106554
106671
|
}, hookCtx);
|
|
106555
106672
|
if (transformResult?.assistantTexts) finalAssistantTexts = transformResult.assistantTexts;
|
|
106556
106673
|
} catch (err) {
|
|
106557
|
-
log$
|
|
106674
|
+
log$29.warn(`transform_llm_output hook failed: ${String(err)}`);
|
|
106558
106675
|
}
|
|
106559
106676
|
const payloads = buildEmbeddedRunPayloads({
|
|
106560
106677
|
assistantTexts: finalAssistantTexts,
|
|
@@ -106605,7 +106722,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106605
106722
|
durationMs: Date.now() - started,
|
|
106606
106723
|
exitStatus: aborted || timedOut ? "error" : void 0
|
|
106607
106724
|
});
|
|
106608
|
-
log$
|
|
106725
|
+
log$29.debug(`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`);
|
|
106609
106726
|
if (lastProfileId) {
|
|
106610
106727
|
await markAuthProfileGood({
|
|
106611
106728
|
store: authStore,
|
|
@@ -106642,7 +106759,6 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106642
106759
|
}
|
|
106643
106760
|
} finally {
|
|
106644
106761
|
stopCopilotRefreshTimer();
|
|
106645
|
-
if (!params.skipCwdChange) process.chdir(prevCwd);
|
|
106646
106762
|
}
|
|
106647
106763
|
}));
|
|
106648
106764
|
}
|