dsh-remote-plugin 0.8.2 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/apk/dsh-remote.apk +0 -0
- package/approval-summary.mjs +115 -0
- package/gateway.cjs +708 -70
- package/index.mjs +12 -0
- package/insights.mjs +6 -4
- package/market.mjs +4 -1
- package/package.json +2 -1
- package/plugin-center.mjs +208 -24
- package/plugin-transaction.mjs +29 -6
- package/public/admin.html +33 -34
- package/public/admin.js +12 -24
- package/public/announcements.json +31 -0
- package/public/app.js +99 -80
- package/public/approval-summary.js +78 -0
- package/public/build.json +2 -2
- package/public/cache-upgrade.js +51 -0
- package/public/chat-copy.js +59 -0
- package/public/desktop/desktop.css +23 -34
- package/public/desktop/desktop.html +83 -96
- package/public/desktop/desktop.js +68 -51
- package/public/e2ee-transport.js +147 -0
- package/public/extensions.js +6 -6
- package/public/history.js +88 -6
- package/public/image-cache.js +141 -0
- package/public/image-preview.js +48 -5
- package/public/index.html +86 -104
- package/public/md.js +39 -15
- package/public/motion.js +1 -1
- package/public/plugin-center.css +1 -0
- package/public/plugin-center.js +93 -12
- package/public/plugin.html +27 -20
- package/public/relay-devices.js +74 -0
- package/public/relay-settings.css +7 -0
- package/public/relay-settings.js +17 -9
- package/public/session-deck.css +7 -1
- package/public/session-deck.js +1 -1
- package/public/skins/blue-fish/DESIGN.md +24 -0
- package/public/skins/blue-fish/preview.html +12 -289
- package/public/skins/blue-fish/skin.css +95 -585
- package/public/skins/blue-fish/sparkles.svg +18 -0
- package/public/skins/bocchi/DESIGN.md +99 -0
- package/public/skins/bocchi/face.png +0 -0
- package/public/skins/bocchi/grain.png +0 -0
- package/public/skins/bocchi/icon-blush.png +0 -0
- package/public/skins/bocchi/icon-sleep.png +0 -0
- package/public/skins/bocchi/icon-smile.png +0 -0
- package/public/skins/bocchi/icon-star.png +0 -0
- package/public/skins/bocchi/icon-wink.png +0 -0
- package/public/skins/bocchi/icon.png +0 -0
- package/public/skins/bocchi/pattern-soft.png +0 -0
- package/public/skins/bocchi/pattern.png +0 -0
- package/public/skins/bocchi/preview.html +55 -0
- package/public/skins/bocchi/skin.css +233 -0
- package/public/skins/bocchi/stage-bg.png +0 -0
- package/public/skins/bocchi/stage-soft.png +0 -0
- package/public/skins/bocchi/stand.png +0 -0
- package/public/skins/bocchi/sticker-guitar.png +0 -0
- package/public/skins/kessoku/DESIGN.md +38 -0
- package/public/skins/kessoku/grain.png +0 -0
- package/public/skins/kessoku/skin.css +212 -0
- package/public/skins/kita/SOURCES.json +51 -0
- package/public/skins/kita/face.png +0 -0
- package/public/skins/kita/icon-live.png +0 -0
- package/public/skins/kita/icon-reddress.png +0 -0
- package/public/skins/kita/icon-seifuku.png +0 -0
- package/public/skins/kita/pattern.png +0 -0
- package/public/skins/kita/preview.html +56 -0
- package/public/skins/kita/skin.css +26 -0
- package/public/skins/kita/stand.png +0 -0
- package/public/skins/kita/sticker-live.png +0 -0
- package/public/skins/nijika/SOURCES.json +51 -0
- package/public/skins/nijika/face.png +0 -0
- package/public/skins/nijika/icon-live.png +0 -0
- package/public/skins/nijika/icon-reddress.png +0 -0
- package/public/skins/nijika/icon-seifuku.png +0 -0
- package/public/skins/nijika/pattern.png +0 -0
- package/public/skins/nijika/preview.html +56 -0
- package/public/skins/nijika/skin.css +25 -0
- package/public/skins/nijika/stand.png +0 -0
- package/public/skins/nijika/sticker-live.png +0 -0
- package/public/skins/penguin/DESIGN.md +33 -0
- package/public/skins/penguin/SOURCES.json +22 -0
- package/public/skins/penguin/aic-blueprint.svg +24 -0
- package/public/skins/penguin/endfield-triangles.svg +4 -0
- package/public/skins/penguin/face.png +0 -0
- package/public/skins/penguin/icon-blush.png +0 -0
- package/public/skins/penguin/icon-dizzy.png +0 -0
- package/public/skins/penguin/icon-laugh.png +0 -0
- package/public/skins/penguin/icon-sleep.png +0 -0
- package/public/skins/penguin/icon-smile.png +0 -0
- package/public/skins/penguin/icon-star.png +0 -0
- package/public/skins/penguin/icon-wink.png +0 -0
- package/public/skins/penguin/icon.png +0 -0
- package/public/skins/penguin/mascot.png +0 -0
- package/public/skins/penguin/pattern-night.png +0 -0
- package/public/skins/penguin/pattern.png +0 -0
- package/public/skins/penguin/preview.html +12 -0
- package/public/skins/penguin/skin.css +212 -0
- package/public/skins/ryo/SOURCES.json +51 -0
- package/public/skins/ryo/face.png +0 -0
- package/public/skins/ryo/icon-live.png +0 -0
- package/public/skins/ryo/icon-reddress.png +0 -0
- package/public/skins/ryo/icon-seifuku.png +0 -0
- package/public/skins/ryo/pattern.png +0 -0
- package/public/skins/ryo/preview.html +56 -0
- package/public/skins/ryo/skin.css +25 -0
- package/public/skins/ryo/stand.png +0 -0
- package/public/skins/ryo/sticker-live.png +0 -0
- package/public/sponsor-entry.js +21 -0
- package/public/styles.css +29 -19
- package/public/teams.js +2 -2
- package/public/theme-picker.css +58 -0
- package/public/theme-vars.css +532 -5
- package/public/theme.js +111 -3
- package/public/update.json +12 -12
- package/public/version.json +1 -1
- package/public/workflow.css +2 -1
- package/public/workflow.js +27 -5
- package/skills/dsh-remote-doctor/references/wiki/plugins.md +1 -1
- package/task-board.mjs +2 -2
- package/teams.mjs +7 -2
|
@@ -33,7 +33,13 @@ const THEME_META = [
|
|
|
33
33
|
{ id: 'light', sw: ['#F5F7F8', '#FFFFFF', '#176B87'] },
|
|
34
34
|
{ id: 'neutral', sw: ['#EEF1E8', '#FAFBF6', '#47643C'] },
|
|
35
35
|
{ id: 'mono', sw: ['#050505', '#333333', '#F5F5F5'] },
|
|
36
|
-
{ id: 'fish', sw: ['#EAF6FF', '#FFFFFF', '#2F52D0'] }
|
|
36
|
+
{ id: 'fish', sw: ['#EAF6FF', '#FFFFFF', '#2F52D0'] },
|
|
37
|
+
{ id: 'penguin', sw: ['#EDF3FA', '#FFFFFF', '#2B6CB0'] },
|
|
38
|
+
{ id: 'penguin-night', sw: ['#10151B', '#1A222C', '#F2C230'] },
|
|
39
|
+
{ id: 'bocchi', sw: ['#FFD9E8', '#FFFFFF', '#D0105A'] },
|
|
40
|
+
{ id: 'nijika', sw: ['#FFF3D5', '#FFFFFF', '#94600C'] },
|
|
41
|
+
{ id: 'ryo', sw: ['#E9F1FA', '#FFFFFF', '#315D91'] },
|
|
42
|
+
{ id: 'kita', sw: ['#FFE9E5', '#FFFFFF', '#B6373C'] }
|
|
37
43
|
]
|
|
38
44
|
function themeGet() {
|
|
39
45
|
const v = LS.get('dshTheme', '')
|
|
@@ -117,6 +123,7 @@ for (const key of ['server', 'token']) {
|
|
|
117
123
|
if (next === value) return
|
|
118
124
|
cancelHistoryLoad()
|
|
119
125
|
value = next; connectionGeneration++
|
|
126
|
+
window.DshImagePreview?.reset?.()
|
|
120
127
|
clearTimeout(state.refreshTimer); state.refreshTimer = null
|
|
121
128
|
state.sessions = []; state.byId.clear(); state.pendingProjections.clear(); state.runtimeErrors = new Map()
|
|
122
129
|
state.hostInfo = null
|
|
@@ -134,6 +141,7 @@ for (const key of ['server', 'token']) {
|
|
|
134
141
|
window.DshExtensions?.invalidateCapabilities()
|
|
135
142
|
window.DshFileInbox?.reset()
|
|
136
143
|
window.DshSessionDeck?.reset()
|
|
144
|
+
window.DshApprovalSummary?.reset()
|
|
137
145
|
if (typeof document !== 'undefined') document.getElementById('btn-insights')?.classList.add('hidden')
|
|
138
146
|
if(typeof document!=='undefined') {
|
|
139
147
|
const identityGeneration=connectionGeneration
|
|
@@ -209,7 +217,7 @@ function renderPresetMenuDesktop() {
|
|
|
209
217
|
menu.innerHTML = `<div class="ds-empty">${esc(t('ds.presetsEmpty'))}</div><div class="ds-empty ds-presets-guide">${esc(t('ds.presetsGuide'))}</div>`
|
|
210
218
|
return
|
|
211
219
|
}
|
|
212
|
-
menu.innerHTML = list.map(p => `<button class="ds-
|
|
220
|
+
menu.innerHTML = list.map(p => `<button class="ds-action-item" data-ds-preset="${esc(p.id)}">${esc(p.name)}</button>`).join('')
|
|
213
221
|
}
|
|
214
222
|
const PRESET_NAME_MAX = 20
|
|
215
223
|
const PRESET_TEXT_MAX = 2000
|
|
@@ -447,12 +455,6 @@ async function selectSessionModel(provider, modelId) {
|
|
|
447
455
|
}
|
|
448
456
|
|
|
449
457
|
/* ---------------- 反馈 ---------------- */
|
|
450
|
-
const FEEDBACK_LINKS = {
|
|
451
|
-
githubIssues: 'https://github.com/Blank-not-black/dsh-Remote/issues',
|
|
452
|
-
giteeIssues: 'https://gitee.com/Blankneverfails/dsh-Remote/issues',
|
|
453
|
-
bili: 'https://space.bilibili.com/419009275/dynamic',
|
|
454
|
-
repo: 'https://github.com/Blank-not-black/dsh-Remote'
|
|
455
|
-
}
|
|
456
458
|
async function copyText(text) {
|
|
457
459
|
try { await navigator.clipboard.writeText(text); return true } catch {}
|
|
458
460
|
try {
|
|
@@ -463,19 +465,6 @@ async function copyText(text) {
|
|
|
463
465
|
ta.remove(); return ok
|
|
464
466
|
} catch { return false }
|
|
465
467
|
}
|
|
466
|
-
function openFeedbackMenu() {
|
|
467
|
-
$('feedback-menu').classList.remove('hidden')
|
|
468
|
-
$('btn-feedback').setAttribute('aria-expanded', 'true')
|
|
469
|
-
const first = $('feedback-menu').querySelector('[role="menuitem"]')
|
|
470
|
-
if (first) first.focus()
|
|
471
|
-
}
|
|
472
|
-
function closeFeedbackMenu() {
|
|
473
|
-
$('feedback-menu').classList.add('hidden')
|
|
474
|
-
$('btn-feedback').setAttribute('aria-expanded', 'false')
|
|
475
|
-
}
|
|
476
|
-
function toggleFeedbackMenu() {
|
|
477
|
-
$('feedback-menu').classList.contains('hidden') ? openFeedbackMenu() : closeFeedbackMenu()
|
|
478
|
-
}
|
|
479
468
|
function doctorEnvironment() {
|
|
480
469
|
let report = {}
|
|
481
470
|
try { report = globalThis.DshDiagnostics?.report?.() || {} } catch {}
|
|
@@ -496,7 +485,6 @@ function doctorEnvironment() {
|
|
|
496
485
|
}
|
|
497
486
|
}
|
|
498
487
|
function openDoctor() {
|
|
499
|
-
closeFeedbackMenu()
|
|
500
488
|
if (!window.DshDoctor) {
|
|
501
489
|
toast(t('ds.feedbackSubmitFailed', { msg: 'doctor unavailable' }), 'err')
|
|
502
490
|
return
|
|
@@ -527,6 +515,7 @@ function openFeedbackModal() {
|
|
|
527
515
|
$('fb-include-diagnostics').checked = false
|
|
528
516
|
$('fb-include-crashes').checked = false
|
|
529
517
|
$('fb-crash-details').open = false
|
|
518
|
+
updateFeedbackLength()
|
|
530
519
|
void loadCrashPreview()
|
|
531
520
|
$('modal-feedback').classList.remove('hidden')
|
|
532
521
|
setTimeout(() => $('fb-msg').focus(), 50)
|
|
@@ -662,6 +651,12 @@ async function loadCrashPreview() {
|
|
|
662
651
|
if(crashes){const data=await read('/crash-logs');evidence.crashes=data.upload||data}
|
|
663
652
|
if(connection.valid()&&generation===loadCrashPreview.generation)preview.textContent=JSON.stringify(evidence,null,2)
|
|
664
653
|
}
|
|
654
|
+
function updateFeedbackLength() {
|
|
655
|
+
const length = $('fb-msg').value.trim().length, over = length > 20000
|
|
656
|
+
$('fb-length').textContent = I18N.lang === 'en' ? length + ' / 20000 characters' + (over ? ' — shorten before submitting; your text is preserved.' : '') : length + ' / 20000 字符' + (over ? ',请精简后提交;全文已保留。' : '')
|
|
657
|
+
$('fb-msg').setAttribute('aria-invalid', String(over))
|
|
658
|
+
$('fb-copy-draft').textContent = I18N.lang === 'en' ? 'Copy text' : '复制全文'
|
|
659
|
+
}
|
|
665
660
|
async function submitFeedback() {
|
|
666
661
|
const type = document.querySelector('#fb-chips .ds-fb-chip.current')?.dataset.fbType || 'bug'
|
|
667
662
|
const message = $('fb-msg').value.trim()
|
|
@@ -670,7 +665,7 @@ async function submitFeedback() {
|
|
|
670
665
|
const includeCrashLogs = $('fb-include-crashes').checked
|
|
671
666
|
const clientDiagnostics=includeDiagnostics?globalThis.DshDiagnostics?.report():null
|
|
672
667
|
if (!message) { toast(t('ds.feedbackEmpty'), 'err'); return }
|
|
673
|
-
if (message.length >
|
|
668
|
+
if (message.length > 20000) { toast(t('ds.feedbackTooLong'), 'err'); return }
|
|
674
669
|
const btn = $('fb-submit')
|
|
675
670
|
btn.disabled = true
|
|
676
671
|
const diagnostic=globalThis.DshDiagnostics?.start('feedback.submit')
|
|
@@ -688,10 +683,15 @@ async function submitFeedback() {
|
|
|
688
683
|
toast(clientDiagnostics&&!saved?(I18N.lang==='en'?'Feedback received; complete diagnostic report not confirmed. Copy or export the local log.':'反馈已收到,但完整诊断日志未获保存确认,请复制或导出本地日志补充。'):t('ds.feedbackSubmitted'),clientDiagnostics&&!saved?'err':'ok')
|
|
689
684
|
}
|
|
690
685
|
else if (res.status === 429) { toast(t('ds.feedbackRateLimited'), 'err') }
|
|
686
|
+
else if (json.error === 'message too long' && Number.isSafeInteger(json.max)) { toast(I18N.lang === 'en' ? 'This gateway limits feedback to ' + json.max + ' characters. Your full text is preserved; update the host gateway.' : '当前网关正文上限为 ' + json.max + ' 字符,全文已保留;请更新主机网关。', 'err') }
|
|
687
|
+
else if (json.error === 'collector-message-limit') { toast(I18N.lang === 'en' ? 'The collector still limits feedback to ' + json.max + ' characters. Your full text is preserved; copy it before updating the collector.' : '收集器仍只支持 ' + json.max + ' 字符,全文已保留;可先复制全文,待收集器升级后再提交。', 'err') }
|
|
688
|
+
else if (json.error === 'collector-body-limit') { toast(I18N.lang === 'en' ? 'The collector rejected the request size. Your full text is preserved; copy it before updating the collector.' : '收集器请求体超限,全文已保留;请先复制,待收集器升级后再提交。', 'err') }
|
|
689
|
+
else if (json.error === 'feedback_service_unavailable') { toast(I18N.lang === 'en' ? 'Delivery is unconfirmed; it may have been received. Your text is preserved. Check before resubmitting.' : '发送结果未确认,可能已收到。全文已保留,请先核对,勿重复提交。', 'err') }
|
|
690
|
+
else if (json.error === 'feedback-content-unconfirmed') { toast(I18N.lang === 'en' ? 'The content receipt did not match. It may have been received; check before resubmitting. Your text is preserved.' : '正文保存回执不一致,可能已收到;请先核对,勿重复提交。全文已保留。', 'err') }
|
|
691
691
|
else { toast(t('ds.feedbackSubmitFailed', { msg: json.error || res.status }), 'err') }
|
|
692
692
|
} catch(error) {
|
|
693
693
|
diagnostic?.fail(error)
|
|
694
|
-
toast(
|
|
694
|
+
toast(I18N.lang === 'en' ? 'Delivery is unconfirmed; it may have been received. Your text is preserved. Check before resubmitting.' : '发送结果未确认,可能已收到。全文已保留,请先核对,勿重复提交。', 'err')
|
|
695
695
|
} finally {
|
|
696
696
|
btn.disabled = false
|
|
697
697
|
}
|
|
@@ -1236,6 +1236,8 @@ function editServer(id) {
|
|
|
1236
1236
|
function removeServer(id) {
|
|
1237
1237
|
const s = state.servers.find(x => x.id === id)
|
|
1238
1238
|
if (!s) return
|
|
1239
|
+
void window.DshImageCache?.clear(historyCacheScope(s.url,serverToken(s)))
|
|
1240
|
+
void window.DshHistory.cacheClear(historyCacheScope(s.url,serverToken(s)))
|
|
1239
1241
|
state.servers = state.servers.filter(x => x.id !== id)
|
|
1240
1242
|
const wasActive = state.server === s.url && state.token === serverToken(s)
|
|
1241
1243
|
for (const g of state.groups) if (state.groupActive[g] === id) state.groupActive[g] = ''
|
|
@@ -2196,7 +2198,11 @@ function restoreCachedSessionList() {
|
|
|
2196
2198
|
}
|
|
2197
2199
|
|
|
2198
2200
|
let conversationView = null
|
|
2199
|
-
function historyCacheScope() { const hash=new SHA256();hash.update(new TextEncoder().encode(JSON.stringify([
|
|
2201
|
+
function historyCacheScope(server=state.server,token=state.token) { const hash=new SHA256();hash.update(new TextEncoder().encode(JSON.stringify([server||location.origin,token])));return 'historyCacheV2:'+hash.hex() }
|
|
2202
|
+
function captureChatImage() {
|
|
2203
|
+
const connection=captureConnection(),sessionId=state.current
|
|
2204
|
+
return {scope:historyCacheScope(),valid:()=>connection.valid()&&state.current===sessionId}
|
|
2205
|
+
}
|
|
2200
2206
|
function historySource(value) {
|
|
2201
2207
|
state.history.source=value
|
|
2202
2208
|
const el=$('history-source')
|
|
@@ -2420,7 +2426,8 @@ function blockHtml(b,index=0,context={}) {
|
|
|
2420
2426
|
if (b.type==='thinking'||b.type==='reasoning') return window.DshActivity.reasoning({text:b.text??b.content??'',key:window.DshActivity.reasoningKey(context,index,key)})
|
|
2421
2427
|
if (b.type==='tool-call'||b.type==='tool-result') return window.DshActivity.tool({key,name:b.name||b.toolName,...(b.type==='tool-call'?{args:b.arguments??b.args??b.input}:{result:b.result??b.output??b.content??b,error:!!(b.error||b.ok===false||b.isError)})})
|
|
2422
2428
|
}
|
|
2423
|
-
if (b.type === 'text') return window.DshActivity.hasVisibleText(b.text) ? `<div class="md">${window.mdToHtml ? window.mdToHtml(b.text ?? '', { fileLinks: true, imageLabel: t('block.image') }) : esc(b.text ?? '')}</div>` : ''
|
|
2429
|
+
if (b.type === 'text') return window.DshActivity.hasVisibleText(b.text) ? `<div class="md">${window.mdToHtml ? window.mdToHtml(b.text ?? '', { fileLinks: true, imageLabel: t('block.image'), copyCode: true, copyScope: window.DshChatCopy?.scope(state.history), copyCodeLabel: window.I18N?.lang === 'en' ? 'Copy code' : '复制代码' }) : esc(b.text ?? '')}</div>` : ''
|
|
2430
|
+
if (b.type === 'code') return window.DshChatCopy?.code(b.content ?? b.code ?? '', b.language || b.lang || '', { scope: window.DshChatCopy?.scope(state.history) }) || `<pre><code>${esc(b.content ?? b.code ?? '')}</code></pre>`
|
|
2424
2431
|
if (b.type === 'file' && typeof window !== 'undefined' && window.DshChatFiles) return window.DshChatFiles.render(b)
|
|
2425
2432
|
if (b.type === 'file') return `<div class="ds-tool">📎 ${esc(b.attachment?.name || b.name || 'file')} <small>${esc(b.attachment?.bytes ?? b.bytes ?? '')} bytes</small></div>`
|
|
2426
2433
|
if (b.type === 'thinking' || b.type === 'reasoning') return `<details><summary>${esc(t('block.thinking'))}</summary><div style="opacity:.82">${esc(b.text ?? b.content ?? '')}</div></details>`
|
|
@@ -2501,6 +2508,10 @@ function canForkTurnResult() {
|
|
|
2501
2508
|
return !!session && session.origin !== 'subagent' && session.formatStatus !== 'migration-required' && activeGatewayCapability('operations') === true
|
|
2502
2509
|
}
|
|
2503
2510
|
function bindTurnResultActions() {
|
|
2511
|
+
window.DshChatCopy?.bind($('history'), {
|
|
2512
|
+
capture: () => { const connection = captureConnection(), sessionId = state.current, history = state.history; return { history, valid: () => connection.valid() && state.current === sessionId && state.history === history } },
|
|
2513
|
+
copy: copyText, notice: toast,
|
|
2514
|
+
})
|
|
2504
2515
|
window.DshTurnResults.bind($('history'), {
|
|
2505
2516
|
capture: () => {
|
|
2506
2517
|
const connection = captureConnection(), sessionId = state.current, history = state.history
|
|
@@ -4274,7 +4285,6 @@ function bindUi() {
|
|
|
4274
4285
|
$('btn-insights').addEventListener('click', () => openInsights())
|
|
4275
4286
|
$('stats-drawer-close').addEventListener('click', toggleStatsDrawer)
|
|
4276
4287
|
// 赞赏支持
|
|
4277
|
-
$('btn-donate').addEventListener('click', openDonateModal)
|
|
4278
4288
|
$('btn-donate-about').addEventListener('click', openDonateModal)
|
|
4279
4289
|
$('btn-donate-close').addEventListener('click', () => $('modal-donate').classList.add('hidden'))
|
|
4280
4290
|
// 更新内容弹窗
|
|
@@ -4292,31 +4302,16 @@ function bindUi() {
|
|
|
4292
4302
|
$('modal-new-session').addEventListener('click', (e) => { if (e.target === $('modal-new-session')) closeNewSessionModal() })
|
|
4293
4303
|
$('modal-notes').addEventListener('click', (e) => { if (e.target === $('modal-notes')) closeNotesModal() })
|
|
4294
4304
|
// 反馈
|
|
4295
|
-
$('btn-feedback').addEventListener('click', (e) => { e.stopPropagation(); toggleFeedbackMenu() })
|
|
4296
|
-
$('feedback-menu').addEventListener('click', (e) => {
|
|
4297
|
-
if (e.target.closest('a[role="menuitem"]')) closeFeedbackMenu()
|
|
4298
|
-
})
|
|
4299
|
-
$('btn-copy-link').addEventListener('click', async () => {
|
|
4300
|
-
const ok = await copyText(FEEDBACK_LINKS.repo)
|
|
4301
|
-
toast(t(ok ? 'ds.feedbackCopied' : 'ds.feedbackCopyFailed'), ok ? 'ok' : 'err')
|
|
4302
|
-
closeFeedbackMenu()
|
|
4303
|
-
})
|
|
4304
|
-
$('btn-write-feedback').addEventListener('click', () => { closeFeedbackMenu(); openFeedbackModal() })
|
|
4305
|
-
$('btn-doctor').addEventListener('click', openDoctor)
|
|
4306
4305
|
$('fb-cancel').addEventListener('click', closeFeedbackModal)
|
|
4307
4306
|
$('fb-submit').addEventListener('click', submitFeedback)
|
|
4307
|
+
$('fb-msg').addEventListener('input', updateFeedbackLength)
|
|
4308
|
+
$('fb-copy-draft').addEventListener('click', async () => { const ok = await copyText($('fb-msg').value); toast(I18N.lang === 'en' ? (ok ? 'Copied' : 'Copy failed') : (ok ? '已复制全文' : '复制失败,请重试'), ok ? 'ok' : 'err') })
|
|
4308
4309
|
$('fb-include-diagnostics').addEventListener('change',()=>{void loadCrashPreview()})
|
|
4309
4310
|
$('fb-include-crashes').addEventListener('change',()=>{void loadCrashPreview()})
|
|
4310
4311
|
document.querySelectorAll('#fb-chips .ds-fb-chip').forEach(btn =>
|
|
4311
4312
|
btn.addEventListener('click', () => {
|
|
4312
4313
|
document.querySelectorAll('#fb-chips .ds-fb-chip').forEach(b => b.classList.toggle('current', b === btn))
|
|
4313
4314
|
}))
|
|
4314
|
-
document.addEventListener('click', (e) => {
|
|
4315
|
-
if (!e.target.closest('.ds-feedback')) closeFeedbackMenu()
|
|
4316
|
-
})
|
|
4317
|
-
document.addEventListener('keydown', (e) => {
|
|
4318
|
-
if (e.key === 'Escape' && !$('feedback-menu').classList.contains('hidden')) { closeFeedbackMenu(); $('btn-feedback').focus() }
|
|
4319
|
-
})
|
|
4320
4315
|
// 统计柱状图悬停提示: 自定义 tooltip, 限制在视口内, 避免原生 title 溢出抽屉
|
|
4321
4316
|
$('stats-chart').addEventListener('mouseover', (e) => {
|
|
4322
4317
|
const bar = e.target.closest('.ds-stats-bar')
|
|
@@ -4370,9 +4365,10 @@ function bindUi() {
|
|
|
4370
4365
|
if (event.key === 'Enter' && !event.isComposing) { event.preventDefault(); void saveAccessTokenDesktop() }
|
|
4371
4366
|
})
|
|
4372
4367
|
$('btn-theme').addEventListener('click', () => {
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4368
|
+
window.DSHTheme.openPicker({
|
|
4369
|
+
themes: THEME_META, current: themeGet(), label: id => t('ds.theme.' + id),
|
|
4370
|
+
lang: I18N.lang, onSelect: themeSet
|
|
4371
|
+
})
|
|
4376
4372
|
})
|
|
4377
4373
|
$('btn-lang').addEventListener('click', () => {
|
|
4378
4374
|
I18N.setLang(I18N.lang === 'zh' ? 'en' : 'zh')
|
|
@@ -4426,7 +4422,7 @@ async function start() {
|
|
|
4426
4422
|
}
|
|
4427
4423
|
$('token-desc').textContent = state.token ? '● ' + state.token.slice(0, 12) + '…' : t('ds.toastAuth')
|
|
4428
4424
|
bindUi()
|
|
4429
|
-
window.DshImagePreview?.configure?.({ resolvePath: chatImageRequest, resolveAttachment: chatImageAttachment })
|
|
4425
|
+
window.DshImagePreview?.configure?.({ resolvePath: chatImageRequest, resolveAttachment: chatImageAttachment, capture: captureChatImage })
|
|
4430
4426
|
if (!state.token) { showView('view-settings'); $('desktop-token-input').focus() }
|
|
4431
4427
|
renderWorkbench()
|
|
4432
4428
|
updateConn()
|
|
@@ -4454,6 +4450,7 @@ function mountWorkflowDesktop() {
|
|
|
4454
4450
|
busy:!!state.byId.get(state.current)?.running,sending:sendMessage.pending?.has(state.history)}),
|
|
4455
4451
|
settings:name=>{showView('view-settings');showSettingsPage(name)},plugins:()=>showView('view-plugins'),
|
|
4456
4452
|
feedback:openFeedbackModal,
|
|
4453
|
+
doctor:openDoctor,
|
|
4457
4454
|
browse:()=>{closeNewSessionModal();showView('view-files')},
|
|
4458
4455
|
register:async()=>{
|
|
4459
4456
|
const connection=captureConnection(),path=state.fs.path;if(!path)return toast('请先选择主机目录','err')
|
|
@@ -4471,16 +4468,27 @@ function mountWorkflowDesktop() {
|
|
|
4471
4468
|
approvalRecords: renderApprovalRecordsDesktop,
|
|
4472
4469
|
clearApprovalRecords: resetApprovalRecords,
|
|
4473
4470
|
clear:async kind=>{
|
|
4474
|
-
const
|
|
4471
|
+
const en=window.I18N?.lang==='en'
|
|
4472
|
+
const messages={history:en?'Clear cached history? Host records will be kept.':'清除本机历史缓存?主机记录保留。',images:en?'Clear cached images? Images will download again when viewed.':'清除本机图片缓存?再次查看时会重新下载。',caches:en?'Clear history and image caches? Connections and preferences will be kept.':'清除本机历史和图片缓存?保留连接、凭证与偏好设置。',connection:en?'Remove this connection, credential and its caches?':'移除当前地址、保存的凭证及其缓存?其他连接条目保留。',all:en?'Clear all local Remote settings, credentials and caches?':'清除本机全部 Remote 配置、凭证与缓存?主机数据保留。'}
|
|
4473
|
+
const text=messages[kind]
|
|
4475
4474
|
if(!confirm(text))return
|
|
4476
4475
|
clearTimeout(scheduleHistoryCacheSave._t)
|
|
4477
4476
|
if(kind==='connection'){
|
|
4477
|
+
const connection=captureConnection(),scope=historyCacheScope()
|
|
4478
|
+
cancelHistoryLoad()
|
|
4479
|
+
await window.DshImageCache.clear(scope);await window.DshHistory.cacheClear(scope)
|
|
4480
|
+
if(!connection.valid())return
|
|
4478
4481
|
const current=currentServerEntry();if(current)state.servers=state.servers.filter(s=>s.id!==current.id)
|
|
4479
4482
|
state.groupActive[state.activeGroup]='';state.token='';state.server='';LS.del('token');LS.del('server');saveServers()
|
|
4480
4483
|
closeStream('mux');closeStream('host');stopPolling();renderServers();showView('view-settings');showSettingsPage('servers');return
|
|
4481
4484
|
}
|
|
4482
|
-
|
|
4483
|
-
if(kind
|
|
4485
|
+
const results=[]
|
|
4486
|
+
if(kind!=='images')cancelHistoryLoad()
|
|
4487
|
+
if(kind!=='images')results.push(await window.DshHistory.cacheClear())
|
|
4488
|
+
if(kind!=='history')results.push(await window.DshImageCache.clear())
|
|
4489
|
+
if(kind==='all'){window.DshWorkflow.clearStorage();location.reload()}
|
|
4490
|
+
else if(results.includes(false))toast(en?'Some caches could not be cleared. Retry shortly.':'部分缓存未能清除,请稍后重试。','err')
|
|
4491
|
+
else toast(en?'Cache cleared':'缓存已清除','ok')
|
|
4484
4492
|
},
|
|
4485
4493
|
recover:(row,receipt)=>{const value=receipt.result?.result?.value;if(row.method==='session.create'&&value?.sessionId)void openSession(value.sessionId);if(row.sessionId===state.current)void resyncCurrentSession()},
|
|
4486
4494
|
})
|
|
@@ -4493,3 +4501,12 @@ globalThis.DshFileInbox?.mount({ capture: captureConnection, url: apiUrl,
|
|
|
4493
4501
|
sessionTitle: id => state.byId.has(id) ? titleOf(state.byId.get(id)) : '', openFiles: () => showView('view-files'),
|
|
4494
4502
|
headers: connection => ({ authorization: 'Bearer ' + connection.token, 'x-dsh-remote-client': 'web', ...clientIdHeaders() }), native: () => null })
|
|
4495
4503
|
globalThis.DshSessionDeck?.mount({ context: () => ({ sessionId: state.current, inChat: state.view === 'view-chat' }) })
|
|
4504
|
+
globalThis.DshApprovalSummary?.mount({ capture: captureConnection, items: () => state.approvals,
|
|
4505
|
+
url: (connection, path) => connection.server + path,
|
|
4506
|
+
headers: connection => ({ authorization: 'Bearer ' + connection.token, ...clientIdHeaders() }) })
|
|
4507
|
+
globalThis.DshCacheUpgrade?.mount({
|
|
4508
|
+
scopes:()=>state.servers.map(server=>historyCacheScope(server.url,serverToken(server))),
|
|
4509
|
+
safe:()=>!state.current&&!state.approvals.length&&!state.questions.length
|
|
4510
|
+
&&![...document.querySelectorAll('textarea,input:not([type="checkbox"]):not([type="radio"])')].some(input=>input.getBoundingClientRect().width&&input.value)
|
|
4511
|
+
&&!document.querySelector('[data-transfer-id]')&&!state.sessions.some(session=>session.running)
|
|
4512
|
+
})
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/* Packaged Android WebUI: paired public origins always use the native TLS proxy. */
|
|
2
|
+
;(function(root) {
|
|
3
|
+
'use strict'
|
|
4
|
+
const bridge = root.NativeE2ee
|
|
5
|
+
if (!bridge?.resolve) return
|
|
6
|
+
const active = new Set()
|
|
7
|
+
function changed(origin) { for (const request of [...active]) if (request.origin === origin) request.cancel() }
|
|
8
|
+
function resolve(input) {
|
|
9
|
+
const original = String(input), value = JSON.parse(bridge.resolve(original))
|
|
10
|
+
if (value.error || typeof value.url !== 'string') throw new Error('E2EE_TRANSPORT_UNAVAILABLE')
|
|
11
|
+
if ((value.secure || value.paired) && !/^(?:http|ws):\/\/127\.0\.0\.1:\d+\/e2ee-[a-f0-9]{48}\//.test(value.url)) throw new Error('E2EE_TRANSPORT_UNAVAILABLE')
|
|
12
|
+
return value.url
|
|
13
|
+
}
|
|
14
|
+
const fetch = root.fetch.bind(root)
|
|
15
|
+
root.fetch = function(input, init) {
|
|
16
|
+
try {
|
|
17
|
+
const request = typeof root.Request === 'function' && input instanceof root.Request
|
|
18
|
+
const url = request ? input.url : new URL(String(input), root.location.href).href
|
|
19
|
+
const mapped = resolve(url)
|
|
20
|
+
const controller = new root.AbortController(), signal = init?.signal || (request ? input.signal : null)
|
|
21
|
+
const cancel = () => controller.abort(signal?.reason), entry = { origin: new URL(url).origin, cancel: () => controller.abort() }
|
|
22
|
+
if (signal?.aborted) cancel(); else signal?.addEventListener('abort', cancel, { once: true })
|
|
23
|
+
active.add(entry)
|
|
24
|
+
return fetch(mapped === url ? input : request ? new root.Request(mapped, input) : mapped, { ...init, signal: controller.signal })
|
|
25
|
+
.finally(() => { active.delete(entry); signal?.removeEventListener('abort', cancel) })
|
|
26
|
+
} catch (error) { return Promise.reject(error) }
|
|
27
|
+
}
|
|
28
|
+
if (root.WebSocket) {
|
|
29
|
+
const WebSocket = root.WebSocket
|
|
30
|
+
root.WebSocket = class extends WebSocket {
|
|
31
|
+
constructor(url, protocols) {
|
|
32
|
+
const original = new URL(String(url), root.location.href)
|
|
33
|
+
super(resolve(original.href), ...(protocols === undefined ? [] : [protocols]))
|
|
34
|
+
const entry = { origin: original.origin.replace(/^wss:/, 'https:'), cancel: () => this.close() }; active.add(entry)
|
|
35
|
+
this.addEventListener?.('close', () => active.delete(entry), { once: true })
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (root.XMLHttpRequest) {
|
|
40
|
+
const open = root.XMLHttpRequest.prototype.open
|
|
41
|
+
const entries = new WeakMap()
|
|
42
|
+
root.XMLHttpRequest.prototype.open = function(method, url, ...args) {
|
|
43
|
+
const original = new URL(String(url), root.location.href), mapped = resolve(original.href)
|
|
44
|
+
const previous = entries.get(this); if (previous) active.delete(previous)
|
|
45
|
+
const result = open.call(this, method, mapped, ...args)
|
|
46
|
+
const entry = { origin: original.origin, cancel: () => this.abort() }; active.add(entry); entries.set(this, entry)
|
|
47
|
+
this.addEventListener?.('loadend', () => active.delete(entry), { once: true })
|
|
48
|
+
return result
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function externalAllowed(input) {
|
|
52
|
+
try { const state = JSON.parse(bridge.info(new URL(String(input), root.location.href).origin)); return !state.configured && !state.required } catch { return false }
|
|
53
|
+
}
|
|
54
|
+
const externalNotice = () => root.alert?.(root.I18N?.lang === 'en' ? 'Use this paired relay inside the app. Open management locally on your host.' : '此配对中转需要在应用内使用;管理页面请从主机本地打开。')
|
|
55
|
+
if (root.open) {
|
|
56
|
+
const open = root.open.bind(root)
|
|
57
|
+
root.open = (url, ...args) => { if (!externalAllowed(url)) { externalNotice(); return null }; return open(url, ...args) }
|
|
58
|
+
}
|
|
59
|
+
root.document?.addEventListener('click', event => {
|
|
60
|
+
const anchor = event.target?.closest?.('a[href]')
|
|
61
|
+
if (anchor && !externalAllowed(anchor.href)) { event.preventDefault(); event.stopImmediatePropagation(); externalNotice() }
|
|
62
|
+
}, true)
|
|
63
|
+
root.DshE2eeTransport = { resolve, mount(target, { connection, onConnect, onModeChange } = {}) {
|
|
64
|
+
if (!target || target.dataset.e2eeMounted) return
|
|
65
|
+
target.dataset.e2eeMounted = 'true'
|
|
66
|
+
const en = () => root.I18N?.lang === 'en', text = (zh, english) => en() ? english : zh
|
|
67
|
+
const title = document.createElement('h3'), explanation = document.createElement('p'), button = document.createElement('button'), status = document.createElement('p')
|
|
68
|
+
const file = document.createElement('input'); file.type = 'file'; file.accept = '.json,application/json'; file.hidden = true
|
|
69
|
+
const modeLabel = document.createElement('label'), modeSwitch = document.createElement('input'), modeText = document.createElement('span'), modeStatus = document.createElement('p')
|
|
70
|
+
modeLabel.className = 'relay-encryption-switch'; modeSwitch.type = 'checkbox'; modeSwitch.checked = true; modeSwitch.dataset.e2eeToggle = 'true'
|
|
71
|
+
modeText.textContent = text('端到端加密(默认开启)', 'End-to-end encryption (on by default)'); modeLabel.append(modeSwitch, modeText)
|
|
72
|
+
modeStatus.setAttribute('role', 'status'); modeStatus.className = 'relay-encryption-status'
|
|
73
|
+
title.textContent = text('端到端加密配对(试验)', 'End-to-end pairing (experimental)')
|
|
74
|
+
explanation.textContent = text('仅导入从自己主机本地取得的配对文件。端到端加密默认开启,关闭前必须确认风险;连接失败不会自动切换模式。切换会断开当前请求,主机已受理的任务仍会继续,结果不明的操作不会自动重发。', 'Import a pairing file obtained locally from your own host. End-to-end encryption is on by default. Disabling requires confirmation; failures never change the mode automatically. Switching disconnects requests; accepted host tasks continue and uncertain writes are not resent.')
|
|
75
|
+
button.type = 'button'; button.textContent = text('导入本机配对文件', 'Import local pairing file')
|
|
76
|
+
status.setAttribute('role', 'status'); target.append(title, explanation, modeLabel, modeStatus, button, file, status)
|
|
77
|
+
let selectedOrigin = '', identity = ''
|
|
78
|
+
function modeContext() {
|
|
79
|
+
const ctx = connection(), key = JSON.stringify([ctx.url('/relay'),ctx.headers?.authorization||''])
|
|
80
|
+
if (key !== identity) { identity = key; selectedOrigin = new URL(ctx.url('/relay'),root.location.href).origin }
|
|
81
|
+
return ctx
|
|
82
|
+
}
|
|
83
|
+
function renderMode() {
|
|
84
|
+
try {
|
|
85
|
+
modeContext(); const state = JSON.parse(bridge.info(selectedOrigin))
|
|
86
|
+
modeSwitch.checked = state.encrypted !== false
|
|
87
|
+
modeSwitch.disabled = !!state.error || !state.configured || typeof bridge.setEncryption !== 'function'
|
|
88
|
+
modeStatus.dataset.security = !state.configured || state.error ? 'pending' : modeSwitch.checked ? 'encrypted' : 'legacy'
|
|
89
|
+
modeStatus.textContent = selectedOrigin + ' · ' + (state.error ? text('无法读取安全状态,请重试;不会自动降级。','Security status unavailable. No automatic fallback.') : !state.configured
|
|
90
|
+
? text('默认开启,待本地配对;当前连接尚不能标记为已加密。','On by default; local pairing required. This connection is not yet verified as encrypted.')
|
|
91
|
+
: modeSwitch.checked ? text('端到端加密已启用;每次连接仍需通过主机证书校验。','End-to-end encryption enabled; each connection must verify the host certificate.')
|
|
92
|
+
: text('警告:端到端加密已关闭。仅有 HTTPS,中转方在技术上可读取内容和访问令牌。','Warning: end-to-end encryption is OFF. HTTPS remains, but the relay can technically read content and access tokens.'))
|
|
93
|
+
} catch { modeSwitch.disabled = true; modeStatus.textContent = text('无法读取安全状态。','Security status unavailable.') }
|
|
94
|
+
}
|
|
95
|
+
modeSwitch.addEventListener('change', () => {
|
|
96
|
+
const requested = modeSwitch.checked, ctx = modeContext(), origin = selectedOrigin
|
|
97
|
+
renderMode()
|
|
98
|
+
try {
|
|
99
|
+
const state = JSON.parse(bridge.info(origin))
|
|
100
|
+
if (!state.configured || state.error || !ctx.valid()) return
|
|
101
|
+
if (!requested && !root.confirm(text('确认关闭端到端加密?\n关闭后,中转服务器在技术上可读取对话、图片及 Remote 访问令牌。令牌泄露可能导致主机被操作和模型额度被消耗。外层 HTTPS 仍保留,但不能阻止中转方读取内容。\n此选择仅对当前主机保存,重启后仍生效。取消可保持加密。\n目标:','Turn off end-to-end encryption?\nThe relay can technically read conversations, images and the Remote access token. A leaked token may allow host access and model usage. HTTPS remains but does not hide content from the relay.\nThis choice persists for this host after restart. Cancel to keep encryption.\nHost: ') + origin)) return
|
|
102
|
+
if (!ctx.valid()) return
|
|
103
|
+
const result = JSON.parse(bridge.setEncryption(origin, requested, state.fingerprint, !requested))
|
|
104
|
+
if (result.error || result.encrypted !== requested) throw Error('E2EE_MODE_CHANGE_FAILED')
|
|
105
|
+
changed(origin); onModeChange?.(origin, ctx); renderMode()
|
|
106
|
+
status.textContent = requested ? text('已开启;连接失败时不会自动降级。','Enabled. Connection failures never trigger fallback.') : text('已关闭端到端加密,HTTPS 仍保留。','End-to-end encryption disabled; HTTPS remains.')
|
|
107
|
+
} catch { renderMode(); status.textContent = text('模式未能切换,原设置保留。开启失败时请检查系统和证书,不能跳过校验。','Mode change failed; the previous setting is kept. Check system support and the certificate; verification cannot be skipped.') }
|
|
108
|
+
})
|
|
109
|
+
root.setInterval?.(renderMode, 1000); renderMode()
|
|
110
|
+
if (bridge.supported?.() === false) status.textContent = text('此系统不支持 TLS 1.3,加密模式无法连接。可升级系统;若选择关闭,须先确认风险。','This system lacks TLS 1.3. Upgrade Android, or explicitly acknowledge the risks before disabling encryption.')
|
|
111
|
+
button.addEventListener('click', () => file.click())
|
|
112
|
+
file.addEventListener('change', async () => {
|
|
113
|
+
const ctx = connection(), selected = file.files?.[0]; file.value = ''
|
|
114
|
+
if (!selected || selected.size > 16384) { status.textContent = text('请选择不超过 16KB 的配对 JSON 文件。', 'Select a pairing JSON file up to 16KB.'); return }
|
|
115
|
+
button.disabled = true
|
|
116
|
+
try {
|
|
117
|
+
const json = await selected.text(), pair = JSON.parse(json), url = new URL(pair.relayUrl)
|
|
118
|
+
if (!ctx.valid()) return
|
|
119
|
+
if (url.protocol !== 'https:' || url.pathname !== '/relay/v1/e2ee' || !/^[a-f0-9]{64}$/.test(pair.fingerprint)) throw Error('INVALID_E2EE_PAIRING')
|
|
120
|
+
const old = JSON.parse(bridge.info(url.origin))
|
|
121
|
+
if (old.error) throw Error(old.error)
|
|
122
|
+
const prompt = text('确认此文件来自自己的主机本地?\n主机地址:', 'Confirm this file came locally from your own host?\nHost: ') + url.origin
|
|
123
|
+
+ '\n' + text('证书指纹:', 'Certificate fingerprint: ') + pair.fingerprint
|
|
124
|
+
+ (old.configured && old.fingerprint !== pair.fingerprint ? '\n' + text('主机证书已改变,此操作将替换旧配对。', 'The host certificate changed. This replaces the previous pairing.') : '')
|
|
125
|
+
if (!root.confirm(prompt) || !ctx.valid()) return
|
|
126
|
+
// Reuse a credential only after the current authenticated host confirms
|
|
127
|
+
// this exact certificate and public origin. Never send host A's token to B.
|
|
128
|
+
let sameHost = false
|
|
129
|
+
try {
|
|
130
|
+
const response = await root.fetch(ctx.url('/relay'), { headers: ctx.headers, signal: root.AbortSignal.timeout(8000) })
|
|
131
|
+
const host = response.ok ? await response.json() : null
|
|
132
|
+
sameHost = host?.e2ee?.fingerprint === pair.fingerprint && new URL(host.publicUrl).origin === url.origin
|
|
133
|
+
} catch {}
|
|
134
|
+
if (!ctx.valid()) return
|
|
135
|
+
const result = JSON.parse(bridge.configure(json, old.fingerprint || ''))
|
|
136
|
+
if (result.error || !result.origin) throw Error('E2EE_IMPORT_FAILED')
|
|
137
|
+
selectedOrigin = result.origin
|
|
138
|
+
changed(result.origin)
|
|
139
|
+
status.textContent = sameHost ? text('加密配对已保存,连接时将校验主机证书。', 'Pairing saved. The host certificate will be verified when connecting.')
|
|
140
|
+
: text('加密配对已保存。请在主机与连接中选择对应公网地址并填写该主机的访问令牌,当前连接的凭证不会自动复用。', 'Pairing saved. Select its public URL in Hosts and connections and enter that host’s access token. The current credential will not be reused automatically.')
|
|
141
|
+
if (sameHost) onConnect?.(result.origin, ctx)
|
|
142
|
+
renderMode()
|
|
143
|
+
} catch { if (ctx.valid()) status.textContent = text('配对导入失败,请检查文件、有效期和主机配置;不会使用旧链路重试。', 'Pairing import failed. Check the file, expiry and host configuration. No legacy fallback will be attempted.') }
|
|
144
|
+
finally { button.disabled = false }
|
|
145
|
+
})
|
|
146
|
+
} }
|
|
147
|
+
})(typeof window !== 'undefined' ? window : globalThis)
|
package/public/extensions.js
CHANGED
|
@@ -4,11 +4,11 @@ window.DshExtensions = (() => {
|
|
|
4
4
|
let current, cache
|
|
5
5
|
let shortcuts
|
|
6
6
|
const catalog = [
|
|
7
|
-
{ id: 'skills', name: '@linxin666/dsh-client-ui-skill-explorer', label: '打开技能中心', summary: '浏览、搜索和阅读主机上的技能', verified: '0.4.
|
|
8
|
-
{ id: 'teams', name: '@nanmicoder/dsh-agent-teams', label: '查看智能体团队', summary: '查看智能体团队、任务与成员状态', verified: '0.1.
|
|
9
|
-
{ id: 'cost', name: 'dsh-cost-meter', label: '查看费用与额度', summary: '查看费用、套餐额度与峰谷提醒', verified: '1.
|
|
10
|
-
{ id: 'context', name: 'dsh-context', label: '查看当前会话上下文', session: true, summary: '查看会话上下文用量与构成', verified: '0.
|
|
11
|
-
{ id: 'tasks', name: '@linxin666/dsh-client-ui-task-board', label: '查看任务看板', summary: '只读查看任务、执行结果与计划时间', verified: '0.4.
|
|
7
|
+
{ id: 'skills', name: '@linxin666/dsh-client-ui-skill-explorer', label: '打开技能中心', summary: '浏览、搜索和阅读主机上的技能', verified: '0.4.13' },
|
|
8
|
+
{ id: 'teams', name: '@nanmicoder/dsh-agent-teams', label: '查看智能体团队', summary: '查看智能体团队、任务与成员状态', verified: '0.1.28' },
|
|
9
|
+
{ id: 'cost', name: 'dsh-cost-meter', label: '查看费用与额度', summary: '查看费用、套餐额度与峰谷提醒', verified: '1.9.46' },
|
|
10
|
+
{ id: 'context', name: 'dsh-context', label: '查看当前会话上下文', session: true, summary: '查看会话上下文用量与构成', verified: '0.78.2' },
|
|
11
|
+
{ id: 'tasks', name: '@linxin666/dsh-client-ui-task-board', label: '查看任务看板', summary: '只读查看任务、执行结果与计划时间', verified: '0.4.13' },
|
|
12
12
|
]
|
|
13
13
|
const empty = () => ({ known: false, skills: false, cost: false, context: false, teams: false, tasks: false })
|
|
14
14
|
const helpUrl = 'https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/wiki/plugins.md'
|
|
@@ -39,7 +39,7 @@ window.DshExtensions = (() => {
|
|
|
39
39
|
const native = identity(config)
|
|
40
40
|
if (!native.valid() || config.valid && !config.valid()) return
|
|
41
41
|
const code = result?.ok === true && result.available !== false ? 'available'
|
|
42
|
-
: result?.code === 'unsupported' ? 'unsupported' :
|
|
42
|
+
: result?.code === 'unsupported' ? 'unsupported' : ['not-installed','endpoint-missing'].includes(result?.code) ? 'endpoint-missing'
|
|
43
43
|
: result?.code === 'host-denied' ? 'host-denied' : result?.code === 'timeout' ? 'timeout' : 'read-failed'
|
|
44
44
|
cache.observations ||= {}
|
|
45
45
|
cache.observations[id] = { code, at: Date.now(), version: cache.snapshot?.items?.find(row => row.name === catalog.find(feature => feature.id === id).name)?.version }
|
package/public/history.js
CHANGED
|
@@ -163,10 +163,13 @@
|
|
|
163
163
|
if(database)return database
|
|
164
164
|
database=new Promise(resolve=>{
|
|
165
165
|
if(typeof indexedDB==='undefined'){resolve(null);return}
|
|
166
|
-
|
|
166
|
+
let request,settled=false
|
|
167
|
+
const done=db=>{if(settled){db?.close();return}settled=true;clearTimeout(timer);resolve(db)}
|
|
168
|
+
const timer=setTimeout(()=>done(null),1500)
|
|
169
|
+
try{request=indexedDB.open('dshRemoteHistoryV1',1)}catch{done(null);return}
|
|
167
170
|
request.onupgradeneeded=()=>{const store=request.result.createObjectStore('history',{keyPath:'key'});store.createIndex('scopeTime',['scope','updatedAt'])}
|
|
168
|
-
request.onsuccess=()=>{
|
|
169
|
-
request.onerror=request.onblocked=()=>
|
|
171
|
+
request.onsuccess=()=>{request.result.onversionchange=()=>{request.result.close();database=null};done(request.result)}
|
|
172
|
+
request.onerror=request.onblocked=()=>done(null)
|
|
170
173
|
})
|
|
171
174
|
return database
|
|
172
175
|
}
|
|
@@ -200,9 +203,12 @@
|
|
|
200
203
|
if(epoch!==cacheEpoch)return false
|
|
201
204
|
if(db)try{const saved=await new Promise(resolve=>{
|
|
202
205
|
const tx=db.transaction('history','readwrite'),store=tx.objectStore('history');store.put(data)
|
|
206
|
+
let settled=false
|
|
207
|
+
const done=value=>{if(settled)return;settled=true;clearTimeout(timer);resolve(value)}
|
|
208
|
+
const timer=setTimeout(()=>{done(false);try{tx.abort()}catch{}},1500)
|
|
203
209
|
let count=0;const request=store.index('scopeTime').openKeyCursor(IDBKeyRange.bound([scope,0],[scope,Number.MAX_SAFE_INTEGER]),'prev')
|
|
204
210
|
request.onsuccess=()=>{const cursor=request.result;if(!cursor)return;if(++count>10)store.delete(cursor.primaryKey);cursor.continue()}
|
|
205
|
-
tx.oncomplete=()=>
|
|
211
|
+
tx.oncomplete=()=>done(true);tx.onabort=tx.onerror=()=>{globalThis.DshDiagnostics?.storageFailure(scope,tx.error||{name:'UnknownError'},'indexeddb');done(false)}
|
|
206
212
|
});if(saved)return true}catch(error){globalThis.DshDiagnostics?.storageFailure(scope,error,'indexeddb')}
|
|
207
213
|
if(epoch!==cacheEpoch)return false
|
|
208
214
|
try{
|
|
@@ -215,8 +221,84 @@
|
|
|
215
221
|
}catch{return false}
|
|
216
222
|
}
|
|
217
223
|
async function cacheRemove(scope,id) {const key=cacheKey(scope,id);try{localStorage.removeItem(key)}catch{};const db=await openDatabase();if(db)try{db.transaction('history','readwrite').objectStore('history').delete(key)}catch{}}
|
|
218
|
-
async function
|
|
219
|
-
|
|
224
|
+
async function cacheInspect(mode,action,fallback) {
|
|
225
|
+
const db=await openDatabase();if(!db)return fallback
|
|
226
|
+
return new Promise(resolve=>{
|
|
227
|
+
let tx,value=fallback,settled=false
|
|
228
|
+
const done=result=>{if(settled)return;settled=true;clearTimeout(timer);resolve(result)}
|
|
229
|
+
const timer=setTimeout(()=>{done(fallback);try{tx?.abort()}catch{}},1500)
|
|
230
|
+
try{tx=db.transaction('history',mode);tx.oncomplete=()=>done(value);tx.onabort=tx.onerror=()=>done(fallback);action(tx.objectStore('history'),result=>{value=result})}catch{done(fallback)}
|
|
231
|
+
})
|
|
232
|
+
}
|
|
233
|
+
async function cacheStats() {
|
|
234
|
+
const rows=new Map(),bytes=value=>{const text=JSON.stringify(value);return typeof TextEncoder==='function'?new TextEncoder().encode(text).length:text.length*2}
|
|
235
|
+
const available=await cacheInspect('readonly',(store,result)=>{
|
|
236
|
+
const request=store.openCursor()
|
|
237
|
+
request.onsuccess=()=>{const cursor=request.result;if(!cursor){result(true);return}rows.set(cursor.primaryKey,bytes(cursor.value));cursor.continue()}
|
|
238
|
+
},false)
|
|
239
|
+
try{for(const key of Object.keys(localStorage))if(key.includes(':session:')||/^(?:(?:history|sessions)Cache|dsh-remote-(?:sessions|history))/.test(key)){
|
|
240
|
+
if(key.endsWith(':cache-index'))continue
|
|
241
|
+
const text=localStorage.getItem(key);if(text&&!rows.has(key))rows.set(key,typeof TextEncoder==='function'?new TextEncoder().encode(text).length:text.length*2)
|
|
242
|
+
}}catch{}
|
|
243
|
+
return {available:available||typeof indexedDB==='undefined',count:rows.size,bytes:[...rows.values()].reduce((a,b)=>a+b,0)}
|
|
244
|
+
}
|
|
245
|
+
async function cacheClear(scope) {
|
|
246
|
+
cacheEpoch++
|
|
247
|
+
try{for(const key of Object.keys(localStorage))if(scope===undefined?(key.includes(':session:')||key.endsWith(':cache-index')||/^(?:(?:history|sessions)Cache|dsh-remote-(?:sessions|history))/.test(key)):(key===scope||key.startsWith(scope+':')||key===scope.replace(/^history/,'sessions')))localStorage.removeItem(key)}catch{}
|
|
248
|
+
return cacheInspect('readwrite',(store,result)=>{
|
|
249
|
+
if(scope===undefined){store.clear();result(true);return}
|
|
250
|
+
const request=store.openCursor()
|
|
251
|
+
request.onsuccess=()=>{const cursor=request.result;if(!cursor){result(true);return}if(cursor.value.scope===scope)cursor.delete();cursor.continue()}
|
|
252
|
+
},typeof indexedDB==='undefined')
|
|
253
|
+
}
|
|
254
|
+
let migrating
|
|
255
|
+
function migrateLegacy(scopes) {
|
|
256
|
+
if(migrating)return migrating
|
|
257
|
+
migrating=(async()=>{
|
|
258
|
+
const epoch=cacheEpoch,allowed=new Set(scopes.filter(value=>/^historyCacheV2:[a-f0-9]{64}$/.test(value)))
|
|
259
|
+
const result={migrated:0,reclaimed:0,pending:0}
|
|
260
|
+
const keys=Object.keys(localStorage).filter(key=>/^historyCacheV2:[a-f0-9]{64}$/.test(key)||/^(?:historyCache(?:V1)?$|dsh-remote-(?:history|sessions)(?:$|[-:]))/.test(key)).slice(0,100)
|
|
261
|
+
for(const key of keys){
|
|
262
|
+
if(epoch!==cacheEpoch)break
|
|
263
|
+
let raw
|
|
264
|
+
try{raw=localStorage.getItem(key)}catch{result.pending++;continue}
|
|
265
|
+
if(!raw)continue
|
|
266
|
+
if(!allowed.has(key)){
|
|
267
|
+
// Unscoped caches cannot be assigned to a newly selected credential.
|
|
268
|
+
// Keep unknown identities; reclaim only the named pre-V2 global cache.
|
|
269
|
+
if(/^historyCacheV2:/.test(key)){result.pending++;continue}
|
|
270
|
+
try{if(localStorage.getItem(key)===raw){localStorage.removeItem(key);result.reclaimed++}}catch{result.pending++}
|
|
271
|
+
continue
|
|
272
|
+
}
|
|
273
|
+
if(raw.length>5*1024*1024){result.pending++;continue}
|
|
274
|
+
let values
|
|
275
|
+
try{
|
|
276
|
+
if(raw.length>250000&&typeof Worker!=='undefined'){
|
|
277
|
+
values=await new Promise(resolve=>{
|
|
278
|
+
let worker,url,timer
|
|
279
|
+
const done=value=>{clearTimeout(timer);worker?.terminate();if(url)URL.revokeObjectURL(url);resolve(value)}
|
|
280
|
+
try{url=URL.createObjectURL(new Blob(['self.onmessage=e=>{try{self.postMessage(Object.entries(JSON.parse(e.data)).filter(x=>Array.isArray(x[1]?.events)).sort((a,b)=>(b[1].updatedAt||0)-(a[1].updatedAt||0)).slice(0,10))}catch{self.postMessage(null)}}'],{type:'text/javascript'}));worker=new Worker(url);worker.onmessage=e=>done(e.data);worker.onerror=()=>done(null);timer=setTimeout(()=>done(null),3000);worker.postMessage(raw)}catch{done(null)}
|
|
281
|
+
})
|
|
282
|
+
}else values=Object.entries(JSON.parse(raw)).filter(([,value])=>Array.isArray(value?.events)).sort((a,b)=>(b[1].updatedAt||0)-(a[1].updatedAt||0)).slice(0,10)
|
|
283
|
+
}catch{result.pending++;continue}
|
|
284
|
+
if(!values){result.pending++;continue}
|
|
285
|
+
let saved=true
|
|
286
|
+
for(const [id,value]of values){
|
|
287
|
+
if(epoch!==cacheEpoch){saved=false;break}
|
|
288
|
+
if(await cacheLoad(key,id)){result.migrated++;continue}
|
|
289
|
+
if(!await cacheSave(key,id,value)){saved=false;break}
|
|
290
|
+
result.migrated++
|
|
291
|
+
}
|
|
292
|
+
if(saved&&epoch===cacheEpoch)try{
|
|
293
|
+
if(localStorage.getItem(key)===raw){localStorage.removeItem(key);result.reclaimed++}
|
|
294
|
+
}catch{result.pending++}
|
|
295
|
+
else result.pending++
|
|
296
|
+
}
|
|
297
|
+
return result
|
|
298
|
+
})().finally(()=>{migrating=null})
|
|
299
|
+
return migrating
|
|
300
|
+
}
|
|
301
|
+
const api={HistoryView,reconcile,insertSorted,signature,cacheLoad,cacheSave,cacheRemove,cacheClear,cacheStats,decodeLegacy,migrateLegacy,WINDOW_SIZE}
|
|
220
302
|
if(typeof module!=='undefined'&&module.exports)module.exports=api
|
|
221
303
|
else root.DshHistory=api
|
|
222
304
|
})(typeof window==='undefined'?globalThis:window)
|