@xiangyixie/dsh-superagent 0.19.0 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -1
- package/lib/client.js +788 -314
- package/lib/console.js +108 -17
- package/lib/goal.js +1 -1
- package/lib/index.js +275 -86
- package/lib/long-goal.js +39 -15
- package/lib/orchestrator.js +25 -15
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* dsh-superagent — browser half.
|
|
3
3
|
*
|
|
4
4
|
* The "超级智能体" entry opens a main panel that is rendered natively inside
|
|
5
|
-
* the host React tree: host primitives (Button,
|
|
5
|
+
* the host React tree: host primitives (Button, MarkdownText, the host icon set)
|
|
6
6
|
* plus the host's measured geometry, so the panel reads as one of the shell's
|
|
7
7
|
* own spaces. Nothing is framed: the page never carries its own chrome.
|
|
8
8
|
*
|
|
@@ -60,12 +60,27 @@ window.__ModuleLoader__.load({
|
|
|
60
60
|
&& (value.$$typeof === Symbol.for('react.memo') || value.$$typeof === Symbol.for('react.forward_ref')))
|
|
61
61
|
const pick = name => (isComponent(ui?.[name]) ? ui[name] : null)
|
|
62
62
|
const Button = pick('Button')
|
|
63
|
-
const FishLogo = pick('FishLogo')
|
|
64
63
|
const MarkdownText = pick('MarkdownText')
|
|
65
64
|
const UserMessageBubble = pick('UserMessageBubble')
|
|
66
65
|
const StateDot = pick('StateDot')
|
|
67
66
|
const Tooltip = pick('Tooltip')
|
|
68
|
-
|
|
67
|
+
// Host process rows and surfaces: reasoning/tool rows, activity text, the
|
|
68
|
+
// transient notice, inline fields, option capsules, document previews and
|
|
69
|
+
// the file glyphs all exist in the primitives package, so the panel never
|
|
70
|
+
// draws a near-copy of them.
|
|
71
|
+
const DisclosureRow = pick('DisclosureRow')
|
|
72
|
+
const TextShimmer = pick('TextShimmer')
|
|
73
|
+
const Toast = pick('Toast')
|
|
74
|
+
const Input = pick('Input')
|
|
75
|
+
const Pill = pick('Pill')
|
|
76
|
+
const Tag = pick('Tag')
|
|
77
|
+
const FileTypeIcon = pick('FileTypeIcon')
|
|
78
|
+
const QuotePreview = pick('QuotePreview')
|
|
79
|
+
const DetailDocument = pick('DetailDocument')
|
|
80
|
+
const CodeBlock = pick('CodeBlock')
|
|
81
|
+
const MISSING_PRIMITIVES = ['Button', 'MarkdownText', 'UserMessageBubble', 'StateDot', 'Tooltip',
|
|
82
|
+
'DisclosureRow', 'TextShimmer', 'Toast', 'Input', 'Pill', 'Tag', 'FileTypeIcon',
|
|
83
|
+
'QuotePreview', 'DetailDocument', 'CodeBlock']
|
|
69
84
|
.filter(name => !pick(name))
|
|
70
85
|
if (!ui) {
|
|
71
86
|
console.warn('[dsh-superagent] host primitives module is absent; assistant text renders as plain text')
|
|
@@ -81,6 +96,13 @@ window.__ModuleLoader__.load({
|
|
|
81
96
|
close: ui?.IconCloseOutlineRegular ?? ui?.IconCloseOutlineMedium,
|
|
82
97
|
folder: ui?.IconFolderCloseRegular ?? ui?.IconFolderCloseMedium,
|
|
83
98
|
panel: ui?.IconPanelLeftOutlineRegular ?? ui?.IconPanelLeftOutlineMedium,
|
|
99
|
+
// The host's own glyphs for the three process rows the panel shows.
|
|
100
|
+
think: ui?.IconThinkOutlineRegular ?? ui?.IconThinkOutlineMedium,
|
|
101
|
+
code: ui?.IconCodeOutlineRegular ?? ui?.IconCodeOutlineMedium,
|
|
102
|
+
question: ui?.IconQuestionOutlineRegular ?? ui?.IconQuestionOutlineMedium,
|
|
103
|
+
attach: ui?.IconPaperclipOutlineRegular ?? ui?.IconPaperclipOutlineMedium,
|
|
104
|
+
checklist: ui?.IconChecklistOutlineRegular ?? ui?.IconChecklistOutlineMedium,
|
|
105
|
+
plus: ui?.IconPlusOutlineRegular ?? ui?.IconPlusOutlineMedium,
|
|
84
106
|
}
|
|
85
107
|
// MarkdownText reads `labels.code` on every fenced block, so the host
|
|
86
108
|
// component is only safe with this shape filled in.
|
|
@@ -96,13 +118,20 @@ window.__ModuleLoader__.load({
|
|
|
96
118
|
},
|
|
97
119
|
footnotes: '脚注',
|
|
98
120
|
}
|
|
121
|
+
/** DetailDocument chrome; same markdown labels as assistant prose. */
|
|
122
|
+
const DETAIL_LABELS = {
|
|
123
|
+
title: '产物内容',
|
|
124
|
+
loading: '正在读取产物…',
|
|
125
|
+
retry: '重试',
|
|
126
|
+
markdown: MARKDOWN_LABELS,
|
|
127
|
+
}
|
|
99
128
|
/** Composer delivery behaviour: idle sends start a turn, running sends steer. */
|
|
100
129
|
const RAIL_KEY = 'dsh-superagent.rail-open'
|
|
101
130
|
function readRailOpen() {
|
|
102
131
|
try {
|
|
103
|
-
return window.localStorage.getItem(RAIL_KEY)
|
|
132
|
+
return window.localStorage.getItem(RAIL_KEY) !== '0'
|
|
104
133
|
} catch (error) {
|
|
105
|
-
return
|
|
134
|
+
return true
|
|
106
135
|
}
|
|
107
136
|
}
|
|
108
137
|
function saveRailOpen(open) {
|
|
@@ -152,134 +181,167 @@ window.__ModuleLoader__.load({
|
|
|
152
181
|
}
|
|
153
182
|
: null
|
|
154
183
|
|
|
155
|
-
/**
|
|
156
|
-
* One class sheet for the panel. Every value is copied from the host's own
|
|
157
|
-
* modules: header 76px / 10-28-0-20, sidebar rows 32px / radius 12 / 5px 9px,
|
|
158
|
-
* hero title 26-32 / 500, hero pad 0 24, composer card radius 28, input
|
|
159
|
-
* 4-8-0-14 with a 36px docked floor and 52px hero floor, toolbar 2-8-6 with
|
|
160
|
-
* 12px gaps, send 34px circle on button-info-fill, stats row 22px.
|
|
161
|
-
*/
|
|
162
184
|
const CSS = `
|
|
163
|
-
.dsa-root{--dsa-col:var(--dsh-chat-content-width,clamp(680px,calc(var(--dsh-conversation-column-width,100%) * .64),920px));display:flex;flex-direction:column;height:100%;min-width:0;background:var(--dsw-alias-bg-base
|
|
164
|
-
|
|
165
|
-
.
|
|
166
|
-
|
|
167
|
-
.dsa-
|
|
168
|
-
.dsa-
|
|
169
|
-
.dsa-
|
|
170
|
-
.dsa-
|
|
185
|
+
.dsa-root{--dsa-col:var(--dsh-chat-content-width,clamp(680px,calc(var(--dsh-conversation-column-width,100%) * .64),920px));--dsa-side:var(--dsh-composer-side-clearance,32px);display:flex;flex-direction:column;height:100%;min-width:0;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);font-size:14px;line-height:22px}
|
|
186
|
+
/* Header geometry follows the host conversation header: 30px title cluster,
|
|
187
|
+
padding 4/8, 28px utilities, hairline below (ConversationRoot.module.css:76,
|
|
188
|
+
147-152 + InputBar.module.css:335-348). */
|
|
189
|
+
.dsa-header{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;min-height:40px;padding:10px 28px 0 20px;border-bottom:.5px solid var(--dsw-alias-border-l3)}
|
|
190
|
+
.dsa-header-title{display:flex;align-items:center;gap:4px;min-width:0;height:30px;box-sizing:border-box;padding:4px 8px;color:inherit;font:inherit;font-size:14px;font-weight:500;line-height:20px;border:0;border-radius:var(--dsw-radius-sm);background:none;cursor:pointer}
|
|
191
|
+
.dsa-header-title:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
192
|
+
.dsa-header-title span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
193
|
+
.dsa-iconbtn{position:relative;display:inline-flex;flex:none;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer}
|
|
171
194
|
.dsa-iconbtn svg{width:15px;height:15px}
|
|
172
|
-
.dsa-iconbtn:hover{background:var(--dsw-alias-interactive-bg-hover
|
|
173
|
-
.dsa-iconbtn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-alias-state-business-primary
|
|
174
|
-
.dsa-
|
|
175
|
-
.dsa-
|
|
176
|
-
.dsa-
|
|
177
|
-
.dsa-
|
|
178
|
-
.dsa-
|
|
179
|
-
.dsa-
|
|
195
|
+
.dsa-iconbtn:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
196
|
+
.dsa-iconbtn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-alias-state-business-primary);outline-offset:-2px}
|
|
197
|
+
.dsa-badge{position:absolute;top:-2px;right:-2px;min-width:14px;height:14px;padding:0 3px;border-radius:7px;background:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-label-on-color);font-size:9px;line-height:14px;font-weight:600;text-align:center;box-sizing:border-box}
|
|
198
|
+
.dsa-body{position:relative;display:grid;grid-template-columns:clamp(106px,14%,162px) minmax(0,1fr) 0;grid-template-rows:minmax(0,1fr);flex:1;min-height:0;overflow:hidden}
|
|
199
|
+
.dsa-body[data-rail=open]{grid-template-columns:clamp(106px,14%,162px) minmax(0,1fr) clamp(224px,31%,352px)}
|
|
200
|
+
.dsa-main{grid-column:2;grid-row:1;position:relative;display:flex;flex-direction:column;min-width:0;min-height:0}
|
|
201
|
+
.dsa-project-nav{grid-column:1;grid-row:1;min-width:0;overflow:auto;border-right:.5px solid var(--dsw-alias-border-l3);padding:8px 6px}
|
|
202
|
+
.dsa-project-nav .dsa-rowitem[data-current=true]{background:var(--dsw-alias-interactive-bg-hover)}
|
|
203
|
+
.dsa-project-head{display:flex;align-items:center;justify-content:space-between;padding:10px 8px 4px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
|
|
204
|
+
.dsa-project-add{display:grid;gap:4px;padding:5px 2px}
|
|
205
|
+
.dsa-project-add input{min-width:0;width:100%;box-sizing:border-box}
|
|
206
|
+
.dsa-msg .dsa-reply{opacity:0;display:block;margin:2px 0 0 auto}
|
|
207
|
+
.dsa-msg:hover .dsa-reply,.dsa-reply:focus-visible{opacity:1}
|
|
208
|
+
.dsa-quote{display:flex;gap:6px;align-items:center;margin:0 10px;padding:4px 7px;border-left:2px solid var(--dsw-alias-border-l3);font-size:12px;color:var(--dsw-alias-label-secondary)}
|
|
209
|
+
.dsa-quote span{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
210
|
+
.dsa-workbench{grid-column:3;grid-row:1;min-width:0;overflow:hidden;display:flex;flex-direction:column;border-left:.5px solid var(--dsw-alias-border-l3);background:var(--dsw-alias-bg-base)}
|
|
211
|
+
.dsa-body[data-rail=closed] .dsa-workbench{visibility:hidden}
|
|
212
|
+
/* 48px header bar, 14/20 500, hairline below — the host workspace browser
|
|
213
|
+
header (Rows.module.css:37). */
|
|
214
|
+
.dsa-workbench-head{display:flex;align-items:center;justify-content:space-between;gap:6px;flex:none;min-height:48px;padding:0 16px;border-bottom:.5px solid var(--dsw-alias-border-l3);font-size:14px;line-height:20px;font-weight:500}
|
|
215
|
+
.dsa-workbench-head form{display:flex;gap:4px;width:100%;min-width:0;padding:4px 0}
|
|
216
|
+
.dsa-workbench-head input{flex:1;min-width:0}
|
|
217
|
+
.dsa-workbench-scroll{flex:1;min-height:0;overflow:auto;padding:8px 10px}
|
|
218
|
+
.dsa-workbench-section{padding:8px 0}
|
|
219
|
+
.dsa-workbench-section+.dsa-workbench-section{border-top:.5px solid var(--dsw-alias-border-l3)}
|
|
220
|
+
.dsa-workbench-section h3{margin:0 8px 4px;font-size:12px;line-height:18px;font-weight:500;color:var(--dsw-alias-label-tertiary)}
|
|
221
|
+
.dsa-workbench-empty{padding:4px 8px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
|
|
222
|
+
.dsa-workbench .dsa-detail{position:relative;inset:auto;width:auto;max-width:none;flex:1;min-height:0;box-shadow:none;border:0;border-radius:0;background:transparent}
|
|
223
|
+
.dsa-workbench .dsa-detail-body{min-height:0}
|
|
224
|
+
@media(max-width:740px){.dsa-body[data-rail=open]{grid-template-columns:clamp(106px,14%,162px) minmax(0,1fr) 0}.dsa-workbench{position:absolute;grid-column:1/-1;inset:0 0 0 auto;width:min(300px,72%);z-index:10;background:var(--dsw-alias-bg-base)}.dsa-scroll{padding:0 14px}}
|
|
180
225
|
.dsa-scroll{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;margin-right:2px;padding:0 32px;scrollbar-gutter:stable}
|
|
181
226
|
.dsa-scroll::-webkit-scrollbar{width:10px}
|
|
182
|
-
.dsa-scroll::-webkit-scrollbar-thumb{border-radius:5px;background:var(--dsw-alias-scrollbar-bg-l1
|
|
227
|
+
.dsa-scroll::-webkit-scrollbar-thumb{border-radius:5px;background:var(--dsw-alias-scrollbar-bg-l1)}
|
|
183
228
|
.dsa-flow{width:min(100%,var(--dsa-col));margin:0 auto;padding:16px 0 8px;box-sizing:border-box}
|
|
184
|
-
|
|
185
|
-
.
|
|
186
|
-
.dsa-hero
|
|
187
|
-
.dsa-hero-
|
|
188
|
-
.dsa-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
.dsa-
|
|
193
|
-
.dsa-
|
|
229
|
+
/* New-space hero: 26/32 500 headline and a 12px stack, the host new-session
|
|
230
|
+
hero (HeroShell.module.css:15-45, 122-130). */
|
|
231
|
+
.dsa-hero{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:56px 24px;text-align:center}
|
|
232
|
+
.dsa-hero-title{font-size:26px;line-height:32px;font-weight:500;color:var(--dsw-alias-label-primary)}
|
|
233
|
+
.dsa-hero-desc{max-width:420px;font-size:14px;line-height:24px;color:var(--dsw-alias-label-secondary)}
|
|
234
|
+
/* Composer card: InputBar.module.css:54-86 (radius panel, elevation-soft
|
|
235
|
+
hairline, 8px top pad, 12px stack gap) and :273-289/335-417 (toolbar row,
|
|
236
|
+
28px attach circle, 34px send circle). */
|
|
237
|
+
.dsa-composer{flex:none;padding:4px var(--dsa-side) 4px;background:var(--dsw-alias-bg-base)}
|
|
238
|
+
.dsa-card{display:flex;flex-direction:column;gap:12px;box-sizing:border-box;width:100%;max-width:var(--dsh-composer-card-max-width,calc(var(--dsa-col) + 32px));margin:0 auto;padding-top:8px;border:0;--dsw-elevation-stroke-color:var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-panel);background:var(--dsw-specific-input-major);box-shadow:var(--dsw-elevation-soft)}
|
|
239
|
+
.dsa-input{box-sizing:border-box;width:100%;min-height:36px;max-height:var(--dsh-composer-text-max-height,336px);padding:4px 8px 0 14px;border:0;outline:none;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));caret-color:var(--dsw-alias-state-business-primary);resize:none;overflow-y:auto}
|
|
240
|
+
.dsa-input::placeholder{color:var(--dsw-alias-label-caption)}
|
|
241
|
+
.dsa-row{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px;padding:2px 8px 6px;min-width:0}
|
|
194
242
|
.dsa-trailing{display:flex;align-items:center;min-width:0;gap:12px}
|
|
195
243
|
.dsa-trailing{margin-left:auto;flex:none}
|
|
196
|
-
.dsa-
|
|
197
|
-
.dsa-
|
|
198
|
-
.dsa-
|
|
199
|
-
.dsa-
|
|
244
|
+
.dsa-goals{flex:none;width:min(100%,var(--dsa-col));max-height:40vh;overflow:auto;margin:0 auto;padding:0 0 8px}
|
|
245
|
+
.dsa-goals details{margin:4px 0;padding:6px 8px}
|
|
246
|
+
.dsa-goals summary{cursor:pointer;overflow-wrap:anywhere}
|
|
247
|
+
.dsa-goal-phase{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:4px 0}
|
|
248
|
+
.dsa-goal-actions{display:flex;align-items:center;flex-wrap:wrap;gap:6px}
|
|
249
|
+
.dsa-instruction{display:grid;gap:6px}
|
|
250
|
+
.dsa-add{display:grid;place-items:center;flex:none;width:28px;height:28px;border:0;border-radius:999px;background:var(--dsw-specific-selector);color:var(--dsw-alias-label-primary);cursor:pointer}
|
|
251
|
+
.dsa-add:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid)}
|
|
252
|
+
.dsa-add:disabled{opacity:.5;cursor:default}
|
|
253
|
+
.dsa-add svg{width:16px;height:16px}
|
|
254
|
+
.dsa-send{display:grid;place-items:center;flex:none;width:34px;height:34px;border:0;border-radius:999px;background:var(--dsw-alias-button-info-fill);color:var(--dsw-alias-label-on-color);cursor:pointer;transform:translateY(-2px);transition:background-color 100ms ease}
|
|
255
|
+
.dsa-send:hover:not(:disabled){background:var(--dsw-alias-button-info-hover)}
|
|
200
256
|
.dsa-send:disabled{opacity:.4;cursor:default}
|
|
201
257
|
.dsa-send svg{width:15px;height:15px}
|
|
202
258
|
.dsa-send[data-mode=stop] svg{width:10px;height:10px;border-radius:2px}
|
|
203
|
-
.dsa-spin{width:14px;height:14px;border-radius:50%;border:2px solid
|
|
259
|
+
.dsa-spin{width:14px;height:14px;border-radius:50%;border:2px solid color-mix(in srgb,currentColor 30%,transparent);border-top-color:currentColor;animation:dsa-spin .8s linear infinite}
|
|
204
260
|
@keyframes dsa-spin{to{transform:rotate(360deg)}}
|
|
205
|
-
.dsa-stats{min-height:calc(22px + var(--dsh-content-font-delta-secondary,0px));display:flex;align-items:center;justify-content:center;gap:10px;font-size:12px;line-height:20px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
|
|
206
261
|
.dsa-msg{padding:0 0 4px}
|
|
207
|
-
.
|
|
208
|
-
|
|
262
|
+
/* User row: 70.2% of the content column, capped at 82% (MessageItem.module.css:20);
|
|
263
|
+
the bubble itself is the host UserMessageBubble — this width is its owner's. */
|
|
264
|
+
.dsa-user{display:flex;flex-direction:column;align-items:flex-end;gap:8px;margin-bottom:16px}
|
|
265
|
+
.dsa-user > *{max-width:min(calc(var(--dsa-col) * .702),82%)}
|
|
266
|
+
.dsa-bubble{box-sizing:border-box;max-width:min(calc(var(--dsa-col) * .702),82%);padding:10px 16px;border-radius:var(--dsw-radius-xl);background:var(--dsw-specific-bubble);color:var(--dsw-alias-label-primary);font-size:var(--dsh-content-font-size,14px);line-height:calc(22px + var(--dsh-content-font-delta,0px));white-space:pre-wrap;word-break:break-word}
|
|
209
267
|
.dsa-bubble[data-pending=true]{opacity:.6}
|
|
210
|
-
.dsa-assistant{display:flex;flex-direction:column;gap:
|
|
268
|
+
.dsa-assistant{display:flex;flex-direction:column;gap:12px;margin-bottom:16px;font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));overflow-wrap:anywhere}
|
|
211
269
|
.dsa-md-plain{white-space:pre-wrap;overflow-wrap:anywhere}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
.dsa-
|
|
215
|
-
.dsa-
|
|
216
|
-
.dsa-
|
|
217
|
-
.dsa-
|
|
218
|
-
.dsa-
|
|
219
|
-
.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
.dsa-approval
|
|
223
|
-
.dsa-approval-
|
|
224
|
-
.dsa-
|
|
225
|
-
.dsa-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
.dsa-rail-count{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
|
|
234
|
-
.dsa-rowdot{flex:none;width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-label-caption,rgb(129,133,140))}
|
|
235
|
-
.dsa-rowdot[data-status=running]{background:var(--dsw-alias-state-success-primary,#22c55e)}
|
|
236
|
-
.dsa-rowdot[data-status=waiting]{background:var(--dsw-alias-state-warning-primary,#ffc140)}
|
|
237
|
-
.dsa-rowdot[data-status=stopped]{background:var(--dsw-alias-state-warn-primary,#f59e0b)}
|
|
238
|
-
.dsa-rail-head{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:6px 8px;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
|
|
239
|
-
.dsa-rail-list{display:flex;flex:1;flex-direction:column;gap:2px;min-height:0;overflow-y:auto;margin-bottom:8px}
|
|
240
|
-
.dsa-rowitem{display:flex;align-items:center;gap:6px;box-sizing:border-box;width:100%;height:32px;padding:0 8px 0 9px;border:0;border-radius:var(--dsw-radius-md,12px);background:transparent;color:var(--dsw-alias-label-primary,#f9fafb);font:inherit;font-size:14px;line-height:20px;text-align:left;cursor:default}
|
|
270
|
+
/* Process rows are the host DisclosureRow (24px header, tertiary ink); the
|
|
271
|
+
nested body keeps the host's 22px indent (MessageItem.module.css:233). */
|
|
272
|
+
.dsa-proc{display:flex;flex-direction:column;gap:2px;margin:-4px 0 0}
|
|
273
|
+
.dsa-proc-body{margin:2px 0 6px;padding:0 0 0 calc(22px + var(--dsh-content-font-delta,0px));font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere}
|
|
274
|
+
.dsa-proc-code{margin:0 0 6px;padding-left:calc(22px + var(--dsh-content-font-delta,0px))}
|
|
275
|
+
.dsa-typing{display:inline-flex;align-items:center;gap:8px;padding:2px 0 12px;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary)}
|
|
276
|
+
.dsa-approvals{display:flex;flex-direction:column;gap:8px;width:min(calc(100% - 64px),var(--dsa-col));margin:0 auto;padding:8px 0 12px}
|
|
277
|
+
/* Approval takeover: ApprovalPanel.module.css:1-18 (warn-secondary border,
|
|
278
|
+
xl radius, input-major fill, lv2 shadow), :20-29 strip, :31-46 body,
|
|
279
|
+
:155-168 command + action row. */
|
|
280
|
+
.dsa-approval{display:flex;flex-direction:column;overflow:hidden;width:100%;border:1px solid var(--dsw-alias-state-warn-secondary);border-radius:var(--dsw-radius-xl);background:var(--dsw-specific-input-major);box-shadow:var(--dsw-shadow-lv2)}
|
|
281
|
+
.dsa-approval-bar{display:flex;align-items:center;gap:8px;padding:10px 16px;background:var(--dsw-alias-state-warn-tertiary);color:var(--dsw-alias-state-warn-primary);font-size:13px;line-height:18px}
|
|
282
|
+
.dsa-approval-main{display:flex;flex-direction:column;gap:6px;padding:12px 16px 0}
|
|
283
|
+
.dsa-approval-title{font-size:15px;font-weight:500;line-height:24px;color:var(--dsw-alias-label-primary)}
|
|
284
|
+
.dsa-approval-body{font-family:var(--ds-font-family-code);font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary);word-break:break-all;overflow-wrap:anywhere}
|
|
285
|
+
.dsa-approval-actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;padding:14px 16px}
|
|
286
|
+
.dsa-rowdot{flex:none;width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-label-caption)}
|
|
287
|
+
/* 32px host row (Rows.module.css): 14/20 title, 10/16 tertiary trailing. */
|
|
288
|
+
.dsa-rowitem{display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:32px;padding:0 8px;border:0;border-radius:var(--dsw-radius-md);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:14px;line-height:20px;text-align:left;cursor:pointer}
|
|
289
|
+
.dsa-rowitem:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
241
290
|
.dsa-rowtitle{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
242
|
-
.dsa-rowtime{flex:none;font-size:10px;line-height:16px;color:var(--dsw-alias-label-tertiary
|
|
243
|
-
.dsa-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:
|
|
244
|
-
.dsa-note{font-size:
|
|
245
|
-
.dsa-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-caption
|
|
246
|
-
.dsa-toast{display:flex;align-items:center;gap:8px;margin:8px auto 0;width:min(calc(100% - 64px),var(--dsa-col));padding:
|
|
247
|
-
.dsa-toast[data-kind=err]{color:var(--dsw-alias-state-error-primary
|
|
248
|
-
.dsa-sessions{position:absolute;top:
|
|
249
|
-
.dsa-sessions-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:4px
|
|
250
|
-
.dsa-sessions-new,.dsa-linkbtn{border:0;background:transparent;color:var(--dsw-alias-state-business-primary
|
|
251
|
-
.dsa-sessions-new:hover,.dsa-linkbtn:hover{background:var(--dsw-alias-interactive-bg-hover
|
|
291
|
+
.dsa-rowtime{flex:none;font-size:10px;line-height:16px;color:var(--dsw-alias-label-tertiary);margin-inline-end:-1px}
|
|
292
|
+
.dsa-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;height:100%;padding:24px;text-align:center}
|
|
293
|
+
.dsa-note{font-size:14px;line-height:22px;color:var(--dsw-alias-label-secondary)}
|
|
294
|
+
.dsa-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-caption)}
|
|
295
|
+
.dsa-toast{display:flex;align-items:center;gap:8px;margin:8px auto 0;width:min(calc(100% - 64px),var(--dsa-col));padding:4px 8px;border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}
|
|
296
|
+
.dsa-toast[data-kind=err]{color:var(--dsw-alias-state-error-primary)}
|
|
297
|
+
.dsa-sessions{position:absolute;top:44px;right:12px;z-index:30;display:flex;flex-direction:column;width:min(300px,80vw);max-height:min(60vh,440px);padding:8px;border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-menu-surface-fill,var(--dsw-alias-bg-elevated,var(--dsw-alias-bg-base)));box-shadow:var(--dsw-elevation-panel)}
|
|
298
|
+
.dsa-sessions-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:4px 8px 8px;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary)}
|
|
299
|
+
.dsa-sessions-new,.dsa-linkbtn{border:0;background:transparent;color:var(--dsw-alias-state-business-primary);font:inherit;font-size:12px;line-height:18px;cursor:pointer;padding:2px 6px;border-radius:var(--dsw-radius-sm)}
|
|
300
|
+
.dsa-sessions-new:hover,.dsa-linkbtn:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
252
301
|
.dsa-sessions-list{display:flex;flex-direction:column;gap:2px;min-height:0;overflow-y:auto}
|
|
253
|
-
.dsa-session-row{
|
|
254
|
-
.dsa-session-row[data-current=true]{background:var(--dsw-alias-interactive-bg-hover
|
|
255
|
-
.dsa-session-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:
|
|
256
|
-
.dsa-session-meta{flex:none;font-size:10px;line-height:16px;color:var(--dsw-alias-label-tertiary
|
|
302
|
+
.dsa-session-row{cursor:pointer}
|
|
303
|
+
.dsa-session-row[data-current=true]{background:var(--dsw-alias-interactive-bg-hover)}
|
|
304
|
+
.dsa-session-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;line-height:20px}
|
|
305
|
+
.dsa-session-meta,.dsa-session-row .dsa-rowtime{flex:none;font-size:10px;line-height:16px;color:var(--dsw-alias-label-tertiary)}
|
|
257
306
|
.dsa-sessions-foot{display:flex;justify-content:flex-end;padding-top:6px}
|
|
258
|
-
|
|
259
|
-
.
|
|
260
|
-
.dsa-detail
|
|
261
|
-
.dsa-detail-
|
|
307
|
+
/* Right-hand detail surface: 48px bar + 16px body rhythm, the host panel
|
|
308
|
+
header geometry (Rows.module.css:37) and section spacing. */
|
|
309
|
+
.dsa-detail{position:absolute;inset:0;z-index:20;display:flex;flex-direction:column;background:var(--dsw-alias-bg-base)}
|
|
310
|
+
.dsa-detail-head{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:48px;padding:0 16px;border-bottom:.5px solid var(--dsw-alias-border-l3)}
|
|
311
|
+
.dsa-detail-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;line-height:20px;font-weight:500}
|
|
312
|
+
.dsa-detail-body{flex:1;min-height:0;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:16px}
|
|
262
313
|
.dsa-detail-sec{display:flex;flex-direction:column;gap:6px}
|
|
263
|
-
.dsa-detail-label{font-size:
|
|
264
|
-
.dsa-detail-item{display:flex;flex-direction:column;gap:
|
|
265
|
-
.dsa-detail-q{font-size:
|
|
266
|
-
.dsa-answer-row{display:flex;gap:
|
|
267
|
-
.dsa-answer-
|
|
268
|
-
.dsa-
|
|
269
|
-
.dsa-
|
|
270
|
-
.dsa-
|
|
271
|
-
.dsa-
|
|
272
|
-
.dsa-
|
|
273
|
-
.dsa-
|
|
274
|
-
.
|
|
314
|
+
.dsa-detail-label{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
|
|
315
|
+
.dsa-detail-item{display:flex;flex-direction:column;gap:6px;padding:10px 12px;border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover)}
|
|
316
|
+
.dsa-detail-q{font-size:14px;line-height:22px;color:var(--dsw-alias-label-primary);white-space:pre-wrap}
|
|
317
|
+
.dsa-answer-row{display:flex;align-items:center;gap:8px}
|
|
318
|
+
.dsa-answer-row > span{flex:1;min-width:0}
|
|
319
|
+
.dsa-answer-input{flex:1;min-width:0;box-sizing:border-box;height:32px;padding:0 10px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:20px;outline:none}
|
|
320
|
+
.dsa-answer-input:focus{border-color:var(--dsw-alias-state-business-primary)}
|
|
321
|
+
.dsa-artifact-link{display:flex;align-items:center;gap:6px;box-sizing:border-box;width:100%;height:32px;padding:0 8px;border:0;border-radius:var(--dsw-radius-md);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:20px;text-align:left;cursor:pointer;overflow:hidden}
|
|
322
|
+
.dsa-artifact-link:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
323
|
+
.dsa-artifact-link svg{flex:none}
|
|
324
|
+
.dsa-artifact-link span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
325
|
+
/* Attention / plan card: PlanReviewPanel.module.css:1-21 frame + surface,
|
|
326
|
+
:28-39 tinted strip, :64-88 summary, :41-62 footer actions. */
|
|
327
|
+
.dsa-attention{display:flex;flex-direction:column;gap:8px;width:min(calc(100% - 64px),var(--dsa-col));margin:0 auto;padding:6px 0 10px}
|
|
328
|
+
.dsa-attention-card{display:flex;flex-direction:column;overflow:hidden;box-sizing:border-box;width:100%;--dsw-elevation-stroke-color:var(--dsw-alias-border-l2);border:0;border-radius:var(--dsw-radius-xl);background:var(--dsw-specific-input-major);box-shadow:var(--dsw-elevation-panel);color:var(--dsw-alias-label-primary)}
|
|
329
|
+
.dsa-attention-head{display:flex;align-items:center;flex:none;gap:8px;padding:12px 16px;background:var(--dsw-alias-state-warn-tertiary);color:var(--dsw-alias-state-warn-primary);font-size:14px;line-height:20px}
|
|
330
|
+
.dsa-attention-head .dsa-session-meta{margin-left:auto;color:var(--dsw-alias-state-warn-primary)}
|
|
331
|
+
.dsa-attention-dot{width:7px;height:7px;border-radius:50%;background:var(--dsw-alias-state-warn-primary)}
|
|
332
|
+
.dsa-attention-summary{min-width:0;padding:14px 16px 12px;display:flex;flex-direction:column;gap:8px}
|
|
333
|
+
.dsa-attention-title{font-size:15px;font-weight:500;line-height:22px;overflow:hidden;text-overflow:ellipsis}
|
|
334
|
+
.dsa-attention-desc{color:var(--dsw-alias-label-secondary);font-size:14px;line-height:24px}
|
|
335
|
+
.dsa-attention-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 16px 12px}
|
|
336
|
+
.dsa-attention-options{display:flex;flex-wrap:wrap;gap:8px}
|
|
275
337
|
.dsa-artifact-row{display:flex;align-items:center;gap:4px}
|
|
276
338
|
.dsa-artifact-row .dsa-artifact-link{flex:1;min-width:0;overflow:hidden}
|
|
277
|
-
.dsa-preview{border
|
|
278
|
-
.dsa-preview-img{display:block;max-width:100%;border-radius:var(--dsw-radius-sm
|
|
279
|
-
.dsa-preview-frame{width:100%;height:320px;border:0;border-radius:var(--dsw-radius-sm
|
|
280
|
-
.dsa-preview-text{max-height:320px;overflow:auto;white-space:pre-wrap;word-break:break-word;font:inherit;font-size:
|
|
281
|
-
.dsa-chip{padding:
|
|
282
|
-
.dsa-chip:hover{background:var(--dsw-alias-interactive-bg-hover
|
|
339
|
+
.dsa-preview{display:flex;flex-direction:column;gap:12px;padding:12px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-base)}
|
|
340
|
+
.dsa-preview-img{display:block;max-width:100%;border-radius:var(--dsw-radius-sm)}
|
|
341
|
+
.dsa-preview-frame{width:100%;height:320px;border:0;border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-base)}
|
|
342
|
+
.dsa-preview-text{max-height:320px;overflow:auto;white-space:pre-wrap;word-break:break-word;font:inherit;font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary)}
|
|
343
|
+
.dsa-chip{height:28px;padding:0 12px;border:0;border-radius:999px;background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:20px;cursor:pointer}
|
|
344
|
+
.dsa-chip:hover{background:var(--dsw-alias-interactive-bg-hover-solid)}
|
|
283
345
|
`
|
|
284
346
|
|
|
285
347
|
/** Inject the sheet once; the panel is mounted once per window. */
|
|
@@ -295,7 +357,7 @@ window.__ModuleLoader__.load({
|
|
|
295
357
|
/** Host icon, or nothing when the primitives module is absent. */
|
|
296
358
|
function Icon(props) {
|
|
297
359
|
const component = ICONS[props.of]
|
|
298
|
-
if (
|
|
360
|
+
if (!isComponent(component)) return null
|
|
299
361
|
return h(component, { size: props.size ?? 16, className: props.className })
|
|
300
362
|
}
|
|
301
363
|
|
|
@@ -349,6 +411,12 @@ window.__ModuleLoader__.load({
|
|
|
349
411
|
messages: [],
|
|
350
412
|
approvals: [],
|
|
351
413
|
runs: [],
|
|
414
|
+
goals: [],
|
|
415
|
+
workbench: null,
|
|
416
|
+
workbenchRun: null,
|
|
417
|
+
workerSession: null,
|
|
418
|
+
reply: null,
|
|
419
|
+
goalBusy: false,
|
|
352
420
|
toast: null,
|
|
353
421
|
canceling: false,
|
|
354
422
|
approvalBusy: {},
|
|
@@ -363,6 +431,7 @@ window.__ModuleLoader__.load({
|
|
|
363
431
|
answerDraft: '',
|
|
364
432
|
preview: null,
|
|
365
433
|
previewText: '',
|
|
434
|
+
previewError: '',
|
|
366
435
|
previewBusy: false,
|
|
367
436
|
uploadInsert: '',
|
|
368
437
|
uploading: false,
|
|
@@ -549,6 +618,11 @@ window.__ModuleLoader__.load({
|
|
|
549
618
|
sessionId: frame.sessionId,
|
|
550
619
|
messages: [],
|
|
551
620
|
approvals: [],
|
|
621
|
+
runs: [],
|
|
622
|
+
goals: [],
|
|
623
|
+
workbenchRun: null,
|
|
624
|
+
workerSession: null,
|
|
625
|
+
reply: null,
|
|
552
626
|
approvalBusy: {},
|
|
553
627
|
currentId: null,
|
|
554
628
|
typing: false,
|
|
@@ -601,18 +675,23 @@ window.__ModuleLoader__.load({
|
|
|
601
675
|
return model
|
|
602
676
|
}
|
|
603
677
|
case 'runs': {
|
|
678
|
+
if (frame.sessionId && model.sessionId && frame.sessionId !== model.sessionId) return model
|
|
604
679
|
const runs = Array.isArray(frame.runs) ? frame.runs : []
|
|
605
|
-
const
|
|
680
|
+
const goals = Array.isArray(frame.goals) ? frame.goals : []
|
|
681
|
+
const update = model.detail ? runs.find(run => run.id === model.detail.id) : null
|
|
682
|
+
const sameReport = update?.reportTruncated && model.detail?.report?.startsWith(update.report)
|
|
683
|
+
const detail = update ? { ...update, report: sameReport ? model.detail.report : update.report } : model.detail
|
|
606
684
|
const seen = Array.isArray(model.seenAttention) ? model.seenAttention : []
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
685
|
+
const ids = new Set([
|
|
686
|
+
...runs.flatMap(run => (run.attention ?? []).map(item => `${run.id}:${item.id}`)),
|
|
687
|
+
...goals.flatMap(goal => (goal.decisions ?? []).map(item => item.source?.attentionId
|
|
688
|
+
? `${item.source.runId}:${item.source.attentionId}` : `${goal.id}:${item.id}`)),
|
|
689
|
+
])
|
|
690
|
+
const fresh = [...ids].filter(id => !seen.includes(id))
|
|
613
691
|
return {
|
|
614
692
|
...model,
|
|
615
693
|
runs,
|
|
694
|
+
goals,
|
|
616
695
|
detail,
|
|
617
696
|
unread: model.unread + fresh.length,
|
|
618
697
|
seenAttention: fresh.length > 0 ? [...seen, ...fresh].slice(-200) : seen,
|
|
@@ -626,29 +705,19 @@ window.__ModuleLoader__.load({
|
|
|
626
705
|
}
|
|
627
706
|
|
|
628
707
|
function Header(props) {
|
|
629
|
-
const {
|
|
630
|
-
const toggleLabel = railOpen ? '
|
|
708
|
+
const { title, railOpen, onToggleRail, onToggleSessions, sessionsOpen, unread } = props
|
|
709
|
+
const toggleLabel = railOpen ? '收起工作台' : '打开工作台'
|
|
631
710
|
return h('header', { className: 'dsa-header' },
|
|
632
|
-
h('
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
unread > 0 ? h('span', { className: 'dsa-badge' }, unread > 9 ? '9+' : String(unread)) : null), 'bottom'),
|
|
643
|
-
tipped(toggleLabel, h('button', {
|
|
644
|
-
type: 'button',
|
|
645
|
-
className: 'dsa-iconbtn dsa-railtoggle',
|
|
646
|
-
'aria-label': runningCount > 0 ? `${toggleLabel},${runningCount} 条任务线运行中` : toggleLabel,
|
|
647
|
-
'aria-expanded': railOpen ? 'true' : 'false',
|
|
648
|
-
onClick: onToggleRail,
|
|
649
|
-
},
|
|
650
|
-
h(Icon, { of: 'panel' }),
|
|
651
|
-
runningCount > 0 ? h('span', { className: 'dsa-badge' }, runningCount > 9 ? '9+' : String(runningCount)) : null))))
|
|
711
|
+
h('button', {
|
|
712
|
+
type: 'button', className: 'dsa-header-title', title: `${toggleLabel}(Ctrl+Shift+B)`,
|
|
713
|
+
'aria-label': `${title},${toggleLabel}`, 'aria-expanded': railOpen, 'aria-controls': 'dsa-workbench',
|
|
714
|
+
onClick: onToggleRail,
|
|
715
|
+
}, h('span', null, title), h(Icon, { of: 'panel', size: 14 })),
|
|
716
|
+
tipped(unread ? `会话(${unread} 个新问题)` : '会话', h('button', {
|
|
717
|
+
type: 'button', className: 'dsa-iconbtn', 'aria-label': '会话', 'aria-expanded': sessionsOpen,
|
|
718
|
+
onClick: onToggleSessions,
|
|
719
|
+
}, h(Icon, { of: 'clock' }),
|
|
720
|
+
unread ? h('span', { className: 'dsa-badge' }, unread > 9 ? '9+' : String(unread)) : null), 'bottom'))
|
|
652
721
|
}
|
|
653
722
|
|
|
654
723
|
function UserMessage(props) {
|
|
@@ -659,25 +728,64 @@ window.__ModuleLoader__.load({
|
|
|
659
728
|
: h('div', { className: 'dsa-bubble', 'data-pending': pending ? 'true' : 'false' }, props.message.text))
|
|
660
729
|
}
|
|
661
730
|
|
|
731
|
+
/** One host process row (reasoning or tool call) with its own disclosure. */
|
|
732
|
+
function ProcessRow(props) {
|
|
733
|
+
const [open, setOpen] = react.useState(false)
|
|
734
|
+
const toggle = react.useCallback(() => setOpen(value => !value), [])
|
|
735
|
+
const body = props.body
|
|
736
|
+
const row = DisclosureRow
|
|
737
|
+
? h(DisclosureRow, {
|
|
738
|
+
icon: h(Icon, { of: props.icon, size: 16 }),
|
|
739
|
+
title: props.title,
|
|
740
|
+
open,
|
|
741
|
+
expandable: Boolean(body),
|
|
742
|
+
onToggle: toggle,
|
|
743
|
+
running: props.running === true,
|
|
744
|
+
}, body)
|
|
745
|
+
: h('div', { className: 'dsa-proc' },
|
|
746
|
+
h('button', {
|
|
747
|
+
type: 'button', className: 'dsa-rowitem', 'aria-expanded': open, disabled: !body,
|
|
748
|
+
onClick: toggle,
|
|
749
|
+
}, h(Icon, { of: props.icon, size: 16 }), h('span', { className: 'dsa-rowtitle' }, props.title)),
|
|
750
|
+
open && body ? body : null)
|
|
751
|
+
return row
|
|
752
|
+
}
|
|
753
|
+
|
|
662
754
|
function AssistantMessage(props) {
|
|
663
755
|
const message = props.message
|
|
664
756
|
const tools = Array.isArray(message.tools) ? message.tools : []
|
|
665
757
|
const children = []
|
|
666
758
|
if (message.reasoning) {
|
|
667
|
-
children.push(h(
|
|
759
|
+
children.push(h(ProcessRow, {
|
|
760
|
+
key: 'reasoning',
|
|
761
|
+
icon: 'think',
|
|
762
|
+
title: '思考',
|
|
763
|
+
running: message.streaming === true,
|
|
764
|
+
body: h('div', { className: 'dsa-proc-body' }, message.reasoning),
|
|
765
|
+
}))
|
|
668
766
|
}
|
|
669
767
|
if (tools.length > 0) {
|
|
670
|
-
children.push(h('div', { key: 'tools', className: 'dsa-
|
|
671
|
-
const
|
|
768
|
+
children.push(h('div', { key: 'tools', className: 'dsa-proc' }, tools.map(tool => {
|
|
769
|
+
const args = typeof tool.arguments === 'string' && tool.arguments ? tool.arguments : ''
|
|
770
|
+
const body = args
|
|
771
|
+
? (CodeBlock
|
|
772
|
+
? h('div', { className: 'dsa-proc-code' }, h(CodeBlock, {
|
|
773
|
+
code: args,
|
|
774
|
+
lang: 'json',
|
|
775
|
+
copyLabel: '复制',
|
|
776
|
+
copiedLabel: '已复制',
|
|
777
|
+
toolbarLabels: { codeLabel: '参数', wrapLabel: '换行', unwrapLabel: '取消换行' },
|
|
778
|
+
showHeader: false,
|
|
779
|
+
}))
|
|
780
|
+
: h('div', { className: 'dsa-proc-body' }, args))
|
|
781
|
+
: null
|
|
782
|
+
return h(ProcessRow, {
|
|
672
783
|
key: tool.callId ?? tool.name,
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
? h(Tooltip, { key: tool.callId ?? tool.name, label: tool.arguments, side: 'top', maxWidth: 420 }, chip)
|
|
679
|
-
: react.cloneElement(chip, { title: tool.arguments }))
|
|
680
|
-
: chip
|
|
784
|
+
icon: tool.status === 'err' ? 'question' : 'code',
|
|
785
|
+
title: tool.name,
|
|
786
|
+
running: tool.status === 'running',
|
|
787
|
+
body,
|
|
788
|
+
})
|
|
681
789
|
})))
|
|
682
790
|
}
|
|
683
791
|
if (message.text) {
|
|
@@ -695,6 +803,11 @@ window.__ModuleLoader__.load({
|
|
|
695
803
|
children.push(h('div', { key: 'text', className: 'dsa-md-plain' }, message.text))
|
|
696
804
|
}
|
|
697
805
|
}
|
|
806
|
+
if (message.interrupted) {
|
|
807
|
+
children.push(Tag
|
|
808
|
+
? h(Tag, { key: 'interrupted', tone: 'neutral' }, '已中断')
|
|
809
|
+
: h('div', { key: 'interrupted', className: 'dsa-hint' }, '已中断'))
|
|
810
|
+
}
|
|
698
811
|
return h('div', { className: 'dsa-assistant' }, children)
|
|
699
812
|
}
|
|
700
813
|
|
|
@@ -704,10 +817,22 @@ window.__ModuleLoader__.load({
|
|
|
704
817
|
rows.push(h('div', { key: message.id, className: 'dsa-msg' },
|
|
705
818
|
message.role === 'user'
|
|
706
819
|
? h(UserMessage, { message })
|
|
707
|
-
: h(AssistantMessage, { message })
|
|
820
|
+
: h(AssistantMessage, { message }),
|
|
821
|
+
props.onReply && message.text && !message.streaming && !message.pending ? h('button', {
|
|
822
|
+
type: 'button', className: 'dsa-linkbtn dsa-reply', onClick: () => props.onReply?.(message),
|
|
823
|
+
'aria-label': '回复这条消息', title: '回复这条消息',
|
|
824
|
+
}, '↩ 回复') : null))
|
|
708
825
|
}
|
|
709
826
|
if (props.model.typing) {
|
|
710
|
-
rows.push(h('div', { key: 'typing', className: 'dsa-typing' },
|
|
827
|
+
rows.push(h('div', { key: 'typing', className: 'dsa-typing' },
|
|
828
|
+
StateDot ? h(StateDot, { state: 'ongoing', size: 10 }) : null,
|
|
829
|
+
TextShimmer ? h(TextShimmer, { active: true }, '正在生成…') : '正在生成…'))
|
|
830
|
+
}
|
|
831
|
+
if (rows.length === 0) {
|
|
832
|
+
rows.push(h('div', { key: 'hero', className: 'dsa-hero' },
|
|
833
|
+
h('div', { className: 'dsa-hero-title' }, PANEL_LABEL),
|
|
834
|
+
h('div', { className: 'dsa-hero-desc' }, '把一个目标拆成可并行的子任务,交付一份合并报告;重启后还能接着跑。'),
|
|
835
|
+
h('div', { className: 'dsa-hint' }, '在下面描述目标,或直接发消息。')))
|
|
711
836
|
}
|
|
712
837
|
return h('div', {
|
|
713
838
|
className: 'dsa-scroll',
|
|
@@ -756,11 +881,15 @@ window.__ModuleLoader__.load({
|
|
|
756
881
|
}
|
|
757
882
|
|
|
758
883
|
function Composer(props) {
|
|
759
|
-
const {
|
|
884
|
+
const { disabled, onSend } = props
|
|
760
885
|
const [text, setText] = react.useState('')
|
|
761
886
|
const areaRef = react.useRef(null)
|
|
762
887
|
const fileRef = react.useRef(null)
|
|
763
888
|
|
|
889
|
+
react.useEffect(() => {
|
|
890
|
+
if (props.model.reply) areaRef.current?.focus()
|
|
891
|
+
}, [props.model.reply?.id])
|
|
892
|
+
|
|
764
893
|
// An uploaded file lands as a path the user can see and edit before sending.
|
|
765
894
|
react.useEffect(() => {
|
|
766
895
|
if (!props.insert) return
|
|
@@ -802,13 +931,21 @@ window.__ModuleLoader__.load({
|
|
|
802
931
|
}
|
|
803
932
|
|
|
804
933
|
return h('div', { className: 'dsa-composer' },
|
|
805
|
-
h('div', { className: 'dsa-card'
|
|
934
|
+
h('div', { className: 'dsa-card' },
|
|
935
|
+
props.model.reply ? (QuotePreview
|
|
936
|
+
? h(QuotePreview, {
|
|
937
|
+
text: props.model.reply.text,
|
|
938
|
+
removal: { label: '取消引用', onRemove: props.onClearReply },
|
|
939
|
+
})
|
|
940
|
+
: h('div', { className: 'dsa-quote' },
|
|
941
|
+
h('span', null, props.model.reply.text),
|
|
942
|
+
h('button', { type: 'button', className: 'dsa-linkbtn', onClick: props.onClearReply, 'aria-label': '取消引用' }, '×'))) : null,
|
|
806
943
|
h('textarea', {
|
|
807
944
|
ref: areaRef,
|
|
808
945
|
className: 'dsa-input',
|
|
809
946
|
rows: 1,
|
|
810
947
|
value: text,
|
|
811
|
-
placeholder:
|
|
948
|
+
placeholder: '发消息或委托任务…',
|
|
812
949
|
disabled,
|
|
813
950
|
onInput: event => {
|
|
814
951
|
setText(event.target.value)
|
|
@@ -834,8 +971,27 @@ window.__ModuleLoader__.load({
|
|
|
834
971
|
'aria-label': '添加文件',
|
|
835
972
|
disabled: disabled || props.uploading === true,
|
|
836
973
|
onClick: pickFile,
|
|
837
|
-
}, props.uploading === true ? h('span', { className: 'dsa-spin' }) : '
|
|
974
|
+
}, props.uploading === true ? h('span', { className: 'dsa-spin' }) : h(Icon, { of: 'attach', size: 16 })), 'top'),
|
|
838
975
|
h('div', { className: 'dsa-trailing' },
|
|
976
|
+
Button
|
|
977
|
+
? h(Button, {
|
|
978
|
+
variant: 'ghost',
|
|
979
|
+
size: 'sm',
|
|
980
|
+
disabled: disabled || !text.trim(),
|
|
981
|
+
onClick: async () => {
|
|
982
|
+
const value = text.trim()
|
|
983
|
+
if (value && await props.onGoal(value)) setText('')
|
|
984
|
+
},
|
|
985
|
+
}, '委托')
|
|
986
|
+
: h('button', {
|
|
987
|
+
type: 'button',
|
|
988
|
+
className: 'dsa-linkbtn',
|
|
989
|
+
disabled: disabled || !text.trim(),
|
|
990
|
+
onClick: async () => {
|
|
991
|
+
const value = text.trim()
|
|
992
|
+
if (value && await props.onGoal(value)) setText('')
|
|
993
|
+
},
|
|
994
|
+
}, '委托'),
|
|
839
995
|
props.running
|
|
840
996
|
? tipped('停止本轮', h('button', {
|
|
841
997
|
type: 'button',
|
|
@@ -845,54 +1001,100 @@ window.__ModuleLoader__.load({
|
|
|
845
1001
|
disabled: props.canceling === true,
|
|
846
1002
|
onClick: () => props.onStop?.(),
|
|
847
1003
|
}, props.canceling ? h('span', { className: 'dsa-spin' }) : h(Icon, { of: 'stop', size: 10 })), 'top')
|
|
848
|
-
:
|
|
1004
|
+
: null,
|
|
1005
|
+
!props.running || text.trim() ? tipped('发送', h('button', {
|
|
849
1006
|
type: 'button',
|
|
850
1007
|
className: 'dsa-send',
|
|
851
1008
|
'aria-label': '发送',
|
|
852
1009
|
disabled: disabled || !text.trim(),
|
|
853
1010
|
onClick: submit,
|
|
854
|
-
}, h(Icon, { of: 'send', size: 15 })), 'top'))))
|
|
855
|
-
h('div', { className: 'dsa-stats' },
|
|
856
|
-
h('span', null, `${props.model.runs.length} 条调度会话`)))
|
|
1011
|
+
}, h(Icon, { of: 'send', size: 15 })), 'top') : null))))
|
|
857
1012
|
}
|
|
858
1013
|
|
|
859
|
-
/**
|
|
860
|
-
* The superagent is the only conversation. This panel lists what it is
|
|
861
|
-
* orchestrating — the delegated sessions/task lines — never a chat history
|
|
862
|
-
* of the user's own conversations.
|
|
863
|
-
*/
|
|
1014
|
+
/** The assistant workbench follows the selected project and its task runs. */
|
|
864
1015
|
function Rail(props) {
|
|
865
1016
|
const { model } = props
|
|
866
|
-
const
|
|
867
|
-
const
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
1017
|
+
const [nameDraft, setNameDraft] = react.useState(null)
|
|
1018
|
+
const workbench = model.workbench?.sessionId === model.sessionId ? model.workbench : null
|
|
1019
|
+
const project = workbench?.project
|
|
1020
|
+
const name = workbench?.name || PANEL_LABEL
|
|
1021
|
+
const byId = new Map([...(workbench?.runs ?? []), ...model.runs].map(run => [run.id, run]))
|
|
1022
|
+
const runs = [...byId.values()]
|
|
1023
|
+
const selected = model.workbenchRun ? byId.get(model.workbenchRun) : null
|
|
1024
|
+
const artifactRows = runs.flatMap(run => artifactsOf(run).map(item => ({ run, item }))).slice(0, 16)
|
|
1025
|
+
const section = (title, content, emptyLabel) => h('section', { className: 'dsa-workbench-section' },
|
|
1026
|
+
h('h3', null, title), content.length ? content : h('div', { className: 'dsa-workbench-empty' }, emptyLabel))
|
|
1027
|
+
const label = project ? '项目详情' : '工作台'
|
|
1028
|
+
let heading = h('span', { title: project?.cwd }, label)
|
|
1029
|
+
let rename = null
|
|
1030
|
+
if (selected || model.detail) {
|
|
1031
|
+
heading = h('button', { type: 'button', className: 'dsa-linkbtn', onClick: props.onCloseRun }, `‹ ${label}`)
|
|
1032
|
+
} else if (!project && nameDraft === null) {
|
|
1033
|
+
rename = h('button', { type: 'button', className: 'dsa-linkbtn', onClick: () => setNameDraft(name), title: '编辑助理名称' }, '改名')
|
|
1034
|
+
} else if (!project) {
|
|
1035
|
+
heading = h('form', {
|
|
1036
|
+
onSubmit: async event => {
|
|
1037
|
+
event.preventDefault()
|
|
1038
|
+
if (nameDraft.trim() && await props.onName(nameDraft.trim())) setNameDraft(null)
|
|
1039
|
+
},
|
|
1040
|
+
}, h('input', {
|
|
1041
|
+
className: 'dsa-answer-input', 'aria-label': '助理名称', maxLength: 32, value: nameDraft,
|
|
1042
|
+
onChange: event => setNameDraft(event.target.value), onKeyDown: event => { if (event.key === 'Escape') setNameDraft(null) },
|
|
1043
|
+
}), h('button', { type: 'submit', className: 'dsa-linkbtn' }, '保存'))
|
|
1044
|
+
}
|
|
1045
|
+
return h('aside', { id: 'dsa-workbench', className: 'dsa-workbench', 'aria-label': label },
|
|
1046
|
+
h('div', { className: 'dsa-workbench-head' }, heading, rename),
|
|
1047
|
+
model.detail ? props.detail : selected ? h('div', { className: 'dsa-workbench-scroll' },
|
|
1048
|
+
h('h3', null, selected.goal),
|
|
1049
|
+
h('p', { className: 'dsa-detail-label' }, STATUS_LABELS[selected.status] ?? selected.status),
|
|
1050
|
+
h('div', { className: 'dsa-md-plain' }, selected.output ?? selected.report ?? ''),
|
|
1051
|
+
h('button', { type: 'button', className: 'dsa-linkbtn', onClick: () => props.onOpenSession(selected) }, '打开会话'))
|
|
1052
|
+
: h('div', { className: 'dsa-workbench-scroll' },
|
|
1053
|
+
section(project ? '项目任务' : '最近任务', runs.map(run => {
|
|
878
1054
|
const waiting = Array.isArray(run.attention) && run.attention.length > 0
|
|
879
|
-
return
|
|
880
|
-
key: run.id,
|
|
881
|
-
|
|
882
|
-
className: 'dsa-rowitem',
|
|
883
|
-
title: '查看任务详情',
|
|
1055
|
+
return h('button', {
|
|
1056
|
+
key: run.id, type: 'button', className: 'dsa-rowitem', title: run.goal ?? '查看任务详情',
|
|
1057
|
+
'data-status': waiting ? 'waiting' : run.status,
|
|
884
1058
|
onClick: () => props.onOpen?.(run.id),
|
|
885
|
-
},
|
|
886
|
-
|
|
1059
|
+
}, StateDot
|
|
1060
|
+
? h(StateDot, { state: statusDot(waiting, run.status), size: 10 })
|
|
1061
|
+
: h('span', { className: 'dsa-rowdot', 'data-status': waiting ? 'waiting' : run.status }),
|
|
887
1062
|
h('span', { className: 'dsa-rowtitle' }, run.goal ?? '调度中的会话'),
|
|
888
|
-
h('span', { className: 'dsa-rowtime' }, waiting ? '等你决定' : run.status
|
|
889
|
-
}))
|
|
1063
|
+
h('span', { className: 'dsa-rowtime' }, waiting ? '等你决定' : (STATUS_LABELS[run.status] ?? run.status)))
|
|
1064
|
+
}), '暂无任务'),
|
|
1065
|
+
section(project ? '项目产物' : '工作产物', artifactRows.map(({ run, item }) => h('button', {
|
|
1066
|
+
key: `${run.id}:${item.href}`, type: 'button', className: 'dsa-artifact-link', title: item.href,
|
|
1067
|
+
onClick: () => props.onArtifact(run, item),
|
|
1068
|
+
}, FileTypeIcon ? h(FileTypeIcon, { path: item.href, size: 16 }) : null,
|
|
1069
|
+
h('span', null, item.name))), '暂无产物')))
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
function ProjectNav({ workbench, onSelect, onAdd, onPick }) {
|
|
1073
|
+
const [draft, setDraft] = react.useState(null)
|
|
1074
|
+
const project = workbench?.project
|
|
1075
|
+
const choose = (entry, label, current) => h('button', {
|
|
1076
|
+
key: entry?.cwd ?? 'global', type: 'button', className: 'dsa-rowitem', 'data-current': current,
|
|
1077
|
+
title: entry?.cwd ?? '全局助理', onClick: () => onSelect(entry),
|
|
1078
|
+
}, h('span', { className: 'dsa-rowtitle' }, label))
|
|
1079
|
+
return h('nav', { className: 'dsa-project-nav', 'aria-label': '全局助理和项目' },
|
|
1080
|
+
choose(null, '全局助理', !project),
|
|
1081
|
+
h('div', { className: 'dsa-project-head' }, h('span', null, '项目'),
|
|
1082
|
+
h('button', { type: 'button', className: 'dsa-linkbtn', 'aria-label': '添加项目', onClick: async () => {
|
|
1083
|
+
if (workbench?.canPickProject && await onPick()) return
|
|
1084
|
+
setDraft(draft === null ? '' : null)
|
|
1085
|
+
} }, '+')),
|
|
1086
|
+
draft === null ? null : h('form', { className: 'dsa-project-add', onSubmit: async event => {
|
|
1087
|
+
event.preventDefault()
|
|
1088
|
+
if (draft.trim() && await onAdd(draft.trim())) setDraft(null)
|
|
1089
|
+
} }, h('input', { className: 'dsa-answer-input', placeholder: '项目文件夹绝对路径', value: draft, onChange: event => setDraft(event.target.value) }),
|
|
1090
|
+
h('button', { type: 'submit', className: 'dsa-linkbtn', disabled: !draft.trim() }, '打开项目')),
|
|
1091
|
+
(workbench?.projects ?? []).map(entry => choose(entry, entry.name, entry.cwd === project?.cwd)))
|
|
890
1092
|
}
|
|
891
1093
|
|
|
892
1094
|
/** Artifacts are whatever the run report links to, same rule as the console page. */
|
|
893
1095
|
function artifactsOf(run) {
|
|
894
1096
|
const report = typeof run?.report === 'string' ? run.report : ''
|
|
895
|
-
const found = []
|
|
1097
|
+
const found = (run.artifacts ?? []).filter(item => item.href).map(item => ({ ...item, runId: run.id }))
|
|
896
1098
|
const pattern = /\[([^\]\n]{1,80})\]\(<?([^)>\n]+)>?\)/g
|
|
897
1099
|
let match = pattern.exec(report)
|
|
898
1100
|
while (match) {
|
|
@@ -914,13 +1116,10 @@ window.__ModuleLoader__.load({
|
|
|
914
1116
|
const busy = model.sessionsBusy === true
|
|
915
1117
|
return h('div', { className: 'dsa-sessions', role: 'dialog', 'aria-label': '会话' },
|
|
916
1118
|
h('div', { className: 'dsa-sessions-head' },
|
|
917
|
-
h('span', null, '会话'),
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
className: 'dsa-sessions-new',
|
|
921
|
-
disabled: busy,
|
|
922
|
-
onClick: () => props.onNew?.(),
|
|
923
|
-
}, '新对话')),
|
|
1119
|
+
h('span', null, busy ? '会话 · 读取中' : '会话'),
|
|
1120
|
+
Button
|
|
1121
|
+
? h(Button, { variant: 'ghost', size: 'sm', disabled: busy, onClick: () => props.onNew?.() }, '新对话')
|
|
1122
|
+
: h('button', { type: 'button', className: 'dsa-sessions-new', disabled: busy, onClick: () => props.onNew?.() }, '新对话')),
|
|
924
1123
|
h('div', { className: 'dsa-sessions-list' },
|
|
925
1124
|
sessions.length === 0
|
|
926
1125
|
? h('div', { className: 'dsa-hint', style: { padding: '8px' } }, '还没有历史会话')
|
|
@@ -938,24 +1137,140 @@ window.__ModuleLoader__.load({
|
|
|
938
1137
|
h('button', { type: 'button', className: 'dsa-linkbtn', onClick: () => props.onClose?.() }, '关闭')))
|
|
939
1138
|
}
|
|
940
1139
|
|
|
1140
|
+
const STATUS_LABELS = {
|
|
1141
|
+
planning: '规划中', queued: '排队中', running: '进行中', aggregating: '汇总中', verifying: '验收中',
|
|
1142
|
+
ready: '待开始', pending: '待开始', 'needs-decision': '等你决定', completed: '完成', partial: '部分完成',
|
|
1143
|
+
paused: '已暂停', failed: '失败', stopped: '已停止', cancelled: '已取消', interrupted: '已中断', skipped: '已跳过',
|
|
1144
|
+
}
|
|
1145
|
+
const ACTIVE_RUN = new Set(['queued', 'planning', 'running', 'aggregating'])
|
|
1146
|
+
|
|
1147
|
+
/** Host StateDot semantics: amber attention, spinner, green done, red failure. */
|
|
1148
|
+
function statusDot(waiting, status) {
|
|
1149
|
+
if (waiting || status === 'needs-decision') return 'warning'
|
|
1150
|
+
if (ACTIVE_RUN.has(status) || status === 'verifying') return 'ongoing'
|
|
1151
|
+
if (status === 'completed' || status === 'partial') return 'done'
|
|
1152
|
+
if (['failed', 'cancelled', 'stopped', 'interrupted'].includes(status)) return 'error'
|
|
1153
|
+
return 'idle'
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
function InstructionForm({ run, onInstruct }) {
|
|
1157
|
+
const [text, setText] = react.useState('')
|
|
1158
|
+
const [target, setTarget] = react.useState('')
|
|
1159
|
+
const [busy, setBusy] = react.useState(false)
|
|
1160
|
+
const workers = (run.subtasks ?? []).filter(item => item.status === 'running' && item.childId)
|
|
1161
|
+
const targetAvailable = target === '' || workers.some(item => String(item.index) === target)
|
|
1162
|
+
const canSend = ACTIVE_RUN.has(run.status) || run.status === 'interrupted'
|
|
1163
|
+
const receipts = [...(run.instructions ?? []), ...(run.followups ?? [])]
|
|
1164
|
+
const receiptLabels = { pending: '待读取', applied: '已进入执行上下文', missed: '未应用', failed: '发送失败' }
|
|
1165
|
+
return h('div', { className: 'dsa-detail-sec' },
|
|
1166
|
+
canSend ? h('form', {
|
|
1167
|
+
className: 'dsa-instruction',
|
|
1168
|
+
onSubmit: async event => {
|
|
1169
|
+
event.preventDefault()
|
|
1170
|
+
if (busy || !text.trim() || !targetAvailable) return
|
|
1171
|
+
setBusy(true)
|
|
1172
|
+
try {
|
|
1173
|
+
if (await onInstruct(run.id, text.trim(), target === '' ? null : Number(target))) setText('')
|
|
1174
|
+
} finally {
|
|
1175
|
+
setBusy(false)
|
|
1176
|
+
}
|
|
1177
|
+
},
|
|
1178
|
+
},
|
|
1179
|
+
h('select', { className: 'dsa-answer-input', 'aria-label': '指令接收任务', value: target, onChange: event => setTarget(event.target.value) },
|
|
1180
|
+
h('option', { value: '' }, '该任务的下一次执行或汇总'),
|
|
1181
|
+
!targetAvailable ? h('option', { value: target, disabled: true }, '原工作线已停止,请重新选择') : null,
|
|
1182
|
+
workers.map(item => h('option', { key: item.index, value: String(item.index) }, item.title ?? `工作线 ${item.index}`))),
|
|
1183
|
+
h('input', { className: 'dsa-answer-input', placeholder: '补充这项任务的要求', value: text, onInput: event => setText(event.target.value) }),
|
|
1184
|
+
h('button', { type: 'submit', className: 'dsa-linkbtn', disabled: busy || !text.trim() || !targetAvailable }, '发送指令')) : null,
|
|
1185
|
+
receipts.map(entry => h('div', { key: entry.id, className: 'dsa-detail-label' },
|
|
1186
|
+
`${entry.text} · ${entry.targets
|
|
1187
|
+
? entry.targets.map(item => `工作线 ${item.subtaskIndex} ${receiptLabels[item.status] ?? item.status}`).join(',')
|
|
1188
|
+
: receiptLabels[entry.status] ?? entry.status}`)))
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
function GoalDecision({ goal, item, onAction, busy }) {
|
|
1192
|
+
const [note, setNote] = react.useState('')
|
|
1193
|
+
const labels = { answer: '提交回答', accept: '接受验收', retry: '再试一次', skip: '跳过', stop: '停止', continue: '继续' }
|
|
1194
|
+
return h('div', { className: 'dsa-attention-card' },
|
|
1195
|
+
h('div', { className: 'dsa-detail-q' }, item.question),
|
|
1196
|
+
item.reason ? h('div', { className: 'dsa-detail-label' }, item.reason) : null,
|
|
1197
|
+
h('div', { className: 'dsa-answer-row' },
|
|
1198
|
+
h('input', { className: 'dsa-answer-input', value: note, placeholder: item.options.includes('answer') ? '写下你的回答' : '补充说明(可选)', onInput: event => setNote(event.target.value) }),
|
|
1199
|
+
item.options.map(answer => h('button', {
|
|
1200
|
+
key: answer, type: 'button', className: 'dsa-linkbtn',
|
|
1201
|
+
disabled: busy || (answer === 'answer' && !note.trim()),
|
|
1202
|
+
onClick: () => onAction(goal.id, 'answer', { decisionId: item.id, answer, note: note.trim() }),
|
|
1203
|
+
}, labels[answer] ?? answer))))
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
function GoalCards({ model, onOpen, onAction }) {
|
|
1207
|
+
if (!model.goals.length) return null
|
|
1208
|
+
return h('section', { className: 'dsa-goals', 'aria-label': '委托的目标' },
|
|
1209
|
+
model.goals.map(goal => {
|
|
1210
|
+
const active = ['planning', 'running', 'needs-decision'].includes(goal.status)
|
|
1211
|
+
const paused = goal.status === 'paused'
|
|
1212
|
+
const completed = goal.phases.filter(phase => phase.status === 'completed').length
|
|
1213
|
+
const button = (action, label) => h('button', {
|
|
1214
|
+
type: 'button', className: 'dsa-linkbtn', disabled: model.goalBusy,
|
|
1215
|
+
onClick: () => onAction(goal.id, action),
|
|
1216
|
+
}, label)
|
|
1217
|
+
return h('div', { key: goal.id },
|
|
1218
|
+
h('details', { className: 'dsa-attention-card' },
|
|
1219
|
+
h('summary', null, `${STATUS_LABELS[goal.status] ?? goal.status} · ${completed}/${goal.phases.length} · ${goal.goal}`),
|
|
1220
|
+
goal.reason ? h('div', { className: 'dsa-detail-label' }, goal.reason) : null,
|
|
1221
|
+
goal.phases.map(phase => h('div', { key: phase.id, className: 'dsa-goal-phase' },
|
|
1222
|
+
h('span', null, `${phase.title} · ${STATUS_LABELS[phase.status] ?? phase.status}`),
|
|
1223
|
+
h('div', { className: 'dsa-goal-actions' },
|
|
1224
|
+
phase.runId ? h('button', { type: 'button', className: 'dsa-linkbtn', onClick: () => onOpen(phase.runId) },
|
|
1225
|
+
phase.status === 'completed' ? '产物与报告' : '查看工作线') : null,
|
|
1226
|
+
goal.status !== 'needs-decision' && ['failed', 'skipped'].includes(phase.status) ? h('button', {
|
|
1227
|
+
type: 'button', className: 'dsa-linkbtn', disabled: model.goalBusy,
|
|
1228
|
+
onClick: () => onAction(goal.id, 'retry_phase', { phaseId: phase.id }),
|
|
1229
|
+
}, '重试阶段') : null))),
|
|
1230
|
+
h('div', { className: 'dsa-goal-actions' },
|
|
1231
|
+
active && goal.status !== 'needs-decision' ? button('pause', '暂停新阶段') : null,
|
|
1232
|
+
paused ? button('resume', '继续') : null,
|
|
1233
|
+
active || paused ? button('cancel', '取消目标') : null)),
|
|
1234
|
+
goal.decisions.map(item => h(GoalDecision, { key: item.id, goal, item, onAction, busy: model.goalBusy })))
|
|
1235
|
+
}))
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
function ownedRunQuestions(goals) {
|
|
1239
|
+
return new Set(goals.flatMap(goal => goal.decisions.map(item => `${item.source?.runId}:${item.source?.attentionId}`)))
|
|
1240
|
+
}
|
|
1241
|
+
|
|
941
1242
|
/** One delegated run: status, questions waiting for the user, artifacts. */
|
|
942
1243
|
function RunDetail(props) {
|
|
943
1244
|
const { model } = props
|
|
944
1245
|
const run = model.detail
|
|
945
1246
|
if (!run) return null
|
|
946
|
-
|
|
1247
|
+
if (model.workerSession) {
|
|
1248
|
+
const worker = model.workerSession
|
|
1249
|
+
return h('section', { className: 'dsa-detail', 'aria-label': '工作线原会话' },
|
|
1250
|
+
h('div', { className: 'dsa-detail-head' },
|
|
1251
|
+
h('span', { className: 'dsa-detail-title' }, worker.title ?? '工作线原会话'),
|
|
1252
|
+
h('button', { type: 'button', className: 'dsa-linkbtn', onClick: props.onCloseWorker }, '返回任务')),
|
|
1253
|
+
worker.transcript.messages.length ? h(Transcript, { model: worker.transcript })
|
|
1254
|
+
: h('div', { className: 'dsa-workbench-empty' }, '暂无会话记录'))
|
|
1255
|
+
}
|
|
1256
|
+
const ownedQuestions = ownedRunQuestions(model.goals)
|
|
1257
|
+
const attention = (run.attention ?? []).filter(item => !ownedQuestions.has(`${run.id}:${item.id}`))
|
|
947
1258
|
const artifacts = artifactsOf(run)
|
|
948
1259
|
const busy = model.detailBusy === true
|
|
949
1260
|
return h('div', { className: 'dsa-detail', role: 'dialog', 'aria-label': '任务详情' },
|
|
950
1261
|
h('div', { className: 'dsa-detail-head' },
|
|
951
1262
|
h('span', { className: 'dsa-detail-title' }, run.goal ?? '任务详情'),
|
|
952
|
-
h('button', {
|
|
1263
|
+
ACTIVE_RUN.has(run.status) ? h('button', {
|
|
953
1264
|
type: 'button',
|
|
954
1265
|
className: 'dsa-linkbtn',
|
|
955
1266
|
onClick: () => props.onCancelRun?.(run.id),
|
|
956
|
-
},
|
|
957
|
-
h('button', { type: 'button', className: 'dsa-linkbtn', onClick: () => props.onClose?.() }, '关闭')),
|
|
1267
|
+
}, '停止任务') : null),
|
|
958
1268
|
h('div', { className: 'dsa-detail-body' },
|
|
1269
|
+
(run.subtasks ?? []).some(task => task.childId) ? h('div', { className: 'dsa-detail-sec' },
|
|
1270
|
+
h('div', { className: 'dsa-detail-label' }, '工作线会话'),
|
|
1271
|
+
(run.subtasks ?? []).filter(task => task.childId).map(task => h('div', { key: task.childId, className: 'dsa-goal-phase' },
|
|
1272
|
+
h('span', null, task.title),
|
|
1273
|
+
h('button', { type: 'button', className: 'dsa-linkbtn', onClick: () => props.onOpenWorker(run.id, task.childId) }, '打开会话')))) : null,
|
|
959
1274
|
model.preview
|
|
960
1275
|
? h('div', { className: 'dsa-detail-sec dsa-preview' },
|
|
961
1276
|
h('div', { className: 'dsa-detail-head' },
|
|
@@ -970,34 +1285,53 @@ window.__ModuleLoader__.load({
|
|
|
970
1285
|
src: model.preview.url,
|
|
971
1286
|
title: model.preview.name,
|
|
972
1287
|
})
|
|
973
|
-
:
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1288
|
+
: model.preview.kind === 'md' && DetailDocument
|
|
1289
|
+
? h(DetailDocument, {
|
|
1290
|
+
state: model.previewBusy
|
|
1291
|
+
? { status: 'loading' }
|
|
1292
|
+
: model.previewError
|
|
1293
|
+
? { status: 'error', message: model.previewError }
|
|
1294
|
+
: { status: 'found', markdown: model.previewText },
|
|
1295
|
+
labels: DETAIL_LABELS,
|
|
1296
|
+
onRetry: () => props.onRetryPreview?.(),
|
|
1297
|
+
})
|
|
1298
|
+
: h('div', { className: 'dsa-preview-text' },
|
|
1299
|
+
model.previewBusy ? '读取中…' : (model.previewError || model.previewText)))
|
|
979
1300
|
: null,
|
|
980
1301
|
h('div', { className: 'dsa-detail-sec' },
|
|
981
1302
|
h('div', { className: 'dsa-detail-label' }, '状态'),
|
|
982
1303
|
h('div', { className: 'dsa-detail-q' }, `${run.status ?? '未知'}${run.startedAt ? ` · ${run.startedAt}` : ''}`)),
|
|
1304
|
+
h(InstructionForm, { key: run.id, run, onInstruct: props.onInstruct }),
|
|
983
1305
|
attention.length > 0
|
|
984
1306
|
? h('div', { className: 'dsa-detail-sec' },
|
|
985
1307
|
h('div', { className: 'dsa-detail-label' }, '等你决定'),
|
|
986
1308
|
attention.map(item => h('div', { key: item.id, className: 'dsa-detail-item' },
|
|
987
1309
|
h('div', { className: 'dsa-detail-q' }, item.question ?? '有一个问题需要你回答'),
|
|
988
1310
|
h('div', { className: 'dsa-answer-row' },
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1311
|
+
Input
|
|
1312
|
+
? h(Input, {
|
|
1313
|
+
value: model.answerDraft,
|
|
1314
|
+
placeholder: '写下你的回答',
|
|
1315
|
+
onChange: event => props.onDraft?.(event.target.value),
|
|
1316
|
+
onKeyDown: event => {
|
|
1317
|
+
if (event.key === 'Enter' && !event.nativeEvent?.isComposing) {
|
|
1318
|
+
event.preventDefault()
|
|
1319
|
+
props.onAnswer?.(run.id, item.id, model.answerDraft)
|
|
1320
|
+
}
|
|
1321
|
+
},
|
|
1322
|
+
})
|
|
1323
|
+
: h('input', {
|
|
1324
|
+
className: 'dsa-answer-input',
|
|
1325
|
+
value: model.answerDraft,
|
|
1326
|
+
placeholder: '写下你的回答',
|
|
1327
|
+
onChange: event => props.onDraft?.(event.target.value),
|
|
1328
|
+
onKeyDown: event => {
|
|
1329
|
+
if (event.key === 'Enter' && !event.nativeEvent?.isComposing) {
|
|
1330
|
+
event.preventDefault()
|
|
1331
|
+
props.onAnswer?.(run.id, item.id, model.answerDraft)
|
|
1332
|
+
}
|
|
1333
|
+
},
|
|
1334
|
+
}),
|
|
1001
1335
|
h(Button ?? 'button', {
|
|
1002
1336
|
variant: Button ? 'primary' : undefined,
|
|
1003
1337
|
type: Button ? undefined : 'button',
|
|
@@ -1013,7 +1347,7 @@ window.__ModuleLoader__.load({
|
|
|
1013
1347
|
type: 'button',
|
|
1014
1348
|
className: 'dsa-artifact-link',
|
|
1015
1349
|
onClick: () => props.onArtifact?.(item),
|
|
1016
|
-
}, item.name),
|
|
1350
|
+
}, FileTypeIcon ? h(FileTypeIcon, { path: item.href, size: 16 }) : null, h('span', null, item.name)),
|
|
1017
1351
|
h('button', {
|
|
1018
1352
|
type: 'button',
|
|
1019
1353
|
className: 'dsa-linkbtn',
|
|
@@ -1027,10 +1361,13 @@ window.__ModuleLoader__.load({
|
|
|
1027
1361
|
: h('div', { className: 'dsa-detail-sec' },
|
|
1028
1362
|
h('div', { className: 'dsa-detail-label' }, '产物'),
|
|
1029
1363
|
h('div', { className: 'dsa-hint' }, '这条任务还没有报告产物')),
|
|
1364
|
+
run.output ? h('div', { className: 'dsa-detail-sec' },
|
|
1365
|
+
h('div', { className: 'dsa-detail-label' }, '交付内容'),
|
|
1366
|
+
h('div', { className: 'dsa-md-plain' }, run.output)) : null,
|
|
1030
1367
|
run.report
|
|
1031
1368
|
? h('div', { className: 'dsa-detail-sec' },
|
|
1032
|
-
h('div', { className: 'dsa-
|
|
1033
|
-
|
|
1369
|
+
run.output ? h('details', null, h('summary', null, '验收报告'), h('div', { className: 'dsa-md-plain' }, run.report))
|
|
1370
|
+
: h('div', { className: 'dsa-md-plain' }, run.report))
|
|
1034
1371
|
: null))
|
|
1035
1372
|
}
|
|
1036
1373
|
|
|
@@ -1042,66 +1379,80 @@ window.__ModuleLoader__.load({
|
|
|
1042
1379
|
function AttentionCards(props) {
|
|
1043
1380
|
const { model } = props
|
|
1044
1381
|
const entries = []
|
|
1382
|
+
const ownedQuestions = ownedRunQuestions(model.goals)
|
|
1045
1383
|
for (const run of Array.isArray(model.runs) ? model.runs : []) {
|
|
1046
1384
|
for (const item of Array.isArray(run.attention) ? run.attention : []) {
|
|
1047
|
-
if (item?.id) entries.push({ run, item })
|
|
1385
|
+
if (item?.id && !ownedQuestions.has(`${run.id}:${item.id}`)) entries.push({ run, item })
|
|
1048
1386
|
}
|
|
1049
1387
|
}
|
|
1050
1388
|
if (entries.length === 0) return null
|
|
1051
1389
|
return h('div', { className: 'dsa-attention' },
|
|
1052
1390
|
entries.map(({ run, item }) => {
|
|
1053
1391
|
const options = Array.isArray(item.options) ? item.options : []
|
|
1392
|
+
const draft = String(model.answerDraft ?? '')
|
|
1393
|
+
const submit = () => props.onAnswer?.(run.id, item.id, draft)
|
|
1394
|
+
const field = Input
|
|
1395
|
+
? h(Input, {
|
|
1396
|
+
value: model.answerDraft,
|
|
1397
|
+
placeholder: options.length > 0 ? '或者直接写别的回答' : '写下你的回答',
|
|
1398
|
+
onChange: event => props.onDraft?.(event.target.value),
|
|
1399
|
+
onKeyDown: event => {
|
|
1400
|
+
if (event.key === 'Enter' && !event.nativeEvent?.isComposing) {
|
|
1401
|
+
event.preventDefault()
|
|
1402
|
+
submit()
|
|
1403
|
+
}
|
|
1404
|
+
},
|
|
1405
|
+
})
|
|
1406
|
+
: h('input', {
|
|
1407
|
+
className: 'dsa-answer-input',
|
|
1408
|
+
value: model.answerDraft,
|
|
1409
|
+
placeholder: options.length > 0 ? '或者直接写别的回答' : '写下你的回答',
|
|
1410
|
+
onChange: event => props.onDraft?.(event.target.value),
|
|
1411
|
+
onKeyDown: event => {
|
|
1412
|
+
if (event.key === 'Enter' && !event.nativeEvent?.isComposing) {
|
|
1413
|
+
event.preventDefault()
|
|
1414
|
+
submit()
|
|
1415
|
+
}
|
|
1416
|
+
},
|
|
1417
|
+
})
|
|
1054
1418
|
return h('div', { key: `${run.id}:${item.id}`, className: 'dsa-attention-card' },
|
|
1055
1419
|
h('div', { className: 'dsa-attention-head' },
|
|
1056
|
-
h('span', { className: 'dsa-attention-dot' }),
|
|
1420
|
+
StateDot ? h(StateDot, { state: 'warning', size: 10 }) : h('span', { className: 'dsa-attention-dot' }),
|
|
1057
1421
|
h('span', null, item.source === 'plan' ? '计划确认' : '等你决定'),
|
|
1058
1422
|
h('span', { className: 'dsa-session-meta' }, run.goal ?? '')),
|
|
1059
|
-
h('div', { className: 'dsa-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
h('
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
disabled: !String(model.answerDraft ?? '').trim(),
|
|
1078
|
-
onClick: () => props.onAnswer?.(run.id, item.id, model.answerDraft),
|
|
1079
|
-
}, '回答')),
|
|
1423
|
+
h('div', { className: 'dsa-attention-summary' },
|
|
1424
|
+
h('div', { className: 'dsa-attention-title' }, item.question ?? '有一个问题需要你回答'),
|
|
1425
|
+
item.reason ? h('div', { className: 'dsa-attention-desc' }, item.reason) : null,
|
|
1426
|
+
h('div', { className: 'dsa-answer-row' },
|
|
1427
|
+
field,
|
|
1428
|
+
Button
|
|
1429
|
+
? h(Button, {
|
|
1430
|
+
variant: 'primary',
|
|
1431
|
+
size: 'sm',
|
|
1432
|
+
disabled: !draft.trim(),
|
|
1433
|
+
onClick: submit,
|
|
1434
|
+
}, '回答')
|
|
1435
|
+
: h('button', {
|
|
1436
|
+
type: 'button',
|
|
1437
|
+
className: 'dsa-chip',
|
|
1438
|
+
disabled: !draft.trim(),
|
|
1439
|
+
onClick: submit,
|
|
1440
|
+
}, '回答'))),
|
|
1080
1441
|
options.length > 0
|
|
1081
|
-
? h('div', { className: 'dsa-attention-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1442
|
+
? h('div', { className: 'dsa-attention-footer' },
|
|
1443
|
+
h('div', { className: 'dsa-attention-options' },
|
|
1444
|
+
options.map(option => (Pill
|
|
1445
|
+
? h(Pill, { key: option, onClick: () => props.onAnswer?.(run.id, item.id, option) }, option)
|
|
1446
|
+
: h('button', {
|
|
1447
|
+
key: option,
|
|
1448
|
+
type: 'button',
|
|
1449
|
+
className: 'dsa-chip',
|
|
1450
|
+
onClick: () => props.onAnswer?.(run.id, item.id, option),
|
|
1451
|
+
}, option)))))
|
|
1088
1452
|
: null)
|
|
1089
1453
|
}))
|
|
1090
1454
|
}
|
|
1091
1455
|
|
|
1092
|
-
function Hero(props) {
|
|
1093
|
-
const ready = props.model.capabilities?.chat !== false
|
|
1094
|
-
return h('div', { className: 'dsa-hero' },
|
|
1095
|
-
h('div', { className: 'dsa-hero-stack' },
|
|
1096
|
-
h('div', { className: 'dsa-hero-title' },
|
|
1097
|
-
FishLogo ? h(FishLogo, { size: 32 }) : h(Icon, { of: 'spark', size: 26 }),
|
|
1098
|
-
h('span', null, PANEL_LABEL)),
|
|
1099
|
-
h('div', { className: 'dsa-hero-note' }, ready
|
|
1100
|
-
? '说一句话就开始:它会拆任务、并行走、把结果收回来说给你。'
|
|
1101
|
-
: (props.model.capabilities?.reason ?? '这个宿主暂时不能对话')),
|
|
1102
|
-
h(Composer, { ...props, hero: true, disabled: props.disabled || !ready })))
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
1456
|
function Seat(props) {
|
|
1106
1457
|
const { model, dispatch } = props
|
|
1107
1458
|
// Hooks must run before the loading/error early returns.
|
|
@@ -1113,6 +1464,13 @@ window.__ModuleLoader__.load({
|
|
|
1113
1464
|
return next
|
|
1114
1465
|
})
|
|
1115
1466
|
}
|
|
1467
|
+
const inspectRun = runId => {
|
|
1468
|
+
if (!railOpen) {
|
|
1469
|
+
setRailOpen(true)
|
|
1470
|
+
saveRailOpen(true)
|
|
1471
|
+
}
|
|
1472
|
+
return dispatch({ type: 'openRun', runId })
|
|
1473
|
+
}
|
|
1116
1474
|
react.useEffect(() => {
|
|
1117
1475
|
if (typeof window === 'undefined' || typeof window.addEventListener !== 'function') return undefined
|
|
1118
1476
|
const onKey = event => {
|
|
@@ -1149,14 +1507,11 @@ window.__ModuleLoader__.load({
|
|
|
1149
1507
|
onClick: () => dispatch({ type: 'retry' }),
|
|
1150
1508
|
}, '重试')))
|
|
1151
1509
|
}
|
|
1152
|
-
const
|
|
1153
|
-
const runningCount = Array.isArray(model.runs)
|
|
1154
|
-
? model.runs.filter(run => run.status === 'running').length
|
|
1155
|
-
: 0
|
|
1510
|
+
const chatUnavailable = model.capabilities?.chat === false
|
|
1156
1511
|
return h('div', { className: 'dsa-root', 'data-rail': railOpen ? 'open' : 'closed' },
|
|
1157
1512
|
h(Header, {
|
|
1513
|
+
title: model.workbench?.project?.name || model.workbench?.name || PANEL_LABEL,
|
|
1158
1514
|
railOpen,
|
|
1159
|
-
runningCount,
|
|
1160
1515
|
unread: model.unread ?? 0,
|
|
1161
1516
|
sessionsOpen: model.sessionsOpen === true,
|
|
1162
1517
|
onToggleRail: toggleRail,
|
|
@@ -1164,27 +1519,30 @@ window.__ModuleLoader__.load({
|
|
|
1164
1519
|
}),
|
|
1165
1520
|
h(SessionsPanel, {
|
|
1166
1521
|
model,
|
|
1167
|
-
onNew: () => dispatch({ type: 'newSession' }),
|
|
1522
|
+
onNew: () => dispatch({ type: 'newSession', cwd: model.workbench?.project?.cwd }),
|
|
1168
1523
|
onSwitch: sessionId => dispatch({ type: 'switchSession', sessionId }),
|
|
1169
1524
|
onClose: () => dispatch({ type: 'sessions', open: false }),
|
|
1170
1525
|
}),
|
|
1171
|
-
|
|
1526
|
+
model.toast
|
|
1527
|
+
? (Toast
|
|
1528
|
+
? h(Toast, {
|
|
1529
|
+
key: model.toast.text,
|
|
1530
|
+
text: model.toast.text,
|
|
1531
|
+
tone: model.toast.kind === 'ok' ? 'success' : undefined,
|
|
1532
|
+
holdMs: model.toast.kind === 'err' ? 6000 : 3000,
|
|
1533
|
+
onDone: () => dispatch({ type: 'dismissToast' }),
|
|
1534
|
+
})
|
|
1535
|
+
: h(Notice, { toast: model.toast }))
|
|
1536
|
+
: null,
|
|
1172
1537
|
h('div', { className: 'dsa-body', 'data-rail': railOpen ? 'open' : 'closed' },
|
|
1538
|
+
h(ProjectNav, {
|
|
1539
|
+
workbench: model.workbench,
|
|
1540
|
+
onSelect: entry => dispatch({ type: 'selectProject', project: entry }),
|
|
1541
|
+
onAdd: cwd => dispatch({ type: 'newSession', cwd }),
|
|
1542
|
+
onPick: () => dispatch({ type: 'pickProject' }),
|
|
1543
|
+
}),
|
|
1173
1544
|
h('div', { className: 'dsa-main' },
|
|
1174
|
-
|
|
1175
|
-
? h(Hero, {
|
|
1176
|
-
model,
|
|
1177
|
-
disabled: model.sending,
|
|
1178
|
-
running: model.typing,
|
|
1179
|
-
canceling: model.canceling,
|
|
1180
|
-
insert: model.uploadInsert,
|
|
1181
|
-
uploading: model.uploading === true,
|
|
1182
|
-
onInserted: () => dispatch({ type: 'inserted' }),
|
|
1183
|
-
onUpload: file => dispatch({ type: 'upload', file }),
|
|
1184
|
-
onStop: () => dispatch({ type: 'cancel' }),
|
|
1185
|
-
onSend: text => dispatch({ type: 'send', text }),
|
|
1186
|
-
})
|
|
1187
|
-
: h(Transcript, { model, scrollRef: model.scrollRef }),
|
|
1545
|
+
h(Transcript, { model, scrollRef: model.scrollRef, onReply: message => dispatch({ type: 'reply', message }) }),
|
|
1188
1546
|
h(Approvals, {
|
|
1189
1547
|
approvals: model.approvals,
|
|
1190
1548
|
busy: model.approvalBusy,
|
|
@@ -1195,9 +1553,15 @@ window.__ModuleLoader__.load({
|
|
|
1195
1553
|
onDraft: value => dispatch({ type: 'draft', value }),
|
|
1196
1554
|
onAnswer: (runId, attentionId, answer) => dispatch({ type: 'answer', runId, attentionId, answer }),
|
|
1197
1555
|
}),
|
|
1198
|
-
|
|
1556
|
+
h(GoalCards, {
|
|
1557
|
+
model,
|
|
1558
|
+
onOpen: inspectRun,
|
|
1559
|
+
onAction: (goalId, action, body) => dispatch({ type: 'goalAction', goalId, action, body }),
|
|
1560
|
+
}),
|
|
1561
|
+
chatUnavailable ? h('div', { className: 'dsa-detail-label', role: 'status' }, model.capabilities.reason || '暂时无法对话') : null,
|
|
1562
|
+
h(Composer, {
|
|
1199
1563
|
model,
|
|
1200
|
-
disabled: model.sending || model.
|
|
1564
|
+
disabled: model.sending || model.goalBusy || chatUnavailable,
|
|
1201
1565
|
running: model.typing,
|
|
1202
1566
|
canceling: model.canceling,
|
|
1203
1567
|
insert: model.uploadInsert,
|
|
@@ -1206,23 +1570,35 @@ window.__ModuleLoader__.load({
|
|
|
1206
1570
|
onUpload: file => dispatch({ type: 'upload', file }),
|
|
1207
1571
|
onStop: () => dispatch({ type: 'cancel' }),
|
|
1208
1572
|
onSend: text => dispatch({ type: 'send', text }),
|
|
1209
|
-
|
|
1210
|
-
|
|
1573
|
+
onGoal: text => dispatch({ type: 'newGoal', text }),
|
|
1574
|
+
onClearReply: () => dispatch({ type: 'reply' }),
|
|
1575
|
+
})),
|
|
1576
|
+
h(Rail, {
|
|
1577
|
+
model,
|
|
1578
|
+
onOpen: inspectRun,
|
|
1579
|
+
onCloseRun: () => dispatch({ type: 'closeRun' }),
|
|
1580
|
+
onName: name => dispatch({ type: 'nameWorkbench', name }),
|
|
1581
|
+
onOpenSession: run => dispatch({ type: 'showOriginalRun', run }),
|
|
1582
|
+
onArtifact: (run, item) => dispatch({ type: 'openWorkbenchArtifact', run, item }),
|
|
1583
|
+
detail: h(RunDetail, {
|
|
1211
1584
|
model,
|
|
1212
|
-
|
|
1585
|
+
onOpenWorker: (runId, childId) => dispatch({ type: 'openWorker', runId, childId }),
|
|
1586
|
+
onCloseWorker: () => dispatch({ type: 'closeWorker' }),
|
|
1213
1587
|
onCancelRun: runId => dispatch({ type: 'cancelRun', runId }),
|
|
1588
|
+
onInstruct: (runId, text, subtaskIndex) => dispatch({ type: 'instructRun', runId, text, subtaskIndex }),
|
|
1214
1589
|
onDraft: value => dispatch({ type: 'draft', value }),
|
|
1215
1590
|
onAnswer: (runId, attentionId, answer) => dispatch({ type: 'answer', runId, attentionId, answer }),
|
|
1216
1591
|
onArtifact: item => dispatch({ type: 'artifact', item }),
|
|
1217
1592
|
onClosePreview: () => dispatch({ type: 'closePreview' }),
|
|
1593
|
+
onRetryPreview: () => dispatch({ type: 'retryPreview' }),
|
|
1218
1594
|
onReveal: item => dispatch({ type: 'revealArtifact', item }),
|
|
1219
1595
|
onDownload: item => dispatch({ type: 'downloadArtifact', item }),
|
|
1220
|
-
})
|
|
1221
|
-
|
|
1596
|
+
}),
|
|
1597
|
+
})))
|
|
1222
1598
|
}
|
|
1223
1599
|
|
|
1224
1600
|
/** One-line status above the composer; errors stay until replaced. */
|
|
1225
|
-
function
|
|
1601
|
+
function Notice(props) {
|
|
1226
1602
|
if (!props.toast) return null
|
|
1227
1603
|
return h('div', { className: 'dsa-toast', 'data-kind': props.toast.kind }, props.toast.text)
|
|
1228
1604
|
}
|
|
@@ -1236,6 +1612,20 @@ window.__ModuleLoader__.load({
|
|
|
1236
1612
|
|
|
1237
1613
|
const patch = updater => setModel(current => updater(current))
|
|
1238
1614
|
|
|
1615
|
+
async function refreshWorkbench() {
|
|
1616
|
+
const workbench = await call('/workbench')
|
|
1617
|
+
patch(current => current.sessionId === workbench.sessionId ? { ...current, workbench } : current)
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
const taskStates = model.runs.map(run => `${run.id}:${run.status}`).join(',')
|
|
1621
|
+
react.useEffect(() => {
|
|
1622
|
+
if (model.phase !== 'ready') return undefined
|
|
1623
|
+
const refresh = () => refreshWorkbench().catch(() => {})
|
|
1624
|
+
refresh()
|
|
1625
|
+
const timer = setInterval(refresh, 8000)
|
|
1626
|
+
return () => clearInterval(timer)
|
|
1627
|
+
}, [model.phase, model.sessionId, taskStates])
|
|
1628
|
+
|
|
1239
1629
|
// Connect once per attempt: wait for the relay, then follow the feed.
|
|
1240
1630
|
react.useEffect(() => {
|
|
1241
1631
|
let alive = true
|
|
@@ -1254,6 +1644,7 @@ window.__ModuleLoader__.load({
|
|
|
1254
1644
|
capabilities: data?.capabilities ?? null,
|
|
1255
1645
|
approvals: Array.isArray(data?.approvals) ? data.approvals : [],
|
|
1256
1646
|
runs: Array.isArray(data?.runs) ? data.runs : [],
|
|
1647
|
+
goals: Array.isArray(data?.goals) ? data.goals : [],
|
|
1257
1648
|
}))
|
|
1258
1649
|
break
|
|
1259
1650
|
} catch (error) {
|
|
@@ -1291,17 +1682,73 @@ window.__ModuleLoader__.load({
|
|
|
1291
1682
|
if (node) node.scrollTop = node.scrollHeight
|
|
1292
1683
|
}, [model.messages.length, model.typing])
|
|
1293
1684
|
|
|
1294
|
-
//
|
|
1685
|
+
// The host toast fades itself after hold + fade; this timer only sweeps
|
|
1686
|
+
// up when the toast surface is unavailable.
|
|
1295
1687
|
react.useEffect(() => {
|
|
1296
1688
|
if (!model.toast) return undefined
|
|
1297
|
-
const timer = setTimeout(() => patch(current => ({ ...current, toast: null })),
|
|
1689
|
+
const timer = setTimeout(() => patch(current => ({ ...current, toast: null })), 8000)
|
|
1298
1690
|
return () => clearTimeout(timer)
|
|
1299
1691
|
}, [model.toast])
|
|
1300
1692
|
|
|
1301
1693
|
const actions = {
|
|
1302
|
-
|
|
1303
|
-
|
|
1694
|
+
reply: ({ message }) => patch(current => ({ ...current, reply: message ? { id: message.id, text: message.text.slice(0, 800) } : null })),
|
|
1695
|
+
nameWorkbench: async ({ name }) => {
|
|
1696
|
+
const workbench = await call('/workbench', { method: 'POST', body: JSON.stringify({ name }) })
|
|
1697
|
+
patch(current => current.sessionId === workbench.sessionId ? { ...current, workbench } : current)
|
|
1698
|
+
},
|
|
1699
|
+
selectProject: async ({ project }) => {
|
|
1700
|
+
const current = modelRef.current.workbench
|
|
1701
|
+
if ((current?.project?.cwd ?? null) === (project?.cwd ?? null)) return
|
|
1702
|
+
const sessionId = project ? project.sessionId : current?.globalSessionId
|
|
1703
|
+
if (sessionId) await actions.switchSession({ sessionId })
|
|
1704
|
+
else await actions.newSession({ cwd: project?.cwd })
|
|
1705
|
+
},
|
|
1706
|
+
pickProject: async () => {
|
|
1707
|
+
const { cwd } = await call('/projects/pick', { method: 'POST', body: '{}' })
|
|
1708
|
+
if (cwd) await actions.newSession({ cwd })
|
|
1709
|
+
},
|
|
1710
|
+
showOriginalRun: async ({ run }) => {
|
|
1711
|
+
if (run.parentSessionId && run.parentSessionId !== modelRef.current.sessionId) {
|
|
1712
|
+
await actions.switchSession({ sessionId: run.parentSessionId })
|
|
1713
|
+
}
|
|
1714
|
+
await actions.openRun({ runId: run.id, original: true })
|
|
1715
|
+
},
|
|
1716
|
+
openWorkbenchArtifact: async ({ run, item }) => {
|
|
1717
|
+
await actions.showOriginalRun({ run })
|
|
1718
|
+
await actions.artifact({ item })
|
|
1719
|
+
},
|
|
1720
|
+
newGoal: async action => {
|
|
1721
|
+
const sessionId = modelRef.current.sessionId
|
|
1722
|
+
patch(current => ({ ...current, goalBusy: true }))
|
|
1723
|
+
try {
|
|
1724
|
+
const data = await call('/goals', { method: 'POST', body: JSON.stringify({ sessionId, text: action.text }) })
|
|
1725
|
+
patch(current => !current.sessionId || current.sessionId === data.sessionId ? {
|
|
1726
|
+
...current, sessionId: data.sessionId,
|
|
1727
|
+
goals: current.goals.some(goal => goal.id === data.goal.id) ? current.goals : [data.goal, ...current.goals],
|
|
1728
|
+
} : current)
|
|
1729
|
+
} finally {
|
|
1730
|
+
patch(current => ({ ...current, goalBusy: false }))
|
|
1731
|
+
}
|
|
1732
|
+
},
|
|
1733
|
+
goalAction: async ({ goalId, action, body }) => {
|
|
1734
|
+
const sessionId = modelRef.current.sessionId
|
|
1735
|
+
patch(current => ({ ...current, goalBusy: true }))
|
|
1736
|
+
try {
|
|
1737
|
+
await call(`/goals/${encodeURIComponent(goalId)}/${action}`, { method: 'POST', body: JSON.stringify({ ...body, sessionId }) })
|
|
1738
|
+
} finally {
|
|
1739
|
+
patch(current => ({ ...current, goalBusy: false }))
|
|
1740
|
+
}
|
|
1741
|
+
},
|
|
1742
|
+
instructRun: async ({ runId, text, subtaskIndex }) => {
|
|
1304
1743
|
const sessionId = modelRef.current.sessionId
|
|
1744
|
+
await call(`/runs/${encodeURIComponent(runId)}/instruction`, {
|
|
1745
|
+
method: 'POST',
|
|
1746
|
+
body: JSON.stringify({ sessionId, text, subtaskIndex, mode: subtaskIndex === null ? 'followup' : 'inject' }),
|
|
1747
|
+
})
|
|
1748
|
+
},
|
|
1749
|
+
send: async action => {
|
|
1750
|
+
const { reply, sessionId } = modelRef.current
|
|
1751
|
+
const text = reply ? `${reply.text.split(/\r?\n/).map(line => `> ${line}`).join('\n')}\n\n${action.text}` : String(action.text ?? '')
|
|
1305
1752
|
localSeq += 1
|
|
1306
1753
|
const id = `user-local-${localSeq}`
|
|
1307
1754
|
patch(current => ({
|
|
@@ -1310,7 +1757,7 @@ window.__ModuleLoader__.load({
|
|
|
1310
1757
|
typing: true,
|
|
1311
1758
|
messages: [...current.messages, { id, role: 'user', text, at: Date.now(), pending: true }],
|
|
1312
1759
|
}))
|
|
1313
|
-
const mode = modelRef.current.typing ? 'steer' : 'queue'
|
|
1760
|
+
const mode = reply && modelRef.current.typing ? 'steer' : 'queue'
|
|
1314
1761
|
try {
|
|
1315
1762
|
await call('/message', {
|
|
1316
1763
|
method: 'POST',
|
|
@@ -1325,7 +1772,7 @@ window.__ModuleLoader__.load({
|
|
|
1325
1772
|
}))
|
|
1326
1773
|
throw error
|
|
1327
1774
|
}
|
|
1328
|
-
patch(current => ({ ...current, sending: false }))
|
|
1775
|
+
patch(current => ({ ...current, sending: false, reply: current.reply === reply ? null : current.reply }))
|
|
1329
1776
|
},
|
|
1330
1777
|
decide: async action => {
|
|
1331
1778
|
const { id, decision } = action
|
|
@@ -1345,7 +1792,7 @@ window.__ModuleLoader__.load({
|
|
|
1345
1792
|
},
|
|
1346
1793
|
cancel: async () => {
|
|
1347
1794
|
patch(current => ({ ...current, canceling: true }))
|
|
1348
|
-
const running = (modelRef.current.runs ?? []).filter(run => run.
|
|
1795
|
+
const running = (modelRef.current.runs ?? []).filter(run => !run.goalId && ACTIVE_RUN.has(run.status))
|
|
1349
1796
|
const settled = await Promise.allSettled([
|
|
1350
1797
|
call('/cancel', { method: 'POST', body: JSON.stringify({ sessionId: modelRef.current.sessionId }) }),
|
|
1351
1798
|
...running.map(run => call(`/runs/${encodeURIComponent(run.id)}/cancel`, { method: 'POST' })),
|
|
@@ -1378,11 +1825,11 @@ window.__ModuleLoader__.load({
|
|
|
1378
1825
|
throw error
|
|
1379
1826
|
}
|
|
1380
1827
|
},
|
|
1381
|
-
newSession: async () => {
|
|
1828
|
+
newSession: async ({ cwd }) => {
|
|
1382
1829
|
patch(current => ({ ...current, sessionsBusy: true }))
|
|
1383
1830
|
try {
|
|
1384
|
-
await call('/session', { method: 'POST', body:
|
|
1385
|
-
patch(current => ({ ...current, sessionsBusy: false, sessionsOpen: false }))
|
|
1831
|
+
const data = await call('/session', { method: 'POST', body: JSON.stringify({ cwd }) })
|
|
1832
|
+
patch(current => ({ ...applyFrame(current, { type: 'session', sessionId: data.sessionId }), sessionsBusy: false, sessionsOpen: false }))
|
|
1386
1833
|
} catch (error) {
|
|
1387
1834
|
patch(current => ({ ...current, sessionsBusy: false }))
|
|
1388
1835
|
throw error
|
|
@@ -1391,24 +1838,35 @@ window.__ModuleLoader__.load({
|
|
|
1391
1838
|
switchSession: async action => {
|
|
1392
1839
|
patch(current => ({ ...current, sessionsBusy: true }))
|
|
1393
1840
|
try {
|
|
1394
|
-
await call('/session/switch', { method: 'POST', body: JSON.stringify({ sessionId: action.sessionId }) })
|
|
1395
|
-
patch(current => ({ ...current, sessionsBusy: false, sessionsOpen: false }))
|
|
1841
|
+
const data = await call('/session/switch', { method: 'POST', body: JSON.stringify({ sessionId: action.sessionId }) })
|
|
1842
|
+
patch(current => ({ ...applyFrame(current, { type: 'session', sessionId: data.sessionId }), sessionsBusy: false, sessionsOpen: false }))
|
|
1396
1843
|
} catch (error) {
|
|
1397
1844
|
patch(current => ({ ...current, sessionsBusy: false }))
|
|
1398
1845
|
throw error
|
|
1399
1846
|
}
|
|
1400
1847
|
},
|
|
1401
1848
|
openRun: async action => {
|
|
1849
|
+
const listed = modelRef.current.workbench?.runs?.find(run => run.id === action.runId)
|
|
1850
|
+
if (!action.original && listed?.parentSessionId && listed.parentSessionId !== modelRef.current.sessionId) {
|
|
1851
|
+
patch(current => ({ ...current, workbenchRun: action.runId, detail: null, preview: null }))
|
|
1852
|
+
return
|
|
1853
|
+
}
|
|
1402
1854
|
patch(current => ({ ...current, detailBusy: true }))
|
|
1403
1855
|
try {
|
|
1404
1856
|
const run = await call(`/runs/${encodeURIComponent(action.runId)}`)
|
|
1405
|
-
patch(current => ({ ...current, detail: run, detailBusy: false, answerDraft: '' }))
|
|
1857
|
+
patch(current => ({ ...current, detail: run, workbenchRun: null, workerSession: null, detailBusy: false, answerDraft: '', preview: null }))
|
|
1406
1858
|
} catch (error) {
|
|
1407
1859
|
patch(current => ({ ...current, detailBusy: false }))
|
|
1408
1860
|
throw error
|
|
1409
1861
|
}
|
|
1410
1862
|
},
|
|
1411
|
-
|
|
1863
|
+
openWorker: async ({ runId, childId }) => {
|
|
1864
|
+
const data = await call(`/runs/${encodeURIComponent(runId)}/worker/${encodeURIComponent(childId)}`)
|
|
1865
|
+
const transcript = applyFrame(initialModel(), { type: 'stream.snapshot', records: data.records })
|
|
1866
|
+
patch(current => current.detail?.id === runId ? { ...current, workerSession: { title: data.title, transcript } } : current)
|
|
1867
|
+
},
|
|
1868
|
+
closeWorker: () => patch(current => ({ ...current, workerSession: null })),
|
|
1869
|
+
closeRun: () => patch(current => ({ ...current, workbenchRun: null, workerSession: null, detail: null, answerDraft: '', preview: null, previewText: '', previewError: '', previewBusy: false })),
|
|
1412
1870
|
cancelRun: async action => {
|
|
1413
1871
|
await call(`/runs/${encodeURIComponent(action.runId)}/cancel`, { method: 'POST' })
|
|
1414
1872
|
patch(current => ({
|
|
@@ -1454,6 +1912,7 @@ window.__ModuleLoader__.load({
|
|
|
1454
1912
|
...current,
|
|
1455
1913
|
preview: { name: item.name ?? href, url, kind },
|
|
1456
1914
|
previewText: '',
|
|
1915
|
+
previewError: '',
|
|
1457
1916
|
previewBusy: kind === 'md' || kind === 'text',
|
|
1458
1917
|
}))
|
|
1459
1918
|
if (kind !== 'md' && kind !== 'text') return
|
|
@@ -1461,12 +1920,25 @@ window.__ModuleLoader__.load({
|
|
|
1461
1920
|
const res = await fetch(url, { headers: { accept: 'text/plain, text/markdown, */*' } })
|
|
1462
1921
|
const text = await res.text()
|
|
1463
1922
|
if (!res.ok) throw new Error(text.slice(0, 200) || `HTTP ${res.status}`)
|
|
1923
|
+
patch(current => ({ ...current, previewBusy: false, previewText: text, previewError: '' }))
|
|
1924
|
+
} catch (error) {
|
|
1925
|
+
patch(current => ({ ...current, previewBusy: false, previewError: `这个产物读不出来:${error.message}` }))
|
|
1926
|
+
}
|
|
1927
|
+
},
|
|
1928
|
+
retryPreview: async () => {
|
|
1929
|
+
const preview = modelRef.current.preview
|
|
1930
|
+
if (!preview) return
|
|
1931
|
+
patch(current => ({ ...current, previewBusy: true, previewError: '', previewText: '' }))
|
|
1932
|
+
try {
|
|
1933
|
+
const res = await fetch(preview.url, { headers: { accept: 'text/plain, text/markdown, */*' } })
|
|
1934
|
+
const text = await res.text()
|
|
1935
|
+
if (!res.ok) throw new Error(text.slice(0, 200) || `HTTP ${res.status}`)
|
|
1464
1936
|
patch(current => ({ ...current, previewBusy: false, previewText: text }))
|
|
1465
1937
|
} catch (error) {
|
|
1466
|
-
patch(current => ({ ...current, previewBusy: false,
|
|
1938
|
+
patch(current => ({ ...current, previewBusy: false, previewError: `这个产物读不出来:${error.message}` }))
|
|
1467
1939
|
}
|
|
1468
1940
|
},
|
|
1469
|
-
closePreview: () => patch(current => ({ ...current, preview: null, previewText: '', previewBusy: false })),
|
|
1941
|
+
closePreview: () => patch(current => ({ ...current, preview: null, previewText: '', previewError: '', previewBusy: false })),
|
|
1470
1942
|
revealArtifact: async action => {
|
|
1471
1943
|
const item = action.item ?? {}
|
|
1472
1944
|
const query = `?path=${encodeURIComponent(item.href ?? '')}&runId=${encodeURIComponent(item.runId ?? '')}`
|
|
@@ -1474,7 +1946,7 @@ window.__ModuleLoader__.load({
|
|
|
1474
1946
|
},
|
|
1475
1947
|
downloadArtifact: action => {
|
|
1476
1948
|
const item = action.item ?? {}
|
|
1477
|
-
const url = `${API}/artifact?download=1&path=${encodeURIComponent(item.href ?? '')}`
|
|
1949
|
+
const url = `${API}/artifact?download=1&path=${encodeURIComponent(item.href ?? '')}&runId=${encodeURIComponent(item.runId ?? '')}`
|
|
1478
1950
|
+ `&runId=${encodeURIComponent(item.runId ?? '')}`
|
|
1479
1951
|
if (typeof window !== 'undefined' && typeof window.open === 'function') window.open(url, '_blank', 'noopener')
|
|
1480
1952
|
},
|
|
@@ -1499,13 +1971,14 @@ window.__ModuleLoader__.load({
|
|
|
1499
1971
|
setAttempt(value => value + 1)
|
|
1500
1972
|
},
|
|
1501
1973
|
toast: action => patch(current => ({ ...current, toast: { kind: 'err', text: String(action.text ?? '') } })),
|
|
1974
|
+
dismissToast: () => patch(current => ({ ...current, toast: null })),
|
|
1502
1975
|
}
|
|
1503
1976
|
|
|
1504
1977
|
const dispatch = action => {
|
|
1505
1978
|
// The shell must survive a failed action: show it, never throw.
|
|
1506
1979
|
const run = actions[action.type]
|
|
1507
1980
|
if (!run) return
|
|
1508
|
-
Promise.resolve(run(action)).catch(error => {
|
|
1981
|
+
return Promise.resolve().then(() => run(action)).then(() => true).catch(error => {
|
|
1509
1982
|
patch(current => ({
|
|
1510
1983
|
...current,
|
|
1511
1984
|
reason: error.message,
|
|
@@ -1513,6 +1986,7 @@ window.__ModuleLoader__.load({
|
|
|
1513
1986
|
toast: { kind: 'err', text: `${error.message}${error.hint ? ` ${error.hint}` : ''}` },
|
|
1514
1987
|
phase: current.phase === 'loading' ? 'error' : current.phase,
|
|
1515
1988
|
}))
|
|
1989
|
+
return false
|
|
1516
1990
|
})
|
|
1517
1991
|
}
|
|
1518
1992
|
|
|
@@ -1527,7 +2001,7 @@ window.__ModuleLoader__.load({
|
|
|
1527
2001
|
function EntryIcon(props) {
|
|
1528
2002
|
const size = typeof props?.size === 'number' ? props.size : 16
|
|
1529
2003
|
const host = ICONS.spark
|
|
1530
|
-
if (
|
|
2004
|
+
if (isComponent(host)) return h(host, { size })
|
|
1531
2005
|
return h('svg', {
|
|
1532
2006
|
viewBox: '0 0 16 16',
|
|
1533
2007
|
width: size,
|