@jsonstudio/llms 0.6.2172 → 0.6.2979
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/conversion/compat/antigravity-session-signature.js +35 -1
- package/dist/conversion/compat/profiles/chat-gemini-cli.json +0 -7
- package/dist/conversion/compat/profiles/chat-gemini.json +0 -6
- package/dist/conversion/hub/core/detour-registry.d.ts +2 -0
- package/dist/conversion/hub/core/hub-context.d.ts +3 -1
- package/dist/conversion/hub/core/index.d.ts +1 -0
- package/dist/conversion/hub/core/stage-driver.js +2 -0
- package/dist/conversion/hub/format-adapters/anthropic-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/chat-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/gemini-format-adapter.js +15 -4
- package/dist/conversion/hub/format-adapters/responses-format-adapter.js +15 -4
- package/dist/conversion/hub/hub-feature.js +3 -2
- package/dist/conversion/hub/node-support.js +9 -4
- package/dist/conversion/hub/operation-table/operation-table-runner.js +10 -6
- package/dist/conversion/hub/operation-table/semantic-mappers/anthropic-mapper.js +2 -2
- package/dist/conversion/hub/operation-table/semantic-mappers/chat-mapper.js +10 -10
- package/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.js +4 -8
- package/dist/conversion/hub/operation-table/semantic-mappers/responses-mapper.js +19 -65
- package/dist/conversion/hub/ops/operations.js +2 -121
- package/dist/conversion/hub/pipeline/compat/compat-engine.js +6 -0
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.d.ts +1 -1
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +33 -1042
- package/dist/conversion/hub/pipeline/compat/compat-profile-resolver.js +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-profile-store.js +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-types.d.ts +14 -17
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.d.ts +3 -0
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.js +39 -0
- package/dist/conversion/hub/pipeline/hub-pipeline.js +115 -262
- package/dist/conversion/hub/pipeline/session-identifiers.js +6 -196
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.js +37 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.js +12 -86
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.d.ts +14 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/semantic-lift.js +24 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.d.ts +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/archive/shell-like-tool-call-normalization-fallback.js +157 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.d.ts +16 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.js +29 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-factories.js +3 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.d.ts +2 -15
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.js +8 -595
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.d.ts +8 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.js +28 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.d.ts +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-diagnostics.js +4 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.d.ts +10 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/tool-output-snapshot.js +12 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.js +30 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/index.js +9 -129
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.d.ts +1 -4
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage2_format_build/index.js +9 -26
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +32 -14
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.d.ts +2 -2
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.js +48 -8
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage2_route_select/index.js +18 -3
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/index.js +10 -198
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/stream-json-sniffer.js +81 -0
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage2_format_parse/index.js +36 -1
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage3_semantic_map/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.d.ts +6 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.js +17 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.d.ts +9 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/client-remap-protocol-switch.js +28 -0
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.js +14 -102
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage2_sse_stream/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage1_tool_governance/index.js +12 -10
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage2_finalize/index.js +6 -5
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.d.ts +11 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage3_servertool_orchestration/index.js +10 -32
- package/dist/conversion/hub/pipeline/stages/utils.js +17 -1
- package/dist/conversion/hub/pipeline/target-utils.js +14 -91
- package/dist/conversion/hub/pipelines/inbound.js +3 -1
- package/dist/conversion/hub/pipelines/outbound.js +2 -0
- package/dist/conversion/hub/policy/policy-engine.js +9 -3
- package/dist/conversion/hub/policy/protocol-spec.js +20 -148
- package/dist/conversion/hub/process/chat-process-anthropic-alias.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-anthropic-alias.js +36 -0
- package/dist/conversion/hub/process/chat-process-clock-directive-parser.d.ts +5 -0
- package/dist/conversion/hub/process/chat-process-clock-directive-parser.js +48 -0
- package/dist/conversion/hub/process/chat-process-clock-directives.d.ts +24 -0
- package/dist/conversion/hub/process/chat-process-clock-directives.js +98 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-directives.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-directives.js +42 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-finalize.d.ts +14 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-finalize.js +10 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-messages.d.ts +5 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-messages.js +10 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.d.ts +30 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-orchestration.js +68 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.d.ts +9 -0
- package/dist/conversion/hub/process/chat-process-clock-reminder-time-tag.js +18 -0
- package/dist/conversion/hub/process/chat-process-clock-reminders.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-clock-reminders.js +104 -0
- package/dist/conversion/hub/process/chat-process-clock-tool-schemas.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-clock-tool-schemas.js +233 -0
- package/dist/conversion/hub/process/chat-process-clock-tools.d.ts +6 -0
- package/dist/conversion/hub/process/chat-process-clock-tools.js +41 -0
- package/dist/conversion/hub/process/chat-process-continue-execution.d.ts +11 -0
- package/dist/conversion/hub/process/chat-process-continue-execution.js +82 -0
- package/dist/conversion/hub/process/chat-process-governance-context.d.ts +15 -0
- package/dist/conversion/hub/process/chat-process-governance-context.js +7 -0
- package/dist/conversion/hub/process/chat-process-governance-finalize.d.ts +16 -0
- package/dist/conversion/hub/process/chat-process-governance-finalize.js +11 -0
- package/dist/conversion/hub/process/chat-process-governance-orchestration.d.ts +9 -0
- package/dist/conversion/hub/process/chat-process-governance-orchestration.js +47 -0
- package/dist/conversion/hub/process/chat-process-governed-control-ops.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-governed-control-ops.js +5 -0
- package/dist/conversion/hub/process/chat-process-governed-filter-call.d.ts +12 -0
- package/dist/conversion/hub/process/chat-process-governed-filter-call.js +18 -0
- package/dist/conversion/hub/process/chat-process-governed-merge.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-governed-merge.js +11 -0
- package/dist/conversion/hub/process/chat-process-media.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-media.js +18 -0
- package/dist/conversion/hub/process/chat-process-node-result.d.ts +23 -0
- package/dist/conversion/hub/process/chat-process-node-result.js +24 -0
- package/dist/conversion/hub/process/chat-process-pending-tool-sync.d.ts +14 -0
- package/dist/conversion/hub/process/chat-process-pending-tool-sync.js +52 -0
- package/dist/conversion/hub/process/chat-process-post-governed-normalization.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-post-governed-normalization.js +16 -0
- package/dist/conversion/hub/process/chat-process-review.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-review.js +8 -0
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.js +22 -0
- package/dist/conversion/hub/process/chat-process-tool-normalization.d.ts +2 -0
- package/dist/conversion/hub/process/chat-process-tool-normalization.js +4 -0
- package/dist/conversion/hub/process/chat-process-web-search-intent.d.ts +12 -0
- package/dist/conversion/hub/process/chat-process-web-search-intent.js +13 -0
- package/dist/conversion/hub/process/chat-process-web-search-tool-schema.d.ts +3 -0
- package/dist/conversion/hub/process/chat-process-web-search-tool-schema.js +4 -0
- package/dist/conversion/hub/process/chat-process-web-search.d.ts +8 -0
- package/dist/conversion/hub/process/chat-process-web-search.js +26 -0
- package/dist/conversion/hub/process/chat-process.d.ts +2 -19
- package/dist/conversion/hub/process/chat-process.js +12 -1701
- package/dist/conversion/hub/process/client-inject-readiness.d.ts +1 -0
- package/dist/conversion/hub/process/client-inject-readiness.js +4 -0
- package/dist/conversion/hub/registry.js +5 -2
- package/dist/conversion/hub/response/chat-response-utils.js +5 -86
- package/dist/conversion/hub/response/provider-response.d.ts +9 -0
- package/dist/conversion/hub/response/provider-response.js +6 -21
- package/dist/conversion/hub/response/response-mappers.js +2 -26
- package/dist/conversion/hub/response/response-runtime.js +2 -93
- package/dist/conversion/hub/semantic-mappers/anthropic-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/anthropic-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/chat-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/chat-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/gemini-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/gemini-mapper.js +1 -0
- package/dist/conversion/hub/semantic-mappers/responses-mapper.d.ts +1 -0
- package/dist/conversion/hub/semantic-mappers/responses-mapper.js +1 -0
- package/dist/conversion/hub/snapshot-recorder.js +10 -3
- package/dist/conversion/hub/standardized-bridge.js +11 -288
- package/dist/conversion/hub/tool-governance/engine.js +5 -0
- package/dist/conversion/hub/tool-governance/rules.js +10 -10
- package/dist/conversion/hub/tool-session-compat.d.ts +2 -2
- package/dist/conversion/hub/tool-session-compat.js +17 -231
- package/dist/conversion/hub/tool-surface/tool-surface-engine.js +5 -3
- package/dist/conversion/responses/responses-host-policy.js +2 -12
- package/dist/conversion/responses/responses-openai-bridge/response-payload.js +6 -82
- package/dist/conversion/responses/responses-openai-bridge/types.d.ts +1 -0
- package/dist/conversion/responses/responses-openai-bridge.js +21 -54
- package/dist/conversion/shared/anthropic-message-utils.js +151 -13
- package/dist/conversion/shared/args-mapping.js +2 -146
- package/dist/conversion/shared/bridge-actions.js +203 -718
- package/dist/conversion/shared/bridge-id-utils.js +5 -71
- package/dist/conversion/shared/bridge-instructions.js +2 -1
- package/dist/conversion/shared/bridge-message-types.d.ts +2 -0
- package/dist/conversion/shared/bridge-message-utils.js +1 -2
- package/dist/conversion/shared/bridge-metadata.d.ts +1 -0
- package/dist/conversion/shared/bridge-metadata.js +4 -0
- package/dist/conversion/shared/bridge-policies.js +5 -189
- package/dist/conversion/shared/chat-envelope-validator.js +2 -126
- package/dist/conversion/shared/chat-output-normalizer.js +2 -54
- package/dist/conversion/shared/compaction-detect.js +2 -57
- package/dist/conversion/shared/gemini-tool-utils.js +9 -524
- package/dist/conversion/shared/jsonish.js +3 -160
- package/dist/conversion/shared/mcp-injection.js +3 -169
- package/dist/conversion/shared/media.js +2 -7
- package/dist/conversion/shared/metadata-passthrough.js +9 -46
- package/dist/conversion/shared/openai-finalizer.js +2 -1
- package/dist/conversion/shared/openai-message-normalize.js +11 -283
- package/dist/conversion/shared/output-content-normalizer.js +9 -112
- package/dist/conversion/shared/payload-budget.js +2 -85
- package/dist/conversion/shared/protocol-state.js +11 -7
- package/dist/conversion/shared/reasoning-mapping.js +2 -6
- package/dist/conversion/shared/reasoning-normalizer.js +4 -1
- package/dist/conversion/shared/reasoning-tool-normalizer.js +14 -126
- package/dist/conversion/shared/reasoning-tool-parser.js +4 -87
- package/dist/conversion/shared/reasoning-utils.js +2 -6
- package/dist/conversion/shared/responses-conversation-store.js +4 -82
- package/dist/conversion/shared/responses-output-builder.js +11 -47
- package/dist/conversion/shared/responses-reasoning-registry.js +7 -1
- package/dist/conversion/shared/responses-request-adapter.d.ts +7 -1
- package/dist/conversion/shared/responses-request-adapter.js +14 -1
- package/dist/conversion/shared/responses-response-utils.js +6 -7
- package/dist/conversion/shared/responses-tool-utils.d.ts +1 -0
- package/dist/conversion/shared/responses-tool-utils.js +90 -14
- package/dist/conversion/shared/runtime-metadata.js +13 -5
- package/dist/conversion/shared/streaming-text-extractor.js +2 -7
- package/dist/conversion/shared/text-markup-normalizer/normalize.d.ts +1 -1
- package/dist/conversion/shared/text-markup-normalizer/normalize.js +43 -17
- package/dist/conversion/shared/text-markup-normalizer.d.ts +1 -0
- package/dist/conversion/shared/text-markup-normalizer.js +1 -0
- package/dist/conversion/shared/thought-signature-validator.js +3 -2
- package/dist/conversion/shared/tool-argument-repairer.js +2 -2
- package/dist/conversion/shared/tool-call-id-manager.js +5 -7
- package/dist/conversion/shared/tool-call-utils.js +3 -45
- package/dist/conversion/shared/tool-canonicalizer.js +25 -29
- package/dist/conversion/shared/tool-filter-pipeline.js +4 -99
- package/dist/conversion/shared/tool-governor.d.ts +6 -0
- package/dist/conversion/shared/tool-governor.js +43 -125
- package/dist/conversion/shared/tool-harvester.js +2 -8
- package/dist/conversion/shared/tool-mapping.js +2 -5
- package/dist/conversion/shared/tooling.d.ts +0 -4
- package/dist/conversion/shared/tooling.js +18 -0
- package/dist/native/router_hotpath_napi.node +0 -0
- package/dist/router/virtual-router/engine/provider-key/parse.d.ts +1 -6
- package/dist/router/virtual-router/engine/provider-key/parse.js +1 -43
- package/dist/router/virtual-router/engine/routing-state/store.js +48 -12
- package/dist/router/virtual-router/engine-logging.js +4 -3
- package/dist/router/virtual-router/engine-selection/alias-selection.js +45 -83
- package/dist/router/virtual-router/engine-selection/key-parsing.js +9 -23
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.d.ts +20 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-directive-parser.js +163 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.d.ts +7 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-directives.js +103 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-orchestration-semantics.js +110 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.d.ts +8 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-semantics.js +281 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminder-time-tag-semantics.js +25 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.d.ts +4 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-reminders-semantics.js +44 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-clock-tool-schema-semantics.js +62 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.d.ts +40 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governance-semantics.js +484 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.d.ts +9 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.js +64 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-node-result-semantics.js +163 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-post-governed-normalization-semantics.js +49 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.d.ts +30 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-servertool-orchestration-semantics.js +446 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-web-search-intent-semantics.js +49 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.d.ts +134 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js +729 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.d.ts +62 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.js +338 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.d.ts +18 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js +317 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.d.ts +22 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.js +426 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.d.ts +57 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-orchestration-semantics.js +705 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.d.ts +46 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js +503 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.d.ts +146 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.js +570 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.js +148 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.js +637 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.d.ts +11 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-session-identifiers-semantics.js +207 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.d.ts +3 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-target-semantics.js +128 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.d.ts +57 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-analysis.js +217 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.js +284 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.d.ts +5 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-policy.js +18 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.d.ts +25 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-quota-buckets.js +85 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath.d.ts +59 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath.js +117 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.d.ts +76 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.js +1166 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.d.ts +16 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-alias-selection-semantics.js +96 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.d.ts +6 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-actions-semantics.js +85 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.d.ts +9 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-semantics.js +70 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-stop-message-state-semantics.js +76 -0
- package/dist/router/virtual-router/engine-selection/route-utils.js +1 -1
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-session-lease.js +231 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.d.ts +4 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-antigravity-target-split.js +43 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.d.ts +27 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.js +116 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-select.d.ts +1 -1
- package/dist/router/virtual-router/engine-selection/tier-selection-select.js +29 -129
- package/dist/router/virtual-router/engine-selection/tier-selection.js +2 -265
- package/dist/router/virtual-router/engine.js +258 -249
- package/dist/router/virtual-router/features.js +2 -2
- package/dist/router/virtual-router/routing-instructions.d.ts +5 -7
- package/dist/router/virtual-router/routing-instructions.js +93 -66
- package/dist/router/virtual-router/routing-stop-message-actions.js +91 -112
- package/dist/router/virtual-router/routing-stop-message-parser.js +9 -132
- package/dist/router/virtual-router/routing-stop-message-state-codec.d.ts +1 -0
- package/dist/router/virtual-router/routing-stop-message-state-codec.js +58 -71
- package/dist/router/virtual-router/sticky-session-store.js +4 -2
- package/dist/router/virtual-router/stop-message-file-resolver.d.ts +1 -0
- package/dist/router/virtual-router/stop-message-file-resolver.js +10 -0
- package/dist/router/virtual-router/stop-message-state-sync.d.ts +1 -1
- package/dist/router/virtual-router/stop-message-state-sync.js +3 -7
- package/dist/router/virtual-router/token-counter.js +0 -9
- package/dist/router/virtual-router/types.d.ts +9 -7
- package/dist/servertool/clock/config.js +23 -51
- package/dist/servertool/clock/io.js +1 -0
- package/dist/servertool/clock/session-scope.d.ts +2 -2
- package/dist/servertool/clock/session-scope.js +5 -47
- package/dist/servertool/engine.d.ts +9 -0
- package/dist/servertool/engine.js +196 -79
- package/dist/servertool/handlers/antigravity-thought-signature-bootstrap.js +2 -2
- package/dist/servertool/handlers/clock.js +1 -1
- package/dist/servertool/handlers/continue-execution.js +8 -4
- package/dist/servertool/handlers/followup-request-builder.js +18 -1
- package/dist/servertool/handlers/gemini-empty-reply-continue.js +7 -1
- package/dist/servertool/handlers/review.js +180 -0
- package/dist/servertool/handlers/stop-message-auto/blocked-report.js +59 -1
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.d.ts +23 -2
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.js +397 -89
- package/dist/servertool/handlers/stop-message-auto/routing-state.d.ts +5 -15
- package/dist/servertool/handlers/stop-message-auto/routing-state.js +29 -55
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.d.ts +6 -0
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.js +35 -61
- package/dist/servertool/handlers/stop-message-auto.js +392 -76
- package/dist/servertool/server-side-tools.d.ts +1 -0
- package/dist/servertool/server-side-tools.js +90 -52
- package/dist/servertool/types.d.ts +17 -0
- package/dist/tools/apply-patch/patch-text/normalize.js +11 -0
- package/dist/tools/exec-command/validator.d.ts +4 -1
- package/dist/tools/exec-command/validator.js +87 -3
- package/dist/tools/tool-registry.d.ts +7 -1
- package/dist/tools/tool-registry.js +3 -2
- package/package.json +115 -7
- package/dist/servertool/handlers/stop-message-stage-policy/bd-runtime.d.ts +0 -18
- package/dist/servertool/handlers/stop-message-stage-policy/bd-runtime.js +0 -398
- package/dist/servertool/handlers/stop-message-stage-policy/decision.d.ts +0 -9
- package/dist/servertool/handlers/stop-message-stage-policy/decision.js +0 -127
- package/dist/servertool/handlers/stop-message-stage-policy/observation.d.ts +0 -2
- package/dist/servertool/handlers/stop-message-stage-policy/observation.js +0 -179
- package/dist/servertool/handlers/stop-message-stage-policy/templates.d.ts +0 -4
- package/dist/servertool/handlers/stop-message-stage-policy/templates.js +0 -96
- package/dist/servertool/handlers/stop-message-stage-policy/text-utils.d.ts +0 -9
- package/dist/servertool/handlers/stop-message-stage-policy/text-utils.js +0 -89
- package/dist/servertool/handlers/stop-message-stage-policy/types.d.ts +0 -59
- package/dist/servertool/handlers/stop-message-stage-policy.d.ts +0 -3
- package/dist/servertool/handlers/stop-message-stage-policy.js +0 -2
- /package/dist/servertool/handlers/{stop-message-stage-policy/types.js → review.d.ts} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalizeFunctionCallId, normalizeFunctionCallOutputId, normalizeResponsesCallId } from './bridge-id-utils.js';
|
|
2
|
+
import { sanitizeResponsesFunctionNameWithNative } from '../../router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.js';
|
|
2
3
|
export function createToolCallIdTransformer(style) {
|
|
3
4
|
if (style !== 'fc') {
|
|
4
5
|
return null;
|
|
@@ -65,6 +66,94 @@ export function enforceToolCallIdStyle(input, transformer) {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}
|
|
69
|
+
function isStableToolCallId(raw) {
|
|
70
|
+
return /^((fc|call)_[A-Za-z0-9_-]+)$/i.test(raw);
|
|
71
|
+
}
|
|
72
|
+
export function normalizeResponsesToolCallIds(payload) {
|
|
73
|
+
if (!payload || typeof payload !== 'object') {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
let counter = 0;
|
|
77
|
+
const aliasMap = new Map();
|
|
78
|
+
const nextFallback = (prefix) => `${prefix}_${++counter}`;
|
|
79
|
+
const normalizeCallId = (raw, fallbackPrefix) => {
|
|
80
|
+
const trimmed = typeof raw === 'string' ? raw.trim() : '';
|
|
81
|
+
if (trimmed) {
|
|
82
|
+
const cached = aliasMap.get(trimmed);
|
|
83
|
+
if (cached)
|
|
84
|
+
return cached;
|
|
85
|
+
}
|
|
86
|
+
const normalized = trimmed && isStableToolCallId(trimmed)
|
|
87
|
+
? trimmed
|
|
88
|
+
: normalizeFunctionCallId({
|
|
89
|
+
callId: trimmed || undefined,
|
|
90
|
+
fallback: nextFallback(fallbackPrefix)
|
|
91
|
+
});
|
|
92
|
+
if (trimmed) {
|
|
93
|
+
aliasMap.set(trimmed, normalized);
|
|
94
|
+
}
|
|
95
|
+
return normalized;
|
|
96
|
+
};
|
|
97
|
+
const output = Array.isArray(payload.output) ? payload.output : [];
|
|
98
|
+
for (const item of output) {
|
|
99
|
+
if (!item || typeof item !== 'object')
|
|
100
|
+
continue;
|
|
101
|
+
const type = typeof item.type === 'string' ? String(item.type).toLowerCase() : '';
|
|
102
|
+
if (type === 'function_call') {
|
|
103
|
+
const normalizedCallId = normalizeCallId(item.call_id ?? item.tool_call_id ?? item.id, 'fc_call');
|
|
104
|
+
item.call_id = normalizedCallId;
|
|
105
|
+
if (item.tool_call_id !== undefined) {
|
|
106
|
+
item.tool_call_id = normalizedCallId;
|
|
107
|
+
}
|
|
108
|
+
const rawOutputId = typeof item.id === 'string' ? item.id : undefined;
|
|
109
|
+
item.id = normalizeFunctionCallOutputId({
|
|
110
|
+
callId: normalizedCallId,
|
|
111
|
+
fallback: rawOutputId ?? nextFallback('fc')
|
|
112
|
+
});
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (type === 'function_call_output' || type === 'tool_result' || type === 'tool_message') {
|
|
116
|
+
const normalizedCallId = normalizeCallId(item.call_id ?? item.tool_call_id ?? item.id, 'fc_call');
|
|
117
|
+
item.call_id = normalizedCallId;
|
|
118
|
+
if (item.tool_call_id !== undefined) {
|
|
119
|
+
item.tool_call_id = normalizedCallId;
|
|
120
|
+
}
|
|
121
|
+
const rawOutputId = typeof item.id === 'string' ? item.id : undefined;
|
|
122
|
+
item.id = normalizeFunctionCallOutputId({
|
|
123
|
+
callId: normalizedCallId,
|
|
124
|
+
fallback: rawOutputId ?? nextFallback('fc')
|
|
125
|
+
});
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (Array.isArray(item.tool_calls)) {
|
|
129
|
+
for (const call of item.tool_calls) {
|
|
130
|
+
if (!call || typeof call !== 'object')
|
|
131
|
+
continue;
|
|
132
|
+
const normalizedCallId = normalizeCallId(call.id ?? call.tool_call_id ?? call.call_id, 'fc_call');
|
|
133
|
+
call.id = normalizedCallId;
|
|
134
|
+
if (call.tool_call_id !== undefined) {
|
|
135
|
+
call.tool_call_id = normalizedCallId;
|
|
136
|
+
}
|
|
137
|
+
if (call.call_id !== undefined) {
|
|
138
|
+
call.call_id = normalizedCallId;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const submitCalls = payload?.required_action?.submit_tool_outputs?.tool_calls;
|
|
144
|
+
if (Array.isArray(submitCalls)) {
|
|
145
|
+
for (const call of submitCalls) {
|
|
146
|
+
if (!call || typeof call !== 'object')
|
|
147
|
+
continue;
|
|
148
|
+
const normalizedCallId = normalizeCallId(call.tool_call_id ?? call.id ?? call.call_id, 'fc_call');
|
|
149
|
+
call.tool_call_id = normalizedCallId;
|
|
150
|
+
call.id = normalizedCallId;
|
|
151
|
+
if (call.call_id !== undefined) {
|
|
152
|
+
call.call_id = normalizedCallId;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
68
157
|
export function resolveToolCallIdStyle(metadata) {
|
|
69
158
|
// Standard OpenAI `/v1/responses` requires function_call item ids to start with `fc_`.
|
|
70
159
|
// Default to `fc` unless explicitly overridden (e.g. LM Studio compat).
|
|
@@ -116,18 +205,5 @@ function prunePrivateExtraFields(target) {
|
|
|
116
205
|
}
|
|
117
206
|
const RAW_SYSTEM_SENTINEL = '__rcc_raw_system';
|
|
118
207
|
export function sanitizeResponsesFunctionName(rawName) {
|
|
119
|
-
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
const trimmed = rawName.trim();
|
|
123
|
-
if (!trimmed) {
|
|
124
|
-
return undefined;
|
|
125
|
-
}
|
|
126
|
-
const dotIndex = trimmed.indexOf('.');
|
|
127
|
-
const base = dotIndex >= 0 ? trimmed.slice(dotIndex + 1) : trimmed;
|
|
128
|
-
const sanitized = base.replace(/[^A-Za-z0-9_-]/g, '_');
|
|
129
|
-
if (sanitized.length > 0) {
|
|
130
|
-
return sanitized;
|
|
131
|
-
}
|
|
132
|
-
return 'tool_call';
|
|
208
|
+
return sanitizeResponsesFunctionNameWithNative(rawName);
|
|
133
209
|
}
|
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import { isJsonObject, jsonClone } from '../hub/types/json.js';
|
|
2
|
+
import { cloneRuntimeMetadataWithNative, ensureRuntimeMetadataCarrierWithNative, readRuntimeMetadataWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
2
3
|
export function readRuntimeMetadata(carrier) {
|
|
3
4
|
if (!carrier || typeof carrier !== 'object') {
|
|
4
5
|
return undefined;
|
|
5
6
|
}
|
|
6
|
-
const candidate = carrier
|
|
7
|
+
const candidate = readRuntimeMetadataWithNative(carrier);
|
|
7
8
|
return candidate && isJsonObject(candidate) ? candidate : undefined;
|
|
8
9
|
}
|
|
9
10
|
export function ensureRuntimeMetadata(carrier) {
|
|
10
11
|
if (!carrier || typeof carrier !== 'object') {
|
|
11
12
|
throw new Error('ensureRuntimeMetadata requires object carrier');
|
|
12
13
|
}
|
|
13
|
-
const
|
|
14
|
-
|
|
14
|
+
const nextCarrier = ensureRuntimeMetadataCarrierWithNative(carrier);
|
|
15
|
+
for (const key of Object.keys(carrier)) {
|
|
16
|
+
if (!Object.prototype.hasOwnProperty.call(nextCarrier, key)) {
|
|
17
|
+
delete carrier[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
Object.assign(carrier, nextCarrier);
|
|
21
|
+
const existing = carrier.__rt;
|
|
22
|
+
if (existing && isJsonObject(existing)) {
|
|
15
23
|
return existing;
|
|
16
24
|
}
|
|
17
25
|
carrier.__rt = {};
|
|
18
26
|
return carrier.__rt;
|
|
19
27
|
}
|
|
20
28
|
export function cloneRuntimeMetadata(carrier) {
|
|
21
|
-
const rt =
|
|
22
|
-
return rt ? jsonClone(rt) : undefined;
|
|
29
|
+
const rt = cloneRuntimeMetadataWithNative(carrier);
|
|
30
|
+
return rt && isJsonObject(rt) ? jsonClone(rt) : undefined;
|
|
23
31
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Detects <function=execute> blocks and structured apply_patch payloads
|
|
3
3
|
// and converts them into OpenAI tool_calls incrementally.
|
|
4
4
|
import { isStructuredApplyPatchPayload } from '../../tools/apply-patch-structured.js';
|
|
5
|
+
import { repairArgumentsToStringWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
5
6
|
function isObject(v) {
|
|
6
7
|
return !!v && typeof v === 'object' && !Array.isArray(v);
|
|
7
8
|
}
|
|
@@ -32,13 +33,7 @@ export class StreamingTextToolExtractor {
|
|
|
32
33
|
return `${p}_${Date.now()}_${(++this.idCounter).toString(36)}`;
|
|
33
34
|
}
|
|
34
35
|
toToolCall(name, argsObj) {
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
argStr = JSON.stringify(argsObj ?? {});
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
argStr = '{}';
|
|
41
|
-
}
|
|
36
|
+
const argStr = repairArgumentsToStringWithNative(argsObj);
|
|
42
37
|
return { id: this.genId(), type: 'function', function: { name, arguments: argStr } };
|
|
43
38
|
}
|
|
44
39
|
tryExtractStructuredBlocks() {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { TextMarkupNormalizeOptions } from './extractors.js';
|
|
2
|
-
export declare function normalizeAssistantTextToToolCalls(message: Record<string, any>,
|
|
2
|
+
export declare function normalizeAssistantTextToToolCalls(message: Record<string, any>, _options?: TextMarkupNormalizeOptions): Record<string, any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { extractToolCallsFromReasoningTextWithNative } from '../../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
2
2
|
function enabled() {
|
|
3
3
|
try {
|
|
4
4
|
return String(process?.env?.RCC_TEXT_MARKUP_COMPAT ?? '1').trim() !== '0';
|
|
@@ -7,7 +7,7 @@ function enabled() {
|
|
|
7
7
|
return true;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
export function normalizeAssistantTextToToolCalls(message,
|
|
10
|
+
export function normalizeAssistantTextToToolCalls(message, _options) {
|
|
11
11
|
if (!enabled())
|
|
12
12
|
return message;
|
|
13
13
|
try {
|
|
@@ -44,22 +44,48 @@ export function normalizeAssistantTextToToolCalls(message, options) {
|
|
|
44
44
|
if (!candidates.length)
|
|
45
45
|
return message;
|
|
46
46
|
let calls = null;
|
|
47
|
+
const mapNativeToolCalls = (raw) => {
|
|
48
|
+
const mapped = [];
|
|
49
|
+
raw.forEach((entry, index) => {
|
|
50
|
+
if (!entry || typeof entry !== 'object')
|
|
51
|
+
return;
|
|
52
|
+
const functionNode = entry.function && typeof entry.function === 'object' && !Array.isArray(entry.function)
|
|
53
|
+
? entry.function
|
|
54
|
+
: undefined;
|
|
55
|
+
const name = (typeof functionNode?.name === 'string' && functionNode.name.trim()) ||
|
|
56
|
+
(typeof entry.name === 'string' && entry.name.trim()) ||
|
|
57
|
+
undefined;
|
|
58
|
+
if (!name)
|
|
59
|
+
return;
|
|
60
|
+
const argsCandidate = functionNode?.arguments ?? entry.arguments ?? entry.args ?? '{}';
|
|
61
|
+
let args = '{}';
|
|
62
|
+
if (typeof argsCandidate === 'string') {
|
|
63
|
+
args = argsCandidate;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
try {
|
|
67
|
+
args = JSON.stringify(argsCandidate ?? {});
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
args = '{}';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const id = (typeof entry.id === 'string' && entry.id.trim()) ||
|
|
74
|
+
(typeof entry.call_id === 'string' && entry.call_id.trim()) ||
|
|
75
|
+
`call_${index + 1}`;
|
|
76
|
+
mapped.push({ id, name, args });
|
|
77
|
+
});
|
|
78
|
+
return mapped;
|
|
79
|
+
};
|
|
47
80
|
for (const text of candidates) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
extractApplyPatchCallsFromText(text) ||
|
|
57
|
-
extractExecuteBlocksFromText(text) ||
|
|
58
|
-
extractSimpleXmlToolsFromText(text) ||
|
|
59
|
-
extractExploredListDirectoryCallsFromText(text) ||
|
|
60
|
-
extractBareExecCommandFromText(text);
|
|
61
|
-
if (calls && calls.length)
|
|
62
|
-
break;
|
|
81
|
+
const nativeParsed = extractToolCallsFromReasoningTextWithNative(text);
|
|
82
|
+
if (nativeParsed.toolCalls.length) {
|
|
83
|
+
const nativeCalls = mapNativeToolCalls(nativeParsed.toolCalls);
|
|
84
|
+
if (nativeCalls.length) {
|
|
85
|
+
calls = nativeCalls;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
63
89
|
}
|
|
64
90
|
if (calls && calls.length) {
|
|
65
91
|
const toolCalls = calls.map((c) => ({ id: c.id, type: 'function', function: { name: c.name, arguments: c.args } }));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export type { JsonToolRepairConfig, TextMarkupNormalizeOptions, ToolCallLite } from './text-markup-normalizer/extractors.js';
|
|
2
2
|
export { extractApplyPatchCallsFromText, extractBareExecCommandFromText, extractExecuteBlocksFromText, extractExploredListDirectoryCallsFromText, extractInvokeToolsFromText, extractJsonToolCallsFromText, extractParameterXmlToolsFromText, extractQwenToolCallTokensFromText, extractSimpleXmlToolsFromText, extractToolNamespaceXmlBlocksFromText, extractXMLToolCallsFromText } from './text-markup-normalizer/extractors.js';
|
|
3
3
|
export { normalizeAssistantTextToToolCalls } from './text-markup-normalizer/normalize.js';
|
|
4
|
+
export { extractToolCallsFromReasoningTextWithNative, parseLenientJsonishWithNative, repairArgumentsToStringWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { extractApplyPatchCallsFromText, extractBareExecCommandFromText, extractExecuteBlocksFromText, extractExploredListDirectoryCallsFromText, extractInvokeToolsFromText, extractJsonToolCallsFromText, extractParameterXmlToolsFromText, extractQwenToolCallTokensFromText, extractSimpleXmlToolsFromText, extractToolNamespaceXmlBlocksFromText, extractXMLToolCallsFromText } from './text-markup-normalizer/extractors.js';
|
|
2
2
|
export { normalizeAssistantTextToToolCalls } from './text-markup-normalizer/normalize.js';
|
|
3
|
+
export { extractToolCallsFromReasoningTextWithNative, parseLenientJsonishWithNative, repairArgumentsToStringWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* 提供严格的 thoughtSignature 验证功能,用于 Claude/Gemini thinking 块的签名验证。
|
|
5
5
|
* 参考 gcli2api 的实现,确保与上游 API 的兼容性。
|
|
6
6
|
*/
|
|
7
|
+
import { sanitizeReasoningTaggedTextWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
7
8
|
const DEFAULT_OPTIONS = {
|
|
8
9
|
// Antigravity-Manager alignment: treat short signatures as noise.
|
|
9
10
|
minLength: 50,
|
|
@@ -27,7 +28,7 @@ export function hasValidThoughtSignature(block, options) {
|
|
|
27
28
|
return true; // 非 thinking 块默认有效
|
|
28
29
|
}
|
|
29
30
|
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
30
|
-
const thinking = String(obj.thinking || obj.text || '');
|
|
31
|
+
const thinking = sanitizeReasoningTaggedTextWithNative(String(obj.thinking || obj.text || ''));
|
|
31
32
|
const signature = coerceThoughtSignature(obj.thoughtSignature || obj.signature);
|
|
32
33
|
// 空 thinking + 任意签名 = 有效 (trailing signature case)
|
|
33
34
|
if (!thinking.trim() && signature !== undefined && opts.allowEmptyThinkingWithSignature) {
|
|
@@ -56,7 +57,7 @@ export function sanitizeThinkingBlock(block) {
|
|
|
56
57
|
}
|
|
57
58
|
const sanitized = {
|
|
58
59
|
type: blockType,
|
|
59
|
-
thinking: String(obj.thinking || obj.text || '')
|
|
60
|
+
thinking: sanitizeReasoningTaggedTextWithNative(String(obj.thinking || obj.text || ''))
|
|
60
61
|
};
|
|
61
62
|
const signature = coerceThoughtSignature(obj.thoughtSignature || obj.signature);
|
|
62
63
|
if (signature) {
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* This module provides a deterministic, best-effort repair surface that returns a JSON string
|
|
8
8
|
* or `{}` and never throws.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import { repairArgumentsToStringWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
11
11
|
export class ToolArgumentRepairer {
|
|
12
12
|
repairToString(args) {
|
|
13
|
-
return
|
|
13
|
+
return repairArgumentsToStringWithNative(args);
|
|
14
14
|
}
|
|
15
15
|
validateAndRepair(toolName, args) {
|
|
16
16
|
const repaired = this.repairToString(args);
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* 提供统一的工具调用 ID 生成、规范化和风格管理功能。
|
|
5
5
|
* 支持 'fc' (function call) 和 'preserve' 两种风格。
|
|
6
6
|
*/
|
|
7
|
+
import { normalizeFunctionCallIdWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
7
8
|
const DEFAULT_OPTIONS = {
|
|
8
9
|
style: 'fc',
|
|
9
10
|
prefix: 'fc_',
|
|
@@ -43,13 +44,10 @@ export class ToolCallIdManager {
|
|
|
43
44
|
return this.generateId();
|
|
44
45
|
}
|
|
45
46
|
if (this.options.style === 'fc') {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
// 如果不是 fc_ 风格,生成新的 fc_ ID
|
|
52
|
-
return this.generateId();
|
|
47
|
+
return normalizeFunctionCallIdWithNative({
|
|
48
|
+
callId: trimmed,
|
|
49
|
+
fallback: this.generateId()
|
|
50
|
+
});
|
|
53
51
|
}
|
|
54
52
|
// preserve 风格:保留原始 ID
|
|
55
53
|
return trimmed;
|
|
@@ -1,56 +1,14 @@
|
|
|
1
|
+
import { deriveToolCallKeyWithNative, mergeToolCallsWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
1
2
|
/**
|
|
2
3
|
* Derive a deterministic key for a tool call by combining the normalized
|
|
3
4
|
* function name and serialized arguments. Used to deduplicate inferred calls.
|
|
4
5
|
*/
|
|
5
6
|
export function deriveToolCallKey(call) {
|
|
6
|
-
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
const fn = call.function;
|
|
10
|
-
const name = typeof fn?.name === 'string' ? fn.name.trim() : '';
|
|
11
|
-
const argsRaw = fn?.arguments;
|
|
12
|
-
let args = '';
|
|
13
|
-
if (typeof argsRaw === 'string') {
|
|
14
|
-
args = argsRaw.trim();
|
|
15
|
-
}
|
|
16
|
-
else if (argsRaw !== undefined) {
|
|
17
|
-
try {
|
|
18
|
-
args = JSON.stringify(argsRaw);
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
args = '';
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (!name && !args) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
return `${name}::${args}`;
|
|
7
|
+
return deriveToolCallKeyWithNative(call);
|
|
28
8
|
}
|
|
29
9
|
/**
|
|
30
10
|
* Merge tool call entries with deduplication (by derived key). Returns the new array.
|
|
31
11
|
*/
|
|
32
12
|
export function mergeToolCalls(existing, additions) {
|
|
33
|
-
|
|
34
|
-
const next = Array.isArray(additions) ? additions : [];
|
|
35
|
-
if (!next.length) {
|
|
36
|
-
return base;
|
|
37
|
-
}
|
|
38
|
-
const seen = new Set();
|
|
39
|
-
for (const call of base) {
|
|
40
|
-
const key = deriveToolCallKey(call);
|
|
41
|
-
if (key) {
|
|
42
|
-
seen.add(key);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
for (const call of next) {
|
|
46
|
-
const key = deriveToolCallKey(call);
|
|
47
|
-
if (key && seen.has(key)) {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
base.push(call);
|
|
51
|
-
if (key) {
|
|
52
|
-
seen.add(key);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return base;
|
|
13
|
+
return mergeToolCallsWithNative(existing, additions);
|
|
56
14
|
}
|
|
@@ -1,42 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import { normalizeChatResponseReasoningToolsWithNative } from '../../router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js';
|
|
2
2
|
import { repairToolArguments } from './tool-argument-repairer.js';
|
|
3
3
|
function isObject(v) {
|
|
4
4
|
return !!v && typeof v === 'object' && !Array.isArray(v);
|
|
5
5
|
}
|
|
6
6
|
export function canonicalizeChatResponseTools(payload) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
7
|
+
const cloned = isObject(payload) ? JSON.parse(JSON.stringify(payload)) : payload;
|
|
8
|
+
const nativeOut = normalizeChatResponseReasoningToolsWithNative(cloned);
|
|
9
|
+
const out = isObject(nativeOut) ? nativeOut : cloned;
|
|
10
|
+
const choices = Array.isArray(out?.choices) ? out.choices : [];
|
|
11
|
+
for (const ch of choices) {
|
|
12
|
+
const msg = ch && ch.message ? ch.message : undefined;
|
|
13
|
+
const tcs = Array.isArray(msg?.tool_calls) ? msg.tool_calls : [];
|
|
14
|
+
if (!tcs || !tcs.length)
|
|
15
|
+
continue;
|
|
16
|
+
try {
|
|
17
|
+
if (String(ch.finish_reason || '').toLowerCase() !== 'tool_calls') {
|
|
18
|
+
ch.finish_reason = 'tool_calls';
|
|
20
19
|
}
|
|
21
|
-
|
|
20
|
+
}
|
|
21
|
+
catch { /* ignore */ }
|
|
22
|
+
try {
|
|
23
|
+
if (msg && typeof msg === 'object')
|
|
24
|
+
msg.content = null;
|
|
25
|
+
}
|
|
26
|
+
catch { /* ignore */ }
|
|
27
|
+
for (const tc of tcs) {
|
|
22
28
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
const fn = tc && tc.function ? tc.function : undefined;
|
|
30
|
+
if (fn)
|
|
31
|
+
fn.arguments = repairToolArguments(fn.arguments);
|
|
25
32
|
}
|
|
26
33
|
catch { /* ignore */ }
|
|
27
|
-
for (const tc of tcs) {
|
|
28
|
-
try {
|
|
29
|
-
const fn = tc && tc.function ? tc.function : undefined;
|
|
30
|
-
if (fn)
|
|
31
|
-
fn.arguments = repairToolArguments(fn.arguments);
|
|
32
|
-
}
|
|
33
|
-
catch { /* ignore */ }
|
|
34
|
-
}
|
|
35
34
|
}
|
|
36
|
-
return out;
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
return payload;
|
|
40
35
|
}
|
|
36
|
+
return out;
|
|
41
37
|
}
|
|
42
38
|
export default canonicalizeChatResponseTools;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FilterEngine } from '../../filters/index.js';
|
|
2
2
|
import { loadFieldMapConfig } from '../../filters/utils/fieldmap-loader.js';
|
|
3
|
-
import { normalizeChatResponseReasoningTools } from './reasoning-tool-normalizer.js';
|
|
4
3
|
import { createSnapshotWriter } from './snapshot-utils.js';
|
|
4
|
+
import { normalizeChatResponseReasoningToolsWithNative as normalizeChatResponseReasoningTools } from '../../router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js';
|
|
5
5
|
const REQUEST_FILTER_STAGES = [
|
|
6
6
|
'request_pre',
|
|
7
7
|
'request_map',
|
|
@@ -100,104 +100,11 @@ export async function runChatRequestToolFilters(chatRequest, options = {}) {
|
|
|
100
100
|
recordStage('req_process_tool_filters_output', staged);
|
|
101
101
|
return staged;
|
|
102
102
|
}
|
|
103
|
-
function applyLocalToolGovernance(chatRequest,
|
|
103
|
+
function applyLocalToolGovernance(chatRequest, _rawPayload) {
|
|
104
104
|
if (!chatRequest || typeof chatRequest !== 'object') {
|
|
105
105
|
return chatRequest;
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
const tools = Array.isArray(chatRequest.tools) ? chatRequest.tools : undefined;
|
|
109
|
-
if (!tools || !tools.length) {
|
|
110
|
-
return chatRequest;
|
|
111
|
-
}
|
|
112
|
-
const hasImageHint = detectImageHint(messages, rawPayload);
|
|
113
|
-
if (hasImageHint) {
|
|
114
|
-
// 有图片线索时不干预工具列表,保持由上游(Codex 等)决定 view_image 的暴露与使用。
|
|
115
|
-
return chatRequest;
|
|
116
|
-
}
|
|
117
|
-
const filteredTools = tools.filter((tool) => {
|
|
118
|
-
if (!tool || typeof tool !== 'object')
|
|
119
|
-
return false;
|
|
120
|
-
const fn = tool.function;
|
|
121
|
-
if (!fn || typeof fn !== 'object')
|
|
122
|
-
return true;
|
|
123
|
-
const name = fn.name;
|
|
124
|
-
if (typeof name !== 'string')
|
|
125
|
-
return true;
|
|
126
|
-
return name.trim() !== 'view_image';
|
|
127
|
-
});
|
|
128
|
-
if (filteredTools.length === tools.length) {
|
|
129
|
-
return chatRequest;
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
...chatRequest,
|
|
133
|
-
tools: filteredTools
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function detectImageHint(messages, rawPayload) {
|
|
137
|
-
const patterns = ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp', '.svg'];
|
|
138
|
-
const hasImageExt = (value) => {
|
|
139
|
-
if (typeof value !== 'string' || !value)
|
|
140
|
-
return false;
|
|
141
|
-
const lower = value.toLowerCase();
|
|
142
|
-
return patterns.some(ext => lower.includes(ext));
|
|
143
|
-
};
|
|
144
|
-
const hasImageInMessage = (msg) => {
|
|
145
|
-
if (!msg || typeof msg !== 'object')
|
|
146
|
-
return false;
|
|
147
|
-
const m = msg;
|
|
148
|
-
const content = m.content;
|
|
149
|
-
if (typeof content === 'string') {
|
|
150
|
-
if (hasImageExt(content))
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
else if (Array.isArray(content)) {
|
|
154
|
-
for (const part of content) {
|
|
155
|
-
if (!part || typeof part !== 'object')
|
|
156
|
-
continue;
|
|
157
|
-
const p = part;
|
|
158
|
-
const t = String(p.type || '').toLowerCase();
|
|
159
|
-
if (t.includes('image')) {
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
if (hasImageExt(p.text))
|
|
163
|
-
return true;
|
|
164
|
-
const imageUrl = typeof p.image_url === 'string'
|
|
165
|
-
? p.image_url
|
|
166
|
-
: p.image_url && typeof p.image_url.url === 'string'
|
|
167
|
-
? p.image_url.url
|
|
168
|
-
: typeof p.url === 'string'
|
|
169
|
-
? p.url
|
|
170
|
-
: undefined;
|
|
171
|
-
if (hasImageExt(imageUrl))
|
|
172
|
-
return true;
|
|
173
|
-
if (hasImageExt(p.path))
|
|
174
|
-
return true;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return false;
|
|
178
|
-
};
|
|
179
|
-
// 仅考虑“当前这一轮”的用户输入是否包含图片链接或图片负载,避免因为历史上下文中曾经出现过图片而在后续轮次持续暴露 view_image。
|
|
180
|
-
if (Array.isArray(messages)) {
|
|
181
|
-
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
182
|
-
const msg = messages[i];
|
|
183
|
-
if (!msg || typeof msg !== 'object')
|
|
184
|
-
continue;
|
|
185
|
-
const role = String(msg.role || '').toLowerCase();
|
|
186
|
-
if (role !== 'user')
|
|
187
|
-
continue;
|
|
188
|
-
if (hasImageInMessage(msg)) {
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (rawPayload && typeof rawPayload === 'object') {
|
|
195
|
-
const text = rawPayload.content;
|
|
196
|
-
if (hasImageExt(text)) {
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return false;
|
|
107
|
+
return chatRequest;
|
|
201
108
|
}
|
|
202
109
|
export async function runChatResponseToolFilters(chatJson, options = {}) {
|
|
203
110
|
const resCtxBase = {
|
|
@@ -220,9 +127,7 @@ export async function runChatResponseToolFilters(chatJson, options = {}) {
|
|
|
220
127
|
recordStage('resp_process_tool_filters_input', chatJson);
|
|
221
128
|
try {
|
|
222
129
|
if (chatJson && typeof chatJson === 'object') {
|
|
223
|
-
normalizeChatResponseReasoningTools(chatJson,
|
|
224
|
-
idPrefixBase: 'reasoning_choice'
|
|
225
|
-
});
|
|
130
|
+
chatJson = normalizeChatResponseReasoningTools(chatJson, 'reasoning_choice');
|
|
226
131
|
}
|
|
227
132
|
}
|
|
228
133
|
catch {
|
|
@@ -8,6 +8,12 @@ export interface ToolGovernanceOptions {
|
|
|
8
8
|
baseDir?: string;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Process OpenAI Chat request (messages/tools) with unified 标准 governance.
|
|
13
|
+
* - Augment tools (strict schemas)
|
|
14
|
+
* - Inject/Refine system tool guidance (idempotent)
|
|
15
|
+
* - Canonicalize structured tool_calls; set content=null when applicable
|
|
16
|
+
*/
|
|
11
17
|
export declare function processChatRequestTools(request: Unknown, opts?: ToolGovernanceOptions): Unknown;
|
|
12
18
|
export declare function normalizeApplyPatchToolCallsOnResponse(chat: Unknown): Unknown;
|
|
13
19
|
export declare function normalizeApplyPatchToolCallsOnRequest(request: Unknown): Unknown;
|