@fudrouter/fsrouter 0.6.64 → 0.6.66
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/open-sse/AGENTS.md +39 -0
- package/open-sse/config/anthropicHeaders.js +87 -0
- package/open-sse/config/appConstants.js +238 -0
- package/open-sse/config/audioRegistry.js +506 -0
- package/open-sse/config/cliFingerprints.js +304 -0
- package/open-sse/config/codexInstructions.js +119 -0
- package/open-sse/config/codexQuotaScopes.js +42 -0
- package/open-sse/config/constants.js +4 -0
- package/open-sse/config/contextEditing.js +68 -0
- package/open-sse/config/credentialLoader.js +83 -0
- package/open-sse/config/defaultThinkingSignature.js +12 -0
- package/open-sse/config/embeddingRegistry.js +264 -0
- package/open-sse/config/errorConfig.js +96 -0
- package/open-sse/config/freeModelCatalog.data.js +121 -0
- package/open-sse/config/freeModelCatalog.js +90 -0
- package/open-sse/config/freeTierCatalog.js +81 -0
- package/open-sse/config/googleTtsLanguages.js +62 -0
- package/open-sse/config/imageParamDefs.js +360 -0
- package/open-sse/config/imageRegistry.js +493 -0
- package/open-sse/config/kiroConstants.js +268 -0
- package/open-sse/config/mediaConfig.js +27 -0
- package/open-sse/config/mediaServiceKinds.js +71 -0
- package/open-sse/config/models.js +13 -0
- package/open-sse/config/moderationRegistry.js +71 -0
- package/open-sse/config/musicRegistry.js +99 -0
- package/open-sse/config/ocrRegistry.js +61 -0
- package/open-sse/config/ollamaModels.js +19 -0
- package/open-sse/config/providerErrorRules.js +114 -0
- package/open-sse/config/providerFieldStrips.js +35 -0
- package/open-sse/config/providerHeaderProfiles.js +191 -0
- package/open-sse/config/providerModels.js +106 -0
- package/open-sse/config/providerRegistry.js +16 -0
- package/open-sse/config/providers.js +19 -0
- package/open-sse/config/registryUtils.js +106 -0
- package/open-sse/config/rerankRegistry.js +177 -0
- package/open-sse/config/runtimeConfig.js +96 -0
- package/open-sse/config/runway.js +39 -0
- package/open-sse/config/searchRegistry.js +153 -0
- package/open-sse/config/toolCloaking.js +199 -0
- package/open-sse/config/ttsModels.js +129 -0
- package/open-sse/config/videoRegistry.js +207 -0
- package/open-sse/executors/adapta-web.js +435 -0
- package/open-sse/executors/antigravity.js +534 -0
- package/open-sse/executors/antigravityUpstreamError.js +13 -0
- package/open-sse/executors/auggie.js +437 -0
- package/open-sse/executors/azure-openai.js +32 -0
- package/open-sse/executors/azure.js +57 -0
- package/open-sse/executors/base.js +181 -0
- package/open-sse/executors/bedrock.js +633 -0
- package/open-sse/executors/blackbox-web.js +578 -0
- package/open-sse/executors/chatgpt-web.js +2042 -0
- package/open-sse/executors/chipotle.js +357 -0
- package/open-sse/executors/claude-web-with-auto-refresh.js +73 -0
- package/open-sse/executors/claude-web.js +586 -0
- package/open-sse/executors/cliproxyapi.js +296 -0
- package/open-sse/executors/cloudflare-ai.js +46 -0
- package/open-sse/executors/codebuddy-cn.js +40 -0
- package/open-sse/executors/codex.js +1324 -0
- package/open-sse/executors/commandCode.js +558 -0
- package/open-sse/executors/commandcode.js +88 -0
- package/open-sse/executors/copilot-m365-connection.js +176 -0
- package/open-sse/executors/copilot-m365-frames.js +192 -0
- package/open-sse/executors/copilot-m365-web.js +299 -0
- package/open-sse/executors/copilot-web.js +580 -0
- package/open-sse/executors/cursor.js +795 -0
- package/open-sse/executors/deepseek-web-with-auto-refresh.js +150 -0
- package/open-sse/executors/deepseek-web.js +875 -0
- package/open-sse/executors/default.js +430 -0
- package/open-sse/executors/devin-cli.js +351 -0
- package/open-sse/executors/doubao-web.js +550 -0
- package/open-sse/executors/duckduckgo-web.js +629 -0
- package/open-sse/executors/forceResponsesUpstream.js +33 -0
- package/open-sse/executors/gemini-business.js +320 -0
- package/open-sse/executors/gemini-cli.js +89 -0
- package/open-sse/executors/gemini-web.js +297 -0
- package/open-sse/executors/github.js +379 -0
- package/open-sse/executors/gitlab.js +569 -0
- package/open-sse/executors/glm.js +361 -0
- package/open-sse/executors/grok-cli.js +119 -0
- package/open-sse/executors/grok-web.js +345 -0
- package/open-sse/executors/huggingchat.js +467 -0
- package/open-sse/executors/iflow.js +108 -0
- package/open-sse/executors/index.js +78 -0
- package/open-sse/executors/inner-ai.js +527 -0
- package/open-sse/executors/kimchi.js +123 -0
- package/open-sse/executors/kimi-web.js +325 -0
- package/open-sse/executors/kimi.js +97 -0
- package/open-sse/executors/kiro.js +503 -0
- package/open-sse/executors/kiroThinking.js +44 -0
- package/open-sse/executors/lmarena.js +395 -0
- package/open-sse/executors/mimo-free.js +167 -0
- package/open-sse/executors/mimocode.js +392 -0
- package/open-sse/executors/ninerouter.js +155 -0
- package/open-sse/executors/nlpcloud.js +438 -0
- package/open-sse/executors/ollama-local.js +14 -0
- package/open-sse/executors/opencode-go.js +41 -0
- package/open-sse/executors/opencode.js +32 -0
- package/open-sse/executors/perplexity-web.js +581 -0
- package/open-sse/executors/poe-web.js +133 -0
- package/open-sse/executors/pollinations.js +95 -0
- package/open-sse/executors/puter.js +31 -0
- package/open-sse/executors/qoder.js +448 -0
- package/open-sse/executors/qwen-web.js +372 -0
- package/open-sse/executors/qwen.js +129 -0
- package/open-sse/executors/t3-chat-web.js +417 -0
- package/open-sse/executors/theoldllm.js +290 -0
- package/open-sse/executors/trae.js +418 -0
- package/open-sse/executors/v0-vercel-web.js +141 -0
- package/open-sse/executors/venice-web.js +142 -0
- package/open-sse/executors/vertex.js +131 -0
- package/open-sse/executors/vertexMedia.js +236 -0
- package/open-sse/executors/windsurf.js +560 -0
- package/open-sse/executors/xai.js +46 -0
- package/open-sse/executors/xiaomi-tokenplan.js +19 -0
- package/open-sse/executors/yuanbao-web.js +385 -0
- package/open-sse/executors/zed-hosted.js +281 -0
- package/open-sse/executors/zenmux-free.js +247 -0
- package/open-sse/handlers/audioSpeech.js +759 -0
- package/open-sse/handlers/audioTranscription.js +395 -0
- package/open-sse/handlers/audioTranslation.js +181 -0
- package/open-sse/handlers/chatCore/nonStreamingHandler.js +300 -0
- package/open-sse/handlers/chatCore/requestDetail.js +102 -0
- package/open-sse/handlers/chatCore/sseToJsonHandler.js +231 -0
- package/open-sse/handlers/chatCore/streamingHandler.js +95 -0
- package/open-sse/handlers/chatCore.js +404 -0
- package/open-sse/handlers/embeddingProviders/_base.js +4 -0
- package/open-sse/handlers/embeddingProviders/gemini.js +54 -0
- package/open-sse/handlers/embeddingProviders/index.js +23 -0
- package/open-sse/handlers/embeddingProviders/openai.js +39 -0
- package/open-sse/handlers/embeddingProviders/openaiCompatNode.js +13 -0
- package/open-sse/handlers/embeddingsCore.js +126 -0
- package/open-sse/handlers/fetch/index.js +237 -0
- package/open-sse/handlers/imageGenerationCore.js +230 -0
- package/open-sse/handlers/imageProviders/_base.js +31 -0
- package/open-sse/handlers/imageProviders/antigravity.js +73 -0
- package/open-sse/handlers/imageProviders/blackForestLabs.js +63 -0
- package/open-sse/handlers/imageProviders/cloudflareAi.js +207 -0
- package/open-sse/handlers/imageProviders/codex.js +217 -0
- package/open-sse/handlers/imageProviders/comfyui.js +25 -0
- package/open-sse/handlers/imageProviders/falAi.js +62 -0
- package/open-sse/handlers/imageProviders/gemini.js +40 -0
- package/open-sse/handlers/imageProviders/huggingface.js +38 -0
- package/open-sse/handlers/imageProviders/index.js +44 -0
- package/open-sse/handlers/imageProviders/leonardo.js +435 -0
- package/open-sse/handlers/imageProviders/nanobanana.js +79 -0
- package/open-sse/handlers/imageProviders/openai.js +61 -0
- package/open-sse/handlers/imageProviders/runwayml.js +72 -0
- package/open-sse/handlers/imageProviders/sdwebui.js +36 -0
- package/open-sse/handlers/imageProviders/stabilityAi.js +59 -0
- package/open-sse/handlers/imageProviders/weavy.js +222 -0
- package/open-sse/handlers/moderations.js +92 -0
- package/open-sse/handlers/ocr.js +89 -0
- package/open-sse/handlers/rerank.js +223 -0
- package/open-sse/handlers/responseSanitizer/reasoning.js +144 -0
- package/open-sse/handlers/responsesHandler.js +99 -0
- package/open-sse/handlers/search/callers.js +371 -0
- package/open-sse/handlers/search/chatSearch.js +409 -0
- package/open-sse/handlers/search/index.js +201 -0
- package/open-sse/handlers/search/normalizers.js +223 -0
- package/open-sse/handlers/search.js +1056 -0
- package/open-sse/handlers/sseParser.js +469 -0
- package/open-sse/handlers/sttCore.js +193 -0
- package/open-sse/handlers/ttsCore.js +74 -0
- package/open-sse/handlers/ttsProviders/_base.js +39 -0
- package/open-sse/handlers/ttsProviders/edgeTts.js +89 -0
- package/open-sse/handlers/ttsProviders/elevenlabs.js +48 -0
- package/open-sse/handlers/ttsProviders/gemini.js +117 -0
- package/open-sse/handlers/ttsProviders/genericFormats.js +169 -0
- package/open-sse/handlers/ttsProviders/googleTts.js +54 -0
- package/open-sse/handlers/ttsProviders/index.js +50 -0
- package/open-sse/handlers/ttsProviders/localDevice.js +87 -0
- package/open-sse/handlers/ttsProviders/minimax.js +59 -0
- package/open-sse/handlers/ttsProviders/openai.js +30 -0
- package/open-sse/handlers/ttsProviders/openrouter.js +70 -0
- package/open-sse/handlers/usageExtractor.js +93 -0
- package/open-sse/handlers/videoGenerationCore.js +119 -0
- package/open-sse/handlers/videoProviders/index.js +22 -0
- package/open-sse/handlers/videoProviders/leonardo.js +511 -0
- package/open-sse/handlers/videoProviders/weavy.js +198 -0
- package/open-sse/handlers/webFetch.js +200 -0
- package/open-sse/index.js +79 -0
- package/open-sse/mcp-server/audit.js +283 -0
- package/open-sse/mcp-server/catalog.js +184 -0
- package/open-sse/mcp-server/descriptionCompressor.js +175 -0
- package/open-sse/mcp-server/httpAuthContext.js +32 -0
- package/open-sse/mcp-server/httpTransport.js +229 -0
- package/open-sse/mcp-server/index.js +33 -0
- package/open-sse/mcp-server/mcpCallerIdentity.js +21 -0
- package/open-sse/mcp-server/runtimeHeartbeat.js +110 -0
- package/open-sse/mcp-server/schemas/a2a.js +153 -0
- package/open-sse/mcp-server/schemas/audit.js +17 -0
- package/open-sse/mcp-server/schemas/index.js +166 -0
- package/open-sse/mcp-server/schemas/pickFastestModel.js +90 -0
- package/open-sse/mcp-server/schemas/toolDefinition.js +0 -0
- package/open-sse/mcp-server/schemas/toolSearch.js +32 -0
- package/open-sse/mcp-server/schemas/tools.js +1219 -0
- package/open-sse/mcp-server/scopeEnforcement.js +80 -0
- package/open-sse/mcp-server/server.js +1168 -0
- package/open-sse/mcp-server/toolCardinality.js +78 -0
- package/open-sse/mcp-server/toolSearch/catalog.js +66 -0
- package/open-sse/mcp-server/toolSearch/handler.js +20 -0
- package/open-sse/mcp-server/toolSearch/index.js +10 -0
- package/open-sse/mcp-server/toolSearch/register.js +21 -0
- package/open-sse/mcp-server/toolSearch/search.js +55 -0
- package/open-sse/mcp-server/toolSearch/signature.js +67 -0
- package/open-sse/mcp-server/tools/advancedTools.js +893 -0
- package/open-sse/mcp-server/tools/agentSkillTools.js +69 -0
- package/open-sse/mcp-server/tools/compressionTools.js +309 -0
- package/open-sse/mcp-server/tools/gamificationTools.js +134 -0
- package/open-sse/mcp-server/tools/githubSkillTools.js +102 -0
- package/open-sse/mcp-server/tools/memoryTools.js +118 -0
- package/open-sse/mcp-server/tools/notionTools.js +101 -0
- package/open-sse/mcp-server/tools/obsidianTools.js +307 -0
- package/open-sse/mcp-server/tools/pickFastestModel.js +223 -0
- package/open-sse/mcp-server/tools/pluginTools.js +181 -0
- package/open-sse/mcp-server/tools/poolTools.js +139 -0
- package/open-sse/mcp-server/tools/skillTools.js +113 -0
- package/open-sse/package.json +10 -0
- package/open-sse/providers/REGISTRY_TEMPLATE.js +98 -0
- package/open-sse/providers/capabilities.js +293 -0
- package/open-sse/providers/index.js +51 -0
- package/open-sse/providers/models/helpers.js +20 -0
- package/open-sse/providers/models/namePatterns.js +33 -0
- package/open-sse/providers/models/schema.js +40 -0
- package/open-sse/providers/pricing.js +308 -0
- package/open-sse/providers/registry/alicode-intl.js +30 -0
- package/open-sse/providers/registry/alicode.js +31 -0
- package/open-sse/providers/registry/anthropic.js +37 -0
- package/open-sse/providers/registry/antigravity.js +81 -0
- package/open-sse/providers/registry/assemblyai.js +38 -0
- package/open-sse/providers/registry/aws-polly.js +45 -0
- package/open-sse/providers/registry/azure.js +21 -0
- package/open-sse/providers/registry/black-forest-labs.js +32 -0
- package/open-sse/providers/registry/blackbox.js +41 -0
- package/open-sse/providers/registry/brave-search.js +35 -0
- package/open-sse/providers/registry/byteplus.js +35 -0
- package/open-sse/providers/registry/cartesia.js +36 -0
- package/open-sse/providers/registry/cerebras.js +31 -0
- package/open-sse/providers/registry/chutes.js +24 -0
- package/open-sse/providers/registry/claude.js +87 -0
- package/open-sse/providers/registry/cline.js +51 -0
- package/open-sse/providers/registry/clinepass.js +57 -0
- package/open-sse/providers/registry/cloudflare-ai.js +55 -0
- package/open-sse/providers/registry/codebuddy-cn.js +77 -0
- package/open-sse/providers/registry/codex.js +100 -0
- package/open-sse/providers/registry/cohere.js +27 -0
- package/open-sse/providers/registry/comfyui.js +20 -0
- package/open-sse/providers/registry/commandcode.js +43 -0
- package/open-sse/providers/registry/coqui.js +30 -0
- package/open-sse/providers/registry/cursor.js +58 -0
- package/open-sse/providers/registry/deepgram.js +33 -0
- package/open-sse/providers/registry/deepseek.js +51 -0
- package/open-sse/providers/registry/digitalocean.js +92 -0
- package/open-sse/providers/registry/edge-tts.js +24 -0
- package/open-sse/providers/registry/elevenlabs.js +35 -0
- package/open-sse/providers/registry/exa.js +50 -0
- package/open-sse/providers/registry/fal-ai.js +34 -0
- package/open-sse/providers/registry/featherless.js +34 -0
- package/open-sse/providers/registry/firecrawl.js +34 -0
- package/open-sse/providers/registry/fireworks.js +29 -0
- package/open-sse/providers/registry/gemini-cli.js +58 -0
- package/open-sse/providers/registry/gemini.js +83 -0
- package/open-sse/providers/registry/github.js +88 -0
- package/open-sse/providers/registry/gitlab.js +32 -0
- package/open-sse/providers/registry/glm-cn.js +35 -0
- package/open-sse/providers/registry/glm.js +58 -0
- package/open-sse/providers/registry/google-pse.js +35 -0
- package/open-sse/providers/registry/google-tts.js +24 -0
- package/open-sse/providers/registry/grok-cli.js +86 -0
- package/open-sse/providers/registry/grok-web.js +39 -0
- package/open-sse/providers/registry/groq.js +37 -0
- package/open-sse/providers/registry/huggingface.js +34 -0
- package/open-sse/providers/registry/hyperbolic.js +35 -0
- package/open-sse/providers/registry/ibm-bob.js +27 -0
- package/open-sse/providers/registry/iflow.js +52 -0
- package/open-sse/providers/registry/index.js +210 -0
- package/open-sse/providers/registry/inworld.js +36 -0
- package/open-sse/providers/registry/jina-ai.js +42 -0
- package/open-sse/providers/registry/jina-reader.js +34 -0
- package/open-sse/providers/registry/kilocode.js +51 -0
- package/open-sse/providers/registry/kimchi.js +49 -0
- package/open-sse/providers/registry/kimi-coding.js +65 -0
- package/open-sse/providers/registry/kimi.js +56 -0
- package/open-sse/providers/registry/kiro.js +115 -0
- package/open-sse/providers/registry/linkup.js +34 -0
- package/open-sse/providers/registry/local-device.js +24 -0
- package/open-sse/providers/registry/mimo-free.js +24 -0
- package/open-sse/providers/registry/minimax-cn.js +76 -0
- package/open-sse/providers/registry/minimax.js +83 -0
- package/open-sse/providers/registry/mistral.js +34 -0
- package/open-sse/providers/registry/mmf.js +19 -0
- package/open-sse/providers/registry/nanobanana.js +35 -0
- package/open-sse/providers/registry/nebius.js +27 -0
- package/open-sse/providers/registry/nvidia.js +43 -0
- package/open-sse/providers/registry/ollama-local.js +19 -0
- package/open-sse/providers/registry/ollama.js +36 -0
- package/open-sse/providers/registry/openai.js +84 -0
- package/open-sse/providers/registry/opencode-go.js +41 -0
- package/open-sse/providers/registry/opencode.js +25 -0
- package/open-sse/providers/registry/openrouter.js +60 -0
- package/open-sse/providers/registry/perplexity-agent.js +49 -0
- package/open-sse/providers/registry/perplexity-web.js +33 -0
- package/open-sse/providers/registry/perplexity.js +37 -0
- package/open-sse/providers/registry/playht.js +36 -0
- package/open-sse/providers/registry/qoder.js +54 -0
- package/open-sse/providers/registry/qwen.js +33 -0
- package/open-sse/providers/registry/recraft.js +24 -0
- package/open-sse/providers/registry/runwayml.js +30 -0
- package/open-sse/providers/registry/sdwebui.js +20 -0
- package/open-sse/providers/registry/searchapi.js +35 -0
- package/open-sse/providers/registry/searxng.js +35 -0
- package/open-sse/providers/registry/serper.js +35 -0
- package/open-sse/providers/registry/siliconflow.js +39 -0
- package/open-sse/providers/registry/stability-ai.js +31 -0
- package/open-sse/providers/registry/tavily.js +50 -0
- package/open-sse/providers/registry/together.js +31 -0
- package/open-sse/providers/registry/topaz.js +19 -0
- package/open-sse/providers/registry/tortoise.js +30 -0
- package/open-sse/providers/registry/venice.js +56 -0
- package/open-sse/providers/registry/vercel-ai-gateway.js +41 -0
- package/open-sse/providers/registry/vertex-partner.js +29 -0
- package/open-sse/providers/registry/vertex.js +32 -0
- package/open-sse/providers/registry/volcengine-ark.js +35 -0
- package/open-sse/providers/registry/voyage-ai.js +30 -0
- package/open-sse/providers/registry/xai.js +45 -0
- package/open-sse/providers/registry/xiaomi-mimo.js +46 -0
- package/open-sse/providers/registry/xiaomi-tokenplan.js +63 -0
- package/open-sse/providers/registry/youcom.js +35 -0
- package/open-sse/providers/schema.js +76 -0
- package/open-sse/providers/shared.js +74 -0
- package/open-sse/providers/thinkingLevels.js +48 -0
- package/open-sse/rtk/applyFilter.js +15 -0
- package/open-sse/rtk/autodetect.js +111 -0
- package/open-sse/rtk/caveman.js +100 -0
- package/open-sse/rtk/cavemanPrompts.js +78 -0
- package/open-sse/rtk/constants.js +55 -0
- package/open-sse/rtk/filters/buildOutput.js +127 -0
- package/open-sse/rtk/filters/dedupLog.js +44 -0
- package/open-sse/rtk/filters/find.js +50 -0
- package/open-sse/rtk/filters/gitDiff.js +92 -0
- package/open-sse/rtk/filters/gitLog.js +99 -0
- package/open-sse/rtk/filters/gitStatus.js +117 -0
- package/open-sse/rtk/filters/grep.js +48 -0
- package/open-sse/rtk/filters/ls.js +79 -0
- package/open-sse/rtk/filters/readNumbered.js +27 -0
- package/open-sse/rtk/filters/searchList.js +52 -0
- package/open-sse/rtk/filters/smartTruncate.js +15 -0
- package/open-sse/rtk/filters/tree.js +32 -0
- package/open-sse/rtk/headroom.js +215 -0
- package/open-sse/rtk/index.js +155 -0
- package/open-sse/rtk/paleo.js +47 -0
- package/open-sse/rtk/ponytail.js +9 -0
- package/open-sse/rtk/ponytailPrompt.js +52 -0
- package/open-sse/rtk/ponytailPrompts.js +76 -0
- package/open-sse/rtk/pxpipe.js +104 -0
- package/open-sse/rtk/registry.js +38 -0
- package/open-sse/rtk/systemInject.js +98 -0
- package/open-sse/services/accountFallback.js +323 -0
- package/open-sse/services/antigravityHeaders.js +91 -0
- package/open-sse/services/antigravityVersion.js +154 -0
- package/open-sse/services/clinepassModels.js +63 -0
- package/open-sse/services/codexQuotaFetcher.js +312 -0
- package/open-sse/services/codexVerbosity.js +30 -0
- package/open-sse/services/combo/context.js +12 -0
- package/open-sse/services/combo/fingerprintExpansion.js +51 -0
- package/open-sse/services/combo/headroomRanking.js +28 -0
- package/open-sse/services/combo/quotaExhaustionCutoff.js +87 -0
- package/open-sse/services/combo/quotaScoring.js +226 -0
- package/open-sse/services/combo/quotaShareConcurrency.js +25 -0
- package/open-sse/services/combo/quotaShareInflight.js +50 -0
- package/open-sse/services/combo/quotaShareStrategy.js +130 -0
- package/open-sse/services/combo/resolveAutoStrategy.js +231 -0
- package/open-sse/services/combo/responseValidation.js +140 -0
- package/open-sse/services/combo/runtimeUnits.js +195 -0
- package/open-sse/services/combo/sessionStickiness.js +128 -0
- package/open-sse/services/combo/shadowRouting.js +131 -0
- package/open-sse/services/combo/targetExhaustion.js +75 -0
- package/open-sse/services/combo/targetSorters.js +126 -0
- package/open-sse/services/combo/targetTimeoutRunner.js +65 -0
- package/open-sse/services/combo/validateQuality.js +271 -0
- package/open-sse/services/combo.js +571 -0
- package/open-sse/services/comboAgentMiddleware.js +91 -0
- package/open-sse/services/comboConfig.js +153 -0
- package/open-sse/services/comboManifestMetrics.js +10 -0
- package/open-sse/services/comboMetrics.js +278 -0
- package/open-sse/services/compact.js +71 -0
- package/open-sse/services/copilotModels.js +155 -0
- package/open-sse/services/emergencyFallback.js +109 -0
- package/open-sse/services/errorClassifier.js +190 -0
- package/open-sse/services/evalRouting.js +201 -0
- package/open-sse/services/freeWebSearch.js +4 -0
- package/open-sse/services/fusion.js +223 -0
- package/open-sse/services/intentClassifier.js +631 -0
- package/open-sse/services/kimchiModels.js +176 -0
- package/open-sse/services/kiroModels.js +332 -0
- package/open-sse/services/model.js +136 -0
- package/open-sse/services/modelCapabilities.js +5 -0
- package/open-sse/services/modelDeprecation.js +101 -0
- package/open-sse/services/modelFamilyFallback.js +166 -0
- package/open-sse/services/oauthCredentialManager.js +156 -0
- package/open-sse/services/pipeline.js +107 -0
- package/open-sse/services/projectId.js +306 -0
- package/open-sse/services/provider.js +169 -0
- package/open-sse/services/providerCooldownTracker.js +94 -0
- package/open-sse/services/providerDefaultRateLimit.js +11 -0
- package/open-sse/services/proxyAutoSelector.js +24 -0
- package/open-sse/services/qoderModels.js +214 -0
- package/open-sse/services/quotaFetchThrottle.js +103 -0
- package/open-sse/services/quotaMonitor.js +310 -0
- package/open-sse/services/quotaPreflight.js +266 -0
- package/open-sse/services/rateLimitManager/headers.js +56 -0
- package/open-sse/services/rateLimitManager.js +616 -0
- package/open-sse/services/rateLimitSemaphore.js +112 -0
- package/open-sse/services/responsesInputSanitizer.js +99 -0
- package/open-sse/services/slidingWindowLimiter.js +44 -0
- package/open-sse/services/streamRecovery.js +355 -0
- package/open-sse/services/taskAwareRouter.js +227 -0
- package/open-sse/services/taskAwareRouting.js +332 -0
- package/open-sse/services/thinkingBudget.js +247 -0
- package/open-sse/services/tokenRefresh/dedup.js +31 -0
- package/open-sse/services/tokenRefresh/providers.js +624 -0
- package/open-sse/services/tokenRefresh.js +254 -0
- package/open-sse/services/usage/claude.js +147 -0
- package/open-sse/services/usage/codebuddy-cn.js +138 -0
- package/open-sse/services/usage/codex.js +267 -0
- package/open-sse/services/usage/github.js +100 -0
- package/open-sse/services/usage/google.js +241 -0
- package/open-sse/services/usage/grok-cli.js +274 -0
- package/open-sse/services/usage/kiro.js +188 -0
- package/open-sse/services/usage/minimax.js +234 -0
- package/open-sse/services/usage/misc.js +288 -0
- package/open-sse/services/usage/shared.js +70 -0
- package/open-sse/services/usage.js +62 -0
- package/open-sse/services/usageDb.js +2 -0
- package/open-sse/services/webSearchRouting.js +25 -0
- package/open-sse/services/wildcardRouter.js +59 -0
- package/open-sse/shared/clineAuth.js +37 -0
- package/open-sse/shared/machineId.js +19 -0
- package/open-sse/shared/qoder/constants.js +64 -0
- package/open-sse/shared/qoder/cosy.js +175 -0
- package/open-sse/shared/qoder/encoding.js +55 -0
- package/open-sse/transformer/responsesTransformer.js +439 -0
- package/open-sse/transformer/streamToJsonConverter.js +103 -0
- package/open-sse/translator/concerns/chunk.js +11 -0
- package/open-sse/translator/concerns/finishReason.js +63 -0
- package/open-sse/translator/concerns/image.js +124 -0
- package/open-sse/translator/concerns/json.js +5 -0
- package/open-sse/translator/concerns/message.js +7 -0
- package/open-sse/translator/concerns/modality.js +155 -0
- package/open-sse/translator/concerns/paramSupport.js +75 -0
- package/open-sse/translator/concerns/prefetch.js +96 -0
- package/open-sse/translator/concerns/reasoning.js +24 -0
- package/open-sse/translator/concerns/thinking.js +53 -0
- package/open-sse/translator/concerns/thinkingUnified.js +329 -0
- package/open-sse/translator/concerns/toolCall.js +153 -0
- package/open-sse/translator/concerns/usage.js +69 -0
- package/open-sse/translator/formats/claude.js +368 -0
- package/open-sse/translator/formats/gemini.js +380 -0
- package/open-sse/translator/formats/maxTokens.js +34 -0
- package/open-sse/translator/formats/openai.js +134 -0
- package/open-sse/translator/formats/responsesApi.js +141 -0
- package/open-sse/translator/formats.js +36 -0
- package/open-sse/translator/helpers/claudeHelper.js +216 -0
- package/open-sse/translator/helpers/geminiHelper.js +372 -0
- package/open-sse/translator/helpers/imageHelper.js +34 -0
- package/open-sse/translator/helpers/maxTokensHelper.js +27 -0
- package/open-sse/translator/helpers/openaiHelper.js +130 -0
- package/open-sse/translator/helpers/responsesApiHelper.js +139 -0
- package/open-sse/translator/helpers/toolCallHelper.js +148 -0
- package/open-sse/translator/index.js +252 -0
- package/open-sse/translator/request/antigravity-to-openai.js +242 -0
- package/open-sse/translator/request/claude-to-kiro.js +478 -0
- package/open-sse/translator/request/claude-to-openai.js +263 -0
- package/open-sse/translator/request/gemini-to-openai.js +152 -0
- package/open-sse/translator/request/openai-responses.js +385 -0
- package/open-sse/translator/request/openai-to-claude.js +383 -0
- package/open-sse/translator/request/openai-to-commandcode.js +176 -0
- package/open-sse/translator/request/openai-to-cursor.js +185 -0
- package/open-sse/translator/request/openai-to-gemini.js +442 -0
- package/open-sse/translator/request/openai-to-kiro.js +607 -0
- package/open-sse/translator/request/openai-to-kiro.old.js +278 -0
- package/open-sse/translator/request/openai-to-ollama.js +195 -0
- package/open-sse/translator/request/openai-to-vertex.js +42 -0
- package/open-sse/translator/response/claude-to-openai.js +195 -0
- package/open-sse/translator/response/commandcode-to-openai.js +188 -0
- package/open-sse/translator/response/cursor-to-openai.js +30 -0
- package/open-sse/translator/response/gemini-to-openai.js +147 -0
- package/open-sse/translator/response/kiro-to-claude.js +261 -0
- package/open-sse/translator/response/kiro-to-openai.js +160 -0
- package/open-sse/translator/response/ollama-to-openai.js +134 -0
- package/open-sse/translator/response/openai-responses.js +535 -0
- package/open-sse/translator/response/openai-to-antigravity.js +123 -0
- package/open-sse/translator/response/openai-to-claude.js +265 -0
- package/open-sse/translator/schema/blocks.js +43 -0
- package/open-sse/translator/schema/defaults.js +7 -0
- package/open-sse/translator/schema/finishReasons.js +27 -0
- package/open-sse/translator/schema/index.js +8 -0
- package/open-sse/translator/schema/roles.js +16 -0
- package/open-sse/utils/agentGoalPolicy.js +85 -0
- package/open-sse/utils/aiSdkCompat.js +75 -0
- package/open-sse/utils/bypassHandler.js +298 -0
- package/open-sse/utils/cacheControlPolicy.js +189 -0
- package/open-sse/utils/claudeCloaking.js +155 -0
- package/open-sse/utils/claudeHeaderCache.js +70 -0
- package/open-sse/utils/claudeSignature.js +41 -0
- package/open-sse/utils/clientDetector.js +63 -0
- package/open-sse/utils/codebuddySanitizer.js +96 -0
- package/open-sse/utils/composerToolCalls.js +158 -0
- package/open-sse/utils/cors.js +13 -0
- package/open-sse/utils/cursorChecksum.js +149 -0
- package/open-sse/utils/cursorImages.js +224 -0
- package/open-sse/utils/cursorProtobuf.js +904 -0
- package/open-sse/utils/cursorVersionDetector.js +55 -0
- package/open-sse/utils/debugLog.js +14 -0
- package/open-sse/utils/diagnostics.js +143 -0
- package/open-sse/utils/error.js +164 -0
- package/open-sse/utils/estimateSize.js +33 -0
- package/open-sse/utils/finishReason.js +32 -0
- package/open-sse/utils/flattenToolHistory.js +68 -0
- package/open-sse/utils/headers.js +36 -0
- package/open-sse/utils/heapPressure.js +35 -0
- package/open-sse/utils/jsonToSse.js +125 -0
- package/open-sse/utils/keepaliveThreshold.js +40 -0
- package/open-sse/utils/logger.js +104 -0
- package/open-sse/utils/noThinkingAlias.js +74 -0
- package/open-sse/utils/number.js +7 -0
- package/open-sse/utils/ollamaTransform.js +85 -0
- package/open-sse/utils/opencodeHeaders.js +47 -0
- package/open-sse/utils/progressTracker.js +81 -0
- package/open-sse/utils/providerRequestLogging.js +219 -0
- package/open-sse/utils/proxyFetch.js +369 -0
- package/open-sse/utils/reasoningContentInjector.js +79 -0
- package/open-sse/utils/reasoningFields.js +70 -0
- package/open-sse/utils/requestLogger.js +260 -0
- package/open-sse/utils/responsesInputNormalization.js +92 -0
- package/open-sse/utils/responsesStatePolicy.js +52 -0
- package/open-sse/utils/responsesStreamHelpers.js +49 -0
- package/open-sse/utils/sessionManager.js +240 -0
- package/open-sse/utils/sleep.js +6 -0
- package/open-sse/utils/sse.js +14 -0
- package/open-sse/utils/sseConstants.js +23 -0
- package/open-sse/utils/sseHeartbeat.js +104 -0
- package/open-sse/utils/stream.js +517 -0
- package/open-sse/utils/streamFailureFinalization.js +134 -0
- package/open-sse/utils/streamHandler.js +250 -0
- package/open-sse/utils/streamHelpers.js +137 -0
- package/open-sse/utils/textualToolCall.js +104 -0
- package/open-sse/utils/thinkCloseMarker.js +72 -0
- package/open-sse/utils/thinkTagParser.js +146 -0
- package/open-sse/utils/toolCallArguments.js +12 -0
- package/open-sse/utils/toolDeduper.js +49 -0
- package/open-sse/utils/toolSources.js +31 -0
- package/open-sse/utils/upstreamResponseHeaders.js +25 -0
- package/open-sse/utils/urlSanitize.js +15 -0
- package/open-sse/utils/usageTracking.js +347 -0
- package/package.json +1 -1
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kiro-specific constants and helpers.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the behaviour of `internal/translator/kiro/common/constants.go` and
|
|
5
|
+
* `internal/translator/kiro/claude/kiro_claude_request.go` from the
|
|
6
|
+
* CLIProxyAPIPlus reference implementation, scoped down to what 9router needs:
|
|
7
|
+
*
|
|
8
|
+
* - `-agentic` model suffix detection + chunked-write system prompt
|
|
9
|
+
* - reasoning / thinking trigger detection (Anthropic-Beta header,
|
|
10
|
+
* Claude `thinking`, OpenAI `reasoning_effort`, AMP/Cursor magic tag)
|
|
11
|
+
* - the `<thinking_mode>enabled</thinking_mode>` system-prompt injection
|
|
12
|
+
* that turns Kiro reasoning on
|
|
13
|
+
*
|
|
14
|
+
* Kiro upstream does not advertise `-agentic` model IDs; they are a 9router
|
|
15
|
+
* fiction. The suffix is stripped before the request leaves this process.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export const KIRO_AGENTIC_SUFFIX = "-agentic";
|
|
19
|
+
export const KIRO_THINKING_SUFFIX = "-thinking";
|
|
20
|
+
|
|
21
|
+
export const KIRO_THINKING_BUDGET_DEFAULT = 16000;
|
|
22
|
+
|
|
23
|
+
export const KIRO_AGENTIC_SYSTEM_PROMPT = `
|
|
24
|
+
# CRITICAL: CHUNKED WRITE PROTOCOL (MANDATORY)
|
|
25
|
+
|
|
26
|
+
You MUST follow these rules for ALL file operations. Violation causes server timeouts and task failure.
|
|
27
|
+
|
|
28
|
+
## ABSOLUTE LIMITS
|
|
29
|
+
- **MAXIMUM 350 LINES** per single write/edit operation - NO EXCEPTIONS
|
|
30
|
+
- **RECOMMENDED 300 LINES** or less for optimal performance
|
|
31
|
+
- **NEVER** write entire files in one operation if >300 lines
|
|
32
|
+
|
|
33
|
+
## MANDATORY CHUNKED WRITE STRATEGY
|
|
34
|
+
|
|
35
|
+
### For NEW FILES (>300 lines total):
|
|
36
|
+
1. FIRST: Write initial chunk (first 250-300 lines) using write_to_file/fsWrite
|
|
37
|
+
2. THEN: Append remaining content in 250-300 line chunks using file append operations
|
|
38
|
+
3. REPEAT: Continue appending until complete
|
|
39
|
+
|
|
40
|
+
### For EDITING EXISTING FILES:
|
|
41
|
+
1. Use surgical edits (apply_diff/targeted edits) - change ONLY what's needed
|
|
42
|
+
2. NEVER rewrite entire files - use incremental modifications
|
|
43
|
+
3. Split large refactors into multiple small, focused edits
|
|
44
|
+
|
|
45
|
+
### For LARGE CODE GENERATION:
|
|
46
|
+
1. Generate in logical sections (imports, types, functions separately)
|
|
47
|
+
2. Write each section as a separate operation
|
|
48
|
+
3. Use append operations for subsequent sections
|
|
49
|
+
|
|
50
|
+
## EXAMPLES OF CORRECT BEHAVIOR
|
|
51
|
+
|
|
52
|
+
CORRECT: Writing a 600-line file
|
|
53
|
+
- Operation 1: Write lines 1-300 (initial file creation)
|
|
54
|
+
- Operation 2: Append lines 301-600
|
|
55
|
+
|
|
56
|
+
CORRECT: Editing multiple functions
|
|
57
|
+
- Operation 1: Edit function A
|
|
58
|
+
- Operation 2: Edit function B
|
|
59
|
+
- Operation 3: Edit function C
|
|
60
|
+
|
|
61
|
+
WRONG: Writing 500 lines in single operation -> TIMEOUT
|
|
62
|
+
WRONG: Rewriting entire file to change 5 lines -> TIMEOUT
|
|
63
|
+
WRONG: Generating massive code blocks without chunking -> TIMEOUT
|
|
64
|
+
|
|
65
|
+
## WHY THIS MATTERS
|
|
66
|
+
- Server has 2-3 minute timeout for operations
|
|
67
|
+
- Large writes exceed timeout and FAIL completely
|
|
68
|
+
- Chunked writes are FASTER and more RELIABLE
|
|
69
|
+
- Failed writes waste time and require retry
|
|
70
|
+
|
|
71
|
+
REMEMBER: When in doubt, write LESS per operation. Multiple small operations > one large operation.
|
|
72
|
+
`.trim();
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Detect whether an inbound request is asking for reasoning / thinking output.
|
|
76
|
+
*
|
|
77
|
+
* Sources of intent (any one is enough):
|
|
78
|
+
* - HTTP header `Anthropic-Beta: ...interleaved-thinking...`
|
|
79
|
+
* - JSON `thinking.type === "enabled"` (Claude Messages API)
|
|
80
|
+
* - JSON `reasoning_effort` in {low, medium, high, auto} (OpenAI o1/o3)
|
|
81
|
+
* - JSON `reasoning.effort` in {low, medium, high, auto} (OpenAI Responses)
|
|
82
|
+
* - System prompt contains `<thinking_mode>enabled</thinking_mode>` or
|
|
83
|
+
* `<thinking_mode>interleaved</thinking_mode>` (AMP / Cursor)
|
|
84
|
+
* - Model name contains `thinking` or `-reason`
|
|
85
|
+
*
|
|
86
|
+
* @param {object} body OpenAI-shaped request body (post-translation)
|
|
87
|
+
* @param {object} [headers] Original inbound HTTP headers (case-insensitive)
|
|
88
|
+
* @param {string} [model] Model id the caller asked for (post-strip ok)
|
|
89
|
+
* @returns {boolean}
|
|
90
|
+
*/
|
|
91
|
+
export function isThinkingEnabled(body, headers, model) {
|
|
92
|
+
if (headers) {
|
|
93
|
+
const beta = pickHeader(headers, "anthropic-beta");
|
|
94
|
+
if (typeof beta === "string" && beta.toLowerCase().includes("interleaved-thinking")) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (body && typeof body === "object") {
|
|
100
|
+
const thinking = body.thinking;
|
|
101
|
+
if (thinking && typeof thinking === "object" && thinking.type === "enabled") {
|
|
102
|
+
const budget = Number(thinking.budget_tokens);
|
|
103
|
+
if (!Number.isFinite(budget) || budget > 0) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const effort = body.reasoning_effort
|
|
109
|
+
?? (body.reasoning && typeof body.reasoning === "object" ? body.reasoning.effort : null);
|
|
110
|
+
if (typeof effort === "string") {
|
|
111
|
+
const v = effort.toLowerCase();
|
|
112
|
+
if (v && v !== "none" && (v === "low" || v === "medium" || v === "high" || v === "auto")) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (containsThinkingModeTag(body)) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (typeof model === "string" && model) {
|
|
123
|
+
const m = model.toLowerCase();
|
|
124
|
+
if (m.includes("thinking") || m.includes("-reason")) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Detect whether a model id refers to a 9router synthetic agentic variant.
|
|
134
|
+
* Agentic variants share the same upstream model as the base; the only
|
|
135
|
+
* difference is the chunked-write system prompt this module injects.
|
|
136
|
+
*
|
|
137
|
+
* @param {string} model
|
|
138
|
+
* @returns {boolean}
|
|
139
|
+
*/
|
|
140
|
+
export function isAgenticModel(model) {
|
|
141
|
+
return typeof model === "string" && model.endsWith(KIRO_AGENTIC_SUFFIX);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Strip the `-agentic` suffix from a model id, leaving the upstream-real id.
|
|
146
|
+
*
|
|
147
|
+
* @param {string} model
|
|
148
|
+
* @returns {string}
|
|
149
|
+
*/
|
|
150
|
+
export function stripAgenticSuffix(model) {
|
|
151
|
+
if (!isAgenticModel(model)) return model;
|
|
152
|
+
return model.slice(0, -KIRO_AGENTIC_SUFFIX.length);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Detect whether a model id is a 9router synthetic thinking variant
|
|
157
|
+
* (e.g. `claude-sonnet-4.5-thinking`). Same upstream model as the base; the
|
|
158
|
+
* only difference is `<thinking_mode>enabled</thinking_mode>` injection.
|
|
159
|
+
*
|
|
160
|
+
* Note: real Kiro thinking-capable variants exist (e.g. `kimi-k2-thinking` in
|
|
161
|
+
* other providers), but for the `kr/` namespace there is no `-thinking`
|
|
162
|
+
* model on Kiro upstream. Treat the suffix as a synthetic alias.
|
|
163
|
+
*
|
|
164
|
+
* @param {string} model Model id with `-agentic` already stripped
|
|
165
|
+
* @returns {boolean}
|
|
166
|
+
*/
|
|
167
|
+
export function isThinkingModel(model) {
|
|
168
|
+
return typeof model === "string" && model.endsWith(KIRO_THINKING_SUFFIX);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Strip the `-thinking` suffix from a model id.
|
|
173
|
+
*
|
|
174
|
+
* @param {string} model
|
|
175
|
+
* @returns {string}
|
|
176
|
+
*/
|
|
177
|
+
export function stripThinkingSuffix(model) {
|
|
178
|
+
if (!isThinkingModel(model)) return model;
|
|
179
|
+
return model.slice(0, -KIRO_THINKING_SUFFIX.length);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Resolve a 9router model id to the real upstream Kiro model id, plus flags
|
|
184
|
+
* describing which behaviours the suffixes implied.
|
|
185
|
+
*
|
|
186
|
+
* resolveKiroModel("claude-sonnet-4.5-thinking-agentic")
|
|
187
|
+
* => { upstream: "claude-sonnet-4.5", agentic: true, thinking: true }
|
|
188
|
+
* resolveKiroModel("claude-sonnet-4.5-thinking")
|
|
189
|
+
* => { upstream: "claude-sonnet-4.5", agentic: false, thinking: true }
|
|
190
|
+
* resolveKiroModel("claude-sonnet-4.5-agentic")
|
|
191
|
+
* => { upstream: "claude-sonnet-4.5", agentic: true, thinking: false }
|
|
192
|
+
* resolveKiroModel("claude-sonnet-4.5")
|
|
193
|
+
* => { upstream: "claude-sonnet-4.5", agentic: false, thinking: false }
|
|
194
|
+
*
|
|
195
|
+
* @param {string} model
|
|
196
|
+
* @returns {{ upstream: string, agentic: boolean, thinking: boolean }}
|
|
197
|
+
*/
|
|
198
|
+
export function resolveKiroModel(model) {
|
|
199
|
+
let upstream = model;
|
|
200
|
+
let agentic = false;
|
|
201
|
+
let thinking = false;
|
|
202
|
+
if (isAgenticModel(upstream)) {
|
|
203
|
+
agentic = true;
|
|
204
|
+
upstream = stripAgenticSuffix(upstream);
|
|
205
|
+
}
|
|
206
|
+
if (isThinkingModel(upstream)) {
|
|
207
|
+
thinking = true;
|
|
208
|
+
upstream = stripThinkingSuffix(upstream);
|
|
209
|
+
}
|
|
210
|
+
return { upstream, agentic, thinking };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Build the magic system-prompt prefix that turns Kiro reasoning on.
|
|
215
|
+
* Same shape as CLIProxyAPIPlus.
|
|
216
|
+
*
|
|
217
|
+
* @param {number} [budget=KIRO_THINKING_BUDGET_DEFAULT]
|
|
218
|
+
*/
|
|
219
|
+
export function buildThinkingSystemPrefix(budget = KIRO_THINKING_BUDGET_DEFAULT) {
|
|
220
|
+
const safeBudget = Math.max(1, Math.min(32000, Number(budget) || KIRO_THINKING_BUDGET_DEFAULT));
|
|
221
|
+
return `<thinking_mode>enabled</thinking_mode>\n<max_thinking_length>${safeBudget}</max_thinking_length>`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function pickHeader(headers, name) {
|
|
225
|
+
if (!headers) return undefined;
|
|
226
|
+
if (typeof headers.get === "function") {
|
|
227
|
+
return headers.get(name);
|
|
228
|
+
}
|
|
229
|
+
const lower = name.toLowerCase();
|
|
230
|
+
for (const key of Object.keys(headers)) {
|
|
231
|
+
if (key.toLowerCase() === lower) {
|
|
232
|
+
return headers[key];
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function containsThinkingModeTag(body) {
|
|
239
|
+
const messages = Array.isArray(body?.messages) ? body.messages : [];
|
|
240
|
+
for (const msg of messages) {
|
|
241
|
+
if (!msg) continue;
|
|
242
|
+
if (msg.role !== "system" && msg.role !== "user") continue;
|
|
243
|
+
const content = msg.content;
|
|
244
|
+
if (typeof content === "string") {
|
|
245
|
+
if (containsTagInText(content)) return true;
|
|
246
|
+
} else if (Array.isArray(content)) {
|
|
247
|
+
for (const part of content) {
|
|
248
|
+
const text = part?.text;
|
|
249
|
+
if (typeof text === "string" && containsTagInText(text)) return true;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (typeof body?.system === "string" && containsTagInText(body.system)) return true;
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function containsTagInText(text) {
|
|
258
|
+
if (!text) return false;
|
|
259
|
+
if (!text.includes("<thinking_mode>")) return false;
|
|
260
|
+
return text.includes("<thinking_mode>enabled</thinking_mode>")
|
|
261
|
+
|| text.includes("<thinking_mode>interleaved</thinking_mode>");
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Added from 9router - missing exports
|
|
265
|
+
export function resolveDefaultProfileArn(authMethod) {
|
|
266
|
+
const social = authMethod === "google" || authMethod === "github";
|
|
267
|
+
return social ? KIRO_DEFAULT_PROFILE_ARNS.social : KIRO_DEFAULT_PROFILE_ARNS["builder-id"];
|
|
268
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Central config for remote-media fetching security limits.
|
|
2
|
+
|
|
3
|
+
// Max bytes accepted from a remote image fetch (reject larger to prevent memory DoS).
|
|
4
|
+
export const MAX_IMAGE_BYTES = 10 * 1024 * 1024; // 10MB
|
|
5
|
+
|
|
6
|
+
// Fetch timeout for remote media.
|
|
7
|
+
export const FETCH_TIMEOUT_MS = 10000;
|
|
8
|
+
|
|
9
|
+
// Magic-byte signatures -> mime. Each entry: { sig:[bytes], offset, mime }.
|
|
10
|
+
// offset>0 for containers where the signature is not at byte 0 (e.g. webp).
|
|
11
|
+
export const IMAGE_SIGNATURES = [
|
|
12
|
+
{ sig: [0x89, 0x50, 0x4e, 0x47], offset: 0, mime: "image/png" },
|
|
13
|
+
{ sig: [0xff, 0xd8, 0xff], offset: 0, mime: "image/jpeg" },
|
|
14
|
+
{ sig: [0x47, 0x49, 0x46, 0x38], offset: 0, mime: "image/gif" },
|
|
15
|
+
{ sig: [0x52, 0x49, 0x46, 0x46], offset: 0, mime: "image/webp", verifyWebp: true },
|
|
16
|
+
{ sig: [0x42, 0x4d], offset: 0, mime: "image/bmp" },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
// Hostnames/IPs that must never be fetched (SSRF guard for loopback + cloud metadata).
|
|
20
|
+
export const BLOCKED_HOSTS = new Set([
|
|
21
|
+
"localhost",
|
|
22
|
+
"127.0.0.1",
|
|
23
|
+
"0.0.0.0",
|
|
24
|
+
"::1",
|
|
25
|
+
"169.254.169.254", // AWS/GCP/Azure IMDS
|
|
26
|
+
"metadata.google.internal",
|
|
27
|
+
]);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media serviceKinds — derived from the backend registries.
|
|
3
|
+
*
|
|
4
|
+
* The dashboard's `/dashboard/media-providers/[kind]` pages list a provider
|
|
5
|
+
* under a media kind when the provider supports it. Historically this relied on
|
|
6
|
+
* a hand-maintained `serviceKinds` array on every provider in providers.ts,
|
|
7
|
+
* which had drifted badly: ~48 providers were wired into the audio/video/music/
|
|
8
|
+
* image/embedding registries (backend works) but declared no `serviceKinds`, so
|
|
9
|
+
* they never appeared in the UI.
|
|
10
|
+
*
|
|
11
|
+
* This module makes the registries the single source of truth: a provider that
|
|
12
|
+
* appears as a key in a media registry supports that kind, full stop. The UI
|
|
13
|
+
* derives membership from here instead of duplicating it by hand, so adding a
|
|
14
|
+
* provider to a registry automatically surfaces it — no second edit, no drift.
|
|
15
|
+
*
|
|
16
|
+
* Kinds without a backing registry (imageToText, webSearch, webFetch, llm) are
|
|
17
|
+
* still declared explicitly via `serviceKinds` on the provider entry; callers
|
|
18
|
+
* union the two sources.
|
|
19
|
+
*/
|
|
20
|
+
import { AUDIO_TRANSCRIPTION_PROVIDERS, AUDIO_SPEECH_PROVIDERS } from "./audioRegistry.js";
|
|
21
|
+
import { VIDEO_PROVIDERS } from "./videoRegistry.js";
|
|
22
|
+
import { MUSIC_PROVIDERS } from "./musicRegistry.js";
|
|
23
|
+
import { IMAGE_PROVIDERS } from "./imageRegistry.js";
|
|
24
|
+
import { EMBEDDING_PROVIDERS } from "./embeddingRegistry.js";
|
|
25
|
+
import { OCR_PROVIDERS } from "./ocrRegistry.js";
|
|
26
|
+
import { SEARCH_PROVIDERS } from "./searchRegistry.js";
|
|
27
|
+
import { MODERATION_PROVIDERS } from "./moderationRegistry.js";
|
|
28
|
+
import { RERANK_PROVIDERS } from "./rerankRegistry.js";
|
|
29
|
+
|
|
30
|
+
/** Media kinds whose provider membership is defined by a backend registry. */
|
|
31
|
+
export const MEDIA_KIND_REGISTRIES = {
|
|
32
|
+
stt: AUDIO_TRANSCRIPTION_PROVIDERS,
|
|
33
|
+
tts: AUDIO_SPEECH_PROVIDERS,
|
|
34
|
+
video: VIDEO_PROVIDERS,
|
|
35
|
+
music: MUSIC_PROVIDERS,
|
|
36
|
+
image: IMAGE_PROVIDERS,
|
|
37
|
+
embedding: EMBEDDING_PROVIDERS,
|
|
38
|
+
ocr: OCR_PROVIDERS,
|
|
39
|
+
search: SEARCH_PROVIDERS,
|
|
40
|
+
moderation: MODERATION_PROVIDERS,
|
|
41
|
+
rerank: RERANK_PROVIDERS,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const REGISTRY_MEDIA_KINDS = Object.freeze(
|
|
45
|
+
Object.keys(MEDIA_KIND_REGISTRIES)
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Media serviceKinds a provider supports, derived from the backend registries.
|
|
50
|
+
* Returns the kinds (e.g. `["tts","video","music"]`) for which `providerId`
|
|
51
|
+
* appears as a registry key. Empty array if the provider serves no media.
|
|
52
|
+
*/
|
|
53
|
+
export function getRegistryMediaKinds(providerId) {
|
|
54
|
+
const kinds = [];
|
|
55
|
+
for (const kind of REGISTRY_MEDIA_KINDS) {
|
|
56
|
+
if (Object.prototype.hasOwnProperty.call(MEDIA_KIND_REGISTRIES[kind], providerId)) {
|
|
57
|
+
kinds.push(kind);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return kinds;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Full set of serviceKinds for a provider: the explicitly declared ones (llm,
|
|
65
|
+
* web*, imageToText) unioned with the media kinds derived from the registries.
|
|
66
|
+
*/
|
|
67
|
+
export function resolveProviderServiceKinds(providerId, declared) {
|
|
68
|
+
const set = new Set(declared ?? []);
|
|
69
|
+
for (const kind of getRegistryMediaKinds(providerId)) set.add(kind);
|
|
70
|
+
return [...set];
|
|
71
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Model metadata registry
|
|
2
|
+
// Only define models that differ from DEFAULT_MODEL_INFO
|
|
3
|
+
// Custom entries are merged over default
|
|
4
|
+
const DEFAULT_MODEL_INFO = {
|
|
5
|
+
type: ["chat"],
|
|
6
|
+
contextWindow: 200000,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const MODEL_INFO = {};
|
|
10
|
+
|
|
11
|
+
export function getModelInfo(modelId) {
|
|
12
|
+
return { ...DEFAULT_MODEL_INFO, ...MODEL_INFO[modelId] };
|
|
13
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moderation Provider Registry
|
|
3
|
+
*
|
|
4
|
+
* Defines providers that support the /v1/moderations endpoint.
|
|
5
|
+
* Follows OpenAI's moderation API format.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const MODERATION_PROVIDERS = {
|
|
9
|
+
openai: {
|
|
10
|
+
id: "openai",
|
|
11
|
+
baseUrl: "https://api.openai.com/v1/moderations",
|
|
12
|
+
authType: "apikey",
|
|
13
|
+
authHeader: "bearer",
|
|
14
|
+
models: [
|
|
15
|
+
{ id: "omni-moderation-latest", name: "Omni Moderation Latest" },
|
|
16
|
+
{ id: "text-moderation-latest", name: "Text Moderation Latest" },
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
mistral: {
|
|
20
|
+
id: "mistral",
|
|
21
|
+
baseUrl: "https://api.mistral.ai/v1/moderations",
|
|
22
|
+
authType: "apikey",
|
|
23
|
+
authHeader: "bearer",
|
|
24
|
+
models: [{ id: "mistral-moderation-latest", name: "Mistral Moderation" }],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get moderation provider config by ID.
|
|
30
|
+
*/
|
|
31
|
+
export function getModerationProvider(providerId) {
|
|
32
|
+
return MODERATION_PROVIDERS[providerId] || null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Parse a moderation model string.
|
|
37
|
+
*/
|
|
38
|
+
export function parseModerationModel(modelStr) {
|
|
39
|
+
if (!modelStr) return { provider: null, model: null };
|
|
40
|
+
|
|
41
|
+
for (const providerId of Object.keys(MODERATION_PROVIDERS)) {
|
|
42
|
+
if (modelStr.startsWith(providerId + "/")) {
|
|
43
|
+
return { provider: providerId, model: modelStr.slice(providerId.length + 1) };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
for (const [providerId, config] of Object.entries(MODERATION_PROVIDERS)) {
|
|
48
|
+
if (config.models.some((m) => m.id === modelStr)) {
|
|
49
|
+
return { provider: providerId, model: modelStr };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return { provider: null, model: modelStr };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get all moderation models as a flat list.
|
|
58
|
+
*/
|
|
59
|
+
export function getAllModerationModels() {
|
|
60
|
+
const models = [];
|
|
61
|
+
for (const [providerId, config] of Object.entries(MODERATION_PROVIDERS)) {
|
|
62
|
+
for (const model of config.models) {
|
|
63
|
+
models.push({
|
|
64
|
+
id: `${providerId}/${model.id}`,
|
|
65
|
+
name: model.name,
|
|
66
|
+
provider: providerId,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return models;
|
|
71
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Music Generation Provider Registry
|
|
3
|
+
*
|
|
4
|
+
* Defines providers that support the /v1/music/generations endpoint.
|
|
5
|
+
* Currently supports local providers (ComfyUI with audio models).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { parseModelFromRegistry, getAllModelsFromRegistry } from "./registryUtils.js";
|
|
9
|
+
|
|
10
|
+
export const MUSIC_PROVIDERS = {
|
|
11
|
+
vertex: {
|
|
12
|
+
id: "vertex",
|
|
13
|
+
baseUrl: "https://us-central1-aiplatform.googleapis.com/v1",
|
|
14
|
+
authType: "apikey",
|
|
15
|
+
authHeader: "bearer",
|
|
16
|
+
format: "vertex-lyria",
|
|
17
|
+
models: [{ id: "lyria-002", name: "Lyria 2 (Vertex)" }],
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
kie: {
|
|
21
|
+
id: "kie",
|
|
22
|
+
baseUrl: "https://api.kie.ai",
|
|
23
|
+
statusUrl: "https://api.kie.ai/api/v1/jobs/recordInfo",
|
|
24
|
+
authType: "apikey",
|
|
25
|
+
authHeader: "bearer",
|
|
26
|
+
format: "kie-music",
|
|
27
|
+
models: [
|
|
28
|
+
{ id: "suno-v4.0", name: "Suno V4.0" },
|
|
29
|
+
{ id: "suno-v3.5", name: "Suno V3.5" },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
suno: {
|
|
34
|
+
id: "suno",
|
|
35
|
+
baseUrl: "https://studio-api.suno.ai/api/generate/v2/",
|
|
36
|
+
statusUrl: "https://studio-api.suno.ai/api/feed/",
|
|
37
|
+
authType: "cookie",
|
|
38
|
+
authHeader: "cookie",
|
|
39
|
+
format: "suno-music",
|
|
40
|
+
models: [
|
|
41
|
+
{ id: "chirp-v3-5", name: "Chirp V3.5" },
|
|
42
|
+
{ id: "chirp-v4", name: "Chirp V4" },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
udio: {
|
|
46
|
+
id: "udio",
|
|
47
|
+
baseUrl: "https://www.udio.com/api/generate-proxy",
|
|
48
|
+
statusUrl: "https://www.udio.com/api/songs",
|
|
49
|
+
authType: "cookie",
|
|
50
|
+
authHeader: "cookie",
|
|
51
|
+
format: "udio-music",
|
|
52
|
+
models: [{ id: "udio-default", name: "Udio Default" }],
|
|
53
|
+
},
|
|
54
|
+
minimax: {
|
|
55
|
+
id: "minimax",
|
|
56
|
+
baseUrl: "https://api.minimax.io/v1/music_generation",
|
|
57
|
+
statusUrl: "https://api.minimax.io/v1/query/music_generation",
|
|
58
|
+
authType: "apikey",
|
|
59
|
+
authHeader: "bearer",
|
|
60
|
+
format: "minimax-music",
|
|
61
|
+
models: [
|
|
62
|
+
{ id: "music-2.6", name: "Music 2.6" },
|
|
63
|
+
{ id: "music-2.6-free", name: "Music 2.6 Free" },
|
|
64
|
+
{ id: "music-cover", name: "Music Cover" },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
comfyui: {
|
|
68
|
+
id: "comfyui",
|
|
69
|
+
baseUrl: "http://localhost:8188",
|
|
70
|
+
authType: "none",
|
|
71
|
+
authHeader: "none",
|
|
72
|
+
format: "comfyui",
|
|
73
|
+
models: [
|
|
74
|
+
{ id: "stable-audio-open", name: "Stable Audio Open" },
|
|
75
|
+
{ id: "musicgen-medium", name: "MusicGen Medium" },
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get music provider config by ID
|
|
82
|
+
*/
|
|
83
|
+
export function getMusicProvider(providerId) {
|
|
84
|
+
return MUSIC_PROVIDERS[providerId] || null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Parse music model string (format: "provider/model" or just "model")
|
|
89
|
+
*/
|
|
90
|
+
export function parseMusicModel(modelStr) {
|
|
91
|
+
return parseModelFromRegistry(modelStr, MUSIC_PROVIDERS);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get all music models as a flat list
|
|
96
|
+
*/
|
|
97
|
+
export function getAllMusicModels() {
|
|
98
|
+
return getAllModelsFromRegistry(MUSIC_PROVIDERS);
|
|
99
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OCR Provider Registry
|
|
3
|
+
*
|
|
4
|
+
* Defines providers that support the /v1/ocr endpoint.
|
|
5
|
+
* Follows Mistral's OCR API format.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const OCR_PROVIDERS = {
|
|
9
|
+
mistral: {
|
|
10
|
+
id: "mistral",
|
|
11
|
+
baseUrl: "https://api.mistral.ai/v1/ocr",
|
|
12
|
+
authType: "apikey",
|
|
13
|
+
authHeader: "bearer",
|
|
14
|
+
models: [{ id: "mistral-ocr-latest", name: "Mistral OCR" }],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get OCR provider config by ID.
|
|
20
|
+
*/
|
|
21
|
+
export function getOcrProvider(providerId) {
|
|
22
|
+
return OCR_PROVIDERS[providerId] || null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Parse an OCR model string.
|
|
27
|
+
*/
|
|
28
|
+
export function parseOcrModel(modelStr) {
|
|
29
|
+
if (!modelStr) return { provider: null, model: null };
|
|
30
|
+
|
|
31
|
+
for (const providerId of Object.keys(OCR_PROVIDERS)) {
|
|
32
|
+
if (modelStr.startsWith(providerId + "/")) {
|
|
33
|
+
return { provider: providerId, model: modelStr.slice(providerId.length + 1) };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const [providerId, config] of Object.entries(OCR_PROVIDERS)) {
|
|
38
|
+
if (config.models.some((m) => m.id === modelStr)) {
|
|
39
|
+
return { provider: providerId, model: modelStr };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return { provider: null, model: modelStr };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get all OCR models as a flat list.
|
|
48
|
+
*/
|
|
49
|
+
export function getAllOcrModels() {
|
|
50
|
+
const models = [];
|
|
51
|
+
for (const [providerId, config] of Object.entries(OCR_PROVIDERS)) {
|
|
52
|
+
for (const model of config.models) {
|
|
53
|
+
models.push({
|
|
54
|
+
id: `${providerId}/${model.id}`,
|
|
55
|
+
name: model.name,
|
|
56
|
+
provider: providerId,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return models;
|
|
61
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const ollamaModels = {
|
|
2
|
+
models: [
|
|
3
|
+
{
|
|
4
|
+
name: "llama3.2",
|
|
5
|
+
modified_at: "2025-12-26T00:00:00Z",
|
|
6
|
+
size: 2000000000,
|
|
7
|
+
digest: "abc123def456",
|
|
8
|
+
details: { format: "gguf", family: "llama", parameter_size: "3B", quantization_level: "Q4_K_M" }
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: "qwen2.5",
|
|
12
|
+
modified_at: "2025-12-26T00:00:00Z",
|
|
13
|
+
size: 4000000000,
|
|
14
|
+
digest: "def456abc123",
|
|
15
|
+
details: { format: "gguf", family: "qwen", parameter_size: "7B", quantization_level: "Q4_K_M" }
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
};
|
|
19
|
+
|