dsh-remote-plugin 0.8.0-rc.9 → 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 (42) hide show
  1. package/README.en.md +2 -0
  2. package/README.md +2 -0
  3. package/apk/dsh-remote.apk +0 -0
  4. package/gateway.cjs +1 -0
  5. package/index.mjs +20 -4
  6. package/insights.mjs +33 -2
  7. package/package.json +2 -1
  8. package/plugin-center.mjs +10 -1
  9. package/public/app.js +5 -0
  10. package/public/build.json +2 -2
  11. package/public/desktop/desktop.css +1 -1
  12. package/public/desktop/desktop.html +1 -0
  13. package/public/desktop/desktop.js +5 -0
  14. package/public/extensions.css +96 -1
  15. package/public/extensions.js +43 -5
  16. package/public/index.html +1 -0
  17. package/public/insights.css +5 -0
  18. package/public/insights.js +40 -11
  19. package/public/md.js +7 -1
  20. package/public/plugin-center.css +3 -0
  21. package/public/plugin-center.js +58 -9
  22. package/public/skills.js +16 -5
  23. package/public/skins/blue-fish/skin.css +39 -0
  24. package/public/task-board.js +109 -0
  25. package/public/teams.js +35 -13
  26. package/public/update.json +8 -8
  27. package/public/version.json +1 -1
  28. package/public/workflow.css +6 -12
  29. package/skills/dsh-remote-doctor/SKILL.md +16 -0
  30. package/skills/dsh-remote-doctor/references/wiki/README.md +40 -0
  31. package/skills/dsh-remote-doctor/references/wiki/ai-guide.md +61 -0
  32. package/skills/dsh-remote-doctor/references/wiki/connection.md +74 -0
  33. package/skills/dsh-remote-doctor/references/wiki/errors.md +26 -0
  34. package/skills/dsh-remote-doctor/references/wiki/evidence.md +44 -0
  35. package/skills/dsh-remote-doctor/references/wiki/files.md +31 -0
  36. package/skills/dsh-remote-doctor/references/wiki/maintenance.md +30 -0
  37. package/skills/dsh-remote-doctor/references/wiki/notifications.md +29 -0
  38. package/skills/dsh-remote-doctor/references/wiki/operations.md +32 -0
  39. package/skills/dsh-remote-doctor/references/wiki/plugins.md +69 -0
  40. package/skills/dsh-remote-doctor/references/wiki/sessions.md +45 -0
  41. package/skills/dsh-remote-doctor/references/wiki/sources.md +27 -0
  42. package/task-board.mjs +57 -0
package/README.en.md CHANGED
@@ -4,6 +4,8 @@ The DSH bundle plugin for DSH Remote adds a sidebar entry, status panel, admin c
4
4
 
5
5
  [English](README.en.md) · [中文](README.md)
6
6
 
7
+ The [operation and troubleshooting knowledge base (Chinese)](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/wiki/README.md) provides task, symptom and error-code navigation. Offline copies ship in `skills/dsh-remote-doctor/references/wiki/` for the bundled Doctor; external AI assistants can start from the repository's llms.txt.
8
+
7
9
  ## Install and connect
8
10
 
9
11
  ```sh
package/README.md CHANGED
@@ -4,6 +4,8 @@ DSH Remote 的 DSH bundle 插件:提供侧栏入口、快速面板、管理控
4
4
 
5
5
  **中文** · [English](README.en.md)
6
6
 
7
+ [操作与排障知识库](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/wiki/README.md)按任务、症状和错误码导航;用户 AI 可从仓库根 llms.txt 开始。包内离线副本位于 `skills/dsh-remote-doctor/references/wiki/`,内置 Doctor 按需读取并引用 KB 编号。
8
+
7
9
  ## 安装与连接
8
10
 
9
11
  ```sh
Binary file
package/gateway.cjs CHANGED
@@ -6382,6 +6382,7 @@ function proxyApi(req, res, url) {
6382
6382
  || (url.pathname === '/remote/api/insights/cost' && req.method === 'GET')
6383
6383
  || (url.pathname === '/remote/api/insights/peak-reminders' && req.method === 'GET')
6384
6384
  || (url.pathname === '/remote/api/teams' && req.method === 'GET')
6385
+ || (url.pathname === '/remote/api/task-board' && req.method === 'GET')
6385
6386
  || (url.pathname === '/remote/api/doctor/target' && req.method === 'GET')
6386
6387
  || /^\/remote\/api\/skills\/(list|read)$/.test(url.pathname)
6387
6388
  || /^\/remote\/api\/plugins\/(state|details|readme|market(?:\/indexes)?|operations|preflight|recover)$/.test(url.pathname)
package/index.mjs CHANGED
@@ -16,6 +16,7 @@ import { randomUUID } from 'node:crypto'
16
16
  import { createPluginCenter, detectProfile } from './plugin-center.mjs'
17
17
  import { readCostInsights } from './insights.mjs'
18
18
  import { readTeamInsights } from './teams.mjs'
19
+ import { readTaskBoard } from './task-board.mjs'
19
20
  import { readPeakReminders } from './peak-reminders.mjs'
20
21
  import { serveSessionFile } from './session-file.mjs'
21
22
  import { createSkillsAdapter } from './skills.mjs'
@@ -301,13 +302,20 @@ async function probeGatewayRunning(base) {
301
302
  const res = await fetch(`${base}/health?probe=live`, { signal: AbortSignal.timeout(6000) })
302
303
  if (!res.ok) return { running: false }
303
304
  const data = await res.json().catch(() => ({}))
304
- if (data.service !== 'dsh-remote' || !Number.isInteger(data.pid) || data.pid <= 1
305
- || typeof data.version !== 'string' || typeof data.upstream !== 'string'
306
- || !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 }
307
315
  return {
308
316
  running: true,
309
317
  base,
310
- pid: Number(data.pid) || 0,
318
+ pid,
311
319
  version: typeof data.version === 'string' ? data.version : '',
312
320
  upstream: typeof data.upstream === 'string' ? data.upstream : '',
313
321
  upstreamOk: data.upstreamOk === true,
@@ -729,6 +737,13 @@ async function serveStatic(req, res, ctx) {
729
737
  const result = await adapter.handle(req.method, pathname.slice(`${MOUNT}/api/skills`.length), url.searchParams)
730
738
  return sendJson(res, result.status, result.body)
731
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
+ }
732
747
  if (pathname === `${MOUNT}/api/teams`) {
733
748
  res.setHeader('cache-control', 'no-store')
734
749
  if (!remoteCommandAuthorized(req)) return sendJson(res, 401, { ok: false, code: 'unauthorized' })
@@ -761,6 +776,7 @@ async function serveStatic(req, res, ctx) {
761
776
  return sendJson(res, result.status, result.body)
762
777
  }
763
778
  if (pathname.startsWith(`${MOUNT}/api/plugins/`)) {
779
+ res.setHeader('cache-control', 'no-store')
764
780
  if (!remoteCommandAuthorized(req)) return sendJson(res, 401, { ok: false, message: 'unauthorized' })
765
781
  try {
766
782
  const url = new URL(req.url, 'http://x')
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.9",
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
@@ -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,管理操作不可用。',
package/public/app.js CHANGED
@@ -8365,6 +8365,11 @@ function openPluginPage(route = 'manage') {
8365
8365
  connection,getWorkspaces: () => workspaceItems(),
8366
8366
  getWorkspaceId: () => workspaceById(state.workspaceFilter)?.workspaceId || workspaceForSession(state.byId.get(state.current))?.workspaceId || '',
8367
8367
  openTeamCaptain: async id => { if (!connection.valid()) return; await openSession(id) },
8368
+ openTaskSession: async (id, workspaceId) => {
8369
+ if (!connection.valid() || $('view-plugins').classList.contains('hidden')) return
8370
+ if (!workspaceItems().some(row => row.workspaceId === workspaceId)) throw Error('unavailable')
8371
+ await openSession(id)
8372
+ },
8368
8373
  openTeamMember: async (id, parentId) => {
8369
8374
  const selected = state.current
8370
8375
  const catalog = await loadSessionSubagents(parentId)
package/public/build.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schema": 1,
3
- "version": "0.8.0-rc.9",
4
- "buildId": "a055b6753d1582f33e402a5c2225a10678d9cc05bde917415410d4d2f186c925"
3
+ "version": "0.8.0",
4
+ "buildId": "8d8653b774000d520d22face4d8f4eb7f6753ad82ee07b8859a536d8d1e3607c"
5
5
  }
@@ -414,7 +414,7 @@ button.ds-overview-attention-item, button.ds-overview-session-item { cursor:poin
414
414
  background: var(--dsr-bg-2); border-color: var(--dsr-line); color: var(--dsr-text);
415
415
  }
416
416
  .ds-setting-name { font-size: 13.5px; font-weight: 600; }
417
- .ds-setting-desc { font-size: 12px; color: var(--dsr-muted); margin-top: 2px; word-break: break-all; }
417
+ .ds-setting-desc { font-size: 12px; color: var(--dsr-muted); margin-top: 2px; word-break: normal; overflow-wrap: break-word; text-wrap: pretty; }
418
418
  #token-desc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
419
419
  .ds-group-bar { display: flex; align-items: center; gap: 10px; padding: 2px 0; }
420
420
  .ds-group-bar > label { font-size: 12px; color: var(--dsr-muted); white-space: nowrap; }
@@ -839,6 +839,7 @@
839
839
  <script src="../skills.js"></script>
840
840
  <script src="../insights.js"></script>
841
841
  <script src="../teams.js"></script>
842
+ <script src="../task-board.js"></script>
842
843
  <script src="../extensions.js"></script>
843
844
  <script src="../sha256.js"></script>
844
845
  <script src="../diagnostics.js"></script>
@@ -4008,6 +4008,11 @@ function openDesktopPlugins(route = 'manage') {
4008
4008
  window.DshExtensions.mount({connection,getWorkspaces: () => state.workspaces || [],
4009
4009
  getWorkspaceId: () => (state.workspaces || []).find(w => (w.sessionIds || []).includes(state.current))?.workspaceId || '',
4010
4010
  openTeamCaptain: async id => { if (!connection.valid()) return; await openSession(id) },
4011
+ openTaskSession: async (id, workspaceId) => {
4012
+ if (!connection.valid() || state.view !== 'view-plugins') return
4013
+ if (!(state.workspaces || []).some(row => row.workspaceId === workspaceId)) throw Error('unavailable')
4014
+ await openSession(id)
4015
+ },
4011
4016
  openTeamMember: async (id, parentId) => {
4012
4017
  const selected = state.current
4013
4018
  const catalog = await loadSessionSubagents(parentId)
@@ -1 +1,96 @@
1
- .ext-page{min-width:0;width:100%;padding:16px;color:var(--dsr-text)}.ext-page.is-manage{padding:0}.ext-header{display:flex;gap:14px;align-items:center;justify-content:space-between;margin-bottom:24px;flex-wrap:wrap}.ext-host{min-width:0;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dsr-muted);font-size:13px;line-height:1.7}.ext-header button{flex-shrink:0;white-space:nowrap;color:var(--dsr-text);background:var(--dsr-panel);border:1px solid var(--dsr-line);border-radius:12px;font:inherit;min-height:44px;padding:10px 14px;cursor:pointer}.ext-header button:focus-visible{outline:2px solid var(--dsr-accent);outline-offset:3px}.ext-page [hidden]{display:none!important}@media(max-width:620px){.ext-page{padding:8px 0}.ext-header{margin-bottom:18px}}
1
+ /* Optional plugin views share the host theme and adapt to their container. */
2
+ .ext-page{min-width:0;width:100%;padding:16px;color:var(--dsr-text)}
3
+ .ext-page.is-manage{padding:0}
4
+ .ext-page,.ext-page *{box-sizing:border-box}
5
+ .ext-page [hidden]{display:none!important}
6
+ .ext-header{display:flex;gap:14px;align-items:center;justify-content:space-between;margin-bottom:28px;flex-wrap:wrap}
7
+ .ext-host{min-width:0;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dsr-muted);font-size:13px;line-height:1.7}
8
+ .ext-header button,.ext-button{display:inline-flex;gap:12px;align-items:center;justify-content:center;flex-shrink:0;min-height:44px;max-width:100%;padding:10px 15px;border:1px solid var(--dsr-line);border-radius:12px;color:var(--dsr-text);background:var(--dsr-panel);font:inherit;font-size:13px;line-height:1.5;text-align:center;text-decoration:none;cursor:pointer}
9
+ .ext-button:hover,.ext-header button:hover{background:var(--dsr-panel-2);border-color:var(--dsr-muted)}
10
+ .ext-button-primary{background:var(--dsr-accent-soft);border-color:var(--dsr-accent-line);color:var(--dsr-accent-strong)}
11
+ .ext-button-primary:hover{background:var(--dsr-accent-soft);border-color:var(--dsr-accent)}
12
+ .ext-button:disabled{opacity:.6;cursor:wait}
13
+ .ext-page :is(button,input,select,summary):focus-visible{outline:2px solid var(--dsr-accent);outline-offset:3px}
14
+ .teams-page,.task-board{container-type:inline-size;min-width:0;max-width:1080px;margin:0 auto;line-height:1.6}
15
+ .ext-heading{margin-bottom:24px;max-width:70ch}
16
+ .ext-eyebrow{display:block;color:var(--dsr-accent-strong);font-size:11px;font-weight:650;letter-spacing:.1em;margin-bottom:7px}
17
+ .ext-heading h2{font-size:clamp(24px,4vw,30px);line-height:1.3;letter-spacing:-.025em;margin:0;font-weight:700}
18
+ .ext-heading p{margin:10px 0 0;color:var(--dsr-muted);font-size:14px;line-height:1.8;text-wrap:pretty}
19
+ .ext-toolbar{display:flex;gap:16px;flex-wrap:wrap;align-items:end;padding:18px;background:var(--dsr-panel);border:1px solid var(--dsr-line);border-radius:16px}
20
+ .ext-field{display:flex;flex:1 1 130px;min-width:0;flex-direction:column;gap:7px;color:var(--dsr-muted);font-size:12px;font-weight:500}
21
+ .ext-workspace{flex-basis:200px}.ext-search{flex-basis:180px}
22
+ .ext-field :is(select,input){width:100%;min-width:0;max-width:100%;min-height:44px;border:1px solid var(--dsr-line);border-radius:10px;padding:10px 12px;font:inherit;font-size:14px;line-height:1.5;color:var(--dsr-text);background:var(--dsr-bg);text-overflow:ellipsis}
23
+ .ext-check{display:flex;gap:9px;align-items:center;min-height:44px;color:var(--dsr-muted);font-size:13px;line-height:1.5;cursor:pointer}
24
+ .ext-check input{width:17px;height:17px;flex-shrink:0;margin:0;accent-color:var(--dsr-accent)}
25
+ .ext-note{font-size:12px;line-height:1.8;color:var(--dsr-muted);margin:14px 2px;overflow-wrap:break-word;word-break:normal}
26
+ .task-scope{margin-bottom:0}.task-scope+.ext-note{margin-top:5px}
27
+ .task-summary{display:flex;gap:4px 16px;flex-wrap:wrap;align-items:baseline;justify-content:space-between;margin:5px 2px 14px}
28
+ .task-summary .ext-note{margin:0}
29
+ .teams-list,.task-list{display:grid;gap:20px;min-width:0}
30
+ .task-list{grid-template-columns:repeat(auto-fill,minmax(min(100%,360px),1fr));align-items:start}
31
+ .teams-card,.task-card{min-width:0;border:1px solid var(--dsr-line);background:var(--dsr-panel);border-radius:18px;padding:24px;overflow-wrap:break-word;word-break:normal}
32
+ .ext-panel-head{display:flex;justify-content:space-between;align-items:flex-start;gap:14px;min-width:0}
33
+ .ext-panel-head>h3,.ext-panel-head>strong{min-width:0;margin:0;font-size:18px;line-height:1.5;font-weight:650;overflow-wrap:anywhere}
34
+ .ext-badge{display:inline-flex;flex-shrink:0;max-width:50%;border:1px solid var(--dsr-line);border-radius:8px;background:var(--dsr-panel-2);padding:4px 9px;font-size:11px;font-weight:600;line-height:1.6;color:var(--dsr-muted);text-align:center}
35
+ .ext-badge[data-tone=active]{border-color:var(--dsr-accent-line);background:var(--dsr-accent-soft);color:var(--dsr-accent-strong)}
36
+ .ext-badge[data-tone=attention]{border-color:var(--dsr-warning-line);background:var(--dsr-warning-soft);color:var(--dsr-warning)}
37
+ .ext-copy{white-space:pre-wrap;overflow-wrap:anywhere;word-break:normal;line-height:1.8;font-size:13px}
38
+ .team-description,.task-description{color:var(--dsr-muted);margin:12px 0 20px}
39
+ .ext-facts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin:18px 0}
40
+ .ext-facts>div{min-width:0}.ext-facts dt{margin:0 0 5px;font-size:11px;line-height:1.7;color:var(--dsr-muted)}
41
+ .ext-facts dd{margin:0;font-size:13px;line-height:1.8;overflow-wrap:anywhere}
42
+ .ext-facts small{display:block;font-size:11px;line-height:1.8;color:var(--dsr-muted);margin-top:3px}
43
+ .ext-identifier{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px;overflow-wrap:anywhere}
44
+ .ext-alert{border:1px solid var(--dsr-warning-line);border-left:3px solid var(--dsr-warning);border-radius:10px;background:var(--dsr-warning-soft);padding:13px 15px;margin:18px 0;font-size:13px;line-height:1.8;overflow-wrap:anywhere}
45
+ .ext-alert>strong{display:block;font-size:12px;color:var(--dsr-warning)}.ext-alert>p{margin:7px 0 0}
46
+ .ext-alert ul{padding-left:18px;margin:8px 0 0}.ext-alert li+li{margin-top:6px}
47
+ .ext-disclosure{border-top:1px solid var(--dsr-line);margin-top:16px}
48
+ .ext-disclosure>summary{list-style:none;display:flex;align-items:center;gap:10px;min-height:50px;padding:12px 0;color:var(--dsr-text);font-size:13px;font-weight:600;cursor:pointer}
49
+ .ext-disclosure>summary::-webkit-details-marker{display:none}
50
+ .ext-disclosure>summary:after{content:'›';font-size:20px;line-height:1;margin-left:auto;color:var(--dsr-muted);transition:transform .15s ease}
51
+ .ext-disclosure[open]>summary:after{transform:rotate(90deg)}
52
+ .ext-count{color:var(--dsr-muted);font-size:11px;font-weight:400;font-variant-numeric:tabular-nums}
53
+ .ext-detail-body{padding:3px 0 8px;min-width:0}
54
+ .ext-alert .ext-disclosure{margin-top:8px;border-color:var(--dsr-warning-line)}
55
+ .ext-alert .ext-disclosure>summary{min-height:44px;padding-bottom:4px}
56
+ .ext-empty{grid-column:1/-1;padding:28px 16px;margin:0;color:var(--dsr-muted);font-size:13px;text-align:center;line-height:1.8}
57
+ .team-overview{display:flex;gap:28px;padding:14px 0;margin:16px 0;border-top:1px solid var(--dsr-line);border-bottom:1px solid var(--dsr-line)}
58
+ .team-overview>span{display:flex;gap:10px;align-items:baseline;color:var(--dsr-muted);font-size:12px}
59
+ .team-overview b{font-size:19px;line-height:1.3;color:var(--dsr-text);font-weight:650;font-variant-numeric:tabular-nums}
60
+ .team-checks{margin:18px 0}.team-captain-action{display:flex;justify-content:flex-end;margin:20px 0 8px}
61
+ .team-members,.team-tasks,.team-messages{list-style:none;padding:0;margin:0}
62
+ .team-members{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr));gap:12px}
63
+ .team-member,.team-task{min-width:0;padding:16px;border:1px solid var(--dsr-line);border-radius:12px;background:var(--dsr-bg)}
64
+ .team-member{display:flex;flex-direction:column}
65
+ .team-member .ext-panel-head>strong,.team-task .ext-panel-head>strong{font-size:14px}
66
+ .team-member-state{max-width:50%;font-size:11px;line-height:1.8;color:var(--dsr-muted);text-align:right}
67
+ .team-role{margin:8px 0 0;color:var(--dsr-muted)}
68
+ .team-member-facts{grid-template-columns:minmax(0,1fr);gap:10px;margin:12px 0 16px}
69
+ .team-member-action{margin-top:auto}.team-member-action .ext-button{width:100%;background:var(--dsr-panel)}
70
+ .team-tasks{display:grid;gap:10px}.team-task-id{display:block;margin-top:4px;color:var(--dsr-muted);font-size:11px}
71
+ .team-task .ext-facts{margin-bottom:0}
72
+ .team-messages>li{padding:12px 0;border-bottom:1px solid var(--dsr-line);font-size:13px}.team-messages>li:last-child{border-bottom:0}.team-messages p{margin:6px 0 0}
73
+ .task-outcomes{padding:15px;border-radius:10px;background:var(--dsr-bg);margin:18px 0}
74
+ .task-schedule{padding:14px 0;margin:18px 0;border-top:1px solid var(--dsr-line);border-bottom:1px solid var(--dsr-line)}
75
+ .task-schedule-head{display:flex;gap:12px;justify-content:space-between;align-items:baseline;font-size:11px;color:var(--dsr-muted)}
76
+ .task-schedule-rule{margin:5px 0;font-size:13px;line-height:1.8;overflow-wrap:anywhere}
77
+ .task-schedule .ext-facts{grid-template-columns:minmax(0,1fr);margin:12px 0 0}
78
+ .task-schedule:has(+.ext-disclosure){border-bottom:0;padding-bottom:0;margin-bottom:0}
79
+ .task-parent{grid-template-columns:minmax(0,1fr);margin:16px 0}
80
+ .task-footer{display:flex;gap:14px;align-items:center;justify-content:space-between;border-top:1px solid var(--dsr-line);padding-top:16px;margin-top:20px}
81
+ .task-footer>span{min-width:0;font-size:10px;line-height:1.8;color:var(--dsr-muted)}.task-footer time{display:block;font-size:11px;font-variant-numeric:tabular-nums}
82
+ .task-footer .ext-button{font-size:12px;padding:10px 12px}
83
+ .pc-adaptation{font-size:13px;line-height:1.7;color:var(--dsr-muted);overflow-wrap:anywhere}.pc-adaptation a{color:var(--dsr-accent)}
84
+ @container(max-width:540px){
85
+ .ext-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;padding:16px}
86
+ .ext-workspace{grid-column:1/-1}
87
+ .ext-toolbar>.ext-check{grid-column:1;font-size:12px}.ext-toolbar>.ext-button{grid-column:2;align-self:end;justify-self:end}
88
+ .teams-card,.task-card{padding:18px}.ext-panel-head{gap:10px}.ext-panel-head>h3{font-size:17px}.ext-badge{max-width:45%}
89
+ .team-overview{gap:22px}.team-overview>span{gap:7px}.team-captain-action .ext-button{width:100%}
90
+ .task-footer{flex-direction:column;align-items:stretch;gap:12px}.task-footer>span{display:flex;gap:8px;flex-wrap:wrap;align-items:baseline}.task-footer .ext-button{width:100%}
91
+ }
92
+ @container(max-width:320px){
93
+ .ext-facts{grid-template-columns:minmax(0,1fr);gap:12px}.team-overview{gap:14px;flex-wrap:wrap}.ext-panel-head{flex-wrap:wrap}.ext-badge{max-width:100%}
94
+ }
95
+ @media(max-width:620px){.ext-page{padding:8px 0}.ext-header{margin-bottom:22px}}
96
+ @media(prefers-reduced-motion:reduce){.ext-disclosure>summary:after{transition:none}}
@@ -7,14 +7,49 @@ window.DshExtensions = (() => {
7
7
  { id: 'teams', name: '@nanmicoder/dsh-agent-teams', label: '查看智能体团队', summary: '查看智能体团队、任务与成员状态', verified: '0.1.24-rc.1' },
8
8
  { id: 'cost', name: 'dsh-cost-meter', label: '查看费用与额度', summary: '查看费用、套餐额度与峰谷提醒', verified: '1.8.17' },
9
9
  { id: 'context', name: 'dsh-context', label: '查看当前会话上下文', session: true, summary: '查看会话上下文用量与构成', verified: '0.64.0' },
10
+ { id: 'tasks', name: '@linxin666/dsh-client-ui-task-board', label: '查看任务看板', summary: '只读查看任务、执行结果与计划时间', verified: '0.4.8' },
10
11
  ]
11
- const empty = () => ({ known: false, skills: false, cost: false, context: false, teams: false })
12
+ const empty = () => ({ known: false, skills: false, cost: false, context: false, teams: false, tasks: false })
13
+ const helpUrl = 'https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/wiki/plugins.md'
14
+ const reasons = {
15
+ 'not-installed': ['未安装', 'Not installed'], disabled: ['配置未启用', 'Disabled in configuration'],
16
+ 'runtime-unknown': ['运行状态未知', 'Runtime status unknown'], waiting: ['等待启动或依赖', 'Waiting for startup or dependencies'],
17
+ 'runtime-failed': ['插件启动失败', 'Plugin startup failed'], 'restart-required': ['配置已更新,待重启 DSH', 'Configuration updated; restart DSH'],
18
+ unverified: ['运行中,接口待读取验证', 'Running; interface not verified yet'], available: ['接口读取成功', 'Interface read succeeded'],
19
+ unsupported: ['接口不兼容', 'Unsupported interface'], 'endpoint-missing': ['主机未提供适配接口', 'Adapter endpoint unavailable on host'], 'read-failed': ['接口读取失败,可重试', 'Interface read failed; retry available'],
20
+ timeout: ['接口读取超时,可重试', 'Interface read timed out; retry available'], 'host-denied': ['主机拒绝读取,请检查认证', 'Host denied access; check authentication'],
21
+ }
22
+ function diagnosticsFor(snapshot, item, config) {
23
+ return catalog.filter(feature => feature.name === item.name).map(feature => {
24
+ const installed = snapshot?.items?.find(row => row?.name === feature.name)
25
+ const runtime = [...(Array.isArray(installed?.runtime) ? installed.runtime : []), ...(snapshot?.runtime || []).filter(row => row?.name === feature.name)]
26
+ const changed = snapshot?.pendingRestart && snapshot.operations?.some(job => job.name === feature.name && job.restartRequired && ['complete','failed','interrupted'].includes(job.phase))
27
+ const observed = config && same(config) ? cache.observations?.[feature.id] : null
28
+ const fresh = observed && observed.version === installed?.version && Date.now() - observed.at < 300000
29
+ const code = !installed ? 'not-installed' : changed ? 'restart-required' : installed.enabled !== true ? 'disabled'
30
+ : snapshot.runtimeAvailable !== true ? 'runtime-unknown' : runtime.some(row => row?.phase === 'failed') ? 'runtime-failed'
31
+ : !runtime.length || runtime.some(row => row?.enabled === false || row?.phase !== 'active') ? 'waiting'
32
+ : snapshot.adaptations?.[feature.id]?.supported === false ? 'unsupported' : fresh ? observed.code : 'unverified'
33
+ return { id: feature.id, code, label: reasons[code][window.I18N?.lang === 'en' ? 1 : 0], helpUrl, checkedAt: fresh ? observed.at : null }
34
+ })
35
+ }
36
+ function reportAvailability(config, id, result) {
37
+ if (!config || !catalog.some(row => row.id === id) || !same(config)) return
38
+ const native = identity(config)
39
+ if (!native.valid() || config.valid && !config.valid()) return
40
+ const code = result?.ok === true && result.available !== false ? 'available'
41
+ : result?.code === 'unsupported' ? 'unsupported' : result?.code === 'not-installed' ? 'endpoint-missing'
42
+ : result?.code === 'host-denied' ? 'host-denied' : result?.code === 'timeout' ? 'timeout' : 'read-failed'
43
+ cache.observations ||= {}
44
+ cache.observations[id] = { code, at: Date.now(), version: cache.snapshot?.items?.find(row => row.name === catalog.find(feature => feature.id === id).name)?.version }
45
+ }
12
46
  function capabilitiesOf(snapshot) {
13
47
  if (snapshot?.ok !== true || !Array.isArray(snapshot.items) || !Array.isArray(snapshot.runtime)) return empty()
14
48
  const result = { ...empty(), known: true }
15
49
  for (const feature of catalog) {
16
50
  const item = snapshot.items.find(row => row?.name === feature.name)
17
51
  if (item?.enabled !== true || snapshot.runtimeAvailable !== true) continue
52
+ if (snapshot.adaptations?.[feature.id]?.supported === false) continue
18
53
  if (item.runtime != null && !Array.isArray(item.runtime)) continue
19
54
  const runtime = [...(item.runtime || []), ...snapshot.runtime.filter(row => row?.name === feature.name)]
20
55
  result[feature.id] = runtime.length > 0 && runtime.every(row => row && row.enabled !== false && row.phase === 'active')
@@ -28,12 +63,14 @@ window.DshExtensions = (() => {
28
63
  function identity(config) { return config.connection || config }
29
64
  function same(config) {
30
65
  const next = identity(config)
31
- return cache && cache.connection.valid() && next.valid() && cache.connection.server === next.server && cache.connection.token === next.token
66
+ return cache && cache.connection.valid() && next.valid() && (typeof next.server === 'string'
67
+ ? cache.connection.server === next.server && cache.connection.token === next.token : cache.connection === next)
32
68
  }
33
69
  function remember(config, snapshot) {
34
70
  if (!config.valid()) return
35
71
  if (!same(config)) { cache?.controller?.abort(); cache = { connection: identity(config) } }
36
72
  cache.value = capabilitiesOf(snapshot); cache.at = Date.now()
73
+ cache.snapshot = snapshot
37
74
  cache.serial = (cache.serial || 0) + 1
38
75
  }
39
76
  function invalidateCapabilities() { cache?.controller?.abort(); cache = null }
@@ -54,7 +91,7 @@ window.DshExtensions = (() => {
54
91
  const snapshot = JSON.parse(body)
55
92
  if (!response.ok || !config.valid() || cache !== record || snapshot?.ok !== true) return empty()
56
93
  if ((record.serial || 0) !== serial) return record.value || empty()
57
- record.value = capabilitiesOf(snapshot); record.at = Date.now(); return record.value
94
+ record.snapshot = snapshot; record.value = capabilitiesOf(snapshot); record.at = Date.now(); return record.value
58
95
  } catch {
59
96
  if (cache === record && config.valid() && (record.serial || 0) !== serial) return record.value || empty()
60
97
  if (cache === record) { record.value = empty(); record.at = Date.now() }
@@ -65,7 +102,7 @@ window.DshExtensions = (() => {
65
102
  return record.task
66
103
  }
67
104
  const node=(tag,text,cls)=>{const el=document.createElement(tag);if(text!=null)el.textContent=text;if(cls)el.className=cls;return el}
68
- const stopViews=()=>{window.DshSkillsCenter?.close();window.DshInsights?.close();window.DshTeams?.close()}
105
+ const stopViews=()=>{window.DshSkillsCenter?.close();window.DshInsights?.close();window.DshTeams?.close();window.DshTasks?.close()}
69
106
  function close(){if(current){const old=current;current=null;stopViews();window.DshPluginCenter?.close();old.target.replaceChildren()}}
70
107
  function mount(config,target,initial='manage') {
71
108
  close()
@@ -92,6 +129,7 @@ window.DshExtensions = (() => {
92
129
  else {if(s.scroller)s.scroller.scrollTop=s.scroll;void window.DshPluginCenter.resume()}
93
130
  }else if(route==='skills')await window.DshSkillsCenter.mount(config,view,{dedicated:true})
94
131
  else if(route==='teams')await window.DshTeams.mount(config,view)
132
+ else if(route==='tasks')await window.DshTasks.mount(config,view)
95
133
  else window.DshInsights.mount({tab:'cost',hostOverview:true,allowedTabs:['cost'],connection:config.connection,url:config.url},view)
96
134
  if(valid()&&route!=='manage')config.scrollTop?.()
97
135
  }
@@ -102,5 +140,5 @@ window.DshExtensions = (() => {
102
140
  for(let parent=el.parentElement;parent;parent=parent.parentElement)if(parent.scrollHeight>parent.clientHeight&&/auto|scroll/.test(getComputedStyle(parent).overflowY))return parent
103
141
  return document.scrollingElement
104
142
  }
105
- return {mount,close,capabilitiesOf,featuresFor,getCapabilities,remember,invalidateCapabilities,catalog:catalog.map(row=>Object.freeze({...row}))}
143
+ return {mount,close,capabilitiesOf,featuresFor,diagnosticsFor,reportAvailability,getCapabilities,remember,invalidateCapabilities,catalog:catalog.map(row=>Object.freeze({...row}))}
106
144
  })()
package/public/index.html CHANGED
@@ -1494,6 +1494,7 @@
1494
1494
  <script src="skills.js"></script>
1495
1495
  <script src="insights.js"></script>
1496
1496
  <script src="teams.js"></script>
1497
+ <script src="task-board.js"></script>
1497
1498
  <script src="extensions.js"></script>
1498
1499
  <script src="diagnostics.js"></script>
1499
1500
  <script src="doctor.js"></script>
@@ -21,3 +21,8 @@
21
21
  .cost-host .ins-ledger-table { overflow-x:auto; }
22
22
  .cost-host .ins-ledger-table table { width:100%; border-collapse:collapse; font-size:12px; }
23
23
  .cost-host .ins-ledger-table th,.cost-host .ins-ledger-table td { text-align:left; padding:8px 6px; border-bottom:1px solid var(--dsr-line); white-space:nowrap; }
24
+ .ins-source{display:flex;gap:4px 18px;flex-wrap:wrap}
25
+ .ins-source>span{min-width:0;max-width:100%;overflow-wrap:break-word}
26
+ .ins-plan-row>span,.ins-events li>div>span{min-width:0;overflow-wrap:anywhere}
27
+ .ins-plan-row>strong{flex-shrink:0;white-space:nowrap}
28
+ .ins-section :is(h3,h4),.ins-plan>strong{overflow-wrap:anywhere}
@@ -16,7 +16,7 @@
16
16
  compaction: '压缩', prune: '裁剪', model: '模型变更', mode: '模式变更', counts: '累计变化',
17
17
  detailsFailed: '变化记录暂不可用,点击刷新重试。', detailsLoading: '正在读取变化记录…',
18
18
  session: '当前会话 API 费用', today: '今日 API 费用', equivalent: '含套餐等值估算', subagents: '子代理 API 费用(单列)', todayTokens: '今日 Token(全部渠道)', planEquivalent: '今日 Plan 等值(非实付)', localTokens: '本周期本地 Token', history: '近 7 日账本', api: 'API 费用', plan: 'Plan 等值',
19
- balance: '账户余额', plans: '套餐额度 · 已用', source: '数据来源', assembled: '摘要读取于', queried: '供应商查询于',
19
+ balance: '账户余额', plans: '套餐额度 · 已用', customBalances: '自定义渠道余额', gatewayQuotas: '网关账户额度 · 已用', partial: '部分账户查询失败', source: '数据来源', assembled: '摘要读取于', queried: '供应商查询于',
20
20
  estimateNote: '费用由插件账本按用量估算,以供应商账单为准;套餐等值金额不计入 API 费用,子代理费用单独列出。',
21
21
  sessionMissing: '插件账本尚无此会话记录', noPlans: '主机未启用可展示的套餐额度。', off: '主机未开启查询',
22
22
  error: '供应商查询失败', stale: '缓存数据', unknown: '暂无有效数据', unlimited: '不限量', reset: '重置',
@@ -31,7 +31,7 @@
31
31
  compaction: 'Compaction', prune: 'Pruning', model: 'Model change', mode: 'Mode change', counts: 'Total changes',
32
32
  detailsFailed: 'Change records are unavailable. Refresh to retry.', detailsLoading: 'Loading change records…',
33
33
  session: 'Session API cost', today: 'Today API cost', equivalent: 'Estimate including plan equivalents', subagents: 'Subagent API cost (separate)', todayTokens: 'Tokens today (all channels)', planEquivalent: 'Plan equivalent today (not paid)', localTokens: 'Local tokens in this period', history: 'Last 7 ledger days', api: 'API cost', plan: 'Plan equivalent',
34
- balance: 'Account balance', plans: 'Plan quotas · used', source: 'Source', assembled: 'Summary read at', queried: 'Provider queried at',
34
+ balance: 'Account balance', plans: 'Plan quotas · used', customBalances: 'Custom provider balances', gatewayQuotas: 'Gateway account quotas · used', partial: 'Some account queries failed', source: 'Source', assembled: 'Summary read at', queried: 'Provider queried at',
35
35
  estimateNote: 'Costs are usage estimates from the plugin ledger. Provider invoices are authoritative. Plan equivalents and subagents are shown separately.',
36
36
  sessionMissing: 'No ledger record for this session yet', noPlans: 'No visible plan quota is enabled on this host.', off: 'Query disabled on host',
37
37
  error: 'Provider query failed', stale: 'Cached data', unknown: 'No valid data', unlimited: 'Unlimited', reset: 'Resets',
@@ -128,8 +128,37 @@
128
128
  html += `<small>${esc(t('queried'))} · ${esc(time(plan.fetchedAt))}</small></div>`
129
129
  }
130
130
  html += '</section>'
131
+ const balances = Array.isArray(data.customBalances) ? data.customBalances.slice(0, 40) : []
132
+ if (balances.length) {
133
+ html += `<section class="ins-section"><h3>${esc(t('customBalances'))}</h3><div class="ins-metrics">`
134
+ for (const row of balances) {
135
+ const known = row.status === 'ok' && typeof row.remaining === 'number' && Number.isFinite(row.remaining)
136
+ html += metric(row.name, known ? (row.currency || '—') + ' ' + row.remaining.toFixed(2) : '—',
137
+ t(row.status === 'ok' ? 'queried' : ['off','error','stale','loading'].includes(row.status) ? row.status : 'unknown') + ' · ' + time(row.fetchedAt))
138
+ }
139
+ html += '</div></section>'
140
+ }
141
+ const gateways = Array.isArray(data.gatewayQuotas) ? data.gatewayQuotas.slice(0, 20) : []
142
+ if (gateways.length) {
143
+ html += `<section class="ins-section"><h3>${esc(t('gatewayQuotas'))}</h3>`
144
+ for (const source of gateways) {
145
+ html += `<div class="ins-plan"><strong>${esc(source.name)}</strong><p class="ins-note">${esc(t(source.status === 'ok' ? 'queried' : ['off','error','stale','loading','partial'].includes(source.status) ? source.status : 'unknown'))} · ${esc(time(source.fetchedAt))}</p>`
146
+ for (const account of (Array.isArray(source.accounts) ? source.accounts : []).slice(0, 16)) {
147
+ html += `<h4>${esc(account.provider)} · ${esc(account.name)}</h4>`
148
+ if (!['ok','partial'].includes(source.status) || account.status !== 'ok') { html += `<p class="ins-note">${esc(t(['off','error','stale','loading'].includes(account.status) ? account.status : 'unknown'))}</p>`; continue }
149
+ const rows = (Array.isArray(account.windows) ? account.windows : []).slice(0, 8)
150
+ if (!rows.length) html += `<p class="ins-note">${esc(t('unknown'))}</p>`
151
+ for (const row of rows) {
152
+ const percent = num(row.percent)
153
+ html += `<div class="ins-plan-row"><span>${esc(row.name)}</span><strong>${percent !== null && percent <= 100 ? percent.toFixed(1) + '%' : '—'}</strong></div>${bar(percent, account.name)}${row.resetsAt ? `<small>${esc(t('reset'))} · ${esc(row.resetsAt)}</small>` : ''}`
154
+ }
155
+ }
156
+ html += '</div>'
157
+ }
158
+ html += '</section>'
159
+ }
131
160
  if (withHistory && Array.isArray(data.history) && data.history.length) html += `<section class="ins-section"><h3>${esc(t('history'))}</h3><div class="ins-ledger-table"><table><thead><tr><th>${esc(t('date'))}</th><th>Token</th><th>${esc(t('api'))}</th><th>${esc(t('plan'))}</th></tr></thead><tbody>${data.history.slice(-7).map(row => `<tr><td>${esc(row.date)}</td><td>${tokens(row.totalTokens)}</td><td>${money(row.apiCost)}</td><td>${money(row.planEquivalent)}</td></tr>`).join('')}</tbody></table></div></section>`
132
- return html + `<p class="ins-source">${esc(t('source'))} · dsh-cost-meter<br>${esc(t('assembled'))} · ${esc(time(data.generatedAt))}</p>`
161
+ return html + `<footer class="ins-source"><span>${esc(t('source'))} · dsh-cost-meter</span><span>${esc(t('assembled'))} · ${esc(time(data.generatedAt))}</span></footer>`
133
162
  }
134
163
 
135
164
  let dialog, options, tab = 'context', generation = 0, controller, poll, debounce, page = false, inline = false, eventKind = '', allowedTabs = ['context','cost']
@@ -160,19 +189,18 @@
160
189
  const response = await fetch(options.url(path), { method: body ? 'POST' : 'GET', headers: { authorization: 'Bearer ' + connection.token,
161
190
  'x-dsh-remote-client': 'web', 'content-type': 'application/json' }, ...(body ? { body: JSON.stringify(body) } : {}), signal: attempt.signal })
162
191
  if (!valid(g)) throw new Error('stale')
163
- if (!response.ok) { const error = new Error('read-failed'); error.status = response.status; throw error }
164
192
  const source = await response.text()
165
193
  if (!valid(g)) throw new Error('stale')
166
194
  if (source.length > 2 * 1024 * 1024) throw new Error('too-large')
167
195
  const data = JSON.parse(source)
168
- if (!obj(data) || data.ok !== true) throw new Error('invalid-response')
196
+ if (!response.ok || !obj(data) || data.ok !== true) { const error = new Error('read-failed'); error.status = response.status; error.code = response.status === 401 || response.status === 403 ? 'host-denied' : data?.code; throw error }
169
197
  return data
170
198
  } finally { clearTimeout(deadline); parent.removeEventListener('abort', abort) }
171
199
  }
172
200
  async function loadContext(force = false) {
173
201
  const g = generation, head = contextOf(current()?.projections?.values?.contextTimeline)
174
202
  if (!valid(g) || tab !== 'context' || detailTask || head?.unsupported) return
175
- if (head && head.detailRev === undefined) { detailStatus = ''; render(); return }
203
+ if (head && head.detailRev === undefined) { detailStatus = ''; root.DshExtensions?.reportAvailability?.(options, 'context', { ok: true }); render(); return }
176
204
  const revision = head?.detailRev ?? null
177
205
  if (!force && detail && detailRevision === revision) return
178
206
  detailTask = true; detailStatus = 'loading'; render()
@@ -183,9 +211,10 @@
183
211
  if (next && num(next.rev) !== null && Array.isArray(next.events) && contextOf(next.head)) {
184
212
  if (newest?.detailRev !== undefined && newest.detailRev !== next.rev) { detailStatus = 'changed'; return }
185
213
  detail = { rev: next.rev, head: next.head, events: next.events }; detailRevision = newest?.detailRev ?? null; detailStatus = ''
214
+ root.DshExtensions?.reportAvailability?.(options, 'context', { ok: true })
186
215
  } else if (next === null) detailStatus = 'missing'
187
- else detailStatus = 'error'
188
- } catch (error) { if (valid(g)) detailStatus = error.status === 404 ? 'missing' : 'error' }
216
+ else { detailStatus = 'error'; root.DshExtensions?.reportAvailability?.(options, 'context', { code: 'unsupported' }) }
217
+ } catch (error) { if (valid(g)) { detailStatus = error.status === 404 ? 'missing' : 'error'; root.DshExtensions?.reportAvailability?.(options, 'context', { code: error.status === 404 ? 'not-installed' : ['AbortError','TimeoutError'].includes(error.name) ? 'timeout' : 'read-failed' }) } }
189
218
  finally {
190
219
  if (g === generation) { detailTask = false; render(); if (detailStatus === 'changed') scheduleContext() }
191
220
  }
@@ -197,9 +226,9 @@
197
226
  try {
198
227
  const data = await request('/remote/api/insights/cost' + (options.sessionId ? '?sessionId=' + encodeURIComponent(options.sessionId) : ''), null, g)
199
228
  if (!valid(g)) return
200
- if (data.available === false || costOf(data)) { cost = data; costStatus = '' }
201
- else costStatus = 'error'
202
- } catch (error) { if (valid(g)) { costStatus = 'error'; if (error.status === 404) { cost = { available: false }; costStatus = '' } } }
229
+ if (data.available === false || costOf(data)) { cost = data; costStatus = ''; root.DshExtensions?.reportAvailability?.(options, 'cost', data) }
230
+ else { costStatus = 'error'; root.DshExtensions?.reportAvailability?.(options, 'cost', { code: 'unsupported' }) }
231
+ } catch (error) { if (valid(g)) { costStatus = 'error'; root.DshExtensions?.reportAvailability?.(options, 'cost', { code: error.status === 404 ? 'not-installed' : ['AbortError','TimeoutError'].includes(error.name) ? 'timeout' : error.code || 'read-failed' }); if (error.status === 404) { cost = { available: false }; costStatus = '' } } }
203
232
  finally { if (valid(g)) render() }
204
233
  }
205
234
  function scheduleContext() { clearTimeout(debounce); debounce = setTimeout(() => loadContext(), 400) }
package/public/md.js CHANGED
@@ -257,13 +257,19 @@
257
257
  i++
258
258
  }
259
259
  if (para.length) html += '<p>' + para.join('<br>') + '</p>'
260
+ else {
261
+ // A block-start check can match a line its full parser rejects. Keep
262
+ // that escaped line as text and always advance instead of spinning.
263
+ html += '<p>' + inline(line, fileLinks, imageHosts) + '</p>'
264
+ i++
265
+ }
260
266
  }
261
267
  return html
262
268
  }
263
269
 
264
270
  function mdToHtml(text, options) {
265
271
  if (options?.imageLabel) imageLabel = String(options.imageLabel)
266
- var raw = String(text == null ? '' : text)
272
+ var raw = String(text == null ? '' : text).replace(/\r\n?/g, '\n')
267
273
  var parts = raw.split(/```/)
268
274
  var out = ''
269
275
  for (var i = 0; i < parts.length; i++) {
@@ -67,6 +67,9 @@
67
67
  .pc-dialog button.pc-danger-confirm{background:var(--dsr-error-soft,#ff8f6b24);color:var(--dsr-error,#ff8f6b);border-color:var(--dsr-error-line,#ff8f6b66)}
68
68
  .pc-empty{grid-column:1/-1;padding:30px 16px;text-align:center;border:1px dashed var(--dsr-line,#30363d);border-radius:14px;font-size:13px;color:var(--dsr-muted,#a7b0bc)}
69
69
  .pc-list>details,.pc-market-note{grid-column:1/-1}
70
+ .pc-dialog .pc-experimental{padding:0;border:1px solid var(--dsr-line,#30363d);border-radius:14px}
71
+ .pc-experimental>summary{padding:14px 16px;font-weight:600}
72
+ .pc-experimental-list{padding:0 14px 14px}
70
73
  .pc-market-note{font-size:12px;color:var(--dsr-muted,#a7b0bc);margin-bottom:4px!important}
71
74
  .pc-dialog details{font-size:13px;padding:12px 0}
72
75
  .pc-dialog summary{cursor:pointer;overflow-wrap:anywhere;color:var(--dsr-muted,#a7b0bc)}