@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
|
// Shared JSON-ish parsing helpers
|
|
2
|
+
import { parseLenientJsonishWithNative, repairArgumentsToStringWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
2
3
|
export function tryParseJson(s) {
|
|
3
4
|
if (typeof s !== 'string')
|
|
4
5
|
return s;
|
|
@@ -11,167 +12,9 @@ export function tryParseJson(s) {
|
|
|
11
12
|
}
|
|
12
13
|
// Lenient parsing for function.arguments often produced by models
|
|
13
14
|
export function parseLenient(value) {
|
|
14
|
-
|
|
15
|
-
return {};
|
|
16
|
-
if (typeof value === 'object')
|
|
17
|
-
return value;
|
|
18
|
-
if (typeof value !== 'string')
|
|
19
|
-
return { _raw: String(value) };
|
|
20
|
-
const s0 = value.trim();
|
|
21
|
-
if (!s0)
|
|
22
|
-
return {};
|
|
23
|
-
// 1) strict JSON
|
|
24
|
-
try {
|
|
25
|
-
return JSON.parse(s0);
|
|
26
|
-
}
|
|
27
|
-
catch { /* continue */ }
|
|
28
|
-
// 2) fenced ```json ... ``` or ``` ... ```
|
|
29
|
-
const fence = s0.match(/```(?:json)?\s*([\s\S]*?)\s*```/i);
|
|
30
|
-
const candidate = fence ? fence[1] : s0;
|
|
31
|
-
// 3) object substring
|
|
32
|
-
const objMatch = candidate.match(/\{[\s\S]*\}/);
|
|
33
|
-
if (objMatch) {
|
|
34
|
-
try {
|
|
35
|
-
return JSON.parse(objMatch[0]);
|
|
36
|
-
}
|
|
37
|
-
catch { /* ignore */ }
|
|
38
|
-
}
|
|
39
|
-
// 4) array substring
|
|
40
|
-
const arrMatch = candidate.match(/\[[\s\S]*\]/);
|
|
41
|
-
if (arrMatch) {
|
|
42
|
-
try {
|
|
43
|
-
return JSON.parse(arrMatch[0]);
|
|
44
|
-
}
|
|
45
|
-
catch { /* ignore */ }
|
|
46
|
-
}
|
|
47
|
-
// 5) single quotes → double; unquoted keys → quoted
|
|
48
|
-
let t = candidate.replace(/'([^']*)'/g, '"$1"');
|
|
49
|
-
t = t.replace(/([{,\s])([A-Za-z_][A-Za-z0-9_-]*)\s*:/g, '$1"$2":');
|
|
50
|
-
try {
|
|
51
|
-
return JSON.parse(t);
|
|
52
|
-
}
|
|
53
|
-
catch { /* ignore */ }
|
|
54
|
-
// 6) key=value fallback across lines/commas
|
|
55
|
-
const obj = {};
|
|
56
|
-
const parts = candidate.split(/[\n,]+/).map(p => p.trim()).filter(Boolean);
|
|
57
|
-
for (const p of parts) {
|
|
58
|
-
const m = p.match(/^([A-Za-z_][A-Za-z0-9_-]*)\s*[:=]\s*(.+)$/);
|
|
59
|
-
if (!m)
|
|
60
|
-
continue;
|
|
61
|
-
const k = m[1];
|
|
62
|
-
let v = m[2].trim();
|
|
63
|
-
if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'")))
|
|
64
|
-
v = v.slice(1, -1);
|
|
65
|
-
try {
|
|
66
|
-
const pv = JSON.parse(v);
|
|
67
|
-
obj[k] = pv;
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
catch { /* fallthrough */ }
|
|
71
|
-
if (/^(true|false)$/i.test(v)) {
|
|
72
|
-
obj[k] = /^true$/i.test(v);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (/^-?\d+(?:\.\d+)?$/.test(v)) {
|
|
76
|
-
obj[k] = Number(v);
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
obj[k] = v;
|
|
80
|
-
}
|
|
81
|
-
return obj;
|
|
15
|
+
return parseLenientJsonishWithNative(value);
|
|
82
16
|
}
|
|
83
17
|
// CCR-style repair: JSON -> JSON5-like cleanup -> safe fallback
|
|
84
18
|
export function repairArgumentsToString(value) {
|
|
85
|
-
|
|
86
|
-
if (value === undefined || value === null)
|
|
87
|
-
return '{}';
|
|
88
|
-
if (typeof value === 'object') {
|
|
89
|
-
try {
|
|
90
|
-
return JSON.stringify(value);
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
return '{}';
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (typeof value !== 'string') {
|
|
97
|
-
try {
|
|
98
|
-
return JSON.stringify({ _raw: String(value) });
|
|
99
|
-
}
|
|
100
|
-
catch {
|
|
101
|
-
return '{}';
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
let s = value.trim();
|
|
105
|
-
if (!s)
|
|
106
|
-
return '{}';
|
|
107
|
-
// 1) strict JSON
|
|
108
|
-
try {
|
|
109
|
-
JSON.parse(s);
|
|
110
|
-
return s;
|
|
111
|
-
}
|
|
112
|
-
catch { /* continue */ }
|
|
113
|
-
// 2) fenced ```json ... ``` or ``` ... ```
|
|
114
|
-
const fence = s.match(/```(?:json)?\s*([\s\S]*?)\s*```/i);
|
|
115
|
-
if (fence && fence[1])
|
|
116
|
-
s = fence[1].trim();
|
|
117
|
-
// 3) strip comments (// and /* */)
|
|
118
|
-
try {
|
|
119
|
-
s = s.replace(/\/\/.*$/gm, '');
|
|
120
|
-
s = s.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
121
|
-
}
|
|
122
|
-
catch { /* ignore */ }
|
|
123
|
-
// 4) remove trailing commas before } or ]
|
|
124
|
-
try {
|
|
125
|
-
s = s.replace(/,\s*(?=[}\]])/g, '');
|
|
126
|
-
}
|
|
127
|
-
catch { /* ignore */ }
|
|
128
|
-
// 5) single quotes to double
|
|
129
|
-
try {
|
|
130
|
-
s = s.replace(/'([^'\\]*(?:\\.[^'\\]*)*)'/g, '"$1"');
|
|
131
|
-
}
|
|
132
|
-
catch { /* ignore */ }
|
|
133
|
-
// 6) quote unquoted keys
|
|
134
|
-
try {
|
|
135
|
-
s = s.replace(/([{,\s])([A-Za-z_][A-Za-z0-9_-]*)\s*:/g, '$1"$2":');
|
|
136
|
-
}
|
|
137
|
-
catch { /* ignore */ }
|
|
138
|
-
// 7) try parse after cleanup
|
|
139
|
-
try {
|
|
140
|
-
const obj = JSON.parse(s);
|
|
141
|
-
try {
|
|
142
|
-
if (obj && typeof obj === 'object' && Object.prototype.hasOwnProperty.call(obj, 'command')) {
|
|
143
|
-
const cmd = obj.command;
|
|
144
|
-
if (Array.isArray(cmd)) {
|
|
145
|
-
obj.command = cmd.map((t) => String(t)).join(' ');
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
catch { /* ignore */ }
|
|
150
|
-
return JSON.stringify(obj);
|
|
151
|
-
}
|
|
152
|
-
catch { /* continue */ }
|
|
153
|
-
// 8) extract first {...} or [...] substring and try again
|
|
154
|
-
try {
|
|
155
|
-
const m = s.match(/\{[\s\S]*\}|\[[\s\S]*\]/);
|
|
156
|
-
if (m) {
|
|
157
|
-
const obj = JSON.parse(m[0]);
|
|
158
|
-
try {
|
|
159
|
-
if (obj && typeof obj === 'object' && Object.prototype.hasOwnProperty.call(obj, 'command')) {
|
|
160
|
-
const cmd = obj.command;
|
|
161
|
-
if (Array.isArray(cmd)) {
|
|
162
|
-
obj.command = cmd.map((t) => String(t)).join(' ');
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
catch { /* ignore */ }
|
|
167
|
-
return JSON.stringify(obj);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
catch { /* ignore */ }
|
|
171
|
-
// 9) final fallback
|
|
172
|
-
return '{}';
|
|
173
|
-
}
|
|
174
|
-
catch {
|
|
175
|
-
return '{}';
|
|
176
|
-
}
|
|
19
|
+
return repairArgumentsToStringWithNative(value);
|
|
177
20
|
}
|
|
@@ -1,173 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
const obj = (props, req = []) => {
|
|
3
|
-
const schema = {
|
|
4
|
-
type: 'object',
|
|
5
|
-
properties: props,
|
|
6
|
-
additionalProperties: false
|
|
7
|
-
};
|
|
8
|
-
if (Array.isArray(req) && req.length > 0) {
|
|
9
|
-
schema.required = req;
|
|
10
|
-
}
|
|
11
|
-
return schema;
|
|
12
|
-
};
|
|
13
|
-
function uniq(arr) { return Array.from(new Set(arr)); }
|
|
14
|
-
function buildKnownServersLine(discoveredServers) {
|
|
15
|
-
if (!Array.isArray(discoveredServers) || discoveredServers.length === 0)
|
|
16
|
-
return '';
|
|
17
|
-
const list = uniq(discoveredServers).slice(0, 8);
|
|
18
|
-
const suffix = discoveredServers.length > list.length ? ` (+${discoveredServers.length - list.length} more)` : '';
|
|
19
|
-
return `Known MCP servers: ${list.join(', ')}${suffix}.`;
|
|
20
|
-
}
|
|
21
|
-
function buildMcpServerReminder() {
|
|
22
|
-
return 'Note: arguments.server is an MCP server label (NOT a tool name like shell/exec_command/apply_patch).';
|
|
23
|
-
}
|
|
24
|
-
function buildListResourcesDescription(discoveredServers) {
|
|
25
|
-
return [
|
|
26
|
-
'List resources exposed by MCP servers.',
|
|
27
|
-
'Only use this for MCP resources (not MCP tools). Many MCP servers expose tools only; if the result is empty, do not retry.',
|
|
28
|
-
'If you do not know the MCP server name yet, call this tool with {} once; then reuse the returned server names for subsequent calls.',
|
|
29
|
-
buildMcpServerReminder(),
|
|
30
|
-
buildKnownServersLine(discoveredServers)
|
|
31
|
-
].filter(Boolean).join('\n');
|
|
32
|
-
}
|
|
33
|
-
function buildListTemplatesDescription(discoveredServers) {
|
|
34
|
-
return [
|
|
35
|
-
'List resource templates exposed by MCP servers.',
|
|
36
|
-
'Only use this for MCP resources (not MCP tools). If list_mcp_resources returns empty, do not retry.',
|
|
37
|
-
'If you do not know the MCP server name yet, call list_mcp_resources({}) once first.',
|
|
38
|
-
buildMcpServerReminder(),
|
|
39
|
-
buildKnownServersLine(discoveredServers)
|
|
40
|
-
].filter(Boolean).join('\n');
|
|
41
|
-
}
|
|
42
|
-
function buildReadResourceDescription(discoveredServers) {
|
|
43
|
-
return [
|
|
44
|
-
'Read a specific MCP resource by { server, uri }.',
|
|
45
|
-
'Only use this for MCP resources (not MCP tools). If list_mcp_resources returns empty, do not retry.',
|
|
46
|
-
'If you do not know the MCP server name yet, call list_mcp_resources({}) once first.',
|
|
47
|
-
buildMcpServerReminder(),
|
|
48
|
-
buildKnownServersLine(discoveredServers)
|
|
49
|
-
].filter(Boolean).join('\n');
|
|
50
|
-
}
|
|
1
|
+
import { injectMcpToolsForChatWithNative, injectMcpToolsForResponsesWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
51
2
|
export function injectMcpToolsForChat(tools, discoveredServers) {
|
|
52
|
-
|
|
53
|
-
const keep = new Set();
|
|
54
|
-
const listServers = discoveredServers && discoveredServers.length ? { type: 'string', enum: uniq(discoveredServers), minLength: 1 } : { type: 'string', minLength: 1 };
|
|
55
|
-
const templateServer = discoveredServers && discoveredServers.length ? { type: 'string', enum: uniq(discoveredServers), minLength: 1 } : { type: 'string', minLength: 1 };
|
|
56
|
-
const ensure = (name, def) => { if (!keep.has(name)) {
|
|
57
|
-
out.push(def);
|
|
58
|
-
keep.add(name);
|
|
59
|
-
} };
|
|
60
|
-
const current = Array.isArray(tools) ? tools : [];
|
|
61
|
-
for (const t of current) {
|
|
62
|
-
const name = t && t.function && typeof t.function.name === 'string' ? String(t.function.name) : '';
|
|
63
|
-
const lower = name.toLowerCase();
|
|
64
|
-
if (!name) {
|
|
65
|
-
out.push(t);
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (lower === 'list_mcp_resources') {
|
|
69
|
-
ensure('list_mcp_resources', { type: 'function', function: { name: 'list_mcp_resources', description: (t.function?.description && String(t.function.description).trim()) ? t.function.description : buildListResourcesDescription(discoveredServers), parameters: obj({ server: listServers, filter: { type: 'string' }, root: { type: 'string' } }) } });
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (lower === 'list_mcp_resource_templates') {
|
|
73
|
-
ensure('list_mcp_resource_templates', {
|
|
74
|
-
type: 'function',
|
|
75
|
-
function: {
|
|
76
|
-
name: 'list_mcp_resource_templates',
|
|
77
|
-
description: (t.function?.description && String(t.function.description).trim()) ? t.function.description : buildListTemplatesDescription(discoveredServers),
|
|
78
|
-
parameters: obj({ server: templateServer, cursor: { type: 'string' } })
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
if (lower === 'read_mcp_resource') {
|
|
84
|
-
// Phase gating: do not expose read until we have known server labels.
|
|
85
|
-
if (discoveredServers.length > 0) {
|
|
86
|
-
const srv = { type: 'string', enum: uniq(discoveredServers) };
|
|
87
|
-
ensure('read_mcp_resource', {
|
|
88
|
-
type: 'function',
|
|
89
|
-
function: {
|
|
90
|
-
name: 'read_mcp_resource',
|
|
91
|
-
description: (t.function?.description && String(t.function.description).trim()) ? t.function.description : buildReadResourceDescription(discoveredServers),
|
|
92
|
-
parameters: obj({ server: srv, uri: { type: 'string' } }, ['server', 'uri'])
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
out.push(t);
|
|
99
|
-
keep.add(lower);
|
|
100
|
-
}
|
|
101
|
-
// Ensure list exists when user did not provide it
|
|
102
|
-
if (!keep.has('list_mcp_resources')) {
|
|
103
|
-
out.push({ type: 'function', function: { name: 'list_mcp_resources', description: buildListResourcesDescription(discoveredServers), parameters: obj({ server: listServers, filter: { type: 'string' }, root: { type: 'string' } }) } });
|
|
104
|
-
}
|
|
105
|
-
// Ensure templates exists (safe to call after list_mcp_resources)
|
|
106
|
-
if (!keep.has('list_mcp_resource_templates')) {
|
|
107
|
-
out.push({
|
|
108
|
-
type: 'function',
|
|
109
|
-
function: {
|
|
110
|
-
name: 'list_mcp_resource_templates',
|
|
111
|
-
description: buildListTemplatesDescription(discoveredServers),
|
|
112
|
-
parameters: obj({ server: templateServer, cursor: { type: 'string' } })
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
return out;
|
|
3
|
+
return injectMcpToolsForChatWithNative(tools, discoveredServers);
|
|
117
4
|
}
|
|
118
5
|
export function injectMcpToolsForResponses(tools, discoveredServers) {
|
|
119
|
-
|
|
120
|
-
const keep = new Set();
|
|
121
|
-
const listServers = { type: 'string', minLength: 1 };
|
|
122
|
-
const templateServer = discoveredServers && discoveredServers.length ? { type: 'string', enum: uniq(discoveredServers), minLength: 1 } : { type: 'string', minLength: 1 };
|
|
123
|
-
const ensure = (name, def) => { if (!keep.has(name)) {
|
|
124
|
-
out.push(def);
|
|
125
|
-
keep.add(name);
|
|
126
|
-
} };
|
|
127
|
-
const current = Array.isArray(tools) ? tools : [];
|
|
128
|
-
for (const t of current) {
|
|
129
|
-
const name = t && t.function && typeof t.function.name === 'string' ? String(t.function.name) : '';
|
|
130
|
-
const lower = name.toLowerCase();
|
|
131
|
-
if (!name) {
|
|
132
|
-
out.push(t);
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
if (lower === 'list_mcp_resources') {
|
|
136
|
-
ensure('list_mcp_resources', { type: 'function', function: { name: 'list_mcp_resources', description: (t.function?.description && String(t.function.description).trim()) ? t.function.description : buildListResourcesDescription(discoveredServers), parameters: obj({ server: listServers, filter: { type: 'string' }, root: { type: 'string' } }) } });
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
if (lower === 'list_mcp_resource_templates') {
|
|
140
|
-
ensure('list_mcp_resource_templates', {
|
|
141
|
-
type: 'function',
|
|
142
|
-
function: {
|
|
143
|
-
name: 'list_mcp_resource_templates',
|
|
144
|
-
description: (t.function?.description && String(t.function.description).trim()) ? t.function.description : buildListTemplatesDescription(discoveredServers),
|
|
145
|
-
parameters: obj({ server: templateServer, cursor: { type: 'string' } })
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (lower === 'read_mcp_resource' && discoveredServers.length > 0) {
|
|
151
|
-
const srv = { type: 'string', enum: uniq(discoveredServers) };
|
|
152
|
-
ensure('read_mcp_resource', { type: 'function', function: { name: 'read_mcp_resource', description: (t.function?.description && String(t.function.description).trim()) ? t.function.description : buildReadResourceDescription(discoveredServers), parameters: obj({ server: srv, uri: { type: 'string' } }, ['server', 'uri']) } });
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
out.push(t);
|
|
156
|
-
keep.add(lower);
|
|
157
|
-
}
|
|
158
|
-
if (!keep.has('list_mcp_resources')) {
|
|
159
|
-
out.push({ type: 'function', function: { name: 'list_mcp_resources', description: buildListResourcesDescription(discoveredServers), parameters: obj({ server: listServers, filter: { type: 'string' }, root: { type: 'string' } }) } });
|
|
160
|
-
keep.add('list_mcp_resources');
|
|
161
|
-
}
|
|
162
|
-
if (!keep.has('list_mcp_resource_templates')) {
|
|
163
|
-
out.push({
|
|
164
|
-
type: 'function',
|
|
165
|
-
function: {
|
|
166
|
-
name: 'list_mcp_resource_templates',
|
|
167
|
-
description: buildListTemplatesDescription(discoveredServers),
|
|
168
|
-
parameters: obj({ server: templateServer, cursor: { type: 'string' } })
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
return out;
|
|
6
|
+
return injectMcpToolsForResponsesWithNative(tools, discoveredServers);
|
|
173
7
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
+
import { isImagePathWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
1
2
|
export function isImagePath(p) {
|
|
2
|
-
|
|
3
|
-
const s = String(p || '').toLowerCase();
|
|
4
|
-
return /\.(png|jpg|jpeg|gif|webp|bmp|svg|tiff?|ico|heic|jxl)$/.test(s);
|
|
5
|
-
}
|
|
6
|
-
catch {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
3
|
+
return isImagePathWithNative(p);
|
|
9
4
|
}
|
|
@@ -1,57 +1,20 @@
|
|
|
1
1
|
import { isJsonObject, jsonClone } from '../hub/types/json.js';
|
|
2
|
-
|
|
3
|
-
return typeof value === 'string' && value.trim().length > 0;
|
|
4
|
-
}
|
|
2
|
+
import { encodeMetadataPassthroughWithNative, extractMetadataPassthroughWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
5
3
|
export function encodeMetadataPassthrough(parameters, options) {
|
|
6
|
-
|
|
7
|
-
return undefined;
|
|
8
|
-
const encoded = {};
|
|
9
|
-
const { prefix, keys } = options;
|
|
10
|
-
for (const key of keys) {
|
|
11
|
-
if (!isValidKey(key))
|
|
12
|
-
continue;
|
|
13
|
-
const value = parameters[key];
|
|
14
|
-
if (value === undefined)
|
|
15
|
-
continue;
|
|
16
|
-
try {
|
|
17
|
-
encoded[`${prefix}${key}`] = JSON.stringify(value);
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return Object.keys(encoded).length ? encoded : undefined;
|
|
4
|
+
return encodeMetadataPassthroughWithNative(parameters, options.prefix, options.keys);
|
|
24
5
|
}
|
|
25
6
|
export function extractMetadataPassthrough(metadataField, options) {
|
|
26
7
|
if (!metadataField || !isJsonObject(metadataField)) {
|
|
27
8
|
return {};
|
|
28
9
|
}
|
|
29
10
|
const cloned = jsonClone(metadataField);
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!rawKey.startsWith(prefix))
|
|
36
|
-
continue;
|
|
37
|
-
const suffix = rawKey.slice(prefix.length);
|
|
38
|
-
if (!allowedKeys.has(suffix))
|
|
39
|
-
continue;
|
|
40
|
-
const rawValue = cloned[rawKey];
|
|
41
|
-
if (typeof rawValue !== 'string')
|
|
42
|
-
continue;
|
|
43
|
-
try {
|
|
44
|
-
const parsed = rawValue ? JSON.parse(rawValue) : undefined;
|
|
45
|
-
passthrough[suffix] = parsed;
|
|
46
|
-
delete cloned[rawKey];
|
|
47
|
-
mutated = true;
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
11
|
+
const native = extractMetadataPassthroughWithNative(cloned, options.prefix, options.keys);
|
|
12
|
+
const metadata = native.metadata && isJsonObject(native.metadata) ? native.metadata : undefined;
|
|
13
|
+
const passthrough = native.passthrough && isJsonObject(native.passthrough)
|
|
14
|
+
? native.passthrough
|
|
15
|
+
: undefined;
|
|
53
16
|
return {
|
|
54
|
-
metadata
|
|
55
|
-
passthrough
|
|
17
|
+
metadata,
|
|
18
|
+
passthrough
|
|
56
19
|
};
|
|
57
20
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// OpenAI Chat finalizer: enforce canonical shapes without the legacy hook system.
|
|
2
2
|
// - Ensures tool_calls use stringified JSON arguments and sets finish_reason='tool_calls' when applicable
|
|
3
3
|
// - Normalizes potential tool messages (role:'tool') content to strict strings (JSON-stringify for objects)
|
|
4
|
+
import { sanitizeReasoningTaggedTextWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
4
5
|
function asObject(v) {
|
|
5
6
|
return v && typeof v === 'object' && !Array.isArray(v) ? v : null;
|
|
6
7
|
}
|
|
@@ -135,7 +136,7 @@ function applyChatReasoningPolicy(target, mode) {
|
|
|
135
136
|
function normalizeReasoningField(container, mode) {
|
|
136
137
|
const bag = container;
|
|
137
138
|
const rawValue = typeof bag.reasoning_content === 'string' ? bag.reasoning_content : '';
|
|
138
|
-
const trimmed = rawValue.trim();
|
|
139
|
+
const trimmed = sanitizeReasoningTaggedTextWithNative(rawValue).trim();
|
|
139
140
|
if (!trimmed && Object.prototype.hasOwnProperty.call(bag, 'reasoning_content')) {
|
|
140
141
|
delete bag.reasoning_content;
|
|
141
142
|
return;
|