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
|
@@ -8,7 +8,7 @@ import { i as logWarn, n as logError, r as logInfo, t as logDebug } from "./logg
|
|
|
8
8
|
import { c as resolveSessionFilePathOptions, d as resolveSessionTranscriptsDirForAgent, f as resolveStorePath, l as resolveSessionTranscriptPath, n as isPrimarySessionTranscriptFileName, o as resolveDefaultSessionStorePath, p as runTasksWithConcurrency, s as resolveSessionFilePath } from "./artifacts-BR0G7jgh.js";
|
|
9
9
|
import { n as normalizeChatType, t as resolveConversationLabel } from "./conversation-label-Byxk5Gak.js";
|
|
10
10
|
import { $ as fetchChannelPermissionsDiscord, A as addRoleDiscord, At as resolveChannelEntryMatchWithFallback, B as removeRoleDiscord, C as fetchMessageDiscord, Ct as resolveDiscordSystemLocation, D as readMessagesDiscord, Dt as buildChannelKeyCandidates, E as pinMessageDiscord, Et as applyChannelMatchMeta, F as fetchRoleInfoDiscord, G as createChannelDiscord, H as listGuildEmojisDiscord, I as fetchVoiceStatusDiscord, J as moveChannelDiscord, K as deleteChannelDiscord, L as kickMemberDiscord, M as createScheduledEventDiscord, N as fetchChannelInfoDiscord, O as searchMessagesDiscord, Ot as normalizeChannelSlug, P as fetchMemberInfoDiscord, R as listGuildChannelsDiscord, S as editMessageDiscord, St as formatDiscordUserTag, T as listThreadsDiscord, Tt as fetchDiscord, U as uploadEmojiDiscord, V as timeoutMemberDiscord, W as uploadStickerDiscord, X as setChannelPermissionDiscord, Y as removeChannelPermissionDiscord, Z as stripUndefinedFields, _ as sendStickerDiscord, _t as resolveDiscordOwnerAllowFrom, a as sendDiscordComponentMessage, at as parseDiscordTarget, b as createThreadDiscord, bt as shouldEmitDiscordReactionNotification, c as parseDiscordComponentCustomId, ct as listDiscordDirectoryPeersLive, d as parseDiscordModalCustomIdForCarbon, dt as normalizeDiscordSlug, f as readDiscordComponentSpec, ft as resolveDiscordAllowListMatch, g as sendPollDiscord, gt as resolveDiscordOwnerAccess, h as sendMessageDiscord, ht as resolveDiscordMemberAccessState, i as removeReactionDiscord, it as createDiscordRestClient, j as banMemberDiscord, k as unpinMessageDiscord, l as parseDiscordComponentCustomIdForCarbon, lt as isDiscordGroupAllowedByPolicy, m as resolveDiscordModalEntry, mt as resolveDiscordGuildEntry, n as reactMessageDiscord, nt as chunkDiscordTextWithMode, o as createDiscordFormModal, ot as resolveDiscordChannelId, p as resolveDiscordComponentEntry, pt as resolveDiscordChannelConfigWithFallback, q as editChannelDiscord, r as removeOwnReactionsDiscord, rt as createDiscordClient, s as formatDiscordComponentEventText, st as listDiscordDirectoryGroupsLive, t as fetchReactionsDiscord, tt as hasAnyGuildPermissionDiscord, u as parseDiscordModalCustomId, ut as normalizeDiscordAllowList, v as sendVoiceMessageDiscord, vt as resolveDiscordShouldRequireMention, w as listPinsDiscord, wt as resolveTimestampMs, x as deleteMessageDiscord, xt as formatDiscordReactionEmoji, y as sendWebhookMessageDiscord, yt as resolveGroupDmAllow, z as listScheduledEventsDiscord } from "./send-djzUznXF.js";
|
|
11
|
-
import { a as enqueueAgentTurn, c as peekDelayedAgentTurn, f as KeyedAsyncQueue, i as clearDelayedReleaseHold, l as setDelayedReleaseHold, n as tryGetAgentTurnRuntime, o as isClaimableAgentTurnWorkId, r as agentTurnIdempotencyKey, s as mergeDelayedAgentTurn, t as getAgentTurnRuntime } from "./agent-turn-runner-
|
|
11
|
+
import { a as enqueueAgentTurn, c as peekDelayedAgentTurn, f as KeyedAsyncQueue, i as clearDelayedReleaseHold, l as setDelayedReleaseHold, n as tryGetAgentTurnRuntime, o as isClaimableAgentTurnWorkId, r as agentTurnIdempotencyKey, s as mergeDelayedAgentTurn, t as getAgentTurnRuntime } from "./agent-turn-runner-BuZraB-G.js";
|
|
12
12
|
import { n as fetchWithTimeout, t as bindAbortRelay } from "./fetch-timeout-BVVZ4csV.js";
|
|
13
13
|
import { n as wrapFetchWithAbortSignal, t as resolveFetch } from "./fetch-CiGIllmg.js";
|
|
14
14
|
import { i as testRegexWithBoundedInput, r as compileSafeRegex, t as redactSensitiveText } from "./redact-BN7L2dg6.js";
|
|
@@ -1891,6 +1891,21 @@ function requireAcpRuntimeBackend(id) {
|
|
|
1891
1891
|
if (normalized && backend.id !== normalized) throw new AcpRuntimeError("ACP_BACKEND_MISSING", `ACP runtime backend "${normalized}" is not registered.`);
|
|
1892
1892
|
return backend;
|
|
1893
1893
|
}
|
|
1894
|
+
async function waitForAcpRuntimeBackendHealthy(params) {
|
|
1895
|
+
const normalized = normalizeBackendId(params.id);
|
|
1896
|
+
const pollMs = params.pollMs ?? 250;
|
|
1897
|
+
const deadline = Date.now() + params.timeoutMs;
|
|
1898
|
+
for (;;) {
|
|
1899
|
+
const backend = getAcpRuntimeBackend(normalized || void 0);
|
|
1900
|
+
if (!backend) return false;
|
|
1901
|
+
if (isBackendHealthy(backend)) return true;
|
|
1902
|
+
const remainingMs = deadline - Date.now();
|
|
1903
|
+
if (remainingMs <= 0) return false;
|
|
1904
|
+
await new Promise((resolve) => {
|
|
1905
|
+
setTimeout(resolve, Math.min(pollMs, remainingMs)).unref();
|
|
1906
|
+
});
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1894
1909
|
|
|
1895
1910
|
//#endregion
|
|
1896
1911
|
//#region src/gateway/protocol/schema/error-codes.ts
|
|
@@ -8895,7 +8910,7 @@ function hasMarkdownToConvert(text) {
|
|
|
8895
8910
|
|
|
8896
8911
|
//#endregion
|
|
8897
8912
|
//#region src/backbone/authz.ts
|
|
8898
|
-
const log$
|
|
8913
|
+
const log$40 = createSubsystemLogger("backbone/authz");
|
|
8899
8914
|
var AuthorizationError = class extends Error {
|
|
8900
8915
|
constructor(message, pluginId, reason, topic) {
|
|
8901
8916
|
super(message);
|
|
@@ -8955,14 +8970,14 @@ function authorizeAccess(grants, msg, direction) {
|
|
|
8955
8970
|
function authorizeConsume(grants, msg) {
|
|
8956
8971
|
if (msg.privacyContext.length === 0) throw new AuthorizationError(`consume rejected: empty privacyContext for plugin '${grants.pluginId}'`, grants.pluginId, "privacyContext");
|
|
8957
8972
|
if (!topicInGrants(msg.topic, grants.consumeTopics)) {
|
|
8958
|
-
log$
|
|
8973
|
+
log$40.warn("consume rejected: topic not granted", {
|
|
8959
8974
|
pluginId: grants.pluginId,
|
|
8960
8975
|
topic: msg.topic
|
|
8961
8976
|
});
|
|
8962
8977
|
throw new AuthorizationError(`consume rejected: topic '${msg.topic}' not in consumeTopics for plugin '${grants.pluginId}'`, grants.pluginId, "topic");
|
|
8963
8978
|
}
|
|
8964
8979
|
if (!scopeInGrants(msg.privacyContext, grants.consumeScopes)) {
|
|
8965
|
-
log$
|
|
8980
|
+
log$40.warn("consume rejected: privacyContext not granted", {
|
|
8966
8981
|
pluginId: grants.pluginId,
|
|
8967
8982
|
scopes: msg.privacyContext
|
|
8968
8983
|
});
|
|
@@ -8976,14 +8991,14 @@ function authorizeConsumeSubscribe(grants, topicGlob) {
|
|
|
8976
8991
|
function authorizeProduce(grants, msg) {
|
|
8977
8992
|
if (msg.privacyContext.length === 0) throw new AuthorizationError(`produce rejected: empty privacyContext for plugin '${grants.pluginId}'`, grants.pluginId, "privacyContext");
|
|
8978
8993
|
if (!topicInGrants(msg.topic, grants.produceTopics)) {
|
|
8979
|
-
log$
|
|
8994
|
+
log$40.warn("produce rejected: topic not granted (possible forgery)", {
|
|
8980
8995
|
pluginId: grants.pluginId,
|
|
8981
8996
|
topic: msg.topic
|
|
8982
8997
|
});
|
|
8983
8998
|
throw new AuthorizationError(`produce rejected: topic '${msg.topic}' not in produceTopics for plugin '${grants.pluginId}'`, grants.pluginId, "topic");
|
|
8984
8999
|
}
|
|
8985
9000
|
if (!scopeInGrants(msg.privacyContext, grants.produceScopes)) {
|
|
8986
|
-
log$
|
|
9001
|
+
log$40.warn("produce rejected: privacyContext not granted", {
|
|
8987
9002
|
pluginId: grants.pluginId,
|
|
8988
9003
|
scopes: msg.privacyContext
|
|
8989
9004
|
});
|
|
@@ -8994,7 +9009,7 @@ function authorizeProduce(grants, msg) {
|
|
|
8994
9009
|
|
|
8995
9010
|
//#endregion
|
|
8996
9011
|
//#region src/backbone/scoped-plugin-api.ts
|
|
8997
|
-
const log$
|
|
9012
|
+
const log$39 = createSubsystemLogger("backbone/scoped-plugin-api");
|
|
8998
9013
|
function stampSource(grants, msg) {
|
|
8999
9014
|
return {
|
|
9000
9015
|
...msg,
|
|
@@ -9003,7 +9018,7 @@ function stampSource(grants, msg) {
|
|
|
9003
9018
|
};
|
|
9004
9019
|
}
|
|
9005
9020
|
function reportSecurityAlert(grants, err) {
|
|
9006
|
-
log$
|
|
9021
|
+
log$39.warn("backbone authz rejection", {
|
|
9007
9022
|
pluginId: grants.pluginId,
|
|
9008
9023
|
reason: err.reason,
|
|
9009
9024
|
message: err.message
|
|
@@ -9053,7 +9068,7 @@ function createScopedBackboneApi(opts) {
|
|
|
9053
9068
|
}
|
|
9054
9069
|
const ret = handler(msg);
|
|
9055
9070
|
if (ret instanceof Promise) ret.catch((e) => {
|
|
9056
|
-
log$
|
|
9071
|
+
log$39.error("subscribe handler error", {
|
|
9057
9072
|
pluginId: grants.pluginId,
|
|
9058
9073
|
error: String(e)
|
|
9059
9074
|
});
|
|
@@ -9714,6 +9729,9 @@ var SessionActorQueue = class {
|
|
|
9714
9729
|
|
|
9715
9730
|
//#endregion
|
|
9716
9731
|
//#region src/acp/control-plane/manager.core.ts
|
|
9732
|
+
const log$38 = createSubsystemLogger("acp/manager");
|
|
9733
|
+
const STARTUP_RECONCILE_BACKEND_WAIT_MS = 3e4;
|
|
9734
|
+
const STARTUP_RECONCILE_BACKEND_POLL_MS = 250;
|
|
9717
9735
|
var AcpSessionManager = class {
|
|
9718
9736
|
constructor(deps = DEFAULT_DEPS) {
|
|
9719
9737
|
this.deps = deps;
|
|
@@ -9791,34 +9809,54 @@ var AcpSessionManager = class {
|
|
|
9791
9809
|
failed: failed + 1
|
|
9792
9810
|
};
|
|
9793
9811
|
}
|
|
9812
|
+
const logFailure = (sessionKey, acpError) => {
|
|
9813
|
+
const redactedKey = redactIdentifier(sessionKey);
|
|
9814
|
+
log$38.warn(`startup identity reconcile failed for ${redactedKey}: code=${acpError.code} ${acpError.message.replaceAll(sessionKey, redactedKey)}`);
|
|
9815
|
+
};
|
|
9816
|
+
const toReconcileError = (error) => toAcpRuntimeError({
|
|
9817
|
+
error,
|
|
9818
|
+
fallbackCode: "ACP_SESSION_INIT_FAILED",
|
|
9819
|
+
fallbackMessage: "ACP startup identity reconcile failed."
|
|
9820
|
+
});
|
|
9821
|
+
const deferred = [];
|
|
9794
9822
|
for (const session of acpSessions) {
|
|
9795
9823
|
if (!session.acp || !session.sessionKey) continue;
|
|
9796
9824
|
if (!isSessionIdentityPending(resolveSessionIdentityFromMeta(session.acp))) continue;
|
|
9797
9825
|
checked += 1;
|
|
9798
9826
|
try {
|
|
9799
|
-
if (await this.
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
if (resolution.kind !== "ready") return false;
|
|
9805
|
-
const { runtime, handle, meta } = await this.ensureRuntimeHandle({
|
|
9806
|
-
cfg: params.cfg,
|
|
9827
|
+
if (await this.reconcileOneSessionIdentity(params.cfg, session.sessionKey)) resolved += 1;
|
|
9828
|
+
} catch (error) {
|
|
9829
|
+
const acpError = toReconcileError(error);
|
|
9830
|
+
if (acpError.code === "ACP_BACKEND_UNAVAILABLE") {
|
|
9831
|
+
deferred.push({
|
|
9807
9832
|
sessionKey: session.sessionKey,
|
|
9808
|
-
|
|
9833
|
+
backend: (session.acp.backend || params.cfg.acp?.backend || "").trim()
|
|
9809
9834
|
});
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
sessionKey: session.sessionKey,
|
|
9813
|
-
runtime,
|
|
9814
|
-
handle,
|
|
9815
|
-
meta,
|
|
9816
|
-
failOnStatusError: false
|
|
9817
|
-
})).meta));
|
|
9818
|
-
})) resolved += 1;
|
|
9819
|
-
} catch (error) {
|
|
9835
|
+
continue;
|
|
9836
|
+
}
|
|
9820
9837
|
failed += 1;
|
|
9821
|
-
|
|
9838
|
+
logFailure(session.sessionKey, acpError);
|
|
9839
|
+
}
|
|
9840
|
+
}
|
|
9841
|
+
if (deferred.length > 0) {
|
|
9842
|
+
const backendIds = [...new Set(deferred.map(({ backend }) => backend))];
|
|
9843
|
+
const healthyByBackend = new Map(await Promise.all(backendIds.map(async (backend) => [backend, await waitForAcpRuntimeBackendHealthy({
|
|
9844
|
+
id: backend || void 0,
|
|
9845
|
+
timeoutMs: params.backendWaitMs ?? STARTUP_RECONCILE_BACKEND_WAIT_MS,
|
|
9846
|
+
pollMs: params.backendPollMs ?? STARTUP_RECONCILE_BACKEND_POLL_MS
|
|
9847
|
+
})])));
|
|
9848
|
+
for (const { sessionKey, backend } of deferred) {
|
|
9849
|
+
if (!healthyByBackend.get(backend)) {
|
|
9850
|
+
failed += 1;
|
|
9851
|
+
logFailure(sessionKey, new AcpRuntimeError("ACP_BACKEND_UNAVAILABLE", `ACP runtime backend${backend ? ` "${backend}"` : ""} did not become healthy before the startup wait expired.`));
|
|
9852
|
+
continue;
|
|
9853
|
+
}
|
|
9854
|
+
try {
|
|
9855
|
+
if (await this.reconcileOneSessionIdentity(params.cfg, sessionKey)) resolved += 1;
|
|
9856
|
+
} catch (error) {
|
|
9857
|
+
failed += 1;
|
|
9858
|
+
logFailure(sessionKey, toReconcileError(error));
|
|
9859
|
+
}
|
|
9822
9860
|
}
|
|
9823
9861
|
}
|
|
9824
9862
|
return {
|
|
@@ -9827,6 +9865,37 @@ var AcpSessionManager = class {
|
|
|
9827
9865
|
failed
|
|
9828
9866
|
};
|
|
9829
9867
|
}
|
|
9868
|
+
async reconcileOneSessionIdentity(cfg, sessionKey) {
|
|
9869
|
+
return await this.withSessionActor(sessionKey, async () => {
|
|
9870
|
+
const resolution = this.resolveSession({
|
|
9871
|
+
cfg,
|
|
9872
|
+
sessionKey
|
|
9873
|
+
});
|
|
9874
|
+
if (resolution.kind !== "ready") return false;
|
|
9875
|
+
const { runtime, handle, meta } = await this.ensureRuntimeHandle({
|
|
9876
|
+
cfg,
|
|
9877
|
+
sessionKey,
|
|
9878
|
+
meta: resolution.meta
|
|
9879
|
+
});
|
|
9880
|
+
try {
|
|
9881
|
+
return !isSessionIdentityPending(resolveSessionIdentityFromMeta((await this.reconcileRuntimeSessionIdentifiers({
|
|
9882
|
+
cfg,
|
|
9883
|
+
sessionKey,
|
|
9884
|
+
runtime,
|
|
9885
|
+
handle,
|
|
9886
|
+
meta,
|
|
9887
|
+
failOnStatusError: true
|
|
9888
|
+
})).meta));
|
|
9889
|
+
} catch (error) {
|
|
9890
|
+
const stored = this.deps.readSessionEntry({
|
|
9891
|
+
cfg,
|
|
9892
|
+
sessionKey
|
|
9893
|
+
})?.acp;
|
|
9894
|
+
if (stored && !isSessionIdentityPending(resolveSessionIdentityFromMeta(stored))) return true;
|
|
9895
|
+
throw error;
|
|
9896
|
+
}
|
|
9897
|
+
});
|
|
9898
|
+
}
|
|
9830
9899
|
async initializeSession(input) {
|
|
9831
9900
|
const sessionKey = normalizeSessionKey$1(input.sessionKey);
|
|
9832
9901
|
if (!sessionKey) throw new AcpRuntimeError("ACP_SESSION_INIT_FAILED", "ACP session key is required.");
|
|
@@ -12404,7 +12473,7 @@ async function applyBootstrapHookOverrides(params) {
|
|
|
12404
12473
|
|
|
12405
12474
|
//#endregion
|
|
12406
12475
|
//#region src/agents/system-prompt-config.ts
|
|
12407
|
-
const log$
|
|
12476
|
+
const log$37 = createSubsystemLogger("agents/system-prompt-config");
|
|
12408
12477
|
const DEFAULT_PROMPT_SOURCE_MAX_CHARS = 2e4;
|
|
12409
12478
|
const MAX_PROMPT_SOURCE_FILE_BYTES = 512 * 1024;
|
|
12410
12479
|
const MAX_PROMPT_SOURCE_FILE_BYTES_HARD = 8 * 1024 * 1024;
|
|
@@ -12590,7 +12659,7 @@ async function readPromptSourceFile(params) {
|
|
|
12590
12659
|
if (!opened.ok) {
|
|
12591
12660
|
promptSourceCache.delete(absolutePath);
|
|
12592
12661
|
if (params.optional) {
|
|
12593
|
-
if (opened.reason !== "path") log$
|
|
12662
|
+
if (opened.reason !== "path") log$37.warn("skipping optional systemPrompt source: present but unusable", {
|
|
12594
12663
|
file: params.file,
|
|
12595
12664
|
reason: opened.reason
|
|
12596
12665
|
});
|
|
@@ -12614,7 +12683,7 @@ async function readPromptSourceFile(params) {
|
|
|
12614
12683
|
} catch (error) {
|
|
12615
12684
|
promptSourceCache.delete(opened.path);
|
|
12616
12685
|
if (params.optional) {
|
|
12617
|
-
log$
|
|
12686
|
+
log$37.warn("skipping optional systemPrompt source after read error", {
|
|
12618
12687
|
file: params.file,
|
|
12619
12688
|
error
|
|
12620
12689
|
});
|
|
@@ -12721,7 +12790,7 @@ async function resolveSystemPromptConfigForRun(params) {
|
|
|
12721
12790
|
|
|
12722
12791
|
//#endregion
|
|
12723
12792
|
//#region src/agents/workspace-lanes.ts
|
|
12724
|
-
const log$
|
|
12793
|
+
const log$36 = createSubsystemLogger("agents/workspace-lanes");
|
|
12725
12794
|
const DEFAULT_ROOT_TEMPLATE = "~/.openclaw/agents/{agentId}/lanes/{laneId}/workspace";
|
|
12726
12795
|
const SUPPORTED_STRATEGY = "hybrid";
|
|
12727
12796
|
const DEFAULT_COPIED_ON_CREATE_FILES = ["USER.md", "BOOTSTRAP.md"];
|
|
@@ -12874,7 +12943,7 @@ function resolveWorkspaceLane(params) {
|
|
|
12874
12943
|
actor: params.actor
|
|
12875
12944
|
});
|
|
12876
12945
|
if (!keyResult.ok) {
|
|
12877
|
-
log$
|
|
12946
|
+
log$36.warn("workspace lane key denied", {
|
|
12878
12947
|
agentId,
|
|
12879
12948
|
laneKeySource: keyResult.laneKeySource,
|
|
12880
12949
|
reason: keyResult.reason
|
|
@@ -12895,7 +12964,7 @@ function resolveWorkspaceLane(params) {
|
|
|
12895
12964
|
laneId: key.laneId
|
|
12896
12965
|
});
|
|
12897
12966
|
if (!rootTemplate.ok) {
|
|
12898
|
-
log$
|
|
12967
|
+
log$36.warn("workspace lane root template denied", {
|
|
12899
12968
|
agentId,
|
|
12900
12969
|
laneId: key.laneId,
|
|
12901
12970
|
laneKeySource: key.laneKeySource,
|
|
@@ -12913,7 +12982,7 @@ function resolveWorkspaceLane(params) {
|
|
|
12913
12982
|
}
|
|
12914
12983
|
const effectiveWorkspaceDir = rootTemplate.effectiveWorkspaceDir;
|
|
12915
12984
|
if (strategy !== SUPPORTED_STRATEGY) {
|
|
12916
|
-
log$
|
|
12985
|
+
log$36.warn("workspace lane strategy denied", {
|
|
12917
12986
|
agentId,
|
|
12918
12987
|
strategy
|
|
12919
12988
|
});
|
|
@@ -13008,7 +13077,7 @@ async function resolveWorkspaceLaneForTurn(params) {
|
|
|
13008
13077
|
if ((config?.create ?? "on-first-message") !== "on-first-message") {
|
|
13009
13078
|
const pathState = await getExistingPathState(resolution.effectiveWorkspaceDir);
|
|
13010
13079
|
if (pathState !== "directory") {
|
|
13011
|
-
log$
|
|
13080
|
+
log$36.warn("workspace lane manual creation denied", {
|
|
13012
13081
|
agentId: resolution.agentId,
|
|
13013
13082
|
laneId: resolution.laneId,
|
|
13014
13083
|
laneKeySource: resolution.laneKeySource,
|
|
@@ -13034,7 +13103,7 @@ async function resolveWorkspaceLaneForTurn(params) {
|
|
|
13034
13103
|
targetRoot: resolution.effectiveWorkspaceDir,
|
|
13035
13104
|
relativePath: file
|
|
13036
13105
|
});
|
|
13037
|
-
if (decision === "copied" || !existed) log$
|
|
13106
|
+
if (decision === "copied" || !existed) log$36.info("workspace lane seed file decision", {
|
|
13038
13107
|
agentId: resolution.agentId,
|
|
13039
13108
|
laneId: resolution.laneId,
|
|
13040
13109
|
laneKeySource: resolution.laneKeySource,
|
|
@@ -13043,7 +13112,7 @@ async function resolveWorkspaceLaneForTurn(params) {
|
|
|
13043
13112
|
});
|
|
13044
13113
|
}
|
|
13045
13114
|
const created = !existed;
|
|
13046
|
-
if (created) log$
|
|
13115
|
+
if (created) log$36.info("workspace lane created", {
|
|
13047
13116
|
agentId: resolution.agentId,
|
|
13048
13117
|
laneId: resolution.laneId,
|
|
13049
13118
|
laneKeySource: resolution.laneKeySource
|
|
@@ -13813,7 +13882,7 @@ function resolveExecSafeBinRuntimePolicy(params) {
|
|
|
13813
13882
|
|
|
13814
13883
|
//#endregion
|
|
13815
13884
|
//#region src/plugins/activation-migration.ts
|
|
13816
|
-
const log$
|
|
13885
|
+
const log$35 = createSubsystemLogger("plugins/activation-migration");
|
|
13817
13886
|
/**
|
|
13818
13887
|
* One-time migration from the presence-implies-load model to explicit-enable (ADR 0016).
|
|
13819
13888
|
* Runs synchronously inside loadOpenClawPlugins, before resolveEnableState is applied.
|
|
@@ -13855,7 +13924,7 @@ function runActivationMigrationIfNeeded(config, pluginRecords) {
|
|
|
13855
13924
|
activationMigrationVersion: 1
|
|
13856
13925
|
}
|
|
13857
13926
|
};
|
|
13858
|
-
if (toEnable.size > 0) log$
|
|
13927
|
+
if (toEnable.size > 0) log$35.info(`activation migration v1: auto-enabled ${toEnable.size} previously-active plugin(s)`, { ids: [...toEnable] });
|
|
13859
13928
|
return next;
|
|
13860
13929
|
}
|
|
13861
13930
|
|
|
@@ -13978,7 +14047,7 @@ function estimateUsageCost(params) {
|
|
|
13978
14047
|
|
|
13979
14048
|
//#endregion
|
|
13980
14049
|
//#region src/plugins/runtime/runtime-analysis-direct.ts
|
|
13981
|
-
const log$
|
|
14050
|
+
const log$34 = createSubsystemLogger("plugins/runtime/analysis");
|
|
13982
14051
|
const NEUTRAL_ANALYSIS_SYSTEM_PROMPT = "You are running a focused internal analysis for a WednesdayAI extension. Return only the requested result.";
|
|
13983
14052
|
function isJsonResponseFormat(params) {
|
|
13984
14053
|
return params.responseFormat === "json" || typeof params.responseFormat === "object" && params.responseFormat.type === "json_schema";
|
|
@@ -14038,8 +14107,8 @@ async function runDirectAnalysis(req, overrides) {
|
|
|
14038
14107
|
elapsedMs: full.elapsedMs,
|
|
14039
14108
|
error: full.error
|
|
14040
14109
|
};
|
|
14041
|
-
if (full.status === "ok" || full.status === "empty") log$
|
|
14042
|
-
else log$
|
|
14110
|
+
if (full.status === "ok" || full.status === "empty") log$34.info("direct analysis run", logFields);
|
|
14111
|
+
else log$34.warn("direct analysis run failed", logFields);
|
|
14043
14112
|
return full;
|
|
14044
14113
|
};
|
|
14045
14114
|
const controller = new AbortController();
|
|
@@ -14178,7 +14247,7 @@ async function runDirectAnalysis(req, overrides) {
|
|
|
14178
14247
|
|
|
14179
14248
|
//#endregion
|
|
14180
14249
|
//#region src/plugins/runtime/runtime-analysis.ts
|
|
14181
|
-
const log$
|
|
14250
|
+
const log$33 = createSubsystemLogger("plugins/runtime/analysis");
|
|
14182
14251
|
const DEFAULT_RUN_TIMEOUT_MS = 15e3;
|
|
14183
14252
|
const MIN_TIMEOUT_MS = 250;
|
|
14184
14253
|
const MAX_TIMEOUT_MS = 12e4;
|
|
@@ -14219,7 +14288,7 @@ function finalizeAnalysisResult(result, cfg, transport) {
|
|
|
14219
14288
|
const { costUsd: _untrusted, ...rest } = result;
|
|
14220
14289
|
let usageState = result.usageState;
|
|
14221
14290
|
if (usageState === void 0) {
|
|
14222
|
-
log$
|
|
14291
|
+
log$33.warn("analysis result missing usageState; treating the call as spent", {
|
|
14223
14292
|
transport,
|
|
14224
14293
|
status: result.status,
|
|
14225
14294
|
provider: result.provider,
|
|
@@ -14648,7 +14717,7 @@ async function executeAnalysisTransport(params, deps, fallbackTimeoutMs, lane, c
|
|
|
14648
14717
|
if (err instanceof CommandLaneAbortedError && !providerDispatched) return queuedCancellation();
|
|
14649
14718
|
const message = err instanceof Error ? err.message : String(err);
|
|
14650
14719
|
const status = /timed?\s*out|timeout/i.test(message) ? "timeout" : "error";
|
|
14651
|
-
log$
|
|
14720
|
+
log$33.warn("analysis run failed", {
|
|
14652
14721
|
purpose: params.purpose,
|
|
14653
14722
|
pluginId: params.pluginId,
|
|
14654
14723
|
status,
|
|
@@ -14709,7 +14778,7 @@ function createRuntimeAnalysis(deps = {}, concurrencyConfig) {
|
|
|
14709
14778
|
try {
|
|
14710
14779
|
await onComplete(result);
|
|
14711
14780
|
} catch (err) {
|
|
14712
|
-
log$
|
|
14781
|
+
log$33.warn("analysis enqueue completion failed", {
|
|
14713
14782
|
purpose: params.purpose,
|
|
14714
14783
|
error: err instanceof Error ? err.message : String(err)
|
|
14715
14784
|
});
|
|
@@ -14765,7 +14834,7 @@ function createRuntimeAnalysis(deps = {}, concurrencyConfig) {
|
|
|
14765
14834
|
(async () => {
|
|
14766
14835
|
try {
|
|
14767
14836
|
const result = await executeAnalysis(job.params, mergedDeps, DEFAULT_RUN_TIMEOUT_MS, CommandLane.Analysis);
|
|
14768
|
-
log$
|
|
14837
|
+
log$33.info("analysis run completed", {
|
|
14769
14838
|
pluginId: job.params.pluginId,
|
|
14770
14839
|
purpose: job.params.purpose,
|
|
14771
14840
|
durationMs: result.elapsedMs,
|
|
@@ -14814,7 +14883,7 @@ function createRuntimeAnalysis(deps = {}, concurrencyConfig) {
|
|
|
14814
14883
|
const parallelSlot = activeParallelRuns;
|
|
14815
14884
|
try {
|
|
14816
14885
|
const result = await executeAnalysis(runParams, mergedDeps, DEFAULT_RUN_TIMEOUT_MS, CommandLane.Analysis);
|
|
14817
|
-
log$
|
|
14886
|
+
log$33.info("analysis run completed", {
|
|
14818
14887
|
pluginId: runParams.pluginId,
|
|
14819
14888
|
purpose: params.purpose,
|
|
14820
14889
|
durationMs: result.elapsedMs,
|
|
@@ -14852,7 +14921,7 @@ function createRuntimeAnalysis(deps = {}, concurrencyConfig) {
|
|
|
14852
14921
|
});
|
|
14853
14922
|
}
|
|
14854
14923
|
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";
|
|
14855
|
-
log$
|
|
14924
|
+
log$33.info("analysis run rejected", {
|
|
14856
14925
|
pluginId: runParams.pluginId,
|
|
14857
14926
|
purpose: params.purpose,
|
|
14858
14927
|
error: "analysis concurrency limit exceeded",
|
|
@@ -20372,7 +20441,7 @@ function stopSweeper$1() {
|
|
|
20372
20441
|
|
|
20373
20442
|
//#endregion
|
|
20374
20443
|
//#region src/infra/exec-approvals.ts
|
|
20375
|
-
const log$
|
|
20444
|
+
const log$32 = createSubsystemLogger("infra/exec-approvals");
|
|
20376
20445
|
const APPROVALS_FILE = join(process.env.HOME ?? "/tmp", ".openclaw", "exec-approvals.json");
|
|
20377
20446
|
const DEFAULT_SECURITY = "deny";
|
|
20378
20447
|
const DEFAULT_ASK = "on-miss";
|
|
@@ -21622,7 +21691,7 @@ function createRunRegistry(options) {
|
|
|
21622
21691
|
|
|
21623
21692
|
//#endregion
|
|
21624
21693
|
//#region src/process/supervisor/supervisor.ts
|
|
21625
|
-
const log$
|
|
21694
|
+
const log$31 = createSubsystemLogger("process/supervisor");
|
|
21626
21695
|
function clampTimeout(value) {
|
|
21627
21696
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return;
|
|
21628
21697
|
return Math.max(1, Math.floor(value));
|
|
@@ -21808,7 +21877,7 @@ function createProcessSupervisor() {
|
|
|
21808
21877
|
exitCode: null,
|
|
21809
21878
|
exitSignal: null
|
|
21810
21879
|
});
|
|
21811
|
-
log$
|
|
21880
|
+
log$31.warn(`spawn failed: runId=${runId} reason=${String(err)}`);
|
|
21812
21881
|
throw err;
|
|
21813
21882
|
}
|
|
21814
21883
|
};
|
|
@@ -22835,7 +22904,7 @@ function normalizeSystemRunApprovalPlan(value) {
|
|
|
22835
22904
|
|
|
22836
22905
|
//#endregion
|
|
22837
22906
|
//#region src/infra/system-run-command.ts
|
|
22838
|
-
const log$
|
|
22907
|
+
const log$30 = createSubsystemLogger("infra/system-run-command");
|
|
22839
22908
|
function formatExecCommand(argv) {
|
|
22840
22909
|
return argv.map((arg) => {
|
|
22841
22910
|
if (arg.length === 0) return "\"\"";
|
|
@@ -25135,7 +25204,7 @@ const BACKGROUND_IDLE_RECHECK_MS = 1e3;
|
|
|
25135
25204
|
const BACKGROUND_IDLE_MAX_ATTEMPTS = 30;
|
|
25136
25205
|
const backgroundIdleAttempts = /* @__PURE__ */ new Map();
|
|
25137
25206
|
const SIGNAL_DEADLINE_GRACE_MS = 0;
|
|
25138
|
-
const log$
|
|
25207
|
+
const log$29 = createSubsystemLogger("agent-signals");
|
|
25139
25208
|
function normalizeTrimmed(value) {
|
|
25140
25209
|
return value?.trim() || void 0;
|
|
25141
25210
|
}
|
|
@@ -25421,7 +25490,7 @@ function dispatchHeartbeatSignal(signal, now = Date.now()) {
|
|
|
25421
25490
|
if (!signal.sessionKey) return false;
|
|
25422
25491
|
if (signal.requiresIdle === true) {
|
|
25423
25492
|
if (signal.notBeforeMs !== void 0 && now > signal.notBeforeMs + SIGNAL_DEADLINE_GRACE_MS) {
|
|
25424
|
-
log$
|
|
25493
|
+
log$29.warn("agent-signals: evicting requiresIdle heartbeat signal past its deadline", {
|
|
25425
25494
|
signalId: signal.id,
|
|
25426
25495
|
type: signal.type,
|
|
25427
25496
|
source: signal.source,
|
|
@@ -25759,11 +25828,11 @@ function getAgentSignalAvailability(params) {
|
|
|
25759
25828
|
|
|
25760
25829
|
//#endregion
|
|
25761
25830
|
//#region src/infra/background-run.ts
|
|
25762
|
-
const log$
|
|
25831
|
+
const log$28 = createSubsystemLogger("infra/background-run");
|
|
25763
25832
|
|
|
25764
25833
|
//#endregion
|
|
25765
25834
|
//#region src/infra/heartbeat-active-hours.ts
|
|
25766
|
-
const log$
|
|
25835
|
+
const log$27 = createSubsystemLogger("heartbeat-active-hours");
|
|
25767
25836
|
|
|
25768
25837
|
//#endregion
|
|
25769
25838
|
//#region src/infra/heartbeat-events-filter.ts
|
|
@@ -25816,7 +25885,7 @@ function isCronSystemEvent(evt) {
|
|
|
25816
25885
|
|
|
25817
25886
|
//#endregion
|
|
25818
25887
|
//#region src/infra/heartbeat-events.ts
|
|
25819
|
-
const log$
|
|
25888
|
+
const log$26 = createSubsystemLogger("infra/heartbeat-events");
|
|
25820
25889
|
function resolveIndicatorType(status) {
|
|
25821
25890
|
switch (status) {
|
|
25822
25891
|
case "ok-empty":
|
|
@@ -25838,7 +25907,7 @@ function emitHeartbeatEvent(evt) {
|
|
|
25838
25907
|
for (const listener of listeners) try {
|
|
25839
25908
|
listener(enriched);
|
|
25840
25909
|
} catch (err) {
|
|
25841
|
-
log$
|
|
25910
|
+
log$26.warn("heartbeat event listener threw", { error: err });
|
|
25842
25911
|
}
|
|
25843
25912
|
}
|
|
25844
25913
|
|
|
@@ -26688,7 +26757,7 @@ function resolveHeartbeatSenderContext(params) {
|
|
|
26688
26757
|
|
|
26689
26758
|
//#endregion
|
|
26690
26759
|
//#region src/infra/nudge.ts
|
|
26691
|
-
const log$
|
|
26760
|
+
const log$25 = createSubsystemLogger("infra/nudge");
|
|
26692
26761
|
function renderSummary(text, data) {
|
|
26693
26762
|
if (data && Object.keys(data).length > 0) try {
|
|
26694
26763
|
return `${text}\n\nData:\n${JSON.stringify(data, null, 2)}`;
|
|
@@ -26722,14 +26791,14 @@ function requestNudge(input, cfg = loadConfig(), deps) {
|
|
|
26722
26791
|
const enqueue = deps.enqueueAgentTurn;
|
|
26723
26792
|
try {
|
|
26724
26793
|
enqueue(payload).catch((error) => {
|
|
26725
|
-
log$
|
|
26794
|
+
log$25.warn("nudge enqueue failed", {
|
|
26726
26795
|
error,
|
|
26727
26796
|
sessionKey: redactIdentifier(sessionKey),
|
|
26728
26797
|
signalId
|
|
26729
26798
|
});
|
|
26730
26799
|
});
|
|
26731
26800
|
} catch (error) {
|
|
26732
|
-
log$
|
|
26801
|
+
log$25.warn("nudge enqueue failed", {
|
|
26733
26802
|
error,
|
|
26734
26803
|
sessionKey: redactIdentifier(sessionKey),
|
|
26735
26804
|
signalId
|
|
@@ -26746,20 +26815,20 @@ function requestNudge(input, cfg = loadConfig(), deps) {
|
|
|
26746
26815
|
const { backbone, runner } = getAgentTurnRuntime();
|
|
26747
26816
|
const id = await enqueueAgentTurn(backbone, payload);
|
|
26748
26817
|
if (!isClaimableAgentTurnWorkId(id)) return;
|
|
26749
|
-
const { runMainAgentTurn } = await import("./agent-turn-execute-
|
|
26818
|
+
const { runMainAgentTurn } = await import("./agent-turn-execute-CBIog9rc.js");
|
|
26750
26819
|
await runner.claimAndExecute({
|
|
26751
26820
|
workId: id,
|
|
26752
26821
|
execute: (claim) => runMainAgentTurn(claim.message.payload)
|
|
26753
26822
|
});
|
|
26754
26823
|
})().catch((error) => {
|
|
26755
|
-
log$
|
|
26824
|
+
log$25.warn("nudge claim chain failed", {
|
|
26756
26825
|
error,
|
|
26757
26826
|
sessionKey: redactIdentifier(sessionKey),
|
|
26758
26827
|
signalId
|
|
26759
26828
|
});
|
|
26760
26829
|
});
|
|
26761
26830
|
} catch (error) {
|
|
26762
|
-
log$
|
|
26831
|
+
log$25.warn("nudge enqueue failed", {
|
|
26763
26832
|
error,
|
|
26764
26833
|
sessionKey: redactIdentifier(sessionKey),
|
|
26765
26834
|
signalId
|
|
@@ -26774,7 +26843,7 @@ function requestNudge(input, cfg = loadConfig(), deps) {
|
|
|
26774
26843
|
|
|
26775
26844
|
//#endregion
|
|
26776
26845
|
//#region src/infra/wake-gate.ts
|
|
26777
|
-
const log$
|
|
26846
|
+
const log$24 = createSubsystemLogger("wake-gate");
|
|
26778
26847
|
const DEFAULT_COMMAND_TIMEOUT_MS = 3e4;
|
|
26779
26848
|
const DEFAULT_MODEL_TIMEOUT_MS = 3e4;
|
|
26780
26849
|
const MAX_COMMAND_OUTPUT_BYTES = 64 * 1024;
|
|
@@ -26896,7 +26965,7 @@ async function runWakeGate(spec, ctx) {
|
|
|
26896
26965
|
if (spec.kind === "command") return await runCommandGate(spec, ctx);
|
|
26897
26966
|
else return await runModelGate(spec, ctx);
|
|
26898
26967
|
} catch (err) {
|
|
26899
|
-
log$
|
|
26968
|
+
log$24.error("wake-gate error (no crash)", {
|
|
26900
26969
|
kind: spec.kind,
|
|
26901
26970
|
error: err instanceof Error ? err.message : String(err)
|
|
26902
26971
|
});
|
|
@@ -26907,7 +26976,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
26907
26976
|
try {
|
|
26908
26977
|
const result = await runCommand(spec.command, spec.cwd, spec.timeoutMs, _ctx.abortSignal);
|
|
26909
26978
|
if (result.exit !== 0) {
|
|
26910
|
-
log$
|
|
26979
|
+
log$24.warn("wake gate command non-zero exit", {
|
|
26911
26980
|
kind: "command",
|
|
26912
26981
|
exit: result.exit,
|
|
26913
26982
|
...stdoutShapeForLog(result.stdout)
|
|
@@ -26916,7 +26985,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
26916
26985
|
}
|
|
26917
26986
|
const lines = result.stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
26918
26987
|
if (lines.length === 0) {
|
|
26919
|
-
log$
|
|
26988
|
+
log$24.warn("wake gate command produced no output", {
|
|
26920
26989
|
kind: "command",
|
|
26921
26990
|
exit: result.exit,
|
|
26922
26991
|
...stdoutShapeForLog(result.stdout)
|
|
@@ -26926,7 +26995,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
26926
26995
|
const lastLine = lines[lines.length - 1];
|
|
26927
26996
|
const decision = await parseWakeDecision(lastLine);
|
|
26928
26997
|
if (!decision) {
|
|
26929
|
-
log$
|
|
26998
|
+
log$24.warn("wake gate command output did not parse as a wake decision", {
|
|
26930
26999
|
kind: "command",
|
|
26931
27000
|
exit: result.exit,
|
|
26932
27001
|
...stdoutShapeForLog(result.stdout)
|
|
@@ -26934,14 +27003,14 @@ async function runCommandGate(spec, _ctx) {
|
|
|
26934
27003
|
return { wake: false };
|
|
26935
27004
|
}
|
|
26936
27005
|
if (!decision.wakeAgent) {
|
|
26937
|
-
log$
|
|
27006
|
+
log$24.debug("wake gate command decided not to wake", {
|
|
26938
27007
|
kind: "command",
|
|
26939
27008
|
exit: result.exit,
|
|
26940
27009
|
...stdoutShapeForLog(result.stdout)
|
|
26941
27010
|
});
|
|
26942
27011
|
return { wake: false };
|
|
26943
27012
|
}
|
|
26944
|
-
log$
|
|
27013
|
+
log$24.info("wake gate command decided to wake", {
|
|
26945
27014
|
kind: "command",
|
|
26946
27015
|
exit: result.exit,
|
|
26947
27016
|
hasText: decision.text !== void 0,
|
|
@@ -26952,7 +27021,7 @@ async function runCommandGate(spec, _ctx) {
|
|
|
26952
27021
|
if (decision.data !== void 0) res.data = decision.data;
|
|
26953
27022
|
return res;
|
|
26954
27023
|
} catch (err) {
|
|
26955
|
-
log$
|
|
27024
|
+
log$24.warn("command gate error", { error: err instanceof Error ? err.message : String(err) });
|
|
26956
27025
|
return { wake: false };
|
|
26957
27026
|
}
|
|
26958
27027
|
}
|
|
@@ -26990,27 +27059,27 @@ async function runModelGate(spec, ctx) {
|
|
|
26990
27059
|
...ctx.abortSignal ? { abortSignal: ctx.abortSignal } : {}
|
|
26991
27060
|
})).payloads ?? []).filter((payload) => !payload.isError && typeof payload.text === "string").map((payload) => payload.text ?? "").join("\n").trim();
|
|
26992
27061
|
if (!modelOutput) {
|
|
26993
|
-
log$
|
|
27062
|
+
log$24.warn("wake gate model produced no output", { kind: "model" });
|
|
26994
27063
|
return { wake: false };
|
|
26995
27064
|
}
|
|
26996
27065
|
const outputLines = modelOutput.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
26997
27066
|
const lastLine = outputLines[outputLines.length - 1] ?? modelOutput;
|
|
26998
27067
|
const decision = await parseWakeDecision(modelOutput) ?? await parseWakeDecision(lastLine);
|
|
26999
27068
|
if (!decision) {
|
|
27000
|
-
log$
|
|
27069
|
+
log$24.warn("wake gate model output did not parse as a wake decision", {
|
|
27001
27070
|
kind: "model",
|
|
27002
27071
|
tail: tailForLog(modelOutput)
|
|
27003
27072
|
});
|
|
27004
27073
|
return { wake: false };
|
|
27005
27074
|
}
|
|
27006
27075
|
if (!decision.wakeAgent) {
|
|
27007
|
-
log$
|
|
27076
|
+
log$24.debug("wake gate model decided not to wake", {
|
|
27008
27077
|
kind: "model",
|
|
27009
27078
|
tail: tailForLog(modelOutput)
|
|
27010
27079
|
});
|
|
27011
27080
|
return { wake: false };
|
|
27012
27081
|
}
|
|
27013
|
-
log$
|
|
27082
|
+
log$24.info("wake gate model decided to wake", {
|
|
27014
27083
|
kind: "model",
|
|
27015
27084
|
hasText: decision.text !== void 0,
|
|
27016
27085
|
hasData: decision.data !== void 0
|
|
@@ -27020,7 +27089,7 @@ async function runModelGate(spec, ctx) {
|
|
|
27020
27089
|
if (decision.data !== void 0) res.data = decision.data;
|
|
27021
27090
|
return res;
|
|
27022
27091
|
} catch (err) {
|
|
27023
|
-
log$
|
|
27092
|
+
log$24.warn("model gate error", { error: err instanceof Error ? err.message : String(err) });
|
|
27024
27093
|
return { wake: false };
|
|
27025
27094
|
} finally {
|
|
27026
27095
|
if (tmpDir) await fs$1.rm(tmpDir, {
|
|
@@ -27032,7 +27101,7 @@ async function runModelGate(spec, ctx) {
|
|
|
27032
27101
|
|
|
27033
27102
|
//#endregion
|
|
27034
27103
|
//#region src/infra/heartbeat-runner.ts
|
|
27035
|
-
const log$
|
|
27104
|
+
const log$23 = createSubsystemLogger("gateway/heartbeat");
|
|
27036
27105
|
const DEFAULT_HEARTBEAT_TARGET = "none";
|
|
27037
27106
|
const redactHeartbeatLogIdentifier = (value) => value?.trim() ? redactIdentifier(value) : null;
|
|
27038
27107
|
function isHeartbeatSessionResolutionError(resolution) {
|
|
@@ -27209,7 +27278,7 @@ async function pruneHeartbeatTranscript(params) {
|
|
|
27209
27278
|
throw err;
|
|
27210
27279
|
}
|
|
27211
27280
|
} catch (err) {
|
|
27212
|
-
log$
|
|
27281
|
+
log$23.warn(`pruneHeartbeatTranscript error: ${err instanceof Error ? err.message : String(err)}`, { transcriptPath });
|
|
27213
27282
|
}
|
|
27214
27283
|
}
|
|
27215
27284
|
/**
|
|
@@ -27449,7 +27518,7 @@ async function prepareHeartbeatDeliveryAndPrompt(params) {
|
|
|
27449
27518
|
reason: HEARTBEAT_SKIP_WAKE_GATE_EMPTY,
|
|
27450
27519
|
durationMs: Date.now() - startedAt
|
|
27451
27520
|
});
|
|
27452
|
-
log$
|
|
27521
|
+
log$23.info("heartbeat: wake gate suppressed run", {
|
|
27453
27522
|
agentId: redactHeartbeatLogIdentifier(agentId),
|
|
27454
27523
|
reason: HEARTBEAT_SKIP_WAKE_GATE_EMPTY
|
|
27455
27524
|
});
|
|
@@ -27460,16 +27529,16 @@ async function prepareHeartbeatDeliveryAndPrompt(params) {
|
|
|
27460
27529
|
}
|
|
27461
27530
|
wakeGateText = wakeResult.data !== void 0 ? `${wakeResult.text ?? ""}\n\nData:\n${JSON.stringify(wakeResult.data, null, 2)}`.trim() : wakeResult.text?.trim() || void 0;
|
|
27462
27531
|
}
|
|
27463
|
-
if (delivery.reason === "unknown-account") log$
|
|
27532
|
+
if (delivery.reason === "unknown-account") log$23.warn("heartbeat: unknown accountId", {
|
|
27464
27533
|
accountId: redactHeartbeatLogIdentifier(delivery.accountId ?? heartbeatAccountId),
|
|
27465
27534
|
target: heartbeat?.target ?? "none"
|
|
27466
27535
|
});
|
|
27467
|
-
else if (heartbeatAccountId) log$
|
|
27536
|
+
else if (heartbeatAccountId) log$23.info("heartbeat: using explicit accountId", {
|
|
27468
27537
|
accountId: redactHeartbeatLogIdentifier(delivery.accountId ?? heartbeatAccountId),
|
|
27469
27538
|
target: heartbeat?.target ?? "none",
|
|
27470
27539
|
channel: delivery.channel
|
|
27471
27540
|
});
|
|
27472
|
-
log$
|
|
27541
|
+
log$23.info("heartbeat: resolved plan", {
|
|
27473
27542
|
agentId: redactHeartbeatLogIdentifier(agentId),
|
|
27474
27543
|
sessionKey: redactHeartbeatLogIdentifier(sessionKey),
|
|
27475
27544
|
sessionSource: preflight.session.source,
|
|
@@ -27544,7 +27613,7 @@ async function resolveHeartbeatPreflightOrSkip(params) {
|
|
|
27544
27613
|
durationMs: Date.now() - startedAt,
|
|
27545
27614
|
indicatorType: resolveIndicatorType("failed")
|
|
27546
27615
|
});
|
|
27547
|
-
log$
|
|
27616
|
+
log$23.error(`heartbeat failed: ${publicReason}`, {
|
|
27548
27617
|
error: publicReason,
|
|
27549
27618
|
agentId: redactHeartbeatLogIdentifier(agentId),
|
|
27550
27619
|
sessionSource: preflight.sessionError.source,
|
|
@@ -27563,7 +27632,7 @@ async function resolveHeartbeatPreflightOrSkip(params) {
|
|
|
27563
27632
|
durationMs: Date.now() - startedAt,
|
|
27564
27633
|
indicatorType: resolveIndicatorType("failed")
|
|
27565
27634
|
});
|
|
27566
|
-
log$
|
|
27635
|
+
log$23.error(`heartbeat failed: ${reason}`, {
|
|
27567
27636
|
error: reason,
|
|
27568
27637
|
agentId: redactHeartbeatLogIdentifier(agentId)
|
|
27569
27638
|
});
|
|
@@ -27600,7 +27669,7 @@ async function loadSharedSessionHeartbeatContext(params) {
|
|
|
27600
27669
|
if (present.length === 0) return;
|
|
27601
27670
|
return present.map((file) => `## ${file.path}\n\n${file.content}`).join("\n\n");
|
|
27602
27671
|
} catch (err) {
|
|
27603
|
-
log$
|
|
27672
|
+
log$23.warn("failed to load heartbeat context files for trigger message", { error: err });
|
|
27604
27673
|
return;
|
|
27605
27674
|
}
|
|
27606
27675
|
}
|
|
@@ -27905,7 +27974,7 @@ async function finalizeTurnOutcome(params) {
|
|
|
27905
27974
|
channel: delivery.channel,
|
|
27906
27975
|
accountId: delivery.accountId
|
|
27907
27976
|
});
|
|
27908
|
-
log$
|
|
27977
|
+
log$23.warn("heartbeat: channel not ready", {
|
|
27909
27978
|
channel: delivery.channel,
|
|
27910
27979
|
reason: readiness.reason
|
|
27911
27980
|
});
|
|
@@ -27993,11 +28062,11 @@ async function cleanupIsolatedHeartbeatSession(params) {
|
|
|
27993
28062
|
restrictToStoreDir: true
|
|
27994
28063
|
});
|
|
27995
28064
|
} catch (archiveErr) {
|
|
27996
|
-
log$
|
|
28065
|
+
log$23.warn(`cron: error-path isolated session archive failed: ${formatErrorMessage(archiveErr)}`, { sessionId: isolatedEntry.sessionId });
|
|
27997
28066
|
}
|
|
27998
28067
|
delete store[createdIsolatedSessionKey];
|
|
27999
28068
|
}).catch((cleanupErr) => {
|
|
28000
|
-
log$
|
|
28069
|
+
log$23.warn(`failed to clean up isolated heartbeat session on error: ${String(cleanupErr)}`);
|
|
28001
28070
|
});
|
|
28002
28071
|
}
|
|
28003
28072
|
async function handleHeartbeatError(params) {
|
|
@@ -28017,7 +28086,7 @@ async function handleHeartbeatError(params) {
|
|
|
28017
28086
|
accountId: delivery.accountId,
|
|
28018
28087
|
indicatorType: visibility.useIndicator ? resolveIndicatorType("failed") : void 0
|
|
28019
28088
|
});
|
|
28020
|
-
log$
|
|
28089
|
+
log$23.error(`heartbeat failed: ${reason}`, { error: reason });
|
|
28021
28090
|
return {
|
|
28022
28091
|
status: "failed",
|
|
28023
28092
|
reason
|
|
@@ -28029,7 +28098,7 @@ async function handleHeartbeatError(params) {
|
|
|
28029
28098
|
const AGENT_TURN_PROMPT = "Process the pending system events for this session.";
|
|
28030
28099
|
async function ackAnnounceExecuted(payload) {
|
|
28031
28100
|
if (payload.kind !== "announce") return;
|
|
28032
|
-
const { markSubagentAnnounceExecuted } = await import("./subagent-registry-
|
|
28101
|
+
const { markSubagentAnnounceExecuted } = await import("./subagent-registry-D22XEgZh.js");
|
|
28033
28102
|
for (const runId of [payload.runId, ...payload.mergedRunIds ?? []]) try {
|
|
28034
28103
|
await markSubagentAnnounceExecuted(runId);
|
|
28035
28104
|
} catch {}
|
|
@@ -28170,7 +28239,7 @@ async function runMainAgentTurn(payload, opts) {
|
|
|
28170
28239
|
|
|
28171
28240
|
//#endregion
|
|
28172
28241
|
//#region src/agents/subagent-announce-turn.ts
|
|
28173
|
-
const log$
|
|
28242
|
+
const log$22 = createSubsystemLogger("agents/subagent-announce-turn");
|
|
28174
28243
|
function clearDelayedReleaseHoldIfNoAnnounceIsParked(sessionKey) {
|
|
28175
28244
|
if (!peekDelayedAgentTurn(sessionKey, (payload) => payload.kind === "announce")) clearDelayedReleaseHold(sessionKey);
|
|
28176
28245
|
}
|
|
@@ -28230,7 +28299,7 @@ async function publishSubagentAnnounceTurn(params) {
|
|
|
28230
28299
|
};
|
|
28231
28300
|
} catch (error) {
|
|
28232
28301
|
clearDelayedReleaseHoldIfNoAnnounceIsParked(params.requesterSessionKey);
|
|
28233
|
-
log$
|
|
28302
|
+
log$22.warn("subagent announce turn failed", { error: String(error) });
|
|
28234
28303
|
return {
|
|
28235
28304
|
status: "failed",
|
|
28236
28305
|
error: String(error)
|
|
@@ -28505,7 +28574,7 @@ const DIRECT_ANNOUNCE_TRANSIENT_RETRY_DELAYS_MS = FAST_TEST_MODE ? [
|
|
|
28505
28574
|
let subagentRegistryAccessPromise;
|
|
28506
28575
|
const STALLED_SIBLING_ANNOUNCE_HOLD_MS = 5 * 6e4;
|
|
28507
28576
|
function loadSubagentRegistryAccess() {
|
|
28508
|
-
if (!subagentRegistryAccessPromise) subagentRegistryAccessPromise = import("./subagent-registry-
|
|
28577
|
+
if (!subagentRegistryAccessPromise) subagentRegistryAccessPromise = import("./subagent-registry-D22XEgZh.js").catch((err) => {
|
|
28509
28578
|
const message = err instanceof Error && err.message ? err.message : String(err);
|
|
28510
28579
|
defaultRuntime.log(`[warn] subagent registry access import failed: ${message}`);
|
|
28511
28580
|
subagentRegistryAccessPromise = void 0;
|
|
@@ -34518,7 +34587,7 @@ const FIELD_LABELS = {
|
|
|
34518
34587
|
|
|
34519
34588
|
//#endregion
|
|
34520
34589
|
//#region src/config/schema.hints.ts
|
|
34521
|
-
const log$
|
|
34590
|
+
const log$21 = createSubsystemLogger("config/schema");
|
|
34522
34591
|
const NORMALIZED_SENSITIVE_KEY_WHITELIST_SUFFIXES = [
|
|
34523
34592
|
"maxtokens",
|
|
34524
34593
|
"maxoutputtokens",
|
|
@@ -34559,7 +34628,7 @@ function isSensitiveConfigPath(path) {
|
|
|
34559
34628
|
|
|
34560
34629
|
//#endregion
|
|
34561
34630
|
//#region src/config/redact-snapshot.ts
|
|
34562
|
-
const log$
|
|
34631
|
+
const log$20 = createSubsystemLogger("config/redaction");
|
|
34563
34632
|
const ENV_VAR_PLACEHOLDER_PATTERN = /^\$\{[^}]*\}$/;
|
|
34564
34633
|
function isSensitivePath(path) {
|
|
34565
34634
|
if (path.endsWith("[]")) return isSensitiveConfigPath(path.slice(0, -2));
|
|
@@ -39971,7 +40040,7 @@ async function handleSubagentsLogAction(ctx) {
|
|
|
39971
40040
|
|
|
39972
40041
|
//#endregion
|
|
39973
40042
|
//#region src/agents/pi-embedded-runner/logger.ts
|
|
39974
|
-
const log$
|
|
40043
|
+
const log$19 = createSubsystemLogger("agent/embedded");
|
|
39975
40044
|
|
|
39976
40045
|
//#endregion
|
|
39977
40046
|
//#region src/agents/pi-embedded-runner/run-sender-identity.ts
|
|
@@ -40016,7 +40085,7 @@ function resolveRunSenderIdentity(params) {
|
|
|
40016
40085
|
candidate: params.inheritedCanonicalIdentity
|
|
40017
40086
|
});
|
|
40018
40087
|
if (inherited) {
|
|
40019
|
-
log$
|
|
40088
|
+
log$19.info("runtime identity injected", {
|
|
40020
40089
|
identitySource: "parent-session",
|
|
40021
40090
|
canonicalIdentity: inherited,
|
|
40022
40091
|
trigger: params.trigger,
|
|
@@ -40035,7 +40104,7 @@ function resolveRunSenderIdentity(params) {
|
|
|
40035
40104
|
candidate: params.configuredIdentity
|
|
40036
40105
|
});
|
|
40037
40106
|
if (configured) {
|
|
40038
|
-
log$
|
|
40107
|
+
log$19.info("runtime identity injected", {
|
|
40039
40108
|
identitySource: "job-config",
|
|
40040
40109
|
canonicalIdentity: configured,
|
|
40041
40110
|
trigger: params.trigger,
|
|
@@ -46015,7 +46084,7 @@ const REMINDER_CONTEXT_MESSAGES_MAX = 10;
|
|
|
46015
46084
|
const REMINDER_CONTEXT_PER_MESSAGE_MAX = 220;
|
|
46016
46085
|
const REMINDER_CONTEXT_TOTAL_MAX = 700;
|
|
46017
46086
|
const REMINDER_CONTEXT_MARKER = "\n\nRecent context:\n";
|
|
46018
|
-
const log$
|
|
46087
|
+
const log$18 = createSubsystemLogger("cron-tool");
|
|
46019
46088
|
const AGENT_FORBIDDEN_JOB_FIELDS = new Set(["identity", "state"]);
|
|
46020
46089
|
const JOB_KEYS = new Set([
|
|
46021
46090
|
"name",
|
|
@@ -46151,7 +46220,7 @@ async function buildReminderContextLines(params) {
|
|
|
46151
46220
|
}
|
|
46152
46221
|
return lines;
|
|
46153
46222
|
} catch (err) {
|
|
46154
|
-
log$
|
|
46223
|
+
log$18.warn("reminder context fetch failed", { error: err });
|
|
46155
46224
|
return ["- (context unavailable: gateway unreachable)"];
|
|
46156
46225
|
}
|
|
46157
46226
|
}
|
|
@@ -46707,7 +46776,7 @@ function assertGatewayToolActionAllowed(params) {
|
|
|
46707
46776
|
|
|
46708
46777
|
//#endregion
|
|
46709
46778
|
//#region src/agents/tools/gateway-tool.ts
|
|
46710
|
-
const log$
|
|
46779
|
+
const log$17 = createSubsystemLogger("gateway-tool");
|
|
46711
46780
|
const DEFAULT_UPDATE_TIMEOUT_MS = 20 * 6e4;
|
|
46712
46781
|
const GatewayToolSchema = Type.Object({
|
|
46713
46782
|
action: stringEnum([
|
|
@@ -46775,7 +46844,7 @@ function createGatewayTool(opts) {
|
|
|
46775
46844
|
try {
|
|
46776
46845
|
await writeRestartSentinel(payload);
|
|
46777
46846
|
} catch {}
|
|
46778
|
-
log$
|
|
46847
|
+
log$17.info(`gateway tool: restart requested (delayMs=${delayMs ?? "default"}, reason=${reason ?? "none"})`);
|
|
46779
46848
|
return jsonResult(scheduleGatewaySigusr1Restart({
|
|
46780
46849
|
delayMs,
|
|
46781
46850
|
reason
|
|
@@ -52590,7 +52659,7 @@ async function resolveAnnounceTarget(params) {
|
|
|
52590
52659
|
|
|
52591
52660
|
//#endregion
|
|
52592
52661
|
//#region src/agents/tools/sessions-send-tool.a2a.ts
|
|
52593
|
-
const log$
|
|
52662
|
+
const log$16 = createSubsystemLogger("agents/sessions-send");
|
|
52594
52663
|
async function runSessionsSendA2AFlow(params) {
|
|
52595
52664
|
const runContextId = params.waitRunId ?? "unknown";
|
|
52596
52665
|
try {
|
|
@@ -52685,7 +52754,7 @@ async function runSessionsSendA2AFlow(params) {
|
|
|
52685
52754
|
timeoutMs: 1e4
|
|
52686
52755
|
});
|
|
52687
52756
|
} catch (err) {
|
|
52688
|
-
log$
|
|
52757
|
+
log$16.warn("sessions_send announce delivery failed", {
|
|
52689
52758
|
runId: runContextId,
|
|
52690
52759
|
channel: announceTarget.channel,
|
|
52691
52760
|
to: announceTarget.to,
|
|
@@ -52693,7 +52762,7 @@ async function runSessionsSendA2AFlow(params) {
|
|
|
52693
52762
|
});
|
|
52694
52763
|
}
|
|
52695
52764
|
} catch (err) {
|
|
52696
|
-
log$
|
|
52765
|
+
log$16.warn("sessions_send announce flow failed", {
|
|
52697
52766
|
runId: runContextId,
|
|
52698
52767
|
error: formatErrorMessage(err)
|
|
52699
52768
|
});
|
|
@@ -55976,7 +56045,7 @@ function resolveRunWorkspaceDir(params) {
|
|
|
55976
56045
|
|
|
55977
56046
|
//#endregion
|
|
55978
56047
|
//#region src/agents/cli-runner.ts
|
|
55979
|
-
const log$
|
|
56048
|
+
const log$15 = createSubsystemLogger("agent/claude-cli");
|
|
55980
56049
|
async function runCliAgent(params) {
|
|
55981
56050
|
const started = Date.now();
|
|
55982
56051
|
const workspaceResolution = resolveRunWorkspaceDir({
|
|
@@ -55989,7 +56058,7 @@ async function runCliAgent(params) {
|
|
|
55989
56058
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
55990
56059
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
55991
56060
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
55992
|
-
if (workspaceResolution.usedFallback) log$
|
|
56061
|
+
if (workspaceResolution.usedFallback) log$15.warn(`[workspace-fallback] caller=runCliAgent reason=${workspaceResolution.fallbackReason} run=${params.runId} session=${redactedSessionId} sessionKey=${redactedSessionKey} agent=${workspaceResolution.agentId} workspace=${redactedWorkspace}`);
|
|
55993
56062
|
const workspaceDir = resolvedWorkspace;
|
|
55994
56063
|
const backendResolved = resolveCliBackendConfig(params.provider, params.config);
|
|
55995
56064
|
if (!backendResolved) throw new Error(`Unknown CLI backend: ${params.provider}`);
|
|
@@ -56019,7 +56088,7 @@ async function runCliAgent(params) {
|
|
|
56019
56088
|
resolvedSystemPrompt,
|
|
56020
56089
|
warn: makeBootstrapWarn({
|
|
56021
56090
|
sessionLabel,
|
|
56022
|
-
warn: (message) => log$
|
|
56091
|
+
warn: (message) => log$15.warn(message)
|
|
56023
56092
|
})
|
|
56024
56093
|
});
|
|
56025
56094
|
const heartbeatPrompt = sessionAgentId === defaultAgentId ? resolveHeartbeatPrompt$1(params.config?.agents?.defaults?.heartbeat?.prompt) : void 0;
|
|
@@ -56082,7 +56151,7 @@ async function runCliAgent(params) {
|
|
|
56082
56151
|
const queueKey = backend.serialize ?? true ? backendResolved.id : `${backendResolved.id}:${params.runId}`;
|
|
56083
56152
|
try {
|
|
56084
56153
|
return await enqueueCliRun(queueKey, async () => {
|
|
56085
|
-
log$
|
|
56154
|
+
log$15.info(`cli exec: provider=${params.provider} model=${normalizedModel} promptChars=${params.prompt.length}`);
|
|
56086
56155
|
const logOutputText = isTruthyEnvValue(process.env.OPENCLAW_CLAUDE_CLI_LOG_OUTPUT);
|
|
56087
56156
|
if (logOutputText) {
|
|
56088
56157
|
const logArgs = [];
|
|
@@ -56115,7 +56184,7 @@ async function runCliAgent(params) {
|
|
|
56115
56184
|
const promptIndex = logArgs.indexOf(argsPrompt);
|
|
56116
56185
|
if (promptIndex >= 0) logArgs[promptIndex] = `<prompt:${argsPrompt.length} chars>`;
|
|
56117
56186
|
}
|
|
56118
|
-
log$
|
|
56187
|
+
log$15.info(`cli argv: ${backend.command} ${logArgs.join(" ")}`);
|
|
56119
56188
|
}
|
|
56120
56189
|
const env = (() => {
|
|
56121
56190
|
const next = {
|
|
@@ -56153,17 +56222,17 @@ async function runCliAgent(params) {
|
|
|
56153
56222
|
const stdout = result.stdout.trim();
|
|
56154
56223
|
const stderr = result.stderr.trim();
|
|
56155
56224
|
if (logOutputText) {
|
|
56156
|
-
if (stdout) log$
|
|
56157
|
-
if (stderr) log$
|
|
56225
|
+
if (stdout) log$15.info(`cli stdout:\n${stdout}`);
|
|
56226
|
+
if (stderr) log$15.info(`cli stderr:\n${stderr}`);
|
|
56158
56227
|
}
|
|
56159
56228
|
if (shouldLogVerbose()) {
|
|
56160
|
-
if (stdout) log$
|
|
56161
|
-
if (stderr) log$
|
|
56229
|
+
if (stdout) log$15.debug(`cli stdout:\n${stdout}`);
|
|
56230
|
+
if (stderr) log$15.debug(`cli stderr:\n${stderr}`);
|
|
56162
56231
|
}
|
|
56163
56232
|
if (result.exitCode !== 0 || result.reason !== "exit") {
|
|
56164
56233
|
if (result.reason === "no-output-timeout" || result.noOutputTimedOut) {
|
|
56165
56234
|
const timeoutReason = `CLI produced no output for ${Math.round(noOutputTimeoutMs / 1e3)}s and was terminated.`;
|
|
56166
|
-
log$
|
|
56235
|
+
log$15.warn(`cli watchdog timeout: provider=${params.provider} model=${modelId} session=${resolvedSessionId ?? params.sessionId} noOutputTimeoutMs=${noOutputTimeoutMs} pid=${managedRun.pid ?? "unknown"}`);
|
|
56167
56236
|
throw new FailoverError(timeoutReason, {
|
|
56168
56237
|
reason: "timeout",
|
|
56169
56238
|
provider: params.provider,
|
|
@@ -56217,7 +56286,7 @@ async function runCliAgent(params) {
|
|
|
56217
56286
|
} catch (err) {
|
|
56218
56287
|
if (err instanceof FailoverError) {
|
|
56219
56288
|
if (err.reason === "session_expired" && params.cliSessionId && params.sessionKey) {
|
|
56220
|
-
log$
|
|
56289
|
+
log$15.warn(`CLI session expired, clearing session ID and retrying: provider=${params.provider} session=${redactRunIdentifier(params.cliSessionId)}`);
|
|
56221
56290
|
const output = await executeCliWithSession(void 0);
|
|
56222
56291
|
const text = output.text?.trim();
|
|
56223
56292
|
return {
|
|
@@ -56797,7 +56866,7 @@ function createBlockReplyDeliveryHandler(params) {
|
|
|
56797
56866
|
* every turn the queue-drain path starts later (a `sessions.steer` mode "queue" follow-up and
|
|
56798
56867
|
* every channel follow-up ride the same drain).
|
|
56799
56868
|
*/
|
|
56800
|
-
const log$
|
|
56869
|
+
const log$14 = createSubsystemLogger("auto-reply/session-run-recording");
|
|
56801
56870
|
const NO_RECORDING = {
|
|
56802
56871
|
complete: async () => {},
|
|
56803
56872
|
fail: async () => {},
|
|
@@ -56828,7 +56897,7 @@ async function beginTurnSessionRun(params) {
|
|
|
56828
56897
|
sessionKey
|
|
56829
56898
|
});
|
|
56830
56899
|
} catch (error) {
|
|
56831
|
-
log$
|
|
56900
|
+
log$14.warn("session-run recording unavailable for this turn", {
|
|
56832
56901
|
runId: params.runId,
|
|
56833
56902
|
error: error instanceof Error ? error.message : String(error)
|
|
56834
56903
|
});
|
|
@@ -57661,7 +57730,7 @@ function repairToolUseResultPairing(messages) {
|
|
|
57661
57730
|
|
|
57662
57731
|
//#endregion
|
|
57663
57732
|
//#region src/agents/compaction.ts
|
|
57664
|
-
const log$
|
|
57733
|
+
const log$13 = createSubsystemLogger("compaction");
|
|
57665
57734
|
const BASE_CHUNK_RATIO = .4;
|
|
57666
57735
|
const MIN_CHUNK_RATIO = .15;
|
|
57667
57736
|
const SAFETY_MARGIN = 1.2;
|
|
@@ -57787,7 +57856,7 @@ async function summarizeWithFallback(params) {
|
|
|
57787
57856
|
try {
|
|
57788
57857
|
return await summarizeChunks(params);
|
|
57789
57858
|
} catch (fullError) {
|
|
57790
|
-
log$
|
|
57859
|
+
log$13.warn(`Full summarization failed, trying partial: ${fullError instanceof Error ? fullError.message : String(fullError)}`);
|
|
57791
57860
|
}
|
|
57792
57861
|
const smallMessages = [];
|
|
57793
57862
|
const oversizedNotes = [];
|
|
@@ -57802,7 +57871,7 @@ async function summarizeWithFallback(params) {
|
|
|
57802
57871
|
messages: smallMessages
|
|
57803
57872
|
}) + (oversizedNotes.length > 0 ? `\n\n${oversizedNotes.join("\n")}` : "");
|
|
57804
57873
|
} catch (partialError) {
|
|
57805
|
-
log$
|
|
57874
|
+
log$13.warn(`Partial summarization also failed: ${partialError instanceof Error ? partialError.message : String(partialError)}`);
|
|
57806
57875
|
}
|
|
57807
57876
|
return `Context contained ${messages.length} messages (${oversizedNotes.length} oversized). Summary unavailable due to size limits.`;
|
|
57808
57877
|
}
|
|
@@ -60008,7 +60077,7 @@ async function applyResetModelOverride(params) {
|
|
|
60008
60077
|
//#endregion
|
|
60009
60078
|
//#region src/infra/session-maintenance-warning.ts
|
|
60010
60079
|
const warnedContexts = /* @__PURE__ */ new Map();
|
|
60011
|
-
const log$
|
|
60080
|
+
const log$12 = createSubsystemLogger("session-maintenance-warning");
|
|
60012
60081
|
function shouldSendWarning() {
|
|
60013
60082
|
return !process.env.VITEST && true;
|
|
60014
60083
|
}
|
|
@@ -60079,7 +60148,7 @@ async function deliverSessionMaintenanceWarning(params) {
|
|
|
60079
60148
|
session: outboundSession
|
|
60080
60149
|
});
|
|
60081
60150
|
} catch (err) {
|
|
60082
|
-
log$
|
|
60151
|
+
log$12.warn(`Failed to deliver session maintenance warning: ${String(err)}`);
|
|
60083
60152
|
enqueueSystemEvent(text, { sessionKey: params.sessionKey });
|
|
60084
60153
|
}
|
|
60085
60154
|
}
|
|
@@ -60249,7 +60318,7 @@ function buildSessionEndHookPayload(params) {
|
|
|
60249
60318
|
|
|
60250
60319
|
//#endregion
|
|
60251
60320
|
//#region src/auto-reply/reply/session.ts
|
|
60252
|
-
const log$
|
|
60321
|
+
const log$11 = createSubsystemLogger("session-init");
|
|
60253
60322
|
async function initSessionState(params) {
|
|
60254
60323
|
const { ctx, cfg, commandAuthorized } = params;
|
|
60255
60324
|
const targetSessionKey = ctx.CommandSource === "native" ? ctx.CommandTargetSessionKey?.trim() : void 0;
|
|
@@ -60456,10 +60525,10 @@ async function initSessionState(params) {
|
|
|
60456
60525
|
if (parentSessionKey && parentSessionKey !== sessionKey && sessionStore[parentSessionKey] && !alreadyForked) {
|
|
60457
60526
|
const parentTokens = sessionStore[parentSessionKey].totalTokens ?? 0;
|
|
60458
60527
|
if (parentForkMaxTokens > 0 && parentTokens > parentForkMaxTokens) {
|
|
60459
|
-
log$
|
|
60528
|
+
log$11.warn(`skipping parent fork (parent too large): parentKey=${parentSessionKey} → sessionKey=${sessionKey} parentTokens=${parentTokens} maxTokens=${parentForkMaxTokens}`);
|
|
60460
60529
|
sessionEntry.forkedFromParent = true;
|
|
60461
60530
|
} else {
|
|
60462
|
-
log$
|
|
60531
|
+
log$11.warn(`forking from parent session: parentKey=${parentSessionKey} → sessionKey=${sessionKey} parentTokens=${parentTokens}`);
|
|
60463
60532
|
const forked = await forkSessionFromParent({
|
|
60464
60533
|
parentEntry: sessionStore[parentSessionKey],
|
|
60465
60534
|
agentId,
|
|
@@ -60470,7 +60539,7 @@ async function initSessionState(params) {
|
|
|
60470
60539
|
sessionEntry.sessionId = forked.sessionId;
|
|
60471
60540
|
sessionEntry.sessionFile = forked.sessionFile;
|
|
60472
60541
|
sessionEntry.forkedFromParent = true;
|
|
60473
|
-
log$
|
|
60542
|
+
log$11.warn(`forked session created: file=${forked.sessionFile}`);
|
|
60474
60543
|
}
|
|
60475
60544
|
}
|
|
60476
60545
|
}
|
|
@@ -69084,7 +69153,7 @@ function toDiscordModelPickerMessagePayload(view) {
|
|
|
69084
69153
|
|
|
69085
69154
|
//#endregion
|
|
69086
69155
|
//#region src/discord/monitor/native-command.ts
|
|
69087
|
-
const log$
|
|
69156
|
+
const log$10 = createSubsystemLogger("discord/native-command");
|
|
69088
69157
|
function buildDiscordCommandOptions(params) {
|
|
69089
69158
|
const { command, cfg } = params;
|
|
69090
69159
|
const args = command.args;
|
|
@@ -70141,7 +70210,7 @@ async function dispatchDiscordCommandInteraction(params) {
|
|
|
70141
70210
|
},
|
|
70142
70211
|
onError: (err, info) => {
|
|
70143
70212
|
const message = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
70144
|
-
log$
|
|
70213
|
+
log$10.error(`discord slash ${info.kind} reply failed: ${message}`);
|
|
70145
70214
|
}
|
|
70146
70215
|
},
|
|
70147
70216
|
replyOptions: {
|
|
@@ -73622,7 +73691,7 @@ function resolveSession(opts) {
|
|
|
73622
73691
|
|
|
73623
73692
|
//#endregion
|
|
73624
73693
|
//#region src/commands/agent.ts
|
|
73625
|
-
const log$
|
|
73694
|
+
const log$9 = createSubsystemLogger("commands/agent");
|
|
73626
73695
|
const OVERRIDE_FIELDS_CLEARED_BY_DELETE = [
|
|
73627
73696
|
"providerOverride",
|
|
73628
73697
|
"modelOverride",
|
|
@@ -73680,7 +73749,7 @@ function runAgentAttempt(params) {
|
|
|
73680
73749
|
});
|
|
73681
73750
|
return runCliWithSession(cliSessionId).catch(async (err) => {
|
|
73682
73751
|
if (err instanceof FailoverError && err.reason === "session_expired" && cliSessionId && params.sessionKey && params.sessionStore && params.storePath) {
|
|
73683
|
-
log$
|
|
73752
|
+
log$9.warn(`CLI session expired, clearing from session store: provider=${params.providerOverride} sessionKey=${params.sessionKey}`);
|
|
73684
73753
|
const entry = params.sessionStore[params.sessionKey];
|
|
73685
73754
|
if (entry) {
|
|
73686
73755
|
const updatedEntry = { ...entry };
|
|
@@ -85000,7 +85069,7 @@ async function registerSlackMonitorSlashCommands(params) {
|
|
|
85000
85069
|
const [{ resolveAgentRoute }, { finalizeInboundContext }, { dispatchReplyWithDispatcher }] = await Promise.all([
|
|
85001
85070
|
import("./resolve-route-DeeqG2Kk.js"),
|
|
85002
85071
|
import("./inbound-context-BmQfexVy.js"),
|
|
85003
|
-
import("./provider-dispatcher-
|
|
85072
|
+
import("./provider-dispatcher-B4JYNdjt.js")
|
|
85004
85073
|
]);
|
|
85005
85074
|
const [{ resolveConversationLabel }, { createReplyPrefixOptions }, { recordInboundSessionMetaSafe }] = await Promise.all([
|
|
85006
85075
|
import("./conversation-label-TAXJpeGu.js"),
|
|
@@ -90916,7 +90985,7 @@ const TELEGRAM_WEBHOOK_MAX_BODY_BYTES = 1024 * 1024;
|
|
|
90916
90985
|
const TELEGRAM_WEBHOOK_BODY_TIMEOUT_MS = 3e4;
|
|
90917
90986
|
const TELEGRAM_WEBHOOK_CALLBACK_TIMEOUT_MS = 1e4;
|
|
90918
90987
|
const TELEGRAM_WEBHOOK_DEFAULT_MAX_CONNECTIONS = 40;
|
|
90919
|
-
const log$
|
|
90988
|
+
const log$8 = createSubsystemLogger("telegram/webhook");
|
|
90920
90989
|
let webhookOwnerSequence = 0;
|
|
90921
90990
|
let ephemeralWebhookListenerSequence = 0;
|
|
90922
90991
|
let activeWebhookDiagnosticUsers = 0;
|
|
@@ -91246,7 +91315,7 @@ async function startTelegramWebhook(opts) {
|
|
|
91246
91315
|
recordRequest({ outcome: "received" });
|
|
91247
91316
|
const secretHeader = resolveSingleHeaderValue(req.headers["x-telegram-bot-api-secret-token"]);
|
|
91248
91317
|
if (!hasValidTelegramWebhookSecret(secretHeader, secret)) {
|
|
91249
|
-
log$
|
|
91318
|
+
log$8.warn("telegram webhook secret rejected", {
|
|
91250
91319
|
sourceIp: resolveWebhookSourceIp(req),
|
|
91251
91320
|
reason: typeof secretHeader === "string" ? "secret-mismatch" : "missing-header",
|
|
91252
91321
|
path
|
|
@@ -91341,7 +91410,7 @@ async function startTelegramWebhook(opts) {
|
|
|
91341
91410
|
const unauthorized = async () => {
|
|
91342
91411
|
if (replied) return;
|
|
91343
91412
|
replied = true;
|
|
91344
|
-
log$
|
|
91413
|
+
log$8.warn("telegram webhook secret rejected", {
|
|
91345
91414
|
sourceIp: resolveWebhookSourceIp(req),
|
|
91346
91415
|
reason: typeof secretHeader === "string" ? "secret-mismatch" : "missing-header",
|
|
91347
91416
|
path
|
|
@@ -92552,7 +92621,7 @@ function resolveMemoryBackendConfig(params) {
|
|
|
92552
92621
|
|
|
92553
92622
|
//#endregion
|
|
92554
92623
|
//#region src/memory/search-manager.ts
|
|
92555
|
-
const log$
|
|
92624
|
+
const log$7 = createSubsystemLogger("memory");
|
|
92556
92625
|
const QMD_MANAGER_CACHE = /* @__PURE__ */ new Map();
|
|
92557
92626
|
async function getMemorySearchManager(params) {
|
|
92558
92627
|
const resolved = resolveMemoryBackendConfig(params);
|
|
@@ -92589,7 +92658,7 @@ async function getMemorySearchManager(params) {
|
|
|
92589
92658
|
}
|
|
92590
92659
|
} catch (err) {
|
|
92591
92660
|
const message = err instanceof Error ? err.message : String(err);
|
|
92592
|
-
log$
|
|
92661
|
+
log$7.warn(`qmd memory unavailable; falling back to builtin: ${message}`);
|
|
92593
92662
|
}
|
|
92594
92663
|
}
|
|
92595
92664
|
try {
|
|
@@ -92616,7 +92685,7 @@ var FallbackMemoryManager = class {
|
|
|
92616
92685
|
} catch (err) {
|
|
92617
92686
|
this.primaryFailed = true;
|
|
92618
92687
|
this.lastError = err instanceof Error ? err.message : String(err);
|
|
92619
|
-
log$
|
|
92688
|
+
log$7.warn(`qmd memory failed; switching to builtin index: ${this.lastError}`);
|
|
92620
92689
|
await this.deps.primary.close?.().catch(() => {});
|
|
92621
92690
|
this.evictCacheEntry();
|
|
92622
92691
|
}
|
|
@@ -92696,12 +92765,12 @@ var FallbackMemoryManager = class {
|
|
|
92696
92765
|
try {
|
|
92697
92766
|
fallback = await this.deps.fallbackFactory();
|
|
92698
92767
|
if (!fallback) {
|
|
92699
|
-
log$
|
|
92768
|
+
log$7.warn("memory fallback requested but builtin index is unavailable");
|
|
92700
92769
|
return null;
|
|
92701
92770
|
}
|
|
92702
92771
|
} catch (err) {
|
|
92703
92772
|
const message = err instanceof Error ? err.message : String(err);
|
|
92704
|
-
log$
|
|
92773
|
+
log$7.warn(`memory fallback unavailable: ${message}`);
|
|
92705
92774
|
return null;
|
|
92706
92775
|
}
|
|
92707
92776
|
this.fallback = fallback;
|
|
@@ -94405,7 +94474,7 @@ function createPluginLoaderLogger(logger) {
|
|
|
94405
94474
|
|
|
94406
94475
|
//#endregion
|
|
94407
94476
|
//#region src/plugins/tools.ts
|
|
94408
|
-
const log$
|
|
94477
|
+
const log$6 = createSubsystemLogger("plugins");
|
|
94409
94478
|
const pluginToolMeta = /* @__PURE__ */ new WeakMap();
|
|
94410
94479
|
function getPluginToolMeta(tool) {
|
|
94411
94480
|
return pluginToolMeta.get(tool);
|
|
@@ -94427,7 +94496,7 @@ function resolvePluginTools(params) {
|
|
|
94427
94496
|
const registry = loadOpenClawPlugins({
|
|
94428
94497
|
config: effectiveConfig,
|
|
94429
94498
|
workspaceDir: params.context.workspaceDir,
|
|
94430
|
-
logger: createPluginLoaderLogger(log$
|
|
94499
|
+
logger: createPluginLoaderLogger(log$6),
|
|
94431
94500
|
activate: false
|
|
94432
94501
|
});
|
|
94433
94502
|
const tools = [];
|
|
@@ -94442,7 +94511,7 @@ function resolvePluginTools(params) {
|
|
|
94442
94511
|
if (existingNormalized.has(pluginIdKey)) {
|
|
94443
94512
|
const message = `plugin id conflicts with core tool name (${entry.pluginId})`;
|
|
94444
94513
|
if (!params.suppressNameConflicts) {
|
|
94445
|
-
log$
|
|
94514
|
+
log$6.error(message);
|
|
94446
94515
|
registry.diagnostics.push({
|
|
94447
94516
|
level: "error",
|
|
94448
94517
|
code: "PLUGIN_REGISTER_ERROR",
|
|
@@ -94459,7 +94528,7 @@ function resolvePluginTools(params) {
|
|
|
94459
94528
|
try {
|
|
94460
94529
|
resolved = entry.factory(params.context);
|
|
94461
94530
|
} catch (err) {
|
|
94462
|
-
log$
|
|
94531
|
+
log$6.error(`plugin tool failed (${entry.pluginId}): ${String(err)}`);
|
|
94463
94532
|
continue;
|
|
94464
94533
|
}
|
|
94465
94534
|
if (!resolved) continue;
|
|
@@ -94476,7 +94545,7 @@ function resolvePluginTools(params) {
|
|
|
94476
94545
|
if (nameSet.has(tool.name) || existing.has(tool.name)) {
|
|
94477
94546
|
const message = `plugin tool name conflict (${entry.pluginId}): ${tool.name}`;
|
|
94478
94547
|
if (!params.suppressNameConflicts) {
|
|
94479
|
-
log$
|
|
94548
|
+
log$6.error(message);
|
|
94480
94549
|
registry.diagnostics.push({
|
|
94481
94550
|
level: "error",
|
|
94482
94551
|
code: "PLUGIN_REGISTER_ERROR",
|
|
@@ -94509,7 +94578,7 @@ function resolvePluginWebSearchProviders(params) {
|
|
|
94509
94578
|
return [...loadOpenClawPlugins({
|
|
94510
94579
|
config: effectiveConfig,
|
|
94511
94580
|
workspaceDir: params.workspaceDir,
|
|
94512
|
-
logger: createPluginLoaderLogger(log$
|
|
94581
|
+
logger: createPluginLoaderLogger(log$6),
|
|
94513
94582
|
activate: false
|
|
94514
94583
|
}).webSearchProviders].toSorted((a, b) => {
|
|
94515
94584
|
return (a.autoDetectOrder ?? Infinity) - (b.autoDetectOrder ?? Infinity);
|
|
@@ -95121,7 +95190,7 @@ function wrapToolWithAbortSignal(tool, abortSignal) {
|
|
|
95121
95190
|
|
|
95122
95191
|
//#endregion
|
|
95123
95192
|
//#region src/agents/pi-tools.before-tool-call.ts
|
|
95124
|
-
const log$
|
|
95193
|
+
const log$5 = createSubsystemLogger("agents/tools");
|
|
95125
95194
|
const BEFORE_TOOL_CALL_WRAPPED = Symbol("beforeToolCallWrapped");
|
|
95126
95195
|
const adjustedParamsByToolCallId = /* @__PURE__ */ new Map();
|
|
95127
95196
|
const MAX_TRACKED_ADJUSTED_PARAMS = 1024;
|
|
@@ -95159,7 +95228,7 @@ async function recordLoopOutcome(args) {
|
|
|
95159
95228
|
config: args.ctx.loopDetection
|
|
95160
95229
|
});
|
|
95161
95230
|
} catch (err) {
|
|
95162
|
-
log$
|
|
95231
|
+
log$5.warn(`tool loop outcome tracking failed: tool=${args.toolName} error=${String(err)}`);
|
|
95163
95232
|
}
|
|
95164
95233
|
}
|
|
95165
95234
|
var UserCancelledError = class extends Error {
|
|
@@ -95186,7 +95255,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
95186
95255
|
const loopResult = detectToolCallLoop(sessionState, toolName, params, args.ctx.loopDetection);
|
|
95187
95256
|
if (loopResult.stuck) {
|
|
95188
95257
|
if (loopResult.level === "critical") {
|
|
95189
|
-
log$
|
|
95258
|
+
log$5.error(`Blocking ${toolName} due to critical loop: ${loopResult.message}`);
|
|
95190
95259
|
logToolLoopAction({
|
|
95191
95260
|
sessionKey: args.ctx.sessionKey,
|
|
95192
95261
|
sessionId: args.ctx?.agentId,
|
|
@@ -95204,7 +95273,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
95204
95273
|
reason: loopResult.message
|
|
95205
95274
|
};
|
|
95206
95275
|
} else if (shouldEmitLoopWarning(sessionState, loopResult.warningKey ?? `${loopResult.detector}:${toolName}`, loopResult.count)) {
|
|
95207
|
-
log$
|
|
95276
|
+
log$5.warn(`Loop warning for ${toolName}: ${loopResult.message}`);
|
|
95208
95277
|
logToolLoopAction({
|
|
95209
95278
|
sessionKey: args.ctx.sessionKey,
|
|
95210
95279
|
sessionId: args.ctx?.agentId,
|
|
@@ -95263,7 +95332,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
95263
95332
|
}
|
|
95264
95333
|
} catch (err) {
|
|
95265
95334
|
const toolCallId = args.toolCallId ? ` toolCallId=${args.toolCallId}` : "";
|
|
95266
|
-
log$
|
|
95335
|
+
log$5.warn(`before_tool_call hook failed: tool=${toolName}${toolCallId} error=${String(err)}`);
|
|
95267
95336
|
}
|
|
95268
95337
|
return {
|
|
95269
95338
|
blocked: false,
|
|
@@ -97079,7 +97148,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
97079
97148
|
const textLength = getToolResultTextLength(msg);
|
|
97080
97149
|
if (textLength > maxChars) {
|
|
97081
97150
|
oversizedIndices.push(i);
|
|
97082
|
-
log$
|
|
97151
|
+
log$19.info(`[tool-result-truncation] Found oversized tool result: entry=${entry.id} chars=${textLength} maxChars=${maxChars} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
97083
97152
|
}
|
|
97084
97153
|
}
|
|
97085
97154
|
if (oversizedIndices.length === 0) return {
|
|
@@ -97101,7 +97170,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
97101
97170
|
message = truncateToolResultMessage(message, maxChars);
|
|
97102
97171
|
truncatedCount++;
|
|
97103
97172
|
const newLength = getToolResultTextLength(message);
|
|
97104
|
-
log$
|
|
97173
|
+
log$19.info(`[tool-result-truncation] Truncated tool result: originalEntry=${entry.id} newChars=${newLength} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
97105
97174
|
}
|
|
97106
97175
|
sessionManager.appendMessage(message);
|
|
97107
97176
|
} else if (entry.type === "compaction") sessionManager.appendCompaction(entry.summary, entry.firstKeptEntryId, entry.tokensBefore, entry.details, entry.fromHook);
|
|
@@ -97115,14 +97184,14 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
97115
97184
|
if (entry.name) sessionManager.appendSessionInfo(entry.name);
|
|
97116
97185
|
}
|
|
97117
97186
|
}
|
|
97118
|
-
log$
|
|
97187
|
+
log$19.info(`[tool-result-truncation] Truncated ${truncatedCount} tool result(s) in session (contextWindow=${contextWindowTokens} maxChars=${maxChars}) sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
97119
97188
|
return {
|
|
97120
97189
|
truncated: true,
|
|
97121
97190
|
truncatedCount
|
|
97122
97191
|
};
|
|
97123
97192
|
} catch (err) {
|
|
97124
97193
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
97125
|
-
log$
|
|
97194
|
+
log$19.warn(`[tool-result-truncation] Failed to truncate: ${errMsg}`);
|
|
97126
97195
|
return {
|
|
97127
97196
|
truncated: false,
|
|
97128
97197
|
truncatedCount: 0,
|
|
@@ -97496,7 +97565,7 @@ const getCompactionSafeguardRuntime = registry$1.get;
|
|
|
97496
97565
|
|
|
97497
97566
|
//#endregion
|
|
97498
97567
|
//#region src/agents/pi-extensions/compaction-safeguard.ts
|
|
97499
|
-
const log$
|
|
97568
|
+
const log$4 = createSubsystemLogger("compaction-safeguard");
|
|
97500
97569
|
const missedModelWarningSessions = /* @__PURE__ */ new WeakSet();
|
|
97501
97570
|
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.";
|
|
97502
97571
|
const MAX_TOOL_FAILURES = 8;
|
|
@@ -97605,7 +97674,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97605
97674
|
api.on("session_before_compact", async (event, ctx) => {
|
|
97606
97675
|
const { preparation, customInstructions, signal } = event;
|
|
97607
97676
|
if (!preparation.messagesToSummarize.some(isRealConversationMessage)) {
|
|
97608
|
-
log$
|
|
97677
|
+
log$4.warn("Compaction safeguard: cancelling compaction with no real conversation messages to summarize.");
|
|
97609
97678
|
return { cancel: true };
|
|
97610
97679
|
}
|
|
97611
97680
|
const { readFiles, modifiedFiles } = computeFileLists(preparation.fileOps);
|
|
@@ -97613,7 +97682,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97613
97682
|
const toolFailureSection = formatToolFailuresSection(collectToolFailures([...preparation.messagesToSummarize, ...preparation.turnPrefixMessages]));
|
|
97614
97683
|
const runtime = getCompactionSafeguardRuntime(ctx.sessionManager);
|
|
97615
97684
|
if (runtime?.enabled === false) {
|
|
97616
|
-
log$
|
|
97685
|
+
log$4.info("Compaction safeguard: compaction disabled by config; cancelling.");
|
|
97617
97686
|
return { cancel: true };
|
|
97618
97687
|
}
|
|
97619
97688
|
const summarizationInstructions = {
|
|
@@ -97654,7 +97723,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97654
97723
|
});
|
|
97655
97724
|
if (pruned.droppedChunks > 0) {
|
|
97656
97725
|
const newContentRatio = newContentTokens / contextWindowTokens * 100;
|
|
97657
|
-
log$
|
|
97726
|
+
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.`);
|
|
97658
97727
|
messagesToSummarize = pruned.messages;
|
|
97659
97728
|
if (pruned.droppedMessagesList.length > 0) try {
|
|
97660
97729
|
const droppedChunkRatio = computeAdaptiveChunkRatio(pruned.droppedMessagesList, contextWindowTokens);
|
|
@@ -97672,7 +97741,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97672
97741
|
previousSummary: preparation.previousSummary
|
|
97673
97742
|
});
|
|
97674
97743
|
} catch (droppedError) {
|
|
97675
|
-
log$
|
|
97744
|
+
log$4.warn(`Compaction safeguard: failed to summarize dropped messages, continuing without: ${droppedError instanceof Error ? droppedError.message : String(droppedError)}`);
|
|
97676
97745
|
}
|
|
97677
97746
|
}
|
|
97678
97747
|
}
|
|
@@ -97720,7 +97789,7 @@ function compactionSafeguardExtension(api) {
|
|
|
97720
97789
|
}
|
|
97721
97790
|
} };
|
|
97722
97791
|
} catch (error) {
|
|
97723
|
-
log$
|
|
97792
|
+
log$4.warn(`Compaction summarization failed; cancelling compaction to preserve history: ${error instanceof Error ? error.message : String(error)}`);
|
|
97724
97793
|
return { cancel: true };
|
|
97725
97794
|
}
|
|
97726
97795
|
});
|
|
@@ -98451,14 +98520,14 @@ function logToolSchemasForGoogle(params) {
|
|
|
98451
98520
|
if (params.provider !== "google-gemini-cli") return;
|
|
98452
98521
|
const toolNames = params.tools.map((tool, index) => `${index}:${tool.name}`);
|
|
98453
98522
|
const tools = sanitizeToolsForGoogle(params);
|
|
98454
|
-
log$
|
|
98523
|
+
log$19.info("google tool schema snapshot", {
|
|
98455
98524
|
provider: params.provider,
|
|
98456
98525
|
toolCount: tools.length,
|
|
98457
98526
|
tools: toolNames
|
|
98458
98527
|
});
|
|
98459
98528
|
for (const [index, tool] of tools.entries()) {
|
|
98460
98529
|
const violations = findUnsupportedSchemaKeywords(tool.parameters, `${tool.name}.parameters`);
|
|
98461
|
-
if (violations.length > 0) log$
|
|
98530
|
+
if (violations.length > 0) log$19.warn("google tool schema has unsupported keywords", {
|
|
98462
98531
|
index,
|
|
98463
98532
|
tool: tool.name,
|
|
98464
98533
|
violations: violations.slice(0, 12),
|
|
@@ -98470,7 +98539,7 @@ const compactionFailureEmitter = new EventEmitter();
|
|
|
98470
98539
|
registerUnhandledRejectionHandler((reason) => {
|
|
98471
98540
|
const message = describeUnknownError(reason);
|
|
98472
98541
|
if (!isCompactionFailureError(message)) return false;
|
|
98473
|
-
log$
|
|
98542
|
+
log$19.error(`Auto-compaction failed (unhandled): ${message}`);
|
|
98474
98543
|
compactionFailureEmitter.emit("failure", message);
|
|
98475
98544
|
return true;
|
|
98476
98545
|
});
|
|
@@ -98522,7 +98591,7 @@ function applyGoogleTurnOrderingFix(params) {
|
|
|
98522
98591
|
const sanitized = sanitizeGoogleTurnOrdering(params.messages);
|
|
98523
98592
|
const didPrepend = sanitized !== params.messages;
|
|
98524
98593
|
if (didPrepend && !hasGoogleTurnOrderingMarker(params.sessionManager)) {
|
|
98525
|
-
(params.warn ?? ((message) => log$
|
|
98594
|
+
(params.warn ?? ((message) => log$19.warn(message)))(`google turn ordering fixup: prepended user bootstrap (sessionId=${params.sessionId})`);
|
|
98526
98595
|
markGoogleTurnOrderingMarker(params.sessionManager);
|
|
98527
98596
|
}
|
|
98528
98597
|
return {
|
|
@@ -98939,6 +99008,57 @@ async function flushPendingToolResultsAfterIdle(opts) {
|
|
|
98939
99008
|
opts.sessionManager?.flushPendingToolResults?.();
|
|
98940
99009
|
}
|
|
98941
99010
|
|
|
99011
|
+
//#endregion
|
|
99012
|
+
//#region src/agents/pi-embedded-runner/workspace-cwd.ts
|
|
99013
|
+
const log$3 = createSubsystemLogger("agents/workspace-cwd");
|
|
99014
|
+
const holders = [];
|
|
99015
|
+
let baselineCwd;
|
|
99016
|
+
function readCwd() {
|
|
99017
|
+
try {
|
|
99018
|
+
return process.cwd();
|
|
99019
|
+
} catch (err) {
|
|
99020
|
+
log$3.warn("process.cwd() failed; the working directory was removed under the process", { error: String(err) });
|
|
99021
|
+
return;
|
|
99022
|
+
}
|
|
99023
|
+
}
|
|
99024
|
+
function tryChdir(target) {
|
|
99025
|
+
if (readCwd() === target) return true;
|
|
99026
|
+
try {
|
|
99027
|
+
process.chdir(target);
|
|
99028
|
+
return true;
|
|
99029
|
+
} catch (err) {
|
|
99030
|
+
log$3.error("cwd restore target is gone", {
|
|
99031
|
+
target,
|
|
99032
|
+
error: String(err)
|
|
99033
|
+
});
|
|
99034
|
+
return false;
|
|
99035
|
+
}
|
|
99036
|
+
}
|
|
99037
|
+
/**
|
|
99038
|
+
* The cwd is process-global while embedded runs overlap (`agents.defaults.maxConcurrent`
|
|
99039
|
+
* defaults to 4). Each holder gets the cwd on acquire; on release the cwd goes to the most
|
|
99040
|
+
* recent surviving holder's workspace, and to the baseline the first holder found once none
|
|
99041
|
+
* remain. The returned release never throws: a throw from a caller's finally would skip the
|
|
99042
|
+
* rest of it (e.g. clearActiveEmbeddedRun) and leak the run registry entry.
|
|
99043
|
+
*/
|
|
99044
|
+
function acquireWorkspaceCwd(workspaceDir) {
|
|
99045
|
+
if (holders.length === 0) baselineCwd = readCwd() ?? os.tmpdir();
|
|
99046
|
+
if (readCwd() !== workspaceDir) process.chdir(workspaceDir);
|
|
99047
|
+
const holder = { workspaceDir };
|
|
99048
|
+
holders.push(holder);
|
|
99049
|
+
let released = false;
|
|
99050
|
+
return () => {
|
|
99051
|
+
if (released) return;
|
|
99052
|
+
released = true;
|
|
99053
|
+
const index = holders.indexOf(holder);
|
|
99054
|
+
if (index !== -1) holders.splice(index, 1);
|
|
99055
|
+
for (let i = holders.length - 1; i >= 0; i -= 1) if (tryChdir(holders[i].workspaceDir)) return;
|
|
99056
|
+
const target = baselineCwd ?? os.tmpdir();
|
|
99057
|
+
if (holders.length === 0) baselineCwd = void 0;
|
|
99058
|
+
if (!tryChdir(target) && !tryChdir(os.tmpdir())) log$3.error("tmpdir chdir failed; leaving the process cwd unchanged");
|
|
99059
|
+
};
|
|
99060
|
+
}
|
|
99061
|
+
|
|
98942
99062
|
//#endregion
|
|
98943
99063
|
//#region src/agents/pi-embedded-runner/compact.ts
|
|
98944
99064
|
function createCompactionDiagId$1() {
|
|
@@ -99349,11 +99469,10 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99349
99469
|
compacted: false,
|
|
99350
99470
|
reason: "compaction deferred by context.prune handler"
|
|
99351
99471
|
};
|
|
99352
|
-
const prevCwd = process.cwd();
|
|
99353
99472
|
const provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
99354
99473
|
const modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
99355
99474
|
const fail = (reason) => {
|
|
99356
|
-
log$
|
|
99475
|
+
log$19.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}`);
|
|
99357
99476
|
return {
|
|
99358
99477
|
ok: false,
|
|
99359
99478
|
compacted: false,
|
|
@@ -99397,7 +99516,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99397
99516
|
cwd: effectiveWorkspace
|
|
99398
99517
|
});
|
|
99399
99518
|
let restoreSkillEnv;
|
|
99400
|
-
|
|
99519
|
+
const releaseWorkspaceCwd = acquireWorkspaceCwd(effectiveWorkspace);
|
|
99401
99520
|
try {
|
|
99402
99521
|
const shouldLoadSkillEntries = !params.skillsSnapshot || !params.skillsSnapshot.resolvedSkills;
|
|
99403
99522
|
const skillEntries = shouldLoadSkillEntries ? loadWorkspaceSkillEntries(effectiveWorkspace) : [];
|
|
@@ -99433,7 +99552,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99433
99552
|
resolvedSystemPrompt,
|
|
99434
99553
|
warn: makeBootstrapWarn({
|
|
99435
99554
|
sessionLabel,
|
|
99436
|
-
warn: (message) => log$
|
|
99555
|
+
warn: (message) => log$19.warn(message)
|
|
99437
99556
|
})
|
|
99438
99557
|
});
|
|
99439
99558
|
const runAbortController = new AbortController();
|
|
@@ -99575,7 +99694,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99575
99694
|
});
|
|
99576
99695
|
try {
|
|
99577
99696
|
if (isPreservationArmed() || !isJsonlSessionBackend()) {
|
|
99578
|
-
log$
|
|
99697
|
+
log$19.warn(`[compaction-diag] refused transcript repair/open runId=${runId} sessionKey=${params.sessionKey ?? params.sessionId} diagId=${diagId} trigger=${trigger} preservationArmed=${isPreservationArmed()} jsonlBackend=${isJsonlSessionBackend()}`);
|
|
99579
99698
|
return {
|
|
99580
99699
|
ok: true,
|
|
99581
99700
|
compacted: false,
|
|
@@ -99584,7 +99703,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99584
99703
|
}
|
|
99585
99704
|
await repairSessionFileIfNeeded({
|
|
99586
99705
|
sessionFile: params.sessionFile,
|
|
99587
|
-
warn: (message) => log$
|
|
99706
|
+
warn: (message) => log$19.warn(message)
|
|
99588
99707
|
});
|
|
99589
99708
|
await prewarmSessionFile(params.sessionFile);
|
|
99590
99709
|
const transcriptPolicy = resolveTranscriptPolicy({
|
|
@@ -99680,7 +99799,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99680
99799
|
const inputStorageCursor = await loadCompactionStorageCursor({
|
|
99681
99800
|
sessionId: params.sessionId,
|
|
99682
99801
|
sessionKey: params.sessionKey,
|
|
99683
|
-
warn: (message) => log$
|
|
99802
|
+
warn: (message) => log$19.warn(message)
|
|
99684
99803
|
});
|
|
99685
99804
|
const truncated = limitHistoryTurns(validated, getDmHistoryLimitFromSessionKey(params.sessionKey, params.config));
|
|
99686
99805
|
const limited = transcriptPolicy.repairToolUseResultPairing ? sanitizeToolUseResultPairing(truncated) : truncated;
|
|
@@ -99692,7 +99811,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99692
99811
|
tokenWindow,
|
|
99693
99812
|
usage,
|
|
99694
99813
|
storageCursor: inputStorageCursor,
|
|
99695
|
-
warn: (message) => log$
|
|
99814
|
+
warn: (message) => log$19.warn(message)
|
|
99696
99815
|
});
|
|
99697
99816
|
const sanitizedHookMessages = await sanitizeHookCompactionMessages({
|
|
99698
99817
|
messages: cloneCompactionMessages(compactionPlan.messages),
|
|
@@ -99715,7 +99834,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99715
99834
|
messages: transcriptPolicy.validateAnthropicTurns ? validateAnthropicTurns(validatedPlannedGemini) : validatedPlannedGemini,
|
|
99716
99835
|
fallbackMessages: limited,
|
|
99717
99836
|
replacedMessages: compactionPlan.replacedMessages,
|
|
99718
|
-
warn: (message) => log$
|
|
99837
|
+
warn: (message) => log$19.warn(message)
|
|
99719
99838
|
});
|
|
99720
99839
|
const compactionInputMessages = compactionInput.messages;
|
|
99721
99840
|
if (compactionInputMessages.length === 0) return fail(compactionInput.abortReason ?? "compaction input is empty");
|
|
@@ -99726,13 +99845,13 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99726
99845
|
messages: preCompactionMessages,
|
|
99727
99846
|
sessionFile: params.sessionFile
|
|
99728
99847
|
}, hookCtx).catch((hookErr) => {
|
|
99729
|
-
log$
|
|
99848
|
+
log$19.warn(`before_compaction hook failed: ${String(hookErr)}`);
|
|
99730
99849
|
});
|
|
99731
|
-
const diagEnabled = log$
|
|
99850
|
+
const diagEnabled = log$19.isEnabled("debug");
|
|
99732
99851
|
const preMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
99733
99852
|
if (diagEnabled && preMetrics) {
|
|
99734
|
-
log$
|
|
99735
|
-
log$
|
|
99853
|
+
log$19.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"}`);
|
|
99854
|
+
log$19.debug(`[compaction-diag] contributors diagId=${diagId} top=${JSON.stringify(preMetrics.contributors)}`);
|
|
99736
99855
|
}
|
|
99737
99856
|
const compactStartedAt = Date.now();
|
|
99738
99857
|
setContextHooksLastCompactionPreparation(sessionManager, void 0);
|
|
@@ -99742,7 +99861,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99742
99861
|
result = await compactWithAbortOnTimeout({
|
|
99743
99862
|
compact: () => session.compact(params.customInstructions),
|
|
99744
99863
|
abort: () => session.abortCompaction(),
|
|
99745
|
-
onAbortSettleTimeout: (err) => log$
|
|
99864
|
+
onAbortSettleTimeout: (err) => log$19.warn(`compaction did not settle after abort: ${String(err)}`)
|
|
99746
99865
|
});
|
|
99747
99866
|
} finally {
|
|
99748
99867
|
setContextHooksPlannedCompaction(sessionManager, void 0);
|
|
@@ -99770,12 +99889,12 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99770
99889
|
compactedCount: compactionInputMessages.length - session.messages.length,
|
|
99771
99890
|
sessionFile: params.sessionFile
|
|
99772
99891
|
}, hookCtx).catch((hookErr) => {
|
|
99773
|
-
log$
|
|
99892
|
+
log$19.warn(`after_compaction hook failed: ${hookErr}`);
|
|
99774
99893
|
});
|
|
99775
99894
|
const outputStorageCursor = await loadCompactionStorageCursor({
|
|
99776
99895
|
sessionId: params.sessionId,
|
|
99777
99896
|
sessionKey: params.sessionKey,
|
|
99778
|
-
warn: (message) => log$
|
|
99897
|
+
warn: (message) => log$19.warn(message)
|
|
99779
99898
|
});
|
|
99780
99899
|
const compactionResult = {
|
|
99781
99900
|
summary: result.summary,
|
|
@@ -99805,10 +99924,10 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99805
99924
|
outputMessageCount: session.messages.length,
|
|
99806
99925
|
replacedMessages: compactionReplacementApplied,
|
|
99807
99926
|
result: compactionResult,
|
|
99808
|
-
warn: (message) => log$
|
|
99927
|
+
warn: (message) => log$19.warn(message)
|
|
99809
99928
|
});
|
|
99810
99929
|
const postMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
99811
|
-
if (diagEnabled && preMetrics && postMetrics) log$
|
|
99930
|
+
if (diagEnabled && preMetrics && postMetrics) log$19.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"}`);
|
|
99812
99931
|
return {
|
|
99813
99932
|
ok: true,
|
|
99814
99933
|
compacted: true,
|
|
@@ -99837,7 +99956,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
99837
99956
|
return fail(describeUnknownError(err));
|
|
99838
99957
|
} finally {
|
|
99839
99958
|
restoreSkillEnv?.();
|
|
99840
|
-
|
|
99959
|
+
releaseWorkspaceCwd();
|
|
99841
99960
|
}
|
|
99842
99961
|
}
|
|
99843
99962
|
/**
|
|
@@ -99961,15 +100080,15 @@ function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
|
99961
100080
|
if (transport === "sse" || transport === "websocket" || transport === "auto") streamParams.transport = transport;
|
|
99962
100081
|
else if (transport != null) {
|
|
99963
100082
|
const transportSummary = typeof transport === "string" ? transport : typeof transport;
|
|
99964
|
-
log$
|
|
100083
|
+
log$19.warn(`ignoring invalid transport param: ${transportSummary}`);
|
|
99965
100084
|
}
|
|
99966
100085
|
if (typeof extraParams.openaiWsWarmup === "boolean") streamParams.openaiWsWarmup = extraParams.openaiWsWarmup;
|
|
99967
100086
|
const cacheRetention = resolveCacheRetention(extraParams, provider);
|
|
99968
100087
|
if (cacheRetention) streamParams.cacheRetention = cacheRetention;
|
|
99969
100088
|
const providerRouting = provider === "openrouter" && extraParams.provider != null && typeof extraParams.provider === "object" ? extraParams.provider : void 0;
|
|
99970
100089
|
if (Object.keys(streamParams).length === 0 && !providerRouting) return;
|
|
99971
|
-
log$
|
|
99972
|
-
if (providerRouting) log$
|
|
100090
|
+
log$19.debug(`creating streamFn wrapper with params: ${JSON.stringify(streamParams)}`);
|
|
100091
|
+
if (providerRouting) log$19.debug(`OpenRouter provider routing: ${JSON.stringify(providerRouting)}`);
|
|
99973
100092
|
const underlying = baseStreamFn ?? streamSimple;
|
|
99974
100093
|
const wrappedStreamFn = (model, context, options) => {
|
|
99975
100094
|
return underlying(providerRouting ? {
|
|
@@ -100091,7 +100210,7 @@ function resolveAnthropicBetas(extraParams, provider, modelId) {
|
|
|
100091
100210
|
for (const beta of configured) if (typeof beta === "string" && beta.trim()) betas.add(beta.trim());
|
|
100092
100211
|
}
|
|
100093
100212
|
if (extraParams?.context1m === true) if (isAnthropic1MModel(modelId)) betas.add(ANTHROPIC_CONTEXT_1M_BETA);
|
|
100094
|
-
else log$
|
|
100213
|
+
else log$19.warn(`ignoring context1m for non-opus/sonnet model: ${provider}/${modelId}`);
|
|
100095
100214
|
return betas.size > 0 ? [...betas] : void 0;
|
|
100096
100215
|
}
|
|
100097
100216
|
function mergeAnthropicBetaHeader(headers, betas) {
|
|
@@ -100118,7 +100237,7 @@ function createAnthropicBetaHeadersWrapper(baseStreamFn, betas) {
|
|
|
100118
100237
|
const isOauth = isAnthropicOAuthApiKey(options?.apiKey);
|
|
100119
100238
|
const requestedContext1m = betas.includes(ANTHROPIC_CONTEXT_1M_BETA);
|
|
100120
100239
|
const effectiveBetas = isOauth && requestedContext1m ? betas.filter((beta) => beta !== ANTHROPIC_CONTEXT_1M_BETA) : betas;
|
|
100121
|
-
if (isOauth && requestedContext1m) log$
|
|
100240
|
+
if (isOauth && requestedContext1m) log$19.warn(`ignoring context1m for OAuth token auth on ${model.provider}/${model.id}; Anthropic rejects context-1m beta with OAuth auth`);
|
|
100122
100241
|
const piAiBetas = isOauth ? PI_AI_OAUTH_ANTHROPIC_BETAS : PI_AI_DEFAULT_ANTHROPIC_BETAS;
|
|
100123
100242
|
const allBetas = [...new Set([...piAiBetas, ...effectiveBetas])];
|
|
100124
100243
|
return underlying(model, context, {
|
|
@@ -100479,12 +100598,12 @@ function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverr
|
|
|
100479
100598
|
};
|
|
100480
100599
|
const wrappedStreamFn = createStreamFnWithExtraParams(agent.streamFn, merged, provider);
|
|
100481
100600
|
if (wrappedStreamFn) {
|
|
100482
|
-
log$
|
|
100601
|
+
log$19.debug(`applying extraParams to agent streamFn for ${provider}/${modelId}`);
|
|
100483
100602
|
agent.streamFn = wrappedStreamFn;
|
|
100484
100603
|
}
|
|
100485
100604
|
const anthropicBetas = resolveAnthropicBetas(merged, provider, modelId);
|
|
100486
100605
|
if (anthropicBetas?.length) {
|
|
100487
|
-
log$
|
|
100606
|
+
log$19.debug(`applying Anthropic beta header for ${provider}/${modelId}: ${anthropicBetas.join(",")}`);
|
|
100488
100607
|
agent.streamFn = createAnthropicBetaHeadersWrapper(agent.streamFn, anthropicBetas);
|
|
100489
100608
|
}
|
|
100490
100609
|
if (shouldApplySiliconFlowThinkingOffCompat({
|
|
@@ -100492,7 +100611,7 @@ function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverr
|
|
|
100492
100611
|
modelId,
|
|
100493
100612
|
thinkingLevel
|
|
100494
100613
|
})) {
|
|
100495
|
-
log$
|
|
100614
|
+
log$19.debug(`normalizing thinking=off to thinking=null for SiliconFlow compatibility (${provider}/${modelId})`);
|
|
100496
100615
|
agent.streamFn = createSiliconFlowThinkingWrapper(agent.streamFn);
|
|
100497
100616
|
}
|
|
100498
100617
|
if (provider === "moonshot") {
|
|
@@ -100500,22 +100619,22 @@ function applyExtraParamsToAgent(agent, cfg, provider, modelId, extraParamsOverr
|
|
|
100500
100619
|
configuredThinking: merged?.thinking,
|
|
100501
100620
|
thinkingLevel
|
|
100502
100621
|
});
|
|
100503
|
-
if (moonshotThinkingType) log$
|
|
100622
|
+
if (moonshotThinkingType) log$19.debug(`applying Moonshot thinking=${moonshotThinkingType} payload wrapper for ${provider}/${modelId}`);
|
|
100504
100623
|
agent.streamFn = createMoonshotThinkingWrapper(agent.streamFn, moonshotThinkingType);
|
|
100505
100624
|
}
|
|
100506
100625
|
if (provider === "openrouter") {
|
|
100507
|
-
log$
|
|
100626
|
+
log$19.debug(`applying OpenRouter app attribution headers for ${provider}/${modelId}`);
|
|
100508
100627
|
const openRouterThinkingLevel = modelId === "auto" || isOpenRouterReasoningUnsupported(modelId) ? void 0 : thinkingLevel;
|
|
100509
100628
|
agent.streamFn = createOpenRouterWrapper(agent.streamFn, openRouterThinkingLevel);
|
|
100510
100629
|
agent.streamFn = createOpenRouterSystemCacheWrapper(agent.streamFn);
|
|
100511
100630
|
}
|
|
100512
100631
|
if (provider === "amazon-bedrock" && !isAnthropicBedrockModel(modelId)) {
|
|
100513
|
-
log$
|
|
100632
|
+
log$19.debug(`disabling prompt caching for non-Anthropic Bedrock model ${provider}/${modelId}`);
|
|
100514
100633
|
agent.streamFn = createBedrockNoCacheWrapper(agent.streamFn);
|
|
100515
100634
|
}
|
|
100516
100635
|
if (provider === "zai" || provider === "z-ai") {
|
|
100517
100636
|
if (merged?.tool_stream !== false) {
|
|
100518
|
-
log$
|
|
100637
|
+
log$19.debug(`enabling Z.AI tool_stream for ${provider}/${modelId}`);
|
|
100519
100638
|
agent.streamFn = createZaiToolStreamWrapper(agent.streamFn, true);
|
|
100520
100639
|
}
|
|
100521
100640
|
}
|
|
@@ -101207,7 +101326,7 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
101207
101326
|
if (!session.manager.isConnected() && !session.broken) try {
|
|
101208
101327
|
await session.manager.connect(apiKey);
|
|
101209
101328
|
session.everConnected = true;
|
|
101210
|
-
log$
|
|
101329
|
+
log$19.debug(`[ws-stream] connected for session=${sessionId}`);
|
|
101211
101330
|
} catch (connErr) {
|
|
101212
101331
|
try {
|
|
101213
101332
|
session.manager.close();
|
|
@@ -101215,12 +101334,12 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
101215
101334
|
session.broken = true;
|
|
101216
101335
|
wsRegistry.delete(sessionId);
|
|
101217
101336
|
if (transport === "websocket") throw connErr instanceof Error ? connErr : new Error(String(connErr));
|
|
101218
|
-
log$
|
|
101337
|
+
log$19.warn(`[ws-stream] WebSocket connect failed for session=${sessionId}; falling back to HTTP. error=${String(connErr)}`);
|
|
101219
101338
|
return fallbackToHttp(model, context, options, eventStream, apiKey, opts.signal);
|
|
101220
101339
|
}
|
|
101221
101340
|
if (session.broken || !session.manager.isConnected()) {
|
|
101222
101341
|
if (transport === "websocket") throw new Error("WebSocket session disconnected");
|
|
101223
|
-
log$
|
|
101342
|
+
log$19.warn(`[ws-stream] session=${sessionId} broken/disconnected; falling back to HTTP`);
|
|
101224
101343
|
try {
|
|
101225
101344
|
session.manager.close();
|
|
101226
101345
|
} catch {}
|
|
@@ -101238,10 +101357,10 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
101238
101357
|
instructions: context.systemPrompt ?? void 0,
|
|
101239
101358
|
signal
|
|
101240
101359
|
});
|
|
101241
|
-
log$
|
|
101360
|
+
log$19.debug(`[ws-stream] warm-up completed for session=${sessionId}`);
|
|
101242
101361
|
} catch (warmErr) {
|
|
101243
101362
|
if (signal?.aborted) throw warmErr instanceof Error ? warmErr : new Error(String(warmErr));
|
|
101244
|
-
log$
|
|
101363
|
+
log$19.warn(`[ws-stream] warm-up failed for session=${sessionId}; continuing without warm-up. error=${String(warmErr)}`);
|
|
101245
101364
|
}
|
|
101246
101365
|
}
|
|
101247
101366
|
const prevResponseId = session.manager.previousResponseId;
|
|
@@ -101249,13 +101368,13 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
101249
101368
|
if (prevResponseId && session.lastContextLength > 0) {
|
|
101250
101369
|
const toolResults = context.messages.slice(session.lastContextLength).filter((m) => m.role === "toolResult");
|
|
101251
101370
|
if (toolResults.length === 0) {
|
|
101252
|
-
log$
|
|
101371
|
+
log$19.debug(`[ws-stream] session=${sessionId}: no new tool results found; sending full context`);
|
|
101253
101372
|
inputItems = buildFullInput(context);
|
|
101254
101373
|
} else inputItems = convertMessagesToInputItems(toolResults);
|
|
101255
|
-
log$
|
|
101374
|
+
log$19.debug(`[ws-stream] session=${sessionId}: incremental send (${inputItems.length} tool results) previous_response_id=${prevResponseId}`);
|
|
101256
101375
|
} else {
|
|
101257
101376
|
inputItems = buildFullInput(context);
|
|
101258
|
-
log$
|
|
101377
|
+
log$19.debug(`[ws-stream] session=${sessionId}: full context send (${inputItems.length} items)`);
|
|
101259
101378
|
}
|
|
101260
101379
|
const tools = convertTools(context.tools);
|
|
101261
101380
|
const streamOpts = options;
|
|
@@ -101285,7 +101404,7 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
101285
101404
|
session.manager.send(payload);
|
|
101286
101405
|
} catch (sendErr) {
|
|
101287
101406
|
if (transport === "websocket") throw sendErr instanceof Error ? sendErr : new Error(String(sendErr));
|
|
101288
|
-
log$
|
|
101407
|
+
log$19.warn(`[ws-stream] send failed for session=${sessionId}; falling back to HTTP. error=${String(sendErr)}`);
|
|
101289
101408
|
try {
|
|
101290
101409
|
session.manager.close();
|
|
101291
101410
|
} catch {}
|
|
@@ -101365,7 +101484,7 @@ function createOpenAIWebSocketStreamFn(apiKey, sessionId, opts = {}) {
|
|
|
101365
101484
|
};
|
|
101366
101485
|
queueMicrotask(() => run().catch((err) => {
|
|
101367
101486
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
101368
|
-
log$
|
|
101487
|
+
log$19.warn(`[ws-stream] session=${sessionId} run error: ${errorMessage}`);
|
|
101369
101488
|
eventStream.push({
|
|
101370
101489
|
type: "error",
|
|
101371
101490
|
reason: "error",
|
|
@@ -103415,7 +103534,7 @@ function normalizeRefForDedupe(raw) {
|
|
|
103415
103534
|
}
|
|
103416
103535
|
async function sanitizeImagesWithLog(images, label, imageSanitization) {
|
|
103417
103536
|
const { images: sanitized, dropped } = await sanitizeImageBlocks(images, label, imageSanitization);
|
|
103418
|
-
if (dropped > 0) log$
|
|
103537
|
+
if (dropped > 0) log$19.warn(`Native image: dropped ${dropped} image(s) after sanitization (${label}).`);
|
|
103419
103538
|
return sanitized;
|
|
103420
103539
|
}
|
|
103421
103540
|
/**
|
|
@@ -103502,7 +103621,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
103502
103621
|
mediaPath: targetPath
|
|
103503
103622
|
})).resolved;
|
|
103504
103623
|
} catch (err) {
|
|
103505
|
-
log$
|
|
103624
|
+
log$19.debug(`Native image: sandbox validation failed for ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
103506
103625
|
return null;
|
|
103507
103626
|
}
|
|
103508
103627
|
else if (!path.isAbsolute(targetPath)) targetPath = path.resolve(workspaceDir, targetPath);
|
|
@@ -103520,7 +103639,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
103520
103639
|
readFile: createSandboxBridgeReadFile({ sandbox: options.sandbox })
|
|
103521
103640
|
}) : await loadWebMedia(targetPath, options?.maxBytes);
|
|
103522
103641
|
if (media.kind !== "image") {
|
|
103523
|
-
log$
|
|
103642
|
+
log$19.debug(`Native image: not an image file: ${targetPath} (got ${media.kind})`);
|
|
103524
103643
|
return null;
|
|
103525
103644
|
}
|
|
103526
103645
|
const mimeType = media.contentType ?? "image/jpeg";
|
|
@@ -103530,7 +103649,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
103530
103649
|
mimeType
|
|
103531
103650
|
};
|
|
103532
103651
|
} catch (err) {
|
|
103533
|
-
log$
|
|
103652
|
+
log$19.debug(`Native image: failed to load ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
103534
103653
|
return null;
|
|
103535
103654
|
}
|
|
103536
103655
|
}
|
|
@@ -103567,7 +103686,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
103567
103686
|
loadedCount: 0,
|
|
103568
103687
|
skippedCount: 0
|
|
103569
103688
|
};
|
|
103570
|
-
log$
|
|
103689
|
+
log$19.debug(`Native image: detected ${allRefs.length} image refs in prompt`);
|
|
103571
103690
|
const promptImages = [...params.existingImages ?? []];
|
|
103572
103691
|
let loadedCount = 0;
|
|
103573
103692
|
let skippedCount = 0;
|
|
@@ -103580,7 +103699,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
103580
103699
|
if (image) {
|
|
103581
103700
|
promptImages.push(image);
|
|
103582
103701
|
loadedCount++;
|
|
103583
|
-
log$
|
|
103702
|
+
log$19.debug(`Native image: loaded ${ref.type} ${ref.resolved}`);
|
|
103584
103703
|
} else skippedCount++;
|
|
103585
103704
|
}
|
|
103586
103705
|
return {
|
|
@@ -104195,7 +104314,7 @@ async function buildStreamFn(params) {
|
|
|
104195
104314
|
const wsApiKey = await params.authStorage.getApiKey(params.provider);
|
|
104196
104315
|
if (wsApiKey) streamFn = createOpenAIWebSocketStreamFn(wsApiKey, params.sessionId, { signal: params.abortSignal });
|
|
104197
104316
|
else {
|
|
104198
|
-
log$
|
|
104317
|
+
log$19.warn(`[ws-stream] no API key for provider=${params.provider}; using HTTP transport`);
|
|
104199
104318
|
streamFn = streamSimple;
|
|
104200
104319
|
}
|
|
104201
104320
|
} else {
|
|
@@ -104298,13 +104417,13 @@ async function resolvePromptBuildHookResult(params) {
|
|
|
104298
104417
|
messages: params.messages,
|
|
104299
104418
|
systemPrompt: params.systemPrompt
|
|
104300
104419
|
}, params.hookCtx).catch((hookErr) => {
|
|
104301
|
-
log$
|
|
104420
|
+
log$19.warn(`before_prompt_build hook failed: ${String(hookErr)}`);
|
|
104302
104421
|
}) : void 0;
|
|
104303
104422
|
const legacyResult = params.legacyBeforeAgentStartResult ?? (params.hookRunner?.hasHooks("before_agent_start") ? await params.hookRunner.runBeforeAgentStart({
|
|
104304
104423
|
prompt: params.prompt,
|
|
104305
104424
|
messages: params.messages
|
|
104306
104425
|
}, params.hookCtx).catch((hookErr) => {
|
|
104307
|
-
log$
|
|
104426
|
+
log$19.warn(`before_agent_start hook (legacy prompt build path) failed: ${String(hookErr)}`);
|
|
104308
104427
|
}) : void 0);
|
|
104309
104428
|
return {
|
|
104310
104429
|
systemPrompt: promptBuildResult?.systemPrompt ?? legacyResult?.systemPrompt,
|
|
@@ -104442,7 +104561,7 @@ async function collectAttemptPromptContribution(params) {
|
|
|
104442
104561
|
messages: params.messages,
|
|
104443
104562
|
envelope: params.envelope
|
|
104444
104563
|
}, params.lifecycleCtx).catch((hookErr) => {
|
|
104445
|
-
log$
|
|
104564
|
+
log$19.warn(`context.collect hook failed: ${String(hookErr)}`);
|
|
104446
104565
|
}) : void 0;
|
|
104447
104566
|
return mergePromptContributions([promptBuildResultToContribution(legacyResult), contextCollectResult]);
|
|
104448
104567
|
}
|
|
@@ -104457,7 +104576,7 @@ async function runContextProjectionAndPruningHooks(params) {
|
|
|
104457
104576
|
contributions: params.contributions,
|
|
104458
104577
|
envelope: params.envelope
|
|
104459
104578
|
}, params.lifecycleCtx).catch((hookErr) => {
|
|
104460
|
-
log$
|
|
104579
|
+
log$19.warn(`context.project hook failed: ${String(hookErr)}`);
|
|
104461
104580
|
});
|
|
104462
104581
|
if (result?.messages) currentMessages = result.messages;
|
|
104463
104582
|
if (result?.projection) projection = {
|
|
@@ -104473,7 +104592,7 @@ async function runContextProjectionAndPruningHooks(params) {
|
|
|
104473
104592
|
tokenWindow: params.lifecycleCtx.tokenWindow,
|
|
104474
104593
|
usage: params.lifecycleCtx.usage
|
|
104475
104594
|
}, params.lifecycleCtx).catch((hookErr) => {
|
|
104476
|
-
log$
|
|
104595
|
+
log$19.warn(`context.prune hook failed: ${String(hookErr)}`);
|
|
104477
104596
|
});
|
|
104478
104597
|
if (result?.messages) currentMessages = result.messages;
|
|
104479
104598
|
if (result?.dropped) dropped.push(...result.dropped);
|
|
@@ -104575,7 +104694,7 @@ function installAttemptInputTransform(params) {
|
|
|
104575
104694
|
runtime: params.projectionRuntime,
|
|
104576
104695
|
timeoutMs: params.projectionArtifactTimeoutMs
|
|
104577
104696
|
}).catch((err) => {
|
|
104578
|
-
log$
|
|
104697
|
+
log$19.warn(`context projection artifact persist failed: ${String(err)}`);
|
|
104579
104698
|
});
|
|
104580
104699
|
const finalMessages = await runTransformLlmInputHooks({
|
|
104581
104700
|
messages: currentMessages,
|
|
@@ -104584,7 +104703,7 @@ function installAttemptInputTransform(params) {
|
|
|
104584
104703
|
provider: params.provider,
|
|
104585
104704
|
modelId: params.modelId
|
|
104586
104705
|
}).catch((err) => {
|
|
104587
|
-
log$
|
|
104706
|
+
log$19.warn(`transform_llm_input hook failed: ${String(err)}`);
|
|
104588
104707
|
}) ?? currentMessages;
|
|
104589
104708
|
params.onFinalInputMessages?.(finalMessages);
|
|
104590
104709
|
return finalMessages;
|
|
@@ -104702,11 +104821,10 @@ function summarizeSessionContext(messages) {
|
|
|
104702
104821
|
}
|
|
104703
104822
|
async function runEmbeddedAttempt(params) {
|
|
104704
104823
|
const resolvedWorkspace = resolveUserPath(params.workspaceDir);
|
|
104705
|
-
const prevCwd = process.cwd();
|
|
104706
104824
|
let pendingClearActiveEmbeddedRun;
|
|
104707
104825
|
const runAbortController = new AbortController();
|
|
104708
104826
|
const currentUserTurnForStorage = resolveCurrentUserTurnForStorage(params);
|
|
104709
|
-
log$
|
|
104827
|
+
log$19.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"}`);
|
|
104710
104828
|
await fs$1.mkdir(resolvedWorkspace, { recursive: true });
|
|
104711
104829
|
const sandboxSessionKey = params.sessionKey?.trim() || params.sessionId;
|
|
104712
104830
|
const toolSessionKey = params.toolSessionKey?.trim() || sandboxSessionKey;
|
|
@@ -104719,7 +104837,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
104719
104837
|
const effectiveWorkspace = sandbox?.enabled ? sandbox.workspaceAccess === "rw" ? resolvedWorkspace : sandbox.workspaceDir : resolvedWorkspace;
|
|
104720
104838
|
await fs$1.mkdir(effectiveWorkspace, { recursive: true });
|
|
104721
104839
|
let restoreSkillEnv;
|
|
104722
|
-
|
|
104840
|
+
const releaseWorkspaceCwd = params.skipCwdChange ? void 0 : acquireWorkspaceCwd(effectiveWorkspace);
|
|
104723
104841
|
try {
|
|
104724
104842
|
const skillWorkspace = params.skillWorkspaceDir ?? effectiveWorkspace;
|
|
104725
104843
|
const shouldLoadSkillEntries = !params.skipSkillEnv && (!params.skillsSnapshot || !params.skillsSnapshot.resolvedSkills);
|
|
@@ -104761,7 +104879,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
104761
104879
|
resolvedSystemPrompt,
|
|
104762
104880
|
warn: makeBootstrapWarn({
|
|
104763
104881
|
sessionLabel,
|
|
104764
|
-
warn: (message) => log$
|
|
104882
|
+
warn: (message) => log$19.warn(message)
|
|
104765
104883
|
}),
|
|
104766
104884
|
contextMode: params.bootstrapContextMode,
|
|
104767
104885
|
runKind: params.bootstrapContextRunKind,
|
|
@@ -105003,7 +105121,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105003
105121
|
if (queue != null) {
|
|
105004
105122
|
await drainPendingPrimaryWrites(queue, 3e4, storage?.config.fallbackToJsonlOnError ?? false);
|
|
105005
105123
|
if (storage?.runtime?.conversation?.upsertTurn) await storage.runtime.conversation.upsertTurn(params.sessionId).catch((err) => {
|
|
105006
|
-
log$
|
|
105124
|
+
log$19.warn("turn upsert failed (non-fatal)", {
|
|
105007
105125
|
sessionId: params.sessionId,
|
|
105008
105126
|
err
|
|
105009
105127
|
});
|
|
@@ -105071,14 +105189,14 @@ async function runEmbeddedAttempt(params) {
|
|
|
105071
105189
|
sessionManager = _wrapped.sm;
|
|
105072
105190
|
_primaryWriteQueue = _wrapped.queue;
|
|
105073
105191
|
}
|
|
105074
|
-
} else log$
|
|
105192
|
+
} else log$19.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", {
|
|
105075
105193
|
sessionId: params.sessionId,
|
|
105076
105194
|
backend: _configuredStorage?.runtime?.backend
|
|
105077
105195
|
});
|
|
105078
105196
|
} else {
|
|
105079
105197
|
await repairSessionFileIfNeeded({
|
|
105080
105198
|
sessionFile: params.sessionFile,
|
|
105081
|
-
warn: (message) => log$
|
|
105199
|
+
warn: (message) => log$19.warn(message)
|
|
105082
105200
|
});
|
|
105083
105201
|
const hadSessionFile = await fs$1.stat(params.sessionFile).then(() => true).catch(() => false);
|
|
105084
105202
|
if (!params.skipSessionManagerCache) await prewarmSessionFile(params.sessionFile);
|
|
@@ -105219,7 +105337,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105219
105337
|
const wsApiKey = await params.authStorage.getApiKey(params.provider);
|
|
105220
105338
|
if (wsApiKey) activeSession.agent.streamFn = createOpenAIWebSocketStreamFn(wsApiKey, params.sessionId, { signal: runAbortController.signal });
|
|
105221
105339
|
else {
|
|
105222
|
-
log$
|
|
105340
|
+
log$19.warn(`[ws-stream] no API key for provider=${params.provider}; using HTTP transport`);
|
|
105223
105341
|
activeSession.agent.streamFn = streamSimple;
|
|
105224
105342
|
}
|
|
105225
105343
|
} else {
|
|
@@ -105419,7 +105537,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105419
105537
|
let abortWarnTimer;
|
|
105420
105538
|
const isProbeSession = params.sessionId?.startsWith("probe-") ?? false;
|
|
105421
105539
|
const abortTimer = setTimeout(() => {
|
|
105422
|
-
if (!isProbeSession) log$
|
|
105540
|
+
if (!isProbeSession) log$19.warn(`embedded run timeout: runId=${params.runId} sessionId=${params.sessionId} timeoutMs=${params.timeoutMs}`);
|
|
105423
105541
|
if (shouldFlagCompactionTimeout({
|
|
105424
105542
|
isTimeout: true,
|
|
105425
105543
|
isCompactionPendingOrRetrying: subscription.isCompacting(),
|
|
@@ -105428,7 +105546,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105428
105546
|
abortRun(true);
|
|
105429
105547
|
if (!abortWarnTimer) abortWarnTimer = setTimeout(() => {
|
|
105430
105548
|
if (!activeSession.isStreaming) return;
|
|
105431
|
-
if (!isProbeSession) log$
|
|
105549
|
+
if (!isProbeSession) log$19.warn(`embedded run abort still streaming: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105432
105550
|
}, 1e4);
|
|
105433
105551
|
}, Math.max(1, params.timeoutMs));
|
|
105434
105552
|
let messagesSnapshot = [];
|
|
@@ -105462,7 +105580,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105462
105580
|
let timeoutHandle;
|
|
105463
105581
|
const timeout = new Promise((resolve) => {
|
|
105464
105582
|
timeoutHandle = setTimeout(() => {
|
|
105465
|
-
log$
|
|
105583
|
+
log$19.warn(`${label} timed out after ${metaTimeoutMs}ms`);
|
|
105466
105584
|
resolve(void 0);
|
|
105467
105585
|
}, metaTimeoutMs);
|
|
105468
105586
|
timeoutHandle.unref?.();
|
|
@@ -105470,7 +105588,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105470
105588
|
try {
|
|
105471
105589
|
return await Promise.race([p, timeout]);
|
|
105472
105590
|
} catch (err) {
|
|
105473
|
-
log$
|
|
105591
|
+
log$19.warn(`${label} failed: ${String(err)}`);
|
|
105474
105592
|
return;
|
|
105475
105593
|
} finally {
|
|
105476
105594
|
if (timeoutHandle !== void 0) clearTimeout(timeoutHandle);
|
|
@@ -105495,14 +105613,14 @@ async function runEmbeddedAttempt(params) {
|
|
|
105495
105613
|
senderIdentity,
|
|
105496
105614
|
workspaceLane: params.workspaceLane
|
|
105497
105615
|
});
|
|
105498
|
-
log$
|
|
105616
|
+
log$19.debug(`embedded run prompt start: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105499
105617
|
const leafEntry = sessionManager.getLeafEntry();
|
|
105500
105618
|
if (leafEntry?.type === "message" && leafEntry.message.role === "user") {
|
|
105501
105619
|
if (leafEntry.parentId) sessionManager.branch(leafEntry.parentId);
|
|
105502
105620
|
else sessionManager.resetLeaf();
|
|
105503
105621
|
const sessionContext = sessionManager.buildSessionContext();
|
|
105504
105622
|
activeSession.agent.state.messages = sessionContext.messages;
|
|
105505
|
-
log$
|
|
105623
|
+
log$19.warn(`Removed orphaned user message to prevent consecutive user turns. runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105506
105624
|
}
|
|
105507
105625
|
const cleanUserMessage = createCleanUserMessageFromPrompt(params.prompt);
|
|
105508
105626
|
const baseEnvelope = createCurrentUserPromptEnvelope({ cleanUserMessage });
|
|
@@ -105531,7 +105649,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105531
105649
|
const contributedSystemPrompt = applySystemPromptContribution(systemPromptText, promptContribution);
|
|
105532
105650
|
if (contributedSystemPrompt !== systemPromptText) {
|
|
105533
105651
|
applySystemPromptOverrideToSession(activeSession, contributedSystemPrompt);
|
|
105534
|
-
log$
|
|
105652
|
+
log$19.debug(`hooks: augmented system prompt (+${contributedSystemPrompt.length - systemPromptText.length} chars)`);
|
|
105535
105653
|
systemPromptText = contributedSystemPrompt;
|
|
105536
105654
|
}
|
|
105537
105655
|
cacheTrace?.recordStage("prompt:before", {
|
|
@@ -105563,12 +105681,12 @@ async function runEmbeddedAttempt(params) {
|
|
|
105563
105681
|
messages: activeSession.messages,
|
|
105564
105682
|
note: `images: prompt=${imageResult.images.length}`
|
|
105565
105683
|
});
|
|
105566
|
-
if (log$
|
|
105684
|
+
if (log$19.isEnabled("debug")) {
|
|
105567
105685
|
const msgCount = activeSession.messages.length;
|
|
105568
105686
|
const systemLen = systemPromptText?.length ?? 0;
|
|
105569
105687
|
const promptLen = effectivePrompt.length;
|
|
105570
105688
|
const sessionSummary = summarizeSessionContext(activeSession.messages);
|
|
105571
|
-
log$
|
|
105689
|
+
log$19.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}`);
|
|
105572
105690
|
}
|
|
105573
105691
|
if (hookRunner?.hasHooks("llm_input")) hookRunner.runLlmInput({
|
|
105574
105692
|
runId: params.runId,
|
|
@@ -105580,7 +105698,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105580
105698
|
historyMessages: activeSession.messages,
|
|
105581
105699
|
imagesCount: imageResult.images.length
|
|
105582
105700
|
}, hookCtx).catch((err) => {
|
|
105583
|
-
log$
|
|
105701
|
+
log$19.warn(`llm_input hook failed: ${String(err)}`);
|
|
105584
105702
|
});
|
|
105585
105703
|
const modelUserMessage = appendPromptImagesToUserMessage(renderedCurrentUserPrompt.modelUserMessage, imageResult.images);
|
|
105586
105704
|
const currentPromptIndex = activeSession.messages.length;
|
|
@@ -105623,7 +105741,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105623
105741
|
errorType: String(err instanceof Error ? err.name : "UnknownError")
|
|
105624
105742
|
});
|
|
105625
105743
|
} finally {
|
|
105626
|
-
log$
|
|
105744
|
+
log$19.debug(`embedded run prompt end: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - promptStartedAt}`);
|
|
105627
105745
|
}
|
|
105628
105746
|
const wasCompactingBefore = activeSession.isCompacting;
|
|
105629
105747
|
const snapshot = activeSession.messages.slice();
|
|
@@ -105638,7 +105756,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105638
105756
|
promptError = err;
|
|
105639
105757
|
promptErrorSource = "compaction";
|
|
105640
105758
|
}
|
|
105641
|
-
if (!isProbeSession) log$
|
|
105759
|
+
if (!isProbeSession) log$19.debug(`compaction wait aborted: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105642
105760
|
} else throw err;
|
|
105643
105761
|
}
|
|
105644
105762
|
const compactionOccurredThisAttempt = getCompactionCount() > 0;
|
|
@@ -105657,7 +105775,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105657
105775
|
currentSessionId: activeSession.sessionId
|
|
105658
105776
|
});
|
|
105659
105777
|
if (timedOutDuringCompaction) {
|
|
105660
|
-
if (!isProbeSession) log$
|
|
105778
|
+
if (!isProbeSession) log$19.warn(`using ${snapshotSelection.source} snapshot: timed out during compaction runId=${params.runId} sessionId=${params.sessionId}`);
|
|
105661
105779
|
}
|
|
105662
105780
|
messagesSnapshot = snapshotSelection.messagesSnapshot;
|
|
105663
105781
|
sessionIdUsed = snapshotSelection.sessionIdUsed;
|
|
@@ -105672,7 +105790,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105672
105790
|
error: describeUnknownError(promptError)
|
|
105673
105791
|
});
|
|
105674
105792
|
} catch (entryErr) {
|
|
105675
|
-
log$
|
|
105793
|
+
log$19.warn(`failed to persist prompt error entry: ${String(entryErr)}`);
|
|
105676
105794
|
}
|
|
105677
105795
|
if (!params.skipTranscriptSync) await drainOrSyncTranscript(_primaryWriteQueue, _isDbBackend, _configuredStorage, {
|
|
105678
105796
|
agentId: hookAgentIdForTranscript,
|
|
@@ -105692,16 +105810,16 @@ async function runEmbeddedAttempt(params) {
|
|
|
105692
105810
|
error: promptError ? describeUnknownError(promptError) : void 0,
|
|
105693
105811
|
durationMs: Date.now() - promptStartedAt
|
|
105694
105812
|
}, hookCtx).catch((err) => {
|
|
105695
|
-
log$
|
|
105813
|
+
log$19.warn(`agent_end hook failed: ${err}`);
|
|
105696
105814
|
});
|
|
105697
105815
|
} finally {
|
|
105698
105816
|
clearTimeout(abortTimer);
|
|
105699
105817
|
if (abortWarnTimer) clearTimeout(abortWarnTimer);
|
|
105700
|
-
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$
|
|
105818
|
+
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$19.debug(`run cleanup: runId=${params.runId} sessionId=${params.sessionId} aborted=${aborted} timedOut=${timedOut}`);
|
|
105701
105819
|
try {
|
|
105702
105820
|
unsubscribe();
|
|
105703
105821
|
} catch (err) {
|
|
105704
|
-
log$
|
|
105822
|
+
log$19.error(`CRITICAL: unsubscribe failed, possible resource leak: runId=${params.runId} ${String(err)}`);
|
|
105705
105823
|
}
|
|
105706
105824
|
pendingClearActiveEmbeddedRun = () => clearActiveEmbeddedRun(params.sessionId, queueHandle, params.sessionKey, !aborted && !timedOut && !promptError);
|
|
105707
105825
|
params.abortSignal?.removeEventListener?.("abort", onAbort);
|
|
@@ -105739,7 +105857,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105739
105857
|
workspaceLane: params.workspaceLane,
|
|
105740
105858
|
runId: params.runId
|
|
105741
105859
|
})).catch((err) => {
|
|
105742
|
-
log$
|
|
105860
|
+
log$19.warn(`model_call_ended hook failed: ${String(err)}`);
|
|
105743
105861
|
});
|
|
105744
105862
|
proxyMetadataFromHook = modelCallEndedEvent.proxyMetadata;
|
|
105745
105863
|
}
|
|
@@ -105763,7 +105881,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105763
105881
|
workspaceLane: params.workspaceLane,
|
|
105764
105882
|
runId: params.runId
|
|
105765
105883
|
})).catch((err) => {
|
|
105766
|
-
log$
|
|
105884
|
+
log$19.warn(`llm_output hook failed: ${String(err)}`);
|
|
105767
105885
|
});
|
|
105768
105886
|
return {
|
|
105769
105887
|
aborted,
|
|
@@ -105806,7 +105924,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105806
105924
|
if (_primaryWriteQueue != null && _primaryWriteQueue.length > 0) try {
|
|
105807
105925
|
await drainPendingPrimaryWrites(_primaryWriteQueue, 5e3, _configuredStorage?.config.fallbackToJsonlOnError ?? false);
|
|
105808
105926
|
} catch (cleanupDrainErr) {
|
|
105809
|
-
log$
|
|
105927
|
+
log$19.error("cleanup drain failed in finally; session entries may be lost", {
|
|
105810
105928
|
sessionId: params.sessionId,
|
|
105811
105929
|
error: cleanupDrainErr
|
|
105812
105930
|
});
|
|
@@ -105818,7 +105936,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
105818
105936
|
}
|
|
105819
105937
|
} finally {
|
|
105820
105938
|
restoreSkillEnv?.();
|
|
105821
|
-
|
|
105939
|
+
releaseWorkspaceCwd?.();
|
|
105822
105940
|
pendingClearActiveEmbeddedRun?.();
|
|
105823
105941
|
}
|
|
105824
105942
|
}
|
|
@@ -106094,8 +106212,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106094
106212
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
106095
106213
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
106096
106214
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
106097
|
-
if (workspaceResolution.usedFallback) log$
|
|
106098
|
-
const prevCwd = process.cwd();
|
|
106215
|
+
if (workspaceResolution.usedFallback) log$19.warn(`[workspace-fallback] caller=runEmbeddedPiAgent reason=${workspaceResolution.fallbackReason} run=${params.runId} session=${redactedSessionId} sessionKey=${redactedSessionKey} agent=${workspaceResolution.agentId} workspace=${redactedWorkspace}`);
|
|
106099
106216
|
let provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
106100
106217
|
let modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
106101
106218
|
const agentDir = params.agentDir ?? resolveOpenClawAgentDir();
|
|
@@ -106135,7 +106252,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106135
106252
|
if (hookRunner?.hasHooks("before_model_resolve")) try {
|
|
106136
106253
|
modelResolveOverride = await hookRunner.runBeforeModelResolve({ prompt: params.prompt }, hookCtx);
|
|
106137
106254
|
} catch (hookErr) {
|
|
106138
|
-
log$
|
|
106255
|
+
log$19.warn(`before_model_resolve hook failed: ${String(hookErr)}`);
|
|
106139
106256
|
}
|
|
106140
106257
|
if (hookRunner?.hasHooks("before_agent_start")) try {
|
|
106141
106258
|
legacyBeforeAgentStartResult = await hookRunner.runBeforeAgentStart({ prompt: params.prompt }, hookCtx);
|
|
@@ -106144,15 +106261,15 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106144
106261
|
modelOverride: modelResolveOverride?.modelOverride ?? legacyBeforeAgentStartResult?.modelOverride
|
|
106145
106262
|
};
|
|
106146
106263
|
} catch (hookErr) {
|
|
106147
|
-
log$
|
|
106264
|
+
log$19.warn(`before_agent_start hook (legacy model resolve path) failed: ${String(hookErr)}`);
|
|
106148
106265
|
}
|
|
106149
106266
|
if (modelResolveOverride?.providerOverride) {
|
|
106150
106267
|
provider = modelResolveOverride.providerOverride;
|
|
106151
|
-
log$
|
|
106268
|
+
log$19.info(`[hooks] provider overridden to ${provider}`);
|
|
106152
106269
|
}
|
|
106153
106270
|
if (modelResolveOverride?.modelOverride) {
|
|
106154
106271
|
modelId = modelResolveOverride.modelOverride;
|
|
106155
|
-
log$
|
|
106272
|
+
log$19.info(`[hooks] model overridden to ${modelId}`);
|
|
106156
106273
|
}
|
|
106157
106274
|
const { model, error, authStorage, modelRegistry } = resolveModel(provider, modelId, agentDir, params.config);
|
|
106158
106275
|
if (!model) throw new FailoverError(error ?? `Unknown model: ${provider}/${modelId}`, {
|
|
@@ -106172,9 +106289,9 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106172
106289
|
warnBelowTokens: CONTEXT_WINDOW_WARN_BELOW_TOKENS,
|
|
106173
106290
|
hardMinTokens: CONTEXT_WINDOW_HARD_MIN_TOKENS
|
|
106174
106291
|
});
|
|
106175
|
-
if (ctxGuard.shouldWarn) log$
|
|
106292
|
+
if (ctxGuard.shouldWarn) log$19.warn(`low context window: ${provider}/${modelId} ctx=${ctxGuard.tokens} (warn<${CONTEXT_WINDOW_WARN_BELOW_TOKENS}) source=${ctxGuard.source}`);
|
|
106176
106293
|
if (ctxGuard.shouldBlock) {
|
|
106177
|
-
log$
|
|
106294
|
+
log$19.error(`blocked model (context window too small): ${provider}/${modelId} ctx=${ctxGuard.tokens} (min=${CONTEXT_WINDOW_HARD_MIN_TOKENS}) source=${ctxGuard.source}`);
|
|
106178
106295
|
throw new FailoverError(`Model context window too small (${ctxGuard.tokens} tokens). Minimum is ${CONTEXT_WINDOW_HARD_MIN_TOKENS}.`, {
|
|
106179
106296
|
reason: "unknown",
|
|
106180
106297
|
provider,
|
|
@@ -106228,14 +106345,14 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106228
106345
|
copilotTokenState.refreshInFlight = (async () => {
|
|
106229
106346
|
const githubToken = copilotTokenState.githubToken.trim();
|
|
106230
106347
|
if (!githubToken) throw new Error("Copilot refresh requires a GitHub token.");
|
|
106231
|
-
log$
|
|
106348
|
+
log$19.debug(`Refreshing GitHub Copilot token (${reason})...`);
|
|
106232
106349
|
const copilotToken = await resolveCopilotApiToken({ githubToken });
|
|
106233
106350
|
authStorage.setRuntimeApiKey(model.provider, copilotToken.token);
|
|
106234
106351
|
copilotTokenState.expiresAt = copilotToken.expiresAt;
|
|
106235
106352
|
const remaining = copilotToken.expiresAt - Date.now();
|
|
106236
|
-
log$
|
|
106353
|
+
log$19.debug(`Copilot token refreshed; expires in ${Math.max(0, Math.floor(remaining / 1e3))}s.`);
|
|
106237
106354
|
})().catch((err) => {
|
|
106238
|
-
log$
|
|
106355
|
+
log$19.warn(`Copilot token refresh failed: ${describeUnknownError(err)}`);
|
|
106239
106356
|
throw err;
|
|
106240
106357
|
}).finally(() => {
|
|
106241
106358
|
copilotTokenState.refreshInFlight = void 0;
|
|
@@ -106245,7 +106362,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106245
106362
|
const scheduleCopilotRefresh = () => {
|
|
106246
106363
|
if (!copilotTokenState || copilotRefreshCancelled) return;
|
|
106247
106364
|
if (!hasCopilotGithubToken()) {
|
|
106248
|
-
log$
|
|
106365
|
+
log$19.warn("Skipping Copilot refresh scheduling; GitHub token missing.");
|
|
106249
106366
|
return;
|
|
106250
106367
|
}
|
|
106251
106368
|
clearCopilotRefreshTimer();
|
|
@@ -106407,7 +106524,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106407
106524
|
while (true) {
|
|
106408
106525
|
if (runLoopIterations >= MAX_RUN_LOOP_ITERATIONS) {
|
|
106409
106526
|
const message = `Exceeded retry limit after ${runLoopIterations} attempts (max=${MAX_RUN_LOOP_ITERATIONS}).`;
|
|
106410
|
-
log$
|
|
106527
|
+
log$19.error(`[run-retry-limit] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} attempts=${runLoopIterations} maxAttempts=${MAX_RUN_LOOP_ITERATIONS}`);
|
|
106411
106528
|
logRunCompleted({
|
|
106412
106529
|
runId: params.runId,
|
|
106413
106530
|
sessionKey: params.sessionKey,
|
|
@@ -106571,21 +106688,21 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106571
106688
|
const errorText = contextOverflowError.text;
|
|
106572
106689
|
const overflowStorage = getConfiguredSessionStorageRuntime();
|
|
106573
106690
|
const msgCount = attempt.messagesSnapshot?.length ?? 0;
|
|
106574
|
-
log$
|
|
106691
|
+
log$19.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)}`);
|
|
106575
106692
|
const isCompactionFailure = isCompactionFailureError(errorText);
|
|
106576
106693
|
const hadAttemptLevelCompaction = attemptCompactionCount > 0;
|
|
106577
106694
|
const explicitOverflowCompactionAllowed = params.trigger !== "analysis" && !params.disablePluginHooks && !params.skipTranscriptSync;
|
|
106578
106695
|
if (explicitOverflowCompactionAllowed && !isCompactionFailure && hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
106579
106696
|
overflowCompactionAttempts++;
|
|
106580
|
-
log$
|
|
106697
|
+
log$19.warn(`context overflow persisted after in-attempt compaction (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); retrying prompt without additional compaction for ${provider}/${modelId}`);
|
|
106581
106698
|
continue;
|
|
106582
106699
|
}
|
|
106583
106700
|
if (explicitOverflowCompactionAllowed && !isCompactionFailure && !hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
106584
|
-
if (log$
|
|
106701
|
+
if (log$19.isEnabled("debug")) log$19.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=compact isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts + 1} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
106585
106702
|
overflowCompactionAttempts++;
|
|
106586
|
-
log$
|
|
106703
|
+
log$19.warn(`context overflow detected (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); attempting auto-compaction for ${provider}/${modelId}`);
|
|
106587
106704
|
const _overflowIsDb = (overflowStorage?.runtime?.backend ?? "fs-jsonl") !== "fs-jsonl";
|
|
106588
|
-
if (_overflowIsDb) log$
|
|
106705
|
+
if (_overflowIsDb) log$19.warn(`context overflow compaction skipped for DB backend session ${params.sessionId}; compact.ts does not yet support DB-backend sessions`);
|
|
106589
106706
|
const compactResult = _overflowIsDb ? {
|
|
106590
106707
|
compacted: false,
|
|
106591
106708
|
reason: "db-backend-not-supported"
|
|
@@ -106618,10 +106735,10 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106618
106735
|
});
|
|
106619
106736
|
if (compactResult.compacted) {
|
|
106620
106737
|
autoCompactionCount += 1;
|
|
106621
|
-
log$
|
|
106738
|
+
log$19.info(`auto-compaction succeeded for ${provider}/${modelId}; retrying prompt`);
|
|
106622
106739
|
continue;
|
|
106623
106740
|
}
|
|
106624
|
-
log$
|
|
106741
|
+
log$19.warn(`auto-compaction failed for ${provider}/${modelId}: ${compactResult.reason ?? "nothing to compact"}`);
|
|
106625
106742
|
}
|
|
106626
106743
|
if (!toolResultTruncationAttempted) {
|
|
106627
106744
|
const contextWindowTokens = ctxInfo.tokens;
|
|
@@ -106630,11 +106747,11 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106630
106747
|
contextWindowTokens
|
|
106631
106748
|
}) : false;
|
|
106632
106749
|
if (hasOversized) {
|
|
106633
|
-
if (log$
|
|
106750
|
+
if (log$19.isEnabled("debug")) log$19.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=truncate_tool_results isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=${hasOversized} attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
106634
106751
|
toolResultTruncationAttempted = true;
|
|
106635
|
-
if ((overflowStorage?.runtime?.backend ?? "fs-jsonl") !== "fs-jsonl") log$
|
|
106752
|
+
if ((overflowStorage?.runtime?.backend ?? "fs-jsonl") !== "fs-jsonl") log$19.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`);
|
|
106636
106753
|
else {
|
|
106637
|
-
log$
|
|
106754
|
+
log$19.warn(`[context-overflow-recovery] Attempting tool result truncation for ${provider}/${modelId} (contextWindow=${contextWindowTokens} tokens)`);
|
|
106638
106755
|
const truncResult = await truncateOversizedToolResultsInSession({
|
|
106639
106756
|
sessionFile: params.sessionFile,
|
|
106640
106757
|
contextWindowTokens,
|
|
@@ -106642,14 +106759,14 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106642
106759
|
sessionKey: params.sessionKey
|
|
106643
106760
|
});
|
|
106644
106761
|
if (truncResult.truncated) {
|
|
106645
|
-
log$
|
|
106762
|
+
log$19.info(`[context-overflow-recovery] Truncated ${truncResult.truncatedCount} tool result(s); retrying prompt`);
|
|
106646
106763
|
continue;
|
|
106647
106764
|
}
|
|
106648
|
-
log$
|
|
106765
|
+
log$19.warn(`[context-overflow-recovery] Tool result truncation did not help: ${truncResult.reason ?? "unknown"}`);
|
|
106649
106766
|
}
|
|
106650
|
-
} else if (log$
|
|
106767
|
+
} else if (log$19.isEnabled("debug")) log$19.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=give_up isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=${hasOversized} attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
106651
106768
|
}
|
|
106652
|
-
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS || toolResultTruncationAttempted) && log$
|
|
106769
|
+
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS || toolResultTruncationAttempted) && log$19.isEnabled("debug")) log$19.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=give_up isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
106653
106770
|
const kind = isCompactionFailure ? "compaction_failure" : "context_overflow";
|
|
106654
106771
|
logRunCompleted({
|
|
106655
106772
|
runId: params.runId,
|
|
@@ -106755,7 +106872,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106755
106872
|
attempted: attemptedThinking
|
|
106756
106873
|
});
|
|
106757
106874
|
if (fallbackThinking) {
|
|
106758
|
-
log$
|
|
106875
|
+
log$19.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
106759
106876
|
thinkLevel = fallbackThinking;
|
|
106760
106877
|
continue;
|
|
106761
106878
|
}
|
|
@@ -106773,7 +106890,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106773
106890
|
attempted: attemptedThinking
|
|
106774
106891
|
});
|
|
106775
106892
|
if (fallbackThinking && !aborted) {
|
|
106776
|
-
log$
|
|
106893
|
+
log$19.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
106777
106894
|
thinkLevel = fallbackThinking;
|
|
106778
106895
|
continue;
|
|
106779
106896
|
}
|
|
@@ -106794,7 +106911,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106794
106911
|
imageDimensionError.contentIndex !== void 0 ? `content=${imageDimensionError.contentIndex}` : null,
|
|
106795
106912
|
imageDimensionError.maxDimensionPx !== void 0 ? `limit=${imageDimensionError.maxDimensionPx}px` : null
|
|
106796
106913
|
].filter(Boolean).join(" ");
|
|
106797
|
-
log$
|
|
106914
|
+
log$19.warn(`Profile ${lastProfileId} rejected image payload${details ? ` (${details})` : ""}.`);
|
|
106798
106915
|
}
|
|
106799
106916
|
if (!aborted && failoverFailure || timedOut && !timedOutDuringCompaction) {
|
|
106800
106917
|
if (lastProfileId) {
|
|
@@ -106802,8 +106919,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106802
106919
|
profileId: lastProfileId,
|
|
106803
106920
|
reason: timedOut || assistantFailoverReason === "timeout" ? "timeout" : assistantFailoverReason ?? "unknown"
|
|
106804
106921
|
});
|
|
106805
|
-
if (timedOut && !isProbeSession) log$
|
|
106806
|
-
if (cloudCodeAssistFormatError) log$
|
|
106922
|
+
if (timedOut && !isProbeSession) log$19.warn(`Profile ${lastProfileId} timed out. Trying next account...`);
|
|
106923
|
+
if (cloudCodeAssistFormatError) log$19.warn(`Profile ${lastProfileId} hit Cloud Code Assist format error. Tool calls will be sanitized on retry.`);
|
|
106807
106924
|
}
|
|
106808
106925
|
if (await advanceAuthProfile()) continue;
|
|
106809
106926
|
if (fallbackConfigured) {
|
|
@@ -106848,7 +106965,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106848
106965
|
}, hookCtx);
|
|
106849
106966
|
if (transformResult?.assistantTexts) finalAssistantTexts = transformResult.assistantTexts;
|
|
106850
106967
|
} catch (err) {
|
|
106851
|
-
log$
|
|
106968
|
+
log$19.warn(`transform_llm_output hook failed: ${String(err)}`);
|
|
106852
106969
|
}
|
|
106853
106970
|
const payloads = buildEmbeddedRunPayloads({
|
|
106854
106971
|
assistantTexts: finalAssistantTexts,
|
|
@@ -106899,7 +107016,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106899
107016
|
durationMs: Date.now() - started,
|
|
106900
107017
|
exitStatus: aborted || timedOut ? "error" : void 0
|
|
106901
107018
|
});
|
|
106902
|
-
log$
|
|
107019
|
+
log$19.debug(`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`);
|
|
106903
107020
|
if (lastProfileId) {
|
|
106904
107021
|
await markAuthProfileGood({
|
|
106905
107022
|
store: authStore,
|
|
@@ -106936,7 +107053,6 @@ async function runEmbeddedPiAgent(params) {
|
|
|
106936
107053
|
}
|
|
106937
107054
|
} finally {
|
|
106938
107055
|
stopCopilotRefreshTimer();
|
|
106939
|
-
if (!params.skipCwdChange) process.chdir(prevCwd);
|
|
106940
107056
|
}
|
|
106941
107057
|
}));
|
|
106942
107058
|
}
|