@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
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
type
|
|
1
|
+
import type { AdapterContext } from '../../hub/types/chat-envelope.js';
|
|
2
|
+
import type { JsonObject } from '../../hub/types/json.js';
|
|
3
|
+
type RequestMessagesRule = {
|
|
4
|
+
when?: {
|
|
5
|
+
role?: 'system' | 'user' | 'assistant' | 'tool';
|
|
6
|
+
hasToolCalls?: boolean;
|
|
7
|
+
};
|
|
8
|
+
action: 'drop' | 'keep' | 'set';
|
|
9
|
+
set?: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
export interface FilterConfig {
|
|
4
12
|
request: {
|
|
5
13
|
allowTopLevel: string[];
|
|
6
14
|
messages: {
|
|
@@ -16,14 +24,7 @@ type FilterConfig = {
|
|
|
16
24
|
assistantToolCalls?: {
|
|
17
25
|
functionArgumentsType?: 'object' | 'string';
|
|
18
26
|
};
|
|
19
|
-
messagesRules?:
|
|
20
|
-
when?: {
|
|
21
|
-
role?: 'system' | 'user' | 'assistant' | 'tool';
|
|
22
|
-
hasToolCalls?: boolean;
|
|
23
|
-
};
|
|
24
|
-
action: 'drop' | 'keep' | 'set';
|
|
25
|
-
set?: Record<string, unknown>;
|
|
26
|
-
}>;
|
|
27
|
+
messagesRules?: RequestMessagesRule[];
|
|
27
28
|
};
|
|
28
29
|
response: {
|
|
29
30
|
allowTopLevel: string[];
|
|
@@ -46,22 +47,16 @@ type FilterConfig = {
|
|
|
46
47
|
allow: string[];
|
|
47
48
|
};
|
|
48
49
|
};
|
|
49
|
-
}
|
|
50
|
+
}
|
|
50
51
|
export declare class UniversalShapeFilter {
|
|
51
|
-
private cfg;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
configPath?: string;
|
|
56
|
-
config?: FilterConfig;
|
|
57
|
-
});
|
|
58
|
-
initialize(): Promise<void>;
|
|
52
|
+
private readonly cfg;
|
|
53
|
+
constructor(config: FilterConfig);
|
|
54
|
+
applyRequestFilter(payload: JsonObject): JsonObject;
|
|
55
|
+
applyResponseFilter(payload: JsonObject, ctx?: AdapterContext): JsonObject;
|
|
59
56
|
private shallowPick;
|
|
60
57
|
private toObjectArgs;
|
|
61
58
|
private toStringArgs;
|
|
62
59
|
private normalizeToolContent;
|
|
63
|
-
applyRequestFilter(payload: UnknownObject): Promise<UnknownObject>;
|
|
64
|
-
applyResponseFilter(payload: UnknownObject, _ctx?: CompatibilityContext): Promise<UnknownObject>;
|
|
65
60
|
private normalizeRequestMessages;
|
|
66
61
|
private normalizeSingleMessage;
|
|
67
62
|
private normalizeAssistantToolCalls;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as fs from 'fs/promises';
|
|
2
|
-
import * as path from 'path';
|
|
3
1
|
const DEFAULT_TOOL_OUTPUT = 'Command succeeded (no output).';
|
|
4
2
|
function isRecord(value) {
|
|
5
3
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -14,55 +12,43 @@ function hasArrayItems(value) {
|
|
|
14
12
|
return Array.isArray(value) && value.length > 0;
|
|
15
13
|
}
|
|
16
14
|
export class UniversalShapeFilter {
|
|
17
|
-
cfg
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
constructor(options = {}) {
|
|
21
|
-
this.configPath = options.configPath;
|
|
22
|
-
this.inlineConfig = options.config;
|
|
15
|
+
cfg;
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.cfg = config;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const text = await fs.readFile(file, 'utf-8');
|
|
33
|
-
this.cfg = JSON.parse(text);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
catch { /* fallthrough to default */ }
|
|
37
|
-
}
|
|
38
|
-
this.cfg = {
|
|
39
|
-
request: {
|
|
40
|
-
allowTopLevel: ['model', 'messages', 'stream', 'thinking', 'do_sample', 'temperature', 'top_p', 'max_tokens', 'tool_stream', 'tools', 'tool_choice', 'stop', 'response_format', 'request_id', 'user_id'],
|
|
41
|
-
messages: { allowedRoles: ['system', 'user', 'assistant', 'tool'], assistantWithToolCallsContentNull: true, toolContentStringify: true },
|
|
42
|
-
tools: { normalize: true, forceToolChoiceAuto: true },
|
|
43
|
-
assistantToolCalls: { functionArgumentsType: 'string' } // 修复:默认使用string格式而不是object
|
|
44
|
-
},
|
|
45
|
-
response: {
|
|
46
|
-
// 保留 Responses 协议关键字段,避免在合成/转换前被丢弃
|
|
47
|
-
allowTopLevel: [
|
|
48
|
-
'id', 'request_id', 'created', 'model',
|
|
49
|
-
'choices', 'usage', 'video_result', 'web_search', 'content_filter',
|
|
50
|
-
// Responses 专有/常见:
|
|
51
|
-
'required_action', 'output', 'output_text', 'status'
|
|
52
|
-
],
|
|
53
|
-
choices: {
|
|
54
|
-
required: true,
|
|
55
|
-
message: {
|
|
56
|
-
allow: ['role', 'content', 'reasoning_content', 'audio', 'tool_calls'],
|
|
57
|
-
roleDefault: 'assistant',
|
|
58
|
-
contentNullWhenToolCalls: true,
|
|
59
|
-
tool_calls: { function: { nameRequired: true, argumentsType: 'string' } }
|
|
60
|
-
},
|
|
61
|
-
finish_reason: ['stop', 'tool_calls', 'length', 'sensitive', 'network_error']
|
|
62
|
-
},
|
|
63
|
-
usage: { allow: ['prompt_tokens', 'completion_tokens', 'prompt_tokens_details', 'total_tokens'] }
|
|
19
|
+
applyRequestFilter(payload) {
|
|
20
|
+
const cfg = this.cfg;
|
|
21
|
+
const allow = new Set(cfg.request.allowTopLevel);
|
|
22
|
+
const src = toRecord(payload);
|
|
23
|
+
const out = {};
|
|
24
|
+
for (const key of Object.keys(src)) {
|
|
25
|
+
if (allow.has(key)) {
|
|
26
|
+
out[key] = src[key];
|
|
64
27
|
}
|
|
65
|
-
}
|
|
28
|
+
}
|
|
29
|
+
const normalizedMessages = this.normalizeRequestMessages(out.messages, cfg.request);
|
|
30
|
+
out.messages = normalizedMessages;
|
|
31
|
+
this.normalizeTools(out, cfg.request);
|
|
32
|
+
this.cleanupToolChoice(out);
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
applyResponseFilter(payload, ctx) {
|
|
36
|
+
const envFlag = String(process.env.RCC_COMPAT_FILTER_OFF_RESPONSES || '1').toLowerCase();
|
|
37
|
+
const envBypass = !(envFlag === '0' || envFlag === 'false' || envFlag === 'off');
|
|
38
|
+
const entryEndpoint = ctx?.entryEndpoint ?? ctx?.endpoint;
|
|
39
|
+
const entry = typeof entryEndpoint === 'string' ? entryEndpoint.toLowerCase() : '';
|
|
40
|
+
if (entry === '/v1/responses' || envBypass) {
|
|
41
|
+
return payload;
|
|
42
|
+
}
|
|
43
|
+
const cfg = this.cfg;
|
|
44
|
+
const src = toRecord(payload);
|
|
45
|
+
const out = this.shallowPick(src, cfg.response.allowTopLevel);
|
|
46
|
+
const choices = Array.isArray(src.choices) ? src.choices : [];
|
|
47
|
+
out.choices = choices.map((choice, idx) => this.normalizeResponseChoice(choice, idx, cfg.response));
|
|
48
|
+
if (src.usage && typeof src.usage === 'object') {
|
|
49
|
+
out.usage = this.shallowPick(src.usage, cfg.response.usage?.allow || []);
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
66
52
|
}
|
|
67
53
|
shallowPick(obj, allow) {
|
|
68
54
|
if (!isRecord(obj)) {
|
|
@@ -119,51 +105,6 @@ export class UniversalShapeFilter {
|
|
|
119
105
|
return DEFAULT_TOOL_OUTPUT;
|
|
120
106
|
}
|
|
121
107
|
}
|
|
122
|
-
async applyRequestFilter(payload) {
|
|
123
|
-
const cfg = this.cfg;
|
|
124
|
-
const allow = new Set(cfg.request.allowTopLevel);
|
|
125
|
-
const src = toRecord(payload);
|
|
126
|
-
const out = {};
|
|
127
|
-
for (const key of Object.keys(src)) {
|
|
128
|
-
if (allow.has(key)) {
|
|
129
|
-
out[key] = src[key];
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
const normalizedMessages = this.normalizeRequestMessages(out.messages, cfg.request);
|
|
133
|
-
out.messages = normalizedMessages;
|
|
134
|
-
this.normalizeTools(out, cfg.request);
|
|
135
|
-
this.cleanupToolChoice(out);
|
|
136
|
-
return out;
|
|
137
|
-
}
|
|
138
|
-
async applyResponseFilter(payload, _ctx) {
|
|
139
|
-
// Bypass shape filtering by default to keep system running; can be turned off via env.
|
|
140
|
-
// Default: RCC_COMPAT_FILTER_OFF_RESPONSES is treated as ON unless explicitly set to 0/false/off.
|
|
141
|
-
const envFlag = String(process.env.RCC_COMPAT_FILTER_OFF_RESPONSES || '1').toLowerCase();
|
|
142
|
-
const envBypass = !(envFlag === '0' || envFlag === 'false' || envFlag === 'off');
|
|
143
|
-
try {
|
|
144
|
-
const ctx = _ctx;
|
|
145
|
-
const entryEndpoint = typeof ctx?.entryEndpoint === 'string' ? ctx.entryEndpoint : undefined;
|
|
146
|
-
const fallbackEndpoint = typeof ctx?.endpoint === 'string' ? ctx.endpoint : undefined;
|
|
147
|
-
const entry = String(entryEndpoint ?? fallbackEndpoint ?? '').toLowerCase();
|
|
148
|
-
if (entry === '/v1/responses' || envBypass) {
|
|
149
|
-
return payload;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
catch {
|
|
153
|
-
if (envBypass) {
|
|
154
|
-
return payload;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
const cfg = this.cfg;
|
|
158
|
-
const src = toRecord(payload);
|
|
159
|
-
const out = this.shallowPick(src, cfg.response.allowTopLevel);
|
|
160
|
-
const choices = Array.isArray(src.choices) ? src.choices : [];
|
|
161
|
-
out.choices = choices.map((choice, idx) => this.normalizeResponseChoice(choice, idx, cfg.response));
|
|
162
|
-
if (src.usage && typeof src.usage === 'object') {
|
|
163
|
-
out.usage = this.shallowPick(src.usage, cfg.response.usage?.allow || []);
|
|
164
|
-
}
|
|
165
|
-
return out;
|
|
166
|
-
}
|
|
167
108
|
normalizeRequestMessages(messages, requestCfg) {
|
|
168
109
|
const entries = toArray(messages);
|
|
169
110
|
const normalized = entries.map(entry => this.normalizeSingleMessage(entry, requestCfg));
|
|
@@ -186,6 +127,17 @@ export class UniversalShapeFilter {
|
|
|
186
127
|
normalized.tool_call_id = msg.tool_call_id;
|
|
187
128
|
}
|
|
188
129
|
}
|
|
130
|
+
else if (Array.isArray(msg.content)) {
|
|
131
|
+
normalized.content = msg.content.map((part) => {
|
|
132
|
+
if (typeof part === 'string') {
|
|
133
|
+
return part;
|
|
134
|
+
}
|
|
135
|
+
if (isRecord(part)) {
|
|
136
|
+
return { ...part };
|
|
137
|
+
}
|
|
138
|
+
return part;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
189
141
|
else {
|
|
190
142
|
normalized.content = (msg.content !== null && msg.content !== undefined) ? String(msg.content) : '';
|
|
191
143
|
}
|
|
@@ -435,12 +387,7 @@ export class UniversalShapeFilter {
|
|
|
435
387
|
if (typeof tc.id === 'string') {
|
|
436
388
|
normalized.id = tc.id;
|
|
437
389
|
}
|
|
438
|
-
if (tc.mcp) {
|
|
439
|
-
const existing = isRecord(normalized._glm) ? normalized._glm : {};
|
|
440
|
-
normalized._glm = { ...existing, mcp: tc.mcp };
|
|
441
|
-
}
|
|
442
390
|
return normalized;
|
|
443
391
|
});
|
|
444
392
|
}
|
|
445
393
|
}
|
|
446
|
-
//# sourceMappingURL=universal-shape-filter.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "chat:gemini",
|
|
3
|
+
"protocol": "gemini-chat",
|
|
4
|
+
"request": {
|
|
5
|
+
"mappings": [
|
|
6
|
+
{ "action": "snapshot", "phase": "compat-pre" },
|
|
7
|
+
{
|
|
8
|
+
"action": "gemini_web_search_request"
|
|
9
|
+
},
|
|
10
|
+
{ "action": "snapshot", "phase": "compat-post" }
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"response": {
|
|
14
|
+
"mappings": []
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
@@ -1,17 +1,200 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
"id": "chat:glm",
|
|
3
|
+
"protocol": "openai-chat",
|
|
4
|
+
"request": {
|
|
5
5
|
"mappings": [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
{ "action": "snapshot", "phase": "compat-pre" },
|
|
7
|
+
{ "action": "dto_unwrap" },
|
|
8
|
+
{
|
|
9
|
+
"action": "glm_image_content"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"action": "glm_vision_prompt"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"action": "rename",
|
|
16
|
+
"from": "response_format",
|
|
17
|
+
"to": "metadata.generation.response_format"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"action": "remove",
|
|
21
|
+
"path": "metadata.clientModelId"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"action": "shape_filter",
|
|
25
|
+
"target": "request",
|
|
26
|
+
"config": {
|
|
27
|
+
"request": {
|
|
28
|
+
"allowTopLevel": [
|
|
29
|
+
"model", "messages", "stream", "thinking", "do_sample", "temperature", "top_p",
|
|
30
|
+
"max_tokens", "tools", "tool_choice", "stop", "response_format", "web_search"
|
|
31
|
+
],
|
|
32
|
+
"messages": {
|
|
33
|
+
"allowedRoles": ["system", "user", "assistant", "tool"],
|
|
34
|
+
"assistantWithToolCallsContentNull": true,
|
|
35
|
+
"toolContentStringify": false
|
|
36
|
+
},
|
|
37
|
+
"messagesRules": [],
|
|
38
|
+
"tools": {
|
|
39
|
+
"normalize": false,
|
|
40
|
+
"forceToolChoiceAuto": true
|
|
41
|
+
},
|
|
42
|
+
"assistantToolCalls": { "functionArgumentsType": "string" }
|
|
43
|
+
},
|
|
44
|
+
"response": {
|
|
45
|
+
"allowTopLevel": [
|
|
46
|
+
"id", "request_id", "created", "model",
|
|
47
|
+
"choices", "usage", "video_result", "web_search", "content_filter",
|
|
48
|
+
"required_action", "output", "output_text", "status"
|
|
49
|
+
],
|
|
50
|
+
"choices": {
|
|
51
|
+
"required": true,
|
|
52
|
+
"message": {
|
|
53
|
+
"allow": ["role", "content", "reasoning_content", "audio", "tool_calls"],
|
|
54
|
+
"roleDefault": "assistant",
|
|
55
|
+
"contentNullWhenToolCalls": true,
|
|
56
|
+
"tool_calls": { "function": { "nameRequired": true, "argumentsType": "string" } }
|
|
57
|
+
},
|
|
58
|
+
"finish_reason": ["stop", "tool_calls", "length", "sensitive", "network_error"]
|
|
59
|
+
},
|
|
60
|
+
"usage": { "allow": ["prompt_tokens", "completion_tokens", "prompt_tokens_details", "total_tokens"] }
|
|
61
|
+
}
|
|
14
62
|
}
|
|
15
|
-
|
|
16
|
-
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"action": "apply_rules",
|
|
66
|
+
"config": {
|
|
67
|
+
"tools": {
|
|
68
|
+
"function": {
|
|
69
|
+
"removeKeys": ["strict", "json_schema"]
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"messages": {
|
|
73
|
+
"assistantToolCalls": {
|
|
74
|
+
"function": {
|
|
75
|
+
"removeKeys": ["strict"]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"topLevel": {
|
|
80
|
+
"conditional": [
|
|
81
|
+
{ "when": { "tools": "empty" }, "remove": ["tool_choice"] }
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"action": "field_map",
|
|
88
|
+
"direction": "incoming",
|
|
89
|
+
"config": [
|
|
90
|
+
{ "sourcePath": "usage.prompt_tokens", "targetPath": "usage.input_tokens", "type": "number" },
|
|
91
|
+
{ "sourcePath": "usage.completion_tokens", "targetPath": "usage.output_tokens", "type": "number" },
|
|
92
|
+
{ "sourcePath": "created", "targetPath": "created_at", "type": "number" },
|
|
93
|
+
{ "sourcePath": "request_id", "targetPath": "request_id", "type": "string" },
|
|
94
|
+
{ "sourcePath": "model", "targetPath": "model", "type": "string", "transform": "normalizeModelName" },
|
|
95
|
+
{
|
|
96
|
+
"sourcePath": "choices[*].message.tool_calls[*].function.arguments",
|
|
97
|
+
"targetPath": "choices[*].message.tool_calls[*].function.arguments",
|
|
98
|
+
"type": "string"
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
{ "action": "tool_schema_sanitize", "mode": "glm_shell" },
|
|
103
|
+
{
|
|
104
|
+
"action": "glm_web_search_request"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"action": "auto_thinking",
|
|
108
|
+
"config": {
|
|
109
|
+
"modelPrefixes": ["glm-4.7", "glm-4.6", "glm-4.5", "glm-z1"],
|
|
110
|
+
"excludePrefixes": ["glm-4.6v"]
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{ "action": "snapshot", "phase": "compat-post" },
|
|
114
|
+
{ "action": "dto_rewrap" }
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"response": {
|
|
118
|
+
"mappings": [
|
|
119
|
+
{ "action": "snapshot", "phase": "compat-pre" },
|
|
120
|
+
{ "action": "dto_unwrap" },
|
|
121
|
+
{
|
|
122
|
+
"action": "resp_blacklist",
|
|
123
|
+
"config": {
|
|
124
|
+
"paths": ["usage.prompt_tokens_details.cached_tokens"],
|
|
125
|
+
"keepCritical": true
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"action": "shape_filter",
|
|
130
|
+
"target": "response",
|
|
131
|
+
"config": {
|
|
132
|
+
"request": {
|
|
133
|
+
"allowTopLevel": [
|
|
134
|
+
"model", "messages", "stream", "thinking", "do_sample", "temperature", "top_p",
|
|
135
|
+
"max_tokens", "tools", "tool_choice", "stop", "response_format"
|
|
136
|
+
],
|
|
137
|
+
"messages": {
|
|
138
|
+
"allowedRoles": ["system", "user", "assistant", "tool"],
|
|
139
|
+
"assistantWithToolCallsContentNull": true,
|
|
140
|
+
"toolContentStringify": false
|
|
141
|
+
},
|
|
142
|
+
"messagesRules": [],
|
|
143
|
+
"tools": {
|
|
144
|
+
"normalize": false,
|
|
145
|
+
"forceToolChoiceAuto": true
|
|
146
|
+
},
|
|
147
|
+
"assistantToolCalls": { "functionArgumentsType": "string" }
|
|
148
|
+
},
|
|
149
|
+
"response": {
|
|
150
|
+
"allowTopLevel": [
|
|
151
|
+
"id", "request_id", "created", "model",
|
|
152
|
+
"choices", "usage", "video_result", "web_search", "content_filter",
|
|
153
|
+
"required_action", "output", "output_text", "status"
|
|
154
|
+
],
|
|
155
|
+
"choices": {
|
|
156
|
+
"required": true,
|
|
157
|
+
"message": {
|
|
158
|
+
"allow": ["role", "content", "reasoning_content", "audio", "tool_calls"],
|
|
159
|
+
"roleDefault": "assistant",
|
|
160
|
+
"contentNullWhenToolCalls": true,
|
|
161
|
+
"tool_calls": { "function": { "nameRequired": true, "argumentsType": "string" } }
|
|
162
|
+
},
|
|
163
|
+
"finish_reason": ["stop", "tool_calls", "length", "sensitive", "network_error"]
|
|
164
|
+
},
|
|
165
|
+
"usage": { "allow": ["prompt_tokens", "completion_tokens", "prompt_tokens_details", "total_tokens"] }
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"action": "field_map",
|
|
171
|
+
"direction": "outgoing",
|
|
172
|
+
"config": [
|
|
173
|
+
{ "sourcePath": "usage.input_tokens", "targetPath": "usage.prompt_tokens", "type": "number" },
|
|
174
|
+
{ "sourcePath": "usage.output_tokens", "targetPath": "usage.completion_tokens", "type": "number" },
|
|
175
|
+
{ "sourcePath": "usage.total_input_tokens", "targetPath": "usage.prompt_tokens", "type": "number" },
|
|
176
|
+
{ "sourcePath": "usage.total_output_tokens", "targetPath": "usage.completion_tokens", "type": "number" },
|
|
177
|
+
{ "sourcePath": "created_at", "targetPath": "created", "type": "number" },
|
|
178
|
+
{ "sourcePath": "request_id", "targetPath": "request_id", "type": "string" },
|
|
179
|
+
{
|
|
180
|
+
"sourcePath": "choices[*].finish_reason",
|
|
181
|
+
"targetPath": "choices[*].finish_reason",
|
|
182
|
+
"type": "string",
|
|
183
|
+
"transform": "normalizeFinishReason"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"sourcePath": "choices[*].message.tool_calls[*].function.arguments",
|
|
187
|
+
"targetPath": "choices[*].message.tool_calls[*].function.arguments",
|
|
188
|
+
"type": "string"
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
{ "action": "tool_schema_sanitize", "mode": "glm_shell" },
|
|
193
|
+
{ "action": "response_normalize" },
|
|
194
|
+
{ "action": "extract_glm_tool_markup" },
|
|
195
|
+
{ "action": "response_validate" },
|
|
196
|
+
{ "action": "snapshot", "phase": "compat-post" },
|
|
197
|
+
{ "action": "dto_rewrap" }
|
|
198
|
+
]
|
|
199
|
+
}
|
|
17
200
|
}
|