@jsonstudio/llms 0.6.2172 → 0.6.2979
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/conversion/compat/antigravity-session-signature.js +35 -1
- package/dist/conversion/compat/profiles/chat-gemini-cli.json +0 -7
- package/dist/conversion/compat/profiles/chat-gemini.json +0 -6
- package/dist/conversion/hub/core/detour-registry.d.ts +2 -0
- package/dist/conversion/hub/core/hub-context.d.ts +3 -1
- package/dist/conversion/hub/core/index.d.ts +1 -0
- package/dist/conversion/hub/core/stage-driver.js +2 -0
- package/dist/conversion/hub/format-adapters/anthropic-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/chat-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/gemini-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/responses-format-adapter.js +15 -4
- package/dist/conversion/hub/hub-feature.js +3 -2
- package/dist/conversion/hub/node-support.js +9 -4
- package/dist/conversion/hub/operation-table/operation-table-runner.js +10 -6
- package/dist/conversion/hub/operation-table/semantic-mappers/anthropic-mapper.js +2 -2
- package/dist/conversion/hub/operation-table/semantic-mappers/chat-mapper.js +10 -10
- package/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.js +4 -8
- package/dist/conversion/hub/operation-table/semantic-mappers/responses-mapper.js +19 -65
- package/dist/conversion/hub/ops/operations.js +2 -121
- package/dist/conversion/hub/pipeline/compat/compat-engine.js +6 -0
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.d.ts +1 -1
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +33 -1042
- package/dist/conversion/hub/pipeline/compat/compat-profile-resolver.js +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-profile-store.js +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-types.d.ts +14 -17
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.d.ts +3 -0
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.js +39 -0
- package/dist/conversion/hub/pipeline/hub-pipeline.js +115 -262
- package/dist/conversion/hub/pipeline/session-identifiers.js +6 -196
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.js +37 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.js +12 -86
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.d.ts +14 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.js +24 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.d.ts +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.js +157 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.d.ts +16 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.js +29 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-factories.js +3 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.d.ts +2 -15
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.js +8 -595
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.d.ts +8 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.js +28 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.d.ts +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.js +4 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.d.ts +10 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.js +12 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.js +30 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/index.js +9 -129
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.d.ts +1 -4
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.js +9 -26
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +32 -14
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.d.ts +2 -2
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.js +48 -8
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage2_route_select/index.js +18 -3
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/index.js +10 -198
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.js +81 -0
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.js +36 -1
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage3_semantic_map/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.d.ts +6 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.js +17 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.d.ts +9 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.js +28 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.js +14 -102
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage2_sse_stream/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage1_tool_governance/index.js +12 -10
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage2_finalize/index.js +6 -5
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.d.ts +11 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.js +10 -32
- package/dist/conversion/hub/pipeline/stages/utils.js +17 -1
- package/dist/conversion/hub/pipeline/target-utils.js +14 -91
- package/dist/conversion/hub/pipelines/inbound.js +3 -1
- package/dist/conversion/hub/pipelines/outbound.js +2 -0
- package/dist/conversion/hub/policy/policy-engine.js +9 -3
- package/dist/conversion/hub/policy/protocol-spec.js +20 -148
- package/dist/conversion/hub/process/chat-process-anthropic-alias.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-anthropic-alias.js +36 -0
- package/dist/conversion/hub/process/chat-process-clock-directive-parser.d.ts +5 -0
- package/dist/conversion/hub/process/chat-process-clock-directive-parser.js +48 -0
- package/dist/conversion/hub/process/chat-process-clock-directives.d.ts +24 -0
- package/dist/conversion/hub/process/chat-process-clock-directives.js +98 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-directives.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-directives.js +42 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-finalize.d.ts +14 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-finalize.js +10 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-messages.d.ts +5 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-messages.js +10 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.d.ts +30 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.js +68 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.d.ts +9 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.js +18 -0
- package/dist/conversion/hub/process/chat-process-clock-reminders.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-clock-reminders.js +104 -0
- package/dist/conversion/hub/process/chat-process-clock-tool-schemas.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-clock-tool-schemas.js +233 -0
- package/dist/conversion/hub/process/chat-process-clock-tools.d.ts +6 -0
- package/dist/conversion/hub/process/chat-process-clock-tools.js +41 -0
- package/dist/conversion/hub/process/chat-process-continue-execution.d.ts +11 -0
- package/dist/conversion/hub/process/chat-process-continue-execution.js +82 -0
- package/dist/conversion/hub/process/chat-process-governance-context.d.ts +15 -0
- package/dist/conversion/hub/process/chat-process-governance-context.js +7 -0
- package/dist/conversion/hub/process/chat-process-governance-finalize.d.ts +16 -0
- package/dist/conversion/hub/process/chat-process-governance-finalize.js +11 -0
- package/dist/conversion/hub/process/chat-process-governance-orchestration.d.ts +9 -0
- package/dist/conversion/hub/process/chat-process-governance-orchestration.js +47 -0
- package/dist/conversion/hub/process/chat-process-governed-control-ops.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-governed-control-ops.js +5 -0
- package/dist/conversion/hub/process/chat-process-governed-filter-call.d.ts +12 -0
- package/dist/conversion/hub/process/chat-process-governed-filter-call.js +18 -0
- package/dist/conversion/hub/process/chat-process-governed-merge.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-governed-merge.js +11 -0
- package/dist/conversion/hub/process/chat-process-media.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-media.js +18 -0
- package/dist/conversion/hub/process/chat-process-node-result.d.ts +23 -0
- package/dist/conversion/hub/process/chat-process-node-result.js +24 -0
- package/dist/conversion/hub/process/chat-process-pending-tool-sync.d.ts +14 -0
- package/dist/conversion/hub/process/chat-process-pending-tool-sync.js +52 -0
- package/dist/conversion/hub/process/chat-process-post-governed-normalization.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-post-governed-normalization.js +16 -0
- package/dist/conversion/hub/process/chat-process-review.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-review.js +8 -0
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.js +22 -0
- package/dist/conversion/hub/process/chat-process-tool-normalization.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-tool-normalization.js +4 -0
- package/dist/conversion/hub/process/chat-process-web-search-intent.d.ts +12 -0
- package/dist/conversion/hub/process/chat-process-web-search-intent.js +13 -0
- package/dist/conversion/hub/process/chat-process-web-search-tool-schema.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-web-search-tool-schema.js +4 -0
- package/dist/conversion/hub/process/chat-process-web-search.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-web-search.js +26 -0
- package/dist/conversion/hub/process/chat-process.d.ts +2 -19
- package/dist/conversion/hub/process/chat-process.js +12 -1701
- package/dist/conversion/hub/process/client-inject-readiness.d.ts +1 -0
- package/dist/conversion/hub/process/client-inject-readiness.js +4 -0
- package/dist/conversion/hub/registry.js +5 -2
- package/dist/conversion/hub/response/chat-response-utils.js +5 -86
- package/dist/conversion/hub/response/provider-response.d.ts +9 -0
- package/dist/conversion/hub/response/provider-response.js +6 -21
- package/dist/conversion/hub/response/response-mappers.js +2 -26
- package/dist/conversion/hub/response/response-runtime.js +2 -93
- package/dist/conversion/hub/semantic-mappers/anthropic-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/anthropic-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/chat-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/chat-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/gemini-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/gemini-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/responses-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/responses-mapper.js +1 -0
- package/dist/conversion/hub/snapshot-recorder.js +10 -3
- package/dist/conversion/hub/standardized-bridge.js +11 -288
- package/dist/conversion/hub/tool-governance/engine.js +5 -0
- package/dist/conversion/hub/tool-governance/rules.js +10 -10
- package/dist/conversion/hub/tool-session-compat.d.ts +2 -2
- package/dist/conversion/hub/tool-session-compat.js +17 -231
- package/dist/conversion/hub/tool-surface/tool-surface-engine.js +5 -3
- package/dist/conversion/responses/responses-host-policy.js +2 -12
- package/dist/conversion/responses/responses-openai-bridge/response-payload.js +6 -82
- package/dist/conversion/responses/responses-openai-bridge/types.d.ts +1 -0
- package/dist/conversion/responses/responses-openai-bridge.js +21 -54
- package/dist/conversion/shared/anthropic-message-utils.js +151 -13
- package/dist/conversion/shared/args-mapping.js +2 -146
- package/dist/conversion/shared/bridge-actions.js +203 -718
- package/dist/conversion/shared/bridge-id-utils.js +5 -71
- package/dist/conversion/shared/bridge-instructions.js +2 -1
- package/dist/conversion/shared/bridge-message-types.d.ts +2 -0
- package/dist/conversion/shared/bridge-message-utils.js +1 -2
- package/dist/conversion/shared/bridge-metadata.d.ts +1 -0
- package/dist/conversion/shared/bridge-metadata.js +4 -0
- package/dist/conversion/shared/bridge-policies.js +5 -189
- package/dist/conversion/shared/chat-envelope-validator.js +2 -126
- package/dist/conversion/shared/chat-output-normalizer.js +2 -54
- package/dist/conversion/shared/compaction-detect.js +2 -57
- package/dist/conversion/shared/gemini-tool-utils.js +9 -524
- package/dist/conversion/shared/jsonish.js +3 -160
- package/dist/conversion/shared/mcp-injection.js +3 -169
- package/dist/conversion/shared/media.js +2 -7
- package/dist/conversion/shared/metadata-passthrough.js +9 -46
- package/dist/conversion/shared/openai-finalizer.js +2 -1
- package/dist/conversion/shared/openai-message-normalize.js +11 -283
- package/dist/conversion/shared/output-content-normalizer.js +9 -112
- package/dist/conversion/shared/payload-budget.js +2 -85
- package/dist/conversion/shared/protocol-state.js +11 -7
- package/dist/conversion/shared/reasoning-mapping.js +2 -6
- package/dist/conversion/shared/reasoning-normalizer.js +4 -1
- package/dist/conversion/shared/reasoning-tool-normalizer.js +14 -126
- package/dist/conversion/shared/reasoning-tool-parser.js +4 -87
- package/dist/conversion/shared/reasoning-utils.js +2 -6
- package/dist/conversion/shared/responses-conversation-store.js +4 -82
- package/dist/conversion/shared/responses-output-builder.js +11 -47
- package/dist/conversion/shared/responses-reasoning-registry.js +7 -1
- package/dist/conversion/shared/responses-request-adapter.d.ts +7 -1
- package/dist/conversion/shared/responses-request-adapter.js +14 -1
- package/dist/conversion/shared/responses-response-utils.js +6 -7
- package/dist/conversion/shared/responses-tool-utils.d.ts +1 -0
- package/dist/conversion/shared/responses-tool-utils.js +90 -14
- package/dist/conversion/shared/runtime-metadata.js +13 -5
- package/dist/conversion/shared/streaming-text-extractor.js +2 -7
- package/dist/conversion/shared/text-markup-normalizer/normalize.d.ts +1 -1
- package/dist/conversion/shared/text-markup-normalizer/normalize.js +43 -17
- package/dist/conversion/shared/text-markup-normalizer.d.ts +1 -0
- package/dist/conversion/shared/text-markup-normalizer.js +1 -0
- package/dist/conversion/shared/thought-signature-validator.js +3 -2
- package/dist/conversion/shared/tool-argument-repairer.js +2 -2
- package/dist/conversion/shared/tool-call-id-manager.js +5 -7
- package/dist/conversion/shared/tool-call-utils.js +3 -45
- package/dist/conversion/shared/tool-canonicalizer.js +25 -29
- package/dist/conversion/shared/tool-filter-pipeline.js +4 -99
- package/dist/conversion/shared/tool-governor.d.ts +6 -0
- package/dist/conversion/shared/tool-governor.js +43 -125
- package/dist/conversion/shared/tool-harvester.js +2 -8
- package/dist/conversion/shared/tool-mapping.js +2 -5
- package/dist/conversion/shared/tooling.d.ts +0 -4
- package/dist/conversion/shared/tooling.js +18 -0
- package/dist/native/router_hotpath_napi.node +0 -0
- package/dist/router/virtual-router/engine/provider-key/parse.d.ts +1 -6
- package/dist/router/virtual-router/engine/provider-key/parse.js +1 -43
- package/dist/router/virtual-router/engine/routing-state/store.js +48 -12
- package/dist/router/virtual-router/engine-logging.js +4 -3
- package/dist/router/virtual-router/engine-selection/alias-selection.js +45 -83
- package/dist/router/virtual-router/engine-selection/key-parsing.js +9 -23
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.d.ts +20 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.js +163 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.d.ts +7 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.js +103 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.js +110 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.d.ts +8 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.js +281 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.js +25 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.d.ts +4 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.js +44 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.js +62 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.d.ts +40 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.js +484 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.d.ts +9 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.js +64 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.js +163 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.js +49 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.d.ts +30 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.js +446 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.js +49 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.d.ts +134 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js +729 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.d.ts +62 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.js +338 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.d.ts +18 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js +317 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.d.ts +22 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.js +426 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.d.ts +57 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.js +705 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.d.ts +46 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js +503 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.d.ts +146 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js +570 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.js +148 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.js +637 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.d.ts +11 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.js +207 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.d.ts +3 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.js +128 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.d.ts +57 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.js +217 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.js +284 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.js +18 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.js +85 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath.d.ts +59 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath.js +117 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.d.ts +76 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.js +1166 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.d.ts +16 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.js +96 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.d.ts +6 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.js +85 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.d.ts +9 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.js +70 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.js +76 -0
- package/dist/router/virtual-router/engine-selection/route-utils.js +1 -1
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.js +231 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.d.ts +4 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.js +43 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.d.ts +27 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.js +116 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-select.d.ts +1 -1
- package/dist/router/virtual-router/engine-selection/tier-selection-select.js +29 -129
- package/dist/router/virtual-router/engine-selection/tier-selection.js +2 -265
- package/dist/router/virtual-router/engine.js +258 -249
- package/dist/router/virtual-router/features.js +2 -2
- package/dist/router/virtual-router/routing-instructions.d.ts +5 -7
- package/dist/router/virtual-router/routing-instructions.js +93 -66
- package/dist/router/virtual-router/routing-stop-message-actions.js +91 -112
- package/dist/router/virtual-router/routing-stop-message-parser.js +9 -132
- package/dist/router/virtual-router/routing-stop-message-state-codec.d.ts +1 -0
- package/dist/router/virtual-router/routing-stop-message-state-codec.js +58 -71
- package/dist/router/virtual-router/sticky-session-store.js +4 -2
- package/dist/router/virtual-router/stop-message-file-resolver.d.ts +1 -0
- package/dist/router/virtual-router/stop-message-file-resolver.js +10 -0
- package/dist/router/virtual-router/stop-message-state-sync.d.ts +1 -1
- package/dist/router/virtual-router/stop-message-state-sync.js +3 -7
- package/dist/router/virtual-router/token-counter.js +0 -9
- package/dist/router/virtual-router/types.d.ts +9 -7
- package/dist/servertool/clock/config.js +23 -51
- package/dist/servertool/clock/io.js +1 -0
- package/dist/servertool/clock/session-scope.d.ts +2 -2
- package/dist/servertool/clock/session-scope.js +5 -47
- package/dist/servertool/engine.d.ts +9 -0
- package/dist/servertool/engine.js +196 -79
- package/dist/servertool/handlers/antigravity-thought-signature-bootstrap.js +2 -2
- package/dist/servertool/handlers/clock.js +1 -1
- package/dist/servertool/handlers/continue-execution.js +8 -4
- package/dist/servertool/handlers/followup-request-builder.js +18 -1
- package/dist/servertool/handlers/gemini-empty-reply-continue.js +7 -1
- package/dist/servertool/handlers/review.js +180 -0
- package/dist/servertool/handlers/stop-message-auto/blocked-report.js +59 -1
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.d.ts +23 -2
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.js +397 -89
- package/dist/servertool/handlers/stop-message-auto/routing-state.d.ts +5 -15
- package/dist/servertool/handlers/stop-message-auto/routing-state.js +29 -55
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.d.ts +6 -0
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.js +35 -61
- package/dist/servertool/handlers/stop-message-auto.js +392 -76
- package/dist/servertool/server-side-tools.d.ts +1 -0
- package/dist/servertool/server-side-tools.js +90 -52
- package/dist/servertool/types.d.ts +17 -0
- package/dist/tools/apply-patch/patch-text/normalize.js +11 -0
- package/dist/tools/exec-command/validator.d.ts +4 -1
- package/dist/tools/exec-command/validator.js +87 -3
- package/dist/tools/tool-registry.d.ts +7 -1
- package/dist/tools/tool-registry.js +3 -2
- package/package.json +115 -7
- package/dist/servertool/handlers/stop-message-stage-policy/bd-runtime.d.ts +0 -18
- package/dist/servertool/handlers/stop-message-stage-policy/bd-runtime.js +0 -398
- package/dist/servertool/handlers/stop-message-stage-policy/decision.d.ts +0 -9
- package/dist/servertool/handlers/stop-message-stage-policy/decision.js +0 -127
- package/dist/servertool/handlers/stop-message-stage-policy/observation.d.ts +0 -2
- package/dist/servertool/handlers/stop-message-stage-policy/observation.js +0 -179
- package/dist/servertool/handlers/stop-message-stage-policy/templates.d.ts +0 -4
- package/dist/servertool/handlers/stop-message-stage-policy/templates.js +0 -96
- package/dist/servertool/handlers/stop-message-stage-policy/text-utils.d.ts +0 -9
- package/dist/servertool/handlers/stop-message-stage-policy/text-utils.js +0 -89
- package/dist/servertool/handlers/stop-message-stage-policy/types.d.ts +0 -59
- package/dist/servertool/handlers/stop-message-stage-policy.d.ts +0 -3
- package/dist/servertool/handlers/stop-message-stage-policy.js +0 -2
- /package/dist/servertool/handlers/{stop-message-stage-policy/types.js → review.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
|
|
24
24
|
👉 **ServerTool 是所有 server-side 工具的唯一统一框架。** web_search / vision followup 等服务端工具均在 llmswitch-core 内部通过 ServerTool 执行,Host 只需提供 providerInvoker/reenterPipeline 即可。设计与接入方式详见 `docs/SERVERTOOL_DESIGN.md`。
|
|
25
25
|
|
|
26
|
+
👉 **Rust 逐步替换门禁与 Shadow 条件**:参见 `docs/rust-migration-gates.md`。
|
|
27
|
+
|
|
26
28
|
## 总览
|
|
27
29
|
|
|
28
30
|
```
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { cacheAntigravitySessionSignatureWithNative, getAntigravityRequestSessionMetaWithNative, resetAntigravitySignatureCachesWithNative } from '../../router/virtual-router/engine-selection/native-router-hotpath.js';
|
|
4
5
|
const DUMMY_THOUGHT_SIGNATURE_SENTINEL = 'skip_thought_signature_validator';
|
|
5
6
|
// Antigravity-Manager alignment:
|
|
6
7
|
// - session_id has no time limit (continuity across long conversations / restarts)
|
|
@@ -693,7 +694,23 @@ export function getAntigravityRequestSessionMeta(requestId) {
|
|
|
693
694
|
}
|
|
694
695
|
const entry = requestSessionIds.get(rid);
|
|
695
696
|
if (!entry) {
|
|
696
|
-
|
|
697
|
+
try {
|
|
698
|
+
const nativeMeta = getAntigravityRequestSessionMetaWithNative(rid);
|
|
699
|
+
const sid = typeof nativeMeta.sessionId === 'string' ? nativeMeta.sessionId.trim() : '';
|
|
700
|
+
if (!sid) {
|
|
701
|
+
return undefined;
|
|
702
|
+
}
|
|
703
|
+
const alias = normalizeAliasKey(nativeMeta.aliasKey);
|
|
704
|
+
const messageCount = typeof nativeMeta.messageCount === 'number' && Number.isFinite(nativeMeta.messageCount) && nativeMeta.messageCount > 0
|
|
705
|
+
? Math.floor(nativeMeta.messageCount)
|
|
706
|
+
: 1;
|
|
707
|
+
const ts = nowMs();
|
|
708
|
+
requestSessionIds.set(rid, { aliasKey: alias, sessionId: sid, messageCount, timestamp: ts });
|
|
709
|
+
return { aliasKey: alias, sessionId: sid, messageCount };
|
|
710
|
+
}
|
|
711
|
+
catch {
|
|
712
|
+
return undefined;
|
|
713
|
+
}
|
|
697
714
|
}
|
|
698
715
|
const ts = nowMs();
|
|
699
716
|
if (isRequestSessionExpired(entry, ts)) {
|
|
@@ -809,6 +826,17 @@ export function cacheAntigravitySessionSignature(a, b, c, d = 1) {
|
|
|
809
826
|
maybePinAntigravitySessionToAlias(aliasKey, sessionId, ts);
|
|
810
827
|
ensureCacheLimit();
|
|
811
828
|
schedulePersistenceFlush();
|
|
829
|
+
try {
|
|
830
|
+
cacheAntigravitySessionSignatureWithNative({
|
|
831
|
+
aliasKey,
|
|
832
|
+
sessionId,
|
|
833
|
+
signature: trimmedSignature,
|
|
834
|
+
messageCount
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
catch {
|
|
838
|
+
// best-effort native sync; TS cache remains source for persistence semantics
|
|
839
|
+
}
|
|
812
840
|
}
|
|
813
841
|
function maybePinAntigravitySessionToAlias(aliasKeyInput, sessionIdInput, ts) {
|
|
814
842
|
const aliasKey = normalizeAliasKey(aliasKeyInput);
|
|
@@ -1063,6 +1091,12 @@ export function resetAntigravitySessionSignatureCachesForTests() {
|
|
|
1063
1091
|
persistence.loadedOnce = false;
|
|
1064
1092
|
persistence.loadedMtimeMs = null;
|
|
1065
1093
|
}
|
|
1094
|
+
try {
|
|
1095
|
+
resetAntigravitySignatureCachesWithNative();
|
|
1096
|
+
}
|
|
1097
|
+
catch {
|
|
1098
|
+
// best-effort
|
|
1099
|
+
}
|
|
1066
1100
|
}
|
|
1067
1101
|
export function shouldTreatAsMissingThoughtSignature(value) {
|
|
1068
1102
|
if (typeof value !== 'string') {
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
"mappings": [
|
|
6
6
|
{ "action": "snapshot", "phase": "compat-pre" },
|
|
7
7
|
{ "action": "claude_thinking_tool_schema" },
|
|
8
|
-
{ "action": "antigravity_thought_signature_prepare" },
|
|
9
|
-
{ "action": "gemini_cli_request_wrap" },
|
|
10
8
|
{
|
|
11
9
|
"action": "shallow_pick",
|
|
12
10
|
"allowTopLevel": [
|
|
@@ -21,10 +19,5 @@
|
|
|
21
19
|
},
|
|
22
20
|
{ "action": "snapshot", "phase": "compat-post" }
|
|
23
21
|
]
|
|
24
|
-
},
|
|
25
|
-
"response": {
|
|
26
|
-
"mappings": [
|
|
27
|
-
{ "action": "antigravity_thought_signature_cache" }
|
|
28
|
-
]
|
|
29
22
|
}
|
|
30
23
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
"mappings": [
|
|
6
6
|
{ "action": "snapshot", "phase": "compat-pre" },
|
|
7
7
|
{ "action": "claude_thinking_tool_schema" },
|
|
8
|
-
{ "action": "antigravity_thought_signature_prepare" },
|
|
9
8
|
{
|
|
10
9
|
"action": "gemini_web_search_request"
|
|
11
10
|
},
|
|
@@ -28,10 +27,5 @@
|
|
|
28
27
|
},
|
|
29
28
|
{ "action": "snapshot", "phase": "compat-post" }
|
|
30
29
|
]
|
|
31
|
-
},
|
|
32
|
-
"response": {
|
|
33
|
-
"mappings": [
|
|
34
|
-
{ "action": "antigravity_thought_signature_cache" }
|
|
35
|
-
]
|
|
36
30
|
}
|
|
37
31
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { DetourEntry, DetourState } from '../types/chat-schema.js';
|
|
2
2
|
import type { HubDirection } from './hub-context.js';
|
|
3
|
+
import type { NativeReqInboundSemanticLiftApplyInput } from '../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
4
|
+
export type DetourRegistryNativeEnvelope = NativeReqInboundSemanticLiftApplyInput['chatEnvelope'];
|
|
3
5
|
export declare class DetourRegistry {
|
|
4
6
|
private readonly inbound;
|
|
5
7
|
private readonly outbound;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { JsonObject, JsonValue } from '../types/json.js';
|
|
2
|
+
import type { NativeProviderProtocolToken } from '../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
2
3
|
export type HubDirection = 'inbound' | 'outbound';
|
|
4
|
+
export type HubNativeProtocolToken = NativeProviderProtocolToken;
|
|
3
5
|
export interface HubContext {
|
|
4
6
|
readonly requestId: string;
|
|
5
|
-
readonly protocol:
|
|
7
|
+
readonly protocol: HubNativeProtocolToken;
|
|
6
8
|
readonly direction: HubDirection;
|
|
7
9
|
readonly routeId?: string;
|
|
8
10
|
readonly providerId?: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './hub-context.js';
|
|
2
2
|
export * from './detour-registry.js';
|
|
3
3
|
export * from './stage-driver.js';
|
|
4
|
+
export type { NativeReqInboundSemanticLiftApplyInput as HubCoreNativeReqInboundSemanticLiftApplyInput } from '../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DetourRegistry } from './detour-registry.js';
|
|
2
2
|
import { jsonClone } from '../types/json.js';
|
|
3
|
+
import { normalizeProviderProtocolTokenWithNative } from '../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
3
4
|
function recordSnapshot(recorder, stage, ctx, payload) {
|
|
4
5
|
if (!recorder)
|
|
5
6
|
return;
|
|
@@ -12,6 +13,7 @@ function recordSnapshot(recorder, stage, ctx, payload) {
|
|
|
12
13
|
}
|
|
13
14
|
export async function runHubPlan(options) {
|
|
14
15
|
const { plan, context, initialInput, recorder } = options;
|
|
16
|
+
normalizeProviderProtocolTokenWithNative(plan.protocol || context.protocol);
|
|
15
17
|
if (!plan.stages?.length && !plan.passthrough) {
|
|
16
18
|
throw new Error(`Hub plan for ${plan.protocol} has neither stages nor passthrough`);
|
|
17
19
|
}
|
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
import { normalizeReasoningInAnthropicPayload } from '../../shared/reasoning-normalizer.js';
|
|
2
|
+
import { parseReqInboundFormatEnvelopeWithNative, parseRespInboundFormatEnvelopeWithNative } from '../../../router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js';
|
|
2
3
|
export class AnthropicFormatAdapter {
|
|
3
4
|
protocol = 'anthropic-messages';
|
|
4
5
|
async parseRequest(original, _ctx) {
|
|
5
|
-
|
|
6
|
+
const parsed = parseReqInboundFormatEnvelopeWithNative({
|
|
7
|
+
rawRequest: original,
|
|
8
|
+
protocol: this.protocol
|
|
9
|
+
});
|
|
10
|
+
const payload = parsed.payload;
|
|
11
|
+
normalizeReasoningInAnthropicPayload(payload);
|
|
6
12
|
return {
|
|
7
13
|
protocol: this.protocol,
|
|
8
14
|
direction: 'request',
|
|
9
|
-
payload
|
|
15
|
+
payload
|
|
10
16
|
};
|
|
11
17
|
}
|
|
12
18
|
async buildRequest(format, _ctx) {
|
|
13
19
|
return format.payload;
|
|
14
20
|
}
|
|
15
21
|
async parseResponse(original, _ctx) {
|
|
16
|
-
|
|
22
|
+
const parsed = parseRespInboundFormatEnvelopeWithNative({
|
|
23
|
+
payload: original,
|
|
24
|
+
protocol: this.protocol
|
|
25
|
+
});
|
|
26
|
+
const payload = parsed.payload;
|
|
27
|
+
normalizeReasoningInAnthropicPayload(payload);
|
|
17
28
|
return {
|
|
18
29
|
protocol: this.protocol,
|
|
19
30
|
direction: 'response',
|
|
20
|
-
payload
|
|
31
|
+
payload
|
|
21
32
|
};
|
|
22
33
|
}
|
|
23
34
|
async buildResponse(format, _ctx) {
|
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
import { normalizeReasoningInChatPayload } from '../../shared/reasoning-normalizer.js';
|
|
2
|
+
import { parseReqInboundFormatEnvelopeWithNative, parseRespInboundFormatEnvelopeWithNative } from '../../../router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js';
|
|
2
3
|
export class ChatFormatAdapter {
|
|
3
4
|
protocol = 'openai-chat';
|
|
4
5
|
async parseRequest(original, _ctx) {
|
|
5
|
-
|
|
6
|
+
const parsed = parseReqInboundFormatEnvelopeWithNative({
|
|
7
|
+
rawRequest: original,
|
|
8
|
+
protocol: this.protocol
|
|
9
|
+
});
|
|
10
|
+
const payload = parsed.payload;
|
|
11
|
+
normalizeReasoningInChatPayload(payload);
|
|
6
12
|
return {
|
|
7
13
|
protocol: this.protocol,
|
|
8
14
|
direction: 'request',
|
|
9
|
-
payload
|
|
15
|
+
payload
|
|
10
16
|
};
|
|
11
17
|
}
|
|
12
18
|
async buildRequest(format, _ctx) {
|
|
13
19
|
return format.payload;
|
|
14
20
|
}
|
|
15
21
|
async parseResponse(original, _ctx) {
|
|
16
|
-
|
|
22
|
+
const parsed = parseRespInboundFormatEnvelopeWithNative({
|
|
23
|
+
payload: original,
|
|
24
|
+
protocol: this.protocol
|
|
25
|
+
});
|
|
26
|
+
const payload = parsed.payload;
|
|
27
|
+
normalizeReasoningInChatPayload(payload);
|
|
17
28
|
return {
|
|
18
29
|
protocol: this.protocol,
|
|
19
30
|
direction: 'response',
|
|
20
|
-
payload
|
|
31
|
+
payload
|
|
21
32
|
};
|
|
22
33
|
}
|
|
23
34
|
async buildResponse(format, _ctx) {
|
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
import { normalizeReasoningInGeminiPayload } from '../../shared/reasoning-normalizer.js';
|
|
2
|
+
import { parseReqInboundFormatEnvelopeWithNative, parseRespInboundFormatEnvelopeWithNative } from '../../../router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js';
|
|
2
3
|
export class GeminiFormatAdapter {
|
|
3
4
|
protocol = 'gemini-chat';
|
|
4
5
|
async parseRequest(original, _ctx) {
|
|
5
|
-
|
|
6
|
+
const parsed = parseReqInboundFormatEnvelopeWithNative({
|
|
7
|
+
rawRequest: original,
|
|
8
|
+
protocol: this.protocol
|
|
9
|
+
});
|
|
10
|
+
const payload = parsed.payload;
|
|
11
|
+
normalizeReasoningInGeminiPayload(payload);
|
|
6
12
|
return {
|
|
7
13
|
protocol: this.protocol,
|
|
8
14
|
direction: 'request',
|
|
9
|
-
payload
|
|
15
|
+
payload
|
|
10
16
|
};
|
|
11
17
|
}
|
|
12
18
|
async buildRequest(format, _ctx) {
|
|
13
19
|
return format.payload;
|
|
14
20
|
}
|
|
15
21
|
async parseResponse(original, _ctx) {
|
|
16
|
-
|
|
22
|
+
const parsed = parseRespInboundFormatEnvelopeWithNative({
|
|
23
|
+
payload: original,
|
|
24
|
+
protocol: this.protocol
|
|
25
|
+
});
|
|
26
|
+
const payload = parsed.payload;
|
|
27
|
+
normalizeReasoningInGeminiPayload(payload);
|
|
17
28
|
return {
|
|
18
29
|
protocol: this.protocol,
|
|
19
30
|
direction: 'response',
|
|
20
|
-
payload
|
|
31
|
+
payload
|
|
21
32
|
};
|
|
22
33
|
}
|
|
23
34
|
async buildResponse(format, _ctx) {
|
|
@@ -1,29 +1,40 @@
|
|
|
1
1
|
import { normalizeReasoningInResponsesPayload } from '../../shared/reasoning-normalizer.js';
|
|
2
|
+
import { parseReqInboundFormatEnvelopeWithNative, parseRespInboundFormatEnvelopeWithNative } from '../../../router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js';
|
|
2
3
|
export class ResponsesFormatAdapter {
|
|
3
4
|
protocol = 'openai-responses';
|
|
4
5
|
async parseRequest(original, _ctx) {
|
|
5
|
-
|
|
6
|
+
const parsed = parseReqInboundFormatEnvelopeWithNative({
|
|
7
|
+
rawRequest: original,
|
|
8
|
+
protocol: this.protocol
|
|
9
|
+
});
|
|
10
|
+
const payload = parsed.payload;
|
|
11
|
+
normalizeReasoningInResponsesPayload(payload, {
|
|
6
12
|
includeInput: true,
|
|
7
13
|
includeInstructions: true
|
|
8
14
|
});
|
|
9
15
|
return {
|
|
10
16
|
protocol: this.protocol,
|
|
11
17
|
direction: 'request',
|
|
12
|
-
payload
|
|
18
|
+
payload
|
|
13
19
|
};
|
|
14
20
|
}
|
|
15
21
|
async buildRequest(format, _ctx) {
|
|
16
22
|
return format.payload;
|
|
17
23
|
}
|
|
18
24
|
async parseResponse(original, _ctx) {
|
|
19
|
-
|
|
25
|
+
const parsed = parseRespInboundFormatEnvelopeWithNative({
|
|
26
|
+
payload: original,
|
|
27
|
+
protocol: this.protocol
|
|
28
|
+
});
|
|
29
|
+
const payload = parsed.payload;
|
|
30
|
+
normalizeReasoningInResponsesPayload(payload, {
|
|
20
31
|
includeOutput: true,
|
|
21
32
|
includeRequiredAction: true
|
|
22
33
|
});
|
|
23
34
|
return {
|
|
24
35
|
protocol: this.protocol,
|
|
25
36
|
direction: 'response',
|
|
26
|
-
payload
|
|
37
|
+
payload
|
|
27
38
|
};
|
|
28
39
|
}
|
|
29
40
|
async buildResponse(format, _ctx) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeProviderProtocolTokenWithNative } from '../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
1
2
|
const DISABLE_FLAG = (process.env.ROUTECODEX_HUB_ENABLED || process.env.ROUTECODEX_ENABLE_HUB) ?? '1';
|
|
2
3
|
const PROTOCOL_LIST = process.env.ROUTECODEX_HUB_PROTOCOLS;
|
|
3
4
|
function parseProtocolList(input) {
|
|
@@ -5,7 +6,7 @@ function parseProtocolList(input) {
|
|
|
5
6
|
return null;
|
|
6
7
|
const entries = input
|
|
7
8
|
.split(',')
|
|
8
|
-
.map((token) => token.trim().toLowerCase())
|
|
9
|
+
.map((token) => normalizeProviderProtocolTokenWithNative(token) ?? token.trim().toLowerCase())
|
|
9
10
|
.filter(Boolean);
|
|
10
11
|
if (!entries.length) {
|
|
11
12
|
return null;
|
|
@@ -20,6 +21,6 @@ export function isHubProtocolEnabled(protocol) {
|
|
|
20
21
|
if (!normalizedList) {
|
|
21
22
|
return true;
|
|
22
23
|
}
|
|
23
|
-
const normalizedProtocol = protocol.trim().toLowerCase();
|
|
24
|
+
const normalizedProtocol = normalizeProviderProtocolTokenWithNative(protocol) ?? protocol.trim().toLowerCase();
|
|
24
25
|
return normalizedList.has(normalizedProtocol);
|
|
25
26
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createProtocolPlans } from './registry.js';
|
|
2
2
|
import { runInboundPipeline } from './pipelines/inbound.js';
|
|
3
3
|
import { runOutboundPipeline } from './pipelines/outbound.js';
|
|
4
|
-
import { chatEnvelopeToStandardized, standardizedToChatEnvelope } from './standardized-bridge.js';
|
|
5
4
|
import { createSnapshotRecorder } from './snapshot-recorder.js';
|
|
6
5
|
import { ConversionError } from './types/errors.js';
|
|
7
6
|
import { isHubProtocolEnabled } from './hub-feature.js';
|
|
7
|
+
import { chatEnvelopeToStandardizedWithNative } from '../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
8
|
+
import { standardizedToChatEnvelopeWithNative } from '../../router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js';
|
|
8
9
|
export function shouldUseHub(protocol) {
|
|
9
10
|
return isHubProtocolEnabled(protocol);
|
|
10
11
|
}
|
|
@@ -19,8 +20,9 @@ export async function runHubInboundConversion(options) {
|
|
|
19
20
|
plan: inbound,
|
|
20
21
|
stageRecorder
|
|
21
22
|
});
|
|
22
|
-
const standardized =
|
|
23
|
-
|
|
23
|
+
const standardized = chatEnvelopeToStandardizedWithNative({
|
|
24
|
+
chatEnvelope: chatEnvelope,
|
|
25
|
+
adapterContext: adapterContext,
|
|
24
26
|
endpoint: options.nodeContext.request.endpoint,
|
|
25
27
|
requestId: options.nodeContext.request.id
|
|
26
28
|
});
|
|
@@ -38,7 +40,10 @@ export async function runHubOutboundConversion(options) {
|
|
|
38
40
|
// A /v1/responses request routed to an anthropic upstream is still a responses *entry* request.
|
|
39
41
|
const stageRecorder = maybeCreateStageRecorder(adapterContext, options.nodeContext.request.endpoint);
|
|
40
42
|
const { outbound } = createProtocolPlans(options.protocol);
|
|
41
|
-
const chatEnvelope =
|
|
43
|
+
const chatEnvelope = standardizedToChatEnvelopeWithNative({
|
|
44
|
+
request: options.request,
|
|
45
|
+
adapterContext: adapterContext
|
|
46
|
+
});
|
|
42
47
|
const payload = await runOutboundPipeline({
|
|
43
48
|
chat: chatEnvelope,
|
|
44
49
|
context: adapterContext,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createBridgeActionState, runBridgeActionPipeline } from '../../shared/bridge-actions.js';
|
|
2
2
|
import { resolveBridgePolicy, resolvePolicyActions } from '../../shared/bridge-policies.js';
|
|
3
|
+
import { normalizeProviderProtocolTokenWithNative } from '../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
3
4
|
const INBOUND_BRIDGE_SPECS = {
|
|
4
5
|
'openai-chat': { protocol: 'openai-chat', stage: 'request_inbound', messages: 'chat_envelope' },
|
|
5
6
|
// Keep parity with the legacy semantic mapper behavior: do not pass messages[] into the action state
|
|
@@ -17,10 +18,11 @@ const OUTBOUND_BRIDGE_SPECS = {
|
|
|
17
18
|
'gemini-chat': { protocol: 'gemini-chat', stage: 'request_outbound', messages: 'chat_envelope', includeCapturedToolResults: true }
|
|
18
19
|
};
|
|
19
20
|
function isSupportedProtocol(protocol) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const normalizedProtocol = normalizeProviderProtocolTokenWithNative(protocol) ?? protocol;
|
|
22
|
+
return normalizedProtocol === 'openai-chat' ||
|
|
23
|
+
normalizedProtocol === 'openai-responses' ||
|
|
24
|
+
normalizedProtocol === 'anthropic-messages' ||
|
|
25
|
+
normalizedProtocol === 'gemini-chat';
|
|
24
26
|
}
|
|
25
27
|
function extractPayloadMessages(payload) {
|
|
26
28
|
const value = payload?.messages;
|
|
@@ -109,7 +111,8 @@ function rebuildGeminiToolOutputsFromMessages(chatEnvelope) {
|
|
|
109
111
|
chatEnvelope.toolOutputs = outputs.length ? outputs : undefined;
|
|
110
112
|
}
|
|
111
113
|
export function applyHubOperationTableInbound(options) {
|
|
112
|
-
const protocol = options.formatEnvelope.protocol
|
|
114
|
+
const protocol = normalizeProviderProtocolTokenWithNative(options.formatEnvelope.protocol)
|
|
115
|
+
?? options.formatEnvelope.protocol;
|
|
113
116
|
if (!isSupportedProtocol(protocol)) {
|
|
114
117
|
return;
|
|
115
118
|
}
|
|
@@ -142,7 +145,8 @@ export function applyHubOperationTableOutboundPreMap(options) {
|
|
|
142
145
|
})();
|
|
143
146
|
}
|
|
144
147
|
export function applyHubOperationTableOutboundPostMap(options) {
|
|
145
|
-
const protocol = options.formatEnvelope.protocol
|
|
148
|
+
const protocol = normalizeProviderProtocolTokenWithNative(options.formatEnvelope.protocol)
|
|
149
|
+
?? options.formatEnvelope.protocol;
|
|
146
150
|
if (!isSupportedProtocol(protocol)) {
|
|
147
151
|
return;
|
|
148
152
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isJsonObject, jsonClone } from '../../types/json.js';
|
|
2
2
|
import { buildOpenAIChatFromAnthropic, buildAnthropicRequestFromOpenAIChat } from '../../../codecs/anthropic-openai-codec.js';
|
|
3
3
|
import { encodeMetadataPassthrough, extractMetadataPassthrough } from '../../../shared/metadata-passthrough.js';
|
|
4
|
-
import {
|
|
4
|
+
import { buildAnthropicToolAliasMapWithNative } from '../../../../router/virtual-router/engine-selection/native-chat-process-governance-semantics.js';
|
|
5
5
|
import { ChatSemanticMapper } from './chat-mapper.js';
|
|
6
6
|
const ANTHROPIC_PARAMETER_KEYS = [
|
|
7
7
|
'model',
|
|
@@ -279,7 +279,7 @@ export class AnthropicSemanticMapper {
|
|
|
279
279
|
if (payload.tools && Array.isArray(payload.tools) && payload.tools.length === 0) {
|
|
280
280
|
markExplicitEmptyTools(chatEnvelope);
|
|
281
281
|
}
|
|
282
|
-
const aliasMap =
|
|
282
|
+
const aliasMap = buildAnthropicToolAliasMapWithNative(payload.tools);
|
|
283
283
|
if (aliasMap) {
|
|
284
284
|
const toolsNode = ensureToolsSemanticsNode(chatEnvelope);
|
|
285
285
|
toolsNode.toolNameAliasMap = jsonClone(aliasMap);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isJsonObject, jsonClone } from '../../types/json.js';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeChatMessageContentWithNative } from '../../../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
3
3
|
import { ensureProtocolState } from '../../../shared/protocol-state.js';
|
|
4
|
+
import { mapReqInboundBridgeToolsToChatWithNative } from '../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
4
5
|
const CHAT_PARAMETER_KEYS = [
|
|
5
6
|
'model',
|
|
6
7
|
'temperature',
|
|
@@ -163,7 +164,7 @@ function normalizeChatMessages(raw) {
|
|
|
163
164
|
}
|
|
164
165
|
const chatMessage = value;
|
|
165
166
|
if (roleValue !== 'system' && roleValue !== 'tool') {
|
|
166
|
-
const normalizedContent =
|
|
167
|
+
const normalizedContent = normalizeChatMessageContentWithNative(chatMessage.content);
|
|
167
168
|
const shouldOverwriteContent = !Array.isArray(chatMessage.content);
|
|
168
169
|
if (shouldOverwriteContent && normalizedContent.contentText !== undefined) {
|
|
169
170
|
chatMessage.content = normalizedContent.contentText;
|
|
@@ -242,16 +243,15 @@ function normalizeStandaloneToolOutputs(raw, missing) {
|
|
|
242
243
|
return outputs;
|
|
243
244
|
}
|
|
244
245
|
function normalizeTools(raw, missing) {
|
|
245
|
-
if (!Array.isArray(raw) || raw.length === 0)
|
|
246
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
246
247
|
return undefined;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
}
|
|
249
|
+
const tools = mapReqInboundBridgeToolsToChatWithNative(raw);
|
|
250
|
+
if (tools.length === 0) {
|
|
251
|
+
raw.forEach((entry, index) => {
|
|
250
252
|
missing.push({ path: `tools[${index}]`, reason: 'invalid_entry', originalValue: jsonClone(entry) });
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
tools.push(entry);
|
|
254
|
-
});
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
255
|
return tools.length ? tools : undefined;
|
|
256
256
|
}
|
|
257
257
|
function extractParameters(body) {
|
|
@@ -5,8 +5,8 @@ import { mapBridgeToolsToChat, mapChatToolsToBridge } from '../../../shared/tool
|
|
|
5
5
|
import { prepareGeminiToolsForBridge, buildGeminiToolsFromBridge } from '../../../shared/gemini-tool-utils.js';
|
|
6
6
|
import { ensureProtocolState, getProtocolState } from '../../../shared/protocol-state.js';
|
|
7
7
|
import { sanitizeReasoningTaggedText } from '../../../shared/reasoning-utils.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { applyClaudeThinkingToolSchemaCompatWithNative } from '../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js';
|
|
9
|
+
import { extractAntigravityGeminiSessionIdWithNative } from '../../../../router/virtual-router/engine-selection/native-router-hotpath.js';
|
|
10
10
|
const GENERATION_CONFIG_KEYS = [
|
|
11
11
|
{ source: 'temperature', target: 'temperature' },
|
|
12
12
|
{ source: 'topP', target: 'top_p' },
|
|
@@ -280,10 +280,6 @@ function resolveAntigravityRequestConfig(options) {
|
|
|
280
280
|
const enableNetworking = wantsNetworking;
|
|
281
281
|
let finalModel = stripOnlineSuffix(mapped);
|
|
282
282
|
finalModel = normalizePreviewAlias(finalModel);
|
|
283
|
-
// Only gemini-2.5-flash reliably supports googleSearch in v1internal; downgrade for networking.
|
|
284
|
-
if (enableNetworking && finalModel !== 'gemini-2.5-flash') {
|
|
285
|
-
finalModel = 'gemini-2.5-flash';
|
|
286
|
-
}
|
|
287
283
|
return {
|
|
288
284
|
requestType: enableNetworking ? 'web_search' : 'agent',
|
|
289
285
|
injectGoogleSearch: enableNetworking,
|
|
@@ -1098,13 +1094,13 @@ function buildGeminiRequestFromChat(chat, metadata) {
|
|
|
1098
1094
|
request.metadata = request.metadata ?? {};
|
|
1099
1095
|
const existing = request.metadata.antigravitySessionId;
|
|
1100
1096
|
if (typeof existing !== 'string' || !existing.trim()) {
|
|
1101
|
-
request.metadata.antigravitySessionId =
|
|
1097
|
+
request.metadata.antigravitySessionId = extractAntigravityGeminiSessionIdWithNative(request);
|
|
1102
1098
|
}
|
|
1103
1099
|
}
|
|
1104
1100
|
// Apply claude-thinking compat at Gemini mapping time to ensure it is always active
|
|
1105
1101
|
// for Claude models, regardless of compatibilityProfile wiring. Provider层负责进一步的
|
|
1106
1102
|
// 传输层收紧(如 session_id / generationConfig),这里不做非标裁剪。
|
|
1107
|
-
const compatRequest =
|
|
1103
|
+
const compatRequest = applyClaudeThinkingToolSchemaCompatWithNative(request);
|
|
1108
1104
|
return compatRequest;
|
|
1109
1105
|
}
|
|
1110
1106
|
function sanitizeAntigravityToolCallId(raw) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isJsonObject, jsonClone } from '../../types/json.js';
|
|
2
2
|
import { captureResponsesContext, buildChatRequestFromResponses, buildResponsesRequestFromChat } from '../../../responses/responses-openai-bridge.js';
|
|
3
3
|
import { maybeAugmentApplyPatchErrorContent } from './chat-mapper.js';
|
|
4
|
+
import { mapReqInboundBridgeToolsToChatWithNative, mapReqInboundResumeToolOutputsDetailedWithNative } from '../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
4
5
|
const RESPONSES_PARAMETER_KEYS = [
|
|
5
6
|
'model',
|
|
6
7
|
'temperature',
|
|
@@ -65,31 +66,14 @@ function deriveResumeToolOutputsFromResume(resume) {
|
|
|
65
66
|
if (!resume || typeof resume !== 'object') {
|
|
66
67
|
return undefined;
|
|
67
68
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
: undefined;
|
|
71
|
-
if (!detailed || detailed.length === 0) {
|
|
69
|
+
const mapped = mapReqInboundResumeToolOutputsDetailedWithNative(resume);
|
|
70
|
+
if (!Array.isArray(mapped) || mapped.length === 0) {
|
|
72
71
|
return undefined;
|
|
73
72
|
}
|
|
74
|
-
const outputs =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
const callIdRaw = typeof entry.callId === 'string' && entry.callId.trim().length
|
|
80
|
-
? entry.callId.trim()
|
|
81
|
-
: typeof entry.originalId === 'string' && entry.originalId.trim().length
|
|
82
|
-
? entry.originalId.trim()
|
|
83
|
-
: `resume_tool_${index}`;
|
|
84
|
-
if (!callIdRaw) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const outputText = typeof entry.outputText === 'string' ? entry.outputText : '';
|
|
88
|
-
outputs.push({
|
|
89
|
-
tool_call_id: callIdRaw,
|
|
90
|
-
content: outputText
|
|
91
|
-
});
|
|
92
|
-
});
|
|
73
|
+
const outputs = mapped.map((entry) => ({
|
|
74
|
+
tool_call_id: entry.tool_call_id,
|
|
75
|
+
content: entry.content
|
|
76
|
+
}));
|
|
93
77
|
return outputs.length ? outputs : undefined;
|
|
94
78
|
}
|
|
95
79
|
function collectParameters(payload, streamHint) {
|
|
@@ -105,35 +89,15 @@ function collectParameters(payload, streamHint) {
|
|
|
105
89
|
return Object.keys(params).length ? params : undefined;
|
|
106
90
|
}
|
|
107
91
|
function normalizeTools(rawTools, missing) {
|
|
108
|
-
if (!rawTools || rawTools.length === 0)
|
|
92
|
+
if (!rawTools || rawTools.length === 0) {
|
|
109
93
|
return undefined;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
94
|
+
}
|
|
95
|
+
const tools = mapReqInboundBridgeToolsToChatWithNative(rawTools);
|
|
96
|
+
if (tools.length === 0) {
|
|
97
|
+
rawTools.forEach((tool, index) => {
|
|
113
98
|
missing.push({ path: `tools[${index}]`, reason: 'invalid_entry', originalValue: jsonClone(tool) });
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const fn = tool.function;
|
|
117
|
-
if (!fn || typeof fn !== 'object' || Array.isArray(fn))
|
|
118
|
-
return;
|
|
119
|
-
const name = fn.name;
|
|
120
|
-
const nameValue = typeof name === 'string' ? name : undefined;
|
|
121
|
-
if (!nameValue)
|
|
122
|
-
return;
|
|
123
|
-
const descriptionValue = fn.description;
|
|
124
|
-
const parametersValue = fn.parameters;
|
|
125
|
-
const strictValue = fn.strict;
|
|
126
|
-
const definition = {
|
|
127
|
-
type: 'function',
|
|
128
|
-
function: {
|
|
129
|
-
name: nameValue,
|
|
130
|
-
description: typeof descriptionValue === 'string' ? descriptionValue : undefined,
|
|
131
|
-
parameters: parametersValue,
|
|
132
|
-
strict: typeof strictValue === 'boolean' ? strictValue : undefined
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
tools.push(definition);
|
|
136
|
-
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
137
101
|
return tools.length ? tools : undefined;
|
|
138
102
|
}
|
|
139
103
|
function normalizeMessages(value, missing) {
|
|
@@ -364,21 +328,11 @@ function collectSubmitToolOutputs(chat, responsesContext) {
|
|
|
364
328
|
}
|
|
365
329
|
if (!outputs.length) {
|
|
366
330
|
const resume = readResponsesResumeFromSemantics(chat);
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
if (!entry || typeof entry !== 'object') {
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
const callId = typeof entry.callId === 'string' && entry.callId.trim().length
|
|
376
|
-
? entry.callId.trim()
|
|
377
|
-
: typeof entry.originalId === 'string' && entry.originalId.trim().length
|
|
378
|
-
? entry.originalId.trim()
|
|
379
|
-
: `resume_tool_${index + 1}`;
|
|
380
|
-
append(callId, typeof entry.outputText === 'string' ? entry.outputText : entry.outputText ?? '');
|
|
381
|
-
});
|
|
331
|
+
if (resume) {
|
|
332
|
+
const resumeOutputs = deriveResumeToolOutputsFromResume(resume);
|
|
333
|
+
if (resumeOutputs?.length) {
|
|
334
|
+
resumeOutputs.forEach((entry) => append(entry.tool_call_id, entry.content, entry.name));
|
|
335
|
+
}
|
|
382
336
|
}
|
|
383
337
|
}
|
|
384
338
|
return outputs;
|