@gaodefa/daocore 2026.5.25 → 2026.5.26
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/abort-By0wxKlI.js +277 -0
- package/dist/abort.runtime-C7zfjxBp.js +2 -0
- package/dist/abort.runtime.js +1 -1
- package/dist/account-inspect-DTeLlJz-.js +173 -0
- package/dist/accounts-B776XBaL.js +119 -0
- package/dist/accounts-CLyZILFF.js +107 -0
- package/dist/accounts-DiXgq14W.js +107 -0
- package/dist/accounts-iTlRLYN8.js +2 -0
- package/dist/acp/control-plane/manager.d.ts +2 -1
- package/dist/acp-runtime-D9YQyGax.js +26 -0
- package/dist/acp-spawn-CWciV70C.js +1275 -0
- package/dist/acp-spawn-DjaS4O_V.js +2 -0
- package/dist/acp-stateful-target-driver-ByvGCj_i.js +89 -0
- package/dist/action-kill-DXeOA6YH.js +33 -0
- package/dist/action-runtime-BjQnG6qb.js +469 -0
- package/dist/action-runtime-api-a73ODsYk.js +2 -0
- package/dist/action-send-B_F3xwIu.js +39 -0
- package/dist/action-spawn-BFiW7gZJ.js +47 -0
- package/dist/actions-Bi7eE2I6.js +161 -0
- package/dist/actions.runtime-DmtbCLld.js +5 -0
- package/dist/agent-BOI4AdYK.js +3 -0
- package/dist/agent-DQPyDWP5.js +2 -0
- package/dist/agent-command-ClCxEw82.js +1367 -0
- package/dist/agent-command-DKqx29vm.d.ts +105 -0
- package/dist/agent-components.runtime-C5wxy4D_.js +10 -0
- package/dist/agent-components.runtime.js +1 -1
- package/dist/agent-harness-BsBVO7nU.d.ts +146 -0
- package/dist/agent-harness-runtime-CkdXIMHI.js +180 -0
- package/dist/agent-harness-runtime-KHFO733B.d.ts +691 -0
- package/dist/agent-harness-task-runtime-CDtn5RjX.js +140 -0
- package/dist/agent-runner-execution-lXW8y0i2.js +1713 -0
- package/dist/agent-runner-utils-OdM9hLGt.js +266 -0
- package/dist/agent-runner.runtime-fZnfhCJI.js +3455 -0
- package/dist/agent-runner.runtime.js +1 -1
- package/dist/agent-runtime-Dp0RDnX1.js +229 -0
- package/dist/agent-via-gateway-vsBf3nqZ.js +463 -0
- package/dist/agents/pi-embedded-runner/tool-split.d.ts +1 -1
- package/dist/agents.commands.add-C94vGOFH.js +304 -0
- package/dist/agents.commands.delete-D-p2NL4v.js +128 -0
- package/dist/api-BZ2QC7WM.js +2 -0
- package/dist/api-BmYK5Dge.js +6 -0
- package/dist/api-CGdlHCIH.js +3 -0
- package/dist/api-CGjlsXii.js +134 -0
- package/dist/api-DGqp6wZo.js +2 -0
- package/dist/api-DKpE-zdY.js +639 -0
- package/dist/api-DNyivJXK.d.ts +52 -0
- package/dist/apply-GK4z5lYw.js +54 -0
- package/dist/apply-_yxsBkiR.js +41 -0
- package/dist/approval-handler.runtime-C7d9p3DG.js +130 -0
- package/dist/assistant-B-h25aRy.js +291 -0
- package/dist/attachment-normalize-DWZ4Nrn-.js +225 -0
- package/dist/attempt-execution-BY9C1EOu.js +558 -0
- package/dist/attempt-execution.runtime-SR7eolDa.js +3 -0
- package/dist/attempt-execution.runtime.js +1 -1
- package/dist/attempt-execution.shared-h6uYmkJz.js +38 -0
- package/dist/attempt.prompt-helpers-COc5m_TZ.js +475 -0
- package/dist/attempt.tool-run-context-CAtfgOqC.js +2094 -0
- package/dist/auth-BdkNYTYU.js +541 -0
- package/dist/banner-0TOO6XHd.js +397 -0
- package/dist/banner-DTHug6Ey.js +2 -0
- package/dist/binding-routing-BJ_A83Nl.js +113 -0
- package/dist/binding-targets-D5dmPh4R.js +121 -0
- package/dist/bot-DX1uG3P-.js +7894 -0
- package/dist/bot-deps-BpaYejaN.js +2 -0
- package/dist/bot-deps-CKFDy5y3.js +747 -0
- package/dist/bot-message-context.runtime-BKOeRg34.js +7 -0
- package/dist/bot-message-context.runtime.js +1 -1
- package/dist/bot-message-context.session.runtime-xgZdFv6P.js +12 -0
- package/dist/bot-message-context.session.runtime.js +1 -1
- package/dist/bot-native-commands.delivery.runtime-DDMQrRfJ.js +4 -0
- package/dist/bot-native-commands.delivery.runtime.js +1 -1
- package/dist/bot-native-commands.runtime-CVVvUz0h.js +13 -0
- package/dist/bot-native-commands.runtime.js +1 -1
- package/dist/bridge-server-37OWsDZc.js +113 -0
- package/dist/browser-cli-BC_6aZJV.js +2 -0
- package/dist/browser-cli-Dg1ipmgf.js +230 -0
- package/dist/browser-cli-actions-input-B0QuzzSW.js +473 -0
- package/dist/browser-cli-actions-observe-C246bas5.js +81 -0
- package/dist/browser-cli-debug-F64e_v4B.js +137 -0
- package/dist/browser-cli-inspect-Srn6eWjO.js +104 -0
- package/dist/browser-cli-manage-CaZ97-Me.js +443 -0
- package/dist/browser-cli-resize-CUR20fvZ.js +26 -0
- package/dist/browser-cli-shared-BhphnFVo.js +50 -0
- package/dist/browser-cli-state-CzaNXNWF.js +337 -0
- package/dist/browser-control-auth-DTY0Wx2B.js +2 -0
- package/dist/browser-profiles-BDGPPDJ7.js +2 -0
- package/dist/browser-runtime-aqBKI8Oi.js +384 -0
- package/dist/build-CG7aTzO9.js +257 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +2 -2
- package/dist/bundled/session-memory/handler.js +1 -1
- package/dist/bundled-channel-config-schema-vrKpzJVf.d.ts +3163 -0
- package/dist/call-Za47o1YZ.d.ts +43 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/capability-cli-BhF26gVm.js +1782 -0
- package/dist/channel-5RHqx1Ge.d.ts +26 -0
- package/dist/channel-5_XS0Mss.js +508 -0
- package/dist/channel-7L-vyWOO.js +362 -0
- package/dist/channel-B07xPK0L.d.ts +114 -0
- package/dist/channel-B9b-GX-e.d.ts +14 -0
- package/dist/channel-BBWX_bA0.d.ts +7 -0
- package/dist/channel-BVxTyJ0I.js +376 -0
- package/dist/channel-BWIsr1r-.js +808 -0
- package/dist/channel-Ba0p4xM-.js +1134 -0
- package/dist/channel-Bi2nTop1.js +481 -0
- package/dist/channel-Bj29iFgF.js +740 -0
- package/dist/channel-Bl8tKAuG.d.ts +427 -0
- package/dist/channel-Bqy7BYGm.d.ts +28 -0
- package/dist/channel-BvzHMdKo.d.ts +8 -0
- package/dist/channel-C6G6-tH6.js +562 -0
- package/dist/channel-CBhuuq-_.js +2126 -0
- package/dist/channel-CMmVpcnl.js +867 -0
- package/dist/channel-COc7idAe.js +653 -0
- package/dist/channel-CcsuLAYt.d.ts +49 -0
- package/dist/channel-CjfuHhSU.js +1556 -0
- package/dist/channel-Cquy73C-.js +1249 -0
- package/dist/channel-Cu7Jxm_X.d.ts +104 -0
- package/dist/channel-CzvuskEn.js +955 -0
- package/dist/channel-D6u-243v.js +1777 -0
- package/dist/channel-DId5JNlc.d.ts +47 -0
- package/dist/channel-DR8PbP31.js +238 -0
- package/dist/channel-DUYRu5km.d.ts +7 -0
- package/dist/channel-DUZ0s98I.js +1496 -0
- package/dist/channel-DXelghSl.d.ts +8 -0
- package/dist/channel-FhfE8D-t.d.ts +6 -0
- package/dist/channel-PEX_yYEO.d.ts +64 -0
- package/dist/channel-aWqPl-K4.d.ts +106 -0
- package/dist/channel-actions.runtime-BzEqt_Va.js +265 -0
- package/dist/channel-actions.runtime.js +1 -1
- package/dist/channel-cSdO0kAq.d.ts +8 -0
- package/dist/channel-core-ClgodQav.d.ts +6 -0
- package/dist/channel-core-DDZnTvT6.js +5 -0
- package/dist/channel-entry-contract-Bzkb_oJX.d.ts +112 -0
- package/dist/channel-inbound-C2wLEE7Q.js +80 -0
- package/dist/channel-lifecycle-DCTZ2J_8.d.ts +126 -0
- package/dist/channel-pairing-pKisqGWj.d.ts +58 -0
- package/dist/channel-plugin-runtime-B8AWkA0i.js +998 -0
- package/dist/channel-plugin-runtime-ntEeH9SC.d.ts +7 -0
- package/dist/channel-runtime-CciKN6E5.js +408 -0
- package/dist/channel-za2kUUnL.d.ts +12 -0
- package/dist/channel.runtime-BQN8Bkb0.js +254 -0
- package/dist/channel.runtime-BXeGEvv7.js +21009 -0
- package/dist/channel.runtime-C40ILulM.js +1008 -0
- package/dist/channel.runtime-CJ2DSojv.js +733 -0
- package/dist/channel.runtime-CUaygROD.js +652 -0
- package/dist/channel.runtime-CcCbJhDb.js +88 -0
- package/dist/channel.runtime-DJbKu9D3.js +4 -0
- package/dist/channel.runtime-DgRuSo5T.js +109 -0
- package/dist/channel.runtime-tRXUD2p2.js +2528 -0
- package/dist/channel.setup-3aVku-g-.js +1098 -0
- package/dist/channel.setup-Cau-V9UT.d.ts +7 -0
- package/dist/channel.setup-DT7Z9egu.js +343 -0
- package/dist/channel.setup-DhlkGTJV.js +10 -0
- package/dist/channel.setup-P5V7jWHY.d.ts +6 -0
- package/dist/channel.setup-x333W0eZ.d.ts +8 -0
- package/dist/chat-D3LWYymW.js +2666 -0
- package/dist/chrome--ATU1T0X.js +1503 -0
- package/dist/cli/run-main.js +9 -9
- package/dist/cli-D8hIXnS1.js +1341 -0
- package/dist/cli-backend-C1JA33SE.d.ts +5 -0
- package/dist/cli-backend-D8WmqNqJ.d.ts +5 -0
- package/dist/cli-compaction-jmi3u2HG.js +347 -0
- package/dist/cli-daS2Mzjd.d.ts +20 -0
- package/dist/cli-metadata-Cy9MEdPv.js +22 -0
- package/dist/cli-runner-DuT8oeZF.js +540 -0
- package/dist/cli-runner-DvKgnkCL.js +2 -0
- package/dist/cli-runner.runtime-B-aD16MD.js +4 -0
- package/dist/cli-runner.runtime-DofcKX1U.js +3 -0
- package/dist/cli-runner.runtime.js +1 -1
- package/dist/cli-shared-BFZytJBA.d.ts +20 -0
- package/dist/cli-startup-metadata.json +13 -13
- package/dist/client-B5IcAlfB.js +650 -0
- package/dist/client-adapter-CXA67h2E.js +897 -0
- package/dist/client-factory-aY6TuKfQ.js +9 -0
- package/dist/command-auth-DS9XgXEG.js +135 -0
- package/dist/command-execution-startup-DQOLt5Sz.js +87 -0
- package/dist/command-handlers-DqxF-IM9.js +1609 -0
- package/dist/command-registry-BSVx1oOc.js +4 -0
- package/dist/command-registry-CsPIOiQ3.js +9 -0
- package/dist/command-registry-core-Bzu5ff5F.js +110 -0
- package/dist/command-status.runtime-MKsizBC-.js +90 -0
- package/dist/command-status.runtime.js +1 -1
- package/dist/commands-B6Y6rqal.d.ts +113 -0
- package/dist/commands-acp-ClJofWty.js +74 -0
- package/dist/commands-compact.runtime-7VqYX4tS.js +10 -0
- package/dist/commands-compact.runtime.js +1 -1
- package/dist/commands-handlers.runtime-Dfqf_Oyp.js +6154 -0
- package/dist/commands-handlers.runtime.js +1 -1
- package/dist/commands-status-CRaEj9Vf.js +16 -0
- package/dist/commands-status-uDaqCP2F.js +3 -0
- package/dist/commands-status.runtime-uDaqCP2F.js +3 -0
- package/dist/commands-status.runtime.js +1 -1
- package/dist/commands-subagents-control.runtime-BaYcGLtc.js +2 -0
- package/dist/commands-subagents-control.runtime-C4xMpLed.js +3 -0
- package/dist/commands-subagents-control.runtime.js +1 -1
- package/dist/commands-system-prompt-C3lzz7wW.js +162 -0
- package/dist/commands-system-prompt-DpiW5FkQ.js +2 -0
- package/dist/commands.runtime-l4fGcB5c.js +176 -0
- package/dist/commands.runtime.js +1 -1
- package/dist/commitments/runtime.js +1 -1
- package/dist/compact-Dq0mi-y_.js +480 -0
- package/dist/compact-voJdoXm-.js +1141 -0
- package/dist/compact.runtime-BNLPSDQQ.js +12 -0
- package/dist/compact.runtime.js +1 -1
- package/dist/completion-cli-qHUelvvd.js +315 -0
- package/dist/computer-use-dP3FCUtq.js +367 -0
- package/dist/config-BDGPPDJ7.js +2 -0
- package/dist/config-Dg3sgjXu.js +373 -0
- package/dist/config-cli-INHPnZOG.js +1633 -0
- package/dist/config-mutations-CAgnXnDt.js +159 -0
- package/dist/config-schema-BkkovNaj.d.ts +20 -0
- package/dist/configure-M1VU0h9O.js +3 -0
- package/dist/configure.commands-CM8RXyn3.js +1251 -0
- package/dist/configure.commands-PvOJd4nu.js +2 -0
- package/dist/context-engine-host-compat-D7I7Q63Z.js +288 -0
- package/dist/context-engine-host-compat-DGHUiQUV.js +2 -0
- package/dist/context-engine-lifecycle-Zsi-S6qy.js +1274 -0
- package/dist/contracts-testkit-Ch7UfUw6.d.ts +145 -0
- package/dist/control-auth-BKUTwIvH.js +114 -0
- package/dist/control-service-CKUzEAa0.js +145 -0
- package/dist/control-ui/assets/agents-CUjpwxUf.js +1008 -0
- package/dist/control-ui/assets/channel-config-extras-Dd4z5RQ8.js +2 -0
- package/dist/control-ui/assets/channels-554ojNKp.js +367 -0
- package/dist/control-ui/assets/cron-BAd2PXq5.js +1013 -0
- package/dist/control-ui/assets/debug-BGCb3cT4.js +97 -0
- package/dist/control-ui/assets/index-BXico1DI.js +7370 -0
- package/dist/control-ui/assets/instances-EkBPy6m3.js +57 -0
- package/dist/control-ui/assets/logs-zcOeZekZ.js +74 -0
- package/dist/control-ui/assets/nodes-BymRwDa6.js +436 -0
- package/dist/control-ui/assets/sessions-C_oSuy7x.js +399 -0
- package/dist/control-ui/assets/skills-BVjEetcV.js +314 -0
- package/dist/control-ui/assets/skills-shared-weS2ZYM5.js +11 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/control-ui/sw.js +1 -1
- package/dist/conversation-binding-runtime-rXAYUZyM.js +4 -0
- package/dist/conversation-runtime-CV0pSg81.js +31 -0
- package/dist/core-BV0irASW.js +282 -0
- package/dist/core-DIjsbXou.d.ts +224 -0
- package/dist/core-api-CyhjZVzn.js +5 -0
- package/dist/core-api-YdHGjff8.js +2 -0
- package/dist/crestodian/crestodian.js +1 -1
- package/dist/crestodian/rescue-message.js +1 -1
- package/dist/crestodian-n5FVHIW5.js +55 -0
- package/dist/daocore-runtime-DhfJoXrT.d.ts +151 -0
- package/dist/daocore-tools-CXDZ1Xhe.js +11727 -0
- package/dist/dashboard-CeQV6L1K.js +263 -0
- package/dist/delivery-D7LfafSk.js +1002 -0
- package/dist/dev-BSY4rs1s.js +97 -0
- package/dist/dialogue-DWFnjTiN.js +37 -0
- package/dist/dir-fetch-tool-BnlEyfZh.js +565 -0
- package/dist/dir-list-tool-Blhg_vTH.js +100 -0
- package/dist/direct-dm-DJPIaf5J.js +64 -0
- package/dist/directive-handling.fast-lane-DGV6PZYZ.js +68 -0
- package/dist/directive-handling.impl-CTDwclQa.js +818 -0
- package/dist/directive-handling.impl-_zI0_GsT.js +2 -0
- package/dist/directive-handling.model-selection-C8lG4FHQ.js +122 -0
- package/dist/directive-handling.persist.runtime-CmLb1evR.js +263 -0
- package/dist/directive-handling.persist.runtime.js +1 -1
- package/dist/dispatch-DvZRbIrc.js +1640 -0
- package/dist/dispatch-acp-transcript.runtime-PehNIsnR.js +40 -0
- package/dist/dispatch-acp-transcript.runtime.js +1 -1
- package/dist/dispatch-acp.runtime-Dg8ft-Ve.js +18 -0
- package/dist/dispatch-acp.runtime.js +1 -1
- package/dist/doctor-DJFM3lrT.js +6 -0
- package/dist/doctor-_ob4EiVf.js +2 -0
- package/dist/doctor-config-flow-D6iEk-en.js +1741 -0
- package/dist/doctor-core-checks-CCfWWL1-.js +573 -0
- package/dist/doctor-core-checks-CqkHUVcZ.js +2 -0
- package/dist/doctor-health-CrNPft4G.js +65 -0
- package/dist/doctor-health-contributions-Bwu5M_GQ.js +696 -0
- package/dist/doctor-lint-B2Wb_jEn.js +94 -0
- package/dist/doctor-prompter-cXq7RExi.js +58 -0
- package/dist/doctor-state-integrity-DfYyVFbQ.js +1231 -0
- package/dist/dynamic-tools-CbHsYkuk.js +486 -0
- package/dist/embedded-backend-IYuqoxzv.js +579 -0
- package/dist/embedded-gateway-stub.runtime-BjJ_93Pp.js +12 -0
- package/dist/embedded-gateway-stub.runtime.js +1 -1
- package/dist/embedding-provider-B50jxKn8.d.ts +65 -0
- package/dist/embedding-provider-DOktf4gm.d.ts +21 -0
- package/dist/embedding-provider-DZOjws8e.d.ts +16 -0
- package/dist/entry.d.ts +1 -1
- package/dist/entry.js +1 -1
- package/dist/exec-approvals-VjIKwFog.js +149 -0
- package/dist/extensionAPI.js +1 -1
- package/dist/extensions/active-memory/index.d.ts +1 -1
- package/dist/extensions/active-memory/index.js +1 -1
- package/dist/extensions/admin-http-rpc/index.d.ts +1 -1
- package/dist/extensions/admin-http-rpc/index.js +1 -1
- package/dist/extensions/alibaba/index.d.ts +1 -1
- package/dist/extensions/anthropic/api.d.ts +3 -3
- package/dist/extensions/anthropic/cli-backend-api.d.ts +2 -2
- package/dist/extensions/anthropic/cli-backend.d.ts +1 -1
- package/dist/extensions/anthropic/cli-migration.d.ts +1 -1
- package/dist/extensions/anthropic/cli-shared.d.ts +1 -1
- package/dist/extensions/anthropic/contract-api.d.ts +1 -1
- package/dist/extensions/anthropic/index.d.ts +1 -1
- package/dist/extensions/anthropic/provider-contract-api.d.ts +1 -1
- package/dist/extensions/anthropic/provider-discovery.d.ts +1 -1
- package/dist/extensions/anthropic/provider-policy-api.d.ts +1 -1
- package/dist/extensions/anthropic/register.runtime.d.ts +1 -1
- package/dist/extensions/anthropic/replay-policy.d.ts +1 -1
- package/dist/extensions/anthropic/setup-api.d.ts +1 -1
- package/dist/extensions/anthropic/stream-wrappers.d.ts +1 -1
- package/dist/extensions/anthropic/test-api.d.ts +2 -2
- package/dist/extensions/arcee/index.d.ts +1 -1
- package/dist/extensions/azure-speech/index.d.ts +1 -1
- package/dist/extensions/azure-speech/speech-provider.d.ts +1 -1
- package/dist/extensions/bonjour/index.d.ts +1 -1
- package/dist/extensions/browser/browser-bridge.js +1 -1
- package/dist/extensions/browser/browser-config.js +4 -4
- package/dist/extensions/browser/browser-control-auth.js +2 -2
- package/dist/extensions/browser/browser-doctor.js +2 -2
- package/dist/extensions/browser/browser-maintenance.js +1 -1
- package/dist/extensions/browser/browser-profiles.js +2 -2
- package/dist/extensions/browser/browser-runtime-api.js +11 -11
- package/dist/extensions/browser/cli-metadata.d.ts +1 -1
- package/dist/extensions/browser/cli-metadata.js +1 -1
- package/dist/extensions/browser/index.d.ts +1 -1
- package/dist/extensions/browser/index.js +1 -1
- package/dist/extensions/browser/plugin-registration.d.ts +1 -1
- package/dist/extensions/browser/plugin-registration.js +1 -1
- package/dist/extensions/browser/register.runtime.d.ts +2 -2
- package/dist/extensions/browser/register.runtime.js +4 -4
- package/dist/extensions/browser/runtime-api.d.ts +3 -3
- package/dist/extensions/browser/runtime-api.js +13 -13
- package/dist/extensions/browser/setup-api.d.ts +1 -1
- package/dist/extensions/byteplus/index.d.ts +1 -1
- package/dist/extensions/byteplus/provider-discovery.d.ts +1 -1
- package/dist/extensions/canvas/cli-metadata.d.ts +1 -1
- package/dist/extensions/canvas/index.d.ts +1 -1
- package/dist/extensions/canvas/index.js +1 -1
- package/dist/extensions/canvas/runtime-api.d.ts +2 -2
- package/dist/extensions/canvas/setup-api.d.ts +1 -1
- package/dist/extensions/cerebras/index.d.ts +1 -1
- package/dist/extensions/chutes/index.d.ts +1 -1
- package/dist/extensions/clickclack/api.d.ts +2 -2
- package/dist/extensions/clickclack/api.js +2 -2
- package/dist/extensions/clickclack/channel-plugin-api.d.ts +1 -1
- package/dist/extensions/clickclack/channel-plugin-api.js +1 -1
- package/dist/extensions/clickclack/index.d.ts +2 -2
- package/dist/extensions/clickclack/runtime-api.d.ts +2 -2
- package/dist/extensions/clickclack/runtime-api.js +2 -2
- package/dist/extensions/cloudflare-ai-gateway/index.d.ts +1 -1
- package/dist/extensions/cloudflare-ai-gateway/stream-wrappers.d.ts +1 -1
- package/dist/extensions/comfy/index.d.ts +1 -1
- package/dist/extensions/copilot-proxy/index.d.ts +1 -1
- package/dist/extensions/copilot-proxy/runtime-api.d.ts +2 -2
- package/dist/extensions/deepgram/index.d.ts +1 -1
- package/dist/extensions/deepgram/realtime-transcription-provider.d.ts +1 -1
- package/dist/extensions/deepgram/test-api.d.ts +1 -1
- package/dist/extensions/deepinfra/api.d.ts +2 -2
- package/dist/extensions/deepinfra/embedding-provider.d.ts +1 -1
- package/dist/extensions/deepinfra/index.d.ts +1 -1
- package/dist/extensions/deepinfra/memory-embedding-adapter.d.ts +1 -1
- package/dist/extensions/deepinfra/speech-provider.d.ts +1 -1
- package/dist/extensions/deepseek/api.d.ts +1 -1
- package/dist/extensions/deepseek/index.d.ts +1 -1
- package/dist/extensions/deepseek/provider-discovery.d.ts +1 -1
- package/dist/extensions/deepseek/provider-policy-api.d.ts +1 -1
- package/dist/extensions/deepseek/stream.d.ts +1 -1
- package/dist/extensions/deepseek/thinking.d.ts +1 -1
- package/dist/extensions/device-pair/api.d.ts +3 -3
- package/dist/extensions/device-pair/api.js +1 -1
- package/dist/extensions/device-pair/index.d.ts +1 -1
- package/dist/extensions/device-pair/notify.d.ts +1 -1
- package/dist/extensions/device-pair/pair-command-approve.js +1 -1
- package/dist/extensions/document-extract/index.d.ts +1 -1
- package/dist/extensions/duckduckgo/index.d.ts +1 -1
- package/dist/extensions/elevenlabs/index.d.ts +1 -1
- package/dist/extensions/elevenlabs/realtime-transcription-provider.d.ts +1 -1
- package/dist/extensions/elevenlabs/setup-api.d.ts +1 -1
- package/dist/extensions/elevenlabs/speech-provider.d.ts +1 -1
- package/dist/extensions/elevenlabs/test-api.d.ts +2 -2
- package/dist/extensions/exa/index.d.ts +1 -1
- package/dist/extensions/fal/index.d.ts +1 -1
- package/dist/extensions/fal/provider-contract-api.d.ts +1 -1
- package/dist/extensions/fal/provider-registration.d.ts +1 -1
- package/dist/extensions/file-transfer/index.d.ts +1 -1
- package/dist/extensions/file-transfer/index.js +4 -4
- package/dist/extensions/firecrawl/index.d.ts +1 -1
- package/dist/extensions/fireworks/index.d.ts +1 -1
- package/dist/extensions/fireworks/provider-policy-api.d.ts +1 -1
- package/dist/extensions/fireworks/stream.d.ts +1 -1
- package/dist/extensions/fireworks/thinking-policy.d.ts +1 -1
- package/dist/extensions/github-copilot/embeddings.d.ts +1 -1
- package/dist/extensions/github-copilot/index.d.ts +1 -1
- package/dist/extensions/github-copilot/models.d.ts +1 -1
- package/dist/extensions/github-copilot/register.runtime.d.ts +2 -2
- package/dist/extensions/github-copilot/stream.d.ts +1 -1
- package/dist/extensions/google/api.d.ts +5 -5
- package/dist/extensions/google/cli-backend.d.ts +1 -1
- package/dist/extensions/google/embedding-batch.d.ts +1 -1
- package/dist/extensions/google/embedding-provider.d.ts +1 -1
- package/dist/extensions/google/gemini-cli-provider.d.ts +1 -1
- package/dist/extensions/google/index.d.ts +1 -1
- package/dist/extensions/google/memory-embedding-adapter.d.ts +1 -1
- package/dist/extensions/google/provider-contract-api.d.ts +1 -1
- package/dist/extensions/google/provider-hooks.d.ts +2 -2
- package/dist/extensions/google/provider-models.d.ts +1 -1
- package/dist/extensions/google/provider-policy-api.d.ts +1 -1
- package/dist/extensions/google/provider-policy.d.ts +1 -1
- package/dist/extensions/google/provider-registration.d.ts +1 -1
- package/dist/extensions/google/realtime-voice-provider.d.ts +1 -1
- package/dist/extensions/google/runtime-api.d.ts +3 -3
- package/dist/extensions/google/setup-api.d.ts +1 -1
- package/dist/extensions/google/speech-provider.d.ts +1 -1
- package/dist/extensions/google/test-api.d.ts +2 -2
- package/dist/extensions/google/thinking-api.d.ts +1 -1
- package/dist/extensions/google/thinking.d.ts +1 -1
- package/dist/extensions/google/transport-stream.d.ts +1 -1
- package/dist/extensions/gradium/index.d.ts +1 -1
- package/dist/extensions/gradium/speech-provider.d.ts +1 -1
- package/dist/extensions/groq/index.d.ts +1 -1
- package/dist/extensions/huggingface/index.d.ts +1 -1
- package/dist/extensions/image-generation-core/api.d.ts +4 -4
- package/dist/extensions/image-generation-core/runtime-api.d.ts +1 -1
- package/dist/extensions/imessage/api.d.ts +2 -2
- package/dist/extensions/imessage/api.js +2 -2
- package/dist/extensions/imessage/channel-plugin-api.d.ts +1 -1
- package/dist/extensions/imessage/channel-plugin-api.js +1 -1
- package/dist/extensions/imessage/index.d.ts +2 -2
- package/dist/extensions/imessage/message-tool-api.d.ts +1 -1
- package/dist/extensions/imessage/runtime-api.d.ts +4 -4
- package/dist/extensions/imessage/runtime-api.js +3 -3
- package/dist/extensions/imessage/setup-entry.d.ts +2 -2
- package/dist/extensions/imessage/test-api.d.ts +1 -1
- package/dist/extensions/inworld/index.d.ts +1 -1
- package/dist/extensions/inworld/speech-provider.d.ts +1 -1
- package/dist/extensions/irc/api.d.ts +1 -1
- package/dist/extensions/irc/api.js +2 -2
- package/dist/extensions/irc/channel-plugin-api.d.ts +1 -1
- package/dist/extensions/irc/channel-plugin-api.js +1 -1
- package/dist/extensions/irc/index.d.ts +2 -2
- package/dist/extensions/irc/setup-entry.d.ts +2 -2
- package/dist/extensions/kilocode/index.d.ts +1 -1
- package/dist/extensions/kimi-coding/index.d.ts +1 -1
- package/dist/extensions/kimi-coding/stream.d.ts +1 -1
- package/dist/extensions/litellm/index.d.ts +1 -1
- package/dist/extensions/llm-task/api.d.ts +2 -2
- package/dist/extensions/llm-task/index.d.ts +1 -1
- package/dist/extensions/llm-task/index.js +1 -1
- package/dist/extensions/lmstudio/api.d.ts +1 -1
- package/dist/extensions/lmstudio/index.d.ts +1 -1
- package/dist/extensions/lmstudio/memory-embedding-adapter.d.ts +1 -1
- package/dist/extensions/mattermost/api.js +1 -1
- package/dist/extensions/mattermost/channel-plugin-api.d.ts +2 -2
- package/dist/extensions/mattermost/channel-plugin-api.js +1 -1
- package/dist/extensions/mattermost/channel-plugin-runtime.d.ts +1 -1
- package/dist/extensions/mattermost/channel-plugin-runtime.js +1 -1
- package/dist/extensions/mattermost/index.d.ts +2 -2
- package/dist/extensions/mattermost/policy-api.js +1 -1
- package/dist/extensions/mattermost/runtime-api.d.ts +9 -9
- package/dist/extensions/mattermost/runtime-api.js +2 -2
- package/dist/extensions/mattermost/setup-entry.d.ts +2 -2
- package/dist/extensions/mattermost/slash-route-api.d.ts +1 -1
- package/dist/extensions/mattermost/slash-route-api.js +1 -1
- package/dist/extensions/memory-core/api.d.ts +1 -1
- package/dist/extensions/memory-core/cli-metadata.d.ts +1 -1
- package/dist/extensions/memory-core/cli-metadata.js +1 -1
- package/dist/extensions/memory-core/index.d.ts +1 -1
- package/dist/extensions/memory-core/manager-runtime.d.ts +1 -1
- package/dist/extensions/memory-core/runtime-api.d.ts +2 -2
- package/dist/extensions/memory-wiki/api.d.ts +3 -3
- package/dist/extensions/memory-wiki/cli-metadata.d.ts +1 -1
- package/dist/extensions/memory-wiki/index.d.ts +1 -1
- package/dist/extensions/memory-wiki/setup-api.d.ts +1 -1
- package/dist/extensions/microsoft/index.d.ts +1 -1
- package/dist/extensions/microsoft/speech-provider.d.ts +1 -1
- package/dist/extensions/microsoft/test-api.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/auth.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/cli.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/index.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/onboard.d.ts +3 -3
- package/dist/extensions/microsoft-foundry/provider.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/runtime.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/shared-runtime.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/shared.d.ts +1 -1
- package/dist/extensions/migrate-claude/apply.d.ts +1 -1
- package/dist/extensions/migrate-claude/apply.js +1 -1
- package/dist/extensions/migrate-claude/config.d.ts +1 -1
- package/dist/extensions/migrate-claude/helpers.d.ts +1 -1
- package/dist/extensions/migrate-claude/index.d.ts +1 -1
- package/dist/extensions/migrate-claude/index.js +1 -1
- package/dist/extensions/migrate-claude/memory.d.ts +2 -2
- package/dist/extensions/migrate-claude/plan.d.ts +1 -1
- package/dist/extensions/migrate-claude/plan.js +1 -1
- package/dist/extensions/migrate-claude/provider.d.ts +1 -1
- package/dist/extensions/migrate-claude/provider.js +1 -1
- package/dist/extensions/migrate-claude/skills.d.ts +2 -2
- package/dist/extensions/migrate-claude/targets.d.ts +1 -1
- package/dist/extensions/migrate-claude/targets.js +1 -1
- package/dist/extensions/migrate-hermes/apply.d.ts +1 -1
- package/dist/extensions/migrate-hermes/apply.js +1 -1
- package/dist/extensions/migrate-hermes/config.d.ts +1 -1
- package/dist/extensions/migrate-hermes/helpers.d.ts +1 -1
- package/dist/extensions/migrate-hermes/index.d.ts +1 -1
- package/dist/extensions/migrate-hermes/index.js +1 -1
- package/dist/extensions/migrate-hermes/items.d.ts +1 -1
- package/dist/extensions/migrate-hermes/model.d.ts +1 -1
- package/dist/extensions/migrate-hermes/model.js +1 -1
- package/dist/extensions/migrate-hermes/plan.d.ts +1 -1
- package/dist/extensions/migrate-hermes/plan.js +1 -1
- package/dist/extensions/migrate-hermes/provider.d.ts +1 -1
- package/dist/extensions/migrate-hermes/provider.js +1 -1
- package/dist/extensions/migrate-hermes/secrets.d.ts +2 -2
- package/dist/extensions/migrate-hermes/secrets.js +1 -1
- package/dist/extensions/migrate-hermes/skills.d.ts +2 -2
- package/dist/extensions/migrate-hermes/targets.d.ts +1 -1
- package/dist/extensions/migrate-hermes/targets.js +1 -1
- package/dist/extensions/minimax/index.d.ts +1 -1
- package/dist/extensions/minimax/provider-contract-api.d.ts +1 -1
- package/dist/extensions/minimax/provider-registration.d.ts +1 -1
- package/dist/extensions/minimax/speech-provider.d.ts +1 -1
- package/dist/extensions/mistral/embedding-provider.d.ts +1 -1
- package/dist/extensions/mistral/index.d.ts +1 -1
- package/dist/extensions/mistral/memory-embedding-adapter.d.ts +1 -1
- package/dist/extensions/mistral/realtime-transcription-provider.d.ts +1 -1
- package/dist/extensions/mistral/test-api.d.ts +1 -1
- package/dist/extensions/moonshot/index.d.ts +1 -1
- package/dist/extensions/moonshot/provider-contract-api.d.ts +1 -1
- package/dist/extensions/moonshot/provider-discovery.d.ts +1 -1
- package/dist/extensions/nvidia/index.d.ts +1 -1
- package/dist/extensions/oc-path/cli-metadata.d.ts +1 -1
- package/dist/extensions/oc-path/cli-registration.d.ts +1 -1
- package/dist/extensions/oc-path/index.d.ts +1 -1
- package/dist/extensions/ollama/api.d.ts +1 -1
- package/dist/extensions/ollama/index.d.ts +1 -1
- package/dist/extensions/ollama/provider-discovery.d.ts +1 -1
- package/dist/extensions/ollama/provider-policy-api.d.ts +1 -1
- package/dist/extensions/ollama/runtime-api.d.ts +1 -1
- package/dist/extensions/open-prose/index.d.ts +1 -1
- package/dist/extensions/open-prose/runtime-api.d.ts +2 -2
- package/dist/extensions/openai/api.d.ts +4 -4
- package/dist/extensions/openai/embedding-batch.d.ts +1 -1
- package/dist/extensions/openai/embedding-provider.d.ts +1 -1
- package/dist/extensions/openai/index.d.ts +1 -1
- package/dist/extensions/openai/memory-embedding-adapter.d.ts +1 -1
- package/dist/extensions/openai/openai-codex-oauth.runtime.d.ts +1 -1
- package/dist/extensions/openai/openai-codex-provider.d.ts +1 -1
- package/dist/extensions/openai/openai-provider.d.ts +1 -1
- package/dist/extensions/openai/prompt-overlay.d.ts +1 -1
- package/dist/extensions/openai/provider-contract-api.d.ts +1 -1
- package/dist/extensions/openai/provider-policy-api.d.ts +1 -1
- package/dist/extensions/openai/realtime-transcription-provider.d.ts +1 -1
- package/dist/extensions/openai/realtime-voice-provider.d.ts +1 -1
- package/dist/extensions/openai/register.runtime.d.ts +6 -6
- package/dist/extensions/openai/replay-policy.d.ts +1 -1
- package/dist/extensions/openai/setup-api.d.ts +1 -1
- package/dist/extensions/openai/shared.d.ts +3 -3
- package/dist/extensions/openai/speech-provider.d.ts +1 -1
- package/dist/extensions/openai/test-api.d.ts +3 -3
- package/dist/extensions/openai/thinking-policy.d.ts +1 -1
- package/dist/extensions/openai/transport-policy.d.ts +1 -1
- package/dist/extensions/opencode/index.d.ts +1 -1
- package/dist/extensions/opencode/provider-policy-api.d.ts +1 -1
- package/dist/extensions/opencode-go/index.d.ts +1 -1
- package/dist/extensions/opencode-go/provider-catalog.d.ts +1 -1
- package/dist/extensions/opencode-go/stream.d.ts +1 -1
- package/dist/extensions/openrouter/api.d.ts +1 -1
- package/dist/extensions/openrouter/index.d.ts +1 -1
- package/dist/extensions/openrouter/provider-contract-api.d.ts +1 -1
- package/dist/extensions/openrouter/provider-policy-api.d.ts +1 -1
- package/dist/extensions/openrouter/speech-provider.d.ts +1 -1
- package/dist/extensions/openrouter/stream.d.ts +1 -1
- package/dist/extensions/openrouter/test-api.d.ts +1 -1
- package/dist/extensions/openrouter/thinking-policy.d.ts +1 -1
- package/dist/extensions/openrouter/video-generation-provider.d.ts +1 -1
- package/dist/extensions/openrouter/video-model-catalog.d.ts +1 -1
- package/dist/extensions/perplexity/index.d.ts +1 -1
- package/dist/extensions/phone-control/index.d.ts +1 -1
- package/dist/extensions/phone-control/runtime-api.d.ts +2 -2
- package/dist/extensions/policy/api.js +1 -1
- package/dist/extensions/policy/index.d.ts +1 -1
- package/dist/extensions/policy/index.js +2 -2
- package/dist/extensions/qianfan/index.d.ts +1 -1
- package/dist/extensions/qwen/api.d.ts +1 -1
- package/dist/extensions/qwen/index.d.ts +1 -1
- package/dist/extensions/qwen/stream.d.ts +1 -1
- package/dist/extensions/runway/index.d.ts +1 -1
- package/dist/extensions/searxng/index.d.ts +1 -1
- package/dist/extensions/senseaudio/index.d.ts +1 -1
- package/dist/extensions/sglang/index.d.ts +1 -1
- package/dist/extensions/signal/api.d.ts +3 -3
- package/dist/extensions/signal/api.js +6 -6
- package/dist/extensions/signal/channel-entry.d.ts +2 -2
- package/dist/extensions/signal/channel-plugin-api.d.ts +1 -1
- package/dist/extensions/signal/channel-plugin-api.js +1 -1
- package/dist/extensions/signal/index.d.ts +2 -2
- package/dist/extensions/signal/reaction-runtime-api.js +1 -1
- package/dist/extensions/signal/runtime-api.d.ts +7 -7
- package/dist/extensions/signal/runtime-api.js +7 -7
- package/dist/extensions/signal/setup-entry.d.ts +2 -2
- package/dist/extensions/skill-workshop/api.d.ts +2 -2
- package/dist/extensions/skill-workshop/api.js +1 -1
- package/dist/extensions/skill-workshop/index.d.ts +1 -1
- package/dist/extensions/skill-workshop/index.js +2 -2
- package/dist/extensions/speech-core/api.d.ts +3 -3
- package/dist/extensions/speech-core/runtime-api.d.ts +2 -2
- package/dist/extensions/stepfun/index.d.ts +1 -1
- package/dist/extensions/synthetic/index.d.ts +1 -1
- package/dist/extensions/talk-voice/api.d.ts +2 -2
- package/dist/extensions/talk-voice/index.d.ts +1 -1
- package/dist/extensions/tavily/index.d.ts +1 -1
- package/dist/extensions/telegram/account-inspect-api.js +1 -1
- package/dist/extensions/telegram/api.d.ts +4 -4
- package/dist/extensions/telegram/api.js +11 -11
- package/dist/extensions/telegram/channel-plugin-api.d.ts +2 -2
- package/dist/extensions/telegram/channel-plugin-api.js +2 -2
- package/dist/extensions/telegram/contract-api.d.ts +1 -1
- package/dist/extensions/telegram/contract-api.js +3 -3
- package/dist/extensions/telegram/index.d.ts +2 -2
- package/dist/extensions/telegram/runtime-api.d.ts +4 -4
- package/dist/extensions/telegram/runtime-api.js +7 -7
- package/dist/extensions/telegram/security-audit-contract-api.js +1 -1
- package/dist/extensions/telegram/setup-entry.d.ts +2 -2
- package/dist/extensions/telegram/setup-plugin-api.d.ts +1 -1
- package/dist/extensions/telegram/setup-plugin-api.js +1 -1
- package/dist/extensions/telegram/test-api.js +2 -2
- package/dist/extensions/tencent/index.d.ts +1 -1
- package/dist/extensions/tencent/provider-discovery.d.ts +1 -1
- package/dist/extensions/thread-ownership/api.d.ts +2 -2
- package/dist/extensions/thread-ownership/index.d.ts +1 -1
- package/dist/extensions/together/index.d.ts +1 -1
- package/dist/extensions/tokenjuice/index.d.ts +1 -1
- package/dist/extensions/tokenjuice/tool-result-middleware.d.ts +1 -1
- package/dist/extensions/tts-local-cli/index.d.ts +1 -1
- package/dist/extensions/tts-local-cli/speech-provider.d.ts +1 -1
- package/dist/extensions/venice/index.d.ts +1 -1
- package/dist/extensions/venice/stream.d.ts +1 -1
- package/dist/extensions/vercel-ai-gateway/index.d.ts +1 -1
- package/dist/extensions/vercel-ai-gateway/thinking.d.ts +1 -1
- package/dist/extensions/video-generation-core/api.d.ts +3 -3
- package/dist/extensions/video-generation-core/runtime-api.d.ts +1 -1
- package/dist/extensions/vllm/api.d.ts +1 -1
- package/dist/extensions/vllm/index.d.ts +1 -1
- package/dist/extensions/vllm/stream.d.ts +1 -1
- package/dist/extensions/volcengine/index.d.ts +1 -1
- package/dist/extensions/volcengine/provider-discovery.d.ts +1 -1
- package/dist/extensions/volcengine/speech-provider.d.ts +1 -1
- package/dist/extensions/voyage/embedding-batch.d.ts +1 -1
- package/dist/extensions/voyage/embedding-provider.d.ts +1 -1
- package/dist/extensions/voyage/index.d.ts +1 -1
- package/dist/extensions/voyage/memory-embedding-adapter.d.ts +1 -1
- package/dist/extensions/vydra/index.d.ts +1 -1
- package/dist/extensions/vydra/speech-provider.d.ts +1 -1
- package/dist/extensions/web-readability/index.d.ts +1 -1
- package/dist/extensions/webhooks/api.d.ts +2 -2
- package/dist/extensions/webhooks/api.js +1 -1
- package/dist/extensions/webhooks/index.d.ts +1 -1
- package/dist/extensions/webhooks/index.js +1 -1
- package/dist/extensions/webhooks/runtime-api.d.ts +2 -2
- package/dist/extensions/xai/api.d.ts +1 -1
- package/dist/extensions/xai/index.d.ts +1 -1
- package/dist/extensions/xai/index.js +4 -4
- package/dist/extensions/xai/provider-contract-api.d.ts +1 -1
- package/dist/extensions/xai/provider-discovery.d.ts +1 -1
- package/dist/extensions/xai/provider-models.d.ts +1 -1
- package/dist/extensions/xai/provider-policy-api.d.ts +1 -1
- package/dist/extensions/xai/realtime-transcription-provider.d.ts +1 -1
- package/dist/extensions/xai/realtime-transcription-provider.js +1 -1
- package/dist/extensions/xai/setup-api.d.ts +1 -1
- package/dist/extensions/xai/speech-provider.d.ts +1 -1
- package/dist/extensions/xai/speech-provider.js +1 -1
- package/dist/extensions/xai/stream.d.ts +1 -1
- package/dist/extensions/xai/test-api.js +1 -1
- package/dist/extensions/xai/tts.js +1 -1
- package/dist/extensions/xai/web-search.js +1 -1
- package/dist/extensions/xai/xai-oauth.d.ts +1 -1
- package/dist/extensions/xai/xai-oauth.js +1 -1
- package/dist/extensions/xiaomi/index.d.ts +1 -1
- package/dist/extensions/xiaomi/speech-provider.d.ts +1 -1
- package/dist/extensions/xiaomi/stream.d.ts +1 -1
- package/dist/extensions/xiaomi/thinking.d.ts +1 -1
- package/dist/extensions/zai/index.d.ts +1 -1
- package/dist/file-fetch-tool-smMykVXl.js +124 -0
- package/dist/file-write-tool-yEYLZ2hU.js +127 -0
- package/dist/format-DyREJP5V.js +1145 -0
- package/dist/gateway/protocol/index.d.ts +1 -1
- package/dist/gateway-cli-D4yhwJa8.js +435 -0
- package/dist/gateway-method-runtime-B8AOnwqD.js +21 -0
- package/dist/gateway-runtime-BqKz92h9.d.ts +163 -0
- package/dist/gemini-cli-provider-wUxyeRzT.d.ts +6 -0
- package/dist/get-reply-Co-_Qlr-.js +4689 -0
- package/dist/get-reply-from-config.runtime-BcbRKxzJ.js +2 -0
- package/dist/get-reply-from-config.runtime.js +1 -1
- package/dist/graph-users-CF7Dlee2.js +1419 -0
- package/dist/group-access-BTU-w5S5.js +112 -0
- package/dist/group-keys-B_lbVBmI.d.ts +17 -0
- package/dist/handle-action.guild-admin-DS29y_6h.js +288 -0
- package/dist/harness-d9YmZWA3.js +61 -0
- package/dist/health-Cov1Kryj.js +4 -0
- package/dist/heartbeat-runner-B2wo_xDj.js +5 -0
- package/dist/heartbeat-runner.runtime-DrHZD-P2.js +4 -0
- package/dist/heartbeat-runner.runtime.js +1 -1
- package/dist/help-BgDd1atJ.js +136 -0
- package/dist/hook-runtime-UU80d5qW.d.ts +108 -0
- package/dist/hooks-CgXKCJSD.js +534 -0
- package/dist/http-registry-CBDAGRJy.d.ts +23 -0
- package/dist/image-generation-runtime-BFOnMPYD.d.ts +21 -0
- package/dist/inbound-direct-dm-runtime-DjOHl6c_.js +2 -0
- package/dist/inbound-reply-dispatch-BCTiM2jm.js +148 -0
- package/dist/index-D7Vsu6c4.d.ts +3971 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/init-CreYGHpp.js +59 -0
- package/dist/inline-buttons-C94TOhmL.js +40 -0
- package/dist/interactive-dispatch-AIMj_vt7.d.ts +143 -0
- package/dist/interactive-dispatch-Bh_T3uZG.d.ts +56 -0
- package/dist/internal-events-B6D5bqsn.js +90 -0
- package/dist/isolated-agent-9faqxl7c.js +1118 -0
- package/dist/isolated-agent-CaY4uTcE.js +2 -0
- package/dist/lifecycle-pTz4liUn.js +571 -0
- package/dist/list.probe-B8pt-DOd.js +449 -0
- package/dist/list.status-command-Wgmt361J.js +789 -0
- package/dist/llm-slug-generator-Do4oXnXl.js +78 -0
- package/dist/llm-slug-generator.js +1 -1
- package/dist/loader-BFBzvUK_.d.ts +142 -0
- package/dist/local-dispatch.runtime-7keeuHHm.js +9 -0
- package/dist/local-dispatch.runtime.js +1 -1
- package/dist/manager-D058VQAp.d.ts +10 -0
- package/dist/manager-DerRaxsV.d.ts +356 -0
- package/dist/manager.core-DKeUsAcV.d.ts +198 -0
- package/dist/manager.runtime-B3nVh8Nl.js +2714 -0
- package/dist/manager.runtime.js +1 -1
- package/dist/markdown-to-line-CZLeX0SL.js +811 -0
- package/dist/mcp-http-LaAmzBev.js +2 -0
- package/dist/mcp-http-M4GjuKFd.js +555 -0
- package/dist/media-understanding-provider-DLA6VsQZ.js +339 -0
- package/dist/memory-core-host-engine-storage-MF-67Z8w.d.ts +54 -0
- package/dist/memory-embedding-adapter-CEwgurWU.d.ts +5 -0
- package/dist/message-actions-Dlv-B5yk.js +145 -0
- package/dist/message-handler-2HSbEoAi.js +384 -0
- package/dist/message-handler-XiApv_iS.js +1715 -0
- package/dist/message-handler.preflight-CN-g4nxs.js +1125 -0
- package/dist/message-handler.process-BzVq3Lq_.js +1484 -0
- package/dist/migration-BXmTbRk9.d.ts +45 -0
- package/dist/model-Ci5kQ7PA.d.ts +33 -0
- package/dist/model-Sqz99RFi.js +74 -0
- package/dist/model-selection-Bh9QtqlJ.js +272 -0
- package/dist/models-C_dD1FNN.js +2 -0
- package/dist/models-CtpB-fi2.js +104 -0
- package/dist/models-Cxa7r3rl.d.ts +24 -0
- package/dist/models-cli-I2sJE5tg.js +256 -0
- package/dist/monitor-B4J6Kn4-.js +60 -0
- package/dist/monitor-BIFxJ3Ql.js +2788 -0
- package/dist/monitor-BTkcXHvw.js +834 -0
- package/dist/monitor-BX7Encm5.js +1657 -0
- package/dist/monitor-CZsJ4D3J.js +4377 -0
- package/dist/monitor-CvKt9k7P.js +2 -0
- package/dist/monitor-Dy9phiVJ.js +1370 -0
- package/dist/monitor-auth-CjtJPc9C.js +179 -0
- package/dist/monitor-jQpVHEky.js +715 -0
- package/dist/monitor-polling.runtime-Li4-3e2G.js +883 -0
- package/dist/monitor-polling.runtime.js +1 -1
- package/dist/monitor-webhook.runtime-CQ2kN5ya.js +387 -0
- package/dist/monitor-webhook.runtime.js +1 -1
- package/dist/monitor.account-CFdazLEm.js +5233 -0
- package/dist/monitor.runtime-B774iFU_.js +2 -0
- package/dist/monitor.runtime.js +1 -1
- package/dist/monitor.webhook-NNrWA5P9.js +180 -0
- package/dist/node-cli-sessions-Ct-6bGab.js +1228 -0
- package/dist/onboard-DEUA1HCQ.js +733 -0
- package/dist/onboard-helpers-Cupkjkec.js +251 -0
- package/dist/onboard-helpers-D1Pvowo1.js +6 -0
- package/dist/onboard-remote-BN_7wNqG.js +2 -0
- package/dist/onboard-remote-BqYAK5dF.js +212 -0
- package/dist/onboard-skills-BM40qOkc.js +160 -0
- package/dist/onboard-skills-rSLgDOzB.js +2 -0
- package/dist/openai-codex-provider-Fo-TKiyf.d.ts +5 -0
- package/dist/openai-http-BRnxRJ_y.js +824 -0
- package/dist/openai-provider-BqDrspuV.d.ts +5 -0
- package/dist/openresponses-http-Dg3OL0qA.js +1173 -0
- package/dist/operations-jvr0A8cu.js +805 -0
- package/dist/outbound-adapter-BJej9JpO.js +543 -0
- package/dist/outbound-session-route-D3QVwFKr.js +45 -0
- package/dist/outbound.runtime-gdOoPtOh.js +2 -0
- package/dist/outbound.runtime.js +1 -1
- package/dist/pairing-store-C-WQTUHq.d.ts +87 -0
- package/dist/pi-embedded-CwD_xrGP.js +3796 -0
- package/dist/pi-embedded-DL6l8KBl.js +4 -0
- package/dist/pi-embedded.runtime-DyGCj24d.js +4 -0
- package/dist/pi-embedded.runtime.js +1 -1
- package/dist/pi-tools-BzbgexEG.js +2413 -0
- package/dist/plan-HWBV2Rhq.js +112 -0
- package/dist/plan-iN77JYw-.js +81 -0
- package/dist/plugin-BbOOGgCS.d.ts +17 -0
- package/dist/plugin-CbNvjum_.js +12396 -0
- package/dist/plugin-app-cache-key-CHpwYM0e.js +46 -0
- package/dist/plugin-enabled-DjbDhNRG.js +233 -0
- package/dist/plugin-entry-B3_M6paP.d.ts +47 -0
- package/dist/plugin-registration-BM_Iko3e.js +88 -0
- package/dist/plugin-runtime-QzTPitsy.d.ts +117 -0
- package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
- package/dist/plugin-sdk/acp-runtime-backend.js +1 -1
- package/dist/plugin-sdk/acp-runtime.js +2 -2
- package/dist/plugin-sdk/agent-harness-runtime.js +6 -6
- package/dist/plugin-sdk/agent-harness-task-runtime.js +1 -1
- package/dist/plugin-sdk/agent-harness.js +7 -7
- package/dist/plugin-sdk/agent-runtime.js +2 -2
- package/dist/plugin-sdk/channel-core.js +2 -2
- package/dist/plugin-sdk/channel-inbound.js +2 -2
- package/dist/plugin-sdk/channel-test-helpers.js +1 -1
- package/dist/plugin-sdk/command-auth.js +1 -1
- package/dist/plugin-sdk/command-status-runtime.js +1 -1
- package/dist/plugin-sdk/compat.js +1 -1
- package/dist/plugin-sdk/conversation-binding-runtime.js +2 -2
- package/dist/plugin-sdk/conversation-runtime.js +3 -3
- package/dist/plugin-sdk/core.js +2 -2
- package/dist/plugin-sdk/direct-dm.js +1 -1
- package/dist/plugin-sdk/gateway-method-runtime.js +1 -1
- package/dist/plugin-sdk/health.js +2 -2
- package/dist/plugin-sdk/inbound-reply-dispatch.js +1 -1
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/mattermost.js +1 -1
- package/dist/plugin-sdk/plugin-test-contracts.js +2 -2
- package/dist/plugin-sdk/provider-test-contracts.js +4 -4
- package/dist/plugin-sdk/reply-runtime.js +4 -4
- package/dist/plugin-sdk/testing.js +2 -2
- package/dist/plugin-sdk/zalouser.js +1 -1
- package/dist/plugin-service-CVyMm03C.js +1229 -0
- package/dist/plugin-service-bHD8oLfO.d.ts +24 -0
- package/dist/plugins/build-smoke-entry.d.ts +2 -2
- package/dist/plugins/loader.d.ts +1 -1
- package/dist/plugins/provider-discovery.runtime.d.ts +1 -1
- package/dist/plugins/provider-runtime.runtime.d.ts +1 -1
- package/dist/plugins/runtime/index.js +4 -4
- package/dist/policy-B2lTxn8H.js +680 -0
- package/dist/policy-Bp9GYcSZ.js +138 -0
- package/dist/prepare.runtime-CxhQeo9l.js +732 -0
- package/dist/prepare.runtime.js +1 -1
- package/dist/preview-warnings-FVRS7Mcs.js +392 -0
- package/dist/probe-BRLc43oX.js +47 -0
- package/dist/probe-C1eD9yG7.js +2204 -0
- package/dist/probe-C1giMJtz.js +682 -0
- package/dist/probe-rIUNPFef.js +2 -0
- package/dist/program-DfIqBXRH.js +131 -0
- package/dist/prompt-overlay-Bq3sUpDV.d.ts +23 -0
- package/dist/provider-BCxvG42s.js +152 -0
- package/dist/provider-BHPMcHk-.js +32 -0
- package/dist/provider-CIAQ8D7q.js +32 -0
- package/dist/provider-api-key-auth-BsEQw2pm.d.ts +27 -0
- package/dist/provider-auth-result-B204hPXB.d.ts +21 -0
- package/dist/provider-catalog-runtime-Dcyw8skT.d.ts +23 -0
- package/dist/provider-catalog-shared-qfgsIQS-.d.ts +62 -0
- package/dist/provider-dispatcher-DyJDef6y.js +22 -0
- package/dist/provider-dispatcher.runtime.js +1 -1
- package/dist/provider-hook-runtime-NiAPyKFa.d.ts +61 -0
- package/dist/provider-j7cYms68.js +8735 -0
- package/dist/provider-model-shared-BwE02tDa.d.ts +143 -0
- package/dist/provider-models-hfm5XTTN.d.ts +12 -0
- package/dist/provider-policy-BB7uTrIp.d.ts +30 -0
- package/dist/provider-registration-DEjYSu9M.d.ts +6 -0
- package/dist/provider-registry-D5hn-VAM.d.ts +8 -0
- package/dist/provider-registry-DHIsMEbc.d.ts +8 -0
- package/dist/provider-registry-VyHjmzoh.d.ts +30 -0
- package/dist/provider-runtime-CdtuIOgf.d.ts +359 -0
- package/dist/provider-self-hosted-setup-xR0Nsu7L.d.ts +74 -0
- package/dist/provider-session.runtime-CmNY15Mr.js +9 -0
- package/dist/provider-session.runtime.js +1 -1
- package/dist/provider-stream-CxVko1CO.d.ts +140 -0
- package/dist/provider-stream-shared-BxFPKFGe.d.ts +128 -0
- package/dist/provider.runtime-DJO3dwrX.js +2 -0
- package/dist/provider.runtime.js +1 -1
- package/dist/providers.runtime-CJOUbS2S.d.ts +25 -0
- package/dist/public-surface-loader-CgBnme5n.js +114 -0
- package/dist/pw-ai-UeRWGzcL.js +3029 -0
- package/dist/pw-role-snapshot-BtlutwlO.js +333 -0
- package/dist/reaction-level-DWOV-qJM.js +19 -0
- package/dist/reaction-runtime-api-5ZiPcbGJ.js +116 -0
- package/dist/realtime-transcription-CZadifvk.d.ts +43 -0
- package/dist/realtime-transcription-provider-BF9HxM3d.d.ts +5 -0
- package/dist/realtime-transcription-provider-Bcj92hEI.d.ts +32 -0
- package/dist/realtime-transcription-provider-DKZ9iHkc.d.ts +28 -0
- package/dist/realtime-transcription-provider-DcsAmQEp.js +205 -0
- package/dist/realtime-transcription-provider-DhjVTTqb.d.ts +37 -0
- package/dist/realtime-voice-B2W34yTP.d.ts +333 -0
- package/dist/realtime-voice-provider-CgNNrGwQ.d.ts +5 -0
- package/dist/register-Dga1nJRL.js +2178 -0
- package/dist/register.agent-VIgyZLKG.js +156 -0
- package/dist/register.configure-C21zJ4Qb.js +16 -0
- package/dist/register.crestodian-Bam6mUXr.js +24 -0
- package/dist/register.maintenance-D9E-Hh90.js +83 -0
- package/dist/register.onboard-BnUcaZsb.js +113 -0
- package/dist/register.runtime-BdRAp4xz.js +54 -0
- package/dist/register.runtime-D3abILg7.d.ts +6 -0
- package/dist/register.setup-Bq-9IQdV.js +40 -0
- package/dist/register.subclis-DubBtg8Z.js +31 -0
- package/dist/register.subclis-H_qmmDFx.js +3 -0
- package/dist/register.subclis-core-fg3DalSH.js +273 -0
- package/dist/registry-CPtiHUu_.d.ts +91 -0
- package/dist/registry-types-XtFJDNYl.d.ts +392 -0
- package/dist/repair-sequencing-Dn0sDvBE.js +640 -0
- package/dist/reply-delivery-DZGfRh-W.js +196 -0
- package/dist/reply-runtime-BdCPL-OF.js +11 -0
- package/dist/reply-runtime-DuaOZ9MH.d.ts +34 -0
- package/dist/reply.runtime-BcbRKxzJ.js +2 -0
- package/dist/reply.runtime.js +1 -1
- package/dist/request-Ca681Kt1.js +54 -0
- package/dist/resolve-allowlist-DWjCzDq1.js +220 -0
- package/dist/result-fallback-classifier-BWIh0wzc.js +79 -0
- package/dist/root-help-8a3TWleF.js +43 -0
- package/dist/route-BsWREv6-.js +469 -0
- package/dist/route-resolution-D8FyF30I.js +274 -0
- package/dist/routes-BxkaJuyM.js +3602 -0
- package/dist/routes-DdwFgSv9.js +2 -0
- package/dist/run-attempt-Ca7HP1Nd.js +7704 -0
- package/dist/run-command-JwrnqCIB.js +2 -0
- package/dist/run-command-wWvfXyIf.js +23 -0
- package/dist/run-embedded.runtime-0QIAc8PG.js +4 -0
- package/dist/run-embedded.runtime.js +1 -1
- package/dist/run-execution-cli.runtime-LhD-S0h_.js +4 -0
- package/dist/run-execution-cli.runtime.js +1 -1
- package/dist/run-executor.runtime.js +1 -1
- package/dist/run-prKMVvM2.js +1162 -0
- package/dist/run-subagent-registry.runtime-C07jSlV2.js +2 -0
- package/dist/run-subagent-registry.runtime.js +1 -1
- package/dist/runtime-3PDZU_1b.d.ts +17 -0
- package/dist/runtime-7Xhj2T8S.js +6179 -0
- package/dist/runtime-CXUwJU3q.js +438 -0
- package/dist/runtime-DeQypuDs.js +1287 -0
- package/dist/runtime-api-0djTIsuz.js +13 -0
- package/dist/runtime-api-9CEihqK3.d.ts +3151 -0
- package/dist/runtime-api-Bz1h0p3i.js +17 -0
- package/dist/runtime-api-CLcJZKu2.js +13 -0
- package/dist/runtime-api-Ce7axAAW.js +24 -0
- package/dist/runtime-api-CoAsju8a.js +4 -0
- package/dist/runtime-api-DEuynhDr.js +3 -0
- package/dist/runtime-api-oZFIOS9l.js +21 -0
- package/dist/runtime-api.actions-Blt2bAHw.d.ts +23 -0
- package/dist/runtime-api.actions-DWLRlSej.js +3 -0
- package/dist/runtime-api.monitor-DtXB3_sf.js +6 -0
- package/dist/runtime-api.send-BU586hbs.js +4 -0
- package/dist/runtime-api.send-BygcWA7R.d.ts +38 -0
- package/dist/runtime-api.threads-Djhr5AJy.js +2 -0
- package/dist/runtime-channel-BIgBTs_X.js +2 -0
- package/dist/runtime-channel-CsUTBjYU.js +150 -0
- package/dist/runtime-embedded-pi.runtime-Rszd_KCt.js +2 -0
- package/dist/runtime-embedded-pi.runtime.js +1 -1
- package/dist/runtime-taskflow-s80xQc2H.d.ts +435 -0
- package/dist/sanitize-outbound-2umQeW_U.js +127 -0
- package/dist/sdk-setup-tools-TiaNam05.js +8 -0
- package/dist/secrets-BmyFSkt-.js +113 -0
- package/dist/secrets-cli-DPAwFvtH.js +149 -0
- package/dist/security-audit-BR9FBcLD.js +122 -0
- package/dist/security-audit-RKut1lWG.js +118 -0
- package/dist/security-audit.runtime-Pe7YbS9P.js +2 -0
- package/dist/security-audit.runtime.js +1 -1
- package/dist/selection-Cqhmjpyl.js +16157 -0
- package/dist/selection-xFFMaq92.js +3 -0
- package/dist/send-BDHagrwl.js +1631 -0
- package/dist/send-BETlETJ5.d.ts +231 -0
- package/dist/send-BV_O_Ljd.js +192 -0
- package/dist/send-CpcmWYrM.d.ts +104 -0
- package/dist/send-W-DVyil6.js +2 -0
- package/dist/send-jUp2-szO.js +143 -0
- package/dist/send.components-BR_yPtKv.js +500 -0
- package/dist/send.components-CK7UbpRP.js +2 -0
- package/dist/send.runtime-DHLfdHbS.js +2 -0
- package/dist/send.runtime.js +1 -1
- package/dist/send.types-D_3tsfSL.d.ts +159 -0
- package/dist/server-DRcdRu6J.js +73 -0
- package/dist/server-Ddv-oAKv.js +24 -0
- package/dist/server-close.runtime.d.ts +1 -1
- package/dist/server-close.runtime.js +1 -1
- package/dist/server-context-9rW0Cvdw.js +2 -0
- package/dist/server-context-uRD5N8_D.js +955 -0
- package/dist/server-cron-BClEPtbv.js +2 -0
- package/dist/server-cron-CNGar45o.js +2989 -0
- package/dist/server-methods-CAMhJf7g.js +16494 -0
- package/dist/server-node-events-DW5DoAxk.js +596 -0
- package/dist/server-plugin-bootstrap-CqX4dDcN.js +70 -0
- package/dist/server-plugins-BIhs3eCz.js +432 -0
- package/dist/server-reload-handlers-54HSfSr7.js +714 -0
- package/dist/server-restart-sentinel-C47-O08k.js +747 -0
- package/dist/server-restart-sentinel-Cx-3Rzl0.js +2 -0
- package/dist/server-runtime-services-D-SWzUww.js +267 -0
- package/dist/server-runtime-services-D0GOFPFq.js +2 -0
- package/dist/server-startup-plugins-C8pzVvkb.js +113 -0
- package/dist/server-startup-post-attach-2xoGJJts.js +716 -0
- package/dist/server-ws-runtime-Dywo6GC-.js +349 -0
- package/dist/server.impl-xK22fZyJ.js +2586 -0
- package/dist/service-Ci8roOZn.js +1446 -0
- package/dist/session-binding-BsdbGBhb.js +219 -0
- package/dist/session-binding-D42jROcb.js +2 -0
- package/dist/session-kill-http-kU4rUj1_.js +121 -0
- package/dist/session-reset-service-DkCGElAA.js +625 -0
- package/dist/session-route-hmQSEijy.js +93 -0
- package/dist/session-status.runtime-Dsz-54he.js +2 -0
- package/dist/session-status.runtime.js +1 -1
- package/dist/session-subagent-reactivation.runtime-CYJIkiW8.js +2 -0
- package/dist/session-subagent-reactivation.runtime.js +1 -1
- package/dist/session-tab-registry-YfQve--K.js +521 -0
- package/dist/sessions-history-http-DeuZSSGj.js +430 -0
- package/dist/sessions.runtime-wAccC8Lk.js +2 -0
- package/dist/sessions.runtime.js +1 -1
- package/dist/setup-B8caUFIZ.js +586 -0
- package/dist/setup-CgHGdMpV.js +2 -0
- package/dist/setup-api-Uew7qBry.js +29 -0
- package/dist/setup-core-BP_fjsmA.js +174 -0
- package/dist/setup-onboard-configure-help-fast-path-ykLp2JqU.js +64 -0
- package/dist/setup-surface-BgEGrdZ3.js +320 -0
- package/dist/setup-surface-BvSqsFEu.js +221 -0
- package/dist/setup-surface-CHzMJ7_T.js +405 -0
- package/dist/setup-surface-DYm3Xvgt.js +288 -0
- package/dist/setup.finalize-BgLIjblM.js +582 -0
- package/dist/setup.gateway-config-BBguRpIc.js +281 -0
- package/dist/setup.migration-import-BY06brv-.js +200 -0
- package/dist/setup.migration-import-Igj5NMey.js +2 -0
- package/dist/shared-client-GL2KQ2Eu.js +2 -0
- package/dist/shared-client-Mc7bTBoQ.js +629 -0
- package/dist/shared-moi7PK0C.js +121 -0
- package/dist/shared-rlOyTpAw.d.ts +115 -0
- package/dist/side-question-BEHswpGw.js +683 -0
- package/dist/simple-completion-runtime-CsXJkjY5.d.ts +73 -0
- package/dist/skill-tool-dispatch.runtime-O5uXeees.js +143 -0
- package/dist/skill-tool-dispatch.runtime.js +1 -1
- package/dist/slash-state-BAYUTcHl.js +2166 -0
- package/dist/speech-BAP4NgqI.d.ts +47 -0
- package/dist/speech-core-DZmhKq_b.d.ts +36 -0
- package/dist/speech-provider-22oDk8Tz.js +184 -0
- package/dist/speech-provider-79S_bTlE.d.ts +8 -0
- package/dist/speech-provider-BYJna1nq.d.ts +5 -0
- package/dist/speech-provider-BvKhsuyg.d.ts +5 -0
- package/dist/speech-provider-CdVIHtT6.d.ts +5 -0
- package/dist/speech-provider-OiRKJFwo.d.ts +8 -0
- package/dist/speech-provider-xUDd1kmD.d.ts +34 -0
- package/dist/src-C8wkJgE6.js +4256 -0
- package/dist/startup-context-BhLJufFU.js +313 -0
- package/dist/status-C20LHDLA.js +73 -0
- package/dist/status-message-CmzgS8zM.js +484 -0
- package/dist/status-message.runtime-iG6qi7wn.js +6 -0
- package/dist/status-message.runtime.js +1 -1
- package/dist/status-subagents.runtime-D49P_RIr.js +18 -0
- package/dist/status-subagents.runtime.js +1 -1
- package/dist/status-text-BI7Q1z4U.js +296 -0
- package/dist/status.runtime-RQes0TI5.js +2 -0
- package/dist/sticker-cache-Dh4joqan.js +206 -0
- package/dist/sticker-vision.runtime-5SRgpo_k.js +17 -0
- package/dist/sticker-vision.runtime.js +1 -1
- package/dist/stream-BrMwI7HV.d.ts +10 -0
- package/dist/stream-Bx_akKgo.d.ts +16 -0
- package/dist/stream-D094UIVI.d.ts +5 -0
- package/dist/stream-D5DoOmTT.d.ts +19 -0
- package/dist/stream-Tt9cSOCl.d.ts +120 -0
- package/dist/stream-wrappers-CUkNtyZK.d.ts +21 -0
- package/dist/subagent-announce-BEPlkjCS.js +354 -0
- package/dist/subagent-announce-delivery-jcxPIfNG.js +958 -0
- package/dist/subagent-control-DdMWVJXs.js +508 -0
- package/dist/subagent-hooks-BsTVb6ur.js +2 -0
- package/dist/subagent-hooks-CBlMBrss.js +2 -0
- package/dist/subagent-hooks-Ch5oDUxb.js +116 -0
- package/dist/subagent-hooks-DmUeAwY3.js +146 -0
- package/dist/subagent-hooks-PNuPbYEl.js +2 -0
- package/dist/subagent-hooks-api-BQ051dF0.js +23 -0
- package/dist/subagent-hooks-api-DcVS0aJZ.js +22 -0
- package/dist/subagent-hooks-api-Dlbc5Mtd.js +23 -0
- package/dist/subagent-hooks-dwsegI07.js +230 -0
- package/dist/subagent-orphan-recovery-Cl_y6Poi.js +352 -0
- package/dist/subagent-registry-BVVgDSdq.d.ts +1 -0
- package/dist/subagent-registry-BosUdBW6.js +2351 -0
- package/dist/subagent-registry-Bxd6vaAO.js +3 -0
- package/dist/subagent-registry-read-BVVgDSdq.d.ts +1 -0
- package/dist/subagent-registry.runtime.js +1 -1
- package/dist/subagent-session-cleanup-Bd6d93qi.js +525 -0
- package/dist/subagent-spawn-ViO3XAR1.js +1164 -0
- package/dist/target-id-Bje_v2Ax.js +107 -0
- package/dist/targets-9q_q5M9n.d.ts +10 -0
- package/dist/targets-C4byiOgQ.js +19 -0
- package/dist/targets-J0MVE-dD.js +44 -0
- package/dist/targets-ZMEvyNa8.js +19 -0
- package/dist/targets-qBcfKetP.d.ts +10 -0
- package/dist/task-registry-control.runtime.d.ts +1 -1
- package/dist/task-registry-control.runtime.js +1 -1
- package/dist/telegram/token.js +1 -1
- package/dist/testing-Dk757Ggg.js +267 -0
- package/dist/thinking-policy-DO6T8IfK.d.ts +5 -0
- package/dist/thread-bindings-CYrmTzFY.js +232 -0
- package/dist/thread-bindings-Cf7fkXxk.js +571 -0
- package/dist/thread-bindings-DI6LNGbW.js +8 -0
- package/dist/thread-bindings-DdmuKtVD.js +228 -0
- package/dist/thread-bindings.discord-api-C01V3kFk.js +187 -0
- package/dist/thread-bindings.manager--WOGVrL-.js +2 -0
- package/dist/thread-bindings.manager-HzjqZNiL.js +536 -0
- package/dist/thread-lifecycle-CJKTxWnQ.js +1614 -0
- package/dist/token-D-FQ8AQz.js +134 -0
- package/dist/tool-DTCfs0DU.js +139 -0
- package/dist/tool-actions.runtime-Cb3iA3Os.js +534 -0
- package/dist/tool-actions.runtime.js +1 -1
- package/dist/tool-plugin-CbbLM31f.d.ts +77 -0
- package/dist/tool-resolution-CbqzNutV.js +149 -0
- package/dist/tool-split-bLqMPHTZ.d.ts +19 -0
- package/dist/tools-effective-inventory-BsAax-ML.js +204 -0
- package/dist/tools-invoke-http-DAqZxikd.js +67 -0
- package/dist/tools-invoke-shared-CsVRemTL.js +200 -0
- package/dist/transport-stream-DOXZsjVL.d.ts +42 -0
- package/dist/tts-Ckj6MJNr.js +66 -0
- package/dist/tui-CwwCXMCq.js +2 -0
- package/dist/tui-DpJn3v2D.js +4709 -0
- package/dist/tui-backend-DQ9wF5es.js +256 -0
- package/dist/tui-cli-k3AYPBn3.js +37 -0
- package/dist/types--0xYmMG9.d.ts +786 -0
- package/dist/types-CMDl9l_P2.d.ts +3650 -0
- package/dist/types.public-DvhPzYJi.d.ts +70 -0
- package/dist/update-cli-DB5Doqld.js +3664 -0
- package/dist/video-generation-runtime-CTQN-4SI.d.ts +21 -0
- package/dist/video-model-catalog-CTyt4dXa.d.ts +16 -0
- package/dist/vision-tools-Dp0JrLRi.js +1409 -0
- package/dist/web-search-B0yvxuiq.js +62 -0
- package/dist/web-search-provider.runtime-B-cNT-5J.js +2 -0
- package/dist/web-search-provider.runtime-HhmIlk_Z.js +328 -0
- package/dist/web-search-provider.runtime.js +1 -1
- package/dist/webhook-targets-3u4hOqRl.d.ts +99 -0
- package/dist/xai-oauth-cZGjnEjh.js +479 -0
- package/dist/xai-user-agent-DA8le6vP.js +32 -0
- package/dist/zod-schema.core-i5HaY1T4.d.ts +166 -0
- package/package.json +1 -1
- package/dist/abort-CvuLeqr1.js +0 -277
- package/dist/abort.runtime-DNoavlKn.js +0 -2
- package/dist/account-inspect-ByX21U_z.js +0 -173
- package/dist/accounts-B0sjdn0w.js +0 -119
- package/dist/accounts-BF_AfTED.js +0 -107
- package/dist/accounts-DX1c8NKM.js +0 -107
- package/dist/accounts-EA2GGTep.js +0 -2
- package/dist/acp-runtime-BC8oA7xM.js +0 -26
- package/dist/acp-spawn-CPYDCZ95.js +0 -2
- package/dist/acp-spawn-Cqi47GCL.js +0 -1275
- package/dist/acp-stateful-target-driver-CcWMRAQ2.js +0 -89
- package/dist/action-kill-CZrPfOIS.js +0 -33
- package/dist/action-runtime-DuhVKLRJ.js +0 -469
- package/dist/action-runtime-api-BKaUWi7b.js +0 -2
- package/dist/action-send-_NpIHMwj.js +0 -39
- package/dist/action-spawn-Dymn4rUo.js +0 -47
- package/dist/actions-Bk_WaEAa.js +0 -161
- package/dist/actions.runtime-Hh7HYOlJ.js +0 -5
- package/dist/agent-CQzGVmy1.js +0 -2
- package/dist/agent-ClmYyW81.js +0 -3
- package/dist/agent-command-D5KxwCVS.d.ts +0 -141
- package/dist/agent-command-DbU2fo-p.js +0 -1367
- package/dist/agent-components.runtime-BpXJmJXk.js +0 -10
- package/dist/agent-harness-D8c6PLE_.d.ts +0 -146
- package/dist/agent-harness-runtime-AHXS4Jj3.d.ts +0 -691
- package/dist/agent-harness-runtime-TzbK9YTz.js +0 -180
- package/dist/agent-harness-task-runtime-CZWJEsKk.js +0 -140
- package/dist/agent-runner-execution-CmHT78Vr.js +0 -1713
- package/dist/agent-runner-utils-B0i1PW18.js +0 -266
- package/dist/agent-runner.runtime-B6Ah_MlB.js +0 -3455
- package/dist/agent-runtime-BOMioAX6.js +0 -229
- package/dist/agent-via-gateway-DfxQCPit.js +0 -463
- package/dist/agents.commands.add-CszEBxoJ.js +0 -304
- package/dist/agents.commands.delete-ulnJ7RH9.js +0 -128
- package/dist/api-6SmEQDkK.js +0 -134
- package/dist/api-B7QdoMF5.js +0 -2
- package/dist/api-BBgby6ck.js +0 -639
- package/dist/api-DwKV-xfM.d.ts +0 -52
- package/dist/api-RfjCqA7Y.js +0 -6
- package/dist/api-VDkFlOiv.js +0 -2
- package/dist/api-We4xoZFr.js +0 -3
- package/dist/apply-Cgtzilem.js +0 -41
- package/dist/apply-Csp3U8cA.js +0 -54
- package/dist/approval-handler.runtime-aQaSBbpF.js +0 -130
- package/dist/assistant-UMyirSUH.js +0 -291
- package/dist/attachment-normalize-BupK-_Ox.js +0 -225
- package/dist/attempt-execution-oLlyFjHk.js +0 -558
- package/dist/attempt-execution.runtime-Cq8RE0x_.js +0 -3
- package/dist/attempt-execution.shared-DyBzUJGB.js +0 -38
- package/dist/attempt.prompt-helpers-CVBP6t5J.js +0 -475
- package/dist/attempt.tool-run-context-UU1BUUC9.js +0 -2094
- package/dist/auth-BDaK_y-g.js +0 -541
- package/dist/banner-VbID973v.js +0 -2
- package/dist/banner-W77piyz6.js +0 -397
- package/dist/binding-routing-DahKvjr3.js +0 -113
- package/dist/binding-targets-C3mqUdUT.js +0 -121
- package/dist/bot-DonUKEuy.js +0 -7894
- package/dist/bot-deps-CroXwZeM.js +0 -747
- package/dist/bot-deps-DKoy3x0l.js +0 -2
- package/dist/bot-message-context.runtime-BI_zyqDu.js +0 -7
- package/dist/bot-message-context.session.runtime-Cpy2H9Ez.js +0 -12
- package/dist/bot-native-commands.delivery.runtime-CsHg3h1O.js +0 -4
- package/dist/bot-native-commands.runtime-rmoBpwZY.js +0 -13
- package/dist/bridge-server-BmDNWgHD.js +0 -113
- package/dist/browser-cli-BQLwmLw3.js +0 -2
- package/dist/browser-cli-CHHIN-of.js +0 -230
- package/dist/browser-cli-actions-input-DBZ7uwag.js +0 -473
- package/dist/browser-cli-actions-observe-BdH2-WTk.js +0 -81
- package/dist/browser-cli-debug-C82Apbgb.js +0 -137
- package/dist/browser-cli-inspect-CrO1qca7.js +0 -104
- package/dist/browser-cli-manage-Dgm1IUZT.js +0 -443
- package/dist/browser-cli-resize-DqgMr3DY.js +0 -26
- package/dist/browser-cli-shared-BTnXMCKA.js +0 -50
- package/dist/browser-cli-state-DT3bVOtg.js +0 -337
- package/dist/browser-control-auth-BRwKCt45.js +0 -2
- package/dist/browser-profiles-DhGtxK9v.js +0 -2
- package/dist/browser-runtime-BL6b-qtr.js +0 -384
- package/dist/build-33AnG55F.js +0 -257
- package/dist/bundled-channel-config-schema-4eXcH-RE.d.ts +0 -3163
- package/dist/call-dct8amtn.d.ts +0 -43
- package/dist/capability-cli-D-KoVyyP.js +0 -1782
- package/dist/channel-0tgrzPag.js +0 -867
- package/dist/channel-4g20sJKJ.d.ts +0 -104
- package/dist/channel-6tG8jWsw.d.ts +0 -8
- package/dist/channel-7OEbQ8xS.d.ts +0 -6
- package/dist/channel-7rVapSdN.d.ts +0 -8
- package/dist/channel-B1fZN0iI.d.ts +0 -427
- package/dist/channel-B5Q7fRiN.js +0 -1134
- package/dist/channel-BEg_0h_C.d.ts +0 -12
- package/dist/channel-BNp1J_eZ.js +0 -376
- package/dist/channel-BP6RWm-M.d.ts +0 -47
- package/dist/channel-BRjqrJfj.d.ts +0 -49
- package/dist/channel-BUoyH_tP.d.ts +0 -114
- package/dist/channel-BVBG4Tmn.d.ts +0 -28
- package/dist/channel-Bap23sAx.js +0 -481
- package/dist/channel-BhZ7x0SB.d.ts +0 -26
- package/dist/channel-Bxod9CjX.js +0 -508
- package/dist/channel-C6LASGjS.js +0 -808
- package/dist/channel-COWZEKCw.js +0 -1249
- package/dist/channel-CRAIreZ3.js +0 -238
- package/dist/channel-CVY2hnJh.js +0 -1556
- package/dist/channel-CgKdh_Jd.d.ts +0 -106
- package/dist/channel-Cxo62btA.js +0 -1496
- package/dist/channel-D5SzoyWI.js +0 -562
- package/dist/channel-DE4vIsYF.d.ts +0 -64
- package/dist/channel-DOdRHxJg.js +0 -1777
- package/dist/channel-DZygtXdy.js +0 -362
- package/dist/channel-DfhOnM71.d.ts +0 -7
- package/dist/channel-DhZiptRe.d.ts +0 -8
- package/dist/channel-DqPZviVV.js +0 -2126
- package/dist/channel-Dssy3NQA.js +0 -740
- package/dist/channel-actions.runtime-CDaMC9SV.js +0 -265
- package/dist/channel-buMY8xZQ.d.ts +0 -7
- package/dist/channel-core-CBhC_PNR.js +0 -5
- package/dist/channel-core-x9b94azO.d.ts +0 -6
- package/dist/channel-cvGHll3-.js +0 -955
- package/dist/channel-entry-contract-BfZdcgTS.d.ts +0 -112
- package/dist/channel-inbound-CNdyzYlz.js +0 -80
- package/dist/channel-l8amaSI9.js +0 -653
- package/dist/channel-lifecycle-DCl2GbRW.d.ts +0 -125
- package/dist/channel-pairing-BRqfYy30.d.ts +0 -58
- package/dist/channel-plugin-runtime-CvcVGjj4.js +0 -998
- package/dist/channel-plugin-runtime-D5n9A86n.d.ts +0 -7
- package/dist/channel-runtime-BAbg8Dcv.js +0 -408
- package/dist/channel-sWtDTVwd.d.ts +0 -14
- package/dist/channel.runtime-9o-iF8zm.js +0 -2528
- package/dist/channel.runtime-BotO7RD0.js +0 -21009
- package/dist/channel.runtime-BrDb4cP8.js +0 -88
- package/dist/channel.runtime-C1cLfrDt.js +0 -254
- package/dist/channel.runtime-CTM3VO2E.js +0 -4
- package/dist/channel.runtime-CnodqvCJ.js +0 -733
- package/dist/channel.runtime-Dmr8503H.js +0 -1008
- package/dist/channel.runtime-DqzR3Gd9.js +0 -109
- package/dist/channel.runtime-LOf0PHu_.js +0 -652
- package/dist/channel.setup-1leD5F5B.js +0 -343
- package/dist/channel.setup-D9UyWhXM.js +0 -1098
- package/dist/channel.setup-DkVld-9Z.d.ts +0 -7
- package/dist/channel.setup-DxT4prSl.d.ts +0 -8
- package/dist/channel.setup-IHNFkdUD.js +0 -10
- package/dist/channel.setup-YwXqilBB.d.ts +0 -6
- package/dist/chat-DrycI6KH.js +0 -2666
- package/dist/chrome-CgGY9FsG.js +0 -1503
- package/dist/cli-backend-B3aNoTD4.d.ts +0 -5
- package/dist/cli-backend-BVUFOLXj.d.ts +0 -5
- package/dist/cli-compaction-DPmSHZx7.js +0 -347
- package/dist/cli-metadata-eFfCoGmY.js +0 -22
- package/dist/cli-nmYmL8lb.js +0 -1341
- package/dist/cli-runner-BTOYShgV.js +0 -2
- package/dist/cli-runner-DgXAxJVr.js +0 -540
- package/dist/cli-runner.runtime-BeMsKcaS.js +0 -4
- package/dist/cli-runner.runtime-DMD8X8-h.js +0 -3
- package/dist/cli-shared-BAuePn3e.d.ts +0 -20
- package/dist/cli-v6XF4hHd.d.ts +0 -20
- package/dist/client-CKLZqMCW.js +0 -650
- package/dist/client-adapter-B_0W-6Fx.js +0 -897
- package/dist/client-factory-CdMLQFeA.js +0 -9
- package/dist/command-auth-BxYfnQzs.js +0 -135
- package/dist/command-execution-startup-CiV5yFW1.js +0 -87
- package/dist/command-handlers-BAWROGlt.js +0 -1609
- package/dist/command-registry-BqTMebZr.js +0 -4
- package/dist/command-registry-C2Y8GeJl.js +0 -9
- package/dist/command-registry-core-Bi-d0-WH.js +0 -110
- package/dist/command-status.runtime-BSXHZzOq.js +0 -90
- package/dist/commands-Z6AfrJar.d.ts +0 -113
- package/dist/commands-acp-BYWOkjAx.js +0 -74
- package/dist/commands-compact.runtime-Cyb7Pu12.js +0 -10
- package/dist/commands-handlers.runtime-DdJ20XTn.js +0 -6154
- package/dist/commands-status-6uhiUw13.js +0 -3
- package/dist/commands-status-BJ5AnkOG.js +0 -16
- package/dist/commands-status.runtime-6uhiUw13.js +0 -3
- package/dist/commands-subagents-control.runtime-DZrrLjSk.js +0 -2
- package/dist/commands-subagents-control.runtime-_R3XgUpp.js +0 -3
- package/dist/commands-system-prompt-CHGtJPnx.js +0 -162
- package/dist/commands-system-prompt-CM23NlDu.js +0 -2
- package/dist/commands.runtime-DUEbtHG1.js +0 -176
- package/dist/compact-BA6lVtLj.js +0 -480
- package/dist/compact-BfC-utPW.js +0 -1141
- package/dist/compact.runtime-BRL2wCqh.js +0 -12
- package/dist/completion-cli-CYKoLZLl.js +0 -315
- package/dist/computer-use-BWgYktaW.js +0 -367
- package/dist/config-B_HanwOV.js +0 -373
- package/dist/config-DhGtxK9v.js +0 -2
- package/dist/config-cli-CI5UtWr-.js +0 -1633
- package/dist/config-mutations-D2GtlLMA.js +0 -159
- package/dist/config-schema-BKOfHz23.d.ts +0 -20
- package/dist/configure-CuPwIiwW.js +0 -3
- package/dist/configure.commands-BWpwrafi.js +0 -1251
- package/dist/configure.commands-qzipmoDP.js +0 -2
- package/dist/context-engine-host-compat-D246ZMR2.js +0 -2
- package/dist/context-engine-host-compat-KMl-oqCw.js +0 -288
- package/dist/context-engine-lifecycle-DvEDHkQz.js +0 -1274
- package/dist/contracts-testkit-Ym3exIK5.d.ts +0 -145
- package/dist/control-auth-B_RiUaHt.js +0 -114
- package/dist/control-service-DcQFx6_O.js +0 -145
- package/dist/control-ui/assets/agents-Bc8cIfWF.js +0 -1008
- package/dist/control-ui/assets/channel-config-extras-DQru4ECs.js +0 -2
- package/dist/control-ui/assets/channels-BfncerPV.js +0 -367
- package/dist/control-ui/assets/cron-DHLcga_r.js +0 -1013
- package/dist/control-ui/assets/debug-DprDzDn1.js +0 -97
- package/dist/control-ui/assets/index-XTZKpkBL.js +0 -7370
- package/dist/control-ui/assets/instances-D1_lOT13.js +0 -57
- package/dist/control-ui/assets/logs-DINx8syb.js +0 -74
- package/dist/control-ui/assets/nodes-BH4XOUmD.js +0 -436
- package/dist/control-ui/assets/sessions-D5Xt25SY.js +0 -399
- package/dist/control-ui/assets/skills-BmayrBHY.js +0 -314
- package/dist/control-ui/assets/skills-shared-CHaYSJ_s.js +0 -11
- package/dist/conversation-binding-runtime-_jhzwiiC.js +0 -4
- package/dist/conversation-runtime-F5kCN0Sj.js +0 -31
- package/dist/core-BpeKfqbI.d.ts +0 -224
- package/dist/core-DE71gncT.js +0 -282
- package/dist/core-api-B4L5WkKc.js +0 -5
- package/dist/core-api-Q9oM19yY.js +0 -2
- package/dist/crestodian-DLpxYmzP.js +0 -55
- package/dist/daocore-runtime-BnYtDbMC.d.ts +0 -151
- package/dist/daocore-tools-wNTIZIO3.js +0 -11727
- package/dist/dashboard-SHmcCcnT.js +0 -263
- package/dist/delivery-BA4di5Tw.js +0 -1002
- package/dist/dev-Cr2Dhgoc.js +0 -97
- package/dist/dialogue-xI4qAuLY.js +0 -37
- package/dist/dir-fetch-tool-6d4yElM4.js +0 -565
- package/dist/dir-list-tool-D2k-hax6.js +0 -100
- package/dist/direct-dm-eGyFHTug.js +0 -64
- package/dist/directive-handling.fast-lane-Ci1l6GN_.js +0 -68
- package/dist/directive-handling.impl-Co3i_YQ4.js +0 -818
- package/dist/directive-handling.impl-DHKC0TrU.js +0 -2
- package/dist/directive-handling.model-selection-bv5KrHOw.js +0 -122
- package/dist/directive-handling.persist.runtime-CPLg-YHh.js +0 -263
- package/dist/dispatch-CdvERWY-.js +0 -1640
- package/dist/dispatch-acp-transcript.runtime-BhQo1XEg.js +0 -40
- package/dist/dispatch-acp.runtime-Dtiu2EgE.js +0 -18
- package/dist/doctor-BzsPHvLP.js +0 -2
- package/dist/doctor-Cg4FWB15.js +0 -6
- package/dist/doctor-config-flow-SYjHcyu4.js +0 -1741
- package/dist/doctor-core-checks-75amkN-e.js +0 -2
- package/dist/doctor-core-checks-B1fu7KDm.js +0 -573
- package/dist/doctor-health-contributions-BMdJKStr.js +0 -696
- package/dist/doctor-health-vLyDQqfq.js +0 -65
- package/dist/doctor-lint-DfvFyBgL.js +0 -94
- package/dist/doctor-prompter-C-dTuOnw.js +0 -58
- package/dist/doctor-state-integrity-Cv-ECLuv.js +0 -1231
- package/dist/dynamic-tools-BG8ijDFH.js +0 -486
- package/dist/embedded-backend-bRfALCWz.js +0 -579
- package/dist/embedded-gateway-stub.runtime-CAh3IhtZ.js +0 -12
- package/dist/embedding-provider-B7kg9IhC.d.ts +0 -16
- package/dist/embedding-provider-jB1zjkZy.d.ts +0 -65
- package/dist/embedding-provider-sea2CddJ.d.ts +0 -21
- package/dist/exec-approvals-BBa28Sct.js +0 -149
- package/dist/file-fetch-tool-DRIsI7eQ.js +0 -124
- package/dist/file-write-tool-vTMh7eW6.js +0 -127
- package/dist/format-nrhTS41q.js +0 -1145
- package/dist/gateway-cli-CCgw11Ik.js +0 -435
- package/dist/gateway-method-runtime-BNAVGCC_.js +0 -21
- package/dist/gateway-runtime-DGdJumdK.d.ts +0 -163
- package/dist/gemini-cli-provider-Bbpd5lx5.d.ts +0 -6
- package/dist/get-reply-DGFCqKen.js +0 -4689
- package/dist/get-reply-from-config.runtime-l7NTyCh5.js +0 -2
- package/dist/graph-users-CGpakgek.js +0 -1419
- package/dist/group-access-D095jQ78.js +0 -112
- package/dist/group-keys-DnxWQtll.d.ts +0 -17
- package/dist/handle-action.guild-admin-B3pALmMq.js +0 -288
- package/dist/harness-Bs-sPbOD.js +0 -61
- package/dist/health-4gWMIKHu.js +0 -4
- package/dist/heartbeat-runner-Sky_Rjw7.js +0 -5
- package/dist/heartbeat-runner.runtime-CRZ-NbrW.js +0 -4
- package/dist/help-B68Ov4LD.js +0 -136
- package/dist/hook-runtime-Cm73yH0T.d.ts +0 -107
- package/dist/hooks-DWSdYas_.js +0 -534
- package/dist/http-registry-CHKiFHCC.d.ts +0 -23
- package/dist/image-generation-runtime-p-dfXZTf.d.ts +0 -21
- package/dist/inbound-direct-dm-runtime-5z3W9Oqn.js +0 -2
- package/dist/inbound-reply-dispatch-D7NeeFC1.js +0 -148
- package/dist/index-CKAHTIU4.d.ts +0 -3971
- package/dist/init-BXF3o80o.js +0 -59
- package/dist/inline-buttons-DsHwKEVU.js +0 -40
- package/dist/interactive-dispatch-BsKWomnh.d.ts +0 -143
- package/dist/interactive-dispatch-CItEYOu3.d.ts +0 -56
- package/dist/internal-events-TAN9dPEj.js +0 -90
- package/dist/isolated-agent-CTrVGI6q.js +0 -2
- package/dist/isolated-agent-DPyibJ8B.js +0 -1118
- package/dist/lifecycle-BwTg0Djv.js +0 -571
- package/dist/list.probe-BpM4PKu7.js +0 -449
- package/dist/list.status-command-BbcloYBd.js +0 -789
- package/dist/llm-slug-generator-UG7Bhj_y.js +0 -78
- package/dist/loader-D6z2PEKl.d.ts +0 -142
- package/dist/local-dispatch.runtime-CU6Y-BDa.js +0 -9
- package/dist/manager-C3AVKMSl.d.ts +0 -356
- package/dist/manager-CSN9j9hh.d.ts +0 -205
- package/dist/manager.runtime-Da5LiiaQ.js +0 -2714
- package/dist/markdown-to-line-BnESmsY4.js +0 -811
- package/dist/mcp-http-C38KS7On.js +0 -2
- package/dist/mcp-http-CcGhAZcF.js +0 -555
- package/dist/media-understanding-provider-BCz5dVl6.js +0 -339
- package/dist/memory-core-host-engine-storage-sWQlfr8J.d.ts +0 -54
- package/dist/memory-embedding-adapter-BrGY0ecB.d.ts +0 -5
- package/dist/message-actions-CQURSOZH.js +0 -145
- package/dist/message-handler-C2U3bt-X.js +0 -1715
- package/dist/message-handler-CwZfuHhP.js +0 -384
- package/dist/message-handler.preflight-Cosa3kg0.js +0 -1125
- package/dist/message-handler.process-BlKFMYXw.js +0 -1484
- package/dist/migration-hAtbc95i.d.ts +0 -45
- package/dist/model-B8M2deNL.js +0 -74
- package/dist/model-Ck-vNyGd.d.ts +0 -33
- package/dist/model-selection-v2wQWgsT.js +0 -272
- package/dist/models-B7IiQBWY.js +0 -104
- package/dist/models-CnWFsPX6.d.ts +0 -24
- package/dist/models-DMNzBNgt.js +0 -2
- package/dist/models-cli-CQaOg02d.js +0 -256
- package/dist/monitor-Bd9kOezJ.js +0 -1370
- package/dist/monitor-Cy6D6MyS.js +0 -715
- package/dist/monitor-DStY23C4.js +0 -834
- package/dist/monitor-DnF8eltK.js +0 -1657
- package/dist/monitor-DrFJ63I1.js +0 -4377
- package/dist/monitor-J8jOsDaJ.js +0 -60
- package/dist/monitor-auth-DKkbt_CR.js +0 -179
- package/dist/monitor-jp3H9Ri_.js +0 -2
- package/dist/monitor-polling.runtime-DPCAacPc.js +0 -883
- package/dist/monitor-tBNmyf1s.js +0 -2788
- package/dist/monitor-webhook.runtime-BnjEsLRS.js +0 -387
- package/dist/monitor.account-Gh8FuMEq.js +0 -5233
- package/dist/monitor.runtime-Bdh6dxyq.js +0 -2
- package/dist/monitor.webhook-BosT2ylg.js +0 -180
- package/dist/node-cli-sessions-B0_DtIxz.js +0 -1228
- package/dist/onboard-CiTp3HuT.js +0 -733
- package/dist/onboard-helpers-6NgX4RkW.js +0 -251
- package/dist/onboard-helpers-BwxJT_0T.js +0 -6
- package/dist/onboard-remote-CNCFouj7.js +0 -212
- package/dist/onboard-remote-DXzWgH_H.js +0 -2
- package/dist/onboard-skills-Dx58zrXg.js +0 -160
- package/dist/onboard-skills-qaynAMqw.js +0 -2
- package/dist/openai-codex-provider-Bj9cyh4I.d.ts +0 -5
- package/dist/openai-http-Dp0cp01u.js +0 -824
- package/dist/openai-provider-Dm3YkkWf.d.ts +0 -5
- package/dist/openresponses-http-acbxr5UW.js +0 -1173
- package/dist/operations-BZVuEl9E.js +0 -805
- package/dist/outbound-adapter-BKGzT1Rl.js +0 -543
- package/dist/outbound-session-route-mWVuRF9I.js +0 -45
- package/dist/outbound.runtime-BTjY78St.js +0 -2
- package/dist/pairing-challenge-DD0D0sfM.d.ts +0 -87
- package/dist/pi-embedded-CFP2IrYS.js +0 -3796
- package/dist/pi-embedded-D8caT0Nm.js +0 -4
- package/dist/pi-embedded.runtime-eBik36nq.js +0 -4
- package/dist/pi-tools-DOiFN8QJ.js +0 -2413
- package/dist/plan-Cq2-YWkv.js +0 -112
- package/dist/plan-DZacZ3Zv.js +0 -81
- package/dist/plugin-BcNkVMQf.d.ts +0 -17
- package/dist/plugin-app-cache-key-CBK84hKp.js +0 -46
- package/dist/plugin-enabled-CMfz3hfi.js +0 -233
- package/dist/plugin-entry-BS5QKDoz.d.ts +0 -47
- package/dist/plugin-k9ChkvvX.js +0 -12396
- package/dist/plugin-registration-DzPoDboh.js +0 -88
- package/dist/plugin-runtime-BNGhLQ-_.d.ts +0 -117
- package/dist/plugin-service-BynKHNHj.d.ts +0 -24
- package/dist/plugin-service-Ckp9CgP5.js +0 -1229
- package/dist/policy-CBa8yH5k.js +0 -680
- package/dist/policy-Dlam-IbU.js +0 -138
- package/dist/prepare.runtime-B8h04--2.js +0 -732
- package/dist/preview-warnings-DPDK9HPk.js +0 -392
- package/dist/probe-Bts3wK7l.js +0 -682
- package/dist/probe-ByHrOECy.js +0 -47
- package/dist/probe-CXqCx5yV.js +0 -2204
- package/dist/probe-fhhJ0LMx.js +0 -2
- package/dist/program-DfNLP_PI.js +0 -131
- package/dist/prompt-overlay-qKGGXVs-.d.ts +0 -23
- package/dist/provider-CeG5mirD.js +0 -8735
- package/dist/provider-D_TXf9b1.js +0 -152
- package/dist/provider-Fb0fhEC5.js +0 -32
- package/dist/provider-api-key-auth-BIph5btg.d.ts +0 -27
- package/dist/provider-auth-result-BFvMZrH6.d.ts +0 -21
- package/dist/provider-catalog-runtime-Du74RUel.d.ts +0 -23
- package/dist/provider-catalog-shared-B3nN3sf2.d.ts +0 -62
- package/dist/provider-dispatcher-DQ0FP7Oj.js +0 -22
- package/dist/provider-hook-runtime-CRpS8VJ_.d.ts +0 -61
- package/dist/provider-model-shared-GrPEK3SY.d.ts +0 -143
- package/dist/provider-models-iUJVn9QI.d.ts +0 -12
- package/dist/provider-policy-DliVEM__.d.ts +0 -30
- package/dist/provider-registration-BxzmE1yB.d.ts +0 -6
- package/dist/provider-registry-B4AQXjYK.d.ts +0 -8
- package/dist/provider-registry-BHyB46kI.d.ts +0 -30
- package/dist/provider-registry-CnfpUSqh.d.ts +0 -8
- package/dist/provider-runtime-D3j0VBbF.d.ts +0 -359
- package/dist/provider-self-hosted-setup-_11XAmRH.d.ts +0 -74
- package/dist/provider-session.runtime-CIMJ-7ay.js +0 -9
- package/dist/provider-stream-mWxYXsAm.d.ts +0 -140
- package/dist/provider-stream-shared-QayId-fm.d.ts +0 -128
- package/dist/provider-xNaUQ5Lv.js +0 -32
- package/dist/provider.runtime-CGsYbZGk.js +0 -2
- package/dist/providers.runtime-fmZQlSRt.d.ts +0 -25
- package/dist/public-surface-loader-CuVkM64A.js +0 -114
- package/dist/pw-ai-BDGftH9e.js +0 -3029
- package/dist/pw-role-snapshot-C_P091Iv.js +0 -333
- package/dist/reaction-level-DKxiNfWB.js +0 -19
- package/dist/reaction-runtime-api-TY4aPHui.js +0 -116
- package/dist/realtime-transcription-CmRx7wX7.d.ts +0 -43
- package/dist/realtime-transcription-provider-BNca2pAl.js +0 -205
- package/dist/realtime-transcription-provider-Csl2NRiB.d.ts +0 -5
- package/dist/realtime-transcription-provider-CtUTdTS4.d.ts +0 -37
- package/dist/realtime-transcription-provider-DKd69ns6.d.ts +0 -28
- package/dist/realtime-transcription-provider-DPj1VZIg.d.ts +0 -32
- package/dist/realtime-voice-CVgV9cqF.d.ts +0 -333
- package/dist/realtime-voice-provider-CmtxwZon.d.ts +0 -5
- package/dist/register-DLjqO2vR.js +0 -2178
- package/dist/register.agent-FV7a6yzo.js +0 -156
- package/dist/register.configure-DrkSyKW3.js +0 -16
- package/dist/register.crestodian-CQGAa8z2.js +0 -24
- package/dist/register.maintenance-tocHfiS3.js +0 -83
- package/dist/register.onboard-BomHnBGE.js +0 -113
- package/dist/register.runtime-6AmV3Vgs.js +0 -54
- package/dist/register.runtime-CSz0gVBB.d.ts +0 -6
- package/dist/register.setup-ENYtNAA5.js +0 -40
- package/dist/register.subclis-BC6TefAM.js +0 -31
- package/dist/register.subclis-DZdEZgSS.js +0 -3
- package/dist/register.subclis-core-C-EfowrU.js +0 -273
- package/dist/registry-VitXYFE8.d.ts +0 -91
- package/dist/registry-types-C4eAzEgQ.d.ts +0 -392
- package/dist/repair-sequencing-l8dFaytn.js +0 -640
- package/dist/reply-delivery-DdeUWVuk.js +0 -196
- package/dist/reply-runtime-Bd91JEZL.js +0 -11
- package/dist/reply.runtime-l7NTyCh5.js +0 -2
- package/dist/request-BY_4UukN.js +0 -54
- package/dist/resolve-allowlist-C4lmxl4V.js +0 -220
- package/dist/result-fallback-classifier-XORMMp30.js +0 -79
- package/dist/root-help-CTW0Wyrf.js +0 -43
- package/dist/route-dOf1WMkJ.js +0 -469
- package/dist/route-resolution-BddNYZEI.js +0 -274
- package/dist/routes-D0xw72Lf.js +0 -3602
- package/dist/routes-TXSPQFWS.js +0 -2
- package/dist/run-DpvUuaWB.js +0 -1162
- package/dist/run-attempt-Bet0PiSc.js +0 -7704
- package/dist/run-command-C5vMVqMt.js +0 -23
- package/dist/run-command-pNDd7NqP.js +0 -2
- package/dist/run-embedded.runtime-CBZV6YWj.js +0 -4
- package/dist/run-execution-cli.runtime-DTQLV8tA.js +0 -4
- package/dist/run-subagent-registry.runtime-DJCvSdhY.js +0 -2
- package/dist/runtime-CNXeG8vX.js +0 -1287
- package/dist/runtime-DEOSWxv9.js +0 -438
- package/dist/runtime-DbTiSX85.d.ts +0 -17
- package/dist/runtime-api-BCM7T4WV.js +0 -17
- package/dist/runtime-api-BTnMvj8L.js +0 -13
- package/dist/runtime-api-By6LEySM.js +0 -3
- package/dist/runtime-api-Cd0b5LPQ.js +0 -4
- package/dist/runtime-api-CtuDiikz.js +0 -21
- package/dist/runtime-api-DjySILXC.js +0 -13
- package/dist/runtime-api-XJTq_pyQ.js +0 -24
- package/dist/runtime-api-k3v6Q0lb2.d.ts +0 -3151
- package/dist/runtime-api.actions-BmsSg8Ai.js +0 -3
- package/dist/runtime-api.actions-C2-n4QQ5.d.ts +0 -23
- package/dist/runtime-api.monitor-DSk7Pd5H.js +0 -6
- package/dist/runtime-api.send-D3sPncy9.js +0 -4
- package/dist/runtime-api.send-t0FX9tXf.d.ts +0 -38
- package/dist/runtime-api.threads-BK9cB4L1.js +0 -2
- package/dist/runtime-channel--Wjr2ePx.js +0 -150
- package/dist/runtime-channel-WdTa9hHZ.js +0 -2
- package/dist/runtime-embedded-pi.runtime-BNYBvaxo.js +0 -2
- package/dist/runtime-r3jS5wSq.js +0 -6179
- package/dist/runtime-taskflow-DMBY6o56.d.ts +0 -435
- package/dist/sanitize-outbound-D6IBCCpn.js +0 -127
- package/dist/sdk-setup-tools-DcDrd8tW.js +0 -8
- package/dist/secrets-OV1uTwRt.js +0 -113
- package/dist/secrets-cli-llC7t41S.js +0 -149
- package/dist/security-audit-BM_fypcl.js +0 -118
- package/dist/security-audit-CQ2yKgF8.js +0 -122
- package/dist/security-audit.runtime-CRgJUegH.js +0 -2
- package/dist/selection-DkJ7MaPC.js +0 -16157
- package/dist/selection-LeUiOSn0.js +0 -3
- package/dist/send-B5TXXeBz.d.ts +0 -231
- package/dist/send-C0ZHzB6o.js +0 -1631
- package/dist/send-CXL3cM-w.js +0 -192
- package/dist/send-CuDA29HM.js +0 -2
- package/dist/send-D7qhwK7Z.js +0 -143
- package/dist/send-DEMaBWpw.d.ts +0 -105
- package/dist/send.components-BNeg1zrc.js +0 -2
- package/dist/send.components-DwRyC_Hc.js +0 -500
- package/dist/send.runtime-DBIUdxpO.js +0 -2
- package/dist/send.types-DywwIqYK.d.ts +0 -160
- package/dist/server-DGcm6Swr.js +0 -24
- package/dist/server-DPvleC-x.js +0 -73
- package/dist/server-context-BWBM4f-_.js +0 -955
- package/dist/server-context-CFgwcLlu.js +0 -2
- package/dist/server-cron-C1kChsjw.js +0 -2989
- package/dist/server-cron-CS1EP5Li.js +0 -2
- package/dist/server-methods-BcIlC8iD.js +0 -16494
- package/dist/server-node-events-BAZCvZOy.js +0 -596
- package/dist/server-plugin-bootstrap-cQUi21Uu.js +0 -70
- package/dist/server-plugins-BRFre223.js +0 -432
- package/dist/server-reload-handlers-DfcsAX-5.js +0 -714
- package/dist/server-restart-sentinel-CFX5zQkM.js +0 -747
- package/dist/server-restart-sentinel-DUvs77Q0.js +0 -2
- package/dist/server-runtime-services-0vm5XmvV.js +0 -2
- package/dist/server-runtime-services-CLz_vkLy.js +0 -267
- package/dist/server-startup-plugins-CPXqqIRV.js +0 -113
- package/dist/server-startup-post-attach-BkNe1Z6g.js +0 -716
- package/dist/server-ws-runtime-rcJeRHFO.js +0 -349
- package/dist/server.impl-a6knQ-N8.js +0 -2586
- package/dist/service-H-BcELwS.js +0 -1446
- package/dist/session-binding-BQliaqL7.js +0 -2
- package/dist/session-binding-DPvZil_F.js +0 -219
- package/dist/session-kill-http-DJMipluP.js +0 -121
- package/dist/session-reset-service-Dn9FU5wA.js +0 -625
- package/dist/session-route-JLWNmJxD.js +0 -93
- package/dist/session-status.runtime-D0OptHcW.js +0 -2
- package/dist/session-subagent-reactivation.runtime-BUmf1vNS.js +0 -2
- package/dist/session-tab-registry-CoBvJVRj.js +0 -521
- package/dist/sessions-history-http-B8CkLDAn.js +0 -430
- package/dist/sessions.runtime-DbNqS_Gy.js +0 -2
- package/dist/setup-CTZUUn1s.js +0 -586
- package/dist/setup-D6fXOEjD.js +0 -2
- package/dist/setup-api-DLPEXHCv.js +0 -29
- package/dist/setup-core-DLXb29jm.js +0 -174
- package/dist/setup-onboard-configure-help-fast-path-CrcZmKPI.js +0 -64
- package/dist/setup-surface--Cct-rCt.js +0 -288
- package/dist/setup-surface-CW8YN207.js +0 -320
- package/dist/setup-surface-DIxcfqD0.js +0 -221
- package/dist/setup-surface-IJ6kmKgi.js +0 -405
- package/dist/setup.finalize-gWpWnCCk.js +0 -582
- package/dist/setup.gateway-config-D_DaSfpW.js +0 -281
- package/dist/setup.migration-import-CYZjCkle.js +0 -2
- package/dist/setup.migration-import-CZJU4scH.js +0 -200
- package/dist/shared-Bp_Fgv6B.js +0 -121
- package/dist/shared-CLqPY0yv.d.ts +0 -115
- package/dist/shared-client-OQdg8NGC.js +0 -629
- package/dist/shared-client-dk1ICVBm.js +0 -2
- package/dist/side-question-CbhRW3UI.js +0 -683
- package/dist/simple-completion-runtime-XIF65b47.d.ts +0 -73
- package/dist/skill-tool-dispatch.runtime-EcycYnWE.js +0 -143
- package/dist/slash-state-BoX6WwB5.js +0 -2166
- package/dist/speech-CvkJG5Mt.d.ts +0 -47
- package/dist/speech-core-MG83lB3i.d.ts +0 -36
- package/dist/speech-provider-1EN9hT-3.d.ts +0 -8
- package/dist/speech-provider-67ebyEcs.js +0 -184
- package/dist/speech-provider-B6tb45De.d.ts +0 -5
- package/dist/speech-provider-C74wAyBX.d.ts +0 -5
- package/dist/speech-provider-CYJoZZpj.d.ts +0 -8
- package/dist/speech-provider-DavEMdKC.d.ts +0 -34
- package/dist/speech-provider-DvFtveg6.d.ts +0 -5
- package/dist/src-CbfOifft.js +0 -4256
- package/dist/startup-context-YF24NARp.js +0 -313
- package/dist/status-message-CcrZdfCO.js +0 -484
- package/dist/status-message.runtime-Cptt1EPV.js +0 -6
- package/dist/status-subagents.runtime-v2eijc4R.js +0 -18
- package/dist/status-text-BWwar3Yc.js +0 -296
- package/dist/status-tn3uQDY7.js +0 -73
- package/dist/status.runtime-BFjTHLiQ.js +0 -2
- package/dist/sticker-cache-Cs7LV_3a.js +0 -206
- package/dist/sticker-vision.runtime-CyPMpoCs.js +0 -17
- package/dist/stream-1rWKMSqV.d.ts +0 -16
- package/dist/stream-Bk9TnoRV.d.ts +0 -10
- package/dist/stream-DZeY9rhs.d.ts +0 -120
- package/dist/stream-DgCoKjcL.d.ts +0 -19
- package/dist/stream-exnufPSG.d.ts +0 -5
- package/dist/stream-wrappers-D2EuY1tP.d.ts +0 -21
- package/dist/subagent-announce-CRjGGxSB.js +0 -354
- package/dist/subagent-announce-delivery-CbfRRdwt.js +0 -958
- package/dist/subagent-control-VTsWynTB.js +0 -508
- package/dist/subagent-hooks-BB__aHul.js +0 -2
- package/dist/subagent-hooks-Cb5fJ2H0.js +0 -146
- package/dist/subagent-hooks-CwVBMhp_.js +0 -2
- package/dist/subagent-hooks-Cx9_GAMF.js +0 -116
- package/dist/subagent-hooks-DOJhvTDx.js +0 -230
- package/dist/subagent-hooks-DUMqhB3r.js +0 -2
- package/dist/subagent-hooks-api-BDGmCxB2.js +0 -22
- package/dist/subagent-hooks-api-CcTdPqP1.js +0 -23
- package/dist/subagent-hooks-api-D18tQta6.js +0 -23
- package/dist/subagent-orphan-recovery-6bNIX25Q.js +0 -352
- package/dist/subagent-registry-DokIxoQ6.js +0 -2351
- package/dist/subagent-registry-tlyJE0hN.js +0 -3
- package/dist/subagent-session-cleanup-BWHQ6rcm.js +0 -525
- package/dist/subagent-spawn-BUdUAwoc.js +0 -1164
- package/dist/target-id-CI1U3MSO.js +0 -107
- package/dist/targets-CbBORUXB.d.ts +0 -10
- package/dist/targets-CgmlXrhv.js +0 -44
- package/dist/targets-D-jSrLUN.js +0 -19
- package/dist/targets-DPDu8x6v.js +0 -19
- package/dist/targets-D_fXvxrg.d.ts +0 -10
- package/dist/testing-D-48HuIK.js +0 -267
- package/dist/thinking-policy-CY16OlCs.d.ts +0 -5
- package/dist/thread-bindings-B9J0nGG7.js +0 -232
- package/dist/thread-bindings-BByWvFZq.js +0 -8
- package/dist/thread-bindings-Cxjm2mLg.js +0 -571
- package/dist/thread-bindings-DQWmglaO.js +0 -228
- package/dist/thread-bindings.discord-api-DWWDvMgL.js +0 -187
- package/dist/thread-bindings.manager-CQW6bNs5.js +0 -2
- package/dist/thread-bindings.manager-DpBYBs9s.js +0 -536
- package/dist/thread-lifecycle-PpB8gTx1.js +0 -1614
- package/dist/token-CBy6YYM_.js +0 -134
- package/dist/tool-BCHcwX9p.js +0 -139
- package/dist/tool-actions.runtime-Cwxr2NmB.js +0 -534
- package/dist/tool-plugin-DHZYdwyJ.d.ts +0 -77
- package/dist/tool-resolution-DQpf531V.js +0 -149
- package/dist/tool-split-ClZW5eN5.d.ts +0 -19
- package/dist/tools-effective-inventory-BHxeIAri.js +0 -204
- package/dist/tools-invoke-http-Bv2LES5Q.js +0 -67
- package/dist/tools-invoke-shared-Cf_ifab9.js +0 -200
- package/dist/transport-stream-D_pZ9Qwv.d.ts +0 -42
- package/dist/tts-CjTcF0YS.js +0 -66
- package/dist/tui-D3_WpyGV.js +0 -2
- package/dist/tui-Y8IezK6P.js +0 -4709
- package/dist/tui-backend-BIJbrfDK.js +0 -256
- package/dist/tui-cli-YVLQJGLU.js +0 -37
- package/dist/types-CnKegQ41.d.ts +0 -786
- package/dist/types-Dyry5PA_2.d.ts +0 -3650
- package/dist/types.public-AUFnQi6j.d.ts +0 -70
- package/dist/update-cli-B7MOXy4Y.js +0 -3664
- package/dist/video-generation-runtime-Cc8klYNS.d.ts +0 -21
- package/dist/video-model-catalog-XG42YlJS.d.ts +0 -16
- package/dist/vision-tools-kEwnV2UO.js +0 -1409
- package/dist/web-search-DH1W_lfx.js +0 -62
- package/dist/web-search-provider.runtime-BX9TezsY.js +0 -328
- package/dist/web-search-provider.runtime-BhRjYeyp.js +0 -2
- package/dist/webhook-targets--wGRjxMd.d.ts +0 -99
- package/dist/xai-oauth-BZQ--94U.js +0 -479
- package/dist/xai-user-agent-SpZaKTGR.js +0 -32
- package/dist/zod-schema.core-BhLPa6BF.d.ts +0 -166
- /package/dist/{accounts-CqgATPC-2.d.ts → accounts-CqgATPC-.d.ts} +0 -0
- /package/dist/{acp-runtime-backend-DU5R8SXu.js → acp-runtime-backend-DHyoMnZY.js} +0 -0
- /package/dist/{channel-actions-Ce2Sna1a.js → channel-actions-B5OPAiNK.js} +0 -0
- /package/dist/{command-status-runtime-Cj5vB8lc.js → command-status-runtime-BqQvv1BR.js} +0 -0
- /package/dist/{delegate-BeKeQwNR.js → delegate-B1QIF1j8.js} +0 -0
- /package/dist/{dispatch-acp-DXlzEM_A.js → dispatch-acp-Ch9ZmM4b.js} +0 -0
- /package/dist/{heartbeat-runner-Dncw_0KS.js → heartbeat-runner-BkgH94IS.js} +0 -0
- /package/dist/{library-6cU4n1-c.js → library-DP1oARlw.js} +0 -0
- /package/dist/{run-executor.runtime-DjwaphFT.js → run-executor.runtime-Czk4Lxkj.js} +0 -0
- /package/dist/{video-generation-core-BVVgDSdq.d.ts → server-plugins-BVVgDSdq.d.ts} +0 -0
- /package/dist/{shared-BE5PSFeb.js → shared-SiM6kZAE.js} +0 -0
- /package/dist/{model-ref-mtPT-mlX.d.ts → video-generation-core-mtPT-mlX.d.ts} +0 -0
|
@@ -1,3796 +0,0 @@
|
|
|
1
|
-
import { c as normalizeOptionalString, s as normalizeOptionalLowercaseString } from "./string-coerce-DyL154ka.js";
|
|
2
|
-
import { t as sanitizeForLog } from "./ansi-4r6vVvJt.js";
|
|
3
|
-
import { i as formatErrorMessage } from "./errors-DCgU20d6.js";
|
|
4
|
-
import { p as resolveUserPath } from "./utils-CNnMhEDp.js";
|
|
5
|
-
import { o as resolveAgentExecutionContract, r as hasConfiguredModelFallbacks, v as resolveSessionAgentIds } from "./agent-scope-BvhOCChS.js";
|
|
6
|
-
import { i as isCronSessionKey } from "./session-key-utils-Ce_xWkNq.js";
|
|
7
|
-
import { a as resolveAgentDir, o as resolveAgentWorkspaceDir } from "./agent-scope-config-JLvcfwLC.js";
|
|
8
|
-
import { g as freezeDiagnosticTraceContext } from "./diagnostic-events-DPfGiEBK.js";
|
|
9
|
-
import { t as createSubsystemLogger } from "./subsystem-CK3I9R1L.js";
|
|
10
|
-
import { n as DEFAULT_MODEL, r as DEFAULT_PROVIDER, t as DEFAULT_CONTEXT_TOKENS } from "./defaults-mDjiWzE5.js";
|
|
11
|
-
import { r as resolveProviderIdForAuth } from "./provider-auth-aliases-Q5-O8vDj.js";
|
|
12
|
-
import { i as isMarkdownCapableMessageChannel } from "./message-channel-itmnr25o.js";
|
|
13
|
-
import { n as resolveSafeTimeoutDelayMs } from "./timer-delay-awNPCchy.js";
|
|
14
|
-
import { a as listOpenAIAuthProfileProvidersForAgentRuntime, c as resolveContextConfigProviderForRuntime, t as OPENAI_CODEX_PROVIDER_ID, u as resolveSelectedOpenAIPiRuntimeProvider } from "./openai-codex-routing-ZCWk8yuK.js";
|
|
15
|
-
import { t as resolveAgentHarnessPolicy } from "./policy-BXkiPhow.js";
|
|
16
|
-
import { t as getGlobalHookRunner } from "./hook-runner-global-DfvRzdbT.js";
|
|
17
|
-
import { a as resolveContextEngine, o as resolveContextEngineOwnerPluginId } from "./registry-BCmRCXCi.js";
|
|
18
|
-
import { s as emitAgentPlanEvent } from "./agent-events-Cfj53GyA.js";
|
|
19
|
-
import { t as extractAssistantTextForPhase } from "./chat-message-content-DN9xEd6w.js";
|
|
20
|
-
import { Y as resolveProviderAuthProfileId, b as prepareProviderRuntimeAuth } from "./provider-runtime-CJ3LFeND.js";
|
|
21
|
-
import { i as ensureAuthProfileStoreWithoutExternalProfiles, n as ensureAuthProfileStore } from "./store-CNzeH6So.js";
|
|
22
|
-
import { t as ensureDaoCoreModelsJson } from "./models-config-xXX6TCIT.js";
|
|
23
|
-
import { t as formatMissingAuthError } from "./model-auth-runtime-shared-cdTr1v5l.js";
|
|
24
|
-
import { r as formatRawAssistantErrorForUi } from "./assistant-error-format-B2ijqfp6.js";
|
|
25
|
-
import { l as isRawApiErrorPayload, n as formatBillingErrorMessage, o as getApiErrorPayloadFingerprint, t as BILLING_ERROR_USER_MESSAGE } from "./sanitize-user-facing-text-T0c8YLm7.js";
|
|
26
|
-
import { c as isTimeoutErrorMessage } from "./failover-matches-C-tab7FS.js";
|
|
27
|
-
import "./runs-g3A6Mtnd.js";
|
|
28
|
-
import { n as SILENT_REPLY_TOKEN, r as isSilentReplyPayloadText } from "./tokens-D8MVQSp9.js";
|
|
29
|
-
import { n as derivePromptTokens, o as normalizeUsage } from "./usage-DKNTRfvn.js";
|
|
30
|
-
import { n as sleepWithAbort } from "./backoff-BQ4uO4hX.js";
|
|
31
|
-
import { i as enqueueCommandInLane } from "./command-queue-B1aRL_eL.js";
|
|
32
|
-
import { i as getReplyPayloadMetadata, l as markReplyPayloadForSourceSuppressionDelivery, r as copyReplyPayloadMetadata, u as setReplyPayloadMetadata } from "./reply-payload-CiT5mlcY.js";
|
|
33
|
-
import { a as hasReplyPayloadContent } from "./payload-BDV15CYA.js";
|
|
34
|
-
import { T as isStrictAgenticExecutionContractActive, p as resolveToolLoopDetectionConfig } from "./daocore-tools-wNTIZIO3.js";
|
|
35
|
-
import { C as createEmbeddedRunStageTracker, O as rotateTranscriptFileAfterCompaction, S as EMBEDDED_RUN_ATTEMPT_DISPATCH_STAGE, T as shouldWarnEmbeddedRunStageSummary, _ as resolveRateLimitProfileRotationLimit, _t as resolveRunLivenessState, a as RUNTIME_AUTH_REFRESH_MARGIN_MS, b as createUsageAccumulator, bt as createEmbeddedRunReplayState, c as buildErrorAgentMeta, ct as extractPlanningOnlyPlanDetails, d as resolveActiveErrorContext, dt as resolveEmptyResponseRetryInstruction, f as resolveFinalAssistantRawText, ft as resolveIncompleteTurnPayloadText, g as resolveOverloadProfileRotationLimit, gt as resolveReplayInvalidFlag, h as resolveOverloadFailoverBackoffMs, ht as resolveReasoningOnlyRetryInstruction, i as selectAgentHarness, k as shouldRotateCompactionTranscript, l as buildUsageAgentMetaFields, lt as resolveAckExecutionFastPathInstruction, m as resolveMaxRunRetryIterations, mt as resolvePlanningOnlyRetryLimit, o as RUNTIME_AUTH_REFRESH_MIN_DELAY_MS, p as resolveFinalAssistantVisibleText, pt as resolvePlanningOnlyRetryInstruction, r as runAgentHarnessAttempt, s as RUNTIME_AUTH_REFRESH_RETRY_MS, st as STRICT_AGENTIC_BLOCKED_TEXT, t as maybeCompactAgentHarnessSession, u as createCompactionDiagId, ut as resolveAttemptReplayMetadata, v as resolveReportedModelRef, vt as resolveSilentToolResultReplyPayload, w as formatEmbeddedRunStageSummary, x as mergeUsageIntoAccumulator, xt as observeReplayMetadata, y as scrubAnthropicRefusalMagic, yt as shouldTreatEmptyAssistantReplyAsSilent } from "./selection-DkJ7MaPC.js";
|
|
36
|
-
import { i as createHeartbeatToolResponsePayload } from "./heartbeat-tool-response-BCz-9pPv.js";
|
|
37
|
-
import { _ as buildAgentHookContextChannelFields, g as listActiveProcessSessionReferences, h as resolveContextEngineCapabilities, m as resolveEmbeddedCompactionTarget, p as buildEmbeddedCompactionRuntimeContext, r as forgetPromptBuildDrainCacheForRun } from "./attempt.prompt-helpers-CVBP6t5J.js";
|
|
38
|
-
import { i as pickFallbackThinkingLevel, s as normalizeTextForComparison } from "./pi-embedded-helpers-CsYU9hpC.js";
|
|
39
|
-
import { S as parseImageSizeError, _ as isRateLimitAssistantError, a as formatAssistantErrorText, c as isBillingAssistantError, f as isFailoverAssistantError, g as isLikelyContextOverflowError, i as extractObservedOverflowTokenCount, p as isFailoverErrorMessage, s as isAuthAssistantError, t as classifyFailoverReason, u as isCompactionFailureError, x as parseImageDimensionError } from "./errors-DVYBGiY7.js";
|
|
40
|
-
import { n as resolveProcessToolScopeKey } from "./pi-tools-DOiFN8QJ.js";
|
|
41
|
-
import { c as resolveFailoverStatus, n as coerceToFailoverError, r as describeFailoverError, t as FailoverError } from "./failover-error-DcavCkbi.js";
|
|
42
|
-
import "./auth-profiles-Cwdg59xU.js";
|
|
43
|
-
import { n as markAuthProfileSuccess } from "./profiles-DP8D3ib5.js";
|
|
44
|
-
import { i as resolveAuthProfileOrder, l as isProfileInCooldown, r as resolveAuthProfileEligibility } from "./order-Bu0ANozT.js";
|
|
45
|
-
import { d as sanitizeRuntimeProviderRequestOverrides, o as resolveProviderRequestConfig } from "./provider-request-config-CsX7LLsy.js";
|
|
46
|
-
import { t as redactIdentifier } from "./redact-identifier-DBO6OkZP.js";
|
|
47
|
-
import { t as sanitizeForConsole } from "./console-sanitize-BUMxGUp3.js";
|
|
48
|
-
import { a as markAuthProfileFailure, s as resolveProfilesUnavailableReason } from "./usage-CtCx0aoe.js";
|
|
49
|
-
import { i as getApiKeyForModel, n as applyLocalNoAuthHeaderOverride, p as shouldPreferExplicitConfigApiKeyAuth, t as applyAuthHeaderOverride } from "./model-auth-DH85P33O.js";
|
|
50
|
-
import { c as retireSessionMcpRuntimeForSessionKey, s as retireSessionMcpRuntime } from "./pi-bundle-mcp-runtime-DpUWOkOe.js";
|
|
51
|
-
import "./pi-bundle-mcp-tools-DbNUbe56.js";
|
|
52
|
-
import { d as hasOutboundDeliveryEvidence, u as hasMessagingToolDeliveryEvidence } from "./subagent-announce-delivery-CbfRRdwt.js";
|
|
53
|
-
import { A as runAgentCleanupStep, S as truncateOversizedToolResultsInSession, b as resolveLiveToolResultMaxChars, g as resolveCompactionTimeoutMs, m as compactContextEngineWithSafetyTimeout, x as sessionLikelyHasOversizedToolResults } from "./attempt.tool-run-context-UU1BUUC9.js";
|
|
54
|
-
import { i as extractAssistantVisibleText, r as extractAssistantThinking } from "./pi-embedded-utils-CZ0KV7bJ.js";
|
|
55
|
-
import { n as isLikelyMutatingToolName } from "./tool-mutation-DHAIDwUO.js";
|
|
56
|
-
import { d as parseReplyDirectives } from "./payloads-ClMXLjYr.js";
|
|
57
|
-
import { N as formatToolAggregate } from "./channel-streaming-BubngPMB.js";
|
|
58
|
-
import { a as suspendSession, c as shouldAllowCooldownProbeForReason, d as shouldSuppressRawErrorConsoleSuffix, i as resolveSessionSuspensionReason, l as buildApiErrorObservationFields, o as LiveSessionModelSwitchError } from "./model-fallback-qEXBEVUu.js";
|
|
59
|
-
import { t as log$1 } from "./logger-k-VzKT7P.js";
|
|
60
|
-
import "./tool-split-DDqLEhqo.js";
|
|
61
|
-
import { n as resolveGlobalLane, r as resolveSessionLane } from "./lanes-BrQRlRRS.js";
|
|
62
|
-
import { i as resolveStoredSessionKeyForSessionId, r as resolveSessionKeyForRequest } from "./session-CD4chmlr.js";
|
|
63
|
-
import { t as ensureContextEnginesInitialized } from "./init-BXF3o80o.js";
|
|
64
|
-
import { c as runContextEngineMaintenance } from "./context-engine-lifecycle-DvEDHkQz.js";
|
|
65
|
-
import "./extra-params-CBOqDb-D.js";
|
|
66
|
-
import { a as resolveContextWindowInfo, i as formatContextWindowWarningMessage, n as evaluateContextWindowGuard, r as formatContextWindowBlockMessage } from "./context-window-guard-DzHCYWZr.js";
|
|
67
|
-
import { t as ensureSelectedAgentHarnessPlugin } from "./runtime-plugin-DsZkgOfu.js";
|
|
68
|
-
import { c as captureCompactionCheckpointSnapshotAsync, h as resolveSessionCompactionCheckpointReason, l as cleanupCompactionCheckpointSnapshot, m as readSessionLeafIdFromTranscriptAsync, n as asCompactionHookRunner, p as persistSessionCompactionCheckpoint, s as runPostCompactionSideEffects, t as readPiModelContextTokens } from "./model-context-tokens-yhMbHeUE.js";
|
|
69
|
-
import { t as ensureRuntimePluginsLoaded } from "./runtime-plugins-Cor0T8kU.js";
|
|
70
|
-
import { n as resolveModelAsync } from "./model-BNkH9D7K.js";
|
|
71
|
-
import { n as createAgentHarnessTaskRuntimeScope } from "./agent-harness-task-runtime-scope-BiH8QC-b.js";
|
|
72
|
-
import { n as shouldSwitchToLiveModel, t as clearLiveModelSwitchPending } from "./live-model-switch-OF42bykh.js";
|
|
73
|
-
import { t as buildAgentRuntimeAuthPlan } from "./auth-Bn2_1BPx.js";
|
|
74
|
-
import { r as buildAgentRuntimePlan } from "./build-33AnG55F.js";
|
|
75
|
-
import { n as resolveRunWorkspaceDir, t as redactRunIdentifier } from "./workspace-run-Ct8kmmAx.js";
|
|
76
|
-
import fs from "node:fs/promises";
|
|
77
|
-
import { randomBytes } from "node:crypto";
|
|
78
|
-
//#region src/agents/pi-embedded-runner/compact.queued.ts
|
|
79
|
-
function shouldFallbackAfterHarnessCompaction(result) {
|
|
80
|
-
return result?.ok === false && (result.failure?.reason === "missing_thread_binding" || result.failure?.reason === "stale_thread_binding");
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Compacts a session with lane queueing (session lane + global lane).
|
|
84
|
-
* Use this from outside a lane context. If already inside a lane, use
|
|
85
|
-
* `compactEmbeddedPiSessionDirect` to avoid deadlocks.
|
|
86
|
-
*/
|
|
87
|
-
async function compactEmbeddedPiSession(params) {
|
|
88
|
-
ensureRuntimePluginsLoaded({
|
|
89
|
-
config: params.config,
|
|
90
|
-
workspaceDir: params.workspaceDir,
|
|
91
|
-
allowGatewaySubagentBinding: params.allowGatewaySubagentBinding
|
|
92
|
-
});
|
|
93
|
-
ensureContextEnginesInitialized();
|
|
94
|
-
const agentIds = resolveSessionAgentIds({
|
|
95
|
-
sessionKey: params.sessionKey,
|
|
96
|
-
config: params.config
|
|
97
|
-
});
|
|
98
|
-
const agentDir = params.agentDir ?? resolveAgentDir(params.config ?? {}, agentIds.sessionAgentId);
|
|
99
|
-
const resolvedWorkspaceDir = resolveUserPath(params.workspaceDir);
|
|
100
|
-
const contextEngine = await resolveContextEngine(params.config, {
|
|
101
|
-
agentDir,
|
|
102
|
-
workspaceDir: resolvedWorkspaceDir
|
|
103
|
-
});
|
|
104
|
-
let contextTokenBudget = params.contextTokenBudget;
|
|
105
|
-
if (!contextTokenBudget || !Number.isFinite(contextTokenBudget) || contextTokenBudget <= 0) {
|
|
106
|
-
const resolvedCompactionTarget = resolveEmbeddedCompactionTarget({
|
|
107
|
-
config: params.config,
|
|
108
|
-
provider: params.provider,
|
|
109
|
-
modelId: params.model,
|
|
110
|
-
authProfileId: params.authProfileId,
|
|
111
|
-
defaultProvider: DEFAULT_PROVIDER,
|
|
112
|
-
defaultModel: DEFAULT_MODEL
|
|
113
|
-
});
|
|
114
|
-
const ceProvider = resolvedCompactionTarget.provider ?? "openai";
|
|
115
|
-
const ceModelId = resolvedCompactionTarget.model ?? "gpt-5.5";
|
|
116
|
-
const { model: ceModel } = await resolveModelAsync(ceProvider, ceModelId, agentDir, params.config);
|
|
117
|
-
const ceRuntimeModel = ceModel;
|
|
118
|
-
const ceHarnessPolicy = resolveAgentHarnessPolicy({
|
|
119
|
-
provider: ceProvider,
|
|
120
|
-
modelId: ceModelId,
|
|
121
|
-
config: params.config,
|
|
122
|
-
agentId: agentIds.sessionAgentId,
|
|
123
|
-
sessionKey: params.sessionKey
|
|
124
|
-
});
|
|
125
|
-
contextTokenBudget = resolveContextWindowInfo({
|
|
126
|
-
cfg: params.config,
|
|
127
|
-
provider: resolveContextConfigProviderForRuntime({
|
|
128
|
-
provider: ceProvider,
|
|
129
|
-
runtimeId: ceHarnessPolicy.runtime
|
|
130
|
-
}),
|
|
131
|
-
modelId: ceModelId,
|
|
132
|
-
modelContextTokens: readPiModelContextTokens(ceModel),
|
|
133
|
-
modelContextWindow: ceRuntimeModel?.contextWindow,
|
|
134
|
-
defaultTokens: DEFAULT_CONTEXT_TOKENS
|
|
135
|
-
}).tokens;
|
|
136
|
-
}
|
|
137
|
-
const contextEngineRuntimeContext = buildCompactionContextEngineRuntimeContext({
|
|
138
|
-
params,
|
|
139
|
-
agentDir,
|
|
140
|
-
contextTokenBudget,
|
|
141
|
-
contextEnginePluginId: resolveContextEngineOwnerPluginId(contextEngine)
|
|
142
|
-
});
|
|
143
|
-
const harnessResult = await maybeCompactAgentHarnessSession({
|
|
144
|
-
...params,
|
|
145
|
-
contextEngine,
|
|
146
|
-
contextTokenBudget,
|
|
147
|
-
contextEngineRuntimeContext
|
|
148
|
-
});
|
|
149
|
-
if (harnessResult) {
|
|
150
|
-
if (!shouldFallbackAfterHarnessCompaction(harnessResult)) {
|
|
151
|
-
await contextEngine.dispose?.();
|
|
152
|
-
return harnessResult;
|
|
153
|
-
}
|
|
154
|
-
log$1.warn(`native harness compaction could not use its session binding; falling back to context engine: ${harnessResult.reason ?? "unknown"}`);
|
|
155
|
-
}
|
|
156
|
-
const sessionLane = resolveSessionLane(params.sessionKey?.trim() || params.sessionId);
|
|
157
|
-
const globalLane = resolveGlobalLane(params.lane);
|
|
158
|
-
const enqueueGlobal = params.enqueue ?? ((task, opts) => enqueueCommandInLane(globalLane, task, opts));
|
|
159
|
-
return enqueueCommandInLane(sessionLane, () => enqueueGlobal(async () => {
|
|
160
|
-
let checkpointSnapshot = null;
|
|
161
|
-
let checkpointSnapshotRetained = false;
|
|
162
|
-
try {
|
|
163
|
-
const engineOwnsCompaction = contextEngine.info.ownsCompaction === true;
|
|
164
|
-
checkpointSnapshot = engineOwnsCompaction ? await captureCompactionCheckpointSnapshotAsync({ sessionFile: params.sessionFile }) : null;
|
|
165
|
-
const hookRunner = engineOwnsCompaction ? asCompactionHookRunner(getGlobalHookRunner()) : null;
|
|
166
|
-
const hookSessionKey = params.sessionKey?.trim() || params.sessionId;
|
|
167
|
-
const { sessionAgentId } = resolveSessionAgentIds({
|
|
168
|
-
sessionKey: params.sessionKey,
|
|
169
|
-
config: params.config
|
|
170
|
-
});
|
|
171
|
-
const resolvedMessageProvider = params.messageChannel ?? params.messageProvider;
|
|
172
|
-
const hookCtx = {
|
|
173
|
-
sessionId: params.sessionId,
|
|
174
|
-
agentId: sessionAgentId,
|
|
175
|
-
sessionKey: hookSessionKey,
|
|
176
|
-
workspaceDir: resolvedWorkspaceDir,
|
|
177
|
-
messageProvider: resolvedMessageProvider
|
|
178
|
-
};
|
|
179
|
-
const runtimeContext = contextEngineRuntimeContext;
|
|
180
|
-
if (hookRunner?.hasHooks?.("before_compaction") && hookRunner.runBeforeCompaction) try {
|
|
181
|
-
await hookRunner.runBeforeCompaction({
|
|
182
|
-
messageCount: -1,
|
|
183
|
-
sessionFile: params.sessionFile
|
|
184
|
-
}, hookCtx);
|
|
185
|
-
} catch (err) {
|
|
186
|
-
log$1.warn("before_compaction hook failed", { errorMessage: formatErrorMessage(err) });
|
|
187
|
-
}
|
|
188
|
-
let result;
|
|
189
|
-
try {
|
|
190
|
-
result = await compactContextEngineWithSafetyTimeout(contextEngine, {
|
|
191
|
-
sessionId: params.sessionId,
|
|
192
|
-
sessionKey: params.sessionKey,
|
|
193
|
-
sessionFile: params.sessionFile,
|
|
194
|
-
tokenBudget: contextTokenBudget,
|
|
195
|
-
currentTokenCount: params.currentTokenCount,
|
|
196
|
-
compactionTarget: params.trigger === "manual" ? "threshold" : "budget",
|
|
197
|
-
customInstructions: params.customInstructions,
|
|
198
|
-
force: params.trigger === "manual",
|
|
199
|
-
runtimeContext
|
|
200
|
-
}, resolveCompactionTimeoutMs(params.config), params.abortSignal);
|
|
201
|
-
} catch (compactErr) {
|
|
202
|
-
log$1.warn("context-engine compaction failed", { errorMessage: formatErrorMessage(compactErr) });
|
|
203
|
-
result = {
|
|
204
|
-
ok: false,
|
|
205
|
-
compacted: false,
|
|
206
|
-
reason: formatErrorMessage(compactErr)
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
const delegatedSessionId = result.result?.sessionId;
|
|
210
|
-
const delegatedSessionFile = result.result?.sessionFile;
|
|
211
|
-
const delegatedRotatedTranscript = typeof delegatedSessionId === "string" && delegatedSessionId !== params.sessionId || typeof delegatedSessionFile === "string" && delegatedSessionFile !== params.sessionFile;
|
|
212
|
-
let postCompactionSessionId = delegatedSessionId ?? params.sessionId;
|
|
213
|
-
let postCompactionSessionFile = delegatedSessionFile ?? params.sessionFile;
|
|
214
|
-
let postCompactionLeafId;
|
|
215
|
-
if (result.ok && result.compacted) {
|
|
216
|
-
if (shouldRotateCompactionTranscript(params.config) && !delegatedRotatedTranscript) try {
|
|
217
|
-
const rotation = await rotateTranscriptFileAfterCompaction({ sessionFile: params.sessionFile });
|
|
218
|
-
if (rotation.rotated) {
|
|
219
|
-
postCompactionSessionId = rotation.sessionId ?? postCompactionSessionId;
|
|
220
|
-
postCompactionSessionFile = rotation.sessionFile ?? postCompactionSessionFile;
|
|
221
|
-
postCompactionLeafId = rotation.leafId;
|
|
222
|
-
log$1.info(`[compaction] rotated active transcript after context-engine compaction (sessionKey=${params.sessionKey ?? params.sessionId})`);
|
|
223
|
-
}
|
|
224
|
-
} catch (err) {
|
|
225
|
-
log$1.warn("failed to rotate compacted transcript", { errorMessage: formatErrorMessage(err) });
|
|
226
|
-
}
|
|
227
|
-
if (params.config && params.sessionKey && checkpointSnapshot) try {
|
|
228
|
-
const postLeafId = postCompactionLeafId ?? await readSessionLeafIdFromTranscriptAsync(postCompactionSessionFile) ?? void 0;
|
|
229
|
-
checkpointSnapshotRetained = await persistSessionCompactionCheckpoint({
|
|
230
|
-
cfg: params.config,
|
|
231
|
-
sessionKey: params.sessionKey,
|
|
232
|
-
sessionId: postCompactionSessionId,
|
|
233
|
-
reason: resolveSessionCompactionCheckpointReason({ trigger: params.trigger }),
|
|
234
|
-
snapshot: checkpointSnapshot,
|
|
235
|
-
summary: result.result?.summary,
|
|
236
|
-
firstKeptEntryId: result.result?.firstKeptEntryId,
|
|
237
|
-
tokensBefore: result.result?.tokensBefore,
|
|
238
|
-
tokensAfter: result.result?.tokensAfter,
|
|
239
|
-
postSessionFile: postCompactionSessionFile,
|
|
240
|
-
postLeafId,
|
|
241
|
-
postEntryId: postLeafId
|
|
242
|
-
}) !== null;
|
|
243
|
-
} catch (err) {
|
|
244
|
-
log$1.warn("failed to persist compaction checkpoint", { errorMessage: formatErrorMessage(err) });
|
|
245
|
-
}
|
|
246
|
-
await runContextEngineMaintenance({
|
|
247
|
-
contextEngine,
|
|
248
|
-
sessionId: postCompactionSessionId,
|
|
249
|
-
sessionKey: params.sessionKey,
|
|
250
|
-
sessionFile: postCompactionSessionFile,
|
|
251
|
-
reason: "compaction",
|
|
252
|
-
runtimeContext,
|
|
253
|
-
config: params.config
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
if (engineOwnsCompaction && result.ok && result.compacted) await runPostCompactionSideEffects({
|
|
257
|
-
config: params.config,
|
|
258
|
-
sessionKey: params.sessionKey,
|
|
259
|
-
sessionFile: postCompactionSessionFile
|
|
260
|
-
});
|
|
261
|
-
if (result.ok && result.compacted && hookRunner?.hasHooks?.("after_compaction") && hookRunner.runAfterCompaction) try {
|
|
262
|
-
const afterHookCtx = {
|
|
263
|
-
...hookCtx,
|
|
264
|
-
sessionId: postCompactionSessionId
|
|
265
|
-
};
|
|
266
|
-
await hookRunner.runAfterCompaction({
|
|
267
|
-
messageCount: -1,
|
|
268
|
-
compactedCount: -1,
|
|
269
|
-
tokenCount: result.result?.tokensAfter,
|
|
270
|
-
sessionFile: postCompactionSessionFile
|
|
271
|
-
}, afterHookCtx);
|
|
272
|
-
} catch (err) {
|
|
273
|
-
log$1.warn("after_compaction hook failed", { errorMessage: formatErrorMessage(err) });
|
|
274
|
-
}
|
|
275
|
-
return {
|
|
276
|
-
ok: result.ok,
|
|
277
|
-
compacted: result.compacted,
|
|
278
|
-
reason: result.reason,
|
|
279
|
-
result: result.result ? {
|
|
280
|
-
summary: result.result.summary ?? "",
|
|
281
|
-
firstKeptEntryId: result.result.firstKeptEntryId ?? "",
|
|
282
|
-
tokensBefore: result.result.tokensBefore,
|
|
283
|
-
tokensAfter: result.result.tokensAfter,
|
|
284
|
-
details: result.result.details,
|
|
285
|
-
...postCompactionSessionId !== params.sessionId ? { sessionId: postCompactionSessionId } : {},
|
|
286
|
-
...postCompactionSessionFile !== params.sessionFile ? { sessionFile: postCompactionSessionFile } : {}
|
|
287
|
-
} : void 0
|
|
288
|
-
};
|
|
289
|
-
} finally {
|
|
290
|
-
if (!checkpointSnapshotRetained) await cleanupCompactionCheckpointSnapshot(checkpointSnapshot);
|
|
291
|
-
await contextEngine.dispose?.();
|
|
292
|
-
}
|
|
293
|
-
}));
|
|
294
|
-
}
|
|
295
|
-
function buildCompactionContextEngineRuntimeContext(params) {
|
|
296
|
-
const { sessionAgentId } = resolveSessionAgentIds({
|
|
297
|
-
sessionKey: params.params.sessionKey,
|
|
298
|
-
config: params.params.config
|
|
299
|
-
});
|
|
300
|
-
return {
|
|
301
|
-
...params.params,
|
|
302
|
-
...buildEmbeddedCompactionRuntimeContext({
|
|
303
|
-
sessionKey: params.params.sessionKey,
|
|
304
|
-
messageChannel: params.params.messageChannel,
|
|
305
|
-
messageProvider: params.params.messageProvider,
|
|
306
|
-
agentAccountId: params.params.agentAccountId,
|
|
307
|
-
currentChannelId: params.params.currentChannelId,
|
|
308
|
-
currentThreadTs: params.params.currentThreadTs,
|
|
309
|
-
currentMessageId: params.params.currentMessageId,
|
|
310
|
-
authProfileId: params.params.authProfileId,
|
|
311
|
-
workspaceDir: params.params.workspaceDir,
|
|
312
|
-
agentDir: params.agentDir,
|
|
313
|
-
config: params.params.config,
|
|
314
|
-
skillsSnapshot: params.params.skillsSnapshot,
|
|
315
|
-
senderIsOwner: params.params.senderIsOwner,
|
|
316
|
-
senderId: params.params.senderId,
|
|
317
|
-
provider: params.params.provider,
|
|
318
|
-
modelId: params.params.model,
|
|
319
|
-
modelFallbacksOverride: params.params.modelFallbacksOverride,
|
|
320
|
-
thinkLevel: params.params.thinkLevel,
|
|
321
|
-
reasoningLevel: params.params.reasoningLevel,
|
|
322
|
-
bashElevated: params.params.bashElevated,
|
|
323
|
-
extraSystemPrompt: params.params.extraSystemPrompt,
|
|
324
|
-
sourceReplyDeliveryMode: params.params.sourceReplyDeliveryMode,
|
|
325
|
-
ownerNumbers: params.params.ownerNumbers
|
|
326
|
-
}),
|
|
327
|
-
...resolveContextEngineCapabilities({
|
|
328
|
-
config: params.params.config,
|
|
329
|
-
sessionKey: params.params.sessionKey,
|
|
330
|
-
agentId: sessionAgentId,
|
|
331
|
-
contextEnginePluginId: params.contextEnginePluginId,
|
|
332
|
-
purpose: "context-engine.compaction"
|
|
333
|
-
}),
|
|
334
|
-
tokenBudget: params.contextTokenBudget,
|
|
335
|
-
currentTokenCount: params.params.currentTokenCount
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
//#endregion
|
|
339
|
-
//#region src/agents/tool-error-summary.ts
|
|
340
|
-
const EXEC_LIKE_TOOL_NAMES = new Set(["exec", "bash"]);
|
|
341
|
-
function isExecLikeToolName(toolName) {
|
|
342
|
-
return EXEC_LIKE_TOOL_NAMES.has(normalizeOptionalLowercaseString(toolName) ?? "");
|
|
343
|
-
}
|
|
344
|
-
//#endregion
|
|
345
|
-
//#region src/agents/pi-embedded-runner/failure-signal.ts
|
|
346
|
-
const FAILURE_SIGNAL_CODES = ["SYSTEM_RUN_DENIED", "INVALID_REQUEST"];
|
|
347
|
-
function resolveFailureSignalCode(value) {
|
|
348
|
-
for (const code of FAILURE_SIGNAL_CODES) if (value === code) return code;
|
|
349
|
-
}
|
|
350
|
-
function resolveEmbeddedRunFailureSignal(params) {
|
|
351
|
-
if (params.trigger !== "cron") return;
|
|
352
|
-
const lastToolError = params.lastToolError;
|
|
353
|
-
if (!lastToolError || !isExecLikeToolName(lastToolError.toolName)) return;
|
|
354
|
-
const code = resolveFailureSignalCode(normalizeOptionalString(lastToolError.errorCode));
|
|
355
|
-
if (!code) return;
|
|
356
|
-
const message = normalizeOptionalString(lastToolError.error) ?? code;
|
|
357
|
-
return {
|
|
358
|
-
kind: "execution_denied",
|
|
359
|
-
source: "tool",
|
|
360
|
-
...lastToolError.toolName ? { toolName: lastToolError.toolName } : {},
|
|
361
|
-
code,
|
|
362
|
-
message,
|
|
363
|
-
fatalForCron: true
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
//#endregion
|
|
367
|
-
//#region src/agents/pi-embedded-runner/post-compaction-loop-guard.ts
|
|
368
|
-
const log = createSubsystemLogger("agents/post-compaction-guard");
|
|
369
|
-
const DEFAULT_WINDOW_SIZE = 3;
|
|
370
|
-
function asPositiveInt(value, fallback) {
|
|
371
|
-
if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) return fallback;
|
|
372
|
-
return value;
|
|
373
|
-
}
|
|
374
|
-
function createPostCompactionLoopGuard(config, options) {
|
|
375
|
-
const state = {
|
|
376
|
-
enabled: options?.enabled ?? true,
|
|
377
|
-
windowSize: asPositiveInt(config?.windowSize, DEFAULT_WINDOW_SIZE),
|
|
378
|
-
remainingAttempts: 0,
|
|
379
|
-
history: []
|
|
380
|
-
};
|
|
381
|
-
const armPostCompaction = () => {
|
|
382
|
-
state.remainingAttempts = state.windowSize;
|
|
383
|
-
state.history = [];
|
|
384
|
-
if (state.enabled) log.info(`post-compaction guard armed for ${state.windowSize} attempts`);
|
|
385
|
-
};
|
|
386
|
-
const observe = (call) => {
|
|
387
|
-
if (!state.enabled) return {
|
|
388
|
-
shouldAbort: false,
|
|
389
|
-
armed: false,
|
|
390
|
-
remainingAttempts: 0
|
|
391
|
-
};
|
|
392
|
-
if (state.remainingAttempts <= 0) return {
|
|
393
|
-
shouldAbort: false,
|
|
394
|
-
armed: false,
|
|
395
|
-
remainingAttempts: 0
|
|
396
|
-
};
|
|
397
|
-
state.remainingAttempts -= 1;
|
|
398
|
-
state.history.push(call);
|
|
399
|
-
const armedAfter = state.remainingAttempts > 0;
|
|
400
|
-
const matches = state.history.filter((entry) => entry.toolName === call.toolName && entry.argsHash === call.argsHash && entry.resultHash === call.resultHash);
|
|
401
|
-
if (matches.length >= state.windowSize) {
|
|
402
|
-
log.error(`post-compaction loop persisted: tool=${call.toolName} repeated ${matches.length} times with identical args+result post-compaction`);
|
|
403
|
-
return {
|
|
404
|
-
shouldAbort: true,
|
|
405
|
-
armed: armedAfter,
|
|
406
|
-
remainingAttempts: state.remainingAttempts,
|
|
407
|
-
detector: "compaction_loop_persisted",
|
|
408
|
-
count: matches.length,
|
|
409
|
-
toolName: call.toolName,
|
|
410
|
-
message: `CRITICAL: tool ${call.toolName} repeated ${matches.length} times with identical arguments and identical results within ${state.windowSize} attempts after auto-compaction. The compaction did not break the loop. Aborting to prevent runaway resource use.`
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
return {
|
|
414
|
-
shouldAbort: false,
|
|
415
|
-
armed: armedAfter,
|
|
416
|
-
remainingAttempts: state.remainingAttempts
|
|
417
|
-
};
|
|
418
|
-
};
|
|
419
|
-
const snapshot = () => ({
|
|
420
|
-
armed: state.remainingAttempts > 0,
|
|
421
|
-
remainingAttempts: state.remainingAttempts
|
|
422
|
-
});
|
|
423
|
-
return {
|
|
424
|
-
armPostCompaction,
|
|
425
|
-
observe,
|
|
426
|
-
snapshot
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
var PostCompactionLoopPersistedError = class PostCompactionLoopPersistedError extends Error {
|
|
430
|
-
constructor(message, details) {
|
|
431
|
-
super(message);
|
|
432
|
-
this.name = "PostCompactionLoopPersistedError";
|
|
433
|
-
this.detector = details.detector;
|
|
434
|
-
this.count = details.count;
|
|
435
|
-
this.toolName = details.toolName;
|
|
436
|
-
}
|
|
437
|
-
static fromVerdict(verdict) {
|
|
438
|
-
return new PostCompactionLoopPersistedError(verdict.message, {
|
|
439
|
-
detector: verdict.detector,
|
|
440
|
-
count: verdict.count,
|
|
441
|
-
toolName: verdict.toolName
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
//#endregion
|
|
446
|
-
//#region src/agents/pi-embedded-runner/run/failover-policy.ts
|
|
447
|
-
function shouldEscalateRetryLimit(reason) {
|
|
448
|
-
return Boolean(reason && reason !== "timeout" && reason !== "model_not_found" && reason !== "format" && reason !== "session_expired");
|
|
449
|
-
}
|
|
450
|
-
function isTerminalFormatFailure(params) {
|
|
451
|
-
return params.failoverFailure && params.failoverReason === "format" && params.allowFormatRetry !== true;
|
|
452
|
-
}
|
|
453
|
-
function shouldRotatePrompt(params) {
|
|
454
|
-
return params.failoverFailure && params.failoverReason !== "timeout" && !isTerminalFormatFailure(params);
|
|
455
|
-
}
|
|
456
|
-
function isAssistantTimeoutFailure(params) {
|
|
457
|
-
return params.idleTimedOut || params.timedOut && !params.timedOutDuringCompaction && !params.timedOutDuringToolExecution;
|
|
458
|
-
}
|
|
459
|
-
function shouldRotateAssistant(params) {
|
|
460
|
-
if (isTerminalFormatFailure(params)) return false;
|
|
461
|
-
return !params.aborted && params.failoverFailure || isAssistantTimeoutFailure(params);
|
|
462
|
-
}
|
|
463
|
-
function mergeRetryFailoverReason(params) {
|
|
464
|
-
return params.failoverReason ?? (params.timedOut ? "timeout" : null) ?? params.previous;
|
|
465
|
-
}
|
|
466
|
-
function resolveRunFailoverDecision(params) {
|
|
467
|
-
if (params.stage === "retry_limit") {
|
|
468
|
-
if (params.fallbackConfigured && shouldEscalateRetryLimit(params.failoverReason)) return {
|
|
469
|
-
action: "fallback_model",
|
|
470
|
-
reason: params.failoverReason ?? "unknown"
|
|
471
|
-
};
|
|
472
|
-
return { action: "return_error_payload" };
|
|
473
|
-
}
|
|
474
|
-
if (params.stage === "prompt") {
|
|
475
|
-
if (params.externalAbort) return {
|
|
476
|
-
action: "surface_error",
|
|
477
|
-
reason: params.failoverReason
|
|
478
|
-
};
|
|
479
|
-
if (!params.profileRotated && shouldRotatePrompt(params)) return {
|
|
480
|
-
action: "rotate_profile",
|
|
481
|
-
reason: params.failoverReason
|
|
482
|
-
};
|
|
483
|
-
if (params.fallbackConfigured && params.failoverFailure && !isTerminalFormatFailure(params)) return {
|
|
484
|
-
action: "fallback_model",
|
|
485
|
-
reason: params.failoverReason ?? "unknown"
|
|
486
|
-
};
|
|
487
|
-
return {
|
|
488
|
-
action: "surface_error",
|
|
489
|
-
reason: params.failoverReason
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
if (params.externalAbort) return {
|
|
493
|
-
action: "surface_error",
|
|
494
|
-
reason: params.failoverReason
|
|
495
|
-
};
|
|
496
|
-
if (isTerminalFormatFailure(params)) return {
|
|
497
|
-
action: "surface_error",
|
|
498
|
-
reason: params.failoverReason
|
|
499
|
-
};
|
|
500
|
-
const assistantShouldRotate = shouldRotateAssistant(params);
|
|
501
|
-
if (!params.profileRotated && assistantShouldRotate) return {
|
|
502
|
-
action: "rotate_profile",
|
|
503
|
-
reason: params.failoverReason
|
|
504
|
-
};
|
|
505
|
-
if (assistantShouldRotate && params.fallbackConfigured) return {
|
|
506
|
-
action: "fallback_model",
|
|
507
|
-
reason: isAssistantTimeoutFailure(params) ? "timeout" : params.failoverReason ?? "unknown"
|
|
508
|
-
};
|
|
509
|
-
if (!assistantShouldRotate) return { action: "continue_normal" };
|
|
510
|
-
return {
|
|
511
|
-
action: "surface_error",
|
|
512
|
-
reason: params.failoverReason
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
//#endregion
|
|
516
|
-
//#region src/agents/pi-embedded-runner/run/assistant-failover.ts
|
|
517
|
-
async function handleAssistantFailover(params) {
|
|
518
|
-
let overloadProfileRotations = params.overloadProfileRotations;
|
|
519
|
-
let decision = params.initialDecision;
|
|
520
|
-
const sameModelIdleTimeoutRetry = () => {
|
|
521
|
-
params.warn(`[llm-idle-timeout] ${sanitizeForLog(params.provider)}/${sanitizeForLog(params.modelId)} produced no reply before the idle watchdog; retrying same model`);
|
|
522
|
-
return {
|
|
523
|
-
action: "retry",
|
|
524
|
-
overloadProfileRotations,
|
|
525
|
-
retryKind: "same_model_idle_timeout",
|
|
526
|
-
lastRetryFailoverReason: mergeRetryFailoverReason({
|
|
527
|
-
previous: params.previousRetryFailoverReason,
|
|
528
|
-
failoverReason: params.failoverReason,
|
|
529
|
-
timedOut: true
|
|
530
|
-
})
|
|
531
|
-
};
|
|
532
|
-
};
|
|
533
|
-
if (decision.action === "rotate_profile") {
|
|
534
|
-
const failedProfileId = params.lastProfileId;
|
|
535
|
-
const timeoutFailure = params.timedOut || params.idleTimedOut;
|
|
536
|
-
const failureReason = params.assistantProfileFailureReason;
|
|
537
|
-
const markFailedProfile = async () => {
|
|
538
|
-
if (!failedProfileId || !failureReason) return;
|
|
539
|
-
try {
|
|
540
|
-
await params.maybeMarkAuthProfileFailure({
|
|
541
|
-
profileId: failedProfileId,
|
|
542
|
-
reason: failureReason,
|
|
543
|
-
modelId: params.modelId
|
|
544
|
-
});
|
|
545
|
-
} catch (err) {
|
|
546
|
-
params.warn(`profile failure mark failed: ${String(err)}`);
|
|
547
|
-
}
|
|
548
|
-
};
|
|
549
|
-
if (params.failoverReason === "overloaded") {
|
|
550
|
-
overloadProfileRotations += 1;
|
|
551
|
-
if (overloadProfileRotations > params.overloadProfileRotationLimit && params.fallbackConfigured) {
|
|
552
|
-
const status = resolveFailoverStatus("overloaded");
|
|
553
|
-
params.warn(`overload profile rotation cap reached for ${sanitizeForLog(params.provider)}/${sanitizeForLog(params.modelId)} after ${overloadProfileRotations} rotations; escalating to model fallback`);
|
|
554
|
-
await markFailedProfile();
|
|
555
|
-
params.logAssistantFailoverDecision("fallback_model", { status });
|
|
556
|
-
return {
|
|
557
|
-
action: "throw",
|
|
558
|
-
overloadProfileRotations,
|
|
559
|
-
error: new FailoverError("The AI service is temporarily overloaded. Please try again in a moment.", {
|
|
560
|
-
reason: "overloaded",
|
|
561
|
-
provider: params.activeErrorContext.provider,
|
|
562
|
-
model: params.activeErrorContext.model,
|
|
563
|
-
profileId: params.lastProfileId,
|
|
564
|
-
status,
|
|
565
|
-
rawError: params.lastAssistant?.errorMessage?.trim()
|
|
566
|
-
})
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
if (params.failoverReason === "rate_limit") params.maybeEscalateRateLimitProfileFallback({
|
|
571
|
-
failoverProvider: params.activeErrorContext.provider,
|
|
572
|
-
failoverModel: params.activeErrorContext.model,
|
|
573
|
-
logFallbackDecision: params.logAssistantFailoverDecision
|
|
574
|
-
});
|
|
575
|
-
const rotated = await params.advanceAuthProfile();
|
|
576
|
-
const markFailedProfilePromise = markFailedProfile();
|
|
577
|
-
if (timeoutFailure && !params.isProbeSession && failedProfileId) {
|
|
578
|
-
const timeoutLabel = params.idleTimedOut ? "idle timeout (model silent)" : "timed out";
|
|
579
|
-
params.warn(`Profile ${failedProfileId} ${timeoutLabel}. Trying next account...`);
|
|
580
|
-
}
|
|
581
|
-
if (params.cloudCodeAssistFormatError && failedProfileId) params.warn(`Profile ${failedProfileId} hit Cloud Code Assist format error. Tool calls will be sanitized on retry.`);
|
|
582
|
-
if (rotated) {
|
|
583
|
-
params.logAssistantFailoverDecision("rotate_profile");
|
|
584
|
-
await params.maybeBackoffBeforeOverloadFailover(params.failoverReason);
|
|
585
|
-
return {
|
|
586
|
-
action: "retry",
|
|
587
|
-
overloadProfileRotations,
|
|
588
|
-
lastRetryFailoverReason: mergeRetryFailoverReason({
|
|
589
|
-
previous: params.previousRetryFailoverReason,
|
|
590
|
-
failoverReason: params.failoverReason,
|
|
591
|
-
timedOut: params.timedOut || params.idleTimedOut
|
|
592
|
-
})
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
await markFailedProfilePromise;
|
|
596
|
-
if (params.idleTimedOut && params.allowSameModelIdleTimeoutRetry) return sameModelIdleTimeoutRetry();
|
|
597
|
-
decision = resolveRunFailoverDecision({
|
|
598
|
-
stage: "assistant",
|
|
599
|
-
allowFormatRetry: params.cloudCodeAssistFormatError,
|
|
600
|
-
aborted: params.aborted,
|
|
601
|
-
externalAbort: params.externalAbort,
|
|
602
|
-
fallbackConfigured: params.fallbackConfigured,
|
|
603
|
-
failoverFailure: params.failoverFailure,
|
|
604
|
-
failoverReason: params.failoverReason,
|
|
605
|
-
timedOut: params.timedOut,
|
|
606
|
-
idleTimedOut: params.idleTimedOut,
|
|
607
|
-
timedOutDuringCompaction: params.timedOutDuringCompaction,
|
|
608
|
-
timedOutDuringToolExecution: params.timedOutDuringToolExecution,
|
|
609
|
-
profileRotated: true
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
if (decision.action === "fallback_model") {
|
|
613
|
-
await params.maybeBackoffBeforeOverloadFailover(params.failoverReason);
|
|
614
|
-
const message = resolveAssistantFailoverErrorMessage(params);
|
|
615
|
-
const status = resolveFailoverStatus(decision.reason) ?? (isTimeoutErrorMessage(message) ? 408 : void 0);
|
|
616
|
-
params.logAssistantFailoverDecision("fallback_model", { status });
|
|
617
|
-
const shouldSuspend = Boolean(params.sessionKey) && (decision.reason === "rate_limit" || decision.reason === "billing");
|
|
618
|
-
return {
|
|
619
|
-
action: "throw",
|
|
620
|
-
overloadProfileRotations,
|
|
621
|
-
error: new FailoverError(message, {
|
|
622
|
-
reason: decision.reason,
|
|
623
|
-
provider: params.activeErrorContext.provider,
|
|
624
|
-
model: params.activeErrorContext.model,
|
|
625
|
-
profileId: params.lastProfileId,
|
|
626
|
-
status,
|
|
627
|
-
rawError: params.lastAssistant?.errorMessage?.trim(),
|
|
628
|
-
suspend: shouldSuspend
|
|
629
|
-
})
|
|
630
|
-
};
|
|
631
|
-
}
|
|
632
|
-
if (decision.action === "surface_error") {
|
|
633
|
-
if (!params.externalAbort && params.idleTimedOut && params.allowSameModelIdleTimeoutRetry) return sameModelIdleTimeoutRetry();
|
|
634
|
-
params.logAssistantFailoverDecision("surface_error");
|
|
635
|
-
if (!params.externalAbort && !params.timedOut && params.failoverFailure) {
|
|
636
|
-
const message = resolveAssistantFailoverErrorMessage(params);
|
|
637
|
-
const reason = resolveSurfaceErrorReason(decision.reason, params);
|
|
638
|
-
const status = resolveFailoverStatus(reason) ?? (isTimeoutErrorMessage(message) ? 408 : void 0);
|
|
639
|
-
const shouldSuspend = Boolean(params.sessionKey) && (reason === "rate_limit" || reason === "billing");
|
|
640
|
-
return {
|
|
641
|
-
action: "throw",
|
|
642
|
-
overloadProfileRotations,
|
|
643
|
-
error: new FailoverError(message, {
|
|
644
|
-
reason,
|
|
645
|
-
provider: params.activeErrorContext.provider,
|
|
646
|
-
model: params.activeErrorContext.model,
|
|
647
|
-
profileId: params.lastProfileId,
|
|
648
|
-
status,
|
|
649
|
-
rawError: params.lastAssistant?.errorMessage?.trim(),
|
|
650
|
-
suspend: shouldSuspend
|
|
651
|
-
})
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
return {
|
|
656
|
-
action: "continue_normal",
|
|
657
|
-
overloadProfileRotations
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
function resolveAssistantFailoverErrorMessage(params) {
|
|
661
|
-
const timeoutFailure = params.timedOut || params.idleTimedOut;
|
|
662
|
-
return (params.lastAssistant ? formatAssistantErrorText(params.lastAssistant, {
|
|
663
|
-
cfg: params.config,
|
|
664
|
-
sessionKey: params.sessionKey,
|
|
665
|
-
provider: params.activeErrorContext.provider,
|
|
666
|
-
model: params.activeErrorContext.model
|
|
667
|
-
}) : void 0) || params.lastAssistant?.errorMessage?.trim() || (timeoutFailure ? "LLM request timed out." : params.rateLimitFailure ? "LLM request rate limited." : params.billingFailure ? formatBillingErrorMessage(params.activeErrorContext.provider, params.activeErrorContext.model) : params.authFailure ? "LLM request unauthorized." : "LLM request failed.");
|
|
668
|
-
}
|
|
669
|
-
function resolveSurfaceErrorReason(declared, params) {
|
|
670
|
-
if (declared) return declared;
|
|
671
|
-
if (params.billingFailure) return "billing";
|
|
672
|
-
if (params.authFailure) return "auth";
|
|
673
|
-
if (params.rateLimitFailure) return "rate_limit";
|
|
674
|
-
return "unknown";
|
|
675
|
-
}
|
|
676
|
-
//#endregion
|
|
677
|
-
//#region src/agents/runtime-auth-refresh.ts
|
|
678
|
-
function clampRuntimeAuthRefreshDelayMs(params) {
|
|
679
|
-
return resolveSafeTimeoutDelayMs(params.refreshAt - params.now, { minMs: params.minDelayMs });
|
|
680
|
-
}
|
|
681
|
-
//#endregion
|
|
682
|
-
//#region src/agents/pi-embedded-runner/run/auth-controller.ts
|
|
683
|
-
function createEmbeddedRunAuthController(params) {
|
|
684
|
-
const applyPreparedRuntimeRequestOverrides = (paramsForApply) => {
|
|
685
|
-
if (!paramsForApply.preparedAuth.baseUrl && !paramsForApply.preparedAuth.request) return;
|
|
686
|
-
const runtimeRequestConfig = resolveProviderRequestConfig({
|
|
687
|
-
provider: paramsForApply.runtimeModel.provider,
|
|
688
|
-
api: paramsForApply.runtimeModel.api,
|
|
689
|
-
baseUrl: paramsForApply.preparedAuth.baseUrl ?? paramsForApply.runtimeModel.baseUrl,
|
|
690
|
-
providerHeaders: paramsForApply.runtimeModel.headers && typeof paramsForApply.runtimeModel.headers === "object" ? paramsForApply.runtimeModel.headers : void 0,
|
|
691
|
-
request: sanitizeRuntimeProviderRequestOverrides(paramsForApply.preparedAuth.request),
|
|
692
|
-
capability: "llm",
|
|
693
|
-
transport: "stream"
|
|
694
|
-
});
|
|
695
|
-
params.setRuntimeModel({
|
|
696
|
-
...paramsForApply.runtimeModel,
|
|
697
|
-
...paramsForApply.preparedAuth.baseUrl ? { baseUrl: paramsForApply.preparedAuth.baseUrl } : {},
|
|
698
|
-
...runtimeRequestConfig.headers ? { headers: runtimeRequestConfig.headers } : {}
|
|
699
|
-
});
|
|
700
|
-
params.setEffectiveModel({
|
|
701
|
-
...params.getEffectiveModel(),
|
|
702
|
-
...paramsForApply.preparedAuth.baseUrl ? { baseUrl: paramsForApply.preparedAuth.baseUrl } : {},
|
|
703
|
-
...runtimeRequestConfig.headers ? { headers: runtimeRequestConfig.headers } : {}
|
|
704
|
-
});
|
|
705
|
-
};
|
|
706
|
-
const hasRefreshableRuntimeAuth = () => Boolean(params.getRuntimeAuthState()?.sourceApiKey.trim());
|
|
707
|
-
const nextRuntimeAuthGeneration = () => (params.getRuntimeAuthState()?.generation ?? 0) + 1;
|
|
708
|
-
const prepareRuntimeAuthForModel = async (prepareParams) => prepareProviderRuntimeAuth({
|
|
709
|
-
provider: prepareParams.runtimeModel.provider,
|
|
710
|
-
config: params.config,
|
|
711
|
-
workspaceDir: params.workspaceDir,
|
|
712
|
-
env: process.env,
|
|
713
|
-
context: {
|
|
714
|
-
config: params.config,
|
|
715
|
-
agentDir: params.agentDir,
|
|
716
|
-
workspaceDir: params.workspaceDir,
|
|
717
|
-
env: process.env,
|
|
718
|
-
provider: prepareParams.runtimeModel.provider,
|
|
719
|
-
modelId: params.getModelId(),
|
|
720
|
-
model: prepareParams.runtimeModel,
|
|
721
|
-
apiKey: prepareParams.apiKey,
|
|
722
|
-
authMode: prepareParams.authMode,
|
|
723
|
-
profileId: prepareParams.profileId
|
|
724
|
-
}
|
|
725
|
-
});
|
|
726
|
-
const clearRuntimeAuthRefreshTimer = () => {
|
|
727
|
-
const runtimeAuthState = params.getRuntimeAuthState();
|
|
728
|
-
if (!runtimeAuthState?.refreshTimer) return;
|
|
729
|
-
clearTimeout(runtimeAuthState.refreshTimer);
|
|
730
|
-
runtimeAuthState.refreshTimer = void 0;
|
|
731
|
-
};
|
|
732
|
-
const stopRuntimeAuthRefreshTimer = () => {
|
|
733
|
-
if (!params.getRuntimeAuthState()) return;
|
|
734
|
-
params.setRuntimeAuthRefreshCancelled(true);
|
|
735
|
-
clearRuntimeAuthRefreshTimer();
|
|
736
|
-
};
|
|
737
|
-
const refreshRuntimeAuth = async (reason) => {
|
|
738
|
-
const runtimeAuthState = params.getRuntimeAuthState();
|
|
739
|
-
if (!runtimeAuthState) return;
|
|
740
|
-
if (runtimeAuthState.refreshInFlight) {
|
|
741
|
-
await runtimeAuthState.refreshInFlight;
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
const refreshGeneration = runtimeAuthState.generation;
|
|
745
|
-
const refreshProfileId = runtimeAuthState.profileId;
|
|
746
|
-
let refreshPromise;
|
|
747
|
-
refreshPromise = (async () => {
|
|
748
|
-
const currentRuntimeAuthState = params.getRuntimeAuthState();
|
|
749
|
-
const sourceApiKey = currentRuntimeAuthState?.sourceApiKey.trim() ?? "";
|
|
750
|
-
if (!sourceApiKey) throw new Error(`Runtime auth refresh requires a source credential.`);
|
|
751
|
-
const runtimeModel = params.getRuntimeModel();
|
|
752
|
-
params.log.debug(`Refreshing runtime auth for ${runtimeModel.provider} (${reason})...`);
|
|
753
|
-
const preparedAuth = await prepareRuntimeAuthForModel({
|
|
754
|
-
runtimeModel,
|
|
755
|
-
apiKey: sourceApiKey,
|
|
756
|
-
authMode: currentRuntimeAuthState?.authMode ?? "unknown",
|
|
757
|
-
profileId: currentRuntimeAuthState?.profileId
|
|
758
|
-
});
|
|
759
|
-
if (!preparedAuth?.apiKey) throw new Error(`Provider "${runtimeModel.provider}" does not support runtime auth refresh.`);
|
|
760
|
-
const activeRuntimeAuthState = params.getRuntimeAuthState();
|
|
761
|
-
if (!activeRuntimeAuthState || activeRuntimeAuthState.generation !== refreshGeneration || activeRuntimeAuthState.profileId !== refreshProfileId || activeRuntimeAuthState.sourceApiKey.trim() !== sourceApiKey) {
|
|
762
|
-
params.log.debug(`Ignoring stale runtime auth refresh for ${runtimeModel.provider}; auth state advanced before ${reason} refresh completed.`);
|
|
763
|
-
return;
|
|
764
|
-
}
|
|
765
|
-
params.authStorage.setRuntimeApiKey(runtimeModel.provider, preparedAuth.apiKey);
|
|
766
|
-
applyPreparedRuntimeRequestOverrides({
|
|
767
|
-
runtimeModel,
|
|
768
|
-
preparedAuth
|
|
769
|
-
});
|
|
770
|
-
params.setRuntimeAuthState({
|
|
771
|
-
...activeRuntimeAuthState,
|
|
772
|
-
expiresAt: preparedAuth.expiresAt
|
|
773
|
-
});
|
|
774
|
-
if (preparedAuth.expiresAt) {
|
|
775
|
-
const remaining = preparedAuth.expiresAt - Date.now();
|
|
776
|
-
params.log.debug(`Runtime auth refreshed for ${runtimeModel.provider}; expires in ${Math.max(0, Math.floor(remaining / 1e3))}s.`);
|
|
777
|
-
}
|
|
778
|
-
})().catch((err) => {
|
|
779
|
-
const runtimeModel = params.getRuntimeModel();
|
|
780
|
-
params.log.warn(`Runtime auth refresh failed for ${runtimeModel.provider}: ${formatErrorMessage(err)}`);
|
|
781
|
-
throw err;
|
|
782
|
-
}).finally(() => {
|
|
783
|
-
const activeState = params.getRuntimeAuthState();
|
|
784
|
-
if (activeState && activeState.generation === refreshGeneration && activeState.refreshInFlight === refreshPromise) activeState.refreshInFlight = void 0;
|
|
785
|
-
});
|
|
786
|
-
runtimeAuthState.refreshInFlight = refreshPromise;
|
|
787
|
-
await refreshPromise;
|
|
788
|
-
};
|
|
789
|
-
const scheduleRuntimeAuthRefresh = () => {
|
|
790
|
-
const runtimeAuthState = params.getRuntimeAuthState();
|
|
791
|
-
if (!runtimeAuthState || params.getRuntimeAuthRefreshCancelled()) return;
|
|
792
|
-
const runtimeModel = params.getRuntimeModel();
|
|
793
|
-
if (!hasRefreshableRuntimeAuth()) {
|
|
794
|
-
params.log.warn(`Skipping runtime auth refresh scheduling for ${runtimeModel.provider}; source credential missing.`);
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
797
|
-
if (!runtimeAuthState.expiresAt) return;
|
|
798
|
-
clearRuntimeAuthRefreshTimer();
|
|
799
|
-
const now = Date.now();
|
|
800
|
-
const delayMs = clampRuntimeAuthRefreshDelayMs({
|
|
801
|
-
refreshAt: runtimeAuthState.expiresAt - RUNTIME_AUTH_REFRESH_MARGIN_MS,
|
|
802
|
-
now,
|
|
803
|
-
minDelayMs: RUNTIME_AUTH_REFRESH_MIN_DELAY_MS
|
|
804
|
-
});
|
|
805
|
-
const timer = setTimeout(() => {
|
|
806
|
-
if (params.getRuntimeAuthRefreshCancelled()) return;
|
|
807
|
-
refreshRuntimeAuth("scheduled").then(() => scheduleRuntimeAuthRefresh()).catch(() => {
|
|
808
|
-
if (params.getRuntimeAuthRefreshCancelled()) return;
|
|
809
|
-
const retryTimer = setTimeout(() => {
|
|
810
|
-
if (params.getRuntimeAuthRefreshCancelled()) return;
|
|
811
|
-
refreshRuntimeAuth("scheduled-retry").then(() => scheduleRuntimeAuthRefresh()).catch(() => void 0);
|
|
812
|
-
}, RUNTIME_AUTH_REFRESH_RETRY_MS);
|
|
813
|
-
const activeRuntimeAuthState = params.getRuntimeAuthState();
|
|
814
|
-
if (activeRuntimeAuthState) activeRuntimeAuthState.refreshTimer = retryTimer;
|
|
815
|
-
if (params.getRuntimeAuthRefreshCancelled() && activeRuntimeAuthState) {
|
|
816
|
-
clearTimeout(retryTimer);
|
|
817
|
-
activeRuntimeAuthState.refreshTimer = void 0;
|
|
818
|
-
}
|
|
819
|
-
});
|
|
820
|
-
}, delayMs);
|
|
821
|
-
runtimeAuthState.refreshTimer = timer;
|
|
822
|
-
if (params.getRuntimeAuthRefreshCancelled()) {
|
|
823
|
-
clearTimeout(timer);
|
|
824
|
-
runtimeAuthState.refreshTimer = void 0;
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
const resolveAuthProfileFailoverReason = (failoverParams) => {
|
|
828
|
-
if (failoverParams.allInCooldown) {
|
|
829
|
-
const profileIds = (failoverParams.profileIds ?? params.profileCandidates).filter((id) => typeof id === "string" && id.length > 0);
|
|
830
|
-
return resolveProfilesUnavailableReason({
|
|
831
|
-
store: params.authStore,
|
|
832
|
-
profileIds
|
|
833
|
-
}) ?? "unknown";
|
|
834
|
-
}
|
|
835
|
-
return classifyFailoverReason(failoverParams.message, { provider: params.getProvider() }) ?? "auth";
|
|
836
|
-
};
|
|
837
|
-
const throwAuthProfileFailover = (failoverParams) => {
|
|
838
|
-
const provider = params.getProvider();
|
|
839
|
-
const modelId = params.getModelId();
|
|
840
|
-
const fallbackMessage = `No available auth profile for ${provider} (all in cooldown or unavailable).`;
|
|
841
|
-
const message = failoverParams.message?.trim() || (failoverParams.error ? formatErrorMessage(failoverParams.error).trim() : "") || fallbackMessage;
|
|
842
|
-
const reason = resolveAuthProfileFailoverReason({
|
|
843
|
-
allInCooldown: failoverParams.allInCooldown,
|
|
844
|
-
message,
|
|
845
|
-
profileIds: params.profileCandidates
|
|
846
|
-
});
|
|
847
|
-
if (params.fallbackConfigured) throw new FailoverError(message, {
|
|
848
|
-
reason,
|
|
849
|
-
provider,
|
|
850
|
-
model: modelId,
|
|
851
|
-
status: resolveFailoverStatus(reason),
|
|
852
|
-
cause: failoverParams.error
|
|
853
|
-
});
|
|
854
|
-
if (failoverParams.error instanceof Error) throw failoverParams.error;
|
|
855
|
-
throw new Error(message);
|
|
856
|
-
};
|
|
857
|
-
const resolveApiKeyForCandidate = async (candidate) => {
|
|
858
|
-
return getApiKeyForModel({
|
|
859
|
-
model: params.getRuntimeModel(),
|
|
860
|
-
cfg: params.config,
|
|
861
|
-
profileId: candidate,
|
|
862
|
-
store: params.authStore,
|
|
863
|
-
agentDir: params.agentDir,
|
|
864
|
-
workspaceDir: params.workspaceDir,
|
|
865
|
-
lockedProfile: candidate != null && candidate === params.lockedProfileId
|
|
866
|
-
});
|
|
867
|
-
};
|
|
868
|
-
const applyApiKeyInfo = async (candidate) => {
|
|
869
|
-
const apiKeyInfo = await resolveApiKeyForCandidate(candidate);
|
|
870
|
-
params.setApiKeyInfo(apiKeyInfo);
|
|
871
|
-
const resolvedProfileId = apiKeyInfo.profileId ?? candidate;
|
|
872
|
-
if (!apiKeyInfo.apiKey) {
|
|
873
|
-
if (apiKeyInfo.mode !== "aws-sdk") {
|
|
874
|
-
const runtimeModel = params.getRuntimeModel();
|
|
875
|
-
throw new Error(formatMissingAuthError(apiKeyInfo, runtimeModel.provider));
|
|
876
|
-
}
|
|
877
|
-
const runtimeModel = params.getRuntimeModel();
|
|
878
|
-
const AWS_SDK_AUTH_SENTINEL = "__aws_sdk_auth__";
|
|
879
|
-
try {
|
|
880
|
-
const preparedAuth = await prepareRuntimeAuthForModel({
|
|
881
|
-
runtimeModel,
|
|
882
|
-
apiKey: AWS_SDK_AUTH_SENTINEL,
|
|
883
|
-
authMode: apiKeyInfo.mode,
|
|
884
|
-
profileId: apiKeyInfo.profileId
|
|
885
|
-
});
|
|
886
|
-
applyPreparedRuntimeRequestOverrides({
|
|
887
|
-
runtimeModel,
|
|
888
|
-
preparedAuth: preparedAuth ?? {}
|
|
889
|
-
});
|
|
890
|
-
if (preparedAuth?.apiKey) {
|
|
891
|
-
clearRuntimeAuthRefreshTimer();
|
|
892
|
-
params.authStorage.setRuntimeApiKey(runtimeModel.provider, preparedAuth.apiKey);
|
|
893
|
-
params.setRuntimeAuthState({
|
|
894
|
-
generation: nextRuntimeAuthGeneration(),
|
|
895
|
-
sourceApiKey: AWS_SDK_AUTH_SENTINEL,
|
|
896
|
-
authMode: apiKeyInfo.mode,
|
|
897
|
-
profileId: resolvedProfileId,
|
|
898
|
-
expiresAt: preparedAuth.expiresAt
|
|
899
|
-
});
|
|
900
|
-
if (preparedAuth.expiresAt) scheduleRuntimeAuthRefresh();
|
|
901
|
-
params.setLastProfileId(resolvedProfileId);
|
|
902
|
-
return;
|
|
903
|
-
}
|
|
904
|
-
} catch (error) {
|
|
905
|
-
params.log.warn(`prepareProviderRuntimeAuth failed for ${runtimeModel.provider}, falling back to sentinel: ${formatErrorMessage(error)}`);
|
|
906
|
-
}
|
|
907
|
-
clearRuntimeAuthRefreshTimer();
|
|
908
|
-
params.authStorage.setRuntimeApiKey(runtimeModel.provider, AWS_SDK_AUTH_SENTINEL);
|
|
909
|
-
params.setRuntimeAuthState(null);
|
|
910
|
-
params.setLastProfileId(resolvedProfileId);
|
|
911
|
-
return;
|
|
912
|
-
}
|
|
913
|
-
let runtimeAuthHandled = false;
|
|
914
|
-
const runtimeModel = params.getRuntimeModel();
|
|
915
|
-
const preparedAuth = await prepareRuntimeAuthForModel({
|
|
916
|
-
runtimeModel,
|
|
917
|
-
apiKey: apiKeyInfo.apiKey,
|
|
918
|
-
authMode: apiKeyInfo.mode,
|
|
919
|
-
profileId: apiKeyInfo.profileId
|
|
920
|
-
});
|
|
921
|
-
applyPreparedRuntimeRequestOverrides({
|
|
922
|
-
runtimeModel,
|
|
923
|
-
preparedAuth: preparedAuth ?? {}
|
|
924
|
-
});
|
|
925
|
-
if (preparedAuth?.apiKey) {
|
|
926
|
-
clearRuntimeAuthRefreshTimer();
|
|
927
|
-
params.authStorage.setRuntimeApiKey(runtimeModel.provider, preparedAuth.apiKey);
|
|
928
|
-
params.setRuntimeAuthState({
|
|
929
|
-
generation: nextRuntimeAuthGeneration(),
|
|
930
|
-
sourceApiKey: apiKeyInfo.apiKey,
|
|
931
|
-
authMode: apiKeyInfo.mode,
|
|
932
|
-
profileId: apiKeyInfo.profileId,
|
|
933
|
-
expiresAt: preparedAuth.expiresAt
|
|
934
|
-
});
|
|
935
|
-
if (preparedAuth.expiresAt) scheduleRuntimeAuthRefresh();
|
|
936
|
-
runtimeAuthHandled = true;
|
|
937
|
-
}
|
|
938
|
-
if (!runtimeAuthHandled) {
|
|
939
|
-
clearRuntimeAuthRefreshTimer();
|
|
940
|
-
params.authStorage.setRuntimeApiKey(runtimeModel.provider, apiKeyInfo.apiKey);
|
|
941
|
-
params.setRuntimeAuthState(null);
|
|
942
|
-
}
|
|
943
|
-
params.setLastProfileId(apiKeyInfo.profileId);
|
|
944
|
-
};
|
|
945
|
-
const advanceAuthProfile = async () => {
|
|
946
|
-
if (params.lockedProfileId) return false;
|
|
947
|
-
let nextIndex = params.getProfileIndex() + 1;
|
|
948
|
-
while (nextIndex < params.profileCandidates.length) {
|
|
949
|
-
const candidate = params.profileCandidates[nextIndex];
|
|
950
|
-
if (candidate && isProfileInCooldown(params.authStore, candidate, void 0, params.getModelId())) {
|
|
951
|
-
nextIndex += 1;
|
|
952
|
-
continue;
|
|
953
|
-
}
|
|
954
|
-
try {
|
|
955
|
-
await applyApiKeyInfo(candidate);
|
|
956
|
-
params.setProfileIndex(nextIndex);
|
|
957
|
-
params.setThinkLevel(params.initialThinkLevel);
|
|
958
|
-
params.attemptedThinking.clear();
|
|
959
|
-
return true;
|
|
960
|
-
} catch (err) {
|
|
961
|
-
if (candidate && candidate === params.lockedProfileId) throw err;
|
|
962
|
-
nextIndex += 1;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
return false;
|
|
966
|
-
};
|
|
967
|
-
const initializeAuthProfile = async () => {
|
|
968
|
-
try {
|
|
969
|
-
const autoProfileCandidates = params.profileCandidates.filter((candidate) => typeof candidate === "string" && candidate.length > 0 && candidate !== params.lockedProfileId);
|
|
970
|
-
const modelId = params.getModelId();
|
|
971
|
-
const allAutoProfilesInCooldown = autoProfileCandidates.length > 0 && autoProfileCandidates.every((candidate) => isProfileInCooldown(params.authStore, candidate, void 0, modelId));
|
|
972
|
-
const unavailableReason = allAutoProfilesInCooldown ? resolveProfilesUnavailableReason({
|
|
973
|
-
store: params.authStore,
|
|
974
|
-
profileIds: autoProfileCandidates
|
|
975
|
-
}) ?? "unknown" : null;
|
|
976
|
-
const allowTransientCooldownProbe = params.allowTransientCooldownProbe && allAutoProfilesInCooldown && shouldAllowCooldownProbeForReason(unavailableReason);
|
|
977
|
-
let didTransientCooldownProbe = false;
|
|
978
|
-
while (params.getProfileIndex() < params.profileCandidates.length) {
|
|
979
|
-
const candidate = params.profileCandidates[params.getProfileIndex()];
|
|
980
|
-
if (candidate && candidate !== params.lockedProfileId && isProfileInCooldown(params.authStore, candidate, void 0, modelId)) if (allowTransientCooldownProbe && !didTransientCooldownProbe) {
|
|
981
|
-
didTransientCooldownProbe = true;
|
|
982
|
-
params.log.warn(`probing cooldowned auth profile for ${params.getProvider()}/${modelId} due to ${unavailableReason ?? "transient"} unavailability`);
|
|
983
|
-
} else {
|
|
984
|
-
params.setProfileIndex(params.getProfileIndex() + 1);
|
|
985
|
-
continue;
|
|
986
|
-
}
|
|
987
|
-
await applyApiKeyInfo(params.profileCandidates[params.getProfileIndex()]);
|
|
988
|
-
break;
|
|
989
|
-
}
|
|
990
|
-
if (params.getProfileIndex() >= params.profileCandidates.length) throwAuthProfileFailover({ allInCooldown: true });
|
|
991
|
-
} catch (err) {
|
|
992
|
-
if (err instanceof FailoverError) throw err;
|
|
993
|
-
if (params.profileCandidates[params.getProfileIndex()] === params.lockedProfileId) throwAuthProfileFailover({
|
|
994
|
-
allInCooldown: false,
|
|
995
|
-
error: err
|
|
996
|
-
});
|
|
997
|
-
if (!await advanceAuthProfile()) throwAuthProfileFailover({
|
|
998
|
-
allInCooldown: false,
|
|
999
|
-
error: err
|
|
1000
|
-
});
|
|
1001
|
-
}
|
|
1002
|
-
};
|
|
1003
|
-
const maybeRefreshRuntimeAuthForAuthError = async (errorText, retried) => {
|
|
1004
|
-
if (!params.getRuntimeAuthState() || retried) return false;
|
|
1005
|
-
if (!isFailoverErrorMessage(errorText, { provider: params.getProvider() })) return false;
|
|
1006
|
-
if (classifyFailoverReason(errorText, { provider: params.getProvider() }) !== "auth") return false;
|
|
1007
|
-
try {
|
|
1008
|
-
await refreshRuntimeAuth("auth-error");
|
|
1009
|
-
scheduleRuntimeAuthRefresh();
|
|
1010
|
-
return true;
|
|
1011
|
-
} catch {
|
|
1012
|
-
return false;
|
|
1013
|
-
}
|
|
1014
|
-
};
|
|
1015
|
-
return {
|
|
1016
|
-
advanceAuthProfile,
|
|
1017
|
-
initializeAuthProfile,
|
|
1018
|
-
maybeRefreshRuntimeAuthForAuthError,
|
|
1019
|
-
stopRuntimeAuthRefreshTimer
|
|
1020
|
-
};
|
|
1021
|
-
}
|
|
1022
|
-
//#endregion
|
|
1023
|
-
//#region src/agents/pi-embedded-runner/run/auth-profile-failure-policy.ts
|
|
1024
|
-
function resolveAuthProfileFailureReason(params) {
|
|
1025
|
-
if (params.policy === "local" || !params.failoverReason || params.failoverReason === "server_error" || params.failoverReason === "empty_response" || params.failoverReason === "format") return null;
|
|
1026
|
-
if (params.failoverReason === "timeout" && params.providerStarted !== true) return null;
|
|
1027
|
-
return params.failoverReason;
|
|
1028
|
-
}
|
|
1029
|
-
//#endregion
|
|
1030
|
-
//#region src/agents/pi-embedded-runner/run/backend.ts
|
|
1031
|
-
async function runEmbeddedAttemptWithBackend(params) {
|
|
1032
|
-
return runAgentHarnessAttempt(params);
|
|
1033
|
-
}
|
|
1034
|
-
//#endregion
|
|
1035
|
-
//#region src/agents/pi-embedded-runner/run/codex-app-server-recovery.ts
|
|
1036
|
-
function resolveCodexAppServerClientCloseRetry(params) {
|
|
1037
|
-
const failure = params.attempt.codexAppServerFailure;
|
|
1038
|
-
if (!failure) return {
|
|
1039
|
-
retry: false,
|
|
1040
|
-
reason: "not_codex_app_server_failure"
|
|
1041
|
-
};
|
|
1042
|
-
if (failure.kind !== "client_closed_before_turn_completed") return {
|
|
1043
|
-
retry: false,
|
|
1044
|
-
reason: failure.kind
|
|
1045
|
-
};
|
|
1046
|
-
if (failure.transport !== "stdio") return {
|
|
1047
|
-
retry: false,
|
|
1048
|
-
reason: "non_stdio_transport"
|
|
1049
|
-
};
|
|
1050
|
-
if (params.alreadyRetried) return {
|
|
1051
|
-
retry: false,
|
|
1052
|
-
reason: "retry_exhausted"
|
|
1053
|
-
};
|
|
1054
|
-
if (!failure.replaySafe || !params.attempt.replayMetadata.replaySafe) return {
|
|
1055
|
-
retry: false,
|
|
1056
|
-
reason: failure.replayBlockedReason ?? "replay_unsafe"
|
|
1057
|
-
};
|
|
1058
|
-
if (params.attempt.assistantTexts.some((text) => text.trim().length > 0)) return {
|
|
1059
|
-
retry: false,
|
|
1060
|
-
reason: "assistant_output"
|
|
1061
|
-
};
|
|
1062
|
-
if (params.attempt.toolMetas.length > 0 || params.attempt.clientToolCalls || params.attempt.lastToolError || params.attempt.didSendDeterministicApprovalPrompt) return {
|
|
1063
|
-
retry: false,
|
|
1064
|
-
reason: "tool_activity"
|
|
1065
|
-
};
|
|
1066
|
-
if (params.attempt.itemLifecycle.startedCount > 0 || params.attempt.itemLifecycle.activeCount > 0) return {
|
|
1067
|
-
retry: false,
|
|
1068
|
-
reason: "active_item"
|
|
1069
|
-
};
|
|
1070
|
-
return { retry: true };
|
|
1071
|
-
}
|
|
1072
|
-
//#endregion
|
|
1073
|
-
//#region src/agents/pi-embedded-runner/run/failover-observation.ts
|
|
1074
|
-
function normalizeFailoverDecisionObservationBase(base) {
|
|
1075
|
-
return {
|
|
1076
|
-
...base,
|
|
1077
|
-
failoverReason: base.failoverReason ?? (base.timedOut ? "timeout" : null),
|
|
1078
|
-
profileFailureReason: base.profileFailureReason ?? (base.timedOut ? "timeout" : null)
|
|
1079
|
-
};
|
|
1080
|
-
}
|
|
1081
|
-
function createFailoverDecisionLogger(base) {
|
|
1082
|
-
const normalizedBase = normalizeFailoverDecisionObservationBase(base);
|
|
1083
|
-
const safeProfileId = normalizedBase.profileId ? redactIdentifier(normalizedBase.profileId, { len: 12 }) : void 0;
|
|
1084
|
-
const safeRunId = sanitizeForConsole(normalizedBase.runId) ?? "-";
|
|
1085
|
-
const safeProvider = sanitizeForConsole(normalizedBase.provider) ?? "-";
|
|
1086
|
-
const safeModel = sanitizeForConsole(normalizedBase.model) ?? "-";
|
|
1087
|
-
const safeSourceProvider = sanitizeForConsole(normalizedBase.sourceProvider) ?? safeProvider;
|
|
1088
|
-
const safeSourceModel = sanitizeForConsole(normalizedBase.sourceModel) ?? safeModel;
|
|
1089
|
-
const profileText = safeProfileId ?? "-";
|
|
1090
|
-
const reasonText = normalizedBase.failoverReason ?? "none";
|
|
1091
|
-
const sourceChanged = safeSourceProvider !== safeProvider || safeSourceModel !== safeModel;
|
|
1092
|
-
return (decision, extra) => {
|
|
1093
|
-
const observedError = buildApiErrorObservationFields(normalizedBase.rawError);
|
|
1094
|
-
const safeRawErrorPreview = sanitizeForConsole(observedError.rawErrorPreview);
|
|
1095
|
-
const rawErrorConsoleSuffix = safeRawErrorPreview && !shouldSuppressRawErrorConsoleSuffix(observedError.providerRuntimeFailureKind) ? ` rawError=${safeRawErrorPreview}` : "";
|
|
1096
|
-
log$1.warn("embedded run failover decision", {
|
|
1097
|
-
event: "embedded_run_failover_decision",
|
|
1098
|
-
tags: [
|
|
1099
|
-
"error_handling",
|
|
1100
|
-
"failover",
|
|
1101
|
-
normalizedBase.stage,
|
|
1102
|
-
decision
|
|
1103
|
-
],
|
|
1104
|
-
runId: normalizedBase.runId,
|
|
1105
|
-
stage: normalizedBase.stage,
|
|
1106
|
-
decision,
|
|
1107
|
-
failoverReason: normalizedBase.failoverReason,
|
|
1108
|
-
profileFailureReason: normalizedBase.profileFailureReason,
|
|
1109
|
-
provider: normalizedBase.provider,
|
|
1110
|
-
model: normalizedBase.model,
|
|
1111
|
-
sourceProvider: normalizedBase.sourceProvider ?? normalizedBase.provider,
|
|
1112
|
-
sourceModel: normalizedBase.sourceModel ?? normalizedBase.model,
|
|
1113
|
-
profileId: safeProfileId,
|
|
1114
|
-
fallbackConfigured: normalizedBase.fallbackConfigured,
|
|
1115
|
-
timedOut: normalizedBase.timedOut,
|
|
1116
|
-
aborted: normalizedBase.aborted,
|
|
1117
|
-
status: extra?.status,
|
|
1118
|
-
...observedError,
|
|
1119
|
-
consoleMessage: `embedded run failover decision: runId=${safeRunId} stage=${normalizedBase.stage} decision=${decision} reason=${reasonText} from=${safeSourceProvider}/${safeSourceModel}${sourceChanged ? ` to=${safeProvider}/${safeModel}` : ""} profile=${profileText}${rawErrorConsoleSuffix}`
|
|
1120
|
-
});
|
|
1121
|
-
};
|
|
1122
|
-
}
|
|
1123
|
-
//#endregion
|
|
1124
|
-
//#region src/agents/pi-embedded-runner/run/fallbacks.ts
|
|
1125
|
-
function hasEmbeddedRunConfiguredModelFallbacks(params) {
|
|
1126
|
-
if (params.modelFallbacksOverride !== void 0) return params.modelFallbacksOverride.length > 0;
|
|
1127
|
-
return hasConfiguredModelFallbacks({
|
|
1128
|
-
cfg: params.cfg,
|
|
1129
|
-
agentId: params.agentId,
|
|
1130
|
-
sessionKey: params.sessionKey
|
|
1131
|
-
});
|
|
1132
|
-
}
|
|
1133
|
-
function createIdleTimeoutBreakerState() {
|
|
1134
|
-
return { consecutiveIdleTimeoutsBeforeOutput: 0 };
|
|
1135
|
-
}
|
|
1136
|
-
/**
|
|
1137
|
-
* Update the breaker counter from the latest attempt's outcome and report
|
|
1138
|
-
* whether the cap is now tripped. Designed to be called from the outer run
|
|
1139
|
-
* loop right after an embedded attempt completes.
|
|
1140
|
-
*
|
|
1141
|
-
* Pure function modulo the mutable `state.consecutiveIdleTimeoutsBeforeOutput`
|
|
1142
|
-
* field, so the caller decides where the state lives (typically a `let` in
|
|
1143
|
-
* the outer loop).
|
|
1144
|
-
*
|
|
1145
|
-
* Decision table:
|
|
1146
|
-
* idleTimedOut completedModelProgress action
|
|
1147
|
-
* ------------ ---------------------- ------
|
|
1148
|
-
* true false count += 1 (wedged provider candidate)
|
|
1149
|
-
* true true count = 0 (model is alive but slow tail)
|
|
1150
|
-
* false true count = 0 (clean progress, all good)
|
|
1151
|
-
* false false count unchanged (e.g. non-timeout error;
|
|
1152
|
-
* don't poison or reset)
|
|
1153
|
-
*
|
|
1154
|
-
* The "false / false" branch matters: a non-timeout error attempt with no
|
|
1155
|
-
* completed progress should not reset the breaker (it isn't a sign the
|
|
1156
|
-
* provider is healthy), but it also shouldn't increment it (the issue at hand
|
|
1157
|
-
* is idle timeouts, not arbitrary errors).
|
|
1158
|
-
*
|
|
1159
|
-
* `outputTokens` is intentionally not part of the reset condition. Some
|
|
1160
|
-
* transports can accumulate billed output tokens from partial tool-call
|
|
1161
|
-
* argument deltas before the model stalls; those tokens are cost, not completed
|
|
1162
|
-
* progress, so they must not keep the breaker disarmed.
|
|
1163
|
-
*/
|
|
1164
|
-
function stepIdleTimeoutBreaker(state, input, options) {
|
|
1165
|
-
const cap = options?.cap ?? 5;
|
|
1166
|
-
if (input.idleTimedOut && !input.completedModelProgress) state.consecutiveIdleTimeoutsBeforeOutput += 1;
|
|
1167
|
-
else if (input.completedModelProgress) state.consecutiveIdleTimeoutsBeforeOutput = 0;
|
|
1168
|
-
return {
|
|
1169
|
-
consecutive: state.consecutiveIdleTimeoutsBeforeOutput,
|
|
1170
|
-
tripped: cap > 0 && state.consecutiveIdleTimeoutsBeforeOutput >= cap
|
|
1171
|
-
};
|
|
1172
|
-
}
|
|
1173
|
-
//#endregion
|
|
1174
|
-
//#region src/agents/pi-embedded-runner/run/payloads.ts
|
|
1175
|
-
const RECOVERABLE_TOOL_ERROR_KEYWORDS = [
|
|
1176
|
-
"required",
|
|
1177
|
-
"missing",
|
|
1178
|
-
"invalid",
|
|
1179
|
-
"must be",
|
|
1180
|
-
"must have",
|
|
1181
|
-
"needs",
|
|
1182
|
-
"requires"
|
|
1183
|
-
];
|
|
1184
|
-
const MUTATING_FAILURE_ACTION_PATTERN = "(?:write|edit|update|save|create|delete|remove|modify|change|apply|patch|move|rename|send|reply|message|run|execute|execution|command|script|shell|bash|exec|tool|action|operation)";
|
|
1185
|
-
const MUTATING_FAILURE_INABILITY_PATTERN = new RegExp(`\\b(?:couldn't|could not|can't|cannot|unable to|am unable to|wasn't able to|was not able to|were unable to)\\b.{0,100}\\b${MUTATING_FAILURE_ACTION_PATTERN}\\b`, "u");
|
|
1186
|
-
const MUTATING_FAILURE_ACTION_THEN_FAILURE_PATTERN = new RegExp(`\\b${MUTATING_FAILURE_ACTION_PATTERN}\\b.{0,100}\\b(?:failed|failure|errored)\\b`, "u");
|
|
1187
|
-
const MUTATING_FAILURE_FAILURE_THEN_ACTION_PATTERN = new RegExp(`\\b(?:failed|failure)\\b.{0,100}\\b${MUTATING_FAILURE_ACTION_PATTERN}\\b`, "u");
|
|
1188
|
-
const MUTATING_FAILURE_ERROR_WHILE_ACTION_PATTERN = new RegExp(`\\b(?:hit|encountered|ran into)\\b.{0,60}\\berror\\b.{0,100}\\b(?:while|trying to|when)\\b.{0,100}\\b${MUTATING_FAILURE_ACTION_PATTERN}\\b`, "u");
|
|
1189
|
-
const DID_NOT_FAIL_PATTERN = /\b(?:did not|didn't)\s+fail\b/u;
|
|
1190
|
-
const NEGATED_FAILURE_PATTERN = /\b(?:no|not|without)\s+(?:failures?|errors?)\b/u;
|
|
1191
|
-
function isRecoverableToolError(error) {
|
|
1192
|
-
const errorLower = normalizeOptionalLowercaseString(error) ?? "";
|
|
1193
|
-
return RECOVERABLE_TOOL_ERROR_KEYWORDS.some((keyword) => errorLower.includes(keyword));
|
|
1194
|
-
}
|
|
1195
|
-
function hasExplicitMutatingToolFailureAcknowledgement(text) {
|
|
1196
|
-
const normalizedText = normalizeTextForComparison(text);
|
|
1197
|
-
if (!normalizedText) return false;
|
|
1198
|
-
if (DID_NOT_FAIL_PATTERN.test(normalizedText)) return false;
|
|
1199
|
-
if (MUTATING_FAILURE_INABILITY_PATTERN.test(normalizedText)) return true;
|
|
1200
|
-
if (NEGATED_FAILURE_PATTERN.test(normalizedText)) return false;
|
|
1201
|
-
return MUTATING_FAILURE_ACTION_THEN_FAILURE_PATTERN.test(normalizedText) || MUTATING_FAILURE_FAILURE_THEN_ACTION_PATTERN.test(normalizedText) || MUTATING_FAILURE_ERROR_WHILE_ACTION_PATTERN.test(normalizedText);
|
|
1202
|
-
}
|
|
1203
|
-
function isVerboseToolDetailEnabled(level) {
|
|
1204
|
-
return level === "full";
|
|
1205
|
-
}
|
|
1206
|
-
function resolveRawAssistantAnswerText(lastAssistant) {
|
|
1207
|
-
if (!lastAssistant) return "";
|
|
1208
|
-
return normalizeOptionalString(extractAssistantTextForPhase(lastAssistant, { phase: "final_answer" }) ?? extractAssistantTextForPhase(lastAssistant)) ?? "";
|
|
1209
|
-
}
|
|
1210
|
-
function normalizeReplyTextForComparison(text) {
|
|
1211
|
-
return normalizeTextForComparison(parseReplyDirectives(text).text ?? "");
|
|
1212
|
-
}
|
|
1213
|
-
function shouldIncludeToolErrorDetails(params) {
|
|
1214
|
-
if (isVerboseToolDetailEnabled(params.verboseLevel)) return true;
|
|
1215
|
-
return isExecLikeToolName(params.lastToolError.toolName) && params.lastToolError.timedOut === true && (params.isCronTrigger === true || isCronSessionKey(params.sessionKey));
|
|
1216
|
-
}
|
|
1217
|
-
function shouldMarkNonTerminalToolErrorWarning(lastToolError) {
|
|
1218
|
-
return lastToolError.middlewareError === true;
|
|
1219
|
-
}
|
|
1220
|
-
function resolveToolErrorWarningPolicy(params) {
|
|
1221
|
-
const normalizedToolName = normalizeOptionalLowercaseString(params.lastToolError.toolName) ?? "";
|
|
1222
|
-
const includeDetails = shouldIncludeToolErrorDetails(params);
|
|
1223
|
-
if (params.suppressToolErrorWarnings) return {
|
|
1224
|
-
showWarning: false,
|
|
1225
|
-
includeDetails
|
|
1226
|
-
};
|
|
1227
|
-
if (normalizedToolName === "sessions_send") return {
|
|
1228
|
-
showWarning: false,
|
|
1229
|
-
includeDetails
|
|
1230
|
-
};
|
|
1231
|
-
if (params.suppressToolErrors) return {
|
|
1232
|
-
showWarning: false,
|
|
1233
|
-
includeDetails
|
|
1234
|
-
};
|
|
1235
|
-
if (params.lastToolError.mutatingAction ?? isLikelyMutatingToolName(params.lastToolError.toolName)) return {
|
|
1236
|
-
showWarning: !params.hasUserFacingErrorReply && !params.hasUserFacingFailureAcknowledgement,
|
|
1237
|
-
includeDetails
|
|
1238
|
-
};
|
|
1239
|
-
if (isExecLikeToolName(params.lastToolError.toolName) && !includeDetails) return {
|
|
1240
|
-
showWarning: false,
|
|
1241
|
-
includeDetails
|
|
1242
|
-
};
|
|
1243
|
-
return {
|
|
1244
|
-
showWarning: !params.hasUserFacingReply && !isRecoverableToolError(params.lastToolError.error),
|
|
1245
|
-
includeDetails
|
|
1246
|
-
};
|
|
1247
|
-
}
|
|
1248
|
-
function buildEmbeddedRunPayloads(params) {
|
|
1249
|
-
if (params.heartbeatToolResponse) return [createHeartbeatToolResponsePayload(params.heartbeatToolResponse)];
|
|
1250
|
-
const replyItems = [];
|
|
1251
|
-
const sourceReplyPayloads = params.sourceReplyDeliveryMode === "message_tool_only" ? params.messagingToolSourceReplyPayloads ?? [] : [];
|
|
1252
|
-
const sourceReplyStartIndex = replyItems.length;
|
|
1253
|
-
sourceReplyPayloads.forEach((payload, index) => {
|
|
1254
|
-
const text = normalizeOptionalString(payload.text) ?? "";
|
|
1255
|
-
const media = Array.from(new Set([...payload.mediaUrl ? [payload.mediaUrl] : [], ...payload.mediaUrls ?? []])).filter((value) => value.trim().length > 0);
|
|
1256
|
-
if (!text && media.length === 0 && !payload.presentation && !payload.interactive && !payload.channelData) return;
|
|
1257
|
-
replyItems.push({
|
|
1258
|
-
text,
|
|
1259
|
-
...payload.mediaUrl ? { mediaUrl: payload.mediaUrl } : {},
|
|
1260
|
-
...media.length ? { media } : {},
|
|
1261
|
-
...payload.audioAsVoice ? { audioAsVoice: true } : {},
|
|
1262
|
-
...payload.presentation ? { presentation: payload.presentation } : {},
|
|
1263
|
-
...payload.interactive ? { interactive: payload.interactive } : {},
|
|
1264
|
-
...payload.channelData ? { channelData: payload.channelData } : {},
|
|
1265
|
-
sourceReplyMirror: { idempotencyKey: payload.idempotencyKey ?? (params.runId ? `${params.runId}:internal-source-reply:${index}` : void 0) }
|
|
1266
|
-
});
|
|
1267
|
-
});
|
|
1268
|
-
const hasSourceReplyPayload = replyItems.length > sourceReplyStartIndex;
|
|
1269
|
-
const useMarkdown = params.toolResultFormat === "markdown";
|
|
1270
|
-
const suppressAssistantArtifacts = params.didSendDeterministicApprovalPrompt === true || hasSourceReplyPayload;
|
|
1271
|
-
const nonEmptyAssistantTexts = params.assistantTexts.filter((text) => text.trim().length > 0);
|
|
1272
|
-
const assistantForPayload = params.currentAssistant ?? void 0 ?? (nonEmptyAssistantTexts.length === 1 ? void 0 : params.lastAssistant);
|
|
1273
|
-
const lastAssistantStopReason = assistantForPayload?.stopReason;
|
|
1274
|
-
const lastAssistantErrored = lastAssistantStopReason === "error";
|
|
1275
|
-
const lastAssistantAborted = lastAssistantStopReason === "aborted";
|
|
1276
|
-
const runAborted = params.runAborted === true || lastAssistantAborted;
|
|
1277
|
-
const lastAssistantNeedsErrorSurface = lastAssistantErrored || lastAssistantAborted;
|
|
1278
|
-
const errorText = assistantForPayload && lastAssistantNeedsErrorSurface ? suppressAssistantArtifacts ? void 0 : formatAssistantErrorText(assistantForPayload, {
|
|
1279
|
-
cfg: params.config,
|
|
1280
|
-
sessionKey: params.sessionKey,
|
|
1281
|
-
provider: params.provider,
|
|
1282
|
-
model: params.model
|
|
1283
|
-
}) : void 0;
|
|
1284
|
-
const rawErrorMessage = lastAssistantNeedsErrorSurface ? normalizeOptionalString(assistantForPayload?.errorMessage) : void 0;
|
|
1285
|
-
const rawErrorFingerprint = rawErrorMessage ? getApiErrorPayloadFingerprint(rawErrorMessage) : null;
|
|
1286
|
-
const formattedRawErrorMessage = rawErrorMessage ? formatRawAssistantErrorForUi(rawErrorMessage) : null;
|
|
1287
|
-
const normalizedFormattedRawErrorMessage = formattedRawErrorMessage ? normalizeTextForComparison(formattedRawErrorMessage) : null;
|
|
1288
|
-
const normalizedRawErrorText = rawErrorMessage ? normalizeTextForComparison(rawErrorMessage) : null;
|
|
1289
|
-
const normalizedErrorText = errorText ? normalizeTextForComparison(errorText) : null;
|
|
1290
|
-
const normalizedGenericBillingErrorText = normalizeTextForComparison(BILLING_ERROR_USER_MESSAGE);
|
|
1291
|
-
const genericErrorText = "The AI service returned an error. Please try again.";
|
|
1292
|
-
if (errorText) replyItems.push({
|
|
1293
|
-
text: errorText,
|
|
1294
|
-
isError: true
|
|
1295
|
-
});
|
|
1296
|
-
if (params.inlineToolResultsAllowed && params.verboseLevel !== "off" && params.toolMetas.length > 0) for (const { toolName, meta } of params.toolMetas) {
|
|
1297
|
-
const { text: cleanedText, mediaUrls, audioAsVoice, replyToId, replyToTag, replyToCurrent } = parseReplyDirectives(formatToolAggregate(toolName, meta ? [meta] : [], { markdown: useMarkdown }));
|
|
1298
|
-
if (cleanedText) replyItems.push({
|
|
1299
|
-
text: cleanedText,
|
|
1300
|
-
media: mediaUrls,
|
|
1301
|
-
audioAsVoice,
|
|
1302
|
-
replyToId,
|
|
1303
|
-
replyToTag,
|
|
1304
|
-
replyToCurrent
|
|
1305
|
-
});
|
|
1306
|
-
}
|
|
1307
|
-
const reasoningText = suppressAssistantArtifacts || runAborted ? "" : assistantForPayload && params.reasoningLevel === "on" && params.thinkingLevel !== "off" ? extractAssistantThinking(assistantForPayload) : "";
|
|
1308
|
-
if (reasoningText) replyItems.push({
|
|
1309
|
-
text: reasoningText,
|
|
1310
|
-
isReasoning: true
|
|
1311
|
-
});
|
|
1312
|
-
const fallbackAnswerText = assistantForPayload ? extractAssistantVisibleText(assistantForPayload) : "";
|
|
1313
|
-
const fallbackRawAnswerText = resolveRawAssistantAnswerText(assistantForPayload);
|
|
1314
|
-
const shouldSuppressRawErrorText = (text) => {
|
|
1315
|
-
if (!lastAssistantNeedsErrorSurface) return false;
|
|
1316
|
-
const trimmed = text.trim();
|
|
1317
|
-
if (!trimmed) return false;
|
|
1318
|
-
if (errorText) {
|
|
1319
|
-
const normalized = normalizeTextForComparison(trimmed);
|
|
1320
|
-
if (normalized && normalizedErrorText && normalized === normalizedErrorText) return true;
|
|
1321
|
-
if (trimmed === genericErrorText) return true;
|
|
1322
|
-
if (normalized && normalizedGenericBillingErrorText && normalized === normalizedGenericBillingErrorText) return true;
|
|
1323
|
-
}
|
|
1324
|
-
if (rawErrorMessage && trimmed === rawErrorMessage) return true;
|
|
1325
|
-
if (formattedRawErrorMessage && trimmed === formattedRawErrorMessage) return true;
|
|
1326
|
-
if (normalizedRawErrorText) {
|
|
1327
|
-
const normalized = normalizeTextForComparison(trimmed);
|
|
1328
|
-
if (normalized && normalized === normalizedRawErrorText) return true;
|
|
1329
|
-
}
|
|
1330
|
-
if (normalizedFormattedRawErrorMessage) {
|
|
1331
|
-
const normalized = normalizeTextForComparison(trimmed);
|
|
1332
|
-
if (normalized && normalized === normalizedFormattedRawErrorMessage) return true;
|
|
1333
|
-
}
|
|
1334
|
-
if (rawErrorFingerprint) {
|
|
1335
|
-
const fingerprint = getApiErrorPayloadFingerprint(trimmed);
|
|
1336
|
-
if (fingerprint && fingerprint === rawErrorFingerprint) return true;
|
|
1337
|
-
}
|
|
1338
|
-
return isRawApiErrorPayload(trimmed);
|
|
1339
|
-
};
|
|
1340
|
-
const rawAnswerDirectiveState = fallbackRawAnswerText ? parseReplyDirectives(fallbackRawAnswerText) : null;
|
|
1341
|
-
const rawAnswerHasMedia = (rawAnswerDirectiveState?.mediaUrls?.length ?? 0) > 0 || rawAnswerDirectiveState?.audioAsVoice;
|
|
1342
|
-
const assistantTextsHaveMedia = params.assistantTexts.some((text) => {
|
|
1343
|
-
const parsed = parseReplyDirectives(text);
|
|
1344
|
-
return (parsed.mediaUrls?.length ?? 0) > 0 || parsed.audioAsVoice;
|
|
1345
|
-
});
|
|
1346
|
-
const normalizedAssistantTexts = normalizeTextForComparison(nonEmptyAssistantTexts.join("\n\n"));
|
|
1347
|
-
const normalizedRawAnswerText = normalizeTextForComparison(rawAnswerDirectiveState?.text ?? "");
|
|
1348
|
-
const shouldPreferRawAnswerText = rawAnswerHasMedia && (!nonEmptyAssistantTexts.length || !assistantTextsHaveMedia && normalizedAssistantTexts.length > 0 && normalizedAssistantTexts === normalizedRawAnswerText);
|
|
1349
|
-
const fallbackAnswerSourceText = shouldPreferRawAnswerText && fallbackRawAnswerText ? fallbackRawAnswerText : fallbackAnswerText;
|
|
1350
|
-
const normalizedFallbackAnswerSourceText = fallbackAnswerSourceText ? normalizeReplyTextForComparison(fallbackAnswerSourceText) : "";
|
|
1351
|
-
const shouldUseCanonicalFinalAnswer = !lastAssistantNeedsErrorSurface && fallbackAnswerSourceText.length > 0 && normalizedFallbackAnswerSourceText.length > 0;
|
|
1352
|
-
const hasAssistantTextPayload = nonEmptyAssistantTexts.length > 0;
|
|
1353
|
-
const answerTexts = suppressAssistantArtifacts || runAborted ? [] : (shouldUseCanonicalFinalAnswer ? [fallbackAnswerSourceText] : shouldPreferRawAnswerText && fallbackRawAnswerText ? [fallbackRawAnswerText] : hasAssistantTextPayload ? nonEmptyAssistantTexts : fallbackAnswerText ? [fallbackAnswerText] : []).filter((text) => !shouldSuppressRawErrorText(text));
|
|
1354
|
-
let hasUserFacingAssistantReply = hasSourceReplyPayload;
|
|
1355
|
-
const hasUserFacingErrorReply = replyItems.some((item) => item.isError === true);
|
|
1356
|
-
let hasUserFacingFailureAcknowledgement = false;
|
|
1357
|
-
for (const text of answerTexts) {
|
|
1358
|
-
const { text: cleanedText, mediaUrls, audioAsVoice, replyToId, replyToTag, replyToCurrent } = parseReplyDirectives(text);
|
|
1359
|
-
if (!cleanedText && (!mediaUrls || mediaUrls.length === 0) && !audioAsVoice) continue;
|
|
1360
|
-
replyItems.push({
|
|
1361
|
-
text: cleanedText,
|
|
1362
|
-
media: mediaUrls,
|
|
1363
|
-
audioAsVoice,
|
|
1364
|
-
replyToId,
|
|
1365
|
-
replyToTag,
|
|
1366
|
-
replyToCurrent
|
|
1367
|
-
});
|
|
1368
|
-
hasUserFacingAssistantReply = true;
|
|
1369
|
-
if (cleanedText && hasExplicitMutatingToolFailureAcknowledgement(cleanedText)) hasUserFacingFailureAcknowledgement = true;
|
|
1370
|
-
}
|
|
1371
|
-
if (params.lastToolError) {
|
|
1372
|
-
const warningPolicy = resolveToolErrorWarningPolicy({
|
|
1373
|
-
lastToolError: params.lastToolError,
|
|
1374
|
-
hasUserFacingReply: hasUserFacingAssistantReply,
|
|
1375
|
-
hasUserFacingErrorReply,
|
|
1376
|
-
hasUserFacingFailureAcknowledgement,
|
|
1377
|
-
suppressToolErrors: Boolean(params.config?.messages?.suppressToolErrors),
|
|
1378
|
-
suppressToolErrorWarnings: params.suppressToolErrorWarnings,
|
|
1379
|
-
isCronTrigger: params.isCronTrigger,
|
|
1380
|
-
sessionKey: params.sessionKey,
|
|
1381
|
-
verboseLevel: params.verboseLevel
|
|
1382
|
-
});
|
|
1383
|
-
if (warningPolicy.showWarning) {
|
|
1384
|
-
const warningText = `⚠️ ${formatToolAggregate(params.lastToolError.toolName, params.lastToolError.meta ? [params.lastToolError.meta] : void 0, { markdown: useMarkdown })} failed${warningPolicy.includeDetails && params.lastToolError.error ? `: ${params.lastToolError.error}` : ""}`;
|
|
1385
|
-
const normalizedWarning = normalizeTextForComparison(warningText);
|
|
1386
|
-
if (!(normalizedWarning ? replyItems.some((item) => {
|
|
1387
|
-
if (!item.text) return false;
|
|
1388
|
-
const normalizedExisting = normalizeTextForComparison(item.text);
|
|
1389
|
-
return normalizedExisting.length > 0 && normalizedExisting === normalizedWarning;
|
|
1390
|
-
}) : false)) replyItems.push({
|
|
1391
|
-
text: warningText,
|
|
1392
|
-
isError: true,
|
|
1393
|
-
nonTerminalToolErrorWarning: hasUserFacingAssistantReply && shouldMarkNonTerminalToolErrorWarning(params.lastToolError)
|
|
1394
|
-
});
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
const hasAudioAsVoiceTag = replyItems.some((item) => item.audioAsVoice);
|
|
1398
|
-
return replyItems.map((item) => {
|
|
1399
|
-
const payload = { text: normalizeOptionalString(item.text) };
|
|
1400
|
-
const mediaUrl = item.mediaUrl ?? item.media?.[0];
|
|
1401
|
-
if (mediaUrl) payload.mediaUrl = mediaUrl;
|
|
1402
|
-
if (item.media?.length) payload.mediaUrls = item.media;
|
|
1403
|
-
if (item.isError !== void 0) payload.isError = item.isError;
|
|
1404
|
-
if (item.nonTerminalToolErrorWarning) setReplyPayloadMetadata(payload, { nonTerminalToolErrorWarning: true });
|
|
1405
|
-
if (item.replyToId) payload.replyToId = item.replyToId;
|
|
1406
|
-
if (item.replyToTag !== void 0) payload.replyToTag = item.replyToTag;
|
|
1407
|
-
if (item.replyToCurrent !== void 0) payload.replyToCurrent = item.replyToCurrent;
|
|
1408
|
-
if (item.audioAsVoice || Boolean(hasAudioAsVoiceTag && item.media?.length)) payload.audioAsVoice = true;
|
|
1409
|
-
if (item.presentation) payload.presentation = item.presentation;
|
|
1410
|
-
if (item.interactive) payload.interactive = item.interactive;
|
|
1411
|
-
if (item.channelData) payload.channelData = item.channelData;
|
|
1412
|
-
if (item.sourceReplyMirror) {
|
|
1413
|
-
markReplyPayloadForSourceSuppressionDelivery(payload);
|
|
1414
|
-
if (params.sessionKey) {
|
|
1415
|
-
const sourceReplyTranscriptMirror = { sessionKey: params.sessionKey };
|
|
1416
|
-
if (params.agentId) sourceReplyTranscriptMirror.agentId = params.agentId;
|
|
1417
|
-
if (payload.text) sourceReplyTranscriptMirror.text = payload.text;
|
|
1418
|
-
if (payload.mediaUrls?.length) sourceReplyTranscriptMirror.mediaUrls = payload.mediaUrls;
|
|
1419
|
-
if (item.sourceReplyMirror.idempotencyKey) sourceReplyTranscriptMirror.idempotencyKey = item.sourceReplyMirror.idempotencyKey;
|
|
1420
|
-
setReplyPayloadMetadata(payload, { sourceReplyTranscriptMirror });
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
if (payload.text && isSilentReplyPayloadText(payload.text, "NO_REPLY")) {
|
|
1424
|
-
const silentText = payload.text;
|
|
1425
|
-
payload.text = void 0;
|
|
1426
|
-
if (hasReplyPayloadContent(payload)) return payload;
|
|
1427
|
-
payload.text = silentText;
|
|
1428
|
-
}
|
|
1429
|
-
return payload;
|
|
1430
|
-
}).filter((p) => {
|
|
1431
|
-
if (!hasReplyPayloadContent(p)) return false;
|
|
1432
|
-
if (p.text && isSilentReplyPayloadText(p.text, "NO_REPLY")) return false;
|
|
1433
|
-
return true;
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
//#endregion
|
|
1437
|
-
//#region src/agents/pi-embedded-runner/run/retry-limit.ts
|
|
1438
|
-
function handleRetryLimitExhaustion(params) {
|
|
1439
|
-
if (params.decision.action === "fallback_model") throw new FailoverError(params.message, {
|
|
1440
|
-
reason: params.decision.reason,
|
|
1441
|
-
provider: params.provider,
|
|
1442
|
-
model: params.model,
|
|
1443
|
-
profileId: params.profileId,
|
|
1444
|
-
status: resolveFailoverStatus(params.decision.reason)
|
|
1445
|
-
});
|
|
1446
|
-
return {
|
|
1447
|
-
payloads: [{
|
|
1448
|
-
text: "Request failed after repeated internal retries. Please try again, or use /new to start a fresh session.",
|
|
1449
|
-
isError: true
|
|
1450
|
-
}],
|
|
1451
|
-
meta: {
|
|
1452
|
-
durationMs: params.durationMs,
|
|
1453
|
-
agentMeta: params.agentMeta,
|
|
1454
|
-
...params.replayInvalid ? { replayInvalid: true } : {},
|
|
1455
|
-
...params.livenessState ? { livenessState: params.livenessState } : {},
|
|
1456
|
-
error: {
|
|
1457
|
-
kind: "retry_limit",
|
|
1458
|
-
message: params.message
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
};
|
|
1462
|
-
}
|
|
1463
|
-
//#endregion
|
|
1464
|
-
//#region src/agents/pi-embedded-runner/run/setup.ts
|
|
1465
|
-
async function resolveHookModelSelection(params) {
|
|
1466
|
-
let provider = params.provider;
|
|
1467
|
-
let modelId = params.modelId;
|
|
1468
|
-
let modelResolveOverride;
|
|
1469
|
-
let legacyBeforeAgentStartResult;
|
|
1470
|
-
const hookRunner = params.hookRunner;
|
|
1471
|
-
if (hookRunner?.hasHooks("before_model_resolve")) try {
|
|
1472
|
-
const event = params.attachments ? {
|
|
1473
|
-
prompt: params.prompt,
|
|
1474
|
-
attachments: params.attachments
|
|
1475
|
-
} : { prompt: params.prompt };
|
|
1476
|
-
modelResolveOverride = await hookRunner.runBeforeModelResolve(event, params.hookContext);
|
|
1477
|
-
} catch (hookErr) {
|
|
1478
|
-
log$1.warn(`before_model_resolve hook failed: ${String(hookErr)}`);
|
|
1479
|
-
}
|
|
1480
|
-
if (hookRunner?.hasHooks("before_agent_start")) try {
|
|
1481
|
-
legacyBeforeAgentStartResult = await hookRunner.runBeforeAgentStart({ prompt: params.prompt }, params.hookContext);
|
|
1482
|
-
modelResolveOverride = {
|
|
1483
|
-
providerOverride: modelResolveOverride?.providerOverride ?? legacyBeforeAgentStartResult?.providerOverride,
|
|
1484
|
-
modelOverride: modelResolveOverride?.modelOverride ?? legacyBeforeAgentStartResult?.modelOverride
|
|
1485
|
-
};
|
|
1486
|
-
} catch (hookErr) {
|
|
1487
|
-
log$1.warn(`before_agent_start hook (legacy model resolve path) failed: ${String(hookErr)}`);
|
|
1488
|
-
}
|
|
1489
|
-
if (modelResolveOverride?.providerOverride) {
|
|
1490
|
-
provider = modelResolveOverride.providerOverride;
|
|
1491
|
-
log$1.info(`[hooks] provider overridden to ${provider}`);
|
|
1492
|
-
}
|
|
1493
|
-
if (modelResolveOverride?.modelOverride) {
|
|
1494
|
-
modelId = modelResolveOverride.modelOverride;
|
|
1495
|
-
log$1.info(`[hooks] model overridden to ${modelId}`);
|
|
1496
|
-
}
|
|
1497
|
-
return {
|
|
1498
|
-
provider,
|
|
1499
|
-
modelId,
|
|
1500
|
-
legacyBeforeAgentStartResult
|
|
1501
|
-
};
|
|
1502
|
-
}
|
|
1503
|
-
function buildBeforeModelResolveAttachments(images) {
|
|
1504
|
-
if (!images?.length) return;
|
|
1505
|
-
return images.map((img) => ({
|
|
1506
|
-
kind: "image",
|
|
1507
|
-
mimeType: img.mimeType
|
|
1508
|
-
}));
|
|
1509
|
-
}
|
|
1510
|
-
function resolveEffectiveRuntimeModel(params) {
|
|
1511
|
-
const ctxInfo = resolveContextWindowInfo({
|
|
1512
|
-
cfg: params.cfg,
|
|
1513
|
-
provider: params.contextConfigProvider ?? params.provider,
|
|
1514
|
-
modelId: params.modelId,
|
|
1515
|
-
modelContextTokens: readPiModelContextTokens(params.runtimeModel),
|
|
1516
|
-
modelContextWindow: params.runtimeModel.contextWindow,
|
|
1517
|
-
defaultTokens: DEFAULT_CONTEXT_TOKENS
|
|
1518
|
-
});
|
|
1519
|
-
const effectiveModel = ctxInfo.tokens < (params.runtimeModel.contextWindow ?? Infinity) ? {
|
|
1520
|
-
...params.runtimeModel,
|
|
1521
|
-
contextWindow: ctxInfo.tokens
|
|
1522
|
-
} : params.runtimeModel;
|
|
1523
|
-
const ctxGuard = evaluateContextWindowGuard({ info: ctxInfo });
|
|
1524
|
-
const runtimeBaseUrl = typeof params.runtimeModel.baseUrl === "string" ? params.runtimeModel.baseUrl : void 0;
|
|
1525
|
-
if (ctxGuard.shouldWarn) log$1.warn(formatContextWindowWarningMessage({
|
|
1526
|
-
provider: params.provider,
|
|
1527
|
-
modelId: params.modelId,
|
|
1528
|
-
guard: ctxGuard,
|
|
1529
|
-
runtimeBaseUrl
|
|
1530
|
-
}));
|
|
1531
|
-
if (ctxGuard.shouldBlock) {
|
|
1532
|
-
const message = formatContextWindowBlockMessage({
|
|
1533
|
-
guard: ctxGuard,
|
|
1534
|
-
runtimeBaseUrl
|
|
1535
|
-
});
|
|
1536
|
-
log$1.error(`blocked model (context window too small): ${params.provider}/${params.modelId} ctx=${ctxGuard.tokens} (min=${ctxGuard.hardMinTokens}) source=${ctxGuard.source}; ${message}`);
|
|
1537
|
-
throw new FailoverError(message, {
|
|
1538
|
-
reason: "unknown",
|
|
1539
|
-
provider: params.provider,
|
|
1540
|
-
model: params.modelId
|
|
1541
|
-
});
|
|
1542
|
-
}
|
|
1543
|
-
return {
|
|
1544
|
-
ctxInfo,
|
|
1545
|
-
effectiveModel
|
|
1546
|
-
};
|
|
1547
|
-
}
|
|
1548
|
-
//#endregion
|
|
1549
|
-
//#region src/agents/pi-embedded-runner/run/tool-media-payloads.ts
|
|
1550
|
-
function mergeAttemptToolMediaPayloads(params) {
|
|
1551
|
-
const mediaUrls = Array.from(new Set(params.toolMediaUrls?.map((url) => url.trim()).filter(Boolean) ?? []));
|
|
1552
|
-
if (mediaUrls.length === 0 && !params.toolAudioAsVoice && !params.toolTrustedLocalMedia) return params.payloads;
|
|
1553
|
-
const payloads = params.payloads?.length ? [...params.payloads] : [];
|
|
1554
|
-
const payloadIndex = payloads.findIndex((payload) => !payload.isReasoning);
|
|
1555
|
-
if (payloadIndex >= 0) {
|
|
1556
|
-
const payload = payloads[payloadIndex];
|
|
1557
|
-
if (params.sourceReplyDeliveryMode === "message_tool_only" && getReplyPayloadMetadata(payload)?.sourceReplyTranscriptMirror) return payloads;
|
|
1558
|
-
const mergedMediaUrls = Array.from(new Set([...payload.mediaUrls ?? [], ...mediaUrls]));
|
|
1559
|
-
payloads[payloadIndex] = copyReplyPayloadMetadata(payload, {
|
|
1560
|
-
...payload,
|
|
1561
|
-
mediaUrls: mergedMediaUrls.length ? mergedMediaUrls : void 0,
|
|
1562
|
-
mediaUrl: payload.mediaUrl ?? mergedMediaUrls[0],
|
|
1563
|
-
audioAsVoice: payload.audioAsVoice || params.toolAudioAsVoice || void 0,
|
|
1564
|
-
trustedLocalMedia: payload.trustedLocalMedia || params.toolTrustedLocalMedia || void 0
|
|
1565
|
-
});
|
|
1566
|
-
return payloads;
|
|
1567
|
-
}
|
|
1568
|
-
return [...payloads, {
|
|
1569
|
-
mediaUrls: mediaUrls.length ? mediaUrls : void 0,
|
|
1570
|
-
mediaUrl: mediaUrls[0],
|
|
1571
|
-
audioAsVoice: params.toolAudioAsVoice || void 0,
|
|
1572
|
-
trustedLocalMedia: params.toolTrustedLocalMedia || void 0
|
|
1573
|
-
}];
|
|
1574
|
-
}
|
|
1575
|
-
//#endregion
|
|
1576
|
-
//#region src/agents/pi-embedded-runner/run.ts
|
|
1577
|
-
const MAX_SAME_MODEL_IDLE_TIMEOUT_RETRIES = 1;
|
|
1578
|
-
const EMBEDDED_RUN_LANE_TIMEOUT_GRACE_MS = 3e4;
|
|
1579
|
-
const MID_TURN_PRECHECK_CONTINUATION_PROMPT = "Continue from the current transcript after the latest tool result. Do not repeat the original user request, and do not rerun completed tools unless the transcript shows they are still needed.";
|
|
1580
|
-
const COMPACTION_CONTINUATION_RETRY_INSTRUCTION = "The previous attempt compacted the conversation context before producing a final user-visible answer. Continue from the compacted transcript and produce the final answer now. Do not restart from scratch, do not repeat completed work, and do not rerun tools unless the transcript clearly lacks required evidence.";
|
|
1581
|
-
function resolveAttemptDispatchApiKey(params) {
|
|
1582
|
-
if (params.runtimeAuthState) return;
|
|
1583
|
-
return params.apiKeyInfo?.apiKey;
|
|
1584
|
-
}
|
|
1585
|
-
function resolveEmbeddedRunLaneTimeoutMs(timeoutMs) {
|
|
1586
|
-
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) return;
|
|
1587
|
-
return Math.floor(timeoutMs) + EMBEDDED_RUN_LANE_TIMEOUT_GRACE_MS;
|
|
1588
|
-
}
|
|
1589
|
-
function withEmbeddedRunLaneTimeout(opts, laneTaskTimeoutMs) {
|
|
1590
|
-
if (laneTaskTimeoutMs === void 0 || opts?.taskTimeoutMs !== void 0) return opts;
|
|
1591
|
-
return {
|
|
1592
|
-
...opts,
|
|
1593
|
-
taskTimeoutMs: laneTaskTimeoutMs
|
|
1594
|
-
};
|
|
1595
|
-
}
|
|
1596
|
-
function resolveEmbeddedRunSessionQueuePriority(trigger) {
|
|
1597
|
-
switch (trigger) {
|
|
1598
|
-
case "user":
|
|
1599
|
-
case "manual": return "foreground";
|
|
1600
|
-
case "cron":
|
|
1601
|
-
case "heartbeat":
|
|
1602
|
-
case "memory":
|
|
1603
|
-
case "overflow": return "background";
|
|
1604
|
-
default: return "normal";
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
function normalizeEmbeddedRunAttemptResult(attempt) {
|
|
1608
|
-
const raw = attempt;
|
|
1609
|
-
return {
|
|
1610
|
-
...attempt,
|
|
1611
|
-
assistantTexts: raw.assistantTexts ?? [],
|
|
1612
|
-
toolMetas: raw.toolMetas ?? [],
|
|
1613
|
-
acceptedSessionSpawns: raw.acceptedSessionSpawns ?? [],
|
|
1614
|
-
messagesSnapshot: raw.messagesSnapshot ?? [],
|
|
1615
|
-
messagingToolSentTexts: raw.messagingToolSentTexts ?? [],
|
|
1616
|
-
messagingToolSentMediaUrls: raw.messagingToolSentMediaUrls ?? [],
|
|
1617
|
-
messagingToolSentTargets: raw.messagingToolSentTargets ?? [],
|
|
1618
|
-
messagingToolSourceReplyPayloads: raw.messagingToolSourceReplyPayloads ?? [],
|
|
1619
|
-
itemLifecycle: raw.itemLifecycle ?? {
|
|
1620
|
-
startedCount: 0,
|
|
1621
|
-
completedCount: 0,
|
|
1622
|
-
activeCount: 0
|
|
1623
|
-
},
|
|
1624
|
-
replayMetadata: resolveAttemptReplayMetadata(raw)
|
|
1625
|
-
};
|
|
1626
|
-
}
|
|
1627
|
-
function hasCompletedModelProgressForIdleBreaker(attempt) {
|
|
1628
|
-
return attempt.assistantTexts.some((text) => text.trim().length > 0) || attempt.toolMetas.length > 0 || (attempt.clientToolCalls?.length ?? 0) > 0 || hasOutboundDeliveryEvidence(attempt) || attempt.itemLifecycle.completedCount > 0;
|
|
1629
|
-
}
|
|
1630
|
-
function createEmptyAuthProfileStore() {
|
|
1631
|
-
return {
|
|
1632
|
-
version: 1,
|
|
1633
|
-
profiles: {}
|
|
1634
|
-
};
|
|
1635
|
-
}
|
|
1636
|
-
function createScopedAuthProfileStore(store, profileIds) {
|
|
1637
|
-
const profiles = store.profiles ?? {};
|
|
1638
|
-
const normalizedProfileIds = (Array.isArray(profileIds) ? profileIds : [profileIds]).map((profileId) => profileId?.trim()).filter((profileId) => !!profileId);
|
|
1639
|
-
const scopedProfiles = Object.fromEntries(normalizedProfileIds.flatMap((profileId) => {
|
|
1640
|
-
const credential = profiles[profileId];
|
|
1641
|
-
return credential ? [[profileId, credential]] : [];
|
|
1642
|
-
}));
|
|
1643
|
-
return Object.keys(scopedProfiles).length > 0 ? {
|
|
1644
|
-
version: store.version,
|
|
1645
|
-
profiles: scopedProfiles
|
|
1646
|
-
} : createEmptyAuthProfileStore();
|
|
1647
|
-
}
|
|
1648
|
-
function buildTraceToolSummary(params) {
|
|
1649
|
-
if (!params.toolMetas?.length) return;
|
|
1650
|
-
const tools = [];
|
|
1651
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1652
|
-
for (const entry of params.toolMetas) {
|
|
1653
|
-
const toolName = normalizeOptionalString(entry.toolName);
|
|
1654
|
-
if (!toolName || seen.has(toolName)) continue;
|
|
1655
|
-
seen.add(toolName);
|
|
1656
|
-
tools.push(toolName);
|
|
1657
|
-
}
|
|
1658
|
-
return {
|
|
1659
|
-
calls: params.toolMetas?.length ?? 0,
|
|
1660
|
-
tools,
|
|
1661
|
-
failures: params.hadFailure ? 1 : 0
|
|
1662
|
-
};
|
|
1663
|
-
}
|
|
1664
|
-
/**
|
|
1665
|
-
* Best-effort backfill of sessionKey from sessionId when not explicitly provided.
|
|
1666
|
-
* The return value is normalized: whitespace-only inputs collapse to undefined, and
|
|
1667
|
-
* successful resolution returns a trimmed session key. This is a read-only lookup
|
|
1668
|
-
* with no side effects.
|
|
1669
|
-
* See: https://github.com/openclaw/openclaw/issues/60552
|
|
1670
|
-
*/
|
|
1671
|
-
function backfillSessionKey(params) {
|
|
1672
|
-
const trimmed = normalizeOptionalString(params.sessionKey);
|
|
1673
|
-
if (trimmed) return trimmed;
|
|
1674
|
-
if (!params.config || !params.sessionId) return;
|
|
1675
|
-
try {
|
|
1676
|
-
return normalizeOptionalString((normalizeOptionalString(params.agentId) ? resolveStoredSessionKeyForSessionId({
|
|
1677
|
-
cfg: params.config,
|
|
1678
|
-
sessionId: params.sessionId,
|
|
1679
|
-
agentId: params.agentId
|
|
1680
|
-
}) : resolveSessionKeyForRequest({
|
|
1681
|
-
cfg: params.config,
|
|
1682
|
-
sessionId: params.sessionId
|
|
1683
|
-
})).sessionKey);
|
|
1684
|
-
} catch (err) {
|
|
1685
|
-
log$1.warn(`[backfillSessionKey] Failed to resolve sessionKey for sessionId=${redactRunIdentifier(sanitizeForLog(params.sessionId))}: ${formatErrorMessage(err)}`);
|
|
1686
|
-
return;
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
function buildHandledReplyPayloads(reply) {
|
|
1690
|
-
const normalized = reply ?? { text: "NO_REPLY" };
|
|
1691
|
-
return [{
|
|
1692
|
-
text: normalized.text,
|
|
1693
|
-
mediaUrl: normalized.mediaUrl,
|
|
1694
|
-
mediaUrls: normalized.mediaUrls,
|
|
1695
|
-
replyToId: normalized.replyToId,
|
|
1696
|
-
audioAsVoice: normalized.audioAsVoice,
|
|
1697
|
-
isError: normalized.isError,
|
|
1698
|
-
isReasoning: normalized.isReasoning
|
|
1699
|
-
}];
|
|
1700
|
-
}
|
|
1701
|
-
async function runEmbeddedPiAgent(params) {
|
|
1702
|
-
const effectiveSessionKey = backfillSessionKey({
|
|
1703
|
-
config: params.config,
|
|
1704
|
-
sessionId: params.sessionId,
|
|
1705
|
-
sessionKey: params.sessionKey,
|
|
1706
|
-
agentId: params.agentId
|
|
1707
|
-
});
|
|
1708
|
-
if (effectiveSessionKey !== params.sessionKey) params = {
|
|
1709
|
-
...params,
|
|
1710
|
-
sessionKey: effectiveSessionKey
|
|
1711
|
-
};
|
|
1712
|
-
const sessionLane = resolveSessionLane(params.sessionKey?.trim() || params.sessionId);
|
|
1713
|
-
const globalLane = resolveGlobalLane(params.lane);
|
|
1714
|
-
const sessionQueuePriority = resolveEmbeddedRunSessionQueuePriority(params.trigger);
|
|
1715
|
-
const laneTaskTimeoutMs = resolveEmbeddedRunLaneTimeoutMs(params.timeoutMs);
|
|
1716
|
-
let laneTaskProgressAtMs = Date.now();
|
|
1717
|
-
const noteLaneTaskProgress = () => {
|
|
1718
|
-
laneTaskProgressAtMs = Date.now();
|
|
1719
|
-
};
|
|
1720
|
-
const withLaneTimeout = (opts) => withEmbeddedRunLaneTimeout({
|
|
1721
|
-
...opts,
|
|
1722
|
-
taskTimeoutProgressAtMs: () => laneTaskProgressAtMs
|
|
1723
|
-
}, laneTaskTimeoutMs);
|
|
1724
|
-
const enqueueGlobal = (task, opts) => params.enqueue ? params.enqueue(task, withLaneTimeout(opts)) : enqueueCommandInLane(globalLane, task, withLaneTimeout(opts));
|
|
1725
|
-
const enqueueSession = (task, opts) => {
|
|
1726
|
-
const sessionOpts = {
|
|
1727
|
-
...opts,
|
|
1728
|
-
priority: sessionQueuePriority
|
|
1729
|
-
};
|
|
1730
|
-
return params.enqueue ? params.enqueue(task, sessionOpts) : enqueueCommandInLane(sessionLane, task, sessionOpts);
|
|
1731
|
-
};
|
|
1732
|
-
const channelHint = params.messageChannel ?? params.messageProvider;
|
|
1733
|
-
const resolvedToolResultFormat = params.toolResultFormat ?? (channelHint ? isMarkdownCapableMessageChannel(channelHint) ? "markdown" : "plain" : "markdown");
|
|
1734
|
-
const isProbeSession = params.sessionId?.startsWith("probe-") ?? false;
|
|
1735
|
-
const throwIfAborted = () => {
|
|
1736
|
-
if (!params.abortSignal?.aborted) return;
|
|
1737
|
-
const reason = params.abortSignal.reason;
|
|
1738
|
-
if (reason instanceof Error) throw reason;
|
|
1739
|
-
const abortErr = reason !== void 0 ? new Error("Operation aborted", { cause: reason }) : /* @__PURE__ */ new Error("Operation aborted");
|
|
1740
|
-
abortErr.name = "AbortError";
|
|
1741
|
-
throw abortErr;
|
|
1742
|
-
};
|
|
1743
|
-
throwIfAborted();
|
|
1744
|
-
return enqueueSession(() => {
|
|
1745
|
-
throwIfAborted();
|
|
1746
|
-
return enqueueGlobal(async () => {
|
|
1747
|
-
throwIfAborted();
|
|
1748
|
-
const started = Date.now();
|
|
1749
|
-
const startupStages = createEmbeddedRunStageTracker();
|
|
1750
|
-
let startupStagesEmitted = false;
|
|
1751
|
-
const notifyExecutionPhase = (phase, extra) => {
|
|
1752
|
-
noteLaneTaskProgress();
|
|
1753
|
-
params.onExecutionPhase?.({
|
|
1754
|
-
phase,
|
|
1755
|
-
...extra
|
|
1756
|
-
});
|
|
1757
|
-
};
|
|
1758
|
-
const notifyRunProgress = (info) => {
|
|
1759
|
-
noteLaneTaskProgress();
|
|
1760
|
-
params.onRunProgress?.(info);
|
|
1761
|
-
};
|
|
1762
|
-
const emitStartupStageSummary = (phase) => {
|
|
1763
|
-
const summary = startupStages.snapshot();
|
|
1764
|
-
const shouldWarn = shouldWarnEmbeddedRunStageSummary(summary);
|
|
1765
|
-
if (!shouldWarn && !log$1.isEnabled("trace")) return;
|
|
1766
|
-
const message = formatEmbeddedRunStageSummary(`[trace:embedded-run] startup stages: runId=${params.runId} sessionId=${params.sessionId} phase=${phase}`, summary);
|
|
1767
|
-
if (shouldWarn) log$1.warn(message);
|
|
1768
|
-
else log$1.trace(message);
|
|
1769
|
-
};
|
|
1770
|
-
params.onExecutionStarted?.();
|
|
1771
|
-
notifyExecutionPhase("runner_entered");
|
|
1772
|
-
const workspaceResolution = resolveRunWorkspaceDir({
|
|
1773
|
-
workspaceDir: params.workspaceDir,
|
|
1774
|
-
sessionKey: params.sessionKey,
|
|
1775
|
-
agentId: params.agentId,
|
|
1776
|
-
config: params.config
|
|
1777
|
-
});
|
|
1778
|
-
const resolvedWorkspace = workspaceResolution.workspaceDir;
|
|
1779
|
-
const isCanonicalWorkspace = resolveUserPath(resolveAgentWorkspaceDir(params.config ?? {}, workspaceResolution.agentId)) === resolvedWorkspace;
|
|
1780
|
-
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
1781
|
-
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
1782
|
-
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
1783
|
-
if (workspaceResolution.usedFallback) log$1.warn(`[workspace-fallback] caller=runEmbeddedPiAgent reason=${workspaceResolution.fallbackReason} run=${params.runId} session=${redactedSessionId} sessionKey=${redactedSessionKey} agent=${workspaceResolution.agentId} workspace=${redactedWorkspace}`);
|
|
1784
|
-
startupStages.mark("workspace");
|
|
1785
|
-
notifyExecutionPhase("workspace");
|
|
1786
|
-
ensureRuntimePluginsLoaded({
|
|
1787
|
-
config: params.config,
|
|
1788
|
-
workspaceDir: resolvedWorkspace,
|
|
1789
|
-
allowGatewaySubagentBinding: params.allowGatewaySubagentBinding
|
|
1790
|
-
});
|
|
1791
|
-
startupStages.mark("runtime-plugins");
|
|
1792
|
-
notifyExecutionPhase("runtime_plugins");
|
|
1793
|
-
let provider = (params.provider ?? "openai").trim() || "openai";
|
|
1794
|
-
let modelId = (params.model ?? "gpt-5.5").trim() || "gpt-5.5";
|
|
1795
|
-
const agentDir = params.agentDir ?? resolveAgentDir(params.config ?? {}, workspaceResolution.agentId);
|
|
1796
|
-
const normalizedSessionKey = params.sessionKey?.trim();
|
|
1797
|
-
const fallbackConfigured = hasEmbeddedRunConfiguredModelFallbacks({
|
|
1798
|
-
cfg: params.config,
|
|
1799
|
-
agentId: params.agentId,
|
|
1800
|
-
sessionKey: normalizedSessionKey,
|
|
1801
|
-
modelFallbacksOverride: params.modelFallbacksOverride
|
|
1802
|
-
});
|
|
1803
|
-
const resolvedSessionKey = normalizedSessionKey;
|
|
1804
|
-
const hookRunner = getGlobalHookRunner();
|
|
1805
|
-
const hookCtx = {
|
|
1806
|
-
runId: params.runId,
|
|
1807
|
-
jobId: params.jobId,
|
|
1808
|
-
agentId: workspaceResolution.agentId,
|
|
1809
|
-
sessionKey: resolvedSessionKey,
|
|
1810
|
-
sessionId: params.sessionId,
|
|
1811
|
-
workspaceDir: resolvedWorkspace,
|
|
1812
|
-
modelProviderId: provider,
|
|
1813
|
-
modelId,
|
|
1814
|
-
trigger: params.trigger,
|
|
1815
|
-
...buildAgentHookContextChannelFields(params)
|
|
1816
|
-
};
|
|
1817
|
-
if (params.trigger === "cron" && hookRunner?.hasHooks("before_agent_reply")) {
|
|
1818
|
-
notifyExecutionPhase("before_agent_reply", {
|
|
1819
|
-
provider,
|
|
1820
|
-
model: modelId
|
|
1821
|
-
});
|
|
1822
|
-
const hookResult = await hookRunner.runBeforeAgentReply({ cleanedBody: params.prompt }, hookCtx);
|
|
1823
|
-
if (hookResult?.handled) return {
|
|
1824
|
-
payloads: buildHandledReplyPayloads(hookResult.reply),
|
|
1825
|
-
meta: {
|
|
1826
|
-
durationMs: Date.now() - started,
|
|
1827
|
-
agentMeta: {
|
|
1828
|
-
sessionId: params.sessionId,
|
|
1829
|
-
provider,
|
|
1830
|
-
model: modelId
|
|
1831
|
-
},
|
|
1832
|
-
finalAssistantVisibleText: hookResult.reply?.text ?? "NO_REPLY",
|
|
1833
|
-
finalAssistantRawText: hookResult.reply?.text ?? "NO_REPLY"
|
|
1834
|
-
}
|
|
1835
|
-
};
|
|
1836
|
-
notifyExecutionPhase("runtime_plugins", {
|
|
1837
|
-
provider,
|
|
1838
|
-
model: modelId
|
|
1839
|
-
});
|
|
1840
|
-
}
|
|
1841
|
-
const hookSelection = await resolveHookModelSelection({
|
|
1842
|
-
prompt: params.prompt,
|
|
1843
|
-
attachments: buildBeforeModelResolveAttachments(params.images),
|
|
1844
|
-
provider,
|
|
1845
|
-
modelId,
|
|
1846
|
-
hookRunner,
|
|
1847
|
-
hookContext: hookCtx
|
|
1848
|
-
});
|
|
1849
|
-
provider = hookSelection.provider;
|
|
1850
|
-
modelId = hookSelection.modelId;
|
|
1851
|
-
const legacyBeforeAgentStartResult = hookSelection.legacyBeforeAgentStartResult;
|
|
1852
|
-
startupStages.mark("hooks");
|
|
1853
|
-
await ensureSelectedAgentHarnessPlugin({
|
|
1854
|
-
provider,
|
|
1855
|
-
modelId,
|
|
1856
|
-
config: params.config,
|
|
1857
|
-
agentId: params.agentId,
|
|
1858
|
-
sessionKey: params.sessionKey,
|
|
1859
|
-
agentHarnessRuntimeOverride: params.agentHarnessRuntimeOverride,
|
|
1860
|
-
workspaceDir: resolvedWorkspace
|
|
1861
|
-
});
|
|
1862
|
-
const agentHarness = selectAgentHarness({
|
|
1863
|
-
provider,
|
|
1864
|
-
modelId,
|
|
1865
|
-
config: params.config,
|
|
1866
|
-
agentId: params.agentId,
|
|
1867
|
-
sessionKey: params.sessionKey,
|
|
1868
|
-
agentHarnessId: params.agentHarnessId,
|
|
1869
|
-
agentHarnessRuntimeOverride: params.agentHarnessRuntimeOverride
|
|
1870
|
-
});
|
|
1871
|
-
const pluginHarnessOwnsTransport = agentHarness.id !== "pi";
|
|
1872
|
-
const modelConfigProvider = provider;
|
|
1873
|
-
const selectedPiRuntimeProvider = resolveSelectedOpenAIPiRuntimeProvider({
|
|
1874
|
-
provider,
|
|
1875
|
-
harnessRuntime: agentHarness.id,
|
|
1876
|
-
agentHarnessId: agentHarness.id,
|
|
1877
|
-
authProfileProvider: params.authProfileId?.split(":", 1)[0],
|
|
1878
|
-
authProfileId: params.authProfileId,
|
|
1879
|
-
config: params.config,
|
|
1880
|
-
workspaceDir: resolvedWorkspace
|
|
1881
|
-
});
|
|
1882
|
-
const dynamicModelResolution = await resolveModelAsync(provider, modelId, agentDir, params.config, {
|
|
1883
|
-
skipPiDiscovery: true,
|
|
1884
|
-
workspaceDir: resolvedWorkspace
|
|
1885
|
-
});
|
|
1886
|
-
let modelResolution = dynamicModelResolution.model || pluginHarnessOwnsTransport ? dynamicModelResolution : await (async () => {
|
|
1887
|
-
await ensureDaoCoreModelsJson(params.config, agentDir, { workspaceDir: resolvedWorkspace });
|
|
1888
|
-
return await resolveModelAsync(provider, modelId, agentDir, params.config, { workspaceDir: resolvedWorkspace });
|
|
1889
|
-
})();
|
|
1890
|
-
if (selectedPiRuntimeProvider !== provider && modelResolution.model) {
|
|
1891
|
-
const runtimeModelResolution = await resolveModelAsync(selectedPiRuntimeProvider, modelId, agentDir, params.config, {
|
|
1892
|
-
skipPiDiscovery: true,
|
|
1893
|
-
workspaceDir: resolvedWorkspace
|
|
1894
|
-
});
|
|
1895
|
-
if (runtimeModelResolution.model) {
|
|
1896
|
-
provider = selectedPiRuntimeProvider;
|
|
1897
|
-
modelResolution = runtimeModelResolution;
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
const { model, error, authStorage, modelRegistry } = modelResolution;
|
|
1901
|
-
if (!model) throw new FailoverError(error ?? `Unknown model: ${provider}/${modelId}`, {
|
|
1902
|
-
reason: "model_not_found",
|
|
1903
|
-
provider,
|
|
1904
|
-
model: modelId,
|
|
1905
|
-
sessionId: params.sessionId,
|
|
1906
|
-
lane: globalLane
|
|
1907
|
-
});
|
|
1908
|
-
let runtimeModel = model;
|
|
1909
|
-
const resolvedRuntimeModel = resolveEffectiveRuntimeModel({
|
|
1910
|
-
cfg: params.config,
|
|
1911
|
-
provider,
|
|
1912
|
-
contextConfigProvider: resolveContextConfigProviderForRuntime({
|
|
1913
|
-
provider: modelConfigProvider,
|
|
1914
|
-
runtimeId: agentHarness.id
|
|
1915
|
-
}),
|
|
1916
|
-
modelId,
|
|
1917
|
-
runtimeModel
|
|
1918
|
-
});
|
|
1919
|
-
const ctxInfo = resolvedRuntimeModel.ctxInfo;
|
|
1920
|
-
let effectiveModel = resolvedRuntimeModel.effectiveModel;
|
|
1921
|
-
startupStages.mark("model-resolution");
|
|
1922
|
-
notifyExecutionPhase("model_resolution", {
|
|
1923
|
-
provider,
|
|
1924
|
-
model: modelId
|
|
1925
|
-
});
|
|
1926
|
-
const pluginHarnessNeedsDaoCoreAuthBootstrap = pluginHarnessOwnsTransport && provider === "openai-codex" && effectiveModel.api === "openai-codex-responses";
|
|
1927
|
-
const authStore = pluginHarnessOwnsTransport && !pluginHarnessNeedsDaoCoreAuthBootstrap ? createEmptyAuthProfileStore() : pluginHarnessNeedsDaoCoreAuthBootstrap ? ensureAuthProfileStore(agentDir, {
|
|
1928
|
-
externalCliProviderIds: [OPENAI_CODEX_PROVIDER_ID],
|
|
1929
|
-
allowKeychainPrompt: false
|
|
1930
|
-
}) : ensureAuthProfileStoreWithoutExternalProfiles(agentDir, { allowKeychainPrompt: false });
|
|
1931
|
-
const attemptAuthProfileStore = pluginHarnessOwnsTransport && !pluginHarnessNeedsDaoCoreAuthBootstrap ? ensureAuthProfileStoreWithoutExternalProfiles(agentDir, { allowKeychainPrompt: false }) : authStore;
|
|
1932
|
-
const requestedProfileId = params.authProfileId?.trim();
|
|
1933
|
-
const requestedProfileIsUserLocked = params.authProfileIdSource === "user";
|
|
1934
|
-
const isForwardablePluginHarnessAuthProfile = (profileId) => {
|
|
1935
|
-
if (!pluginHarnessOwnsTransport || !profileId) return false;
|
|
1936
|
-
const credential = attemptAuthProfileStore.profiles?.[profileId];
|
|
1937
|
-
return buildAgentRuntimeAuthPlan({
|
|
1938
|
-
provider,
|
|
1939
|
-
authProfileProvider: credential?.provider ?? profileId.split(":", 1)[0],
|
|
1940
|
-
authProfileMode: credential?.type,
|
|
1941
|
-
sessionAuthProfileId: profileId,
|
|
1942
|
-
config: params.config,
|
|
1943
|
-
workspaceDir: resolvedWorkspace,
|
|
1944
|
-
harnessId: agentHarness.id,
|
|
1945
|
-
harnessRuntime: agentHarness.id,
|
|
1946
|
-
allowHarnessAuthProfileForwarding: true
|
|
1947
|
-
}).forwardedAuthProfileId === profileId;
|
|
1948
|
-
};
|
|
1949
|
-
const resolvePluginHarnessProfileOrder = () => {
|
|
1950
|
-
if (requestedProfileId && requestedProfileIsUserLocked) return isForwardablePluginHarnessAuthProfile(requestedProfileId) ? [requestedProfileId] : [];
|
|
1951
|
-
if (!pluginHarnessOwnsTransport) return [];
|
|
1952
|
-
const harnessAuthProvider = buildAgentRuntimeAuthPlan({
|
|
1953
|
-
provider,
|
|
1954
|
-
config: params.config,
|
|
1955
|
-
workspaceDir: resolvedWorkspace,
|
|
1956
|
-
harnessId: agentHarness.id,
|
|
1957
|
-
harnessRuntime: agentHarness.id,
|
|
1958
|
-
allowHarnessAuthProfileForwarding: true
|
|
1959
|
-
}).harnessAuthProvider;
|
|
1960
|
-
if (!harnessAuthProvider) return [];
|
|
1961
|
-
const resolvedOrder = resolveAuthProfileOrder({
|
|
1962
|
-
cfg: params.config,
|
|
1963
|
-
store: attemptAuthProfileStore,
|
|
1964
|
-
provider: harnessAuthProvider
|
|
1965
|
-
}).filter(isForwardablePluginHarnessAuthProfile);
|
|
1966
|
-
if (resolvedOrder.length > 0) return resolvedOrder;
|
|
1967
|
-
if (requestedProfileId && isForwardablePluginHarnessAuthProfile(requestedProfileId)) return [requestedProfileId];
|
|
1968
|
-
return [];
|
|
1969
|
-
};
|
|
1970
|
-
const pluginHarnessProfileOrder = pluginHarnessOwnsTransport ? resolvePluginHarnessProfileOrder() : [];
|
|
1971
|
-
const resolvePluginHarnessPreferredProfileId = () => pluginHarnessProfileOrder[0];
|
|
1972
|
-
const preferredProfileId = pluginHarnessOwnsTransport ? resolvePluginHarnessPreferredProfileId() : requestedProfileId;
|
|
1973
|
-
let lockedProfileId = requestedProfileIsUserLocked ? preferredProfileId : void 0;
|
|
1974
|
-
if (lockedProfileId) if (pluginHarnessOwnsTransport) {
|
|
1975
|
-
if (!isForwardablePluginHarnessAuthProfile(lockedProfileId)) lockedProfileId = void 0;
|
|
1976
|
-
} else {
|
|
1977
|
-
const lockedProfile = authStore.profiles[lockedProfileId];
|
|
1978
|
-
const lockedProfileProvider = lockedProfile ? resolveProviderIdForAuth(lockedProfile.provider, {
|
|
1979
|
-
config: params.config,
|
|
1980
|
-
workspaceDir: resolvedWorkspace
|
|
1981
|
-
}) : void 0;
|
|
1982
|
-
const runProvider = resolveProviderIdForAuth(provider, {
|
|
1983
|
-
config: params.config,
|
|
1984
|
-
workspaceDir: resolvedWorkspace
|
|
1985
|
-
});
|
|
1986
|
-
if (!lockedProfile || !lockedProfileProvider || lockedProfileProvider !== runProvider) lockedProfileId = void 0;
|
|
1987
|
-
}
|
|
1988
|
-
const forwardedPluginHarnessProfileId = pluginHarnessOwnsTransport && !lockedProfileId && isForwardablePluginHarnessAuthProfile(preferredProfileId) ? preferredProfileId : void 0;
|
|
1989
|
-
if (lockedProfileId && !pluginHarnessOwnsTransport) {
|
|
1990
|
-
if (!resolveAuthProfileEligibility({
|
|
1991
|
-
cfg: params.config,
|
|
1992
|
-
store: authStore,
|
|
1993
|
-
provider,
|
|
1994
|
-
profileId: lockedProfileId
|
|
1995
|
-
}).eligible) throw new Error(`Auth profile "${lockedProfileId}" is not configured for ${provider}.`);
|
|
1996
|
-
}
|
|
1997
|
-
const profileOrder = shouldPreferExplicitConfigApiKeyAuth(params.config, provider) ? [] : [...new Set(listOpenAIAuthProfileProvidersForAgentRuntime({
|
|
1998
|
-
provider,
|
|
1999
|
-
harnessRuntime: agentHarness.id,
|
|
2000
|
-
agentHarnessId: agentHarness.id,
|
|
2001
|
-
config: params.config
|
|
2002
|
-
}).flatMap((authProvider) => resolveAuthProfileOrder({
|
|
2003
|
-
cfg: params.config,
|
|
2004
|
-
store: authStore,
|
|
2005
|
-
provider: authProvider,
|
|
2006
|
-
preferredProfile: preferredProfileId
|
|
2007
|
-
})))];
|
|
2008
|
-
const providerPreferredProfileId = lockedProfileId ? void 0 : resolveProviderAuthProfileId({
|
|
2009
|
-
provider,
|
|
2010
|
-
config: params.config,
|
|
2011
|
-
workspaceDir: resolvedWorkspace,
|
|
2012
|
-
context: {
|
|
2013
|
-
config: params.config,
|
|
2014
|
-
agentDir,
|
|
2015
|
-
workspaceDir: resolvedWorkspace,
|
|
2016
|
-
provider,
|
|
2017
|
-
modelId,
|
|
2018
|
-
preferredProfileId,
|
|
2019
|
-
lockedProfileId,
|
|
2020
|
-
profileOrder,
|
|
2021
|
-
authStore
|
|
2022
|
-
}
|
|
2023
|
-
});
|
|
2024
|
-
const providerOrderedProfiles = providerPreferredProfileId && profileOrder.includes(providerPreferredProfileId) ? [providerPreferredProfileId, ...profileOrder.filter((profileId) => profileId !== providerPreferredProfileId)] : profileOrder;
|
|
2025
|
-
const profileCandidates = pluginHarnessOwnsTransport ? lockedProfileId ? [lockedProfileId] : pluginHarnessProfileOrder.length > 0 ? pluginHarnessProfileOrder : [void 0] : lockedProfileId ? [lockedProfileId] : providerOrderedProfiles.length > 0 ? providerOrderedProfiles : [void 0];
|
|
2026
|
-
const pluginHarnessForwardedProfileCandidates = pluginHarnessOwnsTransport ? profileCandidates.filter(isForwardablePluginHarnessAuthProfile) : [];
|
|
2027
|
-
const profileFailureStore = pluginHarnessOwnsTransport ? attemptAuthProfileStore : authStore;
|
|
2028
|
-
let profileIndex = 0;
|
|
2029
|
-
const traceAttempts = [];
|
|
2030
|
-
const initialThinkLevel = params.thinkLevel ?? "off";
|
|
2031
|
-
let thinkLevel = initialThinkLevel;
|
|
2032
|
-
const attemptedThinking = /* @__PURE__ */ new Set();
|
|
2033
|
-
let apiKeyInfo = null;
|
|
2034
|
-
let lastProfileId;
|
|
2035
|
-
let runtimeAuthState = null;
|
|
2036
|
-
let runtimeAuthRefreshCancelled = false;
|
|
2037
|
-
const { advanceAuthProfile, initializeAuthProfile, maybeRefreshRuntimeAuthForAuthError, stopRuntimeAuthRefreshTimer } = createEmbeddedRunAuthController({
|
|
2038
|
-
config: params.config,
|
|
2039
|
-
agentDir,
|
|
2040
|
-
workspaceDir: resolvedWorkspace,
|
|
2041
|
-
authStore,
|
|
2042
|
-
authStorage,
|
|
2043
|
-
profileCandidates,
|
|
2044
|
-
lockedProfileId,
|
|
2045
|
-
initialThinkLevel,
|
|
2046
|
-
attemptedThinking,
|
|
2047
|
-
fallbackConfigured,
|
|
2048
|
-
allowTransientCooldownProbe: params.allowTransientCooldownProbe === true,
|
|
2049
|
-
getProvider: () => provider,
|
|
2050
|
-
getModelId: () => modelId,
|
|
2051
|
-
getRuntimeModel: () => runtimeModel,
|
|
2052
|
-
setRuntimeModel: (next) => {
|
|
2053
|
-
runtimeModel = next;
|
|
2054
|
-
},
|
|
2055
|
-
getEffectiveModel: () => effectiveModel,
|
|
2056
|
-
setEffectiveModel: (next) => {
|
|
2057
|
-
effectiveModel = next;
|
|
2058
|
-
},
|
|
2059
|
-
getApiKeyInfo: () => apiKeyInfo,
|
|
2060
|
-
setApiKeyInfo: (next) => {
|
|
2061
|
-
apiKeyInfo = next;
|
|
2062
|
-
},
|
|
2063
|
-
getLastProfileId: () => lastProfileId,
|
|
2064
|
-
setLastProfileId: (next) => {
|
|
2065
|
-
lastProfileId = next;
|
|
2066
|
-
},
|
|
2067
|
-
getRuntimeAuthState: () => runtimeAuthState,
|
|
2068
|
-
setRuntimeAuthState: (next) => {
|
|
2069
|
-
runtimeAuthState = next;
|
|
2070
|
-
},
|
|
2071
|
-
getRuntimeAuthRefreshCancelled: () => runtimeAuthRefreshCancelled,
|
|
2072
|
-
setRuntimeAuthRefreshCancelled: (next) => {
|
|
2073
|
-
runtimeAuthRefreshCancelled = next;
|
|
2074
|
-
},
|
|
2075
|
-
getProfileIndex: () => profileIndex,
|
|
2076
|
-
setProfileIndex: (next) => {
|
|
2077
|
-
profileIndex = next;
|
|
2078
|
-
},
|
|
2079
|
-
setThinkLevel: (next) => {
|
|
2080
|
-
thinkLevel = next;
|
|
2081
|
-
},
|
|
2082
|
-
log: log$1
|
|
2083
|
-
});
|
|
2084
|
-
const advancePluginHarnessAuthProfile = async () => {
|
|
2085
|
-
if (!pluginHarnessOwnsTransport || lockedProfileId) return false;
|
|
2086
|
-
let nextIndex = profileIndex + 1;
|
|
2087
|
-
while (nextIndex < profileCandidates.length) {
|
|
2088
|
-
const candidate = profileCandidates[nextIndex];
|
|
2089
|
-
if (!candidate || !isForwardablePluginHarnessAuthProfile(candidate)) {
|
|
2090
|
-
nextIndex += 1;
|
|
2091
|
-
continue;
|
|
2092
|
-
}
|
|
2093
|
-
if (isProfileInCooldown(attemptAuthProfileStore, candidate, void 0, modelId)) {
|
|
2094
|
-
nextIndex += 1;
|
|
2095
|
-
continue;
|
|
2096
|
-
}
|
|
2097
|
-
profileIndex = nextIndex;
|
|
2098
|
-
lastProfileId = candidate;
|
|
2099
|
-
thinkLevel = initialThinkLevel;
|
|
2100
|
-
attemptedThinking.clear();
|
|
2101
|
-
return true;
|
|
2102
|
-
}
|
|
2103
|
-
return false;
|
|
2104
|
-
};
|
|
2105
|
-
const advanceAttemptAuthProfile = pluginHarnessOwnsTransport && !pluginHarnessNeedsDaoCoreAuthBootstrap ? advancePluginHarnessAuthProfile : advanceAuthProfile;
|
|
2106
|
-
if (!pluginHarnessOwnsTransport || pluginHarnessNeedsDaoCoreAuthBootstrap) await initializeAuthProfile();
|
|
2107
|
-
else if (lockedProfileId) lastProfileId = lockedProfileId;
|
|
2108
|
-
else if (forwardedPluginHarnessProfileId) lastProfileId = forwardedPluginHarnessProfileId;
|
|
2109
|
-
startupStages.mark("auth");
|
|
2110
|
-
notifyExecutionPhase("auth", {
|
|
2111
|
-
provider,
|
|
2112
|
-
model: modelId
|
|
2113
|
-
});
|
|
2114
|
-
const runAttemptAuthProfileStore = pluginHarnessOwnsTransport ? createScopedAuthProfileStore(attemptAuthProfileStore, pluginHarnessForwardedProfileCandidates.length > 0 ? pluginHarnessForwardedProfileCandidates : lastProfileId) : attemptAuthProfileStore;
|
|
2115
|
-
const { sessionAgentId } = resolveSessionAgentIds({
|
|
2116
|
-
sessionKey: params.sessionKey,
|
|
2117
|
-
config: params.config,
|
|
2118
|
-
agentId: params.agentId
|
|
2119
|
-
});
|
|
2120
|
-
const configuredExecutionContract = resolveAgentExecutionContract(params.config, sessionAgentId);
|
|
2121
|
-
const strictAgenticActive = isStrictAgenticExecutionContractActive({
|
|
2122
|
-
config: params.config,
|
|
2123
|
-
sessionKey: params.sessionKey,
|
|
2124
|
-
agentId: params.agentId,
|
|
2125
|
-
provider,
|
|
2126
|
-
modelId
|
|
2127
|
-
});
|
|
2128
|
-
const executionContract = strictAgenticActive ? "strict-agentic" : "default";
|
|
2129
|
-
const configuredExecutionContractForLog = configuredExecutionContract ?? "unspecified";
|
|
2130
|
-
const maxPlanningOnlyRetryAttempts = resolvePlanningOnlyRetryLimit(executionContract);
|
|
2131
|
-
const maxReasoningOnlyRetryAttempts = 2;
|
|
2132
|
-
const maxEmptyResponseRetryAttempts = 1;
|
|
2133
|
-
const MAX_TIMEOUT_COMPACTION_ATTEMPTS = 2;
|
|
2134
|
-
const MAX_OVERFLOW_COMPACTION_ATTEMPTS = 3;
|
|
2135
|
-
const MAX_RUN_LOOP_ITERATIONS = resolveMaxRunRetryIterations(profileCandidates.length, params.config, sessionAgentId);
|
|
2136
|
-
let overflowCompactionAttempts = 0;
|
|
2137
|
-
let toolResultTruncationAttempted = false;
|
|
2138
|
-
let bootstrapPromptWarningSignaturesSeen = params.bootstrapPromptWarningSignaturesSeen ?? (params.bootstrapPromptWarningSignature ? [params.bootstrapPromptWarningSignature] : []);
|
|
2139
|
-
const usageAccumulator = createUsageAccumulator();
|
|
2140
|
-
let lastRunPromptUsage;
|
|
2141
|
-
let autoCompactionCount = 0;
|
|
2142
|
-
let lastCompactionTokensAfter;
|
|
2143
|
-
let runLoopIterations = 0;
|
|
2144
|
-
let overloadProfileRotations = 0;
|
|
2145
|
-
let planningOnlyRetryAttempts = 0;
|
|
2146
|
-
let reasoningOnlyRetryAttempts = 0;
|
|
2147
|
-
let emptyResponseRetryAttempts = 0;
|
|
2148
|
-
let compactionContinuationRetryAttempts = 0;
|
|
2149
|
-
let sameModelIdleTimeoutRetries = 0;
|
|
2150
|
-
const idleTimeoutBreakerState = createIdleTimeoutBreakerState();
|
|
2151
|
-
const resolvedLoopDetectionConfig = resolveToolLoopDetectionConfig({
|
|
2152
|
-
cfg: params.config,
|
|
2153
|
-
agentId: sessionAgentId
|
|
2154
|
-
});
|
|
2155
|
-
const postCompactionGuard = createPostCompactionLoopGuard(resolvedLoopDetectionConfig?.postCompactionGuard, { enabled: resolvedLoopDetectionConfig?.enabled !== false });
|
|
2156
|
-
let postCompactionAbortController;
|
|
2157
|
-
let postCompactionAbortError;
|
|
2158
|
-
const observePostCompactionToolOutcome = (observation) => {
|
|
2159
|
-
const verdict = postCompactionGuard.observe(observation);
|
|
2160
|
-
if (verdict.shouldAbort) {
|
|
2161
|
-
postCompactionAbortError ??= PostCompactionLoopPersistedError.fromVerdict(verdict);
|
|
2162
|
-
postCompactionAbortController?.abort(postCompactionAbortError);
|
|
2163
|
-
}
|
|
2164
|
-
};
|
|
2165
|
-
let lastRetryFailoverReason = null;
|
|
2166
|
-
let planningOnlyRetryInstruction = null;
|
|
2167
|
-
let reasoningOnlyRetryInstruction = null;
|
|
2168
|
-
let emptyResponseRetryInstruction = null;
|
|
2169
|
-
let compactionContinuationRetryInstruction = null;
|
|
2170
|
-
let nextAttemptPromptOverride = null;
|
|
2171
|
-
const ackExecutionFastPathInstruction = resolveAckExecutionFastPathInstruction({
|
|
2172
|
-
provider,
|
|
2173
|
-
modelId,
|
|
2174
|
-
prompt: params.prompt
|
|
2175
|
-
});
|
|
2176
|
-
let rateLimitProfileRotations = 0;
|
|
2177
|
-
let timeoutCompactionAttempts = 0;
|
|
2178
|
-
let codexAppServerClientCloseRetries = 0;
|
|
2179
|
-
const MAX_EMPTY_ERROR_RETRIES = 3;
|
|
2180
|
-
let emptyErrorRetries = 0;
|
|
2181
|
-
const overloadFailoverBackoffMs = resolveOverloadFailoverBackoffMs(params.config);
|
|
2182
|
-
const overloadProfileRotationLimit = resolveOverloadProfileRotationLimit(params.config);
|
|
2183
|
-
const rateLimitProfileRotationLimit = resolveRateLimitProfileRotationLimit(params.config);
|
|
2184
|
-
let activeSessionId = params.sessionId;
|
|
2185
|
-
let activeSessionFile = params.sessionFile;
|
|
2186
|
-
let suppressNextUserMessagePersistence = params.suppressNextUserMessagePersistence ?? false;
|
|
2187
|
-
let lastPersistedCurrentMessageId;
|
|
2188
|
-
const onUserMessagePersisted = (message) => {
|
|
2189
|
-
if (params.currentMessageId !== void 0) lastPersistedCurrentMessageId = params.currentMessageId;
|
|
2190
|
-
params.onUserMessagePersisted?.(message);
|
|
2191
|
-
};
|
|
2192
|
-
const continueFromCurrentTranscript = () => {
|
|
2193
|
-
nextAttemptPromptOverride = MID_TURN_PRECHECK_CONTINUATION_PROMPT;
|
|
2194
|
-
suppressNextUserMessagePersistence = true;
|
|
2195
|
-
};
|
|
2196
|
-
const maybeEscalateRateLimitProfileFallback = (params) => {
|
|
2197
|
-
rateLimitProfileRotations += 1;
|
|
2198
|
-
if (rateLimitProfileRotations <= rateLimitProfileRotationLimit || !fallbackConfigured) return;
|
|
2199
|
-
const status = resolveFailoverStatus("rate_limit");
|
|
2200
|
-
log$1.warn(`rate-limit profile rotation cap reached for ${sanitizeForLog(provider)}/${sanitizeForLog(modelId)} after ${rateLimitProfileRotations} rotations; escalating to model fallback`);
|
|
2201
|
-
params.logFallbackDecision("fallback_model", { status });
|
|
2202
|
-
throw new FailoverError("The AI service is temporarily rate-limited. Please try again in a moment.", {
|
|
2203
|
-
reason: "rate_limit",
|
|
2204
|
-
provider: params.failoverProvider,
|
|
2205
|
-
model: params.failoverModel,
|
|
2206
|
-
profileId: lastProfileId,
|
|
2207
|
-
sessionId: activeSessionId,
|
|
2208
|
-
lane: globalLane,
|
|
2209
|
-
status
|
|
2210
|
-
});
|
|
2211
|
-
};
|
|
2212
|
-
const maybeMarkAuthProfileFailure = async (failure) => {
|
|
2213
|
-
const { profileId, reason } = failure;
|
|
2214
|
-
if (!profileId || !reason) return;
|
|
2215
|
-
await markAuthProfileFailure({
|
|
2216
|
-
store: profileFailureStore,
|
|
2217
|
-
profileId,
|
|
2218
|
-
reason,
|
|
2219
|
-
cfg: params.config,
|
|
2220
|
-
agentDir,
|
|
2221
|
-
runId: params.runId,
|
|
2222
|
-
modelId: failure.modelId
|
|
2223
|
-
});
|
|
2224
|
-
};
|
|
2225
|
-
const resolveRunAuthProfileFailureReason = (failoverReason, opts) => resolveAuthProfileFailureReason({
|
|
2226
|
-
failoverReason,
|
|
2227
|
-
providerStarted: opts?.providerStarted,
|
|
2228
|
-
policy: params.authProfileFailurePolicy
|
|
2229
|
-
});
|
|
2230
|
-
const maybeBackoffBeforeOverloadFailover = async (reason) => {
|
|
2231
|
-
if (reason !== "overloaded" || overloadFailoverBackoffMs <= 0) return;
|
|
2232
|
-
log$1.warn(`overload backoff before failover for ${provider}/${modelId}: delayMs=${overloadFailoverBackoffMs}`);
|
|
2233
|
-
try {
|
|
2234
|
-
await sleepWithAbort(overloadFailoverBackoffMs, params.abortSignal);
|
|
2235
|
-
} catch (err) {
|
|
2236
|
-
if (params.abortSignal?.aborted) {
|
|
2237
|
-
const abortErr = new Error("Operation aborted", { cause: err });
|
|
2238
|
-
abortErr.name = "AbortError";
|
|
2239
|
-
throw abortErr;
|
|
2240
|
-
}
|
|
2241
|
-
throw err;
|
|
2242
|
-
}
|
|
2243
|
-
};
|
|
2244
|
-
ensureContextEnginesInitialized();
|
|
2245
|
-
const contextEngine = await resolveContextEngine(params.config, {
|
|
2246
|
-
agentDir,
|
|
2247
|
-
workspaceDir: resolvedWorkspace
|
|
2248
|
-
});
|
|
2249
|
-
const contextEnginePluginId = resolveContextEngineOwnerPluginId(contextEngine);
|
|
2250
|
-
startupStages.mark("context-engine");
|
|
2251
|
-
notifyExecutionPhase("context_engine", {
|
|
2252
|
-
provider,
|
|
2253
|
-
model: modelId
|
|
2254
|
-
});
|
|
2255
|
-
try {
|
|
2256
|
-
const resolveActiveHookContext = () => ({
|
|
2257
|
-
...hookCtx,
|
|
2258
|
-
sessionId: activeSessionId
|
|
2259
|
-
});
|
|
2260
|
-
const adoptCompactionTranscript = (compactResult) => {
|
|
2261
|
-
const nextSessionId = compactResult.result?.sessionId;
|
|
2262
|
-
const nextSessionFile = compactResult.result?.sessionFile;
|
|
2263
|
-
if (nextSessionId && nextSessionId !== activeSessionId) activeSessionId = nextSessionId;
|
|
2264
|
-
if (nextSessionFile && nextSessionFile !== activeSessionFile) activeSessionFile = nextSessionFile;
|
|
2265
|
-
};
|
|
2266
|
-
const onCompactionHookMessages = async (payload) => {
|
|
2267
|
-
const messages = payload.messages.filter((message) => message.trim().length > 0);
|
|
2268
|
-
if (messages.length === 0) return;
|
|
2269
|
-
await params.onAgentEvent?.({
|
|
2270
|
-
stream: "compaction",
|
|
2271
|
-
data: {
|
|
2272
|
-
phase: payload.phase === "before" ? "start" : "end",
|
|
2273
|
-
...payload.phase === "after" ? { completed: true } : {},
|
|
2274
|
-
messages
|
|
2275
|
-
},
|
|
2276
|
-
...params.sessionKey ? { sessionKey: params.sessionKey } : {}
|
|
2277
|
-
});
|
|
2278
|
-
};
|
|
2279
|
-
const runOwnsCompactionBeforeHook = async (reason) => {
|
|
2280
|
-
if (contextEngine.info.ownsCompaction !== true || !hookRunner?.hasHooks("before_compaction")) return;
|
|
2281
|
-
try {
|
|
2282
|
-
await hookRunner.runBeforeCompaction({
|
|
2283
|
-
messageCount: -1,
|
|
2284
|
-
sessionFile: activeSessionFile
|
|
2285
|
-
}, resolveActiveHookContext());
|
|
2286
|
-
} catch (hookErr) {
|
|
2287
|
-
log$1.warn(`before_compaction hook failed during ${reason}: ${String(hookErr)}`);
|
|
2288
|
-
}
|
|
2289
|
-
};
|
|
2290
|
-
const runOwnsCompactionAfterHook = async (reason, compactResult) => {
|
|
2291
|
-
if (contextEngine.info.ownsCompaction !== true || !compactResult.ok || !compactResult.compacted || !hookRunner?.hasHooks("after_compaction")) return;
|
|
2292
|
-
try {
|
|
2293
|
-
await hookRunner.runAfterCompaction({
|
|
2294
|
-
messageCount: -1,
|
|
2295
|
-
compactedCount: -1,
|
|
2296
|
-
tokenCount: compactResult.result?.tokensAfter,
|
|
2297
|
-
sessionFile: compactResult.result?.sessionFile ?? activeSessionFile
|
|
2298
|
-
}, resolveActiveHookContext());
|
|
2299
|
-
} catch (hookErr) {
|
|
2300
|
-
log$1.warn(`after_compaction hook failed during ${reason}: ${String(hookErr)}`);
|
|
2301
|
-
}
|
|
2302
|
-
};
|
|
2303
|
-
let authRetryPending = false;
|
|
2304
|
-
let accumulatedReplayState = createEmbeddedRunReplayState();
|
|
2305
|
-
let lastTurnTotal;
|
|
2306
|
-
while (true) {
|
|
2307
|
-
if (runLoopIterations >= MAX_RUN_LOOP_ITERATIONS) {
|
|
2308
|
-
const message = `Exceeded retry limit after ${runLoopIterations} attempts (max=${MAX_RUN_LOOP_ITERATIONS}).`;
|
|
2309
|
-
log$1.error(`[run-retry-limit] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} attempts=${runLoopIterations} maxAttempts=${MAX_RUN_LOOP_ITERATIONS}`);
|
|
2310
|
-
return handleRetryLimitExhaustion({
|
|
2311
|
-
message,
|
|
2312
|
-
decision: resolveRunFailoverDecision({
|
|
2313
|
-
stage: "retry_limit",
|
|
2314
|
-
fallbackConfigured,
|
|
2315
|
-
failoverReason: lastRetryFailoverReason
|
|
2316
|
-
}),
|
|
2317
|
-
provider,
|
|
2318
|
-
model: modelId,
|
|
2319
|
-
profileId: lastProfileId,
|
|
2320
|
-
durationMs: Date.now() - started,
|
|
2321
|
-
agentMeta: buildErrorAgentMeta({
|
|
2322
|
-
sessionId: activeSessionId,
|
|
2323
|
-
sessionFile: activeSessionFile,
|
|
2324
|
-
provider,
|
|
2325
|
-
model: model.id,
|
|
2326
|
-
contextTokens: ctxInfo.tokens,
|
|
2327
|
-
usageAccumulator,
|
|
2328
|
-
lastRunPromptUsage,
|
|
2329
|
-
lastTurnTotal
|
|
2330
|
-
}),
|
|
2331
|
-
replayInvalid: accumulatedReplayState.replayInvalid ? true : void 0,
|
|
2332
|
-
livenessState: "blocked"
|
|
2333
|
-
});
|
|
2334
|
-
}
|
|
2335
|
-
runLoopIterations += 1;
|
|
2336
|
-
const runtimeAuthRetry = authRetryPending;
|
|
2337
|
-
authRetryPending = false;
|
|
2338
|
-
attemptedThinking.add(thinkLevel);
|
|
2339
|
-
await fs.mkdir(resolvedWorkspace, { recursive: true });
|
|
2340
|
-
if (!startupStagesEmitted) startupStages.mark(EMBEDDED_RUN_ATTEMPT_DISPATCH_STAGE.workspace);
|
|
2341
|
-
const basePrompt = nextAttemptPromptOverride ?? (provider === "anthropic" ? scrubAnthropicRefusalMagic(params.prompt) : params.prompt);
|
|
2342
|
-
nextAttemptPromptOverride = null;
|
|
2343
|
-
const promptAdditions = [
|
|
2344
|
-
ackExecutionFastPathInstruction,
|
|
2345
|
-
planningOnlyRetryInstruction,
|
|
2346
|
-
reasoningOnlyRetryInstruction,
|
|
2347
|
-
emptyResponseRetryInstruction,
|
|
2348
|
-
compactionContinuationRetryInstruction
|
|
2349
|
-
].filter((value) => typeof value === "string" && value.trim().length > 0);
|
|
2350
|
-
const prompt = promptAdditions.length > 0 ? `${basePrompt}\n\n${promptAdditions.join("\n\n")}` : basePrompt;
|
|
2351
|
-
const resolvedStreamApiKey = resolveAttemptDispatchApiKey({
|
|
2352
|
-
apiKeyInfo,
|
|
2353
|
-
runtimeAuthState
|
|
2354
|
-
});
|
|
2355
|
-
if (!startupStagesEmitted) startupStages.mark(EMBEDDED_RUN_ATTEMPT_DISPATCH_STAGE.prompt);
|
|
2356
|
-
const runtimePlan = buildAgentRuntimePlan({
|
|
2357
|
-
provider,
|
|
2358
|
-
modelId,
|
|
2359
|
-
model: effectiveModel,
|
|
2360
|
-
modelApi: effectiveModel.api,
|
|
2361
|
-
harnessId: agentHarness.id,
|
|
2362
|
-
harnessRuntime: agentHarness.id,
|
|
2363
|
-
allowHarnessAuthProfileForwarding: pluginHarnessOwnsTransport,
|
|
2364
|
-
authProfileProvider: (lastProfileId ? attemptAuthProfileStore.profiles?.[lastProfileId]?.provider : void 0) ?? lastProfileId?.split(":", 1)[0],
|
|
2365
|
-
authProfileMode: lastProfileId ? attemptAuthProfileStore.profiles?.[lastProfileId]?.type : void 0,
|
|
2366
|
-
sessionAuthProfileId: lastProfileId,
|
|
2367
|
-
sessionAuthProfileCandidateIds: pluginHarnessOwnsTransport ? pluginHarnessForwardedProfileCandidates : void 0,
|
|
2368
|
-
config: params.config,
|
|
2369
|
-
workspaceDir: resolvedWorkspace,
|
|
2370
|
-
agentDir,
|
|
2371
|
-
agentId: workspaceResolution.agentId,
|
|
2372
|
-
thinkingLevel: thinkLevel,
|
|
2373
|
-
extraParamsOverride: {
|
|
2374
|
-
...params.streamParams,
|
|
2375
|
-
fastMode: params.fastMode
|
|
2376
|
-
}
|
|
2377
|
-
});
|
|
2378
|
-
if (!startupStagesEmitted) {
|
|
2379
|
-
startupStages.mark(EMBEDDED_RUN_ATTEMPT_DISPATCH_STAGE.runtimePlan);
|
|
2380
|
-
startupStages.mark(EMBEDDED_RUN_ATTEMPT_DISPATCH_STAGE.dispatch);
|
|
2381
|
-
notifyExecutionPhase("attempt_dispatch", {
|
|
2382
|
-
provider,
|
|
2383
|
-
model: modelId
|
|
2384
|
-
});
|
|
2385
|
-
emitStartupStageSummary(EMBEDDED_RUN_ATTEMPT_DISPATCH_STAGE.dispatch);
|
|
2386
|
-
startupStagesEmitted = true;
|
|
2387
|
-
}
|
|
2388
|
-
const attemptAbortController = new AbortController();
|
|
2389
|
-
postCompactionAbortController = attemptAbortController;
|
|
2390
|
-
const parentAbortSignal = params.abortSignal;
|
|
2391
|
-
const relayParentAbort = () => {
|
|
2392
|
-
attemptAbortController.abort(parentAbortSignal?.reason);
|
|
2393
|
-
};
|
|
2394
|
-
if (parentAbortSignal?.aborted) relayParentAbort();
|
|
2395
|
-
else parentAbortSignal?.addEventListener("abort", relayParentAbort, { once: true });
|
|
2396
|
-
const rawAttempt = await runEmbeddedAttemptWithBackend({
|
|
2397
|
-
sessionId: activeSessionId,
|
|
2398
|
-
sessionKey: resolvedSessionKey,
|
|
2399
|
-
sandboxSessionKey: params.sandboxSessionKey,
|
|
2400
|
-
trigger: params.trigger,
|
|
2401
|
-
memoryFlushWritePath: params.memoryFlushWritePath,
|
|
2402
|
-
messageChannel: params.messageChannel,
|
|
2403
|
-
messageProvider: params.messageProvider,
|
|
2404
|
-
agentAccountId: params.agentAccountId,
|
|
2405
|
-
messageTo: params.messageTo,
|
|
2406
|
-
messageThreadId: params.messageThreadId,
|
|
2407
|
-
groupId: params.groupId,
|
|
2408
|
-
groupChannel: params.groupChannel,
|
|
2409
|
-
groupSpace: params.groupSpace,
|
|
2410
|
-
memberRoleIds: params.memberRoleIds,
|
|
2411
|
-
spawnedBy: params.spawnedBy,
|
|
2412
|
-
isCanonicalWorkspace,
|
|
2413
|
-
senderId: params.senderId,
|
|
2414
|
-
senderName: params.senderName,
|
|
2415
|
-
senderUsername: params.senderUsername,
|
|
2416
|
-
senderE164: params.senderE164,
|
|
2417
|
-
currentChannelId: params.currentChannelId,
|
|
2418
|
-
currentThreadTs: params.currentThreadTs,
|
|
2419
|
-
currentMessageId: params.currentMessageId,
|
|
2420
|
-
replyToMode: params.replyToMode,
|
|
2421
|
-
hasRepliedRef: params.hasRepliedRef,
|
|
2422
|
-
sessionFile: activeSessionFile,
|
|
2423
|
-
workspaceDir: resolvedWorkspace,
|
|
2424
|
-
agentDir,
|
|
2425
|
-
config: params.config,
|
|
2426
|
-
allowGatewaySubagentBinding: params.allowGatewaySubagentBinding,
|
|
2427
|
-
contextEngine,
|
|
2428
|
-
contextTokenBudget: ctxInfo.tokens,
|
|
2429
|
-
contextWindowInfo: ctxInfo,
|
|
2430
|
-
skillsSnapshot: params.skillsSnapshot,
|
|
2431
|
-
prompt,
|
|
2432
|
-
transcriptPrompt: params.transcriptPrompt,
|
|
2433
|
-
currentInboundEventKind: params.currentInboundEventKind,
|
|
2434
|
-
currentInboundContext: params.currentInboundContext,
|
|
2435
|
-
images: params.images,
|
|
2436
|
-
imageOrder: params.imageOrder,
|
|
2437
|
-
clientTools: params.clientTools,
|
|
2438
|
-
disableTools: params.disableTools,
|
|
2439
|
-
provider,
|
|
2440
|
-
modelId,
|
|
2441
|
-
agentHarnessId: agentHarness.id,
|
|
2442
|
-
...params.sessionKey ? { agentHarnessTaskRuntimeScope: createAgentHarnessTaskRuntimeScope({ requesterSessionKey: params.sessionKey }) } : {},
|
|
2443
|
-
runtimePlan,
|
|
2444
|
-
model: applyAuthHeaderOverride(applyLocalNoAuthHeaderOverride(effectiveModel, apiKeyInfo), runtimeAuthState ? null : apiKeyInfo, params.config),
|
|
2445
|
-
resolvedApiKey: resolvedStreamApiKey,
|
|
2446
|
-
authProfileId: lastProfileId,
|
|
2447
|
-
authProfileIdSource: lockedProfileId ? "user" : "auto",
|
|
2448
|
-
initialReplayState: accumulatedReplayState,
|
|
2449
|
-
authStorage,
|
|
2450
|
-
authProfileStore: runAttemptAuthProfileStore,
|
|
2451
|
-
toolAuthProfileStore: agentHarness.id === "codex" ? attemptAuthProfileStore : void 0,
|
|
2452
|
-
modelRegistry,
|
|
2453
|
-
agentId: workspaceResolution.agentId,
|
|
2454
|
-
legacyBeforeAgentStartResult,
|
|
2455
|
-
thinkLevel,
|
|
2456
|
-
onToolOutcome: observePostCompactionToolOutcome,
|
|
2457
|
-
onRunProgress: notifyRunProgress,
|
|
2458
|
-
fastMode: params.fastMode,
|
|
2459
|
-
verboseLevel: params.verboseLevel,
|
|
2460
|
-
reasoningLevel: params.reasoningLevel,
|
|
2461
|
-
toolResultFormat: resolvedToolResultFormat,
|
|
2462
|
-
toolProgressDetail: params.toolProgressDetail,
|
|
2463
|
-
execOverrides: params.execOverrides,
|
|
2464
|
-
bashElevated: params.bashElevated,
|
|
2465
|
-
timeoutMs: params.timeoutMs,
|
|
2466
|
-
runTimeoutOverrideMs: params.runTimeoutOverrideMs,
|
|
2467
|
-
runId: params.runId,
|
|
2468
|
-
abortSignal: attemptAbortController.signal,
|
|
2469
|
-
replyOperation: params.replyOperation,
|
|
2470
|
-
shouldEmitToolResult: params.shouldEmitToolResult,
|
|
2471
|
-
shouldEmitToolOutput: params.shouldEmitToolOutput,
|
|
2472
|
-
onPartialReply: params.onPartialReply,
|
|
2473
|
-
onAssistantMessageStart: params.onAssistantMessageStart,
|
|
2474
|
-
onBlockReply: params.onBlockReply,
|
|
2475
|
-
onBlockReplyFlush: params.onBlockReplyFlush,
|
|
2476
|
-
blockReplyBreak: params.blockReplyBreak,
|
|
2477
|
-
blockReplyChunking: params.blockReplyChunking,
|
|
2478
|
-
onReasoningStream: params.onReasoningStream,
|
|
2479
|
-
onReasoningEnd: params.onReasoningEnd,
|
|
2480
|
-
onToolResult: params.onToolResult,
|
|
2481
|
-
onAgentEvent: params.onAgentEvent,
|
|
2482
|
-
onExecutionPhase: params.onExecutionPhase,
|
|
2483
|
-
extraSystemPrompt: params.extraSystemPrompt,
|
|
2484
|
-
sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
|
|
2485
|
-
inputProvenance: params.inputProvenance,
|
|
2486
|
-
streamParams: params.streamParams,
|
|
2487
|
-
modelRun: params.modelRun,
|
|
2488
|
-
promptMode: params.promptMode,
|
|
2489
|
-
ownerNumbers: params.ownerNumbers,
|
|
2490
|
-
enforceFinalTag: params.enforceFinalTag,
|
|
2491
|
-
silentExpected: params.silentExpected,
|
|
2492
|
-
bootstrapContextMode: params.bootstrapContextMode,
|
|
2493
|
-
bootstrapContextRunKind: params.bootstrapContextRunKind,
|
|
2494
|
-
jobId: params.jobId,
|
|
2495
|
-
toolsAllow: params.toolsAllow,
|
|
2496
|
-
disableMessageTool: params.disableMessageTool,
|
|
2497
|
-
forceMessageTool: params.forceMessageTool,
|
|
2498
|
-
enableHeartbeatTool: params.enableHeartbeatTool,
|
|
2499
|
-
forceHeartbeatTool: params.forceHeartbeatTool,
|
|
2500
|
-
requireExplicitMessageTarget: params.requireExplicitMessageTarget,
|
|
2501
|
-
internalEvents: params.internalEvents,
|
|
2502
|
-
bootstrapPromptWarningSignaturesSeen,
|
|
2503
|
-
bootstrapPromptWarningSignature: bootstrapPromptWarningSignaturesSeen[bootstrapPromptWarningSignaturesSeen.length - 1],
|
|
2504
|
-
suppressNextUserMessagePersistence,
|
|
2505
|
-
suppressTranscriptOnlyAssistantPersistence: params.suppressTranscriptOnlyAssistantPersistence,
|
|
2506
|
-
suppressAssistantErrorPersistence: params.suppressAssistantErrorPersistence,
|
|
2507
|
-
onUserMessagePersisted,
|
|
2508
|
-
onAssistantErrorMessagePersisted: params.onAssistantErrorMessagePersisted
|
|
2509
|
-
}).catch((err) => {
|
|
2510
|
-
throw postCompactionAbortError ?? err;
|
|
2511
|
-
}).finally(() => {
|
|
2512
|
-
parentAbortSignal?.removeEventListener?.("abort", relayParentAbort);
|
|
2513
|
-
if (postCompactionAbortController === attemptAbortController) postCompactionAbortController = void 0;
|
|
2514
|
-
});
|
|
2515
|
-
if (postCompactionAbortError) throw postCompactionAbortError;
|
|
2516
|
-
const attempt = normalizeEmbeddedRunAttemptResult(rawAttempt);
|
|
2517
|
-
const { aborted, externalAbort, promptError, promptErrorSource, preflightRecovery, timedOut, idleTimedOut, timedOutDuringCompaction, sessionIdUsed, sessionFileUsed, lastAssistant: sessionLastAssistant, currentAttemptAssistant } = attempt;
|
|
2518
|
-
const timedOutDuringToolExecution = attempt.timedOutDuringToolExecution ?? false;
|
|
2519
|
-
if (sessionIdUsed && sessionIdUsed !== activeSessionId) activeSessionId = sessionIdUsed;
|
|
2520
|
-
if (sessionFileUsed && sessionFileUsed !== activeSessionFile) activeSessionFile = sessionFileUsed;
|
|
2521
|
-
bootstrapPromptWarningSignaturesSeen = attempt.bootstrapPromptWarningSignaturesSeen ?? (attempt.bootstrapPromptWarningSignature ? Array.from(new Set([...bootstrapPromptWarningSignaturesSeen, attempt.bootstrapPromptWarningSignature])) : bootstrapPromptWarningSignaturesSeen);
|
|
2522
|
-
const lastAssistantUsage = normalizeUsage(sessionLastAssistant?.usage);
|
|
2523
|
-
const attemptUsage = attempt.attemptUsage ?? lastAssistantUsage;
|
|
2524
|
-
mergeUsageIntoAccumulator(usageAccumulator, attemptUsage);
|
|
2525
|
-
lastRunPromptUsage = lastAssistantUsage ?? attemptUsage;
|
|
2526
|
-
lastTurnTotal = lastAssistantUsage?.total ?? attemptUsage?.total;
|
|
2527
|
-
const breakerStep = stepIdleTimeoutBreaker(idleTimeoutBreakerState, {
|
|
2528
|
-
idleTimedOut,
|
|
2529
|
-
completedModelProgress: hasCompletedModelProgressForIdleBreaker(attempt),
|
|
2530
|
-
outputTokens: attemptUsage?.output
|
|
2531
|
-
});
|
|
2532
|
-
if (breakerStep.tripped) {
|
|
2533
|
-
const breakerMessage = `Idle-timeout cost-runaway breaker tripped: ${breakerStep.consecutive} consecutive idle timeouts without completed model progress (cap=5). Halting further attempts to bound paid model calls. See issue #76293.`;
|
|
2534
|
-
log$1.error(`[idle-timeout-circuit-breaker-tripped] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} consecutive=${breakerStep.consecutive} cap=5`);
|
|
2535
|
-
return handleRetryLimitExhaustion({
|
|
2536
|
-
message: breakerMessage,
|
|
2537
|
-
decision: resolveRunFailoverDecision({
|
|
2538
|
-
stage: "retry_limit",
|
|
2539
|
-
fallbackConfigured,
|
|
2540
|
-
failoverReason: lastRetryFailoverReason
|
|
2541
|
-
}),
|
|
2542
|
-
provider,
|
|
2543
|
-
model: modelId,
|
|
2544
|
-
profileId: lastProfileId,
|
|
2545
|
-
durationMs: Date.now() - started,
|
|
2546
|
-
agentMeta: buildErrorAgentMeta({
|
|
2547
|
-
sessionId: activeSessionId,
|
|
2548
|
-
sessionFile: activeSessionFile,
|
|
2549
|
-
provider,
|
|
2550
|
-
model: model.id,
|
|
2551
|
-
contextTokens: ctxInfo.tokens,
|
|
2552
|
-
usageAccumulator,
|
|
2553
|
-
lastRunPromptUsage,
|
|
2554
|
-
lastTurnTotal
|
|
2555
|
-
}),
|
|
2556
|
-
replayInvalid: accumulatedReplayState.replayInvalid ? true : void 0,
|
|
2557
|
-
livenessState: "blocked"
|
|
2558
|
-
});
|
|
2559
|
-
}
|
|
2560
|
-
const attemptCompactionCount = Math.max(0, attempt.compactionCount ?? 0);
|
|
2561
|
-
autoCompactionCount += attemptCompactionCount;
|
|
2562
|
-
if (typeof attempt.compactionTokensAfter === "number" && Number.isFinite(attempt.compactionTokensAfter) && attempt.compactionTokensAfter >= 0) lastCompactionTokensAfter = Math.floor(attempt.compactionTokensAfter);
|
|
2563
|
-
const activeErrorContext = resolveActiveErrorContext({
|
|
2564
|
-
provider,
|
|
2565
|
-
model: modelId,
|
|
2566
|
-
assistant: currentAttemptAssistant ?? sessionLastAssistant
|
|
2567
|
-
});
|
|
2568
|
-
const resolveReplayInvalidForAttempt = (incompleteTurnText) => accumulatedReplayState.replayInvalid || resolveReplayInvalidFlag({
|
|
2569
|
-
attempt,
|
|
2570
|
-
incompleteTurnText
|
|
2571
|
-
});
|
|
2572
|
-
if (resolveReplayInvalidForAttempt(null)) accumulatedReplayState.replayInvalid = true;
|
|
2573
|
-
accumulatedReplayState = observeReplayMetadata(accumulatedReplayState, attempt.replayMetadata);
|
|
2574
|
-
const formattedAssistantErrorText = sessionLastAssistant ? formatAssistantErrorText(sessionLastAssistant, {
|
|
2575
|
-
cfg: params.config,
|
|
2576
|
-
sessionKey: resolvedSessionKey ?? params.sessionId,
|
|
2577
|
-
provider: activeErrorContext.provider,
|
|
2578
|
-
model: activeErrorContext.model
|
|
2579
|
-
}) : void 0;
|
|
2580
|
-
const assistantErrorText = sessionLastAssistant?.stopReason === "error" ? sessionLastAssistant.errorMessage?.trim() || formattedAssistantErrorText : void 0;
|
|
2581
|
-
const canRestartForLiveSwitch = !hasOutboundDeliveryEvidence(attempt) && !attempt.didSendDeterministicApprovalPrompt && !attempt.lastToolError && (attempt.toolMetas?.length ?? 0) === 0 && (attempt.assistantTexts?.length ?? 0) === 0;
|
|
2582
|
-
if (preflightRecovery?.handled) {
|
|
2583
|
-
const retryingFromTranscript = preflightRecovery.source === "mid-turn";
|
|
2584
|
-
log$1.info(`[context-overflow-precheck] early recovery route=${preflightRecovery.route} completed for ${provider}/${modelId}; ` + (retryingFromTranscript ? "retrying from current transcript" : "retrying prompt"));
|
|
2585
|
-
if (retryingFromTranscript) continueFromCurrentTranscript();
|
|
2586
|
-
continue;
|
|
2587
|
-
}
|
|
2588
|
-
const requestedSelection = shouldSwitchToLiveModel({
|
|
2589
|
-
cfg: params.config,
|
|
2590
|
-
sessionKey: resolvedSessionKey,
|
|
2591
|
-
agentId: params.agentId,
|
|
2592
|
-
defaultProvider: DEFAULT_PROVIDER,
|
|
2593
|
-
defaultModel: DEFAULT_MODEL,
|
|
2594
|
-
currentProvider: provider,
|
|
2595
|
-
currentModel: modelId,
|
|
2596
|
-
currentAuthProfileId: preferredProfileId,
|
|
2597
|
-
currentAuthProfileIdSource: params.authProfileIdSource
|
|
2598
|
-
});
|
|
2599
|
-
if (requestedSelection && canRestartForLiveSwitch) {
|
|
2600
|
-
await clearLiveModelSwitchPending({
|
|
2601
|
-
cfg: params.config,
|
|
2602
|
-
sessionKey: resolvedSessionKey,
|
|
2603
|
-
agentId: params.agentId
|
|
2604
|
-
});
|
|
2605
|
-
log$1.info(`live session model switch requested during active attempt for ${params.sessionId}: ${provider}/${modelId} -> ${requestedSelection.provider}/${requestedSelection.model}`);
|
|
2606
|
-
throw new LiveSessionModelSwitchError(requestedSelection);
|
|
2607
|
-
}
|
|
2608
|
-
if (timedOut && !timedOutDuringCompaction && !timedOutDuringToolExecution) {
|
|
2609
|
-
const lastTurnPromptTokens = derivePromptTokens(lastRunPromptUsage);
|
|
2610
|
-
const tokenUsedRatio = lastTurnPromptTokens != null && ctxInfo.tokens > 0 ? lastTurnPromptTokens / ctxInfo.tokens : 0;
|
|
2611
|
-
if (timeoutCompactionAttempts >= MAX_TIMEOUT_COMPACTION_ATTEMPTS) log$1.warn(`[timeout-compaction] already attempted timeout compaction ${timeoutCompactionAttempts} time(s); falling through to failover rotation`);
|
|
2612
|
-
else if (tokenUsedRatio > .65) {
|
|
2613
|
-
const timeoutDiagId = createCompactionDiagId();
|
|
2614
|
-
timeoutCompactionAttempts++;
|
|
2615
|
-
log$1.warn(`[timeout-compaction] LLM timed out with high prompt token usage (${Math.round(tokenUsedRatio * 100)}%); attempting compaction before retry (attempt ${timeoutCompactionAttempts}/${MAX_TIMEOUT_COMPACTION_ATTEMPTS}) diagId=${timeoutDiagId}`);
|
|
2616
|
-
let timeoutCompactResult;
|
|
2617
|
-
await runOwnsCompactionBeforeHook("timeout recovery");
|
|
2618
|
-
try {
|
|
2619
|
-
const timeoutCompactionRuntimeContext = {
|
|
2620
|
-
...buildEmbeddedCompactionRuntimeContext({
|
|
2621
|
-
sessionKey: params.sessionKey,
|
|
2622
|
-
messageChannel: params.messageChannel,
|
|
2623
|
-
messageProvider: params.messageProvider,
|
|
2624
|
-
agentAccountId: params.agentAccountId,
|
|
2625
|
-
currentChannelId: params.currentChannelId,
|
|
2626
|
-
currentThreadTs: params.currentThreadTs,
|
|
2627
|
-
currentMessageId: params.currentMessageId,
|
|
2628
|
-
authProfileId: lastProfileId,
|
|
2629
|
-
workspaceDir: resolvedWorkspace,
|
|
2630
|
-
agentDir,
|
|
2631
|
-
config: params.config,
|
|
2632
|
-
skillsSnapshot: params.skillsSnapshot,
|
|
2633
|
-
senderId: params.senderId,
|
|
2634
|
-
provider,
|
|
2635
|
-
modelId,
|
|
2636
|
-
modelFallbacksOverride: params.modelFallbacksOverride,
|
|
2637
|
-
thinkLevel,
|
|
2638
|
-
reasoningLevel: params.reasoningLevel,
|
|
2639
|
-
bashElevated: params.bashElevated,
|
|
2640
|
-
extraSystemPrompt: params.extraSystemPrompt,
|
|
2641
|
-
sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
|
|
2642
|
-
ownerNumbers: params.ownerNumbers,
|
|
2643
|
-
activeProcessSessions: listActiveProcessSessionReferences({ scopeKey: resolveProcessToolScopeKey({
|
|
2644
|
-
sessionKey: params.sandboxSessionKey?.trim() || params.sessionKey,
|
|
2645
|
-
sessionId: activeSessionId,
|
|
2646
|
-
agentId: sessionAgentId
|
|
2647
|
-
}) })
|
|
2648
|
-
}),
|
|
2649
|
-
...resolveContextEngineCapabilities({
|
|
2650
|
-
config: params.config,
|
|
2651
|
-
sessionKey: params.sessionKey,
|
|
2652
|
-
agentId: sessionAgentId,
|
|
2653
|
-
contextEnginePluginId,
|
|
2654
|
-
purpose: "context-engine.timeout-compaction"
|
|
2655
|
-
}),
|
|
2656
|
-
onCompactionHookMessages,
|
|
2657
|
-
...attempt.promptCache ? { promptCache: attempt.promptCache } : {},
|
|
2658
|
-
runId: params.runId,
|
|
2659
|
-
trigger: "timeout_recovery",
|
|
2660
|
-
diagId: timeoutDiagId,
|
|
2661
|
-
attempt: timeoutCompactionAttempts,
|
|
2662
|
-
maxAttempts: MAX_TIMEOUT_COMPACTION_ATTEMPTS
|
|
2663
|
-
};
|
|
2664
|
-
timeoutCompactResult = await compactContextEngineWithSafetyTimeout(contextEngine, {
|
|
2665
|
-
sessionId: activeSessionId,
|
|
2666
|
-
sessionKey: params.sessionKey,
|
|
2667
|
-
sessionFile: activeSessionFile,
|
|
2668
|
-
tokenBudget: ctxInfo.tokens,
|
|
2669
|
-
force: true,
|
|
2670
|
-
compactionTarget: "budget",
|
|
2671
|
-
runtimeContext: timeoutCompactionRuntimeContext
|
|
2672
|
-
}, resolveCompactionTimeoutMs(params.config), params.abortSignal);
|
|
2673
|
-
} catch (compactErr) {
|
|
2674
|
-
log$1.warn(`[timeout-compaction] contextEngine.compact() threw during timeout recovery for ${provider}/${modelId}: ${String(compactErr)}`);
|
|
2675
|
-
timeoutCompactResult = {
|
|
2676
|
-
ok: false,
|
|
2677
|
-
compacted: false,
|
|
2678
|
-
reason: String(compactErr)
|
|
2679
|
-
};
|
|
2680
|
-
}
|
|
2681
|
-
if (timeoutCompactResult.compacted) adoptCompactionTranscript(timeoutCompactResult);
|
|
2682
|
-
await runOwnsCompactionAfterHook("timeout recovery", timeoutCompactResult);
|
|
2683
|
-
if (timeoutCompactResult.compacted) {
|
|
2684
|
-
autoCompactionCount += 1;
|
|
2685
|
-
if (typeof timeoutCompactResult.result?.tokensAfter === "number" && Number.isFinite(timeoutCompactResult.result.tokensAfter) && timeoutCompactResult.result.tokensAfter >= 0) lastCompactionTokensAfter = Math.floor(timeoutCompactResult.result.tokensAfter);
|
|
2686
|
-
if (contextEngine.info.ownsCompaction === true) await runPostCompactionSideEffects({
|
|
2687
|
-
config: params.config,
|
|
2688
|
-
sessionKey: params.sessionKey,
|
|
2689
|
-
sessionFile: activeSessionFile
|
|
2690
|
-
});
|
|
2691
|
-
log$1.info(`[timeout-compaction] compaction succeeded for ${provider}/${modelId}; retrying prompt`);
|
|
2692
|
-
postCompactionGuard.armPostCompaction();
|
|
2693
|
-
continue;
|
|
2694
|
-
} else log$1.warn(`[timeout-compaction] compaction did not reduce context for ${provider}/${modelId}; falling through to normal handling`);
|
|
2695
|
-
}
|
|
2696
|
-
}
|
|
2697
|
-
const contextOverflowError = !aborted ? (() => {
|
|
2698
|
-
if (promptError) {
|
|
2699
|
-
const errorText = formatErrorMessage(promptError);
|
|
2700
|
-
if (isLikelyContextOverflowError(errorText)) return {
|
|
2701
|
-
text: errorText,
|
|
2702
|
-
source: "promptError"
|
|
2703
|
-
};
|
|
2704
|
-
return null;
|
|
2705
|
-
}
|
|
2706
|
-
if (assistantErrorText && isLikelyContextOverflowError(assistantErrorText)) return {
|
|
2707
|
-
text: assistantErrorText,
|
|
2708
|
-
source: "assistantError"
|
|
2709
|
-
};
|
|
2710
|
-
return null;
|
|
2711
|
-
})() : null;
|
|
2712
|
-
if (contextOverflowError) {
|
|
2713
|
-
const overflowDiagId = createCompactionDiagId();
|
|
2714
|
-
const errorText = contextOverflowError.text;
|
|
2715
|
-
const msgCount = attempt.messagesSnapshot?.length ?? 0;
|
|
2716
|
-
const observedOverflowTokens = extractObservedOverflowTokenCount(errorText);
|
|
2717
|
-
log$1.warn(`[context-overflow-diag] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} source=${contextOverflowError.source} messages=${msgCount} sessionFile=${activeSessionFile} diagId=${overflowDiagId} compactionAttempts=${overflowCompactionAttempts} observedTokens=${observedOverflowTokens ?? "unknown"} error=${errorText.slice(0, 200)}`);
|
|
2718
|
-
const isCompactionFailure = isCompactionFailureError(errorText);
|
|
2719
|
-
const hadAttemptLevelCompaction = attemptCompactionCount > 0;
|
|
2720
|
-
if (!isCompactionFailure && hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
2721
|
-
overflowCompactionAttempts++;
|
|
2722
|
-
log$1.warn(`context overflow persisted after in-attempt compaction (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); retrying prompt without additional compaction for ${provider}/${modelId}`);
|
|
2723
|
-
if (preflightRecovery?.source === "mid-turn") continueFromCurrentTranscript();
|
|
2724
|
-
continue;
|
|
2725
|
-
}
|
|
2726
|
-
if (!isCompactionFailure && !hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
2727
|
-
if (log$1.isEnabled("debug")) log$1.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=compact isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts + 1} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
2728
|
-
overflowCompactionAttempts++;
|
|
2729
|
-
log$1.warn(`context overflow detected (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); attempting auto-compaction for ${provider}/${modelId}`);
|
|
2730
|
-
let compactResult;
|
|
2731
|
-
await runOwnsCompactionBeforeHook("overflow recovery");
|
|
2732
|
-
try {
|
|
2733
|
-
const overflowCompactionRuntimeContext = {
|
|
2734
|
-
...buildEmbeddedCompactionRuntimeContext({
|
|
2735
|
-
sessionKey: params.sessionKey,
|
|
2736
|
-
messageChannel: params.messageChannel,
|
|
2737
|
-
messageProvider: params.messageProvider,
|
|
2738
|
-
agentAccountId: params.agentAccountId,
|
|
2739
|
-
currentChannelId: params.currentChannelId,
|
|
2740
|
-
currentThreadTs: params.currentThreadTs,
|
|
2741
|
-
currentMessageId: params.currentMessageId,
|
|
2742
|
-
authProfileId: lastProfileId,
|
|
2743
|
-
workspaceDir: resolvedWorkspace,
|
|
2744
|
-
agentDir,
|
|
2745
|
-
config: params.config,
|
|
2746
|
-
skillsSnapshot: params.skillsSnapshot,
|
|
2747
|
-
senderId: params.senderId,
|
|
2748
|
-
provider,
|
|
2749
|
-
modelId,
|
|
2750
|
-
thinkLevel,
|
|
2751
|
-
reasoningLevel: params.reasoningLevel,
|
|
2752
|
-
bashElevated: params.bashElevated,
|
|
2753
|
-
extraSystemPrompt: params.extraSystemPrompt,
|
|
2754
|
-
sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
|
|
2755
|
-
ownerNumbers: params.ownerNumbers,
|
|
2756
|
-
activeProcessSessions: listActiveProcessSessionReferences({ scopeKey: resolveProcessToolScopeKey({
|
|
2757
|
-
sessionKey: params.sandboxSessionKey?.trim() || params.sessionKey,
|
|
2758
|
-
sessionId: activeSessionId,
|
|
2759
|
-
agentId: sessionAgentId
|
|
2760
|
-
}) })
|
|
2761
|
-
}),
|
|
2762
|
-
...resolveContextEngineCapabilities({
|
|
2763
|
-
config: params.config,
|
|
2764
|
-
sessionKey: params.sessionKey,
|
|
2765
|
-
agentId: sessionAgentId,
|
|
2766
|
-
contextEnginePluginId,
|
|
2767
|
-
purpose: "context-engine.overflow-compaction"
|
|
2768
|
-
}),
|
|
2769
|
-
onCompactionHookMessages,
|
|
2770
|
-
...attempt.promptCache ? { promptCache: attempt.promptCache } : {},
|
|
2771
|
-
runId: params.runId,
|
|
2772
|
-
trigger: "overflow",
|
|
2773
|
-
...observedOverflowTokens !== void 0 ? { currentTokenCount: observedOverflowTokens } : {},
|
|
2774
|
-
diagId: overflowDiagId,
|
|
2775
|
-
attempt: overflowCompactionAttempts,
|
|
2776
|
-
maxAttempts: MAX_OVERFLOW_COMPACTION_ATTEMPTS
|
|
2777
|
-
};
|
|
2778
|
-
compactResult = await compactContextEngineWithSafetyTimeout(contextEngine, {
|
|
2779
|
-
sessionId: activeSessionId,
|
|
2780
|
-
sessionKey: params.sessionKey,
|
|
2781
|
-
sessionFile: activeSessionFile,
|
|
2782
|
-
tokenBudget: ctxInfo.tokens,
|
|
2783
|
-
...observedOverflowTokens !== void 0 ? { currentTokenCount: observedOverflowTokens } : {},
|
|
2784
|
-
force: true,
|
|
2785
|
-
compactionTarget: "budget",
|
|
2786
|
-
runtimeContext: overflowCompactionRuntimeContext
|
|
2787
|
-
}, resolveCompactionTimeoutMs(params.config), params.abortSignal);
|
|
2788
|
-
if (compactResult.ok && compactResult.compacted) {
|
|
2789
|
-
adoptCompactionTranscript(compactResult);
|
|
2790
|
-
await runContextEngineMaintenance({
|
|
2791
|
-
contextEngine,
|
|
2792
|
-
sessionId: activeSessionId,
|
|
2793
|
-
sessionKey: params.sessionKey,
|
|
2794
|
-
sessionFile: activeSessionFile,
|
|
2795
|
-
reason: "compaction",
|
|
2796
|
-
runtimeContext: overflowCompactionRuntimeContext,
|
|
2797
|
-
config: params.config,
|
|
2798
|
-
agentId: sessionAgentId
|
|
2799
|
-
});
|
|
2800
|
-
}
|
|
2801
|
-
} catch (compactErr) {
|
|
2802
|
-
log$1.warn(`contextEngine.compact() threw during overflow recovery for ${provider}/${modelId}: ${String(compactErr)}`);
|
|
2803
|
-
compactResult = {
|
|
2804
|
-
ok: false,
|
|
2805
|
-
compacted: false,
|
|
2806
|
-
reason: String(compactErr)
|
|
2807
|
-
};
|
|
2808
|
-
}
|
|
2809
|
-
await runOwnsCompactionAfterHook("overflow recovery", compactResult);
|
|
2810
|
-
if (compactResult.compacted) {
|
|
2811
|
-
adoptCompactionTranscript(compactResult);
|
|
2812
|
-
if (typeof compactResult.result?.tokensAfter === "number" && Number.isFinite(compactResult.result.tokensAfter) && compactResult.result.tokensAfter >= 0) lastCompactionTokensAfter = Math.floor(compactResult.result.tokensAfter);
|
|
2813
|
-
if (preflightRecovery?.route === "compact_then_truncate") {
|
|
2814
|
-
const truncResult = await truncateOversizedToolResultsInSession({
|
|
2815
|
-
sessionFile: activeSessionFile,
|
|
2816
|
-
contextWindowTokens: ctxInfo.tokens,
|
|
2817
|
-
maxCharsOverride: resolveLiveToolResultMaxChars({
|
|
2818
|
-
contextWindowTokens: ctxInfo.tokens,
|
|
2819
|
-
cfg: params.config,
|
|
2820
|
-
agentId: sessionAgentId
|
|
2821
|
-
}),
|
|
2822
|
-
sessionId: activeSessionId,
|
|
2823
|
-
sessionKey: params.sessionKey,
|
|
2824
|
-
config: params.config
|
|
2825
|
-
});
|
|
2826
|
-
if (truncResult.truncated) log$1.info(`[context-overflow-precheck] post-compaction tool-result truncation succeeded for ${provider}/${modelId}; truncated ${truncResult.truncatedCount} tool result(s)`);
|
|
2827
|
-
else log$1.warn(`[context-overflow-precheck] post-compaction tool-result truncation did not help for ${provider}/${modelId}: ${truncResult.reason ?? "unknown"}`);
|
|
2828
|
-
}
|
|
2829
|
-
autoCompactionCount += 1;
|
|
2830
|
-
log$1.info(`auto-compaction succeeded for ${provider}/${modelId}; retrying prompt`);
|
|
2831
|
-
postCompactionGuard.armPostCompaction();
|
|
2832
|
-
if (preflightRecovery?.source === "mid-turn") continueFromCurrentTranscript();
|
|
2833
|
-
else if (params.currentMessageId !== void 0 && params.currentMessageId === lastPersistedCurrentMessageId) {
|
|
2834
|
-
nextAttemptPromptOverride = MID_TURN_PRECHECK_CONTINUATION_PROMPT;
|
|
2835
|
-
suppressNextUserMessagePersistence = true;
|
|
2836
|
-
}
|
|
2837
|
-
continue;
|
|
2838
|
-
}
|
|
2839
|
-
log$1.warn(`auto-compaction failed for ${provider}/${modelId}: ${compactResult.reason ?? "nothing to compact"}`);
|
|
2840
|
-
}
|
|
2841
|
-
if (!toolResultTruncationAttempted) {
|
|
2842
|
-
const contextWindowTokens = ctxInfo.tokens;
|
|
2843
|
-
const toolResultMaxChars = resolveLiveToolResultMaxChars({
|
|
2844
|
-
contextWindowTokens,
|
|
2845
|
-
cfg: params.config,
|
|
2846
|
-
agentId: sessionAgentId
|
|
2847
|
-
});
|
|
2848
|
-
if (attempt.messagesSnapshot ? sessionLikelyHasOversizedToolResults({
|
|
2849
|
-
messages: attempt.messagesSnapshot,
|
|
2850
|
-
contextWindowTokens,
|
|
2851
|
-
maxCharsOverride: toolResultMaxChars
|
|
2852
|
-
}) : false) {
|
|
2853
|
-
toolResultTruncationAttempted = true;
|
|
2854
|
-
log$1.warn(`[context-overflow-recovery] Attempting tool result truncation for ${provider}/${modelId} (contextWindow=${contextWindowTokens} tokens)`);
|
|
2855
|
-
const truncResult = await truncateOversizedToolResultsInSession({
|
|
2856
|
-
sessionFile: activeSessionFile,
|
|
2857
|
-
contextWindowTokens,
|
|
2858
|
-
maxCharsOverride: toolResultMaxChars,
|
|
2859
|
-
sessionId: activeSessionId,
|
|
2860
|
-
sessionKey: params.sessionKey,
|
|
2861
|
-
config: params.config
|
|
2862
|
-
});
|
|
2863
|
-
if (truncResult.truncated) {
|
|
2864
|
-
log$1.info(`[context-overflow-recovery] Truncated ${truncResult.truncatedCount} tool result(s); retrying prompt`);
|
|
2865
|
-
if (preflightRecovery?.source === "mid-turn") continueFromCurrentTranscript();
|
|
2866
|
-
continue;
|
|
2867
|
-
}
|
|
2868
|
-
log$1.warn(`[context-overflow-recovery] Tool result truncation did not help: ${truncResult.reason ?? "unknown"}`);
|
|
2869
|
-
}
|
|
2870
|
-
}
|
|
2871
|
-
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS) && log$1.isEnabled("debug")) log$1.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=give_up isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
2872
|
-
const kind = isCompactionFailure ? "compaction_failure" : "context_overflow";
|
|
2873
|
-
attempt.setTerminalLifecycleMeta?.({
|
|
2874
|
-
replayInvalid: resolveReplayInvalidForAttempt(),
|
|
2875
|
-
livenessState: "blocked"
|
|
2876
|
-
});
|
|
2877
|
-
return {
|
|
2878
|
-
payloads: [{
|
|
2879
|
-
text: "Context overflow: prompt too large for the model. Try /reset (or /new) to start a fresh session, or use a larger-context model.",
|
|
2880
|
-
isError: true
|
|
2881
|
-
}],
|
|
2882
|
-
meta: {
|
|
2883
|
-
durationMs: Date.now() - started,
|
|
2884
|
-
agentMeta: buildErrorAgentMeta({
|
|
2885
|
-
sessionId: sessionIdUsed,
|
|
2886
|
-
sessionFile: activeSessionFile,
|
|
2887
|
-
provider,
|
|
2888
|
-
model: model.id,
|
|
2889
|
-
contextTokens: ctxInfo.tokens,
|
|
2890
|
-
usageAccumulator,
|
|
2891
|
-
lastRunPromptUsage,
|
|
2892
|
-
lastAssistant: sessionLastAssistant,
|
|
2893
|
-
lastTurnTotal
|
|
2894
|
-
}),
|
|
2895
|
-
systemPromptReport: attempt.systemPromptReport,
|
|
2896
|
-
finalPromptText: attempt.finalPromptText,
|
|
2897
|
-
replayInvalid: resolveReplayInvalidForAttempt(),
|
|
2898
|
-
livenessState: "blocked",
|
|
2899
|
-
error: {
|
|
2900
|
-
kind,
|
|
2901
|
-
message: errorText
|
|
2902
|
-
}
|
|
2903
|
-
}
|
|
2904
|
-
};
|
|
2905
|
-
}
|
|
2906
|
-
if (promptErrorSource === "hook:before_agent_run" && !aborted) {
|
|
2907
|
-
const errorText = formatErrorMessage(promptError);
|
|
2908
|
-
const replayInvalid = resolveReplayInvalidForAttempt();
|
|
2909
|
-
attempt.setTerminalLifecycleMeta?.({
|
|
2910
|
-
replayInvalid,
|
|
2911
|
-
livenessState: "blocked"
|
|
2912
|
-
});
|
|
2913
|
-
return {
|
|
2914
|
-
payloads: [{
|
|
2915
|
-
text: errorText,
|
|
2916
|
-
isError: true
|
|
2917
|
-
}],
|
|
2918
|
-
meta: {
|
|
2919
|
-
durationMs: Date.now() - started,
|
|
2920
|
-
agentMeta: buildErrorAgentMeta({
|
|
2921
|
-
sessionId: sessionIdUsed,
|
|
2922
|
-
sessionFile: activeSessionFile,
|
|
2923
|
-
provider,
|
|
2924
|
-
model: model.id,
|
|
2925
|
-
contextTokens: ctxInfo.tokens,
|
|
2926
|
-
usageAccumulator,
|
|
2927
|
-
lastRunPromptUsage,
|
|
2928
|
-
lastAssistant: sessionLastAssistant,
|
|
2929
|
-
lastTurnTotal
|
|
2930
|
-
}),
|
|
2931
|
-
systemPromptReport: attempt.systemPromptReport,
|
|
2932
|
-
finalAssistantVisibleText: errorText,
|
|
2933
|
-
finalAssistantRawText: errorText,
|
|
2934
|
-
finalPromptText: void 0,
|
|
2935
|
-
replayInvalid,
|
|
2936
|
-
livenessState: "blocked",
|
|
2937
|
-
error: {
|
|
2938
|
-
kind: "hook_block",
|
|
2939
|
-
message: errorText
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2942
|
-
};
|
|
2943
|
-
}
|
|
2944
|
-
if (promptError && !aborted && promptErrorSource !== "compaction") {
|
|
2945
|
-
if (resolveCodexAppServerClientCloseRetry({
|
|
2946
|
-
attempt,
|
|
2947
|
-
alreadyRetried: codexAppServerClientCloseRetries > 0
|
|
2948
|
-
}).retry) {
|
|
2949
|
-
codexAppServerClientCloseRetries += 1;
|
|
2950
|
-
suppressNextUserMessagePersistence = true;
|
|
2951
|
-
log$1.warn(`codex app-server stdio client closed before turn completion; retrying once runId=${params.runId} sessionId=${params.sessionId}`);
|
|
2952
|
-
continue;
|
|
2953
|
-
}
|
|
2954
|
-
if (attempt.codexAppServerFailure) throw promptError;
|
|
2955
|
-
}
|
|
2956
|
-
if (promptError && !aborted && promptErrorSource !== "compaction") {
|
|
2957
|
-
const normalizedPromptFailover = coerceToFailoverError(promptError, {
|
|
2958
|
-
provider: activeErrorContext.provider,
|
|
2959
|
-
model: activeErrorContext.model,
|
|
2960
|
-
profileId: lastProfileId,
|
|
2961
|
-
sessionId: sessionIdUsed,
|
|
2962
|
-
lane: globalLane
|
|
2963
|
-
});
|
|
2964
|
-
const promptErrorDetails = normalizedPromptFailover ? describeFailoverError(normalizedPromptFailover) : describeFailoverError(promptError);
|
|
2965
|
-
if (normalizedPromptFailover?.suspend) suspendSession({
|
|
2966
|
-
cfg: params.config,
|
|
2967
|
-
agentDir,
|
|
2968
|
-
sessionId: activeSessionId ?? params.sessionId,
|
|
2969
|
-
laneId: globalLane,
|
|
2970
|
-
reason: resolveSessionSuspensionReason(normalizedPromptFailover.reason),
|
|
2971
|
-
failedProvider: normalizedPromptFailover.provider ?? provider,
|
|
2972
|
-
failedModel: normalizedPromptFailover.model ?? modelId
|
|
2973
|
-
});
|
|
2974
|
-
const errorText = promptErrorDetails.message || formatErrorMessage(promptError);
|
|
2975
|
-
if (await maybeRefreshRuntimeAuthForAuthError(errorText, runtimeAuthRetry)) {
|
|
2976
|
-
authRetryPending = true;
|
|
2977
|
-
continue;
|
|
2978
|
-
}
|
|
2979
|
-
if (/incorrect role information|roles must alternate/i.test(errorText)) {
|
|
2980
|
-
attempt.setTerminalLifecycleMeta?.({
|
|
2981
|
-
replayInvalid: resolveReplayInvalidForAttempt(),
|
|
2982
|
-
livenessState: "blocked"
|
|
2983
|
-
});
|
|
2984
|
-
return {
|
|
2985
|
-
payloads: [{
|
|
2986
|
-
text: "Message ordering conflict - please try again. If this persists, use /new to start a fresh session.",
|
|
2987
|
-
isError: true
|
|
2988
|
-
}],
|
|
2989
|
-
meta: {
|
|
2990
|
-
durationMs: Date.now() - started,
|
|
2991
|
-
agentMeta: buildErrorAgentMeta({
|
|
2992
|
-
sessionId: sessionIdUsed,
|
|
2993
|
-
sessionFile: activeSessionFile,
|
|
2994
|
-
provider,
|
|
2995
|
-
model: model.id,
|
|
2996
|
-
contextTokens: ctxInfo.tokens,
|
|
2997
|
-
usageAccumulator,
|
|
2998
|
-
lastRunPromptUsage,
|
|
2999
|
-
lastAssistant: sessionLastAssistant,
|
|
3000
|
-
lastTurnTotal
|
|
3001
|
-
}),
|
|
3002
|
-
systemPromptReport: attempt.systemPromptReport,
|
|
3003
|
-
finalPromptText: attempt.finalPromptText,
|
|
3004
|
-
replayInvalid: resolveReplayInvalidForAttempt(),
|
|
3005
|
-
livenessState: "blocked",
|
|
3006
|
-
error: {
|
|
3007
|
-
kind: "role_ordering",
|
|
3008
|
-
message: errorText
|
|
3009
|
-
}
|
|
3010
|
-
}
|
|
3011
|
-
};
|
|
3012
|
-
}
|
|
3013
|
-
const imageSizeError = parseImageSizeError(errorText);
|
|
3014
|
-
if (imageSizeError) {
|
|
3015
|
-
const maxMb = imageSizeError.maxMb;
|
|
3016
|
-
const maxMbLabel = typeof maxMb === "number" && Number.isFinite(maxMb) ? `${maxMb}` : null;
|
|
3017
|
-
const maxBytesHint = maxMbLabel ? ` (max ${maxMbLabel}MB)` : "";
|
|
3018
|
-
attempt.setTerminalLifecycleMeta?.({
|
|
3019
|
-
replayInvalid: resolveReplayInvalidForAttempt(),
|
|
3020
|
-
livenessState: "blocked"
|
|
3021
|
-
});
|
|
3022
|
-
return {
|
|
3023
|
-
payloads: [{
|
|
3024
|
-
text: `Image too large for the model${maxBytesHint}. Please compress or resize the image and try again.`,
|
|
3025
|
-
isError: true
|
|
3026
|
-
}],
|
|
3027
|
-
meta: {
|
|
3028
|
-
durationMs: Date.now() - started,
|
|
3029
|
-
agentMeta: buildErrorAgentMeta({
|
|
3030
|
-
sessionId: sessionIdUsed,
|
|
3031
|
-
sessionFile: activeSessionFile,
|
|
3032
|
-
provider,
|
|
3033
|
-
model: model.id,
|
|
3034
|
-
contextTokens: ctxInfo.tokens,
|
|
3035
|
-
usageAccumulator,
|
|
3036
|
-
lastRunPromptUsage,
|
|
3037
|
-
lastAssistant: sessionLastAssistant,
|
|
3038
|
-
lastTurnTotal
|
|
3039
|
-
}),
|
|
3040
|
-
systemPromptReport: attempt.systemPromptReport,
|
|
3041
|
-
finalPromptText: attempt.finalPromptText,
|
|
3042
|
-
replayInvalid: resolveReplayInvalidForAttempt(),
|
|
3043
|
-
livenessState: "blocked",
|
|
3044
|
-
error: {
|
|
3045
|
-
kind: "image_size",
|
|
3046
|
-
message: errorText
|
|
3047
|
-
}
|
|
3048
|
-
}
|
|
3049
|
-
};
|
|
3050
|
-
}
|
|
3051
|
-
const promptFailoverReason = promptErrorDetails.reason ?? classifyFailoverReason(errorText, { provider });
|
|
3052
|
-
const promptProfileFailureReason = resolveRunAuthProfileFailureReason(promptFailoverReason, { providerStarted: promptErrorSource === "prompt" });
|
|
3053
|
-
const promptFailoverFailure = promptFailoverReason !== null || isFailoverErrorMessage(errorText, { provider });
|
|
3054
|
-
const failedPromptProfileId = lastProfileId;
|
|
3055
|
-
const logPromptFailoverDecision = createFailoverDecisionLogger({
|
|
3056
|
-
stage: "prompt",
|
|
3057
|
-
runId: params.runId,
|
|
3058
|
-
rawError: errorText,
|
|
3059
|
-
failoverReason: promptFailoverReason,
|
|
3060
|
-
profileFailureReason: promptProfileFailureReason,
|
|
3061
|
-
provider,
|
|
3062
|
-
model: modelId,
|
|
3063
|
-
sourceProvider: provider,
|
|
3064
|
-
sourceModel: modelId,
|
|
3065
|
-
profileId: failedPromptProfileId,
|
|
3066
|
-
fallbackConfigured,
|
|
3067
|
-
aborted
|
|
3068
|
-
});
|
|
3069
|
-
if (promptFailoverReason === "rate_limit") maybeEscalateRateLimitProfileFallback({
|
|
3070
|
-
failoverProvider: provider,
|
|
3071
|
-
failoverModel: modelId,
|
|
3072
|
-
logFallbackDecision: logPromptFailoverDecision
|
|
3073
|
-
});
|
|
3074
|
-
let promptFailoverDecision = resolveRunFailoverDecision({
|
|
3075
|
-
stage: "prompt",
|
|
3076
|
-
aborted,
|
|
3077
|
-
externalAbort,
|
|
3078
|
-
fallbackConfigured,
|
|
3079
|
-
failoverFailure: promptFailoverFailure,
|
|
3080
|
-
failoverReason: promptFailoverReason,
|
|
3081
|
-
profileRotated: false
|
|
3082
|
-
});
|
|
3083
|
-
if (promptFailoverDecision.action === "rotate_profile" && await advanceAttemptAuthProfile()) {
|
|
3084
|
-
if (failedPromptProfileId && promptProfileFailureReason) maybeMarkAuthProfileFailure({
|
|
3085
|
-
profileId: failedPromptProfileId,
|
|
3086
|
-
reason: promptProfileFailureReason,
|
|
3087
|
-
modelId
|
|
3088
|
-
}).catch((err) => {
|
|
3089
|
-
log$1.warn(`prompt profile failure mark failed: ${String(err)}`);
|
|
3090
|
-
});
|
|
3091
|
-
traceAttempts.push({
|
|
3092
|
-
provider,
|
|
3093
|
-
model: modelId,
|
|
3094
|
-
result: promptFailoverReason === "timeout" ? "timeout" : "rotate_profile",
|
|
3095
|
-
...promptFailoverReason ? { reason: promptFailoverReason } : {},
|
|
3096
|
-
stage: "prompt"
|
|
3097
|
-
});
|
|
3098
|
-
lastRetryFailoverReason = mergeRetryFailoverReason({
|
|
3099
|
-
previous: lastRetryFailoverReason,
|
|
3100
|
-
failoverReason: promptFailoverReason
|
|
3101
|
-
});
|
|
3102
|
-
logPromptFailoverDecision("rotate_profile");
|
|
3103
|
-
await maybeBackoffBeforeOverloadFailover(promptFailoverReason);
|
|
3104
|
-
continue;
|
|
3105
|
-
}
|
|
3106
|
-
if (promptFailoverDecision.action === "rotate_profile") promptFailoverDecision = resolveRunFailoverDecision({
|
|
3107
|
-
stage: "prompt",
|
|
3108
|
-
aborted,
|
|
3109
|
-
externalAbort,
|
|
3110
|
-
fallbackConfigured,
|
|
3111
|
-
failoverFailure: promptFailoverFailure,
|
|
3112
|
-
failoverReason: promptFailoverReason,
|
|
3113
|
-
profileRotated: true
|
|
3114
|
-
});
|
|
3115
|
-
if (failedPromptProfileId && promptProfileFailureReason) try {
|
|
3116
|
-
await maybeMarkAuthProfileFailure({
|
|
3117
|
-
profileId: failedPromptProfileId,
|
|
3118
|
-
reason: promptProfileFailureReason,
|
|
3119
|
-
modelId
|
|
3120
|
-
});
|
|
3121
|
-
} catch (err) {
|
|
3122
|
-
log$1.warn(`prompt profile failure mark failed: ${String(err)}`);
|
|
3123
|
-
}
|
|
3124
|
-
const fallbackThinking = pickFallbackThinkingLevel({
|
|
3125
|
-
message: errorText,
|
|
3126
|
-
attempted: attemptedThinking
|
|
3127
|
-
});
|
|
3128
|
-
if (fallbackThinking) {
|
|
3129
|
-
log$1.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
3130
|
-
thinkLevel = fallbackThinking;
|
|
3131
|
-
continue;
|
|
3132
|
-
}
|
|
3133
|
-
if (promptFailoverDecision.action === "fallback_model") {
|
|
3134
|
-
const fallbackReason = promptFailoverDecision.reason ?? "unknown";
|
|
3135
|
-
const status = resolveFailoverStatus(fallbackReason);
|
|
3136
|
-
traceAttempts.push({
|
|
3137
|
-
provider,
|
|
3138
|
-
model: modelId,
|
|
3139
|
-
result: promptFailoverReason === "timeout" ? "timeout" : "fallback_model",
|
|
3140
|
-
reason: fallbackReason,
|
|
3141
|
-
stage: "prompt",
|
|
3142
|
-
...typeof status === "number" ? { status } : {}
|
|
3143
|
-
});
|
|
3144
|
-
logPromptFailoverDecision("fallback_model", { status });
|
|
3145
|
-
await maybeBackoffBeforeOverloadFailover(promptFailoverReason);
|
|
3146
|
-
throw normalizedPromptFailover ?? new FailoverError(errorText, {
|
|
3147
|
-
reason: fallbackReason,
|
|
3148
|
-
provider,
|
|
3149
|
-
model: modelId,
|
|
3150
|
-
profileId: lastProfileId,
|
|
3151
|
-
sessionId: sessionIdUsed,
|
|
3152
|
-
lane: globalLane,
|
|
3153
|
-
status
|
|
3154
|
-
});
|
|
3155
|
-
}
|
|
3156
|
-
if (promptFailoverDecision.action === "surface_error") {
|
|
3157
|
-
traceAttempts.push({
|
|
3158
|
-
provider,
|
|
3159
|
-
model: modelId,
|
|
3160
|
-
result: promptFailoverReason === "timeout" ? "timeout" : "surface_error",
|
|
3161
|
-
...promptFailoverReason ? { reason: promptFailoverReason } : {},
|
|
3162
|
-
stage: "prompt"
|
|
3163
|
-
});
|
|
3164
|
-
logPromptFailoverDecision("surface_error");
|
|
3165
|
-
}
|
|
3166
|
-
throw promptError;
|
|
3167
|
-
}
|
|
3168
|
-
const assistantForFailover = currentAttemptAssistant ?? sessionLastAssistant;
|
|
3169
|
-
const fallbackThinking = pickFallbackThinkingLevel({
|
|
3170
|
-
message: assistantForFailover?.errorMessage,
|
|
3171
|
-
attempted: attemptedThinking
|
|
3172
|
-
});
|
|
3173
|
-
if (fallbackThinking && !aborted) {
|
|
3174
|
-
log$1.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
3175
|
-
thinkLevel = fallbackThinking;
|
|
3176
|
-
continue;
|
|
3177
|
-
}
|
|
3178
|
-
const authFailure = isAuthAssistantError(assistantForFailover);
|
|
3179
|
-
const rateLimitFailure = isRateLimitAssistantError(assistantForFailover);
|
|
3180
|
-
const billingFailure = isBillingAssistantError(assistantForFailover);
|
|
3181
|
-
const failoverFailure = isFailoverAssistantError(assistantForFailover);
|
|
3182
|
-
const assistantFailoverReason = classifyFailoverReason(assistantForFailover?.errorMessage ?? "", { provider: assistantForFailover?.provider });
|
|
3183
|
-
const assistantProviderStarted = Boolean(currentAttemptAssistant?.provider) || idleTimedOut || timedOut && !timedOutDuringCompaction && !timedOutDuringToolExecution;
|
|
3184
|
-
const assistantProfileFailureReason = resolveRunAuthProfileFailureReason(assistantFailoverReason ?? (assistantProviderStarted && (timedOut || idleTimedOut) ? "timeout" : null), { providerStarted: assistantProviderStarted });
|
|
3185
|
-
const cloudCodeAssistFormatError = attempt.cloudCodeAssistFormatError;
|
|
3186
|
-
const imageDimensionError = parseImageDimensionError(assistantForFailover?.errorMessage ?? "");
|
|
3187
|
-
const failedAssistantProfileId = lastProfileId;
|
|
3188
|
-
const logAssistantFailoverDecision = createFailoverDecisionLogger({
|
|
3189
|
-
stage: "assistant",
|
|
3190
|
-
runId: params.runId,
|
|
3191
|
-
rawError: assistantForFailover?.errorMessage?.trim(),
|
|
3192
|
-
failoverReason: assistantFailoverReason,
|
|
3193
|
-
profileFailureReason: assistantProfileFailureReason,
|
|
3194
|
-
provider: activeErrorContext.provider,
|
|
3195
|
-
model: activeErrorContext.model,
|
|
3196
|
-
sourceProvider: assistantForFailover?.provider ?? provider,
|
|
3197
|
-
sourceModel: assistantForFailover?.model ?? modelId,
|
|
3198
|
-
profileId: failedAssistantProfileId,
|
|
3199
|
-
fallbackConfigured,
|
|
3200
|
-
timedOut,
|
|
3201
|
-
aborted
|
|
3202
|
-
});
|
|
3203
|
-
if (authFailure && await maybeRefreshRuntimeAuthForAuthError(assistantForFailover?.errorMessage ?? "", runtimeAuthRetry)) {
|
|
3204
|
-
authRetryPending = true;
|
|
3205
|
-
continue;
|
|
3206
|
-
}
|
|
3207
|
-
if (imageDimensionError && lastProfileId) {
|
|
3208
|
-
const details = [
|
|
3209
|
-
imageDimensionError.messageIndex !== void 0 ? `message=${imageDimensionError.messageIndex}` : null,
|
|
3210
|
-
imageDimensionError.contentIndex !== void 0 ? `content=${imageDimensionError.contentIndex}` : null,
|
|
3211
|
-
imageDimensionError.maxDimensionPx !== void 0 ? `limit=${imageDimensionError.maxDimensionPx}px` : null
|
|
3212
|
-
].filter(Boolean).join(" ");
|
|
3213
|
-
log$1.warn(`Profile ${lastProfileId} rejected image payload${details ? ` (${details})` : ""}.`);
|
|
3214
|
-
}
|
|
3215
|
-
const assistantFailoverDecision = resolveRunFailoverDecision({
|
|
3216
|
-
stage: "assistant",
|
|
3217
|
-
allowFormatRetry: cloudCodeAssistFormatError,
|
|
3218
|
-
aborted,
|
|
3219
|
-
externalAbort,
|
|
3220
|
-
fallbackConfigured,
|
|
3221
|
-
failoverFailure,
|
|
3222
|
-
failoverReason: assistantFailoverReason,
|
|
3223
|
-
timedOut,
|
|
3224
|
-
idleTimedOut,
|
|
3225
|
-
timedOutDuringCompaction,
|
|
3226
|
-
timedOutDuringToolExecution,
|
|
3227
|
-
profileRotated: false
|
|
3228
|
-
});
|
|
3229
|
-
const assistantFailoverOutcome = await handleAssistantFailover({
|
|
3230
|
-
initialDecision: assistantFailoverDecision,
|
|
3231
|
-
aborted,
|
|
3232
|
-
externalAbort,
|
|
3233
|
-
fallbackConfigured,
|
|
3234
|
-
failoverFailure,
|
|
3235
|
-
failoverReason: assistantFailoverReason,
|
|
3236
|
-
timedOut,
|
|
3237
|
-
idleTimedOut,
|
|
3238
|
-
timedOutDuringCompaction,
|
|
3239
|
-
timedOutDuringToolExecution,
|
|
3240
|
-
allowSameModelIdleTimeoutRetry: timedOut && idleTimedOut && !timedOutDuringCompaction && !fallbackConfigured && canRestartForLiveSwitch && sameModelIdleTimeoutRetries < MAX_SAME_MODEL_IDLE_TIMEOUT_RETRIES,
|
|
3241
|
-
assistantProfileFailureReason,
|
|
3242
|
-
lastProfileId,
|
|
3243
|
-
modelId,
|
|
3244
|
-
provider,
|
|
3245
|
-
activeErrorContext,
|
|
3246
|
-
lastAssistant: assistantForFailover,
|
|
3247
|
-
config: params.config,
|
|
3248
|
-
sessionKey: params.sessionKey ?? params.sessionId,
|
|
3249
|
-
authFailure,
|
|
3250
|
-
rateLimitFailure,
|
|
3251
|
-
billingFailure,
|
|
3252
|
-
cloudCodeAssistFormatError,
|
|
3253
|
-
isProbeSession,
|
|
3254
|
-
overloadProfileRotations,
|
|
3255
|
-
overloadProfileRotationLimit,
|
|
3256
|
-
previousRetryFailoverReason: lastRetryFailoverReason,
|
|
3257
|
-
logAssistantFailoverDecision,
|
|
3258
|
-
warn: (message) => log$1.warn(message),
|
|
3259
|
-
maybeMarkAuthProfileFailure,
|
|
3260
|
-
maybeEscalateRateLimitProfileFallback,
|
|
3261
|
-
maybeBackoffBeforeOverloadFailover,
|
|
3262
|
-
advanceAuthProfile: advanceAttemptAuthProfile
|
|
3263
|
-
});
|
|
3264
|
-
overloadProfileRotations = assistantFailoverOutcome.overloadProfileRotations;
|
|
3265
|
-
if (assistantFailoverOutcome.action === "retry") {
|
|
3266
|
-
traceAttempts.push({
|
|
3267
|
-
provider: activeErrorContext.provider,
|
|
3268
|
-
model: activeErrorContext.model,
|
|
3269
|
-
result: assistantFailoverOutcome.retryKind === "same_model_idle_timeout" || assistantFailoverReason === "timeout" ? "timeout" : "rotate_profile",
|
|
3270
|
-
...assistantFailoverReason ? { reason: assistantFailoverReason } : {},
|
|
3271
|
-
stage: "assistant"
|
|
3272
|
-
});
|
|
3273
|
-
if (assistantFailoverOutcome.retryKind === "same_model_idle_timeout") sameModelIdleTimeoutRetries += 1;
|
|
3274
|
-
lastRetryFailoverReason = assistantFailoverOutcome.lastRetryFailoverReason;
|
|
3275
|
-
continue;
|
|
3276
|
-
}
|
|
3277
|
-
if (assistantFailoverOutcome.action === "throw") {
|
|
3278
|
-
traceAttempts.push({
|
|
3279
|
-
provider: activeErrorContext.provider,
|
|
3280
|
-
model: activeErrorContext.model,
|
|
3281
|
-
result: assistantFailoverReason === "timeout" ? "timeout" : assistantFailoverDecision.action === "fallback_model" ? "fallback_model" : "error",
|
|
3282
|
-
...assistantFailoverReason ? { reason: assistantFailoverReason } : {},
|
|
3283
|
-
stage: "assistant",
|
|
3284
|
-
...typeof assistantFailoverOutcome.error.status === "number" ? { status: assistantFailoverOutcome.error.status } : {}
|
|
3285
|
-
});
|
|
3286
|
-
if (assistantFailoverOutcome.error.suspend) suspendSession({
|
|
3287
|
-
cfg: params.config,
|
|
3288
|
-
agentDir,
|
|
3289
|
-
sessionId: activeSessionId ?? params.sessionId,
|
|
3290
|
-
laneId: globalLane,
|
|
3291
|
-
reason: resolveSessionSuspensionReason(assistantFailoverOutcome.error.reason),
|
|
3292
|
-
failedProvider: assistantFailoverOutcome.error.provider ?? provider,
|
|
3293
|
-
failedModel: assistantFailoverOutcome.error.model ?? modelId
|
|
3294
|
-
});
|
|
3295
|
-
throw assistantFailoverOutcome.error;
|
|
3296
|
-
}
|
|
3297
|
-
const usageMeta = buildUsageAgentMetaFields({
|
|
3298
|
-
usageAccumulator,
|
|
3299
|
-
lastAssistantUsage: sessionLastAssistant?.usage,
|
|
3300
|
-
lastRunPromptUsage,
|
|
3301
|
-
lastTurnTotal
|
|
3302
|
-
});
|
|
3303
|
-
const reportedModelRef = resolveReportedModelRef({
|
|
3304
|
-
provider,
|
|
3305
|
-
model: model.id,
|
|
3306
|
-
assistant: sessionLastAssistant
|
|
3307
|
-
});
|
|
3308
|
-
const agentMeta = {
|
|
3309
|
-
sessionId: sessionIdUsed,
|
|
3310
|
-
sessionFile: sessionFileUsed,
|
|
3311
|
-
provider: reportedModelRef.provider,
|
|
3312
|
-
model: reportedModelRef.model,
|
|
3313
|
-
contextTokens: ctxInfo.tokens,
|
|
3314
|
-
agentHarnessId: attempt.agentHarnessId,
|
|
3315
|
-
usage: usageMeta.usage,
|
|
3316
|
-
lastCallUsage: usageMeta.lastCallUsage,
|
|
3317
|
-
promptTokens: usageMeta.promptTokens,
|
|
3318
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
3319
|
-
compactionTokensAfter: lastCompactionTokensAfter
|
|
3320
|
-
};
|
|
3321
|
-
const finalAssistantVisibleText = resolveFinalAssistantVisibleText(sessionLastAssistant);
|
|
3322
|
-
const finalAssistantRawText = resolveFinalAssistantRawText(sessionLastAssistant);
|
|
3323
|
-
const payloads = buildEmbeddedRunPayloads({
|
|
3324
|
-
assistantTexts: attempt.assistantTexts,
|
|
3325
|
-
toolMetas: attempt.toolMetas,
|
|
3326
|
-
lastAssistant: attempt.lastAssistant,
|
|
3327
|
-
currentAssistant: currentAttemptAssistant ?? null,
|
|
3328
|
-
lastToolError: attempt.lastToolError,
|
|
3329
|
-
config: params.config,
|
|
3330
|
-
isCronTrigger: params.trigger === "cron",
|
|
3331
|
-
sessionKey: params.sessionKey ?? params.sessionId,
|
|
3332
|
-
provider: activeErrorContext.provider,
|
|
3333
|
-
model: activeErrorContext.model,
|
|
3334
|
-
verboseLevel: params.verboseLevel,
|
|
3335
|
-
reasoningLevel: params.reasoningLevel,
|
|
3336
|
-
thinkingLevel: params.thinkLevel,
|
|
3337
|
-
toolResultFormat: resolvedToolResultFormat,
|
|
3338
|
-
suppressToolErrorWarnings: params.suppressToolErrorWarnings,
|
|
3339
|
-
inlineToolResultsAllowed: false,
|
|
3340
|
-
didSendViaMessagingTool: attempt.didSendViaMessagingTool,
|
|
3341
|
-
messagingToolSourceReplyPayloads: attempt.messagingToolSourceReplyPayloads,
|
|
3342
|
-
sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
|
|
3343
|
-
agentId: params.agentId,
|
|
3344
|
-
runId: params.runId,
|
|
3345
|
-
runAborted: aborted,
|
|
3346
|
-
didSendDeterministicApprovalPrompt: attempt.didSendDeterministicApprovalPrompt,
|
|
3347
|
-
heartbeatToolResponse: attempt.heartbeatToolResponse
|
|
3348
|
-
});
|
|
3349
|
-
const payloadsWithToolMedia = mergeAttemptToolMediaPayloads({
|
|
3350
|
-
payloads,
|
|
3351
|
-
toolMediaUrls: attempt.toolMediaUrls,
|
|
3352
|
-
toolAudioAsVoice: attempt.toolAudioAsVoice,
|
|
3353
|
-
toolTrustedLocalMedia: attempt.toolTrustedLocalMedia,
|
|
3354
|
-
sourceReplyDeliveryMode: params.sourceReplyDeliveryMode
|
|
3355
|
-
});
|
|
3356
|
-
const timedOutDuringPrompt = timedOut && !timedOutDuringCompaction && !timedOutDuringToolExecution;
|
|
3357
|
-
const finalAssistantStopReason = (sessionLastAssistant?.stopReason ?? "").trim().toLowerCase();
|
|
3358
|
-
const recoveredFinalAssistantTextAfterPromptTimeout = timedOutDuringPrompt && [
|
|
3359
|
-
"completed",
|
|
3360
|
-
"end_turn",
|
|
3361
|
-
"stop"
|
|
3362
|
-
].includes(finalAssistantStopReason) ? (finalAssistantVisibleText ?? finalAssistantRawText)?.trim() : void 0;
|
|
3363
|
-
const payloadAlreadyContainsRecoveredFinalAssistant = recoveredFinalAssistantTextAfterPromptTimeout ? (payloadsWithToolMedia ?? []).some((payload) => payload?.isError !== true && payload?.isReasoning !== true && typeof payload.text === "string" && payload.text.trim() === recoveredFinalAssistantTextAfterPromptTimeout) : false;
|
|
3364
|
-
const recoveredFinalAssistantPayloadsAfterPromptTimeout = recoveredFinalAssistantTextAfterPromptTimeout && !payloadAlreadyContainsRecoveredFinalAssistant ? [{ text: recoveredFinalAssistantTextAfterPromptTimeout }] : void 0;
|
|
3365
|
-
const hasSuccessfulFinalAssistantAfterPromptTimeout = timedOutDuringPrompt && Boolean(payloadAlreadyContainsRecoveredFinalAssistant || recoveredFinalAssistantPayloadsAfterPromptTimeout?.length);
|
|
3366
|
-
const hasPartialAssistantTextAfterPromptTimeout = timedOutDuringPrompt && (attempt.assistantTexts ?? []).some((text) => text.trim().length > 0) && !attempt.clientToolCalls && !attempt.yieldDetected && !attempt.didSendViaMessagingTool && !attempt.didSendDeterministicApprovalPrompt && !attempt.lastToolError && (attempt.toolMetas?.length ?? 0) === 0;
|
|
3367
|
-
const attemptToolSummary = buildTraceToolSummary({
|
|
3368
|
-
toolMetas: attempt.toolMetas,
|
|
3369
|
-
hadFailure: Boolean(attempt.lastToolError)
|
|
3370
|
-
});
|
|
3371
|
-
const failureSignal = resolveEmbeddedRunFailureSignal({
|
|
3372
|
-
trigger: params.trigger,
|
|
3373
|
-
lastToolError: attempt.lastToolError
|
|
3374
|
-
});
|
|
3375
|
-
if (timedOutDuringPrompt && !hasSuccessfulFinalAssistantAfterPromptTimeout && !hasMessagingToolDeliveryEvidence(attempt)) {
|
|
3376
|
-
const defaultTimeoutText = idleTimedOut ? "The model did not produce a response before the model idle timeout. Please try again, or increase `models.providers.<id>.timeoutSeconds` for slow local or self-hosted providers. If `agents.defaults.timeoutSeconds` or a run-specific timeout is lower, raise that ceiling too; provider timeouts cannot extend the whole agent run." : "Request timed out before a response was generated. Please try again, or increase `agents.defaults.timeoutSeconds` in your config.";
|
|
3377
|
-
const timeoutText = attempt.promptTimeoutOutcome?.message?.trim() || defaultTimeoutText;
|
|
3378
|
-
const replayInvalid = attempt.promptTimeoutOutcome?.replayInvalid ?? resolveReplayInvalidForAttempt(null);
|
|
3379
|
-
const livenessState = attempt.promptTimeoutOutcome?.livenessState ?? resolveRunLivenessState({
|
|
3380
|
-
payloadCount: hasPartialAssistantTextAfterPromptTimeout ? 0 : payloads.length,
|
|
3381
|
-
aborted,
|
|
3382
|
-
timedOut,
|
|
3383
|
-
attempt,
|
|
3384
|
-
incompleteTurnText: null
|
|
3385
|
-
});
|
|
3386
|
-
const timeoutPhase = attempt.promptTimeoutOutcome?.timeoutPhase ?? "provider";
|
|
3387
|
-
const providerStarted = attempt.promptTimeoutOutcome?.providerStarted ?? true;
|
|
3388
|
-
attempt.setTerminalLifecycleMeta?.({
|
|
3389
|
-
replayInvalid,
|
|
3390
|
-
livenessState,
|
|
3391
|
-
timeoutPhase,
|
|
3392
|
-
providerStarted
|
|
3393
|
-
});
|
|
3394
|
-
return {
|
|
3395
|
-
payloads: [...hasPartialAssistantTextAfterPromptTimeout ? [] : payloadsWithToolMedia || [], {
|
|
3396
|
-
text: timeoutText,
|
|
3397
|
-
isError: true
|
|
3398
|
-
}],
|
|
3399
|
-
meta: {
|
|
3400
|
-
durationMs: Date.now() - started,
|
|
3401
|
-
agentMeta,
|
|
3402
|
-
aborted,
|
|
3403
|
-
systemPromptReport: attempt.systemPromptReport,
|
|
3404
|
-
finalPromptText: attempt.finalPromptText,
|
|
3405
|
-
finalAssistantVisibleText,
|
|
3406
|
-
finalAssistantRawText,
|
|
3407
|
-
replayInvalid,
|
|
3408
|
-
livenessState,
|
|
3409
|
-
timeoutPhase,
|
|
3410
|
-
providerStarted,
|
|
3411
|
-
toolSummary: attemptToolSummary,
|
|
3412
|
-
...failureSignal ? { failureSignal } : {},
|
|
3413
|
-
agentHarnessResultClassification: attempt.agentHarnessResultClassification
|
|
3414
|
-
},
|
|
3415
|
-
didSendViaMessagingTool: attempt.didSendViaMessagingTool,
|
|
3416
|
-
didSendDeterministicApprovalPrompt: attempt.didSendDeterministicApprovalPrompt,
|
|
3417
|
-
messagingToolSentTexts: attempt.messagingToolSentTexts,
|
|
3418
|
-
messagingToolSentMediaUrls: attempt.messagingToolSentMediaUrls,
|
|
3419
|
-
messagingToolSentTargets: attempt.messagingToolSentTargets,
|
|
3420
|
-
messagingToolSourceReplyPayloads: attempt.messagingToolSourceReplyPayloads,
|
|
3421
|
-
heartbeatToolResponse: attempt.heartbeatToolResponse,
|
|
3422
|
-
successfulCronAdds: attempt.successfulCronAdds,
|
|
3423
|
-
acceptedSessionSpawns: attempt.acceptedSessionSpawns
|
|
3424
|
-
};
|
|
3425
|
-
}
|
|
3426
|
-
const silentToolResultReplyPayload = resolveSilentToolResultReplyPayload({
|
|
3427
|
-
isCronTrigger: params.trigger === "cron",
|
|
3428
|
-
payloadCount: payloadsWithToolMedia?.length ?? 0,
|
|
3429
|
-
aborted,
|
|
3430
|
-
timedOut,
|
|
3431
|
-
attempt
|
|
3432
|
-
});
|
|
3433
|
-
const payloadsForTerminalPath = recoveredFinalAssistantPayloadsAfterPromptTimeout ? recoveredFinalAssistantPayloadsAfterPromptTimeout : payloadsWithToolMedia?.length ? payloadsWithToolMedia : silentToolResultReplyPayload ? [silentToolResultReplyPayload] : payloadsWithToolMedia;
|
|
3434
|
-
const payloadCount = payloadsForTerminalPath?.length ?? 0;
|
|
3435
|
-
const emptyAssistantReplyIsSilent = shouldTreatEmptyAssistantReplyAsSilent({
|
|
3436
|
-
allowEmptyAssistantReplyAsSilent: params.allowEmptyAssistantReplyAsSilent,
|
|
3437
|
-
payloadCount,
|
|
3438
|
-
aborted,
|
|
3439
|
-
timedOut,
|
|
3440
|
-
attempt
|
|
3441
|
-
});
|
|
3442
|
-
const nextPlanningOnlyRetryInstruction = emptyAssistantReplyIsSilent ? null : resolvePlanningOnlyRetryInstruction({
|
|
3443
|
-
provider,
|
|
3444
|
-
modelId,
|
|
3445
|
-
executionContract,
|
|
3446
|
-
prompt: params.prompt,
|
|
3447
|
-
aborted,
|
|
3448
|
-
timedOut,
|
|
3449
|
-
attempt
|
|
3450
|
-
});
|
|
3451
|
-
const nextReasoningOnlyRetryInstruction = emptyAssistantReplyIsSilent ? null : resolveReasoningOnlyRetryInstruction({
|
|
3452
|
-
provider: activeErrorContext.provider,
|
|
3453
|
-
modelId: activeErrorContext.model,
|
|
3454
|
-
modelApi: effectiveModel.api,
|
|
3455
|
-
executionContract,
|
|
3456
|
-
aborted,
|
|
3457
|
-
timedOut,
|
|
3458
|
-
attempt
|
|
3459
|
-
});
|
|
3460
|
-
const nextEmptyResponseRetryInstruction = emptyAssistantReplyIsSilent ? null : resolveEmptyResponseRetryInstruction({
|
|
3461
|
-
provider: activeErrorContext.provider,
|
|
3462
|
-
modelId: activeErrorContext.model,
|
|
3463
|
-
modelApi: effectiveModel.api,
|
|
3464
|
-
executionContract,
|
|
3465
|
-
payloadCount,
|
|
3466
|
-
aborted,
|
|
3467
|
-
timedOut,
|
|
3468
|
-
attempt
|
|
3469
|
-
});
|
|
3470
|
-
if (nextPlanningOnlyRetryInstruction && planningOnlyRetryAttempts < maxPlanningOnlyRetryAttempts) {
|
|
3471
|
-
const planDetails = extractPlanningOnlyPlanDetails((attempt.assistantTexts ?? []).join("\n\n").trim());
|
|
3472
|
-
if (planDetails) {
|
|
3473
|
-
emitAgentPlanEvent({
|
|
3474
|
-
runId: params.runId,
|
|
3475
|
-
...params.sessionKey ? { sessionKey: params.sessionKey } : {},
|
|
3476
|
-
data: {
|
|
3477
|
-
phase: "update",
|
|
3478
|
-
title: "Assistant proposed a plan",
|
|
3479
|
-
explanation: planDetails.explanation,
|
|
3480
|
-
steps: planDetails.steps,
|
|
3481
|
-
source: "planning_only_retry"
|
|
3482
|
-
}
|
|
3483
|
-
});
|
|
3484
|
-
params.onAgentEvent?.({
|
|
3485
|
-
stream: "plan",
|
|
3486
|
-
data: {
|
|
3487
|
-
phase: "update",
|
|
3488
|
-
title: "Assistant proposed a plan",
|
|
3489
|
-
explanation: planDetails.explanation,
|
|
3490
|
-
steps: planDetails.steps,
|
|
3491
|
-
source: "planning_only_retry"
|
|
3492
|
-
}
|
|
3493
|
-
});
|
|
3494
|
-
}
|
|
3495
|
-
planningOnlyRetryAttempts += 1;
|
|
3496
|
-
planningOnlyRetryInstruction = nextPlanningOnlyRetryInstruction;
|
|
3497
|
-
const planningOnlyRetryLogPrefix = executionContract === "strict-agentic" ? "strict-agentic execution contract triggered" : "planning-only turn detected";
|
|
3498
|
-
log$1.warn(`${planningOnlyRetryLogPrefix}: runId=${params.runId} sessionId=${params.sessionId} provider=${provider}/${modelId} harness=${sanitizeForLog(agentHarness.id)} contract=${executionContract} configured=${configuredExecutionContractForLog} — retrying ${planningOnlyRetryAttempts}/${maxPlanningOnlyRetryAttempts} with act-now steer`);
|
|
3499
|
-
continue;
|
|
3500
|
-
}
|
|
3501
|
-
if (!nextPlanningOnlyRetryInstruction && nextReasoningOnlyRetryInstruction && reasoningOnlyRetryAttempts < maxReasoningOnlyRetryAttempts) {
|
|
3502
|
-
reasoningOnlyRetryAttempts += 1;
|
|
3503
|
-
reasoningOnlyRetryInstruction = nextReasoningOnlyRetryInstruction;
|
|
3504
|
-
log$1.warn(`reasoning-only assistant turn detected: runId=${params.runId} sessionId=${params.sessionId} provider=${activeErrorContext.provider}/${activeErrorContext.model} — retrying ${reasoningOnlyRetryAttempts}/${maxReasoningOnlyRetryAttempts} with visible-answer continuation`);
|
|
3505
|
-
continue;
|
|
3506
|
-
}
|
|
3507
|
-
const reasoningOnlyRetriesExhausted = !nextPlanningOnlyRetryInstruction && nextReasoningOnlyRetryInstruction && reasoningOnlyRetryAttempts >= maxReasoningOnlyRetryAttempts;
|
|
3508
|
-
if (!nextPlanningOnlyRetryInstruction && !nextReasoningOnlyRetryInstruction && nextEmptyResponseRetryInstruction && emptyResponseRetryAttempts < maxEmptyResponseRetryAttempts) {
|
|
3509
|
-
emptyResponseRetryAttempts += 1;
|
|
3510
|
-
emptyResponseRetryInstruction = nextEmptyResponseRetryInstruction;
|
|
3511
|
-
log$1.warn(`empty response detected: runId=${params.runId} sessionId=${params.sessionId} provider=${activeErrorContext.provider}/${activeErrorContext.model} — retrying ${emptyResponseRetryAttempts}/${maxEmptyResponseRetryAttempts} with visible-answer continuation`);
|
|
3512
|
-
continue;
|
|
3513
|
-
}
|
|
3514
|
-
const incompleteTurnText = emptyAssistantReplyIsSilent ? null : resolveIncompleteTurnPayloadText({
|
|
3515
|
-
payloadCount,
|
|
3516
|
-
aborted,
|
|
3517
|
-
timedOut,
|
|
3518
|
-
attempt
|
|
3519
|
-
});
|
|
3520
|
-
if (!emptyAssistantReplyIsSilent && attemptCompactionCount > 0 && payloadCount === 0 && !aborted && !promptError && !timedOut && !attempt.clientToolCalls && !attempt.yieldDetected && !attempt.didSendDeterministicApprovalPrompt && !attempt.lastToolError && !resolveAttemptReplayMetadata(attempt).hadPotentialSideEffects && compactionContinuationRetryAttempts < 1) {
|
|
3521
|
-
compactionContinuationRetryAttempts += 1;
|
|
3522
|
-
compactionContinuationRetryInstruction = COMPACTION_CONTINUATION_RETRY_INSTRUCTION;
|
|
3523
|
-
log$1.warn(`compaction interrupted visible final answer: runId=${params.runId} sessionId=${params.sessionId} compactions=${attemptCompactionCount} — retrying ${compactionContinuationRetryAttempts}/1 with compacted-transcript continuation`);
|
|
3524
|
-
postCompactionGuard.armPostCompaction();
|
|
3525
|
-
continue;
|
|
3526
|
-
}
|
|
3527
|
-
compactionContinuationRetryInstruction = null;
|
|
3528
|
-
if (reasoningOnlyRetriesExhausted && !finalAssistantVisibleText) log$1.warn(`reasoning-only retries exhausted: runId=${params.runId} sessionId=${params.sessionId} provider=${activeErrorContext.provider}/${activeErrorContext.model} attempts=${reasoningOnlyRetryAttempts}/${maxReasoningOnlyRetryAttempts} — surfacing incomplete-turn error`);
|
|
3529
|
-
if (!incompleteTurnText && nextPlanningOnlyRetryInstruction && strictAgenticActive) {
|
|
3530
|
-
log$1.warn(`strict-agentic run exhausted planning-only retries: runId=${params.runId} sessionId=${params.sessionId} provider=${provider}/${modelId} configured=${configuredExecutionContractForLog} — surfacing blocked state`);
|
|
3531
|
-
const replayInvalid = resolveReplayInvalidForAttempt(null);
|
|
3532
|
-
const livenessState = "blocked";
|
|
3533
|
-
attempt.setTerminalLifecycleMeta?.({
|
|
3534
|
-
replayInvalid,
|
|
3535
|
-
livenessState
|
|
3536
|
-
});
|
|
3537
|
-
return {
|
|
3538
|
-
payloads: [{
|
|
3539
|
-
text: STRICT_AGENTIC_BLOCKED_TEXT,
|
|
3540
|
-
isError: true
|
|
3541
|
-
}],
|
|
3542
|
-
meta: {
|
|
3543
|
-
durationMs: Date.now() - started,
|
|
3544
|
-
agentMeta,
|
|
3545
|
-
aborted,
|
|
3546
|
-
systemPromptReport: attempt.systemPromptReport,
|
|
3547
|
-
finalPromptText: attempt.finalPromptText,
|
|
3548
|
-
finalAssistantVisibleText,
|
|
3549
|
-
finalAssistantRawText,
|
|
3550
|
-
replayInvalid,
|
|
3551
|
-
livenessState,
|
|
3552
|
-
toolSummary: attemptToolSummary,
|
|
3553
|
-
...failureSignal ? { failureSignal } : {},
|
|
3554
|
-
agentHarnessResultClassification: attempt.agentHarnessResultClassification
|
|
3555
|
-
},
|
|
3556
|
-
didSendViaMessagingTool: attempt.didSendViaMessagingTool,
|
|
3557
|
-
didSendDeterministicApprovalPrompt: attempt.didSendDeterministicApprovalPrompt,
|
|
3558
|
-
messagingToolSentTexts: attempt.messagingToolSentTexts,
|
|
3559
|
-
messagingToolSentMediaUrls: attempt.messagingToolSentMediaUrls,
|
|
3560
|
-
messagingToolSentTargets: attempt.messagingToolSentTargets,
|
|
3561
|
-
messagingToolSourceReplyPayloads: attempt.messagingToolSourceReplyPayloads,
|
|
3562
|
-
heartbeatToolResponse: attempt.heartbeatToolResponse,
|
|
3563
|
-
successfulCronAdds: attempt.successfulCronAdds,
|
|
3564
|
-
acceptedSessionSpawns: attempt.acceptedSessionSpawns
|
|
3565
|
-
};
|
|
3566
|
-
}
|
|
3567
|
-
if (reasoningOnlyRetriesExhausted && !finalAssistantVisibleText) {
|
|
3568
|
-
const replayInvalid = resolveReplayInvalidForAttempt("⚠️ Agent couldn't generate a response. Please try again.");
|
|
3569
|
-
const livenessState = resolveRunLivenessState({
|
|
3570
|
-
payloadCount: 0,
|
|
3571
|
-
aborted,
|
|
3572
|
-
timedOut,
|
|
3573
|
-
attempt,
|
|
3574
|
-
incompleteTurnText: "⚠️ Agent couldn't generate a response. Please try again."
|
|
3575
|
-
});
|
|
3576
|
-
attempt.setTerminalLifecycleMeta?.({
|
|
3577
|
-
replayInvalid,
|
|
3578
|
-
livenessState
|
|
3579
|
-
});
|
|
3580
|
-
if (lastProfileId) await maybeMarkAuthProfileFailure({
|
|
3581
|
-
profileId: lastProfileId,
|
|
3582
|
-
reason: assistantProfileFailureReason
|
|
3583
|
-
});
|
|
3584
|
-
return {
|
|
3585
|
-
payloads: [{
|
|
3586
|
-
text: "⚠️ Agent couldn't generate a response. Please try again.",
|
|
3587
|
-
isError: true
|
|
3588
|
-
}],
|
|
3589
|
-
meta: {
|
|
3590
|
-
durationMs: Date.now() - started,
|
|
3591
|
-
agentMeta,
|
|
3592
|
-
aborted,
|
|
3593
|
-
systemPromptReport: attempt.systemPromptReport,
|
|
3594
|
-
finalPromptText: attempt.finalPromptText,
|
|
3595
|
-
finalAssistantVisibleText,
|
|
3596
|
-
finalAssistantRawText,
|
|
3597
|
-
replayInvalid,
|
|
3598
|
-
livenessState,
|
|
3599
|
-
toolSummary: attemptToolSummary,
|
|
3600
|
-
...failureSignal ? { failureSignal } : {},
|
|
3601
|
-
agentHarnessResultClassification: attempt.agentHarnessResultClassification
|
|
3602
|
-
},
|
|
3603
|
-
didSendViaMessagingTool: attempt.didSendViaMessagingTool,
|
|
3604
|
-
didSendDeterministicApprovalPrompt: attempt.didSendDeterministicApprovalPrompt,
|
|
3605
|
-
messagingToolSentTexts: attempt.messagingToolSentTexts,
|
|
3606
|
-
messagingToolSentMediaUrls: attempt.messagingToolSentMediaUrls,
|
|
3607
|
-
messagingToolSentTargets: attempt.messagingToolSentTargets,
|
|
3608
|
-
messagingToolSourceReplyPayloads: attempt.messagingToolSourceReplyPayloads,
|
|
3609
|
-
heartbeatToolResponse: attempt.heartbeatToolResponse,
|
|
3610
|
-
successfulCronAdds: attempt.successfulCronAdds,
|
|
3611
|
-
acceptedSessionSpawns: attempt.acceptedSessionSpawns
|
|
3612
|
-
};
|
|
3613
|
-
}
|
|
3614
|
-
if (!nextPlanningOnlyRetryInstruction && !nextReasoningOnlyRetryInstruction && nextEmptyResponseRetryInstruction && emptyResponseRetryAttempts >= maxEmptyResponseRetryAttempts) log$1.warn(`empty response retries exhausted: runId=${params.runId} sessionId=${params.sessionId} provider=${activeErrorContext.provider}/${activeErrorContext.model} attempts=${emptyResponseRetryAttempts}/${maxEmptyResponseRetryAttempts} — surfacing incomplete-turn error`);
|
|
3615
|
-
const silentErrorContent = sessionLastAssistant?.content;
|
|
3616
|
-
if (incompleteTurnText && !aborted && !promptError && !timedOut && sessionLastAssistant?.stopReason === "error" && ((sessionLastAssistant?.usage)?.output ?? 0) === 0 && (silentErrorContent?.length ?? 0) === 0 && (attempt.replayMetadata ? !attempt.replayMetadata.hadPotentialSideEffects : false) && emptyErrorRetries < MAX_EMPTY_ERROR_RETRIES) {
|
|
3617
|
-
emptyErrorRetries += 1;
|
|
3618
|
-
log$1.warn(`[empty-error-retry] stopReason=error output=0; resubmitting attempt=${emptyErrorRetries}/${MAX_EMPTY_ERROR_RETRIES} provider=${sessionLastAssistant?.provider ?? provider} model=${sessionLastAssistant?.model ?? model.id} sessionKey=${params.sessionKey ?? params.sessionId}`);
|
|
3619
|
-
continue;
|
|
3620
|
-
}
|
|
3621
|
-
if (incompleteTurnText) {
|
|
3622
|
-
const replayInvalid = resolveReplayInvalidForAttempt(incompleteTurnText);
|
|
3623
|
-
const livenessState = resolveRunLivenessState({
|
|
3624
|
-
payloadCount,
|
|
3625
|
-
aborted,
|
|
3626
|
-
timedOut,
|
|
3627
|
-
attempt,
|
|
3628
|
-
incompleteTurnText
|
|
3629
|
-
});
|
|
3630
|
-
attempt.setTerminalLifecycleMeta?.({
|
|
3631
|
-
replayInvalid,
|
|
3632
|
-
livenessState
|
|
3633
|
-
});
|
|
3634
|
-
const incompleteStopReason = attempt.lastAssistant?.stopReason;
|
|
3635
|
-
log$1.warn(`incomplete turn detected: runId=${params.runId} sessionId=${params.sessionId} stopReason=${incompleteStopReason} payloads=${payloadCount} — surfacing error to user`);
|
|
3636
|
-
if (lastProfileId) await maybeMarkAuthProfileFailure({
|
|
3637
|
-
profileId: lastProfileId,
|
|
3638
|
-
reason: assistantProfileFailureReason
|
|
3639
|
-
});
|
|
3640
|
-
return {
|
|
3641
|
-
payloads: [{
|
|
3642
|
-
text: incompleteTurnText,
|
|
3643
|
-
isError: true
|
|
3644
|
-
}],
|
|
3645
|
-
meta: {
|
|
3646
|
-
durationMs: Date.now() - started,
|
|
3647
|
-
agentMeta,
|
|
3648
|
-
aborted,
|
|
3649
|
-
systemPromptReport: attempt.systemPromptReport,
|
|
3650
|
-
finalPromptText: attempt.finalPromptText,
|
|
3651
|
-
finalAssistantVisibleText,
|
|
3652
|
-
finalAssistantRawText,
|
|
3653
|
-
replayInvalid,
|
|
3654
|
-
livenessState,
|
|
3655
|
-
toolSummary: attemptToolSummary,
|
|
3656
|
-
...failureSignal ? { failureSignal } : {},
|
|
3657
|
-
agentHarnessResultClassification: attempt.agentHarnessResultClassification
|
|
3658
|
-
},
|
|
3659
|
-
didSendViaMessagingTool: attempt.didSendViaMessagingTool,
|
|
3660
|
-
didSendDeterministicApprovalPrompt: attempt.didSendDeterministicApprovalPrompt,
|
|
3661
|
-
messagingToolSentTexts: attempt.messagingToolSentTexts,
|
|
3662
|
-
messagingToolSentMediaUrls: attempt.messagingToolSentMediaUrls,
|
|
3663
|
-
messagingToolSentTargets: attempt.messagingToolSentTargets,
|
|
3664
|
-
messagingToolSourceReplyPayloads: attempt.messagingToolSourceReplyPayloads,
|
|
3665
|
-
heartbeatToolResponse: attempt.heartbeatToolResponse,
|
|
3666
|
-
successfulCronAdds: attempt.successfulCronAdds,
|
|
3667
|
-
acceptedSessionSpawns: attempt.acceptedSessionSpawns
|
|
3668
|
-
};
|
|
3669
|
-
}
|
|
3670
|
-
log$1.debug(`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`);
|
|
3671
|
-
if (lastProfileId) await markAuthProfileSuccess({
|
|
3672
|
-
store: profileFailureStore,
|
|
3673
|
-
provider: resolveAuthProfileStateProvider(profileFailureStore, lastProfileId, provider),
|
|
3674
|
-
profileId: lastProfileId,
|
|
3675
|
-
agentDir: params.agentDir
|
|
3676
|
-
});
|
|
3677
|
-
const replayInvalid = resolveReplayInvalidForAttempt(null);
|
|
3678
|
-
const livenessState = attempt.yieldDetected ? "paused" : resolveRunLivenessState({
|
|
3679
|
-
payloadCount,
|
|
3680
|
-
aborted,
|
|
3681
|
-
timedOut,
|
|
3682
|
-
attempt,
|
|
3683
|
-
incompleteTurnText: null
|
|
3684
|
-
});
|
|
3685
|
-
const stopReason = attempt.clientToolCalls ? "tool_calls" : attempt.yieldDetected ? "end_turn" : sessionLastAssistant?.stopReason;
|
|
3686
|
-
const terminalPayloads = emptyAssistantReplyIsSilent ? [{ text: SILENT_REPLY_TOKEN }] : payloadsForTerminalPath;
|
|
3687
|
-
attempt.setTerminalLifecycleMeta?.({
|
|
3688
|
-
replayInvalid,
|
|
3689
|
-
livenessState,
|
|
3690
|
-
stopReason,
|
|
3691
|
-
yielded: attempt.yieldDetected === true
|
|
3692
|
-
});
|
|
3693
|
-
return {
|
|
3694
|
-
payloads: terminalPayloads?.length ? terminalPayloads : void 0,
|
|
3695
|
-
...attempt.diagnosticTrace ? { diagnosticTrace: freezeDiagnosticTraceContext(attempt.diagnosticTrace) } : {},
|
|
3696
|
-
meta: {
|
|
3697
|
-
durationMs: Date.now() - started,
|
|
3698
|
-
agentMeta,
|
|
3699
|
-
aborted,
|
|
3700
|
-
systemPromptReport: attempt.systemPromptReport,
|
|
3701
|
-
finalPromptText: attempt.finalPromptText,
|
|
3702
|
-
finalAssistantVisibleText,
|
|
3703
|
-
finalAssistantRawText,
|
|
3704
|
-
replayInvalid,
|
|
3705
|
-
livenessState,
|
|
3706
|
-
agentHarnessResultClassification: attempt.agentHarnessResultClassification,
|
|
3707
|
-
...attempt.yieldDetected ? { yielded: true } : {},
|
|
3708
|
-
...emptyAssistantReplyIsSilent ? { terminalReplyKind: "silent-empty" } : {},
|
|
3709
|
-
stopReason,
|
|
3710
|
-
pendingToolCalls: attempt.clientToolCalls?.map((call) => ({
|
|
3711
|
-
id: randomBytes(5).toString("hex").slice(0, 9),
|
|
3712
|
-
name: call.name,
|
|
3713
|
-
arguments: JSON.stringify(call.params)
|
|
3714
|
-
})),
|
|
3715
|
-
executionTrace: {
|
|
3716
|
-
winnerProvider: reportedModelRef.provider,
|
|
3717
|
-
winnerModel: reportedModelRef.model,
|
|
3718
|
-
attempts: traceAttempts.length > 0 || sessionLastAssistant?.provider || sessionLastAssistant?.model ? [...traceAttempts, {
|
|
3719
|
-
provider: reportedModelRef.provider,
|
|
3720
|
-
model: reportedModelRef.model,
|
|
3721
|
-
result: "success",
|
|
3722
|
-
stage: "assistant"
|
|
3723
|
-
}] : void 0,
|
|
3724
|
-
fallbackUsed: traceAttempts.length > 0,
|
|
3725
|
-
runner: "embedded"
|
|
3726
|
-
},
|
|
3727
|
-
requestShaping: {
|
|
3728
|
-
...lastProfileId ? { authMode: "auth-profile" } : {},
|
|
3729
|
-
...thinkLevel ? { thinking: thinkLevel } : {},
|
|
3730
|
-
...params.reasoningLevel ? { reasoning: params.reasoningLevel } : {},
|
|
3731
|
-
...params.verboseLevel ? { verbose: params.verboseLevel } : {},
|
|
3732
|
-
...params.blockReplyBreak ? { blockStreaming: params.blockReplyBreak } : {}
|
|
3733
|
-
},
|
|
3734
|
-
toolSummary: attemptToolSummary,
|
|
3735
|
-
...failureSignal ? { failureSignal } : {},
|
|
3736
|
-
completion: {
|
|
3737
|
-
...stopReason ? { stopReason } : {},
|
|
3738
|
-
...stopReason ? { finishReason: stopReason } : {},
|
|
3739
|
-
...stopReason?.toLowerCase().includes("refusal") ? { refusal: true } : {}
|
|
3740
|
-
},
|
|
3741
|
-
contextManagement: autoCompactionCount > 0 ? { lastTurnCompactions: autoCompactionCount } : void 0
|
|
3742
|
-
},
|
|
3743
|
-
didSendViaMessagingTool: attempt.didSendViaMessagingTool,
|
|
3744
|
-
didSendDeterministicApprovalPrompt: attempt.didSendDeterministicApprovalPrompt,
|
|
3745
|
-
messagingToolSentTexts: attempt.messagingToolSentTexts,
|
|
3746
|
-
messagingToolSentMediaUrls: attempt.messagingToolSentMediaUrls,
|
|
3747
|
-
messagingToolSentTargets: attempt.messagingToolSentTargets,
|
|
3748
|
-
messagingToolSourceReplyPayloads: attempt.messagingToolSourceReplyPayloads,
|
|
3749
|
-
heartbeatToolResponse: attempt.heartbeatToolResponse,
|
|
3750
|
-
successfulCronAdds: attempt.successfulCronAdds,
|
|
3751
|
-
acceptedSessionSpawns: attempt.acceptedSessionSpawns
|
|
3752
|
-
};
|
|
3753
|
-
}
|
|
3754
|
-
} finally {
|
|
3755
|
-
forgetPromptBuildDrainCacheForRun(params.runId);
|
|
3756
|
-
stopRuntimeAuthRefreshTimer();
|
|
3757
|
-
await runAgentCleanupStep({
|
|
3758
|
-
runId: params.runId,
|
|
3759
|
-
sessionId: params.sessionId,
|
|
3760
|
-
step: "context-engine-dispose",
|
|
3761
|
-
log: log$1,
|
|
3762
|
-
cleanup: async () => {
|
|
3763
|
-
await contextEngine.dispose?.();
|
|
3764
|
-
}
|
|
3765
|
-
});
|
|
3766
|
-
if (params.cleanupBundleMcpOnRunEnd === true) await runAgentCleanupStep({
|
|
3767
|
-
runId: params.runId,
|
|
3768
|
-
sessionId: params.sessionId,
|
|
3769
|
-
step: "bundle-mcp-retire",
|
|
3770
|
-
log: log$1,
|
|
3771
|
-
cleanup: async () => {
|
|
3772
|
-
const onError = (error, sessionId) => {
|
|
3773
|
-
log$1.warn(`bundle-mcp cleanup failed after run for ${sessionId}: ${formatErrorMessage(error)}`);
|
|
3774
|
-
};
|
|
3775
|
-
if (!await retireSessionMcpRuntimeForSessionKey({
|
|
3776
|
-
sessionKey: params.sessionKey,
|
|
3777
|
-
reason: "embedded-run-end",
|
|
3778
|
-
onError
|
|
3779
|
-
})) await retireSessionMcpRuntime({
|
|
3780
|
-
sessionId: params.sessionId,
|
|
3781
|
-
reason: "embedded-run-end",
|
|
3782
|
-
onError
|
|
3783
|
-
});
|
|
3784
|
-
}
|
|
3785
|
-
});
|
|
3786
|
-
}
|
|
3787
|
-
});
|
|
3788
|
-
});
|
|
3789
|
-
}
|
|
3790
|
-
function resolveAuthProfileStateProvider(store, profileId, fallbackProvider) {
|
|
3791
|
-
const profileProvider = store.profiles?.[profileId]?.provider?.trim();
|
|
3792
|
-
if (profileProvider) return profileProvider;
|
|
3793
|
-
return profileId.split(":", 1)[0]?.trim() || fallbackProvider;
|
|
3794
|
-
}
|
|
3795
|
-
//#endregion
|
|
3796
|
-
export { compactEmbeddedPiSession as n, runEmbeddedPiAgent as t };
|