@jsonstudio/llms 0.6.2172 → 0.6.2979
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/conversion/compat/antigravity-session-signature.js +35 -1
- package/dist/conversion/compat/profiles/chat-gemini-cli.json +0 -7
- package/dist/conversion/compat/profiles/chat-gemini.json +0 -6
- package/dist/conversion/hub/core/detour-registry.d.ts +2 -0
- package/dist/conversion/hub/core/hub-context.d.ts +3 -1
- package/dist/conversion/hub/core/index.d.ts +1 -0
- package/dist/conversion/hub/core/stage-driver.js +2 -0
- package/dist/conversion/hub/format-adapters/anthropic-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/chat-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/gemini-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/responses-format-adapter.js +15 -4
- package/dist/conversion/hub/hub-feature.js +3 -2
- package/dist/conversion/hub/node-support.js +9 -4
- package/dist/conversion/hub/operation-table/operation-table-runner.js +10 -6
- package/dist/conversion/hub/operation-table/semantic-mappers/anthropic-mapper.js +2 -2
- package/dist/conversion/hub/operation-table/semantic-mappers/chat-mapper.js +10 -10
- package/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.js +4 -8
- package/dist/conversion/hub/operation-table/semantic-mappers/responses-mapper.js +19 -65
- package/dist/conversion/hub/ops/operations.js +2 -121
- package/dist/conversion/hub/pipeline/compat/compat-engine.js +6 -0
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.d.ts +1 -1
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +33 -1042
- package/dist/conversion/hub/pipeline/compat/compat-profile-resolver.js +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-profile-store.js +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-types.d.ts +14 -17
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.d.ts +3 -0
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.js +39 -0
- package/dist/conversion/hub/pipeline/hub-pipeline.js +115 -262
- package/dist/conversion/hub/pipeline/session-identifiers.js +6 -196
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.js +37 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.js +12 -86
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.d.ts +14 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.js +24 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.d.ts +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.js +157 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.d.ts +16 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.js +29 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-factories.js +3 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.d.ts +2 -15
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.js +8 -595
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.d.ts +8 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.js +28 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.d.ts +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.js +4 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.d.ts +10 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.js +12 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.js +30 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/index.js +9 -129
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.d.ts +1 -4
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.js +9 -26
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +32 -14
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.d.ts +2 -2
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.js +48 -8
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage2_route_select/index.js +18 -3
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/index.js +10 -198
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.js +81 -0
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.js +36 -1
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage3_semantic_map/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.d.ts +6 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.js +17 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.d.ts +9 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.js +28 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.js +14 -102
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage2_sse_stream/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage1_tool_governance/index.js +12 -10
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage2_finalize/index.js +6 -5
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.d.ts +11 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.js +10 -32
- package/dist/conversion/hub/pipeline/stages/utils.js +17 -1
- package/dist/conversion/hub/pipeline/target-utils.js +14 -91
- package/dist/conversion/hub/pipelines/inbound.js +3 -1
- package/dist/conversion/hub/pipelines/outbound.js +2 -0
- package/dist/conversion/hub/policy/policy-engine.js +9 -3
- package/dist/conversion/hub/policy/protocol-spec.js +20 -148
- package/dist/conversion/hub/process/chat-process-anthropic-alias.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-anthropic-alias.js +36 -0
- package/dist/conversion/hub/process/chat-process-clock-directive-parser.d.ts +5 -0
- package/dist/conversion/hub/process/chat-process-clock-directive-parser.js +48 -0
- package/dist/conversion/hub/process/chat-process-clock-directives.d.ts +24 -0
- package/dist/conversion/hub/process/chat-process-clock-directives.js +98 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-directives.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-directives.js +42 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-finalize.d.ts +14 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-finalize.js +10 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-messages.d.ts +5 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-messages.js +10 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.d.ts +30 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.js +68 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.d.ts +9 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.js +18 -0
- package/dist/conversion/hub/process/chat-process-clock-reminders.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-clock-reminders.js +104 -0
- package/dist/conversion/hub/process/chat-process-clock-tool-schemas.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-clock-tool-schemas.js +233 -0
- package/dist/conversion/hub/process/chat-process-clock-tools.d.ts +6 -0
- package/dist/conversion/hub/process/chat-process-clock-tools.js +41 -0
- package/dist/conversion/hub/process/chat-process-continue-execution.d.ts +11 -0
- package/dist/conversion/hub/process/chat-process-continue-execution.js +82 -0
- package/dist/conversion/hub/process/chat-process-governance-context.d.ts +15 -0
- package/dist/conversion/hub/process/chat-process-governance-context.js +7 -0
- package/dist/conversion/hub/process/chat-process-governance-finalize.d.ts +16 -0
- package/dist/conversion/hub/process/chat-process-governance-finalize.js +11 -0
- package/dist/conversion/hub/process/chat-process-governance-orchestration.d.ts +9 -0
- package/dist/conversion/hub/process/chat-process-governance-orchestration.js +47 -0
- package/dist/conversion/hub/process/chat-process-governed-control-ops.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-governed-control-ops.js +5 -0
- package/dist/conversion/hub/process/chat-process-governed-filter-call.d.ts +12 -0
- package/dist/conversion/hub/process/chat-process-governed-filter-call.js +18 -0
- package/dist/conversion/hub/process/chat-process-governed-merge.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-governed-merge.js +11 -0
- package/dist/conversion/hub/process/chat-process-media.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-media.js +18 -0
- package/dist/conversion/hub/process/chat-process-node-result.d.ts +23 -0
- package/dist/conversion/hub/process/chat-process-node-result.js +24 -0
- package/dist/conversion/hub/process/chat-process-pending-tool-sync.d.ts +14 -0
- package/dist/conversion/hub/process/chat-process-pending-tool-sync.js +52 -0
- package/dist/conversion/hub/process/chat-process-post-governed-normalization.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-post-governed-normalization.js +16 -0
- package/dist/conversion/hub/process/chat-process-review.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-review.js +8 -0
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.js +22 -0
- package/dist/conversion/hub/process/chat-process-tool-normalization.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-tool-normalization.js +4 -0
- package/dist/conversion/hub/process/chat-process-web-search-intent.d.ts +12 -0
- package/dist/conversion/hub/process/chat-process-web-search-intent.js +13 -0
- package/dist/conversion/hub/process/chat-process-web-search-tool-schema.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-web-search-tool-schema.js +4 -0
- package/dist/conversion/hub/process/chat-process-web-search.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-web-search.js +26 -0
- package/dist/conversion/hub/process/chat-process.d.ts +2 -19
- package/dist/conversion/hub/process/chat-process.js +12 -1701
- package/dist/conversion/hub/process/client-inject-readiness.d.ts +1 -0
- package/dist/conversion/hub/process/client-inject-readiness.js +4 -0
- package/dist/conversion/hub/registry.js +5 -2
- package/dist/conversion/hub/response/chat-response-utils.js +5 -86
- package/dist/conversion/hub/response/provider-response.d.ts +9 -0
- package/dist/conversion/hub/response/provider-response.js +6 -21
- package/dist/conversion/hub/response/response-mappers.js +2 -26
- package/dist/conversion/hub/response/response-runtime.js +2 -93
- package/dist/conversion/hub/semantic-mappers/anthropic-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/anthropic-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/chat-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/chat-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/gemini-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/gemini-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/responses-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/responses-mapper.js +1 -0
- package/dist/conversion/hub/snapshot-recorder.js +10 -3
- package/dist/conversion/hub/standardized-bridge.js +11 -288
- package/dist/conversion/hub/tool-governance/engine.js +5 -0
- package/dist/conversion/hub/tool-governance/rules.js +10 -10
- package/dist/conversion/hub/tool-session-compat.d.ts +2 -2
- package/dist/conversion/hub/tool-session-compat.js +17 -231
- package/dist/conversion/hub/tool-surface/tool-surface-engine.js +5 -3
- package/dist/conversion/responses/responses-host-policy.js +2 -12
- package/dist/conversion/responses/responses-openai-bridge/response-payload.js +6 -82
- package/dist/conversion/responses/responses-openai-bridge/types.d.ts +1 -0
- package/dist/conversion/responses/responses-openai-bridge.js +21 -54
- package/dist/conversion/shared/anthropic-message-utils.js +151 -13
- package/dist/conversion/shared/args-mapping.js +2 -146
- package/dist/conversion/shared/bridge-actions.js +203 -718
- package/dist/conversion/shared/bridge-id-utils.js +5 -71
- package/dist/conversion/shared/bridge-instructions.js +2 -1
- package/dist/conversion/shared/bridge-message-types.d.ts +2 -0
- package/dist/conversion/shared/bridge-message-utils.js +1 -2
- package/dist/conversion/shared/bridge-metadata.d.ts +1 -0
- package/dist/conversion/shared/bridge-metadata.js +4 -0
- package/dist/conversion/shared/bridge-policies.js +5 -189
- package/dist/conversion/shared/chat-envelope-validator.js +2 -126
- package/dist/conversion/shared/chat-output-normalizer.js +2 -54
- package/dist/conversion/shared/compaction-detect.js +2 -57
- package/dist/conversion/shared/gemini-tool-utils.js +9 -524
- package/dist/conversion/shared/jsonish.js +3 -160
- package/dist/conversion/shared/mcp-injection.js +3 -169
- package/dist/conversion/shared/media.js +2 -7
- package/dist/conversion/shared/metadata-passthrough.js +9 -46
- package/dist/conversion/shared/openai-finalizer.js +2 -1
- package/dist/conversion/shared/openai-message-normalize.js +11 -283
- package/dist/conversion/shared/output-content-normalizer.js +9 -112
- package/dist/conversion/shared/payload-budget.js +2 -85
- package/dist/conversion/shared/protocol-state.js +11 -7
- package/dist/conversion/shared/reasoning-mapping.js +2 -6
- package/dist/conversion/shared/reasoning-normalizer.js +4 -1
- package/dist/conversion/shared/reasoning-tool-normalizer.js +14 -126
- package/dist/conversion/shared/reasoning-tool-parser.js +4 -87
- package/dist/conversion/shared/reasoning-utils.js +2 -6
- package/dist/conversion/shared/responses-conversation-store.js +4 -82
- package/dist/conversion/shared/responses-output-builder.js +11 -47
- package/dist/conversion/shared/responses-reasoning-registry.js +7 -1
- package/dist/conversion/shared/responses-request-adapter.d.ts +7 -1
- package/dist/conversion/shared/responses-request-adapter.js +14 -1
- package/dist/conversion/shared/responses-response-utils.js +6 -7
- package/dist/conversion/shared/responses-tool-utils.d.ts +1 -0
- package/dist/conversion/shared/responses-tool-utils.js +90 -14
- package/dist/conversion/shared/runtime-metadata.js +13 -5
- package/dist/conversion/shared/streaming-text-extractor.js +2 -7
- package/dist/conversion/shared/text-markup-normalizer/normalize.d.ts +1 -1
- package/dist/conversion/shared/text-markup-normalizer/normalize.js +43 -17
- package/dist/conversion/shared/text-markup-normalizer.d.ts +1 -0
- package/dist/conversion/shared/text-markup-normalizer.js +1 -0
- package/dist/conversion/shared/thought-signature-validator.js +3 -2
- package/dist/conversion/shared/tool-argument-repairer.js +2 -2
- package/dist/conversion/shared/tool-call-id-manager.js +5 -7
- package/dist/conversion/shared/tool-call-utils.js +3 -45
- package/dist/conversion/shared/tool-canonicalizer.js +25 -29
- package/dist/conversion/shared/tool-filter-pipeline.js +4 -99
- package/dist/conversion/shared/tool-governor.d.ts +6 -0
- package/dist/conversion/shared/tool-governor.js +43 -125
- package/dist/conversion/shared/tool-harvester.js +2 -8
- package/dist/conversion/shared/tool-mapping.js +2 -5
- package/dist/conversion/shared/tooling.d.ts +0 -4
- package/dist/conversion/shared/tooling.js +18 -0
- package/dist/native/router_hotpath_napi.node +0 -0
- package/dist/router/virtual-router/engine/provider-key/parse.d.ts +1 -6
- package/dist/router/virtual-router/engine/provider-key/parse.js +1 -43
- package/dist/router/virtual-router/engine/routing-state/store.js +48 -12
- package/dist/router/virtual-router/engine-logging.js +4 -3
- package/dist/router/virtual-router/engine-selection/alias-selection.js +45 -83
- package/dist/router/virtual-router/engine-selection/key-parsing.js +9 -23
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.d.ts +20 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.js +163 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.d.ts +7 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.js +103 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.js +110 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.d.ts +8 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.js +281 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.js +25 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.d.ts +4 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.js +44 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.js +62 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.d.ts +40 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.js +484 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.d.ts +9 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.js +64 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.js +163 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.js +49 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.d.ts +30 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.js +446 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.js +49 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.d.ts +134 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js +729 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.d.ts +62 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.js +338 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.d.ts +18 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js +317 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.d.ts +22 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.js +426 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.d.ts +57 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.js +705 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.d.ts +46 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js +503 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.d.ts +146 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js +570 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.js +148 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.js +637 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.d.ts +11 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.js +207 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.d.ts +3 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.js +128 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.d.ts +57 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.js +217 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.js +284 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.js +18 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.js +85 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath.d.ts +59 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath.js +117 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.d.ts +76 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.js +1166 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.d.ts +16 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.js +96 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.d.ts +6 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.js +85 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.d.ts +9 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.js +70 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.js +76 -0
- package/dist/router/virtual-router/engine-selection/route-utils.js +1 -1
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.js +231 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.d.ts +4 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.js +43 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.d.ts +27 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.js +116 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-select.d.ts +1 -1
- package/dist/router/virtual-router/engine-selection/tier-selection-select.js +29 -129
- package/dist/router/virtual-router/engine-selection/tier-selection.js +2 -265
- package/dist/router/virtual-router/engine.js +258 -249
- package/dist/router/virtual-router/features.js +2 -2
- package/dist/router/virtual-router/routing-instructions.d.ts +5 -7
- package/dist/router/virtual-router/routing-instructions.js +93 -66
- package/dist/router/virtual-router/routing-stop-message-actions.js +91 -112
- package/dist/router/virtual-router/routing-stop-message-parser.js +9 -132
- package/dist/router/virtual-router/routing-stop-message-state-codec.d.ts +1 -0
- package/dist/router/virtual-router/routing-stop-message-state-codec.js +58 -71
- package/dist/router/virtual-router/sticky-session-store.js +4 -2
- package/dist/router/virtual-router/stop-message-file-resolver.d.ts +1 -0
- package/dist/router/virtual-router/stop-message-file-resolver.js +10 -0
- package/dist/router/virtual-router/stop-message-state-sync.d.ts +1 -1
- package/dist/router/virtual-router/stop-message-state-sync.js +3 -7
- package/dist/router/virtual-router/token-counter.js +0 -9
- package/dist/router/virtual-router/types.d.ts +9 -7
- package/dist/servertool/clock/config.js +23 -51
- package/dist/servertool/clock/io.js +1 -0
- package/dist/servertool/clock/session-scope.d.ts +2 -2
- package/dist/servertool/clock/session-scope.js +5 -47
- package/dist/servertool/engine.d.ts +9 -0
- package/dist/servertool/engine.js +196 -79
- package/dist/servertool/handlers/antigravity-thought-signature-bootstrap.js +2 -2
- package/dist/servertool/handlers/clock.js +1 -1
- package/dist/servertool/handlers/continue-execution.js +8 -4
- package/dist/servertool/handlers/followup-request-builder.js +18 -1
- package/dist/servertool/handlers/gemini-empty-reply-continue.js +7 -1
- package/dist/servertool/handlers/review.js +180 -0
- package/dist/servertool/handlers/stop-message-auto/blocked-report.js +59 -1
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.d.ts +23 -2
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.js +397 -89
- package/dist/servertool/handlers/stop-message-auto/routing-state.d.ts +5 -15
- package/dist/servertool/handlers/stop-message-auto/routing-state.js +29 -55
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.d.ts +6 -0
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.js +35 -61
- package/dist/servertool/handlers/stop-message-auto.js +392 -76
- package/dist/servertool/server-side-tools.d.ts +1 -0
- package/dist/servertool/server-side-tools.js +90 -52
- package/dist/servertool/types.d.ts +17 -0
- package/dist/tools/apply-patch/patch-text/normalize.js +11 -0
- package/dist/tools/exec-command/validator.d.ts +4 -1
- package/dist/tools/exec-command/validator.js +87 -3
- package/dist/tools/tool-registry.d.ts +7 -1
- package/dist/tools/tool-registry.js +3 -2
- package/package.json +115 -7
- package/dist/servertool/handlers/stop-message-stage-policy/bd-runtime.d.ts +0 -18
- package/dist/servertool/handlers/stop-message-stage-policy/bd-runtime.js +0 -398
- package/dist/servertool/handlers/stop-message-stage-policy/decision.d.ts +0 -9
- package/dist/servertool/handlers/stop-message-stage-policy/decision.js +0 -127
- package/dist/servertool/handlers/stop-message-stage-policy/observation.d.ts +0 -2
- package/dist/servertool/handlers/stop-message-stage-policy/observation.js +0 -179
- package/dist/servertool/handlers/stop-message-stage-policy/templates.d.ts +0 -4
- package/dist/servertool/handlers/stop-message-stage-policy/templates.js +0 -96
- package/dist/servertool/handlers/stop-message-stage-policy/text-utils.d.ts +0 -9
- package/dist/servertool/handlers/stop-message-stage-policy/text-utils.js +0 -89
- package/dist/servertool/handlers/stop-message-stage-policy/types.d.ts +0 -59
- package/dist/servertool/handlers/stop-message-stage-policy.d.ts +0 -3
- package/dist/servertool/handlers/stop-message-stage-policy.js +0 -2
- /package/dist/servertool/handlers/{stop-message-stage-policy/types.js → review.d.ts} +0 -0
package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type { NativeContextToolOutput, NativeResumeToolOutput } from './native-hub-pipeline-inbound-outbound-semantics.js';
|
|
2
|
+
export interface NativeReqInboundSemanticLiftApplyInput {
|
|
3
|
+
chatEnvelope: Record<string, unknown>;
|
|
4
|
+
payload?: Record<string, unknown>;
|
|
5
|
+
protocol?: string;
|
|
6
|
+
entryEndpoint?: string;
|
|
7
|
+
responsesResume?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export type NativeProviderProtocolToken = NonNullable<NativeReqInboundSemanticLiftApplyInput['protocol']>;
|
|
10
|
+
export interface NativeReqInboundChatToStandardizedInput {
|
|
11
|
+
chatEnvelope: Record<string, unknown>;
|
|
12
|
+
adapterContext: Record<string, unknown>;
|
|
13
|
+
endpoint: string;
|
|
14
|
+
requestId?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function sanitizeReqInboundFormatEnvelopeWithNative<T>(candidate: unknown): T;
|
|
17
|
+
export declare function mapReqInboundResumeToolOutputsDetailedWithNative(responsesResume: unknown): Array<{
|
|
18
|
+
tool_call_id: string;
|
|
19
|
+
content: string;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function resolveClientInjectReadyWithNative(metadata: Record<string, unknown>): boolean;
|
|
22
|
+
export declare function normalizeContextCaptureLabelWithNative(label: string | undefined): string;
|
|
23
|
+
export declare function shouldRunHubChatProcessWithNative(requestId: string, entryEndpoint: string): boolean;
|
|
24
|
+
export declare function normalizeProviderProtocolTokenWithNative(value: string | undefined): string | undefined;
|
|
25
|
+
export declare function isShellLikeToolNameTokenWithNative(name: string | undefined): boolean;
|
|
26
|
+
export declare function applyReqInboundSemanticLiftWithNative(input: NativeReqInboundSemanticLiftApplyInput): Record<string, unknown>;
|
|
27
|
+
export declare function chatEnvelopeToStandardizedWithNative(input: NativeReqInboundChatToStandardizedInput): Record<string, unknown>;
|
|
28
|
+
export declare function resolveReqInboundServerToolFollowupSnapshotWithNative(adapterContext: unknown): Record<string, unknown> | undefined;
|
|
29
|
+
export declare function augmentReqInboundContextSnapshotWithNative(context: Record<string, unknown>, fallbackSnapshot: Record<string, unknown>): Record<string, unknown>;
|
|
30
|
+
export declare function normalizeReqInboundToolCallIdStyleWithNative(value: unknown): 'fc' | 'preserve' | undefined;
|
|
31
|
+
export declare function mapReqInboundBridgeToolsToChatWithNative(rawTools: unknown): Array<Record<string, unknown>>;
|
|
32
|
+
export declare function captureReqInboundResponsesContextSnapshotWithNative(input: {
|
|
33
|
+
rawRequest: Record<string, unknown>;
|
|
34
|
+
requestId?: string;
|
|
35
|
+
toolCallIdStyle?: unknown;
|
|
36
|
+
}): Record<string, unknown>;
|
|
37
|
+
export declare function collectReqInboundToolOutputsWithNative(payload: unknown): Array<{
|
|
38
|
+
tool_call_id: string;
|
|
39
|
+
call_id: string;
|
|
40
|
+
output?: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
}>;
|
|
43
|
+
export declare function buildReqInboundToolOutputSnapshotWithNative(payload: Record<string, unknown>, providerProtocol: string | undefined): Record<string, unknown>;
|
|
44
|
+
export declare function appendReqInboundToolParseDiagnosticTextWithNative(outputText: string, toolName: string | undefined): string | undefined;
|
|
45
|
+
export declare function injectReqInboundToolParseDiagnosticsWithNative(payload: Record<string, unknown>): void;
|
|
46
|
+
export declare function normalizeReqInboundShellLikeToolCallsWithNative(payload: Record<string, unknown>): void;
|
package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js
ADDED
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
import { failNativeRequired, isNativeDisabledByEnv } from './native-router-hotpath-policy.js';
|
|
2
|
+
import { loadNativeRouterHotpathBindingForInternalUse } from './native-router-hotpath.js';
|
|
3
|
+
import { sanitizeFormatEnvelopeWithNative } from './native-hub-pipeline-edge-stage-semantics.js';
|
|
4
|
+
import { augmentContextSnapshotWithNative, collectToolOutputsWithNative, mapResumeToolOutputsDetailedWithNative, normalizeToolCallIdStyleCandidateWithNative, resolveServerToolFollowupSnapshotWithNative } from './native-hub-pipeline-inbound-outbound-semantics.js';
|
|
5
|
+
function readNativeFunction(name) {
|
|
6
|
+
const binding = loadNativeRouterHotpathBindingForInternalUse();
|
|
7
|
+
const fn = binding?.[name];
|
|
8
|
+
return typeof fn === 'function' ? fn : null;
|
|
9
|
+
}
|
|
10
|
+
function parseOptionalString(raw) {
|
|
11
|
+
try {
|
|
12
|
+
const parsed = JSON.parse(raw);
|
|
13
|
+
if (parsed === null) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
if (typeof parsed !== 'string') {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const normalized = parsed.trim();
|
|
20
|
+
return normalized ? normalized : undefined;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function parseBoolean(raw) {
|
|
27
|
+
try {
|
|
28
|
+
const parsed = JSON.parse(raw);
|
|
29
|
+
return typeof parsed === 'boolean' ? parsed : null;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function parseRecord(raw) {
|
|
36
|
+
try {
|
|
37
|
+
const parsed = JSON.parse(raw);
|
|
38
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return parsed;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function parseArray(raw) {
|
|
48
|
+
try {
|
|
49
|
+
const parsed = JSON.parse(raw);
|
|
50
|
+
return Array.isArray(parsed) ? parsed : null;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function parseToolOutputSnapshotBuildResult(raw) {
|
|
57
|
+
const parsed = parseRecord(raw);
|
|
58
|
+
if (!parsed) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const snapshot = parsed.snapshot;
|
|
62
|
+
const payload = parsed.payload;
|
|
63
|
+
if (!snapshot || typeof snapshot !== 'object' || Array.isArray(snapshot)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
snapshot: snapshot,
|
|
71
|
+
payload: payload
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function safeStringify(value) {
|
|
75
|
+
try {
|
|
76
|
+
return JSON.stringify(value);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function replaceRecord(target, source) {
|
|
83
|
+
for (const key of Object.keys(target)) {
|
|
84
|
+
if (!Object.prototype.hasOwnProperty.call(source, key)) {
|
|
85
|
+
delete target[key];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
Object.assign(target, source);
|
|
89
|
+
}
|
|
90
|
+
export function sanitizeReqInboundFormatEnvelopeWithNative(candidate) {
|
|
91
|
+
return sanitizeFormatEnvelopeWithNative(candidate);
|
|
92
|
+
}
|
|
93
|
+
export function mapReqInboundResumeToolOutputsDetailedWithNative(responsesResume) {
|
|
94
|
+
return mapResumeToolOutputsDetailedWithNative(responsesResume);
|
|
95
|
+
}
|
|
96
|
+
export function resolveClientInjectReadyWithNative(metadata) {
|
|
97
|
+
const capability = 'resolveClientInjectReadyJson';
|
|
98
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
99
|
+
if (isNativeDisabledByEnv()) {
|
|
100
|
+
return fail('native disabled');
|
|
101
|
+
}
|
|
102
|
+
const fn = readNativeFunction('resolveClientInjectReadyJson');
|
|
103
|
+
if (!fn) {
|
|
104
|
+
return fail();
|
|
105
|
+
}
|
|
106
|
+
const metadataJson = safeStringify(metadata);
|
|
107
|
+
if (!metadataJson) {
|
|
108
|
+
return fail('json stringify failed');
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const raw = fn(metadataJson);
|
|
112
|
+
if (typeof raw !== 'string' || !raw) {
|
|
113
|
+
return fail('empty result');
|
|
114
|
+
}
|
|
115
|
+
const parsed = parseBoolean(raw);
|
|
116
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
120
|
+
return fail(reason);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export function normalizeContextCaptureLabelWithNative(label) {
|
|
124
|
+
const capability = 'normalizeContextCaptureLabelJson';
|
|
125
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
126
|
+
if (isNativeDisabledByEnv()) {
|
|
127
|
+
return fail('native disabled');
|
|
128
|
+
}
|
|
129
|
+
const fn = readNativeFunction('normalizeContextCaptureLabelJson');
|
|
130
|
+
if (!fn) {
|
|
131
|
+
return fail();
|
|
132
|
+
}
|
|
133
|
+
const labelJson = safeStringify(label ?? null);
|
|
134
|
+
if (!labelJson) {
|
|
135
|
+
return fail('json stringify failed');
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const raw = fn(labelJson);
|
|
139
|
+
if (typeof raw !== 'string' || !raw) {
|
|
140
|
+
return fail('empty result');
|
|
141
|
+
}
|
|
142
|
+
const parsed = parseOptionalString(raw);
|
|
143
|
+
if (parsed === null) {
|
|
144
|
+
return fail('invalid payload');
|
|
145
|
+
}
|
|
146
|
+
return parsed ?? 'context_capture';
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
150
|
+
return fail(reason);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
export function shouldRunHubChatProcessWithNative(requestId, entryEndpoint) {
|
|
154
|
+
const capability = 'shouldRunHubChatProcessJson';
|
|
155
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
156
|
+
if (isNativeDisabledByEnv()) {
|
|
157
|
+
return fail('native disabled');
|
|
158
|
+
}
|
|
159
|
+
const fn = readNativeFunction('shouldRunHubChatProcessJson');
|
|
160
|
+
if (!fn) {
|
|
161
|
+
return fail();
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const raw = fn(requestId, entryEndpoint);
|
|
165
|
+
if (typeof raw !== 'string' || !raw) {
|
|
166
|
+
return fail('empty result');
|
|
167
|
+
}
|
|
168
|
+
const parsed = parseBoolean(raw);
|
|
169
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
173
|
+
return fail(reason);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
export function normalizeProviderProtocolTokenWithNative(value) {
|
|
177
|
+
const capability = 'normalizeProviderProtocolTokenJson';
|
|
178
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
179
|
+
if (isNativeDisabledByEnv()) {
|
|
180
|
+
return fail('native disabled');
|
|
181
|
+
}
|
|
182
|
+
const fn = readNativeFunction('normalizeProviderProtocolTokenJson');
|
|
183
|
+
if (!fn) {
|
|
184
|
+
return fail();
|
|
185
|
+
}
|
|
186
|
+
const valueJson = safeStringify(value ?? null);
|
|
187
|
+
if (!valueJson) {
|
|
188
|
+
return fail('json stringify failed');
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
const raw = fn(valueJson);
|
|
192
|
+
if (typeof raw !== 'string' || !raw) {
|
|
193
|
+
return fail('empty result');
|
|
194
|
+
}
|
|
195
|
+
const parsed = parseOptionalString(raw);
|
|
196
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
200
|
+
return fail(reason);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
export function isShellLikeToolNameTokenWithNative(name) {
|
|
204
|
+
const capability = 'isShellLikeToolNameTokenJson';
|
|
205
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
206
|
+
if (isNativeDisabledByEnv()) {
|
|
207
|
+
return fail('native disabled');
|
|
208
|
+
}
|
|
209
|
+
const fn = readNativeFunction('isShellLikeToolNameTokenJson');
|
|
210
|
+
if (!fn) {
|
|
211
|
+
return fail();
|
|
212
|
+
}
|
|
213
|
+
const nameJson = safeStringify(name ?? null);
|
|
214
|
+
if (!nameJson) {
|
|
215
|
+
return fail('json stringify failed');
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
const raw = fn(nameJson);
|
|
219
|
+
if (typeof raw !== 'string' || !raw) {
|
|
220
|
+
return fail('empty result');
|
|
221
|
+
}
|
|
222
|
+
const parsed = parseBoolean(raw);
|
|
223
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
227
|
+
return fail(reason);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
export function applyReqInboundSemanticLiftWithNative(input) {
|
|
231
|
+
const capability = 'applyReqInboundSemanticLiftJson';
|
|
232
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
233
|
+
if (isNativeDisabledByEnv()) {
|
|
234
|
+
return fail('native disabled');
|
|
235
|
+
}
|
|
236
|
+
const fn = readNativeFunction('applyReqInboundSemanticLiftJson');
|
|
237
|
+
if (!fn) {
|
|
238
|
+
return fail();
|
|
239
|
+
}
|
|
240
|
+
const inputJson = safeStringify(input);
|
|
241
|
+
if (!inputJson) {
|
|
242
|
+
return fail('json stringify failed');
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
const raw = fn(inputJson);
|
|
246
|
+
if (raw instanceof Error) {
|
|
247
|
+
return fail(raw.message || 'native error');
|
|
248
|
+
}
|
|
249
|
+
if (raw && typeof raw === 'object' && 'message' in raw) {
|
|
250
|
+
const message = raw.message;
|
|
251
|
+
if (typeof message === 'string' && message.trim().length) {
|
|
252
|
+
return fail(message.trim());
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (typeof raw !== 'string' || !raw) {
|
|
256
|
+
return fail('empty result');
|
|
257
|
+
}
|
|
258
|
+
const parsed = parseRecord(raw);
|
|
259
|
+
return parsed ?? fail('invalid payload');
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
263
|
+
return fail(reason);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
export function chatEnvelopeToStandardizedWithNative(input) {
|
|
267
|
+
const capability = 'chatEnvelopeToStandardizedJson';
|
|
268
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
269
|
+
if (isNativeDisabledByEnv()) {
|
|
270
|
+
return fail('native disabled');
|
|
271
|
+
}
|
|
272
|
+
const fn = readNativeFunction(capability);
|
|
273
|
+
if (!fn) {
|
|
274
|
+
return fail();
|
|
275
|
+
}
|
|
276
|
+
const chatJson = safeStringify(input.chatEnvelope);
|
|
277
|
+
const adapterContextJson = safeStringify(input.adapterContext);
|
|
278
|
+
if (!chatJson || !adapterContextJson) {
|
|
279
|
+
return fail('json stringify failed');
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
const raw = fn(chatJson, adapterContextJson, String(input.endpoint || ''), input.requestId);
|
|
283
|
+
if (raw instanceof Error) {
|
|
284
|
+
return fail(raw.message || 'native error');
|
|
285
|
+
}
|
|
286
|
+
if (raw && typeof raw === 'object' && 'message' in raw) {
|
|
287
|
+
const message = raw.message;
|
|
288
|
+
if (typeof message === 'string' && message.trim().length) {
|
|
289
|
+
return fail(message.trim());
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (typeof raw !== 'string' || !raw) {
|
|
293
|
+
return fail('empty result');
|
|
294
|
+
}
|
|
295
|
+
const parsed = parseRecord(raw);
|
|
296
|
+
return parsed ?? fail('invalid payload');
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
300
|
+
return fail(reason);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
export function resolveReqInboundServerToolFollowupSnapshotWithNative(adapterContext) {
|
|
304
|
+
return resolveServerToolFollowupSnapshotWithNative(adapterContext);
|
|
305
|
+
}
|
|
306
|
+
export function augmentReqInboundContextSnapshotWithNative(context, fallbackSnapshot) {
|
|
307
|
+
return augmentContextSnapshotWithNative(context, fallbackSnapshot);
|
|
308
|
+
}
|
|
309
|
+
export function normalizeReqInboundToolCallIdStyleWithNative(value) {
|
|
310
|
+
return normalizeToolCallIdStyleCandidateWithNative(value);
|
|
311
|
+
}
|
|
312
|
+
export function mapReqInboundBridgeToolsToChatWithNative(rawTools) {
|
|
313
|
+
const capability = 'mapBridgeToolsToChatJson';
|
|
314
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
315
|
+
if (isNativeDisabledByEnv()) {
|
|
316
|
+
return fail('native disabled');
|
|
317
|
+
}
|
|
318
|
+
const fn = readNativeFunction(capability);
|
|
319
|
+
if (!fn) {
|
|
320
|
+
return fail();
|
|
321
|
+
}
|
|
322
|
+
const payloadJson = safeStringify(Array.isArray(rawTools) ? rawTools : []);
|
|
323
|
+
if (!payloadJson) {
|
|
324
|
+
return fail('json stringify failed');
|
|
325
|
+
}
|
|
326
|
+
try {
|
|
327
|
+
const raw = fn(payloadJson);
|
|
328
|
+
if (typeof raw !== 'string' || !raw) {
|
|
329
|
+
return fail('empty result');
|
|
330
|
+
}
|
|
331
|
+
const parsed = parseArray(raw);
|
|
332
|
+
if (!parsed) {
|
|
333
|
+
return fail('invalid payload');
|
|
334
|
+
}
|
|
335
|
+
return parsed.filter((entry) => Boolean(entry) && typeof entry === 'object' && !Array.isArray(entry));
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
339
|
+
return fail(reason);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
export function captureReqInboundResponsesContextSnapshotWithNative(input) {
|
|
343
|
+
const capability = 'captureReqInboundResponsesContextSnapshotJson';
|
|
344
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
345
|
+
if (isNativeDisabledByEnv()) {
|
|
346
|
+
return fail('native disabled');
|
|
347
|
+
}
|
|
348
|
+
const fn = readNativeFunction(capability);
|
|
349
|
+
if (!fn) {
|
|
350
|
+
return fail();
|
|
351
|
+
}
|
|
352
|
+
const inputJson = safeStringify({
|
|
353
|
+
rawRequest: input.rawRequest,
|
|
354
|
+
requestId: input.requestId,
|
|
355
|
+
toolCallIdStyle: input.toolCallIdStyle
|
|
356
|
+
});
|
|
357
|
+
if (!inputJson) {
|
|
358
|
+
return fail('json stringify failed');
|
|
359
|
+
}
|
|
360
|
+
try {
|
|
361
|
+
const raw = fn(inputJson);
|
|
362
|
+
if (raw instanceof Error) {
|
|
363
|
+
return fail(raw.message || 'native error');
|
|
364
|
+
}
|
|
365
|
+
if (raw && typeof raw === 'object' && 'message' in raw) {
|
|
366
|
+
const message = raw.message;
|
|
367
|
+
if (typeof message === 'string' && message.trim().length) {
|
|
368
|
+
return fail(message.trim());
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (typeof raw !== 'string' || !raw) {
|
|
372
|
+
return fail('empty result');
|
|
373
|
+
}
|
|
374
|
+
const parsed = parseRecord(raw);
|
|
375
|
+
return parsed ?? fail('invalid payload');
|
|
376
|
+
}
|
|
377
|
+
catch (error) {
|
|
378
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
379
|
+
return fail(reason);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
export function collectReqInboundToolOutputsWithNative(payload) {
|
|
383
|
+
return collectToolOutputsWithNative(payload);
|
|
384
|
+
}
|
|
385
|
+
export function buildReqInboundToolOutputSnapshotWithNative(payload, providerProtocol) {
|
|
386
|
+
const capability = 'buildReqInboundToolOutputSnapshotJson';
|
|
387
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
388
|
+
if (isNativeDisabledByEnv()) {
|
|
389
|
+
return fail('native disabled');
|
|
390
|
+
}
|
|
391
|
+
const fn = readNativeFunction(capability);
|
|
392
|
+
if (!fn) {
|
|
393
|
+
return fail();
|
|
394
|
+
}
|
|
395
|
+
const payloadJson = safeStringify(payload);
|
|
396
|
+
const providerProtocolJson = safeStringify(providerProtocol ?? null);
|
|
397
|
+
if (!payloadJson || !providerProtocolJson) {
|
|
398
|
+
return fail('json stringify failed');
|
|
399
|
+
}
|
|
400
|
+
try {
|
|
401
|
+
const raw = fn(payloadJson, providerProtocolJson);
|
|
402
|
+
if (typeof raw !== 'string' || !raw) {
|
|
403
|
+
return fail('empty result');
|
|
404
|
+
}
|
|
405
|
+
const parsed = parseToolOutputSnapshotBuildResult(raw);
|
|
406
|
+
if (!parsed) {
|
|
407
|
+
return fail('invalid payload');
|
|
408
|
+
}
|
|
409
|
+
replaceRecord(payload, parsed.payload);
|
|
410
|
+
return parsed.snapshot;
|
|
411
|
+
}
|
|
412
|
+
catch (error) {
|
|
413
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
414
|
+
return fail(reason);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
export function appendReqInboundToolParseDiagnosticTextWithNative(outputText, toolName) {
|
|
418
|
+
const capability = 'appendToolParseDiagnosticTextJson';
|
|
419
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
420
|
+
if (isNativeDisabledByEnv()) {
|
|
421
|
+
return fail('native disabled');
|
|
422
|
+
}
|
|
423
|
+
const fn = readNativeFunction('appendToolParseDiagnosticTextJson');
|
|
424
|
+
if (!fn) {
|
|
425
|
+
return fail();
|
|
426
|
+
}
|
|
427
|
+
const toolNameJson = safeStringify(toolName ?? null);
|
|
428
|
+
if (!toolNameJson) {
|
|
429
|
+
return fail('json stringify failed');
|
|
430
|
+
}
|
|
431
|
+
try {
|
|
432
|
+
const raw = fn(outputText, toolNameJson);
|
|
433
|
+
if (typeof raw !== 'string' || !raw) {
|
|
434
|
+
return fail('empty result');
|
|
435
|
+
}
|
|
436
|
+
const parsed = parseOptionalString(raw);
|
|
437
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
438
|
+
}
|
|
439
|
+
catch (error) {
|
|
440
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
441
|
+
return fail(reason);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
export function injectReqInboundToolParseDiagnosticsWithNative(payload) {
|
|
445
|
+
const capability = 'injectToolParseDiagnosticsJson';
|
|
446
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
447
|
+
if (isNativeDisabledByEnv()) {
|
|
448
|
+
return fail('native disabled');
|
|
449
|
+
}
|
|
450
|
+
const fn = readNativeFunction('injectToolParseDiagnosticsJson');
|
|
451
|
+
if (!fn) {
|
|
452
|
+
return fail();
|
|
453
|
+
}
|
|
454
|
+
try {
|
|
455
|
+
const payloadJson = JSON.stringify(payload);
|
|
456
|
+
if (typeof payloadJson !== 'string') {
|
|
457
|
+
return fail('json stringify failed');
|
|
458
|
+
}
|
|
459
|
+
const raw = fn(payloadJson);
|
|
460
|
+
if (typeof raw !== 'string' || !raw) {
|
|
461
|
+
return fail('empty result');
|
|
462
|
+
}
|
|
463
|
+
const parsed = parseRecord(raw);
|
|
464
|
+
if (!parsed) {
|
|
465
|
+
return fail('invalid payload');
|
|
466
|
+
}
|
|
467
|
+
replaceRecord(payload, parsed);
|
|
468
|
+
}
|
|
469
|
+
catch (error) {
|
|
470
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
471
|
+
return fail(reason);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
export function normalizeReqInboundShellLikeToolCallsWithNative(payload) {
|
|
475
|
+
const capability = 'normalizeShellLikeToolCallsBeforeGovernanceJson';
|
|
476
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
477
|
+
if (isNativeDisabledByEnv()) {
|
|
478
|
+
return fail('native disabled');
|
|
479
|
+
}
|
|
480
|
+
const fn = readNativeFunction('normalizeShellLikeToolCallsBeforeGovernanceJson');
|
|
481
|
+
if (!fn) {
|
|
482
|
+
return fail();
|
|
483
|
+
}
|
|
484
|
+
try {
|
|
485
|
+
const payloadJson = JSON.stringify(payload);
|
|
486
|
+
if (typeof payloadJson !== 'string') {
|
|
487
|
+
return fail('json stringify failed');
|
|
488
|
+
}
|
|
489
|
+
const raw = fn(payloadJson);
|
|
490
|
+
if (typeof raw !== 'string' || !raw) {
|
|
491
|
+
return fail('empty result');
|
|
492
|
+
}
|
|
493
|
+
const parsed = parseRecord(raw);
|
|
494
|
+
if (!parsed) {
|
|
495
|
+
return fail('invalid payload');
|
|
496
|
+
}
|
|
497
|
+
replaceRecord(payload, parsed);
|
|
498
|
+
}
|
|
499
|
+
catch (error) {
|
|
500
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
501
|
+
return fail(reason);
|
|
502
|
+
}
|
|
503
|
+
}
|
package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.d.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { JsonObject } from '../../../conversion/hub/types/json.js';
|
|
2
|
+
export interface NativeReqOutboundContextMergePlanInput {
|
|
3
|
+
snapshot?: Record<string, unknown>;
|
|
4
|
+
existingToolOutputs?: unknown[];
|
|
5
|
+
hasExistingTools: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface NativeReqOutboundFormatBuildInput {
|
|
8
|
+
formatEnvelope: Record<string, unknown>;
|
|
9
|
+
protocol: string;
|
|
10
|
+
}
|
|
11
|
+
export interface NativeReqOutboundContextMergePlan {
|
|
12
|
+
mergedToolOutputs?: Array<{
|
|
13
|
+
tool_call_id: string;
|
|
14
|
+
content: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
}>;
|
|
17
|
+
normalizedTools?: unknown[];
|
|
18
|
+
}
|
|
19
|
+
export interface NativeReqOutboundContextSnapshotPatchInput {
|
|
20
|
+
chatEnvelope: Record<string, unknown>;
|
|
21
|
+
snapshot: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export interface NativeReqOutboundContextSnapshotPatch {
|
|
24
|
+
toolOutputs?: Array<{
|
|
25
|
+
tool_call_id: string;
|
|
26
|
+
content: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
}>;
|
|
29
|
+
tools?: Array<{
|
|
30
|
+
type: 'function';
|
|
31
|
+
function: {
|
|
32
|
+
name: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
parameters: unknown;
|
|
35
|
+
strict?: boolean;
|
|
36
|
+
};
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
export interface NativeReqOutboundCompatAdapterContextInput {
|
|
40
|
+
__rt?: Record<string, unknown>;
|
|
41
|
+
compatibilityProfile?: string;
|
|
42
|
+
providerProtocol?: string;
|
|
43
|
+
providerId?: string;
|
|
44
|
+
providerKey?: string;
|
|
45
|
+
runtimeKey?: string;
|
|
46
|
+
requestId?: string;
|
|
47
|
+
clientRequestId?: string;
|
|
48
|
+
groupRequestId?: string;
|
|
49
|
+
sessionId?: string;
|
|
50
|
+
conversationId?: string;
|
|
51
|
+
entryEndpoint?: string;
|
|
52
|
+
routeId?: string;
|
|
53
|
+
capturedChatRequest?: JsonObject;
|
|
54
|
+
deepseek?: Record<string, unknown>;
|
|
55
|
+
estimatedInputTokens?: number;
|
|
56
|
+
modelId?: string;
|
|
57
|
+
clientModelId?: string;
|
|
58
|
+
originalModelId?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface NativeReqOutboundStandardizedToChatInput {
|
|
61
|
+
request: JsonObject;
|
|
62
|
+
adapterContext: NativeReqOutboundCompatAdapterContextInput;
|
|
63
|
+
}
|
|
64
|
+
export interface NativeReqOutboundStage3CompatInput {
|
|
65
|
+
payload: JsonObject;
|
|
66
|
+
adapterContext: NativeReqOutboundCompatAdapterContextInput;
|
|
67
|
+
explicitProfile?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface NativeReqOutboundStage3CompatOutput {
|
|
70
|
+
payload: JsonObject;
|
|
71
|
+
appliedProfile?: string;
|
|
72
|
+
nativeApplied: boolean;
|
|
73
|
+
rateLimitDetected?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface NativeRespInboundStage3CompatInput {
|
|
76
|
+
payload: JsonObject;
|
|
77
|
+
adapterContext: NativeReqOutboundCompatAdapterContextInput;
|
|
78
|
+
explicitProfile?: string;
|
|
79
|
+
}
|
|
80
|
+
export type NativeRespInboundStage3CompatOutput = NativeReqOutboundStage3CompatOutput;
|
|
81
|
+
export interface NativeToolSessionCompatInput {
|
|
82
|
+
messages: unknown[];
|
|
83
|
+
toolOutputs?: unknown[];
|
|
84
|
+
}
|
|
85
|
+
export interface NativeToolSessionCompatOutput {
|
|
86
|
+
messages: unknown[];
|
|
87
|
+
toolOutputs?: unknown[];
|
|
88
|
+
}
|
|
89
|
+
export interface NativeToolSessionHistoryUpdateInput {
|
|
90
|
+
messages: unknown[];
|
|
91
|
+
existingHistory?: {
|
|
92
|
+
lastMessages: Array<{
|
|
93
|
+
role: string;
|
|
94
|
+
toolUse?: {
|
|
95
|
+
id: string;
|
|
96
|
+
name?: string;
|
|
97
|
+
};
|
|
98
|
+
toolResult?: {
|
|
99
|
+
id: string;
|
|
100
|
+
name?: string;
|
|
101
|
+
status: string;
|
|
102
|
+
};
|
|
103
|
+
ts: string;
|
|
104
|
+
}>;
|
|
105
|
+
pendingToolUses: Record<string, {
|
|
106
|
+
name?: string;
|
|
107
|
+
ts: string;
|
|
108
|
+
}>;
|
|
109
|
+
updatedAt: string;
|
|
110
|
+
};
|
|
111
|
+
maxMessages?: number;
|
|
112
|
+
nowIso?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface NativeToolSessionHistoryUpdateOutput {
|
|
115
|
+
history?: {
|
|
116
|
+
lastMessages: Array<{
|
|
117
|
+
role: string;
|
|
118
|
+
toolUse?: {
|
|
119
|
+
id: string;
|
|
120
|
+
name?: string;
|
|
121
|
+
};
|
|
122
|
+
toolResult?: {
|
|
123
|
+
id: string;
|
|
124
|
+
name?: string;
|
|
125
|
+
status: string;
|
|
126
|
+
};
|
|
127
|
+
ts: string;
|
|
128
|
+
}>;
|
|
129
|
+
pendingToolUses: Record<string, {
|
|
130
|
+
name?: string;
|
|
131
|
+
ts: string;
|
|
132
|
+
}>;
|
|
133
|
+
updatedAt: string;
|
|
134
|
+
};
|
|
135
|
+
recordsCount: number;
|
|
136
|
+
}
|
|
137
|
+
export declare function resolveReqOutboundContextMergePlanWithNative(input: NativeReqOutboundContextMergePlanInput): NativeReqOutboundContextMergePlan;
|
|
138
|
+
export declare function buildReqOutboundFormatPayloadWithNative(input: NativeReqOutboundFormatBuildInput): JsonObject;
|
|
139
|
+
export declare function applyReqOutboundContextSnapshotWithNative(input: NativeReqOutboundContextSnapshotPatchInput): NativeReqOutboundContextSnapshotPatch;
|
|
140
|
+
export declare function runReqOutboundStage3CompatWithNative(input: NativeReqOutboundStage3CompatInput): NativeReqOutboundStage3CompatOutput;
|
|
141
|
+
export declare function runRespInboundStage3CompatWithNative(input: NativeRespInboundStage3CompatInput): NativeRespInboundStage3CompatOutput;
|
|
142
|
+
export declare function normalizeToolSessionMessagesWithNative(input: NativeToolSessionCompatInput): NativeToolSessionCompatOutput;
|
|
143
|
+
export declare function updateToolSessionHistoryWithNative(input: NativeToolSessionHistoryUpdateInput): NativeToolSessionHistoryUpdateOutput;
|
|
144
|
+
export declare function applyClaudeThinkingToolSchemaCompatWithNative(payload: JsonObject): JsonObject;
|
|
145
|
+
export declare function standardizedToChatEnvelopeWithNative(input: NativeReqOutboundStandardizedToChatInput): JsonObject;
|
|
146
|
+
export declare function shouldAttachReqOutboundContextSnapshotWithNative(hasSnapshot: boolean, contextMetadataKey: string | undefined): boolean;
|