@jsonstudio/llms 0.6.2172 → 0.6.2979
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/conversion/compat/antigravity-session-signature.js +35 -1
- package/dist/conversion/compat/profiles/chat-gemini-cli.json +0 -7
- package/dist/conversion/compat/profiles/chat-gemini.json +0 -6
- package/dist/conversion/hub/core/detour-registry.d.ts +2 -0
- package/dist/conversion/hub/core/hub-context.d.ts +3 -1
- package/dist/conversion/hub/core/index.d.ts +1 -0
- package/dist/conversion/hub/core/stage-driver.js +2 -0
- package/dist/conversion/hub/format-adapters/anthropic-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/chat-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/gemini-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/responses-format-adapter.js +15 -4
- package/dist/conversion/hub/hub-feature.js +3 -2
- package/dist/conversion/hub/node-support.js +9 -4
- package/dist/conversion/hub/operation-table/operation-table-runner.js +10 -6
- package/dist/conversion/hub/operation-table/semantic-mappers/anthropic-mapper.js +2 -2
- package/dist/conversion/hub/operation-table/semantic-mappers/chat-mapper.js +10 -10
- package/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.js +4 -8
- package/dist/conversion/hub/operation-table/semantic-mappers/responses-mapper.js +19 -65
- package/dist/conversion/hub/ops/operations.js +2 -121
- package/dist/conversion/hub/pipeline/compat/compat-engine.js +6 -0
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.d.ts +1 -1
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +33 -1042
- package/dist/conversion/hub/pipeline/compat/compat-profile-resolver.js +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-profile-store.js +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-types.d.ts +14 -17
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.d.ts +3 -0
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.js +39 -0
- package/dist/conversion/hub/pipeline/hub-pipeline.js +115 -262
- package/dist/conversion/hub/pipeline/session-identifiers.js +6 -196
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.js +37 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.js +12 -86
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.d.ts +14 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.js +24 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.d.ts +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.js +157 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.d.ts +16 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.js +29 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-factories.js +3 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.d.ts +2 -15
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.js +8 -595
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.d.ts +8 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.js +28 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.d.ts +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.js +4 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.d.ts +10 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.js +12 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.js +30 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/index.js +9 -129
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.d.ts +1 -4
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.js +9 -26
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +32 -14
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.d.ts +2 -2
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.js +48 -8
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage2_route_select/index.js +18 -3
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/index.js +10 -198
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.js +81 -0
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.js +36 -1
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage3_semantic_map/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.d.ts +6 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.js +17 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.d.ts +9 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.js +28 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.js +14 -102
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage2_sse_stream/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage1_tool_governance/index.js +12 -10
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage2_finalize/index.js +6 -5
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.d.ts +11 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.js +10 -32
- package/dist/conversion/hub/pipeline/stages/utils.js +17 -1
- package/dist/conversion/hub/pipeline/target-utils.js +14 -91
- package/dist/conversion/hub/pipelines/inbound.js +3 -1
- package/dist/conversion/hub/pipelines/outbound.js +2 -0
- package/dist/conversion/hub/policy/policy-engine.js +9 -3
- package/dist/conversion/hub/policy/protocol-spec.js +20 -148
- package/dist/conversion/hub/process/chat-process-anthropic-alias.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-anthropic-alias.js +36 -0
- package/dist/conversion/hub/process/chat-process-clock-directive-parser.d.ts +5 -0
- package/dist/conversion/hub/process/chat-process-clock-directive-parser.js +48 -0
- package/dist/conversion/hub/process/chat-process-clock-directives.d.ts +24 -0
- package/dist/conversion/hub/process/chat-process-clock-directives.js +98 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-directives.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-directives.js +42 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-finalize.d.ts +14 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-finalize.js +10 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-messages.d.ts +5 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-messages.js +10 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.d.ts +30 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.js +68 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.d.ts +9 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.js +18 -0
- package/dist/conversion/hub/process/chat-process-clock-reminders.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-clock-reminders.js +104 -0
- package/dist/conversion/hub/process/chat-process-clock-tool-schemas.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-clock-tool-schemas.js +233 -0
- package/dist/conversion/hub/process/chat-process-clock-tools.d.ts +6 -0
- package/dist/conversion/hub/process/chat-process-clock-tools.js +41 -0
- package/dist/conversion/hub/process/chat-process-continue-execution.d.ts +11 -0
- package/dist/conversion/hub/process/chat-process-continue-execution.js +82 -0
- package/dist/conversion/hub/process/chat-process-governance-context.d.ts +15 -0
- package/dist/conversion/hub/process/chat-process-governance-context.js +7 -0
- package/dist/conversion/hub/process/chat-process-governance-finalize.d.ts +16 -0
- package/dist/conversion/hub/process/chat-process-governance-finalize.js +11 -0
- package/dist/conversion/hub/process/chat-process-governance-orchestration.d.ts +9 -0
- package/dist/conversion/hub/process/chat-process-governance-orchestration.js +47 -0
- package/dist/conversion/hub/process/chat-process-governed-control-ops.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-governed-control-ops.js +5 -0
- package/dist/conversion/hub/process/chat-process-governed-filter-call.d.ts +12 -0
- package/dist/conversion/hub/process/chat-process-governed-filter-call.js +18 -0
- package/dist/conversion/hub/process/chat-process-governed-merge.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-governed-merge.js +11 -0
- package/dist/conversion/hub/process/chat-process-media.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-media.js +18 -0
- package/dist/conversion/hub/process/chat-process-node-result.d.ts +23 -0
- package/dist/conversion/hub/process/chat-process-node-result.js +24 -0
- package/dist/conversion/hub/process/chat-process-pending-tool-sync.d.ts +14 -0
- package/dist/conversion/hub/process/chat-process-pending-tool-sync.js +52 -0
- package/dist/conversion/hub/process/chat-process-post-governed-normalization.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-post-governed-normalization.js +16 -0
- package/dist/conversion/hub/process/chat-process-review.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-review.js +8 -0
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.js +22 -0
- package/dist/conversion/hub/process/chat-process-tool-normalization.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-tool-normalization.js +4 -0
- package/dist/conversion/hub/process/chat-process-web-search-intent.d.ts +12 -0
- package/dist/conversion/hub/process/chat-process-web-search-intent.js +13 -0
- package/dist/conversion/hub/process/chat-process-web-search-tool-schema.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-web-search-tool-schema.js +4 -0
- package/dist/conversion/hub/process/chat-process-web-search.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-web-search.js +26 -0
- package/dist/conversion/hub/process/chat-process.d.ts +2 -19
- package/dist/conversion/hub/process/chat-process.js +12 -1701
- package/dist/conversion/hub/process/client-inject-readiness.d.ts +1 -0
- package/dist/conversion/hub/process/client-inject-readiness.js +4 -0
- package/dist/conversion/hub/registry.js +5 -2
- package/dist/conversion/hub/response/chat-response-utils.js +5 -86
- package/dist/conversion/hub/response/provider-response.d.ts +9 -0
- package/dist/conversion/hub/response/provider-response.js +6 -21
- package/dist/conversion/hub/response/response-mappers.js +2 -26
- package/dist/conversion/hub/response/response-runtime.js +2 -93
- package/dist/conversion/hub/semantic-mappers/anthropic-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/anthropic-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/chat-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/chat-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/gemini-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/gemini-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/responses-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/responses-mapper.js +1 -0
- package/dist/conversion/hub/snapshot-recorder.js +10 -3
- package/dist/conversion/hub/standardized-bridge.js +11 -288
- package/dist/conversion/hub/tool-governance/engine.js +5 -0
- package/dist/conversion/hub/tool-governance/rules.js +10 -10
- package/dist/conversion/hub/tool-session-compat.d.ts +2 -2
- package/dist/conversion/hub/tool-session-compat.js +17 -231
- package/dist/conversion/hub/tool-surface/tool-surface-engine.js +5 -3
- package/dist/conversion/responses/responses-host-policy.js +2 -12
- package/dist/conversion/responses/responses-openai-bridge/response-payload.js +6 -82
- package/dist/conversion/responses/responses-openai-bridge/types.d.ts +1 -0
- package/dist/conversion/responses/responses-openai-bridge.js +21 -54
- package/dist/conversion/shared/anthropic-message-utils.js +151 -13
- package/dist/conversion/shared/args-mapping.js +2 -146
- package/dist/conversion/shared/bridge-actions.js +203 -718
- package/dist/conversion/shared/bridge-id-utils.js +5 -71
- package/dist/conversion/shared/bridge-instructions.js +2 -1
- package/dist/conversion/shared/bridge-message-types.d.ts +2 -0
- package/dist/conversion/shared/bridge-message-utils.js +1 -2
- package/dist/conversion/shared/bridge-metadata.d.ts +1 -0
- package/dist/conversion/shared/bridge-metadata.js +4 -0
- package/dist/conversion/shared/bridge-policies.js +5 -189
- package/dist/conversion/shared/chat-envelope-validator.js +2 -126
- package/dist/conversion/shared/chat-output-normalizer.js +2 -54
- package/dist/conversion/shared/compaction-detect.js +2 -57
- package/dist/conversion/shared/gemini-tool-utils.js +9 -524
- package/dist/conversion/shared/jsonish.js +3 -160
- package/dist/conversion/shared/mcp-injection.js +3 -169
- package/dist/conversion/shared/media.js +2 -7
- package/dist/conversion/shared/metadata-passthrough.js +9 -46
- package/dist/conversion/shared/openai-finalizer.js +2 -1
- package/dist/conversion/shared/openai-message-normalize.js +11 -283
- package/dist/conversion/shared/output-content-normalizer.js +9 -112
- package/dist/conversion/shared/payload-budget.js +2 -85
- package/dist/conversion/shared/protocol-state.js +11 -7
- package/dist/conversion/shared/reasoning-mapping.js +2 -6
- package/dist/conversion/shared/reasoning-normalizer.js +4 -1
- package/dist/conversion/shared/reasoning-tool-normalizer.js +14 -126
- package/dist/conversion/shared/reasoning-tool-parser.js +4 -87
- package/dist/conversion/shared/reasoning-utils.js +2 -6
- package/dist/conversion/shared/responses-conversation-store.js +4 -82
- package/dist/conversion/shared/responses-output-builder.js +11 -47
- package/dist/conversion/shared/responses-reasoning-registry.js +7 -1
- package/dist/conversion/shared/responses-request-adapter.d.ts +7 -1
- package/dist/conversion/shared/responses-request-adapter.js +14 -1
- package/dist/conversion/shared/responses-response-utils.js +6 -7
- package/dist/conversion/shared/responses-tool-utils.d.ts +1 -0
- package/dist/conversion/shared/responses-tool-utils.js +90 -14
- package/dist/conversion/shared/runtime-metadata.js +13 -5
- package/dist/conversion/shared/streaming-text-extractor.js +2 -7
- package/dist/conversion/shared/text-markup-normalizer/normalize.d.ts +1 -1
- package/dist/conversion/shared/text-markup-normalizer/normalize.js +43 -17
- package/dist/conversion/shared/text-markup-normalizer.d.ts +1 -0
- package/dist/conversion/shared/text-markup-normalizer.js +1 -0
- package/dist/conversion/shared/thought-signature-validator.js +3 -2
- package/dist/conversion/shared/tool-argument-repairer.js +2 -2
- package/dist/conversion/shared/tool-call-id-manager.js +5 -7
- package/dist/conversion/shared/tool-call-utils.js +3 -45
- package/dist/conversion/shared/tool-canonicalizer.js +25 -29
- package/dist/conversion/shared/tool-filter-pipeline.js +4 -99
- package/dist/conversion/shared/tool-governor.d.ts +6 -0
- package/dist/conversion/shared/tool-governor.js +43 -125
- package/dist/conversion/shared/tool-harvester.js +2 -8
- package/dist/conversion/shared/tool-mapping.js +2 -5
- package/dist/conversion/shared/tooling.d.ts +0 -4
- package/dist/conversion/shared/tooling.js +18 -0
- package/dist/native/router_hotpath_napi.node +0 -0
- package/dist/router/virtual-router/engine/provider-key/parse.d.ts +1 -6
- package/dist/router/virtual-router/engine/provider-key/parse.js +1 -43
- package/dist/router/virtual-router/engine/routing-state/store.js +48 -12
- package/dist/router/virtual-router/engine-logging.js +4 -3
- package/dist/router/virtual-router/engine-selection/alias-selection.js +45 -83
- package/dist/router/virtual-router/engine-selection/key-parsing.js +9 -23
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.d.ts +20 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.js +163 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.d.ts +7 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.js +103 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.js +110 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.d.ts +8 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.js +281 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.js +25 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.d.ts +4 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.js +44 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.js +62 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.d.ts +40 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.js +484 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.d.ts +9 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.js +64 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.js +163 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.js +49 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.d.ts +30 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.js +446 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.js +49 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.d.ts +134 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js +729 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.d.ts +62 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.js +338 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.d.ts +18 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js +317 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.d.ts +22 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.js +426 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.d.ts +57 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.js +705 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.d.ts +46 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js +503 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.d.ts +146 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js +570 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.js +148 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.js +637 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.d.ts +11 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.js +207 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.d.ts +3 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.js +128 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.d.ts +57 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.js +217 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.js +284 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.js +18 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.js +85 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath.d.ts +59 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath.js +117 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.d.ts +76 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.js +1166 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.d.ts +16 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.js +96 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.d.ts +6 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.js +85 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.d.ts +9 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.js +70 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.js +76 -0
- package/dist/router/virtual-router/engine-selection/route-utils.js +1 -1
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.js +231 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.d.ts +4 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.js +43 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.d.ts +27 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.js +116 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-select.d.ts +1 -1
- package/dist/router/virtual-router/engine-selection/tier-selection-select.js +29 -129
- package/dist/router/virtual-router/engine-selection/tier-selection.js +2 -265
- package/dist/router/virtual-router/engine.js +258 -249
- package/dist/router/virtual-router/features.js +2 -2
- package/dist/router/virtual-router/routing-instructions.d.ts +5 -7
- package/dist/router/virtual-router/routing-instructions.js +93 -66
- package/dist/router/virtual-router/routing-stop-message-actions.js +91 -112
- package/dist/router/virtual-router/routing-stop-message-parser.js +9 -132
- package/dist/router/virtual-router/routing-stop-message-state-codec.d.ts +1 -0
- package/dist/router/virtual-router/routing-stop-message-state-codec.js +58 -71
- package/dist/router/virtual-router/sticky-session-store.js +4 -2
- package/dist/router/virtual-router/stop-message-file-resolver.d.ts +1 -0
- package/dist/router/virtual-router/stop-message-file-resolver.js +10 -0
- package/dist/router/virtual-router/stop-message-state-sync.d.ts +1 -1
- package/dist/router/virtual-router/stop-message-state-sync.js +3 -7
- package/dist/router/virtual-router/token-counter.js +0 -9
- package/dist/router/virtual-router/types.d.ts +9 -7
- package/dist/servertool/clock/config.js +23 -51
- package/dist/servertool/clock/io.js +1 -0
- package/dist/servertool/clock/session-scope.d.ts +2 -2
- package/dist/servertool/clock/session-scope.js +5 -47
- package/dist/servertool/engine.d.ts +9 -0
- package/dist/servertool/engine.js +196 -79
- package/dist/servertool/handlers/antigravity-thought-signature-bootstrap.js +2 -2
- package/dist/servertool/handlers/clock.js +1 -1
- package/dist/servertool/handlers/continue-execution.js +8 -4
- package/dist/servertool/handlers/followup-request-builder.js +18 -1
- package/dist/servertool/handlers/gemini-empty-reply-continue.js +7 -1
- package/dist/servertool/handlers/review.js +180 -0
- package/dist/servertool/handlers/stop-message-auto/blocked-report.js +59 -1
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.d.ts +23 -2
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.js +397 -89
- package/dist/servertool/handlers/stop-message-auto/routing-state.d.ts +5 -15
- package/dist/servertool/handlers/stop-message-auto/routing-state.js +29 -55
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.d.ts +6 -0
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.js +35 -61
- package/dist/servertool/handlers/stop-message-auto.js +392 -76
- package/dist/servertool/server-side-tools.d.ts +1 -0
- package/dist/servertool/server-side-tools.js +90 -52
- package/dist/servertool/types.d.ts +17 -0
- package/dist/tools/apply-patch/patch-text/normalize.js +11 -0
- package/dist/tools/exec-command/validator.d.ts +4 -1
- package/dist/tools/exec-command/validator.js +87 -3
- package/dist/tools/tool-registry.d.ts +7 -1
- package/dist/tools/tool-registry.js +3 -2
- package/package.json +115 -7
- package/dist/servertool/handlers/stop-message-stage-policy/bd-runtime.d.ts +0 -18
- package/dist/servertool/handlers/stop-message-stage-policy/bd-runtime.js +0 -398
- package/dist/servertool/handlers/stop-message-stage-policy/decision.d.ts +0 -9
- package/dist/servertool/handlers/stop-message-stage-policy/decision.js +0 -127
- package/dist/servertool/handlers/stop-message-stage-policy/observation.d.ts +0 -2
- package/dist/servertool/handlers/stop-message-stage-policy/observation.js +0 -179
- package/dist/servertool/handlers/stop-message-stage-policy/templates.d.ts +0 -4
- package/dist/servertool/handlers/stop-message-stage-policy/templates.js +0 -96
- package/dist/servertool/handlers/stop-message-stage-policy/text-utils.d.ts +0 -9
- package/dist/servertool/handlers/stop-message-stage-policy/text-utils.js +0 -89
- package/dist/servertool/handlers/stop-message-stage-policy/types.d.ts +0 -59
- package/dist/servertool/handlers/stop-message-stage-policy.d.ts +0 -3
- package/dist/servertool/handlers/stop-message-stage-policy.js +0 -2
- /package/dist/servertool/handlers/{stop-message-stage-policy/types.js → review.d.ts} +0 -0
|
@@ -0,0 +1,207 @@
|
|
|
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 parseSessionIdentifiers(raw) {
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(raw);
|
|
19
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const row = parsed;
|
|
23
|
+
const out = {};
|
|
24
|
+
const sessionId = typeof row.sessionId === 'string' ? row.sessionId.trim() : '';
|
|
25
|
+
const conversationId = typeof row.conversationId === 'string' ? row.conversationId.trim() : '';
|
|
26
|
+
if (sessionId) {
|
|
27
|
+
out.sessionId = sessionId;
|
|
28
|
+
}
|
|
29
|
+
if (conversationId) {
|
|
30
|
+
out.conversationId = conversationId;
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function parseOptionalString(raw) {
|
|
39
|
+
try {
|
|
40
|
+
const parsed = JSON.parse(raw);
|
|
41
|
+
if (parsed === null) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
if (typeof parsed !== 'string') {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const normalized = parsed.trim();
|
|
48
|
+
return normalized ? normalized : undefined;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function parseHeaderMap(raw) {
|
|
55
|
+
try {
|
|
56
|
+
const parsed = JSON.parse(raw);
|
|
57
|
+
if (parsed === null) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const out = {};
|
|
64
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
65
|
+
if (typeof key !== 'string' || !key || typeof value !== 'string') {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
out[key] = value;
|
|
69
|
+
}
|
|
70
|
+
return Object.keys(out).length ? out : undefined;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function extractSessionIdentifiersFromMetadataWithNative(metadata) {
|
|
77
|
+
const capability = 'extractSessionIdentifiersJson';
|
|
78
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
79
|
+
if (isNativeDisabledByEnv()) {
|
|
80
|
+
return fail('native disabled');
|
|
81
|
+
}
|
|
82
|
+
const fn = readNativeFunction('extractSessionIdentifiersJson');
|
|
83
|
+
if (!fn) {
|
|
84
|
+
return fail();
|
|
85
|
+
}
|
|
86
|
+
const metadataJson = safeStringify(metadata ?? null);
|
|
87
|
+
if (!metadataJson) {
|
|
88
|
+
return fail('json stringify failed');
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const raw = fn(metadataJson);
|
|
92
|
+
if (typeof raw !== 'string' || !raw) {
|
|
93
|
+
return fail('empty result');
|
|
94
|
+
}
|
|
95
|
+
const parsed = parseSessionIdentifiers(raw);
|
|
96
|
+
return parsed ?? fail('invalid payload');
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
100
|
+
return fail(reason);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export function coerceClientHeadersWithNative(raw) {
|
|
104
|
+
const capability = 'coerceClientHeadersJson';
|
|
105
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
106
|
+
if (isNativeDisabledByEnv()) {
|
|
107
|
+
return fail('native disabled');
|
|
108
|
+
}
|
|
109
|
+
const fn = readNativeFunction(capability);
|
|
110
|
+
if (!fn) {
|
|
111
|
+
return fail();
|
|
112
|
+
}
|
|
113
|
+
const rawJson = safeStringify(raw ?? null);
|
|
114
|
+
if (!rawJson) {
|
|
115
|
+
return fail('json stringify failed');
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const result = fn(rawJson);
|
|
119
|
+
if (typeof result !== 'string' || !result) {
|
|
120
|
+
return fail('empty result');
|
|
121
|
+
}
|
|
122
|
+
const parsed = parseHeaderMap(result);
|
|
123
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
127
|
+
return fail(reason);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export function findHeaderValueWithNative(headers, target) {
|
|
131
|
+
const capability = 'findHeaderValueJson';
|
|
132
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
133
|
+
if (isNativeDisabledByEnv()) {
|
|
134
|
+
return fail('native disabled');
|
|
135
|
+
}
|
|
136
|
+
const fn = readNativeFunction(capability);
|
|
137
|
+
if (!fn) {
|
|
138
|
+
return fail();
|
|
139
|
+
}
|
|
140
|
+
const headersJson = safeStringify(headers ?? {});
|
|
141
|
+
if (!headersJson) {
|
|
142
|
+
return fail('json stringify failed');
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const result = fn(headersJson, String(target ?? ''));
|
|
146
|
+
if (typeof result !== 'string' || !result) {
|
|
147
|
+
return fail('empty result');
|
|
148
|
+
}
|
|
149
|
+
const parsed = parseOptionalString(result);
|
|
150
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
154
|
+
return fail(reason);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export function pickHeaderWithNative(headers, candidates) {
|
|
158
|
+
const capability = 'pickHeaderJson';
|
|
159
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
160
|
+
if (isNativeDisabledByEnv()) {
|
|
161
|
+
return fail('native disabled');
|
|
162
|
+
}
|
|
163
|
+
const fn = readNativeFunction(capability);
|
|
164
|
+
if (!fn) {
|
|
165
|
+
return fail();
|
|
166
|
+
}
|
|
167
|
+
const headersJson = safeStringify(headers ?? {});
|
|
168
|
+
const candidatesJson = safeStringify(Array.isArray(candidates) ? candidates : []);
|
|
169
|
+
if (!headersJson || !candidatesJson) {
|
|
170
|
+
return fail('json stringify failed');
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
const result = fn(headersJson, candidatesJson);
|
|
174
|
+
if (typeof result !== 'string' || !result) {
|
|
175
|
+
return fail('empty result');
|
|
176
|
+
}
|
|
177
|
+
const parsed = parseOptionalString(result);
|
|
178
|
+
return parsed === null ? fail('invalid payload') : parsed;
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
182
|
+
return fail(reason);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
export function normalizeHeaderKeyWithNative(value) {
|
|
186
|
+
const capability = 'normalizeHeaderKeyJson';
|
|
187
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
188
|
+
if (isNativeDisabledByEnv()) {
|
|
189
|
+
return fail('native disabled');
|
|
190
|
+
}
|
|
191
|
+
const fn = readNativeFunction(capability);
|
|
192
|
+
if (!fn) {
|
|
193
|
+
return fail();
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
const result = fn(String(value ?? ''));
|
|
197
|
+
if (typeof result !== 'string' || !result) {
|
|
198
|
+
return fail('empty result');
|
|
199
|
+
}
|
|
200
|
+
const parsed = parseOptionalString(result);
|
|
201
|
+
return parsed === null ? fail('invalid payload') : (parsed ?? '');
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
205
|
+
return fail(reason);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function extractTargetModelIdWithNative(target: unknown): string | null;
|
|
2
|
+
export declare function applyTargetMetadataWithNative(metadata: Record<string, unknown>, target: unknown, routeName?: string, originalModel?: string): Record<string, unknown>;
|
|
3
|
+
export declare function applyTargetToSubjectWithNative(subject: Record<string, unknown>, target: unknown, originalModel?: string): Record<string, unknown>;
|
|
@@ -0,0 +1,128 @@
|
|
|
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 parseStringOrNull(raw) {
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(raw);
|
|
19
|
+
if (parsed === null) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
if (typeof parsed !== 'string') {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const normalized = parsed.trim();
|
|
26
|
+
return normalized.length ? normalized : null;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function parseRecord(raw) {
|
|
33
|
+
try {
|
|
34
|
+
const parsed = JSON.parse(raw);
|
|
35
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return parsed;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function extractTargetModelIdWithNative(target) {
|
|
45
|
+
const capability = 'extractTargetModelIdJson';
|
|
46
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
47
|
+
if (isNativeDisabledByEnv()) {
|
|
48
|
+
return fail('native disabled');
|
|
49
|
+
}
|
|
50
|
+
const fn = readNativeFunction('extractTargetModelIdJson');
|
|
51
|
+
if (!fn) {
|
|
52
|
+
return fail();
|
|
53
|
+
}
|
|
54
|
+
const targetJson = safeStringify(target ?? null);
|
|
55
|
+
if (!targetJson) {
|
|
56
|
+
return fail('json stringify failed');
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const raw = fn(targetJson);
|
|
60
|
+
if (typeof raw !== 'string' || !raw) {
|
|
61
|
+
return fail('empty result');
|
|
62
|
+
}
|
|
63
|
+
return parseStringOrNull(raw);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
67
|
+
return fail(reason);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export function applyTargetMetadataWithNative(metadata, target, routeName, originalModel) {
|
|
71
|
+
const capability = 'applyTargetMetadataJson';
|
|
72
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
73
|
+
if (isNativeDisabledByEnv()) {
|
|
74
|
+
return fail('native disabled');
|
|
75
|
+
}
|
|
76
|
+
const fn = readNativeFunction(capability);
|
|
77
|
+
if (!fn) {
|
|
78
|
+
return fail();
|
|
79
|
+
}
|
|
80
|
+
const metadataJson = safeStringify(metadata ?? {});
|
|
81
|
+
const targetJson = safeStringify(target ?? null);
|
|
82
|
+
const routeNameJson = safeStringify(routeName ?? null);
|
|
83
|
+
const originalModelJson = safeStringify(originalModel ?? null);
|
|
84
|
+
if (!metadataJson || !targetJson || !routeNameJson || !originalModelJson) {
|
|
85
|
+
return fail('json stringify failed');
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const raw = fn(metadataJson, targetJson, routeNameJson, originalModelJson);
|
|
89
|
+
if (typeof raw !== 'string' || !raw) {
|
|
90
|
+
return fail('empty result');
|
|
91
|
+
}
|
|
92
|
+
const parsed = parseRecord(raw);
|
|
93
|
+
return parsed ?? fail('invalid payload');
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
97
|
+
return fail(reason);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export function applyTargetToSubjectWithNative(subject, target, originalModel) {
|
|
101
|
+
const capability = 'applyTargetToSubjectJson';
|
|
102
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
103
|
+
if (isNativeDisabledByEnv()) {
|
|
104
|
+
return fail('native disabled');
|
|
105
|
+
}
|
|
106
|
+
const fn = readNativeFunction(capability);
|
|
107
|
+
if (!fn) {
|
|
108
|
+
return fail();
|
|
109
|
+
}
|
|
110
|
+
const subjectJson = safeStringify(subject ?? {});
|
|
111
|
+
const targetJson = safeStringify(target ?? null);
|
|
112
|
+
const originalModelJson = safeStringify(originalModel ?? null);
|
|
113
|
+
if (!subjectJson || !targetJson || !originalModelJson) {
|
|
114
|
+
return fail('json stringify failed');
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const raw = fn(subjectJson, targetJson, originalModelJson);
|
|
118
|
+
if (typeof raw !== 'string' || !raw) {
|
|
119
|
+
return fail('empty result');
|
|
120
|
+
}
|
|
121
|
+
const parsed = parseRecord(raw);
|
|
122
|
+
return parsed ?? fail('invalid payload');
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
126
|
+
return fail(reason);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type PendingToolSyncPayload = {
|
|
2
|
+
ready: boolean;
|
|
3
|
+
insertAt: number;
|
|
4
|
+
};
|
|
5
|
+
export type ContinueExecutionInjectionPayload = {
|
|
6
|
+
hasDirective: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ChatProcessMediaAnalysisPayload = {
|
|
9
|
+
stripIndices: number[];
|
|
10
|
+
containsCurrentTurnImage: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type ChatProcessMediaStripPayload = {
|
|
13
|
+
changed: boolean;
|
|
14
|
+
messages: unknown[];
|
|
15
|
+
};
|
|
16
|
+
export type ChatWebSearchIntentPayload = {
|
|
17
|
+
hasIntent: boolean;
|
|
18
|
+
googlePreferred: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type ClockClearDirectivePayload = {
|
|
21
|
+
hadClear: boolean;
|
|
22
|
+
next: string;
|
|
23
|
+
};
|
|
24
|
+
export type ProviderKeyParsePayload = {
|
|
25
|
+
providerId: string | null;
|
|
26
|
+
alias: string | null;
|
|
27
|
+
keyIndex?: number;
|
|
28
|
+
};
|
|
29
|
+
export type AntigravitySessionIdPayload = {
|
|
30
|
+
sessionId: string;
|
|
31
|
+
};
|
|
32
|
+
export type AntigravityPinnedAliasLookupPayload = {
|
|
33
|
+
alias?: string;
|
|
34
|
+
};
|
|
35
|
+
export type AntigravityPinnedAliasUnpinPayload = {
|
|
36
|
+
changed: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type AntigravityCacheSignaturePayload = {
|
|
39
|
+
ok: boolean;
|
|
40
|
+
};
|
|
41
|
+
export type AntigravityRequestSessionMetaPayload = {
|
|
42
|
+
aliasKey?: string;
|
|
43
|
+
sessionId?: string;
|
|
44
|
+
messageCount?: number;
|
|
45
|
+
};
|
|
46
|
+
export declare function parsePendingToolSyncPayload(raw: string): PendingToolSyncPayload | null;
|
|
47
|
+
export declare function parseContinueExecutionInjectionPayload(raw: string): ContinueExecutionInjectionPayload | null;
|
|
48
|
+
export declare function parseChatProcessMediaAnalysisPayload(raw: string): ChatProcessMediaAnalysisPayload | null;
|
|
49
|
+
export declare function parseChatProcessMediaStripPayload(raw: string): ChatProcessMediaStripPayload | null;
|
|
50
|
+
export declare function parseChatWebSearchIntentPayload(raw: string): ChatWebSearchIntentPayload | null;
|
|
51
|
+
export declare function parseClockClearDirectivePayload(raw: string): ClockClearDirectivePayload | null;
|
|
52
|
+
export declare function parseProviderKeyPayload(raw: string): ProviderKeyParsePayload | null;
|
|
53
|
+
export declare function parseAntigravitySessionIdPayload(raw: string): AntigravitySessionIdPayload | null;
|
|
54
|
+
export declare function parseAntigravityPinnedAliasLookupPayload(raw: string): AntigravityPinnedAliasLookupPayload | null;
|
|
55
|
+
export declare function parseAntigravityPinnedAliasUnpinPayload(raw: string): AntigravityPinnedAliasUnpinPayload | null;
|
|
56
|
+
export declare function parseAntigravityCacheSignaturePayload(raw: string): AntigravityCacheSignaturePayload | null;
|
|
57
|
+
export declare function parseAntigravityRequestSessionMetaPayload(raw: string): AntigravityRequestSessionMetaPayload | null;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
export function parsePendingToolSyncPayload(raw) {
|
|
2
|
+
try {
|
|
3
|
+
const parsed = JSON.parse(raw);
|
|
4
|
+
if (!parsed || typeof parsed.ready !== 'boolean') {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const insertAt = typeof parsed.insertAt === 'number' && Number.isFinite(parsed.insertAt)
|
|
8
|
+
? Math.floor(parsed.insertAt)
|
|
9
|
+
: -1;
|
|
10
|
+
return {
|
|
11
|
+
ready: parsed.ready,
|
|
12
|
+
insertAt
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function parseContinueExecutionInjectionPayload(raw) {
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(raw);
|
|
22
|
+
if (!parsed || typeof parsed.hasDirective !== 'boolean') {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return { hasDirective: parsed.hasDirective };
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function parseChatProcessMediaAnalysisPayload(raw) {
|
|
32
|
+
try {
|
|
33
|
+
const parsed = JSON.parse(raw);
|
|
34
|
+
if (!parsed || typeof parsed.containsCurrentTurnImage !== 'boolean') {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const stripIndices = Array.isArray(parsed.stripIndices)
|
|
38
|
+
? parsed.stripIndices
|
|
39
|
+
.filter((value) => typeof value === 'number' && Number.isFinite(value))
|
|
40
|
+
.map((value) => Math.floor(value))
|
|
41
|
+
: [];
|
|
42
|
+
return {
|
|
43
|
+
stripIndices,
|
|
44
|
+
containsCurrentTurnImage: parsed.containsCurrentTurnImage
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function parseChatProcessMediaStripPayload(raw) {
|
|
52
|
+
try {
|
|
53
|
+
const parsed = JSON.parse(raw);
|
|
54
|
+
if (!parsed || typeof parsed.changed !== 'boolean' || !Array.isArray(parsed.messages)) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
changed: parsed.changed,
|
|
59
|
+
messages: parsed.messages
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export function parseChatWebSearchIntentPayload(raw) {
|
|
67
|
+
try {
|
|
68
|
+
const parsed = JSON.parse(raw);
|
|
69
|
+
if (!parsed || typeof parsed.hasIntent !== 'boolean' || typeof parsed.googlePreferred !== 'boolean') {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
hasIntent: parsed.hasIntent,
|
|
74
|
+
googlePreferred: parsed.googlePreferred
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function parseClockClearDirectivePayload(raw) {
|
|
82
|
+
try {
|
|
83
|
+
const parsed = JSON.parse(raw);
|
|
84
|
+
if (!parsed || typeof parsed.hadClear !== 'boolean' || typeof parsed.next !== 'string') {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
hadClear: parsed.hadClear,
|
|
89
|
+
next: parsed.next
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export function parseProviderKeyPayload(raw) {
|
|
97
|
+
try {
|
|
98
|
+
const parsed = JSON.parse(raw);
|
|
99
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const providerId = typeof parsed.providerId === 'string'
|
|
103
|
+
? parsed.providerId
|
|
104
|
+
: parsed.providerId === null
|
|
105
|
+
? null
|
|
106
|
+
: null;
|
|
107
|
+
const alias = typeof parsed.alias === 'string'
|
|
108
|
+
? parsed.alias
|
|
109
|
+
: parsed.alias === null
|
|
110
|
+
? null
|
|
111
|
+
: null;
|
|
112
|
+
const keyIndex = typeof parsed.keyIndex === 'number' && Number.isFinite(parsed.keyIndex)
|
|
113
|
+
? Math.floor(parsed.keyIndex)
|
|
114
|
+
: undefined;
|
|
115
|
+
return {
|
|
116
|
+
providerId,
|
|
117
|
+
alias,
|
|
118
|
+
...(keyIndex !== undefined ? { keyIndex } : {})
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
export function parseAntigravitySessionIdPayload(raw) {
|
|
126
|
+
try {
|
|
127
|
+
const parsed = JSON.parse(raw);
|
|
128
|
+
if (typeof parsed !== 'string') {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
const sessionId = parsed.trim();
|
|
132
|
+
if (!sessionId) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
return { sessionId };
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export function parseAntigravityPinnedAliasLookupPayload(raw) {
|
|
142
|
+
try {
|
|
143
|
+
const parsed = JSON.parse(raw);
|
|
144
|
+
if (parsed === null) {
|
|
145
|
+
return {};
|
|
146
|
+
}
|
|
147
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
if (parsed.alias === undefined || parsed.alias === null) {
|
|
151
|
+
return {};
|
|
152
|
+
}
|
|
153
|
+
if (typeof parsed.alias !== 'string') {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const alias = parsed.alias.trim();
|
|
157
|
+
if (!alias) {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
return { alias };
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
export function parseAntigravityPinnedAliasUnpinPayload(raw) {
|
|
167
|
+
try {
|
|
168
|
+
const parsed = JSON.parse(raw);
|
|
169
|
+
if (!parsed || typeof parsed.changed !== 'boolean') {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
return { changed: parsed.changed };
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
export function parseAntigravityCacheSignaturePayload(raw) {
|
|
179
|
+
try {
|
|
180
|
+
const parsed = JSON.parse(raw);
|
|
181
|
+
if (!parsed || typeof parsed.ok !== 'boolean') {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
return { ok: parsed.ok };
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
export function parseAntigravityRequestSessionMetaPayload(raw) {
|
|
191
|
+
try {
|
|
192
|
+
const parsed = JSON.parse(raw);
|
|
193
|
+
if (parsed === null) {
|
|
194
|
+
return {};
|
|
195
|
+
}
|
|
196
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
const aliasKey = typeof parsed.aliasKey === 'string' && parsed.aliasKey.trim().length
|
|
200
|
+
? parsed.aliasKey.trim()
|
|
201
|
+
: undefined;
|
|
202
|
+
const sessionId = typeof parsed.sessionId === 'string' && parsed.sessionId.trim().length
|
|
203
|
+
? parsed.sessionId.trim()
|
|
204
|
+
: undefined;
|
|
205
|
+
const messageCount = typeof parsed.messageCount === 'number' && Number.isFinite(parsed.messageCount) && parsed.messageCount > 0
|
|
206
|
+
? Math.floor(parsed.messageCount)
|
|
207
|
+
: undefined;
|
|
208
|
+
return {
|
|
209
|
+
...(aliasKey ? { aliasKey } : {}),
|
|
210
|
+
...(sessionId ? { sessionId } : {}),
|
|
211
|
+
...(messageCount !== undefined ? { messageCount } : {})
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
}
|