dsh-remote-plugin 0.8.0-rc.9 → 0.8.1

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 (53) hide show
  1. package/README.en.md +4 -2
  2. package/README.md +4 -2
  3. package/apk/dsh-remote.apk +0 -0
  4. package/client.js +96 -115
  5. package/file-delivery.mjs +84 -0
  6. package/gateway.cjs +248 -3
  7. package/index.mjs +594 -52
  8. package/insights.mjs +33 -2
  9. package/package.json +4 -2
  10. package/plugin-center.mjs +14 -1
  11. package/public/activity.js +8 -3
  12. package/public/announcements.json +10 -0
  13. package/public/app.js +65 -20
  14. package/public/approval-records.js +75 -3
  15. package/public/build.json +2 -2
  16. package/public/desktop/desktop.css +10 -2
  17. package/public/desktop/desktop.html +24 -4
  18. package/public/desktop/desktop.js +32 -13
  19. package/public/extensions.css +109 -1
  20. package/public/extensions.js +116 -7
  21. package/public/file-inbox.css +66 -0
  22. package/public/file-inbox.js +289 -0
  23. package/public/index.html +26 -9
  24. package/public/insights.css +5 -0
  25. package/public/insights.js +40 -11
  26. package/public/md.js +7 -1
  27. package/public/plugin-center.css +3 -0
  28. package/public/plugin-center.js +58 -9
  29. package/public/plugin.js +21 -6
  30. package/public/session-deck.css +73 -0
  31. package/public/session-deck.js +180 -0
  32. package/public/skills.js +16 -5
  33. package/public/skins/blue-fish/skin.css +39 -0
  34. package/public/styles.css +22 -2
  35. package/public/task-board.js +109 -0
  36. package/public/teams.js +35 -13
  37. package/public/update.json +12 -12
  38. package/public/version.json +1 -1
  39. package/public/workflow.css +6 -12
  40. package/skills/dsh-remote-doctor/SKILL.md +16 -0
  41. package/skills/dsh-remote-doctor/references/wiki/README.md +40 -0
  42. package/skills/dsh-remote-doctor/references/wiki/ai-guide.md +61 -0
  43. package/skills/dsh-remote-doctor/references/wiki/connection.md +74 -0
  44. package/skills/dsh-remote-doctor/references/wiki/errors.md +26 -0
  45. package/skills/dsh-remote-doctor/references/wiki/evidence.md +44 -0
  46. package/skills/dsh-remote-doctor/references/wiki/files.md +31 -0
  47. package/skills/dsh-remote-doctor/references/wiki/maintenance.md +30 -0
  48. package/skills/dsh-remote-doctor/references/wiki/notifications.md +29 -0
  49. package/skills/dsh-remote-doctor/references/wiki/operations.md +32 -0
  50. package/skills/dsh-remote-doctor/references/wiki/plugins.md +90 -0
  51. package/skills/dsh-remote-doctor/references/wiki/sessions.md +45 -0
  52. package/skills/dsh-remote-doctor/references/wiki/sources.md +27 -0
  53. package/task-board.mjs +57 -0
@@ -0,0 +1,289 @@
1
+ /* Foreground file inbox. Confirmation precedes every download; zero dependencies. */
2
+ ;(function(root) {
3
+ 'use strict'
4
+ const MAX = 50 * 1024 * 1024
5
+ const zh = () => root.I18N?.lang !== 'en'
6
+ const label = (cn, en) => zh() ? cn : en
7
+ async function hash(bytes) {
8
+ if (root.crypto?.subtle) return [...new Uint8Array(await root.crypto.subtle.digest('SHA-256', bytes))].map(n => n.toString(16).padStart(2, '0')).join('')
9
+ if (typeof root.SHA256 === 'function') return new root.SHA256().update(new Uint8Array(bytes)).hex()
10
+ throw Error(label('当前环境无法校验文件', 'File verification is unavailable'))
11
+ }
12
+ function createClient(config) {
13
+ let current = null, epoch = 0
14
+ const requests = new Set()
15
+ const stored = key => { try { return JSON.parse(root.localStorage.getItem(key) || 'null') } catch { return null } }
16
+ const persist = ctx => { if (ctx.valid()) root.localStorage.setItem(ctx.storage, JSON.stringify(ctx.prefs)) }
17
+ const requireCurrent = ctx => { if (!ctx.valid()) throw Error(label('连接已改变,请重新打开收件箱', 'Connection changed. Reopen the inbox.')) }
18
+ async function identity() {
19
+ const connection = config.capture(), generation = epoch
20
+ if (!connection.token) throw Error(label('请先连接主机', 'Connect to a host first'))
21
+ if (current?.valid()) return current
22
+ const scope = await hash(new TextEncoder().encode(config.url('/api/file-inbox') + '\0' + connection.token))
23
+ if (generation !== epoch || !connection.valid()) throw Error('connection-changed')
24
+ const storage = 'dshRemoteFileInboxV1:' + scope
25
+ let prefs = stored(storage)
26
+ if (!/^[a-f0-9]{64}$/.test(prefs?.key || '')) {
27
+ prefs = { key: [...root.crypto.getRandomValues(new Uint8Array(32))].map(n => n.toString(16).padStart(2, '0')).join(''), name: config.native?.() ? 'Android' : label('浏览器', 'Browser'), jobs: {}, receipts: {} }
28
+ }
29
+ prefs.jobs ||= {}; prefs.receipts ||= {}
30
+ const ctx = { connection, storage, prefs, lastRegister: 0, valid: () => generation === epoch && connection.valid() }
31
+ persist(ctx); current = ctx
32
+ return ctx
33
+ }
34
+ async function read(ctx, url, options, timeoutMs, decode) {
35
+ requireCurrent(ctx)
36
+ const controller = new AbortController(), timeout = AbortSignal.timeout(timeoutMs), abort = () => controller.abort()
37
+ requests.add(controller); timeout.addEventListener('abort', abort, { once: true })
38
+ try {
39
+ const response = await root.fetch(url, { ...options, signal: controller.signal, redirect: 'error' })
40
+ requireCurrent(ctx)
41
+ const data = await decode(response)
42
+ requireCurrent(ctx)
43
+ return data
44
+ } finally { requests.delete(controller); timeout.removeEventListener('abort', abort) }
45
+ }
46
+ async function api(ctx, body) {
47
+ const { response, data } = await read(ctx, config.url('/api/file-inbox'), { method: body ? 'POST' : 'GET', headers: { ...config.headers(ctx.connection), 'content-type': 'application/json', 'x-dsh-remote-inbox-key': ctx.prefs.key }, ...(body ? { body: JSON.stringify(body) } : {}) }, 12000, async response => ({ response, data: await response.json() }))
48
+ requireCurrent(ctx)
49
+ if (!response.ok) throw Error(response.status === 404 ? label('主机尚不支持文件收件箱,请升级 Remote 插件', 'Update the host Remote plugin to use the file inbox') : String(data.error || 'HTTP ' + response.status))
50
+ return data
51
+ }
52
+ async function acknowledge(ctx, id, phase) {
53
+ requireCurrent(ctx)
54
+ ctx.prefs.receipts[id] = phase; persist(ctx)
55
+ await api(ctx, { action: 'receipt', id, phase })
56
+ delete ctx.prefs.receipts[id]; persist(ctx)
57
+ }
58
+ async function sync() {
59
+ const ctx = await identity()
60
+ if (Date.now() - ctx.lastRegister > 20000) { ctx.device = await api(ctx, { action: 'register', name: ctx.prefs.name }); ctx.lastRegister = Date.now() }
61
+ const before = await api(ctx)
62
+ for (const id of Object.keys(ctx.prefs.jobs)) {
63
+ const row = before.transfers.find(row => row.id === id)
64
+ if (!row || ['expired', 'rejected', 'complete', 'downloaded'].includes(row.phase)) { delete ctx.prefs.jobs[id]; delete ctx.prefs.receipts[id]; persist(ctx) }
65
+ }
66
+ for (const id of Object.keys(ctx.prefs.receipts)) {
67
+ const row = before.transfers.find(row => row.id === id)
68
+ if (!row || ['expired', 'rejected', 'complete', 'downloaded'].includes(row.phase)) { delete ctx.prefs.receipts[id]; persist(ctx) }
69
+ }
70
+ for (const [id, job] of Object.entries(ctx.prefs.jobs)) {
71
+ requireCurrent(ctx)
72
+ let status
73
+ try { status = JSON.parse(config.native()?.getFileDownloadStatus(job)) } catch { continue }
74
+ // DownloadManager returns unknown after its record is removed. Let the
75
+ // user retry instead of retaining a job that can never finish.
76
+ if (!['complete', 'error', 'unknown'].includes(status?.phase)) continue
77
+ try { await acknowledge(ctx, id, status.phase === 'complete' ? 'complete' : 'failed'); delete ctx.prefs.jobs[id]; persist(ctx) } catch {}
78
+ }
79
+ for (const [id, phase] of Object.entries(ctx.prefs.receipts)) { try { await acknowledge(ctx, id, phase) } catch {} }
80
+ const value = await api(ctx)
81
+ return { ...value, device: ctx.device, name: ctx.prefs.name, jobs: { ...ctx.prefs.jobs } }
82
+ }
83
+ return {
84
+ sync,
85
+ reset() { epoch++; current = null; for (const request of requests) request.abort(); requests.clear() },
86
+ async rename(name) { const ctx = await identity(); requireCurrent(ctx); ctx.prefs.name = String(name).trim().slice(0, 60) || 'Remote'; persist(ctx); ctx.lastRegister = 0; return sync() },
87
+ async reject(row) { const ctx = await identity(); return api(ctx, { action: 'reject', id: row.id }) },
88
+ async receive(row) {
89
+ const ctx = await identity()
90
+ const accepted = await api(ctx, { action: 'accept', id: row.id })
91
+ requireCurrent(ctx)
92
+ const url = new URL(config.url('/fs/inbox-file'), root.location.href)
93
+ url.searchParams.set('id', row.id); url.searchParams.set('ticket', accepted.ticket)
94
+ const native = config.native?.()
95
+ try {
96
+ if (native?.downloadToDownloads && native?.getFileDownloadStatus) {
97
+ const job = native.downloadToDownloads(url.href, accepted.fileName, ctx.connection.token)
98
+ if (!/^\d+$/.test(String(job))) throw Error(label('系统下载未启动', 'System download did not start'))
99
+ ctx.prefs.jobs[row.id] = String(job); persist(ctx)
100
+ return { native: true }
101
+ }
102
+ const bytes = await read(ctx, url.href, { headers: config.headers(ctx.connection) }, 20 * 60 * 1000, async response => {
103
+ if (!response.ok || accepted.size > MAX) throw Error(label('文件下载失败', 'Download failed'))
104
+ return response.arrayBuffer()
105
+ })
106
+ requireCurrent(ctx)
107
+ if (bytes.byteLength !== accepted.size || await hash(bytes) !== accepted.sha256) throw Error(label('文件校验失败', 'File verification failed'))
108
+ requireCurrent(ctx)
109
+ return { native: false, blob: new Blob([bytes], { type: 'application/octet-stream' }), name: accepted.fileName, id: row.id, valid: ctx.valid,
110
+ handedOff: () => acknowledge(ctx, row.id, 'downloaded') }
111
+ } catch (error) {
112
+ if (ctx.valid()) { try { await acknowledge(ctx, row.id, 'failed') } catch {} }
113
+ throw error
114
+ }
115
+ },
116
+ }
117
+ }
118
+
119
+ const actionable = row => ['pending', 'accepted', 'downloading', 'failed'].includes(row.phase)
120
+ const sessionTransfers = (rows, sessionId) => sessionId ? rows.filter(row => row.sessionId === sessionId && actionable(row)) : []
121
+ let mounted
122
+ function mount(config) {
123
+ if (mounted || !root.document) return mounted
124
+ const client = createClient(config), doc = root.document
125
+ const node = (tag, text, cls) => { const el = doc.createElement(tag); if (text != null) el.textContent = text; if (cls) el.className = cls; return el }
126
+ const button = (text, action, key, primary = false) => {
127
+ const el = node('button', text, 'file-inbox-button' + (primary ? ' primary' : ''))
128
+ el.type = 'button'; el.dataset.inboxFocus = key; el.addEventListener('click', action); return el
129
+ }
130
+ const files = doc.getElementById('file-inbox-files'), session = doc.getElementById('file-inbox-session')
131
+ const slots = [files, session].filter(Boolean)
132
+ let snapshot, busy = false, polling = false, note = '', noteId = '', lastSignature = '', destroyed = false, generation = 0, revision = 0
133
+ let historyOpen = false, deviceOpen = false
134
+ const expanded = new Set(), ready = new Map()
135
+ const context = () => config.context?.() || { sessionId: '', inChat: false }
136
+ const releasePrepared = () => { ready.forEach(item => URL.revokeObjectURL(item.url)); ready.clear() }
137
+ const phases = () => ({ pending: label('等待接收', 'Awaiting acceptance'), accepted: label('准备下载', 'Preparing download'), downloading: label('下载中 / 等待回执', 'Downloading / awaiting receipt'), downloaded: label('已交给浏览器保存', 'Handed to browser'), complete: label('设备报告已保存', 'Device reports saved'), failed: label('接收失败', 'Receive failed'), rejected: label('已拒绝', 'Rejected'), expired: label('已过期', 'Expired') })
138
+ function reset() { generation++; client.reset(); snapshot = null; note = ''; noteId = ''; busy = false; polling = false; lastSignature = ''; historyOpen = false; deviceOpen = false; expanded.clear(); releasePrepared(); render() }
139
+ async function action(id, work) {
140
+ if (busy) return
141
+ const start = generation, scope = context(), active = doc.activeElement
142
+ const focusKey = slots.some(slot => slot.contains(active)) ? active?.dataset?.inboxFocus : ''
143
+ const actionRevision = ++revision
144
+ busy = true; noteId = id; note = label('处理中…', 'Working…'); render()
145
+ try { await work(); if (start !== generation) return; const value = await client.sync(); if (start !== generation) return; snapshot = value; note = ''; noteId = '' }
146
+ catch (error) { if (start === generation) note = error.message }
147
+ finally { if (start === generation) { busy = false; render(); restoreActionFocus(focusKey, scope, start, actionRevision) } }
148
+ }
149
+ function restoreActionFocus(key, scope, start, actionRevision) {
150
+ if (!key) return
151
+ // Wait for the session deck to select and reveal the replacement card.
152
+ root.requestAnimationFrame(() => {
153
+ const current = context(), active = doc.activeElement
154
+ if (destroyed || start !== generation || actionRevision !== revision || busy ||
155
+ current.sessionId !== scope.sessionId || current.inChat !== scope.inChat ||
156
+ (active && active !== doc.body && active !== doc.documentElement)) return
157
+ const visible = el => el && !el.disabled && !el.closest('[hidden],.hidden,[inert]') && el.getClientRects().length
158
+ const candidates = slots.flatMap(slot => [...slot.querySelectorAll('[data-inbox-focus]')])
159
+ const keys = [key.replace(/:accept$/, ':save'), key, key.replace(/:[^:]+$/, ':card')]
160
+ const target = keys.map(value => candidates.find(el => el.dataset.inboxFocus === value && visible(el))).find(Boolean)
161
+ || candidates.find(el => el.dataset.inboxFocus.startsWith('session:') && visible(el))
162
+ || (scope.inChat ? [doc.getElementById('session-deck-stage'), doc.getElementById('composer-input'), doc.getElementById('composer')].find(visible)
163
+ : candidates.find(el => el.dataset.inboxFocus === 'files:heading' && visible(el)))
164
+ target?.focus({ preventScroll: true })
165
+ })
166
+ }
167
+ function card(row, placement) {
168
+ const compact = placement === 'session', prepared = ready.get(row.id)
169
+ const el = node('article', null, 'file-inbox-card' + (compact ? ' is-compact' : '') + (actionable(row) ? ' needs-action' : ''))
170
+ el.dataset.transferId = row.id
171
+ const key = action => placement + ':' + row.id + ':' + action
172
+ el.tabIndex = -1; el.dataset.inboxFocus = key('card')
173
+ const head = node('div', null, 'file-inbox-card-head'), icon = node('span', '↓', 'file-inbox-icon'), names = node('div', null, 'file-inbox-names')
174
+ icon.setAttribute('aria-hidden', 'true')
175
+ const size = row.size < 1024 ? row.size + ' B' : row.size < 1048576 ? (row.size / 1024).toFixed(1) + ' KiB' : (row.size / 1048576).toFixed(2) + ' MiB'
176
+ const purpose = [row.title && row.title !== row.fileName ? row.title : '', row.message].filter(Boolean).join(' · ')
177
+ if (compact) {
178
+ names.append(node('strong', row.fileName, 'file-inbox-filename'))
179
+ const extension = /\.([a-z0-9]{1,10})$/i.exec(row.fileName)?.[1]?.toUpperCase()
180
+ const meta = node('div', null, 'file-inbox-inline-meta'); meta.append(node('span', (extension ? extension + ' · ' : '') + size, 'file-inbox-size'))
181
+ if (prepared || row.phase !== 'pending') meta.append(node('span', prepared ? label('传输校验通过', 'Transfer verified') : phases()[row.phase] || row.phase, 'file-inbox-phase ' + row.phase))
182
+ head.append(names, meta); el.append(head, node('p', purpose || label('未附文件说明', 'No file description provided'), 'file-inbox-message'))
183
+ } else {
184
+ names.append(node('span', label('文件接收请求', 'File delivery'), 'file-inbox-eyebrow'), node('strong', row.fileName, 'file-inbox-filename'))
185
+ head.append(icon, names, node('span', phases()[row.phase] || row.phase, 'file-inbox-phase ' + row.phase)); el.append(head)
186
+ el.append(node('p', size + (row.title && row.title !== row.fileName ? ' · ' + row.title : ''), 'file-inbox-meta'))
187
+ if (row.message) el.append(node('p', row.message, 'file-inbox-message'))
188
+ }
189
+ const details = node('details', null, 'file-inbox-details'); details.open = expanded.has(key('details'))
190
+ details.append(node('summary', compact ? label('详情', 'Details') : label('查看详情', 'Details')))
191
+ if (compact) details.append(node('p', label('文件:', 'File: ') + row.fileName), node('p', label('说明:', 'Description: ') + (purpose || label('未提供', 'Not provided'))))
192
+ details.append(node('p', label('来源会话:', 'Session: ') + (config.sessionTitle?.(row.sessionId) || row.sessionId)), node('p', label('到期:', 'Expires: ') + new Date(row.expiresAt).toLocaleString()))
193
+ details.addEventListener('toggle', () => details.open ? expanded.add(key('details')) : expanded.delete(key('details')))
194
+ if (!compact) el.append(details)
195
+ const actions = node('div', null, 'file-inbox-actions')
196
+ if (prepared) {
197
+ if (!compact) el.append(node('p', label('已校验,点击保存文件。', 'Verified. Save the file to continue.'), 'file-inbox-meta'))
198
+ actions.append(button(label('保存文件', 'Save file'), () => action(row.id, async () => {
199
+ if (!prepared.valid()) throw Error(label('连接已改变', 'Connection changed'))
200
+ const anchor = node('a'); anchor.href = prepared.url; anchor.download = prepared.name; doc.body.append(anchor); anchor.click(); anchor.remove()
201
+ await prepared.handedOff(); URL.revokeObjectURL(prepared.url); ready.delete(row.id)
202
+ }), key('save'), true))
203
+ } else if (actionable(row) && !snapshot.jobs?.[row.id]) {
204
+ actions.append(button(row.phase === 'pending' ? label('接收文件', 'Accept file') : label('重新接收', 'Receive again'), () => action(row.id, async () => {
205
+ const out = await client.receive(row)
206
+ if (!out.native) ready.set(row.id, { ...out, url: URL.createObjectURL(out.blob) })
207
+ }), key('accept'), true))
208
+ if (row.phase === 'pending') actions.append(button(label('拒绝', 'Reject'), () => action(row.id, () => client.reject(row)), key('reject')))
209
+ }
210
+ if (compact) actions.append(details)
211
+ if (actions.children.length) el.append(actions)
212
+ if (note && noteId === row.id) el.append(node('p', note, 'file-inbox-note'))
213
+ return el
214
+ }
215
+ function render() {
216
+ if (destroyed) return
217
+ const active = doc.activeElement, focused = active?.dataset?.inboxFocus, hadFocus = slots.some(slot => slot.contains(active))
218
+ const rows = snapshot?.transfers || [], current = context()
219
+ if (session) {
220
+ const selected = current.inChat ? sessionTransfers(rows, current.sessionId) : []
221
+ session.hidden = !selected.length
222
+ session.replaceChildren()
223
+ if (selected.length) {
224
+ const header = node('div', null, 'file-inbox-head'), heading = node('h3', label('待接收文件', 'Incoming files'))
225
+ header.append(heading, node('span', String(selected.length), 'file-inbox-count'))
226
+ const list = node('div', null, 'file-inbox-list'); for (const row of selected) list.append(card(row, 'session'))
227
+ session.append(header, list)
228
+ }
229
+ }
230
+ if (files) {
231
+ files.replaceChildren()
232
+ const header = node('header', null, 'file-inbox-head'), heading = node('h2', label('文件收件箱', 'File inbox'))
233
+ heading.tabIndex = -1; heading.dataset.inboxFocus = 'files:heading'
234
+ const count = rows.filter(actionable).length
235
+ header.append(heading, node('span', String(count), 'file-inbox-count'), button(label('刷新', 'Refresh'), tick, 'files:refresh'))
236
+ files.append(header)
237
+ files.append(node('p', label('DSH 发来的文件,确认后才会接收。', 'Files sent by DSH are downloaded only after you accept.'), 'file-inbox-intro'))
238
+ if (note && !noteId) files.append(node('p', note, 'file-inbox-note'))
239
+ const incoming = rows.filter(actionable), list = node('div', null, 'file-inbox-list')
240
+ for (const row of incoming) list.append(card(row, 'files'))
241
+ if (!incoming.length) list.append(node('p', snapshot ? label('暂无待接收文件', 'No incoming files') : label('连接主机后可接收文件', 'Connect to a host to receive files'), 'file-inbox-empty'))
242
+ files.append(list)
243
+ const history = rows.filter(row => !actionable(row))
244
+ if (history.length) {
245
+ const group = node('details', null, 'file-inbox-history'); group.open = historyOpen
246
+ group.append(node('summary', label('已处理', 'History') + ' (' + history.length + ')'))
247
+ const items = node('div', null, 'file-inbox-list'); for (const row of history) items.append(card(row, 'history'))
248
+ group.append(items); group.addEventListener('toggle', () => { historyOpen = group.open }); files.append(group)
249
+ }
250
+ if (snapshot) {
251
+ const device = node('details', null, 'file-inbox-device'); device.open = deviceOpen
252
+ device.append(node('summary', label('接收设备 · ', 'Receiving device · ') + snapshot.name))
253
+ const field = node('label', label('设备名称 ', 'Device name ')), input = node('input'); input.value = snapshot.name; input.maxLength = 60; input.dataset.inboxFocus = 'files:name'
254
+ field.append(input); device.append(field, button(label('保存名称', 'Save name'), () => action('', async () => { await client.rename(input.value) }), 'files:rename'), node('small', label('设备编号:', 'Device id: ') + (snapshot.device?.id || '—')))
255
+ device.addEventListener('toggle', () => { deviceOpen = device.open }); files.append(device)
256
+ }
257
+ }
258
+ for (const slot of slots) for (const el of slot.querySelectorAll('button,input')) el.disabled = busy
259
+ if (hadFocus && focused) {
260
+ const target = slots.flatMap(slot => [...slot.querySelectorAll('[data-inbox-focus]')]).find(el => el.dataset.inboxFocus === focused)
261
+ if (target?.tagName === 'INPUT') target.value = active.value
262
+ if (target && !target.disabled) target.focus()
263
+ }
264
+ }
265
+ async function tick() {
266
+ if (destroyed || polling || busy || doc.visibilityState === 'hidden') return
267
+ const start = generation, readRevision = revision
268
+ polling = true
269
+ try {
270
+ const next = await client.sync(), signature = JSON.stringify(next)
271
+ if (start !== generation || readRevision !== revision) return
272
+ snapshot = next; note = ''; noteId = ''
273
+ for (const [id, item] of ready) if (!next.transfers.some(row => row.id === id && row.phase === 'downloading')) { URL.revokeObjectURL(item.url); ready.delete(id) }
274
+ if (signature !== lastSignature && doc.activeElement?.tagName !== 'INPUT') { render(); lastSignature = signature }
275
+ } catch (error) { if (start === generation && readRevision === revision) { note = error.message; noteId = ''; render() } }
276
+ finally { if (start === generation) polling = false }
277
+ }
278
+ async function open() { config.openFiles?.(); render(); files?.querySelector('h2')?.focus(); await tick() }
279
+ const entries = [...doc.querySelectorAll('[data-file-inbox-open]')]
280
+ for (const el of entries) el.addEventListener('click', open)
281
+ const timer = root.setInterval(tick, 10000)
282
+ doc.addEventListener('visibilitychange', tick)
283
+ mounted = { open, render, reset, close: () => false, refresh: tick, destroy() { client.reset(); releasePrepared(); root.clearInterval(timer); doc.removeEventListener('visibilitychange', tick); for (const el of entries) el.removeEventListener('click', open); for (const slot of slots) slot.replaceChildren(); if (session) session.hidden = true; destroyed = true; mounted = null } }
284
+ render(); void tick()
285
+ return mounted
286
+ }
287
+ root.DshFileInbox = { createClient, sessionTransfers, mount, reset: () => mounted?.reset(), refresh: () => mounted?.refresh(), render: () => mounted?.render(), open: () => mounted?.open(), close: () => mounted?.close() }
288
+ if (typeof module !== 'undefined') module.exports = root.DshFileInbox
289
+ })(typeof window !== 'undefined' ? window : globalThis)
package/public/index.html CHANGED
@@ -34,8 +34,12 @@
34
34
  <div class="topbar-right">
35
35
  <button id="btn-donate" class="topbar-btn icon-btn" data-i18n-title="settings.donate" data-i18n-aria="settings.donate"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 8h11v6a4 4 0 0 1-4 4H10a4 4 0 0 1-4-4Z"/><path d="M17 10h1.5a2.5 2.5 0 0 1 0 5H17M9 4c0 1 1 1.2 1 2M13 4c0 1 1 1.2 1 2M5 20h13"/></svg></button>
36
36
  <button id="btn-feedback" class="topbar-btn icon-btn" data-i18n-title="feedback.title" data-i18n-aria="feedback.title" aria-haspopup="menu" aria-expanded="false"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 11.5a7.5 7.5 0 0 1-7.5 7.5H7l-3 2 .8-3.1A7.5 7.5 0 1 1 20 11.5Z"/><path d="M8 11.5h.01M12 11.5h.01M16 11.5h.01"/></svg></button>
37
- <button id="btn-refresh" class="topbar-btn icon-btn" data-i18n-title="a11y.refresh" data-i18n-aria="a11y.refresh"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 11a8 8 0 1 0 1 4"/><path d="M20 5v6h-6"/></svg></button>
38
- <span id="conn-badge" class="topbar-btn conn-badge off" data-i18n="conn.off">未连接</span>
37
+ <div class="ext-shortcuts">
38
+ <button id="btn-plugin-shortcuts" class="topbar-btn icon-btn" type="button" aria-haspopup="menu" aria-controls="plugin-shortcuts-menu" aria-expanded="false" data-i18n-title="nav.plugins" data-i18n-aria="nav.plugins"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="7" height="7" rx="2"/><rect x="14" y="3" width="7" height="7" rx="2"/><rect x="3" y="14" width="7" height="7" rx="2"/><rect x="14" y="14" width="7" height="7" rx="2"/></svg></button>
39
+ <div id="plugin-shortcuts-menu" class="ext-shortcuts-menu hidden" role="menu" data-i18n-aria="nav.plugins"></div>
40
+ </div>
41
+ <button id="conn-badge" type="button" class="topbar-btn conn-badge off" aria-describedby="conn-refresh-hint" data-i18n="conn.off" data-i18n-title="conn.refresh">未连接</button>
42
+ <span id="conn-refresh-hint" class="ext-sr-only" data-i18n="conn.refresh">点击刷新连接与数据</span>
39
43
  </div>
40
44
  </header>
41
45
 
@@ -92,6 +96,7 @@
92
96
  <label for="fs-workspace" data-i18n="fs.workspace">DSH 工作区</label>
93
97
  <select id="fs-workspace" class="workspace-select" data-i18n-aria="workspace.select"></select>
94
98
  </div>
99
+ <section id="file-inbox-files" class="file-inbox-files" aria-label="文件收件箱"></section>
95
100
  <div class="fs-head">
96
101
  <button id="fs-up" class="icon-btn" data-i18n-title="fs.up" data-i18n-aria="fs.up">‹</button>
97
102
  <div id="fs-path" class="fs-path" data-i18n="fs.loading">加载中…</div>
@@ -127,11 +132,16 @@
127
132
  </div>
128
133
 
129
134
  <button id="session-sub" class="session-sub" type="button" aria-haspopup="dialog" aria-controls="session-info"></button>
130
- <div id="session-cards" class="cards"></div>
131
-
132
- <div id="queue-dock" class="queue-dock hidden" aria-live="polite"></div>
133
-
134
- <section id="session-pending" class="session-pending hidden" aria-live="polite"></section>
135
+ <section id="session-deck" class="session-deck">
136
+ <div id="session-deck-stage" class="session-deck-stage">
137
+ <div id="session-cards" class="cards"></div>
138
+ <div id="queue-dock" class="queue-dock hidden" aria-live="polite"></div>
139
+ <div class="session-attention">
140
+ <section id="session-pending" class="session-pending hidden" aria-live="polite"></section>
141
+ <section id="file-inbox-session" class="file-inbox-session" aria-label="待接收文件" aria-live="polite" hidden></section>
142
+ </div>
143
+ </div>
144
+ </section>
135
145
 
136
146
  <div class="section-head small">
137
147
  <span data-i18n="session.history">对话</span>
@@ -967,6 +977,7 @@
967
977
  'conn.reconnectIn': '重连中 {n}s', 'conn.offline': '离线', 'conn.failed': '连接失败',
968
978
  'conn.poll': '轮询', 'conn.pollTitle': '当前网络不支持实时推送,已降级为轮询(延迟数秒)',
969
979
  'conn.titleGroup': '{group} · {url}({ms})',
980
+ 'conn.refresh': '点击刷新连接与数据',
970
981
  'common.refreshing': '刷新中…', 'select.choose': '请选择', 'select.cancel': '取消',
971
982
  'nav.sessions': '会话', 'nav.files': '文件', 'nav.pending': '待办', 'nav.overview': '总览', 'nav.home': '主页', 'nav.plugins': '插件', 'nav.settings': '设置',
972
983
  'overview.eyebrow': 'SYSTEM OVERVIEW', 'overview.title': '主页', 'overview.subtitle': '实时状态与需要你处理的事项',
@@ -1209,7 +1220,7 @@
1209
1220
  'modal.approvalTitle': '工具审批', 'modal.reject': '拒绝', 'modal.allowOnce': '允许一次',
1210
1221
  'modal.questionTitle': 'DSH 需要你回答', 'modal.later': '稍后', 'modal.submit': '提交',
1211
1222
  'modal.goalTitle': '目标控制', 'modal.close': '关闭', 'modal.updateGoal': '更新目标',
1212
- 'announcement.label': '公告', 'announcement.later': '稍后再看', 'announcement.gotIt': '全部知道了', 'announcement.open': '查看详情', 'announcement.previous': '上一条公告', 'announcement.next': '下一条公告', 'announcement.page': '第 {current} / {total} 条', 'announcement.historyLabel': '公告记录', 'announcement.historyTitle': '历史公告', 'announcement.historyEmpty': '暂无历史公告', 'announcement.close': '关闭', 'announcement.noDate': '未标注日期',
1223
+ 'announcement.label': '公告', 'announcement.later': '稍后再看', 'announcement.gotIt': '全部知道了', 'announcement.open': '查看详情', 'announcement.expand': '展开', 'announcement.collapse': '收起', 'announcement.previous': '上一条公告', 'announcement.next': '下一条公告', 'announcement.page': '第 {current} / {total} 条', 'announcement.historyLabel': '公告记录', 'announcement.historyTitle': '历史公告', 'announcement.historyEmpty': '暂无历史公告', 'announcement.close': '关闭', 'announcement.noDate': '未标注日期',
1213
1224
  'announcement.voteSubmit': '提交投票', 'announcement.voteChoose': '请先选择一项', 'announcement.voteThanks': '已投票:{option}', 'announcement.voteFailed': '投票失败:{msg}', 'announcement.voteNetworkError': '网络错误', 'announcement.voteAgainLater': '提交太频繁,请稍后再试', 'announcement.voteFromHistory': '参与投票',
1214
1225
  'modal.statsTitle': '本轮统计',
1215
1226
  'time.justNow': '刚刚', 'time.minAgo': ' 分钟前', 'time.hourAgo': ' 小时前'
@@ -1231,6 +1242,7 @@
1231
1242
  'conn.reconnectIn': 'Reconnecting {n}s', 'conn.offline': 'Offline', 'conn.failed': 'Connection failed',
1232
1243
  'conn.poll': 'Polling', 'conn.pollTitle': 'Realtime push is unavailable on this network; degraded to polling (a few seconds delay)',
1233
1244
  'conn.titleGroup': '{group} · {url} ({ms})',
1245
+ 'conn.refresh': 'Click to refresh connection and data',
1234
1246
  'common.refreshing': 'Refreshing…', 'select.choose': 'Choose an option', 'select.cancel': 'Cancel',
1235
1247
  'nav.sessions': 'Sessions', 'nav.files': 'Files', 'nav.pending': 'Inbox', 'nav.overview': 'Overview', 'nav.home': 'Home', 'nav.plugins': 'Plugins', 'nav.settings': 'Settings',
1236
1248
  'overview.eyebrow': 'SYSTEM OVERVIEW', 'overview.title': 'Home', 'overview.subtitle': 'Live status and items needing your attention',
@@ -1473,7 +1485,7 @@
1473
1485
  'modal.approvalTitle': 'Tool approval', 'modal.reject': 'Reject', 'modal.allowOnce': 'Allow once',
1474
1486
  'modal.questionTitle': 'DSH needs your answer', 'modal.later': 'Later', 'modal.submit': 'Submit',
1475
1487
  'modal.goalTitle': 'Goal control', 'modal.close': 'Close', 'modal.updateGoal': 'Update goal',
1476
- 'announcement.label': 'Announcement', 'announcement.later': 'Later', 'announcement.gotIt': 'Mark all read', 'announcement.open': 'View details', 'announcement.previous': 'Previous announcement', 'announcement.next': 'Next announcement', 'announcement.page': 'Announcement {current} of {total}', 'announcement.historyLabel': 'Announcement archive', 'announcement.historyTitle': 'Announcement history', 'announcement.historyEmpty': 'No announcement history', 'announcement.close': 'Close', 'announcement.noDate': 'No date',
1488
+ 'announcement.label': 'Announcement', 'announcement.later': 'Later', 'announcement.gotIt': 'Mark all read', 'announcement.open': 'View details', 'announcement.expand': 'Expand', 'announcement.collapse': 'Collapse', 'announcement.previous': 'Previous announcement', 'announcement.next': 'Next announcement', 'announcement.page': 'Announcement {current} of {total}', 'announcement.historyLabel': 'Announcement archive', 'announcement.historyTitle': 'Announcement history', 'announcement.historyEmpty': 'No announcement history', 'announcement.close': 'Close', 'announcement.noDate': 'No date',
1477
1489
  'announcement.voteSubmit': 'Submit vote', 'announcement.voteChoose': 'Choose an option first', 'announcement.voteThanks': 'Voted: {option}', 'announcement.voteFailed': 'Vote failed: {msg}', 'announcement.voteNetworkError': 'Network error', 'announcement.voteAgainLater': 'Too many submissions; try again later', 'announcement.voteFromHistory': 'Vote now',
1478
1490
  'modal.statsTitle': 'This round',
1479
1491
  'time.justNow': 'just now', 'time.minAgo': ' min ago', 'time.hourAgo': ' hr ago'
@@ -1494,6 +1506,7 @@
1494
1506
  <script src="skills.js"></script>
1495
1507
  <script src="insights.js"></script>
1496
1508
  <script src="teams.js"></script>
1509
+ <script src="task-board.js"></script>
1497
1510
  <script src="extensions.js"></script>
1498
1511
  <script src="diagnostics.js"></script>
1499
1512
  <script src="doctor.js"></script>
@@ -1513,6 +1526,10 @@
1513
1526
  <script src="approval-records.js"></script>
1514
1527
  <script src="doctor-entry.js"></script>
1515
1528
  <script src="onboarding.js"></script>
1529
+ <link rel="stylesheet" href="file-inbox.css">
1530
+ <script src="file-inbox.js"></script>
1531
+ <link rel="stylesheet" href="session-deck.css">
1532
+ <script src="session-deck.js"></script>
1516
1533
  <script src="app.js"></script>
1517
1534
  </body>
1518
1535
  </html>
@@ -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)}