@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
|
@@ -312,6 +312,7 @@ export async function runServerToolOrchestration(options) {
|
|
|
312
312
|
return 'unknown';
|
|
313
313
|
const mapping = {
|
|
314
314
|
continue_execution_flow: 'continue_execution',
|
|
315
|
+
review_flow: 'review',
|
|
315
316
|
stop_message_flow: 'stop_message_auto',
|
|
316
317
|
empty_reply_continue: 'empty_reply_continue',
|
|
317
318
|
apply_patch_guard: 'apply_patch_guard',
|
|
@@ -429,6 +430,31 @@ export async function runServerToolOrchestration(options) {
|
|
|
429
430
|
catch {
|
|
430
431
|
// best-effort only
|
|
431
432
|
}
|
|
433
|
+
if (event.hookId === 'stop_message_auto' && event.result === 'miss') {
|
|
434
|
+
const compareContext = readStopMessageCompareContext(options.adapterContext);
|
|
435
|
+
const summary = formatStopMessageCompareContext(compareContext);
|
|
436
|
+
try {
|
|
437
|
+
// eslint-disable-next-line no-console
|
|
438
|
+
console.log(`${BLUE}[servertool][stop_compare] requestId=${options.requestId} stage=miss flow=none ${summary}${RESET}`);
|
|
439
|
+
}
|
|
440
|
+
catch {
|
|
441
|
+
// best-effort logging
|
|
442
|
+
}
|
|
443
|
+
const compareResult = compareContext
|
|
444
|
+
? `${compareContext.decision}_${compareContext.reason.toLowerCase().replace(/[^a-z0-9]+/g, '_') || 'unknown'}`
|
|
445
|
+
: 'unknown_no_context';
|
|
446
|
+
appendServerToolProgressFileEvent({
|
|
447
|
+
requestId: options.requestId,
|
|
448
|
+
flowId: 'none',
|
|
449
|
+
tool: 'stop_message_auto',
|
|
450
|
+
stage: 'compare',
|
|
451
|
+
result: compareResult,
|
|
452
|
+
message: summary,
|
|
453
|
+
step: 2,
|
|
454
|
+
entryEndpoint: options.entryEndpoint,
|
|
455
|
+
providerProtocol: options.providerProtocol
|
|
456
|
+
});
|
|
457
|
+
}
|
|
432
458
|
};
|
|
433
459
|
const logStopCompare = (stage, flowId) => {
|
|
434
460
|
const compareContext = readStopMessageCompareContext(options.adapterContext);
|
|
@@ -495,13 +521,28 @@ export async function runServerToolOrchestration(options) {
|
|
|
495
521
|
providerProtocol: options.providerProtocol,
|
|
496
522
|
providerInvoker: options.providerInvoker,
|
|
497
523
|
reenterPipeline: options.reenterPipeline,
|
|
524
|
+
clientInjectDispatch: options.clientInjectDispatch,
|
|
498
525
|
onAutoHookTrace: logAutoHookTrace
|
|
499
526
|
};
|
|
500
|
-
const
|
|
527
|
+
const runEngine = async (overrides) => withTimeout(runServerSideToolEngine({
|
|
528
|
+
...engineOptions,
|
|
529
|
+
...overrides
|
|
530
|
+
}), effectiveServerToolTimeoutMs, () => createServerToolTimeoutError({
|
|
501
531
|
requestId: options.requestId,
|
|
502
532
|
phase: 'engine',
|
|
503
533
|
timeoutMs: effectiveServerToolTimeoutMs || serverToolTimeoutMs
|
|
504
534
|
}));
|
|
535
|
+
// StopMessage owns a dedicated orchestration skeleton:
|
|
536
|
+
// same trigger/processing semantics as before, but isolated from the generic servertool queue.
|
|
537
|
+
let engineResult = await runEngine({
|
|
538
|
+
disableToolCallHandlers: true,
|
|
539
|
+
includeAutoHookIds: ['stop_message_auto']
|
|
540
|
+
});
|
|
541
|
+
if (engineResult.mode === 'passthrough' || !engineResult.execution) {
|
|
542
|
+
engineResult = await runEngine({
|
|
543
|
+
excludeAutoHookIds: ['stop_message_auto']
|
|
544
|
+
});
|
|
545
|
+
}
|
|
505
546
|
if (engineResult.mode === 'passthrough' || !engineResult.execution) {
|
|
506
547
|
const skipReason = engineResult.mode === 'passthrough' ? 'passthrough' : 'no_execution';
|
|
507
548
|
if (stopSignal.observed) {
|
|
@@ -583,7 +624,7 @@ export async function runServerToolOrchestration(options) {
|
|
|
583
624
|
flowId: engineResult.execution.flowId
|
|
584
625
|
};
|
|
585
626
|
}
|
|
586
|
-
if (!engineResult.execution.followup
|
|
627
|
+
if (!engineResult.execution.followup) {
|
|
587
628
|
logProgress(5, totalSteps, 'completed (no followup)', { flowId });
|
|
588
629
|
return {
|
|
589
630
|
chat: engineResult.finalChatResponse,
|
|
@@ -594,6 +635,7 @@ export async function runServerToolOrchestration(options) {
|
|
|
594
635
|
const isStopMessageFlow = engineResult.execution.flowId === 'stop_message_flow';
|
|
595
636
|
const isClockHoldFlow = engineResult.execution.flowId === 'clock_hold_flow';
|
|
596
637
|
const isContinueExecutionFlow = engineResult.execution.flowId === 'continue_execution_flow';
|
|
638
|
+
const isReviewFlow = engineResult.execution.flowId === 'review_flow';
|
|
597
639
|
const isEmptyReplyContinue = engineResult.execution.flowId === 'empty_reply_continue';
|
|
598
640
|
const isApplyPatchGuard = engineResult.execution.flowId === 'apply_patch_guard';
|
|
599
641
|
const isExecCommandGuard = engineResult.execution.flowId === 'exec_command_guard';
|
|
@@ -602,7 +644,9 @@ export async function runServerToolOrchestration(options) {
|
|
|
602
644
|
// ServerTool followups must not inherit or inject any routeHint; always route fresh.
|
|
603
645
|
const preserveRouteHint = false;
|
|
604
646
|
const followupPlan = engineResult.execution.followup;
|
|
605
|
-
const followupEntryEndpoint = engineResult.execution.followup
|
|
647
|
+
const followupEntryEndpoint = ('entryEndpoint' in engineResult.execution.followup
|
|
648
|
+
? engineResult.execution.followup.entryEndpoint
|
|
649
|
+
: undefined) ||
|
|
606
650
|
options.entryEndpoint ||
|
|
607
651
|
'/v1/chat/completions';
|
|
608
652
|
const followupPayloadRaw = (() => {
|
|
@@ -629,7 +673,12 @@ export async function runServerToolOrchestration(options) {
|
|
|
629
673
|
}
|
|
630
674
|
return null;
|
|
631
675
|
})();
|
|
632
|
-
|
|
676
|
+
const metadataOnlyFollowup = !followupPayloadRaw &&
|
|
677
|
+
Boolean(followupPlan &&
|
|
678
|
+
typeof followupPlan === 'object' &&
|
|
679
|
+
!Array.isArray(followupPlan) &&
|
|
680
|
+
Object.prototype.hasOwnProperty.call(followupPlan, 'metadata'));
|
|
681
|
+
if (!followupPayloadRaw && !metadataOnlyFollowup) {
|
|
633
682
|
logProgress(5, totalSteps, 'completed (missing followup payload)', { flowId });
|
|
634
683
|
return {
|
|
635
684
|
chat: engineResult.finalChatResponse,
|
|
@@ -637,7 +686,9 @@ export async function runServerToolOrchestration(options) {
|
|
|
637
686
|
flowId: engineResult.execution.flowId
|
|
638
687
|
};
|
|
639
688
|
}
|
|
640
|
-
const loopState =
|
|
689
|
+
const loopState = followupPayloadRaw
|
|
690
|
+
? buildServerToolLoopState(options.adapterContext, engineResult.execution.flowId, followupPayloadRaw, engineResult.finalChatResponse)
|
|
691
|
+
: null;
|
|
641
692
|
const stopMessageReservation = null;
|
|
642
693
|
if (applyAutoLimit && loopState && typeof loopState.repeatCount === 'number' && loopState.repeatCount >= 3) {
|
|
643
694
|
logProgress(5, totalSteps, 'completed (auto limit hit)', { flowId });
|
|
@@ -712,7 +763,7 @@ export async function runServerToolOrchestration(options) {
|
|
|
712
763
|
// For stateful auto-followups (e.g. stop_message_flow / clock_hold_flow / continue_execution_flow),
|
|
713
764
|
// keep the same providerKey/alias.
|
|
714
765
|
// Otherwise the followup requestId suffix would cause round-robin alias switching and compatibility drift.
|
|
715
|
-
if (isStopMessageFlow || isClockHoldFlow || isContinueExecutionFlow) {
|
|
766
|
+
if (isStopMessageFlow || isClockHoldFlow || isContinueExecutionFlow || isReviewFlow) {
|
|
716
767
|
const providerKeyRaw = options.adapterContext.providerKey;
|
|
717
768
|
const providerKey = typeof providerKeyRaw === 'string' && providerKeyRaw.trim().length ? providerKeyRaw.trim() : '';
|
|
718
769
|
if (providerKey) {
|
|
@@ -722,9 +773,115 @@ export async function runServerToolOrchestration(options) {
|
|
|
722
773
|
const retryEmptyFollowupOnce = isStopMessageFlow || isEmptyReplyContinue;
|
|
723
774
|
const maxAttempts = retryEmptyFollowupOnce ? 2 : 1;
|
|
724
775
|
const followupRequestId = buildFollowupRequestId(options.requestId, engineResult.execution.followup.requestIdSuffix);
|
|
776
|
+
const clientInjectOnlyRaw = metadata.clientInjectOnly;
|
|
777
|
+
const clientInjectOnly = clientInjectOnlyRaw === true ||
|
|
778
|
+
(typeof clientInjectOnlyRaw === 'string' && clientInjectOnlyRaw.trim().toLowerCase() === 'true');
|
|
779
|
+
if (clientInjectOnly) {
|
|
780
|
+
if (!options.clientInjectDispatch) {
|
|
781
|
+
const wrapped = new ProviderProtocolError('[servertool] client inject dispatcher unavailable', {
|
|
782
|
+
code: 'SERVERTOOL_FOLLOWUP_FAILED',
|
|
783
|
+
category: 'INTERNAL_ERROR',
|
|
784
|
+
details: {
|
|
785
|
+
flowId: engineResult.execution.flowId,
|
|
786
|
+
requestId: options.requestId,
|
|
787
|
+
upstreamCode: 'client_inject_failed',
|
|
788
|
+
reason: 'client_inject_dispatcher_unavailable'
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
wrapped.status = 502;
|
|
792
|
+
throw wrapped;
|
|
793
|
+
}
|
|
794
|
+
const disconnectWatcher = createClientDisconnectWatcher({
|
|
795
|
+
adapterContext: options.adapterContext,
|
|
796
|
+
requestId: options.requestId,
|
|
797
|
+
flowId: engineResult.execution.flowId
|
|
798
|
+
});
|
|
799
|
+
try {
|
|
800
|
+
const injectFollowupBody = followupPayloadRaw && typeof followupPayloadRaw === 'object' && !Array.isArray(followupPayloadRaw)
|
|
801
|
+
? coerceFollowupPayloadStream(followupPayloadRaw, metadata.stream === true)
|
|
802
|
+
: {};
|
|
803
|
+
const dispatchResult = await withTimeout(Promise.race([
|
|
804
|
+
options.clientInjectDispatch({
|
|
805
|
+
entryEndpoint: followupEntryEndpoint,
|
|
806
|
+
requestId: followupRequestId,
|
|
807
|
+
body: injectFollowupBody,
|
|
808
|
+
metadata
|
|
809
|
+
}),
|
|
810
|
+
disconnectWatcher.promise
|
|
811
|
+
]), followupTimeoutMs, () => createServerToolTimeoutError({
|
|
812
|
+
requestId: options.requestId,
|
|
813
|
+
phase: 'followup',
|
|
814
|
+
timeoutMs: followupTimeoutMs,
|
|
815
|
+
flowId: engineResult.execution.flowId
|
|
816
|
+
}));
|
|
817
|
+
if (!dispatchResult || dispatchResult.ok !== true) {
|
|
818
|
+
const wrapped = new ProviderProtocolError('[servertool.inject] client injection failed', {
|
|
819
|
+
code: 'SERVERTOOL_FOLLOWUP_FAILED',
|
|
820
|
+
details: {
|
|
821
|
+
flowId: engineResult.execution.flowId,
|
|
822
|
+
requestId: options.requestId,
|
|
823
|
+
upstreamCode: 'client_inject_failed',
|
|
824
|
+
reason: dispatchResult && typeof dispatchResult.reason === 'string' && dispatchResult.reason.trim()
|
|
825
|
+
? dispatchResult.reason.trim()
|
|
826
|
+
: 'client_inject_not_handled'
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
wrapped.status = 502;
|
|
830
|
+
throw wrapped;
|
|
831
|
+
}
|
|
832
|
+
disconnectWatcher.cancel();
|
|
833
|
+
const decorated = decorateFinalChatWithServerToolContext(engineResult.finalChatResponse, engineResult.execution);
|
|
834
|
+
logProgress(5, totalSteps, 'completed (client inject only)', { flowId });
|
|
835
|
+
return {
|
|
836
|
+
chat: decorated,
|
|
837
|
+
executed: true,
|
|
838
|
+
flowId: engineResult.execution.flowId
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
catch (error) {
|
|
842
|
+
disconnectWatcher.cancel();
|
|
843
|
+
if (isServerToolClientDisconnectedError(error) || isAdapterClientDisconnected(options.adapterContext)) {
|
|
844
|
+
logProgress(5, totalSteps, 'completed (client disconnected)', { flowId });
|
|
845
|
+
return {
|
|
846
|
+
chat: engineResult.finalChatResponse,
|
|
847
|
+
executed: true,
|
|
848
|
+
flowId: engineResult.execution.flowId
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
if (isStopMessageFlow) {
|
|
852
|
+
disableStopMessageAfterFailedFollowup(options.adapterContext, stopMessageReservation);
|
|
853
|
+
logProgress(5, totalSteps, 'failed (stopMessage client inject failed; state cleared)', { flowId });
|
|
854
|
+
throw error;
|
|
855
|
+
}
|
|
856
|
+
throw error;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
if (!options.reenterPipeline) {
|
|
860
|
+
const wrapped = new ProviderProtocolError('[servertool] followup requires reenter pipeline', {
|
|
861
|
+
code: 'SERVERTOOL_FOLLOWUP_FAILED',
|
|
862
|
+
category: 'INTERNAL_ERROR',
|
|
863
|
+
details: {
|
|
864
|
+
flowId: engineResult.execution.flowId,
|
|
865
|
+
requestId: options.requestId,
|
|
866
|
+
reason: 'reenter_pipeline_unavailable'
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
wrapped.status = 502;
|
|
870
|
+
throw wrapped;
|
|
871
|
+
}
|
|
872
|
+
if (!followupPayloadRaw) {
|
|
873
|
+
const decorated = decorateFinalChatWithServerToolContext(engineResult.finalChatResponse, engineResult.execution);
|
|
874
|
+
logProgress(5, totalSteps, 'completed (metadata-only followup without payload)', { flowId });
|
|
875
|
+
return {
|
|
876
|
+
chat: decorated,
|
|
877
|
+
executed: true,
|
|
878
|
+
flowId: engineResult.execution.flowId
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
// Build followup payload for non-client-inject flows
|
|
725
882
|
let followupPayload = coerceFollowupPayloadStream(followupPayloadRaw, metadata.stream === true);
|
|
726
|
-
if (shouldInjectStopLoopWarning) {
|
|
727
|
-
appendStopMessageLoopWarning(followupPayload, loopState
|
|
883
|
+
if (shouldInjectStopLoopWarning && loopState) {
|
|
884
|
+
appendStopMessageLoopWarning(followupPayload, loopState.stopPairRepeatCount ?? STOP_MESSAGE_LOOP_WARN_THRESHOLD);
|
|
728
885
|
}
|
|
729
886
|
followupPayload = applyHubFollowupPolicyShadow({
|
|
730
887
|
requestId: followupRequestId,
|
|
@@ -819,6 +976,11 @@ export async function runServerToolOrchestration(options) {
|
|
|
819
976
|
}
|
|
820
977
|
lastError = error;
|
|
821
978
|
if (attempt >= maxAttempts) {
|
|
979
|
+
if (isStopMessageFlow) {
|
|
980
|
+
disableStopMessageAfterFailedFollowup(options.adapterContext, stopMessageReservation);
|
|
981
|
+
logProgress(5, totalSteps, 'failed (stopMessage followup failed; state cleared)', { flowId, attempt });
|
|
982
|
+
throw error;
|
|
983
|
+
}
|
|
822
984
|
const wrapped = new ProviderProtocolError(`[servertool] Followup failed for flow ${engineResult.execution.flowId ?? 'unknown'} ` +
|
|
823
985
|
`(attempt ${attempt}/${maxAttempts})`, {
|
|
824
986
|
code: 'SERVERTOOL_FOLLOWUP_FAILED',
|
|
@@ -840,18 +1002,8 @@ export async function runServerToolOrchestration(options) {
|
|
|
840
1002
|
: undefined;
|
|
841
1003
|
if (retryEmptyFollowupOnce && (!followupBody || isEmptyClientResponsePayload(followupBody))) {
|
|
842
1004
|
if (isStopMessageFlow) {
|
|
843
|
-
// 对 stopMessage:先清理状态,避免后续请求继续触发失败循环;
|
|
844
|
-
// 若原始响应可用则回退原始响应,否则显式抛错,避免“静默空响应”。
|
|
845
1005
|
disableStopMessageAfterFailedFollowup(options.adapterContext, stopMessageReservation);
|
|
846
|
-
|
|
847
|
-
if (fallbackOriginal && !isEmptyClientResponsePayload(fallbackOriginal)) {
|
|
848
|
-
logProgress(5, totalSteps, 'completed (stopMessage followup empty; fallback to original)', { flowId });
|
|
849
|
-
return {
|
|
850
|
-
chat: fallbackOriginal,
|
|
851
|
-
executed: true,
|
|
852
|
-
flowId: engineResult.execution.flowId
|
|
853
|
-
};
|
|
854
|
-
}
|
|
1006
|
+
logProgress(5, totalSteps, 'failed (stopMessage followup empty; state cleared)', { flowId });
|
|
855
1007
|
throw createEmptyFollowupError({
|
|
856
1008
|
flowId: engineResult.execution.flowId,
|
|
857
1009
|
requestId: options.requestId,
|
|
@@ -976,6 +1128,8 @@ function disableStopMessageAfterFailedFollowup(adapterContext, reservation) {
|
|
|
976
1128
|
state.stopMessageSource = undefined;
|
|
977
1129
|
state.stopMessageUpdatedAt = now;
|
|
978
1130
|
state.stopMessageLastUsedAt = now;
|
|
1131
|
+
state.stopMessageAiSeedPrompt = undefined;
|
|
1132
|
+
state.stopMessageAiHistory = undefined;
|
|
979
1133
|
saveRoutingInstructionStateSync(key, state);
|
|
980
1134
|
}
|
|
981
1135
|
catch {
|
|
@@ -988,67 +1142,30 @@ function resolveStickyKeyFromAdapterContext(adapterContext) {
|
|
|
988
1142
|
}
|
|
989
1143
|
const record = adapterContext;
|
|
990
1144
|
const runtime = readRuntimeMetadata(record);
|
|
991
|
-
const
|
|
992
|
-
readTextFromAny(runtime?.
|
|
993
|
-
readTextFromAny(record.
|
|
994
|
-
readTextFromAny(
|
|
995
|
-
if (
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
readTextFromAny(
|
|
1007
|
-
readTextFromAny(
|
|
1008
|
-
readTextFromAny(
|
|
1009
|
-
|
|
1010
|
-
readTextFromAny(
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
if (sessionId) {
|
|
1014
|
-
return `session:${sessionId}`;
|
|
1015
|
-
}
|
|
1016
|
-
if (conversationId) {
|
|
1017
|
-
return `conversation:${conversationId}`;
|
|
1018
|
-
}
|
|
1019
|
-
const requestId = resolveStickyRequestId(record, runtime);
|
|
1020
|
-
return requestId || undefined;
|
|
1021
|
-
}
|
|
1022
|
-
function resolveStickyRequestId(context, runtime) {
|
|
1023
|
-
return (readTextFromAny(context.requestId) ||
|
|
1024
|
-
readTextFromAny(context.request_id) ||
|
|
1025
|
-
readTextFromAny(runtime?.requestId) ||
|
|
1026
|
-
readTextFromAny(runtime?.request_id));
|
|
1027
|
-
}
|
|
1028
|
-
function resolveResponsesResumePreviousRequestId(context, runtime) {
|
|
1029
|
-
const contextMetadata = asRecord(context.metadata);
|
|
1030
|
-
const contextMetadataContext = asRecord(contextMetadata?.context);
|
|
1031
|
-
const originalRequest = asRecord(context.originalRequest);
|
|
1032
|
-
const originalMetadata = asRecord(originalRequest?.metadata);
|
|
1033
|
-
const candidates = [
|
|
1034
|
-
context.responsesResume,
|
|
1035
|
-
contextMetadata?.responsesResume,
|
|
1036
|
-
contextMetadataContext?.responsesResume,
|
|
1037
|
-
originalRequest?.responsesResume,
|
|
1038
|
-
originalMetadata?.responsesResume,
|
|
1039
|
-
runtime?.responsesResume
|
|
1040
|
-
];
|
|
1041
|
-
for (const candidate of candidates) {
|
|
1042
|
-
const resume = asRecord(candidate);
|
|
1043
|
-
if (!resume) {
|
|
1044
|
-
continue;
|
|
1045
|
-
}
|
|
1046
|
-
const previousRequestId = readTextFromAny(resume.previousRequestId) || readTextFromAny(resume.previous_request_id);
|
|
1047
|
-
if (previousRequestId) {
|
|
1048
|
-
return previousRequestId;
|
|
1049
|
-
}
|
|
1145
|
+
const explicitScope = readTextFromAny(runtime?.stopMessageClientInjectSessionScope) ||
|
|
1146
|
+
readTextFromAny(runtime?.stopMessageClientInjectScope) ||
|
|
1147
|
+
readTextFromAny(record.stopMessageClientInjectSessionScope) ||
|
|
1148
|
+
readTextFromAny(record.stopMessageClientInjectScope);
|
|
1149
|
+
if (explicitScope && explicitScope.startsWith('tmux:')) {
|
|
1150
|
+
return explicitScope;
|
|
1151
|
+
}
|
|
1152
|
+
const metadata = asRecord(record.metadata);
|
|
1153
|
+
const tmuxSessionId = readTextFromAny(record.clientTmuxSessionId) ||
|
|
1154
|
+
readTextFromAny(record.client_tmux_session_id) ||
|
|
1155
|
+
readTextFromAny(record.tmuxSessionId) ||
|
|
1156
|
+
readTextFromAny(record.tmux_session_id) ||
|
|
1157
|
+
readTextFromAny(runtime?.clientTmuxSessionId) ||
|
|
1158
|
+
readTextFromAny(runtime?.client_tmux_session_id) ||
|
|
1159
|
+
readTextFromAny(runtime?.tmuxSessionId) ||
|
|
1160
|
+
readTextFromAny(runtime?.tmux_session_id) ||
|
|
1161
|
+
readTextFromAny(metadata?.clientTmuxSessionId) ||
|
|
1162
|
+
readTextFromAny(metadata?.client_tmux_session_id) ||
|
|
1163
|
+
readTextFromAny(metadata?.tmuxSessionId) ||
|
|
1164
|
+
readTextFromAny(metadata?.tmux_session_id);
|
|
1165
|
+
if (!tmuxSessionId) {
|
|
1166
|
+
return undefined;
|
|
1050
1167
|
}
|
|
1051
|
-
return
|
|
1168
|
+
return `tmux:${tmuxSessionId}`;
|
|
1052
1169
|
}
|
|
1053
1170
|
function asRecord(value) {
|
|
1054
1171
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
@@ -57,7 +57,7 @@ function buildClockToolSchema() {
|
|
|
57
57
|
type: 'function',
|
|
58
58
|
function: {
|
|
59
59
|
name: 'clock',
|
|
60
|
-
description: 'Time + Alarm for this session. Use get/schedule/update/list/cancel/clear. Scheduled reminders will be injected into future requests.',
|
|
60
|
+
description: 'Time + Alarm for this session. If waiting longer than 2 minutes is required, call clock.schedule now (do not only promise to wait). Format example: {"action":"schedule","items":[{"dueAt":"<ISO8601>","task":"<exact follow-up action>","tool":"<tool-name-or-empty>","arguments":"<json-string-or-{}>"}],"taskId":""}. Use get/schedule/update/list/cancel/clear. Scheduled reminders will be injected into future requests.',
|
|
61
61
|
strict: true,
|
|
62
62
|
parameters: {
|
|
63
63
|
type: 'object',
|
|
@@ -65,7 +65,7 @@ function buildClockToolSchema() {
|
|
|
65
65
|
action: {
|
|
66
66
|
type: 'string',
|
|
67
67
|
enum: ['get', 'schedule', 'update', 'list', 'cancel', 'clear'],
|
|
68
|
-
description: 'Get current time, or schedule/update/list/cancel/clear session-scoped reminders.'
|
|
68
|
+
description: 'Get current time, or schedule/update/list/cancel/clear session-scoped reminders. If waiting longer than 2 minutes is required, use action="schedule" immediately.'
|
|
69
69
|
},
|
|
70
70
|
items: {
|
|
71
71
|
type: 'array',
|
|
@@ -385,7 +385,7 @@ const handler = async (ctx) => {
|
|
|
385
385
|
return respond({
|
|
386
386
|
ok: false,
|
|
387
387
|
action,
|
|
388
|
-
message: 'clock requires session scope (
|
|
388
|
+
message: 'clock requires tmux session scope (clientTmuxSessionId/tmuxSessionId).'
|
|
389
389
|
});
|
|
390
390
|
}
|
|
391
391
|
if (action === 'list') {
|
|
@@ -54,7 +54,7 @@ const handler = async (ctx) => {
|
|
|
54
54
|
}
|
|
55
55
|
const parsed = parseToolArguments(toolCall);
|
|
56
56
|
const reason = normalizeReason(parsed);
|
|
57
|
-
const followupText = '
|
|
57
|
+
const followupText = '继续执行当前任务。强制规则:凡是“仅汇报进度”或“准备 stop/end_turn”,都必须先调用 CONTINUE execution(continue_execution,可传 {"reason":"progress_update"})。进度汇报顺序必须是:1) 先调 continue_execution;2) 最多 5 行简短汇报;3) 立即继续真实动作。进度汇报后禁止 finish_reason=stop/end_turn;仅在任务真正完成后才允许最终总结。';
|
|
58
58
|
return {
|
|
59
59
|
flowId: FLOW_ID,
|
|
60
60
|
finalize: async () => {
|
|
@@ -64,7 +64,7 @@ const handler = async (ctx) => {
|
|
|
64
64
|
noop: true,
|
|
65
65
|
action: 'continue_execution',
|
|
66
66
|
...(reason ? { reason } : {}),
|
|
67
|
-
message: 'No-op acknowledged.
|
|
67
|
+
message: 'No-op acknowledged. continue_execution is mandatory before progress-only summaries or stop/end_turn. Do not emit finish_reason=stop/end_turn for progress-only updates. After summary, continue real actions immediately; server auto-followup keeps execution moving.'
|
|
68
68
|
});
|
|
69
69
|
return {
|
|
70
70
|
chatResponse: patched,
|
|
@@ -78,9 +78,13 @@ const handler = async (ctx) => {
|
|
|
78
78
|
{ op: 'preserve_tools' },
|
|
79
79
|
{ op: 'ensure_standard_tools' },
|
|
80
80
|
{ op: 'append_assistant_message', required: true },
|
|
81
|
-
{ op: 'append_tool_messages_from_tool_outputs', required: true }
|
|
82
|
-
{ op: 'append_user_text', text: followupText }
|
|
81
|
+
{ op: 'append_tool_messages_from_tool_outputs', required: true }
|
|
83
82
|
]
|
|
83
|
+
},
|
|
84
|
+
metadata: {
|
|
85
|
+
clientInjectOnly: true,
|
|
86
|
+
clientInjectText: '继续执行',
|
|
87
|
+
clientInjectSource: 'servertool.continue_execution'
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
90
|
}
|
|
@@ -331,7 +331,7 @@ function buildStandardFollowupTools() {
|
|
|
331
331
|
type: 'function',
|
|
332
332
|
function: {
|
|
333
333
|
name: 'continue_execution',
|
|
334
|
-
description: 'No-op control tool
|
|
334
|
+
description: 'No-op control tool for progress reporting without interrupting execution. Mandatory rule: if you are giving a progress-only update or are about to stop/end_turn, you MUST call continue_execution first (example arguments: {"reason":"progress_update"}). Required sequence: (1) call continue_execution, (2) provide a brief progress summary (<=5 lines), (3) immediately continue real actions. Do NOT emit finish_reason=stop/end_turn for progress-only updates. Only stop when the overall goal is complete. If waiting longer than 2 minutes is needed, use clock.schedule instead.',
|
|
335
335
|
parameters: {
|
|
336
336
|
type: 'object',
|
|
337
337
|
properties: {},
|
|
@@ -340,6 +340,23 @@ function buildStandardFollowupTools() {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
},
|
|
343
|
+
{
|
|
344
|
+
type: 'function',
|
|
345
|
+
function: {
|
|
346
|
+
name: 'review',
|
|
347
|
+
description: 'Independent reviewer handoff. Use when you need an external evidence-based code review before claiming completion. The review result will be injected back to client as next-step guidance. Do not stop immediately after this tool.',
|
|
348
|
+
parameters: {
|
|
349
|
+
type: 'object',
|
|
350
|
+
properties: {
|
|
351
|
+
goal: { type: 'string' },
|
|
352
|
+
context: { type: 'string' },
|
|
353
|
+
focus: { type: 'string' }
|
|
354
|
+
},
|
|
355
|
+
required: ['goal', 'context', 'focus'],
|
|
356
|
+
additionalProperties: false
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
},
|
|
343
360
|
{
|
|
344
361
|
type: 'function',
|
|
345
362
|
function: {
|
|
@@ -186,11 +186,17 @@ function extractResponsesOutputText(base) {
|
|
|
186
186
|
const pType = typeof part.type === 'string'
|
|
187
187
|
? String(part.type).trim().toLowerCase()
|
|
188
188
|
: '';
|
|
189
|
-
if (pType === 'output_text') {
|
|
189
|
+
if (pType === 'output_text' || pType === 'text' || pType === 'input_text') {
|
|
190
190
|
const text = typeof part.text === 'string' ? String(part.text) : '';
|
|
191
191
|
if (text.trim().length)
|
|
192
192
|
chunks.push(text.trim());
|
|
193
|
+
continue;
|
|
193
194
|
}
|
|
195
|
+
const fallback = typeof part.content === 'string'
|
|
196
|
+
? String(part.content).trim()
|
|
197
|
+
: '';
|
|
198
|
+
if (fallback.length)
|
|
199
|
+
chunks.push(fallback);
|
|
194
200
|
}
|
|
195
201
|
}
|
|
196
202
|
return chunks.join('\n').trim();
|