@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-node-result-semantics.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { failNativeRequired, isNativeDisabledByEnv } from './native-router-hotpath-policy.js';
|
|
2
|
+
import { loadNativeRouterHotpathBindingForInternalUse } from './native-router-hotpath.js';
|
|
3
|
+
function parseJson(raw) {
|
|
4
|
+
return JSON.parse(raw);
|
|
5
|
+
}
|
|
6
|
+
function readNativeFunction(name) {
|
|
7
|
+
const binding = loadNativeRouterHotpathBindingForInternalUse();
|
|
8
|
+
const fn = binding?.[name];
|
|
9
|
+
return typeof fn === 'function' ? fn : null;
|
|
10
|
+
}
|
|
11
|
+
function safeStringify(value) {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.stringify(value);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function buildChatProcessContextMetadataWithNative(metadata) {
|
|
20
|
+
const capability = 'buildChatProcessContextMetadataJson';
|
|
21
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
22
|
+
if (isNativeDisabledByEnv()) {
|
|
23
|
+
return fail('native disabled');
|
|
24
|
+
}
|
|
25
|
+
const fn = readNativeFunction('buildChatProcessContextMetadataJson');
|
|
26
|
+
if (!fn) {
|
|
27
|
+
return fail();
|
|
28
|
+
}
|
|
29
|
+
const metadataJson = safeStringify(metadata ?? null);
|
|
30
|
+
if (!metadataJson) {
|
|
31
|
+
return fail('json stringify failed');
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const raw = fn(metadataJson);
|
|
35
|
+
if (typeof raw !== 'string' || !raw) {
|
|
36
|
+
return fail('empty result');
|
|
37
|
+
}
|
|
38
|
+
const parsed = parseJson(raw);
|
|
39
|
+
if (parsed === null) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
43
|
+
return fail('invalid payload');
|
|
44
|
+
}
|
|
45
|
+
return parsed;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
49
|
+
return fail(reason);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function applyChatProcessedRequestWithNative(request, timestampMs) {
|
|
53
|
+
const capability = 'applyChatProcessedRequestJson';
|
|
54
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
55
|
+
if (isNativeDisabledByEnv()) {
|
|
56
|
+
return fail('native disabled');
|
|
57
|
+
}
|
|
58
|
+
const fn = readNativeFunction('applyChatProcessedRequestJson');
|
|
59
|
+
if (!fn) {
|
|
60
|
+
return fail();
|
|
61
|
+
}
|
|
62
|
+
const requestJson = safeStringify(request);
|
|
63
|
+
if (!requestJson) {
|
|
64
|
+
return fail('json stringify failed');
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const raw = fn(requestJson, Number.isFinite(timestampMs) ? timestampMs : Date.now());
|
|
68
|
+
if (typeof raw !== 'string' || !raw) {
|
|
69
|
+
return fail('empty result');
|
|
70
|
+
}
|
|
71
|
+
const parsed = parseJson(raw);
|
|
72
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
73
|
+
return fail('invalid payload');
|
|
74
|
+
}
|
|
75
|
+
return parsed;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
79
|
+
return fail(reason);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export function buildChatProcessedDescriptorWithNative(timestampMs, streamingEnabled) {
|
|
83
|
+
const capability = 'buildChatProcessedDescriptorJson';
|
|
84
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
85
|
+
if (isNativeDisabledByEnv()) {
|
|
86
|
+
return fail('native disabled');
|
|
87
|
+
}
|
|
88
|
+
const fn = readNativeFunction('buildChatProcessedDescriptorJson');
|
|
89
|
+
if (!fn) {
|
|
90
|
+
return fail();
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const raw = fn(Number.isFinite(timestampMs) ? timestampMs : Date.now(), streamingEnabled === true);
|
|
94
|
+
if (typeof raw !== 'string' || !raw) {
|
|
95
|
+
return fail('empty result');
|
|
96
|
+
}
|
|
97
|
+
const parsed = parseJson(raw);
|
|
98
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
99
|
+
return fail('invalid payload');
|
|
100
|
+
}
|
|
101
|
+
return parsed;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
105
|
+
return fail(reason);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export function buildChatNodeResultMetadataWithNative(startTimeMs, endTimeMs, messagesCount, toolsCount, includeDataProcessed) {
|
|
109
|
+
const capability = 'buildChatNodeResultMetadataJson';
|
|
110
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
111
|
+
if (isNativeDisabledByEnv()) {
|
|
112
|
+
return fail('native disabled');
|
|
113
|
+
}
|
|
114
|
+
const fn = readNativeFunction('buildChatNodeResultMetadataJson');
|
|
115
|
+
if (!fn) {
|
|
116
|
+
return fail();
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
const raw = fn(Number.isFinite(startTimeMs) ? startTimeMs : 0, Number.isFinite(endTimeMs) ? endTimeMs : Date.now(), Math.floor(Number.isFinite(messagesCount) ? messagesCount : 0), Math.floor(Number.isFinite(toolsCount) ? toolsCount : 0), includeDataProcessed === true);
|
|
120
|
+
if (typeof raw !== 'string' || !raw) {
|
|
121
|
+
return fail('empty result');
|
|
122
|
+
}
|
|
123
|
+
const parsed = parseJson(raw);
|
|
124
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
125
|
+
return fail('invalid payload');
|
|
126
|
+
}
|
|
127
|
+
return parsed;
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
131
|
+
return fail(reason);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export function buildProcessedRequestFromChatResponseWithNative(chatResponse, streamEnabled) {
|
|
135
|
+
const capability = 'buildProcessedRequestFromChatResponseJson';
|
|
136
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
137
|
+
if (isNativeDisabledByEnv()) {
|
|
138
|
+
return fail('native disabled');
|
|
139
|
+
}
|
|
140
|
+
const fn = readNativeFunction(capability);
|
|
141
|
+
if (!fn) {
|
|
142
|
+
return fail();
|
|
143
|
+
}
|
|
144
|
+
const payloadJson = safeStringify(chatResponse);
|
|
145
|
+
if (!payloadJson) {
|
|
146
|
+
return fail('json stringify failed');
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const raw = fn(payloadJson, streamEnabled === true);
|
|
150
|
+
if (typeof raw !== 'string' || !raw) {
|
|
151
|
+
return fail('empty result');
|
|
152
|
+
}
|
|
153
|
+
const parsed = parseJson(raw);
|
|
154
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
155
|
+
return fail('invalid payload');
|
|
156
|
+
}
|
|
157
|
+
return parsed;
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
161
|
+
return fail(reason);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildImageAttachmentMetadataWithNative(metadata: Record<string, unknown> | undefined, originalEndpoint: string): Record<string, unknown>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { failNativeRequired, isNativeDisabledByEnv } from './native-router-hotpath-policy.js';
|
|
2
|
+
import { loadNativeRouterHotpathBindingForInternalUse } from './native-router-hotpath.js';
|
|
3
|
+
function parseRecord(raw) {
|
|
4
|
+
try {
|
|
5
|
+
const parsed = JSON.parse(raw);
|
|
6
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return parsed;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function buildImageAttachmentMetadataWithNative(metadata, originalEndpoint) {
|
|
16
|
+
const capability = 'buildImageAttachmentMetadataJson';
|
|
17
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
18
|
+
if (isNativeDisabledByEnv()) {
|
|
19
|
+
return fail('native disabled');
|
|
20
|
+
}
|
|
21
|
+
const binding = loadNativeRouterHotpathBindingForInternalUse();
|
|
22
|
+
const fn = binding?.buildImageAttachmentMetadataJson;
|
|
23
|
+
if (typeof fn !== 'function') {
|
|
24
|
+
return fail();
|
|
25
|
+
}
|
|
26
|
+
const metadataJson = (() => {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.stringify(metadata ?? null);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
})();
|
|
34
|
+
if (!metadataJson) {
|
|
35
|
+
return fail('json stringify failed');
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const raw = fn(metadataJson, String(originalEndpoint || ''));
|
|
39
|
+
if (typeof raw !== 'string' || !raw) {
|
|
40
|
+
return fail('empty result');
|
|
41
|
+
}
|
|
42
|
+
const parsed = parseRecord(raw);
|
|
43
|
+
return parsed ?? fail('invalid payload');
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
47
|
+
return fail(reason);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type NativeChatWebSearchPlan = {
|
|
2
|
+
shouldInject: boolean;
|
|
3
|
+
selectedEngineIndexes: number[];
|
|
4
|
+
};
|
|
5
|
+
export type NativeChatClockPlan = {
|
|
6
|
+
shouldInject: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type NativeContinueExecutionPlan = {
|
|
9
|
+
shouldInject: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type NativeContinueDirectiveInjection = {
|
|
12
|
+
changed: boolean;
|
|
13
|
+
messages: unknown[];
|
|
14
|
+
};
|
|
15
|
+
export type NativeChatServerToolBundlePlan = {
|
|
16
|
+
webSearch: NativeChatWebSearchPlan;
|
|
17
|
+
clock: NativeChatClockPlan;
|
|
18
|
+
continueExecution: NativeContinueExecutionPlan;
|
|
19
|
+
};
|
|
20
|
+
export declare function detectProviderResponseShapeWithNative(payload: unknown): 'openai-chat' | 'openai-responses' | 'anthropic-messages' | 'gemini-chat' | 'unknown';
|
|
21
|
+
export declare function isStopMessageStateActiveWithNative(raw: unknown): boolean;
|
|
22
|
+
export declare function resolveStopMessageSessionScopeWithNative(metadata: Record<string, unknown>): string | undefined;
|
|
23
|
+
export declare function resolveHasActiveStopMessageForContinueExecutionWithNative(runtimeState: unknown, persistedState: unknown): boolean;
|
|
24
|
+
export declare function buildReviewOperationsWithNative(metadata: Record<string, unknown>): Record<string, unknown>[];
|
|
25
|
+
export declare function buildContinueExecutionOperationsWithNative(shouldInject: boolean): Record<string, unknown>[];
|
|
26
|
+
export declare function planChatWebSearchOperationsWithNative(request: unknown, runtimeMetadata: Record<string, unknown>): NativeChatWebSearchPlan;
|
|
27
|
+
export declare function planChatClockOperationsWithNative(runtimeMetadata: Record<string, unknown>): NativeChatClockPlan;
|
|
28
|
+
export declare function planContinueExecutionOperationsWithNative(runtimeMetadata: Record<string, unknown>, hasActiveStopMessage: boolean): NativeContinueExecutionPlan;
|
|
29
|
+
export declare function tryPlanChatServerToolBundleWithNative(request: unknown, runtimeMetadata: Record<string, unknown>, hasActiveStopMessage: boolean): NativeChatServerToolBundlePlan | null;
|
|
30
|
+
export declare function injectContinueExecutionDirectiveWithNative(messages: unknown[], marker: string, targetText: string): NativeContinueDirectiveInjection;
|
|
@@ -0,0 +1,446 @@
|
|
|
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 parseWebSearchPlan(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
|
+
if (typeof row.shouldInject !== 'boolean' || !Array.isArray(row.selectedEngineIndexes)) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const selectedEngineIndexes = row.selectedEngineIndexes
|
|
27
|
+
.map((entry) => (typeof entry === 'number' && Number.isFinite(entry) ? Math.floor(entry) : null))
|
|
28
|
+
.filter((entry) => entry !== null && entry >= 0);
|
|
29
|
+
return {
|
|
30
|
+
shouldInject: row.shouldInject,
|
|
31
|
+
selectedEngineIndexes
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function parseClockPlan(raw) {
|
|
39
|
+
try {
|
|
40
|
+
const parsed = JSON.parse(raw);
|
|
41
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const row = parsed;
|
|
45
|
+
if (typeof row.shouldInject !== 'boolean') {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return { shouldInject: row.shouldInject };
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function parseContinueExecutionPlan(raw) {
|
|
55
|
+
return parseClockPlan(raw);
|
|
56
|
+
}
|
|
57
|
+
function parseContinueDirectiveInjection(raw) {
|
|
58
|
+
try {
|
|
59
|
+
const parsed = JSON.parse(raw);
|
|
60
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const row = parsed;
|
|
64
|
+
if (typeof row.changed !== 'boolean' || !Array.isArray(row.messages)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
changed: row.changed,
|
|
69
|
+
messages: row.messages
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function parseServerToolBundlePlan(raw) {
|
|
77
|
+
try {
|
|
78
|
+
const parsed = JSON.parse(raw);
|
|
79
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const row = parsed;
|
|
83
|
+
const webSearchRaw = typeof row.webSearch === 'object' ? JSON.stringify(row.webSearch) : '';
|
|
84
|
+
const clockRaw = typeof row.clock === 'object' ? JSON.stringify(row.clock) : '';
|
|
85
|
+
const continueRaw = typeof row.continueExecution === 'object' ? JSON.stringify(row.continueExecution) : '';
|
|
86
|
+
const webSearch = webSearchRaw ? parseWebSearchPlan(webSearchRaw) : null;
|
|
87
|
+
const clock = clockRaw ? parseClockPlan(clockRaw) : null;
|
|
88
|
+
const continueExecution = continueRaw ? parseContinueExecutionPlan(continueRaw) : null;
|
|
89
|
+
if (!webSearch || !clock || !continueExecution) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return { webSearch, clock, continueExecution };
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function parseProviderResponseShape(raw) {
|
|
99
|
+
try {
|
|
100
|
+
const parsed = JSON.parse(raw);
|
|
101
|
+
if (typeof parsed !== 'string') {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
if (parsed === 'openai-chat' ||
|
|
105
|
+
parsed === 'openai-responses' ||
|
|
106
|
+
parsed === 'anthropic-messages' ||
|
|
107
|
+
parsed === 'gemini-chat' ||
|
|
108
|
+
parsed === 'unknown') {
|
|
109
|
+
return parsed;
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function parseReviewOperations(raw) {
|
|
118
|
+
try {
|
|
119
|
+
const parsed = JSON.parse(raw);
|
|
120
|
+
if (!Array.isArray(parsed)) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
const operations = parsed.filter((entry) => Boolean(entry && typeof entry === 'object' && !Array.isArray(entry)));
|
|
124
|
+
return operations;
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function parseBoolean(raw) {
|
|
131
|
+
try {
|
|
132
|
+
const parsed = JSON.parse(raw);
|
|
133
|
+
return typeof parsed === 'boolean' ? parsed : null;
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function parseStringOrUndefined(raw) {
|
|
140
|
+
try {
|
|
141
|
+
const parsed = JSON.parse(raw);
|
|
142
|
+
if (parsed === null) {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
return typeof parsed === 'string' ? parsed : null;
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
export function detectProviderResponseShapeWithNative(payload) {
|
|
152
|
+
const capability = 'detectProviderResponseShapeJson';
|
|
153
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
154
|
+
if (isNativeDisabledByEnv()) {
|
|
155
|
+
return fail('native disabled');
|
|
156
|
+
}
|
|
157
|
+
const fn = readNativeFunction(capability);
|
|
158
|
+
if (!fn) {
|
|
159
|
+
return fail();
|
|
160
|
+
}
|
|
161
|
+
const payloadJson = safeStringify(payload ?? null);
|
|
162
|
+
if (!payloadJson) {
|
|
163
|
+
return fail('json stringify failed');
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
const raw = fn(payloadJson);
|
|
167
|
+
if (typeof raw !== 'string' || !raw) {
|
|
168
|
+
return fail('empty result');
|
|
169
|
+
}
|
|
170
|
+
const parsed = parseProviderResponseShape(raw);
|
|
171
|
+
return parsed ?? fail('invalid payload');
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
175
|
+
return fail(reason);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
export function isStopMessageStateActiveWithNative(raw) {
|
|
179
|
+
const capability = 'isStopMessageStateActiveJson';
|
|
180
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
181
|
+
if (isNativeDisabledByEnv()) {
|
|
182
|
+
return fail('native disabled');
|
|
183
|
+
}
|
|
184
|
+
const fn = readNativeFunction(capability);
|
|
185
|
+
if (!fn) {
|
|
186
|
+
return fail();
|
|
187
|
+
}
|
|
188
|
+
const rawJson = safeStringify(raw ?? null);
|
|
189
|
+
if (!rawJson) {
|
|
190
|
+
return fail('json stringify failed');
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
const response = fn(rawJson);
|
|
194
|
+
if (typeof response !== 'string' || !response) {
|
|
195
|
+
return fail('empty result');
|
|
196
|
+
}
|
|
197
|
+
const parsed = parseBoolean(response);
|
|
198
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
202
|
+
return fail(reason);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
export function resolveStopMessageSessionScopeWithNative(metadata) {
|
|
206
|
+
const capability = 'resolveStopMessageSessionScopeJson';
|
|
207
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
208
|
+
if (isNativeDisabledByEnv()) {
|
|
209
|
+
return fail('native disabled');
|
|
210
|
+
}
|
|
211
|
+
const fn = readNativeFunction(capability);
|
|
212
|
+
if (!fn) {
|
|
213
|
+
return fail();
|
|
214
|
+
}
|
|
215
|
+
const metadataJson = safeStringify(metadata);
|
|
216
|
+
if (!metadataJson) {
|
|
217
|
+
return fail('json stringify failed');
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
const response = fn(metadataJson);
|
|
221
|
+
if (typeof response !== 'string' || !response) {
|
|
222
|
+
return fail('empty result');
|
|
223
|
+
}
|
|
224
|
+
const parsed = parseStringOrUndefined(response);
|
|
225
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
229
|
+
return fail(reason);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
export function resolveHasActiveStopMessageForContinueExecutionWithNative(runtimeState, persistedState) {
|
|
233
|
+
const capability = 'resolveHasActiveStopMessageForContinueExecutionJson';
|
|
234
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
235
|
+
if (isNativeDisabledByEnv()) {
|
|
236
|
+
return fail('native disabled');
|
|
237
|
+
}
|
|
238
|
+
const fn = readNativeFunction(capability);
|
|
239
|
+
if (!fn) {
|
|
240
|
+
return fail();
|
|
241
|
+
}
|
|
242
|
+
const runtimeStateJson = safeStringify(runtimeState ?? null);
|
|
243
|
+
const persistedStateJson = safeStringify(persistedState ?? null);
|
|
244
|
+
if (!runtimeStateJson || !persistedStateJson) {
|
|
245
|
+
return fail('json stringify failed');
|
|
246
|
+
}
|
|
247
|
+
try {
|
|
248
|
+
const response = fn(runtimeStateJson, persistedStateJson);
|
|
249
|
+
if (typeof response !== 'string' || !response) {
|
|
250
|
+
return fail('empty result');
|
|
251
|
+
}
|
|
252
|
+
const parsed = parseBoolean(response);
|
|
253
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
257
|
+
return fail(reason);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
export function buildReviewOperationsWithNative(metadata) {
|
|
261
|
+
const capability = 'buildReviewOperationsJson';
|
|
262
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
263
|
+
if (isNativeDisabledByEnv()) {
|
|
264
|
+
return fail('native disabled');
|
|
265
|
+
}
|
|
266
|
+
const fn = readNativeFunction(capability);
|
|
267
|
+
if (!fn) {
|
|
268
|
+
return fail();
|
|
269
|
+
}
|
|
270
|
+
const metadataJson = safeStringify(metadata);
|
|
271
|
+
if (!metadataJson) {
|
|
272
|
+
return fail('json stringify failed');
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
const raw = fn(metadataJson);
|
|
276
|
+
if (typeof raw !== 'string' || !raw) {
|
|
277
|
+
return fail('empty result');
|
|
278
|
+
}
|
|
279
|
+
const parsed = parseReviewOperations(raw);
|
|
280
|
+
return parsed ?? fail('invalid payload');
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
284
|
+
return fail(reason);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
export function buildContinueExecutionOperationsWithNative(shouldInject) {
|
|
288
|
+
const capability = 'buildContinueExecutionOperationsJson';
|
|
289
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
290
|
+
if (isNativeDisabledByEnv()) {
|
|
291
|
+
return fail('native disabled');
|
|
292
|
+
}
|
|
293
|
+
const fn = readNativeFunction(capability);
|
|
294
|
+
if (!fn) {
|
|
295
|
+
return fail();
|
|
296
|
+
}
|
|
297
|
+
try {
|
|
298
|
+
const raw = fn(shouldInject === true);
|
|
299
|
+
if (typeof raw !== 'string' || !raw) {
|
|
300
|
+
return fail('empty result');
|
|
301
|
+
}
|
|
302
|
+
const parsed = parseReviewOperations(raw);
|
|
303
|
+
return parsed ?? fail('invalid payload');
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
307
|
+
return fail(reason);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
export function planChatWebSearchOperationsWithNative(request, runtimeMetadata) {
|
|
311
|
+
const capability = 'planChatWebSearchOperationsJson';
|
|
312
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
313
|
+
if (isNativeDisabledByEnv()) {
|
|
314
|
+
return fail('native disabled');
|
|
315
|
+
}
|
|
316
|
+
const fn = readNativeFunction('planChatWebSearchOperationsJson');
|
|
317
|
+
if (!fn) {
|
|
318
|
+
return fail();
|
|
319
|
+
}
|
|
320
|
+
const requestJson = safeStringify(request ?? null);
|
|
321
|
+
const runtimeMetadataJson = safeStringify(runtimeMetadata);
|
|
322
|
+
if (!requestJson || !runtimeMetadataJson) {
|
|
323
|
+
return fail('json stringify failed');
|
|
324
|
+
}
|
|
325
|
+
try {
|
|
326
|
+
const raw = fn(requestJson, runtimeMetadataJson);
|
|
327
|
+
if (typeof raw !== 'string' || !raw) {
|
|
328
|
+
return fail('empty result');
|
|
329
|
+
}
|
|
330
|
+
const parsed = parseWebSearchPlan(raw);
|
|
331
|
+
return parsed ?? fail('invalid payload');
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
335
|
+
return fail(reason);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
export function planChatClockOperationsWithNative(runtimeMetadata) {
|
|
339
|
+
const capability = 'planChatClockOperationsJson';
|
|
340
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
341
|
+
if (isNativeDisabledByEnv()) {
|
|
342
|
+
return fail('native disabled');
|
|
343
|
+
}
|
|
344
|
+
const fn = readNativeFunction('planChatClockOperationsJson');
|
|
345
|
+
if (!fn) {
|
|
346
|
+
return fail();
|
|
347
|
+
}
|
|
348
|
+
const runtimeMetadataJson = safeStringify(runtimeMetadata);
|
|
349
|
+
if (!runtimeMetadataJson) {
|
|
350
|
+
return fail('json stringify failed');
|
|
351
|
+
}
|
|
352
|
+
try {
|
|
353
|
+
const raw = fn(runtimeMetadataJson);
|
|
354
|
+
if (typeof raw !== 'string' || !raw) {
|
|
355
|
+
return fail('empty result');
|
|
356
|
+
}
|
|
357
|
+
const parsed = parseClockPlan(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 planContinueExecutionOperationsWithNative(runtimeMetadata, hasActiveStopMessage) {
|
|
366
|
+
const capability = 'planContinueExecutionOperationsJson';
|
|
367
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
368
|
+
if (isNativeDisabledByEnv()) {
|
|
369
|
+
return fail('native disabled');
|
|
370
|
+
}
|
|
371
|
+
const fn = readNativeFunction('planContinueExecutionOperationsJson');
|
|
372
|
+
if (!fn) {
|
|
373
|
+
return fail();
|
|
374
|
+
}
|
|
375
|
+
const runtimeMetadataJson = safeStringify(runtimeMetadata);
|
|
376
|
+
if (!runtimeMetadataJson) {
|
|
377
|
+
return fail('json stringify failed');
|
|
378
|
+
}
|
|
379
|
+
try {
|
|
380
|
+
const raw = fn(runtimeMetadataJson, hasActiveStopMessage === true);
|
|
381
|
+
if (typeof raw !== 'string' || !raw) {
|
|
382
|
+
return fail('empty result');
|
|
383
|
+
}
|
|
384
|
+
const parsed = parseContinueExecutionPlan(raw);
|
|
385
|
+
return parsed ?? fail('invalid payload');
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
389
|
+
return fail(reason);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
export function tryPlanChatServerToolBundleWithNative(request, runtimeMetadata, hasActiveStopMessage) {
|
|
393
|
+
const capability = 'planChatServertoolOrchestrationBundleJson';
|
|
394
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
395
|
+
if (isNativeDisabledByEnv()) {
|
|
396
|
+
return fail('native disabled');
|
|
397
|
+
}
|
|
398
|
+
const fn = readNativeFunction('planChatServertoolOrchestrationBundleJson');
|
|
399
|
+
if (!fn) {
|
|
400
|
+
return fail();
|
|
401
|
+
}
|
|
402
|
+
const requestJson = safeStringify(request ?? null);
|
|
403
|
+
const runtimeMetadataJson = safeStringify(runtimeMetadata);
|
|
404
|
+
if (!requestJson || !runtimeMetadataJson) {
|
|
405
|
+
return fail('json stringify failed');
|
|
406
|
+
}
|
|
407
|
+
try {
|
|
408
|
+
const raw = fn(requestJson, runtimeMetadataJson, hasActiveStopMessage === true);
|
|
409
|
+
if (typeof raw !== 'string' || !raw) {
|
|
410
|
+
return fail('empty result');
|
|
411
|
+
}
|
|
412
|
+
const parsed = parseServerToolBundlePlan(raw);
|
|
413
|
+
return parsed ?? fail('invalid payload');
|
|
414
|
+
}
|
|
415
|
+
catch (error) {
|
|
416
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
417
|
+
return fail(reason);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
export function injectContinueExecutionDirectiveWithNative(messages, marker, targetText) {
|
|
421
|
+
const capability = 'injectContinueExecutionDirectiveJson';
|
|
422
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
423
|
+
if (isNativeDisabledByEnv()) {
|
|
424
|
+
return fail('native disabled');
|
|
425
|
+
}
|
|
426
|
+
const fn = readNativeFunction('injectContinueExecutionDirectiveJson');
|
|
427
|
+
if (!fn) {
|
|
428
|
+
return fail();
|
|
429
|
+
}
|
|
430
|
+
const messagesJson = safeStringify(messages);
|
|
431
|
+
if (!messagesJson) {
|
|
432
|
+
return fail('json stringify failed');
|
|
433
|
+
}
|
|
434
|
+
try {
|
|
435
|
+
const raw = fn(messagesJson, marker, targetText);
|
|
436
|
+
if (typeof raw !== 'string' || !raw) {
|
|
437
|
+
return fail('empty result');
|
|
438
|
+
}
|
|
439
|
+
const parsed = parseContinueDirectiveInjection(raw);
|
|
440
|
+
return parsed ?? fail('invalid payload');
|
|
441
|
+
}
|
|
442
|
+
catch (error) {
|
|
443
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
444
|
+
return fail(reason);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractWebSearchSemanticsHintWithNative(semantics: unknown): Record<string, unknown> | undefined;
|