@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
|
@@ -4,18 +4,14 @@ import { extractCapturedChatSeed } from './followup-request-builder.js';
|
|
|
4
4
|
import { readRuntimeMetadata } from '../../conversion/shared/runtime-metadata.js';
|
|
5
5
|
import { isStopEligibleForServerTool } from '../stop-gateway-context.js';
|
|
6
6
|
import { attachStopMessageCompareContext } from '../stop-message-compare-context.js';
|
|
7
|
-
import { extractStopMessageAutoResponseSnapshot,
|
|
8
|
-
import { getCapturedRequest, hasCompactionFlag, readServerToolFollowupFlowId, resolveClientConnectionState, resolveEntryEndpoint, resolveImplicitGeminiStopMessageSnapshot,
|
|
7
|
+
import { extractStopMessageAutoResponseSnapshot, renderStopMessageAutoFollowupViaAi, resolveStopMessageAiApprovedMarker, resolveStopMessageAiDoneMarker } from './stop-message-auto/iflow-followup.js';
|
|
8
|
+
import { getCapturedRequest, hasCompactionFlag, persistStopMessageState, readServerToolFollowupFlowId, resolveBdWorkingDirectoryForRecord, resolveClientConnectionState, resolveDefaultStopMessageSnapshot, resolveEntryEndpoint, resolveImplicitGeminiStopMessageSnapshot, resolveStopMessageSessionScope, resolveStickyKey, resolveStopMessageFollowupProviderKey } from './stop-message-auto/runtime-utils.js';
|
|
9
|
+
import { loadRoutingInstructionStateSync } from '../../router/virtual-router/sticky-session-store.js';
|
|
10
|
+
import { clearStopMessageState, createStopMessageState, resolveStopMessageSnapshot } from './stop-message-auto/routing-state.js';
|
|
9
11
|
export { extractBlockedReportFromMessagesForTests } from './stop-message-auto/blocked-report.js';
|
|
10
12
|
const STOPMESSAGE_DEBUG = (process.env.ROUTECODEX_STOPMESSAGE_DEBUG || '').trim() === '1';
|
|
11
|
-
const STOPMESSAGE_IMPLICIT_GEMINI =
|
|
12
|
-
const STOPMESSAGE_DEFAULT_ENABLED =
|
|
13
|
-
const raw = process.env.ROUTECODEX_STOPMESSAGE_DEFAULT_ENABLED;
|
|
14
|
-
if (typeof raw === 'string' && raw.trim().length > 0) {
|
|
15
|
-
return raw.trim() !== '0';
|
|
16
|
-
}
|
|
17
|
-
return process.env.NODE_ENV !== 'test';
|
|
18
|
-
})();
|
|
13
|
+
const STOPMESSAGE_IMPLICIT_GEMINI = false;
|
|
14
|
+
const STOPMESSAGE_DEFAULT_ENABLED = false;
|
|
19
15
|
const STOPMESSAGE_DEFAULT_TEXT = (() => {
|
|
20
16
|
const raw = process.env.ROUTECODEX_STOPMESSAGE_DEFAULT_TEXT;
|
|
21
17
|
return typeof raw === 'string' && raw.trim().length > 0 ? raw.trim() : '继续执行';
|
|
@@ -40,14 +36,113 @@ function debugLog(message, extra) {
|
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
38
|
const FLOW_ID = 'stop_message_flow';
|
|
39
|
+
function hasStopMessageDoneMarker(snapshot, marker) {
|
|
40
|
+
if (!snapshot || !marker) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const normalizedMarker = marker.trim();
|
|
44
|
+
if (!normalizedMarker) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
const candidates = [snapshot.assistantText, snapshot.reasoningText, snapshot.responseExcerpt];
|
|
48
|
+
return candidates.some((value) => typeof value === 'string' && value.includes(normalizedMarker));
|
|
49
|
+
}
|
|
50
|
+
function hasStopMessageMarkerLine(text, marker) {
|
|
51
|
+
const content = typeof text === 'string' ? text.trim() : '';
|
|
52
|
+
const normalizedMarker = typeof marker === 'string' ? marker.trim() : '';
|
|
53
|
+
if (!content || !normalizedMarker) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
const escapedMarker = normalizedMarker.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
57
|
+
const markerLinePattern = new RegExp(`(^|\\n)\\s*${escapedMarker}\\s*(?=\\n|$)`);
|
|
58
|
+
return markerLinePattern.test(content);
|
|
59
|
+
}
|
|
60
|
+
function readStopMessageStageMode(raw) {
|
|
61
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const value = raw.stopMessageStageMode;
|
|
65
|
+
if (typeof value !== 'string') {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const normalized = value.trim().toLowerCase();
|
|
69
|
+
if (normalized === 'on' || normalized === 'off' || normalized === 'auto') {
|
|
70
|
+
return normalized;
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
43
74
|
const STOP_MESSAGE_EXECUTION_DIRECTIVE = [
|
|
44
75
|
'执行策略(必须遵守):',
|
|
45
76
|
'- 禁止输出口播式状态汇报(如“继续执行中”“我会继续”)。',
|
|
46
77
|
'- 以当前上下文目标为准,优先推进可验证的工程动作,不要停留在任务管理操作。',
|
|
47
78
|
'- 优先完成真实动作(改代码/补测试/运行验证),再做简短汇报。',
|
|
79
|
+
'- 禁止连续执行纯只读/纯汇报动作(如 cargo llvm-cov report、cat/head/tail/rg/git status);若上一轮没有代码修改证据,本轮必须先完成写动作(修改文件或新增测试)。',
|
|
80
|
+
'- 覆盖率命令仅用于“写动作之后的验证”,不得作为本轮唯一或首要动作。',
|
|
81
|
+
'- 若预计等待超过 2 分钟,必须调用 clock.schedule 设置定时,不得只口头说明等待。',
|
|
82
|
+
'- 若仅需汇报任务进度,必须按顺序:先调用 CONTINUE execution(continue_execution,参数示例 {"reason":"progress_update"}),再做 <=5 行简短汇报,然后立即继续执行。',
|
|
48
83
|
'- 若遇阻塞,请按 JSON 输出结构化阻塞信息(type=blocked, summary, blocker, impact, next_action, evidence)。',
|
|
49
|
-
'- 如果即将返回 finish_reason=stop 或协议等价 end_turn,先调用 continue_execution 工具,不要直接结束会话。'
|
|
84
|
+
'- 如果即将返回 finish_reason=stop 或协议等价 end_turn,先调用 continue_execution 工具,不要直接结束会话。',
|
|
85
|
+
'- 仅当总体目标完成时,才允许停止。'
|
|
50
86
|
].join('\n');
|
|
87
|
+
const STOP_MESSAGE_AI_HISTORY_MAX = 8;
|
|
88
|
+
const STOP_MESSAGE_EXECUTION_APPEND = '请直接继续执行,不要进行状态汇总;优先写动作(改代码/补测试),覆盖率命令只用于写动作后的验证,不得连续只做汇报/只读检查;仅在完成一个阶段性任务或已完成总体目标时再停止并回复。';
|
|
89
|
+
function readStopMessageAiSeedPrompt(state) {
|
|
90
|
+
if (!state || typeof state !== 'object' || Array.isArray(state)) {
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
const raw = state.stopMessageAiSeedPrompt;
|
|
94
|
+
return typeof raw === 'string' ? raw.trim() : '';
|
|
95
|
+
}
|
|
96
|
+
function readStopMessageAiHistory(state) {
|
|
97
|
+
if (!state || typeof state !== 'object' || Array.isArray(state)) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
const raw = state.stopMessageAiHistory;
|
|
101
|
+
if (!Array.isArray(raw)) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
const normalized = [];
|
|
105
|
+
for (const entry of raw) {
|
|
106
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const record = entry;
|
|
110
|
+
const item = {};
|
|
111
|
+
if (typeof record.ts === 'number' && Number.isFinite(record.ts)) {
|
|
112
|
+
item.ts = Math.floor(record.ts);
|
|
113
|
+
}
|
|
114
|
+
if (typeof record.round === 'number' && Number.isFinite(record.round)) {
|
|
115
|
+
item.round = Math.max(0, Math.floor(record.round));
|
|
116
|
+
}
|
|
117
|
+
for (const key of ['assistantText', 'reasoningText', 'responseExcerpt', 'followupText']) {
|
|
118
|
+
const value = record[key];
|
|
119
|
+
if (typeof value === 'string' && value.trim()) {
|
|
120
|
+
item[key] = value.trim();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (Object.keys(item).length > 0) {
|
|
124
|
+
normalized.push(item);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return normalized.slice(-STOP_MESSAGE_AI_HISTORY_MAX);
|
|
128
|
+
}
|
|
129
|
+
function appendStopMessageAiHistory(history, item) {
|
|
130
|
+
const next = [...history, item].filter((entry) => entry && Object.keys(entry).length > 0);
|
|
131
|
+
return next.slice(-STOP_MESSAGE_AI_HISTORY_MAX);
|
|
132
|
+
}
|
|
133
|
+
function enforceStopMessageExecutionFollowupText(text, doneMarker) {
|
|
134
|
+
const rawBase = typeof text === 'string' && text.trim() ? text.trim() : '';
|
|
135
|
+
const marker = doneMarker && doneMarker.trim() ? doneMarker.trim() : '[STOPMESSAGE_DONE]';
|
|
136
|
+
const escapedMarker = marker.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
137
|
+
const markerLinePattern = new RegExp(`(^|\\n)\\s*${escapedMarker}\\s*(?=\\n|$)`, 'g');
|
|
138
|
+
const strippedBase = rawBase.replace(markerLinePattern, '$1').replace(/\n{3,}/g, '\n\n').trim();
|
|
139
|
+
const base = strippedBase || '继续执行';
|
|
140
|
+
let next = base;
|
|
141
|
+
if (!next.includes(STOP_MESSAGE_EXECUTION_APPEND)) {
|
|
142
|
+
next = `${next}\n\n${STOP_MESSAGE_EXECUTION_APPEND}`;
|
|
143
|
+
}
|
|
144
|
+
return next.trim();
|
|
145
|
+
}
|
|
51
146
|
const handler = async (ctx) => {
|
|
52
147
|
const record = ctx.adapterContext;
|
|
53
148
|
const rt = readRuntimeMetadata(ctx.adapterContext);
|
|
@@ -111,33 +206,160 @@ const handler = async (ctx) => {
|
|
|
111
206
|
return markSkip('skip_compaction_flag');
|
|
112
207
|
}
|
|
113
208
|
const connectionState = resolveClientConnectionState(record.clientConnectionState);
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
209
|
+
const strictSessionScope = resolveStopMessageSessionScope(record, rt);
|
|
210
|
+
if (!strictSessionScope) {
|
|
211
|
+
debugLog('skip_missing_session_scope');
|
|
212
|
+
return markSkip('skip_missing_session_scope');
|
|
213
|
+
}
|
|
214
|
+
const stickyKey = strictSessionScope || resolveStickyKey(record, rt);
|
|
215
|
+
let stickyState = stickyKey ? loadRoutingInstructionStateSync(stickyKey) : null;
|
|
216
|
+
let snapshot = resolveStopMessageSnapshot(stickyState);
|
|
217
|
+
if (!snapshot) {
|
|
218
|
+
snapshot = resolveStopMessageSnapshot(rt?.stopMessageState);
|
|
219
|
+
if (snapshot && stickyKey) {
|
|
220
|
+
stickyState = createStopMessageState(snapshot);
|
|
221
|
+
persistStopMessageState(stickyKey, stickyState);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const stickyMode = readStopMessageStageMode(stickyState);
|
|
225
|
+
const runtimeMode = readStopMessageStageMode(rt?.stopMessageState);
|
|
226
|
+
const explicitMode = stickyMode ?? runtimeMode;
|
|
227
|
+
if (!snapshot && explicitMode === 'off') {
|
|
228
|
+
debugLog('skip_explicit_mode_off', { stickyKey });
|
|
229
|
+
return markSkip('skip_explicit_mode_off', {
|
|
230
|
+
armed: true,
|
|
231
|
+
mode: 'off',
|
|
232
|
+
allowModeOnly: true,
|
|
233
|
+
textLength: 0,
|
|
234
|
+
maxRepeats: 0,
|
|
235
|
+
used: 0
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
if (!snapshot) {
|
|
239
|
+
const implicit = STOPMESSAGE_IMPLICIT_GEMINI
|
|
240
|
+
? resolveImplicitGeminiStopMessageSnapshot(ctx, record)
|
|
241
|
+
: null;
|
|
242
|
+
const defaultSnapshot = STOPMESSAGE_DEFAULT_ENABLED
|
|
243
|
+
? resolveDefaultStopMessageSnapshot(ctx, {
|
|
244
|
+
text: STOPMESSAGE_DEFAULT_TEXT,
|
|
245
|
+
maxRepeats: STOPMESSAGE_DEFAULT_MAX_REPEATS
|
|
246
|
+
})
|
|
247
|
+
: null;
|
|
248
|
+
const fallback = implicit
|
|
249
|
+
? {
|
|
250
|
+
text: implicit.text,
|
|
251
|
+
maxRepeats: implicit.maxRepeats,
|
|
252
|
+
used: implicit.used,
|
|
253
|
+
source: implicit.source,
|
|
254
|
+
updatedAt: implicit.updatedAt,
|
|
255
|
+
lastUsedAt: implicit.lastUsedAt,
|
|
256
|
+
stageMode: 'on'
|
|
257
|
+
}
|
|
258
|
+
: defaultSnapshot
|
|
259
|
+
? {
|
|
260
|
+
text: defaultSnapshot.text,
|
|
261
|
+
maxRepeats: defaultSnapshot.maxRepeats,
|
|
262
|
+
used: defaultSnapshot.used,
|
|
263
|
+
source: defaultSnapshot.source,
|
|
264
|
+
updatedAt: defaultSnapshot.updatedAt,
|
|
265
|
+
lastUsedAt: defaultSnapshot.lastUsedAt,
|
|
266
|
+
stageMode: 'on'
|
|
267
|
+
}
|
|
268
|
+
: null;
|
|
269
|
+
if (!fallback) {
|
|
270
|
+
if (!STOPMESSAGE_DEFAULT_ENABLED && !implicit) {
|
|
271
|
+
debugLog('skip_default_disabled');
|
|
272
|
+
return markSkip('skip_default_disabled', { armed: false, mode: 'off' });
|
|
273
|
+
}
|
|
274
|
+
debugLog('skip_no_stop_message_state');
|
|
275
|
+
return markSkip('skip_no_stop_message_state', { armed: false, mode: 'off' });
|
|
276
|
+
}
|
|
277
|
+
snapshot = fallback;
|
|
278
|
+
if (stickyKey) {
|
|
279
|
+
stickyState = createStopMessageState(snapshot);
|
|
280
|
+
persistStopMessageState(stickyKey, stickyState);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const mode = snapshot.stageMode ?? 'on';
|
|
284
|
+
if (mode === 'off') {
|
|
285
|
+
debugLog('skip_explicit_mode_off', { stickyKey });
|
|
286
|
+
return markSkip('skip_explicit_mode_off', {
|
|
287
|
+
armed: true,
|
|
288
|
+
mode: 'off',
|
|
289
|
+
allowModeOnly: true,
|
|
290
|
+
textLength: 0,
|
|
291
|
+
maxRepeats: 0,
|
|
292
|
+
used: 0
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
const text = typeof snapshot.text === 'string' ? snapshot.text.trim() : '';
|
|
296
|
+
const maxRepeats = typeof snapshot.maxRepeats === 'number' && Number.isFinite(snapshot.maxRepeats)
|
|
297
|
+
? Math.max(1, Math.floor(snapshot.maxRepeats))
|
|
298
|
+
: 0;
|
|
299
|
+
const aiMode = snapshot.aiMode === 'on' ? 'on' : 'off';
|
|
300
|
+
const used = typeof snapshot.used === 'number' && Number.isFinite(snapshot.used)
|
|
301
|
+
? Math.max(0, Math.floor(snapshot.used))
|
|
302
|
+
: 0;
|
|
127
303
|
updateCompare({
|
|
128
304
|
armed: true,
|
|
129
|
-
mode
|
|
130
|
-
allowModeOnly:
|
|
305
|
+
mode,
|
|
306
|
+
allowModeOnly: false,
|
|
131
307
|
textLength: text.length,
|
|
132
|
-
maxRepeats
|
|
133
|
-
used
|
|
308
|
+
maxRepeats,
|
|
309
|
+
used
|
|
134
310
|
});
|
|
311
|
+
if (used >= maxRepeats) {
|
|
312
|
+
if (stickyKey && stickyState) {
|
|
313
|
+
clearStopMessageState(stickyState, Date.now());
|
|
314
|
+
persistStopMessageState(stickyKey, stickyState);
|
|
315
|
+
}
|
|
316
|
+
debugLog('skip_reached_max_repeats', {
|
|
317
|
+
stickyKey,
|
|
318
|
+
used,
|
|
319
|
+
maxRepeats
|
|
320
|
+
});
|
|
321
|
+
return markSkip('skip_reached_max_repeats');
|
|
322
|
+
}
|
|
323
|
+
const injectReadyRaw = rt?.stopMessageClientInjectReady;
|
|
324
|
+
const injectReadyExplicitlyFalse = injectReadyRaw === false ||
|
|
325
|
+
(typeof injectReadyRaw === 'string' && injectReadyRaw.trim().toLowerCase() === 'false');
|
|
326
|
+
if (injectReadyExplicitlyFalse) {
|
|
327
|
+
const injectReason = typeof rt?.stopMessageClientInjectReason === 'string'
|
|
328
|
+
? String(rt.stopMessageClientInjectReason).trim()
|
|
329
|
+
: '';
|
|
330
|
+
if (stickyKey) {
|
|
331
|
+
const nextState = stickyState ??
|
|
332
|
+
createStopMessageState({
|
|
333
|
+
text,
|
|
334
|
+
maxRepeats,
|
|
335
|
+
used,
|
|
336
|
+
...(snapshot.source ? { source: snapshot.source } : {}),
|
|
337
|
+
...(snapshot.updatedAt ? { updatedAt: snapshot.updatedAt } : {}),
|
|
338
|
+
...(snapshot.lastUsedAt ? { lastUsedAt: snapshot.lastUsedAt } : {}),
|
|
339
|
+
...(snapshot.stageMode ? { stageMode: snapshot.stageMode } : {}),
|
|
340
|
+
aiMode
|
|
341
|
+
});
|
|
342
|
+
clearStopMessageState(nextState, Date.now());
|
|
343
|
+
persistStopMessageState(stickyKey, nextState);
|
|
344
|
+
}
|
|
345
|
+
debugLog('skip_client_inject_unready', {
|
|
346
|
+
stickyKey,
|
|
347
|
+
injectReadyRaw: injectReadyRaw,
|
|
348
|
+
injectReason
|
|
349
|
+
});
|
|
350
|
+
const normalizedInjectReason = injectReason && /^[a-z0-9_:-]+$/i.test(injectReason) ? injectReason.toLowerCase() : 'unknown';
|
|
351
|
+
return markSkip(`skip_client_inject_unready_${normalizedInjectReason}`);
|
|
352
|
+
}
|
|
135
353
|
const stopEligible = isStopEligibleForServerTool(ctx.base, ctx.adapterContext);
|
|
136
354
|
updateCompare({ stopEligible });
|
|
137
355
|
if (!stopEligible) {
|
|
138
356
|
debugLog('skip_not_stop_finish_reason');
|
|
139
357
|
return markSkip('skip_not_stop_finish_reason');
|
|
140
358
|
}
|
|
359
|
+
const autoResponseSnapshot = extractStopMessageAutoResponseSnapshot(ctx.base, ctx.adapterContext);
|
|
360
|
+
const doneMarker = resolveStopMessageAiDoneMarker();
|
|
361
|
+
const approvedMarker = resolveStopMessageAiApprovedMarker();
|
|
362
|
+
const completionClaimedByMainModel = aiMode === 'on' && hasStopMessageDoneMarker(autoResponseSnapshot, doneMarker);
|
|
141
363
|
const captured = getCapturedRequest(ctx.adapterContext);
|
|
142
364
|
updateCompare({ hasCapturedRequest: Boolean(captured) });
|
|
143
365
|
if (!captured) {
|
|
@@ -157,59 +379,152 @@ const handler = async (ctx) => {
|
|
|
157
379
|
debugLog('skip_failed_build_followup');
|
|
158
380
|
return markSkip('skip_failed_build_followup');
|
|
159
381
|
}
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
382
|
+
const historyStateCandidate = stickyState ?? rt?.stopMessageState;
|
|
383
|
+
const existingSeedPrompt = readStopMessageAiSeedPrompt(historyStateCandidate);
|
|
384
|
+
const existingHistory = readStopMessageAiHistory(historyStateCandidate);
|
|
385
|
+
const fallbackCandidateFollowupText = existingSeedPrompt || text || '继续执行';
|
|
386
|
+
const isFirstPrompt = existingHistory.length === 0;
|
|
387
|
+
let followupText = '';
|
|
388
|
+
if (aiMode === 'on') {
|
|
389
|
+
const aiFollowupText = renderStopMessageAutoFollowupViaAi({
|
|
390
|
+
baseStopMessageText: text,
|
|
391
|
+
candidateFollowupText: fallbackCandidateFollowupText,
|
|
392
|
+
responseSnapshot: autoResponseSnapshot,
|
|
393
|
+
requestId: typeof record.requestId === 'string'
|
|
394
|
+
? record.requestId.trim()
|
|
395
|
+
: undefined,
|
|
396
|
+
sessionId: typeof record.sessionId === 'string'
|
|
397
|
+
? record.sessionId.trim()
|
|
398
|
+
: undefined,
|
|
399
|
+
workingDirectory: resolveBdWorkingDirectoryForRecord(record, rt),
|
|
400
|
+
providerKey: resolveStopMessageFollowupProviderKey({ record, runtimeMetadata: rt }),
|
|
401
|
+
model: typeof seed.model === 'string' ? seed.model : undefined,
|
|
402
|
+
usedRepeats: used,
|
|
403
|
+
maxRepeats,
|
|
404
|
+
doneMarker,
|
|
405
|
+
approvedMarker,
|
|
406
|
+
completionClaimed: completionClaimedByMainModel,
|
|
407
|
+
isFirstPrompt,
|
|
408
|
+
historyEntries: existingHistory
|
|
409
|
+
});
|
|
410
|
+
if (aiFollowupText) {
|
|
411
|
+
followupText = aiFollowupText.trim();
|
|
412
|
+
debugLog('ai_followup_applied', {
|
|
413
|
+
textLength: followupText.length
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
followupText = '继续执行';
|
|
418
|
+
debugLog('ai_followup_fallback_to_continue_execution');
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
followupText = fallbackCandidateFollowupText;
|
|
423
|
+
debugLog('fixed_followup_applied', { textLength: followupText.length });
|
|
424
|
+
}
|
|
425
|
+
if (hasStopMessageMarkerLine(followupText, approvedMarker)) {
|
|
426
|
+
if (stickyKey) {
|
|
427
|
+
const nextState = stickyState ??
|
|
428
|
+
createStopMessageState({
|
|
429
|
+
text,
|
|
430
|
+
maxRepeats,
|
|
431
|
+
used,
|
|
432
|
+
...(snapshot.source ? { source: snapshot.source } : {}),
|
|
433
|
+
...(snapshot.updatedAt ? { updatedAt: snapshot.updatedAt } : {}),
|
|
434
|
+
...(snapshot.lastUsedAt ? { lastUsedAt: snapshot.lastUsedAt } : {}),
|
|
435
|
+
...(snapshot.stageMode ? { stageMode: snapshot.stageMode } : {}),
|
|
436
|
+
aiMode
|
|
437
|
+
});
|
|
438
|
+
clearStopMessageState(nextState, Date.now());
|
|
439
|
+
persistStopMessageState(stickyKey, nextState);
|
|
182
440
|
}
|
|
183
|
-
|
|
184
|
-
|
|
441
|
+
const approvedInjectText = typeof followupText === 'string' && followupText.trim()
|
|
442
|
+
? followupText.trim()
|
|
443
|
+
: approvedMarker;
|
|
444
|
+
debugLog('trigger_done_marker_approved', {
|
|
445
|
+
stickyKey,
|
|
446
|
+
doneMarker,
|
|
447
|
+
approvedMarker
|
|
185
448
|
});
|
|
449
|
+
updateCompare({
|
|
450
|
+
decision: 'trigger',
|
|
451
|
+
reason: 'done_marker_approved'
|
|
452
|
+
});
|
|
453
|
+
return {
|
|
454
|
+
flowId: FLOW_ID,
|
|
455
|
+
finalize: async () => ({
|
|
456
|
+
chatResponse: ctx.base,
|
|
457
|
+
execution: {
|
|
458
|
+
flowId: FLOW_ID,
|
|
459
|
+
followup: {
|
|
460
|
+
requestIdSuffix: ':stop_followup',
|
|
461
|
+
metadata: {
|
|
462
|
+
...(connectionState ? { clientConnectionState: connectionState } : {}),
|
|
463
|
+
clientInjectOnly: true,
|
|
464
|
+
clientInjectText: approvedInjectText,
|
|
465
|
+
clientInjectSource: 'servertool.stop_message.done'
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
})
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
if (aiMode === 'on') {
|
|
473
|
+
followupText = enforceStopMessageExecutionFollowupText(followupText || '继续执行', doneMarker);
|
|
186
474
|
}
|
|
187
475
|
else {
|
|
188
|
-
followupText = '继续执行';
|
|
189
|
-
debugLog('iflow_automessage_followup_fallback_to_continue_execution');
|
|
476
|
+
followupText = (followupText || '继续执行').trim();
|
|
190
477
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
478
|
+
const nextHistory = aiMode === 'on'
|
|
479
|
+
? appendStopMessageAiHistory(existingHistory, {
|
|
480
|
+
ts: Date.now(),
|
|
481
|
+
round: used + 1,
|
|
482
|
+
...(autoResponseSnapshot.assistantText ? { assistantText: autoResponseSnapshot.assistantText } : {}),
|
|
483
|
+
...(autoResponseSnapshot.reasoningText ? { reasoningText: autoResponseSnapshot.reasoningText } : {}),
|
|
484
|
+
...(autoResponseSnapshot.responseExcerpt ? { responseExcerpt: autoResponseSnapshot.responseExcerpt } : {}),
|
|
485
|
+
followupText
|
|
486
|
+
})
|
|
487
|
+
: [];
|
|
488
|
+
const nextUsed = used + 1;
|
|
489
|
+
updateCompare({ used: nextUsed });
|
|
490
|
+
if (stickyKey) {
|
|
491
|
+
const nextState = stickyState ??
|
|
492
|
+
createStopMessageState({
|
|
493
|
+
text,
|
|
494
|
+
maxRepeats,
|
|
495
|
+
used,
|
|
496
|
+
...(snapshot.source ? { source: snapshot.source } : {}),
|
|
497
|
+
...(snapshot.updatedAt ? { updatedAt: snapshot.updatedAt } : {}),
|
|
498
|
+
...(snapshot.lastUsedAt ? { lastUsedAt: snapshot.lastUsedAt } : {}),
|
|
499
|
+
...(snapshot.stageMode ? { stageMode: snapshot.stageMode } : {}),
|
|
500
|
+
aiMode,
|
|
501
|
+
aiSeedPrompt: fallbackCandidateFollowupText,
|
|
502
|
+
aiHistory: existingHistory
|
|
503
|
+
});
|
|
504
|
+
const now = Date.now();
|
|
505
|
+
if (nextUsed >= maxRepeats) {
|
|
506
|
+
clearStopMessageState(nextState, now);
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
nextState.stopMessageText = text;
|
|
510
|
+
nextState.stopMessageMaxRepeats = maxRepeats;
|
|
511
|
+
nextState.stopMessageUsed = nextUsed;
|
|
512
|
+
nextState.stopMessageStageMode = mode;
|
|
513
|
+
nextState.stopMessageAiMode = aiMode;
|
|
514
|
+
nextState.stopMessageLastUsedAt = now;
|
|
515
|
+
nextState.stopMessageAiSeedPrompt = fallbackCandidateFollowupText;
|
|
516
|
+
nextState.stopMessageAiHistory =
|
|
517
|
+
aiMode === 'on' && nextHistory.length > 0
|
|
518
|
+
? nextHistory.map((entry) => ({ ...entry }))
|
|
519
|
+
: undefined;
|
|
520
|
+
}
|
|
521
|
+
persistStopMessageState(stickyKey, nextState);
|
|
194
522
|
}
|
|
195
|
-
const followupProviderKey = resolveStopMessageFollowupProviderKey({ record, runtimeMetadata: rt });
|
|
196
|
-
const followupToolContentMaxChars = resolveStopMessageFollowupToolContentMaxChars({
|
|
197
|
-
providerKey: followupProviderKey,
|
|
198
|
-
model: seed.model
|
|
199
|
-
});
|
|
200
|
-
const followupOps = [];
|
|
201
|
-
if (typeof followupToolContentMaxChars === 'number' &&
|
|
202
|
-
Number.isFinite(followupToolContentMaxChars) &&
|
|
203
|
-
followupToolContentMaxChars > 0) {
|
|
204
|
-
followupOps.push({ op: 'compact_tool_content', maxChars: Math.floor(followupToolContentMaxChars) });
|
|
205
|
-
}
|
|
206
|
-
followupOps.push({ op: 'ensure_standard_tools' });
|
|
207
|
-
followupOps.push({ op: 'inject_system_text', text: STOP_MESSAGE_EXECUTION_DIRECTIVE });
|
|
208
|
-
followupOps.push({ op: 'append_user_text', text: followupText });
|
|
209
523
|
updateCompare({
|
|
210
524
|
decision: 'trigger',
|
|
211
525
|
reason: 'triggered'
|
|
212
526
|
});
|
|
527
|
+
// stop_message uses clientInjectOnly path only (tmux injection), no servertool followup reenter
|
|
213
528
|
return {
|
|
214
529
|
flowId: FLOW_ID,
|
|
215
530
|
finalize: async () => ({
|
|
@@ -218,11 +533,12 @@ const handler = async (ctx) => {
|
|
|
218
533
|
flowId: FLOW_ID,
|
|
219
534
|
followup: {
|
|
220
535
|
requestIdSuffix: ':stop_followup',
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
536
|
+
metadata: {
|
|
537
|
+
...(connectionState ? { clientConnectionState: connectionState } : {}),
|
|
538
|
+
clientInjectOnly: true,
|
|
539
|
+
clientInjectText: followupText,
|
|
540
|
+
clientInjectSource: 'servertool.stop_message'
|
|
541
|
+
}
|
|
226
542
|
}
|
|
227
543
|
}
|
|
228
544
|
})
|
|
@@ -9,6 +9,7 @@ import './handlers/clock-auto.js';
|
|
|
9
9
|
import './handlers/exec-command-guard.js';
|
|
10
10
|
import './handlers/apply-patch-guard.js';
|
|
11
11
|
import './handlers/continue-execution.js';
|
|
12
|
+
import './handlers/review.js';
|
|
12
13
|
export declare function runServerSideToolEngine(options: ServerSideToolEngineOptions): Promise<ServerSideToolEngineResult>;
|
|
13
14
|
export declare function extractToolCalls(chatResponse: JsonObject): ToolCall[];
|
|
14
15
|
export declare function cloneJson<T>(value: T): T;
|