kaijibot 2026.8.20 → 2026.8.21
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/.buildstamp +1 -1
- package/dist/abort-BA4i4CO6.js +202 -0
- package/dist/abort-cutoff.runtime-140Dy9Z_.js +20 -0
- package/dist/abort-cutoff.runtime.js +1 -1
- package/dist/abort-primitives-DqU6syXA.js +93 -0
- package/dist/abort.runtime-D2xd_Jxq.js +2 -0
- package/dist/abort.runtime.js +1 -1
- package/dist/account-action-gate-w2MQyrck.js +114 -0
- package/dist/acp-cli-lUerPOt4.js +2171 -0
- package/dist/acp-spawn-CKu5HWZd.js +1024 -0
- package/dist/acp-stateful-target-driver-DNcDMame.js +88 -0
- package/dist/action-agents-bNO5zlxQ.js +67 -0
- package/dist/action-focus-BQH1yzA9.js +124 -0
- package/dist/action-help-Copk6G3d.js +7 -0
- package/dist/action-info-BUV_zoSU.js +58 -0
- package/dist/action-kill-BMDz9l_U.js +33 -0
- package/dist/action-list-CxkulhYF.js +21 -0
- package/dist/action-log-D0K9-YCV.js +30 -0
- package/dist/action-send-B8ggJVwC.js +39 -0
- package/dist/action-spawn-D9kSXA_K.js +46 -0
- package/dist/action-unfocus-bI4VBonB.js +28 -0
- package/dist/agent-CdxQT19_.js +2 -0
- package/dist/agent-command-Bu_cXSEL.js +1479 -0
- package/dist/agent-list-CPYyofv7.js +67 -0
- package/dist/agent-runner-utils--p6HAP6k.js +202 -0
- package/dist/agent-runner.runtime-BossnlL1.js +2825 -0
- package/dist/agent-runner.runtime.js +1 -1
- package/dist/agents/auth-profiles.runtime.js +1 -1
- package/dist/agents/model-catalog.runtime.js +1 -1
- package/dist/agents/models-config.runtime.js +1 -1
- package/dist/agents/pi-model-discovery-runtime.js +1 -1
- package/dist/agents-DA2-qNUI.js +887 -0
- package/dist/agents-DaKVGj9F.js +5 -0
- package/dist/allow-from-p586L6ne.js +164 -0
- package/dist/anthropic-cache-control-payload-N8EtT94O.js +28 -0
- package/dist/anthropic-payload-policy-D6dpwqVe.js +136 -0
- package/dist/anthropic-vertex-stream-CrF-fPgb.js +5666 -0
- package/dist/api-BPByI3-X.js +2 -0
- package/dist/api-BvFPt7b2.js +19 -0
- package/dist/api-C6IdzdoP.js +5 -0
- package/dist/api-CSOm-O9I.js +5 -0
- package/dist/api-ChQfiSmG.js +4 -0
- package/dist/api-Cm3n-2Iw.js +3 -0
- package/dist/api-CqBQhm6r.js +2 -0
- package/dist/api-D7SjdU34.js +4 -0
- package/dist/api-D7qSjVDS.js +3 -0
- package/dist/api-DbRoXBTn.js +45 -0
- package/dist/api-_HshnS5J.js +35 -0
- package/dist/apply-G86rau7x.js +493 -0
- package/dist/apply.runtime-BoYc09wu.js +166 -0
- package/dist/apply.runtime-Dmh02lO-.js +2 -0
- package/dist/apply.runtime.js +1 -1
- package/dist/approval-gateway-resolver-bdX78er-.js +58 -0
- package/dist/approval-gateway-runtime-CJm68vrp.js +2 -0
- package/dist/approval-handler-runtime-CT08B2_a.js +439 -0
- package/dist/approval-native-helpers-DagoPLtW.js +33 -0
- package/dist/approval-native-runtime-CN4meUkM.js +709 -0
- package/dist/approval-renderers-CnmO8wke.js +64 -0
- package/dist/asr-Cz-FH-3c.js +196 -0
- package/dist/audit-Cbfv4nmn.js +885 -0
- package/dist/audit-extra.async-DQv_s9K0.js +847 -0
- package/dist/audit.deep.runtime-CAPtrWg1.js +2 -0
- package/dist/audit.deep.runtime.js +1 -1
- package/dist/audit.nondeep.runtime-HUJ6INiD.js +859 -0
- package/dist/audit.nondeep.runtime.js +1 -1
- package/dist/audit.runtime-CAKbHyXK.js +7 -0
- package/dist/audit.runtime.js +1 -1
- package/dist/auth-CRAwpkC_.js +181 -0
- package/dist/auth-choice-Bhps2D29.js +3 -0
- package/dist/auth-choice-kMIs0xTd.js +71 -0
- package/dist/auth-choice-vRXPONqL.js +353 -0
- package/dist/auth-choice.apply-helpers-D6x2bWVB.js +2 -0
- package/dist/auth-profiles.runtime.js +1 -1
- package/dist/binding-routing-C6_mrNEN.js +50 -0
- package/dist/binding-targets-Cq2e7wRT.js +99 -0
- package/dist/block-streaming-BTtPFYsM.js +103 -0
- package/dist/bootstrap-files-DsmC0cJP.js +206 -0
- package/dist/bridge-server-Co3awCAM.js +103 -0
- package/dist/browser-node-runtime-D8xut4fJ.js +12 -0
- package/dist/browser-open-BzpYLaas.js +94 -0
- package/dist/browser-runtime-BBkGI01q.js +377 -0
- package/dist/browser-security-runtime-CzhzXJ8D.js +10 -0
- package/dist/browser-setup-tools-CD_s48fd.js +12 -0
- package/dist/btw-command-Bgn_NviR.js +17 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +4 -4
- package/dist/bundled/session-memory/handler.js +3 -3
- package/dist/call-CiUZqjsN.js +2 -0
- package/dist/call-k_nZXTJ3.js +495 -0
- package/dist/call.runtime-CZI7yxSF.js +2 -0
- package/dist/call.runtime.js +1 -1
- package/dist/capability-cli-CIm_YhHH.js +1357 -0
- package/dist/catalog-provider-Ch4CMHLl.js +40 -0
- package/dist/cdp.helpers-BVl3YwYe.js +372 -0
- package/dist/channel-config-helpers-BO9yY1Zu.js +462 -0
- package/dist/channel-core-BB7pTANC.js +5 -0
- package/dist/channel-feedback-c7a-Gb7w.js +259 -0
- package/dist/channel-plugin-resolution-DHgXIZV6.js +146 -0
- package/dist/channel-policy-DO-ZWErE.js +270 -0
- package/dist/channel-reply-pipeline-2KImYC85.js +26 -0
- package/dist/channel-runtime-Bqn7zFyT.js +6 -0
- package/dist/channel.runtime-2WY9MkoH.js +399 -0
- package/dist/channel.runtime.js +1 -1
- package/dist/channels-D66hRVnR.js +1147 -0
- package/dist/channels-cli-0DjAVaKh.js +248 -0
- package/dist/chat-Fv3LkEfF.js +213 -0
- package/dist/chat-history-text-CZhwQ5__.js +42 -0
- package/dist/chrome-CEE9kYYR.js +1080 -0
- package/dist/chrome.executables-Dp7W-RgV.js +550 -0
- package/dist/chunk-B9X-O7Vw.js +267 -0
- package/dist/clack-prompter-BSVVLa7H.js +113 -0
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/cli-BsNkLoFI.js +57 -0
- package/dist/cli-DQH9X5IE.js +2 -0
- package/dist/cli-DuoVlLKx.js +154 -0
- package/dist/cli-auth-seam-BrijKBRQ.js +14 -0
- package/dist/cli-backend-CIs4F7ip.js +66 -0
- package/dist/cli-migration-CVktTGRI.js +127 -0
- package/dist/cli-runner-12iECISR.js +1662 -0
- package/dist/cli-runner.runtime-C5noDuQ-.js +3 -0
- package/dist/cli-runner.runtime-YrAg_h19.js +2 -0
- package/dist/cli-runner.runtime.js +1 -1
- package/dist/cli-runtime-wB1rYZco.js +3 -0
- package/dist/cli-shared-BUW2okV2.js +142 -0
- package/dist/cli-startup-metadata.json +1 -1
- package/dist/cli.runtime-Bhxt80sB.js +819 -0
- package/dist/cli.runtime.js +1 -1
- package/dist/client-bootstrap-BWo-ZK_j.js +28 -0
- package/dist/command-auth-Dlrd5CYD.js +75 -0
- package/dist/command-config-resolution-B8pxzh3W.js +2 -0
- package/dist/command-config-resolution-BXSCDJTh.js +23 -0
- package/dist/command-detection-DFlZHBMC.js +50 -0
- package/dist/command-execution-startup-DYXpKpvc.js +269 -0
- package/dist/command-format-JYoGhCek.js +2 -0
- package/dist/command-registry-BF51N12E.js +3 -0
- package/dist/command-registry-BqpfCBbW.js +113 -0
- package/dist/command-secret-gateway-DuuctECr.js +528 -0
- package/dist/command-status-builders-CnD1rvYb.js +145 -0
- package/dist/commands-acp-DiLJUV45.js +1017 -0
- package/dist/commands-compact.runtime-BOM8PsWH.js +10 -0
- package/dist/commands-compact.runtime.js +1 -1
- package/dist/commands-context-C-jRwdK3.js +34 -0
- package/dist/commands-core.runtime-CH_aGeT-.js +2 -0
- package/dist/commands-core.runtime.js +1 -1
- package/dist/commands-handlers.runtime-Ca6xoeW5.js +3762 -0
- package/dist/commands-handlers.runtime.js +1 -1
- package/dist/commands-models-CRURuXR-.js +306 -0
- package/dist/commands-registry-CJw_6JDj.js +295 -0
- package/dist/commands-registry.runtime-78mbU8Il.js +2 -0
- package/dist/commands-registry.runtime.js +1 -1
- package/dist/commands-reset-hooks-D3RzsOIn.js +129 -0
- package/dist/commands-status-Cufj4x2j.js +223 -0
- package/dist/commands-status.runtime-C8Nz4Glk.js +2 -0
- package/dist/commands-status.runtime.js +1 -1
- package/dist/commands-subagents-control.runtime-DjhcmoRT.js +3 -0
- package/dist/commands-subagents-control.runtime-s_DYQWfW.js +2 -0
- package/dist/commands-subagents-control.runtime.js +1 -1
- package/dist/commands.runtime-ChfYOBeV.js +103 -0
- package/dist/commands.runtime.js +1 -1
- package/dist/comment-shared-DFEZzqhH.js +40 -0
- package/dist/compact-DEsHFhEL.js +11324 -0
- package/dist/compact.runtime-BzLFUSmk.js +7 -0
- package/dist/compact.runtime.js +1 -1
- package/dist/completion-cli-CiWtzUFQ.js +2 -0
- package/dist/completion-cli-h3zgpXGM.js +468 -0
- package/dist/config-Bd1PtH4x.js +166 -0
- package/dist/config-cli-BiEmyiRa.js +948 -0
- package/dist/config-defaults-Bw9wwyo1.js +163 -0
- package/dist/config-guard-BGGjXg_Y.js +94 -0
- package/dist/config-runtime-Bvdi0W59.js +14 -0
- package/dist/config-validation-BDeuMlc1.js +279 -0
- package/dist/configure-CUSDnrHs.js +2 -0
- package/dist/configure-FDqT3i_9.js +1162 -0
- package/dist/connection-auth-7izNv08V.js +30 -0
- package/dist/context-B2wCjR9D.js +249 -0
- package/dist/context-n8ANhlMJ.js +2 -0
- package/dist/context-visibility-d6FHLhsq.js +14 -0
- package/dist/context-writer-COhxMkVz.js +290 -0
- package/dist/control-auth-Csa4b5CR.js +122 -0
- package/dist/control-ui-links-tILfT2Ek.js +70 -0
- package/dist/conversation-id-d7KXWjzV.js +140 -0
- package/dist/conversation-runtime-D-YmpVS2.js +31 -0
- package/dist/core-8TPCsNB-.js +210 -0
- package/dist/cron-cli-C5ok2iVK.js +637 -0
- package/dist/daemon-cli-Cr_y38yv.js +476 -0
- package/dist/daemon-install-CrhzPiZ-.js +70 -0
- package/dist/delegate-r3VqUt34.js +61 -0
- package/dist/deliver-Cuu36rnv.js +3 -0
- package/dist/deliver-SAyi_F0e.js +782 -0
- package/dist/deliver-runtime-DKv9J6QE.js +2 -0
- package/dist/delivery-outbound.runtime-DDoInTnF.js +6 -0
- package/dist/delivery-outbound.runtime.js +1 -1
- package/dist/delivery-queue-CWi3kUit.js +372 -0
- package/dist/delivery-queue-ecSu6ZNL.js +2 -0
- package/dist/device-bootstrap---geQnCr.js +4 -0
- package/dist/device-bootstrap-BEWox6at.js +248 -0
- package/dist/device-bootstrap-profile-BR1NnTGX.js +36 -0
- package/dist/device-identity-huL1Exh1.js +2 -0
- package/dist/device-pairing-DSkkI5A-.js +600 -0
- package/dist/devices-cli-BUAuMOOj.js +336 -0
- package/dist/diagnostics-Bh0Gbi4L.js +33 -0
- package/dist/diagnostics-BsUG_otQ.js +2 -0
- package/dist/direct-dm-D_7_vKGq.js +139 -0
- package/dist/directive-handling.fast-lane-C91i_iZm.js +2 -0
- package/dist/directive-handling.fast-lane-F7l0XNwG.js +64 -0
- package/dist/directive-handling.impl-8RAWZiZE.js +659 -0
- package/dist/directive-handling.impl-BxAIWFS-.js +2 -0
- package/dist/directive-handling.parse-B3O0CfXY.js +376 -0
- package/dist/directive-handling.persist-QXt7GHcD.js +139 -0
- package/dist/directive-handling.persist.runtime-CPPm2qYQ.js +2 -0
- package/dist/directive-handling.persist.runtime.js +1 -1
- package/dist/directive-handling.shared-C5ywsGJd.js +159 -0
- package/dist/directory-cli-D9v1dSPr.js +240 -0
- package/dist/dispatch-DoyBs65s.js +1126 -0
- package/dist/dispatch-acp-Dz8rU6t9.js +969 -0
- package/dist/dispatch-acp-command-bypass-CJ5xdqXR.js +38 -0
- package/dist/dispatch-acp-manager.runtime-tPUGDjl3.js +3 -0
- package/dist/dispatch-acp-manager.runtime.js +1 -1
- package/dist/dispatch-acp-media.runtime-rwYN3ewY.js +3 -0
- package/dist/dispatch-acp-media.runtime.js +1 -1
- package/dist/dispatch-acp-session.runtime-C9nyGih8.js +2 -0
- package/dist/dispatch-acp-session.runtime.js +1 -1
- package/dist/dispatch-acp.runtime-Co-JFuKU.js +19 -0
- package/dist/dispatch-acp.runtime.js +1 -1
- package/dist/docker-TZx6u2PT.js +826 -0
- package/dist/doctor-completion-C46W5KI7.js +90 -0
- package/dist/doctor-config-preflight-B_UDrFsE.js +148 -0
- package/dist/doctor-config-preflight-DtvhOeuT.js +2 -0
- package/dist/doctor-state-migrations-Cd3yfnI1.js +2 -0
- package/dist/doctor-state-migrations-D3qorqjy.js +3 -0
- package/dist/drive-C2mxxJx5.js +718 -0
- package/dist/embedding-provider-C5S1sxvR.js +129 -0
- package/dist/embedding-provider-CNDA2uD3.js +26 -0
- package/dist/embedding-provider-CdVS1B85.js +33 -0
- package/dist/engine-CKgZ1obQ.js +82 -0
- package/dist/engine-embeddings-Bt1bTxtw.js +1489 -0
- package/dist/entry-capabilities-DrciJZn1.js +89 -0
- package/dist/entry.js +1 -1
- package/dist/exec-approval-forwarder.runtime-Dpa8Gi_P.js +3 -0
- package/dist/exec-approval-forwarder.runtime.js +1 -1
- package/dist/exec-approval-session-target-BYtddDF5.js +165 -0
- package/dist/exec-approvals-cli-BuOJPaPp.js +485 -0
- package/dist/exec-defaults-B5egc-6t.js +1440 -0
- package/dist/extensionAPI.js +5 -5
- package/dist/extensions/alibaba/index.js +1 -1
- package/dist/extensions/alibaba/video-generation-provider.js +1 -1
- package/dist/extensions/anthropic/api.js +2 -2
- package/dist/extensions/anthropic/cli-auth-seam.js +1 -1
- package/dist/extensions/anthropic/cli-backend-api.js +2 -2
- package/dist/extensions/anthropic/cli-backend.js +1 -1
- package/dist/extensions/anthropic/cli-migration.js +1 -1
- package/dist/extensions/anthropic/cli-shared.js +1 -1
- package/dist/extensions/anthropic/config-defaults.js +1 -1
- package/dist/extensions/anthropic/contract-api.js +1 -1
- package/dist/extensions/anthropic/index.js +1 -1
- package/dist/extensions/anthropic/media-understanding-provider.js +1 -1
- package/dist/extensions/anthropic/provider-policy-api.js +1 -1
- package/dist/extensions/anthropic/register.runtime.js +1 -1
- package/dist/extensions/anthropic/replay-policy.js +1 -1
- package/dist/extensions/anthropic/setup-api.js +1 -1
- package/dist/extensions/anthropic/stream-wrappers.js +1 -1
- package/dist/extensions/anthropic/test-api.js +3 -3
- package/dist/extensions/anthropic-vertex/api.js +3 -3
- package/dist/extensions/anthropic-vertex/index.js +3 -3
- package/dist/extensions/anthropic-vertex/provider-catalog.js +1 -1
- package/dist/extensions/anthropic-vertex/region.js +1 -1
- package/dist/extensions/anthropic-vertex/setup-api.js +1 -1
- package/dist/extensions/arcee/index.js +4 -4
- package/dist/extensions/browser/browser-bridge.js +1 -1
- package/dist/extensions/browser/browser-cdp.js +1 -1
- package/dist/extensions/browser/browser-config.js +4 -4
- package/dist/extensions/browser/browser-control-auth.js +1 -1
- package/dist/extensions/browser/browser-doctor.js +5 -5
- package/dist/extensions/browser/browser-host-inspection.js +1 -1
- package/dist/extensions/browser/browser-maintenance.js +2 -2
- package/dist/extensions/browser/browser-profiles.js +2 -2
- package/dist/extensions/browser/browser-runtime-api.js +12 -12
- package/dist/extensions/browser/index.js +1 -1
- package/dist/extensions/browser/plugin-registration.js +1 -1
- package/dist/extensions/browser/register.runtime.js +3 -3
- package/dist/extensions/browser/runtime-api.js +13 -13
- package/dist/extensions/browser/setup-api.js +2 -2
- package/dist/extensions/browser/test-support.js +1 -1
- package/dist/extensions/byteplus/index.js +3 -3
- package/dist/extensions/byteplus/video-generation-provider.js +1 -1
- package/dist/extensions/cerebras/index.js +1 -1
- package/dist/extensions/chutes/api.js +3 -3
- package/dist/extensions/chutes/index.js +9 -9
- package/dist/extensions/chutes/models.js +1 -1
- package/dist/extensions/chutes/onboard.js +2 -2
- package/dist/extensions/chutes/provider-catalog.js +1 -1
- package/dist/extensions/cloudflare-ai-gateway/api.js +1 -1
- package/dist/extensions/cloudflare-ai-gateway/catalog-provider.js +1 -1
- package/dist/extensions/cloudflare-ai-gateway/index.js +4 -4
- package/dist/extensions/deepinfra/api.js +8 -8
- package/dist/extensions/deepinfra/embedding-provider.js +2 -2
- package/dist/extensions/deepinfra/image-generation-provider.js +1 -1
- package/dist/extensions/deepinfra/index.js +9 -9
- package/dist/extensions/deepinfra/media-models.js +2 -2
- package/dist/extensions/deepinfra/media-understanding-provider.js +1 -1
- package/dist/extensions/deepinfra/memory-embedding-adapter.js +1 -1
- package/dist/extensions/deepinfra/onboard.js +2 -2
- package/dist/extensions/deepinfra/provider-catalog.js +1 -1
- package/dist/extensions/deepinfra/provider-models.js +1 -1
- package/dist/extensions/deepinfra/speech-provider.js +1 -1
- package/dist/extensions/deepinfra/video-generation-provider.js +1 -1
- package/dist/extensions/deepseek/index.js +3 -3
- package/dist/extensions/device-pair/api.js +6 -6
- package/dist/extensions/device-pair/index.js +9 -9
- package/dist/extensions/device-pair/notify.js +1 -1
- package/dist/extensions/device-pair/pair-command-approve.js +1 -1
- package/dist/extensions/device-pair/qr-image.js +2 -2
- package/dist/extensions/diffs/.kaijibot-runtime-deps-stamp.json +1 -1
- package/dist/extensions/diffs/index.js +1 -1
- package/dist/extensions/exa/index.js +4 -4
- package/dist/extensions/feishu/.kaijibot-runtime-deps-stamp.json +1 -1
- package/dist/extensions/feishu/api.js +21 -21
- package/dist/extensions/feishu/contract-api.js +2 -2
- package/dist/extensions/feishu/runtime-api.js +4 -4
- package/dist/extensions/feishu/security-contract-api.js +1 -1
- package/dist/extensions/feishu/session-key-api.js +1 -1
- package/dist/extensions/feishu/setup-api.js +1 -1
- package/dist/extensions/fireworks/index.js +4 -4
- package/dist/extensions/fireworks/stream.js +1 -1
- package/dist/extensions/github-copilot/api.js +1 -1
- package/dist/extensions/github-copilot/index.js +5 -5
- package/dist/extensions/github-copilot/login.js +1 -1
- package/dist/extensions/github-copilot/models-defaults.js +1 -1
- package/dist/extensions/github-copilot/models.js +1 -1
- package/dist/extensions/github-copilot/register.runtime.js +4 -4
- package/dist/extensions/github-copilot/replay-policy.js +1 -1
- package/dist/extensions/github-copilot/stream.js +1 -1
- package/dist/extensions/google/api.js +1 -1
- package/dist/extensions/google/gemini-cli-provider.js +1 -1
- package/dist/extensions/google/image-generation-provider.js +1 -1
- package/dist/extensions/google/index.js +5 -5
- package/dist/extensions/google/media-understanding-provider.js +1 -1
- package/dist/extensions/google/music-generation-provider.js +1 -1
- package/dist/extensions/google/oauth-token-shared.js +1 -1
- package/dist/extensions/google/oauth.credentials.js +1 -1
- package/dist/extensions/google/oauth.flow.js +1 -1
- package/dist/extensions/google/oauth.http.js +1 -1
- package/dist/extensions/google/oauth.js +2 -2
- package/dist/extensions/google/oauth.project.js +1 -1
- package/dist/extensions/google/oauth.runtime.js +1 -1
- package/dist/extensions/google/oauth.settings.js +1 -1
- package/dist/extensions/google/oauth.token.js +1 -1
- package/dist/extensions/google/provider-models.js +1 -1
- package/dist/extensions/google/provider-registration.js +1 -1
- package/dist/extensions/google/runtime-api.js +2 -2
- package/dist/extensions/google/test-api.js +2 -2
- package/dist/extensions/google/video-generation-provider.js +1 -1
- package/dist/extensions/google/web-search-contract-api.js +1 -1
- package/dist/extensions/google/web-search-provider.js +1 -1
- package/dist/extensions/gradium/index.js +1 -1
- package/dist/extensions/gradium/speech-provider.js +1 -1
- package/dist/extensions/gradium/tts.js +1 -1
- package/dist/extensions/groq/index.js +1 -1
- package/dist/extensions/groq/media-understanding-provider.js +1 -1
- package/dist/extensions/groq/test-api.js +1 -1
- package/dist/extensions/huggingface/api.js +3 -3
- package/dist/extensions/huggingface/index.js +3 -3
- package/dist/extensions/huggingface/models.js +1 -1
- package/dist/extensions/huggingface/onboard.js +1 -1
- package/dist/extensions/huggingface/provider-catalog.js +2 -2
- package/dist/extensions/image-generation-core/api.js +2 -2
- package/dist/extensions/image-generation-core/runtime-api.js +2 -2
- package/dist/extensions/kilocode/api.js +2 -2
- package/dist/extensions/kilocode/index.js +8 -8
- package/dist/extensions/kilocode/onboard.js +2 -2
- package/dist/extensions/kilocode/provider-catalog.js +1 -1
- package/dist/extensions/kilocode/provider-models.js +1 -1
- package/dist/extensions/kilocode/shared.js +1 -1
- package/dist/extensions/kimi-coding/index.js +4 -4
- package/dist/extensions/kindle-portal/.kaijibot-runtime-deps-stamp.json +1 -1
- package/dist/extensions/knowledge-wiki/index.js +2 -2
- package/dist/extensions/litellm/index.js +1 -1
- package/dist/extensions/llm-task/index.js +1 -1
- package/dist/extensions/lmstudio/api.js +4 -4
- package/dist/extensions/lmstudio/index.js +3 -3
- package/dist/extensions/lmstudio/runtime-api.js +1 -1
- package/dist/extensions/media-understanding-core/runtime-api.js +2 -2
- package/dist/extensions/memory-core/cli-metadata.js +2 -2
- package/dist/extensions/memory-core/index.js +12 -12
- package/dist/extensions/memory-core/manager-runtime.js +1 -1
- package/dist/extensions/memory-core/runtime-api.js +5 -5
- package/dist/extensions/memory-lancedb/cli-metadata.js +1 -1
- package/dist/extensions/memory-lancedb/index.js +3 -3
- package/dist/extensions/microsoft/index.js +1 -1
- package/dist/extensions/microsoft/speech-provider.js +1 -1
- package/dist/extensions/microsoft/test-api.js +1 -1
- package/dist/extensions/microsoft/tts.js +1 -1
- package/dist/extensions/microsoft-foundry/auth.js +1 -1
- package/dist/extensions/microsoft-foundry/cli.js +1 -1
- package/dist/extensions/microsoft-foundry/index.js +1 -1
- package/dist/extensions/microsoft-foundry/onboard.js +2 -2
- package/dist/extensions/microsoft-foundry/provider.js +1 -1
- package/dist/extensions/microsoft-foundry/runtime.js +1 -1
- package/dist/extensions/microsoft-foundry/shared-runtime.js +2 -2
- package/dist/extensions/microsoft-foundry/shared.js +1 -1
- package/dist/extensions/minimax/api.js +5 -5
- package/dist/extensions/minimax/image-generation-provider.js +1 -1
- package/dist/extensions/minimax/index.js +7 -7
- package/dist/extensions/minimax/media-understanding-provider.js +1 -1
- package/dist/extensions/minimax/model-definitions.js +1 -1
- package/dist/extensions/minimax/music-generation-provider.js +1 -1
- package/dist/extensions/minimax/oauth.js +1 -1
- package/dist/extensions/minimax/oauth.runtime.js +1 -1
- package/dist/extensions/minimax/onboard.js +1 -1
- package/dist/extensions/minimax/provider-catalog.js +1 -1
- package/dist/extensions/minimax/provider-models.js +1 -1
- package/dist/extensions/minimax/provider-registration.js +1 -1
- package/dist/extensions/minimax/speech-provider.js +1 -1
- package/dist/extensions/minimax/test-api.js +2 -2
- package/dist/extensions/minimax/video-generation-provider.js +1 -1
- package/dist/extensions/minimax/web-search-contract-api.js +1 -1
- package/dist/extensions/minimax/web-search-provider.js +1 -1
- package/dist/extensions/mistral/embedding-provider.js +1 -1
- package/dist/extensions/mistral/index.js +3 -3
- package/dist/extensions/mistral/media-understanding-provider.js +1 -1
- package/dist/extensions/mistral/memory-embedding-adapter.js +3 -3
- package/dist/extensions/mistral/provider-compat.js +1 -1
- package/dist/extensions/mistral/test-api.js +1 -1
- package/dist/extensions/moonshot/api.js +3 -3
- package/dist/extensions/moonshot/index.js +9 -9
- package/dist/extensions/moonshot/media-understanding-provider.js +1 -1
- package/dist/extensions/moonshot/onboard.js +1 -1
- package/dist/extensions/moonshot/provider-catalog.js +1 -1
- package/dist/extensions/moonshot/test-api.js +2 -2
- package/dist/extensions/moonshot/web-search-contract-api.js +1 -1
- package/dist/extensions/moonshot/web-search-provider.js +1 -1
- package/dist/extensions/nvidia/index.js +1 -1
- package/dist/extensions/ollama/api.js +4 -4
- package/dist/extensions/ollama/index.js +8 -8
- package/dist/extensions/ollama/provider-discovery.js +1 -1
- package/dist/extensions/ollama/runtime-api.js +2 -2
- package/dist/extensions/ollama/web-search-contract-api.js +1 -1
- package/dist/extensions/ollama/web-search-provider.js +1 -1
- package/dist/extensions/openai/api.js +3 -3
- package/dist/extensions/openai/image-generation-provider.js +1 -1
- package/dist/extensions/openai/index.js +9 -9
- package/dist/extensions/openai/media-understanding-provider.js +1 -1
- package/dist/extensions/openai/openai-codex-auth-identity.js +1 -1
- package/dist/extensions/openai/openai-codex-cli-auth.js +1 -1
- package/dist/extensions/openai/openai-codex-provider.js +1 -1
- package/dist/extensions/openai/openai-codex-provider.runtime.js +2 -2
- package/dist/extensions/openai/openai-codex-shared.js +1 -1
- package/dist/extensions/openai/openai-provider.js +1 -1
- package/dist/extensions/openai/prompt-overlay.js +1 -1
- package/dist/extensions/openai/realtime-provider-shared.js +1 -1
- package/dist/extensions/openai/realtime-transcription-provider.js +1 -1
- package/dist/extensions/openai/realtime-voice-provider.js +1 -1
- package/dist/extensions/openai/register.runtime.js +8 -8
- package/dist/extensions/openai/shared.js +3 -3
- package/dist/extensions/openai/speech-provider.js +1 -1
- package/dist/extensions/openai/test-api.js +5 -5
- package/dist/extensions/openai/transport-policy.js +1 -1
- package/dist/extensions/openai/video-generation-provider.js +1 -1
- package/dist/extensions/opencode/index.js +4 -4
- package/dist/extensions/opencode-go/index.js +3 -3
- package/dist/extensions/openrouter/api.js +2 -2
- package/dist/extensions/openrouter/image-generation-provider.js +1 -1
- package/dist/extensions/openrouter/index.js +8 -8
- package/dist/extensions/openrouter/media-understanding-provider.js +1 -1
- package/dist/extensions/openrouter/music-generation-provider.js +1 -1
- package/dist/extensions/openrouter/stream.js +1 -1
- package/dist/extensions/openrouter/test-api.js +3 -3
- package/dist/extensions/openrouter/video-generation-provider.js +6 -6
- package/dist/extensions/openrouter/video-http.js +1 -1
- package/dist/extensions/openrouter/video-model-catalog.js +1 -1
- package/dist/extensions/openshell/index.js +4 -4
- package/dist/extensions/perplexity/index.js +1 -1
- package/dist/extensions/perplexity/test-api.js +1 -1
- package/dist/extensions/perplexity/web-search-contract-api.js +1 -1
- package/dist/extensions/perplexity/web-search-provider.js +1 -1
- package/dist/extensions/qianfan/index.js +1 -1
- package/dist/extensions/qwen/api.js +4 -4
- package/dist/extensions/qwen/index.js +8 -8
- package/dist/extensions/qwen/media-understanding-provider.js +1 -1
- package/dist/extensions/qwen/model-definitions.js +1 -1
- package/dist/extensions/qwen/models.js +1 -1
- package/dist/extensions/qwen/onboard.js +1 -1
- package/dist/extensions/qwen/provider-catalog.js +1 -1
- package/dist/extensions/qwen/stream.js +1 -1
- package/dist/extensions/qwen/test-api.js +2 -2
- package/dist/extensions/qwen/video-generation-provider.js +1 -1
- package/dist/extensions/runway/index.js +1 -1
- package/dist/extensions/runway/video-generation-provider.js +1 -1
- package/dist/extensions/sherpa-speech/asr.js +1 -1
- package/dist/extensions/sherpa-speech/engine.js +1 -1
- package/dist/extensions/sherpa-speech/index.js +1 -1
- package/dist/extensions/speech-core/api.js +3 -3
- package/dist/extensions/speech-core/runtime-api.js +5 -5
- package/dist/extensions/stepfun/index.js +2 -2
- package/dist/extensions/talk-voice/index.js +2 -2
- package/dist/extensions/tavily/index.js +5 -5
- package/dist/extensions/together/index.js +1 -1
- package/dist/extensions/together/video-generation-provider.js +4 -4
- package/dist/extensions/venice/api.js +3 -3
- package/dist/extensions/venice/index.js +6 -6
- package/dist/extensions/venice/models.js +1 -1
- package/dist/extensions/venice/onboard.js +2 -2
- package/dist/extensions/venice/provider-catalog.js +1 -1
- package/dist/extensions/vercel-ai-gateway/api.js +2 -2
- package/dist/extensions/vercel-ai-gateway/index.js +2 -2
- package/dist/extensions/vercel-ai-gateway/models.js +1 -1
- package/dist/extensions/vercel-ai-gateway/provider-catalog.js +1 -1
- package/dist/extensions/volcengine/index.js +2 -2
- package/dist/extensions/vydra/image-generation-provider.js +1 -1
- package/dist/extensions/vydra/index.js +5 -5
- package/dist/extensions/vydra/shared.js +1 -1
- package/dist/extensions/vydra/speech-provider.js +1 -1
- package/dist/extensions/vydra/video-generation-provider.js +1 -1
- package/dist/extensions/webhooks/.kaijibot-runtime-deps-stamp.json +1 -1
- package/dist/extensions/webhooks/api.js +1 -1
- package/dist/extensions/webhooks/index.js +4 -4
- package/dist/extensions/webhooks/runtime-api.js +1 -1
- package/dist/extensions/wechat/api.js +3 -3
- package/dist/extensions/xai/api.js +6 -6
- package/dist/extensions/xai/code-execution.js +5 -5
- package/dist/extensions/xai/index.js +14 -14
- package/dist/extensions/xai/model-definitions.js +1 -1
- package/dist/extensions/xai/onboard.js +1 -1
- package/dist/extensions/xai/provider-catalog.js +1 -1
- package/dist/extensions/xai/provider-models.js +1 -1
- package/dist/extensions/xai/setup-api.js +1 -1
- package/dist/extensions/xai/stream.js +1 -1
- package/dist/extensions/xai/video-generation-provider.js +1 -1
- package/dist/extensions/xai/web-search-contract-api.js +1 -1
- package/dist/extensions/xai/web-search.js +1 -1
- package/dist/extensions/xai/x-search.js +5 -5
- package/dist/extensions/xiaomi/index.js +1 -1
- package/dist/extensions/zai/index.js +7 -7
- package/dist/extensions/zai/media-understanding-provider.js +1 -1
- package/dist/extensions/zai/test-api.js +1 -1
- package/dist/extra-params-Bfdm7Piq.js +295 -0
- package/dist/fetch-4HO0k3hc.js +65 -0
- package/dist/fetch-guard-BWtRcc5b.js +224 -0
- package/dist/fetch-jNI8hIPZ.js +256 -0
- package/dist/format-KzNAm6y6.js +245 -0
- package/dist/fragment-collector-DEW1fwlc.js +189 -0
- package/dist/gateway-CR7RtTbI.js +2 -0
- package/dist/gateway-CuQC7wph.js +119 -0
- package/dist/gateway-cli-CWHsIpm8.js +1532 -0
- package/dist/gateway-install-token-CcpoWcqs.js +284 -0
- package/dist/gateway-lock-B4umteJZ.js +238 -0
- package/dist/gateway-rpc-Do_3fQSm.js +14 -0
- package/dist/gateway-rpc.runtime-C4kzyrJj.js +23 -0
- package/dist/gateway-rpc.runtime.js +1 -1
- package/dist/gemini-cli-provider-YULRMcs8.js +106 -0
- package/dist/gemini-web-search-provider-D_QJZMM3.js +167 -0
- package/dist/get-reply-from-config.runtime-BpdriKtr.js +2 -0
- package/dist/get-reply-from-config.runtime.js +1 -1
- package/dist/group-policy-BxTxJeKP.js +202 -0
- package/dist/health-B5YmS_bW.js +2 -0
- package/dist/health-CQ4zXQ-2.js +579 -0
- package/dist/heartbeat-B1UJqney.js +184 -0
- package/dist/heartbeat-runner--rVDmB2Z.js +1365 -0
- package/dist/heartbeat-runner-CwtXIPI-.js +4 -0
- package/dist/heartbeat-runner.runtime-D_5UeAsX.js +2 -0
- package/dist/heartbeat-runner.runtime.js +1 -1
- package/dist/heartbeat-summary-Cf17FCYf.js +58 -0
- package/dist/heartbeat-visibility-BpEZ4Xf-.js +86 -0
- package/dist/hooks-cli-BGDBJqzt.js +364 -0
- package/dist/identity-Bwhl61jK.js +30 -0
- package/dist/identity-avatar-Bu5l4dFW.js +87 -0
- package/dist/image-DiK7kcmJ.js +152 -0
- package/dist/image-generation-core-Cwutmg_V.js +17 -0
- package/dist/image-generation-core.auth.runtime-DA7XD5V2.js +2 -0
- package/dist/image-generation-core.auth.runtime.js +1 -1
- package/dist/image-generation-provider-B-0SxnvJ.js +280 -0
- package/dist/image-generation-provider-B-UW3NU_.js +94 -0
- package/dist/image-generation-provider-BR1_oIU4.js +130 -0
- package/dist/image-generation-provider-BvAaZO7K.js +86 -0
- package/dist/image-generation-provider-CnGMLnE9.js +163 -0
- package/dist/image-generation-provider-DHvw6TSJ.js +136 -0
- package/dist/image-generation-runtime-DCWf9P6F.js +2 -0
- package/dist/image-runtime-DGNzvqkb.js +7 -0
- package/dist/images-BwT2L5zh.js +586 -0
- package/dist/inbound-reply-dispatch-DgEqNffL.js +73 -0
- package/dist/inbound.runtime-CloYEZJO.js +4 -0
- package/dist/inbound.runtime-DLbKJWOY.js +3 -0
- package/dist/inbound.runtime.js +1 -1
- package/dist/index.js +2 -2
- package/dist/infra-runtime-DE-Vi3Dn.js +25 -0
- package/dist/ingest-DbZJju1a.js +842 -0
- package/dist/ingest-Dyj9M3ZM.js +2 -0
- package/dist/input-files-tzSehEsO.js +252 -0
- package/dist/inspect-_4i1jBjC.js +2 -0
- package/dist/inspect-dprTBmSB.js +282 -0
- package/dist/issue-format-CoEMThLD.js +2 -0
- package/dist/kaijibot-tools-Df_9YJcO.js +9434 -0
- package/dist/kaijibot-tools.runtime-CZId-V1O.js +2 -0
- package/dist/kaijibot-tools.runtime.js +1 -1
- package/dist/kill-tree-DerqhtJm.js +2 -0
- package/dist/kimi-web-search-provider-DunVVASJ.js +308 -0
- package/dist/launchd-Bh7KL8au.js +556 -0
- package/dist/library-BqMFzJMy.js +45 -0
- package/dist/lifecycle-core-DD_IXtH-.js +422 -0
- package/dist/list.runtime-DU0ctAjd.js +12 -0
- package/dist/list.runtime-DXWlaAJq.js +9 -0
- package/dist/list.runtime.js +1 -1
- package/dist/llm-engine-CMR9RxLA.js +1792 -0
- package/dist/llm-engine-VKRjaGY_.js +2 -0
- package/dist/llm-extractor-BCPvoWmb.js +445 -0
- package/dist/llm-slug-generator.js +2 -2
- package/dist/login-Dex1JqnY.js +108 -0
- package/dist/logs-cli-BZFJyrsk.js +264 -0
- package/dist/logs-cli.runtime-bBS2Sbi6.js +2 -0
- package/dist/logs-cli.runtime.js +1 -1
- package/dist/manager-BmS2ofc4.js +2049 -0
- package/dist/manager-CabVEPeE.js +3314 -0
- package/dist/markdown-tables-DyVly8kN.js +51 -0
- package/dist/mcp-cli-DGrmbpsu.js +733 -0
- package/dist/media-models-Dw0Y1LxG.js +49 -0
- package/dist/media-runtime-CAa8uHqv.js +312 -0
- package/dist/media-understanding-D_VRj6xY.js +83 -0
- package/dist/media-understanding-provider-B9Jfjq6L.js +13 -0
- package/dist/media-understanding-provider-BWksuEBw.js +30 -0
- package/dist/media-understanding-provider-Bhtq5Kpe.js +14 -0
- package/dist/media-understanding-provider-BzsmDAMk.js +67 -0
- package/dist/media-understanding-provider-C6_6yxvP.js +123 -0
- package/dist/media-understanding-provider-CdRlAb9s.js +18 -0
- package/dist/media-understanding-provider-D5m-2RW8.js +21 -0
- package/dist/media-understanding-provider-PmVmfI6p.js +112 -0
- package/dist/media-understanding-provider-cmLTPd8x.js +18 -0
- package/dist/media-understanding-provider-nPxfFv8l.js +37 -0
- package/dist/media-understanding-provider-yp9gxov6.js +69 -0
- package/dist/media-understanding-runtime-Bu7m-lVs.js +2 -0
- package/dist/memory-5jlpYBqx.js +242 -0
- package/dist/memory-BFKl6oSn.js +3 -0
- package/dist/memory-core-host-engine-embeddings-p06288xV.js +2 -0
- package/dist/memory-core-host-runtime-cli-BnvAiNzO.js +9 -0
- package/dist/memory-core-host-runtime-core-CnVg69Uw.js +8 -0
- package/dist/memory-embedding-adapter-Cux48Bvk.js +33 -0
- package/dist/memory-index-DSbV_yD0.js +2 -0
- package/dist/memory-index-EFkCRTeh.js +514 -0
- package/dist/message-CMCdNyAT.js +223 -0
- package/dist/message-action-runner-CG2CcWaS.js +1628 -0
- package/dist/message-action-runner-DUZQ7nmt.js +2 -0
- package/dist/message.gateway.runtime-COLMRCv4.js +2 -0
- package/dist/message.gateway.runtime.js +1 -1
- package/dist/method-scopes-BNjBMlqM.js +2883 -0
- package/dist/minimax-vlm-D1DbVSjC.js +183 -0
- package/dist/minimax-web-search-provider-BzgvahXM.js +165 -0
- package/dist/mmr-Clamw4uq.js +146 -0
- package/dist/model-CJIbRRp9.js +630 -0
- package/dist/model-auth-BQpkMtoP.js +427 -0
- package/dist/model-auth-env-BWJjZ_uc.js +53 -0
- package/dist/model-auth-env-CZXe-GO2.js +2 -0
- package/dist/model-auth-label-dLSkL9EI.js +45 -0
- package/dist/model-catalog-DgqowW_L.js +204 -0
- package/dist/model-definitions-BOTIDDWJ.js +258 -0
- package/dist/model-definitions-mx0Ogg9X.js +74 -0
- package/dist/model-discovery-live.runtime-D2J8zvfK.js +419 -0
- package/dist/model-discovery-live.runtime.js +1 -1
- package/dist/model-discovery-modelsdev-BKijFiV8.js +174 -0
- package/dist/model-picker-B4SuA28P.js +3 -0
- package/dist/model-picker-buwrc8kM.js +500 -0
- package/dist/model-picker.runtime-DXgS2Rab.js +15 -0
- package/dist/model-picker.runtime.js +1 -1
- package/dist/model-selection-CBuo2hSg.js +381 -0
- package/dist/models-BmveqjOE.js +126 -0
- package/dist/models-BucP8NI1.js +760 -0
- package/dist/models-C4-eAnR7.js +157 -0
- package/dist/models-DMLYOe4h.js +2 -0
- package/dist/models-DNNfkS3j.js +2584 -0
- package/dist/models-D_V6hTy-.js +166 -0
- package/dist/models-DkiHZi9S.js +47 -0
- package/dist/models-OhM18fW_.js +555 -0
- package/dist/models-cli-CfvtZXPd.js +198 -0
- package/dist/models-config-BLMZzgfx.js +900 -0
- package/dist/models-config.providers.secrets-rjdH8T5l.js +299 -0
- package/dist/models.fetch-D1o7sMO8.js +518 -0
- package/dist/monitor-CJdL31iS.js +4435 -0
- package/dist/monitor-DB732mUY.js +1023 -0
- package/dist/music-generation-provider-BrUTQBmG.js +169 -0
- package/dist/music-generation-provider-D6aYWSSm.js +238 -0
- package/dist/music-generation-provider-dpX_Oiuw.js +142 -0
- package/dist/node-cli-BSrC37hh.js +2374 -0
- package/dist/node-command-policy-J_sy6jJz.js +205 -0
- package/dist/node-service-Bz1OVtIc.js +69 -0
- package/dist/nodes-cli-uwgDIsqv.js +1046 -0
- package/dist/nodes-screen-EQaXZCHa.js +216 -0
- package/dist/nodes-utils-ChvZvxK1.js +196 -0
- package/dist/nodes.helpers-WGb2Q8DZ.js +34 -0
- package/dist/normalize-reply-B7T9vV8x.js +72 -0
- package/dist/note-9YcA8RtG.js +110 -0
- package/dist/notify-C9-q0Rdu.js +305 -0
- package/dist/oauth-CVAbqwnx.js +152 -0
- package/dist/oauth-RbN-L8pg.js +57 -0
- package/dist/oauth-token-shared-CCzflFLG.js +28 -0
- package/dist/oauth.credentials-BeCOUsTe.js +165 -0
- package/dist/oauth.flow-C2PFyq_h.js +122 -0
- package/dist/oauth.http-BgZeCfvj.js +23 -0
- package/dist/oauth.project-jFMmutMJ.js +123 -0
- package/dist/oauth.settings-CBmYrmAk.js +44 -0
- package/dist/oauth.token-DSow_5Ie.js +43 -0
- package/dist/onboard-8SmAjhIH.js +67 -0
- package/dist/onboard-B-ZJptUZ.js +25 -0
- package/dist/onboard-Beu-mw_-.js +29 -0
- package/dist/onboard-BzUrcgZ5.js +25 -0
- package/dist/onboard-CPuf8esc.js +25 -0
- package/dist/onboard-CR4uUkKJ.js +36 -0
- package/dist/onboard-CTfex1XR2.js +58 -0
- package/dist/onboard-Cksl3HNo.js +54 -0
- package/dist/onboard-D-ccZlbM.js +312 -0
- package/dist/onboard-DHXNhsF7.js +621 -0
- package/dist/onboard-Dd6X5k1s.js +25 -0
- package/dist/onboard-custom-9KIp_ybR.js +647 -0
- package/dist/onboard-custom-CbXUFVN6.js +2 -0
- package/dist/onboard-helpers-BFknCN7m.js +223 -0
- package/dist/onboard-helpers-DSJ_xWpL.js +5 -0
- package/dist/onboard-remote-C28pAu4b.js +193 -0
- package/dist/onboard-remote-DQxyE18D.js +2 -0
- package/dist/onboard-skills-B642NK1o.js +2 -0
- package/dist/onboard-skills-CI4B6Kx5.js +134 -0
- package/dist/openai-codex-auth-identity-PqpqYz4a.js +45 -0
- package/dist/openai-codex-cli-auth-cFTkwXjR.js +57 -0
- package/dist/openai-codex-provider-DjUpM_l9.js +299 -0
- package/dist/openai-codex-shared-o0pq7UkS.js +6 -0
- package/dist/openai-provider-ChZN4Q0c.js +283 -0
- package/dist/openai-transport-stream-DXBBlxJ9.js +1632 -0
- package/dist/operator-approvals-client-RJESCyw4.js +68 -0
- package/dist/outbound-runtime-Bhs-eGEn.js +2 -0
- package/dist/pair-command-approve-5Jr6xo-1.js +34 -0
- package/dist/parse-DH0T3Cu9.js +168 -0
- package/dist/perplexity-web-search-provider-DqEogUCL.js +92 -0
- package/dist/perplexity-web-search-provider.runtime-Clsvb0kX.js +332 -0
- package/dist/perplexity-web-search-provider.runtime-bOr3A0b4.js +2 -0
- package/dist/perplexity-web-search-provider.runtime.js +1 -1
- package/dist/perplexity-web-search-provider.shared-DzXnzvHH.js +73 -0
- package/dist/persistent-bindings.lifecycle-CjXEQUMz.js +94 -0
- package/dist/pi-embedded-Cp3OIZy9.js +2 -0
- package/dist/pi-embedded-DJN2vlNF.js +6 -0
- package/dist/pi-embedded-runner-DXHhhGRS.js +8348 -0
- package/dist/pi-embedded-subscribe.handlers.compaction.runtime-D1jUEg-R.js +23 -0
- package/dist/pi-embedded-subscribe.handlers.compaction.runtime.js +1 -1
- package/dist/pi-embedded-utils-CtraRgVx.js +212 -0
- package/dist/pi-embedded.runtime-DQPfEvkF.js +5 -0
- package/dist/pi-embedded.runtime.js +1 -1
- package/dist/pi-model-discovery-B9q9ykaA.js +232 -0
- package/dist/plugin-enabled-CMdiRqJS.js +71 -0
- package/dist/plugin-registration-BhPJI7wp.js +23 -0
- package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
- package/dist/plugin-sdk/account-core.js +2 -2
- package/dist/plugin-sdk/account-helpers.js +1 -1
- package/dist/plugin-sdk/account-resolution.js +2 -2
- package/dist/plugin-sdk/acp-binding-runtime.js +1 -1
- package/dist/plugin-sdk/acp-runtime.js +3 -3
- package/dist/plugin-sdk/agent-harness-runtime.js +8 -8
- package/dist/plugin-sdk/agent-runtime.js +11 -11
- package/dist/plugin-sdk/allow-from.js +1 -1
- package/dist/plugin-sdk/approval-gateway-runtime.js +2 -2
- package/dist/plugin-sdk/approval-handler-runtime.js +3 -3
- package/dist/plugin-sdk/approval-native-runtime.js +2 -2
- package/dist/plugin-sdk/approval-reply-runtime.js +1 -1
- package/dist/plugin-sdk/approval-runtime.js +5 -5
- package/dist/plugin-sdk/browser-node-runtime.js +5 -5
- package/dist/plugin-sdk/browser-security-runtime.js +2 -2
- package/dist/plugin-sdk/browser-setup-tools.js +3 -3
- package/dist/plugin-sdk/browser-support.js +10 -10
- package/dist/plugin-sdk/channel-config-helpers.js +1 -1
- package/dist/plugin-sdk/channel-config-writes.js +1 -1
- package/dist/plugin-sdk/channel-core.js +2 -2
- package/dist/plugin-sdk/channel-feedback.js +2 -2
- package/dist/plugin-sdk/channel-inbound.js +4 -4
- package/dist/plugin-sdk/channel-message.js +2 -2
- package/dist/plugin-sdk/channel-policy.js +2 -2
- package/dist/plugin-sdk/channel-reply-pipeline.js +2 -2
- package/dist/plugin-sdk/channel-runtime.js +4 -4
- package/dist/plugin-sdk/channel-setup.js +1 -1
- package/dist/plugin-sdk/cli-runtime.js +2 -2
- package/dist/plugin-sdk/command-auth-native.js +1 -1
- package/dist/plugin-sdk/command-auth.js +6 -6
- package/dist/plugin-sdk/command-detection.js +1 -1
- package/dist/plugin-sdk/command-status.js +1 -1
- package/dist/plugin-sdk/command-surface.js +1 -1
- package/dist/plugin-sdk/compat.js +5 -5
- package/dist/plugin-sdk/config-mutation.js +1 -1
- package/dist/plugin-sdk/config-runtime.js +8 -8
- package/dist/plugin-sdk/conversation-binding-runtime.js +1 -1
- package/dist/plugin-sdk/conversation-runtime.js +4 -4
- package/dist/plugin-sdk/core.js +4 -4
- package/dist/plugin-sdk/device-bootstrap.js +4 -4
- package/dist/plugin-sdk/direct-dm.js +1 -1
- package/dist/plugin-sdk/extension-shared.js +1 -1
- package/dist/plugin-sdk/feishu.js +5 -5
- package/dist/plugin-sdk/fetch-runtime.js +2 -2
- package/dist/plugin-sdk/gateway-method-runtime.js +1 -1
- package/dist/plugin-sdk/gateway-runtime.js +2 -2
- package/dist/plugin-sdk/generate-text.js +1 -1
- package/dist/plugin-sdk/image-generation-core.js +2 -2
- package/dist/plugin-sdk/image-generation-runtime.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/infra-runtime.js +16 -16
- package/dist/plugin-sdk/markdown-table-runtime.js +1 -1
- package/dist/plugin-sdk/media-generation-runtime-shared.js +1 -1
- package/dist/plugin-sdk/media-generation-runtime.js +1 -1
- package/dist/plugin-sdk/media-runtime.js +7 -7
- package/dist/plugin-sdk/media-understanding-runtime.js +2 -2
- package/dist/plugin-sdk/media-understanding.js +2 -2
- package/dist/plugin-sdk/memory-core-host-engine-embeddings.js +2 -2
- package/dist/plugin-sdk/memory-core-host-engine-foundation.js +1 -1
- package/dist/plugin-sdk/memory-core-host-runtime-cli.js +2 -2
- package/dist/plugin-sdk/memory-core-host-runtime-core.js +2 -2
- package/dist/plugin-sdk/memory-core.js +4 -4
- package/dist/plugin-sdk/memory-host-core.js +2 -2
- package/dist/plugin-sdk/models-provider-runtime.js +1 -1
- package/dist/plugin-sdk/native-command-registry.js +1 -1
- package/dist/plugin-sdk/outbound-media.js +2 -2
- package/dist/plugin-sdk/outbound-runtime.js +2 -2
- package/dist/plugin-sdk/plugin-test-runtime.js +2 -2
- package/dist/plugin-sdk/provider-auth-api-key.js +3 -3
- package/dist/plugin-sdk/provider-auth-login.js +1 -1
- package/dist/plugin-sdk/provider-auth-runtime.js +4 -4
- package/dist/plugin-sdk/provider-auth.js +6 -6
- package/dist/plugin-sdk/provider-catalog-shared.js +1 -1
- package/dist/plugin-sdk/provider-entry.js +1 -1
- package/dist/plugin-sdk/provider-http.js +3 -3
- package/dist/plugin-sdk/provider-model-shared.js +2 -2
- package/dist/plugin-sdk/provider-stream-family.js +5 -5
- package/dist/plugin-sdk/provider-stream-shared.js +3 -3
- package/dist/plugin-sdk/provider-stream.js +4 -4
- package/dist/plugin-sdk/provider-test-contracts.js +1 -1
- package/dist/plugin-sdk/provider-tools.js +1 -1
- package/dist/plugin-sdk/provider-transport-runtime.js +2 -2
- package/dist/plugin-sdk/provider-web-fetch.js +1 -1
- package/dist/plugin-sdk/provider-web-search-config-contract.js +2 -2
- package/dist/plugin-sdk/provider-web-search-contract.js +2 -2
- package/dist/plugin-sdk/provider-web-search.js +4 -4
- package/dist/plugin-sdk/provider-zai-endpoint.js +1 -1
- package/dist/plugin-sdk/reply-chunking.js +2 -2
- package/dist/plugin-sdk/reply-dispatch-runtime.js +2 -2
- package/dist/plugin-sdk/reply-runtime.js +13 -13
- package/dist/plugin-sdk/retry-runtime.js +2 -2
- package/dist/plugin-sdk/routing.js +1 -1
- package/dist/plugin-sdk/runtime-env.js +5 -5
- package/dist/plugin-sdk/runtime-secret-resolution.js +1 -1
- package/dist/plugin-sdk/runtime.js +2 -2
- package/dist/plugin-sdk/sandbox.js +2 -2
- package/dist/plugin-sdk/session-store-runtime.js +2 -2
- package/dist/plugin-sdk/setup-runtime.js +1 -1
- package/dist/plugin-sdk/setup-tools.js +2 -2
- package/dist/plugin-sdk/setup.js +3 -3
- package/dist/plugin-sdk/simple-completion-runtime.js +2 -2
- package/dist/plugin-sdk/skill-commands-runtime.js +1 -1
- package/dist/plugin-sdk/speech-core.js +2 -2
- package/dist/plugin-sdk/speech.js +1 -1
- package/dist/plugin-sdk/src/config/sessions/transcript.d.ts +5 -0
- package/dist/plugin-sdk/src/infra/heartbeat-degeneration-guard.d.ts +31 -0
- package/dist/plugin-sdk/src/infra/heartbeat-events.d.ts +6 -0
- package/dist/plugin-sdk/ssrf-runtime.js +2 -2
- package/dist/plugin-sdk/testing.js +4 -4
- package/dist/plugin-sdk/text-runtime.js +4 -4
- package/dist/plugin-sdk/text-utility-runtime.js +1 -1
- package/dist/plugin-sdk/video-generation-core.js +1 -1
- package/dist/plugin-sdk/video-generation-runtime.js +1 -1
- package/dist/plugin-sdk/video-generation.js +1 -1
- package/dist/plugin-sdk/web-media.js +2 -2
- package/dist/plugin-service-31XQtuZr.js +2494 -0
- package/dist/plugins/runtime/index.js +1 -1
- package/dist/plugins-cli-20A8dYUN.js +576 -0
- package/dist/plugins-update-command-D0Iv4BPb.js +1009 -0
- package/dist/policy-BEVsx7jw.js +172 -0
- package/dist/ports-CwmEcxRS.js +433 -0
- package/dist/ports-Dr-FwKZD.js +263 -0
- package/dist/preemptive-compaction-DlRJt7Zq.js +430 -0
- package/dist/proactive-scheduler-B3w5rW0h.js +1444 -0
- package/dist/probe-BY1GUZvs.js +178 -0
- package/dist/probe-CCTEVLB2.js +54 -0
- package/dist/probe-CcQ1ucSE.js +2 -0
- package/dist/probe-DcSW0ngD.js +426 -0
- package/dist/probe-auth-C7DjgU_m.js +69 -0
- package/dist/probe-auth-Cfwc8qaj.js +3 -0
- package/dist/program-E_Dt_QTp.js +111 -0
- package/dist/prompt-overlay-DsEnjhTn.js +72 -0
- package/dist/prompt-select-styled-Dtw90p2J.js +5305 -0
- package/dist/provider-api-key-auth-CerNsquw.js +113 -0
- package/dist/provider-api-key-auth.runtime-B0BpFkRm.js +14 -0
- package/dist/provider-api-key-auth.runtime.js +1 -1
- package/dist/provider-auth-DwgUXcgu.js +36 -0
- package/dist/provider-auth-api-key-BQfXwqgU.js +5 -0
- package/dist/provider-auth-choice-BKxMQwxd.js +134 -0
- package/dist/provider-auth-choice-preference-DeDdHlsY.js +62 -0
- package/dist/provider-auth-input-BfXB22nt.js +117 -0
- package/dist/provider-auth-login-BYMTrXdl.js +8 -0
- package/dist/provider-auth-login.runtime-CCwO-k5h.js +206 -0
- package/dist/provider-auth-login.runtime.js +1 -1
- package/dist/provider-auth-runtime-p93v7b23.js +36 -0
- package/dist/provider-catalog-BA7O6Faq.js +18 -0
- package/dist/provider-catalog-BZJt3Ew2.js +75 -0
- package/dist/provider-catalog-CjNAbR9b.js +12 -0
- package/dist/provider-catalog-CpTP4D3p.js +56 -0
- package/dist/provider-catalog-CzVEmVzS.js +11 -0
- package/dist/provider-catalog-D1iJW59q.js +11 -0
- package/dist/provider-catalog-Dc48HHhB.js +11 -0
- package/dist/provider-catalog-KHD3te_R.js +61 -0
- package/dist/provider-catalog-jKq2UIeG.js +17 -0
- package/dist/provider-catalog-pmlFBXYr.js +26 -0
- package/dist/provider-catalog-shared-Cra7j-_m.js +104 -0
- package/dist/provider-catalog-xzYpukvK.js +13 -0
- package/dist/provider-compat-CCwXKQGq.js +37 -0
- package/dist/provider-discovery-DubIrc_R.js +2 -0
- package/dist/provider-dispatcher-Dl07uV70.js +22 -0
- package/dist/provider-entry-DkwXZuZY.js +97 -0
- package/dist/provider-http-CHFd_hrC.js +26 -0
- package/dist/provider-iVtrs6XY.js +70 -0
- package/dist/provider-model-shared-CxQysvS-.js +171 -0
- package/dist/provider-models-B3FlcSqf.js +225 -0
- package/dist/provider-models-B63rx638.js +22 -0
- package/dist/provider-models-BXMZj2p1.js +119 -0
- package/dist/provider-models-Bq_MZ0xR.js +35 -0
- package/dist/provider-models-CsUYkHTw.js +116 -0
- package/dist/provider-models-DCvjBHoV.js +169 -0
- package/dist/provider-openai-codex-oauth-tls-DbmKevdp.js +99 -0
- package/dist/provider-registration-DkqLtXSj.js +57 -0
- package/dist/provider-registration-vrLHkywc.js +238 -0
- package/dist/provider-stream-DTbeHqKf.js +285 -0
- package/dist/provider-stream-family-Cz7SHqeS.js +2 -0
- package/dist/provider-stream-shared-CTpijFfV.js +80 -0
- package/dist/provider-tools-X4kNlvXF.js +332 -0
- package/dist/provider-usage-4x0im5xP.js +3 -0
- package/dist/provider-usage-CdkW3Bkb.js +289 -0
- package/dist/provider-web-search-CyGNmODH.js +55 -0
- package/dist/provider-web-search-contract-BEZzFHD8.js +12 -0
- package/dist/provider-web-search-contract-fields-DNH2_b3H.js +38 -0
- package/dist/proxy-stream-wrappers-BcJuaE24.js +480 -0
- package/dist/push-apns-CO3sqbX3.js +1061 -0
- package/dist/pw-ai-DEf5tZLp.js +2268 -0
- package/dist/qmd-manager-CrqmeTuY.js +1799 -0
- package/dist/qr-cli-g_Pkqstu.js +359 -0
- package/dist/qr-image-DcG1bUox.js +2 -0
- package/dist/queue-BveCZpTb.js +636 -0
- package/dist/realtime-provider-shared-BIili3oc.js +21 -0
- package/dist/realtime-transcription-provider-DqEHy_Jr.js +180 -0
- package/dist/realtime-voice-provider-Dau1KlKK.js +342 -0
- package/dist/record-shared-CC55xbFE.js +10 -0
- package/dist/region-CPFmncMW.js +74 -0
- package/dist/register.agent-D5el253o.js +241 -0
- package/dist/register.configure-DeqUaelp.js +15 -0
- package/dist/register.maintenance-Dv5x9ZE6.js +443 -0
- package/dist/register.message-e2Pbh8A_.js +601 -0
- package/dist/register.onboard-COuTKpAw.js +83 -0
- package/dist/register.runtime-BjOIl4eF.js +81 -0
- package/dist/register.runtime-BzJ6RkQN.js +343 -0
- package/dist/register.runtime.js +1 -1
- package/dist/register.setup-DQYY7K4K.js +104 -0
- package/dist/register.status-health-sessions-CXNGQh_O.js +1211 -0
- package/dist/register.subclis-B6uy_ogx.js +232 -0
- package/dist/register.subclis-Cmdrfiej.js +3 -0
- package/dist/remote-env-DU45InJB.js +12 -0
- package/dist/replay-policy-BKyiI8sk.js +10 -0
- package/dist/replay-policy-C6igC4nS.js +8 -0
- package/dist/reply-Bd8ShNWW.js +3523 -0
- package/dist/reply-payloads-CFKnBOGu.js +78 -0
- package/dist/reply-prefix-D43zayDn.js +33 -0
- package/dist/reply.runtime-ByKwE5dg.js +2 -0
- package/dist/reply.runtime.js +1 -1
- package/dist/resolve-CSTOvc_c.js +280 -0
- package/dist/restart-C0QhPXk1.js +454 -0
- package/dist/restart-handoff-Dd9C10Ns.js +2 -0
- package/dist/restart-health-BAtQdyZh.js +203 -0
- package/dist/restart-health-CnQMSvvJ.js +2 -0
- package/dist/restart-stale-pids-CiBNQGrr.js +529 -0
- package/dist/retry-C1lmuHl8.js +76 -0
- package/dist/retry-policy-B_7wH7D2.js +58 -0
- package/dist/route-reply-CXZFXlfK.js +141 -0
- package/dist/route-reply.runtime-BK8V9NEg.js +2 -0
- package/dist/route-reply.runtime.js +1 -1
- package/dist/rpc-f0OkPaI1.js +61 -0
- package/dist/rpc.runtime-BQ78T_pB.js +21 -0
- package/dist/rpc.runtime.js +1 -1
- package/dist/run-main-CkwrrhfI.js +453 -0
- package/dist/run-wait-B4pXPLkF.js +118 -0
- package/dist/runner-BSA9M_M9.js +1497 -0
- package/dist/runtime-C18YgW822.js +242 -0
- package/dist/runtime-C3OJQ1Xd.js +200 -0
- package/dist/runtime-CDNVtwVk.js +72 -0
- package/dist/runtime-CMNHfJtF.js +725 -0
- package/dist/runtime-C_o_otMV.js +355 -0
- package/dist/runtime-CiJWy5Ce.js +9 -0
- package/dist/runtime-Di50Fr1z.js +191 -0
- package/dist/runtime-W3qG5LHM.js +2 -0
- package/dist/runtime-api-Bx7nlc4w.js +12 -0
- package/dist/runtime-api-DCNC_FTy2.js +2 -0
- package/dist/runtime-api-_Z8MjR0l.js +3 -0
- package/dist/runtime-embedded-pi.runtime-Cv0MW9ps.js +3 -0
- package/dist/runtime-embedded-pi.runtime.js +1 -1
- package/dist/runtime-env-BeD13rEG.js +9 -0
- package/dist/runtime-internal-DclGtT-e.js +2 -0
- package/dist/runtime-model-auth.runtime-Bjl23_fr.js +39 -0
- package/dist/runtime-model-auth.runtime.js +1 -1
- package/dist/runtime-oEwr_zQb.js +107 -0
- package/dist/runtime-plugins-CwWhqXLJ.js +69 -0
- package/dist/runtime-prepare.runtime-Bi-YD5R-.js +80 -0
- package/dist/runtime-prepare.runtime.js +1 -1
- package/dist/runtime-provider-CSEDbSxr.js +21 -0
- package/dist/runtime-shared-BxJFDFe6.js +249 -0
- package/dist/runtime-taskflow-RwpXng2l.js +250 -0
- package/dist/runtime-web-channel-plugin-Bw74Ar_q.js +215 -0
- package/dist/runtime-web-tools-CEaAGeYr.js +1467 -0
- package/dist/sandbox-BC2XUWcW.js +4 -0
- package/dist/sandbox-cli-ain0MYTB.js +447 -0
- package/dist/sandbox-epLgxWBQ.js +2586 -0
- package/dist/schtasks-CL3tJAH5.js +785 -0
- package/dist/secrets-cli-iLwRZbRt.js +2114 -0
- package/dist/security-audit-DfrokBuq.js +34 -0
- package/dist/security-cli-BqsMM550.js +486 -0
- package/dist/semantic-dedup-BBpIPaSV.js +95 -0
- package/dist/send-C5LHdZqP.js +993 -0
- package/dist/send-media-Df0E2Z_m.js +2123 -0
- package/dist/server-2CD2yd73.js +13 -0
- package/dist/server-B44RMlVT.js +77 -0
- package/dist/server-context-SulhWpXY.js +4164 -0
- package/dist/server-methods-BPzzX5VC.js +11937 -0
- package/dist/server-middleware-WQzQIrD4.js +110 -0
- package/dist/server-node-events-Ug_Atc7G.js +451 -0
- package/dist/server.impl-InfVdwPj.js +19765 -0
- package/dist/service-CK-XuLCu.js +132 -0
- package/dist/service-D9X-uqEA.js +2 -0
- package/dist/service-audit-BQx1zTWD.js +2 -0
- package/dist/service-audit-CQC1FeD7.js +254 -0
- package/dist/session-B5RmIL21.js +48 -0
- package/dist/session-archive.runtime-B1x5wHBw.js +2 -0
- package/dist/session-archive.runtime.js +1 -1
- package/dist/session-conversation-CFty7VTc.js +27 -0
- package/dist/session-cost-usage-CckjvorH.js +2 -0
- package/dist/session-cost-usage-DMRjhi4B.js +648 -0
- package/dist/session-file-DGJqy_ea.js +44 -0
- package/dist/session-key-D-jBcxEp.js +65 -0
- package/dist/session-meta-BijZlLS3.js +109 -0
- package/dist/session-override-1YQHEAlz.js +103 -0
- package/dist/session-reset-model.runtime-CEWrfXLr.js +120 -0
- package/dist/session-reset-model.runtime.js +1 -1
- package/dist/session-reset-service-Dphtb16d.js +474 -0
- package/dist/session-subagent-reactivation.runtime-CF4aqSpn.js +2 -0
- package/dist/session-subagent-reactivation.runtime.js +1 -1
- package/dist/session-tab-registry-DG9SGi0I.js +553 -0
- package/dist/session-updates-BRFvmIoC.js +234 -0
- package/dist/session-updates.runtime-CiHARWGr.js +2 -0
- package/dist/session-updates.runtime.js +1 -1
- package/dist/session-utils-Cai4P9ih.js +930 -0
- package/dist/session-utils.fs-DV8bxCEw.js +537 -0
- package/dist/sessions-BTcXDmCA.js +2 -0
- package/dist/sessions-CyYVTseV.js +45 -0
- package/dist/sessions-Fb0ep3uj.js +231 -0
- package/dist/sessions.runtime-BGyynSR4.js +2 -0
- package/dist/sessions.runtime.js +1 -1
- package/dist/setup-CjEjg8Ci.js +505 -0
- package/dist/setup-D-ypxGnK.js +329 -0
- package/dist/setup-DjympYIJ.js +15 -0
- package/dist/setup-binary-BKTpThn7.js +2 -0
- package/dist/setup-surface-QaubzT60.js +586 -0
- package/dist/setup-tools-6s2MNbj0.js +4 -0
- package/dist/setup-wizard-proxy-BscKn1FO.js +139 -0
- package/dist/setup.finalize-B3MWkUF9.js +436 -0
- package/dist/setup.gateway-config-BdK0tA_r.js +246 -0
- package/dist/shared-0JcWj8-R.js +224 -0
- package/dist/shared-BAqqhcWT.js +127 -0
- package/dist/shared-BOd3OCF0.js +36 -0
- package/dist/shared-D5_A7-ng.js +219 -0
- package/dist/shared-DICWV0-6.js +218 -0
- package/dist/shared-DiGX-JK8.js +137 -0
- package/dist/shared-DktX3NHd.js +175 -0
- package/dist/shared-runtime-BltNIfGY.js +7 -0
- package/dist/short-term-promotion-CT1zdD1r.js +1631 -0
- package/dist/simple-completion-runtime-CZyp8rJ3.js +131 -0
- package/dist/simple-completion-transport-BWyoXghG.js +32 -0
- package/dist/skill-commands-BC_2IdwF.js +82 -0
- package/dist/skill-commands.runtime-BP6BnOeq.js +2 -0
- package/dist/skill-commands.runtime.js +1 -1
- package/dist/skills-install-CHUWYiLs.js +822 -0
- package/dist/speech-core-aXx4I3sB.js +126 -0
- package/dist/speech-provider-B2yBILHX.js +101 -0
- package/dist/speech-provider-BTBQ5VOv.js +103 -0
- package/dist/speech-provider-BciszvJf.js +184 -0
- package/dist/speech-provider-BoQDEC_Y.js +167 -0
- package/dist/speech-provider-C-wTEx8k.js +182 -0
- package/dist/speech-provider-DYJcz4pW.js +39 -0
- package/dist/ssh-tunnel-B-uzzPcH.js +2 -0
- package/dist/ssh-tunnel-Bu9s0zUo.js +159 -0
- package/dist/ssrf-runtime-D1skzXnx.js +6 -0
- package/dist/stage-sandbox-media.runtime-DhlTQjXA.js +230 -0
- package/dist/stage-sandbox-media.runtime.js +1 -1
- package/dist/standalone-generate-BRvNW_O7.js +2 -0
- package/dist/standalone-generate-CDfZss4x.js +217 -0
- package/dist/state-migrations-BNib6l8O.js +823 -0
- package/dist/status-8clcfnN0.js +473 -0
- package/dist/status-CNcOKUs2.js +500 -0
- package/dist/status-D1l9Tu3s.js +399 -0
- package/dist/status-P3bvFirO.js +3 -0
- package/dist/status-TmH9qSMG.js +2 -0
- package/dist/status-all-BeyVXDNT.js +495 -0
- package/dist/status-json-Cj42CVZZ.js +14 -0
- package/dist/status-json-command-DWk5RiyN.js +92 -0
- package/dist/status-runtime-shared-orzti3tZ.js +271 -0
- package/dist/status.agent-local-BEtIuLEr.js +58 -0
- package/dist/status.command.text-runtime-B-tNLc3T.js +15 -0
- package/dist/status.format-VfGIeDvx.js +60 -0
- package/dist/status.gateway-connection.runtime-BrkaJ2f5.js +2 -0
- package/dist/status.gateway-connection.runtime.js +1 -1
- package/dist/status.gateway-probe-BwuiZk1h.js +16 -0
- package/dist/status.scan-DegSjLE2.js +62 -0
- package/dist/status.scan-overview-CrSELCru.js +395 -0
- package/dist/status.scan.fast-json-Bm5lN6IK.js +2 -0
- package/dist/status.scan.fast-json-Ch2Zw813.js +128 -0
- package/dist/status.scan.runtime-D-LvzBYN.js +417 -0
- package/dist/status.scan.runtime.js +1 -1
- package/dist/status.summary-OB-43Bvk.js +2 -0
- package/dist/status.summary-gJukahkb.js +209 -0
- package/dist/status.update-BFj-9E8m.js +79 -0
- package/dist/status.update-DYICl5t8.js +2 -0
- package/dist/store-D_vXZ7m9.js +1112 -0
- package/dist/store.runtime-6eaZtPq6.js +2 -0
- package/dist/store.runtime.js +1 -1
- package/dist/stream-B84y4XQY.js +76 -0
- package/dist/stream-BgcqyefI.js +649 -0
- package/dist/stream-C_VJaXT6.js +26 -0
- package/dist/stream-D5lrRuHb.js +129 -0
- package/dist/stream-DXG7L3j5.js +27 -0
- package/dist/stream-UtEiCziE.js +153 -0
- package/dist/stream-wrappers-B7-5gN0i.js +144 -0
- package/dist/strip-inbound-meta-BSHFFiJd.js +155 -0
- package/dist/subagent-announce.registry.runtime-R2bop0gW.js +3 -0
- package/dist/subagent-announce.registry.runtime.js +1 -1
- package/dist/subagent-control-UyMtkJwo.js +485 -0
- package/dist/subagent-followup.runtime-bTK0TymS.js +68 -0
- package/dist/subagent-followup.runtime.js +1 -1
- package/dist/subagent-list-c0JKZR0g.js +168 -0
- package/dist/subagent-orphan-recovery-CSEzwva5.js +214 -0
- package/dist/subagent-registry-Be219RP1.js +2889 -0
- package/dist/subagent-registry-read-IQtTTWj3.js +57 -0
- package/dist/subagent-registry-runtime-Dk57Y91p.js +2 -0
- package/dist/subagent-registry.runtime-D6h_BK2i.js +3 -0
- package/dist/subagent-registry.runtime.js +1 -1
- package/dist/subagent-spawn-BeyYZuFf.js +782 -0
- package/dist/subagents-format-ZcZBg1Vh.js +629 -0
- package/dist/supervisor-DVGQ2rPX.js +737 -0
- package/dist/system-cli-_3czEwa7.js +60 -0
- package/dist/system-prompt-BBrWR8Ef.js +711 -0
- package/dist/system-prompt-Dc6Xr30m.js +2 -0
- package/dist/system-prompt-cache-boundary-BqVZ8lnu.js +25 -0
- package/dist/system-run-command-W-wf2HqZ.js +300 -0
- package/dist/systemd-BeYwG5kN.js +591 -0
- package/dist/systemd-hints-BpWajEeA.js +76 -0
- package/dist/systemd-linger-DsTUkfUn.js +68 -0
- package/dist/systemd-linger-X-aDLDla.js +2 -0
- package/dist/tables-BGTNKk6h.js +832 -0
- package/dist/tailscale-status-CCyq-VvN.js +72 -0
- package/dist/targets-BN0-h0GJ.js +300 -0
- package/dist/targets-CXrDP8_l.js +595 -0
- package/dist/targets.runtime-BvBk-CQ8.js +2 -0
- package/dist/targets.runtime.js +1 -1
- package/dist/task-executor-DNUNtRg8.js +350 -0
- package/dist/task-owner-access--E5Vkg9U.js +48 -0
- package/dist/task-registry-COE-B6MO.js +2346 -0
- package/dist/task-registry-control.runtime-BzsTfRw1.js +3 -0
- package/dist/task-registry-control.runtime.js +1 -1
- package/dist/task-registry-delivery-runtime-Cv6xz8KP.js +2 -0
- package/dist/task-registry-delivery-runtime-DSfcd2LA.js +3 -0
- package/dist/task-registry.maintenance-Bhd9abl9.js +2 -0
- package/dist/task-registry.maintenance-W3lTkY0l.js +425 -0
- package/dist/testing-CQ_-oCQB.js +441 -0
- package/dist/text-report-BgqWDKJR.js +587 -0
- package/dist/text-runtime-asv4kIxS.js +313 -0
- package/dist/thread-bindings-BCRWofo_.js +223 -0
- package/dist/tool-auth-shared-BWZwTobX.js +53 -0
- package/dist/tool-config-shared-BleK697I.js +19 -0
- package/dist/tool-schema-runtime-DZsW_KR4.js +1892 -0
- package/dist/tools-effective-inventory-SB9JwX-y.js +152 -0
- package/dist/tools.runtime-J5rhfXQp.js +4 -0
- package/dist/tools.runtime.js +1 -1
- package/dist/transcript-B8bIvyol.js +2 -0
- package/dist/transcript-CxdKo8Wl.js +222 -0
- package/dist/transcript-DxWx6dVc.js +233 -0
- package/dist/transcript.runtime-CmBnobSv.js +2 -0
- package/dist/transcript.runtime.js +1 -1
- package/dist/transport-policy-BGfaKNz0.js +75 -0
- package/dist/transport-ready-MwpvBxBB.js +36 -0
- package/dist/tts-C1GyTLOi.js +31 -0
- package/dist/tts-JSdoZrZA.js +40 -0
- package/dist/tui-Cqdp1x16.js +4018 -0
- package/dist/tui-cli-BC4O3H6r.js +31 -0
- package/dist/typing-mode-BoJYxUas.js +84 -0
- package/dist/undici-global-dispatcher-BLnQvRel.js +99 -0
- package/dist/update-BrD8yWSp.js +1253 -0
- package/dist/update-check-gcnsxBqT.js +431 -0
- package/dist/update-cli-BzaCTuax.js +1779 -0
- package/dist/update-runner-Cvxezvhf.js +1492 -0
- package/dist/usage-CG1Nshi3.js +71 -0
- package/dist/usage-format-DQTT4pqY.js +507 -0
- package/dist/usage-format-sR4xu0xw.js +2 -0
- package/dist/utils-CBnbWiRL.js +189 -0
- package/dist/video-generation-CksImGdK.js +167 -0
- package/dist/video-generation-provider-7YR4_ldd.js +171 -0
- package/dist/video-generation-provider-AlAZkYIW.js +181 -0
- package/dist/video-generation-provider-BEqi4pUJ.js +104 -0
- package/dist/video-generation-provider-CraaZaR7.js +77 -0
- package/dist/video-generation-provider-CuvO2Hzh.js +246 -0
- package/dist/video-generation-provider-D-t16ACe.js +240 -0
- package/dist/video-generation-provider-DeowxvLt.js +233 -0
- package/dist/video-generation-provider-HbOZ3qzI.js +227 -0
- package/dist/video-generation-provider-_apx1yFE.js +263 -0
- package/dist/video-generation-provider-bvpb6cdV.js +64 -0
- package/dist/video-http-DRLB0lIA.js +29 -0
- package/dist/video-model-catalog-BE5LhQSo.js +187 -0
- package/dist/web-media-BYZC5tOg.js +330 -0
- package/dist/web-media-DKpK9EDb.js +2 -0
- package/dist/web-search-DSDz1iyf.js +221 -0
- package/dist/web-search-provider-DnYRRBVM.js +155 -0
- package/dist/web-search-provider-common-B9jozd8T.js +206 -0
- package/dist/web-search-provider-config-DCqeS6ct.js +52 -0
- package/dist/web-shared--44LWgiH.js +414 -0
- package/dist/x-search-shared-DKPdPR5_.js +109 -0
- package/docs/platforms/termux.md +3 -3
- package/package.json +1 -1
- package/dist/abort-D8E9Viul.js +0 -202
- package/dist/abort-cutoff.runtime-buOT5TQ9.js +0 -20
- package/dist/abort-primitives-B6Qmun6I.js +0 -93
- package/dist/abort.runtime-DBAOcoA0.js +0 -2
- package/dist/account-action-gate-BT_vXl45.js +0 -114
- package/dist/acp-cli-CK-PaZW1.js +0 -2171
- package/dist/acp-spawn-DREGP-Dg.js +0 -1024
- package/dist/acp-stateful-target-driver-BCNEZ0qY.js +0 -88
- package/dist/action-agents-Bghuxxiu.js +0 -67
- package/dist/action-focus-DsDsKPpt.js +0 -124
- package/dist/action-help-Dea7LzSX.js +0 -7
- package/dist/action-info-BeSnrfUx.js +0 -58
- package/dist/action-kill-A8Gm3ASV.js +0 -33
- package/dist/action-list-BkyeGY4Y.js +0 -21
- package/dist/action-log-C-PshBJC.js +0 -30
- package/dist/action-send-B7O-Cyik.js +0 -39
- package/dist/action-spawn-0DHhLXka.js +0 -46
- package/dist/action-unfocus-DQ3mnyh6.js +0 -28
- package/dist/agent-ChCFDEkx.js +0 -2
- package/dist/agent-command-HwJps2h3.js +0 -1479
- package/dist/agent-list-3PG6_Efg.js +0 -67
- package/dist/agent-runner-utils-dAUhMPP0.js +0 -202
- package/dist/agent-runner.runtime-BvOJ3ms5.js +0 -2825
- package/dist/agents-DGs1CWL1.js +0 -5
- package/dist/agents-R-PuEDKr.js +0 -887
- package/dist/allow-from-REaY_RBI.js +0 -164
- package/dist/anthropic-cache-control-payload-CvmvKgnD.js +0 -28
- package/dist/anthropic-payload-policy-CANcBjYh.js +0 -136
- package/dist/anthropic-vertex-stream-BOdy5JqE.js +0 -5666
- package/dist/api-BChlvn8B.js +0 -5
- package/dist/api-BEM__kGA.js +0 -4
- package/dist/api-BQr2q6_t.js +0 -4
- package/dist/api-BzKZ27N_.js +0 -2
- package/dist/api-C7GkbUyn.js +0 -35
- package/dist/api-Cbv-utnp.js +0 -45
- package/dist/api-Csv5YmWm.js +0 -3
- package/dist/api-CvN3buT5.js +0 -3
- package/dist/api-D7OkY2ha.js +0 -5
- package/dist/api-D7cDr4c5.js +0 -19
- package/dist/api-Df793QOm.js +0 -2
- package/dist/apply-DG2_D6J9.js +0 -493
- package/dist/apply.runtime-4Oo5FMhm.js +0 -166
- package/dist/apply.runtime-O1GHmKzQ.js +0 -2
- package/dist/approval-gateway-resolver-By95iflu.js +0 -58
- package/dist/approval-gateway-runtime-C_2l5m0E.js +0 -2
- package/dist/approval-handler-runtime-BcIBxW0i.js +0 -439
- package/dist/approval-native-helpers-Dy60ZISZ.js +0 -33
- package/dist/approval-native-runtime-zPzOoZlr.js +0 -709
- package/dist/approval-renderers-oIQzoEfU.js +0 -64
- package/dist/asr-ChZCFIGe.js +0 -195
- package/dist/audit-DfEhlnGH.js +0 -885
- package/dist/audit-extra.async-B-_wy7Tg.js +0 -847
- package/dist/audit.deep.runtime-CqfZhQYQ.js +0 -2
- package/dist/audit.nondeep.runtime-BEYvNUL0.js +0 -859
- package/dist/audit.runtime-BZIKjR29.js +0 -7
- package/dist/auth-B4RCO9pL.js +0 -181
- package/dist/auth-choice-BKccwE1z.js +0 -353
- package/dist/auth-choice-BjfYwU59.js +0 -71
- package/dist/auth-choice-D5arr50x.js +0 -3
- package/dist/auth-choice.apply-helpers-Bte42LAy.js +0 -2
- package/dist/binding-routing-BOSLYF1b.js +0 -50
- package/dist/binding-targets-JPaoc1qf.js +0 -99
- package/dist/block-streaming-CEz8_YvV.js +0 -103
- package/dist/bootstrap-files-MSqLqaFY.js +0 -206
- package/dist/bridge-server-vuRzCH3N.js +0 -103
- package/dist/browser-node-runtime-C3g2gsaZ.js +0 -12
- package/dist/browser-open-BP0tUM0r.js +0 -94
- package/dist/browser-runtime-BF4n8YQ5.js +0 -377
- package/dist/browser-security-runtime-Ci12HfND.js +0 -10
- package/dist/browser-setup-tools-6xFifQZE.js +0 -12
- package/dist/btw-command-YUgszbXM.js +0 -17
- package/dist/call-5P034-jt.js +0 -495
- package/dist/call-BUDlcDxf.js +0 -2
- package/dist/call.runtime-DUm_Bttq.js +0 -2
- package/dist/capability-cli-Dedr9-5P.js +0 -1357
- package/dist/catalog-provider-B6R9uezh.js +0 -40
- package/dist/cdp.helpers-BIDb2U4E.js +0 -372
- package/dist/channel-config-helpers-XmE0KJZk.js +0 -462
- package/dist/channel-core-CjiYN8RW.js +0 -5
- package/dist/channel-feedback-1aAUqgjY.js +0 -259
- package/dist/channel-plugin-resolution-CN215YtG.js +0 -146
- package/dist/channel-policy-B4aZ_llS.js +0 -270
- package/dist/channel-reply-pipeline-CKLpE2fN.js +0 -26
- package/dist/channel-runtime-B5LPKA4v.js +0 -6
- package/dist/channel.runtime-dnBq2L1v.js +0 -399
- package/dist/channels-CYG1q9PH.js +0 -1147
- package/dist/channels-cli-BoG2L78B.js +0 -248
- package/dist/chat-DnjpEdFB.js +0 -213
- package/dist/chat-history-text-BzdTyI1F.js +0 -42
- package/dist/chrome-e2X2vBVg.js +0 -1080
- package/dist/chrome.executables-CnUVYt-H.js +0 -550
- package/dist/chunk-DgPObAqu.js +0 -267
- package/dist/clack-prompter-BWIrYn8q.js +0 -113
- package/dist/cli-CMvRUMSs.js +0 -154
- package/dist/cli-CYvUljnp.js +0 -57
- package/dist/cli-Cw69q4uo.js +0 -2
- package/dist/cli-auth-seam-BL5t2dya.js +0 -14
- package/dist/cli-backend-Cykx4ud8.js +0 -66
- package/dist/cli-migration-CSx1vbkG.js +0 -127
- package/dist/cli-runner-No9Uhffw.js +0 -1662
- package/dist/cli-runner.runtime-COquWuXM.js +0 -3
- package/dist/cli-runner.runtime-egfGJUTe.js +0 -2
- package/dist/cli-runtime-BTdQg8Pm.js +0 -3
- package/dist/cli-shared-DkBvc2Y5.js +0 -142
- package/dist/cli.runtime-djxOgvtS.js +0 -819
- package/dist/client-bootstrap-Dyqi3fZr.js +0 -28
- package/dist/command-auth-D6uvRaCj.js +0 -75
- package/dist/command-config-resolution-2RDsbHMM.js +0 -2
- package/dist/command-config-resolution-DRvqZFqh.js +0 -23
- package/dist/command-detection-q0CJzVXY.js +0 -50
- package/dist/command-execution-startup-BZH7rNOz.js +0 -269
- package/dist/command-format-BNut7VFf.js +0 -2
- package/dist/command-registry-BsP1NxvH.js +0 -3
- package/dist/command-registry-YDJgbbaF.js +0 -113
- package/dist/command-secret-gateway-DFgAUeer.js +0 -528
- package/dist/command-status-builders-DykmScCm.js +0 -145
- package/dist/commands-acp-BblekZyF.js +0 -1017
- package/dist/commands-compact.runtime-CjyTQ5zv.js +0 -10
- package/dist/commands-context-B5MBVGe2.js +0 -34
- package/dist/commands-core.runtime-CnZNxnAO.js +0 -2
- package/dist/commands-handlers.runtime-DDqt62Dn.js +0 -3762
- package/dist/commands-models-DTev55uI.js +0 -306
- package/dist/commands-registry-vcJhtPD2.js +0 -295
- package/dist/commands-registry.runtime-CgwuBxnW.js +0 -2
- package/dist/commands-reset-hooks-BTmweR6W.js +0 -129
- package/dist/commands-status-DkWx-VSd.js +0 -223
- package/dist/commands-status.runtime-B6nbPpK_.js +0 -2
- package/dist/commands-subagents-control.runtime-B3F_rMws.js +0 -3
- package/dist/commands-subagents-control.runtime-D7PSJsuS.js +0 -2
- package/dist/commands.runtime-D0Qr8f98.js +0 -103
- package/dist/comment-shared-C3tQmrNA.js +0 -40
- package/dist/compact-DBa1TeO8.js +0 -11324
- package/dist/compact.runtime-DLdGjZpf.js +0 -7
- package/dist/completion-cli-CywOElFT.js +0 -468
- package/dist/completion-cli-DK-0MXVG.js +0 -2
- package/dist/config-CYhAmlA1.js +0 -166
- package/dist/config-cli-Cd2yLD4r.js +0 -948
- package/dist/config-defaults-ClVNRdCi.js +0 -163
- package/dist/config-guard-C-3SAUrc.js +0 -94
- package/dist/config-runtime-ofeq3zSi.js +0 -14
- package/dist/config-validation-6s7vNOEX.js +0 -279
- package/dist/configure-C-7Lttr2.js +0 -2
- package/dist/configure-D_7K9hWl.js +0 -1162
- package/dist/connection-auth-47Ob5Igi.js +0 -30
- package/dist/context-6q3_7y5g.js +0 -249
- package/dist/context-BEEy1M1I.js +0 -2
- package/dist/context-visibility-2p0h1zWp.js +0 -14
- package/dist/context-writer-CwqLN0tS.js +0 -290
- package/dist/control-auth-BIgC7VS3.js +0 -122
- package/dist/control-ui-links-DEuG_GSl.js +0 -70
- package/dist/conversation-id-Ztzvbgi8.js +0 -140
- package/dist/conversation-runtime-DdIJJiVg.js +0 -31
- package/dist/core-BNu-9utc.js +0 -210
- package/dist/cron-cli-DRRlvCJ_.js +0 -637
- package/dist/daemon-cli-B9FyFrQ6.js +0 -476
- package/dist/daemon-install-TThZ0lbE.js +0 -70
- package/dist/delegate-Cw2paU9j.js +0 -61
- package/dist/deliver-C5UOgw2b.js +0 -3
- package/dist/deliver-DrIu_P0l.js +0 -782
- package/dist/deliver-runtime-Bc7cK2WN.js +0 -2
- package/dist/delivery-outbound.runtime-BjOSpQD-.js +0 -6
- package/dist/delivery-queue-B19gpiaY.js +0 -372
- package/dist/delivery-queue-Cu4I41c4.js +0 -2
- package/dist/device-bootstrap-D8veEU4x.js +0 -4
- package/dist/device-bootstrap-DyTx6egK.js +0 -248
- package/dist/device-bootstrap-profile-I2zbsVdf.js +0 -36
- package/dist/device-identity-HSVRQkzQ.js +0 -2
- package/dist/device-pairing-BCo5v6N5.js +0 -600
- package/dist/devices-cli-CLWd-IeZ.js +0 -336
- package/dist/diagnostics-DPXDETG1.js +0 -2
- package/dist/diagnostics-QjuefiNT.js +0 -33
- package/dist/direct-dm-CNgsDTy-.js +0 -139
- package/dist/directive-handling.fast-lane-BD5lnzxN.js +0 -2
- package/dist/directive-handling.fast-lane-BTy2s6gs.js +0 -64
- package/dist/directive-handling.impl-CX9FZ-B9.js +0 -2
- package/dist/directive-handling.impl-RaR111-L.js +0 -659
- package/dist/directive-handling.parse-DoJ6BVS3.js +0 -376
- package/dist/directive-handling.persist-BLK-h7OI.js +0 -139
- package/dist/directive-handling.persist.runtime-BzAa2gYU.js +0 -2
- package/dist/directive-handling.shared-D1rGNZt5.js +0 -159
- package/dist/directory-cli-C7aTBxHk.js +0 -240
- package/dist/dispatch-DZk7ttx4.js +0 -1126
- package/dist/dispatch-acp-command-bypass-CASB-Big.js +0 -38
- package/dist/dispatch-acp-fiE-20qf.js +0 -969
- package/dist/dispatch-acp-manager.runtime-CXbLrETb.js +0 -3
- package/dist/dispatch-acp-media.runtime-DBNkTr9w.js +0 -3
- package/dist/dispatch-acp-session.runtime-C37eUPyo.js +0 -2
- package/dist/dispatch-acp.runtime-DNcxyRdr.js +0 -19
- package/dist/docker-WeeHs5I_.js +0 -826
- package/dist/doctor-completion-BndMTWBa.js +0 -90
- package/dist/doctor-config-preflight-CSR8GR_C.js +0 -148
- package/dist/doctor-config-preflight-uNP9xifp.js +0 -2
- package/dist/doctor-state-migrations-Cx5F1a8u.js +0 -3
- package/dist/doctor-state-migrations-Dfz-deYl.js +0 -2
- package/dist/drive-DBvfSweP.js +0 -718
- package/dist/embedding-provider-CFWlEX1d.js +0 -26
- package/dist/embedding-provider-CIycGLf5.js +0 -33
- package/dist/embedding-provider-CWndQr_-.js +0 -129
- package/dist/engine-DP8OY9SI.js +0 -82
- package/dist/engine-embeddings-UKC8SpiN.js +0 -1489
- package/dist/entry-capabilities-E73Yz1yg.js +0 -89
- package/dist/exec-approval-forwarder.runtime-B2duci0j.js +0 -3
- package/dist/exec-approval-session-target-B9-fNjez.js +0 -165
- package/dist/exec-approvals-cli-DLdT3aSv.js +0 -485
- package/dist/exec-defaults-VRp473Sn.js +0 -1440
- package/dist/extra-params-CTzuV0V2.js +0 -295
- package/dist/fetch-DnGnGfIj.js +0 -65
- package/dist/fetch-PlNhlY1D.js +0 -256
- package/dist/fetch-guard-DjigeYAg.js +0 -224
- package/dist/format-DqUmaubt.js +0 -245
- package/dist/fragment-collector-PpItYLA6.js +0 -189
- package/dist/gateway-DML9FbXS.js +0 -2
- package/dist/gateway-cli-DVL048Zj.js +0 -1532
- package/dist/gateway-install-token-BamWepdY.js +0 -284
- package/dist/gateway-lock-CYNSW8aZ.js +0 -238
- package/dist/gateway-mGyPIOuQ.js +0 -119
- package/dist/gateway-rpc-CyLUAd7r.js +0 -14
- package/dist/gateway-rpc.runtime-DK8N4h7v.js +0 -23
- package/dist/gemini-cli-provider-CS_UZ3WR.js +0 -106
- package/dist/gemini-web-search-provider-DL5e-EZn.js +0 -167
- package/dist/get-reply-from-config.runtime-D64zRtWj.js +0 -2
- package/dist/group-policy-F3YMiMAb.js +0 -202
- package/dist/health-4aL9xNMP.js +0 -579
- package/dist/health-DdFGarRx.js +0 -2
- package/dist/heartbeat-OI7GfQHK.js +0 -184
- package/dist/heartbeat-runner-Duz5xcLR.js +0 -1289
- package/dist/heartbeat-runner-aaEswJ0B.js +0 -4
- package/dist/heartbeat-runner.runtime-D_qxPkdL.js +0 -2
- package/dist/heartbeat-summary-Brqv8KYX.js +0 -58
- package/dist/heartbeat-visibility-D03CCH71.js +0 -81
- package/dist/hooks-cli-BzctiLUS.js +0 -364
- package/dist/identity-Bxp0hRpo.js +0 -30
- package/dist/identity-avatar-Di47l4kX.js +0 -87
- package/dist/image-B7CPx51h.js +0 -152
- package/dist/image-generation-core-Q4HhEwJY.js +0 -17
- package/dist/image-generation-core.auth.runtime-Bb2j1_UK.js +0 -2
- package/dist/image-generation-provider-0fSo5h6u.js +0 -136
- package/dist/image-generation-provider-CvFrycEI.js +0 -86
- package/dist/image-generation-provider-DA9kPptM.js +0 -163
- package/dist/image-generation-provider-DF7Y6NGy.js +0 -130
- package/dist/image-generation-provider-DTBiXZGp.js +0 -280
- package/dist/image-generation-provider-xgflECGv.js +0 -94
- package/dist/image-generation-runtime-ovbXa2gS.js +0 -2
- package/dist/image-runtime-LoZZdTXn.js +0 -7
- package/dist/images-DKmW2P-z.js +0 -586
- package/dist/inbound-reply-dispatch-C9NpDPnv.js +0 -73
- package/dist/inbound.runtime-CjLChnR7.js +0 -4
- package/dist/inbound.runtime-hVoRWxJ7.js +0 -3
- package/dist/infra-runtime-C8p_6KK_.js +0 -25
- package/dist/ingest-CdJaLY6Q.js +0 -2
- package/dist/ingest-e1icVEK-.js +0 -842
- package/dist/input-files-CT4CpkOx.js +0 -252
- package/dist/inspect-DOgFXMYn.js +0 -2
- package/dist/inspect-Ysjfnqlj.js +0 -282
- package/dist/issue-format-DjVI0gtD.js +0 -2
- package/dist/kaijibot-tools-rpqkBcQN.js +0 -9434
- package/dist/kaijibot-tools.runtime-BfIawT2J.js +0 -2
- package/dist/kill-tree-0Qfa0fPs.js +0 -2
- package/dist/kimi-web-search-provider-CEDoiAGa.js +0 -308
- package/dist/launchd-upj2lSvL.js +0 -556
- package/dist/library-DbtNtgzd.js +0 -45
- package/dist/lifecycle-core-QhQwW6wK.js +0 -422
- package/dist/list.runtime-DfPgbfBV.js +0 -9
- package/dist/list.runtime-X8TKiP_H.js +0 -12
- package/dist/llm-engine-B-oDIukn.js +0 -2
- package/dist/llm-engine-qg7Gd_hc.js +0 -1792
- package/dist/llm-extractor-CU3Bv_HG.js +0 -445
- package/dist/login-DVTUoRIz.js +0 -108
- package/dist/logs-cli-CaPofk7V.js +0 -264
- package/dist/logs-cli.runtime-DbvBADru.js +0 -2
- package/dist/manager-Dgu69d8y.js +0 -3314
- package/dist/manager-DwHThjE2.js +0 -2049
- package/dist/markdown-tables-DQxQ2v3M.js +0 -51
- package/dist/mcp-cli-CbzoZsr0.js +0 -733
- package/dist/media-models-CuHKr-jc.js +0 -49
- package/dist/media-runtime-bKQT2hiX.js +0 -312
- package/dist/media-understanding-BH3AUOGs.js +0 -83
- package/dist/media-understanding-provider-74lVtrOy.js +0 -69
- package/dist/media-understanding-provider-8BsFirXn.js +0 -18
- package/dist/media-understanding-provider-BP6_w_P_.js +0 -67
- package/dist/media-understanding-provider-BpQmj7qs.js +0 -21
- package/dist/media-understanding-provider-BycEDsFD.js +0 -123
- package/dist/media-understanding-provider-C84Ved45.js +0 -14
- package/dist/media-understanding-provider-CK_eMz1X.js +0 -37
- package/dist/media-understanding-provider-DaSwJ4pP.js +0 -18
- package/dist/media-understanding-provider-Dbs2lNmG.js +0 -112
- package/dist/media-understanding-provider-DqLVMGtn.js +0 -30
- package/dist/media-understanding-provider-QqsNUSwt.js +0 -13
- package/dist/media-understanding-runtime-BZA_6tIW.js +0 -2
- package/dist/memory-DEFXUqME.js +0 -3
- package/dist/memory-VUm9E4xZ.js +0 -242
- package/dist/memory-core-host-engine-embeddings-DT26N-48.js +0 -2
- package/dist/memory-core-host-runtime-cli-ByvpXhTk.js +0 -9
- package/dist/memory-core-host-runtime-core-49LtYnDz.js +0 -8
- package/dist/memory-embedding-adapter-BhBdY21w.js +0 -33
- package/dist/memory-index-D1k6rjci.js +0 -2
- package/dist/memory-index-DGv1BQqr.js +0 -514
- package/dist/message-DktPWsWA.js +0 -223
- package/dist/message-action-runner-D5h5Bbhw.js +0 -2
- package/dist/message-action-runner-ezKz_h2P.js +0 -1628
- package/dist/message.gateway.runtime-ZPAymL77.js +0 -2
- package/dist/method-scopes-Dj9nhnXI.js +0 -2883
- package/dist/minimax-vlm-CtLVue6p.js +0 -183
- package/dist/minimax-web-search-provider-Cd-P4xbp.js +0 -165
- package/dist/mmr-CYI_i9v5.js +0 -146
- package/dist/model-B_-8Dp2m.js +0 -630
- package/dist/model-auth-HL2aJaae.js +0 -427
- package/dist/model-auth-env-Ckzim7ba.js +0 -2
- package/dist/model-auth-env-qNUE5jbD.js +0 -53
- package/dist/model-auth-label-BcJD9v1K.js +0 -45
- package/dist/model-catalog-Bkr4CqDm.js +0 -204
- package/dist/model-definitions-D1o_PR5n.js +0 -258
- package/dist/model-definitions-DJm7w6s6.js +0 -74
- package/dist/model-discovery-live.runtime-Ct-IkaF1.js +0 -419
- package/dist/model-discovery-modelsdev-B_Cpy5zK.js +0 -174
- package/dist/model-picker-B-xpoNbr.js +0 -500
- package/dist/model-picker-R0G2MgB_.js +0 -3
- package/dist/model-picker.runtime-BYwcAdzp.js +0 -15
- package/dist/model-selection-BheFUUQH.js +0 -381
- package/dist/models-BEEXc36p.js +0 -166
- package/dist/models-BPkdENoW.js +0 -2
- package/dist/models-BX49tVvV.js +0 -555
- package/dist/models-C03H7fA8.js +0 -157
- package/dist/models-D7VoP8nw.js +0 -760
- package/dist/models-DtHue44_.js +0 -47
- package/dist/models-HYQ1KAk_.js +0 -126
- package/dist/models-cli-BbXVjf9R.js +0 -198
- package/dist/models-config-B85vfu4p.js +0 -900
- package/dist/models-config.providers.secrets-CpQyoJal.js +0 -299
- package/dist/models-xp1rDutG.js +0 -2584
- package/dist/models.fetch-4YMjSao8.js +0 -518
- package/dist/monitor-BRNovC_Y.js +0 -1023
- package/dist/monitor-CKCVK6S4.js +0 -4435
- package/dist/music-generation-provider-BYL9HM9M.js +0 -238
- package/dist/music-generation-provider-BxTgkF9N.js +0 -142
- package/dist/music-generation-provider-CIJ6A211.js +0 -169
- package/dist/node-cli-Btl_VPq-.js +0 -2374
- package/dist/node-command-policy-NrFO7Yy5.js +0 -205
- package/dist/node-service-C5TgmiSv.js +0 -69
- package/dist/nodes-cli-BV6_k5Dm.js +0 -1046
- package/dist/nodes-screen-DXF9W1E2.js +0 -216
- package/dist/nodes-utils-C50A34ps.js +0 -196
- package/dist/nodes.helpers--U8G3EK-.js +0 -34
- package/dist/normalize-reply-lOvnPpkZ.js +0 -72
- package/dist/note-C-MCr2CR.js +0 -110
- package/dist/notify-CQt_pnIb.js +0 -305
- package/dist/oauth-BiAql40W.js +0 -152
- package/dist/oauth-Ca6vDvKF.js +0 -57
- package/dist/oauth-token-shared-2mBrCAD0.js +0 -28
- package/dist/oauth.credentials-CZ0vMrEi.js +0 -165
- package/dist/oauth.flow-DYTskRLV.js +0 -122
- package/dist/oauth.http-BWxW_gXO.js +0 -23
- package/dist/oauth.project-Cb5OEIsJ.js +0 -123
- package/dist/oauth.settings-CDxrRPQK.js +0 -44
- package/dist/oauth.token-Bru4bLzC.js +0 -43
- package/dist/onboard-C1B08y2Y.js +0 -25
- package/dist/onboard-CJdBVSv3.js +0 -25
- package/dist/onboard-CtbzdbPe.js +0 -312
- package/dist/onboard-DBdkbwl4.js +0 -621
- package/dist/onboard-DBjMgyJ9.js +0 -25
- package/dist/onboard-DIMihTCh.js +0 -36
- package/dist/onboard-DVhexP5q.js +0 -54
- package/dist/onboard-DVnq8yjP.js +0 -25
- package/dist/onboard-DX6XRus52.js +0 -58
- package/dist/onboard-D_Vx-9lK.js +0 -29
- package/dist/onboard-R8-I3hmu.js +0 -67
- package/dist/onboard-custom-BGpsNoJc.js +0 -647
- package/dist/onboard-custom-BHvw3fAA.js +0 -2
- package/dist/onboard-helpers-BeAYS2Qq.js +0 -223
- package/dist/onboard-helpers-CKb-ZP-L.js +0 -5
- package/dist/onboard-remote-BTBfReZD.js +0 -2
- package/dist/onboard-remote-DX0VcrI6.js +0 -193
- package/dist/onboard-skills-CZi8Ky26.js +0 -134
- package/dist/onboard-skills-DLC4BbyM.js +0 -2
- package/dist/openai-codex-auth-identity-ASruZ_P2.js +0 -45
- package/dist/openai-codex-cli-auth-Bt_S0j_c.js +0 -57
- package/dist/openai-codex-provider-BouOhpJB.js +0 -299
- package/dist/openai-codex-shared-DedETK99.js +0 -6
- package/dist/openai-provider-Jci9fP5i.js +0 -283
- package/dist/openai-transport-stream-DJo_5UPR.js +0 -1632
- package/dist/operator-approvals-client-D_up6Wq0.js +0 -68
- package/dist/outbound-runtime-DhL6nVw0.js +0 -2
- package/dist/pair-command-approve-DUMQ1lrT.js +0 -34
- package/dist/parse-DLTK-NVk.js +0 -168
- package/dist/perplexity-web-search-provider-uU3my6N4.js +0 -92
- package/dist/perplexity-web-search-provider.runtime-4zsB5_nx.js +0 -2
- package/dist/perplexity-web-search-provider.runtime-C7OOMB_b.js +0 -332
- package/dist/perplexity-web-search-provider.shared-BXQXODBs.js +0 -73
- package/dist/persistent-bindings.lifecycle-Du2uuiGS.js +0 -94
- package/dist/pi-embedded-C4xYML3_.js +0 -6
- package/dist/pi-embedded-Cbug4fLp.js +0 -2
- package/dist/pi-embedded-runner-CjJ1OH7H.js +0 -8348
- package/dist/pi-embedded-subscribe.handlers.compaction.runtime-qoJmuaC3.js +0 -23
- package/dist/pi-embedded-utils-qmoBiSxI.js +0 -212
- package/dist/pi-embedded.runtime-PZWkJVMG.js +0 -5
- package/dist/pi-model-discovery-BhWyylI9.js +0 -232
- package/dist/plugin-enabled-BNJoHRI0.js +0 -71
- package/dist/plugin-registration-CdgdKLdK.js +0 -23
- package/dist/plugin-service-BjwQ0UnC.js +0 -2494
- package/dist/plugins-cli-Inx9NBeP.js +0 -576
- package/dist/plugins-update-command-DCBmHAcw.js +0 -1009
- package/dist/policy-C_NvSQ7D.js +0 -172
- package/dist/ports-2fHnkw5y.js +0 -433
- package/dist/ports-NdA63CHy.js +0 -263
- package/dist/preemptive-compaction-B2i0-LZS.js +0 -430
- package/dist/proactive-scheduler-CMe3amTs.js +0 -1444
- package/dist/probe-C5X2xHFS.js +0 -2
- package/dist/probe-D0gXnUmv.js +0 -426
- package/dist/probe-DwQLQHpB.js +0 -178
- package/dist/probe-aZFpBShN.js +0 -54
- package/dist/probe-auth-0-Td92Qd.js +0 -69
- package/dist/probe-auth-Zwhwfcyg.js +0 -3
- package/dist/program-DKVfTrYP.js +0 -111
- package/dist/prompt-overlay-BvX2tpcA.js +0 -72
- package/dist/prompt-select-styled-Cacsr7x1.js +0 -5305
- package/dist/provider-CWw9unv5.js +0 -70
- package/dist/provider-api-key-auth-DDqs17y7.js +0 -113
- package/dist/provider-api-key-auth.runtime-DFOWhO8H.js +0 -14
- package/dist/provider-auth-D28-DXtL.js +0 -36
- package/dist/provider-auth-api-key-BlUb_Gw8.js +0 -5
- package/dist/provider-auth-choice--RwbO1el.js +0 -134
- package/dist/provider-auth-choice-preference-Bay-KWTs.js +0 -62
- package/dist/provider-auth-input-Duh7v6fc.js +0 -117
- package/dist/provider-auth-login-CqDuosT-.js +0 -8
- package/dist/provider-auth-login.runtime-1ovWzWaE.js +0 -206
- package/dist/provider-auth-runtime-Bep_6xgO.js +0 -36
- package/dist/provider-catalog-B1UHTZ2J.js +0 -56
- package/dist/provider-catalog-BETTnkqQ.js +0 -11
- package/dist/provider-catalog-BgCSPWtg.js +0 -11
- package/dist/provider-catalog-COSwNV9M.js +0 -61
- package/dist/provider-catalog-CVtyzqed.js +0 -17
- package/dist/provider-catalog-D87LxNms.js +0 -26
- package/dist/provider-catalog-DUa_pOgJ.js +0 -75
- package/dist/provider-catalog-_qlQKmNX.js +0 -13
- package/dist/provider-catalog-fRX7Kwpd.js +0 -12
- package/dist/provider-catalog-fjbp4-73.js +0 -11
- package/dist/provider-catalog-kLIlcQiR.js +0 -18
- package/dist/provider-catalog-shared-CUCxLlCb.js +0 -104
- package/dist/provider-compat-CFb-paAS.js +0 -37
- package/dist/provider-discovery-D9udizRd.js +0 -2
- package/dist/provider-dispatcher-CICWLOwX.js +0 -22
- package/dist/provider-entry-D_0kX9WL.js +0 -97
- package/dist/provider-http-CCWzhnsk.js +0 -26
- package/dist/provider-model-shared-TaFcxfzp.js +0 -171
- package/dist/provider-models-3mIjIjQp.js +0 -22
- package/dist/provider-models-CvYgNrs5.js +0 -225
- package/dist/provider-models-D3D1lxRx.js +0 -169
- package/dist/provider-models-DACMEf7B.js +0 -116
- package/dist/provider-models-DoU8PeBb.js +0 -119
- package/dist/provider-models-gP-2JH8n.js +0 -35
- package/dist/provider-openai-codex-oauth-tls-CmSkuSt5.js +0 -99
- package/dist/provider-registration-CbWstPtp.js +0 -238
- package/dist/provider-registration-iGHQBjjx.js +0 -57
- package/dist/provider-stream-BwKmnNvt.js +0 -285
- package/dist/provider-stream-family-CuZuVwyU.js +0 -2
- package/dist/provider-stream-shared-DiqyLpmc.js +0 -80
- package/dist/provider-tools-C8ePitIe.js +0 -332
- package/dist/provider-usage-AerKfwcb.js +0 -289
- package/dist/provider-usage-B1OEBtrp.js +0 -3
- package/dist/provider-web-search-DNrh74o2.js +0 -55
- package/dist/provider-web-search-contract-CD7a3E_j.js +0 -12
- package/dist/provider-web-search-contract-fields-CZpi7HIW.js +0 -38
- package/dist/proxy-stream-wrappers-C_X_spRH.js +0 -480
- package/dist/push-apns-CHUTf5fh.js +0 -1061
- package/dist/pw-ai-DPV1q8xc.js +0 -2268
- package/dist/qmd-manager-Dlyrllit.js +0 -1799
- package/dist/qr-cli-Dxp3C4eA.js +0 -359
- package/dist/qr-image-BqQWAdsz.js +0 -2
- package/dist/queue-B6wGsjBh.js +0 -636
- package/dist/realtime-provider-shared-CjyMmm-x.js +0 -21
- package/dist/realtime-transcription-provider-C3KDEeGw.js +0 -180
- package/dist/realtime-voice-provider-WpxiXAqx.js +0 -342
- package/dist/record-shared-B1JngQ0O.js +0 -10
- package/dist/region-eNoH-aE8.js +0 -74
- package/dist/register.agent-DjEMzHSM.js +0 -241
- package/dist/register.configure-VpDjmPim.js +0 -15
- package/dist/register.maintenance-Bfd-BrEw.js +0 -443
- package/dist/register.message-BUAWvHEW.js +0 -601
- package/dist/register.onboard-D8DOKdFA.js +0 -83
- package/dist/register.runtime-BnPl3ouC.js +0 -343
- package/dist/register.runtime-C3VwoQaW.js +0 -81
- package/dist/register.setup-ED3BxpQA.js +0 -104
- package/dist/register.status-health-sessions-C0kPqTo8.js +0 -1211
- package/dist/register.subclis-BGrRMx_K.js +0 -3
- package/dist/register.subclis-BgdtMdC4.js +0 -232
- package/dist/remote-env-BAi-jql2.js +0 -12
- package/dist/replay-policy-COnD0YJl.js +0 -8
- package/dist/replay-policy-D4RdgaIZ.js +0 -10
- package/dist/reply-B9iku3Vu.js +0 -3523
- package/dist/reply-payloads-DaWnvZFb.js +0 -78
- package/dist/reply-prefix-D_x6MM3Q.js +0 -33
- package/dist/reply.runtime-DC_qTxWc.js +0 -2
- package/dist/resolve-D3giEZj4.js +0 -280
- package/dist/restart-handoff-lV2xM09Z.js +0 -2
- package/dist/restart-health-35eesagj.js +0 -203
- package/dist/restart-health-BotG9-Zg.js +0 -2
- package/dist/restart-pf6Zqlgl.js +0 -454
- package/dist/restart-stale-pids-DCtlWGBh.js +0 -529
- package/dist/retry-DSboRh9T.js +0 -76
- package/dist/retry-policy-CkDNftgh.js +0 -58
- package/dist/route-reply-BFcr1fvj.js +0 -141
- package/dist/route-reply.runtime-HOUK8uDO.js +0 -2
- package/dist/rpc-CQwfsySN.js +0 -61
- package/dist/rpc.runtime-DiwjuRBV.js +0 -21
- package/dist/run-main-OjNMZyXa.js +0 -453
- package/dist/run-wait-DMiGPgPf.js +0 -118
- package/dist/runner-B--qu6Qm.js +0 -1497
- package/dist/runtime-BJ0UokoN.js +0 -2
- package/dist/runtime-BSuZXVXq.js +0 -355
- package/dist/runtime-B_DKJsuG.js +0 -725
- package/dist/runtime-CI87-tZg.js +0 -191
- package/dist/runtime-Cc6PgJbr.js +0 -107
- package/dist/runtime-DGF3I3_g.js +0 -9
- package/dist/runtime-Dfvvcuic.js +0 -72
- package/dist/runtime-TNNT_OrI.js +0 -200
- package/dist/runtime-YH3CE4eQ2.js +0 -242
- package/dist/runtime-api-B5xKNnZ9.js +0 -12
- package/dist/runtime-api-CMG5-b6Q2.js +0 -2
- package/dist/runtime-api-ChFdpsKY.js +0 -3
- package/dist/runtime-embedded-pi.runtime-BszFlzTt.js +0 -3
- package/dist/runtime-env-Clh0MW-d.js +0 -9
- package/dist/runtime-internal-CoQKvsS_.js +0 -2
- package/dist/runtime-model-auth.runtime-Cya-LuWL.js +0 -39
- package/dist/runtime-plugins-DNdpXSxM.js +0 -69
- package/dist/runtime-prepare.runtime-CayOPY9P.js +0 -80
- package/dist/runtime-provider-C-L4QipI.js +0 -21
- package/dist/runtime-shared-Dy_2RXMm.js +0 -249
- package/dist/runtime-taskflow-N2ChOWcS.js +0 -250
- package/dist/runtime-web-channel-plugin-C8CjwZRm.js +0 -215
- package/dist/runtime-web-tools-BvAG0LO3.js +0 -1467
- package/dist/sandbox-Bbc-GWm9.js +0 -2586
- package/dist/sandbox-CSOc5tM4.js +0 -4
- package/dist/sandbox-cli-CT-AarMn.js +0 -447
- package/dist/schtasks-jmQncr1-.js +0 -785
- package/dist/secrets-cli-D1EGuqKu.js +0 -2114
- package/dist/security-audit-BeFqdMin.js +0 -34
- package/dist/security-cli-DbD2JBGF.js +0 -486
- package/dist/semantic-dedup-CZxiDAfb.js +0 -95
- package/dist/send-CGF-mKH3.js +0 -993
- package/dist/send-media-BCm-tPYM.js +0 -2123
- package/dist/server-BWwUuJYL.js +0 -77
- package/dist/server-cBkUNKnZ.js +0 -13
- package/dist/server-context-D_30U_XN.js +0 -4164
- package/dist/server-methods-Bs4pJXUR.js +0 -11937
- package/dist/server-middleware-Dr3VqWzc.js +0 -110
- package/dist/server-node-events-DVfmqVwQ.js +0 -451
- package/dist/server.impl-BJbVZ0t9.js +0 -19765
- package/dist/service-BI1Vz4Xe.js +0 -132
- package/dist/service-CHv4oM_x.js +0 -2
- package/dist/service-audit-DUt5vf5G.js +0 -254
- package/dist/service-audit-VJKA2Zjk.js +0 -2
- package/dist/session-SfhQH5KQ.js +0 -48
- package/dist/session-archive.runtime-B8CG4Ram.js +0 -2
- package/dist/session-conversation-l2xHTnMN.js +0 -27
- package/dist/session-cost-usage-BKZY5nPZ.js +0 -2
- package/dist/session-cost-usage-CmX6miDz.js +0 -648
- package/dist/session-file-CL6lkGa1.js +0 -44
- package/dist/session-key-BmBQ4szp.js +0 -65
- package/dist/session-meta-BR5xK9t1.js +0 -109
- package/dist/session-override-BKrEVfnV.js +0 -103
- package/dist/session-reset-model.runtime-Buk5p4ha.js +0 -120
- package/dist/session-reset-service-BVvvwdRa.js +0 -474
- package/dist/session-subagent-reactivation.runtime-BZNsC5wr.js +0 -2
- package/dist/session-tab-registry-XSWB4W6w.js +0 -553
- package/dist/session-updates-BteiRNzh.js +0 -234
- package/dist/session-updates.runtime-D2XSr1UE.js +0 -2
- package/dist/session-utils-B-CMvBgt.js +0 -930
- package/dist/session-utils.fs-CYcamwPP.js +0 -537
- package/dist/sessions-B5jygaWj.js +0 -231
- package/dist/sessions-BD7awYpY.js +0 -45
- package/dist/sessions-BzM5kMV8.js +0 -2
- package/dist/sessions.runtime-oTrbiPRt.js +0 -2
- package/dist/setup-BoZjwU6i.js +0 -505
- package/dist/setup-DQ_xc449.js +0 -329
- package/dist/setup-Dm1kEe1b.js +0 -15
- package/dist/setup-binary-BJMUy4FP.js +0 -2
- package/dist/setup-surface-D8PAGJCT.js +0 -586
- package/dist/setup-tools-B1DDAQcl.js +0 -4
- package/dist/setup-wizard-proxy-CXecAj2f.js +0 -139
- package/dist/setup.finalize-DYg55WnG.js +0 -436
- package/dist/setup.gateway-config-DWNIMpld.js +0 -246
- package/dist/shared-B1VFlQTd.js +0 -218
- package/dist/shared-B5czq-MF.js +0 -175
- package/dist/shared-BQt90p2U.js +0 -36
- package/dist/shared-CIgFLTPv.js +0 -127
- package/dist/shared-CQhbwWcx.js +0 -219
- package/dist/shared-DDPpwpbe.js +0 -137
- package/dist/shared-DyzdPKTA.js +0 -224
- package/dist/shared-runtime-D-MybTye.js +0 -7
- package/dist/short-term-promotion-Dj0a8ugl.js +0 -1631
- package/dist/simple-completion-runtime-BFLs1pEi.js +0 -131
- package/dist/simple-completion-transport-RE6NPD4B.js +0 -32
- package/dist/skill-commands-CskrC_3W.js +0 -82
- package/dist/skill-commands.runtime-BQvrQPdi.js +0 -2
- package/dist/skills-install-Dg0hrLqC.js +0 -822
- package/dist/speech-core-Dg6E-HQH.js +0 -126
- package/dist/speech-provider-B8AJ3snZ.js +0 -103
- package/dist/speech-provider-B9cT4Gjm.js +0 -39
- package/dist/speech-provider-Bi2E3iv8.js +0 -182
- package/dist/speech-provider-CZSo12LO.js +0 -101
- package/dist/speech-provider-Cj9cz2XB.js +0 -184
- package/dist/speech-provider-R64i_C4Y.js +0 -167
- package/dist/ssh-tunnel-dSVKikW0.js +0 -159
- package/dist/ssh-tunnel-tfx0yANN.js +0 -2
- package/dist/ssrf-runtime-CGgU7d_A.js +0 -6
- package/dist/stage-sandbox-media.runtime-vS4_gqco.js +0 -230
- package/dist/standalone-generate-CEVB92OE.js +0 -217
- package/dist/standalone-generate-EPaOZgrf.js +0 -2
- package/dist/state-migrations-uFpgm1mQ.js +0 -823
- package/dist/status-BLvCM5Ba.js +0 -399
- package/dist/status-CjZEGpOn.js +0 -500
- package/dist/status-CtGb77xh.js +0 -473
- package/dist/status-DeOg-kac.js +0 -2
- package/dist/status-all-CUUt2uLK.js +0 -495
- package/dist/status-json-CKZoUDkl.js +0 -14
- package/dist/status-json-command-BZpfq-t-.js +0 -92
- package/dist/status-runtime-shared-3yS4P9VD.js +0 -271
- package/dist/status-scF4idaf.js +0 -3
- package/dist/status.agent-local-BjZrgfxM.js +0 -58
- package/dist/status.command.text-runtime-BJVN8JqQ.js +0 -15
- package/dist/status.format-BB7s3jni.js +0 -60
- package/dist/status.gateway-connection.runtime-Cdh_gMsz.js +0 -2
- package/dist/status.gateway-probe-Bx2GQ9TU.js +0 -16
- package/dist/status.scan-XFmv1sO8.js +0 -62
- package/dist/status.scan-overview-yDUTiScm.js +0 -395
- package/dist/status.scan.fast-json-CyTKi1z8.js +0 -128
- package/dist/status.scan.fast-json-FEegP0m5.js +0 -2
- package/dist/status.scan.runtime-DPX-O1i4.js +0 -417
- package/dist/status.summary-CLyVQFLP.js +0 -2
- package/dist/status.summary-DYD-kVqt.js +0 -209
- package/dist/status.update-D0v2dhjh.js +0 -2
- package/dist/status.update-fG9weCeY.js +0 -79
- package/dist/store-CB8cC8s0.js +0 -1112
- package/dist/store.runtime-ItAjV6eb.js +0 -2
- package/dist/stream-BPDfd8e1.js +0 -129
- package/dist/stream-BmplokBX.js +0 -649
- package/dist/stream-CxHR78zN.js +0 -26
- package/dist/stream-DBSqjZK_.js +0 -153
- package/dist/stream-DnQfYsj6.js +0 -27
- package/dist/stream-W2dOHnSg.js +0 -76
- package/dist/stream-wrappers-DarIRPWz.js +0 -144
- package/dist/strip-inbound-meta-BltI8kVf.js +0 -155
- package/dist/subagent-announce.registry.runtime-B2pfZw2p.js +0 -3
- package/dist/subagent-control-BTb1NZKm.js +0 -485
- package/dist/subagent-followup.runtime-CxXMev7H.js +0 -68
- package/dist/subagent-list-CU2DlTNj.js +0 -168
- package/dist/subagent-orphan-recovery-lqdIgbEP.js +0 -214
- package/dist/subagent-registry-apNqP8Xn.js +0 -2889
- package/dist/subagent-registry-read-C8xgeh3J.js +0 -57
- package/dist/subagent-registry-runtime-lzitxvG1.js +0 -2
- package/dist/subagent-registry.runtime-DMnY4uWu.js +0 -3
- package/dist/subagent-spawn-lUENqxqV.js +0 -782
- package/dist/subagents-format-CAP1ruPY.js +0 -629
- package/dist/supervisor-DLgjrm-c.js +0 -737
- package/dist/system-cli-BCgDARtJ.js +0 -60
- package/dist/system-prompt-C414pRhO.js +0 -2
- package/dist/system-prompt-T5mXJ7TP.js +0 -711
- package/dist/system-prompt-cache-boundary-NtELRwVL.js +0 -25
- package/dist/system-run-command-DKJXglyj.js +0 -300
- package/dist/systemd-CuaTSaBa.js +0 -591
- package/dist/systemd-hints-B_h09Mzm.js +0 -76
- package/dist/systemd-linger-BA63Qx3W.js +0 -2
- package/dist/systemd-linger-DQ03a1ek.js +0 -68
- package/dist/tables-DFdELq_3.js +0 -832
- package/dist/tailscale-status-PTtL7jnj.js +0 -72
- package/dist/targets-CRHINrER.js +0 -300
- package/dist/targets-UyRPOuj6.js +0 -595
- package/dist/targets.runtime-vvzN_6WM.js +0 -2
- package/dist/task-executor-CtuKi2TZ.js +0 -350
- package/dist/task-owner-access-DhSShXSw.js +0 -48
- package/dist/task-registry-control.runtime-CsUj_KYA.js +0 -3
- package/dist/task-registry-delivery-runtime-Dic6aaTy.js +0 -3
- package/dist/task-registry-delivery-runtime-DtH77Z_E.js +0 -2
- package/dist/task-registry-tECWk779.js +0 -2346
- package/dist/task-registry.maintenance-Du91FMxz.js +0 -2
- package/dist/task-registry.maintenance-IBRK-koK.js +0 -425
- package/dist/testing-DyM4-o2f.js +0 -441
- package/dist/text-report-BEzLSDXl.js +0 -587
- package/dist/text-runtime-CjATQur1.js +0 -313
- package/dist/thread-bindings-BuyhU9E1.js +0 -223
- package/dist/tool-auth-shared-CPke5dxM.js +0 -53
- package/dist/tool-config-shared-DT9mUxpt.js +0 -19
- package/dist/tool-schema-runtime-DTZlFcMR.js +0 -1892
- package/dist/tools-effective-inventory-B16Ib7bd.js +0 -152
- package/dist/tools.runtime-B6sF2TBH.js +0 -4
- package/dist/transcript-0fLDbW8-.js +0 -222
- package/dist/transcript-B3chs9GK.js +0 -191
- package/dist/transcript-DQsKeQyR.js +0 -2
- package/dist/transcript.runtime-Bz9gTz-q.js +0 -2
- package/dist/transport-policy-BLTAZ-oe.js +0 -75
- package/dist/transport-ready-CjD7QFVT.js +0 -36
- package/dist/tts-BKZmS4xr.js +0 -40
- package/dist/tts-BObT55hT.js +0 -31
- package/dist/tui-B9QEI36P.js +0 -4018
- package/dist/tui-cli-D0ST19K6.js +0 -31
- package/dist/typing-mode-BueK7uiv.js +0 -84
- package/dist/undici-global-dispatcher-eRWmqD02.js +0 -99
- package/dist/update-Bhmi2Spr.js +0 -1253
- package/dist/update-check-JM7VVIJX.js +0 -431
- package/dist/update-cli-BlJMXLUZ.js +0 -1779
- package/dist/update-runner-BhQ8gYeg.js +0 -1492
- package/dist/usage-AvsukxPf.js +0 -71
- package/dist/usage-format-CiHAOGUv.js +0 -2
- package/dist/usage-format-DEkEYT6G.js +0 -507
- package/dist/utils-BwORcPSF.js +0 -189
- package/dist/video-generation-D4NjX7OM.js +0 -167
- package/dist/video-generation-provider--Hl1nMjg.js +0 -233
- package/dist/video-generation-provider-BYmO0XfA.js +0 -104
- package/dist/video-generation-provider-CTlDBaAN.js +0 -240
- package/dist/video-generation-provider-Cx3N6a-k.js +0 -263
- package/dist/video-generation-provider-CxAzTS6S.js +0 -181
- package/dist/video-generation-provider-D2-wBkk8.js +0 -246
- package/dist/video-generation-provider-DhD2Xpwp.js +0 -64
- package/dist/video-generation-provider-Dp7jqb8H.js +0 -77
- package/dist/video-generation-provider-WfRVn7Nn.js +0 -227
- package/dist/video-generation-provider-lCyC0SPc.js +0 -171
- package/dist/video-http-CqiFyKro.js +0 -29
- package/dist/video-model-catalog-Dujyv6aJ.js +0 -187
- package/dist/web-media-B770i-06.js +0 -2
- package/dist/web-media-CfbPpWDK.js +0 -330
- package/dist/web-search-C7rRmaDZ.js +0 -221
- package/dist/web-search-provider-DXmbjaIP.js +0 -155
- package/dist/web-search-provider-common-DxHMfm5S.js +0 -206
- package/dist/web-search-provider-config-DopQHA3M.js +0 -52
- package/dist/web-shared-BQmfD1uO.js +0 -414
- package/dist/x-search-shared-C-MC18vi.js +0 -109
- /package/dist/{account-lookup-44DR0qFz.js → account-lookup-DvZ7IbyB.js} +0 -0
- /package/dist/{auth-profiles.runtime-CeH05HY2.js → auth-profiles.runtime-CNNciZQU.js} +0 -0
- /package/dist/{backoff-CoEL_G0O.js → backoff-D10eQVn6.js} +0 -0
- /package/dist/{chat-envelope-C8CaVGEc.js → chat-envelope-C14DhfdY.js} +0 -0
- /package/dist/{chat-message-content-BmiUVjys.js → chat-message-content-N9aXPKj0.js} +0 -0
- /package/dist/{commands-H3Ab0eU8.js → commands-BNMz19sX.js} +0 -0
- /package/dist/{control-ui-shared-upny-T3O.js → control-ui-shared-Bdc3sIMw.js} +0 -0
- /package/dist/{detect-binary-BF7GWFFn.js → detect-binary-DykWiFpV.js} +0 -0
- /package/dist/{device-auth-ChMjC2OY.js → device-auth-Co78c3Fk.js} +0 -0
- /package/dist/{device-identity-CnWSzhCW.js → device-identity-BbqzkeXB.js} +0 -0
- /package/dist/{device-metadata-normalization-BCk_oevU.js → device-metadata-normalization-_VVweA-R.js} +0 -0
- /package/dist/{directive-tags-C-tVOPf_.js → directive-tags-DISVLDCp.js} +0 -0
- /package/dist/{exec-file-CMG8z0ly.js → exec-file-CJGGCNuX.js} +0 -0
- /package/dist/{fetch-timeout-BAjBTvFf.js → fetch-timeout-BCovYv8d.js} +0 -0
- /package/dist/{fingerprint-vRPYSVrE.js → fingerprint-Dl8U2WD6.js} +0 -0
- /package/dist/{identity-BtgZsd-F.js → identity-Dplh_aWR.js} +0 -0
- /package/dist/{input-provenance-CqVg_UvP.js → input-provenance-DXlFriXS.js} +0 -0
- /package/dist/{issue-format-BJCe7wW8.js → issue-format-CxtLa4Cu.js} +0 -0
- /package/dist/{kill-tree-cyGT7uvN.js → kill-tree-DCyfVQx0.js} +0 -0
- /package/dist/{model-auth-markers-CrDTQj4i.js → model-auth-markers-BR92KCie.js} +0 -0
- /package/dist/{model-auth-runtime-shared-Dlg_9I8x.js → model-auth-runtime-shared-7sMIRCy3.js} +0 -0
- /package/dist/{number-coercion-D1JCit9l.js → number-coercion-Cmu1aJr8.js} +0 -0
- /package/dist/{plugin-approvals-D2nSmWGQ.js → plugin-approvals-BVOH9uWd.js} +0 -0
- /package/dist/{plugin-web-search-config-CM7ac77h.js → plugin-web-search-config-Vy4SBasR.js} +0 -0
- /package/dist/{ports-lsof-rC3_YG8t.js → ports-lsof-C7nTF2Et.js} +0 -0
- /package/dist/{ports-probe-CKr2RdYw.js → ports-probe-BFA3MD3-.js} +0 -0
- /package/dist/{prompt-cache-stability-DdwE3HeP.js → prompt-cache-stability-CgXAu47S.js} +0 -0
- /package/dist/{prompt-style-BCo80D6m.js → prompt-style-BCVDnx1C.js} +0 -0
- /package/dist/{provider-discovery-RmybjjET.js → provider-discovery-DfcBjamA.js} +0 -0
- /package/dist/{provider-model-compat-CsF2NGa6.js → provider-model-compat-DfOMY_2L.js} +0 -0
- /package/dist/{restart-handoff-B3HMjoAC.js → restart-handoff-CUig5xgo.js} +0 -0
- /package/dist/{runtime-parse-D4az8KIY.js → runtime-parse-DYEtqXT6.js} +0 -0
- /package/dist/{runtime-status-Di5Hf2P6.js → runtime-status-Cph8qA_2.js} +0 -0
- /package/dist/{schtasks-exec-BgQqxhbL.js → schtasks-exec-wK5FEC9N.js} +0 -0
- /package/dist/{session-transcript-files.fs-CTjDzbyc.js → session-transcript-files.fs-98DIXUOq.js} +0 -0
- /package/dist/{subagent-registry-state-zLMA_MzM.js → subagent-registry-state-CjRrrVgp.js} +0 -0
- /package/dist/{subagent-session-metrics-BgoCTpFX.js → subagent-session-metrics-8IQoh3DH.js} +0 -0
- /package/dist/{targets-DOJmrCN8.js → targets-uT1GHLfz.js} +0 -0
- /package/dist/{thread-info-BvQiu1xr.js → thread-info-DjVKrfI6.js} +0 -0
- /package/dist/{tokens-DIzGgGwL.js → tokens-CB2-NTu5.js} +0 -0
- /package/dist/{transcript-events-BC4_m8-c.js → transcript-events-B4kB35M0.js} +0 -0
- /package/dist/{transcript-mirror-BlMhpuHP.js → transcript-mirror-BQwPaEwA.js} +0 -0
- /package/dist/{wsl-DQ0RgjjQ.js → wsl-084fnhGP.js} +0 -0
- /package/dist/{zod-parse-Cu9hgbVC.js → zod-parse-DRCmgWgX.js} +0 -0
|
@@ -0,0 +1,2825 @@
|
|
|
1
|
+
import { d as readStringValue, i as normalizeLowercaseStringOrEmpty, s as normalizeOptionalString, t as hasNonEmptyString } from "./string-coerce-xZwG7Dq8.js";
|
|
2
|
+
import { r as formatErrorMessage } from "./errors-Ez4cKI2Y.js";
|
|
3
|
+
import { n as defaultRuntime } from "./runtime-CGvKIwIL.js";
|
|
4
|
+
import { f as resolveConfigDir } from "./utils-C8dt4mi-.js";
|
|
5
|
+
import { o as isInternalMessageChannel, p as resolveMessageChannel, s as isMarkdownCapableMessageChannel } from "./message-channel-DOJZxe6w.js";
|
|
6
|
+
import { t as sanitizeForLog } from "./ansi-BFdeIM_K.js";
|
|
7
|
+
import { d as resolveResponseUsageMode, u as normalizeVerboseLevel } from "./thinking.shared-lXIMjxJI.js";
|
|
8
|
+
import { s as isCliProvider } from "./model-selection-Bq91MzO2.js";
|
|
9
|
+
import { u as resolveAgentIdFromSessionKey } from "./session-key-Dny5dRer.js";
|
|
10
|
+
import { _ as resolveRunModelFallbacksOverride, v as resolveSessionAgentId } from "./agent-scope-z3lpbLWu.js";
|
|
11
|
+
import { r as logVerbose } from "./globals-CwigADVM.js";
|
|
12
|
+
import "./defaults-ZxwOnZ1C.js";
|
|
13
|
+
import { o as loadConfig } from "./io-Bz-M35LC.js";
|
|
14
|
+
import "./config-DuLfQQvE.js";
|
|
15
|
+
import { g as resolveMemoryFlushPlan } from "./memory-state-Cly_TwQt.js";
|
|
16
|
+
import { _ as resolveGroupSessionKey, c as updateSessionStore, l as updateSessionStoreEntry } from "./store-D_vXZ7m9.js";
|
|
17
|
+
import "./sessions-CyYVTseV.js";
|
|
18
|
+
import { a as resolveSessionTranscriptPath, i as resolveSessionFilePathOptions, r as resolveSessionFilePath } from "./paths-DrQr2my6.js";
|
|
19
|
+
import { a as resolveFreshSessionTotalTokens } from "./types-BCUhyLRe.js";
|
|
20
|
+
import { t as loadSessionStore } from "./store-load-5DAj5ABj.js";
|
|
21
|
+
import { a as isSilentReplyText, i as isSilentReplyPrefixText, n as SILENT_REPLY_TOKEN, o as startsWithSilentToken, s as stripLeadingSilentToken } from "./tokens-CB2-NTu5.js";
|
|
22
|
+
import { N as readPostCompactionContext, t as compactEmbeddedPiSession } from "./compact-DEsHFhEL.js";
|
|
23
|
+
import { o as resolveContextTokensForModel } from "./context-B2wCjR9D.js";
|
|
24
|
+
import { a as resolveModelCostConfig, i as formatUsd, n as estimateUsageCost, r as formatTokenCount } from "./usage-format-DQTT4pqY.js";
|
|
25
|
+
import { a as normalizeUsage, n as deriveSessionTotalTokens, r as hasNonzeroUsage, t as derivePromptTokens } from "./usage-CG1Nshi3.js";
|
|
26
|
+
import { i as readSessionMessages } from "./session-utils.fs-DV8bxCEw.js";
|
|
27
|
+
import { s as stripHeartbeatToken } from "./heartbeat-B1UJqney.js";
|
|
28
|
+
import { a as generateSecureUuid } from "./secure-random-B1Z18GKR.js";
|
|
29
|
+
import { n as isDiagnosticsEnabled, t as emitDiagnosticEvent } from "./diagnostic-events-DfwuwExP.js";
|
|
30
|
+
import { n as GatewayDrainingError, t as CommandLaneClearedError } from "./command-queue-CmX7XAL1.js";
|
|
31
|
+
import "./pi-embedded-helpers-y7PopKx-.js";
|
|
32
|
+
import { C as isBillingErrorMessage, S as sanitizeUserFacingText, T as isRateLimitErrorMessage, d as isCompactionFailureError, f as isContextOverflowError, h as isLikelyContextOverflowError, t as BILLING_ERROR_USER_MESSAGE, w as isOverloadedErrorMessage, y as isTransientHttpError } from "./errors-CVtNPIIv.js";
|
|
33
|
+
import { n as resolveSandboxConfigForAgent } from "./config-DZwpO1J4.js";
|
|
34
|
+
import { n as resolveSandboxRuntimeStatus } from "./runtime-status-BGBO_3JB.js";
|
|
35
|
+
import "./thinking-CHPwc2Q0.js";
|
|
36
|
+
import { c as resolveModelAuthMode } from "./model-auth-BQpkMtoP.js";
|
|
37
|
+
import { u as estimateMessagesTokens } from "./tool-schema-runtime-DZsW_KR4.js";
|
|
38
|
+
import { a as resolveSandboxedMediaSource, t as assertMediaNotDataUrl } from "./sandbox-paths-YYUkkfbi.js";
|
|
39
|
+
import { h as resolvePathFromInput, p as resolveEffectiveToolFsWorkspaceOnly, s as parseReplyDirectives } from "./deliver-SAyi_F0e.js";
|
|
40
|
+
import { i as enqueueSystemEvent } from "./system-events-Yd4M0_kC.js";
|
|
41
|
+
import { a as isAudioFileName } from "./mime-DU0uzyOh.js";
|
|
42
|
+
import { p as resolveSendableOutboundReplyParts, s as hasOutboundReplyContent } from "./reply-payload-CNLx7o4Q.js";
|
|
43
|
+
import { i as isRenderablePayload, n as applyReplyThreading, t as applyReplyTagsToPayload } from "./reply-payloads-CFKnBOGu.js";
|
|
44
|
+
import { i as resolveReplyToMode, t as createReplyToModeFilterForChannel } from "./reply-threading-WuEtpU4C.js";
|
|
45
|
+
import { n as filterMessagingToolMediaDuplicates, r as shouldSuppressMessagingToolReplies, t as filterMessagingToolDuplicates } from "./reply-payloads-dedupe-Ambyl4GJ.js";
|
|
46
|
+
import { c as isFallbackSummaryError, f as LiveSessionModelSwitchError, l as runWithModelFallback } from "./kaijibot-tools-Df_9YJcO.js";
|
|
47
|
+
import { u as saveMediaSource } from "./store-BqvhZgld.js";
|
|
48
|
+
import { i as emitAgentEvent, u as registerAgentRunContext } from "./agent-events-DScaTZPE.js";
|
|
49
|
+
import { a as scheduleFollowupDrain, n as enqueueFollowupRun, o as refreshQueuedFollowupSession } from "./queue-BveCZpTb.js";
|
|
50
|
+
import { n as routeReply, t as isRoutableChannel } from "./route-reply-CXZFXlfK.js";
|
|
51
|
+
import { h as replyRunRegistry, m as createReplyOperation, p as ReplyRunAlreadyActiveError, s as queueEmbeddedPiMessage } from "./runs-CEDW87Fd.js";
|
|
52
|
+
import { a as ensureSandboxWorkspaceForSession } from "./sandbox-epLgxWBQ.js";
|
|
53
|
+
import { n as isLikelyExecutionAckPrompt, t as runEmbeddedPiAgent } from "./pi-embedded-runner-DXHhhGRS.js";
|
|
54
|
+
import { o as resolveBootstrapWarningSignaturesSeen } from "./bootstrap-budget-zHsa4DnA.js";
|
|
55
|
+
import "./pi-embedded-Cp3OIZy9.js";
|
|
56
|
+
import { n as resolveCronStorePath, t as loadCronStore } from "./store-FPsFA16D.js";
|
|
57
|
+
import { r as resolveEffectiveBlockStreamingConfig } from "./block-streaming-BTtPFYsM.js";
|
|
58
|
+
import { n as resolveOriginMessageProvider, r as resolveOriginMessageTo, t as resolveOriginAccountId } from "./origin-routing-BWt0cuvv.js";
|
|
59
|
+
import { r as resolveActiveRunQueueAction, t as createTypingSignaler } from "./typing-mode-BoJYxUas.js";
|
|
60
|
+
import { a as setCliSessionBinding, o as setCliSessionId, r as getCliSessionBinding, t as runCliAgent } from "./cli-runner-12iECISR.js";
|
|
61
|
+
import { i as resolveFallbackTransition, n as buildFallbackNotice, t as buildFallbackClearedNotice } from "./fallback-state-DcYqyCEy.js";
|
|
62
|
+
import { n as classifyOAuthRefreshFailure, t as buildOAuthRefreshFailureLoginCommand } from "./oauth-refresh-failure-D4qLGlz9.js";
|
|
63
|
+
import { a as resolveModelFallbackOptions, c as resolveRunAuthProfile, i as isBunFetchSocketError, o as resolveQueuedReplyExecutionConfig, r as formatBunFetchSocketError, s as resolveQueuedReplyRuntimeConfig, t as buildEmbeddedRunExecutionParams } from "./agent-runner-utils--p6HAP6k.js";
|
|
64
|
+
import { n as createBlockReplyContentKey, r as createBlockReplyPipeline, t as createAudioAsVoiceBuffer } from "./block-reply-pipeline-BFCpQM1A.js";
|
|
65
|
+
import { n as incrementCompactionCount } from "./session-updates-BRFvmIoC.js";
|
|
66
|
+
import fs from "node:fs";
|
|
67
|
+
import path from "node:path";
|
|
68
|
+
import crypto from "node:crypto";
|
|
69
|
+
//#region src/auto-reply/reply/reply-delivery.ts
|
|
70
|
+
function normalizeReplyPayloadDirectives(params) {
|
|
71
|
+
const parseMode = params.parseMode ?? "always";
|
|
72
|
+
const silentToken = params.silentToken ?? "NO_REPLY";
|
|
73
|
+
const sourceText = params.payload.text ?? "";
|
|
74
|
+
const parsed = parseMode === "always" || parseMode === "auto" && (sourceText.includes("[[") || sourceText.includes("MEDIA:") || sourceText.includes(silentToken)) ? parseReplyDirectives(sourceText, {
|
|
75
|
+
currentMessageId: params.currentMessageId,
|
|
76
|
+
silentToken
|
|
77
|
+
}) : void 0;
|
|
78
|
+
let text = parsed ? parsed.text || void 0 : params.payload.text || void 0;
|
|
79
|
+
if (params.trimLeadingWhitespace && text) text = text.trimStart() || void 0;
|
|
80
|
+
const mediaUrls = params.payload.mediaUrls ?? parsed?.mediaUrls;
|
|
81
|
+
const mediaUrl = params.payload.mediaUrl ?? parsed?.mediaUrl ?? mediaUrls?.[0];
|
|
82
|
+
return {
|
|
83
|
+
payload: {
|
|
84
|
+
...params.payload,
|
|
85
|
+
text,
|
|
86
|
+
mediaUrls,
|
|
87
|
+
mediaUrl,
|
|
88
|
+
replyToId: params.payload.replyToId ?? parsed?.replyToId,
|
|
89
|
+
replyToTag: params.payload.replyToTag || parsed?.replyToTag,
|
|
90
|
+
replyToCurrent: params.payload.replyToCurrent || parsed?.replyToCurrent,
|
|
91
|
+
audioAsVoice: Boolean(params.payload.audioAsVoice || parsed?.audioAsVoice)
|
|
92
|
+
},
|
|
93
|
+
isSilent: parsed?.isSilent ?? false
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function createBlockReplyDeliveryHandler(params) {
|
|
97
|
+
return async (payload) => {
|
|
98
|
+
const { text, skip } = params.normalizeStreamingText(payload);
|
|
99
|
+
if (skip && !resolveSendableOutboundReplyParts(payload).hasMedia) return;
|
|
100
|
+
const taggedPayload = applyReplyTagsToPayload({
|
|
101
|
+
...payload,
|
|
102
|
+
text,
|
|
103
|
+
mediaUrl: payload.mediaUrl ?? payload.mediaUrls?.[0],
|
|
104
|
+
replyToId: payload.replyToId ?? (payload.replyToCurrent === false ? void 0 : params.currentMessageId)
|
|
105
|
+
}, params.currentMessageId);
|
|
106
|
+
if (!isRenderablePayload(taggedPayload) && !payload.audioAsVoice) return;
|
|
107
|
+
const normalized = normalizeReplyPayloadDirectives({
|
|
108
|
+
payload: taggedPayload,
|
|
109
|
+
currentMessageId: params.currentMessageId,
|
|
110
|
+
silentToken: SILENT_REPLY_TOKEN,
|
|
111
|
+
trimLeadingWhitespace: true,
|
|
112
|
+
parseMode: "auto"
|
|
113
|
+
});
|
|
114
|
+
const mediaNormalizedPayload = params.normalizeMediaPaths ? await params.normalizeMediaPaths(normalized.payload) : normalized.payload;
|
|
115
|
+
const blockPayload = params.applyReplyToMode(mediaNormalizedPayload);
|
|
116
|
+
const blockHasMedia = resolveSendableOutboundReplyParts(blockPayload).hasMedia;
|
|
117
|
+
if (!blockPayload.text && !blockHasMedia && !blockPayload.audioAsVoice) return;
|
|
118
|
+
if (normalized.isSilent && !blockHasMedia) return;
|
|
119
|
+
if (blockPayload.text) params.typingSignals.signalTextDelta(blockPayload.text).catch((err) => {
|
|
120
|
+
logVerbose(`block reply typing signal failed: ${String(err)}`);
|
|
121
|
+
});
|
|
122
|
+
if (params.blockStreamingEnabled && params.blockReplyPipeline) params.blockReplyPipeline.enqueue(blockPayload);
|
|
123
|
+
else if (params.blockStreamingEnabled) {
|
|
124
|
+
params.directlySentBlockKeys.add(createBlockReplyContentKey(blockPayload));
|
|
125
|
+
await params.onBlockReply(blockPayload);
|
|
126
|
+
} else if (blockHasMedia) {
|
|
127
|
+
params.directlySentBlockKeys.add(createBlockReplyContentKey(blockPayload));
|
|
128
|
+
await params.onBlockReply({
|
|
129
|
+
...blockPayload,
|
|
130
|
+
text: void 0
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/auto-reply/reply/reply-media-paths.ts
|
|
137
|
+
const HTTP_URL_RE = /^https?:\/\//i;
|
|
138
|
+
const FILE_URL_RE = /^file:\/\//i;
|
|
139
|
+
const WINDOWS_DRIVE_RE = /^[a-zA-Z]:[\\/]/;
|
|
140
|
+
const SCHEME_RE = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
|
|
141
|
+
const HAS_FILE_EXT_RE = /\.\w{1,10}$/;
|
|
142
|
+
const AGENT_STATE_MEDIA_DIRNAME = path.join(".kaijibot", "media");
|
|
143
|
+
const MANAGED_GLOBAL_MEDIA_SUBDIRS = new Set(["outbound"]);
|
|
144
|
+
function isPathInside(root, candidate) {
|
|
145
|
+
const relative = path.relative(path.resolve(root), path.resolve(candidate));
|
|
146
|
+
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
147
|
+
}
|
|
148
|
+
function isManagedGlobalReplyMediaPath(candidate) {
|
|
149
|
+
const globalMediaRoot = path.join(resolveConfigDir(), "media");
|
|
150
|
+
const relative = path.relative(path.resolve(globalMediaRoot), path.resolve(candidate));
|
|
151
|
+
if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return false;
|
|
152
|
+
const firstSegment = relative.split(path.sep)[0] ?? "";
|
|
153
|
+
return MANAGED_GLOBAL_MEDIA_SUBDIRS.has(firstSegment) || firstSegment.startsWith("tool-");
|
|
154
|
+
}
|
|
155
|
+
function isAllowedAbsoluteReplyMediaPath(params) {
|
|
156
|
+
if (isManagedGlobalReplyMediaPath(params.candidate)) return true;
|
|
157
|
+
return [params.workspaceDir, params.sandboxRoot].filter((root) => Boolean(root)).map((root) => path.join(path.resolve(root), AGENT_STATE_MEDIA_DIRNAME)).some((root) => isPathInside(root, params.candidate));
|
|
158
|
+
}
|
|
159
|
+
function isLikelyLocalMediaSource(media) {
|
|
160
|
+
return FILE_URL_RE.test(media) || media.startsWith("/") || media.startsWith("./") || media.startsWith("../") || media.startsWith("~") || WINDOWS_DRIVE_RE.test(media) || media.startsWith("\\\\") || !SCHEME_RE.test(media) && (media.includes("/") || media.includes("\\") || HAS_FILE_EXT_RE.test(media));
|
|
161
|
+
}
|
|
162
|
+
function getPayloadMediaList(payload) {
|
|
163
|
+
return resolveSendableOutboundReplyParts(payload).mediaUrls;
|
|
164
|
+
}
|
|
165
|
+
function createReplyMediaPathNormalizer(params) {
|
|
166
|
+
const agentId = params.sessionKey ? resolveSessionAgentId({
|
|
167
|
+
sessionKey: params.sessionKey,
|
|
168
|
+
config: params.cfg
|
|
169
|
+
}) : void 0;
|
|
170
|
+
const workspaceOnly = resolveEffectiveToolFsWorkspaceOnly({
|
|
171
|
+
cfg: params.cfg,
|
|
172
|
+
agentId
|
|
173
|
+
});
|
|
174
|
+
let sandboxRootPromise;
|
|
175
|
+
const persistedMediaBySource = /* @__PURE__ */ new Map();
|
|
176
|
+
const resolveSandboxRoot = async () => {
|
|
177
|
+
if (!sandboxRootPromise) sandboxRootPromise = ensureSandboxWorkspaceForSession({
|
|
178
|
+
config: params.cfg,
|
|
179
|
+
sessionKey: params.sessionKey,
|
|
180
|
+
workspaceDir: params.workspaceDir
|
|
181
|
+
}).then((sandbox) => sandbox?.workspaceDir);
|
|
182
|
+
return await sandboxRootPromise;
|
|
183
|
+
};
|
|
184
|
+
const persistVolatileAgentMedia = async (media) => {
|
|
185
|
+
if (!path.isAbsolute(media)) return media;
|
|
186
|
+
const sandboxRoot = await resolveSandboxRoot();
|
|
187
|
+
if (![params.workspaceDir, sandboxRoot].filter((root) => Boolean(root)).map((root) => path.join(path.resolve(root), AGENT_STATE_MEDIA_DIRNAME)).some((root) => isPathInside(root, media))) return media;
|
|
188
|
+
const cached = persistedMediaBySource.get(media);
|
|
189
|
+
if (cached) return await cached;
|
|
190
|
+
const persistPromise = saveMediaSource(media, void 0, "outbound").then((saved) => saved.path).catch((err) => {
|
|
191
|
+
persistedMediaBySource.delete(media);
|
|
192
|
+
throw err;
|
|
193
|
+
});
|
|
194
|
+
persistedMediaBySource.set(media, persistPromise);
|
|
195
|
+
try {
|
|
196
|
+
return await persistPromise;
|
|
197
|
+
} catch (err) {
|
|
198
|
+
logVerbose(`failed to persist volatile reply media ${media}: ${String(err)}`);
|
|
199
|
+
return media;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const normalizeMediaSource = async (raw) => {
|
|
203
|
+
const media = raw.trim();
|
|
204
|
+
if (!media) return media;
|
|
205
|
+
assertMediaNotDataUrl(media);
|
|
206
|
+
if (HTTP_URL_RE.test(media)) return media;
|
|
207
|
+
const sandboxRoot = await resolveSandboxRoot();
|
|
208
|
+
if (sandboxRoot) try {
|
|
209
|
+
return await resolveSandboxedMediaSource({
|
|
210
|
+
media,
|
|
211
|
+
sandboxRoot
|
|
212
|
+
});
|
|
213
|
+
} catch (err) {
|
|
214
|
+
if (!isLikelyLocalMediaSource(media) || FILE_URL_RE.test(media)) throw err;
|
|
215
|
+
if (workspaceOnly) throw err;
|
|
216
|
+
if (!path.isAbsolute(media)) return resolvePathFromInput(media, params.workspaceDir);
|
|
217
|
+
if (isAllowedAbsoluteReplyMediaPath({
|
|
218
|
+
candidate: media,
|
|
219
|
+
workspaceDir: params.workspaceDir,
|
|
220
|
+
sandboxRoot
|
|
221
|
+
})) return media;
|
|
222
|
+
throw new Error("Absolute host-local MEDIA paths are blocked in normal replies. Use a safe relative path or the message tool.", { cause: err });
|
|
223
|
+
}
|
|
224
|
+
if (!isLikelyLocalMediaSource(media)) return media;
|
|
225
|
+
if (FILE_URL_RE.test(media)) throw new Error("Absolute host-local MEDIA file URLs are blocked in normal replies. Use a safe relative path or the message tool.");
|
|
226
|
+
if (!path.isAbsolute(media)) return resolvePathFromInput(media, params.workspaceDir);
|
|
227
|
+
if (isAllowedAbsoluteReplyMediaPath({
|
|
228
|
+
candidate: media,
|
|
229
|
+
workspaceDir: params.workspaceDir,
|
|
230
|
+
sandboxRoot
|
|
231
|
+
})) return media;
|
|
232
|
+
throw new Error("Absolute host-local MEDIA paths are blocked in normal replies. Use a safe relative path or the message tool.");
|
|
233
|
+
};
|
|
234
|
+
return async (payload) => {
|
|
235
|
+
const mediaList = getPayloadMediaList(payload);
|
|
236
|
+
if (mediaList.length === 0) return payload;
|
|
237
|
+
const normalizedMedia = [];
|
|
238
|
+
const seen = /* @__PURE__ */ new Set();
|
|
239
|
+
for (const media of mediaList) {
|
|
240
|
+
let normalized;
|
|
241
|
+
try {
|
|
242
|
+
normalized = await persistVolatileAgentMedia(await normalizeMediaSource(media));
|
|
243
|
+
} catch (err) {
|
|
244
|
+
logVerbose(`dropping blocked reply media ${media}: ${String(err)}`);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if (!normalized || seen.has(normalized)) continue;
|
|
248
|
+
seen.add(normalized);
|
|
249
|
+
normalizedMedia.push(normalized);
|
|
250
|
+
}
|
|
251
|
+
if (normalizedMedia.length === 0) return {
|
|
252
|
+
...payload,
|
|
253
|
+
mediaUrl: void 0,
|
|
254
|
+
mediaUrls: void 0
|
|
255
|
+
};
|
|
256
|
+
return {
|
|
257
|
+
...payload,
|
|
258
|
+
mediaUrl: normalizedMedia[0],
|
|
259
|
+
mediaUrls: normalizedMedia
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
const GPT_CHAT_BREVITY_ACK_MAX_CHARS = 420;
|
|
264
|
+
const GPT_CHAT_BREVITY_ACK_MAX_SENTENCES = 3;
|
|
265
|
+
const GPT_CHAT_BREVITY_SOFT_MAX_CHARS = 900;
|
|
266
|
+
const GPT_CHAT_BREVITY_SOFT_MAX_SENTENCES = 6;
|
|
267
|
+
const FALLBACK_SELECTION_STATE_KEYS = [
|
|
268
|
+
"providerOverride",
|
|
269
|
+
"modelOverride",
|
|
270
|
+
"modelOverrideSource",
|
|
271
|
+
"authProfileOverride",
|
|
272
|
+
"authProfileOverrideSource",
|
|
273
|
+
"authProfileOverrideCompactionCount"
|
|
274
|
+
];
|
|
275
|
+
function setFallbackSelectionStateField(entry, key, value) {
|
|
276
|
+
switch (key) {
|
|
277
|
+
case "providerOverride":
|
|
278
|
+
if (entry.providerOverride !== value) {
|
|
279
|
+
entry.providerOverride = value;
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
283
|
+
case "modelOverride":
|
|
284
|
+
if (entry.modelOverride !== value) {
|
|
285
|
+
entry.modelOverride = value;
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
return false;
|
|
289
|
+
case "modelOverrideSource":
|
|
290
|
+
if (entry.modelOverrideSource !== value) {
|
|
291
|
+
entry.modelOverrideSource = value;
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
return false;
|
|
295
|
+
case "authProfileOverride":
|
|
296
|
+
if (entry.authProfileOverride !== value) {
|
|
297
|
+
entry.authProfileOverride = value;
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
return false;
|
|
301
|
+
case "authProfileOverrideSource":
|
|
302
|
+
if (entry.authProfileOverrideSource !== value) {
|
|
303
|
+
entry.authProfileOverrideSource = value;
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
return false;
|
|
307
|
+
case "authProfileOverrideCompactionCount":
|
|
308
|
+
if (entry.authProfileOverrideCompactionCount !== value) {
|
|
309
|
+
entry.authProfileOverrideCompactionCount = value;
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function snapshotFallbackSelectionState(entry) {
|
|
316
|
+
return {
|
|
317
|
+
providerOverride: entry.providerOverride,
|
|
318
|
+
modelOverride: entry.modelOverride,
|
|
319
|
+
modelOverrideSource: entry.modelOverrideSource,
|
|
320
|
+
authProfileOverride: entry.authProfileOverride,
|
|
321
|
+
authProfileOverrideSource: entry.authProfileOverrideSource,
|
|
322
|
+
authProfileOverrideCompactionCount: entry.authProfileOverrideCompactionCount
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
function buildFallbackSelectionState(params) {
|
|
326
|
+
return {
|
|
327
|
+
providerOverride: params.provider,
|
|
328
|
+
modelOverride: params.model,
|
|
329
|
+
modelOverrideSource: "auto",
|
|
330
|
+
authProfileOverride: params.authProfileId,
|
|
331
|
+
authProfileOverrideSource: params.authProfileId ? params.authProfileIdSource : void 0,
|
|
332
|
+
authProfileOverrideCompactionCount: void 0
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function applyFallbackCandidateSelectionToEntry(params) {
|
|
336
|
+
if (params.provider === params.run.provider && params.model === params.run.model) return { updated: false };
|
|
337
|
+
const scopedAuthProfile = resolveRunAuthProfile(params.run, params.provider);
|
|
338
|
+
const nextState = buildFallbackSelectionState({
|
|
339
|
+
provider: params.provider,
|
|
340
|
+
model: params.model,
|
|
341
|
+
authProfileId: scopedAuthProfile.authProfileId,
|
|
342
|
+
authProfileIdSource: scopedAuthProfile.authProfileIdSource
|
|
343
|
+
});
|
|
344
|
+
return {
|
|
345
|
+
updated: applyFallbackSelectionState(params.entry, nextState, params.now),
|
|
346
|
+
nextState
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function applyFallbackSelectionState(entry, nextState, now = Date.now()) {
|
|
350
|
+
let updated = false;
|
|
351
|
+
for (const key of FALLBACK_SELECTION_STATE_KEYS) {
|
|
352
|
+
const nextValue = nextState[key];
|
|
353
|
+
if (nextValue === void 0) {
|
|
354
|
+
if (Object.hasOwn(entry, key)) {
|
|
355
|
+
delete entry[key];
|
|
356
|
+
updated = true;
|
|
357
|
+
}
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (entry[key] !== nextValue) updated = setFallbackSelectionStateField(entry, key, nextValue) || updated;
|
|
361
|
+
}
|
|
362
|
+
if (updated) entry.updatedAt = now;
|
|
363
|
+
return updated;
|
|
364
|
+
}
|
|
365
|
+
function rollbackFallbackSelectionStateIfUnchanged(entry, expectedState, previousState, now = Date.now()) {
|
|
366
|
+
let updated = false;
|
|
367
|
+
for (const key of FALLBACK_SELECTION_STATE_KEYS) {
|
|
368
|
+
if (entry[key] !== expectedState[key]) continue;
|
|
369
|
+
const previousValue = previousState[key];
|
|
370
|
+
if (previousValue === void 0) {
|
|
371
|
+
if (Object.hasOwn(entry, key)) {
|
|
372
|
+
delete entry[key];
|
|
373
|
+
updated = true;
|
|
374
|
+
}
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
if (entry[key] !== previousValue) updated = setFallbackSelectionStateField(entry, key, previousValue) || updated;
|
|
378
|
+
}
|
|
379
|
+
if (updated) entry.updatedAt = now;
|
|
380
|
+
return updated;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Build a human-friendly rate-limit message from a FallbackSummaryError.
|
|
384
|
+
* Includes a countdown when the soonest cooldown expiry is known.
|
|
385
|
+
*/
|
|
386
|
+
function buildRateLimitCooldownMessage(err) {
|
|
387
|
+
if (!isFallbackSummaryError(err)) return "⚠️ All models are temporarily rate-limited. Please try again in a few minutes.";
|
|
388
|
+
const expiry = err.soonestCooldownExpiry;
|
|
389
|
+
const now = Date.now();
|
|
390
|
+
if (typeof expiry === "number" && expiry > now) {
|
|
391
|
+
const secsLeft = Math.max(1, Math.ceil((expiry - now) / 1e3));
|
|
392
|
+
if (secsLeft <= 60) return `⚠️ Rate-limited — ready in ~${secsLeft}s. Please wait a moment.`;
|
|
393
|
+
return `⚠️ Rate-limited — ready in ~${Math.ceil(secsLeft / 60)} min. Please try again shortly.`;
|
|
394
|
+
}
|
|
395
|
+
return "⚠️ All models are temporarily rate-limited. Please try again in a few minutes.";
|
|
396
|
+
}
|
|
397
|
+
function isPureTransientRateLimitSummary(err) {
|
|
398
|
+
return isFallbackSummaryError(err) && err.attempts.length > 0 && err.attempts.every((attempt) => {
|
|
399
|
+
const reason = attempt.reason;
|
|
400
|
+
return reason === "rate_limit" || reason === "overloaded";
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
function isToolResultTurnMismatchError(message) {
|
|
404
|
+
const lower = normalizeLowercaseStringOrEmpty(message);
|
|
405
|
+
return lower.includes("toolresult") && lower.includes("tooluse") && lower.includes("exceeds the number") && lower.includes("previous turn");
|
|
406
|
+
}
|
|
407
|
+
function collapseRepeatedFailureDetail(message) {
|
|
408
|
+
const parts = message.split(/\s+\|\s+/u).map((part) => part.trim()).filter(Boolean);
|
|
409
|
+
if (parts.length >= 2 && parts.every((part) => part === parts[0])) return parts[0];
|
|
410
|
+
return message.trim();
|
|
411
|
+
}
|
|
412
|
+
const SAFE_MISSING_API_KEY_PROVIDERS = new Set([
|
|
413
|
+
"anthropic",
|
|
414
|
+
"google",
|
|
415
|
+
"openai",
|
|
416
|
+
"openai-codex"
|
|
417
|
+
]);
|
|
418
|
+
function buildMissingApiKeyFailureText(message) {
|
|
419
|
+
const normalizedMessage = collapseRepeatedFailureDetail(message);
|
|
420
|
+
const provider = normalizedMessage.match(/No API key found for provider "([^"]+)"/u)?.[1]?.trim().toLowerCase();
|
|
421
|
+
if (!provider) return null;
|
|
422
|
+
if (provider === "openai" && normalizedMessage.includes("OpenAI Codex OAuth")) return "⚠️ Missing API key for OpenAI on the gateway. Use `openai-codex/gpt-5.4` for OAuth, or set `OPENAI_API_KEY`, then try again.";
|
|
423
|
+
if (SAFE_MISSING_API_KEY_PROVIDERS.has(provider)) return `⚠️ Missing API key for provider "${provider}". Configure the gateway auth for that provider, then try again.`;
|
|
424
|
+
return "⚠️ Missing API key for the selected provider on the gateway. Configure provider auth, then try again.";
|
|
425
|
+
}
|
|
426
|
+
function buildExternalRunFailureText(message) {
|
|
427
|
+
const normalizedMessage = collapseRepeatedFailureDetail(message);
|
|
428
|
+
if (isToolResultTurnMismatchError(normalizedMessage)) return "⚠️ Session history got out of sync. Please try again, or use /new to start a fresh session.";
|
|
429
|
+
const missingApiKeyFailure = buildMissingApiKeyFailureText(normalizedMessage);
|
|
430
|
+
if (missingApiKeyFailure) return missingApiKeyFailure;
|
|
431
|
+
const oauthRefreshFailure = classifyOAuthRefreshFailure(normalizedMessage);
|
|
432
|
+
if (oauthRefreshFailure) {
|
|
433
|
+
const loginCommand = buildOAuthRefreshFailureLoginCommand(oauthRefreshFailure.provider);
|
|
434
|
+
if (oauthRefreshFailure.reason) return `⚠️ Model login expired on the gateway${oauthRefreshFailure.provider ? ` for ${oauthRefreshFailure.provider}` : ""}. Re-auth with \`${loginCommand}\`, then try again.`;
|
|
435
|
+
return `⚠️ Model login failed on the gateway${oauthRefreshFailure.provider ? ` for ${oauthRefreshFailure.provider}` : ""}. Please try again. If this keeps happening, re-auth with \`${loginCommand}\`.`;
|
|
436
|
+
}
|
|
437
|
+
return "⚠️ Something went wrong while processing your request. Please try again, or use /new to start a fresh session.";
|
|
438
|
+
}
|
|
439
|
+
function shouldApplyOpenAIGptChatGuard(params) {
|
|
440
|
+
if (params.provider !== "openai" && params.provider !== "openai-codex") return false;
|
|
441
|
+
return /^gpt-5(?:[.-]|$)/i.test(params.model ?? "");
|
|
442
|
+
}
|
|
443
|
+
function countChatReplySentences(text) {
|
|
444
|
+
return text.trim().split(/(?<=[.!?])\s+/u).map((part) => part.trim()).filter(Boolean).length;
|
|
445
|
+
}
|
|
446
|
+
function scoreChattyFinalReplyText(text) {
|
|
447
|
+
const trimmed = text.trim();
|
|
448
|
+
if (!trimmed) return 0;
|
|
449
|
+
let score = 0;
|
|
450
|
+
const sentenceCount = countChatReplySentences(trimmed);
|
|
451
|
+
if (trimmed.length > 900) score += 1;
|
|
452
|
+
if (trimmed.length > 1500) score += 1;
|
|
453
|
+
if (sentenceCount > 6) score += 1;
|
|
454
|
+
if (sentenceCount > 10) score += 1;
|
|
455
|
+
if (trimmed.split(/\n{2,}/u).filter(Boolean).length >= 3) score += 1;
|
|
456
|
+
if (/\b(?:in summary|to summarize|here(?:'s| is) what|what changed|what I verified)\b/i.test(trimmed)) score += 1;
|
|
457
|
+
return score;
|
|
458
|
+
}
|
|
459
|
+
function shortenChattyFinalReplyText(text, params) {
|
|
460
|
+
const trimmed = text.trim();
|
|
461
|
+
if (!trimmed) return trimmed;
|
|
462
|
+
let shortened = trimmed.split(/(?<=[.!?])\s+/u).map((part) => part.trim()).filter(Boolean).slice(0, params.maxSentences).join(" ");
|
|
463
|
+
if (!shortened) shortened = trimmed.slice(0, params.maxChars).trimEnd();
|
|
464
|
+
if (shortened.length > params.maxChars) shortened = shortened.slice(0, params.maxChars).trimEnd();
|
|
465
|
+
if (shortened.length >= trimmed.length) return trimmed;
|
|
466
|
+
return shortened.replace(/[.,;:!?-]*$/u, "").trimEnd() + "...";
|
|
467
|
+
}
|
|
468
|
+
function applyOpenAIGptChatReplyGuard(params) {
|
|
469
|
+
if (params.isHeartbeat || !shouldApplyOpenAIGptChatGuard({
|
|
470
|
+
provider: params.provider,
|
|
471
|
+
model: params.model
|
|
472
|
+
}) || !params.payloads?.length) return;
|
|
473
|
+
const trimmedCommand = params.commandBody.trim();
|
|
474
|
+
const isAckTurn = isLikelyExecutionAckPrompt(trimmedCommand);
|
|
475
|
+
const allowSoftCap = !isAckTurn && trimmedCommand.length > 0 && trimmedCommand.length <= 120 && !/\b(?:detail|detailed|depth|deep dive|explain|compare|walk me through|why|how)\b/i.test(trimmedCommand);
|
|
476
|
+
for (const payload of params.payloads) {
|
|
477
|
+
const text = normalizeOptionalString(payload.text);
|
|
478
|
+
if (!text || payload.isError || payload.isReasoning || payload.mediaUrl || (payload.mediaUrls?.length ?? 0) > 0 || payload.interactive || text.includes("```")) continue;
|
|
479
|
+
if (isAckTurn) {
|
|
480
|
+
payload.text = shortenChattyFinalReplyText(text, {
|
|
481
|
+
maxChars: GPT_CHAT_BREVITY_ACK_MAX_CHARS,
|
|
482
|
+
maxSentences: GPT_CHAT_BREVITY_ACK_MAX_SENTENCES
|
|
483
|
+
});
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
if (allowSoftCap && scoreChattyFinalReplyText(text) >= 4) payload.text = shortenChattyFinalReplyText(text, {
|
|
487
|
+
maxChars: GPT_CHAT_BREVITY_SOFT_MAX_CHARS,
|
|
488
|
+
maxSentences: GPT_CHAT_BREVITY_SOFT_MAX_SENTENCES
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
function buildRestartLifecycleReplyText() {
|
|
493
|
+
return "⚠️ Gateway is restarting. Please wait a few seconds and try again.";
|
|
494
|
+
}
|
|
495
|
+
function resolveRestartLifecycleError(err) {
|
|
496
|
+
const pending = [err];
|
|
497
|
+
const seen = /* @__PURE__ */ new Set();
|
|
498
|
+
while (pending.length > 0) {
|
|
499
|
+
const candidate = pending.shift();
|
|
500
|
+
if (!candidate || seen.has(candidate)) continue;
|
|
501
|
+
seen.add(candidate);
|
|
502
|
+
if (candidate instanceof GatewayDrainingError || candidate instanceof CommandLaneClearedError) return candidate;
|
|
503
|
+
if (isFallbackSummaryError(candidate)) for (const attempt of candidate.attempts) pending.push(attempt.error);
|
|
504
|
+
if (candidate instanceof Error && "cause" in candidate) pending.push(candidate.cause);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
function isReplyOperationUserAbort(replyOperation) {
|
|
508
|
+
return replyOperation?.result?.kind === "aborted" && replyOperation.result.code === "aborted_by_user";
|
|
509
|
+
}
|
|
510
|
+
function isReplyOperationRestartAbort(replyOperation) {
|
|
511
|
+
return replyOperation?.result?.kind === "aborted" && replyOperation.result.code === "aborted_for_restart";
|
|
512
|
+
}
|
|
513
|
+
async function runAgentTurnWithFallback(params) {
|
|
514
|
+
const TRANSIENT_HTTP_RETRY_DELAY_MS = 2500;
|
|
515
|
+
let didLogHeartbeatStrip = false;
|
|
516
|
+
let autoCompactionCount = 0;
|
|
517
|
+
const directlySentBlockKeys = /* @__PURE__ */ new Set();
|
|
518
|
+
const runtimeConfig = resolveQueuedReplyRuntimeConfig(params.followupRun.run.config);
|
|
519
|
+
const effectiveRun = runtimeConfig === params.followupRun.run.config ? params.followupRun.run : {
|
|
520
|
+
...params.followupRun.run,
|
|
521
|
+
config: runtimeConfig
|
|
522
|
+
};
|
|
523
|
+
const runId = params.opts?.runId ?? crypto.randomUUID();
|
|
524
|
+
const normalizeReplyMediaPaths = createReplyMediaPathNormalizer({
|
|
525
|
+
cfg: runtimeConfig,
|
|
526
|
+
sessionKey: params.sessionKey,
|
|
527
|
+
workspaceDir: params.followupRun.run.workspaceDir
|
|
528
|
+
});
|
|
529
|
+
let didNotifyAgentRunStart = false;
|
|
530
|
+
const notifyAgentRunStart = () => {
|
|
531
|
+
if (didNotifyAgentRunStart) return;
|
|
532
|
+
didNotifyAgentRunStart = true;
|
|
533
|
+
params.opts?.onAgentRunStart?.(runId);
|
|
534
|
+
};
|
|
535
|
+
const shouldSurfaceToControlUi = params.sessionCtx.Provider === "evolution-event" || params.sessionCtx.Provider === "insight-event" || isInternalMessageChannel(params.followupRun.run.messageProvider ?? params.sessionCtx.Surface ?? params.sessionCtx.Provider);
|
|
536
|
+
if (params.sessionKey) registerAgentRunContext(runId, {
|
|
537
|
+
sessionKey: params.sessionKey,
|
|
538
|
+
verboseLevel: params.resolvedVerboseLevel,
|
|
539
|
+
isHeartbeat: params.isHeartbeat,
|
|
540
|
+
isControlUiVisible: shouldSurfaceToControlUi
|
|
541
|
+
});
|
|
542
|
+
let runResult;
|
|
543
|
+
let fallbackProvider = params.followupRun.run.provider;
|
|
544
|
+
let fallbackModel = params.followupRun.run.model;
|
|
545
|
+
let fallbackAttempts = [];
|
|
546
|
+
let didResetAfterCompactionFailure = false;
|
|
547
|
+
let didRetryTransientHttpError = false;
|
|
548
|
+
let liveModelSwitchRetries = 0;
|
|
549
|
+
let bootstrapPromptWarningSignaturesSeen = resolveBootstrapWarningSignaturesSeen(params.getActiveSessionEntry()?.systemPromptReport);
|
|
550
|
+
const persistFallbackCandidateSelection = async (provider, model) => {
|
|
551
|
+
if (!params.sessionKey || !params.activeSessionStore || provider === params.followupRun.run.provider && model === params.followupRun.run.model) return;
|
|
552
|
+
const activeSessionEntry = params.getActiveSessionEntry() ?? params.activeSessionStore[params.sessionKey];
|
|
553
|
+
if (!activeSessionEntry) return;
|
|
554
|
+
const previousState = snapshotFallbackSelectionState(activeSessionEntry);
|
|
555
|
+
const applied = applyFallbackCandidateSelectionToEntry({
|
|
556
|
+
entry: activeSessionEntry,
|
|
557
|
+
run: params.followupRun.run,
|
|
558
|
+
provider,
|
|
559
|
+
model
|
|
560
|
+
});
|
|
561
|
+
const nextState = applied.nextState;
|
|
562
|
+
if (!applied.updated || !nextState) return;
|
|
563
|
+
params.activeSessionStore[params.sessionKey] = activeSessionEntry;
|
|
564
|
+
try {
|
|
565
|
+
if (params.storePath) await updateSessionStore(params.storePath, (store) => {
|
|
566
|
+
const persistedEntry = store[params.sessionKey];
|
|
567
|
+
if (!persistedEntry) return;
|
|
568
|
+
applyFallbackSelectionState(persistedEntry, nextState);
|
|
569
|
+
store[params.sessionKey] = persistedEntry;
|
|
570
|
+
});
|
|
571
|
+
} catch (error) {
|
|
572
|
+
rollbackFallbackSelectionStateIfUnchanged(activeSessionEntry, nextState, previousState);
|
|
573
|
+
params.activeSessionStore[params.sessionKey] = activeSessionEntry;
|
|
574
|
+
throw error;
|
|
575
|
+
}
|
|
576
|
+
return async () => {
|
|
577
|
+
if (rollbackFallbackSelectionStateIfUnchanged(activeSessionEntry, nextState, previousState)) params.activeSessionStore[params.sessionKey] = activeSessionEntry;
|
|
578
|
+
if (!params.storePath) return;
|
|
579
|
+
await updateSessionStore(params.storePath, (store) => {
|
|
580
|
+
const persistedEntry = store[params.sessionKey];
|
|
581
|
+
if (!persistedEntry) return;
|
|
582
|
+
if (rollbackFallbackSelectionStateIfUnchanged(persistedEntry, nextState, previousState)) store[params.sessionKey] = persistedEntry;
|
|
583
|
+
});
|
|
584
|
+
};
|
|
585
|
+
};
|
|
586
|
+
while (true) try {
|
|
587
|
+
const normalizeStreamingText = (payload) => {
|
|
588
|
+
let text = payload.text;
|
|
589
|
+
const reply = resolveSendableOutboundReplyParts(payload);
|
|
590
|
+
if (params.followupRun.run.silentExpected) return { skip: true };
|
|
591
|
+
if (!params.isHeartbeat && text?.includes("HEARTBEAT_OK")) {
|
|
592
|
+
const stripped = stripHeartbeatToken(text, { mode: "message" });
|
|
593
|
+
if (stripped.didStrip && !didLogHeartbeatStrip) {
|
|
594
|
+
didLogHeartbeatStrip = true;
|
|
595
|
+
logVerbose("Stripped stray HEARTBEAT_OK token from reply");
|
|
596
|
+
}
|
|
597
|
+
if (stripped.shouldSkip && !reply.hasMedia) return { skip: true };
|
|
598
|
+
text = stripped.text;
|
|
599
|
+
}
|
|
600
|
+
if (isSilentReplyText(text, "NO_REPLY")) return { skip: true };
|
|
601
|
+
if (isSilentReplyPrefixText(text, "NO_REPLY") || isSilentReplyPrefixText(text, "HEARTBEAT_OK")) return { skip: true };
|
|
602
|
+
if (text && startsWithSilentToken(text, "NO_REPLY")) text = stripLeadingSilentToken(text, SILENT_REPLY_TOKEN);
|
|
603
|
+
if (!text) {
|
|
604
|
+
if (reply.hasMedia) return {
|
|
605
|
+
text: void 0,
|
|
606
|
+
skip: false
|
|
607
|
+
};
|
|
608
|
+
return { skip: true };
|
|
609
|
+
}
|
|
610
|
+
const sanitized = sanitizeUserFacingText(text, { errorContext: Boolean(payload.isError) });
|
|
611
|
+
if (!sanitized.trim()) return { skip: true };
|
|
612
|
+
return {
|
|
613
|
+
text: sanitized,
|
|
614
|
+
skip: false
|
|
615
|
+
};
|
|
616
|
+
};
|
|
617
|
+
const handlePartialForTyping = async (payload) => {
|
|
618
|
+
if (isSilentReplyPrefixText(payload.text, "NO_REPLY")) return;
|
|
619
|
+
const { text, skip } = normalizeStreamingText(payload);
|
|
620
|
+
if (skip || !text) return;
|
|
621
|
+
await params.typingSignals.signalTextDelta(text);
|
|
622
|
+
return text;
|
|
623
|
+
};
|
|
624
|
+
const blockReplyPipeline = params.blockReplyPipeline;
|
|
625
|
+
const blockReplyHandler = params.opts?.onBlockReply ? createBlockReplyDeliveryHandler({
|
|
626
|
+
onBlockReply: params.opts.onBlockReply,
|
|
627
|
+
currentMessageId: params.sessionCtx.MessageSidFull ?? params.sessionCtx.MessageSid,
|
|
628
|
+
normalizeStreamingText,
|
|
629
|
+
applyReplyToMode: params.applyReplyToMode,
|
|
630
|
+
normalizeMediaPaths: normalizeReplyMediaPaths,
|
|
631
|
+
typingSignals: params.typingSignals,
|
|
632
|
+
blockStreamingEnabled: params.blockStreamingEnabled,
|
|
633
|
+
blockReplyPipeline,
|
|
634
|
+
directlySentBlockKeys
|
|
635
|
+
}) : void 0;
|
|
636
|
+
const onToolResult = params.opts?.onToolResult;
|
|
637
|
+
const fallbackResult = await runWithModelFallback({
|
|
638
|
+
...resolveModelFallbackOptions(params.followupRun.run),
|
|
639
|
+
runId,
|
|
640
|
+
run: async (provider, model, runOptions) => {
|
|
641
|
+
params.opts?.onModelSelected?.({
|
|
642
|
+
provider,
|
|
643
|
+
model,
|
|
644
|
+
thinkLevel: params.followupRun.run.thinkLevel
|
|
645
|
+
});
|
|
646
|
+
let rollbackFallbackCandidateSelection;
|
|
647
|
+
try {
|
|
648
|
+
rollbackFallbackCandidateSelection = await persistFallbackCandidateSelection(provider, model);
|
|
649
|
+
} catch (error) {
|
|
650
|
+
logVerbose(`failed to persist fallback candidate selection (non-fatal): ${String(error)}`);
|
|
651
|
+
}
|
|
652
|
+
if (isCliProvider(provider, runtimeConfig)) {
|
|
653
|
+
const startedAt = Date.now();
|
|
654
|
+
notifyAgentRunStart();
|
|
655
|
+
emitAgentEvent({
|
|
656
|
+
runId,
|
|
657
|
+
stream: "lifecycle",
|
|
658
|
+
data: {
|
|
659
|
+
phase: "start",
|
|
660
|
+
startedAt
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
const cliSessionBinding = getCliSessionBinding(params.getActiveSessionEntry(), provider);
|
|
664
|
+
const authProfileId = provider === params.followupRun.run.provider ? params.followupRun.run.authProfileId : void 0;
|
|
665
|
+
return (async () => {
|
|
666
|
+
let lifecycleTerminalEmitted = false;
|
|
667
|
+
try {
|
|
668
|
+
const result = await runCliAgent({
|
|
669
|
+
sessionId: params.followupRun.run.sessionId,
|
|
670
|
+
sessionKey: params.sessionKey,
|
|
671
|
+
agentId: params.followupRun.run.agentId,
|
|
672
|
+
sessionFile: params.followupRun.run.sessionFile,
|
|
673
|
+
workspaceDir: params.followupRun.run.workspaceDir,
|
|
674
|
+
config: runtimeConfig,
|
|
675
|
+
prompt: params.commandBody,
|
|
676
|
+
provider,
|
|
677
|
+
model,
|
|
678
|
+
thinkLevel: params.followupRun.run.thinkLevel,
|
|
679
|
+
timeoutMs: params.followupRun.run.timeoutMs,
|
|
680
|
+
runId,
|
|
681
|
+
extraSystemPrompt: params.followupRun.run.extraSystemPrompt,
|
|
682
|
+
ownerNumbers: params.followupRun.run.ownerNumbers,
|
|
683
|
+
cliSessionId: cliSessionBinding?.sessionId,
|
|
684
|
+
cliSessionBinding,
|
|
685
|
+
authProfileId,
|
|
686
|
+
bootstrapPromptWarningSignaturesSeen,
|
|
687
|
+
bootstrapPromptWarningSignature: bootstrapPromptWarningSignaturesSeen[bootstrapPromptWarningSignaturesSeen.length - 1],
|
|
688
|
+
images: params.opts?.images,
|
|
689
|
+
imageOrder: params.opts?.imageOrder,
|
|
690
|
+
messageProvider: params.followupRun.run.messageProvider,
|
|
691
|
+
agentAccountId: params.followupRun.run.agentAccountId,
|
|
692
|
+
abortSignal: params.replyOperation?.abortSignal ?? params.opts?.abortSignal,
|
|
693
|
+
replyOperation: params.replyOperation
|
|
694
|
+
});
|
|
695
|
+
bootstrapPromptWarningSignaturesSeen = resolveBootstrapWarningSignaturesSeen(result.meta?.systemPromptReport);
|
|
696
|
+
const cliText = normalizeOptionalString(result.payloads?.[0]?.text);
|
|
697
|
+
if (cliText) emitAgentEvent({
|
|
698
|
+
runId,
|
|
699
|
+
stream: "assistant",
|
|
700
|
+
data: { text: cliText }
|
|
701
|
+
});
|
|
702
|
+
emitAgentEvent({
|
|
703
|
+
runId,
|
|
704
|
+
stream: "lifecycle",
|
|
705
|
+
data: {
|
|
706
|
+
phase: "end",
|
|
707
|
+
startedAt,
|
|
708
|
+
endedAt: Date.now()
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
lifecycleTerminalEmitted = true;
|
|
712
|
+
return result;
|
|
713
|
+
} catch (err) {
|
|
714
|
+
if (rollbackFallbackCandidateSelection) try {
|
|
715
|
+
await rollbackFallbackCandidateSelection();
|
|
716
|
+
} catch (rollbackError) {
|
|
717
|
+
logVerbose(`failed to roll back fallback candidate selection (non-fatal): ${String(rollbackError)}`);
|
|
718
|
+
}
|
|
719
|
+
emitAgentEvent({
|
|
720
|
+
runId,
|
|
721
|
+
stream: "lifecycle",
|
|
722
|
+
data: {
|
|
723
|
+
phase: "error",
|
|
724
|
+
startedAt,
|
|
725
|
+
endedAt: Date.now(),
|
|
726
|
+
error: String(err)
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
lifecycleTerminalEmitted = true;
|
|
730
|
+
throw err;
|
|
731
|
+
} finally {
|
|
732
|
+
if (!lifecycleTerminalEmitted) emitAgentEvent({
|
|
733
|
+
runId,
|
|
734
|
+
stream: "lifecycle",
|
|
735
|
+
data: {
|
|
736
|
+
phase: "error",
|
|
737
|
+
startedAt,
|
|
738
|
+
endedAt: Date.now(),
|
|
739
|
+
error: "CLI run completed without lifecycle terminal event"
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
})();
|
|
744
|
+
}
|
|
745
|
+
const { embeddedContext, senderContext, runBaseParams } = buildEmbeddedRunExecutionParams({
|
|
746
|
+
run: effectiveRun,
|
|
747
|
+
sessionCtx: params.sessionCtx,
|
|
748
|
+
hasRepliedRef: params.opts?.hasRepliedRef,
|
|
749
|
+
provider,
|
|
750
|
+
runId,
|
|
751
|
+
allowTransientCooldownProbe: runOptions?.allowTransientCooldownProbe,
|
|
752
|
+
model
|
|
753
|
+
});
|
|
754
|
+
return (async () => {
|
|
755
|
+
let attemptCompactionCount = 0;
|
|
756
|
+
try {
|
|
757
|
+
const result = await runEmbeddedPiAgent({
|
|
758
|
+
...embeddedContext,
|
|
759
|
+
allowGatewaySubagentBinding: true,
|
|
760
|
+
trigger: params.isHeartbeat ? "heartbeat" : "user",
|
|
761
|
+
groupId: resolveGroupSessionKey(params.sessionCtx)?.id,
|
|
762
|
+
groupChannel: normalizeOptionalString(params.sessionCtx.GroupChannel) ?? normalizeOptionalString(params.sessionCtx.GroupSubject),
|
|
763
|
+
groupSpace: normalizeOptionalString(params.sessionCtx.GroupSpace),
|
|
764
|
+
...senderContext,
|
|
765
|
+
...runBaseParams,
|
|
766
|
+
prompt: params.commandBody,
|
|
767
|
+
extraSystemPrompt: params.followupRun.run.extraSystemPrompt,
|
|
768
|
+
toolResultFormat: (() => {
|
|
769
|
+
const channel = resolveMessageChannel(params.sessionCtx.Surface, params.sessionCtx.Provider);
|
|
770
|
+
if (!channel) return "markdown";
|
|
771
|
+
return isMarkdownCapableMessageChannel(channel) ? "markdown" : "plain";
|
|
772
|
+
})(),
|
|
773
|
+
suppressToolErrorWarnings: params.opts?.suppressToolErrorWarnings,
|
|
774
|
+
bootstrapContextMode: params.opts?.bootstrapContextMode,
|
|
775
|
+
bootstrapContextRunKind: params.opts?.isHeartbeat ? "heartbeat" : "default",
|
|
776
|
+
images: params.opts?.images,
|
|
777
|
+
imageOrder: params.opts?.imageOrder,
|
|
778
|
+
abortSignal: params.replyOperation?.abortSignal ?? params.opts?.abortSignal,
|
|
779
|
+
replyOperation: params.replyOperation,
|
|
780
|
+
blockReplyBreak: params.resolvedBlockStreamingBreak,
|
|
781
|
+
blockReplyChunking: params.blockReplyChunking,
|
|
782
|
+
onPartialReply: async (payload) => {
|
|
783
|
+
const textForTyping = await handlePartialForTyping(payload);
|
|
784
|
+
if (!params.opts?.onPartialReply || textForTyping === void 0) return;
|
|
785
|
+
await params.opts.onPartialReply({
|
|
786
|
+
text: textForTyping,
|
|
787
|
+
mediaUrls: payload.mediaUrls
|
|
788
|
+
});
|
|
789
|
+
},
|
|
790
|
+
onAssistantMessageStart: async () => {
|
|
791
|
+
await params.typingSignals.signalMessageStart();
|
|
792
|
+
await params.opts?.onAssistantMessageStart?.();
|
|
793
|
+
},
|
|
794
|
+
onReasoningStream: params.typingSignals.shouldStartOnReasoning || params.opts?.onReasoningStream ? async (payload) => {
|
|
795
|
+
if (params.followupRun.run.silentExpected) return;
|
|
796
|
+
await params.typingSignals.signalReasoningDelta();
|
|
797
|
+
await params.opts?.onReasoningStream?.({
|
|
798
|
+
text: payload.text,
|
|
799
|
+
mediaUrls: payload.mediaUrls
|
|
800
|
+
});
|
|
801
|
+
} : void 0,
|
|
802
|
+
onReasoningEnd: params.opts?.onReasoningEnd,
|
|
803
|
+
onAgentEvent: async (evt) => {
|
|
804
|
+
const hasLifecyclePhase = evt.stream === "lifecycle" && typeof evt.data.phase === "string";
|
|
805
|
+
if (evt.stream !== "lifecycle" || hasLifecyclePhase) notifyAgentRunStart();
|
|
806
|
+
if (evt.stream === "tool") {
|
|
807
|
+
const phase = readStringValue(evt.data.phase) ?? "";
|
|
808
|
+
const name = readStringValue(evt.data.name);
|
|
809
|
+
if (phase === "start" || phase === "update") {
|
|
810
|
+
await params.typingSignals.signalToolStart();
|
|
811
|
+
await params.opts?.onToolStart?.({
|
|
812
|
+
name,
|
|
813
|
+
phase
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
if (evt.stream === "item") await params.opts?.onItemEvent?.({
|
|
818
|
+
itemId: readStringValue(evt.data.itemId),
|
|
819
|
+
kind: readStringValue(evt.data.kind),
|
|
820
|
+
title: readStringValue(evt.data.title),
|
|
821
|
+
name: readStringValue(evt.data.name),
|
|
822
|
+
phase: readStringValue(evt.data.phase),
|
|
823
|
+
status: readStringValue(evt.data.status),
|
|
824
|
+
summary: readStringValue(evt.data.summary),
|
|
825
|
+
progressText: readStringValue(evt.data.progressText),
|
|
826
|
+
approvalId: readStringValue(evt.data.approvalId),
|
|
827
|
+
approvalSlug: readStringValue(evt.data.approvalSlug)
|
|
828
|
+
});
|
|
829
|
+
if (evt.stream === "plan") await params.opts?.onPlanUpdate?.({
|
|
830
|
+
phase: readStringValue(evt.data.phase),
|
|
831
|
+
title: readStringValue(evt.data.title),
|
|
832
|
+
explanation: readStringValue(evt.data.explanation),
|
|
833
|
+
steps: Array.isArray(evt.data.steps) ? evt.data.steps.filter((step) => typeof step === "string") : void 0,
|
|
834
|
+
source: readStringValue(evt.data.source)
|
|
835
|
+
});
|
|
836
|
+
if (evt.stream === "approval") await params.opts?.onApprovalEvent?.({
|
|
837
|
+
phase: readStringValue(evt.data.phase),
|
|
838
|
+
kind: readStringValue(evt.data.kind),
|
|
839
|
+
status: readStringValue(evt.data.status),
|
|
840
|
+
title: readStringValue(evt.data.title),
|
|
841
|
+
itemId: readStringValue(evt.data.itemId),
|
|
842
|
+
toolCallId: readStringValue(evt.data.toolCallId),
|
|
843
|
+
approvalId: readStringValue(evt.data.approvalId),
|
|
844
|
+
approvalSlug: readStringValue(evt.data.approvalSlug),
|
|
845
|
+
command: readStringValue(evt.data.command),
|
|
846
|
+
host: readStringValue(evt.data.host),
|
|
847
|
+
reason: readStringValue(evt.data.reason),
|
|
848
|
+
message: readStringValue(evt.data.message)
|
|
849
|
+
});
|
|
850
|
+
if (evt.stream === "command_output") await params.opts?.onCommandOutput?.({
|
|
851
|
+
itemId: readStringValue(evt.data.itemId),
|
|
852
|
+
phase: readStringValue(evt.data.phase),
|
|
853
|
+
title: readStringValue(evt.data.title),
|
|
854
|
+
toolCallId: readStringValue(evt.data.toolCallId),
|
|
855
|
+
name: readStringValue(evt.data.name),
|
|
856
|
+
output: readStringValue(evt.data.output),
|
|
857
|
+
status: readStringValue(evt.data.status),
|
|
858
|
+
exitCode: typeof evt.data.exitCode === "number" || evt.data.exitCode === null ? evt.data.exitCode : void 0,
|
|
859
|
+
durationMs: typeof evt.data.durationMs === "number" ? evt.data.durationMs : void 0,
|
|
860
|
+
cwd: readStringValue(evt.data.cwd)
|
|
861
|
+
});
|
|
862
|
+
if (evt.stream === "patch") await params.opts?.onPatchSummary?.({
|
|
863
|
+
itemId: readStringValue(evt.data.itemId),
|
|
864
|
+
phase: readStringValue(evt.data.phase),
|
|
865
|
+
title: readStringValue(evt.data.title),
|
|
866
|
+
toolCallId: readStringValue(evt.data.toolCallId),
|
|
867
|
+
name: readStringValue(evt.data.name),
|
|
868
|
+
added: Array.isArray(evt.data.added) ? evt.data.added.filter((entry) => typeof entry === "string") : void 0,
|
|
869
|
+
modified: Array.isArray(evt.data.modified) ? evt.data.modified.filter((entry) => typeof entry === "string") : void 0,
|
|
870
|
+
deleted: Array.isArray(evt.data.deleted) ? evt.data.deleted.filter((entry) => typeof entry === "string") : void 0,
|
|
871
|
+
summary: readStringValue(evt.data.summary)
|
|
872
|
+
});
|
|
873
|
+
if (evt.stream === "compaction") {
|
|
874
|
+
const phase = readStringValue(evt.data.phase) ?? "";
|
|
875
|
+
if (phase === "start") {
|
|
876
|
+
const notifyUser = runtimeConfig?.agents?.defaults?.compaction?.notifyUser === true;
|
|
877
|
+
if (params.opts?.onCompactionStart) await params.opts.onCompactionStart();
|
|
878
|
+
else if (notifyUser && params.opts?.onBlockReply) {
|
|
879
|
+
const currentMessageId = params.sessionCtx.MessageSidFull ?? params.sessionCtx.MessageSid;
|
|
880
|
+
const noticePayload = params.applyReplyToMode({
|
|
881
|
+
text: "🧹 Compacting context...",
|
|
882
|
+
replyToId: currentMessageId,
|
|
883
|
+
replyToCurrent: true,
|
|
884
|
+
isCompactionNotice: true
|
|
885
|
+
});
|
|
886
|
+
try {
|
|
887
|
+
await params.opts.onBlockReply(noticePayload);
|
|
888
|
+
} catch (err) {
|
|
889
|
+
logVerbose(`compaction start notice delivery failed (non-fatal): ${String(err)}`);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
const completed = evt.data?.completed === true;
|
|
894
|
+
if (phase === "end" && completed) {
|
|
895
|
+
attemptCompactionCount += 1;
|
|
896
|
+
await params.opts?.onCompactionEnd?.();
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
onBlockReply: blockReplyHandler,
|
|
901
|
+
onBlockReplyFlush: params.blockStreamingEnabled && blockReplyPipeline ? async () => {
|
|
902
|
+
await blockReplyPipeline.flush({ force: true });
|
|
903
|
+
} : void 0,
|
|
904
|
+
shouldEmitToolResult: params.shouldEmitToolResult,
|
|
905
|
+
shouldEmitToolOutput: params.shouldEmitToolOutput,
|
|
906
|
+
bootstrapPromptWarningSignaturesSeen,
|
|
907
|
+
bootstrapPromptWarningSignature: bootstrapPromptWarningSignaturesSeen[bootstrapPromptWarningSignaturesSeen.length - 1],
|
|
908
|
+
onToolResult: onToolResult ? (() => {
|
|
909
|
+
let toolResultChain = Promise.resolve();
|
|
910
|
+
return (payload) => {
|
|
911
|
+
toolResultChain = toolResultChain.then(async () => {
|
|
912
|
+
const { text, skip } = normalizeStreamingText(payload);
|
|
913
|
+
if (skip) return;
|
|
914
|
+
if (text !== void 0) await params.typingSignals.signalTextDelta(text);
|
|
915
|
+
await onToolResult({
|
|
916
|
+
...payload,
|
|
917
|
+
text
|
|
918
|
+
});
|
|
919
|
+
}).catch((err) => {
|
|
920
|
+
logVerbose(`tool result delivery failed: ${String(err)}`);
|
|
921
|
+
});
|
|
922
|
+
const task = toolResultChain.finally(() => {
|
|
923
|
+
params.pendingToolTasks.delete(task);
|
|
924
|
+
});
|
|
925
|
+
params.pendingToolTasks.add(task);
|
|
926
|
+
};
|
|
927
|
+
})() : void 0
|
|
928
|
+
});
|
|
929
|
+
bootstrapPromptWarningSignaturesSeen = resolveBootstrapWarningSignaturesSeen(result.meta?.systemPromptReport);
|
|
930
|
+
const resultCompactionCount = Math.max(0, result.meta?.agentMeta?.compactionCount ?? 0);
|
|
931
|
+
attemptCompactionCount = Math.max(attemptCompactionCount, resultCompactionCount);
|
|
932
|
+
return result;
|
|
933
|
+
} catch (err) {
|
|
934
|
+
if (rollbackFallbackCandidateSelection) try {
|
|
935
|
+
await rollbackFallbackCandidateSelection();
|
|
936
|
+
} catch (rollbackError) {
|
|
937
|
+
logVerbose(`failed to roll back fallback candidate selection (non-fatal): ${String(rollbackError)}`);
|
|
938
|
+
}
|
|
939
|
+
throw err;
|
|
940
|
+
} finally {
|
|
941
|
+
autoCompactionCount += attemptCompactionCount;
|
|
942
|
+
}
|
|
943
|
+
})();
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
runResult = fallbackResult.result;
|
|
947
|
+
fallbackProvider = fallbackResult.provider;
|
|
948
|
+
fallbackModel = fallbackResult.model;
|
|
949
|
+
fallbackAttempts = Array.isArray(fallbackResult.attempts) ? fallbackResult.attempts.map((attempt) => ({
|
|
950
|
+
provider: String(attempt.provider ?? ""),
|
|
951
|
+
model: String(attempt.model ?? ""),
|
|
952
|
+
error: String(attempt.error ?? ""),
|
|
953
|
+
reason: attempt.reason ? String(attempt.reason) : void 0,
|
|
954
|
+
status: typeof attempt.status === "number" ? attempt.status : void 0,
|
|
955
|
+
code: attempt.code ? String(attempt.code) : void 0
|
|
956
|
+
})) : [];
|
|
957
|
+
const embeddedError = runResult.meta?.error;
|
|
958
|
+
if (embeddedError && isContextOverflowError(embeddedError.message) && !didResetAfterCompactionFailure && await params.resetSessionAfterCompactionFailure(embeddedError.message)) {
|
|
959
|
+
didResetAfterCompactionFailure = true;
|
|
960
|
+
params.replyOperation?.fail("run_failed", embeddedError);
|
|
961
|
+
return {
|
|
962
|
+
kind: "final",
|
|
963
|
+
payload: { text: "⚠️ Context limit exceeded. I've reset our conversation to start fresh - please try again.\n\nTo prevent this, increase your compaction buffer by setting `agents.defaults.compaction.reserveTokensFloor` to 20000 or higher in your config." }
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
if (embeddedError?.kind === "role_ordering") {
|
|
967
|
+
if (await params.resetSessionAfterRoleOrderingConflict(embeddedError.message)) {
|
|
968
|
+
params.replyOperation?.fail("run_failed", embeddedError);
|
|
969
|
+
return {
|
|
970
|
+
kind: "final",
|
|
971
|
+
payload: { text: "⚠️ Message ordering conflict. I've reset the conversation - please try again." }
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
break;
|
|
976
|
+
} catch (err) {
|
|
977
|
+
if (err instanceof LiveSessionModelSwitchError) {
|
|
978
|
+
liveModelSwitchRetries += 1;
|
|
979
|
+
if (liveModelSwitchRetries > 2) {
|
|
980
|
+
defaultRuntime.error(`Live model switch failed after 2 retries (${sanitizeForLog(err.provider)}/${sanitizeForLog(err.model)}). The requested model may be unavailable.`);
|
|
981
|
+
const switchErrorText = shouldSurfaceToControlUi ? "⚠️ Agent failed before reply: model switch could not be completed. The requested model may be temporarily unavailable.\nLogs: kaijibot logs --follow" : "⚠️ Agent failed before reply: model switch could not be completed. The requested model may be temporarily unavailable. Please try again shortly.";
|
|
982
|
+
params.replyOperation?.fail("run_failed", err);
|
|
983
|
+
return {
|
|
984
|
+
kind: "final",
|
|
985
|
+
payload: { text: switchErrorText }
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
params.followupRun.run.provider = err.provider;
|
|
989
|
+
params.followupRun.run.model = err.model;
|
|
990
|
+
params.followupRun.run.authProfileId = err.authProfileId;
|
|
991
|
+
params.followupRun.run.authProfileIdSource = err.authProfileId ? err.authProfileIdSource : void 0;
|
|
992
|
+
fallbackProvider = err.provider;
|
|
993
|
+
fallbackModel = err.model;
|
|
994
|
+
continue;
|
|
995
|
+
}
|
|
996
|
+
const message = formatErrorMessage(err);
|
|
997
|
+
const isBilling = isBillingErrorMessage(message);
|
|
998
|
+
const isContextOverflow = !isBilling && isLikelyContextOverflowError(message);
|
|
999
|
+
const isCompactionFailure = !isBilling && isCompactionFailureError(message);
|
|
1000
|
+
const isSessionCorruption = /function call turn comes immediately after/i.test(message);
|
|
1001
|
+
const isRoleOrderingError = /incorrect role information|roles must alternate/i.test(message);
|
|
1002
|
+
const isTransientHttp = isTransientHttpError(message);
|
|
1003
|
+
if (isReplyOperationRestartAbort(params.replyOperation)) return {
|
|
1004
|
+
kind: "final",
|
|
1005
|
+
payload: { text: buildRestartLifecycleReplyText() }
|
|
1006
|
+
};
|
|
1007
|
+
if (isReplyOperationUserAbort(params.replyOperation)) return {
|
|
1008
|
+
kind: "final",
|
|
1009
|
+
payload: { text: SILENT_REPLY_TOKEN }
|
|
1010
|
+
};
|
|
1011
|
+
const restartLifecycleError = resolveRestartLifecycleError(err);
|
|
1012
|
+
if (restartLifecycleError instanceof GatewayDrainingError) {
|
|
1013
|
+
params.replyOperation?.fail("gateway_draining", restartLifecycleError);
|
|
1014
|
+
return {
|
|
1015
|
+
kind: "final",
|
|
1016
|
+
payload: { text: buildRestartLifecycleReplyText() }
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
if (restartLifecycleError instanceof CommandLaneClearedError) {
|
|
1020
|
+
params.replyOperation?.fail("command_lane_cleared", restartLifecycleError);
|
|
1021
|
+
return {
|
|
1022
|
+
kind: "final",
|
|
1023
|
+
payload: { text: buildRestartLifecycleReplyText() }
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
if (isCompactionFailure && !didResetAfterCompactionFailure && await params.resetSessionAfterCompactionFailure(message)) {
|
|
1027
|
+
didResetAfterCompactionFailure = true;
|
|
1028
|
+
params.replyOperation?.fail("run_failed", err);
|
|
1029
|
+
return {
|
|
1030
|
+
kind: "final",
|
|
1031
|
+
payload: { text: "⚠️ Context limit exceeded during compaction. I've reset our conversation to start fresh - please try again.\n\nTo prevent this, increase your compaction buffer by setting `agents.defaults.compaction.reserveTokensFloor` to 20000 or higher in your config." }
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
if (isRoleOrderingError) {
|
|
1035
|
+
if (await params.resetSessionAfterRoleOrderingConflict(message)) {
|
|
1036
|
+
params.replyOperation?.fail("run_failed", err);
|
|
1037
|
+
return {
|
|
1038
|
+
kind: "final",
|
|
1039
|
+
payload: { text: "⚠️ Message ordering conflict. I've reset the conversation - please try again." }
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
if (isSessionCorruption && params.sessionKey && params.activeSessionStore && params.storePath) {
|
|
1044
|
+
const sessionKey = params.sessionKey;
|
|
1045
|
+
const corruptedSessionId = params.getActiveSessionEntry()?.sessionId;
|
|
1046
|
+
defaultRuntime.error(`Session history corrupted (Gemini function call ordering). Resetting session: ${params.sessionKey}`);
|
|
1047
|
+
try {
|
|
1048
|
+
if (corruptedSessionId) {
|
|
1049
|
+
const transcriptPath = resolveSessionTranscriptPath(corruptedSessionId);
|
|
1050
|
+
try {
|
|
1051
|
+
fs.unlinkSync(transcriptPath);
|
|
1052
|
+
} catch {}
|
|
1053
|
+
}
|
|
1054
|
+
delete params.activeSessionStore[sessionKey];
|
|
1055
|
+
await updateSessionStore(params.storePath, (store) => {
|
|
1056
|
+
delete store[sessionKey];
|
|
1057
|
+
});
|
|
1058
|
+
} catch (cleanupErr) {
|
|
1059
|
+
defaultRuntime.error(`Failed to reset corrupted session ${params.sessionKey}: ${String(cleanupErr)}`);
|
|
1060
|
+
}
|
|
1061
|
+
params.replyOperation?.fail("session_corruption_reset", err);
|
|
1062
|
+
return {
|
|
1063
|
+
kind: "final",
|
|
1064
|
+
payload: { text: "⚠️ Session history was corrupted. I've reset the conversation - please try again!" }
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
if (isTransientHttp && !didRetryTransientHttpError) {
|
|
1068
|
+
didRetryTransientHttpError = true;
|
|
1069
|
+
defaultRuntime.error(`Transient HTTP provider error before reply (${message}). Retrying once in ${TRANSIENT_HTTP_RETRY_DELAY_MS}ms.`);
|
|
1070
|
+
await new Promise((resolve) => {
|
|
1071
|
+
setTimeout(resolve, TRANSIENT_HTTP_RETRY_DELAY_MS);
|
|
1072
|
+
});
|
|
1073
|
+
continue;
|
|
1074
|
+
}
|
|
1075
|
+
defaultRuntime.error(`Embedded agent failed before reply: ${message}`);
|
|
1076
|
+
const isRateLimit = isFallbackSummaryError(err) ? isPureTransientRateLimitSummary(err) : isRateLimitErrorMessage(message);
|
|
1077
|
+
const trimmedMessage = (isTransientHttp ? sanitizeUserFacingText(message, { errorContext: true }) : message).replace(/\.\s*$/, "");
|
|
1078
|
+
const fallbackText = isBilling ? BILLING_ERROR_USER_MESSAGE : isRateLimit ? buildRateLimitCooldownMessage(err) : isContextOverflow ? "⚠️ Context overflow — prompt too large for this model. Try a shorter message or a larger-context model." : isRoleOrderingError ? "⚠️ Message ordering conflict - please try again. If this persists, use /new to start a fresh session." : shouldSurfaceToControlUi ? `⚠️ Agent failed before reply: ${trimmedMessage}.\nLogs: kaijibot logs --follow` : buildExternalRunFailureText(message);
|
|
1079
|
+
params.replyOperation?.fail("run_failed", err);
|
|
1080
|
+
return {
|
|
1081
|
+
kind: "final",
|
|
1082
|
+
payload: { text: fallbackText }
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
const finalEmbeddedError = runResult?.meta?.error;
|
|
1086
|
+
const hasPayloadText = runResult?.payloads?.some((p) => normalizeOptionalString(p.text));
|
|
1087
|
+
if (finalEmbeddedError && !hasPayloadText) {
|
|
1088
|
+
if (isContextOverflowError(finalEmbeddedError.message ?? "")) {
|
|
1089
|
+
params.replyOperation?.fail("run_failed", finalEmbeddedError);
|
|
1090
|
+
return {
|
|
1091
|
+
kind: "final",
|
|
1092
|
+
payload: { text: "⚠️ Context overflow — this conversation is too large for the model. Use /new to start a fresh session." }
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
if (runResult) {
|
|
1097
|
+
if (!runResult.payloads?.some((p) => !p.isError && !p.isReasoning && hasOutboundReplyContent(p, { trimText: true }))) {
|
|
1098
|
+
const metaErrorMsg = finalEmbeddedError?.message ?? "";
|
|
1099
|
+
const rawErrorPayloadText = runResult.payloads?.find((p) => p.isError && hasNonEmptyString(p.text) && !p.text.startsWith("⚠️"))?.text ?? "";
|
|
1100
|
+
const errorCandidate = metaErrorMsg || rawErrorPayloadText;
|
|
1101
|
+
if (errorCandidate && (isRateLimitErrorMessage(errorCandidate) || isOverloadedErrorMessage(errorCandidate))) {
|
|
1102
|
+
const isOverloaded = isOverloadedErrorMessage(errorCandidate);
|
|
1103
|
+
runResult.payloads = [{
|
|
1104
|
+
text: isOverloaded ? "⚠️ The AI service is temporarily overloaded. Please try again in a moment." : "⚠️ API rate limit reached — the model couldn't generate a response. Please try again in a moment.",
|
|
1105
|
+
isError: true
|
|
1106
|
+
}];
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
applyOpenAIGptChatReplyGuard({
|
|
1110
|
+
provider: fallbackProvider,
|
|
1111
|
+
model: fallbackModel,
|
|
1112
|
+
commandBody: params.commandBody,
|
|
1113
|
+
isHeartbeat: params.isHeartbeat,
|
|
1114
|
+
payloads: runResult.payloads
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
return {
|
|
1118
|
+
kind: "success",
|
|
1119
|
+
runId,
|
|
1120
|
+
runResult,
|
|
1121
|
+
fallbackProvider,
|
|
1122
|
+
fallbackModel,
|
|
1123
|
+
fallbackAttempts,
|
|
1124
|
+
didLogHeartbeatStrip,
|
|
1125
|
+
autoCompactionCount,
|
|
1126
|
+
directlySentBlockKeys: directlySentBlockKeys.size > 0 ? directlySentBlockKeys : void 0
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
//#endregion
|
|
1130
|
+
//#region src/auto-reply/reply/agent-runner-helpers.ts
|
|
1131
|
+
const hasAudioMedia = (urls) => Boolean(urls?.some((url) => isAudioFileName(url)));
|
|
1132
|
+
const isAudioPayload = (payload) => hasAudioMedia(resolveSendableOutboundReplyParts(payload).mediaUrls);
|
|
1133
|
+
function resolveCurrentVerboseLevel(params) {
|
|
1134
|
+
if (!params.sessionKey || !params.storePath) return;
|
|
1135
|
+
try {
|
|
1136
|
+
const entry = loadSessionStore(params.storePath)[params.sessionKey];
|
|
1137
|
+
return normalizeVerboseLevel(String(entry?.verboseLevel ?? ""));
|
|
1138
|
+
} catch {
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
function createVerboseGate(params, shouldEmit) {
|
|
1143
|
+
const fallbackVerbose = normalizeVerboseLevel(String(params.resolvedVerboseLevel ?? "")) ?? "off";
|
|
1144
|
+
return () => {
|
|
1145
|
+
return shouldEmit(resolveCurrentVerboseLevel(params) ?? fallbackVerbose);
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
const createShouldEmitToolResult = (params) => {
|
|
1149
|
+
return createVerboseGate(params, (level) => level !== "off");
|
|
1150
|
+
};
|
|
1151
|
+
const createShouldEmitToolOutput = (params) => {
|
|
1152
|
+
return createVerboseGate(params, (level) => level === "full");
|
|
1153
|
+
};
|
|
1154
|
+
const finalizeWithFollowup = (value, queueKey, runFollowupTurn) => {
|
|
1155
|
+
scheduleFollowupDrain(queueKey, runFollowupTurn);
|
|
1156
|
+
return value;
|
|
1157
|
+
};
|
|
1158
|
+
const signalTypingIfNeeded = async (payloads, typingSignals) => {
|
|
1159
|
+
if (payloads.some((payload) => hasOutboundReplyContent(payload, { trimText: true }))) await typingSignals.signalRunStart();
|
|
1160
|
+
};
|
|
1161
|
+
//#endregion
|
|
1162
|
+
//#region src/auto-reply/reply/memory-flush.ts
|
|
1163
|
+
function resolveMemoryFlushContextWindowTokens(params) {
|
|
1164
|
+
return resolveContextTokensForModel({
|
|
1165
|
+
cfg: params.cfg,
|
|
1166
|
+
provider: params.provider,
|
|
1167
|
+
model: params.modelId,
|
|
1168
|
+
contextTokensOverride: params.agentCfgContextTokens,
|
|
1169
|
+
allowAsyncLoad: false
|
|
1170
|
+
}) ?? 2e5;
|
|
1171
|
+
}
|
|
1172
|
+
function resolvePositiveTokenCount(value) {
|
|
1173
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : void 0;
|
|
1174
|
+
}
|
|
1175
|
+
function resolveMemoryFlushGateState(params) {
|
|
1176
|
+
if (!params.entry) return null;
|
|
1177
|
+
const totalTokens = resolvePositiveTokenCount(params.tokenCount) ?? resolveFreshSessionTotalTokens(params.entry);
|
|
1178
|
+
if (!totalTokens || totalTokens <= 0) return null;
|
|
1179
|
+
const contextWindow = Math.max(1, Math.floor(params.contextWindowTokens));
|
|
1180
|
+
const reserveTokens = Math.max(0, Math.floor(params.reserveTokensFloor));
|
|
1181
|
+
const softThreshold = Math.max(0, Math.floor(params.softThresholdTokens));
|
|
1182
|
+
const threshold = Math.max(0, contextWindow - reserveTokens - softThreshold);
|
|
1183
|
+
if (threshold <= 0) return null;
|
|
1184
|
+
return {
|
|
1185
|
+
entry: params.entry,
|
|
1186
|
+
totalTokens,
|
|
1187
|
+
threshold
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
function shouldRunMemoryFlush(params) {
|
|
1191
|
+
const state = resolveMemoryFlushGateState(params);
|
|
1192
|
+
if (!state || state.totalTokens < state.threshold) return false;
|
|
1193
|
+
if (hasAlreadyFlushedForCurrentCompaction(state.entry)) return false;
|
|
1194
|
+
return true;
|
|
1195
|
+
}
|
|
1196
|
+
function shouldRunPreflightCompaction(params) {
|
|
1197
|
+
const state = resolveMemoryFlushGateState(params);
|
|
1198
|
+
return Boolean(state && state.totalTokens >= state.threshold);
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Returns true when a memory flush has already been performed for the current
|
|
1202
|
+
* compaction cycle. This prevents repeated flush runs within the same cycle —
|
|
1203
|
+
* important for both the token-based and transcript-size–based trigger paths.
|
|
1204
|
+
*/
|
|
1205
|
+
function hasAlreadyFlushedForCurrentCompaction(entry) {
|
|
1206
|
+
const compactionCount = entry.compactionCount ?? 0;
|
|
1207
|
+
const lastFlushAt = entry.memoryFlushCompactionCount;
|
|
1208
|
+
return typeof lastFlushAt === "number" && lastFlushAt === compactionCount;
|
|
1209
|
+
}
|
|
1210
|
+
//#endregion
|
|
1211
|
+
//#region src/auto-reply/reply/agent-runner-memory.ts
|
|
1212
|
+
const memoryDeps = {
|
|
1213
|
+
compactEmbeddedPiSession,
|
|
1214
|
+
runWithModelFallback,
|
|
1215
|
+
runEmbeddedPiAgent,
|
|
1216
|
+
registerAgentRunContext,
|
|
1217
|
+
refreshQueuedFollowupSession,
|
|
1218
|
+
incrementCompactionCount,
|
|
1219
|
+
updateSessionStoreEntry,
|
|
1220
|
+
randomUUID: () => crypto.randomUUID(),
|
|
1221
|
+
now: () => Date.now()
|
|
1222
|
+
};
|
|
1223
|
+
function estimatePromptTokensForMemoryFlush(prompt) {
|
|
1224
|
+
const trimmed = normalizeOptionalString(prompt);
|
|
1225
|
+
if (!trimmed) return;
|
|
1226
|
+
const tokens = estimateMessagesTokens([{
|
|
1227
|
+
role: "user",
|
|
1228
|
+
content: trimmed,
|
|
1229
|
+
timestamp: Date.now()
|
|
1230
|
+
}]);
|
|
1231
|
+
if (!Number.isFinite(tokens) || tokens <= 0) return;
|
|
1232
|
+
return Math.ceil(tokens);
|
|
1233
|
+
}
|
|
1234
|
+
function resolveEffectivePromptTokens(basePromptTokens, lastOutputTokens, promptTokenEstimate) {
|
|
1235
|
+
const base = Math.max(0, basePromptTokens ?? 0);
|
|
1236
|
+
const output = Math.max(0, lastOutputTokens ?? 0);
|
|
1237
|
+
const estimate = Math.max(0, promptTokenEstimate ?? 0);
|
|
1238
|
+
return base + output + estimate;
|
|
1239
|
+
}
|
|
1240
|
+
const TRANSCRIPT_OUTPUT_READ_BUFFER_TOKENS = 8192;
|
|
1241
|
+
const TRANSCRIPT_TAIL_CHUNK_BYTES = 64 * 1024;
|
|
1242
|
+
function parseUsageFromTranscriptLine(line) {
|
|
1243
|
+
const trimmed = line.trim();
|
|
1244
|
+
if (!trimmed) return;
|
|
1245
|
+
try {
|
|
1246
|
+
const parsed = JSON.parse(trimmed);
|
|
1247
|
+
const usage = normalizeUsage(parsed.message?.usage ?? parsed.usage);
|
|
1248
|
+
if (usage && hasNonzeroUsage(usage)) return usage;
|
|
1249
|
+
} catch {}
|
|
1250
|
+
}
|
|
1251
|
+
function resolveSessionLogPath(sessionId, sessionEntry, sessionKey, opts) {
|
|
1252
|
+
if (!sessionId) return;
|
|
1253
|
+
try {
|
|
1254
|
+
const transcriptPath = normalizeOptionalString(sessionEntry?.transcriptPath);
|
|
1255
|
+
const sessionFile = normalizeOptionalString(sessionEntry?.sessionFile) || transcriptPath;
|
|
1256
|
+
const pathOpts = resolveSessionFilePathOptions({
|
|
1257
|
+
agentId: resolveAgentIdFromSessionKey(sessionKey),
|
|
1258
|
+
storePath: opts?.storePath
|
|
1259
|
+
});
|
|
1260
|
+
return resolveSessionFilePath(sessionId, sessionFile ? { sessionFile } : sessionEntry, pathOpts);
|
|
1261
|
+
} catch {
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
function deriveTranscriptUsageSnapshot(usage) {
|
|
1266
|
+
if (!usage) return;
|
|
1267
|
+
const promptTokens = derivePromptTokens(usage);
|
|
1268
|
+
const outputRaw = usage.output;
|
|
1269
|
+
const outputTokens = typeof outputRaw === "number" && Number.isFinite(outputRaw) && outputRaw > 0 ? outputRaw : void 0;
|
|
1270
|
+
if (!(typeof promptTokens === "number") && !(typeof outputTokens === "number")) return;
|
|
1271
|
+
return {
|
|
1272
|
+
promptTokens,
|
|
1273
|
+
outputTokens
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
async function appendPostCompactionRefreshPrompt(params) {
|
|
1277
|
+
const refreshPrompt = await readPostCompactionContext(params.followupRun.run.workspaceDir, params.cfg);
|
|
1278
|
+
if (!refreshPrompt) return;
|
|
1279
|
+
const existingPrompt = normalizeOptionalString(params.followupRun.run.extraSystemPrompt);
|
|
1280
|
+
if (existingPrompt?.includes(refreshPrompt)) return;
|
|
1281
|
+
params.followupRun.run.extraSystemPrompt = [existingPrompt, refreshPrompt].filter(Boolean).join("\n\n");
|
|
1282
|
+
}
|
|
1283
|
+
async function readSessionLogSnapshot(params) {
|
|
1284
|
+
const logPath = resolveSessionLogPath(params.sessionId, params.sessionEntry, params.sessionKey, params.opts);
|
|
1285
|
+
if (!logPath) return {};
|
|
1286
|
+
const snapshot = {};
|
|
1287
|
+
if (params.includeByteSize) try {
|
|
1288
|
+
const stat = await fs.promises.stat(logPath);
|
|
1289
|
+
const size = Math.floor(stat.size);
|
|
1290
|
+
snapshot.byteSize = Number.isFinite(size) && size >= 0 ? size : void 0;
|
|
1291
|
+
} catch {
|
|
1292
|
+
snapshot.byteSize = void 0;
|
|
1293
|
+
}
|
|
1294
|
+
if (params.includeUsage) try {
|
|
1295
|
+
snapshot.usage = deriveTranscriptUsageSnapshot(await readLastNonzeroUsageFromSessionLog(logPath));
|
|
1296
|
+
} catch {
|
|
1297
|
+
snapshot.usage = void 0;
|
|
1298
|
+
}
|
|
1299
|
+
return snapshot;
|
|
1300
|
+
}
|
|
1301
|
+
async function readLastNonzeroUsageFromSessionLog(logPath) {
|
|
1302
|
+
const handle = await fs.promises.open(logPath, "r");
|
|
1303
|
+
try {
|
|
1304
|
+
let position = (await handle.stat()).size;
|
|
1305
|
+
let leadingPartial = "";
|
|
1306
|
+
while (position > 0) {
|
|
1307
|
+
const chunkSize = Math.min(TRANSCRIPT_TAIL_CHUNK_BYTES, position);
|
|
1308
|
+
const start = position - chunkSize;
|
|
1309
|
+
const buffer = Buffer.allocUnsafe(chunkSize);
|
|
1310
|
+
const { bytesRead } = await handle.read(buffer, 0, chunkSize, start);
|
|
1311
|
+
if (bytesRead <= 0) break;
|
|
1312
|
+
const lines = `${buffer.toString("utf-8", 0, bytesRead)}${leadingPartial}`.split(/\n+/);
|
|
1313
|
+
leadingPartial = lines.shift() ?? "";
|
|
1314
|
+
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
1315
|
+
const usage = parseUsageFromTranscriptLine(lines[i] ?? "");
|
|
1316
|
+
if (usage) return usage;
|
|
1317
|
+
}
|
|
1318
|
+
position = start;
|
|
1319
|
+
}
|
|
1320
|
+
return parseUsageFromTranscriptLine(leadingPartial);
|
|
1321
|
+
} finally {
|
|
1322
|
+
await handle.close();
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
function estimatePromptTokensFromSessionTranscript(params) {
|
|
1326
|
+
const sessionId = normalizeOptionalString(params.sessionId);
|
|
1327
|
+
if (!sessionId) return;
|
|
1328
|
+
try {
|
|
1329
|
+
const messages = readSessionMessages(sessionId, params.storePath, params.sessionFile);
|
|
1330
|
+
if (messages.length === 0) return;
|
|
1331
|
+
const estimatedTokens = estimateMessagesTokens(messages);
|
|
1332
|
+
if (!Number.isFinite(estimatedTokens) || estimatedTokens <= 0) return;
|
|
1333
|
+
return Math.ceil(estimatedTokens);
|
|
1334
|
+
} catch {
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
async function runPreflightCompactionIfNeeded(params) {
|
|
1339
|
+
if (!params.sessionKey) return params.sessionEntry;
|
|
1340
|
+
let entry = params.sessionEntry ?? (params.sessionKey ? params.sessionStore?.[params.sessionKey] : void 0);
|
|
1341
|
+
if (!entry?.sessionId) return entry ?? params.sessionEntry;
|
|
1342
|
+
const isCli = isCliProvider(params.followupRun.run.provider, params.cfg);
|
|
1343
|
+
if (params.isHeartbeat || isCli) {
|
|
1344
|
+
logVerbose("skipping preflight compaction and memory flush for heartbeat/cli session");
|
|
1345
|
+
return entry ?? params.sessionEntry;
|
|
1346
|
+
}
|
|
1347
|
+
const contextWindowTokens = resolveMemoryFlushContextWindowTokens({
|
|
1348
|
+
cfg: params.cfg,
|
|
1349
|
+
provider: params.followupRun.run.provider,
|
|
1350
|
+
modelId: params.followupRun.run.model ?? params.defaultModel,
|
|
1351
|
+
agentCfgContextTokens: params.agentCfgContextTokens
|
|
1352
|
+
});
|
|
1353
|
+
const memoryFlushPlan = resolveMemoryFlushPlan({ cfg: params.cfg });
|
|
1354
|
+
const reserveTokensFloor = memoryFlushPlan?.reserveTokensFloor ?? params.cfg.agents?.defaults?.compaction?.reserveTokensFloor ?? 2e4;
|
|
1355
|
+
const softThresholdTokens = memoryFlushPlan?.softThresholdTokens ?? 4e3;
|
|
1356
|
+
const freshPersistedTokens = resolveFreshSessionTotalTokens(entry);
|
|
1357
|
+
const persistedTotalTokens = entry.totalTokens;
|
|
1358
|
+
const hasPersistedTotalTokens = typeof persistedTotalTokens === "number" && Number.isFinite(persistedTotalTokens) && persistedTotalTokens > 0;
|
|
1359
|
+
if (!(entry.totalTokensFresh === false || !hasPersistedTotalTokens)) return entry ?? params.sessionEntry;
|
|
1360
|
+
const promptTokenEstimate = estimatePromptTokensForMemoryFlush(params.promptForEstimate ?? params.followupRun.prompt);
|
|
1361
|
+
const transcriptPromptTokens = typeof freshPersistedTokens === "number" ? void 0 : estimatePromptTokensFromSessionTranscript({
|
|
1362
|
+
sessionId: entry.sessionId,
|
|
1363
|
+
storePath: params.storePath,
|
|
1364
|
+
sessionFile: entry.sessionFile ?? params.followupRun.run.sessionFile
|
|
1365
|
+
});
|
|
1366
|
+
const projectedTokenCount = typeof transcriptPromptTokens === "number" ? resolveEffectivePromptTokens(transcriptPromptTokens, void 0, promptTokenEstimate) : void 0;
|
|
1367
|
+
const tokenCountForCompaction = typeof projectedTokenCount === "number" && Number.isFinite(projectedTokenCount) && projectedTokenCount > 0 ? projectedTokenCount : void 0;
|
|
1368
|
+
const threshold = contextWindowTokens - reserveTokensFloor - softThresholdTokens;
|
|
1369
|
+
logVerbose(`preflightCompaction check: sessionKey=${params.sessionKey} tokenCount=${tokenCountForCompaction ?? freshPersistedTokens ?? "undefined"} contextWindow=${contextWindowTokens} threshold=${threshold} isHeartbeat=${params.isHeartbeat} isCli=${isCli} persistedFresh=${entry?.totalTokensFresh === true} transcriptPromptTokens=${transcriptPromptTokens ?? "undefined"} promptTokensEst=${promptTokenEstimate ?? "undefined"}`);
|
|
1370
|
+
if (!shouldRunPreflightCompaction({
|
|
1371
|
+
entry,
|
|
1372
|
+
tokenCount: tokenCountForCompaction,
|
|
1373
|
+
contextWindowTokens,
|
|
1374
|
+
reserveTokensFloor,
|
|
1375
|
+
softThresholdTokens
|
|
1376
|
+
})) return entry ?? params.sessionEntry;
|
|
1377
|
+
logVerbose(`preflightCompaction triggered: sessionKey=${params.sessionKey} tokenCount=${tokenCountForCompaction ?? freshPersistedTokens ?? "undefined"} threshold=${threshold}`);
|
|
1378
|
+
params.replyOperation.setPhase("preflight_compacting");
|
|
1379
|
+
const sessionFile = resolveSessionLogPath(entry.sessionId, entry.sessionFile ? entry : {
|
|
1380
|
+
...entry,
|
|
1381
|
+
sessionFile: params.followupRun.run.sessionFile
|
|
1382
|
+
}, params.sessionKey ?? params.followupRun.run.sessionKey, { storePath: params.storePath });
|
|
1383
|
+
const result = await memoryDeps.compactEmbeddedPiSession({
|
|
1384
|
+
sessionId: entry.sessionId,
|
|
1385
|
+
sessionKey: params.sessionKey,
|
|
1386
|
+
allowGatewaySubagentBinding: true,
|
|
1387
|
+
messageChannel: params.followupRun.run.messageProvider,
|
|
1388
|
+
groupId: entry.groupId ?? params.followupRun.run.groupId,
|
|
1389
|
+
groupChannel: entry.groupChannel ?? params.followupRun.run.groupChannel,
|
|
1390
|
+
groupSpace: entry.space ?? params.followupRun.run.groupSpace,
|
|
1391
|
+
sessionFile: sessionFile ?? params.followupRun.run.sessionFile,
|
|
1392
|
+
workspaceDir: params.followupRun.run.workspaceDir,
|
|
1393
|
+
agentDir: params.followupRun.run.agentDir,
|
|
1394
|
+
config: params.cfg,
|
|
1395
|
+
skillsSnapshot: entry.skillsSnapshot ?? params.followupRun.run.skillsSnapshot,
|
|
1396
|
+
provider: params.followupRun.run.provider,
|
|
1397
|
+
model: params.followupRun.run.model,
|
|
1398
|
+
thinkLevel: params.followupRun.run.thinkLevel,
|
|
1399
|
+
bashElevated: params.followupRun.run.bashElevated,
|
|
1400
|
+
trigger: "budget",
|
|
1401
|
+
currentTokenCount: tokenCountForCompaction,
|
|
1402
|
+
senderIsOwner: params.followupRun.run.senderIsOwner,
|
|
1403
|
+
ownerNumbers: params.followupRun.run.ownerNumbers,
|
|
1404
|
+
abortSignal: params.replyOperation.abortSignal
|
|
1405
|
+
});
|
|
1406
|
+
if (!result?.ok || !result.compacted) {
|
|
1407
|
+
logVerbose(`preflightCompaction skipped: sessionKey=${params.sessionKey} reason=${result?.reason ?? "not_compacted"}`);
|
|
1408
|
+
return entry ?? params.sessionEntry;
|
|
1409
|
+
}
|
|
1410
|
+
await incrementCompactionCount({
|
|
1411
|
+
cfg: params.cfg,
|
|
1412
|
+
sessionEntry: entry,
|
|
1413
|
+
sessionStore: params.sessionStore,
|
|
1414
|
+
sessionKey: params.sessionKey,
|
|
1415
|
+
storePath: params.storePath,
|
|
1416
|
+
tokensAfter: result.result?.tokensAfter
|
|
1417
|
+
});
|
|
1418
|
+
await appendPostCompactionRefreshPrompt({
|
|
1419
|
+
cfg: params.cfg,
|
|
1420
|
+
followupRun: params.followupRun
|
|
1421
|
+
});
|
|
1422
|
+
entry = params.sessionStore?.[params.sessionKey] ?? entry;
|
|
1423
|
+
return entry ?? params.sessionEntry;
|
|
1424
|
+
}
|
|
1425
|
+
async function runMemoryFlushIfNeeded(params) {
|
|
1426
|
+
const memoryFlushPlan = resolveMemoryFlushPlan({ cfg: params.cfg });
|
|
1427
|
+
if (!memoryFlushPlan) return params.sessionEntry;
|
|
1428
|
+
const memoryFlushWritable = (() => {
|
|
1429
|
+
if (!params.sessionKey) return true;
|
|
1430
|
+
const runtime = resolveSandboxRuntimeStatus({
|
|
1431
|
+
cfg: params.cfg,
|
|
1432
|
+
sessionKey: params.sessionKey
|
|
1433
|
+
});
|
|
1434
|
+
if (!runtime.sandboxed) return true;
|
|
1435
|
+
return resolveSandboxConfigForAgent(params.cfg, runtime.agentId).workspaceAccess === "rw";
|
|
1436
|
+
})();
|
|
1437
|
+
const isCli = isCliProvider(params.followupRun.run.provider, params.cfg);
|
|
1438
|
+
const canAttemptFlush = memoryFlushWritable && !params.isHeartbeat && !isCli;
|
|
1439
|
+
let entry = params.sessionEntry ?? (params.sessionKey ? params.sessionStore?.[params.sessionKey] : void 0);
|
|
1440
|
+
const contextWindowTokens = resolveMemoryFlushContextWindowTokens({
|
|
1441
|
+
cfg: params.cfg,
|
|
1442
|
+
provider: params.followupRun.run.provider,
|
|
1443
|
+
modelId: params.followupRun.run.model ?? params.defaultModel,
|
|
1444
|
+
agentCfgContextTokens: params.agentCfgContextTokens
|
|
1445
|
+
});
|
|
1446
|
+
const promptTokenEstimate = estimatePromptTokensForMemoryFlush(params.promptForEstimate ?? params.followupRun.prompt);
|
|
1447
|
+
const persistedPromptTokensRaw = entry?.totalTokens;
|
|
1448
|
+
const persistedPromptTokens = typeof persistedPromptTokensRaw === "number" && Number.isFinite(persistedPromptTokensRaw) && persistedPromptTokensRaw > 0 ? persistedPromptTokensRaw : void 0;
|
|
1449
|
+
const hasFreshPersistedPromptTokens = typeof persistedPromptTokens === "number" && entry?.totalTokensFresh === true;
|
|
1450
|
+
const flushThreshold = contextWindowTokens - memoryFlushPlan.reserveTokensFloor - memoryFlushPlan.softThresholdTokens;
|
|
1451
|
+
const shouldReadTranscriptForOutput = canAttemptFlush && entry && hasFreshPersistedPromptTokens && typeof promptTokenEstimate === "number" && Number.isFinite(promptTokenEstimate) && flushThreshold > 0 && (persistedPromptTokens ?? 0) + promptTokenEstimate >= flushThreshold - TRANSCRIPT_OUTPUT_READ_BUFFER_TOKENS;
|
|
1452
|
+
const shouldReadTranscript = Boolean(canAttemptFlush && entry && (!hasFreshPersistedPromptTokens || shouldReadTranscriptForOutput));
|
|
1453
|
+
const forceFlushTranscriptBytes = memoryFlushPlan.forceFlushTranscriptBytes;
|
|
1454
|
+
const shouldCheckTranscriptSizeForForcedFlush = Boolean(canAttemptFlush && entry && Number.isFinite(forceFlushTranscriptBytes) && forceFlushTranscriptBytes > 0);
|
|
1455
|
+
const sessionLogSnapshot = shouldReadTranscript || shouldCheckTranscriptSizeForForcedFlush ? await readSessionLogSnapshot({
|
|
1456
|
+
sessionId: params.followupRun.run.sessionId,
|
|
1457
|
+
sessionEntry: entry,
|
|
1458
|
+
sessionKey: params.sessionKey ?? params.followupRun.run.sessionKey,
|
|
1459
|
+
opts: { storePath: params.storePath },
|
|
1460
|
+
includeByteSize: shouldCheckTranscriptSizeForForcedFlush,
|
|
1461
|
+
includeUsage: shouldReadTranscript
|
|
1462
|
+
}) : void 0;
|
|
1463
|
+
const transcriptByteSize = sessionLogSnapshot?.byteSize;
|
|
1464
|
+
const shouldForceFlushByTranscriptSize = typeof transcriptByteSize === "number" && transcriptByteSize >= forceFlushTranscriptBytes;
|
|
1465
|
+
const transcriptUsageSnapshot = sessionLogSnapshot?.usage;
|
|
1466
|
+
const transcriptPromptTokens = transcriptUsageSnapshot?.promptTokens;
|
|
1467
|
+
const transcriptOutputTokens = transcriptUsageSnapshot?.outputTokens;
|
|
1468
|
+
const hasReliableTranscriptPromptTokens = typeof transcriptPromptTokens === "number" && Number.isFinite(transcriptPromptTokens) && transcriptPromptTokens > 0;
|
|
1469
|
+
if (entry && hasReliableTranscriptPromptTokens && (!hasFreshPersistedPromptTokens || (transcriptPromptTokens ?? 0) > (persistedPromptTokens ?? 0))) {
|
|
1470
|
+
const nextEntry = {
|
|
1471
|
+
...entry,
|
|
1472
|
+
totalTokens: transcriptPromptTokens,
|
|
1473
|
+
totalTokensFresh: true
|
|
1474
|
+
};
|
|
1475
|
+
entry = nextEntry;
|
|
1476
|
+
if (params.sessionKey && params.sessionStore) params.sessionStore[params.sessionKey] = nextEntry;
|
|
1477
|
+
if (params.storePath && params.sessionKey) try {
|
|
1478
|
+
const updatedEntry = await updateSessionStoreEntry({
|
|
1479
|
+
storePath: params.storePath,
|
|
1480
|
+
sessionKey: params.sessionKey,
|
|
1481
|
+
update: async () => ({
|
|
1482
|
+
totalTokens: transcriptPromptTokens,
|
|
1483
|
+
totalTokensFresh: true
|
|
1484
|
+
})
|
|
1485
|
+
});
|
|
1486
|
+
if (updatedEntry) {
|
|
1487
|
+
entry = updatedEntry;
|
|
1488
|
+
if (params.sessionStore) params.sessionStore[params.sessionKey] = updatedEntry;
|
|
1489
|
+
}
|
|
1490
|
+
} catch (err) {
|
|
1491
|
+
logVerbose(`failed to persist derived prompt totalTokens: ${String(err)}`);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
const promptTokensSnapshot = Math.max(hasFreshPersistedPromptTokens ? persistedPromptTokens ?? 0 : 0, hasReliableTranscriptPromptTokens ? transcriptPromptTokens ?? 0 : 0);
|
|
1495
|
+
const projectedTokenCount = promptTokensSnapshot > 0 && (hasFreshPersistedPromptTokens || hasReliableTranscriptPromptTokens) ? resolveEffectivePromptTokens(promptTokensSnapshot, transcriptOutputTokens, promptTokenEstimate) : void 0;
|
|
1496
|
+
const tokenCountForFlush = typeof projectedTokenCount === "number" && Number.isFinite(projectedTokenCount) && projectedTokenCount > 0 ? projectedTokenCount : void 0;
|
|
1497
|
+
logVerbose(`memoryFlush check: sessionKey=${params.sessionKey} tokenCount=${tokenCountForFlush ?? "undefined"} contextWindow=${contextWindowTokens} threshold=${flushThreshold} isHeartbeat=${params.isHeartbeat} isCli=${isCli} memoryFlushWritable=${memoryFlushWritable} compactionCount=${entry?.compactionCount ?? 0} memoryFlushCompactionCount=${entry?.memoryFlushCompactionCount ?? "undefined"} persistedPromptTokens=${persistedPromptTokens ?? "undefined"} persistedFresh=${entry?.totalTokensFresh === true} promptTokensEst=${promptTokenEstimate ?? "undefined"} transcriptPromptTokens=${transcriptPromptTokens ?? "undefined"} transcriptOutputTokens=${transcriptOutputTokens ?? "undefined"} projectedTokenCount=${projectedTokenCount ?? "undefined"} transcriptBytes=${transcriptByteSize ?? "undefined"} forceFlushTranscriptBytes=${forceFlushTranscriptBytes} forceFlushByTranscriptSize=${shouldForceFlushByTranscriptSize}`);
|
|
1498
|
+
if (!(memoryFlushWritable && !params.isHeartbeat && !isCli && shouldRunMemoryFlush({
|
|
1499
|
+
entry,
|
|
1500
|
+
tokenCount: tokenCountForFlush,
|
|
1501
|
+
contextWindowTokens,
|
|
1502
|
+
reserveTokensFloor: memoryFlushPlan.reserveTokensFloor,
|
|
1503
|
+
softThresholdTokens: memoryFlushPlan.softThresholdTokens
|
|
1504
|
+
}) || shouldForceFlushByTranscriptSize && entry != null && !hasAlreadyFlushedForCurrentCompaction(entry))) return entry ?? params.sessionEntry;
|
|
1505
|
+
logVerbose(`memoryFlush triggered: sessionKey=${params.sessionKey} tokenCount=${tokenCountForFlush ?? "undefined"} threshold=${flushThreshold}`);
|
|
1506
|
+
params.replyOperation.setPhase("memory_flushing");
|
|
1507
|
+
let activeSessionEntry = entry ?? params.sessionEntry;
|
|
1508
|
+
const activeSessionStore = params.sessionStore;
|
|
1509
|
+
let bootstrapPromptWarningSignaturesSeen = resolveBootstrapWarningSignaturesSeen(activeSessionEntry?.systemPromptReport ?? (params.sessionKey ? activeSessionStore?.[params.sessionKey]?.systemPromptReport : void 0));
|
|
1510
|
+
const flushRunId = memoryDeps.randomUUID();
|
|
1511
|
+
if (params.sessionKey) memoryDeps.registerAgentRunContext(flushRunId, {
|
|
1512
|
+
sessionKey: params.sessionKey,
|
|
1513
|
+
verboseLevel: params.resolvedVerboseLevel
|
|
1514
|
+
});
|
|
1515
|
+
let memoryCompactionCompleted = false;
|
|
1516
|
+
const memoryFlushNowMs = memoryDeps.now();
|
|
1517
|
+
const activeMemoryFlushPlan = resolveMemoryFlushPlan({
|
|
1518
|
+
cfg: params.cfg,
|
|
1519
|
+
nowMs: memoryFlushNowMs
|
|
1520
|
+
}) ?? memoryFlushPlan;
|
|
1521
|
+
const memoryFlushWritePath = activeMemoryFlushPlan.relativePath;
|
|
1522
|
+
const flushSystemPrompt = [params.followupRun.run.extraSystemPrompt, activeMemoryFlushPlan.systemPrompt].filter(Boolean).join("\n\n");
|
|
1523
|
+
let postCompactionSessionId;
|
|
1524
|
+
try {
|
|
1525
|
+
await memoryDeps.runWithModelFallback({
|
|
1526
|
+
...resolveModelFallbackOptions(params.followupRun.run),
|
|
1527
|
+
runId: flushRunId,
|
|
1528
|
+
run: async (provider, model, runOptions) => {
|
|
1529
|
+
const { embeddedContext, senderContext, runBaseParams } = buildEmbeddedRunExecutionParams({
|
|
1530
|
+
run: params.followupRun.run,
|
|
1531
|
+
sessionCtx: params.sessionCtx,
|
|
1532
|
+
hasRepliedRef: params.opts?.hasRepliedRef,
|
|
1533
|
+
provider,
|
|
1534
|
+
model,
|
|
1535
|
+
runId: flushRunId,
|
|
1536
|
+
allowTransientCooldownProbe: runOptions?.allowTransientCooldownProbe
|
|
1537
|
+
});
|
|
1538
|
+
const result = await memoryDeps.runEmbeddedPiAgent({
|
|
1539
|
+
...embeddedContext,
|
|
1540
|
+
...senderContext,
|
|
1541
|
+
...runBaseParams,
|
|
1542
|
+
allowGatewaySubagentBinding: true,
|
|
1543
|
+
silentExpected: true,
|
|
1544
|
+
trigger: "memory",
|
|
1545
|
+
memoryFlushWritePath,
|
|
1546
|
+
prompt: activeMemoryFlushPlan.prompt,
|
|
1547
|
+
extraSystemPrompt: flushSystemPrompt,
|
|
1548
|
+
bootstrapPromptWarningSignaturesSeen,
|
|
1549
|
+
bootstrapPromptWarningSignature: bootstrapPromptWarningSignaturesSeen[bootstrapPromptWarningSignaturesSeen.length - 1],
|
|
1550
|
+
abortSignal: params.replyOperation.abortSignal,
|
|
1551
|
+
replyOperation: params.replyOperation,
|
|
1552
|
+
onAgentEvent: (evt) => {
|
|
1553
|
+
if (evt.stream === "compaction") {
|
|
1554
|
+
if ((typeof evt.data.phase === "string" ? evt.data.phase : "") === "end") memoryCompactionCompleted = true;
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
});
|
|
1558
|
+
if (result.meta?.agentMeta?.sessionId) postCompactionSessionId = result.meta.agentMeta.sessionId;
|
|
1559
|
+
bootstrapPromptWarningSignaturesSeen = resolveBootstrapWarningSignaturesSeen(result.meta?.systemPromptReport);
|
|
1560
|
+
return result;
|
|
1561
|
+
}
|
|
1562
|
+
});
|
|
1563
|
+
let memoryFlushCompactionCount = activeSessionEntry?.compactionCount ?? (params.sessionKey ? activeSessionStore?.[params.sessionKey]?.compactionCount : 0) ?? 0;
|
|
1564
|
+
if (memoryCompactionCompleted) {
|
|
1565
|
+
const previousSessionId = activeSessionEntry?.sessionId ?? params.followupRun.run.sessionId;
|
|
1566
|
+
const nextCount = await memoryDeps.incrementCompactionCount({
|
|
1567
|
+
cfg: params.cfg,
|
|
1568
|
+
sessionEntry: activeSessionEntry,
|
|
1569
|
+
sessionStore: activeSessionStore,
|
|
1570
|
+
sessionKey: params.sessionKey,
|
|
1571
|
+
storePath: params.storePath,
|
|
1572
|
+
newSessionId: postCompactionSessionId
|
|
1573
|
+
});
|
|
1574
|
+
const updatedEntry = params.sessionKey ? activeSessionStore?.[params.sessionKey] : void 0;
|
|
1575
|
+
if (updatedEntry) {
|
|
1576
|
+
activeSessionEntry = updatedEntry;
|
|
1577
|
+
params.followupRun.run.sessionId = updatedEntry.sessionId;
|
|
1578
|
+
params.replyOperation.updateSessionId(updatedEntry.sessionId);
|
|
1579
|
+
if (updatedEntry.sessionFile) params.followupRun.run.sessionFile = updatedEntry.sessionFile;
|
|
1580
|
+
const queueKey = params.followupRun.run.sessionKey ?? params.sessionKey;
|
|
1581
|
+
if (queueKey) memoryDeps.refreshQueuedFollowupSession({
|
|
1582
|
+
key: queueKey,
|
|
1583
|
+
previousSessionId,
|
|
1584
|
+
nextSessionId: updatedEntry.sessionId,
|
|
1585
|
+
nextSessionFile: updatedEntry.sessionFile
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
if (typeof nextCount === "number") memoryFlushCompactionCount = nextCount;
|
|
1589
|
+
}
|
|
1590
|
+
if (params.storePath && params.sessionKey) try {
|
|
1591
|
+
const updatedEntry = await memoryDeps.updateSessionStoreEntry({
|
|
1592
|
+
storePath: params.storePath,
|
|
1593
|
+
sessionKey: params.sessionKey,
|
|
1594
|
+
update: async () => ({
|
|
1595
|
+
memoryFlushAt: memoryDeps.now(),
|
|
1596
|
+
memoryFlushCompactionCount
|
|
1597
|
+
})
|
|
1598
|
+
});
|
|
1599
|
+
if (updatedEntry) {
|
|
1600
|
+
activeSessionEntry = updatedEntry;
|
|
1601
|
+
params.followupRun.run.sessionId = updatedEntry.sessionId;
|
|
1602
|
+
params.replyOperation.updateSessionId(updatedEntry.sessionId);
|
|
1603
|
+
if (updatedEntry.sessionFile) params.followupRun.run.sessionFile = updatedEntry.sessionFile;
|
|
1604
|
+
}
|
|
1605
|
+
} catch (err) {
|
|
1606
|
+
logVerbose(`failed to persist memory flush metadata: ${String(err)}`);
|
|
1607
|
+
}
|
|
1608
|
+
} catch (err) {
|
|
1609
|
+
logVerbose(`memory flush run failed: ${String(err)}`);
|
|
1610
|
+
}
|
|
1611
|
+
return activeSessionEntry;
|
|
1612
|
+
}
|
|
1613
|
+
//#endregion
|
|
1614
|
+
//#region src/auto-reply/reply/agent-runner-payloads.ts
|
|
1615
|
+
let replyPayloadsDedupeRuntimePromise = null;
|
|
1616
|
+
function loadReplyPayloadsDedupeRuntime() {
|
|
1617
|
+
replyPayloadsDedupeRuntimePromise ??= import("./reply-payloads-dedupe.runtime-Y6x_m1r3.js");
|
|
1618
|
+
return replyPayloadsDedupeRuntimePromise;
|
|
1619
|
+
}
|
|
1620
|
+
async function normalizeReplyPayloadMedia(params) {
|
|
1621
|
+
if (!params.normalizeMediaPaths || !resolveSendableOutboundReplyParts(params.payload).hasMedia) return params.payload;
|
|
1622
|
+
try {
|
|
1623
|
+
return await params.normalizeMediaPaths(params.payload);
|
|
1624
|
+
} catch (err) {
|
|
1625
|
+
logVerbose(`reply payload media normalization failed: ${String(err)}`);
|
|
1626
|
+
return {
|
|
1627
|
+
...params.payload,
|
|
1628
|
+
mediaUrl: void 0,
|
|
1629
|
+
mediaUrls: void 0,
|
|
1630
|
+
audioAsVoice: false
|
|
1631
|
+
};
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
async function normalizeSentMediaUrlsForDedupe(params) {
|
|
1635
|
+
if (params.sentMediaUrls.length === 0 || !params.normalizeMediaPaths) return params.sentMediaUrls;
|
|
1636
|
+
const normalizedUrls = [];
|
|
1637
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1638
|
+
for (const raw of params.sentMediaUrls) {
|
|
1639
|
+
const trimmed = raw.trim();
|
|
1640
|
+
if (!trimmed) continue;
|
|
1641
|
+
if (!seen.has(trimmed)) {
|
|
1642
|
+
seen.add(trimmed);
|
|
1643
|
+
normalizedUrls.push(trimmed);
|
|
1644
|
+
}
|
|
1645
|
+
try {
|
|
1646
|
+
const normalizedMediaUrls = resolveSendableOutboundReplyParts(await params.normalizeMediaPaths({
|
|
1647
|
+
mediaUrl: trimmed,
|
|
1648
|
+
mediaUrls: [trimmed]
|
|
1649
|
+
})).mediaUrls;
|
|
1650
|
+
for (const mediaUrl of normalizedMediaUrls) {
|
|
1651
|
+
const candidate = mediaUrl.trim();
|
|
1652
|
+
if (!candidate || seen.has(candidate)) continue;
|
|
1653
|
+
seen.add(candidate);
|
|
1654
|
+
normalizedUrls.push(candidate);
|
|
1655
|
+
}
|
|
1656
|
+
} catch (err) {
|
|
1657
|
+
logVerbose(`messaging tool sent-media normalization failed: ${String(err)}`);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
return normalizedUrls;
|
|
1661
|
+
}
|
|
1662
|
+
async function buildReplyPayloads(params) {
|
|
1663
|
+
let didLogHeartbeatStrip = params.didLogHeartbeatStrip;
|
|
1664
|
+
const sanitizedPayloads = params.isHeartbeat ? params.payloads : params.payloads.flatMap((payload) => {
|
|
1665
|
+
let text = payload.text;
|
|
1666
|
+
if (payload.isError && text && isBunFetchSocketError(text)) text = formatBunFetchSocketError(text);
|
|
1667
|
+
if (!text || !text.includes("HEARTBEAT_OK")) return [{
|
|
1668
|
+
...payload,
|
|
1669
|
+
text
|
|
1670
|
+
}];
|
|
1671
|
+
const stripped = stripHeartbeatToken(text, { mode: "message" });
|
|
1672
|
+
if (stripped.didStrip && !didLogHeartbeatStrip) {
|
|
1673
|
+
didLogHeartbeatStrip = true;
|
|
1674
|
+
logVerbose("Stripped stray HEARTBEAT_OK token from reply");
|
|
1675
|
+
}
|
|
1676
|
+
const hasMedia = resolveSendableOutboundReplyParts(payload).hasMedia;
|
|
1677
|
+
if (stripped.shouldSkip && !hasMedia) return [];
|
|
1678
|
+
return [{
|
|
1679
|
+
...payload,
|
|
1680
|
+
text: stripped.text
|
|
1681
|
+
}];
|
|
1682
|
+
});
|
|
1683
|
+
const replyTaggedPayloads = (await Promise.all(applyReplyThreading({
|
|
1684
|
+
payloads: sanitizedPayloads,
|
|
1685
|
+
replyToMode: params.replyToMode,
|
|
1686
|
+
replyToChannel: params.replyToChannel,
|
|
1687
|
+
currentMessageId: params.currentMessageId,
|
|
1688
|
+
replyThreading: params.replyThreading
|
|
1689
|
+
}).map(async (payload) => {
|
|
1690
|
+
const parsed = normalizeReplyPayloadDirectives({
|
|
1691
|
+
payload,
|
|
1692
|
+
currentMessageId: params.currentMessageId,
|
|
1693
|
+
silentToken: SILENT_REPLY_TOKEN,
|
|
1694
|
+
parseMode: "always"
|
|
1695
|
+
}).payload;
|
|
1696
|
+
return await normalizeReplyPayloadMedia({
|
|
1697
|
+
payload: parsed,
|
|
1698
|
+
normalizeMediaPaths: params.normalizeMediaPaths
|
|
1699
|
+
});
|
|
1700
|
+
}))).filter(isRenderablePayload);
|
|
1701
|
+
const silentFilteredPayloads = params.silentExpected ? [] : replyTaggedPayloads;
|
|
1702
|
+
const shouldDropFinalPayloads = params.blockStreamingEnabled && Boolean(params.blockReplyPipeline?.didStream()) && !params.blockReplyPipeline?.isAborted();
|
|
1703
|
+
const messagingToolSentTexts = params.messagingToolSentTexts ?? [];
|
|
1704
|
+
const messagingToolSentTargets = params.messagingToolSentTargets ?? [];
|
|
1705
|
+
const dedupeRuntime = messagingToolSentTexts.length > 0 || (params.messagingToolSentMediaUrls?.length ?? 0) > 0 || messagingToolSentTargets.length > 0 ? await loadReplyPayloadsDedupeRuntime() : null;
|
|
1706
|
+
const suppressMessagingToolReplies = dedupeRuntime?.shouldSuppressMessagingToolReplies({
|
|
1707
|
+
messageProvider: resolveOriginMessageProvider({
|
|
1708
|
+
originatingChannel: params.originatingChannel,
|
|
1709
|
+
provider: params.messageProvider
|
|
1710
|
+
}),
|
|
1711
|
+
messagingToolSentTargets,
|
|
1712
|
+
originatingTo: resolveOriginMessageTo({ originatingTo: params.originatingTo }),
|
|
1713
|
+
accountId: resolveOriginAccountId({ originatingAccountId: params.accountId })
|
|
1714
|
+
}) ?? false;
|
|
1715
|
+
const dedupeMessagingToolPayloads = suppressMessagingToolReplies || messagingToolSentTargets.length === 0;
|
|
1716
|
+
const messagingToolSentMediaUrls = dedupeMessagingToolPayloads ? await normalizeSentMediaUrlsForDedupe({
|
|
1717
|
+
sentMediaUrls: params.messagingToolSentMediaUrls ?? [],
|
|
1718
|
+
normalizeMediaPaths: params.normalizeMediaPaths
|
|
1719
|
+
}) : params.messagingToolSentMediaUrls ?? [];
|
|
1720
|
+
const dedupedPayloads = dedupeMessagingToolPayloads ? (dedupeRuntime ?? await loadReplyPayloadsDedupeRuntime()).filterMessagingToolDuplicates({
|
|
1721
|
+
payloads: silentFilteredPayloads,
|
|
1722
|
+
sentTexts: messagingToolSentTexts
|
|
1723
|
+
}) : silentFilteredPayloads;
|
|
1724
|
+
const mediaFilteredPayloads = dedupeMessagingToolPayloads ? (dedupeRuntime ?? await loadReplyPayloadsDedupeRuntime()).filterMessagingToolMediaDuplicates({
|
|
1725
|
+
payloads: dedupedPayloads,
|
|
1726
|
+
sentMediaUrls: messagingToolSentMediaUrls
|
|
1727
|
+
}) : dedupedPayloads;
|
|
1728
|
+
const filteredPayloads = shouldDropFinalPayloads ? [] : params.blockStreamingEnabled ? mediaFilteredPayloads.filter((payload) => !params.blockReplyPipeline?.hasSentPayload(payload)) : params.directlySentBlockKeys?.size ? mediaFilteredPayloads.filter((payload) => !params.directlySentBlockKeys.has(createBlockReplyContentKey(payload))) : mediaFilteredPayloads;
|
|
1729
|
+
return {
|
|
1730
|
+
replyPayloads: suppressMessagingToolReplies ? [] : filteredPayloads,
|
|
1731
|
+
didLogHeartbeatStrip
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1734
|
+
//#endregion
|
|
1735
|
+
//#region src/auto-reply/reply/agent-runner-reminder-guard.ts
|
|
1736
|
+
const UNSCHEDULED_REMINDER_NOTE = "Note: I did not schedule a reminder in this turn, so this will not trigger automatically.";
|
|
1737
|
+
const REMINDER_COMMITMENT_PATTERNS = [/\b(?:i\s*['’]?ll|i will)\s+(?:make sure to\s+)?(?:remember|remind|ping|follow up|follow-up|check back|circle back)\b/i, /\b(?:i\s*['’]?ll|i will)\s+(?:set|create|schedule)\s+(?:a\s+)?reminder\b/i];
|
|
1738
|
+
function hasUnbackedReminderCommitment(text) {
|
|
1739
|
+
const normalized = normalizeLowercaseStringOrEmpty(text);
|
|
1740
|
+
if (!normalized.trim()) return false;
|
|
1741
|
+
if (normalized.includes(normalizeLowercaseStringOrEmpty("Note: I did not schedule a reminder in this turn, so this will not trigger automatically."))) return false;
|
|
1742
|
+
return REMINDER_COMMITMENT_PATTERNS.some((pattern) => pattern.test(text));
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Returns true when the cron store has at least one enabled job that shares the
|
|
1746
|
+
* current session key. Used to suppress the "no reminder scheduled" guard note
|
|
1747
|
+
* when an existing cron (created in a prior turn) already covers the commitment.
|
|
1748
|
+
*/
|
|
1749
|
+
async function hasSessionRelatedCronJobs(params) {
|
|
1750
|
+
try {
|
|
1751
|
+
const store = await loadCronStore(resolveCronStorePath(params.cronStorePath));
|
|
1752
|
+
if (store.jobs.length === 0) return false;
|
|
1753
|
+
if (params.sessionKey) return store.jobs.some((job) => job.enabled && job.sessionKey === params.sessionKey);
|
|
1754
|
+
return false;
|
|
1755
|
+
} catch {
|
|
1756
|
+
return false;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
function appendUnscheduledReminderNote(payloads) {
|
|
1760
|
+
let appended = false;
|
|
1761
|
+
return payloads.map((payload) => {
|
|
1762
|
+
if (appended || payload.isError || typeof payload.text !== "string") return payload;
|
|
1763
|
+
if (!hasUnbackedReminderCommitment(payload.text)) return payload;
|
|
1764
|
+
appended = true;
|
|
1765
|
+
const trimmed = payload.text.trimEnd();
|
|
1766
|
+
return {
|
|
1767
|
+
...payload,
|
|
1768
|
+
text: `${trimmed}\n\n${UNSCHEDULED_REMINDER_NOTE}`
|
|
1769
|
+
};
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
//#endregion
|
|
1773
|
+
//#region src/auto-reply/reply/agent-runner-session-reset.ts
|
|
1774
|
+
const deps = {
|
|
1775
|
+
generateSecureUuid,
|
|
1776
|
+
updateSessionStore,
|
|
1777
|
+
refreshQueuedFollowupSession,
|
|
1778
|
+
error: (message) => defaultRuntime.error(message)
|
|
1779
|
+
};
|
|
1780
|
+
async function resetReplyRunSession(params) {
|
|
1781
|
+
if (!params.sessionKey || !params.activeSessionStore || !params.storePath) return false;
|
|
1782
|
+
const prevEntry = params.activeSessionStore[params.sessionKey] ?? params.activeSessionEntry;
|
|
1783
|
+
if (!prevEntry) return false;
|
|
1784
|
+
const prevSessionId = params.options.cleanupTranscripts ? prevEntry.sessionId : void 0;
|
|
1785
|
+
const nextSessionId = deps.generateSecureUuid();
|
|
1786
|
+
const nextEntry = {
|
|
1787
|
+
...prevEntry,
|
|
1788
|
+
sessionId: nextSessionId,
|
|
1789
|
+
updatedAt: Date.now(),
|
|
1790
|
+
systemSent: false,
|
|
1791
|
+
abortedLastRun: false,
|
|
1792
|
+
modelProvider: void 0,
|
|
1793
|
+
model: void 0,
|
|
1794
|
+
inputTokens: void 0,
|
|
1795
|
+
outputTokens: void 0,
|
|
1796
|
+
totalTokens: void 0,
|
|
1797
|
+
totalTokensFresh: false,
|
|
1798
|
+
estimatedCostUsd: void 0,
|
|
1799
|
+
cacheRead: void 0,
|
|
1800
|
+
cacheWrite: void 0,
|
|
1801
|
+
contextTokens: void 0,
|
|
1802
|
+
systemPromptReport: void 0,
|
|
1803
|
+
fallbackNoticeSelectedModel: void 0,
|
|
1804
|
+
fallbackNoticeActiveModel: void 0,
|
|
1805
|
+
fallbackNoticeReason: void 0
|
|
1806
|
+
};
|
|
1807
|
+
const agentId = resolveAgentIdFromSessionKey(params.sessionKey);
|
|
1808
|
+
const nextSessionFile = resolveSessionTranscriptPath(nextSessionId, agentId, params.messageThreadId);
|
|
1809
|
+
nextEntry.sessionFile = nextSessionFile;
|
|
1810
|
+
params.activeSessionStore[params.sessionKey] = nextEntry;
|
|
1811
|
+
try {
|
|
1812
|
+
await deps.updateSessionStore(params.storePath, (store) => {
|
|
1813
|
+
store[params.sessionKey] = nextEntry;
|
|
1814
|
+
});
|
|
1815
|
+
} catch (err) {
|
|
1816
|
+
deps.error(`Failed to persist session reset after ${params.options.failureLabel} (${params.sessionKey}): ${String(err)}`);
|
|
1817
|
+
}
|
|
1818
|
+
params.followupRun.run.sessionId = nextSessionId;
|
|
1819
|
+
params.followupRun.run.sessionFile = nextSessionFile;
|
|
1820
|
+
deps.refreshQueuedFollowupSession({
|
|
1821
|
+
key: params.queueKey,
|
|
1822
|
+
previousSessionId: prevEntry.sessionId,
|
|
1823
|
+
nextSessionId,
|
|
1824
|
+
nextSessionFile
|
|
1825
|
+
});
|
|
1826
|
+
params.onActiveSessionEntry(nextEntry);
|
|
1827
|
+
params.onNewSession(nextSessionId, nextSessionFile);
|
|
1828
|
+
deps.error(params.options.buildLogMessage(nextSessionId));
|
|
1829
|
+
if (params.options.cleanupTranscripts && prevSessionId) {
|
|
1830
|
+
const transcriptCandidates = /* @__PURE__ */ new Set();
|
|
1831
|
+
const resolved = resolveSessionFilePath(prevSessionId, prevEntry, resolveSessionFilePathOptions({
|
|
1832
|
+
agentId,
|
|
1833
|
+
storePath: params.storePath
|
|
1834
|
+
}));
|
|
1835
|
+
if (resolved) transcriptCandidates.add(resolved);
|
|
1836
|
+
transcriptCandidates.add(resolveSessionTranscriptPath(prevSessionId, agentId));
|
|
1837
|
+
for (const candidate of transcriptCandidates) try {
|
|
1838
|
+
fs.unlinkSync(candidate);
|
|
1839
|
+
} catch {}
|
|
1840
|
+
}
|
|
1841
|
+
return true;
|
|
1842
|
+
}
|
|
1843
|
+
//#endregion
|
|
1844
|
+
//#region src/auto-reply/reply/agent-runner-usage-line.ts
|
|
1845
|
+
const formatResponseUsageLine = (params) => {
|
|
1846
|
+
const usage = params.usage;
|
|
1847
|
+
if (!usage) return null;
|
|
1848
|
+
const input = usage.input;
|
|
1849
|
+
const output = usage.output;
|
|
1850
|
+
if (typeof input !== "number" && typeof output !== "number") return null;
|
|
1851
|
+
const inputLabel = typeof input === "number" ? formatTokenCount(input) : "?";
|
|
1852
|
+
const outputLabel = typeof output === "number" ? formatTokenCount(output) : "?";
|
|
1853
|
+
const cost = params.showCost && typeof input === "number" && typeof output === "number" ? estimateUsageCost({
|
|
1854
|
+
usage: {
|
|
1855
|
+
input,
|
|
1856
|
+
output,
|
|
1857
|
+
cacheRead: usage.cacheRead,
|
|
1858
|
+
cacheWrite: usage.cacheWrite
|
|
1859
|
+
},
|
|
1860
|
+
cost: params.costConfig
|
|
1861
|
+
}) : void 0;
|
|
1862
|
+
const costLabel = params.showCost ? formatUsd(cost) : void 0;
|
|
1863
|
+
return `Usage: ${inputLabel} in / ${outputLabel} out${costLabel ? ` · est ${costLabel}` : ""}`;
|
|
1864
|
+
};
|
|
1865
|
+
const appendUsageLine = (payloads, line) => {
|
|
1866
|
+
let index = -1;
|
|
1867
|
+
for (let i = payloads.length - 1; i >= 0; i -= 1) if (payloads[i]?.text) {
|
|
1868
|
+
index = i;
|
|
1869
|
+
break;
|
|
1870
|
+
}
|
|
1871
|
+
if (index === -1) return [...payloads, { text: line }];
|
|
1872
|
+
const existing = payloads[index];
|
|
1873
|
+
const existingText = existing.text ?? "";
|
|
1874
|
+
const separator = existingText.endsWith("\n") ? "" : "\n";
|
|
1875
|
+
const next = {
|
|
1876
|
+
...existing,
|
|
1877
|
+
text: `${existingText}${separator}${line}`
|
|
1878
|
+
};
|
|
1879
|
+
const updated = payloads.slice();
|
|
1880
|
+
updated[index] = next;
|
|
1881
|
+
return updated;
|
|
1882
|
+
};
|
|
1883
|
+
//#endregion
|
|
1884
|
+
//#region src/auto-reply/reply/followup-delivery.ts
|
|
1885
|
+
function resolveFollowupDeliveryPayloads(params) {
|
|
1886
|
+
const replyToChannel = resolveOriginMessageProvider({
|
|
1887
|
+
originatingChannel: params.originatingChannel,
|
|
1888
|
+
provider: params.messageProvider
|
|
1889
|
+
});
|
|
1890
|
+
const replyToMode = resolveReplyToMode(params.cfg, replyToChannel, params.originatingAccountId, params.originatingChatType);
|
|
1891
|
+
const mediaFilteredPayloads = filterMessagingToolMediaDuplicates({
|
|
1892
|
+
payloads: filterMessagingToolDuplicates({
|
|
1893
|
+
payloads: applyReplyThreading({
|
|
1894
|
+
payloads: params.payloads.flatMap((payload) => {
|
|
1895
|
+
const text = payload.text;
|
|
1896
|
+
if (!text || !text.includes("HEARTBEAT_OK")) return [payload];
|
|
1897
|
+
const stripped = stripHeartbeatToken(text, { mode: "message" });
|
|
1898
|
+
const hasMedia = resolveSendableOutboundReplyParts(payload).hasMedia;
|
|
1899
|
+
if (stripped.shouldSkip && !hasMedia) return [];
|
|
1900
|
+
return [{
|
|
1901
|
+
...payload,
|
|
1902
|
+
text: stripped.text
|
|
1903
|
+
}];
|
|
1904
|
+
}),
|
|
1905
|
+
replyToMode,
|
|
1906
|
+
replyToChannel
|
|
1907
|
+
}),
|
|
1908
|
+
sentTexts: params.sentTexts ?? []
|
|
1909
|
+
}),
|
|
1910
|
+
sentMediaUrls: params.sentMediaUrls ?? []
|
|
1911
|
+
});
|
|
1912
|
+
return shouldSuppressMessagingToolReplies({
|
|
1913
|
+
messageProvider: replyToChannel,
|
|
1914
|
+
messagingToolSentTargets: params.sentTargets,
|
|
1915
|
+
originatingTo: resolveOriginMessageTo({ originatingTo: params.originatingTo }),
|
|
1916
|
+
accountId: resolveOriginAccountId({ originatingAccountId: params.originatingAccountId })
|
|
1917
|
+
}) ? [] : mediaFilteredPayloads;
|
|
1918
|
+
}
|
|
1919
|
+
//#endregion
|
|
1920
|
+
//#region src/auto-reply/reply/session-usage.ts
|
|
1921
|
+
function applyCliSessionIdToSessionPatch(params, entry, patch) {
|
|
1922
|
+
const cliProvider = params.providerUsed ?? entry.modelProvider;
|
|
1923
|
+
if (params.cliSessionBinding && cliProvider) {
|
|
1924
|
+
const nextEntry = {
|
|
1925
|
+
...entry,
|
|
1926
|
+
...patch
|
|
1927
|
+
};
|
|
1928
|
+
setCliSessionBinding(nextEntry, cliProvider, params.cliSessionBinding);
|
|
1929
|
+
return {
|
|
1930
|
+
...patch,
|
|
1931
|
+
cliSessionIds: nextEntry.cliSessionIds,
|
|
1932
|
+
cliSessionBindings: nextEntry.cliSessionBindings,
|
|
1933
|
+
claudeCliSessionId: nextEntry.claudeCliSessionId
|
|
1934
|
+
};
|
|
1935
|
+
}
|
|
1936
|
+
if (params.cliSessionId && cliProvider) {
|
|
1937
|
+
const nextEntry = {
|
|
1938
|
+
...entry,
|
|
1939
|
+
...patch
|
|
1940
|
+
};
|
|
1941
|
+
setCliSessionId(nextEntry, cliProvider, params.cliSessionId);
|
|
1942
|
+
return {
|
|
1943
|
+
...patch,
|
|
1944
|
+
cliSessionIds: nextEntry.cliSessionIds,
|
|
1945
|
+
cliSessionBindings: nextEntry.cliSessionBindings,
|
|
1946
|
+
claudeCliSessionId: nextEntry.claudeCliSessionId
|
|
1947
|
+
};
|
|
1948
|
+
}
|
|
1949
|
+
return patch;
|
|
1950
|
+
}
|
|
1951
|
+
function resolveNonNegativeNumber(value) {
|
|
1952
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
1953
|
+
}
|
|
1954
|
+
function estimateSessionRunCostUsd(params) {
|
|
1955
|
+
if (!hasNonzeroUsage(params.usage)) return;
|
|
1956
|
+
const cost = resolveModelCostConfig({
|
|
1957
|
+
provider: params.providerUsed,
|
|
1958
|
+
model: params.modelUsed,
|
|
1959
|
+
config: params.cfg
|
|
1960
|
+
});
|
|
1961
|
+
return resolveNonNegativeNumber(estimateUsageCost({
|
|
1962
|
+
usage: params.usage,
|
|
1963
|
+
cost
|
|
1964
|
+
}));
|
|
1965
|
+
}
|
|
1966
|
+
async function persistSessionUsageUpdate(params) {
|
|
1967
|
+
const { storePath, sessionKey } = params;
|
|
1968
|
+
if (!storePath || !sessionKey) return;
|
|
1969
|
+
const label = params.logLabel ? `${params.logLabel} ` : "";
|
|
1970
|
+
const cfg = params.cfg ?? loadConfig();
|
|
1971
|
+
const hasUsage = hasNonzeroUsage(params.usage);
|
|
1972
|
+
const hasPromptTokens = typeof params.promptTokens === "number" && Number.isFinite(params.promptTokens) && params.promptTokens > 0;
|
|
1973
|
+
const hasFreshContextSnapshot = Boolean(params.lastCallUsage) || hasPromptTokens || params.usageIsContextSnapshot === true;
|
|
1974
|
+
if (hasUsage || hasFreshContextSnapshot) {
|
|
1975
|
+
try {
|
|
1976
|
+
await updateSessionStoreEntry({
|
|
1977
|
+
storePath,
|
|
1978
|
+
sessionKey,
|
|
1979
|
+
update: async (entry) => {
|
|
1980
|
+
const resolvedContextTokens = params.contextTokensUsed ?? entry.contextTokens;
|
|
1981
|
+
const usageForContext = params.lastCallUsage ?? (params.usageIsContextSnapshot === true ? params.usage : void 0);
|
|
1982
|
+
const totalTokens = hasFreshContextSnapshot ? deriveSessionTotalTokens({
|
|
1983
|
+
usage: usageForContext,
|
|
1984
|
+
contextTokens: resolvedContextTokens,
|
|
1985
|
+
promptTokens: params.promptTokens
|
|
1986
|
+
}) : void 0;
|
|
1987
|
+
const runEstimatedCostUsd = estimateSessionRunCostUsd({
|
|
1988
|
+
cfg,
|
|
1989
|
+
usage: params.usage,
|
|
1990
|
+
providerUsed: params.providerUsed ?? entry.modelProvider,
|
|
1991
|
+
modelUsed: params.modelUsed ?? entry.model
|
|
1992
|
+
});
|
|
1993
|
+
const existingEstimatedCostUsd = resolveNonNegativeNumber(entry.estimatedCostUsd) ?? 0;
|
|
1994
|
+
const patch = {
|
|
1995
|
+
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
1996
|
+
model: params.modelUsed ?? entry.model,
|
|
1997
|
+
contextTokens: resolvedContextTokens,
|
|
1998
|
+
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
1999
|
+
updatedAt: Date.now()
|
|
2000
|
+
};
|
|
2001
|
+
if (hasUsage) {
|
|
2002
|
+
patch.inputTokens = params.usage?.input ?? 0;
|
|
2003
|
+
patch.outputTokens = params.usage?.output ?? 0;
|
|
2004
|
+
const cacheUsage = params.lastCallUsage ?? params.usage;
|
|
2005
|
+
patch.cacheRead = cacheUsage?.cacheRead ?? 0;
|
|
2006
|
+
patch.cacheWrite = cacheUsage?.cacheWrite ?? 0;
|
|
2007
|
+
}
|
|
2008
|
+
if (runEstimatedCostUsd !== void 0) patch.estimatedCostUsd = existingEstimatedCostUsd + runEstimatedCostUsd;
|
|
2009
|
+
else if (entry.estimatedCostUsd !== void 0) patch.estimatedCostUsd = entry.estimatedCostUsd;
|
|
2010
|
+
patch.totalTokens = totalTokens;
|
|
2011
|
+
patch.totalTokensFresh = typeof totalTokens === "number";
|
|
2012
|
+
return applyCliSessionIdToSessionPatch(params, entry, patch);
|
|
2013
|
+
}
|
|
2014
|
+
});
|
|
2015
|
+
} catch (err) {
|
|
2016
|
+
logVerbose(`failed to persist ${label}usage update: ${String(err)}`);
|
|
2017
|
+
}
|
|
2018
|
+
return;
|
|
2019
|
+
}
|
|
2020
|
+
if (params.modelUsed || params.contextTokensUsed) try {
|
|
2021
|
+
await updateSessionStoreEntry({
|
|
2022
|
+
storePath,
|
|
2023
|
+
sessionKey,
|
|
2024
|
+
update: async (entry) => {
|
|
2025
|
+
return applyCliSessionIdToSessionPatch(params, entry, {
|
|
2026
|
+
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
2027
|
+
model: params.modelUsed ?? entry.model,
|
|
2028
|
+
contextTokens: params.contextTokensUsed ?? entry.contextTokens,
|
|
2029
|
+
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
2030
|
+
updatedAt: Date.now()
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
});
|
|
2034
|
+
} catch (err) {
|
|
2035
|
+
logVerbose(`failed to persist ${label}model/context update: ${String(err)}`);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
//#endregion
|
|
2039
|
+
//#region src/auto-reply/reply/session-run-accounting.ts
|
|
2040
|
+
async function persistRunSessionUsage(params) {
|
|
2041
|
+
await persistSessionUsageUpdate(params);
|
|
2042
|
+
}
|
|
2043
|
+
async function incrementRunCompactionCount(params) {
|
|
2044
|
+
const tokensAfterCompaction = params.lastCallUsage ? deriveSessionTotalTokens({
|
|
2045
|
+
usage: params.lastCallUsage,
|
|
2046
|
+
contextTokens: params.contextTokensUsed
|
|
2047
|
+
}) : void 0;
|
|
2048
|
+
return incrementCompactionCount({
|
|
2049
|
+
sessionEntry: params.sessionEntry,
|
|
2050
|
+
sessionStore: params.sessionStore,
|
|
2051
|
+
sessionKey: params.sessionKey,
|
|
2052
|
+
storePath: params.storePath,
|
|
2053
|
+
cfg: params.cfg,
|
|
2054
|
+
amount: params.amount,
|
|
2055
|
+
tokensAfter: tokensAfterCompaction,
|
|
2056
|
+
newSessionId: params.newSessionId
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
//#endregion
|
|
2060
|
+
//#region src/auto-reply/reply/followup-runner.ts
|
|
2061
|
+
function createFollowupRunner(params) {
|
|
2062
|
+
const { opts, typing, typingMode, sessionEntry, sessionStore, sessionKey, storePath, defaultModel, agentCfgContextTokens } = params;
|
|
2063
|
+
const typingSignals = createTypingSignaler({
|
|
2064
|
+
typing,
|
|
2065
|
+
mode: typingMode,
|
|
2066
|
+
isHeartbeat: opts?.isHeartbeat === true
|
|
2067
|
+
});
|
|
2068
|
+
/**
|
|
2069
|
+
* Sends followup payloads, routing to the originating channel if set.
|
|
2070
|
+
*
|
|
2071
|
+
* When originatingChannel/originatingTo are set on the queued run,
|
|
2072
|
+
* replies are routed directly to that provider instead of using the
|
|
2073
|
+
* session's current dispatcher. This ensures replies go back to
|
|
2074
|
+
* where the message originated.
|
|
2075
|
+
*/
|
|
2076
|
+
const sendFollowupPayloads = async (payloads, queued) => {
|
|
2077
|
+
const { originatingChannel, originatingTo } = queued;
|
|
2078
|
+
const runtimeConfig = resolveQueuedReplyRuntimeConfig(queued.run.config);
|
|
2079
|
+
const shouldRouteToOriginating = isRoutableChannel(originatingChannel) && originatingTo;
|
|
2080
|
+
if (!shouldRouteToOriginating && !opts?.onBlockReply) {
|
|
2081
|
+
logVerbose("followup queue: no onBlockReply handler; dropping payloads");
|
|
2082
|
+
return;
|
|
2083
|
+
}
|
|
2084
|
+
for (const payload of payloads) {
|
|
2085
|
+
if (!payload || !hasOutboundReplyContent(payload)) continue;
|
|
2086
|
+
if (isSilentReplyText(payload.text, "NO_REPLY") && !resolveSendableOutboundReplyParts(payload).hasMedia) continue;
|
|
2087
|
+
await typingSignals.signalTextDelta(payload.text);
|
|
2088
|
+
if (shouldRouteToOriginating) {
|
|
2089
|
+
const result = await routeReply({
|
|
2090
|
+
payload,
|
|
2091
|
+
channel: originatingChannel,
|
|
2092
|
+
to: originatingTo,
|
|
2093
|
+
sessionKey: queued.run.sessionKey,
|
|
2094
|
+
accountId: queued.originatingAccountId,
|
|
2095
|
+
threadId: queued.originatingThreadId,
|
|
2096
|
+
cfg: runtimeConfig
|
|
2097
|
+
});
|
|
2098
|
+
if (!result.ok) {
|
|
2099
|
+
logVerbose(`followup queue: route-reply failed: ${result.error ?? "unknown error"}`);
|
|
2100
|
+
const provider = resolveOriginMessageProvider({ provider: queued.run.messageProvider });
|
|
2101
|
+
const origin = resolveOriginMessageProvider({ originatingChannel });
|
|
2102
|
+
if (opts?.onBlockReply && origin && origin === provider) await opts.onBlockReply(payload);
|
|
2103
|
+
}
|
|
2104
|
+
} else if (opts?.onBlockReply) await opts.onBlockReply(payload);
|
|
2105
|
+
}
|
|
2106
|
+
};
|
|
2107
|
+
return async (queued) => {
|
|
2108
|
+
queued.run.config = await resolveQueuedReplyExecutionConfig(queued.run.config);
|
|
2109
|
+
const replySessionKey = queued.run.sessionKey ?? sessionKey;
|
|
2110
|
+
const runtimeConfig = resolveQueuedReplyRuntimeConfig(queued.run.config);
|
|
2111
|
+
const effectiveQueued = runtimeConfig === queued.run.config ? queued : {
|
|
2112
|
+
...queued,
|
|
2113
|
+
run: {
|
|
2114
|
+
...queued.run,
|
|
2115
|
+
config: runtimeConfig
|
|
2116
|
+
}
|
|
2117
|
+
};
|
|
2118
|
+
const run = effectiveQueued.run;
|
|
2119
|
+
const replyOperation = createReplyOperation({
|
|
2120
|
+
sessionId: run.sessionId,
|
|
2121
|
+
sessionKey: replySessionKey ?? "",
|
|
2122
|
+
resetTriggered: false,
|
|
2123
|
+
upstreamAbortSignal: opts?.abortSignal
|
|
2124
|
+
});
|
|
2125
|
+
try {
|
|
2126
|
+
const runId = crypto.randomUUID();
|
|
2127
|
+
const shouldSurfaceToControlUi = isInternalMessageChannel(resolveOriginMessageProvider({
|
|
2128
|
+
originatingChannel: queued.originatingChannel,
|
|
2129
|
+
provider: run.messageProvider
|
|
2130
|
+
}));
|
|
2131
|
+
if (run.sessionKey) registerAgentRunContext(runId, {
|
|
2132
|
+
sessionKey: run.sessionKey,
|
|
2133
|
+
verboseLevel: run.verboseLevel,
|
|
2134
|
+
isControlUiVisible: shouldSurfaceToControlUi
|
|
2135
|
+
});
|
|
2136
|
+
let autoCompactionCount = 0;
|
|
2137
|
+
let runResult;
|
|
2138
|
+
let fallbackProvider = run.provider;
|
|
2139
|
+
let fallbackModel = run.model;
|
|
2140
|
+
let activeSessionEntry = (sessionKey ? sessionStore?.[sessionKey] : void 0) ?? sessionEntry;
|
|
2141
|
+
activeSessionEntry = await runPreflightCompactionIfNeeded({
|
|
2142
|
+
cfg: runtimeConfig,
|
|
2143
|
+
followupRun: effectiveQueued,
|
|
2144
|
+
promptForEstimate: queued.prompt,
|
|
2145
|
+
defaultModel,
|
|
2146
|
+
agentCfgContextTokens,
|
|
2147
|
+
sessionEntry: activeSessionEntry,
|
|
2148
|
+
sessionStore,
|
|
2149
|
+
sessionKey,
|
|
2150
|
+
storePath,
|
|
2151
|
+
isHeartbeat: opts?.isHeartbeat === true,
|
|
2152
|
+
replyOperation
|
|
2153
|
+
});
|
|
2154
|
+
let bootstrapPromptWarningSignaturesSeen = resolveBootstrapWarningSignaturesSeen(activeSessionEntry?.systemPromptReport);
|
|
2155
|
+
replyOperation.setPhase("running");
|
|
2156
|
+
try {
|
|
2157
|
+
const fallbackResult = await runWithModelFallback({
|
|
2158
|
+
cfg: runtimeConfig,
|
|
2159
|
+
provider: run.provider,
|
|
2160
|
+
model: run.model,
|
|
2161
|
+
runId,
|
|
2162
|
+
agentDir: run.agentDir,
|
|
2163
|
+
fallbacksOverride: resolveRunModelFallbacksOverride({
|
|
2164
|
+
cfg: runtimeConfig,
|
|
2165
|
+
agentId: run.agentId,
|
|
2166
|
+
sessionKey: run.sessionKey
|
|
2167
|
+
}),
|
|
2168
|
+
run: async (provider, model, runOptions) => {
|
|
2169
|
+
const authProfile = resolveRunAuthProfile(run, provider);
|
|
2170
|
+
let attemptCompactionCount = 0;
|
|
2171
|
+
try {
|
|
2172
|
+
const result = await runEmbeddedPiAgent({
|
|
2173
|
+
allowGatewaySubagentBinding: true,
|
|
2174
|
+
replyOperation,
|
|
2175
|
+
sessionId: run.sessionId,
|
|
2176
|
+
sessionKey: run.sessionKey,
|
|
2177
|
+
agentId: run.agentId,
|
|
2178
|
+
trigger: "user",
|
|
2179
|
+
messageChannel: queued.originatingChannel ?? void 0,
|
|
2180
|
+
messageProvider: run.messageProvider,
|
|
2181
|
+
agentAccountId: run.agentAccountId,
|
|
2182
|
+
messageTo: queued.originatingTo,
|
|
2183
|
+
messageThreadId: queued.originatingThreadId,
|
|
2184
|
+
currentChannelId: queued.originatingTo,
|
|
2185
|
+
currentThreadTs: queued.originatingThreadId != null ? String(queued.originatingThreadId) : void 0,
|
|
2186
|
+
groupId: run.groupId,
|
|
2187
|
+
groupChannel: run.groupChannel,
|
|
2188
|
+
groupSpace: run.groupSpace,
|
|
2189
|
+
senderId: run.senderId,
|
|
2190
|
+
senderName: run.senderName,
|
|
2191
|
+
senderUsername: run.senderUsername,
|
|
2192
|
+
senderE164: run.senderE164,
|
|
2193
|
+
senderIsOwner: run.senderIsOwner,
|
|
2194
|
+
sessionFile: run.sessionFile,
|
|
2195
|
+
agentDir: run.agentDir,
|
|
2196
|
+
workspaceDir: run.workspaceDir,
|
|
2197
|
+
config: runtimeConfig,
|
|
2198
|
+
skillsSnapshot: run.skillsSnapshot,
|
|
2199
|
+
prompt: queued.prompt,
|
|
2200
|
+
extraSystemPrompt: run.extraSystemPrompt,
|
|
2201
|
+
ownerNumbers: run.ownerNumbers,
|
|
2202
|
+
enforceFinalTag: run.enforceFinalTag,
|
|
2203
|
+
provider,
|
|
2204
|
+
model,
|
|
2205
|
+
...authProfile,
|
|
2206
|
+
thinkLevel: run.thinkLevel,
|
|
2207
|
+
verboseLevel: run.verboseLevel,
|
|
2208
|
+
reasoningLevel: run.reasoningLevel,
|
|
2209
|
+
suppressToolErrorWarnings: opts?.suppressToolErrorWarnings,
|
|
2210
|
+
execOverrides: run.execOverrides,
|
|
2211
|
+
bashElevated: run.bashElevated,
|
|
2212
|
+
timeoutMs: run.timeoutMs,
|
|
2213
|
+
runId,
|
|
2214
|
+
allowTransientCooldownProbe: runOptions?.allowTransientCooldownProbe,
|
|
2215
|
+
blockReplyBreak: run.blockReplyBreak,
|
|
2216
|
+
bootstrapPromptWarningSignaturesSeen,
|
|
2217
|
+
bootstrapPromptWarningSignature: bootstrapPromptWarningSignaturesSeen[bootstrapPromptWarningSignaturesSeen.length - 1],
|
|
2218
|
+
onAgentEvent: (evt) => {
|
|
2219
|
+
if (evt.stream !== "compaction") return;
|
|
2220
|
+
const phase = typeof evt.data.phase === "string" ? evt.data.phase : "";
|
|
2221
|
+
const completed = evt.data?.completed === true;
|
|
2222
|
+
if (phase === "end" && completed) attemptCompactionCount += 1;
|
|
2223
|
+
}
|
|
2224
|
+
});
|
|
2225
|
+
bootstrapPromptWarningSignaturesSeen = resolveBootstrapWarningSignaturesSeen(result.meta?.systemPromptReport);
|
|
2226
|
+
const resultCompactionCount = Math.max(0, result.meta?.agentMeta?.compactionCount ?? 0);
|
|
2227
|
+
attemptCompactionCount = Math.max(attemptCompactionCount, resultCompactionCount);
|
|
2228
|
+
return result;
|
|
2229
|
+
} finally {
|
|
2230
|
+
autoCompactionCount += attemptCompactionCount;
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
runResult = fallbackResult.result;
|
|
2235
|
+
fallbackProvider = fallbackResult.provider;
|
|
2236
|
+
fallbackModel = fallbackResult.model;
|
|
2237
|
+
} catch (err) {
|
|
2238
|
+
const message = formatErrorMessage(err);
|
|
2239
|
+
replyOperation.fail("run_failed", err);
|
|
2240
|
+
defaultRuntime.error?.(`Followup agent failed before reply: ${message}`);
|
|
2241
|
+
return;
|
|
2242
|
+
}
|
|
2243
|
+
const usage = runResult.meta?.agentMeta?.usage;
|
|
2244
|
+
const promptTokens = runResult.meta?.agentMeta?.promptTokens;
|
|
2245
|
+
const modelUsed = runResult.meta?.agentMeta?.model ?? fallbackModel ?? defaultModel;
|
|
2246
|
+
const providerUsed = runResult.meta?.agentMeta?.provider ?? fallbackProvider ?? queued.run.provider;
|
|
2247
|
+
const contextTokensUsed = resolveContextTokensForModel({
|
|
2248
|
+
cfg: queued.run.config,
|
|
2249
|
+
provider: providerUsed,
|
|
2250
|
+
model: modelUsed,
|
|
2251
|
+
contextTokensOverride: agentCfgContextTokens,
|
|
2252
|
+
fallbackContextTokens: sessionEntry?.contextTokens ?? 2e5,
|
|
2253
|
+
allowAsyncLoad: false
|
|
2254
|
+
}) ?? 2e5;
|
|
2255
|
+
if (storePath && sessionKey) await persistRunSessionUsage({
|
|
2256
|
+
storePath,
|
|
2257
|
+
sessionKey,
|
|
2258
|
+
cfg: runtimeConfig,
|
|
2259
|
+
usage,
|
|
2260
|
+
lastCallUsage: runResult.meta?.agentMeta?.lastCallUsage,
|
|
2261
|
+
promptTokens,
|
|
2262
|
+
modelUsed,
|
|
2263
|
+
providerUsed,
|
|
2264
|
+
contextTokensUsed,
|
|
2265
|
+
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
2266
|
+
cliSessionBinding: runResult.meta?.agentMeta?.cliSessionBinding,
|
|
2267
|
+
usageIsContextSnapshot: isCliProvider(providerUsed, runtimeConfig),
|
|
2268
|
+
logLabel: "followup"
|
|
2269
|
+
});
|
|
2270
|
+
const payloadArray = runResult.payloads ?? [];
|
|
2271
|
+
if (payloadArray.length === 0) return;
|
|
2272
|
+
const finalPayloads = resolveFollowupDeliveryPayloads({
|
|
2273
|
+
cfg: runtimeConfig,
|
|
2274
|
+
payloads: payloadArray.flatMap((payload) => {
|
|
2275
|
+
const text = payload.text;
|
|
2276
|
+
if (!text || !text.includes("HEARTBEAT_OK")) return [payload];
|
|
2277
|
+
const stripped = stripHeartbeatToken(text, { mode: "message" });
|
|
2278
|
+
const hasMedia = resolveSendableOutboundReplyParts(payload).hasMedia;
|
|
2279
|
+
if (stripped.shouldSkip && !hasMedia) return [];
|
|
2280
|
+
return [{
|
|
2281
|
+
...payload,
|
|
2282
|
+
text: stripped.text
|
|
2283
|
+
}];
|
|
2284
|
+
}),
|
|
2285
|
+
messageProvider: run.messageProvider,
|
|
2286
|
+
originatingAccountId: queued.originatingAccountId ?? run.agentAccountId,
|
|
2287
|
+
originatingChannel: queued.originatingChannel,
|
|
2288
|
+
originatingChatType: queued.originatingChatType,
|
|
2289
|
+
originatingTo: queued.originatingTo,
|
|
2290
|
+
sentMediaUrls: runResult.messagingToolSentMediaUrls,
|
|
2291
|
+
sentTargets: runResult.messagingToolSentTargets,
|
|
2292
|
+
sentTexts: runResult.messagingToolSentTexts
|
|
2293
|
+
});
|
|
2294
|
+
if (finalPayloads.length === 0) return;
|
|
2295
|
+
if (autoCompactionCount > 0) {
|
|
2296
|
+
const previousSessionId = run.sessionId;
|
|
2297
|
+
const count = await incrementRunCompactionCount({
|
|
2298
|
+
cfg: runtimeConfig,
|
|
2299
|
+
sessionEntry,
|
|
2300
|
+
sessionStore,
|
|
2301
|
+
sessionKey,
|
|
2302
|
+
storePath,
|
|
2303
|
+
amount: autoCompactionCount,
|
|
2304
|
+
lastCallUsage: runResult.meta?.agentMeta?.lastCallUsage,
|
|
2305
|
+
contextTokensUsed,
|
|
2306
|
+
newSessionId: runResult.meta?.agentMeta?.sessionId
|
|
2307
|
+
});
|
|
2308
|
+
const refreshedSessionEntry = sessionKey && sessionStore ? sessionStore[sessionKey] : void 0;
|
|
2309
|
+
if (refreshedSessionEntry) {
|
|
2310
|
+
const queueKey = run.sessionKey ?? sessionKey;
|
|
2311
|
+
if (queueKey) refreshQueuedFollowupSession({
|
|
2312
|
+
key: queueKey,
|
|
2313
|
+
previousSessionId,
|
|
2314
|
+
nextSessionId: refreshedSessionEntry.sessionId,
|
|
2315
|
+
nextSessionFile: refreshedSessionEntry.sessionFile
|
|
2316
|
+
});
|
|
2317
|
+
}
|
|
2318
|
+
if (run.verboseLevel && run.verboseLevel !== "off") {
|
|
2319
|
+
const suffix = typeof count === "number" ? ` (count ${count})` : "";
|
|
2320
|
+
finalPayloads.unshift({ text: `🧹 Auto-compaction complete${suffix}.` });
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
await sendFollowupPayloads(finalPayloads, effectiveQueued);
|
|
2324
|
+
} finally {
|
|
2325
|
+
replyOperation.complete();
|
|
2326
|
+
typing.markRunComplete();
|
|
2327
|
+
typing.markDispatchIdle();
|
|
2328
|
+
}
|
|
2329
|
+
};
|
|
2330
|
+
}
|
|
2331
|
+
//#endregion
|
|
2332
|
+
//#region src/auto-reply/reply/agent-runner.ts
|
|
2333
|
+
const BLOCK_REPLY_SEND_TIMEOUT_MS = 15e3;
|
|
2334
|
+
async function runReplyAgent(params) {
|
|
2335
|
+
const { commandBody, followupRun, queueKey, resolvedQueue, shouldSteer, shouldFollowup, isActive, isRunActive, isStreaming, opts, typing, sessionEntry, sessionStore, sessionKey, storePath, defaultModel, agentCfgContextTokens, resolvedVerboseLevel, isNewSession, blockStreamingEnabled, blockReplyChunking, resolvedBlockStreamingBreak, sessionCtx, shouldInjectGroupIntro, typingMode, resetTriggered, replyOperation: providedReplyOperation } = params;
|
|
2336
|
+
let activeSessionEntry = sessionEntry;
|
|
2337
|
+
const activeSessionStore = sessionStore;
|
|
2338
|
+
let activeIsNewSession = isNewSession;
|
|
2339
|
+
const isHeartbeat = opts?.isHeartbeat === true;
|
|
2340
|
+
const typingSignals = createTypingSignaler({
|
|
2341
|
+
typing,
|
|
2342
|
+
mode: typingMode,
|
|
2343
|
+
isHeartbeat
|
|
2344
|
+
});
|
|
2345
|
+
const shouldEmitToolResult = createShouldEmitToolResult({
|
|
2346
|
+
sessionKey,
|
|
2347
|
+
storePath,
|
|
2348
|
+
resolvedVerboseLevel
|
|
2349
|
+
});
|
|
2350
|
+
const shouldEmitToolOutput = createShouldEmitToolOutput({
|
|
2351
|
+
sessionKey,
|
|
2352
|
+
storePath,
|
|
2353
|
+
resolvedVerboseLevel
|
|
2354
|
+
});
|
|
2355
|
+
const pendingToolTasks = /* @__PURE__ */ new Set();
|
|
2356
|
+
const blockReplyTimeoutMs = opts?.blockReplyTimeoutMs ?? BLOCK_REPLY_SEND_TIMEOUT_MS;
|
|
2357
|
+
const touchActiveSessionEntry = async () => {
|
|
2358
|
+
if (!activeSessionEntry || !activeSessionStore || !sessionKey) return;
|
|
2359
|
+
const updatedAt = Date.now();
|
|
2360
|
+
activeSessionEntry.updatedAt = updatedAt;
|
|
2361
|
+
activeSessionStore[sessionKey] = activeSessionEntry;
|
|
2362
|
+
if (storePath) await updateSessionStoreEntry({
|
|
2363
|
+
storePath,
|
|
2364
|
+
sessionKey,
|
|
2365
|
+
update: async () => ({ updatedAt })
|
|
2366
|
+
});
|
|
2367
|
+
};
|
|
2368
|
+
if (shouldSteer && isStreaming) {
|
|
2369
|
+
if (queueEmbeddedPiMessage((sessionKey ? replyRunRegistry.resolveSessionId(sessionKey) : void 0) ?? followupRun.run.sessionId, followupRun.prompt) && !shouldFollowup) {
|
|
2370
|
+
await touchActiveSessionEntry();
|
|
2371
|
+
typing.cleanup();
|
|
2372
|
+
return;
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
const activeRunQueueAction = resolveActiveRunQueueAction({
|
|
2376
|
+
isActive,
|
|
2377
|
+
isHeartbeat,
|
|
2378
|
+
shouldFollowup,
|
|
2379
|
+
queueMode: resolvedQueue.mode
|
|
2380
|
+
});
|
|
2381
|
+
const queuedRunFollowupTurn = createFollowupRunner({
|
|
2382
|
+
opts,
|
|
2383
|
+
typing,
|
|
2384
|
+
typingMode,
|
|
2385
|
+
sessionEntry: activeSessionEntry,
|
|
2386
|
+
sessionStore: activeSessionStore,
|
|
2387
|
+
sessionKey,
|
|
2388
|
+
storePath,
|
|
2389
|
+
defaultModel,
|
|
2390
|
+
agentCfgContextTokens
|
|
2391
|
+
});
|
|
2392
|
+
if (activeRunQueueAction === "drop") {
|
|
2393
|
+
typing.cleanup();
|
|
2394
|
+
return;
|
|
2395
|
+
}
|
|
2396
|
+
if (activeRunQueueAction === "enqueue-followup") {
|
|
2397
|
+
enqueueFollowupRun(queueKey, followupRun, resolvedQueue, "message-id", queuedRunFollowupTurn, false);
|
|
2398
|
+
if (!isRunActive?.()) finalizeWithFollowup(void 0, queueKey, queuedRunFollowupTurn);
|
|
2399
|
+
await touchActiveSessionEntry();
|
|
2400
|
+
typing.cleanup();
|
|
2401
|
+
return;
|
|
2402
|
+
}
|
|
2403
|
+
followupRun.run.config = await resolveQueuedReplyExecutionConfig(followupRun.run.config);
|
|
2404
|
+
const replyToChannel = resolveOriginMessageProvider({
|
|
2405
|
+
originatingChannel: sessionCtx.OriginatingChannel,
|
|
2406
|
+
provider: sessionCtx.Surface ?? sessionCtx.Provider
|
|
2407
|
+
});
|
|
2408
|
+
const replyToMode = resolveReplyToMode(followupRun.run.config, replyToChannel, sessionCtx.AccountId, sessionCtx.ChatType);
|
|
2409
|
+
const applyReplyToMode = createReplyToModeFilterForChannel(replyToMode, replyToChannel);
|
|
2410
|
+
const cfg = followupRun.run.config;
|
|
2411
|
+
const normalizeReplyMediaPaths = createReplyMediaPathNormalizer({
|
|
2412
|
+
cfg,
|
|
2413
|
+
sessionKey,
|
|
2414
|
+
workspaceDir: followupRun.run.workspaceDir
|
|
2415
|
+
});
|
|
2416
|
+
const blockReplyCoalescing = blockStreamingEnabled && opts?.onBlockReply ? resolveEffectiveBlockStreamingConfig({
|
|
2417
|
+
cfg,
|
|
2418
|
+
provider: sessionCtx.Provider,
|
|
2419
|
+
accountId: sessionCtx.AccountId,
|
|
2420
|
+
chunking: blockReplyChunking
|
|
2421
|
+
}).coalescing : void 0;
|
|
2422
|
+
const blockReplyPipeline = blockStreamingEnabled && opts?.onBlockReply ? createBlockReplyPipeline({
|
|
2423
|
+
onBlockReply: opts.onBlockReply,
|
|
2424
|
+
timeoutMs: blockReplyTimeoutMs,
|
|
2425
|
+
coalescing: blockReplyCoalescing,
|
|
2426
|
+
buffer: createAudioAsVoiceBuffer({ isAudioPayload })
|
|
2427
|
+
}) : null;
|
|
2428
|
+
const replySessionKey = sessionKey ?? followupRun.run.sessionKey;
|
|
2429
|
+
let replyOperation;
|
|
2430
|
+
try {
|
|
2431
|
+
replyOperation = providedReplyOperation ?? createReplyOperation({
|
|
2432
|
+
sessionId: followupRun.run.sessionId,
|
|
2433
|
+
sessionKey: replySessionKey ?? "",
|
|
2434
|
+
resetTriggered: resetTriggered === true,
|
|
2435
|
+
upstreamAbortSignal: opts?.abortSignal
|
|
2436
|
+
});
|
|
2437
|
+
} catch (error) {
|
|
2438
|
+
if (error instanceof ReplyRunAlreadyActiveError) {
|
|
2439
|
+
typing.cleanup();
|
|
2440
|
+
return { text: "⚠️ Previous run is still shutting down. Please try again in a moment." };
|
|
2441
|
+
}
|
|
2442
|
+
throw error;
|
|
2443
|
+
}
|
|
2444
|
+
let runFollowupTurn = queuedRunFollowupTurn;
|
|
2445
|
+
try {
|
|
2446
|
+
await typingSignals.signalRunStart();
|
|
2447
|
+
activeSessionEntry = await runPreflightCompactionIfNeeded({
|
|
2448
|
+
cfg,
|
|
2449
|
+
followupRun,
|
|
2450
|
+
promptForEstimate: followupRun.prompt,
|
|
2451
|
+
defaultModel,
|
|
2452
|
+
agentCfgContextTokens,
|
|
2453
|
+
sessionEntry: activeSessionEntry,
|
|
2454
|
+
sessionStore: activeSessionStore,
|
|
2455
|
+
sessionKey,
|
|
2456
|
+
storePath,
|
|
2457
|
+
isHeartbeat,
|
|
2458
|
+
replyOperation
|
|
2459
|
+
});
|
|
2460
|
+
activeSessionEntry = await runMemoryFlushIfNeeded({
|
|
2461
|
+
cfg,
|
|
2462
|
+
followupRun,
|
|
2463
|
+
promptForEstimate: followupRun.prompt,
|
|
2464
|
+
sessionCtx,
|
|
2465
|
+
opts,
|
|
2466
|
+
defaultModel,
|
|
2467
|
+
agentCfgContextTokens,
|
|
2468
|
+
resolvedVerboseLevel,
|
|
2469
|
+
sessionEntry: activeSessionEntry,
|
|
2470
|
+
sessionStore: activeSessionStore,
|
|
2471
|
+
sessionKey,
|
|
2472
|
+
storePath,
|
|
2473
|
+
isHeartbeat,
|
|
2474
|
+
replyOperation
|
|
2475
|
+
});
|
|
2476
|
+
runFollowupTurn = createFollowupRunner({
|
|
2477
|
+
opts,
|
|
2478
|
+
typing,
|
|
2479
|
+
typingMode,
|
|
2480
|
+
sessionEntry: activeSessionEntry,
|
|
2481
|
+
sessionStore: activeSessionStore,
|
|
2482
|
+
sessionKey,
|
|
2483
|
+
storePath,
|
|
2484
|
+
defaultModel,
|
|
2485
|
+
agentCfgContextTokens
|
|
2486
|
+
});
|
|
2487
|
+
let responseUsageLine;
|
|
2488
|
+
const resetSession = async ({ failureLabel, buildLogMessage, cleanupTranscripts }) => await resetReplyRunSession({
|
|
2489
|
+
options: {
|
|
2490
|
+
failureLabel,
|
|
2491
|
+
buildLogMessage,
|
|
2492
|
+
cleanupTranscripts
|
|
2493
|
+
},
|
|
2494
|
+
sessionKey,
|
|
2495
|
+
queueKey,
|
|
2496
|
+
activeSessionEntry,
|
|
2497
|
+
activeSessionStore,
|
|
2498
|
+
storePath,
|
|
2499
|
+
messageThreadId: typeof sessionCtx.MessageThreadId === "string" ? sessionCtx.MessageThreadId : void 0,
|
|
2500
|
+
followupRun,
|
|
2501
|
+
onActiveSessionEntry: (nextEntry) => {
|
|
2502
|
+
activeSessionEntry = nextEntry;
|
|
2503
|
+
},
|
|
2504
|
+
onNewSession: () => {
|
|
2505
|
+
activeIsNewSession = true;
|
|
2506
|
+
}
|
|
2507
|
+
});
|
|
2508
|
+
const resetSessionAfterCompactionFailure = async (reason) => resetSession({
|
|
2509
|
+
failureLabel: "compaction failure",
|
|
2510
|
+
buildLogMessage: (nextSessionId) => `Auto-compaction failed (${reason}). Restarting session ${sessionKey} -> ${nextSessionId} and retrying.`
|
|
2511
|
+
});
|
|
2512
|
+
const resetSessionAfterRoleOrderingConflict = async (reason) => resetSession({
|
|
2513
|
+
failureLabel: "role ordering conflict",
|
|
2514
|
+
buildLogMessage: (nextSessionId) => `Role ordering conflict (${reason}). Restarting session ${sessionKey} -> ${nextSessionId}.`,
|
|
2515
|
+
cleanupTranscripts: true
|
|
2516
|
+
});
|
|
2517
|
+
replyOperation.setPhase("running");
|
|
2518
|
+
const runStartedAt = Date.now();
|
|
2519
|
+
const runOutcome = await runAgentTurnWithFallback({
|
|
2520
|
+
commandBody,
|
|
2521
|
+
followupRun,
|
|
2522
|
+
sessionCtx,
|
|
2523
|
+
replyOperation,
|
|
2524
|
+
opts,
|
|
2525
|
+
typingSignals,
|
|
2526
|
+
blockReplyPipeline,
|
|
2527
|
+
blockStreamingEnabled,
|
|
2528
|
+
blockReplyChunking,
|
|
2529
|
+
resolvedBlockStreamingBreak,
|
|
2530
|
+
applyReplyToMode,
|
|
2531
|
+
shouldEmitToolResult,
|
|
2532
|
+
shouldEmitToolOutput,
|
|
2533
|
+
pendingToolTasks,
|
|
2534
|
+
resetSessionAfterCompactionFailure,
|
|
2535
|
+
resetSessionAfterRoleOrderingConflict,
|
|
2536
|
+
isHeartbeat,
|
|
2537
|
+
sessionKey,
|
|
2538
|
+
getActiveSessionEntry: () => activeSessionEntry,
|
|
2539
|
+
activeSessionStore,
|
|
2540
|
+
storePath,
|
|
2541
|
+
resolvedVerboseLevel
|
|
2542
|
+
});
|
|
2543
|
+
if (runOutcome.kind === "final") {
|
|
2544
|
+
if (!replyOperation.result) replyOperation.fail("run_failed", /* @__PURE__ */ new Error("reply operation exited with final payload"));
|
|
2545
|
+
return finalizeWithFollowup(runOutcome.payload, queueKey, runFollowupTurn);
|
|
2546
|
+
}
|
|
2547
|
+
const { runId, runResult, fallbackProvider, fallbackModel, fallbackAttempts, directlySentBlockKeys } = runOutcome;
|
|
2548
|
+
let { didLogHeartbeatStrip, autoCompactionCount } = runOutcome;
|
|
2549
|
+
if (shouldInjectGroupIntro && activeSessionEntry && activeSessionStore && sessionKey && activeSessionEntry.groupActivationNeedsSystemIntro) {
|
|
2550
|
+
const updatedAt = Date.now();
|
|
2551
|
+
activeSessionEntry.groupActivationNeedsSystemIntro = false;
|
|
2552
|
+
activeSessionEntry.updatedAt = updatedAt;
|
|
2553
|
+
activeSessionStore[sessionKey] = activeSessionEntry;
|
|
2554
|
+
if (storePath) await updateSessionStoreEntry({
|
|
2555
|
+
storePath,
|
|
2556
|
+
sessionKey,
|
|
2557
|
+
update: async () => ({
|
|
2558
|
+
groupActivationNeedsSystemIntro: false,
|
|
2559
|
+
updatedAt
|
|
2560
|
+
})
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
const payloadArray = runResult.payloads ?? [];
|
|
2564
|
+
if (blockReplyPipeline) {
|
|
2565
|
+
await blockReplyPipeline.flush({ force: true });
|
|
2566
|
+
blockReplyPipeline.stop();
|
|
2567
|
+
}
|
|
2568
|
+
if (pendingToolTasks.size > 0) await Promise.allSettled(pendingToolTasks);
|
|
2569
|
+
const usage = runResult.meta?.agentMeta?.usage;
|
|
2570
|
+
const promptTokens = runResult.meta?.agentMeta?.promptTokens;
|
|
2571
|
+
const modelUsed = runResult.meta?.agentMeta?.model ?? fallbackModel ?? defaultModel;
|
|
2572
|
+
const providerUsed = runResult.meta?.agentMeta?.provider ?? fallbackProvider ?? followupRun.run.provider;
|
|
2573
|
+
const verboseEnabled = resolvedVerboseLevel !== "off";
|
|
2574
|
+
const selectedProvider = followupRun.run.provider;
|
|
2575
|
+
const selectedModel = followupRun.run.model;
|
|
2576
|
+
const fallbackStateEntry = activeSessionEntry ?? (sessionKey ? activeSessionStore?.[sessionKey] : void 0);
|
|
2577
|
+
const fallbackTransition = resolveFallbackTransition({
|
|
2578
|
+
selectedProvider,
|
|
2579
|
+
selectedModel,
|
|
2580
|
+
activeProvider: providerUsed,
|
|
2581
|
+
activeModel: modelUsed,
|
|
2582
|
+
attempts: fallbackAttempts,
|
|
2583
|
+
state: fallbackStateEntry
|
|
2584
|
+
});
|
|
2585
|
+
if (fallbackTransition.stateChanged) {
|
|
2586
|
+
if (fallbackStateEntry) {
|
|
2587
|
+
fallbackStateEntry.fallbackNoticeSelectedModel = fallbackTransition.nextState.selectedModel;
|
|
2588
|
+
fallbackStateEntry.fallbackNoticeActiveModel = fallbackTransition.nextState.activeModel;
|
|
2589
|
+
fallbackStateEntry.fallbackNoticeReason = fallbackTransition.nextState.reason;
|
|
2590
|
+
fallbackStateEntry.updatedAt = Date.now();
|
|
2591
|
+
activeSessionEntry = fallbackStateEntry;
|
|
2592
|
+
}
|
|
2593
|
+
if (sessionKey && fallbackStateEntry && activeSessionStore) activeSessionStore[sessionKey] = fallbackStateEntry;
|
|
2594
|
+
if (sessionKey && storePath) await updateSessionStoreEntry({
|
|
2595
|
+
storePath,
|
|
2596
|
+
sessionKey,
|
|
2597
|
+
update: async () => ({
|
|
2598
|
+
fallbackNoticeSelectedModel: fallbackTransition.nextState.selectedModel,
|
|
2599
|
+
fallbackNoticeActiveModel: fallbackTransition.nextState.activeModel,
|
|
2600
|
+
fallbackNoticeReason: fallbackTransition.nextState.reason
|
|
2601
|
+
})
|
|
2602
|
+
});
|
|
2603
|
+
}
|
|
2604
|
+
const cliSessionId = isCliProvider(providerUsed, cfg) ? normalizeOptionalString(runResult.meta?.agentMeta?.sessionId) : void 0;
|
|
2605
|
+
const cliSessionBinding = isCliProvider(providerUsed, cfg) ? runResult.meta?.agentMeta?.cliSessionBinding : void 0;
|
|
2606
|
+
const contextTokensUsed = resolveContextTokensForModel({
|
|
2607
|
+
cfg,
|
|
2608
|
+
provider: providerUsed,
|
|
2609
|
+
model: modelUsed,
|
|
2610
|
+
contextTokensOverride: agentCfgContextTokens,
|
|
2611
|
+
fallbackContextTokens: activeSessionEntry?.contextTokens ?? 2e5,
|
|
2612
|
+
allowAsyncLoad: false
|
|
2613
|
+
}) ?? 2e5;
|
|
2614
|
+
await persistRunSessionUsage({
|
|
2615
|
+
storePath,
|
|
2616
|
+
sessionKey,
|
|
2617
|
+
cfg,
|
|
2618
|
+
usage,
|
|
2619
|
+
lastCallUsage: runResult.meta?.agentMeta?.lastCallUsage,
|
|
2620
|
+
promptTokens,
|
|
2621
|
+
modelUsed,
|
|
2622
|
+
providerUsed,
|
|
2623
|
+
contextTokensUsed,
|
|
2624
|
+
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
2625
|
+
cliSessionId,
|
|
2626
|
+
cliSessionBinding,
|
|
2627
|
+
usageIsContextSnapshot: isCliProvider(providerUsed, cfg)
|
|
2628
|
+
});
|
|
2629
|
+
if (payloadArray.length === 0) return finalizeWithFollowup(void 0, queueKey, runFollowupTurn);
|
|
2630
|
+
const payloadResult = await buildReplyPayloads({
|
|
2631
|
+
payloads: payloadArray,
|
|
2632
|
+
isHeartbeat,
|
|
2633
|
+
didLogHeartbeatStrip,
|
|
2634
|
+
silentExpected: followupRun.run.silentExpected,
|
|
2635
|
+
blockStreamingEnabled,
|
|
2636
|
+
blockReplyPipeline,
|
|
2637
|
+
directlySentBlockKeys,
|
|
2638
|
+
replyToMode,
|
|
2639
|
+
replyToChannel,
|
|
2640
|
+
currentMessageId: sessionCtx.MessageSidFull ?? sessionCtx.MessageSid,
|
|
2641
|
+
replyThreading: sessionCtx.ReplyThreading,
|
|
2642
|
+
messageProvider: followupRun.run.messageProvider,
|
|
2643
|
+
messagingToolSentTexts: runResult.messagingToolSentTexts,
|
|
2644
|
+
messagingToolSentMediaUrls: runResult.messagingToolSentMediaUrls,
|
|
2645
|
+
messagingToolSentTargets: runResult.messagingToolSentTargets,
|
|
2646
|
+
originatingChannel: sessionCtx.OriginatingChannel,
|
|
2647
|
+
originatingTo: resolveOriginMessageTo({
|
|
2648
|
+
originatingTo: sessionCtx.OriginatingTo,
|
|
2649
|
+
to: sessionCtx.To
|
|
2650
|
+
}),
|
|
2651
|
+
accountId: sessionCtx.AccountId,
|
|
2652
|
+
normalizeMediaPaths: normalizeReplyMediaPaths
|
|
2653
|
+
});
|
|
2654
|
+
const { replyPayloads } = payloadResult;
|
|
2655
|
+
didLogHeartbeatStrip = payloadResult.didLogHeartbeatStrip;
|
|
2656
|
+
if (replyPayloads.length === 0) return finalizeWithFollowup(void 0, queueKey, runFollowupTurn);
|
|
2657
|
+
const successfulCronAdds = runResult.successfulCronAdds ?? 0;
|
|
2658
|
+
const hasReminderCommitment = replyPayloads.some((payload) => !payload.isError && typeof payload.text === "string" && hasUnbackedReminderCommitment(payload.text));
|
|
2659
|
+
const coveredByExistingCron = hasReminderCommitment && successfulCronAdds === 0 ? await hasSessionRelatedCronJobs({
|
|
2660
|
+
cronStorePath: cfg.cron?.store,
|
|
2661
|
+
sessionKey
|
|
2662
|
+
}) : false;
|
|
2663
|
+
const guardedReplyPayloads = hasReminderCommitment && successfulCronAdds === 0 && !coveredByExistingCron ? appendUnscheduledReminderNote(replyPayloads) : replyPayloads;
|
|
2664
|
+
await signalTypingIfNeeded(guardedReplyPayloads, typingSignals);
|
|
2665
|
+
if (isDiagnosticsEnabled(cfg) && hasNonzeroUsage(usage)) {
|
|
2666
|
+
const input = usage.input ?? 0;
|
|
2667
|
+
const output = usage.output ?? 0;
|
|
2668
|
+
const cacheRead = usage.cacheRead ?? 0;
|
|
2669
|
+
const cacheWrite = usage.cacheWrite ?? 0;
|
|
2670
|
+
const promptTokens = input + cacheRead + cacheWrite;
|
|
2671
|
+
const totalTokens = usage.total ?? promptTokens + output;
|
|
2672
|
+
const costUsd = estimateUsageCost({
|
|
2673
|
+
usage,
|
|
2674
|
+
cost: resolveModelCostConfig({
|
|
2675
|
+
provider: providerUsed,
|
|
2676
|
+
model: modelUsed,
|
|
2677
|
+
config: cfg
|
|
2678
|
+
})
|
|
2679
|
+
});
|
|
2680
|
+
emitDiagnosticEvent({
|
|
2681
|
+
type: "model.usage",
|
|
2682
|
+
sessionKey,
|
|
2683
|
+
sessionId: followupRun.run.sessionId,
|
|
2684
|
+
channel: replyToChannel,
|
|
2685
|
+
provider: providerUsed,
|
|
2686
|
+
model: modelUsed,
|
|
2687
|
+
usage: {
|
|
2688
|
+
input,
|
|
2689
|
+
output,
|
|
2690
|
+
cacheRead,
|
|
2691
|
+
cacheWrite,
|
|
2692
|
+
promptTokens,
|
|
2693
|
+
total: totalTokens
|
|
2694
|
+
},
|
|
2695
|
+
lastCallUsage: runResult.meta?.agentMeta?.lastCallUsage,
|
|
2696
|
+
context: {
|
|
2697
|
+
limit: contextTokensUsed,
|
|
2698
|
+
used: totalTokens
|
|
2699
|
+
},
|
|
2700
|
+
costUsd,
|
|
2701
|
+
durationMs: Date.now() - runStartedAt
|
|
2702
|
+
});
|
|
2703
|
+
}
|
|
2704
|
+
const responseUsageMode = resolveResponseUsageMode(activeSessionEntry?.responseUsage ?? (sessionKey ? activeSessionStore?.[sessionKey]?.responseUsage : void 0));
|
|
2705
|
+
if (responseUsageMode !== "off" && hasNonzeroUsage(usage)) {
|
|
2706
|
+
const showCost = resolveModelAuthMode(providerUsed, cfg) === "api-key";
|
|
2707
|
+
let formatted = formatResponseUsageLine({
|
|
2708
|
+
usage,
|
|
2709
|
+
showCost,
|
|
2710
|
+
costConfig: showCost ? resolveModelCostConfig({
|
|
2711
|
+
provider: providerUsed,
|
|
2712
|
+
model: modelUsed,
|
|
2713
|
+
config: cfg
|
|
2714
|
+
}) : void 0
|
|
2715
|
+
});
|
|
2716
|
+
if (formatted && responseUsageMode === "full" && sessionKey) formatted = `${formatted} · session \`${sessionKey}\``;
|
|
2717
|
+
if (formatted) responseUsageLine = formatted;
|
|
2718
|
+
}
|
|
2719
|
+
let finalPayloads = guardedReplyPayloads;
|
|
2720
|
+
const verboseNotices = [];
|
|
2721
|
+
if (verboseEnabled && activeIsNewSession) verboseNotices.push({ text: `🧭 New session: ${followupRun.run.sessionId}` });
|
|
2722
|
+
if (fallbackTransition.fallbackTransitioned) {
|
|
2723
|
+
emitAgentEvent({
|
|
2724
|
+
runId,
|
|
2725
|
+
sessionKey,
|
|
2726
|
+
stream: "lifecycle",
|
|
2727
|
+
data: {
|
|
2728
|
+
phase: "fallback",
|
|
2729
|
+
selectedProvider,
|
|
2730
|
+
selectedModel,
|
|
2731
|
+
activeProvider: providerUsed,
|
|
2732
|
+
activeModel: modelUsed,
|
|
2733
|
+
reasonSummary: fallbackTransition.reasonSummary,
|
|
2734
|
+
attemptSummaries: fallbackTransition.attemptSummaries,
|
|
2735
|
+
attempts: fallbackAttempts
|
|
2736
|
+
}
|
|
2737
|
+
});
|
|
2738
|
+
if (verboseEnabled) {
|
|
2739
|
+
const fallbackNotice = buildFallbackNotice({
|
|
2740
|
+
selectedProvider,
|
|
2741
|
+
selectedModel,
|
|
2742
|
+
activeProvider: providerUsed,
|
|
2743
|
+
activeModel: modelUsed,
|
|
2744
|
+
attempts: fallbackAttempts
|
|
2745
|
+
});
|
|
2746
|
+
if (fallbackNotice) verboseNotices.push({ text: fallbackNotice });
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
if (fallbackTransition.fallbackCleared) {
|
|
2750
|
+
emitAgentEvent({
|
|
2751
|
+
runId,
|
|
2752
|
+
sessionKey,
|
|
2753
|
+
stream: "lifecycle",
|
|
2754
|
+
data: {
|
|
2755
|
+
phase: "fallback_cleared",
|
|
2756
|
+
selectedProvider,
|
|
2757
|
+
selectedModel,
|
|
2758
|
+
activeProvider: providerUsed,
|
|
2759
|
+
activeModel: modelUsed,
|
|
2760
|
+
previousActiveModel: fallbackTransition.previousState.activeModel
|
|
2761
|
+
}
|
|
2762
|
+
});
|
|
2763
|
+
if (verboseEnabled) verboseNotices.push({ text: buildFallbackClearedNotice({
|
|
2764
|
+
selectedProvider,
|
|
2765
|
+
selectedModel,
|
|
2766
|
+
previousActiveModel: fallbackTransition.previousState.activeModel
|
|
2767
|
+
}) });
|
|
2768
|
+
}
|
|
2769
|
+
if (autoCompactionCount > 0) {
|
|
2770
|
+
const previousSessionId = activeSessionEntry?.sessionId ?? followupRun.run.sessionId;
|
|
2771
|
+
const count = await incrementRunCompactionCount({
|
|
2772
|
+
cfg,
|
|
2773
|
+
sessionEntry: activeSessionEntry,
|
|
2774
|
+
sessionStore: activeSessionStore,
|
|
2775
|
+
sessionKey,
|
|
2776
|
+
storePath,
|
|
2777
|
+
amount: autoCompactionCount,
|
|
2778
|
+
lastCallUsage: runResult.meta?.agentMeta?.lastCallUsage,
|
|
2779
|
+
contextTokensUsed,
|
|
2780
|
+
newSessionId: runResult.meta?.agentMeta?.sessionId
|
|
2781
|
+
});
|
|
2782
|
+
const refreshedSessionEntry = sessionKey && activeSessionStore ? activeSessionStore[sessionKey] : void 0;
|
|
2783
|
+
if (refreshedSessionEntry) {
|
|
2784
|
+
activeSessionEntry = refreshedSessionEntry;
|
|
2785
|
+
refreshQueuedFollowupSession({
|
|
2786
|
+
key: queueKey,
|
|
2787
|
+
previousSessionId,
|
|
2788
|
+
nextSessionId: refreshedSessionEntry.sessionId,
|
|
2789
|
+
nextSessionFile: refreshedSessionEntry.sessionFile
|
|
2790
|
+
});
|
|
2791
|
+
}
|
|
2792
|
+
if (sessionKey) readPostCompactionContext(process.cwd(), cfg).then((contextContent) => {
|
|
2793
|
+
if (contextContent) enqueueSystemEvent(contextContent, { sessionKey });
|
|
2794
|
+
}).catch(() => {});
|
|
2795
|
+
if (verboseEnabled) {
|
|
2796
|
+
const suffix = typeof count === "number" ? ` (count ${count})` : "";
|
|
2797
|
+
verboseNotices.push({ text: `🧹 Auto-compaction complete${suffix}.` });
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
if (verboseNotices.length > 0) finalPayloads = [...verboseNotices, ...finalPayloads];
|
|
2801
|
+
if (responseUsageLine) finalPayloads = appendUsageLine(finalPayloads, responseUsageLine);
|
|
2802
|
+
return finalizeWithFollowup(finalPayloads.length === 1 ? finalPayloads[0] : finalPayloads, queueKey, runFollowupTurn);
|
|
2803
|
+
} catch (error) {
|
|
2804
|
+
if (replyOperation.result?.kind === "aborted" && replyOperation.result.code === "aborted_for_restart") return finalizeWithFollowup({ text: "⚠️ Gateway is restarting. Please wait a few seconds and try again." }, queueKey, runFollowupTurn);
|
|
2805
|
+
if (replyOperation.result?.kind === "aborted") return finalizeWithFollowup({ text: SILENT_REPLY_TOKEN }, queueKey, runFollowupTurn);
|
|
2806
|
+
if (error instanceof GatewayDrainingError) {
|
|
2807
|
+
replyOperation.fail("gateway_draining", error);
|
|
2808
|
+
return finalizeWithFollowup({ text: "⚠️ Gateway is restarting. Please wait a few seconds and try again." }, queueKey, runFollowupTurn);
|
|
2809
|
+
}
|
|
2810
|
+
if (error instanceof CommandLaneClearedError) {
|
|
2811
|
+
replyOperation.fail("command_lane_cleared", error);
|
|
2812
|
+
return finalizeWithFollowup({ text: "⚠️ Gateway is restarting. Please wait a few seconds and try again." }, queueKey, runFollowupTurn);
|
|
2813
|
+
}
|
|
2814
|
+
replyOperation.fail("run_failed", error);
|
|
2815
|
+
finalizeWithFollowup(void 0, queueKey, runFollowupTurn);
|
|
2816
|
+
throw error;
|
|
2817
|
+
} finally {
|
|
2818
|
+
replyOperation.complete();
|
|
2819
|
+
blockReplyPipeline?.stop();
|
|
2820
|
+
typing.markRunComplete();
|
|
2821
|
+
typing.markDispatchIdle();
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
//#endregion
|
|
2825
|
+
export { runReplyAgent };
|