@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,5 +1,5 @@
|
|
|
1
1
|
import { analyzeMediaAttachments, detectExtendedThinkingKeyword, detectKeyword, extractMessageText, getLatestMessageRole, } from './message-utils.js';
|
|
2
|
-
import {
|
|
2
|
+
import { extractAntigravityGeminiSessionIdWithNative } from './engine-selection/native-router-hotpath.js';
|
|
3
3
|
import { detectCodingTool, detectLastAssistantToolCategory, detectVisionTool, detectWebSearchToolDeclared, detectWebTool, extractMeaningfulDeclaredToolNames } from './tool-signals.js';
|
|
4
4
|
import { computeRequestTokens } from './token-estimator.js';
|
|
5
5
|
const THINKING_KEYWORDS = ['let me think', 'chain of thought', 'cot', 'reason step', 'deliberate'];
|
|
@@ -12,7 +12,7 @@ export function buildRoutingFeatures(request, metadata) {
|
|
|
12
12
|
const text = msg ? extractMessageText(msg) : '';
|
|
13
13
|
return { role, parts: [{ text }] };
|
|
14
14
|
});
|
|
15
|
-
return
|
|
15
|
+
return extractAntigravityGeminiSessionIdWithNative({ contents });
|
|
16
16
|
}
|
|
17
17
|
catch {
|
|
18
18
|
return undefined;
|
|
@@ -10,6 +10,8 @@ export interface RoutingInstruction {
|
|
|
10
10
|
stopMessageText?: string;
|
|
11
11
|
stopMessageMaxRepeats?: number;
|
|
12
12
|
stopMessageStageMode?: 'on' | 'off' | 'auto';
|
|
13
|
+
stopMessageAiMode?: 'on' | 'off';
|
|
14
|
+
stopMessageSource?: string;
|
|
13
15
|
/**
|
|
14
16
|
* True when the instruction is parsed from an older user message
|
|
15
17
|
* (not the latest user turn in current request).
|
|
@@ -57,14 +59,10 @@ export interface RoutingInstructionState {
|
|
|
57
59
|
stopMessageUsed?: number;
|
|
58
60
|
stopMessageUpdatedAt?: number;
|
|
59
61
|
stopMessageLastUsedAt?: number;
|
|
60
|
-
stopMessageStage?: string;
|
|
61
62
|
stopMessageStageMode?: 'on' | 'off' | 'auto';
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
stopMessageAssignedIssueId?: string;
|
|
66
|
-
stopMessageAssignedIssueSource?: 'in_progress' | 'ready' | 'open';
|
|
67
|
-
stopMessageNoTaskSummaryUsed?: boolean;
|
|
63
|
+
stopMessageAiMode?: 'on' | 'off';
|
|
64
|
+
stopMessageAiSeedPrompt?: string;
|
|
65
|
+
stopMessageAiHistory?: Array<Record<string, unknown>>;
|
|
68
66
|
preCommandSource?: string;
|
|
69
67
|
preCommandScriptPath?: string;
|
|
70
68
|
preCommandUpdatedAt?: number;
|
|
@@ -5,41 +5,24 @@ import { parsePreCommandInstruction } from './routing-pre-command-parser.js';
|
|
|
5
5
|
import { applyPreCommandInstructionToState, clearPreCommandState } from './routing-pre-command-actions.js';
|
|
6
6
|
import { deserializeStopMessageState, serializeStopMessageState } from './routing-stop-message-state-codec.js';
|
|
7
7
|
import { deserializePreCommandState, serializePreCommandState } from './routing-pre-command-state-codec.js';
|
|
8
|
+
const ROUTING_INSTRUCTION_MARKER_PATTERN = /<\*\*[\s\S]*?\*\*>/;
|
|
9
|
+
const ROUTING_INSTRUCTION_MARKER_GLOBAL_PATTERN = /<\*\*[\s\S]*?\*\*>/g;
|
|
8
10
|
export function parseRoutingInstructions(messages) {
|
|
9
11
|
const instructions = [];
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (!message || message.role !== 'user') {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
if (lastUserIndex < 0) {
|
|
22
|
-
lastUserIndex = idx;
|
|
23
|
-
}
|
|
24
|
-
const content = extractMessageText(message);
|
|
25
|
-
if (!content) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
const candidate = stripCodeSegments(content);
|
|
29
|
-
if (!candidate) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (!/<\*\*[^*]+\*\*>/.test(candidate)) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
sanitized = candidate;
|
|
36
|
-
sanitizedIndex = idx;
|
|
37
|
-
break;
|
|
12
|
+
// 只解析“当前最新一条消息”中的 marker,避免历史 user marker 在后续轮次被重复回放。
|
|
13
|
+
const latestMessage = messages.length > 0 ? messages[messages.length - 1] : undefined;
|
|
14
|
+
if (!latestMessage || latestMessage.role !== 'user') {
|
|
15
|
+
return instructions;
|
|
16
|
+
}
|
|
17
|
+
const content = extractMessageText(latestMessage);
|
|
18
|
+
if (!content) {
|
|
19
|
+
return instructions;
|
|
38
20
|
}
|
|
39
|
-
|
|
21
|
+
const sanitized = stripCodeSegments(content);
|
|
22
|
+
if (!sanitized || !ROUTING_INSTRUCTION_MARKER_PATTERN.test(sanitized)) {
|
|
40
23
|
return instructions;
|
|
41
24
|
}
|
|
42
|
-
const regex = /<\*\*([
|
|
25
|
+
const regex = /<\*\*([\s\S]*?)\*\*>/g;
|
|
43
26
|
let match;
|
|
44
27
|
while ((match = regex.exec(sanitized)) !== null) {
|
|
45
28
|
const instruction = match[1].trim();
|
|
@@ -50,27 +33,11 @@ export function parseRoutingInstructions(messages) {
|
|
|
50
33
|
for (const segment of segments) {
|
|
51
34
|
const parsed = parseSingleInstruction(segment);
|
|
52
35
|
if (parsed) {
|
|
53
|
-
|
|
54
|
-
sanitizedIndex >= 0 &&
|
|
55
|
-
sanitizedIndex !== lastUserIndex;
|
|
56
|
-
const normalizedParsed = fromHistoricalUserMessage &&
|
|
57
|
-
(parsed.type === 'stopMessageSet' ||
|
|
58
|
-
parsed.type === 'stopMessageMode' ||
|
|
59
|
-
parsed.type === 'stopMessageClear')
|
|
60
|
-
? { ...parsed, fromHistoricalUserMessage: true }
|
|
61
|
-
: parsed;
|
|
62
|
-
// preCommand 是强副作用命令(执行本地脚本),仅允许从 latest user message 生效。
|
|
63
|
-
if ((normalizedParsed.type === 'preCommandSet' || normalizedParsed.type === 'preCommandClear') &&
|
|
64
|
-
lastUserIndex >= 0 &&
|
|
65
|
-
sanitizedIndex >= 0 &&
|
|
66
|
-
sanitizedIndex !== lastUserIndex) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
instructions.push(normalizedParsed);
|
|
36
|
+
instructions.push(parsed);
|
|
70
37
|
}
|
|
71
38
|
}
|
|
72
39
|
}
|
|
73
|
-
return instructions;
|
|
40
|
+
return normalizeStopMessageInstructionPrecedence(instructions);
|
|
74
41
|
}
|
|
75
42
|
/**
|
|
76
43
|
* 解析并预处理路由指令,优先处理 clear 指令,确保新指令能够覆盖旧状态。
|
|
@@ -115,10 +82,14 @@ function expandInstructionSegments(instruction) {
|
|
|
115
82
|
if (!trimmed) {
|
|
116
83
|
return [];
|
|
117
84
|
}
|
|
85
|
+
const normalizedLeading = normalizeInstructionLeading(trimmed);
|
|
118
86
|
// stopMessage 指令需要整体解析,不能按逗号拆分,否则类似
|
|
119
87
|
// "<**stopMessage:\"继续\",3**>" 会被错误拆成 ["stopMessage:\"继续\"", "3"]。
|
|
120
|
-
if (/^stopMessage
|
|
121
|
-
return [
|
|
88
|
+
if (/^(?:"|')?stopMessage(?:"|')?\s*[:,]/i.test(normalizedLeading)) {
|
|
89
|
+
return [normalizeStopMessageCommandPrefix(normalizedLeading)];
|
|
90
|
+
}
|
|
91
|
+
if (/^precommand(?:\s*:|$)/i.test(normalizedLeading)) {
|
|
92
|
+
return [normalizedLeading];
|
|
122
93
|
}
|
|
123
94
|
const prefix = trimmed[0];
|
|
124
95
|
if (prefix === '!' || prefix === '#' || prefix === '@') {
|
|
@@ -128,7 +99,12 @@ function expandInstructionSegments(instruction) {
|
|
|
128
99
|
.filter((token) => token.length > 0)
|
|
129
100
|
.map((token) => `${prefix}${token}`);
|
|
130
101
|
}
|
|
131
|
-
|
|
102
|
+
const splitTokens = splitInstructionTargets(trimmed);
|
|
103
|
+
const recoveredStopMessage = recoverSplitStopMessageInstruction(splitTokens);
|
|
104
|
+
if (recoveredStopMessage) {
|
|
105
|
+
return [recoveredStopMessage];
|
|
106
|
+
}
|
|
107
|
+
return splitTokens;
|
|
132
108
|
}
|
|
133
109
|
function splitInstructionTargets(content) {
|
|
134
110
|
return content
|
|
@@ -136,6 +112,33 @@ function splitInstructionTargets(content) {
|
|
|
136
112
|
.map((segment) => segment.trim())
|
|
137
113
|
.filter((segment) => segment.length > 0);
|
|
138
114
|
}
|
|
115
|
+
function normalizeInstructionLeading(content) {
|
|
116
|
+
// Remove common zero-width prefixes that may be injected by client/editor copies.
|
|
117
|
+
return content.replace(/^[\u200B-\u200D\u2060\uFEFF]+/, '').trimStart();
|
|
118
|
+
}
|
|
119
|
+
function normalizeStopMessageCommandPrefix(content) {
|
|
120
|
+
const normalized = normalizeInstructionLeading(content);
|
|
121
|
+
return normalized.replace(/^(?:"|')?stopMessage(?:"|')?\s*([:,])/i, 'stopMessage$1');
|
|
122
|
+
}
|
|
123
|
+
function normalizeSplitStopMessageHeadToken(token) {
|
|
124
|
+
return normalizeInstructionLeading(token)
|
|
125
|
+
.replace(/^["']+|["']+$/g, '')
|
|
126
|
+
.trim();
|
|
127
|
+
}
|
|
128
|
+
function recoverSplitStopMessageInstruction(tokens) {
|
|
129
|
+
if (!Array.isArray(tokens) || tokens.length < 2) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const head = normalizeSplitStopMessageHeadToken(tokens[0]);
|
|
133
|
+
if (!/^stopmessage$/i.test(head)) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
const tail = tokens.slice(1).join(',').trim();
|
|
137
|
+
if (!tail) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return `stopMessage:${tail}`;
|
|
141
|
+
}
|
|
139
142
|
function splitTargetAndProcessMode(rawTarget) {
|
|
140
143
|
const trimmed = typeof rawTarget === 'string' ? rawTarget.trim() : '';
|
|
141
144
|
if (!trimmed) {
|
|
@@ -179,7 +182,7 @@ function parseNamedTargetInstruction(instruction, prefix) {
|
|
|
179
182
|
return { type: prefix, ...normalized, ...(processMode ? { processMode } : {}) };
|
|
180
183
|
}
|
|
181
184
|
function parseSingleInstruction(instruction) {
|
|
182
|
-
if (instruction
|
|
185
|
+
if (/^clear$/i.test(instruction)) {
|
|
183
186
|
return { type: 'clear' };
|
|
184
187
|
}
|
|
185
188
|
const preCommandInstruction = parsePreCommandInstruction(instruction);
|
|
@@ -260,6 +263,33 @@ function parseSingleInstruction(instruction) {
|
|
|
260
263
|
}
|
|
261
264
|
return null;
|
|
262
265
|
}
|
|
266
|
+
function normalizeStopMessageInstructionPrecedence(instructions) {
|
|
267
|
+
if (!Array.isArray(instructions) || instructions.length <= 1) {
|
|
268
|
+
return instructions;
|
|
269
|
+
}
|
|
270
|
+
const isStopDirective = (inst) => inst.type === 'stopMessageSet' || inst.type === 'stopMessageMode' || inst.type === 'stopMessageClear';
|
|
271
|
+
const hasGlobalClear = instructions.some((inst) => inst.type === 'clear');
|
|
272
|
+
const hasStopClear = instructions.some((inst) => inst.type === 'stopMessageClear');
|
|
273
|
+
if (hasGlobalClear) {
|
|
274
|
+
const lastGlobalClearIndex = instructions.map((inst) => inst.type).lastIndexOf('clear');
|
|
275
|
+
return lastGlobalClearIndex >= 0 ? [instructions[lastGlobalClearIndex]] : instructions;
|
|
276
|
+
}
|
|
277
|
+
if (hasStopClear) {
|
|
278
|
+
const lastStopClearIndex = instructions.map((inst) => inst.type).lastIndexOf('stopMessageClear');
|
|
279
|
+
return lastStopClearIndex >= 0 ? [instructions[lastStopClearIndex]] : instructions;
|
|
280
|
+
}
|
|
281
|
+
let lastStopIndex = -1;
|
|
282
|
+
for (let idx = instructions.length - 1; idx >= 0; idx -= 1) {
|
|
283
|
+
if (isStopDirective(instructions[idx])) {
|
|
284
|
+
lastStopIndex = idx;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (lastStopIndex < 0) {
|
|
289
|
+
return instructions;
|
|
290
|
+
}
|
|
291
|
+
return instructions.filter((inst, idx) => !isStopDirective(inst) || idx === lastStopIndex);
|
|
292
|
+
}
|
|
263
293
|
function parseTarget(target) {
|
|
264
294
|
if (!target) {
|
|
265
295
|
return null;
|
|
@@ -375,14 +405,14 @@ export function applyRoutingInstructions(instructions, currentState) {
|
|
|
375
405
|
stopMessageUsed: currentState.stopMessageUsed,
|
|
376
406
|
stopMessageUpdatedAt: currentState.stopMessageUpdatedAt,
|
|
377
407
|
stopMessageLastUsedAt: currentState.stopMessageLastUsedAt,
|
|
378
|
-
stopMessageStage: currentState.stopMessageStage,
|
|
379
408
|
stopMessageStageMode: currentState.stopMessageStageMode,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
409
|
+
stopMessageAiMode: currentState.stopMessageAiMode,
|
|
410
|
+
stopMessageAiSeedPrompt: currentState.stopMessageAiSeedPrompt,
|
|
411
|
+
stopMessageAiHistory: Array.isArray(currentState.stopMessageAiHistory)
|
|
412
|
+
? currentState.stopMessageAiHistory.map((entry) => entry && typeof entry === 'object' && !Array.isArray(entry)
|
|
413
|
+
? { ...entry }
|
|
414
|
+
: {})
|
|
415
|
+
: undefined,
|
|
386
416
|
preCommandSource: currentState.preCommandSource,
|
|
387
417
|
preCommandScriptPath: currentState.preCommandScriptPath,
|
|
388
418
|
preCommandUpdatedAt: currentState.preCommandUpdatedAt
|
|
@@ -534,7 +564,7 @@ export function cleanMessagesFromRoutingInstructions(messages) {
|
|
|
534
564
|
if (message.role !== 'user' || typeof message.content !== 'string') {
|
|
535
565
|
return message;
|
|
536
566
|
}
|
|
537
|
-
const cleanedContent = message.content.replace(
|
|
567
|
+
const cleanedContent = message.content.replace(ROUTING_INSTRUCTION_MARKER_GLOBAL_PATTERN, '').trim();
|
|
538
568
|
return {
|
|
539
569
|
...message,
|
|
540
570
|
content: cleanedContent
|
|
@@ -582,13 +612,10 @@ export function deserializeRoutingInstructionState(data) {
|
|
|
582
612
|
stopMessageSource: undefined,
|
|
583
613
|
stopMessageMaxRepeats: undefined,
|
|
584
614
|
stopMessageUsed: undefined,
|
|
585
|
-
stopMessageStage: undefined,
|
|
586
615
|
stopMessageStageMode: undefined,
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
stopMessageAssignedIssueSource: undefined,
|
|
591
|
-
stopMessageNoTaskSummaryUsed: undefined,
|
|
616
|
+
stopMessageAiMode: undefined,
|
|
617
|
+
stopMessageAiSeedPrompt: undefined,
|
|
618
|
+
stopMessageAiHistory: undefined,
|
|
592
619
|
preCommandSource: undefined,
|
|
593
620
|
preCommandScriptPath: undefined,
|
|
594
621
|
preCommandUpdatedAt: undefined
|
|
@@ -1,120 +1,99 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeStopMessageStageMode } from './routing-stop-message-state-codec.js';
|
|
2
|
+
import { applyStopMessageInstructionWithNative } from './engine-selection/native-virtual-router-stop-message-actions-semantics.js';
|
|
3
|
+
const STOP_MESSAGE_FIELDS = [
|
|
4
|
+
'stopMessageSource',
|
|
5
|
+
'stopMessageText',
|
|
6
|
+
'stopMessageMaxRepeats',
|
|
7
|
+
'stopMessageUsed',
|
|
8
|
+
'stopMessageUpdatedAt',
|
|
9
|
+
'stopMessageLastUsedAt',
|
|
10
|
+
'stopMessageStageMode',
|
|
11
|
+
'stopMessageAiMode',
|
|
12
|
+
'stopMessageAiSeedPrompt',
|
|
13
|
+
'stopMessageAiHistory'
|
|
14
|
+
];
|
|
15
|
+
const SKIP_PATCH_VALUE = Symbol('skipPatchValue');
|
|
2
16
|
export function applyStopMessageInstructionToState(instruction, state) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const shouldRearmForSource = instruction.fromHistoricalUserMessage
|
|
28
|
-
? !isSameInstruction
|
|
29
|
-
: shouldRearm;
|
|
30
|
-
state.stopMessageText = text;
|
|
31
|
-
state.stopMessageMaxRepeats = maxRepeats;
|
|
32
|
-
state.stopMessageSource = 'explicit';
|
|
33
|
-
if (targetMode) {
|
|
34
|
-
state.stopMessageStageMode = targetMode;
|
|
35
|
-
}
|
|
36
|
-
if (shouldRearmForSource) {
|
|
37
|
-
resetStopMessageRuntimeState(state, Date.now());
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
17
|
+
const nowMs = Date.now();
|
|
18
|
+
const before = snapshotStopMessageState(state);
|
|
19
|
+
const patch = applyStopMessageInstructionWithNative(instruction, before, nowMs);
|
|
20
|
+
applyStopMessagePatch(state, patch);
|
|
21
|
+
return patch.applied;
|
|
22
|
+
}
|
|
23
|
+
function snapshotStopMessageState(state) {
|
|
24
|
+
return {
|
|
25
|
+
stopMessageSource: state.stopMessageSource,
|
|
26
|
+
stopMessageText: state.stopMessageText,
|
|
27
|
+
stopMessageMaxRepeats: state.stopMessageMaxRepeats,
|
|
28
|
+
stopMessageUsed: state.stopMessageUsed,
|
|
29
|
+
stopMessageUpdatedAt: state.stopMessageUpdatedAt,
|
|
30
|
+
stopMessageLastUsedAt: state.stopMessageLastUsedAt,
|
|
31
|
+
stopMessageStageMode: state.stopMessageStageMode,
|
|
32
|
+
stopMessageAiMode: state.stopMessageAiMode,
|
|
33
|
+
stopMessageAiSeedPrompt: state.stopMessageAiSeedPrompt,
|
|
34
|
+
stopMessageAiHistory: Array.isArray(state.stopMessageAiHistory) ? cloneHistory(state.stopMessageAiHistory) : undefined
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function applyStopMessagePatch(state, patch) {
|
|
38
|
+
for (const field of patch.unset) {
|
|
39
|
+
if (!STOP_MESSAGE_FIELDS.includes(field)) {
|
|
40
|
+
continue;
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
: undefined;
|
|
74
|
-
const shouldRearm = previousMode !== mode ||
|
|
75
|
-
previousMax !== nextMax ||
|
|
76
|
-
typeof state.stopMessageUsed !== 'number' ||
|
|
77
|
-
!Number.isFinite(state.stopMessageUsed);
|
|
78
|
-
const shouldRearmForSource = instruction.fromHistoricalUserMessage
|
|
79
|
-
? (previousMode !== mode || previousMax !== nextMax || typeof state.stopMessageUsed !== 'number' || !Number.isFinite(state.stopMessageUsed))
|
|
80
|
-
: shouldRearm;
|
|
81
|
-
if (shouldRearmForSource) {
|
|
82
|
-
resetStopMessageRuntimeState(state, Date.now());
|
|
42
|
+
state[field] = undefined;
|
|
43
|
+
}
|
|
44
|
+
for (const [field, rawValue] of Object.entries(patch.set)) {
|
|
45
|
+
const value = coerceStopMessagePatchValue(field, rawValue);
|
|
46
|
+
if (value === SKIP_PATCH_VALUE) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
state[field] = value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function coerceStopMessagePatchValue(field, value) {
|
|
53
|
+
switch (field) {
|
|
54
|
+
case 'stopMessageSource':
|
|
55
|
+
case 'stopMessageText':
|
|
56
|
+
case 'stopMessageAiSeedPrompt':
|
|
57
|
+
return typeof value === 'string' ? value : SKIP_PATCH_VALUE;
|
|
58
|
+
case 'stopMessageStageMode': {
|
|
59
|
+
const normalized = normalizeStopMessageStageMode(value);
|
|
60
|
+
return normalized ?? SKIP_PATCH_VALUE;
|
|
61
|
+
}
|
|
62
|
+
case 'stopMessageAiMode': {
|
|
63
|
+
const normalizedAiMode = normalizeStopMessageAiMode(value);
|
|
64
|
+
return normalizedAiMode ?? SKIP_PATCH_VALUE;
|
|
65
|
+
}
|
|
66
|
+
case 'stopMessageMaxRepeats':
|
|
67
|
+
case 'stopMessageUsed':
|
|
68
|
+
case 'stopMessageUpdatedAt':
|
|
69
|
+
case 'stopMessageLastUsedAt':
|
|
70
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : SKIP_PATCH_VALUE;
|
|
71
|
+
case 'stopMessageAiHistory': {
|
|
72
|
+
if (!Array.isArray(value)) {
|
|
73
|
+
return SKIP_PATCH_VALUE;
|
|
83
74
|
}
|
|
84
|
-
return
|
|
75
|
+
return cloneHistory(value);
|
|
85
76
|
}
|
|
86
|
-
case 'stopMessageClear':
|
|
87
|
-
clearStopMessageState(state);
|
|
88
|
-
return true;
|
|
89
|
-
default:
|
|
90
|
-
return false;
|
|
91
77
|
}
|
|
78
|
+
return SKIP_PATCH_VALUE;
|
|
92
79
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
state.stopMessageAssignedIssueSource = undefined;
|
|
103
|
-
state.stopMessageNoTaskSummaryUsed = undefined;
|
|
80
|
+
function cloneHistory(value) {
|
|
81
|
+
const out = [];
|
|
82
|
+
for (const item of value) {
|
|
83
|
+
if (!item || typeof item !== 'object' || Array.isArray(item)) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
out.push({ ...item });
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
104
89
|
}
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
state.stopMessageObservationHash = undefined;
|
|
115
|
-
state.stopMessageObservationStableCount = undefined;
|
|
116
|
-
state.stopMessageBdWorkState = undefined;
|
|
117
|
-
state.stopMessageAssignedIssueId = undefined;
|
|
118
|
-
state.stopMessageAssignedIssueSource = undefined;
|
|
119
|
-
state.stopMessageNoTaskSummaryUsed = undefined;
|
|
90
|
+
function normalizeStopMessageAiMode(value) {
|
|
91
|
+
if (typeof value !== 'string') {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
const normalized = value.trim().toLowerCase();
|
|
95
|
+
if (normalized === 'on' || normalized === 'off') {
|
|
96
|
+
return normalized;
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
120
99
|
}
|
|
@@ -1,142 +1,19 @@
|
|
|
1
|
-
import { resolveStopMessageText } from './stop-message-file-resolver.js';
|
|
1
|
+
import { isStopMessageFileReference, resolveStopMessageText } from './stop-message-file-resolver.js';
|
|
2
|
+
import { parseStopMessageInstructionWithNative } from './engine-selection/native-virtual-router-stop-message-semantics.js';
|
|
2
3
|
export const DEFAULT_STOP_MESSAGE_MAX_REPEATS = 10;
|
|
3
4
|
export function parseStopMessageInstruction(instruction) {
|
|
4
|
-
|
|
5
|
+
const resolved = parseStopMessageInstructionWithNative(instruction);
|
|
6
|
+
if (!resolved) {
|
|
5
7
|
return null;
|
|
6
8
|
}
|
|
7
|
-
|
|
8
|
-
if (!body) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
if (/^clear$/i.test(body)) {
|
|
9
|
+
if (resolved.kind === 'clear') {
|
|
12
10
|
return { type: 'stopMessageClear' };
|
|
13
11
|
}
|
|
14
|
-
const modeOnly = parseStopMessageModeWithOptionalRepeats(body);
|
|
15
|
-
if (modeOnly) {
|
|
16
|
-
return {
|
|
17
|
-
type: 'stopMessageMode',
|
|
18
|
-
stopMessageStageMode: modeOnly.mode,
|
|
19
|
-
...(typeof modeOnly.maxRepeats === 'number' ? { stopMessageMaxRepeats: modeOnly.maxRepeats } : {})
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
let text = '';
|
|
23
|
-
let maxRepeats = DEFAULT_STOP_MESSAGE_MAX_REPEATS;
|
|
24
|
-
let cursor = body;
|
|
25
|
-
let stageMode;
|
|
26
|
-
if (cursor[0] === '"') {
|
|
27
|
-
let escaped = false;
|
|
28
|
-
let endIndex = -1;
|
|
29
|
-
for (let i = 1; i < cursor.length; i += 1) {
|
|
30
|
-
const ch = cursor[i];
|
|
31
|
-
if (escaped) {
|
|
32
|
-
escaped = false;
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (ch === '\\') {
|
|
36
|
-
escaped = true;
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
if (ch === '"') {
|
|
40
|
-
endIndex = i;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (endIndex <= 0) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
const rawText = cursor.slice(1, endIndex);
|
|
48
|
-
text = rawText.replace(/\\"/g, '"');
|
|
49
|
-
cursor = cursor.slice(endIndex + 1).trim();
|
|
50
|
-
if (cursor.startsWith(',')) {
|
|
51
|
-
const tail = cursor.slice(1).trim();
|
|
52
|
-
const parsedTail = parseStopMessageTail(tail);
|
|
53
|
-
maxRepeats = parsedTail.maxRepeats;
|
|
54
|
-
stageMode = parsedTail.stageMode;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
const parts = cursor
|
|
59
|
-
.split(',')
|
|
60
|
-
.map((part) => part.trim())
|
|
61
|
-
.filter(Boolean);
|
|
62
|
-
if (!parts.length) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
text = parts[0];
|
|
66
|
-
const parsedTail = parseStopMessageTail(parts.slice(1));
|
|
67
|
-
maxRepeats = parsedTail.maxRepeats;
|
|
68
|
-
stageMode = parsedTail.stageMode;
|
|
69
|
-
}
|
|
70
|
-
if (!text) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
12
|
return {
|
|
74
13
|
type: 'stopMessageSet',
|
|
75
|
-
stopMessageText: resolveStopMessageText(text),
|
|
76
|
-
stopMessageMaxRepeats: maxRepeats,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
function parseStopMessageTail(input) {
|
|
81
|
-
const tokens = Array.isArray(input)
|
|
82
|
-
? input.map((part) => part.trim()).filter(Boolean)
|
|
83
|
-
: input
|
|
84
|
-
.split(',')
|
|
85
|
-
.map((part) => part.trim())
|
|
86
|
-
.filter(Boolean);
|
|
87
|
-
let maxRepeats = DEFAULT_STOP_MESSAGE_MAX_REPEATS;
|
|
88
|
-
let stageMode;
|
|
89
|
-
for (const token of tokens) {
|
|
90
|
-
const mode = parseStopMessageStageModeToken(token);
|
|
91
|
-
if (mode) {
|
|
92
|
-
stageMode = mode;
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
const parsed = Number.parseInt(token, 10);
|
|
96
|
-
if (!Number.isNaN(parsed) && parsed > 0) {
|
|
97
|
-
maxRepeats = parsed;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
maxRepeats,
|
|
102
|
-
...(stageMode ? { stageMode } : {})
|
|
14
|
+
stopMessageText: resolveStopMessageText(resolved.text),
|
|
15
|
+
stopMessageMaxRepeats: resolved.maxRepeats,
|
|
16
|
+
stopMessageSource: isStopMessageFileReference(resolved.text) ? 'explicit_file' : 'explicit_text',
|
|
17
|
+
...(resolved.aiMode ? { stopMessageAiMode: resolved.aiMode } : {})
|
|
103
18
|
};
|
|
104
19
|
}
|
|
105
|
-
function parseStopMessageModeWithOptionalRepeats(value) {
|
|
106
|
-
const normalized = value.trim().toLowerCase();
|
|
107
|
-
const match = normalized.match(/^(?:(?:stage|mode)\s*[:=]\s*)?(on|off|auto)\s*(?:,\s*(\d+)\s*)?$/i);
|
|
108
|
-
if (!match) {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
const token = match[1].trim().toLowerCase();
|
|
112
|
-
const mode = token === 'on' || token === 'off' || token === 'auto'
|
|
113
|
-
? token
|
|
114
|
-
: undefined;
|
|
115
|
-
if (!mode) {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
if (mode === 'off') {
|
|
119
|
-
return { mode };
|
|
120
|
-
}
|
|
121
|
-
const repeatToken = match[2];
|
|
122
|
-
if (!repeatToken) {
|
|
123
|
-
return { mode, maxRepeats: DEFAULT_STOP_MESSAGE_MAX_REPEATS };
|
|
124
|
-
}
|
|
125
|
-
const parsed = Number.parseInt(repeatToken, 10);
|
|
126
|
-
if (Number.isNaN(parsed) || parsed <= 0) {
|
|
127
|
-
return { mode, maxRepeats: DEFAULT_STOP_MESSAGE_MAX_REPEATS };
|
|
128
|
-
}
|
|
129
|
-
return { mode, maxRepeats: parsed };
|
|
130
|
-
}
|
|
131
|
-
function parseStopMessageStageModeToken(value) {
|
|
132
|
-
const normalized = value.trim().toLowerCase();
|
|
133
|
-
const match = normalized.match(/^(?:(?:stage|mode)\s*[:=]\s*)?(on|off|auto)$/i);
|
|
134
|
-
if (!match) {
|
|
135
|
-
return undefined;
|
|
136
|
-
}
|
|
137
|
-
const token = match[1].trim().toLowerCase();
|
|
138
|
-
if (token === 'on' || token === 'off' || token === 'auto') {
|
|
139
|
-
return token;
|
|
140
|
-
}
|
|
141
|
-
return undefined;
|
|
142
|
-
}
|
|
@@ -4,3 +4,4 @@ export declare function serializeStopMessageState(state: RoutingInstructionState
|
|
|
4
4
|
export declare function deserializeStopMessageState(data: Record<string, unknown>, state: RoutingInstructionState): void;
|
|
5
5
|
export declare function normalizeStopMessageStageMode(value: unknown): 'on' | 'off' | 'auto' | undefined;
|
|
6
6
|
export declare function ensureStopMessageModeMaxRepeats(state: RoutingInstructionState): boolean;
|
|
7
|
+
export declare function normalizeStopMessageAiMode(value: unknown): 'on' | 'off' | undefined;
|