dsh-remote-plugin 0.8.0-rc.8 → 0.8.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.
Files changed (58) hide show
  1. package/README.en.md +12 -5
  2. package/README.md +12 -5
  3. package/apk/dsh-remote.apk +0 -0
  4. package/gateway.cjs +402 -165
  5. package/index.mjs +49 -20
  6. package/insights.mjs +33 -2
  7. package/package.json +2 -1
  8. package/plugin-center.mjs +12 -3
  9. package/plugin-transaction.mjs +18 -2
  10. package/public/admin.html +1 -1
  11. package/public/admin.js +2 -1
  12. package/public/app.js +296 -97
  13. package/public/approval-records.js +229 -0
  14. package/public/build.json +2 -2
  15. package/public/desktop/desktop.css +53 -1
  16. package/public/desktop/desktop.html +40 -2
  17. package/public/desktop/desktop.js +197 -60
  18. package/public/doctor-entry.js +33 -4
  19. package/public/doctor.js +41 -13
  20. package/public/extensions.css +96 -1
  21. package/public/extensions.js +43 -5
  22. package/public/index.html +45 -9
  23. package/public/insights.css +5 -0
  24. package/public/insights.js +40 -11
  25. package/public/md.js +7 -1
  26. package/public/onboarding.css +36 -0
  27. package/public/onboarding.js +253 -0
  28. package/public/operations.js +1 -1
  29. package/public/permission-presets.js +159 -0
  30. package/public/plugin-center.css +3 -0
  31. package/public/plugin-center.js +58 -9
  32. package/public/plugin.html +1 -1
  33. package/public/plugin.js +5 -1
  34. package/public/skills.js +16 -5
  35. package/public/skins/blue-fish/skin.css +51 -0
  36. package/public/styles.css +43 -1
  37. package/public/task-board.js +109 -0
  38. package/public/teams.js +35 -13
  39. package/public/theme.js +5 -11
  40. package/public/turn-results.js +2 -0
  41. package/public/update.json +8 -8
  42. package/public/version.json +1 -1
  43. package/public/workflow.css +6 -12
  44. package/public/workflow.js +13 -4
  45. package/skills/dsh-remote-doctor/SKILL.md +16 -0
  46. package/skills/dsh-remote-doctor/references/wiki/README.md +40 -0
  47. package/skills/dsh-remote-doctor/references/wiki/ai-guide.md +61 -0
  48. package/skills/dsh-remote-doctor/references/wiki/connection.md +74 -0
  49. package/skills/dsh-remote-doctor/references/wiki/errors.md +26 -0
  50. package/skills/dsh-remote-doctor/references/wiki/evidence.md +44 -0
  51. package/skills/dsh-remote-doctor/references/wiki/files.md +31 -0
  52. package/skills/dsh-remote-doctor/references/wiki/maintenance.md +30 -0
  53. package/skills/dsh-remote-doctor/references/wiki/notifications.md +29 -0
  54. package/skills/dsh-remote-doctor/references/wiki/operations.md +32 -0
  55. package/skills/dsh-remote-doctor/references/wiki/plugins.md +69 -0
  56. package/skills/dsh-remote-doctor/references/wiki/sessions.md +45 -0
  57. package/skills/dsh-remote-doctor/references/wiki/sources.md +27 -0
  58. package/task-board.mjs +57 -0
package/index.mjs CHANGED
@@ -12,9 +12,11 @@ import net from 'node:net'
12
12
  import { homedir, hostname, networkInterfaces } from 'node:os'
13
13
  import { dirname, extname, normalize, resolve } from 'node:path'
14
14
  import { fileURLToPath } from 'node:url'
15
+ import { randomUUID } from 'node:crypto'
15
16
  import { createPluginCenter, detectProfile } from './plugin-center.mjs'
16
17
  import { readCostInsights } from './insights.mjs'
17
18
  import { readTeamInsights } from './teams.mjs'
19
+ import { readTaskBoard } from './task-board.mjs'
18
20
  import { readPeakReminders } from './peak-reminders.mjs'
19
21
  import { serveSessionFile } from './session-file.mjs'
20
22
  import { createSkillsAdapter } from './skills.mjs'
@@ -187,16 +189,20 @@ function sendJson(res, status, body) {
187
189
 
188
190
  function readBody(req, maxBytes) {
189
191
  return new Promise((resolvePromise, reject) => {
190
- let body = ''
192
+ const chunks = []; let size = 0, settled = false
191
193
  req.on('data', (chunk) => {
192
- body += chunk
193
- if (body.length > maxBytes) {
194
- reject(new Error('body too large'))
195
- req.destroy()
194
+ if (settled) return
195
+ size += chunk.length
196
+ if (size > maxBytes) {
197
+ settled = true; chunks.length = 0
198
+ reject(Object.assign(new Error('body too large'), { status: 413 }))
199
+ return
196
200
  }
201
+ chunks.push(chunk)
197
202
  })
198
- req.on('end', () => resolvePromise(body))
203
+ req.on('end', () => { if (!settled) { settled = true; resolvePromise(Buffer.concat(chunks).toString('utf8')) } })
199
204
  req.on('error', reject)
205
+ req.once('aborted', () => reject(Object.assign(new Error('request aborted'), { status: 400 })))
200
206
  })
201
207
  }
202
208
 
@@ -296,13 +302,20 @@ async function probeGatewayRunning(base) {
296
302
  const res = await fetch(`${base}/health?probe=live`, { signal: AbortSignal.timeout(6000) })
297
303
  if (!res.ok) return { running: false }
298
304
  const data = await res.json().catch(() => ({}))
299
- if (data.service !== 'dsh-remote' || !Number.isInteger(data.pid) || data.pid <= 1
300
- || typeof data.version !== 'string' || typeof data.upstream !== 'string'
301
- || !data.events?.mux || !data.events?.host) return { running: false }
305
+ // Early 0.7.x live probes deliberately omit readiness/upstream fields.
306
+ // Recognize that exact compact shape without invoking the old, blocking
307
+ // full health check. Public health never authorizes a PID kill: takeover
308
+ // still requires the existing token and /admin/api/shutdown below.
309
+ const compact = data.ok === true && data.probe === 'live' && data.liveness?.ok === true
310
+ && !Object.hasOwn(data, 'pid') && !Object.hasOwn(data, 'upstream') && !Object.hasOwn(data, 'events')
311
+ const pid = compact ? data.liveness.pid : data.pid
312
+ if (data.service !== 'dsh-remote' || !Number.isInteger(pid) || pid <= 1
313
+ || typeof data.version !== 'string' || !data.version
314
+ || (!compact && (typeof data.upstream !== 'string' || !data.events?.mux || !data.events?.host))) return { running: false }
302
315
  return {
303
316
  running: true,
304
317
  base,
305
- pid: Number(data.pid) || 0,
318
+ pid,
306
319
  version: typeof data.version === 'string' ? data.version : '',
307
320
  upstream: typeof data.upstream === 'string' ? data.upstream : '',
308
321
  upstreamOk: data.upstreamOk === true,
@@ -561,7 +574,7 @@ async function resolveAgent(ctx, sessionId) {
561
574
  if (!handle || !handle.agent) return { agent: null, resolvePath: 'resume-empty-handle' }
562
575
  return { agent: handle.agent, resolvePath: 'resume' }
563
576
  } catch (e) {
564
- return { agent: null, resolvePath: 'resume-error: ' + (e?.message || String(e)) }
577
+ return { agent: null, resolvePath: 'resume-error' }
565
578
  }
566
579
  }
567
580
 
@@ -590,12 +603,14 @@ function remoteCommandAuthorized(req) {
590
603
  function commandOperationSnapshot(operation) {
591
604
  if (!operation) return { active: false, phase: 'idle', command: '', startedAt: 0, endedAt: 0, message: '' }
592
605
  return {
606
+ id: operation.id,
593
607
  active: operation.active === true,
594
608
  phase: operation.phase || 'idle',
595
609
  command: String(operation.command || ''),
596
610
  startedAt: Number(operation.startedAt) || 0,
597
611
  endedAt: Number(operation.endedAt) || 0,
598
612
  message: String(operation.message || ''),
613
+ ...(typeof operation.executed === 'boolean' ? { executed: operation.executed } : {}),
599
614
  }
600
615
  }
601
616
 
@@ -611,7 +626,7 @@ function beginCommandOperation(ctx, agent, sessionId, line, command) {
611
626
  if (existing.line !== line) throw new Error('当前会话已有命令正在执行,请等待完成后再提交。')
612
627
  return { operation: existing, reused: true }
613
628
  }
614
- const operation = { active: true, phase: 'running', command, line, startedAt: Date.now(), endedAt: 0, message: '' }
629
+ const operation = { id: randomUUID(), active: true, phase: 'running', command, line, startedAt: Date.now(), endedAt: 0, message: '' }
615
630
  commandOperations.set(sessionId, operation)
616
631
  // 不把已登记命令绑定到 HTTP 超时:真实 command/done 才是完成边界。
617
632
  // 处理器仍接收可用 AbortSignal,以符合命令执行器的契约。
@@ -619,13 +634,14 @@ function beginCommandOperation(ctx, agent, sessionId, line, command) {
619
634
  void executeRegisteredCommand(ctx, agent, line, signal).then((result) => {
620
635
  operation.active = false
621
636
  operation.endedAt = Date.now()
622
- operation.phase = result?.result?.kind === 'error' ? 'failed' : 'complete'
623
- operation.message = String(result?.result?.text || '')
637
+ operation.executed = commandWasExecuted(result)
638
+ operation.phase = !operation.executed || result?.result?.kind === 'error' ? 'failed' : 'complete'
639
+ operation.message = operation.phase === 'failed' ? (operation.executed ? 'command-failed' : 'command-not-executed') : String(result?.result?.text || '').slice(0, 2000)
624
640
  }, (error) => {
625
641
  operation.active = false
626
642
  operation.endedAt = Date.now()
627
643
  operation.phase = 'failed'
628
- operation.message = error?.message || String(error)
644
+ operation.message = 'command-failed'
629
645
  }).finally(() => {
630
646
  const cleanup = setTimeout(() => {
631
647
  if (commandOperations.get(sessionId) === operation && !operation.active) commandOperations.delete(sessionId)
@@ -721,6 +737,13 @@ async function serveStatic(req, res, ctx) {
721
737
  const result = await adapter.handle(req.method, pathname.slice(`${MOUNT}/api/skills`.length), url.searchParams)
722
738
  return sendJson(res, result.status, result.body)
723
739
  }
740
+ if (pathname === `${MOUNT}/api/task-board`) {
741
+ res.setHeader('cache-control', 'no-store')
742
+ if (!remoteCommandAuthorized(req)) return sendJson(res, 401, { ok: false, code: 'unauthorized' })
743
+ if (req.method !== 'GET') return sendJson(res, 405, { ok: false, code: 'read-only' })
744
+ const result = await readTaskBoard(ctx, new URL(req.url, 'http://x').searchParams)
745
+ return sendJson(res, result.status, result.body)
746
+ }
724
747
  if (pathname === `${MOUNT}/api/teams`) {
725
748
  res.setHeader('cache-control', 'no-store')
726
749
  if (!remoteCommandAuthorized(req)) return sendJson(res, 401, { ok: false, code: 'unauthorized' })
@@ -753,6 +776,7 @@ async function serveStatic(req, res, ctx) {
753
776
  return sendJson(res, result.status, result.body)
754
777
  }
755
778
  if (pathname.startsWith(`${MOUNT}/api/plugins/`)) {
779
+ res.setHeader('cache-control', 'no-store')
756
780
  if (!remoteCommandAuthorized(req)) return sendJson(res, 401, { ok: false, message: 'unauthorized' })
757
781
  try {
758
782
  const url = new URL(req.url, 'http://x')
@@ -1025,8 +1049,8 @@ async function serveStatic(req, res, ctx) {
1025
1049
  let body
1026
1050
  try {
1027
1051
  body = JSON.parse((await readBody(req, 8192)) || '{}')
1028
- } catch {
1029
- sendJson(res, 400, { ok: false, message: 'invalid json' })
1052
+ } catch (error) {
1053
+ sendJson(res, error.status === 413 ? 413 : 400, { ok: false, message: error.status === 413 ? 'body too large' : 'invalid json' })
1030
1054
  return
1031
1055
  }
1032
1056
  const { sessionId, line } = body || {}
@@ -1047,7 +1071,7 @@ async function serveStatic(req, res, ctx) {
1047
1071
  commandEntries = Array.isArray(listed) ? listed : null
1048
1072
  commandNames = commandEntries ? commandEntries.map(commandEntryName).filter(Boolean) : []
1049
1073
  } catch (e) {
1050
- commandNames = ['list-error: ' + (e?.message || String(e))]
1074
+ commandNames = ['list-error']
1051
1075
  }
1052
1076
  const name = commandHead(line)
1053
1077
  if (commandEntries && (!name || !commandEntries.some(entry => commandEntryName(entry) === name))) {
@@ -1077,7 +1101,7 @@ async function serveStatic(req, res, ctx) {
1077
1101
  const result = await executeRegisteredCommand(ctx, agent, line, signal)
1078
1102
  sendJson(res, 200, { ok: true, executed: commandWasExecuted(result), debug: { resolvePath, commandNames } })
1079
1103
  } catch (e) {
1080
- sendJson(res, 200, { ok: false, message: e?.message || String(e) })
1104
+ sendJson(res, 200, { ok: false, message: 'command-failed' })
1081
1105
  }
1082
1106
  return
1083
1107
  }
@@ -1176,7 +1200,12 @@ export function apply(ctx) {
1176
1200
  ctx.effect(() => ctx.webServer.register({
1177
1201
  kind: 'prefix',
1178
1202
  path: MOUNT,
1179
- handler: (req, res) => serveStatic(req, res, ctx),
1203
+ handler: (req, res) => serveStatic(req, res, ctx).catch(error => {
1204
+ if (res.writableEnded || res.destroyed) return
1205
+ if (res.headersSent) return res.destroy()
1206
+ if (error.status === 413) res.setHeader('connection', 'close')
1207
+ sendJson(res, error.status || (error instanceof SyntaxError ? 400 : 500), { ok: false, message: error.status === 413 ? 'body too large' : 'request-failed' })
1208
+ }),
1180
1209
  }), 'dsh-remote: /remote route')
1181
1210
  // 实时统计: 监听 DSH 会话事件流, 把带 usage 的 assistant/message 投递到网关聚合
1182
1211
  ctx.on('session/event', (session, event) => {
package/insights.mjs CHANGED
@@ -3,7 +3,37 @@ const states = new WeakMap()
3
3
  const record = value => value && typeof value === 'object' && !Array.isArray(value) ? value : {}
4
4
  const number = value => typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : null
5
5
  const text = (value, max = 80) => typeof value === 'string' ? value.slice(0, max) : ''
6
- const status = value => ['ok', 'off', 'error', 'stale', 'loading'].includes(value) ? value : 'unknown'
6
+ const status = value => ['ok', 'off', 'error', 'stale', 'loading', 'partial'].includes(value) ? value : 'unknown'
7
+ const visible = value => value?.enabled === true && value.display !== 'off'
8
+ const unit = value => ['USD', 'CNY', 'EUR', 'CREDITS'].includes(value) ? value : ''
9
+ function customBalances(raw, config) {
10
+ const multiple = Array.isArray(config.customBalances)
11
+ const definitions = multiple ? config.customBalances : [config.customBalance]
12
+ const snapshots = multiple ? (Array.isArray(raw.customBalances) ? raw.customBalances : []) : [raw.customBalance]
13
+ return snapshots.slice(0, 40).flatMap(value => {
14
+ const row = record(value), index = multiple ? row.index : 0
15
+ if (!Number.isInteger(index) || index < 0 || !visible(definitions[index])) return []
16
+ return [{ name: text(row.label || definitions[index].label), status: status(row.status), fetchedAt: number(row.fetchedAt),
17
+ currency: unit(row.unit), remaining: typeof row.remaining === 'number' && Number.isFinite(row.remaining) ? row.remaining : null,
18
+ maxBudget: number(row.maxBudget), spend: number(row.spend) }]
19
+ })
20
+ }
21
+ function gatewayQuotas(raw, config) {
22
+ const definitions = Array.isArray(config.gatewayQuotas?.sources) ? config.gatewayQuotas.sources : []
23
+ return (Array.isArray(raw.gatewayQuotas) ? raw.gatewayQuotas : []).slice(0, 20).flatMap(value => {
24
+ const row = record(value)
25
+ if (!visible(definitions.find(source => source?.id === row.id))) return []
26
+ return [{ name: text(row.label), status: status(row.status), fetchedAt: number(row.fetchedAt),
27
+ accounts: (Array.isArray(row.accounts) ? row.accounts : []).slice(0, 16).map(value => {
28
+ const account = record(value)
29
+ return { name: text(account.label), provider: text(account.provider), status: status(account.status),
30
+ windows: (Array.isArray(account.windows) ? account.windows : []).slice(0, 8).map(value => {
31
+ const w = record(value), percent = number(w.percent)
32
+ return { name: text(w.label || w.id), percent: percent !== null && percent <= 100 ? percent : null, resetsAt: text(w.resetsAt) }
33
+ }) }
34
+ }) }]
35
+ })
36
+ }
7
37
  function amount(value) {
8
38
  const row = record(value)
9
39
  const tokens = Object.fromEntries(['input', 'cacheRead', 'cacheWrite', 'output'].map(key => [key, number(row[key])]))
@@ -41,7 +71,8 @@ export function summarizeCost(state, session, sessionId) {
41
71
  subagents: s.found === true ? amount(s.subagents) : null, subagentCount: number(s.subagentCount) } : null,
42
72
  balance: config.hideOfficialBalance === true || record(config.balance).display === 'off' ? null : {
43
73
  status: status(balance.status), fetchedAt: number(balance.fetchedAt),
44
- currency: /^[A-Z]{3}$/.test(balance.currency) ? balance.currency : '', total: number(balance.totalBalance) }, plans }
74
+ currency: /^[A-Z]{3}$/.test(balance.currency) ? balance.currency : '', total: number(balance.totalBalance) }, plans,
75
+ customBalances: customBalances(raw, config), gatewayQuotas: gatewayQuotas(raw, config) }
45
76
  }
46
77
  function bounded(task, ms = 20000) {
47
78
  let timer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-remote-plugin",
3
- "version": "0.8.0-rc.8",
3
+ "version": "0.8.0",
4
4
  "description": "DSH Remote 官方 bundle 插件:DSH 左侧原生边栏入口 + 右侧抽屉内嵌管理控制台;内置网关随 DSH 自动启停(systemd 独立单元),抽屉直显令牌与设备监控;网关提供 /fs/* 文件传输端点(列表/断点下载/上传),配合 Android App 远程操控会话/审批/提问/goal 与文件互传(多服务器测速切换、聊天记录离线缓存)。",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",
@@ -24,6 +24,7 @@
24
24
  "market.mjs",
25
25
  "insights.mjs",
26
26
  "teams.mjs",
27
+ "task-board.mjs",
27
28
  "peak-reminders.mjs",
28
29
  "skills.mjs",
29
30
  "doctor-skill.mjs",
package/plugin-center.mjs CHANGED
@@ -4,7 +4,7 @@ import { dirname, basename, join, resolve } from 'node:path'
4
4
  import { fileURLToPath } from 'node:url'
5
5
  import { createHash } from 'node:crypto'
6
6
  import { spawn, execFile } from 'node:child_process'
7
- import { prepareReleasePlan, profileRevision, backupTransaction, writeWorkspace, mergeReleaseRules, releasePolicy, verifyInstalled, treeDigest, restoreTransaction } from './plugin-transaction.mjs'
7
+ import { prepareReleasePlan, profileRevision, backupTransaction, writeWorkspace, mergeReleaseRules, releasePolicy, verifyInstalled, treeDigest, restoreTransaction, canonicalPath } from './plugin-transaction.mjs'
8
8
  import { createMarketAdapter, createReadmeReader } from './market.mjs'
9
9
 
10
10
  const REGISTRY = 'https://registry.npmjs.org'
@@ -21,6 +21,15 @@ function atomic(path, value) {
21
21
  const fail = (message, status = 400) => Object.assign(new Error(message), { status })
22
22
  const protectedPackage = name => name === 'dsh-remote-plugin' || name.startsWith('@deepseek-ai/')
23
23
  const revision = path => createHash('sha256').update(readFileSync(path)).digest('hex')
24
+ function adapterInterfaces(ctx) {
25
+ // Shape checks only: never query balances, read content or activate sessions.
26
+ const result = {}
27
+ for (const [id, name, method] of [['cost', 'costMeter', 'getState'], ['tasks', 'taskBoard', 'snapshot']]) {
28
+ try { const service = ctx.get?.(name); result[id] = { supported: service ? typeof service[method] === 'function' : null } }
29
+ catch { result[id] = { supported: null } }
30
+ }
31
+ return result
32
+ }
24
33
  // A detached worker can replace/delete its ledger between two manager reads.
25
34
  // Windows sharing violations are uncertain ownership, never proof of death.
26
35
  function ownershipText(path) {
@@ -284,7 +293,7 @@ export function createPluginCenter(ctx, options = {}) {
284
293
  const ownerText = ownershipText(lockPath)
285
294
  const owner = ownerText === null ? null : ownerText === undefined ? {} : JSON.parse(ownerText)
286
295
  const legacyLock = owner && idPattern.test(owner.id || '') && !owner.launcherPid && !owner.workerPid && !owner.cliPid && !existsSync(join(storage, 'launch-' + owner.id + '.json'))
287
- return { ok: true, profile: profile.name, revision: revision(manifestPath), writable: !!profile.cli,
296
+ return { ok: true, profile: profile.name, revision: revision(manifestPath), writable: !!profile.cli, adaptations: adapterInterfaces(ctx),
288
297
  reason: profile.cli ? '' : profile.name === 'desktop'
289
298
  ? '未能验证当前桌面安装的插件管理入口;仅显示状态,请检查 DSH Desktop 版本与安装完整性。'
290
299
  : '当前启动方式没有可验证的 DSH CLI,管理操作不可用。',
@@ -575,6 +584,6 @@ function runCli(cli, args, dir, output, onSpawn, cliMode) {
575
584
  })
576
585
  }
577
586
 
578
- if (process.argv[1] && resolve(process.argv[1]) === SELF && process.argv[2] === '--worker') {
587
+ if (process.argv[2] === '--worker' && process.argv[1] && canonicalPath(process.argv[1]) === canonicalPath(SELF)) {
579
588
  await runWorker(process.argv[3], process.argv[4], process.argv[5], undefined, process.argv[6])
580
589
  }
@@ -142,16 +142,32 @@ export async function prepareReleasePlan(dir, operation, publishedTimes, env = p
142
142
  return { revision: before, minutes: policy.minutes, blockers, ruleChanges: merged.changes, workspace: merged.raw, baselineWarning,
143
143
  action: operation.action, name: operation.name, version: operation.version || '', expiresAt: Date.now() + 10 * 60000 }
144
144
  }
145
- function inside(root, path) { const rel = relative(resolve(root), resolve(path)); if (isAbsolute(rel) || rel === '..' || rel.startsWith('..\\') || rel.startsWith('../')) throw error('快照路径越界。') }
145
+ export function canonicalPath(value) {
146
+ let current = resolve(value)
147
+ const suffix = []
148
+ while (true) {
149
+ try { return join(realpathSync(current), ...suffix) }
150
+ catch (err) {
151
+ const parent = dirname(current)
152
+ if (!['ENOENT', 'ENOTDIR'].includes(err.code) || parent === current) throw err
153
+ suffix.unshift(current.slice(parent.length).replace(/^[\\/]+/, '')); current = parent
154
+ }
155
+ }
156
+ }
157
+ function inside(root, path) { const rel = relative(canonicalPath(root), canonicalPath(path)); if (isAbsolute(rel) || rel === '..' || rel.startsWith('..\\') || rel.startsWith('../')) throw error('快照路径越界。') }
146
158
  export function treeDigest(root, { localRoot = join(dirname(root), 'local-plugins'), localSnapshotRoot = localRoot, linkIdentityRoot = root, linkedPaths } = {}) {
147
159
  if (!existsSync(root)) return null
160
+ root = canonicalPath(root)
161
+ localRoot = localRoot && canonicalPath(localRoot)
162
+ localSnapshotRoot = localSnapshotRoot && canonicalPath(localSnapshotRoot)
163
+ linkIdentityRoot = canonicalPath(linkIdentityRoot)
148
164
  const digest = createHash('sha256')
149
165
  function walk(dir) {
150
166
  for (const entry of readdirSync(dir).sort()) {
151
167
  const file = join(dir, entry), info = lstatSync(file)
152
168
  digest.update(relative(root, file).replaceAll('\\', '/') + '\0')
153
169
  if (info.isSymbolicLink()) {
154
- const target = resolve(dirname(join(linkIdentityRoot, relative(root, file))), readlinkSync(file)), rel = relative(resolve(linkIdentityRoot), target)
170
+ const target = canonicalPath(resolve(dirname(join(linkIdentityRoot, relative(root, file))), readlinkSync(file))), rel = relative(linkIdentityRoot, target)
155
171
  if (isAbsolute(rel) || rel === '..' || rel.startsWith('..\\') || rel.startsWith('../')) {
156
172
  // Desktop's bundled local plugins use junctions outside node_modules.
157
173
  // Only the same profile's local-plugins is an allowed second root.
package/public/admin.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
6
6
  <meta name="theme-color" content="#0D1117">
7
7
  <title>DSH Remote · 管理</title>
8
- <script>/* 首帧前应用皮肤 */ (function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'&&t!=='fish'){t=window.matchMedia('(prefers-color-scheme: light)').matches?'light':'default'}document.documentElement.setAttribute('data-theme',t)}catch(e){}})()</script>
8
+ <script>/* 首帧前应用皮肤 */ (function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'&&t!=='fish'){t='fish'}}catch(e){t='fish'}document.documentElement.setAttribute('data-theme',t)})()</script>
9
9
  <link rel="stylesheet" href="../styles.css">
10
10
  <link rel="stylesheet" href="../relay-settings.css">
11
11
  <link rel="stylesheet" href="../insights.css">
package/public/admin.js CHANGED
@@ -1054,7 +1054,8 @@ $('modal-donate').addEventListener('click', (e) => { if (e.target === $('modal-d
1054
1054
  $('btn-feedback').addEventListener('click', (e) => { e.stopPropagation(); toggleFeedbackMenu() })
1055
1055
  for(const id of ['btn-ai-doctor','admin-doctor'])$(id)?.addEventListener('click', () => {
1056
1056
  closeFeedbackMenu()
1057
- window.DshDoctorEntry?.open({state:()=>lastState,pluginMode,token:()=>token,copy:async text=>{try{await navigator.clipboard.writeText(text);return true}catch{return false}},toast})
1057
+ if(typeof window.DshDoctorEntry?.open!=='function'){toast('诊疗组件未能加载,请刷新页面后重试。','err');return}
1058
+ window.DshDoctorEntry.open({state:()=>lastState,pluginMode,token:()=>token,copy:async text=>{try{await navigator.clipboard.writeText(text);return true}catch{return false}},toast})
1058
1059
  })
1059
1060
  $('fb-menu').addEventListener('click', (e) => {
1060
1061
  if (e.target.closest('a[role="menuitem"]')) closeFeedbackMenu()