@jsonstudio/llms 0.6.2172 → 0.6.2979
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/conversion/compat/antigravity-session-signature.js +35 -1
- package/dist/conversion/compat/profiles/chat-gemini-cli.json +0 -7
- package/dist/conversion/compat/profiles/chat-gemini.json +0 -6
- package/dist/conversion/hub/core/detour-registry.d.ts +2 -0
- package/dist/conversion/hub/core/hub-context.d.ts +3 -1
- package/dist/conversion/hub/core/index.d.ts +1 -0
- package/dist/conversion/hub/core/stage-driver.js +2 -0
- package/dist/conversion/hub/format-adapters/anthropic-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/chat-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/gemini-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/responses-format-adapter.js +15 -4
- package/dist/conversion/hub/hub-feature.js +3 -2
- package/dist/conversion/hub/node-support.js +9 -4
- package/dist/conversion/hub/operation-table/operation-table-runner.js +10 -6
- package/dist/conversion/hub/operation-table/semantic-mappers/anthropic-mapper.js +2 -2
- package/dist/conversion/hub/operation-table/semantic-mappers/chat-mapper.js +10 -10
- package/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.js +4 -8
- package/dist/conversion/hub/operation-table/semantic-mappers/responses-mapper.js +19 -65
- package/dist/conversion/hub/ops/operations.js +2 -121
- package/dist/conversion/hub/pipeline/compat/compat-engine.js +6 -0
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.d.ts +1 -1
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +33 -1042
- package/dist/conversion/hub/pipeline/compat/compat-profile-resolver.js +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-profile-store.js +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-types.d.ts +14 -17
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.d.ts +3 -0
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.js +39 -0
- package/dist/conversion/hub/pipeline/hub-pipeline.js +115 -262
- package/dist/conversion/hub/pipeline/session-identifiers.js +6 -196
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.js +37 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.js +12 -86
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.d.ts +14 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.js +24 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.d.ts +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.js +157 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.d.ts +16 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.js +29 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-factories.js +3 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.d.ts +2 -15
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.js +8 -595
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.d.ts +8 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.js +28 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.d.ts +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.js +4 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.d.ts +10 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.js +12 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.js +30 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/index.js +9 -129
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.d.ts +1 -4
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.js +9 -26
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +32 -14
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.d.ts +2 -2
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.js +48 -8
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage2_route_select/index.js +18 -3
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/index.js +10 -198
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.js +81 -0
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.js +36 -1
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage3_semantic_map/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.d.ts +6 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.js +17 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.d.ts +9 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.js +28 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.js +14 -102
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage2_sse_stream/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage1_tool_governance/index.js +12 -10
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage2_finalize/index.js +6 -5
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.d.ts +11 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.js +10 -32
- package/dist/conversion/hub/pipeline/stages/utils.js +17 -1
- package/dist/conversion/hub/pipeline/target-utils.js +14 -91
- package/dist/conversion/hub/pipelines/inbound.js +3 -1
- package/dist/conversion/hub/pipelines/outbound.js +2 -0
- package/dist/conversion/hub/policy/policy-engine.js +9 -3
- package/dist/conversion/hub/policy/protocol-spec.js +20 -148
- package/dist/conversion/hub/process/chat-process-anthropic-alias.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-anthropic-alias.js +36 -0
- package/dist/conversion/hub/process/chat-process-clock-directive-parser.d.ts +5 -0
- package/dist/conversion/hub/process/chat-process-clock-directive-parser.js +48 -0
- package/dist/conversion/hub/process/chat-process-clock-directives.d.ts +24 -0
- package/dist/conversion/hub/process/chat-process-clock-directives.js +98 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-directives.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-directives.js +42 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-finalize.d.ts +14 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-finalize.js +10 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-messages.d.ts +5 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-messages.js +10 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.d.ts +30 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.js +68 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.d.ts +9 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.js +18 -0
- package/dist/conversion/hub/process/chat-process-clock-reminders.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-clock-reminders.js +104 -0
- package/dist/conversion/hub/process/chat-process-clock-tool-schemas.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-clock-tool-schemas.js +233 -0
- package/dist/conversion/hub/process/chat-process-clock-tools.d.ts +6 -0
- package/dist/conversion/hub/process/chat-process-clock-tools.js +41 -0
- package/dist/conversion/hub/process/chat-process-continue-execution.d.ts +11 -0
- package/dist/conversion/hub/process/chat-process-continue-execution.js +82 -0
- package/dist/conversion/hub/process/chat-process-governance-context.d.ts +15 -0
- package/dist/conversion/hub/process/chat-process-governance-context.js +7 -0
- package/dist/conversion/hub/process/chat-process-governance-finalize.d.ts +16 -0
- package/dist/conversion/hub/process/chat-process-governance-finalize.js +11 -0
- package/dist/conversion/hub/process/chat-process-governance-orchestration.d.ts +9 -0
- package/dist/conversion/hub/process/chat-process-governance-orchestration.js +47 -0
- package/dist/conversion/hub/process/chat-process-governed-control-ops.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-governed-control-ops.js +5 -0
- package/dist/conversion/hub/process/chat-process-governed-filter-call.d.ts +12 -0
- package/dist/conversion/hub/process/chat-process-governed-filter-call.js +18 -0
- package/dist/conversion/hub/process/chat-process-governed-merge.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-governed-merge.js +11 -0
- package/dist/conversion/hub/process/chat-process-media.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-media.js +18 -0
- package/dist/conversion/hub/process/chat-process-node-result.d.ts +23 -0
- package/dist/conversion/hub/process/chat-process-node-result.js +24 -0
- package/dist/conversion/hub/process/chat-process-pending-tool-sync.d.ts +14 -0
- package/dist/conversion/hub/process/chat-process-pending-tool-sync.js +52 -0
- package/dist/conversion/hub/process/chat-process-post-governed-normalization.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-post-governed-normalization.js +16 -0
- package/dist/conversion/hub/process/chat-process-review.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-review.js +8 -0
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.js +22 -0
- package/dist/conversion/hub/process/chat-process-tool-normalization.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-tool-normalization.js +4 -0
- package/dist/conversion/hub/process/chat-process-web-search-intent.d.ts +12 -0
- package/dist/conversion/hub/process/chat-process-web-search-intent.js +13 -0
- package/dist/conversion/hub/process/chat-process-web-search-tool-schema.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-web-search-tool-schema.js +4 -0
- package/dist/conversion/hub/process/chat-process-web-search.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-web-search.js +26 -0
- package/dist/conversion/hub/process/chat-process.d.ts +2 -19
- package/dist/conversion/hub/process/chat-process.js +12 -1701
- package/dist/conversion/hub/process/client-inject-readiness.d.ts +1 -0
- package/dist/conversion/hub/process/client-inject-readiness.js +4 -0
- package/dist/conversion/hub/registry.js +5 -2
- package/dist/conversion/hub/response/chat-response-utils.js +5 -86
- package/dist/conversion/hub/response/provider-response.d.ts +9 -0
- package/dist/conversion/hub/response/provider-response.js +6 -21
- package/dist/conversion/hub/response/response-mappers.js +2 -26
- package/dist/conversion/hub/response/response-runtime.js +2 -93
- package/dist/conversion/hub/semantic-mappers/anthropic-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/anthropic-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/chat-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/chat-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/gemini-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/gemini-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/responses-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/responses-mapper.js +1 -0
- package/dist/conversion/hub/snapshot-recorder.js +10 -3
- package/dist/conversion/hub/standardized-bridge.js +11 -288
- package/dist/conversion/hub/tool-governance/engine.js +5 -0
- package/dist/conversion/hub/tool-governance/rules.js +10 -10
- package/dist/conversion/hub/tool-session-compat.d.ts +2 -2
- package/dist/conversion/hub/tool-session-compat.js +17 -231
- package/dist/conversion/hub/tool-surface/tool-surface-engine.js +5 -3
- package/dist/conversion/responses/responses-host-policy.js +2 -12
- package/dist/conversion/responses/responses-openai-bridge/response-payload.js +6 -82
- package/dist/conversion/responses/responses-openai-bridge/types.d.ts +1 -0
- package/dist/conversion/responses/responses-openai-bridge.js +21 -54
- package/dist/conversion/shared/anthropic-message-utils.js +151 -13
- package/dist/conversion/shared/args-mapping.js +2 -146
- package/dist/conversion/shared/bridge-actions.js +203 -718
- package/dist/conversion/shared/bridge-id-utils.js +5 -71
- package/dist/conversion/shared/bridge-instructions.js +2 -1
- package/dist/conversion/shared/bridge-message-types.d.ts +2 -0
- package/dist/conversion/shared/bridge-message-utils.js +1 -2
- package/dist/conversion/shared/bridge-metadata.d.ts +1 -0
- package/dist/conversion/shared/bridge-metadata.js +4 -0
- package/dist/conversion/shared/bridge-policies.js +5 -189
- package/dist/conversion/shared/chat-envelope-validator.js +2 -126
- package/dist/conversion/shared/chat-output-normalizer.js +2 -54
- package/dist/conversion/shared/compaction-detect.js +2 -57
- package/dist/conversion/shared/gemini-tool-utils.js +9 -524
- package/dist/conversion/shared/jsonish.js +3 -160
- package/dist/conversion/shared/mcp-injection.js +3 -169
- package/dist/conversion/shared/media.js +2 -7
- package/dist/conversion/shared/metadata-passthrough.js +9 -46
- package/dist/conversion/shared/openai-finalizer.js +2 -1
- package/dist/conversion/shared/openai-message-normalize.js +11 -283
- package/dist/conversion/shared/output-content-normalizer.js +9 -112
- package/dist/conversion/shared/payload-budget.js +2 -85
- package/dist/conversion/shared/protocol-state.js +11 -7
- package/dist/conversion/shared/reasoning-mapping.js +2 -6
- package/dist/conversion/shared/reasoning-normalizer.js +4 -1
- package/dist/conversion/shared/reasoning-tool-normalizer.js +14 -126
- package/dist/conversion/shared/reasoning-tool-parser.js +4 -87
- package/dist/conversion/shared/reasoning-utils.js +2 -6
- package/dist/conversion/shared/responses-conversation-store.js +4 -82
- package/dist/conversion/shared/responses-output-builder.js +11 -47
- package/dist/conversion/shared/responses-reasoning-registry.js +7 -1
- package/dist/conversion/shared/responses-request-adapter.d.ts +7 -1
- package/dist/conversion/shared/responses-request-adapter.js +14 -1
- package/dist/conversion/shared/responses-response-utils.js +6 -7
- package/dist/conversion/shared/responses-tool-utils.d.ts +1 -0
- package/dist/conversion/shared/responses-tool-utils.js +90 -14
- package/dist/conversion/shared/runtime-metadata.js +13 -5
- package/dist/conversion/shared/streaming-text-extractor.js +2 -7
- package/dist/conversion/shared/text-markup-normalizer/normalize.d.ts +1 -1
- package/dist/conversion/shared/text-markup-normalizer/normalize.js +43 -17
- package/dist/conversion/shared/text-markup-normalizer.d.ts +1 -0
- package/dist/conversion/shared/text-markup-normalizer.js +1 -0
- package/dist/conversion/shared/thought-signature-validator.js +3 -2
- package/dist/conversion/shared/tool-argument-repairer.js +2 -2
- package/dist/conversion/shared/tool-call-id-manager.js +5 -7
- package/dist/conversion/shared/tool-call-utils.js +3 -45
- package/dist/conversion/shared/tool-canonicalizer.js +25 -29
- package/dist/conversion/shared/tool-filter-pipeline.js +4 -99
- package/dist/conversion/shared/tool-governor.d.ts +6 -0
- package/dist/conversion/shared/tool-governor.js +43 -125
- package/dist/conversion/shared/tool-harvester.js +2 -8
- package/dist/conversion/shared/tool-mapping.js +2 -5
- package/dist/conversion/shared/tooling.d.ts +0 -4
- package/dist/conversion/shared/tooling.js +18 -0
- package/dist/native/router_hotpath_napi.node +0 -0
- package/dist/router/virtual-router/engine/provider-key/parse.d.ts +1 -6
- package/dist/router/virtual-router/engine/provider-key/parse.js +1 -43
- package/dist/router/virtual-router/engine/routing-state/store.js +48 -12
- package/dist/router/virtual-router/engine-logging.js +4 -3
- package/dist/router/virtual-router/engine-selection/alias-selection.js +45 -83
- package/dist/router/virtual-router/engine-selection/key-parsing.js +9 -23
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.d.ts +20 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.js +163 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.d.ts +7 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.js +103 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.js +110 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.d.ts +8 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.js +281 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.js +25 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.d.ts +4 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.js +44 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.js +62 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.d.ts +40 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.js +484 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.d.ts +9 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.js +64 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.js +163 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.js +49 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.d.ts +30 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.js +446 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.js +49 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.d.ts +134 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js +729 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.d.ts +62 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.js +338 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.d.ts +18 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js +317 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.d.ts +22 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.js +426 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.d.ts +57 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.js +705 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.d.ts +46 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js +503 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.d.ts +146 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js +570 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.js +148 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.js +637 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.d.ts +11 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.js +207 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.d.ts +3 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.js +128 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.d.ts +57 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.js +217 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.js +284 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.js +18 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.js +85 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath.d.ts +59 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath.js +117 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.d.ts +76 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.js +1166 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.d.ts +16 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.js +96 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.d.ts +6 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.js +85 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.d.ts +9 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.js +70 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.js +76 -0
- package/dist/router/virtual-router/engine-selection/route-utils.js +1 -1
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.js +231 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.d.ts +4 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.js +43 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.d.ts +27 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.js +116 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-select.d.ts +1 -1
- package/dist/router/virtual-router/engine-selection/tier-selection-select.js +29 -129
- package/dist/router/virtual-router/engine-selection/tier-selection.js +2 -265
- package/dist/router/virtual-router/engine.js +258 -249
- package/dist/router/virtual-router/features.js +2 -2
- package/dist/router/virtual-router/routing-instructions.d.ts +5 -7
- package/dist/router/virtual-router/routing-instructions.js +93 -66
- package/dist/router/virtual-router/routing-stop-message-actions.js +91 -112
- package/dist/router/virtual-router/routing-stop-message-parser.js +9 -132
- package/dist/router/virtual-router/routing-stop-message-state-codec.d.ts +1 -0
- package/dist/router/virtual-router/routing-stop-message-state-codec.js +58 -71
- package/dist/router/virtual-router/sticky-session-store.js +4 -2
- package/dist/router/virtual-router/stop-message-file-resolver.d.ts +1 -0
- package/dist/router/virtual-router/stop-message-file-resolver.js +10 -0
- package/dist/router/virtual-router/stop-message-state-sync.d.ts +1 -1
- package/dist/router/virtual-router/stop-message-state-sync.js +3 -7
- package/dist/router/virtual-router/token-counter.js +0 -9
- package/dist/router/virtual-router/types.d.ts +9 -7
- package/dist/servertool/clock/config.js +23 -51
- package/dist/servertool/clock/io.js +1 -0
- package/dist/servertool/clock/session-scope.d.ts +2 -2
- package/dist/servertool/clock/session-scope.js +5 -47
- package/dist/servertool/engine.d.ts +9 -0
- package/dist/servertool/engine.js +196 -79
- package/dist/servertool/handlers/antigravity-thought-signature-bootstrap.js +2 -2
- package/dist/servertool/handlers/clock.js +1 -1
- package/dist/servertool/handlers/continue-execution.js +8 -4
- package/dist/servertool/handlers/followup-request-builder.js +18 -1
- package/dist/servertool/handlers/gemini-empty-reply-continue.js +7 -1
- package/dist/servertool/handlers/review.js +180 -0
- package/dist/servertool/handlers/stop-message-auto/blocked-report.js +59 -1
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.d.ts +23 -2
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.js +397 -89
- package/dist/servertool/handlers/stop-message-auto/routing-state.d.ts +5 -15
- package/dist/servertool/handlers/stop-message-auto/routing-state.js +29 -55
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.d.ts +6 -0
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.js +35 -61
- package/dist/servertool/handlers/stop-message-auto.js +392 -76
- package/dist/servertool/server-side-tools.d.ts +1 -0
- package/dist/servertool/server-side-tools.js +90 -52
- package/dist/servertool/types.d.ts +17 -0
- package/dist/tools/apply-patch/patch-text/normalize.js +11 -0
- package/dist/tools/exec-command/validator.d.ts +4 -1
- package/dist/tools/exec-command/validator.js +87 -3
- package/dist/tools/tool-registry.d.ts +7 -1
- package/dist/tools/tool-registry.js +3 -2
- package/package.json +115 -7
- package/dist/servertool/handlers/stop-message-stage-policy/bd-runtime.d.ts +0 -18
- package/dist/servertool/handlers/stop-message-stage-policy/bd-runtime.js +0 -398
- package/dist/servertool/handlers/stop-message-stage-policy/decision.d.ts +0 -9
- package/dist/servertool/handlers/stop-message-stage-policy/decision.js +0 -127
- package/dist/servertool/handlers/stop-message-stage-policy/observation.d.ts +0 -2
- package/dist/servertool/handlers/stop-message-stage-policy/observation.js +0 -179
- package/dist/servertool/handlers/stop-message-stage-policy/templates.d.ts +0 -4
- package/dist/servertool/handlers/stop-message-stage-policy/templates.js +0 -96
- package/dist/servertool/handlers/stop-message-stage-policy/text-utils.d.ts +0 -9
- package/dist/servertool/handlers/stop-message-stage-policy/text-utils.js +0 -89
- package/dist/servertool/handlers/stop-message-stage-policy/types.d.ts +0 -59
- package/dist/servertool/handlers/stop-message-stage-policy.d.ts +0 -3
- package/dist/servertool/handlers/stop-message-stage-policy.js +0 -2
- /package/dist/servertool/handlers/{stop-message-stage-policy/types.js → review.d.ts} +0 -0
package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.js
ADDED
|
@@ -0,0 +1,705 @@
|
|
|
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 parseOrchestrationOutput(raw) {
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(raw);
|
|
19
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const row = parsed;
|
|
23
|
+
const requestId = typeof row.requestId === 'string' ? row.requestId : '';
|
|
24
|
+
const success = row.success === true;
|
|
25
|
+
if (!requestId) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const output = {
|
|
29
|
+
requestId,
|
|
30
|
+
success
|
|
31
|
+
};
|
|
32
|
+
if (row.payload && typeof row.payload === 'object' && !Array.isArray(row.payload)) {
|
|
33
|
+
output.payload = row.payload;
|
|
34
|
+
}
|
|
35
|
+
if (row.metadata && typeof row.metadata === 'object' && !Array.isArray(row.metadata)) {
|
|
36
|
+
output.metadata = row.metadata;
|
|
37
|
+
}
|
|
38
|
+
if (row.error && typeof row.error === 'object' && !Array.isArray(row.error)) {
|
|
39
|
+
const err = row.error;
|
|
40
|
+
const code = typeof err.code === 'string' ? err.code.trim() : '';
|
|
41
|
+
const message = typeof err.message === 'string' ? err.message.trim() : '';
|
|
42
|
+
if (code && message) {
|
|
43
|
+
output.error = {
|
|
44
|
+
code,
|
|
45
|
+
message,
|
|
46
|
+
...(Object.prototype.hasOwnProperty.call(err, 'details') ? { details: err.details } : {})
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return output;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function parseString(raw) {
|
|
57
|
+
try {
|
|
58
|
+
const parsed = JSON.parse(raw);
|
|
59
|
+
return typeof parsed === 'string' ? parsed : null;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function parseOptionalString(raw) {
|
|
66
|
+
try {
|
|
67
|
+
const parsed = JSON.parse(raw);
|
|
68
|
+
if (parsed === null) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
return typeof parsed === 'string' ? parsed : null;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function parseBoolean(raw) {
|
|
78
|
+
try {
|
|
79
|
+
const parsed = JSON.parse(raw);
|
|
80
|
+
return typeof parsed === 'boolean' ? parsed : null;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function parseRecord(raw) {
|
|
87
|
+
try {
|
|
88
|
+
const parsed = JSON.parse(raw);
|
|
89
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return parsed;
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function parseOptionalBoolean(raw) {
|
|
99
|
+
try {
|
|
100
|
+
const parsed = JSON.parse(raw);
|
|
101
|
+
if (parsed === null) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
return typeof parsed === 'boolean' ? parsed : null;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function parseStopMessageRouterMetadata(raw) {
|
|
111
|
+
try {
|
|
112
|
+
const parsed = JSON.parse(raw);
|
|
113
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
const row = parsed;
|
|
117
|
+
const out = {};
|
|
118
|
+
const assignIfNonEmpty = (key) => {
|
|
119
|
+
const rawValue = row[key];
|
|
120
|
+
if (typeof rawValue !== 'string') {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const trimmed = rawValue.trim();
|
|
124
|
+
if (!trimmed) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
out[key] = trimmed;
|
|
128
|
+
};
|
|
129
|
+
assignIfNonEmpty('stopMessageClientInjectSessionScope');
|
|
130
|
+
assignIfNonEmpty('stopMessageClientInjectScope');
|
|
131
|
+
assignIfNonEmpty('clientTmuxSessionId');
|
|
132
|
+
assignIfNonEmpty('client_tmux_session_id');
|
|
133
|
+
assignIfNonEmpty('tmuxSessionId');
|
|
134
|
+
assignIfNonEmpty('tmux_session_id');
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function parseHubPolicyOverride(raw) {
|
|
142
|
+
try {
|
|
143
|
+
const parsed = JSON.parse(raw);
|
|
144
|
+
if (parsed === null) {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const row = parsed;
|
|
151
|
+
const mode = typeof row.mode === 'string' ? row.mode.trim().toLowerCase() : '';
|
|
152
|
+
if (mode !== 'off' && mode !== 'observe' && mode !== 'enforce') {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
const out = { mode };
|
|
156
|
+
if (typeof row.sampleRate === 'number' && Number.isFinite(row.sampleRate)) {
|
|
157
|
+
out.sampleRate = row.sampleRate;
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function parseHubShadowCompareConfig(raw) {
|
|
166
|
+
try {
|
|
167
|
+
const parsed = JSON.parse(raw);
|
|
168
|
+
if (parsed === null) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
const row = parsed;
|
|
175
|
+
const baselineMode = typeof row.baselineMode === 'string' ? row.baselineMode.trim().toLowerCase() : '';
|
|
176
|
+
if (baselineMode !== 'off' && baselineMode !== 'observe' && baselineMode !== 'enforce') {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
return { baselineMode };
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function parseApplyPatchToolMode(raw) {
|
|
186
|
+
try {
|
|
187
|
+
const parsed = JSON.parse(raw);
|
|
188
|
+
if (parsed === null) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
if (typeof parsed !== 'string') {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
const mode = parsed.trim().toLowerCase();
|
|
195
|
+
if (mode === 'schema' || mode === 'freeform') {
|
|
196
|
+
return mode;
|
|
197
|
+
}
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function parseStringArray(raw) {
|
|
205
|
+
try {
|
|
206
|
+
const parsed = JSON.parse(raw);
|
|
207
|
+
if (!Array.isArray(parsed)) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
const out = [];
|
|
211
|
+
for (const entry of parsed) {
|
|
212
|
+
if (typeof entry !== 'string') {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
out.push(entry);
|
|
216
|
+
}
|
|
217
|
+
return out;
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
export function runHubPipelineOrchestrationWithNative(input) {
|
|
224
|
+
const capability = 'runHubPipelineJson';
|
|
225
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
226
|
+
if (isNativeDisabledByEnv()) {
|
|
227
|
+
return fail('native disabled');
|
|
228
|
+
}
|
|
229
|
+
const fn = readNativeFunction(capability);
|
|
230
|
+
if (!fn) {
|
|
231
|
+
return fail();
|
|
232
|
+
}
|
|
233
|
+
const inputJson = safeStringify(input);
|
|
234
|
+
if (!inputJson) {
|
|
235
|
+
return fail('json stringify failed');
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
const raw = fn(inputJson);
|
|
239
|
+
if (typeof raw !== 'string' || !raw) {
|
|
240
|
+
return fail('empty result');
|
|
241
|
+
}
|
|
242
|
+
const parsed = parseOrchestrationOutput(raw);
|
|
243
|
+
return parsed ?? fail('invalid payload');
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
247
|
+
return fail(reason);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
export function normalizeHubEndpointWithNative(endpoint) {
|
|
251
|
+
const capability = 'normalizeHubEndpointJson';
|
|
252
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
253
|
+
if (isNativeDisabledByEnv()) {
|
|
254
|
+
return fail('native disabled');
|
|
255
|
+
}
|
|
256
|
+
const fn = readNativeFunction(capability);
|
|
257
|
+
if (!fn) {
|
|
258
|
+
return fail();
|
|
259
|
+
}
|
|
260
|
+
try {
|
|
261
|
+
const raw = fn(String(endpoint || ''));
|
|
262
|
+
if (typeof raw !== 'string' || !raw) {
|
|
263
|
+
return fail('empty result');
|
|
264
|
+
}
|
|
265
|
+
const parsed = parseString(raw);
|
|
266
|
+
return parsed ?? fail('invalid payload');
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
270
|
+
return fail(reason);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
export function resolveHubProviderProtocolWithNative(value) {
|
|
274
|
+
const capability = 'resolveProviderProtocolJson';
|
|
275
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
276
|
+
if (isNativeDisabledByEnv()) {
|
|
277
|
+
return fail('native disabled');
|
|
278
|
+
}
|
|
279
|
+
const fn = readNativeFunction(capability);
|
|
280
|
+
if (!fn) {
|
|
281
|
+
return fail();
|
|
282
|
+
}
|
|
283
|
+
const normalizedInput = typeof value === 'string' ? value : '';
|
|
284
|
+
try {
|
|
285
|
+
const raw = fn(normalizedInput);
|
|
286
|
+
if (typeof raw !== 'string' || !raw) {
|
|
287
|
+
return fail('empty result');
|
|
288
|
+
}
|
|
289
|
+
const parsed = parseString(raw);
|
|
290
|
+
return parsed ?? fail('invalid payload');
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
294
|
+
return fail(reason);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
export function resolveHubClientProtocolWithNative(entryEndpoint) {
|
|
298
|
+
const capability = 'resolveHubClientProtocolJson';
|
|
299
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
300
|
+
if (isNativeDisabledByEnv()) {
|
|
301
|
+
return fail('native disabled');
|
|
302
|
+
}
|
|
303
|
+
const fn = readNativeFunction(capability);
|
|
304
|
+
if (!fn) {
|
|
305
|
+
return fail();
|
|
306
|
+
}
|
|
307
|
+
try {
|
|
308
|
+
const raw = fn(String(entryEndpoint || ''));
|
|
309
|
+
if (typeof raw !== 'string' || !raw) {
|
|
310
|
+
return fail('empty result');
|
|
311
|
+
}
|
|
312
|
+
const parsed = parseString(raw);
|
|
313
|
+
return parsed ?? fail('invalid payload');
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
317
|
+
return fail(reason);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
export function resolveOutboundStreamIntentWithNative(providerPreference) {
|
|
321
|
+
const capability = 'resolveOutboundStreamIntentJson';
|
|
322
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
323
|
+
if (isNativeDisabledByEnv()) {
|
|
324
|
+
return fail('native disabled');
|
|
325
|
+
}
|
|
326
|
+
const fn = readNativeFunction(capability);
|
|
327
|
+
if (!fn) {
|
|
328
|
+
return fail();
|
|
329
|
+
}
|
|
330
|
+
const preferenceJson = safeStringify(providerPreference ?? null);
|
|
331
|
+
if (!preferenceJson) {
|
|
332
|
+
return fail('json stringify failed');
|
|
333
|
+
}
|
|
334
|
+
try {
|
|
335
|
+
const raw = fn(preferenceJson);
|
|
336
|
+
if (typeof raw !== 'string' || !raw) {
|
|
337
|
+
return fail('empty result');
|
|
338
|
+
}
|
|
339
|
+
const parsed = parseOptionalBoolean(raw);
|
|
340
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
344
|
+
return fail(reason);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
export function applyOutboundStreamPreferenceWithNative(request, stream, processMode) {
|
|
348
|
+
const capability = 'applyOutboundStreamPreferenceJson';
|
|
349
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
350
|
+
if (isNativeDisabledByEnv()) {
|
|
351
|
+
return fail('native disabled');
|
|
352
|
+
}
|
|
353
|
+
const fn = readNativeFunction(capability);
|
|
354
|
+
if (!fn) {
|
|
355
|
+
return fail();
|
|
356
|
+
}
|
|
357
|
+
const requestJson = safeStringify(request ?? {});
|
|
358
|
+
const streamJson = safeStringify(stream ?? null);
|
|
359
|
+
const modeJson = safeStringify(processMode ?? null);
|
|
360
|
+
if (!requestJson || !streamJson || !modeJson) {
|
|
361
|
+
return fail('json stringify failed');
|
|
362
|
+
}
|
|
363
|
+
try {
|
|
364
|
+
const raw = fn(requestJson, streamJson, modeJson);
|
|
365
|
+
if (typeof raw !== 'string' || !raw) {
|
|
366
|
+
return fail('empty result');
|
|
367
|
+
}
|
|
368
|
+
const parsed = parseRecord(raw);
|
|
369
|
+
return parsed ?? fail('invalid payload');
|
|
370
|
+
}
|
|
371
|
+
catch (error) {
|
|
372
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
373
|
+
return fail(reason);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
export function resolveHubSseProtocolFromMetadataWithNative(metadata) {
|
|
377
|
+
const capability = 'resolveSseProtocolFromMetadataJson';
|
|
378
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
379
|
+
if (isNativeDisabledByEnv()) {
|
|
380
|
+
return fail('native disabled');
|
|
381
|
+
}
|
|
382
|
+
const fn = readNativeFunction(capability);
|
|
383
|
+
if (!fn) {
|
|
384
|
+
return fail();
|
|
385
|
+
}
|
|
386
|
+
const metadataJson = safeStringify(metadata ?? {});
|
|
387
|
+
if (!metadataJson) {
|
|
388
|
+
return fail('json stringify failed');
|
|
389
|
+
}
|
|
390
|
+
try {
|
|
391
|
+
const raw = fn(metadataJson);
|
|
392
|
+
if (typeof raw !== 'string' || !raw) {
|
|
393
|
+
return fail('empty result');
|
|
394
|
+
}
|
|
395
|
+
const parsed = parseOptionalString(raw);
|
|
396
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
400
|
+
return fail(reason);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
export function resolveStopMessageRouterMetadataWithNative(metadata) {
|
|
404
|
+
const capability = 'resolveStopMessageRouterMetadataJson';
|
|
405
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
406
|
+
if (isNativeDisabledByEnv()) {
|
|
407
|
+
return fail('native disabled');
|
|
408
|
+
}
|
|
409
|
+
const fn = readNativeFunction(capability);
|
|
410
|
+
if (!fn) {
|
|
411
|
+
return fail();
|
|
412
|
+
}
|
|
413
|
+
const metadataJson = safeStringify(metadata ?? null);
|
|
414
|
+
if (!metadataJson) {
|
|
415
|
+
return fail('json stringify failed');
|
|
416
|
+
}
|
|
417
|
+
try {
|
|
418
|
+
const raw = fn(metadataJson);
|
|
419
|
+
if (typeof raw !== 'string' || !raw) {
|
|
420
|
+
return fail('empty result');
|
|
421
|
+
}
|
|
422
|
+
const parsed = parseStopMessageRouterMetadata(raw);
|
|
423
|
+
return parsed ?? fail('invalid payload');
|
|
424
|
+
}
|
|
425
|
+
catch (error) {
|
|
426
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
427
|
+
return fail(reason);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
export function extractAdapterContextMetadataFieldsWithNative(metadata, keys) {
|
|
431
|
+
const capability = 'extractAdapterContextMetadataFieldsJson';
|
|
432
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
433
|
+
if (isNativeDisabledByEnv()) {
|
|
434
|
+
return fail('native disabled');
|
|
435
|
+
}
|
|
436
|
+
const fn = readNativeFunction(capability);
|
|
437
|
+
if (!fn) {
|
|
438
|
+
return fail();
|
|
439
|
+
}
|
|
440
|
+
const metadataJson = safeStringify(metadata ?? {});
|
|
441
|
+
const keysJson = safeStringify(Array.isArray(keys) ? keys : []);
|
|
442
|
+
if (!metadataJson || !keysJson) {
|
|
443
|
+
return fail('json stringify failed');
|
|
444
|
+
}
|
|
445
|
+
try {
|
|
446
|
+
const raw = fn(metadataJson, keysJson);
|
|
447
|
+
if (typeof raw !== 'string' || !raw) {
|
|
448
|
+
return fail('empty result');
|
|
449
|
+
}
|
|
450
|
+
const parsed = parseRecord(raw);
|
|
451
|
+
return parsed ?? fail('invalid payload');
|
|
452
|
+
}
|
|
453
|
+
catch (error) {
|
|
454
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
455
|
+
return fail(reason);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
export function resolveHubPolicyOverrideFromMetadataWithNative(metadata) {
|
|
459
|
+
const capability = 'resolveHubPolicyOverrideJson';
|
|
460
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
461
|
+
if (isNativeDisabledByEnv()) {
|
|
462
|
+
return fail('native disabled');
|
|
463
|
+
}
|
|
464
|
+
const fn = readNativeFunction(capability);
|
|
465
|
+
if (!fn) {
|
|
466
|
+
return fail();
|
|
467
|
+
}
|
|
468
|
+
const metadataJson = safeStringify(metadata ?? null);
|
|
469
|
+
if (!metadataJson) {
|
|
470
|
+
return fail('json stringify failed');
|
|
471
|
+
}
|
|
472
|
+
try {
|
|
473
|
+
const raw = fn(metadataJson);
|
|
474
|
+
if (typeof raw !== 'string' || !raw) {
|
|
475
|
+
return fail('empty result');
|
|
476
|
+
}
|
|
477
|
+
const parsed = parseHubPolicyOverride(raw);
|
|
478
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
479
|
+
}
|
|
480
|
+
catch (error) {
|
|
481
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
482
|
+
return fail(reason);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
export function resolveHubShadowCompareConfigWithNative(metadata) {
|
|
486
|
+
const capability = 'resolveHubShadowCompareConfigJson';
|
|
487
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
488
|
+
if (isNativeDisabledByEnv()) {
|
|
489
|
+
return fail('native disabled');
|
|
490
|
+
}
|
|
491
|
+
const fn = readNativeFunction(capability);
|
|
492
|
+
if (!fn) {
|
|
493
|
+
return fail();
|
|
494
|
+
}
|
|
495
|
+
const metadataJson = safeStringify(metadata ?? null);
|
|
496
|
+
if (!metadataJson) {
|
|
497
|
+
return fail('json stringify failed');
|
|
498
|
+
}
|
|
499
|
+
try {
|
|
500
|
+
const raw = fn(metadataJson);
|
|
501
|
+
if (typeof raw !== 'string' || !raw) {
|
|
502
|
+
return fail('empty result');
|
|
503
|
+
}
|
|
504
|
+
const parsed = parseHubShadowCompareConfig(raw);
|
|
505
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
506
|
+
}
|
|
507
|
+
catch (error) {
|
|
508
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
509
|
+
return fail(reason);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
export function resolveApplyPatchToolModeFromToolsWithNative(toolsRaw) {
|
|
513
|
+
const capability = 'resolveApplyPatchToolModeFromToolsJson';
|
|
514
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
515
|
+
if (isNativeDisabledByEnv()) {
|
|
516
|
+
return fail('native disabled');
|
|
517
|
+
}
|
|
518
|
+
const fn = readNativeFunction(capability);
|
|
519
|
+
if (!fn) {
|
|
520
|
+
return fail();
|
|
521
|
+
}
|
|
522
|
+
const toolsJson = safeStringify(toolsRaw ?? null);
|
|
523
|
+
if (!toolsJson) {
|
|
524
|
+
return fail('json stringify failed');
|
|
525
|
+
}
|
|
526
|
+
try {
|
|
527
|
+
const raw = fn(toolsJson);
|
|
528
|
+
if (typeof raw !== 'string' || !raw) {
|
|
529
|
+
return fail('empty result');
|
|
530
|
+
}
|
|
531
|
+
const parsed = parseApplyPatchToolMode(raw);
|
|
532
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
533
|
+
}
|
|
534
|
+
catch (error) {
|
|
535
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
536
|
+
return fail(reason);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
export function resolveHasInstructionRequestedPassthroughWithNative(messages) {
|
|
540
|
+
const capability = 'resolveHasInstructionRequestedPassthroughJson';
|
|
541
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
542
|
+
if (isNativeDisabledByEnv()) {
|
|
543
|
+
return fail('native disabled');
|
|
544
|
+
}
|
|
545
|
+
const fn = readNativeFunction(capability);
|
|
546
|
+
if (!fn) {
|
|
547
|
+
return fail();
|
|
548
|
+
}
|
|
549
|
+
const messagesJson = safeStringify(messages ?? null);
|
|
550
|
+
if (!messagesJson) {
|
|
551
|
+
return fail('json stringify failed');
|
|
552
|
+
}
|
|
553
|
+
try {
|
|
554
|
+
const raw = fn(messagesJson);
|
|
555
|
+
if (typeof raw !== 'string' || !raw) {
|
|
556
|
+
return fail('empty result');
|
|
557
|
+
}
|
|
558
|
+
const parsed = parseBoolean(raw);
|
|
559
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
560
|
+
}
|
|
561
|
+
catch (error) {
|
|
562
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
563
|
+
return fail(reason);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
export function resolveActiveProcessModeWithNative(baseMode, messages) {
|
|
567
|
+
const capability = 'resolveActiveProcessModeJson';
|
|
568
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
569
|
+
if (isNativeDisabledByEnv()) {
|
|
570
|
+
return fail('native disabled');
|
|
571
|
+
}
|
|
572
|
+
const fn = readNativeFunction(capability);
|
|
573
|
+
if (!fn) {
|
|
574
|
+
return fail();
|
|
575
|
+
}
|
|
576
|
+
const baseModeJson = safeStringify(baseMode);
|
|
577
|
+
const messagesJson = safeStringify(messages ?? null);
|
|
578
|
+
if (!baseModeJson || !messagesJson) {
|
|
579
|
+
return fail('json stringify failed');
|
|
580
|
+
}
|
|
581
|
+
try {
|
|
582
|
+
const raw = fn(baseModeJson, messagesJson);
|
|
583
|
+
if (typeof raw !== 'string' || !raw) {
|
|
584
|
+
return fail('empty result');
|
|
585
|
+
}
|
|
586
|
+
const parsed = parseString(raw);
|
|
587
|
+
if (parsed === 'chat' || parsed === 'passthrough') {
|
|
588
|
+
return parsed;
|
|
589
|
+
}
|
|
590
|
+
return fail('invalid payload');
|
|
591
|
+
}
|
|
592
|
+
catch (error) {
|
|
593
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
594
|
+
return fail(reason);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
export function findMappableSemanticsKeysWithNative(metadata) {
|
|
598
|
+
const capability = 'findMappableSemanticsKeysJson';
|
|
599
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
600
|
+
if (isNativeDisabledByEnv()) {
|
|
601
|
+
return fail('native disabled');
|
|
602
|
+
}
|
|
603
|
+
const fn = readNativeFunction(capability);
|
|
604
|
+
if (!fn) {
|
|
605
|
+
return fail();
|
|
606
|
+
}
|
|
607
|
+
const metadataJson = safeStringify(metadata ?? null);
|
|
608
|
+
if (!metadataJson) {
|
|
609
|
+
return fail('json stringify failed');
|
|
610
|
+
}
|
|
611
|
+
try {
|
|
612
|
+
const raw = fn(metadataJson);
|
|
613
|
+
if (typeof raw !== 'string' || !raw) {
|
|
614
|
+
return fail('empty result');
|
|
615
|
+
}
|
|
616
|
+
const parsed = parseStringArray(raw);
|
|
617
|
+
return parsed ?? fail('invalid payload');
|
|
618
|
+
}
|
|
619
|
+
catch (error) {
|
|
620
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
621
|
+
return fail(reason);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
export function buildPassthroughAuditWithNative(rawInbound, providerProtocol) {
|
|
625
|
+
const capability = 'buildPassthroughAuditJson';
|
|
626
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
627
|
+
if (isNativeDisabledByEnv()) {
|
|
628
|
+
return fail('native disabled');
|
|
629
|
+
}
|
|
630
|
+
const fn = readNativeFunction(capability);
|
|
631
|
+
if (!fn) {
|
|
632
|
+
return fail();
|
|
633
|
+
}
|
|
634
|
+
const inboundJson = safeStringify(rawInbound ?? {});
|
|
635
|
+
if (!inboundJson) {
|
|
636
|
+
return fail('json stringify failed');
|
|
637
|
+
}
|
|
638
|
+
try {
|
|
639
|
+
const raw = fn(inboundJson, String(providerProtocol || ''));
|
|
640
|
+
if (typeof raw !== 'string' || !raw) {
|
|
641
|
+
return fail('empty result');
|
|
642
|
+
}
|
|
643
|
+
const parsed = parseRecord(raw);
|
|
644
|
+
return parsed ?? fail('invalid payload');
|
|
645
|
+
}
|
|
646
|
+
catch (error) {
|
|
647
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
648
|
+
return fail(reason);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
export function annotatePassthroughGovernanceSkipWithNative(audit) {
|
|
652
|
+
const capability = 'annotatePassthroughGovernanceSkipJson';
|
|
653
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
654
|
+
if (isNativeDisabledByEnv()) {
|
|
655
|
+
return fail('native disabled');
|
|
656
|
+
}
|
|
657
|
+
const fn = readNativeFunction(capability);
|
|
658
|
+
if (!fn) {
|
|
659
|
+
return fail();
|
|
660
|
+
}
|
|
661
|
+
const auditJson = safeStringify(audit ?? {});
|
|
662
|
+
if (!auditJson) {
|
|
663
|
+
return fail('json stringify failed');
|
|
664
|
+
}
|
|
665
|
+
try {
|
|
666
|
+
const raw = fn(auditJson);
|
|
667
|
+
if (typeof raw !== 'string' || !raw) {
|
|
668
|
+
return fail('empty result');
|
|
669
|
+
}
|
|
670
|
+
const parsed = parseRecord(raw);
|
|
671
|
+
return parsed ?? fail('invalid payload');
|
|
672
|
+
}
|
|
673
|
+
catch (error) {
|
|
674
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
675
|
+
return fail(reason);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
export function attachPassthroughProviderInputAuditWithNative(audit, providerPayload, providerProtocol) {
|
|
679
|
+
const capability = 'attachPassthroughProviderInputAuditJson';
|
|
680
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
681
|
+
if (isNativeDisabledByEnv()) {
|
|
682
|
+
return fail('native disabled');
|
|
683
|
+
}
|
|
684
|
+
const fn = readNativeFunction(capability);
|
|
685
|
+
if (!fn) {
|
|
686
|
+
return fail();
|
|
687
|
+
}
|
|
688
|
+
const auditJson = safeStringify(audit ?? {});
|
|
689
|
+
const payloadJson = safeStringify(providerPayload ?? {});
|
|
690
|
+
if (!auditJson || !payloadJson) {
|
|
691
|
+
return fail('json stringify failed');
|
|
692
|
+
}
|
|
693
|
+
try {
|
|
694
|
+
const raw = fn(auditJson, payloadJson, String(providerProtocol || ''));
|
|
695
|
+
if (typeof raw !== 'string' || !raw) {
|
|
696
|
+
return fail('empty result');
|
|
697
|
+
}
|
|
698
|
+
const parsed = parseRecord(raw);
|
|
699
|
+
return parsed ?? fail('invalid payload');
|
|
700
|
+
}
|
|
701
|
+
catch (error) {
|
|
702
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
703
|
+
return fail(reason);
|
|
704
|
+
}
|
|
705
|
+
}
|