dsh-remote-plugin 0.8.8 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.en.md +16 -5
  2. package/README.md +15 -4
  3. package/apk/dsh-remote.apk +0 -0
  4. package/gateway.cjs +583 -84
  5. package/index.mjs +1 -0
  6. package/package.json +8 -3
  7. package/public/activity.js +97 -10
  8. package/public/admin.html +34 -33
  9. package/public/admin.js +10 -2
  10. package/public/announcements.json +36 -0
  11. package/public/app.js +1564 -226
  12. package/public/bc-integration.css +81 -0
  13. package/public/build.json +2 -2
  14. package/public/composer-tools.css +184 -0
  15. package/public/composer-tools.js +888 -0
  16. package/public/desktop/desktop.html +94 -73
  17. package/public/desktop/desktop.js +726 -83
  18. package/public/e2ee-config.js +5 -0
  19. package/public/e2ee-transport.js +23 -4
  20. package/public/file-inbox.js +77 -18
  21. package/public/genui.css +10 -0
  22. package/public/genui.js +22 -4
  23. package/public/history.js +114 -17
  24. package/public/host-queue.js +232 -0
  25. package/public/host-schedule.js +301 -0
  26. package/public/host-state.css +19 -0
  27. package/public/index.html +332 -140
  28. package/public/md.js +21 -1
  29. package/public/network.js +33 -1
  30. package/public/onboarding.js +3 -3
  31. package/public/operations.js +4 -3
  32. package/public/plan-review.css +297 -0
  33. package/public/plan-review.js +642 -0
  34. package/public/plugin.html +29 -28
  35. package/public/relay-autopair.js +30 -10
  36. package/public/relay-devices.js +7 -3
  37. package/public/relay-settings.css +11 -0
  38. package/public/relay-settings.js +372 -30
  39. package/public/session-cache.js +85 -0
  40. package/public/session-management.css +61 -0
  41. package/public/session-management.js +742 -0
  42. package/public/session-search.css +137 -0
  43. package/public/session-search.js +977 -0
  44. package/public/skins/blue-fish/preview.html +3 -3
  45. package/public/skins/bocchi/preview.html +5 -5
  46. package/public/skins/kita/preview.html +6 -6
  47. package/public/skins/miku/SOURCES.json +10 -0
  48. package/public/skins/miku/chibi.png +0 -0
  49. package/public/skins/miku/preview.html +33 -0
  50. package/public/skins/miku/skin.css +82 -0
  51. package/public/skins/nijika/preview.html +6 -6
  52. package/public/skins/penguin/preview.html +3 -3
  53. package/public/skins/ryo/preview.html +6 -6
  54. package/public/slash-suggestions.js +15 -3
  55. package/public/sponsor-entry.js +11 -3
  56. package/public/styles.css +141 -21
  57. package/public/subagents.css +5 -0
  58. package/public/subagents.js +52 -0
  59. package/public/theme-vars.css +65 -1
  60. package/public/theme.js +4 -3
  61. package/public/turn-diff.css +323 -0
  62. package/public/turn-diff.js +778 -0
  63. package/public/update.json +12 -12
  64. package/public/version.json +1 -1
  65. package/public/workflow.css +305 -34
  66. package/public/workflow.js +141 -41
package/public/md.js CHANGED
@@ -56,10 +56,30 @@
56
56
  const local = /^(?:[A-Za-z]:[\\/]|\\\\|\/|\.{1,2}[\\/]|[^:\s]+[\\/])/.test(target)
57
57
  || /^[^:\s]+\.(?:png|jpe?g|gif|webp|bmp|svg|avif)$/i.test(target)
58
58
  if (!local) return null
59
+ return localImageHtml(target, label)
60
+ }
61
+
62
+ function localImageHtml(target, label) {
59
63
  return '<button type="button" class="chat-image is-loading" data-chat-image data-chat-image-path="' + escapeHtml(target) +
60
64
  '" data-chat-image-alt="' + label + '" aria-label="' + label + '"><span class="chat-image-status">' + label + '</span></button>'
61
65
  }
62
66
 
67
+ function genuiImageHtml(target, alt, options) {
68
+ if (!options?.fileLinks || Array.isArray(options.imageHosts) || typeof target !== 'string') return null
69
+ if (/^\/(?:api|fs)\/file\?/.test(target)) {
70
+ const query = new URLSearchParams(target.slice(target.indexOf('?') + 1))
71
+ target = query.size === 1 ? query.get('path') || '' : ''
72
+ }
73
+ if (/^file:/i.test(target)) target = files?.pathOf?.(target) || ''
74
+ // Use the existing authenticated file-image path for this session, including
75
+ // URLs from the host's file picker. Never fetch a model-provided URL directly.
76
+ if (target.length > 4096 || /[\x00-\x1f?#]/.test(target) || !/\.(?:png|jpe?g|gif|webp|bmp|avif)$/i.test(target)) return null
77
+ const drive = /^[A-Za-z]:[\\/]/.test(target)
78
+ const localPath = !/^[\\/]{2}/.test(target) && (target.startsWith('/') || files?.relativePath?.(target))
79
+ if (!drive && !localPath) return null
80
+ return localImageHtml(target, escapeHtml(alt || imageLabel))
81
+ }
82
+
63
83
  function inline(s, fileLinks, imageHosts) {
64
84
  // Pull images out before inline emphasis/link rules so alt text and URLs stay intact.
65
85
  const images = []
@@ -306,7 +326,7 @@
306
326
  if (options?.richContent !== false && genui && part.closed && code.length <= 200000) {
307
327
  try {
308
328
  if (/^(?:dsh-ui|json dsh-ui|dsh-ui json)$/.test(language)) {
309
- out += genui.render(JSON.parse(code)); continue
329
+ out += genui.render(JSON.parse(code), { image: (src, alt) => genuiImageHtml(src, alt, options) }); continue
310
330
  }
311
331
  if (language === 'html' || language === 'htm') {
312
332
  out += genui.html(code) + '<details><summary>HTML / 源码</summary>' + codeHtml(code, options, language) + '</details>'; continue
package/public/network.js CHANGED
@@ -22,6 +22,38 @@
22
22
  const job=Promise.resolve().then(read).finally(()=>{if(sharedReads.get(key)===job)sharedReads.delete(key)})
23
23
  sharedReads.set(key,job);return job
24
24
  }
25
+ // Public health covers reachability. Automatic selection also needs proof
26
+ // that the gateway accepts this saved credential.
27
+ async function probeGateway(base, { headers, onHealth } = {}) {
28
+ const url = String(base || '').replace(/\/+$/, '')
29
+ if (!url || (headers && !headers.authorization)) return Infinity
30
+ try {
31
+ return await readWithDeadline(async signal => {
32
+ const started = root.performance.now()
33
+ const response = await root.fetch(url + '/health?probe=live&t=' + Date.now(), { signal, cache: 'no-store' })
34
+ if (!response.ok) return Infinity
35
+ const health = await response.json().catch(() => null)
36
+ if (signal.aborted) return Infinity
37
+ if (health && typeof health === 'object') onHealth?.(health)
38
+ const latency = Math.round(root.performance.now() - started)
39
+ if (!headers) return latency
40
+ const options = { headers, signal, cache: 'no-store', redirect: 'error' }
41
+ const auth = await root.fetch(url + '/diagnostics', options)
42
+ if (auth.ok) {
43
+ const result = await auth.json().catch(() => null)
44
+ if (result?.schema === 1 && typeof result.gateway?.version === 'string') return latency
45
+ } else if (![404, 405, 501].includes(auth.status)) {
46
+ return Infinity
47
+ }
48
+ // Older gateways still authenticate the read-only event poll.
49
+ const legacy = await root.fetch(url + '/api/events.poll?kind=host&wait=0', options)
50
+ void legacy.body?.cancel().catch(() => {})
51
+ return legacy.ok && /^application\/json\b/i.test(legacy.headers.get('content-type') || '') ? latency : Infinity
52
+ }, 3500)
53
+ } catch {
54
+ return Infinity
55
+ }
56
+ }
25
57
  function mode(){try{return ['auto','weak','normal'].includes(root.localStorage.getItem('dshNetworkModeV1'))?root.localStorage.getItem('dshNetworkModeV1'):'auto'}catch{return 'auto'}}
26
58
  function profile(){
27
59
  const selected=mode(),connection=root.navigator?.connection
@@ -94,7 +126,7 @@
94
126
  if(streamTitle)streamTitle.textContent=english?'No streaming on weak networks':'弱网时关闭流式输出'
95
127
  if(streamDetail)streamDetail.textContent=english?'Show only finished messages and tool results on weak networks; live thinking and calls that have not returned stay hidden.':'弱网下只显示已完成的消息和工具结果,隐藏流式思考和尚未返回的工具调用;标准网络不受影响。'
96
128
  }
97
- const api={profile,setMode,PollLoop,shareRead,readWithDeadline,observeLatency:ms=>{if(Number.isFinite(ms))measuredLatency=ms},preferences,streamTrimmed}
129
+ const api={profile,setMode,PollLoop,shareRead,readWithDeadline,probeGateway,observeLatency:ms=>{if(Number.isFinite(ms))measuredLatency=ms},preferences,streamTrimmed}
98
130
  if(typeof module!=='undefined'&&module.exports)module.exports=api
99
131
  else{root.DshNetwork=api;root.document.addEventListener('DOMContentLoaded',()=>{preferences();new MutationObserver(preferences).observe(root.document.documentElement,{attributes:true,attributeFilter:['lang']})})}
100
132
  })(typeof window==='undefined'?globalThis:window)
@@ -11,7 +11,7 @@
11
11
  ['在电脑的 DSH 中安装 Remote 插件,打开插件里的连接向导。手机选择“扫码连接”,扫描连接码;下载 APK 的二维码用于安装,不能拿来配对。', 'Install Remote in DSH on the computer and open its connection wizard. Scan the connection QR on the phone; the APK download QR installs the app and does not pair it.'],
12
12
  ['同一 Wi-Fi 下可用局域网地址。离开家后需要可达的中转或组网地址;手机里的 localhost 指向手机自己。', 'Use the LAN address on the same Wi-Fi. Away from home, use a reachable relay or private-network address. On a phone, localhost means the phone itself.'],
13
13
  ['连接码含访问凭证,请不要公开截图。“主机与连接”可以重新扫码或修改地址。', 'Connection QR codes contain credentials. Keep them private. Hosts and connections lets you scan again or edit addresses.']
14
- ], action: ['打开主机与连接', 'Open hosts and connections'], target: '#workflow-connection' },
14
+ ], action: ['打开主机与连接', 'Open hosts and connections'], target: '#conn-badge' },
15
15
  { id: 'session', title: ['选择工作区,打开一段对话', 'Choose a workspace and open a conversation'],
16
16
  body: ['工作区是电脑上的项目目录;会话是在这个目录里进行的一段对话。可以打开已有会话,也可以新建。', 'A workspace is a project folder on the computer. A conversation works in that folder. Open an existing conversation or create one.'],
17
17
  tips: [
@@ -214,7 +214,7 @@
214
214
  restart.querySelector('.setting-desc').textContent = done
215
215
  ? text('重新查看连接、对话与常见操作', 'Revisit connection, chat and common actions')
216
216
  : text('按步骤熟悉连接、对话与常见操作', 'Learn connection, chat and common actions step by step')
217
- entry.hidden = done
217
+ entry.hidden = done || (progress.status === 'new' && !!live.hasSessions)
218
218
  return
219
219
  }
220
220
  entry.hidden = true
@@ -239,7 +239,7 @@
239
239
  card = el('section', 'onboarding-coach'); card.id = 'onboarding-coach'; card.tabIndex = -1
240
240
  card.setAttribute('aria-labelledby', 'onboarding-title'); card.hidden = true
241
241
  entry = button('', () => start(), 'onboarding-entry'); entry.id = 'onboarding-entry'
242
- entry.append(el('strong'), el('span')); $('view-home').prepend(entry)
242
+ entry.append(el('strong'), el('span')); $('view-home').append(entry)
243
243
  restart = button('', () => start(true), 'workflow-setting-link onboarding-restart'); restart.id = 'onboarding-restart'
244
244
  const mark = el('span', 'workflow-setting-icon onboarding-restart-icon'); mark.setAttribute('aria-hidden', 'true')
245
245
  const copy = el('span', 'onboarding-restart-copy'); copy.append(el('span', 'setting-name'), el('span', 'setting-desc'))
@@ -1,9 +1,10 @@
1
1
  /* Durable write receipts. POST once, recover using GET only; zero dependencies. */
2
2
  ;(function(root) {
3
3
  'use strict'
4
- const methods = new Set(['session.fork','session.create','session.prompt','session.updateQueue','session.selectModel',
4
+ const hostStateWrites = new Set(['session.updateQueue','schedule.create','schedule.edit','schedule.run'])
5
+ const methods = new Set(['session.fork','session.create','session.prompt','session.selectModel',
5
6
  'session.rename','session.cancel','workspace.create','workspace.archiveSession',
6
- 'goal.edit','goal.pause','goal.resume','goal.complete','goal.clear'])
7
+ 'goal.edit','goal.pause','goal.resume','goal.complete','goal.clear','session.continue',...hostStateWrites])
7
8
  const pending = new Map()
8
9
  const storageKey = 'dshRemoteOperationReceiptsV1'
9
10
  // Scope of the connection the UI is currently showing. Receipts from another
@@ -141,7 +142,7 @@
141
142
  }
142
143
  return [...rows.values()].filter(row => row.current || row.phase === 'unknown')
143
144
  }
144
- const api = { supports: method => methods.has(method), execute, check, restore,
145
+ const api = { supports: method => methods.has(method), requiresReceipt: method => method === 'session.continue' || hostStateWrites.has(method), execute, check, restore,
145
146
  dismiss: id => {
146
147
  const row = pending.get(id) || saved().find(value => value.id === id)
147
148
  if (!row || row.inFlight || (row.phase && row.phase !== 'unknown')) return false
@@ -0,0 +1,297 @@
1
+ /* Plan mode chip, plan-review card and read-only plan history.
2
+ * Prefix: .dr-plan-* — loaded by both the mobile Web/Android page and desktop Web. */
3
+
4
+ .dr-plan {
5
+ display: flex;
6
+ flex-direction: column;
7
+ gap: 10px;
8
+ margin: 10px 0;
9
+ color: var(--dsr-text, #1d2635);
10
+ font-size: 13px;
11
+ line-height: 1.45;
12
+ }
13
+
14
+ .dr-plan-status {
15
+ display: flex;
16
+ align-items: center;
17
+ flex-wrap: wrap;
18
+ gap: 8px;
19
+ padding: 8px 10px;
20
+ border: 1px solid var(--dsr-line, #d9dde5);
21
+ border-radius: 12px;
22
+ background: var(--dsr-panel, #fff);
23
+ }
24
+
25
+ .dr-plan-badge {
26
+ display: inline-flex;
27
+ align-items: center;
28
+ padding: 2px 8px;
29
+ border-radius: 999px;
30
+ font-size: 11px;
31
+ font-weight: 700;
32
+ letter-spacing: .04em;
33
+ color: var(--dsr-on-accent, #fff);
34
+ background: var(--dsr-muted, #687386);
35
+ }
36
+
37
+ .dr-plan-status--active .dr-plan-badge,
38
+ .dr-plan-status--entering .dr-plan-badge,
39
+ .dr-plan-status--leaving .dr-plan-badge {
40
+ background: var(--dsr-accent, #3979d6);
41
+ }
42
+
43
+ .dr-plan-status--review {
44
+ border-color: var(--dsr-warning-line, rgba(150, 90, 11, .35));
45
+ background: var(--dsr-warning-soft, rgba(185, 106, 14, .12));
46
+ }
47
+
48
+ .dr-plan-status--review .dr-plan-badge {
49
+ background: var(--dsr-warning, #965a0b);
50
+ }
51
+
52
+ .dr-plan-status--unsupported,
53
+ .dr-plan-status--unavailable {
54
+ color: var(--dsr-muted, #687386);
55
+ border-style: dashed;
56
+ }
57
+
58
+ .dr-plan-status--readonly,
59
+ .dr-plan-status--disconnected {
60
+ border-color: var(--dsr-error-line, rgba(183, 66, 63, .35));
61
+ }
62
+
63
+ .dr-plan-status-copy {
64
+ font-weight: 600;
65
+ }
66
+
67
+ .dr-plan-status-hint {
68
+ flex: 1 1 100%;
69
+ color: var(--dsr-muted, #687386);
70
+ font-size: 12px;
71
+ }
72
+
73
+ .dr-plan-status-review {
74
+ color: var(--dsr-warning, #965a0b);
75
+ font-size: 12px;
76
+ font-weight: 600;
77
+ }
78
+
79
+ .dr-plan-btn {
80
+ appearance: none;
81
+ border: 1px solid var(--dsr-accent-line, rgba(23, 107, 135, .35));
82
+ border-radius: 10px;
83
+ padding: 5px 10px;
84
+ font: inherit;
85
+ font-weight: 600;
86
+ color: var(--dsr-accent, #176b87);
87
+ background: var(--dsr-panel, #fff);
88
+ cursor: pointer;
89
+ }
90
+
91
+ .dr-plan-btn:disabled {
92
+ opacity: .55;
93
+ cursor: default;
94
+ }
95
+
96
+ .dr-plan-btn--approve {
97
+ color: var(--dsr-on-accent, #fff);
98
+ background: var(--dsr-accent, #176b87);
99
+ border-color: var(--dsr-accent, #176b87);
100
+ }
101
+
102
+ .dr-plan-btn--keep {
103
+ color: var(--dsr-warning, #965a0b);
104
+ border-color: var(--dsr-warning-line, rgba(150, 90, 11, .35));
105
+ }
106
+
107
+ .dr-plan-option {
108
+ margin-left: 6px;
109
+ padding: 0 6px;
110
+ border-radius: 6px;
111
+ font-size: 11px;
112
+ font-weight: 500;
113
+ opacity: .8;
114
+ background: var(--dsr-accent-soft, rgba(23, 107, 135, .10));
115
+ }
116
+
117
+ .dr-plan-btn--approve .dr-plan-option {
118
+ background: rgba(255, 255, 255, .18);
119
+ }
120
+
121
+ .dr-plan-notice {
122
+ margin: 0;
123
+ padding: 7px 10px;
124
+ border-radius: 10px;
125
+ border: 1px solid var(--dsr-line, #d9dde5);
126
+ background: var(--dsr-panel, #fff);
127
+ font-size: 12px;
128
+ }
129
+
130
+ .dr-plan-notice--ok { border-color: var(--dsr-success-line, rgba(35, 122, 70, .35)); color: var(--dsr-success, #237a46); }
131
+ .dr-plan-notice--err { border-color: var(--dsr-error-line, rgba(183, 66, 63, .35)); color: var(--dsr-error, #b7423f); }
132
+ .dr-plan-notice--info { color: var(--dsr-muted, #687386); }
133
+
134
+ .dr-plan-review {
135
+ padding: 10px;
136
+ border: 1px solid var(--dsr-warning-line, rgba(150, 90, 11, .35));
137
+ border-radius: 14px;
138
+ background: var(--dsr-panel, #fff);
139
+ }
140
+
141
+ .dr-plan-review-head {
142
+ display: flex;
143
+ align-items: center;
144
+ justify-content: space-between;
145
+ gap: 8px;
146
+ }
147
+
148
+ .dr-plan-review-strip {
149
+ font-size: 11px;
150
+ font-weight: 700;
151
+ letter-spacing: .06em;
152
+ text-transform: uppercase;
153
+ color: var(--dsr-warning, #965a0b);
154
+ }
155
+
156
+ .dr-plan-review-state {
157
+ padding: 1px 8px;
158
+ border-radius: 999px;
159
+ font-size: 11px;
160
+ color: var(--dsr-warning, #965a0b);
161
+ background: var(--dsr-warning-soft, rgba(185, 106, 14, .12));
162
+ }
163
+
164
+ .dr-plan-review-title {
165
+ margin: 6px 0 2px;
166
+ font-size: 15px;
167
+ font-weight: 700;
168
+ }
169
+
170
+ .dr-plan-review-summary {
171
+ margin: 0 0 6px;
172
+ color: var(--dsr-muted, #687386);
173
+ }
174
+
175
+ .dr-plan-doc {
176
+ margin: 6px 0;
177
+ border: 1px solid var(--dsr-line, #d9dde5);
178
+ border-radius: 10px;
179
+ background: var(--dsr-code-bg, rgba(0, 0, 0, .04));
180
+ }
181
+
182
+ .dr-plan-doc summary {
183
+ padding: 6px 9px;
184
+ font-size: 12px;
185
+ font-weight: 600;
186
+ cursor: pointer;
187
+ }
188
+
189
+ .dr-plan-doc pre {
190
+ margin: 0;
191
+ max-height: 50vh;
192
+ overflow: auto;
193
+ padding: 8px 9px;
194
+ font-size: 12px;
195
+ line-height: 1.5;
196
+ white-space: pre-wrap;
197
+ overflow-wrap: anywhere;
198
+ }
199
+
200
+ .dr-plan-hint {
201
+ margin: 6px 0;
202
+ color: var(--dsr-muted, #687386);
203
+ font-size: 12px;
204
+ }
205
+
206
+ .dr-plan-review-actions {
207
+ display: flex;
208
+ flex-wrap: wrap;
209
+ gap: 8px;
210
+ margin-top: 8px;
211
+ }
212
+
213
+ .dr-plan-feedback {
214
+ display: flex;
215
+ flex-direction: column;
216
+ gap: 4px;
217
+ margin-top: 8px;
218
+ font-size: 12px;
219
+ color: var(--dsr-muted, #687386);
220
+ }
221
+
222
+ .dr-plan-feedback textarea {
223
+ width: 100%;
224
+ box-sizing: border-box;
225
+ resize: vertical;
226
+ padding: 7px 9px;
227
+ border: 1px solid var(--dsr-line, #d9dde5);
228
+ border-radius: 10px;
229
+ font: inherit;
230
+ color: inherit;
231
+ background: var(--dsr-panel, #fff);
232
+ }
233
+
234
+ .dr-plan-review-note {
235
+ margin: 8px 0 0;
236
+ font-size: 11px;
237
+ color: var(--dsr-muted, #687386);
238
+ }
239
+
240
+ .dr-plan-review-status:empty { display: none; }
241
+
242
+ .dr-plan-history {
243
+ display: flex;
244
+ flex-direction: column;
245
+ gap: 8px;
246
+ padding-top: 4px;
247
+ border-top: 1px dashed var(--dsr-line, #d9dde5);
248
+ }
249
+
250
+ .dr-plan-history-head {
251
+ margin: 6px 0 0;
252
+ font-size: 12px;
253
+ font-weight: 700;
254
+ color: var(--dsr-muted, #687386);
255
+ }
256
+
257
+ .dr-plan-history-item {
258
+ padding: 8px 10px;
259
+ border: 1px solid var(--dsr-line, #d9dde5);
260
+ border-radius: 12px;
261
+ background: var(--dsr-panel, #fff);
262
+ }
263
+
264
+ .dr-plan-history-top {
265
+ display: flex;
266
+ align-items: center;
267
+ justify-content: space-between;
268
+ gap: 8px;
269
+ }
270
+
271
+ .dr-plan-history-title {
272
+ font-weight: 600;
273
+ overflow: hidden;
274
+ text-overflow: ellipsis;
275
+ white-space: nowrap;
276
+ }
277
+
278
+ .dr-plan-history-badge {
279
+ flex: 0 0 auto;
280
+ padding: 1px 8px;
281
+ border-radius: 999px;
282
+ font-size: 11px;
283
+ color: var(--dsr-muted, #687386);
284
+ background: var(--dsr-code-bg, rgba(0, 0, 0, .06));
285
+ }
286
+
287
+ .dr-plan-history-meta {
288
+ margin-top: 2px;
289
+ font-size: 12px;
290
+ color: var(--dsr-muted, #687386);
291
+ }
292
+
293
+ @media (max-width: 560px) {
294
+ .dr-plan-status { padding: 7px 8px; }
295
+ .dr-plan-review-actions { flex-direction: column; }
296
+ .dr-plan-review-actions .dr-plan-btn { width: 100%; }
297
+ }