fengming 0.3.8 → 0.3.10
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/CHANGELOG.md +12 -0
- package/dist/abort-CCR8oZyg.js +277 -0
- package/dist/abort.runtime-eqx84NZa.js +2 -0
- package/dist/abort.runtime.js +1 -1
- package/dist/acp-spawn-BcDyvaXh.js +2 -0
- package/dist/acp-spawn-CCtSel-_.js +1286 -0
- package/dist/acp-stateful-target-driver-B3pCvuOV.js +89 -0
- package/dist/active-tool-schema-warnings-Cf-5q5WU.js +105 -0
- package/dist/active-tool-schema-warnings-Dzt3XE-y.js +2 -0
- package/dist/agent-1M2dVE2G.js +2 -0
- package/dist/agent-DLDIbUT4.js +1825 -0
- package/dist/agent-DZi6j3o6.js +3 -0
- package/dist/agent-command-ppfDBwET.js +1435 -0
- package/dist/agent-harness-runtime-C0bo62eY.d.ts +913 -0
- package/dist/agent-harness-runtime-RkTGiliR.js +207 -0
- package/dist/agent-runner-utils-B4YeVAO_.js +267 -0
- package/dist/agent-runner.runtime-T_3tlZN1.js +3784 -0
- package/dist/agent-runner.runtime.js +1 -1
- package/dist/agent-runtime-CloshyK-.d.ts +207 -0
- package/dist/agent-runtime-DZsmp1xr.js +199 -0
- package/dist/agent-tools-CET9usCz.js +2506 -0
- package/dist/agent-via-gateway-CZ0X0YkM.js +486 -0
- package/dist/agent-wait-dedupe-I81_F2tr.js +180 -0
- package/dist/agents/embedded-agent-runner/run/runtime-context-prompt.d.ts +1 -1
- package/dist/agents/embedded-agent-runner/tool-split.d.ts +1 -1
- package/dist/agents/model-catalog.runtime.d.ts +1 -1
- package/dist/api-BDB5xHYj.js +3 -0
- package/dist/api-BH7bfI5d.js +6 -0
- package/dist/api-BxJNXitd.js +2 -0
- package/dist/approval-client-helpers-CfQA9Jzh.d.ts +78 -0
- package/dist/approval-native-helpers-B2zyhxWc.d.ts +241 -0
- package/dist/approval-renderers-CMqSXyvm.d.ts +39 -0
- package/dist/assistant-Cu_Mzzgu.js +291 -0
- package/dist/attachment-normalize-Bb3v5iCC.js +213 -0
- package/dist/attempt-execution-BskbAq5I.js +584 -0
- package/dist/attempt-execution.runtime-BuT1wpNS.js +3 -0
- package/dist/attempt-execution.runtime.js +1 -1
- package/dist/attempt.prompt-helpers-ByKj-vQ7.js +543 -0
- package/dist/auto-reply/reply/commands-crestodian.d.ts +1 -1
- package/dist/binding-routing-EGRNvRC4.js +113 -0
- package/dist/binding-targets-B9vYS8n6.js +121 -0
- package/dist/bridge-server-DG9YtKQe.js +113 -0
- package/dist/browser-cli-B0Ou-Nbm.js +2 -0
- package/dist/browser-cli-GF25gL6M.js +230 -0
- package/dist/browser-cli-actions-input-CuER6RVe.js +522 -0
- package/dist/browser-cli-actions-observe-Dq-Zz_FA.js +81 -0
- package/dist/browser-cli-debug-7hvb49S1.js +137 -0
- package/dist/browser-cli-inspect-WU5KeWOK.js +117 -0
- package/dist/browser-cli-manage-B9D9BvSe.js +446 -0
- package/dist/browser-cli-resize-BUOusOPb.js +32 -0
- package/dist/browser-cli-shared-DmpSN-Qi.js +69 -0
- package/dist/browser-cli-state-D_YxTqRw.js +371 -0
- package/dist/browser-control-auth-Cqd1n9FA.js +2 -0
- package/dist/browser-profiles-9tQ05wYh.js +2 -0
- package/dist/browser-runtime-Bbzumoha.js +389 -0
- package/dist/build-CBXuT2K1.js +261 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +2 -2
- package/dist/bundled/session-memory/handler.js +1 -1
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/capability-cli-CiVGX7ut.js +1809 -0
- package/dist/channel-BIVwHq7P.js +2309 -0
- package/dist/channel-CiA2FVdL.d.ts +427 -0
- package/dist/channel-core-Cj9JTqeu.js +5 -0
- package/dist/channel-core-DjVpcH1C.d.ts +6 -0
- package/dist/channel-entry-contract-Bs_54m1D.d.ts +114 -0
- package/dist/channel-inbound-CdUdeQRa.js +121 -0
- package/dist/channel-inbound-iGiqx6CS.d.ts +97 -0
- package/dist/channel-message-C3QPaDUk.js +12 -0
- package/dist/channel-message-CXDjxb2U.d.ts +9 -0
- package/dist/channel-outbound-ofvvmMSK.d.ts +325 -0
- package/dist/channel-pairing-DKscOV1K.d.ts +58 -0
- package/dist/channel.runtime-VW6PW_ez.js +697 -0
- package/dist/channel.runtime.js +1 -1
- package/dist/chat-CFkQepUQ.js +3 -0
- package/dist/chat-Czh_tXM0.js +2940 -0
- package/dist/chrome-B2cq8YyH.js +1517 -0
- package/dist/cli/run-main.js +5 -5
- package/dist/cli-compaction-Dxv4nt7R.js +363 -0
- package/dist/cli-runner-CimXSTVs.js +2 -0
- package/dist/cli-runner-orCzE1Sr.js +597 -0
- package/dist/cli-runner.runtime-CsW0dXJW.js +3 -0
- package/dist/cli-runner.runtime-DgPrc1do.js +4 -0
- package/dist/cli-runner.runtime.js +1 -1
- package/dist/cli-startup-metadata.json +10 -12
- package/dist/command-registry-C5ooX6PF.js +4 -0
- package/dist/command-registry-DMB-HKIk.js +9 -0
- package/dist/command-registry-core-B2w_XWvn.js +114 -0
- package/dist/command-status.runtime-Bdy3Dkar.js +90 -0
- package/dist/command-status.runtime.js +1 -1
- package/dist/commands-compact.runtime-Bk2jTQo6.js +10 -0
- package/dist/commands-compact.runtime.js +1 -1
- package/dist/commands-handlers.runtime-Csw1og0U.js +6327 -0
- package/dist/commands-handlers.runtime.js +1 -1
- package/dist/commands-mRqmLIVz.d.ts +117 -0
- package/dist/commands-status-Dgrj_ubK.js +3 -0
- package/dist/commands-status-s32HJOpD.js +16 -0
- package/dist/commands-status.runtime-Dgrj_ubK.js +3 -0
- package/dist/commands-status.runtime.js +1 -1
- package/dist/commands-subagents-control.runtime-C_hnOO9l.js +2 -0
- package/dist/commands-subagents-control.runtime.js +1 -1
- package/dist/commands-system-prompt-CQV742Cc.js +2 -0
- package/dist/commands-system-prompt-DTfsKwK1.js +161 -0
- package/dist/commands-types-MXHhrssO.d.ts +132 -0
- package/dist/commands.runtime-akiVK67l.js +175 -0
- package/dist/commands.runtime.js +1 -1
- package/dist/commitments/runtime.js +1 -1
- package/dist/compact-U6ZhvPtD.js +1165 -0
- package/dist/compact.runtime-36E5vKsC.js +12 -0
- package/dist/compact.runtime.js +1 -1
- package/dist/completion-cli-Bf4mEw2W.js +393 -0
- package/dist/config-BJJhHN9E.js +374 -0
- package/dist/config-mutations-swLu-j_p.js +161 -0
- package/dist/config-schema-Tjner6bM.d.ts +20 -0
- package/dist/context-engine-host-compat-6fkn_daV.js +280 -0
- package/dist/context-engine-host-compat-DtAZC1bS.js +2 -0
- package/dist/context-engine-lifecycle-R__Idxi1.js +627 -0
- package/dist/control-auth-DnkI94_D.js +114 -0
- package/dist/control-service-BBsamNjq.js +40 -0
- package/dist/control-service-BGpHj7RL.js +3 -0
- package/dist/control-ui/assets/activity-D-mnRThU.js +124 -0
- package/dist/control-ui/assets/agents-U_KSP5I_.js +1030 -0
- package/dist/control-ui/assets/channels-ohK9_G1O.js +120 -0
- package/dist/control-ui/assets/cron-6ZCzfU29.js +1016 -0
- package/dist/control-ui/assets/debug-CSsDLg_s.js +97 -0
- package/dist/control-ui/assets/index-jUDczxhd.js +7214 -0
- package/dist/control-ui/assets/instances-782ZoDT4.js +57 -0
- package/dist/control-ui/assets/nodes-BMX16BKM.js +444 -0
- package/dist/control-ui/assets/sessions-jLGSApYa.js +425 -0
- package/dist/control-ui/assets/skills-DweBwUhs.js +362 -0
- package/dist/control-ui/assets/workboard-BsU-FXIo.js +402 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/control-ui/sw.js +1 -1
- package/dist/conversation-runtime-DDekWU-U.js +31 -0
- package/dist/core-Bpk-qSJH.js +284 -0
- package/dist/core-Chrz4oRB.d.ts +223 -0
- package/dist/core-api-DSpUKNVW.js +2 -0
- package/dist/core-api-hLsW03Wo.js +5 -0
- package/dist/crestodian/crestodian.js +1 -1
- package/dist/crestodian/rescue-message.d.ts +1 -1
- package/dist/crestodian/rescue-message.js +1 -1
- package/dist/crestodian-C0x7JjF-.js +55 -0
- package/dist/delegate-BArFIZ4B.d.ts +30 -0
- package/dist/deliver-BnVp3VbL.d.ts +111 -0
- package/dist/delivery-queue-BFOASdf5.d.ts +161 -0
- package/dist/delivery-queue-runtime-BFfc8AEs.d.ts +9 -0
- package/dist/dialogue-No0NvYX7.js +37 -0
- package/dist/direct-dm-C-h88JJH.d.ts +79 -0
- package/dist/directive-handling.fast-lane-DTyDKhZb.js +70 -0
- package/dist/directive-handling.impl-DMReM6tu.js +2 -0
- package/dist/directive-handling.impl-DzPouhV-.js +823 -0
- package/dist/directive-handling.model-selection-BjwTBAZJ.js +122 -0
- package/dist/directive-handling.persist.runtime-D_O1okkR.js +274 -0
- package/dist/directive-handling.persist.runtime.js +1 -1
- package/dist/dispatch-Dtl-oRuN.js +2057 -0
- package/dist/dispatch-acp-transcript.runtime-M4y0Dq74.js +40 -0
- package/dist/dispatch-acp-transcript.runtime.js +1 -1
- package/dist/dispatch-acp.runtime-B8uCIKZS.js +18 -0
- package/dist/dispatch-acp.runtime.js +1 -1
- package/dist/dispatcher-DslvaRcj.js +106 -0
- package/dist/doctor-config-flow-LU2C94af.js +1819 -0
- package/dist/doctor-core-checks-BqcjExIZ.js +666 -0
- package/dist/doctor-core-checks-Diuk8l0N.js +2 -0
- package/dist/doctor-core-checks.runtime-DbS-kMZN.js +278 -0
- package/dist/doctor-core-checks.runtime.js +1 -1
- package/dist/doctor-health-BdqHwfYE.js +65 -0
- package/dist/doctor-health-contributions-DLLTVnll.js +874 -0
- package/dist/doctor-lint-PZqkVMWf.js +95 -0
- package/dist/doctor-mRfJMSb5.js +6 -0
- package/dist/doctor-state-integrity-Cdlm-peH.js +1257 -0
- package/dist/draft-stream-controls-B7uLonbw.d.ts +159 -0
- package/dist/embedded-agent-CEpOPW6X.js +4 -0
- package/dist/embedded-agent-CNINO_M-.d.ts +5 -0
- package/dist/embedded-agent-DxwzoZkp.js +4074 -0
- package/dist/embedded-agent.runtime-DDbhA85-.js +4 -0
- package/dist/embedded-agent.runtime.js +1 -1
- package/dist/embedded-backend-ChaKCepC.js +1581 -0
- package/dist/embedded-gateway-stub.runtime-e_ZxGhcW.js +12 -0
- package/dist/embedded-gateway-stub.runtime.js +1 -1
- package/dist/entry.d.ts +1 -1
- package/dist/extensionAPI.d.ts +2 -2
- package/dist/extensionAPI.js +1 -1
- package/dist/extensions/active-memory/index.d.ts +1 -1
- package/dist/extensions/active-memory/index.js +1 -1
- package/dist/extensions/admin-http-rpc/index.d.ts +1 -1
- package/dist/extensions/admin-http-rpc/index.js +1 -1
- package/dist/extensions/bonjour/index.d.ts +1 -1
- package/dist/extensions/browser/browser-bridge.js +1 -1
- package/dist/extensions/browser/browser-config.js +4 -4
- package/dist/extensions/browser/browser-control-auth.js +2 -2
- package/dist/extensions/browser/browser-doctor.js +2 -2
- package/dist/extensions/browser/browser-maintenance.js +1 -1
- package/dist/extensions/browser/browser-profiles.js +2 -2
- package/dist/extensions/browser/browser-runtime-api.js +12 -12
- package/dist/extensions/browser/cli-metadata.d.ts +1 -1
- package/dist/extensions/browser/cli-metadata.js +1 -1
- package/dist/extensions/browser/index.d.ts +1 -1
- package/dist/extensions/browser/index.js +1 -1
- package/dist/extensions/browser/plugin-registration.d.ts +1 -1
- package/dist/extensions/browser/plugin-registration.js +1 -1
- package/dist/extensions/browser/register.runtime.d.ts +2 -2
- package/dist/extensions/browser/register.runtime.js +4 -4
- package/dist/extensions/browser/runtime-api.d.ts +3 -3
- package/dist/extensions/browser/runtime-api.js +14 -14
- package/dist/extensions/browser/setup-api.d.ts +1 -1
- package/dist/extensions/canvas/cli-metadata.d.ts +1 -1
- package/dist/extensions/canvas/index.d.ts +1 -1
- package/dist/extensions/canvas/index.js +1 -1
- package/dist/extensions/canvas/setup-api.d.ts +1 -1
- package/dist/extensions/deepseek/api.d.ts +1 -1
- package/dist/extensions/deepseek/index.d.ts +1 -1
- package/dist/extensions/deepseek/provider-discovery.d.ts +1 -1
- package/dist/extensions/deepseek/stream.d.ts +1 -1
- package/dist/extensions/device-pair/api.d.ts +4 -4
- package/dist/extensions/device-pair/api.js +1 -1
- package/dist/extensions/device-pair/index.d.ts +1 -1
- package/dist/extensions/device-pair/notify.d.ts +1 -1
- package/dist/extensions/device-pair/pair-command-approve.js +1 -1
- package/dist/extensions/device-pair/qr-image.d.ts +1 -1
- package/dist/extensions/memory-core/api.d.ts +1 -1
- package/dist/extensions/memory-core/cli-metadata.d.ts +1 -1
- package/dist/extensions/memory-core/cli-metadata.js +1 -1
- package/dist/extensions/memory-core/index.d.ts +1 -1
- package/dist/extensions/memory-core/manager-runtime.d.ts +1 -1
- package/dist/extensions/memory-core/runtime-api.d.ts +3 -3
- package/dist/extensions/skill-workshop/api.d.ts +2 -2
- package/dist/extensions/skill-workshop/api.js +1 -1
- package/dist/extensions/skill-workshop/index.d.ts +1 -1
- package/dist/extensions/skill-workshop/index.js +2 -2
- package/dist/extensions/tavily/index.d.ts +1 -1
- package/dist/extensions/tavily/web-search-contract-api.d.ts +1 -1
- package/dist/extensions/tavily/web-search-provider.d.ts +1 -1
- package/dist/extensions/thread-ownership/api.d.ts +2 -2
- package/dist/extensions/thread-ownership/index.d.ts +1 -1
- package/dist/extensions/webhooks/api.d.ts +2 -2
- package/dist/extensions/webhooks/api.js +1 -1
- package/dist/extensions/webhooks/index.d.ts +1 -1
- package/dist/extensions/webhooks/index.js +1 -1
- package/dist/extensions/webhooks/runtime-api.d.ts +1 -1
- package/dist/extensions/workboard/api.d.ts +2 -2
- package/dist/extensions/workboard/index.d.ts +1 -1
- package/dist/extensions/workboard/index.js +1 -1
- package/dist/extensions/workboard/runtime-api.d.ts +1 -1
- package/dist/fengming-runtime-CtRd5677.d.ts +153 -0
- package/dist/fengming-tools-DBLsJfsf.js +12221 -0
- package/dist/gateway-cli-BgDV2HF9.js +443 -0
- package/dist/gateway-method-runtime-d9oN_XO9.js +21 -0
- package/dist/get-reply-CEMtvaTJ.js +5198 -0
- package/dist/get-reply-from-config.runtime-CE8zmX7o.js +2 -0
- package/dist/get-reply-from-config.runtime.js +1 -1
- package/dist/heartbeat-runner-H8SmaKmJ.js +5 -0
- package/dist/heartbeat-runner.runtime-6hUaxEbl.js +3 -0
- package/dist/heartbeat-runner.runtime.js +1 -1
- package/dist/hooks-DkEvkwzS.js +536 -0
- package/dist/host-compat-DeAq3dnI.d.ts +21 -0
- package/dist/http-registry-BDoApjTY.d.ts +23 -0
- package/dist/inbound-reply-dispatch-CIYP2OPo.d.ts +156 -0
- package/dist/inbound-reply-dispatch-geHu6oUK.js +147 -0
- package/dist/inbound-reply-dispatch-vwW5Hl-_.js +2 -0
- package/dist/index.js +1 -1
- package/dist/init-DpE_6dG4.js +59 -0
- package/dist/interactive-Cb_1f91G.d.ts +26 -0
- package/dist/isolated-agent-B_upYOOM.js +2 -0
- package/dist/isolated-agent-KH9uwWhw.js +1097 -0
- package/dist/kernel-BHnBXnm2.d.ts +241 -0
- package/dist/lifecycle-BmZwopzF.js +570 -0
- package/dist/list.probe-5kzWm9Jk.js +451 -0
- package/dist/list.probe-9zBcGGQ4.js +2 -0
- package/dist/list.status-command-DY2ifqp1.js +815 -0
- package/dist/llm-slug-generator-Bmx0I84M.js +78 -0
- package/dist/llm-slug-generator.js +1 -1
- package/dist/loader-BVz75gSb.d.ts +142 -0
- package/dist/local-dispatch.runtime-CX3IOY1E.js +10 -0
- package/dist/local-dispatch.runtime.js +1 -1
- package/dist/manager-BXGg8bfG.d.ts +409 -0
- package/dist/mcp-http-B1lnh67s.js +2 -0
- package/dist/mcp-http-CamghE-W.js +583 -0
- package/dist/media-runtime-DpykroJR.d.ts +261 -0
- package/dist/memory-core-host-engine-embeddings-N2dX5P40.d.ts +324 -0
- package/dist/memory-core-host-engine-storage-WQfkQMer.d.ts +54 -0
- package/dist/message-handler-Ca_pqGVS.js +1806 -0
- package/dist/model-catalog-BBMLIjhq.d.ts +88 -0
- package/dist/model-selection-Cq82FXLy.js +352 -0
- package/dist/models-cli-Dm_393dw.js +257 -0
- package/dist/monitor-d0eyE2k0.js +60 -0
- package/dist/monitor.account-vLQ3bKHu.js +5382 -0
- package/dist/nodes-Bunvrb33.js +1483 -0
- package/dist/nodes-edNlxb2I.js +3 -0
- package/dist/nodes-pending-DEIwVh9v.js +211 -0
- package/dist/openai-compat-errors-CvWEoG98.js +136 -0
- package/dist/openai-http-Bskdv4Tv.js +836 -0
- package/dist/openresponses-http-DxdgCxFU.js +1175 -0
- package/dist/operations-Z85LFqsT.js +805 -0
- package/dist/outbound.types-DVkbsxo8.d.ts +291 -0
- package/dist/plugin-enabled-fvhTpvYS.js +232 -0
- package/dist/plugin-entry-CunlVUw6.d.ts +47 -0
- package/dist/plugin-registration-9ovnK_Tk.js +97 -0
- package/dist/plugin-runtime-DH2ZM9P5.d.ts +117 -0
- package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
- package/dist/plugin-sdk/acp-runtime-backend.js +1 -1
- package/dist/plugin-sdk/acp-runtime.js +1 -1
- package/dist/plugin-sdk/agent-harness-runtime.js +5 -5
- package/dist/plugin-sdk/agent-harness-task-runtime.js +1 -1
- package/dist/plugin-sdk/agent-harness.js +6 -6
- package/dist/plugin-sdk/agent-runtime.js +2 -2
- package/dist/plugin-sdk/bundled-channel-config-schema-Dfn3b8sF.d.ts +3169 -0
- package/dist/plugin-sdk/bundled-channel-config-schema.d.ts +1 -1
- package/dist/plugin-sdk/channel-config-schema-legacy.d.ts +1 -1
- package/dist/plugin-sdk/channel-core.js +2 -2
- package/dist/plugin-sdk/channel-envelope.js +1 -1
- package/dist/plugin-sdk/channel-inbound-roots.js +1 -1
- package/dist/plugin-sdk/channel-inbound.js +2 -2
- package/dist/plugin-sdk/channel-location.js +1 -1
- package/dist/plugin-sdk/channel-message-runtime.js +3 -3
- package/dist/plugin-sdk/channel-message.js +2 -2
- package/dist/plugin-sdk/channel-runtime.js +0 -1
- package/dist/plugin-sdk/command-status-runtime.js +1 -1
- package/dist/plugin-sdk/compat.js +1 -1
- package/dist/plugin-sdk/conversation-binding-runtime.js +1 -1
- package/dist/plugin-sdk/conversation-runtime.js +3 -3
- package/dist/plugin-sdk/core.js +2 -2
- package/dist/plugin-sdk/discord.d.ts +1 -1
- package/dist/plugin-sdk/gateway-method-runtime.js +1 -1
- package/dist/plugin-sdk/health.js +1 -1
- package/dist/plugin-sdk/hook-runtime.js +0 -1
- package/dist/plugin-sdk/inbound-reply-dispatch.js +2 -2
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/infra-runtime.js +3 -1
- package/dist/plugin-sdk/provider-auth-api-key.js +0 -1
- package/dist/plugin-sdk/provider-stream-family.js +0 -1
- package/dist/plugin-sdk/provider-usage.js +649 -1
- package/dist/plugin-sdk/reply-runtime.js +4 -4
- package/dist/plugin-sdk/video-generation.js +206 -1
- package/dist/plugin-service-BdZxoKBZ.js +1249 -0
- package/dist/plugin-service-quTl5hT0.d.ts +24 -0
- package/dist/plugins/build-smoke-entry.d.ts +2 -2
- package/dist/plugins/loader.d.ts +1 -1
- package/dist/plugins/provider-discovery.runtime.d.ts +1 -1
- package/dist/plugins/provider-runtime.runtime.d.ts +1 -1
- package/dist/plugins/runtime/index.d.ts +1 -1
- package/dist/plugins/runtime/index.js +4 -4
- package/dist/plugins/tools.d.ts +1 -1
- package/dist/prepare.runtime-DFvkUqBZ.js +798 -0
- package/dist/prepare.runtime.js +1 -1
- package/dist/preview-warnings-CGzc8ccG.js +618 -0
- package/dist/program-D19g2jaa.js +131 -0
- package/dist/provider-api-key-auth-B8GgTfo8.d.ts +27 -0
- package/dist/provider-auth-result-Diw-woMA.d.ts +21 -0
- package/dist/provider-catalog-shared-hMvzzDgL.d.ts +62 -0
- package/dist/provider-dispatcher-DCTc4lG_.js +22 -0
- package/dist/provider-dispatcher.runtime.js +1 -1
- package/dist/provider-model-shared-BUCh3uCL.d.ts +143 -0
- package/dist/provider-registry-BIokPlxa.d.ts +8 -0
- package/dist/provider-registry-CyUOXHG-.d.ts +8 -0
- package/dist/provider-registry-i--H79Ao.d.ts +29 -0
- package/dist/provider-self-hosted-setup-BF8UR8wg.d.ts +74 -0
- package/dist/provider-stream-NF0XJnar.d.ts +139 -0
- package/dist/provider-stream-shared-DLwDaYed.d.ts +132 -0
- package/dist/provider-web-search-contract-fields-D61Vl5Kl.d.ts +25 -0
- package/dist/pw-ai-DYR-D7xR.js +3064 -0
- package/dist/register.agent-DwW0mQPk.js +152 -0
- package/dist/register.crestodian-BhIukKDA.js +24 -0
- package/dist/register.maintenance-DWHlvztJ.js +85 -0
- package/dist/register.subclis-Bsvdh8RI.js +3 -0
- package/dist/register.subclis-DVk0HU4k.js +31 -0
- package/dist/register.subclis-core-BK7nVvl6.js +278 -0
- package/dist/registry-hscEPAcC.d.ts +8 -0
- package/dist/registry-types-Ce-n1tuw.d.ts +392 -0
- package/dist/repair-sequencing-0-qGNSUO.js +652 -0
- package/dist/reply-payload-mCw4ZND6.d.ts +200 -0
- package/dist/reply-turn-admission-DMWNadoS.js +2056 -0
- package/dist/reply.runtime-CE8zmX7o.js +2 -0
- package/dist/reply.runtime.js +1 -1
- package/dist/result-fallback-classifier-BZmv2ACy.js +98 -0
- package/dist/route-qQ-jYpFa.js +475 -0
- package/dist/routes-dTCmw98g.js +2 -0
- package/dist/routes-r8DRKa83.js +3701 -0
- package/dist/run-BgH7EPGH.js +1162 -0
- package/dist/run-command-DCsM-BVh.js +23 -0
- package/dist/run-command-I2ib4dwS.js +2 -0
- package/dist/run-context-CWaKUKKJ.js +66 -0
- package/dist/run-embedded.runtime-CBnDBWN0.js +4 -0
- package/dist/run-embedded.runtime.js +1 -1
- package/dist/run-execution-cli.runtime-DlYXI-lw.js +4 -0
- package/dist/run-execution-cli.runtime.js +1 -1
- package/dist/run-executor.runtime-DwepGrmB.js +330 -0
- package/dist/run-executor.runtime.js +1 -1
- package/dist/run-subagent-registry.runtime-CeVpoIhj.js +2 -0
- package/dist/run-subagent-registry.runtime.js +1 -1
- package/dist/runtime-D2ee-rNh.js +436 -0
- package/dist/runtime-api-B99ZlkNt.d.ts +5 -0
- package/dist/runtime-api-Cta2L_Yo.js +12 -0
- package/dist/runtime-channel-LKOkML3M.js +2 -0
- package/dist/runtime-channel-UtWvrTZ5.js +148 -0
- package/dist/runtime-embedded-agent.runtime-9O2Idzyb.js +2 -0
- package/dist/runtime-embedded-agent.runtime.js +1 -1
- package/dist/runtime-forwarders-DjI8RFL5.d.ts +39 -0
- package/dist/sdk-setup-tools-B-X04pa6.js +8 -0
- package/dist/selection-B02h8Old.js +3 -0
- package/dist/selection-DEPvzrW2.js +18365 -0
- package/dist/server-CMYi8gDo.js +24 -0
- package/dist/server-Cx07rsiY.js +72 -0
- package/dist/server-close.runtime.js +1 -1
- package/dist/server-context-BIemGRt4.js +2 -0
- package/dist/server-context-CB_an9iy.js +955 -0
- package/dist/server-cron-BeyuBUjb.js +3173 -0
- package/dist/server-cron-CV7KkVeB.js +2 -0
- package/dist/server-methods-C7EnpOhB.js +497 -0
- package/dist/server-node-events-DMMzZciN.js +597 -0
- package/dist/server-plugin-bootstrap-O6MzvzL8.js +71 -0
- package/dist/server-plugins-Dwnaz9kX.js +435 -0
- package/dist/server-reload-handlers-C-6TyPvI.js +719 -0
- package/dist/server-restart-sentinel-Dc35eYgk.js +700 -0
- package/dist/server-runtime-services-DCs-gqh_.js +3 -0
- package/dist/server-runtime-services-DF2fzzVd.js +147 -0
- package/dist/server-startup-plugins-t-YeYibm.js +127 -0
- package/dist/server-startup-post-attach-CiEki-DC.js +793 -0
- package/dist/server-ws-runtime-uaUpI-e8.js +374 -0
- package/dist/server.impl-MoHjSMr5.js +2622 -0
- package/dist/session-kill-http-CYCiQpt2.js +121 -0
- package/dist/session-reset-service-BYbADY57.js +651 -0
- package/dist/session-status.runtime-8NASbeO4.js +2 -0
- package/dist/session-status.runtime.js +1 -1
- package/dist/session-subagent-reactivation.runtime-DGeNY2Rb.js +2 -0
- package/dist/session-subagent-reactivation.runtime.js +1 -1
- package/dist/session-tab-registry-C2eElZrt.js +551 -0
- package/dist/sessions-DXAdVXIx.js +1917 -0
- package/dist/sessions-history-http-BwK7b8OH.js +432 -0
- package/dist/sessions-patch-BYC5gvY1.js +401 -0
- package/dist/sessions-resolve-C3ORcdmo.js +180 -0
- package/dist/sessions.runtime-BijldeSY.js +2 -0
- package/dist/sessions.runtime.js +1 -1
- package/dist/snapshot-urls-C5CfP3Co.js +317 -0
- package/dist/speech-core-wWkTZPpQ.d.ts +49 -0
- package/dist/standalone-CHrieUsw.js +42 -0
- package/dist/startup-context-CZfmG8-g.js +314 -0
- package/dist/status-subagents.runtime-D2XMebiS.js +32 -0
- package/dist/status-subagents.runtime.js +1 -1
- package/dist/status-text-JR7IPyzZ.js +301 -0
- package/dist/stream-BJgTkLEI.d.ts +5 -0
- package/dist/subagent-announce-B9cfs_KZ.js +353 -0
- package/dist/subagent-announce-delivery-CtmEvLTS.js +1369 -0
- package/dist/subagent-control-DVqLHi9O.js +492 -0
- package/dist/subagent-hooks-D251uSvy.js +230 -0
- package/dist/subagent-hooks-api-DvdMKxsC.js +23 -0
- package/dist/subagent-hooks-uLORYChc.js +2 -0
- package/dist/subagent-registry-BW2l_oYu.js +3 -0
- package/dist/subagent-registry-BxEMHuiN.js +2627 -0
- package/dist/subagent-registry.runtime.d.ts +1 -1
- package/dist/subagent-registry.runtime.js +1 -1
- package/dist/subagent-session-cleanup-BC5wV2qQ.js +390 -0
- package/dist/system-fvgHsr2x.js +111 -0
- package/dist/talk-DU0Sod_K.js +2454 -0
- package/dist/target-id-BR2xJIkd.js +107 -0
- package/dist/task-registry-control.runtime.js +1 -1
- package/dist/thread-bindings-8XNu5U2p.js +228 -0
- package/dist/tool-Boeg0N5g.js +143 -0
- package/dist/tool-dispatch-BhLLaL2g.js +155 -0
- package/dist/tool-resolution-CzsLs-87.js +153 -0
- package/dist/tool-split-Bedy42Ms.d.ts +19 -0
- package/dist/tools-B6egHpE3.d.ts +38 -0
- package/dist/tools-effective-NXscxK8n.js +442 -0
- package/dist/tools-effective-inventory-NsGMUVo-.js +379 -0
- package/dist/tools-invoke-_sSu96Kq.js +51 -0
- package/dist/tools-invoke-http-BDhlRl-G.js +68 -0
- package/dist/tools-invoke-shared-BH-T9Bcg.js +200 -0
- package/dist/tts-runtime-C1wu3o15.d.ts +230 -0
- package/dist/tui-C733Qov0.js +2 -0
- package/dist/tui-DqbscVN5.js +3 -0
- package/dist/tui-backend-_Pn3Byj-.js +257 -0
- package/dist/tui-cli-CAiC39zd.js +40 -0
- package/dist/tui-ink-run-ChXEGj1h.js +7414 -0
- package/dist/tui-ink-run-D4mSfLHj.js +2 -0
- package/dist/types-BQw1qXGl.d.ts +7034 -0
- package/dist/types-BzMoU6-C.d.ts +111 -0
- package/dist/types-DltHmoCX.d.ts +393 -0
- package/dist/types.public-C_bVIMBl.d.ts +70 -0
- package/dist/web-fetch/runtime.d.ts +1 -1
- package/dist/webhook-targets-DW2jhddP.d.ts +99 -0
- package/npm-shrinkwrap.json +12861 -11889
- package/package.json +2 -5
- package/skills/batch/SKILL.md +118 -0
- package/skills/code-review/SKILL.md +107 -0
- package/skills/debug/SKILL.md +83 -0
- package/skills/loop/SKILL.md +118 -0
- package/skills/run/SKILL.md +79 -0
- package/skills/run-skill-generator/SKILL.md +179 -0
- package/skills/verify/SKILL.md +103 -0
- package/dist/abort-DGskei2p.js +0 -277
- package/dist/abort.runtime-Buq9IZxn.js +0 -2
- package/dist/acp-spawn-DC6IyYaB.js +0 -1286
- package/dist/acp-spawn-Diqb3nel.js +0 -2
- package/dist/acp-stateful-target-driver-Clhe_L8v.js +0 -89
- package/dist/active-tool-schema-warnings-BRhKkyvt.js +0 -2
- package/dist/active-tool-schema-warnings-C6N0-ce6.js +0 -105
- package/dist/agent-C5lhsEZJ.js +0 -2
- package/dist/agent-WEb757bl.js +0 -1825
- package/dist/agent-command-iLD_nsVY.js +0 -1435
- package/dist/agent-core-BeDN8Ns5.d.ts +0 -13
- package/dist/agent-harness-runtime-C89_Q-bW.d.ts +0 -913
- package/dist/agent-harness-runtime-Dfn5rik2.js +0 -207
- package/dist/agent-runner-utils-DNiuuo43.js +0 -267
- package/dist/agent-runner.runtime-CFF_qJ5V.js +0 -3784
- package/dist/agent-runtime-BkMtWXxn.js +0 -199
- package/dist/agent-runtime-HufMO_YR.d.ts +0 -207
- package/dist/agent-tools-HmaDv4ot.js +0 -2506
- package/dist/agent-via-gateway-CZQG8RYL.js +0 -486
- package/dist/agent-wait-dedupe-C3xQk2Ww.js +0 -180
- package/dist/agent-z1cs3c7n.js +0 -3
- package/dist/api-B4IMKjSe.js +0 -3
- package/dist/api-BwSbBWI8.js +0 -3
- package/dist/api-CE9In9m4.js +0 -5
- package/dist/api-ClPvYNGa.js +0 -32
- package/dist/api-CntBCaZf.js +0 -3
- package/dist/api-DBZBwTsn.js +0 -6
- package/dist/api-OCPwGOvK.js +0 -2
- package/dist/api-yYhEo7gK.js +0 -4
- package/dist/approval-client-helpers-CfdQ3-vv.d.ts +0 -78
- package/dist/approval-native-helpers-DSHPksK4.d.ts +0 -241
- package/dist/approval-renderers-BfEfwk44.d.ts +0 -39
- package/dist/assistant-v5fdOYu7.js +0 -291
- package/dist/attachment-normalize-BHAbLiL2.js +0 -213
- package/dist/attempt-execution-5w9WYbaJ.js +0 -584
- package/dist/attempt-execution.runtime-DnhOWGzr.js +0 -3
- package/dist/attempt.prompt-helpers-C4M4erF7.js +0 -543
- package/dist/binding-routing-Dpes-QF1.js +0 -113
- package/dist/binding-targets-B6H5Pd-A.js +0 -121
- package/dist/bridge-server-BCpxCRm_.js +0 -113
- package/dist/browser-cli-DMhXHopl.js +0 -230
- package/dist/browser-cli-Dy_VugK0.js +0 -2
- package/dist/browser-cli-actions-input-WMP7_lm6.js +0 -522
- package/dist/browser-cli-actions-observe-DQWAWhwU.js +0 -81
- package/dist/browser-cli-debug-CaT2ZKAx.js +0 -137
- package/dist/browser-cli-inspect-DU-LUXq1.js +0 -117
- package/dist/browser-cli-manage-DAuogqIh.js +0 -446
- package/dist/browser-cli-resize-Cz5uO_aR.js +0 -32
- package/dist/browser-cli-shared-CjPZcG3j.js +0 -69
- package/dist/browser-cli-state-CC3l77-K.js +0 -371
- package/dist/browser-control-auth-ELccIUZy.js +0 -2
- package/dist/browser-profiles-Cuy4ia6_.js +0 -2
- package/dist/browser-runtime-De-iUfME.js +0 -389
- package/dist/build-DEF8Per9.js +0 -261
- package/dist/capability-cli-Bydel4E7.js +0 -1809
- package/dist/channel-6SGL4R5P.js +0 -2309
- package/dist/channel-D3Q3b8J-.d.ts +0 -427
- package/dist/channel-core-Bj71kAB5.d.ts +0 -6
- package/dist/channel-core-DMvyWnHg.js +0 -5
- package/dist/channel-entry-contract-zYxRmEdf.d.ts +0 -114
- package/dist/channel-inbound-DVJzBcJ8.d.ts +0 -97
- package/dist/channel-inbound-DlCa7eJe.js +0 -121
- package/dist/channel-message-CyPGMMFB.js +0 -12
- package/dist/channel-message-Czl4cdoA.d.ts +0 -9
- package/dist/channel-outbound-BNbhmruA.d.ts +0 -325
- package/dist/channel-pairing-BiS-tSvl.d.ts +0 -58
- package/dist/channel-runtime-D8hntg7H.js +0 -7
- package/dist/channel.runtime-DxErReJR.js +0 -697
- package/dist/chat-BLA8ORQI.js +0 -3
- package/dist/chat-DWRXkuvU.js +0 -2940
- package/dist/chrome-DPwFYi-g.js +0 -1517
- package/dist/cli-compaction-YZpssARf.js +0 -363
- package/dist/cli-runner-D2OAqxu3.js +0 -597
- package/dist/cli-runner-DO4SORQf.js +0 -2
- package/dist/cli-runner.runtime-CNSIpbeT.js +0 -4
- package/dist/cli-runner.runtime-DAOYvpVQ.js +0 -3
- package/dist/command-registry-DpD0fb8D.js +0 -4
- package/dist/command-registry-core-Cl3tLG8G.js +0 -114
- package/dist/command-registry-nbP7c8RT.js +0 -9
- package/dist/command-status.runtime-BBuXTkq0.js +0 -90
- package/dist/commands-CR8MVvlD.d.ts +0 -117
- package/dist/commands-compact.runtime-BoafIjjg.js +0 -10
- package/dist/commands-handlers.runtime-D9jViG_x.js +0 -6327
- package/dist/commands-status-BqqJ7PVq.js +0 -16
- package/dist/commands-status-CMd41Vxf.js +0 -3
- package/dist/commands-status.runtime-CMd41Vxf.js +0 -3
- package/dist/commands-subagents-control.runtime-CU4I3A_n.js +0 -2
- package/dist/commands-system-prompt-CTtu1D3-.js +0 -2
- package/dist/commands-system-prompt-xswhORdM.js +0 -161
- package/dist/commands-types-B67CsqXf.d.ts +0 -132
- package/dist/commands.runtime-BUFhkrjQ.js +0 -175
- package/dist/compact-Dz_WvRkQ.js +0 -1165
- package/dist/compact.runtime-n-AKErni.js +0 -12
- package/dist/completion-cli-DJYs_L4_.js +0 -393
- package/dist/config-CFMbHJb0.js +0 -374
- package/dist/config-mutations-DCAloTKR.js +0 -161
- package/dist/config-schema-Drw1zrnG.d.ts +0 -20
- package/dist/context-engine-host-compat-4mNm1HCE.js +0 -2
- package/dist/context-engine-host-compat-BzJ7fUIn.js +0 -280
- package/dist/context-engine-lifecycle-V4PNQp6k.js +0 -627
- package/dist/control-auth-DG_cw-aN.js +0 -114
- package/dist/control-service-CurYipgK.js +0 -3
- package/dist/control-service-VyncoV7j.js +0 -40
- package/dist/control-ui/assets/activity-D5Plhlo-.js +0 -124
- package/dist/control-ui/assets/agents-Chcdfe1E.js +0 -1030
- package/dist/control-ui/assets/channels-BEtB4H37.js +0 -120
- package/dist/control-ui/assets/cron-CZyPkxSU.js +0 -1016
- package/dist/control-ui/assets/debug-DvM8iG47.js +0 -97
- package/dist/control-ui/assets/index-Rmpgh0f1.js +0 -7214
- package/dist/control-ui/assets/instances-yTC_uu60.js +0 -57
- package/dist/control-ui/assets/nodes-vbAxVHIH.js +0 -444
- package/dist/control-ui/assets/sessions-DOviHme5.js +0 -425
- package/dist/control-ui/assets/skills-Bfp5HEGW.js +0 -362
- package/dist/control-ui/assets/workboard-5sU2kHsV.js +0 -402
- package/dist/conversation-runtime-DgaABwHh.js +0 -31
- package/dist/core-BeBXdneV.js +0 -284
- package/dist/core-Chqb7X6l.d.ts +0 -223
- package/dist/core-api-BlK0FgBM.js +0 -2
- package/dist/core-api-pAvYk716.js +0 -5
- package/dist/crestodian-FeGTBqO1.js +0 -55
- package/dist/delegate-BjIjSU_E.d.ts +0 -30
- package/dist/deliver-CvtWN4Ey.d.ts +0 -111
- package/dist/delivery-queue-CQ-cj3KG.d.ts +0 -161
- package/dist/delivery-queue-runtime-ut7MG04m.d.ts +0 -9
- package/dist/detect-BjXPyrwn.js +0 -115
- package/dist/detect-C1xeIemQ.d.ts +0 -16
- package/dist/dialogue-BowVYhEC.js +0 -37
- package/dist/direct-dm-DoZZHpA0.d.ts +0 -79
- package/dist/directive-handling.fast-lane-hnmQ_CvD.js +0 -70
- package/dist/directive-handling.impl-Cai-CFS1.js +0 -2
- package/dist/directive-handling.impl-DY84qIfU.js +0 -823
- package/dist/directive-handling.model-selection-DASssLFQ.js +0 -122
- package/dist/directive-handling.persist.runtime-BY7tJUs2.js +0 -274
- package/dist/dispatch-D5iG5A8j.js +0 -2057
- package/dist/dispatch-acp-transcript.runtime-D3r16hbD.js +0 -40
- package/dist/dispatch-acp.runtime-CAIau5qX.js +0 -18
- package/dist/dispatcher-7-d2gw3J.js +0 -106
- package/dist/doctor-DD5YEMmf.js +0 -6
- package/dist/doctor-config-flow-CdlLHJmX.js +0 -1819
- package/dist/doctor-core-checks-6MP99TQG.js +0 -666
- package/dist/doctor-core-checks-Dm_o576z.js +0 -2
- package/dist/doctor-core-checks.runtime-B2qbKATd.js +0 -278
- package/dist/doctor-health-BKrhOv1v.js +0 -65
- package/dist/doctor-health-contributions-bIBLmw69.js +0 -874
- package/dist/doctor-lint-aOLOWli4.js +0 -95
- package/dist/doctor-state-integrity-23NQNNuo.js +0 -1257
- package/dist/draft-stream-controls-Bk1GVJ1l.d.ts +0 -159
- package/dist/embedded-agent-BeK8FhZr.d.ts +0 -5
- package/dist/embedded-agent-CNp_y7jW.js +0 -4074
- package/dist/embedded-agent-NEmNlXDR.js +0 -4
- package/dist/embedded-agent.runtime-hEby8P2s.js +0 -4
- package/dist/embedded-backend-BdbgfpBP.js +0 -1581
- package/dist/embedded-gateway-stub.runtime-ySZUA3Gy.js +0 -12
- package/dist/extensions/alibaba/fengming.plugin.json +0 -47
- package/dist/extensions/alibaba/index.d.ts +0 -12
- package/dist/extensions/alibaba/index.js +0 -13
- package/dist/extensions/alibaba/package.json +0 -15
- package/dist/extensions/alibaba/video-generation-provider.d.ts +0 -6
- package/dist/extensions/alibaba/video-generation-provider.js +0 -2
- package/dist/extensions/baichuan/fengming.plugin.json +0 -69
- package/dist/extensions/baichuan/index.d.ts +0 -11
- package/dist/extensions/baichuan/index.js +0 -45
- package/dist/extensions/baichuan/models.d.ts +0 -7
- package/dist/extensions/baichuan/models.js +0 -2
- package/dist/extensions/baichuan/onboard.d.ts +0 -5
- package/dist/extensions/baichuan/onboard.js +0 -2
- package/dist/extensions/baichuan/package.json +0 -15
- package/dist/extensions/baichuan/provider-catalog.d.ts +0 -2
- package/dist/extensions/baichuan/provider-catalog.js +0 -2
- package/dist/extensions/baichuan/provider-discovery.d.ts +0 -2
- package/dist/extensions/baichuan/provider-discovery.js +0 -5
- package/dist/extensions/byteplus/api.d.ts +0 -3
- package/dist/extensions/byteplus/api.js +0 -3
- package/dist/extensions/byteplus/fengming.plugin.json +0 -196
- package/dist/extensions/byteplus/index.d.ts +0 -12
- package/dist/extensions/byteplus/index.js +0 -85
- package/dist/extensions/byteplus/models.d.ts +0 -2
- package/dist/extensions/byteplus/models.js +0 -2
- package/dist/extensions/byteplus/package.json +0 -15
- package/dist/extensions/byteplus/provider-catalog.d.ts +0 -2
- package/dist/extensions/byteplus/provider-catalog.js +0 -2
- package/dist/extensions/byteplus/provider-discovery.d.ts +0 -5
- package/dist/extensions/byteplus/provider-discovery.js +0 -23
- package/dist/extensions/byteplus/video-generation-provider.d.ts +0 -6
- package/dist/extensions/byteplus/video-generation-provider.js +0 -2
- package/dist/extensions/longcat/fengming.plugin.json +0 -84
- package/dist/extensions/longcat/index.d.ts +0 -11
- package/dist/extensions/longcat/index.js +0 -45
- package/dist/extensions/longcat/models.d.ts +0 -7
- package/dist/extensions/longcat/models.js +0 -2
- package/dist/extensions/longcat/onboard.d.ts +0 -5
- package/dist/extensions/longcat/onboard.js +0 -2
- package/dist/extensions/longcat/package.json +0 -15
- package/dist/extensions/longcat/provider-catalog.d.ts +0 -2
- package/dist/extensions/longcat/provider-catalog.js +0 -2
- package/dist/extensions/longcat/provider-discovery.d.ts +0 -2
- package/dist/extensions/longcat/provider-discovery.js +0 -5
- package/dist/extensions/minimax/api.d.ts +0 -5
- package/dist/extensions/minimax/api.js +0 -6
- package/dist/extensions/minimax/fengming.plugin.json +0 -206
- package/dist/extensions/minimax/image-generation-provider.d.ts +0 -6
- package/dist/extensions/minimax/image-generation-provider.js +0 -2
- package/dist/extensions/minimax/index.d.ts +0 -12
- package/dist/extensions/minimax/index.js +0 -29
- package/dist/extensions/minimax/media-understanding-provider.d.ts +0 -6
- package/dist/extensions/minimax/media-understanding-provider.js +0 -2
- package/dist/extensions/minimax/model-definitions.d.ts +0 -2
- package/dist/extensions/minimax/model-definitions.js +0 -2
- package/dist/extensions/minimax/music-generation-provider.d.ts +0 -6
- package/dist/extensions/minimax/music-generation-provider.js +0 -2
- package/dist/extensions/minimax/oauth.d.ts +0 -2
- package/dist/extensions/minimax/oauth.js +0 -2
- package/dist/extensions/minimax/oauth.runtime.d.ts +0 -2
- package/dist/extensions/minimax/oauth.runtime.js +0 -2
- package/dist/extensions/minimax/onboard.d.ts +0 -2
- package/dist/extensions/minimax/onboard.js +0 -2
- package/dist/extensions/minimax/package.json +0 -15
- package/dist/extensions/minimax/provider-catalog.d.ts +0 -2
- package/dist/extensions/minimax/provider-catalog.js +0 -2
- package/dist/extensions/minimax/provider-contract-api.d.ts +0 -6
- package/dist/extensions/minimax/provider-contract-api.js +0 -77
- package/dist/extensions/minimax/provider-discovery.d.ts +0 -5
- package/dist/extensions/minimax/provider-discovery.js +0 -23
- package/dist/extensions/minimax/provider-models.d.ts +0 -2
- package/dist/extensions/minimax/provider-models.js +0 -2
- package/dist/extensions/minimax/provider-registration.d.ts +0 -7
- package/dist/extensions/minimax/provider-registration.js +0 -2
- package/dist/extensions/minimax/speech-provider.d.ts +0 -5
- package/dist/extensions/minimax/speech-provider.js +0 -2
- package/dist/extensions/minimax/tts.d.ts +0 -20
- package/dist/extensions/minimax/tts.js +0 -2
- package/dist/extensions/minimax/video-generation-provider.d.ts +0 -7
- package/dist/extensions/minimax/video-generation-provider.js +0 -2
- package/dist/extensions/minimax/web-search-contract-api.d.ts +0 -5
- package/dist/extensions/minimax/web-search-contract-api.js +0 -31
- package/dist/extensions/minimax/web-search-provider.d.ts +0 -5
- package/dist/extensions/minimax/web-search-provider.js +0 -2
- package/dist/extensions/moonshot/api.d.ts +0 -3
- package/dist/extensions/moonshot/api.js +0 -4
- package/dist/extensions/moonshot/fengming.plugin.json +0 -250
- package/dist/extensions/moonshot/index.d.ts +0 -11
- package/dist/extensions/moonshot/index.js +0 -70
- package/dist/extensions/moonshot/media-understanding-provider.d.ts +0 -6
- package/dist/extensions/moonshot/media-understanding-provider.js +0 -2
- package/dist/extensions/moonshot/onboard.d.ts +0 -2
- package/dist/extensions/moonshot/onboard.js +0 -2
- package/dist/extensions/moonshot/package.json +0 -15
- package/dist/extensions/moonshot/provider-catalog.d.ts +0 -2
- package/dist/extensions/moonshot/provider-catalog.js +0 -2
- package/dist/extensions/moonshot/provider-contract-api.d.ts +0 -5
- package/dist/extensions/moonshot/provider-contract-api.js +0 -27
- package/dist/extensions/moonshot/provider-discovery.d.ts +0 -5
- package/dist/extensions/moonshot/provider-discovery.js +0 -15
- package/dist/extensions/moonshot/web-search-contract-api.d.ts +0 -5
- package/dist/extensions/moonshot/web-search-contract-api.js +0 -29
- package/dist/extensions/moonshot/web-search-provider.d.ts +0 -5
- package/dist/extensions/moonshot/web-search-provider.js +0 -2
- package/dist/extensions/qianfan/api.d.ts +0 -3
- package/dist/extensions/qianfan/api.js +0 -3
- package/dist/extensions/qianfan/fengming.plugin.json +0 -89
- package/dist/extensions/qianfan/index.d.ts +0 -11
- package/dist/extensions/qianfan/index.js +0 -26
- package/dist/extensions/qianfan/onboard.d.ts +0 -2
- package/dist/extensions/qianfan/onboard.js +0 -2
- package/dist/extensions/qianfan/package.json +0 -15
- package/dist/extensions/qianfan/provider-catalog.d.ts +0 -2
- package/dist/extensions/qianfan/provider-catalog.js +0 -2
- package/dist/extensions/qwen/api.d.ts +0 -4
- package/dist/extensions/qwen/api.js +0 -5
- package/dist/extensions/qwen/fengming.plugin.json +0 -389
- package/dist/extensions/qwen/index.d.ts +0 -11
- package/dist/extensions/qwen/index.js +0 -202
- package/dist/extensions/qwen/media-understanding-provider.d.ts +0 -6
- package/dist/extensions/qwen/media-understanding-provider.js +0 -2
- package/dist/extensions/qwen/model-definitions.d.ts +0 -2
- package/dist/extensions/qwen/model-definitions.js +0 -2
- package/dist/extensions/qwen/models.d.ts +0 -2
- package/dist/extensions/qwen/models.js +0 -2
- package/dist/extensions/qwen/onboard.d.ts +0 -21
- package/dist/extensions/qwen/onboard.js +0 -2
- package/dist/extensions/qwen/package.json +0 -15
- package/dist/extensions/qwen/provider-catalog.d.ts +0 -2
- package/dist/extensions/qwen/provider-catalog.js +0 -2
- package/dist/extensions/qwen/stream.d.ts +0 -2
- package/dist/extensions/qwen/stream.js +0 -2
- package/dist/extensions/qwen/video-generation-provider.d.ts +0 -6
- package/dist/extensions/qwen/video-generation-provider.js +0 -2
- package/dist/extensions/sensenova/fengming.plugin.json +0 -69
- package/dist/extensions/sensenova/index.d.ts +0 -11
- package/dist/extensions/sensenova/index.js +0 -45
- package/dist/extensions/sensenova/models.d.ts +0 -7
- package/dist/extensions/sensenova/models.js +0 -2
- package/dist/extensions/sensenova/onboard.d.ts +0 -5
- package/dist/extensions/sensenova/onboard.js +0 -2
- package/dist/extensions/sensenova/package.json +0 -15
- package/dist/extensions/sensenova/provider-catalog.d.ts +0 -2
- package/dist/extensions/sensenova/provider-catalog.js +0 -2
- package/dist/extensions/sensenova/provider-discovery.d.ts +0 -2
- package/dist/extensions/sensenova/provider-discovery.js +0 -5
- package/dist/extensions/stepfun/fengming.plugin.json +0 -162
- package/dist/extensions/stepfun/index.d.ts +0 -12
- package/dist/extensions/stepfun/index.js +0 -165
- package/dist/extensions/stepfun/onboard.d.ts +0 -7
- package/dist/extensions/stepfun/onboard.js +0 -2
- package/dist/extensions/stepfun/package.json +0 -15
- package/dist/extensions/stepfun/provider-catalog.d.ts +0 -14
- package/dist/extensions/stepfun/provider-catalog.js +0 -2
- package/dist/extensions/tencent/api.d.ts +0 -3
- package/dist/extensions/tencent/api.js +0 -4
- package/dist/extensions/tencent/fengming.plugin.json +0 -105
- package/dist/extensions/tencent/index.d.ts +0 -12
- package/dist/extensions/tencent/index.js +0 -62
- package/dist/extensions/tencent/models.d.ts +0 -2
- package/dist/extensions/tencent/models.js +0 -2
- package/dist/extensions/tencent/onboard.d.ts +0 -6
- package/dist/extensions/tencent/onboard.js +0 -2
- package/dist/extensions/tencent/package.json +0 -15
- package/dist/extensions/tencent/provider-catalog.d.ts +0 -2
- package/dist/extensions/tencent/provider-catalog.js +0 -2
- package/dist/extensions/tencent/provider-discovery.d.ts +0 -5
- package/dist/extensions/tencent/provider-discovery.js +0 -14
- package/dist/extensions/tiangong/fengming.plugin.json +0 -69
- package/dist/extensions/tiangong/index.d.ts +0 -11
- package/dist/extensions/tiangong/index.js +0 -45
- package/dist/extensions/tiangong/models.d.ts +0 -7
- package/dist/extensions/tiangong/models.js +0 -2
- package/dist/extensions/tiangong/onboard.d.ts +0 -5
- package/dist/extensions/tiangong/onboard.js +0 -2
- package/dist/extensions/tiangong/package.json +0 -15
- package/dist/extensions/tiangong/provider-catalog.d.ts +0 -2
- package/dist/extensions/tiangong/provider-catalog.js +0 -2
- package/dist/extensions/tiangong/provider-discovery.d.ts +0 -2
- package/dist/extensions/tiangong/provider-discovery.js +0 -5
- package/dist/extensions/volcengine/api.d.ts +0 -12
- package/dist/extensions/volcengine/api.js +0 -4
- package/dist/extensions/volcengine/fengming.plugin.json +0 -263
- package/dist/extensions/volcengine/index.d.ts +0 -12
- package/dist/extensions/volcengine/index.js +0 -88
- package/dist/extensions/volcengine/models.d.ts +0 -2
- package/dist/extensions/volcengine/models.js +0 -2
- package/dist/extensions/volcengine/package.json +0 -15
- package/dist/extensions/volcengine/provider-catalog.d.ts +0 -2
- package/dist/extensions/volcengine/provider-catalog.js +0 -2
- package/dist/extensions/volcengine/provider-discovery.d.ts +0 -5
- package/dist/extensions/volcengine/provider-discovery.js +0 -23
- package/dist/extensions/volcengine/speech-provider.d.ts +0 -5
- package/dist/extensions/volcengine/speech-provider.js +0 -2
- package/dist/extensions/volcengine/tts.d.ts +0 -22
- package/dist/extensions/volcengine/tts.js +0 -2
- package/dist/extensions/weixin/fengming.plugin.json +0 -22
- package/dist/extensions/weixin/index.d.ts +0 -26
- package/dist/extensions/weixin/index.js +0 -862
- package/dist/extensions/weixin/package.json +0 -45
- package/dist/extensions/xiaomi/api.d.ts +0 -3
- package/dist/extensions/xiaomi/api.js +0 -3
- package/dist/extensions/xiaomi/fengming.plugin.json +0 -260
- package/dist/extensions/xiaomi/index.d.ts +0 -12
- package/dist/extensions/xiaomi/index.js +0 -284
- package/dist/extensions/xiaomi/onboard.d.ts +0 -2
- package/dist/extensions/xiaomi/onboard.js +0 -2
- package/dist/extensions/xiaomi/package.json +0 -15
- package/dist/extensions/xiaomi/provider-catalog.d.ts +0 -2
- package/dist/extensions/xiaomi/provider-catalog.js +0 -2
- package/dist/extensions/xiaomi/speech-provider.d.ts +0 -5
- package/dist/extensions/xiaomi/speech-provider.js +0 -2
- package/dist/extensions/xiaomi/stream.d.ts +0 -5
- package/dist/extensions/xiaomi/stream.js +0 -2
- package/dist/extensions/xiaomi/thinking.d.ts +0 -11
- package/dist/extensions/xiaomi/thinking.js +0 -2
- package/dist/extensions/xingchen/fengming.plugin.json +0 -69
- package/dist/extensions/xingchen/index.d.ts +0 -11
- package/dist/extensions/xingchen/index.js +0 -45
- package/dist/extensions/xingchen/models.d.ts +0 -7
- package/dist/extensions/xingchen/models.js +0 -2
- package/dist/extensions/xingchen/onboard.d.ts +0 -5
- package/dist/extensions/xingchen/onboard.js +0 -2
- package/dist/extensions/xingchen/package.json +0 -15
- package/dist/extensions/xingchen/provider-catalog.d.ts +0 -2
- package/dist/extensions/xingchen/provider-catalog.js +0 -2
- package/dist/extensions/xingchen/provider-discovery.d.ts +0 -2
- package/dist/extensions/xingchen/provider-discovery.js +0 -5
- package/dist/extensions/yi/fengming.plugin.json +0 -84
- package/dist/extensions/yi/index.d.ts +0 -11
- package/dist/extensions/yi/index.js +0 -45
- package/dist/extensions/yi/models.d.ts +0 -7
- package/dist/extensions/yi/models.js +0 -2
- package/dist/extensions/yi/onboard.d.ts +0 -5
- package/dist/extensions/yi/onboard.js +0 -2
- package/dist/extensions/yi/package.json +0 -15
- package/dist/extensions/yi/provider-catalog.d.ts +0 -2
- package/dist/extensions/yi/provider-catalog.js +0 -2
- package/dist/extensions/yi/provider-discovery.d.ts +0 -2
- package/dist/extensions/yi/provider-discovery.js +0 -5
- package/dist/extensions/zai/api.d.ts +0 -4
- package/dist/extensions/zai/api.js +0 -4
- package/dist/extensions/zai/detect.d.ts +0 -2
- package/dist/extensions/zai/detect.js +0 -2
- package/dist/extensions/zai/fengming.plugin.json +0 -377
- package/dist/extensions/zai/index.d.ts +0 -12
- package/dist/extensions/zai/index.js +0 -297
- package/dist/extensions/zai/media-understanding-provider.d.ts +0 -5
- package/dist/extensions/zai/media-understanding-provider.js +0 -2
- package/dist/extensions/zai/model-definitions.d.ts +0 -2
- package/dist/extensions/zai/model-definitions.js +0 -2
- package/dist/extensions/zai/onboard.d.ts +0 -2
- package/dist/extensions/zai/onboard.js +0 -2
- package/dist/extensions/zai/package.json +0 -15
- package/dist/extensions/zai/runtime-api.d.ts +0 -2
- package/dist/extensions/zai/runtime-api.js +0 -2
- package/dist/extensions/zhinao/fengming.plugin.json +0 -69
- package/dist/extensions/zhinao/index.d.ts +0 -11
- package/dist/extensions/zhinao/index.js +0 -45
- package/dist/extensions/zhinao/models.d.ts +0 -7
- package/dist/extensions/zhinao/models.js +0 -2
- package/dist/extensions/zhinao/onboard.d.ts +0 -5
- package/dist/extensions/zhinao/onboard.js +0 -2
- package/dist/extensions/zhinao/package.json +0 -15
- package/dist/extensions/zhinao/provider-catalog.d.ts +0 -2
- package/dist/extensions/zhinao/provider-catalog.js +0 -2
- package/dist/extensions/zhinao/provider-discovery.d.ts +0 -2
- package/dist/extensions/zhinao/provider-discovery.js +0 -5
- package/dist/fengming-runtime-0jdu_329.d.ts +0 -153
- package/dist/fengming-tools-gQkwsWYz.js +0 -12221
- package/dist/fengming.plugin-C-Kdi1_5.js +0 -130
- package/dist/fengming.plugin-CRPqMj85.js +0 -166
- package/dist/gateway-cli-BV1V43-D.js +0 -443
- package/dist/gateway-method-runtime-J2OPP_oH.js +0 -21
- package/dist/get-reply-BE8ZGJos.js +0 -5198
- package/dist/get-reply-from-config.runtime-C5wfxVI_.js +0 -2
- package/dist/heartbeat-runner-_0HlObMb.js +0 -5
- package/dist/heartbeat-runner.runtime-DvYz_4Z3.js +0 -3
- package/dist/hook-runtime-BH9moP5T.js +0 -4
- package/dist/hooks-icCwsmrQ.js +0 -536
- package/dist/host-compat-dfJvEfe7.d.ts +0 -21
- package/dist/http-registry-Buj7R-F_.d.ts +0 -23
- package/dist/image-generation-provider-hrRXkkGc.js +0 -152
- package/dist/inbound-reply-dispatch-5AYt56Yt.js +0 -147
- package/dist/inbound-reply-dispatch-B5weFW8i.js +0 -2
- package/dist/inbound-reply-dispatch-cJh4H31y.d.ts +0 -156
- package/dist/infra-runtime-3_0R8nmO.js +0 -32
- package/dist/init-BnfkYG_k.js +0 -59
- package/dist/interactive-V8NfYsTW.d.ts +0 -26
- package/dist/isolated-agent-CgH7dfOj.js +0 -1097
- package/dist/isolated-agent-dBWkiw0a.js +0 -2
- package/dist/kernel-Ds2aqAJF.d.ts +0 -241
- package/dist/kimi-web-search-provider-QJT3Ftj3.js +0 -80
- package/dist/kimi-web-search-provider.runtime-Dj3SS4T5.js +0 -307
- package/dist/kimi-web-search-provider.runtime.js +0 -1
- package/dist/lib-Dg4yjNFQ.js +0 -871
- package/dist/lifecycle-B9k7QGsS.js +0 -570
- package/dist/list.probe-CbVHFNwf.js +0 -2
- package/dist/list.probe-CxiEBmyW.js +0 -451
- package/dist/list.status-command-DE-edGgB.js +0 -815
- package/dist/llm-slug-generator-DJgq9eFd.js +0 -78
- package/dist/loader-5AqYM9PC.d.ts +0 -142
- package/dist/local-dispatch.runtime-D3F4v51B.js +0 -10
- package/dist/manager-BWf1ks-Z.d.ts +0 -409
- package/dist/mcp-http-DU7Nsg4P.js +0 -583
- package/dist/mcp-http-iZCW6Cet.js +0 -2
- package/dist/media-runtime-DZ5RpQN7.d.ts +0 -261
- package/dist/media-understanding-DEdEyoQB.d.ts +0 -46
- package/dist/media-understanding-provider-4JHrQOUE.js +0 -70
- package/dist/media-understanding-provider-BV7O82XV.js +0 -29
- package/dist/media-understanding-provider-BlPRhYkx.js +0 -69
- package/dist/media-understanding-provider-BuX8eQLj.js +0 -13
- package/dist/memory-core-host-engine-embeddings-BDu5fx8E.d.ts +0 -324
- package/dist/memory-core-host-engine-storage-CdCuH-E2.d.ts +0 -54
- package/dist/message-handler-L6QLWNVP.js +0 -1806
- package/dist/minimax-web-search-provider-_gxeEOy8.js +0 -58
- package/dist/minimax-web-search-provider.runtime-BF4mGi6U.js +0 -148
- package/dist/minimax-web-search-provider.runtime.js +0 -1
- package/dist/model-catalog-DCnRkX8f.d.ts +0 -88
- package/dist/model-definitions-B2gY43hI.d.ts +0 -34
- package/dist/model-definitions-BLOyeH5h.js +0 -73
- package/dist/model-definitions-CoByf5mT.js +0 -243
- package/dist/model-definitions-WP3OmzbS.d.ts +0 -57
- package/dist/model-selection-DhTE6GZD.js +0 -352
- package/dist/models--iAR9QkZ.js +0 -175
- package/dist/models-8ImVEkvh.js +0 -36
- package/dist/models-BIDM8htk.js +0 -48
- package/dist/models-BRgRfrcS.js +0 -36
- package/dist/models-Bib5-APc.js +0 -67
- package/dist/models-Bl67zOoe.js +0 -36
- package/dist/models-BqDDYFE3.d.ts +0 -65
- package/dist/models-BtRQoRIu.js +0 -36
- package/dist/models-BvXmOXik.js +0 -48
- package/dist/models-C-sJciOD.d.ts +0 -9
- package/dist/models-COnXPdlL.js +0 -24
- package/dist/models-CXTmk-Da.d.ts +0 -8
- package/dist/models-Cz0C_8re.js +0 -36
- package/dist/models-DbwEIt-m.d.ts +0 -15
- package/dist/models-DgXkSADi.js +0 -30
- package/dist/models-cli-Bv3y3JgQ.js +0 -257
- package/dist/monitor-BiVOsbbN.js +0 -1024
- package/dist/monitor-BumfRp1t.js +0 -60
- package/dist/monitor.account-Cd6EwtuZ.js +0 -5382
- package/dist/music-generation-provider-ZdDMiC-c.js +0 -308
- package/dist/nodes-C0f8XgD5.js +0 -1483
- package/dist/nodes-Dk4vOgg9.js +0 -3
- package/dist/nodes-pending-Cjg09MXz.js +0 -211
- package/dist/oauth-BIO69Qw0.d.ts +0 -25
- package/dist/oauth-CnO10TN2.js +0 -207
- package/dist/onboard-B3BYT5k7.js +0 -34
- package/dist/onboard-BDMNV6RE.js +0 -23
- package/dist/onboard-B_WNNy5F.d.ts +0 -6
- package/dist/onboard-BbyMaErU.js +0 -69
- package/dist/onboard-BuYPNE6j2.js +0 -23
- package/dist/onboard-C394zMnM.d.ts +0 -11
- package/dist/onboard-CHn4oVbY.js +0 -24
- package/dist/onboard-CPpVbb0O.js +0 -73
- package/dist/onboard-CWDx7Crt.js +0 -23
- package/dist/onboard-CbzkwBzu.d.ts +0 -12
- package/dist/onboard-D099qUd0.js +0 -23
- package/dist/onboard-D7dbzfHc.js +0 -23
- package/dist/onboard-DB-x0nHF.js +0 -30
- package/dist/onboard-DFVrRnxJ.js +0 -23
- package/dist/onboard-DFiqoOc2.d.ts +0 -7
- package/dist/onboard-DJaMK3rr.d.ts +0 -6
- package/dist/onboard-DMdK8D_h.js +0 -67
- package/dist/onboard-J-KL-I6m.js +0 -48
- package/dist/onboard-MIBU-Rmv.js +0 -39
- package/dist/onboard-vmGylfFe.js +0 -23
- package/dist/openai-compat-errors-Dcr5Y8bF.js +0 -136
- package/dist/openai-http-CcqspzU6.js +0 -836
- package/dist/openresponses-http-BnyYYvUF.js +0 -1175
- package/dist/operations-H2Oq0KYz.js +0 -805
- package/dist/outbound.types-BhRehecY.d.ts +0 -291
- package/dist/plugin-enabled-CEIKWKrq.js +0 -232
- package/dist/plugin-entry-CTVRRaaA.d.ts +0 -47
- package/dist/plugin-registration-BTyO5Fwt.js +0 -97
- package/dist/plugin-runtime-_XF2N_UQ.d.ts +0 -117
- package/dist/plugin-sdk/bundled-channel-config-schema-BsOWCrJT.d.ts +0 -3169
- package/dist/plugin-service-B91jVlmZ.d.ts +0 -24
- package/dist/plugin-service-CtGwVz8V.js +0 -1249
- package/dist/prepare.runtime-9dlboph7.js +0 -798
- package/dist/preview-warnings-DJx4KJpC.js +0 -618
- package/dist/program-CWC-NBBB.js +0 -131
- package/dist/provider-api-key-auth-BmNcYRMl.d.ts +0 -27
- package/dist/provider-auth-api-key-CCaFiqY3.js +0 -5
- package/dist/provider-auth-result-D_E9dcVc.d.ts +0 -21
- package/dist/provider-catalog-5KZLmrDO.js +0 -11
- package/dist/provider-catalog-7P6AvDzS.js +0 -11
- package/dist/provider-catalog-B2gyTjTU.js +0 -88
- package/dist/provider-catalog-B3YBhe77.js +0 -17
- package/dist/provider-catalog-B7XEeuUm.js +0 -11
- package/dist/provider-catalog-BFGPRd9v.js +0 -17
- package/dist/provider-catalog-BLvkIMSk.d.ts +0 -6
- package/dist/provider-catalog-BPBL9mJf.d.ts +0 -5
- package/dist/provider-catalog-BRkZ6-HD.d.ts +0 -5
- package/dist/provider-catalog-Bfl_AoTZ.js +0 -142
- package/dist/provider-catalog-BpiHWHu1.js +0 -11
- package/dist/provider-catalog-C1qDLekT.d.ts +0 -5
- package/dist/provider-catalog-CKWNCfry.js +0 -11
- package/dist/provider-catalog-CUHB2pSt.d.ts +0 -7
- package/dist/provider-catalog-CWqN2j6J.d.ts +0 -5
- package/dist/provider-catalog-CZ8oYbx3.js +0 -11
- package/dist/provider-catalog-CcQ5-4ZW.d.ts +0 -6
- package/dist/provider-catalog-Cd16uZ0U.js +0 -20
- package/dist/provider-catalog-CpF2D0VK.js +0 -61
- package/dist/provider-catalog-CvXq36zW.d.ts +0 -5
- package/dist/provider-catalog-D2pgEME3.js +0 -48
- package/dist/provider-catalog-DPzcupEl.d.ts +0 -5
- package/dist/provider-catalog-DaeI606G.d.ts +0 -9
- package/dist/provider-catalog-DrOCtTb-.js +0 -11
- package/dist/provider-catalog-DwZ1J2Al.d.ts +0 -6
- package/dist/provider-catalog-Dy7IcHmS.js +0 -107
- package/dist/provider-catalog-TsZS52nq.d.ts +0 -10
- package/dist/provider-catalog-YqIFRCND.d.ts +0 -5
- package/dist/provider-catalog-Ywb5jRwG.d.ts +0 -5
- package/dist/provider-catalog-evknl1oN.js +0 -11
- package/dist/provider-catalog-l0hFpFO2.d.ts +0 -17
- package/dist/provider-catalog-shared-DsRBv0Tp.d.ts +0 -62
- package/dist/provider-dispatcher-BMy9mBJ1.js +0 -22
- package/dist/provider-model-shared-CPAfQBNs.d.ts +0 -143
- package/dist/provider-models-Diu65OcG.d.ts +0 -18
- package/dist/provider-models-LE7PlLYY.js +0 -22
- package/dist/provider-onboard-CpvXEmvz.d.ts +0 -91
- package/dist/provider-registration-DF-LkmNE.js +0 -235
- package/dist/provider-registry-D9cTPW1F.d.ts +0 -8
- package/dist/provider-registry-DI7gMKUP.d.ts +0 -8
- package/dist/provider-registry-DZtgZDkl.d.ts +0 -29
- package/dist/provider-self-hosted-setup-CoHvoyKm.d.ts +0 -74
- package/dist/provider-stream-BpXJr5Ap.d.ts +0 -139
- package/dist/provider-stream-family-Bj5aBD8w.js +0 -2
- package/dist/provider-stream-shared-BaUkhUHj.d.ts +0 -132
- package/dist/provider-usage-DFUhW2do.js +0 -651
- package/dist/provider-web-search-contract-fields-CkXzSsWu.d.ts +0 -25
- package/dist/pw-ai-9Q_dIq4B.js +0 -3064
- package/dist/register.agent-CbfrlzXB.js +0 -152
- package/dist/register.crestodian-CEg0rPfK.js +0 -24
- package/dist/register.maintenance-k9N8I4Wg.js +0 -85
- package/dist/register.subclis-CrXOeaS3.js +0 -3
- package/dist/register.subclis-DfKlni8N.js +0 -31
- package/dist/register.subclis-core-Bg4wbDsO.js +0 -278
- package/dist/registry-Bh3-P2HL.d.ts +0 -8
- package/dist/registry-types-BmEUS4d3.d.ts +0 -392
- package/dist/repair-sequencing-E4yViXG9.js +0 -652
- package/dist/reply-payload-S2mrc_Mh.d.ts +0 -200
- package/dist/reply-turn-admission-BBoPjmGB.js +0 -2056
- package/dist/reply.runtime-C5wfxVI_.js +0 -2
- package/dist/result-fallback-classifier-CX4iLD1G.js +0 -98
- package/dist/route-CifxcQZ1.js +0 -475
- package/dist/routes-B3XAOeWo.js +0 -2
- package/dist/routes-H185h3U-.js +0 -3701
- package/dist/run-CTJFbwbB.js +0 -1162
- package/dist/run-command-B7B53tYk.js +0 -23
- package/dist/run-command-BFuxRDxS.js +0 -2
- package/dist/run-context-C7im9ICg.js +0 -66
- package/dist/run-embedded.runtime-TljBTbzh.js +0 -4
- package/dist/run-execution-cli.runtime-Bt5zwx1W.js +0 -4
- package/dist/run-executor.runtime-hmbWX2Ct.js +0 -330
- package/dist/run-subagent-registry.runtime-B70X80nS.js +0 -2
- package/dist/runtime-DoKE0o7v.js +0 -436
- package/dist/runtime-api-Ca4Llbgf.js +0 -12
- package/dist/runtime-api-pa8xcEmg.d.ts +0 -5
- package/dist/runtime-channel-CFQ59svm.js +0 -148
- package/dist/runtime-channel-DRwCWGUx.js +0 -2
- package/dist/runtime-embedded-agent.runtime-DwmqKUVp.js +0 -2
- package/dist/runtime-forwarders-BMThPHg_.d.ts +0 -39
- package/dist/sdk-setup-tools-Cg_Tabrf.js +0 -8
- package/dist/selection-COhr7g82.js +0 -18365
- package/dist/selection-_G44EVqd.js +0 -3
- package/dist/send-media-BNc67G7I.js +0 -2072
- package/dist/server-5rR0RCpI.js +0 -24
- package/dist/server-context-BhiPROPA.js +0 -955
- package/dist/server-context-OShBAJZQ.js +0 -2
- package/dist/server-cron-Bkzb9edh.js +0 -3173
- package/dist/server-cron-DdR-ugiU.js +0 -2
- package/dist/server-lwtC1vaS.js +0 -72
- package/dist/server-methods-BY_ZqDFJ.js +0 -497
- package/dist/server-node-events-CLvE94AS.js +0 -597
- package/dist/server-plugin-bootstrap-cKOAH5GL.js +0 -71
- package/dist/server-plugins-CPpUykw5.js +0 -435
- package/dist/server-reload-handlers-uzt4VDZ-.js +0 -719
- package/dist/server-restart-sentinel-CpvV0t4O.js +0 -700
- package/dist/server-runtime-services-BhOHoerM.js +0 -147
- package/dist/server-runtime-services-D3Ig68nC.js +0 -3
- package/dist/server-startup-plugins-DslzKVHK.js +0 -127
- package/dist/server-startup-post-attach-DPFBTQez.js +0 -793
- package/dist/server-ws-runtime-D0zoWoiz.js +0 -374
- package/dist/server.impl-CzqLQ3qt.js +0 -2622
- package/dist/session-kill-http-D8JhwZVS.js +0 -121
- package/dist/session-reset-service-uoi7E4Xp.js +0 -651
- package/dist/session-status.runtime-CZK5IU8w.js +0 -2
- package/dist/session-subagent-reactivation.runtime-BSO00-FY.js +0 -2
- package/dist/session-tab-registry-DM9U7e3o.js +0 -551
- package/dist/sessions-B-SkIoaa.js +0 -1917
- package/dist/sessions-history-http-DCiOG4FK.js +0 -432
- package/dist/sessions-patch-DlAAvQvB.js +0 -401
- package/dist/sessions-resolve-DfMXookg.js +0 -180
- package/dist/sessions.runtime-0V2YxKxB.js +0 -2
- package/dist/snapshot-urls-Ble1-NEW.js +0 -317
- package/dist/speech-core-Bk60ZS_y.d.ts +0 -49
- package/dist/speech-provider-DQO9eZd0.js +0 -233
- package/dist/speech-provider-DnBCla4V.js +0 -171
- package/dist/speech-provider-DyYHFxT5.js +0 -227
- package/dist/standalone-9EWfcxeO.js +0 -42
- package/dist/startup-context-nti4X0_w.js +0 -314
- package/dist/status-subagents.runtime-CPZb1EF1.js +0 -32
- package/dist/status-text-C1Hf37lF.js +0 -301
- package/dist/stream-9VBt1MDs.js +0 -26
- package/dist/stream-B_3P7v7P.js +0 -86
- package/dist/stream-CXsue2-v.d.ts +0 -9
- package/dist/stream-oNBFxfKt.d.ts +0 -5
- package/dist/subagent-announce-CPjQQLy8.js +0 -353
- package/dist/subagent-announce-delivery-B6iBOicL.js +0 -1369
- package/dist/subagent-control-DP72sk-l.js +0 -492
- package/dist/subagent-hooks-B1oUIYH3.js +0 -2
- package/dist/subagent-hooks-BkGj4_xI.js +0 -230
- package/dist/subagent-hooks-api-D2mulK3S.js +0 -23
- package/dist/subagent-registry-CEKAUB5h.js +0 -3
- package/dist/subagent-registry-OUVucPAn.js +0 -2627
- package/dist/subagent-session-cleanup-Bx8d3kw0.js +0 -390
- package/dist/system-CelaP2zI.js +0 -111
- package/dist/talk-DGOI3Lu3.js +0 -2454
- package/dist/target-id-BXRG7x9x.js +0 -107
- package/dist/thinking-B8V29FhB.js +0 -35
- package/dist/thread-bindings-DpVdEPZ0.js +0 -228
- package/dist/tool-DHzDpxE4.js +0 -143
- package/dist/tool-dispatch-ClP3Rc7g.js +0 -155
- package/dist/tool-resolution-CZcLod1d.js +0 -153
- package/dist/tool-split-BhiQ8676.d.ts +0 -19
- package/dist/tools-ZvSvbsCW.d.ts +0 -38
- package/dist/tools-effective-C2mHZT-A.js +0 -442
- package/dist/tools-effective-inventory-ctnM7hc6.js +0 -379
- package/dist/tools-invoke-Ci6Rux2s.js +0 -51
- package/dist/tools-invoke-http-CJflXcJk.js +0 -68
- package/dist/tools-invoke-shared-BLu_mJEX.js +0 -200
- package/dist/tts-B2rPJPij.js +0 -83
- package/dist/tts-Gp9FI3_n.js +0 -163
- package/dist/tts-runtime-DNi1HXPF.d.ts +0 -230
- package/dist/tui-BUhfQ9vD.js +0 -3
- package/dist/tui-BhH5mvLf.js +0 -2
- package/dist/tui-backend-C_4ajTHI.js +0 -257
- package/dist/tui-cli-BhWJ-QoB.js +0 -40
- package/dist/tui-ink-run-BTWbUQGb.js +0 -7414
- package/dist/tui-ink-run-DfTdivkh.js +0 -2
- package/dist/types-B4fW3r5y.d.ts +0 -111
- package/dist/types-DI62NfFe.d.ts +0 -7034
- package/dist/types-sAih_uQb.d.ts +0 -393
- package/dist/types.public-B3MKhuo2.d.ts +0 -70
- package/dist/video-generation-B9c6a5cw.js +0 -207
- package/dist/video-generation-BgJp7UIA.d.ts +0 -224
- package/dist/video-generation-provider-BjiVjf40.js +0 -325
- package/dist/video-generation-provider-CsnQJg_h.js +0 -297
- package/dist/video-generation-provider-DtU-ZPqP.js +0 -64
- package/dist/video-generation-provider-wZ0bzv0e.js +0 -77
- package/dist/webhook-targets-Cy8e7y3g.d.ts +0 -99
- package/skills/canvas/SKILL.md +0 -78
- package/skills/clawhub/SKILL.md +0 -77
- package/skills/coding-agent/SKILL.md +0 -143
- package/skills/diagram-maker/SKILL.md +0 -53
- package/skills/diagram-maker/references/excalidraw-patterns.md +0 -85
- package/skills/diagram-maker/references/svg-template.md +0 -112
- package/skills/gemini/SKILL.md +0 -47
- package/skills/gh-issues/SKILL.md +0 -213
- package/skills/gifgrep/SKILL.md +0 -85
- package/skills/github/SKILL.md +0 -84
- package/skills/healthcheck/SKILL.md +0 -105
- package/skills/mcporter/SKILL.md +0 -61
- package/skills/meme-maker/SKILL.md +0 -42
- package/skills/meme-maker/references/templates.json +0 -358
- package/skills/meme-maker/scripts/meme.mjs +0 -398
- package/skills/model-usage/SKILL.md +0 -71
- package/skills/model-usage/references/codexbar-cli.md +0 -33
- package/skills/model-usage/scripts/model_usage.py +0 -319
- package/skills/model-usage/scripts/test_model_usage.py +0 -40
- package/skills/nano-pdf/SKILL.md +0 -38
- package/skills/node-connect/SKILL.md +0 -143
- package/skills/node-inspect-debugger/SKILL.md +0 -85
- package/skills/openai-whisper/SKILL.md +0 -38
- package/skills/openai-whisper-api/SKILL.md +0 -71
- package/skills/openai-whisper-api/scripts/transcribe.sh +0 -154
- package/skills/oracle/SKILL.md +0 -126
- package/skills/pyproject.toml +0 -10
- package/skills/python-debugpy/SKILL.md +0 -73
- package/skills/sag/SKILL.md +0 -87
- package/skills/session-logs/SKILL.md +0 -151
- package/skills/sherpa-onnx-tts/SKILL.md +0 -109
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +0 -178
- package/skills/skill-creator/SKILL.md +0 -78
- package/skills/skill-creator/license.txt +0 -202
- package/skills/skill-creator/scripts/init_skill.py +0 -378
- package/skills/skill-creator/scripts/package_skill.py +0 -139
- package/skills/skill-creator/scripts/quick_validate.py +0 -169
- package/skills/skill-creator/scripts/test_package_skill.py +0 -161
- package/skills/skill-creator/scripts/test_quick_validate.py +0 -116
- package/skills/spike/SKILL.md +0 -51
- package/skills/summarize/SKILL.md +0 -87
- package/skills/taskflow/SKILL.md +0 -149
- package/skills/taskflow/examples/inbox-triage.lobster +0 -33
- package/skills/taskflow/examples/pr-intake.lobster +0 -32
- package/skills/taskflow-inbox-triage/SKILL.md +0 -119
- package/skills/video-frames/SKILL.md +0 -46
- package/skills/video-frames/scripts/frame.sh +0 -81
- package/skills/voice-call/SKILL.md +0 -45
- package/skills/weather/SKILL.md +0 -64
- /package/dist/{acp-runtime-backend-DbchQ02o.js → acp-runtime-backend-DZ1Lnt7f.js} +0 -0
- /package/dist/{delegate-k1aptKei.js → delegate-CwhxUdeb.js} +0 -0
- /package/dist/{dispatch-acp-CD4YxPpf.js → dispatch-acp-BP4I5ZQf.js} +0 -0
- /package/dist/{exec-approvals-ByWUCFQM.js → exec-approvals-ByWUCFQM2.js} +0 -0
- /package/dist/{heartbeat-runner-CM0UZxa_.js → heartbeat-runner-CL3alQ8-.js} +0 -0
- /package/dist/{index-B0VJdRJQ.d.ts → index-B0VJdRJQ2.d.ts} +0 -0
- /package/dist/{library-CQ71yATP.js → library-CiTr_aqC.js} +0 -0
- /package/dist/{run-session-state-DbDeH-q6.js → run-session-state-BOMUtBKZ.js} +0 -0
- /package/dist/{session-subagent-reactivation-Bj91A2ms.js → session-subagent-reactivation-CH0C2I6Y.js} +0 -0
- /package/dist/{types-C4HgagiY2.d.ts → types-C4HgagiY.d.ts} +0 -0
|
@@ -0,0 +1,2057 @@
|
|
|
1
|
+
import { a as normalizeLowercaseStringOrEmpty, c as normalizeOptionalString, s as normalizeOptionalLowercaseString } from "./string-coerce-DKw2K5wM.js";
|
|
2
|
+
import { i as formatErrorMessage } from "./errors-C_Wa6a5T.js";
|
|
3
|
+
import { n as isAbortError } from "./unhandled-rejections-CyXc0Srv.js";
|
|
4
|
+
import { t as createLazyImportLoader } from "./lazy-promise-Djskx0qC.js";
|
|
5
|
+
import { c as isDiagnosticsEnabled } from "./diagnostic-events-Bwqd0ZOT.js";
|
|
6
|
+
import { t as createSubsystemLogger } from "./subsystem-B7U-DPv3.js";
|
|
7
|
+
import { _ as resolveSessionAgentId } from "./agent-scope-EEbMCF2I.js";
|
|
8
|
+
import { n as isAcpSessionKey } from "./session-key-utils-CdfsDYvz.js";
|
|
9
|
+
import { o as resolveAgentWorkspaceDir, r as resolveAgentConfig } from "./agent-scope-config-BHdZonI2.js";
|
|
10
|
+
import { c as measureDiagnosticsTimelineSpan, l as measureDiagnosticsTimelineSpanSync } from "./plugin-metadata-snapshot-CHymO30I.js";
|
|
11
|
+
import { r as logVerbose } from "./globals-BMM_rcFF.js";
|
|
12
|
+
import { t as applyMergePatch } from "./merge-patch-DUwYfE67.js";
|
|
13
|
+
import { g as normalizeVerboseLevel } from "./thinking-BmfCvr5O.js";
|
|
14
|
+
import "./message-channel-core-rOsWksPZ.js";
|
|
15
|
+
import { i as normalizeMessageChannel } from "./message-channel-normalize-CaOaCinb.js";
|
|
16
|
+
import "./message-channel-DcN_7tYD.js";
|
|
17
|
+
import { i as getReplyPayloadMetadata, l as markReplyPayloadAsTtsSupplement, r as copyReplyPayloadMetadata, s as isReplyPayloadStatusNotice } from "./reply-payload-DM17pxMC.js";
|
|
18
|
+
import { n as getGlobalPluginRegistry, t as getGlobalHookRunner, u as fireAndForgetHook } from "./hook-runner-global-De3loPgD.js";
|
|
19
|
+
import { m as triggerInternalHook, n as createInternalHookEvent } from "./internal-hooks-DgzYHw8L.js";
|
|
20
|
+
import { u as resolveStorePath } from "./paths-C79m3Aob.js";
|
|
21
|
+
import { i as readSessionEntry, t as loadSessionStore, z as resolveSessionStoreEntry } from "./store-load-CVdafI-Y.js";
|
|
22
|
+
import { a as normalizeChannelId, t as getChannelPlugin } from "./registry-BfD-kLBR.js";
|
|
23
|
+
import { f as updateSessionStoreEntry } from "./store-DH20opqS.js";
|
|
24
|
+
import { t as normalizeChatType } from "./chat-type-DeA3YwAD.js";
|
|
25
|
+
import { n as resolveGroupSessionKey } from "./group-BhAqCyJo.js";
|
|
26
|
+
import { t as appendAssistantMessageToSessionTranscript } from "./transcript-g0svEjnG.js";
|
|
27
|
+
import { i as buildModelAliasIndex, x as resolveModelRefFromString } from "./model-selection-shared-vfQyPxy6.js";
|
|
28
|
+
import { s as resolveDefaultModelForAgent } from "./model-selection-C4gJ7iHA.js";
|
|
29
|
+
import { a as isNativeCommandTurn, c as resolveCommandTurnTargetSessionKey, s as resolveCommandTurnContext } from "./command-turn-context-Cqhb6nXp.js";
|
|
30
|
+
import { i as resolveTextCommand, r as normalizeCommandBody } from "./commands-registry-normalize-BS7j1B-J.js";
|
|
31
|
+
import { i as resolveSourceReplyVisibilityPolicy, t as isExplicitSourceReplyCommand } from "./source-reply-delivery-mode-IbdsphCJ.js";
|
|
32
|
+
import { p as replyRunRegistry } from "./reply-run-registry-CE6ehUBj.js";
|
|
33
|
+
import { g as markDiagnosticSessionProgress, i as logMessageDispatchStarted, r as logMessageDispatchCompleted, s as logMessageReceived } from "./diagnostic-B66j5Hib.js";
|
|
34
|
+
import { h as resolveToolProfilePolicy, l as mergeAlsoAllowPolicy } from "./tool-policy-Dv92jaRW.js";
|
|
35
|
+
import { t as isToolAllowedByPolicies } from "./tool-policy-match-BK9FXN4N.js";
|
|
36
|
+
import { n as getSessionBindingService } from "./session-binding-service-BjjMIxQb.js";
|
|
37
|
+
import { c as toPluginInboundClaimEvent, i as toInternalMessageReceivedContext, l as toPluginMessageContext, n as deriveInboundMessageHookContext, s as toPluginInboundClaimContext, u as toPluginMessageReceivedEvent } from "./message-hook-mappers-C-mvGDFP.js";
|
|
38
|
+
import { o as runReplyPayloadSendingHook, s as isOutboundDeliveryError } from "./deliver-jDF9kjsI.js";
|
|
39
|
+
import { m as resolveSendableOutboundReplyParts, s as hasOutboundReplyContent } from "./reply-payload-swpu2tGD.js";
|
|
40
|
+
import { D as isParentOwnedBackgroundAcpSession } from "./fengming-tools-DBLsJfsf.js";
|
|
41
|
+
import { o as resolveSubagentCapabilityStore, t as isSubagentEnvelopeSession } from "./subagent-capabilities-BPtXB0Jr.js";
|
|
42
|
+
import { i as resolveInheritedToolPolicyForSession, n as resolveEffectiveToolPolicy, o as resolveSubagentToolPolicyForSession, r as resolveGroupToolPolicy } from "./agent-tools.policy-CAz43ea3.js";
|
|
43
|
+
import { i as selectAgentHarness } from "./selection-DEPvzrW2.js";
|
|
44
|
+
import { n as normalizeTtsAutoMode } from "./tts-auto-mode-jJO08bho.js";
|
|
45
|
+
import { i as shouldCleanTtsDirectiveText, r as shouldAttemptTtsPayload, t as resolveConfiguredTtsMode } from "./tts-config-DZTpGcdO.js";
|
|
46
|
+
import { t as createTtsDirectiveTextStreamCleaner } from "./directives-C5xgI26A.js";
|
|
47
|
+
import { a as buildPluginBindingUnavailableText, b as touchConversationBindingRecord, c as hasShownPluginBindingFallbackNotice, d as markPluginBindingFallbackNoticeShown, h as toPluginConversationBinding, n as buildPluginBindingDeclinedText, r as buildPluginBindingErrorText, u as isPluginOwnedSessionBindingRecord, y as resolveConversationBindingRecord } from "./conversation-binding-BsrrLxjw.js";
|
|
48
|
+
import { t as resolveChannelModelOverride } from "./model-overrides-DLX8G4Uc.js";
|
|
49
|
+
import { n as hasActiveApprovalNativeRouteRuntime } from "./approval-native-route-coordinator-B6NgzbVd.js";
|
|
50
|
+
import { t as createDiagnosticMessageLifecycle } from "./message-lifecycle-DwGP2xHi.js";
|
|
51
|
+
import { r as matchPluginCommand } from "./commands-B_S6qZes.js";
|
|
52
|
+
import { n as resolveSendPolicy } from "./send-policy-C6dhXszH.js";
|
|
53
|
+
import { r as findCommandByNativeName } from "./commands-registry-Ca8q0Fs-.js";
|
|
54
|
+
import { n as isReplyProfilerEnabled } from "./reply-timing-tracker-DLRaKkVU.js";
|
|
55
|
+
import { a as resolveSessionRuntimeOverrideForProvider, n as resolveReplyTurnKind, t as admitReplyTurn } from "./reply-turn-admission-DMWNadoS.js";
|
|
56
|
+
import { n as resolveOriginMessageProvider } from "./origin-routing-CMrrA67a.js";
|
|
57
|
+
import { i as resolveConversationBindingContextFromMessage } from "./conversation-binding-input-CF1dayP1.js";
|
|
58
|
+
import { d as resolveEffectiveReplyRoute, l as withFullRuntimeReplyConfig, t as resolveRunTypingPolicy } from "./typing-policy-BqIN_Fzu.js";
|
|
59
|
+
import { n as commitInboundDedupe, r as releaseInboundDedupe, t as claimInboundDedupe } from "./inbound-dedupe-DbeC774x.js";
|
|
60
|
+
import { n as createReplyDispatcherWithTyping, r as waitForReplyDispatcherIdle, t as createReplyDispatcher } from "./reply-dispatcher-DjSNvGzA.js";
|
|
61
|
+
import { t as resolveRoutedDeliveryThreadId } from "./routed-delivery-thread-BlvaHYEh.js";
|
|
62
|
+
import { n as resolveStoredModelOverride } from "./stored-model-override-DYDNe185.js";
|
|
63
|
+
import { t as finalizeInboundContext } from "./inbound-context-CbkangX1.js";
|
|
64
|
+
import crypto from "node:crypto";
|
|
65
|
+
//#region src/auto-reply/dispatch-dispatcher.ts
|
|
66
|
+
async function settleReplyDispatcher(params) {
|
|
67
|
+
params.dispatcher.markComplete();
|
|
68
|
+
try {
|
|
69
|
+
await params.dispatcher.waitForIdle();
|
|
70
|
+
} finally {
|
|
71
|
+
await params.onSettled?.();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function withReplyDispatcher(params) {
|
|
75
|
+
try {
|
|
76
|
+
return await params.run();
|
|
77
|
+
} finally {
|
|
78
|
+
await settleReplyDispatcher(params);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/channels/plugins/exec-approval-local.ts
|
|
83
|
+
function shouldSuppressLocalExecApprovalPrompt(params) {
|
|
84
|
+
const channel = params.channel ? normalizeChannelId(params.channel) : null;
|
|
85
|
+
if (!channel) return false;
|
|
86
|
+
return getChannelPlugin(channel)?.outbound?.shouldSuppressLocalPayloadPrompt?.({
|
|
87
|
+
cfg: params.cfg,
|
|
88
|
+
accountId: params.accountId,
|
|
89
|
+
payload: params.payload,
|
|
90
|
+
hint: {
|
|
91
|
+
kind: "approval-pending",
|
|
92
|
+
approvalKind: "exec",
|
|
93
|
+
nativeRouteActive: hasActiveApprovalNativeRouteRuntime({
|
|
94
|
+
channel,
|
|
95
|
+
accountId: params.accountId,
|
|
96
|
+
approvalKind: "exec"
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
}) ?? false;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/auto-reply/reply/routing-policy.ts
|
|
103
|
+
function resolveReplyRoutingDecision(params) {
|
|
104
|
+
const originatingChannel = normalizeMessageChannel(params.originatingChannel);
|
|
105
|
+
const providerChannel = normalizeMessageChannel(params.provider);
|
|
106
|
+
const surfaceChannel = normalizeMessageChannel(params.surface);
|
|
107
|
+
const currentSurface = providerChannel ?? surfaceChannel;
|
|
108
|
+
const isInternalWebchatTurn = currentSurface === "webchat" && (surfaceChannel === "webchat" || !surfaceChannel) && params.explicitDeliverRoute !== true;
|
|
109
|
+
const shouldRouteToOriginating = Boolean(!params.suppressDirectUserDelivery && !isInternalWebchatTurn && params.isRoutableChannel(originatingChannel) && params.originatingTo && originatingChannel !== currentSurface);
|
|
110
|
+
return {
|
|
111
|
+
originatingChannel,
|
|
112
|
+
currentSurface,
|
|
113
|
+
isInternalWebchatTurn,
|
|
114
|
+
shouldRouteToOriginating,
|
|
115
|
+
shouldSuppressTyping: params.suppressDirectUserDelivery === true || shouldRouteToOriginating || originatingChannel === "webchat"
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/auto-reply/reply/dispatch-from-config.ts
|
|
120
|
+
var DispatchReplyOperationAbortedError = class extends Error {
|
|
121
|
+
constructor() {
|
|
122
|
+
super("Dispatch reply operation aborted");
|
|
123
|
+
this.name = "AbortError";
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
function isDispatchReplyOperationAbortedError(error) {
|
|
127
|
+
return error instanceof DispatchReplyOperationAbortedError;
|
|
128
|
+
}
|
|
129
|
+
function composeAbortSignals(...signals) {
|
|
130
|
+
const activeSignals = [];
|
|
131
|
+
for (const signal of signals) if (signal && !activeSignals.includes(signal)) activeSignals.push(signal);
|
|
132
|
+
if (activeSignals.length === 0) return;
|
|
133
|
+
if (activeSignals.length === 1) return activeSignals[0];
|
|
134
|
+
if (typeof AbortSignal.any === "function") return AbortSignal.any(activeSignals);
|
|
135
|
+
const controller = new AbortController();
|
|
136
|
+
const abort = (signal) => {
|
|
137
|
+
if (!controller.signal.aborted) controller.abort(signal.reason);
|
|
138
|
+
};
|
|
139
|
+
for (const signal of activeSignals) {
|
|
140
|
+
if (signal.aborted) {
|
|
141
|
+
abort(signal);
|
|
142
|
+
return controller.signal;
|
|
143
|
+
}
|
|
144
|
+
signal.addEventListener("abort", () => abort(signal), { once: true });
|
|
145
|
+
}
|
|
146
|
+
return controller.signal;
|
|
147
|
+
}
|
|
148
|
+
const routeReplyRuntimeLoader = createLazyImportLoader(() => import("./route-reply.runtime.js"));
|
|
149
|
+
const getReplyFromConfigRuntimeLoader = createLazyImportLoader(() => import("./get-reply-from-config.runtime.js"));
|
|
150
|
+
const abortRuntimeLoader = createLazyImportLoader(() => import("./abort.runtime.js"));
|
|
151
|
+
const ttsRuntimeLoader = createLazyImportLoader(() => import("./tts.runtime.js"));
|
|
152
|
+
const runtimePluginsLoader = createLazyImportLoader(() => import("./runtime-plugins.runtime.js"));
|
|
153
|
+
const replyMediaPathsRuntimeLoader = createLazyImportLoader(() => import("./reply-media-paths.runtime.js"));
|
|
154
|
+
function loadRouteReplyRuntime() {
|
|
155
|
+
return routeReplyRuntimeLoader.load();
|
|
156
|
+
}
|
|
157
|
+
function loadGetReplyFromConfigRuntime() {
|
|
158
|
+
return getReplyFromConfigRuntimeLoader.load();
|
|
159
|
+
}
|
|
160
|
+
function loadAbortRuntime() {
|
|
161
|
+
return abortRuntimeLoader.load();
|
|
162
|
+
}
|
|
163
|
+
function loadTtsRuntime() {
|
|
164
|
+
return ttsRuntimeLoader.load();
|
|
165
|
+
}
|
|
166
|
+
function loadRuntimePlugins() {
|
|
167
|
+
return runtimePluginsLoader.load();
|
|
168
|
+
}
|
|
169
|
+
function loadReplyMediaPathsRuntime() {
|
|
170
|
+
return replyMediaPathsRuntimeLoader.load();
|
|
171
|
+
}
|
|
172
|
+
function formatSuppressedReplyPayloadForLog(reply) {
|
|
173
|
+
const metadata = getReplyPayloadMetadata(reply);
|
|
174
|
+
const text = normalizeOptionalString(reply.text);
|
|
175
|
+
const textPreview = text ? text.replace(/\s+/g, " ").slice(0, 160) : void 0;
|
|
176
|
+
const sendableParts = resolveSendableOutboundReplyParts(reply);
|
|
177
|
+
const richParts = [
|
|
178
|
+
reply.presentation ? "presentation" : void 0,
|
|
179
|
+
reply.interactive ? "interactive" : void 0,
|
|
180
|
+
reply.channelData ? "channelData" : void 0
|
|
181
|
+
].filter(Boolean);
|
|
182
|
+
return [
|
|
183
|
+
`textChars=${text?.length ?? 0}`,
|
|
184
|
+
`media=${sendableParts.mediaCount}`,
|
|
185
|
+
`rich=${richParts.length ? richParts.join("|") : "none"}`,
|
|
186
|
+
`error=${reply.isError === true}`,
|
|
187
|
+
`beforeAgentRunBlocked=${metadata?.beforeAgentRunBlocked === true}`,
|
|
188
|
+
`deliverDespiteSuppression=${metadata?.deliverDespiteSourceReplySuppression === true}`,
|
|
189
|
+
textPreview ? `textPreview=${JSON.stringify(textPreview)}` : void 0
|
|
190
|
+
].filter(Boolean).join(" ");
|
|
191
|
+
}
|
|
192
|
+
async function maybeApplyTtsToReplyPayload(params) {
|
|
193
|
+
if (isReplyPayloadStatusNotice(params.payload)) return params.payload;
|
|
194
|
+
if (!shouldAttemptTtsPayload({
|
|
195
|
+
cfg: params.cfg,
|
|
196
|
+
ttsAuto: params.ttsAuto,
|
|
197
|
+
agentId: params.agentId,
|
|
198
|
+
channelId: params.channel,
|
|
199
|
+
accountId: params.accountId
|
|
200
|
+
})) return params.payload;
|
|
201
|
+
const { maybeApplyTtsToPayload } = await loadTtsRuntime();
|
|
202
|
+
const ttsPayload = await maybeApplyTtsToPayload(params);
|
|
203
|
+
return ttsPayload === params.payload ? ttsPayload : copyReplyPayloadMetadata(params.payload, ttsPayload);
|
|
204
|
+
}
|
|
205
|
+
const AUDIO_PLACEHOLDER_RE = /^<media:audio>(\s*\([^)]*\))?$/i;
|
|
206
|
+
const AUDIO_HEADER_RE = /^\[Audio\b/i;
|
|
207
|
+
const normalizeMediaType = (value) => normalizeOptionalLowercaseString(value.split(";")[0]) ?? "";
|
|
208
|
+
const isInboundAudioContext = (ctx) => {
|
|
209
|
+
if ([typeof ctx.MediaType === "string" ? ctx.MediaType : void 0, ...Array.isArray(ctx.MediaTypes) ? ctx.MediaTypes : []].filter(Boolean).map((type) => normalizeMediaType(type)).some((type) => type === "audio" || type.startsWith("audio/"))) return true;
|
|
210
|
+
const trimmed = (typeof ctx.BodyForCommands === "string" ? ctx.BodyForCommands : typeof ctx.CommandBody === "string" ? ctx.CommandBody : typeof ctx.RawBody === "string" ? ctx.RawBody : typeof ctx.Body === "string" ? ctx.Body : "").trim();
|
|
211
|
+
if (!trimmed) return false;
|
|
212
|
+
if (AUDIO_PLACEHOLDER_RE.test(trimmed)) return true;
|
|
213
|
+
return AUDIO_HEADER_RE.test(trimmed);
|
|
214
|
+
};
|
|
215
|
+
const resolveRoutedPolicyConversationType = (ctx) => {
|
|
216
|
+
const commandTargetSessionKey = resolveCommandTurnTargetSessionKey(ctx);
|
|
217
|
+
if (commandTargetSessionKey && commandTargetSessionKey !== ctx.SessionKey) return;
|
|
218
|
+
const chatType = normalizeChatType(ctx.ChatType);
|
|
219
|
+
if (chatType === "direct") return "direct";
|
|
220
|
+
if (chatType === "group" || chatType === "channel") return "group";
|
|
221
|
+
};
|
|
222
|
+
const resolveSessionStoreLookup = (ctx, cfg) => {
|
|
223
|
+
const sessionKey = normalizeOptionalString(resolveCommandTurnTargetSessionKey(ctx) ?? ctx.SessionKey);
|
|
224
|
+
if (!sessionKey) return {};
|
|
225
|
+
const agentId = resolveSessionAgentId({
|
|
226
|
+
sessionKey,
|
|
227
|
+
config: cfg,
|
|
228
|
+
agentId: ctx.AgentId
|
|
229
|
+
});
|
|
230
|
+
const storePath = resolveStorePath(cfg.session?.store, { agentId });
|
|
231
|
+
try {
|
|
232
|
+
const store = loadSessionStore(storePath);
|
|
233
|
+
return {
|
|
234
|
+
sessionKey,
|
|
235
|
+
storePath,
|
|
236
|
+
store,
|
|
237
|
+
entry: resolveSessionStoreEntry({
|
|
238
|
+
store,
|
|
239
|
+
sessionKey
|
|
240
|
+
}).existing
|
|
241
|
+
};
|
|
242
|
+
} catch {
|
|
243
|
+
return {
|
|
244
|
+
sessionKey,
|
|
245
|
+
storePath
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const resolveBoundAcpDispatchSessionKey = (params) => {
|
|
250
|
+
const bindingContext = resolveConversationBindingContextFromMessage({
|
|
251
|
+
cfg: params.cfg,
|
|
252
|
+
ctx: params.ctx
|
|
253
|
+
});
|
|
254
|
+
if (!bindingContext) return;
|
|
255
|
+
const binding = getSessionBindingService().resolveByConversation({
|
|
256
|
+
channel: bindingContext.channel,
|
|
257
|
+
accountId: bindingContext.accountId,
|
|
258
|
+
conversationId: bindingContext.conversationId,
|
|
259
|
+
...bindingContext.parentConversationId ? { parentConversationId: bindingContext.parentConversationId } : {}
|
|
260
|
+
});
|
|
261
|
+
const targetSessionKey = normalizeOptionalString(binding?.targetSessionKey);
|
|
262
|
+
if (!binding || !targetSessionKey || !isAcpSessionKey(targetSessionKey)) return;
|
|
263
|
+
if (isPluginOwnedSessionBindingRecord(binding)) return;
|
|
264
|
+
getSessionBindingService().touch(binding.bindingId);
|
|
265
|
+
return targetSessionKey;
|
|
266
|
+
};
|
|
267
|
+
const createShouldEmitVerboseProgress = (params) => {
|
|
268
|
+
const resolveCurrentExplicitLevel = () => {
|
|
269
|
+
if (params.sessionKey && params.storePath) try {
|
|
270
|
+
return normalizeVerboseLevel(readSessionEntry(params.storePath, params.sessionKey)?.verboseLevel ?? "");
|
|
271
|
+
} catch {}
|
|
272
|
+
return normalizeVerboseLevel(params.initialExplicitLevel ?? "");
|
|
273
|
+
};
|
|
274
|
+
const resolveLevel = () => {
|
|
275
|
+
const explicitLevel = resolveCurrentExplicitLevel();
|
|
276
|
+
if (explicitLevel) return explicitLevel;
|
|
277
|
+
return normalizeVerboseLevel(params.fallbackLevel) ?? "off";
|
|
278
|
+
};
|
|
279
|
+
return {
|
|
280
|
+
shouldEmit: () => resolveLevel() !== "off",
|
|
281
|
+
shouldEmitFull: () => resolveLevel() === "full"
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
function createReplyDispatchEvent(params) {
|
|
285
|
+
const { shouldSendToolSummaries, ...event } = params;
|
|
286
|
+
return Object.defineProperty(event, "shouldSendToolSummaries", {
|
|
287
|
+
enumerable: true,
|
|
288
|
+
get: shouldSendToolSummaries
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function resolveHarnessDefaultChannel(params) {
|
|
292
|
+
const originatingChannel = typeof params.ctx.OriginatingChannel === "string" ? params.ctx.OriginatingChannel : void 0;
|
|
293
|
+
return params.entry?.channel ?? params.entry?.origin?.provider ?? originatingChannel ?? params.ctx.Provider ?? params.ctx.Surface;
|
|
294
|
+
}
|
|
295
|
+
function resolveHarnessDefaultParentSessionKey(params) {
|
|
296
|
+
return params.entry?.parentSessionKey ?? params.ctx.ModelParentSessionKey ?? params.ctx.ParentSessionKey;
|
|
297
|
+
}
|
|
298
|
+
function resolveTurnModelOverride(replyOptions) {
|
|
299
|
+
if (replyOptions?.isHeartbeat !== true) return;
|
|
300
|
+
return normalizeOptionalString(replyOptions.heartbeatModelOverride);
|
|
301
|
+
}
|
|
302
|
+
function resolveChannelModelCandidate(params) {
|
|
303
|
+
if (!params.cfg.channels?.modelByChannel) return;
|
|
304
|
+
const channel = resolveHarnessDefaultChannel({
|
|
305
|
+
ctx: params.ctx,
|
|
306
|
+
entry: params.entry
|
|
307
|
+
});
|
|
308
|
+
const channelModelOverride = resolveChannelModelOverride({
|
|
309
|
+
cfg: params.cfg,
|
|
310
|
+
channel,
|
|
311
|
+
groupId: params.entry?.groupId,
|
|
312
|
+
groupChatType: params.entry?.chatType ?? params.ctx.ChatType,
|
|
313
|
+
groupChannel: params.entry?.groupChannel ?? params.ctx.GroupChannel,
|
|
314
|
+
groupSubject: params.entry?.subject ?? params.ctx.GroupSubject,
|
|
315
|
+
parentSessionKey: params.parentSessionKey
|
|
316
|
+
});
|
|
317
|
+
if (!channelModelOverride) return;
|
|
318
|
+
return resolveModelRefFromString({
|
|
319
|
+
raw: channelModelOverride.model,
|
|
320
|
+
defaultProvider: params.defaultProvider,
|
|
321
|
+
aliasIndex: params.aliasIndex
|
|
322
|
+
})?.ref;
|
|
323
|
+
}
|
|
324
|
+
function resolveStoredModelCandidate(params) {
|
|
325
|
+
const storedModelRef = resolveStoredModelOverride({
|
|
326
|
+
sessionEntry: params.entry,
|
|
327
|
+
sessionStore: params.sessionStore,
|
|
328
|
+
sessionKey: params.sessionKey,
|
|
329
|
+
parentSessionKey: params.parentSessionKey,
|
|
330
|
+
defaultProvider: params.defaultProvider
|
|
331
|
+
});
|
|
332
|
+
if (!storedModelRef) return;
|
|
333
|
+
return {
|
|
334
|
+
provider: storedModelRef.provider ?? params.defaultProvider,
|
|
335
|
+
model: storedModelRef.model
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function resolveModelOverrideCandidate(params) {
|
|
339
|
+
if (!params.modelOverride) return;
|
|
340
|
+
return resolveModelRefFromString({
|
|
341
|
+
raw: params.modelOverride,
|
|
342
|
+
defaultProvider: params.defaultProvider,
|
|
343
|
+
aliasIndex: params.aliasIndex
|
|
344
|
+
})?.ref;
|
|
345
|
+
}
|
|
346
|
+
const resolveHarnessSourceVisibleRepliesDefault = (params) => {
|
|
347
|
+
if (isNativeCommandTurn(resolveCommandTurnContext(params.ctx))) return;
|
|
348
|
+
try {
|
|
349
|
+
const defaultModelRef = resolveDefaultModelForAgent({
|
|
350
|
+
cfg: params.cfg,
|
|
351
|
+
agentId: params.sessionAgentId
|
|
352
|
+
});
|
|
353
|
+
const aliasIndex = buildModelAliasIndex({
|
|
354
|
+
cfg: params.cfg,
|
|
355
|
+
defaultProvider: defaultModelRef.provider
|
|
356
|
+
});
|
|
357
|
+
const parentSessionKey = resolveHarnessDefaultParentSessionKey(params);
|
|
358
|
+
const channelModelCandidate = resolveChannelModelCandidate({
|
|
359
|
+
aliasIndex,
|
|
360
|
+
cfg: params.cfg,
|
|
361
|
+
ctx: params.ctx,
|
|
362
|
+
defaultProvider: defaultModelRef.provider,
|
|
363
|
+
entry: params.entry,
|
|
364
|
+
parentSessionKey
|
|
365
|
+
});
|
|
366
|
+
const storedModelCandidate = resolveStoredModelCandidate({
|
|
367
|
+
defaultProvider: defaultModelRef.provider,
|
|
368
|
+
entry: params.entry,
|
|
369
|
+
parentSessionKey,
|
|
370
|
+
sessionKey: params.sessionKey,
|
|
371
|
+
sessionStore: params.sessionStore
|
|
372
|
+
});
|
|
373
|
+
const turnModelCandidate = resolveModelOverrideCandidate({
|
|
374
|
+
aliasIndex,
|
|
375
|
+
defaultProvider: defaultModelRef.provider,
|
|
376
|
+
modelOverride: params.turnModelOverride
|
|
377
|
+
});
|
|
378
|
+
const resolveCandidateDefault = (candidate) => {
|
|
379
|
+
const agentHarnessRuntimeOverride = resolveSessionRuntimeOverrideForProvider({
|
|
380
|
+
provider: candidate.provider,
|
|
381
|
+
entry: params.entry
|
|
382
|
+
});
|
|
383
|
+
return selectAgentHarness({
|
|
384
|
+
provider: candidate.provider,
|
|
385
|
+
modelId: candidate.model,
|
|
386
|
+
config: params.cfg,
|
|
387
|
+
agentId: params.sessionAgentId,
|
|
388
|
+
sessionKey: params.sessionKey,
|
|
389
|
+
agentHarnessRuntimeOverride
|
|
390
|
+
}).deliveryDefaults?.sourceVisibleReplies;
|
|
391
|
+
};
|
|
392
|
+
const selectedModelCandidate = turnModelCandidate ?? storedModelCandidate ?? channelModelCandidate;
|
|
393
|
+
if (selectedModelCandidate) return resolveCandidateDefault(selectedModelCandidate);
|
|
394
|
+
const sourceProvider = normalizeOptionalString(params.entry?.origin?.provider ?? params.ctx.Provider ?? params.ctx.Surface);
|
|
395
|
+
if (sourceProvider) {
|
|
396
|
+
const sourceDefault = resolveCandidateDefault({ provider: sourceProvider });
|
|
397
|
+
if (sourceDefault) return sourceDefault;
|
|
398
|
+
}
|
|
399
|
+
return resolveCandidateDefault(defaultModelRef);
|
|
400
|
+
} catch (error) {
|
|
401
|
+
logVerbose(`dispatch-from-config: could not resolve harness visible-reply defaults: ${formatErrorMessage(error)}`);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
function shouldBypassPluginOwnedBindingForCommand(ctx, cfg) {
|
|
406
|
+
const commandTurn = resolveCommandTurnContext(ctx);
|
|
407
|
+
if ((commandTurn.kind === "native" || commandTurn.kind === "text-slash") && !commandTurn.authorized) return false;
|
|
408
|
+
if (isNativeCommandTurn(commandTurn) && commandTurn.authorized) return true;
|
|
409
|
+
if (!isExplicitSourceReplyCommand(ctx, cfg)) return false;
|
|
410
|
+
const commandBody = normalizeCommandBody(commandTurn.body ?? ctx.CommandBody ?? "", { botUsername: ctx.BotUsername });
|
|
411
|
+
if (!commandBody.startsWith("/")) return false;
|
|
412
|
+
if (resolveTextCommand(commandBody)) return true;
|
|
413
|
+
const provider = normalizeOptionalString(ctx.Provider ?? ctx.Surface);
|
|
414
|
+
if (commandTurn.commandName && findCommandByNativeName(commandTurn.commandName, provider, { includeBundledChannelFallback: true })) return true;
|
|
415
|
+
return Boolean(matchPluginCommand(commandBody, { channel: normalizeOptionalString(ctx.Surface ?? ctx.Provider) }));
|
|
416
|
+
}
|
|
417
|
+
async function clearPendingFinalDeliveryAfterSuccess(params) {
|
|
418
|
+
if (!params.storePath || !params.sessionKey) return;
|
|
419
|
+
await updateSessionStoreEntry({
|
|
420
|
+
storePath: params.storePath,
|
|
421
|
+
sessionKey: params.sessionKey,
|
|
422
|
+
skipMaintenance: true,
|
|
423
|
+
takeCacheOwnership: true,
|
|
424
|
+
update: async (entry) => {
|
|
425
|
+
if (!entry.pendingFinalDelivery && !entry.pendingFinalDeliveryText) return null;
|
|
426
|
+
return {
|
|
427
|
+
pendingFinalDelivery: void 0,
|
|
428
|
+
pendingFinalDeliveryText: void 0,
|
|
429
|
+
pendingFinalDeliveryCreatedAt: void 0,
|
|
430
|
+
pendingFinalDeliveryLastAttemptAt: void 0,
|
|
431
|
+
pendingFinalDeliveryAttemptCount: void 0,
|
|
432
|
+
pendingFinalDeliveryLastError: void 0,
|
|
433
|
+
pendingFinalDeliveryContext: void 0,
|
|
434
|
+
updatedAt: Date.now()
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
async function mirrorInternalSourceReplyToTranscript(params) {
|
|
440
|
+
const mirror = params.metadata;
|
|
441
|
+
if (!mirror) return;
|
|
442
|
+
const result = await appendAssistantMessageToSessionTranscript({
|
|
443
|
+
sessionKey: mirror.sessionKey,
|
|
444
|
+
agentId: mirror.agentId,
|
|
445
|
+
text: mirror.text,
|
|
446
|
+
mediaUrls: mirror.mediaUrls,
|
|
447
|
+
idempotencyKey: mirror.idempotencyKey,
|
|
448
|
+
updateMode: "inline",
|
|
449
|
+
config: params.cfg
|
|
450
|
+
});
|
|
451
|
+
if (!result.ok) logVerbose(`dispatch-from-config: internal source reply mirror skipped: ${result.reason}`);
|
|
452
|
+
}
|
|
453
|
+
function getDispatcherFinalOutcomeCounts(dispatcher) {
|
|
454
|
+
return {
|
|
455
|
+
cancelled: dispatcher.getCancelledCounts?.().final ?? 0,
|
|
456
|
+
failed: dispatcher.getFailedCounts().final
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function sourceReplyTranscriptMirrorForDeliveredPayload(metadata, payload) {
|
|
460
|
+
const sendable = resolveSendableOutboundReplyParts(payload);
|
|
461
|
+
return {
|
|
462
|
+
...metadata,
|
|
463
|
+
text: sendable.text,
|
|
464
|
+
mediaUrls: sendable.mediaUrls.length > 0 ? sendable.mediaUrls : void 0
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
function captureDeliveredSourceReplyTranscriptMirror(params) {
|
|
468
|
+
if (!params.metadata || !params.dispatcher.appendBeforeDeliver) return () => params.metadata;
|
|
469
|
+
let deliveredMetadata;
|
|
470
|
+
const { idempotencyKey, sessionKey } = params.metadata;
|
|
471
|
+
params.dispatcher.appendBeforeDeliver((payload, info) => {
|
|
472
|
+
if (info.kind !== "final") return payload;
|
|
473
|
+
const payloadMetadata = getReplyPayloadMetadata(payload)?.sourceReplyTranscriptMirror;
|
|
474
|
+
if (!payloadMetadata) return payload;
|
|
475
|
+
if (payloadMetadata.idempotencyKey === idempotencyKey && payloadMetadata.sessionKey === sessionKey) deliveredMetadata = sourceReplyTranscriptMirrorForDeliveredPayload(payloadMetadata, payload);
|
|
476
|
+
return payload;
|
|
477
|
+
});
|
|
478
|
+
return () => deliveredMetadata;
|
|
479
|
+
}
|
|
480
|
+
async function mirrorInternalSourceReplyAfterDispatcherDelivery(params) {
|
|
481
|
+
await params.dispatcher.waitForIdle();
|
|
482
|
+
const after = getDispatcherFinalOutcomeCounts(params.dispatcher);
|
|
483
|
+
if (after.cancelled > params.before.cancelled || after.failed > params.before.failed) return;
|
|
484
|
+
const metadata = params.metadata();
|
|
485
|
+
if (!metadata) return;
|
|
486
|
+
await mirrorInternalSourceReplyToTranscript({
|
|
487
|
+
metadata,
|
|
488
|
+
cfg: params.cfg
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
function runWithDispatchAbortSignal(signal, run) {
|
|
492
|
+
if (!signal) return Promise.resolve().then(run);
|
|
493
|
+
const shouldStopForAbort = () => signal.aborted;
|
|
494
|
+
if (signal.aborted && shouldStopForAbort()) return Promise.reject(new DispatchReplyOperationAbortedError());
|
|
495
|
+
let settled = false;
|
|
496
|
+
let abortHandler;
|
|
497
|
+
const aborted = new Promise((_, reject) => {
|
|
498
|
+
abortHandler = () => {
|
|
499
|
+
if (!settled && shouldStopForAbort()) reject(new DispatchReplyOperationAbortedError());
|
|
500
|
+
};
|
|
501
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
502
|
+
});
|
|
503
|
+
const work = Promise.resolve().then(run).then((value) => {
|
|
504
|
+
settled = true;
|
|
505
|
+
return value;
|
|
506
|
+
}, (error) => {
|
|
507
|
+
settled = true;
|
|
508
|
+
if (shouldStopForAbort() && isAbortError(error)) throw new DispatchReplyOperationAbortedError();
|
|
509
|
+
throw error;
|
|
510
|
+
});
|
|
511
|
+
return Promise.race([work, aborted]).finally(() => {
|
|
512
|
+
settled = true;
|
|
513
|
+
if (abortHandler) signal.removeEventListener("abort", abortHandler);
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
function createAbortAwareDispatcher(params) {
|
|
517
|
+
const sendIfActive = (send) => (payload) => params.isAborted() ? false : send(payload);
|
|
518
|
+
const dispatcher = {
|
|
519
|
+
sendToolResult: sendIfActive(params.dispatcher.sendToolResult),
|
|
520
|
+
sendBlockReply: sendIfActive(params.dispatcher.sendBlockReply),
|
|
521
|
+
sendFinalReply: sendIfActive(params.dispatcher.sendFinalReply),
|
|
522
|
+
waitForIdle: () => params.dispatcher.waitForIdle(),
|
|
523
|
+
getQueuedCounts: () => params.dispatcher.getQueuedCounts(),
|
|
524
|
+
getFailedCounts: () => params.dispatcher.getFailedCounts(),
|
|
525
|
+
markComplete: () => {
|
|
526
|
+
if (!params.isAborted()) params.dispatcher.markComplete();
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
if (params.dispatcher.getCancelledCounts) dispatcher.getCancelledCounts = () => params.dispatcher.getCancelledCounts();
|
|
530
|
+
return dispatcher;
|
|
531
|
+
}
|
|
532
|
+
const replyHotPathTimingLog = createSubsystemLogger("auto-reply/reply-timing");
|
|
533
|
+
const REPLY_HOT_PATH_TIMING_WARN_TOTAL_MS = 1e3;
|
|
534
|
+
const REPLY_HOT_PATH_TIMING_WARN_STAGE_MS = 500;
|
|
535
|
+
function createReplyHotPathTimingTracker(options = {}) {
|
|
536
|
+
if (!options.profilerEnabled) return {
|
|
537
|
+
async measure(_name, run) {
|
|
538
|
+
return await run();
|
|
539
|
+
},
|
|
540
|
+
logIfSlow() {}
|
|
541
|
+
};
|
|
542
|
+
const startedAt = Date.now();
|
|
543
|
+
let didLog = false;
|
|
544
|
+
const spans = [];
|
|
545
|
+
const toMs = (value) => Math.max(0, Math.round(value));
|
|
546
|
+
const snapshot = () => ({
|
|
547
|
+
totalMs: toMs(Date.now() - startedAt),
|
|
548
|
+
spans: spans.slice()
|
|
549
|
+
});
|
|
550
|
+
const shouldLog = (summary) => summary.totalMs >= REPLY_HOT_PATH_TIMING_WARN_TOTAL_MS || summary.spans.some((span) => span.durationMs >= REPLY_HOT_PATH_TIMING_WARN_STAGE_MS);
|
|
551
|
+
const formatSpans = (summary) => summary.spans.length > 0 ? summary.spans.map((span) => `${span.name}:${span.durationMs}ms@${span.elapsedMs}ms`).join(",") : "none";
|
|
552
|
+
return {
|
|
553
|
+
async measure(name, run) {
|
|
554
|
+
const spanStartedAt = Date.now();
|
|
555
|
+
try {
|
|
556
|
+
return await run();
|
|
557
|
+
} finally {
|
|
558
|
+
spans.push({
|
|
559
|
+
name,
|
|
560
|
+
durationMs: toMs(Date.now() - spanStartedAt),
|
|
561
|
+
elapsedMs: toMs(Date.now() - startedAt)
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
logIfSlow(params) {
|
|
566
|
+
if (didLog) return;
|
|
567
|
+
const summary = snapshot();
|
|
568
|
+
if (!shouldLog(summary)) return;
|
|
569
|
+
didLog = true;
|
|
570
|
+
replyHotPathTimingLog.warn(`reply hot path timings channel=${params.channel} messageId=${params.messageId ?? "unknown"} sessionKey=${params.sessionKey ?? "unknown"} outcome=${params.outcome} totalMs=${summary.totalMs} stages=${formatSpans(summary)}${params.reason ? ` reason=${params.reason}` : ""}`, {
|
|
571
|
+
channel: params.channel,
|
|
572
|
+
messageId: params.messageId,
|
|
573
|
+
sessionKey: params.sessionKey,
|
|
574
|
+
outcome: params.outcome,
|
|
575
|
+
reason: params.reason,
|
|
576
|
+
totalMs: summary.totalMs,
|
|
577
|
+
spans: summary.spans
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
async function dispatchReplyFromConfig(params) {
|
|
583
|
+
const { ctx, cfg, dispatcher } = params;
|
|
584
|
+
if (params.replyOptions?.abortSignal?.aborted) return {
|
|
585
|
+
queuedFinal: false,
|
|
586
|
+
counts: dispatcher.getQueuedCounts()
|
|
587
|
+
};
|
|
588
|
+
const diagnosticsEnabled = isDiagnosticsEnabled(cfg);
|
|
589
|
+
const channel = normalizeLowercaseStringOrEmpty(ctx.Surface ?? ctx.Provider ?? "unknown");
|
|
590
|
+
const chatId = ctx.To ?? ctx.From;
|
|
591
|
+
const messageId = ctx.MessageSid ?? ctx.MessageSidFirst ?? ctx.MessageSidLast;
|
|
592
|
+
const sessionKey = normalizeOptionalString(ctx.SessionKey) ?? normalizeOptionalString(ctx.CommandTargetSessionKey);
|
|
593
|
+
const startTime = diagnosticsEnabled ? Date.now() : 0;
|
|
594
|
+
const canTrackSession = diagnosticsEnabled && Boolean(sessionKey);
|
|
595
|
+
const messageLifecycle = createDiagnosticMessageLifecycle({
|
|
596
|
+
enabled: diagnosticsEnabled,
|
|
597
|
+
channel,
|
|
598
|
+
chatId,
|
|
599
|
+
messageId,
|
|
600
|
+
sessionKey,
|
|
601
|
+
source: "dispatch",
|
|
602
|
+
processingReason: "message_start",
|
|
603
|
+
startedAtMs: startTime,
|
|
604
|
+
trackSessionState: canTrackSession
|
|
605
|
+
});
|
|
606
|
+
const traceAttributes = {
|
|
607
|
+
surface: channel,
|
|
608
|
+
hasSessionKey: Boolean(sessionKey),
|
|
609
|
+
hasRunId: typeof params.replyOptions?.runId === "string"
|
|
610
|
+
};
|
|
611
|
+
const replyHotPathTiming = createReplyHotPathTimingTracker({ profilerEnabled: isReplyProfilerEnabled({ config: cfg }) });
|
|
612
|
+
const traceReplyPhase = (name, run) => replyHotPathTiming.measure(name, () => measureDiagnosticsTimelineSpan(name, run, {
|
|
613
|
+
phase: "agent-turn",
|
|
614
|
+
config: cfg,
|
|
615
|
+
attributes: traceAttributes
|
|
616
|
+
}));
|
|
617
|
+
let agentDispatchStartedAt = 0;
|
|
618
|
+
const recordProcessed = (outcome, opts) => {
|
|
619
|
+
if (diagnosticsEnabled) replyHotPathTiming.logIfSlow({
|
|
620
|
+
channel,
|
|
621
|
+
messageId,
|
|
622
|
+
sessionKey,
|
|
623
|
+
outcome,
|
|
624
|
+
reason: opts?.reason
|
|
625
|
+
});
|
|
626
|
+
messageLifecycle.markProcessed(outcome, opts);
|
|
627
|
+
};
|
|
628
|
+
const recordAgentDispatchStarted = () => {
|
|
629
|
+
if (!diagnosticsEnabled || agentDispatchStartedAt > 0) return;
|
|
630
|
+
agentDispatchStartedAt = Date.now();
|
|
631
|
+
logMessageDispatchStarted({
|
|
632
|
+
channel,
|
|
633
|
+
sessionKey: acpDispatchSessionKey,
|
|
634
|
+
source: "replyResolver"
|
|
635
|
+
});
|
|
636
|
+
};
|
|
637
|
+
const recordAgentDispatchCompleted = (outcome, opts) => {
|
|
638
|
+
if (!diagnosticsEnabled || agentDispatchStartedAt <= 0) return;
|
|
639
|
+
logMessageDispatchCompleted({
|
|
640
|
+
channel,
|
|
641
|
+
sessionKey: acpDispatchSessionKey,
|
|
642
|
+
source: "replyResolver",
|
|
643
|
+
durationMs: Date.now() - agentDispatchStartedAt,
|
|
644
|
+
outcome,
|
|
645
|
+
reason: opts?.reason,
|
|
646
|
+
error: opts?.error
|
|
647
|
+
});
|
|
648
|
+
};
|
|
649
|
+
const markProcessing = () => {
|
|
650
|
+
messageLifecycle.markProcessing();
|
|
651
|
+
};
|
|
652
|
+
const markIdle = (reason) => {
|
|
653
|
+
messageLifecycle.markIdle(reason);
|
|
654
|
+
};
|
|
655
|
+
let inboundDedupeReplayUnsafe = false;
|
|
656
|
+
const markInboundDedupeReplayUnsafe = () => {
|
|
657
|
+
inboundDedupeReplayUnsafe = true;
|
|
658
|
+
};
|
|
659
|
+
const initialSessionStoreEntry = resolveSessionStoreLookup(ctx, cfg);
|
|
660
|
+
const boundAcpDispatchSessionKey = resolveBoundAcpDispatchSessionKey({
|
|
661
|
+
ctx,
|
|
662
|
+
cfg
|
|
663
|
+
});
|
|
664
|
+
const acpDispatchSessionKey = boundAcpDispatchSessionKey ?? initialSessionStoreEntry.sessionKey ?? sessionKey;
|
|
665
|
+
const dispatchOperationSessionKey = initialSessionStoreEntry.sessionKey ?? sessionKey ?? acpDispatchSessionKey;
|
|
666
|
+
if (params.replyOptions?.isHeartbeat === true && dispatchOperationSessionKey && replyRunRegistry.get(dispatchOperationSessionKey)) return {
|
|
667
|
+
queuedFinal: false,
|
|
668
|
+
counts: dispatcher.getQueuedCounts()
|
|
669
|
+
};
|
|
670
|
+
const markProgress = () => {
|
|
671
|
+
if (!canTrackSession || !sessionKey) return;
|
|
672
|
+
markDiagnosticSessionProgress({ sessionKey });
|
|
673
|
+
if (acpDispatchSessionKey && acpDispatchSessionKey !== sessionKey) markDiagnosticSessionProgress({ sessionKey: acpDispatchSessionKey });
|
|
674
|
+
};
|
|
675
|
+
const sessionStoreEntry = boundAcpDispatchSessionKey ? resolveSessionStoreLookup({
|
|
676
|
+
...ctx,
|
|
677
|
+
SessionKey: boundAcpDispatchSessionKey
|
|
678
|
+
}, cfg) : initialSessionStoreEntry;
|
|
679
|
+
const sessionAgentId = resolveSessionAgentId({
|
|
680
|
+
sessionKey: acpDispatchSessionKey,
|
|
681
|
+
config: cfg,
|
|
682
|
+
agentId: ctx.AgentId
|
|
683
|
+
});
|
|
684
|
+
const sessionAgentCfg = resolveAgentConfig(cfg, sessionAgentId);
|
|
685
|
+
const verboseProgress = createShouldEmitVerboseProgress({
|
|
686
|
+
sessionKey: acpDispatchSessionKey,
|
|
687
|
+
storePath: sessionStoreEntry.storePath,
|
|
688
|
+
initialExplicitLevel: sessionStoreEntry.entry?.verboseLevel,
|
|
689
|
+
fallbackLevel: normalizeVerboseLevel(sessionStoreEntry.entry?.verboseLevel ?? sessionAgentCfg?.verboseDefault ?? cfg.agents?.defaults?.verboseDefault ?? "") ?? "off"
|
|
690
|
+
});
|
|
691
|
+
const shouldEmitVerboseProgress = verboseProgress.shouldEmit;
|
|
692
|
+
const shouldEmitFullVerboseProgress = verboseProgress.shouldEmitFull;
|
|
693
|
+
const replyRoute = resolveEffectiveReplyRoute({
|
|
694
|
+
ctx,
|
|
695
|
+
entry: sessionStoreEntry.entry
|
|
696
|
+
});
|
|
697
|
+
const routeThreadId = resolveRoutedDeliveryThreadId({
|
|
698
|
+
ctx,
|
|
699
|
+
sessionKey: acpDispatchSessionKey
|
|
700
|
+
});
|
|
701
|
+
const inboundAudio = isInboundAudioContext(ctx);
|
|
702
|
+
const sessionTtsAuto = normalizeTtsAutoMode(sessionStoreEntry.entry?.ttsAuto);
|
|
703
|
+
const workspaceDir = resolveAgentWorkspaceDir(cfg, sessionAgentId);
|
|
704
|
+
let dispatchReplyOperation;
|
|
705
|
+
let dispatchAbortOperation;
|
|
706
|
+
let preDispatchAbortOperation;
|
|
707
|
+
const ensureDispatchReplyOperation = async (phase) => {
|
|
708
|
+
if (dispatchReplyOperation && !dispatchReplyOperation.result) return { status: "ready" };
|
|
709
|
+
if (dispatchAbortOperation && !dispatchAbortOperation.result) return dispatchReplyOperation ? { status: "ready" } : { status: "busy" };
|
|
710
|
+
if (phase === "dispatch" && preDispatchAbortOperation?.result && preDispatchAbortOperation.result.kind !== "completed" && !dispatchReplyOperation) {
|
|
711
|
+
dispatchAbortOperation = preDispatchAbortOperation;
|
|
712
|
+
return { status: "busy" };
|
|
713
|
+
}
|
|
714
|
+
if (!dispatchOperationSessionKey) return { status: "ready" };
|
|
715
|
+
const operationSessionId = dispatchAbortOperation?.sessionId ?? initialSessionStoreEntry.entry?.sessionId ?? sessionStoreEntry.entry?.sessionId ?? crypto.randomUUID();
|
|
716
|
+
const replyTurnKind = resolveReplyTurnKind(params.replyOptions);
|
|
717
|
+
const allowActivePreDispatch = phase === "pre_dispatch" && replyTurnKind === "visible";
|
|
718
|
+
const admission = await admitReplyTurn({
|
|
719
|
+
sessionKey: dispatchOperationSessionKey,
|
|
720
|
+
sessionId: operationSessionId,
|
|
721
|
+
kind: replyTurnKind,
|
|
722
|
+
resetTriggered: false,
|
|
723
|
+
upstreamAbortSignal: params.replyOptions?.abortSignal,
|
|
724
|
+
waitForActive: !allowActivePreDispatch
|
|
725
|
+
});
|
|
726
|
+
if (admission.status === "skipped") {
|
|
727
|
+
if (allowActivePreDispatch && admission.reason === "active-run") {
|
|
728
|
+
preDispatchAbortOperation = admission.activeOperation;
|
|
729
|
+
return { status: "ready" };
|
|
730
|
+
}
|
|
731
|
+
dispatchAbortOperation = admission.activeOperation;
|
|
732
|
+
logVerbose(`dispatch-from-config: skipped reply operation admission for ${dispatchOperationSessionKey}; reason=${admission.reason}`);
|
|
733
|
+
return { status: "busy" };
|
|
734
|
+
}
|
|
735
|
+
dispatchReplyOperation = admission.operation;
|
|
736
|
+
dispatchAbortOperation = admission.operation;
|
|
737
|
+
return { status: "ready" };
|
|
738
|
+
};
|
|
739
|
+
const getPreDispatchAbortOperation = () => dispatchAbortOperation ?? preDispatchAbortOperation;
|
|
740
|
+
let cachedPreDispatchAbortSignal;
|
|
741
|
+
let cachedDispatchAbortSignal;
|
|
742
|
+
const getPreDispatchAbortSignal = () => {
|
|
743
|
+
const operationSignal = getPreDispatchAbortOperation()?.abortSignal;
|
|
744
|
+
const upstreamSignal = params.replyOptions?.abortSignal;
|
|
745
|
+
if (cachedPreDispatchAbortSignal && cachedPreDispatchAbortSignal.operationSignal === operationSignal && cachedPreDispatchAbortSignal.upstreamSignal === upstreamSignal) return cachedPreDispatchAbortSignal.signal;
|
|
746
|
+
const signal = composeAbortSignals(operationSignal, upstreamSignal);
|
|
747
|
+
cachedPreDispatchAbortSignal = {
|
|
748
|
+
operationSignal,
|
|
749
|
+
upstreamSignal,
|
|
750
|
+
signal
|
|
751
|
+
};
|
|
752
|
+
return signal;
|
|
753
|
+
};
|
|
754
|
+
const getDispatchAbortSignal = () => {
|
|
755
|
+
const operationSignal = dispatchReplyOperation?.abortSignal;
|
|
756
|
+
const upstreamSignal = params.replyOptions?.abortSignal;
|
|
757
|
+
if (cachedDispatchAbortSignal && cachedDispatchAbortSignal.operationSignal === operationSignal && cachedDispatchAbortSignal.upstreamSignal === upstreamSignal) return cachedDispatchAbortSignal.signal;
|
|
758
|
+
const signal = composeAbortSignals(operationSignal, upstreamSignal);
|
|
759
|
+
cachedDispatchAbortSignal = {
|
|
760
|
+
operationSignal,
|
|
761
|
+
upstreamSignal,
|
|
762
|
+
signal
|
|
763
|
+
};
|
|
764
|
+
return signal;
|
|
765
|
+
};
|
|
766
|
+
const getQueuedFollowupAbortSignal = () => dispatchReplyOperation?.abortSignal ?? params.replyOptions?.abortSignal;
|
|
767
|
+
const getReplyOptions = () => {
|
|
768
|
+
const abortSignal = getDispatchAbortSignal();
|
|
769
|
+
if (!abortSignal) return params.replyOptions;
|
|
770
|
+
return {
|
|
771
|
+
...params.replyOptions,
|
|
772
|
+
abortSignal,
|
|
773
|
+
queuedFollowupAbortSignal: getQueuedFollowupAbortSignal(),
|
|
774
|
+
...dispatchReplyOperation ? { replyOperation: dispatchReplyOperation } : {}
|
|
775
|
+
};
|
|
776
|
+
};
|
|
777
|
+
const completeDispatchReplyOperation = () => {
|
|
778
|
+
if (dispatchReplyOperation) dispatchReplyOperation.complete();
|
|
779
|
+
};
|
|
780
|
+
const failDispatchReplyOperation = (error) => {
|
|
781
|
+
if (dispatchReplyOperation && !dispatchReplyOperation.result) dispatchReplyOperation.fail("run_failed", error);
|
|
782
|
+
};
|
|
783
|
+
const isDispatchOperationAborted = () => getDispatchAbortSignal()?.aborted === true;
|
|
784
|
+
const isPreDispatchOperationAborted = () => getPreDispatchAbortSignal()?.aborted === true;
|
|
785
|
+
const throwIfDispatchOperationAborted = () => {
|
|
786
|
+
if (isDispatchOperationAborted()) throw new DispatchReplyOperationAbortedError();
|
|
787
|
+
};
|
|
788
|
+
const dispatchHookDispatcher = createAbortAwareDispatcher({
|
|
789
|
+
dispatcher,
|
|
790
|
+
isAborted: isPreDispatchOperationAborted
|
|
791
|
+
});
|
|
792
|
+
const { ensureRuntimePluginsLoaded } = await traceReplyPhase("reply.load_runtime_plugins", () => loadRuntimePlugins());
|
|
793
|
+
await traceReplyPhase("reply.ensure_runtime_plugins", () => {
|
|
794
|
+
ensureRuntimePluginsLoaded({
|
|
795
|
+
config: cfg,
|
|
796
|
+
workspaceDir
|
|
797
|
+
});
|
|
798
|
+
});
|
|
799
|
+
const hookRunner = getGlobalHookRunner();
|
|
800
|
+
const timestamp = typeof ctx.Timestamp === "number" && Number.isFinite(ctx.Timestamp) ? ctx.Timestamp : void 0;
|
|
801
|
+
const hookContext = deriveInboundMessageHookContext(ctx, { messageId: ctx.MessageSidFull ?? ctx.MessageSid ?? ctx.MessageSidFirst ?? ctx.MessageSidLast });
|
|
802
|
+
const { isGroup, groupId } = hookContext;
|
|
803
|
+
const inboundClaimContext = toPluginInboundClaimContext(hookContext);
|
|
804
|
+
const inboundClaimEvent = toPluginInboundClaimEvent(hookContext, {
|
|
805
|
+
commandAuthorized: typeof ctx.CommandAuthorized === "boolean" ? ctx.CommandAuthorized : void 0,
|
|
806
|
+
wasMentioned: typeof ctx.WasMentioned === "boolean" ? ctx.WasMentioned : void 0
|
|
807
|
+
});
|
|
808
|
+
const suppressAcpChildUserDelivery = isParentOwnedBackgroundAcpSession(sessionStoreEntry.entry);
|
|
809
|
+
const normalizedRouteReplyChannel = normalizeMessageChannel(replyRoute.channel);
|
|
810
|
+
const normalizedProviderChannel = normalizeMessageChannel(ctx.Provider);
|
|
811
|
+
const normalizedSurfaceChannel = normalizeMessageChannel(ctx.Surface);
|
|
812
|
+
const normalizedCurrentSurface = normalizedProviderChannel ?? normalizedSurfaceChannel;
|
|
813
|
+
const isInternalWebchatTurn = normalizedCurrentSurface === "webchat" && (normalizedSurfaceChannel === "webchat" || !normalizedSurfaceChannel) && ctx.ExplicitDeliverRoute !== true;
|
|
814
|
+
const routeReplyRuntime = Boolean(!suppressAcpChildUserDelivery && !isInternalWebchatTurn && normalizedRouteReplyChannel && replyRoute.to && normalizedRouteReplyChannel !== normalizedCurrentSurface) ? await loadRouteReplyRuntime() : void 0;
|
|
815
|
+
const { originatingChannel: routeReplyChannel, currentSurface, shouldRouteToOriginating, shouldSuppressTyping } = resolveReplyRoutingDecision({
|
|
816
|
+
provider: ctx.Provider,
|
|
817
|
+
surface: ctx.Surface,
|
|
818
|
+
explicitDeliverRoute: ctx.ExplicitDeliverRoute,
|
|
819
|
+
originatingChannel: replyRoute.channel,
|
|
820
|
+
originatingTo: replyRoute.to,
|
|
821
|
+
suppressDirectUserDelivery: suppressAcpChildUserDelivery,
|
|
822
|
+
isRoutableChannel: routeReplyRuntime?.isRoutableChannel ?? (() => false)
|
|
823
|
+
});
|
|
824
|
+
const routeReplyTo = replyRoute.to;
|
|
825
|
+
const deliveryChannel = shouldRouteToOriginating ? routeReplyChannel : currentSurface;
|
|
826
|
+
let normalizeReplyMediaPaths;
|
|
827
|
+
const getNormalizeReplyMediaPaths = async () => {
|
|
828
|
+
if (normalizeReplyMediaPaths) return normalizeReplyMediaPaths;
|
|
829
|
+
const { createReplyMediaPathNormalizer } = await loadReplyMediaPathsRuntime();
|
|
830
|
+
normalizeReplyMediaPaths = createReplyMediaPathNormalizer({
|
|
831
|
+
cfg,
|
|
832
|
+
sessionKey: acpDispatchSessionKey,
|
|
833
|
+
workspaceDir,
|
|
834
|
+
messageProvider: deliveryChannel,
|
|
835
|
+
accountId: replyRoute.accountId,
|
|
836
|
+
groupId,
|
|
837
|
+
groupChannel: ctx.GroupChannel,
|
|
838
|
+
groupSpace: ctx.GroupSpace,
|
|
839
|
+
requesterSenderId: ctx.SenderId,
|
|
840
|
+
requesterSenderName: ctx.SenderName,
|
|
841
|
+
requesterSenderUsername: ctx.SenderUsername,
|
|
842
|
+
requesterSenderE164: ctx.SenderE164
|
|
843
|
+
});
|
|
844
|
+
return normalizeReplyMediaPaths;
|
|
845
|
+
};
|
|
846
|
+
const normalizeReplyMediaPayload = async (payload) => {
|
|
847
|
+
if (!resolveSendableOutboundReplyParts(payload).hasMedia) return payload;
|
|
848
|
+
return await (await getNormalizeReplyMediaPaths())(payload);
|
|
849
|
+
};
|
|
850
|
+
const routeReplyToOriginating = async (payload, options) => {
|
|
851
|
+
if (!shouldRouteToOriginating || !routeReplyChannel || !routeReplyTo || !routeReplyRuntime) return null;
|
|
852
|
+
markInboundDedupeReplayUnsafe();
|
|
853
|
+
const agentRuntimeSessionKey = ctx.CommandSource === "native" ? resolveCommandTurnTargetSessionKey(ctx) ?? ctx.SessionKey : ctx.SessionKey;
|
|
854
|
+
return await routeReplyRuntime.routeReply({
|
|
855
|
+
payload,
|
|
856
|
+
channel: routeReplyChannel,
|
|
857
|
+
to: routeReplyTo,
|
|
858
|
+
sessionKey: agentRuntimeSessionKey,
|
|
859
|
+
policySessionKey: resolveCommandTurnTargetSessionKey(ctx) ?? ctx.SessionKey,
|
|
860
|
+
policyConversationType: resolveRoutedPolicyConversationType(ctx),
|
|
861
|
+
accountId: replyRoute.accountId,
|
|
862
|
+
requesterSenderId: ctx.SenderId,
|
|
863
|
+
requesterSenderName: ctx.SenderName,
|
|
864
|
+
requesterSenderUsername: ctx.SenderUsername,
|
|
865
|
+
requesterSenderE164: ctx.SenderE164,
|
|
866
|
+
threadId: routeThreadId,
|
|
867
|
+
cfg,
|
|
868
|
+
abortSignal: options?.abortSignal,
|
|
869
|
+
mirror: options?.mirror,
|
|
870
|
+
isGroup,
|
|
871
|
+
groupId,
|
|
872
|
+
replyKind: options?.kind ?? "final",
|
|
873
|
+
runId: params.replyOptions?.runId
|
|
874
|
+
});
|
|
875
|
+
};
|
|
876
|
+
const isRoutedReplyDelivered = (result) => result.ok && result.suppressed !== true;
|
|
877
|
+
/**
|
|
878
|
+
* Helper to send a payload via route-reply (async).
|
|
879
|
+
* Only used when actually routing to a different provider.
|
|
880
|
+
* Note: Only called when shouldRouteToOriginating is true, so
|
|
881
|
+
* routeReplyChannel and routeReplyTo are guaranteed to be defined.
|
|
882
|
+
*/
|
|
883
|
+
const sendPayloadAsync = async (payload, abortSignal, mirror, kind = "tool") => {
|
|
884
|
+
if (!routeReplyRuntime || !routeReplyChannel || !routeReplyTo) return;
|
|
885
|
+
const effectiveAbortSignal = abortSignal ?? getDispatchAbortSignal();
|
|
886
|
+
if (effectiveAbortSignal?.aborted) return;
|
|
887
|
+
const result = await routeReplyToOriginating(payload, {
|
|
888
|
+
abortSignal: effectiveAbortSignal,
|
|
889
|
+
mirror,
|
|
890
|
+
kind
|
|
891
|
+
});
|
|
892
|
+
if (result && !result.ok) logVerbose(`dispatch-from-config: route-reply failed: ${result.error ?? "unknown error"}`);
|
|
893
|
+
};
|
|
894
|
+
const sendBindingNotice = async (payload, mode) => {
|
|
895
|
+
if (suppressAutomaticSourceDelivery) return false;
|
|
896
|
+
const result = await routeReplyToOriginating(payload, { kind: mode === "terminal" ? "final" : "tool" });
|
|
897
|
+
if (result) {
|
|
898
|
+
if (!result.ok) logVerbose(`dispatch-from-config: route-reply (plugin binding notice) failed: ${result.error ?? "unknown error"}`);
|
|
899
|
+
return result.ok;
|
|
900
|
+
}
|
|
901
|
+
markInboundDedupeReplayUnsafe();
|
|
902
|
+
return mode === "additive" ? dispatcher.sendToolResult(payload) : dispatcher.sendFinalReply(payload);
|
|
903
|
+
};
|
|
904
|
+
const pluginOwnedBindingRecord = inboundClaimContext.conversationId && inboundClaimContext.channelId ? resolveConversationBindingRecord({
|
|
905
|
+
channel: inboundClaimContext.channelId,
|
|
906
|
+
accountId: inboundClaimContext.accountId ?? cfg.channels?.[inboundClaimContext.channelId]?.defaultAccount ?? "default",
|
|
907
|
+
conversationId: inboundClaimContext.conversationId,
|
|
908
|
+
parentConversationId: inboundClaimContext.parentConversationId
|
|
909
|
+
}) : null;
|
|
910
|
+
const pluginOwnedBinding = isPluginOwnedSessionBindingRecord(pluginOwnedBindingRecord) ? toPluginConversationBinding(pluginOwnedBindingRecord) : null;
|
|
911
|
+
const sendPolicy = resolveSendPolicy({
|
|
912
|
+
cfg,
|
|
913
|
+
entry: sessionStoreEntry.entry,
|
|
914
|
+
sessionKey: sessionStoreEntry.sessionKey ?? sessionKey,
|
|
915
|
+
channel: (shouldRouteToOriginating ? routeReplyChannel : void 0) ?? sessionStoreEntry.entry?.channel ?? replyRoute.channel ?? ctx.Surface ?? ctx.Provider ?? void 0,
|
|
916
|
+
chatType: sessionStoreEntry.entry?.chatType
|
|
917
|
+
});
|
|
918
|
+
const { globalPolicy, globalProviderPolicy, agentPolicy, agentProviderPolicy, profile, providerProfile, profileAlsoAllow, providerProfileAlsoAllow } = resolveEffectiveToolPolicy({
|
|
919
|
+
config: cfg,
|
|
920
|
+
sessionKey: acpDispatchSessionKey,
|
|
921
|
+
agentId: sessionAgentId
|
|
922
|
+
});
|
|
923
|
+
const chatType = normalizeChatType(ctx.ChatType);
|
|
924
|
+
const configuredVisibleReplies = chatType === "group" || chatType === "channel" ? cfg.messages?.groupChat?.visibleReplies ?? cfg.messages?.visibleReplies : cfg.messages?.visibleReplies;
|
|
925
|
+
const harnessDefaultVisibleReplies = configuredVisibleReplies === void 0 && chatType !== "group" && chatType !== "channel" ? resolveHarnessSourceVisibleRepliesDefault({
|
|
926
|
+
cfg,
|
|
927
|
+
ctx,
|
|
928
|
+
entry: sessionStoreEntry.entry,
|
|
929
|
+
sessionAgentId,
|
|
930
|
+
sessionKey: acpDispatchSessionKey,
|
|
931
|
+
sessionStore: sessionStoreEntry.store,
|
|
932
|
+
turnModelOverride: resolveTurnModelOverride(params.replyOptions)
|
|
933
|
+
}) : void 0;
|
|
934
|
+
const effectiveVisibleReplies = configuredVisibleReplies ?? harnessDefaultVisibleReplies;
|
|
935
|
+
const runtimeProfileAlsoAllow = params.replyOptions?.sourceReplyDeliveryMode === "message_tool_only" || ctx.InboundEventKind === "room_event" && !isInternalWebchatTurn || params.replyOptions?.sourceReplyDeliveryMode === void 0 && !isExplicitSourceReplyCommand(ctx, cfg) && (configuredVisibleReplies === "message_tool" || !isInternalWebchatTurn && effectiveVisibleReplies === "message_tool") ? ["message"] : [];
|
|
936
|
+
const profilePolicy = mergeAlsoAllowPolicy(resolveToolProfilePolicy(profile), [...profileAlsoAllow ?? [], ...runtimeProfileAlsoAllow]);
|
|
937
|
+
const providerProfilePolicy = mergeAlsoAllowPolicy(resolveToolProfilePolicy(providerProfile), [...providerProfileAlsoAllow ?? [], ...runtimeProfileAlsoAllow]);
|
|
938
|
+
const groupResolution = resolveGroupSessionKey(ctx);
|
|
939
|
+
const groupPolicy = resolveGroupToolPolicy({
|
|
940
|
+
config: cfg,
|
|
941
|
+
sessionKey: acpDispatchSessionKey,
|
|
942
|
+
messageProvider: resolveOriginMessageProvider({
|
|
943
|
+
originatingChannel: ctx.OriginatingChannel,
|
|
944
|
+
provider: ctx.Provider ?? ctx.Surface
|
|
945
|
+
}),
|
|
946
|
+
groupId: groupResolution?.id,
|
|
947
|
+
groupChannel: normalizeOptionalString(ctx.GroupChannel) ?? normalizeOptionalString(ctx.GroupSubject),
|
|
948
|
+
groupSpace: normalizeOptionalString(ctx.GroupSpace),
|
|
949
|
+
accountId: ctx.AccountId,
|
|
950
|
+
senderId: normalizeOptionalString(ctx.SenderId),
|
|
951
|
+
senderName: normalizeOptionalString(ctx.SenderName),
|
|
952
|
+
senderUsername: normalizeOptionalString(ctx.SenderUsername),
|
|
953
|
+
senderE164: normalizeOptionalString(ctx.SenderE164)
|
|
954
|
+
});
|
|
955
|
+
const subagentStore = resolveSubagentCapabilityStore(acpDispatchSessionKey, { cfg });
|
|
956
|
+
const messageToolAvailable = isToolAllowedByPolicies("message", [
|
|
957
|
+
profilePolicy,
|
|
958
|
+
providerProfilePolicy,
|
|
959
|
+
globalProviderPolicy,
|
|
960
|
+
agentProviderPolicy,
|
|
961
|
+
globalPolicy,
|
|
962
|
+
agentPolicy,
|
|
963
|
+
groupPolicy,
|
|
964
|
+
acpDispatchSessionKey && isSubagentEnvelopeSession(acpDispatchSessionKey, {
|
|
965
|
+
cfg,
|
|
966
|
+
store: subagentStore
|
|
967
|
+
}) ? resolveSubagentToolPolicyForSession(cfg, acpDispatchSessionKey, { store: subagentStore }) : void 0,
|
|
968
|
+
resolveInheritedToolPolicyForSession(cfg, acpDispatchSessionKey, { store: subagentStore })
|
|
969
|
+
]);
|
|
970
|
+
const sourceReplyPolicy = resolveSourceReplyVisibilityPolicy({
|
|
971
|
+
cfg,
|
|
972
|
+
ctx,
|
|
973
|
+
requested: params.replyOptions?.sourceReplyDeliveryMode,
|
|
974
|
+
strictMessageToolOnly: ctx.InboundEventKind === "room_event" && !isInternalWebchatTurn,
|
|
975
|
+
sendPolicy,
|
|
976
|
+
suppressAcpChildUserDelivery,
|
|
977
|
+
explicitSuppressTyping: params.replyOptions?.suppressTyping === true,
|
|
978
|
+
shouldSuppressTyping,
|
|
979
|
+
messageToolAvailable,
|
|
980
|
+
defaultVisibleReplies: harnessDefaultVisibleReplies
|
|
981
|
+
});
|
|
982
|
+
const { sourceReplyDeliveryMode, suppressAutomaticSourceDelivery, suppressDelivery, sendPolicyDenied, deliverySuppressionReason, suppressHookUserDelivery, suppressHookReplyLifecycle } = sourceReplyPolicy;
|
|
983
|
+
const attachSourceReplyDeliveryMode = (result) => sourceReplyDeliveryMode === "message_tool_only" ? {
|
|
984
|
+
...result,
|
|
985
|
+
sourceReplyDeliveryMode
|
|
986
|
+
} : result;
|
|
987
|
+
const inboundDedupeClaim = claimInboundDedupe(ctx);
|
|
988
|
+
if (inboundDedupeClaim.status === "duplicate" || inboundDedupeClaim.status === "inflight") {
|
|
989
|
+
recordProcessed("skipped", { reason: "duplicate" });
|
|
990
|
+
return attachSourceReplyDeliveryMode({
|
|
991
|
+
queuedFinal: false,
|
|
992
|
+
counts: dispatcher.getQueuedCounts()
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
const commitInboundDedupeIfClaimed = () => {
|
|
996
|
+
if (inboundDedupeClaim.status === "claimed") commitInboundDedupe(inboundDedupeClaim.key);
|
|
997
|
+
};
|
|
998
|
+
const finishReplyOperationBusyDispatch = (opts) => {
|
|
999
|
+
if (opts?.recordAgentDispatchCompleted) recordAgentDispatchCompleted("completed", { reason: "reply-operation-active" });
|
|
1000
|
+
recordProcessed("skipped", { reason: "reply-operation-active" });
|
|
1001
|
+
markIdle("message_completed");
|
|
1002
|
+
commitInboundDedupeIfClaimed();
|
|
1003
|
+
return attachSourceReplyDeliveryMode({
|
|
1004
|
+
queuedFinal: false,
|
|
1005
|
+
counts: dispatcher.getQueuedCounts()
|
|
1006
|
+
});
|
|
1007
|
+
};
|
|
1008
|
+
const finishReplyOperationAbortedDispatch = () => {
|
|
1009
|
+
commitInboundDedupeIfClaimed();
|
|
1010
|
+
recordProcessed("completed", { reason: "reply_operation_aborted" });
|
|
1011
|
+
markIdle("message_completed");
|
|
1012
|
+
completeDispatchReplyOperation();
|
|
1013
|
+
return attachSourceReplyDeliveryMode({
|
|
1014
|
+
queuedFinal: false,
|
|
1015
|
+
counts: dispatcher.getQueuedCounts()
|
|
1016
|
+
});
|
|
1017
|
+
};
|
|
1018
|
+
let pluginFallbackReason;
|
|
1019
|
+
if (pluginOwnedBinding) {
|
|
1020
|
+
if (isPreDispatchOperationAborted()) return finishReplyOperationAbortedDispatch();
|
|
1021
|
+
touchConversationBindingRecord(pluginOwnedBinding.bindingId);
|
|
1022
|
+
if (shouldBypassPluginOwnedBindingForCommand(ctx, cfg)) logVerbose(`plugin-bound inbound command escaped plugin binding (plugin=${pluginOwnedBinding.pluginId} session=${sessionKey ?? "unknown"}); falling through to command processing`);
|
|
1023
|
+
else if (sendPolicyDenied || suppressDelivery && !suppressAutomaticSourceDelivery) logVerbose(`plugin-bound inbound skipped under ${deliverySuppressionReason} (plugin=${pluginOwnedBinding.pluginId} session=${sessionKey ?? "unknown"}); falling through to suppressed agent processing`);
|
|
1024
|
+
else {
|
|
1025
|
+
logVerbose(`plugin-bound inbound routed to ${pluginOwnedBinding.pluginId} conversation=${pluginOwnedBinding.conversationId}`);
|
|
1026
|
+
const targetedClaimOutcome = hookRunner?.runInboundClaimForPluginOutcome ? await hookRunner.runInboundClaimForPluginOutcome(pluginOwnedBinding.pluginId, inboundClaimEvent, {
|
|
1027
|
+
...inboundClaimContext,
|
|
1028
|
+
pluginBinding: pluginOwnedBinding
|
|
1029
|
+
}) : getGlobalPluginRegistry()?.plugins.some((plugin) => plugin.id === pluginOwnedBinding.pluginId && plugin.status === "loaded") ?? false ? { status: "no_handler" } : { status: "missing_plugin" };
|
|
1030
|
+
switch (targetedClaimOutcome.status) {
|
|
1031
|
+
case "handled":
|
|
1032
|
+
if (targetedClaimOutcome.result.reply) await sendBindingNotice(targetedClaimOutcome.result.reply, "terminal");
|
|
1033
|
+
markIdle("plugin_binding_dispatch");
|
|
1034
|
+
recordProcessed("completed", { reason: "plugin-bound-handled" });
|
|
1035
|
+
commitInboundDedupeIfClaimed();
|
|
1036
|
+
return attachSourceReplyDeliveryMode({
|
|
1037
|
+
queuedFinal: false,
|
|
1038
|
+
counts: dispatcher.getQueuedCounts()
|
|
1039
|
+
});
|
|
1040
|
+
case "missing_plugin":
|
|
1041
|
+
case "no_handler":
|
|
1042
|
+
pluginFallbackReason = targetedClaimOutcome.status === "missing_plugin" ? "plugin-bound-fallback-missing-plugin" : "plugin-bound-fallback-no-handler";
|
|
1043
|
+
if ((chatType === "group" || chatType === "channel") && ctx.WasMentioned === false && !isExplicitSourceReplyCommand(ctx, cfg)) {
|
|
1044
|
+
markIdle("plugin_binding_fallback_unmentioned");
|
|
1045
|
+
recordProcessed("completed", { reason: pluginFallbackReason });
|
|
1046
|
+
commitInboundDedupeIfClaimed();
|
|
1047
|
+
return attachSourceReplyDeliveryMode({
|
|
1048
|
+
queuedFinal: false,
|
|
1049
|
+
counts: dispatcher.getQueuedCounts()
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
if (!hasShownPluginBindingFallbackNotice(pluginOwnedBinding.bindingId)) {
|
|
1053
|
+
if (await sendBindingNotice({ text: buildPluginBindingUnavailableText(pluginOwnedBinding) }, "additive")) markPluginBindingFallbackNoticeShown(pluginOwnedBinding.bindingId);
|
|
1054
|
+
}
|
|
1055
|
+
break;
|
|
1056
|
+
case "declined":
|
|
1057
|
+
await sendBindingNotice({ text: buildPluginBindingDeclinedText(pluginOwnedBinding) }, "terminal");
|
|
1058
|
+
markIdle("plugin_binding_declined");
|
|
1059
|
+
recordProcessed("completed", { reason: "plugin-bound-declined" });
|
|
1060
|
+
commitInboundDedupeIfClaimed();
|
|
1061
|
+
return attachSourceReplyDeliveryMode({
|
|
1062
|
+
queuedFinal: false,
|
|
1063
|
+
counts: dispatcher.getQueuedCounts()
|
|
1064
|
+
});
|
|
1065
|
+
case "error":
|
|
1066
|
+
logVerbose(`plugin-bound inbound claim failed for ${pluginOwnedBinding.pluginId}: ${targetedClaimOutcome.error}`);
|
|
1067
|
+
await sendBindingNotice({ text: buildPluginBindingErrorText(pluginOwnedBinding) }, "terminal");
|
|
1068
|
+
markIdle("plugin_binding_error");
|
|
1069
|
+
recordProcessed("completed", { reason: "plugin-bound-error" });
|
|
1070
|
+
commitInboundDedupeIfClaimed();
|
|
1071
|
+
return attachSourceReplyDeliveryMode({
|
|
1072
|
+
queuedFinal: false,
|
|
1073
|
+
counts: dispatcher.getQueuedCounts()
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
if (hookRunner?.hasHooks("message_received")) fireAndForgetHook(hookRunner.runMessageReceived(toPluginMessageReceivedEvent(hookContext), toPluginMessageContext(hookContext)), "dispatch-from-config: message_received plugin hook failed");
|
|
1079
|
+
if (sessionKey) fireAndForgetHook(triggerInternalHook(createInternalHookEvent("message", "received", sessionKey, {
|
|
1080
|
+
...toInternalMessageReceivedContext(hookContext),
|
|
1081
|
+
timestamp
|
|
1082
|
+
})), "dispatch-from-config: message_received internal hook failed");
|
|
1083
|
+
markProcessing();
|
|
1084
|
+
try {
|
|
1085
|
+
const abortRuntime = params.fastAbortResolver ? null : await loadAbortRuntime();
|
|
1086
|
+
const fastAbortResolver = params.fastAbortResolver ?? abortRuntime?.tryFastAbortFromMessage;
|
|
1087
|
+
const formatAbortReplyTextResolver = params.formatAbortReplyTextResolver ?? abortRuntime?.formatAbortReplyText;
|
|
1088
|
+
if (!fastAbortResolver || !formatAbortReplyTextResolver) throw new Error("abort runtime unavailable");
|
|
1089
|
+
const fastAbort = await fastAbortResolver({
|
|
1090
|
+
ctx,
|
|
1091
|
+
cfg
|
|
1092
|
+
});
|
|
1093
|
+
if (fastAbort.handled) {
|
|
1094
|
+
let queuedFinal = false;
|
|
1095
|
+
let routedFinalCount = 0;
|
|
1096
|
+
if (!suppressDelivery) {
|
|
1097
|
+
const payload = { text: formatAbortReplyTextResolver(fastAbort.stoppedSubagents) };
|
|
1098
|
+
const result = await routeReplyToOriginating(payload);
|
|
1099
|
+
if (result) {
|
|
1100
|
+
queuedFinal = result.ok;
|
|
1101
|
+
if (isRoutedReplyDelivered(result)) routedFinalCount += 1;
|
|
1102
|
+
if (!result.ok) logVerbose(`dispatch-from-config: route-reply (abort) failed: ${result.error ?? "unknown error"}`);
|
|
1103
|
+
} else {
|
|
1104
|
+
markInboundDedupeReplayUnsafe();
|
|
1105
|
+
queuedFinal = dispatcher.sendFinalReply(payload);
|
|
1106
|
+
}
|
|
1107
|
+
} else logVerbose(`dispatch-from-config: fast_abort reply suppressed by ${deliverySuppressionReason} (session=${sessionKey ?? "unknown"})`);
|
|
1108
|
+
const counts = dispatcher.getQueuedCounts();
|
|
1109
|
+
counts.final += routedFinalCount;
|
|
1110
|
+
recordProcessed("completed", { reason: "fast_abort" });
|
|
1111
|
+
markIdle("message_completed");
|
|
1112
|
+
commitInboundDedupeIfClaimed();
|
|
1113
|
+
completeDispatchReplyOperation();
|
|
1114
|
+
return attachSourceReplyDeliveryMode({
|
|
1115
|
+
queuedFinal,
|
|
1116
|
+
counts
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
if ((await ensureDispatchReplyOperation("pre_dispatch")).status === "busy") return finishReplyOperationBusyDispatch();
|
|
1120
|
+
const shouldSuppressDefaultToolProgressMessages = () => !shouldEmitVerboseProgress();
|
|
1121
|
+
const shouldSendVerboseProgressMessages = () => !shouldSuppressDefaultToolProgressMessages();
|
|
1122
|
+
const shouldSendToolSummaries = () => shouldSendVerboseProgressMessages();
|
|
1123
|
+
const shouldDeliverVerboseProgressDespiteSourceSuppression = () => suppressAutomaticSourceDelivery && sourceReplyDeliveryMode === "message_tool_only" && ctx.InboundEventKind !== "room_event" && !sendPolicyDenied && shouldEmitVerboseProgress() && shouldSendVerboseProgressMessages();
|
|
1124
|
+
let finalReplyDeliveryStarted = false;
|
|
1125
|
+
const hasExecApprovalPayload = (payload) => {
|
|
1126
|
+
const execApproval = payload.channelData && typeof payload.channelData === "object" && !Array.isArray(payload.channelData) ? payload.channelData.execApproval : void 0;
|
|
1127
|
+
return execApproval && typeof execApproval === "object" && !Array.isArray(execApproval);
|
|
1128
|
+
};
|
|
1129
|
+
const shouldSuppressLateTextOnlyToolProgress = (payload) => {
|
|
1130
|
+
if (!finalReplyDeliveryStarted) return false;
|
|
1131
|
+
return !resolveSendableOutboundReplyParts(payload).hasMedia && !hasExecApprovalPayload(payload);
|
|
1132
|
+
};
|
|
1133
|
+
const shouldSuppressMessageToolOnlyTextErrorProgress = (payload) => {
|
|
1134
|
+
if (sourceReplyDeliveryMode !== "message_tool_only" || shouldEmitFullVerboseProgress() || payload.isError !== true) return false;
|
|
1135
|
+
return !resolveSendableOutboundReplyParts(payload).hasMedia && !hasExecApprovalPayload(payload);
|
|
1136
|
+
};
|
|
1137
|
+
const sendFinalPayload = async (payload, options = {}) => {
|
|
1138
|
+
const abortSignal = options.abortSignal ?? getDispatchAbortSignal();
|
|
1139
|
+
const throwIfFinalDeliveryAborted = () => {
|
|
1140
|
+
if (abortSignal?.aborted) throw new DispatchReplyOperationAbortedError();
|
|
1141
|
+
};
|
|
1142
|
+
throwIfFinalDeliveryAborted();
|
|
1143
|
+
const sourceReplyTranscriptMirror = getReplyPayloadMetadata(payload)?.sourceReplyTranscriptMirror;
|
|
1144
|
+
if (hasOutboundReplyContent(payload, { trimText: true })) {
|
|
1145
|
+
markInboundDedupeReplayUnsafe();
|
|
1146
|
+
finalReplyDeliveryStarted = true;
|
|
1147
|
+
}
|
|
1148
|
+
const ttsPayload = await maybeApplyTtsToReplyPayload({
|
|
1149
|
+
payload,
|
|
1150
|
+
cfg,
|
|
1151
|
+
channel: deliveryChannel,
|
|
1152
|
+
kind: "final",
|
|
1153
|
+
inboundAudio,
|
|
1154
|
+
ttsAuto: sessionTtsAuto,
|
|
1155
|
+
agentId: sessionAgentId,
|
|
1156
|
+
accountId: replyRoute.accountId
|
|
1157
|
+
});
|
|
1158
|
+
throwIfFinalDeliveryAborted();
|
|
1159
|
+
const normalizedPayload = await normalizeReplyMediaPayload(ttsPayload);
|
|
1160
|
+
throwIfFinalDeliveryAborted();
|
|
1161
|
+
const result = await routeReplyToOriginating(normalizedPayload, {
|
|
1162
|
+
abortSignal,
|
|
1163
|
+
kind: "final"
|
|
1164
|
+
});
|
|
1165
|
+
if (result) {
|
|
1166
|
+
if (!result.ok) logVerbose(`dispatch-from-config: route-reply (final) failed: ${result.error ?? "unknown error"}`);
|
|
1167
|
+
if (isRoutedReplyDelivered(result)) await mirrorInternalSourceReplyToTranscript({
|
|
1168
|
+
metadata: sourceReplyTranscriptMirror,
|
|
1169
|
+
cfg
|
|
1170
|
+
});
|
|
1171
|
+
return {
|
|
1172
|
+
queuedFinal: result.ok,
|
|
1173
|
+
routedFinalCount: isRoutedReplyDelivered(result) ? 1 : 0
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
throwIfFinalDeliveryAborted();
|
|
1177
|
+
markInboundDedupeReplayUnsafe();
|
|
1178
|
+
const finalOutcomeBefore = getDispatcherFinalOutcomeCounts(dispatcher);
|
|
1179
|
+
const deliveredSourceReplyTranscriptMirror = captureDeliveredSourceReplyTranscriptMirror({
|
|
1180
|
+
dispatcher,
|
|
1181
|
+
metadata: sourceReplyTranscriptMirror
|
|
1182
|
+
});
|
|
1183
|
+
const queuedFinal = dispatcher.sendFinalReply(normalizedPayload);
|
|
1184
|
+
if (queuedFinal) await mirrorInternalSourceReplyAfterDispatcherDelivery({
|
|
1185
|
+
dispatcher,
|
|
1186
|
+
before: finalOutcomeBefore,
|
|
1187
|
+
metadata: deliveredSourceReplyTranscriptMirror,
|
|
1188
|
+
cfg
|
|
1189
|
+
});
|
|
1190
|
+
return {
|
|
1191
|
+
queuedFinal,
|
|
1192
|
+
routedFinalCount: 0
|
|
1193
|
+
};
|
|
1194
|
+
};
|
|
1195
|
+
if (hookRunner?.hasHooks("before_dispatch")) {
|
|
1196
|
+
const beforeDispatchResult = await traceReplyPhase("reply.before_dispatch_hooks", () => runWithDispatchAbortSignal(getPreDispatchAbortSignal(), () => hookRunner.runBeforeDispatch({
|
|
1197
|
+
content: hookContext.content,
|
|
1198
|
+
body: hookContext.bodyForAgent ?? hookContext.body,
|
|
1199
|
+
channel: hookContext.channelId,
|
|
1200
|
+
sessionKey: sessionStoreEntry.sessionKey ?? sessionKey,
|
|
1201
|
+
senderId: hookContext.senderId,
|
|
1202
|
+
isGroup: hookContext.isGroup,
|
|
1203
|
+
timestamp: hookContext.timestamp
|
|
1204
|
+
}, {
|
|
1205
|
+
channelId: hookContext.channelId,
|
|
1206
|
+
accountId: hookContext.accountId,
|
|
1207
|
+
conversationId: inboundClaimContext.conversationId,
|
|
1208
|
+
sessionKey: sessionStoreEntry.sessionKey ?? sessionKey,
|
|
1209
|
+
senderId: hookContext.senderId
|
|
1210
|
+
})));
|
|
1211
|
+
if (beforeDispatchResult?.handled) {
|
|
1212
|
+
const text = beforeDispatchResult.text;
|
|
1213
|
+
let queuedFinal = false;
|
|
1214
|
+
let routedFinalCount = 0;
|
|
1215
|
+
if (text && !suppressDelivery) {
|
|
1216
|
+
const handledReply = await sendFinalPayload({ text }, { abortSignal: getPreDispatchAbortSignal() });
|
|
1217
|
+
queuedFinal = handledReply.queuedFinal;
|
|
1218
|
+
routedFinalCount += handledReply.routedFinalCount;
|
|
1219
|
+
}
|
|
1220
|
+
const counts = dispatcher.getQueuedCounts();
|
|
1221
|
+
counts.final += routedFinalCount;
|
|
1222
|
+
recordProcessed("completed", { reason: "before_dispatch_handled" });
|
|
1223
|
+
markIdle("message_completed");
|
|
1224
|
+
commitInboundDedupeIfClaimed();
|
|
1225
|
+
completeDispatchReplyOperation();
|
|
1226
|
+
return attachSourceReplyDeliveryMode({
|
|
1227
|
+
queuedFinal,
|
|
1228
|
+
counts
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
if (hookRunner?.hasHooks("reply_dispatch")) {
|
|
1233
|
+
const replyDispatchResult = await traceReplyPhase("reply.reply_dispatch_hooks", () => runWithDispatchAbortSignal(getPreDispatchAbortSignal(), () => hookRunner.runReplyDispatch(createReplyDispatchEvent({
|
|
1234
|
+
ctx,
|
|
1235
|
+
runId: params.replyOptions?.runId,
|
|
1236
|
+
sessionKey: acpDispatchSessionKey,
|
|
1237
|
+
images: params.replyOptions?.images,
|
|
1238
|
+
inboundAudio,
|
|
1239
|
+
sessionTtsAuto,
|
|
1240
|
+
ttsChannel: deliveryChannel,
|
|
1241
|
+
suppressUserDelivery: suppressHookUserDelivery,
|
|
1242
|
+
suppressReplyLifecycle: suppressHookReplyLifecycle,
|
|
1243
|
+
sourceReplyDeliveryMode,
|
|
1244
|
+
shouldRouteToOriginating,
|
|
1245
|
+
originatingChannel: routeReplyChannel,
|
|
1246
|
+
originatingTo: routeReplyTo,
|
|
1247
|
+
shouldSendToolSummaries,
|
|
1248
|
+
sendPolicy
|
|
1249
|
+
}), {
|
|
1250
|
+
cfg,
|
|
1251
|
+
dispatcher: dispatchHookDispatcher,
|
|
1252
|
+
abortSignal: getPreDispatchAbortSignal() ?? params.replyOptions?.abortSignal,
|
|
1253
|
+
onReplyStart: params.replyOptions?.onReplyStart,
|
|
1254
|
+
recordProcessed,
|
|
1255
|
+
markIdle
|
|
1256
|
+
})));
|
|
1257
|
+
if (replyDispatchResult?.handled) {
|
|
1258
|
+
commitInboundDedupeIfClaimed();
|
|
1259
|
+
completeDispatchReplyOperation();
|
|
1260
|
+
return attachSourceReplyDeliveryMode({
|
|
1261
|
+
queuedFinal: replyDispatchResult.queuedFinal,
|
|
1262
|
+
counts: replyDispatchResult.counts
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
if ((await ensureDispatchReplyOperation("dispatch")).status === "busy") return finishReplyOperationBusyDispatch();
|
|
1267
|
+
if (suppressDelivery) logVerbose(`Delivery suppressed by ${deliverySuppressionReason} for session ${sessionStoreEntry.sessionKey ?? sessionKey ?? "unknown"} — agent will still process the message`);
|
|
1268
|
+
const toolStartStatusesSent = /* @__PURE__ */ new Set();
|
|
1269
|
+
let toolStartStatusCount = 0;
|
|
1270
|
+
let didSendPlanStatusNotice = false;
|
|
1271
|
+
const normalizeWorkingLabel = (label) => {
|
|
1272
|
+
const collapsed = label.replace(/\s+/g, " ").trim();
|
|
1273
|
+
if (collapsed.length <= 80) return collapsed;
|
|
1274
|
+
return `${collapsed.slice(0, 77).trimEnd()}...`;
|
|
1275
|
+
};
|
|
1276
|
+
const formatPlanUpdateText = (payload) => {
|
|
1277
|
+
const explanation = payload.explanation?.replace(/\s+/g, " ").trim();
|
|
1278
|
+
const steps = (payload.steps ?? []).map((step) => step.replace(/\s+/g, " ").trim()).filter(Boolean);
|
|
1279
|
+
if (steps.length > 0) return steps.map((step, index) => `${index + 1}. ${step}`).join("\n");
|
|
1280
|
+
return explanation || "Planning next steps.";
|
|
1281
|
+
};
|
|
1282
|
+
const maybeSendWorkingStatus = async (label) => {
|
|
1283
|
+
if (shouldSuppressProgressDelivery()) return;
|
|
1284
|
+
const normalizedLabel = normalizeWorkingLabel(label);
|
|
1285
|
+
if (!shouldEmitVerboseProgress() || true) return;
|
|
1286
|
+
toolStartStatusesSent.add(normalizedLabel);
|
|
1287
|
+
toolStartStatusCount += 1;
|
|
1288
|
+
const payload = { text: `Working: ${normalizedLabel}` };
|
|
1289
|
+
if (shouldRouteToOriginating) {
|
|
1290
|
+
await sendPayloadAsync(payload, void 0, false);
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
markInboundDedupeReplayUnsafe();
|
|
1294
|
+
dispatcher.sendToolResult(payload);
|
|
1295
|
+
};
|
|
1296
|
+
const sendPlanUpdate = async (payload) => {
|
|
1297
|
+
if (shouldSuppressProgressDelivery() || !shouldSendVerboseProgressMessages() || didSendPlanStatusNotice) return;
|
|
1298
|
+
didSendPlanStatusNotice = true;
|
|
1299
|
+
const replyPayload = {
|
|
1300
|
+
text: formatPlanUpdateText(payload),
|
|
1301
|
+
isStatusNotice: true
|
|
1302
|
+
};
|
|
1303
|
+
if (shouldRouteToOriginating) {
|
|
1304
|
+
await sendPayloadAsync(replyPayload, void 0, false);
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
markInboundDedupeReplayUnsafe();
|
|
1308
|
+
dispatcher.sendToolResult(replyPayload);
|
|
1309
|
+
};
|
|
1310
|
+
const summarizeApprovalLabel = (payload) => {
|
|
1311
|
+
if (payload.status === "pending") {
|
|
1312
|
+
const command = normalizeOptionalString(payload.command);
|
|
1313
|
+
if (command) return normalizeWorkingLabel(`awaiting approval: ${command}`);
|
|
1314
|
+
return "awaiting approval";
|
|
1315
|
+
}
|
|
1316
|
+
if (payload.status === "unavailable") {
|
|
1317
|
+
const message = normalizeOptionalString(payload.message);
|
|
1318
|
+
if (message) return normalizeWorkingLabel(message);
|
|
1319
|
+
return "approval unavailable";
|
|
1320
|
+
}
|
|
1321
|
+
return "";
|
|
1322
|
+
};
|
|
1323
|
+
const summarizePatchLabel = (payload) => {
|
|
1324
|
+
const summary = normalizeOptionalString(payload.summary);
|
|
1325
|
+
if (summary) return normalizeWorkingLabel(summary);
|
|
1326
|
+
const title = normalizeOptionalString(payload.title);
|
|
1327
|
+
if (title) return normalizeWorkingLabel(title);
|
|
1328
|
+
return "";
|
|
1329
|
+
};
|
|
1330
|
+
let accumulatedBlockText = "";
|
|
1331
|
+
let accumulatedBlockTtsText = "";
|
|
1332
|
+
let blockCount = 0;
|
|
1333
|
+
const cleanBlockTtsDirectiveText = shouldCleanTtsDirectiveText({
|
|
1334
|
+
cfg,
|
|
1335
|
+
ttsAuto: sessionTtsAuto,
|
|
1336
|
+
agentId: sessionAgentId,
|
|
1337
|
+
channelId: deliveryChannel,
|
|
1338
|
+
accountId: replyRoute.accountId
|
|
1339
|
+
}) ? createTtsDirectiveTextStreamCleaner() : void 0;
|
|
1340
|
+
const resolveToolDeliveryPayload = (payload) => {
|
|
1341
|
+
if (shouldSuppressLocalExecApprovalPrompt({
|
|
1342
|
+
channel: normalizeMessageChannel(ctx.Surface ?? ctx.Provider),
|
|
1343
|
+
cfg,
|
|
1344
|
+
accountId: ctx.AccountId,
|
|
1345
|
+
payload
|
|
1346
|
+
})) return null;
|
|
1347
|
+
if (shouldSendToolSummaries()) return payload;
|
|
1348
|
+
const execApproval = payload.channelData && typeof payload.channelData === "object" && !Array.isArray(payload.channelData) ? payload.channelData.execApproval : void 0;
|
|
1349
|
+
if (execApproval && typeof execApproval === "object" && !Array.isArray(execApproval)) return payload;
|
|
1350
|
+
if (!resolveSendableOutboundReplyParts(payload).hasMedia) return null;
|
|
1351
|
+
return {
|
|
1352
|
+
...payload,
|
|
1353
|
+
text: void 0
|
|
1354
|
+
};
|
|
1355
|
+
};
|
|
1356
|
+
const typing = resolveRunTypingPolicy({
|
|
1357
|
+
requestedPolicy: params.replyOptions?.typingPolicy,
|
|
1358
|
+
suppressTyping: sourceReplyPolicy.suppressTyping,
|
|
1359
|
+
originatingChannel: routeReplyChannel,
|
|
1360
|
+
systemEvent: shouldRouteToOriginating
|
|
1361
|
+
});
|
|
1362
|
+
const shouldSuppressProgressDelivery = () => sendPolicyDenied || suppressDelivery && !shouldDeliverVerboseProgressDespiteSourceSuppression();
|
|
1363
|
+
const hasVisibleRegularVerboseToolProgress = () => shouldEmitVerboseProgress() && !shouldEmitFullVerboseProgress() && shouldSendVerboseProgressMessages() && ctx.InboundEventKind !== "room_event" && !shouldSuppressProgressDelivery();
|
|
1364
|
+
let observedVisibleToolErrorProgress = false;
|
|
1365
|
+
const markVisibleToolErrorProgress = () => {
|
|
1366
|
+
if (hasVisibleRegularVerboseToolProgress()) observedVisibleToolErrorProgress = true;
|
|
1367
|
+
};
|
|
1368
|
+
const hasFailedProgressStatus = (payload) => payload.phase === "error" || payload.status === "failed" || payload.status === "error" || typeof payload.exitCode === "number" && payload.exitCode !== 0;
|
|
1369
|
+
const shouldSuppressToolErrorWarnings = () => {
|
|
1370
|
+
if (params.replyOptions?.suppressToolErrorWarnings !== void 0) return params.replyOptions.suppressToolErrorWarnings;
|
|
1371
|
+
if (!shouldEmitVerboseProgress()) return false;
|
|
1372
|
+
return observedVisibleToolErrorProgress ? true : void 0;
|
|
1373
|
+
};
|
|
1374
|
+
const suppressToolErrorWarnings = params.replyOptions?.suppressToolErrorWarnings ?? (observedVisibleToolErrorProgress ? true : void 0);
|
|
1375
|
+
const onToolResultFromReplyOptions = params.replyOptions?.onToolResult;
|
|
1376
|
+
const onPlanUpdateFromReplyOptions = params.replyOptions?.onPlanUpdate;
|
|
1377
|
+
const onApprovalEventFromReplyOptions = params.replyOptions?.onApprovalEvent;
|
|
1378
|
+
const onPatchSummaryFromReplyOptions = params.replyOptions?.onPatchSummary;
|
|
1379
|
+
const allowSuppressedSourceProgressCallbacks = params.replyOptions?.allowProgressCallbacksWhenSourceDeliverySuppressed === true;
|
|
1380
|
+
const shouldAllowQuietChannelOwnedProgressCallbacks = (options) => options?.requiresToolSummaryVisibility === true && params.replyOptions?.suppressDefaultToolProgressMessages === true;
|
|
1381
|
+
let hasPendingDirectBlockReplyDelivery = false;
|
|
1382
|
+
const waitForPendingDirectBlockReplyDelivery = async (abortSignal) => {
|
|
1383
|
+
if (!hasPendingDirectBlockReplyDelivery) return;
|
|
1384
|
+
hasPendingDirectBlockReplyDelivery = false;
|
|
1385
|
+
await waitForReplyDispatcherIdle(dispatcher, abortSignal);
|
|
1386
|
+
};
|
|
1387
|
+
const shouldForwardProgressCallback = (options) => {
|
|
1388
|
+
if (options?.requiresToolSummaryVisibility === true && !shouldSendToolSummaries() && !shouldAllowQuietChannelOwnedProgressCallbacks(options)) return false;
|
|
1389
|
+
return !suppressAutomaticSourceDelivery || allowSuppressedSourceProgressCallbacks && ctx.InboundEventKind !== "room_event" && !sendPolicyDenied && options?.forwardWhenSourceDeliverySuppressed === true;
|
|
1390
|
+
};
|
|
1391
|
+
const wrapProgressCallback = (callback, options) => {
|
|
1392
|
+
if (!callback) return;
|
|
1393
|
+
return async (...args) => {
|
|
1394
|
+
if (isDispatchOperationAborted()) return;
|
|
1395
|
+
markProgress();
|
|
1396
|
+
if (options?.waitForDirectBlockReplyDelivery) {
|
|
1397
|
+
await waitForPendingDirectBlockReplyDelivery(dispatchAbortOperation?.abortSignal);
|
|
1398
|
+
if (isDispatchOperationAborted()) return;
|
|
1399
|
+
}
|
|
1400
|
+
if (shouldForwardProgressCallback(options)) {
|
|
1401
|
+
options?.onForward?.(...args);
|
|
1402
|
+
await callback?.(...args);
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
};
|
|
1406
|
+
const replyResolver = params.replyResolver ?? (await traceReplyPhase("reply.load_reply_resolver", () => loadGetReplyFromConfigRuntime())).getReplyFromConfig;
|
|
1407
|
+
const replyConfig = withFullRuntimeReplyConfig(params.configOverride ? applyMergePatch(cfg, params.configOverride) : cfg);
|
|
1408
|
+
recordAgentDispatchStarted();
|
|
1409
|
+
const replyResult = await runWithDispatchAbortSignal(getDispatchAbortSignal(), () => traceReplyPhase("reply.run_reply_resolver", () => replyResolver(ctx, {
|
|
1410
|
+
...getReplyOptions(),
|
|
1411
|
+
sourceReplyDeliveryMode,
|
|
1412
|
+
suppressToolErrorWarnings,
|
|
1413
|
+
shouldSuppressToolErrorWarnings,
|
|
1414
|
+
typingPolicy: typing.typingPolicy,
|
|
1415
|
+
suppressTyping: typing.suppressTyping,
|
|
1416
|
+
onPartialReply: wrapProgressCallback(params.replyOptions?.onPartialReply),
|
|
1417
|
+
onReasoningStream: wrapProgressCallback(params.replyOptions?.onReasoningStream),
|
|
1418
|
+
onReasoningEnd: wrapProgressCallback(params.replyOptions?.onReasoningEnd),
|
|
1419
|
+
onAssistantMessageStart: wrapProgressCallback(params.replyOptions?.onAssistantMessageStart),
|
|
1420
|
+
onBlockReplyQueued: wrapProgressCallback(params.replyOptions?.onBlockReplyQueued),
|
|
1421
|
+
onToolStart: wrapProgressCallback(params.replyOptions?.onToolStart, {
|
|
1422
|
+
forwardWhenSourceDeliverySuppressed: true,
|
|
1423
|
+
requiresToolSummaryVisibility: true,
|
|
1424
|
+
waitForDirectBlockReplyDelivery: true
|
|
1425
|
+
}),
|
|
1426
|
+
onItemEvent: wrapProgressCallback(params.replyOptions?.onItemEvent, {
|
|
1427
|
+
forwardWhenSourceDeliverySuppressed: true,
|
|
1428
|
+
requiresToolSummaryVisibility: true,
|
|
1429
|
+
waitForDirectBlockReplyDelivery: true,
|
|
1430
|
+
onForward: (payload) => {
|
|
1431
|
+
if (hasFailedProgressStatus(payload)) markVisibleToolErrorProgress();
|
|
1432
|
+
}
|
|
1433
|
+
}),
|
|
1434
|
+
onCommandOutput: wrapProgressCallback(params.replyOptions?.onCommandOutput, {
|
|
1435
|
+
forwardWhenSourceDeliverySuppressed: true,
|
|
1436
|
+
requiresToolSummaryVisibility: true,
|
|
1437
|
+
waitForDirectBlockReplyDelivery: true,
|
|
1438
|
+
onForward: (payload) => {
|
|
1439
|
+
if (hasFailedProgressStatus(payload)) markVisibleToolErrorProgress();
|
|
1440
|
+
}
|
|
1441
|
+
}),
|
|
1442
|
+
onCompactionStart: wrapProgressCallback(params.replyOptions?.onCompactionStart, {
|
|
1443
|
+
forwardWhenSourceDeliverySuppressed: true,
|
|
1444
|
+
requiresToolSummaryVisibility: true,
|
|
1445
|
+
waitForDirectBlockReplyDelivery: true
|
|
1446
|
+
}),
|
|
1447
|
+
onCompactionEnd: wrapProgressCallback(params.replyOptions?.onCompactionEnd, {
|
|
1448
|
+
forwardWhenSourceDeliverySuppressed: true,
|
|
1449
|
+
requiresToolSummaryVisibility: true,
|
|
1450
|
+
waitForDirectBlockReplyDelivery: true
|
|
1451
|
+
}),
|
|
1452
|
+
onToolResult: (payload) => {
|
|
1453
|
+
markProgress();
|
|
1454
|
+
const run = async () => {
|
|
1455
|
+
if (isDispatchOperationAborted()) return;
|
|
1456
|
+
await waitForPendingDirectBlockReplyDelivery(dispatchAbortOperation?.abortSignal);
|
|
1457
|
+
if (isDispatchOperationAborted()) return;
|
|
1458
|
+
markInboundDedupeReplayUnsafe();
|
|
1459
|
+
if (!suppressAutomaticSourceDelivery && shouldSendToolSummaries()) await onToolResultFromReplyOptions?.(payload);
|
|
1460
|
+
if (isDispatchOperationAborted()) return;
|
|
1461
|
+
if (shouldSuppressProgressDelivery()) return;
|
|
1462
|
+
const visibleToolPayload = resolveToolDeliveryPayload(payload);
|
|
1463
|
+
if (!visibleToolPayload) return;
|
|
1464
|
+
const deliveryPayload = resolveToolDeliveryPayload(await normalizeReplyMediaPayload(await maybeApplyTtsToReplyPayload({
|
|
1465
|
+
payload: visibleToolPayload,
|
|
1466
|
+
cfg,
|
|
1467
|
+
channel: deliveryChannel,
|
|
1468
|
+
kind: "tool",
|
|
1469
|
+
inboundAudio,
|
|
1470
|
+
ttsAuto: sessionTtsAuto,
|
|
1471
|
+
agentId: sessionAgentId,
|
|
1472
|
+
accountId: replyRoute.accountId
|
|
1473
|
+
})));
|
|
1474
|
+
if (!deliveryPayload) return;
|
|
1475
|
+
if (isDispatchOperationAborted()) return;
|
|
1476
|
+
if (shouldSuppressLateTextOnlyToolProgress(deliveryPayload)) return;
|
|
1477
|
+
if (shouldSuppressMessageToolOnlyTextErrorProgress(deliveryPayload)) return;
|
|
1478
|
+
if (shouldSuppressDefaultToolProgressMessages()) {
|
|
1479
|
+
if (!resolveSendableOutboundReplyParts(deliveryPayload).hasMedia && !hasExecApprovalPayload(deliveryPayload)) return;
|
|
1480
|
+
}
|
|
1481
|
+
if (deliveryPayload.isError === true) markVisibleToolErrorProgress();
|
|
1482
|
+
if (shouldRouteToOriginating) await sendPayloadAsync(deliveryPayload, void 0, false);
|
|
1483
|
+
else {
|
|
1484
|
+
markInboundDedupeReplayUnsafe();
|
|
1485
|
+
dispatcher.sendToolResult(deliveryPayload);
|
|
1486
|
+
}
|
|
1487
|
+
};
|
|
1488
|
+
return run();
|
|
1489
|
+
},
|
|
1490
|
+
onPlanUpdate: async (payload) => {
|
|
1491
|
+
if (isDispatchOperationAborted()) return;
|
|
1492
|
+
markProgress();
|
|
1493
|
+
await waitForPendingDirectBlockReplyDelivery(dispatchAbortOperation?.abortSignal);
|
|
1494
|
+
if (isDispatchOperationAborted()) return;
|
|
1495
|
+
markInboundDedupeReplayUnsafe();
|
|
1496
|
+
if (shouldForwardProgressCallback({
|
|
1497
|
+
forwardWhenSourceDeliverySuppressed: true,
|
|
1498
|
+
requiresToolSummaryVisibility: true
|
|
1499
|
+
})) await onPlanUpdateFromReplyOptions?.(payload);
|
|
1500
|
+
if (isDispatchOperationAborted()) return;
|
|
1501
|
+
if (payload.phase !== "update" || shouldSuppressDefaultToolProgressMessages()) return;
|
|
1502
|
+
await sendPlanUpdate({
|
|
1503
|
+
explanation: payload.explanation,
|
|
1504
|
+
steps: payload.steps
|
|
1505
|
+
});
|
|
1506
|
+
},
|
|
1507
|
+
onApprovalEvent: async (payload) => {
|
|
1508
|
+
if (isDispatchOperationAborted()) return;
|
|
1509
|
+
markProgress();
|
|
1510
|
+
await waitForPendingDirectBlockReplyDelivery(dispatchAbortOperation?.abortSignal);
|
|
1511
|
+
if (isDispatchOperationAborted()) return;
|
|
1512
|
+
markInboundDedupeReplayUnsafe();
|
|
1513
|
+
if (shouldForwardProgressCallback({
|
|
1514
|
+
forwardWhenSourceDeliverySuppressed: true,
|
|
1515
|
+
requiresToolSummaryVisibility: true
|
|
1516
|
+
})) await onApprovalEventFromReplyOptions?.(payload);
|
|
1517
|
+
if (isDispatchOperationAborted()) return;
|
|
1518
|
+
if (payload.phase !== "requested" || shouldSuppressDefaultToolProgressMessages()) return;
|
|
1519
|
+
const label = summarizeApprovalLabel({
|
|
1520
|
+
status: payload.status,
|
|
1521
|
+
command: payload.command,
|
|
1522
|
+
message: payload.message
|
|
1523
|
+
});
|
|
1524
|
+
if (!label) return;
|
|
1525
|
+
await maybeSendWorkingStatus(label);
|
|
1526
|
+
},
|
|
1527
|
+
onPatchSummary: async (payload) => {
|
|
1528
|
+
if (isDispatchOperationAborted()) return;
|
|
1529
|
+
markProgress();
|
|
1530
|
+
await waitForPendingDirectBlockReplyDelivery(dispatchAbortOperation?.abortSignal);
|
|
1531
|
+
if (isDispatchOperationAborted()) return;
|
|
1532
|
+
markInboundDedupeReplayUnsafe();
|
|
1533
|
+
if (shouldForwardProgressCallback({
|
|
1534
|
+
forwardWhenSourceDeliverySuppressed: true,
|
|
1535
|
+
requiresToolSummaryVisibility: true
|
|
1536
|
+
})) await onPatchSummaryFromReplyOptions?.(payload);
|
|
1537
|
+
if (isDispatchOperationAborted()) return;
|
|
1538
|
+
if (payload.phase !== "end" || shouldSuppressDefaultToolProgressMessages()) return;
|
|
1539
|
+
const label = summarizePatchLabel({
|
|
1540
|
+
summary: payload.summary,
|
|
1541
|
+
title: payload.title
|
|
1542
|
+
});
|
|
1543
|
+
if (!label) return;
|
|
1544
|
+
await maybeSendWorkingStatus(label);
|
|
1545
|
+
},
|
|
1546
|
+
onBlockReply: (payload, context) => {
|
|
1547
|
+
markProgress();
|
|
1548
|
+
const run = async () => {
|
|
1549
|
+
if (isDispatchOperationAborted()) return;
|
|
1550
|
+
if (payload.isReasoning !== true && hasOutboundReplyContent(payload, { trimText: true })) markInboundDedupeReplayUnsafe();
|
|
1551
|
+
if (suppressDelivery) return;
|
|
1552
|
+
if (payload.isReasoning === true) return;
|
|
1553
|
+
const isStatusNotice = isReplyPayloadStatusNotice(payload);
|
|
1554
|
+
if (payload.text && !isStatusNotice) {
|
|
1555
|
+
const joinsBufferedTtsDirective = cleanBlockTtsDirectiveText?.hasBufferedDirectiveText() === true;
|
|
1556
|
+
if (accumulatedBlockText.length > 0) accumulatedBlockText += "\n";
|
|
1557
|
+
accumulatedBlockText += payload.text;
|
|
1558
|
+
if (accumulatedBlockTtsText.length > 0 && !joinsBufferedTtsDirective) accumulatedBlockTtsText += "\n";
|
|
1559
|
+
accumulatedBlockTtsText += payload.text;
|
|
1560
|
+
blockCount++;
|
|
1561
|
+
}
|
|
1562
|
+
const visiblePayload = payload.text && cleanBlockTtsDirectiveText && !isStatusNotice ? (() => {
|
|
1563
|
+
const text = cleanBlockTtsDirectiveText.push(payload.text);
|
|
1564
|
+
return {
|
|
1565
|
+
...payload,
|
|
1566
|
+
text: text.trim() ? text : void 0
|
|
1567
|
+
};
|
|
1568
|
+
})() : payload;
|
|
1569
|
+
if (!hasOutboundReplyContent(visiblePayload, { trimText: true })) return;
|
|
1570
|
+
const payloadMetadata = getReplyPayloadMetadata(payload);
|
|
1571
|
+
const queuedContext = payloadMetadata?.assistantMessageIndex !== void 0 ? {
|
|
1572
|
+
...context,
|
|
1573
|
+
assistantMessageIndex: payloadMetadata.assistantMessageIndex
|
|
1574
|
+
} : context;
|
|
1575
|
+
if (!suppressAutomaticSourceDelivery) await params.replyOptions?.onBlockReplyQueued?.(visiblePayload, queuedContext);
|
|
1576
|
+
if (isDispatchOperationAborted()) return;
|
|
1577
|
+
const normalizedPayload = await normalizeReplyMediaPayload(await maybeApplyTtsToReplyPayload({
|
|
1578
|
+
payload: visiblePayload,
|
|
1579
|
+
cfg,
|
|
1580
|
+
channel: deliveryChannel,
|
|
1581
|
+
kind: "block",
|
|
1582
|
+
inboundAudio,
|
|
1583
|
+
ttsAuto: sessionTtsAuto,
|
|
1584
|
+
agentId: sessionAgentId,
|
|
1585
|
+
accountId: replyRoute.accountId
|
|
1586
|
+
}));
|
|
1587
|
+
if (isDispatchOperationAborted()) return;
|
|
1588
|
+
if (shouldRouteToOriginating) await sendPayloadAsync(normalizedPayload, context?.abortSignal, false, "block");
|
|
1589
|
+
else {
|
|
1590
|
+
markInboundDedupeReplayUnsafe();
|
|
1591
|
+
if (dispatcher.sendBlockReply(normalizedPayload)) hasPendingDirectBlockReplyDelivery = true;
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
return run();
|
|
1595
|
+
}
|
|
1596
|
+
}, replyConfig)));
|
|
1597
|
+
if ((await ensureDispatchReplyOperation("dispatch")).status === "busy") return finishReplyOperationBusyDispatch({ recordAgentDispatchCompleted: true });
|
|
1598
|
+
if (ctx.AcpDispatchTailAfterReset === true) {
|
|
1599
|
+
ctx.AcpDispatchTailAfterReset = false;
|
|
1600
|
+
if (hookRunner?.hasHooks("reply_dispatch")) {
|
|
1601
|
+
const tailDispatchResult = await runWithDispatchAbortSignal(getDispatchAbortSignal(), () => hookRunner.runReplyDispatch(createReplyDispatchEvent({
|
|
1602
|
+
ctx,
|
|
1603
|
+
runId: params.replyOptions?.runId,
|
|
1604
|
+
sessionKey: acpDispatchSessionKey,
|
|
1605
|
+
images: params.replyOptions?.images,
|
|
1606
|
+
inboundAudio,
|
|
1607
|
+
sessionTtsAuto,
|
|
1608
|
+
ttsChannel: deliveryChannel,
|
|
1609
|
+
suppressUserDelivery: suppressHookUserDelivery,
|
|
1610
|
+
suppressReplyLifecycle: suppressHookReplyLifecycle,
|
|
1611
|
+
sourceReplyDeliveryMode,
|
|
1612
|
+
shouldRouteToOriginating,
|
|
1613
|
+
originatingChannel: routeReplyChannel,
|
|
1614
|
+
originatingTo: routeReplyTo,
|
|
1615
|
+
shouldSendToolSummaries,
|
|
1616
|
+
sendPolicy,
|
|
1617
|
+
isTailDispatch: true
|
|
1618
|
+
}), {
|
|
1619
|
+
cfg,
|
|
1620
|
+
dispatcher: dispatchHookDispatcher,
|
|
1621
|
+
abortSignal: getPreDispatchAbortSignal() ?? params.replyOptions?.abortSignal,
|
|
1622
|
+
onReplyStart: params.replyOptions?.onReplyStart,
|
|
1623
|
+
recordProcessed,
|
|
1624
|
+
markIdle
|
|
1625
|
+
}));
|
|
1626
|
+
if (tailDispatchResult?.handled) {
|
|
1627
|
+
recordAgentDispatchCompleted("completed");
|
|
1628
|
+
completeDispatchReplyOperation();
|
|
1629
|
+
return attachSourceReplyDeliveryMode({
|
|
1630
|
+
queuedFinal: tailDispatchResult.queuedFinal,
|
|
1631
|
+
counts: tailDispatchResult.counts
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
const replies = replyResult ? Array.isArray(replyResult) ? replyResult : [replyResult] : [];
|
|
1637
|
+
const beforeAgentRunBlocked = replies.some((reply) => getReplyPayloadMetadata(reply)?.beforeAgentRunBlocked === true);
|
|
1638
|
+
let queuedFinal = false;
|
|
1639
|
+
let routedFinalCount = 0;
|
|
1640
|
+
let attemptedFinalDelivery = false;
|
|
1641
|
+
let finalDeliveryFailed = false;
|
|
1642
|
+
const explicitCommandTurnCtx = isExplicitSourceReplyCommand(ctx, cfg);
|
|
1643
|
+
const shouldDeliverDespiteSourceReplySuppression = (reply) => suppressAutomaticSourceDelivery && !sendPolicyDenied && getReplyPayloadMetadata(reply)?.deliverDespiteSourceReplySuppression === true && (ctx.InboundEventKind !== "room_event" || explicitCommandTurnCtx);
|
|
1644
|
+
for (const reply of replies) {
|
|
1645
|
+
throwIfDispatchOperationAborted();
|
|
1646
|
+
if (reply.isReasoning === true) continue;
|
|
1647
|
+
if (suppressDelivery && !shouldDeliverDespiteSourceReplySuppression(reply)) {
|
|
1648
|
+
if (hasOutboundReplyContent(reply, { trimText: true })) logVerbose([
|
|
1649
|
+
`dispatch-from-config: final reply suppressed by ${deliverySuppressionReason || "source delivery policy"}`,
|
|
1650
|
+
`(session=${acpDispatchSessionKey ?? sessionKey ?? "unknown"}`,
|
|
1651
|
+
`provider=${ctx.Provider ?? "unknown"}`,
|
|
1652
|
+
`surface=${ctx.Surface ?? "unknown"}`,
|
|
1653
|
+
`chatType=${chatType ?? "unknown"}`,
|
|
1654
|
+
`inboundEventKind=${ctx.InboundEventKind ?? "unknown"}`,
|
|
1655
|
+
`message=${ctx.MessageSidFull ?? ctx.MessageSid ?? "unknown"}`,
|
|
1656
|
+
`${formatSuppressedReplyPayloadForLog(reply)})`
|
|
1657
|
+
].join(" "));
|
|
1658
|
+
continue;
|
|
1659
|
+
}
|
|
1660
|
+
attemptedFinalDelivery = true;
|
|
1661
|
+
const finalReply = await sendFinalPayload(reply);
|
|
1662
|
+
queuedFinal = finalReply.queuedFinal || queuedFinal;
|
|
1663
|
+
routedFinalCount += finalReply.routedFinalCount;
|
|
1664
|
+
if (!finalReply.queuedFinal && finalReply.routedFinalCount === 0) finalDeliveryFailed = true;
|
|
1665
|
+
}
|
|
1666
|
+
if (attemptedFinalDelivery && !finalDeliveryFailed) {
|
|
1667
|
+
throwIfDispatchOperationAborted();
|
|
1668
|
+
await clearPendingFinalDeliveryAfterSuccess({
|
|
1669
|
+
storePath: sessionStoreEntry.storePath,
|
|
1670
|
+
sessionKey: sessionStoreEntry.sessionKey ?? sessionKey
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
if (!suppressDelivery) {
|
|
1674
|
+
if (resolveConfiguredTtsMode(cfg, {
|
|
1675
|
+
agentId: sessionAgentId,
|
|
1676
|
+
channelId: deliveryChannel,
|
|
1677
|
+
accountId: replyRoute.accountId
|
|
1678
|
+
}) === "final" && replies.length === 0 && blockCount > 0 && accumulatedBlockTtsText.trim()) try {
|
|
1679
|
+
await waitForPendingDirectBlockReplyDelivery(getDispatchAbortSignal());
|
|
1680
|
+
throwIfDispatchOperationAborted();
|
|
1681
|
+
const ttsSyntheticReply = await maybeApplyTtsToReplyPayload({
|
|
1682
|
+
payload: { text: accumulatedBlockTtsText },
|
|
1683
|
+
cfg,
|
|
1684
|
+
channel: deliveryChannel,
|
|
1685
|
+
kind: "final",
|
|
1686
|
+
inboundAudio,
|
|
1687
|
+
ttsAuto: sessionTtsAuto,
|
|
1688
|
+
agentId: sessionAgentId,
|
|
1689
|
+
accountId: replyRoute.accountId
|
|
1690
|
+
});
|
|
1691
|
+
throwIfDispatchOperationAborted();
|
|
1692
|
+
if (ttsSyntheticReply.mediaUrl) {
|
|
1693
|
+
const normalizedTtsOnlyPayload = await normalizeReplyMediaPayload(markReplyPayloadAsTtsSupplement({
|
|
1694
|
+
mediaUrl: ttsSyntheticReply.mediaUrl,
|
|
1695
|
+
audioAsVoice: ttsSyntheticReply.audioAsVoice,
|
|
1696
|
+
spokenText: accumulatedBlockTtsText,
|
|
1697
|
+
trustedLocalMedia: true
|
|
1698
|
+
}, accumulatedBlockTtsText, { visibleTextAlreadyDelivered: true }));
|
|
1699
|
+
throwIfDispatchOperationAborted();
|
|
1700
|
+
const result = await routeReplyToOriginating(normalizedTtsOnlyPayload, {
|
|
1701
|
+
abortSignal: getDispatchAbortSignal(),
|
|
1702
|
+
kind: "final"
|
|
1703
|
+
});
|
|
1704
|
+
if (result) {
|
|
1705
|
+
queuedFinal = result.ok || queuedFinal;
|
|
1706
|
+
if (isRoutedReplyDelivered(result)) routedFinalCount += 1;
|
|
1707
|
+
if (!result.ok) logVerbose(`dispatch-from-config: route-reply (tts-only) failed: ${result.error ?? "unknown error"}`);
|
|
1708
|
+
} else {
|
|
1709
|
+
throwIfDispatchOperationAborted();
|
|
1710
|
+
markInboundDedupeReplayUnsafe();
|
|
1711
|
+
queuedFinal = dispatcher.sendFinalReply(normalizedTtsOnlyPayload) || queuedFinal;
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
} catch (err) {
|
|
1715
|
+
if (isDispatchReplyOperationAbortedError(err)) throw err;
|
|
1716
|
+
logVerbose(`dispatch-from-config: accumulated block TTS failed: ${formatErrorMessage(err)}`);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
await waitForPendingDirectBlockReplyDelivery(getDispatchAbortSignal());
|
|
1720
|
+
const counts = dispatcher.getQueuedCounts();
|
|
1721
|
+
counts.final += routedFinalCount;
|
|
1722
|
+
commitInboundDedupeIfClaimed();
|
|
1723
|
+
recordAgentDispatchCompleted("completed");
|
|
1724
|
+
recordProcessed("completed", pluginFallbackReason ? { reason: pluginFallbackReason } : void 0);
|
|
1725
|
+
markIdle("message_completed");
|
|
1726
|
+
completeDispatchReplyOperation();
|
|
1727
|
+
return attachSourceReplyDeliveryMode({
|
|
1728
|
+
queuedFinal,
|
|
1729
|
+
counts,
|
|
1730
|
+
...beforeAgentRunBlocked ? { beforeAgentRunBlocked } : {}
|
|
1731
|
+
});
|
|
1732
|
+
} catch (err) {
|
|
1733
|
+
if (isDispatchReplyOperationAbortedError(err)) return finishReplyOperationAbortedDispatch();
|
|
1734
|
+
if (inboundDedupeClaim.status === "claimed") if (inboundDedupeReplayUnsafe) commitInboundDedupe(inboundDedupeClaim.key);
|
|
1735
|
+
else releaseInboundDedupe(inboundDedupeClaim.key);
|
|
1736
|
+
recordAgentDispatchCompleted("error", { error: String(err) });
|
|
1737
|
+
recordProcessed("error", { error: String(err) });
|
|
1738
|
+
markIdle("message_error");
|
|
1739
|
+
failDispatchReplyOperation(err);
|
|
1740
|
+
throw err;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
//#endregion
|
|
1744
|
+
//#region src/auto-reply/dispatch.ts
|
|
1745
|
+
const foregroundReplyFenceByKey = /* @__PURE__ */ new Map();
|
|
1746
|
+
const replyPayloadSendingDispatchers = /* @__PURE__ */ new WeakSet();
|
|
1747
|
+
function normalizeForegroundReplyFencePart(value) {
|
|
1748
|
+
if (typeof value !== "string") return;
|
|
1749
|
+
const trimmed = value.trim();
|
|
1750
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
1751
|
+
}
|
|
1752
|
+
function resolveForegroundReplyFenceKey(finalized) {
|
|
1753
|
+
const sessionKey = normalizeForegroundReplyFencePart(finalized.SessionKey);
|
|
1754
|
+
const channel = normalizeForegroundReplyFencePart(finalized.OriginatingChannel) ?? normalizeForegroundReplyFencePart(finalized.Surface) ?? normalizeForegroundReplyFencePart(finalized.Provider);
|
|
1755
|
+
const target = normalizeForegroundReplyFencePart(finalized.OriginatingTo) ?? normalizeForegroundReplyFencePart(finalized.NativeChannelId) ?? normalizeForegroundReplyFencePart(finalized.From) ?? normalizeForegroundReplyFencePart(finalized.To);
|
|
1756
|
+
if (!sessionKey || !channel || !target) return;
|
|
1757
|
+
return JSON.stringify([
|
|
1758
|
+
"foreground",
|
|
1759
|
+
channel,
|
|
1760
|
+
normalizeForegroundReplyFencePart(finalized.AccountId) ?? "default",
|
|
1761
|
+
sessionKey,
|
|
1762
|
+
normalizeChatType(finalized.ChatType) ?? "unknown",
|
|
1763
|
+
target
|
|
1764
|
+
]);
|
|
1765
|
+
}
|
|
1766
|
+
function beginForegroundReplyFence(finalized) {
|
|
1767
|
+
const key = resolveForegroundReplyFenceKey(finalized);
|
|
1768
|
+
if (!key) return;
|
|
1769
|
+
const state = foregroundReplyFenceByKey.get(key) ?? {
|
|
1770
|
+
generation: 0,
|
|
1771
|
+
visibleDeliveryGeneration: 0,
|
|
1772
|
+
activeDispatches: 0,
|
|
1773
|
+
activeGenerations: /* @__PURE__ */ new Map(),
|
|
1774
|
+
waiters: /* @__PURE__ */ new Set()
|
|
1775
|
+
};
|
|
1776
|
+
state.generation += 1;
|
|
1777
|
+
state.activeDispatches += 1;
|
|
1778
|
+
state.activeGenerations.set(state.generation, (state.activeGenerations.get(state.generation) ?? 0) + 1);
|
|
1779
|
+
foregroundReplyFenceByKey.set(key, state);
|
|
1780
|
+
return {
|
|
1781
|
+
key,
|
|
1782
|
+
generation: state.generation
|
|
1783
|
+
};
|
|
1784
|
+
}
|
|
1785
|
+
function notifyForegroundReplyFenceWaiters(state) {
|
|
1786
|
+
const waiters = [...state.waiters];
|
|
1787
|
+
state.waiters.clear();
|
|
1788
|
+
for (const resolve of waiters) resolve();
|
|
1789
|
+
}
|
|
1790
|
+
function hasNewerActiveForegroundReplyFenceGeneration(state, generation) {
|
|
1791
|
+
for (const [activeGeneration, count] of state.activeGenerations) if (activeGeneration > generation && count > 0) return true;
|
|
1792
|
+
return false;
|
|
1793
|
+
}
|
|
1794
|
+
async function shouldCancelForegroundReplyDelivery(snapshot) {
|
|
1795
|
+
if (!snapshot) return false;
|
|
1796
|
+
while (true) {
|
|
1797
|
+
const state = foregroundReplyFenceByKey.get(snapshot.key);
|
|
1798
|
+
if (!state) return false;
|
|
1799
|
+
if (state.visibleDeliveryGeneration > snapshot.generation) return true;
|
|
1800
|
+
if (!hasNewerActiveForegroundReplyFenceGeneration(state, snapshot.generation)) return false;
|
|
1801
|
+
await new Promise((resolve) => {
|
|
1802
|
+
state.waiters.add(resolve);
|
|
1803
|
+
});
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
function markForegroundReplyFenceVisibleDelivery(snapshot, payload, deliveryResult) {
|
|
1807
|
+
if (!snapshot || !hasOutboundReplyContent(payload, { trimText: true })) return;
|
|
1808
|
+
if (isExplicitlyNonVisibleDelivery(deliveryResult)) return;
|
|
1809
|
+
markForegroundReplyFenceVisibleDeliveryGeneration(snapshot);
|
|
1810
|
+
}
|
|
1811
|
+
function markForegroundReplyFenceVisibleDeliveryGeneration(snapshot) {
|
|
1812
|
+
if (!snapshot) return;
|
|
1813
|
+
const state = foregroundReplyFenceByKey.get(snapshot.key);
|
|
1814
|
+
if (!state) return;
|
|
1815
|
+
state.visibleDeliveryGeneration = Math.max(state.visibleDeliveryGeneration, snapshot.generation);
|
|
1816
|
+
notifyForegroundReplyFenceWaiters(state);
|
|
1817
|
+
}
|
|
1818
|
+
function isExplicitlyNonVisibleDelivery(deliveryResult) {
|
|
1819
|
+
return typeof deliveryResult === "object" && deliveryResult !== null && !Array.isArray(deliveryResult) && "visibleReplySent" in deliveryResult && deliveryResult.visibleReplySent === false;
|
|
1820
|
+
}
|
|
1821
|
+
function isExplicitlyVisibleDelivery(deliveryResult) {
|
|
1822
|
+
return typeof deliveryResult === "object" && deliveryResult !== null && !Array.isArray(deliveryResult) && deliveryResult.visibleReplySent === true;
|
|
1823
|
+
}
|
|
1824
|
+
function isVisiblePartialDeliveryError(error) {
|
|
1825
|
+
if (isOutboundDeliveryError(error)) return error.sentBeforeError;
|
|
1826
|
+
return typeof error === "object" && error !== null && !Array.isArray(error) && (error.visibleReplySent === true || error.sentBeforeError === true);
|
|
1827
|
+
}
|
|
1828
|
+
async function runForegroundReplyFenceFreshSettledDelivery(snapshot, onFreshSettledDelivery) {
|
|
1829
|
+
if (!onFreshSettledDelivery) return;
|
|
1830
|
+
if (await shouldCancelForegroundReplyDelivery(snapshot)) return;
|
|
1831
|
+
try {
|
|
1832
|
+
if (isExplicitlyVisibleDelivery(await onFreshSettledDelivery())) markForegroundReplyFenceVisibleDeliveryGeneration(snapshot);
|
|
1833
|
+
} catch (err) {
|
|
1834
|
+
if (isVisiblePartialDeliveryError(err)) markForegroundReplyFenceVisibleDeliveryGeneration(snapshot);
|
|
1835
|
+
throw err;
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
function endForegroundReplyFence(snapshot) {
|
|
1839
|
+
const state = foregroundReplyFenceByKey.get(snapshot.key);
|
|
1840
|
+
if (!state) return;
|
|
1841
|
+
const activeGenerationCount = state.activeGenerations.get(snapshot.generation) ?? 0;
|
|
1842
|
+
if (activeGenerationCount <= 1) state.activeGenerations.delete(snapshot.generation);
|
|
1843
|
+
else state.activeGenerations.set(snapshot.generation, activeGenerationCount - 1);
|
|
1844
|
+
state.activeDispatches -= 1;
|
|
1845
|
+
notifyForegroundReplyFenceWaiters(state);
|
|
1846
|
+
if (state.activeDispatches <= 0) foregroundReplyFenceByKey.delete(snapshot.key);
|
|
1847
|
+
}
|
|
1848
|
+
function resolveDispatcherSilentReplyContext(ctx, cfg) {
|
|
1849
|
+
const finalized = finalizeInboundContext(ctx);
|
|
1850
|
+
const commandTargetSessionKey = resolveCommandTurnTargetSessionKey(finalized);
|
|
1851
|
+
const policySessionKey = commandTargetSessionKey ?? finalized.SessionKey;
|
|
1852
|
+
const chatType = normalizeChatType(finalized.ChatType);
|
|
1853
|
+
const conversationType = commandTargetSessionKey && commandTargetSessionKey !== finalized.SessionKey ? void 0 : chatType === "direct" ? "direct" : chatType === "group" || chatType === "channel" ? "group" : void 0;
|
|
1854
|
+
return {
|
|
1855
|
+
cfg,
|
|
1856
|
+
sessionKey: policySessionKey,
|
|
1857
|
+
surface: finalized.Surface ?? finalized.Provider,
|
|
1858
|
+
conversationType
|
|
1859
|
+
};
|
|
1860
|
+
}
|
|
1861
|
+
function resolveInboundReplyHookTarget(finalized, hookCtx) {
|
|
1862
|
+
if (typeof finalized.OriginatingTo === "string" && finalized.OriginatingTo.trim()) return finalized.OriginatingTo;
|
|
1863
|
+
if (hookCtx.isGroup) return hookCtx.conversationId ?? hookCtx.to ?? hookCtx.from;
|
|
1864
|
+
return hookCtx.from || hookCtx.conversationId || hookCtx.to || "";
|
|
1865
|
+
}
|
|
1866
|
+
function buildMessageSendingBeforeDeliver(ctx) {
|
|
1867
|
+
const hookRunner = getGlobalHookRunner();
|
|
1868
|
+
if (!hookRunner?.hasHooks("message_sending")) return;
|
|
1869
|
+
const finalized = finalizeInboundContext(ctx);
|
|
1870
|
+
const hookCtx = deriveInboundMessageHookContext(finalized);
|
|
1871
|
+
const replyTarget = resolveInboundReplyHookTarget(finalized, hookCtx);
|
|
1872
|
+
return async (payload) => {
|
|
1873
|
+
if (!payload.text) return payload;
|
|
1874
|
+
const result = await hookRunner.runMessageSending({
|
|
1875
|
+
content: payload.text,
|
|
1876
|
+
to: replyTarget
|
|
1877
|
+
}, toPluginMessageContext(hookCtx));
|
|
1878
|
+
if (result?.cancel) return null;
|
|
1879
|
+
if (result?.content != null) return {
|
|
1880
|
+
...payload,
|
|
1881
|
+
text: result.content
|
|
1882
|
+
};
|
|
1883
|
+
return payload;
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
function buildReplyPayloadSendingBeforeDeliver(ctx, opts) {
|
|
1887
|
+
const finalized = finalizeInboundContext(ctx);
|
|
1888
|
+
const hookCtx = deriveInboundMessageHookContext(finalized);
|
|
1889
|
+
return async (payload, info) => {
|
|
1890
|
+
const hookedPayload = await runReplyPayloadSendingHook({
|
|
1891
|
+
payload,
|
|
1892
|
+
kind: info.kind,
|
|
1893
|
+
channel: finalized.Surface ?? finalized.Provider,
|
|
1894
|
+
sessionKey: finalized.SessionKey,
|
|
1895
|
+
runId: opts?.runId,
|
|
1896
|
+
context: {
|
|
1897
|
+
...toPluginMessageContext(hookCtx),
|
|
1898
|
+
runId: opts?.runId
|
|
1899
|
+
}
|
|
1900
|
+
});
|
|
1901
|
+
return hookedPayload && hasOutboundReplyContent(hookedPayload) ? hookedPayload : null;
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
function installReplyPayloadSendingBeforeDeliver(dispatcher, ctx, opts) {
|
|
1905
|
+
if (replyPayloadSendingDispatchers.has(dispatcher)) return;
|
|
1906
|
+
const beforeDeliver = buildReplyPayloadSendingBeforeDeliver(ctx, opts);
|
|
1907
|
+
if (!beforeDeliver || !dispatcher.appendBeforeDeliver) return;
|
|
1908
|
+
dispatcher.appendBeforeDeliver(beforeDeliver);
|
|
1909
|
+
replyPayloadSendingDispatchers.add(dispatcher);
|
|
1910
|
+
}
|
|
1911
|
+
function markReplyPayloadSendingBeforeDeliverInstalled(dispatcher, beforeDeliver) {
|
|
1912
|
+
if (beforeDeliver) replyPayloadSendingDispatchers.add(dispatcher);
|
|
1913
|
+
}
|
|
1914
|
+
function combineBeforeDeliverHooks(...hooks) {
|
|
1915
|
+
const activeHooks = hooks.filter((hook) => Boolean(hook));
|
|
1916
|
+
if (activeHooks.length === 0) return;
|
|
1917
|
+
return async (payload, info) => {
|
|
1918
|
+
let current = payload;
|
|
1919
|
+
for (const hook of activeHooks) {
|
|
1920
|
+
if (!current) return null;
|
|
1921
|
+
current = await hook(current, info);
|
|
1922
|
+
}
|
|
1923
|
+
return current;
|
|
1924
|
+
};
|
|
1925
|
+
}
|
|
1926
|
+
function buildDispatchTimelineAttributes(ctx) {
|
|
1927
|
+
const commandTurn = resolveCommandTurnContext(ctx);
|
|
1928
|
+
return {
|
|
1929
|
+
surface: typeof ctx.Surface === "string" ? ctx.Surface : typeof ctx.Provider === "string" ? ctx.Provider : "unknown",
|
|
1930
|
+
hasSessionKey: typeof ctx.SessionKey === "string" || typeof ctx.CommandTargetSessionKey === "string",
|
|
1931
|
+
commandSource: commandTurn.source
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
function finalizeDispatchResult(result, dispatcher) {
|
|
1935
|
+
const cancelledCounts = dispatcher.getCancelledCounts?.();
|
|
1936
|
+
const failedCounts = dispatcher.getFailedCounts?.();
|
|
1937
|
+
if (!cancelledCounts && !failedCounts) return result;
|
|
1938
|
+
const resultCounts = {
|
|
1939
|
+
tool: result.counts?.tool ?? 0,
|
|
1940
|
+
block: result.counts?.block ?? 0,
|
|
1941
|
+
final: result.counts?.final ?? 0
|
|
1942
|
+
};
|
|
1943
|
+
const counts = {
|
|
1944
|
+
tool: Math.max(0, resultCounts.tool - (cancelledCounts?.tool ?? 0) - (failedCounts?.tool ?? 0)),
|
|
1945
|
+
block: Math.max(0, resultCounts.block - (cancelledCounts?.block ?? 0) - (failedCounts?.block ?? 0)),
|
|
1946
|
+
final: Math.max(0, resultCounts.final - (cancelledCounts?.final ?? 0) - (failedCounts?.final ?? 0))
|
|
1947
|
+
};
|
|
1948
|
+
const hasFailedCounts = (failedCounts?.tool ?? 0) > 0 || (failedCounts?.block ?? 0) > 0 || (failedCounts?.final ?? 0) > 0;
|
|
1949
|
+
return {
|
|
1950
|
+
...result,
|
|
1951
|
+
queuedFinal: result.queuedFinal && counts.final > 0,
|
|
1952
|
+
counts,
|
|
1953
|
+
...hasFailedCounts ? { failedCounts } : {}
|
|
1954
|
+
};
|
|
1955
|
+
}
|
|
1956
|
+
async function dispatchInboundMessage(params) {
|
|
1957
|
+
const finalized = measureDiagnosticsTimelineSpanSync("auto_reply.finalize_context", () => finalizeInboundContext(params.ctx), {
|
|
1958
|
+
phase: "agent-turn",
|
|
1959
|
+
config: params.cfg,
|
|
1960
|
+
attributes: buildDispatchTimelineAttributes(params.ctx)
|
|
1961
|
+
});
|
|
1962
|
+
if (isDiagnosticsEnabled(params.cfg)) logMessageReceived({
|
|
1963
|
+
sessionKey: finalized.SessionKey,
|
|
1964
|
+
channel: finalized.Surface ?? finalized.Provider,
|
|
1965
|
+
chatId: finalized.To ?? finalized.From,
|
|
1966
|
+
messageId: finalized.MessageSid ?? finalized.MessageSidFirst ?? finalized.MessageSidLast,
|
|
1967
|
+
source: "dispatchInboundMessage"
|
|
1968
|
+
});
|
|
1969
|
+
installReplyPayloadSendingBeforeDeliver(params.dispatcher, finalized, { runId: params.replyOptions?.runId });
|
|
1970
|
+
return finalizeDispatchResult(await withReplyDispatcher({
|
|
1971
|
+
dispatcher: params.dispatcher,
|
|
1972
|
+
run: () => measureDiagnosticsTimelineSpan("auto_reply.dispatch_reply_from_config", () => dispatchReplyFromConfig({
|
|
1973
|
+
ctx: finalized,
|
|
1974
|
+
cfg: params.cfg,
|
|
1975
|
+
dispatcher: params.dispatcher,
|
|
1976
|
+
replyOptions: params.replyOptions,
|
|
1977
|
+
replyResolver: params.replyResolver
|
|
1978
|
+
}), {
|
|
1979
|
+
phase: "agent-turn",
|
|
1980
|
+
config: params.cfg,
|
|
1981
|
+
attributes: buildDispatchTimelineAttributes(finalized)
|
|
1982
|
+
})
|
|
1983
|
+
}), params.dispatcher);
|
|
1984
|
+
}
|
|
1985
|
+
async function dispatchInboundMessageWithBufferedDispatcher(params) {
|
|
1986
|
+
const finalized = finalizeInboundContext(params.ctx);
|
|
1987
|
+
const foregroundReplyFence = beginForegroundReplyFence(finalized);
|
|
1988
|
+
const silentReplyContext = resolveDispatcherSilentReplyContext(finalized, params.cfg);
|
|
1989
|
+
const replyPayloadBeforeDeliver = buildReplyPayloadSendingBeforeDeliver(finalized, { runId: params.replyOptions?.runId });
|
|
1990
|
+
const globalBeforeDeliver = combineBeforeDeliverHooks(replyPayloadBeforeDeliver, buildMessageSendingBeforeDeliver(finalized));
|
|
1991
|
+
const configuredBeforeDeliver = params.dispatcherOptions.beforeDeliver ? combineBeforeDeliverHooks(params.dispatcherOptions.beforeDeliver, replyPayloadBeforeDeliver) : globalBeforeDeliver;
|
|
1992
|
+
const beforeDeliver = foregroundReplyFence || configuredBeforeDeliver ? async (payload, info) => {
|
|
1993
|
+
if (await shouldCancelForegroundReplyDelivery(foregroundReplyFence)) return null;
|
|
1994
|
+
const deliverPayload = configuredBeforeDeliver ? await configuredBeforeDeliver(payload, info) : payload;
|
|
1995
|
+
if (!deliverPayload || await shouldCancelForegroundReplyDelivery(foregroundReplyFence)) return null;
|
|
1996
|
+
return deliverPayload;
|
|
1997
|
+
} : void 0;
|
|
1998
|
+
const deliver = async (payload, info) => {
|
|
1999
|
+
try {
|
|
2000
|
+
const result = await params.dispatcherOptions.deliver(payload, info);
|
|
2001
|
+
markForegroundReplyFenceVisibleDelivery(foregroundReplyFence, payload, result);
|
|
2002
|
+
return result;
|
|
2003
|
+
} catch (err) {
|
|
2004
|
+
if (isVisiblePartialDeliveryError(err)) markForegroundReplyFenceVisibleDelivery(foregroundReplyFence, payload, { visibleReplySent: true });
|
|
2005
|
+
throw err;
|
|
2006
|
+
}
|
|
2007
|
+
};
|
|
2008
|
+
const { dispatcher, replyOptions, markDispatchIdle, markRunComplete } = createReplyDispatcherWithTyping({
|
|
2009
|
+
...params.dispatcherOptions,
|
|
2010
|
+
deliver,
|
|
2011
|
+
beforeDeliver,
|
|
2012
|
+
silentReplyContext: params.dispatcherOptions.silentReplyContext ?? silentReplyContext
|
|
2013
|
+
});
|
|
2014
|
+
markReplyPayloadSendingBeforeDeliverInstalled(dispatcher, replyPayloadBeforeDeliver);
|
|
2015
|
+
try {
|
|
2016
|
+
return await dispatchInboundMessage({
|
|
2017
|
+
ctx: finalized,
|
|
2018
|
+
cfg: params.cfg,
|
|
2019
|
+
dispatcher,
|
|
2020
|
+
replyResolver: params.replyResolver,
|
|
2021
|
+
replyOptions: {
|
|
2022
|
+
...params.replyOptions,
|
|
2023
|
+
...replyOptions
|
|
2024
|
+
}
|
|
2025
|
+
});
|
|
2026
|
+
} finally {
|
|
2027
|
+
try {
|
|
2028
|
+
if (isExplicitlyVisibleDelivery(await params.dispatcherOptions.onSettled?.())) markForegroundReplyFenceVisibleDeliveryGeneration(foregroundReplyFence);
|
|
2029
|
+
await runForegroundReplyFenceFreshSettledDelivery(foregroundReplyFence, params.dispatcherOptions.onFreshSettledDelivery);
|
|
2030
|
+
} finally {
|
|
2031
|
+
if (foregroundReplyFence) endForegroundReplyFence(foregroundReplyFence);
|
|
2032
|
+
markRunComplete();
|
|
2033
|
+
markDispatchIdle();
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
async function dispatchInboundMessageWithDispatcher(params) {
|
|
2038
|
+
const silentReplyContext = resolveDispatcherSilentReplyContext(params.ctx, params.cfg);
|
|
2039
|
+
const replyPayloadBeforeDeliver = buildReplyPayloadSendingBeforeDeliver(params.ctx, { runId: params.replyOptions?.runId });
|
|
2040
|
+
const globalBeforeDeliver = combineBeforeDeliverHooks(replyPayloadBeforeDeliver, buildMessageSendingBeforeDeliver(params.ctx));
|
|
2041
|
+
const composedBeforeDeliver = params.dispatcherOptions.beforeDeliver ? combineBeforeDeliverHooks(params.dispatcherOptions.beforeDeliver, replyPayloadBeforeDeliver) : globalBeforeDeliver;
|
|
2042
|
+
const dispatcher = createReplyDispatcher({
|
|
2043
|
+
...params.dispatcherOptions,
|
|
2044
|
+
beforeDeliver: composedBeforeDeliver,
|
|
2045
|
+
silentReplyContext: params.dispatcherOptions.silentReplyContext ?? silentReplyContext
|
|
2046
|
+
});
|
|
2047
|
+
markReplyPayloadSendingBeforeDeliverInstalled(dispatcher, replyPayloadBeforeDeliver);
|
|
2048
|
+
return await dispatchInboundMessage({
|
|
2049
|
+
ctx: params.ctx,
|
|
2050
|
+
cfg: params.cfg,
|
|
2051
|
+
dispatcher,
|
|
2052
|
+
replyResolver: params.replyResolver,
|
|
2053
|
+
replyOptions: params.replyOptions
|
|
2054
|
+
});
|
|
2055
|
+
}
|
|
2056
|
+
//#endregion
|
|
2057
|
+
export { settleReplyDispatcher as a, dispatchReplyFromConfig as i, dispatchInboundMessageWithBufferedDispatcher as n, withReplyDispatcher as o, dispatchInboundMessageWithDispatcher as r, dispatchInboundMessage as t };
|