@jsonstudio/rcc 0.89.168 → 0.89.524
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 +18 -15
- package/dist/build-info.js +3 -3
- package/dist/build-info.js.map +1 -1
- package/dist/cli.js +94 -0
- package/dist/cli.js.map +1 -1
- package/dist/client/gemini-cli/gemini-cli-protocol-client.js +28 -5
- package/dist/client/gemini-cli/gemini-cli-protocol-client.js.map +1 -1
- package/dist/commands/token-daemon.d.ts +2 -0
- package/dist/commands/token-daemon.js +183 -0
- package/dist/commands/token-daemon.js.map +1 -0
- package/dist/error-handling/quiet-error-handling-center.d.ts +9 -0
- package/dist/error-handling/quiet-error-handling-center.js +141 -0
- package/dist/error-handling/quiet-error-handling-center.js.map +1 -0
- package/dist/error-handling/route-error-hub.js +8 -2
- package/dist/error-handling/route-error-hub.js.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/modules/llmswitch/bridge.d.ts +1 -1
- package/dist/modules/llmswitch/bridge.js +3 -2
- package/dist/modules/llmswitch/bridge.js.map +1 -1
- package/dist/modules/pipeline/utils/colored-logger.d.ts +2 -0
- package/dist/modules/pipeline/utils/colored-logger.js +22 -3
- package/dist/modules/pipeline/utils/colored-logger.js.map +1 -1
- package/dist/providers/auth/antigravity-userinfo-helper.d.ts +10 -0
- package/dist/providers/auth/antigravity-userinfo-helper.js +140 -0
- package/dist/providers/auth/antigravity-userinfo-helper.js.map +1 -0
- package/dist/providers/auth/gemini-cli-userinfo-helper.js +12 -2
- package/dist/providers/auth/gemini-cli-userinfo-helper.js.map +1 -1
- package/dist/providers/auth/oauth-lifecycle.js +395 -24
- package/dist/providers/auth/oauth-lifecycle.js.map +1 -1
- package/dist/providers/auth/token-scanner/index.d.ts +32 -0
- package/dist/providers/auth/token-scanner/index.js +86 -0
- package/dist/providers/auth/token-scanner/index.js.map +1 -0
- package/dist/providers/auth/tokenfile-auth.d.ts +17 -0
- package/dist/providers/auth/tokenfile-auth.js +27 -5
- package/dist/providers/auth/tokenfile-auth.js.map +1 -1
- package/dist/providers/core/api/provider-types.d.ts +10 -0
- package/dist/providers/core/config/oauth-flows.d.ts +25 -0
- package/dist/providers/core/config/oauth-flows.js +92 -5
- package/dist/providers/core/config/oauth-flows.js.map +1 -1
- package/dist/providers/core/config/provider-oauth-configs.js +93 -2
- package/dist/providers/core/config/provider-oauth-configs.js.map +1 -1
- package/dist/providers/core/config/service-profiles.js +18 -10
- package/dist/providers/core/config/service-profiles.js.map +1 -1
- package/dist/providers/core/runtime/base-provider.d.ts +2 -0
- package/dist/providers/core/runtime/base-provider.js +135 -15
- package/dist/providers/core/runtime/base-provider.js.map +1 -1
- package/dist/providers/core/runtime/gemini-cli-http-provider.d.ts +8 -3
- package/dist/providers/core/runtime/gemini-cli-http-provider.js +332 -67
- package/dist/providers/core/runtime/gemini-cli-http-provider.js.map +1 -1
- package/dist/providers/core/runtime/http-request-executor.d.ts +1 -0
- package/dist/providers/core/runtime/http-request-executor.js +41 -1
- package/dist/providers/core/runtime/http-request-executor.js.map +1 -1
- package/dist/providers/core/runtime/http-transport-provider.d.ts +27 -0
- package/dist/providers/core/runtime/http-transport-provider.js +342 -69
- package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
- package/dist/providers/core/runtime/provider-error-classifier.d.ts +2 -2
- package/dist/providers/core/runtime/provider-error-classifier.js +14 -4
- package/dist/providers/core/runtime/provider-error-classifier.js.map +1 -1
- package/dist/providers/core/runtime/provider-factory.d.ts +1 -0
- package/dist/providers/core/runtime/provider-factory.js +37 -8
- package/dist/providers/core/runtime/provider-factory.js.map +1 -1
- package/dist/providers/core/runtime/responses-provider.d.ts +3 -3
- package/dist/providers/core/runtime/responses-provider.js +56 -117
- package/dist/providers/core/runtime/responses-provider.js.map +1 -1
- package/dist/providers/core/runtime/vision-debug-utils.d.ts +13 -0
- package/dist/providers/core/runtime/vision-debug-utils.js +114 -0
- package/dist/providers/core/runtime/vision-debug-utils.js.map +1 -0
- package/dist/providers/core/strategies/oauth-auth-code-flow.js +82 -25
- package/dist/providers/core/strategies/oauth-auth-code-flow.js.map +1 -1
- package/dist/providers/core/utils/http-client.d.ts +5 -0
- package/dist/providers/core/utils/http-client.js +31 -4
- package/dist/providers/core/utils/http-client.js.map +1 -1
- package/dist/providers/core/utils/provider-error-reporter.js +8 -2
- package/dist/providers/core/utils/provider-error-reporter.js.map +1 -1
- package/dist/providers/core/utils/snapshot-writer.d.ts +1 -1
- package/dist/providers/core/utils/snapshot-writer.js +5 -1
- package/dist/providers/core/utils/snapshot-writer.js.map +1 -1
- package/dist/providers/profile/provider-profile-loader.js +8 -4
- package/dist/providers/profile/provider-profile-loader.js.map +1 -1
- package/dist/runtime/runtime-flags.d.ts +4 -0
- package/dist/runtime/runtime-flags.js +32 -0
- package/dist/runtime/runtime-flags.js.map +1 -0
- package/dist/server/handlers/handler-utils.js +29 -2
- package/dist/server/handlers/handler-utils.js.map +1 -1
- package/dist/server/handlers/messages-handler.js +27 -26
- package/dist/server/handlers/messages-handler.js.map +1 -1
- package/dist/server/handlers/responses-handler.js +35 -1
- package/dist/server/handlers/responses-handler.js.map +1 -1
- package/dist/server/handlers/sse-dispatcher.js +22 -2
- package/dist/server/handlers/sse-dispatcher.js.map +1 -1
- package/dist/server/runtime/http-server/index.d.ts +10 -0
- package/dist/server/runtime/http-server/index.js +551 -148
- package/dist/server/runtime/http-server/index.js.map +1 -1
- package/dist/server/runtime/http-server/request-executor.d.ts +14 -0
- package/dist/server/runtime/http-server/request-executor.js +638 -149
- package/dist/server/runtime/http-server/request-executor.js.map +1 -1
- package/dist/server/runtime/http-server/routes.d.ts +5 -0
- package/dist/server/runtime/http-server/routes.js +69 -0
- package/dist/server/runtime/http-server/routes.js.map +1 -1
- package/dist/server/runtime/http-server/runtime-manager.js +18 -0
- package/dist/server/runtime/http-server/runtime-manager.js.map +1 -1
- package/dist/server/utils/sse-request-parser.d.ts +1 -0
- package/dist/server/utils/sse-request-parser.js +17 -6
- package/dist/server/utils/sse-request-parser.js.map +1 -1
- package/dist/server/utils/utf8-chunk-buffer.d.ts +43 -0
- package/dist/server/utils/utf8-chunk-buffer.js +132 -0
- package/dist/server/utils/utf8-chunk-buffer.js.map +1 -0
- package/dist/server/utils/warmup-detector.d.ts +7 -0
- package/dist/server/utils/warmup-detector.js +125 -0
- package/dist/server/utils/warmup-detector.js.map +1 -0
- package/dist/server/utils/warmup-storm-tracker.d.ts +9 -0
- package/dist/server/utils/warmup-storm-tracker.js +61 -0
- package/dist/server/utils/warmup-storm-tracker.js.map +1 -0
- package/dist/token-daemon/index.d.ts +7 -0
- package/dist/token-daemon/index.js +242 -0
- package/dist/token-daemon/index.js.map +1 -0
- package/dist/token-daemon/server-utils.d.ts +33 -0
- package/dist/token-daemon/server-utils.js +155 -0
- package/dist/token-daemon/server-utils.js.map +1 -0
- package/dist/token-daemon/token-daemon.d.ts +20 -0
- package/dist/token-daemon/token-daemon.js +144 -0
- package/dist/token-daemon/token-daemon.js.map +1 -0
- package/dist/token-daemon/token-types.d.ts +44 -0
- package/dist/token-daemon/token-types.js +18 -0
- package/dist/token-daemon/token-types.js.map +1 -0
- package/dist/token-daemon/token-utils.d.ts +17 -0
- package/dist/token-daemon/token-utils.js +153 -0
- package/dist/token-daemon/token-utils.js.map +1 -0
- package/dist/tools/semantic-replay.js +7 -6
- package/dist/tools/semantic-replay.js.map +1 -1
- package/dist/utils/debug-utils.js +14 -0
- package/dist/utils/debug-utils.js.map +1 -1
- package/dist/utils/error-handler-registry.d.ts +36 -0
- package/dist/utils/error-handler-registry.js +99 -12
- package/dist/utils/error-handler-registry.js.map +1 -1
- package/dist/utils/error-handling-utils.js +4 -3
- package/dist/utils/error-handling-utils.js.map +1 -1
- package/dist/utils/log-helpers.d.ts +6 -0
- package/dist/utils/log-helpers.js +90 -0
- package/dist/utils/log-helpers.js.map +1 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.js +55 -2
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/snapshot-writer.js +2 -6
- package/dist/utils/snapshot-writer.js.map +1 -1
- package/node_modules/@jsonstudio/llms/README.md +2 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/codecs/gemini-openai-codec.js +152 -6
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/auto-thinking.d.ts +6 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/auto-thinking.js +25 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/field-mapping.d.ts +14 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/field-mapping.js +155 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/gemini-web-search.d.ts +17 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/gemini-web-search.js +68 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-image-content.d.ts +2 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-image-content.js +83 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-tool-extraction.d.ts +2 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-tool-extraction.js +264 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-vision-prompt.d.ts +11 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-vision-prompt.js +177 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-web-search.d.ts +2 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-web-search.js +63 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/qwen-transform.d.ts +3 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/qwen-transform.js +209 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/request-rules.d.ts +24 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/request-rules.js +63 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-blacklist.d.ts +14 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-blacklist.js +85 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-normalize.d.ts +5 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-normalize.js +121 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-validate.d.ts +5 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-validate.js +76 -0
- package/{dist/providers/compat/utils/snapshot-writer.d.ts → node_modules/@jsonstudio/llms/dist/conversion/compat/actions/snapshot.d.ts} +2 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/snapshot.js +21 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/tool-schema.d.ts +6 -0
- package/{dist/providers/compat/glm/utils/tool-schema-helpers.js → node_modules/@jsonstudio/llms/dist/conversion/compat/actions/tool-schema.js} +6 -1
- package/{dist/providers/compat/filters → node_modules/@jsonstudio/llms/dist/conversion/compat/actions}/universal-shape-filter.d.ts +17 -22
- package/{dist/providers/compat/filters → node_modules/@jsonstudio/llms/dist/conversion/compat/actions}/universal-shape-filter.js +46 -99
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-gemini.json +17 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-glm.json +196 -13
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-iflow.json +194 -26
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-lmstudio.json +43 -35
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-qwen.json +20 -16
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/responses-c4m.json +42 -42
- package/node_modules/@jsonstudio/llms/dist/conversion/config/sample-config.json +1 -1
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-engine.d.ts +7 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-engine.js +5 -665
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.d.ts +9 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +869 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-types.d.ts +55 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/hub-pipeline.d.ts +2 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/hub-pipeline.js +74 -5
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +2 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/target-utils.js +9 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/process/chat-process.js +213 -1
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/provider-response.d.ts +34 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/provider-response.js +84 -24
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/response-runtime.js +19 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/server-side-tools.d.ts +26 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/server-side-tools.js +383 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/semantic-mappers/gemini-mapper.js +241 -14
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/semantic-mappers/responses-mapper.js +17 -1
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/standardized-bridge.js +14 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/types/standardized.d.ts +1 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-host-policy.d.ts +6 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-host-policy.js +14 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-openai-bridge.js +133 -5
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/anthropic-message-utils.js +98 -3
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/bridge-message-utils.js +137 -10
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-output-builder.js +43 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-reasoning-registry.d.ts +4 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-reasoning-registry.js +62 -1
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-response-utils.js +23 -1
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/snapshot-utils.js +17 -47
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-canonicalizer.d.ts +2 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-filter-pipeline.js +12 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-mapping.js +25 -2
- package/node_modules/@jsonstudio/llms/dist/index.d.ts +1 -0
- package/node_modules/@jsonstudio/llms/dist/index.js +1 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/bootstrap.js +540 -36
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/classifier.js +12 -11
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/context-advisor.d.ts +19 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/context-advisor.js +64 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/engine.d.ts +26 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/engine.js +450 -54
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/features.js +23 -458
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/health-manager.js +2 -7
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/message-utils.d.ts +7 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/message-utils.js +78 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/provider-registry.js +7 -2
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-counter.js +14 -3
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-estimator.d.ts +2 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-estimator.js +16 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-file-scanner.d.ts +15 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-file-scanner.js +56 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/tool-signals.d.ts +13 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/tool-signals.js +403 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/types.d.ts +86 -2
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/types.js +3 -1
- package/node_modules/@jsonstudio/llms/dist/servertool/engine.d.ts +27 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/engine.js +60 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/flow-types.d.ts +40 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/flow-types.js +1 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/handlers/vision.d.ts +1 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/handlers/vision.js +194 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/handlers/web-search.d.ts +1 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/handlers/web-search.js +638 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/orchestration-types.d.ts +33 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/orchestration-types.js +1 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/registry.d.ts +18 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/registry.js +27 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/server-side-tools.d.ts +8 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/server-side-tools.js +208 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/types.d.ts +88 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/types.js +1 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/vision-tool.d.ts +2 -0
- package/node_modules/@jsonstudio/llms/dist/servertool/vision-tool.js +185 -0
- package/node_modules/@jsonstudio/llms/dist/sse/json-to-sse/event-generators/responses.js +15 -3
- package/node_modules/@jsonstudio/llms/dist/sse/sse-to-json/builders/response-builder.js +6 -3
- package/node_modules/@jsonstudio/llms/dist/sse/sse-to-json/gemini-sse-to-json-converter.js +27 -1
- package/node_modules/@jsonstudio/llms/dist/sse/types/gemini-types.d.ts +20 -1
- package/node_modules/@jsonstudio/llms/dist/sse/types/responses-types.js +1 -1
- package/node_modules/@jsonstudio/llms/dist/telemetry/stats-center.d.ts +73 -0
- package/node_modules/@jsonstudio/llms/dist/telemetry/stats-center.js +280 -0
- package/node_modules/@jsonstudio/llms/package.json +2 -2
- package/package.json +11 -10
- package/scripts/README.md +26 -12
- package/scripts/auth-antigravity-token.mjs +64 -0
- package/scripts/auth-gemini-cli-token.mjs +96 -0
- package/scripts/auth-iflow-manual.mjs +81 -0
- package/scripts/auth-iflow-token-direct.mjs +87 -0
- package/scripts/auth-iflow-token.mjs +77 -0
- package/scripts/copy-compat-assets.mjs +3 -15
- package/scripts/install-verify.mjs +1 -0
- package/scripts/pack-mode.mjs +2 -1
- package/scripts/publish-rcc.mjs +20 -4
- package/scripts/replay-codex-sample.mjs +13 -8
- package/scripts/tests/chat-pipeline-blackbox.mjs +1 -1
- package/scripts/tests/virtual-router-health.mjs +141 -6
- package/scripts/tools/capture-provider-goldens.mjs +8 -7
- package/scripts/verify-client-headers.mjs +224 -0
- package/dist/providers/compat/base-compatibility.d.ts +0 -27
- package/dist/providers/compat/base-compatibility.js +0 -143
- package/dist/providers/compat/base-compatibility.js.map +0 -1
- package/dist/providers/compat/compat-directory-loader.d.ts +0 -4
- package/dist/providers/compat/compat-directory-loader.js +0 -85
- package/dist/providers/compat/compat-directory-loader.js.map +0 -1
- package/dist/providers/compat/compatibility-adapter.d.ts +0 -18
- package/dist/providers/compat/compatibility-adapter.js +0 -104
- package/dist/providers/compat/compatibility-adapter.js.map +0 -1
- package/dist/providers/compat/compatibility-factory.d.ts +0 -57
- package/dist/providers/compat/compatibility-factory.js +0 -155
- package/dist/providers/compat/compatibility-factory.js.map +0 -1
- package/dist/providers/compat/compatibility-interface.d.ts +0 -35
- package/dist/providers/compat/compatibility-interface.js +0 -2
- package/dist/providers/compat/compatibility-interface.js.map +0 -1
- package/dist/providers/compat/compatibility-manager.d.ts +0 -85
- package/dist/providers/compat/compatibility-manager.js +0 -368
- package/dist/providers/compat/compatibility-manager.js.map +0 -1
- package/dist/providers/compat/config/config-compatibility.d.ts +0 -28
- package/dist/providers/compat/config/config-compatibility.js +0 -95
- package/dist/providers/compat/config/config-compatibility.js.map +0 -1
- package/dist/providers/compat/field-mapping.d.ts +0 -102
- package/dist/providers/compat/field-mapping.js +0 -447
- package/dist/providers/compat/field-mapping.js.map +0 -1
- package/dist/providers/compat/filters/blacklist-sanitizer.d.ts +0 -45
- package/dist/providers/compat/filters/blacklist-sanitizer.js +0 -133
- package/dist/providers/compat/filters/blacklist-sanitizer.js.map +0 -1
- package/dist/providers/compat/filters/response-blacklist-sanitizer.d.ts +0 -28
- package/dist/providers/compat/filters/response-blacklist-sanitizer.js +0 -138
- package/dist/providers/compat/filters/response-blacklist-sanitizer.js.map +0 -1
- package/dist/providers/compat/filters/universal-shape-filter.js.map +0 -1
- package/dist/providers/compat/glm/config/blacklist-rules.json +0 -22
- package/dist/providers/compat/glm/config/field-mappings.json +0 -92
- package/dist/providers/compat/glm/config/response-blacklist.json +0 -7
- package/dist/providers/compat/glm/config/shape-filters.json +0 -37
- package/dist/providers/compat/glm/field-mapping/field-mapping-processor.d.ts +0 -28
- package/dist/providers/compat/glm/field-mapping/field-mapping-processor.js +0 -306
- package/dist/providers/compat/glm/field-mapping/field-mapping-processor.js.map +0 -1
- package/dist/providers/compat/glm/functions/glm-processor.d.ts +0 -50
- package/dist/providers/compat/glm/functions/glm-processor.js +0 -134
- package/dist/providers/compat/glm/functions/glm-processor.js.map +0 -1
- package/dist/providers/compat/glm/glm-compatibility.d.ts +0 -34
- package/dist/providers/compat/glm/glm-compatibility.js +0 -117
- package/dist/providers/compat/glm/glm-compatibility.js.map +0 -1
- package/dist/providers/compat/glm/hooks/base-hook.d.ts +0 -21
- package/dist/providers/compat/glm/hooks/base-hook.js +0 -53
- package/dist/providers/compat/glm/hooks/base-hook.js.map +0 -1
- package/dist/providers/compat/glm/hooks/glm-request-validation-hook.d.ts +0 -24
- package/dist/providers/compat/glm/hooks/glm-request-validation-hook.js +0 -268
- package/dist/providers/compat/glm/hooks/glm-request-validation-hook.js.map +0 -1
- package/dist/providers/compat/glm/hooks/glm-response-normalization-hook.d.ts +0 -21
- package/dist/providers/compat/glm/hooks/glm-response-normalization-hook.js +0 -171
- package/dist/providers/compat/glm/hooks/glm-response-normalization-hook.js.map +0 -1
- package/dist/providers/compat/glm/hooks/glm-response-validation-hook.d.ts +0 -25
- package/dist/providers/compat/glm/hooks/glm-response-validation-hook.js +0 -236
- package/dist/providers/compat/glm/hooks/glm-response-validation-hook.js.map +0 -1
- package/dist/providers/compat/glm/hooks/glm-tool-cleaning-hook.d.ts +0 -26
- package/dist/providers/compat/glm/hooks/glm-tool-cleaning-hook.js +0 -186
- package/dist/providers/compat/glm/hooks/glm-tool-cleaning-hook.js.map +0 -1
- package/dist/providers/compat/glm/index.d.ts +0 -24
- package/dist/providers/compat/glm/index.js +0 -29
- package/dist/providers/compat/glm/index.js.map +0 -1
- package/dist/providers/compat/glm/utils/tool-schema-helpers.d.ts +0 -3
- package/dist/providers/compat/glm/utils/tool-schema-helpers.js.map +0 -1
- package/dist/providers/compat/iflow/config/field-mappings.json +0 -92
- package/dist/providers/compat/iflow/config/shape-filters.json +0 -37
- package/dist/providers/compat/iflow/field-mapping/iflow-field-mapping-processor.d.ts +0 -34
- package/dist/providers/compat/iflow/field-mapping/iflow-field-mapping-processor.js +0 -386
- package/dist/providers/compat/iflow/field-mapping/iflow-field-mapping-processor.js.map +0 -1
- package/dist/providers/compat/iflow/functions/iflow-processor.d.ts +0 -53
- package/dist/providers/compat/iflow/functions/iflow-processor.js +0 -215
- package/dist/providers/compat/iflow/functions/iflow-processor.js.map +0 -1
- package/dist/providers/compat/iflow/hooks/base-hook.d.ts +0 -23
- package/dist/providers/compat/iflow/hooks/base-hook.js +0 -59
- package/dist/providers/compat/iflow/hooks/base-hook.js.map +0 -1
- package/dist/providers/compat/iflow/hooks/iflow-request-validation-hook.d.ts +0 -23
- package/dist/providers/compat/iflow/hooks/iflow-request-validation-hook.js +0 -279
- package/dist/providers/compat/iflow/hooks/iflow-request-validation-hook.js.map +0 -1
- package/dist/providers/compat/iflow/hooks/iflow-response-normalization-hook.d.ts +0 -20
- package/dist/providers/compat/iflow/hooks/iflow-response-normalization-hook.js +0 -180
- package/dist/providers/compat/iflow/hooks/iflow-response-normalization-hook.js.map +0 -1
- package/dist/providers/compat/iflow/hooks/iflow-response-validation-hook.d.ts +0 -23
- package/dist/providers/compat/iflow/hooks/iflow-response-validation-hook.js +0 -232
- package/dist/providers/compat/iflow/hooks/iflow-response-validation-hook.js.map +0 -1
- package/dist/providers/compat/iflow/hooks/iflow-tool-cleaning-hook.d.ts +0 -25
- package/dist/providers/compat/iflow/hooks/iflow-tool-cleaning-hook.js +0 -216
- package/dist/providers/compat/iflow/hooks/iflow-tool-cleaning-hook.js.map +0 -1
- package/dist/providers/compat/iflow/iflow-compatibility.d.ts +0 -24
- package/dist/providers/compat/iflow/iflow-compatibility.js +0 -94
- package/dist/providers/compat/iflow/iflow-compatibility.js.map +0 -1
- package/dist/providers/compat/index.d.ts +0 -59
- package/dist/providers/compat/index.js +0 -83
- package/dist/providers/compat/index.js.map +0 -1
- package/dist/providers/compat/lmstudio-compatibility.d.ts +0 -44
- package/dist/providers/compat/lmstudio-compatibility.js +0 -193
- package/dist/providers/compat/lmstudio-compatibility.js.map +0 -1
- package/dist/providers/compat/passthrough-compatibility.d.ts +0 -29
- package/dist/providers/compat/passthrough-compatibility.js +0 -83
- package/dist/providers/compat/passthrough-compatibility.js.map +0 -1
- package/dist/providers/compat/profiles/chat/glm/index.d.ts +0 -6
- package/dist/providers/compat/profiles/chat/glm/index.js +0 -6
- package/dist/providers/compat/profiles/chat/glm/index.js.map +0 -1
- package/dist/providers/compat/profiles/chat/iflow/index.d.ts +0 -6
- package/dist/providers/compat/profiles/chat/iflow/index.js +0 -6
- package/dist/providers/compat/profiles/chat/iflow/index.js.map +0 -1
- package/dist/providers/compat/profiles/chat/lmstudio/index.d.ts +0 -6
- package/dist/providers/compat/profiles/chat/lmstudio/index.js +0 -6
- package/dist/providers/compat/profiles/chat/lmstudio/index.js.map +0 -1
- package/dist/providers/compat/profiles/chat/qwen/index.d.ts +0 -6
- package/dist/providers/compat/profiles/chat/qwen/index.js +0 -6
- package/dist/providers/compat/profiles/chat/qwen/index.js.map +0 -1
- package/dist/providers/compat/profiles/compat/passthrough/index.d.ts +0 -6
- package/dist/providers/compat/profiles/compat/passthrough/index.js +0 -6
- package/dist/providers/compat/profiles/compat/passthrough/index.js.map +0 -1
- package/dist/providers/compat/profiles/responses/c4m/index.d.ts +0 -6
- package/dist/providers/compat/profiles/responses/c4m/index.js +0 -6
- package/dist/providers/compat/profiles/responses/c4m/index.js.map +0 -1
- package/dist/providers/compat/profiles/responses/default/index.d.ts +0 -6
- package/dist/providers/compat/profiles/responses/default/index.js +0 -6
- package/dist/providers/compat/profiles/responses/default/index.js.map +0 -1
- package/dist/providers/compat/profiles/responses/fai/index.d.ts +0 -6
- package/dist/providers/compat/profiles/responses/fai/index.js +0 -6
- package/dist/providers/compat/profiles/responses/fai/index.js.map +0 -1
- package/dist/providers/compat/profiles/responses/fc/index.d.ts +0 -6
- package/dist/providers/compat/profiles/responses/fc/index.js +0 -6
- package/dist/providers/compat/profiles/responses/fc/index.js.map +0 -1
- package/dist/providers/compat/qwen/index.d.ts +0 -4
- package/dist/providers/compat/qwen/index.js +0 -6
- package/dist/providers/compat/qwen/index.js.map +0 -1
- package/dist/providers/compat/qwen-compatibility.d.ts +0 -52
- package/dist/providers/compat/qwen-compatibility.js +0 -330
- package/dist/providers/compat/qwen-compatibility.js.map +0 -1
- package/dist/providers/compat/register-compat-module.d.ts +0 -8
- package/dist/providers/compat/register-compat-module.js +0 -53
- package/dist/providers/compat/register-compat-module.js.map +0 -1
- package/dist/providers/compat/responses/c4m-responses-compatibility.d.ts +0 -27
- package/dist/providers/compat/responses/c4m-responses-compatibility.js +0 -197
- package/dist/providers/compat/responses/c4m-responses-compatibility.js.map +0 -1
- package/dist/providers/compat/standard-compatibility-utils.d.ts +0 -1
- package/dist/providers/compat/standard-compatibility-utils.js +0 -77
- package/dist/providers/compat/standard-compatibility-utils.js.map +0 -1
- package/dist/providers/compat/standard-compatibility.d.ts +0 -31
- package/dist/providers/compat/standard-compatibility.js +0 -118
- package/dist/providers/compat/standard-compatibility.js.map +0 -1
- package/dist/providers/compat/utils/snapshot-writer.js +0 -62
- package/dist/providers/compat/utils/snapshot-writer.js.map +0 -1
- package/dist/tools/replay-request.d.ts +0 -0
- package/dist/tools/replay-request.js +0 -2
- package/dist/tools/replay-request.js.map +0 -1
- package/scripts/check-glm-compat.mjs +0 -47
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface OAuthTokenFileMatch {
|
|
2
|
+
filePath: string;
|
|
3
|
+
sequence: number;
|
|
4
|
+
alias: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 扫描本地 RouteCodex auth 目录中的 OAuth token 文件。
|
|
8
|
+
*
|
|
9
|
+
* 约定:
|
|
10
|
+
* - 目录: ~/.routecodex/auth
|
|
11
|
+
* - 文件名: <provider>-oauth-<sequence>[-<alias>].json
|
|
12
|
+
*
|
|
13
|
+
* 仅在 Node 环境下使用;如果环境不满足,返回空列表。
|
|
14
|
+
*/
|
|
15
|
+
export declare function scanOAuthTokenFiles(oauthProviderId: string, authDir?: string): OAuthTokenFileMatch[];
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
const TOKEN_FILE_PATTERN = /^([a-z0-9_-]+)-oauth-(\d+)(?:-(.+))?\.json$/i;
|
|
5
|
+
/**
|
|
6
|
+
* 扫描本地 RouteCodex auth 目录中的 OAuth token 文件。
|
|
7
|
+
*
|
|
8
|
+
* 约定:
|
|
9
|
+
* - 目录: ~/.routecodex/auth
|
|
10
|
+
* - 文件名: <provider>-oauth-<sequence>[-<alias>].json
|
|
11
|
+
*
|
|
12
|
+
* 仅在 Node 环境下使用;如果环境不满足,返回空列表。
|
|
13
|
+
*/
|
|
14
|
+
export function scanOAuthTokenFiles(oauthProviderId, authDir) {
|
|
15
|
+
if (!isNodeEnvironment()) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const provider = oauthProviderId.trim().toLowerCase();
|
|
19
|
+
if (!provider) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
const baseDir = authDir && authDir.trim()
|
|
23
|
+
? authDir.trim()
|
|
24
|
+
: path.join(os.homedir(), '.routecodex', 'auth');
|
|
25
|
+
let entries;
|
|
26
|
+
try {
|
|
27
|
+
entries = fs.readdirSync(baseDir);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const matches = [];
|
|
33
|
+
for (const entry of entries) {
|
|
34
|
+
if (!entry.endsWith('.json'))
|
|
35
|
+
continue;
|
|
36
|
+
const match = entry.match(TOKEN_FILE_PATTERN);
|
|
37
|
+
if (!match)
|
|
38
|
+
continue;
|
|
39
|
+
const [, providerPrefix, sequenceStr, alias] = match;
|
|
40
|
+
if (providerPrefix.toLowerCase() !== provider)
|
|
41
|
+
continue;
|
|
42
|
+
const sequence = parseInt(sequenceStr, 10);
|
|
43
|
+
if (!Number.isFinite(sequence) || sequence <= 0)
|
|
44
|
+
continue;
|
|
45
|
+
matches.push({
|
|
46
|
+
filePath: path.join(baseDir, entry),
|
|
47
|
+
sequence,
|
|
48
|
+
alias: alias || 'default'
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
matches.sort((a, b) => a.sequence - b.sequence);
|
|
52
|
+
return matches;
|
|
53
|
+
}
|
|
54
|
+
function isNodeEnvironment() {
|
|
55
|
+
return typeof process !== 'undefined' && !!process.release && process.release.name === 'node';
|
|
56
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StandardizedMessage, StandardizedRequest } from '../../conversion/hub/types/standardized.js';
|
|
2
|
+
export type ToolCategory = 'read' | 'write' | 'search' | 'other';
|
|
3
|
+
export type ToolClassification = {
|
|
4
|
+
category: ToolCategory;
|
|
5
|
+
name: string;
|
|
6
|
+
commandSnippet?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function detectVisionTool(request: StandardizedRequest): boolean;
|
|
9
|
+
export declare function detectCodingTool(request: StandardizedRequest): boolean;
|
|
10
|
+
export declare function detectWebTool(request: StandardizedRequest): boolean;
|
|
11
|
+
export declare function extractMeaningfulDeclaredToolNames(tools: StandardizedRequest['tools'] | undefined): string[];
|
|
12
|
+
export declare function detectLastAssistantToolCategory(messages: StandardizedMessage[]): ToolClassification | undefined;
|
|
13
|
+
export declare function canonicalizeToolName(rawName: string): string;
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
const WEB_TOOL_KEYWORDS = ['websearch', 'web_search', 'web-search', 'webfetch', 'web_fetch', 'web_request', 'search_web', 'internet_search'];
|
|
2
|
+
const READ_TOOL_EXACT = new Set([
|
|
3
|
+
'read_file',
|
|
4
|
+
'read_text',
|
|
5
|
+
'view_file',
|
|
6
|
+
'view_code',
|
|
7
|
+
'view_document',
|
|
8
|
+
'open_file',
|
|
9
|
+
'get_file',
|
|
10
|
+
'download_file',
|
|
11
|
+
'describe_current_request',
|
|
12
|
+
'list_dir',
|
|
13
|
+
'list_directory',
|
|
14
|
+
'list_files',
|
|
15
|
+
'list_documents',
|
|
16
|
+
'list_resources',
|
|
17
|
+
'search_files',
|
|
18
|
+
'find_files'
|
|
19
|
+
]);
|
|
20
|
+
const WRITE_TOOL_EXACT = new Set([
|
|
21
|
+
'apply_patch',
|
|
22
|
+
'write_file',
|
|
23
|
+
'create_file',
|
|
24
|
+
'modify_file',
|
|
25
|
+
'edit_file',
|
|
26
|
+
'update_file',
|
|
27
|
+
'save_file',
|
|
28
|
+
'append_file',
|
|
29
|
+
'replace_file',
|
|
30
|
+
'delete_file',
|
|
31
|
+
'remove_file',
|
|
32
|
+
'rename_file',
|
|
33
|
+
'move_file',
|
|
34
|
+
'copy_file',
|
|
35
|
+
'mkdir',
|
|
36
|
+
'rmdir'
|
|
37
|
+
]);
|
|
38
|
+
const SEARCH_TOOL_EXACT = new Set(['websearch', 'web_search', 'search_web', 'internet_search', 'webfetch', 'web_fetch']);
|
|
39
|
+
const READ_TOOL_KEYWORDS = ['read', 'list', 'view', 'download', 'open', 'show', 'fetch', 'inspect'];
|
|
40
|
+
const WRITE_TOOL_KEYWORDS = ['write', 'patch', 'modify', 'edit', 'create', 'update', 'append', 'replace', 'delete', 'remove'];
|
|
41
|
+
const SEARCH_TOOL_KEYWORDS = ['search', 'websearch', 'web_fetch', 'webfetch', 'web-request', 'web_request', 'internet'];
|
|
42
|
+
const SHELL_TOOL_NAMES = new Set(['shell_command', 'shell', 'bash']);
|
|
43
|
+
const DECLARED_TOOL_IGNORE = new Set(['exec_command']);
|
|
44
|
+
const SHELL_HEREDOC_PATTERN = /<<\s*['"]?[a-z0-9_-]+/i;
|
|
45
|
+
const SHELL_WRITE_PATTERNS = [
|
|
46
|
+
'apply_patch',
|
|
47
|
+
'sed -i',
|
|
48
|
+
'perl -pi',
|
|
49
|
+
'tee ',
|
|
50
|
+
'cat <<',
|
|
51
|
+
'cat >',
|
|
52
|
+
'printf >',
|
|
53
|
+
'touch ',
|
|
54
|
+
'truncate',
|
|
55
|
+
'mkdir',
|
|
56
|
+
'mktemp',
|
|
57
|
+
'rmdir',
|
|
58
|
+
'rm ',
|
|
59
|
+
'rm-',
|
|
60
|
+
'unlink',
|
|
61
|
+
'mv ',
|
|
62
|
+
'cp ',
|
|
63
|
+
'ln -',
|
|
64
|
+
'chmod',
|
|
65
|
+
'chown',
|
|
66
|
+
'chgrp',
|
|
67
|
+
'tar ',
|
|
68
|
+
'git add',
|
|
69
|
+
'git commit',
|
|
70
|
+
'git apply',
|
|
71
|
+
'git am',
|
|
72
|
+
'git rebase',
|
|
73
|
+
'git checkout',
|
|
74
|
+
'git merge',
|
|
75
|
+
'patch <<',
|
|
76
|
+
'npm install',
|
|
77
|
+
'pnpm install',
|
|
78
|
+
'yarn add',
|
|
79
|
+
'yarn install',
|
|
80
|
+
'pip install',
|
|
81
|
+
'pip3 install',
|
|
82
|
+
'brew install',
|
|
83
|
+
'cargo add',
|
|
84
|
+
'cargo install',
|
|
85
|
+
'go install',
|
|
86
|
+
'make install'
|
|
87
|
+
];
|
|
88
|
+
const SHELL_SEARCH_PATTERNS = [
|
|
89
|
+
'rg ',
|
|
90
|
+
'rg-',
|
|
91
|
+
'grep ',
|
|
92
|
+
'grep-',
|
|
93
|
+
'ripgrep',
|
|
94
|
+
'find ',
|
|
95
|
+
'fd ',
|
|
96
|
+
'locate ',
|
|
97
|
+
'search ',
|
|
98
|
+
'ack ',
|
|
99
|
+
'ag ',
|
|
100
|
+
'where ',
|
|
101
|
+
'which ',
|
|
102
|
+
'codesearch'
|
|
103
|
+
];
|
|
104
|
+
const SHELL_READ_PATTERNS = [
|
|
105
|
+
'ls',
|
|
106
|
+
'dir ',
|
|
107
|
+
'pwd',
|
|
108
|
+
'cat ',
|
|
109
|
+
'type ',
|
|
110
|
+
'head ',
|
|
111
|
+
'tail ',
|
|
112
|
+
'stat',
|
|
113
|
+
'tree',
|
|
114
|
+
'wc ',
|
|
115
|
+
'du ',
|
|
116
|
+
'printf "',
|
|
117
|
+
'python - <<',
|
|
118
|
+
'python -c',
|
|
119
|
+
'node - <<',
|
|
120
|
+
'node -e'
|
|
121
|
+
];
|
|
122
|
+
export function detectVisionTool(request) {
|
|
123
|
+
if (!Array.isArray(request.tools)) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
return request.tools.some((tool) => {
|
|
127
|
+
const functionName = extractToolName(tool);
|
|
128
|
+
const description = extractToolDescription(tool);
|
|
129
|
+
return /vision|image|picture|photo/i.test(functionName) || /vision|image|picture|photo/i.test(description || '');
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
export function detectCodingTool(request) {
|
|
133
|
+
if (!Array.isArray(request.tools)) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return request.tools.some((tool) => {
|
|
137
|
+
const functionName = extractToolName(tool).toLowerCase();
|
|
138
|
+
const description = (extractToolDescription(tool) || '').toLowerCase();
|
|
139
|
+
if (!functionName && !description) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
if (WRITE_TOOL_EXACT.has(functionName)) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
return WRITE_TOOL_KEYWORDS.some((keyword) => functionName.includes(keyword.toLowerCase()) || description.includes(keyword.toLowerCase()));
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
export function detectWebTool(request) {
|
|
149
|
+
if (!Array.isArray(request.tools)) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
return request.tools.some((tool) => {
|
|
153
|
+
const functionName = extractToolName(tool);
|
|
154
|
+
const description = extractToolDescription(tool);
|
|
155
|
+
const normalizedName = functionName.toLowerCase();
|
|
156
|
+
const normalizedDesc = (description || '').toLowerCase();
|
|
157
|
+
return (WEB_TOOL_KEYWORDS.some((keyword) => normalizedName.includes(keyword)) ||
|
|
158
|
+
WEB_TOOL_KEYWORDS.some((keyword) => normalizedDesc.includes(keyword)));
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
export function extractMeaningfulDeclaredToolNames(tools) {
|
|
162
|
+
if (!Array.isArray(tools) || tools.length === 0) {
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
165
|
+
const names = [];
|
|
166
|
+
for (const tool of tools) {
|
|
167
|
+
const rawName = extractToolName(tool);
|
|
168
|
+
if (!rawName) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const canonical = canonicalizeToolName(rawName).toLowerCase();
|
|
172
|
+
if (!canonical || DECLARED_TOOL_IGNORE.has(canonical)) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
names.push(rawName);
|
|
176
|
+
}
|
|
177
|
+
return names;
|
|
178
|
+
}
|
|
179
|
+
export function detectLastAssistantToolCategory(messages) {
|
|
180
|
+
for (let idx = messages.length - 1; idx >= 0; idx -= 1) {
|
|
181
|
+
const msg = messages[idx];
|
|
182
|
+
if (!msg || !Array.isArray(msg.tool_calls) || msg.tool_calls.length === 0) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
let fallback;
|
|
186
|
+
for (const call of msg.tool_calls) {
|
|
187
|
+
const classification = classifyToolCall(call);
|
|
188
|
+
if (!classification) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (!fallback) {
|
|
192
|
+
fallback = classification;
|
|
193
|
+
}
|
|
194
|
+
if (classification.category !== 'other') {
|
|
195
|
+
return classification;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (fallback) {
|
|
199
|
+
return fallback;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
function classifyToolCall(call) {
|
|
205
|
+
if (!call || typeof call !== 'object') {
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
const functionName = typeof call?.function?.name === 'string' && call.function.name.trim()
|
|
209
|
+
? canonicalizeToolName(call.function.name)
|
|
210
|
+
: '';
|
|
211
|
+
if (!functionName) {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
const argsObject = parseToolArguments(call?.function?.arguments);
|
|
215
|
+
const commandText = extractCommandText(argsObject);
|
|
216
|
+
const nameCategory = categorizeToolName(functionName);
|
|
217
|
+
const snippet = buildCommandSnippet(commandText);
|
|
218
|
+
if (nameCategory === 'write' || nameCategory === 'read' || nameCategory === 'search') {
|
|
219
|
+
return { category: nameCategory, name: functionName, commandSnippet: snippet };
|
|
220
|
+
}
|
|
221
|
+
if (SHELL_TOOL_NAMES.has(functionName)) {
|
|
222
|
+
const shellCategory = classifyShellCommand(commandText);
|
|
223
|
+
return { category: shellCategory, name: functionName, commandSnippet: snippet };
|
|
224
|
+
}
|
|
225
|
+
if (commandText) {
|
|
226
|
+
const derivedCategory = classifyShellCommand(commandText);
|
|
227
|
+
if (derivedCategory !== 'other') {
|
|
228
|
+
return { category: derivedCategory, name: functionName, commandSnippet: snippet };
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return { category: 'other', name: functionName, commandSnippet: snippet };
|
|
232
|
+
}
|
|
233
|
+
function extractToolName(tool) {
|
|
234
|
+
if (!tool || typeof tool !== 'object') {
|
|
235
|
+
return '';
|
|
236
|
+
}
|
|
237
|
+
const candidate = tool;
|
|
238
|
+
const fromFunction = candidate.function;
|
|
239
|
+
if (fromFunction && typeof fromFunction.name === 'string' && fromFunction.name.trim()) {
|
|
240
|
+
return fromFunction.name;
|
|
241
|
+
}
|
|
242
|
+
if (typeof candidate.name === 'string' && candidate.name.trim()) {
|
|
243
|
+
return candidate.name;
|
|
244
|
+
}
|
|
245
|
+
return '';
|
|
246
|
+
}
|
|
247
|
+
function extractToolDescription(tool) {
|
|
248
|
+
if (!tool || typeof tool !== 'object') {
|
|
249
|
+
return '';
|
|
250
|
+
}
|
|
251
|
+
const candidate = tool;
|
|
252
|
+
const fromFunction = candidate.function;
|
|
253
|
+
if (fromFunction && typeof fromFunction.description === 'string' && fromFunction.description.trim()) {
|
|
254
|
+
return fromFunction.description;
|
|
255
|
+
}
|
|
256
|
+
if (typeof candidate.description === 'string' && candidate.description.trim()) {
|
|
257
|
+
return candidate.description;
|
|
258
|
+
}
|
|
259
|
+
return '';
|
|
260
|
+
}
|
|
261
|
+
export function canonicalizeToolName(rawName) {
|
|
262
|
+
const trimmed = rawName.trim();
|
|
263
|
+
const markerIndex = trimmed.indexOf('arg_');
|
|
264
|
+
if (markerIndex > 0) {
|
|
265
|
+
return trimmed.slice(0, markerIndex);
|
|
266
|
+
}
|
|
267
|
+
return trimmed;
|
|
268
|
+
}
|
|
269
|
+
function parseToolArguments(rawArguments) {
|
|
270
|
+
if (!rawArguments) {
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
273
|
+
if (typeof rawArguments === 'string') {
|
|
274
|
+
try {
|
|
275
|
+
return JSON.parse(rawArguments);
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
return rawArguments;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (typeof rawArguments === 'object') {
|
|
282
|
+
return rawArguments;
|
|
283
|
+
}
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
function extractCommandText(args) {
|
|
287
|
+
if (!args) {
|
|
288
|
+
return '';
|
|
289
|
+
}
|
|
290
|
+
if (typeof args === 'string') {
|
|
291
|
+
return args;
|
|
292
|
+
}
|
|
293
|
+
if (Array.isArray(args)) {
|
|
294
|
+
return args.map((item) => (typeof item === 'string' ? item : '')).filter(Boolean).join(' ');
|
|
295
|
+
}
|
|
296
|
+
if (typeof args === 'object') {
|
|
297
|
+
const record = args;
|
|
298
|
+
const stringKeys = ['command', 'cmd', 'input', 'code', 'script', 'text', 'prompt'];
|
|
299
|
+
for (const key of stringKeys) {
|
|
300
|
+
const value = record[key];
|
|
301
|
+
if (typeof value === 'string' && value.trim()) {
|
|
302
|
+
return value;
|
|
303
|
+
}
|
|
304
|
+
if (Array.isArray(value)) {
|
|
305
|
+
const joined = value.map((item) => (typeof item === 'string' ? item : '')).filter(Boolean).join(' ');
|
|
306
|
+
if (joined.trim()) {
|
|
307
|
+
return joined;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
const nestedArgs = record.args;
|
|
312
|
+
if (typeof nestedArgs === 'string' && nestedArgs.trim()) {
|
|
313
|
+
return nestedArgs;
|
|
314
|
+
}
|
|
315
|
+
if (Array.isArray(nestedArgs)) {
|
|
316
|
+
const joined = nestedArgs.map((item) => (typeof item === 'string' ? item : '')).filter(Boolean).join(' ');
|
|
317
|
+
if (joined.trim()) {
|
|
318
|
+
return joined;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return '';
|
|
323
|
+
}
|
|
324
|
+
function buildCommandSnippet(commandText) {
|
|
325
|
+
if (!commandText) {
|
|
326
|
+
return undefined;
|
|
327
|
+
}
|
|
328
|
+
const collapsed = commandText.replace(/\s+/g, ' ').trim();
|
|
329
|
+
if (!collapsed) {
|
|
330
|
+
return undefined;
|
|
331
|
+
}
|
|
332
|
+
const limit = 80;
|
|
333
|
+
if (collapsed.length <= limit) {
|
|
334
|
+
return collapsed;
|
|
335
|
+
}
|
|
336
|
+
return `${collapsed.slice(0, limit)}…`;
|
|
337
|
+
}
|
|
338
|
+
function categorizeToolName(name) {
|
|
339
|
+
const normalized = name.toLowerCase();
|
|
340
|
+
if (SEARCH_TOOL_EXACT.has(normalized) ||
|
|
341
|
+
SEARCH_TOOL_KEYWORDS.some((keyword) => normalized.includes(keyword.toLowerCase()))) {
|
|
342
|
+
return 'search';
|
|
343
|
+
}
|
|
344
|
+
if (READ_TOOL_EXACT.has(normalized) ||
|
|
345
|
+
READ_TOOL_KEYWORDS.some((keyword) => normalized.includes(keyword.toLowerCase()))) {
|
|
346
|
+
return 'read';
|
|
347
|
+
}
|
|
348
|
+
if (WRITE_TOOL_EXACT.has(normalized) ||
|
|
349
|
+
WRITE_TOOL_KEYWORDS.some((keyword) => normalized.includes(keyword.toLowerCase()))) {
|
|
350
|
+
return 'write';
|
|
351
|
+
}
|
|
352
|
+
return 'other';
|
|
353
|
+
}
|
|
354
|
+
function classifyShellCommand(command) {
|
|
355
|
+
if (!command) {
|
|
356
|
+
return 'other';
|
|
357
|
+
}
|
|
358
|
+
if (SHELL_HEREDOC_PATTERN.test(command)) {
|
|
359
|
+
return 'write';
|
|
360
|
+
}
|
|
361
|
+
const segments = splitCommandSegments(command).map(stripShellWrapper);
|
|
362
|
+
if (segments.some((segment) => matchesAnyPattern(segment, SHELL_WRITE_PATTERNS))) {
|
|
363
|
+
return 'write';
|
|
364
|
+
}
|
|
365
|
+
if (segments.some((segment) => matchesAnyPattern(segment, SHELL_SEARCH_PATTERNS))) {
|
|
366
|
+
return 'search';
|
|
367
|
+
}
|
|
368
|
+
if (segments.some((segment) => matchesAnyPattern(segment, SHELL_READ_PATTERNS))) {
|
|
369
|
+
return 'read';
|
|
370
|
+
}
|
|
371
|
+
const stripped = stripShellWrapper(command);
|
|
372
|
+
if (matchesAnyPattern(stripped, SHELL_WRITE_PATTERNS)) {
|
|
373
|
+
return 'write';
|
|
374
|
+
}
|
|
375
|
+
if (matchesAnyPattern(stripped, SHELL_SEARCH_PATTERNS)) {
|
|
376
|
+
return 'search';
|
|
377
|
+
}
|
|
378
|
+
if (matchesAnyPattern(stripped, SHELL_READ_PATTERNS)) {
|
|
379
|
+
return 'read';
|
|
380
|
+
}
|
|
381
|
+
return 'other';
|
|
382
|
+
}
|
|
383
|
+
function splitCommandSegments(command) {
|
|
384
|
+
return command
|
|
385
|
+
.split(/(?:\r?\n|&&|\|\||;)/)
|
|
386
|
+
.map((segment) => segment.trim())
|
|
387
|
+
.filter(Boolean);
|
|
388
|
+
}
|
|
389
|
+
function stripShellWrapper(command) {
|
|
390
|
+
if (!command) {
|
|
391
|
+
return '';
|
|
392
|
+
}
|
|
393
|
+
const wrappers = ['bash -lc', 'sh -c', 'zsh -c'];
|
|
394
|
+
for (const wrapper of wrappers) {
|
|
395
|
+
if (command.startsWith(wrapper)) {
|
|
396
|
+
return command.slice(wrapper.length).trim();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return command.trim();
|
|
400
|
+
}
|
|
401
|
+
function matchesAnyPattern(command, patterns) {
|
|
402
|
+
return patterns.some((pattern) => command.includes(pattern));
|
|
403
|
+
}
|
|
@@ -2,9 +2,24 @@
|
|
|
2
2
|
* Virtual Router 类型定义
|
|
3
3
|
*/
|
|
4
4
|
import type { StandardizedRequest } from '../../conversion/hub/types/standardized.js';
|
|
5
|
+
export declare const DEFAULT_MODEL_CONTEXT_TOKENS = 200000;
|
|
5
6
|
export declare const DEFAULT_ROUTE = "default";
|
|
6
7
|
export declare const ROUTE_PRIORITY: string[];
|
|
7
|
-
export
|
|
8
|
+
export interface RoutePoolTier {
|
|
9
|
+
id: string;
|
|
10
|
+
targets: string[];
|
|
11
|
+
priority: number;
|
|
12
|
+
backup?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Optional force flag for this route pool.
|
|
15
|
+
* Currently interpreted for:
|
|
16
|
+
* - routing.vision: force dedicated vision backend handling.
|
|
17
|
+
* - routing.web_search / routing.search: force server-side web_search flow.
|
|
18
|
+
*/
|
|
19
|
+
force?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export type RoutingPools = Record<string, RoutePoolTier[]>;
|
|
22
|
+
export type StreamingPreference = 'auto' | 'always' | 'never';
|
|
8
23
|
export interface ProviderAuthConfig {
|
|
9
24
|
type: 'apiKey' | 'oauth';
|
|
10
25
|
secretRef?: string;
|
|
@@ -32,6 +47,15 @@ export interface ProviderProfile {
|
|
|
32
47
|
modelId?: string;
|
|
33
48
|
processMode?: 'chat' | 'passthrough';
|
|
34
49
|
responsesConfig?: ResponsesProviderConfig;
|
|
50
|
+
streaming?: StreamingPreference;
|
|
51
|
+
maxContextTokens?: number;
|
|
52
|
+
/**
|
|
53
|
+
* When true, this provider must be skipped for any request that
|
|
54
|
+
* requires server-side tool orchestration (e.g. web_search).
|
|
55
|
+
* Normal chat routing (without servertool injection) may still
|
|
56
|
+
* use this provider as usual.
|
|
57
|
+
*/
|
|
58
|
+
serverToolsDisabled?: boolean;
|
|
35
59
|
}
|
|
36
60
|
export interface ProviderRuntimeProfile {
|
|
37
61
|
runtimeKey: string;
|
|
@@ -46,6 +70,17 @@ export interface ProviderRuntimeProfile {
|
|
|
46
70
|
modelId?: string;
|
|
47
71
|
processMode?: 'chat' | 'passthrough';
|
|
48
72
|
responsesConfig?: ResponsesProviderConfig;
|
|
73
|
+
streaming?: StreamingPreference;
|
|
74
|
+
modelStreaming?: Record<string, StreamingPreference>;
|
|
75
|
+
modelContextTokens?: Record<string, number>;
|
|
76
|
+
defaultContextTokens?: number;
|
|
77
|
+
maxContextTokens?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Provider-level flag propagated from virtualrouter.providers[*].
|
|
80
|
+
* When true, VirtualRouterEngine will skip this runtime for any
|
|
81
|
+
* request that declares serverToolRequired=true in routing metadata.
|
|
82
|
+
*/
|
|
83
|
+
serverToolsDisabled?: boolean;
|
|
49
84
|
}
|
|
50
85
|
export interface VirtualRouterClassifierConfig {
|
|
51
86
|
longContextThresholdTokens?: number;
|
|
@@ -63,12 +98,39 @@ export interface ProviderHealthConfig {
|
|
|
63
98
|
cooldownMs: number;
|
|
64
99
|
fatalCooldownMs?: number;
|
|
65
100
|
}
|
|
101
|
+
export interface VirtualRouterWebSearchEngineConfig {
|
|
102
|
+
id: string;
|
|
103
|
+
providerKey: string;
|
|
104
|
+
description?: string;
|
|
105
|
+
default?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* When true, this engine will never be used by server-side tools
|
|
108
|
+
* (e.g. web_search). It will also be omitted from injected tool
|
|
109
|
+
* schemas so main models cannot select it for servertool flows.
|
|
110
|
+
*/
|
|
111
|
+
serverToolsDisabled?: boolean;
|
|
112
|
+
}
|
|
113
|
+
export interface VirtualRouterWebSearchConfig {
|
|
114
|
+
engines: VirtualRouterWebSearchEngineConfig[];
|
|
115
|
+
injectPolicy?: 'always' | 'selective';
|
|
116
|
+
/**
|
|
117
|
+
* When true, always prefer server-side web_search orchestration
|
|
118
|
+
* over upstream builtin behaviours (e.g. OpenAI Responses builtin web_search).
|
|
119
|
+
*/
|
|
120
|
+
force?: boolean;
|
|
121
|
+
}
|
|
66
122
|
export interface VirtualRouterConfig {
|
|
67
123
|
routing: RoutingPools;
|
|
68
124
|
providers: Record<string, ProviderProfile>;
|
|
69
125
|
classifier: VirtualRouterClassifierConfig;
|
|
70
126
|
loadBalancing?: LoadBalancingPolicy;
|
|
71
127
|
health?: ProviderHealthConfig;
|
|
128
|
+
contextRouting?: VirtualRouterContextRoutingConfig;
|
|
129
|
+
webSearch?: VirtualRouterWebSearchConfig;
|
|
130
|
+
}
|
|
131
|
+
export interface VirtualRouterContextRoutingConfig {
|
|
132
|
+
warnRatio: number;
|
|
133
|
+
hardLimit?: boolean;
|
|
72
134
|
}
|
|
73
135
|
export type VirtualRouterProviderDefinition = Record<string, unknown>;
|
|
74
136
|
export interface VirtualRouterBootstrapInput extends Record<string, unknown> {
|
|
@@ -78,6 +140,8 @@ export interface VirtualRouterBootstrapInput extends Record<string, unknown> {
|
|
|
78
140
|
classifier?: VirtualRouterClassifierConfig;
|
|
79
141
|
loadBalancing?: LoadBalancingPolicy;
|
|
80
142
|
health?: ProviderHealthConfig;
|
|
143
|
+
contextRouting?: VirtualRouterContextRoutingConfig;
|
|
144
|
+
webSearch?: VirtualRouterWebSearchConfig | Record<string, unknown>;
|
|
81
145
|
}
|
|
82
146
|
export type ProviderRuntimeMap = Record<string, ProviderRuntimeProfile>;
|
|
83
147
|
export interface VirtualRouterBootstrapResult {
|
|
@@ -96,6 +160,13 @@ export interface RouterMetadataInput {
|
|
|
96
160
|
providerProtocol?: string;
|
|
97
161
|
stage?: 'inbound' | 'outbound' | 'response';
|
|
98
162
|
routeHint?: string;
|
|
163
|
+
/**
|
|
164
|
+
* Indicates that current routing decision is for a request which
|
|
165
|
+
* expects server-side tools orchestration (e.g. web_search).
|
|
166
|
+
* Virtual Router should skip providers that opt out via
|
|
167
|
+
* serverToolsDisabled when this flag is true.
|
|
168
|
+
*/
|
|
169
|
+
serverToolRequired?: boolean;
|
|
99
170
|
responsesResume?: {
|
|
100
171
|
previousRequestId?: string;
|
|
101
172
|
restoredFromResponseId?: string;
|
|
@@ -117,7 +188,9 @@ export interface RoutingFeatures {
|
|
|
117
188
|
hasThinkingKeyword: boolean;
|
|
118
189
|
estimatedTokens: number;
|
|
119
190
|
lastAssistantToolCategory?: 'read' | 'write' | 'search' | 'other';
|
|
120
|
-
|
|
191
|
+
lastAssistantToolSnippet?: string;
|
|
192
|
+
lastAssistantToolLabel?: string;
|
|
193
|
+
latestMessageFromUser?: boolean;
|
|
121
194
|
metadata: RouterMetadataInput;
|
|
122
195
|
}
|
|
123
196
|
export interface ClassificationResult {
|
|
@@ -134,6 +207,7 @@ export interface RoutingDecision {
|
|
|
134
207
|
reasoning: string;
|
|
135
208
|
fallback: boolean;
|
|
136
209
|
pool: string[];
|
|
210
|
+
poolId?: string;
|
|
137
211
|
}
|
|
138
212
|
export interface TargetMetadata {
|
|
139
213
|
providerKey: string;
|
|
@@ -144,6 +218,15 @@ export interface TargetMetadata {
|
|
|
144
218
|
modelId: string;
|
|
145
219
|
processMode?: 'chat' | 'passthrough';
|
|
146
220
|
responsesConfig?: ResponsesProviderConfig;
|
|
221
|
+
streaming?: StreamingPreference;
|
|
222
|
+
maxContextTokens?: number;
|
|
223
|
+
/**
|
|
224
|
+
* Route-level flags propagated from the virtual router.
|
|
225
|
+
* These are derived from routing pools and webSearch config and
|
|
226
|
+
* are used by hub pipeline/process layers (web_search / vision).
|
|
227
|
+
*/
|
|
228
|
+
forceWebSearch?: boolean;
|
|
229
|
+
forceVision?: boolean;
|
|
147
230
|
}
|
|
148
231
|
export interface ResponsesProviderConfig {
|
|
149
232
|
toolCallIdStyle?: 'fc' | 'preserve';
|
|
@@ -165,6 +248,7 @@ export interface RoutingDiagnostics {
|
|
|
165
248
|
reasoning: string;
|
|
166
249
|
fallback: boolean;
|
|
167
250
|
pool: string[];
|
|
251
|
+
poolId?: string;
|
|
168
252
|
confidence: number;
|
|
169
253
|
}
|
|
170
254
|
export interface RoutingStatusSnapshot {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Virtual Router 类型定义
|
|
3
3
|
*/
|
|
4
|
+
export const DEFAULT_MODEL_CONTEXT_TOKENS = 200_000;
|
|
4
5
|
export const DEFAULT_ROUTE = 'default';
|
|
5
6
|
export const ROUTE_PRIORITY = [
|
|
6
7
|
'vision',
|
|
7
8
|
'longcontext',
|
|
8
|
-
'
|
|
9
|
+
'web_search',
|
|
10
|
+
'search',
|
|
9
11
|
'coding',
|
|
10
12
|
'thinking',
|
|
11
13
|
'tools',
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AdapterContext } from '../conversion/hub/types/chat-envelope.js';
|
|
2
|
+
import type { JsonObject } from '../conversion/hub/types/json.js';
|
|
3
|
+
import type { ProviderInvoker } from './types.js';
|
|
4
|
+
export interface ServerToolOrchestrationOptions {
|
|
5
|
+
chat: JsonObject;
|
|
6
|
+
adapterContext: AdapterContext;
|
|
7
|
+
requestId: string;
|
|
8
|
+
entryEndpoint: string;
|
|
9
|
+
providerProtocol: string;
|
|
10
|
+
reenterPipeline?: (options: {
|
|
11
|
+
entryEndpoint: string;
|
|
12
|
+
requestId: string;
|
|
13
|
+
body: JsonObject;
|
|
14
|
+
metadata?: JsonObject;
|
|
15
|
+
}) => Promise<{
|
|
16
|
+
body?: JsonObject;
|
|
17
|
+
__sse_responses?: unknown;
|
|
18
|
+
format?: string;
|
|
19
|
+
}>;
|
|
20
|
+
providerInvoker?: ProviderInvoker;
|
|
21
|
+
}
|
|
22
|
+
export interface ServerToolOrchestrationResult {
|
|
23
|
+
chat: JsonObject;
|
|
24
|
+
executed: boolean;
|
|
25
|
+
flowId?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function runServerToolOrchestration(options: ServerToolOrchestrationOptions): Promise<ServerToolOrchestrationResult>;
|