@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
|
@@ -6,9 +6,37 @@ import { augmentOpenAITools } from '../../guidance/index.js';
|
|
|
6
6
|
import { validateToolCall } from '../../tools/tool-registry.js';
|
|
7
7
|
import { captureApplyPatchRegression } from '../../tools/patch-regression-capturer.js';
|
|
8
8
|
import { normalizeExecCommandArgs } from '../../tools/exec-command/normalize.js';
|
|
9
|
+
import { readRuntimeMetadata } from './runtime-metadata.js';
|
|
9
10
|
function isObject(v) { return !!v && typeof v === 'object' && !Array.isArray(v); }
|
|
10
11
|
// Note: tool schema strict augmentation removed per alignment
|
|
11
12
|
function enforceChatBudget(chat, _modelId) { return chat; }
|
|
13
|
+
function resolveExecCommandGuardValidationOptions(payload) {
|
|
14
|
+
const carrier = isObject(payload.metadata)
|
|
15
|
+
? payload.metadata
|
|
16
|
+
: payload;
|
|
17
|
+
const rt = readRuntimeMetadata(carrier);
|
|
18
|
+
if (!rt || typeof rt !== 'object') {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const guardRaw = rt.execCommandGuard;
|
|
22
|
+
if (!guardRaw || typeof guardRaw !== 'object' || Array.isArray(guardRaw)) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const guard = guardRaw;
|
|
26
|
+
const enabled = guard.enabled === true;
|
|
27
|
+
if (!enabled) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const policyFile = typeof guard.policyFile === 'string' && guard.policyFile.trim().length
|
|
31
|
+
? guard.policyFile.trim()
|
|
32
|
+
: undefined;
|
|
33
|
+
return {
|
|
34
|
+
execCommandGuard: {
|
|
35
|
+
enabled: true,
|
|
36
|
+
...(policyFile ? { policyFile } : {})
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
12
40
|
function isTruthyEnv(value) {
|
|
13
41
|
const v = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
14
42
|
return v === '1' || v === 'true' || v === 'yes' || v === 'on';
|
|
@@ -116,9 +144,11 @@ function buildExecCommandGuardScript(reason, message) {
|
|
|
116
144
|
? 'blocked by exec_command guard: git reset --hard is forbidden. Use git reset --mixed REF or git restore --source REF -- FILE.'
|
|
117
145
|
: reason === 'forbidden_git_checkout_scope'
|
|
118
146
|
? 'blocked by exec_command guard: git checkout is allowed only for a single file. Use git checkout -- FILE or git checkout REF -- FILE.'
|
|
119
|
-
:
|
|
120
|
-
? `
|
|
121
|
-
:
|
|
147
|
+
: reason === 'forbidden_exec_command_policy'
|
|
148
|
+
? `policy 不允许: ${(message || '').trim() || 'command blocked by policy'}`
|
|
149
|
+
: message && message.trim()
|
|
150
|
+
? `blocked by exec_command guard: ${message.trim()}`
|
|
151
|
+
: fallback;
|
|
122
152
|
const compact = detail.replace(/\s+/g, ' ').trim() || fallback;
|
|
123
153
|
return `bash -lc "printf '%s\\n' ${shellSingleQuote(compact)} >&2; exit 2"`;
|
|
124
154
|
}
|
|
@@ -158,7 +188,7 @@ function buildBlockedExecCommandArgs(rawArgs, reason, message) {
|
|
|
158
188
|
}
|
|
159
189
|
}
|
|
160
190
|
const EXEC_COMMAND_NAME_AS_COMMAND_PATTERN = /^(?:rg|wc|cat|ls|find|grep|git|sed|head|tail|awk|bash|sh|zsh|node|npm|pnpm|yarn|bd|echo|cp|mv|rm|mkdir|python|python3|perl|ruby)\b/i;
|
|
161
|
-
function repairCommandNameAsExecToolCall(fn) {
|
|
191
|
+
function repairCommandNameAsExecToolCall(fn, validationOptions) {
|
|
162
192
|
try {
|
|
163
193
|
if (!fn)
|
|
164
194
|
return false;
|
|
@@ -195,7 +225,7 @@ function repairCommandNameAsExecToolCall(fn) {
|
|
|
195
225
|
if (typeof argsObj.cwd === 'string' && (!argsObj.workdir || typeof argsObj.workdir !== 'string')) {
|
|
196
226
|
argsObj.workdir = String(argsObj.cwd);
|
|
197
227
|
}
|
|
198
|
-
const validation = validateToolCall('exec_command', JSON.stringify(argsObj));
|
|
228
|
+
const validation = validateToolCall('exec_command', JSON.stringify(argsObj), validationOptions);
|
|
199
229
|
if (validation.ok && typeof validation.normalizedArgs === 'string') {
|
|
200
230
|
fn.arguments = validation.normalizedArgs;
|
|
201
231
|
}
|
|
@@ -247,114 +277,6 @@ function tryWriteSnapshot(options, stage, data) {
|
|
|
247
277
|
* - Inject/Refine system tool guidance (idempotent)
|
|
248
278
|
* - Canonicalize structured tool_calls; set content=null when applicable
|
|
249
279
|
*/
|
|
250
|
-
const IMAGE_EXT_RE = /\.(png|jpe?g|gif|webp|bmp|svg)(?:[?#].*)?$/i;
|
|
251
|
-
function hasImageReference(messages) {
|
|
252
|
-
if (!Array.isArray(messages))
|
|
253
|
-
return false;
|
|
254
|
-
for (const entry of messages) {
|
|
255
|
-
if (!entry || typeof entry !== 'object')
|
|
256
|
-
continue;
|
|
257
|
-
const content = entry.content;
|
|
258
|
-
if (!content)
|
|
259
|
-
continue;
|
|
260
|
-
if (Array.isArray(content)) {
|
|
261
|
-
if (content.some((part) => isImagePart(part)))
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
else if (isObject(content)) {
|
|
265
|
-
if (isImagePart(content))
|
|
266
|
-
return true;
|
|
267
|
-
}
|
|
268
|
-
else if (typeof content === 'string') {
|
|
269
|
-
if (stringHasImageLink(content))
|
|
270
|
-
return true;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return false;
|
|
274
|
-
}
|
|
275
|
-
function hasInputImage(entries) {
|
|
276
|
-
if (!Array.isArray(entries))
|
|
277
|
-
return false;
|
|
278
|
-
for (const entry of entries) {
|
|
279
|
-
if (!entry || typeof entry !== 'object')
|
|
280
|
-
continue;
|
|
281
|
-
const type = String(entry.type || '').toLowerCase();
|
|
282
|
-
if (type.includes('image'))
|
|
283
|
-
return true;
|
|
284
|
-
const content = entry.content;
|
|
285
|
-
if (!content)
|
|
286
|
-
continue;
|
|
287
|
-
if (Array.isArray(content)) {
|
|
288
|
-
if (content.some((part) => isImagePart(part)))
|
|
289
|
-
return true;
|
|
290
|
-
}
|
|
291
|
-
else if (isObject(content)) {
|
|
292
|
-
if (isImagePart(content))
|
|
293
|
-
return true;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
function attachmentsHaveImage(payload) {
|
|
299
|
-
const attachments = payload?.attachments;
|
|
300
|
-
if (!Array.isArray(attachments))
|
|
301
|
-
return false;
|
|
302
|
-
for (const attachment of attachments) {
|
|
303
|
-
if (!attachment || typeof attachment !== 'object')
|
|
304
|
-
continue;
|
|
305
|
-
const mime = typeof attachment.mime === 'string' ? attachment.mime.toLowerCase() : '';
|
|
306
|
-
if (mime.startsWith('image/'))
|
|
307
|
-
return true;
|
|
308
|
-
const name = typeof attachment.name === 'string' ? attachment.name : '';
|
|
309
|
-
if (IMAGE_EXT_RE.test(name))
|
|
310
|
-
return true;
|
|
311
|
-
const url = typeof attachment.url === 'string' ? attachment.url : '';
|
|
312
|
-
if (stringHasImageLink(url))
|
|
313
|
-
return true;
|
|
314
|
-
}
|
|
315
|
-
return false;
|
|
316
|
-
}
|
|
317
|
-
function stringHasImageLink(value) {
|
|
318
|
-
if (!value)
|
|
319
|
-
return false;
|
|
320
|
-
if (value.includes('cid:'))
|
|
321
|
-
return true;
|
|
322
|
-
if (IMAGE_EXT_RE.test(value))
|
|
323
|
-
return true;
|
|
324
|
-
const lowered = value.toLowerCase();
|
|
325
|
-
return lowered.includes('image://');
|
|
326
|
-
}
|
|
327
|
-
function isImagePart(part) {
|
|
328
|
-
if (!part || typeof part !== 'object')
|
|
329
|
-
return false;
|
|
330
|
-
const type = String(part.type || '').toLowerCase();
|
|
331
|
-
if (type.includes('image'))
|
|
332
|
-
return true;
|
|
333
|
-
const imageUrl = part.image_url || part.imageUrl;
|
|
334
|
-
if (typeof imageUrl === 'string')
|
|
335
|
-
return true;
|
|
336
|
-
if (isObject(imageUrl) && typeof imageUrl.url === 'string')
|
|
337
|
-
return true;
|
|
338
|
-
const url = part.url;
|
|
339
|
-
if (typeof url === 'string' && stringHasImageLink(url))
|
|
340
|
-
return true;
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
function shouldExposeViewImage(payload) {
|
|
344
|
-
if (hasImageReference(payload?.messages))
|
|
345
|
-
return true;
|
|
346
|
-
if (hasInputImage(payload?.input))
|
|
347
|
-
return true;
|
|
348
|
-
if (attachmentsHaveImage(payload))
|
|
349
|
-
return true;
|
|
350
|
-
return false;
|
|
351
|
-
}
|
|
352
|
-
function isViewImageTool(tool) {
|
|
353
|
-
if (!tool || typeof tool !== 'object')
|
|
354
|
-
return false;
|
|
355
|
-
const name = String(tool.name || tool?.function?.name || '').toLowerCase();
|
|
356
|
-
return name === 'view_image';
|
|
357
|
-
}
|
|
358
280
|
export function processChatRequestTools(request, opts) {
|
|
359
281
|
const options = { ...(opts || {}) };
|
|
360
282
|
if (!isObject(request))
|
|
@@ -365,13 +287,6 @@ export function processChatRequestTools(request, opts) {
|
|
|
365
287
|
try {
|
|
366
288
|
let tools = Array.isArray(out?.tools) ? out.tools : [];
|
|
367
289
|
if (tools.length > 0) {
|
|
368
|
-
if (!shouldExposeViewImage(out)) {
|
|
369
|
-
const filtered = tools.filter((tool) => !isViewImageTool(tool));
|
|
370
|
-
if (filtered.length !== tools.length) {
|
|
371
|
-
tools = filtered;
|
|
372
|
-
out.tools = tools;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
290
|
for (const t of tools) {
|
|
376
291
|
if (!t || typeof t !== 'object')
|
|
377
292
|
continue;
|
|
@@ -425,10 +340,11 @@ export function processChatRequestTools(request, opts) {
|
|
|
425
340
|
* Process OpenAI Chat response (choices[0].message) with unified 标准 governance.
|
|
426
341
|
* - Canonicalize structured tool_calls; ensure finish_reason and content=null policy
|
|
427
342
|
*/
|
|
428
|
-
import {
|
|
343
|
+
import { parseLenientJsonishWithNative as parseLenient, repairArgumentsToStringWithNative as repairArgumentsToString } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
429
344
|
export function normalizeApplyPatchToolCallsOnResponse(chat) {
|
|
430
345
|
try {
|
|
431
346
|
const out = JSON.parse(JSON.stringify(chat));
|
|
347
|
+
const validationOptions = resolveExecCommandGuardValidationOptions(out);
|
|
432
348
|
const choices = Array.isArray(out?.choices) ? out.choices : [];
|
|
433
349
|
for (const ch of choices) {
|
|
434
350
|
const msg = ch && ch.message ? ch.message : undefined;
|
|
@@ -438,7 +354,7 @@ export function normalizeApplyPatchToolCallsOnResponse(chat) {
|
|
|
438
354
|
for (const tc of tcs) {
|
|
439
355
|
try {
|
|
440
356
|
const fn = tc && tc.function ? tc.function : undefined;
|
|
441
|
-
repairCommandNameAsExecToolCall(fn);
|
|
357
|
+
repairCommandNameAsExecToolCall(fn, validationOptions);
|
|
442
358
|
rewriteExecCommandApplyPatchCall(fn);
|
|
443
359
|
const name = typeof fn?.name === 'string' ? String(fn.name).trim().toLowerCase() : '';
|
|
444
360
|
if (name !== 'apply_patch')
|
|
@@ -488,6 +404,7 @@ export function normalizeApplyPatchToolCallsOnRequest(request) {
|
|
|
488
404
|
function normalizeSpecialToolCallsOnRequest(request) {
|
|
489
405
|
try {
|
|
490
406
|
const out = JSON.parse(JSON.stringify(request));
|
|
407
|
+
const validationOptions = resolveExecCommandGuardValidationOptions(out);
|
|
491
408
|
const messages = Array.isArray(out?.messages) ? out.messages : [];
|
|
492
409
|
// 仅针对「当轮」工具调用做校验与形态修复:选择最后一条 assistant 消息
|
|
493
410
|
let lastAssistantIndex = -1;
|
|
@@ -516,7 +433,7 @@ function normalizeSpecialToolCallsOnRequest(request) {
|
|
|
516
433
|
for (const tc of tcs) {
|
|
517
434
|
try {
|
|
518
435
|
const fn = tc && tc.function ? tc.function : undefined;
|
|
519
|
-
repairCommandNameAsExecToolCall(fn);
|
|
436
|
+
repairCommandNameAsExecToolCall(fn, validationOptions);
|
|
520
437
|
if (rewriteExecCommandApplyPatchCall(fn)) {
|
|
521
438
|
rewrittenNestedApplyPatchCount += 1;
|
|
522
439
|
}
|
|
@@ -555,7 +472,7 @@ function normalizeSpecialToolCallsOnRequest(request) {
|
|
|
555
472
|
// exec_command 兼容:TOON / map / string 一律收敛为 { cmd, command, workdir, ... }
|
|
556
473
|
if (name === 'exec_command') {
|
|
557
474
|
const argsStr = repairArgumentsToString(rawArgs);
|
|
558
|
-
const validation = validateToolCall('exec_command', argsStr);
|
|
475
|
+
const validation = validateToolCall('exec_command', argsStr, validationOptions);
|
|
559
476
|
if (validation && validation.ok && typeof validation.normalizedArgs === 'string') {
|
|
560
477
|
fn.arguments = validation.normalizedArgs;
|
|
561
478
|
}
|
|
@@ -603,6 +520,7 @@ function enhanceResponseToolArguments(chat) {
|
|
|
603
520
|
if (!enable)
|
|
604
521
|
return chat;
|
|
605
522
|
const out = JSON.parse(JSON.stringify(chat));
|
|
523
|
+
const validationOptions = resolveExecCommandGuardValidationOptions(out);
|
|
606
524
|
const choices = Array.isArray(out?.choices) ? out.choices : [];
|
|
607
525
|
for (const ch of choices) {
|
|
608
526
|
const msg = ch && ch.message ? ch.message : undefined;
|
|
@@ -686,7 +604,7 @@ function enhanceResponseToolArguments(chat) {
|
|
|
686
604
|
}
|
|
687
605
|
}
|
|
688
606
|
else if (name === 'exec_command') {
|
|
689
|
-
const validation = validateToolCall('exec_command', repaired);
|
|
607
|
+
const validation = validateToolCall('exec_command', repaired, validationOptions);
|
|
690
608
|
if (validation.ok && typeof validation.normalizedArgs === 'string') {
|
|
691
609
|
finalStr = validation.normalizedArgs;
|
|
692
610
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// - Handles structural shapes (function_call legacy, tool_calls)
|
|
5
5
|
// - Normalizes arguments (single JSON string), sets finish_reason when applicable
|
|
6
6
|
import { isStructuredApplyPatchPayload } from '../../tools/apply-patch-structured.js';
|
|
7
|
+
import { repairArgumentsToStringWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
7
8
|
function isObject(v) {
|
|
8
9
|
return !!v && typeof v === 'object' && !Array.isArray(v);
|
|
9
10
|
}
|
|
@@ -18,14 +19,7 @@ function hashString(s) {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
function toJsonString(v) {
|
|
21
|
-
|
|
22
|
-
return v;
|
|
23
|
-
try {
|
|
24
|
-
return JSON.stringify(v ?? {});
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return '{}';
|
|
28
|
-
}
|
|
22
|
+
return repairArgumentsToStringWithNative(v);
|
|
29
23
|
}
|
|
30
24
|
function genId(ctx, i = 0) {
|
|
31
25
|
const p = ctx?.idPrefix || 'call';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sanitizeResponsesFunctionNameWithNative } from '../../router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.js';
|
|
1
2
|
export function stringifyArgs(args) {
|
|
2
3
|
if (typeof args === 'string')
|
|
3
4
|
return args;
|
|
@@ -73,11 +74,7 @@ function enforceBuiltinToolSchema(name, candidate) {
|
|
|
73
74
|
return asSchema(candidate);
|
|
74
75
|
}
|
|
75
76
|
const DEFAULT_SANITIZER = (value) => {
|
|
76
|
-
|
|
77
|
-
const trimmed = value.trim();
|
|
78
|
-
return trimmed.length ? trimmed : undefined;
|
|
79
|
-
}
|
|
80
|
-
return undefined;
|
|
77
|
+
return sanitizeResponsesFunctionNameWithNative(value);
|
|
81
78
|
};
|
|
82
79
|
function resolveToolName(candidate, options) {
|
|
83
80
|
const sanitized = options?.sanitizeName?.(candidate);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Shared helpers for standard tool normalization (shell packing rules).
|
|
3
3
|
* The goal is deterministic, minimal shaping so executors succeed consistently.
|
|
4
4
|
*/
|
|
5
|
+
import { parseLenientJsonishWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
5
6
|
// We intentionally do NOT evaluate shell control operators (&&, |, etc.).
|
|
6
7
|
// Codex CLI executor runs argv directly (execvp-like), not through a shell.
|
|
7
8
|
// So we avoid wrapping with "bash -lc" and leave such tokens as-is.
|
|
@@ -45,6 +46,23 @@ export function splitCommandString(input) {
|
|
|
45
46
|
const s = input.trim();
|
|
46
47
|
if (!s)
|
|
47
48
|
return [];
|
|
49
|
+
try {
|
|
50
|
+
if (s.startsWith('{') || s.startsWith('[')) {
|
|
51
|
+
const parsed = parseLenientJsonishWithNative(s);
|
|
52
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
53
|
+
const command = parsed.command;
|
|
54
|
+
if (Array.isArray(command)) {
|
|
55
|
+
const tokens = command.map((entry) => String(entry ?? '')).map((entry) => entry.trim()).filter(Boolean);
|
|
56
|
+
if (tokens.length) {
|
|
57
|
+
return tokens;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Keep legacy parser path when native parse returns non-command payload.
|
|
65
|
+
}
|
|
48
66
|
const out = [];
|
|
49
67
|
let cur = '';
|
|
50
68
|
let inSingle = false;
|
|
Binary file
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function extractProviderId(providerKey: string): string | null;
|
|
3
|
-
export declare function normalizeAliasDescriptor(alias: string): string;
|
|
4
|
-
export declare function extractKeyAlias(providerKey: string): string | null;
|
|
5
|
-
export declare function extractKeyIndex(providerKey: string): number | undefined;
|
|
6
|
-
export declare function getProviderModelId(providerKey: string, providerRegistry: ProviderRegistry): string | null;
|
|
1
|
+
export { extractProviderId, normalizeAliasDescriptor, extractKeyAlias, extractKeyIndex, getProviderModelId } from '../../engine-selection/key-parsing.js';
|
|
@@ -1,43 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
const firstDot = providerKey.indexOf('.');
|
|
3
|
-
if (firstDot <= 0)
|
|
4
|
-
return null;
|
|
5
|
-
return providerKey.substring(0, firstDot);
|
|
6
|
-
}
|
|
7
|
-
export function normalizeAliasDescriptor(alias) {
|
|
8
|
-
if (/^\d+-/.test(alias)) {
|
|
9
|
-
return alias.replace(/^\d+-/, '');
|
|
10
|
-
}
|
|
11
|
-
return alias;
|
|
12
|
-
}
|
|
13
|
-
export function extractKeyAlias(providerKey) {
|
|
14
|
-
const parts = providerKey.split('.');
|
|
15
|
-
if (parts.length === 3) {
|
|
16
|
-
return normalizeAliasDescriptor(parts[1]);
|
|
17
|
-
}
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
export function extractKeyIndex(providerKey) {
|
|
21
|
-
const parts = providerKey.split('.');
|
|
22
|
-
if (parts.length === 2) {
|
|
23
|
-
const index = parseInt(parts[1], 10);
|
|
24
|
-
if (!isNaN(index) && index > 0) {
|
|
25
|
-
return index;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
export function getProviderModelId(providerKey, providerRegistry) {
|
|
31
|
-
const profile = providerRegistry.get(providerKey);
|
|
32
|
-
if (profile.modelId) {
|
|
33
|
-
return profile.modelId;
|
|
34
|
-
}
|
|
35
|
-
const parts = providerKey.split('.');
|
|
36
|
-
if (parts.length === 2) {
|
|
37
|
-
return parts[1] || null;
|
|
38
|
-
}
|
|
39
|
-
if (parts.length === 3) {
|
|
40
|
-
return parts[2] || null;
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
1
|
+
export { extractProviderId, normalizeAliasDescriptor, extractKeyAlias, extractKeyIndex, getProviderModelId } from '../../engine-selection/key-parsing.js';
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import { mergeStopMessageFromPersisted } from '../../stop-message-state-sync.js';
|
|
2
|
+
function readToken(value) {
|
|
3
|
+
if (typeof value !== 'string') {
|
|
4
|
+
return '';
|
|
5
|
+
}
|
|
6
|
+
const trimmed = value.trim();
|
|
7
|
+
return trimmed || '';
|
|
8
|
+
}
|
|
9
|
+
function isPersistentScopeKey(key) {
|
|
10
|
+
if (!key) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return key.startsWith('session:')
|
|
14
|
+
|| key.startsWith('conversation:')
|
|
15
|
+
|| key.startsWith('tmux:');
|
|
16
|
+
}
|
|
2
17
|
export function resolveStopMessageScope(metadata) {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
18
|
+
const explicitScope = readToken(metadata?.stopMessageClientInjectSessionScope)
|
|
19
|
+
|| readToken(metadata?.stopMessageClientInjectScope);
|
|
20
|
+
if (explicitScope && explicitScope.startsWith('tmux:')) {
|
|
21
|
+
return explicitScope;
|
|
22
|
+
}
|
|
23
|
+
const tmuxSessionId = readToken(metadata?.clientTmuxSessionId)
|
|
24
|
+
|| readToken(metadata?.client_tmux_session_id)
|
|
25
|
+
|| readToken(metadata?.tmuxSessionId)
|
|
26
|
+
|| readToken(metadata?.tmux_session_id);
|
|
27
|
+
if (tmuxSessionId) {
|
|
28
|
+
return `tmux:${tmuxSessionId}`;
|
|
6
29
|
}
|
|
7
30
|
return undefined;
|
|
8
31
|
}
|
|
@@ -12,7 +35,7 @@ export function getRoutingInstructionState(stickyKey, routingInstructionState, r
|
|
|
12
35
|
// 对 session:/conversation: 作用域,在每次读取时尝试从磁盘刷新 stopMessage 相关字段,
|
|
13
36
|
// 确保 servertool(如 stop_message_auto)通过 sticky-session-store 更新的使用次数
|
|
14
37
|
// 能在 VirtualRouter 日志中实时反映出来。
|
|
15
|
-
if (existing && (key
|
|
38
|
+
if (existing && isPersistentScopeKey(key)) {
|
|
16
39
|
try {
|
|
17
40
|
const persisted = routingStateStore.loadSync(key);
|
|
18
41
|
const merged = mergeStopMessageFromPersisted(existing, persisted);
|
|
@@ -22,6 +45,10 @@ export function getRoutingInstructionState(stickyKey, routingInstructionState, r
|
|
|
22
45
|
existing.stopMessageUsed = merged.stopMessageUsed;
|
|
23
46
|
existing.stopMessageUpdatedAt = merged.stopMessageUpdatedAt;
|
|
24
47
|
existing.stopMessageLastUsedAt = merged.stopMessageLastUsedAt;
|
|
48
|
+
existing.stopMessageStageMode = merged.stopMessageStageMode;
|
|
49
|
+
existing.stopMessageAiMode = merged.stopMessageAiMode;
|
|
50
|
+
existing.stopMessageAiSeedPrompt = merged.stopMessageAiSeedPrompt;
|
|
51
|
+
existing.stopMessageAiHistory = merged.stopMessageAiHistory;
|
|
25
52
|
if (persisted) {
|
|
26
53
|
existing.preCommandSource = persisted.preCommandSource;
|
|
27
54
|
existing.preCommandScriptPath = persisted.preCommandScriptPath;
|
|
@@ -35,7 +62,7 @@ export function getRoutingInstructionState(stickyKey, routingInstructionState, r
|
|
|
35
62
|
}
|
|
36
63
|
let initial = null;
|
|
37
64
|
// 仅对 session:/conversation: 作用域的 key 尝试从磁盘恢复持久化状态
|
|
38
|
-
if (
|
|
65
|
+
if (isPersistentScopeKey(key)) {
|
|
39
66
|
initial = routingStateStore.loadSync(key);
|
|
40
67
|
}
|
|
41
68
|
if (!initial) {
|
|
@@ -52,6 +79,10 @@ export function getRoutingInstructionState(stickyKey, routingInstructionState, r
|
|
|
52
79
|
stopMessageUsed: undefined,
|
|
53
80
|
stopMessageUpdatedAt: undefined,
|
|
54
81
|
stopMessageLastUsedAt: undefined,
|
|
82
|
+
stopMessageStageMode: undefined,
|
|
83
|
+
stopMessageAiMode: undefined,
|
|
84
|
+
stopMessageAiSeedPrompt: undefined,
|
|
85
|
+
stopMessageAiHistory: undefined,
|
|
55
86
|
preCommandSource: undefined,
|
|
56
87
|
preCommandScriptPath: undefined,
|
|
57
88
|
preCommandUpdatedAt: undefined
|
|
@@ -74,8 +105,8 @@ function isRoutingStateEmpty(state) {
|
|
|
74
105
|
const noStopMessage = (!state.stopMessageText || !state.stopMessageText.trim()) &&
|
|
75
106
|
(typeof state.stopMessageMaxRepeats !== 'number' || !Number.isFinite(state.stopMessageMaxRepeats)) &&
|
|
76
107
|
(typeof state.stopMessageUsed !== 'number' || !Number.isFinite(state.stopMessageUsed)) &&
|
|
77
|
-
(typeof state.
|
|
78
|
-
(typeof state.
|
|
108
|
+
(typeof state.stopMessageStageMode !== 'string' || !state.stopMessageStageMode.trim()) &&
|
|
109
|
+
(typeof state.stopMessageAiMode !== 'string' || !state.stopMessageAiMode.trim());
|
|
79
110
|
const noPreCommand = (!state.preCommandScriptPath || !state.preCommandScriptPath.trim()) &&
|
|
80
111
|
(typeof state.preCommandUpdatedAt !== 'number' || !Number.isFinite(state.preCommandUpdatedAt));
|
|
81
112
|
return (noForced &&
|
|
@@ -89,21 +120,26 @@ function isRoutingStateEmpty(state) {
|
|
|
89
120
|
noPreCommand);
|
|
90
121
|
}
|
|
91
122
|
export function persistRoutingInstructionState(key, state, routingStateStore) {
|
|
92
|
-
if (!
|
|
123
|
+
if (!isPersistentScopeKey(key)) {
|
|
93
124
|
return;
|
|
94
125
|
}
|
|
95
126
|
const supportsSync = typeof routingStateStore.saveSync === 'function';
|
|
127
|
+
const shouldUseSyncForSession = supportsSync && (key.startsWith('session:')
|
|
128
|
+
|| key.startsWith('tmux:'));
|
|
96
129
|
const prefersSync = supportsSync &&
|
|
97
|
-
key.startsWith('session:')
|
|
130
|
+
(key.startsWith('session:')
|
|
131
|
+
|| key.startsWith('tmux:')) &&
|
|
98
132
|
(Boolean(state.stopMessageText && state.stopMessageText.trim()) ||
|
|
99
133
|
(typeof state.stopMessageMaxRepeats === 'number' && Number.isFinite(state.stopMessageMaxRepeats)) ||
|
|
100
134
|
(typeof state.stopMessageUsed === 'number' && Number.isFinite(state.stopMessageUsed)) ||
|
|
101
|
-
(
|
|
102
|
-
(
|
|
135
|
+
Boolean(state.stopMessageStageMode && state.stopMessageStageMode.trim()) ||
|
|
136
|
+
Boolean(state.stopMessageAiMode && state.stopMessageAiMode.trim()) ||
|
|
103
137
|
Boolean(state.preCommandScriptPath && state.preCommandScriptPath.trim()) ||
|
|
104
138
|
(typeof state.preCommandUpdatedAt === 'number' && Number.isFinite(state.preCommandUpdatedAt)));
|
|
105
139
|
if (isRoutingStateEmpty(state)) {
|
|
106
|
-
|
|
140
|
+
// For session scope, clear must be sync to avoid stale persisted snapshots
|
|
141
|
+
// being reloaded immediately by same-request readers.
|
|
142
|
+
if (shouldUseSyncForSession) {
|
|
107
143
|
routingStateStore.saveSync(key, null);
|
|
108
144
|
}
|
|
109
145
|
else {
|
|
@@ -18,23 +18,24 @@ function summarizeStopMessageRuntime(state) {
|
|
|
18
18
|
const parsedMaxRepeats = typeof state.stopMessageMaxRepeats === 'number' && Number.isFinite(state.stopMessageMaxRepeats)
|
|
19
19
|
? Math.max(0, Math.floor(state.stopMessageMaxRepeats))
|
|
20
20
|
: 0;
|
|
21
|
+
const hasGoalText = Boolean(text);
|
|
21
22
|
const maxRepeats = parsedMaxRepeats > 0
|
|
22
23
|
? parsedMaxRepeats
|
|
23
|
-
: mode === 'on' || mode === 'auto'
|
|
24
|
+
: hasGoalText && (mode === 'on' || mode === 'auto')
|
|
24
25
|
? DEFAULT_STOP_MESSAGE_MAX_REPEATS
|
|
25
26
|
: 0;
|
|
26
27
|
const used = typeof state.stopMessageUsed === 'number' && Number.isFinite(state.stopMessageUsed)
|
|
27
28
|
? Math.max(0, Math.floor(state.stopMessageUsed))
|
|
28
29
|
: 0;
|
|
29
30
|
const remaining = maxRepeats > 0 ? Math.max(0, maxRepeats - used) : -1;
|
|
30
|
-
const active = mode !== 'off' && maxRepeats > 0
|
|
31
|
+
const active = mode !== 'off' && hasGoalText && maxRepeats > 0;
|
|
31
32
|
const updatedAt = typeof state.stopMessageUpdatedAt === 'number' && Number.isFinite(state.stopMessageUpdatedAt)
|
|
32
33
|
? state.stopMessageUpdatedAt
|
|
33
34
|
: undefined;
|
|
34
35
|
const lastUsedAt = typeof state.stopMessageLastUsedAt === 'number' && Number.isFinite(state.stopMessageLastUsedAt)
|
|
35
36
|
? state.stopMessageLastUsedAt
|
|
36
37
|
: undefined;
|
|
37
|
-
const hasAny =
|
|
38
|
+
const hasAny = hasGoalText || maxRepeats > 0 || used > 0;
|
|
38
39
|
return {
|
|
39
40
|
hasAny,
|
|
40
41
|
...(safeText ? { safeText } : {}),
|