@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pinAliasQueueWithNative, resolveAliasSelectionStrategyWithNative } from './native-virtual-router-alias-selection-semantics.js';
|
|
1
2
|
// Default provider-level strategy table.
|
|
2
3
|
// This is a data-only default; callers can override via `loadBalancing.aliasSelection.providers`.
|
|
3
4
|
export const DEFAULT_PROVIDER_ALIAS_SELECTION = {
|
|
@@ -5,21 +6,7 @@ export const DEFAULT_PROVIDER_ALIAS_SELECTION = {
|
|
|
5
6
|
antigravity: 'sticky-queue'
|
|
6
7
|
};
|
|
7
8
|
export function resolveAliasSelectionStrategy(providerId, cfg) {
|
|
8
|
-
|
|
9
|
-
return 'none';
|
|
10
|
-
if (cfg?.enabled === false)
|
|
11
|
-
return 'none';
|
|
12
|
-
const overrides = cfg?.providers ?? {};
|
|
13
|
-
const override = overrides[providerId];
|
|
14
|
-
if (override === 'none' || override === 'sticky-queue') {
|
|
15
|
-
return override;
|
|
16
|
-
}
|
|
17
|
-
const def = cfg?.defaultStrategy;
|
|
18
|
-
if (def === 'none' || def === 'sticky-queue') {
|
|
19
|
-
return def;
|
|
20
|
-
}
|
|
21
|
-
const table = DEFAULT_PROVIDER_ALIAS_SELECTION[providerId];
|
|
22
|
-
return table ?? 'none';
|
|
9
|
+
return resolveAliasSelectionStrategyWithNative(providerId, cfg);
|
|
23
10
|
}
|
|
24
11
|
export function pinCandidatesByAliasQueue(opts) {
|
|
25
12
|
const { queueStore, providerId, modelId, candidates, orderedTargets, excludedProviderKeys, aliasOfKey, modelIdOfKey, availabilityCheck } = opts;
|
|
@@ -56,49 +43,51 @@ export function pinCandidatesByAliasQueue(opts) {
|
|
|
56
43
|
modelIdOfKey,
|
|
57
44
|
allowedAliases: new Set(aliasBuckets.keys())
|
|
58
45
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
46
|
+
const excludedAliases = collectExcludedAliases({
|
|
47
|
+
excludedProviderKeys,
|
|
48
|
+
providerId,
|
|
49
|
+
modelId,
|
|
50
|
+
aliasOfKey,
|
|
51
|
+
modelIdOfKey
|
|
52
|
+
});
|
|
53
|
+
const availabilityByAlias = buildAliasAvailabilityMap(aliasBuckets, availabilityCheck);
|
|
54
|
+
const resolved = pinAliasQueueWithNative({
|
|
55
|
+
queue: queueStore.get(queueKey) ?? [],
|
|
56
|
+
desiredOrder,
|
|
57
|
+
excludedAliases,
|
|
58
|
+
aliasBuckets: Object.fromEntries(aliasBuckets.entries()),
|
|
59
|
+
candidateOrder: candidates,
|
|
60
|
+
availabilityByAlias: Object.fromEntries(availabilityByAlias.entries())
|
|
61
|
+
});
|
|
62
|
+
queueStore.set(queueKey, resolved.queue);
|
|
63
|
+
return resolved.selectedCandidates.length ? resolved.selectedCandidates : null;
|
|
64
|
+
}
|
|
65
|
+
function collectExcludedAliases(opts) {
|
|
66
|
+
const { excludedProviderKeys, providerId, modelId, aliasOfKey, modelIdOfKey } = opts;
|
|
67
|
+
if (!excludedProviderKeys || excludedProviderKeys.size === 0) {
|
|
68
|
+
return [];
|
|
78
69
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
70
|
+
const excludedAliases = [];
|
|
71
|
+
for (const ex of excludedProviderKeys) {
|
|
72
|
+
if (!ex || typeof ex !== 'string')
|
|
73
|
+
continue;
|
|
74
|
+
if (!ex.startsWith(`${providerId}.`))
|
|
75
|
+
continue;
|
|
76
|
+
const exModel = modelIdOfKey(ex);
|
|
77
|
+
if (!exModel || exModel !== modelId)
|
|
78
|
+
continue;
|
|
79
|
+
const exAlias = aliasOfKey(ex);
|
|
80
|
+
if (exAlias)
|
|
81
|
+
excludedAliases.push(exAlias);
|
|
90
82
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
// Preserve original candidate order.
|
|
100
|
-
const selectedSet = new Set(selectedKeys);
|
|
101
|
-
return candidates.filter((key) => selectedSet.has(key));
|
|
83
|
+
return excludedAliases;
|
|
84
|
+
}
|
|
85
|
+
function buildAliasAvailabilityMap(aliasBuckets, availabilityCheck) {
|
|
86
|
+
const out = new Map();
|
|
87
|
+
for (const [alias, keys] of aliasBuckets.entries()) {
|
|
88
|
+
out.set(alias, keys.some((key) => availabilityCheck(key)));
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
102
91
|
}
|
|
103
92
|
function resolveAliasOrderFromTargets(opts) {
|
|
104
93
|
const { orderedTargets, providerId, modelId, aliasOfKey, modelIdOfKey, allowedAliases } = opts;
|
|
@@ -127,30 +116,3 @@ function resolveAliasOrderFromTargets(opts) {
|
|
|
127
116
|
}
|
|
128
117
|
return out;
|
|
129
118
|
}
|
|
130
|
-
function mergeAliasQueue(existing, desired) {
|
|
131
|
-
if (!Array.isArray(existing) || existing.length === 0) {
|
|
132
|
-
return [...desired];
|
|
133
|
-
}
|
|
134
|
-
const desiredSet = new Set(desired);
|
|
135
|
-
const merged = existing.filter((a) => desiredSet.has(a));
|
|
136
|
-
const mergedSet = new Set(merged);
|
|
137
|
-
for (const a of desired) {
|
|
138
|
-
if (!mergedSet.has(a))
|
|
139
|
-
merged.push(a);
|
|
140
|
-
}
|
|
141
|
-
return merged;
|
|
142
|
-
}
|
|
143
|
-
function rotateQueueToTail(queue, aliases) {
|
|
144
|
-
if (!Array.isArray(queue) || queue.length < 2)
|
|
145
|
-
return queue;
|
|
146
|
-
if (!Array.isArray(aliases) || aliases.length === 0)
|
|
147
|
-
return queue;
|
|
148
|
-
const toMove = new Set(aliases);
|
|
149
|
-
const kept = queue.filter((a) => !toMove.has(a));
|
|
150
|
-
const moved = [];
|
|
151
|
-
for (const a of queue) {
|
|
152
|
-
if (toMove.has(a) && !moved.includes(a))
|
|
153
|
-
moved.push(a);
|
|
154
|
-
}
|
|
155
|
-
return [...kept, ...moved];
|
|
156
|
-
}
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
+
import { analyzeProviderKey } from './native-router-hotpath.js';
|
|
2
|
+
function parseProviderKey(providerKey) {
|
|
3
|
+
return analyzeProviderKey(providerKey);
|
|
4
|
+
}
|
|
1
5
|
export function extractProviderId(providerKey) {
|
|
2
|
-
|
|
3
|
-
if (firstDot <= 0)
|
|
4
|
-
return null;
|
|
5
|
-
return providerKey.substring(0, firstDot);
|
|
6
|
+
return parseProviderKey(providerKey).providerId;
|
|
6
7
|
}
|
|
7
8
|
export function extractKeyAlias(providerKey) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// NOTE: modelId can contain dots (e.g. "gpt-5.2"), so we must not assume `split('.')` length === 3.
|
|
11
|
-
const firstDot = providerKey.indexOf('.');
|
|
12
|
-
if (firstDot <= 0)
|
|
13
|
-
return null;
|
|
14
|
-
const secondDot = providerKey.indexOf('.', firstDot + 1);
|
|
15
|
-
if (secondDot <= firstDot + 1)
|
|
16
|
-
return null;
|
|
17
|
-
const alias = providerKey.substring(firstDot + 1, secondDot);
|
|
18
|
-
if (!alias)
|
|
9
|
+
const alias = parseProviderKey(providerKey).alias;
|
|
10
|
+
if (!alias) {
|
|
19
11
|
return null;
|
|
12
|
+
}
|
|
20
13
|
return normalizeAliasDescriptor(alias);
|
|
21
14
|
}
|
|
22
15
|
export function normalizeAliasDescriptor(alias) {
|
|
@@ -26,14 +19,7 @@ export function normalizeAliasDescriptor(alias) {
|
|
|
26
19
|
return alias;
|
|
27
20
|
}
|
|
28
21
|
export function extractKeyIndex(providerKey) {
|
|
29
|
-
|
|
30
|
-
if (parts.length === 2) {
|
|
31
|
-
const index = parseInt(parts[1], 10);
|
|
32
|
-
if (!isNaN(index) && index > 0) {
|
|
33
|
-
return index;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return undefined;
|
|
22
|
+
return parseProviderKey(providerKey).keyIndex;
|
|
37
23
|
}
|
|
38
24
|
export function getProviderModelId(providerKey, providerRegistry) {
|
|
39
25
|
const profile = providerRegistry.get(providerKey);
|
package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ClockDirectiveRecurrenceCandidate = {
|
|
2
|
+
kind: 'daily' | 'weekly' | 'interval';
|
|
3
|
+
maxRuns: number;
|
|
4
|
+
everyMinutes?: number;
|
|
5
|
+
};
|
|
6
|
+
export type ClockScheduleDirectiveCandidate = {
|
|
7
|
+
dueAt: string;
|
|
8
|
+
task: string;
|
|
9
|
+
recurrence?: ClockDirectiveRecurrenceCandidate;
|
|
10
|
+
};
|
|
11
|
+
export type ClockDirectiveTextPart = {
|
|
12
|
+
kind: 'text';
|
|
13
|
+
text: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'directive';
|
|
16
|
+
full: string;
|
|
17
|
+
candidate?: ClockScheduleDirectiveCandidate;
|
|
18
|
+
};
|
|
19
|
+
export declare function parseClockScheduleDirectiveCandidateWithNative(payload: string): ClockScheduleDirectiveCandidate | null;
|
|
20
|
+
export declare function extractClockScheduleDirectiveTextPartsWithNative(text: string): ClockDirectiveTextPart[];
|
package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { isNativeDisabledByEnv, makeNativeRequiredError } from './native-router-hotpath-policy.js';
|
|
2
|
+
import { loadNativeRouterHotpathBindingForInternalUse } from './native-router-hotpath.js';
|
|
3
|
+
function parsePositiveInt(value) {
|
|
4
|
+
const parsed = Number(value);
|
|
5
|
+
if (!Number.isFinite(parsed)) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
const floored = Math.floor(parsed);
|
|
9
|
+
return floored > 0 ? floored : undefined;
|
|
10
|
+
}
|
|
11
|
+
function parseRecurrence(value) {
|
|
12
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const row = value;
|
|
16
|
+
const kind = typeof row.kind === 'string' ? row.kind.trim().toLowerCase() : '';
|
|
17
|
+
if (kind !== 'daily' && kind !== 'weekly' && kind !== 'interval') {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const maxRuns = parsePositiveInt(row.maxRuns);
|
|
21
|
+
if (!maxRuns) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
if (kind === 'interval') {
|
|
25
|
+
const everyMinutes = parsePositiveInt(row.everyMinutes);
|
|
26
|
+
if (!everyMinutes) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return { kind, maxRuns, everyMinutes };
|
|
30
|
+
}
|
|
31
|
+
return { kind, maxRuns };
|
|
32
|
+
}
|
|
33
|
+
function parseCandidateRow(value) {
|
|
34
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const row = value;
|
|
38
|
+
const dueAt = typeof row.dueAt === 'string' ? row.dueAt.trim() : '';
|
|
39
|
+
const task = typeof row.task === 'string' ? row.task.trim() : '';
|
|
40
|
+
if (!dueAt || !task) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const recurrence = parseRecurrence(row.recurrence);
|
|
44
|
+
if (row.recurrence !== undefined && !recurrence) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return recurrence ? { dueAt, task, recurrence } : { dueAt, task };
|
|
48
|
+
}
|
|
49
|
+
function parseNativeCandidatePayload(raw) {
|
|
50
|
+
try {
|
|
51
|
+
return parseCandidateRow(JSON.parse(raw));
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function parseNativeTextPart(value) {
|
|
58
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const row = value;
|
|
62
|
+
const kind = typeof row.kind === 'string' ? row.kind.trim().toLowerCase() : '';
|
|
63
|
+
if (kind === 'text') {
|
|
64
|
+
const text = typeof row.text === 'string' ? row.text : '';
|
|
65
|
+
return { kind: 'text', text };
|
|
66
|
+
}
|
|
67
|
+
if (kind !== 'directive') {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const full = typeof row.full === 'string' ? row.full : '';
|
|
71
|
+
if (!full) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const candidateRaw = row.candidate;
|
|
75
|
+
if (candidateRaw === undefined || candidateRaw === null) {
|
|
76
|
+
return { kind: 'directive', full };
|
|
77
|
+
}
|
|
78
|
+
const candidate = parseCandidateRow(candidateRaw);
|
|
79
|
+
if (!candidate) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return { kind: 'directive', full, candidate };
|
|
83
|
+
}
|
|
84
|
+
function parseNativeTextPartsPayload(raw) {
|
|
85
|
+
try {
|
|
86
|
+
const parsed = JSON.parse(raw);
|
|
87
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const row = parsed;
|
|
91
|
+
const partsRaw = Array.isArray(row.parts) ? row.parts : null;
|
|
92
|
+
if (!partsRaw) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const parts = [];
|
|
96
|
+
for (const item of partsRaw) {
|
|
97
|
+
const part = parseNativeTextPart(item);
|
|
98
|
+
if (!part) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
parts.push(part);
|
|
102
|
+
}
|
|
103
|
+
return parts;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function toErrorReason(error) {
|
|
110
|
+
return error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
111
|
+
}
|
|
112
|
+
function requireNativeFunction(capability, exportName) {
|
|
113
|
+
if (isNativeDisabledByEnv()) {
|
|
114
|
+
throw makeNativeRequiredError(capability, 'native disabled');
|
|
115
|
+
}
|
|
116
|
+
const binding = loadNativeRouterHotpathBindingForInternalUse();
|
|
117
|
+
const fn = binding?.[exportName];
|
|
118
|
+
if (typeof fn !== 'function') {
|
|
119
|
+
throw makeNativeRequiredError(capability);
|
|
120
|
+
}
|
|
121
|
+
return fn;
|
|
122
|
+
}
|
|
123
|
+
export function parseClockScheduleDirectiveCandidateWithNative(payload) {
|
|
124
|
+
const capability = 'parseClockScheduleDirectiveCandidateJson';
|
|
125
|
+
const fn = requireNativeFunction(capability, capability);
|
|
126
|
+
let raw;
|
|
127
|
+
try {
|
|
128
|
+
raw = fn(payload);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
throw makeNativeRequiredError(capability, toErrorReason(error));
|
|
132
|
+
}
|
|
133
|
+
if (typeof raw !== 'string' || !raw) {
|
|
134
|
+
throw makeNativeRequiredError(capability, 'empty result');
|
|
135
|
+
}
|
|
136
|
+
if (raw.trim() === 'null') {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const parsed = parseNativeCandidatePayload(raw);
|
|
140
|
+
if (!parsed) {
|
|
141
|
+
throw makeNativeRequiredError(capability, 'invalid payload');
|
|
142
|
+
}
|
|
143
|
+
return parsed;
|
|
144
|
+
}
|
|
145
|
+
export function extractClockScheduleDirectiveTextPartsWithNative(text) {
|
|
146
|
+
const capability = 'extractClockScheduleDirectiveTextPartsJson';
|
|
147
|
+
const fn = requireNativeFunction(capability, capability);
|
|
148
|
+
let raw;
|
|
149
|
+
try {
|
|
150
|
+
raw = fn(String(text || ''));
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
throw makeNativeRequiredError(capability, toErrorReason(error));
|
|
154
|
+
}
|
|
155
|
+
if (typeof raw !== 'string' || !raw) {
|
|
156
|
+
throw makeNativeRequiredError(capability, 'empty result');
|
|
157
|
+
}
|
|
158
|
+
const parsed = parseNativeTextPartsPayload(raw);
|
|
159
|
+
if (!parsed) {
|
|
160
|
+
throw makeNativeRequiredError(capability, 'invalid payload');
|
|
161
|
+
}
|
|
162
|
+
return parsed;
|
|
163
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ClockScheduleDirectiveCandidate } from './native-chat-process-clock-directive-parser.js';
|
|
2
|
+
export type NativeClockReminderDirectiveExtractionPayload = {
|
|
3
|
+
hadClear: boolean;
|
|
4
|
+
directiveCandidates: ClockScheduleDirectiveCandidate[];
|
|
5
|
+
baseMessages: unknown[];
|
|
6
|
+
};
|
|
7
|
+
export declare function extractClockReminderDirectivesWithNative(messages: unknown[]): NativeClockReminderDirectiveExtractionPayload;
|
package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { failNativeRequired, isNativeDisabledByEnv } from './native-router-hotpath-policy.js';
|
|
2
|
+
import { loadNativeRouterHotpathBindingForInternalUse } from './native-router-hotpath.js';
|
|
3
|
+
function parseCandidate(value) {
|
|
4
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const row = value;
|
|
8
|
+
const dueAt = typeof row.dueAt === 'string' ? row.dueAt.trim() : '';
|
|
9
|
+
const task = typeof row.task === 'string' ? row.task.trim() : '';
|
|
10
|
+
if (!dueAt || !task) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const recurrenceRaw = row.recurrence;
|
|
14
|
+
if (recurrenceRaw === undefined || recurrenceRaw === null) {
|
|
15
|
+
return { dueAt, task };
|
|
16
|
+
}
|
|
17
|
+
if (!recurrenceRaw || typeof recurrenceRaw !== 'object' || Array.isArray(recurrenceRaw)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const recurrence = recurrenceRaw;
|
|
21
|
+
const kind = typeof recurrence.kind === 'string' ? recurrence.kind.trim() : '';
|
|
22
|
+
const maxRuns = Number(recurrence.maxRuns);
|
|
23
|
+
if (!Number.isFinite(maxRuns) || Math.floor(maxRuns) <= 0) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (kind !== 'daily' && kind !== 'weekly' && kind !== 'interval') {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (kind === 'interval') {
|
|
30
|
+
const everyMinutes = Number(recurrence.everyMinutes);
|
|
31
|
+
if (!Number.isFinite(everyMinutes) || Math.floor(everyMinutes) <= 0) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
dueAt,
|
|
36
|
+
task,
|
|
37
|
+
recurrence: {
|
|
38
|
+
kind,
|
|
39
|
+
maxRuns: Math.floor(maxRuns),
|
|
40
|
+
everyMinutes: Math.floor(everyMinutes)
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
dueAt,
|
|
46
|
+
task,
|
|
47
|
+
recurrence: {
|
|
48
|
+
kind,
|
|
49
|
+
maxRuns: Math.floor(maxRuns)
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function parsePayload(raw) {
|
|
54
|
+
try {
|
|
55
|
+
const parsed = JSON.parse(raw);
|
|
56
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const row = parsed;
|
|
60
|
+
const hadClear = row.hadClear === true;
|
|
61
|
+
const baseMessages = Array.isArray(row.baseMessages) ? row.baseMessages : null;
|
|
62
|
+
const directiveCandidatesRaw = Array.isArray(row.directiveCandidates) ? row.directiveCandidates : null;
|
|
63
|
+
if (!baseMessages || !directiveCandidatesRaw) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const directiveCandidates = [];
|
|
67
|
+
for (const entry of directiveCandidatesRaw) {
|
|
68
|
+
const candidate = parseCandidate(entry);
|
|
69
|
+
if (!candidate) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
directiveCandidates.push(candidate);
|
|
73
|
+
}
|
|
74
|
+
return { hadClear, directiveCandidates, baseMessages };
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export function extractClockReminderDirectivesWithNative(messages) {
|
|
81
|
+
const capability = 'extractClockReminderDirectivesJson';
|
|
82
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
83
|
+
if (isNativeDisabledByEnv()) {
|
|
84
|
+
return fail('native disabled');
|
|
85
|
+
}
|
|
86
|
+
const binding = loadNativeRouterHotpathBindingForInternalUse();
|
|
87
|
+
const fn = binding?.extractClockReminderDirectivesJson;
|
|
88
|
+
if (typeof fn !== 'function') {
|
|
89
|
+
return fail();
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const raw = fn(JSON.stringify(messages));
|
|
93
|
+
if (typeof raw !== 'string' || !raw) {
|
|
94
|
+
return fail('empty result');
|
|
95
|
+
}
|
|
96
|
+
const parsed = parsePayload(raw);
|
|
97
|
+
return parsed ?? fail('invalid payload');
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
101
|
+
return fail(reason);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type NativeGuardedClockScheduleItem = {
|
|
2
|
+
dueAtMs: number;
|
|
3
|
+
setBy?: string;
|
|
4
|
+
task: string;
|
|
5
|
+
recurrence?: unknown;
|
|
6
|
+
notBeforeRequestId?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function buildGuardedClockScheduleItemWithNative(marker: unknown, requestId: string, dueWindowMs: number, nowMs: number): NativeGuardedClockScheduleItem;
|
|
9
|
+
export declare function normalizeDueInjectTextWithNative(value: unknown): string;
|
|
10
|
+
export declare function shouldReserveClockDueReminderWithNative(hadClear: boolean, sessionId: string | null): boolean;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { failNativeRequired, isNativeDisabledByEnv } from './native-router-hotpath-policy.js';
|
|
2
|
+
import { loadNativeRouterHotpathBindingForInternalUse } from './native-router-hotpath.js';
|
|
3
|
+
function parseGuardedItem(raw) {
|
|
4
|
+
try {
|
|
5
|
+
const parsed = JSON.parse(raw);
|
|
6
|
+
if (parsed === null) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const row = parsed;
|
|
13
|
+
const dueAtMs = Number(row.dueAtMs);
|
|
14
|
+
const setBy = typeof row.setBy === 'string' ? row.setBy : '';
|
|
15
|
+
const task = typeof row.task === 'string' ? row.task : '';
|
|
16
|
+
if (!Number.isFinite(dueAtMs) || !task.trim()) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const notBeforeRequestId = typeof row.notBeforeRequestId === 'string' && row.notBeforeRequestId.trim()
|
|
20
|
+
? row.notBeforeRequestId
|
|
21
|
+
: undefined;
|
|
22
|
+
return {
|
|
23
|
+
dueAtMs: Math.floor(dueAtMs),
|
|
24
|
+
...(setBy.trim() ? { setBy } : {}),
|
|
25
|
+
task,
|
|
26
|
+
...(row.recurrence !== undefined ? { recurrence: row.recurrence } : {}),
|
|
27
|
+
...(notBeforeRequestId ? { notBeforeRequestId } : {})
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function parseJsonString(raw) {
|
|
35
|
+
try {
|
|
36
|
+
const parsed = JSON.parse(raw);
|
|
37
|
+
return typeof parsed === 'string' ? parsed : null;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function buildGuardedClockScheduleItemWithNative(marker, requestId, dueWindowMs, nowMs) {
|
|
44
|
+
const capability = 'buildGuardedClockScheduleItemJson';
|
|
45
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
46
|
+
if (isNativeDisabledByEnv()) {
|
|
47
|
+
return fail('native disabled');
|
|
48
|
+
}
|
|
49
|
+
const binding = loadNativeRouterHotpathBindingForInternalUse();
|
|
50
|
+
const fn = binding?.buildGuardedClockScheduleItemJson;
|
|
51
|
+
if (typeof fn !== 'function') {
|
|
52
|
+
return fail();
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const raw = fn(JSON.stringify(marker ?? null), String(requestId || ''), Number.isFinite(dueWindowMs) ? dueWindowMs : 0, Number.isFinite(nowMs) ? nowMs : 0);
|
|
56
|
+
if (typeof raw !== 'string' || !raw) {
|
|
57
|
+
return fail('empty result');
|
|
58
|
+
}
|
|
59
|
+
const parsed = parseGuardedItem(raw);
|
|
60
|
+
return parsed ?? fail('invalid payload');
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
64
|
+
return fail(reason);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function normalizeDueInjectTextWithNative(value) {
|
|
68
|
+
const capability = 'normalizeDueInjectTextJson';
|
|
69
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
70
|
+
if (isNativeDisabledByEnv()) {
|
|
71
|
+
return fail('native disabled');
|
|
72
|
+
}
|
|
73
|
+
const binding = loadNativeRouterHotpathBindingForInternalUse();
|
|
74
|
+
const fn = binding?.normalizeDueInjectTextJson;
|
|
75
|
+
if (typeof fn !== 'function') {
|
|
76
|
+
return fail();
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const raw = fn(JSON.stringify(value ?? null));
|
|
80
|
+
if (typeof raw !== 'string' || !raw) {
|
|
81
|
+
return fail('empty result');
|
|
82
|
+
}
|
|
83
|
+
const parsed = parseJsonString(raw);
|
|
84
|
+
return parsed ?? fail('invalid payload');
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
88
|
+
return fail(reason);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export function shouldReserveClockDueReminderWithNative(hadClear, sessionId) {
|
|
92
|
+
const capability = 'shouldReserveClockDueReminderJson';
|
|
93
|
+
const fail = (reason) => failNativeRequired(capability, reason);
|
|
94
|
+
if (isNativeDisabledByEnv()) {
|
|
95
|
+
return fail('native disabled');
|
|
96
|
+
}
|
|
97
|
+
const binding = loadNativeRouterHotpathBindingForInternalUse();
|
|
98
|
+
const fn = binding?.shouldReserveClockDueReminderJson;
|
|
99
|
+
if (typeof fn !== 'function') {
|
|
100
|
+
return fail();
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const raw = fn(hadClear === true, String(sessionId ?? ''));
|
|
104
|
+
return raw === true;
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
const reason = error instanceof Error ? error.message : String(error ?? 'unknown');
|
|
108
|
+
return fail(reason);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function resolveClockConfigWithNative(raw: unknown, rawIsUndefined: boolean): Record<string, unknown> | null;
|
|
2
|
+
export declare function resolveClockSessionScopeWithNative(primary: Record<string, unknown> | null | undefined, fallback: Record<string, unknown> | null | undefined): string | null;
|
|
3
|
+
export declare function buildClockMarkerScheduleMessagesWithNative(requestId: string, markerIndex: number, marker: Record<string, unknown>, payload: Record<string, unknown>): unknown[];
|
|
4
|
+
export declare function findLastUserMessageIndexWithNative(messages: unknown[]): number;
|
|
5
|
+
export declare function injectTimeTagIntoMessagesWithNative(messages: unknown[], timeTagLine: string): unknown[];
|
|
6
|
+
export declare function buildDueReminderUserMessageWithNative(reservation: unknown, dueInjectText: string): unknown;
|
|
7
|
+
export declare function buildClockReminderMetadataWithNative(nextRequestMetadata: unknown, metadata: Record<string, unknown>, dueUserMessage: unknown, reservation: unknown): Record<string, unknown>;
|
|
8
|
+
export declare function buildClockReminderMessagesWithNative(baseMessages: unknown[], markerToolMessages: unknown[], dueUserMessage: unknown, timeTagLine: string): unknown[];
|