@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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JsonObject } from '../../../../types/json.js';
|
|
2
|
+
type ToolOutputItem = {
|
|
3
|
+
tool_call_id: string;
|
|
4
|
+
call_id: string;
|
|
5
|
+
output?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function buildToolOutputSnapshot(payload: JsonObject, providerProtocol?: string): Record<string, unknown>;
|
|
9
|
+
export declare function collectToolOutputs(payload: JsonObject): ToolOutputItem[];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { buildReqInboundToolOutputSnapshotWithNative, collectReqInboundToolOutputsWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
2
|
+
export function buildToolOutputSnapshot(payload, providerProtocol) {
|
|
3
|
+
return buildReqInboundToolOutputSnapshotWithNative(payload, providerProtocol);
|
|
4
|
+
}
|
|
5
|
+
export function collectToolOutputs(payload) {
|
|
6
|
+
return collectReqInboundToolOutputsWithNative(payload).map((entry) => ({
|
|
7
|
+
tool_call_id: entry.tool_call_id,
|
|
8
|
+
call_id: entry.call_id,
|
|
9
|
+
...(typeof entry.output === 'string' ? { output: entry.output } : {}),
|
|
10
|
+
...(typeof entry.name === 'string' ? { name: entry.name } : {})
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AdapterContext, ChatEnvelope } from '../../../../types/chat-envelope.js';
|
|
2
|
+
export declare function applyToolCallIdStyleMetadata(chatEnvelope: ChatEnvelope, adapterContext: AdapterContext, snapshot?: Record<string, unknown>): void;
|
|
3
|
+
export declare function applyContextSnapshotToChatEnvelope(chatEnvelope: ChatEnvelope, snapshot: Record<string, unknown>): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { selectToolCallIdStyleWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.js';
|
|
2
|
+
import { applyReqOutboundContextSnapshotWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js';
|
|
3
|
+
export function applyToolCallIdStyleMetadata(chatEnvelope, adapterContext, snapshot) {
|
|
4
|
+
const metadata = chatEnvelope.metadata || (chatEnvelope.metadata = { context: adapterContext });
|
|
5
|
+
const current = typeof metadata.toolCallIdStyle === 'string'
|
|
6
|
+
? String(metadata.toolCallIdStyle).trim()
|
|
7
|
+
: '';
|
|
8
|
+
const resolved = selectToolCallIdStyleWithNative(adapterContext, snapshot ?? {}, current || undefined);
|
|
9
|
+
if (!resolved) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
// Always honor the route-selected AdapterContext toolCallIdStyle when present.
|
|
13
|
+
// This prevents cross-provider leakage (e.g. LM Studio "preserve" contaminating OpenAI "fc").
|
|
14
|
+
if (!current || current !== resolved) {
|
|
15
|
+
metadata.toolCallIdStyle = resolved;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function applyContextSnapshotToChatEnvelope(chatEnvelope, snapshot) {
|
|
19
|
+
const hasExistingTools = Array.isArray(chatEnvelope.tools) && chatEnvelope.tools.length > 0;
|
|
20
|
+
const patch = applyReqOutboundContextSnapshotWithNative({
|
|
21
|
+
chatEnvelope: chatEnvelope,
|
|
22
|
+
snapshot
|
|
23
|
+
});
|
|
24
|
+
if (Array.isArray(patch.toolOutputs) && patch.toolOutputs.length) {
|
|
25
|
+
chatEnvelope.toolOutputs = patch.toolOutputs;
|
|
26
|
+
}
|
|
27
|
+
if (!hasExistingTools && Array.isArray(patch.tools) && patch.tools.length) {
|
|
28
|
+
chatEnvelope.tools = patch.tools;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/index.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { standardizedToChatEnvelope } from '../../../../standardized-bridge.js';
|
|
2
|
-
import { validateChatEnvelope } from '../../../../../shared/chat-envelope-validator.js';
|
|
3
1
|
import { applyHubOperationTableOutboundPostMap, applyHubOperationTableOutboundPreMap } from '../../../../operation-table/operation-table-runner.js';
|
|
4
2
|
import { recordStage } from '../../../stages/utils.js';
|
|
3
|
+
import { applyContextSnapshotToChatEnvelope, applyToolCallIdStyleMetadata } from './context-merge.js';
|
|
4
|
+
import { shouldAttachReqOutboundContextSnapshotWithNative, standardizedToChatEnvelopeWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js';
|
|
5
|
+
import { validateChatEnvelopeWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js';
|
|
5
6
|
export async function runReqOutboundStage1SemanticMap(options) {
|
|
6
|
-
const chatEnvelope =
|
|
7
|
+
const chatEnvelope = standardizedToChatEnvelopeWithNative({
|
|
8
|
+
request: options.request,
|
|
7
9
|
adapterContext: options.adapterContext
|
|
8
10
|
});
|
|
9
11
|
applyToolCallIdStyleMetadata(chatEnvelope, options.adapterContext, options.contextSnapshot);
|
|
10
|
-
|
|
12
|
+
const shouldAttachContextSnapshot = shouldAttachReqOutboundContextSnapshotWithNative(Boolean(options.contextSnapshot), options.contextMetadataKey);
|
|
13
|
+
if (shouldAttachContextSnapshot && options.contextSnapshot && options.contextMetadataKey) {
|
|
11
14
|
const snapshot = options.contextSnapshot;
|
|
12
15
|
chatEnvelope.metadata[options.contextMetadataKey] = snapshot;
|
|
13
|
-
|
|
14
|
-
attachToolsFromContext(chatEnvelope, snapshot);
|
|
16
|
+
applyContextSnapshotToChatEnvelope(chatEnvelope, snapshot);
|
|
15
17
|
}
|
|
16
|
-
|
|
18
|
+
validateChatEnvelopeWithNative(chatEnvelope, {
|
|
17
19
|
stage: 'req_outbound',
|
|
18
20
|
direction: 'request'
|
|
19
21
|
});
|
|
@@ -31,125 +33,3 @@ export async function runReqOutboundStage1SemanticMap(options) {
|
|
|
31
33
|
recordStage(options.stageRecorder, 'chat_process.req.stage6.outbound.semantic_map', chatEnvelope);
|
|
32
34
|
return { chatEnvelope, formatEnvelope };
|
|
33
35
|
}
|
|
34
|
-
function attachToolOutputsFromContext(chatEnvelope, snapshot) {
|
|
35
|
-
const outputsRaw = snapshot?.tool_outputs;
|
|
36
|
-
if (!Array.isArray(outputsRaw) || !outputsRaw.length) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const normalized = outputsRaw
|
|
40
|
-
.map((entry) => normalizeToolOutput(entry))
|
|
41
|
-
.filter((entry) => Boolean(entry));
|
|
42
|
-
if (!normalized.length) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const existing = Array.isArray(chatEnvelope.toolOutputs) ? chatEnvelope.toolOutputs.slice() : [];
|
|
46
|
-
const known = new Set(existing.map((entry) => entry.tool_call_id).filter(Boolean));
|
|
47
|
-
for (const entry of normalized) {
|
|
48
|
-
if (entry.tool_call_id && !known.has(entry.tool_call_id)) {
|
|
49
|
-
existing.push(entry);
|
|
50
|
-
known.add(entry.tool_call_id);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (existing.length) {
|
|
54
|
-
chatEnvelope.toolOutputs = existing;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function attachToolsFromContext(chatEnvelope, snapshot) {
|
|
58
|
-
if (Array.isArray(chatEnvelope.tools) && chatEnvelope.tools.length) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const normalized = snapshot?.toolsNormalized ?? snapshot?.tools;
|
|
62
|
-
if (!Array.isArray(normalized) || !normalized.length) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const tools = normalized
|
|
66
|
-
.map((entry) => normalizeToolDefinition(entry))
|
|
67
|
-
.filter((entry) => Boolean(entry));
|
|
68
|
-
if (tools.length) {
|
|
69
|
-
chatEnvelope.tools = tools;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function normalizeToolDefinition(entry) {
|
|
73
|
-
if (!entry || typeof entry !== 'object') {
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
const record = entry;
|
|
77
|
-
if (record.type !== 'function') {
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
const fn = record.function;
|
|
81
|
-
if (!fn || typeof fn !== 'object') {
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
const fnRecord = fn;
|
|
85
|
-
const name = typeof fnRecord.name === 'string' && fnRecord.name.trim().length ? fnRecord.name.trim() : undefined;
|
|
86
|
-
if (!name) {
|
|
87
|
-
return undefined;
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
type: 'function',
|
|
91
|
-
function: {
|
|
92
|
-
name,
|
|
93
|
-
description: typeof fnRecord.description === 'string' ? fnRecord.description : undefined,
|
|
94
|
-
parameters: (fnRecord.parameters ?? { type: 'object', properties: {} }),
|
|
95
|
-
strict: typeof fnRecord.strict === 'boolean' ? fnRecord.strict : undefined
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function normalizeToolOutput(entry) {
|
|
100
|
-
if (!entry || typeof entry !== 'object') {
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
const record = entry;
|
|
104
|
-
const toolCallId = typeof record.tool_call_id === 'string' && record.tool_call_id.trim().length
|
|
105
|
-
? record.tool_call_id.trim()
|
|
106
|
-
: typeof record.call_id === 'string' && record.call_id.trim().length
|
|
107
|
-
? record.call_id.trim()
|
|
108
|
-
: undefined;
|
|
109
|
-
if (!toolCallId) {
|
|
110
|
-
return undefined;
|
|
111
|
-
}
|
|
112
|
-
let content = '';
|
|
113
|
-
const rawOutput = 'output' in record ? record.output : record.content;
|
|
114
|
-
if (typeof rawOutput === 'string') {
|
|
115
|
-
content = rawOutput;
|
|
116
|
-
}
|
|
117
|
-
else if (rawOutput !== undefined) {
|
|
118
|
-
try {
|
|
119
|
-
content = JSON.stringify(rawOutput);
|
|
120
|
-
}
|
|
121
|
-
catch {
|
|
122
|
-
content = String(rawOutput);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
const name = typeof record.name === 'string' && record.name.trim().length ? record.name.trim() : undefined;
|
|
126
|
-
return {
|
|
127
|
-
tool_call_id: toolCallId,
|
|
128
|
-
content,
|
|
129
|
-
name
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
function applyToolCallIdStyleMetadata(chatEnvelope, adapterContext, snapshot) {
|
|
133
|
-
const metadata = chatEnvelope.metadata || (chatEnvelope.metadata = { context: adapterContext });
|
|
134
|
-
const current = typeof metadata.toolCallIdStyle === 'string'
|
|
135
|
-
? String(metadata.toolCallIdStyle).trim()
|
|
136
|
-
: '';
|
|
137
|
-
const resolved = selectToolCallIdStyle(adapterContext, snapshot);
|
|
138
|
-
if (!resolved) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
// Always honor the route-selected AdapterContext toolCallIdStyle when present.
|
|
142
|
-
// This prevents cross-provider leakage (e.g. LM Studio "preserve" contaminating OpenAI "fc").
|
|
143
|
-
if (!current || current !== resolved) {
|
|
144
|
-
metadata.toolCallIdStyle = resolved;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function selectToolCallIdStyle(adapterContext, snapshot) {
|
|
148
|
-
if (adapterContext && typeof adapterContext.toolCallIdStyle === 'string' && adapterContext.toolCallIdStyle.trim().length) {
|
|
149
|
-
return adapterContext.toolCallIdStyle;
|
|
150
|
-
}
|
|
151
|
-
if (snapshot && typeof snapshot.toolCallIdStyle === 'string' && snapshot.toolCallIdStyle.trim().length) {
|
|
152
|
-
return String(snapshot.toolCallIdStyle);
|
|
153
|
-
}
|
|
154
|
-
return undefined;
|
|
155
|
-
}
|
package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import type { AdapterContext } from '../../../../types/chat-envelope.js';
|
|
2
1
|
import type { FormatEnvelope } from '../../../../types/format-envelope.js';
|
|
3
2
|
import type { JsonObject } from '../../../../types/json.js';
|
|
4
|
-
import type {
|
|
3
|
+
import type { StageRecorder } from '../../../../format-adapters/index.js';
|
|
5
4
|
export interface ReqOutboundStage2FormatBuildOptions {
|
|
6
5
|
formatEnvelope: FormatEnvelope<JsonObject>;
|
|
7
|
-
adapterContext: AdapterContext;
|
|
8
|
-
formatAdapter: Pick<FormatAdapter, 'buildRequest'>;
|
|
9
6
|
stageRecorder?: StageRecorder;
|
|
10
7
|
}
|
|
11
8
|
export declare function runReqOutboundStage2FormatBuild(options: ReqOutboundStage2FormatBuildOptions): Promise<JsonObject>;
|
package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.js
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
import { recordStage } from '../../../stages/utils.js';
|
|
2
|
-
|
|
2
|
+
import { stripPrivateFieldsWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js';
|
|
3
|
+
import { buildReqOutboundFormatPayloadWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js';
|
|
3
4
|
export async function runReqOutboundStage2FormatBuild(options) {
|
|
4
|
-
const payload = (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (Array.isArray(value)) {
|
|
14
|
-
value.forEach((entry) => stripPrivateFields(entry));
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (typeof value !== 'object') {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const record = value;
|
|
21
|
-
for (const key of Object.keys(record)) {
|
|
22
|
-
const child = record[key];
|
|
23
|
-
if (typeof key === 'string' && key.startsWith(PRIVATE_FIELD_PREFIX)) {
|
|
24
|
-
delete record[key];
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
stripPrivateFields(child);
|
|
28
|
-
}
|
|
5
|
+
const payload = buildReqOutboundFormatPayloadWithNative({
|
|
6
|
+
formatEnvelope: options.formatEnvelope,
|
|
7
|
+
protocol: options.formatEnvelope.protocol
|
|
8
|
+
});
|
|
9
|
+
const stripped = stripPrivateFieldsWithNative(payload);
|
|
10
|
+
recordStage(options.stageRecorder, 'chat_process.req.stage7.outbound.format_build', stripped);
|
|
11
|
+
return stripped;
|
|
29
12
|
}
|
package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js
CHANGED
|
@@ -1,27 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { buildNativeReqOutboundCompatAdapterContext } from '../../../compat/native-adapter-context.js';
|
|
2
|
+
import { resolveCompatProfileWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js';
|
|
3
|
+
import { runReqOutboundStage3CompatWithNative, runRespInboundStage3CompatWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js';
|
|
4
|
+
const RATE_LIMIT_ERROR = 'ERR_COMPAT_RATE_LIMIT_DETECTED';
|
|
3
5
|
function pickCompatProfile(adapterContext) {
|
|
4
6
|
const candidate = adapterContext.compatibilityProfile;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
return resolveCompatProfileForContext(adapterContext);
|
|
7
|
+
const explicit = typeof candidate === 'string' && candidate.trim() ? candidate.trim() : undefined;
|
|
8
|
+
return resolveCompatProfileWithNative(adapterContext, explicit);
|
|
9
9
|
}
|
|
10
10
|
export async function runReqOutboundStage3Compat(options) {
|
|
11
11
|
const profile = pickCompatProfile(options.adapterContext);
|
|
12
|
-
const
|
|
12
|
+
const nativeCompat = runReqOutboundStage3CompatWithNative({
|
|
13
|
+
payload: options.payload,
|
|
14
|
+
adapterContext: buildNativeReqOutboundCompatAdapterContext(options.adapterContext),
|
|
15
|
+
explicitProfile: profile
|
|
16
|
+
});
|
|
17
|
+
const effectiveProfile = nativeCompat.appliedProfile ?? profile;
|
|
18
|
+
const appliedProfile = nativeCompat.appliedProfile;
|
|
13
19
|
options.stageRecorder?.record('chat_process.req.stage8.outbound.compat', {
|
|
14
|
-
applied: Boolean(
|
|
15
|
-
profile:
|
|
20
|
+
applied: Boolean(appliedProfile),
|
|
21
|
+
profile: appliedProfile || effectiveProfile || 'passthrough'
|
|
16
22
|
});
|
|
17
|
-
return
|
|
23
|
+
return nativeCompat.payload;
|
|
18
24
|
}
|
|
19
25
|
export function runRespInboundStageCompatResponse(options) {
|
|
20
26
|
const profile = pickCompatProfile(options.adapterContext);
|
|
21
|
-
const
|
|
27
|
+
const nativeCompat = runRespInboundStage3CompatWithNative({
|
|
28
|
+
payload: options.payload,
|
|
29
|
+
adapterContext: buildNativeReqOutboundCompatAdapterContext(options.adapterContext),
|
|
30
|
+
explicitProfile: profile
|
|
31
|
+
});
|
|
32
|
+
const effectiveProfile = nativeCompat.appliedProfile ?? profile;
|
|
33
|
+
const appliedProfile = nativeCompat.appliedProfile;
|
|
34
|
+
if (nativeCompat.nativeApplied === true && nativeCompat.rateLimitDetected === true) {
|
|
35
|
+
const err = new Error('Provider returned rate limit notice');
|
|
36
|
+
err.code = RATE_LIMIT_ERROR;
|
|
37
|
+
err.statusCode = 429;
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
22
40
|
options.stageRecorder?.record('chat_process.resp.stage3.compat', {
|
|
23
|
-
applied: Boolean(
|
|
24
|
-
profile:
|
|
41
|
+
applied: Boolean(appliedProfile),
|
|
42
|
+
profile: appliedProfile || effectiveProfile || 'passthrough'
|
|
25
43
|
});
|
|
26
|
-
return
|
|
44
|
+
return nativeCompat.payload;
|
|
27
45
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StageRecorder } from '../../../../format-adapters/index.js';
|
|
2
2
|
import type { ProcessedRequest, StandardizedRequest } from '../../../../types/standardized.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { HubProcessNodeResult } from '../../../../process/chat-process.js';
|
|
4
4
|
export interface ReqProcessStage1ToolGovernanceOptions {
|
|
5
5
|
request: StandardizedRequest;
|
|
6
6
|
rawPayload: Record<string, unknown>;
|
|
@@ -11,6 +11,6 @@ export interface ReqProcessStage1ToolGovernanceOptions {
|
|
|
11
11
|
}
|
|
12
12
|
export interface ReqProcessStage1ToolGovernanceResult {
|
|
13
13
|
processedRequest?: ProcessedRequest;
|
|
14
|
-
nodeResult?:
|
|
14
|
+
nodeResult?: HubProcessNodeResult;
|
|
15
15
|
}
|
|
16
16
|
export declare function runReqProcessStage1ToolGovernance(options: ReqProcessStage1ToolGovernanceOptions): Promise<ReqProcessStage1ToolGovernanceResult>;
|
package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.js
CHANGED
|
@@ -1,19 +1,59 @@
|
|
|
1
|
-
import { runHubChatProcess } from '../../../../process/chat-process.js';
|
|
2
1
|
import { recordStage } from '../../../stages/utils.js';
|
|
3
2
|
import { captureApplyPatchExecutionFailuresFromProcessedRequest } from '../../../../../../tools/apply-patch/execution-capturer.js';
|
|
3
|
+
import { applyReqProcessToolGovernanceWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.js';
|
|
4
|
+
import { maybeInjectClockRemindersAndApplyDirectives } from '../../../../process/chat-process-clock-reminders.js';
|
|
5
|
+
function isRecord(value) {
|
|
6
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function parseProcessedRequest(value) {
|
|
9
|
+
if (!isRecord(value)) {
|
|
10
|
+
throw new Error('native req_process_stage1_tool_governance returned invalid processedRequest');
|
|
11
|
+
}
|
|
12
|
+
if (typeof value.model !== 'string' || !Array.isArray(value.messages) || !isRecord(value.parameters) || !isRecord(value.metadata)) {
|
|
13
|
+
throw new Error('native req_process_stage1_tool_governance returned malformed processedRequest envelope');
|
|
14
|
+
}
|
|
15
|
+
if (!isRecord(value.processed) || !isRecord(value.processingMetadata)) {
|
|
16
|
+
throw new Error('native req_process_stage1_tool_governance missing processed/processingMetadata');
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
function parseNodeResult(value) {
|
|
21
|
+
if (!isRecord(value) || typeof value.success !== 'boolean' || !isRecord(value.metadata)) {
|
|
22
|
+
throw new Error('native req_process_stage1_tool_governance returned invalid nodeResult');
|
|
23
|
+
}
|
|
24
|
+
const errorValue = value.error;
|
|
25
|
+
if (errorValue !== undefined && (!isRecord(errorValue) || typeof errorValue.message !== 'string')) {
|
|
26
|
+
throw new Error('native req_process_stage1_tool_governance returned invalid nodeResult.error');
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
4
30
|
export async function runReqProcessStage1ToolGovernance(options) {
|
|
5
|
-
const
|
|
31
|
+
const nativeResult = applyReqProcessToolGovernanceWithNative({
|
|
6
32
|
request: options.request,
|
|
7
33
|
rawPayload: options.rawPayload,
|
|
8
34
|
metadata: options.metadata,
|
|
9
35
|
entryEndpoint: options.entryEndpoint,
|
|
10
36
|
requestId: options.requestId
|
|
11
37
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
38
|
+
let processedRequest = parseProcessedRequest(nativeResult.processedRequest);
|
|
39
|
+
const nodeResult = parseNodeResult(nativeResult.nodeResult);
|
|
40
|
+
processedRequest = await maybeInjectClockRemindersAndApplyDirectives(processedRequest, options.metadata, options.requestId);
|
|
41
|
+
const nodeResultMetadata = nodeResult.metadata && typeof nodeResult.metadata === 'object'
|
|
42
|
+
? nodeResult.metadata
|
|
43
|
+
: null;
|
|
44
|
+
const dataProcessed = nodeResultMetadata?.dataProcessed && typeof nodeResultMetadata.dataProcessed === 'object'
|
|
45
|
+
? nodeResultMetadata.dataProcessed
|
|
46
|
+
: null;
|
|
47
|
+
if (dataProcessed) {
|
|
48
|
+
dataProcessed.messages = Array.isArray(processedRequest.messages) ? processedRequest.messages.length : 0;
|
|
49
|
+
dataProcessed.tools = Array.isArray(processedRequest.tools) ? processedRequest.tools.length : 0;
|
|
17
50
|
}
|
|
18
|
-
|
|
51
|
+
recordStage(options.stageRecorder, 'chat_process.req.stage4.tool_governance', processedRequest);
|
|
52
|
+
// Best-effort: capture apply_patch execution failures reported by tool role messages.
|
|
53
|
+
// This is for errorsamples collection only and must not affect runtime behavior.
|
|
54
|
+
captureApplyPatchExecutionFailuresFromProcessedRequest(processedRequest);
|
|
55
|
+
return {
|
|
56
|
+
processedRequest,
|
|
57
|
+
nodeResult
|
|
58
|
+
};
|
|
19
59
|
}
|
package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage2_route_select/index.js
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import { recordStage } from '../../../stages/utils.js';
|
|
2
|
-
import {
|
|
2
|
+
import { applyReqProcessRouteSelectionWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.js';
|
|
3
|
+
function replaceRecordInPlace(target, source) {
|
|
4
|
+
for (const key of Object.keys(target)) {
|
|
5
|
+
if (!Object.prototype.hasOwnProperty.call(source, key)) {
|
|
6
|
+
delete target[key];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
Object.assign(target, source);
|
|
10
|
+
}
|
|
3
11
|
export function runReqProcessStage2RouteSelect(options) {
|
|
4
12
|
const previousModel = typeof options.request.model === 'string' ? options.request.model : undefined;
|
|
5
13
|
const result = options.routerEngine.route(options.request, options.metadataInput);
|
|
6
|
-
|
|
7
|
-
|
|
14
|
+
const nativeApplied = applyReqProcessRouteSelectionWithNative({
|
|
15
|
+
request: options.request,
|
|
16
|
+
normalizedMetadata: options.normalizedMetadata,
|
|
17
|
+
target: result.target,
|
|
18
|
+
routeName: result.decision.routeName,
|
|
19
|
+
originalModel: previousModel
|
|
20
|
+
});
|
|
21
|
+
replaceRecordInPlace(options.request, nativeApplied.request);
|
|
22
|
+
replaceRecordInPlace(options.normalizedMetadata, nativeApplied.normalizedMetadata);
|
|
8
23
|
recordStage(options.stageRecorder, 'chat_process.req.stage5.route_select', {
|
|
9
24
|
target: result.target,
|
|
10
25
|
decision: result.decision,
|