@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
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
2
|
import { isJsonObject, jsonClone } from '../types/json.js';
|
|
3
3
|
import { VirtualRouterEngine } from '../../../router/virtual-router/engine.js';
|
|
4
|
-
import { parseRoutingInstructions } from '../../../router/virtual-router/routing-instructions.js';
|
|
5
4
|
import { providerErrorCenter } from '../../../router/virtual-router/error-center.js';
|
|
6
5
|
import { providerSuccessCenter } from '../../../router/virtual-router/success-center.js';
|
|
7
6
|
import { defaultSseCodecRegistry } from '../../../sse/index.js';
|
|
@@ -18,6 +17,7 @@ import { shouldRecordSnapshots } from '../../shared/snapshot-utils.js';
|
|
|
18
17
|
import { runReqInboundStage1FormatParse } from './stages/req_inbound/req_inbound_stage1_format_parse/index.js';
|
|
19
18
|
import { runReqInboundStage2SemanticMap } from './stages/req_inbound/req_inbound_stage2_semantic_map/index.js';
|
|
20
19
|
import { runChatContextCapture, captureResponsesContextSnapshot } from './stages/req_inbound/req_inbound_stage3_context_capture/index.js';
|
|
20
|
+
import { normalizeReqInboundToolCallIdStyleWithNative } from '../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
21
21
|
import { createResponsesContextCapture, createNoopContextCapture } from './stages/req_inbound/req_inbound_stage3_context_capture/context-factories.js';
|
|
22
22
|
import { runReqProcessStage1ToolGovernance } from './stages/req_process/req_process_stage1_tool_governance/index.js';
|
|
23
23
|
import { runReqProcessStage2RouteSelect } from './stages/req_process/req_process_stage2_route_select/index.js';
|
|
@@ -26,10 +26,11 @@ import { runReqOutboundStage2FormatBuild } from './stages/req_outbound/req_outbo
|
|
|
26
26
|
import { runReqOutboundStage3Compat } from './stages/req_outbound/req_outbound_stage3_compat/index.js';
|
|
27
27
|
import { extractSessionIdentifiersFromMetadata } from './session-identifiers.js';
|
|
28
28
|
import { computeRequestTokens } from '../../../router/virtual-router/token-estimator.js';
|
|
29
|
+
import { annotatePassthroughGovernanceSkipWithNative, attachPassthroughProviderInputAuditWithNative, buildPassthroughAuditWithNative, applyOutboundStreamPreferenceWithNative, normalizeHubEndpointWithNative, extractAdapterContextMetadataFieldsWithNative, resolveApplyPatchToolModeFromToolsWithNative, resolveHubClientProtocolWithNative, resolveHubPolicyOverrideFromMetadataWithNative, resolveHubProviderProtocolWithNative, resolveOutboundStreamIntentWithNative, resolveHubShadowCompareConfigWithNative, resolveActiveProcessModeWithNative, findMappableSemanticsKeysWithNative, resolveHubSseProtocolFromMetadataWithNative, resolveStopMessageRouterMetadataWithNative, runHubPipelineOrchestrationWithNative } from '../../../router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.js';
|
|
30
|
+
import { normalizeAliasMapWithNative, resolveAliasMapFromRespSemanticsWithNative } from '../../../router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.js';
|
|
29
31
|
import { isCompactionRequest } from '../../shared/compaction-detect.js';
|
|
30
32
|
import { applyHubProviderOutboundPolicy, recordHubPolicyObservation, setHubPolicyRuntimePolicy } from '../policy/policy-engine.js';
|
|
31
33
|
import { applyProviderOutboundToolSurface } from '../tool-surface/tool-surface-engine.js';
|
|
32
|
-
import { applyHubOperations } from '../ops/operations.js';
|
|
33
34
|
import { cloneRuntimeMetadata, ensureRuntimeMetadata, readRuntimeMetadata } from '../../shared/runtime-metadata.js';
|
|
34
35
|
function isTruthyEnv(value) {
|
|
35
36
|
const v = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
@@ -49,142 +50,51 @@ function resolveApplyPatchToolModeFromEnv() {
|
|
|
49
50
|
return undefined;
|
|
50
51
|
}
|
|
51
52
|
function resolveApplyPatchToolModeFromTools(toolsRaw) {
|
|
52
|
-
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
for (const entry of toolsRaw) {
|
|
56
|
-
if (!entry || typeof entry !== 'object' || Array.isArray(entry))
|
|
57
|
-
continue;
|
|
58
|
-
const record = entry;
|
|
59
|
-
const type = typeof record.type === 'string' ? record.type.trim().toLowerCase() : '';
|
|
60
|
-
if (type && type !== 'function')
|
|
61
|
-
continue;
|
|
62
|
-
const fn = record.function && typeof record.function === 'object' && !Array.isArray(record.function)
|
|
63
|
-
? record.function
|
|
64
|
-
: undefined;
|
|
65
|
-
const name = typeof fn?.name === 'string' ? fn.name.trim().toLowerCase() : '';
|
|
66
|
-
if (name !== 'apply_patch')
|
|
67
|
-
continue;
|
|
68
|
-
const format = typeof record.format === 'string'
|
|
69
|
-
? record.format.trim().toLowerCase()
|
|
70
|
-
: typeof fn?.format === 'string'
|
|
71
|
-
? String(fn.format).trim().toLowerCase()
|
|
72
|
-
: '';
|
|
73
|
-
if (format === 'freeform')
|
|
74
|
-
return 'freeform';
|
|
75
|
-
// If apply_patch is present without explicit freeform marker, default to schema mode.
|
|
76
|
-
return 'schema';
|
|
77
|
-
}
|
|
78
|
-
return undefined;
|
|
53
|
+
return resolveApplyPatchToolModeFromToolsWithNative(toolsRaw);
|
|
79
54
|
}
|
|
80
55
|
function extractHubPolicyOverride(metadata) {
|
|
81
|
-
const
|
|
82
|
-
if (!
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
const obj = raw;
|
|
86
|
-
const mode = typeof obj.mode === 'string' ? obj.mode.trim().toLowerCase() : '';
|
|
87
|
-
const sampleRate = typeof obj.sampleRate === 'number' && Number.isFinite(obj.sampleRate) ? obj.sampleRate : undefined;
|
|
88
|
-
if (mode !== 'off' && mode !== 'observe' && mode !== 'enforce') {
|
|
56
|
+
const parsed = resolveHubPolicyOverrideFromMetadataWithNative(metadata);
|
|
57
|
+
if (!parsed) {
|
|
89
58
|
return undefined;
|
|
90
59
|
}
|
|
91
60
|
return {
|
|
92
|
-
mode: mode,
|
|
93
|
-
...(sampleRate !== undefined ? { sampleRate } : {})
|
|
61
|
+
mode: parsed.mode,
|
|
62
|
+
...(parsed.sampleRate !== undefined ? { sampleRate: parsed.sampleRate } : {})
|
|
94
63
|
};
|
|
95
64
|
}
|
|
65
|
+
function propagateAdapterContextMetadataFields(adapterContext, metadata, keys) {
|
|
66
|
+
const picked = extractAdapterContextMetadataFieldsWithNative(metadata, keys);
|
|
67
|
+
Object.assign(adapterContext, picked);
|
|
68
|
+
}
|
|
69
|
+
function resolveStopMessageRouterMetadata(metadata) {
|
|
70
|
+
return resolveStopMessageRouterMetadataWithNative(metadata);
|
|
71
|
+
}
|
|
96
72
|
function extractHubShadowCompareConfig(metadata) {
|
|
97
|
-
const
|
|
98
|
-
if (!
|
|
73
|
+
const parsed = resolveHubShadowCompareConfigWithNative(metadata);
|
|
74
|
+
if (!parsed) {
|
|
99
75
|
return undefined;
|
|
100
76
|
}
|
|
101
|
-
|
|
102
|
-
const modeCandidate = typeof obj.baselineMode === 'string'
|
|
103
|
-
? obj.baselineMode.trim().toLowerCase()
|
|
104
|
-
: typeof obj.mode === 'string'
|
|
105
|
-
? obj.mode.trim().toLowerCase()
|
|
106
|
-
: '';
|
|
107
|
-
if (modeCandidate !== 'off' && modeCandidate !== 'observe' && modeCandidate !== 'enforce') {
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
return { baselineMode: modeCandidate };
|
|
111
|
-
}
|
|
112
|
-
const PASSTHROUGH_CANONICAL_CHAT_KEYS = new Set([
|
|
113
|
-
'model',
|
|
114
|
-
'messages',
|
|
115
|
-
'tools',
|
|
116
|
-
'parameters',
|
|
117
|
-
'metadata',
|
|
118
|
-
'semantics',
|
|
119
|
-
'stream'
|
|
120
|
-
]);
|
|
121
|
-
function cloneJsonRecord(payload) {
|
|
122
|
-
try {
|
|
123
|
-
return jsonClone(payload);
|
|
124
|
-
}
|
|
125
|
-
catch {
|
|
126
|
-
return { ...payload };
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
function collectPassthroughTodoTopLevelKeys(payload) {
|
|
130
|
-
return Object.keys(payload)
|
|
131
|
-
.filter((key) => !PASSTHROUGH_CANONICAL_CHAT_KEYS.has(key))
|
|
132
|
-
.sort();
|
|
77
|
+
return { baselineMode: parsed.baselineMode };
|
|
133
78
|
}
|
|
134
79
|
function buildPassthroughAudit(rawInbound, providerProtocol) {
|
|
135
|
-
return
|
|
136
|
-
raw: {
|
|
137
|
-
inbound: cloneJsonRecord(rawInbound)
|
|
138
|
-
},
|
|
139
|
-
todo: {
|
|
140
|
-
inbound: {
|
|
141
|
-
unmappedTopLevelKeys: collectPassthroughTodoTopLevelKeys(rawInbound),
|
|
142
|
-
providerProtocol,
|
|
143
|
-
note: 'passthrough_mode_parse_record_only'
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
};
|
|
80
|
+
return buildPassthroughAuditWithNative(rawInbound, providerProtocol);
|
|
147
81
|
}
|
|
148
82
|
function annotatePassthroughGovernanceSkip(audit) {
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
reason: 'process_mode_passthrough'
|
|
155
|
-
};
|
|
83
|
+
const next = annotatePassthroughGovernanceSkipWithNative(audit);
|
|
84
|
+
for (const key of Object.keys(audit)) {
|
|
85
|
+
delete audit[key];
|
|
86
|
+
}
|
|
87
|
+
Object.assign(audit, next);
|
|
156
88
|
}
|
|
157
89
|
function attachPassthroughProviderInputAudit(audit, providerPayload, providerProtocol) {
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
raw.providerInput = cloneJsonRecord(providerPayload);
|
|
162
|
-
const todo = audit.todo && typeof audit.todo === 'object' && !Array.isArray(audit.todo)
|
|
163
|
-
? audit.todo
|
|
164
|
-
: (audit.todo = {});
|
|
165
|
-
todo.outbound = {
|
|
166
|
-
unmappedTopLevelKeys: collectPassthroughTodoTopLevelKeys(providerPayload),
|
|
167
|
-
providerProtocol,
|
|
168
|
-
note: 'provider_payload_not_mapped_back_to_chat_semantics'
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function hasInstructionRequestedPassthrough(messages) {
|
|
172
|
-
if (!Array.isArray(messages) || messages.length === 0) {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
try {
|
|
176
|
-
const instructions = parseRoutingInstructions(messages);
|
|
177
|
-
return instructions.some((instruction) => instruction.processMode === 'passthrough');
|
|
178
|
-
}
|
|
179
|
-
catch {
|
|
180
|
-
return false;
|
|
90
|
+
const next = attachPassthroughProviderInputAuditWithNative(audit, providerPayload, providerProtocol);
|
|
91
|
+
for (const key of Object.keys(audit)) {
|
|
92
|
+
delete audit[key];
|
|
181
93
|
}
|
|
94
|
+
Object.assign(audit, next);
|
|
182
95
|
}
|
|
183
96
|
function resolveActiveProcessMode(baseMode, messages) {
|
|
184
|
-
|
|
185
|
-
return 'passthrough';
|
|
186
|
-
}
|
|
187
|
-
return hasInstructionRequestedPassthrough(messages) ? 'passthrough' : 'chat';
|
|
97
|
+
return resolveActiveProcessModeWithNative(baseMode, messages);
|
|
188
98
|
}
|
|
189
99
|
export class HubPipeline {
|
|
190
100
|
routerEngine;
|
|
@@ -279,7 +189,6 @@ export class HubPipeline {
|
|
|
279
189
|
}
|
|
280
190
|
}
|
|
281
191
|
async executeRequestStagePipeline(normalized, hooks) {
|
|
282
|
-
const formatAdapter = hooks.createFormatAdapter();
|
|
283
192
|
const semanticMapper = hooks.createSemanticMapper();
|
|
284
193
|
const rawRequest = this.asJsonObject(normalized.payload);
|
|
285
194
|
// Detect applyPatchToolMode (runtime/tooling hint). Client tool schemas are captured as chat semantics
|
|
@@ -320,7 +229,6 @@ export class HubPipeline {
|
|
|
320
229
|
const formatEnvelope = await runReqInboundStage1FormatParse({
|
|
321
230
|
rawRequest,
|
|
322
231
|
adapterContext: inboundAdapterContext,
|
|
323
|
-
formatAdapter,
|
|
324
232
|
stageRecorder: inboundRecorder
|
|
325
233
|
});
|
|
326
234
|
const responsesResumeFromMetadata = normalized.metadata && typeof normalized.metadata.responsesResume === 'object'
|
|
@@ -483,6 +391,7 @@ export class HubPipeline {
|
|
|
483
391
|
normalized.metadata.conversationId = sessionIdentifiers.conversationId;
|
|
484
392
|
}
|
|
485
393
|
const disableStickyRoutes = readRuntimeMetadata(normalized.metadata)?.disableStickyRoutes === true;
|
|
394
|
+
const stopMessageRouterMetadata = resolveStopMessageRouterMetadata(normalized.metadata);
|
|
486
395
|
const metadataInput = {
|
|
487
396
|
requestId: normalized.id,
|
|
488
397
|
entryEndpoint: normalized.entryEndpoint,
|
|
@@ -496,7 +405,8 @@ export class HubPipeline {
|
|
|
496
405
|
...(disableStickyRoutes ? { disableStickyRoutes: true } : {}),
|
|
497
406
|
...(serverToolRequired ? { serverToolRequired: true } : {}),
|
|
498
407
|
...(sessionIdentifiers.sessionId ? { sessionId: sessionIdentifiers.sessionId } : {}),
|
|
499
|
-
...(sessionIdentifiers.conversationId ? { conversationId: sessionIdentifiers.conversationId } : {})
|
|
408
|
+
...(sessionIdentifiers.conversationId ? { conversationId: sessionIdentifiers.conversationId } : {}),
|
|
409
|
+
...stopMessageRouterMetadata
|
|
500
410
|
};
|
|
501
411
|
const routing = runReqProcessStage2RouteSelect({
|
|
502
412
|
routerEngine: this.routerEngine,
|
|
@@ -549,7 +459,7 @@ export class HubPipeline {
|
|
|
549
459
|
let providerPayload;
|
|
550
460
|
let shadowBaselineProviderPayload;
|
|
551
461
|
if (activeProcessMode === 'passthrough') {
|
|
552
|
-
providerPayload =
|
|
462
|
+
providerPayload = jsonClone(rawRequest);
|
|
553
463
|
if (typeof outboundStream === 'boolean') {
|
|
554
464
|
providerPayload.stream = outboundStream;
|
|
555
465
|
}
|
|
@@ -564,7 +474,6 @@ export class HubPipeline {
|
|
|
564
474
|
throw new Error(`[HubPipeline] Unsupported provider protocol for hub pipeline: ${outboundProtocol}`);
|
|
565
475
|
}
|
|
566
476
|
const outboundSemanticMapper = protocolSwitch ? outboundHooks.createSemanticMapper() : semanticMapper;
|
|
567
|
-
const outboundFormatAdapter = protocolSwitch ? outboundHooks.createFormatAdapter() : formatAdapter;
|
|
568
477
|
const outboundContextMetadataKey = protocolSwitch ? outboundHooks.contextMetadataKey : hooks.contextMetadataKey;
|
|
569
478
|
const outboundContextSnapshot = protocolSwitch ? undefined : contextSnapshot;
|
|
570
479
|
const outboundStage1 = await runReqOutboundStage1SemanticMap({
|
|
@@ -577,8 +486,6 @@ export class HubPipeline {
|
|
|
577
486
|
});
|
|
578
487
|
let formattedPayload = await runReqOutboundStage2FormatBuild({
|
|
579
488
|
formatEnvelope: outboundStage1.formatEnvelope,
|
|
580
|
-
adapterContext: outboundAdapterContext,
|
|
581
|
-
formatAdapter: outboundFormatAdapter,
|
|
582
489
|
stageRecorder: outboundRecorder
|
|
583
490
|
});
|
|
584
491
|
formattedPayload = await runReqOutboundStage3Compat({
|
|
@@ -734,11 +641,10 @@ export class HubPipeline {
|
|
|
734
641
|
};
|
|
735
642
|
}
|
|
736
643
|
resolveClientProtocol(entryEndpoint) {
|
|
737
|
-
const
|
|
738
|
-
if (
|
|
739
|
-
return
|
|
740
|
-
|
|
741
|
-
return 'anthropic-messages';
|
|
644
|
+
const protocol = resolveHubClientProtocolWithNative(entryEndpoint);
|
|
645
|
+
if (protocol === 'openai-responses' || protocol === 'anthropic-messages' || protocol === 'openai-chat') {
|
|
646
|
+
return protocol;
|
|
647
|
+
}
|
|
742
648
|
return 'openai-chat';
|
|
743
649
|
}
|
|
744
650
|
coerceStandardizedRequestFromPayload(payload, normalized) {
|
|
@@ -964,6 +870,7 @@ export class HubPipeline {
|
|
|
964
870
|
normalized.metadata.conversationId = sessionIdentifiers.conversationId;
|
|
965
871
|
}
|
|
966
872
|
const disableStickyRoutes = readRuntimeMetadata(normalized.metadata)?.disableStickyRoutes === true;
|
|
873
|
+
const stopMessageRouterMetadata = resolveStopMessageRouterMetadata(normalized.metadata);
|
|
967
874
|
const metadataInput = {
|
|
968
875
|
requestId: normalized.id,
|
|
969
876
|
entryEndpoint: normalized.entryEndpoint,
|
|
@@ -977,7 +884,8 @@ export class HubPipeline {
|
|
|
977
884
|
...(disableStickyRoutes ? { disableStickyRoutes: true } : {}),
|
|
978
885
|
...(serverToolRequired ? { serverToolRequired: true } : {}),
|
|
979
886
|
...(sessionIdentifiers.sessionId ? { sessionId: sessionIdentifiers.sessionId } : {}),
|
|
980
|
-
...(sessionIdentifiers.conversationId ? { conversationId: sessionIdentifiers.conversationId } : {})
|
|
887
|
+
...(sessionIdentifiers.conversationId ? { conversationId: sessionIdentifiers.conversationId } : {}),
|
|
888
|
+
...stopMessageRouterMetadata
|
|
981
889
|
};
|
|
982
890
|
const routing = runReqProcessStage2RouteSelect({
|
|
983
891
|
routerEngine: this.routerEngine,
|
|
@@ -1026,7 +934,7 @@ export class HubPipeline {
|
|
|
1026
934
|
const outboundStart = Date.now();
|
|
1027
935
|
let providerPayload;
|
|
1028
936
|
if (activeProcessMode === 'passthrough') {
|
|
1029
|
-
providerPayload =
|
|
937
|
+
providerPayload = jsonClone(rawPayloadInput);
|
|
1030
938
|
if (typeof outboundStream === 'boolean') {
|
|
1031
939
|
providerPayload.stream = outboundStream;
|
|
1032
940
|
}
|
|
@@ -1041,7 +949,6 @@ export class HubPipeline {
|
|
|
1041
949
|
throw new Error(`[HubPipeline] Unsupported provider protocol for hub pipeline: ${outboundProtocol}`);
|
|
1042
950
|
}
|
|
1043
951
|
const outboundSemanticMapper = protocolSwitch ? outboundHooks.createSemanticMapper() : hooks.createSemanticMapper();
|
|
1044
|
-
const outboundFormatAdapter = protocolSwitch ? outboundHooks.createFormatAdapter() : hooks.createFormatAdapter();
|
|
1045
952
|
const outboundContextMetadataKey = protocolSwitch ? outboundHooks.contextMetadataKey : hooks.contextMetadataKey;
|
|
1046
953
|
const outboundContextSnapshot = undefined;
|
|
1047
954
|
const outboundStage1 = await runReqOutboundStage1SemanticMap({
|
|
@@ -1054,8 +961,6 @@ export class HubPipeline {
|
|
|
1054
961
|
});
|
|
1055
962
|
let formattedPayload = await runReqOutboundStage2FormatBuild({
|
|
1056
963
|
formatEnvelope: outboundStage1.formatEnvelope,
|
|
1057
|
-
adapterContext: outboundAdapterContext,
|
|
1058
|
-
formatAdapter: outboundFormatAdapter,
|
|
1059
964
|
stageRecorder: outboundRecorder
|
|
1060
965
|
});
|
|
1061
966
|
formattedPayload = await runReqOutboundStage3Compat({
|
|
@@ -1260,7 +1165,7 @@ export class HubPipeline {
|
|
|
1260
1165
|
// Never inherit stale top-level metadata.compatibilityProfile from a previous hop.
|
|
1261
1166
|
const compatibilityProfile = target ? targetCompatProfile : metadataCompatProfile;
|
|
1262
1167
|
const streamingHint = normalized.stream === true ? 'force' : normalized.stream === false ? 'disable' : 'auto';
|
|
1263
|
-
const toolCallIdStyle =
|
|
1168
|
+
const toolCallIdStyle = normalizeReqInboundToolCallIdStyleWithNative(metadata.toolCallIdStyle);
|
|
1264
1169
|
const adapterContext = {
|
|
1265
1170
|
requestId: normalized.id,
|
|
1266
1171
|
entryEndpoint: normalized.entryEndpoint || '/v1/chat/completions',
|
|
@@ -1338,6 +1243,23 @@ export class HubPipeline {
|
|
|
1338
1243
|
if (conversationId) {
|
|
1339
1244
|
adapterContext.conversationId = conversationId;
|
|
1340
1245
|
}
|
|
1246
|
+
propagateAdapterContextMetadataFields(adapterContext, metadata, [
|
|
1247
|
+
'clockDaemonId',
|
|
1248
|
+
'clockClientDaemonId',
|
|
1249
|
+
'clock_daemon_id',
|
|
1250
|
+
'clock_client_daemon_id',
|
|
1251
|
+
'tmuxSessionId',
|
|
1252
|
+
'tmux_session_id',
|
|
1253
|
+
'clientType',
|
|
1254
|
+
'clockClientType',
|
|
1255
|
+
'clientInjectReady',
|
|
1256
|
+
'clientInjectReason',
|
|
1257
|
+
'client_inject_ready',
|
|
1258
|
+
'client_inject_reason',
|
|
1259
|
+
'workdir',
|
|
1260
|
+
'cwd',
|
|
1261
|
+
'workingDirectory'
|
|
1262
|
+
]);
|
|
1341
1263
|
const clientConnectionState = metadata.clientConnectionState;
|
|
1342
1264
|
if (clientConnectionState && typeof clientConnectionState === 'object' && !Array.isArray(clientConnectionState)) {
|
|
1343
1265
|
const stateRecord = clientConnectionState;
|
|
@@ -1418,12 +1340,45 @@ export class HubPipeline {
|
|
|
1418
1340
|
const stream = Boolean(metadataRecord.stream ||
|
|
1419
1341
|
resolvedReadable ||
|
|
1420
1342
|
(request.payload && typeof request.payload === 'object' && request.payload.stream));
|
|
1421
|
-
|
|
1343
|
+
let payload = await this.materializePayload(request.payload, {
|
|
1422
1344
|
requestId: id,
|
|
1423
1345
|
entryEndpoint,
|
|
1424
1346
|
providerProtocol,
|
|
1425
1347
|
metadata: metadataRecord
|
|
1426
1348
|
}, resolvedReadable);
|
|
1349
|
+
const routeHint = typeof metadataRecord.routeHint === 'string' ? metadataRecord.routeHint : undefined;
|
|
1350
|
+
const orchestrationResult = runHubPipelineOrchestrationWithNative({
|
|
1351
|
+
requestId: id,
|
|
1352
|
+
endpoint,
|
|
1353
|
+
entryEndpoint,
|
|
1354
|
+
providerProtocol,
|
|
1355
|
+
payload,
|
|
1356
|
+
metadata: {
|
|
1357
|
+
entryEndpoint,
|
|
1358
|
+
providerProtocol,
|
|
1359
|
+
processMode,
|
|
1360
|
+
direction,
|
|
1361
|
+
stage,
|
|
1362
|
+
stream,
|
|
1363
|
+
...(routeHint ? { routeHint } : {})
|
|
1364
|
+
},
|
|
1365
|
+
stream,
|
|
1366
|
+
processMode,
|
|
1367
|
+
direction,
|
|
1368
|
+
stage
|
|
1369
|
+
});
|
|
1370
|
+
if (!orchestrationResult.success) {
|
|
1371
|
+
const code = orchestrationResult.error && typeof orchestrationResult.error.code === 'string'
|
|
1372
|
+
? orchestrationResult.error.code.trim()
|
|
1373
|
+
: 'hub_pipeline_native_failed';
|
|
1374
|
+
const message = orchestrationResult.error && typeof orchestrationResult.error.message === 'string'
|
|
1375
|
+
? orchestrationResult.error.message.trim()
|
|
1376
|
+
: 'Native hub pipeline orchestration failed';
|
|
1377
|
+
throw new Error(`[${code}] ${message}`);
|
|
1378
|
+
}
|
|
1379
|
+
if (orchestrationResult.payload) {
|
|
1380
|
+
payload = orchestrationResult.payload;
|
|
1381
|
+
}
|
|
1427
1382
|
const normalizedMetadata = {
|
|
1428
1383
|
...metadataRecord,
|
|
1429
1384
|
entryEndpoint,
|
|
@@ -1431,9 +1386,9 @@ export class HubPipeline {
|
|
|
1431
1386
|
processMode,
|
|
1432
1387
|
direction,
|
|
1433
1388
|
stage,
|
|
1434
|
-
stream
|
|
1389
|
+
stream,
|
|
1390
|
+
...(orchestrationResult.metadata ?? {})
|
|
1435
1391
|
};
|
|
1436
|
-
const routeHint = typeof metadataRecord.routeHint === 'string' ? metadataRecord.routeHint : undefined;
|
|
1437
1392
|
if (routeHint) {
|
|
1438
1393
|
normalizedMetadata.routeHint = routeHint;
|
|
1439
1394
|
}
|
|
@@ -1538,156 +1493,54 @@ export class HubPipeline {
|
|
|
1538
1493
|
return undefined;
|
|
1539
1494
|
}
|
|
1540
1495
|
resolveOutboundStreamIntent(providerPreference) {
|
|
1541
|
-
|
|
1542
|
-
return true;
|
|
1543
|
-
}
|
|
1544
|
-
if (providerPreference === 'never') {
|
|
1545
|
-
return false;
|
|
1546
|
-
}
|
|
1547
|
-
return undefined;
|
|
1496
|
+
return resolveOutboundStreamIntentWithNative(providerPreference);
|
|
1548
1497
|
}
|
|
1549
1498
|
applyOutboundStreamPreference(request, stream, processMode) {
|
|
1550
1499
|
if (!request || typeof request !== 'object') {
|
|
1551
1500
|
return request;
|
|
1552
1501
|
}
|
|
1553
|
-
|
|
1554
|
-
return request;
|
|
1555
|
-
}
|
|
1556
|
-
const ops = [];
|
|
1557
|
-
if (typeof stream === 'boolean') {
|
|
1558
|
-
ops.push({ op: 'set_request_parameter_fields', fields: { stream } });
|
|
1559
|
-
ops.push({ op: 'set_request_metadata_fields', fields: { outboundStream: stream } });
|
|
1560
|
-
}
|
|
1561
|
-
else {
|
|
1562
|
-
ops.push({ op: 'unset_request_parameter_keys', keys: ['stream'] });
|
|
1563
|
-
ops.push({ op: 'unset_request_metadata_keys', keys: ['outboundStream'] });
|
|
1564
|
-
}
|
|
1565
|
-
return applyHubOperations(request, ops);
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
function normalizeToolCallIdStyleCandidate(value) {
|
|
1569
|
-
if (typeof value !== 'string') {
|
|
1570
|
-
return undefined;
|
|
1571
|
-
}
|
|
1572
|
-
const normalized = value.trim().toLowerCase();
|
|
1573
|
-
if (normalized === 'fc') {
|
|
1574
|
-
return 'fc';
|
|
1502
|
+
return applyOutboundStreamPreferenceWithNative(request, stream, processMode);
|
|
1575
1503
|
}
|
|
1576
|
-
if (normalized === 'preserve') {
|
|
1577
|
-
return 'preserve';
|
|
1578
|
-
}
|
|
1579
|
-
return undefined;
|
|
1580
1504
|
}
|
|
1581
1505
|
function normalizeEndpoint(endpoint) {
|
|
1582
|
-
|
|
1583
|
-
return '/v1/chat/completions';
|
|
1584
|
-
const trimmed = endpoint.trim();
|
|
1585
|
-
if (!trimmed)
|
|
1586
|
-
return '/v1/chat/completions';
|
|
1587
|
-
const normalized = trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
|
|
1588
|
-
return normalized.replace(/\/{2,}/g, '/');
|
|
1506
|
+
return normalizeHubEndpointWithNative(endpoint);
|
|
1589
1507
|
}
|
|
1590
1508
|
function resolveProviderProtocol(value) {
|
|
1591
|
-
|
|
1592
|
-
|
|
1509
|
+
try {
|
|
1510
|
+
const normalized = resolveHubProviderProtocolWithNative(value);
|
|
1511
|
+
if (normalized === 'openai-chat' ||
|
|
1512
|
+
normalized === 'openai-responses' ||
|
|
1513
|
+
normalized === 'anthropic-messages' ||
|
|
1514
|
+
normalized === 'gemini-chat') {
|
|
1515
|
+
return normalized;
|
|
1516
|
+
}
|
|
1593
1517
|
}
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
if (mapped) {
|
|
1597
|
-
return mapped;
|
|
1518
|
+
catch {
|
|
1519
|
+
// Keep legacy caller-facing error shape below.
|
|
1598
1520
|
}
|
|
1599
1521
|
throw new Error(`[HubPipeline] Unsupported providerProtocol "${value}". Configure a valid protocol (openai-chat|openai-responses|anthropic-messages|gemini-chat).`);
|
|
1600
1522
|
}
|
|
1601
|
-
const PROVIDER_PROTOCOL_ALIASES = {
|
|
1602
|
-
'openai-chat': 'openai-chat',
|
|
1603
|
-
openai: 'openai-chat',
|
|
1604
|
-
chat: 'openai-chat',
|
|
1605
|
-
'responses': 'openai-responses',
|
|
1606
|
-
'openai-responses': 'openai-responses',
|
|
1607
|
-
'anthropic': 'anthropic-messages',
|
|
1608
|
-
'anthropic-messages': 'anthropic-messages',
|
|
1609
|
-
'messages': 'anthropic-messages',
|
|
1610
|
-
'gemini': 'gemini-chat',
|
|
1611
|
-
'google-gemini': 'gemini-chat',
|
|
1612
|
-
'gemini-chat': 'gemini-chat'
|
|
1613
|
-
};
|
|
1614
|
-
function resolveEndpointForProviderProtocol(protocol) {
|
|
1615
|
-
if (!protocol) {
|
|
1616
|
-
return undefined;
|
|
1617
|
-
}
|
|
1618
|
-
const value = protocol.toLowerCase();
|
|
1619
|
-
if (value === 'openai-responses')
|
|
1620
|
-
return '/v1/responses';
|
|
1621
|
-
if (value === 'openai-chat')
|
|
1622
|
-
return '/v1/chat/completions';
|
|
1623
|
-
if (value === 'anthropic-messages' || value === 'anthropic')
|
|
1624
|
-
return '/v1/messages';
|
|
1625
|
-
if (value === 'gemini-chat' || value === 'gemini' || value === 'google-gemini')
|
|
1626
|
-
return '/v1/responses';
|
|
1627
|
-
return undefined;
|
|
1628
|
-
}
|
|
1629
1523
|
function resolveSseProtocolFromMetadata(metadata) {
|
|
1630
|
-
const
|
|
1631
|
-
if (
|
|
1524
|
+
const resolved = resolveHubSseProtocolFromMetadataWithNative(metadata);
|
|
1525
|
+
if (!resolved) {
|
|
1632
1526
|
return undefined;
|
|
1633
1527
|
}
|
|
1634
|
-
return resolveProviderProtocol(
|
|
1528
|
+
return resolveProviderProtocol(resolved);
|
|
1635
1529
|
}
|
|
1636
1530
|
function coerceAliasMap(candidate) {
|
|
1637
|
-
|
|
1638
|
-
return undefined;
|
|
1639
|
-
}
|
|
1640
|
-
const normalized = {};
|
|
1641
|
-
for (const [key, value] of Object.entries(candidate)) {
|
|
1642
|
-
if (typeof key !== 'string' || typeof value !== 'string') {
|
|
1643
|
-
continue;
|
|
1644
|
-
}
|
|
1645
|
-
const trimmedKey = key.trim();
|
|
1646
|
-
const trimmedValue = value.trim();
|
|
1647
|
-
if (!trimmedKey.length || !trimmedValue.length) {
|
|
1648
|
-
continue;
|
|
1649
|
-
}
|
|
1650
|
-
normalized[trimmedKey] = trimmedValue;
|
|
1651
|
-
}
|
|
1652
|
-
return Object.keys(normalized).length ? normalized : undefined;
|
|
1531
|
+
return normalizeAliasMapWithNative(candidate);
|
|
1653
1532
|
}
|
|
1654
1533
|
function readAliasMapFromSemantics(chatEnvelope) {
|
|
1655
|
-
if (!chatEnvelope?.semantics || typeof chatEnvelope.semantics !== 'object') {
|
|
1656
|
-
return undefined;
|
|
1657
|
-
}
|
|
1658
|
-
const node = chatEnvelope.semantics.tools;
|
|
1659
|
-
if (!node || !isJsonObject(node)) {
|
|
1534
|
+
if (!chatEnvelope?.semantics || typeof chatEnvelope.semantics !== 'object' || Array.isArray(chatEnvelope.semantics)) {
|
|
1660
1535
|
return undefined;
|
|
1661
1536
|
}
|
|
1662
|
-
|
|
1663
|
-
node.toolAliasMap;
|
|
1664
|
-
return coerceAliasMap(candidate);
|
|
1537
|
+
return resolveAliasMapFromRespSemanticsWithNative(chatEnvelope.semantics);
|
|
1665
1538
|
}
|
|
1666
1539
|
function assertNoMappableSemanticsInMetadata(metadata, scope) {
|
|
1667
1540
|
if (!metadata || typeof metadata !== 'object') {
|
|
1668
1541
|
return;
|
|
1669
1542
|
}
|
|
1670
|
-
const
|
|
1671
|
-
'responsesResume',
|
|
1672
|
-
'responses_resume',
|
|
1673
|
-
'clientToolsRaw',
|
|
1674
|
-
'client_tools_raw',
|
|
1675
|
-
'anthropicToolNameMap',
|
|
1676
|
-
'anthropic_tool_name_map',
|
|
1677
|
-
// Responses semantics must be stored in chat.semantics.responses.context, not metadata.
|
|
1678
|
-
'responsesContext',
|
|
1679
|
-
'responses_context',
|
|
1680
|
-
'responseFormat',
|
|
1681
|
-
'response_format',
|
|
1682
|
-
// OpenAI Chat legacy semantics must be stored in chat.semantics (system/tools/providerExtras), not metadata.
|
|
1683
|
-
'systemInstructions',
|
|
1684
|
-
'system_instructions',
|
|
1685
|
-
'toolsFieldPresent',
|
|
1686
|
-
'tools_field_present',
|
|
1687
|
-
'extraFields',
|
|
1688
|
-
'extra_fields'
|
|
1689
|
-
];
|
|
1690
|
-
const present = banned.filter((k) => Object.prototype.hasOwnProperty.call(metadata, k));
|
|
1543
|
+
const present = findMappableSemanticsKeysWithNative(metadata);
|
|
1691
1544
|
if (present.length) {
|
|
1692
1545
|
throw new Error(`[HubPipeline][semantic_gate] Mappable semantics must not be stored in metadata (${scope}): ${present.join(', ')}`);
|
|
1693
1546
|
}
|