kaijibot 2026.8.21 → 2026.8.23
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/README.en.md +1 -1
- package/README.md +1 -1
- package/dist/.buildstamp +1 -1
- package/dist/abort-Bg5O8Yiz.js +202 -0
- package/dist/abort-cutoff.runtime-CvjKPRCc.js +20 -0
- package/dist/abort-cutoff.runtime.js +1 -1
- package/dist/abort.runtime-UZvtDM6M.js +2 -0
- package/dist/abort.runtime.js +1 -1
- package/dist/acp-cli-BHDaxHbu.js +2171 -0
- package/dist/acp-spawn-BJJ8QbXE.js +1024 -0
- package/dist/acp-stateful-target-driver-DyZ1dneY.js +88 -0
- package/dist/action-agents-Bx5S-ZYL.js +67 -0
- package/dist/action-focus-DGURwLDo.js +124 -0
- package/dist/action-help-7ey3e-V9.js +7 -0
- package/dist/action-info-BxQpOqFZ.js +58 -0
- package/dist/action-kill-C7kGSXgP.js +33 -0
- package/dist/action-list-cwGVroWS.js +21 -0
- package/dist/action-log-DT-bRM9X.js +30 -0
- package/dist/action-send-BNv-Wz-l.js +39 -0
- package/dist/action-spawn-DkEYjxPF.js +46 -0
- package/dist/action-unfocus-CU1WRop0.js +28 -0
- package/dist/agent-BOaVCAE9.js +2 -0
- package/dist/agent-command-0Ie27CS4.js +1479 -0
- package/dist/agent-runner-utils-fBrjJUeq.js +202 -0
- package/dist/agent-runner.runtime-DEArTfVM.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-CH6NQBfT.js +5 -0
- package/dist/agents-DuBi4yGs.js +887 -0
- package/dist/anthropic-vertex-stream-C-dr7gew.js +5666 -0
- package/dist/api-C-d6hJ6R.js +3 -0
- package/dist/api-CWzMTsre.js +35 -0
- package/dist/api-CspIEuoI.js +4 -0
- package/dist/api-DWfH8UCU.js +19 -0
- package/dist/api-DnP8S2bH.js +5 -0
- package/dist/api-Y8trG2YC.js +2 -0
- package/dist/api-fZ1Mwhb9.js +2 -0
- package/dist/api-inKLxoen.js +45 -0
- package/dist/api-plrtNPKq.js +2 -0
- package/dist/api-tiV4Lam3.js +2 -0
- package/dist/apply-DyMW1n_a.js +493 -0
- package/dist/apply.runtime-BOvle-IJ.js +166 -0
- package/dist/apply.runtime-C0ny2nmc.js +2 -0
- package/dist/apply.runtime.js +1 -1
- package/dist/approval-client-helpers-Ss4gUaso.js +82 -0
- package/dist/approval-gateway-resolver-D6xh0K2G.js +58 -0
- package/dist/approval-gateway-runtime-CffF6RIQ.js +2 -0
- package/dist/approval-handler-runtime-p9BmT1Xf.js +439 -0
- package/dist/approval-native-runtime-DN73OHKf.js +709 -0
- package/dist/approval-renderers-CITEnajR.js +64 -0
- package/dist/asr-Jt-OmxEb.js +196 -0
- package/dist/audit-BM_BshdA.js +885 -0
- package/dist/audit-extra.async-Cvm-ViC4.js +847 -0
- package/dist/audit.deep.runtime-Ccabqd1Y.js +2 -0
- package/dist/audit.deep.runtime.js +1 -1
- package/dist/audit.nondeep.runtime-BNrDSb24.js +859 -0
- package/dist/audit.nondeep.runtime.js +1 -1
- package/dist/audit.runtime-BKUEHsrE.js +7 -0
- package/dist/audit.runtime.js +1 -1
- package/dist/auth-Dt8gUUJi.js +181 -0
- package/dist/auth-choice-BC_BWYZD.js +3 -0
- package/dist/auth-choice-BtwWAcEq.js +71 -0
- package/dist/auth-choice-CO__21te.js +353 -0
- package/dist/auth-choice-options-BxgjFsFO.js +104 -0
- package/dist/auth-choice-prompt-B-P39mib.js +2 -0
- package/dist/auth-choice-prompt-Dp7Vptqj.js +36 -0
- package/dist/auth-choice.plugin-providers.runtime-BJqmauZz.js +11 -0
- package/dist/auth-choice.plugin-providers.runtime.js +1 -1
- package/dist/auth-health-CPclIUZ3.js +165 -0
- package/dist/auth-profiles-P49vCUs4.js +438 -0
- package/dist/auth-profiles.runtime-pIuc_0v-.js +7 -0
- package/dist/auth-profiles.runtime.js +1 -1
- package/dist/auto-recall-Dm-J3oEj.js +78 -0
- package/dist/backup-create-DcO0pYFy.js +391 -0
- package/dist/banner-CIw8Yepm.js +2 -0
- package/dist/banner-w4GNKrs6.js +281 -0
- package/dist/binding-routing-upMo3iCO.js +50 -0
- package/dist/binding-targets-C9WygzAM.js +99 -0
- package/dist/bridge-server-Cu0xkN0E.js +103 -0
- package/dist/browser-config-runtime-3QVJiqnP.js +6 -0
- package/dist/browser-control-auth-BkunTzw7.js +120 -0
- package/dist/browser-node-runtime-BusKdg2E.js +12 -0
- package/dist/browser-profiles-BocOxjqC.js +170 -0
- package/dist/browser-runtime-D3goJLF9.js +377 -0
- package/dist/browser-setup-tools-j-IDYASL.js +12 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +4 -4
- package/dist/bundled/session-memory/handler.js +2 -2
- package/dist/call-CMDK9Mqx.js +2 -0
- package/dist/call-Cisydyym.js +495 -0
- package/dist/call.runtime-CJUaD_Ck.js +2 -0
- package/dist/call.runtime.js +1 -1
- package/dist/capability-cli-e_bf338W.js +1357 -0
- package/dist/catalog-provider-D5mzbnCM.js +40 -0
- package/dist/cdp.helpers-BqVqEY02.js +372 -0
- package/dist/channel-core-cQ4DROoP.js +5 -0
- package/dist/channel-summary-BHojSrOd.js +139 -0
- package/dist/channel-summary-CzjCL-4-.js +2 -0
- package/dist/channel.runtime-D6e2VBFb.js +399 -0
- package/dist/channel.runtime.js +1 -1
- package/dist/channels-cli-Y-Wnalvd.js +248 -0
- package/dist/channels-uiGUmLk2.js +1147 -0
- package/dist/chat-CQc5lJAu.js +213 -0
- package/dist/chrome-BcU0ZvUn.js +1080 -0
- package/dist/chrome.executables-Dp0Lkjmz.js +550 -0
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/cli-BGB7qdp3.js +191 -0
- package/dist/cli-BtTS8CKF.js +2 -0
- package/dist/cli-CQX3q4Fm.js +57 -0
- package/dist/cli-ZLAF588A.js +154 -0
- package/dist/cli-auth-seam-D-Qci5-b.js +14 -0
- package/dist/cli-backend-DxaeTZ8N.js +66 -0
- package/dist/cli-g4KJW_UT.js +2 -0
- package/dist/cli-migration-B2SFdY0j.js +127 -0
- package/dist/cli-runner-BVQt0v1D.js +1662 -0
- package/dist/cli-runner.runtime-BAMS4uW0.js +3 -0
- package/dist/cli-runner.runtime-H3alxbDK.js +2 -0
- package/dist/cli-runner.runtime.js +1 -1
- package/dist/cli-shared-BaJRfEqD.js +142 -0
- package/dist/cli-startup-metadata.json +2 -2
- package/dist/cli.runtime-CQ1qvGdJ.js +819 -0
- package/dist/cli.runtime.js +1 -1
- package/dist/client-bootstrap-BE7PiMJr.js +28 -0
- package/dist/codex-native-web-search-TdFXLTHZ.js +2 -0
- package/dist/codex-native-web-search-dKQT4ZPV.js +156 -0
- package/dist/collector-BXDPP4rJ.js +2 -0
- package/dist/collector-CT3qBEYi.js +424 -0
- package/dist/command-auth-FR5r0kKW.js +75 -0
- package/dist/command-config-resolution-BfTLOZxI.js +23 -0
- package/dist/command-config-resolution-GV0h_B0u.js +2 -0
- package/dist/command-execution-startup-oMdUg9Py.js +269 -0
- package/dist/command-format-CZ8oMoC9.js +2 -0
- package/dist/command-queue-BlORGS1M.js +260 -0
- package/dist/command-registry-DNKWkedC.js +3 -0
- package/dist/command-registry-DO6fBZ31.js +113 -0
- package/dist/command-secret-gateway-Cnjliq_k.js +528 -0
- package/dist/commands-acp-OeD4TGXU.js +1017 -0
- package/dist/commands-compact.runtime-ZE5b-Pvj.js +10 -0
- package/dist/commands-compact.runtime.js +1 -1
- package/dist/commands-core.runtime-Ca3exd9B.js +2 -0
- package/dist/commands-core.runtime.js +1 -1
- package/dist/commands-handlers.runtime-DKL8ULNw.js +3762 -0
- package/dist/commands-handlers.runtime.js +1 -1
- package/dist/commands-models-uaQEC1GX.js +306 -0
- package/dist/commands-reset-hooks-0RFpUGBC.js +129 -0
- package/dist/commands-status-4HTjDVIN.js +223 -0
- package/dist/commands-status.runtime-CyJiWLQs.js +2 -0
- package/dist/commands-status.runtime.js +1 -1
- package/dist/commands-subagents-control.runtime-B3DtD7Se.js +3 -0
- package/dist/commands-subagents-control.runtime-BLHWicyx.js +2 -0
- package/dist/commands-subagents-control.runtime.js +1 -1
- package/dist/commands.runtime-Bk9-pUEs.js +103 -0
- package/dist/commands.runtime.js +1 -1
- package/dist/comment-shared-BCggDOtV.js +40 -0
- package/dist/compact-CBJu2_ft.js +11324 -0
- package/dist/compact.runtime-Bj3PGRRh.js +7 -0
- package/dist/compact.runtime.js +1 -1
- package/dist/completion-cli-B27D7vni.js +468 -0
- package/dist/completion-cli-QdkbM0Vz.js +2 -0
- package/dist/config-BZb7_jO5.js +166 -0
- package/dist/config-C2M27bOw.js +8 -0
- package/dist/config-D_fICGrQ.js +53 -0
- package/dist/config-cli-B7j3KePQ.js +948 -0
- package/dist/config-defaults-XFEo6I7v.js +163 -0
- package/dist/config-guard-wGGj2x7b.js +94 -0
- package/dist/config-runtime-xwO8vvQP.js +14 -0
- package/dist/config-validation-tPbNhbrH.js +279 -0
- package/dist/configure-CXFWPXal.js +1162 -0
- package/dist/configure-lBR_2rAt.js +2 -0
- package/dist/connection-auth-ClCO21bT.js +30 -0
- package/dist/context-CJMC7SyI.js +249 -0
- package/dist/context-CWC_tVM8.js +2 -0
- package/dist/context-writer-DNkMBOu9.js +290 -0
- package/dist/control-auth-DUZs9D8n.js +122 -0
- package/dist/control-ui/assets/agents-HENIRhRj.js +767 -0
- package/dist/control-ui/assets/anthropic-DlOZcqqy.js +40 -0
- package/dist/control-ui/assets/azure-openai-responses-BmSDwKAQ.js +2 -0
- package/dist/control-ui/assets/cron-B2CJajqc.js +744 -0
- package/dist/control-ui/assets/dialogues-DmWmdbMF.js +83 -0
- package/dist/control-ui/assets/history-CP7LOJan.js +71 -0
- package/dist/control-ui/assets/index-BsGBtIKy.css +1 -0
- package/dist/control-ui/assets/index-BtNFbQhY.js +2686 -0
- package/dist/control-ui/assets/mistral-CYEJ-E7G.js +72 -0
- package/dist/control-ui/assets/openai-codex-responses-BnLjDxo3.js +8 -0
- package/dist/control-ui/assets/openai-completions-D46D4eD2.js +6 -0
- package/dist/control-ui/assets/openai-responses-CNVWXuC0.js +2 -0
- package/dist/control-ui/assets/openai-responses-shared-ByeOE-gc.js +13 -0
- package/dist/control-ui/index.html +2 -2
- package/dist/conversation-id-DlazDTmW.js +140 -0
- package/dist/conversation-runtime-BjljNAU1.js +31 -0
- package/dist/core-4Dt1_PpO.js +210 -0
- package/dist/cron-cli-CTGN3Kum.js +637 -0
- package/dist/curator-BM2jeaou.js +600 -0
- package/dist/curator-_QLWjb7r.js +2 -0
- package/dist/daemon-cli-BLe7aLfJ.js +476 -0
- package/dist/daemon-install-BneaHOcs.js +70 -0
- package/dist/delegate-CyUm6mk6.js +61 -0
- package/dist/deliver-BvUx9v-a.js +3 -0
- package/dist/deliver-DQbRPHSb.js +782 -0
- package/dist/deliver-runtime-ERlRZAW4.js +2 -0
- package/dist/delivery-outbound.runtime-Bi6Lu4JP.js +6 -0
- package/dist/delivery-outbound.runtime.js +1 -1
- package/dist/delivery-queue-B4kCxhnW.js +2 -0
- package/dist/delivery-queue-DDHwRyN-.js +372 -0
- package/dist/deps-DZQeVHSD.js +60 -0
- package/dist/devices-cli-CFSjN2KZ.js +336 -0
- package/dist/diagnostic-Bh12mVkv.js +311 -0
- package/dist/direct-dm-Bn07LLbq.js +139 -0
- package/dist/directive-handling.fast-lane-Cd6SSr-l.js +64 -0
- package/dist/directive-handling.fast-lane-ejwgECy7.js +2 -0
- package/dist/directive-handling.impl-Bpy5KQZr.js +659 -0
- package/dist/directive-handling.impl-ZEKrT-pi.js +2 -0
- package/dist/directive-handling.parse-COyCTXvI.js +376 -0
- package/dist/directive-handling.persist-CgxhTMmz.js +139 -0
- package/dist/directive-handling.persist.runtime-4pppF2CM.js +2 -0
- package/dist/directive-handling.persist.runtime.js +1 -1
- package/dist/directive-handling.shared-BuNzwbwp.js +159 -0
- package/dist/directory-cli-gWQfdmFR.js +240 -0
- package/dist/dispatch-Cg_O6HsU.js +1126 -0
- package/dist/dispatch-acp-C7kPkeqX.js +969 -0
- package/dist/dispatch-acp-manager.runtime-Bh3V5wGh.js +3 -0
- package/dist/dispatch-acp-manager.runtime.js +1 -1
- package/dist/dispatch-acp-media.runtime-pWY6A7VY.js +3 -0
- package/dist/dispatch-acp-media.runtime.js +1 -1
- package/dist/dispatch-acp-session.runtime-DdkuSkq8.js +2 -0
- package/dist/dispatch-acp-session.runtime.js +1 -1
- package/dist/dispatch-acp.runtime-fr_7acr8.js +19 -0
- package/dist/dispatch-acp.runtime.js +1 -1
- package/dist/dns-cli-C4uepTJE.js +193 -0
- package/dist/docs-cli-DWzfteG6.js +156 -0
- package/dist/doctor-completion-D2s3ieS6.js +90 -0
- package/dist/doctor-config-preflight-BIf8igIW.js +148 -0
- package/dist/doctor-config-preflight-BiJSPUPg.js +2 -0
- package/dist/doctor-state-migrations-BbfPLoLz.js +2 -0
- package/dist/doctor-state-migrations-DFQets45.js +3 -0
- package/dist/drive-CvbBPFcl.js +718 -0
- package/dist/embedding-provider-DUT_HxYD.js +26 -0
- package/dist/embedding-provider-DjVEIg-4.js +33 -0
- package/dist/embedding-provider-TKNNnQ3m.js +129 -0
- package/dist/engine-CT4xJJ-H.js +82 -0
- package/dist/engine-embeddings-BN4uJOv0.js +1489 -0
- package/dist/entry-capabilities-BhpTqh0w.js +89 -0
- package/dist/entry.js +2 -2
- package/dist/env-overrides-Dn5yy0l4.js +347 -0
- package/dist/env-overrides.runtime-DdD841Km.js +7 -0
- package/dist/env-overrides.runtime.js +1 -1
- package/dist/exec-approval-forwarder.runtime-CV81fvQh.js +3 -0
- package/dist/exec-approval-forwarder.runtime.js +1 -1
- package/dist/exec-approval-reply-C_NfihTE.js +292 -0
- package/dist/exec-approvals-cli-DKOFcUAn.js +485 -0
- package/dist/exec-defaults-Cs1FwIKH.js +1440 -0
- package/dist/extensionAPI.js +4 -4
- 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/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 +2 -2
- 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 +2 -2
- 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 +3 -3
- package/dist/extensions/browser/browser-control-auth.js +1 -1
- package/dist/extensions/browser/browser-doctor.js +4 -4
- 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 +1 -1
- package/dist/extensions/browser/browser-runtime-api.js +11 -11
- 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 +12 -12
- 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 +7 -7
- 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 +6 -6
- package/dist/extensions/deepinfra/api.js +3 -3
- package/dist/extensions/deepinfra/embedding-provider.js +1 -1
- package/dist/extensions/deepinfra/index.js +4 -4
- package/dist/extensions/deepinfra/media-understanding-provider.js +1 -1
- package/dist/extensions/deepinfra/memory-embedding-adapter.js +1 -1
- package/dist/extensions/deepinfra/video-generation-provider.js +1 -1
- package/dist/extensions/deepseek/index.js +1 -1
- package/dist/extensions/device-pair/api.js +2 -2
- package/dist/extensions/device-pair/index.js +5 -5
- 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/diffs/node_modules/.package-lock.json +3 -3
- package/dist/extensions/diffs/node_modules/typebox/build/format/email.mjs +1 -1
- package/dist/extensions/diffs/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/dist/extensions/diffs/node_modules/typebox/package.json +1 -1
- package/dist/extensions/exa/index.js +1 -1
- package/dist/extensions/feishu/.kaijibot-runtime-deps-stamp.json +1 -1
- package/dist/extensions/feishu/api.js +16 -16
- package/dist/extensions/feishu/contract-api.js +2 -2
- package/dist/extensions/feishu/node_modules/.package-lock.json +3 -3
- package/dist/extensions/feishu/node_modules/typebox/build/format/email.mjs +1 -1
- package/dist/extensions/feishu/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/dist/extensions/feishu/node_modules/typebox/package.json +1 -1
- package/dist/extensions/feishu/runtime-api.js +2 -2
- 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 +1 -1
- package/dist/extensions/github-copilot/api.js +1 -1
- package/dist/extensions/github-copilot/index.js +6 -6
- 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/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.js +2 -2
- 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-provider.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 +6 -6
- 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 +3 -3
- package/dist/extensions/kindle-portal/.kaijibot-runtime-deps-stamp.json +1 -1
- package/dist/extensions/kindle-portal/node_modules/.package-lock.json +3 -3
- package/dist/extensions/kindle-portal/node_modules/typebox/build/format/email.mjs +1 -1
- package/dist/extensions/kindle-portal/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/dist/extensions/kindle-portal/node_modules/typebox/package.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 +6 -6
- package/dist/extensions/lmstudio/index.js +2 -2
- 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 +1 -1
- 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/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/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/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-provider.js +1 -1
- package/dist/extensions/mistral/embedding-provider.js +1 -1
- package/dist/extensions/mistral/index.js +2 -2
- package/dist/extensions/mistral/media-understanding-provider.js +1 -1
- package/dist/extensions/mistral/memory-embedding-adapter.js +3 -3
- package/dist/extensions/mistral/test-api.js +1 -1
- package/dist/extensions/moonshot/index.js +5 -5
- package/dist/extensions/moonshot/media-understanding-provider.js +1 -1
- package/dist/extensions/moonshot/test-api.js +2 -2
- package/dist/extensions/moonshot/web-search-provider.js +1 -1
- package/dist/extensions/nvidia/index.js +1 -1
- package/dist/extensions/ollama/api.js +3 -3
- package/dist/extensions/ollama/index.js +6 -6
- package/dist/extensions/ollama/runtime-api.js +2 -2
- 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-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 +1 -1
- 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 +3 -3
- package/dist/extensions/opencode-go/index.js +2 -2
- package/dist/extensions/openrouter/api.js +2 -2
- package/dist/extensions/openrouter/image-generation-provider.js +1 -1
- package/dist/extensions/openrouter/index.js +6 -6
- package/dist/extensions/openrouter/media-understanding-provider.js +1 -1
- package/dist/extensions/openrouter/music-generation-provider.js +1 -1
- package/dist/extensions/openrouter/test-api.js +3 -3
- package/dist/extensions/openrouter/video-generation-provider.js +1 -1
- package/dist/extensions/openshell/index.js +4 -4
- package/dist/extensions/qianfan/index.js +1 -1
- package/dist/extensions/qwen/index.js +3 -3
- package/dist/extensions/qwen/media-understanding-provider.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/sglang/api.js +2 -2
- package/dist/extensions/sglang/index.js +2 -2
- package/dist/extensions/sglang/models.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 +2 -2
- package/dist/extensions/speech-core/runtime-api.js +4 -4
- package/dist/extensions/stepfun/index.js +2 -2
- package/dist/extensions/talk-voice/index.js +3 -3
- package/dist/extensions/tavily/index.js +1 -1
- package/dist/extensions/together/index.js +1 -1
- package/dist/extensions/together/video-generation-provider.js +1 -1
- package/dist/extensions/venice/api.js +3 -3
- package/dist/extensions/venice/index.js +5 -5
- 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/index.js +1 -1
- package/dist/extensions/vllm/api.js +2 -2
- package/dist/extensions/vllm/index.js +2 -2
- package/dist/extensions/vllm/models.js +1 -1
- package/dist/extensions/vllm/register.runtime.js +2 -2
- 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 +3 -3
- package/dist/extensions/webhooks/runtime-api.js +1 -1
- package/dist/extensions/wechat/api.js +3 -3
- package/dist/extensions/xai/api.js +5 -5
- package/dist/extensions/xai/code-execution.js +3 -3
- package/dist/extensions/xai/index.js +9 -9
- 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/video-generation-provider.js +1 -1
- package/dist/extensions/xai/web-search.js +1 -1
- package/dist/extensions/xai/x-search.js +3 -3
- package/dist/extensions/xiaomi/index.js +1 -1
- package/dist/extensions/zai/index.js +5 -5
- package/dist/extensions/zai/media-understanding-provider.js +1 -1
- package/dist/extensions/zai/test-api.js +1 -1
- package/dist/extra-params-CEZLNZPM.js +295 -0
- package/dist/format-P9xNDyfD.js +245 -0
- package/dist/fragment-collector-D6OalgG0.js +189 -0
- package/dist/gateway-cli-Zfvn259p.js +1532 -0
- package/dist/gateway-install-token-6z725yP4.js +284 -0
- package/dist/gateway-rpc-BIq75xob.js +14 -0
- package/dist/gateway-rpc.runtime-qaUC59kw.js +23 -0
- package/dist/gateway-rpc.runtime.js +1 -1
- package/dist/gemini-cli-provider-DapCuX8Q.js +106 -0
- package/dist/gemini-web-search-provider-qckYFHgT.js +167 -0
- package/dist/get-reply-from-config.runtime-DHsGpgGI.js +2 -0
- package/dist/get-reply-from-config.runtime.js +1 -1
- package/dist/gmail-setup-utils-Cc3pRzTO.js +422 -0
- package/dist/health-3b-YI19K.js +579 -0
- package/dist/health-MLtfjMov.js +2 -0
- package/dist/heartbeat-runner-BUj0aHm6.js +4 -0
- package/dist/heartbeat-runner-CsnBv3An.js +1365 -0
- package/dist/heartbeat-runner.runtime-DYHZ3Vol.js +2 -0
- package/dist/heartbeat-runner.runtime.js +1 -1
- package/dist/help-ktSd2tag.js +76 -0
- package/dist/hooks-cli-IZb2tmWn.js +364 -0
- package/dist/image-C3lHN8WH.js +152 -0
- package/dist/image-generation-core-Csa-tOLR.js +17 -0
- package/dist/image-generation-core.auth.runtime-DWfzUU3N.js +2 -0
- package/dist/image-generation-core.auth.runtime.js +1 -1
- package/dist/image-generation-provider-Bq81bEDF.js +94 -0
- package/dist/image-generation-provider-D9rV0jKg.js +280 -0
- package/dist/image-generation-provider-DLxx1bzz.js +130 -0
- package/dist/image-generation-provider-DtYtLZ5X.js +136 -0
- package/dist/image-generation-provider-DxkBVWXc.js +163 -0
- package/dist/image-generation-runtime-BSjvNi3e.js +2 -0
- package/dist/image-runtime-DiMm78ho.js +7 -0
- package/dist/inbound-reply-dispatch-vAjY1w2F.js +73 -0
- package/dist/inbound.runtime-CRF3jMe0.js +3 -0
- package/dist/inbound.runtime-DTPuWSKr.js +4 -0
- package/dist/inbound.runtime.js +1 -1
- package/dist/index.js +2 -2
- package/dist/infra-runtime-D3jjt6RI.js +25 -0
- package/dist/ingest-DZbARiPc.js +2 -0
- package/dist/ingest-gzQEKaUE.js +842 -0
- package/dist/io-NwOu0Lqq.js +7188 -0
- package/dist/io-p7f7Dzgz.js +5 -0
- package/dist/kaijibot-tools-DlPDuhB1.js +9434 -0
- package/dist/kaijibot-tools.runtime-Cme2o8P6.js +2 -0
- package/dist/kaijibot-tools.runtime.js +1 -1
- package/dist/kimi-web-search-provider-Ccz-6FOv.js +308 -0
- package/dist/library-CNY5LwdW.js +45 -0
- package/dist/lifecycle-DPisznBr.js +51 -0
- package/dist/lifecycle-core-DHpL48zF.js +422 -0
- package/dist/list.runtime-BGQLMIEV.js +9 -0
- package/dist/list.runtime-rNaKvGI6.js +12 -0
- package/dist/list.runtime.js +1 -1
- package/dist/llm-engine-CJ4a8si7.js +2 -0
- package/dist/llm-engine-JflSw21y.js +1792 -0
- package/dist/llm-extractor-f_T1e84b.js +445 -0
- package/dist/llm-slug-generator.js +2 -2
- package/dist/load-context-BgiRixkE.js +51 -0
- package/dist/logging-BmlPHvHz.js +13 -0
- package/dist/logging-i6p97HMj.js +2 -0
- package/dist/login-BCtkm5rk.js +108 -0
- package/dist/logs-cli-ObIjoAas.js +264 -0
- package/dist/logs-cli.runtime-BFjo2k4n.js +2 -0
- package/dist/logs-cli.runtime.js +1 -1
- package/dist/manager-CWqmCOrL.js +2049 -0
- package/dist/manager-YA9gsC3-.js +3314 -0
- package/dist/mcp/plugin-tools-serve.js +3 -3
- package/dist/mcp-cli-4snhlJll.js +733 -0
- package/dist/mcp-config-BorcRx6O.js +115 -0
- package/dist/media-runtime-we0ajcYl.js +312 -0
- package/dist/media-understanding-provider-3Ttl6hmp.js +18 -0
- package/dist/media-understanding-provider-BGTcMbZI.js +13 -0
- package/dist/media-understanding-provider-BWZtBNix.js +30 -0
- package/dist/media-understanding-provider-CLJBFDyf.js +123 -0
- package/dist/media-understanding-provider-CZ0oRDnO.js +69 -0
- package/dist/media-understanding-provider-CfBvdveE.js +112 -0
- package/dist/media-understanding-provider-D6Ei6zjV.js +18 -0
- package/dist/media-understanding-provider-DEbLZtur.js +37 -0
- package/dist/media-understanding-provider-DysTPulI.js +14 -0
- package/dist/media-understanding-provider-guIrycoj.js +21 -0
- package/dist/media-understanding-provider-sqqt3Zo1.js +67 -0
- package/dist/media-understanding-runtime-DIH8yX06.js +2 -0
- package/dist/media-understanding-zIdRKTHF.js +83 -0
- package/dist/memory-CEPz51C1.js +242 -0
- package/dist/memory-Dz9LyrwM.js +3 -0
- package/dist/memory-core-host-engine-embeddings-D_hioQXv.js +2 -0
- package/dist/memory-core-host-engine-foundation-1Abnrvzg.js +11 -0
- package/dist/memory-core-host-runtime-cli-CPpWR4jD.js +9 -0
- package/dist/memory-core-host-runtime-core-QOAE1eXJ.js +8 -0
- package/dist/memory-embedding-adapter-CJMHQ4fD.js +33 -0
- package/dist/memory-host-search.runtime-CCL0QyRa.js +2 -0
- package/dist/memory-host-search.runtime.js +1 -1
- package/dist/memory-index-BaKGqStn.js +2 -0
- package/dist/memory-index-Dq16t3Le.js +514 -0
- package/dist/memory-runtime-Cr2ycPVC.js +2 -0
- package/dist/memory-runtime-DuWAywa6.js +26 -0
- package/dist/message-B59-6tOr.js +223 -0
- package/dist/message-action-runner-CD2L-ZBQ.js +2 -0
- package/dist/message-action-runner-y-EYEp0n.js +1628 -0
- package/dist/message.config.runtime-NCa2v5Ci.js +3 -0
- package/dist/message.config.runtime.js +1 -1
- package/dist/message.gateway.runtime-Ba2cmeG0.js +2 -0
- package/dist/message.gateway.runtime.js +1 -1
- package/dist/metadata-registry-loader-BAAhCgIz.js +2 -0
- package/dist/metadata-registry-loader-D7YsnsL7.js +15 -0
- package/dist/minimax-vlm-CRQ1qjBy.js +183 -0
- package/dist/minimax-web-search-provider-CBq2_5UU.js +165 -0
- package/dist/mmr-CqmAMXIW.js +146 -0
- package/dist/model-NNxPja4R.js +630 -0
- package/dist/model-auth-BCNvl8s6.js +427 -0
- package/dist/model-auth-label-B0iZbvPM.js +45 -0
- package/dist/model-catalog-B_WMQ0w_.js +204 -0
- package/dist/model-definitions-YQ1lzfH1.js +258 -0
- package/dist/model-picker-ByUUyua6.js +3 -0
- package/dist/model-picker-D2NwBUVu.js +500 -0
- package/dist/model-picker.runtime-BLIC1v4k.js +15 -0
- package/dist/model-picker.runtime.js +1 -1
- package/dist/model-selection-BNkt6VsY.js +381 -0
- package/dist/model-suppression-BLpblK4C.js +28 -0
- package/dist/model-suppression.runtime-CzgXh3-Q.js +7 -0
- package/dist/model-suppression.runtime.js +1 -1
- package/dist/models-11Amlqm7.js +2584 -0
- package/dist/models-BAPi-xJJ.js +2 -0
- package/dist/models-BUxoFu33.js +47 -0
- package/dist/models-Ch34kBry.js +18 -0
- package/dist/models-CxT1_oJh.js +157 -0
- package/dist/models-DdsCg0Z3.js +18 -0
- package/dist/models-cli-DyOOLtYl.js +198 -0
- package/dist/models-config-C91hdcPk.js +900 -0
- package/dist/models-config.providers.secrets-CAQfFlJs.js +299 -0
- package/dist/models-jeG3zz29.js +555 -0
- package/dist/models-uX_1Gq3N.js +760 -0
- package/dist/models.fetch-CBAxXkYq.js +518 -0
- package/dist/monitor-DAF8Gyq4.js +4435 -0
- package/dist/monitor-DSKG-_yl.js +1023 -0
- package/dist/music-generation-provider-BnrTAmbY.js +142 -0
- package/dist/music-generation-provider-CEN-hiuw.js +238 -0
- package/dist/music-generation-provider-CltAphNV.js +169 -0
- package/dist/node-cli-DiZrvwCr.js +2374 -0
- package/dist/nodes-cli-CHIEN-F1.js +1046 -0
- package/dist/nodes-utils-DsRDUdkI.js +196 -0
- package/dist/notify-CLlD_xFa.js +305 -0
- package/dist/oauth-BH1NzJxX.js +57 -0
- package/dist/oauth-oo4i0YoK.js +152 -0
- package/dist/oauth-token-shared-DQSx2gNJ.js +28 -0
- package/dist/oauth.credentials-Bry_dis_.js +165 -0
- package/dist/oauth.flow-BHm8lbRc.js +122 -0
- package/dist/oauth.settings-BEQZQI_l.js +44 -0
- package/dist/oauth.token-CrxxQ__U.js +43 -0
- package/dist/onboard-7nVuWCbc.js +25 -0
- package/dist/onboard-BR4C6q_p.js +25 -0
- package/dist/onboard-CLJvlk15.js +621 -0
- package/dist/onboard-CdxRLmEw2.js +58 -0
- package/dist/onboard-ClstIj39.js +29 -0
- package/dist/onboard-DCvok686.js +25 -0
- package/dist/onboard-RcjANnyK.js +312 -0
- package/dist/onboard-custom-utbZx3tp.js +2 -0
- package/dist/onboard-custom-zmMvywOs.js +647 -0
- package/dist/onboard-helpers-DptwxvqO.js +223 -0
- package/dist/onboard-helpers-hUiLSHkd.js +5 -0
- package/dist/onboard-remote-BLFcjcH2.js +2 -0
- package/dist/onboard-remote-D21HhC2v.js +193 -0
- package/dist/onboard-search-D-BZAp6B.js +324 -0
- package/dist/onboard-skills-B90sl6kA.js +134 -0
- package/dist/onboard-skills-DBZJuUNt.js +2 -0
- package/dist/openai-codex-auth-identity-DJ-yiC5N.js +45 -0
- package/dist/openai-codex-cli-auth-BdZB_Fn0.js +57 -0
- package/dist/openai-codex-provider-D23flY_z.js +299 -0
- package/dist/openai-codex-shared-7LLW54Av.js +6 -0
- package/dist/openai-provider-xmL-RBDi.js +283 -0
- package/dist/openai-transport-stream-M1bujvhd.js +1632 -0
- package/dist/operator-approvals-client-DNHRZj38.js +68 -0
- package/dist/order-DFWeiLxK.js +794 -0
- package/dist/pair-command-approve-CSw5-2fz.js +34 -0
- package/dist/pairing-cli-WXk-duET.js +118 -0
- package/dist/persistent-bindings.lifecycle-CvUywK5_.js +94 -0
- package/dist/pi-bundle-mcp-tools-CX0SFgbF.js +709 -0
- package/dist/pi-embedded-BycqI-F6.js +2 -0
- package/dist/pi-embedded-CROyZQKw.js +6 -0
- package/dist/pi-embedded-runner-DvjFL5Sg.js +8350 -0
- package/dist/pi-embedded-subscribe.handlers.compaction.runtime-DAY2Idkx.js +23 -0
- package/dist/pi-embedded-subscribe.handlers.compaction.runtime.js +1 -1
- package/dist/pi-embedded.runtime-CnpLMfdZ.js +5 -0
- package/dist/pi-embedded.runtime.js +1 -1
- package/dist/pi-model-discovery-eCOzFFEF.js +232 -0
- package/dist/pi-tools.before-tool-call.runtime-DxhFk59d.js +354 -0
- package/dist/pi-tools.before-tool-call.runtime.js +1 -1
- package/dist/plugin-enabled-CHyNN_TN.js +71 -0
- package/dist/plugin-install-config-policy-AxFoCFZw.js +137 -0
- package/dist/plugin-registration-DNzK0hY5.js +23 -0
- package/dist/plugin-registry-CtFzpQUT.js +3 -0
- package/dist/plugin-registry-loader-2DtlC05M.js +22 -0
- package/dist/plugin-registry-rGAVZ04A.js +2 -0
- package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
- 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 +6 -6
- package/dist/plugin-sdk/agent-runtime.js +9 -9
- package/dist/plugin-sdk/approval-client-runtime.js +2 -2
- 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-reply-runtime.js +2 -2
- package/dist/plugin-sdk/approval-runtime.js +4 -4
- package/dist/plugin-sdk/browser-config-runtime.js +2 -2
- package/dist/plugin-sdk/browser-config.js +2 -2
- package/dist/plugin-sdk/browser-control-auth.js +1 -1
- package/dist/plugin-sdk/browser-node-runtime.js +3 -3
- package/dist/plugin-sdk/browser-profiles.js +1 -1
- package/dist/plugin-sdk/browser-setup-tools.js +2 -2
- package/dist/plugin-sdk/browser-support.js +7 -7
- package/dist/plugin-sdk/channel-core.js +2 -2
- package/dist/plugin-sdk/channel-inbound.js +3 -3
- package/dist/plugin-sdk/command-auth.js +4 -4
- package/dist/plugin-sdk/compat.js +2 -2
- package/dist/plugin-sdk/config-mutation.js +4 -4
- package/dist/plugin-sdk/config-runtime.js +6 -6
- package/dist/plugin-sdk/config-schema.js +1 -1
- 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 +3 -3
- package/dist/plugin-sdk/direct-dm.js +1 -1
- package/dist/plugin-sdk/gateway-method-runtime.js +1 -1
- package/dist/plugin-sdk/gateway-runtime.js +1 -1
- 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 +4 -4
- 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 +5 -5
- 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 +2 -2
- package/dist/plugin-sdk/memory-core-host-runtime-cli.js +2 -2
- package/dist/plugin-sdk/memory-core-host-runtime-core.js +3 -3
- package/dist/plugin-sdk/memory-core.js +5 -5
- package/dist/plugin-sdk/memory-host-core.js +3 -3
- package/dist/plugin-sdk/memory-host-search.js +1 -1
- package/dist/plugin-sdk/models-provider-runtime.js +1 -1
- package/dist/plugin-sdk/plugin-test-runtime.js +3 -3
- package/dist/plugin-sdk/provider-auth-api-key.js +4 -4
- package/dist/plugin-sdk/provider-auth.js +7 -7
- package/dist/plugin-sdk/provider-entry.js +1 -1
- package/dist/plugin-sdk/provider-setup.js +2 -2
- package/dist/plugin-sdk/provider-stream-family.js +3 -3
- package/dist/plugin-sdk/provider-stream.js +2 -2
- package/dist/plugin-sdk/provider-test-contracts.js +2 -2
- package/dist/plugin-sdk/provider-transport-runtime.js +1 -1
- package/dist/plugin-sdk/reply-dispatch-runtime.js +1 -1
- package/dist/plugin-sdk/reply-runtime.js +7 -7
- package/dist/plugin-sdk/runtime-secret-resolution.js +1 -1
- package/dist/plugin-sdk/runtime.js +3 -3
- package/dist/plugin-sdk/sandbox.js +2 -2
- package/dist/plugin-sdk/self-hosted-provider-setup.js +1 -1
- package/dist/plugin-sdk/session-store-runtime.js +2 -2
- package/dist/plugin-sdk/simple-completion-runtime.js +1 -1
- package/dist/plugin-sdk/skill-commands-runtime.js +1 -1
- package/dist/plugin-sdk/speech-core.js +1 -1
- package/dist/plugin-sdk/src/cognitive/feedback/collector.d.ts +21 -0
- package/dist/plugin-sdk/src/cognitive/persona/lifecycle.d.ts +3 -6
- package/dist/plugin-sdk/src/cognitive/types.d.ts +14 -0
- package/dist/plugin-sdk/src/config/types.cognitive.d.ts +2 -0
- package/dist/plugin-sdk/src/config/zod-schema.cognitive.d.ts +2 -0
- package/dist/plugin-sdk/src/config/zod-schema.d.ts +1 -0
- package/dist/plugin-sdk/testing.js +5 -5
- package/dist/plugin-sdk/text-runtime.js +2 -2
- package/dist/plugin-sdk/video-generation-core.js +1 -1
- package/dist/plugin-sdk/video-generation-runtime.js +1 -1
- package/dist/plugin-service-ByhemcPW.js +2494 -0
- package/dist/plugins/provider-discovery.runtime.js +1 -1
- package/dist/plugins/provider-runtime.runtime.js +1 -1
- package/dist/plugins/runtime/index.js +1 -1
- package/dist/plugins-cli-Bsu-vzeD.js +576 -0
- package/dist/plugins-command-helpers-DHYkcqua.js +117 -0
- package/dist/plugins-install-persist-C8eGd_C5.js +121 -0
- package/dist/plugins-update-command-3xt3Uqf8.js +1009 -0
- package/dist/policy-D-ZKSMmN.js +172 -0
- package/dist/preemptive-compaction-DBfSd-op.js +430 -0
- package/dist/proactive-scheduler-CsHZHnLk.js +1535 -0
- package/dist/probe-CWzUPp-f.js +426 -0
- package/dist/probe-QRfkrTQp.js +54 -0
- package/dist/probe-auth-DG3q8vB9.js +69 -0
- package/dist/probe-auth-GBOKLPAd.js +3 -0
- package/dist/profiles-CBddrdQK.js +117 -0
- package/dist/program-g6p3Qeig.js +111 -0
- package/dist/prompt-overlay-CTwbv1jO.js +72 -0
- package/dist/prompt-select-styled-Cgy0KIgT.js +5305 -0
- package/dist/provider-B_TyrVqo.js +70 -0
- package/dist/provider-api-key-auth-DsEmjrKm.js +113 -0
- package/dist/provider-api-key-auth.runtime-DnU922Pm.js +14 -0
- package/dist/provider-api-key-auth.runtime.js +1 -1
- package/dist/provider-auth-B0NxCABI.js +36 -0
- package/dist/provider-auth-api-key-BRkYGkki.js +5 -0
- package/dist/provider-auth-choice-BU5MwS9n.js +134 -0
- package/dist/provider-auth-choice-preference-BjTvWslj.js +62 -0
- package/dist/provider-auth-choice.runtime-B8ZRr0Ji.js +2 -0
- package/dist/provider-auth-choice.runtime-DIN9GqRk.js +14 -0
- package/dist/provider-auth-choice.runtime.js +1 -1
- package/dist/provider-auth-guidance-BmbcHSR7.js +34 -0
- package/dist/provider-auth-helpers-BHAUl4Gr.js +168 -0
- package/dist/provider-catalog-BL8_CAyj.js +11 -0
- package/dist/provider-catalog-BRtoWqwn.js +11 -0
- package/dist/provider-catalog-BeddZRA_.js +12 -0
- package/dist/provider-catalog-Dl5yMnFQ.js +17 -0
- package/dist/provider-catalog-Doxz6-g3.js +56 -0
- package/dist/provider-catalog-nJImUuqB.js +26 -0
- package/dist/provider-dispatcher-D2GbNyfD.js +22 -0
- package/dist/provider-entry-B01Usrgw.js +97 -0
- package/dist/provider-flow-DgiCMoEf.js +66 -0
- package/dist/provider-models-CjNZS5bS.js +35 -0
- package/dist/provider-models-KjFLrk3V.js +119 -0
- package/dist/provider-models-vPWkBVJC.js +116 -0
- package/dist/provider-registration-BKyn4HAU.js +238 -0
- package/dist/provider-registration-Dtxvk5CC.js +57 -0
- package/dist/provider-runtime-DOtN11v9.js +2 -0
- package/dist/provider-runtime-DSAVX2DR.js +366 -0
- package/dist/provider-runtime.runtime-kKhVhqLz.js +26 -0
- package/dist/provider-runtime.runtime.js +1 -1
- package/dist/provider-self-hosted-setup-l_z2VcmU.js +249 -0
- package/dist/provider-setup-Bf_9tp4f.js +2 -0
- package/dist/provider-stream-BdikYSRa.js +285 -0
- package/dist/provider-stream-family-DSm3KbQw.js +2 -0
- package/dist/provider-usage-BGu0-R4j.js +289 -0
- package/dist/provider-usage-lgVGEKOt.js +3 -0
- package/dist/provider-wizard-BLwU3k7w.js +166 -0
- package/dist/providers.runtime-C0Xkoksw.js +125 -0
- package/dist/providers.runtime.js +1 -1
- package/dist/proxy-stream-wrappers-CIRRoMpa.js +480 -0
- package/dist/push-apns-BuLz1QrB.js +1061 -0
- package/dist/pw-ai-Ld88tf39.js +2268 -0
- package/dist/qmd-manager-kG_qjIil.js +1799 -0
- package/dist/qr-cli-CsNdevN-.js +359 -0
- package/dist/qr-image-CJ2mMFzI.js +2 -0
- package/dist/queue-fniCZ6ND.js +636 -0
- package/dist/realtime-provider-shared-B2y3nIjr.js +21 -0
- package/dist/realtime-transcription-provider-BYeb_Pdh.js +180 -0
- package/dist/realtime-voice-provider-Cs5kAI5o.js +342 -0
- package/dist/record-shared-vbhlkLLm.js +10 -0
- package/dist/refresh-DgMFD0Y0.js +115 -0
- package/dist/region-BOx9--Jp.js +74 -0
- package/dist/register.agent-i88emBrg.js +241 -0
- package/dist/register.backup-PaaKiScO.js +234 -0
- package/dist/register.configure-DOwB_pGJ.js +15 -0
- package/dist/register.maintenance-CYchYFw1.js +443 -0
- package/dist/register.message-DCzLrhHI.js +601 -0
- package/dist/register.onboard-La1ps81U.js +83 -0
- package/dist/register.runtime-Br9LK2gh.js +81 -0
- package/dist/register.runtime-CgbjcVmK.js +343 -0
- package/dist/register.runtime.js +1 -1
- package/dist/register.setup-BwGIBl0j.js +104 -0
- package/dist/register.status-health-sessions-Bg-JiJ0c.js +1211 -0
- package/dist/register.subclis-BvRTTvO6.js +3 -0
- package/dist/register.subclis-C72FAl_s.js +232 -0
- package/dist/repair-DUb-NpH_.js +112 -0
- package/dist/replay-policy-8aUdDKqI.js +8 -0
- package/dist/reply-SolAjGzg.js +3523 -0
- package/dist/reply.runtime-BzJw9WP7.js +2 -0
- package/dist/reply.runtime.js +1 -1
- package/dist/resolve-b0jc4sM3.js +280 -0
- package/dist/restart-CReI1iMn.js +454 -0
- package/dist/root-help-DOYfXVGX.js +44 -0
- package/dist/route-reply-Bsd_X1hM.js +141 -0
- package/dist/route-reply.runtime-0EDNxcfO.js +2 -0
- package/dist/route-reply.runtime.js +1 -1
- package/dist/rpc-C4VoC6lx.js +61 -0
- package/dist/rpc.runtime-CrjwpfEG.js +21 -0
- package/dist/rpc.runtime.js +1 -1
- package/dist/run-main-BqkJC57m.js +453 -0
- package/dist/run-wait-KirpkWGm.js +118 -0
- package/dist/runner-BVkPQnQI.js +1497 -0
- package/dist/runs-Djzm6zWd.js +495 -0
- package/dist/runtime-6nDEFb75.js +72 -0
- package/dist/runtime-BU-qtT4-.js +107 -0
- package/dist/runtime-BYFm5p1W.js +725 -0
- package/dist/runtime-Bw9f54EP.js +355 -0
- package/dist/runtime-D2tXO42J2.js +242 -0
- package/dist/runtime-DOWgnTkX.js +191 -0
- package/dist/runtime-DObmMc6X.js +253 -0
- package/dist/runtime-DoFRWRgY.js +9 -0
- package/dist/runtime-Dt-rXRTW.js +2 -0
- package/dist/runtime-api-BtobjiSx.js +12 -0
- package/dist/runtime-api-CjjNrjOu2.js +2 -0
- package/dist/runtime-api-D7fKSLcI.js +3 -0
- package/dist/runtime-embedded-pi.runtime-2nLOBaP4.js +3 -0
- package/dist/runtime-embedded-pi.runtime.js +1 -1
- package/dist/runtime-internal-BBIguEmO.js +2 -0
- package/dist/runtime-model-auth.runtime-Cgx5HiVv.js +39 -0
- package/dist/runtime-model-auth.runtime.js +1 -1
- package/dist/runtime-oxFh0OA-.js +2 -0
- package/dist/runtime-plugins-zeEZH6Ee.js +69 -0
- package/dist/runtime-prepare.runtime-C1hoi3Pj.js +80 -0
- package/dist/runtime-prepare.runtime.js +1 -1
- package/dist/runtime-provider-CXi4BTPW.js +21 -0
- package/dist/runtime-r3Ke_KuH.js +200 -0
- package/dist/runtime-registry-loader-471RbKgH.js +2 -0
- package/dist/runtime-registry-loader-Dov85dVR.js +58 -0
- package/dist/runtime-schema-DUetufoV.js +28395 -0
- package/dist/runtime-shared-BGttaPX3.js +249 -0
- package/dist/runtime-taskflow-CXpDzGWH.js +250 -0
- package/dist/runtime-web-channel-plugin-Dyt-ZWxm.js +215 -0
- package/dist/runtime-web-tools-CXeVnAOE.js +1467 -0
- package/dist/runtime-web-tools-fallback.runtime-B5P96RjD.js +9 -0
- package/dist/runtime-web-tools-fallback.runtime.js +1 -1
- package/dist/sandbox-B7Mdkad9.js +2586 -0
- package/dist/sandbox-Bkj7NfH_.js +4 -0
- package/dist/sandbox-cli-BMrDh7ip.js +447 -0
- package/dist/secrets-cli-CDO_S3rr.js +2114 -0
- package/dist/security-audit-D4tdLi7R.js +34 -0
- package/dist/security-cli-BtMEiNIM.js +486 -0
- package/dist/semantic-dedup-BGgf2SFR.js +95 -0
- package/dist/send-C5pIHqBv.js +993 -0
- package/dist/send-media-Dcmyu6Y-.js +2123 -0
- package/dist/server-D0ZKpih4.js +77 -0
- package/dist/server-context-BekzVd0R.js +4164 -0
- package/dist/server-iDg2UFb7.js +13 -0
- package/dist/server-methods-MPVSmE3_.js +11937 -0
- package/dist/server-middleware-FqXPNqqT.js +110 -0
- package/dist/server-node-events-C1iGhswC.js +451 -0
- package/dist/server.impl-CFp5ICor.js +19766 -0
- package/dist/session-C-0F1BlP.js +48 -0
- package/dist/session-conversation-Ckza03tl.js +27 -0
- package/dist/session-cost-usage-Dnbtqvv7.js +648 -0
- package/dist/session-cost-usage-iTVG22AO.js +2 -0
- package/dist/session-file-CiJXAZP4.js +44 -0
- package/dist/session-key-6G1LpIon.js +65 -0
- package/dist/session-meta-knhthO95.js +109 -0
- package/dist/session-override-CGqy8cfR.js +103 -0
- package/dist/session-reset-model.runtime-VxsiNT-r.js +120 -0
- package/dist/session-reset-model.runtime.js +1 -1
- package/dist/session-reset-service-6oOKZMC9.js +474 -0
- package/dist/session-subagent-reactivation.runtime-DzMHk0SH.js +2 -0
- package/dist/session-subagent-reactivation.runtime.js +1 -1
- package/dist/session-system-events-BifSkL6x.js +63 -0
- package/dist/session-tab-registry-DR0gRhet.js +553 -0
- package/dist/session-updates-CHOc_4vH.js +234 -0
- package/dist/session-updates.runtime-DsHKjhyM.js +2 -0
- package/dist/session-updates.runtime.js +1 -1
- package/dist/session-utils-GLg54NBi.js +930 -0
- package/dist/sessions-BxOkBx-e.js +45 -0
- package/dist/sessions-C6oolVsU.js +231 -0
- package/dist/sessions-D6_b32XT.js +2 -0
- package/dist/sessions.runtime-Dtv72AMI.js +2 -0
- package/dist/sessions.runtime.js +1 -1
- package/dist/setup-DOX0TZju.js +505 -0
- package/dist/setup-DwqTuGTp.js +329 -0
- package/dist/setup-surface-Ore2Ehcn.js +586 -0
- package/dist/setup.finalize-hAPbyOmw.js +436 -0
- package/dist/setup.gateway-config-DteoOy8F.js +246 -0
- package/dist/shared-CLjMam2L.js +36 -0
- package/dist/shared-DGIkRU6J.js +218 -0
- package/dist/shared-DUnO9yTD.js +175 -0
- package/dist/shared-DeBJWig-.js +137 -0
- package/dist/shared-igYZ1cFQ.js +224 -0
- package/dist/shared-runtime-cWVnVIl5.js +7 -0
- package/dist/short-term-promotion-BhxerFzv.js +1631 -0
- package/dist/simple-completion-runtime-Bv1VtWSA.js +131 -0
- package/dist/simple-completion-transport-CLqa5Iyl.js +32 -0
- package/dist/skill-commands-D02-U6zf.js +82 -0
- package/dist/skill-commands.runtime-J2XiyESs.js +2 -0
- package/dist/skill-commands.runtime.js +1 -1
- package/dist/skills-BI8fjdW_.js +4 -0
- package/dist/skills-C6n71k5r.js +1075 -0
- package/dist/skills-cli-zp3lOjti.js +382 -0
- package/dist/skills-install-DlqA6nec.js +822 -0
- package/dist/skills-status-B57B5p12.js +170 -0
- package/dist/skills-status-DSk7-Gbk.js +2 -0
- package/dist/soul-cli-D_VMWljI.js +110 -0
- package/dist/speech-core-5C9NDTWw.js +126 -0
- package/dist/speech-provider-5npDU3CX.js +103 -0
- package/dist/speech-provider-B-nDtAnq.js +182 -0
- package/dist/speech-provider-BgLqt9Ul.js +184 -0
- package/dist/speech-provider-DAxRZc2f.js +167 -0
- package/dist/stage-sandbox-media.runtime-CFdAVxo8.js +230 -0
- package/dist/stage-sandbox-media.runtime.js +1 -1
- package/dist/standalone-generate-BG6TQ0jK.js +217 -0
- package/dist/standalone-generate-CgZQCsuI.js +2 -0
- package/dist/startup-auth-CKh--SuD.js +151 -0
- package/dist/state-migrations-CN7oRMHd.js +823 -0
- package/dist/status-BAqccuUp.js +278 -0
- package/dist/status-BaSW-xxu.js +2 -0
- package/dist/status-CAODeWKS.js +3 -0
- package/dist/status-CJpxvQmZ.js +500 -0
- package/dist/status-KOZpSuVN.js +2 -0
- package/dist/status-TqK4AoMQ.js +473 -0
- package/dist/status-all-DNG9crv3.js +495 -0
- package/dist/status-evx_KM_Z.js +399 -0
- package/dist/status-json-CT6-w9e9.js +14 -0
- package/dist/status-json-command-sAasGH5G.js +92 -0
- package/dist/status-runtime-shared-DTGujn3T.js +271 -0
- package/dist/status.command.text-runtime-CugrZfYj.js +15 -0
- package/dist/status.gateway-connection.runtime-kuu5mcJa.js +2 -0
- package/dist/status.gateway-connection.runtime.js +1 -1
- package/dist/status.gateway-probe-DNRjTzrV.js +16 -0
- package/dist/status.scan-overview-BjX4TLdw.js +395 -0
- package/dist/status.scan-rcGDJYtU.js +62 -0
- package/dist/status.scan.deps.runtime-CvmH94mX.js +18 -0
- package/dist/status.scan.deps.runtime.js +1 -1
- package/dist/status.scan.fast-json-BJv_9gqh.js +128 -0
- package/dist/status.scan.fast-json-DKOmheDO.js +2 -0
- package/dist/status.scan.runtime-BRjuY3QE.js +417 -0
- package/dist/status.scan.runtime.js +1 -1
- package/dist/status.summary-Bxs_2k1b.js +2 -0
- package/dist/status.summary-Dag8_BJw.js +209 -0
- package/dist/store-BCDEVRXR.js +1112 -0
- package/dist/store-C6poa5Og.js +1075 -0
- package/dist/store-DxQRR8Va.js +424 -0
- package/dist/store.runtime-D6t_wvEo.js +2 -0
- package/dist/store.runtime.js +1 -1
- package/dist/stream-CxAFhAae.js +649 -0
- package/dist/stream-wrappers-BALQapyz.js +144 -0
- package/dist/subagent-announce.registry.runtime-C55O0bdZ.js +3 -0
- package/dist/subagent-announce.registry.runtime.js +1 -1
- package/dist/subagent-control-CoVHKnJF.js +485 -0
- package/dist/subagent-followup.runtime-9Gmh8O_s.js +68 -0
- package/dist/subagent-followup.runtime.js +1 -1
- package/dist/subagent-list-BPsxOWK_.js +168 -0
- package/dist/subagent-orphan-recovery-BCcEet7k.js +214 -0
- package/dist/subagent-registry-DfHx9pew.js +2889 -0
- package/dist/subagent-registry-runtime-B_Mc7UDa.js +2 -0
- package/dist/subagent-registry.runtime-gOuSIzDg.js +3 -0
- package/dist/subagent-registry.runtime.js +1 -1
- package/dist/subagent-spawn-BOLGVu7f.js +782 -0
- package/dist/subagents-format-DXuyOMu-.js +629 -0
- package/dist/system-cli-_jfrKryu.js +60 -0
- package/dist/targets-DKzJlbu6.js +595 -0
- package/dist/task-executor-DhjMRE2d.js +350 -0
- package/dist/task-owner-access-rwopIPhc.js +48 -0
- package/dist/task-registry-C6EQpySp.js +2346 -0
- package/dist/task-registry-control.runtime-t4jeMENC.js +3 -0
- package/dist/task-registry-control.runtime.js +1 -1
- package/dist/task-registry-delivery-runtime-BMfszrF8.js +2 -0
- package/dist/task-registry-delivery-runtime-D_Ocdg0_.js +3 -0
- package/dist/task-registry.maintenance-DNXaqTr4.js +2 -0
- package/dist/task-registry.maintenance-DqvsLuqb.js +425 -0
- package/dist/testing-CXEcd2QQ.js +441 -0
- package/dist/text-report-CUwo5L1k.js +587 -0
- package/dist/text-runtime-B3UrMt6T.js +313 -0
- package/dist/thread-bindings-BR0oLaqe.js +223 -0
- package/dist/tool-auth-shared-BwlRX_zo.js +53 -0
- package/dist/tool-config-shared-CThVi2Zv.js +19 -0
- package/dist/tool-schema-runtime-CiqxCMkH.js +1892 -0
- package/dist/tools-BUzk9uUn.js +110 -0
- package/dist/tools-effective-inventory-CMhZ6G55.js +152 -0
- package/dist/tools.runtime-D6GnPvuW.js +4 -0
- package/dist/tools.runtime.js +1 -1
- package/dist/transcript-kBzFcvfJ.js +233 -0
- package/dist/transcript.runtime-X5nUWG5J.js +2 -0
- package/dist/transcript.runtime.js +1 -1
- package/dist/transport-policy-qrbV7LdB.js +75 -0
- package/dist/tts-BW2-rTjx.js +31 -0
- package/dist/tui-Cnxy7MIi.js +4018 -0
- package/dist/tui-cli-COdAidhT.js +31 -0
- package/dist/update-cli-C62761SQ.js +1779 -0
- package/dist/update-runner-BY92EdE9.js +1492 -0
- package/dist/usage-format-CPx6tGPA.js +2 -0
- package/dist/usage-format-CpsXzXcG.js +507 -0
- package/dist/video-generation-provider-BKRHP8oO.js +171 -0
- package/dist/video-generation-provider-CCsVq0-G.js +263 -0
- package/dist/video-generation-provider-CPHXFGar.js +246 -0
- package/dist/video-generation-provider-DRMOwtTj.js +104 -0
- package/dist/video-generation-provider-DohNwNos.js +181 -0
- package/dist/video-generation-provider-DsIqJI0e.js +227 -0
- package/dist/video-generation-provider-Kg01Dy_G.js +233 -0
- package/dist/video-generation-provider-Z-xZjApd.js +240 -0
- package/dist/video-generation-provider-kfoZ8epM.js +64 -0
- package/dist/video-generation-provider-wgwFq2Wr.js +77 -0
- package/dist/web-fetch-providers.runtime-YHUYJGZL.js +33 -0
- package/dist/web-fetch-providers.runtime.js +1 -1
- package/dist/web-search-C0DUuJkz.js +221 -0
- package/dist/web-search-provider-BVISR8ti.js +155 -0
- package/dist/web-search-providers.runtime-BxK0HVx5.js +206 -0
- package/dist/web-search-providers.runtime.js +1 -1
- package/dist/webhooks-cli-CNvp2Osa.js +321 -0
- package/dist/x-search-shared-uvKOvvdl.js +109 -0
- package/dist/zod-schema-CgftpN_n.js +1401 -0
- package/docs/concepts/cognitive-overview.md +27 -12
- package/package.json +2 -1
- package/dist/abort-BA4i4CO6.js +0 -202
- package/dist/abort-cutoff.runtime-140Dy9Z_.js +0 -20
- package/dist/abort.runtime-D2xd_Jxq.js +0 -2
- package/dist/acp-cli-lUerPOt4.js +0 -2171
- package/dist/acp-spawn-CKu5HWZd.js +0 -1024
- package/dist/acp-stateful-target-driver-DNcDMame.js +0 -88
- package/dist/action-agents-bNO5zlxQ.js +0 -67
- package/dist/action-focus-BQH1yzA9.js +0 -124
- package/dist/action-help-Copk6G3d.js +0 -7
- package/dist/action-info-BUV_zoSU.js +0 -58
- package/dist/action-kill-BMDz9l_U.js +0 -33
- package/dist/action-list-CxkulhYF.js +0 -21
- package/dist/action-log-D0K9-YCV.js +0 -30
- package/dist/action-send-B8ggJVwC.js +0 -39
- package/dist/action-spawn-D9kSXA_K.js +0 -46
- package/dist/action-unfocus-bI4VBonB.js +0 -28
- package/dist/agent-CdxQT19_.js +0 -2
- package/dist/agent-command-Bu_cXSEL.js +0 -1479
- package/dist/agent-runner-utils--p6HAP6k.js +0 -202
- package/dist/agent-runner.runtime-BossnlL1.js +0 -2825
- package/dist/agents-DA2-qNUI.js +0 -887
- package/dist/agents-DaKVGj9F.js +0 -5
- package/dist/anthropic-vertex-stream-CrF-fPgb.js +0 -5666
- package/dist/api-BPByI3-X.js +0 -2
- package/dist/api-BRJq6Aya.js +0 -2
- package/dist/api-BpAm-eRQ.js +0 -2
- package/dist/api-BvFPt7b2.js +0 -19
- package/dist/api-CSOm-O9I.js +0 -5
- package/dist/api-ChQfiSmG.js +0 -4
- package/dist/api-CqBQhm6r.js +0 -2
- package/dist/api-D7qSjVDS.js +0 -3
- package/dist/api-DbRoXBTn.js +0 -45
- package/dist/api-_HshnS5J.js +0 -35
- package/dist/apply-G86rau7x.js +0 -493
- package/dist/apply.runtime-BoYc09wu.js +0 -166
- package/dist/apply.runtime-Dmh02lO-.js +0 -2
- package/dist/approval-client-helpers-cyaJyAMz.js +0 -82
- package/dist/approval-gateway-resolver-bdX78er-.js +0 -58
- package/dist/approval-gateway-runtime-CJm68vrp.js +0 -2
- package/dist/approval-handler-runtime-CT08B2_a.js +0 -439
- package/dist/approval-native-runtime-CN4meUkM.js +0 -709
- package/dist/approval-renderers-CnmO8wke.js +0 -64
- package/dist/asr-Cz-FH-3c.js +0 -196
- package/dist/audit-Cbfv4nmn.js +0 -885
- package/dist/audit-extra.async-DQv_s9K0.js +0 -847
- package/dist/audit.deep.runtime-CAPtrWg1.js +0 -2
- package/dist/audit.nondeep.runtime-HUJ6INiD.js +0 -859
- package/dist/audit.runtime-CAKbHyXK.js +0 -7
- package/dist/auth-CRAwpkC_.js +0 -181
- package/dist/auth-choice-Bhps2D29.js +0 -3
- package/dist/auth-choice-kMIs0xTd.js +0 -71
- package/dist/auth-choice-options-Bx_XsiW-.js +0 -104
- package/dist/auth-choice-prompt-B-koxVGL.js +0 -2
- package/dist/auth-choice-prompt-DytHsI5U.js +0 -36
- package/dist/auth-choice-vRXPONqL.js +0 -353
- package/dist/auth-choice.plugin-providers.runtime-BNfpK_sp.js +0 -11
- package/dist/auth-health-BAxUQXZE.js +0 -165
- package/dist/auth-profiles-YXfmeEhu.js +0 -438
- package/dist/auth-profiles.runtime-CNNciZQU.js +0 -7
- package/dist/auto-recall-CsrNcQNa.js +0 -78
- package/dist/backup-create-DuIPhK_s.js +0 -391
- package/dist/banner-Bb9u_-IS.js +0 -2
- package/dist/banner-BkHTsqFt.js +0 -281
- package/dist/binding-routing-C6_mrNEN.js +0 -50
- package/dist/binding-targets-Cq2e7wRT.js +0 -99
- package/dist/bridge-server-Co3awCAM.js +0 -103
- package/dist/browser-config-runtime-BtkKPBMj.js +0 -6
- package/dist/browser-control-auth-Bqu1lakr.js +0 -120
- package/dist/browser-node-runtime-D8xut4fJ.js +0 -12
- package/dist/browser-profiles-gPG14SPk.js +0 -170
- package/dist/browser-runtime-BBkGI01q.js +0 -377
- package/dist/browser-setup-tools-CD_s48fd.js +0 -12
- package/dist/call-CiUZqjsN.js +0 -2
- package/dist/call-k_nZXTJ3.js +0 -495
- package/dist/call.runtime-CZI7yxSF.js +0 -2
- package/dist/capability-cli-CIm_YhHH.js +0 -1357
- package/dist/catalog-provider-Ch4CMHLl.js +0 -40
- package/dist/cdp.helpers-BVl3YwYe.js +0 -372
- package/dist/channel-core-BB7pTANC.js +0 -5
- package/dist/channel-summary-TxoZjGPA.js +0 -139
- package/dist/channel-summary-dKkFDRbe.js +0 -2
- package/dist/channel.runtime-2WY9MkoH.js +0 -399
- package/dist/channels-D66hRVnR.js +0 -1147
- package/dist/channels-cli-0DjAVaKh.js +0 -248
- package/dist/chat-Fv3LkEfF.js +0 -213
- package/dist/chrome-CEE9kYYR.js +0 -1080
- package/dist/chrome.executables-Dp7W-RgV.js +0 -550
- package/dist/cli-BsNkLoFI.js +0 -57
- package/dist/cli-DQH9X5IE.js +0 -2
- package/dist/cli-DW_ou4hw.js +0 -2
- package/dist/cli-DuoVlLKx.js +0 -154
- package/dist/cli-QG03g_im.js +0 -191
- package/dist/cli-auth-seam-BrijKBRQ.js +0 -14
- package/dist/cli-backend-CIs4F7ip.js +0 -66
- package/dist/cli-migration-CVktTGRI.js +0 -127
- package/dist/cli-runner-12iECISR.js +0 -1662
- package/dist/cli-runner.runtime-C5noDuQ-.js +0 -3
- package/dist/cli-runner.runtime-YrAg_h19.js +0 -2
- package/dist/cli-shared-BUW2okV2.js +0 -142
- package/dist/cli.runtime-Bhxt80sB.js +0 -819
- package/dist/client-bootstrap-BWo-ZK_j.js +0 -28
- package/dist/codex-native-web-search-C6s55zGf.js +0 -2
- package/dist/codex-native-web-search-Cxf1u7R-.js +0 -156
- package/dist/collector-CRTTihSY.js +0 -349
- package/dist/collector-tJxrYXuY.js +0 -2
- package/dist/command-auth-Dlrd5CYD.js +0 -75
- package/dist/command-config-resolution-B8pxzh3W.js +0 -2
- package/dist/command-config-resolution-BXSCDJTh.js +0 -23
- package/dist/command-execution-startup-DYXpKpvc.js +0 -269
- package/dist/command-format-JYoGhCek.js +0 -2
- package/dist/command-queue-CmX7XAL1.js +0 -260
- package/dist/command-registry-BF51N12E.js +0 -3
- package/dist/command-registry-BqpfCBbW.js +0 -113
- package/dist/command-secret-gateway-DuuctECr.js +0 -528
- package/dist/commands-acp-DiLJUV45.js +0 -1017
- package/dist/commands-compact.runtime-BOM8PsWH.js +0 -10
- package/dist/commands-core.runtime-CH_aGeT-.js +0 -2
- package/dist/commands-handlers.runtime-Ca6xoeW5.js +0 -3762
- package/dist/commands-models-CRURuXR-.js +0 -306
- package/dist/commands-reset-hooks-D3RzsOIn.js +0 -129
- package/dist/commands-status-Cufj4x2j.js +0 -223
- package/dist/commands-status.runtime-C8Nz4Glk.js +0 -2
- package/dist/commands-subagents-control.runtime-DjhcmoRT.js +0 -3
- package/dist/commands-subagents-control.runtime-s_DYQWfW.js +0 -2
- package/dist/commands.runtime-ChfYOBeV.js +0 -103
- package/dist/comment-shared-DFEZzqhH.js +0 -40
- package/dist/compact-DEsHFhEL.js +0 -11324
- package/dist/compact.runtime-BzLFUSmk.js +0 -7
- package/dist/completion-cli-CiWtzUFQ.js +0 -2
- package/dist/completion-cli-h3zgpXGM.js +0 -468
- package/dist/config-B3cxNRyw.js +0 -8
- package/dist/config-Bd1PtH4x.js +0 -166
- package/dist/config-DuLfQQvE.js +0 -53
- package/dist/config-cli-BiEmyiRa.js +0 -948
- package/dist/config-defaults-Bw9wwyo1.js +0 -163
- package/dist/config-guard-BGGjXg_Y.js +0 -94
- package/dist/config-runtime-Bvdi0W59.js +0 -14
- package/dist/config-validation-BDeuMlc1.js +0 -279
- package/dist/configure-CUSDnrHs.js +0 -2
- package/dist/configure-FDqT3i_9.js +0 -1162
- package/dist/connection-auth-7izNv08V.js +0 -30
- package/dist/context-B2wCjR9D.js +0 -249
- package/dist/context-n8ANhlMJ.js +0 -2
- package/dist/context-writer-COhxMkVz.js +0 -290
- package/dist/control-auth-Csa4b5CR.js +0 -122
- package/dist/control-ui/assets/agents-CYCtph5J.js +0 -767
- package/dist/control-ui/assets/anthropic-B66S-tt5.js +0 -40
- package/dist/control-ui/assets/azure-openai-responses-CRJyPvrW.js +0 -2
- package/dist/control-ui/assets/cron-DPaLQLTR.js +0 -744
- package/dist/control-ui/assets/dialogues-DPJy1B4C.js +0 -83
- package/dist/control-ui/assets/history-CT3DjMa7.js +0 -71
- package/dist/control-ui/assets/index-Ci2oc-eJ.css +0 -1
- package/dist/control-ui/assets/index-Ua-cFlP6.js +0 -2686
- package/dist/control-ui/assets/mistral-DWkPN1WM.js +0 -72
- package/dist/control-ui/assets/openai-codex-responses-CSJ_tbUW.js +0 -8
- package/dist/control-ui/assets/openai-completions-QUhkmdlC.js +0 -6
- package/dist/control-ui/assets/openai-responses-CjthZA3L.js +0 -2
- package/dist/control-ui/assets/openai-responses-shared-tozh4HQx.js +0 -13
- package/dist/conversation-id-d7KXWjzV.js +0 -140
- package/dist/conversation-runtime-D-YmpVS2.js +0 -31
- package/dist/core-8TPCsNB-.js +0 -210
- package/dist/cron-cli-C5ok2iVK.js +0 -637
- package/dist/curator-9KwCnpXG.js +0 -598
- package/dist/curator-t_jLT3Ie.js +0 -2
- package/dist/daemon-cli-Cr_y38yv.js +0 -476
- package/dist/daemon-install-CrhzPiZ-.js +0 -70
- package/dist/delegate-r3VqUt34.js +0 -61
- package/dist/deliver-Cuu36rnv.js +0 -3
- package/dist/deliver-SAyi_F0e.js +0 -782
- package/dist/deliver-runtime-DKv9J6QE.js +0 -2
- package/dist/delivery-outbound.runtime-DDoInTnF.js +0 -6
- package/dist/delivery-queue-CWi3kUit.js +0 -372
- package/dist/delivery-queue-ecSu6ZNL.js +0 -2
- package/dist/deps-BIU2SScd.js +0 -60
- package/dist/devices-cli-BUAuMOOj.js +0 -336
- package/dist/diagnostic-BLwuJXPT.js +0 -311
- package/dist/direct-dm-D_7_vKGq.js +0 -139
- package/dist/directive-handling.fast-lane-C91i_iZm.js +0 -2
- package/dist/directive-handling.fast-lane-F7l0XNwG.js +0 -64
- package/dist/directive-handling.impl-8RAWZiZE.js +0 -659
- package/dist/directive-handling.impl-BxAIWFS-.js +0 -2
- package/dist/directive-handling.parse-B3O0CfXY.js +0 -376
- package/dist/directive-handling.persist-QXt7GHcD.js +0 -139
- package/dist/directive-handling.persist.runtime-CPPm2qYQ.js +0 -2
- package/dist/directive-handling.shared-C5ywsGJd.js +0 -159
- package/dist/directory-cli-D9v1dSPr.js +0 -240
- package/dist/dispatch-DoyBs65s.js +0 -1126
- package/dist/dispatch-acp-Dz8rU6t9.js +0 -969
- package/dist/dispatch-acp-manager.runtime-tPUGDjl3.js +0 -3
- package/dist/dispatch-acp-media.runtime-rwYN3ewY.js +0 -3
- package/dist/dispatch-acp-session.runtime-C9nyGih8.js +0 -2
- package/dist/dispatch-acp.runtime-Co-JFuKU.js +0 -19
- package/dist/dns-cli-BRVJtnve.js +0 -193
- package/dist/docs-cli-DvJd--iI.js +0 -156
- package/dist/doctor-completion-C46W5KI7.js +0 -90
- package/dist/doctor-config-preflight-B_UDrFsE.js +0 -148
- package/dist/doctor-config-preflight-DtvhOeuT.js +0 -2
- package/dist/doctor-state-migrations-Cd3yfnI1.js +0 -2
- package/dist/doctor-state-migrations-D3qorqjy.js +0 -3
- package/dist/drive-C2mxxJx5.js +0 -718
- package/dist/embedding-provider-C5S1sxvR.js +0 -129
- package/dist/embedding-provider-CNDA2uD3.js +0 -26
- package/dist/embedding-provider-CdVS1B85.js +0 -33
- package/dist/engine-CKgZ1obQ.js +0 -82
- package/dist/engine-embeddings-Bt1bTxtw.js +0 -1489
- package/dist/entry-capabilities-DrciJZn1.js +0 -89
- package/dist/env-overrides-DTd6EBBV.js +0 -347
- package/dist/env-overrides.runtime-Dxy8Shg7.js +0 -7
- package/dist/exec-approval-forwarder.runtime-Dpa8Gi_P.js +0 -3
- package/dist/exec-approval-reply-BaUWuhD6.js +0 -292
- package/dist/exec-approvals-cli-BuOJPaPp.js +0 -485
- package/dist/exec-defaults-B5egc-6t.js +0 -1440
- package/dist/extra-params-Bfdm7Piq.js +0 -295
- package/dist/format-KzNAm6y6.js +0 -245
- package/dist/fragment-collector-DEW1fwlc.js +0 -189
- package/dist/gateway-cli-CWHsIpm8.js +0 -1532
- package/dist/gateway-install-token-CcpoWcqs.js +0 -284
- package/dist/gateway-rpc-Do_3fQSm.js +0 -14
- package/dist/gateway-rpc.runtime-C4kzyrJj.js +0 -23
- package/dist/gemini-cli-provider-YULRMcs8.js +0 -106
- package/dist/gemini-web-search-provider-D_QJZMM3.js +0 -167
- package/dist/get-reply-from-config.runtime-BpdriKtr.js +0 -2
- package/dist/gmail-setup-utils-D_e1q-h_.js +0 -422
- package/dist/health-B5YmS_bW.js +0 -2
- package/dist/health-CQ4zXQ-2.js +0 -579
- package/dist/heartbeat-runner--rVDmB2Z.js +0 -1365
- package/dist/heartbeat-runner-CwtXIPI-.js +0 -4
- package/dist/heartbeat-runner.runtime-D_5UeAsX.js +0 -2
- package/dist/help-CAj5xloH.js +0 -76
- package/dist/hooks-cli-BGDBJqzt.js +0 -364
- package/dist/image-DiK7kcmJ.js +0 -152
- package/dist/image-generation-core-Cwutmg_V.js +0 -17
- package/dist/image-generation-core.auth.runtime-DA7XD5V2.js +0 -2
- package/dist/image-generation-provider-B-0SxnvJ.js +0 -280
- package/dist/image-generation-provider-B-UW3NU_.js +0 -94
- package/dist/image-generation-provider-BR1_oIU4.js +0 -130
- package/dist/image-generation-provider-CnGMLnE9.js +0 -163
- package/dist/image-generation-provider-DHvw6TSJ.js +0 -136
- package/dist/image-generation-runtime-DCWf9P6F.js +0 -2
- package/dist/image-runtime-DGNzvqkb.js +0 -7
- package/dist/inbound-reply-dispatch-DgEqNffL.js +0 -73
- package/dist/inbound.runtime-CloYEZJO.js +0 -4
- package/dist/inbound.runtime-DLbKJWOY.js +0 -3
- package/dist/infra-runtime-DE-Vi3Dn.js +0 -25
- package/dist/ingest-DbZJju1a.js +0 -842
- package/dist/ingest-Dyj9M3ZM.js +0 -2
- package/dist/io-Bz-M35LC.js +0 -7184
- package/dist/io-DacBLjh1.js +0 -5
- package/dist/kaijibot-tools-Df_9YJcO.js +0 -9434
- package/dist/kaijibot-tools.runtime-CZId-V1O.js +0 -2
- package/dist/kimi-web-search-provider-DunVVASJ.js +0 -308
- package/dist/library-BqMFzJMy.js +0 -45
- package/dist/lifecycle-core-DD_IXtH-.js +0 -422
- package/dist/lifecycle-lZ5BtT_X.js +0 -57
- package/dist/list.runtime-DU0ctAjd.js +0 -12
- package/dist/list.runtime-DXWlaAJq.js +0 -9
- package/dist/llm-engine-CMR9RxLA.js +0 -1792
- package/dist/llm-engine-VKRjaGY_.js +0 -2
- package/dist/llm-extractor-BCPvoWmb.js +0 -445
- package/dist/load-context-DV3B4twI.js +0 -51
- package/dist/logging-BMNGvpuz.js +0 -13
- package/dist/logging-CN3VAZ70.js +0 -2
- package/dist/login-Dex1JqnY.js +0 -108
- package/dist/logs-cli-BZFJyrsk.js +0 -264
- package/dist/logs-cli.runtime-bBS2Sbi6.js +0 -2
- package/dist/manager-BmS2ofc4.js +0 -2049
- package/dist/manager-CabVEPeE.js +0 -3314
- package/dist/mcp-cli-DGrmbpsu.js +0 -733
- package/dist/mcp-config-CY_3tJVi.js +0 -115
- package/dist/media-runtime-CAa8uHqv.js +0 -312
- package/dist/media-understanding-D_VRj6xY.js +0 -83
- package/dist/media-understanding-provider-B9Jfjq6L.js +0 -13
- package/dist/media-understanding-provider-BWksuEBw.js +0 -30
- package/dist/media-understanding-provider-Bhtq5Kpe.js +0 -14
- package/dist/media-understanding-provider-BzsmDAMk.js +0 -67
- package/dist/media-understanding-provider-C6_6yxvP.js +0 -123
- package/dist/media-understanding-provider-CdRlAb9s.js +0 -18
- package/dist/media-understanding-provider-D5m-2RW8.js +0 -21
- package/dist/media-understanding-provider-PmVmfI6p.js +0 -112
- package/dist/media-understanding-provider-cmLTPd8x.js +0 -18
- package/dist/media-understanding-provider-nPxfFv8l.js +0 -37
- package/dist/media-understanding-provider-yp9gxov6.js +0 -69
- package/dist/media-understanding-runtime-Bu7m-lVs.js +0 -2
- package/dist/memory-5jlpYBqx.js +0 -242
- package/dist/memory-BFKl6oSn.js +0 -3
- package/dist/memory-core-host-engine-embeddings-p06288xV.js +0 -2
- package/dist/memory-core-host-engine-foundation-DHbdNLgZ.js +0 -11
- package/dist/memory-core-host-runtime-cli-BnvAiNzO.js +0 -9
- package/dist/memory-core-host-runtime-core-CnVg69Uw.js +0 -8
- package/dist/memory-embedding-adapter-Cux48Bvk.js +0 -33
- package/dist/memory-host-search.runtime-D6ORyqHq.js +0 -2
- package/dist/memory-index-DSbV_yD0.js +0 -2
- package/dist/memory-index-EFkCRTeh.js +0 -514
- package/dist/memory-runtime-BKqNwQ9X.js +0 -2
- package/dist/memory-runtime-Cn41W0bC.js +0 -26
- package/dist/message-CMCdNyAT.js +0 -223
- package/dist/message-action-runner-CG2CcWaS.js +0 -1628
- package/dist/message-action-runner-DUZQ7nmt.js +0 -2
- package/dist/message.config.runtime-B3ztIjsr.js +0 -3
- package/dist/message.gateway.runtime-COLMRCv4.js +0 -2
- package/dist/metadata-registry-loader-BSyFpHop.js +0 -15
- package/dist/metadata-registry-loader-Ci3mcmNV.js +0 -2
- package/dist/minimax-vlm-D1DbVSjC.js +0 -183
- package/dist/minimax-web-search-provider-BzgvahXM.js +0 -165
- package/dist/mmr-Clamw4uq.js +0 -146
- package/dist/model-CJIbRRp9.js +0 -630
- package/dist/model-auth-BQpkMtoP.js +0 -427
- package/dist/model-auth-label-dLSkL9EI.js +0 -45
- package/dist/model-catalog-DgqowW_L.js +0 -204
- package/dist/model-definitions-BOTIDDWJ.js +0 -258
- package/dist/model-picker-B4SuA28P.js +0 -3
- package/dist/model-picker-buwrc8kM.js +0 -500
- package/dist/model-picker.runtime-DXgS2Rab.js +0 -15
- package/dist/model-selection-CBuo2hSg.js +0 -381
- package/dist/model-suppression-CthTVW_x.js +0 -28
- package/dist/model-suppression.runtime-R-qnGNBa.js +0 -7
- package/dist/models-B3UnmjRf.js +0 -18
- package/dist/models-BucP8NI1.js +0 -760
- package/dist/models-C3w7hz3K.js +0 -18
- package/dist/models-C4-eAnR7.js +0 -157
- package/dist/models-DMLYOe4h.js +0 -2
- package/dist/models-DNNfkS3j.js +0 -2584
- package/dist/models-DkiHZi9S.js +0 -47
- package/dist/models-OhM18fW_.js +0 -555
- package/dist/models-cli-CfvtZXPd.js +0 -198
- package/dist/models-config-BLMZzgfx.js +0 -900
- package/dist/models-config.providers.secrets-rjdH8T5l.js +0 -299
- package/dist/models.fetch-D1o7sMO8.js +0 -518
- package/dist/monitor-CJdL31iS.js +0 -4435
- package/dist/monitor-DB732mUY.js +0 -1023
- package/dist/music-generation-provider-BrUTQBmG.js +0 -169
- package/dist/music-generation-provider-D6aYWSSm.js +0 -238
- package/dist/music-generation-provider-dpX_Oiuw.js +0 -142
- package/dist/node-cli-BSrC37hh.js +0 -2374
- package/dist/nodes-cli-uwgDIsqv.js +0 -1046
- package/dist/nodes-utils-ChvZvxK1.js +0 -196
- package/dist/notify-C9-q0Rdu.js +0 -305
- package/dist/oauth-CVAbqwnx.js +0 -152
- package/dist/oauth-RbN-L8pg.js +0 -57
- package/dist/oauth-token-shared-CCzflFLG.js +0 -28
- package/dist/oauth.credentials-BeCOUsTe.js +0 -165
- package/dist/oauth.flow-C2PFyq_h.js +0 -122
- package/dist/oauth.settings-CBmYrmAk.js +0 -44
- package/dist/oauth.token-DSow_5Ie.js +0 -43
- package/dist/onboard-B-ZJptUZ.js +0 -25
- package/dist/onboard-Beu-mw_-.js +0 -29
- package/dist/onboard-BzUrcgZ5.js +0 -25
- package/dist/onboard-CPuf8esc.js +0 -25
- package/dist/onboard-CTfex1XR2.js +0 -58
- package/dist/onboard-D-ccZlbM.js +0 -312
- package/dist/onboard-DHXNhsF7.js +0 -621
- package/dist/onboard-custom-9KIp_ybR.js +0 -647
- package/dist/onboard-custom-CbXUFVN6.js +0 -2
- package/dist/onboard-helpers-BFknCN7m.js +0 -223
- package/dist/onboard-helpers-DSJ_xWpL.js +0 -5
- package/dist/onboard-remote-C28pAu4b.js +0 -193
- package/dist/onboard-remote-DQxyE18D.js +0 -2
- package/dist/onboard-search-CPHGVmos.js +0 -324
- package/dist/onboard-skills-B642NK1o.js +0 -2
- package/dist/onboard-skills-CI4B6Kx5.js +0 -134
- package/dist/openai-codex-auth-identity-PqpqYz4a.js +0 -45
- package/dist/openai-codex-cli-auth-cFTkwXjR.js +0 -57
- package/dist/openai-codex-provider-DjUpM_l9.js +0 -299
- package/dist/openai-codex-shared-o0pq7UkS.js +0 -6
- package/dist/openai-provider-ChZN4Q0c.js +0 -283
- package/dist/openai-transport-stream-DXBBlxJ9.js +0 -1632
- package/dist/operator-approvals-client-RJESCyw4.js +0 -68
- package/dist/order-D863tCt-.js +0 -794
- package/dist/pair-command-approve-5Jr6xo-1.js +0 -34
- package/dist/pairing-cli-BF3jieZo.js +0 -118
- package/dist/persistent-bindings.lifecycle-CjXEQUMz.js +0 -94
- package/dist/pi-bundle-mcp-tools-DPVGNVRw.js +0 -709
- package/dist/pi-embedded-Cp3OIZy9.js +0 -2
- package/dist/pi-embedded-DJN2vlNF.js +0 -6
- package/dist/pi-embedded-runner-DXHhhGRS.js +0 -8348
- package/dist/pi-embedded-subscribe.handlers.compaction.runtime-D1jUEg-R.js +0 -23
- package/dist/pi-embedded.runtime-DQPfEvkF.js +0 -5
- package/dist/pi-model-discovery-B9q9ykaA.js +0 -232
- package/dist/pi-tools.before-tool-call.runtime-vGvkJ6V9.js +0 -354
- package/dist/plugin-enabled-CMdiRqJS.js +0 -71
- package/dist/plugin-install-config-policy-32D2JJMl.js +0 -137
- package/dist/plugin-registration-BhPJI7wp.js +0 -23
- package/dist/plugin-registry-Bo4RF_Fn.js +0 -2
- package/dist/plugin-registry-C4M8QkVh.js +0 -3
- package/dist/plugin-registry-loader-ZzUapRh3.js +0 -22
- package/dist/plugin-service-31XQtuZr.js +0 -2494
- package/dist/plugins-cli-20A8dYUN.js +0 -576
- package/dist/plugins-command-helpers-C3Qls10N.js +0 -117
- package/dist/plugins-install-persist-DEr-zA4G.js +0 -121
- package/dist/plugins-update-command-D0Iv4BPb.js +0 -1009
- package/dist/policy-BEVsx7jw.js +0 -172
- package/dist/preemptive-compaction-DlRJt7Zq.js +0 -430
- package/dist/proactive-scheduler-B3w5rW0h.js +0 -1444
- package/dist/probe-CCTEVLB2.js +0 -54
- package/dist/probe-DcSW0ngD.js +0 -426
- package/dist/probe-auth-C7DjgU_m.js +0 -69
- package/dist/probe-auth-Cfwc8qaj.js +0 -3
- package/dist/profiles-BYudUysD.js +0 -117
- package/dist/program-E_Dt_QTp.js +0 -111
- package/dist/prompt-overlay-DsEnjhTn.js +0 -72
- package/dist/prompt-select-styled-Dtw90p2J.js +0 -5305
- package/dist/provider-api-key-auth-CerNsquw.js +0 -113
- package/dist/provider-api-key-auth.runtime-B0BpFkRm.js +0 -14
- package/dist/provider-auth-DwgUXcgu.js +0 -36
- package/dist/provider-auth-api-key-BQfXwqgU.js +0 -5
- package/dist/provider-auth-choice-BKxMQwxd.js +0 -134
- package/dist/provider-auth-choice-preference-DeDdHlsY.js +0 -62
- package/dist/provider-auth-choice.runtime-BJxc73Ex.js +0 -2
- package/dist/provider-auth-choice.runtime-DBcrr0Ab.js +0 -14
- package/dist/provider-auth-guidance-Cqo9An-I.js +0 -34
- package/dist/provider-auth-helpers-r9kVb6L3.js +0 -168
- package/dist/provider-catalog-CjNAbR9b.js +0 -12
- package/dist/provider-catalog-CpTP4D3p.js +0 -56
- package/dist/provider-catalog-D1iJW59q.js +0 -11
- package/dist/provider-catalog-Dc48HHhB.js +0 -11
- package/dist/provider-catalog-jKq2UIeG.js +0 -17
- package/dist/provider-catalog-pmlFBXYr.js +0 -26
- package/dist/provider-dispatcher-Dl07uV70.js +0 -22
- package/dist/provider-entry-DkwXZuZY.js +0 -97
- package/dist/provider-flow-CmI4jkWV.js +0 -66
- package/dist/provider-iVtrs6XY.js +0 -70
- package/dist/provider-models-BXMZj2p1.js +0 -119
- package/dist/provider-models-Bq_MZ0xR.js +0 -35
- package/dist/provider-models-CsUYkHTw.js +0 -116
- package/dist/provider-registration-DkqLtXSj.js +0 -57
- package/dist/provider-registration-vrLHkywc.js +0 -238
- package/dist/provider-runtime-C_ebc-4l.js +0 -2
- package/dist/provider-runtime-Czioyn5w.js +0 -366
- package/dist/provider-runtime.runtime-lPuF4lqy.js +0 -26
- package/dist/provider-self-hosted-setup-Bjk91HZ7.js +0 -249
- package/dist/provider-setup-hUbxRciz.js +0 -2
- package/dist/provider-stream-DTbeHqKf.js +0 -285
- package/dist/provider-stream-family-Cz7SHqeS.js +0 -2
- package/dist/provider-usage-4x0im5xP.js +0 -3
- package/dist/provider-usage-CdkW3Bkb.js +0 -289
- package/dist/provider-wizard-BPkIa2bk.js +0 -166
- package/dist/providers.runtime-CawuCJXc.js +0 -125
- package/dist/proxy-stream-wrappers-BcJuaE24.js +0 -480
- package/dist/push-apns-CO3sqbX3.js +0 -1061
- package/dist/pw-ai-DEf5tZLp.js +0 -2268
- package/dist/qmd-manager-CrqmeTuY.js +0 -1799
- package/dist/qr-cli-g_Pkqstu.js +0 -359
- package/dist/qr-image-DcG1bUox.js +0 -2
- package/dist/queue-BveCZpTb.js +0 -636
- package/dist/realtime-provider-shared-BIili3oc.js +0 -21
- package/dist/realtime-transcription-provider-DqEHy_Jr.js +0 -180
- package/dist/realtime-voice-provider-Dau1KlKK.js +0 -342
- package/dist/record-shared-CC55xbFE.js +0 -10
- package/dist/refresh-BXJ80ji4.js +0 -115
- package/dist/region-CPFmncMW.js +0 -74
- package/dist/register.agent-D5el253o.js +0 -241
- package/dist/register.backup-CBhoChp-.js +0 -234
- package/dist/register.configure-DeqUaelp.js +0 -15
- package/dist/register.maintenance-Dv5x9ZE6.js +0 -443
- package/dist/register.message-e2Pbh8A_.js +0 -601
- package/dist/register.onboard-COuTKpAw.js +0 -83
- package/dist/register.runtime-BjOIl4eF.js +0 -81
- package/dist/register.runtime-BzJ6RkQN.js +0 -343
- package/dist/register.setup-DQYY7K4K.js +0 -104
- package/dist/register.status-health-sessions-CXNGQh_O.js +0 -1211
- package/dist/register.subclis-B6uy_ogx.js +0 -232
- package/dist/register.subclis-Cmdrfiej.js +0 -3
- package/dist/repair-C8v1vNU-.js +0 -112
- package/dist/replay-policy-C6igC4nS.js +0 -8
- package/dist/reply-Bd8ShNWW.js +0 -3523
- package/dist/reply.runtime-ByKwE5dg.js +0 -2
- package/dist/resolve-CSTOvc_c.js +0 -280
- package/dist/restart-C0QhPXk1.js +0 -454
- package/dist/root-help-D2vz4lbV.js +0 -44
- package/dist/route-reply-CXZFXlfK.js +0 -141
- package/dist/route-reply.runtime-BK8V9NEg.js +0 -2
- package/dist/rpc-f0OkPaI1.js +0 -61
- package/dist/rpc.runtime-BQ78T_pB.js +0 -21
- package/dist/run-main-CkwrrhfI.js +0 -453
- package/dist/run-wait-B4pXPLkF.js +0 -118
- package/dist/runner-BSA9M_M9.js +0 -1497
- package/dist/runs-CEDW87Fd.js +0 -495
- package/dist/runtime-C18YgW822.js +0 -242
- package/dist/runtime-C3OJQ1Xd.js +0 -200
- package/dist/runtime-CDNVtwVk.js +0 -72
- package/dist/runtime-CMNHfJtF.js +0 -725
- package/dist/runtime-C_o_otMV.js +0 -355
- package/dist/runtime-CiJWy5Ce.js +0 -9
- package/dist/runtime-D8bLKXLh.js +0 -253
- package/dist/runtime-DM4z9RVx.js +0 -2
- package/dist/runtime-Di50Fr1z.js +0 -191
- package/dist/runtime-W3qG5LHM.js +0 -2
- package/dist/runtime-api-Bx7nlc4w.js +0 -12
- package/dist/runtime-api-DCNC_FTy2.js +0 -2
- package/dist/runtime-api-_Z8MjR0l.js +0 -3
- package/dist/runtime-embedded-pi.runtime-Cv0MW9ps.js +0 -3
- package/dist/runtime-internal-DclGtT-e.js +0 -2
- package/dist/runtime-model-auth.runtime-Bjl23_fr.js +0 -39
- package/dist/runtime-oEwr_zQb.js +0 -107
- package/dist/runtime-plugins-CwWhqXLJ.js +0 -69
- package/dist/runtime-prepare.runtime-Bi-YD5R-.js +0 -80
- package/dist/runtime-provider-CSEDbSxr.js +0 -21
- package/dist/runtime-registry-loader-CbbaZCXY.js +0 -58
- package/dist/runtime-registry-loader-kqiMFCUa.js +0 -2
- package/dist/runtime-schema-CDuvvU7B.js +0 -28383
- package/dist/runtime-shared-BxJFDFe6.js +0 -249
- package/dist/runtime-taskflow-RwpXng2l.js +0 -250
- package/dist/runtime-web-channel-plugin-Bw74Ar_q.js +0 -215
- package/dist/runtime-web-tools-CEaAGeYr.js +0 -1467
- package/dist/runtime-web-tools-fallback.runtime-DU8Hp_QZ.js +0 -9
- package/dist/sandbox-BC2XUWcW.js +0 -4
- package/dist/sandbox-cli-ain0MYTB.js +0 -447
- package/dist/sandbox-epLgxWBQ.js +0 -2586
- package/dist/secrets-cli-iLwRZbRt.js +0 -2114
- package/dist/security-audit-DfrokBuq.js +0 -34
- package/dist/security-cli-BqsMM550.js +0 -486
- package/dist/semantic-dedup-BBpIPaSV.js +0 -95
- package/dist/send-C5LHdZqP.js +0 -993
- package/dist/send-media-Df0E2Z_m.js +0 -2123
- package/dist/server-2CD2yd73.js +0 -13
- package/dist/server-B44RMlVT.js +0 -77
- package/dist/server-context-SulhWpXY.js +0 -4164
- package/dist/server-methods-BPzzX5VC.js +0 -11937
- package/dist/server-middleware-WQzQIrD4.js +0 -110
- package/dist/server-node-events-Ug_Atc7G.js +0 -451
- package/dist/server.impl-InfVdwPj.js +0 -19765
- package/dist/session-B5RmIL21.js +0 -48
- package/dist/session-conversation-CFty7VTc.js +0 -27
- package/dist/session-cost-usage-CckjvorH.js +0 -2
- package/dist/session-cost-usage-DMRjhi4B.js +0 -648
- package/dist/session-file-DGJqy_ea.js +0 -44
- package/dist/session-key-D-jBcxEp.js +0 -65
- package/dist/session-meta-BijZlLS3.js +0 -109
- package/dist/session-override-1YQHEAlz.js +0 -103
- package/dist/session-reset-model.runtime-CEWrfXLr.js +0 -120
- package/dist/session-reset-service-Dphtb16d.js +0 -474
- package/dist/session-subagent-reactivation.runtime-CF4aqSpn.js +0 -2
- package/dist/session-system-events-BSVIh760.js +0 -63
- package/dist/session-tab-registry-DG9SGi0I.js +0 -553
- package/dist/session-updates-BRFvmIoC.js +0 -234
- package/dist/session-updates.runtime-CiHARWGr.js +0 -2
- package/dist/session-utils-Cai4P9ih.js +0 -930
- package/dist/sessions-BTcXDmCA.js +0 -2
- package/dist/sessions-CyYVTseV.js +0 -45
- package/dist/sessions-Fb0ep3uj.js +0 -231
- package/dist/sessions.runtime-BGyynSR4.js +0 -2
- package/dist/setup-CjEjg8Ci.js +0 -505
- package/dist/setup-D-ypxGnK.js +0 -329
- package/dist/setup-surface-QaubzT60.js +0 -586
- package/dist/setup.finalize-B3MWkUF9.js +0 -436
- package/dist/setup.gateway-config-BdK0tA_r.js +0 -246
- package/dist/shared-0JcWj8-R.js +0 -224
- package/dist/shared-BOd3OCF0.js +0 -36
- package/dist/shared-DICWV0-6.js +0 -218
- package/dist/shared-DiGX-JK8.js +0 -137
- package/dist/shared-DktX3NHd.js +0 -175
- package/dist/shared-runtime-BltNIfGY.js +0 -7
- package/dist/short-term-promotion-CT1zdD1r.js +0 -1631
- package/dist/simple-completion-runtime-CZyp8rJ3.js +0 -131
- package/dist/simple-completion-transport-BWyoXghG.js +0 -32
- package/dist/skill-commands-BC_2IdwF.js +0 -82
- package/dist/skill-commands.runtime-BP6BnOeq.js +0 -2
- package/dist/skills-BQX1AsbM.js +0 -4
- package/dist/skills-D7XPR8N-.js +0 -1075
- package/dist/skills-cli-CxmgxC7X.js +0 -382
- package/dist/skills-install-CHUWYiLs.js +0 -822
- package/dist/skills-status-DRTnP8E3.js +0 -170
- package/dist/skills-status-v28wm8HD.js +0 -2
- package/dist/soul-cli-B1-3BHbA.js +0 -110
- package/dist/speech-core-aXx4I3sB.js +0 -126
- package/dist/speech-provider-BTBQ5VOv.js +0 -103
- package/dist/speech-provider-BciszvJf.js +0 -184
- package/dist/speech-provider-BoQDEC_Y.js +0 -167
- package/dist/speech-provider-C-wTEx8k.js +0 -182
- package/dist/stage-sandbox-media.runtime-DhlTQjXA.js +0 -230
- package/dist/standalone-generate-BRvNW_O7.js +0 -2
- package/dist/standalone-generate-CDfZss4x.js +0 -217
- package/dist/startup-auth-B5V0AaIU.js +0 -151
- package/dist/state-migrations-BNib6l8O.js +0 -823
- package/dist/status-8clcfnN0.js +0 -473
- package/dist/status-C9YBVOov.js +0 -278
- package/dist/status-CNcOKUs2.js +0 -500
- package/dist/status-D1l9Tu3s.js +0 -399
- package/dist/status-DKth_wbp.js +0 -2
- package/dist/status-P3bvFirO.js +0 -3
- package/dist/status-TmH9qSMG.js +0 -2
- package/dist/status-all-BeyVXDNT.js +0 -495
- package/dist/status-json-Cj42CVZZ.js +0 -14
- package/dist/status-json-command-DWk5RiyN.js +0 -92
- package/dist/status-runtime-shared-orzti3tZ.js +0 -271
- package/dist/status.command.text-runtime-B-tNLc3T.js +0 -15
- package/dist/status.gateway-connection.runtime-BrkaJ2f5.js +0 -2
- package/dist/status.gateway-probe-BwuiZk1h.js +0 -16
- package/dist/status.scan-DegSjLE2.js +0 -62
- package/dist/status.scan-overview-CrSELCru.js +0 -395
- package/dist/status.scan.deps.runtime-DrUvBz4e.js +0 -18
- package/dist/status.scan.fast-json-Bm5lN6IK.js +0 -2
- package/dist/status.scan.fast-json-Ch2Zw813.js +0 -128
- package/dist/status.scan.runtime-D-LvzBYN.js +0 -417
- package/dist/status.summary-OB-43Bvk.js +0 -2
- package/dist/status.summary-gJukahkb.js +0 -209
- package/dist/store-D5JODeba.js +0 -421
- package/dist/store-D_vXZ7m9.js +0 -1112
- package/dist/store-yc7MvXdd.js +0 -1075
- package/dist/store.runtime-6eaZtPq6.js +0 -2
- package/dist/stream-BgcqyefI.js +0 -649
- package/dist/stream-wrappers-B7-5gN0i.js +0 -144
- package/dist/subagent-announce.registry.runtime-R2bop0gW.js +0 -3
- package/dist/subagent-control-UyMtkJwo.js +0 -485
- package/dist/subagent-followup.runtime-bTK0TymS.js +0 -68
- package/dist/subagent-list-c0JKZR0g.js +0 -168
- package/dist/subagent-orphan-recovery-CSEzwva5.js +0 -214
- package/dist/subagent-registry-Be219RP1.js +0 -2889
- package/dist/subagent-registry-runtime-Dk57Y91p.js +0 -2
- package/dist/subagent-registry.runtime-D6h_BK2i.js +0 -3
- package/dist/subagent-spawn-BeyYZuFf.js +0 -782
- package/dist/subagents-format-ZcZBg1Vh.js +0 -629
- package/dist/system-cli-_3czEwa7.js +0 -60
- package/dist/targets-CXrDP8_l.js +0 -595
- package/dist/task-executor-DNUNtRg8.js +0 -350
- package/dist/task-owner-access--E5Vkg9U.js +0 -48
- package/dist/task-registry-COE-B6MO.js +0 -2346
- package/dist/task-registry-control.runtime-BzsTfRw1.js +0 -3
- package/dist/task-registry-delivery-runtime-Cv6xz8KP.js +0 -2
- package/dist/task-registry-delivery-runtime-DSfcd2LA.js +0 -3
- package/dist/task-registry.maintenance-Bhd9abl9.js +0 -2
- package/dist/task-registry.maintenance-W3lTkY0l.js +0 -425
- package/dist/testing-CQ_-oCQB.js +0 -441
- package/dist/text-report-BgqWDKJR.js +0 -587
- package/dist/text-runtime-asv4kIxS.js +0 -313
- package/dist/thread-bindings-BCRWofo_.js +0 -223
- package/dist/tool-auth-shared-BWZwTobX.js +0 -53
- package/dist/tool-config-shared-BleK697I.js +0 -19
- package/dist/tool-schema-runtime-DZsW_KR4.js +0 -1892
- package/dist/tools-C7lv9rSD.js +0 -110
- package/dist/tools-effective-inventory-SB9JwX-y.js +0 -152
- package/dist/tools.runtime-J5rhfXQp.js +0 -4
- package/dist/transcript-DxWx6dVc.js +0 -233
- package/dist/transcript.runtime-CmBnobSv.js +0 -2
- package/dist/transport-policy-BGfaKNz0.js +0 -75
- package/dist/tts-C1GyTLOi.js +0 -31
- package/dist/tui-Cqdp1x16.js +0 -4018
- package/dist/tui-cli-BC4O3H6r.js +0 -31
- package/dist/update-cli-BzaCTuax.js +0 -1779
- package/dist/update-runner-Cvxezvhf.js +0 -1492
- package/dist/usage-format-DQTT4pqY.js +0 -507
- package/dist/usage-format-sR4xu0xw.js +0 -2
- package/dist/video-generation-provider-7YR4_ldd.js +0 -171
- package/dist/video-generation-provider-AlAZkYIW.js +0 -181
- package/dist/video-generation-provider-BEqi4pUJ.js +0 -104
- package/dist/video-generation-provider-CraaZaR7.js +0 -77
- package/dist/video-generation-provider-CuvO2Hzh.js +0 -246
- package/dist/video-generation-provider-D-t16ACe.js +0 -240
- package/dist/video-generation-provider-DeowxvLt.js +0 -233
- package/dist/video-generation-provider-HbOZ3qzI.js +0 -227
- package/dist/video-generation-provider-_apx1yFE.js +0 -263
- package/dist/video-generation-provider-bvpb6cdV.js +0 -64
- package/dist/web-fetch-providers.runtime-m66rypbB.js +0 -33
- package/dist/web-search-DSDz1iyf.js +0 -221
- package/dist/web-search-provider-DnYRRBVM.js +0 -155
- package/dist/web-search-providers.runtime-Cv56XIGr.js +0 -206
- package/dist/webhooks-cli-DQ_JTSNA.js +0 -321
- package/dist/x-search-shared-DKPdPR5_.js +0 -109
- package/dist/zod-schema-B7jQiHXQ.js +0 -1400
|
@@ -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-NwOu0Lqq.js";
|
|
14
|
+
import "./config-D_fICGrQ.js";
|
|
15
|
+
import { g as resolveMemoryFlushPlan } from "./memory-state-Cly_TwQt.js";
|
|
16
|
+
import { _ as resolveGroupSessionKey, c as updateSessionStore, l as updateSessionStoreEntry } from "./store-BCDEVRXR.js";
|
|
17
|
+
import "./sessions-BxOkBx-e.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-CBJu2_ft.js";
|
|
23
|
+
import { o as resolveContextTokensForModel } from "./context-CJMC7SyI.js";
|
|
24
|
+
import { a as resolveModelCostConfig, i as formatUsd, n as estimateUsageCost, r as formatTokenCount } from "./usage-format-CpsXzXcG.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-BlORGS1M.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-BCNvl8s6.js";
|
|
37
|
+
import { u as estimateMessagesTokens } from "./tool-schema-runtime-CiqxCMkH.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-DQbRPHSb.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-DlPDuhB1.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-fniCZ6ND.js";
|
|
50
|
+
import { n as routeReply, t as isRoutableChannel } from "./route-reply-Bsd_X1hM.js";
|
|
51
|
+
import { h as replyRunRegistry, m as createReplyOperation, p as ReplyRunAlreadyActiveError, s as queueEmbeddedPiMessage } from "./runs-Djzm6zWd.js";
|
|
52
|
+
import { a as ensureSandboxWorkspaceForSession } from "./sandbox-B7Mdkad9.js";
|
|
53
|
+
import { n as isLikelyExecutionAckPrompt, t as runEmbeddedPiAgent } from "./pi-embedded-runner-DvjFL5Sg.js";
|
|
54
|
+
import { o as resolveBootstrapWarningSignaturesSeen } from "./bootstrap-budget-zHsa4DnA.js";
|
|
55
|
+
import "./pi-embedded-BycqI-F6.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-BVQt0v1D.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-fBrjJUeq.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-CHOc_4vH.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 };
|