dsh-remote-plugin 0.8.0-rc.2 → 0.8.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apk/dsh-remote.apk +0 -0
- package/gateway.cjs +21 -6
- package/package.json +1 -1
- package/public/activity.js +126 -0
- package/public/announcements.json +8 -0
- package/public/app.js +195 -113
- package/public/desktop/desktop.css +10 -10
- package/public/desktop/desktop.html +25 -9
- package/public/desktop/desktop.js +133 -47
- package/public/extensions.js +3 -2
- package/public/history.js +32 -11
- package/public/image-preview.js +132 -0
- package/public/index.html +32 -10
- package/public/md.js +41 -1
- package/public/network.js +29 -5
- package/public/relay-settings.js +19 -10
- package/public/styles.css +15 -15
- package/public/subagents.css +61 -0
- package/public/subagents.js +275 -0
- package/public/update.json +4 -4
- package/public/version.json +1 -1
- package/public/workflow.css +177 -1
- package/public/workflow.js +88 -8
|
@@ -418,7 +418,7 @@ button.ds-overview-attention-item, button.ds-overview-session-item { cursor:poin
|
|
|
418
418
|
#token-desc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
|
|
419
419
|
.ds-group-bar { display: flex; align-items: center; gap: 10px; padding: 2px 0; }
|
|
420
420
|
.ds-group-bar > label { font-size: 12px; color: var(--dsr-muted); white-space: nowrap; }
|
|
421
|
-
.ds-group-select { flex: 1; min-width:
|
|
421
|
+
.ds-group-select { flex: 0 1 340px; min-width: 180px; position: relative; }
|
|
422
422
|
.ds-select-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px; background: var(--dsr-panel); color: var(--dsr-text); border: 1px solid var(--dsr-line); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 13px; cursor: pointer; }
|
|
423
423
|
.ds-select-btn .caret { color: var(--dsr-muted); font-size: 10px; }
|
|
424
424
|
.ds-group-menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; max-height: 240px; overflow-y: auto; background: var(--dsr-panel); border: 1px solid var(--dsr-line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.28); padding: 4px; display: flex; flex-direction: column; gap: 2px; }
|
|
@@ -427,18 +427,18 @@ button.ds-overview-attention-item, button.ds-overview-session-item { cursor:poin
|
|
|
427
427
|
.ds-group-option.current { background: var(--dsr-accent-soft); color: var(--dsr-accent-strong); font-weight: 600; }
|
|
428
428
|
.ds-server-list { display: flex; flex-direction: column; gap: 7px; }
|
|
429
429
|
.ds-srv-group { border: 1px solid var(--dsr-line); border-radius: 12px; background: var(--dsr-panel); overflow: hidden; }
|
|
430
|
-
.ds-srv-head { display: flex; align-items: center; gap: 6px; padding:
|
|
431
|
-
.ds-srv-name { flex: 1; min-width: 0; text-align: left; background: none; border: none; color: var(--dsr-text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 2px 0; display: flex; align-items: center; gap: 6px; }
|
|
432
|
-
.ds-srv-
|
|
430
|
+
.ds-srv-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
|
|
431
|
+
.ds-srv-name { flex: 1 1 auto; min-width: 0; text-align: left; background: none; border: none; color: var(--dsr-text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 2px 0; display: flex; align-items: center; gap: 6px; }
|
|
432
|
+
.ds-srv-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
433
|
+
.ds-srv-count { flex-shrink: 0; font-size: 10.5px; color: var(--dsr-muted); background: var(--dsr-bg-2); border-radius: 999px; padding: 0 7px; line-height: 16px; }
|
|
433
434
|
.ds-srv-body { display: flex; flex-direction: column; gap: 6px; padding: 0 9px 9px; }
|
|
434
435
|
.ds-srv-body.hidden { display: none; }
|
|
435
|
-
.ds-server-row { display:
|
|
436
|
+
.ds-server-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 6px 8px; background: var(--dsr-bg-2); border: 1px solid var(--dsr-line); border-radius: 10px; padding: 9px 8px 9px 11px; cursor: pointer; }
|
|
436
437
|
.ds-server-row.active { border-color: var(--dsr-info-line); background: var(--dsr-info-soft); }
|
|
437
|
-
.ds-server-main {
|
|
438
|
-
.ds-server-note { font-size: 13px;
|
|
439
|
-
.ds-server-url { font-size: 11.5px; color: var(--dsr-muted);
|
|
440
|
-
.ds-server-
|
|
441
|
-
.ds-server-badge { flex-shrink: 0; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--dsr-accent-soft); color: var(--dsr-accent-strong); border: 1px solid var(--dsr-accent-line); white-space: nowrap; }
|
|
438
|
+
.ds-server-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
439
|
+
.ds-server-note { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; min-width: 0; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
|
|
440
|
+
.ds-server-url { min-width: 0; font-size: 11.5px; line-height: 1.4; color: var(--dsr-muted); overflow-wrap: anywhere; }
|
|
441
|
+
.ds-server-badge { justify-self: end; flex-shrink: 0; min-width: 58px; text-align: center; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: var(--dsr-accent-soft); color: var(--dsr-accent-strong); border: 1px solid var(--dsr-accent-line); white-space: nowrap; }
|
|
442
442
|
.ds-server-badge.good { background: var(--dsr-success-soft); color: var(--dsr-success); border-color: var(--dsr-success-line); }
|
|
443
443
|
.ds-server-badge.bad { background: var(--dsr-warning-soft); color: var(--dsr-warning); border-color: var(--dsr-warning-line); }
|
|
444
444
|
.ds-server-add { display: flex; gap: 8px; }
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
<link rel="stylesheet" href="../insights.css">
|
|
14
14
|
<link rel="stylesheet" href="../workflow.css">
|
|
15
15
|
<link rel="stylesheet" href="../relay-settings.css">
|
|
16
|
+
<link rel="stylesheet" href="../subagents.css">
|
|
16
17
|
</head>
|
|
17
18
|
<body>
|
|
18
19
|
<div class="ds-app" id="ds-app">
|
|
@@ -112,7 +113,8 @@
|
|
|
112
113
|
<span id="ds-session-status" class="ds-session-status hidden"></span>
|
|
113
114
|
|
|
114
115
|
<div class="ds-top-right">
|
|
115
|
-
<button id="btn-
|
|
116
|
+
<button id="btn-subagents" class="subagents-entry hidden" type="button" aria-haspopup="dialog" aria-controls="subagent-page" data-i18n="subagent.title">子代理</button>
|
|
117
|
+
<button id="btn-session-more" class="ds-icon-btn" type="button" aria-haspopup="dialog" aria-controls="session-actions" data-i18n-aria="ds.sessionMore" aria-label="更多操作">⋯</button>
|
|
116
118
|
<span class="ds-conn" id="conn-badge" title="">●</span>
|
|
117
119
|
<span class="ds-server" id="server-badge"></span>
|
|
118
120
|
</div>
|
|
@@ -597,12 +599,12 @@
|
|
|
597
599
|
'ds.statsPeak': '高峰', 'ds.statsOff': '空闲', 'ds.statsDays': '近 {n} 天',
|
|
598
600
|
'ds.statsGatewayDown': '统计需要网关运行', 'ds.statsEmpty': '暂无统计',
|
|
599
601
|
'ds.statsNote': '注:Token 量按 DSH usage 事件记录,第三方 provider 需提供 usage 才能计入;费用仅对已知 DeepSeek 模型估算,与官网账单可能有出入,一切以官网为准。统计自 2026-08-17 定价生效日起。',
|
|
600
|
-
'ds.serversEmpty': '未添加备用服务器', 'ds.serversUntested': '未测速', 'ds.serversCurrent': ' · 当前', 'ds.serversTokenSet': '令牌已配置', 'ds.serversTokenMissing': '未配置令牌',
|
|
602
|
+
'ds.serversEmpty': '未添加备用服务器', 'ds.serversUntested': '未测速', 'ds.serversCurrent': ' · 当前', 'ds.serversCurrentOnly': '当前', 'ds.serversTokenSet': '令牌已配置', 'ds.serversTokenMissing': '未配置令牌',
|
|
601
603
|
'ds.serversUnreachable': '不可达', 'ds.serversDelete': '删除', 'ds.serversEdit': '编辑',
|
|
602
604
|
'ds.serversNeedAddress': '请输入服务器地址', 'ds.serversBadProtocol': '地址需以 http:// 或 https:// 开头',
|
|
603
605
|
'ds.serversDuplicate': '相同地址和令牌已存在', 'ds.serversAdded': '已添加', 'ds.serversEdited': '已更新',
|
|
604
606
|
'ds.serversRemovedActive': '已删除当前服务器,重新测速…',
|
|
605
|
-
'ds.serversCurrentDesc': '当前:{group} · {url}
|
|
607
|
+
'ds.serversCurrentDesc': '当前:{group} · {url}',
|
|
606
608
|
'ds.serversPromptNote': '服务器备注(可留空):', 'ds.serversPromptEditUrl': '编辑服务器地址:', 'ds.serversPromptEditToken': '编辑服务器令牌(留空保持不变):',
|
|
607
609
|
'ds.serversPromptEditNote': '编辑备注({url}):', 'ds.serversPromptEditGroup': '所属组:',
|
|
608
610
|
'ds.serversManualSelected': '已切换至:{url}',
|
|
@@ -611,7 +613,7 @@
|
|
|
611
613
|
'ds.speedManualUsing': '手动模式:{url}({ms})',
|
|
612
614
|
'ds.groupsNoServer': '组内暂无服务器', 'ds.groupsAutoSelect': '自动选择最快', 'ds.groupsDelete': '删除组',
|
|
613
615
|
'ds.groupsAutoOn': '{group} 已切换为自动选择', 'ds.groupsAutoOff': '{group} 已切换为手动选择',
|
|
614
|
-
'ds.groupsSwitched': '已切换到组:{group}', 'ds.groupsSwitchHint': '点击切换当前组,双击重命名',
|
|
616
|
+
'ds.groupsSwitched': '已切换到组:{group}', 'ds.groupsSwitchHint': '点击切换当前组,双击重命名', 'ds.groupsCurrentLabel': '当前组:{group}',
|
|
615
617
|
'ds.groupsPromptAdd': '新组名:', 'ds.groupsDuplicate': '组名已存在', 'ds.groupsAdded': '已创建组:{group}',
|
|
616
618
|
'ds.groupsPromptRename': '重命名组「{group}」:', 'ds.groupsRenamed': '组已重命名',
|
|
617
619
|
'ds.groupsCannotDeleteDefault': '默认组不可删除',
|
|
@@ -637,13 +639,15 @@
|
|
|
637
639
|
'goal.actionFailed': '目标操作失败', 'goal.actionSubmitted': '目标操作已提交',
|
|
638
640
|
'goal.cannotEmpty': '目标不能为空', 'goal.updateFailed': '更新失败', 'goal.updated': '目标已更新', 'goal.editPrompt': '修改目标:',
|
|
639
641
|
'todos.title': '任务清单',
|
|
642
|
+
'session.migrationRequired': '请先在 DSH 中打开原会话完成迁移,然后刷新。',
|
|
640
643
|
'subagent.title': '子代理', 'subagent.count': '子代理 · {n} 个', 'subagent.expand': '展开子代理', 'subagent.collapse': '收起子代理', 'subagent.diagnostic': '诊断项', 'subagent.running': '· 运行中', 'subagent.interrupt': '中断',
|
|
641
644
|
'subagent.confirmInterrupt': '中断这个子代理当前回合?', 'subagent.interruptFailed': '中断失败', 'subagent.interruptSubmitted': '中断请求已提交',
|
|
642
645
|
'queue.title': '排队消息', 'queue.steer': '插话', 'queue.steerUnavailable': '仅运行中可插话', 'queue.steerSubmitted': '插话请求已提交', 'queue.steerFailed': '插话失败:{msg}', 'queue.image': '图片消息',
|
|
643
646
|
'models.loading': '模型加载中…', 'models.loadFailed': '模型列表加载失败:{msg}', 'models.unavailable': '不可用', 'models.none': '没有可用模型',
|
|
644
647
|
'models.switchFailed': '切换模型失败', 'models.switched': '已切换模型:{model}',
|
|
645
648
|
'models.effortFailed': '切换思考深度失败', 'models.effortSwitched': '思考深度:{effort}', 'models.effortLow': '低', 'models.effortHigh': '高', 'models.effortMax': '极高', 'models.effortOff': '关闭', 'models.effortCustomHint': '该路由未公布档位,按 DSH 兼容值尝试;不支持时不会更改当前设置。',
|
|
646
|
-
'block.thinking': '🧠 思考过程', 'block.thinkingLive': '🧠 思考中…',
|
|
649
|
+
'block.thinking': '🧠 思考过程', 'block.thinkingLive': '🧠 思考中…', 'block.image': '图片',
|
|
650
|
+
'ds.activity.group': '工具与思考 · {n} 项', 'ds.activity.groupRunning': '运行中',
|
|
647
651
|
'menu.modelTitle': '模型切换', 'menu.effortTitle': '思考深度',
|
|
648
652
|
},
|
|
649
653
|
en: {
|
|
@@ -706,12 +710,12 @@
|
|
|
706
710
|
'ds.statsPeak': 'Peak', 'ds.statsOff': 'Off-peak', 'ds.statsDays': 'Last {n} days',
|
|
707
711
|
'ds.statsGatewayDown': 'Stats require the gateway', 'ds.statsEmpty': 'No stats yet',
|
|
708
712
|
'ds.statsNote': 'Note: token volume uses DSH usage events; a third-party provider must expose usage to be counted. Costs are estimates for known DeepSeek models and may differ from the official bill; always defer to deepseek.com. Stats start from the 2026-08-17 pricing date.',
|
|
709
|
-
'ds.serversEmpty': 'No backup servers', 'ds.serversUntested': 'Untested', 'ds.serversCurrent': ' · current', 'ds.serversTokenSet': 'Token set', 'ds.serversTokenMissing': 'No token',
|
|
713
|
+
'ds.serversEmpty': 'No backup servers', 'ds.serversUntested': 'Untested', 'ds.serversCurrent': ' · current', 'ds.serversCurrentOnly': 'Current', 'ds.serversTokenSet': 'Token set', 'ds.serversTokenMissing': 'No token',
|
|
710
714
|
'ds.serversUnreachable': 'Unreachable', 'ds.serversDelete': 'Delete', 'ds.serversEdit': 'Edit',
|
|
711
715
|
'ds.serversNeedAddress': 'Enter a server address', 'ds.serversBadProtocol': 'Address must start with http:// or https://',
|
|
712
716
|
'ds.serversDuplicate': 'The same address and token already exist', 'ds.serversAdded': 'Added', 'ds.serversEdited': 'Updated',
|
|
713
717
|
'ds.serversRemovedActive': 'Removed active server, re-testing…',
|
|
714
|
-
'ds.serversCurrentDesc': 'Current: {group} · {url}
|
|
718
|
+
'ds.serversCurrentDesc': 'Current: {group} · {url}',
|
|
715
719
|
'ds.serversPromptNote': 'Server note (optional):', 'ds.serversPromptEditUrl': 'Edit server URL:', 'ds.serversPromptEditToken': 'Edit server token (blank keeps the current token):',
|
|
716
720
|
'ds.serversPromptEditNote': 'Edit note ({url}):', 'ds.serversPromptEditGroup': 'Group:',
|
|
717
721
|
'ds.serversManualSelected': 'Switched to: {url}',
|
|
@@ -720,7 +724,7 @@
|
|
|
720
724
|
'ds.speedManualUsing': 'Manual mode: {url} ({ms})',
|
|
721
725
|
'ds.groupsNoServer': 'No servers in this group', 'ds.groupsAutoSelect': 'Auto-select fastest', 'ds.groupsDelete': 'Delete group',
|
|
722
726
|
'ds.groupsAutoOn': '{group} is now auto-select', 'ds.groupsAutoOff': '{group} is now manual',
|
|
723
|
-
'ds.groupsSwitched': 'Switched to group: {group}', 'ds.groupsSwitchHint': 'Click to switch, double-click to rename',
|
|
727
|
+
'ds.groupsSwitched': 'Switched to group: {group}', 'ds.groupsSwitchHint': 'Click to switch, double-click to rename', 'ds.groupsCurrentLabel': 'Current group: {group}',
|
|
724
728
|
'ds.groupsPromptAdd': 'New group name:', 'ds.groupsDuplicate': 'Group already exists', 'ds.groupsAdded': 'Created group: {group}',
|
|
725
729
|
'ds.groupsPromptRename': 'Rename group "{group}":', 'ds.groupsRenamed': 'Group renamed',
|
|
726
730
|
'ds.groupsCannotDeleteDefault': 'The default group cannot be deleted',
|
|
@@ -746,17 +750,26 @@
|
|
|
746
750
|
'goal.actionFailed': 'Goal action failed', 'goal.actionSubmitted': 'Goal action submitted',
|
|
747
751
|
'goal.cannotEmpty': 'Goal cannot be empty', 'goal.updateFailed': 'Update failed', 'goal.updated': 'Goal updated', 'goal.editPrompt': 'Edit goal:',
|
|
748
752
|
'todos.title': 'Todos',
|
|
753
|
+
'session.migrationRequired': 'Open the source session in DSH to complete migration, then refresh.',
|
|
749
754
|
'subagent.title': 'Subagents', 'subagent.count': 'Subagents · {n}', 'subagent.expand': 'Expand subagents', 'subagent.collapse': 'Collapse subagents', 'subagent.diagnostic': 'Diagnostic', 'subagent.running': '· running', 'subagent.interrupt': 'Interrupt',
|
|
750
755
|
'subagent.confirmInterrupt': 'Interrupt this subagent\'s current turn?', 'subagent.interruptFailed': 'Interrupt failed', 'subagent.interruptSubmitted': 'Interrupt requested',
|
|
751
756
|
'queue.title': 'Queued messages', 'queue.steer': 'Interject', 'queue.steerUnavailable': 'Only available while running', 'queue.steerSubmitted': 'Interjection requested', 'queue.steerFailed': 'Interjection failed: {msg}', 'queue.image': 'Image message',
|
|
752
757
|
'models.loading': 'Loading models…', 'models.loadFailed': 'Failed to load models: {msg}', 'models.unavailable': 'unavailable', 'models.none': 'No models available',
|
|
753
758
|
'models.switchFailed': 'Model switch failed', 'models.switched': 'Switched model: {model}',
|
|
754
759
|
'models.effortFailed': 'Failed to switch reasoning effort', 'models.effortSwitched': 'Reasoning effort: {effort}', 'models.effortLow': 'Low', 'models.effortHigh': 'High', 'models.effortMax': 'Max', 'models.effortOff': 'Off', 'models.effortCustomHint': 'This route does not publish effort metadata. DSH compatibility values are tried; unsupported values leave the current setting unchanged.',
|
|
755
|
-
'block.thinking': '🧠 Thinking', 'block.thinkingLive': '🧠 Thinking…',
|
|
760
|
+
'block.thinking': '🧠 Thinking', 'block.thinkingLive': '🧠 Thinking…', 'block.image': 'Image',
|
|
761
|
+
'ds.activity.group': 'Tools and thinking · {n}', 'ds.activity.groupRunning': 'Running',
|
|
756
762
|
'menu.modelTitle': 'Model', 'menu.effortTitle': 'Reasoning effort',
|
|
757
763
|
}
|
|
758
764
|
}
|
|
759
765
|
</script>
|
|
766
|
+
<div id="image-lightbox" class="image-lightbox hidden" role="dialog" aria-modal="true" aria-label="图片预览" tabindex="-1">
|
|
767
|
+
<button id="image-lightbox-close" class="image-lightbox-close" type="button" data-image-lightbox-close aria-label="关闭">×</button>
|
|
768
|
+
<div class="image-lightbox-stage" data-image-lightbox-stage>
|
|
769
|
+
<img data-image-lightbox-img alt="" draggable="false">
|
|
770
|
+
</div>
|
|
771
|
+
<div class="image-lightbox-hint" data-image-lightbox-hint>双击放大 · 点空白处关闭</div>
|
|
772
|
+
</div>
|
|
760
773
|
<script src="i18n.js"></script>
|
|
761
774
|
<link rel="stylesheet" href="../genui.css">
|
|
762
775
|
<script src="../genui.js"></script>
|
|
@@ -771,11 +784,14 @@
|
|
|
771
784
|
<script src="../extensions.js"></script>
|
|
772
785
|
<script src="../sha256.js"></script>
|
|
773
786
|
<script src="../history.js"></script>
|
|
787
|
+
<script src="../activity.js"></script>
|
|
788
|
+
<script src="../image-preview.js"></script>
|
|
774
789
|
<script src="../link-check.js"></script>
|
|
775
790
|
<script src="../network.js"></script>
|
|
776
791
|
<script src="../operations.js"></script>
|
|
777
792
|
<script src="../workflow.js"></script>
|
|
778
793
|
<script src="../relay-settings.js"></script>
|
|
794
|
+
<script src="../subagents.js"></script>
|
|
779
795
|
<script src="desktop.js"></script>
|
|
780
796
|
</body>
|
|
781
797
|
</html>
|
|
@@ -101,7 +101,7 @@ const state = {
|
|
|
101
101
|
wb: { bound: false, path: '', title: '', expanded: false, projects: null, open: null, apiMissing: false },
|
|
102
102
|
archivedIds: [],
|
|
103
103
|
view: 'sessions',
|
|
104
|
-
|
|
104
|
+
subagentSessions: {}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
// Increment on every identity transition, including A -> B -> A and token edits.
|
|
@@ -118,7 +118,7 @@ for (const key of ['server', 'token']) {
|
|
|
118
118
|
state.sessions = []; state.byId.clear(); state.pendingProjections.clear()
|
|
119
119
|
state.hostInfo = null
|
|
120
120
|
if(typeof closeStream==='function'&&typeof streamMeta!=='undefined'){closeStream('mux');closeStream('host')}
|
|
121
|
-
state.current = null; state.history = emptyDesktopHistory()
|
|
121
|
+
state.current = null; state.history = emptyDesktopHistory(); state.subagentSessions = {}; window.DshSubagents?.reset()
|
|
122
122
|
state.models = { loaded: false, loading: false, groups: [], current: null, failures: [] }
|
|
123
123
|
state.approvals = []; state.questions = []; state.questionModal = null
|
|
124
124
|
state.queues = {}; state.queueSteering = {}; state.compactions = {}; state.compactionTerminals = {}; state.compactionSeqs = {}; state.compactionBootAt = Date.now(); state.pendingCommands = {}; state.sessionTurnTimes = {}
|
|
@@ -671,7 +671,12 @@ async function rpc(method, payload = {}, timeoutMs = 45000) {
|
|
|
671
671
|
if (!res.ok) throw new Error('HTTP ' + res.status)
|
|
672
672
|
const full = await res.json()
|
|
673
673
|
if (!full?.result) throw new Error('bad response')
|
|
674
|
-
if (!full.result.ok)
|
|
674
|
+
if (!full.result.ok) {
|
|
675
|
+
const err = full.result.error || {}
|
|
676
|
+
const error = new Error(err.code === 'session/migration-required' ? t('session.migrationRequired') : err.message || 'dsh error')
|
|
677
|
+
error.code = err.code
|
|
678
|
+
throw error
|
|
679
|
+
}
|
|
675
680
|
return full.result.value
|
|
676
681
|
}
|
|
677
682
|
async function respond(rpcId, value) {
|
|
@@ -933,6 +938,7 @@ function renderGroupSelect() {
|
|
|
933
938
|
const menu = $('group-select-menu')
|
|
934
939
|
if (!label || !menu) return
|
|
935
940
|
label.textContent = state.activeGroup
|
|
941
|
+
$('group-select-btn')?.setAttribute('aria-label', t('ds.groupsCurrentLabel', { group: state.activeGroup }))
|
|
936
942
|
menu.innerHTML = state.groups.map(g => `<button type="button" class="ds-group-option ${g === state.activeGroup ? 'current' : ''}" data-group-option="${esc(g)}">${esc(g)}${g === state.activeGroup ? ' ✓' : ''}</button>`).join('')
|
|
937
943
|
menu.querySelectorAll('[data-group-option]').forEach(b => b.addEventListener('click', () => {
|
|
938
944
|
closeGroupMenu()
|
|
@@ -1021,7 +1027,7 @@ function renderServers() {
|
|
|
1021
1027
|
const activeManual = state.groupActive[g] || ''
|
|
1022
1028
|
return `<div class="ds-srv-group" data-group="${esc(g)}">
|
|
1023
1029
|
<div class="ds-srv-head">
|
|
1024
|
-
<button class="ds-srv-name" data-group-name="${esc(g)}" title="${t('ds.groupsSwitchHint')}">${g === state.activeGroup ? '▾' : '▸'} ${esc(g)}
|
|
1030
|
+
<button class="ds-srv-name" data-group-name="${esc(g)}" title="${t('ds.groupsSwitchHint')}"><span class="ds-srv-label">${g === state.activeGroup ? '▾' : '▸'} ${esc(g)}</span><span class="ds-srv-count">${list.length}</span></button>
|
|
1025
1031
|
<button class="ds-mini" data-speed-group="${esc(g)}" title="${t('ds.speedTest')}">⚡</button>
|
|
1026
1032
|
<label class="ds-switch" title="${t('ds.groupsAutoSelect')}"><input type="checkbox" data-auto-group="${esc(g)}" ${auto ? 'checked' : ''}><span class="ds-slider"></span></label>
|
|
1027
1033
|
${g !== '默认' ? `<button class="ds-mini" data-del-group="${esc(g)}" title="${t('ds.groupsDelete')}">✕</button>` : ''}
|
|
@@ -1029,15 +1035,18 @@ function renderServers() {
|
|
|
1029
1035
|
<div class="ds-srv-body ${g === state.activeGroup ? '' : 'hidden'}">
|
|
1030
1036
|
${list.map(s => {
|
|
1031
1037
|
const ms = state.serverLatency[serverKey(s)]
|
|
1032
|
-
let badge = `<span class="ds-server-badge">${t('ds.serversUntested')}</span>`
|
|
1033
1038
|
const active = s.url === state.server && serverToken(s) === state.token
|
|
1034
|
-
|
|
1039
|
+
// One status per row keeps long addresses readable.
|
|
1040
|
+
let badge = `<span class="ds-server-badge">${t('ds.serversUntested')}</span>`
|
|
1041
|
+
if (!s.token) badge = `<span class="ds-server-badge bad">${t('ds.serversTokenMissing')}</span>`
|
|
1042
|
+
else if (Number.isFinite(ms)) badge = `<span class="ds-server-badge ${active ? 'good' : ''}">${ms}ms${active ? t('ds.serversCurrent') : ''}</span>`
|
|
1035
1043
|
else if (ms !== undefined) badge = `<span class="ds-server-badge bad">${t('ds.serversUnreachable')}</span>`
|
|
1044
|
+
else if (active) badge = `<span class="ds-server-badge good">${t('ds.serversCurrentOnly')}</span>`
|
|
1036
1045
|
const activeInGroup = auto ? active : s.id === activeManual
|
|
1037
1046
|
return `<div class="ds-server-row ${activeInGroup ? 'active' : ''}" data-use-server="${esc(s.id)}">
|
|
1038
|
-
<span class="ds-server-main"><span class="ds-server-note">${esc(serverTitle(s))}</span>${s.note ? `<span class="ds-server-url">${esc(s.url)}</span>` : ''}
|
|
1039
|
-
<button class="ds-mini" data-edit-server="${esc(s.id)}" title="${t('ds.serversEdit')}">✎</button>
|
|
1040
|
-
<button class="ds-mini" data-del-server="${esc(s.id)}"
|
|
1047
|
+
<span class="ds-server-main"><span class="ds-server-note" title="${esc(serverTitle(s))}">${esc(serverTitle(s))}</span>${s.note ? `<span class="ds-server-url">${esc(s.url)}</span>` : ''}</span>${badge}
|
|
1048
|
+
<button class="ds-mini ds-server-edit" data-edit-server="${esc(s.id)}" title="${t('ds.serversEdit')}" aria-label="${t('ds.serversEdit')}">✎</button>
|
|
1049
|
+
<button class="ds-mini ds-server-del" data-del-server="${esc(s.id)}" aria-label="${t('ds.serversDelete')}">✕</button>
|
|
1041
1050
|
</div>`
|
|
1042
1051
|
}).join('') || `<div class="ds-empty">${t('ds.groupsNoServer')}</div>`}
|
|
1043
1052
|
</div>
|
|
@@ -1079,7 +1088,7 @@ function renderServers() {
|
|
|
1079
1088
|
const curGroup = cur ? cur.group : state.activeGroup
|
|
1080
1089
|
const curLabel = cur ? (cur.note || cur.url) : (state.server || t('ds.origin'))
|
|
1081
1090
|
const curMs = cur ? state.serverLatency[serverKey(cur)] : undefined
|
|
1082
|
-
$('server-desc').textContent = t('ds.serversCurrentDesc', { group: curGroup, url: curLabel
|
|
1091
|
+
$('server-desc').textContent = t('ds.serversCurrentDesc', { group: curGroup, url: curLabel }) + (Number.isFinite(curMs) ? ' · ' + curMs + 'ms' : '')
|
|
1083
1092
|
updateConn()
|
|
1084
1093
|
}
|
|
1085
1094
|
|
|
@@ -1608,9 +1617,15 @@ function hydrateSessionProjections(sessionId, projections) {
|
|
|
1608
1617
|
if (!s || !projections || typeof projections !== 'object') return
|
|
1609
1618
|
const incomingSeq = Number(projections.asOfSeq) || 0
|
|
1610
1619
|
const current = s.projections || { asOfSeq: 0, values: {} }
|
|
1620
|
+
if (projections.kind === 'cached' && current.kind === 'sequenced') return
|
|
1621
|
+
if (current.kind === 'cached' || projections.kind === 'cached') {
|
|
1622
|
+
s.projections = { ...projections, asOfSeq: incomingSeq, kind: projections.kind || 'sequenced', values: { ...(current.values || {}), ...(projections.values || {}) } }
|
|
1623
|
+
return
|
|
1624
|
+
}
|
|
1611
1625
|
const currentSeq = Number(current.asOfSeq) || 0
|
|
1612
1626
|
if (incomingSeq < currentSeq) return
|
|
1613
1627
|
s.projections = {
|
|
1628
|
+
kind: projections.kind || current.kind || 'sequenced',
|
|
1614
1629
|
asOfSeq: Math.max(currentSeq, incomingSeq),
|
|
1615
1630
|
values: { ...(current.values || {}), ...(projections.values || {}) }
|
|
1616
1631
|
}
|
|
@@ -1631,6 +1646,7 @@ function applyProjection(sessionId, key, value, seq) {
|
|
|
1631
1646
|
state.pendingProjections.set(sessionId, pending)
|
|
1632
1647
|
return
|
|
1633
1648
|
}
|
|
1649
|
+
if (s.projections?.kind === 'cached') s.projections = { kind: 'sequenced', asOfSeq: 0, values: { ...(s.projections.values || {}) } }
|
|
1634
1650
|
const currentSeq = Number(s.projections?.asOfSeq) || 0
|
|
1635
1651
|
if (seq && seq < currentSeq) return
|
|
1636
1652
|
s.projections = s.projections || { asOfSeq: 0, values: {} }
|
|
@@ -1788,6 +1804,12 @@ async function refreshSessions() {
|
|
|
1788
1804
|
if (!v) { renderSessions(); renderOverviewDesktop(); return }
|
|
1789
1805
|
state.sessions = v.items || []
|
|
1790
1806
|
state.byId = new Map(state.sessions.map(s => [s.sessionId, s]))
|
|
1807
|
+
for (const [id, child] of Object.entries(state.subagentSessions || {})) {
|
|
1808
|
+
const listed = state.byId.get(id)
|
|
1809
|
+
const merged = listed ? { ...child, ...listed, parentSessionId: child.parentSessionId, subagentMode: child.subagentMode, origin: 'subagent' } : child
|
|
1810
|
+
state.byId.set(id, merged)
|
|
1811
|
+
state.subagentSessions[id] = merged
|
|
1812
|
+
}
|
|
1791
1813
|
applyPendingProjections()
|
|
1792
1814
|
try{LS.set(historyCacheScope()+':sessions',JSON.stringify(state.sessions.slice(0,80)))}catch{}
|
|
1793
1815
|
renderSessions()
|
|
@@ -1913,6 +1935,7 @@ const emptySessionCleanup = new Set()
|
|
|
1913
1935
|
async function archiveEmptySessionOnLeave(sessionId, leaving = false) {
|
|
1914
1936
|
const base = state.server, connection=captureConnection()
|
|
1915
1937
|
const protectedSession = () => !connection.valid() || state.server !== base || (!leaving && state.current !== sessionId)
|
|
1938
|
+
|| !!state.byId.get(sessionId)?.parentSessionId || state.byId.get(sessionId)?.origin === 'subagent'
|
|
1916
1939
|
|| !state.byId.has(sessionId) || state.byId.get(sessionId)?.running
|
|
1917
1940
|
|| state.sessionActivity?.has(sessionId) || state.pendingPrompts?.has(sessionId)
|
|
1918
1941
|
|| (state.queues[sessionId] || []).length > 0
|
|
@@ -1956,6 +1979,8 @@ async function openSession(id) {
|
|
|
1956
1979
|
}
|
|
1957
1980
|
async function closeSession() {
|
|
1958
1981
|
const sessionId = state.current
|
|
1982
|
+
const parentId = state.byId.get(sessionId)?.parentSessionId
|
|
1983
|
+
if (parentId && parentId !== sessionId) return openSession(parentId)
|
|
1959
1984
|
if (sessionId) await archiveEmptySessionOnLeave(sessionId)
|
|
1960
1985
|
if (state.current !== sessionId) return
|
|
1961
1986
|
state.current = null
|
|
@@ -1986,7 +2011,7 @@ function getConversationView() {
|
|
|
1986
2011
|
if(!conversationView)conversationView=new window.DshHistory.HistoryView($('history'),{
|
|
1987
2012
|
html:entry=>eventHtml(entry),
|
|
1988
2013
|
older:()=>loadHistory(false),olderLabel:()=>t('ds.historyEarlier'),loadingLabel:()=>t('ds.historyLoadingEarlier'),live:partialReasoningHtml,
|
|
1989
|
-
changed:view=>{state.history.renderStart=view.start;state.history.renderEnd=view.end;const latest=$('btn-history-latest');if(latest){latest.classList.toggle('hidden'
|
|
2014
|
+
changed:view=>{state.history.renderStart=view.start;state.history.renderEnd=view.end;const latest=$('btn-history-latest');if(latest){latest.classList.toggle('hidden',view.atBottom&&view.unread===0&&!state.history.tailEvicted);latest.textContent=t('ds.historyLatest')+(view.unread?' ('+view.unread+')':view.hasPending?' · '+(I18N.lang==='en'?'New content':'有新内容'):'')}},
|
|
1990
2015
|
scrolled:()=>{}
|
|
1991
2016
|
})
|
|
1992
2017
|
return conversationView
|
|
@@ -2031,6 +2056,8 @@ async function loadHistory(reset = true) {
|
|
|
2031
2056
|
if(reset){if(hadContent)historySource('syncing');else setSessionRecovery('loading')}
|
|
2032
2057
|
const network=window.DshNetwork?.profile() || {historyPageSize:60,readTimeout:45000}
|
|
2033
2058
|
const payload={sessionId:id,maxMessages:network.historyPageSize}
|
|
2059
|
+
const child=state.subagentSessions?.[id] || state.byId.get(id)
|
|
2060
|
+
if(child?.origin==='subagent' && child.parentSessionId) Object.assign(payload,{parentSessionId:child.parentSessionId,subagentMode:child.subagentMode || 'unknown'})
|
|
2034
2061
|
if(!reset&&Number.isFinite(history.minSeq))payload.beforeSeq=history.minSeq
|
|
2035
2062
|
getConversationView().more.disabled=true
|
|
2036
2063
|
getConversationView().more.textContent=getConversationView().options.loadingLabel()
|
|
@@ -2136,7 +2163,9 @@ function applyReasoningStreamEvent(event) {
|
|
|
2136
2163
|
return changed
|
|
2137
2164
|
}
|
|
2138
2165
|
let reasoningRenderTimer = null
|
|
2166
|
+
function weakStreamTrim() { return !!window.DshNetwork?.streamTrimmed?.() }
|
|
2139
2167
|
function scheduleReasoningRender() {
|
|
2168
|
+
if (weakStreamTrim()) return
|
|
2140
2169
|
if (reasoningRenderTimer) return
|
|
2141
2170
|
reasoningRenderTimer = setTimeout(() => {
|
|
2142
2171
|
reasoningRenderTimer = null
|
|
@@ -2144,22 +2173,32 @@ function scheduleReasoningRender() {
|
|
|
2144
2173
|
}, 80)
|
|
2145
2174
|
}
|
|
2146
2175
|
function partialReasoningHtml() {
|
|
2176
|
+
if (weakStreamTrim()) return ''
|
|
2147
2177
|
return [...state.history.partialReasoning.values()]
|
|
2148
2178
|
.filter(item => item.text)
|
|
2149
2179
|
.sort((a, b) => (a.turn ?? 0) - (b.turn ?? 0) || (a.step ?? 0) - (b.step ?? 0) || (a.index ?? 0) - (b.index ?? 0))
|
|
2150
|
-
.map(item => `<div class="ds-msg assistant ds-reasoning-live"><div class="role">${esc(t('ds.role.dsh'))}</div><details open><summary>${esc(t('block.thinkingLive'))}</summary><div>${esc(item.text)}</div></details></div>`)
|
|
2180
|
+
.map(item => window.DshActivity ? window.DshActivity.reasoning({text:item.text,live:true,key:window.DshActivity.reasoningKey(item,item.index,'live-reasoning')}) : `<div class="ds-msg assistant ds-reasoning-live"><div class="role">${esc(t('ds.role.dsh'))}</div><details open><summary>${esc(t('block.thinkingLive'))}</summary><div>${esc(item.text)}</div></details></div>`)
|
|
2151
2181
|
.join('')
|
|
2152
2182
|
}
|
|
2153
2183
|
function safeJson(v) { try { return JSON.stringify(v, null, 2) } catch { return String(v) } }
|
|
2154
|
-
function blockHtml(b) {
|
|
2184
|
+
function blockHtml(b,index=0,context={}) {
|
|
2155
2185
|
if (!b) return ''
|
|
2156
|
-
if (b.type === '
|
|
2186
|
+
if ((b.type === 'tool-call' || b.type === 'tool-result') && context.suppressBlockTools) return ''
|
|
2187
|
+
if (typeof window !== 'undefined' && window.DshActivity) {
|
|
2188
|
+
const key='block:'+context.seq+':'+index
|
|
2189
|
+
if (b.type==='thinking'||b.type==='reasoning') return window.DshActivity.reasoning({text:b.text??b.content??'',key:window.DshActivity.reasoningKey(context,index,key)})
|
|
2190
|
+
if (b.type==='tool-call'||b.type==='tool-result') return window.DshActivity.tool({key,name:b.name||b.toolName,...(b.type==='tool-call'?{args:b.arguments??b.args??b.input}:{result:b.result??b.output??b.content??b,error:!!(b.error||b.ok===false||b.isError)})})
|
|
2191
|
+
}
|
|
2192
|
+
if (b.type === 'text') return `<div class="md">${window.mdToHtml ? window.mdToHtml(b.text ?? '', { fileLinks: true, imageLabel: t('block.image') }) : esc(b.text ?? '')}</div>`
|
|
2157
2193
|
if (b.type === 'file' && typeof window !== 'undefined' && window.DshChatFiles) return window.DshChatFiles.render(b)
|
|
2158
2194
|
if (b.type === 'file') return `<div class="ds-tool">📎 ${esc(b.attachment?.name || b.name || 'file')} <small>${esc(b.attachment?.bytes ?? b.bytes ?? '')} bytes</small></div>`
|
|
2159
2195
|
if (b.type === 'thinking' || b.type === 'reasoning') return `<details><summary>${esc(t('block.thinking'))}</summary><div style="opacity:.82">${esc(b.text ?? b.content ?? '')}</div></details>`
|
|
2160
2196
|
if (b.type === 'tool-call') return `<div>🔧 ${esc(b.name || '')}</div>`
|
|
2161
2197
|
if (b.type === 'tool-result') return `<div>📦</div>`
|
|
2162
|
-
if (b.type === 'image')
|
|
2198
|
+
if (b.type === 'image') {
|
|
2199
|
+
const alt = b.name || b.filename || t('block.image')
|
|
2200
|
+
return `<button type="button" class="chat-image" data-chat-image aria-label="${esc(t('block.image'))}"><img alt="${esc(alt)}" src="data:${esc(b.mediaType || 'image/png')};base64,${esc(b.data || '')}" draggable="false"></button>`
|
|
2201
|
+
}
|
|
2163
2202
|
return ''
|
|
2164
2203
|
}
|
|
2165
2204
|
function systemReminderText(blocks) {
|
|
@@ -2169,11 +2208,25 @@ function systemReminderText(blocks) {
|
|
|
2169
2208
|
.map(b => String(b.text ?? ''))
|
|
2170
2209
|
.join('\n')
|
|
2171
2210
|
}
|
|
2211
|
+
function activityGroupHtml(group) {
|
|
2212
|
+
const items = group.items || []
|
|
2213
|
+
if (!items.length) return ''
|
|
2214
|
+
const tools = items.filter(item => item.kind === 'tool').map(item => item.entry)
|
|
2215
|
+
const running = !!group.running
|
|
2216
|
+
const failed = tools.some(entry => entry.view?.toolActivity?.error || entry.event?.data?.error)
|
|
2217
|
+
const body = items.map(item => item.kind === 'reasoning'
|
|
2218
|
+
? window.DshActivity.reasoning({ text: item.text, key: item.key })
|
|
2219
|
+
: eventHtml(item.entry)).join('')
|
|
2220
|
+
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('ds.activity.group', { n: items.length }))}</span>${running ? `<span class="activity-group-live"><i aria-hidden="true"></i>${esc(t('ds.activity.groupRunning'))}</span>` : ''}<span class="activity-chevron" aria-hidden="true"></span></summary><div class="activity-group-body">${body}</div></details>`
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2172
2223
|
function eventHtml(entry) {
|
|
2173
2224
|
const ev = entry.event || {}
|
|
2174
2225
|
const data = ev.data || {}
|
|
2175
2226
|
const type = ev.type || 'event'
|
|
2227
|
+
if (entry.view?.activityGroup) return activityGroupHtml(entry.view.activityGroup)
|
|
2176
2228
|
if (!shouldShowEvent(type, ev)) return ''
|
|
2229
|
+
if (window.DshActivity && (type==='tool/call'||type==='tool/result')) return window.DshActivity.toolEvent(entry)
|
|
2177
2230
|
if (type === 'user/message' || type === 'assistant/message') {
|
|
2178
2231
|
const msg = data.message || {}
|
|
2179
2232
|
const role = data.role || msg.role || (type.startsWith('user') ? 'user' : 'assistant')
|
|
@@ -2184,8 +2237,9 @@ function eventHtml(entry) {
|
|
|
2184
2237
|
return `<details class="event ds-tool ds-event-detail"><summary>${esc(t('ds.eventSystemReminder'))}</summary><pre>${esc(shown)}</pre></details>`
|
|
2185
2238
|
}
|
|
2186
2239
|
if (type === 'user/message' && !isHumanUserMessage(ev)) return ''
|
|
2187
|
-
const text = blocks.map(blockHtml).join('')
|
|
2188
|
-
|
|
2240
|
+
const text = blocks.map((block,index)=>blockHtml(block,index,{...data,seq:entry.seq,suppressBlockTools:state.history.suppressBlockTools})).join('')
|
|
2241
|
+
if (!text) return ''
|
|
2242
|
+
return `<div class="ds-msg ${esc(role)}"><div class="role">${esc(role === 'user' ? t('ds.role.me') : t('ds.role.dsh'))}</div>${text}</div>`
|
|
2189
2243
|
}
|
|
2190
2244
|
if (type === 'tool/call') {
|
|
2191
2245
|
const name = data.name || data.toolName || t('ds.toolDefault')
|
|
@@ -2202,16 +2256,44 @@ function eventHtml(entry) {
|
|
|
2202
2256
|
return `<div class="ds-tool">${esc(type)}</div>`
|
|
2203
2257
|
}
|
|
2204
2258
|
function renderHistory(reset=false, mode='auto') {
|
|
2205
|
-
|
|
2206
|
-
|
|
2259
|
+
let prepared=window.DshActivity?.prepare(state.history.visible)||state.history.visible
|
|
2260
|
+
if(weakStreamTrim())prepared=prepared.filter(entry=>entry.event?.type!=='tool/call'||entry.view?.toolActivity)
|
|
2261
|
+
state.history.suppressBlockTools = state.history.visible.some(entry => entry.event?.type === 'tool/call')
|
|
2262
|
+
if(window.DshActivity?.group)prepared=window.DshActivity.group(prepared)
|
|
2263
|
+
const sessionRunning = !!state.byId.get(state.current)?.running
|
|
2264
|
+
const groups = prepared.filter(entry => entry.view?.activityGroup)
|
|
2265
|
+
const activeGroup = groups.at(-1)
|
|
2266
|
+
if (activeGroup) activeGroup.view.activityGroup.running = sessionRunning
|
|
2267
|
+
getConversationView().set(prepared,{reset,follow:mode==='bottom',live:partialReasoningHtml(),hasMore:state.history.hasMore,loading:state.history.loading,emptyLabel:t('ds.historyEmpty')})
|
|
2268
|
+
window.DshImagePreview?.hydrate?.($('history'))
|
|
2269
|
+
}
|
|
2270
|
+
window.applyStreamPreference=()=>{if(state.current)renderHistory(false,'auto')}
|
|
2207
2271
|
|
|
2208
2272
|
/* ---------------- 会话信息卡(goal / todo / 子代理) ---------------- */
|
|
2209
2273
|
let sessionSubagentsJob = null
|
|
2274
|
+
function rememberSubagent(entry, parentId) {
|
|
2275
|
+
const childId = entry.id
|
|
2276
|
+
const child = state.byId.get(childId) || { sessionId: childId, cwd: state.byId.get(parentId)?.cwd || '' }
|
|
2277
|
+
Object.assign(child, { parentSessionId: parentId, origin: 'subagent', subagentMode: entry.mode || child.subagentMode || 'unknown' })
|
|
2278
|
+
if (entry.label && !child.projections?.values?.title) {
|
|
2279
|
+
child.projections ||= { values: {} }
|
|
2280
|
+
child.projections.values ||= {}
|
|
2281
|
+
child.projections.values.title = entry.label
|
|
2282
|
+
}
|
|
2283
|
+
state.byId.set(childId, child)
|
|
2284
|
+
state.subagentSessions ||= {}
|
|
2285
|
+
state.subagentSessions[childId] = child
|
|
2286
|
+
}
|
|
2287
|
+
async function openSubagentSession(childId, parentId, entry = {}, rootId = parentId) {
|
|
2288
|
+
if (!childId || childId === parentId || state.current !== rootId) return
|
|
2289
|
+
rememberSubagent({ ...entry, id: childId }, parentId)
|
|
2290
|
+
await openSession(childId)
|
|
2291
|
+
}
|
|
2210
2292
|
async function loadSessionSubagents(sessionId) {
|
|
2211
2293
|
if (sessionSubagentsJob?.sessionId === sessionId && sessionSubagentsJob.connection.valid()) return sessionSubagentsJob.promise
|
|
2212
2294
|
const connection = captureConnection(), job = { sessionId, connection }
|
|
2213
2295
|
job.promise = (async () => {
|
|
2214
|
-
const value = await
|
|
2296
|
+
const value = await rpc('subagent.list', { parentSessionId: sessionId })
|
|
2215
2297
|
return connection.valid() ? value : null
|
|
2216
2298
|
})()
|
|
2217
2299
|
sessionSubagentsJob = job
|
|
@@ -2268,30 +2350,15 @@ async function renderSessionCards() {
|
|
|
2268
2350
|
requestAnimationFrame(() => box.querySelector(`[data-goal-collapse="${collapse ? '0' : '1'}"]`)?.focus())
|
|
2269
2351
|
}))
|
|
2270
2352
|
|
|
2271
|
-
const sub = await loadSessionSubagents(sessionId)
|
|
2272
2353
|
if (!connection.valid() || renderGeneration !== sessionCardsRenderGeneration || state.current !== sessionId) return
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
}).join('')
|
|
2282
|
-
const subagentClosedIcon = 'M7 10l5 5 5-5'
|
|
2283
|
-
const subagentOpenIcon = 'M7 14l5-5 5 5'
|
|
2284
|
-
const subagentIcon = expanded ? subagentOpenIcon : subagentClosedIcon
|
|
2285
|
-
box.insertAdjacentHTML('beforeend', `<div class="ds-card ds-subagent-card"><button type="button" class="ds-subagent-toggle" data-subagent-toggle aria-expanded="${expanded}" aria-label="${esc(toggleLabel)}" title="${esc(toggleLabel)}"><span class="ds-card-title">${esc(t('subagent.count', { n: sub.entries.length }))}</span><span class="ds-subagent-toggle-icon" aria-hidden="true"><morph-icon data-morph-state="${expanded ? 'open' : 'closed'}" data-morph-closed="${subagentClosedIcon}" data-morph-open="${subagentOpenIcon}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${subagentIcon}"/></svg></morph-icon></span></button><div class="ds-subagent-list${expanded ? '' : ' hidden'}">${rows}</div></div>`)
|
|
2286
|
-
box.querySelector('[data-subagent-toggle]')?.addEventListener('click', () => {
|
|
2287
|
-
const icon = box.querySelector('[data-subagent-toggle] morph-icon')
|
|
2288
|
-
if (icon) icon.setAttribute('data-morph-state', expanded ? 'closed' : 'open')
|
|
2289
|
-
state.subagentExpandedSession = expanded ? '' : sessionId
|
|
2290
|
-
setTimeout(() => renderSessionCards(), 240)
|
|
2291
|
-
})
|
|
2292
|
-
box.querySelectorAll('[data-sub-interrupt]').forEach(btn =>
|
|
2293
|
-
btn.addEventListener('click', () => interruptSubagent(btn.dataset.subInterrupt)))
|
|
2294
|
-
}
|
|
2354
|
+
window.DshSubagents?.configure($('btn-subagents'), {
|
|
2355
|
+
sessionId, title: titleOf(s), activity: s.running === true ? 'running' : s.running === false ? 'inactive' : 'unknown', parentId: s.origin === 'subagent' ? s.parentSessionId : null,
|
|
2356
|
+
valid: () => connection.valid() && state.current === sessionId,
|
|
2357
|
+
read: loadSessionSubagents, remember: rememberSubagent,
|
|
2358
|
+
onShow: () => conversationView?.pause(), onClose: () => conversationView?.resume(),
|
|
2359
|
+
open: (entry, parentId) => openSubagentSession(entry.id, parentId, entry, sessionId),
|
|
2360
|
+
interrupt: interruptSubagent,
|
|
2361
|
+
})
|
|
2295
2362
|
}
|
|
2296
2363
|
|
|
2297
2364
|
function setGoalPhaseLocal(phase) {
|
|
@@ -2336,10 +2403,11 @@ async function goalAction(kind) {
|
|
|
2336
2403
|
renderSessionCards()
|
|
2337
2404
|
}
|
|
2338
2405
|
|
|
2339
|
-
async function interruptSubagent(childId) {
|
|
2406
|
+
async function interruptSubagent(childId, parentId = state.current) {
|
|
2407
|
+
const connection = captureConnection(), rootId = state.current
|
|
2340
2408
|
if (!confirm(t('subagent.confirmInterrupt'))) return
|
|
2341
|
-
const result = await safeRpc('subagent.interrupt', { parentSessionId:
|
|
2342
|
-
if (result == null) return
|
|
2409
|
+
const result = await safeRpc('subagent.interrupt', { parentSessionId: parentId, childSessionId: childId, mode: 'continuable' }, t('subagent.interruptFailed'))
|
|
2410
|
+
if (result == null || !connection.valid() || state.current !== rootId) return
|
|
2343
2411
|
toast(t('subagent.interruptSubmitted'), 'ok')
|
|
2344
2412
|
setTimeout(renderSessionCards, 600)
|
|
2345
2413
|
}
|
|
@@ -2435,6 +2503,7 @@ async function runSlashCommand(text) {
|
|
|
2435
2503
|
}
|
|
2436
2504
|
|
|
2437
2505
|
async function sendMessage(requestedMode = 'queue') {
|
|
2506
|
+
if (state.byId.get(state.current)?.origin === 'subagent') { toast('子代理记录为只读 / Subagent records are read only'); return false }
|
|
2438
2507
|
const input = $('composer')
|
|
2439
2508
|
const originalText = input.value, text = originalText.trim()
|
|
2440
2509
|
if (!text || !state.current) return
|
|
@@ -2736,6 +2805,18 @@ function fsApiUrl(sub, params = {}) {
|
|
|
2736
2805
|
function fsHeaders() {
|
|
2737
2806
|
return { authorization: 'Bearer ' + state.token, 'x-dsh-remote-client': 'web', ...clientIdHeaders() }
|
|
2738
2807
|
}
|
|
2808
|
+
|
|
2809
|
+
/** Local image paths inside Markdown: resolve relative to the open session workspace. */
|
|
2810
|
+
function chatImageRequest(pathValue) {
|
|
2811
|
+
const value = String(pathValue || '').trim()
|
|
2812
|
+
if (!value) return null
|
|
2813
|
+
let target = value
|
|
2814
|
+
if (!/^(?:[A-Za-z]:[\\/]|\\\\|\/|~[\\/])/.test(value)) {
|
|
2815
|
+
const root = state.byId.get(state.current)?.cwd || ''
|
|
2816
|
+
if (root) target = root.replace(/[\\/]+$/, '') + (root.includes('\\') ? '\\' : '/') + value.replace(/^\.?[\\/]+/, '')
|
|
2817
|
+
}
|
|
2818
|
+
return { url: fsApiUrl('/file', { path: target }), headers: fsHeaders() }
|
|
2819
|
+
}
|
|
2739
2820
|
function fsParent(p) {
|
|
2740
2821
|
const meta = fsPathMeta(p)
|
|
2741
2822
|
if (!meta.value) return null
|
|
@@ -3565,10 +3646,12 @@ function setMobileSidebar(open) {
|
|
|
3565
3646
|
function openDesktopPlugins(route = 'manage') {
|
|
3566
3647
|
const connection=captureConnection()
|
|
3567
3648
|
if(!connection.token){$('desktop-plugin-page').textContent=t('ds.toastAuth');return}
|
|
3568
|
-
window.DshExtensions.mount({connection,getSession:()=>state.byId.get(state.current),getTitle:()=>titleOf(state.byId.get(state.current)),openContext:()=>void openInsights('context',true),scrollTop:()=>{$('view-plugins').scrollTop=0},url:path=>connection.server+path,headers:{authorization:'Bearer '+connection.token,'x-dsh-remote-client':'web',...clientIdHeaders()},valid:connection.valid},$('desktop-plugin-page'),route)
|
|
3649
|
+
window.DshExtensions.mount({connection,back:()=>showView('view-settings'),getSession:()=>state.byId.get(state.current),getTitle:()=>titleOf(state.byId.get(state.current)),openContext:()=>void openInsights('context',true),scrollTop:()=>{$('view-plugins').scrollTop=0},url:path=>connection.server+path,headers:{authorization:'Bearer '+connection.token,'x-dsh-remote-client':'web',...clientIdHeaders()},valid:connection.valid},$('desktop-plugin-page'),route)
|
|
3569
3650
|
}
|
|
3570
3651
|
|
|
3571
3652
|
function showView(id) {
|
|
3653
|
+
if (id !== 'view-chat') window.DshSubagents?.close()
|
|
3654
|
+
document.body?.classList.toggle('viewing-subagent', id === 'view-chat' && state.byId.get(state.current)?.origin === 'subagent')
|
|
3572
3655
|
window.DshWorkflow?.close()
|
|
3573
3656
|
if (window.DshWorkflow?.isMounted() && id === 'view-overview') id = 'view-sessions'
|
|
3574
3657
|
if (id !== 'view-chat') conversationView?.pause()
|
|
@@ -3594,6 +3677,7 @@ function showView(id) {
|
|
|
3594
3677
|
|
|
3595
3678
|
function updateSessionActions() {
|
|
3596
3679
|
const active = state.view === 'view-chat' && !!state.current
|
|
3680
|
+
$('btn-subagents')?.classList.toggle('hidden', !active)
|
|
3597
3681
|
$('btn-rename-session')?.classList.toggle('hidden', !active)
|
|
3598
3682
|
$('btn-archive-session')?.classList.toggle('hidden', !active || state.archivedIds.includes(state.current))
|
|
3599
3683
|
$('ds-session-status')?.classList.toggle('hidden', !active || !recoveryLabel())
|
|
@@ -3947,6 +4031,7 @@ async function start() {
|
|
|
3947
4031
|
}
|
|
3948
4032
|
$('token-desc').textContent = state.token ? '● ' + state.token.slice(0, 12) + '…' : t('ds.toastAuth')
|
|
3949
4033
|
bindUi()
|
|
4034
|
+
window.DshImagePreview?.configure?.({ resolvePath: chatImageRequest })
|
|
3950
4035
|
if (!state.token) { showView('view-settings'); $('desktop-token-input').focus() }
|
|
3951
4036
|
renderWorkbench()
|
|
3952
4037
|
updateConn()
|
|
@@ -3984,6 +4069,7 @@ function mountWorkflowDesktop() {
|
|
|
3984
4069
|
},
|
|
3985
4070
|
command:runSlashCommand,send:sendMessage,refresh:refreshSessions,retry:()=>{startOverviewDetection(true);void refreshSessions()},
|
|
3986
4071
|
operations:()=>{const connection=captureConnection();return {url:apiUrl,headers:{authorization:'Bearer '+connection.token},valid:connection.valid}},
|
|
4072
|
+
relay:()=>{const connection=captureConnection();return {url:()=>apiUrl('/admin/api/relay'),headers:{authorization:'Bearer '+connection.token},valid:connection.valid,connected:!!connection.token}},
|
|
3987
4073
|
discover:()=>{if(confirm('登记当前绑定目录下的子目录为工作区?'))void refreshWorkbench({discover:true})},
|
|
3988
4074
|
files:()=>{const cwd=sessionCwd(state.byId.get(state.current));if(!cwd)return toast('当前会话没有工作目录','err');state.fs.loaded=true;showView('view-files');void loadFs(cwd,true)},
|
|
3989
4075
|
admin:()=>window.open(new URL(apiUrl('/admin/'),location.href).href,'_blank','noopener,noreferrer'),
|
package/public/extensions.js
CHANGED
|
@@ -84,7 +84,8 @@ window.DshExtensions = (() => {
|
|
|
84
84
|
if(!available[route]){navigate('manage');return}
|
|
85
85
|
if(s.route==='manage'){s.scroller=scrollParent(root);s.scroll=s.scroller?.scrollTop||0;window.DshPluginCenter?.pause()}
|
|
86
86
|
}
|
|
87
|
-
stopViews();s.route=route;view.replaceChildren();header.hidden=route==='manage';manager.hidden=route!=='manage';view.hidden=route==='manage';root.className='ext-page'+(route==='manage'?' is-manage':'')
|
|
87
|
+
stopViews();s.route=route;view.replaceChildren();header.hidden=route==='manage'&&!config.back;manager.hidden=route!=='manage';view.hidden=route==='manage';root.className='ext-page'+(route==='manage'?' is-manage':'')
|
|
88
|
+
back.textContent=route==='manage'?(window.I18N?.lang==='en'?'← Back to More':'← 返回更多'):(window.I18N?.lang==='en'?'← Back to plugins':'← 返回插件列表')
|
|
88
89
|
if(route==='manage'){
|
|
89
90
|
if(!s.mounted){s.mounted=true;await window.DshPluginCenter.mount({...config,onFeature:navigate},manager)}
|
|
90
91
|
else {if(s.scroller)s.scroller.scrollTop=s.scroll;void window.DshPluginCenter.resume()}
|
|
@@ -92,7 +93,7 @@ window.DshExtensions = (() => {
|
|
|
92
93
|
else window.DshInsights.mount({tab:'cost',hostOverview:true,allowedTabs:['cost'],connection:config.connection,url:config.url},view)
|
|
93
94
|
if(valid()&&route!=='manage')config.scrollTop?.()
|
|
94
95
|
}
|
|
95
|
-
back.addEventListener('click',()=>{if(valid())void navigate('manage')})
|
|
96
|
+
back.addEventListener('click',()=>{if(valid()){if(s.route==='manage')config.back?.();else void navigate('manage')}})
|
|
96
97
|
void navigate('manage').then(()=>{if(initial!=='manage'&&initial!=='home'&&valid())void navigate(initial)})
|
|
97
98
|
}
|
|
98
99
|
function scrollParent(el) {
|