@symerian/symi 2.5.8 → 2.6.1
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/{accounts-qtxJ-6em.js → accounts-3dCrO3oZ.js} +1 -1
- package/dist/{accounts-tNElYrCH.js → accounts-BRw8yhIW.js} +21 -21
- package/dist/{accounts-CWktKM8a.js → accounts-BuZxOb3B.js} +1 -1
- package/dist/{active-listener-C9r8ZB9m.js → active-listener-CfHHV2SU.js} +1 -1
- package/dist/{agent-scope-BxoUQqgM.js → agent-scope-CpEJ0B88.js} +3 -3
- package/dist/{agents-CXloh6n_.js → agents-DQIz-_on.js} +4 -4
- package/dist/{agents.config-BuTzBaXf.js → agents.config-CIJRaVWl.js} +1 -1
- package/dist/{agents.config-BhAJXAtA.js → agents.config-D8WPDf-m.js} +1 -1
- package/dist/{audio-preflight-O3ASWbaG.js → audio-preflight-BVaaZWkg.js} +34 -34
- package/dist/{audio-preflight-C40mKAp7.js → audio-preflight-CPBOQV4I.js} +4 -4
- package/dist/{auth-choice-DvaVrSwn.js → auth-choice-BqFbNDuP.js} +1 -1
- package/dist/{auth-choice-Br6zT8iS.js → auth-choice-DTDyJL1r.js} +1 -1
- package/dist/{model-auth-DK43VicI.js → auth-profiles-DdK1Hxaa.js} +412 -412
- package/dist/{banner-BtqKaQZr.js → banner-DYDCxnDL.js} +1 -1
- package/dist/{bindings-B7Ke6LJi.js → bindings-BsHoBLIE.js} +2 -2
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +60 -60
- package/dist/bundled/bootstrap-extra-files/handler.js +6 -6
- package/dist/bundled/command-logger/handler.js +3 -3
- package/dist/bundled/session-memory/handler.js +61 -61
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{channel-activity-CsM_hJ_s.js → channel-activity-B6G1jnQT.js} +2 -2
- package/dist/{channel-options-CfLxsV76.js → channel-options-CvHSm_Kx.js} +1 -1
- package/dist/{channel-options-DFHEgad5.js → channel-options-vBCJhJB7.js} +1 -1
- package/dist/{channel-web-D-jDDmWN.js → channel-web-CM2LyWZW.js} +1 -1
- package/dist/{channels-cli-BEZORT4N.js → channels-cli-D5H3Wcho.js} +4 -4
- package/dist/{channels-cli-CT6wdGT8.js → channels-cli-DzOjNNFn.js} +4 -4
- package/dist/{chrome-BFekevcE.js → chrome-D2SKJnR7.js} +24 -24
- package/dist/{chrome-CDJYxX5a.js → chrome-DkaXoP36.js} +5 -5
- package/dist/{chunk-BW5f05BR.js → chunk-09egQapi.js} +1 -1
- package/dist/{cli-kxxM9xT0.js → cli-8hqssnRJ.js} +1 -1
- package/dist/{cli-CkxvN9Cb.js → cli-DNZwCDRe.js} +1 -1
- package/dist/{command-registry-DsqA8NDd.js → command-registry-CHtN2HeK.js} +9 -9
- package/dist/{commands-registry-D7CTCQPm.js → commands-registry-Bfc7Uz0o.js} +4 -4
- package/dist/{completion-cli-mZMiIG7C.js → completion-cli-C8y_J5KC.js} +1 -1
- package/dist/{completion-cli-QCrjurdu.js → completion-cli-Cov6N3BO.js} +2 -2
- package/dist/{config-DRbjHIwD.js → config-5SdHIcHU.js} +6 -6
- package/dist/{config-cli-CS_0o9LY.js → config-cli-B2REEd2l.js} +1 -1
- package/dist/{config-cli-DLsLPE4o.js → config-cli-BwO0xAbV.js} +1 -1
- package/dist/{configure-T9J4bw0H.js → configure-BWSYSi2-.js} +3 -3
- package/dist/{configure-BX4aNf3w.js → configure-C6yNe33U.js} +3 -3
- package/dist/{conversation-label-DXUkoKcB.js → conversation-label-Onz2hiJh.js} +1 -1
- package/dist/{deliver-BH0l3UKW.js → deliver-C-37cZUe.js} +1 -1
- package/dist/{deliver-CvCK5Mm9.js → deliver-C46-vyqg.js} +11 -11
- package/dist/{diagnostic-CI0kRQkt.js → diagnostic-rPhsBoZz.js} +2 -2
- package/dist/{doctor-completion-BKydQfCM.js → doctor-completion-BKKzstt6.js} +1 -1
- package/dist/{doctor-completion-CTodkFg2.js → doctor-completion-D7CDLFLg.js} +1 -1
- package/dist/entry.js +1 -1
- package/dist/{command-format-BaxDnULz.js → env-BDXYbTKj.js} +10 -10
- package/dist/{errors-BoQgnc8X.js → errors-XIsvXeC-.js} +1 -1
- package/dist/extensionAPI.js +6 -6
- package/dist/{frontmatter-C_bv_0P8.js → frontmatter-CTR5f_Ez.js} +2 -2
- package/dist/{gateway-cli-CZnyhTAu.js → gateway-cli-BhFM4Bkm.js} +20 -18
- package/dist/{gateway-cli-DEpU3Bg3.js → gateway-cli-Datohp3m.js} +20 -18
- package/dist/{gemini-auth-CdSPHuLl.js → gemini-auth-Dy12ZAH3.js} +2 -2
- package/dist/{github-copilot-token-C_qUP7p5.js → github-copilot-token-cCYzSU9h.js} +1 -1
- package/dist/{glass-ui-ws-KbKXJGb5.js → glass-ui-ws-BzqfD_wX.js} +7 -7
- package/dist/{glass-ui-ws-BdBSYcsf.js → glass-ui-ws-D9yvYULL.js} +7 -7
- package/dist/{health-DQmyj-7z.js → health-BjwDRAdd.js} +1 -1
- package/dist/{health-z-YCZRhf.js → health-C5XJPwpt.js} +1 -1
- package/dist/{hooks-cli-4d-QhgRs.js → hooks-cli-CafMq9Vr.js} +2 -2
- package/dist/{hooks-cli-BRehYEXJ.js → hooks-cli-U12oVyLH.js} +2 -2
- package/dist/{image-B0wGflxA.js → image-CuzFLQWC.js} +7 -7
- package/dist/{image-CHzdaNJ4.js → image-DcpMiprB.js} +1 -1
- package/dist/{image-ops-CvJzsyvE.js → image-ops-C7CauEK8.js} +99 -99
- package/dist/{inbound-context-BlHX0H3E.js → inbound-context-DSDTl6Kj.js} +2 -2
- package/dist/index.js +6 -6
- package/dist/{ir-DccrnjsE.js → ir-CTiz95Vb.js} +5 -5
- package/dist/llm-slug-generator.js +64 -84
- package/dist/{local-roots-DMwIh5cS.js → local-roots-DhZz0Ybs.js} +6 -6
- package/dist/{login-qr-Batf3PT5.js → login-qr-AP9agO-i.js} +13 -13
- package/dist/{login-CwCoxapk.js → login-ul8zaw_S.js} +7 -7
- package/dist/{manager-D_LwXbc6.js → manager-PprhCvO_.js} +25 -25
- package/dist/{manifest-registry-D0IQ3WuX.js → manifest-registry-yb7sAlu4.js} +2 -2
- package/dist/{markdown-tables-iMQQZu4Q.js → markdown-tables-C-BmIap8.js} +1 -1
- package/dist/{message-channel-Dz5lr5b0.js → message-channel-OlFBYAw8.js} +1 -1
- package/dist/{models-CPlSSoV0.js → models-Bo4iHJy-.js} +7 -8
- package/dist/{models-cli-BM2RWTmM.js → models-cli-6aNi3eN9.js} +7 -8
- package/dist/{models-cli-DDhpJuX3.js → models-cli-B5vh-XK8.js} +3 -3
- package/dist/{onboard-DpB21qno.js → onboard-Bm-pmstf.js} +2 -2
- package/dist/{onboard-channels-DjfS9mS6.js → onboard-channels-BRd1cXye.js} +1 -1
- package/dist/{onboard-channels-S0FbC25u.js → onboard-channels-CUl5U8kV.js} +1 -1
- package/dist/{onboard-BczLOUCW.js → onboard-f-GJ26Ix.js} +2 -2
- package/dist/{onboarding-CyPkawbg.js → onboarding-CvBDWlBJ.js} +3 -3
- package/dist/{onboarding--mrKZtpR.js → onboarding-DIVKvosg.js} +3 -3
- package/dist/{onboarding.finalize-0XoI3wLH.js → onboarding.finalize-DJX6mSLa.js} +6 -6
- package/dist/{onboarding.finalize-C0ijhYbg.js → onboarding.finalize-WSac-JKd.js} +5 -5
- package/dist/{outbound-D4fN_ZlE.js → outbound-CtMCmwxR.js} +7 -7
- package/dist/{outbound-attachment-DjNDa3zn.js → outbound-attachment-DJldbweZ.js} +2 -2
- package/dist/{paths-DLyHUt31.js → paths-CbQV9WEg.js} +2 -2
- package/dist/{pi-auth-json-0SYBFZTt.js → pi-auth-json-Bk8ERadJ.js} +10 -10
- package/dist/{pi-embedded-Cg70pjmm.js → pi-embedded-BmbbC1Sb.js} +20275 -20070
- package/dist/{pi-embedded-helpers-lgx_U5KS.js → pi-embedded-helpers-B8kqLWns.js} +4 -4
- package/dist/{pi-embedded-helpers-DLFjnVBb.js → pi-embedded-helpers-CfqDGQ9J.js} +81 -81
- package/dist/{plugin-registry-VhRGXCLQ.js → plugin-registry-2zUJMasm.js} +1 -1
- package/dist/{plugin-registry-Dxo1iUfJ.js → plugin-registry-5yf-hu_W.js} +1 -1
- package/dist/plugin-sdk/agents/model-token-filter.d.ts +10 -0
- package/dist/plugin-sdk/agents/pi-embedded-runner.d.ts +1 -1
- package/dist/plugin-sdk/agents/pi-tools.validate-wrapper.d.ts +23 -0
- package/dist/plugin-sdk/agents/pi-tools.validate.d.ts +26 -0
- package/dist/plugin-sdk/agents/tool-loop-detection.d.ts +3 -1
- package/dist/plugin-sdk/agents/unified-runner.d.ts +69 -1
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-execution.d.ts +2 -2
- package/dist/plugin-sdk/{channel-web-DKo2tOO-.js → channel-web-DPyyTvFo.js} +1 -1
- package/dist/plugin-sdk/config/model-profiles.d.ts +2 -0
- package/dist/plugin-sdk/index.js +2 -2
- package/dist/plugin-sdk/infra/diagnostic-events.d.ts +1 -1
- package/dist/plugin-sdk/logging/diagnostic-session-state.d.ts +2 -0
- package/dist/plugin-sdk/logging/diagnostic.d.ts +1 -1
- package/dist/plugin-sdk/{reply-Ch4_18FZ.js → reply-QAcAd9ev.js} +536 -331
- package/dist/plugin-sdk/{tool-loop-detection-edmW8ZiF.js → tool-loop-detection-DU5sTIKg.js} +53 -3
- package/dist/plugin-sdk/{web-Dz2oyzw_.js → web-DaTTL9M0.js} +2 -2
- package/dist/{plugins-DQYI3Fr-.js → plugins-BzmbgY7s.js} +5 -5
- package/dist/{plugins-cli-zNr1ThAO.js → plugins-cli-D4eRESV2.js} +2 -2
- package/dist/{plugins-cli-DeDSnKlr.js → plugins-cli-DksVl33N.js} +2 -2
- package/dist/{program-COEKTv5u.js → program-BjORH7Cc.js} +7 -7
- package/dist/{program-context-CbM3x8lT.js → program-context-DaNGrTOm.js} +17 -17
- package/dist/{prompt-select-styled-d18_XWTb.js → prompt-select-styled-QaS2zul_.js} +4 -4
- package/dist/{prompt-select-styled-C6JLWNMU.js → prompt-select-styled-YOj4xigd.js} +4 -4
- package/dist/{provider-auth-helpers-BmH4oHwJ.js → provider-auth-helpers-BAGT_RXV.js} +1 -1
- package/dist/{provider-auth-helpers-C8cO9DLi.js → provider-auth-helpers-DCEbm2hz.js} +1 -1
- package/dist/{push-apns-CoqskfCc.js → push-apns-BECodU1i.js} +1 -1
- package/dist/{push-apns-CJtWrkQV.js → push-apns-Bek3ANJa.js} +1 -1
- package/dist/{pw-ai-De-KR9_s.js → pw-ai-1htA-NnS.js} +1 -1
- package/dist/{pw-ai-BnAKvSuw.js → pw-ai-m0mj2KWK.js} +16 -16
- package/dist/{qmd-manager-QHUP-_em.js → qmd-manager-iDLSiI4Z.js} +10 -10
- package/dist/{register.agent-C1Is84Q1.js → register.agent-B34lxx7F.js} +5 -5
- package/dist/{register.agent-fK3vOCU5.js → register.agent-DJHQo-Iq.js} +6 -6
- package/dist/{register.configure-CIwwqqt9.js → register.configure-BdhhIzb0.js} +6 -6
- package/dist/{register.configure-DFJeKFFK.js → register.configure-DC_-t5kj.js} +6 -6
- package/dist/{register.maintenance-BwTFd3Ax.js → register.maintenance-CITur3O_.js} +8 -8
- package/dist/{register.maintenance-DKDqruW6.js → register.maintenance-cs-A4kHF.js} +7 -7
- package/dist/{register.message-DYnXMP4c.js → register.message--RhtnEYn.js} +2 -2
- package/dist/{register.message-Ce57RPK8.js → register.message-PIaHm2pZ.js} +2 -2
- package/dist/{register.onboard-9glf-j43.js → register.onboard-CTJQoDcK.js} +4 -4
- package/dist/{register.onboard-Dj-_AJQr.js → register.onboard-DucZgrF7.js} +4 -4
- package/dist/{register.setup-C0CXUMFE.js → register.setup-2ZiUN7ui.js} +4 -4
- package/dist/{register.setup-Cp3DBI6D.js → register.setup-DD4Rgkt9.js} +4 -4
- package/dist/{register.status-health-sessions-DBXMyrNP.js → register.status-health-sessions-BqD7L8XL.js} +3 -3
- package/dist/{register.status-health-sessions-BncpB9Vw.js → register.status-health-sessions-sLgA92t7.js} +3 -3
- package/dist/{register.subclis-D6PmKJll.js → register.subclis-B2dGWFur.js} +9 -9
- package/dist/{registry-CK4e9hn8.js → registry-DYq1AYOv.js} +2 -2
- package/dist/{replies-BIX_isV7.js → replies-LSmuwOhA.js} +3 -3
- package/dist/{reply-BfZzgC9H.js → reply-DYnTEYoa.js} +537 -332
- package/dist/{reply-prefix-XlyuyChD.js → reply-prefix-DpqZu44Z.js} +1 -1
- package/dist/{resolve-route-CZ-1eqw0.js → resolve-route-C4_I4GFI.js} +5 -5
- package/dist/{retry-Cly39XZB.js → retry-BBVXkKBV.js} +1 -1
- package/dist/{run-main-wm3s04Xh.js → run-main-DWmu2b6D.js} +14 -14
- package/dist/{runner-DUBExAb5.js → runner-BcQ0sF9T.js} +1 -1
- package/dist/{runner-odEv83vv.js → runner-CU9l0uJh.js} +46 -46
- package/dist/{send-WyRqb4WD.js → send-CQAKg_12.js} +7 -7
- package/dist/{send-DeFniOjh.js → send-CVMyYPQw.js} +7 -7
- package/dist/{send-CiTGOvEc.js → send-CvhXrdgS.js} +12 -12
- package/dist/{send-DW96zgDL.js → send-DAN9hA5h.js} +6 -6
- package/dist/{send-B1u-LrcS.js → send-DYj_o4_F.js} +14 -14
- package/dist/{server-methods-D5zcFhng.js → server-methods-C8EWZt2g.js} +7 -7
- package/dist/{server-methods-xXv4ObXK.js → server-methods-vDGoM3xL.js} +7 -7
- package/dist/{server-node-events-BN7H6wBM.js → server-node-events-CKi12bol.js} +2 -2
- package/dist/{server-node-events-D4At7-pe.js → server-node-events-DFwGbkcO.js} +2 -2
- package/dist/{session-SM36BTsl.js → session-DSU1vxxi.js} +4 -4
- package/dist/{skill-commands-BJMb_psG.js → skill-commands-DcVwOafC.js} +17 -17
- package/dist/{skills-BFekKL7i.js → skills-Bs0AW1g3.js} +25 -25
- package/dist/{sqlite-DRbx2dhW.js → sqlite-D_mz1_-y.js} +17 -17
- package/dist/{status-XJTqV-CC.js → status--iNVOTMO.js} +2 -2
- package/dist/{status-PbQwO8SV.js → status-B1_iHrOg.js} +2 -2
- package/dist/{status-Nhvf_TEN.js → status-BQcdARV4.js} +1 -1
- package/dist/{status-C5rGEkur.js → status-DiX0DAtH.js} +1 -1
- package/dist/{store-C0wvOkae.js → store-01F_JM7O.js} +6 -6
- package/dist/{subagent-registry-DvCrN2PQ.js → subagent-registry-CXrOOgPW.js} +19438 -19233
- package/dist/{subsystem-Bs9YvKLa.js → subsystem-BjyjJF-d.js} +1 -1
- package/dist/{tables-DuZspiBu.js → tables-qMwbq29u.js} +1 -1
- package/dist/{target-errors-Be1SwYlW.js → target-errors-Bbr9rlzN.js} +2 -2
- package/dist/{thinking-CdlENGRW.js → thinking-BprCy23Z.js} +5 -5
- package/dist/{tokens-H1H1LiSQ.js → tokens-Bux9Y_xD.js} +1 -1
- package/dist/{tool-images-DXB7tqWi.js → tool-images-SqqWIT22.js} +2 -2
- package/dist/{tool-loop-detection-BgbtzUGc.js → tool-loop-detection-C7TCF2V2.js} +53 -3
- package/dist/{tool-loop-detection-BU3fbtCd.js → tool-loop-detection-D7qjFnRh.js} +53 -3
- package/dist/{tool-loop-detection-B6j1r-Wk.js → tool-loop-detection-DPVtQOfM.js} +53 -3
- package/dist/{tool-loop-detection-Cs8_HCsx.js → tool-loop-detection-DR_rrIA1.js} +56 -6
- package/dist/{pi-embedded-CTBkDXkV.js → unified-runner-CulJZMxc.js} +69924 -69719
- package/dist/{update-cli-BHxqriaA.js → update-cli-560gprSp.js} +7 -7
- package/dist/{update-cli-IqwjBYS0.js → update-cli-D1pLX3eo.js} +8 -8
- package/dist/{update-runner-BuoOzUcX.js → update-runner-BQxFFCGc.js} +1 -1
- package/dist/{update-runner-BFwirE1P.js → update-runner-CLKHrONW.js} +1 -1
- package/dist/{web-C4CDNJmR.js → web-Bqrgp43v.js} +1 -1
- package/dist/{web-OSVyyJa9.js → web-D4qJ9XKP.js} +6 -6
- package/dist/{web-Cr6E8Ych.js → web-Dr5cOn-1.js} +2 -2
- package/dist/{web-Dti17mxB.js → web-hHX9a9YO.js} +64 -64
- package/dist/{whatsapp-actions-D1RsnX7P.js → whatsapp-actions-BIeSWsCF.js} +25 -25
- package/dist/{workspace-wAaHI8-5.js → workspace-DscDraUb.js} +28 -28
- package/extensions/bluebubbles/node_modules/.bin/symi +0 -0
- package/extensions/copilot-proxy/node_modules/.bin/symi +0 -0
- package/extensions/diagnostics-otel/node_modules/.bin/acorn +0 -0
- package/extensions/diagnostics-otel/node_modules/.bin/symi +0 -0
- package/extensions/discord/node_modules/.bin/symi +0 -0
- package/extensions/feishu/node_modules/.bin/symi +0 -0
- package/extensions/google-antigravity-auth/node_modules/.bin/symi +0 -0
- package/extensions/google-gemini-cli-auth/node_modules/.bin/symi +0 -0
- package/extensions/googlechat/node_modules/.bin/symi +0 -0
- package/extensions/imessage/node_modules/.bin/symi +0 -0
- package/extensions/irc/node_modules/.bin/symi +0 -0
- package/extensions/learning-loop/node_modules/.bin/symi +0 -0
- package/extensions/line/node_modules/.bin/symi +0 -0
- package/extensions/matrix/node_modules/.bin/markdown-it +0 -0
- package/extensions/matrix/node_modules/.bin/symi +0 -0
- package/extensions/mattermost/node_modules/.bin/symi +0 -0
- package/extensions/memory-core/node_modules/.bin/symi +0 -0
- package/extensions/memory-lancedb/node_modules/.bin/arrow2csv +0 -0
- package/extensions/memory-lancedb/node_modules/.bin/openai +0 -0
- package/extensions/memory-lancedb/node_modules/.bin/symi +0 -0
- package/extensions/minimax-portal-auth/node_modules/.bin/symi +0 -0
- package/extensions/msteams/node_modules/.bin/symi +0 -0
- package/extensions/nextcloud-talk/node_modules/.bin/symi +0 -0
- package/extensions/nostr/node_modules/.bin/symi +0 -0
- package/extensions/nostr/node_modules/.bin/tsc +0 -0
- package/extensions/nostr/node_modules/.bin/tsserver +0 -0
- package/extensions/signal/node_modules/.bin/symi +0 -0
- package/extensions/slack/node_modules/.bin/symi +0 -0
- package/extensions/telegram/node_modules/.bin/symi +0 -0
- package/extensions/tlon/node_modules/.bin/symi +0 -0
- package/extensions/twitch/node_modules/.bin/symi +0 -0
- package/extensions/voice-call/node_modules/.bin/symi +0 -0
- package/extensions/whatsapp/node_modules/.bin/symi +0 -0
- package/extensions/zalo/node_modules/.bin/symi +0 -0
- package/extensions/zalouser/node_modules/.bin/symi +0 -0
- package/package.json +83 -113
- package/skills/nano-banana-pro/scripts/generate_image.py +0 -0
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +0 -0
- package/skills/tmux/scripts/find-sessions.sh +0 -0
- package/skills/tmux/scripts/wait-for-text.sh +0 -0
- package/dist/paths-Cce4PUkG.js +0 -212
- /package/dist/{boolean-B8-BqKGQ.js → boolean-CE7i9tBR.js} +0 -0
- /package/dist/{chat-type-C_KiWNAH.js → chat-type-3FRbbjbq.js} +0 -0
- /package/dist/{diagnostic-session-state-Bxo4UHOL.js → diagnostic-session-state-Zw87xFym.js} +0 -0
- /package/dist/{legacy-names-BHV4AoFT.js → legacy-names-CePMUvus.js} +0 -0
- /package/dist/{pi-model-discovery-DaNAekda.js → pi-model-discovery-Bv5YDJc8.js} +0 -0
- /package/dist/{redact-jSxx6Ep2.js → redact-BDMXB06K.js} +0 -0
- /package/dist/{ssrf-BTMDZjHT.js → ssrf-DpUUUgkK.js} +0 -0
- /package/dist/{targets-CFovdgJI.js → targets-DGkXkFPj.js} +0 -0
- /package/dist/{transcript-events-DDYvbmRV.js → transcript-events-BBh3Gsrx.js} +0 -0
|
@@ -27147,7 +27147,8 @@ const BUILTIN_PROFILES = [
|
|
|
27147
27147
|
"<end_of_turn>"
|
|
27148
27148
|
],
|
|
27149
27149
|
suppressMonologue: true,
|
|
27150
|
-
hasStructuredThinking: false
|
|
27150
|
+
hasStructuredThinking: false,
|
|
27151
|
+
validateToolArgs: true
|
|
27151
27152
|
},
|
|
27152
27153
|
promptAdditions: [
|
|
27153
27154
|
"CRITICAL OUTPUT RULES:",
|
|
@@ -27157,7 +27158,8 @@ const BUILTIN_PROFILES = [
|
|
|
27157
27158
|
"- Do not write verification checklists, self-assessments, or numbered assessment lists after your answer.",
|
|
27158
27159
|
"- Do not write 'Verification:', 'Requirements:', 'Status Check:', or 'Everything is correct'.",
|
|
27159
27160
|
"- If you need to verify your work, do so before writing your response, not after.",
|
|
27160
|
-
"- Send brief progress updates on long tasks so the user knows you are active."
|
|
27161
|
+
"- Send brief progress updates on long tasks so the user knows you are active.",
|
|
27162
|
+
"- When calling tools, provide arguments as clean values only. Never include <|, |>, or XML-like tags in tool argument values. For exec/bash commands, provide only valid shell syntax."
|
|
27161
27163
|
],
|
|
27162
27164
|
ui: {
|
|
27163
27165
|
badge: "Local",
|
|
@@ -27181,7 +27183,8 @@ const BUILTIN_PROFILES = [
|
|
|
27181
27183
|
filters: {
|
|
27182
27184
|
stripPatterns: [],
|
|
27183
27185
|
suppressMonologue: false,
|
|
27184
|
-
hasStructuredThinking: true
|
|
27186
|
+
hasStructuredThinking: true,
|
|
27187
|
+
validateToolArgs: false
|
|
27185
27188
|
},
|
|
27186
27189
|
promptAdditions: [],
|
|
27187
27190
|
ui: {
|
|
@@ -27215,7 +27218,8 @@ const BUILTIN_PROFILES = [
|
|
|
27215
27218
|
"^\\s*<bos>\\s*"
|
|
27216
27219
|
],
|
|
27217
27220
|
suppressMonologue: true,
|
|
27218
|
-
hasStructuredThinking: false
|
|
27221
|
+
hasStructuredThinking: false,
|
|
27222
|
+
validateToolArgs: true
|
|
27219
27223
|
},
|
|
27220
27224
|
promptAdditions: [
|
|
27221
27225
|
"CRITICAL OUTPUT RULES:",
|
|
@@ -27226,7 +27230,8 @@ const BUILTIN_PROFILES = [
|
|
|
27226
27230
|
"- Do not write 'Verification:', 'Requirements:', 'Status Check:', or 'Everything is correct'.",
|
|
27227
27231
|
"- If you need to verify your work, do so before writing your response, not after.",
|
|
27228
27232
|
"- Keep planning and reasoning internal. Only speak when you have a result or need user input.",
|
|
27229
|
-
"- When working on multi-step tasks, send a brief one-line status update so the user knows you are active."
|
|
27233
|
+
"- When working on multi-step tasks, send a brief one-line status update so the user knows you are active.",
|
|
27234
|
+
"- When calling tools, provide arguments as clean values only. Never include <|, |>, or XML-like tags in tool argument values. For exec/bash commands, provide only valid shell syntax."
|
|
27230
27235
|
],
|
|
27231
27236
|
ui: {
|
|
27232
27237
|
badge: "CoreWeave",
|
|
@@ -27254,7 +27259,8 @@ const FALLBACK_PROFILE = {
|
|
|
27254
27259
|
filters: {
|
|
27255
27260
|
stripPatterns: [],
|
|
27256
27261
|
suppressMonologue: false,
|
|
27257
|
-
hasStructuredThinking: false
|
|
27262
|
+
hasStructuredThinking: false,
|
|
27263
|
+
validateToolArgs: false
|
|
27258
27264
|
},
|
|
27259
27265
|
promptAdditions: [],
|
|
27260
27266
|
ui: {
|
|
@@ -27737,6 +27743,19 @@ function stripModelTokensAggressive(text, modelId) {
|
|
|
27737
27743
|
}
|
|
27738
27744
|
return result;
|
|
27739
27745
|
}
|
|
27746
|
+
/**
|
|
27747
|
+
* Clean residual fragments left after aggressive token stripping.
|
|
27748
|
+
* After `<|` and `|>` are removed, orphaned `<`, `"`, `|` can remain
|
|
27749
|
+
* at string boundaries (e.g., `<<|"|uname -a` → `<"uname -a`).
|
|
27750
|
+
*
|
|
27751
|
+
* Conservative: only trims leading junk before what looks like a command,
|
|
27752
|
+
* and trailing junk. Does NOT touch content in the middle of the string.
|
|
27753
|
+
* Preserves heredoc syntax (`<<EOF`, `<<"EOF"`) via negative lookahead.
|
|
27754
|
+
*/
|
|
27755
|
+
function cleanResidualTokenFragments(text) {
|
|
27756
|
+
if (!text) return text;
|
|
27757
|
+
return text.replace(/^[<"|]+(?!<[A-Z_])(?=[a-zA-Z0-9/~$.(])/gm, "").replace(/[<"|]+$/gm, "").trim();
|
|
27758
|
+
}
|
|
27740
27759
|
|
|
27741
27760
|
//#endregion
|
|
27742
27761
|
//#region src/agents/output-normalizer.ts
|
|
@@ -27822,10 +27841,14 @@ function detectRepetition(text, minBlock) {
|
|
|
27822
27841
|
const searchStart = sampleStart + minBlock;
|
|
27823
27842
|
return text.indexOf(sample, searchStart) >= 0;
|
|
27824
27843
|
}
|
|
27844
|
+
function sanitizeStringValue(value, modelId) {
|
|
27845
|
+
const stripped = stripModelTokensAggressive(value, modelId);
|
|
27846
|
+
return isGemmaModel$1(modelId) ? cleanResidualTokenFragments(stripped) : stripped;
|
|
27847
|
+
}
|
|
27825
27848
|
function sanitizeArgs(args, modelId) {
|
|
27826
27849
|
const result = {};
|
|
27827
|
-
for (const [key, value] of Object.entries(args)) if (typeof value === "string") result[key] =
|
|
27828
|
-
else if (Array.isArray(value)) result[key] = value.map((item) => typeof item === "string" ?
|
|
27850
|
+
for (const [key, value] of Object.entries(args)) if (typeof value === "string") result[key] = sanitizeStringValue(value, modelId);
|
|
27851
|
+
else if (Array.isArray(value)) result[key] = value.map((item) => typeof item === "string" ? sanitizeStringValue(item, modelId) : item && typeof item === "object" ? sanitizeArgs(item, modelId) : item);
|
|
27829
27852
|
else if (value && typeof value === "object") result[key] = sanitizeArgs(value, modelId);
|
|
27830
27853
|
else result[key] = value;
|
|
27831
27854
|
return result;
|
|
@@ -29909,7 +29932,7 @@ async function recordLoopOutcome(args) {
|
|
|
29909
29932
|
if (!args.ctx?.sessionKey) return;
|
|
29910
29933
|
try {
|
|
29911
29934
|
const { getDiagnosticSessionState } = await import("./diagnostic-session-state-Wd5tNeQG.js").then((n) => n.n);
|
|
29912
|
-
const { recordToolCallOutcome } = await import("./tool-loop-detection-
|
|
29935
|
+
const { recordToolCallOutcome } = await import("./tool-loop-detection-DU5sTIKg.js");
|
|
29913
29936
|
recordToolCallOutcome(getDiagnosticSessionState({
|
|
29914
29937
|
sessionKey: args.ctx.sessionKey,
|
|
29915
29938
|
sessionId: args.ctx?.agentId
|
|
@@ -29931,7 +29954,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
29931
29954
|
if (args.ctx?.sessionKey) {
|
|
29932
29955
|
const { getDiagnosticSessionState } = await import("./diagnostic-session-state-Wd5tNeQG.js").then((n) => n.n);
|
|
29933
29956
|
const { logToolLoopAction } = await import("./diagnostic-mFf4i4G9.js").then((n) => n.n);
|
|
29934
|
-
const { detectToolCallLoop, recordToolCall } = await import("./tool-loop-detection-
|
|
29957
|
+
const { detectToolCallLoop, recordToolCall } = await import("./tool-loop-detection-DU5sTIKg.js");
|
|
29935
29958
|
const sessionState = getDiagnosticSessionState({
|
|
29936
29959
|
sessionKey: args.ctx.sessionKey,
|
|
29937
29960
|
sessionId: args.ctx?.agentId
|
|
@@ -30202,6 +30225,88 @@ function toClientToolDefinitions(tools, onClientToolCall, hookContext) {
|
|
|
30202
30225
|
});
|
|
30203
30226
|
}
|
|
30204
30227
|
|
|
30228
|
+
//#endregion
|
|
30229
|
+
//#region src/agents/pi-tools.validate.ts
|
|
30230
|
+
/**
|
|
30231
|
+
* Tool argument validation — validates that exec/bash commands contain
|
|
30232
|
+
* valid shell syntax after model token sanitization.
|
|
30233
|
+
*
|
|
30234
|
+
* Gated on ModelProfile.filters.validateToolArgs — only active for
|
|
30235
|
+
* models known to leak control tokens into structured output (Gemma, Ollama).
|
|
30236
|
+
*
|
|
30237
|
+
* @module
|
|
30238
|
+
*/
|
|
30239
|
+
/**
|
|
30240
|
+
* Validate that a command string contains extractable valid shell syntax.
|
|
30241
|
+
* Returns the cleaned command if valid, or an error reason if not.
|
|
30242
|
+
*
|
|
30243
|
+
* Does NOT attempt to parse the full shell grammar — just checks for
|
|
30244
|
+
* obvious corruption (residual control tokens, empty commands).
|
|
30245
|
+
* Preserves heredocs, redirects, pipes, and other legitimate shell syntax.
|
|
30246
|
+
*/
|
|
30247
|
+
function validateShellCommand(command) {
|
|
30248
|
+
if (!command || !command.trim()) return {
|
|
30249
|
+
valid: false,
|
|
30250
|
+
cleaned: "",
|
|
30251
|
+
reason: "empty command"
|
|
30252
|
+
};
|
|
30253
|
+
let cleaned = cleanResidualTokenFragments(command);
|
|
30254
|
+
if (/(?:^|[^<])<\|/.test(cleaned) || /\|>/.test(cleaned)) {
|
|
30255
|
+
cleaned = cleaned.replace(/<\|[^|>]*(?:\|>)?/g, "").trim();
|
|
30256
|
+
cleaned = cleanResidualTokenFragments(cleaned);
|
|
30257
|
+
}
|
|
30258
|
+
if (!cleaned || !cleaned.trim()) return {
|
|
30259
|
+
valid: false,
|
|
30260
|
+
cleaned: "",
|
|
30261
|
+
reason: "command is empty after removing control tokens"
|
|
30262
|
+
};
|
|
30263
|
+
if (!/[a-zA-Z0-9_/.~-]/.test(cleaned)) return {
|
|
30264
|
+
valid: false,
|
|
30265
|
+
cleaned,
|
|
30266
|
+
reason: "no recognizable shell command found"
|
|
30267
|
+
};
|
|
30268
|
+
return {
|
|
30269
|
+
valid: true,
|
|
30270
|
+
cleaned: cleaned.trim()
|
|
30271
|
+
};
|
|
30272
|
+
}
|
|
30273
|
+
|
|
30274
|
+
//#endregion
|
|
30275
|
+
//#region src/agents/pi-tools.validate-wrapper.ts
|
|
30276
|
+
const EXEC_TOOL_NAMES = new Set(["exec", "bash"]);
|
|
30277
|
+
/**
|
|
30278
|
+
* Wrap tools with argument validation. Only exec/bash tools are validated.
|
|
30279
|
+
* Other tools pass through unchanged.
|
|
30280
|
+
*
|
|
30281
|
+
* Call this AFTER tools are created and the model profile is resolved.
|
|
30282
|
+
*/
|
|
30283
|
+
function wrapToolsWithArgValidation(tools, profile) {
|
|
30284
|
+
if (!profile.filters?.validateToolArgs) return tools;
|
|
30285
|
+
return tools.map((tool) => wrapToolWithArgValidation(tool));
|
|
30286
|
+
}
|
|
30287
|
+
/**
|
|
30288
|
+
* Wrap a single tool with argument validation for exec/bash commands.
|
|
30289
|
+
*/
|
|
30290
|
+
function wrapToolWithArgValidation(tool) {
|
|
30291
|
+
const toolName = (tool.name ?? "").toLowerCase().trim();
|
|
30292
|
+
if (!EXEC_TOOL_NAMES.has(toolName)) return tool;
|
|
30293
|
+
const originalExecute = tool.execute;
|
|
30294
|
+
return {
|
|
30295
|
+
...tool,
|
|
30296
|
+
execute(toolCallId, params, ...rest) {
|
|
30297
|
+
const command = params.command ?? params.cmd;
|
|
30298
|
+
if (typeof command !== "string") return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
30299
|
+
const result = validateShellCommand(command);
|
|
30300
|
+
if (!result.valid) return Promise.resolve({ output: `Error: ${result.reason}. The command appears to contain model control tokens. Please provide a clean shell command without any <|, |>, or XML-like tags. Only valid shell syntax is accepted.` });
|
|
30301
|
+
if (result.cleaned !== command) return originalExecute.call(tool, toolCallId, {
|
|
30302
|
+
...params,
|
|
30303
|
+
command: result.cleaned
|
|
30304
|
+
}, ...rest);
|
|
30305
|
+
return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
30306
|
+
}
|
|
30307
|
+
};
|
|
30308
|
+
}
|
|
30309
|
+
|
|
30205
30310
|
//#endregion
|
|
30206
30311
|
//#region src/agents/plan-mode.ts
|
|
30207
30312
|
/**
|
|
@@ -34281,10 +34386,11 @@ async function runEmbeddedAttempt(params) {
|
|
|
34281
34386
|
await resourceLoader.reload();
|
|
34282
34387
|
}
|
|
34283
34388
|
const hookRunner = getGlobalHookRunner();
|
|
34284
|
-
const { builtInTools, customTools } = splitSdkTools({
|
|
34389
|
+
const { builtInTools: rawBuiltInTools, customTools } = splitSdkTools({
|
|
34285
34390
|
tools,
|
|
34286
34391
|
sandboxEnabled: !!sandbox?.enabled
|
|
34287
34392
|
});
|
|
34393
|
+
const builtInTools = wrapToolsWithArgValidation(rawBuiltInTools, modelProfile);
|
|
34288
34394
|
let clientToolCallDetected = null;
|
|
34289
34395
|
const clientToolLoopDetection = resolveToolLoopDetectionConfig({
|
|
34290
34396
|
cfg: params.config,
|
|
@@ -35832,7 +35938,8 @@ async function runAgentTurn(params) {
|
|
|
35832
35938
|
const cb = params.callbacks;
|
|
35833
35939
|
const sessionFile = resolveSessionFilePath(params.sessionId, void 0, { agentId });
|
|
35834
35940
|
const profile = resolveModelProfile(params.provider && params.modelId ? `${params.provider}/${params.modelId}` : params.config.agents?.defaults?.model?.primary ?? "", params.config.models?.profiles);
|
|
35835
|
-
const
|
|
35941
|
+
const toolsUsed = [];
|
|
35942
|
+
const buildInternalParams = (providerOverride, modelOverride) => ({
|
|
35836
35943
|
sessionId: params.sessionId,
|
|
35837
35944
|
sessionKey: params.sessionKey,
|
|
35838
35945
|
agentId,
|
|
@@ -35847,14 +35954,28 @@ async function runAgentTurn(params) {
|
|
|
35847
35954
|
extraSystemPrompt: params.extraSystemPrompt,
|
|
35848
35955
|
clientTools: params.clientTools,
|
|
35849
35956
|
disableTools: params.disableTools,
|
|
35850
|
-
provider: params.provider,
|
|
35851
|
-
model: params.modelId,
|
|
35957
|
+
provider: providerOverride ?? params.provider,
|
|
35958
|
+
model: modelOverride ?? params.modelId,
|
|
35852
35959
|
authProfileId: params.authProfileId,
|
|
35853
35960
|
authProfileIdSource: params.authProfileIdSource,
|
|
35854
35961
|
thinkLevel: params.thinkLevel,
|
|
35855
35962
|
reasoningLevel: params.reasoningLevel,
|
|
35856
35963
|
timeoutMs: params.timeoutMs,
|
|
35857
35964
|
abortSignal: params.abortSignal,
|
|
35965
|
+
lane: params.lane,
|
|
35966
|
+
toolResultFormat: params.toolResultFormat,
|
|
35967
|
+
verboseLevel: params.verboseLevel,
|
|
35968
|
+
ownerNumbers: params.ownerNumbers,
|
|
35969
|
+
enforceFinalTag: params.enforceFinalTag,
|
|
35970
|
+
execOverrides: params.execOverrides,
|
|
35971
|
+
bashElevated: params.bashElevated,
|
|
35972
|
+
suppressToolErrorWarnings: params.suppressToolErrorWarnings,
|
|
35973
|
+
streamParams: params.streamParams,
|
|
35974
|
+
blockReplyBreak: params.blockReplyBreak,
|
|
35975
|
+
blockReplyChunking: params.blockReplyChunking,
|
|
35976
|
+
requireExplicitMessageTarget: params.requireExplicitMessageTarget,
|
|
35977
|
+
disableMessageTool: params.disableMessageTool,
|
|
35978
|
+
symipulseMs: params.symipulseMs,
|
|
35858
35979
|
messageChannel: ch?.messageChannel,
|
|
35859
35980
|
messageProvider: ch?.messageProvider,
|
|
35860
35981
|
agentAccountId: ch?.agentAccountId,
|
|
@@ -35876,26 +35997,92 @@ async function runAgentTurn(params) {
|
|
|
35876
35997
|
onPartialReply: cb?.onDelta ? (payload) => {
|
|
35877
35998
|
if (payload.text) cb.onDelta(payload.text);
|
|
35878
35999
|
} : void 0,
|
|
36000
|
+
onAssistantMessageStart: cb?.onTypingStart ? () => {
|
|
36001
|
+
cb.onTypingStart();
|
|
36002
|
+
cb?.onLifecycle?.("streaming");
|
|
36003
|
+
} : cb?.onLifecycle ? () => {
|
|
36004
|
+
cb.onLifecycle("streaming");
|
|
36005
|
+
} : void 0,
|
|
35879
36006
|
onToolResult: cb?.onToolResult ? (payload) => {
|
|
35880
36007
|
if (payload.text) cb.onToolResult("tool", payload.text);
|
|
35881
36008
|
} : void 0,
|
|
35882
36009
|
onReasoningStream: cb?.onThinking ? (payload) => {
|
|
35883
36010
|
if (payload.text) cb.onThinking(payload.text);
|
|
35884
36011
|
} : void 0,
|
|
35885
|
-
|
|
36012
|
+
onBlockReply: cb?.onBlockReply ? (payload) => {
|
|
36013
|
+
cb.onBlockReply({
|
|
36014
|
+
...payload,
|
|
36015
|
+
isFinal: false
|
|
36016
|
+
});
|
|
36017
|
+
} : void 0,
|
|
36018
|
+
onBlockReplyFlush: cb?.onBlockReplyFlush,
|
|
36019
|
+
onAgentEvent: (evt) => {
|
|
36020
|
+
cb?.onAgentEvent?.(evt);
|
|
36021
|
+
const stream = evt.stream;
|
|
36022
|
+
const data = evt.data;
|
|
36023
|
+
const phase = typeof data?.phase === "string" ? data.phase : "";
|
|
36024
|
+
if (stream === "lifecycle") {
|
|
36025
|
+
if (phase === "start") {
|
|
36026
|
+
cb?.onLifecycle?.("start");
|
|
36027
|
+
cb?.onTypingStart?.();
|
|
36028
|
+
} else if (phase === "end") cb?.onTypingStop?.();
|
|
36029
|
+
else if (phase === "error") {
|
|
36030
|
+
cb?.onLifecycle?.("error");
|
|
36031
|
+
cb?.onTypingStop?.();
|
|
36032
|
+
if (cb?.onError && typeof data?.error === "string") cb.onError(new Error(data.error));
|
|
36033
|
+
}
|
|
36034
|
+
}
|
|
36035
|
+
if (stream === "tool") {
|
|
36036
|
+
const toolName = typeof data?.name === "string" ? data.name : "";
|
|
36037
|
+
if (phase === "start" && toolName) {
|
|
36038
|
+
toolsUsed.push(toolName);
|
|
36039
|
+
cb?.onToolStart?.(toolName, data?.args ?? {});
|
|
36040
|
+
cb?.onTypingStart?.();
|
|
36041
|
+
}
|
|
36042
|
+
}
|
|
36043
|
+
if (stream === "compaction" && phase === "end") cb?.onCompaction?.({
|
|
36044
|
+
tokensBefore: typeof data?.tokensBefore === "number" ? data.tokensBefore : 0,
|
|
36045
|
+
tokensAfter: typeof data?.tokensAfter === "number" ? data.tokensAfter : 0
|
|
36046
|
+
});
|
|
36047
|
+
}
|
|
35886
36048
|
});
|
|
36049
|
+
let result;
|
|
36050
|
+
let fallbackProvider;
|
|
36051
|
+
let fallbackModel;
|
|
36052
|
+
const TRANSIENT_RETRY_DELAY_MS = 2500;
|
|
36053
|
+
const maxAttempts = params.retryOnTransientError ? 2 : 1;
|
|
36054
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) try {
|
|
36055
|
+
if (params.fallbackModels?.length) {
|
|
36056
|
+
const fallbackResult = await runWithModelFallback({
|
|
36057
|
+
cfg: params.config,
|
|
36058
|
+
provider: params.provider ?? "",
|
|
36059
|
+
model: params.modelId ?? "",
|
|
36060
|
+
agentDir,
|
|
36061
|
+
fallbacksOverride: params.fallbackModels,
|
|
36062
|
+
run: (provider, model) => runEmbeddedPiAgent(buildInternalParams(provider, model)),
|
|
36063
|
+
onError: async (fallbackAttempt) => {
|
|
36064
|
+
const fromModel = `${fallbackAttempt.provider}/${fallbackAttempt.model}`;
|
|
36065
|
+
cb?.onFallback?.(fromModel, "(next)", String(fallbackAttempt.error));
|
|
36066
|
+
}
|
|
36067
|
+
});
|
|
36068
|
+
result = fallbackResult.result;
|
|
36069
|
+
fallbackProvider = fallbackResult.provider;
|
|
36070
|
+
fallbackModel = fallbackResult.model;
|
|
36071
|
+
} else result = await runEmbeddedPiAgent(buildInternalParams());
|
|
36072
|
+
break;
|
|
36073
|
+
} catch (err) {
|
|
36074
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
36075
|
+
if (params.retryOnTransientError && attempt < maxAttempts - 1 && isTransientHttpError(errMsg)) {
|
|
36076
|
+
await new Promise((resolve) => setTimeout(resolve, TRANSIENT_RETRY_DELAY_MS));
|
|
36077
|
+
continue;
|
|
36078
|
+
}
|
|
36079
|
+
throw err;
|
|
36080
|
+
}
|
|
36081
|
+
result = result;
|
|
35887
36082
|
const responseText = (result.payloads ?? []).filter((p) => p.text && !p.isError).map((p) => p.text).join("\n").trim();
|
|
35888
|
-
const resolvedProvider = result.meta.agentMeta?.provider ?? params.provider ?? "";
|
|
35889
|
-
const resolvedModel = result.meta.agentMeta?.model ?? params.modelId ?? "";
|
|
35890
|
-
|
|
35891
|
-
provider: resolvedProvider,
|
|
35892
|
-
modelId: resolvedModel,
|
|
35893
|
-
tokenCount: result.meta.agentMeta?.usage?.total ?? 0,
|
|
35894
|
-
durationMs: Date.now() - startTime,
|
|
35895
|
-
toolsUsed: []
|
|
35896
|
-
});
|
|
35897
|
-
if (cb?.onLifecycle) await cb.onLifecycle(result.meta.error ? "error" : "end");
|
|
35898
|
-
return {
|
|
36083
|
+
const resolvedProvider = fallbackProvider ?? result.meta.agentMeta?.provider ?? params.provider ?? "";
|
|
36084
|
+
const resolvedModel = fallbackModel ?? result.meta.agentMeta?.model ?? params.modelId ?? "";
|
|
36085
|
+
const turnResult = {
|
|
35899
36086
|
text: responseText,
|
|
35900
36087
|
durationMs: Date.now() - startTime,
|
|
35901
36088
|
provider: resolvedProvider,
|
|
@@ -35904,6 +36091,23 @@ async function runAgentTurn(params) {
|
|
|
35904
36091
|
didSendViaMessagingTool: result.didSendViaMessagingTool ?? false,
|
|
35905
36092
|
rawResult: result
|
|
35906
36093
|
};
|
|
36094
|
+
if (params.postRunHooks?.length) {
|
|
36095
|
+
for (const hook of params.postRunHooks) if (hook.shouldRun(turnResult)) try {
|
|
36096
|
+
await hook.execute(turnResult, params);
|
|
36097
|
+
} catch (hookErr) {
|
|
36098
|
+
if (cb?.onError && hookErr instanceof Error) cb.onError(hookErr);
|
|
36099
|
+
}
|
|
36100
|
+
turnResult.durationMs = Date.now() - startTime;
|
|
36101
|
+
}
|
|
36102
|
+
if (cb?.onFinal) await cb.onFinal(responseText, {
|
|
36103
|
+
provider: resolvedProvider,
|
|
36104
|
+
modelId: resolvedModel,
|
|
36105
|
+
tokenCount: result.meta.agentMeta?.usage?.total ?? 0,
|
|
36106
|
+
durationMs: turnResult.durationMs,
|
|
36107
|
+
toolsUsed
|
|
36108
|
+
});
|
|
36109
|
+
if (cb?.onLifecycle) await cb.onLifecycle(result.meta.error ? "error" : "end");
|
|
36110
|
+
return turnResult;
|
|
35907
36111
|
}
|
|
35908
36112
|
|
|
35909
36113
|
//#endregion
|
|
@@ -35911,7 +36115,7 @@ async function runAgentTurn(params) {
|
|
|
35911
36115
|
function createDefaultDeps() {
|
|
35912
36116
|
return {
|
|
35913
36117
|
sendMessageWhatsApp: async (...args) => {
|
|
35914
|
-
const { sendMessageWhatsApp } = await import("./web-
|
|
36118
|
+
const { sendMessageWhatsApp } = await import("./web-DaTTL9M0.js");
|
|
35915
36119
|
return await sendMessageWhatsApp(...args);
|
|
35916
36120
|
},
|
|
35917
36121
|
sendMessageTelegram: async (...args) => {
|
|
@@ -53349,7 +53553,7 @@ function loadWebLoginQr() {
|
|
|
53349
53553
|
return webLoginQrPromise;
|
|
53350
53554
|
}
|
|
53351
53555
|
function loadWebChannel() {
|
|
53352
|
-
webChannelPromise ??= import("./web-
|
|
53556
|
+
webChannelPromise ??= import("./web-DaTTL9M0.js");
|
|
53353
53557
|
return webChannelPromise;
|
|
53354
53558
|
}
|
|
53355
53559
|
function loadWhatsAppActions() {
|
|
@@ -75711,7 +75915,6 @@ function createBlockReplyDeliveryHandler(params) {
|
|
|
75711
75915
|
//#endregion
|
|
75712
75916
|
//#region src/auto-reply/reply/agent-runner-execution.ts
|
|
75713
75917
|
async function runAgentTurnWithFallback(params) {
|
|
75714
|
-
const TRANSIENT_HTTP_RETRY_DELAY_MS = 2500;
|
|
75715
75918
|
let didLogHeartbeatStrip = false;
|
|
75716
75919
|
let autoCompactionCompleted = false;
|
|
75717
75920
|
const directlySentBlockKeys = /* @__PURE__ */ new Set();
|
|
@@ -75732,199 +75935,216 @@ async function runAgentTurnWithFallback(params) {
|
|
|
75732
75935
|
let fallbackModel = params.followupRun.run.model;
|
|
75733
75936
|
let fallbackAttempts = [];
|
|
75734
75937
|
let didResetAfterCompactionFailure = false;
|
|
75735
|
-
|
|
75736
|
-
|
|
75737
|
-
|
|
75738
|
-
|
|
75739
|
-
if (
|
|
75740
|
-
|
|
75741
|
-
|
|
75742
|
-
didLogHeartbeatStrip = true;
|
|
75743
|
-
logVerbose("Stripped stray SYMIPULSE_OK token from reply");
|
|
75744
|
-
}
|
|
75745
|
-
if (stripped.shouldSkip && (payload.mediaUrls?.length ?? 0) === 0) return { skip: true };
|
|
75746
|
-
text = stripped.text;
|
|
75747
|
-
}
|
|
75748
|
-
if (isSilentReplyText(text, SILENT_REPLY_TOKEN)) return { skip: true };
|
|
75749
|
-
if (!text) {
|
|
75750
|
-
if ((payload.mediaUrls?.length ?? 0) > 0) return {
|
|
75751
|
-
text: void 0,
|
|
75752
|
-
skip: false
|
|
75753
|
-
};
|
|
75754
|
-
return { skip: true };
|
|
75938
|
+
const normalizeStreamingText = (payload) => {
|
|
75939
|
+
let text = payload.text;
|
|
75940
|
+
if (!params.isHeartbeat && text?.includes("SYMIPULSE_OK")) {
|
|
75941
|
+
const stripped = stripHeartbeatToken(text, { mode: "message" });
|
|
75942
|
+
if (stripped.didStrip && !didLogHeartbeatStrip) {
|
|
75943
|
+
didLogHeartbeatStrip = true;
|
|
75944
|
+
logVerbose("Stripped stray SYMIPULSE_OK token from reply");
|
|
75755
75945
|
}
|
|
75756
|
-
|
|
75757
|
-
|
|
75758
|
-
|
|
75759
|
-
|
|
75946
|
+
if (stripped.shouldSkip && (payload.mediaUrls?.length ?? 0) === 0) return { skip: true };
|
|
75947
|
+
text = stripped.text;
|
|
75948
|
+
}
|
|
75949
|
+
if (isSilentReplyText(text, SILENT_REPLY_TOKEN)) return { skip: true };
|
|
75950
|
+
if (!text) {
|
|
75951
|
+
if ((payload.mediaUrls?.length ?? 0) > 0) return {
|
|
75952
|
+
text: void 0,
|
|
75760
75953
|
skip: false
|
|
75761
75954
|
};
|
|
75955
|
+
return { skip: true };
|
|
75956
|
+
}
|
|
75957
|
+
const sanitized = sanitizeUserFacingText(text, { errorContext: Boolean(payload.isError) });
|
|
75958
|
+
if (!sanitized.trim()) return { skip: true };
|
|
75959
|
+
return {
|
|
75960
|
+
text: sanitized,
|
|
75961
|
+
skip: false
|
|
75762
75962
|
};
|
|
75763
|
-
|
|
75764
|
-
|
|
75765
|
-
|
|
75766
|
-
|
|
75963
|
+
};
|
|
75964
|
+
const blockReplyPipeline = params.blockReplyPipeline;
|
|
75965
|
+
const onToolResult = params.opts?.onToolResult;
|
|
75966
|
+
let toolResultChain = Promise.resolve();
|
|
75967
|
+
const serializedOnToolResult = onToolResult ? (name, resultText) => {
|
|
75968
|
+
toolResultChain = toolResultChain.then(async () => {
|
|
75969
|
+
const { text, skip } = normalizeStreamingText({ text: resultText });
|
|
75970
|
+
if (skip) return;
|
|
75767
75971
|
await params.typingSignals.signalTextDelta(text);
|
|
75768
|
-
|
|
75769
|
-
|
|
75770
|
-
|
|
75771
|
-
|
|
75772
|
-
|
|
75773
|
-
|
|
75774
|
-
|
|
75775
|
-
|
|
75776
|
-
|
|
75777
|
-
|
|
75778
|
-
|
|
75779
|
-
|
|
75780
|
-
|
|
75781
|
-
|
|
75782
|
-
|
|
75783
|
-
|
|
75784
|
-
|
|
75785
|
-
|
|
75786
|
-
|
|
75787
|
-
|
|
75788
|
-
|
|
75789
|
-
|
|
75790
|
-
|
|
75791
|
-
|
|
75792
|
-
|
|
75793
|
-
let lifecycleTerminalEmitted = false;
|
|
75794
|
-
try {
|
|
75795
|
-
const result = await runCliAgent({
|
|
75796
|
-
sessionId: params.followupRun.run.sessionId,
|
|
75797
|
-
sessionKey: params.sessionKey,
|
|
75798
|
-
agentId: params.followupRun.run.agentId,
|
|
75799
|
-
sessionFile: params.followupRun.run.sessionFile,
|
|
75800
|
-
workspaceDir: params.followupRun.run.workspaceDir,
|
|
75801
|
-
config: params.followupRun.run.config,
|
|
75802
|
-
prompt: params.commandBody,
|
|
75803
|
-
provider,
|
|
75804
|
-
model,
|
|
75805
|
-
thinkLevel: params.followupRun.run.thinkLevel,
|
|
75806
|
-
timeoutMs: params.followupRun.run.timeoutMs,
|
|
75807
|
-
runId,
|
|
75808
|
-
extraSystemPrompt: params.followupRun.run.extraSystemPrompt,
|
|
75809
|
-
ownerNumbers: params.followupRun.run.ownerNumbers,
|
|
75810
|
-
cliSessionId,
|
|
75811
|
-
images: params.opts?.images
|
|
75812
|
-
});
|
|
75813
|
-
const cliText = result.payloads?.[0]?.text?.trim();
|
|
75814
|
-
if (cliText) emitAgentEvent({
|
|
75815
|
-
runId,
|
|
75816
|
-
stream: "assistant",
|
|
75817
|
-
data: { text: cliText }
|
|
75818
|
-
});
|
|
75819
|
-
emitAgentEvent({
|
|
75820
|
-
runId,
|
|
75821
|
-
stream: "lifecycle",
|
|
75822
|
-
data: {
|
|
75823
|
-
phase: "end",
|
|
75824
|
-
startedAt,
|
|
75825
|
-
endedAt: Date.now()
|
|
75826
|
-
}
|
|
75827
|
-
});
|
|
75828
|
-
lifecycleTerminalEmitted = true;
|
|
75829
|
-
return result;
|
|
75830
|
-
} catch (err) {
|
|
75831
|
-
emitAgentEvent({
|
|
75832
|
-
runId,
|
|
75833
|
-
stream: "lifecycle",
|
|
75834
|
-
data: {
|
|
75835
|
-
phase: "error",
|
|
75836
|
-
startedAt,
|
|
75837
|
-
endedAt: Date.now(),
|
|
75838
|
-
error: String(err)
|
|
75839
|
-
}
|
|
75840
|
-
});
|
|
75841
|
-
lifecycleTerminalEmitted = true;
|
|
75842
|
-
throw err;
|
|
75843
|
-
} finally {
|
|
75844
|
-
if (!lifecycleTerminalEmitted) emitAgentEvent({
|
|
75845
|
-
runId,
|
|
75846
|
-
stream: "lifecycle",
|
|
75847
|
-
data: {
|
|
75848
|
-
phase: "error",
|
|
75849
|
-
startedAt,
|
|
75850
|
-
endedAt: Date.now(),
|
|
75851
|
-
error: "CLI run completed without lifecycle terminal event"
|
|
75852
|
-
}
|
|
75853
|
-
});
|
|
75854
|
-
}
|
|
75855
|
-
})();
|
|
75972
|
+
await onToolResult({
|
|
75973
|
+
text,
|
|
75974
|
+
mediaUrls: void 0
|
|
75975
|
+
});
|
|
75976
|
+
}).catch((err) => {
|
|
75977
|
+
logVerbose(`tool result delivery failed: ${String(err)}`);
|
|
75978
|
+
});
|
|
75979
|
+
const task = toolResultChain.finally(() => {
|
|
75980
|
+
params.pendingToolTasks.delete(task);
|
|
75981
|
+
});
|
|
75982
|
+
params.pendingToolTasks.add(task);
|
|
75983
|
+
} : void 0;
|
|
75984
|
+
while (true) try {
|
|
75985
|
+
const run = params.followupRun.run;
|
|
75986
|
+
const resolvedProvider = run.provider;
|
|
75987
|
+
const resolvedModel = run.model;
|
|
75988
|
+
if (isCliProvider(resolvedProvider, run.config)) {
|
|
75989
|
+
const startedAt = Date.now();
|
|
75990
|
+
notifyAgentRunStart();
|
|
75991
|
+
emitAgentEvent({
|
|
75992
|
+
runId,
|
|
75993
|
+
stream: "lifecycle",
|
|
75994
|
+
data: {
|
|
75995
|
+
phase: "start",
|
|
75996
|
+
startedAt
|
|
75856
75997
|
}
|
|
75857
|
-
|
|
75858
|
-
|
|
75859
|
-
|
|
75860
|
-
|
|
75861
|
-
|
|
75998
|
+
});
|
|
75999
|
+
const cliSessionId = getCliSessionId(params.getActiveSessionEntry(), resolvedProvider);
|
|
76000
|
+
let lifecycleTerminalEmitted = false;
|
|
76001
|
+
try {
|
|
76002
|
+
const cliResult = await runCliAgent({
|
|
76003
|
+
sessionId: run.sessionId,
|
|
76004
|
+
sessionKey: params.sessionKey,
|
|
76005
|
+
agentId: run.agentId,
|
|
76006
|
+
sessionFile: run.sessionFile,
|
|
76007
|
+
workspaceDir: run.workspaceDir,
|
|
76008
|
+
config: run.config,
|
|
76009
|
+
prompt: params.commandBody,
|
|
76010
|
+
provider: resolvedProvider,
|
|
76011
|
+
model: resolvedModel,
|
|
76012
|
+
thinkLevel: run.thinkLevel,
|
|
76013
|
+
timeoutMs: run.timeoutMs,
|
|
76014
|
+
runId,
|
|
76015
|
+
extraSystemPrompt: run.extraSystemPrompt,
|
|
76016
|
+
ownerNumbers: run.ownerNumbers,
|
|
76017
|
+
cliSessionId,
|
|
76018
|
+
images: params.opts?.images
|
|
75862
76019
|
});
|
|
75863
|
-
const
|
|
75864
|
-
|
|
75865
|
-
provider,
|
|
75866
|
-
model,
|
|
76020
|
+
const cliText = cliResult.payloads?.[0]?.text?.trim();
|
|
76021
|
+
if (cliText) emitAgentEvent({
|
|
75867
76022
|
runId,
|
|
75868
|
-
|
|
76023
|
+
stream: "assistant",
|
|
76024
|
+
data: { text: cliText }
|
|
75869
76025
|
});
|
|
75870
|
-
|
|
75871
|
-
|
|
75872
|
-
|
|
75873
|
-
|
|
75874
|
-
|
|
75875
|
-
|
|
75876
|
-
|
|
75877
|
-
|
|
75878
|
-
|
|
75879
|
-
|
|
75880
|
-
|
|
75881
|
-
|
|
75882
|
-
|
|
75883
|
-
|
|
75884
|
-
|
|
75885
|
-
|
|
75886
|
-
|
|
75887
|
-
|
|
75888
|
-
|
|
75889
|
-
|
|
75890
|
-
|
|
75891
|
-
|
|
75892
|
-
|
|
75893
|
-
|
|
75894
|
-
|
|
75895
|
-
|
|
75896
|
-
|
|
75897
|
-
|
|
75898
|
-
|
|
75899
|
-
|
|
75900
|
-
|
|
75901
|
-
|
|
75902
|
-
|
|
75903
|
-
|
|
75904
|
-
|
|
75905
|
-
|
|
75906
|
-
|
|
75907
|
-
|
|
75908
|
-
|
|
75909
|
-
|
|
75910
|
-
|
|
75911
|
-
|
|
75912
|
-
|
|
75913
|
-
|
|
75914
|
-
|
|
75915
|
-
|
|
75916
|
-
|
|
75917
|
-
|
|
75918
|
-
|
|
75919
|
-
|
|
75920
|
-
|
|
75921
|
-
|
|
75922
|
-
|
|
75923
|
-
|
|
75924
|
-
|
|
75925
|
-
|
|
75926
|
-
|
|
75927
|
-
|
|
76026
|
+
emitAgentEvent({
|
|
76027
|
+
runId,
|
|
76028
|
+
stream: "lifecycle",
|
|
76029
|
+
data: {
|
|
76030
|
+
phase: "end",
|
|
76031
|
+
startedAt,
|
|
76032
|
+
endedAt: Date.now()
|
|
76033
|
+
}
|
|
76034
|
+
});
|
|
76035
|
+
lifecycleTerminalEmitted = true;
|
|
76036
|
+
runResult = cliResult;
|
|
76037
|
+
break;
|
|
76038
|
+
} catch (err) {
|
|
76039
|
+
emitAgentEvent({
|
|
76040
|
+
runId,
|
|
76041
|
+
stream: "lifecycle",
|
|
76042
|
+
data: {
|
|
76043
|
+
phase: "error",
|
|
76044
|
+
startedAt,
|
|
76045
|
+
endedAt: Date.now(),
|
|
76046
|
+
error: String(err)
|
|
76047
|
+
}
|
|
76048
|
+
});
|
|
76049
|
+
lifecycleTerminalEmitted = true;
|
|
76050
|
+
throw err;
|
|
76051
|
+
} finally {
|
|
76052
|
+
if (!lifecycleTerminalEmitted) emitAgentEvent({
|
|
76053
|
+
runId,
|
|
76054
|
+
stream: "lifecycle",
|
|
76055
|
+
data: {
|
|
76056
|
+
phase: "error",
|
|
76057
|
+
startedAt,
|
|
76058
|
+
endedAt: Date.now(),
|
|
76059
|
+
error: "CLI run completed without lifecycle terminal event"
|
|
76060
|
+
}
|
|
76061
|
+
});
|
|
76062
|
+
}
|
|
76063
|
+
}
|
|
76064
|
+
params.opts?.onModelSelected?.({
|
|
76065
|
+
provider: resolvedProvider,
|
|
76066
|
+
model: resolvedModel,
|
|
76067
|
+
thinkLevel: run.thinkLevel
|
|
76068
|
+
});
|
|
76069
|
+
const toolResultFormat = (() => {
|
|
76070
|
+
const channel = resolveMessageChannel(params.sessionCtx.Surface, params.sessionCtx.Provider);
|
|
76071
|
+
return !channel || isMarkdownCapableMessageChannel(channel) ? "markdown" : "plain";
|
|
76072
|
+
})();
|
|
76073
|
+
const turnResult = await runAgentTurn({
|
|
76074
|
+
sessionId: run.sessionId,
|
|
76075
|
+
sessionKey: params.sessionKey ?? run.sessionKey ?? run.sessionId,
|
|
76076
|
+
agentId: run.agentId,
|
|
76077
|
+
workspaceDir: run.workspaceDir,
|
|
76078
|
+
agentDir: run.agentDir,
|
|
76079
|
+
config: run.config,
|
|
76080
|
+
skillsSnapshot: run.skillsSnapshot,
|
|
76081
|
+
prompt: params.commandBody,
|
|
76082
|
+
extraSystemPrompt: run.extraSystemPrompt,
|
|
76083
|
+
images: params.opts?.images,
|
|
76084
|
+
provider: resolvedProvider,
|
|
76085
|
+
modelId: resolvedModel,
|
|
76086
|
+
authProfileId: run.authProfileId,
|
|
76087
|
+
authProfileIdSource: run.authProfileIdSource,
|
|
76088
|
+
thinkLevel: run.thinkLevel,
|
|
76089
|
+
verboseLevel: run.verboseLevel,
|
|
76090
|
+
reasoningLevel: run.reasoningLevel,
|
|
76091
|
+
timeoutMs: run.timeoutMs,
|
|
76092
|
+
runId,
|
|
76093
|
+
abortSignal: params.opts?.abortSignal,
|
|
76094
|
+
toolResultFormat,
|
|
76095
|
+
ownerNumbers: run.ownerNumbers,
|
|
76096
|
+
enforceFinalTag: run.enforceFinalTag,
|
|
76097
|
+
execOverrides: run.execOverrides,
|
|
76098
|
+
bashElevated: run.bashElevated,
|
|
76099
|
+
suppressToolErrorWarnings: params.opts?.suppressToolErrorWarnings,
|
|
76100
|
+
blockReplyBreak: params.resolvedBlockStreamingBreak,
|
|
76101
|
+
blockReplyChunking: params.blockReplyChunking,
|
|
76102
|
+
retryOnTransientError: true,
|
|
76103
|
+
fallbackModels: resolveModelFallbackOptions(run).fallbacksOverride,
|
|
76104
|
+
channel: {
|
|
76105
|
+
messageChannel: resolveMessageChannel(params.sessionCtx.Surface, params.sessionCtx.Provider) ?? void 0,
|
|
76106
|
+
messageProvider: params.sessionCtx.Provider?.trim().toLowerCase() || void 0,
|
|
76107
|
+
agentAccountId: params.sessionCtx.AccountId,
|
|
76108
|
+
messageTo: params.sessionCtx.OriginatingTo ?? params.sessionCtx.To,
|
|
76109
|
+
messageThreadId: params.sessionCtx.MessageThreadId ?? void 0,
|
|
76110
|
+
groupId: resolveGroupSessionKey(params.sessionCtx)?.id,
|
|
76111
|
+
groupChannel: params.sessionCtx.GroupChannel?.trim() ?? params.sessionCtx.GroupSubject?.trim(),
|
|
76112
|
+
groupSpace: params.sessionCtx.GroupSpace?.trim() ?? void 0,
|
|
76113
|
+
senderId: params.sessionCtx.SenderId?.trim() || void 0,
|
|
76114
|
+
senderName: params.sessionCtx.SenderName?.trim() || void 0,
|
|
76115
|
+
senderUsername: params.sessionCtx.SenderUsername?.trim() || void 0,
|
|
76116
|
+
senderE164: params.sessionCtx.SenderE164?.trim() || void 0,
|
|
76117
|
+
senderIsOwner: run.senderIsOwner,
|
|
76118
|
+
currentChannelId: params.sessionCtx.CurrentChannelId,
|
|
76119
|
+
currentThreadTs: params.sessionCtx.CurrentThreadTs,
|
|
76120
|
+
hasRepliedRef: params.opts?.hasRepliedRef
|
|
76121
|
+
},
|
|
76122
|
+
callbacks: {
|
|
76123
|
+
onDelta: async (text) => {
|
|
76124
|
+
if (isSilentReplyPrefixText(text, SILENT_REPLY_TOKEN)) return;
|
|
76125
|
+
const { text: normalized, skip } = normalizeStreamingText({ text });
|
|
76126
|
+
if (skip || !normalized) return;
|
|
76127
|
+
await params.typingSignals.signalTextDelta(normalized);
|
|
76128
|
+
await params.opts?.onPartialReply?.({ text: normalized });
|
|
76129
|
+
},
|
|
76130
|
+
onToolStart: async (name) => {
|
|
76131
|
+
notifyAgentRunStart();
|
|
76132
|
+
await params.typingSignals.signalToolStart();
|
|
76133
|
+
await params.opts?.onToolStart?.({
|
|
76134
|
+
name,
|
|
76135
|
+
phase: "start"
|
|
76136
|
+
});
|
|
76137
|
+
},
|
|
76138
|
+
onToolResult: serializedOnToolResult,
|
|
76139
|
+
onThinking: params.typingSignals.shouldStartOnReasoning || params.opts?.onReasoningStream ? async (text) => {
|
|
76140
|
+
await params.typingSignals.signalReasoningDelta();
|
|
76141
|
+
await params.opts?.onReasoningStream?.({ text });
|
|
76142
|
+
} : void 0,
|
|
76143
|
+
onLifecycle: async (phase) => {
|
|
76144
|
+
if (phase === "start" || phase === "streaming") notifyAgentRunStart();
|
|
76145
|
+
},
|
|
76146
|
+
onBlockReply: params.opts?.onBlockReply ? async (payload) => {
|
|
76147
|
+
await createBlockReplyDeliveryHandler({
|
|
75928
76148
|
onBlockReply: params.opts.onBlockReply,
|
|
75929
76149
|
currentMessageId: params.sessionCtx.MessageSidFull ?? params.sessionCtx.MessageSid,
|
|
75930
76150
|
normalizeStreamingText,
|
|
@@ -75933,46 +76153,22 @@ async function runAgentTurnWithFallback(params) {
|
|
|
75933
76153
|
blockStreamingEnabled: params.blockStreamingEnabled,
|
|
75934
76154
|
blockReplyPipeline,
|
|
75935
76155
|
directlySentBlockKeys
|
|
75936
|
-
})
|
|
75937
|
-
|
|
75938
|
-
|
|
75939
|
-
|
|
75940
|
-
|
|
75941
|
-
|
|
75942
|
-
|
|
75943
|
-
|
|
75944
|
-
|
|
75945
|
-
|
|
75946
|
-
|
|
75947
|
-
if (skip) return;
|
|
75948
|
-
await params.typingSignals.signalTextDelta(text);
|
|
75949
|
-
await onToolResult({
|
|
75950
|
-
text,
|
|
75951
|
-
mediaUrls: payload.mediaUrls
|
|
75952
|
-
});
|
|
75953
|
-
}).catch((err) => {
|
|
75954
|
-
logVerbose(`tool result delivery failed: ${String(err)}`);
|
|
75955
|
-
});
|
|
75956
|
-
const task = toolResultChain.finally(() => {
|
|
75957
|
-
params.pendingToolTasks.delete(task);
|
|
75958
|
-
});
|
|
75959
|
-
params.pendingToolTasks.add(task);
|
|
75960
|
-
};
|
|
75961
|
-
})() : void 0
|
|
75962
|
-
});
|
|
76156
|
+
})(payload);
|
|
76157
|
+
} : void 0,
|
|
76158
|
+
onBlockReplyFlush: params.blockStreamingEnabled && blockReplyPipeline ? async () => {
|
|
76159
|
+
await blockReplyPipeline.flush({ force: true });
|
|
76160
|
+
} : void 0,
|
|
76161
|
+
onCompaction: () => {
|
|
76162
|
+
autoCompactionCompleted = true;
|
|
76163
|
+
},
|
|
76164
|
+
onAgentEvent: (evt) => {
|
|
76165
|
+
if (evt.stream !== "lifecycle") notifyAgentRunStart();
|
|
76166
|
+
}
|
|
75963
76167
|
}
|
|
75964
76168
|
});
|
|
75965
|
-
runResult =
|
|
75966
|
-
fallbackProvider =
|
|
75967
|
-
fallbackModel =
|
|
75968
|
-
fallbackAttempts = Array.isArray(fallbackResult.attempts) ? fallbackResult.attempts.map((attempt) => ({
|
|
75969
|
-
provider: String(attempt.provider ?? ""),
|
|
75970
|
-
model: String(attempt.model ?? ""),
|
|
75971
|
-
error: String(attempt.error ?? ""),
|
|
75972
|
-
reason: attempt.reason ? String(attempt.reason) : void 0,
|
|
75973
|
-
status: typeof attempt.status === "number" ? attempt.status : void 0,
|
|
75974
|
-
code: attempt.code ? String(attempt.code) : void 0
|
|
75975
|
-
})) : [];
|
|
76169
|
+
runResult = turnResult.rawResult;
|
|
76170
|
+
fallbackProvider = turnResult.provider;
|
|
76171
|
+
fallbackModel = turnResult.modelId;
|
|
75976
76172
|
const embeddedError = runResult.meta?.error;
|
|
75977
76173
|
if (embeddedError && isContextOverflowError(embeddedError.message) && !didResetAfterCompactionFailure && await params.resetSessionAfterCompactionFailure(embeddedError.message)) {
|
|
75978
76174
|
didResetAfterCompactionFailure = true;
|
|
@@ -76031,14 +76227,6 @@ async function runAgentTurnWithFallback(params) {
|
|
|
76031
76227
|
payload: { text: "⚠️ Session history was corrupted. I've reset the conversation - please try again!" }
|
|
76032
76228
|
};
|
|
76033
76229
|
}
|
|
76034
|
-
if (isTransientHttp && !didRetryTransientHttpError) {
|
|
76035
|
-
didRetryTransientHttpError = true;
|
|
76036
|
-
defaultRuntime.error(`Transient HTTP provider error before reply (${message}). Retrying once in ${TRANSIENT_HTTP_RETRY_DELAY_MS}ms.`);
|
|
76037
|
-
await new Promise((resolve) => {
|
|
76038
|
-
setTimeout(resolve, TRANSIENT_HTTP_RETRY_DELAY_MS);
|
|
76039
|
-
});
|
|
76040
|
-
continue;
|
|
76041
|
-
}
|
|
76042
76230
|
defaultRuntime.error(`Embedded agent failed before reply: ${message}`);
|
|
76043
76231
|
const trimmedMessage = (isTransientHttp ? sanitizeUserFacingText(message, { errorContext: true }) : message).replace(/\.\s*$/, "");
|
|
76044
76232
|
return {
|
|
@@ -76211,7 +76399,7 @@ async function runMemoryFlushIfNeeded(params) {
|
|
|
76211
76399
|
try {
|
|
76212
76400
|
await runWithModelFallback({
|
|
76213
76401
|
...resolveModelFallbackOptions(params.followupRun.run),
|
|
76214
|
-
run: (provider, model) => {
|
|
76402
|
+
run: async (provider, model) => {
|
|
76215
76403
|
const { authProfile, embeddedContext, senderContext } = buildEmbeddedRunContexts({
|
|
76216
76404
|
run: params.followupRun.run,
|
|
76217
76405
|
sessionCtx: params.sessionCtx,
|
|
@@ -76225,21 +76413,46 @@ async function runMemoryFlushIfNeeded(params) {
|
|
|
76225
76413
|
runId: flushRunId,
|
|
76226
76414
|
authProfile
|
|
76227
76415
|
});
|
|
76228
|
-
return
|
|
76229
|
-
|
|
76230
|
-
|
|
76231
|
-
|
|
76416
|
+
return (await runAgentTurn({
|
|
76417
|
+
sessionId: embeddedContext.sessionId,
|
|
76418
|
+
sessionKey: embeddedContext.sessionKey ?? embeddedContext.sessionId ?? "",
|
|
76419
|
+
workspaceDir: runBaseParams.workspaceDir,
|
|
76420
|
+
agentDir: runBaseParams.agentDir,
|
|
76421
|
+
config: runBaseParams.config ?? params.cfg,
|
|
76422
|
+
skillsSnapshot: runBaseParams.skillsSnapshot,
|
|
76232
76423
|
prompt: resolveMemoryFlushPromptForRun({
|
|
76233
76424
|
prompt: memoryFlushSettings.prompt,
|
|
76234
76425
|
cfg: params.cfg
|
|
76235
76426
|
}),
|
|
76236
76427
|
extraSystemPrompt: flushSystemPrompt,
|
|
76237
|
-
|
|
76238
|
-
|
|
76239
|
-
|
|
76240
|
-
|
|
76241
|
-
|
|
76242
|
-
|
|
76428
|
+
provider,
|
|
76429
|
+
modelId: model,
|
|
76430
|
+
authProfileId: runBaseParams.authProfileId,
|
|
76431
|
+
authProfileIdSource: runBaseParams.authProfileIdSource,
|
|
76432
|
+
thinkLevel: runBaseParams.thinkLevel,
|
|
76433
|
+
verboseLevel: runBaseParams.verboseLevel,
|
|
76434
|
+
reasoningLevel: runBaseParams.reasoningLevel,
|
|
76435
|
+
timeoutMs: runBaseParams.timeoutMs,
|
|
76436
|
+
runId: runBaseParams.runId,
|
|
76437
|
+
ownerNumbers: runBaseParams.ownerNumbers,
|
|
76438
|
+
enforceFinalTag: runBaseParams.enforceFinalTag,
|
|
76439
|
+
execOverrides: runBaseParams.execOverrides,
|
|
76440
|
+
bashElevated: runBaseParams.bashElevated,
|
|
76441
|
+
channel: {
|
|
76442
|
+
messageProvider: embeddedContext.messageProvider,
|
|
76443
|
+
agentAccountId: embeddedContext.agentAccountId,
|
|
76444
|
+
messageTo: embeddedContext.messageTo,
|
|
76445
|
+
messageThreadId: embeddedContext.messageThreadId,
|
|
76446
|
+
senderId: senderContext.senderId,
|
|
76447
|
+
senderName: senderContext.senderName,
|
|
76448
|
+
senderUsername: senderContext.senderUsername,
|
|
76449
|
+
senderE164: senderContext.senderE164,
|
|
76450
|
+
senderIsOwner: runBaseParams.senderIsOwner
|
|
76451
|
+
},
|
|
76452
|
+
callbacks: { onCompaction: () => {
|
|
76453
|
+
memoryCompactionCompleted = true;
|
|
76454
|
+
} }
|
|
76455
|
+
})).rawResult;
|
|
76243
76456
|
}
|
|
76244
76457
|
});
|
|
76245
76458
|
let memoryFlushCompactionCount = activeSessionEntry?.compactionCount ?? (params.sessionKey ? activeSessionStore?.[params.sessionKey]?.compactionCount : 0) ?? 0;
|
|
@@ -76554,81 +76767,73 @@ function createFollowupRunner(params) {
|
|
|
76554
76767
|
let fallbackProvider = queued.run.provider;
|
|
76555
76768
|
let fallbackModel = queued.run.model;
|
|
76556
76769
|
try {
|
|
76557
|
-
|
|
76558
|
-
|
|
76559
|
-
|
|
76560
|
-
|
|
76770
|
+
runResult = await runAgentTurn({
|
|
76771
|
+
sessionId: queued.run.sessionId,
|
|
76772
|
+
sessionKey: queued.run.sessionKey ?? queued.run.sessionId,
|
|
76773
|
+
workspaceDir: queued.run.workspaceDir,
|
|
76561
76774
|
agentDir: queued.run.agentDir,
|
|
76562
|
-
|
|
76563
|
-
|
|
76564
|
-
|
|
76565
|
-
|
|
76566
|
-
|
|
76567
|
-
|
|
76568
|
-
|
|
76569
|
-
|
|
76570
|
-
|
|
76571
|
-
|
|
76572
|
-
|
|
76573
|
-
|
|
76574
|
-
|
|
76575
|
-
|
|
76576
|
-
|
|
76577
|
-
|
|
76578
|
-
|
|
76579
|
-
|
|
76580
|
-
|
|
76581
|
-
|
|
76582
|
-
|
|
76583
|
-
|
|
76584
|
-
|
|
76585
|
-
|
|
76586
|
-
|
|
76587
|
-
|
|
76588
|
-
|
|
76589
|
-
|
|
76590
|
-
|
|
76591
|
-
|
|
76592
|
-
|
|
76593
|
-
|
|
76594
|
-
|
|
76595
|
-
|
|
76596
|
-
|
|
76597
|
-
|
|
76598
|
-
|
|
76599
|
-
runId,
|
|
76600
|
-
blockReplyBreak: queued.run.blockReplyBreak,
|
|
76601
|
-
onAgentEvent: (evt) => {
|
|
76602
|
-
if (evt.stream !== "compaction") return;
|
|
76603
|
-
if ((typeof evt.data.phase === "string" ? evt.data.phase : "") === "end") autoCompactionCompleted = true;
|
|
76604
|
-
}
|
|
76605
|
-
});
|
|
76606
|
-
}
|
|
76775
|
+
config: queued.run.config,
|
|
76776
|
+
skillsSnapshot: queued.run.skillsSnapshot,
|
|
76777
|
+
prompt: queued.prompt,
|
|
76778
|
+
extraSystemPrompt: queued.run.extraSystemPrompt,
|
|
76779
|
+
provider: queued.run.provider,
|
|
76780
|
+
modelId: queued.run.model,
|
|
76781
|
+
authProfileId: queued.run.authProfileId,
|
|
76782
|
+
authProfileIdSource: queued.run.authProfileIdSource,
|
|
76783
|
+
thinkLevel: queued.run.thinkLevel,
|
|
76784
|
+
verboseLevel: queued.run.verboseLevel,
|
|
76785
|
+
reasoningLevel: queued.run.reasoningLevel,
|
|
76786
|
+
timeoutMs: queued.run.timeoutMs,
|
|
76787
|
+
runId,
|
|
76788
|
+
ownerNumbers: queued.run.ownerNumbers,
|
|
76789
|
+
enforceFinalTag: queued.run.enforceFinalTag,
|
|
76790
|
+
execOverrides: queued.run.execOverrides,
|
|
76791
|
+
bashElevated: queued.run.bashElevated,
|
|
76792
|
+
suppressToolErrorWarnings: opts?.suppressToolErrorWarnings,
|
|
76793
|
+
blockReplyBreak: queued.run.blockReplyBreak,
|
|
76794
|
+
fallbackModels: resolveAgentModelFallbacksOverride(queued.run.config, resolveAgentIdFromSessionKey(queued.run.sessionKey)),
|
|
76795
|
+
channel: {
|
|
76796
|
+
messageProvider: queued.run.messageProvider,
|
|
76797
|
+
agentAccountId: queued.run.agentAccountId,
|
|
76798
|
+
messageTo: queued.originatingTo,
|
|
76799
|
+
messageThreadId: queued.originatingThreadId,
|
|
76800
|
+
groupId: queued.run.groupId,
|
|
76801
|
+
groupChannel: queued.run.groupChannel,
|
|
76802
|
+
groupSpace: queued.run.groupSpace,
|
|
76803
|
+
senderId: queued.run.senderId,
|
|
76804
|
+
senderName: queued.run.senderName,
|
|
76805
|
+
senderUsername: queued.run.senderUsername,
|
|
76806
|
+
senderE164: queued.run.senderE164,
|
|
76807
|
+
senderIsOwner: queued.run.senderIsOwner
|
|
76808
|
+
},
|
|
76809
|
+
callbacks: { onCompaction: () => {
|
|
76810
|
+
autoCompactionCompleted = true;
|
|
76811
|
+
} }
|
|
76607
76812
|
});
|
|
76608
|
-
|
|
76609
|
-
|
|
76610
|
-
fallbackModel = fallbackResult.model;
|
|
76813
|
+
fallbackProvider = runResult.provider;
|
|
76814
|
+
fallbackModel = runResult.modelId;
|
|
76611
76815
|
} catch (err) {
|
|
76612
76816
|
const message = err instanceof Error ? err.message : String(err);
|
|
76613
76817
|
defaultRuntime.error?.(`Followup agent failed before reply: ${message}`);
|
|
76614
76818
|
return;
|
|
76615
76819
|
}
|
|
76616
|
-
const
|
|
76617
|
-
const
|
|
76618
|
-
const
|
|
76820
|
+
const rawResult = runResult.rawResult;
|
|
76821
|
+
const usage = rawResult.meta?.agentMeta?.usage;
|
|
76822
|
+
const promptTokens = rawResult.meta?.agentMeta?.promptTokens;
|
|
76823
|
+
const modelUsed = rawResult.meta?.agentMeta?.model ?? fallbackModel ?? defaultModel;
|
|
76619
76824
|
const contextTokensUsed = agentCfgContextTokens ?? lookupContextTokens(modelUsed) ?? sessionEntry?.contextTokens ?? DEFAULT_CONTEXT_TOKENS;
|
|
76620
76825
|
if (storePath && sessionKey) await persistRunSessionUsage({
|
|
76621
76826
|
storePath,
|
|
76622
76827
|
sessionKey,
|
|
76623
76828
|
usage,
|
|
76624
|
-
lastCallUsage:
|
|
76829
|
+
lastCallUsage: rawResult.meta?.agentMeta?.lastCallUsage,
|
|
76625
76830
|
promptTokens,
|
|
76626
76831
|
modelUsed,
|
|
76627
76832
|
providerUsed: fallbackProvider,
|
|
76628
76833
|
contextTokensUsed,
|
|
76629
76834
|
logLabel: "followup"
|
|
76630
76835
|
});
|
|
76631
|
-
const payloadArray =
|
|
76836
|
+
const payloadArray = rawResult.payloads ?? [];
|
|
76632
76837
|
if (payloadArray.length === 0) return;
|
|
76633
76838
|
const sanitizedPayloads = payloadArray.flatMap((payload) => {
|
|
76634
76839
|
const text = payload.text;
|
|
@@ -76649,13 +76854,13 @@ function createFollowupRunner(params) {
|
|
|
76649
76854
|
replyToMode: resolveReplyToMode(queued.run.config, replyToChannel, queued.originatingAccountId, queued.originatingChatType),
|
|
76650
76855
|
replyToChannel
|
|
76651
76856
|
}),
|
|
76652
|
-
sentTexts:
|
|
76857
|
+
sentTexts: rawResult.messagingToolSentTexts ?? []
|
|
76653
76858
|
}),
|
|
76654
|
-
sentMediaUrls:
|
|
76859
|
+
sentMediaUrls: rawResult.messagingToolSentMediaUrls ?? []
|
|
76655
76860
|
});
|
|
76656
76861
|
const finalPayloads = shouldSuppressMessagingToolReplies({
|
|
76657
76862
|
messageProvider: queued.run.messageProvider,
|
|
76658
|
-
messagingToolSentTargets:
|
|
76863
|
+
messagingToolSentTargets: rawResult.messagingToolSentTargets,
|
|
76659
76864
|
originatingTo: queued.originatingTo,
|
|
76660
76865
|
accountId: queued.run.agentAccountId
|
|
76661
76866
|
}) ? [] : mediaFilteredPayloads;
|
|
@@ -76666,7 +76871,7 @@ function createFollowupRunner(params) {
|
|
|
76666
76871
|
sessionStore,
|
|
76667
76872
|
sessionKey,
|
|
76668
76873
|
storePath,
|
|
76669
|
-
lastCallUsage:
|
|
76874
|
+
lastCallUsage: rawResult.meta?.agentMeta?.lastCallUsage,
|
|
76670
76875
|
contextTokensUsed
|
|
76671
76876
|
});
|
|
76672
76877
|
if (queued.run.verboseLevel && queued.run.verboseLevel !== "off") {
|