dsh-plugin-opencode2api 1.3.1 → 1.3.3

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 CHANGED
@@ -45,14 +45,14 @@ 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.1)
48
+ ## 接入云端设备池(1.3.3)
49
49
 
50
50
  如果你有一个自己的中转站(例如本项目作者的 oc-proxy),可以把这台设备变成它的一个后端,让中转站把请求分过来。
51
51
 
52
52
  1. 中转站后台 → **管理 → 设备** → **生成接入码**(15 分钟有效,只能用一次);
53
53
  2. 在这台设备上打开插件:
54
54
  - 手机:输入框上方「本地API」→ 面板里填前端地址和接入码 → 加入设备池;
55
- - 桌面:设置 → 本地免费 API → **云端设备池** → 填地址和接入码 → 加入设备池;
55
+ - 桌面:设置 → 本地免费 API → **云端设备池** → 粘入接入码 → 加入设备池(服务器地址已默认填好,需要换服才展开「自定义服务器地址」);
56
56
  3. 插件会自动创建 Cloudflare 隧道、下载并启动 cloudflared、每 60 秒上报心跳。
57
57
 
58
58
  管理端看到设备「在线」后就会把请求分配过来。心跳超过 3 分钟没到会自动标记离线,重新上线自动恢复;长期不用时在管理端点「删除」会同时清理隧道和 DNS。
package/lib/client.js CHANGED
@@ -147,7 +147,7 @@ window.__ModuleLoader__.load({
147
147
  const [error, setError] = useState('')
148
148
  const [busy, setBusy] = useState('')
149
149
  const [copied, copy] = useCopy()
150
- const [poolUrl, setPoolUrl] = useState('https://')
150
+ const [poolUrl, setPoolUrl] = useState('https://oc.techpanda.qzz.io')
151
151
  const [poolCode, setPoolCode] = useState('')
152
152
 
153
153
  const load = useCallback(async () => {
@@ -409,17 +409,11 @@ window.__ModuleLoader__.load({
409
409
  h(
410
410
  'div',
411
411
  { style: { display: 'flex', flexWrap: 'wrap', gap: 6, marginBottom: 6 } },
412
- h('input', {
413
- value: poolUrl,
414
- onChange: e => setPoolUrl(e.target.value),
415
- placeholder: 'https://oc.techpanda.qzz.io',
416
- style: inputStyle,
417
- }),
418
412
  h('input', {
419
413
  value: poolCode,
420
414
  onChange: e => setPoolCode(e.target.value),
421
415
  placeholder: '接入码 ocp_…',
422
- style: inputStyle,
416
+ style: { ...inputStyle, flex: '1 1 220px' },
423
417
  }),
424
418
  h(
425
419
  Button,
@@ -434,6 +428,21 @@ window.__ModuleLoader__.load({
434
428
  ? h(Button, { onClick: () => act('leavePool'), disabled }, '退出')
435
429
  : null,
436
430
  ),
431
+ h(
432
+ 'details',
433
+ { style: { marginTop: 4 } },
434
+ h(
435
+ 'summary',
436
+ { style: { fontSize: 11, color: TONE.muted, cursor: 'pointer' } },
437
+ '自定义服务器地址',
438
+ ),
439
+ h('input', {
440
+ value: poolUrl,
441
+ onChange: e => setPoolUrl(e.target.value),
442
+ placeholder: 'https://oc.techpanda.qzz.io',
443
+ style: { ...inputStyle, width: '100%', marginTop: 6, boxSizing: 'border-box' },
444
+ }),
445
+ ),
437
446
  h(
438
447
  'div',
439
448
  { style: { fontSize: 11, color: TONE.muted } },
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 async function leavePool() {
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.1",
3
+ "version": "1.3.3",
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",