@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-chat-process-governance-semantics.js
ADDED
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
import { failNativeRequired, isNativeDisabledByEnv } from './native-router-hotpath-policy.js';
|
|
2
|
+
import { loadNativeRouterHotpathBindingForInternalUse } from './native-router-hotpath.js';
|
|
3
|
+
function parseAliasMapPayload(raw) {
|
|
4
|
+
try {
|
|
5
|
+
const parsed = JSON.parse(raw);
|
|
6
|
+
if (parsed === null) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const out = {};
|
|
13
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
14
|
+
if (!key || typeof value !== 'string') {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
out[key] = value;
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function parseGovernanceContextPayload(raw) {
|
|
26
|
+
try {
|
|
27
|
+
const parsed = JSON.parse(raw);
|
|
28
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const row = parsed;
|
|
32
|
+
const entryEndpoint = typeof row.entryEndpoint === 'string' ? row.entryEndpoint : '';
|
|
33
|
+
const providerProtocol = typeof row.providerProtocol === 'string' ? row.providerProtocol : '';
|
|
34
|
+
const inboundStreamIntent = row.inboundStreamIntent === true;
|
|
35
|
+
const metadata = row.metadata && typeof row.metadata === 'object' && !Array.isArray(row.metadata)
|
|
36
|
+
? row.metadata
|
|
37
|
+
: null;
|
|
38
|
+
if (!entryEndpoint || !providerProtocol || !metadata) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const rawRequestBody = row.rawRequestBody && typeof row.rawRequestBody === 'object' && !Array.isArray(row.rawRequestBody)
|
|
42
|
+
? row.rawRequestBody
|
|
43
|
+
: undefined;
|
|
44
|
+
return {
|
|
45
|
+
entryEndpoint,
|
|
46
|
+
metadata,
|
|
47
|
+
providerProtocol,
|
|
48
|
+
metadataToolHints: row.metadataToolHints === null ? undefined : row.metadataToolHints,
|
|
49
|
+
inboundStreamIntent,
|
|
50
|
+
...(rawRequestBody ? { rawRequestBody } : {})
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function parseCastToolsPayload(raw) {
|
|
58
|
+
try {
|
|
59
|
+
const parsed = JSON.parse(raw);
|
|
60
|
+
if (parsed === null) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
if (!Array.isArray(parsed)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return parsed;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function parseWebSearchOperationsPayload(raw) {
|
|
73
|
+
try {
|
|
74
|
+
const parsed = JSON.parse(raw);
|
|
75
|
+
if (!Array.isArray(parsed)) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return parsed;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function parseRecord(raw) {
|
|
85
|
+
try {
|
|
86
|
+
const parsed = JSON.parse(raw);
|
|
87
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return parsed;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function parseRespProcessToolGovernancePayload(raw) {
|
|
97
|
+
try {
|
|
98
|
+
const parsed = JSON.parse(raw);
|
|
99
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const row = parsed;
|
|
103
|
+
const governedPayloadRaw = row.governed_payload && typeof row.governed_payload === 'object' && !Array.isArray(row.governed_payload)
|
|
104
|
+
? row.governed_payload
|
|
105
|
+
: row.governedPayload && typeof row.governedPayload === 'object' && !Array.isArray(row.governedPayload)
|
|
106
|
+
? row.governedPayload
|
|
107
|
+
: null;
|
|
108
|
+
const summaryRaw = row.summary && typeof row.summary === 'object' && !Array.isArray(row.summary)
|
|
109
|
+
? row.summary
|
|
110
|
+
: null;
|
|
111
|
+
if (!governedPayloadRaw || !summaryRaw) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const applied = summaryRaw.applied === true;
|
|
115
|
+
const toolCallsNormalizedRaw = typeof summaryRaw.tool_calls_normalized === 'number'
|
|
116
|
+
? summaryRaw.tool_calls_normalized
|
|
117
|
+
: typeof summaryRaw.toolCallsNormalized === 'number'
|
|
118
|
+
? summaryRaw.toolCallsNormalized
|
|
119
|
+
: NaN;
|
|
120
|
+
const applyPatchRepairedRaw = typeof summaryRaw.apply_patch_repaired === 'number'
|
|
121
|
+
? summaryRaw.apply_patch_repaired
|
|
122
|
+
: typeof summaryRaw.applyPatchRepaired === 'number'
|
|
123
|
+
? summaryRaw.applyPatchRepaired
|
|
124
|
+
: NaN;
|
|
125
|
+
if (!Number.isFinite(toolCallsNormalizedRaw) || !Number.isFinite(applyPatchRepairedRaw)) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
governedPayload: governedPayloadRaw,
|
|
130
|
+
summary: {
|
|
131
|
+
applied,
|
|
132
|
+
toolCallsNormalized: Math.floor(toolCallsNormalizedRaw),
|
|
133
|
+
applyPatchRepaired: Math.floor(applyPatchRepairedRaw)
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function parseRespProcessFinalizePayload(raw) {
|
|
142
|
+
try {
|
|
143
|
+
const parsed = JSON.parse(raw);
|
|
144
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const row = parsed;
|
|
148
|
+
const finalizedPayloadRaw = row.finalized_payload && typeof row.finalized_payload === 'object' && !Array.isArray(row.finalized_payload)
|
|
149
|
+
? row.finalized_payload
|
|
150
|
+
: row.finalizedPayload && typeof row.finalizedPayload === 'object' && !Array.isArray(row.finalizedPayload)
|
|
151
|
+
? row.finalizedPayload
|
|
152
|
+
: null;
|
|
153
|
+
return finalizedPayloadRaw;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function readNativeFunction(name) {
|
|
160
|
+
const binding = loadNativeRouterHotpathBindingForInternalUse();
|
|
161
|
+
const fn = binding?.[name];
|
|
162
|
+
return typeof fn === 'function' ? fn : null;
|
|
163
|
+
}
|
|
164
|
+
function safeStringify(value) {
|
|
165
|
+
try {
|
|
166
|
+
return JSON.stringify(value);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
export function buildAnthropicToolAliasMapWithNative(sourceTools) {
|
|
173
|
+
const capability = 'buildAnthropicToolAliasMapJson';
|
|
174
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
175
|
+
if (isNativeDisabledByEnv()) {
|
|
176
|
+
return fail('native disabled');
|
|
177
|
+
}
|
|
178
|
+
const fn = readNativeFunction('buildAnthropicToolAliasMapJson');
|
|
179
|
+
if (!fn) {
|
|
180
|
+
return fail();
|
|
181
|
+
}
|
|
182
|
+
const sourceToolsJson = safeStringify(sourceTools ?? null);
|
|
183
|
+
if (!sourceToolsJson) {
|
|
184
|
+
return fail('json stringify failed');
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const raw = fn(sourceToolsJson);
|
|
188
|
+
if (typeof raw !== 'string' || !raw) {
|
|
189
|
+
return fail('empty result');
|
|
190
|
+
}
|
|
191
|
+
const parsed = parseAliasMapPayload(raw);
|
|
192
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
196
|
+
return fail(reason);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
export function resolveGovernanceContextWithNative(request, context) {
|
|
200
|
+
const capability = 'resolveGovernanceContextJson';
|
|
201
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
202
|
+
if (isNativeDisabledByEnv()) {
|
|
203
|
+
return fail('native disabled');
|
|
204
|
+
}
|
|
205
|
+
const fn = readNativeFunction('resolveGovernanceContextJson');
|
|
206
|
+
if (!fn) {
|
|
207
|
+
return fail();
|
|
208
|
+
}
|
|
209
|
+
const requestJson = safeStringify(request ?? null);
|
|
210
|
+
const contextJson = safeStringify(context ?? null);
|
|
211
|
+
if (!requestJson || !contextJson) {
|
|
212
|
+
return fail('json stringify failed');
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
const raw = fn(requestJson, contextJson);
|
|
216
|
+
if (typeof raw !== 'string' || !raw) {
|
|
217
|
+
return fail('empty result');
|
|
218
|
+
}
|
|
219
|
+
const parsed = parseGovernanceContextPayload(raw);
|
|
220
|
+
return parsed ?? fail('invalid payload');
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
224
|
+
return fail(reason);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
export function castGovernedToolsWithNative(tools) {
|
|
228
|
+
const capability = 'castGovernedToolsJson';
|
|
229
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
230
|
+
if (isNativeDisabledByEnv()) {
|
|
231
|
+
return fail('native disabled');
|
|
232
|
+
}
|
|
233
|
+
const fn = readNativeFunction('castGovernedToolsJson');
|
|
234
|
+
if (!fn) {
|
|
235
|
+
return fail();
|
|
236
|
+
}
|
|
237
|
+
const toolsJson = safeStringify(tools ?? null);
|
|
238
|
+
if (!toolsJson) {
|
|
239
|
+
return fail('json stringify failed');
|
|
240
|
+
}
|
|
241
|
+
try {
|
|
242
|
+
const raw = fn(toolsJson);
|
|
243
|
+
if (typeof raw !== 'string' || !raw) {
|
|
244
|
+
return fail('empty result');
|
|
245
|
+
}
|
|
246
|
+
const parsed = parseCastToolsPayload(raw);
|
|
247
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
251
|
+
return fail(reason);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
export function buildWebSearchToolAppendOperationsWithNative(engines) {
|
|
255
|
+
const capability = 'buildWebSearchToolAppendOperationsJson';
|
|
256
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
257
|
+
if (isNativeDisabledByEnv()) {
|
|
258
|
+
return fail('native disabled');
|
|
259
|
+
}
|
|
260
|
+
const fn = readNativeFunction('buildWebSearchToolAppendOperationsJson');
|
|
261
|
+
if (!fn) {
|
|
262
|
+
return fail();
|
|
263
|
+
}
|
|
264
|
+
const enginesJson = safeStringify(engines ?? null);
|
|
265
|
+
if (!enginesJson) {
|
|
266
|
+
return fail('json stringify failed');
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
const raw = fn(enginesJson);
|
|
270
|
+
if (typeof raw !== 'string' || !raw) {
|
|
271
|
+
return fail('empty result');
|
|
272
|
+
}
|
|
273
|
+
const parsed = parseWebSearchOperationsPayload(raw);
|
|
274
|
+
return parsed ?? fail('invalid payload');
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
278
|
+
return fail(reason);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
export function applyGovernedControlOperationsWithNative(request, governed, inboundStreamIntent) {
|
|
282
|
+
const capability = 'applyGovernedControlOperationsJson';
|
|
283
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
284
|
+
if (isNativeDisabledByEnv()) {
|
|
285
|
+
return fail('native disabled');
|
|
286
|
+
}
|
|
287
|
+
const fn = readNativeFunction('applyGovernedControlOperationsJson');
|
|
288
|
+
if (!fn) {
|
|
289
|
+
return fail();
|
|
290
|
+
}
|
|
291
|
+
const requestJson = safeStringify(request);
|
|
292
|
+
const governedJson = safeStringify(governed);
|
|
293
|
+
if (!requestJson || !governedJson) {
|
|
294
|
+
return fail('json stringify failed');
|
|
295
|
+
}
|
|
296
|
+
try {
|
|
297
|
+
const raw = fn(requestJson, governedJson, inboundStreamIntent === true);
|
|
298
|
+
if (typeof raw !== 'string' || !raw) {
|
|
299
|
+
return fail('empty result');
|
|
300
|
+
}
|
|
301
|
+
const parsed = parseRecord(raw);
|
|
302
|
+
return parsed ?? fail('invalid payload');
|
|
303
|
+
}
|
|
304
|
+
catch (error) {
|
|
305
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
306
|
+
return fail(reason);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
export function applyGovernedMergeRequestWithNative(request, governed, inboundStreamIntent, governanceTimestampMs) {
|
|
310
|
+
const capability = 'applyGovernedMergeRequestJson';
|
|
311
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
312
|
+
if (isNativeDisabledByEnv()) {
|
|
313
|
+
return fail('native disabled');
|
|
314
|
+
}
|
|
315
|
+
const fn = readNativeFunction('applyGovernedMergeRequestJson');
|
|
316
|
+
if (!fn) {
|
|
317
|
+
return fail();
|
|
318
|
+
}
|
|
319
|
+
const requestJson = safeStringify(request);
|
|
320
|
+
const governedJson = safeStringify(governed);
|
|
321
|
+
if (!requestJson || !governedJson) {
|
|
322
|
+
return fail('json stringify failed');
|
|
323
|
+
}
|
|
324
|
+
try {
|
|
325
|
+
const raw = fn(requestJson, governedJson, inboundStreamIntent === true, Number.isFinite(governanceTimestampMs) ? governanceTimestampMs : Date.now());
|
|
326
|
+
if (typeof raw !== 'string' || !raw) {
|
|
327
|
+
return fail('empty result');
|
|
328
|
+
}
|
|
329
|
+
const parsed = parseRecord(raw);
|
|
330
|
+
return parsed ?? fail('invalid payload');
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
334
|
+
return fail(reason);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
export function mergeGovernanceSummaryIntoMetadataWithNative(metadata, summary) {
|
|
338
|
+
const capability = 'mergeGovernanceSummaryIntoMetadataJson';
|
|
339
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
340
|
+
if (isNativeDisabledByEnv()) {
|
|
341
|
+
return fail('native disabled');
|
|
342
|
+
}
|
|
343
|
+
const fn = readNativeFunction('mergeGovernanceSummaryIntoMetadataJson');
|
|
344
|
+
if (!fn) {
|
|
345
|
+
return fail();
|
|
346
|
+
}
|
|
347
|
+
const metadataJson = safeStringify(metadata ?? {});
|
|
348
|
+
const summaryJson = safeStringify(summary ?? {});
|
|
349
|
+
if (!metadataJson || !summaryJson) {
|
|
350
|
+
return fail('json stringify failed');
|
|
351
|
+
}
|
|
352
|
+
try {
|
|
353
|
+
const raw = fn(metadataJson, summaryJson);
|
|
354
|
+
if (typeof raw !== 'string' || !raw) {
|
|
355
|
+
return fail('empty result');
|
|
356
|
+
}
|
|
357
|
+
const parsed = parseRecord(raw);
|
|
358
|
+
return parsed ?? fail('invalid payload');
|
|
359
|
+
}
|
|
360
|
+
catch (error) {
|
|
361
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
362
|
+
return fail(reason);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
export function finalizeGovernedRequestWithNative(request, summary) {
|
|
366
|
+
const capability = 'finalizeGovernedRequestJson';
|
|
367
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
368
|
+
if (isNativeDisabledByEnv()) {
|
|
369
|
+
return fail('native disabled');
|
|
370
|
+
}
|
|
371
|
+
const fn = readNativeFunction('finalizeGovernedRequestJson');
|
|
372
|
+
if (!fn) {
|
|
373
|
+
return fail();
|
|
374
|
+
}
|
|
375
|
+
const requestJson = safeStringify(request ?? {});
|
|
376
|
+
const summaryJson = safeStringify(summary ?? {});
|
|
377
|
+
if (!requestJson || !summaryJson) {
|
|
378
|
+
return fail('json stringify failed');
|
|
379
|
+
}
|
|
380
|
+
try {
|
|
381
|
+
const raw = fn(requestJson, summaryJson);
|
|
382
|
+
if (typeof raw !== 'string' || !raw) {
|
|
383
|
+
return fail('empty result');
|
|
384
|
+
}
|
|
385
|
+
const parsed = parseRecord(raw);
|
|
386
|
+
return parsed ?? fail('invalid payload');
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
390
|
+
return fail(reason);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
export function applyRespProcessToolGovernanceWithNative(input) {
|
|
394
|
+
const capability = 'governResponseJson';
|
|
395
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
396
|
+
if (isNativeDisabledByEnv()) {
|
|
397
|
+
return fail('native disabled');
|
|
398
|
+
}
|
|
399
|
+
const fn = readNativeFunction('governResponseJson');
|
|
400
|
+
if (!fn) {
|
|
401
|
+
return fail();
|
|
402
|
+
}
|
|
403
|
+
const inputJson = safeStringify({
|
|
404
|
+
payload: input.payload,
|
|
405
|
+
client_protocol: input.clientProtocol,
|
|
406
|
+
entry_endpoint: input.entryEndpoint,
|
|
407
|
+
request_id: input.requestId
|
|
408
|
+
});
|
|
409
|
+
if (!inputJson) {
|
|
410
|
+
return fail('json stringify failed');
|
|
411
|
+
}
|
|
412
|
+
try {
|
|
413
|
+
const raw = fn(inputJson);
|
|
414
|
+
if (typeof raw !== 'string' || !raw) {
|
|
415
|
+
return fail('empty result');
|
|
416
|
+
}
|
|
417
|
+
const parsed = parseRespProcessToolGovernancePayload(raw);
|
|
418
|
+
return parsed ?? fail('invalid payload');
|
|
419
|
+
}
|
|
420
|
+
catch (error) {
|
|
421
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
422
|
+
return fail(reason);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
export function stripOrphanFunctionCallsTagWithNative(payload) {
|
|
426
|
+
const capability = 'stripOrphanFunctionCallsTagJson';
|
|
427
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
428
|
+
if (isNativeDisabledByEnv()) {
|
|
429
|
+
return fail('native disabled');
|
|
430
|
+
}
|
|
431
|
+
const fn = readNativeFunction(capability);
|
|
432
|
+
if (!fn) {
|
|
433
|
+
return fail();
|
|
434
|
+
}
|
|
435
|
+
const payloadJson = safeStringify(payload);
|
|
436
|
+
if (!payloadJson) {
|
|
437
|
+
return fail('json stringify failed');
|
|
438
|
+
}
|
|
439
|
+
try {
|
|
440
|
+
const raw = fn(payloadJson);
|
|
441
|
+
if (typeof raw !== 'string' || !raw) {
|
|
442
|
+
return fail('empty result');
|
|
443
|
+
}
|
|
444
|
+
const parsed = parseRecord(raw);
|
|
445
|
+
return parsed ?? fail('invalid payload');
|
|
446
|
+
}
|
|
447
|
+
catch (error) {
|
|
448
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
449
|
+
return fail(reason);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
export async function finalizeRespProcessChatResponseWithNative(input) {
|
|
453
|
+
const capability = 'finalizeChatResponseJson';
|
|
454
|
+
const fail = async (reason) => failNativeRequired(capability, reason);
|
|
455
|
+
if (isNativeDisabledByEnv()) {
|
|
456
|
+
return fail('native disabled');
|
|
457
|
+
}
|
|
458
|
+
const fn = readNativeFunction('finalizeChatResponseJson');
|
|
459
|
+
if (!fn) {
|
|
460
|
+
return fail();
|
|
461
|
+
}
|
|
462
|
+
const inputJson = safeStringify({
|
|
463
|
+
payload: input.payload,
|
|
464
|
+
stream: input.stream === true,
|
|
465
|
+
reasoningMode: input.reasoningMode,
|
|
466
|
+
endpoint: input.endpoint,
|
|
467
|
+
requestId: input.requestId
|
|
468
|
+
});
|
|
469
|
+
if (!inputJson) {
|
|
470
|
+
return fail('json stringify failed');
|
|
471
|
+
}
|
|
472
|
+
try {
|
|
473
|
+
const raw = fn(inputJson);
|
|
474
|
+
if (typeof raw !== 'string' || !raw) {
|
|
475
|
+
return fail('empty result');
|
|
476
|
+
}
|
|
477
|
+
const parsed = parseRespProcessFinalizePayload(raw);
|
|
478
|
+
return parsed ?? fail('invalid payload');
|
|
479
|
+
}
|
|
480
|
+
catch (error) {
|
|
481
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
482
|
+
return fail(reason);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type NativeGovernedFilterPayload = {
|
|
2
|
+
model?: unknown;
|
|
3
|
+
messages: unknown[];
|
|
4
|
+
tools?: unknown;
|
|
5
|
+
tool_choice?: unknown;
|
|
6
|
+
stream: boolean;
|
|
7
|
+
parameters: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
export declare function buildGovernedFilterPayloadWithNative(request: unknown): NativeGovernedFilterPayload;
|
package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { failNativeRequired, isNativeDisabledByEnv } from './native-router-hotpath-policy.js';
|
|
2
|
+
import { loadNativeRouterHotpathBindingForInternalUse } from './native-router-hotpath.js';
|
|
3
|
+
function parsePayload(raw) {
|
|
4
|
+
try {
|
|
5
|
+
const parsed = JSON.parse(raw);
|
|
6
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const row = parsed;
|
|
10
|
+
const messages = Array.isArray(row.messages) ? row.messages : null;
|
|
11
|
+
const parameters = row.parameters && typeof row.parameters === 'object' && !Array.isArray(row.parameters)
|
|
12
|
+
? row.parameters
|
|
13
|
+
: null;
|
|
14
|
+
if (!messages || !parameters || typeof row.stream !== 'boolean') {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
model: row.model,
|
|
19
|
+
messages,
|
|
20
|
+
...(row.tools !== undefined ? { tools: row.tools } : {}),
|
|
21
|
+
...(row.tool_choice !== undefined ? { tool_choice: row.tool_choice } : {}),
|
|
22
|
+
stream: row.stream,
|
|
23
|
+
parameters
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function buildGovernedFilterPayloadWithNative(request) {
|
|
31
|
+
const capability = 'buildGovernedFilterPayloadJson';
|
|
32
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
33
|
+
if (isNativeDisabledByEnv()) {
|
|
34
|
+
return fail('native disabled');
|
|
35
|
+
}
|
|
36
|
+
const binding = loadNativeRouterHotpathBindingForInternalUse();
|
|
37
|
+
const fn = binding?.buildGovernedFilterPayloadJson;
|
|
38
|
+
if (typeof fn !== 'function') {
|
|
39
|
+
return fail();
|
|
40
|
+
}
|
|
41
|
+
const requestJson = (() => {
|
|
42
|
+
try {
|
|
43
|
+
return JSON.stringify(request ?? null);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
49
|
+
if (!requestJson) {
|
|
50
|
+
return fail('json stringify failed');
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const raw = fn(requestJson);
|
|
54
|
+
if (typeof raw !== 'string' || !raw) {
|
|
55
|
+
return fail('empty result');
|
|
56
|
+
}
|
|
57
|
+
const parsed = parsePayload(raw);
|
|
58
|
+
return parsed ?? fail('invalid payload');
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
62
|
+
return fail(reason);
|
|
63
|
+
}
|
|
64
|
+
}
|
package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function buildChatProcessContextMetadataWithNative(metadata: unknown): Record<string, unknown> | undefined;
|
|
2
|
+
export declare function applyChatProcessedRequestWithNative(request: Record<string, unknown>, timestampMs: number): Record<string, unknown>;
|
|
3
|
+
export declare function buildChatProcessedDescriptorWithNative(timestampMs: number, streamingEnabled: boolean): Record<string, unknown>;
|
|
4
|
+
export declare function buildChatNodeResultMetadataWithNative(startTimeMs: number, endTimeMs: number, messagesCount: number, toolsCount: number, includeDataProcessed: boolean): Record<string, unknown>;
|
|
5
|
+
export declare function buildProcessedRequestFromChatResponseWithNative(chatResponse: Record<string, unknown>, streamEnabled: boolean): Record<string, unknown>;
|