dsh-remote-plugin 0.8.6 → 0.8.8

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 (45) hide show
  1. package/apk/dsh-remote.apk +0 -0
  2. package/gateway.cjs +169 -63
  3. package/index.mjs +36 -1
  4. package/package.json +1 -1
  5. package/public/activity.js +144 -49
  6. package/public/admin.html +33 -32
  7. package/public/admin.js +25 -6
  8. package/public/app.js +199 -57
  9. package/public/build.json +2 -2
  10. package/public/desktop/desktop.html +85 -74
  11. package/public/desktop/desktop.js +52 -27
  12. package/public/diagnostics.js +30 -4
  13. package/public/doctor.css +1 -1
  14. package/public/e2ee-transport.js +189 -18
  15. package/public/history.js +15 -2
  16. package/public/index.html +97 -76
  17. package/public/operations.js +59 -14
  18. package/public/plugin.html +27 -26
  19. package/public/relay-autopair.js +60 -26
  20. package/public/relay-devices.js +11 -5
  21. package/public/relay-settings.css +9 -0
  22. package/public/relay-settings.js +67 -9
  23. package/public/skins/blue-fish/preview.html +3 -3
  24. package/public/skins/bocchi/preview.html +5 -5
  25. package/public/skins/kita/preview.html +6 -6
  26. package/public/skins/nijika/preview.html +6 -6
  27. package/public/skins/penguin/preview.html +3 -3
  28. package/public/skins/penguin-logistics/cargo.svg +4 -0
  29. package/public/skins/penguin-logistics/console.svg +4 -0
  30. package/public/skins/penguin-logistics/mark.svg +4 -0
  31. package/public/skins/penguin-logistics/radio.svg +4 -0
  32. package/public/skins/penguin-logistics/skin.css +292 -0
  33. package/public/skins/penguin-logistics/standing.png +0 -0
  34. package/public/skins/ryo/preview.html +6 -6
  35. package/public/slash-suggestions.css +43 -0
  36. package/public/slash-suggestions.js +184 -0
  37. package/public/subagents.css +2 -0
  38. package/public/subagents.js +31 -10
  39. package/public/theme-vars.css +37 -2
  40. package/public/theme.js +4 -2
  41. package/public/update.json +12 -12
  42. package/public/version.json +1 -1
  43. package/public/workflow.css +19 -11
  44. package/public/workflow.js +25 -14
  45. package/skills/dsh-remote-doctor/references/wiki/connection.md +2 -0
package/public/app.js CHANGED
@@ -120,6 +120,7 @@ for (const key of ['server', 'token']) {
120
120
  if (next === value) return
121
121
  cancelHistoryLoad()
122
122
  value = next; connectionGeneration++
123
+ window.DshSlashSuggestions?.close()
123
124
  window.DshImagePreview?.reset?.()
124
125
  clearTimeout(state.refreshTimer); state.refreshTimer = null
125
126
  state.sessions = []; state.byId.clear(); state.pendingProjections.clear(); state.runtimeErrors = new Map()
@@ -497,12 +498,17 @@ function saveAutoPairedRelay(origin, connection) {
497
498
  if (state.servers.some(s=>s.url===origin&&serverToken(s)===token&&s.group===state.activeGroup)) return
498
499
  state.servers.push({id:newServerId(),url:origin,note:I18N.lang==='en'?'Cloud relay':'公网中转',group:state.activeGroup,token})
499
500
  saveServers();renderServers();syncBgConfig()
500
- toast(I18N.lang==='en'?'Relay pairing configured. LAN remains connected.':'公网配对已配置,局域网连接保留。','ok')
501
+ toast(I18N.lang==='en'?'Public access verified. LAN remains connected.':'公网已验证,局域网连接保留。','ok')
502
+ }
503
+ let relaySetup = null
504
+ function relaySetupFor(connection) {
505
+ if (relaySetup && relaySetup.token === connection.token && relaySetup.servers.includes(connection.server)) return relaySetup.id
506
+ return ''
501
507
  }
502
508
  function offerLocalRelayPairing(connection=captureConnection(), force=false) {
503
509
  if (!connection.token || !connection.valid()) return
504
510
  return window.DshRelayAutoPair?.offer({
505
- connection:()=>({valid:connection.valid,url:path=>connection.server+path,headers:{authorization:'Bearer '+connection.token}}),
511
+ connection:()=>({valid:connection.valid,url:path=>connection.server+path,headers:{authorization:'Bearer '+connection.token},setupId:relaySetupFor(connection)}),
506
512
  onPaired:saveAutoPairedRelay,force,
507
513
  onStatus:(message,error)=>{if(force&&error&&connection.valid())toast(message,'err')},
508
514
  })
@@ -622,13 +628,25 @@ async function respond(rpcId, value) {
622
628
  return receipt?.accepted === true
623
629
  }
624
630
 
631
+ function operationPendingHost(connection) {
632
+ try {
633
+ const url = new URL(connection?.server || '', location.href)
634
+ return url.host || location.host
635
+ } catch { return location.host }
636
+ }
637
+ // A durable write may have been applied even if the connection identity changed
638
+ // while its receipt was pending. Never drop that fact silently.
639
+ function notifyPendingOperation(error, connection) {
640
+ if (connection?.valid()) toast(error.message, 'err')
641
+ else toast(t('send.unconfirmedSwitched', { host: operationPendingHost(connection) }), 'err')
642
+ }
625
643
  async function safeRpc(method, payload, errText) {
626
644
  const connection = captureConnection()
627
645
  try { const value = await rpc(method, payload); return connection.valid() ? value : null }
628
646
  catch (e) {
647
+ if (e.operationPending) { notifyPendingOperation(e, connection); return null }
629
648
  if (!connection.valid()) return null
630
649
  if (e.message === 'AUTH') authFailure()
631
- else if (e.operationPending) toast(e.message, 'err')
632
650
  else toast(errText ? `${errText}:${e.message}` : e.message, 'err')
633
651
  return null
634
652
  }
@@ -1419,10 +1437,10 @@ function openStream(kind, handler, refreshOnOpen, isRestore, ticket = null) {
1419
1437
  state.approvals = []
1420
1438
  state.questions = []
1421
1439
  renderPending()
1440
+ resyncAfterStreamOpen()
1422
1441
  }
1423
1442
  if (refreshOnOpen) refreshAll()
1424
1443
  if (allStreamsOpen()) {
1425
- resyncAfterStreamOpen()
1426
1444
  void pingServer(state.server || location.origin)
1427
1445
  void refreshHostDescription()
1428
1446
  }
@@ -1452,6 +1470,7 @@ function openStream(kind, handler, refreshOnOpen, isRestore, ticket = null) {
1452
1470
  aggregateStreamFailures()
1453
1471
  updateConn()
1454
1472
  if (!navigator.onLine) { clearReconnect(); return }
1473
+ if (kind === 'mux') scheduleSessionSync()
1455
1474
  // 任一通道连续失败 3 次就降级轮询;另一个通道不会清零它的失败计数。
1456
1475
  if (state.streamMode !== 'poll' && meta.failures >= 3) { enterPollMode(); return }
1457
1476
  // 多服务器: 连续掉线若干次就重测速, 自动换到当前可达的最快地址
@@ -2035,7 +2054,7 @@ function rememberRuntimeError(sessionId, message) {
2035
2054
  function resyncAfterStreamOpen() {
2036
2055
  if (!state.current || Date.now() - state.lastStreamResyncAt < 1200) return
2037
2056
  state.lastStreamResyncAt = Date.now()
2038
- void refreshAll().then(() => resyncCurrentSession())
2057
+ scheduleSessionSync(state.current, 0)
2039
2058
  }
2040
2059
  function sessionTitleValue(s) {
2041
2060
  const value = proj(s, 'title', '')
@@ -2653,6 +2672,7 @@ function bindNativeBack() {
2653
2672
  try {
2654
2673
  CAP.Plugins?.App?.addListener?.('appStateChange',({isActive})=>{if(isActive)onResume()})
2655
2674
  CAP.Plugins?.App?.addListener?.('backButton', () => {
2675
+ if (typeof window !== 'undefined' && window.DshSlashSuggestions?.close()) return
2656
2676
  if ($('composer-wrap')?.classList.contains('fs')) { setComposerFullscreen(false); return }
2657
2677
  if (customSelectCurrent) { closeCustomSelect(); return }
2658
2678
  if (groupDrawerOpen()) { closeGroupDrawer(); return }
@@ -3032,20 +3052,7 @@ function insertLiveEvent(event) {
3032
3052
  scheduleHistoryCacheSave()
3033
3053
  }
3034
3054
 
3035
- function isToolEvent(type) { return type === 'tool/call' || type === 'tool/result' }
3036
-
3037
- /** One collapsed row for a turn's tools and reasoning, matching the desktop conversation rhythm. */
3038
- function activityGroupHtml(group, ctx) {
3039
- const items = group.items || []
3040
- if (!items.length) return ''
3041
- const tools = items.filter(item => item.kind === 'tool').map(item => item.entry)
3042
- const running = !!group.running
3043
- const failed = tools.some(entry => entry.view?.toolActivity?.error || entry.event?.data?.error)
3044
- const body = items.map(item => item.kind === 'reasoning'
3045
- ? window.DshActivity.reasoning({ text: item.text, key: item.key })
3046
- : eventHtml(item.entry, ctx)).join('')
3047
- return `<details class="chat-activity-group${failed ? ' is-error' : ''}${running ? ' is-running' : ''}" data-activity-key="activity-group:${items[0]?.seq ?? ''}"><summary><span class="activity-group-title">${esc(t('activity.group', { n: items.length }))}</span>${running ? `<span class="activity-group-live"><i aria-hidden="true"></i>${esc(t('activity.groupRunning'))}</span>` : ''}<span class="activity-chevron" aria-hidden="true"></span></summary><div class="activity-group-body">${body}</div></details>`
3048
- }
3055
+ function isToolEvent(type) { return window.DshActivity?.isToolEvent?.(type) ?? (type === 'tool/call' || type === 'tool/result') }
3049
3056
 
3050
3057
  function filteredEntries() {
3051
3058
  const showTools = LS.get('showTools', '1') !== '0'
@@ -3098,14 +3105,14 @@ function renderHistory(reset=false,mode='auto') {
3098
3105
  if(weakStreamTrim())prepared=prepared.filter(entry=>entry.event?.type!=='tool/call'||entry.view?.toolActivity)
3099
3106
  // DSH 0.2.1 also embeds tool blocks in messages; the separated events own the grouped rows.
3100
3107
  state.history.suppressBlockTools = state.history.visible.some(entry => entry.event?.type === 'tool/call')
3101
- if(window.DshActivity?.group)prepared=window.DshActivity.group(prepared)
3102
- // Running is a property of the session's current turn, not of an unpaired call:
3103
- // a finished turn may keep an unmatched call after an interrupt, and the model may be
3104
- // thinking between tools while the last group is still the active one.
3105
- const sessionRunning = !!state.byId.get(state.current)?.running
3106
- const groups = prepared.filter(entry => entry.view?.activityGroup)
3107
- const activeGroup = groups.at(-1)
3108
- if (activeGroup) activeGroup.view.activityGroup.running = sessionRunning
3108
+ const activity = window.DshActivity
3109
+ const groupLive = activity?.group && !weakStreamTrim()
3110
+ if(activity?.group)prepared=activity.group(prepared, {
3111
+ liveReasoning: groupLive ? [...state.history.partialReasoning.values()] : [],
3112
+ running: !!state.byId.get(state.current)?.running,
3113
+ suppressBlockTools: state.history.suppressBlockTools,
3114
+ showTools: LS.get('showTools', '1') !== '0',
3115
+ })
3109
3116
  if (window.DshTurnResults) {
3110
3117
  prepared = window.DshTurnResults.decorate(prepared, state.history.visible, { sessionId: state.current, canFork: canForkTurnResult() })
3111
3118
  bindTurnResultActions()
@@ -3114,7 +3121,7 @@ function renderHistory(reset=false,mode='auto') {
3114
3121
  const hostError = state.runtimeErrors?.get(state.current)
3115
3122
  const recordedError = state.history.visible.some(entry => window.DshActivity?.failure?.(entry.event)?.message === hostError)
3116
3123
  const runtimeHtml = hostError && !recordedError ? window.DshActivity?.failureHtml?.(hostError) || '' : ''
3117
- getConversationView().set(prepared,{reset,follow:mode==='bottom',live:partialReasoningHtml()+runtimeHtml,hasMore:state.history.hasMore,loading:state.history.loading,emptyLabel:t('history.empty')})
3124
+ getConversationView().set(prepared,{reset,follow:mode==='bottom',live:(groupLive?'':partialReasoningHtml())+runtimeHtml,hasMore:state.history.hasMore,loading:state.history.loading,emptyLabel:t('history.empty')})
3118
3125
  window.DshImagePreview?.hydrate?.($('history'))
3119
3126
  }
3120
3127
  window.applyStreamPreference=()=>{if(state.current)renderHistory(false,'auto')}
@@ -3174,7 +3181,7 @@ function bindRail() {
3174
3181
  const INTERESTING_EVENTS = new Set([
3175
3182
  'turn/start', 'turn/end',
3176
3183
  'user/message', 'assistant/message', 'assistant/attempt',
3177
- 'tool/call', 'tool/result',
3184
+ 'tool/call', 'tool/result', 'tool/ptc-dispatch-start', 'tool/ptc-dispatch',
3178
3185
  'agent/status',
3179
3186
  'checkpoint/created', 'compaction/complete', 'compaction/summary',
3180
3187
  'goal/created', 'goal/updated', 'goal/completed', 'goal/cleared',
@@ -3219,7 +3226,8 @@ function eventHtml(entry, ctx = {}) {
3219
3226
  // Successful boundaries stay quiet; failed turns keep their durable explanation.
3220
3227
  if (type === 'turn/start' || type === 'turn/end') return failure
3221
3228
  if (type === 'assistant/attempt') return window.DshActivity?.attemptHtml?.(ev) || ''
3222
- if (entry.view?.activityGroup) return activityGroupHtml(entry.view.activityGroup, ctx)
3229
+ if (entry.view?.activityTurn) return window.DshActivity.turnHtml(entry.view.activityTurn)
3230
+ if (entry.view?.activityGroup) return window.DshActivity.groupHtml(entry.view.activityGroup, item => eventHtml(item, ctx))
3223
3231
  if (!shouldShowEvent(type, ev)) return ''
3224
3232
  if (window.DshActivity && isToolEvent(type)) return window.DshActivity.toolEvent(entry)
3225
3233
  let inner = ''
@@ -3450,7 +3458,7 @@ async function interruptSubagent(childId, parentId = state.current) {
3450
3458
  const result = await safeRpc('subagent.interrupt', { parentSessionId: parentId, childSessionId: childId, mode: 'continuable' }, t('subagent.interruptFailed'))
3451
3459
  if (result == null || !connection.valid() || state.current !== rootId) return
3452
3460
  toast(t('subagent.interruptSubmitted'), 'ok')
3453
- setTimeout(renderSessionCards, 600)
3461
+ return true
3454
3462
  }
3455
3463
 
3456
3464
  /* ---------------- 发送 / 取消 / 快捷菜单 ---------------- */
@@ -3727,7 +3735,29 @@ function setComposerSendFeedback(context, key, phase, message = '') {
3727
3735
  renderComposerSend()
3728
3736
  }
3729
3737
  // No preflight or automatic retry: an ambiguous timeout may already have delivered the message.
3738
+ async function sendPrompt(payload, context) {
3739
+ const connection = captureConnection()
3740
+ try {
3741
+ const value = await rpc('session.prompt', payload)
3742
+ return connection.valid() ? value : null
3743
+ } catch (error) {
3744
+ if (error.operationPending) {
3745
+ // Keep the warning on screen instead of a 3-second toast while the
3746
+ // connection is unchanged; otherwise attribute it to the old connection.
3747
+ if (connection.valid() && composerContext() === context) {
3748
+ setComposerSendFeedback(context, error.receiptMissing ? 'send.receiptMissing' : 'send.resultUnconfirmed', 'unknown')
3749
+ }
3750
+ else notifyPendingOperation(error, connection)
3751
+ return null
3752
+ }
3753
+ if (!connection.valid()) return null
3754
+ if (error.message === 'AUTH') authFailure()
3755
+ else toast(t('send.failed') + ':' + error.message, 'err')
3756
+ return null
3757
+ }
3758
+ }
3730
3759
  async function submitSteer(method, payload, context) {
3760
+ const connection = captureConnection()
3731
3761
  if (steeringInFlight.has(context)) {
3732
3762
  if (composerContext() === context) toast(t('send.steerPending'), 'err')
3733
3763
  return null
@@ -3746,6 +3776,7 @@ async function submitSteer(method, payload, context) {
3746
3776
  return result
3747
3777
  } catch (error) {
3748
3778
  setComposerSendFeedback(context, error.rpcRejected || error.message === 'AUTH' ? 'send.steerRejected' : 'send.steerUnconfirmed', error.rpcRejected ? 'error' : 'unknown', error.message)
3779
+ if (error.operationPending && (!connection.valid() || composerContext() !== context)) notifyPendingOperation(error, connection)
3749
3780
  if (error.message === 'AUTH' && composerContext() === context) authFailure()
3750
3781
  return null
3751
3782
  } finally { clearTimeout(slow); steeringInFlight.delete(context) }
@@ -3829,7 +3860,7 @@ async function sendSessionContent(text, images, requestedMode = 'queue') {
3829
3860
  }
3830
3861
  const v = mode === 'steer'
3831
3862
  ? await submitSteer('session.prompt', payload, context)
3832
- : await safeRpc('session.prompt', payload, t('send.failed'))
3863
+ : await sendPrompt(payload, context)
3833
3864
  if (composerContext() !== context) return !!v?.accepted
3834
3865
  if (v?.accepted) {
3835
3866
  state.sessionActivity.add(sessionId)
@@ -3874,6 +3905,7 @@ async function encodeComposerImagesFor(images) {
3874
3905
 
3875
3906
  async function sendMessage(requestedMode) {
3876
3907
  const input = $('composer-input')
3908
+ if (typeof window !== 'undefined') window.DshSlashSuggestions?.close()
3877
3909
  const originalText = input.value
3878
3910
  const text = originalText.trim()
3879
3911
  const context = composerContext()
@@ -3930,6 +3962,7 @@ function toggleComposerMenu() {
3930
3962
  menu.classList.toggle('hidden', !show)
3931
3963
  $('btn-plus').classList.toggle('active', show)
3932
3964
  if (show) refreshPermissionPresets()
3965
+ if (show) void window.DshSlashSuggestions?.openPanel()
3933
3966
  if (show && !state.models.loaded && !state.models.loading) loadSessionModels()
3934
3967
  }
3935
3968
 
@@ -4929,9 +4962,13 @@ async function saveChatImage(ref) {
4929
4962
  try {
4930
4963
  if (ref.kind === 'attachment') {
4931
4964
  if (!/^(?:sha256:)?[a-f0-9]{64}$/.test(String(ref.attachmentId || ''))) return
4932
- const target = new URL('/remote/api/session-file', location.href)
4965
+ // Native shells serve the UI from https://localhost, so anchor the endpoint on
4966
+ // the paired gateway origin instead of location.href (DownloadManager cannot
4967
+ // reach the device-local WebView origin).
4968
+ const target = new URL((connection.server || '') + '/remote/api/session-file', location.href)
4933
4969
  target.searchParams.set('sessionId', ref.sessionId || state.current || '')
4934
- target.searchParams.set('attachmentId', ref.attachmentId)
4970
+ // The plugin validates bare 64-hex ids; some upstream refs carry a sha256: prefix.
4971
+ target.searchParams.set('attachmentId', String(ref.attachmentId).replace(/^sha256:/, ''))
4935
4972
  url = target.href
4936
4973
  } else {
4937
4974
  const request = chatImageRequest(ref.path)
@@ -5598,6 +5635,9 @@ async function loadLocalVersion() {
5598
5635
  const res = await fetch('version.json?t=' + Date.now())
5599
5636
  if (res.ok) state.localVersion = (await res.json())?.version || ''
5600
5637
  } catch {}
5638
+ if (!state.localVersion && CAP?.isNativePlatform?.()) {
5639
+ state.localVersion = (window.NativeUpdate?.getInstalledVersion?.() || '').replace(/\.rc\.(\d+)$/, '-rc.$1')
5640
+ }
5601
5641
  $('update-desc').textContent = state.localVersion ? t('update.currentV', { version: state.localVersion }) : t('update.noVersion')
5602
5642
  }
5603
5643
 
@@ -6154,7 +6194,10 @@ function closeNotesModal() {
6154
6194
  if (notesVersion) { LS.set(NOTES_KEY, notesVersion); notesVersion = '' }
6155
6195
  }
6156
6196
 
6197
+ let activeUpdateCheck
6198
+
6157
6199
  async function checkUpdate(silent) {
6200
+ if (silent && activeUpdateCheck && !activeUpdateCheck.silent) return
6158
6201
  if (!state.localVersion) {
6159
6202
  $('update-desc').textContent = t('update.noVersion')
6160
6203
  resetUpdateExpand()
@@ -6162,27 +6205,54 @@ async function checkUpdate(silent) {
6162
6205
  return
6163
6206
  }
6164
6207
  const base = updateBase()
6165
- if (!base) {
6208
+ const connection = captureConnection()
6209
+ const native = window.NativeUpdate
6210
+ const canCheckOfficial = !silent && CAP?.isNativePlatform?.() && native?.checkOfficialRelease
6211
+ && native.getOfficialReleaseStatus && native.downloadOfficialRelease && native.getDownloadStatus
6212
+ if (!base && !canCheckOfficial) {
6166
6213
  if (!silent) toast(t('update.needServer'), 'err')
6167
6214
  $('update-desc').textContent = state.localVersion ? `${t('update.currentV', { version: state.localVersion })} · ${t('update.needServer')}` : t('update.needServer')
6168
6215
  resetUpdateExpand()
6169
6216
  return
6170
6217
  }
6218
+ const request = { silent }
6219
+ activeUpdateCheck = request
6220
+ const valid = () => activeUpdateCheck === request && connection.valid()
6171
6221
  if (!silent) toast(t('update.checking'))
6172
6222
  try {
6173
- const res = await fetch(base + '/update.json?t=' + Date.now() + '&local=' + encodeURIComponent(state.localVersion))
6174
- if (!res.ok) throw new Error('HTTP ' + res.status)
6175
- const info = await res.json()
6223
+ let info
6224
+ if (base) {
6225
+ try {
6226
+ const res = await fetch(base + '/update.json?t=' + Date.now() + '&local=' + encodeURIComponent(state.localVersion),
6227
+ { signal: AbortSignal.timeout(8000), cache: 'no-store' })
6228
+ if (!res.ok) throw new Error('HTTP ' + res.status)
6229
+ const host = await res.json()
6230
+ if (typeof host?.version !== 'string' || !host.version) throw new Error(t('update.noVersion'))
6231
+ if (canCheckOfficial && cmpVersion(host.version, state.localVersion) > 0 && !/^[a-f0-9]{64}$/i.test(host.sha256 || '')) {
6232
+ throw new Error(t('update.hashMissing'))
6233
+ }
6234
+ info = { ...host, source: 'host', base }
6235
+ } catch (error) {
6236
+ if (!canCheckOfficial) throw error
6237
+ }
6238
+ }
6239
+ if (!valid()) return
6240
+ if (canCheckOfficial && (!info || cmpVersion(info.version, state.localVersion) <= 0)) {
6241
+ info = await checkOfficialAndroidRelease(native, valid)
6242
+ if (!valid()) return
6243
+ }
6176
6244
  if (!silent || !window.DshWorkflow?.isMounted()) openNotesModal(info)
6177
6245
  if (info.version && cmpVersion(info.version, state.localVersion) > 0) {
6178
6246
  state.updateInfo = info
6179
6247
  const hasNotes = !!(info.notes && String(info.notes).trim())
6180
- $('update-desc').textContent = t('update.found', { version: info.version, notes: hasNotes ? ':' + info.notes : '' })
6248
+ $('update-desc').textContent = info.source === 'official'
6249
+ ? t('update.foundOfficial', { version: info.version })
6250
+ : t('update.found', { version: info.version, notes: hasNotes ? ':' + info.notes : '' })
6181
6251
  $('update-desc').classList.remove('expanded')
6182
6252
  $('btn-update-expand').classList.toggle('hidden', !hasNotes)
6183
6253
  renderUpdateExpandBtn()
6184
6254
  $('btn-download-update').classList.remove('hidden')
6185
- if (!silent) toast(t('update.found', { version: info.version }), 'ok')
6255
+ if (!silent) toast(t(info.source === 'official' ? 'update.foundOfficial' : 'update.found', { version: info.version }), 'ok')
6186
6256
  else notify(t('update.foundTitle'), t('update.foundBody', { version: info.version }))
6187
6257
  } else {
6188
6258
  state.updateInfo = null
@@ -6192,9 +6262,16 @@ async function checkUpdate(silent) {
6192
6262
  if (!silent) toast(t('update.latestToast'), 'ok')
6193
6263
  }
6194
6264
  } catch (e) {
6265
+ if (!valid()) return
6266
+ if (!silent) {
6267
+ state.updateInfo = null
6268
+ $('btn-download-update').classList.add('hidden')
6269
+ }
6195
6270
  $('update-desc').textContent = t('update.checkFailedDesc', { msg: e.message || t('fs.networkError') })
6196
6271
  resetUpdateExpand()
6197
6272
  if (!silent) toast(t('update.checkFailed', { msg: e.message }), 'err')
6273
+ } finally {
6274
+ if (activeUpdateCheck === request) activeUpdateCheck = null
6198
6275
  }
6199
6276
  }
6200
6277
 
@@ -6207,6 +6284,21 @@ let updateDownloadBusy = false
6207
6284
  let updateDownloadTimer = null
6208
6285
  let updateDownloadSample = null
6209
6286
 
6287
+ async function checkOfficialAndroidRelease(native, valid) {
6288
+ $('update-desc').textContent = t('update.checkingOfficial')
6289
+ native.checkOfficialRelease()
6290
+ const deadline = Date.now() + 24000
6291
+ while (valid() && Date.now() < deadline) {
6292
+ const status = JSON.parse(native.getOfficialReleaseStatus())
6293
+ if (status.phase === 'complete' && /^\d+\.\d+\.\d+$/.test(status.version) && /^[a-f0-9]{64}$/i.test(status.sha256)) {
6294
+ return { source: 'official', version: status.version, sha256: status.sha256 }
6295
+ }
6296
+ if (status.phase !== 'checking') break
6297
+ await new Promise(resolve => setTimeout(resolve, 250))
6298
+ }
6299
+ throw new Error(t('update.officialUnavailable'))
6300
+ }
6301
+
6210
6302
  function updateDownloadProgress(value) {
6211
6303
  const box = $('update-download-progress')
6212
6304
  if (!box) return
@@ -6222,8 +6314,14 @@ function updateDownloadProgress(value) {
6222
6314
  if (total > 0) bar.value = Math.min(100, received * 100 / total)
6223
6315
  else bar.removeAttribute('value')
6224
6316
  const phase = value.phase || 'downloading'
6225
- $('update-download-status').textContent = phase === 'error' ? t('update.downloadFailed', { msg: value.error || t('fs.networkError') }) : t(`update.phase.${phase}`)
6226
- $('update-download-detail').textContent = `${total > 0 ? `${Math.min(100, received * 100 / total).toFixed(0)}% · ` : ''}${format(received)}${total > 0 ? ` / ${format(total)}` : ''} · ${format(phase === 'downloading' ? updateDownloadSample.speed : 0)}/s`
6317
+ let status
6318
+ if (phase !== 'error') status = t(`update.phase.${phase}`)
6319
+ else if (value.code === 'installer') status = t('update.installerFailed')
6320
+ else if (value.code === 'verify') status = t(value.patch ? 'update.patchMismatch' : 'update.corrupted')
6321
+ else if (value.code === 'storage') status = t('update.storageFailed')
6322
+ else status = t('update.downloadFailed', { msg: value.error || t('fs.networkError') })
6323
+ $('update-download-status').textContent = status
6324
+ $('update-download-detail').textContent = `${total > 0 ? `${Math.min(100, received * 100 / total).toFixed(0)}% · ` : ''}${format(received)}${total > 0 ? ` / ${format(total)}` : ''} · ${format(phase === 'downloading' || phase === 'official' ? updateDownloadSample.speed : 0)}/s`
6227
6325
  }
6228
6326
 
6229
6327
  function finishUpdateDownload() {
@@ -6275,9 +6373,10 @@ async function verifyUpdateApk(info, url) {
6275
6373
 
6276
6374
  async function downloadUpdate(force = false) {
6277
6375
  if (updateDownloadBusy || (force !== true && !state.updateInfo)) return
6278
- const base=updateBase()
6279
- if(!base){toast(t('update.needServer'),'err');return}
6280
- const connection=captureConnection()
6376
+ const base = updateBase()
6377
+ const official = !force && state.updateInfo?.source === 'official'
6378
+ if (!official && !base) { toast(t('update.needServer'), 'err'); return }
6379
+ const connection = captureConnection()
6281
6380
  updateDownloadBusy = true
6282
6381
  updateDownloadSample = null
6283
6382
  $('btn-download-update').disabled = true
@@ -6296,24 +6395,39 @@ async function downloadUpdate(force = false) {
6296
6395
  if(!connection.valid())return
6297
6396
  const sha256=String(info?.sha256||'').trim().toLowerCase()
6298
6397
  if(!/^[0-9a-f]{64}$/.test(sha256))throw new Error(t('update.hashMissing'))
6299
- const target=new URL(info.apkUrl||'dsh-remote.apk',base+'/')
6300
- if(force===true)target.searchParams.set('dshPatch',Date.now().toString(36)+'-'+sha256.slice(0,16))
6301
- const url=target.href
6302
- updateDownloadProgress({ phase: 'downloading', received: 0, total: 0 })
6303
- if (CAP?.isNativePlatform?.() && window.NativeUpdate?.downloadVerifiedAndInstall && window.NativeUpdate?.getDownloadStatus) {
6304
- if (!window.NativeUpdate.downloadVerifiedAndInstall(url, sha256)) throw new Error(t('update.busy'))
6398
+ if (!official && info.base && info.base !== base) throw new Error(t('update.checkAgain'))
6399
+ const target = official ? null : new URL(info.apkUrl || 'dsh-remote.apk', base + '/')
6400
+ if (force) target.searchParams.set('dshPatch', Date.now().toString(36) + '-' + sha256.slice(0, 16))
6401
+ const url = target?.href
6402
+ updateDownloadProgress({ phase: official ? 'official' : 'downloading' })
6403
+ const native = window.NativeUpdate
6404
+ if (CAP?.isNativePlatform?.() && native?.downloadVerifiedAndInstall && native.getDownloadStatus) {
6405
+ const started = official ? native.downloadOfficialRelease(info.version, sha256) : native.downloadVerifiedAndInstall(url, sha256)
6406
+ if (!started) throw new Error(t('update.busy'))
6407
+ let usingOfficial = official
6305
6408
  nativePending=true
6306
6409
  const poll = () => {
6307
6410
  try {
6308
- const value = JSON.parse(window.NativeUpdate.getDownloadStatus())
6309
- updateDownloadProgress(value)
6310
- if (['complete', 'error'].includes(value.phase)) finishUpdateDownload()
6411
+ const value = JSON.parse(native.getDownloadStatus())
6412
+ if (value.phase === 'error' && value.code === 'unavailable' && !force && !usingOfficial
6413
+ && connection.valid() && /^\d+\.\d+\.\d+$/.test(info.version) && native.downloadOfficialRelease) {
6414
+ // The host and GitHub may serve different builds with the same version.
6415
+ if (native.downloadOfficialRelease(info.version, sha256)) {
6416
+ usingOfficial = true
6417
+ updateDownloadProgress({ phase: 'official' })
6418
+ return
6419
+ }
6420
+ }
6421
+ if (usingOfficial && value.phase === 'downloading') value.phase = 'official'
6422
+ updateDownloadProgress({ ...value, patch: force })
6423
+ if (['complete', 'installer', 'error'].includes(value.phase)) finishUpdateDownload()
6311
6424
  } catch (error) { updateDownloadProgress({ phase: 'error', error: error.message }); finishUpdateDownload() }
6312
6425
  }
6313
6426
  updateDownloadTimer = setInterval(poll, 500)
6314
6427
  poll()
6315
6428
  return
6316
6429
  }
6430
+ if (official) throw new Error(t('update.officialUnavailable'))
6317
6431
  const result = await verifyUpdateApk(info, url)
6318
6432
  if(!connection.valid())return
6319
6433
  if (!result.ok) throw new Error(result.corrupted ? t(force===true?'update.patchMismatch':'update.corrupted') : result.status ? t('update.serverFileMissing') : result.msg || t('fs.networkError'))
@@ -7204,6 +7318,7 @@ async function openModelConfigDocument() {
7204
7318
  }
7205
7319
  /* ---------------- 视图切换 ---------------- */
7206
7320
  function showView(id, pluginRoute = 'manage') {
7321
+ window.DshSlashSuggestions?.close()
7207
7322
  window.DshExtensions?.closeShortcuts()
7208
7323
  if (id !== 'view-session') window.DshSubagents?.close()
7209
7324
  document.body?.classList.toggle('viewing-subagent', id === 'view-session' && state.byId.get(state.current)?.origin === 'subagent')
@@ -7411,6 +7526,17 @@ function applyPairUrl(url, options = {}) {
7411
7526
  renderServers()
7412
7527
  $('token-desc').textContent = t('token.savedScan')
7413
7528
  syncBgConfig()
7529
+ const setupId = u.searchParams.get('relaySetup')
7530
+ if (/^[a-f0-9]{32}$/.test(setupId || '') && window.NativeE2ee?.configure) {
7531
+ relaySetup = { id: setupId, token: tok, servers }
7532
+ showView('view-settings')
7533
+ showSettingsPage('servers')
7534
+ requestAnimationFrame(() => {
7535
+ $('relay-phone-pairing')?.scrollIntoView({ block: 'start' })
7536
+ const connection = captureConnection()
7537
+ if (relaySetupFor(connection) === setupId) void offerLocalRelayPairing(connection)
7538
+ })
7539
+ }
7414
7540
  return true
7415
7541
  } catch {
7416
7542
  return false
@@ -7975,7 +8101,8 @@ const THEME_META = [
7975
8101
  { id: 'bocchi', sw: ['#FFD9E8', '#FFFFFF', '#D0105A'] },
7976
8102
  { id: 'nijika', sw: ['#FFF3D5', '#FFFFFF', '#94600C'] },
7977
8103
  { id: 'ryo', sw: ['#E9F1FA', '#FFFFFF', '#315D91'] },
7978
- { id: 'kita', sw: ['#FFE9E5', '#FFFFFF', '#B6373C'] }
8104
+ { id: 'kita', sw: ['#FFE9E5', '#FFFFFF', '#B6373C'] },
8105
+ { id: 'penguin-logistics', sw: ['#12161B', '#1D252E', '#E9B66F'] }
7979
8106
  ]
7980
8107
 
7981
8108
  function renderThemeBtn() {
@@ -8264,11 +8391,25 @@ function bindUi() {
8264
8391
  $('btn-model-refresh').addEventListener('click', loadSessionModels)
8265
8392
  const input = $('composer-input')
8266
8393
  input.addEventListener('input', () => autosize(input))
8394
+ window.DshSlashSuggestions?.mount({
8395
+ input, t,
8396
+ panel: $('composer-command-list'), chipClass: 'menu-chip', chipAttribute: 'data-cmd',
8397
+ context() {
8398
+ const connection = captureConnection(), sessionId = state.current, history = state.history
8399
+ if (!sessionId || state.byId.get(sessionId)?.origin === 'subagent') return null
8400
+ return {
8401
+ sessionId, url: path => connection.server + path,
8402
+ headers: { authorization: 'Bearer ' + connection.token, ...clientIdHeaders() },
8403
+ valid: () => connection.valid() && state.current === sessionId && state.history === history,
8404
+ }
8405
+ },
8406
+ readSkills: sessionId => rpc('skills.list', { sessionId }, 5000),
8407
+ })
8267
8408
  $('btn-fs-toggle').addEventListener('click', () => setComposerFullscreen(!$('composer-wrap').classList.contains('fs')))
8268
8409
  bindComposerFullscreenGesture()
8269
8410
  updateComposerFullscreenButton()
8270
8411
  input.addEventListener('keydown', (e) => {
8271
- if (e.key !== 'Enter' || e.isComposing) return
8412
+ if (e.defaultPrevented || e.key !== 'Enter' || e.isComposing) return
8272
8413
  if (isMobileDevice() && mobileEnterAction() !== 'send') return
8273
8414
  if (!e.shiftKey) { e.preventDefault(); sendMessage() }
8274
8415
  })
@@ -8591,8 +8732,9 @@ function mountWorkflow() {
8591
8732
  },
8592
8733
  command: runSlashCommand, refresh: refreshAll, retry: () => { startOverviewDetection(true); void refreshAll() },
8593
8734
  operations: () => { const connection=captureConnection(); return { url:apiUrl,headers:{authorization:'Bearer '+connection.token},valid:connection.valid } },
8594
- relay: () => { const connection=captureConnection(); return { url:()=>adminApiUrl('/admin/api/relay'),headers:{authorization:'Bearer '+connection.token},valid:connection.valid,connected:!!connection.token } },
8735
+ relay: () => { const connection=captureConnection(); return { url:()=>adminApiUrl('/admin/api/relay'),headers:{authorization:'Bearer '+connection.token},valid:connection.valid,connected:!!connection.token,setupId:relaySetupFor(connection) } },
8595
8736
  e2eeAutoPaired: saveAutoPairedRelay,
8737
+ e2eeScan: () => scanPair('CAMERA'),
8596
8738
  e2eeConnect: (origin, connection) => {
8597
8739
  if (!connection.valid()) return
8598
8740
  const token = connection.headers.authorization.slice(7)
package/public/build.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schema": 1,
3
- "version": "0.8.6",
4
- "buildId": "d76fba47d9b6c34d9a5d32c0e87d24222e6845b382ba95f08151758c5325a3b6"
3
+ "version": "0.8.8",
4
+ "buildId": "84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"
5
5
  }