@fudrouter/fsrouter 0.6.59 → 0.6.61
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/package.json +1 -1
- package/open-sse/AGENTS.md +0 -39
- package/open-sse/config/anthropicHeaders.js +0 -87
- package/open-sse/config/appConstants.js +0 -238
- package/open-sse/config/audioRegistry.js +0 -506
- package/open-sse/config/cliFingerprints.js +0 -304
- package/open-sse/config/codexInstructions.js +0 -119
- package/open-sse/config/codexQuotaScopes.js +0 -42
- package/open-sse/config/constants.js +0 -4
- package/open-sse/config/contextEditing.js +0 -68
- package/open-sse/config/credentialLoader.js +0 -83
- package/open-sse/config/defaultThinkingSignature.js +0 -12
- package/open-sse/config/embeddingRegistry.js +0 -264
- package/open-sse/config/errorConfig.js +0 -96
- package/open-sse/config/freeModelCatalog.data.js +0 -121
- package/open-sse/config/freeModelCatalog.js +0 -90
- package/open-sse/config/freeTierCatalog.js +0 -81
- package/open-sse/config/googleTtsLanguages.js +0 -62
- package/open-sse/config/imageParamDefs.js +0 -360
- package/open-sse/config/imageRegistry.js +0 -493
- package/open-sse/config/kiroConstants.js +0 -268
- package/open-sse/config/mediaConfig.js +0 -27
- package/open-sse/config/mediaServiceKinds.js +0 -71
- package/open-sse/config/models.js +0 -13
- package/open-sse/config/moderationRegistry.js +0 -71
- package/open-sse/config/musicRegistry.js +0 -99
- package/open-sse/config/ocrRegistry.js +0 -61
- package/open-sse/config/ollamaModels.js +0 -19
- package/open-sse/config/providerErrorRules.js +0 -114
- package/open-sse/config/providerFieldStrips.js +0 -35
- package/open-sse/config/providerHeaderProfiles.js +0 -191
- package/open-sse/config/providerModels.js +0 -106
- package/open-sse/config/providerRegistry.js +0 -16
- package/open-sse/config/providers.js +0 -19
- package/open-sse/config/registryUtils.js +0 -106
- package/open-sse/config/rerankRegistry.js +0 -177
- package/open-sse/config/runtimeConfig.js +0 -96
- package/open-sse/config/runway.js +0 -39
- package/open-sse/config/searchRegistry.js +0 -153
- package/open-sse/config/toolCloaking.js +0 -199
- package/open-sse/config/ttsModels.js +0 -129
- package/open-sse/config/videoRegistry.js +0 -207
- package/open-sse/executors/adapta-web.js +0 -435
- package/open-sse/executors/antigravity.js +0 -534
- package/open-sse/executors/antigravityUpstreamError.js +0 -13
- package/open-sse/executors/auggie.js +0 -437
- package/open-sse/executors/azure-openai.js +0 -32
- package/open-sse/executors/azure.js +0 -57
- package/open-sse/executors/base.js +0 -181
- package/open-sse/executors/bedrock.js +0 -633
- package/open-sse/executors/blackbox-web.js +0 -578
- package/open-sse/executors/chatgpt-web.js +0 -2042
- package/open-sse/executors/chipotle.js +0 -357
- package/open-sse/executors/claude-web-with-auto-refresh.js +0 -73
- package/open-sse/executors/claude-web.js +0 -586
- package/open-sse/executors/cliproxyapi.js +0 -296
- package/open-sse/executors/cloudflare-ai.js +0 -46
- package/open-sse/executors/codebuddy-cn.js +0 -40
- package/open-sse/executors/codex.js +0 -1324
- package/open-sse/executors/commandCode.js +0 -558
- package/open-sse/executors/commandcode.js +0 -88
- package/open-sse/executors/copilot-m365-connection.js +0 -176
- package/open-sse/executors/copilot-m365-frames.js +0 -192
- package/open-sse/executors/copilot-m365-web.js +0 -299
- package/open-sse/executors/copilot-web.js +0 -580
- package/open-sse/executors/cursor.js +0 -795
- package/open-sse/executors/deepseek-web-with-auto-refresh.js +0 -150
- package/open-sse/executors/deepseek-web.js +0 -875
- package/open-sse/executors/default.js +0 -430
- package/open-sse/executors/devin-cli.js +0 -351
- package/open-sse/executors/doubao-web.js +0 -550
- package/open-sse/executors/duckduckgo-web.js +0 -629
- package/open-sse/executors/forceResponsesUpstream.js +0 -33
- package/open-sse/executors/gemini-business.js +0 -320
- package/open-sse/executors/gemini-cli.js +0 -89
- package/open-sse/executors/gemini-web.js +0 -297
- package/open-sse/executors/github.js +0 -379
- package/open-sse/executors/gitlab.js +0 -569
- package/open-sse/executors/glm.js +0 -361
- package/open-sse/executors/grok-cli.js +0 -119
- package/open-sse/executors/grok-web.js +0 -345
- package/open-sse/executors/huggingchat.js +0 -467
- package/open-sse/executors/iflow.js +0 -108
- package/open-sse/executors/index.js +0 -78
- package/open-sse/executors/inner-ai.js +0 -527
- package/open-sse/executors/kimchi.js +0 -123
- package/open-sse/executors/kimi-web.js +0 -325
- package/open-sse/executors/kimi.js +0 -97
- package/open-sse/executors/kiro.js +0 -503
- package/open-sse/executors/kiroThinking.js +0 -44
- package/open-sse/executors/lmarena.js +0 -395
- package/open-sse/executors/mimo-free.js +0 -167
- package/open-sse/executors/mimocode.js +0 -392
- package/open-sse/executors/ninerouter.js +0 -155
- package/open-sse/executors/nlpcloud.js +0 -438
- package/open-sse/executors/ollama-local.js +0 -14
- package/open-sse/executors/opencode-go.js +0 -41
- package/open-sse/executors/opencode.js +0 -32
- package/open-sse/executors/perplexity-web.js +0 -581
- package/open-sse/executors/poe-web.js +0 -133
- package/open-sse/executors/pollinations.js +0 -95
- package/open-sse/executors/puter.js +0 -31
- package/open-sse/executors/qoder.js +0 -448
- package/open-sse/executors/qwen-web.js +0 -372
- package/open-sse/executors/qwen.js +0 -129
- package/open-sse/executors/t3-chat-web.js +0 -417
- package/open-sse/executors/theoldllm.js +0 -290
- package/open-sse/executors/trae.js +0 -418
- package/open-sse/executors/v0-vercel-web.js +0 -141
- package/open-sse/executors/venice-web.js +0 -142
- package/open-sse/executors/vertex.js +0 -131
- package/open-sse/executors/vertexMedia.js +0 -236
- package/open-sse/executors/windsurf.js +0 -560
- package/open-sse/executors/xai.js +0 -46
- package/open-sse/executors/xiaomi-tokenplan.js +0 -19
- package/open-sse/executors/yuanbao-web.js +0 -385
- package/open-sse/executors/zed-hosted.js +0 -281
- package/open-sse/executors/zenmux-free.js +0 -247
- package/open-sse/handlers/audioSpeech.js +0 -759
- package/open-sse/handlers/audioTranscription.js +0 -395
- package/open-sse/handlers/audioTranslation.js +0 -181
- package/open-sse/handlers/chatCore/nonStreamingHandler.js +0 -300
- package/open-sse/handlers/chatCore/requestDetail.js +0 -102
- package/open-sse/handlers/chatCore/sseToJsonHandler.js +0 -231
- package/open-sse/handlers/chatCore/streamingHandler.js +0 -95
- package/open-sse/handlers/chatCore.js +0 -404
- package/open-sse/handlers/embeddingProviders/_base.js +0 -4
- package/open-sse/handlers/embeddingProviders/gemini.js +0 -54
- package/open-sse/handlers/embeddingProviders/index.js +0 -23
- package/open-sse/handlers/embeddingProviders/openai.js +0 -39
- package/open-sse/handlers/embeddingProviders/openaiCompatNode.js +0 -13
- package/open-sse/handlers/embeddingsCore.js +0 -126
- package/open-sse/handlers/fetch/index.js +0 -237
- package/open-sse/handlers/imageGenerationCore.js +0 -230
- package/open-sse/handlers/imageProviders/_base.js +0 -31
- package/open-sse/handlers/imageProviders/antigravity.js +0 -73
- package/open-sse/handlers/imageProviders/blackForestLabs.js +0 -63
- package/open-sse/handlers/imageProviders/cloudflareAi.js +0 -207
- package/open-sse/handlers/imageProviders/codex.js +0 -217
- package/open-sse/handlers/imageProviders/comfyui.js +0 -25
- package/open-sse/handlers/imageProviders/falAi.js +0 -62
- package/open-sse/handlers/imageProviders/gemini.js +0 -40
- package/open-sse/handlers/imageProviders/huggingface.js +0 -38
- package/open-sse/handlers/imageProviders/index.js +0 -44
- package/open-sse/handlers/imageProviders/leonardo.js +0 -435
- package/open-sse/handlers/imageProviders/nanobanana.js +0 -79
- package/open-sse/handlers/imageProviders/openai.js +0 -61
- package/open-sse/handlers/imageProviders/runwayml.js +0 -72
- package/open-sse/handlers/imageProviders/sdwebui.js +0 -36
- package/open-sse/handlers/imageProviders/stabilityAi.js +0 -59
- package/open-sse/handlers/imageProviders/weavy.js +0 -222
- package/open-sse/handlers/moderations.js +0 -92
- package/open-sse/handlers/ocr.js +0 -89
- package/open-sse/handlers/rerank.js +0 -223
- package/open-sse/handlers/responseSanitizer/reasoning.js +0 -144
- package/open-sse/handlers/responsesHandler.js +0 -99
- package/open-sse/handlers/search/callers.js +0 -371
- package/open-sse/handlers/search/chatSearch.js +0 -409
- package/open-sse/handlers/search/index.js +0 -201
- package/open-sse/handlers/search/normalizers.js +0 -223
- package/open-sse/handlers/search.js +0 -1056
- package/open-sse/handlers/sseParser.js +0 -469
- package/open-sse/handlers/sttCore.js +0 -193
- package/open-sse/handlers/ttsCore.js +0 -74
- package/open-sse/handlers/ttsProviders/_base.js +0 -39
- package/open-sse/handlers/ttsProviders/edgeTts.js +0 -89
- package/open-sse/handlers/ttsProviders/elevenlabs.js +0 -48
- package/open-sse/handlers/ttsProviders/gemini.js +0 -117
- package/open-sse/handlers/ttsProviders/genericFormats.js +0 -169
- package/open-sse/handlers/ttsProviders/googleTts.js +0 -54
- package/open-sse/handlers/ttsProviders/index.js +0 -50
- package/open-sse/handlers/ttsProviders/localDevice.js +0 -87
- package/open-sse/handlers/ttsProviders/minimax.js +0 -59
- package/open-sse/handlers/ttsProviders/openai.js +0 -30
- package/open-sse/handlers/ttsProviders/openrouter.js +0 -70
- package/open-sse/handlers/usageExtractor.js +0 -93
- package/open-sse/handlers/videoGenerationCore.js +0 -119
- package/open-sse/handlers/videoProviders/index.js +0 -22
- package/open-sse/handlers/videoProviders/leonardo.js +0 -511
- package/open-sse/handlers/videoProviders/weavy.js +0 -198
- package/open-sse/handlers/webFetch.js +0 -200
- package/open-sse/index.js +0 -79
- package/open-sse/mcp-server/audit.js +0 -283
- package/open-sse/mcp-server/catalog.js +0 -184
- package/open-sse/mcp-server/descriptionCompressor.js +0 -175
- package/open-sse/mcp-server/httpAuthContext.js +0 -32
- package/open-sse/mcp-server/httpTransport.js +0 -229
- package/open-sse/mcp-server/index.js +0 -33
- package/open-sse/mcp-server/mcpCallerIdentity.js +0 -21
- package/open-sse/mcp-server/runtimeHeartbeat.js +0 -110
- package/open-sse/mcp-server/schemas/a2a.js +0 -153
- package/open-sse/mcp-server/schemas/audit.js +0 -17
- package/open-sse/mcp-server/schemas/index.js +0 -166
- package/open-sse/mcp-server/schemas/pickFastestModel.js +0 -90
- package/open-sse/mcp-server/schemas/toolDefinition.js +0 -0
- package/open-sse/mcp-server/schemas/toolSearch.js +0 -32
- package/open-sse/mcp-server/schemas/tools.js +0 -1219
- package/open-sse/mcp-server/scopeEnforcement.js +0 -80
- package/open-sse/mcp-server/server.js +0 -1168
- package/open-sse/mcp-server/toolCardinality.js +0 -78
- package/open-sse/mcp-server/toolSearch/catalog.js +0 -66
- package/open-sse/mcp-server/toolSearch/handler.js +0 -20
- package/open-sse/mcp-server/toolSearch/index.js +0 -10
- package/open-sse/mcp-server/toolSearch/register.js +0 -21
- package/open-sse/mcp-server/toolSearch/search.js +0 -55
- package/open-sse/mcp-server/toolSearch/signature.js +0 -67
- package/open-sse/mcp-server/tools/advancedTools.js +0 -893
- package/open-sse/mcp-server/tools/agentSkillTools.js +0 -69
- package/open-sse/mcp-server/tools/compressionTools.js +0 -309
- package/open-sse/mcp-server/tools/gamificationTools.js +0 -134
- package/open-sse/mcp-server/tools/githubSkillTools.js +0 -102
- package/open-sse/mcp-server/tools/memoryTools.js +0 -118
- package/open-sse/mcp-server/tools/notionTools.js +0 -101
- package/open-sse/mcp-server/tools/obsidianTools.js +0 -307
- package/open-sse/mcp-server/tools/pickFastestModel.js +0 -223
- package/open-sse/mcp-server/tools/pluginTools.js +0 -181
- package/open-sse/mcp-server/tools/poolTools.js +0 -139
- package/open-sse/mcp-server/tools/skillTools.js +0 -113
- package/open-sse/package.json +0 -10
- package/open-sse/providers/REGISTRY_TEMPLATE.js +0 -98
- package/open-sse/providers/capabilities.js +0 -293
- package/open-sse/providers/index.js +0 -51
- package/open-sse/providers/models/helpers.js +0 -20
- package/open-sse/providers/models/namePatterns.js +0 -33
- package/open-sse/providers/models/schema.js +0 -40
- package/open-sse/providers/pricing.js +0 -308
- package/open-sse/providers/registry/alicode-intl.js +0 -30
- package/open-sse/providers/registry/alicode.js +0 -31
- package/open-sse/providers/registry/anthropic.js +0 -37
- package/open-sse/providers/registry/antigravity.js +0 -81
- package/open-sse/providers/registry/assemblyai.js +0 -38
- package/open-sse/providers/registry/aws-polly.js +0 -45
- package/open-sse/providers/registry/azure.js +0 -21
- package/open-sse/providers/registry/black-forest-labs.js +0 -32
- package/open-sse/providers/registry/blackbox.js +0 -41
- package/open-sse/providers/registry/brave-search.js +0 -35
- package/open-sse/providers/registry/byteplus.js +0 -35
- package/open-sse/providers/registry/cartesia.js +0 -36
- package/open-sse/providers/registry/cerebras.js +0 -31
- package/open-sse/providers/registry/chutes.js +0 -24
- package/open-sse/providers/registry/claude.js +0 -87
- package/open-sse/providers/registry/cline.js +0 -51
- package/open-sse/providers/registry/clinepass.js +0 -57
- package/open-sse/providers/registry/cloudflare-ai.js +0 -55
- package/open-sse/providers/registry/codebuddy-cn.js +0 -77
- package/open-sse/providers/registry/codex.js +0 -100
- package/open-sse/providers/registry/cohere.js +0 -27
- package/open-sse/providers/registry/comfyui.js +0 -20
- package/open-sse/providers/registry/commandcode.js +0 -43
- package/open-sse/providers/registry/coqui.js +0 -30
- package/open-sse/providers/registry/cursor.js +0 -58
- package/open-sse/providers/registry/deepgram.js +0 -33
- package/open-sse/providers/registry/deepseek.js +0 -51
- package/open-sse/providers/registry/digitalocean.js +0 -92
- package/open-sse/providers/registry/edge-tts.js +0 -24
- package/open-sse/providers/registry/elevenlabs.js +0 -35
- package/open-sse/providers/registry/exa.js +0 -50
- package/open-sse/providers/registry/fal-ai.js +0 -34
- package/open-sse/providers/registry/featherless.js +0 -34
- package/open-sse/providers/registry/firecrawl.js +0 -34
- package/open-sse/providers/registry/fireworks.js +0 -29
- package/open-sse/providers/registry/gemini-cli.js +0 -58
- package/open-sse/providers/registry/gemini.js +0 -83
- package/open-sse/providers/registry/github.js +0 -88
- package/open-sse/providers/registry/gitlab.js +0 -32
- package/open-sse/providers/registry/glm-cn.js +0 -35
- package/open-sse/providers/registry/glm.js +0 -58
- package/open-sse/providers/registry/google-pse.js +0 -35
- package/open-sse/providers/registry/google-tts.js +0 -24
- package/open-sse/providers/registry/grok-cli.js +0 -86
- package/open-sse/providers/registry/grok-web.js +0 -39
- package/open-sse/providers/registry/groq.js +0 -37
- package/open-sse/providers/registry/huggingface.js +0 -34
- package/open-sse/providers/registry/hyperbolic.js +0 -35
- package/open-sse/providers/registry/ibm-bob.js +0 -27
- package/open-sse/providers/registry/iflow.js +0 -52
- package/open-sse/providers/registry/index.js +0 -210
- package/open-sse/providers/registry/inworld.js +0 -36
- package/open-sse/providers/registry/jina-ai.js +0 -42
- package/open-sse/providers/registry/jina-reader.js +0 -34
- package/open-sse/providers/registry/kilocode.js +0 -51
- package/open-sse/providers/registry/kimchi.js +0 -49
- package/open-sse/providers/registry/kimi-coding.js +0 -65
- package/open-sse/providers/registry/kimi.js +0 -56
- package/open-sse/providers/registry/kiro.js +0 -115
- package/open-sse/providers/registry/linkup.js +0 -34
- package/open-sse/providers/registry/local-device.js +0 -24
- package/open-sse/providers/registry/mimo-free.js +0 -24
- package/open-sse/providers/registry/minimax-cn.js +0 -76
- package/open-sse/providers/registry/minimax.js +0 -83
- package/open-sse/providers/registry/mistral.js +0 -34
- package/open-sse/providers/registry/mmf.js +0 -19
- package/open-sse/providers/registry/nanobanana.js +0 -35
- package/open-sse/providers/registry/nebius.js +0 -27
- package/open-sse/providers/registry/nvidia.js +0 -43
- package/open-sse/providers/registry/ollama-local.js +0 -19
- package/open-sse/providers/registry/ollama.js +0 -36
- package/open-sse/providers/registry/openai.js +0 -84
- package/open-sse/providers/registry/opencode-go.js +0 -41
- package/open-sse/providers/registry/opencode.js +0 -25
- package/open-sse/providers/registry/openrouter.js +0 -60
- package/open-sse/providers/registry/perplexity-agent.js +0 -49
- package/open-sse/providers/registry/perplexity-web.js +0 -33
- package/open-sse/providers/registry/perplexity.js +0 -37
- package/open-sse/providers/registry/playht.js +0 -36
- package/open-sse/providers/registry/qoder.js +0 -54
- package/open-sse/providers/registry/qwen.js +0 -33
- package/open-sse/providers/registry/recraft.js +0 -24
- package/open-sse/providers/registry/runwayml.js +0 -30
- package/open-sse/providers/registry/sdwebui.js +0 -20
- package/open-sse/providers/registry/searchapi.js +0 -35
- package/open-sse/providers/registry/searxng.js +0 -35
- package/open-sse/providers/registry/serper.js +0 -35
- package/open-sse/providers/registry/siliconflow.js +0 -39
- package/open-sse/providers/registry/stability-ai.js +0 -31
- package/open-sse/providers/registry/tavily.js +0 -50
- package/open-sse/providers/registry/together.js +0 -31
- package/open-sse/providers/registry/topaz.js +0 -19
- package/open-sse/providers/registry/tortoise.js +0 -30
- package/open-sse/providers/registry/venice.js +0 -56
- package/open-sse/providers/registry/vercel-ai-gateway.js +0 -41
- package/open-sse/providers/registry/vertex-partner.js +0 -29
- package/open-sse/providers/registry/vertex.js +0 -32
- package/open-sse/providers/registry/volcengine-ark.js +0 -35
- package/open-sse/providers/registry/voyage-ai.js +0 -30
- package/open-sse/providers/registry/xai.js +0 -45
- package/open-sse/providers/registry/xiaomi-mimo.js +0 -46
- package/open-sse/providers/registry/xiaomi-tokenplan.js +0 -63
- package/open-sse/providers/registry/youcom.js +0 -35
- package/open-sse/providers/schema.js +0 -76
- package/open-sse/providers/shared.js +0 -74
- package/open-sse/providers/thinkingLevels.js +0 -48
- package/open-sse/rtk/applyFilter.js +0 -15
- package/open-sse/rtk/autodetect.js +0 -111
- package/open-sse/rtk/caveman.js +0 -100
- package/open-sse/rtk/cavemanPrompts.js +0 -78
- package/open-sse/rtk/constants.js +0 -55
- package/open-sse/rtk/filters/buildOutput.js +0 -127
- package/open-sse/rtk/filters/dedupLog.js +0 -44
- package/open-sse/rtk/filters/find.js +0 -50
- package/open-sse/rtk/filters/gitDiff.js +0 -92
- package/open-sse/rtk/filters/gitLog.js +0 -99
- package/open-sse/rtk/filters/gitStatus.js +0 -117
- package/open-sse/rtk/filters/grep.js +0 -48
- package/open-sse/rtk/filters/ls.js +0 -79
- package/open-sse/rtk/filters/readNumbered.js +0 -27
- package/open-sse/rtk/filters/searchList.js +0 -52
- package/open-sse/rtk/filters/smartTruncate.js +0 -15
- package/open-sse/rtk/filters/tree.js +0 -32
- package/open-sse/rtk/headroom.js +0 -215
- package/open-sse/rtk/index.js +0 -155
- package/open-sse/rtk/paleo.js +0 -47
- package/open-sse/rtk/ponytail.js +0 -9
- package/open-sse/rtk/ponytailPrompt.js +0 -52
- package/open-sse/rtk/ponytailPrompts.js +0 -76
- package/open-sse/rtk/pxpipe.js +0 -104
- package/open-sse/rtk/registry.js +0 -38
- package/open-sse/rtk/systemInject.js +0 -98
- package/open-sse/services/accountFallback.js +0 -323
- package/open-sse/services/antigravityHeaders.js +0 -91
- package/open-sse/services/antigravityVersion.js +0 -154
- package/open-sse/services/clinepassModels.js +0 -63
- package/open-sse/services/codexQuotaFetcher.js +0 -312
- package/open-sse/services/codexVerbosity.js +0 -30
- package/open-sse/services/combo/context.js +0 -12
- package/open-sse/services/combo/fingerprintExpansion.js +0 -51
- package/open-sse/services/combo/headroomRanking.js +0 -28
- package/open-sse/services/combo/quotaExhaustionCutoff.js +0 -87
- package/open-sse/services/combo/quotaScoring.js +0 -226
- package/open-sse/services/combo/quotaShareConcurrency.js +0 -25
- package/open-sse/services/combo/quotaShareInflight.js +0 -50
- package/open-sse/services/combo/quotaShareStrategy.js +0 -130
- package/open-sse/services/combo/resolveAutoStrategy.js +0 -231
- package/open-sse/services/combo/responseValidation.js +0 -140
- package/open-sse/services/combo/runtimeUnits.js +0 -195
- package/open-sse/services/combo/sessionStickiness.js +0 -128
- package/open-sse/services/combo/shadowRouting.js +0 -131
- package/open-sse/services/combo/targetExhaustion.js +0 -75
- package/open-sse/services/combo/targetSorters.js +0 -126
- package/open-sse/services/combo/targetTimeoutRunner.js +0 -65
- package/open-sse/services/combo/validateQuality.js +0 -271
- package/open-sse/services/combo.js +0 -571
- package/open-sse/services/comboAgentMiddleware.js +0 -91
- package/open-sse/services/comboConfig.js +0 -153
- package/open-sse/services/comboManifestMetrics.js +0 -10
- package/open-sse/services/comboMetrics.js +0 -278
- package/open-sse/services/compact.js +0 -71
- package/open-sse/services/copilotModels.js +0 -155
- package/open-sse/services/emergencyFallback.js +0 -109
- package/open-sse/services/errorClassifier.js +0 -190
- package/open-sse/services/evalRouting.js +0 -201
- package/open-sse/services/freeWebSearch.js +0 -4
- package/open-sse/services/fusion.js +0 -223
- package/open-sse/services/intentClassifier.js +0 -631
- package/open-sse/services/kimchiModels.js +0 -176
- package/open-sse/services/kiroModels.js +0 -332
- package/open-sse/services/model.js +0 -136
- package/open-sse/services/modelCapabilities.js +0 -5
- package/open-sse/services/modelDeprecation.js +0 -101
- package/open-sse/services/modelFamilyFallback.js +0 -166
- package/open-sse/services/oauthCredentialManager.js +0 -156
- package/open-sse/services/pipeline.js +0 -107
- package/open-sse/services/projectId.js +0 -306
- package/open-sse/services/provider.js +0 -169
- package/open-sse/services/providerCooldownTracker.js +0 -94
- package/open-sse/services/providerDefaultRateLimit.js +0 -11
- package/open-sse/services/proxyAutoSelector.js +0 -24
- package/open-sse/services/qoderModels.js +0 -214
- package/open-sse/services/quotaFetchThrottle.js +0 -103
- package/open-sse/services/quotaMonitor.js +0 -310
- package/open-sse/services/quotaPreflight.js +0 -266
- package/open-sse/services/rateLimitManager/headers.js +0 -56
- package/open-sse/services/rateLimitManager.js +0 -616
- package/open-sse/services/rateLimitSemaphore.js +0 -112
- package/open-sse/services/responsesInputSanitizer.js +0 -99
- package/open-sse/services/slidingWindowLimiter.js +0 -44
- package/open-sse/services/streamRecovery.js +0 -355
- package/open-sse/services/taskAwareRouter.js +0 -227
- package/open-sse/services/taskAwareRouting.js +0 -332
- package/open-sse/services/thinkingBudget.js +0 -247
- package/open-sse/services/tokenRefresh/dedup.js +0 -31
- package/open-sse/services/tokenRefresh/providers.js +0 -624
- package/open-sse/services/tokenRefresh.js +0 -254
- package/open-sse/services/usage/claude.js +0 -147
- package/open-sse/services/usage/codebuddy-cn.js +0 -138
- package/open-sse/services/usage/codex.js +0 -267
- package/open-sse/services/usage/github.js +0 -100
- package/open-sse/services/usage/google.js +0 -241
- package/open-sse/services/usage/grok-cli.js +0 -274
- package/open-sse/services/usage/kiro.js +0 -188
- package/open-sse/services/usage/minimax.js +0 -234
- package/open-sse/services/usage/misc.js +0 -288
- package/open-sse/services/usage/shared.js +0 -70
- package/open-sse/services/usage.js +0 -62
- package/open-sse/services/usageDb.js +0 -2
- package/open-sse/services/webSearchRouting.js +0 -25
- package/open-sse/services/wildcardRouter.js +0 -59
- package/open-sse/shared/clineAuth.js +0 -37
- package/open-sse/shared/machineId.js +0 -19
- package/open-sse/shared/qoder/constants.js +0 -64
- package/open-sse/shared/qoder/cosy.js +0 -175
- package/open-sse/shared/qoder/encoding.js +0 -55
- package/open-sse/transformer/responsesTransformer.js +0 -439
- package/open-sse/transformer/streamToJsonConverter.js +0 -103
- package/open-sse/translator/concerns/chunk.js +0 -11
- package/open-sse/translator/concerns/finishReason.js +0 -63
- package/open-sse/translator/concerns/image.js +0 -124
- package/open-sse/translator/concerns/json.js +0 -5
- package/open-sse/translator/concerns/message.js +0 -7
- package/open-sse/translator/concerns/modality.js +0 -155
- package/open-sse/translator/concerns/paramSupport.js +0 -75
- package/open-sse/translator/concerns/prefetch.js +0 -96
- package/open-sse/translator/concerns/reasoning.js +0 -24
- package/open-sse/translator/concerns/thinking.js +0 -53
- package/open-sse/translator/concerns/thinkingUnified.js +0 -329
- package/open-sse/translator/concerns/toolCall.js +0 -153
- package/open-sse/translator/concerns/usage.js +0 -69
- package/open-sse/translator/formats/claude.js +0 -368
- package/open-sse/translator/formats/gemini.js +0 -380
- package/open-sse/translator/formats/maxTokens.js +0 -34
- package/open-sse/translator/formats/openai.js +0 -134
- package/open-sse/translator/formats/responsesApi.js +0 -141
- package/open-sse/translator/formats.js +0 -36
- package/open-sse/translator/helpers/claudeHelper.js +0 -216
- package/open-sse/translator/helpers/geminiHelper.js +0 -372
- package/open-sse/translator/helpers/imageHelper.js +0 -34
- package/open-sse/translator/helpers/maxTokensHelper.js +0 -27
- package/open-sse/translator/helpers/openaiHelper.js +0 -130
- package/open-sse/translator/helpers/responsesApiHelper.js +0 -139
- package/open-sse/translator/helpers/toolCallHelper.js +0 -148
- package/open-sse/translator/index.js +0 -252
- package/open-sse/translator/request/antigravity-to-openai.js +0 -242
- package/open-sse/translator/request/claude-to-kiro.js +0 -478
- package/open-sse/translator/request/claude-to-openai.js +0 -263
- package/open-sse/translator/request/gemini-to-openai.js +0 -152
- package/open-sse/translator/request/openai-responses.js +0 -385
- package/open-sse/translator/request/openai-to-claude.js +0 -383
- package/open-sse/translator/request/openai-to-commandcode.js +0 -176
- package/open-sse/translator/request/openai-to-cursor.js +0 -185
- package/open-sse/translator/request/openai-to-gemini.js +0 -442
- package/open-sse/translator/request/openai-to-kiro.js +0 -607
- package/open-sse/translator/request/openai-to-kiro.old.js +0 -278
- package/open-sse/translator/request/openai-to-ollama.js +0 -195
- package/open-sse/translator/request/openai-to-vertex.js +0 -42
- package/open-sse/translator/response/claude-to-openai.js +0 -195
- package/open-sse/translator/response/commandcode-to-openai.js +0 -188
- package/open-sse/translator/response/cursor-to-openai.js +0 -30
- package/open-sse/translator/response/gemini-to-openai.js +0 -147
- package/open-sse/translator/response/kiro-to-claude.js +0 -261
- package/open-sse/translator/response/kiro-to-openai.js +0 -160
- package/open-sse/translator/response/ollama-to-openai.js +0 -134
- package/open-sse/translator/response/openai-responses.js +0 -535
- package/open-sse/translator/response/openai-to-antigravity.js +0 -123
- package/open-sse/translator/response/openai-to-claude.js +0 -265
- package/open-sse/translator/schema/blocks.js +0 -43
- package/open-sse/translator/schema/defaults.js +0 -7
- package/open-sse/translator/schema/finishReasons.js +0 -27
- package/open-sse/translator/schema/index.js +0 -8
- package/open-sse/translator/schema/roles.js +0 -16
- package/open-sse/utils/agentGoalPolicy.js +0 -85
- package/open-sse/utils/aiSdkCompat.js +0 -75
- package/open-sse/utils/bypassHandler.js +0 -298
- package/open-sse/utils/cacheControlPolicy.js +0 -189
- package/open-sse/utils/claudeCloaking.js +0 -155
- package/open-sse/utils/claudeHeaderCache.js +0 -70
- package/open-sse/utils/claudeSignature.js +0 -41
- package/open-sse/utils/clientDetector.js +0 -63
- package/open-sse/utils/codebuddySanitizer.js +0 -96
- package/open-sse/utils/composerToolCalls.js +0 -158
- package/open-sse/utils/cors.js +0 -13
- package/open-sse/utils/cursorChecksum.js +0 -149
- package/open-sse/utils/cursorImages.js +0 -224
- package/open-sse/utils/cursorProtobuf.js +0 -904
- package/open-sse/utils/cursorVersionDetector.js +0 -55
- package/open-sse/utils/debugLog.js +0 -14
- package/open-sse/utils/diagnostics.js +0 -143
- package/open-sse/utils/error.js +0 -164
- package/open-sse/utils/estimateSize.js +0 -33
- package/open-sse/utils/finishReason.js +0 -32
- package/open-sse/utils/flattenToolHistory.js +0 -68
- package/open-sse/utils/headers.js +0 -36
- package/open-sse/utils/heapPressure.js +0 -35
- package/open-sse/utils/jsonToSse.js +0 -125
- package/open-sse/utils/keepaliveThreshold.js +0 -40
- package/open-sse/utils/logger.js +0 -104
- package/open-sse/utils/noThinkingAlias.js +0 -74
- package/open-sse/utils/number.js +0 -7
- package/open-sse/utils/ollamaTransform.js +0 -85
- package/open-sse/utils/opencodeHeaders.js +0 -47
- package/open-sse/utils/progressTracker.js +0 -81
- package/open-sse/utils/providerRequestLogging.js +0 -219
- package/open-sse/utils/proxyFetch.js +0 -369
- package/open-sse/utils/reasoningContentInjector.js +0 -79
- package/open-sse/utils/reasoningFields.js +0 -70
- package/open-sse/utils/requestLogger.js +0 -260
- package/open-sse/utils/responsesInputNormalization.js +0 -92
- package/open-sse/utils/responsesStatePolicy.js +0 -52
- package/open-sse/utils/responsesStreamHelpers.js +0 -49
- package/open-sse/utils/sessionManager.js +0 -240
- package/open-sse/utils/sleep.js +0 -6
- package/open-sse/utils/sse.js +0 -14
- package/open-sse/utils/sseConstants.js +0 -23
- package/open-sse/utils/sseHeartbeat.js +0 -104
- package/open-sse/utils/stream.js +0 -517
- package/open-sse/utils/streamFailureFinalization.js +0 -134
- package/open-sse/utils/streamHandler.js +0 -250
- package/open-sse/utils/streamHelpers.js +0 -137
- package/open-sse/utils/textualToolCall.js +0 -104
- package/open-sse/utils/thinkCloseMarker.js +0 -72
- package/open-sse/utils/thinkTagParser.js +0 -146
- package/open-sse/utils/toolCallArguments.js +0 -12
- package/open-sse/utils/toolDeduper.js +0 -49
- package/open-sse/utils/toolSources.js +0 -31
- package/open-sse/utils/upstreamResponseHeaders.js +0 -25
- package/open-sse/utils/urlSanitize.js +0 -15
- package/open-sse/utils/usageTracking.js +0 -347
|
@@ -1,392 +0,0 @@
|
|
|
1
|
-
import * as crypto from "node:crypto";
|
|
2
|
-
import * as os from "node:os";
|
|
3
|
-
import { BaseExecutor } from "./base.ts";
|
|
4
|
-
import { createProxyDispatcher } from "../utils/proxyDispatcher.ts";
|
|
5
|
-
import { fetch as undiciFetch } from "undici";
|
|
6
|
-
const BOOTSTRAP_PATH = "/api/free-ai/bootstrap";
|
|
7
|
-
const CHAT_PATH = "/api/free-ai/openai/chat";
|
|
8
|
-
const JWT_REFRESH_BUFFER_MS = 5 * 60 * 1e3;
|
|
9
|
-
const BOOTSTRAP_TIMEOUT_MS = 15e3;
|
|
10
|
-
const COOLDOWN_BASE_MS = 5e3;
|
|
11
|
-
const COOLDOWN_MAX_MS = 6e4;
|
|
12
|
-
const MIMO_SOURCE = "mimocode-cli-free";
|
|
13
|
-
const MIMO_SYSTEM_MARKER = "You are MiMoCode, an interactive CLI tool that helps users with software engineering tasks.";
|
|
14
|
-
function injectSystemMarker(body) {
|
|
15
|
-
const messages = body.messages;
|
|
16
|
-
if (!Array.isArray(messages)) return body;
|
|
17
|
-
const hasMarker = messages.some(
|
|
18
|
-
(m) => m != null && typeof m === "object" && m.role === "system" && typeof m.content === "string" && m.content.includes(MIMO_SYSTEM_MARKER)
|
|
19
|
-
);
|
|
20
|
-
if (hasMarker) return body;
|
|
21
|
-
return { ...body, messages: [{ role: "system", content: MIMO_SYSTEM_MARKER }, ...messages] };
|
|
22
|
-
}
|
|
23
|
-
const USER_AGENTS = [
|
|
24
|
-
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36",
|
|
25
|
-
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36",
|
|
26
|
-
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36"
|
|
27
|
-
];
|
|
28
|
-
function parseJwtExp(jwt) {
|
|
29
|
-
try {
|
|
30
|
-
const parts = jwt.split(".");
|
|
31
|
-
if (parts.length < 2) return Date.now() + 50 * 60 * 1e3;
|
|
32
|
-
const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString());
|
|
33
|
-
return (payload.exp ?? Math.floor(Date.now() / 1e3) + 3e3) * 1e3;
|
|
34
|
-
} catch {
|
|
35
|
-
return Date.now() + 50 * 60 * 1e3;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function isAccountReady(account) {
|
|
39
|
-
if (account.cooldownUntil > Date.now()) return false;
|
|
40
|
-
if (account.jwt && account.expiresAt - Date.now() > JWT_REFRESH_BUFFER_MS) return true;
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
function getCpuModel() {
|
|
44
|
-
try {
|
|
45
|
-
const cpus = os.cpus();
|
|
46
|
-
if (cpus.length > 0 && cpus[0].model) return cpus[0].model.trim();
|
|
47
|
-
} catch {
|
|
48
|
-
}
|
|
49
|
-
return "unknown-cpu";
|
|
50
|
-
}
|
|
51
|
-
function generateFingerprint(seed) {
|
|
52
|
-
if (seed) return crypto.createHash("sha256").update(seed).digest("hex");
|
|
53
|
-
const hostname = os.hostname();
|
|
54
|
-
const platform = os.platform();
|
|
55
|
-
const arch = os.arch();
|
|
56
|
-
const cpu = getCpuModel();
|
|
57
|
-
let username = "unknown-user";
|
|
58
|
-
try {
|
|
59
|
-
username = os.userInfo().username;
|
|
60
|
-
} catch {
|
|
61
|
-
}
|
|
62
|
-
return crypto.createHash("sha256").update(`${hostname}|${platform}|${arch}|${cpu}|${username}`).digest("hex");
|
|
63
|
-
}
|
|
64
|
-
const bootstrapInflight = /* @__PURE__ */ new Map();
|
|
65
|
-
async function bootstrapJwt(baseUrl, fingerprint, signal, dispatcher) {
|
|
66
|
-
const existing = bootstrapInflight.get(fingerprint);
|
|
67
|
-
if (existing) return existing;
|
|
68
|
-
const url = `${baseUrl}${BOOTSTRAP_PATH}`;
|
|
69
|
-
const controller = new AbortController();
|
|
70
|
-
const timer = setTimeout(() => controller.abort(), BOOTSTRAP_TIMEOUT_MS);
|
|
71
|
-
const onSignal = signal ? () => controller.abort(signal.reason) : null;
|
|
72
|
-
if (signal && onSignal) signal.addEventListener("abort", onSignal, { once: true });
|
|
73
|
-
const promise = (async () => {
|
|
74
|
-
try {
|
|
75
|
-
const resp = dispatcher ? await undiciFetch(url, {
|
|
76
|
-
method: "POST",
|
|
77
|
-
headers: { "Content-Type": "application/json" },
|
|
78
|
-
body: JSON.stringify({ client: fingerprint }),
|
|
79
|
-
signal: controller.signal,
|
|
80
|
-
dispatcher
|
|
81
|
-
}) : await fetch(url, {
|
|
82
|
-
method: "POST",
|
|
83
|
-
headers: { "Content-Type": "application/json" },
|
|
84
|
-
body: JSON.stringify({ client: fingerprint }),
|
|
85
|
-
signal: controller.signal
|
|
86
|
-
});
|
|
87
|
-
if (!resp.ok) {
|
|
88
|
-
const body = await resp.text().catch(() => "");
|
|
89
|
-
throw new Error(`Bootstrap failed: ${resp.status} ${body.slice(0, 200)}`);
|
|
90
|
-
}
|
|
91
|
-
const data = await resp.json();
|
|
92
|
-
if (!data.jwt) throw new Error("Bootstrap response missing jwt field");
|
|
93
|
-
return { jwt: data.jwt, expiresAt: parseJwtExp(data.jwt) };
|
|
94
|
-
} finally {
|
|
95
|
-
clearTimeout(timer);
|
|
96
|
-
if (signal && onSignal) signal.removeEventListener("abort", onSignal);
|
|
97
|
-
bootstrapInflight.delete(fingerprint);
|
|
98
|
-
}
|
|
99
|
-
})();
|
|
100
|
-
bootstrapInflight.set(fingerprint, promise);
|
|
101
|
-
return promise;
|
|
102
|
-
}
|
|
103
|
-
function rewriteModelName(model) {
|
|
104
|
-
const idx = model.lastIndexOf("/");
|
|
105
|
-
return idx >= 0 ? model.slice(idx + 1) : model;
|
|
106
|
-
}
|
|
107
|
-
class MimocodeExecutor extends BaseExecutor {
|
|
108
|
-
accounts = [];
|
|
109
|
-
nextAccountIdx = 0;
|
|
110
|
-
baseUrl;
|
|
111
|
-
proxyUrlMap = /* @__PURE__ */ new Map();
|
|
112
|
-
static encoder = new TextEncoder();
|
|
113
|
-
constructor() {
|
|
114
|
-
super("mimocode", { format: "openai" });
|
|
115
|
-
this.baseUrl = this.getBaseUrls()[0] || "https://api.xiaomimimo.com";
|
|
116
|
-
this.accounts.push({
|
|
117
|
-
fingerprint: generateFingerprint(),
|
|
118
|
-
jwt: "",
|
|
119
|
-
expiresAt: 0,
|
|
120
|
-
cooldownUntil: 0,
|
|
121
|
-
consecutiveFails: 0,
|
|
122
|
-
// #3837/#5521 backward compat: default the per-account proxy to null (not undefined),
|
|
123
|
-
// mirroring the syncAccountsFromCredentials() account builder, so an executor with no
|
|
124
|
-
// accountProxies config still exposes `acct.proxy === null` on every account.
|
|
125
|
-
proxy: null
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
getProxyDispatcher(fingerprint) {
|
|
129
|
-
const proxyUrl = this.proxyUrlMap.get(fingerprint);
|
|
130
|
-
if (!proxyUrl) return void 0;
|
|
131
|
-
return createProxyDispatcher(proxyUrl);
|
|
132
|
-
}
|
|
133
|
-
fetchWithProxy(url, init, fingerprint) {
|
|
134
|
-
const dispatcher = this.getProxyDispatcher(fingerprint);
|
|
135
|
-
if (dispatcher) {
|
|
136
|
-
const undiciFn = undiciFetch;
|
|
137
|
-
return undiciFn(url, { ...init, dispatcher });
|
|
138
|
-
}
|
|
139
|
-
return fetch(url, init);
|
|
140
|
-
}
|
|
141
|
-
syncAccountsFromCredentials(credentials) {
|
|
142
|
-
const psd = credentials?.providerSpecificData;
|
|
143
|
-
const fingerprints = psd?.fingerprints;
|
|
144
|
-
const accountProxies = psd?.accountProxies;
|
|
145
|
-
if (Array.isArray(accountProxies)) {
|
|
146
|
-
for (const entry of accountProxies) {
|
|
147
|
-
if (entry?.fingerprint && entry?.proxy?.host) {
|
|
148
|
-
const {
|
|
149
|
-
type = "socks5",
|
|
150
|
-
host,
|
|
151
|
-
port,
|
|
152
|
-
username,
|
|
153
|
-
password
|
|
154
|
-
} = entry.proxy;
|
|
155
|
-
const resolvedPort = port ?? (type === "socks5" ? 1080 : 8080);
|
|
156
|
-
const auth = username ? `${encodeURIComponent(username)}:${password ? encodeURIComponent(password) : ""}@` : "";
|
|
157
|
-
this.proxyUrlMap.set(entry.fingerprint, `${type}://${auth}${host}:${resolvedPort}`);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (Array.isArray(fingerprints)) {
|
|
162
|
-
const existing = new Set(this.accounts.map((a) => a.fingerprint));
|
|
163
|
-
for (const fp of fingerprints) {
|
|
164
|
-
if (typeof fp === "string" && !existing.has(fp)) {
|
|
165
|
-
this.accounts.push({
|
|
166
|
-
fingerprint: fp,
|
|
167
|
-
jwt: "",
|
|
168
|
-
expiresAt: 0,
|
|
169
|
-
cooldownUntil: 0,
|
|
170
|
-
consecutiveFails: 0,
|
|
171
|
-
proxy: null
|
|
172
|
-
});
|
|
173
|
-
existing.add(fp);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
const proxyMap = Array.isArray(accountProxies) ? new Map(accountProxies.map((ap) => [ap.fingerprint, ap.proxy])) : null;
|
|
178
|
-
for (const acct of this.accounts) {
|
|
179
|
-
if (proxyMap) {
|
|
180
|
-
const entry = proxyMap.get(acct.fingerprint);
|
|
181
|
-
acct.proxy = entry !== void 0 ? entry ?? null : null;
|
|
182
|
-
} else {
|
|
183
|
-
acct.proxy = null;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
async getJwtForAccount(account, signal) {
|
|
188
|
-
if (isAccountReady(account)) return account.jwt;
|
|
189
|
-
const dispatcher = this.getProxyDispatcher(account.fingerprint);
|
|
190
|
-
const result = await bootstrapJwt(this.baseUrl, account.fingerprint, signal, dispatcher);
|
|
191
|
-
account.jwt = result.jwt;
|
|
192
|
-
account.expiresAt = result.expiresAt;
|
|
193
|
-
return account.jwt;
|
|
194
|
-
}
|
|
195
|
-
pickAccount() {
|
|
196
|
-
for (let i = 0; i < this.accounts.length; i++) {
|
|
197
|
-
const idx = (this.nextAccountIdx + i) % this.accounts.length;
|
|
198
|
-
const acct = this.accounts[idx];
|
|
199
|
-
if (isAccountReady(acct)) {
|
|
200
|
-
this.nextAccountIdx = (idx + 1) % this.accounts.length;
|
|
201
|
-
return acct;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
const fallbackIdx = this.nextAccountIdx % this.accounts.length;
|
|
205
|
-
this.nextAccountIdx = (this.nextAccountIdx + 1) % this.accounts.length;
|
|
206
|
-
return this.accounts[fallbackIdx];
|
|
207
|
-
}
|
|
208
|
-
markCooldown(account) {
|
|
209
|
-
account.consecutiveFails++;
|
|
210
|
-
const backoff = Math.min(
|
|
211
|
-
COOLDOWN_BASE_MS * Math.pow(2, account.consecutiveFails - 1),
|
|
212
|
-
COOLDOWN_MAX_MS
|
|
213
|
-
);
|
|
214
|
-
account.cooldownUntil = Date.now() + backoff + Math.random() * 1e3;
|
|
215
|
-
}
|
|
216
|
-
markSuccess(account) {
|
|
217
|
-
account.consecutiveFails = 0;
|
|
218
|
-
}
|
|
219
|
-
buildUrl(_model, _stream, _urlIndex = 0, _credentials) {
|
|
220
|
-
return `${this.baseUrl.replace(/\/$/, "")}${CHAT_PATH}`;
|
|
221
|
-
}
|
|
222
|
-
buildHeaders(_credentials, stream = true, _clientHeaders, _model) {
|
|
223
|
-
const headers = {
|
|
224
|
-
"Content-Type": "application/json",
|
|
225
|
-
"X-Mimo-Source": MIMO_SOURCE,
|
|
226
|
-
"User-Agent": USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)]
|
|
227
|
-
};
|
|
228
|
-
if (stream) headers["Accept"] = "text/event-stream, application/json";
|
|
229
|
-
return headers;
|
|
230
|
-
}
|
|
231
|
-
transformRequest(model, body, _stream, _credentials) {
|
|
232
|
-
if (typeof body === "object" && body !== null) {
|
|
233
|
-
const withModel = { ...body, model: rewriteModelName(model) };
|
|
234
|
-
return injectSystemMarker(withModel);
|
|
235
|
-
}
|
|
236
|
-
return body;
|
|
237
|
-
}
|
|
238
|
-
async testConnection(_credentials, _signal, log) {
|
|
239
|
-
try {
|
|
240
|
-
this.syncAccountsFromCredentials(_credentials);
|
|
241
|
-
const account = this.accounts[0];
|
|
242
|
-
const jwt = await this.getJwtForAccount(account, _signal);
|
|
243
|
-
const resp = await this.fetchWithProxy(
|
|
244
|
-
this.buildUrl("mimo-auto", false),
|
|
245
|
-
{
|
|
246
|
-
method: "POST",
|
|
247
|
-
headers: {
|
|
248
|
-
"Content-Type": "application/json",
|
|
249
|
-
Authorization: `Bearer ${jwt}`,
|
|
250
|
-
"X-Mimo-Source": MIMO_SOURCE
|
|
251
|
-
},
|
|
252
|
-
body: JSON.stringify(
|
|
253
|
-
injectSystemMarker({
|
|
254
|
-
model: "mimo-auto",
|
|
255
|
-
messages: [{ role: "user", content: "ping" }],
|
|
256
|
-
stream: false
|
|
257
|
-
})
|
|
258
|
-
),
|
|
259
|
-
signal: _signal ?? void 0
|
|
260
|
-
},
|
|
261
|
-
account.fingerprint
|
|
262
|
-
);
|
|
263
|
-
return resp.status === 200;
|
|
264
|
-
} catch {
|
|
265
|
-
log?.warn?.("MIMOCODE", "testConnection network error");
|
|
266
|
-
return false;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
async execute(input) {
|
|
270
|
-
const { model, stream, body, signal, log } = input;
|
|
271
|
-
const encoder = MimocodeExecutor.encoder;
|
|
272
|
-
if (signal?.aborted) {
|
|
273
|
-
return {
|
|
274
|
-
response: new Response(
|
|
275
|
-
encoder.encode(
|
|
276
|
-
JSON.stringify({
|
|
277
|
-
error: { message: "Request aborted", type: "abort", code: "ABORTED" }
|
|
278
|
-
})
|
|
279
|
-
),
|
|
280
|
-
{ status: 499, headers: { "Content-Type": "application/json" } }
|
|
281
|
-
),
|
|
282
|
-
url: this.buildUrl(model, stream),
|
|
283
|
-
headers: this.buildHeaders(input.credentials, stream),
|
|
284
|
-
transformedBody: body
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
const url = this.buildUrl(model, stream);
|
|
288
|
-
const reqBody = this.transformRequest(model, body, stream, input.credentials);
|
|
289
|
-
this.syncAccountsFromCredentials(input.credentials);
|
|
290
|
-
for (let attempt = 0; attempt < this.accounts.length; attempt++) {
|
|
291
|
-
const account = this.pickAccount();
|
|
292
|
-
try {
|
|
293
|
-
const jwt = await this.getJwtForAccount(account, signal);
|
|
294
|
-
const headers = this.buildHeaders(input.credentials, stream);
|
|
295
|
-
headers["Authorization"] = `Bearer ${jwt}`;
|
|
296
|
-
let resp = await this.fetchWithProxy(
|
|
297
|
-
url,
|
|
298
|
-
{
|
|
299
|
-
method: "POST",
|
|
300
|
-
headers,
|
|
301
|
-
body: JSON.stringify(reqBody),
|
|
302
|
-
signal: signal ?? void 0
|
|
303
|
-
},
|
|
304
|
-
account.fingerprint
|
|
305
|
-
);
|
|
306
|
-
if (resp.status === 401 || resp.status === 403) {
|
|
307
|
-
log?.warn?.(
|
|
308
|
-
"MIMOCODE",
|
|
309
|
-
`Auth failed (${resp.status}) on account ${account.fingerprint.slice(0, 8)}\u2026`
|
|
310
|
-
);
|
|
311
|
-
account.jwt = "";
|
|
312
|
-
account.expiresAt = 0;
|
|
313
|
-
account.consecutiveFails = 0;
|
|
314
|
-
const freshJwt = await this.getJwtForAccount(account, signal);
|
|
315
|
-
headers["Authorization"] = `Bearer ${freshJwt}`;
|
|
316
|
-
resp = await this.fetchWithProxy(
|
|
317
|
-
url,
|
|
318
|
-
{
|
|
319
|
-
method: "POST",
|
|
320
|
-
headers,
|
|
321
|
-
body: JSON.stringify(reqBody),
|
|
322
|
-
signal: signal ?? void 0
|
|
323
|
-
},
|
|
324
|
-
account.fingerprint
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
if (resp.status === 429) {
|
|
328
|
-
this.markCooldown(account);
|
|
329
|
-
log?.warn?.(
|
|
330
|
-
"MIMOCODE",
|
|
331
|
-
`Rate limited on account ${account.fingerprint.slice(0, 8)}, trying next\u2026`
|
|
332
|
-
);
|
|
333
|
-
continue;
|
|
334
|
-
}
|
|
335
|
-
this.markSuccess(account);
|
|
336
|
-
const respHeaders = {};
|
|
337
|
-
resp.headers.forEach((v, k) => {
|
|
338
|
-
respHeaders[k] = v;
|
|
339
|
-
});
|
|
340
|
-
return {
|
|
341
|
-
response: resp,
|
|
342
|
-
url,
|
|
343
|
-
headers: respHeaders,
|
|
344
|
-
transformedBody: reqBody
|
|
345
|
-
};
|
|
346
|
-
} catch (err) {
|
|
347
|
-
this.markCooldown(account);
|
|
348
|
-
if (attempt === this.accounts.length - 1) {
|
|
349
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
350
|
-
log?.error?.("MIMOCODE", `Executor error: ${msg}`);
|
|
351
|
-
return {
|
|
352
|
-
response: new Response(
|
|
353
|
-
encoder.encode(
|
|
354
|
-
JSON.stringify({
|
|
355
|
-
error: { message: msg, type: "upstream_error", code: "EXECUTOR_ERROR" }
|
|
356
|
-
})
|
|
357
|
-
),
|
|
358
|
-
{ status: 502, headers: { "Content-Type": "application/json" } }
|
|
359
|
-
),
|
|
360
|
-
url,
|
|
361
|
-
headers: this.buildHeaders(input.credentials, stream),
|
|
362
|
-
transformedBody: body
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
return {
|
|
368
|
-
response: new Response(
|
|
369
|
-
encoder.encode(
|
|
370
|
-
JSON.stringify({
|
|
371
|
-
error: {
|
|
372
|
-
message: "All accounts exhausted",
|
|
373
|
-
type: "upstream_error",
|
|
374
|
-
code: "NO_ACCOUNTS"
|
|
375
|
-
}
|
|
376
|
-
})
|
|
377
|
-
),
|
|
378
|
-
{ status: 502, headers: { "Content-Type": "application/json" } }
|
|
379
|
-
),
|
|
380
|
-
url,
|
|
381
|
-
headers: this.buildHeaders(input.credentials, stream),
|
|
382
|
-
transformedBody: body
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
var mimocode_default = MimocodeExecutor;
|
|
387
|
-
export {
|
|
388
|
-
MIMO_SYSTEM_MARKER,
|
|
389
|
-
MimocodeExecutor,
|
|
390
|
-
mimocode_default as default,
|
|
391
|
-
generateFingerprint
|
|
392
|
-
};
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseExecutor,
|
|
3
|
-
mergeUpstreamExtraHeaders,
|
|
4
|
-
mergeAbortSignals
|
|
5
|
-
} from "./base.ts";
|
|
6
|
-
import { FETCH_TIMEOUT_MS } from "../config/constants.ts";
|
|
7
|
-
import { buildErrorBody } from "../utils/error.js";
|
|
8
|
-
import { getSupervisor } from '../../dist/lib/services/registry.js';
|
|
9
|
-
import { getOrCreateApiKey } from '../../dist/lib/services/apiKey.js';
|
|
10
|
-
const DEFAULT_PORT = 20130;
|
|
11
|
-
const DEFAULT_HOST = "127.0.0.1";
|
|
12
|
-
const HEALTH_CHECK_TIMEOUT_MS = 3e3;
|
|
13
|
-
const NINEROUTER_FALLBACK_HINT = "connection_cooldown";
|
|
14
|
-
const NINEROUTER_FALLBACK_HINT_HEADER = "X-Omni-Fallback-Hint";
|
|
15
|
-
function resolveNineRouterBaseUrl() {
|
|
16
|
-
const host = process.env.NINEROUTER_HOST || DEFAULT_HOST;
|
|
17
|
-
const port = parseInt(process.env.NINEROUTER_PORT || String(DEFAULT_PORT), 10);
|
|
18
|
-
return `http://${host}:${port}`;
|
|
19
|
-
}
|
|
20
|
-
class NineRouterExecutor extends BaseExecutor {
|
|
21
|
-
upstreamBaseUrl;
|
|
22
|
-
constructor(baseUrl) {
|
|
23
|
-
const effectiveBase = baseUrl ?? resolveNineRouterBaseUrl();
|
|
24
|
-
super("9router", {
|
|
25
|
-
id: "9router",
|
|
26
|
-
baseUrl: `${effectiveBase}/v1/chat/completions`,
|
|
27
|
-
headers: { "Content-Type": "application/json" }
|
|
28
|
-
});
|
|
29
|
-
this.upstreamBaseUrl = effectiveBase;
|
|
30
|
-
}
|
|
31
|
-
buildUrl(_model, _stream, _urlIndex = 0, _credentials = null) {
|
|
32
|
-
return `${this.upstreamBaseUrl}/v1/chat/completions`;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Build a 503 service_not_running Response with the fallback hint header.
|
|
36
|
-
* Message goes through buildErrorBody to satisfy hard rule #12 (no raw err.message).
|
|
37
|
-
*/
|
|
38
|
-
buildServiceUnavailableResponse(message) {
|
|
39
|
-
const body = buildErrorBody(503, message);
|
|
40
|
-
body.error.code = "service_not_running";
|
|
41
|
-
return new Response(JSON.stringify(body), {
|
|
42
|
-
status: 503,
|
|
43
|
-
headers: {
|
|
44
|
-
"Content-Type": "application/json",
|
|
45
|
-
[NINEROUTER_FALLBACK_HINT_HEADER]: NINEROUTER_FALLBACK_HINT
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* True when the body matches the Anthropic Messages wire shape.
|
|
51
|
-
* The same heuristic used by CliproxyapiExecutor — see comments there for
|
|
52
|
-
* the reasoning behind each signal.
|
|
53
|
-
*/
|
|
54
|
-
isAnthropicShape(body) {
|
|
55
|
-
if (!body || typeof body !== "object") return false;
|
|
56
|
-
const b = body;
|
|
57
|
-
if (b.system !== void 0) return true;
|
|
58
|
-
if (b.thinking !== void 0) return true;
|
|
59
|
-
if (b.metadata && typeof b.metadata === "object" && b.metadata.user_id !== void 0)
|
|
60
|
-
return true;
|
|
61
|
-
const msgs = b.messages;
|
|
62
|
-
if (Array.isArray(msgs) && msgs.length > 0) {
|
|
63
|
-
const first = msgs[0];
|
|
64
|
-
if (Array.isArray(first?.content)) return true;
|
|
65
|
-
}
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
selectEndpoint(body) {
|
|
69
|
-
return this.isAnthropicShape(body) ? "/v1/messages" : "/v1/chat/completions";
|
|
70
|
-
}
|
|
71
|
-
buildHeaders(credentials, stream = true) {
|
|
72
|
-
const key = credentials?.apiKey ?? credentials?.accessToken;
|
|
73
|
-
const headers = { "Content-Type": "application/json" };
|
|
74
|
-
if (key) headers["Authorization"] = `Bearer ${key}`;
|
|
75
|
-
if (stream) headers["Accept"] = "text/event-stream";
|
|
76
|
-
return headers;
|
|
77
|
-
}
|
|
78
|
-
transformRequest(model, body, _stream, _credentials) {
|
|
79
|
-
if (!body || typeof body !== "object") return body;
|
|
80
|
-
const transformed = { ...body };
|
|
81
|
-
if (transformed.model !== model) transformed.model = model;
|
|
82
|
-
return transformed;
|
|
83
|
-
}
|
|
84
|
-
async execute(input) {
|
|
85
|
-
const supervisor = getSupervisor("9router");
|
|
86
|
-
const status = supervisor?.getStatus();
|
|
87
|
-
if (!supervisor || status?.state !== "running") {
|
|
88
|
-
const stateLabel = status?.state ?? "unknown";
|
|
89
|
-
const msg = `9router is not running (state: ${stateLabel})`;
|
|
90
|
-
input.log?.warn?.("9ROUTER", msg);
|
|
91
|
-
return {
|
|
92
|
-
response: this.buildServiceUnavailableResponse(msg),
|
|
93
|
-
url: "",
|
|
94
|
-
headers: {},
|
|
95
|
-
transformedBody: null
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
const dynamicPort = status.port;
|
|
99
|
-
const dynamicBaseUrl = `http://127.0.0.1:${dynamicPort}`;
|
|
100
|
-
const apiKey = await getOrCreateApiKey("9router");
|
|
101
|
-
const dynamicCredentials = { ...input.credentials, apiKey };
|
|
102
|
-
const innerModel = input.model.replace(/^9router\//, "");
|
|
103
|
-
const endpoint = this.selectEndpoint(input.body);
|
|
104
|
-
const url = `${dynamicBaseUrl}${endpoint}`;
|
|
105
|
-
const shape = endpoint === "/v1/messages" ? "anthropic" : "openai";
|
|
106
|
-
const headers = this.buildHeaders(dynamicCredentials, input.stream);
|
|
107
|
-
const transformedBody = this.transformRequest(
|
|
108
|
-
innerModel,
|
|
109
|
-
input.body,
|
|
110
|
-
input.stream,
|
|
111
|
-
dynamicCredentials
|
|
112
|
-
);
|
|
113
|
-
mergeUpstreamExtraHeaders(headers, input.upstreamExtraHeaders ?? null);
|
|
114
|
-
const timeoutSignal = AbortSignal.timeout(FETCH_TIMEOUT_MS);
|
|
115
|
-
const combinedSignal = input.signal ? mergeAbortSignals(input.signal, timeoutSignal) : timeoutSignal;
|
|
116
|
-
input.log?.info?.(
|
|
117
|
-
"9ROUTER",
|
|
118
|
-
`\u2192 ${url} (model: ${innerModel}, shape: ${shape}, port: ${dynamicPort})`
|
|
119
|
-
);
|
|
120
|
-
const response = await fetch(url, {
|
|
121
|
-
method: "POST",
|
|
122
|
-
headers,
|
|
123
|
-
body: JSON.stringify(transformedBody),
|
|
124
|
-
signal: combinedSignal
|
|
125
|
-
});
|
|
126
|
-
return { response, url, headers, transformedBody };
|
|
127
|
-
}
|
|
128
|
-
async healthCheck() {
|
|
129
|
-
const start = Date.now();
|
|
130
|
-
try {
|
|
131
|
-
const res = await fetch(`${this.upstreamBaseUrl}/api/health`, {
|
|
132
|
-
signal: AbortSignal.timeout(HEALTH_CHECK_TIMEOUT_MS)
|
|
133
|
-
});
|
|
134
|
-
return {
|
|
135
|
-
ok: res.ok,
|
|
136
|
-
latencyMs: Date.now() - start,
|
|
137
|
-
...!res.ok ? { error: `HTTP ${res.status}` } : {}
|
|
138
|
-
};
|
|
139
|
-
} catch (err) {
|
|
140
|
-
return {
|
|
141
|
-
ok: false,
|
|
142
|
-
latencyMs: Date.now() - start,
|
|
143
|
-
error: err instanceof Error ? err.message : String(err)
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
var ninerouter_default = NineRouterExecutor;
|
|
149
|
-
export {
|
|
150
|
-
NINEROUTER_FALLBACK_HINT,
|
|
151
|
-
NINEROUTER_FALLBACK_HINT_HEADER,
|
|
152
|
-
NineRouterExecutor,
|
|
153
|
-
ninerouter_default as default,
|
|
154
|
-
resolveNineRouterBaseUrl
|
|
155
|
-
};
|