@jsonstudio/rcc 0.89.1960 → 0.89.2195
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 +66 -6
- 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 +103 -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 +131 -47
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/stop.js +13 -0
- 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/bundled-default-config.d.ts +18 -0
- package/dist/cli/config/bundled-default-config.js +62 -0
- package/dist/cli/config/bundled-default-config.js.map +1 -0
- 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.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 +1147 -0
- 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 +17 -100
- 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 +4 -46
- package/dist/server/runtime/http-server/index.js +98 -2577
- 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/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/copy-modules-config.mjs +18 -0
- package/scripts/tests/ci-jest.mjs +4 -0
- package/scripts/verify-codex-error-samples.mjs +27 -6
|
@@ -1,837 +1,17 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
3
|
-
import { createRequire } from 'module';
|
|
4
|
-
import { importCoreModule, resolveCoreModulePath } from './core-loader.js';
|
|
5
|
-
import { writeErrorsampleJson } from '../../utils/errorsamples.js';
|
|
6
|
-
import { isLlmsEngineShadowEnabledForSubpath, recordLlmsEngineShadowDiff, resolveLlmsEngineShadowConfig, shouldRunLlmsEngineShadowForSubpath } from '../../utils/llms-engine-shadow.js';
|
|
7
|
-
import { buildInfo } from '../../build-info.js';
|
|
8
|
-
import { resolveLlmswitchCoreVersion } from '../../utils/runtime-versions.js';
|
|
9
|
-
const require = createRequire(import.meta.url);
|
|
10
|
-
function parsePrefixList(raw) {
|
|
11
|
-
return String(raw || '')
|
|
12
|
-
.split(',')
|
|
13
|
-
.map((s) => s.trim())
|
|
14
|
-
.filter(Boolean)
|
|
15
|
-
.map((s) => s.replace(/^\/*/, '').replace(/\/+$/, ''));
|
|
16
|
-
}
|
|
17
|
-
function matchesPrefix(subpath, prefixes) {
|
|
18
|
-
if (!prefixes.length) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
const normalized = subpath.replace(/^\/*/, '').replace(/\.js$/i, '');
|
|
22
|
-
return prefixes.some((prefix) => normalized === prefix || normalized.startsWith(`${prefix}/`));
|
|
23
|
-
}
|
|
24
|
-
function isEngineEnabled() {
|
|
25
|
-
const raw = String(process.env.ROUTECODEX_LLMS_ENGINE_ENABLE || '').trim().toLowerCase();
|
|
26
|
-
return raw === '1' || raw === 'true' || raw === 'yes';
|
|
27
|
-
}
|
|
28
|
-
function getEnginePrefixes() {
|
|
29
|
-
return parsePrefixList(process.env.ROUTECODEX_LLMS_ENGINE_PREFIXES);
|
|
30
|
-
}
|
|
31
|
-
function resolveImplForSubpath(subpath) {
|
|
32
|
-
if (!isEngineEnabled()) {
|
|
33
|
-
return 'ts';
|
|
34
|
-
}
|
|
35
|
-
const enginePrefixes = getEnginePrefixes();
|
|
36
|
-
if (matchesPrefix(subpath, enginePrefixes)) {
|
|
37
|
-
return 'engine';
|
|
38
|
-
}
|
|
39
|
-
return 'ts';
|
|
40
|
-
}
|
|
41
|
-
async function importCoreDist(subpath, impl = resolveImplForSubpath(subpath)) {
|
|
42
|
-
try {
|
|
43
|
-
return await importCoreModule(subpath, impl);
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
47
|
-
const pkg = impl === 'engine' ? '@jsonstudio/llms-engine' : '@jsonstudio/llms';
|
|
48
|
-
throw new Error(`[llmswitch-bridge] Unable to load core module "${subpath}" (${impl}). 请确认 ${pkg} 依赖已安装(npm install)。${detail ? ` (${detail})` : ''}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function requireCoreDist(subpath, impl = resolveImplForSubpath(subpath)) {
|
|
52
|
-
if (impl === 'engine' && !isEngineEnabled()) {
|
|
53
|
-
throw new Error('[llmswitch-bridge] ROUTECODEX_LLMS_ENGINE_ENABLE must be enabled to load engine core');
|
|
54
|
-
}
|
|
55
|
-
const modulePath = resolveCoreModulePath(subpath, impl);
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
57
|
-
return require(modulePath);
|
|
58
|
-
}
|
|
59
|
-
let cachedAntigravitySignatureModule = null;
|
|
60
|
-
let antigravitySignatureModuleWarmupPromise = null;
|
|
61
|
-
function loadAntigravitySignatureModule() {
|
|
62
|
-
if (cachedAntigravitySignatureModule) {
|
|
63
|
-
return cachedAntigravitySignatureModule;
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
cachedAntigravitySignatureModule = requireCoreDist('conversion/compat/antigravity-session-signature');
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
cachedAntigravitySignatureModule = null;
|
|
70
|
-
}
|
|
71
|
-
return cachedAntigravitySignatureModule;
|
|
72
|
-
}
|
|
73
|
-
export async function warmupAntigravitySessionSignatureModule() {
|
|
74
|
-
if (cachedAntigravitySignatureModule) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (!antigravitySignatureModuleWarmupPromise) {
|
|
78
|
-
antigravitySignatureModuleWarmupPromise = (async () => {
|
|
79
|
-
try {
|
|
80
|
-
return await importCoreDist('conversion/compat/antigravity-session-signature');
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
})();
|
|
86
|
-
}
|
|
87
|
-
try {
|
|
88
|
-
cachedAntigravitySignatureModule = await antigravitySignatureModuleWarmupPromise;
|
|
89
|
-
}
|
|
90
|
-
finally {
|
|
91
|
-
antigravitySignatureModuleWarmupPromise = null;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
export function extractAntigravityGeminiSessionId(payload) {
|
|
95
|
-
const mod = loadAntigravitySignatureModule();
|
|
96
|
-
const fn = mod?.extractAntigravityGeminiSessionId;
|
|
97
|
-
if (typeof fn !== 'function') {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
return fn(payload);
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
export function cacheAntigravitySessionSignature(a, b, c, d = 1) {
|
|
108
|
-
const mod = loadAntigravitySignatureModule();
|
|
109
|
-
const fn = mod?.cacheAntigravitySessionSignature;
|
|
110
|
-
if (typeof fn !== 'function') {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const supportsAliasKey = typeof mod?.getAntigravitySessionSignature === 'function' &&
|
|
114
|
-
mod.getAntigravitySessionSignature.length >= 2;
|
|
115
|
-
const isNewSignature = typeof c === 'string';
|
|
116
|
-
const aliasKey = isNewSignature ? a : 'antigravity.unknown';
|
|
117
|
-
const sessionId = isNewSignature ? b : a;
|
|
118
|
-
const signature = isNewSignature ? c : b;
|
|
119
|
-
const messageCount = typeof c === 'number' ? c : typeof d === 'number' ? d : 1;
|
|
120
|
-
try {
|
|
121
|
-
if (isNewSignature && supportsAliasKey) {
|
|
122
|
-
fn(aliasKey, sessionId, signature, messageCount);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
fn(sessionId, signature, messageCount);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
// best-effort only
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
export function getAntigravityLatestSignatureSessionIdForAlias(aliasKey, options) {
|
|
133
|
-
const mod = loadAntigravitySignatureModule();
|
|
134
|
-
const fn = mod?.getAntigravityLatestSignatureSessionIdForAlias;
|
|
135
|
-
if (typeof fn !== 'function') {
|
|
136
|
-
return undefined;
|
|
137
|
-
}
|
|
138
|
-
try {
|
|
139
|
-
const out = fn(aliasKey, options);
|
|
140
|
-
return typeof out === 'string' && out.trim().length ? out.trim() : undefined;
|
|
141
|
-
}
|
|
142
|
-
catch {
|
|
143
|
-
return undefined;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
export function lookupAntigravitySessionSignatureEntry(aliasKey, sessionId, options) {
|
|
147
|
-
const mod = loadAntigravitySignatureModule();
|
|
148
|
-
const fn = mod?.lookupAntigravitySessionSignatureEntry;
|
|
149
|
-
if (typeof fn !== 'function') {
|
|
150
|
-
return undefined;
|
|
151
|
-
}
|
|
152
|
-
try {
|
|
153
|
-
const out = fn(aliasKey, sessionId, options);
|
|
154
|
-
return out && typeof out === 'object' ? out : undefined;
|
|
155
|
-
}
|
|
156
|
-
catch {
|
|
157
|
-
return undefined;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
export function invalidateAntigravitySessionSignature(aliasKey, sessionId) {
|
|
161
|
-
const mod = loadAntigravitySignatureModule();
|
|
162
|
-
const fn = mod?.invalidateAntigravitySessionSignature;
|
|
163
|
-
if (typeof fn !== 'function') {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
try {
|
|
167
|
-
fn(aliasKey, sessionId);
|
|
168
|
-
}
|
|
169
|
-
catch {
|
|
170
|
-
// best-effort only
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
export function resetAntigravitySessionSignatureCachesForTests() {
|
|
174
|
-
const mod = loadAntigravitySignatureModule();
|
|
175
|
-
const fn = mod?.resetAntigravitySessionSignatureCachesForTests;
|
|
176
|
-
if (typeof fn !== 'function') {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
try {
|
|
180
|
-
fn();
|
|
181
|
-
}
|
|
182
|
-
catch {
|
|
183
|
-
// best-effort only
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
let quotaModulePromise = null;
|
|
187
|
-
let cachedQuotaModuleError = null;
|
|
188
|
-
async function importQuotaModule() {
|
|
189
|
-
if (!quotaModulePromise) {
|
|
190
|
-
quotaModulePromise = (async () => {
|
|
191
|
-
try {
|
|
192
|
-
const mod = await importCoreDist('quota/index');
|
|
193
|
-
cachedQuotaModuleError = null;
|
|
194
|
-
return mod;
|
|
195
|
-
}
|
|
196
|
-
catch {
|
|
197
|
-
cachedQuotaModuleError = 'failed to import core module quota/index (resolveCoreModulePath or import failed)';
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
|
-
})();
|
|
201
|
-
}
|
|
202
|
-
return await quotaModulePromise;
|
|
203
|
-
}
|
|
204
|
-
export async function createCoreQuotaManager(options) {
|
|
205
|
-
const mod = await importQuotaModule();
|
|
206
|
-
const Ctor = mod?.QuotaManager;
|
|
207
|
-
if (typeof Ctor !== 'function') {
|
|
208
|
-
throw new Error(`[llmswitch-bridge] core QuotaManager not available; please update @jsonstudio/llms${cachedQuotaModuleError ? ` (${cachedQuotaModuleError})` : ''}`);
|
|
209
|
-
}
|
|
210
|
-
return new Ctor({ ...(options ?? {}) });
|
|
211
|
-
}
|
|
212
|
-
export function configureAntigravitySessionSignaturePersistence(input) {
|
|
213
|
-
const mod = loadAntigravitySignatureModule();
|
|
214
|
-
const fn = mod?.configureAntigravitySessionSignaturePersistence;
|
|
215
|
-
if (typeof fn !== 'function') {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
try {
|
|
219
|
-
fn(input);
|
|
220
|
-
}
|
|
221
|
-
catch {
|
|
222
|
-
// best-effort only
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
export function flushAntigravitySessionSignaturePersistenceSync() {
|
|
226
|
-
const mod = loadAntigravitySignatureModule();
|
|
227
|
-
const fn = mod?.flushAntigravitySessionSignaturePersistenceSync;
|
|
228
|
-
if (typeof fn !== 'function') {
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
try {
|
|
232
|
-
fn();
|
|
233
|
-
}
|
|
234
|
-
catch {
|
|
235
|
-
// best-effort only
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
export async function writeSnapshotViaHooks(channelOrOptions, payload) {
|
|
239
|
-
let hooksModule = null;
|
|
240
|
-
try {
|
|
241
|
-
hooksModule = await importCoreDist('conversion/shared/snapshot-hooks');
|
|
242
|
-
}
|
|
243
|
-
catch {
|
|
244
|
-
hooksModule = null;
|
|
245
|
-
}
|
|
246
|
-
const writer = hooksModule?.writeSnapshotViaHooks;
|
|
247
|
-
if (typeof writer !== 'function') {
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
let options;
|
|
251
|
-
if (payload && typeof channelOrOptions === 'string') {
|
|
252
|
-
const channelValue = typeof payload.channel === 'string' && payload.channel ? payload.channel : channelOrOptions;
|
|
253
|
-
options = {
|
|
254
|
-
...payload,
|
|
255
|
-
channel: channelValue
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
else if (channelOrOptions && typeof channelOrOptions === 'object') {
|
|
259
|
-
options = channelOrOptions;
|
|
260
|
-
}
|
|
261
|
-
if (!options) {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
await writer(options);
|
|
265
|
-
}
|
|
266
|
-
export async function resumeResponsesConversation(responseId, submitPayload, options) {
|
|
267
|
-
const mod = await importCoreDist('conversion/shared/responses-conversation-store');
|
|
268
|
-
const fn = mod.resumeResponsesConversation;
|
|
269
|
-
if (typeof fn !== 'function') {
|
|
270
|
-
throw new Error('[llmswitch-bridge] resumeResponsesConversation not available');
|
|
271
|
-
}
|
|
272
|
-
return await fn(responseId, submitPayload, options);
|
|
273
|
-
}
|
|
274
|
-
export async function rebindResponsesConversationRequestId(oldId, newId) {
|
|
275
|
-
if (!oldId || !newId || oldId === newId) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
const mod = await importCoreDist('conversion/shared/responses-conversation-store');
|
|
279
|
-
const fn = mod.rebindResponsesConversationRequestId;
|
|
280
|
-
if (typeof fn === 'function') {
|
|
281
|
-
fn(oldId, newId);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
const cachedConvertProviderResponseByImpl = {
|
|
285
|
-
ts: null,
|
|
286
|
-
engine: null
|
|
287
|
-
};
|
|
288
|
-
const llmsEngineShadowConfig = resolveLlmsEngineShadowConfig();
|
|
289
1
|
/**
|
|
290
|
-
*
|
|
291
|
-
*
|
|
2
|
+
* RouteCodex LLM Switch Bridge
|
|
3
|
+
*
|
|
4
|
+
* Single boundary module for llmswitch-core integration.
|
|
292
5
|
*/
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
return result instanceof Promise ? await result : result;
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
return cachedConvertProviderResponseByImpl[impl];
|
|
308
|
-
};
|
|
309
|
-
const shadowEnabled = isLlmsEngineShadowEnabledForSubpath(llmsEngineShadowConfig, 'conversion/hub/response');
|
|
310
|
-
if (shadowEnabled) {
|
|
311
|
-
// Fail fast: if shadow is enabled for this module, engine core must be available.
|
|
312
|
-
await ensureFn('engine');
|
|
313
|
-
}
|
|
314
|
-
const wantsShadow = shadowEnabled && shouldRunLlmsEngineShadowForSubpath(llmsEngineShadowConfig, 'conversion/hub/response');
|
|
315
|
-
if (wantsShadow) {
|
|
316
|
-
const baseline = await (await ensureFn('ts'))(options);
|
|
317
|
-
const requestId = typeof options.requestId === 'string'
|
|
318
|
-
? String(options.requestId)
|
|
319
|
-
: (typeof options.id === 'string' ? String(options.id) : `shadow_${Date.now()}`);
|
|
320
|
-
void (async () => {
|
|
321
|
-
try {
|
|
322
|
-
const candidate = await (await ensureFn('engine'))(options);
|
|
323
|
-
await recordLlmsEngineShadowDiff({
|
|
324
|
-
group: 'provider-response',
|
|
325
|
-
requestId,
|
|
326
|
-
subpath: 'conversion/hub/response',
|
|
327
|
-
baselineImpl: 'ts',
|
|
328
|
-
candidateImpl: 'engine',
|
|
329
|
-
baselineOut: baseline,
|
|
330
|
-
candidateOut: candidate,
|
|
331
|
-
excludedComparePaths: []
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
catch (error) {
|
|
335
|
-
// eslint-disable-next-line no-console
|
|
336
|
-
console.error('[llms-engine-shadow] provider response shadow failed:', error);
|
|
337
|
-
}
|
|
338
|
-
})();
|
|
339
|
-
return baseline;
|
|
340
|
-
}
|
|
341
|
-
const impl = resolveImplForSubpath(subpath);
|
|
342
|
-
return await (await ensureFn(impl))(options);
|
|
343
|
-
}
|
|
344
|
-
let cachedSnapshotRecorderFactory = null;
|
|
345
|
-
/**
|
|
346
|
-
* 为 HubPipeline / provider 响应路径创建阶段快照记录器。
|
|
347
|
-
* 内部通过 llmswitch-core 的 snapshot-recorder 模块实现。
|
|
348
|
-
*/
|
|
349
|
-
export async function createSnapshotRecorder(context, endpoint) {
|
|
350
|
-
if (!cachedSnapshotRecorderFactory) {
|
|
351
|
-
const mod = await importCoreDist('conversion/hub/snapshot-recorder');
|
|
352
|
-
const factory = mod.createSnapshotRecorder;
|
|
353
|
-
if (typeof factory !== 'function') {
|
|
354
|
-
throw new Error('[llmswitch-bridge] createSnapshotRecorder not available');
|
|
355
|
-
}
|
|
356
|
-
cachedSnapshotRecorderFactory = factory;
|
|
357
|
-
}
|
|
358
|
-
const recorder = cachedSnapshotRecorderFactory(context, endpoint);
|
|
359
|
-
const baseRecord = typeof recorder?.record === 'function' ? recorder.record.bind(recorder) : null;
|
|
360
|
-
if (!baseRecord) {
|
|
361
|
-
return recorder;
|
|
362
|
-
}
|
|
363
|
-
return {
|
|
364
|
-
...recorder,
|
|
365
|
-
record(stage, payload) {
|
|
366
|
-
baseRecord(stage, payload);
|
|
367
|
-
try {
|
|
368
|
-
if (!stage || typeof stage !== 'string')
|
|
369
|
-
return;
|
|
370
|
-
const p = payload;
|
|
371
|
-
if (!p || typeof p !== 'object')
|
|
372
|
-
return;
|
|
373
|
-
if (stage.startsWith('hub_policy.')) {
|
|
374
|
-
const violations = p.violations;
|
|
375
|
-
if (!Array.isArray(violations) || violations.length <= 0)
|
|
376
|
-
return;
|
|
377
|
-
void writeErrorsampleJson({
|
|
378
|
-
group: 'policy',
|
|
379
|
-
kind: stage,
|
|
380
|
-
payload: {
|
|
381
|
-
kind: 'hub_policy_violation',
|
|
382
|
-
timestamp: new Date().toISOString(),
|
|
383
|
-
endpoint,
|
|
384
|
-
stage,
|
|
385
|
-
versions: {
|
|
386
|
-
routecodex: buildInfo.version,
|
|
387
|
-
llms: resolveLlmswitchCoreVersion(),
|
|
388
|
-
node: process.version
|
|
389
|
-
},
|
|
390
|
-
...(context && typeof context === 'object'
|
|
391
|
-
? {
|
|
392
|
-
requestId: context.requestId,
|
|
393
|
-
providerProtocol: context.providerProtocol,
|
|
394
|
-
runtime: context.runtime
|
|
395
|
-
}
|
|
396
|
-
: {}),
|
|
397
|
-
observation: payload
|
|
398
|
-
}
|
|
399
|
-
}).catch(() => { });
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
if (stage.startsWith('hub_toolsurface.')) {
|
|
403
|
-
const diffCount = typeof p.diffCount === 'number' ? p.diffCount : 0;
|
|
404
|
-
if (!(diffCount > 0))
|
|
405
|
-
return;
|
|
406
|
-
void writeErrorsampleJson({
|
|
407
|
-
group: 'tool-surface',
|
|
408
|
-
kind: stage,
|
|
409
|
-
payload: {
|
|
410
|
-
kind: 'hub_toolsurface_diff',
|
|
411
|
-
timestamp: new Date().toISOString(),
|
|
412
|
-
endpoint,
|
|
413
|
-
stage,
|
|
414
|
-
versions: {
|
|
415
|
-
routecodex: buildInfo.version,
|
|
416
|
-
llms: resolveLlmswitchCoreVersion(),
|
|
417
|
-
node: process.version
|
|
418
|
-
},
|
|
419
|
-
...(context && typeof context === 'object'
|
|
420
|
-
? {
|
|
421
|
-
requestId: context.requestId,
|
|
422
|
-
providerProtocol: context.providerProtocol,
|
|
423
|
-
runtime: context.runtime
|
|
424
|
-
}
|
|
425
|
-
: {}),
|
|
426
|
-
observation: payload
|
|
427
|
-
}
|
|
428
|
-
}).catch(() => { });
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
if (stage.startsWith('hub_followup.')) {
|
|
432
|
-
const diffCount = typeof p.diffCount === 'number' ? p.diffCount : 0;
|
|
433
|
-
if (!(diffCount > 0))
|
|
434
|
-
return;
|
|
435
|
-
void writeErrorsampleJson({
|
|
436
|
-
group: 'followup',
|
|
437
|
-
kind: stage,
|
|
438
|
-
payload: {
|
|
439
|
-
kind: 'hub_followup_diff',
|
|
440
|
-
timestamp: new Date().toISOString(),
|
|
441
|
-
endpoint,
|
|
442
|
-
stage,
|
|
443
|
-
versions: {
|
|
444
|
-
routecodex: buildInfo.version,
|
|
445
|
-
llms: resolveLlmswitchCoreVersion(),
|
|
446
|
-
node: process.version
|
|
447
|
-
},
|
|
448
|
-
...(context && typeof context === 'object'
|
|
449
|
-
? {
|
|
450
|
-
requestId: context.requestId,
|
|
451
|
-
providerProtocol: context.providerProtocol,
|
|
452
|
-
runtime: context.runtime
|
|
453
|
-
}
|
|
454
|
-
: {}),
|
|
455
|
-
observation: payload
|
|
456
|
-
}
|
|
457
|
-
}).catch(() => { });
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
catch {
|
|
462
|
-
// best-effort only; must never break request path
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
let cachedResponsesSseConverterFactory = null;
|
|
468
|
-
/**
|
|
469
|
-
* 创建 Responses SSE→JSON 转换器实例,供 ResponsesProvider 使用。
|
|
470
|
-
*/
|
|
471
|
-
export async function createResponsesSseToJsonConverter() {
|
|
472
|
-
if (!cachedResponsesSseConverterFactory) {
|
|
473
|
-
const mod = await importCoreDist('sse/sse-to-json/index');
|
|
474
|
-
const Ctor = mod.ResponsesSseToJsonConverter;
|
|
475
|
-
if (typeof Ctor !== 'function') {
|
|
476
|
-
throw new Error('[llmswitch-bridge] ResponsesSseToJsonConverter not available');
|
|
477
|
-
}
|
|
478
|
-
cachedResponsesSseConverterFactory = () => new Ctor();
|
|
479
|
-
}
|
|
480
|
-
return cachedResponsesSseConverterFactory();
|
|
481
|
-
}
|
|
482
|
-
let cachedProviderErrorCenter = null;
|
|
483
|
-
/**
|
|
484
|
-
* ProviderErrorCenter 统一桥接入口。
|
|
485
|
-
* Provider/Host 通过本函数获取 error center,避免直接 import core 模块。
|
|
486
|
-
*/
|
|
487
|
-
export async function getProviderErrorCenter() {
|
|
488
|
-
if (!cachedProviderErrorCenter) {
|
|
489
|
-
const mod = await importCoreDist('router/virtual-router/error-center');
|
|
490
|
-
const center = mod.providerErrorCenter;
|
|
491
|
-
if (!center) {
|
|
492
|
-
throw new Error('[llmswitch-bridge] providerErrorCenter not available');
|
|
493
|
-
}
|
|
494
|
-
cachedProviderErrorCenter = center;
|
|
495
|
-
}
|
|
496
|
-
return cachedProviderErrorCenter;
|
|
497
|
-
}
|
|
498
|
-
let cachedProviderSuccessCenter = null;
|
|
499
|
-
/**
|
|
500
|
-
* ProviderSuccessCenter 统一桥接入口。
|
|
501
|
-
* Host 通过本函数获取 success center,避免直接 import core 模块。
|
|
502
|
-
*/
|
|
503
|
-
export async function getProviderSuccessCenter() {
|
|
504
|
-
if (!cachedProviderSuccessCenter) {
|
|
505
|
-
const mod = await importCoreDist('router/virtual-router/success-center');
|
|
506
|
-
const center = mod.providerSuccessCenter;
|
|
507
|
-
if (!center) {
|
|
508
|
-
throw new Error('[llmswitch-bridge] providerSuccessCenter not available');
|
|
509
|
-
}
|
|
510
|
-
cachedProviderSuccessCenter = center;
|
|
511
|
-
}
|
|
512
|
-
return cachedProviderSuccessCenter;
|
|
513
|
-
}
|
|
514
|
-
let cachedStickySessionStore = undefined;
|
|
515
|
-
function getStickySessionStoreExports() {
|
|
516
|
-
if (cachedStickySessionStore !== undefined) {
|
|
517
|
-
return cachedStickySessionStore;
|
|
518
|
-
}
|
|
519
|
-
try {
|
|
520
|
-
// NOTE: must be sync because VirtualRouter routingStateStore expects loadSync.
|
|
521
|
-
// Centralized here to keep a single core import surface.
|
|
522
|
-
cachedStickySessionStore = requireCoreDist('router/virtual-router/sticky-session-store');
|
|
523
|
-
}
|
|
524
|
-
catch {
|
|
525
|
-
cachedStickySessionStore = null;
|
|
526
|
-
}
|
|
527
|
-
return cachedStickySessionStore;
|
|
528
|
-
}
|
|
529
|
-
export function loadRoutingInstructionStateSync(key) {
|
|
530
|
-
const mod = getStickySessionStoreExports();
|
|
531
|
-
const fn = mod?.loadRoutingInstructionStateSync;
|
|
532
|
-
if (typeof fn !== 'function') {
|
|
533
|
-
return null;
|
|
534
|
-
}
|
|
535
|
-
return fn(key);
|
|
536
|
-
}
|
|
537
|
-
export function saveRoutingInstructionStateAsync(key, state) {
|
|
538
|
-
const mod = getStickySessionStoreExports();
|
|
539
|
-
const fn = mod?.saveRoutingInstructionStateAsync;
|
|
540
|
-
if (typeof fn !== 'function') {
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
fn(key, state);
|
|
544
|
-
}
|
|
545
|
-
export function saveRoutingInstructionStateSync(key, state) {
|
|
546
|
-
const mod = getStickySessionStoreExports();
|
|
547
|
-
const fn = mod?.saveRoutingInstructionStateSync;
|
|
548
|
-
if (typeof fn !== 'function') {
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
fn(key, state);
|
|
552
|
-
}
|
|
553
|
-
let cachedSessionIdentifiersModule = undefined;
|
|
554
|
-
function getSessionIdentifiersModule() {
|
|
555
|
-
if (cachedSessionIdentifiersModule !== undefined) {
|
|
556
|
-
return cachedSessionIdentifiersModule;
|
|
557
|
-
}
|
|
558
|
-
try {
|
|
559
|
-
cachedSessionIdentifiersModule = requireCoreDist('conversion/hub/pipeline/session-identifiers');
|
|
560
|
-
}
|
|
561
|
-
catch {
|
|
562
|
-
cachedSessionIdentifiersModule = null;
|
|
563
|
-
}
|
|
564
|
-
return cachedSessionIdentifiersModule;
|
|
565
|
-
}
|
|
566
|
-
export function extractSessionIdentifiersFromMetadata(meta) {
|
|
567
|
-
const mod = getSessionIdentifiersModule();
|
|
568
|
-
const fn = mod?.extractSessionIdentifiersFromMetadata;
|
|
569
|
-
if (typeof fn !== 'function') {
|
|
570
|
-
return {};
|
|
571
|
-
}
|
|
572
|
-
try {
|
|
573
|
-
return fn(meta);
|
|
574
|
-
}
|
|
575
|
-
catch {
|
|
576
|
-
return {};
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
let cachedStatsCenter = undefined;
|
|
580
|
-
export function getStatsCenterSafe() {
|
|
581
|
-
if (cachedStatsCenter) {
|
|
582
|
-
return cachedStatsCenter;
|
|
583
|
-
}
|
|
584
|
-
if (cachedStatsCenter === null) {
|
|
585
|
-
return { recordProviderUsage: () => { } };
|
|
586
|
-
}
|
|
587
|
-
try {
|
|
588
|
-
const mod = requireCoreDist('telemetry/stats-center');
|
|
589
|
-
const fn = mod?.getStatsCenter;
|
|
590
|
-
const center = typeof fn === 'function' ? fn() : null;
|
|
591
|
-
if (center && typeof center.recordProviderUsage === 'function') {
|
|
592
|
-
cachedStatsCenter = center;
|
|
593
|
-
return center;
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
catch {
|
|
597
|
-
// fall through
|
|
598
|
-
}
|
|
599
|
-
cachedStatsCenter = null;
|
|
600
|
-
return { recordProviderUsage: () => { } };
|
|
601
|
-
}
|
|
602
|
-
export function getLlmsStatsSnapshot() {
|
|
603
|
-
try {
|
|
604
|
-
const mod = requireCoreDist('telemetry/stats-center');
|
|
605
|
-
const get = mod?.getStatsCenter;
|
|
606
|
-
const center = typeof get === 'function' ? get() : null;
|
|
607
|
-
const snap = center && typeof center === 'object' ? center.getSnapshot : null;
|
|
608
|
-
return typeof snap === 'function' ? snap.call(center) : null;
|
|
609
|
-
}
|
|
610
|
-
catch {
|
|
611
|
-
return null;
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
/**
|
|
615
|
-
* 通过 llmswitch-core 的 bootstrapVirtualRouterConfig 预处理 Virtual Router 配置。
|
|
616
|
-
*/
|
|
617
|
-
export async function bootstrapVirtualRouterConfig(input) {
|
|
618
|
-
const mod = await importCoreDist('router/virtual-router/bootstrap');
|
|
619
|
-
const fn = mod.bootstrapVirtualRouterConfig;
|
|
620
|
-
if (typeof fn !== 'function') {
|
|
621
|
-
throw new Error('[llmswitch-bridge] bootstrapVirtualRouterConfig not available');
|
|
622
|
-
}
|
|
623
|
-
return fn(input);
|
|
624
|
-
}
|
|
625
|
-
let cachedClockTaskStoreModule = undefined;
|
|
626
|
-
let clockTaskStoreLastLoadAttemptAtMs = 0;
|
|
627
|
-
let hasLoggedClockTaskStoreLoadFailure = false;
|
|
628
|
-
const CLOCK_TASK_STORE_RETRY_INTERVAL_MS = 30_000;
|
|
629
|
-
async function tryLoadClockTaskStoreModule() {
|
|
630
|
-
try {
|
|
631
|
-
return await importCoreDist('servertool/clock/task-store');
|
|
632
|
-
}
|
|
633
|
-
catch {
|
|
634
|
-
// fallback to legacy split exports
|
|
635
|
-
}
|
|
636
|
-
try {
|
|
637
|
-
const [tasksModule, configModule] = await Promise.all([
|
|
638
|
-
importCoreDist('servertool/clock/tasks'),
|
|
639
|
-
importCoreDist('servertool/clock/config')
|
|
640
|
-
]);
|
|
641
|
-
return {
|
|
642
|
-
...tasksModule,
|
|
643
|
-
resolveClockConfig: configModule.resolveClockConfig
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
catch {
|
|
647
|
-
return null;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
async function getClockTaskStoreModuleSafe() {
|
|
651
|
-
if (cachedClockTaskStoreModule) {
|
|
652
|
-
return cachedClockTaskStoreModule;
|
|
653
|
-
}
|
|
654
|
-
const now = Date.now();
|
|
655
|
-
if (cachedClockTaskStoreModule === null &&
|
|
656
|
-
now - clockTaskStoreLastLoadAttemptAtMs < CLOCK_TASK_STORE_RETRY_INTERVAL_MS) {
|
|
657
|
-
return null;
|
|
658
|
-
}
|
|
659
|
-
clockTaskStoreLastLoadAttemptAtMs = now;
|
|
660
|
-
const loaded = await tryLoadClockTaskStoreModule();
|
|
661
|
-
if (loaded) {
|
|
662
|
-
cachedClockTaskStoreModule = loaded;
|
|
663
|
-
hasLoggedClockTaskStoreLoadFailure = false;
|
|
664
|
-
return loaded;
|
|
665
|
-
}
|
|
666
|
-
cachedClockTaskStoreModule = null;
|
|
667
|
-
if (!hasLoggedClockTaskStoreLoadFailure) {
|
|
668
|
-
hasLoggedClockTaskStoreLoadFailure = true;
|
|
669
|
-
console.warn('[llmswitch-bridge] clock task-store module unavailable; clock daemon inject/tasks are temporarily disabled. Please ensure @jsonstudio/llms dist is built and installed.');
|
|
670
|
-
}
|
|
671
|
-
return null;
|
|
672
|
-
}
|
|
673
|
-
export async function resolveClockConfigSnapshot(input) {
|
|
674
|
-
const mod = await getClockTaskStoreModuleSafe();
|
|
675
|
-
const fn = mod?.resolveClockConfig;
|
|
676
|
-
if (typeof fn !== 'function') {
|
|
677
|
-
return null;
|
|
678
|
-
}
|
|
679
|
-
try {
|
|
680
|
-
return fn(input) ?? null;
|
|
681
|
-
}
|
|
682
|
-
catch {
|
|
683
|
-
return null;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
export async function reserveClockDueTasks(args) {
|
|
687
|
-
const mod = await getClockTaskStoreModuleSafe();
|
|
688
|
-
const fn = mod?.reserveDueTasksForRequest;
|
|
689
|
-
if (typeof fn !== 'function') {
|
|
690
|
-
return { reservation: null };
|
|
691
|
-
}
|
|
692
|
-
try {
|
|
693
|
-
return await fn(args);
|
|
694
|
-
}
|
|
695
|
-
catch {
|
|
696
|
-
return { reservation: null };
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
export async function commitClockDueReservation(args) {
|
|
700
|
-
const mod = await getClockTaskStoreModuleSafe();
|
|
701
|
-
const fn = mod?.commitClockReservation;
|
|
702
|
-
if (typeof fn !== 'function') {
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
try {
|
|
706
|
-
await fn(args.reservation, args.config);
|
|
707
|
-
}
|
|
708
|
-
catch {
|
|
709
|
-
// best-effort only
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
export async function listClockSessionIdsSnapshot() {
|
|
713
|
-
const mod = await getClockTaskStoreModuleSafe();
|
|
714
|
-
const fn = mod?.listClockSessionIds;
|
|
715
|
-
if (typeof fn !== 'function') {
|
|
716
|
-
return [];
|
|
717
|
-
}
|
|
718
|
-
try {
|
|
719
|
-
const out = await fn();
|
|
720
|
-
return Array.isArray(out) ? out.filter((item) => typeof item === 'string' && item.trim()).map((item) => item.trim()) : [];
|
|
721
|
-
}
|
|
722
|
-
catch {
|
|
723
|
-
return [];
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
export async function listClockTasksSnapshot(args) {
|
|
727
|
-
const mod = await getClockTaskStoreModuleSafe();
|
|
728
|
-
const fn = mod?.listClockTasks;
|
|
729
|
-
if (typeof fn !== 'function') {
|
|
730
|
-
return [];
|
|
731
|
-
}
|
|
732
|
-
try {
|
|
733
|
-
const out = await fn(args.sessionId, args.config);
|
|
734
|
-
return Array.isArray(out) ? out : [];
|
|
735
|
-
}
|
|
736
|
-
catch {
|
|
737
|
-
return [];
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
export async function scheduleClockTasksSnapshot(args) {
|
|
741
|
-
const mod = await getClockTaskStoreModuleSafe();
|
|
742
|
-
const fn = mod?.scheduleClockTasks;
|
|
743
|
-
if (typeof fn !== 'function') {
|
|
744
|
-
return [];
|
|
745
|
-
}
|
|
746
|
-
try {
|
|
747
|
-
const out = await fn(args.sessionId, Array.isArray(args.items) ? args.items : [], args.config);
|
|
748
|
-
return Array.isArray(out) ? out : [];
|
|
749
|
-
}
|
|
750
|
-
catch {
|
|
751
|
-
return [];
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
export async function updateClockTaskSnapshot(args) {
|
|
755
|
-
const mod = await getClockTaskStoreModuleSafe();
|
|
756
|
-
const fn = mod?.updateClockTask;
|
|
757
|
-
if (typeof fn !== 'function') {
|
|
758
|
-
return null;
|
|
759
|
-
}
|
|
760
|
-
try {
|
|
761
|
-
return await fn(args.sessionId, args.taskId, args.patch, args.config);
|
|
762
|
-
}
|
|
763
|
-
catch {
|
|
764
|
-
return null;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
export async function cancelClockTaskSnapshot(args) {
|
|
768
|
-
const mod = await getClockTaskStoreModuleSafe();
|
|
769
|
-
const fn = mod?.cancelClockTask;
|
|
770
|
-
if (typeof fn !== 'function') {
|
|
771
|
-
return false;
|
|
772
|
-
}
|
|
773
|
-
try {
|
|
774
|
-
return Boolean(await fn(args.sessionId, args.taskId, args.config));
|
|
775
|
-
}
|
|
776
|
-
catch {
|
|
777
|
-
return false;
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
export async function clearClockTasksSnapshot(args) {
|
|
781
|
-
const mod = await getClockTaskStoreModuleSafe();
|
|
782
|
-
const fn = mod?.clearClockTasks;
|
|
783
|
-
if (typeof fn !== 'function') {
|
|
784
|
-
return 0;
|
|
785
|
-
}
|
|
786
|
-
try {
|
|
787
|
-
const removed = await fn(args.sessionId, args.config);
|
|
788
|
-
return Number.isFinite(Number(removed)) ? Math.max(0, Math.floor(Number(removed))) : 0;
|
|
789
|
-
}
|
|
790
|
-
catch {
|
|
791
|
-
return 0;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
const cachedHubPipelineCtorByImpl = {
|
|
795
|
-
ts: null,
|
|
796
|
-
engine: null
|
|
797
|
-
};
|
|
798
|
-
/**
|
|
799
|
-
* 获取 HubPipeline 构造函数,供 Host 创建 HubPipeline 实例。
|
|
800
|
-
*/
|
|
801
|
-
export async function getHubPipelineCtor() {
|
|
802
|
-
const impl = resolveImplForSubpath('conversion/hub/pipeline/hub-pipeline');
|
|
803
|
-
if (!cachedHubPipelineCtorByImpl[impl]) {
|
|
804
|
-
const mod = await importCoreDist('conversion/hub/pipeline/hub-pipeline', impl);
|
|
805
|
-
const Ctor = mod.HubPipeline;
|
|
806
|
-
if (typeof Ctor !== 'function') {
|
|
807
|
-
throw new Error('[llmswitch-bridge] HubPipeline constructor not available');
|
|
808
|
-
}
|
|
809
|
-
cachedHubPipelineCtorByImpl[impl] = Ctor;
|
|
810
|
-
}
|
|
811
|
-
return cachedHubPipelineCtorByImpl[impl];
|
|
812
|
-
}
|
|
813
|
-
export async function getHubPipelineCtorForImpl(impl) {
|
|
814
|
-
if (!cachedHubPipelineCtorByImpl[impl]) {
|
|
815
|
-
const mod = await importCoreDist('conversion/hub/pipeline/hub-pipeline', impl);
|
|
816
|
-
const Ctor = mod.HubPipeline;
|
|
817
|
-
if (typeof Ctor !== 'function') {
|
|
818
|
-
throw new Error('[llmswitch-bridge] HubPipeline constructor not available');
|
|
819
|
-
}
|
|
820
|
-
cachedHubPipelineCtorByImpl[impl] = Ctor;
|
|
821
|
-
}
|
|
822
|
-
return cachedHubPipelineCtorByImpl[impl];
|
|
823
|
-
}
|
|
824
|
-
function resolveBaseDir() {
|
|
825
|
-
const env = String(process.env.ROUTECODEX_BASEDIR || process.env.RCC_BASEDIR || '').trim();
|
|
826
|
-
if (env) {
|
|
827
|
-
return env;
|
|
828
|
-
}
|
|
829
|
-
try {
|
|
830
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
831
|
-
return path.resolve(path.dirname(__filename), '../../..');
|
|
832
|
-
}
|
|
833
|
-
catch {
|
|
834
|
-
return process.cwd();
|
|
835
|
-
}
|
|
836
|
-
}
|
|
6
|
+
// Core module loading utilities.
|
|
7
|
+
export { importCoreDist, requireCoreDist, resolveImplForSubpath } from './bridge/module-loader.js';
|
|
8
|
+
// Existing bridge exports.
|
|
9
|
+
export { createSnapshotRecorder } from './bridge/snapshot-recorder.js';
|
|
10
|
+
export { convertProviderResponse } from './bridge/response-converter.js';
|
|
11
|
+
export { warmupAntigravitySessionSignatureModule, extractAntigravityGeminiSessionId, cacheAntigravitySessionSignature, getAntigravityLatestSignatureSessionIdForAlias, lookupAntigravitySessionSignatureEntry, invalidateAntigravitySessionSignature, clearAntigravitySessionAliasPins, resetAntigravitySessionSignatureCachesForTests, configureAntigravitySessionSignaturePersistence, flushAntigravitySessionSignaturePersistenceSync } from './bridge/antigravity-signature.js';
|
|
12
|
+
// Newly factored bridge modules.
|
|
13
|
+
export { createCoreQuotaManager } from './bridge/quota-manager.js';
|
|
14
|
+
export { writeSnapshotViaHooks, resumeResponsesConversation, rebindResponsesConversationRequestId, createResponsesSseToJsonConverter, getProviderErrorCenter, getProviderSuccessCenter } from './bridge/runtime-integrations.js';
|
|
15
|
+
export { loadRoutingInstructionStateSync, saveRoutingInstructionStateAsync, saveRoutingInstructionStateSync, extractSessionIdentifiersFromMetadata, getStatsCenterSafe, getLlmsStatsSnapshot, resolveClockConfigSnapshot, reserveClockDueTasks, commitClockDueReservation, listClockSessionIdsSnapshot, listClockTasksSnapshot, scheduleClockTasksSnapshot, updateClockTaskSnapshot, cancelClockTaskSnapshot, clearClockTasksSnapshot } from './bridge/state-integrations.js';
|
|
16
|
+
export { bootstrapVirtualRouterConfig, getHubPipelineCtor, getHubPipelineCtorForImpl, resolveBaseDir } from './bridge/routing-integrations.js';
|
|
837
17
|
//# sourceMappingURL=bridge.js.map
|