dsh-remote-plugin 0.8.0-rc.3 → 0.8.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,10 +4,11 @@ window.DshExtensions = (() => {
4
4
  let current, cache
5
5
  const catalog = [
6
6
  { id: 'skills', name: '@linxin666/dsh-client-ui-skill-explorer', label: '打开技能中心' },
7
+ { id: 'teams', name: '@nanmicoder/dsh-agent-teams', label: '查看智能体团队' },
7
8
  { id: 'cost', name: 'dsh-cost-meter', label: '查看费用与额度' },
8
9
  { id: 'context', name: 'dsh-context', label: '查看当前会话上下文', session: true },
9
10
  ]
10
- const empty = () => ({ known: false, skills: false, cost: false, context: false })
11
+ const empty = () => ({ known: false, skills: false, cost: false, context: false, teams: false })
11
12
  function capabilitiesOf(snapshot) {
12
13
  if (snapshot?.ok !== true || !Array.isArray(snapshot.items) || !Array.isArray(snapshot.runtime)) return empty()
13
14
  const result = { ...empty(), known: true }
@@ -64,7 +65,7 @@ window.DshExtensions = (() => {
64
65
  return record.task
65
66
  }
66
67
  const node=(tag,text,cls)=>{const el=document.createElement(tag);if(text!=null)el.textContent=text;if(cls)el.className=cls;return el}
67
- const stopViews=()=>{window.DshSkillsCenter?.close();window.DshInsights?.close()}
68
+ const stopViews=()=>{window.DshSkillsCenter?.close();window.DshInsights?.close();window.DshTeams?.close()}
68
69
  function close(){if(current){const old=current;current=null;stopViews();window.DshPluginCenter?.close();old.target.replaceChildren()}}
69
70
  function mount(config,target,initial='manage') {
70
71
  close()
@@ -90,6 +91,7 @@ window.DshExtensions = (() => {
90
91
  if(!s.mounted){s.mounted=true;await window.DshPluginCenter.mount({...config,onFeature:navigate},manager)}
91
92
  else {if(s.scroller)s.scroller.scrollTop=s.scroll;void window.DshPluginCenter.resume()}
92
93
  }else if(route==='skills')await window.DshSkillsCenter.mount(config,view,{dedicated:true})
94
+ else if(route==='teams')await window.DshTeams.mount(config,view)
93
95
  else window.DshInsights.mount({tab:'cost',hostOverview:true,allowedTabs:['cost'],connection:config.connection,url:config.url},view)
94
96
  if(valid()&&route!=='manage')config.scrollTop?.()
95
97
  }
package/public/history.js CHANGED
@@ -28,6 +28,8 @@
28
28
  this.more=document.createElement('button'); this.more.type='button'; this.more.className='history-page-control'; this.more.textContent=options.olderLabel()
29
29
  this.more.addEventListener('click',()=>this.older())
30
30
  this.empty=document.createElement('div'); this.empty.className='history-empty'
31
+ this.retry=document.createElement('button');this.retry.type='button';this.retry.className='history-page-control';this.retry.textContent=options.retryLabel?.()||'Retry'
32
+ this.retry.addEventListener('click',()=>options.retry?.())
31
33
  this.live=document.createElement('div'); this.live.className='history-live'
32
34
  box.addEventListener('toggle',event=>{const detail=event.target;if(detail?.dataset?.activityKey)this.rememberDisclosure(detail)},true)
33
35
  const intent=()=>{this.intentUntil=Date.now()+1200}
@@ -62,7 +64,7 @@
62
64
  this.pendingLive=live
63
65
  // Reading is explicit user intent. A stream update never changes it by proximity.
64
66
  if(this.reading&&!reset)live=this.liveHtml||''
65
- if(!reset&&entries.length===this.entries.length&&entries.every((entry,i)=>entry===this.entries[i])&&hasMore===this.hasMore&&loading===this.loading&&(this.end===entries.length?live:'')===this.liveHtml){this.more.disabled=loading;this.more.textContent=loading?this.options.loadingLabel():this.options.olderLabel();this.domChanged=false;this.options.changed?.(this);return}
67
+ if(!reset&&!this.renderErrors&&entries.length===this.entries.length&&entries.every((entry,i)=>entry===this.entries[i])&&hasMore===this.hasMore&&loading===this.loading&&(this.end===entries.length?live:'')===this.liveHtml){this.more.disabled=loading;this.more.textContent=loading?this.options.loadingLabel():this.options.olderLabel();this.domChanged=false;this.options.changed?.(this);return}
66
68
  const oldWidth=this.end-this.start
67
69
  const anchor=this.anchor(), oldStart=this.entries[this.start]?.seq, oldEnd=this.entries[Math.max(this.start,this.end-1)]?.seq
68
70
  this.entries=entries.slice(); this.hasMore=hasMore; this.loading=loading
@@ -74,7 +76,7 @@
74
76
  this.start=Math.max(0,start-(this.pendingOlder?WINDOW_STEP:0));this.end=Math.min(entries.length,Math.max(this.start+1,end+1,this.start+Math.min(WINDOW_SIZE,oldWidth)))
75
77
  }
76
78
  this.previousLength=entries.length
77
- this.empty.textContent=emptyLabel
79
+ this.emptyLabel=emptyLabel
78
80
  this.more.textContent=loading?this.options.loadingLabel():this.options.olderLabel();this.more.disabled=loading;this.more.hidden=this.start===0&&!hasMore
79
81
  this.liveHtml=this.reading&&!reset ? this.liveHtml||'' : this.end===entries.length?live:''
80
82
  this.render(anchor,reset || (!this.reading && this.end===entries.length))
@@ -93,22 +95,27 @@
93
95
  const rangeKey=this.start+':'+this.end
94
96
  let changed=rangeKey!==this.lastRange || this.live.innerHTML!==this.liveHtml
95
97
  this.lastRange=rangeKey
98
+ this.renderErrors=0
96
99
  for(const entry of slice) {
97
100
  // Hidden events render an empty string; keeping their node would leave dead gaps.
98
- const html=this.options.html(entry)
99
- if(!html){if(this.nodes.delete(entry.seq))changed=true;continue}
100
- const key=signature(entry);let cached=this.nodes.get(entry.seq)
101
- if(!cached || cached.key!==key){changed=true;const node=document.createElement('div');node.className='history-entry';node.dataset.historySeq=String(entry.seq);node.innerHTML=html;this.restoreDisclosures(node);cached={key,node};this.nodes.set(entry.seq,cached)}
101
+ let html,key,failed=false
102
+ try{html=this.options.html(entry);key=signature(entry)}catch(error){failed=true;this.renderErrors++;key='render-error';globalThis.DshDiagnostics?.record('history.row',{phase:'failed',...globalThis.DshDiagnostics.errorFacts(error),category:'render'})}
103
+ if(!html&&!failed){if(this.nodes.delete(entry.seq))changed=true;continue}
104
+ let cached=this.nodes.get(entry.seq)
105
+ if(!cached || cached.key!==key){changed=true;const node=document.createElement('div');node.className='history-entry';node.dataset.historySeq=String(entry.seq);if(failed)node.textContent=this.options.errorLabel?.()||'This message could not be displayed. Retry loading history.';else{node.innerHTML=html;this.restoreDisclosures(node)}cached={key,node};this.nodes.set(entry.seq,cached)}
102
106
  desired.push(cached.node)
103
107
  }
104
108
  this.more.hidden=this.start===0&&!this.hasMore
105
109
  const keep=new Set(desired)
106
110
  this.suppress=true
107
- for(const child of [...box.children])if(child!==this.more && child!==this.live && child!==this.empty && !keep.has(child))child.remove()
111
+ for(const child of [...box.children])if(child!==this.more && child!==this.live && child!==this.empty && child!==this.retry && !keep.has(child))child.remove()
108
112
  if(this.more.parentNode!==box)box.prepend(this.more)
109
113
  let cursor=this.more.nextSibling
110
114
  for(const node of desired){if(node===cursor)cursor=cursor.nextSibling;else box.insertBefore(node,cursor)}
111
- if(!slice.length && !this.liveHtml){if(this.empty.parentNode!==box)box.append(this.empty)}else this.empty.remove()
115
+ const empty=!desired.length&&!this.liveHtml, unreadable=empty&&slice.length>0
116
+ this.empty.textContent=unreadable?(this.options.unreadableLabel?.()||this.emptyLabel):this.emptyLabel
117
+ if(empty){if(this.empty.parentNode!==box)box.append(this.empty)}else this.empty.remove()
118
+ if((unreadable||this.renderErrors)&&this.options.retry){if(this.retry.parentNode!==box)box.append(this.retry)}else this.retry.remove()
112
119
  if(this.live.innerHTML!==this.liveHtml){this.live.innerHTML=this.liveHtml;this.restoreDisclosures(this.live)}
113
120
  if(this.live.parentNode!==box)box.append(this.live)
114
121
  if(bottom)box.scrollTop=box.scrollHeight
package/public/index.html CHANGED
@@ -445,7 +445,8 @@
445
445
  <label class="switch"><input type="checkbox" id="opt-notify"><span class="slider"></span></label>
446
446
  </div>
447
447
  <div class="setting-row">
448
- <div><div class="setting-name" data-i18n="settings.peakRemindTitle">峰谷计费提醒 · dsh-cost-meter</div><div class="setting-desc" data-i18n="settings.peakRemindDesc">由 dsh-cost-meter 统一管理,请在 DSH「设置 → 费用 → 峰谷计价」配置。提醒由 DSH 页面触发,Remote 不再独立后台计时。</div></div>
448
+ <div><div class="setting-name" data-i18n="settings.peakRemindTitle">峰谷计费提醒 · dsh-cost-meter</div><div class="setting-desc" data-i18n="settings.peakRemindDesc">按费用插件的峰谷窗口、节假日、提前量与提醒类型发送 Android 通知。无需保持 DSH 页面打开;请允许通知并将系统省电设为无限制。</div><div id="peak-remind-status" class="setting-desc" role="status"></div></div>
449
+ <label class="switch"><input type="checkbox" id="opt-peak-remind" aria-label="峰谷计费提醒 · dsh-cost-meter"><span class="slider"></span></label>
449
450
  </div>
450
451
  <div class="setting-row">
451
452
  <div><div class="setting-name" data-i18n="settings.testNotifyTitle">测试通知</div><div class="setting-desc" data-i18n="settings.testNotifyDesc">立即排一条 3 秒后的本地通知,用于排查系统通知限制</div></div>
@@ -652,6 +653,12 @@
652
653
  <input id="fb-contact" class="fb-input" maxlength="200" data-i18n-placeholder="feedback.contactPlaceholder" placeholder="联系方式(可选):邮箱 / 微信 / B站 ID">
653
654
  <label class="fb-diagnostics"><input id="fb-include-diagnostics" type="checkbox"> <span data-i18n="feedback.includeDiagnostics">附带兼容性诊断日志(可选)</span><small data-i18n="feedback.diagnosticsPrivacy">仅上传网关/协议版本、接口失败摘要和实时链路状态;不包含令牌、Cookie、对话内容或文件路径。</small></label>
654
655
  <label class="fb-diagnostics"><input id="fb-include-crashes" type="checkbox"> <span data-i18n="feedback.includeCrashes">附带崩溃日志摘要(可选)</span><small data-i18n="feedback.crashPrivacy">默认仅在本机记录。勾选后上传最近 3 条退出、重启和错误位置摘要,不含对话、密钥或完整路径。</small></label>
656
+ <section class="client-diagnostics" aria-label="操作诊断日志">
657
+ <p data-log-label="privacy">操作日志仅保存在此设备,记录操作阶段、耗时、错误位置与连接状态。可复制或导出后自行反馈。</p>
658
+ <details id="fb-client-log-details"><summary data-log-label="details">查看操作诊断日志</summary><pre id="fb-client-log-preview"></pre></details>
659
+ <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>
660
+ <p id="fb-client-log-status" role="status" aria-live="polite"></p>
661
+ </section>
655
662
  <details id="fb-crash-details" class="crash-preview"><summary data-i18n="feedback.crashPreview">查看拟上传的日志摘要</summary><pre id="fb-crash-preview"></pre></details>
656
663
  </div>
657
664
  <div class="modal-actions">
@@ -901,7 +908,7 @@
901
908
  <div id="announcement-content" class="modal-body announcement-content"></div>
902
909
  <div id="announcement-poll" class="announcement-poll hidden">
903
910
  <div id="announcement-poll-question" class="announcement-poll-question"></div>
904
- <div id="announcement-poll-options" class="announcement-poll-options" role="radiogroup"></div>
911
+ <div id="announcement-poll-options" class="announcement-poll-options"></div>
905
912
  <div id="announcement-poll-status" class="announcement-poll-status hidden"></div>
906
913
  <button id="announcement-poll-submit" class="btn primary" type="button" data-i18n="announcement.voteSubmit">提交投票</button>
907
914
  </div>
@@ -1000,6 +1007,7 @@
1000
1007
  'session.confirmStop': '停止当前回合?排队中的消息不会被删除。', 'session.stopFailed': '停止失败', 'session.stopRequested': '已请求停止本轮', 'session.archive': '归档', 'session.archiveConfirm': '归档这个会话?归档后可在“显示已归档会话”中打开。', 'session.archiveFailed': '归档失败:{msg}', 'session.archived': '会话已归档', 'session.archiveTitle': '确认归档会话', 'session.archiveDesc': '归档后会话将从普通列表隐藏,但不会删除对话记录。', 'session.archiveConversation': '对话', 'session.archiveWorkspace': '工作区', 'session.archiveCancel': '取消', 'session.archiveConfirmAction': '确认归档', 'session.rename': '重命名会话', 'session.renameTitle': '重命名会话', 'session.renamePlaceholder': '输入新的会话名称', 'session.renameCancel': '取消', 'session.renameConfirm': '保存', 'session.renameEmpty': '会话名称不能为空', 'session.renameFailed': '重命名失败', 'session.renamed': '会话名称已更新',
1001
1008
  'notify.approvalTitle': '工具审批', 'notify.approvalBody': '{tool} 需要批准', 'notify.questionTitle': 'DSH 提问', 'notify.questionBody': '需要你回答',
1002
1009
  'notify.permissionFailed': '通知权限申请失败:{msg}', 'notify.hostUnavailable': '此通知所属服务器已移除或令牌已变更,请重新连接后查看待处理事项',
1010
+ 'history.renderFailed': '部分记录显示失败,请重试',
1003
1011
  'history.cached': '本地缓存', 'history.syncing': '本地缓存 · 正在同步', 'history.synced': '最新记录已同步', 'history.saved': '最新记录 · 已缓存', 'history.offline': '本地记录 · 网络不可用', 'history.earlier': '加载更早的记录', 'history.loadingEarlier': '正在加载更早的记录…', 'history.latest': '回到最新', 'history.cacheFailed': '已同步 · 本地缓存未保存', 'history.loading': '加载历史…', 'history.cacheFallback': '网络不可用:显示本地缓存的历史', 'history.loadFailed': '加载历史失败:{msg}', 'history.retry': '重试',
1004
1012
  'history.offlineCache': '离线缓存 {n} 条', 'history.count': '{n} 条', 'history.empty': '还没有消息',
1005
1013
  'history.queueAndCount': '队列 {q} · 历史 {n}', 'history.countOnly': '历史 {n}',
@@ -1113,7 +1121,7 @@
1113
1121
  'settings.notifyTitle': '通知', 'settings.notifyDesc': '收到审批/提问时推送', 'settings.announcementHistoryTitle': '历史公告', 'settings.announcementHistoryDesc': '查看以前收到的公告', 'settings.announcementHistory': '查看记录',
1114
1122
  'settings.testNotifyTitle': '测试通知', 'settings.testNotifyDesc': '立即排一条 3 秒后的本地通知,用于排查系统通知限制', 'settings.testNotify': '发送测试通知',
1115
1123
  'settings.testNotifySent': '测试通知已排定,3 秒后到达', 'settings.testNotifyFailed': '发送测试通知失败:{msg}', 'settings.testNotifyUnavailable': '测试通知仅在 App 内可用',
1116
- 'settings.peakRemindTitle': '峰谷计费提醒 · dsh-cost-meter', 'settings.peakRemindDesc': '由 dsh-cost-meter 统一管理,请在 DSH「设置 → 费用 → 峰谷计价」配置。提醒由 DSH 页面触发,Remote 不再独立后台计时。',
1124
+ 'settings.peakRemindTitle': '峰谷计费提醒 · dsh-cost-meter', 'settings.peakRemindDesc': '按费用插件的峰谷窗口、节假日、提前量与提醒类型发送 Android 通知。无需保持 DSH 页面打开;请允许通知并将系统省电设为无限制。',
1117
1125
  'peakRemind.enterPeak': '已进入高峰计费时段', 'peakRemind.enterOff': '已进入空闲计费时段',
1118
1126
  'peakRemind.peak0912': '高峰 9:00-12:00', 'peakRemind.off1214': '空闲 12:00-14:00',
1119
1127
  'peakRemind.peak1418': '高峰 14:00-18:00', 'peakRemind.off1809': '空闲 18:00-次日 9:00',
@@ -1139,6 +1147,8 @@
1139
1147
  'theme.default': '默认深空', 'theme.dark': '落日', 'theme.light': '易北爱乐厅', 'theme.neutral': '草原孤塔', 'theme.mono': '黑曜白',
1140
1148
  'theme.panelTitle': '选择配色', 'theme.close': '关闭',
1141
1149
  'settings.tokenTitle': '访问令牌', 'settings.change': '更换',
1150
+ 'settings.unknown': '未知', 'settings.dshRecovering': '正在等待网关恢复并核验操作结果…',
1151
+ 'settings.hostHealth': '{status} · HTTP {http} · mux {mux} / host {host} · 检查于 {time}',
1142
1152
  'settings.hostTitle': 'DSH 状态', 'settings.hostProbing': '探测中…', 'settings.probe': '探测', 'settings.probeFailed': '探测失败',
1143
1153
  'settings.dshControlTitle': '远程启动 DSH', 'settings.dshExperimental': 'Windows 实验性', 'settings.dshControlProbing': '正在向网关查询本机 DSH 服务…', 'settings.dshRunning': '运行中', 'settings.dshStopped': '已停止', 'settings.dshUnsupported': '当前系统未配置可控的 DSH 服务', 'settings.dshStart': '启动', 'settings.dshRestart': '重启', 'settings.dshStarting': '正在{action} DSH…', 'settings.dshStarted': 'DSH 已{action}', 'settings.dshFailed': 'DSH 操作失败:{msg}',
1144
1154
  'settings.dshRunningDetail': '运行中 · {service} · PID {pid} · {state}', 'settings.dshStoppedDetail': '已停止 · {service} · {state}', 'settings.dshStatusFailed': '服务状态查询失败:{msg}',
@@ -1245,6 +1255,7 @@
1245
1255
  'session.confirmStop': 'Stop the current turn? Queued messages will be kept.', 'session.stopFailed': 'Stop failed', 'session.stopRequested': 'Stop requested', 'session.archive': 'Archive', 'session.archiveConfirm': 'Archive this session? You can open it from “Show archived”.', 'session.archiveFailed': 'Archive failed: {msg}', 'session.archived': 'Session archived', 'session.archiveTitle': 'Confirm archive', 'session.archiveDesc': 'The session will be hidden from the normal list, but its conversation will not be deleted.', 'session.archiveConversation': 'Conversation', 'session.archiveWorkspace': 'Workspace', 'session.archiveCancel': 'Cancel', 'session.archiveConfirmAction': 'Archive session', 'session.rename': 'Rename session', 'session.renameTitle': 'Rename session', 'session.renamePlaceholder': 'Enter a new session name', 'session.renameCancel': 'Cancel', 'session.renameConfirm': 'Save', 'session.renameEmpty': 'Session name cannot be empty', 'session.renameFailed': 'Rename failed', 'session.renamed': 'Session name updated',
1246
1256
  'notify.approvalTitle': 'Tool approval', 'notify.approvalBody': '{tool} needs approval', 'notify.questionTitle': 'DSH question', 'notify.questionBody': 'Needs your answer',
1247
1257
  'notify.permissionFailed': 'Notification permission failed: {msg}', 'notify.hostUnavailable': 'This notification belongs to a removed server or changed credential. Reconnect to view pending requests.',
1258
+ 'history.renderFailed': 'Some records could not be displayed. Retry.',
1248
1259
  'history.cached': 'Local cache', 'history.syncing': 'Local cache · Syncing', 'history.synced': 'Latest history synced', 'history.saved': 'Latest history · Cached', 'history.offline': 'Local history · Offline', 'history.earlier': 'Load earlier history', 'history.loadingEarlier': 'Loading earlier history…', 'history.latest': 'Jump to latest', 'history.cacheFailed': 'Synced · Cache could not be saved', 'history.loading': 'Loading history…', 'history.cacheFallback': 'Network unavailable: showing cached history', 'history.loadFailed': 'Failed to load history: {msg}', 'history.retry': 'Retry',
1249
1260
  'history.offlineCache': 'Offline cache {n} items', 'history.count': '{n} items', 'history.empty': 'No messages yet',
1250
1261
  'history.queueAndCount': 'Queue {q} · History {n}', 'history.countOnly': 'History {n}',
@@ -1358,7 +1369,7 @@
1358
1369
  'settings.notifyTitle': 'Notifications', 'settings.notifyDesc': 'Push on approvals / questions', 'settings.announcementHistoryTitle': 'Announcement history', 'settings.announcementHistoryDesc': 'Review announcements you received before', 'settings.announcementHistory': 'View history',
1359
1370
  'settings.testNotifyTitle': 'Test notification', 'settings.testNotifyDesc': 'Schedule a local notification in 3 seconds to verify the notification pipeline', 'settings.testNotify': 'Send test notification',
1360
1371
  'settings.testNotifySent': 'Test notification scheduled, arriving in 3s', 'settings.testNotifyFailed': 'Failed to send test notification: {msg}', 'settings.testNotifyUnavailable': 'Test notification is only available in the app',
1361
- 'settings.peakRemindTitle': 'Peak/off-peak reminders · dsh-cost-meter', 'settings.peakRemindDesc': 'Managed by dsh-cost-meter. Configure in DSH Settings → Cost → Peak pricing. Alerts require the DSH page; Remote no longer runs a separate background timer.',
1372
+ 'settings.peakRemindTitle': 'Peak/off-peak reminders · dsh-cost-meter', 'settings.peakRemindDesc': 'Android notifications follow the plugin’s windows, holidays, lead time and reminder type. The DSH page can be closed. Allow notifications and unrestricted battery use.',
1362
1373
  'peakRemind.enterPeak': 'Peak pricing period started', 'peakRemind.enterOff': 'Off-peak pricing period started',
1363
1374
  'peakRemind.peak0912': 'Peak 9:00-12:00', 'peakRemind.off1214': 'Off-peak 12:00-14:00',
1364
1375
  'peakRemind.peak1418': 'Peak 14:00-18:00', 'peakRemind.off1809': 'Off-peak 18:00-9:00 next day',
@@ -1384,6 +1395,8 @@
1384
1395
  'theme.default': 'Default', 'theme.dark': 'Sunset', 'theme.light': 'Elbphilharmonie', 'theme.neutral': 'Prairie Tower', 'theme.mono': 'Monochrome',
1385
1396
  'theme.panelTitle': 'Choose theme', 'theme.close': 'Close',
1386
1397
  'settings.tokenTitle': 'Access token', 'settings.change': 'Change',
1398
+ 'settings.unknown': 'Unknown', 'settings.dshRecovering': 'Waiting for the gateway and verifying the operation…',
1399
+ 'settings.hostHealth': '{status} · HTTP {http} · mux {mux} / host {host} · Checked {time}',
1387
1400
  'settings.hostTitle': 'DSH status', 'settings.hostProbing': 'Probing…', 'settings.probe': 'Probe', 'settings.probeFailed': 'Probe failed',
1388
1401
  'settings.dshControlTitle': 'Remote DSH control', 'settings.dshExperimental': 'Windows experimental', 'settings.dshControlProbing': 'Querying the gateway for the local DSH service…', 'settings.dshRunning': 'Running', 'settings.dshStopped': 'Stopped', 'settings.dshUnsupported': 'No controllable DSH service is configured', 'settings.dshStart': 'Start', 'settings.dshRestart': 'Restart', 'settings.dshStarting': '{action}ing DSH…', 'settings.dshStarted': 'DSH {action}ed', 'settings.dshFailed': 'DSH operation failed: {msg}',
1389
1402
  'settings.dshRunningDetail': 'Running · {service} · PID {pid} · {state}', 'settings.dshStoppedDetail': 'Stopped · {service} · {state}', 'settings.dshStatusFailed': 'Service status query failed: {msg}',
@@ -1433,9 +1446,13 @@
1433
1446
  <script src="plugin-center.js"></script>
1434
1447
  <script src="skills.js"></script>
1435
1448
  <script src="insights.js"></script>
1449
+ <script src="teams.js"></script>
1436
1450
  <script src="extensions.js"></script>
1451
+ <script src="diagnostics.js"></script>
1437
1452
  <script src="history.js"></script>
1453
+ <script src="announcement-forms.js"></script>
1438
1454
  <script src="activity.js"></script>
1455
+ <script src="turn-results.js"></script>
1439
1456
  <script src="image-preview.js"></script>
1440
1457
  <script src="link-check.js"></script>
1441
1458
  <script src="network.js"></script>
package/public/network.js CHANGED
@@ -20,7 +20,7 @@
20
20
  function streamSetting(){try{return root.localStorage.getItem(STREAM_KEY)!=='0'}catch{return true}}
21
21
  function streamTrimmed(){return streamSetting()&&profile().weak}
22
22
  class PollLoop {
23
- constructor(options){this.options=options;this.jobs={};this.setTimer=options.setTimer||setTimeout;this.clearTimer=options.clearTimer||clearTimeout}
23
+ constructor(options){this.options=options;this.jobs={};this.setTimer=options.setTimer||((fn,ms)=>setTimeout(fn,ms));this.clearTimer=options.clearTimer||(timer=>clearTimeout(timer))}
24
24
  stop(){for(const job of Object.values(this.jobs)){job.controller.abort();this.clearTimer(job.timer)}this.jobs={}}
25
25
  tick(){
26
26
  if(!this.options.active()){this.stop();return Promise.resolve()}
@@ -1,7 +1,7 @@
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.create','session.prompt','session.updateQueue','session.selectModel',
4
+ const methods = new Set(['session.fork','session.create','session.prompt','session.updateQueue','session.selectModel',
5
5
  'session.rename','session.cancel','workspace.create','workspace.archiveSession',
6
6
  'goal.edit','goal.pause','goal.resume','goal.complete','goal.clear'])
7
7
  const pending = new Map()
@@ -0,0 +1,76 @@
1
+ /* AgentTeams view: reads only; scheduling remains owned by the host plugin. */
2
+ 'use strict';
3
+ ;(function(root) {
4
+ const esc = value => String(value ?? '').replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]))
5
+ const text = (zh, en) => root.I18N?.lang === 'en' ? en : zh
6
+ let current
7
+ function status(value) {
8
+ const names = { staged: ['待确认计划','Plan awaiting review'], running: ['运行中','Running'], working: ['工作中','Working'], idle: ['未运行','Idle'], unknown: ['未知','Unknown'],
9
+ open: ['待执行','Open'], blocked: ['受阻','Blocked'], completed: ['已完成','Completed'], failed: ['失败','Failed'], cancelled: ['已取消','Cancelled'], in_progress: ['执行中','In progress'], removed: ['已移除','Removed'] }
10
+ return names[value] ? text(...names[value]) : value || text('未知','Unknown')
11
+ }
12
+ function teamHtml(team, index, archived) {
13
+ const button = (label, member = '') => `<button type="button" data-team-open="${index}"${member ? ` data-team-member="${esc(member)}"` : ''}>${esc(label)}</button>`
14
+ const members = (team.members || []).map(member => `<li><div><strong>${esc(member.name)}</strong> · ${esc(status(member.activity))} · ${esc(status(member.status))}</div><p>${esc(member.role)}</p><small>${esc([member.provider,member.model].filter(Boolean).join('/'))} ${esc(member.currentTask)}</small>${!archived && member.id ? button(text('打开成员记录','Open member record'), member.id) : ''}</li>`).join('')
15
+ const tasks = (team.tasks || []).map(task => `<li><strong>${esc(task.id)} · ${esc(task.subject)}</strong><span class="teams-state">${esc(status(task.state || task.status))}</span><p>${esc(task.description)}</p><small>${esc(text('负责人','Assignee'))}:${esc(task.assignee || '—')} · ${esc(text('依赖','Depends on'))}:${esc((task.dependencies || []).join(', ') || '—')}</small>${task.verdictStale ? `<p class="teams-error">${esc(task.verdictStale)}</p>` : ''}</li>`).join('')
16
+ const delivery = team.deliverable === true && team.delivery?.ok === true ? text('插件报告可交付','Plugin reports deliverable') : text('交付尚未确认','Delivery not confirmed')
17
+ return `<article class="teams-card"><header><h3>${esc(team.name)}</h3><span>${esc(archived ? text('已归档','Archived') : team.halted ? text('已暂停调度','Scheduling halted') : status(team.phase))}</span></header><p>${esc(team.description)}</p><p>${esc(delivery)}</p>${team.delivery?.blockers?.length ? `<ul>${team.delivery.blockers.map(v => `<li>${esc(v)}</li>`).join('')}</ul>` : ''}${button(text('打开队长会话','Open captain session'))}<details open data-team-detail="members:${esc(team.teamId)}"><summary>${esc(text('成员','Members'))} · ${(team.members || []).length}${team.membersTruncated ? '+' : ''}</summary><ul>${members || `<li>${esc(text('暂无成员','No members'))}</li>`}</ul></details><details data-team-detail="tasks:${esc(team.teamId)}"><summary>${esc(text('任务与依赖','Tasks and dependencies'))} · ${(team.tasks || []).length}${team.tasksTruncated ? '+' : ''}</summary><ul>${tasks || `<li>${esc(text('暂无任务','No tasks'))}</li>`}</ul></details><details data-team-detail="messages:${esc(team.teamId)}"><summary>${esc(text('队长未读消息预览','Unread captain messages'))} · ${team.messageCount ?? '—'}</summary>${(team.captainInbox || []).map(row => `<p><strong>${esc(row.from)}</strong>:${esc(row.content)}</p>`).join('') || `<p>${esc(text('暂无预览消息','No message previews'))}</p>`}</details></article>`
18
+ }
19
+ function close() { if (current) { current.controller.abort(); clearInterval(current.timer); current = null } }
20
+ async function mount(config, target) {
21
+ close()
22
+ const s = { config, target, controller: new AbortController(), request: 0, data: null, workspaceId: '', archived: false, expanded: new Map() }
23
+ current = s
24
+ const valid = () => current === s && config.valid()
25
+ const workspaces = (config.getWorkspaces?.() || []).filter(w => w?.workspaceId)
26
+ s.workspaceId = workspaces.some(w => w.workspaceId === config.getWorkspaceId?.()) ? config.getWorkspaceId() : workspaces[0]?.workspaceId || ''
27
+ target.innerHTML = `<section class="teams-page"><h2>${esc(text('智能体团队','Agent teams'))}</h2><p>${esc(text('查看当前工作区的团队、成员、任务依赖与消息。','Teams, members, dependencies and messages in the selected workspace.'))}</p><div class="teams-controls"><label>${esc(text('工作区','Workspace'))}<select data-teams-workspace>${workspaces.map(w => `<option value="${esc(w.workspaceId)}">${esc(w.title || w.path || w.workspaceId)}</option>`).join('')}</select></label><label><input type="checkbox" data-teams-archived> ${esc(text('查看归档团队','Archived teams'))}</label><button type="button" data-teams-refresh>${esc(text('刷新','Refresh'))}</button></div><p data-teams-status role="status" aria-live="polite"></p><div data-teams-content></div></section>`
28
+ const selector = target.querySelector('[data-teams-workspace]'), content = target.querySelector('[data-teams-content]'), note = target.querySelector('[data-teams-status]')
29
+ selector.value = s.workspaceId
30
+ function render(data) {
31
+ for (const detail of content.querySelectorAll('details[data-team-detail]')) s.expanded.set(detail.dataset.teamDetail, detail.open)
32
+ content.innerHTML = data.teams.length ? data.teams.map((team, index) => teamHtml(team, index, s.archived)).join('') : `<p>${esc(text('此工作区暂无团队。','No teams in this workspace.'))}</p>`
33
+ for (const detail of content.querySelectorAll('details[data-team-detail]')) if (s.expanded.has(detail.dataset.teamDetail)) detail.open = s.expanded.get(detail.dataset.teamDetail)
34
+ }
35
+ async function load(clear = false) {
36
+ if (!valid()) { if (current === s) close(); return }
37
+ s.readController?.abort()
38
+ s.readController = new AbortController()
39
+ const request = ++s.request
40
+ if (clear) { s.data = null; s.expanded.clear(); content.replaceChildren() }
41
+ if (!s.workspaceId) { note.textContent = text('请先登记一个 DSH 工作区。','Register a DSH workspace first.'); return }
42
+ note.textContent = text('正在读取团队…','Loading teams…')
43
+ try {
44
+ const response = await fetch(config.url('/remote/api/teams?workspaceId=' + encodeURIComponent(s.workspaceId) + '&archived=' + (s.archived ? '1' : '0')), { headers: config.headers, signal: AbortSignal.any([s.controller.signal, s.readController.signal, AbortSignal.timeout(20000)]) })
45
+ const body = await response.text()
46
+ if (!valid() || request !== s.request) return
47
+ if (body.length > 2 * 1024 * 1024) throw Error('large')
48
+ const data = JSON.parse(body)
49
+ if (!response.ok || data.ok !== true || data.schema !== 1 || data.available !== false && (!Array.isArray(data.teams) || data.workspaceId !== s.workspaceId)) throw Error('schema')
50
+ if (data.available === false) { s.data = null; content.replaceChildren(); note.textContent = text('主机未提供兼容的智能体团队接口。','No compatible AgentTeams endpoint on this host.'); return }
51
+ render(data); s.data = data
52
+ note.textContent = data.truncated ? text('团队较多,仅显示前 40 个。','Showing the first 40 teams.') : text('已更新','Updated')
53
+ } catch {
54
+ if (valid() && request === s.request) note.textContent = s.data ? text('刷新失败,保留上次结果,可重试。','Refresh failed. Showing the previous result; retry is available.') : text('读取失败,请检查插件状态后重试。','Unable to load. Check plugin status and retry.')
55
+ }
56
+ }
57
+ selector.addEventListener('change', () => { s.workspaceId = selector.value; void load(true) })
58
+ target.querySelector('[data-teams-archived]').addEventListener('change', event => { s.archived = event.target.checked; void load(true) })
59
+ target.querySelector('[data-teams-refresh]').addEventListener('click', () => void load())
60
+ content.addEventListener('click', async event => {
61
+ const button = event.target.closest?.('[data-team-open]')
62
+ if (!button || !valid() || !s.data) return
63
+ const team = s.data.teams[Number(button.dataset.teamOpen)], member = button.dataset.teamMember
64
+ if (!team || !team.captainSessionId) return
65
+ button.disabled = true
66
+ try { if (member) await config.openTeamMember?.(member, team.captainSessionId); else await config.openTeamCaptain?.(team.captainSessionId) }
67
+ catch { if (valid()) note.textContent = text('会话暂不可读,请刷新后重试。','Session unavailable. Refresh and retry.') }
68
+ finally { if (valid()) button.disabled = false }
69
+ })
70
+ s.timer = setInterval(() => { if (!document.hidden) void load() }, 15000)
71
+ await load()
72
+ }
73
+ const api = { mount, close, teamHtml }
74
+ root.DshTeams = api
75
+ if (typeof module !== 'undefined' && module.exports) module.exports = api
76
+ })(typeof window === 'undefined' ? globalThis : window)
@@ -0,0 +1,119 @@
1
+ /* Completed-turn actions derived from durable events. No dependencies. */
2
+ 'use strict';
3
+ ;(function(root) {
4
+ const esc = value => String(value ?? '').replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]))
5
+ const text = (zh, en) => root.I18N?.lang === 'en' ? en : zh
6
+ const keys = ['inputTokens', 'outputTokens', 'cacheReadTokens', 'cacheWriteTokens']
7
+ const count = n => typeof n === 'number' && Number.isFinite(n) && n >= 0
8
+ function messageText(event) {
9
+ const data = event.data || {}, blocks = data.message?.content ?? data.content
10
+ if (Array.isArray(blocks)) return blocks.filter(b => b?.type === 'text').map(b => String(b.text ?? '')).join('\n\n').trim()
11
+ return typeof data.text === 'string' ? data.text.trim() : ''
12
+ }
13
+ function summarize(entries, sessionId) {
14
+ const results = new Map(), seen = new Set()
15
+ let turn = null
16
+ const fresh = (id, started = false) => ({ id, started, messages: 0, missing: false, samples: 0, total: 0, usage: Object.fromEntries(keys.map(k => [k, 0])), text: '' })
17
+ for (const entry of entries) {
18
+ const event = entry.event || {}, data = event.data || {}, id = data.turn
19
+ if (!Number.isSafeInteger(entry.seq) || seen.has(entry.seq)) continue
20
+ seen.add(entry.seq)
21
+ if (event.type === 'turn/start') { turn = fresh(id, true); continue }
22
+ if (event.type === 'user/message') {
23
+ const source = data.source ?? data.message?.source
24
+ if ((!source || source.kind === 'user') && (!turn || !turn.started)) turn = fresh(id)
25
+ }
26
+ if (event.type === 'assistant/message') {
27
+ if (!turn || id != null && turn.id != null && id !== turn.id) turn = fresh(id)
28
+ if (turn.id == null) turn.id = id
29
+ turn.messages++
30
+ const body = messageText(event)
31
+ if (body) turn.text = body
32
+ const u = data.usage
33
+ if (u && (count(u.totalTokens) || count(u.inputTokens) && count(u.outputTokens))) {
34
+ for (const k of keys) if (count(u[k])) turn.usage[k] += u[k]
35
+ // DSH counters are disjoint. Reasoning is already included in output.
36
+ turn.total += count(u.totalTokens) ? u.totalTokens : keys.reduce((n, k) => n + (count(u[k]) ? u[k] : 0), 0)
37
+ turn.samples++
38
+ } else turn.missing = true
39
+ }
40
+ if (event.type !== 'turn/end') continue
41
+ if (turn?.messages && (id == null || turn.id == null || id === turn.id)) {
42
+ const time = typeof event.time === 'number' ? event.time : Date.parse(event.time)
43
+ results.set(entry.seq, { sessionId, atSeq: entry.seq, text: turn.text,
44
+ time: Number.isFinite(time) && time > 0 ? time : null,
45
+ total: turn.samples ? turn.total : null, usage: turn.usage,
46
+ partial: !turn.started || turn.missing })
47
+ }
48
+ turn = null
49
+ }
50
+ return results
51
+ }
52
+ function decorate(prepared, entries, options = {}) {
53
+ const results = summarize(entries, options.sessionId)
54
+ return prepared.map(entry => results.has(entry.seq) && entry.event?.type === 'turn/end'
55
+ ? { ...entry, view: { ...entry.view, turnResult: { ...results.get(entry.seq), canFork: options.canFork === true } } }
56
+ : entry)
57
+ }
58
+ const paths = {
59
+ copy: '<rect x="8" y="8" width="12" height="13" rx="2"/><path d="M16 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3"/>',
60
+ fork: '<circle cx="6" cy="12" r="3"/><circle cx="18" cy="5" r="3"/><circle cx="18" cy="19" r="3"/><path d="m9 11 6-4m-6 6 6 4"/>',
61
+ usage: '<ellipse cx="12" cy="5" rx="8" ry="3"/><path d="M4 5v14c0 4 16 4 16 0V5M4 12c0 4 16 4 16 0"/>'
62
+ }
63
+ const icon = name => `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${paths[name]}</svg>`
64
+ function formatTokens(n) {
65
+ for (const [size, suffix] of [[1e9, 'B'], [1e6, 'M'], [1e3, 'K']]) if (n >= size) return (n / size).toFixed(1).replace(/\.0$/, '') + suffix
66
+ return String(n)
67
+ }
68
+ function html(result) {
69
+ const button = (action, label, disabled = false) => `<button type="button" data-turn-action="${action}" title="${esc(label)}" aria-label="${esc(label)}"${disabled ? ' disabled' : ''}>${icon(action)}<span>${esc(label)}</span></button>`
70
+ const total = result.total == null ? '—' : formatTokens(result.total) + ' tok'
71
+ const label = text(result.partial && result.total != null ? '已知用量' : '用量', result.partial && result.total != null ? 'Known usage' : 'Usage')
72
+ const u = result.usage
73
+ const detail = result.total == null ? text('主机未提供该回合的用量。', 'The host did not report usage for this turn.')
74
+ : `${text('输入', 'Input')} ${u.inputTokens} · ${text('输出', 'Output')} ${u.outputTokens} · ${text('缓存读取', 'Cache read')} ${u.cacheReadTokens} · ${text('缓存写入', 'Cache write')} ${u.cacheWriteTokens} · ${text('合计', 'Total')} ${result.total}` + (result.partial ? text('(记录未加载完整或部分调用未报告用量)', ' (history incomplete or some calls did not report usage)') : '')
75
+ const date = result.time == null ? null : new Date(result.time)
76
+ const stamp = date ? date.toLocaleString(root.I18N?.lang === 'en' ? 'en-US' : 'zh-CN', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hour12: false }) : text('时间未知', 'Time unavailable')
77
+ const labels = [text('输入', 'Input'), text('输出', 'Output'), text('缓存读取', 'Cache read'), text('缓存写入', 'Cache write')]
78
+ const breakdown = result.total == null ? `<p>${esc(detail)}</p>` : `<dl>${keys.map((key, index) => `<div><dt>${esc(labels[index])}</dt><dd>${u[key].toLocaleString()} tok</dd></div>`).join('')}<div><dt>${esc(text('合计', 'Total'))}</dt><dd>${result.total.toLocaleString()} tok</dd></div></dl>${result.partial ? `<p>${esc(text('记录未加载完整,或部分调用未报告用量。', 'History is incomplete, or some calls did not report usage.'))}</p>` : ''}`
79
+ return `<div class="turn-result" data-turn-seq="${result.atSeq}" data-turn-session="${esc(result.sessionId)}" role="group" aria-label="${esc(text('回合结果', 'Turn result'))}">${button('copy', text('复制结果', 'Copy result'), !result.text)}${result.canFork ? button('fork', text('从此处分支', 'Branch from here')) : ''}<details class="turn-result-usage" data-activity-key="turn-usage:${result.atSeq}"><summary title="${esc(detail)}">${icon('usage')}${esc(label)} ${esc(total)}</summary><div class="turn-result-breakdown">${breakdown}</div></details><time${date ? ` datetime="${date.toISOString()}" title="${esc(date.toLocaleString())}"` : ''}>${esc(stamp)}</time><span class="turn-result-status" role="status" aria-live="polite"></span></div>`
80
+ }
81
+ // Delegate on the stable history container so paging/redraws need no new listeners.
82
+ function bind(box, host) {
83
+ if (!box || box.dataset.turnResultsBound) return
84
+ box.dataset.turnResultsBound = '1'
85
+ const pending = new Set()
86
+ box.addEventListener('click', async event => {
87
+ const button = event.target.closest?.('[data-turn-action]'), row = button?.closest('.turn-result')
88
+ if (!row || !box.contains(row)) return
89
+ const context = host.capture(), atSeq = Number(row.dataset.turnSeq)
90
+ if (context.sessionId !== row.dataset.turnSession || !context.valid()) return
91
+ const result = summarize(context.entries, context.sessionId).get(atSeq)
92
+ if (!result) return
93
+ const key = context.key + ':' + context.sessionId + ':' + atSeq + ':' + button.dataset.turnAction
94
+ if (pending.has(key)) return
95
+ const status = row.querySelector('.turn-result-status')
96
+ pending.add(key); button.disabled = true
97
+ try {
98
+ if (button.dataset.turnAction === 'copy') {
99
+ if (!result.text || !await host.copy(result.text)) throw Error(text('复制失败,请重试', 'Copy failed. Please retry.'))
100
+ if (context.valid()) status.textContent = text('已复制', 'Copied')
101
+ } else if (button.dataset.turnAction === 'fork' && context.canFork) {
102
+ // No prompt is sent to the child. Unknown write receipts are never replayed.
103
+ const child = await host.fork({ sessionId: context.sessionId, atSeq })
104
+ if (!context.valid()) return
105
+ if (!child?.sessionId) throw Error(text('主机未返回分支会话', 'The host did not return a branch session'))
106
+ await host.open(child.sessionId, context)
107
+ }
108
+ } catch (error) {
109
+ if (context.valid()) status.textContent = error.message || text('操作失败', 'Action failed')
110
+ } finally {
111
+ pending.delete(key)
112
+ if (context.valid()) button.disabled = false
113
+ }
114
+ })
115
+ }
116
+ const api = { summarize, decorate, html, bind }
117
+ if (typeof module !== 'undefined' && module.exports) module.exports = api
118
+ else root.DshTurnResults = api
119
+ })(typeof window === 'undefined' ? globalThis : window)
@@ -1,9 +1,9 @@
1
1
  {
2
- "version": "0.8.0-rc.3",
2
+ "version": "0.8.0-rc.4",
3
3
  "apkUrl": "dsh-remote.apk",
4
- "sha256": "cda79a6d4c43bac042b6b47bbdd141c3f7c6e0ac20c7a455b9fe204d32822908",
5
- "releasedAt": "2026-10-17T12:41:14.228Z",
6
- "notes": "0.8.0 开发者预览 rc.3:适配 DSH 0.2.1,新增独立子代理树形页面,统一二级设置界面;精简思考与工具调用展示并保留展开状态;支持重新下载同版本补丁安装包并校验 SHA-256;修复审批展示、公告与返回导航等测试反馈;峰谷提醒交由 dsh-cost-meter 管理,停用 Remote 独立提醒服务。",
4
+ "sha256": "317014a140e50fe7eec4835995c6819dcaac29ad7f42419a280fc68f04e5e6d6",
5
+ "releasedAt": "2026-10-18T11:53:28.027Z",
6
+ "notes": "0.8.0-rc.4:修复 Desktop 状态探测、重启恢复与 WebSocket 重连,避免切换主机后状态串线;修复会话历史空白、返回阻塞及缓存异常后的恢复,支持异常记录隔离和重试;新增回复结果复制、分支、用量与时间显示,修复普通分支会话隐藏;公告支持填空、多选及混合问卷,适配智能体团队查看;恢复按 dsh-cost-meter 规则发送的 Android 峰谷提醒,补齐后台状态诊断;新增仅保存在用户设备的操作日志,支持预览、复制、导出与清除。",
7
7
  "history": [
8
8
  {
9
9
  "version": "0.7.6",
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.8.0-rc.3"
2
+ "version": "0.8.0-rc.4"
3
3
  }
@@ -325,3 +325,42 @@ body.workflow-v8.in-session .history { padding-bottom:calc(var(--composer-height
325
325
  .image-lightbox-hint { position:fixed; left:0; right:0; bottom:calc(var(--dsr-safe-b, 0px) + 10px); z-index:2; text-align:center; color:rgba(226,236,247,.78); font-size:12px; pointer-events:none; }
326
326
  body.image-preview-open { overflow:hidden; }
327
327
  @media (prefers-reduced-motion:reduce) { .workflow-v8 * { scroll-behavior:auto!important; } }
328
+ /* Completed-turn actions share one quiet row on mobile and desktop. */
329
+ .turn-result{display:flex;align-items:center;flex-wrap:wrap;gap:4px 12px;padding:4px 0 12px;color:var(--dsr-muted);font-size:12px;line-height:1.5}
330
+ .turn-result button{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;padding:4px 6px;border:0;border-radius:8px;background:transparent;color:inherit;font:inherit;cursor:pointer}
331
+ .turn-result button:hover{background:var(--dsr-panel);color:var(--dsr-text)}
332
+ .turn-result button:focus-visible{outline:2px solid var(--dsr-accent,#58a6ff);outline-offset:2px}
333
+ .turn-result button:disabled{opacity:.45;cursor:default}
334
+ .turn-result svg{width:18px;height:18px;flex-shrink:0}
335
+ .turn-result-usage{position:relative;min-width:0}
336
+ .turn-result-usage>summary{display:flex;align-items:center;gap:5px;min-height:44px;list-style:none;cursor:pointer}
337
+ .turn-result-usage>summary::-webkit-details-marker{display:none}
338
+ .turn-result-usage>summary:focus-visible{outline:2px solid var(--dsr-accent);outline-offset:2px;border-radius:6px}
339
+ .turn-result-usage[open]{flex-basis:100%;order:3}
340
+ .turn-result-breakdown{max-width:320px;padding:10px 12px;border:1px solid var(--dsr-divider);border-radius:10px;background:var(--dsr-panel);color:var(--dsr-text)}
341
+ .turn-result-breakdown dl{margin:0}.turn-result-breakdown dl>div{display:flex;justify-content:space-between;gap:12px;padding:3px 0}
342
+ .turn-result-breakdown dd{margin:0;font-variant-numeric:tabular-nums}.turn-result-breakdown p{margin:6px 0;color:var(--dsr-muted)}
343
+ .turn-result time{white-space:nowrap;font-variant-numeric:tabular-nums}
344
+ .turn-result-status{flex-basis:100%;overflow-wrap:anywhere}
345
+ .turn-result-status:empty{display:none}
346
+ @media(max-width:480px){.turn-result{gap:2px 10px}.turn-result button{min-width:44px}.turn-result button span{display:none}}
347
+ .announcement-form-field{min-width:0;margin:12px 0;padding:12px;border:1px solid var(--dsr-divider);border-radius:12px}
348
+ .announcement-form-field legend{padding:0 4px;font-size:14px;font-weight:600;overflow-wrap:anywhere}
349
+ .announcement-form-field textarea{box-sizing:border-box;width:100%;min-height:72px;padding:10px;border:1px solid var(--dsr-divider);border-radius:8px;background:var(--dsr-bg);color:var(--dsr-text);font:inherit;font-size:16px;resize:vertical}
350
+ .announcement-form-hint{margin:0 0 8px;color:var(--dsr-muted);font-size:12px}
351
+ .teams-page{max-width:960px;margin:0 auto;color:var(--dsr-text)}
352
+ .teams-page h2{font-size:24px}.teams-page p{overflow-wrap:anywhere;white-space:pre-wrap}
353
+ .teams-controls{display:flex;align-items:center;flex-wrap:wrap;gap:12px}.teams-controls label{display:flex;align-items:center;gap:8px;min-width:0}
354
+ .teams-controls select{max-width:min(100%,320px);min-width:0;padding:10px;border:1px solid var(--dsr-divider);border-radius:8px;background:var(--dsr-panel);color:var(--dsr-text);font-size:16px}
355
+ .teams-page button{min-height:44px;padding:8px 12px;border:1px solid var(--dsr-divider);border-radius:8px;background:var(--dsr-panel);color:var(--dsr-text);font:inherit;cursor:pointer}
356
+ .teams-card{padding:16px;margin:16px 0;background:var(--dsr-panel);border:1px solid var(--dsr-divider);border-radius:16px}
357
+ .teams-card header{display:flex;align-items:baseline;justify-content:space-between;gap:12px;flex-wrap:wrap}.teams-card h3{margin:0;font-size:18px;overflow-wrap:anywhere}
358
+ .teams-card details{margin-top:12px}.teams-card summary{min-height:44px;display:flex;align-items:center;cursor:pointer}
359
+ .teams-card ul{list-style:none;margin:0;padding:0}.teams-card li{padding:12px 0;border-bottom:1px solid var(--dsr-divider);overflow-wrap:anywhere}
360
+ .teams-card small{display:block;color:var(--dsr-muted)}.teams-state{display:inline-block;margin-left:8px;color:var(--dsr-accent)}.teams-error{color:var(--dsr-error)}
361
+ .client-diagnostics{margin:16px 0;padding:12px;border:1px solid var(--dsr-divider);border-radius:12px;min-width:0}
362
+ .client-diagnostics label{display:flex;align-items:center;gap:8px;min-height:44px}.client-diagnostics p{font-size:12px;color:var(--dsr-muted);overflow-wrap:anywhere}
363
+ .client-diagnostics summary{cursor:pointer;min-height:44px;display:flex;align-items:center}.client-diagnostics pre{max-height:240px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px}
364
+ .client-log-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}.client-log-actions button{min-height:44px;padding:8px 12px;border:1px solid var(--dsr-divider);border-radius:8px;background:var(--dsr-panel);color:var(--dsr-text);font:inherit;cursor:pointer}
365
+ .client-log-dialog{box-sizing:border-box;width:min(700px,94vw);max-height:88vh;overflow:auto;padding:16px;border:1px solid var(--dsr-divider);border-radius:16px;background:var(--dsr-panel);color:var(--dsr-text)}
366
+ .client-log-dialog::backdrop{background:rgba(0,0,0,.6)}.client-log-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.client-log-head h2{font-size:20px;margin:0}.client-log-head button{min-width:44px;min-height:44px;border:1px solid var(--dsr-divider);border-radius:8px;background:var(--dsr-panel);color:var(--dsr-text);font:inherit}
@@ -163,6 +163,7 @@
163
163
  if(language&&home.contains(language))general?.append(language)
164
164
  const about=$('settings-page-about'),servers=$('settings-page-servers')
165
165
  if(about&&config.feedback)about.append(button('提交反馈','Send feedback',config.feedback))
166
+ if(about&&root.DshDiagnostics)about.append(button('本地操作日志','Local operation logs',()=>root.DshDiagnostics.show()))
166
167
  for(const id of ['btn-dsh-start','btn-host-describe']){const row=$(id)?.closest('.setting-row,.ds-setting-row');if(row&&about?.contains(row))servers?.append(row)}
167
168
  const support=home.querySelector('.feedback-card');if(support)about?.append(support)
168
169
  home.querySelector('p.about')?.remove()
@@ -352,12 +353,13 @@
352
353
  update()
353
354
  }
354
355
  function clearStorage() {
356
+ root.DshDiagnostics?.clear()
355
357
  const keys=new Set(['activeServer','busySendMode','dsShowArchivedV1','dshAdminDoctorCollapsed','dshAdminToken',
356
358
  'dshLang','dshNetworkModeV1','dshWeakStreamOff','dshTheme','fsWorkspaceIdV1','lastNewSessionWorkspaceV1','mobileEnterAction',
357
359
  'notify','peakRemind','server','servers','servers-v1','servers-v2','sessionSort','showArchivedV1','showTools',
358
360
  'steerSendingEnabled','token','workspaceFilterV1','dshRemoteClientIdV2','dshPromptPresets','seenNotesVersion',
359
361
  'dshCollapsedGoalsV1','workbenchOrderV1','seenAnnouncementsV1','announcementHistoryV1','announcementVotesV1',
360
- 'dshAdminEnabledHostIPsV1','dshAdminManualHostIPsV1','dshRemoteOperationReceiptsV1'])
362
+ 'dshAdminEnabledHostIPsV1','dshAdminManualHostIPsV1','dshRemoteOperationReceiptsV1','dshRemoteDiagnosticsV1','dshRemoteDiagnosticsV1Salt'])
361
363
  for(const key of Object.keys(localStorage))if(keys.has(key)||/^(?:sessions|history)Cache/.test(key))localStorage.removeItem(key)
362
364
  sessionStorage.removeItem('dshRemoteOperationReceiptsV1')
363
365
  sessionStorage.removeItem('dshRemoteLayout')
package/teams.mjs ADDED
@@ -0,0 +1,53 @@
1
+ /* Read-only AgentTeams projection, scoped by registered workspace membership. */
2
+ const text = (v, n = 500) => typeof v === 'string' ? v.slice(0, n) : ''
3
+ const list = (v, n = 300) => Array.isArray(v) ? v.slice(0, n) : []
4
+ const number = v => Number.isFinite(v) && v >= 0 ? v : null
5
+ export function summarizeTeams(raw, workspace) {
6
+ if (!raw || !Array.isArray(raw.teams)) throw Error('unsupported')
7
+ const members = new Set(workspace.sessionIds || [])
8
+ const matching = raw.teams.filter(team => team && members.has(team.captainSessionId))
9
+ return { ok: true, schema: 1, available: true, workspaceId: workspace.id, truncated: matching.length > 40,
10
+ teams: matching.slice(0, 40).map(team => ({
11
+ teamId: text(team.teamId, 120), name: text(team.name, 200), description: text(team.description, 2000),
12
+ captainSessionId: text(team.captainSessionId, 200), phase: text(team.phase, 40), planReviewState: text(team.planReviewState, 60), halted: team.halted === true,
13
+ deliverable: typeof team.deliverable === 'boolean' ? team.deliverable : null,
14
+ delivery: team.delivery && typeof team.delivery.ok === 'boolean' ? { ok: team.delivery.ok,
15
+ blockers: list(team.delivery.blockers, 30).map(v => text(v)), warnings: list(team.delivery.warnings, 30).map(v => text(v)) } : null,
16
+ membersTruncated: Array.isArray(team.members) && team.members.length > 100,
17
+ members: list(team.members, 100).map(member => ({ id: text(member?.id, 200), name: text(member?.name, 120), role: text(member?.role),
18
+ provider: text(member?.provider, 100), model: text(member?.model, 120), status: text(member?.status, 60), activity: text(member?.activity, 40),
19
+ done: number(member?.done), total: number(member?.total), currentTask: text(member?.currentTask, 120), unread: number(member?.unread) })),
20
+ tasksTruncated: Array.isArray(team.tasks) && team.tasks.length > 300,
21
+ tasks: list(team.tasks).map(task => ({ id: text(task?.id, 120), subject: text(task?.subject), description: text(task?.description, 2000),
22
+ status: text(task?.status, 40), state: text(task?.state, 40), assignee: text(task?.assignee, 120),
23
+ dependencies: list(task?.dependencies, 100).map(v => text(v, 120)), verdictStale: text(task?.verdictStale), updatedAt: number(task?.updatedAt) })),
24
+ messageCount: number(team.messageCount), captainInbox: list(team.captainInbox, 5).map(row => ({ from: text(row?.from, 120), content: text(row?.content, 2000) }))
25
+ })) }
26
+ }
27
+ export async function readTeamInsights(ctx, query, fetchState) {
28
+ if ([...query.keys()].some(key => !['workspaceId','archived'].includes(key)) || query.getAll('workspaceId').length !== 1 || query.getAll('archived').length > 1) return { status: 400, body: { ok: false, code: 'invalid-query' } }
29
+ const id = query.get('workspaceId'), archived = query.get('archived') || '0'
30
+ if (!id || id.length > 200 || /[\x00-\x1f]/.test(id) || !['0','1'].includes(archived)) return { status: 400, body: { ok: false, code: 'invalid-query' } }
31
+ try {
32
+ const registry = ctx.get?.('workspaceRegistry') ?? ctx.get?.('workspace')
33
+ if (!registry || typeof registry.list !== 'function') return { status: 503, body: { ok: false, code: 'workspace-unavailable' } }
34
+ const workspace = registry.list().find(row => row.id === id)
35
+ if (!workspace) return { status: 404, body: { ok: false, code: 'workspace-not-found' } }
36
+ // Upstream owns team assembly. Never scan client-supplied paths or forward controls.
37
+ const response = await fetchState(archived === '1')
38
+ if (response.status === 404) return { status: 200, body: { ok: true, schema: 1, available: false, code: 'not-installed' } }
39
+ if (!response.ok) return { status: 502, body: { ok: false, code: 'teams-unavailable' } }
40
+ const reader = response.body.getReader(), chunks = []
41
+ let size = 0
42
+ try {
43
+ for (;;) {
44
+ const part = await reader.read()
45
+ if (part.done) break
46
+ size += part.value.byteLength
47
+ if (size > 2 * 1024 * 1024) throw Error('too-large')
48
+ chunks.push(Buffer.from(part.value))
49
+ }
50
+ } finally { await reader.cancel().catch(() => {}); reader.releaseLock() }
51
+ return { status: 200, body: summarizeTeams(JSON.parse(Buffer.concat(chunks).toString('utf8')), workspace) }
52
+ } catch { return { status: 502, body: { ok: false, code: 'teams-unavailable' } } }
53
+ }