dsh-remote-plugin 0.7.4 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +29 -48
- package/README.md +29 -48
- package/apk/dsh-remote.apk +0 -0
- package/gateway.cjs +3 -1
- package/index.mjs +28 -0
- package/package.json +4 -2
- package/plugin-center.mjs +126 -26
- package/public/app.js +189 -37
- package/public/chat-files.js +85 -0
- package/public/desktop/desktop.css +21 -2
- package/public/desktop/desktop.html +9 -0
- package/public/desktop/desktop.js +107 -32
- package/public/extensions.css +1 -0
- package/public/extensions.js +103 -0
- package/public/history.js +31 -10
- package/public/index.html +12 -3
- package/public/insights.css +2 -0
- package/public/insights.js +50 -23
- package/public/md.js +26 -18
- package/public/plugin-center.css +7 -3
- package/public/plugin-center.js +76 -18
- package/public/skills.css +81 -0
- package/public/skills.js +191 -0
- package/public/styles.css +27 -2
- package/public/theme-vars.css +5 -0
- package/public/update.json +8 -8
- package/public/version.json +1 -1
- package/session-file.mjs +34 -0
- package/skills.mjs +53 -0
package/public/plugin-center.js
CHANGED
|
@@ -3,8 +3,21 @@
|
|
|
3
3
|
window.DshPluginCenter = (() => {
|
|
4
4
|
let dialog, connection, snapshot, timer, generation = 0, pending = false, tab = 'installed', offset = 0, searchSequence = 0, detailSequence = 0
|
|
5
5
|
const expandedDetails = new Map()
|
|
6
|
-
let renderedInstalled = '', renderedJobs = '', filter = '', statusFilter = 'all', refreshSequence = 0
|
|
6
|
+
let renderedInstalled = '', renderedJobs = '', filter = '', statusFilter = 'all', refreshSequence = 0, trackedOperation = ''
|
|
7
7
|
const labels = { install: '安装', update: '更新', remove: '卸载', enable: '启用', disable: '停用', queued: '等待执行', running: '执行中', complete: '已完成', failed: '失败', interrupted: '已中断', active: '运行中', pending: '等待依赖', loading: '加载中', disposed: '未运行', unloading: '卸载中', inactive: '未运行' }
|
|
8
|
+
const stages = { queued: '等待主机启动', backup: '备份配置', 'profile-lock': '检查配置锁', cli: '执行插件命令', verify: '保存并核验', complete: '完成' }
|
|
9
|
+
function jobProgress(job) {
|
|
10
|
+
const active = ['queued', 'running'].includes(job.phase), now = Date.now()
|
|
11
|
+
const elapsed = Math.max(0, Math.floor(((active ? now : job.endedAt || now) - job.startedAt) / 1000))
|
|
12
|
+
const parts = [stages[job.stage] || labels[job.phase] || job.phase, '耗时 ' + elapsed + ' 秒']
|
|
13
|
+
if (active && job.updatedAt && now - job.updatedAt > 15000) parts.push('主机任务状态超过 15 秒未更新,正在重新核对进程')
|
|
14
|
+
if (active && job.stage === 'cli') {
|
|
15
|
+
const silence = Math.max(0, Math.floor((now - (job.lastOutputAt || job.startedAt)) / 1000))
|
|
16
|
+
parts.push(job.lastOutputAt ? '最近输出在 ' + silence + ' 秒前' : '等待首次输出')
|
|
17
|
+
if (silence >= 30) parts.push('暂无新输出,命令仍待结束;请展开日志检查网络或锁占用')
|
|
18
|
+
}
|
|
19
|
+
return parts.join(' · ')
|
|
20
|
+
}
|
|
8
21
|
function node(tag, text, className) {
|
|
9
22
|
const el = document.createElement(tag)
|
|
10
23
|
if (text != null) el.textContent = text
|
|
@@ -46,10 +59,10 @@ window.DshPluginCenter = (() => {
|
|
|
46
59
|
function renderInstalled() {
|
|
47
60
|
const list = dialog.querySelector('.pc-list'), restore = preserveListPosition(list); list.replaceChildren()
|
|
48
61
|
if (!snapshot) { list.append(node('p', '尚未读取插件状态,请点击刷新。')); return }
|
|
49
|
-
const rows = snapshot.items.filter(item => tab === 'builtin' ? !item.managed : item.managed)
|
|
62
|
+
const rows = snapshot.items.filter(item => tab === 'builtin' ? !item.managed && item.name !== 'dsh-remote-plugin' : item.managed || item.name === 'dsh-remote-plugin')
|
|
50
63
|
.filter(item => [item.name, item.displayName, item.description].join(' ').toLowerCase().includes(filter.toLowerCase()))
|
|
51
64
|
.filter(item => statusFilter === 'all' || (statusFilter === 'enabled' ? item.enabled : !item.enabled))
|
|
52
|
-
if (!rows.length) list.append(node('p', filter || statusFilter !== 'all' ? '没有匹配的插件。' : tab === 'builtin' ? '暂无内置插件。' : '
|
|
65
|
+
if (!rows.length) list.append(node('p', filter || statusFilter !== 'all' ? '没有匹配的插件。' : tab === 'builtin' ? '暂无内置插件。' : '当前主机没有其他已安装插件。第三方插件可按需选择。', 'pc-empty'))
|
|
53
66
|
for (const item of rows) {
|
|
54
67
|
const el = card(item.displayName || item.name, item.description)
|
|
55
68
|
el.append(node('small', item.name, 'pc-package'))
|
|
@@ -75,7 +88,16 @@ window.DshPluginCenter = (() => {
|
|
|
75
88
|
}
|
|
76
89
|
const remove = button('卸载', () => mutate('remove', item.name)); remove.className = 'pc-danger-button'; actions.append(remove)
|
|
77
90
|
for (const action of actions.children) if (action !== detail) action.disabled = pending || snapshot.busy
|
|
91
|
+
} else if (item.selfUpdate && snapshot.writable) {
|
|
92
|
+
const update = button('更新 Remote', () => showDetails(item.name, '', area, detail, true))
|
|
93
|
+
update.disabled = snapshot.busy || pending; actions.append(update)
|
|
78
94
|
} else actions.append(node('small', '主机维护 · 只读'))
|
|
95
|
+
if (connection.onFeature) {
|
|
96
|
+
for (const feature of window.DshExtensions?.featuresFor(snapshot, item, !!connection.getSession?.()?.sessionId) || []) {
|
|
97
|
+
const action = button(feature.label, () => connection.onFeature(feature.id))
|
|
98
|
+
action.className = 'pc-open-feature'; actions.prepend(action)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
79
101
|
el.dataset.plugin = item.name
|
|
80
102
|
detail.setAttribute('aria-controls', area.id)
|
|
81
103
|
renderInline(area, detail, item)
|
|
@@ -140,7 +162,7 @@ window.DshPluginCenter = (() => {
|
|
|
140
162
|
area.append(input, button('查看此版本', () => showDetails(entry.name, input.value.trim(), area, control, true)))
|
|
141
163
|
const row = snapshot?.items.find(row => row.name === item.name), action = row ? 'update' : 'install'
|
|
142
164
|
const install = button(labels[action] + ' ' + item.version, () => mutate(action, item.name, item.version))
|
|
143
|
-
install.disabled = !item.bundle || item.protected || !snapshot?.writable || snapshot.busy || pending || row?.version === item.version
|
|
165
|
+
install.disabled = !item.bundle || item.protected && !(row?.selfUpdate && action === 'update') || !snapshot?.writable || snapshot.busy || pending || row?.version === item.version
|
|
144
166
|
area.append(install)
|
|
145
167
|
}
|
|
146
168
|
function installedDetails(item, area, control) {
|
|
@@ -160,6 +182,12 @@ window.DshPluginCenter = (() => {
|
|
|
160
182
|
try { data = await api('/state') } catch (error) { if (sequence === refreshSequence) throw error; return }
|
|
161
183
|
if (sequence !== refreshSequence) return
|
|
162
184
|
snapshot = data
|
|
185
|
+
window.DshExtensions?.remember(connection, snapshot)
|
|
186
|
+
const tracked = snapshot.operations.find(job => job.id === trackedOperation)
|
|
187
|
+
if (tracked && !['queued', 'running'].includes(tracked.phase)) {
|
|
188
|
+
message((labels[tracked.phase] || tracked.phase) + ':' + tracked.name + '。' + (tracked.message || '请查看操作记录。'))
|
|
189
|
+
trackedOperation = ''
|
|
190
|
+
}
|
|
163
191
|
const recovery = dialog.querySelector('.pc-recovery'); recovery.replaceChildren()
|
|
164
192
|
if (snapshot.recovery) {
|
|
165
193
|
recovery.append(node('p', snapshot.recovery.reason))
|
|
@@ -175,24 +203,33 @@ window.DshPluginCenter = (() => {
|
|
|
175
203
|
dialog.querySelector('.pc-status').textContent = snapshot.reason || (snapshot.pendingRestart ? '插件配置已变更,重启 DSH 后生效。' : '安装到当前连接的 DSH 主机。')
|
|
176
204
|
dialog.querySelector('.pc-status').hidden = !snapshot.reason && !snapshot.pendingRestart
|
|
177
205
|
const summary = dialog.querySelector('.pc-summary'); summary.replaceChildren()
|
|
178
|
-
for (const [count, title] of [[snapshot.items.filter(item => item.managed).length, '已安装'], [snapshot.items.filter(item => item.managed && item.enabled).length, '配置启用']]) {
|
|
206
|
+
for (const [count, title] of [[snapshot.items.filter(item => item.managed || item.name === 'dsh-remote-plugin').length, '已安装'], [snapshot.items.filter(item => (item.managed || item.name === 'dsh-remote-plugin') && item.enabled).length, '配置启用']]) {
|
|
179
207
|
const stat = node('span', null, 'pc-stat'); stat.append(node('strong', String(count)), node('span', title)); summary.append(stat)
|
|
180
208
|
}
|
|
181
209
|
if (snapshot.busy) summary.append(node('span', '任务执行中', 'pc-badge'))
|
|
182
|
-
const
|
|
183
|
-
|
|
210
|
+
const progress = dialog.querySelector('.pc-progress'); progress.replaceChildren()
|
|
211
|
+
const activeJob = snapshot.operations.find(job => ['queued', 'running'].includes(job.phase))
|
|
212
|
+
if (activeJob) progress.append(node('strong', (labels[activeJob.action] || activeJob.action) + ' ' + activeJob.name), node('p', jobProgress(activeJob)), node('p', activeJob.message || '任务在主机执行,可关闭窗口后回来查看。'))
|
|
213
|
+
if (snapshot.busyReason) progress.append(node('p', snapshot.busyReason))
|
|
214
|
+
if (snapshot.profileLock) progress.append(node('p', snapshot.profileLock.message))
|
|
215
|
+
progress.hidden = !progress.children.length
|
|
216
|
+
const installedKey = JSON.stringify([snapshot.items, snapshot.runtime, snapshot.runtimeAvailable, snapshot.pendingRestart, snapshot.busy, snapshot.writable, pending, tab, filter, statusFilter])
|
|
217
|
+
if (['installed', 'builtin'].includes(tab) && installedKey !== renderedInstalled) { renderInstalled(); renderedInstalled = installedKey }
|
|
184
218
|
renderTabs()
|
|
185
|
-
const jobsKey = JSON.stringify(snapshot.operations)
|
|
219
|
+
const jobsKey = JSON.stringify(snapshot.operations.map(job => [job, jobProgress(job)]))
|
|
186
220
|
if (jobsKey === renderedJobs) return
|
|
187
221
|
renderedJobs = jobsKey
|
|
188
222
|
const jobs = dialog.querySelector('.pc-jobs')
|
|
223
|
+
const knownJobs = new Set([...jobs.children].map(el => el.dataset.id))
|
|
224
|
+
if (activeJob && !knownJobs.has(activeJob.id)) dialog.querySelector('.pc-history').open = true
|
|
189
225
|
const expanded = new Set([...jobs.querySelectorAll('details[open]')].map(el => el.dataset.id))
|
|
190
226
|
jobs.replaceChildren()
|
|
191
227
|
for (const job of snapshot.operations) {
|
|
192
228
|
const el = node('details')
|
|
193
|
-
el.dataset.id = job.id; el.open = expanded.has(job.id)
|
|
229
|
+
el.dataset.id = job.id; el.open = expanded.has(job.id) || !knownJobs.has(job.id) && ['queued', 'running'].includes(job.phase)
|
|
194
230
|
el.append(node('summary', (labels[job.action] || job.action) + ' ' + job.name + (job.version ? '@' + job.version : '') + ' · ' + (labels[job.phase] || job.phase)))
|
|
195
231
|
el.append(node('small', new Date(job.startedAt).toLocaleString()))
|
|
232
|
+
el.append(node('p', jobProgress(job), 'pc-job-progress'))
|
|
196
233
|
el.append(node('p', job.message || '任务在主机端执行,可关闭窗口后回来查看。'))
|
|
197
234
|
if (job.log) el.append(node('pre', job.log))
|
|
198
235
|
jobs.append(el)
|
|
@@ -244,9 +281,11 @@ window.DshPluginCenter = (() => {
|
|
|
244
281
|
// LAN HTTP is not a secure context; an idempotency key does not need WebCrypto.
|
|
245
282
|
const id = globalThis.crypto?.randomUUID?.() || `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`
|
|
246
283
|
const body = { id, action, name, ...(version ? { version } : {}), revision: snapshot.revision }
|
|
284
|
+
if (name === 'dsh-remote-plugin' && action === 'update') body.confirmSelfUpdate = true
|
|
247
285
|
const area = dialog.querySelector('.pc-detail')
|
|
248
286
|
const review = card('确认' + labels[action], name + (version ? '@' + version : ''))
|
|
249
287
|
review.append(node('p', '目标环境:' + snapshot.profile + '。配置修改后需要重启 DSH;不会自动重启。'))
|
|
288
|
+
if (body.confirmSelfUpdate) review.append(node('p', '更新当前主机的 Remote 插件本体,先备份配置与旧包,后台执行。重启 DSH 后新版本生效,连接可能短暂中断;此操作不会升级手机 App。'))
|
|
250
289
|
const confirm = button('确认' + labels[action], () => executeMutation(body)); confirm.className = action === 'remove' ? 'pc-danger-confirm' : 'pc-primary'
|
|
251
290
|
review.append(confirm, button('取消', () => area.replaceChildren()))
|
|
252
291
|
area.replaceChildren(review); area.scrollIntoView({ block: 'nearest' })
|
|
@@ -255,9 +294,12 @@ window.DshPluginCenter = (() => {
|
|
|
255
294
|
if (pending) return
|
|
256
295
|
const current = generation
|
|
257
296
|
pending = true
|
|
297
|
+
if (tab !== 'market') { renderInstalled(); renderedInstalled = '' }
|
|
298
|
+
for (const control of dialog.querySelector('.pc-detail').querySelectorAll('button')) control.disabled = true
|
|
258
299
|
try {
|
|
259
300
|
message('正在提交…')
|
|
260
301
|
await api(endpoint, body)
|
|
302
|
+
if (endpoint === '/operations') trackedOperation = body.id
|
|
261
303
|
message('已受理,可在操作记录查看结果。')
|
|
262
304
|
dialog.querySelector('.pc-detail').replaceChildren()
|
|
263
305
|
} catch (error) {
|
|
@@ -268,12 +310,30 @@ window.DshPluginCenter = (() => {
|
|
|
268
310
|
} finally { if (current === generation) { pending = false; await refresh() } }
|
|
269
311
|
}
|
|
270
312
|
function close() {
|
|
313
|
+
window.DshSkillsCenter?.close()
|
|
271
314
|
generation++; searchSequence++; detailSequence++; clearTimeout(timer); expandedDetails.clear()
|
|
272
315
|
if (!dialog) return
|
|
273
316
|
if (dialog.tagName === 'DIALOG') dialog.close()
|
|
274
317
|
else { dialog.open = false; dialog.remove() }
|
|
275
318
|
dialog = null
|
|
276
319
|
}
|
|
320
|
+
function startPolling() {
|
|
321
|
+
clearTimeout(timer)
|
|
322
|
+
const current = generation
|
|
323
|
+
async function poll() {
|
|
324
|
+
if (current !== generation || !dialog?.open) return
|
|
325
|
+
try { await refresh() } catch (error) { if (current === generation) message(error.message) }
|
|
326
|
+
if (current === generation && dialog?.open) timer = setTimeout(poll, 4000)
|
|
327
|
+
}
|
|
328
|
+
timer = setTimeout(poll, 4000)
|
|
329
|
+
}
|
|
330
|
+
function pause() { generation++; refreshSequence++; clearTimeout(timer); if (dialog) dialog.open = false }
|
|
331
|
+
async function resume() {
|
|
332
|
+
if (!dialog || !connection.valid()) return
|
|
333
|
+
dialog.open = true; const current = ++generation
|
|
334
|
+
try { await refresh() } catch (error) { if (current === generation) message(error.message) }
|
|
335
|
+
if (current === generation && dialog?.open) startPolling()
|
|
336
|
+
}
|
|
277
337
|
async function open(config, target) {
|
|
278
338
|
close()
|
|
279
339
|
if (!dialog) {
|
|
@@ -285,6 +345,7 @@ window.DshPluginCenter = (() => {
|
|
|
285
345
|
const toolbar = node('div', null, 'pc-tabs')
|
|
286
346
|
for (const [value, title] of [['installed', '已安装'], ['market', '添加插件'], ['builtin', '内置插件']]) {
|
|
287
347
|
const control = button(title, () => {
|
|
348
|
+
window.DshSkillsCenter?.close()
|
|
288
349
|
tab = value; detailSequence++; expandedDetails.clear(); renderedInstalled = ''; dialog.querySelector('.pc-detail').replaceChildren()
|
|
289
350
|
renderTabs(); message('')
|
|
290
351
|
dialog.querySelector('.pc-market-tools').hidden = value !== 'market'; dialog.querySelector('.pc-filters').hidden = value === 'market'
|
|
@@ -311,18 +372,20 @@ window.DshPluginCenter = (() => {
|
|
|
311
372
|
search().catch(error => { if (current === generation) message(error.message) })
|
|
312
373
|
})
|
|
313
374
|
const jobs = node('details', null, 'pc-history'); jobs.append(node('summary', '操作记录'), node('div', null, 'pc-jobs'))
|
|
375
|
+
const progress = node('section', null, 'pc-progress'); progress.hidden = true; progress.setAttribute('role', 'status'); progress.setAttribute('aria-live', 'polite')
|
|
314
376
|
const alert = node('p', null, 'pc-message'); alert.setAttribute('role', 'status')
|
|
315
377
|
const context = node('div', null, 'pc-context'); context.append(node('p', null, 'pc-profile'), node('div', null, 'pc-summary'))
|
|
316
378
|
controls.append(toolbarRow, filters, market)
|
|
317
|
-
dialog.append(heading, context, node('p', null, 'pc-status'), controls, alert, node('div', null, 'pc-recovery'), node('div', null, 'pc-detail'), node('div', null, 'pc-list'), jobs)
|
|
379
|
+
dialog.append(heading, context, node('p', null, 'pc-status'), controls, alert, progress, node('div', null, 'pc-recovery'), node('div', null, 'pc-detail'), node('div', null, 'pc-list'), jobs)
|
|
318
380
|
const surface = dialog
|
|
319
381
|
dialog.addEventListener('close', () => {
|
|
320
382
|
if (dialog !== surface) return
|
|
383
|
+
window.DshSkillsCenter?.close()
|
|
321
384
|
generation++; clearTimeout(timer); dialog = null; surface.remove()
|
|
322
385
|
})
|
|
323
386
|
;(target || document.body).append(dialog)
|
|
324
387
|
}
|
|
325
|
-
generation++; searchSequence++; detailSequence++; connection = config; tab = 'installed'; pending = false; snapshot = null; filter = ''; statusFilter = 'all'
|
|
388
|
+
generation++; searchSequence++; detailSequence++; connection = config; tab = 'installed'; pending = false; snapshot = null; filter = ''; statusFilter = 'all'; trackedOperation = ''
|
|
326
389
|
const current = generation
|
|
327
390
|
renderedInstalled = ''; renderedJobs = ''
|
|
328
391
|
dialog.querySelector('.pc-market-tools').hidden = true
|
|
@@ -332,12 +395,7 @@ window.DshPluginCenter = (() => {
|
|
|
332
395
|
message('正在读取插件状态…')
|
|
333
396
|
try { await refresh(); message('') } catch (error) { if (current === generation) message(error.message) }
|
|
334
397
|
if (current !== generation) return
|
|
335
|
-
|
|
336
|
-
if (current !== generation || !dialog?.open) return
|
|
337
|
-
try { await refresh() } catch (error) { if (current === generation) message(error.message) }
|
|
338
|
-
if (current === generation && dialog?.open) timer = setTimeout(poll, 4000)
|
|
339
|
-
}
|
|
340
|
-
timer = setTimeout(poll, 4000)
|
|
398
|
+
startPolling()
|
|
341
399
|
}
|
|
342
|
-
return { open, mount: (config, target) => open(config, target), close }
|
|
400
|
+
return { open, mount: (config, target) => open(config, target), close, pause, resume }
|
|
343
401
|
})()
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* Read-only library: shared theme and deliberate wrapping. */
|
|
2
|
+
.sc-shell { grid-column:1/-1; min-width:0; color:var(--dsr-text,#f0f6fc); container-type:inline-size; container-name:skills; }
|
|
3
|
+
.sc-heading { margin-bottom:20px; }
|
|
4
|
+
.sc-heading h3 { margin:0; font-size:22px; line-height:1.3; }
|
|
5
|
+
.sc-intro,.sc-updated,.sc-source,.sc-meta { color:var(--dsr-muted,#a7b0bc); font-size:13px; line-height:1.6; }
|
|
6
|
+
.sc-intro { margin:8px 0 0!important; }.sc-source { display:block; }
|
|
7
|
+
.sc-filters { display:grid; grid-template-columns:minmax(220px,1fr) minmax(130px,.5fr) minmax(155px,.6fr) auto; gap:10px; align-items:center; }
|
|
8
|
+
.sc-filters input,.sc-filters select,.sc-filters button,.sc-reading-tools input,.sc-reading-tools select,.sc-reading-tools button,.sc-page button {
|
|
9
|
+
box-sizing:border-box; min-width:0; min-height:46px; max-width:100%; margin:0; padding:11px 12px;
|
|
10
|
+
border:1px solid var(--dsr-line,#30363d); border-radius:12px; background:var(--dsr-panel,#161b22);
|
|
11
|
+
color:var(--dsr-text,#f0f6fc); font:inherit; font-size:14px; line-height:1.4;
|
|
12
|
+
}
|
|
13
|
+
.sc-filters input,.sc-filters select,.sc-reading-tools input,.sc-reading-tools select { width:100%; }
|
|
14
|
+
.sc-filters input::placeholder,.sc-reading-tools input::placeholder { color:var(--dsr-muted,#a7b0bc); opacity:1; }
|
|
15
|
+
.sc-filters select,.sc-reading-tools select { padding-right:28px; text-overflow:ellipsis; }
|
|
16
|
+
.sc-filters button,.sc-reading-tools button,.sc-page button { white-space:nowrap; cursor:pointer; }
|
|
17
|
+
.sc-filters button { min-width:88px; }
|
|
18
|
+
.sc-shell :is(input,select,button):focus-visible { outline:2px solid var(--dsr-accent,#58a6ff); outline-offset:3px; }
|
|
19
|
+
.sc-summary { display:flex; align-items:baseline; justify-content:space-between; flex-wrap:wrap; gap:4px 16px; margin:20px 0 16px; font-size:13px; }
|
|
20
|
+
.sc-count,.sc-updated { white-space:nowrap; }
|
|
21
|
+
.sc-notice:not(:empty) { margin-top:12px!important; padding:12px 14px; border:1px solid var(--dsr-warning-line,#ff9e6466); border-radius:12px; font-size:13px; line-height:1.6; }
|
|
22
|
+
.sc-notice:empty { display:none; }
|
|
23
|
+
.sc-body { display:grid; grid-template-columns:minmax(240px,1fr) minmax(0,1.5fr); gap:20px; align-items:start; }
|
|
24
|
+
.sc-list { display:grid; gap:14px; max-height:68dvh; overflow:auto; }
|
|
25
|
+
.sc-card,.sc-detail { min-width:0; border:1px solid var(--dsr-line,#30363d); border-radius:18px; background:var(--dsr-panel,#161b22); padding:20px; overflow-wrap:break-word; word-break:normal; line-break:strict; }
|
|
26
|
+
.sc-card { display:flex; flex-direction:column; align-items:stretch; }
|
|
27
|
+
.sc-card.is-selected { border-color:var(--dsr-accent,#58a6ff); background:var(--dsr-accent-soft,#58a6ff1f); }
|
|
28
|
+
.sc-card h3 { margin:8px 0 10px!important; font-size:18px; line-height:1.45; overflow-wrap:break-word; word-break:normal; }
|
|
29
|
+
.sc-description { margin:0!important; font-size:14px; line-height:1.7; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
|
|
30
|
+
.sc-description,.sc-intro,.sc-detail p { text-wrap:pretty; }
|
|
31
|
+
.sc-flags { display:flex; flex-wrap:wrap; align-items:flex-start; gap:8px; margin:16px 0; }
|
|
32
|
+
.sc-flags .pc-badge { max-width:100%; min-width:0; white-space:normal; line-height:1.5; overflow-wrap:break-word; }
|
|
33
|
+
.sc-flags .sc-status { white-space:nowrap; }
|
|
34
|
+
.sc-card > button { min-height:44px; width:100%; margin-top:auto; border-radius:12px; font-size:14px; }
|
|
35
|
+
.sc-detail { position:sticky; top:12px; }.sc-detail[hidden] { display:none; }
|
|
36
|
+
.sc-card .sc-detail { margin-top:16px; padding:16px 0 0; border:0; border-top:1px solid var(--dsr-line,#30363d); border-radius:0; background:transparent; }
|
|
37
|
+
.sc-detail h3 { font-size:20px; line-height:1.4; margin:16px 0 10px; }
|
|
38
|
+
.sc-detail h4 { margin:24px 0 10px; font-size:15px; line-height:1.5; }
|
|
39
|
+
.sc-detail p { margin-top:10px!important; font-size:14px; line-height:1.75; }
|
|
40
|
+
.sc-detail .sc-content { max-height:58dvh; margin:0; padding:16px; border:1px solid var(--dsr-line,#30363d); border-radius:14px; white-space:pre-wrap; overflow-wrap:break-word; word-break:normal; overflow:auto; font:13px/1.8 ui-monospace,monospace; background:var(--dsr-bg,#0d1117); }
|
|
41
|
+
.sc-page .sc-filters { grid-template-columns:minmax(220px,1fr) minmax(130px,.45fr) minmax(155px,.55fr) minmax(105px,.35fr) auto; }
|
|
42
|
+
.sc-page .sc-body { display:block; }
|
|
43
|
+
.sc-page .sc-list { max-height:none; overflow:visible; grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr)); align-items:stretch; }
|
|
44
|
+
.sc-page .sc-detail { position:static; padding:24px; }.sc-page .sc-content { max-height:none; overflow:visible; }
|
|
45
|
+
.sc-reading-tools { display:grid; grid-template-columns:minmax(200px,1fr) minmax(150px,auto) auto; gap:10px; margin:18px 0 10px; align-items:center; }
|
|
46
|
+
.sc-markdown { font-family:inherit!important; white-space:normal!important; line-height:1.8; }
|
|
47
|
+
.sc-markdown :is(p,li) { max-width:75ch; }
|
|
48
|
+
.sc-markdown :is(h1,h2,h3,h4) { line-height:1.4; overflow-wrap:break-word; }
|
|
49
|
+
.sc-markdown h1 { font-size:23px; }.sc-markdown h2 { font-size:20px; }
|
|
50
|
+
.sc-markdown pre { max-width:100%; overflow-x:auto; white-space:pre; }
|
|
51
|
+
.sc-markdown table { display:block; max-width:100%; overflow-x:auto; }
|
|
52
|
+
.sc-content mark { background:var(--dsr-accent-soft,#ffd16670); color:inherit; }.sc-page [hidden] { display:none!important; }
|
|
53
|
+
@media(max-width:1100px) {
|
|
54
|
+
.sc-filters,.sc-page .sc-filters { grid-template-columns:repeat(3,minmax(0,1fr)) auto; }
|
|
55
|
+
.sc-filters input { grid-column:1/-1; }
|
|
56
|
+
}
|
|
57
|
+
@media(max-width:620px) {
|
|
58
|
+
.sc-heading { margin-bottom:16px; }.sc-heading h3 { font-size:21px; }
|
|
59
|
+
.sc-filters,.sc-page .sc-filters { grid-template-columns:repeat(2,minmax(0,1fr)); }.sc-filters input { grid-column:1/-1; }
|
|
60
|
+
.sc-body { grid-template-columns:1fr; }.sc-detail { position:static; }.sc-list { max-height:none; overflow-anchor:none; }
|
|
61
|
+
.sc-page .sc-list { grid-template-columns:1fr; }.sc-card { padding:18px; }.sc-page .sc-detail { padding:18px; }
|
|
62
|
+
.sc-detail .sc-content { max-height:45dvh; padding:14px; }.sc-page .sc-content { max-height:none; }
|
|
63
|
+
.sc-reading-tools { grid-template-columns:minmax(0,1fr) auto; }.sc-reading-tools input { grid-column:1/-1; }
|
|
64
|
+
.sc-summary { margin:16px 0; }.sc-updated { font-size:12px; }
|
|
65
|
+
}
|
|
66
|
+
@media(max-width:360px) {
|
|
67
|
+
.sc-card,.sc-page .sc-detail { padding:16px; }.sc-filters { gap:8px; }
|
|
68
|
+
.sc-filters :is(input,select,button),.sc-reading-tools :is(input,select,button) { font-size:13px; }
|
|
69
|
+
.sc-card h3 { font-size:17px; }.sc-detail h3 { font-size:19px; }
|
|
70
|
+
}
|
|
71
|
+
/* A wide window can still contain a narrow reading pane. */
|
|
72
|
+
@container skills (max-width:1000px) {
|
|
73
|
+
.sc-filters,.sc-page .sc-filters { grid-template-columns:repeat(3,minmax(0,1fr)) auto; }
|
|
74
|
+
.sc-filters input { grid-column:1/-1; }
|
|
75
|
+
}
|
|
76
|
+
@container skills (max-width:620px) {
|
|
77
|
+
.sc-filters,.sc-page .sc-filters { grid-template-columns:repeat(2,minmax(0,1fr)); }
|
|
78
|
+
.sc-page .sc-list { grid-template-columns:1fr; }
|
|
79
|
+
.sc-reading-tools { grid-template-columns:minmax(0,1fr) auto; }
|
|
80
|
+
.sc-reading-tools input { grid-column:1/-1; }
|
|
81
|
+
}
|
package/public/skills.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/* Shared read-only skill center. Skill text is displayed as text, never executed. */
|
|
2
|
+
'use strict';
|
|
3
|
+
window.DshSkillsCenter = (() => {
|
|
4
|
+
let current
|
|
5
|
+
const sourceNames = { 'project-dsh': '项目 · DSH', 'project-agents': '项目 · Agents', custom: '自定义目录', 'user-dsh': '用户 · DSH', 'user-agents': '用户 · Agents', runtime: '插件注册', bundled: '内置技能' }
|
|
6
|
+
const errors = { 'not-installed': '当前主机暂未提供技能中心,请返回插件列表核对状态。', unsupported: '主机技能中心接口不兼容,请核对插件版本。', 'host-denied': '主机拒绝读取技能,请检查主机认证状态。', 'skill-changed': '技能已变化,请刷新列表后重新选择。', 'skills-unavailable': '暂时无法读取主机技能,请重试。' }
|
|
7
|
+
function node(tag, text, cls) { const el = document.createElement(tag); if (text != null) el.textContent = text; if (cls) el.className = cls; return el }
|
|
8
|
+
function button(label, fn) { const el = node('button', label); el.type = 'button'; el.addEventListener('click', fn); return el }
|
|
9
|
+
function close() { if (current) { current.controller.abort(); current = null } }
|
|
10
|
+
function live(s) { return current === s && s.connection.valid() }
|
|
11
|
+
function placeDetail(s) {
|
|
12
|
+
const selected = s.cards.get(s.selected)
|
|
13
|
+
if (s.dedicated) {
|
|
14
|
+
s.detail.hidden = !s.detailOpen
|
|
15
|
+
s.body.hidden = s.detailOpen
|
|
16
|
+
for (const part of s.listParts) part.hidden = s.detailOpen
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
s.detail.hidden = s.mobile.matches && !selected
|
|
20
|
+
const parent = s.mobile.matches && selected ? selected.card : s.body
|
|
21
|
+
if (s.detail.parentNode !== parent) parent.append(s.detail)
|
|
22
|
+
for (const [id, { card, action }] of s.cards) {
|
|
23
|
+
const open = id === s.selected
|
|
24
|
+
card.className = 'sc-card' + (open ? ' is-selected' : '')
|
|
25
|
+
action.textContent = open ? '收起技能' : '查看技能'
|
|
26
|
+
action.setAttribute('aria-pressed', String(open))
|
|
27
|
+
action.setAttribute('aria-expanded', String(open))
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function scrollParent(el) {
|
|
31
|
+
for (let parent = el.parentElement; parent; parent = parent.parentElement) {
|
|
32
|
+
if (parent.scrollHeight > parent.clientHeight && /auto|scroll/.test(getComputedStyle(parent).overflowY)) return parent
|
|
33
|
+
}
|
|
34
|
+
return document.scrollingElement
|
|
35
|
+
}
|
|
36
|
+
async function api(s, route) {
|
|
37
|
+
if (!live(s)) throw new Error('连接已切换,请重新打开技能中心。')
|
|
38
|
+
const response = await fetch(s.connection.url('/remote/api/skills' + route), { headers: s.connection.headers,
|
|
39
|
+
signal: AbortSignal.any([s.controller.signal, AbortSignal.timeout(25000)]) })
|
|
40
|
+
if (!live(s)) throw new Error('连接已切换,请重新打开技能中心。')
|
|
41
|
+
let data
|
|
42
|
+
try { data = await response.json() } catch { throw new Error('主机 Remote 尚不支持技能中心,请更新主机插件。') }
|
|
43
|
+
if (!live(s)) throw new Error('连接已切换,请重新打开技能中心。')
|
|
44
|
+
if (!response.ok || data.ok === false || data.available === false) throw new Error(errors[data.code] || '请求失败,请检查连接后重试。')
|
|
45
|
+
return data
|
|
46
|
+
}
|
|
47
|
+
function renderList(s) {
|
|
48
|
+
const q = s.search.value.trim().toLowerCase(), source = s.sources.value, status = s.status.value
|
|
49
|
+
const rows = s.items.filter(row => (!source || row.source === source) && (!status || (status === 'on' ? row.modelInvocable === true : row.modelInvocable === false)))
|
|
50
|
+
.filter(row => [row.name, row.description, row.whenToUse, row.workspace].join(' ').toLowerCase().includes(q))
|
|
51
|
+
if (s.sort) rows.sort((a,b) => (s.sort.value === 'source' ? a.source.localeCompare(b.source) : 0) || a.name.localeCompare(b.name))
|
|
52
|
+
if (s.selected && !rows.some(row => row.id === s.selected)) {
|
|
53
|
+
s.selected = ''; ++s.detailSequence
|
|
54
|
+
s.detail.replaceChildren(node('h3', '技能详情'), node('p', '选择一个技能,查看适用场景和正文。'))
|
|
55
|
+
}
|
|
56
|
+
s.count.textContent = rows.length + ' / ' + s.items.length + ' 个技能'
|
|
57
|
+
s.list.replaceChildren()
|
|
58
|
+
s.cards.clear()
|
|
59
|
+
if (!rows.length) s.list.append(node('p', s.items.length ? '没有匹配的技能,试试更改筛选条件。' : '主机没有提供可显示的技能。', 'sc-empty'))
|
|
60
|
+
for (const row of rows) {
|
|
61
|
+
const card = node('article', null, 'sc-card' + (s.selected === row.id ? ' is-selected' : ''))
|
|
62
|
+
card.append(node('small', sourceNames[row.source] || row.source, 'sc-source'), node('h3', row.name), node('p', row.description || '未提供说明', 'sc-description'))
|
|
63
|
+
const flags = node('div', null, 'sc-flags')
|
|
64
|
+
flags.append(node('span', row.modelInvocable == null ? '模型调用状态未知' : row.modelInvocable ? '模型可调用' : '模型调用已停用', 'pc-badge sc-status' + (row.modelInvocable ? ' is-active' : '')))
|
|
65
|
+
if (row.workspace) flags.append(node('span', row.workspace, 'pc-badge'))
|
|
66
|
+
card.append(flags)
|
|
67
|
+
const action = button('查看技能', () => select(s, row)); card.append(action)
|
|
68
|
+
s.cards.set(row.id, { card, action })
|
|
69
|
+
s.list.append(card)
|
|
70
|
+
}
|
|
71
|
+
placeDetail(s)
|
|
72
|
+
}
|
|
73
|
+
async function select(s, row) {
|
|
74
|
+
if (!live(s)) return
|
|
75
|
+
const action = s.cards.get(row.id)?.action
|
|
76
|
+
const scroller = !s.dedicated && s.mobile.matches && action ? scrollParent(action) : null
|
|
77
|
+
const top = scroller ? action.getBoundingClientRect().top : 0
|
|
78
|
+
const collapse = !s.dedicated && s.selected === row.id
|
|
79
|
+
if (s.dedicated) {
|
|
80
|
+
if (!s.detailOpen) { s.returnScroller = scrollParent(s.shell); s.returnScroll = s.returnScroller?.scrollTop || 0 }
|
|
81
|
+
s.detailOpen = true
|
|
82
|
+
}
|
|
83
|
+
s.selected = collapse ? '' : row.id; const sequence = ++s.detailSequence
|
|
84
|
+
s.detail.replaceChildren(node('h3', collapse ? '技能详情' : row.name), node('p', collapse ? '选择一个技能,查看适用场景和正文。' : '正在读取技能…'))
|
|
85
|
+
placeDetail(s)
|
|
86
|
+
if (s.dedicated && s.returnScroller) s.returnScroller.scrollTop = 0
|
|
87
|
+
if (s.dedicated) s.detail.prepend(button('← 返回技能列表', () => back(s)))
|
|
88
|
+
if (scroller) scroller.scrollTop += action.getBoundingClientRect().top - top
|
|
89
|
+
if (collapse) return
|
|
90
|
+
try {
|
|
91
|
+
const data = await api(s, '/read?id=' + encodeURIComponent(row.id))
|
|
92
|
+
if (!live(s) || sequence !== s.detailSequence) return
|
|
93
|
+
const item = data.item || row
|
|
94
|
+
s.detail.replaceChildren(node('small', sourceNames[item.source] || item.source, 'sc-source'), node('h3', item.name), node('p', item.description || '未提供说明'))
|
|
95
|
+
if (item.whenToUse) s.detail.append(node('h4', '适用场景'), node('p', item.whenToUse))
|
|
96
|
+
s.detail.append(node('p', '模型调用:' + (item.modelInvocable == null ? '未知' : item.modelInvocable ? '允许' : '已停用') + ' · 手动调用:' + (item.userInvocable == null ? '未知' : item.userInvocable ? '允许' : '已停用'), 'sc-meta'), node('h4', '技能正文'))
|
|
97
|
+
s.detail.append(data.content == null ? node('p', '此技能未提供可读取的文件正文。') : node('pre', data.content || '正文为空。', 'sc-content'))
|
|
98
|
+
if (data.truncated) s.detail.append(node('p', '正文较长,当前显示前 100,000 个字符。', 'sc-notice'))
|
|
99
|
+
if (s.dedicated) {
|
|
100
|
+
s.detail.prepend(button('← 返回技能列表', () => back(s)))
|
|
101
|
+
if (data.content != null) readingTools(s, data.content)
|
|
102
|
+
s.detail.querySelector('button')?.focus({ preventScroll: true })
|
|
103
|
+
}
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (live(s) && sequence === s.detailSequence) s.detail.replaceChildren(node('h3', row.name), node('p', error.message), button('重试读取', () => { s.selected = ''; void select(s, row) }))
|
|
106
|
+
if (live(s) && s.dedicated && sequence === s.detailSequence) s.detail.prepend(button('← 返回技能列表', () => back(s)))
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function back(s = current) {
|
|
110
|
+
if (!s || !live(s) || !s.detailOpen) return false
|
|
111
|
+
++s.detailSequence; s.detailOpen = false; placeDetail(s)
|
|
112
|
+
if (s.returnScroller) s.returnScroller.scrollTop = s.returnScroll
|
|
113
|
+
s.cards.get(s.selected)?.action.focus({ preventScroll: true })
|
|
114
|
+
return true
|
|
115
|
+
}
|
|
116
|
+
function readingTools(s, content) {
|
|
117
|
+
const tools = node('div', null, 'sc-reading-tools'), search = node('input'), mode = node('select'), feedback = node('p', '', 'sc-meta')
|
|
118
|
+
search.placeholder = '搜索技能正文'; search.setAttribute('aria-label', '搜索技能正文')
|
|
119
|
+
for (const [value,label] of [['text','纯文本'],['markdown','Markdown 阅读']]) { const option=node('option',label); option.value=value; mode.append(option) }
|
|
120
|
+
mode.value = 'text'; mode.setAttribute('aria-label','正文显示方式')
|
|
121
|
+
const body = s.detail.querySelector('.sc-content')
|
|
122
|
+
const render = () => {
|
|
123
|
+
const query = search.value.trim()
|
|
124
|
+
if (!query && mode.value === 'markdown' && typeof window.mdToHtml === 'function') { body.className = 'sc-content sc-markdown'; body.innerHTML = window.mdToHtml(content); feedback.textContent=''; return }
|
|
125
|
+
body.className = 'sc-content'; body.replaceChildren()
|
|
126
|
+
let cursor=0,count=0,index; const lower=content.toLowerCase(),needle=query.toLowerCase()
|
|
127
|
+
while (needle && count<500 && (index=lower.indexOf(needle,cursor))>=0) {
|
|
128
|
+
body.append(document.createTextNode(content.slice(cursor,index)),node('mark',content.slice(index,index+query.length)));cursor=index+query.length;count++
|
|
129
|
+
}
|
|
130
|
+
body.append(document.createTextNode(content.slice(cursor))); feedback.textContent = query ? `找到 ${count}${count===500?'+' : ''} 处匹配 · 搜索时显示纯文本` : ''
|
|
131
|
+
}
|
|
132
|
+
search.addEventListener('input',render); mode.addEventListener('change',render)
|
|
133
|
+
const copy = button('复制正文',async()=>{ try { if (typeof window.copyText === 'function') { if (!await window.copyText(content)) throw new Error() } else await navigator.clipboard.writeText(content);feedback.textContent='正文已复制' } catch {feedback.textContent='复制失败,请选择正文后复制。'} })
|
|
134
|
+
tools.append(search,mode,copy); body.before(tools,feedback)
|
|
135
|
+
}
|
|
136
|
+
async function refresh() {
|
|
137
|
+
const s = current
|
|
138
|
+
if (!s || !live(s)) return
|
|
139
|
+
const sequence = ++s.listSequence; ++s.detailSequence
|
|
140
|
+
s.message.textContent = '正在读取主机技能…'; s.reload.disabled = true
|
|
141
|
+
try {
|
|
142
|
+
const data = await api(s, '/list')
|
|
143
|
+
if (!live(s) || sequence !== s.listSequence) return
|
|
144
|
+
if (data.schema !== 1 || !Array.isArray(data.items)) throw new Error(errors.unsupported)
|
|
145
|
+
s.items = data.items; s.selected = ''
|
|
146
|
+
const previous = s.sources.value
|
|
147
|
+
s.sources.replaceChildren(node('option', '全部来源'))
|
|
148
|
+
s.sources.children[0].value = ''
|
|
149
|
+
for (const key of [...new Set(s.items.map(row => row.source))]) { const option = node('option', (sourceNames[key] || key) + ' · ' + s.items.filter(row=>row.source===key).length); option.value = key; s.sources.append(option) }
|
|
150
|
+
s.sources.value = [...s.sources.children].some(option => option.value === previous) ? previous : ''
|
|
151
|
+
s.message.textContent = (data.complete === false ? '主机技能扫描尚不完整。' : '') + (data.truncated ? '当前显示前 500 个技能。' : '')
|
|
152
|
+
s.updated.textContent = '更新于 ' + new Date(data.generatedAt).toLocaleTimeString()
|
|
153
|
+
s.detail.replaceChildren(node('h3', '技能详情'), node('p', '选择一个技能,查看适用场景和正文。'))
|
|
154
|
+
renderList(s)
|
|
155
|
+
} catch (error) {
|
|
156
|
+
if (live(s) && sequence === s.listSequence) { s.message.textContent = error.message; s.updated.textContent = s.items.length ? '保留上次读取结果' : ''; if (!s.items.length) s.list.replaceChildren() }
|
|
157
|
+
} finally { if (live(s) && sequence === s.listSequence) s.reload.disabled = false }
|
|
158
|
+
}
|
|
159
|
+
async function mount(connection, target, options = {}) {
|
|
160
|
+
close()
|
|
161
|
+
const s = { connection, controller: new AbortController(), items: [], selected: '', cards: new Map(), listSequence: 0, detailSequence: 0,
|
|
162
|
+
dedicated: options.dedicated === true, detailOpen: false, mobile: window.matchMedia?.('(max-width:620px)') || { matches: false } }
|
|
163
|
+
current = s
|
|
164
|
+
const shell = node('section', null, 'sc-shell'), heading = node('div', null, 'sc-heading')
|
|
165
|
+
s.shell = shell; if (s.dedicated) shell.className += ' sc-page'
|
|
166
|
+
heading.append(node('h3', '技能中心'), node('p', '浏览主机技能、适用场景与调用状态。', 'sc-intro'))
|
|
167
|
+
const filters = node('div', null, 'sc-filters')
|
|
168
|
+
s.search = node('input'); s.search.value = ''; s.search.placeholder = '搜索技能名称、说明或适用场景'; s.search.setAttribute('aria-label', '搜索技能')
|
|
169
|
+
s.sources = node('select'); s.sources.setAttribute('aria-label', '技能来源')
|
|
170
|
+
s.status = node('select'); s.status.setAttribute('aria-label', '模型调用状态')
|
|
171
|
+
for (const [value, label] of [['', '全部调用状态'], ['on', '模型可调用'], ['off', '模型调用已停用']]) { const option = node('option', label); option.value = value; s.status.append(option) }
|
|
172
|
+
s.status.value = ''; s.sources.value = ''
|
|
173
|
+
for (const el of [s.search, s.sources, s.status]) el.addEventListener(el === s.search ? 'input' : 'change', () => { if (live(s)) renderList(s) })
|
|
174
|
+
s.reload = button('刷新技能', refresh); filters.append(s.search, s.sources, s.status)
|
|
175
|
+
if (s.dedicated) { s.sort=node('select');s.sort.setAttribute('aria-label','技能排序');for(const [value,label] of [['name','按名称'],['source','按来源']]){const option=node('option',label);option.value=value;s.sort.append(option)}s.sort.value='name';s.sort.addEventListener('change',()=>{if(live(s))renderList(s)});filters.append(s.sort) }
|
|
176
|
+
filters.append(s.reload)
|
|
177
|
+
s.message = node('p', '', 'sc-notice'); s.message.setAttribute('role', 'status')
|
|
178
|
+
s.count = node('strong', '', 'sc-count'); s.updated = node('small', '', 'sc-updated')
|
|
179
|
+
const summary = node('div', null, 'sc-summary'); summary.append(s.count, s.updated)
|
|
180
|
+
s.list = node('div', null, 'sc-list'); s.detail = node('section', null, 'sc-detail'); s.detail.setAttribute('aria-label', '技能详情')
|
|
181
|
+
const body = node('div', null, 'sc-body'); s.body = body; body.append(s.list); if(!s.dedicated) body.append(s.detail)
|
|
182
|
+
s.listParts = [heading, filters, s.message, summary]
|
|
183
|
+
const resize = () => { if (live(s)) placeDetail(s) }
|
|
184
|
+
s.mobile.addEventListener?.('change', resize)
|
|
185
|
+
s.controller.signal.addEventListener('abort', () => s.mobile.removeEventListener?.('change', resize), { once: true })
|
|
186
|
+
shell.append(heading, filters, s.message, summary, body); target.replaceChildren(shell)
|
|
187
|
+
if(s.dedicated)shell.append(s.detail)
|
|
188
|
+
await refresh()
|
|
189
|
+
}
|
|
190
|
+
return { mount, close, refresh, back }
|
|
191
|
+
})()
|
package/public/styles.css
CHANGED
|
@@ -370,9 +370,17 @@ body.in-session .view {
|
|
|
370
370
|
.queue-dock-item:last-child { border-bottom: 0; }
|
|
371
371
|
.queue-dock-preview { flex: 1; min-width: 0; color: var(--dsr-text); font-size: 13px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
372
372
|
.queue-dock-action { flex: 0 0 auto; }
|
|
373
|
-
.session-pending { flex:0
|
|
373
|
+
.session-pending { flex:0 1 auto; min-height:0; max-height:30vh; max-height:30dvh; display:flex; flex-direction:column; margin:0 0 10px; padding:10px; border:1px solid var(--dsr-warning-line); border-radius:13px; background:var(--dsr-warning-soft); }
|
|
374
374
|
.session-pending-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; color:var(--dsr-text); font-size:12px; font-weight:750; }
|
|
375
|
-
.session-pending-
|
|
375
|
+
.session-pending-head { flex:none; }
|
|
376
|
+
.session-pending-list { min-height:0; overflow-y:auto; overscroll-behavior:contain; display:flex; flex-direction:column; gap:8px; }
|
|
377
|
+
.session-pending-list > * { flex:none; }
|
|
378
|
+
.session-pending button.question { width:100%; text-align:left; }
|
|
379
|
+
.session-pending .pc-title { display:block; }
|
|
380
|
+
.question-card-head { display:flex; align-items:center; justify-content:space-between; gap:10px; }
|
|
381
|
+
.question-card-head .pc-title { min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
|
|
382
|
+
.question-card-head .mini-btn { flex:none; white-space:nowrap; }
|
|
383
|
+
.question-summary { display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; overflow-wrap:anywhere; font-size:13px; line-height:1.45; margin-top:5px; color:var(--dsr-muted); }
|
|
376
384
|
.session-pending .pending-card { min-width:0; background:var(--dsr-panel); }
|
|
377
385
|
.session-pending .pc-title { line-height:1.45; overflow-wrap:anywhere; word-break:break-word; }
|
|
378
386
|
.session-pending .pc-desc { line-height:1.5; white-space:pre-wrap; overflow-wrap:anywhere; }
|
|
@@ -1107,6 +1115,16 @@ button.overview-attention-item, button.overview-session-item { cursor:pointer; }
|
|
|
1107
1115
|
border: 1px solid var(--dsr-line); border-radius: 10px; padding: 9px 11px; font: inherit; outline: none;
|
|
1108
1116
|
}
|
|
1109
1117
|
.modal-actions { display: flex; gap: 9px; margin-top: 14px; }
|
|
1118
|
+
#modal-question { box-sizing:border-box; padding:max(12px, var(--dsr-safe-top)) 12px max(12px, var(--dsr-safe-b)); }
|
|
1119
|
+
#modal-question .modal-card { box-sizing:border-box; display:flex; flex-direction:column; min-height:0; max-height:100%; overflow:hidden; }
|
|
1120
|
+
#modal-question .modal-title, #modal-question .modal-actions { flex:none; }
|
|
1121
|
+
#question-body { min-height:0; overflow-y:auto; overscroll-behavior:contain; overflow-wrap:anywhere; }
|
|
1122
|
+
#question-body .q-item { min-width:0; }
|
|
1123
|
+
#question-body .q-text { font-weight:400; }
|
|
1124
|
+
#question-body .q-text p { margin:6px 0; }
|
|
1125
|
+
#question-body .q-option { min-height:44px; cursor:pointer; }
|
|
1126
|
+
#question-body .q-option > span { min-width:0; overflow-wrap:anywhere; }
|
|
1127
|
+
#question-body pre { white-space:pre-wrap; overflow-wrap:anywhere; }
|
|
1110
1128
|
.archive-modal-desc { margin: 0 0 12px; color: var(--dsr-muted); line-height: 1.55; }
|
|
1111
1129
|
.archive-summary { border: 1px solid var(--dsr-line); border-radius: 12px; background: var(--dsr-panel); padding: 10px 12px; }
|
|
1112
1130
|
.archive-summary-row { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 10px; align-items: start; padding: 6px 0; font-size: 13px; }
|
|
@@ -1337,3 +1355,10 @@ html[lang="en"] .overview-status { min-block-size:2.5em; }
|
|
|
1337
1355
|
.overview-pulse-card.status-checking .pulse-sweep { opacity:.4; }
|
|
1338
1356
|
.overview-pulse-card .pulse-text-echo { display:none; }
|
|
1339
1357
|
}
|
|
1358
|
+
/* Compact conversation chrome; full title and workspace remain in session info. */
|
|
1359
|
+
body.in-session .session-head { padding-top:calc(var(--dsr-safe-top) + 4px); padding-bottom:4px; }
|
|
1360
|
+
.session-head #session-title { display:block; white-space:nowrap; text-overflow:ellipsis; overflow:hidden; line-height:44px; -webkit-line-clamp:unset; }
|
|
1361
|
+
body.in-session #session-sub { min-height:32px; padding:4px 2px; }
|
|
1362
|
+
.chat-file { display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px; padding:12px; border:1px solid var(--dsr-line); border-radius:12px; margin:8px 0; }
|
|
1363
|
+
.chat-file-name { min-width:0; flex:1; overflow-wrap:break-word; }.chat-file small { color:var(--dsr-muted); }
|
|
1364
|
+
.chat-file button { flex-shrink:0; min-height:44px; padding:8px 12px; border:1px solid var(--dsr-accent-line); border-radius:10px; color:var(--dsr-accent-strong); background:var(--dsr-accent-soft); font:inherit; cursor:pointer; }
|
package/public/theme-vars.css
CHANGED
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
--dsr-safe-top: max(env(safe-area-inset-top, 0px), var(--native-top, 0px));
|
|
9
9
|
--dsr-safe-b: max(env(safe-area-inset-bottom, 0px), var(--native-bottom, 0px));
|
|
10
10
|
}
|
|
11
|
+
/* Native geometry already subtracts any system padding consumed by the WebView. */
|
|
12
|
+
html[data-native-insets="overlap"] {
|
|
13
|
+
--dsr-safe-top: var(--native-top, 0px);
|
|
14
|
+
--dsr-safe-b: var(--native-bottom, 0px);
|
|
15
|
+
}
|
|
11
16
|
|
|
12
17
|
html,
|
|
13
18
|
html[data-theme="default"],
|
package/public/update.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.7.
|
|
2
|
+
"version": "0.7.6",
|
|
3
3
|
"apkUrl": "dsh-remote.apk",
|
|
4
|
-
"sha256": "
|
|
5
|
-
"releasedAt": "2026-10-
|
|
6
|
-
"notes": "
|
|
4
|
+
"sha256": "33e85026a3b95f341ade14b1ee97db9ac2dea97a4ef3f55976be86e7a2655e1d",
|
|
5
|
+
"releasedAt": "2026-10-15T04:38:27.277Z",
|
|
6
|
+
"notes": "修复长提问占满会话导致无法回答,支持点击摘要卡片并在独立滚动弹窗中选择;补齐 Android 后台审批与提问通知、请求去重及会话跳转;支持普通相对路径聊天文件下载,并反馈系统下载完成或失败原因。",
|
|
7
7
|
"history": [
|
|
8
|
+
{
|
|
9
|
+
"version": "0.7.6",
|
|
10
|
+
"notes": "修复长提问占满会话导致无法回答,支持点击摘要卡片并在独立滚动弹窗中选择;补齐 Android 后台审批与提问通知、请求去重及会话跳转;支持普通相对路径聊天文件下载,并反馈系统下载完成或失败原因。"
|
|
11
|
+
},
|
|
8
12
|
{
|
|
9
13
|
"version": "0.7.4",
|
|
10
14
|
"notes": "修复 Windows Desktop 进程核验拖慢健康检查和管理页的问题:后台缓存并合并探测,测速与首页检测使用存活检查,控制操作仍实时核验身份。修复管理代理超时误报认证失败、操作进度参数丢失、状态轮询竞态及禁用后仍探测 Desktop 崩溃日志。修复桌面对话切换时消息发错会话、压缩状态串会话、归档关闭新会话、服务器切换串用 WS 票据、同源会话导出认证、Desktop 管理页网关地址以及不同本地 IP 同号端口误判。同步修复手机端共享的票据、命令与导出逻辑。继续修复连接切换后旧模型、审批、队列和压缩状态残留,测速覆盖手动选择,新建会话跳错服务器,目标编辑串会话,以及工作台绑定和模型密钥保存串服务器。桌面发送失败保留草稿并避免重复提交。优化实时历史插入、事件列表刷新和子代理查询,修复桌面实时消息被误判无变化;连接切换可立即开始新轮询,旧结果不会覆盖新状态。加强弱网传输:历史与前端资源按需 gzip 压缩、ETag 缓存验证,双通道独立长轮询避免互相阻塞,弱网模式减少历史分页并延长只读等待;Android 后台支持 gzip。修复桌面首次连接依赖系统 prompt 的问题。Android 已完成构建,尚未手机真机验收;本次不提供 HarmonyOS HAP。"
|
|
@@ -40,10 +44,6 @@
|
|
|
40
44
|
{
|
|
41
45
|
"version": "0.6.23",
|
|
42
46
|
"notes": "0.6.23:加强 DSH 版本兼容。旧版点号 RPC 与新版 slash Remote API 可自动协商和回退,修复部分新版 DSH 中 host.describe、创建会话等请求返回 404 的问题;DSH 重启或升级后会重新识别协议并恢复实时通道。反馈时可由用户选择附带脱敏兼容性诊断,便于定位接口问题;诊断不包含令牌、Cookie、对话内容或文件路径。"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"version": "0.6.22",
|
|
46
|
-
"notes": "0.6.22:斜杠命令统一后台受理并显示运行状态与耗时,/compact 不再受两分钟请求等待限制;/export 可在手机保存到系统下载目录、在浏览器按下载设置保存会话 ZIP;修复命令桥接超时后被误作为普通消息发送的问题。首次有多条未读公告时改为单一分页窗口,可左右切换,确认一次即可全部标为已读。"
|
|
47
47
|
}
|
|
48
48
|
]
|
|
49
49
|
}
|
package/public/version.json
CHANGED