@jsonstudio/rcc 0.89.1968 → 0.89.2202
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 +22 -0
- package/config/file-line-limit-policy.json +21 -0
- package/configsamples/config.json +1 -1
- package/configsamples/config.v1.quickstart.sanitized.json +6 -6
- package/configsamples/provider/iflow/config.v1.json +1 -1
- package/dist/app/config-readers.d.ts +18 -0
- package/dist/app/config-readers.js +95 -0
- package/dist/app/config-readers.js.map +1 -0
- package/dist/app/index.d.ts +9 -0
- package/dist/app/index.js +8 -0
- package/dist/app/index.js.map +1 -0
- package/dist/app/shutdown.d.ts +32 -0
- package/dist/app/shutdown.js +41 -0
- package/dist/app/shutdown.js.map +1 -0
- package/dist/bootstrap/index.d.ts +7 -0
- package/dist/bootstrap/index.js +7 -0
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/bootstrap/log-filter.d.ts +15 -0
- package/dist/bootstrap/log-filter.js +81 -0
- package/dist/bootstrap/log-filter.js.map +1 -0
- package/dist/build-info.js +2 -2
- package/dist/cli/commands/claude.js +6 -5
- package/dist/cli/commands/claude.js.map +1 -1
- package/dist/cli/commands/init/basic.d.ts +1 -7
- package/dist/cli/commands/init/basic.js +0 -79
- package/dist/cli/commands/init/basic.js.map +1 -1
- package/dist/cli/commands/init/prompt-utils.d.ts +7 -0
- package/dist/cli/commands/init/prompt-utils.js +80 -0
- package/dist/cli/commands/init/prompt-utils.js.map +1 -0
- package/dist/cli/commands/init/workflows.js +2 -1
- package/dist/cli/commands/init/workflows.js.map +1 -1
- package/dist/cli/commands/init.js +74 -2
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/launcher/index.d.ts +7 -0
- package/dist/cli/commands/launcher/index.js +7 -0
- package/dist/cli/commands/launcher/index.js.map +1 -0
- package/dist/cli/commands/launcher/types.d.ts +112 -0
- package/dist/cli/commands/launcher/types.js +7 -0
- package/dist/cli/commands/launcher/types.js.map +1 -0
- package/dist/cli/commands/launcher/utils.d.ts +114 -0
- package/dist/cli/commands/launcher/utils.js +378 -0
- package/dist/cli/commands/launcher/utils.js.map +1 -0
- package/dist/cli/commands/launcher-kernel.d.ts +2 -74
- package/dist/cli/commands/launcher-kernel.js +141 -143
- package/dist/cli/commands/launcher-kernel.js.map +1 -1
- package/dist/cli/commands/start-types.d.ts +67 -0
- package/dist/cli/commands/start-types.js +3 -0
- package/dist/cli/commands/start-types.js.map +1 -0
- package/dist/cli/commands/start-utils.d.ts +19 -0
- package/dist/cli/commands/start-utils.js +78 -0
- package/dist/cli/commands/start-utils.js.map +1 -0
- package/dist/cli/commands/start.d.ts +2 -67
- package/dist/cli/commands/start.js +201 -48
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/stop.js +17 -1
- package/dist/cli/commands/stop.js.map +1 -1
- package/dist/cli/commands/tmux-inject.js +1 -1
- package/dist/cli/commands/tmux-inject.js.map +1 -1
- package/dist/cli/config/init-config.js +60 -2
- package/dist/cli/config/init-config.js.map +1 -1
- package/dist/cli/config/init-provider-catalog.js +3 -1
- package/dist/cli/config/init-provider-catalog.js.map +1 -1
- package/dist/cli/config/precommand-default-script.d.ts +17 -0
- package/dist/cli/config/precommand-default-script.js +47 -0
- package/dist/cli/config/precommand-default-script.js.map +1 -0
- package/dist/cli/server/port-utils.js +63 -51
- package/dist/cli/server/port-utils.js.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/client/gemini-cli/gemini-cli-protocol-client.js +55 -5
- package/dist/client/gemini-cli/gemini-cli-protocol-client.js.map +1 -1
- package/dist/commands/oauth.js +28 -4
- package/dist/commands/oauth.js.map +1 -1
- package/dist/commands/quota-daemon.js +12 -0
- package/dist/commands/quota-daemon.js.map +1 -1
- package/dist/configsamples/config.v1.quickstart.sanitized.json +6 -6
- package/dist/constants/index.d.ts +34 -0
- package/dist/constants/index.js +57 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/docs/daemon-admin-ui.html +268 -11
- package/dist/error-handling/quiet-error-handling-center.js +19 -1
- package/dist/error-handling/quiet-error-handling-center.js.map +1 -1
- package/dist/index.js +233 -30
- package/dist/index.js.map +1 -1
- package/dist/manager/index.js +4 -4
- package/dist/manager/index.js.map +1 -1
- package/dist/manager/modules/quota/antigravity-quota-core.d.ts +26 -0
- package/dist/manager/modules/quota/antigravity-quota-core.js +23 -0
- package/dist/manager/modules/quota/antigravity-quota-core.js.map +1 -0
- package/dist/manager/modules/quota/antigravity-quota-helpers.d.ts +16 -0
- package/dist/manager/modules/quota/antigravity-quota-helpers.js +167 -0
- package/dist/manager/modules/quota/antigravity-quota-helpers.js.map +1 -0
- package/dist/manager/modules/quota/antigravity-quota-manager.d.ts +10 -39
- package/dist/manager/modules/quota/antigravity-quota-manager.js +167 -464
- package/dist/manager/modules/quota/antigravity-quota-manager.js.map +1 -1
- package/dist/manager/modules/quota/antigravity-quota-persistence.d.ts +20 -0
- package/dist/manager/modules/quota/antigravity-quota-persistence.js +139 -0
- package/dist/manager/modules/quota/antigravity-quota-persistence.js.map +1 -0
- package/dist/manager/modules/quota/antigravity-quota-runtime.d.ts +55 -0
- package/dist/manager/modules/quota/antigravity-quota-runtime.js +174 -0
- package/dist/manager/modules/quota/antigravity-quota-runtime.js.map +1 -0
- package/dist/manager/modules/quota/antigravity-quota-sync.d.ts +46 -0
- package/dist/manager/modules/quota/antigravity-quota-sync.js +162 -0
- package/dist/manager/modules/quota/antigravity-quota-sync.js.map +1 -0
- package/dist/manager/modules/quota/index.d.ts +1 -0
- package/dist/manager/modules/quota/provider-quota-daemon.error-helpers.d.ts +13 -0
- package/dist/manager/modules/quota/provider-quota-daemon.error-helpers.js +149 -0
- package/dist/manager/modules/quota/provider-quota-daemon.error-helpers.js.map +1 -0
- package/dist/manager/modules/quota/provider-quota-daemon.events.js +1 -148
- package/dist/manager/modules/quota/provider-quota-daemon.events.js.map +1 -1
- package/dist/manager/modules/quota/provider-quota-daemon.js.map +1 -1
- package/dist/manager/modules/quota/quota-adapter.d.ts +111 -0
- package/dist/manager/modules/quota/quota-adapter.js +325 -0
- package/dist/manager/modules/quota/quota-adapter.js.map +1 -0
- package/dist/manager/quota/provider-quota-center.d.ts +10 -0
- package/dist/manager/quota/provider-quota-center.js +15 -2
- package/dist/manager/quota/provider-quota-center.js.map +1 -1
- package/dist/modules/llmswitch/bridge/antigravity-signature.d.ts +28 -0
- package/dist/modules/llmswitch/bridge/antigravity-signature.js +180 -0
- package/dist/modules/llmswitch/bridge/antigravity-signature.js.map +1 -0
- package/dist/modules/llmswitch/bridge/index.d.ts +13 -0
- package/dist/modules/llmswitch/bridge/index.js +14 -0
- package/dist/modules/llmswitch/bridge/index.js.map +1 -0
- package/dist/modules/llmswitch/bridge/module-loader.d.ts +16 -0
- package/dist/modules/llmswitch/bridge/module-loader.js +59 -0
- package/dist/modules/llmswitch/bridge/module-loader.js.map +1 -0
- package/dist/modules/llmswitch/bridge/quota-manager.d.ts +8 -0
- package/dist/modules/llmswitch/bridge/quota-manager.js +37 -0
- package/dist/modules/llmswitch/bridge/quota-manager.js.map +1 -0
- package/dist/modules/llmswitch/bridge/response-converter.d.ts +11 -0
- package/dist/modules/llmswitch/bridge/response-converter.js +68 -0
- package/dist/modules/llmswitch/bridge/response-converter.js.map +1 -0
- package/dist/modules/llmswitch/bridge/routing-integrations.d.ts +12 -0
- package/dist/modules/llmswitch/bridge/routing-integrations.js +56 -0
- package/dist/modules/llmswitch/bridge/routing-integrations.js.map +1 -0
- package/dist/modules/llmswitch/bridge/runtime-integrations.d.ts +34 -0
- package/dist/modules/llmswitch/bridge/runtime-integrations.js +87 -0
- package/dist/modules/llmswitch/bridge/runtime-integrations.js.map +1 -0
- package/dist/modules/llmswitch/bridge/snapshot-recorder.d.ts +13 -0
- package/dist/modules/llmswitch/bridge/snapshot-recorder.js +484 -0
- package/dist/modules/llmswitch/bridge/snapshot-recorder.js.map +1 -0
- package/dist/modules/llmswitch/bridge/state-integrations.d.ts +59 -0
- package/dist/modules/llmswitch/bridge/state-integrations.js +264 -0
- package/dist/modules/llmswitch/bridge/state-integrations.js.map +1 -0
- package/dist/modules/llmswitch/bridge.d.ts +14 -131
- package/dist/modules/llmswitch/bridge.js +14 -834
- package/dist/modules/llmswitch/bridge.js.map +1 -1
- package/dist/modules/pipeline/types/provider-config-types.d.ts +240 -0
- package/dist/modules/pipeline/types/provider-config-types.js +2 -0
- package/dist/modules/pipeline/types/provider-config-types.js.map +1 -0
- package/dist/modules/pipeline/types/provider-types.d.ts +2 -239
- package/dist/modules/pipeline/types/provider-types.js +1 -1
- package/dist/modules/pipeline/types/provider-types.js.map +1 -1
- package/dist/modules/pipeline/utils/debug-logger.js +3 -5
- package/dist/modules/pipeline/utils/debug-logger.js.map +1 -1
- package/dist/providers/auth/apikey-auth.d.ts +57 -1
- package/dist/providers/auth/apikey-auth.js +131 -1
- package/dist/providers/auth/apikey-auth.js.map +1 -1
- package/dist/providers/auth/oauth-lifecycle/error-detection.d.ts +8 -0
- package/dist/providers/auth/oauth-lifecycle/error-detection.js +71 -0
- package/dist/providers/auth/oauth-lifecycle/error-detection.js.map +1 -0
- package/dist/providers/auth/oauth-lifecycle/index.d.ts +10 -0
- package/dist/providers/auth/oauth-lifecycle/index.js +11 -0
- package/dist/providers/auth/oauth-lifecycle/index.js.map +1 -0
- package/dist/providers/auth/oauth-lifecycle/path-resolver.d.ts +18 -0
- package/dist/providers/auth/oauth-lifecycle/path-resolver.js +121 -0
- package/dist/providers/auth/oauth-lifecycle/path-resolver.js.map +1 -0
- package/dist/providers/auth/oauth-lifecycle/throttle.d.ts +22 -0
- package/dist/providers/auth/oauth-lifecycle/throttle.js +37 -0
- package/dist/providers/auth/oauth-lifecycle/throttle.js.map +1 -0
- package/dist/providers/auth/oauth-lifecycle/token-helpers.d.ts +36 -0
- package/dist/providers/auth/oauth-lifecycle/token-helpers.js +127 -0
- package/dist/providers/auth/oauth-lifecycle/token-helpers.js.map +1 -0
- package/dist/providers/auth/oauth-lifecycle/token-io.d.ts +14 -0
- package/dist/providers/auth/oauth-lifecycle/token-io.js +151 -0
- package/dist/providers/auth/oauth-lifecycle/token-io.js.map +1 -0
- package/dist/providers/auth/oauth-lifecycle.js +70 -446
- package/dist/providers/auth/oauth-lifecycle.js.map +1 -1
- package/dist/providers/auth/oauth-repair-cooldown.js +8 -3
- package/dist/providers/auth/oauth-repair-cooldown.js.map +1 -1
- package/dist/providers/auth/oauth-repair-env.js +5 -3
- package/dist/providers/auth/oauth-repair-env.js.map +1 -1
- package/dist/providers/auth/oauth-token-utils.d.ts +61 -0
- package/dist/providers/auth/oauth-token-utils.js +187 -0
- package/dist/providers/auth/oauth-token-utils.js.map +1 -0
- package/dist/providers/auth/oauth-utils/camoufox-helper.d.ts +21 -0
- package/dist/providers/auth/oauth-utils/camoufox-helper.js +82 -0
- package/dist/providers/auth/oauth-utils/camoufox-helper.js.map +1 -0
- package/dist/providers/auth/oauth-utils/error-extraction.d.ts +17 -0
- package/dist/providers/auth/oauth-utils/error-extraction.js +80 -0
- package/dist/providers/auth/oauth-utils/error-extraction.js.map +1 -0
- package/dist/providers/auth/oauth-utils/index.d.ts +7 -0
- package/dist/providers/auth/oauth-utils/index.js +8 -0
- package/dist/providers/auth/oauth-utils/index.js.map +1 -0
- package/dist/providers/auth/token-refresh/index.d.ts +6 -0
- package/dist/providers/auth/token-refresh/index.js +7 -0
- package/dist/providers/auth/token-refresh/index.js.map +1 -0
- package/dist/providers/auth/token-refresh/token-state.d.ts +17 -0
- package/dist/providers/auth/token-refresh/token-state.js +30 -0
- package/dist/providers/auth/token-refresh/token-state.js.map +1 -0
- package/dist/providers/auth/token-storage/index.d.ts +7 -0
- package/dist/providers/auth/token-storage/index.js +8 -0
- package/dist/providers/auth/token-storage/index.js.map +1 -0
- package/dist/providers/auth/token-storage/token-file-resolver.d.ts +12 -0
- package/dist/providers/auth/token-storage/token-file-resolver.js +117 -0
- package/dist/providers/auth/token-storage/token-file-resolver.js.map +1 -0
- package/dist/providers/auth/token-storage/token-persistence.d.ts +22 -0
- package/dist/providers/auth/token-storage/token-persistence.js +86 -0
- package/dist/providers/auth/token-storage/token-persistence.js.map +1 -0
- package/dist/providers/auth/tokenfile-auth.js +12 -9
- package/dist/providers/auth/tokenfile-auth.js.map +1 -1
- package/dist/providers/core/api/provider-config.d.ts +8 -0
- package/dist/providers/core/config/camoufox-launcher.d.ts +1 -0
- package/dist/providers/core/config/camoufox-launcher.js +40 -9
- package/dist/providers/core/config/camoufox-launcher.js.map +1 -1
- package/dist/providers/core/config/oauth-flows.js +7 -2
- package/dist/providers/core/config/oauth-flows.js.map +1 -1
- package/dist/providers/core/config/provider-debug-hooks.d.ts +0 -12
- package/dist/providers/core/config/provider-debug-hooks.js +16 -56
- package/dist/providers/core/config/provider-debug-hooks.js.map +1 -1
- package/dist/providers/core/config/provider-debug-output-utils.d.ts +38 -0
- package/dist/providers/core/config/provider-debug-output-utils.js +46 -0
- package/dist/providers/core/config/provider-debug-output-utils.js.map +1 -0
- package/dist/providers/core/config/provider-oauth-configs.js +13 -9
- package/dist/providers/core/config/provider-oauth-configs.js.map +1 -1
- package/dist/providers/core/runtime/antigravity-request-type.d.ts +2 -0
- package/dist/providers/core/runtime/antigravity-request-type.js +126 -0
- package/dist/providers/core/runtime/antigravity-request-type.js.map +1 -0
- package/dist/providers/core/runtime/base-provider-runtime-helpers.d.ts +27 -0
- package/dist/providers/core/runtime/base-provider-runtime-helpers.js +105 -0
- package/dist/providers/core/runtime/base-provider-runtime-helpers.js.map +1 -0
- package/dist/providers/core/runtime/base-provider-series-cooldown.d.ts +19 -0
- package/dist/providers/core/runtime/base-provider-series-cooldown.js +363 -0
- package/dist/providers/core/runtime/base-provider-series-cooldown.js.map +1 -0
- package/dist/providers/core/runtime/base-provider.d.ts +4 -35
- package/dist/providers/core/runtime/base-provider.js +20 -501
- package/dist/providers/core/runtime/base-provider.js.map +1 -1
- package/dist/providers/core/runtime/deepseek-http-provider-helpers.d.ts +32 -0
- package/dist/providers/core/runtime/deepseek-http-provider-helpers.js +301 -0
- package/dist/providers/core/runtime/deepseek-http-provider-helpers.js.map +1 -0
- package/dist/providers/core/runtime/deepseek-http-provider.d.ts +0 -3
- package/dist/providers/core/runtime/deepseek-http-provider.js +5 -127
- package/dist/providers/core/runtime/deepseek-http-provider.js.map +1 -1
- package/dist/providers/core/runtime/deepseek-session-pow-helpers.d.ts +21 -0
- package/dist/providers/core/runtime/deepseek-session-pow-helpers.js +99 -0
- package/dist/providers/core/runtime/deepseek-session-pow-helpers.js.map +1 -0
- package/dist/providers/core/runtime/deepseek-session-pow.js +13 -108
- package/dist/providers/core/runtime/deepseek-session-pow.js.map +1 -1
- package/dist/providers/core/runtime/gemini-cli-http-provider.d.ts +0 -15
- package/dist/providers/core/runtime/gemini-cli-http-provider.js +13 -303
- package/dist/providers/core/runtime/gemini-cli-http-provider.js.map +1 -1
- package/dist/providers/core/runtime/gemini-cli-response-postprocessor.d.ts +9 -0
- package/dist/providers/core/runtime/gemini-cli-response-postprocessor.js +85 -0
- package/dist/providers/core/runtime/gemini-cli-response-postprocessor.js.map +1 -0
- package/dist/providers/core/runtime/gemini-http-provider.js +2 -2
- package/dist/providers/core/runtime/gemini-http-provider.js.map +1 -1
- package/dist/providers/core/runtime/gemini-sse-normalizer.d.ts +25 -0
- package/dist/providers/core/runtime/gemini-sse-normalizer.js +159 -0
- package/dist/providers/core/runtime/gemini-sse-normalizer.js.map +1 -0
- package/dist/providers/core/runtime/http-request-executor.js +1 -48
- package/dist/providers/core/runtime/http-request-executor.js.map +1 -1
- package/dist/providers/core/runtime/http-transport-provider.d.ts +2 -48
- package/dist/providers/core/runtime/http-transport-provider.js +158 -1273
- package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
- package/dist/providers/core/runtime/provider-bootstrap-utils.d.ts +20 -0
- package/dist/providers/core/runtime/provider-bootstrap-utils.js +78 -0
- package/dist/providers/core/runtime/provider-bootstrap-utils.js.map +1 -0
- package/dist/providers/core/runtime/provider-factory-helpers.d.ts +19 -0
- package/dist/providers/core/runtime/provider-factory-helpers.js +203 -0
- package/dist/providers/core/runtime/provider-factory-helpers.js.map +1 -0
- package/dist/providers/core/runtime/provider-factory.d.ts +9 -7
- package/dist/providers/core/runtime/provider-factory.js +57 -214
- package/dist/providers/core/runtime/provider-factory.js.map +1 -1
- package/dist/providers/core/runtime/provider-family-profile-utils.d.ts +23 -0
- package/dist/providers/core/runtime/provider-family-profile-utils.js +57 -0
- package/dist/providers/core/runtime/provider-family-profile-utils.js.map +1 -0
- package/dist/providers/core/runtime/provider-http-executor-utils.d.ts +32 -0
- package/dist/providers/core/runtime/provider-http-executor-utils.js +92 -0
- package/dist/providers/core/runtime/provider-http-executor-utils.js.map +1 -0
- package/dist/providers/core/runtime/provider-iflow-business-error-utils.d.ts +15 -0
- package/dist/providers/core/runtime/provider-iflow-business-error-utils.js +49 -0
- package/dist/providers/core/runtime/provider-iflow-business-error-utils.js.map +1 -0
- package/dist/providers/core/runtime/provider-request-executor-deps-factory.d.ts +29 -0
- package/dist/providers/core/runtime/provider-request-executor-deps-factory.js +41 -0
- package/dist/providers/core/runtime/provider-request-executor-deps-factory.js.map +1 -0
- package/dist/providers/core/runtime/provider-request-header-orchestrator.d.ts +30 -0
- package/dist/providers/core/runtime/provider-request-header-orchestrator.js +91 -0
- package/dist/providers/core/runtime/provider-request-header-orchestrator.js.map +1 -0
- package/dist/providers/core/runtime/provider-request-preprocessor.d.ts +5 -0
- package/dist/providers/core/runtime/provider-request-preprocessor.js +39 -0
- package/dist/providers/core/runtime/provider-request-preprocessor.js.map +1 -0
- package/dist/providers/core/runtime/provider-request-shaping-utils.d.ts +37 -0
- package/dist/providers/core/runtime/provider-request-shaping-utils.js +65 -0
- package/dist/providers/core/runtime/provider-request-shaping-utils.js.map +1 -0
- package/dist/providers/core/runtime/provider-response-postprocessor.d.ts +7 -0
- package/dist/providers/core/runtime/provider-response-postprocessor.js +28 -0
- package/dist/providers/core/runtime/provider-response-postprocessor.js.map +1 -0
- package/dist/providers/core/runtime/provider-runtime-utils.d.ts +16 -0
- package/dist/providers/core/runtime/provider-runtime-utils.js +51 -0
- package/dist/providers/core/runtime/provider-runtime-utils.js.map +1 -0
- package/dist/providers/core/runtime/responses-provider-helpers.d.ts +37 -0
- package/dist/providers/core/runtime/responses-provider-helpers.js +212 -0
- package/dist/providers/core/runtime/responses-provider-helpers.js.map +1 -0
- package/dist/providers/core/runtime/responses-provider.d.ts +0 -10
- package/dist/providers/core/runtime/responses-provider.js +14 -224
- package/dist/providers/core/runtime/responses-provider.js.map +1 -1
- package/dist/providers/core/runtime/runtime-endpoint-resolver.d.ts +21 -0
- package/dist/providers/core/runtime/runtime-endpoint-resolver.js +64 -0
- package/dist/providers/core/runtime/runtime-endpoint-resolver.js.map +1 -0
- package/dist/providers/core/runtime/service-profile-resolver.d.ts +29 -0
- package/dist/providers/core/runtime/service-profile-resolver.js +88 -0
- package/dist/providers/core/runtime/service-profile-resolver.js.map +1 -0
- package/dist/providers/core/runtime/transport/auth-mode-utils.d.ts +13 -0
- package/dist/providers/core/runtime/transport/auth-mode-utils.js +43 -0
- package/dist/providers/core/runtime/transport/auth-mode-utils.js.map +1 -0
- package/dist/providers/core/runtime/transport/auth-provider-factory.d.ts +37 -0
- package/dist/providers/core/runtime/transport/auth-provider-factory.js +131 -0
- package/dist/providers/core/runtime/transport/auth-provider-factory.js.map +1 -0
- package/dist/providers/core/runtime/transport/header-utils.d.ts +15 -0
- package/dist/providers/core/runtime/transport/header-utils.js +85 -0
- package/dist/providers/core/runtime/transport/header-utils.js.map +1 -0
- package/dist/providers/core/runtime/transport/iflow-signer.d.ts +12 -0
- package/dist/providers/core/runtime/transport/iflow-signer.js +63 -0
- package/dist/providers/core/runtime/transport/iflow-signer.js.map +1 -0
- package/dist/providers/core/runtime/transport/index.d.ts +15 -0
- package/dist/providers/core/runtime/transport/index.js +16 -0
- package/dist/providers/core/runtime/transport/index.js.map +1 -0
- package/dist/providers/core/runtime/transport/oauth-header-preflight.d.ts +12 -0
- package/dist/providers/core/runtime/transport/oauth-header-preflight.js +56 -0
- package/dist/providers/core/runtime/transport/oauth-header-preflight.js.map +1 -0
- package/dist/providers/core/runtime/transport/oauth-recovery-handler.d.ts +34 -0
- package/dist/providers/core/runtime/transport/oauth-recovery-handler.js +126 -0
- package/dist/providers/core/runtime/transport/oauth-recovery-handler.js.map +1 -0
- package/dist/providers/core/runtime/transport/provider-payload-utils.d.ts +21 -0
- package/dist/providers/core/runtime/transport/provider-payload-utils.js +88 -0
- package/dist/providers/core/runtime/transport/provider-payload-utils.js.map +1 -0
- package/dist/providers/core/runtime/transport/request-header-builder.d.ts +24 -0
- package/dist/providers/core/runtime/transport/request-header-builder.js +90 -0
- package/dist/providers/core/runtime/transport/request-header-builder.js.map +1 -0
- package/dist/providers/core/runtime/transport/runtime-detector.d.ts +22 -0
- package/dist/providers/core/runtime/transport/runtime-detector.js +63 -0
- package/dist/providers/core/runtime/transport/runtime-detector.js.map +1 -0
- package/dist/providers/core/runtime/transport/session-header-utils.d.ts +8 -0
- package/dist/providers/core/runtime/transport/session-header-utils.js +72 -0
- package/dist/providers/core/runtime/transport/session-header-utils.js.map +1 -0
- package/dist/providers/core/runtime/vision-debug-utils.d.ts +2 -0
- package/dist/providers/core/runtime/vision-debug-utils.js +31 -0
- package/dist/providers/core/runtime/vision-debug-utils.js.map +1 -1
- package/dist/providers/core/strategies/oauth-auth-code-flow.d.ts +13 -0
- package/dist/providers/core/strategies/oauth-auth-code-flow.js +272 -55
- package/dist/providers/core/strategies/oauth-auth-code-flow.js.map +1 -1
- package/dist/providers/core/utils/snapshot-writer-buffer.d.ts +13 -0
- package/dist/providers/core/utils/snapshot-writer-buffer.js +39 -0
- package/dist/providers/core/utils/snapshot-writer-buffer.js.map +1 -0
- package/dist/providers/core/utils/snapshot-writer.js +75 -54
- package/dist/providers/core/utils/snapshot-writer.js.map +1 -1
- package/dist/providers/profile/families/antigravity-profile.js +2 -10
- package/dist/providers/profile/families/antigravity-profile.js.map +1 -1
- package/dist/providers/profile/families/deepseek-profile.d.ts +2 -0
- package/dist/providers/profile/families/deepseek-profile.js +110 -0
- package/dist/providers/profile/families/deepseek-profile.js.map +1 -0
- package/dist/providers/profile/families/iflow-profile.js +89 -10
- package/dist/providers/profile/families/iflow-profile.js.map +1 -1
- package/dist/providers/profile/provider-profile-loader.d.ts +5 -0
- package/dist/providers/profile/provider-profile-loader.js +35 -0
- package/dist/providers/profile/provider-profile-loader.js.map +1 -1
- package/dist/providers/profile/provider-profile.d.ts +16 -1
- package/dist/runtime/runtime-flags.js +1 -1
- package/dist/runtime/runtime-flags.js.map +1 -1
- package/dist/runtime/wasm-runtime/index.d.ts +56 -0
- package/dist/runtime/wasm-runtime/index.js +69 -0
- package/dist/runtime/wasm-runtime/index.js.map +1 -0
- package/dist/scripts/camoufox/launch-auth.mjs +158 -10
- package/dist/server/handlers/handler-response-utils.d.ts +13 -0
- package/dist/server/handlers/handler-response-utils.js +427 -0
- package/dist/server/handlers/handler-response-utils.js.map +1 -0
- package/dist/server/handlers/handler-utils.d.ts +2 -11
- package/dist/server/handlers/handler-utils.js +21 -421
- package/dist/server/handlers/handler-utils.js.map +1 -1
- package/dist/server/runtime/http-server/clock-client-reaper.d.ts +23 -0
- package/dist/server/runtime/http-server/clock-client-reaper.js +159 -0
- package/dist/server/runtime/http-server/clock-client-reaper.js.map +1 -0
- package/dist/server/runtime/http-server/clock-client-registry-utils.d.ts +87 -0
- package/dist/server/runtime/http-server/clock-client-registry-utils.js +276 -0
- package/dist/server/runtime/http-server/clock-client-registry-utils.js.map +1 -0
- package/dist/server/runtime/http-server/clock-client-registry.d.ts +5 -50
- package/dist/server/runtime/http-server/clock-client-registry.js +74 -320
- package/dist/server/runtime/http-server/clock-client-registry.js.map +1 -1
- package/dist/server/runtime/http-server/clock-client-route-utils.d.ts +12 -0
- package/dist/server/runtime/http-server/clock-client-route-utils.js +210 -0
- package/dist/server/runtime/http-server/clock-client-route-utils.js.map +1 -0
- package/dist/server/runtime/http-server/clock-client-routes.js +27 -201
- package/dist/server/runtime/http-server/clock-client-routes.js.map +1 -1
- package/dist/server/runtime/http-server/clock-daemon-log-throttle.d.ts +12 -0
- package/dist/server/runtime/http-server/clock-daemon-log-throttle.js +56 -0
- package/dist/server/runtime/http-server/clock-daemon-log-throttle.js.map +1 -0
- package/dist/server/runtime/http-server/daemon-admin/control-handler.js +143 -14
- package/dist/server/runtime/http-server/daemon-admin/control-handler.js.map +1 -1
- package/dist/server/runtime/http-server/daemon-admin/credentials-handler-utils.d.ts +19 -0
- package/dist/server/runtime/http-server/daemon-admin/credentials-handler-utils.js +107 -0
- package/dist/server/runtime/http-server/daemon-admin/credentials-handler-utils.js.map +1 -0
- package/dist/server/runtime/http-server/daemon-admin/credentials-handler.js +2 -104
- package/dist/server/runtime/http-server/daemon-admin/credentials-handler.js.map +1 -1
- package/dist/server/runtime/http-server/daemon-admin/providers-handler-routing-utils.d.ts +28 -0
- package/dist/server/runtime/http-server/daemon-admin/providers-handler-routing-utils.js +298 -0
- package/dist/server/runtime/http-server/daemon-admin/providers-handler-routing-utils.js.map +1 -0
- package/dist/server/runtime/http-server/daemon-admin/providers-handler-utils.d.ts +22 -0
- package/dist/server/runtime/http-server/daemon-admin/providers-handler-utils.js +211 -0
- package/dist/server/runtime/http-server/daemon-admin/providers-handler-utils.js.map +1 -0
- package/dist/server/runtime/http-server/daemon-admin/providers-handler.js +25 -454
- package/dist/server/runtime/http-server/daemon-admin/providers-handler.js.map +1 -1
- package/dist/server/runtime/http-server/daemon-admin/quota-handler.js +81 -32
- package/dist/server/runtime/http-server/daemon-admin/quota-handler.js.map +1 -1
- package/dist/server/runtime/http-server/daemon-admin/routecodex-x7e-gate.d.ts +22 -0
- package/dist/server/runtime/http-server/daemon-admin/routecodex-x7e-gate.js +70 -0
- package/dist/server/runtime/http-server/daemon-admin/routecodex-x7e-gate.js.map +1 -0
- package/dist/server/runtime/http-server/executor/antigravity-detector.d.ts +34 -0
- package/dist/server/runtime/http-server/executor/antigravity-detector.js +118 -0
- package/dist/server/runtime/http-server/executor/antigravity-detector.js.map +1 -0
- package/dist/server/runtime/http-server/executor/env-config.d.ts +13 -0
- package/dist/server/runtime/http-server/executor/env-config.js +20 -0
- package/dist/server/runtime/http-server/executor/env-config.js.map +1 -0
- package/dist/server/runtime/http-server/executor/index.d.ts +11 -0
- package/dist/server/runtime/http-server/executor/index.js +18 -0
- package/dist/server/runtime/http-server/executor/index.js.map +1 -0
- package/dist/server/runtime/http-server/executor/provider-request-context.d.ts +20 -0
- package/dist/server/runtime/http-server/executor/provider-request-context.js +38 -0
- package/dist/server/runtime/http-server/executor/provider-request-context.js.map +1 -0
- package/dist/server/runtime/http-server/executor/provider-response-converter.d.ts +23 -0
- package/dist/server/runtime/http-server/executor/provider-response-converter.js +337 -0
- package/dist/server/runtime/http-server/executor/provider-response-converter.js.map +1 -0
- package/dist/server/runtime/http-server/executor/provider-response-utils.d.ts +8 -0
- package/dist/server/runtime/http-server/executor/provider-response-utils.js +93 -0
- package/dist/server/runtime/http-server/executor/provider-response-utils.js.map +1 -0
- package/dist/server/runtime/http-server/executor/provider-runtime-resolver.d.ts +23 -0
- package/dist/server/runtime/http-server/executor/provider-runtime-resolver.js +85 -0
- package/dist/server/runtime/http-server/executor/provider-runtime-resolver.js.map +1 -0
- package/dist/server/runtime/http-server/executor/request-executor-core-utils.d.ts +7 -0
- package/dist/server/runtime/http-server/executor/request-executor-core-utils.js +39 -0
- package/dist/server/runtime/http-server/executor/request-executor-core-utils.js.map +1 -0
- package/dist/server/runtime/http-server/executor/request-retry-helpers.d.ts +16 -0
- package/dist/server/runtime/http-server/executor/request-retry-helpers.js +218 -0
- package/dist/server/runtime/http-server/executor/request-retry-helpers.js.map +1 -0
- package/dist/server/runtime/http-server/executor/retry-engine.d.ts +21 -0
- package/dist/server/runtime/http-server/executor/retry-engine.js +73 -0
- package/dist/server/runtime/http-server/executor/retry-engine.js.map +1 -0
- package/dist/server/runtime/http-server/executor/sse-error-handler.d.ts +14 -0
- package/dist/server/runtime/http-server/executor/sse-error-handler.js +127 -0
- package/dist/server/runtime/http-server/executor/sse-error-handler.js.map +1 -0
- package/dist/server/runtime/http-server/executor/usage-aggregator.d.ts +39 -0
- package/dist/server/runtime/http-server/executor/usage-aggregator.js +177 -0
- package/dist/server/runtime/http-server/executor/usage-aggregator.js.map +1 -0
- package/dist/server/runtime/http-server/executor/usage-logger.d.ts +7 -0
- package/dist/server/runtime/http-server/executor/usage-logger.js +13 -0
- package/dist/server/runtime/http-server/executor/usage-logger.js.map +1 -0
- package/dist/server/runtime/http-server/executor/utils.d.ts +21 -0
- package/dist/server/runtime/http-server/executor/utils.js +62 -0
- package/dist/server/runtime/http-server/executor/utils.js.map +1 -0
- package/dist/server/runtime/http-server/executor-metadata.js +83 -2
- package/dist/server/runtime/http-server/executor-metadata.js.map +1 -1
- package/dist/server/runtime/http-server/executor-response.js +17 -9
- package/dist/server/runtime/http-server/executor-response.js.map +1 -1
- package/dist/server/runtime/http-server/http-server-bootstrap.d.ts +31 -0
- package/dist/server/runtime/http-server/http-server-bootstrap.js +367 -0
- package/dist/server/runtime/http-server/http-server-bootstrap.js.map +1 -0
- package/dist/server/runtime/http-server/http-server-clock-daemon.d.ts +5 -0
- package/dist/server/runtime/http-server/http-server-clock-daemon.js +242 -0
- package/dist/server/runtime/http-server/http-server-clock-daemon.js.map +1 -0
- package/dist/server/runtime/http-server/http-server-legacy-pipeline.d.ts +2 -0
- package/dist/server/runtime/http-server/http-server-legacy-pipeline.js +65 -0
- package/dist/server/runtime/http-server/http-server-legacy-pipeline.js.map +1 -0
- package/dist/server/runtime/http-server/http-server-lifecycle.d.ts +27 -0
- package/dist/server/runtime/http-server/http-server-lifecycle.js +285 -0
- package/dist/server/runtime/http-server/http-server-lifecycle.js.map +1 -0
- package/dist/server/runtime/http-server/http-server-runtime-providers.d.ts +10 -0
- package/dist/server/runtime/http-server/http-server-runtime-providers.js +415 -0
- package/dist/server/runtime/http-server/http-server-runtime-providers.js.map +1 -0
- package/dist/server/runtime/http-server/http-server-runtime-setup.d.ts +2 -0
- package/dist/server/runtime/http-server/http-server-runtime-setup.js +93 -0
- package/dist/server/runtime/http-server/http-server-runtime-setup.js.map +1 -0
- package/dist/server/runtime/http-server/index.d.ts +2 -46
- package/dist/server/runtime/http-server/index.js +96 -2615
- package/dist/server/runtime/http-server/index.js.map +1 -1
- package/dist/server/runtime/http-server/request-executor.d.ts +8 -21
- package/dist/server/runtime/http-server/request-executor.js +94 -956
- package/dist/server/runtime/http-server/request-executor.js.map +1 -1
- package/dist/server/runtime/http-server/routes.js +2 -2
- package/dist/server/runtime/http-server/routes.js.map +1 -1
- package/dist/server/runtime/http-server/servertool-admin-state.d.ts +42 -0
- package/dist/server/runtime/http-server/servertool-admin-state.js +210 -0
- package/dist/server/runtime/http-server/servertool-admin-state.js.map +1 -0
- package/dist/server/runtime/http-server/stats-manager-internals.d.ts +96 -0
- package/dist/server/runtime/http-server/stats-manager-internals.js +311 -0
- package/dist/server/runtime/http-server/stats-manager-internals.js.map +1 -0
- package/dist/server/runtime/http-server/stats-manager-table.d.ts +6 -0
- package/dist/server/runtime/http-server/stats-manager-table.js +135 -0
- package/dist/server/runtime/http-server/stats-manager-table.js.map +1 -0
- package/dist/server/runtime/http-server/stats-manager.d.ts +0 -23
- package/dist/server/runtime/http-server/stats-manager.js +95 -483
- package/dist/server/runtime/http-server/stats-manager.js.map +1 -1
- package/dist/server/utils/client-connection-state.js +61 -0
- package/dist/server/utils/client-connection-state.js.map +1 -1
- package/dist/server/utils/request-id-manager.d.ts +6 -0
- package/dist/server/utils/request-id-manager.js +105 -15
- package/dist/server/utils/request-id-manager.js.map +1 -1
- package/dist/server/utils/stage-logger.js +14 -4
- package/dist/server/utils/stage-logger.js.map +1 -1
- package/dist/server-lifecycle/index.d.ts +6 -0
- package/dist/server-lifecycle/index.js +7 -0
- package/dist/server-lifecycle/index.js.map +1 -0
- package/dist/server-lifecycle/port-utils.d.ts +18 -0
- package/dist/server-lifecycle/port-utils.js +204 -0
- package/dist/server-lifecycle/port-utils.js.map +1 -0
- package/dist/sharedmodule/process-snapshot.d.ts +26 -0
- package/dist/sharedmodule/process-snapshot.js +141 -0
- package/dist/sharedmodule/process-snapshot.js.map +1 -0
- package/dist/token-daemon/index.js +10 -3
- package/dist/token-daemon/index.js.map +1 -1
- package/dist/token-daemon/token-daemon.js +9 -11
- package/dist/token-daemon/token-daemon.js.map +1 -1
- package/dist/token-daemon/token-utils.d.ts +1 -1
- package/dist/token-daemon/token-utils.js +19 -3
- package/dist/token-daemon/token-utils.js.map +1 -1
- package/dist/tools/semantic-replay-snapshot-loader.d.ts +4 -0
- package/dist/tools/semantic-replay-snapshot-loader.js +396 -0
- package/dist/tools/semantic-replay-snapshot-loader.js.map +1 -0
- package/dist/tools/semantic-replay.js +2 -393
- package/dist/tools/semantic-replay.js.map +1 -1
- package/dist/utils/daemon-stop-intent.d.ts +17 -0
- package/dist/utils/daemon-stop-intent.js +104 -0
- package/dist/utils/daemon-stop-intent.js.map +1 -0
- package/dist/utils/key-429-tracker.js +6 -5
- package/dist/utils/key-429-tracker.js.map +1 -1
- package/dist/utils/managed-server-pids.js +44 -6
- package/dist/utils/managed-server-pids.js.map +1 -1
- package/dist/utils/pipeline-health-manager.js +7 -6
- package/dist/utils/pipeline-health-manager.js.map +1 -1
- package/dist/utils/process-lifecycle-logger.js +45 -1
- package/dist/utils/process-lifecycle-logger.js.map +1 -1
- package/dist/utils/runtime-exit-forensics.d.ts +2 -2
- package/dist/utils/runtime-exit-forensics.js +10 -5
- package/dist/utils/runtime-exit-forensics.js.map +1 -1
- package/dist/utils/snapshot-writer.js +3 -3
- package/dist/utils/snapshot-writer.js.map +1 -1
- package/docs/QUOTA_MANAGER_V3.md +3 -0
- package/docs/VIRTUAL_ROUTER_PRIORITY_AND_HEALTH.md +114 -0
- package/docs/daemon-admin-ui.html +268 -11
- package/docs/file-line-limit-gate.md +30 -0
- package/docs/refactoring/host-164.3-responsibility-migration.md +62 -0
- package/docs/release-iflow-400-gate.md +58 -0
- package/docs/replay-evidence-iflow-400.txt +33 -0
- package/docs/stop-message-auto.md +4 -3
- package/package.json +4 -3
- package/scripts/auth-iflow-manual.mjs +13 -23
- package/scripts/camoufox/launch-auth.mjs +158 -10
- package/scripts/ci/check-file-line-limit.mjs +149 -0
- package/scripts/copy-compat-assets.mjs +26 -0
- package/scripts/tests/ci-jest.mjs +4 -0
- package/scripts/verify-codex-error-samples.mjs +27 -6
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base Provider - 基础Provider抽象类
|
|
3
|
-
*
|
|
4
|
-
* 提供Provider的通用实现和抽象方法定义
|
|
5
|
-
*/
|
|
6
|
-
import { attachProviderRuntimeMetadata, extractProviderRuntimeMetadata } from './provider-runtime-metadata.js';
|
|
7
1
|
import { emitProviderError, buildRuntimeFromProviderContext } from '../utils/provider-error-reporter.js';
|
|
8
|
-
import { normalizeProviderFamily, normalizeProviderType, providerTypeToProtocol } from '../utils/provider-type-utils.js';
|
|
9
2
|
import { classifyProviderError } from './provider-error-classifier.js';
|
|
10
3
|
import { getStatsCenterSafe as getStatsCenterSafeFromBridge } from '../../../modules/llmswitch/bridge.js';
|
|
11
4
|
import { RateLimitCooldownError } from './rate-limit-manager.js';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const SERIES_COOLDOWN_MAX_MS = 3 * 60 * 60_000;
|
|
15
|
-
/**
|
|
16
|
-
* 基础Provider抽象类
|
|
17
|
-
*
|
|
18
|
-
* 为所有Provider实现提供通用逻辑和抽象方法定义
|
|
19
|
-
*/
|
|
5
|
+
import { createProviderContext, extractUsageTokensFromResponse, hasDataEnvelope, reattachRuntimeMetadata, truncateLogMessage } from './base-provider-runtime-helpers.js';
|
|
6
|
+
import { buildSeriesCooldownDetail, isDailyLimitRateLimitMessage, parseDurationToMs as parseSeriesCooldownDurationToMs, SERIES_COOLDOWN_DETAIL_KEY } from './base-provider-series-cooldown.js';
|
|
20
7
|
export class BaseProvider {
|
|
21
8
|
id;
|
|
22
9
|
providerType;
|
|
@@ -96,7 +83,7 @@ export class BaseProvider {
|
|
|
96
83
|
});
|
|
97
84
|
// 预处理请求
|
|
98
85
|
const processedRequest = await this.preprocessRequest(request);
|
|
99
|
-
|
|
86
|
+
reattachRuntimeMetadata(processedRequest, runtimeMetadata);
|
|
100
87
|
// 发送请求 (子类实现)
|
|
101
88
|
const response = await this.sendRequest(processedRequest);
|
|
102
89
|
// 后处理响应
|
|
@@ -125,7 +112,7 @@ export class BaseProvider {
|
|
|
125
112
|
this.lastActivity = Date.now();
|
|
126
113
|
// 预处理请求
|
|
127
114
|
const processedRequest = await this.preprocessRequest(request);
|
|
128
|
-
|
|
115
|
+
reattachRuntimeMetadata(processedRequest, runtimeMetadata);
|
|
129
116
|
// 发送请求 (子类实现)
|
|
130
117
|
const response = await this.sendRequestInternal(processedRequest);
|
|
131
118
|
// 后处理响应
|
|
@@ -133,7 +120,7 @@ export class BaseProvider {
|
|
|
133
120
|
const endTime = Date.now();
|
|
134
121
|
this.resetRateLimitCounter(context.providerKey, context.model);
|
|
135
122
|
try {
|
|
136
|
-
const usage =
|
|
123
|
+
const usage = extractUsageTokensFromResponse(finalResponse);
|
|
137
124
|
const event = {
|
|
138
125
|
requestId: context.requestId,
|
|
139
126
|
timestamp: endTime,
|
|
@@ -239,95 +226,25 @@ export class BaseProvider {
|
|
|
239
226
|
getCurrentRuntimeMetadata() {
|
|
240
227
|
return this.lastRuntimeMetadata;
|
|
241
228
|
}
|
|
242
|
-
extractUsageTokensFromResponse(finalResponse) {
|
|
243
|
-
if (!finalResponse || typeof finalResponse !== 'object') {
|
|
244
|
-
return {};
|
|
245
|
-
}
|
|
246
|
-
const container = finalResponse;
|
|
247
|
-
const meta = (container.metadata && typeof container.metadata === 'object')
|
|
248
|
-
? container.metadata
|
|
249
|
-
: undefined;
|
|
250
|
-
const usageNode = meta && meta.usage && typeof meta.usage === 'object'
|
|
251
|
-
? meta.usage
|
|
252
|
-
: (container.usage && typeof container.usage === 'object'
|
|
253
|
-
? container.usage
|
|
254
|
-
: undefined);
|
|
255
|
-
if (!usageNode) {
|
|
256
|
-
return {};
|
|
257
|
-
}
|
|
258
|
-
const readNumber = (value) => {
|
|
259
|
-
if (typeof value !== 'number') {
|
|
260
|
-
return undefined;
|
|
261
|
-
}
|
|
262
|
-
if (!Number.isFinite(value)) {
|
|
263
|
-
return undefined;
|
|
264
|
-
}
|
|
265
|
-
return value;
|
|
266
|
-
};
|
|
267
|
-
const promptTokens = readNumber(usageNode.prompt_tokens) ??
|
|
268
|
-
readNumber(usageNode.promptTokens) ??
|
|
269
|
-
readNumber(usageNode.input_tokens) ??
|
|
270
|
-
readNumber(usageNode.inputTokens);
|
|
271
|
-
const completionTokens = readNumber(usageNode.completion_tokens) ??
|
|
272
|
-
readNumber(usageNode.completionTokens) ??
|
|
273
|
-
readNumber(usageNode.output_tokens) ??
|
|
274
|
-
readNumber(usageNode.outputTokens);
|
|
275
|
-
let totalTokens = readNumber(usageNode.total_tokens) ??
|
|
276
|
-
readNumber(usageNode.totalTokens);
|
|
277
|
-
if (totalTokens === undefined && (promptTokens !== undefined || completionTokens !== undefined)) {
|
|
278
|
-
totalTokens = (promptTokens ?? 0) + (completionTokens ?? 0);
|
|
279
|
-
}
|
|
280
|
-
return { promptTokens, completionTokens, totalTokens };
|
|
281
|
-
}
|
|
282
229
|
createContext(request) {
|
|
283
|
-
const runtimeMetadata = extractProviderRuntimeMetadata(request);
|
|
284
|
-
this.lastRuntimeMetadata = runtimeMetadata;
|
|
285
230
|
const runtimeProfile = this.getRuntimeProfile();
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const providerFamily = normalizeProviderFamily(runtimeMetadata?.providerFamily, runtimeMetadata?.providerId, runtimeMetadata?.providerKey, runtimeProfile?.providerFamily, runtimeProfile?.providerId, this.config.config.providerId, this.config.config.providerType);
|
|
295
|
-
const providerProtocol = runtimeMetadata?.providerProtocol ||
|
|
296
|
-
providerTypeToProtocol(providerType);
|
|
297
|
-
const context = {
|
|
298
|
-
requestId: runtimeMetadata?.requestId || `req-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
299
|
-
providerType,
|
|
300
|
-
providerFamily,
|
|
301
|
-
startTime: Date.now(),
|
|
302
|
-
model: payloadModel ?? runtimeModel,
|
|
303
|
-
hasTools: this.hasTools(payload),
|
|
304
|
-
metadata: runtimeMetadata?.metadata || {},
|
|
305
|
-
providerId: runtimeMetadata?.providerId || runtimeMetadata?.providerKey || runtimeProfile?.providerId,
|
|
306
|
-
providerKey: runtimeMetadata?.providerKey || runtimeProfile?.providerKey,
|
|
307
|
-
providerProtocol,
|
|
308
|
-
routeName: runtimeMetadata?.routeName,
|
|
309
|
-
target: runtimeMetadata?.target,
|
|
310
|
-
runtimeMetadata,
|
|
311
|
-
pipelineId: runtimeMetadata?.pipelineId
|
|
312
|
-
};
|
|
231
|
+
const { context, runtimeMetadata } = createProviderContext({
|
|
232
|
+
request,
|
|
233
|
+
providerType: this.providerType,
|
|
234
|
+
runtimeProfile,
|
|
235
|
+
configProviderId: this.config.config.providerId,
|
|
236
|
+
configProviderType: this.config.config.providerType
|
|
237
|
+
});
|
|
238
|
+
this.lastRuntimeMetadata = runtimeMetadata;
|
|
313
239
|
return context;
|
|
314
240
|
}
|
|
315
|
-
reattachRuntimeMetadata(payload, metadata) {
|
|
316
|
-
if (!metadata || !payload || typeof payload !== 'object') {
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
const target = this.hasDataEnvelope(payload) && payload.data && typeof payload.data === 'object'
|
|
320
|
-
? payload.data
|
|
321
|
-
: payload;
|
|
322
|
-
attachProviderRuntimeMetadata(target, metadata);
|
|
323
|
-
}
|
|
324
241
|
handleRequestError(error, _context) {
|
|
325
242
|
const now = Date.now();
|
|
326
243
|
const runtimeProfile = this.getRuntimeProfile();
|
|
327
244
|
const classification = classifyProviderError({
|
|
328
245
|
error,
|
|
329
246
|
context: _context,
|
|
330
|
-
detectDailyLimit: (messageLower, upstreamLower) =>
|
|
247
|
+
detectDailyLimit: (messageLower, upstreamLower) => isDailyLimitRateLimitMessage(messageLower, upstreamLower),
|
|
331
248
|
registerRateLimitFailure: this.registerRateLimitFailure.bind(this),
|
|
332
249
|
forceRateLimitFailure: this.forceRateLimitFailure.bind(this),
|
|
333
250
|
authMode: this.authMode
|
|
@@ -346,12 +263,12 @@ export class BaseProvider {
|
|
|
346
263
|
// 仅负责从上游错误中提取配额冷却信息,并通过 virtualRouterSeriesCooldown
|
|
347
264
|
// 提供给 llmswitch-core 的 VirtualRouter。具体的 alias / series 冷却与重路由
|
|
348
265
|
// 逻辑完全由 VirtualRouterEngine 处理,Provider 层不再维护独立的 backoff 状态。
|
|
349
|
-
seriesCooldownDetail =
|
|
266
|
+
seriesCooldownDetail = buildSeriesCooldownDetail(augmentedError, _context, runtimeProfile, providerKey);
|
|
350
267
|
}
|
|
351
268
|
const affectsHealth = classification.affectsHealth;
|
|
352
269
|
const recoverable = classification.forceFatalRateLimit ? false : classification.recoverable;
|
|
353
|
-
const logErrorMessage = typeof msg === 'string' ?
|
|
354
|
-
const logUpstreamMessage = typeof upstreamMessage === 'string' ?
|
|
270
|
+
const logErrorMessage = typeof msg === 'string' ? truncateLogMessage(msg) : msg;
|
|
271
|
+
const logUpstreamMessage = typeof upstreamMessage === 'string' ? truncateLogMessage(upstreamMessage) : upstreamMessage;
|
|
355
272
|
this.dependencies.logger?.logModule(this.getLogId(), 'request-error', {
|
|
356
273
|
requestId: _context.requestId,
|
|
357
274
|
error: logErrorMessage,
|
|
@@ -408,26 +325,11 @@ export class BaseProvider {
|
|
|
408
325
|
details: enrichedDetails
|
|
409
326
|
});
|
|
410
327
|
}
|
|
411
|
-
unwrapRequestPayload(request) {
|
|
412
|
-
if (this.hasDataEnvelope(request) && request.data && typeof request.data === 'object') {
|
|
413
|
-
return request.data;
|
|
414
|
-
}
|
|
415
|
-
return request;
|
|
416
|
-
}
|
|
417
|
-
hasDataEnvelope(value) {
|
|
418
|
-
return Boolean(value && typeof value === 'object' && 'data' in value);
|
|
419
|
-
}
|
|
420
|
-
hasTools(payload) {
|
|
421
|
-
const tools = payload['tools'];
|
|
422
|
-
if (Array.isArray(tools)) {
|
|
423
|
-
return tools.length > 0;
|
|
424
|
-
}
|
|
425
|
-
return Boolean(tools);
|
|
426
|
-
}
|
|
427
328
|
enforceRateLimitWindow(_context) {
|
|
428
329
|
// 冷却窗口治理收敛到 llmswitch-core VirtualRouter。
|
|
429
330
|
// Provider 层不在此处主动拦截请求,避免与 VirtualRouter 的健康状态重复。
|
|
430
331
|
}
|
|
332
|
+
hasDataEnvelope(value) { return hasDataEnvelope(value); }
|
|
431
333
|
getRateLimitBucketKey(providerKey, model) {
|
|
432
334
|
if (!providerKey) {
|
|
433
335
|
return undefined;
|
|
@@ -480,392 +382,9 @@ export class BaseProvider {
|
|
|
480
382
|
}
|
|
481
383
|
BaseProvider.rateLimitFailures.set(bucketKey, BaseProvider.RATE_LIMIT_THRESHOLD);
|
|
482
384
|
}
|
|
483
|
-
|
|
484
|
-
const normalizedProviderId = BaseProvider.normalizeSeriesProviderId(runtimeProfile?.providerId || _context.providerId, providerKey);
|
|
485
|
-
if (!normalizedProviderId) {
|
|
486
|
-
return null;
|
|
487
|
-
}
|
|
488
|
-
const topLevelId = BaseProvider.extractTopLevelProviderId(normalizedProviderId);
|
|
489
|
-
if (!topLevelId || !SERIES_COOLDOWN_PROVIDER_IDS.has(topLevelId.toLowerCase())) {
|
|
490
|
-
return null;
|
|
491
|
-
}
|
|
492
|
-
const extracted = BaseProvider.extractQuotaResetDelayWithSource(error);
|
|
493
|
-
if (!extracted) {
|
|
494
|
-
return null;
|
|
495
|
-
}
|
|
496
|
-
const rawDelay = extracted.delay;
|
|
497
|
-
const cooldownMs = BaseProvider.parseDurationToMs(rawDelay);
|
|
498
|
-
if (!cooldownMs || cooldownMs <= 0) {
|
|
499
|
-
return null;
|
|
500
|
-
}
|
|
501
|
-
const cappedCooldownMs = Math.min(cooldownMs, SERIES_COOLDOWN_MAX_MS);
|
|
502
|
-
const modelId = BaseProvider.resolveContextModel(_context, runtimeProfile, providerKey);
|
|
503
|
-
const series = BaseProvider.resolveModelSeries(modelId);
|
|
504
|
-
if (!modelId || series === 'default') {
|
|
505
|
-
return null;
|
|
506
|
-
}
|
|
507
|
-
return {
|
|
508
|
-
scope: 'model-series',
|
|
509
|
-
providerId: normalizedProviderId,
|
|
510
|
-
providerKey,
|
|
511
|
-
model: modelId,
|
|
512
|
-
series,
|
|
513
|
-
cooldownMs: cappedCooldownMs,
|
|
514
|
-
quotaResetDelay: rawDelay,
|
|
515
|
-
source: extracted.source,
|
|
516
|
-
expiresAt: Date.now() + cappedCooldownMs
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
static extractQuotaResetDelayWithSource(error) {
|
|
520
|
-
if (!error) {
|
|
521
|
-
return null;
|
|
522
|
-
}
|
|
523
|
-
const response = error.response;
|
|
524
|
-
const textSources = [];
|
|
525
|
-
const objectSources = [];
|
|
526
|
-
const rawData = response?.data;
|
|
527
|
-
const dataNode = BaseProvider.normalizeObjectCandidate(rawData);
|
|
528
|
-
if (dataNode) {
|
|
529
|
-
objectSources.push(dataNode);
|
|
530
|
-
const errBlock = BaseProvider.normalizeObjectCandidate(dataNode?.error);
|
|
531
|
-
if (errBlock) {
|
|
532
|
-
objectSources.push(errBlock);
|
|
533
|
-
const details = errBlock?.details;
|
|
534
|
-
if (Array.isArray(details)) {
|
|
535
|
-
for (const detail of details) {
|
|
536
|
-
const normalizedDetail = BaseProvider.normalizeObjectCandidate(detail);
|
|
537
|
-
if (normalizedDetail) {
|
|
538
|
-
objectSources.push(normalizedDetail);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
const errMessage = errBlock?.message;
|
|
543
|
-
if (typeof errMessage === 'string') {
|
|
544
|
-
textSources.push(errMessage);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
else if (typeof rawData === 'string') {
|
|
549
|
-
textSources.push(rawData);
|
|
550
|
-
}
|
|
551
|
-
if (error && typeof error === 'object') {
|
|
552
|
-
objectSources.push(error);
|
|
553
|
-
}
|
|
554
|
-
if (typeof error.message === 'string') {
|
|
555
|
-
textSources.push(error.message);
|
|
556
|
-
}
|
|
557
|
-
const upstreamMessage = error.upstreamMessage;
|
|
558
|
-
if (typeof upstreamMessage === 'string') {
|
|
559
|
-
textSources.push(upstreamMessage);
|
|
560
|
-
}
|
|
561
|
-
for (const source of objectSources) {
|
|
562
|
-
const candidate = BaseProvider.extractQuotaDelayFromObject(source);
|
|
563
|
-
if (candidate) {
|
|
564
|
-
return { delay: candidate, source: 'quota_reset_delay' };
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
for (const text of textSources) {
|
|
568
|
-
const candidate = BaseProvider.extractQuotaDelayFromString(text);
|
|
569
|
-
if (candidate) {
|
|
570
|
-
return { delay: candidate, source: 'quota_reset_delay' };
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
// 若未在结构化字段中发现 quotaResetDelay / quotaResetTimeStamp,
|
|
574
|
-
// 则根据常见文案模式做一次保守的回退解析,给出一个近似的冷却窗口,
|
|
575
|
-
// 以便 VirtualRouter 至少可以对整条系列做一次降温,而不是在明显「额度耗尽」
|
|
576
|
-
// 的情况下持续命中上游 429。
|
|
577
|
-
const fallback = BaseProvider.extractFallbackQuotaDelayFromTexts(textSources);
|
|
578
|
-
if (fallback) {
|
|
579
|
-
return fallback;
|
|
580
|
-
}
|
|
581
|
-
return null;
|
|
582
|
-
}
|
|
583
|
-
static extractQuotaDelayFromObject(source) {
|
|
584
|
-
if (!source || typeof source !== 'object') {
|
|
585
|
-
return undefined;
|
|
586
|
-
}
|
|
587
|
-
const record = source;
|
|
588
|
-
const directDelay = record.quotaResetDelay;
|
|
589
|
-
if (typeof directDelay === 'string' && directDelay.trim().length) {
|
|
590
|
-
return directDelay.trim();
|
|
591
|
-
}
|
|
592
|
-
const metadata = record.metadata;
|
|
593
|
-
if (metadata && typeof metadata === 'object') {
|
|
594
|
-
const metaDelay = metadata.quotaResetDelay;
|
|
595
|
-
if (typeof metaDelay === 'string' && metaDelay.trim().length) {
|
|
596
|
-
return metaDelay.trim();
|
|
597
|
-
}
|
|
598
|
-
const metaResetTs = metadata.quotaResetTimeStamp;
|
|
599
|
-
if (typeof metaResetTs === 'string' && metaResetTs.trim().length) {
|
|
600
|
-
const ttlMs = BaseProvider.computeTtlFromTimestamp(metaResetTs.trim());
|
|
601
|
-
if (ttlMs && ttlMs > 0) {
|
|
602
|
-
return `${Math.round(ttlMs / 1000)}s`;
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
const directResetTs = record.quotaResetTimeStamp;
|
|
607
|
-
if (typeof directResetTs === 'string' && directResetTs.trim().length) {
|
|
608
|
-
const ttlMs = BaseProvider.computeTtlFromTimestamp(directResetTs.trim());
|
|
609
|
-
if (ttlMs && ttlMs > 0) {
|
|
610
|
-
return `${Math.round(ttlMs / 1000)}s`;
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
return undefined;
|
|
614
|
-
}
|
|
615
|
-
static computeTtlFromTimestamp(value) {
|
|
616
|
-
if (!value || typeof value !== 'string') {
|
|
617
|
-
return null;
|
|
618
|
-
}
|
|
619
|
-
const parsed = Date.parse(value);
|
|
620
|
-
if (!Number.isFinite(parsed)) {
|
|
621
|
-
return null;
|
|
622
|
-
}
|
|
623
|
-
const now = Date.now();
|
|
624
|
-
const diff = parsed - now;
|
|
625
|
-
if (!Number.isFinite(diff) || diff <= 0) {
|
|
626
|
-
return null;
|
|
627
|
-
}
|
|
628
|
-
return Math.round(diff);
|
|
629
|
-
}
|
|
385
|
+
// Kept for compatibility with existing tests/introspection helpers.
|
|
630
386
|
static parseDurationToMs(value) {
|
|
631
|
-
|
|
632
|
-
return null;
|
|
633
|
-
}
|
|
634
|
-
const pattern = /(\d+(?:\.\d+)?)(ms|s|m|h)/gi;
|
|
635
|
-
let totalMs = 0;
|
|
636
|
-
let matched = false;
|
|
637
|
-
let match;
|
|
638
|
-
while ((match = pattern.exec(value)) !== null) {
|
|
639
|
-
matched = true;
|
|
640
|
-
const amount = Number.parseFloat(match[1]);
|
|
641
|
-
if (!Number.isFinite(amount)) {
|
|
642
|
-
continue;
|
|
643
|
-
}
|
|
644
|
-
const unit = match[2].toLowerCase();
|
|
645
|
-
if (unit === 'ms') {
|
|
646
|
-
totalMs += amount;
|
|
647
|
-
}
|
|
648
|
-
else if (unit === 'h') {
|
|
649
|
-
totalMs += amount * 3_600_000;
|
|
650
|
-
}
|
|
651
|
-
else if (unit === 'm') {
|
|
652
|
-
totalMs += amount * 60_000;
|
|
653
|
-
}
|
|
654
|
-
else if (unit === 's') {
|
|
655
|
-
totalMs += amount * 1_000;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
if (!matched) {
|
|
659
|
-
const seconds = Number.parseFloat(value);
|
|
660
|
-
if (Number.isFinite(seconds)) {
|
|
661
|
-
totalMs = seconds * 1_000;
|
|
662
|
-
matched = true;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
if (!matched || totalMs <= 0) {
|
|
666
|
-
return null;
|
|
667
|
-
}
|
|
668
|
-
return Math.round(totalMs);
|
|
669
|
-
}
|
|
670
|
-
static normalizeSeriesProviderId(providerId, providerKey) {
|
|
671
|
-
const aliasFromKey = BaseProvider.extractProviderAliasId(providerKey);
|
|
672
|
-
if (aliasFromKey) {
|
|
673
|
-
return aliasFromKey;
|
|
674
|
-
}
|
|
675
|
-
const aliasFromId = BaseProvider.extractProviderAliasId(providerId);
|
|
676
|
-
if (aliasFromId) {
|
|
677
|
-
return aliasFromId;
|
|
678
|
-
}
|
|
679
|
-
const topFromKey = BaseProvider.extractTopLevelProviderId(providerKey);
|
|
680
|
-
if (topFromKey) {
|
|
681
|
-
return topFromKey;
|
|
682
|
-
}
|
|
683
|
-
return BaseProvider.extractTopLevelProviderId(providerId);
|
|
684
|
-
}
|
|
685
|
-
static normalizeObjectCandidate(value) {
|
|
686
|
-
if (!value) {
|
|
687
|
-
return null;
|
|
688
|
-
}
|
|
689
|
-
if (typeof value === 'object') {
|
|
690
|
-
return value;
|
|
691
|
-
}
|
|
692
|
-
if (typeof value === 'string') {
|
|
693
|
-
const trimmed = value.trim();
|
|
694
|
-
if (!trimmed) {
|
|
695
|
-
return null;
|
|
696
|
-
}
|
|
697
|
-
try {
|
|
698
|
-
const parsed = JSON.parse(trimmed);
|
|
699
|
-
if (parsed && typeof parsed === 'object') {
|
|
700
|
-
return parsed;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
catch {
|
|
704
|
-
return null;
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
return null;
|
|
708
|
-
}
|
|
709
|
-
static extractQuotaDelayFromString(text) {
|
|
710
|
-
if (typeof text !== 'string' || !text) {
|
|
711
|
-
return undefined;
|
|
712
|
-
}
|
|
713
|
-
const match = text.match(/quotaResetDelay["']?\s*[:=]\s*"([^"]+)"/i);
|
|
714
|
-
if (match && match[1]) {
|
|
715
|
-
const normalized = match[1].trim();
|
|
716
|
-
return normalized.length ? normalized : undefined;
|
|
717
|
-
}
|
|
718
|
-
return undefined;
|
|
719
|
-
}
|
|
720
|
-
static extractFallbackQuotaDelayFromTexts(texts) {
|
|
721
|
-
if (!Array.isArray(texts) || texts.length === 0) {
|
|
722
|
-
return null;
|
|
723
|
-
}
|
|
724
|
-
const haystack = texts.join(' ').toLowerCase();
|
|
725
|
-
if (!haystack) {
|
|
726
|
-
return null;
|
|
727
|
-
}
|
|
728
|
-
// Antigravity / Gemini CLI: capacity exhausted (not quota depleted).
|
|
729
|
-
// Example: "No capacity available for model ..." with reason "MODEL_CAPACITY_EXHAUSTED".
|
|
730
|
-
// This is typically short-lived; apply a short series cooldown to avoid hammering every alias.
|
|
731
|
-
if (haystack.includes('no capacity available') ||
|
|
732
|
-
haystack.includes('model_capacity_exhausted') ||
|
|
733
|
-
haystack.includes('model capacity exhausted')) {
|
|
734
|
-
const envValue = (process.env.ROUTECODEX_RL_CAPACITY_COOLDOWN || process.env.RCC_RL_CAPACITY_COOLDOWN || '').trim();
|
|
735
|
-
return {
|
|
736
|
-
delay: envValue.length ? envValue : '30s',
|
|
737
|
-
source: 'capacity_exhausted_fallback'
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
|
-
// 针对常见的「额度/余额耗尽」类 429 文案给出保守的冷却时间,
|
|
741
|
-
// 用于 series 级别的降温,避免在明显 quota 用尽时持续命中上游:
|
|
742
|
-
// - Gemini: "Resource has been exhausted (e.g. check quota)."
|
|
743
|
-
// - 通用: "quota has been exhausted" / "quota exceeded"
|
|
744
|
-
// - GLM: "余额不足或无可用资源包"
|
|
745
|
-
if (haystack.includes('resource has been exhausted') ||
|
|
746
|
-
haystack.includes('resource exhausted') ||
|
|
747
|
-
haystack.includes('quota has been exhausted') ||
|
|
748
|
-
haystack.includes('quota exceeded') ||
|
|
749
|
-
haystack.includes('余额不足') ||
|
|
750
|
-
haystack.includes('无可用资源包')) {
|
|
751
|
-
// 默认按 5 分钟冷却整条系列,具体 TTL 只作为「第一时间」的保护,
|
|
752
|
-
// 真正的长周期拉黑/恢复由 daemon/QuotaManager 结合 VirtualRouter 健康状态统一管理。
|
|
753
|
-
// 若存在 ROUTECODEX_RL_DEFAULT_QUOTA_COOLDOWN / RCC_RL_DEFAULT_QUOTA_COOLDOWN,
|
|
754
|
-
// 则优先采用该环境变量,支持按部署环境调节冷却窗口(例如 1m / 30m / 2h)。
|
|
755
|
-
const envValue = (process.env.ROUTECODEX_RL_DEFAULT_QUOTA_COOLDOWN || process.env.RCC_RL_DEFAULT_QUOTA_COOLDOWN || '').trim();
|
|
756
|
-
return {
|
|
757
|
-
delay: envValue.length ? envValue : '5m',
|
|
758
|
-
source: 'quota_exhausted_fallback'
|
|
759
|
-
};
|
|
760
|
-
}
|
|
761
|
-
return null;
|
|
762
|
-
}
|
|
763
|
-
static extractTopLevelProviderId(source) {
|
|
764
|
-
if (!source || typeof source !== 'string') {
|
|
765
|
-
return undefined;
|
|
766
|
-
}
|
|
767
|
-
const trimmed = source.trim();
|
|
768
|
-
if (!trimmed) {
|
|
769
|
-
return undefined;
|
|
770
|
-
}
|
|
771
|
-
const firstDot = trimmed.indexOf('.');
|
|
772
|
-
if (firstDot <= 0) {
|
|
773
|
-
return trimmed;
|
|
774
|
-
}
|
|
775
|
-
return trimmed.slice(0, firstDot);
|
|
776
|
-
}
|
|
777
|
-
static extractProviderAliasId(source) {
|
|
778
|
-
if (!source || typeof source !== 'string') {
|
|
779
|
-
return undefined;
|
|
780
|
-
}
|
|
781
|
-
const trimmed = source.trim();
|
|
782
|
-
if (!trimmed) {
|
|
783
|
-
return undefined;
|
|
784
|
-
}
|
|
785
|
-
const segments = trimmed.split('.');
|
|
786
|
-
if (segments.length >= 2 && segments[0] && segments[1]) {
|
|
787
|
-
return `${segments[0]}.${segments[1]}`;
|
|
788
|
-
}
|
|
789
|
-
return undefined;
|
|
790
|
-
}
|
|
791
|
-
static resolveContextModel(_context, runtimeProfile, providerKey) {
|
|
792
|
-
if (typeof _context.model === 'string' && _context.model.trim().length) {
|
|
793
|
-
return _context.model.trim();
|
|
794
|
-
}
|
|
795
|
-
const target = _context.target;
|
|
796
|
-
if (target && typeof target === 'object') {
|
|
797
|
-
const candidate = target.clientModelId ||
|
|
798
|
-
target.modelId;
|
|
799
|
-
if (typeof candidate === 'string' && candidate.trim().length) {
|
|
800
|
-
return candidate.trim();
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
if (runtimeProfile?.defaultModel && runtimeProfile.defaultModel.trim().length) {
|
|
804
|
-
return runtimeProfile.defaultModel.trim();
|
|
805
|
-
}
|
|
806
|
-
if (providerKey) {
|
|
807
|
-
return BaseProvider.deriveModelIdFromProviderKey(providerKey);
|
|
808
|
-
}
|
|
809
|
-
return undefined;
|
|
810
|
-
}
|
|
811
|
-
static deriveModelIdFromProviderKey(providerKey) {
|
|
812
|
-
if (!providerKey) {
|
|
813
|
-
return undefined;
|
|
814
|
-
}
|
|
815
|
-
const firstDot = providerKey.indexOf('.');
|
|
816
|
-
if (firstDot <= 0 || firstDot === providerKey.length - 1) {
|
|
817
|
-
return undefined;
|
|
818
|
-
}
|
|
819
|
-
const remainder = providerKey.slice(firstDot + 1);
|
|
820
|
-
const secondDot = remainder.indexOf('.');
|
|
821
|
-
if (secondDot <= 0 || secondDot === remainder.length - 1) {
|
|
822
|
-
const trimmed = remainder.trim();
|
|
823
|
-
return trimmed || undefined;
|
|
824
|
-
}
|
|
825
|
-
const finalPart = remainder.slice(secondDot + 1).trim();
|
|
826
|
-
return finalPart || undefined;
|
|
827
|
-
}
|
|
828
|
-
static resolveModelSeries(model) {
|
|
829
|
-
if (!model) {
|
|
830
|
-
return 'default';
|
|
831
|
-
}
|
|
832
|
-
const lower = model.toLowerCase();
|
|
833
|
-
if (lower.includes('claude') || lower.includes('opus')) {
|
|
834
|
-
return 'claude';
|
|
835
|
-
}
|
|
836
|
-
if (lower.includes('flash')) {
|
|
837
|
-
return 'gemini-flash';
|
|
838
|
-
}
|
|
839
|
-
if (lower.includes('gemini') || lower.includes('pro')) {
|
|
840
|
-
return 'gemini-pro';
|
|
841
|
-
}
|
|
842
|
-
return 'default';
|
|
843
|
-
}
|
|
844
|
-
isDailyLimitRateLimit(messageLower, upstreamLower) {
|
|
845
|
-
const haystack = `${messageLower} ${upstreamLower ?? ''}`;
|
|
846
|
-
// Capacity exhausted != daily quota exhausted. Avoid marking it as a hard daily limit.
|
|
847
|
-
if (haystack.includes('no capacity available') ||
|
|
848
|
-
haystack.includes('model_capacity_exhausted') ||
|
|
849
|
-
haystack.includes('model capacity exhausted')) {
|
|
850
|
-
return false;
|
|
851
|
-
}
|
|
852
|
-
return (haystack.includes('daily cost limit') ||
|
|
853
|
-
haystack.includes('daily quota') ||
|
|
854
|
-
haystack.includes('quota has been exhausted') ||
|
|
855
|
-
haystack.includes('quota exceeded') ||
|
|
856
|
-
haystack.includes('resource has been exhausted') ||
|
|
857
|
-
haystack.includes('resource exhausted') ||
|
|
858
|
-
haystack.includes('resource_exhausted') ||
|
|
859
|
-
haystack.includes('费用限制') ||
|
|
860
|
-
haystack.includes('每日费用限制') ||
|
|
861
|
-
haystack.includes('余额不足') ||
|
|
862
|
-
haystack.includes('无可用资源包'));
|
|
863
|
-
}
|
|
864
|
-
truncateLogMessage(value, maxLength = 400) {
|
|
865
|
-
if (!value || value.length <= maxLength) {
|
|
866
|
-
return value;
|
|
867
|
-
}
|
|
868
|
-
return `${value.slice(0, maxLength - 3)}...`;
|
|
387
|
+
return parseSeriesCooldownDurationToMs(value);
|
|
869
388
|
}
|
|
870
389
|
}
|
|
871
390
|
//# sourceMappingURL=base-provider.js.map
|