one-model-router 0.0.10 → 0.0.12

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.
Files changed (80) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +32 -5
  3. package/bin/omr.js +46 -0
  4. package/package.json +3 -2
  5. package/src/admin.js +965 -941
  6. package/src/balances.js +61 -61
  7. package/src/boot.js +117 -117
  8. package/src/channels/buddy.js +2031 -2031
  9. package/src/channels/cline.js +753 -753
  10. package/src/channels/codearts.js +2051 -2051
  11. package/src/channels/comate.js +830 -830
  12. package/src/channels/doubaowork.js +1784 -1784
  13. package/src/channels/freebuff.js +1316 -1316
  14. package/src/channels/gemini.js +1721 -1721
  15. package/src/channels/index.js +270 -270
  16. package/src/channels/joycode.js +936 -936
  17. package/src/channels/kimi.js +572 -572
  18. package/src/channels/lobsterai.js +1226 -1226
  19. package/src/channels/loomy.js +1032 -1032
  20. package/src/channels/miaoshou.js +1396 -1396
  21. package/src/channels/mimo.js +474 -474
  22. package/src/channels/minimax.js +1451 -1451
  23. package/src/channels/qoder-wasm.js +434 -434
  24. package/src/channels/qoder.js +1619 -1619
  25. package/src/channels/raccoon.js +1842 -1842
  26. package/src/channels/tabbit.js +1457 -1457
  27. package/src/channels/trae.js +1405 -1405
  28. package/src/channels/zcode-global.js +35 -35
  29. package/src/channels/zcode.js +2085 -2085
  30. package/src/checkin.js +496 -496
  31. package/src/credits.js +464 -464
  32. package/src/crypto.js +132 -132
  33. package/src/free-models.js +683 -683
  34. package/src/gateway.js +596 -578
  35. package/src/health.js +86 -86
  36. package/src/model-key.js +35 -35
  37. package/src/paths.js +96 -96
  38. package/src/probe.js +318 -318
  39. package/src/providers/builtin.js +626 -626
  40. package/src/providers/index.js +483 -457
  41. package/src/providers/kilo.js +111 -111
  42. package/src/providers/last-good.js +69 -69
  43. package/src/providers/modelsdev.js +242 -242
  44. package/src/providers/openai-compat.js +312 -312
  45. package/src/providers/opencode/bun-fetch.js +226 -226
  46. package/src/providers/opencode/lane.js +186 -186
  47. package/src/providers/opencode/o2a/LICENSE.dsh-our-free-model +21 -21
  48. package/src/providers/opencode/o2a/asset-source.js +43 -43
  49. package/src/providers/opencode/o2a/assets/opencode_prompt_v2.txt +96 -96
  50. package/src/providers/opencode/o2a/assets/opencode_tools.json +327 -327
  51. package/src/providers/opencode/o2a/entry.js +17 -17
  52. package/src/providers/opencode/o2a/gateway-body.js +42 -42
  53. package/src/providers/opencode/o2a/headers.js +133 -133
  54. package/src/providers/opencode/o2a/identity.js +148 -148
  55. package/src/providers/opencode/o2a/official-prompt.js +191 -191
  56. package/src/providers/opencode/o2a/official-tools.js +110 -110
  57. package/src/providers/opencode/o2a/tool-renames.js +217 -217
  58. package/src/providers/opencode/o2a/toolshape.js +418 -418
  59. package/src/providers/opencode/o2a/version.js +37 -37
  60. package/src/providers/opencode/upstream.js +403 -403
  61. package/src/providers/opencode/wire.js +496 -496
  62. package/src/providers/opencode.js +652 -652
  63. package/src/router.js +629 -629
  64. package/src/server.js +49 -33
  65. package/src/store.js +467 -467
  66. package/src/sync/index.js +1529 -1529
  67. package/src/sync/login-preload.cjs +52 -52
  68. package/src/sync/noise.js +141 -141
  69. package/src/sync/relay-http.js +176 -176
  70. package/src/sync/remote-host.js +818 -818
  71. package/src/sync/remote-http.js +112 -112
  72. package/src/sync/remote-login.js +657 -657
  73. package/src/sync/remote-pairing.js +204 -204
  74. package/src/sync/remote-protocol.js +321 -321
  75. package/src/sync/snapshot.js +211 -211
  76. package/src/update.js +458 -0
  77. package/src/util.js +334 -334
  78. package/web/app.js +4010 -3972
  79. package/web/index.html +32 -32
  80. package/web/style.css +971 -971
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 OneModelRouter
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OneModelRouter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -23,7 +23,13 @@
23
23
  winget install OneModelRouter.OneModelRouter
24
24
 
25
25
  # 或一行安装脚本(自动取最新版并校验 sha256)
26
- powershell -c "irm https://bothua111.github.io/OneModelRouter/install.ps1 | iex"
26
+ powershell -c "irm https://one-model-router.traesite.cn/install.ps1 | iex"
27
+
28
+ # 网络不好时用 githubusercontent 备用
29
+ powershell -c "irm https://raw.githubusercontent.com/bothua111/OneModelRouter/gh-pages/install.ps1 | iex"
30
+
31
+ # 原生安装包不可用时,脚本会自动回退 npm 安装网页版;也可强制:
32
+ # powershell -c "& ([scriptblock]::Create((irm https://one-model-router.traesite.cn/install.ps1))) -Npm"
27
33
  ```
28
34
 
29
35
  也可直接从 [Releases](https://github.com/bothua111/OneModelRouter/releases/latest) 下载
@@ -36,7 +42,10 @@ powershell -c "irm https://bothua111.github.io/OneModelRouter/install.ps1 | iex"
36
42
  brew tap bothua111/cask && brew install --cask onemodelrouter
37
43
 
38
44
  # 或一行安装脚本(curl 下载不带隔离标记,可直接打开)
39
- curl -fsSL https://bothua111.github.io/OneModelRouter/install.sh | sh
45
+ curl -fsSL https://one-model-router.traesite.cn/install.sh | sh
46
+
47
+ # 网络不好时用 githubusercontent 备用
48
+ curl -fsSL https://raw.githubusercontent.com/bothua111/OneModelRouter/gh-pages/install.sh | sh
40
49
  ```
41
50
 
42
51
  Apple Silicon 与 Intel 分别有 `arm64` / `x64` 包。当前发布链是**无证书 ad-hoc 签名**,
@@ -46,7 +55,10 @@ Apple Silicon 与 Intel 分别有 `arm64` / `x64` 包。当前发布链是**无
46
55
 
47
56
  ```bash
48
57
  # 一行安装脚本(默认装 AppImage 到 ~/.local/bin)
49
- curl -fsSL https://bothua111.github.io/OneModelRouter/install.sh | sh
58
+ curl -fsSL https://one-model-router.traesite.cn/install.sh | sh
59
+
60
+ # 网络不好时用 githubusercontent 备用
61
+ curl -fsSL https://raw.githubusercontent.com/bothua111/OneModelRouter/gh-pages/install.sh | sh
50
62
 
51
63
  # 或用系统包(Releases 里下载)
52
64
  sudo dpkg -i OneModelRouter-<版本>-amd64.deb # Debian / Ubuntu
@@ -62,6 +74,8 @@ npm i -g one-model-router # 或:npx one-model-router start --detach
62
74
  omr start --detach
63
75
  ```
64
76
 
77
+ npm 版是**网页版**:管理界面在浏览器 <http://127.0.0.1:18681/admin>,数据目录与桌面端共用。
78
+
65
79
  ### Docker
66
80
 
67
81
  ```bash
@@ -107,6 +121,9 @@ curl http://127.0.0.1:18682/v1/models
107
121
  | `omr stop` / `omr restart` | 停止 / 重启后台实例 |
108
122
  | `omr status` | 查看进程、端口与 `/health` 探针 |
109
123
  | `omr portal` | 用系统浏览器打开管理面板 |
124
+ | `omr update` | 检查并升级到最新版(按当前系统优先装对应安装包,失败回退 npm 升级) |
125
+ | `omr update --check` | 只检查是否有新版本 |
126
+ | `omr update --npm` | 强制走 npm 全局升级 |
110
127
  | `omr version` | 版本 |
111
128
 
112
129
  通用选项:`--port`(网关,默认 18682)、`--admin-port`(管理面,默认 18681)、`--data-dir`。
@@ -120,6 +137,7 @@ curl http://127.0.0.1:18682/v1/models
120
137
  | `OMR_ADMIN_PORT` | `18681` | 管理面板端口 |
121
138
  | `OMR_GATEWAY_HOST` | `127.0.0.1` | 网关监听地址(容器内需设 `0.0.0.0`) |
122
139
  | `OMR_ADMIN_HOST` | `127.0.0.1` | 管理面监听地址 |
140
+ | `OMR_NO_UPDATE_CHECK` | — | 设为 `1` 关闭网页版后台自动检查更新 |
123
141
 
124
142
  桌面端与 CLI / Docker **共用同一份数据目录**,凭据不需要重复配置。
125
143
 
@@ -129,12 +147,16 @@ curl http://127.0.0.1:18682/v1/models
129
147
 
130
148
  | 渠道 | 方式 |
131
149
  | --- | --- |
132
- | Windows / macOS / Linux 桌面端 | 管理面板右上角「升级」按钮,内置自更新(优先 Gitee 源) |
150
+ | Windows / macOS / Linux 桌面端 | 管理面板右上角「升级」按钮,内置自更新(源顺序:TRAE 站点 → githubusercontent → Gitee → GitHub → 镜像) |
133
151
  | winget | `winget upgrade OneModelRouter.OneModelRouter` |
134
152
  | Homebrew | `brew upgrade --cask onemodelrouter` |
135
- | npm | `npm update -g one-model-router` |
153
+ | npm(网页版) | `omr update`(按当前系统优先装对应安装包,失败自动回退 `npm i -g one-model-router@latest`) |
154
+ | npm(网页版,手动) | `npm update -g one-model-router` |
136
155
  | Docker | `docker pull` 新 tag 后重建容器 |
137
156
 
157
+ 升级 feed 源顺序统一为:**TRAE 站点 → raw.githubusercontent.com → Gitee raw → GitHub Release → 加速镜像**,
158
+ 客户端并行探测取「版本最高且可达」的一份,避免首选源缓存陈旧导致漏升级。
159
+
138
160
  ---
139
161
 
140
162
  ## 常见问题
@@ -153,6 +175,11 @@ curl http://127.0.0.1:18682/v1/models
153
175
  用官网的 `install.sh` 安装(curl 下载不带隔离标记),或在终端执行
154
176
  `xattr -dr com.apple.quarantine /Applications/OneModelRouter.app` 后再打开。
155
177
 
178
+ **npm 版怎么升级?**
179
+ `omr update`:按当前系统优先装对应原生安装包(Windows 用 Setup、macOS 用 dmg/zip、Linux 用 AppImage),
180
+ 失败时自动回退 `npm i -g one-model-router@latest`;升级完执行 `omr restart` 生效。
181
+ 只想检查不升级:`omr update --check`。管理面板右上角「升级」按钮也是同一套逻辑。
182
+
156
183
  **Linux AppImage 双击没反应?**
157
184
  缺 `libfuse2`:`sudo apt install libfuse2`,或直接 `./OneModelRouter --appimage-extract-and-run`。
158
185
 
package/bin/omr.js CHANGED
@@ -17,6 +17,7 @@ import { spawn } from 'node:child_process'
17
17
  import { closeSync, mkdirSync, openSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'
18
18
  import { dirname, join } from 'node:path'
19
19
  import { fileURLToPath, pathToFileURL } from 'node:url'
20
+ import { runUpdate, checkForUpdate, cleanupStaged } from '../src/update.js'
20
21
 
21
22
  const ROOT = dirname(dirname(fileURLToPath(import.meta.url)))
22
23
  const PKG = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'))
@@ -42,6 +43,8 @@ function parseArgs(argv) {
42
43
  else if (a === '--port') args.port = rest.shift()
43
44
  else if (a === '--admin-port') args.adminPort = rest.shift()
44
45
  else if (a === '--data-dir') args.dataDir = rest.shift()
46
+ else if (a === '--npm') args.npm = true
47
+ else if (a === '--check') args.check = true
45
48
  else if (a === '-h' || a === '--help') args.command = 'help'
46
49
  else if (a === '-v' || a === '--version') args.command = 'version'
47
50
  else die(`未知参数 ${a}(omr help 看用法)`)
@@ -257,6 +260,40 @@ function portal() {
257
260
  } catch { /* 打不开就让用户手点,地址已经打在上一行 */ }
258
261
  }
259
262
 
263
+ /**
264
+ * omr update:自更新(与桌面版同一套 feed/产物逻辑)。
265
+ * - 默认 auto:按当前系统优先装对应原生安装包,失败自动回退 npm 全局升级;
266
+ * - --npm:强制走 npm i -g one-model-router@latest;
267
+ * - --check:只检查是否有新版本,不下载安装。
268
+ * 升级完成后需要重启服务使其生效(omr restart)。
269
+ */
270
+ async function update() {
271
+ const log = (...a) => console.log(...a)
272
+ const mode = args.npm ? 'npm' : 'auto'
273
+ if (args.check) {
274
+ const info = await checkForUpdate()
275
+ if (!info.hasUpdate) log(`已是最新版本 v${info.current}`)
276
+ else {
277
+ log(`可升级:v${info.current} → v${info.latest}(更新源:${info.source})`)
278
+ if (info.notes) log(`更新说明:${info.notes}`)
279
+ log(`执行 omr update 升级${info.asset ? '' : '(本平台无原生包,将走 npm 升级)'}`)
280
+ }
281
+ return
282
+ }
283
+ const pid = runningPid()
284
+ if (pid) log(`检测到正在运行的实例(PID ${pid});升级完成后请执行 omr restart 重启使其生效`)
285
+ try {
286
+ const result = await runUpdate({ mode, log })
287
+ if (!result.updated) {
288
+ log(`已是最新版本 v${result.current ?? ''}`)
289
+ }
290
+ } catch (error) {
291
+ die(`升级失败:${error?.message ?? error}`)
292
+ } finally {
293
+ cleanupStaged()
294
+ }
295
+ }
296
+
260
297
  function version() {
261
298
  log(`${PKG.name} ${PKG.version}(node ${process.version})`)
262
299
  }
@@ -272,6 +309,9 @@ function help() {
272
309
  log(' restart 停止后重新后台启动')
273
310
  log(' status 查看运行状态与健康探针')
274
311
  log(' portal 打印并用系统浏览器打开管理面板')
312
+ log(' update 检查并升级到最新版(按系统优先装原生包,失败回退 npm 升级)')
313
+ log(' update --check 只检查是否有新版本')
314
+ log(' update --npm 强制走 npm 全局升级(npm i -g one-model-router@latest)')
275
315
  log(' version 显示版本')
276
316
  log('')
277
317
  log('选项:')
@@ -291,6 +331,12 @@ const commands = {
291
331
  },
292
332
  status,
293
333
  portal,
334
+ update,
335
+ upgrade: update,
336
+ 'check-update': async () => {
337
+ args.check = true
338
+ await update()
339
+ },
294
340
  version,
295
341
  help,
296
342
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one-model-router",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "本地模型路由网关:聚合免费/自有模型通道,OpenAI 兼容转发,模型组自动轮询切换,自动签到领积分",
5
5
  "author": {
6
6
  "name": "OneModelRouter",
@@ -32,7 +32,8 @@
32
32
  "dist:linux": "electron-builder --linux",
33
33
  "dist:all": "electron-builder -mwl",
34
34
  "gen:feed": "node scripts/gen-feed.cjs",
35
- "gen:winget": "node scripts/gen-winget.cjs"
35
+ "gen:winget": "node scripts/gen-winget.cjs",
36
+ "sync:site-feed": "node scripts/sync-site-feed.cjs"
36
37
  },
37
38
  "engines": {
38
39
  "node": ">=18.0.0"