@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,637 @@
|
|
|
1
|
+
import { failNativeRequired, isNativeDisabledByEnv } from './native-router-hotpath-policy.js';
|
|
2
|
+
import { loadNativeRouterHotpathBindingForInternalUse } from './native-router-hotpath.js';
|
|
3
|
+
function readNativeFunction(name) {
|
|
4
|
+
const binding = loadNativeRouterHotpathBindingForInternalUse();
|
|
5
|
+
const fn = binding?.[name];
|
|
6
|
+
return typeof fn === 'function' ? fn : null;
|
|
7
|
+
}
|
|
8
|
+
function safeStringify(value) {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.stringify(value);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function parseAliasMap(raw) {
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(raw);
|
|
19
|
+
if (parsed === null) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const out = {};
|
|
26
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
27
|
+
if (typeof key !== 'string' || typeof value !== 'string') {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const trimmedKey = key.trim();
|
|
31
|
+
const trimmedValue = value.trim();
|
|
32
|
+
if (!trimmedKey || !trimmedValue) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
out[trimmedKey] = trimmedValue;
|
|
36
|
+
}
|
|
37
|
+
return Object.keys(out).length ? out : undefined;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function parseClientToolsRaw(raw) {
|
|
44
|
+
try {
|
|
45
|
+
const parsed = JSON.parse(raw);
|
|
46
|
+
if (parsed === null) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
if (!Array.isArray(parsed)) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return parsed;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function parseRecord(raw) {
|
|
59
|
+
try {
|
|
60
|
+
const parsed = JSON.parse(raw);
|
|
61
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return parsed;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function parseBoolean(raw) {
|
|
71
|
+
try {
|
|
72
|
+
const parsed = JSON.parse(raw);
|
|
73
|
+
return typeof parsed === 'boolean' ? parsed : null;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function parseStringOrUndefined(raw) {
|
|
80
|
+
try {
|
|
81
|
+
const parsed = JSON.parse(raw);
|
|
82
|
+
if (parsed === null) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
return typeof parsed === 'string' ? parsed : null;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function parseContextLengthDiagnostics(raw) {
|
|
92
|
+
try {
|
|
93
|
+
const parsed = JSON.parse(raw);
|
|
94
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const row = parsed;
|
|
98
|
+
const output = {};
|
|
99
|
+
const estimated = row.estimatedPromptTokens;
|
|
100
|
+
const maxContext = row.maxContextTokens;
|
|
101
|
+
if (typeof estimated === 'number' && Number.isFinite(estimated)) {
|
|
102
|
+
output.estimatedPromptTokens = Math.floor(estimated);
|
|
103
|
+
}
|
|
104
|
+
if (typeof maxContext === 'number' && Number.isFinite(maxContext)) {
|
|
105
|
+
output.maxContextTokens = Math.floor(maxContext);
|
|
106
|
+
}
|
|
107
|
+
return output;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function parseJsonObjectCandidate(raw) {
|
|
114
|
+
try {
|
|
115
|
+
const parsed = JSON.parse(raw);
|
|
116
|
+
if (parsed === null) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
return parsed;
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function parseResponsesHostPolicyResult(raw) {
|
|
129
|
+
try {
|
|
130
|
+
const parsed = JSON.parse(raw);
|
|
131
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const row = parsed;
|
|
135
|
+
if (typeof row.shouldStripHostManagedFields !== 'boolean') {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
if (typeof row.targetProtocol !== 'string') {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const targetProtocol = row.targetProtocol.trim();
|
|
142
|
+
if (!targetProtocol.length) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
shouldStripHostManagedFields: row.shouldStripHostManagedFields,
|
|
147
|
+
targetProtocol
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
export function normalizeAliasMapWithNative(candidate) {
|
|
155
|
+
const capability = 'normalizeAliasMapJson';
|
|
156
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
157
|
+
if (isNativeDisabledByEnv()) {
|
|
158
|
+
return fail('native disabled');
|
|
159
|
+
}
|
|
160
|
+
const fn = readNativeFunction('normalizeAliasMapJson');
|
|
161
|
+
if (!fn) {
|
|
162
|
+
return fail();
|
|
163
|
+
}
|
|
164
|
+
const candidateJson = safeStringify(candidate ?? null);
|
|
165
|
+
if (!candidateJson) {
|
|
166
|
+
return fail('json stringify failed');
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
const raw = fn(candidateJson);
|
|
170
|
+
if (typeof raw !== 'string' || !raw) {
|
|
171
|
+
return fail('empty result');
|
|
172
|
+
}
|
|
173
|
+
const parsed = parseAliasMap(raw);
|
|
174
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
178
|
+
return fail(reason);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
export function resolveClientToolsRawWithNative(candidate) {
|
|
182
|
+
const capability = 'resolveClientToolsRawJson';
|
|
183
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
184
|
+
if (isNativeDisabledByEnv()) {
|
|
185
|
+
return fail('native disabled');
|
|
186
|
+
}
|
|
187
|
+
const fn = readNativeFunction('resolveClientToolsRawJson');
|
|
188
|
+
if (!fn) {
|
|
189
|
+
return fail();
|
|
190
|
+
}
|
|
191
|
+
const candidateJson = safeStringify(candidate ?? null);
|
|
192
|
+
if (!candidateJson) {
|
|
193
|
+
return fail('json stringify failed');
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
const raw = fn(candidateJson);
|
|
197
|
+
if (typeof raw !== 'string' || !raw) {
|
|
198
|
+
return fail('empty result');
|
|
199
|
+
}
|
|
200
|
+
const parsed = parseClientToolsRaw(raw);
|
|
201
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
205
|
+
return fail(reason);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
export function resolveAliasMapFromRespSemanticsWithNative(semantics) {
|
|
209
|
+
const capability = 'resolveAliasMapFromRespSemanticsJson';
|
|
210
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
211
|
+
if (isNativeDisabledByEnv()) {
|
|
212
|
+
return fail('native disabled');
|
|
213
|
+
}
|
|
214
|
+
const fn = readNativeFunction('resolveAliasMapFromRespSemanticsJson');
|
|
215
|
+
if (!fn) {
|
|
216
|
+
return fail();
|
|
217
|
+
}
|
|
218
|
+
const semanticsJson = safeStringify(semantics ?? null);
|
|
219
|
+
if (!semanticsJson) {
|
|
220
|
+
return fail('json stringify failed');
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
const raw = fn(semanticsJson);
|
|
224
|
+
if (typeof raw !== 'string' || !raw) {
|
|
225
|
+
return fail('empty result');
|
|
226
|
+
}
|
|
227
|
+
const parsed = parseAliasMap(raw);
|
|
228
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
232
|
+
return fail(reason);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
export function resolveClientToolsRawFromRespSemanticsWithNative(semantics) {
|
|
236
|
+
const capability = 'resolveClientToolsRawFromRespSemanticsJson';
|
|
237
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
238
|
+
if (isNativeDisabledByEnv()) {
|
|
239
|
+
return fail('native disabled');
|
|
240
|
+
}
|
|
241
|
+
const fn = readNativeFunction('resolveClientToolsRawFromRespSemanticsJson');
|
|
242
|
+
if (!fn) {
|
|
243
|
+
return fail();
|
|
244
|
+
}
|
|
245
|
+
const semanticsJson = safeStringify(semantics ?? null);
|
|
246
|
+
if (!semanticsJson) {
|
|
247
|
+
return fail('json stringify failed');
|
|
248
|
+
}
|
|
249
|
+
try {
|
|
250
|
+
const raw = fn(semanticsJson);
|
|
251
|
+
if (typeof raw !== 'string' || !raw) {
|
|
252
|
+
return fail('empty result');
|
|
253
|
+
}
|
|
254
|
+
const parsed = parseClientToolsRaw(raw);
|
|
255
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
259
|
+
return fail(reason);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
export function sanitizeResponsesFunctionNameWithNative(rawName) {
|
|
263
|
+
const capability = 'sanitizeResponsesFunctionNameJson';
|
|
264
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
265
|
+
if (isNativeDisabledByEnv()) {
|
|
266
|
+
return fail('native disabled');
|
|
267
|
+
}
|
|
268
|
+
const fn = readNativeFunction(capability);
|
|
269
|
+
if (!fn) {
|
|
270
|
+
return fail();
|
|
271
|
+
}
|
|
272
|
+
const rawNameJson = safeStringify(rawName ?? null);
|
|
273
|
+
if (!rawNameJson) {
|
|
274
|
+
return fail('json stringify failed');
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
const raw = fn(rawNameJson);
|
|
278
|
+
if (typeof raw !== 'string' || !raw) {
|
|
279
|
+
return fail('empty result');
|
|
280
|
+
}
|
|
281
|
+
const parsed = parseStringOrUndefined(raw);
|
|
282
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
286
|
+
return fail(reason);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
export function extractSseWrapperErrorWithNative(payload) {
|
|
290
|
+
const capability = 'extractSseWrapperErrorJson';
|
|
291
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
292
|
+
if (isNativeDisabledByEnv()) {
|
|
293
|
+
return fail('native disabled');
|
|
294
|
+
}
|
|
295
|
+
const fn = readNativeFunction(capability);
|
|
296
|
+
if (!fn) {
|
|
297
|
+
return fail();
|
|
298
|
+
}
|
|
299
|
+
const payloadJson = safeStringify(payload ?? null);
|
|
300
|
+
if (!payloadJson) {
|
|
301
|
+
return fail('json stringify failed');
|
|
302
|
+
}
|
|
303
|
+
try {
|
|
304
|
+
const raw = fn(payloadJson);
|
|
305
|
+
if (typeof raw !== 'string' || !raw) {
|
|
306
|
+
return fail('empty result');
|
|
307
|
+
}
|
|
308
|
+
const parsed = parseStringOrUndefined(raw);
|
|
309
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
313
|
+
return fail(reason);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
export function extractContextLengthDiagnosticsWithNative(adapterContext) {
|
|
317
|
+
const capability = 'extractContextLengthDiagnosticsJson';
|
|
318
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
319
|
+
if (isNativeDisabledByEnv()) {
|
|
320
|
+
return fail('native disabled');
|
|
321
|
+
}
|
|
322
|
+
const fn = readNativeFunction(capability);
|
|
323
|
+
if (!fn) {
|
|
324
|
+
return fail();
|
|
325
|
+
}
|
|
326
|
+
const contextJson = safeStringify(adapterContext ?? null);
|
|
327
|
+
if (!contextJson) {
|
|
328
|
+
return fail('json stringify failed');
|
|
329
|
+
}
|
|
330
|
+
try {
|
|
331
|
+
const raw = fn(contextJson);
|
|
332
|
+
if (typeof raw !== 'string' || !raw) {
|
|
333
|
+
return fail('empty result');
|
|
334
|
+
}
|
|
335
|
+
const parsed = parseContextLengthDiagnostics(raw);
|
|
336
|
+
return parsed ?? fail('invalid payload');
|
|
337
|
+
}
|
|
338
|
+
catch (error) {
|
|
339
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
340
|
+
return fail(reason);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
export function isContextLengthExceededSignalWithNative(code, message, context) {
|
|
344
|
+
const capability = 'isContextLengthExceededSignalJson';
|
|
345
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
346
|
+
if (isNativeDisabledByEnv()) {
|
|
347
|
+
return fail('native disabled');
|
|
348
|
+
}
|
|
349
|
+
const fn = readNativeFunction(capability);
|
|
350
|
+
if (!fn) {
|
|
351
|
+
return fail();
|
|
352
|
+
}
|
|
353
|
+
const contextJson = safeStringify(context ?? null);
|
|
354
|
+
if (!contextJson) {
|
|
355
|
+
return fail('json stringify failed');
|
|
356
|
+
}
|
|
357
|
+
const normalizedCode = typeof code === 'string' ? code : '';
|
|
358
|
+
try {
|
|
359
|
+
const raw = fn(normalizedCode, String(message || ''), contextJson);
|
|
360
|
+
if (typeof raw !== 'string' || !raw) {
|
|
361
|
+
return fail('empty result');
|
|
362
|
+
}
|
|
363
|
+
const parsed = parseBoolean(raw);
|
|
364
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
368
|
+
return fail(reason);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
export function applyClientPassthroughPatchWithNative(clientPayload, sourcePayload) {
|
|
372
|
+
const capability = 'applyClientPassthroughPatchJson';
|
|
373
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
374
|
+
if (isNativeDisabledByEnv()) {
|
|
375
|
+
return fail('native disabled');
|
|
376
|
+
}
|
|
377
|
+
const fn = readNativeFunction(capability);
|
|
378
|
+
if (!fn) {
|
|
379
|
+
return fail();
|
|
380
|
+
}
|
|
381
|
+
const clientPayloadJson = safeStringify(clientPayload);
|
|
382
|
+
const sourcePayloadJson = safeStringify(sourcePayload);
|
|
383
|
+
if (!clientPayloadJson || !sourcePayloadJson) {
|
|
384
|
+
return fail('json stringify failed');
|
|
385
|
+
}
|
|
386
|
+
try {
|
|
387
|
+
const raw = fn(clientPayloadJson, sourcePayloadJson);
|
|
388
|
+
if (typeof raw !== 'string' || !raw) {
|
|
389
|
+
return fail('empty result');
|
|
390
|
+
}
|
|
391
|
+
const parsed = parseRecord(raw);
|
|
392
|
+
return parsed ?? fail('invalid payload');
|
|
393
|
+
}
|
|
394
|
+
catch (error) {
|
|
395
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
396
|
+
return fail(reason);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
export function buildAnthropicResponseFromChatWithNative(chatResponse, aliasMap) {
|
|
400
|
+
const capability = 'buildAnthropicResponseFromChatJson';
|
|
401
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
402
|
+
if (isNativeDisabledByEnv()) {
|
|
403
|
+
return fail('native disabled');
|
|
404
|
+
}
|
|
405
|
+
const fn = readNativeFunction(capability);
|
|
406
|
+
if (!fn) {
|
|
407
|
+
return fail();
|
|
408
|
+
}
|
|
409
|
+
const chatResponseJson = safeStringify(chatResponse);
|
|
410
|
+
const aliasMapJson = safeStringify(aliasMap ?? null);
|
|
411
|
+
if (!chatResponseJson || !aliasMapJson) {
|
|
412
|
+
return fail('json stringify failed');
|
|
413
|
+
}
|
|
414
|
+
try {
|
|
415
|
+
const raw = fn(chatResponseJson, aliasMapJson);
|
|
416
|
+
const nativeErrorMessage = raw instanceof Error
|
|
417
|
+
? raw.message
|
|
418
|
+
: raw && typeof raw === 'object' && 'message' in raw
|
|
419
|
+
? (() => {
|
|
420
|
+
const candidate = raw.message;
|
|
421
|
+
return typeof candidate === 'string' ? candidate : '';
|
|
422
|
+
})()
|
|
423
|
+
: '';
|
|
424
|
+
if (nativeErrorMessage) {
|
|
425
|
+
return fail(nativeErrorMessage);
|
|
426
|
+
}
|
|
427
|
+
if (typeof raw !== 'string' || !raw) {
|
|
428
|
+
return fail('empty result');
|
|
429
|
+
}
|
|
430
|
+
const parsed = parseRecord(raw);
|
|
431
|
+
return parsed ?? fail('invalid payload');
|
|
432
|
+
}
|
|
433
|
+
catch (error) {
|
|
434
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
435
|
+
return fail(reason);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
export function normalizeResponsesToolCallArgumentsForClientWithNative(responsesPayload, toolsRaw) {
|
|
439
|
+
const capability = 'normalizeResponsesToolCallArgumentsForClientJson';
|
|
440
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
441
|
+
if (isNativeDisabledByEnv()) {
|
|
442
|
+
return fail('native disabled');
|
|
443
|
+
}
|
|
444
|
+
const fn = readNativeFunction(capability);
|
|
445
|
+
if (!fn) {
|
|
446
|
+
return fail();
|
|
447
|
+
}
|
|
448
|
+
const payloadJson = safeStringify(responsesPayload);
|
|
449
|
+
const toolsRawJson = safeStringify(toolsRaw ?? []);
|
|
450
|
+
if (!payloadJson || !toolsRawJson) {
|
|
451
|
+
return fail('json stringify failed');
|
|
452
|
+
}
|
|
453
|
+
try {
|
|
454
|
+
const raw = fn(payloadJson, toolsRawJson);
|
|
455
|
+
const nativeErrorMessage = raw instanceof Error
|
|
456
|
+
? raw.message
|
|
457
|
+
: raw && typeof raw === 'object' && 'message' in raw
|
|
458
|
+
? (() => {
|
|
459
|
+
const candidate = raw.message;
|
|
460
|
+
return typeof candidate === 'string' ? candidate : '';
|
|
461
|
+
})()
|
|
462
|
+
: '';
|
|
463
|
+
if (nativeErrorMessage) {
|
|
464
|
+
return fail(nativeErrorMessage);
|
|
465
|
+
}
|
|
466
|
+
if (typeof raw !== 'string' || !raw) {
|
|
467
|
+
return fail('empty result');
|
|
468
|
+
}
|
|
469
|
+
const parsed = parseRecord(raw);
|
|
470
|
+
return parsed ?? fail('invalid payload');
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
474
|
+
return fail(reason);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
export function normalizeResponsesUsageWithNative(usageRaw) {
|
|
478
|
+
const capability = 'normalizeResponsesUsageJson';
|
|
479
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
480
|
+
if (isNativeDisabledByEnv()) {
|
|
481
|
+
return fail('native disabled');
|
|
482
|
+
}
|
|
483
|
+
const fn = readNativeFunction(capability);
|
|
484
|
+
if (!fn) {
|
|
485
|
+
return fail();
|
|
486
|
+
}
|
|
487
|
+
const usageJson = safeStringify(usageRaw ?? null);
|
|
488
|
+
if (!usageJson) {
|
|
489
|
+
return fail('json stringify failed');
|
|
490
|
+
}
|
|
491
|
+
try {
|
|
492
|
+
const raw = fn(usageJson);
|
|
493
|
+
const nativeErrorMessage = raw instanceof Error
|
|
494
|
+
? raw.message
|
|
495
|
+
: raw && typeof raw === 'object' && 'message' in raw
|
|
496
|
+
? (() => {
|
|
497
|
+
const candidate = raw.message;
|
|
498
|
+
return typeof candidate === 'string' ? candidate : '';
|
|
499
|
+
})()
|
|
500
|
+
: '';
|
|
501
|
+
if (nativeErrorMessage) {
|
|
502
|
+
return fail(nativeErrorMessage);
|
|
503
|
+
}
|
|
504
|
+
if (typeof raw !== 'string' || !raw) {
|
|
505
|
+
return fail('empty result');
|
|
506
|
+
}
|
|
507
|
+
try {
|
|
508
|
+
return JSON.parse(raw);
|
|
509
|
+
}
|
|
510
|
+
catch {
|
|
511
|
+
return fail('invalid payload');
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
catch (error) {
|
|
515
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
516
|
+
return fail(reason);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
export function buildResponsesPayloadFromChatWithNative(payload, context = {}) {
|
|
520
|
+
const capability = 'buildResponsesPayloadFromChatJson';
|
|
521
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
522
|
+
if (isNativeDisabledByEnv()) {
|
|
523
|
+
return fail('native disabled');
|
|
524
|
+
}
|
|
525
|
+
const fn = readNativeFunction(capability);
|
|
526
|
+
if (!fn) {
|
|
527
|
+
return fail();
|
|
528
|
+
}
|
|
529
|
+
const payloadJson = safeStringify(payload);
|
|
530
|
+
const contextJson = safeStringify({
|
|
531
|
+
requestId: context.requestId,
|
|
532
|
+
toolsRaw: Array.isArray(context.toolsRaw) ? context.toolsRaw : []
|
|
533
|
+
});
|
|
534
|
+
if (!payloadJson || !contextJson) {
|
|
535
|
+
return fail('json stringify failed');
|
|
536
|
+
}
|
|
537
|
+
try {
|
|
538
|
+
const raw = fn(payloadJson, contextJson);
|
|
539
|
+
const nativeErrorMessage = raw instanceof Error
|
|
540
|
+
? raw.message
|
|
541
|
+
: raw && typeof raw === 'object' && 'message' in raw
|
|
542
|
+
? (() => {
|
|
543
|
+
const candidate = raw.message;
|
|
544
|
+
return typeof candidate === 'string' ? candidate : '';
|
|
545
|
+
})()
|
|
546
|
+
: '';
|
|
547
|
+
if (nativeErrorMessage) {
|
|
548
|
+
return fail(nativeErrorMessage);
|
|
549
|
+
}
|
|
550
|
+
if (typeof raw !== 'string' || !raw) {
|
|
551
|
+
return fail('empty result');
|
|
552
|
+
}
|
|
553
|
+
const parsed = parseRecord(raw);
|
|
554
|
+
return parsed ?? fail('invalid payload');
|
|
555
|
+
}
|
|
556
|
+
catch (error) {
|
|
557
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
558
|
+
return fail(reason);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
export function looksLikeJsonStreamPrefixWithNative(firstChunkText) {
|
|
562
|
+
const capability = 'looksLikeJsonStreamPrefixJson';
|
|
563
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
564
|
+
if (isNativeDisabledByEnv()) {
|
|
565
|
+
return fail('native disabled');
|
|
566
|
+
}
|
|
567
|
+
const fn = readNativeFunction('looksLikeJsonStreamPrefixJson');
|
|
568
|
+
if (!fn) {
|
|
569
|
+
return fail();
|
|
570
|
+
}
|
|
571
|
+
try {
|
|
572
|
+
const raw = fn(String(firstChunkText || ''));
|
|
573
|
+
if (typeof raw !== 'string' || !raw) {
|
|
574
|
+
return fail('empty result');
|
|
575
|
+
}
|
|
576
|
+
const parsed = parseBoolean(raw);
|
|
577
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
578
|
+
}
|
|
579
|
+
catch (error) {
|
|
580
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
581
|
+
return fail(reason);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
export function parseJsonObjectCandidateWithNative(rawText, maxBytes) {
|
|
585
|
+
const capability = 'parseJsonObjectCandidateJson';
|
|
586
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
587
|
+
if (isNativeDisabledByEnv()) {
|
|
588
|
+
return fail('native disabled');
|
|
589
|
+
}
|
|
590
|
+
const fn = readNativeFunction('parseJsonObjectCandidateJson');
|
|
591
|
+
if (!fn) {
|
|
592
|
+
return fail();
|
|
593
|
+
}
|
|
594
|
+
const bounded = Number.isFinite(maxBytes) && maxBytes > 0 ? Math.floor(maxBytes) : 0;
|
|
595
|
+
try {
|
|
596
|
+
const raw = fn(String(rawText || ''), bounded);
|
|
597
|
+
if (typeof raw !== 'string' || !raw) {
|
|
598
|
+
return fail('empty result');
|
|
599
|
+
}
|
|
600
|
+
const parsed = parseJsonObjectCandidate(raw);
|
|
601
|
+
return parsed === undefined ? fail('invalid payload') : parsed;
|
|
602
|
+
}
|
|
603
|
+
catch (error) {
|
|
604
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
605
|
+
return fail(reason);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
export function evaluateResponsesHostPolicyWithNative(context, targetProtocol) {
|
|
609
|
+
const capability = 'evaluateResponsesHostPolicyJson';
|
|
610
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
611
|
+
if (isNativeDisabledByEnv()) {
|
|
612
|
+
return fail('native disabled');
|
|
613
|
+
}
|
|
614
|
+
const fn = readNativeFunction(capability);
|
|
615
|
+
if (!fn) {
|
|
616
|
+
return fail();
|
|
617
|
+
}
|
|
618
|
+
const payloadJson = safeStringify({
|
|
619
|
+
context: context && typeof context === 'object' && !Array.isArray(context) ? context : undefined,
|
|
620
|
+
targetProtocol
|
|
621
|
+
});
|
|
622
|
+
if (!payloadJson) {
|
|
623
|
+
return fail('json stringify failed');
|
|
624
|
+
}
|
|
625
|
+
try {
|
|
626
|
+
const raw = fn(payloadJson);
|
|
627
|
+
if (typeof raw !== 'string' || !raw) {
|
|
628
|
+
return fail('empty result');
|
|
629
|
+
}
|
|
630
|
+
const parsed = parseResponsesHostPolicyResult(raw);
|
|
631
|
+
return parsed ?? fail('invalid payload');
|
|
632
|
+
}
|
|
633
|
+
catch (error) {
|
|
634
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
635
|
+
return fail(reason);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface NativeSessionIdentifiersOutput {
|
|
2
|
+
sessionId?: string;
|
|
3
|
+
conversationId?: string;
|
|
4
|
+
}
|
|
5
|
+
type NativeHeaderMap = Record<string, string>;
|
|
6
|
+
export declare function extractSessionIdentifiersFromMetadataWithNative(metadata: Record<string, unknown> | undefined): NativeSessionIdentifiersOutput;
|
|
7
|
+
export declare function coerceClientHeadersWithNative(raw: unknown): NativeHeaderMap | undefined;
|
|
8
|
+
export declare function findHeaderValueWithNative(headers: Record<string, string>, target: string): string | undefined;
|
|
9
|
+
export declare function pickHeaderWithNative(headers: Record<string, string>, candidates: string[]): string | undefined;
|
|
10
|
+
export declare function normalizeHeaderKeyWithNative(value: string): string;
|
|
11
|
+
export {};
|