@fudrouter/fsrouter 0.6.72 → 0.6.74
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/dist/lib/headroom/detect.js +97 -7
- package/dist/lib/headroom/process.js +136 -4
- package/dist/open-sse/config/appConstants.js +23 -79
- package/dist/open-sse/config/cliFingerprints.js +1 -1
- package/dist/open-sse/config/errorConfig.js +0 -11
- package/dist/open-sse/config/grokCli.js +10 -0
- package/dist/open-sse/config/kiroConstants.js +99 -46
- package/dist/open-sse/config/runtimeConfig.js +2 -0
- package/dist/open-sse/config/ttsModels.js +2 -0
- package/dist/open-sse/executors/antigravity.js +250 -164
- package/dist/open-sse/executors/base.js +16 -11
- package/dist/open-sse/executors/codex.js +269 -1108
- package/dist/open-sse/executors/commandCode.js +1 -1
- package/dist/open-sse/executors/commandcode.js +10 -4
- package/dist/open-sse/executors/cursor.js +96 -203
- package/dist/open-sse/executors/default.js +146 -244
- package/dist/open-sse/executors/github.js +128 -73
- package/dist/open-sse/executors/grok-cli.js +527 -94
- package/dist/open-sse/executors/grok-web.js +5 -7
- package/dist/open-sse/executors/index.js +12 -0
- package/dist/open-sse/executors/kiro.js +150 -61
- package/dist/open-sse/executors/opencode-go.js +12 -4
- package/dist/open-sse/executors/opencode.js +1 -1
- package/dist/open-sse/executors/perplexity-web.js +20 -96
- package/dist/open-sse/executors/qoder.js +28 -18
- package/dist/open-sse/executors/vertex.js +53 -7
- package/dist/open-sse/executors/xiaomi-tokenplan.js +6 -5
- package/dist/open-sse/handlers/chatCore/nonStreamingHandler.js +97 -85
- package/dist/open-sse/handlers/chatCore/requestDetail.js +32 -8
- package/dist/open-sse/handlers/chatCore/sseToJsonHandler.js +13 -7
- package/dist/open-sse/handlers/chatCore/streamingHandler.js +74 -25
- package/dist/open-sse/handlers/chatCore.js +35 -41
- package/dist/open-sse/handlers/embeddingProviders/index.js +1 -0
- package/dist/open-sse/handlers/embeddingProviders/openai.js +8 -16
- package/dist/open-sse/handlers/imageProviders/blackForestLabs.js +2 -21
- package/dist/open-sse/handlers/imageProviders/cloudflareAi.js +2 -30
- package/dist/open-sse/handlers/imageProviders/codex.js +2 -20
- package/dist/open-sse/handlers/imageProviders/comfyui.js +5 -18
- package/dist/open-sse/handlers/imageProviders/falAi.js +2 -22
- package/dist/open-sse/handlers/imageProviders/gemini.js +2 -16
- package/dist/open-sse/handlers/imageProviders/huggingface.js +2 -17
- package/dist/open-sse/handlers/imageProviders/index.js +3 -4
- package/dist/open-sse/handlers/imageProviders/leonardo.js +1 -1
- package/dist/open-sse/handlers/imageProviders/nanobanana.js +4 -23
- package/dist/open-sse/handlers/imageProviders/openai.js +15 -43
- package/dist/open-sse/handlers/imageProviders/runwayml.js +2 -26
- package/dist/open-sse/handlers/imageProviders/sdwebui.js +4 -20
- package/dist/open-sse/handlers/imageProviders/stabilityAi.js +2 -26
- package/dist/open-sse/handlers/imageProviders/weavy.js +1 -1
- package/dist/open-sse/handlers/search/chatSearch.js +60 -14
- package/dist/open-sse/handlers/ttsProviders/gemini.js +14 -3
- package/dist/open-sse/handlers/ttsProviders/index.js +4 -2
- package/dist/open-sse/handlers/ttsProviders/openai.js +4 -1
- package/dist/open-sse/handlers/ttsProviders/openrouter.js +7 -4
- package/dist/open-sse/handlers/videoCore.js +166 -0
- package/dist/open-sse/handlers/videoProviders/weavy.js +1 -1
- package/dist/open-sse/mcp-server/catalog.js +1 -1
- package/dist/open-sse/mcp-server/server.js +2 -2
- package/dist/open-sse/mcp-server/tools/advancedTools.js +2 -2
- package/dist/open-sse/mcp-server/tools/agentSkillTools.js +1 -1
- package/dist/open-sse/mcp-server/tools/compressionTools.js +4 -4
- package/dist/open-sse/mcp-server/tools/gamificationTools.js +10 -10
- package/dist/open-sse/mcp-server/tools/githubSkillTools.js +1 -1
- package/dist/open-sse/mcp-server/tools/memoryTools.js +3 -3
- package/dist/open-sse/mcp-server/tools/notionTools.js +2 -2
- package/dist/open-sse/mcp-server/tools/obsidianTools.js +2 -2
- package/dist/open-sse/mcp-server/tools/pickFastestModel.js +1 -1
- package/dist/open-sse/mcp-server/tools/pluginTools.js +4 -4
- package/dist/open-sse/mcp-server/tools/skillTools.js +2 -2
- package/dist/open-sse/providers/capabilities.js +24 -4
- package/dist/open-sse/providers/registry/alicode-intl.js +1 -1
- package/dist/open-sse/providers/registry/anthropic.js +1 -8
- package/dist/open-sse/providers/registry/codex.js +0 -9
- package/dist/open-sse/providers/registry/cohere.js +0 -2
- package/dist/open-sse/providers/registry/gemini.js +0 -2
- package/dist/open-sse/providers/registry/github.js +9 -6
- package/dist/open-sse/providers/registry/grok-cli.js +28 -18
- package/dist/open-sse/providers/registry/index.js +74 -80
- package/dist/open-sse/providers/registry/kiro.js +12 -0
- package/dist/open-sse/providers/registry/mistral.js +0 -3
- package/dist/open-sse/providers/registry/openai.js +0 -3
- package/dist/open-sse/providers/registry/perplexity.js +0 -2
- package/dist/open-sse/providers/registry/xai.js +5 -3
- package/dist/open-sse/rtk/autodetect.js +10 -2
- package/dist/open-sse/rtk/caveman.js +2 -93
- package/dist/open-sse/rtk/cavemanPrompts.js +34 -2
- package/dist/open-sse/rtk/constants.js +7 -2
- package/dist/open-sse/rtk/headroom.js +133 -0
- package/dist/open-sse/rtk/ponytail.js +1 -1
- package/dist/open-sse/rtk/registry.js +2 -0
- package/dist/open-sse/services/accountFallback.js +0 -108
- package/dist/open-sse/services/combo/quotaExhaustionCutoff.js +2 -2
- package/dist/open-sse/services/combo/quotaShareStrategy.js +1 -1
- package/dist/open-sse/services/combo/resolveAutoStrategy.js +1 -1
- package/dist/open-sse/services/combo/sessionStickiness.js +1 -1
- package/dist/open-sse/services/combo/targetSorters.js +2 -2
- package/dist/open-sse/services/combo/validateQuality.js +1 -1
- package/dist/open-sse/services/comboConfig.js +1 -1
- package/dist/open-sse/services/emergencyFallback.js +1 -1
- package/dist/open-sse/services/grokCliModels.js +127 -0
- package/dist/open-sse/services/model.js +7 -1
- package/dist/open-sse/services/provider.js +1 -1
- package/dist/open-sse/services/proxyAutoSelector.js +1 -1
- package/dist/open-sse/services/tokenRefresh/providers.js +3 -3
- package/dist/open-sse/services/usage/codex.js +148 -214
- package/dist/open-sse/services/usage/grok-cli.js +61 -7
- package/dist/open-sse/services/usage/misc.js +0 -19
- package/dist/open-sse/services/usage.js +0 -2
- package/dist/open-sse/translator/concerns/paramSupport.js +2 -2
- package/dist/open-sse/translator/concerns/thinkingUnified.js +6 -0
- package/dist/open-sse/translator/index.js +97 -59
- package/dist/open-sse/translator/request/claude-to-kiro.js +67 -40
- package/dist/open-sse/translator/request/openai-responses.js +1 -0
- package/dist/open-sse/translator/request/openai-to-commandcode.js +0 -4
- package/dist/open-sse/translator/request/openai-to-kiro.js +49 -20
- package/dist/open-sse/translator/response/commandcode-to-openai.js +0 -4
- package/dist/open-sse/utils/bypassHandler.js +18 -3
- package/dist/open-sse/utils/claudeCloaking.js +15 -5
- package/dist/open-sse/utils/cursorImages.js +1 -1
- package/dist/open-sse/utils/error.js +0 -17
- package/dist/open-sse/utils/keepaliveThreshold.js +4 -4
- package/dist/open-sse/utils/kiroSessionReplay.js +125 -0
- package/dist/open-sse/utils/noThinkingAlias.js +1 -1
- package/dist/open-sse/utils/proxyFetch.js +0 -1
- package/dist/open-sse/utils/reasoningContentInjector.js +4 -7
- package/dist/open-sse/utils/responsesStatePolicy.js +1 -1
- package/dist/open-sse/utils/responsesStreamHelpers.js +1 -0
- package/dist/open-sse/utils/sessionManager.js +49 -22
- package/dist/open-sse/utils/stream.js +54 -77
- package/dist/open-sse/utils/streamHandler.js +19 -15
- package/dist/open-sse/utils/streamHelpers.js +2 -17
- package/dist/open-sse/utils/usageTracking.js +103 -12
- package/dist/routes/headroom/extras/route.js +58 -0
- package/dist/routes/headroom/restart/route.js +33 -0
- package/open-sse/config/appConstants.js +23 -79
- package/open-sse/config/errorConfig.js +0 -11
- package/open-sse/config/grokCli.js +10 -0
- package/open-sse/config/kiroConstants.js +99 -46
- package/open-sse/config/runtimeConfig.js +2 -0
- package/open-sse/config/ttsModels.js +2 -0
- package/open-sse/executors/antigravity.js +250 -164
- package/open-sse/executors/base.js +16 -11
- package/open-sse/executors/codex.js +269 -1108
- package/open-sse/executors/commandcode.js +10 -4
- package/open-sse/executors/cursor.js +96 -203
- package/open-sse/executors/default.js +146 -244
- package/open-sse/executors/github.js +128 -73
- package/open-sse/executors/grok-cli.js +527 -94
- package/open-sse/executors/grok-web.js +5 -7
- package/open-sse/executors/index.js +12 -0
- package/open-sse/executors/kiro.js +150 -61
- package/open-sse/executors/opencode-go.js +12 -4
- package/open-sse/executors/opencode.js +1 -1
- package/open-sse/executors/perplexity-web.js +20 -96
- package/open-sse/executors/qoder.js +28 -18
- package/open-sse/executors/vertex.js +53 -7
- package/open-sse/executors/xiaomi-tokenplan.js +6 -5
- package/open-sse/handlers/chatCore/nonStreamingHandler.js +97 -85
- package/open-sse/handlers/chatCore/requestDetail.js +32 -8
- package/open-sse/handlers/chatCore/sseToJsonHandler.js +13 -7
- package/open-sse/handlers/chatCore/streamingHandler.js +74 -25
- package/open-sse/handlers/chatCore.js +35 -41
- package/open-sse/handlers/embeddingProviders/index.js +1 -0
- package/open-sse/handlers/embeddingProviders/openai.js +8 -16
- package/open-sse/handlers/imageProviders/blackForestLabs.js +2 -21
- package/open-sse/handlers/imageProviders/cloudflareAi.js +2 -30
- package/open-sse/handlers/imageProviders/codex.js +2 -20
- package/open-sse/handlers/imageProviders/comfyui.js +5 -18
- package/open-sse/handlers/imageProviders/falAi.js +2 -22
- package/open-sse/handlers/imageProviders/gemini.js +2 -16
- package/open-sse/handlers/imageProviders/huggingface.js +2 -17
- package/open-sse/handlers/imageProviders/index.js +3 -4
- package/open-sse/handlers/imageProviders/leonardo.js +1 -1
- package/open-sse/handlers/imageProviders/nanobanana.js +4 -23
- package/open-sse/handlers/imageProviders/openai.js +15 -43
- package/open-sse/handlers/imageProviders/runwayml.js +2 -26
- package/open-sse/handlers/imageProviders/sdwebui.js +4 -20
- package/open-sse/handlers/imageProviders/stabilityAi.js +2 -26
- package/open-sse/handlers/imageProviders/weavy.js +1 -1
- package/open-sse/handlers/search/chatSearch.js +60 -14
- package/open-sse/handlers/ttsProviders/gemini.js +14 -3
- package/open-sse/handlers/ttsProviders/index.js +4 -2
- package/open-sse/handlers/ttsProviders/openai.js +4 -1
- package/open-sse/handlers/ttsProviders/openrouter.js +7 -4
- package/open-sse/handlers/videoCore.js +166 -0
- package/open-sse/handlers/videoProviders/weavy.js +1 -1
- package/open-sse/mcp-server/audit.js +1 -1
- package/open-sse/mcp-server/catalog.js +2 -2
- package/open-sse/mcp-server/descriptionCompressor.js +1 -1
- package/open-sse/mcp-server/mcpCallerIdentity.js +1 -1
- package/open-sse/mcp-server/schemas/tools.js +1 -1
- package/open-sse/mcp-server/server.js +4 -4
- package/open-sse/mcp-server/tools/advancedTools.js +5 -5
- package/open-sse/mcp-server/tools/agentSkillTools.js +1 -1
- package/open-sse/mcp-server/tools/compressionTools.js +4 -4
- package/open-sse/mcp-server/tools/gamificationTools.js +10 -10
- package/open-sse/mcp-server/tools/githubSkillTools.js +1 -1
- package/open-sse/mcp-server/tools/memoryTools.js +3 -3
- package/open-sse/mcp-server/tools/notionTools.js +2 -2
- package/open-sse/mcp-server/tools/obsidianTools.js +2 -2
- package/open-sse/mcp-server/tools/pickFastestModel.js +3 -3
- package/open-sse/mcp-server/tools/pluginTools.js +4 -4
- package/open-sse/mcp-server/tools/skillTools.js +2 -2
- package/open-sse/providers/capabilities.js +24 -4
- package/open-sse/providers/registry/alicode-intl.js +1 -1
- package/open-sse/providers/registry/anthropic.js +1 -8
- package/open-sse/providers/registry/codex.js +0 -9
- package/open-sse/providers/registry/cohere.js +0 -2
- package/open-sse/providers/registry/gemini.js +0 -2
- package/open-sse/providers/registry/github.js +9 -6
- package/open-sse/providers/registry/grok-cli.js +28 -18
- package/open-sse/providers/registry/index.js +74 -80
- package/open-sse/providers/registry/kiro.js +12 -0
- package/open-sse/providers/registry/mistral.js +0 -3
- package/open-sse/providers/registry/openai.js +0 -3
- package/open-sse/providers/registry/perplexity.js +0 -2
- package/open-sse/providers/registry/xai.js +5 -3
- package/open-sse/rtk/autodetect.js +10 -2
- package/open-sse/rtk/caveman.js +2 -93
- package/open-sse/rtk/cavemanPrompts.js +34 -2
- package/open-sse/rtk/constants.js +7 -2
- package/open-sse/rtk/headroom.js +133 -0
- package/open-sse/rtk/ponytail.js +1 -1
- package/open-sse/rtk/registry.js +2 -0
- package/open-sse/services/accountFallback.js +0 -108
- package/open-sse/services/combo/quotaExhaustionCutoff.js +2 -2
- package/open-sse/services/combo/quotaShareStrategy.js +1 -1
- package/open-sse/services/combo/resolveAutoStrategy.js +1 -1
- package/open-sse/services/combo/sessionStickiness.js +1 -1
- package/open-sse/services/combo/shadowRouting.js +1 -1
- package/open-sse/services/combo/targetSorters.js +4 -4
- package/open-sse/services/combo/validateQuality.js +1 -1
- package/open-sse/services/evalRouting.js +1 -1
- package/open-sse/services/grokCliModels.js +127 -0
- package/open-sse/services/model.js +7 -1
- package/open-sse/services/modelCapabilities.js +1 -1
- package/open-sse/services/modelFamilyFallback.js +1 -1
- package/open-sse/services/provider.js +1 -1
- package/open-sse/services/providerCooldownTracker.js +1 -1
- package/open-sse/services/rateLimitManager.js +1 -1
- package/open-sse/services/tokenRefresh/providers.js +3 -3
- package/open-sse/services/usage/codex.js +148 -214
- package/open-sse/services/usage/grok-cli.js +61 -7
- package/open-sse/services/usage/misc.js +0 -19
- package/open-sse/services/usage.js +0 -2
- package/open-sse/translator/concerns/paramSupport.js +2 -2
- package/open-sse/translator/concerns/thinkingUnified.js +6 -0
- package/open-sse/translator/index.js +97 -59
- package/open-sse/translator/request/claude-to-kiro.js +67 -40
- package/open-sse/translator/request/openai-responses.js +1 -0
- package/open-sse/translator/request/openai-to-commandcode.js +0 -4
- package/open-sse/translator/request/openai-to-kiro.js +49 -20
- package/open-sse/translator/response/commandcode-to-openai.js +0 -4
- package/open-sse/utils/bypassHandler.js +18 -3
- package/open-sse/utils/claudeCloaking.js +15 -5
- package/open-sse/utils/error.js +0 -17
- package/open-sse/utils/kiroSessionReplay.js +125 -0
- package/open-sse/utils/logger.js +1 -1
- package/open-sse/utils/proxyFetch.js +0 -1
- package/open-sse/utils/reasoningContentInjector.js +4 -7
- package/open-sse/utils/responsesStreamHelpers.js +1 -0
- package/open-sse/utils/sessionManager.js +49 -22
- package/open-sse/utils/stream.js +54 -77
- package/open-sse/utils/streamHandler.js +19 -15
- package/open-sse/utils/streamHelpers.js +2 -17
- package/open-sse/utils/usageTracking.js +103 -12
- package/package.json +4 -7
- package/public/assets/EndpointPageClient.C2WMTYy0.js +6 -0
- package/public/assets/{Loading.Bj-WGl4k.js → Loading.BHPtQ9vj.js} +1 -1
- package/public/assets/{NoAuthProxyCard.qAv57b-0.js → NoAuthProxyCard.BDcXaWvM.js} +1 -1
- package/public/assets/index.Be3gbrBl.js +89 -0
- package/public/assets/index.COMgQZYj.css +1 -0
- package/public/assets/{page.CbkENBd5.js → page.-lpNgYAw.js} +1 -1
- package/public/assets/{page.CssmrzTT.js → page.11hpNKmq.js} +1 -1
- package/public/assets/{page.C72FTTJr.js → page.B-LxsnqU.js} +1 -1
- package/public/assets/{page.sOFOrxqq.js → page.B-dzeIUC.js} +1 -1
- package/public/assets/{page.CsxWmPoI.js → page.B-nBR75u.js} +1 -1
- package/public/assets/{page.Dx_GRRdT.js → page.B3QqvLep.js} +1 -1
- package/public/assets/{page.DPyOkPVo.js → page.B8xdkCWA.js} +1 -1
- package/public/assets/{page.DUI8kqOY.js → page.BFb7yUd8.js} +1 -1
- package/public/assets/page.BbPPdoas.js +1 -0
- package/public/assets/page.BdS20a1O.js +1 -0
- package/public/assets/{page.DibhF7f-.js → page.BfmI9KYe.js} +1 -1
- package/public/assets/{page.DX4Nno6M.js → page.BgGJovOg.js} +1 -1
- package/public/assets/{page.BnmTC5jG.js → page.C0gBvR4O.js} +1 -1
- package/public/assets/{page.D5gj98Oe.js → page.C6bYizL7.js} +1 -1
- package/public/assets/{page.vla5Mzki.js → page.C8sLEMa6.js} +1 -1
- package/public/assets/{page.CXd_R9yU.js → page.CCNsZBXp.js} +1 -1
- package/public/assets/{page.CQlVGoXg.js → page.CF_YSLwP.js} +1 -1
- package/public/assets/{page.BbO1pspY.js → page.CPTtRDxw.js} +1 -1
- package/public/assets/{page.D1oKew1j.js → page.CdMmlUEm.js} +1 -1
- package/public/assets/{page.DxMDTbSx.js → page.Cged1bOZ.js} +1 -1
- package/public/assets/{page.Cj5h09Zo.js → page.Ch647dVk.js} +1 -1
- package/public/assets/{page.DVIHRbxB.js → page.CpvXDkQF.js} +1 -1
- package/public/assets/{page.i4KDuWcM.js → page.CrBl7f8N.js} +1 -1
- package/public/assets/{page.BSLJ4tx5.js → page.CrP7niA2.js} +1 -1
- package/public/assets/{page.CnTop8Zt.js → page.CvUFZzXr.js} +1 -1
- package/public/assets/{page.O2ddJYoT.js → page.CyUqJPmx.js} +1 -1
- package/public/assets/{page.DBhu4Arl.js → page.D8Rp8fFR.js} +1 -1
- package/public/assets/{page.CPZav1_c.js → page.Df9qtrdG.js} +1 -1
- package/public/assets/{page.Qkkv8roc.js → page.DiL4Gwqe.js} +1 -1
- package/public/assets/{page.BdmJ3yY3.js → page.Dl1apZE2.js} +1 -1
- package/public/assets/{page.1qjqvrwX.js → page.HV0w1d5C.js} +1 -1
- package/public/assets/{page.ChX1NqmC.js → page.N1x4YL8_.js} +1 -1
- package/public/assets/{page.Dh5f0XJC.js → page.P2Ny5veR.js} +1 -1
- package/public/assets/{page.CSs3-gdt.js → page.fOOCr18J.js} +1 -1
- package/public/assets/{page.Ir7KvKcF.js → page.sUIPWIiF.js} +1 -1
- package/public/assets/{page.CzlQTyAL.js → page.tE7PpWYW.js} +1 -1
- package/public/assets/{page.DzZLqI5Q.js → page.uziaGZsT.js} +1 -1
- package/public/index.html +2 -2
- package/public/assets/EndpointPageClient.LyNNvZ4z.js +0 -6
- package/public/assets/index.BuPfZebu.css +0 -1
- package/public/assets/index.CShjRV_B.js +0 -89
- package/public/assets/page.DD_czjjP.js +0 -1
|
@@ -1,10 +1,80 @@
|
|
|
1
1
|
import { BaseExecutor } from "./base.js";
|
|
2
|
-
import { PROVIDERS } from "../config/providers.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { PROVIDERS, PROVIDER_OAUTH } from "../config/providers.js";
|
|
3
|
+
import { ANTHROPIC_API_VERSION, OPENAI_COMPAT_BASE, ANTHROPIC_COMPAT_BASE } from "../providers/shared.js";
|
|
4
|
+
import { OAUTH_ENDPOINTS, buildKimiHeaders } from "../config/appConstants.js";
|
|
5
|
+
import { buildClineHeaders } from "../shared/clineAuth.js";
|
|
5
6
|
import { getCachedClaudeHeaders } from "../utils/claudeHeaderCache.js";
|
|
6
7
|
import { proxyAwareFetch } from "../utils/proxyFetch.js";
|
|
7
8
|
import { injectReasoningContent } from "../utils/reasoningContentInjector.js";
|
|
9
|
+
import { stripUnsupportedParams } from "../translator/concerns/paramSupport.js";
|
|
10
|
+
|
|
11
|
+
// Auth header descriptors — derived from registry transport.auth, fallback to hardcoded defaults.
|
|
12
|
+
const BEARER = { combined: true, header: "Authorization", scheme: "bearer" };
|
|
13
|
+
const XAPIKEY = { combined: true, header: "x-api-key", scheme: "raw" };
|
|
14
|
+
const AUTH_DESCRIPTORS = Object.fromEntries(
|
|
15
|
+
Object.entries(PROVIDERS)
|
|
16
|
+
.filter(([, t]) => t.auth)
|
|
17
|
+
.map(([id, t]) => [id, t.auth])
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
// Apply a token to a header per scheme (matches legacy: combined always sets, even when undefined).
|
|
21
|
+
function setAuth(headers, spec, token) {
|
|
22
|
+
headers[spec.header] = spec.scheme === "bearer" ? `Bearer ${token}` : token;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Resolve auth onto headers from a descriptor.
|
|
26
|
+
function applyAuth(headers, desc, credentials) {
|
|
27
|
+
if (desc.combined) {
|
|
28
|
+
// combined providers always set the header (legacy behavior, incl. noAuth → "Bearer undefined")
|
|
29
|
+
setAuth(headers, desc, credentials.apiKey || credentials.accessToken);
|
|
30
|
+
if (desc.anthropicVersion && !headers["anthropic-version"]) headers["anthropic-version"] = ANTHROPIC_API_VERSION;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// split apiKey/oauth: set only the matching branch (legacy: anthropic-compatible skips when both absent)
|
|
34
|
+
if (credentials.apiKey) setAuth(headers, desc.apiKey, credentials.apiKey);
|
|
35
|
+
else if (credentials.accessToken) setAuth(headers, desc.oauth, credentials.accessToken);
|
|
36
|
+
if (desc.anthropicVersion && !headers["anthropic-version"]) headers["anthropic-version"] = ANTHROPIC_API_VERSION;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Provider-specific header quirks kept as small hooks (not pure auth).
|
|
40
|
+
const HEADER_HOOKS = {
|
|
41
|
+
kimiHeaders: (h) => Object.assign(h, buildKimiHeaders()),
|
|
42
|
+
clineHeaders: (h, c) => Object.assign(h, buildClineHeaders(c.apiKey || c.accessToken)),
|
|
43
|
+
kilocodeOrg: (h, c) => { if (c.providerSpecificData?.orgId) h["X-Kilocode-OrganizationID"] = c.providerSpecificData.orgId; },
|
|
44
|
+
claudeOverlay: (h) => {
|
|
45
|
+
const cached = getCachedClaudeHeaders();
|
|
46
|
+
if (!cached) return;
|
|
47
|
+
for (const lcKey of Object.keys(cached)) {
|
|
48
|
+
const titleKey = lcKey.replace(/(^|-)([a-z])/g, (_, sep, ch) => sep + ch.toUpperCase());
|
|
49
|
+
if (lcKey === "anthropic-beta") {
|
|
50
|
+
const staticBetaStr = h[titleKey] || h[lcKey] || "";
|
|
51
|
+
const flags = new Set(staticBetaStr.split(",").map(f => f.trim()).filter(Boolean));
|
|
52
|
+
for (const f of cached[lcKey].split(",").map(f => f.trim()).filter(Boolean)) flags.add(f);
|
|
53
|
+
cached[lcKey] = Array.from(flags).join(",");
|
|
54
|
+
}
|
|
55
|
+
if (titleKey !== lcKey && h[titleKey] !== undefined) delete h[titleKey];
|
|
56
|
+
}
|
|
57
|
+
Object.assign(h, cached);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Config-driven OAuth refresh grants — derived from registry oauth.refresh.
|
|
62
|
+
const REFRESH_GRANTS = Object.fromEntries(
|
|
63
|
+
Object.entries(PROVIDER_OAUTH)
|
|
64
|
+
.filter(([, o]) => o.refresh)
|
|
65
|
+
.map(([id, o]) => {
|
|
66
|
+
const tokenUrl = o.tokenUrl;
|
|
67
|
+
const encoding = o.refresh.encoding;
|
|
68
|
+
const extraParams = o.refresh.scope ? { scope: o.refresh.scope } : {};
|
|
69
|
+
return [id, {
|
|
70
|
+
encoding,
|
|
71
|
+
url: () => tokenUrl,
|
|
72
|
+
params: (ex) => id === "gemini"
|
|
73
|
+
? { client_id: ex.config.clientId, client_secret: ex.config.clientSecret, ...extraParams }
|
|
74
|
+
: { client_id: o.clientId, ...extraParams },
|
|
75
|
+
}];
|
|
76
|
+
})
|
|
77
|
+
);
|
|
8
78
|
|
|
9
79
|
export class DefaultExecutor extends BaseExecutor {
|
|
10
80
|
constructor(provider) {
|
|
@@ -12,85 +82,14 @@ export class DefaultExecutor extends BaseExecutor {
|
|
|
12
82
|
}
|
|
13
83
|
|
|
14
84
|
transformRequest(model, body) {
|
|
15
|
-
|
|
85
|
+
const transformed = this.applyJsonSchemaFallback(body);
|
|
16
86
|
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
messages = messages.map(msg => {
|
|
22
|
-
if (msg.role === "tool") {
|
|
23
|
-
const newMsg = { ...msg, role: "user" };
|
|
24
|
-
delete newMsg.tool_call_id;
|
|
25
|
-
delete newMsg.name;
|
|
26
|
-
return newMsg;
|
|
27
|
-
}
|
|
28
|
-
return msg;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Ensure at least 2 messages: add system message if only 1 user message
|
|
32
|
-
if (messages.length === 1 && messages[0].role === "user") {
|
|
33
|
-
messages.unshift({
|
|
34
|
-
role: "system",
|
|
35
|
-
content: "You are a helpful assistant."
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// CodeBuddy API does not support "strict" mode in tools parameter
|
|
40
|
-
let tools = transformed.tools;
|
|
41
|
-
if (Array.isArray(tools)) {
|
|
42
|
-
if (tools.length === 0) {
|
|
43
|
-
tools = undefined;
|
|
44
|
-
} else {
|
|
45
|
-
// Recursive function to strip $schema and default
|
|
46
|
-
const cleanSchema = (obj) => {
|
|
47
|
-
if (!obj || typeof obj !== 'object') return;
|
|
48
|
-
if (Array.isArray(obj)) {
|
|
49
|
-
obj.forEach(cleanSchema);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
delete obj.$schema;
|
|
53
|
-
delete obj.default;
|
|
54
|
-
for (const key of Object.keys(obj)) {
|
|
55
|
-
cleanSchema(obj[key]);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
tools = tools.map(t => {
|
|
60
|
-
if (t && t.type === "function" && t.function) {
|
|
61
|
-
const func = { ...t.function };
|
|
62
|
-
delete func.strict;
|
|
63
|
-
if (func.parameters) {
|
|
64
|
-
cleanSchema(func.parameters);
|
|
65
|
-
}
|
|
66
|
-
return { ...t, function: func };
|
|
67
|
-
}
|
|
68
|
-
return t;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
transformed = { ...transformed, messages, stream: true };
|
|
74
|
-
if (tools) transformed.tools = tools;
|
|
75
|
-
|
|
76
|
-
// CodeBuddy API strictness: delete stream_options, tool_choice unconditionally
|
|
77
|
-
delete transformed.stream_options;
|
|
78
|
-
delete transformed.tool_choice;
|
|
79
|
-
|
|
80
|
-
// Strip tool_calls from assistant messages if CodeBuddy is strictly validating history
|
|
81
|
-
if (transformed.messages) {
|
|
82
|
-
transformed.messages = transformed.messages.map(msg => {
|
|
83
|
-
if (msg.role === "assistant" && msg.tool_calls) {
|
|
84
|
-
const newMsg = { ...msg };
|
|
85
|
-
// Convert tool_calls to text so context isn't fully lost
|
|
86
|
-
const toolSummary = newMsg.tool_calls.map(tc => `[Called tool: ${tc.function?.name}]`).join("\n");
|
|
87
|
-
newMsg.content = newMsg.content ? `${newMsg.content}\n${toolSummary}` : toolSummary;
|
|
88
|
-
delete newMsg.tool_calls;
|
|
89
|
-
return newMsg;
|
|
90
|
-
}
|
|
91
|
-
return msg;
|
|
92
|
-
});
|
|
87
|
+
if (transformed && typeof transformed === "object") {
|
|
88
|
+
// quirk: some openai-compatible providers reject Anthropic's client_metadata field
|
|
89
|
+
if (this.config.quirks?.dropClientMetadata) {
|
|
90
|
+
delete transformed.client_metadata;
|
|
93
91
|
}
|
|
92
|
+
stripUnsupportedParams(this.provider, model, transformed);
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
return injectReasoningContent({ provider: this.provider, model, body: transformed });
|
|
@@ -117,135 +116,69 @@ export class DefaultExecutor extends BaseExecutor {
|
|
|
117
116
|
}
|
|
118
117
|
|
|
119
118
|
buildUrl(model, stream, urlIndex = 0, credentials = null) {
|
|
119
|
+
// Runtime transport (multi-endpoint providers): use the sourceFormat-matched endpoint
|
|
120
|
+
const rt = credentials?.runtimeTransport;
|
|
121
|
+
if (rt?.baseUrl) {
|
|
122
|
+
return rt.urlSuffix ? `${rt.baseUrl}${rt.urlSuffix}` : rt.baseUrl;
|
|
123
|
+
}
|
|
120
124
|
if (this.provider?.startsWith?.("openai-compatible-")) {
|
|
121
|
-
const baseUrl = credentials?.providerSpecificData?.baseUrl ||
|
|
125
|
+
const baseUrl = credentials?.providerSpecificData?.baseUrl || OPENAI_COMPAT_BASE;
|
|
122
126
|
const normalized = baseUrl.replace(/\/$/, "");
|
|
123
127
|
const path = this.provider.includes("responses") ? "/responses" : "/chat/completions";
|
|
124
128
|
return `${normalized}${path}`;
|
|
125
129
|
}
|
|
126
130
|
if (this.provider?.startsWith?.("anthropic-compatible-")) {
|
|
127
|
-
const baseUrl = credentials?.providerSpecificData?.baseUrl ||
|
|
131
|
+
const baseUrl = credentials?.providerSpecificData?.baseUrl || ANTHROPIC_COMPAT_BASE;
|
|
128
132
|
const normalized = baseUrl.replace(/\/$/, "");
|
|
129
133
|
return `${normalized}/messages`;
|
|
130
134
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (url?.includes("{accountId}")) {
|
|
145
|
-
const accountId = credentials?.providerSpecificData?.accountId;
|
|
146
|
-
if (!accountId) throw new Error(`${this.provider} requires accountId in providerSpecificData`);
|
|
147
|
-
return url.replace("{accountId}", accountId);
|
|
148
|
-
}
|
|
149
|
-
return url;
|
|
150
|
-
}
|
|
135
|
+
// gemini-format: build :streamGenerateContent / :generateContent path
|
|
136
|
+
if (this.config.format === "gemini") {
|
|
137
|
+
return `${this.config.baseUrl}/${model}:${stream ? "streamGenerateContent?alt=sse" : "generateContent"}`;
|
|
138
|
+
}
|
|
139
|
+
// urlSuffix (e.g. ?beta=true) declared per-provider in registry
|
|
140
|
+
if (this.config.urlSuffix) {
|
|
141
|
+
return `${this.config.baseUrl}${this.config.urlSuffix}`;
|
|
142
|
+
}
|
|
143
|
+
const url = this.config.baseUrl;
|
|
144
|
+
if (url?.includes("{accountId}")) {
|
|
145
|
+
const accountId = credentials?.providerSpecificData?.accountId;
|
|
146
|
+
if (!accountId) throw new Error(`${this.provider} requires accountId in providerSpecificData`);
|
|
147
|
+
return url.replace("{accountId}", accountId);
|
|
151
148
|
}
|
|
149
|
+
return url;
|
|
152
150
|
}
|
|
153
151
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
case "claude": {
|
|
162
|
-
// Overlay live cached headers from real Claude Code client over static defaults.
|
|
163
|
-
// Static headers (Title-Case) remain as cold-start fallback.
|
|
164
|
-
const cached = getCachedClaudeHeaders();
|
|
165
|
-
if (cached) {
|
|
166
|
-
// Remove Title-Case static keys that conflict with incoming lowercase cached keys
|
|
167
|
-
for (const lcKey of Object.keys(cached)) {
|
|
168
|
-
// Build the Title-Case equivalent: "anthropic-version" → "Anthropic-Version"
|
|
169
|
-
const titleKey = lcKey.replace(/(^|-)([a-z])/g, (_, sep, c) => sep + c.toUpperCase());
|
|
170
|
-
|
|
171
|
-
// Special handling for Anthropic-Beta to preserve required flags like OAuth
|
|
172
|
-
if (lcKey === "anthropic-beta") {
|
|
173
|
-
const staticBetaStr = headers[titleKey] || headers[lcKey] || "";
|
|
174
|
-
const staticFlags = new Set(staticBetaStr.split(",").map(f => f.trim()).filter(Boolean));
|
|
175
|
-
const cachedFlags = new Set(cached[lcKey].split(",").map(f => f.trim()).filter(Boolean));
|
|
176
|
-
|
|
177
|
-
// Merge all static flags (which contain oauth, thinking, etc) into the cached ones
|
|
178
|
-
for (const flag of staticFlags) {
|
|
179
|
-
cachedFlags.add(flag);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
cached[lcKey] = Array.from(cachedFlags).join(",");
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (titleKey !== lcKey && headers[titleKey] !== undefined) {
|
|
186
|
-
delete headers[titleKey];
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
Object.assign(headers, cached);
|
|
190
|
-
}
|
|
191
|
-
credentials.apiKey
|
|
192
|
-
? (headers["x-api-key"] = credentials.apiKey)
|
|
193
|
-
: (headers["Authorization"] = `Bearer ${credentials.accessToken}`);
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
case "glm":
|
|
197
|
-
case "kimi":
|
|
198
|
-
case "minimax":
|
|
199
|
-
case "minimax-cn":
|
|
200
|
-
headers["x-api-key"] = credentials.apiKey || credentials.accessToken;
|
|
201
|
-
break;
|
|
202
|
-
case "kimi-coding":
|
|
203
|
-
headers["Authorization"] = `Bearer ${credentials.apiKey || credentials.accessToken}`;
|
|
204
|
-
Object.assign(headers, buildKimiHeaders());
|
|
205
|
-
break;
|
|
206
|
-
case "kimchi":
|
|
207
|
-
headers["Authorization"] = `Bearer ${credentials.apiKey || credentials.accessToken}`;
|
|
208
|
-
headers["User-Agent"] = `kimchi/${getKimchiVersionSync()}`;
|
|
209
|
-
break;
|
|
210
|
-
case "ibm-bob":
|
|
211
|
-
headers["Authorization"] = `apikey ${credentials.apiKey || credentials.accessToken}`;
|
|
212
|
-
break;
|
|
213
|
-
default:
|
|
214
|
-
if (this.provider?.startsWith?.("anthropic-compatible-")) {
|
|
215
|
-
if (credentials.apiKey) {
|
|
216
|
-
headers["x-api-key"] = credentials.apiKey;
|
|
217
|
-
} else if (credentials.accessToken) {
|
|
218
|
-
headers["Authorization"] = `Bearer ${credentials.accessToken}`;
|
|
219
|
-
}
|
|
220
|
-
if (!headers["anthropic-version"]) {
|
|
221
|
-
headers["anthropic-version"] = "2023-06-01";
|
|
222
|
-
}
|
|
223
|
-
} else if (this.provider === "gitlab") {
|
|
224
|
-
// GitLab Duo uses Bearer token (PAT with ai_features scope, or OAuth access token)
|
|
225
|
-
headers["Authorization"] = `Bearer ${credentials.apiKey || credentials.accessToken}`;
|
|
226
|
-
} else if (this.provider === "codebuddy" || this.provider === "cb") {
|
|
227
|
-
headers["Authorization"] = `Bearer ${credentials.apiKey || credentials.accessToken}`;
|
|
228
|
-
} else if (this.provider === "kilocode") {
|
|
229
|
-
headers["Authorization"] = `Bearer ${credentials.apiKey || credentials.accessToken}`;
|
|
230
|
-
if (credentials.providerSpecificData?.orgId) {
|
|
231
|
-
headers["X-Kilocode-OrganizationID"] = credentials.providerSpecificData.orgId;
|
|
232
|
-
}
|
|
233
|
-
} else if (this.provider === "cline") {
|
|
234
|
-
Object.assign(headers, buildClineHeaders(credentials.apiKey || credentials.accessToken));
|
|
235
|
-
} else if (this.config?.format === "claude") {
|
|
236
|
-
// Generic claude-format provider (e.g. agentrouter): x-api-key + anthropic-version
|
|
237
|
-
headers["x-api-key"] = credentials.apiKey || credentials.accessToken;
|
|
238
|
-
if (!headers["anthropic-version"]) headers["anthropic-version"] = "2023-06-01";
|
|
239
|
-
} else {
|
|
240
|
-
headers["Authorization"] = `Bearer ${credentials.apiKey || credentials.accessToken}`;
|
|
241
|
-
}
|
|
152
|
+
// Fallback descriptor for providers without an explicit entry in AUTH_DESCRIPTORS.
|
|
153
|
+
resolveAuthDescriptor() {
|
|
154
|
+
if (this.provider?.startsWith?.("anthropic-compatible-")) {
|
|
155
|
+
return { apiKey: { header: "x-api-key", scheme: "raw" }, oauth: { header: "Authorization", scheme: "bearer" }, anthropicVersion: true };
|
|
156
|
+
}
|
|
157
|
+
if (this.config?.format === "claude") {
|
|
158
|
+
return { ...XAPIKEY, anthropicVersion: true };
|
|
242
159
|
}
|
|
160
|
+
return BEARER;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
buildHeaders(credentials, stream = true) {
|
|
164
|
+
const rt = credentials?.runtimeTransport;
|
|
165
|
+
const headers = { "Content-Type": "application/json", ...(rt ? rt.headers : this.config.headers) };
|
|
166
|
+
const desc = rt?.auth || AUTH_DESCRIPTORS[this.provider] || this.resolveAuthDescriptor();
|
|
167
|
+
// Hooks run BEFORE auth so dynamic overlays (claude cached headers) can't clobber the token.
|
|
168
|
+
for (const hook of desc.hooks || []) HEADER_HOOKS[hook]?.(headers, credentials);
|
|
169
|
+
applyAuth(headers, desc, credentials);
|
|
243
170
|
|
|
244
171
|
// Strip first-party Claude Code identity headers for non-Anthropic anthropic-compatible upstreams
|
|
245
172
|
if (this.provider?.startsWith?.("anthropic-compatible-")) {
|
|
246
173
|
const baseUrl = credentials?.providerSpecificData?.baseUrl || "";
|
|
247
174
|
const isOfficialAnthropic = baseUrl === "" || baseUrl.includes("api.anthropic.com");
|
|
248
175
|
if (!isOfficialAnthropic) {
|
|
176
|
+
// Some third-party Anthropic-compatible gateways require Bearer auth in
|
|
177
|
+
// addition to x-api-key. Send both (x-api-key already set above) so
|
|
178
|
+
// gateways that read either header succeed.
|
|
179
|
+
if (credentials.apiKey && !headers["Authorization"]) {
|
|
180
|
+
headers["Authorization"] = `Bearer ${credentials.apiKey}`;
|
|
181
|
+
}
|
|
249
182
|
delete headers["anthropic-dangerous-direct-browser-access"];
|
|
250
183
|
delete headers["Anthropic-Dangerous-Direct-Browser-Access"];
|
|
251
184
|
delete headers["x-app"];
|
|
@@ -272,44 +205,28 @@ export class DefaultExecutor extends BaseExecutor {
|
|
|
272
205
|
return headers;
|
|
273
206
|
}
|
|
274
207
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
log?.error?.("TOKEN", `Leonardo refresh error: ${error.message}`);
|
|
285
|
-
return null;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (this.provider === "weavy") {
|
|
290
|
-
try {
|
|
291
|
-
const { refreshWeavyToken } = await import("../services/tokenRefresh.js");
|
|
292
|
-
const email = credentials?.email || credentials?.name || credentials?.connectionName;
|
|
293
|
-
if (!email) return null;
|
|
294
|
-
const result = await refreshWeavyToken(email, credentials, log);
|
|
295
|
-
if (result) log?.info?.("TOKEN", "Weavy refreshed");
|
|
296
|
-
return result;
|
|
297
|
-
} catch (error) {
|
|
298
|
-
log?.error?.("TOKEN", `Weavy refresh error: ${error.message}`);
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
208
|
+
// Generic OAuth refresh for the common {grant_type, refresh_token, client_id[, ...]} shape.
|
|
209
|
+
// grant = REFRESH_GRANTS[provider]; client creds resolved from PROVIDERS or this.config.
|
|
210
|
+
refreshFromGrant(credentials, proxyOptions) {
|
|
211
|
+
const grant = REFRESH_GRANTS[this.provider];
|
|
212
|
+
const params = { grant_type: "refresh_token", refresh_token: credentials.refreshToken, ...grant.params(this) };
|
|
213
|
+
return grant.encoding === "json"
|
|
214
|
+
? this.refreshWithJSON(grant.url(), params, proxyOptions)
|
|
215
|
+
: this.refreshWithForm(grant.url(), params, proxyOptions);
|
|
216
|
+
}
|
|
302
217
|
|
|
218
|
+
async refreshCredentials(credentials, log, proxyOptions = null) {
|
|
303
219
|
if (!credentials.refreshToken) return null;
|
|
304
220
|
|
|
305
221
|
const refreshers = {
|
|
306
|
-
claude: () => this.
|
|
307
|
-
codex: () => this.
|
|
222
|
+
claude: () => this.refreshFromGrant(credentials, proxyOptions),
|
|
223
|
+
codex: () => this.refreshFromGrant(credentials, proxyOptions),
|
|
308
224
|
qwen: () => this.refreshWithForm(OAUTH_ENDPOINTS.qwen.token, { grant_type: "refresh_token", refresh_token: credentials.refreshToken, client_id: PROVIDERS.qwen.clientId }, proxyOptions),
|
|
309
225
|
iflow: () => this.refreshIflow(credentials.refreshToken, proxyOptions),
|
|
310
|
-
gemini: () => this.
|
|
226
|
+
gemini: () => this.refreshFromGrant(credentials, proxyOptions),
|
|
311
227
|
kiro: () => this.refreshKiro(credentials.refreshToken, proxyOptions),
|
|
312
228
|
cline: () => this.refreshCline(credentials.refreshToken, proxyOptions),
|
|
229
|
+
clinepass: () => this.refreshCline(credentials.refreshToken, proxyOptions),
|
|
313
230
|
"kimi-coding": () => this.refreshKimiCoding(credentials.refreshToken, proxyOptions),
|
|
314
231
|
kilocode: () => this.refreshKilocode(credentials.refreshToken, proxyOptions)
|
|
315
232
|
};
|
|
@@ -361,17 +278,6 @@ export class DefaultExecutor extends BaseExecutor {
|
|
|
361
278
|
return { accessToken: tokens.access_token, refreshToken: tokens.refresh_token || refreshToken, expiresIn: tokens.expires_in };
|
|
362
279
|
}
|
|
363
280
|
|
|
364
|
-
async refreshGoogle(refreshToken, proxyOptions = null) {
|
|
365
|
-
const response = await proxyAwareFetch(OAUTH_ENDPOINTS.google.token, {
|
|
366
|
-
method: "POST",
|
|
367
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json" },
|
|
368
|
-
body: new URLSearchParams({ grant_type: "refresh_token", refresh_token: refreshToken, client_id: this.config.clientId, client_secret: this.config.clientSecret })
|
|
369
|
-
}, proxyOptions);
|
|
370
|
-
if (!response.ok) return null;
|
|
371
|
-
const tokens = await response.json();
|
|
372
|
-
return { accessToken: tokens.access_token, refreshToken: tokens.refresh_token || refreshToken, expiresIn: tokens.expires_in };
|
|
373
|
-
}
|
|
374
|
-
|
|
375
281
|
async refreshKiro(refreshToken, proxyOptions = null) {
|
|
376
282
|
const response = await proxyAwareFetch(PROVIDERS.kiro.tokenUrl, {
|
|
377
283
|
method: "POST",
|
|
@@ -384,37 +290,33 @@ export class DefaultExecutor extends BaseExecutor {
|
|
|
384
290
|
}
|
|
385
291
|
|
|
386
292
|
async refreshCline(refreshToken, proxyOptions = null) {
|
|
387
|
-
|
|
388
|
-
const response = await proxyAwareFetch("https://api.cline.bot/api/v1/auth/refresh", {
|
|
293
|
+
const response = await proxyAwareFetch(PROVIDERS.cline.refreshUrl, {
|
|
389
294
|
method: "POST",
|
|
390
295
|
headers: { "Content-Type": "application/json", "Accept": "application/json" },
|
|
391
296
|
body: JSON.stringify({ refreshToken, grantType: "refresh_token", clientType: "extension" })
|
|
392
297
|
}, proxyOptions);
|
|
393
|
-
|
|
394
|
-
if (!response.ok) {
|
|
395
|
-
const errorText = await response.text();
|
|
396
|
-
console.log('[DEBUG] Cline refresh error:', errorText);
|
|
397
|
-
return null;
|
|
398
|
-
}
|
|
298
|
+
if (!response.ok) return null;
|
|
399
299
|
const payload = await response.json();
|
|
400
|
-
console.log('[DEBUG] Cline refresh payload:', JSON.stringify(payload).substring(0, 200));
|
|
401
300
|
const data = payload?.data || payload;
|
|
402
301
|
const expiresAtIso = data?.expiresAt;
|
|
403
302
|
const expiresIn = expiresAtIso ? Math.max(1, Math.floor((new Date(expiresAtIso).getTime() - Date.now()) / 1000)) : undefined;
|
|
404
|
-
|
|
405
|
-
|
|
303
|
+
let accessToken = data?.accessToken;
|
|
304
|
+
if (accessToken && !accessToken.startsWith("workos:")) {
|
|
305
|
+
accessToken = `workos:${accessToken}`;
|
|
306
|
+
}
|
|
307
|
+
return { accessToken, refreshToken: data?.refreshToken || refreshToken, expiresIn };
|
|
406
308
|
}
|
|
407
309
|
|
|
408
310
|
async refreshKimiCoding(refreshToken, proxyOptions = null) {
|
|
409
311
|
const kimiHeaders = buildKimiHeaders();
|
|
410
|
-
const response = await proxyAwareFetch("
|
|
312
|
+
const response = await proxyAwareFetch(PROVIDERS["kimi-coding"].refreshUrl, {
|
|
411
313
|
method: "POST",
|
|
412
314
|
headers: {
|
|
413
315
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
414
316
|
"Accept": "application/json",
|
|
415
317
|
...kimiHeaders
|
|
416
318
|
},
|
|
417
|
-
body: new URLSearchParams({ grant_type: "refresh_token", refresh_token: refreshToken, client_id: "
|
|
319
|
+
body: new URLSearchParams({ grant_type: "refresh_token", refresh_token: refreshToken, client_id: PROVIDERS["kimi-coding"].clientId })
|
|
418
320
|
}, proxyOptions);
|
|
419
321
|
if (!response.ok) return null;
|
|
420
322
|
const tokens = await response.json();
|