dsh-plugin-opencode2api 1.3.1 → 1.3.2
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/README.md +1 -1
- package/lib/index.js +14 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ dsh plugin --profile web add dsh-plugin-opencode2api
|
|
|
45
45
|
|
|
46
46
|
Windows / macOS / Linux 装好后,打开 DSH Web UI(默认 `http://127.0.0.1:3080`)→ **设置 → 本地免费 API**,就能看到状态和操作按钮;手机 App 则在「本地API」胶囊/面板里。
|
|
47
47
|
|
|
48
|
-
## 接入云端设备池(1.3.
|
|
48
|
+
## 接入云端设备池(1.3.2)
|
|
49
49
|
|
|
50
50
|
如果你有一个自己的中转站(例如本项目作者的 oc-proxy),可以把这台设备变成它的一个后端,让中转站把请求分过来。
|
|
51
51
|
|
package/lib/index.js
CHANGED
|
@@ -455,6 +455,10 @@ export async function heartbeat() {
|
|
|
455
455
|
signal: AbortSignal.timeout(15000),
|
|
456
456
|
})
|
|
457
457
|
const data = await res.json().catch(() => ({}))
|
|
458
|
+
if (res.status === 401) {
|
|
459
|
+
resetPoolLocally(data.error || '设备已被移除')
|
|
460
|
+
return
|
|
461
|
+
}
|
|
458
462
|
if (!res.ok) throw new Error(data.error || `HTTP ${res.status}`)
|
|
459
463
|
pool.lastHeartbeat = Date.now()
|
|
460
464
|
pool.lastError = ''
|
|
@@ -549,7 +553,16 @@ export async function joinPool(input = {}) {
|
|
|
549
553
|
}
|
|
550
554
|
}
|
|
551
555
|
|
|
552
|
-
export
|
|
556
|
+
export function resetPoolLocally(reason) {
|
|
557
|
+
stopPoolTimers()
|
|
558
|
+
stopTunnel()
|
|
559
|
+
try {
|
|
560
|
+
fs.unlinkSync(POOL)
|
|
561
|
+
} catch {}
|
|
562
|
+
poolInfo = { status: String(reason || '已退出').slice(0, 40), tone: 'warn', hostname: '', lastError: '' }
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
async function leavePool() {
|
|
553
566
|
const pool = readPool()
|
|
554
567
|
stopPoolTimers()
|
|
555
568
|
stopTunnel()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-opencode2api",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Unofficial one-click installer and auto-runner for opencode2api — a local free OpenAI-compatible API gateway — inside DSH, with a desktop settings UI and a dsh-go native panel (Windows, macOS, Linux, Android).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|