fengming 0.3.4 → 0.3.5
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 +3 -2
- package/dist/abort-CjCDVBbH.js +277 -0
- package/dist/abort.runtime-DxJ8129J.js +2 -0
- package/dist/abort.runtime.js +1 -1
- package/dist/accounts-Cyn0sm_v.js +423 -0
- package/dist/accounts-DzcLKcN5.js +2 -0
- package/dist/acp/control-plane/manager.js +1 -1
- package/dist/acp-spawn-4lfz_3K9.js +1286 -0
- package/dist/acp-spawn-BCUjuO6L.js +2 -0
- package/dist/acp-stateful-target-driver-Bv99uwEA.js +89 -0
- package/dist/action-info-CP-p6RHS.js +75 -0
- package/dist/active-runtime-registry-DjKe53a5.js +62 -0
- package/dist/active-tool-schema-warnings-p7CqUnu1.js +105 -0
- package/dist/active-tool-schema-warnings-pGI92yka.js +2 -0
- package/dist/agent-B77yluip.js +1825 -0
- package/dist/agent-BooUvZnR.js +2 -0
- package/dist/agent-bundle-lsp-runtime-3ieSgTgo.js +389 -0
- package/dist/agent-bundle-lsp-runtime-CkJ0XJK7.js +2 -0
- package/dist/agent-bundle-mcp-materialize-BH-esGZL.js +124 -0
- package/dist/agent-bundle-mcp-tools-DkixTTnL.js +3 -0
- package/dist/agent-command-BJKcnQy6.js +1435 -0
- package/dist/agent-delivery-CEfe_Zzt.js +117 -0
- package/dist/agent-harness-runtime-R_Ae6o9C.js +207 -0
- package/dist/agent-kWSaRcQt.js +3 -0
- package/dist/agent-model-discovery-C49swEgd.js +238 -0
- package/dist/agent-model-discovery-DZbixJQs.js +3 -0
- package/dist/agent-runner-utils-BChpi9Ec.js +267 -0
- package/dist/agent-runner.runtime-3LOdt215.js +3784 -0
- package/dist/agent-runner.runtime.js +1 -1
- package/dist/agent-runtime-3jsv8b7Y.js +199 -0
- package/dist/agent-runtime-label-uoFI4ovH.js +30 -0
- package/dist/agent-runtime-metadata-BhFt6kLt.js +53 -0
- package/dist/agent-tool-result-middleware-loader-BxYJNC1i.js +55 -0
- package/dist/agent-tools-COLEG7aL.js +2506 -0
- package/dist/agent-tools.before-tool-call--rMZI5Rd.js +1274 -0
- package/dist/agent-tools.before-tool-call-CbX2sfP4.js +2 -0
- package/dist/agent-via-gateway-DfKij3De.js +486 -0
- package/dist/agent-wait-dedupe-BAUSJotw.js +180 -0
- package/dist/agents/agent-bundle-mcp-materialize.js +1 -1
- package/dist/agents/auth-profiles.runtime.js +1 -1
- package/dist/agents/compaction-planning.worker.js +1 -1
- package/dist/agents/embedded-agent-runner/effective-tool-policy.js +1 -1
- package/dist/agents/embedded-agent-runner/tool-split.js +1 -1
- package/dist/agents/model-catalog.runtime.js +1 -1
- package/dist/agents/model-provider-auth.worker.js +3 -3
- package/dist/agents/models-config.runtime.js +1 -1
- package/dist/agents-CZSNDJWD.js +632 -0
- package/dist/agents.command-shared-DgbjfH23.js +16 -0
- package/dist/agents.commands.add-DknGM1oz.js +304 -0
- package/dist/agents.commands.bind-DDVI0yDe.js +265 -0
- package/dist/agents.commands.delete-Dv4RHEhc.js +128 -0
- package/dist/agents.commands.identity-BSZbc1QR.js +143 -0
- package/dist/agents.commands.list-CA0OTw59.js +235 -0
- package/dist/aliases-EY1GbfwT.js +97 -0
- package/dist/api-CY0oKcRz.js +3 -0
- package/dist/api-DgjY0gIl.js +6 -0
- package/dist/api-VyMyAYze.js +2 -0
- package/dist/api-key-rotation-DxPKIdmC.js +167 -0
- package/dist/app-registration-BBDxCbFo.js +194 -0
- package/dist/apply-DMYy7tc3.js +544 -0
- package/dist/apply-Dd0n97MD.js +2 -0
- package/dist/apply-bHIT1nMp.js +416 -0
- package/dist/apply-g8x7Z83S.js +510 -0
- package/dist/apply-nnbx9TaB.js +2 -0
- package/dist/approval-native-helpers-CjaYvOaZ.js +398 -0
- package/dist/artifacts-B55YR-uA.js +368 -0
- package/dist/assistant-hJaOgfKl.js +291 -0
- package/dist/attachment-normalize-COsastJx.js +213 -0
- package/dist/attempt-execution-fDWDWcWe.js +584 -0
- package/dist/attempt-execution.helpers-Cze5xPim.js +969 -0
- package/dist/attempt-execution.runtime-B1iCG6LN.js +3 -0
- package/dist/attempt-execution.runtime.js +1 -1
- package/dist/attempt.prompt-helpers-CkBYHBBo.js +543 -0
- package/dist/attempt.tool-run-context-DzfRK5pV.js +1240 -0
- package/dist/audio-preflight.runtime-rjWd9uyk.js +7 -0
- package/dist/audio-preflight.runtime.js +1 -1
- package/dist/audit-DgFtNg3U.js +1108 -0
- package/dist/audit-L8EC3WhV.js +477 -0
- package/dist/audit.nondeep.runtime-D0sQ6bO2.js +1416 -0
- package/dist/audit.nondeep.runtime.js +1 -1
- package/dist/audit.runtime-CiG82F31.js +7 -0
- package/dist/audit.runtime.js +1 -1
- package/dist/auth-CzPdsZVM.js +567 -0
- package/dist/auth-choice-BNzS9QBI.js +3 -0
- package/dist/auth-choice-Cwr5kgcD.js +110 -0
- package/dist/auth-choice-DW9qPpMS.js +400 -0
- package/dist/auth-choice.apply.api-providers-C68tOdqj.js +34 -0
- package/dist/auth-choice.apply.api-providers-DSRK0gYo.js +2 -0
- package/dist/auth-choice.plugin-providers.runtime-BJ9VyO1C.js +11 -0
- package/dist/auth-choice.plugin-providers.runtime.js +1 -1
- package/dist/auth-health-BanKwsTW.js +219 -0
- package/dist/auth-list-Dq8obVno.js +115 -0
- package/dist/auth-order-VXqoAroP.js +105 -0
- package/dist/auth-profiles-6VFEdgC-.js +73 -0
- package/dist/auth-profiles-a0M4JYYg.js +14 -0
- package/dist/backend-config-COaTdVnN.js +259 -0
- package/dist/bash-tools-BMAquSiM.js +3 -0
- package/dist/bash-tools-DLiUXfaS.js +3497 -0
- package/dist/binding-routing-Bwvdx_7S.js +113 -0
- package/dist/binding-targets-Z_d0mK_1.js +121 -0
- package/dist/bootstrap-files-CoCV_zqu.js +202 -0
- package/dist/bootstrap-files-_T3VoTrV.js +3 -0
- package/dist/bridge-server-BIaNurGa.js +113 -0
- package/dist/browser-cli-D4wL8NU9.js +230 -0
- package/dist/browser-cli-actions-input-z40PGiYI.js +522 -0
- package/dist/browser-cli-actions-observe-C4TeyNke.js +81 -0
- package/dist/browser-cli-debug-Dv0gH-c8.js +137 -0
- package/dist/browser-cli-inspect-BUXeITYc.js +117 -0
- package/dist/browser-cli-manage-qMb3Yw5Y.js +446 -0
- package/dist/browser-cli-resize-CZWnGwGz.js +32 -0
- package/dist/browser-cli-shared-BpinhvE3.js +69 -0
- package/dist/browser-cli-state-CBbKqqgP.js +371 -0
- package/dist/browser-cli-uI5GGX51.js +2 -0
- package/dist/browser-control-auth-CFPJXdN_.js +2 -0
- package/dist/browser-profiles-D4ni3t4J.js +2 -0
- package/dist/browser-runtime-Dm5D_PLf.js +389 -0
- package/dist/browser-tool.schema-Bek02ox5.js +132 -0
- package/dist/btw-command-DdrwvCK4.js +18 -0
- package/dist/build-DkEeJ9sO.js +261 -0
- package/dist/build-info.json +2 -2
- package/dist/bundled/boot-md/handler.js +2 -2
- package/dist/bundled/session-memory/handler.js +1 -1
- package/dist/bundled-channel-config-schema-BeowdkHi.d.ts +3168 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/capability-cli-DTRuKZJC.js +1809 -0
- package/dist/capability-provider-runtime-Cpp-Jq9g.js +346 -0
- package/dist/cdp.helpers-GfQkB-B5.js +637 -0
- package/dist/channel-BRehZ4Cg.js +2309 -0
- package/dist/channel-actions-hdQKe_se.js +46 -0
- package/dist/channel-bootstrap.runtime-BzjlNG_j.js +38 -0
- package/dist/channel-bootstrap.runtime-CmNNVl40.js +2 -0
- package/dist/channel-bootstrap.runtime.js +1 -1
- package/dist/channel-core-BLcWqSk-.js +5 -0
- package/dist/channel-inbound-pR1B7HTU.js +121 -0
- package/dist/channel-message-W0VurpjH.js +12 -0
- package/dist/channel-outbound-DO4HI6E_.js +436 -0
- package/dist/channel-plugin-resolution-CLA7S5_A.js +2 -0
- package/dist/channel-plugin-resolution-DzwVj01h.js +135 -0
- package/dist/channel-resolution-DOPyiG4k.js +46 -0
- package/dist/channel-selection-kwoWZDQ3.js +171 -0
- package/dist/channel-selection.runtime-LiDliif9.js +2 -0
- package/dist/channel-selection.runtime.js +1 -1
- package/dist/channel.runtime-DDt3PayH.js +697 -0
- package/dist/channel.runtime.js +1 -1
- package/dist/channels-CKJd4eUz.js +1004 -0
- package/dist/channels-cli-DLAPi8pX.js +331 -0
- package/dist/chat-6WsYrS9m.js +3 -0
- package/dist/chat-DpsCEXAx.js +2940 -0
- package/dist/chrome-BWHc9vYG.js +1517 -0
- package/dist/chrome-mcp-BGKgR8A_.js +2 -0
- package/dist/chrome-mcp-Bg5D5PDc.js +864 -0
- package/dist/claude-live-session-BLCZnv-A.js +2 -0
- package/dist/claude-live-session-CGnB64D6.js +1338 -0
- package/dist/clawbot-cli-ynXzgp8B.js +9 -0
- package/dist/cli/daemon-cli.js +3 -3
- package/dist/cli/gateway-lifecycle.runtime.js +4 -4
- package/dist/cli/run-main.js +12 -12
- package/dist/cli-B4Ttnj0P.js +2 -0
- package/dist/cli-BjVgdamH.js +2 -0
- package/dist/cli-CNqBrHLU.js +293 -0
- package/dist/cli-backends.runtime-DoxtCrow.js +7 -0
- package/dist/cli-backends.runtime.js +1 -1
- package/dist/cli-compaction-BCuLbs75.js +363 -0
- package/dist/cli-mthNIkji.js +141 -0
- package/dist/cli-registry-loader-B2sNTdgY.js +2 -0
- package/dist/cli-registry-loader-Dz9YFrjw.js +193 -0
- package/dist/cli-runner-C9t-9-Io.js +597 -0
- package/dist/cli-runner-D21qMGk7.js +2 -0
- package/dist/cli-runner.runtime-BNqbJFgu.js +3 -0
- package/dist/cli-runner.runtime-Dv50IEvH.js +4 -0
- package/dist/cli-runner.runtime.js +1 -1
- package/dist/cli-session-jBtClYfT.js +119 -0
- package/dist/cli-startup-metadata.json +9 -9
- package/dist/cli.runtime-CGBzSGAG.js +1276 -0
- package/dist/cli.runtime.js +1 -1
- package/dist/codex-native-web-search-B3C-srtm.js +20 -0
- package/dist/codex-native-web-search-B7xh2Xcb.js +4 -0
- package/dist/codex-native-web-search-core-CrwANQg5.js +106 -0
- package/dist/command-auth-Dz_pdczs.js +135 -0
- package/dist/command-config-resolution-XCA63Yv8.js +25 -0
- package/dist/command-config-resolution-xtKMDTG9.js +2 -0
- package/dist/command-config-resolution.runtime-xtKMDTG9.js +2 -0
- package/dist/command-config-resolution.runtime.js +1 -1
- package/dist/command-execution-startup-CasEqEXh.js +90 -0
- package/dist/command-primitives-runtime-DC9gtSI3.js +3 -0
- package/dist/command-registry-BQnMdca9.js +9 -0
- package/dist/command-registry-core-hx2t1jQP.js +114 -0
- package/dist/command-registry-rbKA-L_8.js +4 -0
- package/dist/command-secret-gateway-7oveYQCx.js +589 -0
- package/dist/command-secret-targets-B7M1Us_C.js +2 -0
- package/dist/command-status-builders-DrSoZhiI.js +147 -0
- package/dist/command-status.runtime-By0071-y.js +90 -0
- package/dist/command-status.runtime.js +1 -1
- package/dist/commands/status.summary.runtime.js +3 -3
- package/dist/commands-B1MnUj5-.js +161 -0
- package/dist/commands-compact.runtime-DELj3JaW.js +10 -0
- package/dist/commands-compact.runtime.js +1 -1
- package/dist/commands-core.runtime-Zw0grrkC.js +2 -0
- package/dist/commands-core.runtime.js +1 -1
- package/dist/commands-handlers.runtime-BCl_ZHJZ.js +6327 -0
- package/dist/commands-handlers.runtime.js +1 -1
- package/dist/commands-models-Uurm-0C3.js +448 -0
- package/dist/commands-registry-Bo1AeDcq.js +195 -0
- package/dist/commands-registry.runtime-C9DBHyhh.js +4 -0
- package/dist/commands-registry.runtime.js +1 -1
- package/dist/commands-status-BoAXH-wg.js +16 -0
- package/dist/commands-status-CNALMTN9.js +3 -0
- package/dist/commands-status.runtime-CNALMTN9.js +3 -0
- package/dist/commands-status.runtime.js +1 -1
- package/dist/commands-subagents-control.runtime-Dl4IuTzV.js +2 -0
- package/dist/commands-subagents-control.runtime.js +1 -1
- package/dist/commands-system-prompt-BPzpLmUp.js +2 -0
- package/dist/commands-system-prompt-DCOZSNh5.js +161 -0
- package/dist/commands.runtime-bfCLM0Sg.js +175 -0
- package/dist/commands.runtime.js +1 -1
- package/dist/commitments/runtime.js +1 -1
- package/dist/common-CoOYhmSg.js +286 -0
- package/dist/compact-yqaUOESq.js +1165 -0
- package/dist/compact.runtime-Y91AFZVE.js +12 -0
- package/dist/compact.runtime.js +1 -1
- package/dist/compaction-planning-DVnykwzd.js +202 -0
- package/dist/completion-cli-BJjq_g_B.js +393 -0
- package/dist/config-CsmSEaNn.js +374 -0
- package/dist/config-CtNXZ0iy.js +610 -0
- package/dist/config-cli-CNpIVdqp.js +1703 -0
- package/dist/config-mutation-B-SErGM0.js +5 -0
- package/dist/config-mutations-Bu3ahkX8.js +161 -0
- package/dist/config-utils-Bv0Nisds.js +141 -0
- package/dist/config-validation-DitvTYD8.js +33 -0
- package/dist/configure-CdjbRKTg.js +771 -0
- package/dist/configure-Cvi-5ml4.js +3 -0
- package/dist/configure.commands-BJii4733.js +1253 -0
- package/dist/configure.commands-tJzVFJ0o.js +2 -0
- package/dist/context-D1N9oPds.js +2 -0
- package/dist/context-XMtJ9b3v.js +248 -0
- package/dist/context-engine-host-compat-3QznbSaW.js +280 -0
- package/dist/context-engine-host-compat-DquSpnKD.js +2 -0
- package/dist/context-engine-lifecycle-Bqdhy9JU.js +627 -0
- package/dist/control-auth-CMW_9jmY.js +114 -0
- package/dist/control-service-D-r3k91q.js +40 -0
- package/dist/control-service-uIPYrp9F.js +3 -0
- package/dist/control-ui/assets/activity-DgMhyllD.js +124 -0
- package/dist/control-ui/assets/agents-CsRhxO2O.js +1030 -0
- package/dist/control-ui/assets/channels-Dq8bzpMg.js +120 -0
- package/dist/control-ui/assets/cron-Dk5bqYwg.js +1016 -0
- package/dist/control-ui/assets/debug-CNIwFEQO.js +97 -0
- package/dist/control-ui/assets/index-CV2NsPlu.js +7214 -0
- package/dist/control-ui/assets/instances-DLr0iEvT.js +57 -0
- package/dist/control-ui/assets/nodes-D3JEksjl.js +444 -0
- package/dist/control-ui/assets/sessions-nbXWGlHZ.js +425 -0
- package/dist/control-ui/assets/skills-tBOi8OBq.js +362 -0
- package/dist/control-ui/assets/workboard-ClTo7wmK.js +402 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/control-ui/sw.js +1 -1
- package/dist/control-ui-AkRMsk9S.js +750 -0
- package/dist/conversation-label-generator-DHtcgSBn.js +72 -0
- package/dist/conversation-runtime-BEgHW4ta.js +31 -0
- package/dist/core-Bslrvfnp.js +284 -0
- package/dist/core-api-BOlUb7G8.js +5 -0
- package/dist/core-api-CiBoGa2I.js +2 -0
- package/dist/crestodian/crestodian.js +1 -1
- package/dist/crestodian/rescue-message.js +1 -1
- package/dist/crestodian-mXnyuHx9.js +55 -0
- package/dist/cron-PbdpyFrD.js +453 -0
- package/dist/daemon-install-C-d4dFvn.js +66 -0
- package/dist/daemon-install-auth-profiles-store.runtime-CvE2EVVo.js +2 -0
- package/dist/daemon-install-auth-profiles-store.runtime.js +1 -1
- package/dist/dashboard-Ey5dnvMI.js +263 -0
- package/dist/defaults-CsRAv-qE.js +130 -0
- package/dist/defaults-DHZBSNHC.js +3 -0
- package/dist/defaults.constants-CR4S_tvw.js +76 -0
- package/dist/deliver-BkuuFBlm.js +1399 -0
- package/dist/deliver-P4upyes7.js +3 -0
- package/dist/deliver-runtime-CjnLI_nC.js +2 -0
- package/dist/delivery-outbound.runtime-fcJ-M8qj.js +7 -0
- package/dist/delivery-outbound.runtime.js +1 -1
- package/dist/delivery-queue-BqgHvNlY.js +863 -0
- package/dist/delivery-queue-CfsRscJb.js +2 -0
- package/dist/delivery-queue-runtime-D0PKG1Bv.js +16 -0
- package/dist/delivery-target.runtime-C5e8d0WH.js +45 -0
- package/dist/delivery-target.runtime.js +1 -1
- package/dist/delivery.runtime-2Ut8xM3P.js +470 -0
- package/dist/delivery.runtime.js +1 -1
- package/dist/detached-task-runtime-OOZBqRy-.js +86 -0
- package/dist/diagnostics-zf6WQ2h7.js +168 -0
- package/dist/dialogue-C8IOya-l.js +37 -0
- package/dist/direct-dm-wPF-KfNb.js +81 -0
- package/dist/directive-handling.defaults-C-1lmFYo.js +22 -0
- package/dist/directive-handling.fast-lane-DENPMtYI.js +70 -0
- package/dist/directive-handling.impl-C1p5t3qA.js +2 -0
- package/dist/directive-handling.impl-DOo2Sa7C.js +823 -0
- package/dist/directive-handling.model-selection-6gC-fr_g.js +122 -0
- package/dist/directive-handling.persist.runtime-CuhUd2kW.js +274 -0
- package/dist/directive-handling.persist.runtime.js +1 -1
- package/dist/directives-BIKSyN8C.js +319 -0
- package/dist/directory-cli-DZ0PU0Rv.js +239 -0
- package/dist/dispatch-DQLImAqt.js +2057 -0
- package/dist/dispatch-acp-DzyX7wsq.js +1102 -0
- package/dist/dispatch-acp-manager.runtime-CoAfs4O1.js +3 -0
- package/dist/dispatch-acp-manager.runtime.js +1 -1
- package/dist/dispatch-acp-media.runtime-7uUP_jr9.js +4 -0
- package/dist/dispatch-acp-media.runtime.js +1 -1
- package/dist/dispatch-acp-transcript.runtime-BUlmV_h0.js +40 -0
- package/dist/dispatch-acp-transcript.runtime.js +1 -1
- package/dist/dispatch-acp-tts.runtime-ChBnVkNt.js +3 -0
- package/dist/dispatch-acp-tts.runtime.js +1 -1
- package/dist/dispatch-acp.runtime-DAexFaBu.js +18 -0
- package/dist/dispatch-acp.runtime.js +1 -1
- package/dist/dispatcher-D3IQEbf9.js +106 -0
- package/dist/doctor-BSqEqfb6.js +760 -0
- package/dist/doctor-auth-flat-profiles-BIZ4wsYP.js +2 -0
- package/dist/doctor-auth-flat-profiles-DXtD5LfC.js +516 -0
- package/dist/doctor-auth-legacy-oauth-DwFbRYTP.js +48 -0
- package/dist/doctor-auth-oauth-sidecar-6I3FEJbi.js +2 -0
- package/dist/doctor-auth-oauth-sidecar-BSC3rnDM.js +177 -0
- package/dist/doctor-auth-tVGsUiM6.js +216 -0
- package/dist/doctor-bootstrap-size-B0q6bdkO.js +57 -0
- package/dist/doctor-claude-cli-Bn79OuBT.js +150 -0
- package/dist/doctor-config-flow-CCwocXpV.js +1819 -0
- package/dist/doctor-core-checks-D7-1l8jy.js +666 -0
- package/dist/doctor-core-checks-eM8FNi8B.js +2 -0
- package/dist/doctor-core-checks.runtime-Dc03aeoU.js +278 -0
- package/dist/doctor-core-checks.runtime.js +1 -1
- package/dist/doctor-gRYfpEbB.js +6 -0
- package/dist/doctor-gateway-daemon-flow-KTnHAdeV.js +349 -0
- package/dist/doctor-gateway-services-BByDQtjY.js +465 -0
- package/dist/doctor-health-CnoM718z.js +65 -0
- package/dist/doctor-health-contributions-flVKMQwr.js +874 -0
- package/dist/doctor-lint-BBm6gtBa.js +95 -0
- package/dist/doctor-memory-search-DjHVDCGo.js +407 -0
- package/dist/doctor-state-integrity-Bgw25cz1.js +1257 -0
- package/dist/doctor-tool-result-cap-advice-B8wTpiTO.js +27 -0
- package/dist/doctor-workspace-status-DcjeJIpT.js +76 -0
- package/dist/dreaming-BE4t8DVf.js +523 -0
- package/dist/dreaming-command-DWm1lB-Z.js +101 -0
- package/dist/dreaming-narrative-8DM-OMrm.js +721 -0
- package/dist/dreaming-narrative-CcFfheQI.js +2 -0
- package/dist/dreaming-phases-CqOhhTdZ.js +2 -0
- package/dist/dreaming-phases-D9eT6Kk0.js +1162 -0
- package/dist/drive-D2M5B7-2.js +899 -0
- package/dist/echo-transcript-B-wl5MoX.js +52 -0
- package/dist/effective-tool-policy-Cx8mC5aA.js +89 -0
- package/dist/embedded-agent-BTvtoOe_.js +4 -0
- package/dist/embedded-agent-CGmSKuNM.js +4074 -0
- package/dist/embedded-agent-helpers-CboIPx57.js +6 -0
- package/dist/embedded-agent-helpers-cw0InMDZ.js +1037 -0
- package/dist/embedded-agent.runtime-Bfe4bjyF.js +4 -0
- package/dist/embedded-agent.runtime.js +1 -1
- package/dist/embedded-backend-D-EshN85.js +744 -0
- package/dist/embedded-gateway-stub.runtime-Cx9qs0KV.js +12 -0
- package/dist/embedded-gateway-stub.runtime.js +1 -1
- package/dist/embedding-provider-runtime-DaXfsUPo.js +86 -0
- package/dist/embedding-providers-CdU99clu.js +2 -0
- package/dist/embeddings-http-BQnlTr-1.js +222 -0
- package/dist/engine-qmd-5jbjGywA.js +708 -0
- package/dist/engine-storage-CfAgwoDp.js +203 -0
- package/dist/entry.js +1 -1
- package/dist/errors-C0AUxo3P.js +2 -0
- package/dist/exec-approval-forwarder.runtime-BvR47p5Z.js +4 -0
- package/dist/exec-approval-forwarder.runtime.js +1 -1
- package/dist/exec-approval-session-target-CCqYgaVa.js +177 -0
- package/dist/exec-auto-reviewer-BfJaNkNy.js +2 -0
- package/dist/exec-auto-reviewer-Dqx7I88Z.js +241 -0
- package/dist/execute.runtime-Qb6Z75sG.js +579 -0
- package/dist/execute.runtime.js +1 -1
- package/dist/extensionAPI.js +2 -2
- package/dist/extensions/active-memory/index.js +3 -3
- package/dist/extensions/admin-http-rpc/index.js +1 -1
- package/dist/extensions/alibaba/index.js +1 -1
- package/dist/extensions/alibaba/video-generation-provider.js +1 -1
- package/dist/extensions/baichuan/index.js +1 -1
- package/dist/extensions/browser/browser-bridge.js +1 -1
- package/dist/extensions/browser/browser-cdp.js +1 -1
- package/dist/extensions/browser/browser-config.js +5 -5
- package/dist/extensions/browser/browser-control-auth.js +2 -2
- package/dist/extensions/browser/browser-doctor.js +3 -3
- package/dist/extensions/browser/browser-maintenance.js +1 -1
- package/dist/extensions/browser/browser-profiles.js +3 -3
- package/dist/extensions/browser/browser-runtime-api.js +14 -14
- package/dist/extensions/browser/cli-metadata.js +1 -1
- package/dist/extensions/browser/index.js +1 -1
- package/dist/extensions/browser/plugin-registration.js +1 -1
- package/dist/extensions/browser/register.runtime.js +4 -4
- package/dist/extensions/browser/runtime-api.js +16 -16
- package/dist/extensions/byteplus/index.js +3 -3
- package/dist/extensions/byteplus/video-generation-provider.js +1 -1
- package/dist/extensions/canvas/index.js +3 -3
- package/dist/extensions/canvas/runtime-api.js +2 -2
- package/dist/extensions/deepseek/index.js +1 -1
- package/dist/extensions/device-pair/api.js +2 -2
- package/dist/extensions/device-pair/pair-command-approve.js +1 -1
- package/dist/extensions/device-pair/qr-image.js +2 -2
- package/dist/extensions/longcat/index.js +1 -1
- package/dist/extensions/memory-core/api.js +3 -3
- package/dist/extensions/memory-core/cli-metadata.js +1 -1
- package/dist/extensions/memory-core/cli.js +2 -2
- package/dist/extensions/memory-core/index.js +11 -11
- package/dist/extensions/memory-core/manager-runtime.js +1 -1
- package/dist/extensions/memory-core/runtime-api.js +6 -6
- package/dist/extensions/minimax/image-generation-provider.js +1 -1
- package/dist/extensions/minimax/index.js +7 -7
- package/dist/extensions/minimax/media-understanding-provider.js +1 -1
- package/dist/extensions/minimax/music-generation-provider.js +1 -1
- package/dist/extensions/minimax/oauth.js +1 -1
- package/dist/extensions/minimax/oauth.runtime.js +1 -1
- package/dist/extensions/minimax/provider-registration.js +1 -1
- package/dist/extensions/minimax/speech-provider.js +1 -1
- package/dist/extensions/minimax/video-generation-provider.js +1 -1
- package/dist/extensions/minimax/web-search-provider.js +1 -1
- package/dist/extensions/moonshot/index.js +5 -5
- package/dist/extensions/moonshot/media-understanding-provider.js +1 -1
- package/dist/extensions/moonshot/web-search-provider.js +1 -1
- package/dist/extensions/qianfan/index.js +1 -1
- package/dist/extensions/qwen/index.js +5 -5
- package/dist/extensions/qwen/media-understanding-provider.js +1 -1
- package/dist/extensions/qwen/video-generation-provider.js +1 -1
- package/dist/extensions/sensenova/index.js +1 -1
- package/dist/extensions/skill-workshop/api.js +2 -2
- package/dist/extensions/skill-workshop/index.js +4 -4
- package/dist/extensions/stepfun/index.js +2 -2
- package/dist/extensions/tavily/index.js +1 -1
- package/dist/extensions/tavily/web-search-provider.js +1 -1
- package/dist/extensions/tencent/index.js +2 -2
- package/dist/extensions/tiangong/index.js +1 -1
- package/dist/extensions/volcengine/index.js +3 -3
- package/dist/extensions/volcengine/speech-provider.js +1 -1
- package/dist/extensions/webhooks/api.js +1 -1
- package/dist/extensions/webhooks/index.js +1 -1
- package/dist/extensions/weixin/index.js +3 -3
- package/dist/extensions/workboard/index.js +2 -2
- package/dist/extensions/xiaomi/index.js +4 -4
- package/dist/extensions/xiaomi/speech-provider.js +1 -1
- package/dist/extensions/xingchen/index.js +1 -1
- package/dist/extensions/yi/index.js +1 -1
- package/dist/extensions/zai/index.js +4 -4
- package/dist/extensions/zai/media-understanding-provider.js +1 -1
- package/dist/extensions/zhinao/index.js +1 -1
- package/dist/external-cli-auth-selection-CM_aOUJw.js +113 -0
- package/dist/extra-params-Bm1eLWN9.js +615 -0
- package/dist/fallback-notice-state-v1kyWACv.js +15 -0
- package/dist/fallbacks-CDllk2g1.js +31 -0
- package/dist/fallbacks-shared-DdMKEmAC.js +116 -0
- package/dist/fengming-runtime-DSv30J04.js +33 -0
- package/dist/fengming-runtime-config-BE-DquuY.js +2 -0
- package/dist/fengming-runtime-memory-BE-DquuY.js +2 -0
- package/dist/fengming-runtime-session-BE-DquuY.js +2 -0
- package/dist/fengming-tools-DHb-ZeDC.js +12221 -0
- package/dist/flows-Cz3y10A9.js +189 -0
- package/dist/fs-utils-D05rps7O.js +9 -0
- package/dist/gateway/protocol/index.d.ts +1 -1
- package/dist/gateway-DTi2D7ZS.js +133 -0
- package/dist/gateway-cli-DT2fL2fX.js +443 -0
- package/dist/gateway-install-token-CJhAycOA.js +136 -0
- package/dist/gateway-method-runtime-BuiYTDQk.js +21 -0
- package/dist/gateway-runtime-C5_cVlSW.js +23 -0
- package/dist/get-reply-Cz-dUrWm.js +5198 -0
- package/dist/get-reply-from-config.runtime-BC1HT67i.js +2 -0
- package/dist/get-reply-from-config.runtime.js +1 -1
- package/dist/github-copilot-token-09lxV3kH.js +2 -0
- package/dist/health-CmihbcqN.js +621 -0
- package/dist/health-D8L37hBZ.js +111 -0
- package/dist/health-DU7I9RrJ.js +3 -0
- package/dist/health-state-QZ2E6xGQ.js +106 -0
- package/dist/heartbeat-runner-Bz5PMzEI.js +1930 -0
- package/dist/heartbeat-runner-DfqqQ_8w.js +5 -0
- package/dist/heartbeat-runner.runtime-8BshUhoS.js +3 -0
- package/dist/heartbeat-runner.runtime.js +1 -1
- package/dist/helpers-Bkq4POdX.js +406 -0
- package/dist/hook-helpers-nmDwt3Fa.js +44 -0
- package/dist/hooks-9FOcRqfu.js +536 -0
- package/dist/hooks-cli-CrQelcwo.js +465 -0
- package/dist/http-endpoint-helpers-BD5u6YsT.js +37 -0
- package/dist/http-utils-RcKuBJ0I.js +98 -0
- package/dist/image-DwNoypK2.js +385 -0
- package/dist/image-fallbacks-BUyDnmUX.js +31 -0
- package/dist/image-generation-core.auth.runtime-CA8miEMh.js +2 -0
- package/dist/image-generation-core.auth.runtime.js +1 -1
- package/dist/image-generation-provider-DXMW5EmB.js +152 -0
- package/dist/image-runtime-D5QpNNzz.js +9 -0
- package/dist/image-tool.helpers-6vGxo1Y0.js +150 -0
- package/dist/images-BGWLzQEJ.js +416 -0
- package/dist/images-Db4UB3JG.js +2 -0
- package/dist/inbound-reply-dispatch-DRF6ZmQg.js +2 -0
- package/dist/inbound-reply-dispatch-RAKLqow4.js +147 -0
- package/dist/index-DhOQs6M_.d.ts +1497 -0
- package/dist/index.js +1 -1
- package/dist/infra-runtime-BFrpRc_V.js +32 -0
- package/dist/init-sR7bCS9D.js +59 -0
- package/dist/install-BzdJbOUx.js +262 -0
- package/dist/install.runtime-Zye6pbZ6.js +2 -0
- package/dist/internal-DL_vFx8C.js +399 -0
- package/dist/isolated-agent-Qif8Llbt.js +2 -0
- package/dist/isolated-agent-aqEjxqs-.js +1097 -0
- package/dist/kernel-B-i4c2IK.js +979 -0
- package/dist/kernel-DYDJ_hLb.js +3 -0
- package/dist/kimi-web-search-provider.runtime-95HAkvHY.js +307 -0
- package/dist/kimi-web-search-provider.runtime.js +1 -1
- package/dist/library-CZVbE5hF.js +45 -0
- package/dist/lifecycle-C8M3YLbT.js +2 -0
- package/dist/lifecycle-CPDNQnUN.js +570 -0
- package/dist/lifecycle-DpuP7n3J.js +355 -0
- package/dist/lifecycle.runtime-C8M3YLbT.js +2 -0
- package/dist/lifecycle.runtime.js +1 -1
- package/dist/link-understanding/apply.runtime.js +3 -3
- package/dist/list-B_ALwpPl.js +2 -0
- package/dist/list-Bda_GYFy.js +207 -0
- package/dist/list.list-command-W9OGfAIU.js +429 -0
- package/dist/list.model-row-LV4AaX0H.js +39 -0
- package/dist/list.probe-CrZm6BH2.js +451 -0
- package/dist/list.probe-Dfdmb8bC.js +2 -0
- package/dist/list.provider-catalog-7T1jKk0n.js +211 -0
- package/dist/list.provider-catalog-DjGyZVEj.js +2 -0
- package/dist/list.registry-load-DkCS8JZQ.js +152 -0
- package/dist/list.row-sources-B1vjo_Y9.js +474 -0
- package/dist/list.source-plan-C9Sa6zRK.js +81 -0
- package/dist/list.status-command-9daSZZDm.js +815 -0
- package/dist/live-model-switch-Dy-UFUMS.js +119 -0
- package/dist/llm-slug-generator-DEmh5-_1.js +78 -0
- package/dist/llm-slug-generator.js +1 -1
- package/dist/load-config-CvQpC8k6.js +27 -0
- package/dist/load-context-_qSHpZ5S.js +82 -0
- package/dist/loader-CntMt07B.js +7008 -0
- package/dist/local-dispatch.runtime-BSN_gqNS.js +10 -0
- package/dist/local-dispatch.runtime.js +1 -1
- package/dist/main-session-restart-recovery-Db7366lt.js +2 -0
- package/dist/main-session-restart-recovery-n87NTooQ.js +389 -0
- package/dist/managed-image-attachments-BTBBHlKl.js +2 -0
- package/dist/managed-image-attachments-C6_V1yX0.js +616 -0
- package/dist/manager-CKrWxjV6.js +3737 -0
- package/dist/manager-Dvb1FVnx.js +2314 -0
- package/dist/mcp/plugin-tools-serve.js +2 -2
- package/dist/mcp-http-CSoGXOa_.js +583 -0
- package/dist/mcp-http-D4ieDB3W.js +2 -0
- package/dist/media-runtime-GeQTQkkK.js +391 -0
- package/dist/media-services-CWbIUZDe.js +416 -0
- package/dist/media-understanding/apply.runtime.js +1 -1
- package/dist/media-understanding-DXc2BD2L.js +87 -0
- package/dist/media-understanding-provider-BkdUiVWU.js +70 -0
- package/dist/media-understanding-provider-BlgmLViW.js +13 -0
- package/dist/media-understanding-provider-C9P2VjkC.js +29 -0
- package/dist/media-understanding-provider-CJlbgAvl.js +69 -0
- package/dist/memory-CnC2jM1l.js +437 -0
- package/dist/memory-core-host-engine-embeddings-Dy9vN-Ce.js +667 -0
- package/dist/memory-core-host-engine-foundation-C-pGGQnm.js +15 -0
- package/dist/memory-core-host-engine-qmd-DLJDON9w.js +2 -0
- package/dist/memory-core-host-engine-storage-Bzf-C8XE.js +2 -0
- package/dist/memory-core-host-runtime-cli-_LWA6G3x.js +10 -0
- package/dist/memory-core-host-runtime-core-CromkNBr.js +12 -0
- package/dist/memory-core-host-runtime-files-DpbviC1b.js +4 -0
- package/dist/memory-embedding-provider-runtime-CaVVaYC5.js +36 -0
- package/dist/memory-host-core-B5dWHwBF.js +78 -0
- package/dist/memory-host-search.runtime-DqlCFac1.js +2 -0
- package/dist/memory-host-search.runtime.js +1 -1
- package/dist/memory-runtime-BCeeWb1G.js +2 -0
- package/dist/memory-runtime-pR9KGin0.js +57 -0
- package/dist/memory-search-CpDEEY2Q.js +235 -0
- package/dist/message-BeGCG-D8.js +284 -0
- package/dist/message-YGMOyqP5.js +2 -0
- package/dist/message-action-runner-ByMT3_eb.js +1922 -0
- package/dist/message-action-runner-VXmKO_W7.js +2 -0
- package/dist/message-handler-MZ0DMbCx.js +1806 -0
- package/dist/metadata-registry-loader-BH9D1UOx.js +2 -0
- package/dist/metadata-registry-loader-BK1cHCas.js +22 -0
- package/dist/migrate-BA6w0hd3.js +2 -0
- package/dist/migrate-BGuQC-1W.js +458 -0
- package/dist/migration-provider-runtime-BBdDegWG.js +2 -0
- package/dist/migration-provider-runtime-C5WUjrQz.js +68 -0
- package/dist/minimax-web-search-provider.runtime-suVFk3Zx.js +148 -0
- package/dist/minimax-web-search-provider.runtime.js +1 -1
- package/dist/model-BJZXR9dq.js +1302 -0
- package/dist/model-BL7xlN5h.js +2 -0
- package/dist/model-auth-C-6dYVob.js +6 -0
- package/dist/model-auth-DJz7R41W.js +705 -0
- package/dist/model-auth-label-DKNXktIu.js +67 -0
- package/dist/model-catalog-BjiK5rtT.js +3 -0
- package/dist/model-catalog-DM1CTjkW.js +434 -0
- package/dist/model-catalog-visibility-DEJZG0In.js +76 -0
- package/dist/model-config.helpers-BKcUeE_P.js +95 -0
- package/dist/model-context-tokens-5y_PQELY.js +572 -0
- package/dist/model-fallback-BDdBR053.js +1288 -0
- package/dist/model-fallback-auth.runtime-pcWfkIUF.js +5 -0
- package/dist/model-fallback-auth.runtime.js +1 -1
- package/dist/model-picker-Bpvp4_N4.js +1135 -0
- package/dist/model-picker-DWPPtq6d.js +3 -0
- package/dist/model-picker-visibility-BtdqVF80.js +22 -0
- package/dist/model-picker.runtime-CYlqts2z.js +48 -0
- package/dist/model-picker.runtime.js +1 -1
- package/dist/model-pricing-cache-BmmncDqL.js +856 -0
- package/dist/model-pricing-cache-CEwRyWw2.js +3 -0
- package/dist/model-pricing-cache-state-B8Aspp85.js +83 -0
- package/dist/model-provider-auth-B3KXoKkE.js +2 -0
- package/dist/model-provider-auth-Bo_8T7of.js +375 -0
- package/dist/model-runtime-aliases-Br-ZlhrL.js +133 -0
- package/dist/model-selection-D5-ERakL.js +254 -0
- package/dist/model-selection-DrzgktRu.js +7 -0
- package/dist/model-selection-ibwsPgIw.js +352 -0
- package/dist/model-selection.runtime-BRkOZejt.js +7 -0
- package/dist/model-selection.runtime.js +1 -1
- package/dist/models-RPAH3ZBn.js +57 -0
- package/dist/models-auth-status-Cwu9OXU8.js +280 -0
- package/dist/models-cli-CrYkSUoa.js +257 -0
- package/dist/models-config-Ayzj9gDz.js +1189 -0
- package/dist/models-config-BFcjB7nN.js +2 -0
- package/dist/models-config.providers.secrets-CCRUW7gL.js +2 -0
- package/dist/models-config.providers.secrets-DdX_XSRo.js +382 -0
- package/dist/models-http-jLFnelH7.js +88 -0
- package/dist/monitor-CqWICrjO.js +60 -0
- package/dist/monitor-DwccYPfp.js +1024 -0
- package/dist/monitor.account-e9EVttpP.js +5382 -0
- package/dist/music-generation-provider-Dfc--R-x.js +308 -0
- package/dist/native-hook-relay-Cioqiqv8.js +1378 -0
- package/dist/native-hook-relay-DRwJIspI.js +19 -0
- package/dist/node-cli-CrG3LH9J.js +2806 -0
- package/dist/node-command-policy-CkBTEmhl.js +295 -0
- package/dist/nodes-BxrWFA09.js +1483 -0
- package/dist/nodes-DFPTGZjc.js +3 -0
- package/dist/nodes-cli-Czwyt6r1.js +960 -0
- package/dist/nodes-pending-B_4QHyB2.js +211 -0
- package/dist/nodes-utils-c4k31OaG.js +85 -0
- package/dist/oauth-BXncC0JP.js +852 -0
- package/dist/oauth-Ba1O2vqP.js +207 -0
- package/dist/oauth-CGQkfxbJ.js +746 -0
- package/dist/onboard-I5tQlVm6.js +768 -0
- package/dist/onboard-channels-BleKfB1D.js +2 -0
- package/dist/onboard-channels-jVaUjGYX.js +1534 -0
- package/dist/onboard-custom-BR_5oqUr.js +3 -0
- package/dist/onboard-custom-Ss0DThuP.js +280 -0
- package/dist/onboard-custom-config-B-knjQm7.js +422 -0
- package/dist/onboard-search-BsIztGYF.js +412 -0
- package/dist/openai-compat-errors-UkLkk8Q9.js +136 -0
- package/dist/openai-http-mTQB44gu.js +836 -0
- package/dist/openai-transport-stream-CZSs3SIi.js +3427 -0
- package/dist/openresponses-http-BA1Shmj-.js +1175 -0
- package/dist/operations-DhgPih1F.js +805 -0
- package/dist/order-CaXafMPG.js +218 -0
- package/dist/outbound-attachment-BAp7DXDc.js +19 -0
- package/dist/param-readers-De-m2SoB.js +2 -0
- package/dist/payloads-Dg9aAEOC.js +256 -0
- package/dist/persistent-bindings.lifecycle-BkLOz501.js +2 -0
- package/dist/persistent-bindings.lifecycle-e2MLbBCo.js +85 -0
- package/dist/plugin-enabled-CGSENjXc.js +232 -0
- package/dist/plugin-install-BI9_bsVT.js +118 -0
- package/dist/plugin-install-an4V2iXO.js +2 -0
- package/dist/plugin-install-config-policy-C66Nss3D.js +169 -0
- package/dist/plugin-registration-DMerQktl.js +97 -0
- package/dist/plugin-registry-BZfdCw65.js +3 -0
- package/dist/plugin-registry-I1fegSdK.js +2 -0
- package/dist/plugin-runtime-B3XMLJka.js +102 -0
- package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
- package/dist/plugin-sdk/acp-binding-runtime.js +1 -1
- package/dist/plugin-sdk/acp-runtime-backend.js +1 -1
- package/dist/plugin-sdk/acp-runtime.js +2 -2
- package/dist/plugin-sdk/agent-harness-runtime.js +16 -16
- package/dist/plugin-sdk/agent-harness-task-runtime.js +4 -4
- package/dist/plugin-sdk/agent-harness.js +17 -17
- package/dist/plugin-sdk/agent-runtime.js +17 -17
- package/dist/plugin-sdk/agent-sessions.js +1 -1
- package/dist/plugin-sdk/approval-native-runtime.js +2 -2
- package/dist/plugin-sdk/approval-reaction-runtime.js +1 -1
- package/dist/plugin-sdk/approval-runtime.js +2 -2
- package/dist/plugin-sdk/bundled-channel-config-schema-BsOWCrJT.d.ts +3169 -0
- package/dist/plugin-sdk/bundled-channel-config-schema.d.ts +1 -1
- package/dist/plugin-sdk/channel-actions.js +2 -2
- 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 +4 -4
- package/dist/plugin-sdk/channel-location.js +1 -1
- package/dist/plugin-sdk/channel-message-runtime.js +5 -5
- package/dist/plugin-sdk/channel-message.js +5 -5
- package/dist/plugin-sdk/channel-outbound.js +2 -2
- package/dist/plugin-sdk/channel-reply-options-runtime.js +1 -1
- package/dist/plugin-sdk/command-auth-native.js +2 -2
- package/dist/plugin-sdk/command-auth.js +4 -4
- package/dist/plugin-sdk/command-primitives-runtime.js +2 -2
- package/dist/plugin-sdk/command-status-runtime.js +1 -1
- package/dist/plugin-sdk/command-status.js +1 -1
- package/dist/plugin-sdk/compat.js +2 -2
- package/dist/plugin-sdk/config-mutation.js +2 -2
- package/dist/plugin-sdk/config-runtime.js +1 -1
- package/dist/plugin-sdk/config-schema.d.ts +2 -2
- 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 +3 -3
- package/dist/plugin-sdk/delivery-queue-runtime.js +1 -1
- package/dist/plugin-sdk/direct-dm.js +1 -1
- package/dist/plugin-sdk/discord.d.ts +1 -1
- package/dist/plugin-sdk/embedding-providers.js +2 -2
- package/dist/plugin-sdk/gateway-method-runtime.js +1 -1
- package/dist/plugin-sdk/gateway-runtime.js +2 -2
- package/dist/plugin-sdk/health.js +1 -1
- package/dist/plugin-sdk/image-generation-core.js +3 -3
- package/dist/plugin-sdk/image-generation-runtime.js +1 -1
- package/dist/plugin-sdk/image-generation.js +2 -2
- package/dist/plugin-sdk/inbound-reply-dispatch.js +3 -3
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/infra-runtime.js +3 -3
- package/dist/plugin-sdk/mattermost.js +1 -1
- package/dist/plugin-sdk/media-generation-runtime-shared.js +1 -1
- package/dist/plugin-sdk/media-generation-runtime.js +1 -1
- package/dist/plugin-sdk/media-runtime.js +7 -7
- package/dist/plugin-sdk/media-understanding-runtime.js +1 -1
- package/dist/plugin-sdk/media-understanding.js +2 -2
- package/dist/plugin-sdk/memory-core-host-engine-embeddings.js +4 -4
- package/dist/plugin-sdk/memory-core-host-engine-foundation.js +2 -2
- package/dist/plugin-sdk/memory-core-host-engine-qmd.js +2 -2
- package/dist/plugin-sdk/memory-core-host-engine-storage.js +6 -6
- package/dist/plugin-sdk/memory-core-host-runtime-cli.js +2 -2
- package/dist/plugin-sdk/memory-core-host-runtime-core.js +3 -3
- package/dist/plugin-sdk/memory-core-host-runtime-files.js +4 -4
- package/dist/plugin-sdk/memory-core.js +3 -3
- package/dist/plugin-sdk/memory-host-core.js +3 -3
- package/dist/plugin-sdk/memory-host-files.js +4 -4
- package/dist/plugin-sdk/memory-host-search.js +1 -1
- package/dist/plugin-sdk/models-provider-runtime.js +1 -1
- package/dist/plugin-sdk/music-generation-core.js +1 -1
- package/dist/plugin-sdk/native-command-registry.js +1 -1
- package/dist/plugin-sdk/outbound-media.js +2 -2
- package/dist/plugin-sdk/outbound-runtime.js +3 -3
- package/dist/plugin-sdk/param-readers.js +2 -2
- package/dist/plugin-sdk/plugin-runtime.js +2 -2
- package/dist/plugin-sdk/provider-auth-api-key.js +4 -4
- package/dist/plugin-sdk/provider-auth-login.js +1 -1
- package/dist/plugin-sdk/provider-auth-runtime.js +2 -2
- package/dist/plugin-sdk/provider-auth.js +6 -6
- package/dist/plugin-sdk/provider-catalog-runtime.js +2 -2
- package/dist/plugin-sdk/provider-entry.js +1 -1
- package/dist/plugin-sdk/provider-setup.js +1 -1
- package/dist/plugin-sdk/provider-stream-family.js +3 -3
- package/dist/plugin-sdk/provider-stream.js +2 -2
- package/dist/plugin-sdk/provider-transport-runtime.js +1 -1
- package/dist/plugin-sdk/provider-web-fetch.js +2 -2
- package/dist/plugin-sdk/provider-web-search.js +4 -4
- package/dist/plugin-sdk/realtime-bootstrap-context.js +2 -2
- package/dist/plugin-sdk/realtime-transcription.js +1 -1
- package/dist/plugin-sdk/realtime-voice.js +2 -2
- package/dist/plugin-sdk/reply-dispatch-runtime.js +1 -1
- package/dist/plugin-sdk/reply-runtime.js +6 -6
- package/dist/plugin-sdk/runtime-secret-resolution.js +2 -2
- package/dist/plugin-sdk/runtime.js +3 -3
- package/dist/plugin-sdk/self-hosted-provider-setup.js +1 -1
- package/dist/plugin-sdk/simple-completion-runtime.js +1 -1
- package/dist/plugin-sdk/speech-core.js +2 -2
- package/dist/plugin-sdk/speech.js +1 -1
- package/dist/plugin-sdk/tool-plugin.js +1 -1
- package/dist/plugin-sdk/transcripts.js +1 -1
- package/dist/plugin-sdk/tts-runtime.js +1 -1
- package/dist/plugin-sdk/video-generation-core.js +2 -2
- package/dist/plugin-sdk/video-generation-runtime.js +1 -1
- package/dist/plugin-sdk/web-media.js +3 -3
- package/dist/plugin-sdk/zalouser.js +1 -1
- package/dist/plugin-service-2XF6Lu_a.js +1249 -0
- package/dist/plugins/build-smoke-entry.js +2 -2
- package/dist/plugins/loader.js +1 -1
- package/dist/plugins/provider-discovery.runtime.js +1 -1
- package/dist/plugins/provider-runtime.runtime.js +1 -1
- package/dist/plugins/runtime/index.js +19 -19
- package/dist/plugins/tools.js +1 -1
- package/dist/plugins-authoring-command-CCX6tJwd.js +304 -0
- package/dist/plugins-cli-HX8nTV2h.js +63 -0
- package/dist/plugins-cli.runtime-BYn4VsLP.js +339 -0
- package/dist/plugins-cli.runtime.js +1 -1
- package/dist/plugins-command-helpers-ByuW-yNj.js +2 -0
- package/dist/plugins-command-helpers-DaaxGnCD.js +164 -0
- package/dist/plugins-inspect-command-C9NDk23X.js +248 -0
- package/dist/plugins-install-command-B0NfUxeA.js +993 -0
- package/dist/plugins-install-command-BmuScfLI.js +2 -0
- package/dist/plugins-install-persist-CfwO876P.js +252 -0
- package/dist/plugins-list-command-Bx8X908n.js +184 -0
- package/dist/plugins-uninstall-command-p6h44-Ft.js +118 -0
- package/dist/postinstall-inventory.json +862 -862
- package/dist/prepare.runtime-8DdQ4k9k.js +798 -0
- package/dist/prepare.runtime.js +1 -1
- package/dist/presentation-card-DeAf3jYW.js +164 -0
- package/dist/preview-warnings-BF7nlTo8.js +618 -0
- package/dist/profiles-DUhMLnqX.js +194 -0
- package/dist/program-C7f_U7fr.js +131 -0
- package/dist/provider-adapters-CWLwE9KS.js +104 -0
- package/dist/provider-api-key-auth-CshQbUPZ.js +117 -0
- package/dist/provider-api-key-auth.runtime-B64jPCKn.js +14 -0
- package/dist/provider-api-key-auth.runtime.js +1 -1
- package/dist/provider-auth-D-I3YLSn.js +281 -0
- package/dist/provider-auth-api-key-Bub0Rjak.js +5 -0
- package/dist/provider-auth-choice-DpNAEScm.js +311 -0
- package/dist/provider-auth-choice-helpers-Bof937LW.js +210 -0
- package/dist/provider-auth-choice.runtime-B3spikLY.js +18 -0
- package/dist/provider-auth-choice.runtime-vVgz7FKq.js +2 -0
- package/dist/provider-auth-choice.runtime.js +1 -1
- package/dist/provider-auth-guidance-DcCL0Q2U.js +2 -0
- package/dist/provider-auth-guidance-rWRMN4Jn.js +34 -0
- package/dist/provider-auth-helpers-Cp8L-Xha.js +177 -0
- package/dist/provider-auth-login.runtime-BJUzc4iH.js +156 -0
- package/dist/provider-auth-login.runtime.js +1 -1
- package/dist/provider-auth-runtime-DmcWtzbb.js +186 -0
- package/dist/provider-discovery-JyAJi97k.js +95 -0
- package/dist/provider-discovery.runtime-D_0WTYr8.js +290 -0
- package/dist/provider-discovery.runtime.js +1 -1
- package/dist/provider-dispatcher-C8Jt94Xl.js +22 -0
- package/dist/provider-dispatcher.runtime.js +1 -1
- package/dist/provider-entry-By0ggZuI.js +134 -0
- package/dist/provider-hook-runtime-B8AUbQxf.js +255 -0
- package/dist/provider-openai-codex-oauth-C9Mmnt7d.js +2 -0
- package/dist/provider-openai-codex-oauth-CH5Jg1vk.js +44 -0
- package/dist/provider-registration-C1zvaHQP.js +235 -0
- package/dist/provider-registry-B9diJyLv.js +31 -0
- package/dist/provider-registry-BXSxmPGA.js +61 -0
- package/dist/provider-registry-CoE-sxbq.js +61 -0
- package/dist/provider-registry-DLth_GdI.js +61 -0
- package/dist/provider-registry-J4LRd5Rg.js +36 -0
- package/dist/provider-runtime-B4cw16pt.js +3 -0
- package/dist/provider-runtime-DNNbfwOK.js +386 -0
- package/dist/provider-runtime.runtime-98mAe_ni.js +26 -0
- package/dist/provider-runtime.runtime.js +1 -1
- package/dist/provider-self-hosted-setup-Dysv2Kwt.js +373 -0
- package/dist/provider-stream-BLaC8bqO.js +1084 -0
- package/dist/provider-stream-Caa5YOx2.js +313 -0
- package/dist/provider-stream-family-CvvfxLyP.js +2 -0
- package/dist/provider-usage-CVNosTP3.js +71 -0
- package/dist/provider-usage-D2NudXbO.js +4 -0
- package/dist/provider-usage.load-DG6R3lkG.js +357 -0
- package/dist/provider-web-search-DmgTaxRU.js +58 -0
- package/dist/provider-wizard-Cw-5H3tX.js +125 -0
- package/dist/providers.runtime-DF0T9lFz.js +240 -0
- package/dist/providers.runtime-oM9Vn1wr.js +2 -0
- package/dist/providers.runtime.js +1 -1
- package/dist/proxy-BxGnVyJu.js +662 -0
- package/dist/public-artifacts-BMP9hZfh.js +7 -0
- package/dist/pw-ai-CD52qfYo.js +3064 -0
- package/dist/qmd-manager-BYbvU4YC.js +2040 -0
- package/dist/qr-cli-Btz2ZdO3.js +2 -0
- package/dist/qr-cli-eyTRwMm2.js +371 -0
- package/dist/qr-image-BCwiO6tL.js +2 -0
- package/dist/queue-CJRoTOBi.js +923 -0
- package/dist/read-file-ogB-HjbK.js +183 -0
- package/dist/register-service-commands-D_gQ3b6_.js +77 -0
- package/dist/register.agent-DXQLn-r0.js +152 -0
- package/dist/register.configure-FavQPGce.js +16 -0
- package/dist/register.crestodian-Cbfmnl6h.js +24 -0
- package/dist/register.maintenance-B8xODEMU.js +85 -0
- package/dist/register.message-B8PYgZ-j.js +404 -0
- package/dist/register.migrate-CieoN8zZ.js +106 -0
- package/dist/register.onboard-BqWDIDKH.js +115 -0
- package/dist/register.setup-CgeTBW4T.js +40 -0
- package/dist/register.status-health-sessions-C99aHa5h.js +293 -0
- package/dist/register.subclis-79SvyMFt.js +31 -0
- package/dist/register.subclis-CXrO8_TO.js +3 -0
- package/dist/register.subclis-core-GoXV1yMG.js +273 -0
- package/dist/rem-harness-laL5luQa.js +649 -0
- package/dist/repair-sequencing-DGY2mBg6.js +652 -0
- package/dist/reply-media-paths.runtime-BeWVPkgy.js +2 -0
- package/dist/reply-media-paths.runtime-rzAV_Kee.js +154 -0
- package/dist/reply-media-paths.runtime.js +1 -1
- package/dist/reply-payloads-D_JHMviC.js +79 -0
- package/dist/reply-payloads-dedupe-B9GGGaL-.js +176 -0
- package/dist/reply-payloads-dedupe.runtime--C3jHs9y.js +2 -0
- package/dist/reply-payloads-dedupe.runtime.js +1 -1
- package/dist/reply-timing-tracker-DPjlETUb.js +205 -0
- package/dist/reply-turn-admission-DdfIwcMK.js +2056 -0
- package/dist/reply.runtime-BC1HT67i.js +2 -0
- package/dist/reply.runtime.js +1 -1
- package/dist/reset-preserved-selection-Czd80hug.js +45 -0
- package/dist/resolve-COJFlAZT.js +106 -0
- package/dist/restart-B9GMMIZt.js +121 -0
- package/dist/result-fallback-classifier-By0Z6b8r.js +98 -0
- package/dist/root-help-Bp0kGaUZ.js +43 -0
- package/dist/route-CgG9Z7OI.js +475 -0
- package/dist/route-reply-D9_9oRg1.js +174 -0
- package/dist/route-reply.runtime-BwNl3h2m.js +2 -0
- package/dist/route-reply.runtime.js +1 -1
- package/dist/routes-Cz2NHUV4.js +2 -0
- package/dist/routes-DMo6Eacc.js +3701 -0
- package/dist/run-SFRSThMI.js +1162 -0
- package/dist/run-auth-profile.runtime-BxLM8m_2.js +2 -0
- package/dist/run-auth-profile.runtime.js +1 -1
- package/dist/run-command-Cd5iN7eN.js +2 -0
- package/dist/run-command-ah46O06U.js +23 -0
- package/dist/run-context-DGCQJldA.js +66 -0
- package/dist/run-context.runtime-CSBHDAd5.js +2 -0
- package/dist/run-context.runtime.js +1 -1
- package/dist/run-delivery.runtime-C9xoiZ3h.js +762 -0
- package/dist/run-delivery.runtime.js +1 -1
- package/dist/run-embedded.runtime-D8bz5vfV.js +4 -0
- package/dist/run-embedded.runtime.js +1 -1
- package/dist/run-execution-cli.runtime-BAa8KPn7.js +4 -0
- package/dist/run-execution-cli.runtime.js +1 -1
- package/dist/run-executor.runtime-CNnemqSa.js +330 -0
- package/dist/run-executor.runtime.js +1 -1
- package/dist/run-model-catalog.runtime-Dh7EghXr.js +2 -0
- package/dist/run-model-catalog.runtime.js +1 -1
- package/dist/run-session-state-cMlTFwT_.js +159 -0
- package/dist/run-subagent-registry.runtime-BgQU86-E.js +2 -0
- package/dist/run-subagent-registry.runtime.js +1 -1
- package/dist/runner-B3YXRJOB.js +704 -0
- package/dist/runner.entries-DMTKpRDP.js +1485 -0
- package/dist/runtime-BHReFHE2.js +2 -0
- package/dist/runtime-BiQZ6Usw.js +615 -0
- package/dist/runtime-CAeriu2O.js +10 -0
- package/dist/runtime-CAnCRCX3.js +224 -0
- package/dist/runtime-CV_2NqSY.js +300 -0
- package/dist/runtime-CmpnvXo3.js +245 -0
- package/dist/runtime-D2fci1Ey.js +2 -0
- package/dist/runtime-DAsYmYeA.js +3 -0
- package/dist/runtime-DeA45VKG.js +210 -0
- package/dist/runtime-DvkZ8tHI.js +436 -0
- package/dist/runtime-DxVUR2Xg.js +2 -0
- package/dist/runtime-api-B88le0UE.js +12 -0
- package/dist/runtime-channel-AubRWvnH.js +2 -0
- package/dist/runtime-channel-DdclSuEu.js +148 -0
- package/dist/runtime-config-collectors-DukTj2va.js +525 -0
- package/dist/runtime-embedded-agent.runtime-BpLweeFv.js +2 -0
- package/dist/runtime-embedded-agent.runtime.js +1 -1
- package/dist/runtime-internal-CaoUylZw.js +2 -0
- package/dist/runtime-llm.runtime-DlpqGc7S.js +307 -0
- package/dist/runtime-llm.runtime.js +1 -1
- package/dist/runtime-model-auth.runtime-CLAaWzxY.js +46 -0
- package/dist/runtime-model-auth.runtime-DxVvqRTd.js +2 -0
- package/dist/runtime-model-auth.runtime.js +1 -1
- package/dist/runtime-options-TTtN01-I.js +275 -0
- package/dist/runtime-plugin-ClqxJSbp.js +92 -0
- package/dist/runtime-plugins-Bq01wLXP.js +32 -0
- package/dist/runtime-plugins.runtime-cwCvl1TR.js +2 -0
- package/dist/runtime-plugins.runtime.js +1 -1
- package/dist/runtime-prepare.runtime-Cz_hV_k5.js +81 -0
- package/dist/runtime-prepare.runtime.js +1 -1
- package/dist/runtime-provider-QCJq90av.js +24 -0
- package/dist/runtime-provider-Wllc3jC6.js +2 -0
- package/dist/runtime-registry-loader-BM1mQBJr.js +2 -0
- package/dist/runtime-registry-loader-DzhYCt4s.js +117 -0
- package/dist/runtime-shared-BfqOW-Vb.js +365 -0
- package/dist/runtime-web-channel-plugin-BcVPgD14.js +204 -0
- package/dist/runtime-web-tools-fallback.runtime.js +1 -1
- package/dist/scan-ldbaD8jq.js +573 -0
- package/dist/sdk-security-runtime-Bxhq2O1G.js +86 -0
- package/dist/sdk-setup-tools-CsQM9pF0.js +8 -0
- package/dist/secrets-cli-DbpIf4-z.js +150 -0
- package/dist/security-cli-BK4Xpa6h.js +520 -0
- package/dist/selection-BXKik6Ps.js +3 -0
- package/dist/selection-D4O3gK3Q.js +18365 -0
- package/dist/send-DaoGIay5.js +1222 -0
- package/dist/send-DzNjJGJX.js +178 -0
- package/dist/send-f5w9krNS.js +711 -0
- package/dist/send-media-cOciBxcg.js +2072 -0
- package/dist/send-result-DMFwBuOl.js +141 -0
- package/dist/server-BoC1mxZ-.js +24 -0
- package/dist/server-DZnI6w5k.js +72 -0
- package/dist/server-aux-handlers-BwRdYdub.js +1347 -0
- package/dist/server-chat-Q95f4ywD.js +827 -0
- package/dist/server-close.runtime.js +3 -3
- package/dist/server-context-CnXNaarB.js +2 -0
- package/dist/server-context-DRBebo7Y.js +955 -0
- package/dist/server-cron-C0o0ZvqF.js +3173 -0
- package/dist/server-cron-CLeBvurR.js +2 -0
- package/dist/server-maintenance-CqHfTnFD.js +152 -0
- package/dist/server-methods-BmlBQJMD.js +497 -0
- package/dist/server-middleware-DJhnR6jl.js +122 -0
- package/dist/server-model-catalog-CoSSk_Gy.js +2 -0
- package/dist/server-model-catalog-D32oDTQp.js +73 -0
- package/dist/server-node-events-DX9a4etQ.js +597 -0
- package/dist/server-plugin-bootstrap-Vco-EpxY.js +71 -0
- package/dist/server-plugins-WBX2fZRp.js +435 -0
- package/dist/server-reload-handlers-DGJLH8bg.js +719 -0
- package/dist/server-restart-sentinel-Bvon7f8K.js +700 -0
- package/dist/server-runtime-services-BNcH4vhR.js +3 -0
- package/dist/server-runtime-services-BjcQG5y7.js +147 -0
- package/dist/server-runtime-subscriptions-W39HeyoT.js +67 -0
- package/dist/server-session-events-CO73dMU-.js +244 -0
- package/dist/server-session-key-D8V67lDk.js +2 -0
- package/dist/server-session-key-v-KYSmRS.js +75 -0
- package/dist/server-startup-config-u54lUdWN.js +305 -0
- package/dist/server-startup-early-Cy5kArJG.js +87 -0
- package/dist/server-startup-memory-DvINFAYn.js +72 -0
- package/dist/server-startup-plugins-CerpbOSQ.js +127 -0
- package/dist/server-startup-post-attach-COUCwhNa.js +793 -0
- package/dist/server-ws-runtime-BfznAnbI.js +374 -0
- package/dist/server.impl-dQXccj0z.js +2622 -0
- package/dist/session-cost-usage-Bs5yIOBH.js +1600 -0
- package/dist/session-kill-http-DVleb3RW.js +121 -0
- package/dist/session-log-runtime-OG7J4j9m.js +1258 -0
- package/dist/session-override-LIWl5a9T.js +134 -0
- package/dist/session-reset-model.runtime-BpnTi4sa.js +144 -0
- package/dist/session-reset-model.runtime.js +1 -1
- package/dist/session-reset-service-HA07zS8L.js +651 -0
- package/dist/session-status.runtime-D6_clH8l.js +2 -0
- package/dist/session-status.runtime.js +1 -1
- package/dist/session-store-Cj4Rh6qc.js +273 -0
- package/dist/session-store.runtime-DSCxACdZ.js +4 -0
- package/dist/session-store.runtime.js +1 -1
- package/dist/session-subagent-reactivation.runtime-CcwaHAxg.js +2 -0
- package/dist/session-subagent-reactivation.runtime.js +1 -1
- package/dist/session-tab-registry-C-9uI2Wi.js +551 -0
- package/dist/session-utils-BRtPESA4.js +1508 -0
- package/dist/sessions-Beltl3Ra.js +1917 -0
- package/dist/sessions-DR-X-j8D.js +316 -0
- package/dist/sessions-cleanup-CR1CFcJb.js +165 -0
- package/dist/sessions-history-http-CjyHWYEv.js +432 -0
- package/dist/sessions-patch-peSeltuF.js +401 -0
- package/dist/sessions-resolve-D9ULr95s.js +180 -0
- package/dist/sessions-table-Da6bua9d.js +161 -0
- package/dist/sessions-uKpnhod0.js +12736 -0
- package/dist/sessions.runtime-C1mVNaU3.js +2 -0
- package/dist/sessions.runtime.js +1 -1
- package/dist/set-DVj21EuB.js +31 -0
- package/dist/set-image-JChDCaAP.js +17 -0
- package/dist/setup-5I-zpID3.js +614 -0
- package/dist/setup-CjtY6cli.js +2 -0
- package/dist/setup-onboard-configure-help-fast-path-C5GcSuXb.js +64 -0
- package/dist/setup.finalize-Bf10PNbl.js +586 -0
- package/dist/setup.gateway-config-EH5Rvwzy.js +281 -0
- package/dist/setup.migration-import-CoeV4Kc1.js +200 -0
- package/dist/setup.migration-import-DFFGw4DI.js +2 -0
- package/dist/setup.post-install-migration-DcQmWTE7.js +128 -0
- package/dist/shared-BFSJZ6B3.js +212 -0
- package/dist/shared-CVM-dYkO.js +5 -0
- package/dist/shared-fvgcmCsj.js +71 -0
- package/dist/simple-completion-runtime-C_TXe4M1.js +2 -0
- package/dist/simple-completion-runtime-DREq-fcF.js +206 -0
- package/dist/simple-completion-transport-DtD1fEvJ.js +83 -0
- package/dist/snapshot-urls-B-wkwDI9.js +317 -0
- package/dist/speech-core-KQg6oKcR.js +119 -0
- package/dist/speech-provider-DfyLYitQ.js +171 -0
- package/dist/speech-provider-oDvTumNW.js +227 -0
- package/dist/speech-provider-yL-TQ3Em.js +233 -0
- package/dist/stale-oauth-profile-shadows-CW11VYMM.js +2 -0
- package/dist/stale-oauth-profile-shadows-DFl6Lyf1.js +186 -0
- package/dist/standalone-runtime-registry-loader-BiponY-y.js +59 -0
- package/dist/startup-context-PVXYM-X3.js +314 -0
- package/dist/status-BA_0z83w.js +249 -0
- package/dist/status-Bc7BGlRt.js +2 -0
- package/dist/status-BwPWg9eQ.js +3 -0
- package/dist/status-CLQ66eml.js +4 -0
- package/dist/status-Ci2gChtY.js +466 -0
- package/dist/status-CmtBWJEE.js +2 -0
- package/dist/status-DdnMnPNs.js +73 -0
- package/dist/status-all-BpTvkYrt.js +573 -0
- package/dist/status-json-CizozZCr.js +15 -0
- package/dist/status-json-command-FzKa2t6O.js +84 -0
- package/dist/status-message-BHbnxwmt.js +495 -0
- package/dist/status-message.runtime-Df5WBBAk.js +6 -0
- package/dist/status-message.runtime.js +1 -1
- package/dist/status-queue.runtime-CXnZV4Bj.js +2 -0
- package/dist/status-queue.runtime.js +1 -1
- package/dist/status-runtime-shared-D3Hz8WZ_.js +289 -0
- package/dist/status-subagents.runtime-PoDdwwaw.js +32 -0
- package/dist/status-subagents.runtime.js +1 -1
- package/dist/status-text-DNxXSCuI.js +301 -0
- package/dist/status.command-C_e9GcMg.js +2 -0
- package/dist/status.command-DjVKDmt_.js +425 -0
- package/dist/status.command.text-runtime-BeHlqL8b.js +15 -0
- package/dist/status.runtime-h--fx9HY.js +2 -0
- package/dist/status.scan-WyR8TeJz.js +72 -0
- package/dist/status.scan-overview-CMzUAQMQ.js +460 -0
- package/dist/status.scan.deps.runtime-1JTrdyHk.js +19 -0
- package/dist/status.scan.deps.runtime.js +1 -1
- package/dist/status.scan.fast-json-D2jw1wKO.js +163 -0
- package/dist/status.scan.fast-json-DbN1KxJT.js +2 -0
- package/dist/status.summary-6ZijZM1g.js +2 -0
- package/dist/status.summary-CiCsChO-.js +276 -0
- package/dist/store-CdBPITcg.js +2302 -0
- package/dist/store-D0l2NCdn.js +3 -0
- package/dist/stored-model-override-HEgnFh6b.js +79 -0
- package/dist/subagent-announce-BUv_kA1W.js +353 -0
- package/dist/subagent-announce-delivery-Ci2Y_p--.js +1369 -0
- package/dist/subagent-control-BM3vNgsQ.js +492 -0
- package/dist/subagent-control.runtime-Df3pVQL9.js +3 -0
- package/dist/subagent-control.runtime.js +1 -1
- package/dist/subagent-hooks-CN2fLez2.js +2 -0
- package/dist/subagent-hooks-CeOmTJBf.js +230 -0
- package/dist/subagent-hooks-api-Cfe4DAT9.js +23 -0
- package/dist/subagent-registry-B9RPAXUs.js +2627 -0
- package/dist/subagent-registry-C7tedtVB.js +3 -0
- package/dist/subagent-registry.runtime.js +2 -2
- package/dist/subagent-session-cleanup-y0ijZ-LQ.js +390 -0
- package/dist/system-DVtrOGbV.js +111 -0
- package/dist/system-prompt-config-BVmrcmmr.js +918 -0
- package/dist/talk-CrdgqTCl.js +2454 -0
- package/dist/target-id-CrUyi-Uq.js +107 -0
- package/dist/targets-KZ2ezPwx.js +267 -0
- package/dist/targets.runtime-iZ8KdQ1C.js +2 -0
- package/dist/targets.runtime.js +1 -1
- package/dist/task-executor-893pMqzn.js +349 -0
- package/dist/task-owner-access-DC7MKz3n.js +74 -0
- package/dist/task-registry-control.runtime.js +2 -2
- package/dist/task-registry-delivery-runtime-YGMOyqP5.js +2 -0
- package/dist/task-registry-uaYJfgXF.js +2362 -0
- package/dist/task-registry.maintenance-Dx0m2NYh.js +2 -0
- package/dist/task-registry.maintenance-gApg-XOt.js +764 -0
- package/dist/task-status-access-CFhD_ieY.js +18 -0
- package/dist/tasks-B_Qoz38D.js +153 -0
- package/dist/tasks-DtV85zJT.js +548 -0
- package/dist/tasks-audit-system-Con3yYnm.js +210 -0
- package/dist/tasks-json-BM3pauZl.js +73 -0
- package/dist/tavily-web-search-provider.runtime-Cmyyc5kX.js +112 -0
- package/dist/tavily-web-search-provider.runtime.js +1 -1
- package/dist/text-report-CKxmVmt5.js +695 -0
- package/dist/text-transforms.runtime-DVwVsBRS.js +113 -0
- package/dist/text-transforms.runtime.js +1 -1
- package/dist/thread-bindings-B6UEVp9q.js +228 -0
- package/dist/tool-KOZc7TIF.js +143 -0
- package/dist/tool-dispatch-Ca4z2GEr.js +155 -0
- package/dist/tool-images-CzDwHeDR.js +247 -0
- package/dist/tool-plugin-BvQBJ2gU.js +93 -0
- package/dist/tool-resolution-Ddxl6tjh.js +153 -0
- package/dist/tool-result-truncation-BSKuIhd5.js +498 -0
- package/dist/tool-schema-nB27q-vb.js +40 -0
- package/dist/tool-schema-projection-COrMarLR.js +215 -0
- package/dist/tool-split-BjPHBFrv.js +323 -0
- package/dist/tools-CV40BWkc.js +901 -0
- package/dist/tools-catalog-5stC7W2V.js +156 -0
- package/dist/tools-effective-BVjqz2FV.js +442 -0
- package/dist/tools-effective-inventory-esPY5jRB.js +379 -0
- package/dist/tools-invoke-Czk_NM9G.js +51 -0
- package/dist/tools-invoke-http-D7PbsODz.js +68 -0
- package/dist/tools-invoke-shared-CzrEn0Dm.js +200 -0
- package/dist/tools-rSjgf61B.js +579 -0
- package/dist/tools.runtime-DiChCSGI.js +5 -0
- package/dist/tools.runtime.js +1 -1
- package/dist/transcript-rewrite-4IQefjvK.js +688 -0
- package/dist/transcripts-tool-BXTS8tE5.js +2 -0
- package/dist/transcripts-tool-CeWGgz5k.js +656 -0
- package/dist/tts-BS8EeM8p.js +2 -0
- package/dist/tts-BlTZjsaE.js +194 -0
- package/dist/tts-runtime-BfRdJDyY.js +1337 -0
- package/dist/tts-vRSvSw-t.js +3 -0
- package/dist/tts.runtime-ChBnVkNt.js +3 -0
- package/dist/tts.runtime-CmVCUbzq.js +2 -0
- package/dist/tts.runtime.js +1 -1
- package/dist/tui-BoQVBgWB.js +4860 -0
- package/dist/tui-DBYK9BeQ.js +2 -0
- package/dist/tui-backend-X0NI7rAv.js +256 -0
- package/dist/tui-cli-BpUtjV38.js +40 -0
- package/dist/typing-policy-CBwyAQh4.js +199 -0
- package/dist/usage-Bl-tgGx-.js +623 -0
- package/dist/usage-Cj_ektBl.js +1113 -0
- package/dist/usage-format-DWO9ckX3.js +394 -0
- package/dist/usage-format-DnCIXsqG.js +2 -0
- package/dist/video-generation-provider-B7ib4AeI.js +297 -0
- package/dist/video-generation-provider-CXQ6fqJx.js +64 -0
- package/dist/video-generation-provider-DXjl05T6.js +325 -0
- package/dist/video-generation-provider-Db8h71jA.js +77 -0
- package/dist/web-fetch/runtime.js +1 -1
- package/dist/web-fetch-providers.runtime-DhPkYjgB.js +41 -0
- package/dist/web-fetch-providers.runtime.js +1 -1
- package/dist/web-guarded-fetch-BdsVyvDS.js +58 -0
- package/dist/web-guarded-fetch-CJR3JCwT.js +2 -0
- package/dist/web-media-BzzQJAwk.js +4 -0
- package/dist/web-media-DViZjNBa.js +2 -0
- package/dist/web-media-inHawfBU.js +651 -0
- package/dist/web-provider-runtime-shared-Cc08Lt9p.js +142 -0
- package/dist/web-search-provider-common-CtbtmUL-.js +252 -0
- package/dist/web-search-providers.runtime-B7x_cRVn.js +41 -0
- package/dist/web-search-providers.runtime.js +1 -1
- package/dist/zod-schema.core-Cuz0lz6m.d.ts +166 -0
- package/package.json +1 -1
- package/dist/abort-CR0u3VsG.js +0 -277
- package/dist/abort.runtime-CXUxanGg.js +0 -2
- package/dist/accounts-BxBaquAf.js +0 -423
- package/dist/accounts-vQjpoqEe.js +0 -2
- package/dist/acp-spawn-2elSoS0E.js +0 -1286
- package/dist/acp-spawn-DtKOHNO1.js +0 -2
- package/dist/acp-stateful-target-driver-BqeA5j0h.js +0 -89
- package/dist/action-info-B8NotHFw.js +0 -75
- package/dist/active-runtime-registry-BO9mpPuB.js +0 -62
- package/dist/active-tool-schema-warnings-C8vGj5FX.js +0 -105
- package/dist/active-tool-schema-warnings-CVeFJuWI.js +0 -2
- package/dist/agent-BgEaDMdp.js +0 -1825
- package/dist/agent-_V5GbziF.js +0 -2
- package/dist/agent-bundle-lsp-runtime-0jBcDEHh.js +0 -389
- package/dist/agent-bundle-lsp-runtime-CQ6dZLs_.js +0 -2
- package/dist/agent-bundle-mcp-materialize-Cu6JqMzC.js +0 -124
- package/dist/agent-bundle-mcp-tools-BGL827cn.js +0 -3
- package/dist/agent-command-CMJdGr16.js +0 -1435
- package/dist/agent-delivery-DMu1MOeq.js +0 -117
- package/dist/agent-harness-runtime-BKSW2E1O.js +0 -207
- package/dist/agent-model-discovery-Cu4YL31r.js +0 -3
- package/dist/agent-model-discovery-DdmVtkZo.js +0 -238
- package/dist/agent-runner-utils-DXNDhwkI.js +0 -267
- package/dist/agent-runner.runtime-Cym4Odfd.js +0 -3784
- package/dist/agent-runtime-BkbhevY3.js +0 -199
- package/dist/agent-runtime-label-DNP06p76.js +0 -30
- package/dist/agent-runtime-metadata-JaTKc7mA.js +0 -53
- package/dist/agent-tool-result-middleware-loader-FbZE0Qpk.js +0 -55
- package/dist/agent-tools-Nwh8BlKX.js +0 -2506
- package/dist/agent-tools.before-tool-call-BwY-FYFl.js +0 -1274
- package/dist/agent-tools.before-tool-call-DwUmYhE3.js +0 -2
- package/dist/agent-u5NDWrw9.js +0 -3
- package/dist/agent-via-gateway-DMtOMwZa.js +0 -486
- package/dist/agent-wait-dedupe-CLuKbI_7.js +0 -180
- package/dist/agents-CiW7UEuB.js +0 -632
- package/dist/agents.command-shared-CXGSQscb.js +0 -16
- package/dist/agents.commands.add-BYBrZDXD.js +0 -304
- package/dist/agents.commands.bind-nfg3AlVc.js +0 -265
- package/dist/agents.commands.delete-pRj6vIrn.js +0 -128
- package/dist/agents.commands.identity-Ci2PnDDl.js +0 -143
- package/dist/agents.commands.list-Crj3BmqB.js +0 -235
- package/dist/aliases-BFspFx3-.js +0 -97
- package/dist/api-BiXhdPle.js +0 -3
- package/dist/api-Cptkjys5.js +0 -6
- package/dist/api-D3vT4ZVi.js +0 -2
- package/dist/api-key-rotation-CQgW8LEx.js +0 -167
- package/dist/app-registration-YW276fZC.js +0 -194
- package/dist/apply-BRxKrOiK.js +0 -510
- package/dist/apply-D0fWCa-U.js +0 -2
- package/dist/apply-DIR8y0ZA.js +0 -2
- package/dist/apply-DNUIV0Lt.js +0 -416
- package/dist/apply-Dux9jI7f.js +0 -544
- package/dist/approval-native-helpers-BMT-5X47.js +0 -398
- package/dist/artifacts-CTrtIv9T.js +0 -368
- package/dist/assistant-ClfI8Kho.js +0 -291
- package/dist/attachment-normalize-DAW86mZY.js +0 -213
- package/dist/attempt-execution-DTi2UfET.js +0 -584
- package/dist/attempt-execution.helpers-DrX0QToi.js +0 -969
- package/dist/attempt-execution.runtime-BCmAxwGy.js +0 -3
- package/dist/attempt.prompt-helpers-BE6kGRtT.js +0 -543
- package/dist/attempt.tool-run-context-J9O2yjbV.js +0 -1240
- package/dist/audio-preflight.runtime-D3GXVYBI.js +0 -7
- package/dist/audit-5T20D-xm.js +0 -1108
- package/dist/audit-CWuV5GlP.js +0 -477
- package/dist/audit.nondeep.runtime-DeYwRDYj.js +0 -1416
- package/dist/audit.runtime-rUlvK4Rb.js +0 -7
- package/dist/auth-DunUSatn.js +0 -567
- package/dist/auth-choice--eBzca8Y.js +0 -3
- package/dist/auth-choice-DJ9jsFUq.js +0 -400
- package/dist/auth-choice-_pLkIdVh.js +0 -110
- package/dist/auth-choice.apply.api-providers-CALcopRP.js +0 -2
- package/dist/auth-choice.apply.api-providers-Dzzm1snk.js +0 -34
- package/dist/auth-choice.plugin-providers.runtime-BHKTeZZc.js +0 -11
- package/dist/auth-health-Cs4OjiF2.js +0 -219
- package/dist/auth-list-bwJ4QDs0.js +0 -115
- package/dist/auth-order-BoHN3Dc_.js +0 -105
- package/dist/auth-profiles-BOLncVgy.js +0 -73
- package/dist/auth-profiles-BiQRkULt.js +0 -14
- package/dist/backend-config-B5yga5ay.js +0 -259
- package/dist/bash-tools-BWvldguc.js +0 -3
- package/dist/bash-tools-DEAAO5np.js +0 -3497
- package/dist/binding-routing-BbtHmU_l.js +0 -113
- package/dist/binding-targets-DSNv3-QA.js +0 -121
- package/dist/bootstrap-files-DD8V2dLe.js +0 -202
- package/dist/bootstrap-files-_6u1uJW2.js +0 -3
- package/dist/bridge-server-v1-XPnAZ.js +0 -113
- package/dist/browser-cli-CnpuO4KR.js +0 -230
- package/dist/browser-cli-DPbIn8SK.js +0 -2
- package/dist/browser-cli-actions-input-DoGR6LI-.js +0 -522
- package/dist/browser-cli-actions-observe-CYMpgmtF.js +0 -81
- package/dist/browser-cli-debug-ChJjSq-h.js +0 -137
- package/dist/browser-cli-inspect-Bbci-WPG.js +0 -117
- package/dist/browser-cli-manage-Bnscjb7b.js +0 -446
- package/dist/browser-cli-resize-D1MJdvZI.js +0 -32
- package/dist/browser-cli-shared-BCQwqz51.js +0 -69
- package/dist/browser-cli-state-BWkPsvUg.js +0 -371
- package/dist/browser-control-auth-CEP_ExeC.js +0 -2
- package/dist/browser-profiles-SvnqnHVN.js +0 -2
- package/dist/browser-runtime-0mRxjFpp.js +0 -389
- package/dist/browser-tool.schema--CLR3nDv.js +0 -132
- package/dist/btw-command-DV6HfrRV.js +0 -18
- package/dist/build-DiRmljCi.js +0 -261
- package/dist/bundled-channel-config-schema-Bte--ZlY.d.ts +0 -3168
- package/dist/capability-cli-ATfwTYFe.js +0 -1809
- package/dist/capability-provider-runtime-l3nnLGvn.js +0 -346
- package/dist/cdp.helpers-IIuc0KGS.js +0 -637
- package/dist/channel-CzTD2ouI.js +0 -2309
- package/dist/channel-actions-B5Yk5Axf.js +0 -46
- package/dist/channel-bootstrap.runtime-C9F-Pq1o.js +0 -38
- package/dist/channel-bootstrap.runtime-TPyY5Ngv.js +0 -2
- package/dist/channel-core-XMZJ-ZGF.js +0 -5
- package/dist/channel-inbound-DvqkKmiH.js +0 -121
- package/dist/channel-message-CnJ4vUyt.js +0 -12
- package/dist/channel-outbound-BhefGAqY.js +0 -436
- package/dist/channel-plugin-resolution-BiaJ8aRa.js +0 -2
- package/dist/channel-plugin-resolution-D_CxkMVc.js +0 -135
- package/dist/channel-resolution-DzI28gIM.js +0 -46
- package/dist/channel-selection-CLFO4-eQ.js +0 -171
- package/dist/channel-selection.runtime-Beb2-bMH.js +0 -2
- package/dist/channel.runtime-By5T5eGw.js +0 -697
- package/dist/channels-BrRY9Mag.js +0 -1004
- package/dist/channels-cli-CF--e2RU.js +0 -331
- package/dist/chat-BTMPilpx.js +0 -2940
- package/dist/chat-DnC7XCWK.js +0 -3
- package/dist/chrome-C3_dN9jE.js +0 -1517
- package/dist/chrome-mcp-5jjDHIgn.js +0 -864
- package/dist/chrome-mcp-DFAa-WzK.js +0 -2
- package/dist/claude-live-session-BUPeOzLE.js +0 -1338
- package/dist/claude-live-session-Bprgmr1-.js +0 -2
- package/dist/clawbot-cli-5UVkLT1Y.js +0 -9
- package/dist/cli-6a6sMEUB.js +0 -2
- package/dist/cli-COCN9B5e.js +0 -2
- package/dist/cli-CpI4dBXy.js +0 -141
- package/dist/cli-YLx-ekdH.js +0 -293
- package/dist/cli-backends.runtime-CsBjr7ag.js +0 -7
- package/dist/cli-compaction-Bh0oMwUa.js +0 -363
- package/dist/cli-registry-loader-DDbaAJgY.js +0 -2
- package/dist/cli-registry-loader-xc2Ah8S4.js +0 -193
- package/dist/cli-runner-BfSrIn-9.js +0 -597
- package/dist/cli-runner-D_FAjNbR.js +0 -2
- package/dist/cli-runner.runtime-BJetQDu1.js +0 -3
- package/dist/cli-runner.runtime-BKJQkc7C.js +0 -4
- package/dist/cli-session-Cy3IeH0g.js +0 -119
- package/dist/cli.runtime-BpOz0s3N.js +0 -1276
- package/dist/codex-native-web-search-BDtKRV3F.js +0 -4
- package/dist/codex-native-web-search-C0TrfoMX.js +0 -20
- package/dist/codex-native-web-search-core-CzlK1GfN.js +0 -106
- package/dist/command-auth-CFnvdYX2.js +0 -135
- package/dist/command-config-resolution-B_86rG8v.js +0 -2
- package/dist/command-config-resolution-BbadcA2M.js +0 -25
- package/dist/command-config-resolution.runtime-B_86rG8v.js +0 -2
- package/dist/command-execution-startup-Rrwwdg_5.js +0 -90
- package/dist/command-primitives-runtime-C9bTt5IV.js +0 -3
- package/dist/command-registry-CbpdQKmu.js +0 -9
- package/dist/command-registry-Dw-XC_Zk.js +0 -4
- package/dist/command-registry-core-rvEDki6p.js +0 -114
- package/dist/command-secret-gateway-BX6BIiFn.js +0 -589
- package/dist/command-secret-targets-DCzlTkb5.js +0 -2
- package/dist/command-status-builders-DIsZN9aY.js +0 -147
- package/dist/command-status.runtime-C2x4yMRd.js +0 -90
- package/dist/commands-FYCxWqIx.js +0 -161
- package/dist/commands-compact.runtime-BTMQfx1k.js +0 -10
- package/dist/commands-core.runtime-CuNLz2wm.js +0 -2
- package/dist/commands-handlers.runtime-DyNuPOmY.js +0 -6327
- package/dist/commands-models-s7BRmLQh.js +0 -448
- package/dist/commands-registry-BxEq-3UJ.js +0 -195
- package/dist/commands-registry.runtime-CbXW33S_.js +0 -4
- package/dist/commands-status-BRJMba4h.js +0 -16
- package/dist/commands-status-DCXEwlSF.js +0 -3
- package/dist/commands-status.runtime-DCXEwlSF.js +0 -3
- package/dist/commands-subagents-control.runtime-CduLQJFD.js +0 -2
- package/dist/commands-system-prompt-B3LD8CDs.js +0 -161
- package/dist/commands-system-prompt-DPsXTqOQ.js +0 -2
- package/dist/commands.runtime-3sVz8Qgo.js +0 -175
- package/dist/common-CZvBLb3w.js +0 -286
- package/dist/compact-DxU_9XEc.js +0 -1165
- package/dist/compact.runtime-CqQTypVl.js +0 -12
- package/dist/compaction-planning-DArTi9SN.js +0 -202
- package/dist/completion-cli-CiKl5HhI.js +0 -393
- package/dist/config--yllOaSC.js +0 -374
- package/dist/config-Yt5UcD91.js +0 -610
- package/dist/config-cli-BeXS3R6k.js +0 -1703
- package/dist/config-mutation-cQeWhUqy.js +0 -5
- package/dist/config-mutations-Cg04LH_S.js +0 -161
- package/dist/config-utils-Dhq_UKMC.js +0 -141
- package/dist/config-validation-BANohTKD.js +0 -33
- package/dist/configure-CWxhlx9G.js +0 -771
- package/dist/configure-Jejkc6dn.js +0 -3
- package/dist/configure.commands-BYy1bz8G.js +0 -2
- package/dist/configure.commands-C3hDvZse.js +0 -1253
- package/dist/context-DptQ59DZ.js +0 -248
- package/dist/context-_ZshNBhD.js +0 -2
- package/dist/context-engine-host-compat-C_eflvRw.js +0 -2
- package/dist/context-engine-host-compat-s15Pu845.js +0 -280
- package/dist/context-engine-lifecycle-COHFLnj4.js +0 -627
- package/dist/control-auth-CQJpLoIb.js +0 -114
- package/dist/control-service-BFSgA0Py.js +0 -40
- package/dist/control-service-D7GZv-GS.js +0 -3
- package/dist/control-ui/assets/activity-CCu43qU8.js +0 -124
- package/dist/control-ui/assets/agents-DCvsB0yO.js +0 -1030
- package/dist/control-ui/assets/channels-CpM2j5xT.js +0 -120
- package/dist/control-ui/assets/cron-CLXNfwYa.js +0 -1016
- package/dist/control-ui/assets/debug-BcJ34lrC.js +0 -97
- package/dist/control-ui/assets/index-CuBn2YpX.js +0 -7214
- package/dist/control-ui/assets/instances-Bu6NM_Hs.js +0 -57
- package/dist/control-ui/assets/nodes-Bd1WzVLK.js +0 -444
- package/dist/control-ui/assets/sessions-C2r8pbt7.js +0 -425
- package/dist/control-ui/assets/skills-DIjn93ee.js +0 -362
- package/dist/control-ui/assets/workboard-CHb0if1l.js +0 -402
- package/dist/control-ui-ChfTPXZo.js +0 -750
- package/dist/conversation-label-generator-CTfnInQF.js +0 -72
- package/dist/conversation-runtime-B7oAN9Tq.js +0 -31
- package/dist/core-api-CBD0dvTQ.js +0 -5
- package/dist/core-api-ClCm_yM8.js +0 -2
- package/dist/core-wuoxL08a.js +0 -284
- package/dist/crestodian--iYeGB8u.js +0 -55
- package/dist/cron-D2SzQyqo.js +0 -453
- package/dist/daemon-install-B6CAkU3V.js +0 -66
- package/dist/daemon-install-auth-profiles-store.runtime-Cpt5LSD6.js +0 -2
- package/dist/dashboard-ChYOQjM2.js +0 -263
- package/dist/defaults-CCopehWw.js +0 -130
- package/dist/defaults-H4kBp17N.js +0 -3
- package/dist/defaults.constants-CjB9HP6f.js +0 -76
- package/dist/deliver-BzPhWO_F.js +0 -3
- package/dist/deliver-DGyKH3Qi.js +0 -1399
- package/dist/deliver-runtime-Ca2kcQoZ.js +0 -2
- package/dist/delivery-outbound.runtime-D7ycPxY-.js +0 -7
- package/dist/delivery-queue-CnLv30ko.js +0 -863
- package/dist/delivery-queue-CuaDjNMh.js +0 -2
- package/dist/delivery-queue-runtime-DO2vqOIJ.js +0 -16
- package/dist/delivery-target.runtime-QcBVk_j8.js +0 -45
- package/dist/delivery.runtime-L09v4tys.js +0 -470
- package/dist/detached-task-runtime-BqU7YXYT.js +0 -86
- package/dist/diagnostics-T-Hk_Qzi.js +0 -168
- package/dist/dialogue-C0VnTMMn.js +0 -37
- package/dist/direct-dm-BWn67tDD.js +0 -81
- package/dist/directive-handling.defaults-DO6Snm4_.js +0 -22
- package/dist/directive-handling.fast-lane-BemYRfPn.js +0 -70
- package/dist/directive-handling.impl-BMVh1pMh.js +0 -823
- package/dist/directive-handling.impl-vr4MsYbt.js +0 -2
- package/dist/directive-handling.model-selection-DegP9exp.js +0 -122
- package/dist/directive-handling.persist.runtime-BUdU6_zm.js +0 -274
- package/dist/directives-1xk_ZcMf.js +0 -319
- package/dist/directory-cli-D83WEjEG.js +0 -239
- package/dist/dispatch-Ck2tvRYH.js +0 -2057
- package/dist/dispatch-acp-GdaHNdvf.js +0 -1102
- package/dist/dispatch-acp-manager.runtime-BGSrJqrW.js +0 -3
- package/dist/dispatch-acp-media.runtime-DQ8dYQh8.js +0 -4
- package/dist/dispatch-acp-transcript.runtime-CsJZGhnu.js +0 -40
- package/dist/dispatch-acp-tts.runtime-Bo-QxKgx.js +0 -3
- package/dist/dispatch-acp.runtime-C_u7sGcQ.js +0 -18
- package/dist/dispatcher-GtuYO6Ni.js +0 -106
- package/dist/doctor-B2qP9g8d.js +0 -760
- package/dist/doctor-D9wCez5t.js +0 -6
- package/dist/doctor-auth-XnseqtS7.js +0 -216
- package/dist/doctor-auth-flat-profiles-B6cL-TiJ.js +0 -516
- package/dist/doctor-auth-flat-profiles-Birb7qIk.js +0 -2
- package/dist/doctor-auth-legacy-oauth-CXO3OtyG.js +0 -48
- package/dist/doctor-auth-oauth-sidecar-BSgQPbcS.js +0 -177
- package/dist/doctor-auth-oauth-sidecar-CzzyNwxc.js +0 -2
- package/dist/doctor-bootstrap-size-BlVcO5D6.js +0 -57
- package/dist/doctor-claude-cli-_MTVnCQ-.js +0 -150
- package/dist/doctor-config-flow-0kxzjUjK.js +0 -1819
- package/dist/doctor-core-checks-C_g9REOd.js +0 -666
- package/dist/doctor-core-checks-CahzmM1L.js +0 -2
- package/dist/doctor-core-checks.runtime-Bi_oTiTZ.js +0 -278
- package/dist/doctor-gateway-daemon-flow-UAIWsI9w.js +0 -349
- package/dist/doctor-gateway-services-BiMEGiw_.js +0 -465
- package/dist/doctor-health-C69GVfMl.js +0 -65
- package/dist/doctor-health-contributions-Bz19QhI4.js +0 -874
- package/dist/doctor-lint-BVW4E6Qf.js +0 -95
- package/dist/doctor-memory-search-D2PWzDCY.js +0 -407
- package/dist/doctor-state-integrity-DuJIszQj.js +0 -1257
- package/dist/doctor-tool-result-cap-advice-Dpn4zNH3.js +0 -27
- package/dist/doctor-workspace-status-nW9TcIWi.js +0 -76
- package/dist/dreaming-CcOWzGN5.js +0 -523
- package/dist/dreaming-command-sxm3FQGb.js +0 -101
- package/dist/dreaming-narrative-BSRwiUPL.js +0 -2
- package/dist/dreaming-narrative-BskwmYdC.js +0 -721
- package/dist/dreaming-phases-BuHjGyPw.js +0 -2
- package/dist/dreaming-phases-ChVT8Ovk.js +0 -1162
- package/dist/drive-C_u5W4ln.js +0 -899
- package/dist/echo-transcript-tnZWH4EO.js +0 -52
- package/dist/effective-tool-policy-CeHdL2D7.js +0 -89
- package/dist/embedded-agent-CGULn3lb.js +0 -4
- package/dist/embedded-agent-DZTa1YiK.js +0 -4074
- package/dist/embedded-agent-helpers-B65K9o55.js +0 -6
- package/dist/embedded-agent-helpers-BPXCvWBb.js +0 -1037
- package/dist/embedded-agent.runtime-TfBgXcUV.js +0 -4
- package/dist/embedded-backend-BAaFwayA.js +0 -744
- package/dist/embedded-gateway-stub.runtime-CNyrjvgT.js +0 -12
- package/dist/embedding-provider-runtime-EnkHdROJ.js +0 -86
- package/dist/embedding-providers-CDkDb0kv.js +0 -2
- package/dist/embeddings-http-ClIu4_mP.js +0 -222
- package/dist/engine-qmd-DZRiT9i4.js +0 -708
- package/dist/engine-storage-BEqlN8TR.js +0 -203
- package/dist/errors-Co8auIlv.js +0 -2
- package/dist/exec-approval-forwarder.runtime-C7QvfWQ6.js +0 -4
- package/dist/exec-approval-session-target-ChuH1nXL.js +0 -177
- package/dist/exec-auto-reviewer-Bm7380HF.js +0 -2
- package/dist/exec-auto-reviewer-BrrdGleK.js +0 -241
- package/dist/execute.runtime-B-8jUqDB.js +0 -579
- package/dist/external-cli-auth-selection-0BxmRUps.js +0 -113
- package/dist/extra-params-BgyvpEpv.js +0 -615
- package/dist/fallback-notice-state-BXk_kRWM.js +0 -15
- package/dist/fallbacks-CPdVRP81.js +0 -31
- package/dist/fallbacks-shared-CSGf1oaf.js +0 -116
- package/dist/fengming-runtime-NUA51sEw.js +0 -33
- package/dist/fengming-runtime-config-CIZ-SHPt.js +0 -2
- package/dist/fengming-runtime-memory-CIZ-SHPt.js +0 -2
- package/dist/fengming-runtime-session-CIZ-SHPt.js +0 -2
- package/dist/fengming-tools-MvRSt0JA.js +0 -12221
- package/dist/flows-BocRit8D.js +0 -189
- package/dist/fs-utils-DSXeBcjj.js +0 -9
- package/dist/gateway-BCrUxrVw.js +0 -133
- package/dist/gateway-cli-B8bXBd_L.js +0 -443
- package/dist/gateway-install-token-pngTMc-f.js +0 -136
- package/dist/gateway-method-runtime-ueZTz7WH.js +0 -21
- package/dist/gateway-runtime-DbsoThML.js +0 -23
- package/dist/get-reply-DUuaxcBz.js +0 -5198
- package/dist/get-reply-from-config.runtime-B4Dgs3Hg.js +0 -2
- package/dist/github-copilot-token-7AfRRF7J.js +0 -2
- package/dist/health-7Yq5zpoZ.js +0 -3
- package/dist/health-DlZqxm2f.js +0 -621
- package/dist/health-DxesUuur.js +0 -111
- package/dist/health-state-BMG8kOby.js +0 -106
- package/dist/heartbeat-runner-Bq7A_Cjm.js +0 -5
- package/dist/heartbeat-runner-DVwbVyft.js +0 -1930
- package/dist/heartbeat-runner.runtime-DQ2NPXMD.js +0 -3
- package/dist/helpers-PCu2RivJ.js +0 -406
- package/dist/hook-helpers-DLEnCRO7.js +0 -44
- package/dist/hooks-Bv-otcl7.js +0 -536
- package/dist/hooks-cli-C5ve0nzF.js +0 -465
- package/dist/http-endpoint-helpers-w2SagsQz.js +0 -37
- package/dist/http-utils-CVvn0ZA-.js +0 -98
- package/dist/image-BeixBis4.js +0 -385
- package/dist/image-fallbacks-CPbmIMn9.js +0 -31
- package/dist/image-generation-core.auth.runtime-Co38iRxQ.js +0 -2
- package/dist/image-generation-provider-BA4Ar91S.js +0 -152
- package/dist/image-runtime-7ZsfioS1.js +0 -9
- package/dist/image-tool.helpers-upjA3ksB.js +0 -150
- package/dist/images-ChLi1Uog.js +0 -2
- package/dist/images-nB0XAnTa.js +0 -416
- package/dist/inbound-reply-dispatch-DglobJ8j.js +0 -2
- package/dist/inbound-reply-dispatch-QKOgNx-m.js +0 -147
- package/dist/index-AZzJCgph.d.ts +0 -1497
- package/dist/infra-runtime-CGD3RE_2.js +0 -32
- package/dist/init-poVZDCAM.js +0 -59
- package/dist/install-Dn9oPGmU.js +0 -262
- package/dist/install.runtime-D5sllsjl.js +0 -2
- package/dist/internal-CnOL_Roa.js +0 -399
- package/dist/isolated-agent-CNw6E3F0.js +0 -1097
- package/dist/isolated-agent-DjkHhEyR.js +0 -2
- package/dist/kernel-B5Y5IQ-A.js +0 -3
- package/dist/kernel-CMuO4VJy.js +0 -979
- package/dist/kimi-web-search-provider.runtime-V4m_MHsk.js +0 -307
- package/dist/library-B-1EZjtY.js +0 -45
- package/dist/lifecycle-B-5gEZ7O.js +0 -570
- package/dist/lifecycle-Bzh5Jo09.js +0 -2
- package/dist/lifecycle-DvbcJYMl.js +0 -355
- package/dist/lifecycle.runtime-Bzh5Jo09.js +0 -2
- package/dist/list-B4xSHRdU.js +0 -2
- package/dist/list-BnhZHpxx.js +0 -207
- package/dist/list.list-command-DAz-Ws_6.js +0 -429
- package/dist/list.model-row-DtdX9KDu.js +0 -39
- package/dist/list.probe-CY6lxq51.js +0 -2
- package/dist/list.probe-DPuE1GOH.js +0 -451
- package/dist/list.provider-catalog-BHc9WXI6.js +0 -211
- package/dist/list.provider-catalog-CFbrroys.js +0 -2
- package/dist/list.registry-load-C1_sr3gb.js +0 -152
- package/dist/list.row-sources-BMtHc9oi.js +0 -474
- package/dist/list.source-plan-Dth72qPP.js +0 -81
- package/dist/list.status-command-BXCnEq8Q.js +0 -815
- package/dist/live-model-switch-Dxav22vq.js +0 -119
- package/dist/llm-slug-generator-6o8RXL11.js +0 -78
- package/dist/load-config-EF3n0Dyo.js +0 -27
- package/dist/load-context-CI_ogQt_.js +0 -82
- package/dist/loader-DtwEzpp-.js +0 -7008
- package/dist/local-dispatch.runtime-21liE3rA.js +0 -10
- package/dist/main-session-restart-recovery-D1g62iJ5.js +0 -2
- package/dist/main-session-restart-recovery-v2I9CEXi.js +0 -389
- package/dist/managed-image-attachments-BEl5qfCT.js +0 -616
- package/dist/managed-image-attachments-D5KqX2Qy.js +0 -2
- package/dist/manager-DZc3xiNq.js +0 -2314
- package/dist/manager-Vf3vLTGe.js +0 -3737
- package/dist/mcp-http-BaJoPKF9.js +0 -583
- package/dist/mcp-http-CpEaJIGJ.js +0 -2
- package/dist/media-runtime-DtP_Ff8m.js +0 -391
- package/dist/media-services-CXYbyIIp.js +0 -416
- package/dist/media-understanding-DvTIsIyr.js +0 -87
- package/dist/media-understanding-provider-DBBAvuwG.js +0 -13
- package/dist/media-understanding-provider-DOf_uZrx.js +0 -70
- package/dist/media-understanding-provider-DdRfNh9h.js +0 -69
- package/dist/media-understanding-provider-mqpQDt8V.js +0 -29
- package/dist/memory-BNk25Hi6.js +0 -437
- package/dist/memory-core-host-engine-embeddings-XsK5xS70.js +0 -667
- package/dist/memory-core-host-engine-foundation-BYkoOLXl.js +0 -15
- package/dist/memory-core-host-engine-qmd-0JuUCKCK.js +0 -2
- package/dist/memory-core-host-engine-storage-MCFGjDwW.js +0 -2
- package/dist/memory-core-host-runtime-cli-fVGH65E8.js +0 -10
- package/dist/memory-core-host-runtime-core-JtXIAdlM.js +0 -12
- package/dist/memory-core-host-runtime-files-BGw_ypoN.js +0 -4
- package/dist/memory-embedding-provider-runtime-3UBzs4sx.js +0 -36
- package/dist/memory-host-core-Y_O5V-mu.js +0 -78
- package/dist/memory-host-search.runtime-B4TzyvmR.js +0 -2
- package/dist/memory-runtime-9kEPAeKV.js +0 -2
- package/dist/memory-runtime-BU4t85uu.js +0 -57
- package/dist/memory-search-CVX--mSz.js +0 -235
- package/dist/message-BVXoNpWP.js +0 -284
- package/dist/message-HaiKqj0A.js +0 -2
- package/dist/message-action-runner-Chwzn02r.js +0 -2
- package/dist/message-action-runner-tEEliptt.js +0 -1922
- package/dist/message-handler-CHDS_NF-.js +0 -1806
- package/dist/metadata-registry-loader-Croa1pgR.js +0 -22
- package/dist/metadata-registry-loader-w0p86vis.js +0 -2
- package/dist/migrate-CPCZJ4H5.js +0 -2
- package/dist/migrate-CUj6m6Cx.js +0 -458
- package/dist/migration-provider-runtime-4r4WGtf2.js +0 -2
- package/dist/migration-provider-runtime-TxrH_mM7.js +0 -68
- package/dist/minimax-web-search-provider.runtime-Dr2GJiWj.js +0 -148
- package/dist/model-BQSouNOa.js +0 -2
- package/dist/model-CAk0bcuO.js +0 -1302
- package/dist/model-auth-BF7w9Fiv.js +0 -705
- package/dist/model-auth-label-r729wcPk.js +0 -67
- package/dist/model-auth-us8b_D5d.js +0 -6
- package/dist/model-catalog-BGykBGxx.js +0 -434
- package/dist/model-catalog-BVXrqFbI.js +0 -3
- package/dist/model-catalog-visibility-Bsup46vy.js +0 -76
- package/dist/model-config.helpers-wzD1EEfE.js +0 -95
- package/dist/model-context-tokens-DrIU9eJc.js +0 -572
- package/dist/model-fallback-GySPjr3J.js +0 -1288
- package/dist/model-fallback-auth.runtime-Dg_Jmguu.js +0 -5
- package/dist/model-picker-BI6jXOjt.js +0 -3
- package/dist/model-picker-DYyJHhfH.js +0 -1135
- package/dist/model-picker-visibility-D_IMZfxd.js +0 -22
- package/dist/model-picker.runtime-B70kQMyc.js +0 -48
- package/dist/model-pricing-cache-CSpUDzSt.js +0 -856
- package/dist/model-pricing-cache-dkPwTUVJ.js +0 -3
- package/dist/model-pricing-cache-state-C6shoEWy.js +0 -83
- package/dist/model-provider-auth-BfZHbTaj.js +0 -2
- package/dist/model-provider-auth-CPCBWvqL.js +0 -375
- package/dist/model-runtime-aliases-DUzusc9_.js +0 -133
- package/dist/model-selection-8UzO5mgF.js +0 -254
- package/dist/model-selection-Cb7azWw1.js +0 -7
- package/dist/model-selection-jDYEo0WI.js +0 -352
- package/dist/model-selection.runtime-D_yHZLbs.js +0 -7
- package/dist/models-BxA2IU3W.js +0 -57
- package/dist/models-auth-status-yG7yyRcv.js +0 -280
- package/dist/models-cli-DUt4uiMH.js +0 -257
- package/dist/models-config-B5bkuh6A.js +0 -1189
- package/dist/models-config-Xj8vG_x2.js +0 -2
- package/dist/models-config.providers.secrets-DNBB440Z.js +0 -2
- package/dist/models-config.providers.secrets-DNIQlBSE.js +0 -382
- package/dist/models-http-DMILRsry.js +0 -88
- package/dist/monitor-2_c2Ttjf.js +0 -1024
- package/dist/monitor-7tD_FE_5.js +0 -60
- package/dist/monitor.account-D0F9tnWD.js +0 -5382
- package/dist/music-generation-provider-3ykPaUwR.js +0 -308
- package/dist/native-hook-relay-BJKHIhWd.js +0 -1378
- package/dist/native-hook-relay-V8Kappw1.js +0 -19
- package/dist/node-cli-BLVyQ93e.js +0 -2806
- package/dist/node-command-policy-B0ezpI_O.js +0 -295
- package/dist/nodes-DnWH_15m.js +0 -3
- package/dist/nodes-RkB4ZmP6.js +0 -1483
- package/dist/nodes-cli-upwPs91b.js +0 -960
- package/dist/nodes-pending--sojaxpI.js +0 -211
- package/dist/nodes-utils-Yks_uDZK.js +0 -85
- package/dist/oauth-CQN2efEy.js +0 -207
- package/dist/oauth-DApi3OI9.js +0 -746
- package/dist/oauth-DkUWBub2.js +0 -852
- package/dist/onboard-CiQSBSrz.js +0 -768
- package/dist/onboard-channels-DaWYXiLv.js +0 -1534
- package/dist/onboard-channels-DnwM2_IL.js +0 -2
- package/dist/onboard-custom-BQPckD0V.js +0 -3
- package/dist/onboard-custom-config-BmbThk2-.js +0 -422
- package/dist/onboard-custom-xInFj1Rs.js +0 -280
- package/dist/onboard-search-DSfmthe5.js +0 -412
- package/dist/openai-compat-errors-VR4SN1MV.js +0 -136
- package/dist/openai-http-DV95ynPi.js +0 -836
- package/dist/openai-transport-stream-BwpzqR-b.js +0 -3427
- package/dist/openresponses-http-DPchx8IC.js +0 -1175
- package/dist/operations-f9R8j-r9.js +0 -805
- package/dist/order-BQx8mNGZ.js +0 -218
- package/dist/outbound-attachment-C4yojK6p.js +0 -19
- package/dist/param-readers-BIXyd5la.js +0 -2
- package/dist/payloads-DrY1bKyF.js +0 -256
- package/dist/persistent-bindings.lifecycle-BiPN7luW.js +0 -85
- package/dist/persistent-bindings.lifecycle-X3wfan2Z.js +0 -2
- package/dist/plugin-enabled-CqsBObeO.js +0 -232
- package/dist/plugin-install-CfB1_kpX.js +0 -118
- package/dist/plugin-install-DzMraXHH.js +0 -2
- package/dist/plugin-install-config-policy-BD_elPNg.js +0 -169
- package/dist/plugin-registration-Dy58ncPf.js +0 -97
- package/dist/plugin-registry-BlmODeop.js +0 -3
- package/dist/plugin-registry-k5OK18l5.js +0 -2
- package/dist/plugin-runtime-B3t53CKr.js +0 -102
- package/dist/plugin-sdk/bundled-channel-config-schema-UtIBjviA.d.ts +0 -3169
- package/dist/plugin-service-sKF4gWFm.js +0 -1249
- package/dist/plugins-authoring-command-I72k2cuv.js +0 -304
- package/dist/plugins-cli-DMQRbPsU.js +0 -63
- package/dist/plugins-cli.runtime-CvDuKFJj.js +0 -339
- package/dist/plugins-command-helpers-C5WMM4bk.js +0 -164
- package/dist/plugins-command-helpers-DDt_pMQ4.js +0 -2
- package/dist/plugins-inspect-command-ka7Hpld3.js +0 -248
- package/dist/plugins-install-command-BHSgof-_.js +0 -2
- package/dist/plugins-install-command-t5caX9q_.js +0 -993
- package/dist/plugins-install-persist-Bah1m3x7.js +0 -252
- package/dist/plugins-list-command-BXLWwXHM.js +0 -184
- package/dist/plugins-uninstall-command-C_3m6CrW.js +0 -118
- package/dist/prepare.runtime-COZaHg5E.js +0 -798
- package/dist/presentation-card-CciJv4ru.js +0 -164
- package/dist/preview-warnings-L4VuEOyB.js +0 -618
- package/dist/profiles-CM2xoUYX.js +0 -194
- package/dist/program-B-4C7bC-.js +0 -131
- package/dist/provider-adapters-Eh8mS2Fd.js +0 -104
- package/dist/provider-api-key-auth-DTh2cbmS.js +0 -117
- package/dist/provider-api-key-auth.runtime-DrTYYfxK.js +0 -14
- package/dist/provider-auth-Bnaijzmv.js +0 -281
- package/dist/provider-auth-api-key-CNP8o5E7.js +0 -5
- package/dist/provider-auth-choice-Devw4sQf.js +0 -311
- package/dist/provider-auth-choice-helpers-DmVudRp6.js +0 -210
- package/dist/provider-auth-choice.runtime-C337IQ3W.js +0 -2
- package/dist/provider-auth-choice.runtime-DqGYalFo.js +0 -18
- package/dist/provider-auth-guidance-Bk4WV6Lg.js +0 -2
- package/dist/provider-auth-guidance-C7NCKuKn.js +0 -34
- package/dist/provider-auth-helpers-r7mC8I5l.js +0 -177
- package/dist/provider-auth-login.runtime-BFJgAAS6.js +0 -156
- package/dist/provider-auth-runtime-BiLPGiMW.js +0 -186
- package/dist/provider-discovery-uxRmAIf_.js +0 -95
- package/dist/provider-discovery.runtime-mwbSivDS.js +0 -290
- package/dist/provider-dispatcher-CtKWj3r-.js +0 -22
- package/dist/provider-entry-DjACqdrB.js +0 -134
- package/dist/provider-hook-runtime-CpJsM7Dk.js +0 -255
- package/dist/provider-openai-codex-oauth-DWGmVUYg.js +0 -2
- package/dist/provider-openai-codex-oauth-ctxd00JW.js +0 -44
- package/dist/provider-registration-l8EX4voM.js +0 -235
- package/dist/provider-registry-BgIQXJle.js +0 -31
- package/dist/provider-registry-CVuzobHN.js +0 -36
- package/dist/provider-registry-DmdDbSQs.js +0 -61
- package/dist/provider-registry-LqtLqheu.js +0 -61
- package/dist/provider-registry-pTYVjODc.js +0 -61
- package/dist/provider-runtime-BQZSuC9l.js +0 -3
- package/dist/provider-runtime-D9Q-7VuO.js +0 -386
- package/dist/provider-runtime.runtime-C6YZ8YI0.js +0 -26
- package/dist/provider-self-hosted-setup-BIAD2ISe.js +0 -373
- package/dist/provider-stream-DScdaoRo.js +0 -313
- package/dist/provider-stream-PE0IxmpZ.js +0 -1084
- package/dist/provider-stream-family-S2fhlydZ.js +0 -2
- package/dist/provider-usage-DVKHMF6l.js +0 -4
- package/dist/provider-usage-EEjx1av0.js +0 -71
- package/dist/provider-usage.load-Cu11xbrw.js +0 -357
- package/dist/provider-web-search-Dbk7MO-1.js +0 -58
- package/dist/provider-wizard-DS2Xb2eu.js +0 -125
- package/dist/providers.runtime-BPhGcupv.js +0 -240
- package/dist/providers.runtime-DoylK-ht.js +0 -2
- package/dist/proxy-BxacG0p3.js +0 -662
- package/dist/public-artifacts-Dq3y7bBv.js +0 -7
- package/dist/pw-ai-DlSSqerW.js +0 -3064
- package/dist/qmd-manager-B_SG-ejE.js +0 -2040
- package/dist/qr-cli-CT-sE_j9.js +0 -2
- package/dist/qr-cli-DPlDCXJQ.js +0 -371
- package/dist/qr-image--VmmvuDB.js +0 -2
- package/dist/queue-Be2Y7PcO.js +0 -923
- package/dist/read-file-hhemkDfq.js +0 -183
- package/dist/register-service-commands-CeVpCQU3.js +0 -77
- package/dist/register.agent-JLsb-giw.js +0 -152
- package/dist/register.configure-CP0Q-ost.js +0 -16
- package/dist/register.crestodian-CBXyXEix.js +0 -24
- package/dist/register.maintenance-DGIPQ2Vo.js +0 -85
- package/dist/register.message-BBQwz0Ld.js +0 -404
- package/dist/register.migrate-CkgNlvLD.js +0 -106
- package/dist/register.onboard-CS9gRK0c.js +0 -115
- package/dist/register.setup-DhqDOer9.js +0 -40
- package/dist/register.status-health-sessions-CiwQN_lw.js +0 -293
- package/dist/register.subclis-86Md7P0P.js +0 -3
- package/dist/register.subclis-CTVI8zvZ.js +0 -31
- package/dist/register.subclis-core-Cy4AnRCu.js +0 -273
- package/dist/rem-harness-vSsq3HiK.js +0 -649
- package/dist/repair-sequencing-SHADYdcA.js +0 -652
- package/dist/reply-media-paths.runtime-Bf5nxPuP.js +0 -154
- package/dist/reply-media-paths.runtime-sLsMpKGO.js +0 -2
- package/dist/reply-payloads-CJ3w8rSA.js +0 -79
- package/dist/reply-payloads-dedupe-DDFXWCVR.js +0 -176
- package/dist/reply-payloads-dedupe.runtime-DbXPzKmG.js +0 -2
- package/dist/reply-timing-tracker-DjVIBsVb.js +0 -205
- package/dist/reply-turn-admission-nEW5QbY5.js +0 -2056
- package/dist/reply.runtime-B4Dgs3Hg.js +0 -2
- package/dist/reset-preserved-selection-CVD1yeVC.js +0 -45
- package/dist/resolve-DidlinMh.js +0 -106
- package/dist/restart-DzTrO95c.js +0 -121
- package/dist/result-fallback-classifier-BqsFUDvP.js +0 -98
- package/dist/root-help-QGs0dCCN.js +0 -43
- package/dist/route-B3R-uzFG.js +0 -475
- package/dist/route-reply-CdfhgIoY.js +0 -174
- package/dist/route-reply.runtime-DwuU2WjH.js +0 -2
- package/dist/routes-ChXmJocl.js +0 -3701
- package/dist/routes-D-ZF4AdA.js +0 -2
- package/dist/run-ClmVDTET.js +0 -1162
- package/dist/run-auth-profile.runtime-CTxrwz0y.js +0 -2
- package/dist/run-command-CqZJQ0Im.js +0 -2
- package/dist/run-command-GClW75NL.js +0 -23
- package/dist/run-context-BOdGeRg5.js +0 -66
- package/dist/run-context.runtime-CwuKVYPj.js +0 -2
- package/dist/run-delivery.runtime-BQ39dm34.js +0 -762
- package/dist/run-embedded.runtime-e1K4Bt1_.js +0 -4
- package/dist/run-execution-cli.runtime-Cjrgt4cV.js +0 -4
- package/dist/run-executor.runtime-C2JE6JGb.js +0 -330
- package/dist/run-model-catalog.runtime-DkrLKopr.js +0 -2
- package/dist/run-session-state-C5YdQs7o.js +0 -159
- package/dist/run-subagent-registry.runtime-Dl_lXi6y.js +0 -2
- package/dist/runner-CNGHdaIg.js +0 -704
- package/dist/runner.entries-dckPkeld.js +0 -1485
- package/dist/runtime-9LxcVCyw.js +0 -615
- package/dist/runtime-BCOtBS5G.js +0 -3
- package/dist/runtime-C-pgjoJr.js +0 -210
- package/dist/runtime-CyF0vJXG.js +0 -10
- package/dist/runtime-D-7lMvGV.js +0 -2
- package/dist/runtime-D17OmF9G.js +0 -224
- package/dist/runtime-D6SweufG.js +0 -245
- package/dist/runtime-DVAM7AFd.js +0 -2
- package/dist/runtime-DX2ClrP-.js +0 -436
- package/dist/runtime-FOOWuiYX.js +0 -300
- package/dist/runtime-api-B0F0JsV1.js +0 -12
- package/dist/runtime-cREKSBYC.js +0 -2
- package/dist/runtime-channel-BmD4hoCR.js +0 -148
- package/dist/runtime-channel-BsebQSPL.js +0 -2
- package/dist/runtime-config-collectors-BjYeQ0Tk.js +0 -525
- package/dist/runtime-embedded-agent.runtime-A4r23Bn8.js +0 -2
- package/dist/runtime-internal-DkV-EMTK.js +0 -2
- package/dist/runtime-llm.runtime-BQKNnuRc.js +0 -307
- package/dist/runtime-model-auth.runtime-BbGqHVM5.js +0 -2
- package/dist/runtime-model-auth.runtime-rtJH4LBB.js +0 -46
- package/dist/runtime-options-B0EGb1Wq.js +0 -275
- package/dist/runtime-plugin-Bdqm44bH.js +0 -92
- package/dist/runtime-plugins-rZk1eAK_.js +0 -32
- package/dist/runtime-plugins.runtime-DApiYzny.js +0 -2
- package/dist/runtime-prepare.runtime-DWxvnbyY.js +0 -81
- package/dist/runtime-provider-B0slPjtk.js +0 -2
- package/dist/runtime-provider-DLgupOKt.js +0 -24
- package/dist/runtime-registry-loader-Cf2HuMjd.js +0 -2
- package/dist/runtime-registry-loader-DLzDrA7e.js +0 -117
- package/dist/runtime-shared-Bg-OiD4u.js +0 -365
- package/dist/runtime-web-channel-plugin-DrMjRaqi.js +0 -204
- package/dist/scan-DA7Oqxuv.js +0 -573
- package/dist/sdk-security-runtime-WjOaCbga.js +0 -86
- package/dist/sdk-setup-tools-DaYT6_jD.js +0 -8
- package/dist/secrets-cli-fJQ0geWO.js +0 -150
- package/dist/security-cli-CJMwGp8U.js +0 -520
- package/dist/selection-BNwLQzqJ.js +0 -3
- package/dist/selection-Cj-l80pO.js +0 -18365
- package/dist/send-DstYcrDW.js +0 -711
- package/dist/send-aTxtLkJm.js +0 -178
- package/dist/send-media-OG5Gd31l.js +0 -2072
- package/dist/send-qwDMMnM6.js +0 -1222
- package/dist/send-result-BWRKr16H.js +0 -141
- package/dist/server-CMtA1S09.js +0 -24
- package/dist/server-DIRaYiiH.js +0 -72
- package/dist/server-aux-handlers-BRO-9-Jf.js +0 -1347
- package/dist/server-chat-0J_ke0ph.js +0 -827
- package/dist/server-context-DWOSX34k.js +0 -2
- package/dist/server-context-R7MFLFdI.js +0 -955
- package/dist/server-cron-2FuFg2j8.js +0 -2
- package/dist/server-cron-ChPAVQtg.js +0 -3173
- package/dist/server-maintenance-ZvS7Id6T.js +0 -152
- package/dist/server-methods-DSbhPK3k.js +0 -497
- package/dist/server-middleware-CYxFU-e5.js +0 -122
- package/dist/server-model-catalog-B22UhmRr.js +0 -73
- package/dist/server-model-catalog-BJIHPP3P.js +0 -2
- package/dist/server-node-events-tNWJnXQM.js +0 -597
- package/dist/server-plugin-bootstrap-Ccu97zi8.js +0 -71
- package/dist/server-plugins-ByXwKPnj.js +0 -435
- package/dist/server-reload-handlers-ConGiT9Q.js +0 -719
- package/dist/server-restart-sentinel-mPHo61LL.js +0 -700
- package/dist/server-runtime-services-BR1icaUW.js +0 -3
- package/dist/server-runtime-services-Bx8n34dj.js +0 -147
- package/dist/server-runtime-subscriptions-CZklTkRG.js +0 -67
- package/dist/server-session-events-DxdiZYM2.js +0 -244
- package/dist/server-session-key-CYvLslFO.js +0 -75
- package/dist/server-session-key-D9GQut81.js +0 -2
- package/dist/server-startup-config-Byb0vR8j.js +0 -305
- package/dist/server-startup-early-a65fHTQS.js +0 -87
- package/dist/server-startup-memory-ClwzC9jX.js +0 -72
- package/dist/server-startup-plugins-CaBj0Nt2.js +0 -127
- package/dist/server-startup-post-attach-B7TcxkmO.js +0 -793
- package/dist/server-ws-runtime-Cxk_CqMr.js +0 -374
- package/dist/server.impl-CQ6dnx43.js +0 -2622
- package/dist/session-cost-usage-GsYDNvka.js +0 -1600
- package/dist/session-kill-http-CKkxZhhd.js +0 -121
- package/dist/session-log-runtime-Bwc2Oijk.js +0 -1258
- package/dist/session-override-CWbKiXiC.js +0 -134
- package/dist/session-reset-model.runtime-CDFMjwWA.js +0 -144
- package/dist/session-reset-service-SE0aK4cw.js +0 -651
- package/dist/session-status.runtime-Df89I7Fk.js +0 -2
- package/dist/session-store-RkvjJPMQ.js +0 -273
- package/dist/session-store.runtime-C7P5asx7.js +0 -4
- package/dist/session-subagent-reactivation.runtime-BhGUZG1Z.js +0 -2
- package/dist/session-tab-registry-9rSuQ0Yz.js +0 -551
- package/dist/session-utils-De8TIM0h.js +0 -1508
- package/dist/sessions-6b9a00Tl.js +0 -1917
- package/dist/sessions-CEPHczjC.js +0 -316
- package/dist/sessions-CEojHc8b.js +0 -12736
- package/dist/sessions-cleanup-BkG7_sq9.js +0 -165
- package/dist/sessions-history-http-BjJEfjJa.js +0 -432
- package/dist/sessions-patch-PwG5sknc.js +0 -401
- package/dist/sessions-resolve-CSIrd_fi.js +0 -180
- package/dist/sessions-table-8CbU7jXa.js +0 -161
- package/dist/sessions.runtime-BYHMD0M7.js +0 -2
- package/dist/set-BJDpe28W.js +0 -31
- package/dist/set-image-CwTFx7PX.js +0 -17
- package/dist/setup-B6LmeIms.js +0 -614
- package/dist/setup-B_zxHfYu.js +0 -2
- package/dist/setup-onboard-configure-help-fast-path-Bck3SKEH.js +0 -64
- package/dist/setup.finalize-CmLYX-Rf.js +0 -586
- package/dist/setup.gateway-config-H_89Msro.js +0 -281
- package/dist/setup.migration-import-DVzyUjX6.js +0 -2
- package/dist/setup.migration-import-DmJpqoqf.js +0 -200
- package/dist/setup.post-install-migration-WPFWKXXg.js +0 -128
- package/dist/shared-CUhu8NTs.js +0 -5
- package/dist/shared-D-BN2JhY.js +0 -71
- package/dist/shared-ES8nDIcn.js +0 -212
- package/dist/simple-completion-runtime-BGZkWvKr.js +0 -206
- package/dist/simple-completion-runtime-CM_IISYW.js +0 -2
- package/dist/simple-completion-transport-Bo0u9dhp.js +0 -83
- package/dist/snapshot-urls-C1KjRQD5.js +0 -317
- package/dist/speech-core-Bas7e4h0.js +0 -119
- package/dist/speech-provider-BonJQv5S.js +0 -227
- package/dist/speech-provider-CwdKQmDv.js +0 -171
- package/dist/speech-provider-DcQRnYhZ.js +0 -233
- package/dist/stale-oauth-profile-shadows-C3aeAWfv.js +0 -186
- package/dist/stale-oauth-profile-shadows-m5rb8dPc.js +0 -2
- package/dist/standalone-runtime-registry-loader-B9n2LBKC.js +0 -59
- package/dist/startup-context-DY7C4riM.js +0 -314
- package/dist/status-6EPKat7p.js +0 -73
- package/dist/status-C6Fa7Dsf.js +0 -2
- package/dist/status-CNnxDQlM.js +0 -4
- package/dist/status-D2Scvbc0.js +0 -3
- package/dist/status-Ducanro3.js +0 -2
- package/dist/status-_XX_6QVA.js +0 -466
- package/dist/status-all-BP1u6vou.js +0 -573
- package/dist/status-json-DPlOJ_ue.js +0 -15
- package/dist/status-json-command-BT7EwVKj.js +0 -84
- package/dist/status-message-Dzr9-MX-.js +0 -495
- package/dist/status-message.runtime-DFezIt1d.js +0 -6
- package/dist/status-prBlcUV5.js +0 -249
- package/dist/status-queue.runtime-C1bmg2rl.js +0 -2
- package/dist/status-runtime-shared-RjKIPEQ0.js +0 -289
- package/dist/status-subagents.runtime-tsCCe4Ny.js +0 -32
- package/dist/status-text-Bkeyg8Bf.js +0 -301
- package/dist/status.command-D06_4ATq.js +0 -425
- package/dist/status.command-dDEZM84a.js +0 -2
- package/dist/status.command.text-runtime-WH9tP7yg.js +0 -15
- package/dist/status.runtime-B76GaBIR.js +0 -2
- package/dist/status.scan-Bc6clx0F.js +0 -72
- package/dist/status.scan-overview-v_-AaFhC.js +0 -460
- package/dist/status.scan.deps.runtime-BkH1HAb4.js +0 -19
- package/dist/status.scan.fast-json-CrlfKKI3.js +0 -2
- package/dist/status.scan.fast-json-D8v6zfP8.js +0 -163
- package/dist/status.summary-DBhvgOPr.js +0 -276
- package/dist/status.summary-hQV0PKFO.js +0 -2
- package/dist/store-BClomp_4.js +0 -3
- package/dist/store-BHqDPtNw.js +0 -2302
- package/dist/stored-model-override-vm4CtQWX.js +0 -79
- package/dist/subagent-announce-D244Q4w2.js +0 -353
- package/dist/subagent-announce-delivery-qKZfF7Bs.js +0 -1369
- package/dist/subagent-control-c87mVGUE.js +0 -492
- package/dist/subagent-control.runtime-DfQtIsDb.js +0 -3
- package/dist/subagent-hooks-B_UW5Len.js +0 -2
- package/dist/subagent-hooks-CYvFWt_r.js +0 -230
- package/dist/subagent-hooks-api-DZgaJf19.js +0 -23
- package/dist/subagent-registry-BlcoCggo.js +0 -2627
- package/dist/subagent-registry-CuObhNeO.js +0 -3
- package/dist/subagent-session-cleanup-hFF8Z34s.js +0 -390
- package/dist/system-CN_Knfqq.js +0 -111
- package/dist/system-prompt-config-BmZlhYK9.js +0 -918
- package/dist/talk-DrjGczYs.js +0 -2454
- package/dist/target-id-BNpbyWkq.js +0 -107
- package/dist/targets-CQcGo6u4.js +0 -267
- package/dist/targets.runtime-DwcxNI-x.js +0 -2
- package/dist/task-executor-CZg-qt4u.js +0 -349
- package/dist/task-owner-access-Duem5jjb.js +0 -74
- package/dist/task-registry-Cw8pc3Ry.js +0 -2362
- package/dist/task-registry-delivery-runtime-HaiKqj0A.js +0 -2
- package/dist/task-registry.maintenance-BLv3wpK9.js +0 -764
- package/dist/task-registry.maintenance-CvlIcxE-.js +0 -2
- package/dist/task-status-access-C5nDJSI4.js +0 -18
- package/dist/tasks-D3CfEAlq.js +0 -548
- package/dist/tasks-WKnE5fvr.js +0 -153
- package/dist/tasks-audit-system-okJjcOjU.js +0 -210
- package/dist/tasks-json-C-iUgWNu.js +0 -73
- package/dist/tavily-web-search-provider.runtime-jpagljrA.js +0 -112
- package/dist/text-report-BTsF3Pv3.js +0 -695
- package/dist/text-transforms.runtime-CgH_pbcQ.js +0 -113
- package/dist/thread-bindings-BWxpUE9U.js +0 -228
- package/dist/tool-DhJbbm91.js +0 -143
- package/dist/tool-dispatch-CpFUfblu.js +0 -155
- package/dist/tool-images-C-tFlXjE.js +0 -247
- package/dist/tool-plugin-3NejWxZW.js +0 -93
- package/dist/tool-resolution-oW8Cbamd.js +0 -153
- package/dist/tool-result-truncation-CWFGf7Eu.js +0 -498
- package/dist/tool-schema-CMtc7PdZ.js +0 -40
- package/dist/tool-schema-projection-DJRPEEvY.js +0 -215
- package/dist/tool-split-E4RdK5jS.js +0 -323
- package/dist/tools-BAl3JiNw.js +0 -901
- package/dist/tools-DC8tCPxR.js +0 -579
- package/dist/tools-catalog-Dzv9zaBD.js +0 -156
- package/dist/tools-effective-CGvzyIL2.js +0 -442
- package/dist/tools-effective-inventory-GI5N5Q9v.js +0 -379
- package/dist/tools-invoke-CU2U0hNH.js +0 -51
- package/dist/tools-invoke-http-8s3FiUy4.js +0 -68
- package/dist/tools-invoke-shared-DIETrEY7.js +0 -200
- package/dist/tools.runtime-Bnm8CI7w.js +0 -5
- package/dist/transcript-rewrite-Buv2ITw4.js +0 -688
- package/dist/transcripts-tool-BCFlLCFd.js +0 -2
- package/dist/transcripts-tool-CWgNd0Uw.js +0 -656
- package/dist/tts-Aguo4zC5.js +0 -3
- package/dist/tts-Bf77cURn.js +0 -2
- package/dist/tts-DnADOKOP.js +0 -194
- package/dist/tts-runtime-MBSH-nOM.js +0 -1337
- package/dist/tts.runtime-B-NR9osE.js +0 -2
- package/dist/tts.runtime-Bo-QxKgx.js +0 -3
- package/dist/tui-B0CdNmCz.js +0 -4860
- package/dist/tui-ByRcXM3Z.js +0 -2
- package/dist/tui-backend-C52BUoZI.js +0 -256
- package/dist/tui-cli-BQHpZ4n0.js +0 -40
- package/dist/typing-policy-XspVOezC.js +0 -199
- package/dist/usage-BOYwzimH.js +0 -1113
- package/dist/usage-BSmLrVWB.js +0 -623
- package/dist/usage-format-CfzICmvv.js +0 -2
- package/dist/usage-format-DPJKCPic.js +0 -394
- package/dist/video-generation-provider-CdCTztQ7.js +0 -77
- package/dist/video-generation-provider-MUUshUzz.js +0 -325
- package/dist/video-generation-provider-XmzzTa6e.js +0 -297
- package/dist/video-generation-provider-weiQUJE5.js +0 -64
- package/dist/web-fetch-providers.runtime-tD9zqAS2.js +0 -41
- package/dist/web-guarded-fetch-CyhQZ1yD.js +0 -2
- package/dist/web-guarded-fetch-DIXHI-yJ.js +0 -58
- package/dist/web-media-BPnTMYE5.js +0 -4
- package/dist/web-media-DV_tCQiQ.js +0 -2
- package/dist/web-media-DYydVGCK.js +0 -651
- package/dist/web-provider-runtime-shared-h3M6Bqyg.js +0 -142
- package/dist/web-search-provider-common-CEYWuDcp.js +0 -252
- package/dist/web-search-providers.runtime-YrayP296.js +0 -41
- package/dist/zod-schema.core-BGLctDlK.d.ts +0 -166
- /package/dist/{acp-runtime-backend-CHZtaM6t.js → acp-runtime-backend-B83JR5Zf.js} +0 -0
- /package/dist/{agent-turn-attachments-BYCRK86s.js → agent-turn-attachments-D5uJijuK.js} +0 -0
- /package/dist/{auth-install-policy-t46tJ8jV.js → auth-install-policy-BIpdwrZ9.js} +0 -0
- /package/dist/{cli-backends-BHXnrVN_.js → cli-backends-79CCRQ2a.js} +0 -0
- /package/dist/{command-secret-targets-DZ0J2Wm3.js → command-secret-targets-BOJlcBil.js} +0 -0
- /package/dist/{commands-DWp49Exc.js → commands-Dw9hwmVt.js} +0 -0
- /package/dist/{commands-reset-hooks-MMq2dvff.js → commands-reset-hooks-epArfNOY.js} +0 -0
- /package/dist/{delegate-Dkj_5OvH.js → delegate-Bw8NQXVr.js} +0 -0
- /package/dist/{jobs-BGELIHcx.js → jobs-BIOTaq7l.js} +0 -0
- /package/dist/{kimi-web-search-provider-4PlMYsPx.js → kimi-web-search-provider-Bzg_DiXO.js} +0 -0
- /package/dist/{memory-host-search-Ds9GiNpf.js → memory-host-search-Dph0Mq-v.js} +0 -0
- /package/dist/{minimax-web-search-provider-d5gTJUNg.js → minimax-web-search-provider-CETxDkkI.js} +0 -0
- /package/dist/{model-selection-cli-CO6BHPiL.js → model-selection-cli-DizUvxeY.js} +0 -0
- /package/dist/{provider-auth-choice-preference-f7Us6TQL.js → provider-auth-choice-preference-uJn1811S.js} +0 -0
- /package/dist/{runtime-wfO9bV5y.js → runtime-BEVbpIgZ.js} +0 -0
- /package/dist/{runtime-web-tools-B6vr1LZs.js → runtime-web-tools-Bf0aEe-F.js} +0 -0
- /package/dist/{runtime-web-tools-fallback.runtime-Crs7KfH5.js → runtime-web-tools-fallback.runtime-DU6rTj6l.js} +0 -0
- /package/dist/{session-subagent-reactivation-H5Rdwkyy.js → session-subagent-reactivation-Bb5SCi9J.js} +0 -0
- /package/dist/{tavily-web-search-provider-DbdIzpMv.js → tavily-web-search-provider-CIEhV60D.js} +0 -0
|
@@ -0,0 +1,3427 @@
|
|
|
1
|
+
import { a as normalizeLowercaseStringOrEmpty, p as readStringValue } from "./string-coerce-DKw2K5wM.js";
|
|
2
|
+
import { s as redactSensitiveText } from "./redact-1XrMj58n.js";
|
|
3
|
+
import { _ as parseStrictPositiveInteger, g as parseStrictNonNegativeInteger, m as parseStrictFiniteNumber, o as asFiniteNumberInRange, u as clampTimerTimeoutMs } from "./number-coercion-D1aDmIZp.js";
|
|
4
|
+
import "./parse-finite-number-CpgOyjPq.js";
|
|
5
|
+
import { o as isRecord } from "./record-coerce-Btbek4uV.js";
|
|
6
|
+
import { _ as uniqueStrings, l as normalizeStringEntries } from "./string-normalization-B8G0vlWE.js";
|
|
7
|
+
import { t as createSubsystemLogger } from "./subsystem-46gngkCY.js";
|
|
8
|
+
import { d as isLinkLocalIpAddress, g as parseCanonicalIpAddress, o as isCloudMetadataIpAddress } from "./ip-CMU4Hu-8.js";
|
|
9
|
+
import { c as shouldUseEnvHttpProxyForUrl } from "./proxy-env-emgTBjFN.js";
|
|
10
|
+
import { b as ssrfPolicyFromHttpBaseUrlAllowedOrigin, m as mergeSsrFPolicies, x as ssrfPolicyFromHttpBaseUrlFakeIpHostnameAllowlist } from "./ssrf-CSnp9Gml.js";
|
|
11
|
+
import { a as withTrustedEnvProxyGuardedFetchMode, n as fetchWithSsrFGuard } from "./fetch-guard-CXmTAV-g.js";
|
|
12
|
+
import { F as resolveProviderTransportTurnStateWithPlugin } from "./provider-runtime-DNNbfwOK.js";
|
|
13
|
+
import { t as asBoolean } from "./boolean-CZag3-H2.js";
|
|
14
|
+
import { c as hasCopilotVisionInput, o as buildCopilotDynamicHeaders } from "./copilot-dynamic-headers-CVy4X1Kj.js";
|
|
15
|
+
import { c as resolveProviderRequestPolicyConfig, i as mergeModelProviderRequestOverrides, n as buildProviderRequestDispatcherPolicy, r as getModelProviderRequestTransport } from "./provider-request-config-D6EBylE2.js";
|
|
16
|
+
import { t as redactIdentifier } from "./redact-identifier-BI6BTlLC.js";
|
|
17
|
+
import { n as repairToolUseResultPairing } from "./session-transcript-repair-Y9Ze9H7m.js";
|
|
18
|
+
import { o as calculateCost } from "./sanitize-unicode-8KnR9CZq.js";
|
|
19
|
+
import { r as createAssistantMessageEventStream } from "./event-stream-DexlShPz.js";
|
|
20
|
+
import { n as getEnvApiKey } from "./env-api-keys-DrHBA-r2.js";
|
|
21
|
+
import { n as parseStreamingJson } from "./json-parse-BXBkuUPf.js";
|
|
22
|
+
import { t as estimateStringChars } from "./cjk-chars-BtjJDifS.js";
|
|
23
|
+
import { l as detectOpenAICompletionsCompat } from "./provider-model-compat-L-UePNrg.js";
|
|
24
|
+
import { t as resolveAzureDeploymentNameFromMap } from "./azure-deployment-map-DoNnsBna.js";
|
|
25
|
+
import { t as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-D8Qty_Hp.js";
|
|
26
|
+
import { t as convertMessages } from "./openai-completions-EP2oCCrB.js";
|
|
27
|
+
import { i as resolveOpenAIStrictToolSetting, n as normalizeOpenAIStrictToolParameters, r as resolveOpenAIStrictToolFlagForInventory, t as findOpenAIStrictToolSchemaDiagnostics } from "./openai-tool-schema-D9MLjAGB.js";
|
|
28
|
+
import { r as resolveDebugProxySettings } from "./env-vk5F7eaL.js";
|
|
29
|
+
import { n as ensureModelProviderLocalService } from "./provider-local-service-BJ_bOLRi.js";
|
|
30
|
+
import { n as sanitizeInlineImageDataUrl } from "./inline-image-data-url-n2BKwW65.js";
|
|
31
|
+
import { i as stripSystemPromptCacheBoundary } from "./system-prompt-cache-boundary-Dlr-f5oA.js";
|
|
32
|
+
import { h as truncateErrorDetail } from "./provider-http-errors-D7gji-go.js";
|
|
33
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
34
|
+
import OpenAI, { AzureOpenAI } from "openai";
|
|
35
|
+
//#region src/agents/model-transport-debug.ts
|
|
36
|
+
function normalizeEnv(value) {
|
|
37
|
+
return typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
38
|
+
}
|
|
39
|
+
function isTruthyEnv(value) {
|
|
40
|
+
const normalized = normalizeEnv(value);
|
|
41
|
+
return normalized.length > 0 && normalized !== "0" && normalized !== "false" && normalized !== "off" && normalized !== "no";
|
|
42
|
+
}
|
|
43
|
+
function resolveModelPayloadDebugMode(env = process.env) {
|
|
44
|
+
const normalized = normalizeEnv(env.FENGMING_DEBUG_MODEL_PAYLOAD);
|
|
45
|
+
if (normalized === "tools" || normalized === "full-redacted") return normalized;
|
|
46
|
+
if (normalized === "summary") return "summary";
|
|
47
|
+
return "off";
|
|
48
|
+
}
|
|
49
|
+
function resolveModelSseDebugMode(env = process.env) {
|
|
50
|
+
const normalized = normalizeEnv(env.FENGMING_DEBUG_SSE);
|
|
51
|
+
if (normalized === "peek") return "peek";
|
|
52
|
+
if (normalized === "events" || isTruthyEnv(normalized)) return "events";
|
|
53
|
+
return "off";
|
|
54
|
+
}
|
|
55
|
+
function isModelTransportDebugEnabled(env = process.env) {
|
|
56
|
+
return isTruthyEnv(env.FENGMING_DEBUG_MODEL_TRANSPORT) || resolveModelPayloadDebugMode(env) !== "off" || resolveModelSseDebugMode(env) !== "off" || isTruthyEnv(env.FENGMING_DEBUG_CODE_MODE);
|
|
57
|
+
}
|
|
58
|
+
function emitModelTransportDebug(log, message) {
|
|
59
|
+
if (isModelTransportDebugEnabled()) {
|
|
60
|
+
log.info(message);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
log.debug(message);
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/agents/openai-completions-string-content.ts
|
|
67
|
+
function flattenStringOnlyCompletionContent(content) {
|
|
68
|
+
if (!Array.isArray(content)) return content;
|
|
69
|
+
const textParts = [];
|
|
70
|
+
for (const item of content) {
|
|
71
|
+
if (!item || typeof item !== "object" || item.type !== "text" || typeof item.text !== "string") return content;
|
|
72
|
+
textParts.push(item.text);
|
|
73
|
+
}
|
|
74
|
+
return textParts.join("\n");
|
|
75
|
+
}
|
|
76
|
+
function flattenCompletionMessagesToStringContent(messages) {
|
|
77
|
+
return messages.map((message) => {
|
|
78
|
+
if (!message || typeof message !== "object") return message;
|
|
79
|
+
const content = message.content;
|
|
80
|
+
const flattenedContent = flattenStringOnlyCompletionContent(content);
|
|
81
|
+
if (flattenedContent === content) return message;
|
|
82
|
+
return {
|
|
83
|
+
...message,
|
|
84
|
+
content: flattenedContent
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function stripCompletionMessagesToRoleContent(messages) {
|
|
89
|
+
return messages.map((message) => {
|
|
90
|
+
if (!message || typeof message !== "object" || Array.isArray(message)) return message;
|
|
91
|
+
const record = message;
|
|
92
|
+
const stripped = {};
|
|
93
|
+
if (Object.prototype.hasOwnProperty.call(record, "role")) stripped.role = record.role;
|
|
94
|
+
if (Object.prototype.hasOwnProperty.call(record, "content")) stripped.content = record.content;
|
|
95
|
+
return stripped;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/agents/openai-reasoning-effort.ts
|
|
100
|
+
const GPT_5_REASONING_EFFORTS = [
|
|
101
|
+
"minimal",
|
|
102
|
+
"low",
|
|
103
|
+
"medium",
|
|
104
|
+
"high"
|
|
105
|
+
];
|
|
106
|
+
const GPT_51_REASONING_EFFORTS = [
|
|
107
|
+
"none",
|
|
108
|
+
"low",
|
|
109
|
+
"medium",
|
|
110
|
+
"high"
|
|
111
|
+
];
|
|
112
|
+
const GPT_52_REASONING_EFFORTS = [
|
|
113
|
+
"none",
|
|
114
|
+
"low",
|
|
115
|
+
"medium",
|
|
116
|
+
"high",
|
|
117
|
+
"xhigh"
|
|
118
|
+
];
|
|
119
|
+
const GPT_CODEX_REASONING_EFFORTS = [
|
|
120
|
+
"low",
|
|
121
|
+
"medium",
|
|
122
|
+
"high",
|
|
123
|
+
"xhigh"
|
|
124
|
+
];
|
|
125
|
+
const GPT_PRO_REASONING_EFFORTS = [
|
|
126
|
+
"medium",
|
|
127
|
+
"high",
|
|
128
|
+
"xhigh"
|
|
129
|
+
];
|
|
130
|
+
const GPT_5_PRO_REASONING_EFFORTS = ["high"];
|
|
131
|
+
const GPT_51_CODEX_MAX_REASONING_EFFORTS = [
|
|
132
|
+
"none",
|
|
133
|
+
"medium",
|
|
134
|
+
"high",
|
|
135
|
+
"xhigh"
|
|
136
|
+
];
|
|
137
|
+
const GPT_51_CODEX_MINI_REASONING_EFFORTS = ["medium"];
|
|
138
|
+
const GENERIC_REASONING_EFFORTS = [
|
|
139
|
+
"low",
|
|
140
|
+
"medium",
|
|
141
|
+
"high"
|
|
142
|
+
];
|
|
143
|
+
function normalizeModelId(id) {
|
|
144
|
+
return normalizeLowercaseStringOrEmpty(id ?? "").replace(/-\d{4}-\d{2}-\d{2}$/u, "");
|
|
145
|
+
}
|
|
146
|
+
function isOpenAIGpt54MiniModel(model) {
|
|
147
|
+
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
148
|
+
return /^gpt-5\.4-mini(?:-|$)/u.test(id);
|
|
149
|
+
}
|
|
150
|
+
function normalizeOpenAIReasoningEffort(effort) {
|
|
151
|
+
return effort === "minimal" ? "minimal" : effort;
|
|
152
|
+
}
|
|
153
|
+
function readCompatReasoningEfforts(compat) {
|
|
154
|
+
if (!compat || typeof compat !== "object") return;
|
|
155
|
+
if (compat.supportsReasoningEffort === false) return [];
|
|
156
|
+
const raw = compat.supportedReasoningEfforts;
|
|
157
|
+
if (!Array.isArray(raw)) return;
|
|
158
|
+
const supported = uniqueStrings(normalizeStringEntries(raw.filter((value) => typeof value === "string")));
|
|
159
|
+
return supported.length > 0 ? supported : void 0;
|
|
160
|
+
}
|
|
161
|
+
function isDisabledReasoningEffort(effort) {
|
|
162
|
+
return effort === "none" || effort === "off";
|
|
163
|
+
}
|
|
164
|
+
function resolveOpenAISupportedReasoningEfforts(model) {
|
|
165
|
+
const compatEfforts = readCompatReasoningEfforts(model.compat);
|
|
166
|
+
if (compatEfforts) return compatEfforts;
|
|
167
|
+
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
168
|
+
if (id === "gpt-5.1-codex-mini") return GPT_51_CODEX_MINI_REASONING_EFFORTS;
|
|
169
|
+
if (id === "gpt-5.1-codex-max") return GPT_51_CODEX_MAX_REASONING_EFFORTS;
|
|
170
|
+
if (/^gpt-5(?:\.\d+)?-codex(?:-|$)/u.test(id)) return GPT_CODEX_REASONING_EFFORTS;
|
|
171
|
+
if (id === "gpt-5-pro") return GPT_5_PRO_REASONING_EFFORTS;
|
|
172
|
+
if (/^gpt-5\.[2-9](?:\.\d+)?-pro(?:-|$)/u.test(id)) return GPT_PRO_REASONING_EFFORTS;
|
|
173
|
+
if (/^gpt-5\.[2-9](?:\.\d+)?(?:-|$)/u.test(id)) return GPT_52_REASONING_EFFORTS;
|
|
174
|
+
if (/^gpt-5\.1(?:-|$)/u.test(id)) return GPT_51_REASONING_EFFORTS;
|
|
175
|
+
if (/^gpt-5(?:-|$)/u.test(id)) return GPT_5_REASONING_EFFORTS;
|
|
176
|
+
return GENERIC_REASONING_EFFORTS;
|
|
177
|
+
}
|
|
178
|
+
function supportsOpenAIReasoningEffort(model, effort) {
|
|
179
|
+
return resolveOpenAISupportedReasoningEfforts(model).includes(normalizeOpenAIReasoningEffort(effort));
|
|
180
|
+
}
|
|
181
|
+
function resolveOpenAIReasoningEffortForModel(params) {
|
|
182
|
+
const requested = normalizeOpenAIReasoningEffort(params.effort);
|
|
183
|
+
const normalized = normalizeOpenAIReasoningEffort(params.fallbackMap?.[requested] ?? requested);
|
|
184
|
+
const supported = resolveOpenAISupportedReasoningEfforts(params.model);
|
|
185
|
+
if (supported.includes(normalized)) return normalized;
|
|
186
|
+
if (isDisabledReasoningEffort(requested) || isDisabledReasoningEffort(normalized)) return;
|
|
187
|
+
if (requested === "minimal" && supported.includes("low")) return "low";
|
|
188
|
+
if ((requested === "minimal" || requested === "low") && supported.includes("medium")) return "medium";
|
|
189
|
+
if (requested === "xhigh" && supported.includes("high")) return "high";
|
|
190
|
+
return supported.find((effort) => effort !== "none");
|
|
191
|
+
}
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/agents/openai-responses-payload-policy.ts
|
|
194
|
+
const OPENAI_RESPONSES_APIS = new Set([
|
|
195
|
+
"openai-responses",
|
|
196
|
+
"azure-openai-responses",
|
|
197
|
+
"openai-codex-responses",
|
|
198
|
+
"fengming-openai-responses-transport"
|
|
199
|
+
]);
|
|
200
|
+
const OPENAI_RESPONSES_PROVIDERS = new Set([
|
|
201
|
+
"openai",
|
|
202
|
+
"azure-openai",
|
|
203
|
+
"azure-openai-responses"
|
|
204
|
+
]);
|
|
205
|
+
const LOCAL_ENDPOINT_HOSTS = new Set([
|
|
206
|
+
"localhost",
|
|
207
|
+
"127.0.0.1",
|
|
208
|
+
"::1",
|
|
209
|
+
"[::1]"
|
|
210
|
+
]);
|
|
211
|
+
const MODELSTUDIO_NATIVE_BASE_URLS = new Set([
|
|
212
|
+
"https://coding-intl.dashscope.aliyuncs.com/v1",
|
|
213
|
+
"https://coding.dashscope.aliyuncs.com/v1",
|
|
214
|
+
"https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
215
|
+
"https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
|
|
216
|
+
]);
|
|
217
|
+
const MOONSHOT_NATIVE_BASE_URLS = new Set(["https://api.moonshot.ai/v1", "https://api.moonshot.cn/v1"]);
|
|
218
|
+
function normalizeLowercaseString(value) {
|
|
219
|
+
const stringValue = readStringValue(value)?.trim().toLowerCase();
|
|
220
|
+
return stringValue ? stringValue : void 0;
|
|
221
|
+
}
|
|
222
|
+
function normalizeComparableBaseUrl(value) {
|
|
223
|
+
const trimmed = readStringValue(value)?.trim();
|
|
224
|
+
if (!trimmed) return;
|
|
225
|
+
const parsedValue = /^[a-z0-9.[\]-]+(?::\d+)?(?:[/?#].*)?$/i.test(trimmed) ? `https://${trimmed}` : trimmed;
|
|
226
|
+
try {
|
|
227
|
+
const url = new URL(parsedValue);
|
|
228
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return;
|
|
229
|
+
url.hash = "";
|
|
230
|
+
url.search = "";
|
|
231
|
+
return url.toString().replace(/\/+$/, "").toLowerCase();
|
|
232
|
+
} catch {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function resolveUrlHostname(value) {
|
|
237
|
+
const trimmed = readStringValue(value)?.trim();
|
|
238
|
+
if (!trimmed) return;
|
|
239
|
+
try {
|
|
240
|
+
return new URL(trimmed).hostname.toLowerCase();
|
|
241
|
+
} catch {
|
|
242
|
+
try {
|
|
243
|
+
return new URL(`https://${trimmed}`).hostname.toLowerCase();
|
|
244
|
+
} catch {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function hostMatchesSuffix(host, suffix) {
|
|
250
|
+
return suffix.startsWith(".") || suffix.startsWith("-") ? host.endsWith(suffix) : host === suffix || host.endsWith(`.${suffix}`);
|
|
251
|
+
}
|
|
252
|
+
function isLocalEndpointHost(host) {
|
|
253
|
+
return LOCAL_ENDPOINT_HOSTS.has(host) || host.endsWith(".localhost") || host.endsWith(".local") || host.endsWith(".internal");
|
|
254
|
+
}
|
|
255
|
+
function resolveBundledOpenAIResponsesEndpointClass(baseUrl) {
|
|
256
|
+
const trimmed = readStringValue(baseUrl)?.trim();
|
|
257
|
+
if (!trimmed) return "default";
|
|
258
|
+
const host = resolveUrlHostname(trimmed);
|
|
259
|
+
if (!host) return "invalid";
|
|
260
|
+
const comparableBaseUrl = normalizeComparableBaseUrl(trimmed);
|
|
261
|
+
switch (host) {
|
|
262
|
+
case "api.anthropic.com": return "anthropic-public";
|
|
263
|
+
case "api.cerebras.ai": return "cerebras-native";
|
|
264
|
+
case "llm.chutes.ai": return "chutes-native";
|
|
265
|
+
case "api.deepseek.com": return "deepseek-native";
|
|
266
|
+
case "api.groq.com": return "groq-native";
|
|
267
|
+
case "api.mistral.ai": return "mistral-public";
|
|
268
|
+
case "api.openai.com": return "openai-public";
|
|
269
|
+
case "chatgpt.com": return "openai-codex";
|
|
270
|
+
case "generativelanguage.googleapis.com": return "google-generative-ai";
|
|
271
|
+
case "aiplatform.googleapis.com": return "google-vertex";
|
|
272
|
+
case "api.x.ai": return "xai-native";
|
|
273
|
+
case "api.z.ai": return "zai-native";
|
|
274
|
+
}
|
|
275
|
+
if (hostMatchesSuffix(host, ".githubcopilot.com")) return "github-copilot-native";
|
|
276
|
+
if (hostMatchesSuffix(host, ".openai.azure.com")) return "azure-openai";
|
|
277
|
+
if (hostMatchesSuffix(host, "openrouter.ai")) return "openrouter";
|
|
278
|
+
if (hostMatchesSuffix(host, "opencode.ai")) return "opencode-native";
|
|
279
|
+
if (hostMatchesSuffix(host, "-aiplatform.googleapis.com")) return "google-vertex";
|
|
280
|
+
if (comparableBaseUrl && MOONSHOT_NATIVE_BASE_URLS.has(comparableBaseUrl)) return "moonshot-native";
|
|
281
|
+
if (comparableBaseUrl && MODELSTUDIO_NATIVE_BASE_URLS.has(comparableBaseUrl)) return "modelstudio-native";
|
|
282
|
+
if (isLocalEndpointHost(host)) return "local";
|
|
283
|
+
return "custom";
|
|
284
|
+
}
|
|
285
|
+
function isOpenAIResponsesApi(api) {
|
|
286
|
+
return api !== void 0 && OPENAI_RESPONSES_APIS.has(api);
|
|
287
|
+
}
|
|
288
|
+
function readCompatPayloadBoolean(compat, key) {
|
|
289
|
+
if (!compat || typeof compat !== "object") return;
|
|
290
|
+
return asBoolean(compat[key]);
|
|
291
|
+
}
|
|
292
|
+
function resolveOpenAIResponsesPayloadCapabilities(model) {
|
|
293
|
+
const provider = normalizeLowercaseString(model.provider);
|
|
294
|
+
const api = normalizeLowercaseString(model.api);
|
|
295
|
+
const isOpenAIProvider = provider === "openai" || provider === "openai-codex";
|
|
296
|
+
const endpointClass = resolveBundledOpenAIResponsesEndpointClass(model.baseUrl);
|
|
297
|
+
const isResponsesApi = isOpenAIResponsesApi(api);
|
|
298
|
+
const usesConfiguredBaseUrl = endpointClass !== "default";
|
|
299
|
+
const usesKnownNativeOpenAIEndpoint = endpointClass === "openai-public" || endpointClass === "openai-codex" || endpointClass === "azure-openai";
|
|
300
|
+
const usesKnownNativeOpenAIRoute = endpointClass === "default" ? provider === "openai" : usesKnownNativeOpenAIEndpoint;
|
|
301
|
+
const usesExplicitProxyLikeEndpoint = usesConfiguredBaseUrl && !usesKnownNativeOpenAIEndpoint;
|
|
302
|
+
const promptCacheKeySupport = readCompatPayloadBoolean(model.compat, "supportsPromptCacheKey");
|
|
303
|
+
const shouldStripResponsesPromptCache = promptCacheKeySupport === true ? false : promptCacheKeySupport === false ? isResponsesApi : isResponsesApi && usesExplicitProxyLikeEndpoint;
|
|
304
|
+
const supportsResponsesStoreField = readCompatPayloadBoolean(model.compat, "supportsStore") !== false && isResponsesApi;
|
|
305
|
+
return {
|
|
306
|
+
allowsOpenAIServiceTier: provider === "openai" && (api === "openai-responses" || api === "fengming-openai-responses-transport") && endpointClass === "openai-public" || isOpenAIProvider && (api === "openai-codex-responses" || api === "openai-responses" || api === "fengming-openai-responses-transport") && endpointClass === "openai-codex",
|
|
307
|
+
allowsResponsesStore: supportsResponsesStoreField && api !== "openai-codex-responses" && provider !== void 0 && OPENAI_RESPONSES_PROVIDERS.has(provider) && usesKnownNativeOpenAIEndpoint,
|
|
308
|
+
shouldStripResponsesPromptCache,
|
|
309
|
+
supportsResponsesStoreField,
|
|
310
|
+
usesKnownNativeOpenAIRoute
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function parsePositiveInteger(value) {
|
|
314
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value);
|
|
315
|
+
if (typeof value === "string") return parseStrictPositiveInteger(value);
|
|
316
|
+
}
|
|
317
|
+
function resolveOpenAIResponsesCompactThreshold(model) {
|
|
318
|
+
const contextWindow = parsePositiveInteger(model.contextWindow);
|
|
319
|
+
if (contextWindow) return Math.max(1e3, Math.floor(contextWindow * .7));
|
|
320
|
+
return 8e4;
|
|
321
|
+
}
|
|
322
|
+
function shouldEnableOpenAIResponsesServerCompaction(explicitStore, provider, extraParams) {
|
|
323
|
+
const configured = extraParams?.responsesServerCompaction;
|
|
324
|
+
if (configured === false) return false;
|
|
325
|
+
if (explicitStore !== true) return false;
|
|
326
|
+
if (configured === true) return true;
|
|
327
|
+
return provider === "openai";
|
|
328
|
+
}
|
|
329
|
+
function stripDisabledOpenAIReasoningPayload(payloadObj) {
|
|
330
|
+
const reasoning = payloadObj.reasoning;
|
|
331
|
+
if (reasoning === "none") {
|
|
332
|
+
delete payloadObj.reasoning;
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (!reasoning || typeof reasoning !== "object" || Array.isArray(reasoning)) return;
|
|
336
|
+
if (reasoning.effort === "none") delete payloadObj.reasoning;
|
|
337
|
+
}
|
|
338
|
+
function resolveOpenAIResponsesPayloadPolicy(model, options = {}) {
|
|
339
|
+
const capabilities = resolveOpenAIResponsesPayloadCapabilities(model);
|
|
340
|
+
const storeMode = options.storeMode ?? "provider-policy";
|
|
341
|
+
const explicitStore = storeMode === "preserve" ? void 0 : storeMode === "disable" ? capabilities.supportsResponsesStoreField ? false : void 0 : capabilities.allowsResponsesStore ? true : void 0;
|
|
342
|
+
const isResponsesApi = isOpenAIResponsesApi(normalizeLowercaseString(model.api));
|
|
343
|
+
const shouldStripDisabledReasoningPayload = isResponsesApi && (!capabilities.usesKnownNativeOpenAIRoute || !supportsOpenAIReasoningEffort(model, "none"));
|
|
344
|
+
return {
|
|
345
|
+
allowsServiceTier: capabilities.allowsOpenAIServiceTier,
|
|
346
|
+
compactThreshold: parsePositiveInteger(options.extraParams?.responsesCompactThreshold) ?? resolveOpenAIResponsesCompactThreshold(model),
|
|
347
|
+
explicitStore,
|
|
348
|
+
shouldStripDisabledReasoningPayload,
|
|
349
|
+
shouldStripPromptCache: options.enablePromptCacheStripping === true && capabilities.shouldStripResponsesPromptCache,
|
|
350
|
+
shouldStripStore: explicitStore !== true && readCompatPayloadBoolean(model.compat, "supportsStore") === false && isResponsesApi,
|
|
351
|
+
useServerCompaction: options.enableServerCompaction === true && shouldEnableOpenAIResponsesServerCompaction(explicitStore, model.provider, options.extraParams)
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
function applyOpenAIResponsesPayloadPolicy(payloadObj, policy) {
|
|
355
|
+
if (policy.explicitStore !== void 0) payloadObj.store = policy.explicitStore;
|
|
356
|
+
if (policy.shouldStripStore) delete payloadObj.store;
|
|
357
|
+
if (policy.shouldStripPromptCache) {
|
|
358
|
+
delete payloadObj.prompt_cache_key;
|
|
359
|
+
delete payloadObj.prompt_cache_retention;
|
|
360
|
+
}
|
|
361
|
+
if (policy.useServerCompaction && payloadObj.context_management === void 0) payloadObj.context_management = [{
|
|
362
|
+
type: "compaction",
|
|
363
|
+
compact_threshold: policy.compactThreshold
|
|
364
|
+
}];
|
|
365
|
+
if (policy.shouldStripDisabledReasoningPayload) stripDisabledOpenAIReasoningPayload(payloadObj);
|
|
366
|
+
}
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/agents/deepseek-text-filter.ts
|
|
369
|
+
const DSML_KINDS = [
|
|
370
|
+
"tool_use_error",
|
|
371
|
+
"tool_calls",
|
|
372
|
+
"tool_call",
|
|
373
|
+
"function_calls"
|
|
374
|
+
];
|
|
375
|
+
const DSML_BARS = ["|", "|"];
|
|
376
|
+
const DSML_OPEN_TOKENS = DSML_BARS.flatMap((bar) => DSML_KINDS.map((kind) => `<${bar}DSML${bar}${kind}>`));
|
|
377
|
+
const DSML_CLOSE_TOKENS = DSML_BARS.flatMap((bar) => DSML_KINDS.map((kind) => `</${bar}DSML${bar}${kind}>`));
|
|
378
|
+
const MAX_OPEN_TOKEN_LEN = Math.max(...DSML_OPEN_TOKENS.map((token) => token.length));
|
|
379
|
+
const MAX_CLOSE_TOKEN_LEN = Math.max(...DSML_CLOSE_TOKENS.map((token) => token.length));
|
|
380
|
+
function createDeepSeekTextFilter() {
|
|
381
|
+
let buffer = "";
|
|
382
|
+
let insideDsml = false;
|
|
383
|
+
const consume = (final) => {
|
|
384
|
+
const output = [];
|
|
385
|
+
const emit = (text) => {
|
|
386
|
+
if (text) output.push(text);
|
|
387
|
+
};
|
|
388
|
+
while (buffer) {
|
|
389
|
+
if (insideDsml) {
|
|
390
|
+
const close = findEarliestToken(buffer, DSML_CLOSE_TOKENS);
|
|
391
|
+
if (close) {
|
|
392
|
+
buffer = buffer.slice(close.index + close.token.length);
|
|
393
|
+
insideDsml = false;
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
const keep = final ? 0 : Math.min(buffer.length, MAX_CLOSE_TOKEN_LEN - 1);
|
|
397
|
+
buffer = buffer.slice(buffer.length - keep);
|
|
398
|
+
if (final) insideDsml = false;
|
|
399
|
+
return output;
|
|
400
|
+
}
|
|
401
|
+
const open = findEarliestToken(buffer, DSML_OPEN_TOKENS);
|
|
402
|
+
if (open) {
|
|
403
|
+
emit(buffer.slice(0, open.index));
|
|
404
|
+
buffer = buffer.slice(open.index + open.token.length);
|
|
405
|
+
insideDsml = true;
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
if (final) {
|
|
409
|
+
emit(buffer);
|
|
410
|
+
buffer = "";
|
|
411
|
+
return output;
|
|
412
|
+
}
|
|
413
|
+
const keep = longestDsmlOpenPrefixSuffixLength(buffer);
|
|
414
|
+
const emitLength = buffer.length - keep;
|
|
415
|
+
if (emitLength <= 0) return output;
|
|
416
|
+
emit(buffer.slice(0, emitLength));
|
|
417
|
+
buffer = buffer.slice(emitLength);
|
|
418
|
+
return output;
|
|
419
|
+
}
|
|
420
|
+
return output;
|
|
421
|
+
};
|
|
422
|
+
return {
|
|
423
|
+
push(chunk) {
|
|
424
|
+
buffer += chunk;
|
|
425
|
+
return consume(false);
|
|
426
|
+
},
|
|
427
|
+
flush() {
|
|
428
|
+
return consume(true);
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function findEarliestToken(text, tokens) {
|
|
433
|
+
let best = null;
|
|
434
|
+
for (const token of tokens) {
|
|
435
|
+
const index = text.indexOf(token);
|
|
436
|
+
if (index !== -1 && (!best || index < best.index)) best = {
|
|
437
|
+
index,
|
|
438
|
+
token
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
return best;
|
|
442
|
+
}
|
|
443
|
+
function longestDsmlOpenPrefixSuffixLength(text) {
|
|
444
|
+
const maxLength = Math.min(text.length, MAX_OPEN_TOKEN_LEN - 1);
|
|
445
|
+
for (let length = maxLength; length > 0; length--) {
|
|
446
|
+
const suffix = text.slice(text.length - length);
|
|
447
|
+
if (DSML_OPEN_TOKENS.some((token) => token.startsWith(suffix))) return length;
|
|
448
|
+
}
|
|
449
|
+
return 0;
|
|
450
|
+
}
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/agents/model-max-tokens-params.ts
|
|
453
|
+
const MAX_TOKENS_PARAM_KEYS = [
|
|
454
|
+
"maxTokens",
|
|
455
|
+
"max_completion_tokens",
|
|
456
|
+
"max_tokens"
|
|
457
|
+
];
|
|
458
|
+
function resolveNonNegativeMaxTokensParam(value) {
|
|
459
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
460
|
+
}
|
|
461
|
+
function resolveMaxTokensParam(params) {
|
|
462
|
+
if (!params) return;
|
|
463
|
+
for (const key of MAX_TOKENS_PARAM_KEYS) {
|
|
464
|
+
const resolved = resolveNonNegativeMaxTokensParam(params[key]);
|
|
465
|
+
if (resolved !== void 0) return resolved;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
function canonicalizeMaxTokensParam(params) {
|
|
469
|
+
let resolved;
|
|
470
|
+
for (const source of params.sources) {
|
|
471
|
+
const sourceValue = resolveMaxTokensParam(source);
|
|
472
|
+
if (sourceValue !== void 0) resolved = sourceValue;
|
|
473
|
+
}
|
|
474
|
+
if (resolved === void 0) return;
|
|
475
|
+
for (const key of MAX_TOKENS_PARAM_KEYS) delete params.merged[key];
|
|
476
|
+
params.merged.maxTokens = resolved;
|
|
477
|
+
}
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region src/agents/model-tool-support.ts
|
|
480
|
+
function supportsModelTools(model) {
|
|
481
|
+
return (model.compat && typeof model.compat === "object" ? model.compat : void 0)?.supportsTools !== false;
|
|
482
|
+
}
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/agents/model-transport-url.ts
|
|
485
|
+
function formatModelTransportDebugUrl(rawUrl) {
|
|
486
|
+
try {
|
|
487
|
+
const parsed = new URL(rawUrl);
|
|
488
|
+
parsed.username = "";
|
|
489
|
+
parsed.password = "";
|
|
490
|
+
parsed.search = "";
|
|
491
|
+
parsed.hash = "";
|
|
492
|
+
return parsed.toString();
|
|
493
|
+
} catch {
|
|
494
|
+
return "<invalid-url>";
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function formatModelTransportDebugBaseUrl(rawUrl) {
|
|
498
|
+
return rawUrl ? formatModelTransportDebugUrl(rawUrl) : "default";
|
|
499
|
+
}
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region src/agents/openai-compatible-conversation-turn.ts
|
|
502
|
+
function hasNonEmptyString(value) {
|
|
503
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
504
|
+
}
|
|
505
|
+
function hasNonEmptyContentPart(part) {
|
|
506
|
+
if (!part || typeof part !== "object") return false;
|
|
507
|
+
const record = part;
|
|
508
|
+
if (record.type === "text") return hasNonEmptyString(record.text);
|
|
509
|
+
return true;
|
|
510
|
+
}
|
|
511
|
+
function hasNonEmptyMessageContent(content) {
|
|
512
|
+
if (hasNonEmptyString(content)) return true;
|
|
513
|
+
if (!Array.isArray(content)) return false;
|
|
514
|
+
return content.some(hasNonEmptyContentPart);
|
|
515
|
+
}
|
|
516
|
+
function hasAssistantToolCall(message) {
|
|
517
|
+
const toolCalls = message.tool_calls;
|
|
518
|
+
return Array.isArray(toolCalls) && toolCalls.some((toolCall) => {
|
|
519
|
+
return Boolean(toolCall && typeof toolCall === "object");
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
function hasOpenAICompatibleConversationTurn(messages) {
|
|
523
|
+
if (!Array.isArray(messages)) return false;
|
|
524
|
+
return messages.some((message) => {
|
|
525
|
+
if (!message || typeof message !== "object") return false;
|
|
526
|
+
const record = message;
|
|
527
|
+
if (record.role === "user") return hasNonEmptyMessageContent(record.content);
|
|
528
|
+
if (record.role === "assistant") return hasNonEmptyMessageContent(record.content) || hasAssistantToolCall(record);
|
|
529
|
+
return false;
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region src/agents/openai-reasoning-compat.ts
|
|
534
|
+
const OPENAI_MEDIUM_ONLY_REASONING_MODEL_IDS = new Set(["gpt-5.1-codex-mini"]);
|
|
535
|
+
function readCompatReasoningEffortMap(compat) {
|
|
536
|
+
if (!compat || typeof compat !== "object") return {};
|
|
537
|
+
const rawMap = compat.reasoningEffortMap;
|
|
538
|
+
if (!rawMap || typeof rawMap !== "object") return {};
|
|
539
|
+
return Object.fromEntries(Object.entries(rawMap).filter((entry) => typeof entry[0] === "string" && typeof entry[1] === "string"));
|
|
540
|
+
}
|
|
541
|
+
function resolveOpenAIReasoningEffortMap(model, fallbackMap = {}) {
|
|
542
|
+
const provider = normalizeLowercaseStringOrEmpty(model.provider ?? "");
|
|
543
|
+
const id = normalizeLowercaseStringOrEmpty(model.id ?? "");
|
|
544
|
+
const builtinMap = provider === "openai" && OPENAI_MEDIUM_ONLY_REASONING_MODEL_IDS.has(id) ? {
|
|
545
|
+
minimal: "medium",
|
|
546
|
+
low: "medium"
|
|
547
|
+
} : {};
|
|
548
|
+
return {
|
|
549
|
+
...fallbackMap,
|
|
550
|
+
...builtinMap,
|
|
551
|
+
...readCompatReasoningEffortMap(model.compat)
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
//#endregion
|
|
555
|
+
//#region src/agents/provider-transport-fetch.ts
|
|
556
|
+
const DEFAULT_MAX_SDK_RETRY_WAIT_SECONDS = 60;
|
|
557
|
+
const log$1 = createSubsystemLogger("provider-transport-fetch");
|
|
558
|
+
const BLOCKED_EXACT_ORIGIN_TRUST_HOSTNAME_LABELS = new Set(["instance-data"]);
|
|
559
|
+
const PLAIN_DECIMAL_NUMBER_RE = /^\d+(?:\.\d+)?$/;
|
|
560
|
+
const RETRY_AFTER_HTTP_DATE_RE = /^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} \d{2}:\d{2}:\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [ \d]\d \d{2}:\d{2}:\d{2} \d{4})$/;
|
|
561
|
+
const HTTP_DATE_MONTH_INDEX = new Map([
|
|
562
|
+
"Jan",
|
|
563
|
+
"Feb",
|
|
564
|
+
"Mar",
|
|
565
|
+
"Apr",
|
|
566
|
+
"May",
|
|
567
|
+
"Jun",
|
|
568
|
+
"Jul",
|
|
569
|
+
"Aug",
|
|
570
|
+
"Sep",
|
|
571
|
+
"Oct",
|
|
572
|
+
"Nov",
|
|
573
|
+
"Dec"
|
|
574
|
+
].map((month, index) => [month, index]));
|
|
575
|
+
const OBSOLETE_ASCTIME_HTTP_DATE_RE = /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([ \d]\d) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/;
|
|
576
|
+
function hasReadableSseData(block) {
|
|
577
|
+
const dataLines = block.split(/\r\n|\n|\r/).filter((line) => line === "data" || line.startsWith("data:")).map((line) => {
|
|
578
|
+
if (line === "data") return "";
|
|
579
|
+
const value = line.slice(5);
|
|
580
|
+
return value.startsWith(" ") ? value.slice(1) : value;
|
|
581
|
+
});
|
|
582
|
+
return dataLines.length > 0 && dataLines.join("\n").trim().length > 0;
|
|
583
|
+
}
|
|
584
|
+
function findSseEventBoundary(buffer) {
|
|
585
|
+
let best;
|
|
586
|
+
for (const delimiter of [
|
|
587
|
+
"\r\n\r\n",
|
|
588
|
+
"\n\n",
|
|
589
|
+
"\r\r"
|
|
590
|
+
]) {
|
|
591
|
+
const index = buffer.indexOf(delimiter);
|
|
592
|
+
if (index === -1) continue;
|
|
593
|
+
if (!best || index < best.index) best = {
|
|
594
|
+
index,
|
|
595
|
+
length: delimiter.length
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
return best;
|
|
599
|
+
}
|
|
600
|
+
function sanitizeOpenAISdkSseResponse(response, options) {
|
|
601
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
602
|
+
if (!response.ok || !response.body) return response;
|
|
603
|
+
if (options?.synthesizeJsonAsSse === true && (/\bapplication\/json\b/i.test(contentType) || /\+json\b/i.test(contentType))) {
|
|
604
|
+
const source = response.body;
|
|
605
|
+
const decoder = new TextDecoder();
|
|
606
|
+
const encoder = new TextEncoder();
|
|
607
|
+
let reader;
|
|
608
|
+
let buffer = "";
|
|
609
|
+
const sseBody = new ReadableStream({
|
|
610
|
+
start() {
|
|
611
|
+
reader = source.getReader();
|
|
612
|
+
},
|
|
613
|
+
async pull(controller) {
|
|
614
|
+
try {
|
|
615
|
+
for (;;) {
|
|
616
|
+
const chunk = await reader?.read();
|
|
617
|
+
if (!chunk || chunk.done) {
|
|
618
|
+
buffer += decoder.decode();
|
|
619
|
+
const data = buffer.trim();
|
|
620
|
+
if (data) controller.enqueue(encoder.encode(`data: ${data}\n\n`));
|
|
621
|
+
controller.enqueue(encoder.encode("data: [DONE]\n\n"));
|
|
622
|
+
controller.close();
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
buffer += decoder.decode(chunk.value, { stream: true });
|
|
626
|
+
}
|
|
627
|
+
} catch (error) {
|
|
628
|
+
controller.error(error);
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
async cancel(reason) {
|
|
632
|
+
await reader?.cancel(reason);
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
const headers = new Headers(response.headers);
|
|
636
|
+
headers.set("content-type", "text/event-stream; charset=utf-8");
|
|
637
|
+
return new Response(sseBody, {
|
|
638
|
+
status: response.status,
|
|
639
|
+
statusText: response.statusText,
|
|
640
|
+
headers
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
if (!/\btext\/event-stream\b/i.test(contentType)) return response;
|
|
644
|
+
const source = response.body;
|
|
645
|
+
const decoder = new TextDecoder();
|
|
646
|
+
const encoder = new TextEncoder();
|
|
647
|
+
let reader;
|
|
648
|
+
let buffer = "";
|
|
649
|
+
const enqueueSanitized = (controller, text) => {
|
|
650
|
+
let enqueued = 0;
|
|
651
|
+
buffer += text;
|
|
652
|
+
for (;;) {
|
|
653
|
+
const boundary = findSseEventBoundary(buffer);
|
|
654
|
+
if (!boundary) return enqueued;
|
|
655
|
+
const block = buffer.slice(0, boundary.index);
|
|
656
|
+
const separator = buffer.slice(boundary.index, boundary.index + boundary.length);
|
|
657
|
+
buffer = buffer.slice(boundary.index + boundary.length);
|
|
658
|
+
if (hasReadableSseData(block)) {
|
|
659
|
+
controller.enqueue(encoder.encode(`${block}${separator}`));
|
|
660
|
+
enqueued += 1;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
const sanitizedBody = new ReadableStream({
|
|
665
|
+
start() {
|
|
666
|
+
reader = source.getReader();
|
|
667
|
+
},
|
|
668
|
+
async pull(controller) {
|
|
669
|
+
try {
|
|
670
|
+
for (;;) {
|
|
671
|
+
const chunk = await reader?.read();
|
|
672
|
+
if (!chunk || chunk.done) {
|
|
673
|
+
const tail = decoder.decode();
|
|
674
|
+
if (tail) enqueueSanitized(controller, tail);
|
|
675
|
+
if (buffer && hasReadableSseData(buffer)) controller.enqueue(encoder.encode(buffer));
|
|
676
|
+
buffer = "";
|
|
677
|
+
controller.close();
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
if (enqueueSanitized(controller, decoder.decode(chunk.value, { stream: true })) > 0) return;
|
|
681
|
+
}
|
|
682
|
+
} catch (error) {
|
|
683
|
+
controller.error(error);
|
|
684
|
+
}
|
|
685
|
+
},
|
|
686
|
+
async cancel(reason) {
|
|
687
|
+
await reader?.cancel(reason);
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
return new Response(sanitizedBody, {
|
|
691
|
+
status: response.status,
|
|
692
|
+
statusText: response.statusText,
|
|
693
|
+
headers: response.headers
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
function shouldSanitizeOpenAISdkSseResponse(model) {
|
|
697
|
+
if (model.provider !== "openai") return true;
|
|
698
|
+
try {
|
|
699
|
+
return new URL(model.baseUrl).hostname.toLowerCase() !== "api.openai.com";
|
|
700
|
+
} catch {
|
|
701
|
+
return true;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
async function requestBodyHasStreamTrue(request, init) {
|
|
705
|
+
const method = request?.method ?? init?.method;
|
|
706
|
+
if (method && method.toUpperCase() !== "POST") return false;
|
|
707
|
+
const contentType = (request?.headers ?? new Headers(init?.headers)).get("content-type") ?? "";
|
|
708
|
+
if (contentType && !/\bapplication\/json\b/i.test(contentType)) return false;
|
|
709
|
+
let text;
|
|
710
|
+
if (typeof init?.body === "string") text = init.body;
|
|
711
|
+
if (!text) return false;
|
|
712
|
+
try {
|
|
713
|
+
return JSON.parse(text).stream === true;
|
|
714
|
+
} catch {
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
function parseRetryAfterSeconds(headers) {
|
|
719
|
+
const retryAfterMs = headers.get("retry-after-ms");
|
|
720
|
+
if (retryAfterMs) {
|
|
721
|
+
const trimmedRetryAfterMs = retryAfterMs.trim();
|
|
722
|
+
if (/^\d+(?:\.\d+)?$/.test(trimmedRetryAfterMs)) {
|
|
723
|
+
const milliseconds = asFiniteNumberInRange(parseStrictFiniteNumber(trimmedRetryAfterMs), {
|
|
724
|
+
min: 0,
|
|
725
|
+
max: Number.MAX_SAFE_INTEGER
|
|
726
|
+
});
|
|
727
|
+
return milliseconds === void 0 ? Number.POSITIVE_INFINITY : milliseconds / 1e3;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
const retryAfter = headers.get("retry-after");
|
|
731
|
+
if (!retryAfter) return;
|
|
732
|
+
const trimmedRetryAfterSeconds = retryAfter.trim();
|
|
733
|
+
if (/^\d+$/.test(trimmedRetryAfterSeconds)) return parseStrictNonNegativeInteger(trimmedRetryAfterSeconds) ?? Number.POSITIVE_INFINITY;
|
|
734
|
+
const trimmedRetryAfter = trimmedRetryAfterSeconds;
|
|
735
|
+
if (!RETRY_AFTER_HTTP_DATE_RE.test(trimmedRetryAfter)) return;
|
|
736
|
+
const retryAt = parseRetryAfterHttpDateMs(trimmedRetryAfter);
|
|
737
|
+
if (Number.isNaN(retryAt)) return;
|
|
738
|
+
return Math.max(0, (retryAt - Date.now()) / 1e3);
|
|
739
|
+
}
|
|
740
|
+
function parseRetryAfterHttpDateMs(value) {
|
|
741
|
+
const match = OBSOLETE_ASCTIME_HTTP_DATE_RE.exec(value);
|
|
742
|
+
if (match) {
|
|
743
|
+
const month = HTTP_DATE_MONTH_INDEX.get(match[1] ?? "");
|
|
744
|
+
if (month === void 0) return NaN;
|
|
745
|
+
const year = Number.parseInt(match[6] ?? "", 10);
|
|
746
|
+
const day = Number.parseInt((match[2] ?? "").trim(), 10);
|
|
747
|
+
const hours = Number.parseInt(match[3] ?? "", 10);
|
|
748
|
+
const minutes = Number.parseInt(match[4] ?? "", 10);
|
|
749
|
+
const seconds = Number.parseInt(match[5] ?? "", 10);
|
|
750
|
+
if (day < 1 || day > 31 || hours > 23 || minutes > 59 || seconds > 59 || [
|
|
751
|
+
year,
|
|
752
|
+
day,
|
|
753
|
+
hours,
|
|
754
|
+
minutes,
|
|
755
|
+
seconds
|
|
756
|
+
].some((component) => !Number.isFinite(component))) return NaN;
|
|
757
|
+
const timestamp = Date.UTC(year, month, day, hours, minutes, seconds);
|
|
758
|
+
const parsedDate = new Date(timestamp);
|
|
759
|
+
return parsedDate.getUTCFullYear() === year && parsedDate.getUTCMonth() === month && parsedDate.getUTCDate() === day && parsedDate.getUTCHours() === hours && parsedDate.getUTCMinutes() === minutes && parsedDate.getUTCSeconds() === seconds ? timestamp : NaN;
|
|
760
|
+
}
|
|
761
|
+
const parsed = Date.parse(value);
|
|
762
|
+
if (!Number.isNaN(parsed)) return parsed;
|
|
763
|
+
return NaN;
|
|
764
|
+
}
|
|
765
|
+
function resolveMaxSdkRetryWaitSeconds() {
|
|
766
|
+
const raw = process.env.FENGMING_SDK_RETRY_MAX_WAIT_SECONDS?.trim();
|
|
767
|
+
if (!raw) return DEFAULT_MAX_SDK_RETRY_WAIT_SECONDS;
|
|
768
|
+
if (/^(?:0|false|off|none|disabled)$/i.test(raw)) return;
|
|
769
|
+
if (!PLAIN_DECIMAL_NUMBER_RE.test(raw)) return DEFAULT_MAX_SDK_RETRY_WAIT_SECONDS;
|
|
770
|
+
const seconds = asFiniteNumberInRange(parseStrictFiniteNumber(raw), {
|
|
771
|
+
min: 0,
|
|
772
|
+
minExclusive: true,
|
|
773
|
+
max: Number.MAX_SAFE_INTEGER
|
|
774
|
+
});
|
|
775
|
+
if (seconds !== void 0) return seconds;
|
|
776
|
+
return DEFAULT_MAX_SDK_RETRY_WAIT_SECONDS;
|
|
777
|
+
}
|
|
778
|
+
function shouldBypassLongSdkRetry(response) {
|
|
779
|
+
const maxWaitSeconds = resolveMaxSdkRetryWaitSeconds();
|
|
780
|
+
if (maxWaitSeconds === void 0) return false;
|
|
781
|
+
const status = response.status;
|
|
782
|
+
if (!(status === 408 || status === 409 || status === 429 || status >= 500)) return false;
|
|
783
|
+
const retryAfterSeconds = parseRetryAfterSeconds(response.headers);
|
|
784
|
+
if (retryAfterSeconds !== void 0) return retryAfterSeconds > maxWaitSeconds;
|
|
785
|
+
return status === 429;
|
|
786
|
+
}
|
|
787
|
+
function buildManagedResponse(response, release, refreshTimeout, localServiceLease) {
|
|
788
|
+
const finalizeLocalServiceLease = () => {
|
|
789
|
+
localServiceLease?.release();
|
|
790
|
+
};
|
|
791
|
+
if (!response.body) {
|
|
792
|
+
release().finally(finalizeLocalServiceLease);
|
|
793
|
+
return response;
|
|
794
|
+
}
|
|
795
|
+
const source = response.body;
|
|
796
|
+
let reader;
|
|
797
|
+
let released = false;
|
|
798
|
+
const finalize = async () => {
|
|
799
|
+
if (released) return;
|
|
800
|
+
released = true;
|
|
801
|
+
try {
|
|
802
|
+
await release().catch(() => void 0);
|
|
803
|
+
} finally {
|
|
804
|
+
finalizeLocalServiceLease();
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
const wrappedBody = new ReadableStream({
|
|
808
|
+
start() {
|
|
809
|
+
reader = source.getReader();
|
|
810
|
+
},
|
|
811
|
+
async pull(controller) {
|
|
812
|
+
try {
|
|
813
|
+
const chunk = await reader?.read();
|
|
814
|
+
if (!chunk || chunk.done) {
|
|
815
|
+
controller.close();
|
|
816
|
+
await finalize();
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
refreshTimeout?.();
|
|
820
|
+
controller.enqueue(chunk.value);
|
|
821
|
+
} catch (error) {
|
|
822
|
+
controller.error(error);
|
|
823
|
+
await finalize();
|
|
824
|
+
}
|
|
825
|
+
},
|
|
826
|
+
async cancel(reason) {
|
|
827
|
+
try {
|
|
828
|
+
await reader?.cancel(reason);
|
|
829
|
+
} finally {
|
|
830
|
+
await finalize();
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
return new Response(wrappedBody, {
|
|
835
|
+
status: response.status,
|
|
836
|
+
statusText: response.statusText,
|
|
837
|
+
headers: response.headers
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
function resolveModelRequestPolicy(model) {
|
|
841
|
+
const debugProxy = resolveDebugProxySettings();
|
|
842
|
+
let explicitDebugProxyUrl;
|
|
843
|
+
if (debugProxy.enabled && debugProxy.proxyUrl) try {
|
|
844
|
+
if (new URL(model.baseUrl).protocol === "https:") explicitDebugProxyUrl = debugProxy.proxyUrl;
|
|
845
|
+
} catch {}
|
|
846
|
+
const request = mergeModelProviderRequestOverrides(getModelProviderRequestTransport(model), { proxy: explicitDebugProxyUrl ? {
|
|
847
|
+
mode: "explicit-proxy",
|
|
848
|
+
url: explicitDebugProxyUrl
|
|
849
|
+
} : void 0 });
|
|
850
|
+
return resolveProviderRequestPolicyConfig({
|
|
851
|
+
provider: model.provider,
|
|
852
|
+
api: model.api,
|
|
853
|
+
baseUrl: model.baseUrl,
|
|
854
|
+
capability: "llm",
|
|
855
|
+
transport: "stream",
|
|
856
|
+
request
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
function resolveModelRequestTimeoutMs(model, timeoutMs) {
|
|
860
|
+
if (timeoutMs !== void 0) return typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0 ? clampTimerTimeoutMs(timeoutMs) : void 0;
|
|
861
|
+
const modelTimeoutMs = model.requestTimeoutMs;
|
|
862
|
+
return typeof modelTimeoutMs === "number" && Number.isFinite(modelTimeoutMs) && modelTimeoutMs > 0 ? clampTimerTimeoutMs(modelTimeoutMs) : void 0;
|
|
863
|
+
}
|
|
864
|
+
function buildModelRequestSignal(baseSignal, timeoutMs) {
|
|
865
|
+
if (timeoutMs === void 0) return baseSignal;
|
|
866
|
+
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
867
|
+
if (!baseSignal) return timeoutSignal;
|
|
868
|
+
return AbortSignal.any([baseSignal, timeoutSignal]);
|
|
869
|
+
}
|
|
870
|
+
function resolveHttpOrigin(value) {
|
|
871
|
+
if (typeof value !== "string" || !value.trim()) return;
|
|
872
|
+
try {
|
|
873
|
+
const parsed = new URL(value);
|
|
874
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return;
|
|
875
|
+
parsed.hostname = parsed.hostname.replace(/\.+$/, "");
|
|
876
|
+
return parsed.origin.toLowerCase();
|
|
877
|
+
} catch {
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
function normalizeProviderOriginHostname(value) {
|
|
882
|
+
if (typeof value !== "string" || !value.trim()) return;
|
|
883
|
+
try {
|
|
884
|
+
const parsed = new URL(value);
|
|
885
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return;
|
|
886
|
+
return parsed.hostname.trim().toLowerCase().replace(/\.+$/, "") || void 0;
|
|
887
|
+
} catch {
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
function canImplicitlyTrustConfiguredBaseUrlOrigin(value) {
|
|
892
|
+
const hostname = normalizeProviderOriginHostname(value);
|
|
893
|
+
if (!hostname) return false;
|
|
894
|
+
return !hostname.split(".").filter(Boolean).some((label) => label.includes("metadata") || BLOCKED_EXACT_ORIGIN_TRUST_HOSTNAME_LABELS.has(label)) && !isLinkLocalIpAddress(hostname) && !isCloudMetadataIpAddress(hostname);
|
|
895
|
+
}
|
|
896
|
+
function canApplyFakeIpHostnamePolicy(value) {
|
|
897
|
+
const hostname = normalizeProviderOriginHostname(value);
|
|
898
|
+
if (!hostname) return false;
|
|
899
|
+
return !hostname.split(".").filter(Boolean).some((label) => label.includes("metadata") || BLOCKED_EXACT_ORIGIN_TRUST_HOSTNAME_LABELS.has(label)) && !parseCanonicalIpAddress(hostname);
|
|
900
|
+
}
|
|
901
|
+
function resolveModelTransportSsrFPolicy(params) {
|
|
902
|
+
const baseUrl = params.model.baseUrl;
|
|
903
|
+
const baseOrigin = resolveHttpOrigin(baseUrl);
|
|
904
|
+
const requestOrigin = resolveHttpOrigin(params.url);
|
|
905
|
+
const requestMatchesBaseOrigin = typeof baseUrl === "string" && Boolean(baseOrigin) && requestOrigin === baseOrigin;
|
|
906
|
+
return mergeSsrFPolicies(requestMatchesBaseOrigin && params.trustConfiguredBaseUrlOrigin && canImplicitlyTrustConfiguredBaseUrlOrigin(baseUrl) ? ssrfPolicyFromHttpBaseUrlAllowedOrigin(baseUrl) : void 0, requestMatchesBaseOrigin && canApplyFakeIpHostnamePolicy(baseUrl) ? ssrfPolicyFromHttpBaseUrlFakeIpHostnameAllowlist(baseUrl) : void 0, params.allowPrivateNetwork ? { allowPrivateNetwork: true } : void 0);
|
|
907
|
+
}
|
|
908
|
+
function buildGuardedModelFetch(model, timeoutMs, options) {
|
|
909
|
+
const requestConfig = resolveModelRequestPolicy(model);
|
|
910
|
+
const dispatcherPolicy = buildProviderRequestDispatcherPolicy(requestConfig);
|
|
911
|
+
const requestTimeoutMs = resolveModelRequestTimeoutMs(model, timeoutMs);
|
|
912
|
+
const summarizeError = (error) => {
|
|
913
|
+
if (!error || typeof error !== "object") return `type=${typeof error}`;
|
|
914
|
+
const record = error;
|
|
915
|
+
const cause = record.cause && typeof record.cause === "object" ? record.cause : void 0;
|
|
916
|
+
const read = (value) => typeof value === "string" ? value : typeof value;
|
|
917
|
+
return [
|
|
918
|
+
`name=${read(record.name)}`,
|
|
919
|
+
`code=${read(record.code)}`,
|
|
920
|
+
`causeName=${read(cause?.name)}`,
|
|
921
|
+
`causeCode=${read(cause?.code)}`,
|
|
922
|
+
`message=${error instanceof Error ? error.message : read(record.message)}`
|
|
923
|
+
].join(" ");
|
|
924
|
+
};
|
|
925
|
+
return async (input, init) => {
|
|
926
|
+
let localServiceLease;
|
|
927
|
+
const request = input instanceof Request ? new Request(input, init) : void 0;
|
|
928
|
+
const url = request?.url ?? (input instanceof URL ? input.toString() : typeof input === "string" ? input : (() => {
|
|
929
|
+
throw new Error("传输感知模型请求不支持此 fetch 输入");
|
|
930
|
+
})());
|
|
931
|
+
const policy = resolveModelTransportSsrFPolicy({
|
|
932
|
+
model,
|
|
933
|
+
url,
|
|
934
|
+
allowPrivateNetwork: requestConfig.allowPrivateNetwork,
|
|
935
|
+
trustConfiguredBaseUrlOrigin: !requestConfig.privateNetworkExplicitlyDenied && (requestConfig.policy?.endpointClass === "custom" || requestConfig.policy?.endpointClass === "local")
|
|
936
|
+
});
|
|
937
|
+
const baseInit = (request && {
|
|
938
|
+
method: request.method,
|
|
939
|
+
headers: request.headers,
|
|
940
|
+
body: request.body ?? void 0,
|
|
941
|
+
redirect: request.redirect,
|
|
942
|
+
signal: request.signal,
|
|
943
|
+
...request.body ? { duplex: "half" } : {}
|
|
944
|
+
}) ?? init;
|
|
945
|
+
const synthesizeJsonAsSse = await requestBodyHasStreamTrue(request, baseInit);
|
|
946
|
+
const baseSignal = baseInit?.signal ?? void 0;
|
|
947
|
+
const localServiceSignal = buildModelRequestSignal(baseSignal, requestTimeoutMs);
|
|
948
|
+
const guardedFetchOptions = {
|
|
949
|
+
url,
|
|
950
|
+
init: baseInit,
|
|
951
|
+
capture: { meta: {
|
|
952
|
+
provider: model.provider,
|
|
953
|
+
api: model.api,
|
|
954
|
+
model: model.id
|
|
955
|
+
} },
|
|
956
|
+
dispatcherPolicy,
|
|
957
|
+
timeoutMs: requestTimeoutMs,
|
|
958
|
+
...baseSignal ? { signal: baseSignal } : {},
|
|
959
|
+
allowCrossOriginUnsafeRedirectReplay: false,
|
|
960
|
+
...policy ? { policy } : {}
|
|
961
|
+
};
|
|
962
|
+
let result;
|
|
963
|
+
const fetchStartedAt = Date.now();
|
|
964
|
+
const useEnvProxy = !dispatcherPolicy && shouldUseEnvHttpProxyForUrl(url);
|
|
965
|
+
emitModelTransportDebug(log$1, `[model-fetch] start provider=${model.provider} api=${model.api} model=${model.id} method=${baseInit?.method ?? "GET"} url=${formatModelTransportDebugUrl(url)} timeoutMs=${requestTimeoutMs} proxy=${dispatcherPolicy ? "configured" : useEnvProxy ? "env" : "none"} policy=${policy ? "custom" : "default"}`);
|
|
966
|
+
try {
|
|
967
|
+
localServiceLease = await ensureModelProviderLocalService(model, baseInit?.headers, localServiceSignal);
|
|
968
|
+
result = await fetchWithSsrFGuard(useEnvProxy ? withTrustedEnvProxyGuardedFetchMode(guardedFetchOptions) : guardedFetchOptions);
|
|
969
|
+
} catch (error) {
|
|
970
|
+
log$1.warn(`[model-fetch] error provider=${model.provider} api=${model.api} model=${model.id} elapsedMs=${Date.now() - fetchStartedAt} ${summarizeError(error)}`);
|
|
971
|
+
localServiceLease?.release();
|
|
972
|
+
throw error;
|
|
973
|
+
}
|
|
974
|
+
let response = result.response;
|
|
975
|
+
emitModelTransportDebug(log$1, `[model-fetch] response provider=${model.provider} api=${model.api} model=${model.id} status=${response.status} elapsedMs=${Date.now() - fetchStartedAt} contentType=${response.headers.get("content-type") ?? ""}`);
|
|
976
|
+
if (shouldBypassLongSdkRetry(response)) {
|
|
977
|
+
const headers = new Headers(response.headers);
|
|
978
|
+
headers.set("x-should-retry", "false");
|
|
979
|
+
response = new Response(response.body, {
|
|
980
|
+
status: response.status,
|
|
981
|
+
statusText: response.statusText,
|
|
982
|
+
headers
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
response = buildManagedResponse(response, result.release, result.refreshTimeout, localServiceLease);
|
|
986
|
+
return options?.sanitizeSse === false || !shouldSanitizeOpenAISdkSseResponse(model) ? response : sanitizeOpenAISdkSseResponse(response, { synthesizeJsonAsSse });
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
//#endregion
|
|
990
|
+
//#region src/agents/responses-image-payload-sanitizer.ts
|
|
991
|
+
const IMAGE_OMITTED_TEXT = "omitted image payload: invalid inline image data";
|
|
992
|
+
function invalidSnakeImage() {
|
|
993
|
+
return {
|
|
994
|
+
type: "input_text",
|
|
995
|
+
text: `[${IMAGE_OMITTED_TEXT}]`
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
function sanitizeValue(value) {
|
|
999
|
+
if (Array.isArray(value)) return value.map(sanitizeValue);
|
|
1000
|
+
if (!isRecord(value)) return value;
|
|
1001
|
+
if (value.type === "input_image" && typeof value.image_url === "string") {
|
|
1002
|
+
const imageUrl = sanitizeInlineImageDataUrl(value.image_url);
|
|
1003
|
+
return imageUrl ? {
|
|
1004
|
+
...value,
|
|
1005
|
+
image_url: imageUrl
|
|
1006
|
+
} : invalidSnakeImage();
|
|
1007
|
+
}
|
|
1008
|
+
const next = {};
|
|
1009
|
+
for (const [key, child] of Object.entries(value)) next[key] = sanitizeValue(child);
|
|
1010
|
+
return next;
|
|
1011
|
+
}
|
|
1012
|
+
function sanitizeResponsesImagePayload(params) {
|
|
1013
|
+
if (!Array.isArray(params.input)) return params;
|
|
1014
|
+
return {
|
|
1015
|
+
...params,
|
|
1016
|
+
input: sanitizeValue(params.input)
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
//#endregion
|
|
1020
|
+
//#region src/agents/transport-message-transform.ts
|
|
1021
|
+
const SYNTHETIC_TOOL_RESULT_APIS = new Set([
|
|
1022
|
+
"anthropic-messages",
|
|
1023
|
+
"fengming-anthropic-messages-transport",
|
|
1024
|
+
"bedrock-converse-stream",
|
|
1025
|
+
"google-generative-ai",
|
|
1026
|
+
"fengming-google-generative-ai-transport",
|
|
1027
|
+
"openai-responses",
|
|
1028
|
+
"openai-codex-responses",
|
|
1029
|
+
"azure-openai-responses",
|
|
1030
|
+
"fengming-openai-responses-transport",
|
|
1031
|
+
"fengming-azure-openai-responses-transport"
|
|
1032
|
+
]);
|
|
1033
|
+
const CODEX_STYLE_ABORTED_OUTPUT_APIS = new Set([
|
|
1034
|
+
"openai-responses",
|
|
1035
|
+
"openai-codex-responses",
|
|
1036
|
+
"azure-openai-responses",
|
|
1037
|
+
"fengming-openai-responses-transport",
|
|
1038
|
+
"fengming-azure-openai-responses-transport"
|
|
1039
|
+
]);
|
|
1040
|
+
function defaultAllowSyntheticToolResults(modelApi) {
|
|
1041
|
+
return SYNTHETIC_TOOL_RESULT_APIS.has(modelApi);
|
|
1042
|
+
}
|
|
1043
|
+
function isFailedAssistantTurn(message) {
|
|
1044
|
+
if (message.role !== "assistant") return false;
|
|
1045
|
+
return message.stopReason === "error" || message.stopReason === "aborted";
|
|
1046
|
+
}
|
|
1047
|
+
function transformTransportMessages(messages, model, normalizeToolCallId, options) {
|
|
1048
|
+
const allowSyntheticToolResults = defaultAllowSyntheticToolResults(model.api);
|
|
1049
|
+
const syntheticToolResultText = CODEX_STYLE_ABORTED_OUTPUT_APIS.has(model.api) ? "aborted" : "No result provided";
|
|
1050
|
+
const toolCallIdMap = /* @__PURE__ */ new Map();
|
|
1051
|
+
const replayable = messages.map((msg) => {
|
|
1052
|
+
if (msg.role === "user") return msg;
|
|
1053
|
+
if (msg.role === "toolResult") {
|
|
1054
|
+
const normalizedId = toolCallIdMap.get(msg.toolCallId);
|
|
1055
|
+
return normalizedId && normalizedId !== msg.toolCallId ? {
|
|
1056
|
+
...msg,
|
|
1057
|
+
toolCallId: normalizedId
|
|
1058
|
+
} : msg;
|
|
1059
|
+
}
|
|
1060
|
+
if (msg.role !== "assistant") return msg;
|
|
1061
|
+
const isSameModel = msg.provider === model.provider && msg.api === model.api && msg.model === model.id;
|
|
1062
|
+
const sourceContent = Array.isArray(msg.content) ? msg.content : msg.content != null && typeof msg.content === "object" ? [msg.content] : [];
|
|
1063
|
+
const content = [];
|
|
1064
|
+
for (const block of sourceContent) {
|
|
1065
|
+
if (block.type === "thinking") {
|
|
1066
|
+
if (block.redacted) {
|
|
1067
|
+
if (isSameModel) content.push(block);
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
if (isSameModel && block.thinkingSignature) {
|
|
1071
|
+
content.push(block);
|
|
1072
|
+
continue;
|
|
1073
|
+
}
|
|
1074
|
+
if (!block.thinking.trim()) continue;
|
|
1075
|
+
content.push(isSameModel ? block : {
|
|
1076
|
+
type: "text",
|
|
1077
|
+
text: block.thinking
|
|
1078
|
+
});
|
|
1079
|
+
continue;
|
|
1080
|
+
}
|
|
1081
|
+
if (block.type === "text") {
|
|
1082
|
+
content.push(isSameModel ? block : {
|
|
1083
|
+
type: "text",
|
|
1084
|
+
text: block.text
|
|
1085
|
+
});
|
|
1086
|
+
continue;
|
|
1087
|
+
}
|
|
1088
|
+
if (block.type !== "toolCall") {
|
|
1089
|
+
content.push(block);
|
|
1090
|
+
continue;
|
|
1091
|
+
}
|
|
1092
|
+
let normalizedToolCall = block;
|
|
1093
|
+
if (!isSameModel && block.thoughtSignature && options?.preserveCrossModelToolCallThoughtSignature !== true) {
|
|
1094
|
+
normalizedToolCall = { ...normalizedToolCall };
|
|
1095
|
+
delete normalizedToolCall.thoughtSignature;
|
|
1096
|
+
}
|
|
1097
|
+
if ((!isSameModel || options?.normalizeSameModelToolCallIds === true) && normalizeToolCallId) {
|
|
1098
|
+
const normalizedId = normalizeToolCallId(block.id, model, msg);
|
|
1099
|
+
if (normalizedId !== block.id) {
|
|
1100
|
+
toolCallIdMap.set(block.id, normalizedId);
|
|
1101
|
+
normalizedToolCall = {
|
|
1102
|
+
...normalizedToolCall,
|
|
1103
|
+
id: normalizedId
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
content.push(normalizedToolCall);
|
|
1108
|
+
}
|
|
1109
|
+
return {
|
|
1110
|
+
...msg,
|
|
1111
|
+
content
|
|
1112
|
+
};
|
|
1113
|
+
}).filter((msg) => !isFailedAssistantTurn(msg));
|
|
1114
|
+
if (!allowSyntheticToolResults) return replayable;
|
|
1115
|
+
return repairToolUseResultPairing(replayable, {
|
|
1116
|
+
erroredAssistantResultPolicy: "drop",
|
|
1117
|
+
missingToolResultText: syntheticToolResultText
|
|
1118
|
+
}).messages;
|
|
1119
|
+
}
|
|
1120
|
+
//#endregion
|
|
1121
|
+
//#region src/agents/transport-stream-shared.ts
|
|
1122
|
+
const EMPTY_TOOL_RESULT_TEXT = "(no output)";
|
|
1123
|
+
function sanitizeTransportPayloadText(text) {
|
|
1124
|
+
return text.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "");
|
|
1125
|
+
}
|
|
1126
|
+
function sanitizeNonEmptyTransportPayloadText(text, fallback = EMPTY_TOOL_RESULT_TEXT) {
|
|
1127
|
+
const sanitized = sanitizeTransportPayloadText(text);
|
|
1128
|
+
return sanitized.trim().length > 0 ? sanitized : fallback;
|
|
1129
|
+
}
|
|
1130
|
+
function coerceTransportToolCallArguments(argumentsValue) {
|
|
1131
|
+
if (argumentsValue && typeof argumentsValue === "object" && !Array.isArray(argumentsValue)) return argumentsValue;
|
|
1132
|
+
if (typeof argumentsValue === "string") try {
|
|
1133
|
+
const parsed = JSON.parse(argumentsValue);
|
|
1134
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
|
|
1135
|
+
} catch {}
|
|
1136
|
+
return {};
|
|
1137
|
+
}
|
|
1138
|
+
function mergeTransportHeaders(...headerSources) {
|
|
1139
|
+
const merged = {};
|
|
1140
|
+
for (const headers of headerSources) if (headers) Object.assign(merged, headers);
|
|
1141
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
1142
|
+
}
|
|
1143
|
+
function mergeTransportMetadata(payload, metadata) {
|
|
1144
|
+
if (!metadata || Object.keys(metadata).length === 0) return payload;
|
|
1145
|
+
const existingMetadata = payload.metadata && typeof payload.metadata === "object" && !Array.isArray(payload.metadata) ? payload.metadata : void 0;
|
|
1146
|
+
return {
|
|
1147
|
+
...payload,
|
|
1148
|
+
metadata: {
|
|
1149
|
+
...existingMetadata,
|
|
1150
|
+
...metadata
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
function createEmptyTransportUsage() {
|
|
1155
|
+
return {
|
|
1156
|
+
input: 0,
|
|
1157
|
+
output: 0,
|
|
1158
|
+
cacheRead: 0,
|
|
1159
|
+
cacheWrite: 0,
|
|
1160
|
+
totalTokens: 0,
|
|
1161
|
+
cost: {
|
|
1162
|
+
input: 0,
|
|
1163
|
+
output: 0,
|
|
1164
|
+
cacheRead: 0,
|
|
1165
|
+
cacheWrite: 0,
|
|
1166
|
+
total: 0
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
function createWritableTransportEventStream() {
|
|
1171
|
+
const eventStream = createAssistantMessageEventStream();
|
|
1172
|
+
return {
|
|
1173
|
+
eventStream,
|
|
1174
|
+
stream: eventStream
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
function finalizeTransportStream(params) {
|
|
1178
|
+
const { stream, output, signal } = params;
|
|
1179
|
+
if (signal?.aborted) throw new Error("请求已被中止");
|
|
1180
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") throw new Error("发生了未知错误");
|
|
1181
|
+
stream.push({
|
|
1182
|
+
type: "done",
|
|
1183
|
+
reason: output.stopReason,
|
|
1184
|
+
message: output
|
|
1185
|
+
});
|
|
1186
|
+
stream.end();
|
|
1187
|
+
}
|
|
1188
|
+
function readStringLikeProperty(value, key) {
|
|
1189
|
+
if (!value || typeof value !== "object") return;
|
|
1190
|
+
const raw = value[key];
|
|
1191
|
+
if (typeof raw === "string") return raw.trim() || void 0;
|
|
1192
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
1193
|
+
}
|
|
1194
|
+
function readObjectProperty(value, key) {
|
|
1195
|
+
if (!value || typeof value !== "object") return;
|
|
1196
|
+
const raw = value[key];
|
|
1197
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
|
|
1198
|
+
}
|
|
1199
|
+
function stringifyErrorBody(value) {
|
|
1200
|
+
if (typeof value === "string") return value;
|
|
1201
|
+
if (value === void 0 || value === null) return;
|
|
1202
|
+
try {
|
|
1203
|
+
return JSON.stringify(value);
|
|
1204
|
+
} catch {
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
function normalizeTransportErrorBody(value) {
|
|
1209
|
+
const text = stringifyErrorBody(value);
|
|
1210
|
+
if (!text?.trim()) return;
|
|
1211
|
+
return truncateErrorDetail(redactSensitiveText(text), 500);
|
|
1212
|
+
}
|
|
1213
|
+
function extractTransportErrorDetails(error) {
|
|
1214
|
+
const errorObject = error && typeof error === "object" ? error : void 0;
|
|
1215
|
+
const nestedError = readObjectProperty(errorObject, "error");
|
|
1216
|
+
const errorCode = readStringLikeProperty(errorObject, "errorCode") ?? readStringLikeProperty(errorObject, "code") ?? readStringLikeProperty(nestedError, "code");
|
|
1217
|
+
const errorType = readStringLikeProperty(errorObject, "errorType") ?? readStringLikeProperty(errorObject, "type") ?? readStringLikeProperty(nestedError, "type");
|
|
1218
|
+
const errorBody = normalizeTransportErrorBody(readStringLikeProperty(errorObject, "errorBody")) ?? normalizeTransportErrorBody(readStringLikeProperty(errorObject, "body")) ?? normalizeTransportErrorBody(readObjectProperty(errorObject, "body")) ?? normalizeTransportErrorBody(nestedError);
|
|
1219
|
+
return {
|
|
1220
|
+
...errorCode ? { errorCode } : {},
|
|
1221
|
+
...errorType ? { errorType } : {},
|
|
1222
|
+
...errorBody ? { errorBody } : {}
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
function assignTransportErrorDetails(output, error, signal) {
|
|
1226
|
+
output.stopReason = signal?.aborted ? "aborted" : "error";
|
|
1227
|
+
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
1228
|
+
Object.assign(output, extractTransportErrorDetails(error));
|
|
1229
|
+
}
|
|
1230
|
+
function failTransportStream(params) {
|
|
1231
|
+
const { stream, output, signal, error, cleanup } = params;
|
|
1232
|
+
cleanup?.();
|
|
1233
|
+
assignTransportErrorDetails(output, error, signal);
|
|
1234
|
+
stream.push({
|
|
1235
|
+
type: "error",
|
|
1236
|
+
reason: output.stopReason,
|
|
1237
|
+
error: output
|
|
1238
|
+
});
|
|
1239
|
+
stream.end();
|
|
1240
|
+
}
|
|
1241
|
+
//#endregion
|
|
1242
|
+
//#region src/agents/openai-transport-stream.ts
|
|
1243
|
+
const DEFAULT_AZURE_OPENAI_API_VERSION = "preview";
|
|
1244
|
+
const OPENAI_CODEX_RESPONSES_EMPTY_INPUT_TEXT = " ";
|
|
1245
|
+
const OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS = "Follow the user request.";
|
|
1246
|
+
const GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP = "skip_thought_signature_validator";
|
|
1247
|
+
const AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS = 3e4;
|
|
1248
|
+
const MODEL_STREAM_COOPERATIVE_YIELD_INTERVAL_MS = 12;
|
|
1249
|
+
const MODEL_STREAM_COOPERATIVE_YIELD_MAX_EVENTS = 64;
|
|
1250
|
+
const RESPONSE_FAILED_NO_DETAILS_MESSAGE = "Unknown error (no error details in response)";
|
|
1251
|
+
const MAX_OPENAI_STRICT_TOOL_DOWNGRADE_DIAGNOSTIC_KEYS = 256;
|
|
1252
|
+
const OPENAI_RESPONSES_REASONING_REPLAY_META_KEY = "__fengming_replay";
|
|
1253
|
+
const OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY = "fengmingReasoningReplay";
|
|
1254
|
+
const OPENAI_RESPONSES_REPLAY_ITEM_ID_MAX_LENGTH = 64;
|
|
1255
|
+
const OPENAI_CODEX_RESPONSES_PROVIDERS = new Set(["openai", "openai-codex"]);
|
|
1256
|
+
const log = createSubsystemLogger("openai-transport");
|
|
1257
|
+
const loggedOpenAIStrictToolDowngradeDiagnosticKeys = /* @__PURE__ */ new Set();
|
|
1258
|
+
function throwIfModelStreamAborted(signal) {
|
|
1259
|
+
if (signal?.aborted) throw new Error("请求已被中止");
|
|
1260
|
+
}
|
|
1261
|
+
function createModelStreamCooperativeScheduler(signal) {
|
|
1262
|
+
let lastYieldedAt = Date.now();
|
|
1263
|
+
let eventsSinceYield = 0;
|
|
1264
|
+
return { async afterEvent() {
|
|
1265
|
+
throwIfModelStreamAborted(signal);
|
|
1266
|
+
eventsSinceYield += 1;
|
|
1267
|
+
const now = Date.now();
|
|
1268
|
+
if (eventsSinceYield < MODEL_STREAM_COOPERATIVE_YIELD_MAX_EVENTS && now - lastYieldedAt < MODEL_STREAM_COOPERATIVE_YIELD_INTERVAL_MS) return;
|
|
1269
|
+
eventsSinceYield = 0;
|
|
1270
|
+
lastYieldedAt = now;
|
|
1271
|
+
await new Promise((resolve) => {
|
|
1272
|
+
setTimeout(resolve, 0);
|
|
1273
|
+
});
|
|
1274
|
+
throwIfModelStreamAborted(signal);
|
|
1275
|
+
} };
|
|
1276
|
+
}
|
|
1277
|
+
function stringifyUnknown(value, fallback = "") {
|
|
1278
|
+
if (typeof value === "string") return value;
|
|
1279
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
1280
|
+
return fallback;
|
|
1281
|
+
}
|
|
1282
|
+
function stringifyJsonLike(value, fallback = "") {
|
|
1283
|
+
if (typeof value === "string") return value;
|
|
1284
|
+
if (value && typeof value === "object") return JSON.stringify(value);
|
|
1285
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
1286
|
+
return fallback;
|
|
1287
|
+
}
|
|
1288
|
+
function getServiceTierCostMultiplier(serviceTier) {
|
|
1289
|
+
switch (serviceTier) {
|
|
1290
|
+
case "flex": return .5;
|
|
1291
|
+
case "priority": return 2;
|
|
1292
|
+
default: return 1;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
function applyServiceTierPricing(usage, serviceTier) {
|
|
1296
|
+
const multiplier = getServiceTierCostMultiplier(serviceTier);
|
|
1297
|
+
if (multiplier === 1) return;
|
|
1298
|
+
usage.cost.input *= multiplier;
|
|
1299
|
+
usage.cost.output *= multiplier;
|
|
1300
|
+
usage.cost.cacheRead *= multiplier;
|
|
1301
|
+
usage.cost.cacheWrite *= multiplier;
|
|
1302
|
+
usage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;
|
|
1303
|
+
}
|
|
1304
|
+
function safeDebugValue(value) {
|
|
1305
|
+
if (typeof value === "string") return value;
|
|
1306
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
1307
|
+
if (value === null) return "null";
|
|
1308
|
+
if (value === void 0) return "undefined";
|
|
1309
|
+
return Array.isArray(value) ? "array" : typeof value;
|
|
1310
|
+
}
|
|
1311
|
+
function responseInputTextChars(input) {
|
|
1312
|
+
if (typeof input === "string") return input.length;
|
|
1313
|
+
if (Array.isArray(input)) return input.reduce((total, item) => total + responseInputTextChars(item), 0);
|
|
1314
|
+
if (!input || typeof input !== "object") return 0;
|
|
1315
|
+
const record = input;
|
|
1316
|
+
let total = 0;
|
|
1317
|
+
if (typeof record.text === "string") total += record.text.length;
|
|
1318
|
+
if (typeof record.content === "string") total += record.content.length;
|
|
1319
|
+
else if (Array.isArray(record.content)) total += responseInputTextChars(record.content);
|
|
1320
|
+
return total;
|
|
1321
|
+
}
|
|
1322
|
+
function responseInputRoles(input) {
|
|
1323
|
+
if (!Array.isArray(input)) return "";
|
|
1324
|
+
const roles = /* @__PURE__ */ new Set();
|
|
1325
|
+
for (const item of input) if (item && typeof item === "object") {
|
|
1326
|
+
const role = item.role;
|
|
1327
|
+
if (typeof role === "string" && role.trim()) roles.add(role.trim());
|
|
1328
|
+
}
|
|
1329
|
+
return [...roles].toSorted().join(",");
|
|
1330
|
+
}
|
|
1331
|
+
function readResponsesToolDisplayName(tool) {
|
|
1332
|
+
if (!tool || typeof tool !== "object") return "";
|
|
1333
|
+
const record = tool;
|
|
1334
|
+
if (typeof record.name === "string") return record.name;
|
|
1335
|
+
const fn = record.function;
|
|
1336
|
+
if (fn && typeof fn === "object" && typeof fn.name === "string") return fn.name;
|
|
1337
|
+
return typeof record.type === "string" ? record.type : "";
|
|
1338
|
+
}
|
|
1339
|
+
function summarizeResponsesTools(tools) {
|
|
1340
|
+
if (!Array.isArray(tools)) return "count=0";
|
|
1341
|
+
const names = tools.map(readResponsesToolDisplayName).filter(Boolean);
|
|
1342
|
+
const mode = resolveModelPayloadDebugMode();
|
|
1343
|
+
const maxNames = mode === "tools" || mode === "full-redacted" ? names.length : 12;
|
|
1344
|
+
const label = maxNames >= names.length ? "names" : "sample";
|
|
1345
|
+
const shown = names.slice(0, maxNames).join(",");
|
|
1346
|
+
return `count=${tools.length}${shown ? ` ${label}=${shown}` : ""}`;
|
|
1347
|
+
}
|
|
1348
|
+
function responsesPayloadToolName(tool) {
|
|
1349
|
+
if (!isRecord(tool)) return;
|
|
1350
|
+
if (typeof tool.name === "string") return tool.name;
|
|
1351
|
+
const fn = tool.function;
|
|
1352
|
+
return isRecord(fn) && typeof fn.name === "string" ? fn.name : void 0;
|
|
1353
|
+
}
|
|
1354
|
+
function enforceCodeModeResponsesToolSurface(payload) {
|
|
1355
|
+
if (!isRecord(payload) || !Array.isArray(payload.tools)) return;
|
|
1356
|
+
payload.tools = payload.tools.filter((tool) => {
|
|
1357
|
+
const name = responsesPayloadToolName(tool);
|
|
1358
|
+
return name === "exec" || name === "wait";
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
function assertCodeModeResponsesToolSurface(payload) {
|
|
1362
|
+
if (!isRecord(payload) || !Array.isArray(payload.tools)) throw new Error("Code mode payload tool surface violation: expected exec,wait; got no tools");
|
|
1363
|
+
const names = payload.tools.map(responsesPayloadToolName).filter((name) => typeof name === "string" && name.length > 0).toSorted((a, b) => a.localeCompare(b));
|
|
1364
|
+
if (names.length === 2 && names[0] === "exec" && names[1] === "wait") return;
|
|
1365
|
+
throw new Error(`Code mode payload tool surface violation: expected exec,wait; got ${names.length > 0 ? names.join(",") : "none"}`);
|
|
1366
|
+
}
|
|
1367
|
+
function stringifyRedactedPayload(value) {
|
|
1368
|
+
try {
|
|
1369
|
+
const encoded = JSON.stringify(value);
|
|
1370
|
+
if (!encoded) return "<empty>";
|
|
1371
|
+
const redacted = redactSensitiveText(encoded, { mode: "tools" });
|
|
1372
|
+
return redacted.length > 8e3 ? `${redacted.slice(0, 8e3)}…<truncated>` : redacted;
|
|
1373
|
+
} catch {
|
|
1374
|
+
return "<unserializable>";
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
function stringifyRedactedEvent(value) {
|
|
1378
|
+
const redacted = stringifyRedactedPayload(value);
|
|
1379
|
+
return redacted.length > 2e3 ? `${redacted.slice(0, 2e3)}…<truncated>` : redacted;
|
|
1380
|
+
}
|
|
1381
|
+
const RESPONSE_FAILED_FAILURE_FIELD_KEYS = [
|
|
1382
|
+
"error",
|
|
1383
|
+
"incomplete_details",
|
|
1384
|
+
"status_details",
|
|
1385
|
+
"failure_reason",
|
|
1386
|
+
"last_error",
|
|
1387
|
+
"provider_error",
|
|
1388
|
+
"error_details"
|
|
1389
|
+
];
|
|
1390
|
+
function readResponseFailedString(record, key) {
|
|
1391
|
+
return stringifyUnknown(record?.[key]);
|
|
1392
|
+
}
|
|
1393
|
+
function buildResponsesFailedEventSummary(message, responseId, observation) {
|
|
1394
|
+
const summary = { message };
|
|
1395
|
+
if (responseId) summary.responseId = responseId;
|
|
1396
|
+
if (observation) summary.observation = observation;
|
|
1397
|
+
return summary;
|
|
1398
|
+
}
|
|
1399
|
+
function isResponseFailedIdentifierKey(key) {
|
|
1400
|
+
const normalized = key.replace(/[-_\s]/g, "").toLowerCase();
|
|
1401
|
+
return normalized === "requestid" || normalized === "xrequestid" || normalized === "providerrequestid" || normalized === "providerresponseid" || normalized === "litellmrequestid" || normalized.includes("request") && normalized.endsWith("id") || normalized.includes("provider") && normalized.endsWith("id");
|
|
1402
|
+
}
|
|
1403
|
+
function collectResponseFailedIdentifierHashes(value, opts = {}) {
|
|
1404
|
+
const path = opts.path ?? "";
|
|
1405
|
+
const depth = opts.depth ?? 0;
|
|
1406
|
+
const identifierKey = opts.identifierKey ?? "";
|
|
1407
|
+
const out = opts.out ?? [];
|
|
1408
|
+
const seen = opts.seen ?? /* @__PURE__ */ new WeakSet();
|
|
1409
|
+
if (out.length >= 12 || depth > 4 || !value || typeof value !== "object") return out;
|
|
1410
|
+
if (seen.has(value)) return out;
|
|
1411
|
+
seen.add(value);
|
|
1412
|
+
if (Array.isArray(value)) {
|
|
1413
|
+
for (const [index, item] of value.entries()) {
|
|
1414
|
+
if (index >= 8 || out.length >= 12) break;
|
|
1415
|
+
const itemString = typeof item === "string" || typeof item === "number" ? String(item).trim() : "";
|
|
1416
|
+
if (identifierKey && isResponseFailedIdentifierKey(identifierKey) && itemString) {
|
|
1417
|
+
out.push(`${path}[${index}]=${redactIdentifier(itemString, { len: 12 })}`);
|
|
1418
|
+
continue;
|
|
1419
|
+
}
|
|
1420
|
+
collectResponseFailedIdentifierHashes(item, {
|
|
1421
|
+
path: `${path}[${index}]`,
|
|
1422
|
+
depth: depth + 1,
|
|
1423
|
+
identifierKey,
|
|
1424
|
+
out,
|
|
1425
|
+
seen
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
return out;
|
|
1429
|
+
}
|
|
1430
|
+
for (const [key, child] of Object.entries(value)) {
|
|
1431
|
+
if (out.length >= 12) break;
|
|
1432
|
+
const childPath = path ? `${path}.${key}` : key;
|
|
1433
|
+
const childString = typeof child === "string" || typeof child === "number" ? String(child).trim() : "";
|
|
1434
|
+
if (isResponseFailedIdentifierKey(key) && childString) {
|
|
1435
|
+
out.push(`${childPath}=${redactIdentifier(childString, { len: 12 })}`);
|
|
1436
|
+
continue;
|
|
1437
|
+
}
|
|
1438
|
+
collectResponseFailedIdentifierHashes(child, {
|
|
1439
|
+
path: childPath,
|
|
1440
|
+
depth: depth + 1,
|
|
1441
|
+
identifierKey: isResponseFailedIdentifierKey(key) ? key : void 0,
|
|
1442
|
+
out,
|
|
1443
|
+
seen
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
return out;
|
|
1447
|
+
}
|
|
1448
|
+
function redactResponseFailedDiagnosticValue(value, opts = {}) {
|
|
1449
|
+
const key = opts.key ?? "";
|
|
1450
|
+
const depth = opts.depth ?? 0;
|
|
1451
|
+
if (typeof value === "string" || typeof value === "number") return key && isResponseFailedIdentifierKey(key) ? redactIdentifier(String(value), { len: 12 }) : value;
|
|
1452
|
+
if (depth > 6 || !value || typeof value !== "object") return value;
|
|
1453
|
+
const seen = opts.seen ?? /* @__PURE__ */ new WeakSet();
|
|
1454
|
+
if (seen.has(value)) return "<circular>";
|
|
1455
|
+
seen.add(value);
|
|
1456
|
+
if (Array.isArray(value)) return value.slice(0, 16).map((item) => redactResponseFailedDiagnosticValue(item, {
|
|
1457
|
+
key,
|
|
1458
|
+
depth: depth + 1,
|
|
1459
|
+
seen
|
|
1460
|
+
}));
|
|
1461
|
+
const out = {};
|
|
1462
|
+
for (const [childKey, child] of Object.entries(value)) out[childKey] = redactResponseFailedDiagnosticValue(child, {
|
|
1463
|
+
key: childKey,
|
|
1464
|
+
depth: depth + 1,
|
|
1465
|
+
seen
|
|
1466
|
+
});
|
|
1467
|
+
return out;
|
|
1468
|
+
}
|
|
1469
|
+
function buildResponsesFailedFailureFields(response) {
|
|
1470
|
+
if (!response) return {};
|
|
1471
|
+
const fields = {};
|
|
1472
|
+
for (const key of RESPONSE_FAILED_FAILURE_FIELD_KEYS) if (response[key] !== void 0 && response[key] !== null) fields[key] = response[key];
|
|
1473
|
+
return fields;
|
|
1474
|
+
}
|
|
1475
|
+
function buildResponsesFailedNoDetailsObservation(event, model, response = isRecord(event.response) ? event.response : void 0) {
|
|
1476
|
+
const failureFields = redactResponseFailedDiagnosticValue(buildResponsesFailedFailureFields(response));
|
|
1477
|
+
const metadataKeys = isRecord(response?.metadata) ? Object.keys(response.metadata).toSorted() : [];
|
|
1478
|
+
const responsePreview = {
|
|
1479
|
+
id: readResponseFailedString(response, "id"),
|
|
1480
|
+
status: readResponseFailedString(response, "status"),
|
|
1481
|
+
model: readResponseFailedString(response, "model"),
|
|
1482
|
+
object: readResponseFailedString(response, "object"),
|
|
1483
|
+
failureFields,
|
|
1484
|
+
metadataKeys
|
|
1485
|
+
};
|
|
1486
|
+
return {
|
|
1487
|
+
event: "openai_responses_response_failed_without_details",
|
|
1488
|
+
provider: model.provider,
|
|
1489
|
+
api: model.api,
|
|
1490
|
+
transportModel: model.id,
|
|
1491
|
+
providerRuntimeFailureKind: "no_error_details",
|
|
1492
|
+
responseId: responsePreview.id,
|
|
1493
|
+
responseStatus: responsePreview.status,
|
|
1494
|
+
responseModel: responsePreview.model,
|
|
1495
|
+
responseObject: responsePreview.object,
|
|
1496
|
+
metadataKeys,
|
|
1497
|
+
requestIdHashes: collectResponseFailedIdentifierHashes(event),
|
|
1498
|
+
failureFieldsPreview: stringifyRedactedEvent(failureFields),
|
|
1499
|
+
responsePreview: stringifyRedactedEvent(responsePreview)
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1502
|
+
function summarizeResponsesFailedNoDetailsObservation(observation) {
|
|
1503
|
+
const requestIds = observation.requestIdHashes.join(",");
|
|
1504
|
+
const metadataKeys = observation.metadataKeys.join(",");
|
|
1505
|
+
return `responseId=${safeDebugValue(observation.responseId || void 0)} responseStatus=${safeDebugValue(observation.responseStatus || void 0)} responseModel=${safeDebugValue(observation.responseModel || void 0)} requestIds=${requestIds || "none"} metadataKeys=${metadataKeys || "none"} failureFields=${observation.failureFieldsPreview}`;
|
|
1506
|
+
}
|
|
1507
|
+
function normalizeResponsesFailedEvent(event, model) {
|
|
1508
|
+
const response = isRecord(event.response) ? event.response : void 0;
|
|
1509
|
+
const responseId = readResponseFailedString(response, "id") || void 0;
|
|
1510
|
+
const error = isRecord(response?.error) ? response.error : void 0;
|
|
1511
|
+
if (error) {
|
|
1512
|
+
const code = readResponseFailedString(error, "code").trim();
|
|
1513
|
+
const message = readResponseFailedString(error, "message").trim();
|
|
1514
|
+
if (code || message) return buildResponsesFailedEventSummary(`${code || "unknown"}: ${message || "no message"}`, responseId);
|
|
1515
|
+
}
|
|
1516
|
+
const incompleteReason = readResponseFailedString(isRecord(response?.incomplete_details) ? response.incomplete_details : void 0, "reason");
|
|
1517
|
+
if (incompleteReason) return buildResponsesFailedEventSummary(`incomplete: ${incompleteReason}`, responseId);
|
|
1518
|
+
return buildResponsesFailedEventSummary(RESPONSE_FAILED_NO_DETAILS_MESSAGE, responseId, buildResponsesFailedNoDetailsObservation(event, model, response));
|
|
1519
|
+
}
|
|
1520
|
+
function logResponsesFailedNoDetails(observation) {
|
|
1521
|
+
log.warn(`[responses] response.failed missing error details provider=${observation.provider} api=${observation.api} model=${observation.transportModel} ` + summarizeResponsesFailedNoDetailsObservation(observation), observation);
|
|
1522
|
+
}
|
|
1523
|
+
function summarizeResponsesPayload(params) {
|
|
1524
|
+
if (!params || typeof params !== "object") return "payload=non-object";
|
|
1525
|
+
const record = params;
|
|
1526
|
+
const input = record.input;
|
|
1527
|
+
const reasoning = record.reasoning && typeof record.reasoning === "object" ? record.reasoning : void 0;
|
|
1528
|
+
const text = record.text && typeof record.text === "object" ? record.text : void 0;
|
|
1529
|
+
const parts = [
|
|
1530
|
+
`fields=${Object.keys(record).toSorted().join(",")}`,
|
|
1531
|
+
`model=${safeDebugValue(record.model)}`,
|
|
1532
|
+
`stream=${safeDebugValue(record.stream)}`,
|
|
1533
|
+
`inputItems=${Array.isArray(input) ? input.length : typeof input}`,
|
|
1534
|
+
`inputRoles=${responseInputRoles(input) || "none"}`,
|
|
1535
|
+
`inputTextChars=${responseInputTextChars(input)}`,
|
|
1536
|
+
`tools=${summarizeResponsesTools(record.tools)}`,
|
|
1537
|
+
`reasoningEffort=${safeDebugValue(reasoning?.effort)}`,
|
|
1538
|
+
`reasoningSummary=${safeDebugValue(reasoning?.summary)}`,
|
|
1539
|
+
`textVerbosity=${safeDebugValue(text?.verbosity)}`,
|
|
1540
|
+
`serviceTier=${safeDebugValue(record.service_tier)}`,
|
|
1541
|
+
`store=${safeDebugValue(record.store)}`,
|
|
1542
|
+
`promptCacheKey=${record.prompt_cache_key === void 0 ? "absent" : "present"}`,
|
|
1543
|
+
`metadataKeys=${record.metadata && typeof record.metadata === "object" ? Object.keys(record.metadata).toSorted().join(",") : "none"}`
|
|
1544
|
+
];
|
|
1545
|
+
if (resolveModelPayloadDebugMode() === "full-redacted") parts.push(`payload=${stringifyRedactedPayload(record)}`);
|
|
1546
|
+
return parts.join(" ");
|
|
1547
|
+
}
|
|
1548
|
+
function summarizeOpenAITransportError(error) {
|
|
1549
|
+
if (!error || typeof error !== "object") return `type=${typeof error} message=${safeDebugValue(error)}`;
|
|
1550
|
+
const record = error;
|
|
1551
|
+
const cause = record.cause && typeof record.cause === "object" ? record.cause : void 0;
|
|
1552
|
+
return [
|
|
1553
|
+
`name=${safeDebugValue(record.name)}`,
|
|
1554
|
+
`status=${safeDebugValue(record.status)}`,
|
|
1555
|
+
`code=${safeDebugValue(record.code)}`,
|
|
1556
|
+
`type=${safeDebugValue(record.type)}`,
|
|
1557
|
+
`causeName=${safeDebugValue(cause?.name)}`,
|
|
1558
|
+
`causeCode=${safeDebugValue(cause?.code)}`,
|
|
1559
|
+
`message=${error instanceof Error ? error.message : safeDebugValue(error)}`
|
|
1560
|
+
].join(" ");
|
|
1561
|
+
}
|
|
1562
|
+
function isInvalidEncryptedContentError(error) {
|
|
1563
|
+
if (!error || typeof error !== "object") return false;
|
|
1564
|
+
const record = error;
|
|
1565
|
+
if (record.code === "invalid_encrypted_content") return true;
|
|
1566
|
+
return typeof record.message === "string" && record.message.includes("invalid_encrypted_content");
|
|
1567
|
+
}
|
|
1568
|
+
function stripEncryptedContentFields(value) {
|
|
1569
|
+
if (!value || typeof value !== "object") return {
|
|
1570
|
+
value,
|
|
1571
|
+
changed: false
|
|
1572
|
+
};
|
|
1573
|
+
if (Array.isArray(value)) {
|
|
1574
|
+
let changed = false;
|
|
1575
|
+
const next = value.map((item) => {
|
|
1576
|
+
const stripped = stripEncryptedContentFields(item);
|
|
1577
|
+
changed ||= stripped.changed;
|
|
1578
|
+
return stripped.value;
|
|
1579
|
+
});
|
|
1580
|
+
return changed ? {
|
|
1581
|
+
value: next,
|
|
1582
|
+
changed: true
|
|
1583
|
+
} : {
|
|
1584
|
+
value,
|
|
1585
|
+
changed: false
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
let changed = false;
|
|
1589
|
+
const next = {};
|
|
1590
|
+
for (const [key, child] of Object.entries(value)) {
|
|
1591
|
+
if (key === "encrypted_content") {
|
|
1592
|
+
changed = true;
|
|
1593
|
+
continue;
|
|
1594
|
+
}
|
|
1595
|
+
const stripped = stripEncryptedContentFields(child);
|
|
1596
|
+
changed ||= stripped.changed;
|
|
1597
|
+
next[key] = stripped.value;
|
|
1598
|
+
}
|
|
1599
|
+
return changed ? {
|
|
1600
|
+
value: next,
|
|
1601
|
+
changed: true
|
|
1602
|
+
} : {
|
|
1603
|
+
value,
|
|
1604
|
+
changed: false
|
|
1605
|
+
};
|
|
1606
|
+
}
|
|
1607
|
+
function stripResponsesRequestEncryptedContent(params) {
|
|
1608
|
+
const stripped = stripEncryptedContentFields(params.input);
|
|
1609
|
+
if (!stripped.changed) return params;
|
|
1610
|
+
return {
|
|
1611
|
+
...params,
|
|
1612
|
+
input: stripped.value
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
function hashOptionalReplayContextValue(value) {
|
|
1616
|
+
const normalized = value?.trim();
|
|
1617
|
+
return normalized ? shortHash(normalized) : void 0;
|
|
1618
|
+
}
|
|
1619
|
+
function buildOpenAIResponsesReplayContext(model, options) {
|
|
1620
|
+
return {
|
|
1621
|
+
provider: model.provider,
|
|
1622
|
+
api: model.api,
|
|
1623
|
+
model: model.id,
|
|
1624
|
+
baseUrlHash: hashOptionalReplayContextValue(model.baseUrl),
|
|
1625
|
+
sessionHash: hashOptionalReplayContextValue(options?.sessionId),
|
|
1626
|
+
authProfileHash: hashOptionalReplayContextValue(options?.authProfileId)
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
function buildOpenAIResponsesReasoningReplayMetadata(model, options) {
|
|
1630
|
+
return {
|
|
1631
|
+
v: 1,
|
|
1632
|
+
source: "openai-responses",
|
|
1633
|
+
...buildOpenAIResponsesReplayContext(model, options)
|
|
1634
|
+
};
|
|
1635
|
+
}
|
|
1636
|
+
function isOpenAIResponsesReasoningReplayMetadata(value) {
|
|
1637
|
+
if (!value || typeof value !== "object") return false;
|
|
1638
|
+
const record = value;
|
|
1639
|
+
return record.v === 1 && record.source === "openai-responses" && typeof record.provider === "string" && typeof record.api === "string" && typeof record.model === "string" && (record.baseUrlHash === void 0 || typeof record.baseUrlHash === "string") && (record.sessionHash === void 0 || typeof record.sessionHash === "string") && (record.authProfileHash === void 0 || typeof record.authProfileHash === "string");
|
|
1640
|
+
}
|
|
1641
|
+
function encryptedReasoningReplayMetadataMatches(metadata, context) {
|
|
1642
|
+
return !!metadata && metadata.provider === context.provider && metadata.api === context.api && metadata.model === context.model && metadata.baseUrlHash === context.baseUrlHash && metadata.sessionHash === context.sessionHash && metadata.authProfileHash === context.authProfileHash;
|
|
1643
|
+
}
|
|
1644
|
+
function readOpenAIResponsesReasoningReplayBlockMetadata(block) {
|
|
1645
|
+
const value = block[OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY];
|
|
1646
|
+
return isOpenAIResponsesReasoningReplayMetadata(value) ? value : void 0;
|
|
1647
|
+
}
|
|
1648
|
+
function prepareOpenAIResponsesReasoningItemForReplay(item, context, blockMetadata) {
|
|
1649
|
+
const { [OPENAI_RESPONSES_REASONING_REPLAY_META_KEY]: rawMetadata, ...rest } = item;
|
|
1650
|
+
if (!("encrypted_content" in rest)) return rest;
|
|
1651
|
+
if (encryptedReasoningReplayMetadataMatches(blockMetadata ?? (isOpenAIResponsesReasoningReplayMetadata(rawMetadata) ? rawMetadata : void 0), context)) return rest;
|
|
1652
|
+
return stripEncryptedContentFields(rest).value;
|
|
1653
|
+
}
|
|
1654
|
+
async function createResponsesStreamWithEncryptedContentRetry(params) {
|
|
1655
|
+
try {
|
|
1656
|
+
return await params.client.responses.create(params.request, params.requestOptions);
|
|
1657
|
+
} catch (error) {
|
|
1658
|
+
const retryRequest = stripResponsesRequestEncryptedContent(params.request);
|
|
1659
|
+
if (!isInvalidEncryptedContentError(error) || retryRequest === params.request) throw error;
|
|
1660
|
+
log.warn(`[responses] retrying without encrypted reasoning content provider=${params.model.provider} api=${params.model.api} model=${params.model.id}`);
|
|
1661
|
+
return await params.client.responses.create(retryRequest, params.requestOptions);
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
function resolveAzureOpenAIApiVersion(env = process.env) {
|
|
1665
|
+
return env.AZURE_OPENAI_API_VERSION?.trim() || DEFAULT_AZURE_OPENAI_API_VERSION;
|
|
1666
|
+
}
|
|
1667
|
+
function shortHash(value) {
|
|
1668
|
+
return createHash("sha256").update(value).digest("hex").slice(0, 16);
|
|
1669
|
+
}
|
|
1670
|
+
function normalizeResponsesReplayItemId(id, prefix) {
|
|
1671
|
+
if (!id) return;
|
|
1672
|
+
if (id.length <= OPENAI_RESPONSES_REPLAY_ITEM_ID_MAX_LENGTH) return id;
|
|
1673
|
+
return `${prefix}_${shortHash(id)}`;
|
|
1674
|
+
}
|
|
1675
|
+
function isSafeResponsesReplayItemId(id) {
|
|
1676
|
+
return typeof id === "string" && id.length > 0 && id.length <= OPENAI_RESPONSES_REPLAY_ITEM_ID_MAX_LENGTH;
|
|
1677
|
+
}
|
|
1678
|
+
function encodeTextSignatureV1(id, phase) {
|
|
1679
|
+
return JSON.stringify({
|
|
1680
|
+
v: 1,
|
|
1681
|
+
id,
|
|
1682
|
+
...phase ? { phase } : {}
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1685
|
+
function parseTextSignature(signature) {
|
|
1686
|
+
if (!signature) return;
|
|
1687
|
+
if (signature.startsWith("{")) try {
|
|
1688
|
+
const parsed = JSON.parse(signature);
|
|
1689
|
+
if (parsed.v === 1 && typeof parsed.id === "string") return parsed.phase === "commentary" || parsed.phase === "final_answer" ? {
|
|
1690
|
+
id: parsed.id,
|
|
1691
|
+
phase: parsed.phase
|
|
1692
|
+
} : { id: parsed.id };
|
|
1693
|
+
} catch {}
|
|
1694
|
+
return { id: signature };
|
|
1695
|
+
}
|
|
1696
|
+
function convertResponsesMessages(model, context, allowedToolCallProviders, options) {
|
|
1697
|
+
const messages = [];
|
|
1698
|
+
const shouldReplayReasoningItems = options?.replayReasoningItems ?? true;
|
|
1699
|
+
const shouldReplayResponsesItemIds = options?.replayResponsesItemIds ?? true;
|
|
1700
|
+
const replayContext = buildOpenAIResponsesReplayContext(model, {
|
|
1701
|
+
sessionId: options?.sessionId,
|
|
1702
|
+
authProfileId: options?.authProfileId
|
|
1703
|
+
});
|
|
1704
|
+
const shouldNormalizeSameModelToolCallIds = model.provider === "github-copilot";
|
|
1705
|
+
const sanitizeIdPart = (part) => part.replace(/[^a-zA-Z0-9_-]/g, "_").replace(/_+$/, "");
|
|
1706
|
+
const normalizeIdPart = (part) => {
|
|
1707
|
+
const sanitized = sanitizeIdPart(part);
|
|
1708
|
+
return (sanitized.length > 64 ? sanitized.slice(0, 64) : sanitized).replace(/_+$/, "");
|
|
1709
|
+
};
|
|
1710
|
+
const buildForeignResponsesItemId = (itemId) => {
|
|
1711
|
+
const normalized = `fc_${shortHash(itemId)}`;
|
|
1712
|
+
return normalized.length > 64 ? normalized.slice(0, 64) : normalized;
|
|
1713
|
+
};
|
|
1714
|
+
const buildSameProviderCopilotResponsesItemId = (itemId) => {
|
|
1715
|
+
const sanitized = sanitizeIdPart(itemId);
|
|
1716
|
+
const candidate = sanitized.startsWith("fc_") ? sanitized : `fc_${sanitized}`;
|
|
1717
|
+
return candidate.length > 64 ? buildForeignResponsesItemId(itemId) : candidate;
|
|
1718
|
+
};
|
|
1719
|
+
const normalizeToolCallId = (id, _targetModel, source) => {
|
|
1720
|
+
if (!allowedToolCallProviders.has(model.provider)) return normalizeIdPart(id);
|
|
1721
|
+
if (!id.includes("|")) return normalizeIdPart(id);
|
|
1722
|
+
const [callId, itemId] = id.split("|");
|
|
1723
|
+
const normalizedCallId = normalizeIdPart(callId);
|
|
1724
|
+
let normalizedItemId = source.provider !== model.provider || source.api !== model.api ? buildForeignResponsesItemId(itemId) : model.provider === "github-copilot" ? buildSameProviderCopilotResponsesItemId(itemId) : normalizeIdPart(itemId);
|
|
1725
|
+
if (!normalizedItemId.startsWith("fc_")) normalizedItemId = normalizeIdPart(`fc_${normalizedItemId}`);
|
|
1726
|
+
return `${normalizedCallId}|${normalizedItemId}`;
|
|
1727
|
+
};
|
|
1728
|
+
const transformedMessages = transformTransportMessages(context.messages, model, normalizeToolCallId, { normalizeSameModelToolCallIds: shouldNormalizeSameModelToolCallIds });
|
|
1729
|
+
if ((options?.includeSystemPrompt ?? true) && context.systemPrompt) messages.push({
|
|
1730
|
+
role: model.reasoning && options?.supportsDeveloperRole !== false ? "developer" : "system",
|
|
1731
|
+
content: sanitizeTransportPayloadText(stripSystemPromptCacheBoundary(context.systemPrompt))
|
|
1732
|
+
});
|
|
1733
|
+
let msgIndex = 0;
|
|
1734
|
+
for (const msg of transformedMessages) {
|
|
1735
|
+
if (msg.role === "user") if (typeof msg.content === "string") messages.push({
|
|
1736
|
+
role: "user",
|
|
1737
|
+
content: [{
|
|
1738
|
+
type: "input_text",
|
|
1739
|
+
text: sanitizeTransportPayloadText(msg.content)
|
|
1740
|
+
}]
|
|
1741
|
+
});
|
|
1742
|
+
else {
|
|
1743
|
+
const content = msg.content.map((item) => item.type === "text" ? {
|
|
1744
|
+
type: "input_text",
|
|
1745
|
+
text: sanitizeTransportPayloadText(item.text)
|
|
1746
|
+
} : {
|
|
1747
|
+
type: "input_image",
|
|
1748
|
+
detail: "auto",
|
|
1749
|
+
image_url: `data:${item.mimeType};base64,${item.data}`
|
|
1750
|
+
}).filter((item) => model.input.includes("image") || item.type !== "input_image");
|
|
1751
|
+
if (content.length > 0) messages.push({
|
|
1752
|
+
role: "user",
|
|
1753
|
+
content
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
else if (msg.role === "assistant") {
|
|
1757
|
+
const output = [];
|
|
1758
|
+
const isDifferentModel = msg.model !== model.id && msg.provider === model.provider && msg.api === model.api;
|
|
1759
|
+
for (const block of msg.content) if (block.type === "thinking") {
|
|
1760
|
+
if (shouldReplayReasoningItems && block.thinkingSignature && block.thinkingSignature.startsWith("{")) {
|
|
1761
|
+
const replayableReasoningItem = prepareOpenAIResponsesReasoningItemForReplay(JSON.parse(block.thinkingSignature), replayContext, readOpenAIResponsesReasoningReplayBlockMetadata(block));
|
|
1762
|
+
if (!shouldReplayResponsesItemIds) delete replayableReasoningItem.id;
|
|
1763
|
+
if (model.provider === "github-copilot" && !isSafeResponsesReplayItemId(replayableReasoningItem.id)) continue;
|
|
1764
|
+
output.push(replayableReasoningItem);
|
|
1765
|
+
}
|
|
1766
|
+
} else if (block.type === "text") {
|
|
1767
|
+
const textSignature = parseTextSignature(block.textSignature);
|
|
1768
|
+
let msgId = shouldReplayResponsesItemIds ? textSignature?.id ?? `msg_${msgIndex}` : void 0;
|
|
1769
|
+
msgId = normalizeResponsesReplayItemId(msgId, "msg");
|
|
1770
|
+
const messageItem = {
|
|
1771
|
+
type: "message",
|
|
1772
|
+
role: "assistant",
|
|
1773
|
+
content: [{
|
|
1774
|
+
type: "output_text",
|
|
1775
|
+
text: sanitizeTransportPayloadText(block.text),
|
|
1776
|
+
annotations: []
|
|
1777
|
+
}],
|
|
1778
|
+
status: "completed",
|
|
1779
|
+
...msgId ? { id: msgId } : {},
|
|
1780
|
+
phase: textSignature?.phase
|
|
1781
|
+
};
|
|
1782
|
+
output.push(messageItem);
|
|
1783
|
+
} else if (block.type === "toolCall") {
|
|
1784
|
+
const [callId, itemIdRaw] = block.id.split("|");
|
|
1785
|
+
const itemId = shouldReplayResponsesItemIds && !(isDifferentModel && itemIdRaw?.startsWith("fc_")) ? itemIdRaw : void 0;
|
|
1786
|
+
output.push({
|
|
1787
|
+
type: "function_call",
|
|
1788
|
+
id: itemId,
|
|
1789
|
+
call_id: callId,
|
|
1790
|
+
name: block.name,
|
|
1791
|
+
arguments: typeof block.arguments === "string" ? block.arguments : JSON.stringify(block.arguments ?? {})
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
if (output.length > 0) messages.push(...output);
|
|
1795
|
+
} else if (msg.role === "toolResult") {
|
|
1796
|
+
const textResult = msg.content.filter((item) => item.type === "text").map((item) => item.text).join("\n");
|
|
1797
|
+
const hasImages = msg.content.some((item) => item.type === "image");
|
|
1798
|
+
const [callId] = msg.toolCallId.split("|");
|
|
1799
|
+
messages.push({
|
|
1800
|
+
type: "function_call_output",
|
|
1801
|
+
call_id: callId,
|
|
1802
|
+
output: hasImages && model.input.includes("image") ? [...textResult ? [{
|
|
1803
|
+
type: "input_text",
|
|
1804
|
+
text: sanitizeTransportPayloadText(textResult)
|
|
1805
|
+
}] : [], ...msg.content.filter((item) => item.type === "image").map((item) => ({
|
|
1806
|
+
type: "input_image",
|
|
1807
|
+
detail: "auto",
|
|
1808
|
+
image_url: `data:${item.mimeType};base64,${item.data}`
|
|
1809
|
+
}))] : sanitizeTransportPayloadText(textResult || "(see attached image)")
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
msgIndex += 1;
|
|
1813
|
+
}
|
|
1814
|
+
return messages;
|
|
1815
|
+
}
|
|
1816
|
+
function convertResponsesTools(tools, model, options) {
|
|
1817
|
+
const strict = resolveOpenAIStrictToolFlagWithDiagnostics(tools, options?.strict, {
|
|
1818
|
+
transport: "responses",
|
|
1819
|
+
model
|
|
1820
|
+
});
|
|
1821
|
+
return sortTransportToolsByName(tools).map((tool) => {
|
|
1822
|
+
const result = {
|
|
1823
|
+
type: "function",
|
|
1824
|
+
name: tool.name,
|
|
1825
|
+
description: tool.description,
|
|
1826
|
+
parameters: normalizeOpenAIStrictToolParameters(tool.parameters, strict === true, model.compat)
|
|
1827
|
+
};
|
|
1828
|
+
if (strict !== void 0) result.strict = strict;
|
|
1829
|
+
return result;
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
function resolveOpenAIStrictToolFlagWithDiagnostics(tools, strictSetting, context) {
|
|
1833
|
+
const strict = resolveOpenAIStrictToolFlagForInventory(tools, strictSetting);
|
|
1834
|
+
if (strictSetting === true && strict === false && log.isEnabled("debug", "any")) {
|
|
1835
|
+
const diagnostics = findOpenAIStrictToolSchemaDiagnostics(tools);
|
|
1836
|
+
if (!shouldLogOpenAIStrictToolDowngradeDiagnostic(diagnostics, context)) return strict;
|
|
1837
|
+
const sample = diagnostics.slice(0, 5).map((entry) => ({
|
|
1838
|
+
tool: entry.toolName ?? `tool[${entry.toolIndex}]`,
|
|
1839
|
+
violations: entry.violations.slice(0, 8)
|
|
1840
|
+
}));
|
|
1841
|
+
log.debug(`OpenAI ${context.transport} tool schema strict mode downgraded to strict=false for ${context.model.provider ?? "unknown"}/${context.model.id ?? "unknown"} because ${diagnostics.length} tool schema(s) are not strict-compatible`, {
|
|
1842
|
+
transport: context.transport,
|
|
1843
|
+
provider: context.model.provider,
|
|
1844
|
+
model: context.model.id,
|
|
1845
|
+
incompatibleToolCount: diagnostics.length,
|
|
1846
|
+
sample
|
|
1847
|
+
});
|
|
1848
|
+
}
|
|
1849
|
+
return strict;
|
|
1850
|
+
}
|
|
1851
|
+
function buildOpenAIStrictToolDowngradeDiagnosticKey(diagnostics, context) {
|
|
1852
|
+
return createHash("sha256").update(JSON.stringify({
|
|
1853
|
+
transport: context.transport,
|
|
1854
|
+
provider: context.model.provider ?? null,
|
|
1855
|
+
model: context.model.id ?? null,
|
|
1856
|
+
diagnostics: diagnostics.map((entry) => ({
|
|
1857
|
+
toolIndex: entry.toolIndex,
|
|
1858
|
+
toolName: entry.toolName ?? null,
|
|
1859
|
+
violations: entry.violations
|
|
1860
|
+
}))
|
|
1861
|
+
})).digest("hex");
|
|
1862
|
+
}
|
|
1863
|
+
function shouldLogOpenAIStrictToolDowngradeDiagnostic(diagnostics, context) {
|
|
1864
|
+
const key = buildOpenAIStrictToolDowngradeDiagnosticKey(diagnostics, context);
|
|
1865
|
+
if (loggedOpenAIStrictToolDowngradeDiagnosticKeys.has(key)) return false;
|
|
1866
|
+
if (loggedOpenAIStrictToolDowngradeDiagnosticKeys.size >= MAX_OPENAI_STRICT_TOOL_DOWNGRADE_DIAGNOSTIC_KEYS) loggedOpenAIStrictToolDowngradeDiagnosticKeys.clear();
|
|
1867
|
+
loggedOpenAIStrictToolDowngradeDiagnosticKeys.add(key);
|
|
1868
|
+
return true;
|
|
1869
|
+
}
|
|
1870
|
+
function createResponsesFirstEventTimeoutError(model, timeoutMs) {
|
|
1871
|
+
return /* @__PURE__ */ new Error(`Azure OpenAI Responses stream did not deliver a first event within ${timeoutMs}ms after HTTP streaming headers. provider=${model.provider} model=${model.id}. The provider may be stalled while parsing the tool payload; retry with a smaller tool surface or enable FENGMING_DEBUG_MODEL_PAYLOAD=tools to inspect exposed tools.`);
|
|
1872
|
+
}
|
|
1873
|
+
function withResponsesFirstEventTimeout(openaiStream, model, timeoutMs) {
|
|
1874
|
+
if (timeoutMs === void 0 || timeoutMs <= 0 || !Number.isFinite(timeoutMs)) return openaiStream;
|
|
1875
|
+
return { async *[Symbol.asyncIterator]() {
|
|
1876
|
+
const iterator = openaiStream[Symbol.asyncIterator]();
|
|
1877
|
+
let timer;
|
|
1878
|
+
const clear = () => {
|
|
1879
|
+
if (timer) {
|
|
1880
|
+
clearTimeout(timer);
|
|
1881
|
+
timer = void 0;
|
|
1882
|
+
}
|
|
1883
|
+
};
|
|
1884
|
+
try {
|
|
1885
|
+
const first = await new Promise((resolve, reject) => {
|
|
1886
|
+
timer = setTimeout(() => reject(createResponsesFirstEventTimeoutError(model, timeoutMs)), timeoutMs);
|
|
1887
|
+
iterator.next().then(resolve, reject);
|
|
1888
|
+
}).finally(clear);
|
|
1889
|
+
if (first.done) return;
|
|
1890
|
+
yield first.value;
|
|
1891
|
+
for (;;) {
|
|
1892
|
+
const next = await iterator.next();
|
|
1893
|
+
if (next.done) return;
|
|
1894
|
+
yield next.value;
|
|
1895
|
+
}
|
|
1896
|
+
} catch (error) {
|
|
1897
|
+
iterator.return?.().catch(() => void 0);
|
|
1898
|
+
throw error;
|
|
1899
|
+
} finally {
|
|
1900
|
+
clear();
|
|
1901
|
+
}
|
|
1902
|
+
} };
|
|
1903
|
+
}
|
|
1904
|
+
async function processResponsesStream(openaiStream, output, stream, model, options) {
|
|
1905
|
+
let currentItem = null;
|
|
1906
|
+
let currentBlock = null;
|
|
1907
|
+
const streamStartedAt = Date.now();
|
|
1908
|
+
let eventCount = 0;
|
|
1909
|
+
const eventTypes = /* @__PURE__ */ new Map();
|
|
1910
|
+
const sseDebugMode = resolveModelSseDebugMode();
|
|
1911
|
+
const blockIndex = () => output.content.length - 1;
|
|
1912
|
+
const guardedStream = withResponsesFirstEventTimeout(openaiStream, model, options?.firstEventTimeoutMs);
|
|
1913
|
+
const cooperativeScheduler = createModelStreamCooperativeScheduler(options?.signal);
|
|
1914
|
+
for await (const rawEvent of guardedStream) {
|
|
1915
|
+
throwIfModelStreamAborted(options?.signal);
|
|
1916
|
+
const event = rawEvent;
|
|
1917
|
+
const type = stringifyUnknown(event.type);
|
|
1918
|
+
eventCount += 1;
|
|
1919
|
+
eventTypes.set(type, (eventTypes.get(type) ?? 0) + 1);
|
|
1920
|
+
if (eventCount === 1) emitModelTransportDebug(log, `[responses] first_event provider=${model.provider} api=${model.api} model=${model.id} elapsedMs=${Date.now() - streamStartedAt} type=${type}`);
|
|
1921
|
+
if (sseDebugMode === "peek" && eventCount <= 5) emitModelTransportDebug(log, `[responses] event_peek provider=${model.provider} api=${model.api} model=${model.id} index=${eventCount} type=${type} event=${stringifyRedactedEvent(event)}`);
|
|
1922
|
+
if (type === "response.created") output.responseId = stringifyUnknown(event.response?.id);
|
|
1923
|
+
else if (type === "response.output_item.added") {
|
|
1924
|
+
const item = event.item;
|
|
1925
|
+
if (item.type === "reasoning") {
|
|
1926
|
+
currentItem = item;
|
|
1927
|
+
currentBlock = {
|
|
1928
|
+
type: "thinking",
|
|
1929
|
+
thinking: ""
|
|
1930
|
+
};
|
|
1931
|
+
output.content.push(currentBlock);
|
|
1932
|
+
stream.push({
|
|
1933
|
+
type: "thinking_start",
|
|
1934
|
+
contentIndex: blockIndex(),
|
|
1935
|
+
partial: output
|
|
1936
|
+
});
|
|
1937
|
+
} else if (item.type === "message") {
|
|
1938
|
+
currentItem = item;
|
|
1939
|
+
currentBlock = {
|
|
1940
|
+
type: "text",
|
|
1941
|
+
text: ""
|
|
1942
|
+
};
|
|
1943
|
+
output.content.push(currentBlock);
|
|
1944
|
+
stream.push({
|
|
1945
|
+
type: "text_start",
|
|
1946
|
+
contentIndex: blockIndex(),
|
|
1947
|
+
partial: output
|
|
1948
|
+
});
|
|
1949
|
+
} else if (item.type === "function_call") {
|
|
1950
|
+
currentItem = item;
|
|
1951
|
+
currentBlock = {
|
|
1952
|
+
type: "toolCall",
|
|
1953
|
+
id: `${stringifyUnknown(item.call_id)}|${stringifyUnknown(item.id)}`,
|
|
1954
|
+
name: stringifyUnknown(item.name),
|
|
1955
|
+
arguments: {},
|
|
1956
|
+
partialJson: stringifyJsonLike(item.arguments)
|
|
1957
|
+
};
|
|
1958
|
+
output.content.push(currentBlock);
|
|
1959
|
+
stream.push({
|
|
1960
|
+
type: "toolcall_start",
|
|
1961
|
+
contentIndex: blockIndex(),
|
|
1962
|
+
partial: output
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
} else if (type === "response.reasoning_summary_text.delta") {
|
|
1966
|
+
if (currentItem?.type === "reasoning" && currentBlock?.type === "thinking") {
|
|
1967
|
+
currentBlock.thinking = `${stringifyUnknown(currentBlock.thinking)}${stringifyUnknown(event.delta)}`;
|
|
1968
|
+
stream.push({
|
|
1969
|
+
type: "thinking_delta",
|
|
1970
|
+
contentIndex: blockIndex(),
|
|
1971
|
+
delta: stringifyUnknown(event.delta),
|
|
1972
|
+
partial: output
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
} else if (type === "response.output_text.delta" || type === "response.refusal.delta") {
|
|
1976
|
+
if (currentItem?.type === "message" && currentBlock?.type === "text") {
|
|
1977
|
+
currentBlock.text = `${stringifyUnknown(currentBlock.text)}${stringifyUnknown(event.delta)}`;
|
|
1978
|
+
stream.push({
|
|
1979
|
+
type: "text_delta",
|
|
1980
|
+
contentIndex: blockIndex(),
|
|
1981
|
+
delta: stringifyUnknown(event.delta),
|
|
1982
|
+
partial: output
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
} else if (type === "response.function_call_arguments.delta") {
|
|
1986
|
+
if (currentItem?.type === "function_call" && currentBlock?.type === "toolCall") {
|
|
1987
|
+
currentBlock.partialJson = `${stringifyJsonLike(currentBlock.partialJson)}${stringifyJsonLike(event.delta)}`;
|
|
1988
|
+
currentBlock.arguments = parseStreamingJson(stringifyJsonLike(currentBlock.partialJson));
|
|
1989
|
+
stream.push({
|
|
1990
|
+
type: "toolcall_delta",
|
|
1991
|
+
contentIndex: blockIndex(),
|
|
1992
|
+
delta: stringifyJsonLike(event.delta),
|
|
1993
|
+
partial: output
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1996
|
+
} else if (type === "response.output_item.done") {
|
|
1997
|
+
const item = event.item;
|
|
1998
|
+
if (item.type === "reasoning" && currentBlock?.type === "thinking") {
|
|
1999
|
+
const summary = Array.isArray(item.summary) ? item.summary.map((part) => {
|
|
2000
|
+
return part.text ?? "";
|
|
2001
|
+
}).join("\n\n") : "";
|
|
2002
|
+
currentBlock.thinking = summary;
|
|
2003
|
+
currentBlock.thinkingSignature = JSON.stringify(item);
|
|
2004
|
+
if ("encrypted_content" in item) currentBlock[OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY] = buildOpenAIResponsesReasoningReplayMetadata(model, {
|
|
2005
|
+
authProfileId: options?.authProfileId,
|
|
2006
|
+
sessionId: options?.sessionId
|
|
2007
|
+
});
|
|
2008
|
+
stream.push({
|
|
2009
|
+
type: "thinking_end",
|
|
2010
|
+
contentIndex: blockIndex(),
|
|
2011
|
+
content: stringifyUnknown(currentBlock.thinking),
|
|
2012
|
+
partial: output
|
|
2013
|
+
});
|
|
2014
|
+
currentBlock = null;
|
|
2015
|
+
} else if (item.type === "message" && currentBlock?.type === "text") {
|
|
2016
|
+
const content = Array.isArray(item.content) ? item.content : [];
|
|
2017
|
+
currentBlock.text = content.map((part) => {
|
|
2018
|
+
const contentPart = part;
|
|
2019
|
+
return contentPart.type === "output_text" ? contentPart.text ?? "" : contentPart.refusal ?? "";
|
|
2020
|
+
}).join("");
|
|
2021
|
+
currentBlock.textSignature = encodeTextSignatureV1(stringifyUnknown(item.id), item.phase ?? void 0);
|
|
2022
|
+
stream.push({
|
|
2023
|
+
type: "text_end",
|
|
2024
|
+
contentIndex: blockIndex(),
|
|
2025
|
+
content: stringifyUnknown(currentBlock.text),
|
|
2026
|
+
partial: output
|
|
2027
|
+
});
|
|
2028
|
+
currentBlock = null;
|
|
2029
|
+
} else if (item.type === "function_call") {
|
|
2030
|
+
const args = currentBlock?.type === "toolCall" && currentBlock.partialJson ? parseStreamingJson(stringifyJsonLike(currentBlock.partialJson, "{}")) : parseStreamingJson(stringifyJsonLike(item.arguments, "{}"));
|
|
2031
|
+
stream.push({
|
|
2032
|
+
type: "toolcall_end",
|
|
2033
|
+
contentIndex: blockIndex(),
|
|
2034
|
+
toolCall: {
|
|
2035
|
+
type: "toolCall",
|
|
2036
|
+
id: `${stringifyUnknown(item.call_id)}|${stringifyUnknown(item.id)}`,
|
|
2037
|
+
name: stringifyUnknown(item.name),
|
|
2038
|
+
arguments: args
|
|
2039
|
+
},
|
|
2040
|
+
partial: output
|
|
2041
|
+
});
|
|
2042
|
+
currentBlock = null;
|
|
2043
|
+
}
|
|
2044
|
+
} else if (type === "response.completed") {
|
|
2045
|
+
const response = event.response;
|
|
2046
|
+
if (typeof response?.id === "string") output.responseId = response.id;
|
|
2047
|
+
const usage = response?.usage;
|
|
2048
|
+
if (usage) {
|
|
2049
|
+
const cachedTokens = usage.input_tokens_details?.cached_tokens || 0;
|
|
2050
|
+
const inputTokens = usage.input_tokens || 0;
|
|
2051
|
+
const outputTokens = usage.output_tokens || 0;
|
|
2052
|
+
const reasoningTokens = usage.output_tokens_details?.reasoning_tokens;
|
|
2053
|
+
const input = Math.max(0, inputTokens - cachedTokens);
|
|
2054
|
+
output.usage = {
|
|
2055
|
+
input,
|
|
2056
|
+
output: outputTokens,
|
|
2057
|
+
cacheRead: cachedTokens,
|
|
2058
|
+
cacheWrite: 0,
|
|
2059
|
+
...typeof reasoningTokens === "number" && Number.isFinite(reasoningTokens) ? { reasoningTokens } : {},
|
|
2060
|
+
totalTokens: input + outputTokens + cachedTokens,
|
|
2061
|
+
cost: {
|
|
2062
|
+
input: 0,
|
|
2063
|
+
output: 0,
|
|
2064
|
+
cacheRead: 0,
|
|
2065
|
+
cacheWrite: 0,
|
|
2066
|
+
total: 0
|
|
2067
|
+
}
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2070
|
+
calculateCost(model, output.usage);
|
|
2071
|
+
if (options?.applyServiceTierPricing) options.applyServiceTierPricing(output.usage, response?.service_tier ?? options.serviceTier);
|
|
2072
|
+
output.stopReason = mapResponsesStopReason(response?.status);
|
|
2073
|
+
if (output.content.some((block) => block.type === "toolCall") && output.stopReason === "stop") output.stopReason = "toolUse";
|
|
2074
|
+
} else if (type === "error") throw new Error(`Error Code ${stringifyUnknown(event.code, "unknown")}: ${stringifyUnknown(event.message, "Unknown error")}`);
|
|
2075
|
+
else if (type === "response.failed") {
|
|
2076
|
+
const failure = normalizeResponsesFailedEvent(event, model);
|
|
2077
|
+
if (failure.responseId) output.responseId = failure.responseId;
|
|
2078
|
+
if (failure.observation) logResponsesFailedNoDetails(failure.observation);
|
|
2079
|
+
throw new Error(failure.message);
|
|
2080
|
+
}
|
|
2081
|
+
await cooperativeScheduler.afterEvent();
|
|
2082
|
+
}
|
|
2083
|
+
const eventTypeSummary = [...eventTypes.entries()].slice(0, 12).map(([eventType, count]) => `${eventType}:${count}`).join(",");
|
|
2084
|
+
emitModelTransportDebug(log, `[responses] stream_done provider=${model.provider} api=${model.api} model=${model.id} elapsedMs=${Date.now() - streamStartedAt} events=${eventCount} types=${eventTypeSummary} stopReason=${output.stopReason ?? "unset"} contentBlocks=${output.content.length}`);
|
|
2085
|
+
}
|
|
2086
|
+
function mapResponsesStopReason(status) {
|
|
2087
|
+
if (!status) return "stop";
|
|
2088
|
+
switch (status) {
|
|
2089
|
+
case "completed": return "stop";
|
|
2090
|
+
case "incomplete": return "length";
|
|
2091
|
+
case "failed":
|
|
2092
|
+
case "cancelled": return "error";
|
|
2093
|
+
case "in_progress":
|
|
2094
|
+
case "queued": return "stop";
|
|
2095
|
+
default: throw new Error(`Unhandled stop reason: ${status}`);
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
function buildOpenAIClientHeaders(model, context, optionHeaders, turnHeaders) {
|
|
2099
|
+
const providerHeaders = { ...model.headers };
|
|
2100
|
+
if (model.provider === "github-copilot") Object.assign(providerHeaders, buildCopilotDynamicHeaders({
|
|
2101
|
+
messages: context.messages,
|
|
2102
|
+
hasImages: hasCopilotVisionInput(context.messages)
|
|
2103
|
+
}));
|
|
2104
|
+
const callerHeaders = {
|
|
2105
|
+
...optionHeaders,
|
|
2106
|
+
...turnHeaders
|
|
2107
|
+
};
|
|
2108
|
+
return resolveProviderRequestPolicyConfig({
|
|
2109
|
+
provider: model.provider,
|
|
2110
|
+
api: model.api,
|
|
2111
|
+
baseUrl: model.baseUrl,
|
|
2112
|
+
capability: "llm",
|
|
2113
|
+
transport: "stream",
|
|
2114
|
+
providerHeaders,
|
|
2115
|
+
callerHeaders: Object.keys(callerHeaders).length > 0 ? callerHeaders : void 0,
|
|
2116
|
+
precedence: "caller-wins"
|
|
2117
|
+
}).headers ?? {};
|
|
2118
|
+
}
|
|
2119
|
+
function resolveProviderTransportTurnState(model, params) {
|
|
2120
|
+
return resolveProviderTransportTurnStateWithPlugin({
|
|
2121
|
+
provider: model.provider,
|
|
2122
|
+
context: {
|
|
2123
|
+
provider: model.provider,
|
|
2124
|
+
modelId: model.id,
|
|
2125
|
+
model,
|
|
2126
|
+
sessionId: params.sessionId,
|
|
2127
|
+
turnId: params.turnId,
|
|
2128
|
+
attempt: params.attempt,
|
|
2129
|
+
transport: params.transport
|
|
2130
|
+
}
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
function resolveOpenAISdkTimeoutMs(model) {
|
|
2134
|
+
return resolveModelRequestTimeoutMs(model, void 0);
|
|
2135
|
+
}
|
|
2136
|
+
function buildOpenAISdkClientOptions(model) {
|
|
2137
|
+
const timeout = resolveOpenAISdkTimeoutMs(model);
|
|
2138
|
+
return timeout === void 0 ? {} : { timeout };
|
|
2139
|
+
}
|
|
2140
|
+
function buildOpenAISdkRequestOptions(model, signal) {
|
|
2141
|
+
const timeout = resolveOpenAISdkTimeoutMs(model);
|
|
2142
|
+
if (timeout === void 0 && !signal) return;
|
|
2143
|
+
return {
|
|
2144
|
+
...signal ? { signal } : {},
|
|
2145
|
+
...timeout !== void 0 ? { timeout } : {}
|
|
2146
|
+
};
|
|
2147
|
+
}
|
|
2148
|
+
function createOpenAIResponsesClient(model, context, apiKey, optionHeaders, turnHeaders) {
|
|
2149
|
+
return new OpenAI({
|
|
2150
|
+
apiKey,
|
|
2151
|
+
baseURL: model.baseUrl,
|
|
2152
|
+
dangerouslyAllowBrowser: true,
|
|
2153
|
+
defaultHeaders: buildOpenAIClientHeaders(model, context, optionHeaders, turnHeaders),
|
|
2154
|
+
fetch: buildGuardedModelFetch(model),
|
|
2155
|
+
...buildOpenAISdkClientOptions(model)
|
|
2156
|
+
});
|
|
2157
|
+
}
|
|
2158
|
+
function createOpenAIResponsesTransportStreamFn() {
|
|
2159
|
+
return (model, context, options) => {
|
|
2160
|
+
const responsesOptions = options;
|
|
2161
|
+
const eventStream = createAssistantMessageEventStream();
|
|
2162
|
+
const stream = eventStream;
|
|
2163
|
+
(async () => {
|
|
2164
|
+
const output = {
|
|
2165
|
+
role: "assistant",
|
|
2166
|
+
content: [],
|
|
2167
|
+
api: model.api,
|
|
2168
|
+
provider: model.provider,
|
|
2169
|
+
model: model.id,
|
|
2170
|
+
usage: {
|
|
2171
|
+
input: 0,
|
|
2172
|
+
output: 0,
|
|
2173
|
+
cacheRead: 0,
|
|
2174
|
+
cacheWrite: 0,
|
|
2175
|
+
totalTokens: 0,
|
|
2176
|
+
cost: {
|
|
2177
|
+
input: 0,
|
|
2178
|
+
output: 0,
|
|
2179
|
+
cacheRead: 0,
|
|
2180
|
+
cacheWrite: 0,
|
|
2181
|
+
total: 0
|
|
2182
|
+
}
|
|
2183
|
+
},
|
|
2184
|
+
stopReason: "stop",
|
|
2185
|
+
timestamp: Date.now()
|
|
2186
|
+
};
|
|
2187
|
+
try {
|
|
2188
|
+
const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
|
|
2189
|
+
const turnState = resolveProviderTransportTurnState(model, {
|
|
2190
|
+
sessionId: options?.sessionId,
|
|
2191
|
+
turnId: randomUUID(),
|
|
2192
|
+
attempt: 1,
|
|
2193
|
+
transport: "stream"
|
|
2194
|
+
});
|
|
2195
|
+
const client = createOpenAIResponsesClient(model, context, apiKey, options?.headers, turnState?.headers);
|
|
2196
|
+
let params = buildOpenAIResponsesParams(model, context, responsesOptions, turnState?.metadata);
|
|
2197
|
+
const nextParams = await options?.onPayload?.(params, model);
|
|
2198
|
+
if (nextParams !== void 0) params = nextParams;
|
|
2199
|
+
if (!isOpenAICodexResponsesModel(model)) params = mergeTransportMetadata(params, turnState?.metadata);
|
|
2200
|
+
params = sanitizeOpenAICodexResponsesParams(model, params);
|
|
2201
|
+
params = sanitizeResponsesImagePayload(params);
|
|
2202
|
+
if (options?.fengmingCodeModeToolSurface === true) {
|
|
2203
|
+
enforceCodeModeResponsesToolSurface(params);
|
|
2204
|
+
assertCodeModeResponsesToolSurface(params);
|
|
2205
|
+
}
|
|
2206
|
+
const requestStartedAt = Date.now();
|
|
2207
|
+
const requestOptions = buildOpenAISdkRequestOptions(model, options?.signal);
|
|
2208
|
+
emitModelTransportDebug(log, `[responses] start provider=${model.provider} api=${model.api} model=${model.id} baseUrl=${formatModelTransportDebugBaseUrl(model.baseUrl)} timeoutMs=${safeDebugValue(requestOptions?.timeout)} apiKey=${apiKey ? "present" : "missing"} ${summarizeResponsesPayload(params)}`);
|
|
2209
|
+
const responseStream = await createResponsesStreamWithEncryptedContentRetry({
|
|
2210
|
+
client,
|
|
2211
|
+
request: params,
|
|
2212
|
+
requestOptions,
|
|
2213
|
+
model
|
|
2214
|
+
});
|
|
2215
|
+
emitModelTransportDebug(log, `[responses] headers provider=${model.provider} api=${model.api} model=${model.id} elapsedMs=${Date.now() - requestStartedAt}`);
|
|
2216
|
+
stream.push({
|
|
2217
|
+
type: "start",
|
|
2218
|
+
partial: output
|
|
2219
|
+
});
|
|
2220
|
+
await processResponsesStream(responseStream, output, stream, model, {
|
|
2221
|
+
serviceTier: responsesOptions?.serviceTier,
|
|
2222
|
+
applyServiceTierPricing,
|
|
2223
|
+
signal: options?.signal,
|
|
2224
|
+
authProfileId: responsesOptions?.authProfileId,
|
|
2225
|
+
sessionId: options?.sessionId
|
|
2226
|
+
});
|
|
2227
|
+
if (options?.signal?.aborted) throw new Error("请求已被中止");
|
|
2228
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") throw new Error("发生了未知错误");
|
|
2229
|
+
stream.push({
|
|
2230
|
+
type: "done",
|
|
2231
|
+
reason: output.stopReason,
|
|
2232
|
+
message: output
|
|
2233
|
+
});
|
|
2234
|
+
stream.end();
|
|
2235
|
+
} catch (error) {
|
|
2236
|
+
log.warn(`[responses] error provider=${model.provider} api=${model.api} model=${model.id} ` + summarizeOpenAITransportError(error));
|
|
2237
|
+
assignTransportErrorDetails(output, error, options?.signal);
|
|
2238
|
+
stream.push({
|
|
2239
|
+
type: "error",
|
|
2240
|
+
reason: output.stopReason,
|
|
2241
|
+
error: output
|
|
2242
|
+
});
|
|
2243
|
+
stream.end();
|
|
2244
|
+
}
|
|
2245
|
+
})();
|
|
2246
|
+
return eventStream;
|
|
2247
|
+
};
|
|
2248
|
+
}
|
|
2249
|
+
function resolveCacheRetention(cacheRetention) {
|
|
2250
|
+
if (cacheRetention === "short" || cacheRetention === "long" || cacheRetention === "none") return cacheRetention;
|
|
2251
|
+
if (typeof process !== "undefined" && process.env.FENGMING_CACHE_RETENTION === "long") return "long";
|
|
2252
|
+
return "short";
|
|
2253
|
+
}
|
|
2254
|
+
function resolvePromptCacheKey(options, cacheRetention) {
|
|
2255
|
+
if (cacheRetention === "none") return;
|
|
2256
|
+
return clampOpenAIPromptCacheKey(options?.promptCacheKey ?? options?.sessionId);
|
|
2257
|
+
}
|
|
2258
|
+
function getPromptCacheRetention(baseUrl, cacheRetention) {
|
|
2259
|
+
if (cacheRetention !== "long") return;
|
|
2260
|
+
return baseUrl?.includes("api.openai.com") ? "24h" : void 0;
|
|
2261
|
+
}
|
|
2262
|
+
function resolveOpenAIReasoningEffort(options) {
|
|
2263
|
+
return normalizeOpenAIReasoningEffort(options?.reasoningEffort ?? options?.reasoning ?? "high");
|
|
2264
|
+
}
|
|
2265
|
+
function hasResponsesWebSearchTool(tools) {
|
|
2266
|
+
if (!Array.isArray(tools)) return false;
|
|
2267
|
+
return tools.some((tool) => {
|
|
2268
|
+
if (!isRecord(tool)) return false;
|
|
2269
|
+
if (tool.type === "web_search") return true;
|
|
2270
|
+
if (tool.type === "function" && tool.name === "web_search") return true;
|
|
2271
|
+
const fn = tool.function;
|
|
2272
|
+
return isRecord(fn) && fn.name === "web_search";
|
|
2273
|
+
});
|
|
2274
|
+
}
|
|
2275
|
+
function raiseMinimalReasoningForResponsesWebSearch(params) {
|
|
2276
|
+
if (params.effort !== "minimal" || !hasResponsesWebSearchTool(params.tools)) return params.effort;
|
|
2277
|
+
for (const effort of [
|
|
2278
|
+
"low",
|
|
2279
|
+
"medium",
|
|
2280
|
+
"high"
|
|
2281
|
+
]) {
|
|
2282
|
+
const resolved = resolveOpenAIReasoningEffortForModel({
|
|
2283
|
+
model: params.model,
|
|
2284
|
+
effort
|
|
2285
|
+
});
|
|
2286
|
+
if (resolved && resolved !== "none" && resolved !== "minimal") return resolved;
|
|
2287
|
+
}
|
|
2288
|
+
return params.effort;
|
|
2289
|
+
}
|
|
2290
|
+
function isOpenAICodexResponsesModel(model) {
|
|
2291
|
+
return OPENAI_CODEX_RESPONSES_PROVIDERS.has(model.provider) && (model.api === "openai-codex-responses" || model.api === "fengming-openai-responses-transport");
|
|
2292
|
+
}
|
|
2293
|
+
function isNativeOpenAICodexResponsesBaseUrl(baseUrl) {
|
|
2294
|
+
const trimmed = typeof baseUrl === "string" ? baseUrl.trim() : "";
|
|
2295
|
+
if (!trimmed) return false;
|
|
2296
|
+
try {
|
|
2297
|
+
const url = new URL(trimmed);
|
|
2298
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return false;
|
|
2299
|
+
if (url.hostname.toLowerCase() !== "chatgpt.com") return false;
|
|
2300
|
+
const pathname = url.pathname.replace(/\/+$/u, "").toLowerCase();
|
|
2301
|
+
return [
|
|
2302
|
+
"/backend-api",
|
|
2303
|
+
"/backend-api/v1",
|
|
2304
|
+
"/backend-api/codex",
|
|
2305
|
+
"/backend-api/codex/v1"
|
|
2306
|
+
].includes(pathname);
|
|
2307
|
+
} catch {
|
|
2308
|
+
return false;
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
function usesNativeOpenAICodexResponsesBackend(model) {
|
|
2312
|
+
return isOpenAICodexResponsesModel(model) && isNativeOpenAICodexResponsesBaseUrl(model.baseUrl);
|
|
2313
|
+
}
|
|
2314
|
+
const OPENAI_CODEX_RESPONSES_UNSUPPORTED_PARAMS = [
|
|
2315
|
+
"max_output_tokens",
|
|
2316
|
+
"metadata",
|
|
2317
|
+
"prompt_cache_retention",
|
|
2318
|
+
"service_tier",
|
|
2319
|
+
"temperature",
|
|
2320
|
+
"top_p"
|
|
2321
|
+
];
|
|
2322
|
+
function stripOpenAICodexResponsesUnsupportedTextFields(params) {
|
|
2323
|
+
const text = params.text;
|
|
2324
|
+
if (!text || typeof text !== "object" || Array.isArray(text)) return;
|
|
2325
|
+
const sanitizedText = { ...text };
|
|
2326
|
+
delete sanitizedText.format;
|
|
2327
|
+
if (Object.keys(sanitizedText).length > 0) params.text = sanitizedText;
|
|
2328
|
+
else delete params.text;
|
|
2329
|
+
}
|
|
2330
|
+
function sanitizeOpenAICodexResponsesParams(model, params) {
|
|
2331
|
+
if (!usesNativeOpenAICodexResponsesBackend(model)) return params;
|
|
2332
|
+
for (const key of OPENAI_CODEX_RESPONSES_UNSUPPORTED_PARAMS) delete params[key];
|
|
2333
|
+
stripOpenAICodexResponsesUnsupportedTextFields(params);
|
|
2334
|
+
return params;
|
|
2335
|
+
}
|
|
2336
|
+
function buildOpenAICodexResponsesInstructions(context) {
|
|
2337
|
+
if (!context.systemPrompt) return;
|
|
2338
|
+
return sanitizeTransportPayloadText(stripSystemPromptCacheBoundary(context.systemPrompt));
|
|
2339
|
+
}
|
|
2340
|
+
function resolveOpenAICodexResponsesInstructions(model, context) {
|
|
2341
|
+
const instructions = buildOpenAICodexResponsesInstructions(context);
|
|
2342
|
+
if (instructions && instructions.trim().length > 0) return instructions;
|
|
2343
|
+
return usesNativeOpenAICodexResponsesBackend(model) ? OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS : void 0;
|
|
2344
|
+
}
|
|
2345
|
+
function ensureOpenAICodexResponsesInput(messages, context) {
|
|
2346
|
+
if (messages.length > 0 || !context.systemPrompt) return;
|
|
2347
|
+
if (!buildOpenAICodexResponsesInstructions(context)) throw new Error("OpenAI Codex Responses requires non-empty input when only systemPrompt is provided.");
|
|
2348
|
+
messages.push({
|
|
2349
|
+
role: "user",
|
|
2350
|
+
content: [{
|
|
2351
|
+
type: "input_text",
|
|
2352
|
+
text: OPENAI_CODEX_RESPONSES_EMPTY_INPUT_TEXT
|
|
2353
|
+
}]
|
|
2354
|
+
});
|
|
2355
|
+
}
|
|
2356
|
+
function resolveOpenAIResponsesTextFormat(responseFormat) {
|
|
2357
|
+
if (responseFormat.type === "json_schema" && responseFormat.json_schema && typeof responseFormat.json_schema === "object" && !Array.isArray(responseFormat.json_schema)) return {
|
|
2358
|
+
...responseFormat.json_schema,
|
|
2359
|
+
type: "json_schema"
|
|
2360
|
+
};
|
|
2361
|
+
return responseFormat;
|
|
2362
|
+
}
|
|
2363
|
+
function buildOpenAIResponsesParams(model, context, options, metadata) {
|
|
2364
|
+
const isCodexResponses = isOpenAICodexResponsesModel(model);
|
|
2365
|
+
const isNativeCodexResponses = usesNativeOpenAICodexResponsesBackend(model);
|
|
2366
|
+
const compat = getCompat(model);
|
|
2367
|
+
const supportsDeveloperRole = typeof compat.supportsDeveloperRole === "boolean" ? compat.supportsDeveloperRole : void 0;
|
|
2368
|
+
const messages = convertResponsesMessages(model, context, new Set([
|
|
2369
|
+
"openai",
|
|
2370
|
+
"openai-codex",
|
|
2371
|
+
"opencode",
|
|
2372
|
+
"azure-openai-responses",
|
|
2373
|
+
"github-copilot"
|
|
2374
|
+
]), {
|
|
2375
|
+
includeSystemPrompt: !isCodexResponses,
|
|
2376
|
+
supportsDeveloperRole,
|
|
2377
|
+
replayReasoningItems: true,
|
|
2378
|
+
replayResponsesItemIds: !isNativeCodexResponses,
|
|
2379
|
+
authProfileId: options?.authProfileId,
|
|
2380
|
+
sessionId: options?.sessionId
|
|
2381
|
+
});
|
|
2382
|
+
if (isCodexResponses) ensureOpenAICodexResponsesInput(messages, context);
|
|
2383
|
+
const cacheRetention = resolveCacheRetention(options?.cacheRetention);
|
|
2384
|
+
const promptCacheKey = resolvePromptCacheKey(options, cacheRetention);
|
|
2385
|
+
const payloadPolicy = resolveOpenAIResponsesPayloadPolicy(model, { storeMode: "disable" });
|
|
2386
|
+
const params = {
|
|
2387
|
+
model: model.id,
|
|
2388
|
+
input: messages,
|
|
2389
|
+
stream: true,
|
|
2390
|
+
prompt_cache_key: promptCacheKey,
|
|
2391
|
+
prompt_cache_retention: getPromptCacheRetention(model.baseUrl, cacheRetention),
|
|
2392
|
+
...isCodexResponses ? { instructions: resolveOpenAICodexResponsesInstructions(model, context) } : {},
|
|
2393
|
+
...metadata ? { metadata } : {}
|
|
2394
|
+
};
|
|
2395
|
+
const effectiveMaxTokens = options?.maxTokens || model.maxTokens;
|
|
2396
|
+
if (effectiveMaxTokens) params.max_output_tokens = effectiveMaxTokens;
|
|
2397
|
+
if (options?.temperature !== void 0) params.temperature = options.temperature;
|
|
2398
|
+
if (options?.topP !== void 0) params.top_p = options.topP;
|
|
2399
|
+
if (options?.responseFormat !== void 0) params.text = {
|
|
2400
|
+
...params.text,
|
|
2401
|
+
format: resolveOpenAIResponsesTextFormat(options.responseFormat)
|
|
2402
|
+
};
|
|
2403
|
+
if (options?.serviceTier !== void 0 && payloadPolicy.allowsServiceTier) params.service_tier = options.serviceTier;
|
|
2404
|
+
if (context.tools) {
|
|
2405
|
+
params.tools = convertResponsesTools(context.tools, model, { strict: resolveOpenAIStrictToolSetting(model, { transport: "stream" }) });
|
|
2406
|
+
if (options?.toolChoice) params.tool_choice = options.toolChoice;
|
|
2407
|
+
}
|
|
2408
|
+
if (model.reasoning) {
|
|
2409
|
+
if (options?.reasoningEffort || options?.reasoning || options?.reasoningSummary) {
|
|
2410
|
+
const resolvedReasoningEffort = resolveOpenAIReasoningEffortForModel({
|
|
2411
|
+
model,
|
|
2412
|
+
effort: resolveOpenAIReasoningEffort(options)
|
|
2413
|
+
});
|
|
2414
|
+
const reasoningEffort = resolvedReasoningEffort ? raiseMinimalReasoningForResponsesWebSearch({
|
|
2415
|
+
model,
|
|
2416
|
+
effort: resolvedReasoningEffort,
|
|
2417
|
+
tools: params.tools
|
|
2418
|
+
}) : void 0;
|
|
2419
|
+
if (reasoningEffort) {
|
|
2420
|
+
params.reasoning = {
|
|
2421
|
+
effort: reasoningEffort,
|
|
2422
|
+
...reasoningEffort === "none" ? {} : { summary: options?.reasoningSummary || "auto" }
|
|
2423
|
+
};
|
|
2424
|
+
if (reasoningEffort !== "none") params.include = ["reasoning.encrypted_content"];
|
|
2425
|
+
}
|
|
2426
|
+
} else if (model.provider !== "github-copilot") {
|
|
2427
|
+
const reasoningEffort = resolveOpenAIReasoningEffortForModel({
|
|
2428
|
+
model,
|
|
2429
|
+
effort: "none"
|
|
2430
|
+
});
|
|
2431
|
+
if (reasoningEffort) params.reasoning = { effort: reasoningEffort };
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
applyOpenAIResponsesPayloadPolicy(params, payloadPolicy);
|
|
2435
|
+
return sanitizeOpenAICodexResponsesParams(model, params);
|
|
2436
|
+
}
|
|
2437
|
+
function createAzureOpenAIResponsesTransportStreamFn() {
|
|
2438
|
+
return (model, context, options) => {
|
|
2439
|
+
const responsesOptions = options;
|
|
2440
|
+
const eventStream = createAssistantMessageEventStream();
|
|
2441
|
+
const stream = eventStream;
|
|
2442
|
+
(async () => {
|
|
2443
|
+
const output = {
|
|
2444
|
+
role: "assistant",
|
|
2445
|
+
content: [],
|
|
2446
|
+
api: "azure-openai-responses",
|
|
2447
|
+
provider: model.provider,
|
|
2448
|
+
model: model.id,
|
|
2449
|
+
usage: {
|
|
2450
|
+
input: 0,
|
|
2451
|
+
output: 0,
|
|
2452
|
+
cacheRead: 0,
|
|
2453
|
+
cacheWrite: 0,
|
|
2454
|
+
totalTokens: 0,
|
|
2455
|
+
cost: {
|
|
2456
|
+
input: 0,
|
|
2457
|
+
output: 0,
|
|
2458
|
+
cacheRead: 0,
|
|
2459
|
+
cacheWrite: 0,
|
|
2460
|
+
total: 0
|
|
2461
|
+
}
|
|
2462
|
+
},
|
|
2463
|
+
stopReason: "stop",
|
|
2464
|
+
timestamp: Date.now()
|
|
2465
|
+
};
|
|
2466
|
+
try {
|
|
2467
|
+
const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
|
|
2468
|
+
const turnState = resolveProviderTransportTurnState(model, {
|
|
2469
|
+
sessionId: options?.sessionId,
|
|
2470
|
+
turnId: randomUUID(),
|
|
2471
|
+
attempt: 1,
|
|
2472
|
+
transport: "stream"
|
|
2473
|
+
});
|
|
2474
|
+
const client = createAzureOpenAIClient(model, context, apiKey, options?.headers, turnState?.headers);
|
|
2475
|
+
let params = buildAzureOpenAIResponsesParams(model, context, responsesOptions, resolveAzureDeploymentName(model), turnState?.metadata);
|
|
2476
|
+
const nextParams = await options?.onPayload?.(params, model);
|
|
2477
|
+
if (nextParams !== void 0) params = nextParams;
|
|
2478
|
+
if (!isOpenAICodexResponsesModel(model)) params = mergeTransportMetadata(params, turnState?.metadata);
|
|
2479
|
+
params = sanitizeOpenAICodexResponsesParams(model, params);
|
|
2480
|
+
params = sanitizeResponsesImagePayload(params);
|
|
2481
|
+
if (options?.fengmingCodeModeToolSurface === true) {
|
|
2482
|
+
enforceCodeModeResponsesToolSurface(params);
|
|
2483
|
+
assertCodeModeResponsesToolSurface(params);
|
|
2484
|
+
}
|
|
2485
|
+
const requestStartedAt = Date.now();
|
|
2486
|
+
const requestOptions = buildOpenAISdkRequestOptions(model, options?.signal);
|
|
2487
|
+
emitModelTransportDebug(log, `[responses] start provider=${model.provider} api=${model.api} model=${model.id} baseUrl=${formatModelTransportDebugBaseUrl(model.baseUrl)} timeoutMs=${safeDebugValue(requestOptions?.timeout)} apiKey=${apiKey ? "present" : "missing"} ${summarizeResponsesPayload(params)}`);
|
|
2488
|
+
const responseStream = await client.responses.create(params, requestOptions);
|
|
2489
|
+
emitModelTransportDebug(log, `[responses] headers provider=${model.provider} api=${model.api} model=${model.id} elapsedMs=${Date.now() - requestStartedAt}`);
|
|
2490
|
+
stream.push({
|
|
2491
|
+
type: "start",
|
|
2492
|
+
partial: output
|
|
2493
|
+
});
|
|
2494
|
+
await processResponsesStream(responseStream, output, stream, model, {
|
|
2495
|
+
firstEventTimeoutMs: AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS,
|
|
2496
|
+
signal: options?.signal,
|
|
2497
|
+
authProfileId: responsesOptions?.authProfileId,
|
|
2498
|
+
sessionId: options?.sessionId
|
|
2499
|
+
});
|
|
2500
|
+
if (options?.signal?.aborted) throw new Error("请求已被中止");
|
|
2501
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") throw new Error("发生了未知错误");
|
|
2502
|
+
stream.push({
|
|
2503
|
+
type: "done",
|
|
2504
|
+
reason: output.stopReason,
|
|
2505
|
+
message: output
|
|
2506
|
+
});
|
|
2507
|
+
stream.end();
|
|
2508
|
+
} catch (error) {
|
|
2509
|
+
log.warn(`[responses] error provider=${model.provider} api=${model.api} model=${model.id} ` + summarizeOpenAITransportError(error));
|
|
2510
|
+
assignTransportErrorDetails(output, error, options?.signal);
|
|
2511
|
+
stream.push({
|
|
2512
|
+
type: "error",
|
|
2513
|
+
reason: output.stopReason,
|
|
2514
|
+
error: output
|
|
2515
|
+
});
|
|
2516
|
+
stream.end();
|
|
2517
|
+
}
|
|
2518
|
+
})();
|
|
2519
|
+
return eventStream;
|
|
2520
|
+
};
|
|
2521
|
+
}
|
|
2522
|
+
function normalizeAzureBaseUrl(baseUrl) {
|
|
2523
|
+
return baseUrl.replace(/\/+$/, "");
|
|
2524
|
+
}
|
|
2525
|
+
function resolveAzureDeploymentName(model) {
|
|
2526
|
+
return resolveAzureDeploymentNameFromMap({
|
|
2527
|
+
modelId: model.id,
|
|
2528
|
+
deploymentMap: process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
function createAzureOpenAIClient(model, context, apiKey, optionHeaders, turnHeaders) {
|
|
2532
|
+
return new AzureOpenAI({
|
|
2533
|
+
apiKey,
|
|
2534
|
+
apiVersion: resolveAzureOpenAIApiVersion(),
|
|
2535
|
+
dangerouslyAllowBrowser: true,
|
|
2536
|
+
defaultHeaders: buildOpenAIClientHeaders(model, context, optionHeaders, turnHeaders),
|
|
2537
|
+
baseURL: normalizeAzureBaseUrl(model.baseUrl),
|
|
2538
|
+
fetch: buildGuardedModelFetch(model),
|
|
2539
|
+
...buildOpenAISdkClientOptions(model)
|
|
2540
|
+
});
|
|
2541
|
+
}
|
|
2542
|
+
function buildAzureOpenAIResponsesParams(model, context, options, deploymentName, metadata) {
|
|
2543
|
+
const params = buildOpenAIResponsesParams(model, context, options, metadata);
|
|
2544
|
+
params.model = deploymentName;
|
|
2545
|
+
delete params.store;
|
|
2546
|
+
return params;
|
|
2547
|
+
}
|
|
2548
|
+
function hasToolHistory(messages) {
|
|
2549
|
+
return messages.some((message) => message.role === "toolResult" || message.role === "assistant" && message.content.some((block) => block.type === "toolCall"));
|
|
2550
|
+
}
|
|
2551
|
+
function assertOpenAICompletionsPayloadHasConversationTurn(params, model) {
|
|
2552
|
+
const messages = params.messages;
|
|
2553
|
+
if (!Array.isArray(messages) || hasOpenAICompatibleConversationTurn(messages)) return;
|
|
2554
|
+
throw new Error(`OpenAI-compatible chat payload for ${model.provider}/${model.id} contains no non-empty user or assistant messages after compaction and transport transforms; refusing to send a system/tool-only request. Start a new user turn or repair the compacted session history.`);
|
|
2555
|
+
}
|
|
2556
|
+
function createOpenAICompletionsClient(model, context, apiKey, optionHeaders) {
|
|
2557
|
+
const clientConfig = buildOpenAICompletionsClientConfig(model, context, optionHeaders);
|
|
2558
|
+
return new OpenAI({
|
|
2559
|
+
apiKey,
|
|
2560
|
+
baseURL: clientConfig.baseURL,
|
|
2561
|
+
dangerouslyAllowBrowser: true,
|
|
2562
|
+
defaultHeaders: clientConfig.defaultHeaders,
|
|
2563
|
+
defaultQuery: clientConfig.defaultQuery,
|
|
2564
|
+
fetch: buildGuardedModelFetch(model),
|
|
2565
|
+
...buildOpenAISdkClientOptions(model)
|
|
2566
|
+
});
|
|
2567
|
+
}
|
|
2568
|
+
function isAzureOpenAICompatibleHost(hostname) {
|
|
2569
|
+
return hostname.endsWith(".openai.azure.com") || hostname.endsWith(".services.ai.azure.com") || hostname.endsWith(".cognitiveservices.azure.com");
|
|
2570
|
+
}
|
|
2571
|
+
function buildOpenAICompletionsClientConfig(model, context, optionHeaders) {
|
|
2572
|
+
const headers = buildOpenAIClientHeaders(model, context, optionHeaders);
|
|
2573
|
+
const defaultQuery = {};
|
|
2574
|
+
let baseURL = model.baseUrl;
|
|
2575
|
+
let isAzureHost = false;
|
|
2576
|
+
try {
|
|
2577
|
+
const parsed = new URL(model.baseUrl);
|
|
2578
|
+
isAzureHost = isAzureOpenAICompatibleHost(parsed.hostname.toLowerCase());
|
|
2579
|
+
parsed.searchParams.forEach((value, key) => {
|
|
2580
|
+
if (value) defaultQuery[key] = value;
|
|
2581
|
+
});
|
|
2582
|
+
parsed.search = "";
|
|
2583
|
+
baseURL = parsed.toString().replace(/\/$/, "");
|
|
2584
|
+
} catch {}
|
|
2585
|
+
if (isAzureHost) {
|
|
2586
|
+
const apiVersionHeader = Object.keys(headers).find((key) => key.toLowerCase() === "api-version");
|
|
2587
|
+
if (apiVersionHeader) {
|
|
2588
|
+
const apiVersion = headers[apiVersionHeader]?.trim();
|
|
2589
|
+
delete headers[apiVersionHeader];
|
|
2590
|
+
if (apiVersion && !defaultQuery["api-version"]) defaultQuery["api-version"] = apiVersion;
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
return {
|
|
2594
|
+
baseURL,
|
|
2595
|
+
defaultHeaders: headers,
|
|
2596
|
+
defaultQuery: Object.keys(defaultQuery).length > 0 ? defaultQuery : void 0
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
function createOpenAICompletionsTransportStreamFn() {
|
|
2600
|
+
return (model, context, options) => {
|
|
2601
|
+
const eventStream = createAssistantMessageEventStream();
|
|
2602
|
+
const stream = eventStream;
|
|
2603
|
+
(async () => {
|
|
2604
|
+
const output = {
|
|
2605
|
+
role: "assistant",
|
|
2606
|
+
content: [],
|
|
2607
|
+
api: model.api,
|
|
2608
|
+
provider: model.provider,
|
|
2609
|
+
model: model.id,
|
|
2610
|
+
usage: {
|
|
2611
|
+
input: 0,
|
|
2612
|
+
output: 0,
|
|
2613
|
+
cacheRead: 0,
|
|
2614
|
+
cacheWrite: 0,
|
|
2615
|
+
totalTokens: 0,
|
|
2616
|
+
cost: {
|
|
2617
|
+
input: 0,
|
|
2618
|
+
output: 0,
|
|
2619
|
+
cacheRead: 0,
|
|
2620
|
+
cacheWrite: 0,
|
|
2621
|
+
total: 0
|
|
2622
|
+
}
|
|
2623
|
+
},
|
|
2624
|
+
stopReason: "stop",
|
|
2625
|
+
timestamp: Date.now()
|
|
2626
|
+
};
|
|
2627
|
+
try {
|
|
2628
|
+
const client = createOpenAICompletionsClient(model, context, options?.apiKey || getEnvApiKey(model.provider) || "", options?.headers);
|
|
2629
|
+
let params = buildOpenAICompletionsParams(model, context, options);
|
|
2630
|
+
const nextParams = await options?.onPayload?.(params, model);
|
|
2631
|
+
if (nextParams !== void 0) params = nextParams;
|
|
2632
|
+
if (options?.fengmingCodeModeToolSurface === true) {
|
|
2633
|
+
enforceCodeModeResponsesToolSurface(params);
|
|
2634
|
+
assertCodeModeResponsesToolSurface(params);
|
|
2635
|
+
}
|
|
2636
|
+
if (getCompat(model).requiresNonEmptyUserOrAssistantMessage) assertOpenAICompletionsPayloadHasConversationTurn(params, model);
|
|
2637
|
+
const responseStream = await client.chat.completions.create(params, buildOpenAISdkRequestOptions(model, options?.signal));
|
|
2638
|
+
stream.push({
|
|
2639
|
+
type: "start",
|
|
2640
|
+
partial: output
|
|
2641
|
+
});
|
|
2642
|
+
await processOpenAICompletionsStream(responseStream, output, model, stream, { signal: options?.signal });
|
|
2643
|
+
if (options?.signal?.aborted) throw new Error("请求已被中止");
|
|
2644
|
+
stream.push({
|
|
2645
|
+
type: "done",
|
|
2646
|
+
reason: output.stopReason,
|
|
2647
|
+
message: output
|
|
2648
|
+
});
|
|
2649
|
+
stream.end();
|
|
2650
|
+
} catch (error) {
|
|
2651
|
+
assignTransportErrorDetails(output, error, options?.signal);
|
|
2652
|
+
stream.push({
|
|
2653
|
+
type: "error",
|
|
2654
|
+
reason: output.stopReason,
|
|
2655
|
+
error: output
|
|
2656
|
+
});
|
|
2657
|
+
stream.end();
|
|
2658
|
+
}
|
|
2659
|
+
})();
|
|
2660
|
+
return eventStream;
|
|
2661
|
+
};
|
|
2662
|
+
}
|
|
2663
|
+
async function processOpenAICompletionsStream(responseStream, output, model, stream, options) {
|
|
2664
|
+
const MAX_POST_TOOL_CALL_BUFFER_BYTES = 256e3;
|
|
2665
|
+
const MAX_TOOL_CALL_ARGUMENT_BUFFER_BYTES = 256e3;
|
|
2666
|
+
const compat = getCompat(model);
|
|
2667
|
+
const deepSeekTextFilter = shouldFilterDeepSeekDsmlText(compat) ? createDeepSeekTextFilter() : null;
|
|
2668
|
+
let currentBlock = null;
|
|
2669
|
+
let pendingPostToolCallDeltas = [];
|
|
2670
|
+
let pendingPostToolCallBytes = 0;
|
|
2671
|
+
let isFlushingPendingPostToolCallDeltas = false;
|
|
2672
|
+
const toolCallBlocksByIndex = /* @__PURE__ */ new Map();
|
|
2673
|
+
const toolCallBlocksById = /* @__PURE__ */ new Map();
|
|
2674
|
+
const toolCallBlockBytes = /* @__PURE__ */ new WeakMap();
|
|
2675
|
+
const blockIndex = () => output.content.length - 1;
|
|
2676
|
+
const measureUtf8Bytes = (text) => Buffer.byteLength(text, "utf8");
|
|
2677
|
+
const finishCurrentBlock = () => {
|
|
2678
|
+
if (!currentBlock) return;
|
|
2679
|
+
if (currentBlock.type === "toolCall") currentBlock.arguments = parseStreamingJson(currentBlock.partialArgs);
|
|
2680
|
+
};
|
|
2681
|
+
const finishAllToolCallBlocks = () => {
|
|
2682
|
+
for (const block of toolCallBlocksByIndex.values()) block.arguments = parseStreamingJson(block.partialArgs);
|
|
2683
|
+
};
|
|
2684
|
+
const queuePostToolCallDelta = (next) => {
|
|
2685
|
+
const nextBytes = measureUtf8Bytes(next.text);
|
|
2686
|
+
if (pendingPostToolCallBytes + nextBytes > MAX_POST_TOOL_CALL_BUFFER_BYTES) throw new Error("Exceeded post-tool-call delta buffer limit");
|
|
2687
|
+
pendingPostToolCallBytes += nextBytes;
|
|
2688
|
+
const previous = pendingPostToolCallDeltas[pendingPostToolCallDeltas.length - 1];
|
|
2689
|
+
if (!previous || previous.kind !== next.kind) {
|
|
2690
|
+
pendingPostToolCallDeltas.push(next);
|
|
2691
|
+
return;
|
|
2692
|
+
}
|
|
2693
|
+
if (next.kind === "thinking" && previous.kind === "thinking") {
|
|
2694
|
+
if (previous.signature !== next.signature) {
|
|
2695
|
+
pendingPostToolCallDeltas.push(next);
|
|
2696
|
+
return;
|
|
2697
|
+
}
|
|
2698
|
+
previous.text += next.text;
|
|
2699
|
+
return;
|
|
2700
|
+
}
|
|
2701
|
+
previous.text += next.text;
|
|
2702
|
+
};
|
|
2703
|
+
const appendThinkingDeltaInternal = (reasoningDelta) => {
|
|
2704
|
+
if (!currentBlock || currentBlock.type !== "thinking") {
|
|
2705
|
+
finishCurrentBlock();
|
|
2706
|
+
currentBlock = {
|
|
2707
|
+
type: "thinking",
|
|
2708
|
+
thinking: "",
|
|
2709
|
+
thinkingSignature: reasoningDelta.signature
|
|
2710
|
+
};
|
|
2711
|
+
output.content.push(currentBlock);
|
|
2712
|
+
stream.push({
|
|
2713
|
+
type: "thinking_start",
|
|
2714
|
+
contentIndex: blockIndex(),
|
|
2715
|
+
partial: output
|
|
2716
|
+
});
|
|
2717
|
+
}
|
|
2718
|
+
currentBlock.thinking += reasoningDelta.text;
|
|
2719
|
+
stream.push({
|
|
2720
|
+
type: "thinking_delta",
|
|
2721
|
+
contentIndex: blockIndex(),
|
|
2722
|
+
delta: reasoningDelta.text,
|
|
2723
|
+
partial: output
|
|
2724
|
+
});
|
|
2725
|
+
};
|
|
2726
|
+
const appendTextDeltaInternal = (text) => {
|
|
2727
|
+
if (!currentBlock || currentBlock.type !== "text") {
|
|
2728
|
+
finishCurrentBlock();
|
|
2729
|
+
currentBlock = {
|
|
2730
|
+
type: "text",
|
|
2731
|
+
text: ""
|
|
2732
|
+
};
|
|
2733
|
+
output.content.push(currentBlock);
|
|
2734
|
+
stream.push({
|
|
2735
|
+
type: "text_start",
|
|
2736
|
+
contentIndex: blockIndex(),
|
|
2737
|
+
partial: output
|
|
2738
|
+
});
|
|
2739
|
+
}
|
|
2740
|
+
currentBlock.text += text;
|
|
2741
|
+
stream.push({
|
|
2742
|
+
type: "text_delta",
|
|
2743
|
+
contentIndex: blockIndex(),
|
|
2744
|
+
delta: text,
|
|
2745
|
+
partial: output
|
|
2746
|
+
});
|
|
2747
|
+
};
|
|
2748
|
+
const flushPendingPostToolCallDeltas = () => {
|
|
2749
|
+
if (isFlushingPendingPostToolCallDeltas || currentBlock?.type === "toolCall" || pendingPostToolCallDeltas.length === 0) return;
|
|
2750
|
+
isFlushingPendingPostToolCallDeltas = true;
|
|
2751
|
+
const bufferedDeltas = pendingPostToolCallDeltas;
|
|
2752
|
+
pendingPostToolCallDeltas = [];
|
|
2753
|
+
pendingPostToolCallBytes = 0;
|
|
2754
|
+
for (const delta of bufferedDeltas) if (delta.kind === "text") appendTextDeltaInternal(delta.text);
|
|
2755
|
+
else appendThinkingDeltaInternal(delta);
|
|
2756
|
+
isFlushingPendingPostToolCallDeltas = false;
|
|
2757
|
+
};
|
|
2758
|
+
const appendThinkingDelta = (reasoningDelta) => {
|
|
2759
|
+
flushPendingPostToolCallDeltas();
|
|
2760
|
+
appendThinkingDeltaInternal(reasoningDelta);
|
|
2761
|
+
};
|
|
2762
|
+
const appendTextDelta = (text) => {
|
|
2763
|
+
flushPendingPostToolCallDeltas();
|
|
2764
|
+
appendTextDeltaInternal(text);
|
|
2765
|
+
};
|
|
2766
|
+
const appendVisibleTextDelta = (text) => {
|
|
2767
|
+
if (!text) return;
|
|
2768
|
+
if (currentBlock?.type === "toolCall") queuePostToolCallDelta({
|
|
2769
|
+
kind: "text",
|
|
2770
|
+
text
|
|
2771
|
+
});
|
|
2772
|
+
else appendTextDelta(text);
|
|
2773
|
+
};
|
|
2774
|
+
const appendFilteredVisibleTextDelta = (text) => {
|
|
2775
|
+
const parts = deepSeekTextFilter?.push(text) ?? [text];
|
|
2776
|
+
for (const part of parts) appendVisibleTextDelta(part);
|
|
2777
|
+
};
|
|
2778
|
+
const flushDeepSeekTextFilterAtEnd = () => {
|
|
2779
|
+
const parts = deepSeekTextFilter?.flush();
|
|
2780
|
+
if (!parts) return;
|
|
2781
|
+
for (const part of parts) appendVisibleTextDelta(part);
|
|
2782
|
+
};
|
|
2783
|
+
const cooperativeScheduler = createModelStreamCooperativeScheduler(options?.signal);
|
|
2784
|
+
for await (const rawChunk of responseStream) {
|
|
2785
|
+
throwIfModelStreamAborted(options?.signal);
|
|
2786
|
+
if (!rawChunk || typeof rawChunk !== "object") {
|
|
2787
|
+
await cooperativeScheduler.afterEvent();
|
|
2788
|
+
continue;
|
|
2789
|
+
}
|
|
2790
|
+
const chunk = rawChunk;
|
|
2791
|
+
output.responseId ||= chunk.id;
|
|
2792
|
+
if (chunk.usage) output.usage = parseTransportChunkUsage(chunk.usage, model);
|
|
2793
|
+
const choice = Array.isArray(chunk.choices) ? chunk.choices[0] : void 0;
|
|
2794
|
+
if (!choice) {
|
|
2795
|
+
await cooperativeScheduler.afterEvent();
|
|
2796
|
+
continue;
|
|
2797
|
+
}
|
|
2798
|
+
const choiceUsage = choice.usage;
|
|
2799
|
+
if (!chunk.usage && choiceUsage) output.usage = parseTransportChunkUsage(choiceUsage, model);
|
|
2800
|
+
if (choice.finish_reason) {
|
|
2801
|
+
const finishReasonResult = mapStopReason(choice.finish_reason);
|
|
2802
|
+
output.stopReason = finishReasonResult.stopReason;
|
|
2803
|
+
if (finishReasonResult.errorMessage) output.errorMessage = finishReasonResult.errorMessage;
|
|
2804
|
+
}
|
|
2805
|
+
const choiceDelta = choice.delta ?? choice.message;
|
|
2806
|
+
if (!choiceDelta) {
|
|
2807
|
+
await cooperativeScheduler.afterEvent();
|
|
2808
|
+
continue;
|
|
2809
|
+
}
|
|
2810
|
+
if (choiceDelta.content) {
|
|
2811
|
+
const contentDeltas = getCompletionsContentDeltas(choiceDelta.content);
|
|
2812
|
+
for (const contentDelta of contentDeltas) if (contentDelta.kind === "text") appendFilteredVisibleTextDelta(contentDelta.text);
|
|
2813
|
+
else if (currentBlock?.type === "toolCall") queuePostToolCallDelta(contentDelta);
|
|
2814
|
+
else appendThinkingDelta(contentDelta);
|
|
2815
|
+
}
|
|
2816
|
+
const reasoningDeltas = getCompletionsReasoningDeltas(choiceDelta, compat.visibleReasoningDetailTypes);
|
|
2817
|
+
for (const reasoningDelta of reasoningDeltas) {
|
|
2818
|
+
if (currentBlock?.type === "toolCall") {
|
|
2819
|
+
queuePostToolCallDelta({ ...reasoningDelta });
|
|
2820
|
+
continue;
|
|
2821
|
+
}
|
|
2822
|
+
if (reasoningDelta.kind === "text") appendTextDelta(reasoningDelta.text);
|
|
2823
|
+
else appendThinkingDelta(reasoningDelta);
|
|
2824
|
+
}
|
|
2825
|
+
if (choiceDelta.tool_calls && choiceDelta.tool_calls.length > 0) for (const toolCall of choiceDelta.tool_calls) {
|
|
2826
|
+
const streamIndex = typeof toolCall.index === "number" ? toolCall.index : void 0;
|
|
2827
|
+
let block = streamIndex !== void 0 ? toolCallBlocksByIndex.get(streamIndex) : void 0;
|
|
2828
|
+
if (!block && toolCall.id) block = toolCallBlocksById.get(toolCall.id);
|
|
2829
|
+
if (!block) {
|
|
2830
|
+
const switchingToolCall = currentBlock?.type === "toolCall";
|
|
2831
|
+
finishCurrentBlock();
|
|
2832
|
+
if (switchingToolCall) {
|
|
2833
|
+
currentBlock = null;
|
|
2834
|
+
flushPendingPostToolCallDeltas();
|
|
2835
|
+
}
|
|
2836
|
+
const initialSig = extractGoogleThoughtSignature(toolCall);
|
|
2837
|
+
block = {
|
|
2838
|
+
type: "toolCall",
|
|
2839
|
+
id: toolCall.id || "",
|
|
2840
|
+
name: toolCall.function?.name || "",
|
|
2841
|
+
arguments: {},
|
|
2842
|
+
partialArgs: "",
|
|
2843
|
+
...initialSig ? { thoughtSignature: initialSig } : {}
|
|
2844
|
+
};
|
|
2845
|
+
output.content.push(block);
|
|
2846
|
+
stream.push({
|
|
2847
|
+
type: "toolcall_start",
|
|
2848
|
+
contentIndex: output.content.indexOf(block),
|
|
2849
|
+
partial: output
|
|
2850
|
+
});
|
|
2851
|
+
}
|
|
2852
|
+
if (streamIndex !== void 0 && !toolCallBlocksByIndex.has(streamIndex)) toolCallBlocksByIndex.set(streamIndex, block);
|
|
2853
|
+
if (toolCall.id) {
|
|
2854
|
+
block.id = toolCall.id;
|
|
2855
|
+
toolCallBlocksById.set(toolCall.id, block);
|
|
2856
|
+
}
|
|
2857
|
+
currentBlock = block;
|
|
2858
|
+
if (toolCall.function?.name) block.name = toolCall.function.name;
|
|
2859
|
+
const deltaSig = extractGoogleThoughtSignature(toolCall);
|
|
2860
|
+
if (deltaSig) block.thoughtSignature = deltaSig;
|
|
2861
|
+
if (toolCall.function?.arguments) {
|
|
2862
|
+
const nextArgumentBytes = measureUtf8Bytes(toolCall.function.arguments);
|
|
2863
|
+
const currentBlockArgBytes = toolCallBlockBytes.get(block) ?? 0;
|
|
2864
|
+
if (currentBlockArgBytes + nextArgumentBytes > MAX_TOOL_CALL_ARGUMENT_BUFFER_BYTES) throw new Error("Exceeded tool-call argument buffer limit");
|
|
2865
|
+
toolCallBlockBytes.set(block, currentBlockArgBytes + nextArgumentBytes);
|
|
2866
|
+
block.partialArgs += toolCall.function.arguments;
|
|
2867
|
+
block.arguments = parseStreamingJson(block.partialArgs);
|
|
2868
|
+
stream.push({
|
|
2869
|
+
type: "toolcall_delta",
|
|
2870
|
+
contentIndex: output.content.indexOf(block),
|
|
2871
|
+
delta: toolCall.function.arguments,
|
|
2872
|
+
partial: output
|
|
2873
|
+
});
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
flushPendingPostToolCallDeltas();
|
|
2877
|
+
await cooperativeScheduler.afterEvent();
|
|
2878
|
+
}
|
|
2879
|
+
flushDeepSeekTextFilterAtEnd();
|
|
2880
|
+
finishAllToolCallBlocks();
|
|
2881
|
+
currentBlock = null;
|
|
2882
|
+
flushPendingPostToolCallDeltas();
|
|
2883
|
+
const hasToolCalls = output.content.some((block) => block.type === "toolCall");
|
|
2884
|
+
if (output.stopReason === "toolUse" && !hasToolCalls) output.stopReason = "stop";
|
|
2885
|
+
}
|
|
2886
|
+
function shouldFilterDeepSeekDsmlText(compat) {
|
|
2887
|
+
return compat.thinkingFormat === "deepseek";
|
|
2888
|
+
}
|
|
2889
|
+
function getCompletionsContentDeltas(content) {
|
|
2890
|
+
if (typeof content === "string") return content ? [{
|
|
2891
|
+
kind: "text",
|
|
2892
|
+
text: content
|
|
2893
|
+
}] : [];
|
|
2894
|
+
if (Array.isArray(content)) return content.flatMap((item) => getCompletionsContentDeltas(item));
|
|
2895
|
+
if (!content || typeof content !== "object") return [];
|
|
2896
|
+
const record = content;
|
|
2897
|
+
const type = typeof record.type === "string" ? record.type.toLowerCase() : "";
|
|
2898
|
+
const extractText = (value) => {
|
|
2899
|
+
if (typeof value === "string") return value;
|
|
2900
|
+
if (Array.isArray(value)) return value.map((item) => extractText(item)).join("");
|
|
2901
|
+
if (value && typeof value === "object") {
|
|
2902
|
+
const nested = value;
|
|
2903
|
+
return extractText(nested.text ?? nested.content ?? nested.thinking);
|
|
2904
|
+
}
|
|
2905
|
+
return "";
|
|
2906
|
+
};
|
|
2907
|
+
const text = extractText(record.text ?? record.content ?? record.thinking);
|
|
2908
|
+
if (!text) return [];
|
|
2909
|
+
if (type.includes("thinking") || type.includes("reasoning")) return [{
|
|
2910
|
+
kind: "thinking",
|
|
2911
|
+
signature: "content",
|
|
2912
|
+
text
|
|
2913
|
+
}];
|
|
2914
|
+
if (type === "text" || type === "output_text" || type.endsWith(".output_text")) return [{
|
|
2915
|
+
kind: "text",
|
|
2916
|
+
text
|
|
2917
|
+
}];
|
|
2918
|
+
return [];
|
|
2919
|
+
}
|
|
2920
|
+
function getCompletionsReasoningDeltas(delta, visibleReasoningDetailTypes) {
|
|
2921
|
+
const output = [];
|
|
2922
|
+
const pushDelta = (next) => {
|
|
2923
|
+
const previous = output[output.length - 1];
|
|
2924
|
+
if (!previous || previous.kind !== next.kind) {
|
|
2925
|
+
output.push(next);
|
|
2926
|
+
return;
|
|
2927
|
+
}
|
|
2928
|
+
if (next.kind === "thinking" && previous.kind === "thinking") {
|
|
2929
|
+
if (previous.signature !== next.signature) {
|
|
2930
|
+
output.push(next);
|
|
2931
|
+
return;
|
|
2932
|
+
}
|
|
2933
|
+
previous.text += next.text;
|
|
2934
|
+
return;
|
|
2935
|
+
}
|
|
2936
|
+
previous.text += next.text;
|
|
2937
|
+
};
|
|
2938
|
+
const reasoningDetails = delta.reasoning_details;
|
|
2939
|
+
let usedReasoningThinkingDetails = false;
|
|
2940
|
+
if (Array.isArray(reasoningDetails)) {
|
|
2941
|
+
const visibleTypes = new Set(visibleReasoningDetailTypes);
|
|
2942
|
+
for (const item of reasoningDetails) {
|
|
2943
|
+
const detail = item;
|
|
2944
|
+
if (typeof detail.text !== "string" || !detail.text) continue;
|
|
2945
|
+
if (detail.type === "reasoning.text") {
|
|
2946
|
+
usedReasoningThinkingDetails = true;
|
|
2947
|
+
pushDelta({
|
|
2948
|
+
kind: "thinking",
|
|
2949
|
+
signature: "reasoning_details",
|
|
2950
|
+
text: detail.text
|
|
2951
|
+
});
|
|
2952
|
+
continue;
|
|
2953
|
+
}
|
|
2954
|
+
if (typeof detail.type === "string" && visibleTypes.has(detail.type)) pushDelta({
|
|
2955
|
+
kind: "text",
|
|
2956
|
+
text: detail.text
|
|
2957
|
+
});
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
if (!usedReasoningThinkingDetails) for (const field of [
|
|
2961
|
+
"reasoning_content",
|
|
2962
|
+
"reasoning",
|
|
2963
|
+
"reasoning_text"
|
|
2964
|
+
]) {
|
|
2965
|
+
const value = delta[field];
|
|
2966
|
+
if (typeof value === "string" && value.length > 0) {
|
|
2967
|
+
pushDelta({
|
|
2968
|
+
kind: "thinking",
|
|
2969
|
+
signature: field,
|
|
2970
|
+
text: value
|
|
2971
|
+
});
|
|
2972
|
+
break;
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
return output;
|
|
2976
|
+
}
|
|
2977
|
+
function detectCompat(model) {
|
|
2978
|
+
const { defaults: compatDefaults } = detectOpenAICompletionsCompat(model);
|
|
2979
|
+
return {
|
|
2980
|
+
supportsStore: compatDefaults.supportsStore,
|
|
2981
|
+
supportsDeveloperRole: compatDefaults.supportsDeveloperRole,
|
|
2982
|
+
supportsReasoningEffort: compatDefaults.supportsReasoningEffort,
|
|
2983
|
+
reasoningEffortMap: {},
|
|
2984
|
+
supportsUsageInStreaming: compatDefaults.supportsUsageInStreaming,
|
|
2985
|
+
maxTokensField: compatDefaults.maxTokensField,
|
|
2986
|
+
requiresToolResultName: false,
|
|
2987
|
+
requiresAssistantAfterToolResult: false,
|
|
2988
|
+
requiresThinkingAsText: false,
|
|
2989
|
+
thinkingFormat: compatDefaults.thinkingFormat,
|
|
2990
|
+
visibleReasoningDetailTypes: compatDefaults.visibleReasoningDetailTypes,
|
|
2991
|
+
openRouterRouting: {},
|
|
2992
|
+
vercelGatewayRouting: {},
|
|
2993
|
+
supportsStrictMode: compatDefaults.supportsStrictMode,
|
|
2994
|
+
requiresReasoningContentOnAssistantMessages: compatDefaults.requiresReasoningContentOnAssistantMessages,
|
|
2995
|
+
requiresNonEmptyUserOrAssistantMessage: compatDefaults.requiresNonEmptyUserOrAssistantMessage
|
|
2996
|
+
};
|
|
2997
|
+
}
|
|
2998
|
+
function getCompat(model) {
|
|
2999
|
+
const detected = detectCompat(model);
|
|
3000
|
+
const compat = model.compat ?? {};
|
|
3001
|
+
const supportsStore = typeof compat.supportsStore === "boolean" ? compat.supportsStore : detected.supportsStore;
|
|
3002
|
+
const supportsReasoningEffort = typeof compat.supportsReasoningEffort === "boolean" ? compat.supportsReasoningEffort : detected.supportsReasoningEffort;
|
|
3003
|
+
return {
|
|
3004
|
+
supportsStore,
|
|
3005
|
+
supportsDeveloperRole: compat.supportsDeveloperRole ?? detected.supportsDeveloperRole,
|
|
3006
|
+
supportsReasoningEffort,
|
|
3007
|
+
reasoningEffortMap: resolveOpenAIReasoningEffortMap(model, detected.reasoningEffortMap),
|
|
3008
|
+
supportsUsageInStreaming: compat.supportsUsageInStreaming ?? detected.supportsUsageInStreaming,
|
|
3009
|
+
maxTokensField: compat.maxTokensField ?? detected.maxTokensField,
|
|
3010
|
+
requiresToolResultName: compat.requiresToolResultName ?? detected.requiresToolResultName,
|
|
3011
|
+
requiresAssistantAfterToolResult: compat.requiresAssistantAfterToolResult ?? detected.requiresAssistantAfterToolResult,
|
|
3012
|
+
requiresThinkingAsText: compat.requiresThinkingAsText ?? detected.requiresThinkingAsText,
|
|
3013
|
+
thinkingFormat: compat.thinkingFormat ?? detected.thinkingFormat,
|
|
3014
|
+
openRouterRouting: compat.openRouterRouting ?? {},
|
|
3015
|
+
vercelGatewayRouting: compat.vercelGatewayRouting ?? detected.vercelGatewayRouting,
|
|
3016
|
+
supportsStrictMode: compat.supportsStrictMode ?? detected.supportsStrictMode,
|
|
3017
|
+
supportsPromptCacheKey: compat.supportsPromptCacheKey === true,
|
|
3018
|
+
requiresStringContent: compat.requiresStringContent ?? false,
|
|
3019
|
+
strictMessageKeys: compat.strictMessageKeys === true,
|
|
3020
|
+
visibleReasoningDetailTypes: compat.visibleReasoningDetailTypes ?? detected.visibleReasoningDetailTypes,
|
|
3021
|
+
requiresReasoningContentOnAssistantMessages: detected.requiresReasoningContentOnAssistantMessages,
|
|
3022
|
+
requiresNonEmptyUserOrAssistantMessage: detected.requiresNonEmptyUserOrAssistantMessage
|
|
3023
|
+
};
|
|
3024
|
+
}
|
|
3025
|
+
function resolveOpenAICompletionsReasoningEffort(options) {
|
|
3026
|
+
return options?.reasoningEffort ?? options?.reasoning ?? "high";
|
|
3027
|
+
}
|
|
3028
|
+
function resolveOpenAICompletionsMaxTokens(model, options) {
|
|
3029
|
+
const paramsMaxTokens = resolveMaxTokensParam(model.params);
|
|
3030
|
+
return (options?.maxTokens || void 0) ?? (paramsMaxTokens || void 0) ?? model.maxTokens;
|
|
3031
|
+
}
|
|
3032
|
+
const OPENAI_COMPLETIONS_INPUT_TOKEN_SAFETY_MARGIN = 1.25;
|
|
3033
|
+
const OPENAI_COMPLETIONS_IMAGE_CHAR_ESTIMATE = 8e3;
|
|
3034
|
+
function estimateOpenAICompletionsInputTokens(payload) {
|
|
3035
|
+
let adjustedChars = 0;
|
|
3036
|
+
adjustedChars += estimateOpenAICompletionsMessagesChars(payload.messages);
|
|
3037
|
+
if (Array.isArray(payload.tools) && payload.tools.length > 0) try {
|
|
3038
|
+
adjustedChars += estimateStringChars(JSON.stringify(payload.tools));
|
|
3039
|
+
} catch {
|
|
3040
|
+
adjustedChars += 1024;
|
|
3041
|
+
}
|
|
3042
|
+
if (payload.response_format !== void 0) try {
|
|
3043
|
+
adjustedChars += estimateStringChars(JSON.stringify(payload.response_format));
|
|
3044
|
+
} catch {
|
|
3045
|
+
adjustedChars += 256;
|
|
3046
|
+
}
|
|
3047
|
+
return Math.ceil(adjustedChars / 4 * OPENAI_COMPLETIONS_INPUT_TOKEN_SAFETY_MARGIN);
|
|
3048
|
+
}
|
|
3049
|
+
function estimateOpenAICompletionsMessagesChars(messages) {
|
|
3050
|
+
if (!Array.isArray(messages)) return 0;
|
|
3051
|
+
let adjustedChars = 0;
|
|
3052
|
+
for (const message of messages) {
|
|
3053
|
+
if (!message || typeof message !== "object") continue;
|
|
3054
|
+
const record = message;
|
|
3055
|
+
adjustedChars += estimateOpenAICompletionsContentChars(record.content);
|
|
3056
|
+
for (const field of COMPLETIONS_REASONING_REPLAY_FIELDS) adjustedChars += estimateOpenAICompletionsContentChars(record[field]);
|
|
3057
|
+
if (record.tool_calls !== void 0) try {
|
|
3058
|
+
adjustedChars += estimateStringChars(JSON.stringify(record.tool_calls));
|
|
3059
|
+
} catch {
|
|
3060
|
+
adjustedChars += 256;
|
|
3061
|
+
}
|
|
3062
|
+
}
|
|
3063
|
+
return adjustedChars;
|
|
3064
|
+
}
|
|
3065
|
+
function estimateOpenAICompletionsContentChars(value) {
|
|
3066
|
+
if (typeof value === "string") return estimateStringChars(value);
|
|
3067
|
+
if (!Array.isArray(value)) return 0;
|
|
3068
|
+
let adjustedChars = 0;
|
|
3069
|
+
for (const block of value) {
|
|
3070
|
+
if (!block || typeof block !== "object") continue;
|
|
3071
|
+
const record = block;
|
|
3072
|
+
if (record.type === "image_url" || record.type === "input_image") {
|
|
3073
|
+
adjustedChars += OPENAI_COMPLETIONS_IMAGE_CHAR_ESTIMATE;
|
|
3074
|
+
continue;
|
|
3075
|
+
}
|
|
3076
|
+
const text = record.text;
|
|
3077
|
+
if (typeof text === "string") {
|
|
3078
|
+
adjustedChars += estimateStringChars(text);
|
|
3079
|
+
continue;
|
|
3080
|
+
}
|
|
3081
|
+
try {
|
|
3082
|
+
adjustedChars += estimateStringChars(JSON.stringify(block));
|
|
3083
|
+
} catch {
|
|
3084
|
+
adjustedChars += 256;
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
return adjustedChars;
|
|
3088
|
+
}
|
|
3089
|
+
function resolveOpenAICompletionsEffectiveContextTokens(model) {
|
|
3090
|
+
const contextTokens = model.contextTokens;
|
|
3091
|
+
if (typeof contextTokens === "number" && Number.isFinite(contextTokens) && contextTokens > 0) return contextTokens;
|
|
3092
|
+
return typeof model.contextWindow === "number" && Number.isFinite(model.contextWindow) && model.contextWindow > 0 ? model.contextWindow : void 0;
|
|
3093
|
+
}
|
|
3094
|
+
function isQwenOpenAICompletionsThinkingFormat(format) {
|
|
3095
|
+
return format === "qwen" || format === "qwen-chat-template";
|
|
3096
|
+
}
|
|
3097
|
+
function isOpenAICompletionsThinkingEnabled(effort) {
|
|
3098
|
+
const normalized = effort.trim().toLowerCase();
|
|
3099
|
+
return normalized !== "off" && normalized !== "none";
|
|
3100
|
+
}
|
|
3101
|
+
function setQwenChatTemplateThinking(params, enabled) {
|
|
3102
|
+
const existing = params.chat_template_kwargs;
|
|
3103
|
+
params.chat_template_kwargs = existing && typeof existing === "object" && !Array.isArray(existing) ? {
|
|
3104
|
+
...existing,
|
|
3105
|
+
enable_thinking: enabled
|
|
3106
|
+
} : { enable_thinking: enabled };
|
|
3107
|
+
}
|
|
3108
|
+
function applyQwenOpenAICompletionsThinkingParams(params) {
|
|
3109
|
+
if (!params.modelReasoning || !isQwenOpenAICompletionsThinkingFormat(params.compatThinkingFormat)) return false;
|
|
3110
|
+
const enabled = isOpenAICompletionsThinkingEnabled(params.requestedEffort);
|
|
3111
|
+
if (params.compatThinkingFormat === "qwen-chat-template") setQwenChatTemplateThinking(params.payload, enabled);
|
|
3112
|
+
else params.payload.enable_thinking = enabled;
|
|
3113
|
+
return true;
|
|
3114
|
+
}
|
|
3115
|
+
function applyTogetherOpenAICompletionsThinkingParams(params) {
|
|
3116
|
+
if (!params.modelReasoning || params.compatThinkingFormat !== "together") return false;
|
|
3117
|
+
params.payload.reasoning = { enabled: isOpenAICompletionsThinkingEnabled(params.requestedEffort) };
|
|
3118
|
+
return true;
|
|
3119
|
+
}
|
|
3120
|
+
function convertTools(tools, compat, model) {
|
|
3121
|
+
const strict = resolveOpenAIStrictToolFlagWithDiagnostics(tools, resolveOpenAIStrictToolSetting(model, {
|
|
3122
|
+
transport: "stream",
|
|
3123
|
+
supportsStrictMode: compat?.supportsStrictMode
|
|
3124
|
+
}), {
|
|
3125
|
+
transport: "completions",
|
|
3126
|
+
model
|
|
3127
|
+
});
|
|
3128
|
+
return sortTransportToolsByName(tools).map((tool) => {
|
|
3129
|
+
const functionTool = {
|
|
3130
|
+
name: tool.name,
|
|
3131
|
+
description: tool.description,
|
|
3132
|
+
parameters: normalizeOpenAIStrictToolParameters(tool.parameters, strict === true, model.compat)
|
|
3133
|
+
};
|
|
3134
|
+
if (strict !== void 0) functionTool.strict = strict;
|
|
3135
|
+
return {
|
|
3136
|
+
type: "function",
|
|
3137
|
+
function: functionTool
|
|
3138
|
+
};
|
|
3139
|
+
});
|
|
3140
|
+
}
|
|
3141
|
+
function compareTransportToolText(left, right) {
|
|
3142
|
+
const leftText = left ?? "";
|
|
3143
|
+
const rightText = right ?? "";
|
|
3144
|
+
if (leftText < rightText) return -1;
|
|
3145
|
+
if (leftText > rightText) return 1;
|
|
3146
|
+
return 0;
|
|
3147
|
+
}
|
|
3148
|
+
function sortTransportToolsByName(tools) {
|
|
3149
|
+
return tools.toSorted((left, right) => compareTransportToolText(left.name, right.name) || compareTransportToolText(left.description, right.description));
|
|
3150
|
+
}
|
|
3151
|
+
function extractGoogleThoughtSignature(toolCall) {
|
|
3152
|
+
const tc = toolCall;
|
|
3153
|
+
if (!tc) return;
|
|
3154
|
+
const fromExtra = (tc.extra_content?.google)?.thought_signature;
|
|
3155
|
+
if (typeof fromExtra === "string" && fromExtra.length > 0) return fromExtra;
|
|
3156
|
+
const fromFunction = tc.function?.thought_signature;
|
|
3157
|
+
return typeof fromFunction === "string" && fromFunction.length > 0 ? fromFunction : void 0;
|
|
3158
|
+
}
|
|
3159
|
+
function isGoogleOpenAICompatModel(model) {
|
|
3160
|
+
const endpointClass = detectOpenAICompletionsCompat(model).capabilities.endpointClass;
|
|
3161
|
+
return model.provider === "google" || endpointClass === "google-generative-ai" || endpointClass === "google-vertex";
|
|
3162
|
+
}
|
|
3163
|
+
function requiresGoogleCompatToolCallThoughtSignature(model) {
|
|
3164
|
+
return model.id.toLowerCase().includes("gemini-3");
|
|
3165
|
+
}
|
|
3166
|
+
const GOOGLE_COMPAT_THOUGHT_SIGNATURE_ELLIPSIS_RE = /[\u2026]|\.\.\./;
|
|
3167
|
+
const GOOGLE_COMPAT_THOUGHT_SIGNATURE_BASE64_RE = /^[A-Za-z0-9+/=]+$/;
|
|
3168
|
+
function hasGoogleCompatThoughtSignatureTruncationFootprint(value) {
|
|
3169
|
+
return GOOGLE_COMPAT_THOUGHT_SIGNATURE_ELLIPSIS_RE.test(value) || GOOGLE_COMPAT_THOUGHT_SIGNATURE_BASE64_RE.test(value) && value.length % 4 !== 0;
|
|
3170
|
+
}
|
|
3171
|
+
function injectToolCallThoughtSignatures(outgoingMessages, context, model) {
|
|
3172
|
+
if (!isGoogleOpenAICompatModel(model)) return;
|
|
3173
|
+
const sigById = /* @__PURE__ */ new Map();
|
|
3174
|
+
const fallbackSig = requiresGoogleCompatToolCallThoughtSignature(model) ? GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP : void 0;
|
|
3175
|
+
for (const msg of context.messages ?? []) {
|
|
3176
|
+
if (msg.role !== "assistant") continue;
|
|
3177
|
+
const source = msg;
|
|
3178
|
+
if (!Array.isArray(source.content)) continue;
|
|
3179
|
+
for (const block of source.content) {
|
|
3180
|
+
if (block.type !== "toolCall") continue;
|
|
3181
|
+
const id = block.id;
|
|
3182
|
+
const sig = block.thoughtSignature;
|
|
3183
|
+
if (typeof id === "string" && typeof sig === "string" && sig.length > 0) {
|
|
3184
|
+
const isSameRoute = source.api === model.api && source.provider === model.provider && source.model === model.id;
|
|
3185
|
+
if (!isSameRoute && !fallbackSig) continue;
|
|
3186
|
+
sigById.set(id, isSameRoute ? sig : fallbackSig ?? sig);
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
if (sigById.size === 0 && !fallbackSig) return;
|
|
3191
|
+
for (const message of outgoingMessages) {
|
|
3192
|
+
const toolCalls = message.tool_calls;
|
|
3193
|
+
if (!Array.isArray(toolCalls)) continue;
|
|
3194
|
+
for (const toolCall of toolCalls) {
|
|
3195
|
+
const id = toolCall.id;
|
|
3196
|
+
if (typeof id !== "string") continue;
|
|
3197
|
+
let sig = sigById.get(id) ?? fallbackSig;
|
|
3198
|
+
if (typeof sig === "string" && sig.length > 0) {
|
|
3199
|
+
if (hasGoogleCompatThoughtSignatureTruncationFootprint(sig.trim())) sig = fallbackSig;
|
|
3200
|
+
}
|
|
3201
|
+
if (typeof sig !== "string" || sig.length === 0) continue;
|
|
3202
|
+
const extra = toolCall.extra_content && typeof toolCall.extra_content === "object" ? toolCall.extra_content : {};
|
|
3203
|
+
toolCall.extra_content = extra;
|
|
3204
|
+
const google = extra.google && typeof extra.google === "object" ? extra.google : {};
|
|
3205
|
+
extra.google = google;
|
|
3206
|
+
google.thought_signature = sig;
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
const COMPLETIONS_REASONING_REPLAY_FIELDS = [
|
|
3211
|
+
"reasoning_details",
|
|
3212
|
+
"reasoning_content",
|
|
3213
|
+
"reasoning",
|
|
3214
|
+
"reasoning_text"
|
|
3215
|
+
];
|
|
3216
|
+
function stripCompletionsReasoningReplayFields(record) {
|
|
3217
|
+
for (const field of COMPLETIONS_REASONING_REPLAY_FIELDS) if (field in record) delete record[field];
|
|
3218
|
+
}
|
|
3219
|
+
function sanitizeOpenRouterReasoningReplayFields(record) {
|
|
3220
|
+
const reasoningDetails = record.reasoning_details;
|
|
3221
|
+
if (typeof reasoningDetails === "string") {
|
|
3222
|
+
if (reasoningDetails.length > 0 && typeof record.reasoning !== "string") record.reasoning = reasoningDetails;
|
|
3223
|
+
delete record.reasoning_details;
|
|
3224
|
+
} else if (reasoningDetails !== void 0 && !Array.isArray(reasoningDetails)) delete record.reasoning_details;
|
|
3225
|
+
if ("reasoning" in record && (typeof record.reasoning !== "string" || record.reasoning === "")) delete record.reasoning;
|
|
3226
|
+
if ("reasoning_content" in record && (typeof record.reasoning_content !== "string" || record.reasoning_content === "")) delete record.reasoning_content;
|
|
3227
|
+
const reasoningText = record.reasoning_text;
|
|
3228
|
+
if (typeof reasoningText === "string" && reasoningText.length > 0 && typeof record.reasoning !== "string" && typeof record.reasoning_content !== "string") record.reasoning = reasoningText;
|
|
3229
|
+
if ("reasoning_text" in record) delete record.reasoning_text;
|
|
3230
|
+
}
|
|
3231
|
+
function sanitizeReasoningContentReplayFields(record) {
|
|
3232
|
+
if ("reasoning_content" in record && typeof record.reasoning_content !== "string") delete record.reasoning_content;
|
|
3233
|
+
delete record.reasoning_details;
|
|
3234
|
+
delete record.reasoning;
|
|
3235
|
+
delete record.reasoning_text;
|
|
3236
|
+
}
|
|
3237
|
+
const REASONING_CONTENT_REPLAY_MODEL_IDS = new Set([
|
|
3238
|
+
"deepseek-v4-flash",
|
|
3239
|
+
"deepseek-v4-pro",
|
|
3240
|
+
"kimi-for-coding",
|
|
3241
|
+
"kimi-k2.5",
|
|
3242
|
+
"kimi-k2.6",
|
|
3243
|
+
"kimi-k2-thinking",
|
|
3244
|
+
"kimi-k2-thinking-turbo",
|
|
3245
|
+
"mimo-v2-pro",
|
|
3246
|
+
"mimo-v2-omni",
|
|
3247
|
+
"mimo-v2.5",
|
|
3248
|
+
"mimo-v2.5-pro",
|
|
3249
|
+
"mimo-v2.6-pro"
|
|
3250
|
+
]);
|
|
3251
|
+
const REASONING_CONTENT_REPLAY_TIER_SUFFIXES = [
|
|
3252
|
+
"-free",
|
|
3253
|
+
"-paid",
|
|
3254
|
+
"-trial"
|
|
3255
|
+
];
|
|
3256
|
+
function stripReasoningContentReplayTierSuffix(modelId) {
|
|
3257
|
+
for (const suffix of REASONING_CONTENT_REPLAY_TIER_SUFFIXES) if (modelId.length > suffix.length && modelId.endsWith(suffix)) return modelId.slice(0, -suffix.length);
|
|
3258
|
+
return modelId;
|
|
3259
|
+
}
|
|
3260
|
+
function getReasoningContentReplayModelIdCandidates(modelId) {
|
|
3261
|
+
if (typeof modelId !== "string") return [];
|
|
3262
|
+
const normalized = modelId.trim().toLowerCase();
|
|
3263
|
+
if (!normalized) return [];
|
|
3264
|
+
const parts = normalized.split("/").filter(Boolean);
|
|
3265
|
+
const finalPart = parts[parts.length - 1] ?? normalized;
|
|
3266
|
+
const candidates = [finalPart];
|
|
3267
|
+
const colonParts = finalPart.split(":").filter(Boolean);
|
|
3268
|
+
if (colonParts.length > 1) candidates.push(colonParts[0] ?? "", colonParts[colonParts.length - 1] ?? "");
|
|
3269
|
+
const baseCount = candidates.length;
|
|
3270
|
+
for (let index = 0; index < baseCount; index += 1) {
|
|
3271
|
+
const candidate = candidates[index];
|
|
3272
|
+
if (typeof candidate !== "string") continue;
|
|
3273
|
+
const stripped = stripReasoningContentReplayTierSuffix(candidate);
|
|
3274
|
+
if (stripped !== candidate) candidates.push(stripped);
|
|
3275
|
+
}
|
|
3276
|
+
return uniqueStrings(candidates.filter(Boolean));
|
|
3277
|
+
}
|
|
3278
|
+
function shouldPreserveReasoningContentReplay(model, compat) {
|
|
3279
|
+
if (compat.requiresReasoningContentOnAssistantMessages || compat.thinkingFormat === "deepseek" || compat.thinkingFormat === "zai") return true;
|
|
3280
|
+
return getReasoningContentReplayModelIdCandidates(model.id).some((modelId) => REASONING_CONTENT_REPLAY_MODEL_IDS.has(modelId));
|
|
3281
|
+
}
|
|
3282
|
+
function shouldPreserveOpenRouterReasoningReplay(model) {
|
|
3283
|
+
if (model.provider !== "openrouter") return true;
|
|
3284
|
+
const normalizedModelId = model.id.trim().toLowerCase();
|
|
3285
|
+
return !(normalizedModelId.startsWith("anthropic/") || normalizedModelId.startsWith("x-ai/"));
|
|
3286
|
+
}
|
|
3287
|
+
function sanitizeCompletionsReasoningReplayFields(messages, options) {
|
|
3288
|
+
if (!Array.isArray(messages)) return;
|
|
3289
|
+
for (const msg of messages) {
|
|
3290
|
+
if (!msg || typeof msg !== "object") continue;
|
|
3291
|
+
const record = msg;
|
|
3292
|
+
if (record.role !== "assistant") continue;
|
|
3293
|
+
if (options.preserveOpenRouterReasoning) sanitizeOpenRouterReasoningReplayFields(record);
|
|
3294
|
+
else if (options.preserveReasoningContent) sanitizeReasoningContentReplayFields(record);
|
|
3295
|
+
else stripCompletionsReasoningReplayFields(record);
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
function buildOpenAICompletionsParams(model, context, options) {
|
|
3299
|
+
const compat = getCompat(model);
|
|
3300
|
+
const compatDetection = detectOpenAICompletionsCompat(model);
|
|
3301
|
+
let messages = convertMessages(model, context.systemPrompt ? {
|
|
3302
|
+
...context,
|
|
3303
|
+
systemPrompt: stripSystemPromptCacheBoundary(context.systemPrompt)
|
|
3304
|
+
} : context, compat);
|
|
3305
|
+
injectToolCallThoughtSignatures(messages, context, model);
|
|
3306
|
+
sanitizeCompletionsReasoningReplayFields(messages, {
|
|
3307
|
+
preserveOpenRouterReasoning: compat.thinkingFormat === "openrouter" && shouldPreserveOpenRouterReasoningReplay(model),
|
|
3308
|
+
preserveReasoningContent: shouldPreserveReasoningContentReplay(model, compat)
|
|
3309
|
+
});
|
|
3310
|
+
if (compat.strictMessageKeys) messages = stripCompletionMessagesToRoleContent(messages);
|
|
3311
|
+
const cacheRetention = resolveCacheRetention(options?.cacheRetention);
|
|
3312
|
+
const promptCacheKey = resolvePromptCacheKey(options, cacheRetention);
|
|
3313
|
+
const params = {
|
|
3314
|
+
model: model.id,
|
|
3315
|
+
messages: compat.requiresStringContent ? flattenCompletionMessagesToStringContent(messages) : messages,
|
|
3316
|
+
stream: true
|
|
3317
|
+
};
|
|
3318
|
+
if (compat.supportsUsageInStreaming) params.stream_options = { include_usage: true };
|
|
3319
|
+
if (compat.supportsStore) params.store = false;
|
|
3320
|
+
if (compat.supportsPromptCacheKey && promptCacheKey) {
|
|
3321
|
+
params.prompt_cache_key = promptCacheKey;
|
|
3322
|
+
if (cacheRetention === "long") params.prompt_cache_retention = "24h";
|
|
3323
|
+
}
|
|
3324
|
+
if (options?.temperature !== void 0) params.temperature = options.temperature;
|
|
3325
|
+
if (options?.topP !== void 0) params.top_p = options.topP;
|
|
3326
|
+
if (options?.responseFormat !== void 0) params.response_format = options.responseFormat;
|
|
3327
|
+
if (options?.frequencyPenalty !== void 0) params.frequency_penalty = options.frequencyPenalty;
|
|
3328
|
+
if (options?.presencePenalty !== void 0) params.presence_penalty = options.presencePenalty;
|
|
3329
|
+
if (options?.seed !== void 0) params.seed = options.seed;
|
|
3330
|
+
if (supportsModelTools(model)) {
|
|
3331
|
+
if (context.tools) {
|
|
3332
|
+
params.tools = convertTools(context.tools, compat, model);
|
|
3333
|
+
if (options?.toolChoice) params.tool_choice = options.toolChoice;
|
|
3334
|
+
else if (compatDetection.capabilities.usesExplicitProxyLikeEndpoint && Array.isArray(params.tools) && params.tools.length > 0) params.tool_choice = "auto";
|
|
3335
|
+
} else if (hasToolHistory(context.messages)) params.tools = [];
|
|
3336
|
+
if (compatDetection.capabilities.usesExplicitProxyLikeEndpoint && Array.isArray(params.tools) && params.tools.length === 0) {
|
|
3337
|
+
delete params.tools;
|
|
3338
|
+
delete params.tool_choice;
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
{
|
|
3342
|
+
const effectiveMaxTokens = resolveOpenAICompletionsMaxTokens(model, options);
|
|
3343
|
+
const effectiveContextTokens = resolveOpenAICompletionsEffectiveContextTokens(model);
|
|
3344
|
+
let clampedMaxTokens = effectiveMaxTokens;
|
|
3345
|
+
if (compatDetection.capabilities.usesExplicitProxyLikeEndpoint && effectiveMaxTokens !== void 0 && effectiveContextTokens !== void 0) {
|
|
3346
|
+
const estimatedInputTokens = estimateOpenAICompletionsInputTokens(params);
|
|
3347
|
+
const remainingBudget = Math.max(1, effectiveContextTokens - estimatedInputTokens - 1);
|
|
3348
|
+
if (effectiveMaxTokens > remainingBudget) {
|
|
3349
|
+
clampedMaxTokens = remainingBudget;
|
|
3350
|
+
emitModelTransportDebug(log, `[completions] clamp_max_tokens provider=${model.provider} api=${model.api} model=${model.id} requested=${effectiveMaxTokens} output=${clampedMaxTokens} effectiveContext=${effectiveContextTokens} estimatedInput=${estimatedInputTokens}`);
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
if (clampedMaxTokens) if (compat.maxTokensField === "max_tokens") params.max_tokens = clampedMaxTokens;
|
|
3354
|
+
else params.max_completion_tokens = clampedMaxTokens;
|
|
3355
|
+
}
|
|
3356
|
+
const completionsReasoningEffort = resolveOpenAICompletionsReasoningEffort(options);
|
|
3357
|
+
const resolvedCompletionsReasoningEffort = completionsReasoningEffort ? resolveOpenAIReasoningEffortForModel({
|
|
3358
|
+
model,
|
|
3359
|
+
effort: completionsReasoningEffort,
|
|
3360
|
+
fallbackMap: compat.reasoningEffortMap
|
|
3361
|
+
}) : void 0;
|
|
3362
|
+
const omitGpt54MiniToolReasoningEffort = isOpenAIGpt54MiniModel(model) && Array.isArray(params.tools) && params.tools.length > 0;
|
|
3363
|
+
const handledQwenThinkingFormat = applyQwenOpenAICompletionsThinkingParams({
|
|
3364
|
+
compatThinkingFormat: compat.thinkingFormat,
|
|
3365
|
+
modelReasoning: model.reasoning,
|
|
3366
|
+
payload: params,
|
|
3367
|
+
requestedEffort: completionsReasoningEffort
|
|
3368
|
+
});
|
|
3369
|
+
applyTogetherOpenAICompletionsThinkingParams({
|
|
3370
|
+
compatThinkingFormat: compat.thinkingFormat,
|
|
3371
|
+
modelReasoning: model.reasoning,
|
|
3372
|
+
payload: params,
|
|
3373
|
+
requestedEffort: completionsReasoningEffort
|
|
3374
|
+
});
|
|
3375
|
+
if (compat.thinkingFormat === "openrouter" && model.reasoning && resolvedCompletionsReasoningEffort) params.reasoning = { effort: resolvedCompletionsReasoningEffort };
|
|
3376
|
+
else if (resolvedCompletionsReasoningEffort && model.reasoning && compat.supportsReasoningEffort && !handledQwenThinkingFormat && !omitGpt54MiniToolReasoningEffort) params.reasoning_effort = resolvedCompletionsReasoningEffort;
|
|
3377
|
+
return params;
|
|
3378
|
+
}
|
|
3379
|
+
function parseTransportChunkUsage(rawUsage, model) {
|
|
3380
|
+
const cachedTokens = rawUsage.prompt_tokens_details?.cached_tokens || 0;
|
|
3381
|
+
const promptTokens = rawUsage.prompt_tokens || 0;
|
|
3382
|
+
const input = Math.max(0, promptTokens - cachedTokens);
|
|
3383
|
+
const outputTokens = rawUsage.completion_tokens || 0;
|
|
3384
|
+
const reasoningTokens = rawUsage.completion_tokens_details?.reasoning_tokens;
|
|
3385
|
+
const usage = {
|
|
3386
|
+
input,
|
|
3387
|
+
output: outputTokens,
|
|
3388
|
+
cacheRead: cachedTokens,
|
|
3389
|
+
cacheWrite: 0,
|
|
3390
|
+
...typeof reasoningTokens === "number" && Number.isFinite(reasoningTokens) ? { reasoningTokens } : {},
|
|
3391
|
+
totalTokens: input + outputTokens + cachedTokens,
|
|
3392
|
+
cost: {
|
|
3393
|
+
input: 0,
|
|
3394
|
+
output: 0,
|
|
3395
|
+
cacheRead: 0,
|
|
3396
|
+
cacheWrite: 0,
|
|
3397
|
+
total: 0
|
|
3398
|
+
}
|
|
3399
|
+
};
|
|
3400
|
+
calculateCost(model, usage);
|
|
3401
|
+
return usage;
|
|
3402
|
+
}
|
|
3403
|
+
function mapStopReason(reason) {
|
|
3404
|
+
if (reason === null) return { stopReason: "stop" };
|
|
3405
|
+
switch (reason) {
|
|
3406
|
+
case "stop":
|
|
3407
|
+
case "end": return { stopReason: "stop" };
|
|
3408
|
+
case "length": return { stopReason: "length" };
|
|
3409
|
+
case "function_call":
|
|
3410
|
+
case "tool_call":
|
|
3411
|
+
case "tool_calls": return { stopReason: "toolUse" };
|
|
3412
|
+
case "content_filter": return {
|
|
3413
|
+
stopReason: "error",
|
|
3414
|
+
errorMessage: "Provider finish_reason: content_filter"
|
|
3415
|
+
};
|
|
3416
|
+
case "network_error": return {
|
|
3417
|
+
stopReason: "error",
|
|
3418
|
+
errorMessage: "Provider finish_reason: network_error"
|
|
3419
|
+
};
|
|
3420
|
+
default: return {
|
|
3421
|
+
stopReason: "error",
|
|
3422
|
+
errorMessage: `Provider finish_reason: ${reason}`
|
|
3423
|
+
};
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
//#endregion
|
|
3427
|
+
export { emitModelTransportDebug as C, stripCompletionMessagesToRoleContent as S, resolveMaxTokensParam as _, coerceTransportToolCallArguments as a, resolveOpenAIReasoningEffortForModel as b, failTransportStream as c, sanitizeNonEmptyTransportPayloadText as d, sanitizeTransportPayloadText as f, canonicalizeMaxTokensParam as g, supportsModelTools as h, createOpenAIResponsesTransportStreamFn as i, finalizeTransportStream as l, buildGuardedModelFetch as m, createAzureOpenAIResponsesTransportStreamFn as n, createEmptyTransportUsage as o, transformTransportMessages as p, createOpenAICompletionsTransportStreamFn as r, createWritableTransportEventStream as s, buildOpenAICompletionsParams as t, mergeTransportHeaders as u, applyOpenAIResponsesPayloadPolicy as v, flattenCompletionMessagesToStringContent as x, resolveOpenAIResponsesPayloadPolicy as y };
|