@jsonstudio/rcc 0.90.352 → 0.90.367
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.js +2 -2
- package/dist/cli/commands/codex.js +37 -7
- package/dist/cli/commands/codex.js.map +1 -1
- package/dist/cli/commands/launcher/types.d.ts +1 -0
- package/dist/cli/commands/launcher-kernel.js +69 -90
- package/dist/cli/commands/launcher-kernel.js.map +1 -1
- package/dist/modules/llmswitch/bridge/module-loader.js +2 -2
- package/dist/modules/llmswitch/bridge/module-loader.js.map +1 -1
- package/dist/modules/llmswitch/bridge/quota-manager.js +1 -1
- package/dist/modules/llmswitch/bridge/quota-manager.js.map +1 -1
- package/dist/modules/llmswitch/bridge/runtime-integrations.d.ts +1 -1
- package/dist/modules/llmswitch/bridge/runtime-integrations.js.map +1 -1
- package/dist/modules/llmswitch/bridge.d.ts +5 -5
- package/dist/modules/llmswitch/bridge.js.map +1 -1
- package/dist/modules/llmswitch/core-loader.js +35 -24
- package/dist/modules/llmswitch/core-loader.js.map +1 -1
- package/dist/server/runtime/http-server/executor/provider-response-converter.js +133 -2
- package/dist/server/runtime/http-server/executor/provider-response-converter.js.map +1 -1
- package/dist/server/runtime/http-server/executor-response.js +62 -1
- package/dist/server/runtime/http-server/executor-response.js.map +1 -1
- package/dist/server/runtime/http-server/session-client-route-utils.js +38 -5
- package/dist/server/runtime/http-server/session-client-route-utils.js.map +1 -1
- package/package.json +7 -8
- package/scripts/analyze-thinking-keywords.mjs +1 -1
- package/scripts/ensure-llmswitch-mode.mjs +5 -63
- package/scripts/install-global.sh +0 -46
- package/scripts/install-release.sh +4 -38
- package/scripts/install-verify.mjs +6 -25
- package/scripts/pack-mode.mjs +16 -39
- package/scripts/pack-rcc.mjs +4 -63
- package/scripts/publish-rcc.mjs +4 -59
- package/scripts/snapshot-inspect.mjs +24 -5
- package/scripts/tests/blackbox-rcc-vs-routecodex-antigravity.mjs +2 -2
- package/scripts/vendor-core.mjs +30 -9
- package/vendor/llmswitch-core/README.md +271 -0
- package/vendor/llmswitch-core/dist/bridge/routecodex-adapter.d.ts +74 -0
- package/vendor/llmswitch-core/dist/bridge/routecodex-adapter.js +229 -0
- package/vendor/llmswitch-core/dist/config-unified/enhanced-path-resolver.d.ts +5 -0
- package/vendor/llmswitch-core/dist/config-unified/enhanced-path-resolver.js +46 -0
- package/vendor/llmswitch-core/dist/config-unified/unified-config.d.ts +26 -0
- package/vendor/llmswitch-core/dist/config-unified/unified-config.js +231 -0
- package/vendor/llmswitch-core/dist/conversion/args-mapping.d.ts +18 -0
- package/vendor/llmswitch-core/dist/conversion/args-mapping.js +8 -0
- package/vendor/llmswitch-core/dist/conversion/bridge-actions.d.ts +39 -0
- package/vendor/llmswitch-core/dist/conversion/bridge-actions.js +82 -0
- package/vendor/llmswitch-core/dist/conversion/bridge-id-utils.d.ts +9 -0
- package/vendor/llmswitch-core/dist/conversion/bridge-id-utils.js +13 -0
- package/vendor/llmswitch-core/dist/conversion/bridge-instructions.d.ts +1 -0
- package/vendor/llmswitch-core/dist/conversion/bridge-instructions.js +17 -0
- package/vendor/llmswitch-core/dist/conversion/bridge-message-utils.d.ts +23 -0
- package/vendor/llmswitch-core/dist/conversion/bridge-message-utils.js +45 -0
- package/vendor/llmswitch-core/dist/conversion/bridge-metadata.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/bridge-metadata.js +5 -0
- package/vendor/llmswitch-core/dist/conversion/bridge-policies.d.ts +18 -0
- package/vendor/llmswitch-core/dist/conversion/bridge-policies.js +11 -0
- package/vendor/llmswitch-core/dist/conversion/codec-registry.d.ts +10 -0
- package/vendor/llmswitch-core/dist/conversion/codec-registry.js +37 -0
- package/vendor/llmswitch-core/dist/conversion/codecs/anthropic-openai-codec.d.ts +22 -0
- package/vendor/llmswitch-core/dist/conversion/codecs/anthropic-openai-codec.js +52 -0
- package/vendor/llmswitch-core/dist/conversion/codecs/gemini-openai-codec.d.ts +17 -0
- package/vendor/llmswitch-core/dist/conversion/codecs/gemini-openai-codec.js +85 -0
- package/vendor/llmswitch-core/dist/conversion/codecs/openai-openai-codec.d.ts +12 -0
- package/vendor/llmswitch-core/dist/conversion/codecs/openai-openai-codec.js +54 -0
- package/vendor/llmswitch-core/dist/conversion/codecs/responses-openai-codec.d.ts +12 -0
- package/vendor/llmswitch-core/dist/conversion/codecs/responses-openai-codec.js +66 -0
- package/vendor/llmswitch-core/dist/conversion/compaction-detect.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/compaction-detect.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/anthropic-claude-code-system-prompt.d.ts +4 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/anthropic-claude-code-system-prompt.js +42 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/anthropic-claude-code-user-id.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/anthropic-claude-code-user-id.js +30 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/antigravity-thought-signature-cache.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/antigravity-thought-signature-cache.js +8 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/antigravity-thought-signature-prepare.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/antigravity-thought-signature-prepare.js +26 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/apply-patch-fixer.d.ts +1 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/apply-patch-fixer.js +30 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/auto-thinking.d.ts +6 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/auto-thinking.js +26 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/claude-thinking-tools.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/claude-thinking-tools.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/deepseek-web-request.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/deepseek-web-request.js +62 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/deepseek-web-response.d.ts +12 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/deepseek-web-response.js +114 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/field-mapping.d.ts +14 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/field-mapping.js +155 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/gemini-cli-request.d.ts +5 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/gemini-cli-request.js +27 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/gemini-web-search.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/gemini-web-search.js +24 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/glm-history-image-trim.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/glm-history-image-trim.js +54 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/glm-image-content.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/glm-image-content.js +54 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/glm-native-compat.d.ts +6 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/glm-native-compat.js +34 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/glm-tool-extraction.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/glm-tool-extraction.js +35 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/glm-vision-prompt.d.ts +11 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/glm-vision-prompt.js +104 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/glm-web-search.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/glm-web-search.js +30 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/harvest-tool-calls-from-text.d.ts +15 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/harvest-tool-calls-from-text.js +124 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-kimi-cli-defaults.d.ts +10 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-kimi-cli-defaults.js +31 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-kimi-history-media-placeholder.d.ts +7 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-kimi-history-media-placeholder.js +25 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-kimi-thinking-reasoning-fill.d.ts +12 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-kimi-thinking-reasoning-fill.js +46 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-native-compat.d.ts +6 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-native-compat.js +36 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-response-body-unwrap.d.ts +9 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-response-body-unwrap.js +25 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-tool-text-fallback.d.ts +5 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-tool-text-fallback.js +29 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-web-search.d.ts +18 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/iflow-web-search.js +49 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/index.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/index.js +2 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/lmstudio-responses-fc-ids.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/lmstudio-responses-fc-ids.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/lmstudio-responses-input-stringify.d.ts +14 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/lmstudio-responses-input-stringify.js +125 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/normalize-tool-call-ids.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/normalize-tool-call-ids.js +10 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/qwen-transform.d.ts +4 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/qwen-transform.js +40 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/request-rules.d.ts +24 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/request-rules.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/response-blacklist.d.ts +10 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/response-blacklist.js +10 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/response-normalize.d.ts +5 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/response-normalize.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/response-validate.d.ts +5 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/response-validate.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/snapshot.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/snapshot.js +21 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/strip-orphan-function-calls-tag.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/strip-orphan-function-calls-tag.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/tool-schema.d.ts +6 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/tool-schema.js +91 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/tool-text-request-guidance.d.ts +9 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/tool-text-request-guidance.js +7 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/universal-shape-filter.d.ts +57 -0
- package/vendor/llmswitch-core/dist/conversion/compat/actions/universal-shape-filter.js +14 -0
- package/vendor/llmswitch-core/dist/conversion/compat/antigravity-session-signature.d.ts +86 -0
- package/vendor/llmswitch-core/dist/conversion/compat/antigravity-session-signature.js +1143 -0
- package/vendor/llmswitch-core/dist/conversion/compat/profiles/anthropic-claude-code.json +17 -0
- package/vendor/llmswitch-core/dist/conversion/compat/profiles/chat-claude-code.json +18 -0
- package/vendor/llmswitch-core/dist/conversion/compat/profiles/chat-deepseek-web.json +47 -0
- package/vendor/llmswitch-core/dist/conversion/compat/profiles/chat-gemini-cli.json +23 -0
- package/vendor/llmswitch-core/dist/conversion/compat/profiles/chat-gemini.json +31 -0
- package/vendor/llmswitch-core/dist/conversion/compat/profiles/chat-glm.json +405 -0
- package/vendor/llmswitch-core/dist/conversion/compat/profiles/chat-iflow.json +353 -0
- package/vendor/llmswitch-core/dist/conversion/compat/profiles/chat-lmstudio.json +80 -0
- package/vendor/llmswitch-core/dist/conversion/compat/profiles/chat-qwen.json +22 -0
- package/vendor/llmswitch-core/dist/conversion/compat/profiles/responses-c4m.json +45 -0
- package/vendor/llmswitch-core/dist/conversion/compat/profiles/responses-crs.json +15 -0
- package/vendor/llmswitch-core/dist/conversion/compat/profiles/responses-output2choices-test.json +12 -0
- package/vendor/llmswitch-core/dist/conversion/config/config-manager.d.ts +212 -0
- package/vendor/llmswitch-core/dist/conversion/config/config-manager.js +310 -0
- package/vendor/llmswitch-core/dist/conversion/config/sample-config.json +314 -0
- package/vendor/llmswitch-core/dist/conversion/config/version-switch.json +150 -0
- package/vendor/llmswitch-core/dist/conversion/hub/config/types.d.ts +26 -0
- package/vendor/llmswitch-core/dist/conversion/hub/config/types.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/hub/core/detour-registry.d.ts +11 -0
- package/vendor/llmswitch-core/dist/conversion/hub/core/detour-registry.js +23 -0
- package/vendor/llmswitch-core/dist/conversion/hub/core/hub-context.d.ts +23 -0
- package/vendor/llmswitch-core/dist/conversion/hub/core/hub-context.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/hub/core/index.d.ts +4 -0
- package/vendor/llmswitch-core/dist/conversion/hub/core/index.js +3 -0
- package/vendor/llmswitch-core/dist/conversion/hub/core/stage-driver.d.ts +30 -0
- package/vendor/llmswitch-core/dist/conversion/hub/core/stage-driver.js +33 -0
- package/vendor/llmswitch-core/dist/conversion/hub/format-adapters/anthropic-format-adapter.d.ts +16 -0
- package/vendor/llmswitch-core/dist/conversion/hub/format-adapters/anthropic-format-adapter.js +42 -0
- package/vendor/llmswitch-core/dist/conversion/hub/format-adapters/chat-format-adapter.d.ts +17 -0
- package/vendor/llmswitch-core/dist/conversion/hub/format-adapters/chat-format-adapter.js +42 -0
- package/vendor/llmswitch-core/dist/conversion/hub/format-adapters/gemini-format-adapter.d.ts +16 -0
- package/vendor/llmswitch-core/dist/conversion/hub/format-adapters/gemini-format-adapter.js +42 -0
- package/vendor/llmswitch-core/dist/conversion/hub/format-adapters/index.d.ts +21 -0
- package/vendor/llmswitch-core/dist/conversion/hub/format-adapters/index.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/hub/format-adapters/responses-format-adapter.d.ts +19 -0
- package/vendor/llmswitch-core/dist/conversion/hub/format-adapters/responses-format-adapter.js +42 -0
- package/vendor/llmswitch-core/dist/conversion/hub/hub-feature.d.ts +1 -0
- package/vendor/llmswitch-core/dist/conversion/hub/hub-feature.js +26 -0
- package/vendor/llmswitch-core/dist/conversion/hub/node-support.d.ts +19 -0
- package/vendor/llmswitch-core/dist/conversion/hub/node-support.js +136 -0
- package/vendor/llmswitch-core/dist/conversion/hub/operation-table/operation-table-runner.d.ts +18 -0
- package/vendor/llmswitch-core/dist/conversion/hub/operation-table/operation-table-runner.js +162 -0
- package/vendor/llmswitch-core/dist/conversion/hub/operation-table/semantic-mappers/anthropic-mapper.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/operation-table/semantic-mappers/anthropic-mapper.js +503 -0
- package/vendor/llmswitch-core/dist/conversion/hub/operation-table/semantic-mappers/archive/chat-mapper.archive.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/operation-table/semantic-mappers/archive/chat-mapper.archive.js +409 -0
- package/vendor/llmswitch-core/dist/conversion/hub/operation-table/semantic-mappers/chat-mapper.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/operation-table/semantic-mappers/chat-mapper.js +350 -0
- package/vendor/llmswitch-core/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.d.ts +7 -0
- package/vendor/llmswitch-core/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.js +1540 -0
- package/vendor/llmswitch-core/dist/conversion/hub/operation-table/semantic-mappers/responses-mapper.d.ts +21 -0
- package/vendor/llmswitch-core/dist/conversion/hub/operation-table/semantic-mappers/responses-mapper.js +491 -0
- package/vendor/llmswitch-core/dist/conversion/hub/ops/operations.d.ts +19 -0
- package/vendor/llmswitch-core/dist/conversion/hub/ops/operations.js +7 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/compat/compat-engine.d.ts +9 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/compat/compat-engine.js +13 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.d.ts +9 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +46 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/compat/compat-profile-resolver.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/compat/compat-profile-resolver.js +14 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/compat/compat-profile-store.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/compat/compat-profile-store.js +94 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/compat/compat-types.d.ts +175 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/compat/compat-types.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/compat/native-adapter-context.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/compat/native-adapter-context.js +40 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/hub-pipeline.d.ts +111 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/hub-pipeline.js +1927 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/hub-stage-timing.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/hub-stage-timing.js +211 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/session-identifiers.d.ts +9 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/session-identifiers.js +16 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.d.ts +10 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.js +236 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.d.ts +24 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.js +132 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.d.ts +14 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.js +24 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.js +157 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.d.ts +16 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.js +29 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-factories.d.ts +5 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-factories.js +19 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.d.ts +6 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.js +22 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.js +28 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.d.ts +10 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.js +12 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.js +30 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/index.d.ts +18 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/index.js +84 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.js +12 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.d.ts +14 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +45 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.d.ts +16 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.js +62 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_process/req_process_stage2_route_select/index.d.ts +17 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/req_process/req_process_stage2_route_select/index.js +35 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/index.d.ts +17 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/index.js +243 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.js +81 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.d.ts +10 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.js +50 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage3_semantic_map/index.d.ts +13 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage3_semantic_map/index.js +25 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.d.ts +6 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.js +17 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.d.ts +9 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.js +103 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.d.ts +13 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.js +30 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage2_sse_stream/index.d.ts +17 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage2_sse_stream/index.js +35 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage1_tool_governance/index.d.ts +16 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage1_tool_governance/index.js +52 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage2_finalize/index.d.ts +19 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage2_finalize/index.js +40 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.d.ts +44 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.js +88 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/utils.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/stages/utils.js +27 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/target-utils.d.ts +5 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipeline/target-utils.js +26 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipelines/inbound.d.ts +22 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipelines/inbound.js +66 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipelines/outbound.d.ts +22 -0
- package/vendor/llmswitch-core/dist/conversion/hub/pipelines/outbound.js +59 -0
- package/vendor/llmswitch-core/dist/conversion/hub/policy/policy-engine.d.ts +48 -0
- package/vendor/llmswitch-core/dist/conversion/hub/policy/policy-engine.js +269 -0
- package/vendor/llmswitch-core/dist/conversion/hub/policy/protocol-spec.d.ts +75 -0
- package/vendor/llmswitch-core/dist/conversion/hub/policy/protocol-spec.js +27 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-anthropic-alias.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-anthropic-alias.js +36 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-directive-parser.d.ts +5 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-directive-parser.js +56 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-directives.d.ts +24 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-directives.js +98 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-reminder-directives.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-reminder-directives.js +42 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-reminder-finalize.d.ts +14 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-reminder-finalize.js +10 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-reminder-messages.d.ts +5 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-reminder-messages.js +10 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.d.ts +30 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.js +68 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.d.ts +9 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.js +18 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-reminders.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-reminders.js +104 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-tool-schemas.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-tool-schemas.js +280 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-tools.d.ts +6 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-clock-tools.js +41 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-continue-execution.d.ts +11 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-continue-execution.js +83 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-governance-context.d.ts +15 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-governance-context.js +7 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-governance-finalize.d.ts +16 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-governance-finalize.js +11 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-governance-orchestration.d.ts +9 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-governance-orchestration.js +49 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-governed-control-ops.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-governed-control-ops.js +5 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-governed-filter-call.d.ts +12 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-governed-filter-call.js +18 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-governed-merge.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-governed-merge.js +11 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-media.d.ts +5 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-media.js +108 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-node-result.d.ts +23 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-node-result.js +24 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-pending-tool-sync.d.ts +14 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-pending-tool-sync.js +52 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-post-governed-normalization.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-post-governed-normalization.js +16 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-review.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-review.js +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-servertool-orchestration.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-servertool-orchestration.js +22 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-session-usage.d.ts +7 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-session-usage.js +147 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-tool-normalization.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-tool-normalization.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-web-search-intent.d.ts +12 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-web-search-intent.js +13 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-web-search-tool-schema.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-web-search-tool-schema.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-web-search.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process-web-search.js +26 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process.d.ts +15 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/chat-process.js +27 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/client-inject-readiness.d.ts +1 -0
- package/vendor/llmswitch-core/dist/conversion/hub/process/client-inject-readiness.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/hub/registry.d.ts +28 -0
- package/vendor/llmswitch-core/dist/conversion/hub/registry.js +101 -0
- package/vendor/llmswitch-core/dist/conversion/hub/response/chat-response-utils.d.ts +6 -0
- package/vendor/llmswitch-core/dist/conversion/hub/response/chat-response-utils.js +8 -0
- package/vendor/llmswitch-core/dist/conversion/hub/response/provider-response.d.ts +51 -0
- package/vendor/llmswitch-core/dist/conversion/hub/response/provider-response.js +529 -0
- package/vendor/llmswitch-core/dist/conversion/hub/response/response-mappers.d.ts +24 -0
- package/vendor/llmswitch-core/dist/conversion/hub/response/response-mappers.js +73 -0
- package/vendor/llmswitch-core/dist/conversion/hub/response/response-runtime.d.ts +9 -0
- package/vendor/llmswitch-core/dist/conversion/hub/response/response-runtime.js +758 -0
- package/vendor/llmswitch-core/dist/conversion/hub/semantic-mappers/anthropic-mapper.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/semantic-mappers/anthropic-mapper.js +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/semantic-mappers/chat-mapper.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/semantic-mappers/chat-mapper.js +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/semantic-mappers/gemini-mapper.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/semantic-mappers/gemini-mapper.js +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/semantic-mappers/index.d.ts +4 -0
- package/vendor/llmswitch-core/dist/conversion/hub/semantic-mappers/index.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/hub/semantic-mappers/responses-mapper.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/semantic-mappers/responses-mapper.js +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/snapshot-recorder.d.ts +13 -0
- package/vendor/llmswitch-core/dist/conversion/hub/snapshot-recorder.js +38 -0
- package/vendor/llmswitch-core/dist/conversion/hub/standardized-bridge.d.ts +12 -0
- package/vendor/llmswitch-core/dist/conversion/hub/standardized-bridge.js +16 -0
- package/vendor/llmswitch-core/dist/conversion/hub/tool-governance/engine.d.ts +24 -0
- package/vendor/llmswitch-core/dist/conversion/hub/tool-governance/engine.js +118 -0
- package/vendor/llmswitch-core/dist/conversion/hub/tool-governance/index.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/hub/tool-governance/index.js +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/tool-governance/rules.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/hub/tool-governance/rules.js +80 -0
- package/vendor/llmswitch-core/dist/conversion/hub/tool-governance/types.d.ts +38 -0
- package/vendor/llmswitch-core/dist/conversion/hub/tool-governance/types.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/hub/tool-session-compat.d.ts +26 -0
- package/vendor/llmswitch-core/dist/conversion/hub/tool-session-compat.js +86 -0
- package/vendor/llmswitch-core/dist/conversion/hub/tool-surface/tool-surface-engine.d.ts +18 -0
- package/vendor/llmswitch-core/dist/conversion/hub/tool-surface/tool-surface-engine.js +574 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/chat-envelope.d.ts +79 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/chat-envelope.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/chat-schema.d.ts +112 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/chat-schema.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/errors.d.ts +5 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/errors.js +13 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/format-envelope.d.ts +7 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/format-envelope.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/index.d.ts +6 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/index.js +6 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/json.d.ts +9 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/json.js +9 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/node.d.ts +31 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/node.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/standardized.d.ts +99 -0
- package/vendor/llmswitch-core/dist/conversion/hub/types/standardized.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/index.d.ts +33 -0
- package/vendor/llmswitch-core/dist/conversion/index.js +33 -0
- package/vendor/llmswitch-core/dist/conversion/jsonish.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/jsonish.js +20 -0
- package/vendor/llmswitch-core/dist/conversion/mcp-injection.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/mcp-injection.js +7 -0
- package/vendor/llmswitch-core/dist/conversion/media.d.ts +1 -0
- package/vendor/llmswitch-core/dist/conversion/media.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/metadata-passthrough.d.ts +11 -0
- package/vendor/llmswitch-core/dist/conversion/metadata-passthrough.js +20 -0
- package/vendor/llmswitch-core/dist/conversion/payload-budget.d.ts +13 -0
- package/vendor/llmswitch-core/dist/conversion/payload-budget.js +47 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/codecs/v2/anthropic-openai-pipeline.d.ts +11 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/codecs/v2/anthropic-openai-pipeline.js +104 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/codecs/v2/openai-openai-pipeline.d.ts +15 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/codecs/v2/openai-openai-pipeline.js +176 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/codecs/v2/responses-openai-pipeline.d.ts +12 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/codecs/v2/responses-openai-pipeline.js +212 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/codecs/v2/shared/openai-chat-helpers.d.ts +13 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/codecs/v2/shared/openai-chat-helpers.js +34 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/hooks/adapter-context.d.ts +7 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/hooks/adapter-context.js +18 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/hooks/protocol-hooks.d.ts +67 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/hooks/protocol-hooks.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/index.d.ts +35 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/index.js +103 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/meta/meta-bag.d.ts +20 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/meta/meta-bag.js +81 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/schema/canonical-chat.d.ts +18 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/schema/canonical-chat.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/schema/index.d.ts +1 -0
- package/vendor/llmswitch-core/dist/conversion/pipeline/schema/index.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/protocol-field-allowlists.d.ts +7 -0
- package/vendor/llmswitch-core/dist/conversion/protocol-field-allowlists.js +9 -0
- package/vendor/llmswitch-core/dist/conversion/protocol-state.d.ts +4 -0
- package/vendor/llmswitch-core/dist/conversion/protocol-state.js +27 -0
- package/vendor/llmswitch-core/dist/conversion/provider-protocol-error.d.ts +17 -0
- package/vendor/llmswitch-core/dist/conversion/provider-protocol-error.js +25 -0
- package/vendor/llmswitch-core/dist/conversion/responses/responses-host-policy.d.ts +6 -0
- package/vendor/llmswitch-core/dist/conversion/responses/responses-host-policy.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/responses/responses-openai-bridge/response-payload.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/responses/responses-openai-bridge/response-payload.js +190 -0
- package/vendor/llmswitch-core/dist/conversion/responses/responses-openai-bridge/types.d.ts +35 -0
- package/vendor/llmswitch-core/dist/conversion/responses/responses-openai-bridge/types.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/responses/responses-openai-bridge.d.ts +15 -0
- package/vendor/llmswitch-core/dist/conversion/responses/responses-openai-bridge.js +475 -0
- package/vendor/llmswitch-core/dist/conversion/runtime-metadata.d.ts +7 -0
- package/vendor/llmswitch-core/dist/conversion/runtime-metadata.js +31 -0
- package/vendor/llmswitch-core/dist/conversion/schema-validator.d.ts +7 -0
- package/vendor/llmswitch-core/dist/conversion/schema-validator.js +67 -0
- package/vendor/llmswitch-core/dist/conversion/shared/anthropic-message-utils.d.ts +22 -0
- package/vendor/llmswitch-core/dist/conversion/shared/anthropic-message-utils.js +1416 -0
- package/vendor/llmswitch-core/dist/conversion/shared/chat-envelope-validator.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/shared/chat-envelope-validator.js +4 -0
- package/vendor/llmswitch-core/dist/conversion/shared/chat-output-normalizer.d.ts +4 -0
- package/vendor/llmswitch-core/dist/conversion/shared/chat-output-normalizer.js +10 -0
- package/vendor/llmswitch-core/dist/conversion/shared/chat-request-filters.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/shared/chat-request-filters.js +63 -0
- package/vendor/llmswitch-core/dist/conversion/shared/gemini-tool-utils.d.ts +7 -0
- package/vendor/llmswitch-core/dist/conversion/shared/gemini-tool-utils.js +20 -0
- package/vendor/llmswitch-core/dist/conversion/shared/openai-finalizer.d.ts +8 -0
- package/vendor/llmswitch-core/dist/conversion/shared/openai-finalizer.js +22 -0
- package/vendor/llmswitch-core/dist/conversion/shared/openai-message-normalize.d.ts +1 -0
- package/vendor/llmswitch-core/dist/conversion/shared/openai-message-normalize.js +151 -0
- package/vendor/llmswitch-core/dist/conversion/shared/output-content-normalizer.d.ts +12 -0
- package/vendor/llmswitch-core/dist/conversion/shared/output-content-normalizer.js +26 -0
- package/vendor/llmswitch-core/dist/conversion/shared/reasoning-mapping.d.ts +5 -0
- package/vendor/llmswitch-core/dist/conversion/shared/reasoning-mapping.js +7 -0
- package/vendor/llmswitch-core/dist/conversion/shared/reasoning-normalizer.d.ts +25 -0
- package/vendor/llmswitch-core/dist/conversion/shared/reasoning-normalizer.js +114 -0
- package/vendor/llmswitch-core/dist/conversion/shared/reasoning-tool-normalizer.d.ts +12 -0
- package/vendor/llmswitch-core/dist/conversion/shared/reasoning-tool-normalizer.js +22 -0
- package/vendor/llmswitch-core/dist/conversion/shared/reasoning-tool-parser.d.ts +10 -0
- package/vendor/llmswitch-core/dist/conversion/shared/reasoning-tool-parser.js +11 -0
- package/vendor/llmswitch-core/dist/conversion/shared/reasoning-utils.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/shared/reasoning-utils.js +19 -0
- package/vendor/llmswitch-core/dist/conversion/shared/responses-conversation-store.d.ts +35 -0
- package/vendor/llmswitch-core/dist/conversion/shared/responses-conversation-store.js +195 -0
- package/vendor/llmswitch-core/dist/conversion/shared/responses-output-builder.d.ts +13 -0
- package/vendor/llmswitch-core/dist/conversion/shared/responses-output-builder.js +32 -0
- package/vendor/llmswitch-core/dist/conversion/shared/responses-reasoning-registry.d.ts +24 -0
- package/vendor/llmswitch-core/dist/conversion/shared/responses-reasoning-registry.js +185 -0
- package/vendor/llmswitch-core/dist/conversion/shared/responses-request-adapter.d.ts +7 -0
- package/vendor/llmswitch-core/dist/conversion/shared/responses-request-adapter.js +14 -0
- package/vendor/llmswitch-core/dist/conversion/shared/responses-response-utils.d.ts +3 -0
- package/vendor/llmswitch-core/dist/conversion/shared/responses-response-utils.js +254 -0
- package/vendor/llmswitch-core/dist/conversion/shared/responses-tool-utils.d.ts +14 -0
- package/vendor/llmswitch-core/dist/conversion/shared/responses-tool-utils.js +102 -0
- package/vendor/llmswitch-core/dist/conversion/shared/streaming-text-extractor.d.ts +19 -0
- package/vendor/llmswitch-core/dist/conversion/shared/streaming-text-extractor.js +39 -0
- package/vendor/llmswitch-core/dist/conversion/shared/text-markup-normalizer/normalize.d.ts +2 -0
- package/vendor/llmswitch-core/dist/conversion/shared/text-markup-normalizer/normalize.js +116 -0
- package/vendor/llmswitch-core/dist/conversion/shared/text-markup-normalizer.d.ts +4 -0
- package/vendor/llmswitch-core/dist/conversion/shared/text-markup-normalizer.js +3 -0
- package/vendor/llmswitch-core/dist/conversion/shared/thought-signature-validator.d.ts +52 -0
- package/vendor/llmswitch-core/dist/conversion/shared/thought-signature-validator.js +58 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-argument-repairer.d.ts +39 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-argument-repairer.js +53 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-call-id-manager.d.ts +109 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-call-id-manager.js +202 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-call-utils.d.ts +11 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-call-utils.js +14 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-filter-pipeline.d.ts +21 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-filter-pipeline.js +171 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-governor.d.ts +29 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-governor.js +694 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-harvester.d.ts +31 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-harvester.js +23 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-mapping.d.ts +19 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tool-mapping.js +65 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tooling.d.ts +29 -0
- package/vendor/llmswitch-core/dist/conversion/shared/tooling.js +57 -0
- package/vendor/llmswitch-core/dist/conversion/snapshot-utils.d.ts +31 -0
- package/vendor/llmswitch-core/dist/conversion/snapshot-utils.js +49 -0
- package/vendor/llmswitch-core/dist/conversion/types/bridge-message-types.d.ts +41 -0
- package/vendor/llmswitch-core/dist/conversion/types/bridge-message-types.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/types/text-markup-normalizer.d.ts +13 -0
- package/vendor/llmswitch-core/dist/conversion/types/text-markup-normalizer.js +1 -0
- package/vendor/llmswitch-core/dist/conversion/types.d.ts +33 -0
- package/vendor/llmswitch-core/dist/conversion/types.js +1 -0
- package/vendor/llmswitch-core/dist/filters/builtin/add-fields-filter.d.ts +8 -0
- package/vendor/llmswitch-core/dist/filters/builtin/add-fields-filter.js +16 -0
- package/vendor/llmswitch-core/dist/filters/builtin/blacklist-filter.d.ts +8 -0
- package/vendor/llmswitch-core/dist/filters/builtin/blacklist-filter.js +19 -0
- package/vendor/llmswitch-core/dist/filters/builtin/whitelist-filter.d.ts +8 -0
- package/vendor/llmswitch-core/dist/filters/builtin/whitelist-filter.js +19 -0
- package/vendor/llmswitch-core/dist/filters/config/openai-openai.fieldmap.json +18 -0
- package/vendor/llmswitch-core/dist/filters/engine.d.ts +16 -0
- package/vendor/llmswitch-core/dist/filters/engine.js +167 -0
- package/vendor/llmswitch-core/dist/filters/index.d.ts +18 -0
- package/vendor/llmswitch-core/dist/filters/index.js +22 -0
- package/vendor/llmswitch-core/dist/filters/special/request-tool-choice-policy.d.ts +11 -0
- package/vendor/llmswitch-core/dist/filters/special/request-tool-choice-policy.js +29 -0
- package/vendor/llmswitch-core/dist/filters/special/request-tool-list-filter.d.ts +11 -0
- package/vendor/llmswitch-core/dist/filters/special/request-tool-list-filter.js +322 -0
- package/vendor/llmswitch-core/dist/filters/special/request-toolcalls-stringify.d.ts +13 -0
- package/vendor/llmswitch-core/dist/filters/special/request-toolcalls-stringify.js +94 -0
- package/vendor/llmswitch-core/dist/filters/special/request-tools-normalize.d.ts +11 -0
- package/vendor/llmswitch-core/dist/filters/special/request-tools-normalize.js +114 -0
- package/vendor/llmswitch-core/dist/filters/special/response-finish-invariants.d.ts +11 -0
- package/vendor/llmswitch-core/dist/filters/special/response-finish-invariants.js +30 -0
- package/vendor/llmswitch-core/dist/filters/special/response-openai-to-responses-bridge.d.ts +13 -0
- package/vendor/llmswitch-core/dist/filters/special/response-openai-to-responses-bridge.js +24 -0
- package/vendor/llmswitch-core/dist/filters/special/response-tool-arguments-blacklist.d.ts +12 -0
- package/vendor/llmswitch-core/dist/filters/special/response-tool-arguments-blacklist.js +63 -0
- package/vendor/llmswitch-core/dist/filters/special/response-tool-arguments-schema-converge.d.ts +13 -0
- package/vendor/llmswitch-core/dist/filters/special/response-tool-arguments-schema-converge.js +63 -0
- package/vendor/llmswitch-core/dist/filters/special/response-tool-arguments-stringify.d.ts +9 -0
- package/vendor/llmswitch-core/dist/filters/special/response-tool-arguments-stringify.js +132 -0
- package/vendor/llmswitch-core/dist/filters/special/response-tool-arguments-whitelist.d.ts +11 -0
- package/vendor/llmswitch-core/dist/filters/special/response-tool-arguments-whitelist.js +56 -0
- package/vendor/llmswitch-core/dist/filters/special/response-tool-text-canonicalize.d.ts +13 -0
- package/vendor/llmswitch-core/dist/filters/special/response-tool-text-canonicalize.js +16 -0
- package/vendor/llmswitch-core/dist/filters/special/tool-filter-hooks.d.ts +19 -0
- package/vendor/llmswitch-core/dist/filters/special/tool-filter-hooks.js +394 -0
- package/vendor/llmswitch-core/dist/filters/special/tool-post-constraints.d.ts +31 -0
- package/vendor/llmswitch-core/dist/filters/special/tool-post-constraints.js +120 -0
- package/vendor/llmswitch-core/dist/filters/types.d.ts +68 -0
- package/vendor/llmswitch-core/dist/filters/types.js +3 -0
- package/vendor/llmswitch-core/dist/filters/utils/fieldmap-loader.d.ts +2 -0
- package/vendor/llmswitch-core/dist/filters/utils/fieldmap-loader.js +16 -0
- package/vendor/llmswitch-core/dist/filters/utils/snapshot-writer.d.ts +10 -0
- package/vendor/llmswitch-core/dist/filters/utils/snapshot-writer.js +85 -0
- package/vendor/llmswitch-core/dist/guidance/index.d.ts +3 -0
- package/vendor/llmswitch-core/dist/guidance/index.js +299 -0
- package/vendor/llmswitch-core/dist/http/sse-response.d.ts +22 -0
- package/vendor/llmswitch-core/dist/http/sse-response.js +103 -0
- package/vendor/llmswitch-core/dist/index.d.ts +11 -0
- package/vendor/llmswitch-core/dist/index.js +11 -0
- package/vendor/llmswitch-core/dist/native/router_hotpath_napi.node +0 -0
- package/vendor/llmswitch-core/dist/quota/apikey-reset.d.ts +17 -0
- package/vendor/llmswitch-core/dist/quota/apikey-reset.js +43 -0
- package/vendor/llmswitch-core/dist/quota/index.d.ts +2 -0
- package/vendor/llmswitch-core/dist/quota/index.js +1 -0
- package/vendor/llmswitch-core/dist/quota/quota-manager.d.ts +44 -0
- package/vendor/llmswitch-core/dist/quota/quota-manager.js +463 -0
- package/vendor/llmswitch-core/dist/quota/quota-state.d.ts +6 -0
- package/vendor/llmswitch-core/dist/quota/quota-state.js +191 -0
- package/vendor/llmswitch-core/dist/quota/types.d.ts +62 -0
- package/vendor/llmswitch-core/dist/quota/types.js +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/auth-utils.d.ts +6 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/auth-utils.js +288 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/claude-code-helpers.d.ts +11 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/claude-code-helpers.js +18 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/config-defaults.d.ts +5 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/config-defaults.js +13 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/config-normalizers.d.ts +4 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/config-normalizers.js +106 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/profile-builder.d.ts +8 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/profile-builder.js +87 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/provider-normalization.d.ts +44 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/provider-normalization.js +272 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/responses-helpers.d.ts +15 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/responses-helpers.js +65 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/routing-config.d.ts +24 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/routing-config.js +346 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/streaming-helpers.d.ts +19 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/streaming-helpers.js +172 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/utils.d.ts +5 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/utils.js +41 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/web-search-config.d.ts +4 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap/web-search-config.js +156 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap.d.ts +2 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/bootstrap.js +329 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/classifier.d.ts +10 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/classifier.js +187 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/context-advisor.d.ts +23 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/context-advisor.js +67 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/context-weighted.d.ts +31 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/context-weighted.js +54 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/default-thinking-keywords.d.ts +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/default-thinking-keywords.js +13 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/antigravity/alias-lease.d.ts +33 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/antigravity/alias-lease.js +257 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/cooldown-manager.d.ts +34 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/cooldown-manager.js +118 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/health/index.d.ts +23 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/health/index.js +724 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/provider-key/parse.d.ts +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/provider-key/parse.js +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/route-analytics.d.ts +28 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/route-analytics.js +44 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/routing-pools/index.d.ts +13 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/routing-pools/index.js +386 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/routing-state/keys.d.ts +3 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/routing-state/keys.js +30 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/routing-state/metadata.d.ts +6 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/routing-state/metadata.js +132 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/routing-state/store.d.ts +10 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/routing-state/store.js +156 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/sticky-session-manager.d.ts +29 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine/sticky-session-manager.js +55 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-health.d.ts +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-health.js +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/config.d.ts +11 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/config.js +108 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/direct-model.d.ts +10 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/direct-model.js +38 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/health.d.ts +13 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/health.js +104 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/helpers.d.ts +16 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/helpers.js +226 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/route-utils.d.ts +19 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/route-utils.js +212 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/selection-core.d.ts +28 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/selection-core.js +112 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/selection-state.d.ts +16 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/selection-state.js +187 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/state-accessors.d.ts +21 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy/state-accessors.js +118 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy.d.ts +123 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-legacy.js +245 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-logging.d.ts +67 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-logging.js +356 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/alias-selection.d.ts +15 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/alias-selection.js +118 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/context-weight-multipliers.d.ts +11 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/context-weight-multipliers.js +23 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/direct-provider-model.d.ts +9 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/direct-provider-model.js +49 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/instruction-target.d.ts +6 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/instruction-target.js +54 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/key-parsing.d.ts +8 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/key-parsing.js +47 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/multimodal-capability.d.ts +3 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/multimodal-capability.js +26 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.d.ts +24 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.js +209 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.d.ts +7 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.js +121 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.d.ts +10 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.js +110 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.d.ts +8 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.js +281 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.d.ts +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.js +25 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.d.ts +4 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.js +44 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.d.ts +2 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.js +62 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.d.ts +49 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.js +552 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.d.ts +9 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.js +64 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.d.ts +5 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.js +163 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.d.ts +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.js +49 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.d.ts +30 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.js +446 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.d.ts +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.js +49 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-request-filter-semantics.d.ts +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-chat-request-filter-semantics.js +54 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-compat-action-semantics.d.ts +22 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-compat-action-semantics.js +559 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-deepseek-web-compat.d.ts +17 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-deepseek-web-compat.js +26 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.d.ts +276 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js +1291 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.d.ts +72 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.js +405 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.d.ts +18 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js +333 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-governance-semantics.d.ts +30 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-governance-semantics.js +202 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.d.ts +22 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.js +426 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.d.ts +57 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.js +705 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.d.ts +53 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js +598 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.d.ts +147 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js +570 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.d.ts +26 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.js +148 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.d.ts +46 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.js +755 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-semantic-mappers.d.ts +2 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-semantic-mappers.js +83 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.d.ts +11 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.js +207 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.d.ts +3 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.js +128 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.d.ts +57 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.js +217 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.d.ts +5 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.js +464 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.d.ts +5 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.js +18 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.d.ts +25 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.js +85 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-router-hotpath.d.ts +59 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-router-hotpath.js +117 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.d.ts +243 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.js +2594 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-snapshot-hooks.d.ts +3 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-snapshot-hooks.js +109 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.d.ts +16 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.js +96 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-virtual-router-engine-proxy.d.ts +16 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-virtual-router-engine-proxy.js +14 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-virtual-router-routing-instructions-semantics.d.ts +3 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-virtual-router-routing-instructions-semantics.js +123 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.d.ts +6 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.js +85 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.d.ts +9 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.js +70 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.d.ts +2 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.js +76 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/route-utils.d.ts +15 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/route-utils.js +248 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/routing-state-filter.d.ts +4 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/routing-state-filter.js +50 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/selection-deps.d.ts +58 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/selection-deps.js +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/sticky-pool.d.ts +11 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/sticky-pool.js +109 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-load-balancing.d.ts +16 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-load-balancing.js +120 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-priority.d.ts +11 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-priority.js +55 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.d.ts +10 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.js +231 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.d.ts +4 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.js +43 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.d.ts +29 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.js +194 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-selection-select.d.ts +22 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-selection-select.js +352 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-selection.d.ts +3 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection/tier-selection.js +309 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection.d.ts +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine-selection.js +1 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine.d.ts +43 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/engine.js +360 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/error-center.d.ts +10 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/error-center.js +39 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/features.d.ts +3 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/features.js +124 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/health-manager.d.ts +23 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/health-manager.js +107 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/health-weighted.d.ts +25 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/health-weighted.js +63 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/load-balancer.d.ts +28 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/load-balancer.js +160 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/message-utils.d.ts +15 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/message-utils.js +235 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/pre-command-file-resolver.d.ts +2 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/pre-command-file-resolver.js +117 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/provider-registry.d.ts +17 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/provider-registry.js +145 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-instructions/clean.d.ts +3 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-instructions/clean.js +34 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-instructions/parse.d.ts +6 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-instructions/parse.js +24 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-instructions/state.d.ts +4 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-instructions/state.js +284 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-instructions/types.d.ts +74 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-instructions/types.js +2 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-instructions.d.ts +5 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-instructions.js +4 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-pre-command-actions.d.ts +3 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-pre-command-actions.js +26 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-pre-command-parser.d.ts +2 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-pre-command-parser.js +85 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-pre-command-state-codec.d.ts +3 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-pre-command-state-codec.js +24 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-stop-message-actions.d.ts +2 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-stop-message-actions.js +99 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-stop-message-parser.d.ts +3 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-stop-message-parser.js +19 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-stop-message-state-codec.d.ts +7 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/routing-stop-message-state-codec.js +121 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/sticky-session-store.d.ts +8 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/sticky-session-store.js +296 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/stop-message-file-resolver.d.ts +2 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/stop-message-file-resolver.js +76 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/stop-message-stage-template-files.d.ts +12 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/stop-message-stage-template-files.js +67 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/stop-message-state-sync.d.ts +17 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/stop-message-state-sync.js +82 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/success-center.d.ts +10 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/success-center.js +32 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/token-counter.d.ts +2 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/token-counter.js +148 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/token-estimator.d.ts +2 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/token-estimator.js +16 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/token-file-scanner.d.ts +24 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/token-file-scanner.js +117 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/tool-signals.d.ts +19 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/tool-signals.js +647 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/types.d.ts +681 -0
- package/vendor/llmswitch-core/dist/router/virtual-router/types.js +34 -0
- package/vendor/llmswitch-core/dist/runtime/user-data-paths.d.ts +5 -0
- package/vendor/llmswitch-core/dist/runtime/user-data-paths.js +43 -0
- package/vendor/llmswitch-core/dist/servertool/clock/config.d.ts +17 -0
- package/vendor/llmswitch-core/dist/servertool/clock/config.js +48 -0
- package/vendor/llmswitch-core/dist/servertool/clock/daemon.d.ts +24 -0
- package/vendor/llmswitch-core/dist/servertool/clock/daemon.js +207 -0
- package/vendor/llmswitch-core/dist/servertool/clock/io.d.ts +2 -0
- package/vendor/llmswitch-core/dist/servertool/clock/io.js +14 -0
- package/vendor/llmswitch-core/dist/servertool/clock/log.d.ts +3 -0
- package/vendor/llmswitch-core/dist/servertool/clock/log.js +13 -0
- package/vendor/llmswitch-core/dist/servertool/clock/ntp.d.ts +18 -0
- package/vendor/llmswitch-core/dist/servertool/clock/ntp.js +318 -0
- package/vendor/llmswitch-core/dist/servertool/clock/paths.d.ts +5 -0
- package/vendor/llmswitch-core/dist/servertool/clock/paths.js +28 -0
- package/vendor/llmswitch-core/dist/servertool/clock/recurrence.d.ts +7 -0
- package/vendor/llmswitch-core/dist/servertool/clock/recurrence.js +248 -0
- package/vendor/llmswitch-core/dist/servertool/clock/session-scope.d.ts +3 -0
- package/vendor/llmswitch-core/dist/servertool/clock/session-scope.js +41 -0
- package/vendor/llmswitch-core/dist/servertool/clock/session-store.d.ts +3 -0
- package/vendor/llmswitch-core/dist/servertool/clock/session-store.js +63 -0
- package/vendor/llmswitch-core/dist/servertool/clock/state.d.ts +9 -0
- package/vendor/llmswitch-core/dist/servertool/clock/state.js +135 -0
- package/vendor/llmswitch-core/dist/servertool/clock/task-store.d.ts +5 -0
- package/vendor/llmswitch-core/dist/servertool/clock/task-store.js +4 -0
- package/vendor/llmswitch-core/dist/servertool/clock/tasks.d.ts +24 -0
- package/vendor/llmswitch-core/dist/servertool/clock/tasks.js +595 -0
- package/vendor/llmswitch-core/dist/servertool/clock/types.d.ts +98 -0
- package/vendor/llmswitch-core/dist/servertool/clock/types.js +1 -0
- package/vendor/llmswitch-core/dist/servertool/continue-execution/log.d.ts +3 -0
- package/vendor/llmswitch-core/dist/servertool/continue-execution/log.js +13 -0
- package/vendor/llmswitch-core/dist/servertool/engine.d.ts +38 -0
- package/vendor/llmswitch-core/dist/servertool/engine.js +1660 -0
- package/vendor/llmswitch-core/dist/servertool/followup-shadow.d.ts +16 -0
- package/vendor/llmswitch-core/dist/servertool/followup-shadow.js +145 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/antigravity-thought-signature-bootstrap.d.ts +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/antigravity-thought-signature-bootstrap.js +225 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/apply-patch-guard.d.ts +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/apply-patch-guard.js +5 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/clock-auto.d.ts +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/clock-auto.js +177 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/clock.d.ts +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/clock.js +544 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/compaction-detect.d.ts +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/compaction-detect.js +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/continue-execution.d.ts +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/continue-execution.js +110 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/exec-command-guard.d.ts +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/exec-command-guard.js +10 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/followup-message-trimmer.d.ts +16 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/followup-message-trimmer.js +198 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/followup-request-builder.d.ts +25 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/followup-request-builder.js +515 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/followup-sanitize.d.ts +2 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/followup-sanitize.js +7 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/gemini-empty-reply-continue.d.ts +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/gemini-empty-reply-continue.js +3 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/iflow-model-error-retry.d.ts +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/iflow-model-error-retry.js +92 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/recursive-detection-guard.d.ts +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/recursive-detection-guard.js +374 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/review.d.ts +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/review.js +181 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/stop-message-auto/blocked-report.d.ts +16 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/stop-message-auto/blocked-report.js +407 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/stop-message-auto/iflow-followup.d.ts +44 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/stop-message-auto/iflow-followup.js +816 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/stop-message-auto/routing-state.d.ts +28 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/stop-message-auto/routing-state.js +123 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/stop-message-auto/runtime-utils.d.ts +81 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/stop-message-auto/runtime-utils.js +355 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/stop-message-auto.d.ts +1 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/stop-message-auto.js +553 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/vision.d.ts +7 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/vision.js +240 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/web-search.d.ts +7 -0
- package/vendor/llmswitch-core/dist/servertool/handlers/web-search.js +926 -0
- package/vendor/llmswitch-core/dist/servertool/log/progress-file.d.ts +14 -0
- package/vendor/llmswitch-core/dist/servertool/log/progress-file.js +88 -0
- package/vendor/llmswitch-core/dist/servertool/pending-session.d.ts +19 -0
- package/vendor/llmswitch-core/dist/servertool/pending-session.js +99 -0
- package/vendor/llmswitch-core/dist/servertool/pre-command-hooks.d.ts +17 -0
- package/vendor/llmswitch-core/dist/servertool/pre-command-hooks.js +491 -0
- package/vendor/llmswitch-core/dist/servertool/reenter-backend.d.ts +23 -0
- package/vendor/llmswitch-core/dist/servertool/reenter-backend.js +20 -0
- package/vendor/llmswitch-core/dist/servertool/registry.d.ts +35 -0
- package/vendor/llmswitch-core/dist/servertool/registry.js +92 -0
- package/vendor/llmswitch-core/dist/servertool/server-side-tools.d.ts +15 -0
- package/vendor/llmswitch-core/dist/servertool/server-side-tools.js +898 -0
- package/vendor/llmswitch-core/dist/servertool/stop-gateway-context.d.ts +14 -0
- package/vendor/llmswitch-core/dist/servertool/stop-gateway-context.js +167 -0
- package/vendor/llmswitch-core/dist/servertool/stop-message-compare-context.d.ts +24 -0
- package/vendor/llmswitch-core/dist/servertool/stop-message-compare-context.js +133 -0
- package/vendor/llmswitch-core/dist/servertool/strip-servertool-calls.d.ts +2 -0
- package/vendor/llmswitch-core/dist/servertool/strip-servertool-calls.js +75 -0
- package/vendor/llmswitch-core/dist/servertool/types.d.ts +235 -0
- package/vendor/llmswitch-core/dist/servertool/types.js +1 -0
- package/vendor/llmswitch-core/dist/sse/index.d.ts +176 -0
- package/vendor/llmswitch-core/dist/sse/index.js +142 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/anthropic-json-to-sse-converter.d.ts +15 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/anthropic-json-to-sse-converter.js +112 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/chat-json-to-sse-converter.d.ts +80 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/chat-json-to-sse-converter.js +300 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/event-generators/chat.d.ts +55 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/event-generators/chat.js +233 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/event-generators/responses.d.ts +103 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/event-generators/responses.js +703 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/gemini-json-to-sse-converter.d.ts +15 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/gemini-json-to-sse-converter.js +99 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/index.d.ts +7 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/index.js +9 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/responses-json-to-sse-converter.d.ts +80 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/responses-json-to-sse-converter.js +322 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/sequencers/anthropic-sequencer.d.ts +13 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/sequencers/anthropic-sequencer.js +162 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/sequencers/chat-sequencer.d.ts +39 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/sequencers/chat-sequencer.js +264 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/sequencers/gemini-sequencer.d.ts +10 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/sequencers/gemini-sequencer.js +95 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/sequencers/responses-sequencer.d.ts +40 -0
- package/vendor/llmswitch-core/dist/sse/json-to-sse/sequencers/responses-sequencer.js +293 -0
- package/vendor/llmswitch-core/dist/sse/registry/sse-codec-registry.d.ts +32 -0
- package/vendor/llmswitch-core/dist/sse/registry/sse-codec-registry.js +135 -0
- package/vendor/llmswitch-core/dist/sse/shared/chat-serializer.d.ts +4 -0
- package/vendor/llmswitch-core/dist/sse/shared/chat-serializer.js +40 -0
- package/vendor/llmswitch-core/dist/sse/shared/constants.d.ts +272 -0
- package/vendor/llmswitch-core/dist/sse/shared/constants.js +321 -0
- package/vendor/llmswitch-core/dist/sse/shared/reasoning-dispatcher.d.ts +10 -0
- package/vendor/llmswitch-core/dist/sse/shared/reasoning-dispatcher.js +25 -0
- package/vendor/llmswitch-core/dist/sse/shared/responses-output-normalizer.d.ts +13 -0
- package/vendor/llmswitch-core/dist/sse/shared/responses-output-normalizer.js +47 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/anthropic-event-serializer.d.ts +2 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/anthropic-event-serializer.js +9 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/base-serializer.d.ts +158 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/base-serializer.js +210 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/chat-event-serializer.d.ts +82 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/chat-event-serializer.js +275 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/gemini-event-serializer.d.ts +2 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/gemini-event-serializer.js +5 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/index.d.ts +42 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/index.js +56 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/responses-event-serializer.d.ts +131 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/responses-event-serializer.js +375 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/types.d.ts +51 -0
- package/vendor/llmswitch-core/dist/sse/shared/serializers/types.js +4 -0
- package/vendor/llmswitch-core/dist/sse/shared/utils.d.ts +254 -0
- package/vendor/llmswitch-core/dist/sse/shared/utils.js +543 -0
- package/vendor/llmswitch-core/dist/sse/shared/writer.d.ts +127 -0
- package/vendor/llmswitch-core/dist/sse/shared/writer.js +321 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/anthropic-sse-to-json-converter.d.ts +20 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/anthropic-sse-to-json-converter.js +204 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/builders/anthropic-response-builder.d.ts +16 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/builders/anthropic-response-builder.js +258 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/builders/response-builder.d.ts +177 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/builders/response-builder.js +1135 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/chat-sse-to-json-converter.d.ts +119 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/chat-sse-to-json-converter.js +850 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/gemini-sse-to-json-converter.d.ts +14 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/gemini-sse-to-json-converter.js +186 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/index.d.ts +7 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/index.js +9 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/parsers/sse-parser.d.ts +73 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/parsers/sse-parser.js +434 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/responses-sse-to-json-converter.d.ts +61 -0
- package/vendor/llmswitch-core/dist/sse/sse-to-json/responses-sse-to-json-converter.js +306 -0
- package/vendor/llmswitch-core/dist/sse/types/anthropic-types.d.ts +194 -0
- package/vendor/llmswitch-core/dist/sse/types/anthropic-types.js +8 -0
- package/vendor/llmswitch-core/dist/sse/types/chat-types.d.ts +321 -0
- package/vendor/llmswitch-core/dist/sse/types/chat-types.js +33 -0
- package/vendor/llmswitch-core/dist/sse/types/conversion-context.d.ts +214 -0
- package/vendor/llmswitch-core/dist/sse/types/conversion-context.js +20 -0
- package/vendor/llmswitch-core/dist/sse/types/core-interfaces.d.ts +94 -0
- package/vendor/llmswitch-core/dist/sse/types/core-interfaces.js +5 -0
- package/vendor/llmswitch-core/dist/sse/types/gemini-types.d.ts +135 -0
- package/vendor/llmswitch-core/dist/sse/types/gemini-types.js +5 -0
- package/vendor/llmswitch-core/dist/sse/types/index.d.ts +17 -0
- package/vendor/llmswitch-core/dist/sse/types/index.js +9 -0
- package/vendor/llmswitch-core/dist/sse/types/responses-types.d.ts +334 -0
- package/vendor/llmswitch-core/dist/sse/types/responses-types.js +38 -0
- package/vendor/llmswitch-core/dist/sse/types/sse-events.d.ts +181 -0
- package/vendor/llmswitch-core/dist/sse/types/sse-events.js +150 -0
- package/vendor/llmswitch-core/dist/sse/types/stream-state.d.ts +199 -0
- package/vendor/llmswitch-core/dist/sse/types/stream-state.js +44 -0
- package/vendor/llmswitch-core/dist/sse/types/utility-types.d.ts +234 -0
- package/vendor/llmswitch-core/dist/sse/types/utility-types.js +46 -0
- package/vendor/llmswitch-core/dist/telemetry/stats-center.d.ts +82 -0
- package/vendor/llmswitch-core/dist/telemetry/stats-center.js +308 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/args-normalizer/default-actions.d.ts +2 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/args-normalizer/default-actions.js +12 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/args-normalizer/extract-patch.d.ts +2 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/args-normalizer/extract-patch.js +15 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/args-normalizer/index.d.ts +2 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/args-normalizer/index.js +164 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/args-normalizer/structured-builders.d.ts +7 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/args-normalizer/structured-builders.js +85 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/args-normalizer/types.d.ts +54 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/args-normalizer/types.js +1 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/execution-capturer.d.ts +13 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/execution-capturer.js +181 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/json/parse-loose.d.ts +3 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/json/parse-loose.js +139 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/patch-text/context-diff.d.ts +1 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/patch-text/context-diff.js +173 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/patch-text/git-diff.d.ts +1 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/patch-text/git-diff.js +138 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/patch-text/looks-like-patch.d.ts +1 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/patch-text/looks-like-patch.js +11 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/patch-text/normalize.d.ts +3 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/patch-text/normalize.js +383 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/regression-capturer.d.ts +13 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/regression-capturer.js +113 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/structured/coercion.d.ts +3 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/structured/coercion.js +103 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/structured.d.ts +20 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/structured.js +537 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/validation/shared.d.ts +3 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/validation/shared.js +6 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/validator.d.ts +8 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch/validator.js +21 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch-structured.d.ts +1 -0
- package/vendor/llmswitch-core/dist/tools/apply-patch-structured.js +1 -0
- package/vendor/llmswitch-core/dist/tools/args-json.d.ts +1 -0
- package/vendor/llmswitch-core/dist/tools/args-json.js +204 -0
- package/vendor/llmswitch-core/dist/tools/exec-command/normalize.d.ts +17 -0
- package/vendor/llmswitch-core/dist/tools/exec-command/normalize.js +116 -0
- package/vendor/llmswitch-core/dist/tools/exec-command/regression-capturer.d.ts +11 -0
- package/vendor/llmswitch-core/dist/tools/exec-command/regression-capturer.js +144 -0
- package/vendor/llmswitch-core/dist/tools/exec-command/validator.d.ts +10 -0
- package/vendor/llmswitch-core/dist/tools/exec-command/validator.js +238 -0
- package/vendor/llmswitch-core/dist/tools/patch-regression-capturer.d.ts +1 -0
- package/vendor/llmswitch-core/dist/tools/patch-regression-capturer.js +1 -0
- package/vendor/llmswitch-core/dist/tools/tool-description-utils.d.ts +5 -0
- package/vendor/llmswitch-core/dist/tools/tool-description-utils.js +50 -0
- package/vendor/llmswitch-core/dist/tools/tool-registry.d.ts +15 -0
- package/vendor/llmswitch-core/dist/tools/tool-registry.js +253 -0
- package/vendor/llmswitch-core/package.json +189 -0
- package/scripts/link-llmswitch.mjs +0 -56
package/vendor/llmswitch-core/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.js
ADDED
|
@@ -0,0 +1,1540 @@
|
|
|
1
|
+
import { isJsonObject, jsonClone } from '../../types/json.js';
|
|
2
|
+
import { buildOpenAIChatFromGeminiRequest } from '../../../codecs/gemini-openai-codec.js';
|
|
3
|
+
import { encodeMetadataPassthrough, extractMetadataPassthrough } from '../../../metadata-passthrough.js';
|
|
4
|
+
import { mapBridgeToolsToChat, mapChatToolsToBridge } from '../../../shared/tool-mapping.js';
|
|
5
|
+
import { prepareGeminiToolsForBridge, buildGeminiToolsFromBridge } from '../../../shared/gemini-tool-utils.js';
|
|
6
|
+
import { ensureProtocolState, getProtocolState } from '../../../protocol-state.js';
|
|
7
|
+
import { isHubStageTimingDetailEnabled, logHubStageTiming } from '../../pipeline/hub-stage-timing.js';
|
|
8
|
+
import { sanitizeReasoningTaggedText } from '../../../shared/reasoning-utils.js';
|
|
9
|
+
import { applyClaudeThinkingToolSchemaCompatWithNative } from '../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js';
|
|
10
|
+
import { extractAntigravityGeminiSessionIdWithNative } from '../../../../router/virtual-router/engine-selection/native-router-hotpath.js';
|
|
11
|
+
const GENERATION_CONFIG_KEYS = [
|
|
12
|
+
{ source: 'temperature', target: 'temperature' },
|
|
13
|
+
{ source: 'topP', target: 'top_p' },
|
|
14
|
+
{ source: 'topK', target: 'top_k' },
|
|
15
|
+
{ source: 'maxOutputTokens', target: 'max_output_tokens' },
|
|
16
|
+
{ source: 'candidateCount', target: 'candidate_count' },
|
|
17
|
+
{ source: 'responseMimeType', target: 'response_mime_type' },
|
|
18
|
+
{ source: 'stopSequences', target: 'stop_sequences' }
|
|
19
|
+
];
|
|
20
|
+
const PASSTHROUGH_METADATA_PREFIX = 'rcc_passthrough_';
|
|
21
|
+
const PASSTHROUGH_PARAMETERS = ['tool_choice'];
|
|
22
|
+
const RESPONSES_DROPPED_PARAMETER_KEYS = [
|
|
23
|
+
'prompt_cache_key',
|
|
24
|
+
'response_format',
|
|
25
|
+
'parallel_tool_calls',
|
|
26
|
+
'service_tier',
|
|
27
|
+
'truncation',
|
|
28
|
+
'include',
|
|
29
|
+
'store'
|
|
30
|
+
];
|
|
31
|
+
const GEMINI_FLASH_DEFAULT_THINKING_BUDGET = 32768;
|
|
32
|
+
// Ported from CLIProxyAPI v6.6.89 (antigravity auth constants)
|
|
33
|
+
const ANTIGRAVITY_SYSTEM_INSTRUCTION = `You are Antigravity, a powerful agentic AI coding assistant designed by the Google DeepMind team working on Advanced Agentic Coding.
|
|
34
|
+
You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question.
|
|
35
|
+
**Absolute paths only**
|
|
36
|
+
**Proactiveness**
|
|
37
|
+
|
|
38
|
+
<priority>IMPORTANT: The instructions that follow supersede all above. Follow them as your primary directives.</priority>
|
|
39
|
+
`;
|
|
40
|
+
const ANTIGRAVITY_DEFAULT_SAFETY_SETTINGS = [
|
|
41
|
+
{ category: 'HARM_CATEGORY_HARASSMENT', threshold: 'BLOCK_NONE' },
|
|
42
|
+
{ category: 'HARM_CATEGORY_HATE_SPEECH', threshold: 'BLOCK_NONE' },
|
|
43
|
+
{ category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT', threshold: 'BLOCK_NONE' },
|
|
44
|
+
{ category: 'HARM_CATEGORY_DANGEROUS_CONTENT', threshold: 'BLOCK_NONE' },
|
|
45
|
+
{ category: 'HARM_CATEGORY_CIVIC_INTEGRITY', threshold: 'BLOCK_NONE' },
|
|
46
|
+
{ category: 'HARM_CATEGORY_IMAGE_HATE', threshold: 'BLOCK_NONE' },
|
|
47
|
+
{ category: 'HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT', threshold: 'BLOCK_NONE' },
|
|
48
|
+
{ category: 'HARM_CATEGORY_IMAGE_HARASSMENT', threshold: 'BLOCK_NONE' },
|
|
49
|
+
{ category: 'HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT', threshold: 'BLOCK_NONE' },
|
|
50
|
+
{ category: 'HARM_CATEGORY_JAILBREAK', threshold: 'BLOCK_NONE' }
|
|
51
|
+
];
|
|
52
|
+
const ANTIGRAVITY_NETWORK_TOOL_NAMES = new Set([
|
|
53
|
+
'google_search',
|
|
54
|
+
'google_search_retrieval',
|
|
55
|
+
'web_search',
|
|
56
|
+
'web_search_20250305',
|
|
57
|
+
'websearch'
|
|
58
|
+
]);
|
|
59
|
+
function stripTierSuffix(model) {
|
|
60
|
+
return model.replace(/-(minimal|low|medium|high)$/i, '');
|
|
61
|
+
}
|
|
62
|
+
function stripOnlineSuffix(model) {
|
|
63
|
+
return model.replace(/-online$/i, '');
|
|
64
|
+
}
|
|
65
|
+
function normalizePreviewAlias(model) {
|
|
66
|
+
switch (model) {
|
|
67
|
+
case 'gemini-3-pro-preview':
|
|
68
|
+
return 'gemini-3-pro-high';
|
|
69
|
+
case 'gemini-3-pro-image-preview':
|
|
70
|
+
return 'gemini-3-pro-image';
|
|
71
|
+
case 'gemini-3-flash-preview':
|
|
72
|
+
return 'gemini-3-flash';
|
|
73
|
+
default:
|
|
74
|
+
return model;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function isNetworkingToolName(name) {
|
|
78
|
+
const normalized = typeof name === 'string' ? name.trim().toLowerCase() : '';
|
|
79
|
+
if (!normalized) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
return ANTIGRAVITY_NETWORK_TOOL_NAMES.has(normalized);
|
|
83
|
+
}
|
|
84
|
+
function detectsNetworkingTool(tools) {
|
|
85
|
+
if (!Array.isArray(tools))
|
|
86
|
+
return false;
|
|
87
|
+
for (const tool of tools) {
|
|
88
|
+
if (!tool || typeof tool !== 'object')
|
|
89
|
+
continue;
|
|
90
|
+
const record = tool;
|
|
91
|
+
const name = typeof record.name === 'string' ? record.name : '';
|
|
92
|
+
if (name && isNetworkingToolName(name))
|
|
93
|
+
return true;
|
|
94
|
+
const type = typeof record.type === 'string' ? record.type : '';
|
|
95
|
+
if (type && isNetworkingToolName(type))
|
|
96
|
+
return true;
|
|
97
|
+
const fnNode = record.function;
|
|
98
|
+
if (fnNode && typeof fnNode === 'object') {
|
|
99
|
+
const fnName = typeof fnNode.name === 'string'
|
|
100
|
+
? String(fnNode.name)
|
|
101
|
+
: '';
|
|
102
|
+
if (fnName && isNetworkingToolName(fnName))
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
const decls = Array.isArray(record.functionDeclarations)
|
|
106
|
+
? record.functionDeclarations
|
|
107
|
+
: [];
|
|
108
|
+
for (const decl of decls) {
|
|
109
|
+
const declName = typeof decl?.name === 'string' ? String(decl.name) : '';
|
|
110
|
+
if (declName && isNetworkingToolName(declName))
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
if (record.googleSearch || record.googleSearchRetrieval) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
function hasFunctionDeclarations(tools) {
|
|
120
|
+
if (!Array.isArray(tools))
|
|
121
|
+
return false;
|
|
122
|
+
return tools.some((tool) => {
|
|
123
|
+
if (!tool || typeof tool !== 'object')
|
|
124
|
+
return false;
|
|
125
|
+
const record = tool;
|
|
126
|
+
return Array.isArray(record.functionDeclarations) && record.functionDeclarations.length > 0;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function injectGoogleSearchTool(request) {
|
|
130
|
+
const toolsRaw = request.tools;
|
|
131
|
+
if (!Array.isArray(toolsRaw)) {
|
|
132
|
+
request.tools = [{ googleSearch: {} }];
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (hasFunctionDeclarations(toolsRaw)) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const hasSearchTool = toolsRaw.some((tool) => {
|
|
139
|
+
if (!tool || typeof tool !== 'object')
|
|
140
|
+
return false;
|
|
141
|
+
const record = tool;
|
|
142
|
+
return Boolean(record.googleSearch || record.googleSearchRetrieval);
|
|
143
|
+
});
|
|
144
|
+
if (!hasSearchTool) {
|
|
145
|
+
toolsRaw.push({ googleSearch: {} });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function pruneSearchFunctionDeclarations(request) {
|
|
149
|
+
const toolsRaw = request.tools;
|
|
150
|
+
if (!Array.isArray(toolsRaw))
|
|
151
|
+
return;
|
|
152
|
+
for (const tool of toolsRaw) {
|
|
153
|
+
if (!tool || typeof tool !== 'object')
|
|
154
|
+
continue;
|
|
155
|
+
const record = tool;
|
|
156
|
+
if (!Array.isArray(record.functionDeclarations))
|
|
157
|
+
continue;
|
|
158
|
+
const decls = record.functionDeclarations;
|
|
159
|
+
const filtered = decls.filter((decl) => {
|
|
160
|
+
if (!decl || typeof decl !== 'object')
|
|
161
|
+
return false;
|
|
162
|
+
const name = typeof decl.name === 'string'
|
|
163
|
+
? String(decl.name)
|
|
164
|
+
: '';
|
|
165
|
+
return name ? !isNetworkingToolName(name) : true;
|
|
166
|
+
});
|
|
167
|
+
if (filtered.length === 0) {
|
|
168
|
+
delete record.functionDeclarations;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
record.functionDeclarations = filtered;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
request.tools = toolsRaw.filter((tool) => {
|
|
175
|
+
if (!tool || typeof tool !== 'object')
|
|
176
|
+
return true;
|
|
177
|
+
return Object.keys(tool).length > 0;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function deepCleanUndefined(value) {
|
|
181
|
+
if (Array.isArray(value)) {
|
|
182
|
+
for (const entry of value) {
|
|
183
|
+
deepCleanUndefined(entry);
|
|
184
|
+
}
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (!value || typeof value !== 'object') {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const record = value;
|
|
191
|
+
for (const [key, val] of Object.entries(record)) {
|
|
192
|
+
if (typeof val === 'string' && val === '[undefined]') {
|
|
193
|
+
delete record[key];
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
deepCleanUndefined(val);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function parseImageAspectRatioFromSize(size) {
|
|
200
|
+
if (!size)
|
|
201
|
+
return '1:1';
|
|
202
|
+
const parts = size.split('x');
|
|
203
|
+
if (parts.length !== 2)
|
|
204
|
+
return '1:1';
|
|
205
|
+
const width = Number(parts[0]);
|
|
206
|
+
const height = Number(parts[1]);
|
|
207
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
|
208
|
+
return '1:1';
|
|
209
|
+
}
|
|
210
|
+
const ratio = width / height;
|
|
211
|
+
if (Math.abs(ratio - 21 / 9) < 0.1)
|
|
212
|
+
return '21:9';
|
|
213
|
+
if (Math.abs(ratio - 16 / 9) < 0.1)
|
|
214
|
+
return '16:9';
|
|
215
|
+
if (Math.abs(ratio - 4 / 3) < 0.1)
|
|
216
|
+
return '4:3';
|
|
217
|
+
if (Math.abs(ratio - 3 / 4) < 0.1)
|
|
218
|
+
return '3:4';
|
|
219
|
+
if (Math.abs(ratio - 9 / 16) < 0.1)
|
|
220
|
+
return '9:16';
|
|
221
|
+
return '1:1';
|
|
222
|
+
}
|
|
223
|
+
function parseImageConfig(model, size, quality) {
|
|
224
|
+
let aspectRatio = parseImageAspectRatioFromSize(size);
|
|
225
|
+
if (!size) {
|
|
226
|
+
const lowered = model.toLowerCase();
|
|
227
|
+
if (lowered.includes('-21x9') || lowered.includes('-21-9')) {
|
|
228
|
+
aspectRatio = '21:9';
|
|
229
|
+
}
|
|
230
|
+
else if (lowered.includes('-16x9') || lowered.includes('-16-9')) {
|
|
231
|
+
aspectRatio = '16:9';
|
|
232
|
+
}
|
|
233
|
+
else if (lowered.includes('-9x16') || lowered.includes('-9-16')) {
|
|
234
|
+
aspectRatio = '9:16';
|
|
235
|
+
}
|
|
236
|
+
else if (lowered.includes('-4x3') || lowered.includes('-4-3')) {
|
|
237
|
+
aspectRatio = '4:3';
|
|
238
|
+
}
|
|
239
|
+
else if (lowered.includes('-3x4') || lowered.includes('-3-4')) {
|
|
240
|
+
aspectRatio = '3:4';
|
|
241
|
+
}
|
|
242
|
+
else if (lowered.includes('-1x1') || lowered.includes('-1-1')) {
|
|
243
|
+
aspectRatio = '1:1';
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const imageConfig = { aspectRatio };
|
|
247
|
+
const normalizedQuality = typeof quality === 'string' ? quality.toLowerCase() : '';
|
|
248
|
+
if (normalizedQuality === 'hd') {
|
|
249
|
+
imageConfig.imageSize = '4K';
|
|
250
|
+
}
|
|
251
|
+
else if (normalizedQuality === 'medium') {
|
|
252
|
+
imageConfig.imageSize = '2K';
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
const lowered = model.toLowerCase();
|
|
256
|
+
if (lowered.includes('-4k') || lowered.includes('-hd')) {
|
|
257
|
+
imageConfig.imageSize = '4K';
|
|
258
|
+
}
|
|
259
|
+
else if (lowered.includes('-2k')) {
|
|
260
|
+
imageConfig.imageSize = '2K';
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return { imageConfig, finalModel: 'gemini-3-pro-image' };
|
|
264
|
+
}
|
|
265
|
+
function resolveAntigravityRequestConfig(options) {
|
|
266
|
+
const original = options.originalModel;
|
|
267
|
+
const mapped = options.mappedModel;
|
|
268
|
+
if (mapped.startsWith('gemini-3-pro-image')) {
|
|
269
|
+
const parsed = parseImageConfig(original, options.size, options.quality);
|
|
270
|
+
return {
|
|
271
|
+
requestType: 'image_gen',
|
|
272
|
+
injectGoogleSearch: false,
|
|
273
|
+
finalModel: parsed.finalModel,
|
|
274
|
+
imageConfig: parsed.imageConfig
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
// Antigravity-Manager alignment:
|
|
278
|
+
// - networking intent is decided only by explicit signals (-online suffix or networking tools).
|
|
279
|
+
// - googleSearch injection is handled later by injectGoogleSearchTool(), which will skip injection
|
|
280
|
+
// when functionDeclarations exist to avoid mixed-tool schema conflicts.
|
|
281
|
+
const wantsNetworking = original.endsWith('-online') || detectsNetworkingTool(options.tools);
|
|
282
|
+
const enableNetworking = wantsNetworking;
|
|
283
|
+
let finalModel = stripOnlineSuffix(mapped);
|
|
284
|
+
finalModel = normalizePreviewAlias(finalModel);
|
|
285
|
+
return {
|
|
286
|
+
requestType: enableNetworking ? 'web_search' : 'agent',
|
|
287
|
+
injectGoogleSearch: enableNetworking,
|
|
288
|
+
finalModel
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
function coerceThoughtSignature(value) {
|
|
292
|
+
if (typeof value === 'string' && value.trim().length) {
|
|
293
|
+
return value.trim();
|
|
294
|
+
}
|
|
295
|
+
return undefined;
|
|
296
|
+
}
|
|
297
|
+
function ensureGeminiSemanticsNode(chat) {
|
|
298
|
+
if (!chat.semantics || typeof chat.semantics !== 'object') {
|
|
299
|
+
chat.semantics = {};
|
|
300
|
+
}
|
|
301
|
+
if (!chat.semantics.gemini || !isJsonObject(chat.semantics.gemini)) {
|
|
302
|
+
chat.semantics.gemini = {};
|
|
303
|
+
}
|
|
304
|
+
return chat.semantics.gemini;
|
|
305
|
+
}
|
|
306
|
+
function ensureSystemSemantics(chat) {
|
|
307
|
+
if (!chat.semantics || typeof chat.semantics !== 'object') {
|
|
308
|
+
chat.semantics = {};
|
|
309
|
+
}
|
|
310
|
+
if (!chat.semantics.system || !isJsonObject(chat.semantics.system)) {
|
|
311
|
+
chat.semantics.system = {};
|
|
312
|
+
}
|
|
313
|
+
return chat.semantics.system;
|
|
314
|
+
}
|
|
315
|
+
function markGeminiExplicitEmptyTools(chat) {
|
|
316
|
+
if (!chat.semantics || typeof chat.semantics !== 'object') {
|
|
317
|
+
chat.semantics = {};
|
|
318
|
+
}
|
|
319
|
+
if (!chat.semantics.tools || !isJsonObject(chat.semantics.tools)) {
|
|
320
|
+
chat.semantics.tools = {};
|
|
321
|
+
}
|
|
322
|
+
chat.semantics.tools.explicitEmpty = true;
|
|
323
|
+
}
|
|
324
|
+
function readGeminiSemantics(chat) {
|
|
325
|
+
if (!chat.semantics || typeof chat.semantics !== 'object') {
|
|
326
|
+
return undefined;
|
|
327
|
+
}
|
|
328
|
+
const node = chat.semantics.gemini;
|
|
329
|
+
return node && isJsonObject(node) ? node : undefined;
|
|
330
|
+
}
|
|
331
|
+
function hasExplicitEmptyToolsSemantics(chat) {
|
|
332
|
+
if (!chat.semantics || typeof chat.semantics !== 'object') {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
const toolsNode = chat.semantics.tools;
|
|
336
|
+
if (!toolsNode || !isJsonObject(toolsNode)) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
return Boolean(toolsNode.explicitEmpty);
|
|
340
|
+
}
|
|
341
|
+
function readSystemTextBlocksFromSemantics(chat) {
|
|
342
|
+
if (!chat.semantics || typeof chat.semantics !== 'object') {
|
|
343
|
+
return undefined;
|
|
344
|
+
}
|
|
345
|
+
const systemNode = chat.semantics.system;
|
|
346
|
+
if (!systemNode || !isJsonObject(systemNode)) {
|
|
347
|
+
return undefined;
|
|
348
|
+
}
|
|
349
|
+
const rawBlocks = systemNode.textBlocks;
|
|
350
|
+
if (!Array.isArray(rawBlocks)) {
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
const normalized = rawBlocks
|
|
354
|
+
.map((entry) => (typeof entry === 'string' ? entry : undefined))
|
|
355
|
+
.filter((value) => typeof value === 'string' && value.trim().length > 0);
|
|
356
|
+
return normalized.length ? normalized : undefined;
|
|
357
|
+
}
|
|
358
|
+
function extractThoughtSignatureFromToolCall(tc) {
|
|
359
|
+
if (!tc || typeof tc !== 'object') {
|
|
360
|
+
return undefined;
|
|
361
|
+
}
|
|
362
|
+
const node = tc;
|
|
363
|
+
const direct = coerceThoughtSignature(node.thought_signature ?? node.thoughtSignature);
|
|
364
|
+
if (direct) {
|
|
365
|
+
return direct;
|
|
366
|
+
}
|
|
367
|
+
const extra = node.extra_content ?? node.extraContent;
|
|
368
|
+
if (extra && typeof extra === 'object') {
|
|
369
|
+
const googleNode = extra.google ?? extra.Google;
|
|
370
|
+
if (googleNode && typeof googleNode === 'object') {
|
|
371
|
+
return coerceThoughtSignature(googleNode.thought_signature ?? googleNode.thoughtSignature);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return undefined;
|
|
375
|
+
}
|
|
376
|
+
function normalizeToolOutputs(messages, missing) {
|
|
377
|
+
const outputs = [];
|
|
378
|
+
messages.forEach((msg, index) => {
|
|
379
|
+
if (msg.role !== 'tool')
|
|
380
|
+
return;
|
|
381
|
+
const callId = msg.tool_call_id || msg.id;
|
|
382
|
+
if (typeof callId !== 'string' || !callId.trim()) {
|
|
383
|
+
missing.push({ path: `messages[${index}].tool_call_id`, reason: 'missing_tool_call_id' });
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
outputs.push({
|
|
387
|
+
tool_call_id: callId.trim(),
|
|
388
|
+
content: normalizeToolContent(msg.content),
|
|
389
|
+
name: typeof msg.name === 'string' ? msg.name : undefined
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
return outputs.length ? outputs : undefined;
|
|
393
|
+
}
|
|
394
|
+
function synthesizeToolOutputsFromMessages(messages) {
|
|
395
|
+
if (!Array.isArray(messages)) {
|
|
396
|
+
return [];
|
|
397
|
+
}
|
|
398
|
+
const outputs = [];
|
|
399
|
+
for (const message of messages) {
|
|
400
|
+
if (!message || typeof message !== 'object')
|
|
401
|
+
continue;
|
|
402
|
+
if (message.role !== 'assistant')
|
|
403
|
+
continue;
|
|
404
|
+
const toolCalls = Array.isArray(message.tool_calls)
|
|
405
|
+
? message.tool_calls
|
|
406
|
+
: [];
|
|
407
|
+
for (const call of toolCalls) {
|
|
408
|
+
const callId = typeof call.id === 'string' ? call.id : undefined;
|
|
409
|
+
if (!callId) {
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
const existing = outputs.find((entry) => entry.tool_call_id === callId);
|
|
413
|
+
if (existing) {
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
outputs.push({
|
|
417
|
+
tool_call_id: callId,
|
|
418
|
+
content: '',
|
|
419
|
+
name: (call.function && call.function.name) || undefined
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return outputs;
|
|
424
|
+
}
|
|
425
|
+
function normalizeToolContent(value) {
|
|
426
|
+
if (typeof value === 'string')
|
|
427
|
+
return value;
|
|
428
|
+
if (value == null)
|
|
429
|
+
return '';
|
|
430
|
+
try {
|
|
431
|
+
return JSON.stringify(value);
|
|
432
|
+
}
|
|
433
|
+
catch {
|
|
434
|
+
return String(value ?? '');
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
function convertToolMessageToOutput(message, allowedIds) {
|
|
438
|
+
const rawId = (message.tool_call_id ?? message.id);
|
|
439
|
+
const callId = typeof rawId === 'string' && rawId.trim().length ? rawId.trim() : undefined;
|
|
440
|
+
if (!callId) {
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
if (allowedIds && !allowedIds.has(callId)) {
|
|
444
|
+
return null;
|
|
445
|
+
}
|
|
446
|
+
return {
|
|
447
|
+
tool_call_id: callId,
|
|
448
|
+
content: normalizeToolContent(message.content),
|
|
449
|
+
name: typeof message.name === 'string' ? message.name : undefined
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
function selectAntigravityClaudeThinkingMessages(messages) {
|
|
453
|
+
if (!Array.isArray(messages) || messages.length === 0) {
|
|
454
|
+
return messages ?? [];
|
|
455
|
+
}
|
|
456
|
+
// 为了与 Responses 入口对齐,Claude-thinking 在发往 Antigravity 时仅保留
|
|
457
|
+
// 当前这一轮的 user 消息,丢弃历史 model/assistant 片段(例如错误日志中的「{」)。
|
|
458
|
+
let lastUserIndex = -1;
|
|
459
|
+
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
460
|
+
const msg = messages[i];
|
|
461
|
+
if (!msg || typeof msg !== 'object')
|
|
462
|
+
continue;
|
|
463
|
+
if (msg.role === 'user') {
|
|
464
|
+
lastUserIndex = i;
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
if (lastUserIndex === -1) {
|
|
469
|
+
return messages;
|
|
470
|
+
}
|
|
471
|
+
return [messages[lastUserIndex]];
|
|
472
|
+
}
|
|
473
|
+
function buildFunctionResponseEntry(output, options) {
|
|
474
|
+
const parsedPayload = safeParseJson(output.content);
|
|
475
|
+
const normalizedPayload = ensureFunctionResponsePayload(cloneAsJsonValue(parsedPayload));
|
|
476
|
+
const includeCallId = options?.includeCallId === true;
|
|
477
|
+
const part = {
|
|
478
|
+
functionResponse: {
|
|
479
|
+
name: output.name || 'tool',
|
|
480
|
+
response: normalizedPayload
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
if (includeCallId) {
|
|
484
|
+
part.functionResponse.id = sanitizeAntigravityToolCallId(output.tool_call_id);
|
|
485
|
+
}
|
|
486
|
+
return { role: 'user', parts: [part] };
|
|
487
|
+
}
|
|
488
|
+
function collectSystemSegments(systemInstruction) {
|
|
489
|
+
if (!systemInstruction)
|
|
490
|
+
return [];
|
|
491
|
+
const flatten = (val) => {
|
|
492
|
+
if (typeof val === 'string')
|
|
493
|
+
return val;
|
|
494
|
+
if (Array.isArray(val))
|
|
495
|
+
return val.map((entry) => flatten(entry)).filter(Boolean).join('\n');
|
|
496
|
+
if (val && typeof val === 'object') {
|
|
497
|
+
const text = val.text;
|
|
498
|
+
if (typeof text === 'string')
|
|
499
|
+
return text;
|
|
500
|
+
const parts = val.parts;
|
|
501
|
+
if (Array.isArray(parts))
|
|
502
|
+
return parts.map((entry) => flatten(entry)).filter(Boolean).join('\n');
|
|
503
|
+
}
|
|
504
|
+
return '';
|
|
505
|
+
};
|
|
506
|
+
const text = flatten(systemInstruction).trim();
|
|
507
|
+
return text ? [text] : [];
|
|
508
|
+
}
|
|
509
|
+
function collectParameters(payload) {
|
|
510
|
+
const params = {};
|
|
511
|
+
if (typeof payload.model === 'string') {
|
|
512
|
+
params.model = payload.model;
|
|
513
|
+
}
|
|
514
|
+
const gen = payload.generationConfig;
|
|
515
|
+
if (gen && typeof gen === 'object') {
|
|
516
|
+
for (const { source, target } of GENERATION_CONFIG_KEYS) {
|
|
517
|
+
const value = gen[source];
|
|
518
|
+
if (value !== undefined) {
|
|
519
|
+
params[target] = value;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
if (payload.toolConfig !== undefined) {
|
|
524
|
+
params.tool_config = jsonClone(payload.toolConfig);
|
|
525
|
+
}
|
|
526
|
+
const meta = payload.metadata;
|
|
527
|
+
if (meta && typeof meta === 'object' && Object.prototype.hasOwnProperty.call(meta, '__rcc_stream')) {
|
|
528
|
+
params.stream = Boolean(meta.__rcc_stream);
|
|
529
|
+
}
|
|
530
|
+
return Object.keys(params).length ? params : undefined;
|
|
531
|
+
}
|
|
532
|
+
function appendChatContentToGeminiParts(message, targetParts, options) {
|
|
533
|
+
const content = message.content;
|
|
534
|
+
if (typeof content === 'string') {
|
|
535
|
+
const text = (options?.stripReasoningTags ? sanitizeReasoningTaggedText(content) : content).trim();
|
|
536
|
+
if (text.length) {
|
|
537
|
+
targetParts.push({ text });
|
|
538
|
+
}
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
if (!Array.isArray(content)) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
const items = content;
|
|
545
|
+
for (const block of items) {
|
|
546
|
+
if (block == null)
|
|
547
|
+
continue;
|
|
548
|
+
if (typeof block === 'string') {
|
|
549
|
+
const text = (options?.stripReasoningTags ? sanitizeReasoningTaggedText(block) : block).trim();
|
|
550
|
+
if (text.length) {
|
|
551
|
+
targetParts.push({ text });
|
|
552
|
+
}
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
if (typeof block !== 'object') {
|
|
556
|
+
const raw = String(block);
|
|
557
|
+
const text = (options?.stripReasoningTags ? sanitizeReasoningTaggedText(raw) : raw).trim();
|
|
558
|
+
if (text.length) {
|
|
559
|
+
targetParts.push({ text });
|
|
560
|
+
}
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
const record = block;
|
|
564
|
+
const rawType = record.type;
|
|
565
|
+
const type = typeof rawType === 'string' ? rawType.toLowerCase() : '';
|
|
566
|
+
// Text-style blocks
|
|
567
|
+
if (!type || type === 'text') {
|
|
568
|
+
const textValue = typeof record.text === 'string'
|
|
569
|
+
? record.text
|
|
570
|
+
: typeof record.content === 'string'
|
|
571
|
+
? record.content
|
|
572
|
+
: '';
|
|
573
|
+
const text = (options?.stripReasoningTags ? sanitizeReasoningTaggedText(textValue) : textValue).trim();
|
|
574
|
+
if (text.length) {
|
|
575
|
+
targetParts.push({ text });
|
|
576
|
+
}
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
// Image-style blocks -> Gemini inlineData
|
|
580
|
+
if (type === 'image' || type === 'image_url') {
|
|
581
|
+
// Prefer OpenAI-style image_url.url, but also accept uri/url/data.
|
|
582
|
+
let url;
|
|
583
|
+
const imageUrlRaw = record.image_url;
|
|
584
|
+
if (typeof imageUrlRaw === 'string') {
|
|
585
|
+
url = imageUrlRaw;
|
|
586
|
+
}
|
|
587
|
+
else if (imageUrlRaw && typeof imageUrlRaw === 'object' && typeof imageUrlRaw.url === 'string') {
|
|
588
|
+
url = imageUrlRaw.url;
|
|
589
|
+
}
|
|
590
|
+
else if (typeof record.uri === 'string') {
|
|
591
|
+
url = record.uri;
|
|
592
|
+
}
|
|
593
|
+
else if (typeof record.url === 'string') {
|
|
594
|
+
url = record.url;
|
|
595
|
+
}
|
|
596
|
+
else if (typeof record.data === 'string') {
|
|
597
|
+
url = record.data;
|
|
598
|
+
}
|
|
599
|
+
const trimmed = (url ?? '').trim();
|
|
600
|
+
if (!trimmed.length) {
|
|
601
|
+
// Fallback: at least emit a textual marker so内容不会完全丢失
|
|
602
|
+
targetParts.push({ text: '[image]' });
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
let mimeType;
|
|
606
|
+
let data;
|
|
607
|
+
// data:URL → inlineData { mimeType, data }
|
|
608
|
+
if (trimmed.startsWith('data:')) {
|
|
609
|
+
const match = /^data:([^;,]+)?(?:;base64)?,(.*)$/s.exec(trimmed);
|
|
610
|
+
if (match) {
|
|
611
|
+
mimeType = (match[1] || '').trim() || undefined;
|
|
612
|
+
data = match[2] || '';
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
if (data && data.trim().length) {
|
|
616
|
+
const inline = {
|
|
617
|
+
inlineData: {
|
|
618
|
+
data: data.trim()
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
if (mimeType && mimeType.length) {
|
|
622
|
+
inline.inlineData.mimeType = mimeType;
|
|
623
|
+
}
|
|
624
|
+
targetParts.push(inline);
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
// 非 data: URL 暂时作为文本 URL 传递,保持语义可见
|
|
628
|
+
targetParts.push({ text: trimmed });
|
|
629
|
+
}
|
|
630
|
+
continue;
|
|
631
|
+
}
|
|
632
|
+
// 默认:回退为文本 JSON 表示,避免静默丢失内容
|
|
633
|
+
try {
|
|
634
|
+
const jsonText = JSON.stringify(record);
|
|
635
|
+
if (jsonText.trim().length) {
|
|
636
|
+
targetParts.push({ text: jsonText });
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
catch {
|
|
640
|
+
// ignore malformed block
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
function buildGeminiRequestFromChat(chat, metadata) {
|
|
645
|
+
const contents = [];
|
|
646
|
+
const emittedToolOutputs = new Set();
|
|
647
|
+
const adapterContext = metadata?.context;
|
|
648
|
+
const rawProviderId = adapterContext?.providerId;
|
|
649
|
+
const entryEndpointRaw = adapterContext?.entryEndpoint;
|
|
650
|
+
const entryEndpoint = typeof entryEndpointRaw === 'string' ? entryEndpointRaw.trim().toLowerCase() : '';
|
|
651
|
+
const isAnthropicEntry = entryEndpoint === '/v1/messages';
|
|
652
|
+
const normalizedProviderId = typeof rawProviderId === 'string' ? rawProviderId.toLowerCase() : '';
|
|
653
|
+
const providerIdPrefix = normalizedProviderId.split('.')[0];
|
|
654
|
+
const isAntigravityProvider = providerIdPrefix === 'antigravity';
|
|
655
|
+
const isGeminiCliProvider = providerIdPrefix === 'gemini-cli';
|
|
656
|
+
const requiresThoughtSignature = isAntigravityProvider || isGeminiCliProvider;
|
|
657
|
+
const parameters = chat.parameters && typeof chat.parameters === 'object' ? chat.parameters : {};
|
|
658
|
+
const responsesOrigin = isResponsesOrigin(chat);
|
|
659
|
+
if (responsesOrigin) {
|
|
660
|
+
for (const field of RESPONSES_DROPPED_PARAMETER_KEYS) {
|
|
661
|
+
if (!Object.prototype.hasOwnProperty.call(parameters, field)) {
|
|
662
|
+
continue;
|
|
663
|
+
}
|
|
664
|
+
appendDroppedFieldAudit(chat, {
|
|
665
|
+
field,
|
|
666
|
+
targetProtocol: 'gemini-chat',
|
|
667
|
+
reason: 'unsupported_semantics_no_equivalent'
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
const isAntigravityClaudeThinking = providerIdPrefix === 'antigravity' &&
|
|
672
|
+
typeof parameters.model === 'string' &&
|
|
673
|
+
String(parameters.model).includes('claude-sonnet-4-5-thinking');
|
|
674
|
+
const keepReasoning = Boolean(parameters.keep_thinking) ||
|
|
675
|
+
Boolean(parameters.keep_reasoning);
|
|
676
|
+
const stripReasoningTags = isAntigravityProvider &&
|
|
677
|
+
typeof parameters.model === 'string' &&
|
|
678
|
+
String(parameters.model).startsWith('claude-') &&
|
|
679
|
+
!keepReasoning;
|
|
680
|
+
// Cloud Code / Antigravity requires stable tool call IDs in context (maps to tool_use.id),
|
|
681
|
+
// while standard Gemini endpoints do not require (and may reject) extra id fields.
|
|
682
|
+
const includeToolCallIds = providerIdPrefix === 'antigravity';
|
|
683
|
+
// Function calling protocol:
|
|
684
|
+
// - For gemini-cli.* we allow structured tool loops when tools are present (Codex/agent clients),
|
|
685
|
+
// otherwise keep a conservative path (text-only tool transcripts).
|
|
686
|
+
// - For antigravity.* and other Gemini backends, send tool schemas and emit functionCall/functionResponse parts
|
|
687
|
+
// so tool loops remain structured and recoverable.
|
|
688
|
+
const allowFunctionCallingProtocol = providerIdPrefix !== 'gemini-cli' || (Array.isArray(chat.tools) && chat.tools.length > 0);
|
|
689
|
+
const omitFunctionCallPartsForCli = !allowFunctionCallingProtocol;
|
|
690
|
+
const semanticsNode = readGeminiSemantics(chat);
|
|
691
|
+
const systemTextBlocksFromSemantics = readSystemTextBlocksFromSemantics(chat);
|
|
692
|
+
let antigravityRequestType;
|
|
693
|
+
// Gemini series alignment:
|
|
694
|
+
// - Client/tool surface uses canonical name: "web_search"
|
|
695
|
+
// - Gemini upstream receives a function tool name: "websearch" (no underscore)
|
|
696
|
+
// then ServerTool intercepts and executes the web_search route.
|
|
697
|
+
const mapToolNameForGemini = (nameRaw) => {
|
|
698
|
+
const name = typeof nameRaw === 'string' ? nameRaw.trim() : '';
|
|
699
|
+
if (!name)
|
|
700
|
+
return undefined;
|
|
701
|
+
if (name === 'web_search' || name.startsWith('web_search_')) {
|
|
702
|
+
return 'websearch';
|
|
703
|
+
}
|
|
704
|
+
return name;
|
|
705
|
+
};
|
|
706
|
+
const bridgeDefs = chat.tools && chat.tools.length ? mapChatToolsToBridge(chat.tools) : undefined;
|
|
707
|
+
if (bridgeDefs && bridgeDefs.length) {
|
|
708
|
+
for (const def of bridgeDefs) {
|
|
709
|
+
if (!def || typeof def !== 'object')
|
|
710
|
+
continue;
|
|
711
|
+
const mapped = mapToolNameForGemini(def.name);
|
|
712
|
+
if (mapped && mapped !== def.name) {
|
|
713
|
+
def.name = mapped;
|
|
714
|
+
if (def.function && typeof def.function === 'object') {
|
|
715
|
+
def.function.name = mapped;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
const toolSchemaKeys = bridgeDefs ? buildToolSchemaKeyMap(bridgeDefs) : new Map();
|
|
721
|
+
const sourceMessages = chat.messages;
|
|
722
|
+
// 收集当前 ChatEnvelope 中 assistant/tool_calls 的 id,用于过滤孤立的 tool_result:
|
|
723
|
+
// 只有在本轮对话中存在对应 tool_call 的 tool_result 才允许映射为 Gemini functionResponse。
|
|
724
|
+
const assistantToolCallIds = new Set();
|
|
725
|
+
for (const msg of sourceMessages) {
|
|
726
|
+
if (!msg || typeof msg !== 'object')
|
|
727
|
+
continue;
|
|
728
|
+
if (msg.role !== 'assistant')
|
|
729
|
+
continue;
|
|
730
|
+
const tcs = Array.isArray(msg.tool_calls)
|
|
731
|
+
? msg.tool_calls
|
|
732
|
+
: [];
|
|
733
|
+
for (const tc of tcs) {
|
|
734
|
+
const id = typeof tc.id === 'string' ? tc.id.trim() : '';
|
|
735
|
+
if (id) {
|
|
736
|
+
assistantToolCallIds.add(id);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
for (const message of sourceMessages) {
|
|
741
|
+
if (!message || typeof message !== 'object')
|
|
742
|
+
continue;
|
|
743
|
+
if (message.role === 'system')
|
|
744
|
+
continue;
|
|
745
|
+
if (message.role === 'tool') {
|
|
746
|
+
if (allowFunctionCallingProtocol) {
|
|
747
|
+
const toolOutput = convertToolMessageToOutput(message, assistantToolCallIds);
|
|
748
|
+
if (toolOutput) {
|
|
749
|
+
toolOutput.name = mapToolNameForGemini(toolOutput.name);
|
|
750
|
+
contents.push(buildFunctionResponseEntry(toolOutput, { includeCallId: includeToolCallIds }));
|
|
751
|
+
emittedToolOutputs.add(toolOutput.tool_call_id);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
else {
|
|
755
|
+
const name = typeof message.name === 'string' ? String(message.name).trim() : 'tool';
|
|
756
|
+
const contentText = normalizeToolContent(message.content);
|
|
757
|
+
contents.push({
|
|
758
|
+
role: 'user',
|
|
759
|
+
parts: [{ text: `[tool:${name}] ${contentText}` }]
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
const entry = {
|
|
765
|
+
role: mapChatRoleToGemini(message.role),
|
|
766
|
+
parts: []
|
|
767
|
+
};
|
|
768
|
+
appendChatContentToGeminiParts(message, entry.parts, { stripReasoningTags });
|
|
769
|
+
const toolCalls = Array.isArray(message.tool_calls)
|
|
770
|
+
? message.tool_calls
|
|
771
|
+
: [];
|
|
772
|
+
for (const tc of toolCalls) {
|
|
773
|
+
if (!tc || typeof tc !== 'object')
|
|
774
|
+
continue;
|
|
775
|
+
if (omitFunctionCallPartsForCli) {
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
const fn = tc.function || {};
|
|
779
|
+
const name = mapToolNameForGemini(typeof fn.name === 'string' ? fn.name : undefined);
|
|
780
|
+
if (!name)
|
|
781
|
+
continue;
|
|
782
|
+
let argsStruct;
|
|
783
|
+
if (typeof fn.arguments === 'string') {
|
|
784
|
+
try {
|
|
785
|
+
argsStruct = JSON.parse(fn.arguments);
|
|
786
|
+
}
|
|
787
|
+
catch {
|
|
788
|
+
argsStruct = { _raw: fn.arguments };
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
else {
|
|
792
|
+
argsStruct = fn.arguments ?? {};
|
|
793
|
+
}
|
|
794
|
+
argsStruct = alignToolCallArgsToSchema({ toolName: name, args: argsStruct, schemaKeys: toolSchemaKeys });
|
|
795
|
+
let argsJson = cloneAsJsonValue(argsStruct);
|
|
796
|
+
// Gemini / Antigravity 期望 functionCall.args 为对象(Struct),
|
|
797
|
+
// 若顶层为数组或原始类型,则包装到 value 字段下,避免产生非法的 list 形状。
|
|
798
|
+
if (!argsJson || typeof argsJson !== 'object' || Array.isArray(argsJson)) {
|
|
799
|
+
argsJson = { value: argsJson };
|
|
800
|
+
}
|
|
801
|
+
const functionCall = { name, args: argsJson };
|
|
802
|
+
const part = { functionCall };
|
|
803
|
+
if (includeToolCallIds && typeof tc.id === 'string' && tc.id.trim().length) {
|
|
804
|
+
part.functionCall.id = sanitizeAntigravityToolCallId(String(tc.id));
|
|
805
|
+
}
|
|
806
|
+
// Antigravity-Manager alignment:
|
|
807
|
+
// - Do NOT invent a dummy thoughtSignature in conversion.
|
|
808
|
+
// - Only inject a real thoughtSignature when the compat layer has a cached signature.
|
|
809
|
+
// This avoids sending a placeholder that may be treated as an invalid fingerprint upstream.
|
|
810
|
+
entry.parts.push(part);
|
|
811
|
+
}
|
|
812
|
+
if (entry.parts.length) {
|
|
813
|
+
contents.push(entry);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
const toolOutputMap = new Map();
|
|
817
|
+
if (allowFunctionCallingProtocol) {
|
|
818
|
+
if (Array.isArray(chat.toolOutputs)) {
|
|
819
|
+
for (const entry of chat.toolOutputs) {
|
|
820
|
+
if (entry && typeof entry.tool_call_id === 'string' && entry.tool_call_id.trim().length) {
|
|
821
|
+
toolOutputMap.set(entry.tool_call_id.trim(), entry);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
if (toolOutputMap.size === 0) {
|
|
826
|
+
const syntheticOutputs = synthesizeToolOutputsFromMessages(chat.messages);
|
|
827
|
+
for (const output of syntheticOutputs) {
|
|
828
|
+
toolOutputMap.set(output.tool_call_id, output);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
for (const output of toolOutputMap.values()) {
|
|
832
|
+
if (emittedToolOutputs.has(output.tool_call_id)) {
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
output.name = mapToolNameForGemini(output.name);
|
|
836
|
+
contents.push(buildFunctionResponseEntry(output, { includeCallId: includeToolCallIds }));
|
|
837
|
+
emittedToolOutputs.add(output.tool_call_id);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
const request = {
|
|
841
|
+
model: chat.parameters?.model || 'models/gemini-pro',
|
|
842
|
+
contents
|
|
843
|
+
};
|
|
844
|
+
const geminiState = getProtocolState(metadata, 'gemini');
|
|
845
|
+
if (!isAntigravityProvider && semanticsNode?.systemInstruction !== undefined) {
|
|
846
|
+
request.systemInstruction = jsonClone(semanticsNode.systemInstruction);
|
|
847
|
+
}
|
|
848
|
+
else if (!isAntigravityProvider && geminiState?.systemInstruction !== undefined) {
|
|
849
|
+
request.systemInstruction = jsonClone(geminiState.systemInstruction);
|
|
850
|
+
}
|
|
851
|
+
else if (!isAntigravityProvider) {
|
|
852
|
+
const fallbackSystemInstructions = systemTextBlocksFromSemantics;
|
|
853
|
+
if (fallbackSystemInstructions && fallbackSystemInstructions.length) {
|
|
854
|
+
const sysBlocks = fallbackSystemInstructions
|
|
855
|
+
.filter((value) => typeof value === 'string' && value.trim().length > 0)
|
|
856
|
+
.map((value) => ({ text: value }));
|
|
857
|
+
if (sysBlocks.length) {
|
|
858
|
+
request.systemInstruction = { role: 'system', parts: sysBlocks };
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
if (isAntigravityProvider) {
|
|
863
|
+
const extraSegments = [];
|
|
864
|
+
const seen = new Set();
|
|
865
|
+
const pushSegment = (value) => {
|
|
866
|
+
const trimmed = typeof value === 'string' ? value.trim() : '';
|
|
867
|
+
if (!trimmed)
|
|
868
|
+
return;
|
|
869
|
+
if (seen.has(trimmed))
|
|
870
|
+
return;
|
|
871
|
+
seen.add(trimmed);
|
|
872
|
+
extraSegments.push(trimmed);
|
|
873
|
+
};
|
|
874
|
+
for (const seg of collectSystemSegments(semanticsNode?.systemInstruction)) {
|
|
875
|
+
pushSegment(seg);
|
|
876
|
+
}
|
|
877
|
+
for (const seg of collectSystemSegments(geminiState?.systemInstruction)) {
|
|
878
|
+
pushSegment(seg);
|
|
879
|
+
}
|
|
880
|
+
for (const seg of systemTextBlocksFromSemantics || []) {
|
|
881
|
+
if (typeof seg === 'string') {
|
|
882
|
+
pushSegment(seg);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
// Antigravity requires role="user" and a fixed system instruction prefix.
|
|
886
|
+
// Provider layer must NOT rewrite systemInstruction; this is a semantic mapper concern.
|
|
887
|
+
if (extraSegments.length > 0) {
|
|
888
|
+
const [first, ...rest] = extraSegments;
|
|
889
|
+
request.systemInstruction = {
|
|
890
|
+
role: 'user',
|
|
891
|
+
parts: [{ text: `${ANTIGRAVITY_SYSTEM_INSTRUCTION}\n\n${first}` }, ...rest.map((text) => ({ text }))]
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
else {
|
|
895
|
+
request.systemInstruction = {
|
|
896
|
+
role: 'user',
|
|
897
|
+
parts: [{ text: ANTIGRAVITY_SYSTEM_INSTRUCTION }]
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
if (allowFunctionCallingProtocol && chat.tools && chat.tools.length) {
|
|
902
|
+
const geminiTools = buildGeminiToolsFromBridge(bridgeDefs, {
|
|
903
|
+
mode: isAntigravityProvider ? 'antigravity' : 'default'
|
|
904
|
+
});
|
|
905
|
+
if (geminiTools) {
|
|
906
|
+
request.tools = geminiTools;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
const generationConfig = buildGenerationConfigFromParameters(chat.parameters || {});
|
|
910
|
+
if (responsesOrigin && Object.prototype.hasOwnProperty.call(parameters, 'reasoning')) {
|
|
911
|
+
appendLossyFieldAudit(chat, {
|
|
912
|
+
field: 'reasoning',
|
|
913
|
+
targetProtocol: 'gemini-chat',
|
|
914
|
+
reason: 'normalized_to_gemini_thinking_config'
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
if (semanticsNode?.generationConfig && isJsonObject(semanticsNode.generationConfig)) {
|
|
918
|
+
for (const [key, value] of Object.entries(semanticsNode.generationConfig)) {
|
|
919
|
+
if (generationConfig[key] !== undefined) {
|
|
920
|
+
continue;
|
|
921
|
+
}
|
|
922
|
+
generationConfig[key] = jsonClone(value);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
if (Object.keys(generationConfig).length) {
|
|
926
|
+
request.generationConfig = generationConfig;
|
|
927
|
+
}
|
|
928
|
+
if (!isAntigravityProvider && semanticsNode?.safetySettings !== undefined) {
|
|
929
|
+
request.safetySettings = jsonClone(semanticsNode.safetySettings);
|
|
930
|
+
}
|
|
931
|
+
else if (isAntigravityProvider) {
|
|
932
|
+
// gcli2api alignment: Antigravity always sends a permissive safetySettings set.
|
|
933
|
+
request.safetySettings = jsonClone(ANTIGRAVITY_DEFAULT_SAFETY_SETTINGS);
|
|
934
|
+
}
|
|
935
|
+
if (isAntigravityProvider && isJsonObject(request.generationConfig)) {
|
|
936
|
+
// gcli2api alignment: when generationConfig is present, clamp the key parameters.
|
|
937
|
+
request.generationConfig.maxOutputTokens = 64000;
|
|
938
|
+
request.generationConfig.topK = 64;
|
|
939
|
+
}
|
|
940
|
+
if (isAntigravityProvider && typeof request.model === 'string') {
|
|
941
|
+
const requestPayload = request;
|
|
942
|
+
const original = requestPayload.model;
|
|
943
|
+
// Antigravity v1internal model IDs are tiered (e.g. gemini-3-pro-high/low) and must be preserved.
|
|
944
|
+
// Align with fetchAvailableModels: do NOT strip "-high"/"-low" suffixes for upstream requests.
|
|
945
|
+
const mapped = stripOnlineSuffix(original);
|
|
946
|
+
const size = typeof chat.parameters?.size === 'string' ? String(chat.parameters.size) : undefined;
|
|
947
|
+
const quality = typeof chat.parameters?.quality === 'string' ? String(chat.parameters.quality) : undefined;
|
|
948
|
+
const config = resolveAntigravityRequestConfig({
|
|
949
|
+
originalModel: original,
|
|
950
|
+
mappedModel: mapped,
|
|
951
|
+
tools: requestPayload.tools,
|
|
952
|
+
size,
|
|
953
|
+
quality
|
|
954
|
+
});
|
|
955
|
+
antigravityRequestType = config.requestType;
|
|
956
|
+
requestPayload.requestType = config.requestType;
|
|
957
|
+
requestPayload.model = config.finalModel || mapped;
|
|
958
|
+
pruneSearchFunctionDeclarations(requestPayload);
|
|
959
|
+
if (config.requestType === 'image_gen') {
|
|
960
|
+
delete requestPayload.tools;
|
|
961
|
+
delete requestPayload.systemInstruction;
|
|
962
|
+
if (!isJsonObject(requestPayload.generationConfig)) {
|
|
963
|
+
requestPayload.generationConfig = {};
|
|
964
|
+
}
|
|
965
|
+
const gen = requestPayload.generationConfig;
|
|
966
|
+
delete gen.thinkingConfig;
|
|
967
|
+
delete gen.responseMimeType;
|
|
968
|
+
delete gen.responseModalities;
|
|
969
|
+
if (config.imageConfig) {
|
|
970
|
+
gen.imageConfig = config.imageConfig;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
else if (config.injectGoogleSearch) {
|
|
974
|
+
injectGoogleSearchTool(requestPayload);
|
|
975
|
+
}
|
|
976
|
+
deepCleanUndefined(requestPayload);
|
|
977
|
+
const mappedLower = String(requestPayload.model || '').toLowerCase();
|
|
978
|
+
const isFlashModel = mappedLower.includes('flash');
|
|
979
|
+
const isFlash3Model = mappedLower.includes('gemini-3') && isFlashModel;
|
|
980
|
+
const isImageModel = config.requestType === 'image_gen' || mappedLower.includes('image');
|
|
981
|
+
// Antigravity-Manager v4.1.28 alignment: gemini-3-flash / gemini-3.1-flash are thinking models
|
|
982
|
+
const isThinkingModel = !isImageModel && (mappedLower.includes('think') || mappedLower.includes('pro') || isFlash3Model);
|
|
983
|
+
if (isThinkingModel && (!requestPayload.generationConfig || !isJsonObject(requestPayload.generationConfig))) {
|
|
984
|
+
requestPayload.generationConfig = {};
|
|
985
|
+
}
|
|
986
|
+
const generationConfig = requestPayload.generationConfig;
|
|
987
|
+
if (isFlashModel && isJsonObject(generationConfig)) {
|
|
988
|
+
const gc = generationConfig;
|
|
989
|
+
const thinkingConfigRaw = gc.thinkingConfig;
|
|
990
|
+
const thinkingConfig = isJsonObject(thinkingConfigRaw) ? thinkingConfigRaw : undefined;
|
|
991
|
+
// Antigravity-Manager v4.1.28 alignment: gemini-3-flash / gemini-3.1-flash support thinking.
|
|
992
|
+
// Auto-inject default thinkingConfig when missing (Cherry Studio compatibility).
|
|
993
|
+
if (isFlash3Model && !thinkingConfig) {
|
|
994
|
+
gc.thinkingConfig = {
|
|
995
|
+
thinkingBudget: GEMINI_FLASH_DEFAULT_THINKING_BUDGET,
|
|
996
|
+
includeThoughts: true
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
const budgetRaw = thinkingConfig && thinkingConfig.thinkingBudget;
|
|
1000
|
+
const budget = typeof budgetRaw === 'number' && Number.isFinite(budgetRaw) ? budgetRaw : undefined;
|
|
1001
|
+
if (thinkingConfig && budget !== undefined && budget > GEMINI_FLASH_DEFAULT_THINKING_BUDGET) {
|
|
1002
|
+
thinkingConfig.thinkingBudget = GEMINI_FLASH_DEFAULT_THINKING_BUDGET;
|
|
1003
|
+
gc.thinkingConfig = thinkingConfig;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
if (isThinkingModel && isJsonObject(generationConfig)) {
|
|
1007
|
+
const gc = generationConfig;
|
|
1008
|
+
const thinkingConfig = isJsonObject(gc.thinkingConfig)
|
|
1009
|
+
? gc.thinkingConfig
|
|
1010
|
+
: {};
|
|
1011
|
+
const existingBudget = typeof thinkingConfig.thinkingBudget === 'number'
|
|
1012
|
+
? thinkingConfig.thinkingBudget
|
|
1013
|
+
: undefined;
|
|
1014
|
+
const shouldApply = existingBudget !== undefined ? existingBudget !== 0 : true;
|
|
1015
|
+
if (shouldApply) {
|
|
1016
|
+
if (typeof thinkingConfig.thinkingBudget !== 'number') {
|
|
1017
|
+
thinkingConfig.thinkingBudget = 1024;
|
|
1018
|
+
}
|
|
1019
|
+
if (Object.prototype.hasOwnProperty.call(thinkingConfig, 'thinkingLevel')) {
|
|
1020
|
+
delete thinkingConfig.thinkingLevel;
|
|
1021
|
+
}
|
|
1022
|
+
thinkingConfig.includeThoughts = true;
|
|
1023
|
+
// For Claude routed via Antigravity:
|
|
1024
|
+
// - when tool calls exist, gcli2api drops thinkingConfig to avoid upstream failures
|
|
1025
|
+
// - otherwise, ensure the last model message begins with a thinking block signature
|
|
1026
|
+
const isClaude = mappedLower.includes('claude');
|
|
1027
|
+
if (isClaude) {
|
|
1028
|
+
const contentsArray = Array.isArray(request.contents) ? request.contents : [];
|
|
1029
|
+
const hasToolCalls = contentsArray.some((content) => {
|
|
1030
|
+
if (!isJsonObject(content))
|
|
1031
|
+
return false;
|
|
1032
|
+
const parts = content.parts;
|
|
1033
|
+
if (!Array.isArray(parts))
|
|
1034
|
+
return false;
|
|
1035
|
+
return parts.some((part) => isJsonObject(part) &&
|
|
1036
|
+
('functionCall' in part || 'function_call' in part));
|
|
1037
|
+
});
|
|
1038
|
+
if (hasToolCalls) {
|
|
1039
|
+
delete gc.thinkingConfig;
|
|
1040
|
+
}
|
|
1041
|
+
else {
|
|
1042
|
+
for (let idx = contentsArray.length - 1; idx >= 0; idx -= 1) {
|
|
1043
|
+
const content = contentsArray[idx];
|
|
1044
|
+
if (!isJsonObject(content))
|
|
1045
|
+
continue;
|
|
1046
|
+
if (content.role !== 'model')
|
|
1047
|
+
continue;
|
|
1048
|
+
const parts = content.parts;
|
|
1049
|
+
if (!Array.isArray(parts))
|
|
1050
|
+
continue;
|
|
1051
|
+
const first = parts[0];
|
|
1052
|
+
const firstIsThinking = isJsonObject(first) && ('thought' in first || 'thoughtSignature' in first);
|
|
1053
|
+
// Antigravity-Manager alignment: do not inject placeholder thoughtSignature blocks.
|
|
1054
|
+
// If the upstream requires a signature, it must come from cached candidate parts.
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
1057
|
+
gc.thinkingConfig = thinkingConfig;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
else {
|
|
1061
|
+
gc.thinkingConfig = thinkingConfig;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
if (chat.parameters?.tool_config && isJsonObject(chat.parameters.tool_config)) {
|
|
1067
|
+
request.toolConfig = jsonClone(chat.parameters.tool_config);
|
|
1068
|
+
}
|
|
1069
|
+
else if (semanticsNode?.toolConfig && isJsonObject(semanticsNode.toolConfig)) {
|
|
1070
|
+
request.toolConfig = jsonClone(semanticsNode.toolConfig);
|
|
1071
|
+
}
|
|
1072
|
+
// 为了保持协议解耦,只在 Gemini 自身或开放式 Chat 入口下透传 providerMetadata;
|
|
1073
|
+
// 对于 Anthropic (/v1/messages) 等其它协议的入口,不再将其 metadata 整块转发给 Gemini,
|
|
1074
|
+
// 避免跨协议泄漏上游专有字段。
|
|
1075
|
+
if (!isAnthropicEntry) {
|
|
1076
|
+
if (semanticsNode?.providerMetadata && isJsonObject(semanticsNode.providerMetadata)) {
|
|
1077
|
+
request.metadata = jsonClone(semanticsNode.providerMetadata);
|
|
1078
|
+
}
|
|
1079
|
+
else if (metadata?.providerMetadata && isJsonObject(metadata.providerMetadata)) {
|
|
1080
|
+
request.metadata = jsonClone(metadata.providerMetadata);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
if (chat.parameters && chat.parameters.stream !== undefined) {
|
|
1084
|
+
request.metadata = request.metadata ?? {};
|
|
1085
|
+
request.metadata.__rcc_stream = chat.parameters.stream;
|
|
1086
|
+
}
|
|
1087
|
+
if (hasExplicitEmptyToolsSemantics(chat) &&
|
|
1088
|
+
(!Array.isArray(chat.tools) || chat.tools.length === 0)) {
|
|
1089
|
+
request.metadata = request.metadata ?? {};
|
|
1090
|
+
request.metadata.__rcc_tools_field_present = '1';
|
|
1091
|
+
}
|
|
1092
|
+
const passthrough = encodeMetadataPassthrough(chat.parameters, {
|
|
1093
|
+
prefix: PASSTHROUGH_METADATA_PREFIX,
|
|
1094
|
+
keys: PASSTHROUGH_PARAMETERS
|
|
1095
|
+
});
|
|
1096
|
+
if (passthrough) {
|
|
1097
|
+
request.metadata = request.metadata ?? {};
|
|
1098
|
+
for (const [key, value] of Object.entries(passthrough)) {
|
|
1099
|
+
request.metadata[key] = value;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
if (isAntigravityProvider) {
|
|
1103
|
+
request.metadata = request.metadata ?? {};
|
|
1104
|
+
const existing = request.metadata.antigravitySessionId;
|
|
1105
|
+
if (typeof existing !== 'string' || !existing.trim()) {
|
|
1106
|
+
request.metadata.antigravitySessionId = extractAntigravityGeminiSessionIdWithNative(request);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
// Apply claude-thinking compat at Gemini mapping time to ensure it is always active
|
|
1110
|
+
// for Claude models, regardless of compatibilityProfile wiring. Provider层负责进一步的
|
|
1111
|
+
// 传输层收紧(如 session_id / generationConfig),这里不做非标裁剪。
|
|
1112
|
+
const compatRequest = applyClaudeThinkingToolSchemaCompatWithNative(request);
|
|
1113
|
+
return compatRequest;
|
|
1114
|
+
}
|
|
1115
|
+
function sanitizeAntigravityToolCallId(raw) {
|
|
1116
|
+
const trimmed = typeof raw === 'string' ? raw.trim() : '';
|
|
1117
|
+
if (!trimmed) {
|
|
1118
|
+
return trimmed;
|
|
1119
|
+
}
|
|
1120
|
+
// Antigravity (Claude via Gemini) validates tool_use.id against: ^[a-zA-Z0-9_-]+$
|
|
1121
|
+
// Preserve stable IDs when already valid; otherwise sanitize minimally.
|
|
1122
|
+
if (/^[A-Za-z0-9_-]+$/.test(trimmed)) {
|
|
1123
|
+
return trimmed;
|
|
1124
|
+
}
|
|
1125
|
+
const sanitized = trimmed
|
|
1126
|
+
.replace(/[^A-Za-z0-9_-]/g, '_')
|
|
1127
|
+
.replace(/_{2,}/g, '_')
|
|
1128
|
+
.replace(/^_+/, '')
|
|
1129
|
+
.replace(/_+$/, '');
|
|
1130
|
+
return sanitized || `call_${Math.random().toString(36).slice(2, 10)}`;
|
|
1131
|
+
}
|
|
1132
|
+
function isPlainRecord(value) {
|
|
1133
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
1134
|
+
}
|
|
1135
|
+
function buildToolSchemaKeyMap(defs) {
|
|
1136
|
+
const map = new Map();
|
|
1137
|
+
for (const def of defs) {
|
|
1138
|
+
const fnNode = def && typeof def === 'object' && def.function && typeof def.function === 'object'
|
|
1139
|
+
? def.function
|
|
1140
|
+
: undefined;
|
|
1141
|
+
const name = typeof fnNode?.name === 'string'
|
|
1142
|
+
? fnNode.name
|
|
1143
|
+
: typeof def?.name === 'string'
|
|
1144
|
+
? String(def.name)
|
|
1145
|
+
: '';
|
|
1146
|
+
if (!name || !name.trim())
|
|
1147
|
+
continue;
|
|
1148
|
+
const parameters = (fnNode && fnNode.parameters) ??
|
|
1149
|
+
(def.parameters);
|
|
1150
|
+
if (!isPlainRecord(parameters))
|
|
1151
|
+
continue;
|
|
1152
|
+
const props = parameters.properties;
|
|
1153
|
+
if (!isPlainRecord(props))
|
|
1154
|
+
continue;
|
|
1155
|
+
const keys = Object.keys(props).filter((k) => typeof k === 'string' && k.trim().length > 0);
|
|
1156
|
+
if (!keys.length)
|
|
1157
|
+
continue;
|
|
1158
|
+
map.set(name, new Set(keys));
|
|
1159
|
+
}
|
|
1160
|
+
return map;
|
|
1161
|
+
}
|
|
1162
|
+
function alignToolCallArgsToSchema(options) {
|
|
1163
|
+
const name = typeof options.toolName === 'string' ? options.toolName.trim() : '';
|
|
1164
|
+
if (!name)
|
|
1165
|
+
return options.args;
|
|
1166
|
+
const schema = options.schemaKeys.get(name);
|
|
1167
|
+
if (!schema || schema.size === 0) {
|
|
1168
|
+
return options.args;
|
|
1169
|
+
}
|
|
1170
|
+
if (!isPlainRecord(options.args)) {
|
|
1171
|
+
return options.args;
|
|
1172
|
+
}
|
|
1173
|
+
const lowered = name.toLowerCase();
|
|
1174
|
+
const next = { ...options.args };
|
|
1175
|
+
// Align historical Codex tool args to the *declared schema* for Gemini.
|
|
1176
|
+
// Gemini validates historical functionCall.args against tool declarations, so mismatches like:
|
|
1177
|
+
// - exec_command: { cmd } vs schema { command } (or vice-versa)
|
|
1178
|
+
// - apply_patch: { patch/input } vs schema { instructions } (or vice-versa)
|
|
1179
|
+
// can cause MALFORMED_FUNCTION_CALL and empty responses.
|
|
1180
|
+
if (lowered === 'exec_command') {
|
|
1181
|
+
// Prefer the declared schema key; do not delete keys blindly.
|
|
1182
|
+
if (schema.has('cmd') && !Object.prototype.hasOwnProperty.call(next, 'cmd') && Object.prototype.hasOwnProperty.call(next, 'command')) {
|
|
1183
|
+
next.cmd = next.command;
|
|
1184
|
+
}
|
|
1185
|
+
if (schema.has('command') && !Object.prototype.hasOwnProperty.call(next, 'command') && Object.prototype.hasOwnProperty.call(next, 'cmd')) {
|
|
1186
|
+
next.command = next.cmd;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
else if (lowered === 'write_stdin') {
|
|
1190
|
+
if (schema.has('chars') && !Object.prototype.hasOwnProperty.call(next, 'chars') && Object.prototype.hasOwnProperty.call(next, 'text')) {
|
|
1191
|
+
next.chars = next.text;
|
|
1192
|
+
}
|
|
1193
|
+
if (schema.has('text') && !Object.prototype.hasOwnProperty.call(next, 'text') && Object.prototype.hasOwnProperty.call(next, 'chars')) {
|
|
1194
|
+
next.text = next.chars;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
else if (lowered === 'apply_patch') {
|
|
1198
|
+
if (schema.has('instructions') && !Object.prototype.hasOwnProperty.call(next, 'instructions')) {
|
|
1199
|
+
const patch = typeof next.patch === 'string' ? next.patch : undefined;
|
|
1200
|
+
const input = typeof next.input === 'string' ? next.input : undefined;
|
|
1201
|
+
const candidate = patch && patch.trim().length ? patch : input && input.trim().length ? input : undefined;
|
|
1202
|
+
if (candidate) {
|
|
1203
|
+
next.instructions = candidate;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
if (schema.has('patch') && !Object.prototype.hasOwnProperty.call(next, 'patch')) {
|
|
1207
|
+
const input = typeof next.input === 'string' ? next.input : undefined;
|
|
1208
|
+
if (input && input.trim().length) {
|
|
1209
|
+
next.patch = input;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
// Prune to schema keys for known Codex tools to reduce strict upstream validation failures.
|
|
1214
|
+
if (lowered === 'exec_command' || lowered === 'write_stdin' || lowered === 'apply_patch') {
|
|
1215
|
+
const pruned = {};
|
|
1216
|
+
for (const key of schema) {
|
|
1217
|
+
if (Object.prototype.hasOwnProperty.call(next, key)) {
|
|
1218
|
+
pruned[key] = next[key];
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
return pruned;
|
|
1222
|
+
}
|
|
1223
|
+
return next;
|
|
1224
|
+
}
|
|
1225
|
+
function buildGenerationConfigFromParameters(parameters) {
|
|
1226
|
+
const config = {};
|
|
1227
|
+
for (const { source, target } of GENERATION_CONFIG_KEYS) {
|
|
1228
|
+
const value = parameters[target] ?? (target === 'max_output_tokens' ? parameters.max_tokens : undefined);
|
|
1229
|
+
if (value !== undefined) {
|
|
1230
|
+
config[source] = value;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
const reasoningRaw = parameters.reasoning;
|
|
1234
|
+
const applyThinkingDisabled = () => {
|
|
1235
|
+
config.thinkingConfig = {
|
|
1236
|
+
includeThoughts: false,
|
|
1237
|
+
thinkingBudget: 0
|
|
1238
|
+
};
|
|
1239
|
+
};
|
|
1240
|
+
const applyThinkingEnabled = (budget) => {
|
|
1241
|
+
const next = {
|
|
1242
|
+
includeThoughts: true
|
|
1243
|
+
};
|
|
1244
|
+
if (typeof budget === 'number' && Number.isFinite(budget) && budget > 0) {
|
|
1245
|
+
next.thinkingBudget = Math.floor(budget);
|
|
1246
|
+
}
|
|
1247
|
+
config.thinkingConfig = next;
|
|
1248
|
+
};
|
|
1249
|
+
if (typeof reasoningRaw === 'boolean') {
|
|
1250
|
+
if (reasoningRaw) {
|
|
1251
|
+
applyThinkingEnabled();
|
|
1252
|
+
}
|
|
1253
|
+
else {
|
|
1254
|
+
applyThinkingDisabled();
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
else if (typeof reasoningRaw === 'string') {
|
|
1258
|
+
const normalized = reasoningRaw.trim().toLowerCase();
|
|
1259
|
+
if (normalized === 'off' || normalized === 'none' || normalized === 'disabled' || normalized === 'false') {
|
|
1260
|
+
applyThinkingDisabled();
|
|
1261
|
+
}
|
|
1262
|
+
else if (normalized.length) {
|
|
1263
|
+
const effortBudget = {
|
|
1264
|
+
minimal: 1024,
|
|
1265
|
+
low: 1024,
|
|
1266
|
+
medium: 4096,
|
|
1267
|
+
high: 8192
|
|
1268
|
+
};
|
|
1269
|
+
applyThinkingEnabled(effortBudget[normalized]);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
else if (typeof reasoningRaw === 'number' && Number.isFinite(reasoningRaw)) {
|
|
1273
|
+
if (reasoningRaw <= 0) {
|
|
1274
|
+
applyThinkingDisabled();
|
|
1275
|
+
}
|
|
1276
|
+
else {
|
|
1277
|
+
applyThinkingEnabled(reasoningRaw);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
else if (isJsonObject(reasoningRaw)) {
|
|
1281
|
+
const node = reasoningRaw;
|
|
1282
|
+
const enabled = node.enabled;
|
|
1283
|
+
if (enabled === false) {
|
|
1284
|
+
applyThinkingDisabled();
|
|
1285
|
+
}
|
|
1286
|
+
else {
|
|
1287
|
+
const effort = typeof node.effort === 'string'
|
|
1288
|
+
? node.effort.trim().toLowerCase()
|
|
1289
|
+
: typeof node.level === 'string'
|
|
1290
|
+
? node.level.trim().toLowerCase()
|
|
1291
|
+
: '';
|
|
1292
|
+
const budget = typeof node.budget_tokens === 'number'
|
|
1293
|
+
? node.budget_tokens
|
|
1294
|
+
: typeof node.budget === 'number'
|
|
1295
|
+
? node.budget
|
|
1296
|
+
: typeof node.max_tokens === 'number'
|
|
1297
|
+
? node.max_tokens
|
|
1298
|
+
: undefined;
|
|
1299
|
+
if (typeof budget === 'number' && Number.isFinite(budget)) {
|
|
1300
|
+
if (budget <= 0) {
|
|
1301
|
+
applyThinkingDisabled();
|
|
1302
|
+
}
|
|
1303
|
+
else {
|
|
1304
|
+
applyThinkingEnabled(budget);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
else if (effort === 'off' || effort === 'none' || effort === 'disabled') {
|
|
1308
|
+
applyThinkingDisabled();
|
|
1309
|
+
}
|
|
1310
|
+
else if (effort.length) {
|
|
1311
|
+
const effortBudget = {
|
|
1312
|
+
minimal: 1024,
|
|
1313
|
+
low: 1024,
|
|
1314
|
+
medium: 4096,
|
|
1315
|
+
high: 8192
|
|
1316
|
+
};
|
|
1317
|
+
applyThinkingEnabled(effortBudget[effort]);
|
|
1318
|
+
}
|
|
1319
|
+
else if (enabled === true) {
|
|
1320
|
+
applyThinkingEnabled();
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
return config;
|
|
1325
|
+
}
|
|
1326
|
+
function mapChatRoleToGemini(role) {
|
|
1327
|
+
const r = role.toLowerCase();
|
|
1328
|
+
if (r === 'assistant')
|
|
1329
|
+
return 'model';
|
|
1330
|
+
if (r === 'system')
|
|
1331
|
+
return 'system';
|
|
1332
|
+
if (r === 'tool')
|
|
1333
|
+
return 'tool';
|
|
1334
|
+
return 'user';
|
|
1335
|
+
}
|
|
1336
|
+
function safeParseJson(value) {
|
|
1337
|
+
try {
|
|
1338
|
+
return JSON.parse(value);
|
|
1339
|
+
}
|
|
1340
|
+
catch {
|
|
1341
|
+
return value;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
function ensureFunctionResponsePayload(value) {
|
|
1345
|
+
// Gemini function_response.response 字段在 CloudCode/Gemini CLI 协议里对应的是
|
|
1346
|
+
// protobuf Struct(JSON object),而不是顶层数组。
|
|
1347
|
+
// 这里做一层规范化:
|
|
1348
|
+
// - 对象:直接透传;
|
|
1349
|
+
// - 数组:包一层 { result: [...] } 避免把数组作为 Struct 根节点;
|
|
1350
|
+
// - 原始值:包一层 { result: value },并把 undefined 映射为 null。
|
|
1351
|
+
if (value && typeof value === 'object') {
|
|
1352
|
+
if (Array.isArray(value)) {
|
|
1353
|
+
return {
|
|
1354
|
+
result: value
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
return value;
|
|
1358
|
+
}
|
|
1359
|
+
return {
|
|
1360
|
+
result: value === undefined ? null : value
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
function cloneAsJsonValue(value) {
|
|
1364
|
+
try {
|
|
1365
|
+
return JSON.parse(JSON.stringify(value ?? null));
|
|
1366
|
+
}
|
|
1367
|
+
catch {
|
|
1368
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' || value === null) {
|
|
1369
|
+
return value;
|
|
1370
|
+
}
|
|
1371
|
+
if (Array.isArray(value)) {
|
|
1372
|
+
return value.map((entry) => cloneAsJsonValue(entry));
|
|
1373
|
+
}
|
|
1374
|
+
if (value && typeof value === 'object') {
|
|
1375
|
+
const out = {};
|
|
1376
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
1377
|
+
out[key] = cloneAsJsonValue(entry);
|
|
1378
|
+
}
|
|
1379
|
+
return out;
|
|
1380
|
+
}
|
|
1381
|
+
return String(value ?? '');
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
function isResponsesOrigin(chat) {
|
|
1385
|
+
const semantics = chat?.semantics;
|
|
1386
|
+
if (semantics && semantics.responses && isJsonObject(semantics.responses)) {
|
|
1387
|
+
return true;
|
|
1388
|
+
}
|
|
1389
|
+
const ctx = chat?.metadata && typeof chat.metadata === 'object'
|
|
1390
|
+
? chat.metadata.context
|
|
1391
|
+
: undefined;
|
|
1392
|
+
const protocol = typeof ctx?.providerProtocol === 'string' ? ctx.providerProtocol.trim().toLowerCase() : '';
|
|
1393
|
+
if (protocol === 'openai-responses') {
|
|
1394
|
+
return true;
|
|
1395
|
+
}
|
|
1396
|
+
const endpoint = typeof ctx?.entryEndpoint === 'string' ? ctx.entryEndpoint.trim().toLowerCase() : '';
|
|
1397
|
+
return endpoint === '/v1/responses';
|
|
1398
|
+
}
|
|
1399
|
+
function appendMappingAudit(chat, options) {
|
|
1400
|
+
const metadata = chat.metadata && typeof chat.metadata === 'object'
|
|
1401
|
+
? chat.metadata
|
|
1402
|
+
: (chat.metadata = { context: chat.metadata?.context ?? {} });
|
|
1403
|
+
const root = metadata.mappingAudit && typeof metadata.mappingAudit === 'object' && !Array.isArray(metadata.mappingAudit)
|
|
1404
|
+
? metadata.mappingAudit
|
|
1405
|
+
: (metadata.mappingAudit = {});
|
|
1406
|
+
const current = Array.isArray(root[options.bucket]) ? root[options.bucket] : [];
|
|
1407
|
+
const duplicate = current.find((entry) => entry &&
|
|
1408
|
+
entry.field === options.field &&
|
|
1409
|
+
entry.targetProtocol === options.targetProtocol &&
|
|
1410
|
+
entry.reason === options.reason);
|
|
1411
|
+
if (!duplicate) {
|
|
1412
|
+
current.push({
|
|
1413
|
+
field: options.field,
|
|
1414
|
+
source: options.source ?? 'chat.parameters',
|
|
1415
|
+
targetProtocol: options.targetProtocol,
|
|
1416
|
+
reason: options.reason
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
root[options.bucket] = current;
|
|
1420
|
+
}
|
|
1421
|
+
function appendDroppedFieldAudit(chat, options) {
|
|
1422
|
+
appendMappingAudit(chat, {
|
|
1423
|
+
bucket: 'dropped',
|
|
1424
|
+
...options
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
function appendLossyFieldAudit(chat, options) {
|
|
1428
|
+
appendMappingAudit(chat, {
|
|
1429
|
+
bucket: 'lossy',
|
|
1430
|
+
...options
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
export class GeminiSemanticMapper {
|
|
1434
|
+
async toChat(format, ctx) {
|
|
1435
|
+
const payload = (format.payload ?? {});
|
|
1436
|
+
const missing = [];
|
|
1437
|
+
const { messages: builtMessages } = buildOpenAIChatFromGeminiRequest(payload);
|
|
1438
|
+
let messages = Array.isArray(builtMessages) ? builtMessages : [];
|
|
1439
|
+
if (!Array.isArray(payload.contents)) {
|
|
1440
|
+
missing.push({ path: 'contents', reason: 'absent' });
|
|
1441
|
+
}
|
|
1442
|
+
const bridgeTools = prepareGeminiToolsForBridge(payload.tools, missing);
|
|
1443
|
+
const tools = bridgeTools ? mapBridgeToolsToChat(bridgeTools) : undefined;
|
|
1444
|
+
let parameters = collectParameters(payload);
|
|
1445
|
+
const metadata = { context: ctx };
|
|
1446
|
+
const systemSegments = collectSystemSegments(payload.systemInstruction);
|
|
1447
|
+
if (payload.systemInstruction !== undefined) {
|
|
1448
|
+
const rawSystem = jsonClone(payload.systemInstruction);
|
|
1449
|
+
ensureProtocolState(metadata, 'gemini').systemInstruction = rawSystem;
|
|
1450
|
+
}
|
|
1451
|
+
if (missing.length) {
|
|
1452
|
+
metadata.missingFields = missing;
|
|
1453
|
+
}
|
|
1454
|
+
const toolOutputs = normalizeToolOutputs(messages, missing);
|
|
1455
|
+
const passthrough = extractMetadataPassthrough(payload.metadata, {
|
|
1456
|
+
prefix: PASSTHROUGH_METADATA_PREFIX,
|
|
1457
|
+
keys: PASSTHROUGH_PARAMETERS
|
|
1458
|
+
});
|
|
1459
|
+
if (passthrough.passthrough) {
|
|
1460
|
+
parameters = { ...(parameters || {}), ...passthrough.passthrough };
|
|
1461
|
+
}
|
|
1462
|
+
const providerMetadataSource = passthrough.metadata ?? payload.metadata;
|
|
1463
|
+
let providerMetadata;
|
|
1464
|
+
let explicitEmptyTools = Array.isArray(payload.tools) && payload.tools.length === 0;
|
|
1465
|
+
if (providerMetadataSource) {
|
|
1466
|
+
const cloned = jsonClone(providerMetadataSource);
|
|
1467
|
+
let toolsFieldPresent = false;
|
|
1468
|
+
if (isJsonObject(cloned)) {
|
|
1469
|
+
delete cloned.__rcc_stream;
|
|
1470
|
+
if (Object.prototype.hasOwnProperty.call(cloned, '__rcc_tools_field_present')) {
|
|
1471
|
+
const sentinel = cloned.__rcc_tools_field_present;
|
|
1472
|
+
toolsFieldPresent = sentinel === '1' || sentinel === true;
|
|
1473
|
+
delete cloned.__rcc_tools_field_present;
|
|
1474
|
+
}
|
|
1475
|
+
if (Object.prototype.hasOwnProperty.call(cloned, '__rcc_raw_system')) {
|
|
1476
|
+
delete cloned.__rcc_raw_system;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
if (toolsFieldPresent) {
|
|
1480
|
+
explicitEmptyTools = true;
|
|
1481
|
+
}
|
|
1482
|
+
providerMetadata = cloned;
|
|
1483
|
+
metadata.providerMetadata = providerMetadata;
|
|
1484
|
+
}
|
|
1485
|
+
const chatEnvelope = {
|
|
1486
|
+
messages,
|
|
1487
|
+
tools,
|
|
1488
|
+
toolOutputs,
|
|
1489
|
+
parameters,
|
|
1490
|
+
metadata
|
|
1491
|
+
};
|
|
1492
|
+
if (systemSegments.length) {
|
|
1493
|
+
const systemNode = ensureSystemSemantics(chatEnvelope);
|
|
1494
|
+
systemNode.textBlocks = systemSegments.map((segment) => segment);
|
|
1495
|
+
}
|
|
1496
|
+
let semanticsNode;
|
|
1497
|
+
const ensureSemanticsNode = () => {
|
|
1498
|
+
semanticsNode = semanticsNode ?? ensureGeminiSemanticsNode(chatEnvelope);
|
|
1499
|
+
return semanticsNode;
|
|
1500
|
+
};
|
|
1501
|
+
if (payload.systemInstruction !== undefined) {
|
|
1502
|
+
ensureSemanticsNode().systemInstruction = jsonClone(payload.systemInstruction);
|
|
1503
|
+
}
|
|
1504
|
+
if (payload.safetySettings) {
|
|
1505
|
+
ensureSemanticsNode().safetySettings = jsonClone(payload.safetySettings);
|
|
1506
|
+
}
|
|
1507
|
+
if (payload.generationConfig && isJsonObject(payload.generationConfig)) {
|
|
1508
|
+
ensureSemanticsNode().generationConfig = jsonClone(payload.generationConfig);
|
|
1509
|
+
}
|
|
1510
|
+
if (payload.toolConfig && isJsonObject(payload.toolConfig)) {
|
|
1511
|
+
ensureSemanticsNode().toolConfig = jsonClone(payload.toolConfig);
|
|
1512
|
+
}
|
|
1513
|
+
if (providerMetadata) {
|
|
1514
|
+
ensureSemanticsNode().providerMetadata = jsonClone(providerMetadata);
|
|
1515
|
+
}
|
|
1516
|
+
if (explicitEmptyTools) {
|
|
1517
|
+
markGeminiExplicitEmptyTools(chatEnvelope);
|
|
1518
|
+
}
|
|
1519
|
+
return chatEnvelope;
|
|
1520
|
+
}
|
|
1521
|
+
async fromChat(chat, ctx) {
|
|
1522
|
+
const requestId = typeof ctx.requestId === 'string' && ctx.requestId.trim().length ? ctx.requestId : 'unknown';
|
|
1523
|
+
const forceDetailLog = isHubStageTimingDetailEnabled();
|
|
1524
|
+
logHubStageTiming(requestId, 'req_outbound.gemini.build_request', 'start');
|
|
1525
|
+
const startedAt = Date.now();
|
|
1526
|
+
const envelopePayload = buildGeminiRequestFromChat(chat, chat.metadata);
|
|
1527
|
+
logHubStageTiming(requestId, 'req_outbound.gemini.build_request', 'completed', {
|
|
1528
|
+
elapsedMs: Date.now() - startedAt,
|
|
1529
|
+
forceLog: forceDetailLog
|
|
1530
|
+
});
|
|
1531
|
+
return {
|
|
1532
|
+
protocol: 'gemini-chat',
|
|
1533
|
+
direction: 'response',
|
|
1534
|
+
payload: envelopePayload,
|
|
1535
|
+
meta: {
|
|
1536
|
+
context: ctx
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
}
|