@jsonstudio/llms 0.6.2172 → 0.6.3214
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/args-mapping.js +8 -0
- package/dist/conversion/bridge-actions.js +367 -0
- package/dist/conversion/bridge-id-utils.js +13 -0
- package/dist/conversion/{shared/bridge-instructions.js → bridge-instructions.js} +2 -1
- package/dist/conversion/{shared/bridge-message-utils.d.ts → bridge-message-utils.d.ts} +1 -1
- package/dist/conversion/{shared/bridge-message-utils.js → bridge-message-utils.js} +5 -150
- package/dist/conversion/{shared/bridge-metadata.d.ts → bridge-metadata.d.ts} +1 -0
- package/dist/conversion/bridge-metadata.js +5 -0
- package/dist/conversion/bridge-policies.js +11 -0
- package/dist/conversion/codecs/gemini-openai-codec.js +27 -8
- package/dist/conversion/codecs/responses-openai-codec.js +1 -1
- package/dist/conversion/{shared/compaction-detect.d.ts → compaction-detect.d.ts} +1 -1
- package/dist/conversion/compaction-detect.js +4 -0
- package/dist/conversion/compat/actions/apply-patch-fixer.js +2 -2
- package/dist/conversion/compat/actions/deepseek-web-response.d.ts +0 -1
- package/dist/conversion/compat/actions/deepseek-web-response.js +15 -405
- package/dist/conversion/compat/actions/harvest-tool-calls-from-text.js +1 -1
- package/dist/conversion/compat/actions/lmstudio-responses-fc-ids.js +1 -1
- package/dist/conversion/compat/actions/qwen-transform.js +74 -2
- package/dist/conversion/compat/actions/snapshot.js +1 -1
- package/dist/conversion/compat/antigravity-session-signature.js +71 -1
- package/dist/conversion/compat/profiles/chat-deepseek-web.json +0 -22
- package/dist/conversion/compat/profiles/chat-gemini-cli.json +0 -7
- package/dist/conversion/compat/profiles/chat-gemini.json +0 -6
- package/dist/conversion/compat/profiles/chat-glm.json +251 -72
- package/dist/conversion/compat/profiles/chat-iflow.json +174 -39
- package/dist/conversion/compat/profiles/chat-lmstudio.json +43 -14
- 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 +12 -8
- package/dist/conversion/hub/operation-table/semantic-mappers/anthropic-mapper.js +3 -3
- package/dist/conversion/hub/operation-table/semantic-mappers/chat-mapper.js +16 -13
- package/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.js +6 -10
- package/dist/conversion/hub/operation-table/semantic-mappers/responses-mapper.js +21 -73
- 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.d.ts +1 -0
- package/dist/conversion/hub/pipeline/hub-pipeline.js +165 -265
- 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.d.ts +1 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.js +69 -81
- 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 +20 -3
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/index.js +11 -199
- 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 +54 -39
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage2_finalize/index.js +18 -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 +21 -149
- 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 +20 -26
- package/dist/conversion/hub/response/response-mappers.js +25 -27
- package/dist/conversion/hub/response/response-runtime.js +30 -98
- 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 +11 -4
- package/dist/conversion/hub/standardized-bridge.js +11 -288
- package/dist/conversion/hub/tool-governance/engine.d.ts +8 -0
- package/dist/conversion/hub/tool-governance/engine.js +25 -63
- package/dist/conversion/hub/tool-governance/rules.js +73 -69
- 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 +6 -4
- package/dist/conversion/index.d.ts +1 -2
- package/dist/conversion/index.js +1 -2
- package/dist/conversion/jsonish.js +20 -0
- package/dist/conversion/mcp-injection.js +7 -0
- package/dist/conversion/media.js +4 -0
- package/dist/conversion/{shared/metadata-passthrough.d.ts → metadata-passthrough.d.ts} +1 -1
- package/dist/conversion/metadata-passthrough.js +20 -0
- package/dist/conversion/payload-budget.js +47 -0
- package/dist/conversion/protocol-field-allowlists.d.ts +7 -0
- package/dist/conversion/protocol-field-allowlists.js +9 -0
- package/dist/conversion/{shared/protocol-state.d.ts → protocol-state.d.ts} +2 -2
- package/dist/conversion/protocol-state.js +27 -0
- package/dist/conversion/{shared/errors.d.ts → provider-protocol-error.d.ts} +0 -3
- package/dist/conversion/provider-protocol-error.js +25 -0
- package/dist/conversion/responses/responses-host-policy.js +2 -12
- package/dist/conversion/responses/responses-openai-bridge/response-payload.js +14 -87
- package/dist/conversion/responses/responses-openai-bridge/types.d.ts +2 -1
- package/dist/conversion/responses/responses-openai-bridge.d.ts +1 -1
- package/dist/conversion/responses/responses-openai-bridge.js +62 -62
- package/dist/conversion/{shared/runtime-metadata.d.ts → runtime-metadata.d.ts} +1 -1
- package/dist/conversion/runtime-metadata.js +31 -0
- package/dist/conversion/shared/anthropic-message-utils.js +170 -21
- package/dist/conversion/shared/chat-envelope-validator.js +2 -126
- package/dist/conversion/shared/chat-output-normalizer.js +2 -54
- package/dist/conversion/shared/chat-request-filters.d.ts +3 -4
- package/dist/conversion/shared/chat-request-filters.js +22 -78
- package/dist/conversion/shared/gemini-tool-utils.d.ts +1 -1
- package/dist/conversion/shared/gemini-tool-utils.js +9 -524
- package/dist/conversion/shared/openai-finalizer.js +3 -1
- package/dist/conversion/shared/openai-message-normalize.js +13 -285
- package/dist/conversion/shared/output-content-normalizer.js +9 -112
- package/dist/conversion/shared/reasoning-mapping.js +2 -6
- package/dist/conversion/shared/reasoning-normalizer.js +10 -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 +7 -8
- package/dist/conversion/shared/responses-conversation-store.js +5 -83
- package/dist/conversion/shared/responses-output-builder.js +63 -55
- package/dist/conversion/shared/responses-reasoning-registry.d.ts +14 -2
- package/dist/conversion/shared/responses-reasoning-registry.js +41 -7
- 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 +103 -14
- package/dist/conversion/shared/responses-tool-utils.d.ts +1 -0
- package/dist/conversion/shared/responses-tool-utils.js +91 -15
- package/dist/conversion/shared/streaming-text-extractor.js +2 -7
- package/dist/conversion/shared/text-markup-normalizer/normalize.d.ts +2 -2
- package/dist/conversion/shared/text-markup-normalizer/normalize.js +43 -17
- package/dist/conversion/shared/text-markup-normalizer.d.ts +3 -2
- package/dist/conversion/shared/text-markup-normalizer.js +2 -1
- 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-filter-pipeline.js +5 -100
- package/dist/conversion/shared/tool-governor.d.ts +6 -0
- package/dist/conversion/shared/tool-governor.js +45 -127
- package/dist/conversion/shared/tool-harvester.js +2 -8
- package/dist/conversion/shared/tool-mapping.d.ts +1 -1
- 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/conversion/{shared/snapshot-utils.d.ts → snapshot-utils.d.ts} +11 -0
- package/dist/conversion/{shared/snapshot-utils.js → snapshot-utils.js} +14 -23
- package/dist/conversion/{shared → types}/bridge-message-types.d.ts +2 -0
- package/dist/conversion/types/text-markup-normalizer.d.ts +13 -0
- package/dist/filters/special/request-tools-normalize.js +1 -1
- package/dist/filters/special/response-tool-text-canonicalize.js +2 -2
- package/dist/native/router_hotpath_napi.node +0 -0
- package/dist/quota/quota-manager.js +31 -59
- package/dist/quota/quota-state.js +14 -7
- package/dist/router/virtual-router/bootstrap/profile-builder.d.ts +1 -0
- package/dist/router/virtual-router/bootstrap/profile-builder.js +13 -0
- package/dist/router/virtual-router/bootstrap/provider-normalization.d.ts +2 -0
- package/dist/router/virtual-router/bootstrap/provider-normalization.js +4 -1
- package/dist/router/virtual-router/bootstrap/streaming-helpers.d.ts +7 -0
- package/dist/router/virtual-router/bootstrap/streaming-helpers.js +44 -0
- package/dist/router/virtual-router/bootstrap.js +2 -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.d.ts +1 -2
- package/dist/router/virtual-router/engine/routing-state/store.js +50 -14
- package/dist/router/virtual-router/engine-legacy/config.d.ts +11 -0
- package/dist/router/virtual-router/engine-legacy/config.js +108 -0
- package/dist/router/virtual-router/engine-legacy/direct-model.d.ts +10 -0
- package/dist/router/virtual-router/engine-legacy/direct-model.js +38 -0
- package/dist/router/virtual-router/engine-legacy/health.d.ts +13 -0
- package/dist/router/virtual-router/engine-legacy/health.js +104 -0
- package/dist/router/virtual-router/engine-legacy/helpers.d.ts +16 -0
- package/dist/router/virtual-router/engine-legacy/helpers.js +226 -0
- package/dist/router/virtual-router/engine-legacy/route-finalize.d.ts +9 -0
- package/dist/router/virtual-router/engine-legacy/route-finalize.js +84 -0
- package/dist/router/virtual-router/engine-legacy/route-selection.d.ts +17 -0
- package/dist/router/virtual-router/engine-legacy/route-selection.js +205 -0
- package/dist/router/virtual-router/engine-legacy/route-state-allowlist.d.ts +3 -0
- package/dist/router/virtual-router/engine-legacy/route-state-allowlist.js +36 -0
- package/dist/router/virtual-router/engine-legacy/route-state.d.ts +12 -0
- package/dist/router/virtual-router/engine-legacy/route-state.js +386 -0
- package/dist/router/virtual-router/engine-legacy/route-utils.d.ts +19 -0
- package/dist/router/virtual-router/engine-legacy/route-utils.js +212 -0
- package/dist/router/virtual-router/engine-legacy/routing.d.ts +8 -0
- package/dist/router/virtual-router/engine-legacy/routing.js +8 -0
- package/dist/router/virtual-router/engine-legacy/selection-core.d.ts +28 -0
- package/dist/router/virtual-router/engine-legacy/selection-core.js +112 -0
- package/dist/router/virtual-router/engine-legacy/selection-state.d.ts +16 -0
- package/dist/router/virtual-router/engine-legacy/selection-state.js +187 -0
- package/dist/router/virtual-router/engine-legacy/state-accessors.d.ts +21 -0
- package/dist/router/virtual-router/engine-legacy/state-accessors.js +118 -0
- package/dist/router/virtual-router/engine-legacy.d.ts +123 -0
- package/dist/router/virtual-router/engine-legacy.js +194 -0
- package/dist/router/virtual-router/engine-logging.d.ts +2 -0
- package/dist/router/virtual-router/engine-logging.js +11 -5
- package/dist/router/virtual-router/engine-selection/alias-selection.js +45 -83
- package/dist/router/virtual-router/engine-selection/key-parsing.js +9 -26
- 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-chat-request-filter-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-request-filter-semantics.js +54 -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 +72 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.js +405 -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-governance-semantics.d.ts +22 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-governance-semantics.js +154 -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 +320 -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 +151 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.js +1371 -0
- package/dist/router/virtual-router/engine-selection/native-snapshot-hooks.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-snapshot-hooks.js +69 -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-engine-proxy.d.ts +16 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-engine-proxy.js +14 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-routing-instructions-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-routing-instructions-semantics.js +86 -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 +216 -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 +128 -129
- package/dist/router/virtual-router/engine-selection/tier-selection.js +2 -265
- package/dist/router/virtual-router/engine.d.ts +22 -105
- package/dist/router/virtual-router/engine.js +274 -1632
- package/dist/router/virtual-router/features.js +2 -2
- package/dist/router/virtual-router/load-balancer.d.ts +8 -0
- package/dist/router/virtual-router/load-balancer.js +65 -2
- package/dist/router/virtual-router/provider-registry.js +2 -0
- package/dist/router/virtual-router/routing-instructions/clean.d.ts +3 -0
- package/dist/router/virtual-router/routing-instructions/clean.js +34 -0
- package/dist/router/virtual-router/routing-instructions/parse.d.ts +18 -0
- package/dist/router/virtual-router/routing-instructions/parse.js +377 -0
- package/dist/router/virtual-router/routing-instructions/state.d.ts +4 -0
- package/dist/router/virtual-router/routing-instructions/state.js +245 -0
- package/dist/router/virtual-router/routing-instructions/types.d.ts +70 -0
- package/dist/router/virtual-router/routing-instructions/types.js +2 -0
- package/dist/router/virtual-router/routing-instructions.d.ts +5 -91
- package/dist/router/virtual-router/routing-instructions.js +4 -628
- 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.d.ts +4 -0
- package/dist/router/virtual-router/sticky-session-store.js +23 -83
- 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/tool-signals.js +21 -3
- package/dist/router/virtual-router/types.d.ts +13 -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 +29 -40
- package/dist/servertool/engine.d.ts +9 -0
- package/dist/servertool/engine.js +267 -79
- package/dist/servertool/handlers/antigravity-thought-signature-bootstrap.js +3 -3
- package/dist/servertool/handlers/clock-auto.js +1 -1
- package/dist/servertool/handlers/clock.js +2 -2
- package/dist/servertool/handlers/compaction-detect.d.ts +1 -1
- package/dist/servertool/handlers/compaction-detect.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 +8 -2
- package/dist/servertool/handlers/iflow-model-error-retry.js +1 -1
- package/dist/servertool/handlers/recursive-detection-guard.js +1 -1
- package/dist/servertool/handlers/review.d.ts +1 -0
- 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 +398 -90
- 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 +36 -62
- package/dist/servertool/handlers/stop-message-auto.js +393 -77
- package/dist/servertool/handlers/vision.js +1 -1
- package/dist/servertool/handlers/web-search.js +1 -1
- package/dist/servertool/reenter-backend.js +1 -1
- package/dist/servertool/server-side-tools.d.ts +1 -0
- package/dist/servertool/server-side-tools.js +92 -54
- package/dist/servertool/stop-gateway-context.js +1 -1
- package/dist/servertool/stop-message-compare-context.js +1 -1
- package/dist/servertool/types.d.ts +17 -0
- package/dist/sse/json-to-sse/event-generators/responses.d.ts +4 -0
- package/dist/sse/json-to-sse/event-generators/responses.js +95 -1
- package/dist/sse/json-to-sse/sequencers/responses-sequencer.js +6 -4
- package/dist/sse/sse-to-json/builders/response-builder.d.ts +8 -0
- package/dist/sse/sse-to-json/builders/response-builder.js +162 -4
- package/dist/sse/sse-to-json/responses-sse-to-json-converter.js +2 -0
- package/dist/sse/types/responses-types.d.ts +6 -2
- package/dist/tools/apply-patch/patch-text/normalize.js +11 -0
- package/dist/tools/apply-patch/structured/coercion.js +5 -0
- package/dist/tools/args-json.js +29 -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 +121 -10
- package/dist/conversion/shared/args-mapping.js +0 -221
- package/dist/conversion/shared/bridge-actions.js +0 -881
- package/dist/conversion/shared/bridge-id-utils.js +0 -79
- package/dist/conversion/shared/bridge-metadata.js +0 -1
- package/dist/conversion/shared/bridge-policies.js +0 -195
- package/dist/conversion/shared/compaction-detect.js +0 -59
- package/dist/conversion/shared/errors.js +0 -31
- package/dist/conversion/shared/jsonish.js +0 -177
- package/dist/conversion/shared/mcp-injection.js +0 -173
- package/dist/conversion/shared/media.js +0 -9
- package/dist/conversion/shared/metadata-passthrough.js +0 -57
- package/dist/conversion/shared/payload-budget.js +0 -248
- package/dist/conversion/shared/protocol-field-allowlists.d.ts +0 -7
- package/dist/conversion/shared/protocol-field-allowlists.js +0 -149
- package/dist/conversion/shared/protocol-state.js +0 -23
- package/dist/conversion/shared/runtime-metadata.js +0 -23
- package/dist/conversion/shared/snapshot-hooks.d.ts +0 -11
- package/dist/conversion/shared/snapshot-hooks.js +0 -503
- package/dist/conversion/shared/text-markup-normalizer/extractors-apply-patch.d.ts +0 -2
- package/dist/conversion/shared/text-markup-normalizer/extractors-apply-patch.js +0 -129
- package/dist/conversion/shared/text-markup-normalizer/extractors-json.d.ts +0 -4
- package/dist/conversion/shared/text-markup-normalizer/extractors-json.js +0 -637
- package/dist/conversion/shared/text-markup-normalizer/extractors-shared.d.ts +0 -21
- package/dist/conversion/shared/text-markup-normalizer/extractors-shared.js +0 -177
- package/dist/conversion/shared/text-markup-normalizer/extractors-transcript.d.ts +0 -5
- package/dist/conversion/shared/text-markup-normalizer/extractors-transcript.js +0 -385
- package/dist/conversion/shared/text-markup-normalizer/extractors-xml.d.ts +0 -10
- package/dist/conversion/shared/text-markup-normalizer/extractors-xml.js +0 -602
- package/dist/conversion/shared/text-markup-normalizer/extractors.d.ts +0 -5
- package/dist/conversion/shared/text-markup-normalizer/extractors.js +0 -4
- package/dist/conversion/shared/tool-canonicalizer.d.ts +0 -2
- package/dist/conversion/shared/tool-canonicalizer.js +0 -42
- 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/conversion/{shared/args-mapping.d.ts → args-mapping.d.ts} +0 -0
- /package/dist/conversion/{shared/bridge-actions.d.ts → bridge-actions.d.ts} +0 -0
- /package/dist/conversion/{shared/bridge-id-utils.d.ts → bridge-id-utils.d.ts} +0 -0
- /package/dist/conversion/{shared/bridge-instructions.d.ts → bridge-instructions.d.ts} +0 -0
- /package/dist/conversion/{shared/bridge-policies.d.ts → bridge-policies.d.ts} +0 -0
- /package/dist/conversion/{shared/jsonish.d.ts → jsonish.d.ts} +0 -0
- /package/dist/conversion/{shared/mcp-injection.d.ts → mcp-injection.d.ts} +0 -0
- /package/dist/conversion/{shared/media.d.ts → media.d.ts} +0 -0
- /package/dist/conversion/{shared/payload-budget.d.ts → payload-budget.d.ts} +0 -0
- /package/dist/conversion/{shared → types}/bridge-message-types.js +0 -0
- /package/dist/{servertool/handlers/stop-message-stage-policy/types.js → conversion/types/text-markup-normalizer.js} +0 -0
package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js
ADDED
|
@@ -0,0 +1,570 @@
|
|
|
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 parseRecord(raw) {
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(raw);
|
|
19
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return parsed;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function parseNormalizedToolDefinitions(candidate) {
|
|
29
|
+
if (!Array.isArray(candidate)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const tools = [];
|
|
33
|
+
for (const entry of candidate) {
|
|
34
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const row = entry;
|
|
38
|
+
if (row.type !== 'function') {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const fn = row.function;
|
|
42
|
+
if (!fn || typeof fn !== 'object' || Array.isArray(fn)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const fnRow = fn;
|
|
46
|
+
const name = typeof fnRow.name === 'string' && fnRow.name.trim() ? fnRow.name.trim() : '';
|
|
47
|
+
if (!name) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const description = typeof fnRow.description === 'string' ? fnRow.description : undefined;
|
|
51
|
+
const strict = typeof fnRow.strict === 'boolean' ? fnRow.strict : undefined;
|
|
52
|
+
const parameters = fnRow.parameters ?? { type: 'object', properties: {} };
|
|
53
|
+
tools.push({
|
|
54
|
+
type: 'function',
|
|
55
|
+
function: {
|
|
56
|
+
name,
|
|
57
|
+
...(description ? { description } : {}),
|
|
58
|
+
parameters,
|
|
59
|
+
...(strict !== undefined ? { strict } : {})
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return tools;
|
|
64
|
+
}
|
|
65
|
+
function parseReqOutboundContextMergePlan(raw) {
|
|
66
|
+
try {
|
|
67
|
+
const parsed = JSON.parse(raw);
|
|
68
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const row = parsed;
|
|
72
|
+
const out = {};
|
|
73
|
+
const mergedToolOutputs = row.mergedToolOutputs;
|
|
74
|
+
if (mergedToolOutputs !== undefined) {
|
|
75
|
+
if (!Array.isArray(mergedToolOutputs)) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const normalized = [];
|
|
79
|
+
for (const entry of mergedToolOutputs) {
|
|
80
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const rowEntry = entry;
|
|
84
|
+
const toolCallId = typeof rowEntry.tool_call_id === 'string'
|
|
85
|
+
? rowEntry.tool_call_id.trim()
|
|
86
|
+
: typeof rowEntry.toolCallId === 'string'
|
|
87
|
+
? rowEntry.toolCallId.trim()
|
|
88
|
+
: '';
|
|
89
|
+
const content = typeof rowEntry.content === 'string' ? rowEntry.content : undefined;
|
|
90
|
+
if (!toolCallId || content === undefined) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const name = typeof rowEntry.name === 'string' && rowEntry.name.trim() ? rowEntry.name.trim() : undefined;
|
|
94
|
+
normalized.push({ tool_call_id: toolCallId, content, ...(name ? { name } : {}) });
|
|
95
|
+
}
|
|
96
|
+
out.mergedToolOutputs = normalized;
|
|
97
|
+
}
|
|
98
|
+
const normalizedTools = row.normalizedTools;
|
|
99
|
+
if (normalizedTools !== undefined) {
|
|
100
|
+
const parsedTools = parseNormalizedToolDefinitions(normalizedTools);
|
|
101
|
+
if (parsedTools === null) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
out.normalizedTools = parsedTools;
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function parseReqOutboundContextSnapshotPatch(raw) {
|
|
113
|
+
try {
|
|
114
|
+
const parsed = JSON.parse(raw);
|
|
115
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const row = parsed;
|
|
119
|
+
const out = {};
|
|
120
|
+
const toolOutputs = row.toolOutputs;
|
|
121
|
+
if (toolOutputs !== undefined) {
|
|
122
|
+
if (!Array.isArray(toolOutputs)) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const normalized = [];
|
|
126
|
+
for (const entry of toolOutputs) {
|
|
127
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
const rowEntry = entry;
|
|
131
|
+
const toolCallId = typeof rowEntry.tool_call_id === 'string'
|
|
132
|
+
? rowEntry.tool_call_id.trim()
|
|
133
|
+
: typeof rowEntry.toolCallId === 'string'
|
|
134
|
+
? rowEntry.toolCallId.trim()
|
|
135
|
+
: '';
|
|
136
|
+
const content = typeof rowEntry.content === 'string' ? rowEntry.content : undefined;
|
|
137
|
+
if (!toolCallId || content === undefined) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const name = typeof rowEntry.name === 'string' && rowEntry.name.trim() ? rowEntry.name.trim() : undefined;
|
|
141
|
+
normalized.push({ tool_call_id: toolCallId, content, ...(name ? { name } : {}) });
|
|
142
|
+
}
|
|
143
|
+
out.toolOutputs = normalized;
|
|
144
|
+
}
|
|
145
|
+
const toolsRaw = row.tools;
|
|
146
|
+
if (toolsRaw !== undefined) {
|
|
147
|
+
const parsedTools = parseNormalizedToolDefinitions(toolsRaw);
|
|
148
|
+
if (parsedTools === null) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
out.tools = parsedTools;
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function parseReqOutboundCompatOutput(raw) {
|
|
160
|
+
try {
|
|
161
|
+
const parsed = JSON.parse(raw);
|
|
162
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
const row = parsed;
|
|
166
|
+
const payloadRaw = row.payload;
|
|
167
|
+
if (!payloadRaw || typeof payloadRaw !== 'object' || Array.isArray(payloadRaw)) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
const payload = payloadRaw;
|
|
171
|
+
const appliedProfileRaw = row.appliedProfile;
|
|
172
|
+
const appliedProfile = typeof appliedProfileRaw === 'string' && appliedProfileRaw.trim()
|
|
173
|
+
? appliedProfileRaw.trim()
|
|
174
|
+
: undefined;
|
|
175
|
+
const nativeAppliedRaw = row.nativeApplied;
|
|
176
|
+
if (typeof nativeAppliedRaw !== 'boolean') {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
const nativeApplied = nativeAppliedRaw;
|
|
180
|
+
const rateLimitDetectedRaw = row.rateLimitDetected;
|
|
181
|
+
const rateLimitDetected = typeof rateLimitDetectedRaw === 'boolean' ? rateLimitDetectedRaw : undefined;
|
|
182
|
+
return {
|
|
183
|
+
payload,
|
|
184
|
+
...(appliedProfile ? { appliedProfile } : {}),
|
|
185
|
+
nativeApplied,
|
|
186
|
+
...(rateLimitDetected !== undefined ? { rateLimitDetected } : {})
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function parseToolSessionCompatOutput(raw) {
|
|
194
|
+
try {
|
|
195
|
+
const parsed = JSON.parse(raw);
|
|
196
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
const row = parsed;
|
|
200
|
+
const messagesRaw = row.messages;
|
|
201
|
+
if (!Array.isArray(messagesRaw)) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
const out = {
|
|
205
|
+
messages: messagesRaw
|
|
206
|
+
};
|
|
207
|
+
if (Object.prototype.hasOwnProperty.call(row, 'toolOutputs')) {
|
|
208
|
+
if (row.toolOutputs == null) {
|
|
209
|
+
out.toolOutputs = undefined;
|
|
210
|
+
}
|
|
211
|
+
else if (Array.isArray(row.toolOutputs)) {
|
|
212
|
+
out.toolOutputs = row.toolOutputs;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function parseToolSessionHistoryUpdateOutput(raw) {
|
|
225
|
+
try {
|
|
226
|
+
const parsed = JSON.parse(raw);
|
|
227
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
const row = parsed;
|
|
231
|
+
const recordsCount = typeof row.recordsCount === 'number' && Number.isFinite(row.recordsCount)
|
|
232
|
+
? row.recordsCount
|
|
233
|
+
: null;
|
|
234
|
+
if (recordsCount === null) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
const output = { recordsCount };
|
|
238
|
+
if (row.history !== undefined) {
|
|
239
|
+
if (!row.history || typeof row.history !== 'object' || Array.isArray(row.history)) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
output.history = row.history;
|
|
243
|
+
}
|
|
244
|
+
return output;
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function parseJsonObject(raw) {
|
|
251
|
+
try {
|
|
252
|
+
const parsed = JSON.parse(raw);
|
|
253
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
return parsed;
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function parseReqOutboundFormatBuildOutput(raw) {
|
|
263
|
+
try {
|
|
264
|
+
const parsed = JSON.parse(raw);
|
|
265
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
const row = parsed;
|
|
269
|
+
const payload = row.payload;
|
|
270
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
return payload;
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
export function resolveReqOutboundContextMergePlanWithNative(input) {
|
|
280
|
+
const capability = 'resolveReqOutboundContextMergePlanJson';
|
|
281
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
282
|
+
if (isNativeDisabledByEnv()) {
|
|
283
|
+
return fail('native disabled');
|
|
284
|
+
}
|
|
285
|
+
const fn = readNativeFunction('resolveReqOutboundContextMergePlanJson');
|
|
286
|
+
if (!fn) {
|
|
287
|
+
return fail();
|
|
288
|
+
}
|
|
289
|
+
const inputJson = safeStringify(input);
|
|
290
|
+
if (!inputJson) {
|
|
291
|
+
return fail('json stringify failed');
|
|
292
|
+
}
|
|
293
|
+
try {
|
|
294
|
+
const raw = fn(inputJson);
|
|
295
|
+
if (typeof raw !== 'string' || !raw) {
|
|
296
|
+
return fail('empty result');
|
|
297
|
+
}
|
|
298
|
+
const parsed = parseReqOutboundContextMergePlan(raw);
|
|
299
|
+
return parsed ?? fail('invalid payload');
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
303
|
+
return fail(reason);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
export function buildReqOutboundFormatPayloadWithNative(input) {
|
|
307
|
+
const capability = 'buildFormatRequestJson';
|
|
308
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
309
|
+
if (isNativeDisabledByEnv()) {
|
|
310
|
+
return fail('native disabled');
|
|
311
|
+
}
|
|
312
|
+
const fn = readNativeFunction(capability);
|
|
313
|
+
if (!fn) {
|
|
314
|
+
return fail();
|
|
315
|
+
}
|
|
316
|
+
const inputJson = safeStringify({
|
|
317
|
+
formatEnvelope: input.formatEnvelope,
|
|
318
|
+
protocol: input.protocol
|
|
319
|
+
});
|
|
320
|
+
if (!inputJson) {
|
|
321
|
+
return fail('json stringify failed');
|
|
322
|
+
}
|
|
323
|
+
try {
|
|
324
|
+
const raw = fn(inputJson);
|
|
325
|
+
if (typeof raw !== 'string' || !raw) {
|
|
326
|
+
return fail('empty result');
|
|
327
|
+
}
|
|
328
|
+
const parsed = parseReqOutboundFormatBuildOutput(raw);
|
|
329
|
+
return parsed ?? fail('invalid payload');
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
333
|
+
return fail(reason);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
export function applyReqOutboundContextSnapshotWithNative(input) {
|
|
337
|
+
const capability = 'applyReqOutboundContextSnapshotJson';
|
|
338
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
339
|
+
if (isNativeDisabledByEnv()) {
|
|
340
|
+
return fail('native disabled');
|
|
341
|
+
}
|
|
342
|
+
const fn = readNativeFunction('applyReqOutboundContextSnapshotJson');
|
|
343
|
+
if (!fn) {
|
|
344
|
+
return fail();
|
|
345
|
+
}
|
|
346
|
+
const inputJson = safeStringify(input);
|
|
347
|
+
if (!inputJson) {
|
|
348
|
+
return fail('json stringify failed');
|
|
349
|
+
}
|
|
350
|
+
try {
|
|
351
|
+
const raw = fn(inputJson);
|
|
352
|
+
if (typeof raw !== 'string' || !raw) {
|
|
353
|
+
return fail('empty result');
|
|
354
|
+
}
|
|
355
|
+
const parsed = parseReqOutboundContextSnapshotPatch(raw);
|
|
356
|
+
return parsed ?? fail('invalid payload');
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
360
|
+
return fail(reason);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
export function runReqOutboundStage3CompatWithNative(input) {
|
|
364
|
+
const capability = 'runReqOutboundStage3CompatJson';
|
|
365
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
366
|
+
if (isNativeDisabledByEnv()) {
|
|
367
|
+
return fail('native disabled');
|
|
368
|
+
}
|
|
369
|
+
const fn = readNativeFunction('runReqOutboundStage3CompatJson');
|
|
370
|
+
if (!fn) {
|
|
371
|
+
return fail();
|
|
372
|
+
}
|
|
373
|
+
const inputJson = safeStringify(input);
|
|
374
|
+
if (!inputJson) {
|
|
375
|
+
return fail('json stringify failed');
|
|
376
|
+
}
|
|
377
|
+
try {
|
|
378
|
+
const raw = fn(inputJson);
|
|
379
|
+
if (typeof raw !== 'string' || !raw) {
|
|
380
|
+
return fail('empty result');
|
|
381
|
+
}
|
|
382
|
+
const parsed = parseReqOutboundCompatOutput(raw);
|
|
383
|
+
return parsed ?? fail('invalid payload');
|
|
384
|
+
}
|
|
385
|
+
catch (error) {
|
|
386
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
387
|
+
return fail(reason);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
export function runRespInboundStage3CompatWithNative(input) {
|
|
391
|
+
const capability = 'runRespInboundStage3CompatJson';
|
|
392
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
393
|
+
if (isNativeDisabledByEnv()) {
|
|
394
|
+
return fail('native disabled');
|
|
395
|
+
}
|
|
396
|
+
const fn = readNativeFunction('runRespInboundStage3CompatJson');
|
|
397
|
+
if (!fn) {
|
|
398
|
+
return fail();
|
|
399
|
+
}
|
|
400
|
+
const inputJson = safeStringify(input);
|
|
401
|
+
if (!inputJson) {
|
|
402
|
+
return fail('json stringify failed');
|
|
403
|
+
}
|
|
404
|
+
try {
|
|
405
|
+
const raw = fn(inputJson);
|
|
406
|
+
if (typeof raw !== 'string' || !raw) {
|
|
407
|
+
return fail('empty result');
|
|
408
|
+
}
|
|
409
|
+
const parsed = parseReqOutboundCompatOutput(raw);
|
|
410
|
+
return parsed ?? fail('invalid payload');
|
|
411
|
+
}
|
|
412
|
+
catch (error) {
|
|
413
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
414
|
+
return fail(reason);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
export function normalizeToolSessionMessagesWithNative(input) {
|
|
418
|
+
const capability = 'normalizeToolSessionMessagesJson';
|
|
419
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
420
|
+
if (isNativeDisabledByEnv()) {
|
|
421
|
+
return fail('native disabled');
|
|
422
|
+
}
|
|
423
|
+
const fn = readNativeFunction(capability);
|
|
424
|
+
if (!fn) {
|
|
425
|
+
return fail();
|
|
426
|
+
}
|
|
427
|
+
const inputJson = safeStringify(input);
|
|
428
|
+
if (!inputJson) {
|
|
429
|
+
return fail('json stringify failed');
|
|
430
|
+
}
|
|
431
|
+
try {
|
|
432
|
+
const raw = fn(inputJson);
|
|
433
|
+
if (typeof raw !== 'string' || !raw) {
|
|
434
|
+
return fail('empty result');
|
|
435
|
+
}
|
|
436
|
+
const parsed = parseToolSessionCompatOutput(raw);
|
|
437
|
+
return parsed ?? fail('invalid payload');
|
|
438
|
+
}
|
|
439
|
+
catch (error) {
|
|
440
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
441
|
+
return fail(reason);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
export function updateToolSessionHistoryWithNative(input) {
|
|
445
|
+
const capability = 'updateToolSessionHistoryJson';
|
|
446
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
447
|
+
if (isNativeDisabledByEnv()) {
|
|
448
|
+
return fail('native disabled');
|
|
449
|
+
}
|
|
450
|
+
const fn = readNativeFunction(capability);
|
|
451
|
+
if (!fn) {
|
|
452
|
+
return fail();
|
|
453
|
+
}
|
|
454
|
+
const inputJson = safeStringify(input);
|
|
455
|
+
if (!inputJson) {
|
|
456
|
+
return fail('json stringify failed');
|
|
457
|
+
}
|
|
458
|
+
try {
|
|
459
|
+
const raw = fn(inputJson);
|
|
460
|
+
if (typeof raw !== 'string' || !raw) {
|
|
461
|
+
return fail('empty result');
|
|
462
|
+
}
|
|
463
|
+
const parsed = parseToolSessionHistoryUpdateOutput(raw);
|
|
464
|
+
return parsed ?? fail('invalid payload');
|
|
465
|
+
}
|
|
466
|
+
catch (error) {
|
|
467
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
468
|
+
return fail(reason);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
export function applyClaudeThinkingToolSchemaCompatWithNative(payload) {
|
|
472
|
+
const capability = 'applyClaudeThinkingToolSchemaCompatJson';
|
|
473
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
474
|
+
if (isNativeDisabledByEnv()) {
|
|
475
|
+
return fail('native disabled');
|
|
476
|
+
}
|
|
477
|
+
const fn = readNativeFunction(capability);
|
|
478
|
+
if (!fn) {
|
|
479
|
+
return fail();
|
|
480
|
+
}
|
|
481
|
+
const payloadJson = safeStringify(payload);
|
|
482
|
+
if (!payloadJson) {
|
|
483
|
+
return fail('json stringify failed');
|
|
484
|
+
}
|
|
485
|
+
try {
|
|
486
|
+
const raw = fn(payloadJson);
|
|
487
|
+
if (typeof raw !== 'string' || !raw) {
|
|
488
|
+
return fail('empty result');
|
|
489
|
+
}
|
|
490
|
+
const parsed = parseJsonObject(raw);
|
|
491
|
+
return parsed ?? fail('invalid payload');
|
|
492
|
+
}
|
|
493
|
+
catch (error) {
|
|
494
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
495
|
+
return fail(reason);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
export function standardizedToChatEnvelopeWithNative(input) {
|
|
499
|
+
const capability = 'standardizedToChatEnvelopeJson';
|
|
500
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
501
|
+
if (isNativeDisabledByEnv()) {
|
|
502
|
+
return fail('native disabled');
|
|
503
|
+
}
|
|
504
|
+
const fn = readNativeFunction(capability);
|
|
505
|
+
if (!fn) {
|
|
506
|
+
return fail();
|
|
507
|
+
}
|
|
508
|
+
const requestJson = safeStringify(input.request);
|
|
509
|
+
const adapterContextJson = safeStringify(input.adapterContext);
|
|
510
|
+
if (!requestJson || !adapterContextJson) {
|
|
511
|
+
return fail('json stringify failed');
|
|
512
|
+
}
|
|
513
|
+
try {
|
|
514
|
+
const raw = fn(requestJson, adapterContextJson);
|
|
515
|
+
if (raw instanceof Error) {
|
|
516
|
+
return fail(raw.message || 'native error');
|
|
517
|
+
}
|
|
518
|
+
if (raw && typeof raw === 'object' && 'message' in raw) {
|
|
519
|
+
const message = raw.message;
|
|
520
|
+
if (typeof message === 'string' && message.trim().length) {
|
|
521
|
+
return fail(message.trim());
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (typeof raw !== 'string' || !raw) {
|
|
525
|
+
return fail('empty result');
|
|
526
|
+
}
|
|
527
|
+
const parsed = parseRecord(raw);
|
|
528
|
+
return parsed ?? fail('invalid payload');
|
|
529
|
+
}
|
|
530
|
+
catch (error) {
|
|
531
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
532
|
+
return fail(reason);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
function parseBoolean(raw) {
|
|
536
|
+
try {
|
|
537
|
+
const parsed = JSON.parse(raw);
|
|
538
|
+
return typeof parsed === 'boolean' ? parsed : null;
|
|
539
|
+
}
|
|
540
|
+
catch {
|
|
541
|
+
return null;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
export function shouldAttachReqOutboundContextSnapshotWithNative(hasSnapshot, contextMetadataKey) {
|
|
545
|
+
const capability = 'shouldAttachReqOutboundContextSnapshotJson';
|
|
546
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
547
|
+
if (isNativeDisabledByEnv()) {
|
|
548
|
+
return fail('native disabled');
|
|
549
|
+
}
|
|
550
|
+
const fn = readNativeFunction('shouldAttachReqOutboundContextSnapshotJson');
|
|
551
|
+
if (!fn) {
|
|
552
|
+
return fail();
|
|
553
|
+
}
|
|
554
|
+
try {
|
|
555
|
+
const contextMetadataKeyJson = JSON.stringify(contextMetadataKey ?? null);
|
|
556
|
+
if (typeof contextMetadataKeyJson !== 'string') {
|
|
557
|
+
return fail('json stringify failed');
|
|
558
|
+
}
|
|
559
|
+
const raw = fn(hasSnapshot, contextMetadataKeyJson);
|
|
560
|
+
if (typeof raw !== 'string' || !raw) {
|
|
561
|
+
return fail('empty result');
|
|
562
|
+
}
|
|
563
|
+
const parsed = parseBoolean(raw);
|
|
564
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
565
|
+
}
|
|
566
|
+
catch (error) {
|
|
567
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
568
|
+
return fail(reason);
|
|
569
|
+
}
|
|
570
|
+
}
|
package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface NativeReqProcessToolGovernanceInput {
|
|
2
|
+
request: Record<string, unknown>;
|
|
3
|
+
rawPayload: Record<string, unknown>;
|
|
4
|
+
metadata: Record<string, unknown>;
|
|
5
|
+
entryEndpoint: string;
|
|
6
|
+
requestId: string;
|
|
7
|
+
}
|
|
8
|
+
export interface NativeReqProcessToolGovernanceOutput {
|
|
9
|
+
processedRequest: Record<string, unknown>;
|
|
10
|
+
nodeResult: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export declare function applyReqProcessToolGovernanceWithNative(input: NativeReqProcessToolGovernanceInput): NativeReqProcessToolGovernanceOutput;
|
|
13
|
+
export declare function applyHubOperationsWithNative(request: Record<string, unknown>, operations: unknown[]): Record<string, unknown>;
|
|
14
|
+
export interface NativeReqProcessRouteSelectInput {
|
|
15
|
+
request: Record<string, unknown>;
|
|
16
|
+
normalizedMetadata: Record<string, unknown>;
|
|
17
|
+
target: Record<string, unknown>;
|
|
18
|
+
routeName?: string;
|
|
19
|
+
originalModel?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface NativeReqProcessRouteSelectOutput {
|
|
22
|
+
request: Record<string, unknown>;
|
|
23
|
+
normalizedMetadata: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
export declare function applyReqProcessRouteSelectionWithNative(input: NativeReqProcessRouteSelectInput): NativeReqProcessRouteSelectOutput;
|