wyxrouter 0.4.71
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/CHANGELOG.md +222 -0
- package/LICENSE +21 -0
- package/README.md +96 -0
- package/README.zh-CN.md +1311 -0
- package/assets/pixel-router-2d.png +0 -0
- package/cli/LICENSE +42 -0
- package/cli/README.md +125 -0
- package/cli/app/package.json +58 -0
- package/cli/cli.js +806 -0
- package/cli/package.json +48 -0
- package/i18n/README.ja-JP.md +1209 -0
- package/i18n/README.ru.md +1311 -0
- package/i18n/README.vi.md +1310 -0
- package/i18n/README.zh-CN.md +1306 -0
- package/images/9router.png +0 -0
- package/jsconfig.json +12 -0
- package/next.config.mjs +71 -0
- package/open-sse/config/appConstants.js +203 -0
- package/open-sse/config/codexInstructions.js +119 -0
- package/open-sse/config/constants.js +4 -0
- package/open-sse/config/defaultThinkingSignature.js +12 -0
- package/open-sse/config/errorConfig.js +85 -0
- package/open-sse/config/googleTtsLanguages.js +62 -0
- package/open-sse/config/kiroConstants.js +322 -0
- package/open-sse/config/models.js +13 -0
- package/open-sse/config/ollamaModels.js +19 -0
- package/open-sse/config/providerModels.js +944 -0
- package/open-sse/config/providers.js +458 -0
- package/open-sse/config/runtimeConfig.js +72 -0
- package/open-sse/config/ttsModels.js +129 -0
- package/open-sse/executors/antigravity.js +504 -0
- package/open-sse/executors/azure.js +57 -0
- package/open-sse/executors/base.js +185 -0
- package/open-sse/executors/codex.js +469 -0
- package/open-sse/executors/commandcode.js +88 -0
- package/open-sse/executors/cursor.js +795 -0
- package/open-sse/executors/default.js +497 -0
- package/open-sse/executors/gemini-cli.js +89 -0
- package/open-sse/executors/github.js +379 -0
- package/open-sse/executors/grok-web.js +345 -0
- package/open-sse/executors/iflow.js +108 -0
- package/open-sse/executors/index.js +75 -0
- package/open-sse/executors/kiro.js +508 -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 +507 -0
- package/open-sse/executors/qoder.js +450 -0
- package/open-sse/executors/qwen.js +129 -0
- package/open-sse/executors/vertex.js +131 -0
- package/open-sse/executors/xiaomi-tokenplan.js +19 -0
- package/open-sse/handlers/chatCore/nonStreamingHandler.js +230 -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 +103 -0
- package/open-sse/handlers/chatCore.js +287 -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 +189 -0
- package/open-sse/handlers/imageProviders/_base.js +31 -0
- package/open-sse/handlers/imageProviders/blackForestLabs.js +43 -0
- package/open-sse/handlers/imageProviders/cloudflareAi.js +178 -0
- package/open-sse/handlers/imageProviders/codex.js +198 -0
- package/open-sse/handlers/imageProviders/comfyui.js +8 -0
- package/open-sse/handlers/imageProviders/falAi.js +41 -0
- package/open-sse/handlers/imageProviders/gemini.js +25 -0
- package/open-sse/handlers/imageProviders/huggingface.js +22 -0
- package/open-sse/handlers/imageProviders/index.js +40 -0
- package/open-sse/handlers/imageProviders/nanobanana.js +58 -0
- package/open-sse/handlers/imageProviders/openai.js +40 -0
- package/open-sse/handlers/imageProviders/runwayml.js +47 -0
- package/open-sse/handlers/imageProviders/sdwebui.js +17 -0
- package/open-sse/handlers/imageProviders/stabilityAi.js +34 -0
- package/open-sse/handlers/responsesHandler.js +103 -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/sttCore.js +194 -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/index.js +82 -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 +49 -0
- package/open-sse/rtk/filters/gitDiff.js +92 -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/index.js +155 -0
- package/open-sse/rtk/registry.js +38 -0
- package/open-sse/services/accountFallback.js +238 -0
- package/open-sse/services/combo.js +198 -0
- package/open-sse/services/compact.js +71 -0
- package/open-sse/services/kiroModels.js +332 -0
- package/open-sse/services/model.js +261 -0
- package/open-sse/services/oauthCredentialManager.js +151 -0
- package/open-sse/services/projectId.js +306 -0
- package/open-sse/services/provider.js +356 -0
- package/open-sse/services/qoderModels.js +214 -0
- package/open-sse/services/tokenRefresh.js +939 -0
- package/open-sse/services/usage.js +1496 -0
- package/open-sse/transformer/responsesTransformer.js +439 -0
- package/open-sse/transformer/streamToJsonConverter.js +103 -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 +251 -0
- package/open-sse/translator/request/antigravity-to-openai.js +229 -0
- package/open-sse/translator/request/claude-to-openai.js +232 -0
- package/open-sse/translator/request/gemini-to-openai.js +147 -0
- package/open-sse/translator/request/openai-responses.js +318 -0
- package/open-sse/translator/request/openai-to-claude.js +401 -0
- package/open-sse/translator/request/openai-to-commandcode.js +170 -0
- package/open-sse/translator/request/openai-to-cursor.js +183 -0
- package/open-sse/translator/request/openai-to-gemini.js +470 -0
- package/open-sse/translator/request/openai-to-kiro.js +629 -0
- package/open-sse/translator/request/openai-to-kiro.old.js +278 -0
- package/open-sse/translator/request/openai-to-ollama.js +192 -0
- package/open-sse/translator/request/openai-to-vertex.js +42 -0
- package/open-sse/translator/response/claude-to-openai.js +206 -0
- package/open-sse/translator/response/commandcode-to-openai.js +197 -0
- package/open-sse/translator/response/cursor-to-openai.js +30 -0
- package/open-sse/translator/response/gemini-to-openai.js +245 -0
- package/open-sse/translator/response/kiro-to-openai.js +195 -0
- package/open-sse/translator/response/ollama-to-openai.js +152 -0
- package/open-sse/translator/response/openai-responses.js +590 -0
- package/open-sse/translator/response/openai-to-antigravity.js +122 -0
- package/open-sse/translator/response/openai-to-claude.js +266 -0
- package/open-sse/utils/bypassHandler.js +298 -0
- package/open-sse/utils/claudeCloaking.js +155 -0
- package/open-sse/utils/claudeHeaderCache.js +70 -0
- package/open-sse/utils/clientDetector.js +63 -0
- package/open-sse/utils/cursorChecksum.js +149 -0
- package/open-sse/utils/cursorProtobuf.js +904 -0
- package/open-sse/utils/debugLog.js +14 -0
- package/open-sse/utils/error.js +147 -0
- package/open-sse/utils/ollamaTransform.js +85 -0
- package/open-sse/utils/proxyFetch.js +368 -0
- package/open-sse/utils/reasoningContentInjector.js +79 -0
- package/open-sse/utils/requestLogger.js +260 -0
- package/open-sse/utils/responsesStreamHelpers.js +49 -0
- package/open-sse/utils/sessionManager.js +82 -0
- package/open-sse/utils/stream.js +462 -0
- package/open-sse/utils/streamHandler.js +250 -0
- package/open-sse/utils/streamHelpers.js +122 -0
- package/open-sse/utils/toolDeduper.js +49 -0
- package/open-sse/utils/usageTracking.js +347 -0
- package/package.json +100 -0
- package/postcss.config.mjs +12 -0
- package/public/favicon.svg +11 -0
- package/public/file.svg +1 -0
- package/public/globe.svg +1 -0
- package/public/i18n/literals/ar.json +195 -0
- package/public/i18n/literals/bn.json +195 -0
- package/public/i18n/literals/cs.json +195 -0
- package/public/i18n/literals/da.json +195 -0
- package/public/i18n/literals/de.json +195 -0
- package/public/i18n/literals/el.json +195 -0
- package/public/i18n/literals/es.json +195 -0
- package/public/i18n/literals/fi.json +195 -0
- package/public/i18n/literals/fr.json +195 -0
- package/public/i18n/literals/he.json +195 -0
- package/public/i18n/literals/hi.json +195 -0
- package/public/i18n/literals/hu.json +195 -0
- package/public/i18n/literals/id.json +195 -0
- package/public/i18n/literals/it.json +195 -0
- package/public/i18n/literals/ja.json +195 -0
- package/public/i18n/literals/ko.json +195 -0
- package/public/i18n/literals/nl.json +195 -0
- package/public/i18n/literals/no.json +195 -0
- package/public/i18n/literals/pl.json +195 -0
- package/public/i18n/literals/pt-BR.json +195 -0
- package/public/i18n/literals/pt-PT.json +195 -0
- package/public/i18n/literals/ro.json +195 -0
- package/public/i18n/literals/ru.json +195 -0
- package/public/i18n/literals/sv.json +195 -0
- package/public/i18n/literals/th.json +195 -0
- package/public/i18n/literals/tl.json +195 -0
- package/public/i18n/literals/tr.json +195 -0
- package/public/i18n/literals/uk.json +195 -0
- package/public/i18n/literals/ur.json +195 -0
- package/public/i18n/literals/vi.json +195 -0
- package/public/i18n/literals/zh-CN.json +772 -0
- package/public/i18n/literals/zh-TW.json +195 -0
- package/public/icons/discord.svg +4 -0
- package/public/icons/icon-192.svg +4 -0
- package/public/icons/icon-512.svg +4 -0
- package/public/next.svg +1 -0
- package/public/providers/alicode-intl.png +0 -0
- package/public/providers/alicode.png +0 -0
- package/public/providers/amp.png +0 -0
- package/public/providers/anthropic-m.png +0 -0
- package/public/providers/anthropic.png +0 -0
- package/public/providers/antigravity.png +0 -0
- package/public/providers/assemblyai.png +0 -0
- package/public/providers/aws-polly.png +0 -0
- package/public/providers/azure.png +0 -0
- package/public/providers/black-forest-labs.png +0 -0
- package/public/providers/blackbox.png +0 -0
- package/public/providers/brave-search.png +0 -0
- package/public/providers/byteplus.png +0 -0
- package/public/providers/cartesia.png +0 -0
- package/public/providers/cerebras.png +0 -0
- package/public/providers/chutes.png +0 -0
- package/public/providers/claude.png +0 -0
- package/public/providers/cline.png +0 -0
- package/public/providers/cloudflare-ai.png +0 -0
- package/public/providers/codebuddy.svg +37 -0
- package/public/providers/codex.png +0 -0
- package/public/providers/cohere.png +0 -0
- package/public/providers/comfyui.png +0 -0
- package/public/providers/commandcode.png +0 -0
- package/public/providers/continue.png +0 -0
- package/public/providers/copilot.png +0 -0
- package/public/providers/coqui.png +0 -0
- package/public/providers/cursor.png +0 -0
- package/public/providers/deepgram.png +0 -0
- package/public/providers/deepseek-tui.png +0 -0
- package/public/providers/deepseek.png +0 -0
- package/public/providers/droid.png +0 -0
- package/public/providers/edge-tts.png +0 -0
- package/public/providers/elevenlabs.png +0 -0
- package/public/providers/exa.png +0 -0
- package/public/providers/fal-ai.png +0 -0
- package/public/providers/firecrawl.png +0 -0
- package/public/providers/fireworks.png +0 -0
- package/public/providers/gemini-cli.png +0 -0
- package/public/providers/gemini.png +0 -0
- package/public/providers/github.png +0 -0
- package/public/providers/glm-cn.png +0 -0
- package/public/providers/glm.png +0 -0
- package/public/providers/google-pse.png +0 -0
- package/public/providers/google-tts.png +0 -0
- package/public/providers/grok-web.png +0 -0
- package/public/providers/groq.png +0 -0
- package/public/providers/hermes.png +0 -0
- package/public/providers/huggingface.png +0 -0
- package/public/providers/hyperbolic.png +0 -0
- package/public/providers/iflow.png +0 -0
- package/public/providers/inworld.png +0 -0
- package/public/providers/jcode.png +0 -0
- package/public/providers/jina-ai.png +0 -0
- package/public/providers/jina-reader.png +0 -0
- package/public/providers/kilocode.png +0 -0
- package/public/providers/kimi-coding.png +0 -0
- package/public/providers/kimi.png +0 -0
- package/public/providers/kiro.png +0 -0
- package/public/providers/linkup.png +0 -0
- package/public/providers/local-device.png +0 -0
- package/public/providers/minimax-cn.png +0 -0
- package/public/providers/minimax.png +0 -0
- package/public/providers/mistral.png +0 -0
- package/public/providers/nanobanana.png +0 -0
- package/public/providers/nebius.png +0 -0
- package/public/providers/nvidia.png +0 -0
- package/public/providers/oai-cc.png +0 -0
- package/public/providers/oai-r.png +0 -0
- package/public/providers/ollama-local.png +0 -0
- package/public/providers/ollama.png +0 -0
- package/public/providers/openai.png +0 -0
- package/public/providers/openclaw.png +0 -0
- package/public/providers/opencode-go.png +0 -0
- package/public/providers/opencode.png +0 -0
- package/public/providers/openrouter.png +0 -0
- package/public/providers/perplexity-web.png +0 -0
- package/public/providers/perplexity.png +0 -0
- package/public/providers/playht.png +0 -0
- package/public/providers/qoder.png +0 -0
- package/public/providers/qwen.png +0 -0
- package/public/providers/recraft.png +0 -0
- package/public/providers/roo.png +0 -0
- package/public/providers/runwayml.png +0 -0
- package/public/providers/sdwebui.png +0 -0
- package/public/providers/searchapi.png +0 -0
- package/public/providers/searxng.png +0 -0
- package/public/providers/serper.png +0 -0
- package/public/providers/siliconflow.png +0 -0
- package/public/providers/stability-ai.png +0 -0
- package/public/providers/tavily.png +0 -0
- package/public/providers/together.png +0 -0
- package/public/providers/topaz.png +0 -0
- package/public/providers/tortoise.png +0 -0
- package/public/providers/vertex-partner.png +0 -0
- package/public/providers/vertex.png +0 -0
- package/public/providers/volcengine-ark.png +0 -0
- package/public/providers/voyage-ai.png +0 -0
- package/public/providers/xai.png +0 -0
- package/public/providers/xiaomi-mimo.png +0 -0
- package/public/providers/xiaomi-tokenplan.png +0 -0
- package/public/providers/youcom.png +0 -0
- package/public/sw.js +22 -0
- package/public/vercel.svg +1 -0
- package/public/window.svg +1 -0
- package/scripts/compact-request-details.mjs +71 -0
- package/scripts/import-codex-gptjson.mjs +342 -0
- package/scripts/start-standalone.mjs +25 -0
- package/scripts/translate-readme.js +201 -0
- package/src/app/(dashboard)/dashboard/automation/page.js +294 -0
- package/src/app/(dashboard)/dashboard/basic-chat/BasicChatPageClient.js +967 -0
- package/src/app/(dashboard)/dashboard/basic-chat/page.js +5 -0
- package/src/app/(dashboard)/dashboard/cli-tools/CLIToolsPageClient.js +66 -0
- package/src/app/(dashboard)/dashboard/cli-tools/[toolId]/ToolDetailClient.js +173 -0
- package/src/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js +11 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/AntigravityToolCard.js +481 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/ApiKeySelect.js +66 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/BaseUrlSelect.js +174 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/ClaudeToolCard.js +390 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/ClineToolCard.js +301 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/CodexToolCard.js +458 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/CopilotToolCard.js +323 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/CoworkToolCard.js +640 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/DeepSeekTuiToolCard.js +338 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/DefaultToolCard.js +271 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/DroidToolCard.js +410 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/EndpointPresetControl.js +128 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/HermesToolCard.js +317 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/JcodeToolCard.js +380 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/KiloToolCard.js +275 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/MitmLinkCard.js +40 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/MitmServerCard.js +329 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/MitmToolCard.js +318 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/OpenClawToolCard.js +388 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/OpenCodeToolCard.js +500 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/ToolSummaryCard.js +39 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/cliEndpointMatch.js +13 -0
- package/src/app/(dashboard)/dashboard/cli-tools/components/index.js +19 -0
- package/src/app/(dashboard)/dashboard/cli-tools/page.js +7 -0
- package/src/app/(dashboard)/dashboard/combos/page.js +612 -0
- package/src/app/(dashboard)/dashboard/console-log/ConsoleLogClient.js +91 -0
- package/src/app/(dashboard)/dashboard/console-log/page.js +8 -0
- package/src/app/(dashboard)/dashboard/endpoint/EndpointPageClient.js +1555 -0
- package/src/app/(dashboard)/dashboard/endpoint/page.js +7 -0
- package/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +1903 -0
- package/src/app/(dashboard)/dashboard/media-providers/[kind]/page.js +289 -0
- package/src/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js +410 -0
- package/src/app/(dashboard)/dashboard/media-providers/web/page.js +209 -0
- package/src/app/(dashboard)/dashboard/mitm/MitmPageClient.js +117 -0
- package/src/app/(dashboard)/dashboard/mitm/page.js +5 -0
- package/src/app/(dashboard)/dashboard/page.js +7 -0
- package/src/app/(dashboard)/dashboard/profile/page.js +1140 -0
- package/src/app/(dashboard)/dashboard/providers/[id]/AddApiKeyModal.js +389 -0
- package/src/app/(dashboard)/dashboard/providers/[id]/AddCustomModelModal.js +125 -0
- package/src/app/(dashboard)/dashboard/providers/[id]/CompatibleModelsSection.js +250 -0
- package/src/app/(dashboard)/dashboard/providers/[id]/ConnectionRow.js +299 -0
- package/src/app/(dashboard)/dashboard/providers/[id]/CooldownTimer.js +42 -0
- package/src/app/(dashboard)/dashboard/providers/[id]/EditCompatibleNodeModal.js +161 -0
- package/src/app/(dashboard)/dashboard/providers/[id]/ModelRow.js +95 -0
- package/src/app/(dashboard)/dashboard/providers/[id]/PassthroughModelsSection.js +183 -0
- package/src/app/(dashboard)/dashboard/providers/[id]/page.js +2053 -0
- package/src/app/(dashboard)/dashboard/providers/[id]/page.new.js +1724 -0
- package/src/app/(dashboard)/dashboard/providers/components/ConnectionsCard.js +497 -0
- package/src/app/(dashboard)/dashboard/providers/components/ModelAvailabilityBadge.js +185 -0
- package/src/app/(dashboard)/dashboard/providers/components/ModelsCard.js +294 -0
- package/src/app/(dashboard)/dashboard/providers/new/page.js +220 -0
- package/src/app/(dashboard)/dashboard/providers/page.js +1365 -0
- package/src/app/(dashboard)/dashboard/proxy-pools/page.js +1092 -0
- package/src/app/(dashboard)/dashboard/quota/page.js +11 -0
- package/src/app/(dashboard)/dashboard/skills/page.js +112 -0
- package/src/app/(dashboard)/dashboard/translator/page.js +303 -0
- package/src/app/(dashboard)/dashboard/usage/components/OverviewCards.js +35 -0
- package/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/ProviderLimitCard.js +185 -0
- package/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/QuotaProgressBar.js +127 -0
- package/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/QuotaTable.js +259 -0
- package/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/index.js +1394 -0
- package/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils.js +244 -0
- package/src/app/(dashboard)/dashboard/usage/components/ProviderTopology.js +327 -0
- package/src/app/(dashboard)/dashboard/usage/components/RequestDetailsTab.js +433 -0
- package/src/app/(dashboard)/dashboard/usage/components/UsageChart.js +141 -0
- package/src/app/(dashboard)/dashboard/usage/components/UsageTable.js +247 -0
- package/src/app/(dashboard)/dashboard/usage/page.js +75 -0
- package/src/app/(dashboard)/layout.js +6 -0
- package/src/app/api/auth/login/route.js +76 -0
- package/src/app/api/auth/logout/route.js +12 -0
- package/src/app/api/auth/oidc/callback/route.js +87 -0
- package/src/app/api/auth/oidc/start/route.js +52 -0
- package/src/app/api/auth/oidc/test/route.js +84 -0
- package/src/app/api/auth/status/route.js +45 -0
- package/src/app/api/cli-tools/all-statuses/route.js +46 -0
- package/src/app/api/cli-tools/antigravity-mitm/alias/route.js +53 -0
- package/src/app/api/cli-tools/antigravity-mitm/route.js +202 -0
- package/src/app/api/cli-tools/claude-settings/route.js +203 -0
- package/src/app/api/cli-tools/cline-settings/route.js +133 -0
- package/src/app/api/cli-tools/codex-gateway/accounts/route.js +16 -0
- package/src/app/api/cli-tools/codex-settings/route.js +239 -0
- package/src/app/api/cli-tools/copilot-settings/route.js +148 -0
- package/src/app/api/cli-tools/cowork-mcp-registry/route.js +77 -0
- package/src/app/api/cli-tools/cowork-mcp-tools/route.js +95 -0
- package/src/app/api/cli-tools/cowork-settings/route.js +412 -0
- package/src/app/api/cli-tools/deepseek-tui-settings/route.js +164 -0
- package/src/app/api/cli-tools/droid-settings/route.js +213 -0
- package/src/app/api/cli-tools/hermes-settings/route.js +175 -0
- package/src/app/api/cli-tools/jcode-settings/route.js +216 -0
- package/src/app/api/cli-tools/kilo-settings/route.js +131 -0
- package/src/app/api/cli-tools/openclaw-settings/route.js +292 -0
- package/src/app/api/cli-tools/opencode-settings/route.js +259 -0
- package/src/app/api/combos/[id]/route.js +81 -0
- package/src/app/api/combos/route.js +48 -0
- package/src/app/api/health/route.js +15 -0
- package/src/app/api/init/route.js +4 -0
- package/src/app/api/keys/[id]/route.js +58 -0
- package/src/app/api/keys/route.js +42 -0
- package/src/app/api/locale/route.js +30 -0
- package/src/app/api/mcp/[plugin]/message/route.js +21 -0
- package/src/app/api/mcp/[plugin]/sse/route.js +37 -0
- package/src/app/api/media-providers/tts/deepgram/voices/route.js +65 -0
- package/src/app/api/media-providers/tts/elevenlabs/voices/route.js +71 -0
- package/src/app/api/media-providers/tts/inworld/voices/route.js +61 -0
- package/src/app/api/media-providers/tts/minimax/voices/route.js +113 -0
- package/src/app/api/media-providers/tts/voices/route.js +99 -0
- package/src/app/api/models/alias/route.js +53 -0
- package/src/app/api/models/availability/route.js +103 -0
- package/src/app/api/models/custom/route.js +48 -0
- package/src/app/api/models/disabled/route.js +50 -0
- package/src/app/api/models/route.js +64 -0
- package/src/app/api/models/test/ping.js +191 -0
- package/src/app/api/models/test/route.js +14 -0
- package/src/app/api/oauth/[provider]/[action]/route.js +343 -0
- package/src/app/api/oauth/codebuddy/bulk-import/[jobId]/cancel/route.js +19 -0
- package/src/app/api/oauth/codebuddy/bulk-import/[jobId]/manual/[workerId]/route.js +30 -0
- package/src/app/api/oauth/codebuddy/bulk-import/[jobId]/route.js +23 -0
- package/src/app/api/oauth/codebuddy/bulk-import/latest/route.js +25 -0
- package/src/app/api/oauth/codebuddy/bulk-import/route.js +49 -0
- package/src/app/api/oauth/codebuddy/quota-cookie/route.js +133 -0
- package/src/app/api/oauth/codex/import-token/route.js +96 -0
- package/src/app/api/oauth/cursor/auto-import/route.js +258 -0
- package/src/app/api/oauth/cursor/import/route.js +100 -0
- package/src/app/api/oauth/gitlab/pat/route.js +62 -0
- package/src/app/api/oauth/iflow/cookie/route.js +137 -0
- package/src/app/api/oauth/kiro/auto-import/route.js +85 -0
- package/src/app/api/oauth/kiro/bulk-import/[jobId]/cancel/route.js +18 -0
- package/src/app/api/oauth/kiro/bulk-import/[jobId]/manual/[workerId]/route.js +29 -0
- package/src/app/api/oauth/kiro/bulk-import/[jobId]/route.js +22 -0
- package/src/app/api/oauth/kiro/bulk-import/latest/route.js +25 -0
- package/src/app/api/oauth/kiro/bulk-import/route.js +49 -0
- package/src/app/api/oauth/kiro/import/route.js +110 -0
- package/src/app/api/oauth/kiro/social-authorize/route.js +27 -0
- package/src/app/api/oauth/kiro/social-exchange/route.js +41 -0
- package/src/app/api/pricing/route.js +134 -0
- package/src/app/api/provider-nodes/[id]/route.js +101 -0
- package/src/app/api/provider-nodes/route.js +104 -0
- package/src/app/api/provider-nodes/validate/route.js +201 -0
- package/src/app/api/providers/[id]/models/route.js +526 -0
- package/src/app/api/providers/[id]/route.js +189 -0
- package/src/app/api/providers/[id]/test/route.js +23 -0
- package/src/app/api/providers/[id]/test/testUtils.js +714 -0
- package/src/app/api/providers/[id]/test-models/route.js +66 -0
- package/src/app/api/providers/client/route.js +126 -0
- package/src/app/api/providers/kilo/free-models/route.js +55 -0
- package/src/app/api/providers/route.js +206 -0
- package/src/app/api/providers/suggested-models/filters.js +20 -0
- package/src/app/api/providers/suggested-models/route.js +32 -0
- package/src/app/api/providers/test-batch/route.js +131 -0
- package/src/app/api/providers/validate/route.js +637 -0
- package/src/app/api/proxy-pools/[id]/route.js +123 -0
- package/src/app/api/proxy-pools/[id]/test/route.js +70 -0
- package/src/app/api/proxy-pools/cloudflare-deploy/route.js +145 -0
- package/src/app/api/proxy-pools/deno-deploy/route.js +175 -0
- package/src/app/api/proxy-pools/route.js +93 -0
- package/src/app/api/proxy-pools/vercel-deploy/route.js +142 -0
- package/src/app/api/settings/database/route.js +36 -0
- package/src/app/api/settings/proxy-test/route.js +23 -0
- package/src/app/api/settings/require-login/route.js +15 -0
- package/src/app/api/settings/route.js +100 -0
- package/src/app/api/shutdown/route.js +24 -0
- package/src/app/api/tags/route.js +18 -0
- package/src/app/api/translator/console-logs/route.js +24 -0
- package/src/app/api/translator/console-logs/stream/route.js +79 -0
- package/src/app/api/translator/load/route.js +45 -0
- package/src/app/api/translator/save/route.js +44 -0
- package/src/app/api/translator/send/route.js +94 -0
- package/src/app/api/translator/translate/route.js +90 -0
- package/src/app/api/tunnel/disable/route.js +12 -0
- package/src/app/api/tunnel/enable/route.js +16 -0
- package/src/app/api/tunnel/status/route.js +13 -0
- package/src/app/api/tunnel/tailscale-check/route.js +50 -0
- package/src/app/api/tunnel/tailscale-disable/route.js +12 -0
- package/src/app/api/tunnel/tailscale-enable/route.js +12 -0
- package/src/app/api/tunnel/tailscale-install/route.js +72 -0
- package/src/app/api/usage/[connectionId]/route.js +188 -0
- package/src/app/api/usage/chart/route.js +21 -0
- package/src/app/api/usage/history/route.js +12 -0
- package/src/app/api/usage/logs/route.js +12 -0
- package/src/app/api/usage/providers/route.js +42 -0
- package/src/app/api/usage/request-details/route.js +57 -0
- package/src/app/api/usage/request-logs/route.js +13 -0
- package/src/app/api/usage/stats/route.js +23 -0
- package/src/app/api/usage/stream/route.js +79 -0
- package/src/app/api/v1/api/chat/route.js +37 -0
- package/src/app/api/v1/audio/speech/route.js +16 -0
- package/src/app/api/v1/audio/transcriptions/route.js +19 -0
- package/src/app/api/v1/audio/voices/route.js +68 -0
- package/src/app/api/v1/chat/completions/route.js +35 -0
- package/src/app/api/v1/embeddings/route.js +21 -0
- package/src/app/api/v1/images/generations/route.js +16 -0
- package/src/app/api/v1/messages/count_tokens/route.js +52 -0
- package/src/app/api/v1/messages/route.js +36 -0
- package/src/app/api/v1/models/[kind]/route.js +55 -0
- package/src/app/api/v1/models/info/route.js +110 -0
- package/src/app/api/v1/models/route.js +451 -0
- package/src/app/api/v1/responses/compact/route.js +37 -0
- package/src/app/api/v1/responses/route.js +30 -0
- package/src/app/api/v1/route.js +1 -0
- package/src/app/api/v1/search/route.js +21 -0
- package/src/app/api/v1/web/fetch/route.js +21 -0
- package/src/app/api/v1beta/models/[...path]/route.js +328 -0
- package/src/app/api/v1beta/models/route.js +44 -0
- package/src/app/api/version/route.js +45 -0
- package/src/app/api/version/shutdown/route.js +15 -0
- package/src/app/api/version/update/route.js +21 -0
- package/src/app/callback/page.js +148 -0
- package/src/app/dashboard/settings/pricing/page.js +173 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +496 -0
- package/src/app/landing/components/AnimatedBackground.js +57 -0
- package/src/app/landing/components/Features.js +133 -0
- package/src/app/landing/components/FlowAnimation.js +175 -0
- package/src/app/landing/components/Footer.js +61 -0
- package/src/app/landing/components/GetStarted.js +97 -0
- package/src/app/landing/components/HeroSection.js +47 -0
- package/src/app/landing/components/HowItWorks.js +66 -0
- package/src/app/landing/components/Navigation.js +72 -0
- package/src/app/landing/page.js +106 -0
- package/src/app/layout.js +49 -0
- package/src/app/login/page.js +197 -0
- package/src/app/manifest.js +30 -0
- package/src/app/page.js +5 -0
- package/src/dashboardGuard.js +242 -0
- package/src/i18n/RuntimeI18nProvider.js +27 -0
- package/src/i18n/config.js +146 -0
- package/src/i18n/runtime.js +162 -0
- package/src/lib/appUpdater.js +200 -0
- package/src/lib/auth/dashboardSession.js +68 -0
- package/src/lib/auth/loginLimiter.js +52 -0
- package/src/lib/auth/oidc.js +234 -0
- package/src/lib/consoleLogBuffer.js +79 -0
- package/src/lib/dataDir.js +29 -0
- package/src/lib/db/adapters/betterSqliteAdapter.js +55 -0
- package/src/lib/db/adapters/bunSqliteAdapter.js +63 -0
- package/src/lib/db/adapters/nodeSqliteAdapter.js +84 -0
- package/src/lib/db/adapters/sqljsAdapter.js +115 -0
- package/src/lib/db/backup.js +35 -0
- package/src/lib/db/driver.js +85 -0
- package/src/lib/db/helpers/jsonCol.js +9 -0
- package/src/lib/db/helpers/kvStore.js +39 -0
- package/src/lib/db/helpers/metaStore.js +22 -0
- package/src/lib/db/index.js +171 -0
- package/src/lib/db/migrate.js +286 -0
- package/src/lib/db/migrations/001-initial.js +14 -0
- package/src/lib/db/migrations/index.js +10 -0
- package/src/lib/db/paths.js +18 -0
- package/src/lib/db/repos/aliasRepo.js +62 -0
- package/src/lib/db/repos/apiKeysRepo.js +75 -0
- package/src/lib/db/repos/combosRepo.js +73 -0
- package/src/lib/db/repos/connectionsRepo.js +226 -0
- package/src/lib/db/repos/disabledModelsRepo.js +56 -0
- package/src/lib/db/repos/nodesRepo.js +95 -0
- package/src/lib/db/repos/pricingRepo.js +108 -0
- package/src/lib/db/repos/proxyPoolsRepo.js +103 -0
- package/src/lib/db/repos/requestDetailsRepo.js +259 -0
- package/src/lib/db/repos/settingsRepo.js +104 -0
- package/src/lib/db/repos/usageRepo.js +731 -0
- package/src/lib/db/schema.js +157 -0
- package/src/lib/db/version.js +21 -0
- package/src/lib/disabledModelsDb.js +4 -0
- package/src/lib/localDb.js +21 -0
- package/src/lib/mcp/stdioSseBridge.js +198 -0
- package/src/lib/mitmAliasCache.js +46 -0
- package/src/lib/network/connectionProxy.js +160 -0
- package/src/lib/network/initOutboundProxy.js +25 -0
- package/src/lib/network/outboundProxy.js +68 -0
- package/src/lib/network/proxyTest.js +91 -0
- package/src/lib/oauth/constants/oauth.js +284 -0
- package/src/lib/oauth/constants/xai.js +61 -0
- package/src/lib/oauth/providers.js +1506 -0
- package/src/lib/oauth/services/antigravity.js +321 -0
- package/src/lib/oauth/services/claude.js +136 -0
- package/src/lib/oauth/services/codebuddyBulkImportManager.js +454 -0
- package/src/lib/oauth/services/codex.js +144 -0
- package/src/lib/oauth/services/cursor.js +179 -0
- package/src/lib/oauth/services/gemini.js +240 -0
- package/src/lib/oauth/services/github.js +225 -0
- package/src/lib/oauth/services/iflow.js +202 -0
- package/src/lib/oauth/services/index.js +17 -0
- package/src/lib/oauth/services/kiro.js +334 -0
- package/src/lib/oauth/services/kiroBulkImportManager.js +778 -0
- package/src/lib/oauth/services/kiroConnections.js +93 -0
- package/src/lib/oauth/services/kiroGoogleAutomation.js +1136 -0
- package/src/lib/oauth/services/oauth.js +157 -0
- package/src/lib/oauth/services/openai.js +123 -0
- package/src/lib/oauth/services/qoder.js +216 -0
- package/src/lib/oauth/services/qwen.js +170 -0
- package/src/lib/oauth/services/xai.js +238 -0
- package/src/lib/oauth/utils/banner.js +63 -0
- package/src/lib/oauth/utils/pkce.js +39 -0
- package/src/lib/oauth/utils/server.js +415 -0
- package/src/lib/oauth/utils/ui.js +48 -0
- package/src/lib/providerNormalization.js +45 -0
- package/src/lib/qoder/constants.js +64 -0
- package/src/lib/qoder/cosy.js +175 -0
- package/src/lib/qoder/encoding.js +55 -0
- package/src/lib/requestDetailsDb.js +4 -0
- package/src/lib/tunnel/cloudflare/cloudflared.js +449 -0
- package/src/lib/tunnel/cloudflare/config.js +9 -0
- package/src/lib/tunnel/cloudflare/healthCheck.js +29 -0
- package/src/lib/tunnel/cloudflare/manager.js +151 -0
- package/src/lib/tunnel/cloudflare/pid.js +23 -0
- package/src/lib/tunnel/index.js +48 -0
- package/src/lib/tunnel/shared/dnsResolver.js +17 -0
- package/src/lib/tunnel/shared/internetCheck.js +26 -0
- package/src/lib/tunnel/shared/state.js +41 -0
- package/src/lib/tunnel/shared/watchdogConfig.js +8 -0
- package/src/lib/tunnel/tailscale/config.js +7 -0
- package/src/lib/tunnel/tailscale/healthCheck.js +29 -0
- package/src/lib/tunnel/tailscale/manager.js +129 -0
- package/src/lib/tunnel/tailscale/tailscale.js +790 -0
- package/src/lib/updater/updater.js +235 -0
- package/src/lib/usage/fetcher.js +208 -0
- package/src/lib/usageDb.js +7 -0
- package/src/mitm/antigravityIdeVersion.js +50 -0
- package/src/mitm/cert/generate.js +32 -0
- package/src/mitm/cert/install.js +269 -0
- package/src/mitm/cert/rootCA.js +173 -0
- package/src/mitm/config.js +87 -0
- package/src/mitm/dbReader.js +22 -0
- package/src/mitm/dns/dnsConfig.js +266 -0
- package/src/mitm/handlers/antigravity.js +33 -0
- package/src/mitm/handlers/base.js +226 -0
- package/src/mitm/handlers/copilot.js +35 -0
- package/src/mitm/handlers/cursor.js +15 -0
- package/src/mitm/handlers/kiro.js +526 -0
- package/src/mitm/logger.js +106 -0
- package/src/mitm/manager.js +851 -0
- package/src/mitm/paths.js +32 -0
- package/src/mitm/server.js +435 -0
- package/src/mitm/winElevated.js +81 -0
- package/src/models/index.js +38 -0
- package/src/proxy.js +5 -0
- package/src/shared/components/AddCustomEmbeddingModal.js +183 -0
- package/src/shared/components/Avatar.js +88 -0
- package/src/shared/components/Badge.js +54 -0
- package/src/shared/components/BulkAccountAutomationModal.js +508 -0
- package/src/shared/components/Button.js +56 -0
- package/src/shared/components/Card.js +116 -0
- package/src/shared/components/ChangelogModal.js +97 -0
- package/src/shared/components/CodeBuddyQuotaCookieModal.js +109 -0
- package/src/shared/components/ComboFormModal.js +176 -0
- package/src/shared/components/CursorAuthModal.js +212 -0
- package/src/shared/components/DonateModal.js +136 -0
- package/src/shared/components/Drawer.js +82 -0
- package/src/shared/components/EditConnectionModal.js +286 -0
- package/src/shared/components/Footer.js +132 -0
- package/src/shared/components/GitLabAuthModal.js +194 -0
- package/src/shared/components/Header.js +380 -0
- package/src/shared/components/HeaderLanguage.js +46 -0
- package/src/shared/components/HeaderMenu.js +126 -0
- package/src/shared/components/IFlowCookieModal.js +132 -0
- package/src/shared/components/Input.js +65 -0
- package/src/shared/components/KiroAuthModal.js +1171 -0
- package/src/shared/components/KiroOAuthWrapper.js +149 -0
- package/src/shared/components/KiroSocialOAuthModal.js +205 -0
- package/src/shared/components/LanguageSwitcher.js +190 -0
- package/src/shared/components/Loading.js +75 -0
- package/src/shared/components/ManualConfigModal.js +44 -0
- package/src/shared/components/McpMarketplaceModal.js +255 -0
- package/src/shared/components/Modal.js +146 -0
- package/src/shared/components/ModelSelectModal.js +537 -0
- package/src/shared/components/NineRemoteButton.js +23 -0
- package/src/shared/components/NineRemotePromoModal.js +99 -0
- package/src/shared/components/NoAuthProxyCard.js +86 -0
- package/src/shared/components/OAuthModal.js +682 -0
- package/src/shared/components/Pagination.js +150 -0
- package/src/shared/components/PricingModal.js +208 -0
- package/src/shared/components/ProviderIcon.js +63 -0
- package/src/shared/components/ProviderInfoCard.js +82 -0
- package/src/shared/components/RequestLogger.js +121 -0
- package/src/shared/components/SegmentedControl.js +48 -0
- package/src/shared/components/Select.js +67 -0
- package/src/shared/components/Sidebar.js +441 -0
- package/src/shared/components/ThemeProvider.js +15 -0
- package/src/shared/components/ThemeToggle.js +42 -0
- package/src/shared/components/Toggle.js +69 -0
- package/src/shared/components/Tooltip.js +25 -0
- package/src/shared/components/UsageStats.js +505 -0
- package/src/shared/components/index.js +46 -0
- package/src/shared/components/layouts/AuthLayout.js +29 -0
- package/src/shared/components/layouts/DashboardLayout.js +104 -0
- package/src/shared/components/layouts/index.js +4 -0
- package/src/shared/constants/cliTools.js +397 -0
- package/src/shared/constants/colors.js +77 -0
- package/src/shared/constants/config.js +99 -0
- package/src/shared/constants/coworkPlugins.js +75 -0
- package/src/shared/constants/index.js +4 -0
- package/src/shared/constants/locales.js +36 -0
- package/src/shared/constants/mitmToolHosts.js +12 -0
- package/src/shared/constants/models.js +38 -0
- package/src/shared/constants/pricing.js +303 -0
- package/src/shared/constants/providers.js +289 -0
- package/src/shared/constants/skills.js +78 -0
- package/src/shared/constants/ttsProviders.js +138 -0
- package/src/shared/hooks/index.js +2 -0
- package/src/shared/hooks/useCopyToClipboard.js +43 -0
- package/src/shared/hooks/useTheme.js +60 -0
- package/src/shared/services/bootstrap.js +12 -0
- package/src/shared/services/initializeApp.js +268 -0
- package/src/shared/utils/api.js +93 -0
- package/src/shared/utils/apiKey.js +98 -0
- package/src/shared/utils/clineAuth.js +37 -0
- package/src/shared/utils/cn.js +11 -0
- package/src/shared/utils/connectionStatus.js +162 -0
- package/src/shared/utils/index.js +40 -0
- package/src/shared/utils/machine.js +6 -0
- package/src/shared/utils/machineId.js +66 -0
- package/src/shared/utils/providerModelsFetcher.js +30 -0
- package/src/sse/handlers/chat.js +261 -0
- package/src/sse/handlers/embeddings.js +141 -0
- package/src/sse/handlers/fetch.js +213 -0
- package/src/sse/handlers/imageGeneration.js +142 -0
- package/src/sse/handlers/search.js +206 -0
- package/src/sse/handlers/stt.js +88 -0
- package/src/sse/handlers/tts.js +114 -0
- package/src/sse/services/auth.js +346 -0
- package/src/sse/services/codexGateway.js +215 -0
- package/src/sse/services/model.js +99 -0
- package/src/sse/services/tokenRefresh.js +319 -0
- package/src/sse/utils/logger.js +75 -0
- package/src/store/headerSearchStore.js +19 -0
- package/src/store/index.js +6 -0
- package/src/store/notificationStore.js +45 -0
- package/src/store/providerStore.js +55 -0
- package/src/store/settingsStore.js +51 -0
- package/src/store/themeStore.js +54 -0
- package/src/store/userStore.js +20 -0
- package/start.sh +4 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Patch global fetch with proxy support (must be first)
|
|
2
|
+
import "./utils/proxyFetch.js";
|
|
3
|
+
|
|
4
|
+
// Config
|
|
5
|
+
export { PROVIDERS } from "./config/providers.js";
|
|
6
|
+
export { OAUTH_ENDPOINTS, CLAUDE_SYSTEM_PROMPT } from "./config/appConstants.js";
|
|
7
|
+
export { CACHE_TTL, DEFAULT_MAX_TOKENS, COOLDOWN_MS, BACKOFF_CONFIG } from "./config/runtimeConfig.js";
|
|
8
|
+
export {
|
|
9
|
+
PROVIDER_MODELS,
|
|
10
|
+
getProviderModels,
|
|
11
|
+
getDefaultModel,
|
|
12
|
+
isValidModel,
|
|
13
|
+
findModelName,
|
|
14
|
+
getModelTargetFormat,
|
|
15
|
+
PROVIDER_ID_TO_ALIAS,
|
|
16
|
+
getModelsByProviderId
|
|
17
|
+
} from "./config/providerModels.js";
|
|
18
|
+
|
|
19
|
+
// Translator
|
|
20
|
+
export { FORMATS } from "./translator/formats.js";
|
|
21
|
+
export {
|
|
22
|
+
register,
|
|
23
|
+
translateRequest,
|
|
24
|
+
translateResponse,
|
|
25
|
+
needsTranslation,
|
|
26
|
+
initState,
|
|
27
|
+
initTranslators
|
|
28
|
+
} from "./translator/index.js";
|
|
29
|
+
|
|
30
|
+
// Services
|
|
31
|
+
export {
|
|
32
|
+
detectFormat,
|
|
33
|
+
getProviderConfig,
|
|
34
|
+
buildProviderUrl,
|
|
35
|
+
buildProviderHeaders,
|
|
36
|
+
getTargetFormat
|
|
37
|
+
} from "./services/provider.js";
|
|
38
|
+
|
|
39
|
+
export { parseModel, resolveModelAliasFromMap, getModelInfoCore } from "./services/model.js";
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
checkFallbackError,
|
|
43
|
+
isAccountUnavailable,
|
|
44
|
+
getUnavailableUntil,
|
|
45
|
+
filterAvailableAccounts
|
|
46
|
+
} from "./services/accountFallback.js";
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
TOKEN_EXPIRY_BUFFER_MS,
|
|
50
|
+
refreshAccessToken,
|
|
51
|
+
refreshClaudeOAuthToken,
|
|
52
|
+
refreshGoogleToken,
|
|
53
|
+
refreshQwenToken,
|
|
54
|
+
refreshCodexToken,
|
|
55
|
+
refreshIflowToken,
|
|
56
|
+
refreshGitHubToken,
|
|
57
|
+
refreshCopilotToken,
|
|
58
|
+
getAccessToken,
|
|
59
|
+
refreshTokenByProvider
|
|
60
|
+
} from "./services/tokenRefresh.js";
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
CODEX_MAX_REFRESH_AGE_MS,
|
|
64
|
+
shouldRefreshCredentials,
|
|
65
|
+
refreshProviderCredentials,
|
|
66
|
+
mergeRefreshedCredentials,
|
|
67
|
+
mergeProviderSpecificData,
|
|
68
|
+
} from "./services/oauthCredentialManager.js";
|
|
69
|
+
|
|
70
|
+
// Handlers
|
|
71
|
+
export { handleChatCore, isTokenExpiringSoon } from "./handlers/chatCore.js";
|
|
72
|
+
export { createStreamController, pipeWithDisconnect, createDisconnectAwareStream } from "./utils/streamHandler.js";
|
|
73
|
+
|
|
74
|
+
// Executors
|
|
75
|
+
export { getExecutor, hasSpecializedExecutor } from "./executors/index.js";
|
|
76
|
+
|
|
77
|
+
// Utils
|
|
78
|
+
export { errorResponse, formatProviderError } from "./utils/error.js";
|
|
79
|
+
export {
|
|
80
|
+
createSSETransformStreamWithLogger,
|
|
81
|
+
createPassthroughStreamWithLogger
|
|
82
|
+
} from "./utils/stream.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Port of apply_filter (rtk/src/cmds/system/pipe_cmd.rs) — catch_unwind equivalent
|
|
2
|
+
// On panic/error: passthrough raw output + warn to stderr
|
|
3
|
+
export function safeApply(fn, text) {
|
|
4
|
+
if (typeof fn !== "function") return text;
|
|
5
|
+
try {
|
|
6
|
+
const out = fn(text);
|
|
7
|
+
if (typeof out !== "string") return text;
|
|
8
|
+
return out;
|
|
9
|
+
} catch (err) {
|
|
10
|
+
// Rust: eprintln!("[rtk] warning: filter panicked — passing through raw output")
|
|
11
|
+
const name = fn.filterName || fn.name || "anonymous";
|
|
12
|
+
console.warn(`[rtk] warning: filter '${name}' panicked — passing through raw output: ${err?.message || err}`);
|
|
13
|
+
return text;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Port of auto_detect_filter (rtk/src/cmds/system/pipe_cmd.rs:132-188) + JS extras
|
|
2
|
+
// Order: git-diff → git-status → build-output → grep → find → tree → ls → search-list
|
|
3
|
+
// → read-numbered → dedup-log → smart-truncate → null
|
|
4
|
+
import { DETECT_WINDOW, READ_NUMBERED_MIN_HIT_RATIO, SMART_TRUNCATE_MIN_LINES } from "./constants.js";
|
|
5
|
+
import { gitDiff } from "./filters/gitDiff.js";
|
|
6
|
+
import { gitStatus } from "./filters/gitStatus.js";
|
|
7
|
+
import { buildOutput } from "./filters/buildOutput.js";
|
|
8
|
+
import { grep } from "./filters/grep.js";
|
|
9
|
+
import { find } from "./filters/find.js";
|
|
10
|
+
import { dedupLog } from "./filters/dedupLog.js";
|
|
11
|
+
import { ls } from "./filters/ls.js";
|
|
12
|
+
import { tree } from "./filters/tree.js";
|
|
13
|
+
import { smartTruncate } from "./filters/smartTruncate.js";
|
|
14
|
+
import { readNumbered, READ_NUMBERED_LINE_RE } from "./filters/readNumbered.js";
|
|
15
|
+
import { searchList, SEARCH_LIST_HEADER_RE } from "./filters/searchList.js";
|
|
16
|
+
|
|
17
|
+
const RE_GIT_DIFF = /^diff --git /m;
|
|
18
|
+
const RE_GIT_DIFF_HUNK = /^@@ /m;
|
|
19
|
+
const RE_GIT_STATUS = /^On branch |^nothing to commit|^Changes (not |to be )|^Untracked files:/m;
|
|
20
|
+
const RE_PORCELAIN = /^[ MADRCU?!][ MADRCU?!] \S/m;
|
|
21
|
+
const RE_BUILD_OUTPUT = /^(npm (warn|error|ERR!)|yarn (warn|error)|\s*Compiling\s+\S+|\s*Downloading\s+\S+|added \d+ package|\[ERROR\]|BUILD (SUCCESS|FAILED)|\s*Finished\s+|Successfully (installed|built)|ERROR:)/im;
|
|
22
|
+
const RE_TREE_GLYPH = /[├└]──|│ /;
|
|
23
|
+
const RE_LS_ROW = /^[-dlbcps][rwx-]{9}/m;
|
|
24
|
+
const RE_LS_TOTAL = /^total \d+$/m;
|
|
25
|
+
|
|
26
|
+
export function autoDetectFilter(text) {
|
|
27
|
+
// Rust: floor_char_boundary to avoid UTF-8 split — JS .slice() by char is safe
|
|
28
|
+
const head = text.length > DETECT_WINDOW ? text.slice(0, DETECT_WINDOW) : text;
|
|
29
|
+
|
|
30
|
+
if (RE_GIT_DIFF.test(head) || RE_GIT_DIFF_HUNK.test(head)) return gitDiff;
|
|
31
|
+
if (RE_GIT_STATUS.test(head)) return gitStatus;
|
|
32
|
+
|
|
33
|
+
// Build output BEFORE porcelain check: prevents cargo "Compiling" misdetection as git-status
|
|
34
|
+
if (RE_BUILD_OUTPUT.test(head)) return buildOutput;
|
|
35
|
+
|
|
36
|
+
if (isMostlyPorcelain(head)) return gitStatus;
|
|
37
|
+
|
|
38
|
+
const lines = head.split("\n");
|
|
39
|
+
const nonEmpty = lines.filter(l => l.trim().length > 0);
|
|
40
|
+
|
|
41
|
+
// Rust grep rule: first 5 non-empty lines, ANY matches "file:number:content"
|
|
42
|
+
const first5 = nonEmpty.slice(0, 5);
|
|
43
|
+
if (first5.some(isGrepLine)) return grep;
|
|
44
|
+
|
|
45
|
+
// Rust find rule: ALL non-empty lines path-like (no ':'), >=3 lines
|
|
46
|
+
if (nonEmpty.length >= 3 && nonEmpty.every(isPathLike)) return find;
|
|
47
|
+
|
|
48
|
+
// Tree: contains box-drawing glyphs typical of `tree` command
|
|
49
|
+
if (RE_TREE_GLYPH.test(head)) return tree;
|
|
50
|
+
|
|
51
|
+
// ls -la: has "total N" header or >=3 rows starting with perms string
|
|
52
|
+
if (RE_LS_TOTAL.test(head) || countMatches(head, RE_LS_ROW) >= 3) return ls;
|
|
53
|
+
|
|
54
|
+
// Cursor Glob search list header
|
|
55
|
+
if (SEARCH_LIST_HEADER_RE.test(head)) return searchList;
|
|
56
|
+
|
|
57
|
+
// Line-numbered file dump (" N|content") — fire only if many lines match
|
|
58
|
+
if (lines.length >= SMART_TRUNCATE_MIN_LINES && isLineNumbered(lines)) {
|
|
59
|
+
return readNumbered;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Fallback: dedupLog for generic multi-line noise with duplicates
|
|
63
|
+
if (nonEmpty.length >= 5) return dedupLog;
|
|
64
|
+
|
|
65
|
+
// Last resort: big blob with no structure — smart truncate
|
|
66
|
+
if (text.split("\n").length >= SMART_TRUNCATE_MIN_LINES) return smartTruncate;
|
|
67
|
+
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function isGrepLine(line) {
|
|
72
|
+
// Rust: splitn(3, ':') → parts.len()==3 && parts[1].parse::<usize>().is_ok()
|
|
73
|
+
const first = line.indexOf(":");
|
|
74
|
+
if (first === -1) return false;
|
|
75
|
+
const second = line.indexOf(":", first + 1);
|
|
76
|
+
if (second === -1) return false;
|
|
77
|
+
const lineno = line.slice(first + 1, second);
|
|
78
|
+
return /^\d+$/.test(lineno);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function isPathLike(line) {
|
|
82
|
+
const t = line.trim();
|
|
83
|
+
if (t.length === 0) return false;
|
|
84
|
+
if (t.includes(":")) return false;
|
|
85
|
+
return t.startsWith(".") || t.startsWith("/") || t.includes("/");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function isMostlyPorcelain(head) {
|
|
89
|
+
const lines = head.split("\n").filter(l => l.trim());
|
|
90
|
+
if (lines.length < 3) return false;
|
|
91
|
+
const hits = lines.filter(l => RE_PORCELAIN.test(l)).length;
|
|
92
|
+
return hits / lines.length >= 0.6;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function isLineNumbered(lines) {
|
|
96
|
+
let hits = 0;
|
|
97
|
+
let nonEmpty = 0;
|
|
98
|
+
const sample = lines.slice(0, 100);
|
|
99
|
+
for (const l of sample) {
|
|
100
|
+
if (l.length === 0) continue;
|
|
101
|
+
nonEmpty++;
|
|
102
|
+
if (READ_NUMBERED_LINE_RE.test(l)) hits++;
|
|
103
|
+
}
|
|
104
|
+
if (nonEmpty < 5) return false;
|
|
105
|
+
return hits / nonEmpty >= READ_NUMBERED_MIN_HIT_RATIO;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function countMatches(text, re) {
|
|
109
|
+
const g = new RegExp(re.source, re.flags.includes("g") ? re.flags : re.flags + "g");
|
|
110
|
+
return (text.match(g) || []).length;
|
|
111
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Caveman injector: appends a caveman-style instruction into the system message
|
|
2
|
+
// of the final request body, just before it is dispatched to the provider executor.
|
|
3
|
+
// Dispatches by format so it works for both translated and native-passthrough flows.
|
|
4
|
+
|
|
5
|
+
import { FORMATS } from "../translator/formats.js";
|
|
6
|
+
import { CAVEMAN_PROMPTS } from "./cavemanPrompts.js";
|
|
7
|
+
|
|
8
|
+
const SEP = "\n\n";
|
|
9
|
+
|
|
10
|
+
export function injectCaveman(body, format, level) {
|
|
11
|
+
const prompt = CAVEMAN_PROMPTS[level];
|
|
12
|
+
if (!body || !prompt) return;
|
|
13
|
+
|
|
14
|
+
switch (format) {
|
|
15
|
+
case FORMATS.CLAUDE:
|
|
16
|
+
injectClaudeSystem(body, prompt);
|
|
17
|
+
return;
|
|
18
|
+
case FORMATS.GEMINI:
|
|
19
|
+
case FORMATS.GEMINI_CLI:
|
|
20
|
+
case FORMATS.VERTEX:
|
|
21
|
+
case FORMATS.ANTIGRAVITY:
|
|
22
|
+
// Antigravity wraps Gemini shape in body.request → injectGeminiSystem handles it
|
|
23
|
+
injectGeminiSystem(body, prompt);
|
|
24
|
+
return;
|
|
25
|
+
default:
|
|
26
|
+
// OpenAI and OpenAI-shaped formats (responses/codex/cursor/kiro/ollama)
|
|
27
|
+
injectMessagesSystem(body, prompt);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// OpenAI-shaped: messages[] (chat) or input[] (responses) or instructions (responses string)
|
|
32
|
+
function injectMessagesSystem(body, prompt) {
|
|
33
|
+
// OpenAI Responses API: top-level string field
|
|
34
|
+
if (typeof body.instructions === "string") {
|
|
35
|
+
body.instructions = body.instructions
|
|
36
|
+
? `${body.instructions}${SEP}${prompt}`
|
|
37
|
+
: prompt;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const arr = Array.isArray(body.messages) ? body.messages
|
|
42
|
+
: Array.isArray(body.input) ? body.input
|
|
43
|
+
: null;
|
|
44
|
+
if (!arr) return;
|
|
45
|
+
|
|
46
|
+
const idx = arr.findIndex(m => m && (m.role === "system" || m.role === "developer"));
|
|
47
|
+
if (idx >= 0) {
|
|
48
|
+
appendToOpenAIMessage(arr[idx], prompt);
|
|
49
|
+
} else {
|
|
50
|
+
arr.unshift({ role: "system", content: prompt });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function appendToOpenAIMessage(msg, prompt) {
|
|
55
|
+
if (typeof msg.content === "string") {
|
|
56
|
+
msg.content = `${msg.content}${SEP}${prompt}`;
|
|
57
|
+
} else if (Array.isArray(msg.content)) {
|
|
58
|
+
// Responses-style array of parts {type:"input_text"|"text", text}
|
|
59
|
+
msg.content.push({ type: "input_text", text: prompt });
|
|
60
|
+
} else {
|
|
61
|
+
msg.content = prompt;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Claude shape: body.system as string | array of {type:"text", text}
|
|
66
|
+
// Insert before the last cache_control block to keep caveman inside the cached prefix.
|
|
67
|
+
function injectClaudeSystem(body, prompt) {
|
|
68
|
+
if (typeof body.system === "string" && body.system.length > 0) {
|
|
69
|
+
body.system = `${body.system}${SEP}${prompt}`;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (Array.isArray(body.system)) {
|
|
73
|
+
const block = { type: "text", text: prompt };
|
|
74
|
+
let lastCacheIdx = -1;
|
|
75
|
+
for (let i = body.system.length - 1; i >= 0; i--) {
|
|
76
|
+
if (body.system[i]?.cache_control) { lastCacheIdx = i; break; }
|
|
77
|
+
}
|
|
78
|
+
if (lastCacheIdx >= 0) {
|
|
79
|
+
body.system.splice(lastCacheIdx, 0, block);
|
|
80
|
+
} else {
|
|
81
|
+
body.system.push(block);
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
body.system = prompt;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Gemini shape: body.system_instruction | body.systemInstruction | body.request.systemInstruction
|
|
89
|
+
// Each shape: { parts: [{ text }] }
|
|
90
|
+
function injectGeminiSystem(body, prompt) {
|
|
91
|
+
const target = body.request && typeof body.request === "object" ? body.request : body;
|
|
92
|
+
const useSnake = Object.prototype.hasOwnProperty.call(target, "system_instruction");
|
|
93
|
+
const key = useSnake ? "system_instruction" : "systemInstruction";
|
|
94
|
+
const sys = target[key];
|
|
95
|
+
if (sys && Array.isArray(sys.parts)) {
|
|
96
|
+
sys.parts.push({ text: prompt });
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
target[key] = { parts: [{ text: prompt }] };
|
|
100
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Caveman intensity-level prompts injected into system message to reduce output tokens.
|
|
2
|
+
// Adapted from caveman skill (https://github.com/JuliusBrussee/caveman).
|
|
3
|
+
|
|
4
|
+
export const CAVEMAN_LEVELS = {
|
|
5
|
+
LITE: "lite",
|
|
6
|
+
FULL: "full",
|
|
7
|
+
ULTRA: "ultra",
|
|
8
|
+
WENYAN_LITE: "wenyan-lite",
|
|
9
|
+
WENYAN: "wenyan",
|
|
10
|
+
WENYAN_ULTRA: "wenyan-ultra",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const SHARED_BOUNDARIES = "Code blocks, file paths, commands, errors, URLs: keep exact. Security warnings, irreversible action confirmations, multi-step ordered sequences: write normal. Resume terse style after.";
|
|
14
|
+
|
|
15
|
+
const SHARED_EXAMPLES = "Not: \"Sure! I'd be happy to help you with that. The issue you're experiencing is likely caused by...\" Yes: \"Bug in auth middleware. Token expiry check use `<` not `<=`. Fix:\"";
|
|
16
|
+
|
|
17
|
+
const SHARED_AUTO_CLARITY = "Auto-Clarity: drop caveman for security warnings, irreversible actions, multi-step sequences where fragment ambiguity risks misread, or when user repeats a question. Resume after the clear part.";
|
|
18
|
+
|
|
19
|
+
const SHARED_PERSISTENCE = "ACTIVE EVERY RESPONSE. No revert after many turns. No filler drift. Still active if unsure.";
|
|
20
|
+
|
|
21
|
+
export const CAVEMAN_PROMPTS = {
|
|
22
|
+
[CAVEMAN_LEVELS.LITE]: [
|
|
23
|
+
"Respond tersely. Keep grammar and full sentences but drop filler, hedging and pleasantries (just/really/basically/sure/of course/I'd be happy to).",
|
|
24
|
+
"Pattern: state the thing, the action, the reason. Then next step.",
|
|
25
|
+
SHARED_EXAMPLES,
|
|
26
|
+
SHARED_BOUNDARIES,
|
|
27
|
+
SHARED_AUTO_CLARITY,
|
|
28
|
+
SHARED_PERSISTENCE,
|
|
29
|
+
].join(" "),
|
|
30
|
+
|
|
31
|
+
[CAVEMAN_LEVELS.FULL]: [
|
|
32
|
+
"Respond like terse caveman. All technical substance stay exact, only fluff die.",
|
|
33
|
+
"Drop: articles (a/an/the), filler (just/really/basically/actually/simply), pleasantries, hedging. Fragments OK. Short synonyms (big not extensive, fix not implement a solution for).",
|
|
34
|
+
"Pattern: [thing] [action] [reason]. [next step].",
|
|
35
|
+
SHARED_EXAMPLES,
|
|
36
|
+
SHARED_BOUNDARIES,
|
|
37
|
+
SHARED_AUTO_CLARITY,
|
|
38
|
+
SHARED_PERSISTENCE,
|
|
39
|
+
].join(" "),
|
|
40
|
+
|
|
41
|
+
[CAVEMAN_LEVELS.ULTRA]: [
|
|
42
|
+
"Respond ultra-terse. Maximum compression. Telegraphic.",
|
|
43
|
+
"Abbreviate (DB/auth/config/req/res/fn/impl), strip conjunctions, use arrows for causality (X → Y). One word when one word enough.",
|
|
44
|
+
"Pattern: [thing] → [result]. [fix].",
|
|
45
|
+
SHARED_EXAMPLES,
|
|
46
|
+
SHARED_BOUNDARIES,
|
|
47
|
+
SHARED_AUTO_CLARITY,
|
|
48
|
+
SHARED_PERSISTENCE,
|
|
49
|
+
].join(" "),
|
|
50
|
+
|
|
51
|
+
[CAVEMAN_LEVELS.WENYAN_LITE]: [
|
|
52
|
+
"Respond semi-classical. Drop filler/hedging but keep grammar structure, classical register.",
|
|
53
|
+
"Use classical Chinese sentence patterns where natural. Keep English for technical terms.",
|
|
54
|
+
SHARED_EXAMPLES,
|
|
55
|
+
SHARED_BOUNDARIES,
|
|
56
|
+
SHARED_AUTO_CLARITY,
|
|
57
|
+
SHARED_PERSISTENCE,
|
|
58
|
+
].join(" "),
|
|
59
|
+
|
|
60
|
+
[CAVEMAN_LEVELS.WENYAN]: [
|
|
61
|
+
"Respond classical Chinese (文言文). Maximum classical terseness. 80-90% character reduction.",
|
|
62
|
+
"Classical sentence patterns, verbs precede objects, subjects often omitted, classical particles (之/乃/為/其).",
|
|
63
|
+
"Keep English for code, commands, function names, API names, error strings.",
|
|
64
|
+
SHARED_EXAMPLES,
|
|
65
|
+
SHARED_BOUNDARIES,
|
|
66
|
+
SHARED_AUTO_CLARITY,
|
|
67
|
+
SHARED_PERSISTENCE,
|
|
68
|
+
].join(" "),
|
|
69
|
+
|
|
70
|
+
[CAVEMAN_LEVELS.WENYAN_ULTRA]: [
|
|
71
|
+
"Respond extreme classical compression (文言文 ultra). Maximum compression, ultra terse.",
|
|
72
|
+
"Same classical rules as wenyan-full but even more compressed. One classical particle per clause.",
|
|
73
|
+
SHARED_EXAMPLES,
|
|
74
|
+
SHARED_BOUNDARIES,
|
|
75
|
+
SHARED_AUTO_CLARITY,
|
|
76
|
+
SHARED_PERSISTENCE,
|
|
77
|
+
].join(" "),
|
|
78
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// RTK port constants (mirror Rust defaults)
|
|
2
|
+
export const RAW_CAP = 10 * 1024 * 1024; // 10 MiB
|
|
3
|
+
export const MIN_COMPRESS_SIZE = 500; // bytes; skip tiny blobs
|
|
4
|
+
export const DETECT_WINDOW = 1024; // autodetect peeks first N chars
|
|
5
|
+
export const GIT_DIFF_HUNK_MAX_LINES = 100; // per-hunk line cap
|
|
6
|
+
export const GIT_DIFF_CONTEXT_KEEP = 3; // context lines around changes
|
|
7
|
+
export const DEDUP_LINE_MAX = 2000; // dedupLog truncation cap
|
|
8
|
+
|
|
9
|
+
// Rust pipe_cmd.rs parity caps
|
|
10
|
+
export const GREP_PER_FILE_MAX = 10; // match rust: matches.iter().take(10)
|
|
11
|
+
export const FIND_PER_DIR_MAX = 10; // match rust: files.iter().take(10)
|
|
12
|
+
export const FIND_TOTAL_DIR_MAX = 20; // match rust: dirs.iter().take(20)
|
|
13
|
+
|
|
14
|
+
// git status caps (rust config::limits())
|
|
15
|
+
export const STATUS_MAX_FILES = 10; // config::limits().status_max_files
|
|
16
|
+
export const STATUS_MAX_UNTRACKED = 10; // config::limits().status_max_untracked
|
|
17
|
+
|
|
18
|
+
// ls compact_ls (rtk/src/cmds/system/ls.rs)
|
|
19
|
+
export const LS_EXT_SUMMARY_TOP = 5; // top-N extensions in summary
|
|
20
|
+
export const LS_NOISE_DIRS = [
|
|
21
|
+
"node_modules", ".git", "target", "__pycache__",
|
|
22
|
+
".next", "dist", "build", ".venv", "venv",
|
|
23
|
+
".cache", ".idea", ".vscode", ".DS_Store"
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
// tree filter_tree_output cap (no rust cap, we add one to be safe)
|
|
27
|
+
export const TREE_MAX_LINES = 200;
|
|
28
|
+
|
|
29
|
+
// Cursor Glob "Result of search in '...' (total N files):" list
|
|
30
|
+
export const SEARCH_LIST_PER_DIR_MAX = 10;
|
|
31
|
+
export const SEARCH_LIST_TOTAL_DIR_MAX = 20;
|
|
32
|
+
|
|
33
|
+
// Smart truncate (port of filter.rs smart_truncate fallback)
|
|
34
|
+
export const SMART_TRUNCATE_HEAD = 120; // lines kept from top
|
|
35
|
+
export const SMART_TRUNCATE_TAIL = 60; // lines kept from bottom
|
|
36
|
+
export const SMART_TRUNCATE_MIN_LINES = 250; // only kick in above this
|
|
37
|
+
|
|
38
|
+
// readNumbered (files with " N|content" lines, e.g. Cursor read_file)
|
|
39
|
+
export const READ_NUMBERED_MIN_HIT_RATIO = 0.7;
|
|
40
|
+
|
|
41
|
+
// Filter name strings (Rust parity + JS extras)
|
|
42
|
+
export const FILTERS = {
|
|
43
|
+
GIT_DIFF: "git-diff",
|
|
44
|
+
GIT_STATUS: "git-status",
|
|
45
|
+
GIT_LOG: "git-log",
|
|
46
|
+
GREP: "grep",
|
|
47
|
+
FIND: "find",
|
|
48
|
+
LS: "ls",
|
|
49
|
+
TREE: "tree",
|
|
50
|
+
DEDUP_LOG: "dedup-log",
|
|
51
|
+
SMART_TRUNCATE: "smart-truncate",
|
|
52
|
+
READ_NUMBERED: "read-numbered",
|
|
53
|
+
SEARCH_LIST: "search-list",
|
|
54
|
+
BUILD_OUTPUT: "build-output"
|
|
55
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Compress build tool output (npm, cargo, pip, maven, gradle, etc.)
|
|
2
|
+
// Keeps: errors, warnings, final summary
|
|
3
|
+
// Strips: progress logs, verbose "Compiling X" lists, download logs
|
|
4
|
+
|
|
5
|
+
// Cargo/rustc error continuation: " --> file:line", " |", "N | code", " = note: ..."
|
|
6
|
+
const RE_CARGO_ERR_CONT = /^\s*(-->|\||\d+\s*\||=)/;
|
|
7
|
+
const DEPRECATION_KEEP = 3;
|
|
8
|
+
|
|
9
|
+
export function buildOutput(input) {
|
|
10
|
+
const lines = input.split("\n");
|
|
11
|
+
if (lines.length === 0) return input;
|
|
12
|
+
|
|
13
|
+
const errors = [];
|
|
14
|
+
const warnings = [];
|
|
15
|
+
const deprecations = [];
|
|
16
|
+
let summary = null;
|
|
17
|
+
let compilingCount = 0;
|
|
18
|
+
let downloadingCount = 0;
|
|
19
|
+
let inCargoError = false;
|
|
20
|
+
|
|
21
|
+
for (const line of lines) {
|
|
22
|
+
const trimmed = line.trim();
|
|
23
|
+
|
|
24
|
+
// Continuation of cargo error block: keep verbatim while in block
|
|
25
|
+
if (inCargoError) {
|
|
26
|
+
if (!trimmed) { inCargoError = false; continue; }
|
|
27
|
+
if (RE_CARGO_ERR_CONT.test(line)) { errors.push(line); continue; }
|
|
28
|
+
inCargoError = false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!trimmed) continue;
|
|
32
|
+
|
|
33
|
+
if (/^npm (ERR!|error)/i.test(trimmed) || /^yarn error/i.test(trimmed)) {
|
|
34
|
+
errors.push(line);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (/^npm warn deprecated/i.test(trimmed)) {
|
|
39
|
+
deprecations.push(line);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (/^npm warn/i.test(trimmed) || /^yarn warn/i.test(trimmed)) {
|
|
43
|
+
warnings.push(line);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (/^error(\[|:)/i.test(trimmed) || trimmed.startsWith("error -->")) {
|
|
48
|
+
errors.push(line);
|
|
49
|
+
inCargoError = true;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (/^warning(\[|:)/i.test(trimmed) || trimmed.startsWith("warning -->")) {
|
|
54
|
+
warnings.push(line);
|
|
55
|
+
inCargoError = true;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (/^ERROR:/i.test(trimmed)) {
|
|
60
|
+
errors.push(line);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (/^\[ERROR\]/i.test(trimmed) || /^BUILD FAILED/i.test(trimmed)) {
|
|
65
|
+
errors.push(line);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (/^\[WARNING\]/i.test(trimmed)) {
|
|
70
|
+
warnings.push(line);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (/^\s*Compiling\s+\S+/i.test(trimmed)) {
|
|
75
|
+
compilingCount++;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (/^\s*Downloading\s+\S+/i.test(trimmed) || /^Fetching\s+/i.test(trimmed)) {
|
|
79
|
+
downloadingCount++;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (
|
|
84
|
+
/^(added|removed|changed|audited|installed)\s+\d+\s+package/i.test(trimmed) ||
|
|
85
|
+
/^\s*Finished\s+/i.test(trimmed) ||
|
|
86
|
+
/^BUILD SUCCESS/i.test(trimmed) ||
|
|
87
|
+
/^\d+\s+(vulnerabilities|packages?|warnings?|errors?)/i.test(trimmed) ||
|
|
88
|
+
/^Successfully (installed|built)/i.test(trimmed) ||
|
|
89
|
+
/^To address .* issues/i.test(trimmed) ||
|
|
90
|
+
/^Run `npm (audit|fund)`/i.test(trimmed) ||
|
|
91
|
+
/packages are looking for funding/i.test(trimmed)
|
|
92
|
+
) {
|
|
93
|
+
summary = summary ? `${summary}\n${line}` : line;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let out = "";
|
|
99
|
+
|
|
100
|
+
// Keep first N deprecations verbatim (package name + reason), count the rest
|
|
101
|
+
const keepDep = deprecations.slice(0, DEPRECATION_KEEP);
|
|
102
|
+
for (const d of keepDep) out += `${d}\n`;
|
|
103
|
+
if (deprecations.length > DEPRECATION_KEEP) {
|
|
104
|
+
out += `... +${deprecations.length - DEPRECATION_KEEP} more deprecated packages\n`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (compilingCount > 0) {
|
|
108
|
+
out += `Compiled ${compilingCount} packages\n`;
|
|
109
|
+
}
|
|
110
|
+
if (downloadingCount > 0) {
|
|
111
|
+
out += `Downloaded ${downloadingCount} packages\n`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
for (const e of errors) out += `${e}\n`;
|
|
115
|
+
|
|
116
|
+
const keepWarnings = warnings.slice(0, 5);
|
|
117
|
+
for (const w of keepWarnings) out += `${w}\n`;
|
|
118
|
+
if (warnings.length > 5) {
|
|
119
|
+
out += `... +${warnings.length - 5} more warnings\n`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (summary) out += `${summary}\n`;
|
|
123
|
+
|
|
124
|
+
return out.replace(/\n+$/, "") || input;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
buildOutput.filterName = "build-output";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Generic fallback: collapse consecutive duplicate lines + blank-line dedupe + hard line cap
|
|
2
|
+
import { DEDUP_LINE_MAX } from "../constants.js";
|
|
3
|
+
|
|
4
|
+
export function dedupLog(input) {
|
|
5
|
+
const lines = input.split("\n");
|
|
6
|
+
const out = [];
|
|
7
|
+
let prev = null;
|
|
8
|
+
let runCount = 0;
|
|
9
|
+
let blankStreak = 0;
|
|
10
|
+
|
|
11
|
+
const flushRun = () => {
|
|
12
|
+
if (prev !== null && runCount > 1) {
|
|
13
|
+
out.push(` ... (${runCount - 1} duplicate lines)`);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
for (const line of lines) {
|
|
18
|
+
if (line.trim() === "") {
|
|
19
|
+
if (blankStreak < 1) out.push(line);
|
|
20
|
+
blankStreak += 1;
|
|
21
|
+
flushRun();
|
|
22
|
+
prev = null;
|
|
23
|
+
runCount = 0;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
blankStreak = 0;
|
|
27
|
+
if (line === prev) {
|
|
28
|
+
runCount += 1;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
flushRun();
|
|
32
|
+
out.push(line);
|
|
33
|
+
prev = line;
|
|
34
|
+
runCount = 1;
|
|
35
|
+
if (out.length >= DEDUP_LINE_MAX) {
|
|
36
|
+
out.push(`... (truncated at ${DEDUP_LINE_MAX} lines)`);
|
|
37
|
+
return out.join("\n");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
flushRun();
|
|
41
|
+
return out.join("\n");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
dedupLog.filterName = "dedup-log";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Port of find_wrapper (rtk/src/cmds/system/pipe_cmd.rs:89-128)
|
|
2
|
+
// Group by parent dir, show basenames, cap 10/dir and 20 dirs total
|
|
3
|
+
import { FIND_PER_DIR_MAX, FIND_TOTAL_DIR_MAX } from "../constants.js";
|
|
4
|
+
|
|
5
|
+
export function find(input) {
|
|
6
|
+
const lines = input.split("\n").filter(l => l.trim());
|
|
7
|
+
if (lines.length === 0) return input;
|
|
8
|
+
|
|
9
|
+
const byDir = new Map();
|
|
10
|
+
|
|
11
|
+
for (const path of lines) {
|
|
12
|
+
const lastSlash = path.lastIndexOf("/");
|
|
13
|
+
let dir;
|
|
14
|
+
let basename;
|
|
15
|
+
if (lastSlash === -1) {
|
|
16
|
+
dir = ".";
|
|
17
|
+
basename = path;
|
|
18
|
+
} else {
|
|
19
|
+
// Rust: PathBuf::from(path).parent().display() + file_name().display()
|
|
20
|
+
dir = path.slice(0, lastSlash) || "/";
|
|
21
|
+
basename = path.slice(lastSlash + 1);
|
|
22
|
+
}
|
|
23
|
+
if (!byDir.has(dir)) byDir.set(dir, []);
|
|
24
|
+
byDir.get(dir).push(basename);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Rust: dirs.sort_by_key(|(d, _)| d.clone())
|
|
28
|
+
const dirs = Array.from(byDir.keys()).sort();
|
|
29
|
+
let out = `${lines.length} files in ${dirs.length} dirs:\n\n`;
|
|
30
|
+
|
|
31
|
+
const showDirs = dirs.slice(0, FIND_TOTAL_DIR_MAX);
|
|
32
|
+
for (const dir of showDirs) {
|
|
33
|
+
const files = byDir.get(dir);
|
|
34
|
+
out += `${dir}/ (${files.length}):\n`;
|
|
35
|
+
const showFiles = files.slice(0, FIND_PER_DIR_MAX);
|
|
36
|
+
for (const f of showFiles) out += ` ${f}\n`;
|
|
37
|
+
if (files.length > FIND_PER_DIR_MAX) {
|
|
38
|
+
out += ` +${files.length - FIND_PER_DIR_MAX}\n`;
|
|
39
|
+
}
|
|
40
|
+
out += "\n";
|
|
41
|
+
}
|
|
42
|
+
if (dirs.length > FIND_TOTAL_DIR_MAX) {
|
|
43
|
+
out += `+${dirs.length - FIND_TOTAL_DIR_MAX} more dirs\n`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
find.filterName = "find";
|