@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,127 +0,0 @@
|
|
|
1
|
-
import { detectBdWorkState, resolveBdTaskSelectionFromRuntime } from './bd-runtime.js';
|
|
2
|
-
import { buildObservationHash, buildToolSignatureHash } from './observation.js';
|
|
3
|
-
import { buildStageMessage, resolveStageMode, resolveStageTemplates } from './templates.js';
|
|
4
|
-
import { normalizeBdWorkState, normalizeStageName, normalizeText, toSafeInt } from './text-utils.js';
|
|
5
|
-
function buildAssignedTaskBaseText(baseText, assignedTask) {
|
|
6
|
-
const assignmentLine = `系统已分配任务:${assignedTask.issueId} - ${assignedTask.issueTitle}(来源:${assignedTask.source})`;
|
|
7
|
-
const behaviorLine = '请直接执行该任务,优先推进实现、修复与验证。';
|
|
8
|
-
const suffix = normalizeText(baseText);
|
|
9
|
-
if (!suffix) {
|
|
10
|
-
return `${assignmentLine}\n${behaviorLine}`.trim();
|
|
11
|
-
}
|
|
12
|
-
return `${assignmentLine}\n${behaviorLine}\n\n${suffix}`.trim();
|
|
13
|
-
}
|
|
14
|
-
export function resolveStopMessageStageDecision(args) {
|
|
15
|
-
const mode = resolveStageMode(args.state.stopMessageStageMode);
|
|
16
|
-
const observationHash = buildObservationHash(args.capturedMessages);
|
|
17
|
-
const toolSignatureHash = buildToolSignatureHash(args.capturedMessages);
|
|
18
|
-
if (mode === 'off') {
|
|
19
|
-
return {
|
|
20
|
-
action: 'stop',
|
|
21
|
-
observationHash,
|
|
22
|
-
observationStableCount: 0,
|
|
23
|
-
bdWorkState: 'unknown',
|
|
24
|
-
stopReason: 'mode_off',
|
|
25
|
-
...(toolSignatureHash ? { toolSignatureHash } : {})
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
const templates = resolveStageTemplates(mode);
|
|
29
|
-
if (!templates.enabled) {
|
|
30
|
-
return {
|
|
31
|
-
action: 'followup',
|
|
32
|
-
followupText: args.baseText,
|
|
33
|
-
observationHash,
|
|
34
|
-
observationStableCount: 0,
|
|
35
|
-
bdWorkState: 'unknown',
|
|
36
|
-
...(toolSignatureHash ? { toolSignatureHash } : {})
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
const previousHash = normalizeText(args.state.stopMessageObservationHash);
|
|
40
|
-
const previousStableCount = toSafeInt(args.state.stopMessageObservationStableCount, 0);
|
|
41
|
-
const stableCount = previousHash && previousHash === observationHash ? previousStableCount + 1 : 0;
|
|
42
|
-
const taskProbe = resolveBdTaskSelectionFromRuntime({
|
|
43
|
-
bdCommandRunner: args.bdCommandRunner,
|
|
44
|
-
cwd: args.bdWorkingDirectory,
|
|
45
|
-
nowMs: args.nowMs
|
|
46
|
-
});
|
|
47
|
-
const assignedTask = taskProbe.status === 'ok' ? taskProbe.task : undefined;
|
|
48
|
-
const bdWorkState = detectBdWorkState(args.capturedMessages, {
|
|
49
|
-
bdCommandRunner: args.bdCommandRunner,
|
|
50
|
-
cwd: args.bdWorkingDirectory,
|
|
51
|
-
nowMs: args.nowMs
|
|
52
|
-
});
|
|
53
|
-
if (taskProbe.status === 'ok' && !assignedTask) {
|
|
54
|
-
if (Boolean(args.state.stopMessageNoTaskSummaryUsed)) {
|
|
55
|
-
return {
|
|
56
|
-
action: 'stop',
|
|
57
|
-
observationHash,
|
|
58
|
-
observationStableCount: stableCount,
|
|
59
|
-
bdWorkState,
|
|
60
|
-
noTaskSummaryUsed: true,
|
|
61
|
-
stopReason: 'no_task_after_summary',
|
|
62
|
-
...(toolSignatureHash ? { toolSignatureHash } : {})
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
action: 'followup',
|
|
67
|
-
stage: 'status_probe',
|
|
68
|
-
followupText: buildStageMessage(templates.noTaskSummaryTemplate, args.baseText),
|
|
69
|
-
observationHash,
|
|
70
|
-
observationStableCount: stableCount,
|
|
71
|
-
bdWorkState,
|
|
72
|
-
noTaskSummaryUsed: true,
|
|
73
|
-
...(toolSignatureHash ? { toolSignatureHash } : {})
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
if (mode !== 'on') {
|
|
77
|
-
const previousStage = normalizeStageName(args.state.stopMessageStage);
|
|
78
|
-
const previousBdWorkState = normalizeBdWorkState(args.state.stopMessageBdWorkState);
|
|
79
|
-
const idleConfirmed = bdWorkState === 'idle' && previousBdWorkState === 'idle' && previousStage === 'status_probe';
|
|
80
|
-
if (bdWorkState === 'idle') {
|
|
81
|
-
if (idleConfirmed) {
|
|
82
|
-
return {
|
|
83
|
-
action: 'stop',
|
|
84
|
-
observationHash,
|
|
85
|
-
observationStableCount: stableCount,
|
|
86
|
-
bdWorkState,
|
|
87
|
-
stopReason: 'bd_idle',
|
|
88
|
-
...(toolSignatureHash ? { toolSignatureHash } : {})
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (stableCount >= 2) {
|
|
93
|
-
return {
|
|
94
|
-
action: 'stop',
|
|
95
|
-
observationHash,
|
|
96
|
-
observationStableCount: stableCount,
|
|
97
|
-
bdWorkState,
|
|
98
|
-
stopReason: 'loop_stable',
|
|
99
|
-
...(toolSignatureHash ? { toolSignatureHash } : {})
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const stage = stableCount > 0 ? 'loop_self_check' : bdWorkState === 'active' ? 'active_continue' : 'status_probe';
|
|
104
|
-
const stageTemplate = stage === 'status_probe'
|
|
105
|
-
? templates.statusProbeTemplate
|
|
106
|
-
: stage === 'active_continue'
|
|
107
|
-
? templates.activeContinueTemplate
|
|
108
|
-
: templates.loopSelfCheckTemplate;
|
|
109
|
-
const followupText = buildStageMessage(stageTemplate, assignedTask ? buildAssignedTaskBaseText(args.baseText, assignedTask) : args.baseText);
|
|
110
|
-
return {
|
|
111
|
-
action: 'followup',
|
|
112
|
-
stage,
|
|
113
|
-
followupText,
|
|
114
|
-
observationHash,
|
|
115
|
-
observationStableCount: stableCount,
|
|
116
|
-
bdWorkState,
|
|
117
|
-
...(assignedTask
|
|
118
|
-
? {
|
|
119
|
-
assignedIssueId: assignedTask.issueId,
|
|
120
|
-
assignedIssueTitle: assignedTask.issueTitle,
|
|
121
|
-
assignedIssueSource: assignedTask.source
|
|
122
|
-
}
|
|
123
|
-
: {}),
|
|
124
|
-
noTaskSummaryUsed: false,
|
|
125
|
-
...(toolSignatureHash ? { toolSignatureHash } : {})
|
|
126
|
-
};
|
|
127
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { extractMessageText, normalizeText, normalizeWhitespace } from './text-utils.js';
|
|
3
|
-
function stableStringifyForObservation(value) {
|
|
4
|
-
if (value === null)
|
|
5
|
-
return 'null';
|
|
6
|
-
const type = typeof value;
|
|
7
|
-
if (type === 'string')
|
|
8
|
-
return JSON.stringify(value);
|
|
9
|
-
if (type === 'number')
|
|
10
|
-
return Number.isFinite(value) ? String(value) : 'null';
|
|
11
|
-
if (type === 'boolean')
|
|
12
|
-
return value ? 'true' : 'false';
|
|
13
|
-
if (type === 'undefined' || type === 'function' || type === 'symbol')
|
|
14
|
-
return 'null';
|
|
15
|
-
if (Array.isArray(value)) {
|
|
16
|
-
return `[${value.map((item) => stableStringifyForObservation(item)).join(',')}]`;
|
|
17
|
-
}
|
|
18
|
-
if (value && typeof value === 'object') {
|
|
19
|
-
const record = value;
|
|
20
|
-
const keys = Object.keys(record).sort();
|
|
21
|
-
const chunks = [];
|
|
22
|
-
for (const key of keys) {
|
|
23
|
-
const child = record[key];
|
|
24
|
-
if (typeof child === 'undefined') {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
chunks.push(`${JSON.stringify(key)}:${stableStringifyForObservation(child)}`);
|
|
28
|
-
}
|
|
29
|
-
return `{${chunks.join(',')}}`;
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
return JSON.stringify(value);
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return 'null';
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function normalizeToolArgumentsForObservation(value) {
|
|
39
|
-
if (typeof value === 'string') {
|
|
40
|
-
const trimmed = value.trim();
|
|
41
|
-
if (!trimmed) {
|
|
42
|
-
return '{}';
|
|
43
|
-
}
|
|
44
|
-
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
45
|
-
try {
|
|
46
|
-
return stableStringifyForObservation(JSON.parse(trimmed));
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
return normalizeWhitespace(trimmed);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return normalizeWhitespace(trimmed);
|
|
53
|
-
}
|
|
54
|
-
if (typeof value === 'undefined') {
|
|
55
|
-
return '{}';
|
|
56
|
-
}
|
|
57
|
-
return stableStringifyForObservation(value);
|
|
58
|
-
}
|
|
59
|
-
function extractCommandSignaturesFromText(text) {
|
|
60
|
-
const signatures = [];
|
|
61
|
-
const bashRegex = /(?:^|\n)\s*Bash\(([^)\n]{1,1200})\)/g;
|
|
62
|
-
let bashMatch;
|
|
63
|
-
while ((bashMatch = bashRegex.exec(text)) !== null) {
|
|
64
|
-
const command = normalizeWhitespace((bashMatch[1] || '').trim());
|
|
65
|
-
if (!command)
|
|
66
|
-
continue;
|
|
67
|
-
signatures.push(`text.bash(${command})`);
|
|
68
|
-
}
|
|
69
|
-
const shellCommandRegex = /"name"\s*:\s*"shell_command"[\s\S]{0,800}?"command"\s*:\s*"([^"\\]*(?:\\.[^"\\]*)*)"/g;
|
|
70
|
-
let shellCommandMatch;
|
|
71
|
-
while ((shellCommandMatch = shellCommandRegex.exec(text)) !== null) {
|
|
72
|
-
const raw = shellCommandMatch[1] || '';
|
|
73
|
-
const command = normalizeWhitespace(raw.replace(/\\"/g, '"').replace(/\\n/g, ' ').trim());
|
|
74
|
-
if (!command)
|
|
75
|
-
continue;
|
|
76
|
-
signatures.push(`text.shell_command(${command})`);
|
|
77
|
-
}
|
|
78
|
-
const xmlCommandRegex = /<parameter\s+name="command">([\s\S]{1,1200}?)<\/parameter>/g;
|
|
79
|
-
let xmlCommandMatch;
|
|
80
|
-
while ((xmlCommandMatch = xmlCommandRegex.exec(text)) !== null) {
|
|
81
|
-
const command = normalizeWhitespace((xmlCommandMatch[1] || '').trim());
|
|
82
|
-
if (!command)
|
|
83
|
-
continue;
|
|
84
|
-
signatures.push(`text.param_command(${command})`);
|
|
85
|
-
}
|
|
86
|
-
return signatures;
|
|
87
|
-
}
|
|
88
|
-
function extractToolCallSignatureText(record) {
|
|
89
|
-
const signatures = [];
|
|
90
|
-
const appendSignature = (nameValue, argsValue) => {
|
|
91
|
-
const name = normalizeText(nameValue).toLowerCase();
|
|
92
|
-
if (!name) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const args = normalizeToolArgumentsForObservation(argsValue);
|
|
96
|
-
signatures.push(`${name}(${args})`);
|
|
97
|
-
};
|
|
98
|
-
const scan = (node) => {
|
|
99
|
-
if (!node) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (Array.isArray(node)) {
|
|
103
|
-
for (const item of node) {
|
|
104
|
-
scan(item);
|
|
105
|
-
}
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (typeof node !== 'object') {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const current = node;
|
|
112
|
-
if (current.function && typeof current.function === 'object' && !Array.isArray(current.function)) {
|
|
113
|
-
const fn = current.function;
|
|
114
|
-
appendSignature(fn.name, fn.arguments);
|
|
115
|
-
}
|
|
116
|
-
if (normalizeText(current.type).toLowerCase() === 'function_call') {
|
|
117
|
-
appendSignature(current.name, current.arguments);
|
|
118
|
-
}
|
|
119
|
-
if (typeof current.name === 'string' && Object.prototype.hasOwnProperty.call(current, 'arguments')) {
|
|
120
|
-
appendSignature(current.name, current.arguments);
|
|
121
|
-
}
|
|
122
|
-
if (current.function_call && typeof current.function_call === 'object' && !Array.isArray(current.function_call)) {
|
|
123
|
-
const fnCall = current.function_call;
|
|
124
|
-
appendSignature(fnCall.name, fnCall.arguments);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
scan(record.tool_calls);
|
|
128
|
-
scan(record.tool_call);
|
|
129
|
-
scan(record.function_call);
|
|
130
|
-
scan(record.output);
|
|
131
|
-
const textPayload = extractMessageText(record.content || record.output || record.input || '');
|
|
132
|
-
if (textPayload) {
|
|
133
|
-
signatures.push(...extractCommandSignaturesFromText(textPayload));
|
|
134
|
-
}
|
|
135
|
-
return signatures.join('; ');
|
|
136
|
-
}
|
|
137
|
-
function extractToolSignatureForHash(message) {
|
|
138
|
-
if (!message || typeof message !== 'object' || Array.isArray(message)) {
|
|
139
|
-
return '';
|
|
140
|
-
}
|
|
141
|
-
const record = message;
|
|
142
|
-
return extractToolCallSignatureText(record);
|
|
143
|
-
}
|
|
144
|
-
function normalizeMessageForHash(message) {
|
|
145
|
-
if (!message || typeof message !== 'object' || Array.isArray(message)) {
|
|
146
|
-
return '';
|
|
147
|
-
}
|
|
148
|
-
const record = message;
|
|
149
|
-
const role = normalizeText(record.role).toLowerCase() || 'unknown';
|
|
150
|
-
const text = extractMessageText(record.content || record.output || record.input || '');
|
|
151
|
-
const toolSignature = extractToolCallSignatureText(record);
|
|
152
|
-
const combined = [text, toolSignature].filter((entry) => typeof entry === 'string' && entry.trim()).join(' | ');
|
|
153
|
-
if (!combined) {
|
|
154
|
-
return role;
|
|
155
|
-
}
|
|
156
|
-
return `${role}:${combined.slice(0, 800)}`;
|
|
157
|
-
}
|
|
158
|
-
export function buildObservationHash(messages) {
|
|
159
|
-
const tail = messages
|
|
160
|
-
.slice(-20)
|
|
161
|
-
.map((message) => normalizeMessageForHash(message))
|
|
162
|
-
.filter(Boolean)
|
|
163
|
-
.join('\n');
|
|
164
|
-
if (!tail) {
|
|
165
|
-
return 'empty';
|
|
166
|
-
}
|
|
167
|
-
return createHash('sha1').update(tail).digest('hex').slice(0, 16);
|
|
168
|
-
}
|
|
169
|
-
export function buildToolSignatureHash(messages) {
|
|
170
|
-
const signatures = messages
|
|
171
|
-
.slice(-20)
|
|
172
|
-
.map((message) => extractToolSignatureForHash(message))
|
|
173
|
-
.filter(Boolean)
|
|
174
|
-
.join('\n');
|
|
175
|
-
if (!signatures) {
|
|
176
|
-
return undefined;
|
|
177
|
-
}
|
|
178
|
-
return createHash('sha1').update(signatures).digest('hex').slice(0, 16);
|
|
179
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { StageTemplateBundle } from './types.js';
|
|
2
|
-
export declare function buildStageMessage(template: string, baseText: string): string;
|
|
3
|
-
export declare function resolveStageTemplates(mode: 'auto' | 'on'): StageTemplateBundle;
|
|
4
|
-
export declare function resolveStageMode(modeFromState: unknown): 'auto' | 'on' | 'off';
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { loadStopMessageStageTemplate } from '../../../router/virtual-router/stop-message-stage-template-files.js';
|
|
2
|
-
import { normalizeStageMode, normalizeText } from './text-utils.js';
|
|
3
|
-
const DEFAULT_STATUS_TEMPLATE = [
|
|
4
|
-
'请围绕当前目标直接推进,不要陷入任务面板操作:',
|
|
5
|
-
'1) 优先完成一个可验证动作(改代码 / 补测试 / 运行验证);',
|
|
6
|
-
'2) 若确实缺少目标或上下文,再一次性补齐必要信息,不要循环轮询;',
|
|
7
|
-
'3) 仅在动作完成或出现阻塞时,同步记录;',
|
|
8
|
-
'4) 若执行受阻,输出结构化阻塞信息(见下方约束)以便系统建单。',
|
|
9
|
-
'',
|
|
10
|
-
'{{BASE_STOP_MESSAGE}}'
|
|
11
|
-
].join('\n');
|
|
12
|
-
const DEFAULT_ACTIVE_TEMPLATE = [
|
|
13
|
-
'检测到当前任务可继续,请直接推进工程动作:',
|
|
14
|
-
'1) 先做实现/修复/验证,不要把任务管理操作当作主要步骤;',
|
|
15
|
-
'2) 可以调用工具执行代码与验证,避免空状态播报;',
|
|
16
|
-
'3) 若阻塞,请明确 blocker 并给出 next_action,必要时按结构化格式输出。',
|
|
17
|
-
'',
|
|
18
|
-
'{{BASE_STOP_MESSAGE}}'
|
|
19
|
-
].join('\n');
|
|
20
|
-
const DEFAULT_LOOP_TEMPLATE = [
|
|
21
|
-
'检测到可能出现重复循环,请先自检并尝试跳出:',
|
|
22
|
-
'1) 对比最近两轮是否重复同一工具调用+参数(包括文本里的命令参数);',
|
|
23
|
-
'2) 若重复,改做新的有效动作(改代码、跑测试、定位错误);',
|
|
24
|
-
'3) 执行后再观察状态变化;若仍无变化则停止并报告具体阻塞点。',
|
|
25
|
-
'',
|
|
26
|
-
'{{BASE_STOP_MESSAGE}}'
|
|
27
|
-
].join('\n');
|
|
28
|
-
const DEFAULT_NO_TASK_SUMMARY_TEMPLATE = [
|
|
29
|
-
'当前未发现可推进任务。',
|
|
30
|
-
'请只输出一次收尾总结;不要继续轮询任务列表。',
|
|
31
|
-
'若存在阻塞,请输出一个 JSON 对象(不要附加解释文本):',
|
|
32
|
-
'{"type":"blocked","summary":"...","blocker":"...","impact":"...","next_action":"...","evidence":["..."]}',
|
|
33
|
-
'',
|
|
34
|
-
'{{BASE_STOP_MESSAGE}}'
|
|
35
|
-
].join('\n');
|
|
36
|
-
export function buildStageMessage(template, baseText) {
|
|
37
|
-
const safeBaseText = baseText.trim();
|
|
38
|
-
const safeTemplate = typeof template === 'string' ? template.trim() : '';
|
|
39
|
-
if (safeTemplate.includes('{{BASE_STOP_MESSAGE}}')) {
|
|
40
|
-
const replaced = safeTemplate.replaceAll('{{BASE_STOP_MESSAGE}}', safeBaseText).replace(/\n{3,}/g, '\n\n').trim();
|
|
41
|
-
if (replaced) {
|
|
42
|
-
return replaced;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (!safeTemplate) {
|
|
46
|
-
return safeBaseText;
|
|
47
|
-
}
|
|
48
|
-
if (!safeBaseText) {
|
|
49
|
-
return safeTemplate;
|
|
50
|
-
}
|
|
51
|
-
return `${safeTemplate}\n\n原始约束:\n${safeBaseText}`.trim();
|
|
52
|
-
}
|
|
53
|
-
function loadStageTemplate(stage) {
|
|
54
|
-
const loaded = loadStopMessageStageTemplate(stage);
|
|
55
|
-
return loaded.text || null;
|
|
56
|
-
}
|
|
57
|
-
export function resolveStageTemplates(mode) {
|
|
58
|
-
const statusProbeTemplate = loadStageTemplate('status_probe');
|
|
59
|
-
const activeContinueTemplate = loadStageTemplate('active_continue');
|
|
60
|
-
const loopSelfCheckTemplate = loadStageTemplate('loop_self_check');
|
|
61
|
-
const hasUserTemplate = Boolean(statusProbeTemplate || activeContinueTemplate || loopSelfCheckTemplate);
|
|
62
|
-
const enabled = mode === 'on' || hasUserTemplate;
|
|
63
|
-
if (!enabled) {
|
|
64
|
-
return {
|
|
65
|
-
enabled: false,
|
|
66
|
-
statusProbeTemplate: '',
|
|
67
|
-
activeContinueTemplate: '',
|
|
68
|
-
loopSelfCheckTemplate: '',
|
|
69
|
-
noTaskSummaryTemplate: DEFAULT_NO_TASK_SUMMARY_TEMPLATE
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
enabled: true,
|
|
74
|
-
statusProbeTemplate: statusProbeTemplate || DEFAULT_STATUS_TEMPLATE,
|
|
75
|
-
activeContinueTemplate: activeContinueTemplate || DEFAULT_ACTIVE_TEMPLATE,
|
|
76
|
-
loopSelfCheckTemplate: loopSelfCheckTemplate || DEFAULT_LOOP_TEMPLATE,
|
|
77
|
-
noTaskSummaryTemplate: DEFAULT_NO_TASK_SUMMARY_TEMPLATE
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
export function resolveStageMode(modeFromState) {
|
|
81
|
-
const stateMode = normalizeStageMode(modeFromState);
|
|
82
|
-
if (stateMode) {
|
|
83
|
-
return stateMode;
|
|
84
|
-
}
|
|
85
|
-
const raw = normalizeText(process.env.ROUTECODEX_STOPMESSAGE_STAGE_MODE).toLowerCase();
|
|
86
|
-
if (raw === '1' || raw === 'true' || raw === 'on') {
|
|
87
|
-
return 'on';
|
|
88
|
-
}
|
|
89
|
-
if (raw === '0' || raw === 'false' || raw === 'off') {
|
|
90
|
-
return 'off';
|
|
91
|
-
}
|
|
92
|
-
if (raw === 'auto') {
|
|
93
|
-
return 'auto';
|
|
94
|
-
}
|
|
95
|
-
return 'auto';
|
|
96
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { StopMessageBdWorkState, StopMessageStageName } from './types.js';
|
|
2
|
-
export declare function normalizeWhitespace(text: string): string;
|
|
3
|
-
export declare function normalizeText(value: unknown): string;
|
|
4
|
-
export declare function extractMessageText(value: unknown): string;
|
|
5
|
-
export declare function normalizeMessageForHeuristics(message: unknown): string;
|
|
6
|
-
export declare function normalizeStageName(value: unknown): StopMessageStageName | undefined;
|
|
7
|
-
export declare function normalizeBdWorkState(value: unknown): StopMessageBdWorkState | undefined;
|
|
8
|
-
export declare function normalizeStageMode(value: unknown): 'on' | 'off' | 'auto' | undefined;
|
|
9
|
-
export declare function toSafeInt(value: unknown, fallback: number): number;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
export function normalizeWhitespace(text) {
|
|
2
|
-
return text.replace(/\s+/g, ' ').trim();
|
|
3
|
-
}
|
|
4
|
-
export function normalizeText(value) {
|
|
5
|
-
return typeof value === 'string' ? value.trim() : '';
|
|
6
|
-
}
|
|
7
|
-
export function extractMessageText(value) {
|
|
8
|
-
if (typeof value === 'string') {
|
|
9
|
-
return normalizeWhitespace(value);
|
|
10
|
-
}
|
|
11
|
-
if (Array.isArray(value)) {
|
|
12
|
-
const chunks = [];
|
|
13
|
-
for (const entry of value) {
|
|
14
|
-
const text = extractMessageText(entry);
|
|
15
|
-
if (text) {
|
|
16
|
-
chunks.push(text);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return normalizeWhitespace(chunks.join('\n'));
|
|
20
|
-
}
|
|
21
|
-
if (!value || typeof value !== 'object') {
|
|
22
|
-
return '';
|
|
23
|
-
}
|
|
24
|
-
const record = value;
|
|
25
|
-
const candidates = [
|
|
26
|
-
record.text,
|
|
27
|
-
record.content,
|
|
28
|
-
record.output_text,
|
|
29
|
-
record.input_text,
|
|
30
|
-
record.arguments,
|
|
31
|
-
record.name,
|
|
32
|
-
record.result,
|
|
33
|
-
record.stdout,
|
|
34
|
-
record.stderr
|
|
35
|
-
];
|
|
36
|
-
const chunks = [];
|
|
37
|
-
for (const candidate of candidates) {
|
|
38
|
-
const text = extractMessageText(candidate);
|
|
39
|
-
if (text) {
|
|
40
|
-
chunks.push(text);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return normalizeWhitespace(chunks.join('\n'));
|
|
44
|
-
}
|
|
45
|
-
export function normalizeMessageForHeuristics(message) {
|
|
46
|
-
if (!message || typeof message !== 'object' || Array.isArray(message)) {
|
|
47
|
-
return '';
|
|
48
|
-
}
|
|
49
|
-
const record = message;
|
|
50
|
-
const role = normalizeText(record.role).toLowerCase();
|
|
51
|
-
const text = extractMessageText(record.content || record.output || record.input || '');
|
|
52
|
-
return `${role}:${text}`.trim();
|
|
53
|
-
}
|
|
54
|
-
export function normalizeStageName(value) {
|
|
55
|
-
if (typeof value !== 'string') {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
const normalized = value.trim().toLowerCase();
|
|
59
|
-
if (normalized === 'status_probe' || normalized === 'active_continue' || normalized === 'loop_self_check') {
|
|
60
|
-
return normalized;
|
|
61
|
-
}
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
export function normalizeBdWorkState(value) {
|
|
65
|
-
if (typeof value !== 'string') {
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
const normalized = value.trim().toLowerCase();
|
|
69
|
-
if (normalized === 'active' || normalized === 'idle' || normalized === 'unknown') {
|
|
70
|
-
return normalized;
|
|
71
|
-
}
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
export function normalizeStageMode(value) {
|
|
75
|
-
if (typeof value !== 'string') {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
const normalized = value.trim().toLowerCase();
|
|
79
|
-
if (normalized === 'on' || normalized === 'off' || normalized === 'auto') {
|
|
80
|
-
return normalized;
|
|
81
|
-
}
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
export function toSafeInt(value, fallback) {
|
|
85
|
-
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
86
|
-
return fallback;
|
|
87
|
-
}
|
|
88
|
-
return Math.max(0, Math.floor(value));
|
|
89
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export type StopMessageStageName = 'status_probe' | 'active_continue' | 'loop_self_check';
|
|
2
|
-
export type StopMessageBdWorkState = 'active' | 'idle' | 'unknown';
|
|
3
|
-
export type StopMessageBdMode = 'auto' | 'runtime' | 'heuristic';
|
|
4
|
-
export type StopMessageBdTaskSource = 'in_progress' | 'ready' | 'open';
|
|
5
|
-
export interface StopMessageStageStateSnapshot {
|
|
6
|
-
stopMessageStage?: string;
|
|
7
|
-
stopMessageStageMode?: 'on' | 'off' | 'auto' | string;
|
|
8
|
-
stopMessageObservationHash?: string;
|
|
9
|
-
stopMessageObservationStableCount?: number;
|
|
10
|
-
stopMessageBdWorkState?: string;
|
|
11
|
-
stopMessageNoTaskSummaryUsed?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export interface StopMessageBdCommandResult {
|
|
14
|
-
status: number | null;
|
|
15
|
-
stdout: string;
|
|
16
|
-
stderr: string;
|
|
17
|
-
error?: unknown;
|
|
18
|
-
}
|
|
19
|
-
export type StopMessageBdCommandRunner = (args: string[], options: {
|
|
20
|
-
cwd: string;
|
|
21
|
-
timeoutMs: number;
|
|
22
|
-
}) => StopMessageBdCommandResult;
|
|
23
|
-
export interface StopMessageStageDecision {
|
|
24
|
-
action: 'followup' | 'stop';
|
|
25
|
-
stage?: StopMessageStageName;
|
|
26
|
-
followupText?: string;
|
|
27
|
-
observationHash: string;
|
|
28
|
-
observationStableCount: number;
|
|
29
|
-
toolSignatureHash?: string;
|
|
30
|
-
bdWorkState: StopMessageBdWorkState;
|
|
31
|
-
assignedIssueId?: string;
|
|
32
|
-
assignedIssueTitle?: string;
|
|
33
|
-
assignedIssueSource?: StopMessageBdTaskSource;
|
|
34
|
-
noTaskSummaryUsed?: boolean;
|
|
35
|
-
stopReason?: 'loop_stable' | 'bd_idle' | 'mode_off' | 'no_task_after_summary';
|
|
36
|
-
}
|
|
37
|
-
export interface StopMessageBdTaskSelection {
|
|
38
|
-
issueId: string;
|
|
39
|
-
issueTitle: string;
|
|
40
|
-
priority: number;
|
|
41
|
-
source: StopMessageBdTaskSource;
|
|
42
|
-
}
|
|
43
|
-
export interface StopMessageBdTaskProbeResult {
|
|
44
|
-
status: 'ok' | 'unknown';
|
|
45
|
-
task?: StopMessageBdTaskSelection;
|
|
46
|
-
}
|
|
47
|
-
export interface StageTemplateBundle {
|
|
48
|
-
enabled: boolean;
|
|
49
|
-
statusProbeTemplate: string;
|
|
50
|
-
activeContinueTemplate: string;
|
|
51
|
-
loopSelfCheckTemplate: string;
|
|
52
|
-
noTaskSummaryTemplate: string;
|
|
53
|
-
}
|
|
54
|
-
export interface BdRuntimeCacheEntry {
|
|
55
|
-
mode: StopMessageBdMode;
|
|
56
|
-
cwd: string;
|
|
57
|
-
expiresAt: number;
|
|
58
|
-
state: StopMessageBdWorkState;
|
|
59
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export type { StopMessageBdCommandResult, StopMessageBdCommandRunner, StopMessageBdMode, StopMessageBdTaskSelection, StopMessageBdTaskSource, StopMessageBdWorkState, StopMessageStageDecision, StopMessageStageName, StopMessageStageStateSnapshot } from './stop-message-stage-policy/types.js';
|
|
2
|
-
export { resolveStopMessageStageDecision } from './stop-message-stage-policy/decision.js';
|
|
3
|
-
export { resetStopMessageBdRuntimeCacheForTests, resolveBdTaskSelectionFromRuntime, resolveBdWorkStateFromRuntime } from './stop-message-stage-policy/bd-runtime.js';
|
|
File without changes
|