@jsonstudio/rcc 0.89.164 → 0.89.333
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 +32 -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/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/modules/pipeline/utils/colored-logger.d.ts +2 -0
- package/dist/modules/pipeline/utils/colored-logger.js +20 -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/oauth-lifecycle.js +140 -8
- 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 +2 -0
- package/dist/providers/core/config/oauth-flows.js.map +1 -1
- package/dist/providers/core/config/provider-oauth-configs.js +85 -0
- package/dist/providers/core/config/provider-oauth-configs.js.map +1 -1
- package/dist/providers/core/config/service-profiles.js +15 -1
- package/dist/providers/core/config/service-profiles.js.map +1 -1
- package/dist/providers/core/runtime/base-provider.d.ts +8 -1
- package/dist/providers/core/runtime/base-provider.js +176 -108
- package/dist/providers/core/runtime/base-provider.js.map +1 -1
- package/dist/providers/core/runtime/gemini-cli-http-provider.d.ts +9 -5
- package/dist/providers/core/runtime/gemini-cli-http-provider.js +271 -69
- package/dist/providers/core/runtime/gemini-cli-http-provider.js.map +1 -1
- package/dist/providers/core/runtime/gemini-http-provider.d.ts +1 -2
- package/dist/providers/core/runtime/gemini-http-provider.js +0 -12
- package/dist/providers/core/runtime/gemini-http-provider.js.map +1 -1
- package/dist/providers/core/runtime/http-request-executor.d.ts +42 -0
- package/dist/providers/core/runtime/http-request-executor.js +133 -0
- package/dist/providers/core/runtime/http-request-executor.js.map +1 -0
- package/dist/providers/core/runtime/http-transport-provider.d.ts +32 -12
- package/dist/providers/core/runtime/http-transport-provider.js +464 -426
- package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
- package/dist/providers/core/runtime/provider-error-classifier.d.ts +25 -0
- package/dist/providers/core/runtime/provider-error-classifier.js +149 -0
- package/dist/providers/core/runtime/provider-error-classifier.js.map +1 -0
- package/dist/providers/core/runtime/provider-error-types.d.ts +23 -0
- package/dist/providers/core/runtime/provider-error-types.js +2 -0
- package/dist/providers/core/runtime/provider-error-types.js.map +1 -0
- package/dist/providers/core/runtime/provider-factory.d.ts +1 -0
- package/dist/providers/core/runtime/provider-factory.js +43 -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 +48 -114
- package/dist/providers/core/runtime/responses-provider.js.map +1 -1
- package/dist/providers/core/strategies/oauth-auth-code-flow.js +11 -3
- 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 +29 -3
- 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.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/runtime/http-server/index.d.ts +1 -0
- package/dist/server/runtime/http-server/index.js +39 -4
- package/dist/server/runtime/http-server/index.js.map +1 -1
- package/dist/server/runtime/http-server/request-executor.d.ts +4 -0
- package/dist/server/runtime/http-server/request-executor.js +99 -4
- package/dist/server/runtime/http-server/request-executor.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/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/utils/debug-utils.js +14 -0
- package/dist/utils/debug-utils.js.map +1 -1
- package/dist/utils/error-handler-registry.js +6 -5
- 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/dist/conversion/codecs/gemini-openai-codec.js +15 -1
- 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/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/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 +35 -99
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-glm.json +187 -13
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-iflow.json +177 -9
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-lmstudio.json +10 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-qwen.json +14 -10
- 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 +845 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-types.d.ts +47 -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 +35 -1
- 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 +3 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/response-runtime.js +19 -2
- 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 +51 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/anthropic-message-utils.js +6 -0
- 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/tool-canonicalizer.d.ts +2 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-filter-pipeline.js +11 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/bootstrap.js +251 -12
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/classifier.js +11 -4
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/context-advisor.d.ts +21 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/context-advisor.js +76 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/engine.d.ts +11 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/engine.js +187 -28
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/features.js +22 -457
- 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 +66 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/provider-registry.js +6 -2
- 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 +21 -1
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/types.js +1 -0
- package/node_modules/@jsonstudio/llms/package.json +2 -2
- package/package.json +13 -11
- 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 +30 -1
- package/scripts/publish-rcc.mjs +31 -0
- package/scripts/replay-codex-sample.mjs +13 -8
- package/scripts/tests/chat-pipeline-blackbox.mjs +1 -1
- 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/scripts/check-glm-compat.mjs +0 -47
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Antigravity OAuth authentication script
|
|
3
|
+
// Usage:
|
|
4
|
+
// # 默认使用 ~/.routecodex/auth/antigravity-oauth.json(自动创建/更新)
|
|
5
|
+
// node scripts/auth-antigravity-token.mjs
|
|
6
|
+
//
|
|
7
|
+
// # 或通过环境变量显式指定 token 文件(支持 ~ 展开):
|
|
8
|
+
// // ANTIGRAVITY_TOKEN_FILE="~/.routecodex/auth/antigravity-oauth-alt.json" node scripts/auth-antigravity-token.mjs
|
|
9
|
+
|
|
10
|
+
import os from 'os';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import fs from 'fs/promises';
|
|
13
|
+
|
|
14
|
+
async function resolveAntigravityTokenPath() {
|
|
15
|
+
const envFile =
|
|
16
|
+
(process.env.ANTIGRAVITY_TOKEN_FILE && process.env.ANTIGRAVITY_TOKEN_FILE.trim()) ||
|
|
17
|
+
(process.env.ROUTECODEX_ANTIGRAVITY_TOKEN_FILE && process.env.ROUTECODEX_ANTIGRAVITY_TOKEN_FILE.trim()) ||
|
|
18
|
+
'';
|
|
19
|
+
|
|
20
|
+
if (envFile) {
|
|
21
|
+
const normalized = envFile.startsWith('~')
|
|
22
|
+
? envFile.replace(/^~(?=$|\/)/, os.homedir())
|
|
23
|
+
: envFile;
|
|
24
|
+
return path.resolve(normalized);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const home = os.homedir();
|
|
28
|
+
return path.join(home, '.routecodex', 'auth', 'antigravity-oauth.json');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function run() {
|
|
32
|
+
const tokenPath = await resolveAntigravityTokenPath();
|
|
33
|
+
const dir = path.dirname(tokenPath);
|
|
34
|
+
await fs.mkdir(dir, { recursive: true });
|
|
35
|
+
try {
|
|
36
|
+
await fs.access(tokenPath);
|
|
37
|
+
} catch {
|
|
38
|
+
await fs.writeFile(tokenPath, '{}', 'utf-8');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { ensureValidOAuthToken } = await import('../dist/providers/auth/oauth-lifecycle.js');
|
|
42
|
+
|
|
43
|
+
console.log(`[antigravity-auth] Authenticating token: ${tokenPath}`);
|
|
44
|
+
|
|
45
|
+
await ensureValidOAuthToken(
|
|
46
|
+
'antigravity',
|
|
47
|
+
{
|
|
48
|
+
type: 'antigravity-oauth',
|
|
49
|
+
tokenFile: tokenPath
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
forceReauthorize: true,
|
|
53
|
+
openBrowser: true
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
console.log(`[antigravity-auth] Token saved to: ${tokenPath}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
run().catch((err) => {
|
|
61
|
+
console.error('[antigravity-auth] Error:', err);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
});
|
|
64
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Gemini CLI OAuth authentication script
|
|
3
|
+
// Usage:
|
|
4
|
+
// # 默认使用 ~/.routecodex/auth/gemini-oauth.json(自动创建/更新)
|
|
5
|
+
// node scripts/auth-gemini-cli-token.mjs
|
|
6
|
+
//
|
|
7
|
+
// # 或通过环境变量显式指定 token 文件(支持 ~ 展开):
|
|
8
|
+
// // GEMINI_CLI_TOKEN_FILE="~/.routecodex/auth/gemini-oauth-1-primary.json" node scripts/auth-gemini-cli-token.mjs
|
|
9
|
+
|
|
10
|
+
import os from 'os';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import fs from 'fs/promises';
|
|
13
|
+
|
|
14
|
+
async function resolveGeminiTokenPath() {
|
|
15
|
+
const envFile =
|
|
16
|
+
(process.env.GEMINI_CLI_TOKEN_FILE && process.env.GEMINI_CLI_TOKEN_FILE.trim()) ||
|
|
17
|
+
(process.env.ROUTECODEX_GEMINI_TOKEN_FILE && process.env.ROUTECODEX_GEMINI_TOKEN_FILE.trim()) ||
|
|
18
|
+
'';
|
|
19
|
+
|
|
20
|
+
if (envFile) {
|
|
21
|
+
const normalized = envFile.startsWith('~')
|
|
22
|
+
? envFile.replace(/^~\//, `${os.homedir()}/`)
|
|
23
|
+
: envFile;
|
|
24
|
+
return { tokenPath: normalized, duplicates: [] };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const authDir = path.join(os.homedir(), '.routecodex', 'auth');
|
|
28
|
+
const primaryName = 'gemini-oauth.json';
|
|
29
|
+
|
|
30
|
+
let entries = [];
|
|
31
|
+
try {
|
|
32
|
+
entries = await fs.readdir(authDir);
|
|
33
|
+
} catch {
|
|
34
|
+
// directory may not exist yet
|
|
35
|
+
entries = [];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const matches = entries
|
|
39
|
+
.filter((entry) => entry.endsWith('.json'))
|
|
40
|
+
.filter((entry) => entry === primaryName || entry.startsWith('gemini-oauth-'));
|
|
41
|
+
|
|
42
|
+
matches.sort();
|
|
43
|
+
if (matches.length > 0) {
|
|
44
|
+
const canonical = path.join(authDir, matches[0]);
|
|
45
|
+
const duplicates = matches.slice(1).map((name) => path.join(authDir, name));
|
|
46
|
+
return { tokenPath: canonical, duplicates };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const canonical = path.join(authDir, primaryName);
|
|
50
|
+
return { tokenPath: canonical, duplicates: [] };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function run() {
|
|
54
|
+
const { tokenPath, duplicates } = await resolveGeminiTokenPath();
|
|
55
|
+
console.log(`[gemini-cli-auth] Authenticating token: ${tokenPath}`);
|
|
56
|
+
|
|
57
|
+
// ensure token file exists so re-auth can recreate after delete
|
|
58
|
+
await fs.mkdir(path.dirname(tokenPath), { recursive: true });
|
|
59
|
+
try {
|
|
60
|
+
await fs.access(tokenPath);
|
|
61
|
+
} catch {
|
|
62
|
+
await fs.writeFile(tokenPath, '{}', 'utf-8');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const { ensureValidOAuthToken } = await import('../dist/providers/auth/oauth-lifecycle.js');
|
|
66
|
+
|
|
67
|
+
await ensureValidOAuthToken(
|
|
68
|
+
'gemini-cli',
|
|
69
|
+
{
|
|
70
|
+
type: 'gemini-cli-oauth',
|
|
71
|
+
tokenFile: tokenPath
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
forceReauthorize: true,
|
|
75
|
+
openBrowser: true
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// clean up duplicate token files for the same family
|
|
80
|
+
for (const dup of duplicates) {
|
|
81
|
+
if (dup === tokenPath) continue;
|
|
82
|
+
try {
|
|
83
|
+
await fs.unlink(dup);
|
|
84
|
+
console.log(`[gemini-cli-auth] Removed duplicate token file: ${dup}`);
|
|
85
|
+
} catch {
|
|
86
|
+
// ignore
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log(`[gemini-cli-auth] Token saved to: ${tokenPath}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
run().catch((err) => {
|
|
94
|
+
console.error('[gemini-cli-auth] Error:', err);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs/promises';
|
|
5
|
+
import { createProviderOAuthStrategy } from '../dist/providers/core/config/provider-oauth-configs.js';
|
|
6
|
+
|
|
7
|
+
async function resolveIflowTokenPath() {
|
|
8
|
+
const envFile = process.env.IFLOW_TOKEN_FILE;
|
|
9
|
+
if (envFile && envFile.trim()) {
|
|
10
|
+
const normalized = envFile.startsWith('~') ? envFile.replace(/^~\//, `${os.homedir()}/`) : envFile;
|
|
11
|
+
return { tokenPath: normalized, duplicates: [] };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const authDir = path.join(os.homedir(), '.routecodex', 'auth');
|
|
15
|
+
const seq = 1;
|
|
16
|
+
const prefix = `iflow-oauth-${seq}`;
|
|
17
|
+
let entries = [];
|
|
18
|
+
try {
|
|
19
|
+
entries = await fs.readdir(authDir);
|
|
20
|
+
} catch {
|
|
21
|
+
// directory may not exist yet
|
|
22
|
+
}
|
|
23
|
+
const matches = entries
|
|
24
|
+
.filter((entry) => entry.endsWith('.json'))
|
|
25
|
+
.filter((entry) => entry === `${prefix}.json` || entry.startsWith(`${prefix}-`));
|
|
26
|
+
matches.sort();
|
|
27
|
+
if (matches.length > 0) {
|
|
28
|
+
const canonical = path.join(authDir, matches[0]);
|
|
29
|
+
const duplicates = matches.slice(1).map((name) => path.join(authDir, name));
|
|
30
|
+
return { tokenPath: canonical, duplicates };
|
|
31
|
+
}
|
|
32
|
+
const canonical = path.join(authDir, `${prefix}-primary.json`);
|
|
33
|
+
return { tokenPath: canonical, duplicates: [] };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function run() {
|
|
37
|
+
const { tokenPath, duplicates } = await resolveIflowTokenPath();
|
|
38
|
+
console.log(`[iflow-manual] Manual auth for: ${tokenPath}`);
|
|
39
|
+
|
|
40
|
+
// ensure token file exists
|
|
41
|
+
await fs.mkdir(path.dirname(tokenPath), { recursive: true });
|
|
42
|
+
try { await fs.access(tokenPath); } catch { await fs.writeFile(tokenPath, '{}', 'utf-8'); }
|
|
43
|
+
|
|
44
|
+
// Use device code flow but let user open the URL manually
|
|
45
|
+
const strategy = createProviderOAuthStrategy('iflow', {
|
|
46
|
+
flowType: 'device_code',
|
|
47
|
+
endpoints: {
|
|
48
|
+
deviceCodeUrl: 'https://iflow.cn/oauth/device/code',
|
|
49
|
+
tokenUrl: 'https://iflow.cn/oauth/token',
|
|
50
|
+
userInfoUrl: 'https://iflow.cn/api/oauth/getUserInfo'
|
|
51
|
+
},
|
|
52
|
+
client: { clientId: '10009311001', scopes: ['openid','profile','email','api'] }
|
|
53
|
+
}, tokenPath);
|
|
54
|
+
|
|
55
|
+
// Manually trigger device code flow
|
|
56
|
+
const deviceCodeData = await strategy.initiateDeviceCodeFlow();
|
|
57
|
+
console.log('Please open this URL in your browser:');
|
|
58
|
+
console.log(deviceCodeData.verification_uri);
|
|
59
|
+
console.log('User code:', deviceCodeData.user_code);
|
|
60
|
+
console.log('Press Enter when you have authorized...');
|
|
61
|
+
|
|
62
|
+
await new Promise(resolve => process.stdin.once('data', resolve));
|
|
63
|
+
|
|
64
|
+
const token = await strategy.pollForToken(deviceCodeData);
|
|
65
|
+
await strategy.saveToken(token);
|
|
66
|
+
|
|
67
|
+
// clean up duplicate token files for the same sequence
|
|
68
|
+
for (const dup of duplicates) {
|
|
69
|
+
if (dup === tokenPath) continue;
|
|
70
|
+
try {
|
|
71
|
+
await fs.unlink(dup);
|
|
72
|
+
console.log(`[iflow-manual] Removed duplicate token file: ${dup}`);
|
|
73
|
+
} catch {
|
|
74
|
+
// ignore
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log(`[iflow-manual] Token saved to: ${tokenPath}`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
run().catch(err => { console.error('[iflow-manual] Error:', err); process.exit(1); });
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// iFlow token auth using direct device flow - no browser redirect
|
|
3
|
+
// Usage: ILOW_TOKEN_FILE="~/.routecodex/auth/iflow-oauth-1-xxx.json" node scripts/auth-iflow-token-direct.mjs
|
|
4
|
+
|
|
5
|
+
import os from 'os';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import fs from 'fs/promises';
|
|
8
|
+
|
|
9
|
+
async function resolveIflowTokenPath() {
|
|
10
|
+
const envFile = process.env.IFLOW_TOKEN_FILE;
|
|
11
|
+
if (envFile && envFile.trim()) {
|
|
12
|
+
const normalized = envFile.startsWith('~') ? envFile.replace(/^~\//, `${os.homedir()}/`) : envFile;
|
|
13
|
+
return { tokenPath: normalized, duplicates: [] };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const authDir = path.join(os.homedir(), '.routecodex', 'auth');
|
|
17
|
+
const seq = 1;
|
|
18
|
+
const prefix = `iflow-oauth-${seq}`;
|
|
19
|
+
let entries = [];
|
|
20
|
+
try {
|
|
21
|
+
entries = await fs.readdir(authDir);
|
|
22
|
+
} catch {
|
|
23
|
+
// directory may not exist yet
|
|
24
|
+
}
|
|
25
|
+
const matches = entries
|
|
26
|
+
.filter((entry) => entry.endsWith('.json'))
|
|
27
|
+
.filter((entry) => entry === `${prefix}.json` || entry.startsWith(`${prefix}-`));
|
|
28
|
+
matches.sort();
|
|
29
|
+
if (matches.length > 0) {
|
|
30
|
+
const canonical = path.join(authDir, matches[0]);
|
|
31
|
+
const duplicates = matches.slice(1).map((name) => path.join(authDir, name));
|
|
32
|
+
return { tokenPath: canonical, duplicates };
|
|
33
|
+
}
|
|
34
|
+
const canonical = path.join(authDir, `${prefix}-primary.json`);
|
|
35
|
+
return { tokenPath: canonical, duplicates: [] };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function run() {
|
|
39
|
+
const { tokenPath, duplicates } = await resolveIflowTokenPath();
|
|
40
|
+
console.log(`[iflow-auth-direct] Starting device flow for: ${tokenPath}`);
|
|
41
|
+
|
|
42
|
+
// ensure token file exists so re-auth can recreate after delete
|
|
43
|
+
await fs.mkdir(path.dirname(tokenPath), { recursive: true });
|
|
44
|
+
try {
|
|
45
|
+
await fs.access(tokenPath);
|
|
46
|
+
} catch {
|
|
47
|
+
await fs.writeFile(tokenPath, '{}', 'utf-8');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const { createProviderOAuthStrategy } = await import('../dist/providers/core/config/provider-oauth-configs.js');
|
|
51
|
+
|
|
52
|
+
// Use device code flow instead of auth code flow
|
|
53
|
+
const strategy = createProviderOAuthStrategy('iflow', {
|
|
54
|
+
flowType: 'device_code',
|
|
55
|
+
endpoints: {
|
|
56
|
+
deviceCodeUrl: 'https://iflow.cn/oauth/device/code',
|
|
57
|
+
tokenUrl: 'https://iflow.cn/oauth/token',
|
|
58
|
+
userInfoUrl: 'https://iflow.cn/api/oauth/getUserInfo'
|
|
59
|
+
},
|
|
60
|
+
client: {
|
|
61
|
+
clientId: process.env.IFLOW_CLIENT_ID || 'iflow-desktop-client',
|
|
62
|
+
scopes: ['openid','profile','email','api']
|
|
63
|
+
}
|
|
64
|
+
}, tokenPath);
|
|
65
|
+
|
|
66
|
+
console.log('[iflow-auth-direct] Opening browser for device code flow...');
|
|
67
|
+
const token = await strategy.authenticate({ openBrowser: true });
|
|
68
|
+
await strategy.saveToken(token);
|
|
69
|
+
|
|
70
|
+
// clean up duplicate token files for the same sequence
|
|
71
|
+
for (const dup of duplicates) {
|
|
72
|
+
if (dup === tokenPath) continue;
|
|
73
|
+
try {
|
|
74
|
+
await fs.unlink(dup);
|
|
75
|
+
console.log(`[iflow-auth-direct] Removed duplicate token file: ${dup}`);
|
|
76
|
+
} catch {
|
|
77
|
+
// ignore
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
console.log(`[iflow-auth-direct] Token saved to: ${tokenPath}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
run().catch(err => {
|
|
85
|
+
console.error('[iflow-auth-direct] Error:', err);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// iFlow token authentication script for specific token file
|
|
3
|
+
// Usage: ILOW_TOKEN_FILE="~/.routecodex/auth/iflow-oauth-1-xxx.json" node scripts/auth-iflow-token.mjs
|
|
4
|
+
|
|
5
|
+
import os from 'os';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import fs from 'fs/promises';
|
|
8
|
+
|
|
9
|
+
async function resolveIflowTokenPath() {
|
|
10
|
+
const envFile = process.env.IFLOW_TOKEN_FILE;
|
|
11
|
+
if (envFile && envFile.trim()) {
|
|
12
|
+
const normalized = envFile.startsWith('~') ? envFile.replace(/^~\//, `${os.homedir()}/`) : envFile;
|
|
13
|
+
return { tokenPath: normalized, duplicates: [] };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const authDir = path.join(os.homedir(), '.routecodex', 'auth');
|
|
17
|
+
const seq = 1;
|
|
18
|
+
const prefix = `iflow-oauth-${seq}`;
|
|
19
|
+
let entries = [];
|
|
20
|
+
try {
|
|
21
|
+
entries = await fs.readdir(authDir);
|
|
22
|
+
} catch {
|
|
23
|
+
// directory may not exist yet
|
|
24
|
+
}
|
|
25
|
+
const matches = entries
|
|
26
|
+
.filter((entry) => entry.endsWith('.json'))
|
|
27
|
+
.filter((entry) => entry === `${prefix}.json` || entry.startsWith(`${prefix}-`));
|
|
28
|
+
matches.sort();
|
|
29
|
+
if (matches.length > 0) {
|
|
30
|
+
const canonical = path.join(authDir, matches[0]);
|
|
31
|
+
const duplicates = matches.slice(1).map((name) => path.join(authDir, name));
|
|
32
|
+
return { tokenPath: canonical, duplicates };
|
|
33
|
+
}
|
|
34
|
+
const canonical = path.join(authDir, `${prefix}-primary.json`);
|
|
35
|
+
return { tokenPath: canonical, duplicates: [] };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function run() {
|
|
39
|
+
const { tokenPath, duplicates } = await resolveIflowTokenPath();
|
|
40
|
+
console.log(`[iflow-auth] Authenticating token: ${tokenPath}`);
|
|
41
|
+
|
|
42
|
+
// ensure token file exists so re-auth can recreate after delete
|
|
43
|
+
await fs.mkdir(path.dirname(tokenPath), { recursive: true });
|
|
44
|
+
try {
|
|
45
|
+
await fs.access(tokenPath);
|
|
46
|
+
} catch {
|
|
47
|
+
await fs.writeFile(tokenPath, '{}', 'utf-8');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const { ensureValidOAuthToken } = await import('../dist/providers/auth/oauth-lifecycle.js');
|
|
51
|
+
|
|
52
|
+
await ensureValidOAuthToken('iflow', {
|
|
53
|
+
type: 'iflow-oauth',
|
|
54
|
+
tokenFile: tokenPath
|
|
55
|
+
}, {
|
|
56
|
+
forceReauthorize: true,
|
|
57
|
+
openBrowser: true
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// clean up duplicate token files for the same sequence
|
|
61
|
+
for (const dup of duplicates) {
|
|
62
|
+
if (dup === tokenPath) continue;
|
|
63
|
+
try {
|
|
64
|
+
await fs.unlink(dup);
|
|
65
|
+
console.log(`[iflow-auth] Removed duplicate token file: ${dup}`);
|
|
66
|
+
} catch {
|
|
67
|
+
// ignore
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.log(`[iflow-auth] Token saved to: ${tokenPath}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
run().catch(err => {
|
|
75
|
+
console.error('[iflow-auth] Error:', err);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
});
|
|
@@ -15,23 +15,11 @@ async function ensureDir(p) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
async function main() {
|
|
18
|
-
const SRC = path.resolve(process.cwd(), 'src/providers/compat');
|
|
19
|
-
const DIST = path.resolve(process.cwd(), 'dist/providers/compat');
|
|
20
18
|
const PROMPT_SRC = path.resolve(process.cwd(), 'src/config/system-prompts');
|
|
21
19
|
const PROMPT_DIST = path.resolve(process.cwd(), 'dist/config/system-prompts');
|
|
22
|
-
const copied = [];
|
|
23
20
|
const promptCopied = [];
|
|
24
21
|
try {
|
|
25
|
-
|
|
26
|
-
if (file.endsWith('.json') && file.includes(`${path.sep}config${path.sep}`)) {
|
|
27
|
-
const rel = path.relative(SRC, file);
|
|
28
|
-
const dest = path.join(DIST, rel);
|
|
29
|
-
await ensureDir(path.dirname(dest));
|
|
30
|
-
await fs.copyFile(file, dest);
|
|
31
|
-
copied.push(rel);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// copy system prompt artifacts
|
|
22
|
+
// copy system prompt artifacts only; provider compat assets are owned by llmswitch-core
|
|
35
23
|
try {
|
|
36
24
|
for await (const file of walk(PROMPT_SRC)) {
|
|
37
25
|
const stats = await fs.stat(file);
|
|
@@ -46,8 +34,8 @@ async function main() {
|
|
|
46
34
|
} catch (promptErr) {
|
|
47
35
|
if (promptErr && promptErr.code !== 'ENOENT') throw promptErr;
|
|
48
36
|
}
|
|
49
|
-
// 不再复制
|
|
50
|
-
console.log(`[copy-compat-assets]
|
|
37
|
+
// 不再复制 provider compat 资产;兼容层由 sharedmodule/llmswitch-core 提供
|
|
38
|
+
console.log(`[copy-compat-assets] prompts copied: ${promptCopied.length}`);
|
|
51
39
|
} catch (err) {
|
|
52
40
|
console.error('[copy-compat-assets] failed:', err?.message || String(err));
|
|
53
41
|
process.exit(1);
|
package/scripts/pack-mode.mjs
CHANGED
|
@@ -14,14 +14,36 @@ function parseArgs(argv) {
|
|
|
14
14
|
return out;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
const projectRoot = process.cwd();
|
|
17
18
|
const args = parseArgs(process.argv);
|
|
18
19
|
if (!args.name || !args.bin) {
|
|
19
20
|
console.error('Usage: node scripts/pack-mode.mjs --name <packageName> --bin <binName>');
|
|
20
21
|
process.exit(1);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
const pkgPath = path.join(
|
|
24
|
+
const pkgPath = path.join(projectRoot, 'package.json');
|
|
24
25
|
const backupPath = pkgPath + '.bak.pack';
|
|
26
|
+
const ensureScriptPath = path.join(projectRoot, 'scripts', 'ensure-llmswitch-mode.mjs');
|
|
27
|
+
const llmsPath = path.join(projectRoot, 'node_modules', '@jsonstudio', 'llms');
|
|
28
|
+
|
|
29
|
+
function runEnsureMode(mode) {
|
|
30
|
+
const env = { ...process.env, BUILD_MODE: mode };
|
|
31
|
+
const res = spawnSync(process.execPath, [ensureScriptPath], { stdio: 'inherit', env });
|
|
32
|
+
if ((res.status ?? 0) !== 0) {
|
|
33
|
+
throw new Error(`ensure-llmswitch-mode failed for ${mode}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isSymlink(p) {
|
|
38
|
+
try {
|
|
39
|
+
return fs.lstatSync(p).isSymbolicLink();
|
|
40
|
+
} catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const hadDevLink = isSymlink(llmsPath);
|
|
46
|
+
runEnsureMode('release');
|
|
25
47
|
|
|
26
48
|
const original = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
27
49
|
fs.writeFileSync(backupPath, JSON.stringify(original, null, 2));
|
|
@@ -55,4 +77,11 @@ try {
|
|
|
55
77
|
// restore
|
|
56
78
|
fs.writeFileSync(pkgPath, fs.readFileSync(backupPath, 'utf-8'));
|
|
57
79
|
fs.unlinkSync(backupPath);
|
|
80
|
+
if (hadDevLink) {
|
|
81
|
+
try {
|
|
82
|
+
runEnsureMode('dev');
|
|
83
|
+
} catch (err) {
|
|
84
|
+
console.warn('[pack-mode] failed to restore dev llms link:', err);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
58
87
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const PROJECT_ROOT = path.resolve(__dirname, '..');
|
|
9
|
+
const PACK_SCRIPT = path.join(PROJECT_ROOT, 'scripts', 'pack-mode.mjs');
|
|
10
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(PROJECT_ROOT, 'package.json'), 'utf-8'));
|
|
11
|
+
const version = packageJson.version;
|
|
12
|
+
const tarballName = `jsonstudio-rcc-${version}.tgz`;
|
|
13
|
+
const tarballPath = path.join(PROJECT_ROOT, tarballName);
|
|
14
|
+
|
|
15
|
+
function run(command, args, options = {}) {
|
|
16
|
+
const res = spawnSync(command, args, { stdio: 'inherit', ...options });
|
|
17
|
+
if ((res.status ?? 0) !== 0) {
|
|
18
|
+
throw new Error(`${command} ${args.join(' ')} failed`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
run(process.execPath, [PACK_SCRIPT, '--name', '@jsonstudio/rcc', '--bin', 'rcc'], { cwd: PROJECT_ROOT });
|
|
24
|
+
if (!fs.existsSync(tarballPath)) {
|
|
25
|
+
throw new Error(`tarball not found: ${tarballPath}`);
|
|
26
|
+
}
|
|
27
|
+
run('npm', ['publish', tarballName], { cwd: PROJECT_ROOT });
|
|
28
|
+
} catch (err) {
|
|
29
|
+
console.error('[publish-rcc] failed:', err.message);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
@@ -39,21 +39,26 @@ function readJson(file) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function extractEndpoint(doc) {
|
|
42
|
-
return doc?.data?.url || doc?.endpoint || '/v1/responses';
|
|
42
|
+
return doc?.data?.url || doc?.url || doc?.endpoint || '/v1/responses';
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
function extractBody(doc) {
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
const bodyNode = doc?.data?.body || doc?.body;
|
|
47
|
+
if (!bodyNode) {
|
|
48
|
+
if (typeof doc?.data?.data === 'object') return doc.data.data;
|
|
49
|
+
if (typeof doc?.body?.data === 'object') return doc.body.data;
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
if (typeof bodyNode.body === 'object') return bodyNode.body;
|
|
53
|
+
if (typeof bodyNode === 'object') return bodyNode;
|
|
54
|
+
if (typeof doc?.data?.data === 'object') return doc.data.data;
|
|
55
|
+
if (typeof doc?.body?.data === 'object') return doc.body.data;
|
|
51
56
|
return undefined;
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
function detectStream(doc, requestBody) {
|
|
55
|
-
if (doc?.data?.meta?.stream === true) return true;
|
|
56
|
-
if (doc?.data?.body?.metadata?.stream === true) return true;
|
|
60
|
+
if (doc?.data?.meta?.stream === true || doc?.meta?.stream === true) return true;
|
|
61
|
+
if (doc?.data?.body?.metadata?.stream === true || doc?.body?.metadata?.stream === true) return true;
|
|
57
62
|
if (requestBody?.stream === true) return true;
|
|
58
63
|
return false;
|
|
59
64
|
}
|
|
@@ -191,7 +191,7 @@ function resolveGoldenExpectations(sample) {
|
|
|
191
191
|
if (sample.meta?.endpoint && sample.meta?.requestId) {
|
|
192
192
|
const reqId = sample.meta.requestId;
|
|
193
193
|
const endpoint = sample.meta.endpoint;
|
|
194
|
-
const baseDir = path.join(os.homedir(), '.routecodex', '
|
|
194
|
+
const baseDir = path.join(os.homedir(), '.routecodex', 'codex-samples');
|
|
195
195
|
const folder = endpoint.includes('/messages')
|
|
196
196
|
? 'anthropic-messages'
|
|
197
197
|
: endpoint.includes('/responses')
|
|
@@ -13,18 +13,19 @@ const ROOT = path.resolve(__dirname, '../..');
|
|
|
13
13
|
|
|
14
14
|
const HOME = os.homedir();
|
|
15
15
|
const PROVIDER_ROOT = path.join(HOME, '.routecodex', 'provider');
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const RUNTIME_SNAPSHOT_ROOT = path.join(HOME, '.routecodex', 'codex-samples');
|
|
17
|
+
const GOLDEN_ROOT = path.join(HOME, '.routecodex', 'golden_samples');
|
|
18
|
+
const PROVIDER_GOLDEN_ROOT = path.join(GOLDEN_ROOT, 'provider_golden_samples');
|
|
18
19
|
const CI_GOLDENS_ROOT = path.join(ROOT, 'samples', 'ci-goldens');
|
|
19
20
|
const CUSTOM_SAMPLE_ROOTS = [
|
|
20
|
-
path.join(
|
|
21
|
+
path.join(GOLDEN_ROOT, 'new'),
|
|
21
22
|
CI_GOLDENS_ROOT
|
|
22
23
|
];
|
|
23
24
|
const TEMP_ROOT = path.join(process.cwd(), 'tmp', 'provider-captures');
|
|
24
25
|
const STAGE_DIRS = {
|
|
25
|
-
'openai-chat': path.join(
|
|
26
|
-
'openai-responses': path.join(
|
|
27
|
-
'anthropic-messages': path.join(
|
|
26
|
+
'openai-chat': path.join(RUNTIME_SNAPSHOT_ROOT, 'openai-chat'),
|
|
27
|
+
'openai-responses': path.join(RUNTIME_SNAPSHOT_ROOT, 'openai-responses'),
|
|
28
|
+
'anthropic-messages': path.join(RUNTIME_SNAPSHOT_ROOT, 'anthropic-messages')
|
|
28
29
|
};
|
|
29
30
|
const ENTRY_STAGE_MATRIX = {
|
|
30
31
|
'openai-chat': {
|
|
@@ -437,7 +438,7 @@ function spawnServer(configPath, port) {
|
|
|
437
438
|
}
|
|
438
439
|
|
|
439
440
|
async function captureProvider(providerEntry, entryType, port, options, sanitizedProviderId) {
|
|
440
|
-
const stageDir = path.join(
|
|
441
|
+
const stageDir = path.join(RUNTIME_SNAPSHOT_ROOT, ENTRY_DEFS[entryType].stageDir);
|
|
441
442
|
const suffix = '_req_outbound_stage2_format_build.json';
|
|
442
443
|
const before = snapshotStageFiles(stageDir, suffix);
|
|
443
444
|
const baseUrl = `http://127.0.0.1:${port}`;
|