dsh-remote-plugin 0.8.0 → 0.8.2

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.
@@ -7,6 +7,7 @@
7
7
  const MAX_TEXT = 600
8
8
  const AUTO_DENIED = /^Auto review rejected tool "([^"]+)"; its body was not executed(?::\s*([\s\S]*))?$/
9
9
  const AUTO_ASKED = /^Auto review denied tool "([^"]+)"(?::\s*([\s\S]*))?$/
10
+ const AUTO_FAILED = /^Auto review of tool "([^"]+)" failed; its body was not executed(?::\s*([\s\S]*))?$/
10
11
  const ESCALATION = /^escalate sandbox to ([a-z-]+):\s*([\s\S]*)$/
11
12
  const OUTCOMES = {
12
13
  'allowed-once': 'approval.outcomeAllowed',
@@ -38,6 +39,75 @@
38
39
  ))
39
40
  const timeOf = value => Number.isFinite(Number(value)) && Number(value) > 0 ? Number(value) : 0
40
41
 
42
+ // 本地机械词句替换,不调用模型或外部翻译服务。未识别的原文保持不变。
43
+ // 先保护命令、路径、URL 和引号内容,避免翻译工具参数或改变其含义。
44
+ function chineseReference(value) {
45
+ const original = String(value || ''), protectedParts = []
46
+ let output = original.replace(/`[^`]*`|"[^"\n]*"|(?<![A-Za-z0-9])'[^'\n]*'|https?:\/\/[^\s]+|[A-Za-z]:[\\/][^\s,;]+|(?:\.{0,2}\/)[^\s,;]+/g, part => {
47
+ protectedParts.push(part); return '\uE000' + (protectedParts.length - 1) + '\uE001'
48
+ })
49
+ const phrases = [
50
+ [/\b(?:this|the) (?:command|action|operation) (?:would|will) delete files outside (?:of )?(?:the )?workspace\b/gi, '此操作将删除工作区之外的文件'],
51
+ [/\b(?:this|the) (?:command|action|operation) (?:could|may|might|can) delete files outside (?:of )?(?:the )?workspace\b/gi, '此操作可能删除工作区之外的文件'],
52
+ [/\bthe user (?:has not|hasn't) (?:explicitly )?authorized (?:this|the) (?:action|operation|command)\b/gi, '用户尚未明确授权此操作'],
53
+ [/\bthe user (?:did not|didn't) request\b/gi, '用户未要求'],
54
+ [/\bnot (?:explicitly )?requested by the user\b/gi, '用户未明确要求'],
55
+ [/\bno (?:explicit )?user (?:authorization|approval|consent)\b/gi, '没有明确的用户授权'],
56
+ [/\b(?:this|the) (?:command|action|operation|tool call) (?:could|may|might|can)\b/gi, '此操作可能'],
57
+ [/\b(?:this|the) (?:command|action|operation|tool call) (?:would|will)\b/gi, '此操作将'],
58
+ [/\b(?:is|are) not (?:explicitly )?authorized\b/gi, '未获明确授权'],
59
+ [/\b(?:is|are) not allowed\b/gi, '不允许'],
60
+ [/\b(?:does not|doesn't) (?:have|include) (?:explicit )?(?:user )?(?:authorization|approval)\b/gi, '未获得用户明确授权'],
61
+ [/\bwithout (?:explicit )?user (?:approval|authorization|consent)\b/gi, '未经用户明确批准'],
62
+ [/\b(?:requires?|needs?) (?:explicit )?user (?:approval|authorization|confirmation)\b/gi, '需要用户明确批准'],
63
+ [/\b(?:outside|out of) (?:of )?(?:the )?(?:(?:allowed|approved|current) )?workspace\b/gi, '在工作区之外'],
64
+ [/\boutside (?:the )?(?:authorized|approved) scope\b/gi, '超出已授权范围'],
65
+ [/\b(?:user |explicit )?(?:authorization|approval) is (?:missing|required|unclear|insufficient)\b/gi, '缺少明确的用户授权'],
66
+ [/\brecursive(?:ly)? delet(?:e|es|ion|ing)\b/gi, '递归删除'],
67
+ [/\bdelet(?:e|es|ing) (?:existing )?files\b/gi, '删除文件'],
68
+ [/\b(?:overwrite|overwrites|overwriting) (?:existing )?(?:files|data)\b/gi, '覆盖已有文件或数据'],
69
+ [/\birreversible (?:actions?|operations?|changes?)\b/gi, '不可逆操作'],
70
+ [/\bdestructive (?:actions?|operations?|changes?)\b/gi, '破坏性操作'],
71
+ [/\b(?:expose|leak|exfiltrate) (?:secrets|credentials|tokens|sensitive data)\b/gi, '泄露密钥、凭据或敏感数据'],
72
+ [/\b(?:send|transmit|upload) (?:private|sensitive|local) (?:data|files)\b/gi, '发送私有或敏感数据'],
73
+ [/\buntrusted (?:server|endpoint|service|destination)\b/gi, '不可信的服务'],
74
+ [/\bexternal (?:server|endpoint|service|destination)\b/gi, '外部服务'],
75
+ [/\b(?:elevated|administrator|admin) privileges\b/gi, '管理员权限'],
76
+ [/\bpermission denied\b/gi, '权限被拒绝'], [/\baccess denied\b/gi, '访问被拒绝'],
77
+ [/\bread[- ]only\b/gi, '只读'], [/\bnetwork access\b/gi, '网络访问'],
78
+ [/\b(?:review|request) timed out\b/gi, '审查请求超时'], [/\btimeout\b/gi, '超时'],
79
+ [/\b(?:risk of|may cause) data loss\b/gi, '可能导致数据丢失'],
80
+ ]
81
+ for (const [pattern, replacement] of phrases) output = output.replace(pattern, replacement)
82
+ return output.replace(/\uE000(\d+)\uE001/g, (_match, index) => protectedParts[Number(index)] ?? _match)
83
+ }
84
+
85
+ function feedback(value) {
86
+ const raw = String(value || ''), denied = AUTO_DENIED.exec(raw), asked = AUTO_ASKED.exec(raw), failed = AUTO_FAILED.exec(raw)
87
+ const match = denied || asked || failed
88
+ if (!match || root.I18N?.lang === 'en') return { text: raw, translated: false }
89
+ const prefix = failed ? '自动审查失败,工具未执行' : denied ? '自动审查拒绝,工具未执行' : '自动审查未通过,等待人工决定'
90
+ return { text: prefix + '(' + match[1] + ')' + (match[2] ? ':' + chineseReference(match[2]) : ''), translated: true }
91
+ }
92
+
93
+ function displayReason(value) {
94
+ const raw = String(value || ''), rendered = feedback(raw)
95
+ return rendered.translated ? rendered.text + '\n\n原文:' + raw : raw
96
+ }
97
+
98
+ function feedbackHtml(value) {
99
+ let raw = typeof value === 'string' ? value : ''
100
+ if (!raw && value && typeof value === 'object') {
101
+ const blocks = Array.isArray(value) ? value : value.content
102
+ raw = Array.isArray(blocks) ? blocks.filter(block => block?.type === 'text').map(block => String(block.text || '')).join('\n') : typeof value.text === 'string' ? value.text : ''
103
+ }
104
+ const rendered = feedback(raw)
105
+ if (!rendered.translated) return ''
106
+ let original
107
+ try { original = typeof value === 'string' ? value : JSON.stringify(value, null, 2) } catch { original = raw }
108
+ return `<section class="approval-translation"><h4>自动审查反馈 · 中文参考</h4><p>${esc(rendered.text.slice(0, 12000))}</p><details><summary>查看原文</summary><pre>${esc(String(original).slice(0, 12000))}</pre></details></section>`
109
+ }
110
+
41
111
  function kindOf(reason) {
42
112
  if (AUTO_ASKED.test(reason || '') || AUTO_DENIED.test(reason || '')) return 'auto'
43
113
  if (ESCALATION.test(reason || '')) return 'escalation'
@@ -156,8 +226,10 @@
156
226
  function reasonHtml(record, t) {
157
227
  const info = summary(record)
158
228
  const label = t(KIND[info.kind] || KIND.request)
159
- const body = esc(info.text || t('approval.noReason'))
160
- return `<div class="approval-record-reason"><span class="approval-record-kind">${esc(label)}</span><span>${body}</span></div>`
229
+ const raw = info.text || t('approval.noReason')
230
+ const localized = root.I18N?.lang !== 'en' && ['auto', 'auto-deny'].includes(info.kind) ? chineseReference(raw) : raw
231
+ const original = localized !== raw ? `<details class="approval-original"><summary>查看原文 · 中文为机械翻译参考</summary><div>${esc(raw)}</div></details>` : ''
232
+ return `<div class="approval-record-reason"><span class="approval-record-kind">${esc(label)}</span><div class="approval-record-copy">${esc(localized)}${original}</div></div>`
161
233
  }
162
234
 
163
235
  function recordHtml(record, t, { session = '', now = Date.now() } = {}) {
@@ -224,6 +296,6 @@
224
296
 
225
297
  root.DshApprovalRecords = {
226
298
  create, fromEvent, fromFrame, summary, kindOf, list, recordHtml, lineHtml,
227
- outcomeKey, isPending, serialize, restore, relTime, MAX: MAX_RECORDS,
299
+ outcomeKey, isPending, serialize, restore, relTime, chineseReference, displayReason, feedbackHtml, MAX: MAX_RECORDS,
228
300
  }
229
301
  })(window)
package/public/build.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schema": 1,
3
- "version": "0.8.0",
4
- "buildId": "8d8653b774000d520d22face4d8f4eb7f6753ad82ee07b8859a536d8d1e3607c"
3
+ "version": "0.8.2",
4
+ "buildId": "8377f1e6974af85893b9a4ad046207f61aad317ec44a1cc8d56460d758109bb9"
5
5
  }
@@ -184,7 +184,9 @@ html.reorder-scroll-lock body { overscroll-behavior: none; }
184
184
  .ds-text-input { width: 100%; box-sizing: border-box; min-height: 42px; padding: 10px 12px; border: 1px solid var(--dsr-line); border-radius: 10px; background: var(--dsr-bg-2); color: var(--dsr-text); font: inherit; outline: none; }
185
185
  .ds-text-input:focus { border-color: var(--dsr-accent-line); }
186
186
  .ds-top-right { display: flex; align-items: center; gap: 10px; }
187
- .ds-conn { font-size: 11px; color: var(--dsr-muted); }
187
+ .ds-conn { min-height:36px; padding:6px 8px; border:1px solid var(--dsr-line); border-radius:10px; background:var(--dsr-bg-2); font:inherit; font-size: 11px; color: var(--dsr-muted); cursor:pointer; }
188
+ .ds-conn:focus-visible { outline:2px solid var(--dsr-accent); outline-offset:2px; }
189
+ .ds-topbar { position:relative; z-index:25; }
188
190
  .ds-conn.on { color: var(--dsr-success); }
189
191
  .ds-conn.ing { color: var(--dsr-warning); }
190
192
  .ds-server { font-size: 12px; color: var(--dsr-muted); max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@@ -469,6 +471,12 @@ button.ds-overview-attention-item, button.ds-overview-session-item { cursor:poin
469
471
  .approval-record-badge.pending, .approval-event-badge.pending { color: var(--dsr-warning); border-color: var(--dsr-warning-line); border-style: dashed; }
470
472
  .approval-record-reason { display: flex; gap: 6px; font-size: 12px; line-height: 1.5; color: var(--dsr-text); }
471
473
  .approval-record-kind { flex: none; font-size: 10px; font-weight: 700; color: var(--dsr-muted); border: 1px solid var(--dsr-line); border-radius: 6px; padding: 0 5px; }
474
+ .approval-record-kind { align-self:flex-start; }
475
+ .approval-record-copy { min-width:0; flex:1; overflow-wrap:anywhere; }
476
+ .approval-original { margin-top:6px; color:var(--dsr-muted); font-size:11px; }
477
+ .approval-original summary { cursor:pointer; }
478
+ .approval-original div { margin-top:6px; white-space:pre-wrap; }
479
+ .approval-translation p { white-space:pre-wrap; overflow-wrap:anywhere; }
472
480
  .approval-record-why { font-size: 11.5px; line-height: 1.45; color: var(--dsr-muted); }
473
481
  .approval-record-meta { font-size: 10.5px; color: var(--dsr-muted); }
474
482
  .approval-event { font-size: 12.5px; color: var(--dsr-text); padding: 3px 0; }
@@ -121,7 +121,12 @@
121
121
  <div class="ds-top-right">
122
122
  <button id="btn-subagents" class="subagents-entry hidden" type="button" aria-haspopup="dialog" aria-controls="subagent-page" data-i18n="subagent.title">子代理</button>
123
123
  <button id="btn-session-more" class="ds-icon-btn" type="button" aria-haspopup="dialog" aria-controls="session-actions" data-i18n-aria="ds.sessionMore" aria-label="更多操作">⋯</button>
124
- <span class="ds-conn" id="conn-badge" title="">●</span>
124
+ <div class="ext-shortcuts">
125
+ <button id="btn-plugin-shortcuts" class="ds-btn" type="button" aria-haspopup="menu" aria-controls="plugin-shortcuts-menu" aria-expanded="false" data-i18n="ds.plugins">插件</button>
126
+ <div id="plugin-shortcuts-menu" class="ext-shortcuts-menu hidden" role="menu" data-i18n-aria="ds.plugins"></div>
127
+ </div>
128
+ <button class="ds-conn" id="conn-badge" type="button" aria-describedby="conn-refresh-hint" data-i18n-title="ds.connRefresh" data-i18n-aria="ds.connRefresh">●</button>
129
+ <span id="conn-refresh-hint" class="ext-sr-only" data-i18n="ds.connRefresh">点击刷新连接与数据</span>
125
130
  <span class="ds-server" id="server-badge"></span>
126
131
  </div>
127
132
  </header>
@@ -179,9 +184,16 @@
179
184
 
180
185
  <!-- 会话详情 -->
181
186
  <section id="view-chat" class="ds-view">
182
- <div id="session-cards" class="ds-session-cards"></div>
183
- <div id="queue-dock" class="ds-queue-dock hidden" aria-live="polite"></div>
184
- <section id="session-pending" class="ds-session-pending hidden" aria-live="polite"></section>
187
+ <section id="session-deck" class="session-deck">
188
+ <div id="session-deck-stage" class="session-deck-stage">
189
+ <div id="session-cards" class="ds-session-cards"></div>
190
+ <div id="queue-dock" class="ds-queue-dock hidden" aria-live="polite"></div>
191
+ <div class="session-attention">
192
+ <section id="session-pending" class="ds-session-pending hidden" aria-live="polite"></section>
193
+ <section id="file-inbox-session" class="file-inbox-session" aria-label="待接收文件" aria-live="polite" hidden></section>
194
+ </div>
195
+ </div>
196
+ </section>
185
197
  <div id="history-source" class="history-source" role="status" aria-live="polite"></div>
186
198
  <div class="ds-history-wrap"><div id="history" class="ds-history"></div><button id="btn-history-latest" class="history-latest hidden" type="button" data-i18n="ds.historyLatest">回到最新</button></div>
187
199
  <div class="ds-composer">
@@ -221,6 +233,7 @@
221
233
  <!-- 文件传输 -->
222
234
  <section id="view-files" class="ds-view hidden">
223
235
  <div class="ds-section-label" data-i18n="ds.files">文件传输</div>
236
+ <section id="file-inbox-files" class="file-inbox-files" aria-label="文件收件箱"></section>
224
237
  <div class="ds-fs-bar">
225
238
  <button id="fs-up" class="ds-btn" data-i18n="ds.fsUp">上级</button>
226
239
  <select id="fs-root" class="ds-fs-root hidden" data-i18n-aria="ds.fsRoot" aria-label="允许根目录"></select>
@@ -424,10 +437,10 @@
424
437
  </div>
425
438
  <textarea id="fb-msg" class="ds-fb-textarea" rows="5" maxlength="2000" data-i18n-placeholder="ds.feedbackMessagePlaceholder" placeholder="请描述遇到的问题或建议(必填,≤2000 字)"></textarea>
426
439
  <input id="fb-contact" class="ds-fb-input" maxlength="200" data-i18n-placeholder="ds.feedbackContactPlaceholder" placeholder="联系方式(可选):邮箱 / 微信 / B站 ID">
427
- <label class="ds-fb-diagnostics"><input id="fb-include-diagnostics" type="checkbox"> <span data-i18n="ds.feedbackIncludeDiagnostics">附带兼容性诊断日志(可选)</span><small data-i18n="ds.feedbackDiagnosticsPrivacy">仅上传网关/协议版本、接口失败摘要和实时链路状态;不包含令牌、Cookie、对话内容或文件路径。</small></label>
440
+ <label class="ds-fb-diagnostics"><input id="fb-include-diagnostics" type="checkbox"> <span data-i18n="ds.feedbackIncludeDiagnostics">附带客户端与网关诊断(可选)</span><small data-i18n="ds.feedbackDiagnosticsPrivacy">上传客户端操作与错误位置、存储占用、版本和网关链路状态;不含令牌、Cookie、对话正文、答案或完整路径。可在下方预览。</small></label>
428
441
  <label class="ds-fb-diagnostics"><input id="fb-include-crashes" type="checkbox"> <span data-i18n="ds.feedbackIncludeCrashes">附带崩溃日志摘要(可选)</span><small data-i18n="ds.feedbackCrashPrivacy">默认仅在本机记录。勾选后上传最近 3 条退出、重启和错误位置摘要,不含对话、密钥或完整路径。</small></label>
429
442
  <section class="client-diagnostics" aria-label="操作诊断日志">
430
- <p data-log-label="privacy">操作日志仅保存在此设备,记录操作阶段、耗时、错误位置与连接状态。可复制或导出后自行反馈。</p>
443
+ <p data-log-label="privacy">操作日志默认保存在此设备。提交反馈时勾选诊断选项可附带脱敏日志,也可复制或导出。</p>
431
444
  <details id="fb-client-log-details"><summary data-log-label="details">查看操作诊断日志</summary><pre id="fb-client-log-preview"></pre></details>
432
445
  <div class="client-log-actions"><button id="fb-log-preview" type="button" data-log-label="refresh">刷新预览</button><button id="fb-log-copy" type="button" data-log-label="copy">复制日志</button><button id="fb-log-export" type="button" data-log-label="export">导出日志</button><button id="fb-log-clear" type="button" data-log-label="clear">清除日志</button></div>
433
446
  <p id="fb-client-log-status" role="status" aria-live="polite"></p>
@@ -567,6 +580,7 @@
567
580
  'ds.attention': '需要你处理', 'ds.runtime': '运行指标', 'ds.recentActivity': '近期活动', 'ds.dshVersion': 'DSH 版本', 'ds.gatewayStatus': '网关状态', 'ds.activeSessions': '活跃会话', 'ds.connectionMode': '连接模式', 'ds.liveWs': '实时 WS', 'ds.poll': '降级轮询', 'ds.running': '运行中', 'ds.noReason': '无说明', 'ds.noActivity': '暂无后台活动', 'ds.noSessions': '暂无会话', 'ds.refreshOverview': '刷新总览', 'ds.pendingCount': '{n} 项待处理', 'ds.activeCount': '{n} 个活跃会话', 'ds.nothingPending': '暂无事项', 'ds.action.openSession': '打开最近会话', 'ds.action.newSession': '新建会话', 'ds.action.attention': '处理待办', 'ds.action.connect': '去设置连接', 'ds.action.refresh': '重新检查连接',
568
581
  'ds.sortLabel': '会话排序', 'ds.sortTime': '按时间', 'ds.sortWorkspace': '按工作区', 'ds.workspace': '工作区', 'ds.workspaceUnknown': '未指定工作区', 'ds.wbOrderSaved': '顺序已保存到当前设备',
569
582
  'ds.insights': '上下文与费用',
583
+ 'ds.connRefresh': '点击刷新连接与数据',
570
584
  'ds.insightsContext': '上下文分析',
571
585
  'ds.insightsCost': '费用与额度',
572
586
  'ds.files': '文件传输', 'ds.plugins': '插件', 'ds.settings': '设置', 'ds.stats': '统计', 'ds.menu': '导航',
@@ -610,7 +624,7 @@
610
624
  'ds.feedbackDoctor': 'AI 排查问题', 'ds.feedbackDoctorDesc': '使用你的 DSH 和模型,只读诊断',
611
625
  'ds.feedbackBiliDesc': 'UP 动态页交流', 'ds.feedbackCopyLink': '复制项目链接', 'ds.feedbackCopyDesc': '手动分享给朋友',
612
626
  'ds.feedbackCopied': '项目链接已复制', 'ds.feedbackCopyFailed': '复制失败,请手动复制',
613
- 'ds.feedbackWrite': '写反馈', 'ds.feedbackWriteDesc': 'App 内直接提交', 'ds.feedbackModalTitle': '写反馈', 'ds.feedbackIncludeDiagnostics': '附带兼容性诊断日志(可选)', 'ds.feedbackDiagnosticsPrivacy': '仅上传网关/协议版本、接口失败摘要和实时链路状态;不包含令牌、Cookie、对话内容或文件路径。', 'ds.feedbackIncludeCrashes': '附带崩溃日志摘要(可选)', 'ds.feedbackCrashPrivacy': '默认仅在本机记录。勾选后上传最近 3 条退出、重启和错误位置摘要,不含对话、密钥或完整路径。', 'ds.feedbackCrashPreview': '查看拟上传的日志摘要', 'ds.feedbackCrashLoading': '读取本机日志…', 'ds.feedbackCrashUnavailable': '当前网关暂时无法读取日志,请更新网关或稍后重试。',
627
+ 'ds.feedbackWrite': '写反馈', 'ds.feedbackWriteDesc': 'App 内直接提交', 'ds.feedbackModalTitle': '写反馈', 'ds.feedbackIncludeDiagnostics': '附带客户端与网关诊断(可选)', 'ds.feedbackDiagnosticsPrivacy': '上传客户端操作与错误位置、存储占用、版本和网关链路状态;不含令牌、Cookie、对话正文、答案或完整路径。可在下方预览。', 'ds.feedbackIncludeCrashes': '附带崩溃日志摘要(可选)', 'ds.feedbackCrashPrivacy': '默认仅在本机记录。勾选后上传最近 3 条退出、重启和错误位置摘要,不含对话、密钥或完整路径。', 'ds.feedbackCrashPreview': '查看拟上传的日志摘要', 'ds.feedbackCrashLoading': '读取本机日志…', 'ds.feedbackCrashUnavailable': '当前网关暂时无法读取日志,请更新网关或稍后重试。',
614
628
  'ds.feedbackTypeBug': 'Bug', 'ds.feedbackTypeSuggestion': '建议', 'ds.feedbackTypeOther': '其他',
615
629
  'ds.feedbackMessagePlaceholder': '请描述遇到的问题或建议(必填,≤2000 字)',
616
630
  'ds.feedbackContactPlaceholder': '联系方式(可选):邮箱 / 微信 / B站 ID',
@@ -696,6 +710,7 @@
696
710
  'ds.attention': 'Needs attention', 'ds.runtime': 'Runtime metrics', 'ds.recentActivity': 'Recent activity', 'ds.dshVersion': 'DSH version', 'ds.gatewayStatus': 'Gateway status', 'ds.activeSessions': 'Active sessions', 'ds.connectionMode': 'Connection mode', 'ds.liveWs': 'Live WS', 'ds.poll': 'Degraded polling', 'ds.running': 'Running', 'ds.noReason': 'No reason given', 'ds.noActivity': 'No background activity', 'ds.noSessions': 'No sessions yet', 'ds.refreshOverview': 'Refresh overview', 'ds.pendingCount': '{n} pending', 'ds.activeCount': '{n} active sessions', 'ds.nothingPending': 'Nothing pending', 'ds.action.openSession': 'Open recent session', 'ds.action.newSession': 'New session', 'ds.action.attention': 'Review pending', 'ds.action.connect': 'Set up connection', 'ds.action.refresh': 'Check connection',
697
711
  'ds.sortLabel': 'Session sort', 'ds.sortTime': 'By time', 'ds.sortWorkspace': 'By workspace', 'ds.workspace': 'Workspace', 'ds.workspaceUnknown': 'No workspace', 'ds.wbOrderSaved': 'Order saved on this device',
698
712
  'ds.insights': 'Context & costs',
713
+ 'ds.connRefresh': 'Click to refresh connection and data',
699
714
  'ds.insightsContext': 'Context analysis',
700
715
  'ds.insightsCost': 'Cost & quotas',
701
716
  'ds.files': 'Files', 'ds.plugins': 'Plugins', 'ds.settings': 'Settings', 'ds.stats': 'Stats', 'ds.menu': 'Menu',
@@ -739,7 +754,7 @@
739
754
  'ds.feedbackBiliDesc': 'Chat on the UP\'s Bilibili page', 'ds.feedbackCopyLink': 'Copy project link', 'ds.feedbackCopyDesc': 'Share it manually',
740
755
  'ds.feedbackCopied': 'Project link copied', 'ds.feedbackCopyFailed': 'Copy failed, copy manually',
741
756
  'ds.contributors': 'Contributors', 'ds.contributorsThanks': 'Thank you to everyone who helps make DSH Remote better.', 'ds.contributorsAll': 'View all contributions ↗',
742
- 'ds.feedbackWrite': 'Write feedback', 'ds.feedbackWriteDesc': 'Submit from the app', 'ds.feedbackModalTitle': 'Write feedback', 'ds.feedbackIncludeDiagnostics': 'Include compatibility diagnostics (optional)', 'ds.feedbackDiagnosticsPrivacy': 'Uploads only gateway/protocol versions, interface failure summaries, and realtime status; no token, cookie, conversation content, or file path.', 'ds.feedbackIncludeCrashes': 'Include crash summary (optional)', 'ds.feedbackCrashPrivacy': 'Recorded locally by default. Opt in to upload up to 3 recent exit, restart and error-location records. No conversations, credentials or full paths.', 'ds.feedbackCrashPreview': 'Preview the log summary to upload', 'ds.feedbackCrashLoading': 'Reading local logs…', 'ds.feedbackCrashUnavailable': 'Logs are unavailable. Update the gateway or try again later.',
757
+ 'ds.feedbackWrite': 'Write feedback', 'ds.feedbackWriteDesc': 'Submit from the app', 'ds.feedbackModalTitle': 'Write feedback', 'ds.feedbackIncludeDiagnostics': 'Include client and gateway diagnostics (optional)', 'ds.feedbackDiagnosticsPrivacy': 'Uploads operation stages, error locations, storage sizes, versions and gateway status. No credentials, conversation bodies, answers or full paths. Preview below.', 'ds.feedbackIncludeCrashes': 'Include crash summary (optional)', 'ds.feedbackCrashPrivacy': 'Recorded locally by default. Opt in to upload up to 3 recent exit, restart and error-location records. No conversations, credentials or full paths.', 'ds.feedbackCrashPreview': 'Preview the log summary to upload', 'ds.feedbackCrashLoading': 'Reading local logs…', 'ds.feedbackCrashUnavailable': 'Logs are unavailable. Update the gateway or try again later.',
743
758
  'ds.feedbackTypeBug': 'Bug', 'ds.feedbackTypeSuggestion': 'Suggestion', 'ds.feedbackTypeOther': 'Other',
744
759
  'ds.feedbackMessagePlaceholder': 'Describe the bug or suggestion (required, ≤2000 chars)',
745
760
  'ds.feedbackContactPlaceholder': 'Contact (optional): email / WeChat / Bilibili ID',
@@ -858,6 +873,10 @@
858
873
  <script src="../permission-presets.js"></script>
859
874
  <script src="../approval-records.js"></script>
860
875
  <script src="../doctor-entry.js"></script>
876
+ <link rel="stylesheet" href="../file-inbox.css">
877
+ <script src="../file-inbox.js"></script>
878
+ <link rel="stylesheet" href="../session-deck.css">
879
+ <script src="../session-deck.js"></script>
861
880
  <script src="desktop.js"></script>
862
881
  </body>
863
882
  </html>
@@ -8,7 +8,7 @@ I18N.init(window.DESKTOP_STR)
8
8
  const $ = (id) => document.getElementById(id)
9
9
  const LS = {
10
10
  get(k, d) { try { return localStorage.getItem(k) ?? d } catch { return d } },
11
- set(k, v) { try { localStorage.setItem(k, v) } catch {} },
11
+ set(k, v) { try { localStorage.setItem(k, v); return true } catch(error) { try { globalThis.DshDiagnostics?.storageFailure(k,error) } catch {} return false } },
12
12
  del(k) { try { localStorage.removeItem(k) } catch {} }
13
13
  }
14
14
  const CLIENT_ID = (() => {
@@ -132,6 +132,8 @@ for (const key of ['server', 'token']) {
132
132
  window.DshInsights?.close()
133
133
  window.DshExtensions?.close()
134
134
  window.DshExtensions?.invalidateCapabilities()
135
+ window.DshFileInbox?.reset()
136
+ window.DshSessionDeck?.reset()
135
137
  if (typeof document !== 'undefined') document.getElementById('btn-insights')?.classList.add('hidden')
136
138
  if(typeof document!=='undefined') {
137
139
  const identityGeneration=connectionGeneration
@@ -649,14 +651,16 @@ async function checkNotesOnStart() {
649
651
  } catch {}
650
652
  }
651
653
  async function loadCrashPreview() {
654
+ const generation=loadCrashPreview.generation=(loadCrashPreview.generation||0)+1
652
655
  const connection=captureConnection(),preview=$('fb-crash-preview')
653
656
  preview.textContent=t('ds.feedbackCrashLoading')
654
- try {
655
- const response=await fetch(apiUrl('/crash-logs'),{headers:{authorization:'Bearer '+connection.token},signal:AbortSignal.timeout(5000),cache:'no-store'})
656
- if(!response.ok)throw new Error('unavailable')
657
- const data=await response.json()
658
- if(connection.valid())preview.textContent=JSON.stringify(data.upload,null,2)
659
- }catch{if(connection.valid())preview.textContent=t('ds.feedbackCrashUnavailable')}
657
+ const selected=$('fb-include-diagnostics').checked,crashes=$('fb-include-crashes').checked
658
+ if(!selected&&!crashes){preview.textContent=I18N.lang==='en'?'Select a log option above to preview the attachment.':'勾选上方日志选项后,可在这里预览拟上传的附件。';return}
659
+ const read=async route=>{try{const response=await fetch(apiUrl(route),{headers:{authorization:'Bearer '+connection.token},signal:AbortSignal.timeout(5000),cache:'no-store'});if(!response.ok)throw Error();return await response.json()}catch{return {unavailable:true}}}
660
+ const evidence={}
661
+ if(selected){evidence.client=globalThis.DshDiagnostics?.report();evidence.gateway=await read('/diagnostics')}
662
+ if(crashes){const data=await read('/crash-logs');evidence.crashes=data.upload||data}
663
+ if(connection.valid()&&generation===loadCrashPreview.generation)preview.textContent=JSON.stringify(evidence,null,2)
660
664
  }
661
665
  async function submitFeedback() {
662
666
  const type = document.querySelector('#fb-chips .ds-fb-chip.current')?.dataset.fbType || 'bug'
@@ -664,6 +668,7 @@ async function submitFeedback() {
664
668
  const contact = $('fb-contact').value.trim()
665
669
  const includeDiagnostics = $('fb-include-diagnostics').checked
666
670
  const includeCrashLogs = $('fb-include-crashes').checked
671
+ const clientDiagnostics=includeDiagnostics?globalThis.DshDiagnostics?.report():null
667
672
  if (!message) { toast(t('ds.feedbackEmpty'), 'err'); return }
668
673
  if (message.length > 2000) { toast(t('ds.feedbackTooLong'), 'err'); return }
669
674
  const btn = $('fb-submit')
@@ -673,12 +678,15 @@ async function submitFeedback() {
673
678
  const res = await fetch(apiUrl('/feedback'), {
674
679
  method: 'POST',
675
680
  headers: { 'content-type': 'application/json', authorization: 'Bearer ' + state.token },
676
- body: JSON.stringify({ type, message, contact, appVersion: '', includeDiagnostics, includeCrashLogs })
681
+ body: JSON.stringify({ type, message, contact, appVersion: clientDiagnostics?.client.version||'', includeDiagnostics, includeCrashLogs,...(clientDiagnostics?{clientDiagnostics}:{}) })
677
682
  })
678
683
  diagnostic?.end({phase:res.ok?'complete':'failed',httpStatus:res.status})
679
684
  let json = {}
680
685
  try { json = await res.json() } catch {}
681
- if (res.ok && json.ok) { toast(t('ds.feedbackSubmitted'), 'ok'); closeFeedbackModal() }
686
+ if (res.ok && json.ok) { closeFeedbackModal()
687
+ const saved=json.diagnostics?.saved===true&&json.diagnostics.reportId===clientDiagnostics?.reportId
688
+ 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
+ }
682
690
  else if (res.status === 429) { toast(t('ds.feedbackRateLimited'), 'err') }
683
691
  else { toast(t('ds.feedbackSubmitFailed', { msg: json.error || res.status }), 'err') }
684
692
  } catch(error) {
@@ -2412,7 +2420,7 @@ function blockHtml(b,index=0,context={}) {
2412
2420
  if (b.type==='thinking'||b.type==='reasoning') return window.DshActivity.reasoning({text:b.text??b.content??'',key:window.DshActivity.reasoningKey(context,index,key)})
2413
2421
  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)})})
2414
2422
  }
2415
- if (b.type === 'text') return `<div class="md">${window.mdToHtml ? window.mdToHtml(b.text ?? '', { fileLinks: true, imageLabel: t('block.image') }) : esc(b.text ?? '')}</div>`
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>` : ''
2416
2424
  if (b.type === 'file' && typeof window !== 'undefined' && window.DshChatFiles) return window.DshChatFiles.render(b)
2417
2425
  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>`
2418
2426
  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>`
@@ -2585,27 +2593,25 @@ async function renderSessionCards() {
2585
2593
  let html = ''
2586
2594
  if (goal && !isGoalTerminal(goal)) {
2587
2595
  const collapsed = isGoalCollapsed(sessionId, goal)
2588
- html += `<div class="ds-goal-disclosure${collapsed ? ' is-collapsed' : ''}">
2596
+ html += `<div data-deck-kind="goal" class="ds-goal-disclosure${collapsed ? ' is-collapsed' : ''}">
2589
2597
  <div id="goal-panel-desktop" class="ds-card ds-goal-card${collapsed ? ' hidden' : ''}">
2590
- <div class="ds-goal-card-head"><div class="ds-card-title">${t('goal.title')}</div>
2598
+ <div class="ds-goal-card-head"><div class="ds-card-title">${esc(window.DshSessionDeck?.goalState(goal.phase) || goal.phase || t('goal.title'))}</div>
2591
2599
  <button type="button" class="ds-goal-collapse-btn" data-goal-collapse="1" aria-expanded="true" aria-controls="goal-panel-desktop" title="${esc(t('goal.collapse'))}"><span aria-hidden="true">›</span>${t('goal.collapseShort')}</button>
2592
2600
  </div>
2593
2601
  <div class="ds-goal-obj">${esc(goal.objective || '')}</div>
2594
- <div class="ds-goal-phase">phase: ${esc(goal.phase || '?')} · revision ${goal.revision ?? '?'}</div>
2595
2602
  <div class="ds-goal-actions">
2596
2603
  ${goal.phase === 'active' ? `<button class="ds-mini-btn" data-goal="pause">${t('goal.pause')}</button>` : `<button class="ds-mini-btn" data-goal="resume">${t('goal.resume')}</button>`}
2597
2604
  <button class="ds-mini-btn" data-goal="complete">${t('goal.complete')}</button>
2598
- <button class="ds-mini-btn" data-goal="edit">${t('goal.edit')}</button>
2599
- <button class="ds-mini-btn" data-goal="clear">${t('goal.clear')}</button>
2605
+ <details class="deck-more" data-deck-details="goal-${esc(goal.id || '')}"><summary>${I18N.lang === 'en' ? 'More' : '更多'}</summary><div class="deck-full-content">${esc(goal.objective || '')}<p>revision ${esc(goal.revision ?? '?')}</p></div><div class="ds-goal-actions"><button class="ds-mini-btn" data-goal="edit">${t('goal.edit')}</button><button class="ds-mini-btn" data-goal="clear">${t('goal.clear')}</button></div></details>
2600
2606
  </div>
2601
2607
  </div>
2602
2608
  <button type="button" class="ds-goal-side-tab${collapsed ? '' : ' hidden'}" data-goal-collapse="0" aria-expanded="false" aria-controls="goal-panel-desktop" aria-label="${esc(t('goal.expand'))}" title="${esc(t('goal.expand'))}"><span aria-hidden="true">‹</span><span>${t('goal.title')}</span><small>${t('goal.collapsedHint')}</small></button>
2603
2609
  </div>`
2604
2610
  }
2605
2611
  if (todos?.items?.length) {
2606
- html += `<div class="ds-card"><div class="ds-card-title">${t('todos.title')}</div>${todos.items.map(item =>
2612
+ html += `<div data-deck-kind="todos" class="ds-card">${window.DshSessionDeck?.taskHtml(todos.items) || `<div class="ds-card-title">${t('todos.title')}</div>${todos.items.map(item =>
2607
2613
  `<div class="ds-todo-row"><span class="ds-pill ${item.status === 'completed' ? 'done' : item.status === 'in_progress' ? 'active' : ''}">${esc(item.status || 'pending')}</span><span>${esc(item.content || '')}</span></div>`
2608
- ).join('')}</div>`
2614
+ ).join('')}`}</div>`
2609
2615
  }
2610
2616
  box.innerHTML = html
2611
2617
  box.querySelectorAll('[data-goal]').forEach(btn =>
@@ -2942,12 +2948,13 @@ function serverLabel() {
2942
2948
  }
2943
2949
  function desktopApprovalDetail(a) {
2944
2950
  const lines = []
2945
- if (a?.reason) lines.push(String(a.reason))
2951
+ if (a?.reason) lines.push(window.DshApprovalRecords?.displayReason(a.reason) || String(a.reason))
2946
2952
  if (a?.arguments !== undefined) lines.push(safeJson(a.arguments))
2947
2953
  if (a?.callId) lines.push(`callId: ${a.callId}`)
2948
2954
  return lines.join('\n') || t('ds.approvalReason', { reason: '' })
2949
2955
  }
2950
2956
  function renderSessionPendingDesktop() {
2957
+ window.DshFileInbox?.render()
2951
2958
  const box = $('session-pending')
2952
2959
  if (!box) return
2953
2960
  const sessionId = state.current
@@ -2958,12 +2965,12 @@ function renderSessionPendingDesktop() {
2958
2965
  box.classList.toggle('hidden', !sessionId || !items.length)
2959
2966
  if (!sessionId || !items.length) { box.innerHTML = ''; return }
2960
2967
  box.innerHTML = `<div class="ds-session-pending-head"><span>${esc(t('ds.attention'))}</span><span>${items.length}</span></div><div class="ds-session-pending-list">${items.map(({ kind, item }) => {
2961
- if (kind === 'approval') return `<article class="ds-notif-card" data-session-approval="${esc(item.approvalId)}">
2968
+ if (kind === 'approval') return `<article class="ds-notif-card" data-session-approval="${esc(item.approvalId)}">${window.DshSessionDeck?.approvalHtml(item, desktopApprovalDetail(item)) || `
2962
2969
  <div class="ds-notif-head">🔐 ${t('ds.approvalTitle')}</div>
2963
2970
  <div class="ds-notif-title">${esc(item.toolName || t('ds.toolDefault'))}</div>
2964
2971
  <div class="ds-notif-body">${esc(desktopApprovalDetail(item))}</div>
2965
2972
  <div class="ds-notif-actions"><button type="button" class="ds-btn allow" data-session-approve="1">${t('ds.allow')}</button><button type="button" class="ds-btn reject" data-session-approve="0">${t('ds.reject')}</button></div>
2966
- </article>`
2973
+ `}</article>`
2967
2974
  return `<button type="button" class="ds-notif-card question" data-session-question="${esc(item.rpcId)}" aria-haspopup="dialog">
2968
2975
  <span class="ds-question-card-head"><span class="ds-notif-head">❓ ${esc(item.questions?.[0]?.header || t('ds.questionNotify'))}</span><span class="ds-btn">${t('ds.submit')}</span></span>
2969
2976
  <span class="ds-question-summary">${esc(questionSummary(item))}</span>
@@ -4025,7 +4032,8 @@ function openDesktopPlugins(route = 'manage') {
4025
4032
  back:()=>showView('view-settings'),getSession:()=>state.byId.get(state.current),getTitle:()=>titleOf(state.byId.get(state.current)),openContext:()=>void openInsights('context',true),scrollTop:()=>{$('view-plugins').scrollTop=0},url:path=>connection.server+path,headers:{authorization:'Bearer '+connection.token,'x-dsh-remote-client':'web',...clientIdHeaders()},valid:connection.valid},$('desktop-plugin-page'),route)
4026
4033
  }
4027
4034
 
4028
- function showView(id) {
4035
+ function showView(id, pluginRoute = 'manage') {
4036
+ window.DshExtensions?.closeShortcuts()
4029
4037
  if (id !== 'view-chat') window.DshSubagents?.close()
4030
4038
  document.body?.classList.toggle('viewing-subagent', id === 'view-chat' && state.byId.get(state.current)?.origin === 'subagent')
4031
4039
  window.DshWorkflow?.close()
@@ -4033,6 +4041,8 @@ function showView(id) {
4033
4041
  if (id !== 'view-chat') conversationView?.pause()
4034
4042
  if (state.view === 'view-chat' && id !== 'view-chat' && state.current) void archiveEmptySessionOnLeave(state.current)
4035
4043
  state.view = id
4044
+ window.DshFileInbox?.render()
4045
+ window.DshSessionDeck?.refresh()
4036
4046
  document.body?.classList.toggle('workflow-at-start', !!window.DshWorkflow?.isMounted() && id === 'view-sessions')
4037
4047
  for (const v of ['view-overview', 'view-sessions', 'view-chat', 'view-files', 'view-plugins', 'view-settings']) $(v).classList.toggle('hidden', v !== id)
4038
4048
  if (id === 'view-chat') conversationView?.resume()
@@ -4046,7 +4056,7 @@ function showView(id) {
4046
4056
  else {overviewDetector?.pause();overviewPulse?.pause()}
4047
4057
  if (id === 'view-files' && !state.fs.loaded) loadFs(null, true)
4048
4058
  if (id === 'view-settings') showSettingsHome()
4049
- if (id === 'view-plugins') openDesktopPlugins()
4059
+ if (id === 'view-plugins') openDesktopPlugins(pluginRoute)
4050
4060
  else window.DshExtensions?.close()
4051
4061
  updateSessionActions()
4052
4062
  }
@@ -4146,6 +4156,11 @@ function bindSessionDialogs() {
4146
4156
  }
4147
4157
 
4148
4158
  function bindUi() {
4159
+ $('conn-badge').addEventListener('click', () => { toast(t('ds.connRefresh')); openStreams(); void refreshSessions(); startOverviewDetection(true) })
4160
+ window.DshExtensions?.bindShortcuts({ trigger: $('btn-plugin-shortcuts'), menu: $('plugin-shortcuts-menu'),
4161
+ config: () => optionalPluginConfig(), connected: () => !!state.token, hasSession: () => !!state.current,
4162
+ beforeOpen: () => setMobileSidebar(false),
4163
+ open: route => { if (route === 'context') void openInsights('context', true); else showView('view-plugins', route) } })
4149
4164
  bindSessionDialogs()
4150
4165
  getConversationView()
4151
4166
  $('btn-history-latest').addEventListener('click',()=>{getConversationView().latest();if(state.history.tailEvicted)void loadHistory(true)})
@@ -4290,6 +4305,8 @@ function bindUi() {
4290
4305
  $('btn-doctor').addEventListener('click', openDoctor)
4291
4306
  $('fb-cancel').addEventListener('click', closeFeedbackModal)
4292
4307
  $('fb-submit').addEventListener('click', submitFeedback)
4308
+ $('fb-include-diagnostics').addEventListener('change',()=>{void loadCrashPreview()})
4309
+ $('fb-include-crashes').addEventListener('change',()=>{void loadCrashPreview()})
4293
4310
  document.querySelectorAll('#fb-chips .ds-fb-chip').forEach(btn =>
4294
4311
  btn.addEventListener('click', () => {
4295
4312
  document.querySelectorAll('#fb-chips .ds-fb-chip').forEach(b => b.classList.toggle('current', b === btn))
@@ -4471,3 +4488,8 @@ function mountWorkflowDesktop() {
4471
4488
 
4472
4489
  // Operation logs stay on this device; users can copy or export them.
4473
4490
  globalThis.DshDiagnostics?.configure({surface:"desktop",copy:copyText,snapshot:()=>({sessionId:state.current,server:state.server,loading:!!state.history.loading,loaded:!!state.history.loaded,count:state.history.visible.length,...globalThis.DshDiagnostics.nativeSnapshot()})})
4491
+ globalThis.DshFileInbox?.mount({ capture: captureConnection, url: apiUrl,
4492
+ context: () => ({ sessionId: state.current, inChat: state.view === 'view-chat' }),
4493
+ sessionTitle: id => state.byId.has(id) ? titleOf(state.byId.get(id)) : '', openFiles: () => showView('view-files'),
4494
+ headers: connection => ({ authorization: 'Bearer ' + connection.token, 'x-dsh-remote-client': 'web', ...clientIdHeaders() }), native: () => null })
4495
+ globalThis.DshSessionDeck?.mount({ context: () => ({ sessionId: state.current, inChat: state.view === 'view-chat' }) })