swayrouter 1.0.0
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/.env.example +43 -0
- package/CHANGELOG.md +132 -0
- package/LICENSE +30 -0
- package/README.id.md +633 -0
- package/README.md +628 -0
- package/cli/cli.js +388 -0
- package/cli/package.json +4 -0
- package/cli/src/cli/commands/xaiVideo.js +280 -0
- package/cli/src/cli/tray/SwayAvatar.svg +20 -0
- package/cli/src/cli/tray/autostart.js +351 -0
- package/cli/src/cli/tray/icon.ico +0 -0
- package/cli/src/cli/tray/icon.png +0 -0
- package/cli/src/cli/tray/tray.js +258 -0
- package/cli/src/cli/tray/tray.ps1 +129 -0
- package/cli/src/cli/tray/trayHost.js +157 -0
- package/cli/src/cli/tray/trayWin.js +83 -0
- package/cli/src/cli/utils/display.js +123 -0
- package/cli/src/cli/utils/input.js +138 -0
- package/cli/src/runtime/discover.js +153 -0
- package/cli/src/runtime/lifecycle.js +333 -0
- package/cli/src/runtime/runMenu.js +250 -0
- package/cli/src/runtime/uiAdapters.js +12 -0
- package/cli/src/runtime/update.js +130 -0
- package/dashboard/dist/assets/CliTools-Ch3gKuNw.js +24 -0
- package/dashboard/dist/assets/Combo-BBCldjWi.js +1 -0
- package/dashboard/dist/assets/ConsoleLog-wywAYcPT.js +6 -0
- package/dashboard/dist/assets/Dashboard-DxzyF41b.js +1 -0
- package/dashboard/dist/assets/Header-C_9Su9BF.js +1 -0
- package/dashboard/dist/assets/Keys-D0ufgcsc.js +1 -0
- package/dashboard/dist/assets/Login-BeKpipS_.js +1 -0
- package/dashboard/dist/assets/ManageApiKey-CVXsmW2B.js +1 -0
- package/dashboard/dist/assets/OAuthCallback-D_UZYcF6.js +1 -0
- package/dashboard/dist/assets/Provider-BU7JfTqm.js +4 -0
- package/dashboard/dist/assets/ProviderModelAccordion-BAifkfVR.js +1 -0
- package/dashboard/dist/assets/Proxy-CU15VJ--.js +1 -0
- package/dashboard/dist/assets/QuotaMonitor-HzGK7bcc.js +1 -0
- package/dashboard/dist/assets/Settings-Dt4y2dC0.js +1 -0
- package/dashboard/dist/assets/Setup-DSDUwU7N.js +1 -0
- package/dashboard/dist/assets/StatusBadge-1nAOyHU2.js +1 -0
- package/dashboard/dist/assets/SwayChat-Bup7up6D.js +10 -0
- package/dashboard/dist/assets/Usage-eWnrPQ_v.js +4 -0
- package/dashboard/dist/assets/accordion-DOOPDDgt.js +1 -0
- package/dashboard/dist/assets/admin-extras-api-CCdu5TFM.js +1 -0
- package/dashboard/dist/assets/api-keys-api-ifAC2Ok3.js +1 -0
- package/dashboard/dist/assets/card-CC0Omjcv.js +1 -0
- package/dashboard/dist/assets/chatStudio-C0zPz_Z_.js +2 -0
- package/dashboard/dist/assets/checkbox-7SZBrmbN.js +1 -0
- package/dashboard/dist/assets/connections-api-_N54UD3S.js +1 -0
- package/dashboard/dist/assets/copy-button-qBvM6H9z.js +1 -0
- package/dashboard/dist/assets/currency-api-SV9CBf5e.js +1 -0
- package/dashboard/dist/assets/flip-button-BGgkjtl0.js +1 -0
- package/dashboard/dist/assets/frame-cUiti6Lq.js +1 -0
- package/dashboard/dist/assets/icons-vendor-CUx7SB5V.js +541 -0
- package/dashboard/dist/assets/index-B6j-9zHy.js +10 -0
- package/dashboard/dist/assets/index-C-_l0yYz.css +1 -0
- package/dashboard/dist/assets/live-mode-CHShLY4E.js +1 -0
- package/dashboard/dist/assets/markdown-vendor-BY8e1gQ8.js +29 -0
- package/dashboard/dist/assets/motion-vendor-g5fpGzmJ.js +9 -0
- package/dashboard/dist/assets/oauth-callback-CqYQzyd7.js +1 -0
- package/dashboard/dist/assets/query-vendor-DVevaSVS.js +1 -0
- package/dashboard/dist/assets/react-vendor-xnYrwzsL.js +61 -0
- package/dashboard/dist/assets/ripple-button-l8aMiVVG.js +1 -0
- package/dashboard/dist/assets/segmented-CqmEnQjZ.js +1 -0
- package/dashboard/dist/assets/select-D8pUtMXp.js +1 -0
- package/dashboard/dist/assets/skeleton-7uJDiIXe.js +1 -0
- package/dashboard/dist/assets/table-D0M60Tu1.js +1 -0
- package/dashboard/dist/assets/tabs-C6YkuulG.js +1 -0
- package/dashboard/dist/assets/tunnel-api-DDPsBaDV.js +1 -0
- package/dashboard/dist/assets/ui-vendor-BuM9f2NY.js +17 -0
- package/dashboard/dist/image2/SwayAvatar.svg +20 -0
- package/dashboard/dist/index.html +32 -0
- package/dashboard/dist/logo/avatar.svg +1 -0
- package/dashboard/dist/logo/sway.svg +20 -0
- package/dashboard/dist/logo/swaychat.svg +20 -0
- package/dashboard/dist/providers/SwayCustom.svg +19 -0
- package/dashboard/dist/providers/alicode.svg +12 -0
- package/dashboard/dist/providers/anthropic.svg +11 -0
- package/dashboard/dist/providers/antigravity.svg +3 -0
- package/dashboard/dist/providers/azure.svg +5 -0
- package/dashboard/dist/providers/baidu.svg +3 -0
- package/dashboard/dist/providers/blackbox.svg +5 -0
- package/dashboard/dist/providers/byteplus.svg +3 -0
- package/dashboard/dist/providers/cerebras.svg +4 -0
- package/dashboard/dist/providers/chutes.svg +4 -0
- package/dashboard/dist/providers/claude.svg +3 -0
- package/dashboard/dist/providers/cline.svg +11 -0
- package/dashboard/dist/providers/cloudflare-ai.svg +4 -0
- package/dashboard/dist/providers/codebuddy.svg +11 -0
- package/dashboard/dist/providers/codex.svg +10 -0
- package/dashboard/dist/providers/commandcode.svg +3 -0
- package/dashboard/dist/providers/cursor.svg +3 -0
- package/dashboard/dist/providers/deepseek.svg +10 -0
- package/dashboard/dist/providers/featherless.svg +3 -0
- package/dashboard/dist/providers/fireworks.svg +3 -0
- package/dashboard/dist/providers/gemini.svg +3 -0
- package/dashboard/dist/providers/geminicli.svg +11 -0
- package/dashboard/dist/providers/github.svg +3 -0
- package/dashboard/dist/providers/grok.svg +3 -0
- package/dashboard/dist/providers/groq.svg +3 -0
- package/dashboard/dist/providers/hermesagent.svg +1 -0
- package/dashboard/dist/providers/kilocode.svg +15 -0
- package/dashboard/dist/providers/kimchi.svg +3 -0
- package/dashboard/dist/providers/kimi.svg +4 -0
- package/dashboard/dist/providers/kiro.svg +10 -0
- package/dashboard/dist/providers/meta.svg +3 -0
- package/dashboard/dist/providers/mimo.svg +10 -0
- package/dashboard/dist/providers/minimax.svg +3 -0
- package/dashboard/dist/providers/mistral.svg +3 -0
- package/dashboard/dist/providers/morph.svg +3 -0
- package/dashboard/dist/providers/nebius.svg +4 -0
- package/dashboard/dist/providers/nvidia.svg +3 -0
- package/dashboard/dist/providers/ollama.svg +3 -0
- package/dashboard/dist/providers/omp.svg +5 -0
- package/dashboard/dist/providers/openai.svg +3 -0
- package/dashboard/dist/providers/opencode.svg +3 -0
- package/dashboard/dist/providers/openrouter.svg +3 -0
- package/dashboard/dist/providers/perplexity.svg +3 -0
- package/dashboard/dist/providers/poolside.svg +36 -0
- package/dashboard/dist/providers/qoder.svg +11 -0
- package/dashboard/dist/providers/sumopod.svg +3 -0
- package/dashboard/dist/providers/tencent.svg +5 -0
- package/dashboard/dist/providers/together.svg +12 -0
- package/dashboard/dist/providers/trae.svg +3 -0
- package/dashboard/dist/providers/venice.svg +4 -0
- package/dashboard/dist/providers/vercel.svg +3 -0
- package/dashboard/dist/providers/vertex.svg +17 -0
- package/dashboard/dist/providers/windsurf.svg +10 -0
- package/dashboard/dist/providers/zai.svg +3 -0
- package/dashboard/tsconfig.json +13 -0
- package/package.json +87 -0
- package/src/config/appConstants.js +153 -0
- package/src/config/defaultThinkingSignature.js +7 -0
- package/src/config/errorConfig.js +117 -0
- package/src/config/grokCli.js +9 -0
- package/src/config/kiroConstants.js +235 -0
- package/src/config/mediaConfig.js +20 -0
- package/src/config/ollamaModels.js +18 -0
- package/src/config/providerModels.js +109 -0
- package/src/config/providers.js +17 -0
- package/src/config/runtimeConfig.js +84 -0
- package/src/dashboardGuard.js +254 -0
- package/src/executors/antigravity.js +389 -0
- package/src/executors/azure.js +49 -0
- package/src/executors/base.js +225 -0
- package/src/executors/codebuddy-cn.js +23 -0
- package/src/executors/codebuddy-intl.js +60 -0
- package/src/executors/codex.js +436 -0
- package/src/executors/commandcode.js +83 -0
- package/src/executors/cursor.js +1075 -0
- package/src/executors/default.js +294 -0
- package/src/executors/gemini-cli.js +88 -0
- package/src/executors/github.js +393 -0
- package/src/executors/grok-cli.js +510 -0
- package/src/executors/grok-web.js +342 -0
- package/src/executors/index.js +86 -0
- package/src/executors/kimchi.js +116 -0
- package/src/executors/kiro.js +1155 -0
- package/src/executors/ollama-local.js +14 -0
- package/src/executors/opencode-go.js +47 -0
- package/src/executors/opencode.js +31 -0
- package/src/executors/qoder.js +433 -0
- package/src/executors/trae.js +318 -0
- package/src/executors/vertex.js +151 -0
- package/src/executors/windsurf.js +555 -0
- package/src/executors/xiaomi-tokenplan.js +16 -0
- package/src/handlers/chatCore/nonStreamingHandler.js +370 -0
- package/src/handlers/chatCore/requestDetail.js +130 -0
- package/src/handlers/chatCore/sseToJsonHandler.js +318 -0
- package/src/handlers/chatCore/streamingHandler.js +250 -0
- package/src/handlers/chatCore.js +652 -0
- package/src/lib/auth/dashboardSession.js +83 -0
- package/src/lib/auth/loginLimiter.js +99 -0
- package/src/lib/cache/ttlCache.js +153 -0
- package/src/lib/consoleLogBuffer.js +127 -0
- package/src/lib/dataDir.js +45 -0
- package/src/lib/db/adapters/betterSqliteAdapter.js +36 -0
- package/src/lib/db/adapters/bunSqliteAdapter.js +47 -0
- package/src/lib/db/adapters/nodeSqliteAdapter.js +65 -0
- package/src/lib/db/adapters/runtimeHelpers.js +23 -0
- package/src/lib/db/adapters/sqljsAdapter.js +103 -0
- package/src/lib/db/backup.js +75 -0
- package/src/lib/db/driver.js +110 -0
- package/src/lib/db/helpers/jsonCol.js +18 -0
- package/src/lib/db/helpers/kvStore.js +48 -0
- package/src/lib/db/helpers/metaStore.js +32 -0
- package/src/lib/db/index.js +473 -0
- package/src/lib/db/migrate.js +267 -0
- package/src/lib/db/migrations/001-initial.js +12 -0
- package/src/lib/db/migrations/002-prune-headroom-pxpipe-settings.js +32 -0
- package/src/lib/db/migrations/004-request-details-trace-id.js +12 -0
- package/src/lib/db/migrations/005-request-details-payload-capture.js +11 -0
- package/src/lib/db/migrations/007-headroom-readd-settings.js +35 -0
- package/src/lib/db/migrations/008-account-model-locks.js +22 -0
- package/src/lib/db/migrations/009-warp-pool-lifecycle.js +5 -0
- package/src/lib/db/migrations/010-api-key-file-permissions.js +7 -0
- package/src/lib/db/migrations/011-remove-upstream-user-agent-profile.js +41 -0
- package/src/lib/db/migrations/012-remove-headroom-settings.js +33 -0
- package/src/lib/db/migrations/013-default-fill-first-routing.js +20 -0
- package/src/lib/db/migrations/014-normalize-fill-first-routing.js +37 -0
- package/src/lib/db/migrations/015-remove-ip-ban-tables.js +8 -0
- package/src/lib/db/migrations/016-prune-legacy-codebuddy-intl-models.js +25 -0
- package/src/lib/db/migrations/index.js +20 -0
- package/src/lib/db/nineRouterMigration.js +785 -0
- package/src/lib/db/paths.js +23 -0
- package/src/lib/db/repos/accountModelLocksRepo.js +74 -0
- package/src/lib/db/repos/aliasRepo.js +108 -0
- package/src/lib/db/repos/apiKeysRepo.js +204 -0
- package/src/lib/db/repos/combosRepo.js +85 -0
- package/src/lib/db/repos/connectionsRepo.js +522 -0
- package/src/lib/db/repos/disabledModelsRepo.js +63 -0
- package/src/lib/db/repos/nodesRepo.js +127 -0
- package/src/lib/db/repos/pricingRepo.js +108 -0
- package/src/lib/db/repos/proxyPoolsRepo.js +104 -0
- package/src/lib/db/repos/requestDetailsRepo.js +345 -0
- package/src/lib/db/repos/settingsRepo.js +135 -0
- package/src/lib/db/repos/usageRepo.js +1335 -0
- package/src/lib/db/schema.js +179 -0
- package/src/lib/db/version.js +32 -0
- package/src/lib/db/writeBehind.js +174 -0
- package/src/lib/disabledModelsDb.js +3 -0
- package/src/lib/env.ts +175 -0
- package/src/lib/errors/publicError.js +18 -0
- package/src/lib/grokBuildConfig.js +243 -0
- package/src/lib/guardRequest.js +51 -0
- package/src/lib/localDb.js +21 -0
- package/src/lib/mcp/stdioSseBridge.js +174 -0
- package/src/lib/network/connectionProxy.js +200 -0
- package/src/lib/network/proxyTest.js +158 -0
- package/src/lib/network/proxyUrl.js +76 -0
- package/src/lib/network/relay.js +71 -0
- package/src/lib/oauth/constants/oauth.js +152 -0
- package/src/lib/oauth/constants/xai.js +43 -0
- package/src/lib/oauth/kiroExternalIdp.js +167 -0
- package/src/lib/oauth/providerHelpers.js +90 -0
- package/src/lib/oauth/providers/_shared.js +12 -0
- package/src/lib/oauth/providers/antigravity.js +126 -0
- package/src/lib/oauth/providers/claude.js +60 -0
- package/src/lib/oauth/providers/cline.js +62 -0
- package/src/lib/oauth/providers/clinepass.js +62 -0
- package/src/lib/oauth/providers/codebuddy-cn.js +75 -0
- package/src/lib/oauth/providers/codebuddy-intl.js +73 -0
- package/src/lib/oauth/providers/codex.js +72 -0
- package/src/lib/oauth/providers/cursor.js +18 -0
- package/src/lib/oauth/providers/gemini-cli.js +84 -0
- package/src/lib/oauth/providers/github.js +96 -0
- package/src/lib/oauth/providers/grok-cli.js +123 -0
- package/src/lib/oauth/providers/index.js +233 -0
- package/src/lib/oauth/providers/kilocode.js +60 -0
- package/src/lib/oauth/providers/kimchi.js +79 -0
- package/src/lib/oauth/providers/kimi.js +79 -0
- package/src/lib/oauth/providers/kiro.js +147 -0
- package/src/lib/oauth/providers/qoder.js +90 -0
- package/src/lib/oauth/providers/trae.js +244 -0
- package/src/lib/oauth/providers/windsurf.js +123 -0
- package/src/lib/oauth/providers/xai.js +95 -0
- package/src/lib/oauth/providers.js +16 -0
- package/src/lib/oauth/services/cursor.js +132 -0
- package/src/lib/oauth/services/kiro.js +351 -0
- package/src/lib/oauth/services/oauth.js +135 -0
- package/src/lib/oauth/services/qoder.js +151 -0
- package/src/lib/oauth/services/xai.js +204 -0
- package/src/lib/oauth/utils/ideDetect.js +55 -0
- package/src/lib/oauth/utils/pkce.js +25 -0
- package/src/lib/oauth/utils/server.js +732 -0
- package/src/lib/oauth/utils/ui.js +43 -0
- package/src/lib/providerNormalization.js +40 -0
- package/src/lib/qoder/constants.js +1 -0
- package/src/lib/requestDetailsDb.js +3 -0
- package/src/lib/resourceProfile.ts +124 -0
- package/src/lib/runtimeSecrets.ts +130 -0
- package/src/lib/security/payloadCapture.js +87 -0
- package/src/lib/tunnel/cloudflare/cloudflared.js +436 -0
- package/src/lib/tunnel/cloudflare/config.js +8 -0
- package/src/lib/tunnel/cloudflare/healthCheck.js +37 -0
- package/src/lib/tunnel/cloudflare/manager.js +149 -0
- package/src/lib/tunnel/cloudflare/pid.js +31 -0
- package/src/lib/tunnel/cloudflare/publicUrl.js +41 -0
- package/src/lib/tunnel/cloudflare/requirements.js +12 -0
- package/src/lib/tunnel/index.js +26 -0
- package/src/lib/tunnel/shared/dnsResolver.js +16 -0
- package/src/lib/tunnel/shared/internetCheck.js +30 -0
- package/src/lib/tunnel/shared/state.js +45 -0
- package/src/lib/tunnel/shared/watchdogConfig.js +6 -0
- package/src/lib/update/installer.js +52 -0
- package/src/lib/update/version.js +116 -0
- package/src/lib/usageDb.js +6 -0
- package/src/lib/usageRefresh.js +88 -0
- package/src/lifecycle/appLifecycle.ts +99 -0
- package/src/models.js +36 -0
- package/src/next/headers.js +12 -0
- package/src/next/server.js +74 -0
- package/src/observability/metrics.js +439 -0
- package/src/observability/tracing.js +107 -0
- package/src/open-sse-index.js +70 -0
- package/src/providers/capabilities.js +299 -0
- package/src/providers/display.ts +142 -0
- package/src/providers/index.js +27 -0
- package/src/providers/models/helpers.js +19 -0
- package/src/providers/models/namePatterns.js +27 -0
- package/src/providers/models/schema.js +32 -0
- package/src/providers/pricing.js +248 -0
- package/src/providers/registry/agentrouter.js +52 -0
- package/src/providers/registry/alicode-intl.js +32 -0
- package/src/providers/registry/alicode.js +33 -0
- package/src/providers/registry/alims-intl.js +30 -0
- package/src/providers/registry/anthropic.js +29 -0
- package/src/providers/registry/antigravity.js +139 -0
- package/src/providers/registry/azure.js +23 -0
- package/src/providers/registry/baidu.js +35 -0
- package/src/providers/registry/blackbox.js +41 -0
- package/src/providers/registry/byteplus.js +36 -0
- package/src/providers/registry/cerebras.js +33 -0
- package/src/providers/registry/chutes.js +26 -0
- package/src/providers/registry/claude.js +80 -0
- package/src/providers/registry/cline.js +53 -0
- package/src/providers/registry/clinepass.js +62 -0
- package/src/providers/registry/cloudflare-ai.js +84 -0
- package/src/providers/registry/codebuddy-cn.js +95 -0
- package/src/providers/registry/codebuddy-intl.js +91 -0
- package/src/providers/registry/codex.js +145 -0
- package/src/providers/registry/commandcode.js +45 -0
- package/src/providers/registry/cursor.js +61 -0
- package/src/providers/registry/deepseek.js +55 -0
- package/src/providers/registry/featherless.js +36 -0
- package/src/providers/registry/fireworks.js +34 -0
- package/src/providers/registry/gemini-cli.js +59 -0
- package/src/providers/registry/gemini.js +76 -0
- package/src/providers/registry/github.js +131 -0
- package/src/providers/registry/glm-cn.js +35 -0
- package/src/providers/registry/glm.js +58 -0
- package/src/providers/registry/grok-cli.js +87 -0
- package/src/providers/registry/grok-web.js +41 -0
- package/src/providers/registry/groq.js +38 -0
- package/src/providers/registry/index.js +77 -0
- package/src/providers/registry/kilo-gateway.js +34 -0
- package/src/providers/registry/kilocode.js +48 -0
- package/src/providers/registry/kimchi.js +49 -0
- package/src/providers/registry/kimi.js +82 -0
- package/src/providers/registry/kiro.js +132 -0
- package/src/providers/registry/meta.js +34 -0
- package/src/providers/registry/minimax-cn.js +90 -0
- package/src/providers/registry/minimax.js +90 -0
- package/src/providers/registry/mistral.js +36 -0
- package/src/providers/registry/morph.js +31 -0
- package/src/providers/registry/nebius.js +26 -0
- package/src/providers/registry/nvidia.js +55 -0
- package/src/providers/registry/ollama-local.js +18 -0
- package/src/providers/registry/ollama.js +38 -0
- package/src/providers/registry/openai.js +114 -0
- package/src/providers/registry/opencode-go.js +41 -0
- package/src/providers/registry/opencode.js +26 -0
- package/src/providers/registry/openrouter.js +36 -0
- package/src/providers/registry/perplexity.js +56 -0
- package/src/providers/registry/poolside.js +30 -0
- package/src/providers/registry/qoder.js +58 -0
- package/src/providers/registry/sumopod.js +84 -0
- package/src/providers/registry/tencent.js +29 -0
- package/src/providers/registry/together.js +38 -0
- package/src/providers/registry/trae.js +71 -0
- package/src/providers/registry/venice.js +69 -0
- package/src/providers/registry/vercel-ai-gateway.js +37 -0
- package/src/providers/registry/vertex-partner.js +31 -0
- package/src/providers/registry/vertex.js +33 -0
- package/src/providers/registry/windsurf.js +129 -0
- package/src/providers/registry/xai.js +46 -0
- package/src/providers/registry/xiaomi-mimo.js +66 -0
- package/src/providers/registry/xiaomi-tokenplan.js +58 -0
- package/src/providers/registryEntry.js +3 -0
- package/src/providers/schema.js +33 -0
- package/src/providers/shared.js +114 -0
- package/src/providers/thinkingLevels.js +49 -0
- package/src/routes/api/auth/login/route.js +82 -0
- package/src/routes/api/auth/logout/route.js +9 -0
- package/src/routes/api/auth/reset-password/route.js +12 -0
- package/src/routes/api/auth/status/route.js +33 -0
- package/src/routes/api/auth/verify-password/route.js +39 -0
- package/src/routes/api/chat/tools/curl/route.js +100 -0
- package/src/routes/api/chat/tools/router/route.js +215 -0
- package/src/routes/api/chat/tools/search/route.js +362 -0
- package/src/routes/api/chat/tools/shell/route.js +228 -0
- package/src/routes/api/cli-tools/all-statuses/route.js +37 -0
- package/src/routes/api/cli-tools/claude-settings/route.js +261 -0
- package/src/routes/api/cli-tools/codex-settings/route.js +220 -0
- package/src/routes/api/cli-tools/cowork-mcp-registry/route.js +80 -0
- package/src/routes/api/cli-tools/cowork-mcp-tools/route.js +96 -0
- package/src/routes/api/cli-tools/cowork-settings/route.js +380 -0
- package/src/routes/api/cli-tools/grok-build-settings/route.js +152 -0
- package/src/routes/api/cli-tools/hermes-settings/route.js +169 -0
- package/src/routes/api/cli-tools/kilo-settings/route.js +131 -0
- package/src/routes/api/cli-tools/model-mappings/route.js +43 -0
- package/src/routes/api/cli-tools/omp-settings/route.js +266 -0
- package/src/routes/api/cli-tools/opencode-settings/route.js +243 -0
- package/src/routes/api/combos/[id]/route.js +73 -0
- package/src/routes/api/combos/route.js +43 -0
- package/src/routes/api/health/live/route.js +7 -0
- package/src/routes/api/health/ready/route.js +19 -0
- package/src/routes/api/health/route.js +17 -0
- package/src/routes/api/inflight/stream/route.js +24 -0
- package/src/routes/api/init/route.js +3 -0
- package/src/routes/api/keys/[id]/route.js +71 -0
- package/src/routes/api/keys/route.js +41 -0
- package/src/routes/api/logs/route.js +19 -0
- package/src/routes/api/mcp/[plugin]/message/route.js +23 -0
- package/src/routes/api/mcp/[plugin]/sse/route.js +35 -0
- package/src/routes/api/models/availability/route.js +104 -0
- package/src/routes/api/models/custom/route.js +58 -0
- package/src/routes/api/models/disabled/route.js +47 -0
- package/src/routes/api/models/route.js +64 -0
- package/src/routes/api/models/test/ping.js +236 -0
- package/src/routes/api/models/test/route.js +14 -0
- package/src/routes/api/oauth/[provider]/[action]/route.js +491 -0
- package/src/routes/api/oauth/codex/bulk-import/route.js +105 -0
- package/src/routes/api/oauth/codex/import-token/route.js +82 -0
- package/src/routes/api/oauth/cursor/auto-import/route.js +250 -0
- package/src/routes/api/oauth/cursor/import/route.js +86 -0
- package/src/routes/api/oauth/kiro/api-key/route.js +60 -0
- package/src/routes/api/oauth/kiro/auto-import/route.js +120 -0
- package/src/routes/api/oauth/kiro/import/route.js +72 -0
- package/src/routes/api/oauth/kiro/import-cli-proxy/route.js +42 -0
- package/src/routes/api/oauth/kiro/social-authorize/route.js +40 -0
- package/src/routes/api/oauth/kiro/social-exchange/route.js +62 -0
- package/src/routes/api/pricing/route.js +96 -0
- package/src/routes/api/provider-nodes/[id]/route.js +106 -0
- package/src/routes/api/provider-nodes/route.js +110 -0
- package/src/routes/api/provider-nodes/validate/route.js +197 -0
- package/src/routes/api/providers/[id]/models/route.js +716 -0
- package/src/routes/api/providers/[id]/route.js +195 -0
- package/src/routes/api/providers/[id]/test/route.js +27 -0
- package/src/routes/api/providers/[id]/test/testUtils.js +912 -0
- package/src/routes/api/providers/[id]/test-models/route.js +211 -0
- package/src/routes/api/providers/catalog/route.js +58 -0
- package/src/routes/api/providers/client/route.js +133 -0
- package/src/routes/api/providers/counts/route.js +43 -0
- package/src/routes/api/providers/kilo/free-models/route.js +58 -0
- package/src/routes/api/providers/route.js +361 -0
- package/src/routes/api/providers/suggested-models/filters.js +24 -0
- package/src/routes/api/providers/suggested-models/route.js +34 -0
- package/src/routes/api/providers/test-batch/route.js +145 -0
- package/src/routes/api/providers/validate/route.js +633 -0
- package/src/routes/api/proxy-pools/[id]/route.js +129 -0
- package/src/routes/api/proxy-pools/[id]/test/route.js +64 -0
- package/src/routes/api/proxy-pools/cloudflare-deploy/route.js +183 -0
- package/src/routes/api/proxy-pools/route.js +85 -0
- package/src/routes/api/proxy-pools/vercel-deploy/route.js +181 -0
- package/src/routes/api/settings/currency/route.js +29 -0
- package/src/routes/api/settings/database/path/route.js +8 -0
- package/src/routes/api/settings/database/route.js +89 -0
- package/src/routes/api/settings/migrate-9router/route.js +81 -0
- package/src/routes/api/settings/require-login/route.js +14 -0
- package/src/routes/api/settings/route.js +186 -0
- package/src/routes/api/shutdown/route.js +25 -0
- package/src/routes/api/tags/route.js +17 -0
- package/src/routes/api/translator/console-logs/route.js +28 -0
- package/src/routes/api/translator/console-logs/stream/route.js +95 -0
- package/src/routes/api/tunnel/disable/route.js +18 -0
- package/src/routes/api/tunnel/enable/route.js +32 -0
- package/src/routes/api/tunnel/status/route.js +23 -0
- package/src/routes/api/update/route.js +42 -0
- package/src/routes/api/usage/[connectionId]/codex-reset-credits/route.js +169 -0
- package/src/routes/api/usage/[connectionId]/route.js +222 -0
- package/src/routes/api/usage/chart/route.js +27 -0
- package/src/routes/api/usage/history/route.js +94 -0
- package/src/routes/api/usage/logs/route.js +14 -0
- package/src/routes/api/usage/providers/route.js +36 -0
- package/src/routes/api/usage/request-details/route.js +61 -0
- package/src/routes/api/usage/request-logs/route.js +15 -0
- package/src/routes/api/usage/stats/route.js +23 -0
- package/src/routes/api/usage/stream/route.js +78 -0
- package/src/routes/api/v1/api/chat/route.js +36 -0
- package/src/routes/api/v1/chat/completions/route.js +28 -0
- package/src/routes/api/v1/images/edits/route.js +70 -0
- package/src/routes/api/v1/images/generations/route.js +50 -0
- package/src/routes/api/v1/images/imageValidation.js +45 -0
- package/src/routes/api/v1/messages/count_tokens/route.js +87 -0
- package/src/routes/api/v1/messages/route.js +26 -0
- package/src/routes/api/v1/models/route.js +440 -0
- package/src/routes/api/v1/responses/compact/route.js +34 -0
- package/src/routes/api/v1/responses/route.js +26 -0
- package/src/routes/api/v1/route.js +1 -0
- package/src/routes/api/version/route.js +11 -0
- package/src/routes/table.js +1141 -0
- package/src/rtk/applyFilter.js +13 -0
- package/src/rtk/autodetect.js +104 -0
- package/src/rtk/caveman.js +6 -0
- package/src/rtk/cavemanPrompts.js +107 -0
- package/src/rtk/constants.js +51 -0
- package/src/rtk/filters/buildOutput.js +120 -0
- package/src/rtk/filters/dedupLog.js +43 -0
- package/src/rtk/filters/find.js +47 -0
- package/src/rtk/filters/gitDiff.js +90 -0
- package/src/rtk/filters/gitLog.js +88 -0
- package/src/rtk/filters/gitStatus.js +101 -0
- package/src/rtk/filters/grep.js +45 -0
- package/src/rtk/filters/ls.js +73 -0
- package/src/rtk/filters/readNumbered.js +22 -0
- package/src/rtk/filters/searchList.js +49 -0
- package/src/rtk/filters/smartTruncate.js +13 -0
- package/src/rtk/filters/tree.js +28 -0
- package/src/rtk/index.js +143 -0
- package/src/rtk/ponytail.js +6 -0
- package/src/rtk/ponytailPrompt.js +49 -0
- package/src/rtk/systemInject.js +89 -0
- package/src/server.ts +474 -0
- package/src/services/accountFallback.js +241 -0
- package/src/services/accountPool.js +389 -0
- package/src/services/capacityAdapter.js +140 -0
- package/src/services/cliModelMapping.js +84 -0
- package/src/services/clinepassModels.js +60 -0
- package/src/services/codebuddyModels.js +250 -0
- package/src/services/combo.js +482 -0
- package/src/services/copilotModels.js +126 -0
- package/src/services/currencyRate.js +56 -0
- package/src/services/cursorModels.js +197 -0
- package/src/services/grokCliModels.js +130 -0
- package/src/services/kimchiModels.js +175 -0
- package/src/services/kiroModels.js +246 -0
- package/src/services/model.js +83 -0
- package/src/services/oauthCredentialManager.js +153 -0
- package/src/services/projectId.js +240 -0
- package/src/services/provider.js +145 -0
- package/src/services/qoderModels.js +274 -0
- package/src/services/tokenRefresh/dedup.js +70 -0
- package/src/services/tokenRefresh/providers.js +626 -0
- package/src/services/tokenRefresh.js +274 -0
- package/src/services/usage/claude.js +134 -0
- package/src/services/usage/codebuddy-cn.js +212 -0
- package/src/services/usage/codex.js +193 -0
- package/src/services/usage/deepseek.js +103 -0
- package/src/services/usage/github.js +94 -0
- package/src/services/usage/google.js +218 -0
- package/src/services/usage/grok-cli.js +368 -0
- package/src/services/usage/grokCliQuotaFrame.js +170 -0
- package/src/services/usage/kimi.js +185 -0
- package/src/services/usage/kiro.js +172 -0
- package/src/services/usage/minimax.js +215 -0
- package/src/services/usage/misc.js +264 -0
- package/src/services/usage/shared.js +59 -0
- package/src/services/usage.js +56 -0
- package/src/shared/clineAuth.js +37 -0
- package/src/shared/constants/config.js +80 -0
- package/src/shared/constants/coworkPlugins.js +69 -0
- package/src/shared/constants/models.js +41 -0
- package/src/shared/constants/providers.js +128 -0
- package/src/shared/constants/providersDisplay.js +1 -0
- package/src/shared/qoder/constants.js +50 -0
- package/src/shared/qoder/cosy.js +134 -0
- package/src/shared/qoder/encoding.js +36 -0
- package/src/shared/services/initializeApp.js +226 -0
- package/src/shared/services/quotaAutoPing.js +310 -0
- package/src/shared/utils/apiKey.js +65 -0
- package/src/shared/utils/clineAuth.js +1 -0
- package/src/shared/utils/index.js +3 -0
- package/src/shared/utils/machineId.js +60 -0
- package/src/shared/utils/ssrfGuard.js +280 -0
- package/src/sse/handlers/chat.js +426 -0
- package/src/sse/oauthLease.js +32 -0
- package/src/sse/recovery.js +235 -0
- package/src/sse/services/auth.js +489 -0
- package/src/sse/services/backgroundTokenRefresh.js +173 -0
- package/src/sse/services/model.js +129 -0
- package/src/sse/services/requestCancellation.js +4 -0
- package/src/sse/services/tokenRefresh.js +264 -0
- package/src/sse/utils/logger.js +142 -0
- package/src/staticServe.ts +95 -0
- package/src/transformer/streamToJsonConverter.js +87 -0
- package/src/translator/canonical.js +81 -0
- package/src/translator/concerns/chunk.js +9 -0
- package/src/translator/concerns/compatFallback.js +147 -0
- package/src/translator/concerns/finishReason.js +59 -0
- package/src/translator/concerns/image.js +105 -0
- package/src/translator/concerns/json.js +4 -0
- package/src/translator/concerns/kiroConversation.js +428 -0
- package/src/translator/concerns/message.js +5 -0
- package/src/translator/concerns/modality.js +134 -0
- package/src/translator/concerns/paramSupport.js +97 -0
- package/src/translator/concerns/prefetch.js +86 -0
- package/src/translator/concerns/reasoning.js +18 -0
- package/src/translator/concerns/thinking.js +40 -0
- package/src/translator/concerns/thinkingUnified.js +319 -0
- package/src/translator/concerns/toolCall.js +134 -0
- package/src/translator/concerns/usage.js +61 -0
- package/src/translator/detection.js +42 -0
- package/src/translator/formats/claude.js +323 -0
- package/src/translator/formats/gemini.js +366 -0
- package/src/translator/formats/maxTokens.js +19 -0
- package/src/translator/formats/openai.js +116 -0
- package/src/translator/formats/responsesApi.js +117 -0
- package/src/translator/formats.js +28 -0
- package/src/translator/index.js +237 -0
- package/src/translator/request/antigravity-to-openai.js +217 -0
- package/src/translator/request/claude-to-kiro.js +288 -0
- package/src/translator/request/claude-to-openai.js +199 -0
- package/src/translator/request/gemini-to-openai.js +142 -0
- package/src/translator/request/openai-responses.js +373 -0
- package/src/translator/request/openai-to-claude.js +260 -0
- package/src/translator/request/openai-to-commandcode.js +161 -0
- package/src/translator/request/openai-to-cursor.js +175 -0
- package/src/translator/request/openai-to-gemini.js +422 -0
- package/src/translator/request/openai-to-kiro.js +360 -0
- package/src/translator/request/openai-to-ollama.js +152 -0
- package/src/translator/request/openai-to-vertex.js +36 -0
- package/src/translator/response/claude-to-openai.js +185 -0
- package/src/translator/response/commandcode-to-openai.js +164 -0
- package/src/translator/response/cursor-to-openai.js +18 -0
- package/src/translator/response/gemini-to-openai.js +127 -0
- package/src/translator/response/kiro-to-claude.js +230 -0
- package/src/translator/response/kiro-to-openai.js +136 -0
- package/src/translator/response/ollama-to-openai.js +106 -0
- package/src/translator/response/openai-responses.js +534 -0
- package/src/translator/response/openai-to-antigravity.js +107 -0
- package/src/translator/response/openai-to-claude.js +231 -0
- package/src/translator/schema/blocks.js +40 -0
- package/src/translator/schema/defaults.js +3 -0
- package/src/translator/schema/finishReasons.js +22 -0
- package/src/translator/schema/index.js +7 -0
- package/src/translator/schema/roles.js +12 -0
- package/src/transport/requestBoundary.ts +223 -0
- package/src/transport/routerAdmission.ts +380 -0
- package/src/types/provider.ts +59 -0
- package/src/utils/bypassHandler.js +272 -0
- package/src/utils/claudeCloaking.js +10 -0
- package/src/utils/claudeSignature.js +35 -0
- package/src/utils/clientDetector.js +183 -0
- package/src/utils/cursorChecksum.js +104 -0
- package/src/utils/cursorProtobuf.js +801 -0
- package/src/utils/debugLog.js +12 -0
- package/src/utils/error.js +120 -0
- package/src/utils/inflight.js +127 -0
- package/src/utils/kiroSessionReplay.js +139 -0
- package/src/utils/ollamaTransform.js +83 -0
- package/src/utils/proxyFetch.js +308 -0
- package/src/utils/reasoningContentInjector.js +71 -0
- package/src/utils/requestLogger.js +272 -0
- package/src/utils/responsesStreamHelpers.js +46 -0
- package/src/utils/sessionManager.js +205 -0
- package/src/utils/sse.js +13 -0
- package/src/utils/sseConstants.js +21 -0
- package/src/utils/stream.js +511 -0
- package/src/utils/streamHandler.js +256 -0
- package/src/utils/streamHelpers.js +113 -0
- package/src/utils/toolDeduper.js +44 -0
- package/src/utils/usageTracking.js +329 -0
- package/tsconfig.json +45 -0
package/README.id.md
ADDED
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="./assets/BannerGithubSway.png" alt="Banner Sway Router" />
|
|
3
|
+
<h1 style="margin: 8px 0 0;">Sway Router</h1>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p align="center">
|
|
7
|
+
<strong>Satu gateway. Semua model.</strong><br />
|
|
8
|
+
Connect sekali, route ke mana saja.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="./README.md"><img src="https://img.shields.io/badge/English-README-2563EB?style=for-the-badge" alt="English README" /></a>
|
|
13
|
+
<a href="./README.id.md"><img src="https://img.shields.io/badge/Bahasa_Indonesia-README.id-16A34A?style=for-the-badge" alt="Bahasa Indonesia README" /></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://github.com/envielxyz/SwayRouter/stargazers"><img src="https://img.shields.io/github/stars/envielxyz/SwayRouter?style=flat" alt="GitHub stars" /></a>
|
|
18
|
+
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="Lisensi MIT" /></a>
|
|
19
|
+
<a href="https://bun.sh"><img src="https://img.shields.io/badge/runtime-Bun-black?logo=bun" alt="Bun" /></a>
|
|
20
|
+
<a href="https://www.typescriptlang.org"><img src="https://img.shields.io/badge/code-TypeScript-3178C6?logo=typescript&logoColor=white" alt="TypeScript" /></a>
|
|
21
|
+
<a href="https://react.dev"><img src="https://img.shields.io/badge/dashboard-React-61DAFB?logo=react&logoColor=111827" alt="React" /></a>
|
|
22
|
+
<a href="https://sqlite.org"><img src="https://img.shields.io/badge/storage-SQLite-003B57?logo=sqlite&logoColor=white" alt="SQLite" /></a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<img src="./docs/media/screenshots/dashboard.png" alt="Dashboard Sway Router" width="960" />
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
Sway Router membawa semua provider AI kamu ke satu gateway yang clean, dengan
|
|
30
|
+
dashboard simpel untuk mengatur model, routing, dan usage.
|
|
31
|
+
|
|
32
|
+
## Daftar isi
|
|
33
|
+
|
|
34
|
+
- [Mulai cepat](#mulai-cepat)
|
|
35
|
+
- [Uninstall](#uninstall)
|
|
36
|
+
- [Requirement](#requirement)
|
|
37
|
+
- [HTTP API](#satu-http-api-untuk-semua-kebutuhan)
|
|
38
|
+
- [Dashboard](#dashboard-yang-enak-dipakai)
|
|
39
|
+
- [Migrasi dari 9Router](#migrasi-dari-9router)
|
|
40
|
+
- [Providers](#providers)
|
|
41
|
+
- [CLI Tools yang didukung](#cli-tools-yang-didukung)
|
|
42
|
+
- [Fitur lengkap](#fitur-yang-tersedia)
|
|
43
|
+
- [Perbandingan](#sway-router-vs-9router-vs-omniroute)
|
|
44
|
+
- [Operasional dan keamanan](#operasional-dan-keamanan)
|
|
45
|
+
- [Tech stack](#tech-stack)
|
|
46
|
+
- [Konfigurasi](#konfigurasi)
|
|
47
|
+
- [Atribusi dan lisensi](#atribusi)
|
|
48
|
+
|
|
49
|
+
## Mulai cepat
|
|
50
|
+
|
|
51
|
+
### Global CLI — cara paling cepat
|
|
52
|
+
|
|
53
|
+
Install global lalu jalanin router:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
bun install -g swayrouter@latest
|
|
57
|
+
swayrouter
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
CLI bisa start, stop, restart, dan cek status router. Saat start, CLI juga
|
|
61
|
+
mengecek apakah ada versi baru, tapi nggak akan update sendiri tanpa persetujuan
|
|
62
|
+
kamu.
|
|
63
|
+
|
|
64
|
+
### Windows — install lokal
|
|
65
|
+
|
|
66
|
+
Cara paling gampang di Windows adalah install global secara lokal. Kalau Bun
|
|
67
|
+
sudah terpasang, lewati langkah pertama.
|
|
68
|
+
|
|
69
|
+
1. Buka PowerShell lalu install Bun:
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
powershell -c "irm bun.sh/install.ps1 | iex"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
2. Tutup dan buka lagi PowerShell, lalu cek Bun:
|
|
76
|
+
|
|
77
|
+
```powershell
|
|
78
|
+
bun --version
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
3. Install dan jalankan Sway Router:
|
|
82
|
+
|
|
83
|
+
```powershell
|
|
84
|
+
bun install -g swayrouter@latest
|
|
85
|
+
swayrouter start -b
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
4. Buka `http://127.0.0.1:14045/dashboard` di browser, lalu selesaikan setup
|
|
89
|
+
pertama.
|
|
90
|
+
|
|
91
|
+
5. Cek atau stop instance lokal kapan saja:
|
|
92
|
+
|
|
93
|
+
```powershell
|
|
94
|
+
swayrouter status
|
|
95
|
+
swayrouter stop
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Data runtime CLI disimpan di `%APPDATA%\.swayrouter`. Untuk install lokal
|
|
99
|
+
biasa, kamu tidak perlu membuat file `.env`.
|
|
100
|
+
|
|
101
|
+
### Uninstall
|
|
102
|
+
|
|
103
|
+
Stop router dulu sebelum menghapus CLI global:
|
|
104
|
+
|
|
105
|
+
```powershell
|
|
106
|
+
swayrouter stop
|
|
107
|
+
bun remove -g swayrouter
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Kalau install-nya memakai npm, gunakan `npm uninstall -g swayrouter`.
|
|
111
|
+
Menghapus package tidak menghapus credential provider, setting, API key, atau
|
|
112
|
+
data usage. Kalau ingin menghapus semuanya juga, export backup JSON dulu, stop
|
|
113
|
+
router, lalu hapus `%APPDATA%\.swayrouter` di Windows atau `~/.swayrouter` di
|
|
114
|
+
Linux/macOS.
|
|
115
|
+
|
|
116
|
+
### Windows — jalankan dari source
|
|
117
|
+
|
|
118
|
+
Untuk contributor yang bekerja dari checkout:
|
|
119
|
+
|
|
120
|
+
```powershell
|
|
121
|
+
git clone https://github.com/envielxyz/SwayRouter.git
|
|
122
|
+
cd SwayRouter
|
|
123
|
+
bun install --frozen-lockfile
|
|
124
|
+
Push-Location dashboard
|
|
125
|
+
bun install --frozen-lockfile
|
|
126
|
+
bun run build
|
|
127
|
+
Pop-Location
|
|
128
|
+
bun run dev
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Buka `http://127.0.0.1:14045/dashboard`. Biarkan terminal tetap terbuka saat
|
|
132
|
+
development server berjalan.
|
|
133
|
+
|
|
134
|
+
### Jalanin dari source (macOS/Linux)
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
bun install --frozen-lockfile
|
|
138
|
+
cd dashboard
|
|
139
|
+
bun install --frozen-lockfile
|
|
140
|
+
bun run build
|
|
141
|
+
cd ..
|
|
142
|
+
bun run dev
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Buka `http://127.0.0.1:14045/dashboard`, lalu tambahkan provider pertama kamu.
|
|
146
|
+
|
|
147
|
+
Kalau mau ngembangin dashboard, jalanin `bun run dev` di dalam folder
|
|
148
|
+
`dashboard/` lewat terminal kedua.
|
|
149
|
+
|
|
150
|
+
### Docker — terisolasi dan datanya persistent
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
docker build -t swayrouter:latest .
|
|
154
|
+
docker compose up -d
|
|
155
|
+
docker compose ps
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Docker juga membuat secret persistent di data volume. Copy `.env.example`
|
|
159
|
+
menjadi `.env` hanya kalau kamu ingin memberi override deployment sendiri.
|
|
160
|
+
|
|
161
|
+
Buka `http://127.0.0.1:14045/dashboard`. Untuk lihat log:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
docker compose logs -f swayrouter
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Setup Docker memakai volume `swayrouter-data`, bind port hanya ke localhost,
|
|
168
|
+
menjalankan container sebagai user non-root, memakai root filesystem read-only,
|
|
169
|
+
dan sudah punya readiness health check. Jangan hapus volume kalau ingin tetap
|
|
170
|
+
menyimpan koneksi provider, key, setting, dan data usage.
|
|
171
|
+
|
|
172
|
+
## Requirement
|
|
173
|
+
|
|
174
|
+
| Deployment | Yang dibutuhkan | Process manager |
|
|
175
|
+
| --- | --- | --- |
|
|
176
|
+
| Global CLI | Bun `1.3+`, data directory yang bisa ditulis, dan akses network ke provider | CLI untuk lokal; tambahkan supervisor untuk production |
|
|
177
|
+
| Docker | Docker Engine dengan plugin Compose dan volume persistent | Docker Compose sudah menangani restart dan health check; nggak perlu PM2 |
|
|
178
|
+
| Native VPS | Bun `1.3+`, data directory yang bisa ditulis, dan akses network ke provider | `systemd` direkomendasikan; PM2 opsional |
|
|
179
|
+
|
|
180
|
+
Untuk native VPS kecil, mulai dari **2 vCPU, RAM 2 GB, dan SSD 10 GB**. Komputer
|
|
181
|
+
lokal bisa jalan dengan resource lebih kecil. Sebelum dibuka ke internet, taruh
|
|
182
|
+
Sway Router di belakang reverse proxy HTTPS.
|
|
183
|
+
|
|
184
|
+
### Native VPS dengan PM2 (opsional)
|
|
185
|
+
|
|
186
|
+
PM2 sudah mendukung Bun, tapi hanya diperlukan kalau Sway Router dijalankan langsung
|
|
187
|
+
di VPS tanpa Docker atau supervisor lain:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npm install -g pm2
|
|
191
|
+
pm2 start src/server.ts --name swayrouter --interpreter bun
|
|
192
|
+
pm2 save
|
|
193
|
+
pm2 startup
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Jalankan `pm2 startup` sesuai perintah yang diberikan PM2 supaya process otomatis
|
|
197
|
+
balik hidup setelah reboot. Jangan menjalankan PM2 di atas Docker Compose untuk
|
|
198
|
+
container yang sama.
|
|
199
|
+
|
|
200
|
+
## Satu HTTP API untuk semua kebutuhan
|
|
201
|
+
|
|
202
|
+
Pakai format client yang sudah biasa kamu pakai. Sway Router akan menerjemahkan
|
|
203
|
+
request dan response ke provider di belakang layar.
|
|
204
|
+
|
|
205
|
+
| Client / fitur | Endpoint |
|
|
206
|
+
| --- | --- |
|
|
207
|
+
| OpenAI Chat Completions | `POST /v1/chat/completions` |
|
|
208
|
+
| OpenAI Responses | `POST /v1/responses` |
|
|
209
|
+
| Compact Responses | `POST /v1/responses/compact` |
|
|
210
|
+
| Anthropic Messages | `POST /v1/messages` |
|
|
211
|
+
| Anthropic token count | `POST /v1/messages/count_tokens` |
|
|
212
|
+
| Ollama-style chat | `POST /v1/api/chat` |
|
|
213
|
+
| Image generation | `POST /v1/images/generations` |
|
|
214
|
+
| Image editing | `POST /v1/images/edits` |
|
|
215
|
+
| Daftar model | `GET /v1/models` |
|
|
216
|
+
|
|
217
|
+
Streaming dan non-streaming tersedia selama provider dan model yang dipilih
|
|
218
|
+
mendukungnya. Alias `/codex` dan `/responses` juga tersedia untuk setup client
|
|
219
|
+
yang umum.
|
|
220
|
+
|
|
221
|
+
### Contoh singkat
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
export SWAY_API_KEY="swy-your_gateway_key"
|
|
225
|
+
curl http://127.0.0.1:14045/v1/chat/completions \
|
|
226
|
+
--oauth2-bearer "${SWAY_API_KEY}" \
|
|
227
|
+
-H "Content-Type: application/json" \
|
|
228
|
+
-d '{
|
|
229
|
+
"model": "your-active-model-id",
|
|
230
|
+
"messages": [{"role": "user", "content": "Say hello"}]
|
|
231
|
+
}'
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Gateway key Sway Router berbeda dari credential provider di belakangnya. Secret
|
|
235
|
+
provider tetap tersimpan di server.
|
|
236
|
+
|
|
237
|
+
## Dashboard yang enak dipakai
|
|
238
|
+
|
|
239
|
+
Dashboard Sway Router bukan sekadar halaman admin. Ini jadi control room yang fokus
|
|
240
|
+
buat ngatur provider, model, akun, kuota, usage, log, dan routing. Ada compact
|
|
241
|
+
card, status badge yang jelas, search dan filter, layout responsive, serta
|
|
242
|
+
loading/refresh state yang smooth supaya semuanya tetap gampang dipantau di
|
|
243
|
+
desktop, tablet, dan mobile.
|
|
244
|
+
|
|
245
|
+
| Dashboard | Providers |
|
|
246
|
+
| --- | --- |
|
|
247
|
+
|  |  |
|
|
248
|
+
| Model provider | Custom provider |
|
|
249
|
+
|  |  |
|
|
250
|
+
| Usage & cost | Monitor kuota |
|
|
251
|
+
|  |  |
|
|
252
|
+
| Settings | CLI Tools |
|
|
253
|
+
|  |  |
|
|
254
|
+
|
|
255
|
+
[Lihat showcase UI lengkap](./docs/SHOWCASE.md)
|
|
256
|
+
|
|
257
|
+
### Menu utama
|
|
258
|
+
|
|
259
|
+
| Menu | Isinya |
|
|
260
|
+
| --- | --- |
|
|
261
|
+
| **Dashboard** | Jumlah request, total token, cost, latency, aktivitas provider, dan status sistem |
|
|
262
|
+
| **API Keys** | Buat, lihat, copy, rotate, enable, revoke, dan hapus gateway key |
|
|
263
|
+
| **Providers** | Tambah koneksi, pilih auth, test akun, kelola model, dan atur routing |
|
|
264
|
+
| **Combos** | Buat fallback berurutan untuk model/provider dan pilih strateginya |
|
|
265
|
+
| **Proxy** | Buat/test proxy pool, pasang koneksi, dan deploy relay opsional |
|
|
266
|
+
| **Usage** | Chart, breakdown token, estimasi cost, history, filter, sorting, dan detail request |
|
|
267
|
+
| **Quota Monitor** | Ketersediaan provider/akun, status kuota, diagnostik, dan refresh manual |
|
|
268
|
+
| **CLI Tools** | Atur coding tools yang didukung, pilih model, dan copy config otomatis |
|
|
269
|
+
| **Sway Chat** | Chat lewat router dengan pemilihan model dan built-in tools opsional |
|
|
270
|
+
| **Settings** | Kontrol Preferences, General, Security, Data, dan migrasi 9Router |
|
|
271
|
+
| **Console Logs** | Cari, filter, wrap, copy, dan cek diagnostik runtime/provider |
|
|
272
|
+
|
|
273
|
+
### Isi Settings
|
|
274
|
+
|
|
275
|
+
- **Preferences:** foto profil dengan crop/zoom, nama profil, dan currency
|
|
276
|
+
tampilan (USD default, IDR tersedia).
|
|
277
|
+
- **General:** RTK token saver, Caveman, Ponytail, capture payload request, dan
|
|
278
|
+
Cloudflare Tunnel.
|
|
279
|
+
- **Security:** wajib API key, wajib login dashboard, password dashboard,
|
|
280
|
+
login protection, dan graceful shutdown.
|
|
281
|
+
- **Data:** lokasi database, backup/restore JSON, dan migrasi 9Router.
|
|
282
|
+
|
|
283
|
+
## Migrasi dari 9Router
|
|
284
|
+
|
|
285
|
+
Kalau mau pindah dari 9Router, buka **Settings → Data → Migrate from 9Router**.
|
|
286
|
+
Sway Router mendukung dua sumber migrasi:
|
|
287
|
+
|
|
288
|
+
- **Instalasi lokal:** otomatis mencari database 9Router yang didukung di
|
|
289
|
+
perangkat yang sama.
|
|
290
|
+
- **Backup JSON 9Router:** import backup hasil export dari perangkat ini atau
|
|
291
|
+
perangkat lain.
|
|
292
|
+
|
|
293
|
+
Sebelum import, kamu bisa pilih data yang mau dibawa:
|
|
294
|
+
|
|
295
|
+
- Provider account dan credential
|
|
296
|
+
- Custom provider
|
|
297
|
+
- Custom model
|
|
298
|
+
- Combo
|
|
299
|
+
- Routing settings — default mati
|
|
300
|
+
- Langsung aktifkan account hasil import — default mati
|
|
301
|
+
|
|
302
|
+
Sway Router akan menampilkan preview dulu: data yang siap diimport, sudah ada, atau
|
|
303
|
+
akan dilewati. Source divalidasi, referensi provider dan model disesuaikan ke
|
|
304
|
+
format Sway Router, data duplikat ditangani, dan provider yang tidak kompatibel atau
|
|
305
|
+
tidak tersedia dilaporkan tanpa memasukkan entry yang rusak. Preview tidak
|
|
306
|
+
mengubah data apa pun.
|
|
307
|
+
|
|
308
|
+
Setelah kamu konfirmasi dengan password dashboard, Sway Router membuat safety backup,
|
|
309
|
+
menggabungkan data yang dipilih ke database yang sudah ada, lalu me-refresh
|
|
310
|
+
dashboard. Data Sway Router yang lama tidak diganti, dan account hasil import tetap
|
|
311
|
+
inactive kecuali kamu memilih untuk langsung mengaktifkannya. Gunakan **Import
|
|
312
|
+
JSON** untuk backup Sway Router; gunakan **Migrate from 9Router** untuk backup
|
|
313
|
+
9Router.
|
|
314
|
+
|
|
315
|
+
## Providers
|
|
316
|
+
|
|
317
|
+
Katalog bawaan Sway Router saat ini menampilkan **65 provider**. Daftar di bawah
|
|
318
|
+
diambil dari provider yang tersedia di dashboard, bukan daftar marketing.
|
|
319
|
+
Ketersediaan provider dan pilihan auth bisa berubah mengikuti layanan upstream.
|
|
320
|
+
|
|
321
|
+
### API key — 44
|
|
322
|
+
|
|
323
|
+
| Provider | ID |
|
|
324
|
+
| --- | --- |
|
|
325
|
+
| Alibaba Coding | `alicode-intl` |
|
|
326
|
+
| Alibaba | `alicode` |
|
|
327
|
+
| Alibaba Studio | `alims-intl` |
|
|
328
|
+
| Anthropic | `anthropic` |
|
|
329
|
+
| Azure OpenAI | `azure` |
|
|
330
|
+
| Baidu Qianfan | `baidu` |
|
|
331
|
+
| Blackbox AI | `blackbox` |
|
|
332
|
+
| BytePlus ModelArk | `byteplus` |
|
|
333
|
+
| Cerebras | `cerebras` |
|
|
334
|
+
| Chutes AI | `chutes` |
|
|
335
|
+
| Cloudflare | `cloudflare-ai` |
|
|
336
|
+
| Command Code | `commandcode` |
|
|
337
|
+
| DeepSeek | `deepseek` |
|
|
338
|
+
| Featherless | `featherless` |
|
|
339
|
+
| Fireworks AI | `fireworks` |
|
|
340
|
+
| Gemini | `gemini` |
|
|
341
|
+
| GLM (China) | `glm-cn` |
|
|
342
|
+
| GLM Coding | `glm` |
|
|
343
|
+
| Groq | `groq` |
|
|
344
|
+
| Kilo Gateway | `kilo-gateway` |
|
|
345
|
+
| Minimax (China) | `minimax-cn` |
|
|
346
|
+
| Minimax Coding | `minimax` |
|
|
347
|
+
| Mistral | `mistral` |
|
|
348
|
+
| Morph | `morph` |
|
|
349
|
+
| Nebius AI | `nebius` |
|
|
350
|
+
| NVIDIA NIM | `nvidia` |
|
|
351
|
+
| Ollama Local | `ollama-local` |
|
|
352
|
+
| Ollama Cloud | `ollama` |
|
|
353
|
+
| OpenAI | `openai` |
|
|
354
|
+
| OpenCode Go | `opencode-go` |
|
|
355
|
+
| OpenRouter | `openrouter` |
|
|
356
|
+
| Perplexity AI | `perplexity` |
|
|
357
|
+
| Poolside | `poolside` |
|
|
358
|
+
| Tencent Hunyuan | `tencent` |
|
|
359
|
+
| Together AI | `together` |
|
|
360
|
+
| Venice AI | `venice` |
|
|
361
|
+
| Vercel AI Gateway | `vercel-ai-gateway` |
|
|
362
|
+
| Vertex Partner | `vertex-partner` |
|
|
363
|
+
| Vertex AI | `vertex` |
|
|
364
|
+
| Xiaomi MiMo | `xiaomi-mimo` |
|
|
365
|
+
| Xiaomi MiMo (Token Plan) | `xiaomi-tokenplan` |
|
|
366
|
+
| Meta AI | `meta` |
|
|
367
|
+
| Agent Router | `agentrouter` |
|
|
368
|
+
| SumoPod | `sumopod` |
|
|
369
|
+
|
|
370
|
+
Perplexity AI memakai [Perplexity Router API resmi](https://docs.perplexity.ai/docs/router/quickstart): satu API key, satu koneksi, dan satu katalog model live untuk format OpenAI Chat Completions, OpenAI Responses, dan Anthropic Messages.
|
|
371
|
+
|
|
372
|
+
### OAuth, device code, atau token import — 19
|
|
373
|
+
|
|
374
|
+
| Provider | ID |
|
|
375
|
+
| --- | --- |
|
|
376
|
+
| Antigravity | `antigravity` |
|
|
377
|
+
| Claude Code | `claude` |
|
|
378
|
+
| Cline | `cline` |
|
|
379
|
+
| ClinePass | `clinepass` |
|
|
380
|
+
| CodeBuddy CN | `codebuddy-cn` |
|
|
381
|
+
| CodeBuddy | `codebuddy-intl` |
|
|
382
|
+
| OpenAI Codex | `codex` |
|
|
383
|
+
| Cursor IDE | `cursor` |
|
|
384
|
+
| Gemini CLI | `gemini-cli` |
|
|
385
|
+
| GitHub Copilot | `github` |
|
|
386
|
+
| Grok CLI (Grok Build) | `grok-cli` |
|
|
387
|
+
| Kilo Code | `kilocode` |
|
|
388
|
+
| Kimchi | `kimchi` |
|
|
389
|
+
| Kimi | `kimi` |
|
|
390
|
+
| Kiro AI | `kiro` |
|
|
391
|
+
| Qoder | `qoder` |
|
|
392
|
+
| Trae | `trae` |
|
|
393
|
+
| Windsurf | `windsurf` |
|
|
394
|
+
| xAI (Grok) | `xai` |
|
|
395
|
+
|
|
396
|
+
### Web cookie — 1
|
|
397
|
+
|
|
398
|
+
| Provider | ID |
|
|
399
|
+
| --- | --- |
|
|
400
|
+
| Grok Web (Subscription) | `grok-web` |
|
|
401
|
+
|
|
402
|
+
### No auth — 1
|
|
403
|
+
|
|
404
|
+
| Provider | ID |
|
|
405
|
+
| --- | --- |
|
|
406
|
+
| OpenCode Free | `opencode` |
|
|
407
|
+
|
|
408
|
+
## CLI Tools yang didukung
|
|
409
|
+
|
|
410
|
+
Sway Router bisa mendeteksi dan mengatur coding tools berikut agar memakai
|
|
411
|
+
gateway:
|
|
412
|
+
|
|
413
|
+
- Claude Code
|
|
414
|
+
- Codex CLI
|
|
415
|
+
- OpenCode
|
|
416
|
+
- Hermes Agent
|
|
417
|
+
- Claude Cowork
|
|
418
|
+
- Kilo Code
|
|
419
|
+
- Grok Build
|
|
420
|
+
- OMP (oh-my-pi)
|
|
421
|
+
|
|
422
|
+
## Fitur yang tersedia
|
|
423
|
+
|
|
424
|
+
### Provider dan akun
|
|
425
|
+
|
|
426
|
+
- Hubungkan provider lewat API key, OAuth, device code, cookie/session, atau
|
|
427
|
+
access/refresh token kalau flow tersebut didukung provider.
|
|
428
|
+
- Tambahkan banyak akun ke satu provider, lengkap dengan prioritas dan status
|
|
429
|
+
enable/disable.
|
|
430
|
+
- Test koneksi, test model tertentu, atau test semua model dalam satu batch.
|
|
431
|
+
- Import katalog model secara live kalau endpoint upstream tersedia.
|
|
432
|
+
- Tambahkan custom provider, custom node, custom model, alias, dan pricing.
|
|
433
|
+
- Tandai capability model seperti vision, audio, video, search, tools, dan
|
|
434
|
+
reasoning.
|
|
435
|
+
- Simpan ID model upstream, endpoint, header, dan aturan kompatibilitas khusus
|
|
436
|
+
provider.
|
|
437
|
+
|
|
438
|
+
### Routing dan fallback
|
|
439
|
+
|
|
440
|
+
- `fill-first` untuk penggunaan akun yang predictable.
|
|
441
|
+
- `round-robin` untuk rotasi sederhana.
|
|
442
|
+
- `least-inflight` untuk membagi request aktif.
|
|
443
|
+
- `sticky` dan `cache-affine` saat koneksi akun perlu tetap stabil.
|
|
444
|
+
- Override routing per provider dan kontrol sticky.
|
|
445
|
+
- Combo untuk fallback model/provider secara berurutan.
|
|
446
|
+
- Cooldown akun, account lock, endpoint fallback, dan retry yang dibatasi.
|
|
447
|
+
|
|
448
|
+
### Translasi dan dukungan model
|
|
449
|
+
|
|
450
|
+
- Format request OpenAI, Anthropic, Responses, dan Ollama-style.
|
|
451
|
+
- Translasi request dan response khusus tiap provider.
|
|
452
|
+
- Konversi streaming lewat SSE dan response JSON biasa.
|
|
453
|
+
- Tool call, thinking/reasoning, vision, image input, media, dan usage sesuai
|
|
454
|
+
dukungan model yang dipilih.
|
|
455
|
+
- Compatibility fallback untuk parameter opsional yang ditolak upstream.
|
|
456
|
+
- Dynamic model discovery, katalog statis, custom model, alias, disabled model,
|
|
457
|
+
dan filter berdasarkan capability.
|
|
458
|
+
|
|
459
|
+
### Usage, cost, dan kuota
|
|
460
|
+
|
|
461
|
+
- History request dengan provider, model, akun, endpoint, status, dan latency.
|
|
462
|
+
- Tracking token input, output, cached, dan total.
|
|
463
|
+
- Estimasi cost dengan USD sebagai default dan IDR sebagai pilihan.
|
|
464
|
+
- Total per provider, chart, aktivitas terbaru, dan detail request.
|
|
465
|
+
- Quota monitor dengan status provider/akun dan tombol refresh.
|
|
466
|
+
- Optional capture request/response payload dengan kontrol retention.
|
|
467
|
+
|
|
468
|
+
### Backup dan migrasi
|
|
469
|
+
|
|
470
|
+
- Export dan restore data Sway Router dalam format JSON.
|
|
471
|
+
- Migrasi dari instalasi lokal 9Router atau backup JSON 9Router.
|
|
472
|
+
- Pilih account, custom provider, model, combo, dan routing settings yang mau
|
|
473
|
+
diimport.
|
|
474
|
+
- Lihat preview kompatibilitas dan duplikat sebelum ada perubahan, lalu buat
|
|
475
|
+
safety backup sebelum migrasi diterapkan.
|
|
476
|
+
|
|
477
|
+
### Performa dan reliability
|
|
478
|
+
|
|
479
|
+
- Global request admission control dan queue yang dibatasi.
|
|
480
|
+
- Batas concurrency per provider dan per akun.
|
|
481
|
+
- Kapasitas adaptif berdasarkan memory dan CPU yang tersedia.
|
|
482
|
+
- Batas body request plus timeout upload, koneksi, stream, dan queue.
|
|
483
|
+
- Retry upstream dan endpoint fallback dengan jumlah percobaan terkontrol.
|
|
484
|
+
- Refresh OAuth otomatis dan deduplikasi refresh token.
|
|
485
|
+
- Penanganan aman untuk disconnect, stream yang dibatalkan, provider error, dan
|
|
486
|
+
response 429.
|
|
487
|
+
- Graceful shutdown supaya request aktif bisa selesai dengan rapi.
|
|
488
|
+
|
|
489
|
+
### Built-in tools
|
|
490
|
+
|
|
491
|
+
- Sway Chat dengan web search opsional lewat Tavily atau Brave.
|
|
492
|
+
- Shell, curl, dan router inspection tools dengan kontrol yang jelas.
|
|
493
|
+
- Fitur token saver RTK, Caveman, dan Ponytail.
|
|
494
|
+
- CLI model mapping untuk coding tools yang didukung.
|
|
495
|
+
|
|
496
|
+
## Sway Router vs 9Router vs OmniRoute
|
|
497
|
+
|
|
498
|
+
Ketiganya menyelesaikan masalah yang mirip dan punya routing, account, fallback,
|
|
499
|
+
serta provider workflow. Perbandingan arsitektur sederhananya:
|
|
500
|
+
|
|
501
|
+
Sway Router juga punya rotasi multi-account, pemilihan berbasis kuota, token saver,
|
|
502
|
+
retry, fallback, dan refresh token provider. Bagian ini sengaja fokus ke berat
|
|
503
|
+
runtime, bukan adu daftar fitur.
|
|
504
|
+
|
|
505
|
+
- **Sway Router:** Bun + Hono + SQLite, dengan dashboard React/Vite. Satu
|
|
506
|
+
core server yang dirancang untuk penggunaan lokal dan VPS kecil.
|
|
507
|
+
- **[9Router](https://github.com/decolua/9router):** Node + Next.js/React +
|
|
508
|
+
Express + SQLite. Layer framework lebih banyak dan runtime CLI terpisah.
|
|
509
|
+
- **[OmniRoute](https://github.com/diegosouzapw/OmniRoute):** Node + Next.js/
|
|
510
|
+
React + SQLite/sql.js, dengan layer Redis, browser, desktop, dan PWA opsional.
|
|
511
|
+
|
|
512
|
+
### Mana yang lebih ringan?
|
|
513
|
+
|
|
514
|
+
Untuk setup gateway lokal atau VPS kecil yang sebanding, **Sway Router adalah
|
|
515
|
+
default yang lebih ringan**. Bun dan Hono punya overhead server yang lebih kecil
|
|
516
|
+
daripada aplikasi Next.js penuh, dan core Sway Router tidak membutuhkan service
|
|
517
|
+
tambahan untuk berjalan.
|
|
518
|
+
|
|
519
|
+
Ini perbandingan arsitektur, bukan janji RAM tetap. Pemakaian nyata tetap
|
|
520
|
+
tergantung concurrent stream, ukuran request, jumlah account, layer proxy, dan
|
|
521
|
+
service opsional. Starting point VPS kecil Sway Router yang didokumentasikan adalah
|
|
522
|
+
2 vCPU dan 2 GB RAM, dengan queue, concurrency, retry, dan request body yang
|
|
523
|
+
dibatasi.
|
|
524
|
+
|
|
525
|
+
### Kenapa pilih Sway Router?
|
|
526
|
+
|
|
527
|
+
- **Footprint default lebih kecil.** Core cukup dengan server Bun dan SQLite,
|
|
528
|
+
tanpa Redis, hosted sync service, desktop shell, atau browser pool.
|
|
529
|
+
- **Dashboard yang enak dipakai harian.** Provider, account, model, routing,
|
|
530
|
+
usage, quota, proxy, log, dan settings ada dalam satu control room yang clean.
|
|
531
|
+
- **Resource guardrail sudah built-in.** Sway Router mendeteksi profile host dan
|
|
532
|
+
menjaga concurrency, queue, request body, retry, serta background work tetap
|
|
533
|
+
terbatas.
|
|
534
|
+
- **Gampang dikirim dan diperiksa.** Bisa dijalankan lokal, di VPS kecil, Docker,
|
|
535
|
+
atau standalone binary, dengan backup/import SQLite dan API yang mudah
|
|
536
|
+
diinspeksi.
|
|
537
|
+
|
|
538
|
+
Angka dan peta menu Sway Router diambil dari [provider registry](./src/providers/registry/index.js),
|
|
539
|
+
[navigasi dashboard](./dashboard/src/components/Sidebar.tsx),
|
|
540
|
+
[route table](./src/routes/table.js), dan [package manifest](./package.json).
|
|
541
|
+
|
|
542
|
+
## Operasional dan keamanan
|
|
543
|
+
|
|
544
|
+
- Session dashboard memakai JWT dan password hashing dengan bcrypt.
|
|
545
|
+
- Login limiting dan admin route yang terlindungi.
|
|
546
|
+
- Gateway auth lewat `Authorization: Bearer ...` atau `x-api-key`.
|
|
547
|
+
- Default binding ke localhost dan credential provider tetap di server.
|
|
548
|
+
- Secret dari environment variable dan perlindungan SSRF.
|
|
549
|
+
- Health, readiness, version, runtime status, dan Prometheus-style metrics.
|
|
550
|
+
- SQLite WAL mode, migration, index, backup, export, dan import.
|
|
551
|
+
- Docker/Compose, native source run, Bun CLI, dan standalone binary.
|
|
552
|
+
|
|
553
|
+
Sway Router menjaga process dan account pool-nya sendiri, tapi tidak membuat kuota
|
|
554
|
+
provider dan tidak menjanjikan RPS tetap. Kapasitas nyata tetap tergantung limit
|
|
555
|
+
provider, jumlah akun, latency jaringan, ukuran prompt, dan durasi stream.
|
|
556
|
+
|
|
557
|
+
## Tech stack
|
|
558
|
+
|
|
559
|
+
- **Runtime:** Bun, dengan fallback yang kompatibel dengan Node jika diperlukan
|
|
560
|
+
- **Gateway:** TypeScript, Hono, native HTTP, dan SSE
|
|
561
|
+
- **Dashboard:** React, Vite, Tailwind CSS, React Router, dan TanStack Query
|
|
562
|
+
- **Storage:** SQLite dengan WAL mode, migration, backup, dan fallback `sql.js`
|
|
563
|
+
- **Auth:** JWT, bcrypt, OAuth/PKCE, dan refresh token khusus provider
|
|
564
|
+
- **Shipping:** Bun CLI, Docker, standalone binary, dan GitHub Actions
|
|
565
|
+
|
|
566
|
+
## Konfigurasi
|
|
567
|
+
|
|
568
|
+
Untuk satu instance lokal atau Docker, konfigurasi bersifat opsional. Saat
|
|
569
|
+
start pertama, Sway Router membuat JWT secret, gateway-key secret, dan machine salt
|
|
570
|
+
yang kuat di data directory persistent. Pakai `.env` kalau perlu mengganti
|
|
571
|
+
default, bind ke host lain, atau mengelola secret dari luar:
|
|
572
|
+
|
|
573
|
+
```dotenv
|
|
574
|
+
PORT=14045
|
|
575
|
+
HOSTNAME=127.0.0.1
|
|
576
|
+
DATA_DIR=/var/lib/swayrouter
|
|
577
|
+
NODE_ENV=production
|
|
578
|
+
JWT_SECRET=replace-with-a-random-secret-at-least-32-characters
|
|
579
|
+
API_KEY_SECRET=replace-with-a-random-secret-at-least-32-characters
|
|
580
|
+
MACHINE_ID_SALT=replace-with-a-random-private-salt
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
Jangan arahkan beberapa instance Sway Router yang berbeda ke SQLite data directory
|
|
584
|
+
yang sama. Kalau secret diberikan oleh supervisor, nilainya harus tetap sama
|
|
585
|
+
setelah restart agar session dashboard dan identitas instance tetap stabil.
|
|
586
|
+
|
|
587
|
+
Lokasi database default:
|
|
588
|
+
|
|
589
|
+
```text
|
|
590
|
+
Linux/macOS: ~/.swayrouter/db/data.sqlite
|
|
591
|
+
Windows: %APPDATA%\\.swayrouter\\db\\data.sqlite
|
|
592
|
+
Docker: /app/data/db/data.sqlite
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
Pastikan data directory tetap persistent. Isinya credential provider, config,
|
|
596
|
+
dan data usage. Jangan commit `.env`, file database, backup, OAuth token,
|
|
597
|
+
cookie, atau log.
|
|
598
|
+
|
|
599
|
+
## Kenapa SQLite?
|
|
600
|
+
|
|
601
|
+
SQLite bikin satu instance Sway Router private tetap kecil, portable, dan gampang
|
|
602
|
+
dibackup. PostgreSQL dan Redis lebih cocok untuk aplikasi komersial terpisah
|
|
603
|
+
dengan user terdistribusi, billing, background job, atau banyak instance Sway Router.
|
|
604
|
+
|
|
605
|
+
## Development checks
|
|
606
|
+
|
|
607
|
+
```bash
|
|
608
|
+
bun run typecheck
|
|
609
|
+
bun test
|
|
610
|
+
bun run routes:check
|
|
611
|
+
bun run package:check
|
|
612
|
+
bun run build:binary
|
|
613
|
+
bun run smoke:binary
|
|
614
|
+
bun run build:dashboard
|
|
615
|
+
bun run test:e2e:install
|
|
616
|
+
bun run test:e2e
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
## Atribusi
|
|
620
|
+
|
|
621
|
+
Sway Router adalah project standalone. Beberapa bagian OAuth, tunnel, CLI, dan utility
|
|
622
|
+
diadaptasi dari [9Router](https://github.com/decolua/9router), sedangkan gateway,
|
|
623
|
+
routing, dashboard, storage, API, performa, dan setup release dikembangkan serta
|
|
624
|
+
dirawat di project ini.
|
|
625
|
+
|
|
626
|
+
Lihat [`LICENSE`](./LICENSE) untuk atribusi MIT lengkap.
|
|
627
|
+
|
|
628
|
+
## Lisensi
|
|
629
|
+
|
|
630
|
+
MIT. Lihat [`LICENSE`](./LICENSE).
|
|
631
|
+
|
|
632
|
+
Sway Router adalah gateway dan admin tool. Kamu bertanggung jawab atas akun
|
|
633
|
+
provider, credential, traffic, privacy, compliance, dan keamanan deployment-mu.
|