@xiangyixie/dsh-superagent 0.18.4 → 0.22.0

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/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, FishLogo, the host icon set)
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
- const MISSING_PRIMITIVES = ['Button', 'FishLogo', 'MarkdownText', 'UserMessageBubble', 'StateDot', 'Tooltip']
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) === '1'
132
+ return window.localStorage.getItem(RAIL_KEY) !== '0'
104
133
  } catch (error) {
105
- return false
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,rgb(21,21,23));color:var(--dsw-alias-label-primary,#f9fafb);font-family:var(--dsw-font-family,inherit);font-size:14px;line-height:22px}
164
- .dsa-header{display:flex;align-items:center;gap:10px;flex:none;box-sizing:border-box;min-height:76px;padding:10px 28px 0 20px;border-bottom:.5px solid var(--dsw-alias-border-l3,rgba(255,255,255,.12))}
165
- .dsa-crumbs{display:flex;align-items:center;gap:4px;flex:1;min-width:0;overflow:hidden;white-space:nowrap}
166
- .dsa-crumb{display:inline-block;max-width:220px;overflow:hidden;padding:4px 8px;border:0;border-radius:var(--dsw-radius-md,12px);background:transparent;color:var(--dsw-alias-label-tertiary,rgb(129,133,140));font-size:14px;line-height:20px;text-overflow:ellipsis;white-space:nowrap}
167
- .dsa-crumb-current{font-weight:500;color:var(--dsw-alias-label-primary,#f9fafb)}
168
- .dsa-sep{color:var(--dsw-alias-label-caption,rgb(129,133,140));font-size:14px;line-height:20px}
169
- .dsa-head-actions{display:flex;flex:none;align-items:center;gap:8px;margin-left:20px}
170
- .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,8px);background:transparent;color:var(--dsw-alias-label-secondary,rgb(207,211,214));cursor:pointer}
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,rgba(255,255,255,.08))}
173
- .dsa-iconbtn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-alias-state-business-primary,#7aaaff);outline-offset:-2px}
174
- .dsa-railtoggle{position:relative}
175
- .dsa-railtoggle[aria-expanded=false] svg{transform:scaleX(-1)}
176
- .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,#4d6bfe);color:#fff;font-size:9px;line-height:14px;font-weight:600;text-align:center;box-sizing:border-box}
177
- .dsa-body{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 0;grid-template-rows:minmax(0,1fr);flex:1;min-height:0;overflow:hidden;transition:grid-template-columns var(--ds-transition-duration-slow,240ms) var(--ds-ease-in-out,ease)}
178
- .dsa-body[data-rail=open]{grid-template-columns:minmax(0,1fr) 360px}
179
- .dsa-main{grid-column:1;grid-row:1;position:relative;display:flex;flex-direction:column;min-width:0;min-height:0}
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,rgba(255,255,255,.16))}
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
- .dsa-hero{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:0 24px}
185
- .dsa-hero-stack{display:flex;flex-direction:column;gap:12px;width:100%;max-width:calc(var(--dsa-col) + 32px);padding-bottom:32px}
186
- .dsa-hero-title{display:flex;align-items:center;justify-content:center;gap:10px;font-size:26px;line-height:32px;font-weight:500;color:var(--dsw-alias-label-primary,#f9fafb)}
187
- .dsa-hero-note{text-align:center;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
188
- .dsa-composer{flex:none;padding:0 16px 4px;background:var(--dsw-alias-bg-base,rgb(21,21,23))}
189
- .dsa-card{display:flex;flex-direction:column;gap:12px;box-sizing:border-box;width:100%;max-width:calc(var(--dsa-col) + 32px);margin:0 auto;padding-top:8px;border-radius:var(--dsw-radius-panel,28px);background:var(--dsw-specific-input-major,rgb(35,35,36));box-shadow:var(--dsw-elevation-soft,0 2px 12px rgba(0,0,0,.18))}
190
- .dsa-input{box-sizing:border-box;width:100%;min-height:36px;max-height:336px;padding:4px 8px 0 14px;border:0;outline:none;background:transparent;color:var(--dsw-alias-label-primary,#f9fafb);font:inherit;font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));resize:none;overflow-y:auto}
191
- .dsa-input::placeholder{color:var(--dsw-alias-label-caption,rgb(129,133,140))}
192
- .dsa-card[data-hero=true] .dsa-input{min-height:52px}
193
- .dsa-row{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:12px;padding:2px 8px 6px;min-width:0}
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-add{display:grid;place-items:center;flex:none;width:28px;height:28px;border:0;border-radius:999px;background:var(--dsw-specific-selector,rgba(255,255,255,.08));color:var(--dsw-alias-label-primary,#f9fafb);cursor:pointer}
197
- .dsa-add:hover{background:var(--dsw-alias-interactive-bg-hover-solid,rgba(255,255,255,.14))}
198
- .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,#3964fe);color:var(--dsw-alias-label-on-color,#fff);cursor:pointer;transform:translateY(-2px);transition:background-color 100ms ease}
199
- .dsa-send:hover:not(:disabled){background:var(--dsw-alias-button-info-hover,#2f57e6)}
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 rgba(255,255,255,.35);border-top-color:var(--dsw-alias-label-on-color,#fff);animation:dsa-spin .8s linear infinite}
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
- .dsa-user{display:flex;flex-direction:column;align-items:flex-end;gap:6px;margin-bottom:16px}
208
- .dsa-bubble{max-width:min(calc(var(--dsa-col) * .702),82%);padding:10px 16px;border-radius:var(--dsw-radius-xl,20px);background:var(--dsw-specific-bubble,var(--dsw-static-deepseek-50,#eef4ff));color:var(--dsw-alias-label-primary,#f9fafb);font-size:var(--dsh-content-font-size,14px);line-height:calc(22px + var(--dsh-content-font-delta,0px));white-space:pre-wrap;overflow-wrap:anywhere}
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:6px;margin-bottom:16px;font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));overflow-wrap:anywhere}
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
- .dsa-tools-row{display:flex;flex-wrap:wrap;gap:6px}
213
- .dsa-tool{display:inline-flex;align-items:center;gap:6px;height:24px;padding:0 8px;border-radius:var(--dsw-radius-xs,4px);background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06));font-size:12px;line-height:16px;color:var(--dsw-alias-label-secondary,rgb(207,211,214))}
214
- .dsa-tool[data-status=err]{color:var(--dsw-alias-state-error-primary,#f25a5a)}
215
- .dsa-reasoning{font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140));white-space:pre-wrap}
216
- .dsa-typing{display:inline-flex;align-items:center;gap:8px;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
217
- .dsa-approvals{display:flex;flex-direction:column;gap:8px;width:min(calc(100% - 64px),var(--dsa-col));margin:0 auto;padding:0 0 8px}
218
- .dsa-approval{display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--dsw-alias-state-warn-secondary,var(--dsw-static-amber-400,#fbbf24));border-radius:var(--dsw-radius-xl,20px);background:var(--dsw-specific-input-major,rgb(35,35,36));box-shadow:var(--dsw-shadow-lv2,0 4px 16px rgba(0,0,0,.18))}
219
- .dsa-approval-bar{display:flex;align-items:center;gap:8px;padding:8px 14px;background:var(--dsw-alias-state-warn-tertiary,var(--dsw-static-amber-100,#fef3c7));color:var(--dsw-alias-state-warn-label,var(--dsw-static-amber-600,#d97706));font-size:13px;line-height:20px;font-weight:500}
220
- .dsa-approval-main{display:flex;flex-direction:column;gap:10px;padding:12px 14px}
221
- .dsa-approval-title{font-size:14px;line-height:22px;font-weight:500;color:var(--dsw-alias-label-primary,#f9fafb)}
222
- .dsa-approval-body{font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary,rgb(207,211,214));overflow-wrap:anywhere}
223
- .dsa-approval-actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end}
224
- .dsa-rail{grid-column:2;grid-row:1;justify-self:end;display:flex;flex-direction:column;width:360px;max-width:min(84vw,360px);min-width:0;box-sizing:border-box;padding:8px;border-left:.5px solid var(--dsw-alias-border-l3,rgba(255,255,255,.12));background:var(--dsw-alias-bg-base,rgb(21,21,23));overflow:hidden;visibility:hidden;transform:translateX(100%);transition:transform var(--ds-transition-duration-slow,240ms) var(--ds-ease-in-out,ease),visibility 0s linear var(--ds-transition-duration-slow,240ms)}
225
- .dsa-body[data-rail=open] .dsa-rail{visibility:visible;transform:none;transition:transform var(--ds-transition-duration-slow,240ms) var(--ds-ease-in-out,ease)}
226
- @media (max-width:960px){
227
- .dsa-body[data-rail=open]{grid-template-columns:minmax(0,1fr) 0}
228
- .dsa-body[data-rail=open] .dsa-rail{box-shadow:var(--dsw-shadow-lv2,0 8px 28px rgba(0,0,0,.32))}
229
- }
230
- @media (prefers-reduced-motion:reduce){
231
- .dsa-body,.dsa-rail,.dsa-body[data-rail=open] .dsa-rail{transition:none}
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,rgb(129,133,140));margin-inline-end:-1px}
243
- .dsa-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;height:100%;padding:24px;text-align:center}
244
- .dsa-note{font-size:13px;line-height:1.6;color:var(--dsw-alias-label-secondary,rgb(207,211,214))}
245
- .dsa-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-caption,rgb(129,133,140))}
246
- .dsa-toast{display:flex;align-items:center;gap:8px;margin:8px auto 0;width:min(calc(100% - 64px),var(--dsa-col));padding:6px 10px;border-radius:var(--dsw-radius-md,12px);background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08));color:var(--dsw-alias-label-secondary,rgb(207,211,214));font-size:12px;line-height:18px}
247
- .dsa-toast[data-kind=err]{color:var(--dsw-alias-state-error-primary,#f25a5a)}
248
- .dsa-sessions{position:absolute;top:64px;right:20px;z-index:30;display:flex;flex-direction:column;width:300px;max-height:min(60vh,440px);padding:8px;border:1px solid var(--dsw-alias-border-l3,rgba(255,255,255,.12));border-radius:var(--dsw-radius-lg,16px);background:var(--dsw-alias-bg-base,rgb(21,21,23));box-shadow:var(--dsw-shadow-lv2,0 8px 28px rgba(0,0,0,.32))}
249
- .dsa-sessions-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:4px 6px 8px;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
250
- .dsa-sessions-new,.dsa-linkbtn{border:0;background:transparent;color:var(--dsw-alias-state-business-primary,#7aaaff);font:inherit;font-size:12px;line-height:18px;cursor:pointer;padding:2px 6px;border-radius:var(--dsw-radius-sm,8px)}
251
- .dsa-sessions-new:hover,.dsa-linkbtn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}
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{height:40px;gap:8px;cursor:pointer}
254
- .dsa-session-row[data-current=true]{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}
255
- .dsa-session-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px}
256
- .dsa-session-meta{flex:none;font-size:10px;line-height:16px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
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
- .dsa-detail{position:absolute;inset:0;z-index:20;display:flex;flex-direction:column;background:var(--dsw-alias-bg-base,rgb(21,21,23))}
259
- .dsa-detail-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 16px;border-bottom:.5px solid var(--dsw-alias-border-l3,rgba(255,255,255,.12))}
260
- .dsa-detail-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;font-weight:500}
261
- .dsa-detail-body{flex:1;min-height:0;overflow-y:auto;padding:12px 16px;display:flex;flex-direction:column;gap:12px}
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:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
264
- .dsa-detail-item{display:flex;flex-direction:column;gap:4px;padding:8px 10px;border-radius:var(--dsw-radius-md,12px);background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))}
265
- .dsa-detail-q{font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary,#f9fafb);white-space:pre-wrap}
266
- .dsa-answer-row{display:flex;gap:6px}
267
- .dsa-answer-input{flex:1;min-width:0;box-sizing:border-box;padding:5px 8px;border:1px solid var(--dsw-alias-border-l3,rgba(255,255,255,.16));border-radius:var(--dsw-radius-sm,8px);background:transparent;color:var(--dsw-alias-label-primary,#f9fafb);font:inherit;font-size:12px;outline:none}
268
- .dsa-artifact-link{display:flex;align-items:center;gap:6px;width:100%;padding:5px 8px;border:0;border-radius:var(--dsw-radius-sm,8px);background:transparent;color:var(--dsw-alias-state-business-primary,#7aaaff);font:inherit;font-size:12px;text-align:left;cursor:pointer}
269
- .dsa-artifact-link:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}
270
- .dsa-attention{display:flex;flex-direction:column;gap:8px;margin:8px 0}
271
- .dsa-attention-card{display:flex;flex-direction:column;gap:8px;padding:12px 14px;border:1px solid var(--dsw-alias-state-warning-primary,rgba(255,193,64,.45));border-radius:var(--dsw-radius-lg,16px);background:var(--dsw-alias-bg-base,rgb(21,21,23))}
272
- .dsa-attention-head{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-state-warning-primary,#ffc140)}
273
- .dsa-attention-dot{width:7px;height:7px;border-radius:50%;background:var(--dsw-alias-state-warning-primary,#ffc140)}
274
- .dsa-attention-options{display:flex;flex-wrap:wrap;gap:6px}
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:1px solid var(--dsw-alias-border-l3,rgba(255,255,255,.16));border-radius:var(--dsw-radius-md,12px);padding:8px}
278
- .dsa-preview-img{display:block;max-width:100%;border-radius:var(--dsw-radius-sm,8px)}
279
- .dsa-preview-frame{width:100%;height:320px;border:0;border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-bg-base,rgb(21,21,23))}
280
- .dsa-preview-text{max-height:320px;overflow:auto;white-space:pre-wrap;word-break:break-word;font:inherit;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,rgb(207,211,214))}
281
- .dsa-chip{padding:3px 10px;border:1px solid var(--dsw-alias-border-l3,rgba(255,255,255,.16));border-radius:999px;background:transparent;color:var(--dsw-alias-label-primary,#f9fafb);font:inherit;font-size:12px;line-height:18px;cursor:pointer}
282
- .dsa-chip:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}
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 (typeof component !== 'function') return null
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 detail = model.detail ? runs.find(run => run.id === model.detail.id) ?? model.detail : null
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 fresh = []
608
- for (const run of runs) {
609
- for (const item of Array.isArray(run.attention) ? run.attention : []) {
610
- if (item?.id && !seen.includes(item.id) && !fresh.includes(item.id)) fresh.push(item.id)
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 { railOpen, runningCount, onToggleRail, onToggleSessions, sessionsOpen, unread } = props
630
- const toggleLabel = railOpen ? '收起任务栏(Ctrl+Shift+B)' : '展开任务栏(Ctrl+Shift+B)'
708
+ const { title, railOpen, onToggleRail, onToggleSessions, sessionsOpen, unread } = props
709
+ const toggleLabel = railOpen ? '收起工作台' : '打开工作台'
631
710
  return h('header', { className: 'dsa-header' },
632
- h('div', { className: 'dsa-crumbs' },
633
- h('span', { className: 'dsa-crumb dsa-crumb-current' }, PANEL_LABEL)),
634
- h('div', { className: 'dsa-head-actions' },
635
- tipped(unread > 0 ? `会话(${unread} 个新问题)` : '会话', h('button', {
636
- type: 'button',
637
- className: 'dsa-iconbtn',
638
- 'aria-label': '会话',
639
- 'aria-expanded': sessionsOpen ? 'true' : 'false',
640
- onClick: onToggleSessions,
641
- }, h(Icon, { of: 'clock' }),
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('div', { key: 'reasoning', className: 'dsa-reasoning' }, message.reasoning))
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-tools-row' }, tools.map(tool => {
671
- const chip = h('span', {
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
- className: 'dsa-tool',
674
- 'data-status': tool.status,
675
- }, tool.name)
676
- return typeof tool.arguments === 'string' && tool.arguments
677
- ? (Tooltip
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 { hero, disabled, onSend } = props
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', 'data-hero': hero ? 'true' : 'false' },
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: hero ? '想让我做什么?' : '继续这条对话…',
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' }) : '+'), 'top'),
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
- : tipped('发送', h('button', {
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 runs = Array.isArray(model.runs) ? model.runs : []
867
- const running = runs.filter(run => run.status === 'running').length
868
- return h('aside', { className: 'dsa-rail', 'aria-label': '调度的会话' },
869
- h('div', { className: 'dsa-rail-head' },
870
- h('span', null, '调度的会话'),
871
- h('span', { className: 'dsa-rail-count' }, running > 0 ? `${running} 运行中` : `${runs.length}`)),
872
- h('div', { className: 'dsa-rail-list' },
873
- runs.length === 0
874
- ? h('div', { className: 'dsa-hint', style: { padding: '8px' } }, '超级智能体还没有调度新的会话')
875
- : runs.map(run => {
876
- // A run with an unanswered attention item is waiting on the user,
877
- // not running: show that as its own amber state.
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 tipped(run.goal ?? '', h('button', {
880
- key: run.id,
881
- type: 'button',
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
- h('span', { className: 'dsa-rowdot', 'data-status': waiting ? 'waiting' : run.status }),
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 === 'running' ? '运行中' : run.status === 'completed' ? '完成' : '已停')), 'left', run.id)
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
- h('button', {
919
- type: 'button',
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
- const attention = Array.isArray(run.attention) ? run.attention : []
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
- }, run.status === 'running' ? '停止' : '已停'),
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
- : h('div', { className: 'dsa-preview-text' },
974
- model.previewBusy
975
- ? '读取中…'
976
- : model.preview.kind === 'md' && MarkdownText
977
- ? h(MarkdownText, { text: model.previewText, labels: MARKDOWN_LABELS })
978
- : model.previewText))
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
- h('input', {
990
- className: 'dsa-answer-input',
991
- value: model.answerDraft,
992
- placeholder: '写下你的回答',
993
- onInput: event => props.onDraft?.(event.target.value),
994
- onKeyDown: event => {
995
- if (event.key === 'Enter' && !event.nativeEvent?.isComposing) {
996
- event.preventDefault()
997
- props.onAnswer?.(run.id, item.id, model.answerDraft)
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-detail-label' }, '报告'),
1033
- h('div', { className: 'dsa-md-plain' }, run.report))
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,74 @@ 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-detail-q' }, item.question ?? '有一个问题需要你回答'),
1060
- item.reason ? h('div', { className: 'dsa-detail-label' }, item.reason) : null,
1061
- h('div', { className: 'dsa-answer-row' },
1062
- h('input', {
1063
- className: 'dsa-answer-input',
1064
- value: model.answerDraft,
1065
- placeholder: options.length > 0 ? '或者直接写别的回答' : '写下你的回答',
1066
- onInput: event => props.onDraft?.(event.target.value),
1067
- onKeyDown: event => {
1068
- if (event.key === 'Enter' && !event.nativeEvent?.isComposing) {
1069
- event.preventDefault()
1070
- props.onAnswer?.(run.id, item.id, model.answerDraft)
1071
- }
1072
- },
1073
- }),
1074
- h(Button ?? 'button', {
1075
- variant: Button ? 'primary' : undefined,
1076
- type: Button ? undefined : 'button',
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
+ h(Button ?? 'button', {
1429
+ variant: Button ? 'primary' : undefined,
1430
+ size: Button ? 'sm' : undefined,
1431
+ type: Button ? undefined : 'button',
1432
+ disabled: !draft.trim(),
1433
+ onClick: submit,
1434
+ }, '回答'))),
1080
1435
  options.length > 0
1081
- ? h('div', { className: 'dsa-attention-options' },
1082
- options.map(option => h('button', {
1083
- key: option,
1084
- type: 'button',
1085
- className: 'dsa-chip',
1086
- onClick: () => props.onAnswer?.(run.id, item.id, option),
1087
- }, option)))
1436
+ ? h('div', { className: 'dsa-attention-footer' },
1437
+ h('div', { className: 'dsa-attention-options' },
1438
+ options.map(option => (Pill
1439
+ ? h(Pill, { key: option, onClick: () => props.onAnswer?.(run.id, item.id, option) }, option)
1440
+ : h('button', {
1441
+ key: option,
1442
+ type: 'button',
1443
+ className: 'dsa-chip',
1444
+ onClick: () => props.onAnswer?.(run.id, item.id, option),
1445
+ }, option)))))
1088
1446
  : null)
1089
1447
  }))
1090
1448
  }
1091
1449
 
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
1450
  function Seat(props) {
1106
1451
  const { model, dispatch } = props
1107
1452
  // Hooks must run before the loading/error early returns.
@@ -1113,6 +1458,13 @@ window.__ModuleLoader__.load({
1113
1458
  return next
1114
1459
  })
1115
1460
  }
1461
+ const inspectRun = runId => {
1462
+ if (!railOpen) {
1463
+ setRailOpen(true)
1464
+ saveRailOpen(true)
1465
+ }
1466
+ return dispatch({ type: 'openRun', runId })
1467
+ }
1116
1468
  react.useEffect(() => {
1117
1469
  if (typeof window === 'undefined' || typeof window.addEventListener !== 'function') return undefined
1118
1470
  const onKey = event => {
@@ -1149,14 +1501,11 @@ window.__ModuleLoader__.load({
1149
1501
  onClick: () => dispatch({ type: 'retry' }),
1150
1502
  }, '重试')))
1151
1503
  }
1152
- const empty = model.messages.length === 0
1153
- const runningCount = Array.isArray(model.runs)
1154
- ? model.runs.filter(run => run.status === 'running').length
1155
- : 0
1504
+ const chatUnavailable = model.capabilities?.chat === false
1156
1505
  return h('div', { className: 'dsa-root', 'data-rail': railOpen ? 'open' : 'closed' },
1157
1506
  h(Header, {
1507
+ title: model.workbench?.project?.name || model.workbench?.name || PANEL_LABEL,
1158
1508
  railOpen,
1159
- runningCount,
1160
1509
  unread: model.unread ?? 0,
1161
1510
  sessionsOpen: model.sessionsOpen === true,
1162
1511
  onToggleRail: toggleRail,
@@ -1164,27 +1513,30 @@ window.__ModuleLoader__.load({
1164
1513
  }),
1165
1514
  h(SessionsPanel, {
1166
1515
  model,
1167
- onNew: () => dispatch({ type: 'newSession' }),
1516
+ onNew: () => dispatch({ type: 'newSession', cwd: model.workbench?.project?.cwd }),
1168
1517
  onSwitch: sessionId => dispatch({ type: 'switchSession', sessionId }),
1169
1518
  onClose: () => dispatch({ type: 'sessions', open: false }),
1170
1519
  }),
1171
- h(Toast, { toast: model.toast }),
1520
+ model.toast
1521
+ ? (Toast
1522
+ ? h(Toast, {
1523
+ key: model.toast.text,
1524
+ text: model.toast.text,
1525
+ tone: model.toast.kind === 'ok' ? 'success' : undefined,
1526
+ holdMs: model.toast.kind === 'err' ? 6000 : 3000,
1527
+ onDone: () => dispatch({ type: 'dismissToast' }),
1528
+ })
1529
+ : h(Notice, { toast: model.toast }))
1530
+ : null,
1172
1531
  h('div', { className: 'dsa-body', 'data-rail': railOpen ? 'open' : 'closed' },
1532
+ h(ProjectNav, {
1533
+ workbench: model.workbench,
1534
+ onSelect: entry => dispatch({ type: 'selectProject', project: entry }),
1535
+ onAdd: cwd => dispatch({ type: 'newSession', cwd }),
1536
+ onPick: () => dispatch({ type: 'pickProject' }),
1537
+ }),
1173
1538
  h('div', { className: 'dsa-main' },
1174
- empty
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 }),
1539
+ h(Transcript, { model, scrollRef: model.scrollRef, onReply: message => dispatch({ type: 'reply', message }) }),
1188
1540
  h(Approvals, {
1189
1541
  approvals: model.approvals,
1190
1542
  busy: model.approvalBusy,
@@ -1195,9 +1547,15 @@ window.__ModuleLoader__.load({
1195
1547
  onDraft: value => dispatch({ type: 'draft', value }),
1196
1548
  onAnswer: (runId, attentionId, answer) => dispatch({ type: 'answer', runId, attentionId, answer }),
1197
1549
  }),
1198
- empty ? null : h(Composer, {
1550
+ h(GoalCards, {
1551
+ model,
1552
+ onOpen: inspectRun,
1553
+ onAction: (goalId, action, body) => dispatch({ type: 'goalAction', goalId, action, body }),
1554
+ }),
1555
+ chatUnavailable ? h('div', { className: 'dsa-detail-label', role: 'status' }, model.capabilities.reason || '暂时无法对话') : null,
1556
+ h(Composer, {
1199
1557
  model,
1200
- disabled: model.sending || model.capabilities?.chat === false,
1558
+ disabled: model.sending || model.goalBusy || chatUnavailable,
1201
1559
  running: model.typing,
1202
1560
  canceling: model.canceling,
1203
1561
  insert: model.uploadInsert,
@@ -1206,23 +1564,35 @@ window.__ModuleLoader__.load({
1206
1564
  onUpload: file => dispatch({ type: 'upload', file }),
1207
1565
  onStop: () => dispatch({ type: 'cancel' }),
1208
1566
  onSend: text => dispatch({ type: 'send', text }),
1209
- }),
1210
- h(RunDetail, {
1567
+ onGoal: text => dispatch({ type: 'newGoal', text }),
1568
+ onClearReply: () => dispatch({ type: 'reply' }),
1569
+ })),
1570
+ h(Rail, {
1571
+ model,
1572
+ onOpen: inspectRun,
1573
+ onCloseRun: () => dispatch({ type: 'closeRun' }),
1574
+ onName: name => dispatch({ type: 'nameWorkbench', name }),
1575
+ onOpenSession: run => dispatch({ type: 'showOriginalRun', run }),
1576
+ onArtifact: (run, item) => dispatch({ type: 'openWorkbenchArtifact', run, item }),
1577
+ detail: h(RunDetail, {
1211
1578
  model,
1212
- onClose: () => dispatch({ type: 'closeRun' }),
1579
+ onOpenWorker: (runId, childId) => dispatch({ type: 'openWorker', runId, childId }),
1580
+ onCloseWorker: () => dispatch({ type: 'closeWorker' }),
1213
1581
  onCancelRun: runId => dispatch({ type: 'cancelRun', runId }),
1582
+ onInstruct: (runId, text, subtaskIndex) => dispatch({ type: 'instructRun', runId, text, subtaskIndex }),
1214
1583
  onDraft: value => dispatch({ type: 'draft', value }),
1215
1584
  onAnswer: (runId, attentionId, answer) => dispatch({ type: 'answer', runId, attentionId, answer }),
1216
1585
  onArtifact: item => dispatch({ type: 'artifact', item }),
1217
1586
  onClosePreview: () => dispatch({ type: 'closePreview' }),
1587
+ onRetryPreview: () => dispatch({ type: 'retryPreview' }),
1218
1588
  onReveal: item => dispatch({ type: 'revealArtifact', item }),
1219
1589
  onDownload: item => dispatch({ type: 'downloadArtifact', item }),
1220
- })),
1221
- h(Rail, { model, onOpen: runId => dispatch({ type: 'openRun', runId }) })))
1590
+ }),
1591
+ })))
1222
1592
  }
1223
1593
 
1224
1594
  /** One-line status above the composer; errors stay until replaced. */
1225
- function Toast(props) {
1595
+ function Notice(props) {
1226
1596
  if (!props.toast) return null
1227
1597
  return h('div', { className: 'dsa-toast', 'data-kind': props.toast.kind }, props.toast.text)
1228
1598
  }
@@ -1236,6 +1606,20 @@ window.__ModuleLoader__.load({
1236
1606
 
1237
1607
  const patch = updater => setModel(current => updater(current))
1238
1608
 
1609
+ async function refreshWorkbench() {
1610
+ const workbench = await call('/workbench')
1611
+ patch(current => current.sessionId === workbench.sessionId ? { ...current, workbench } : current)
1612
+ }
1613
+
1614
+ const taskStates = model.runs.map(run => `${run.id}:${run.status}`).join(',')
1615
+ react.useEffect(() => {
1616
+ if (model.phase !== 'ready') return undefined
1617
+ const refresh = () => refreshWorkbench().catch(() => {})
1618
+ refresh()
1619
+ const timer = setInterval(refresh, 8000)
1620
+ return () => clearInterval(timer)
1621
+ }, [model.phase, model.sessionId, taskStates])
1622
+
1239
1623
  // Connect once per attempt: wait for the relay, then follow the feed.
1240
1624
  react.useEffect(() => {
1241
1625
  let alive = true
@@ -1254,6 +1638,7 @@ window.__ModuleLoader__.load({
1254
1638
  capabilities: data?.capabilities ?? null,
1255
1639
  approvals: Array.isArray(data?.approvals) ? data.approvals : [],
1256
1640
  runs: Array.isArray(data?.runs) ? data.runs : [],
1641
+ goals: Array.isArray(data?.goals) ? data.goals : [],
1257
1642
  }))
1258
1643
  break
1259
1644
  } catch (error) {
@@ -1291,17 +1676,73 @@ window.__ModuleLoader__.load({
1291
1676
  if (node) node.scrollTop = node.scrollHeight
1292
1677
  }, [model.messages.length, model.typing])
1293
1678
 
1294
- // A notice clears itself; errors do not stack up.
1679
+ // The host toast fades itself after hold + fade; this timer only sweeps
1680
+ // up when the toast surface is unavailable.
1295
1681
  react.useEffect(() => {
1296
1682
  if (!model.toast) return undefined
1297
- const timer = setTimeout(() => patch(current => ({ ...current, toast: null })), 6000)
1683
+ const timer = setTimeout(() => patch(current => ({ ...current, toast: null })), 8000)
1298
1684
  return () => clearTimeout(timer)
1299
1685
  }, [model.toast])
1300
1686
 
1301
1687
  const actions = {
1302
- send: async action => {
1303
- const text = String(action.text ?? '')
1688
+ reply: ({ message }) => patch(current => ({ ...current, reply: message ? { id: message.id, text: message.text.slice(0, 800) } : null })),
1689
+ nameWorkbench: async ({ name }) => {
1690
+ const workbench = await call('/workbench', { method: 'POST', body: JSON.stringify({ name }) })
1691
+ patch(current => current.sessionId === workbench.sessionId ? { ...current, workbench } : current)
1692
+ },
1693
+ selectProject: async ({ project }) => {
1694
+ const current = modelRef.current.workbench
1695
+ if ((current?.project?.cwd ?? null) === (project?.cwd ?? null)) return
1696
+ const sessionId = project ? project.sessionId : current?.globalSessionId
1697
+ if (sessionId) await actions.switchSession({ sessionId })
1698
+ else await actions.newSession({ cwd: project?.cwd })
1699
+ },
1700
+ pickProject: async () => {
1701
+ const { cwd } = await call('/projects/pick', { method: 'POST', body: '{}' })
1702
+ if (cwd) await actions.newSession({ cwd })
1703
+ },
1704
+ showOriginalRun: async ({ run }) => {
1705
+ if (run.parentSessionId && run.parentSessionId !== modelRef.current.sessionId) {
1706
+ await actions.switchSession({ sessionId: run.parentSessionId })
1707
+ }
1708
+ await actions.openRun({ runId: run.id, original: true })
1709
+ },
1710
+ openWorkbenchArtifact: async ({ run, item }) => {
1711
+ await actions.showOriginalRun({ run })
1712
+ await actions.artifact({ item })
1713
+ },
1714
+ newGoal: async action => {
1715
+ const sessionId = modelRef.current.sessionId
1716
+ patch(current => ({ ...current, goalBusy: true }))
1717
+ try {
1718
+ const data = await call('/goals', { method: 'POST', body: JSON.stringify({ sessionId, text: action.text }) })
1719
+ patch(current => !current.sessionId || current.sessionId === data.sessionId ? {
1720
+ ...current, sessionId: data.sessionId,
1721
+ goals: current.goals.some(goal => goal.id === data.goal.id) ? current.goals : [data.goal, ...current.goals],
1722
+ } : current)
1723
+ } finally {
1724
+ patch(current => ({ ...current, goalBusy: false }))
1725
+ }
1726
+ },
1727
+ goalAction: async ({ goalId, action, body }) => {
1728
+ const sessionId = modelRef.current.sessionId
1729
+ patch(current => ({ ...current, goalBusy: true }))
1730
+ try {
1731
+ await call(`/goals/${encodeURIComponent(goalId)}/${action}`, { method: 'POST', body: JSON.stringify({ ...body, sessionId }) })
1732
+ } finally {
1733
+ patch(current => ({ ...current, goalBusy: false }))
1734
+ }
1735
+ },
1736
+ instructRun: async ({ runId, text, subtaskIndex }) => {
1304
1737
  const sessionId = modelRef.current.sessionId
1738
+ await call(`/runs/${encodeURIComponent(runId)}/instruction`, {
1739
+ method: 'POST',
1740
+ body: JSON.stringify({ sessionId, text, subtaskIndex, mode: subtaskIndex === null ? 'followup' : 'inject' }),
1741
+ })
1742
+ },
1743
+ send: async action => {
1744
+ const { reply, sessionId } = modelRef.current
1745
+ const text = reply ? `${reply.text.split(/\r?\n/).map(line => `> ${line}`).join('\n')}\n\n${action.text}` : String(action.text ?? '')
1305
1746
  localSeq += 1
1306
1747
  const id = `user-local-${localSeq}`
1307
1748
  patch(current => ({
@@ -1310,7 +1751,7 @@ window.__ModuleLoader__.load({
1310
1751
  typing: true,
1311
1752
  messages: [...current.messages, { id, role: 'user', text, at: Date.now(), pending: true }],
1312
1753
  }))
1313
- const mode = modelRef.current.typing ? 'steer' : 'queue'
1754
+ const mode = reply && modelRef.current.typing ? 'steer' : 'queue'
1314
1755
  try {
1315
1756
  await call('/message', {
1316
1757
  method: 'POST',
@@ -1325,7 +1766,7 @@ window.__ModuleLoader__.load({
1325
1766
  }))
1326
1767
  throw error
1327
1768
  }
1328
- patch(current => ({ ...current, sending: false }))
1769
+ patch(current => ({ ...current, sending: false, reply: current.reply === reply ? null : current.reply }))
1329
1770
  },
1330
1771
  decide: async action => {
1331
1772
  const { id, decision } = action
@@ -1345,7 +1786,7 @@ window.__ModuleLoader__.load({
1345
1786
  },
1346
1787
  cancel: async () => {
1347
1788
  patch(current => ({ ...current, canceling: true }))
1348
- const running = (modelRef.current.runs ?? []).filter(run => run.status === 'running')
1789
+ const running = (modelRef.current.runs ?? []).filter(run => !run.goalId && ACTIVE_RUN.has(run.status))
1349
1790
  const settled = await Promise.allSettled([
1350
1791
  call('/cancel', { method: 'POST', body: JSON.stringify({ sessionId: modelRef.current.sessionId }) }),
1351
1792
  ...running.map(run => call(`/runs/${encodeURIComponent(run.id)}/cancel`, { method: 'POST' })),
@@ -1378,11 +1819,11 @@ window.__ModuleLoader__.load({
1378
1819
  throw error
1379
1820
  }
1380
1821
  },
1381
- newSession: async () => {
1822
+ newSession: async ({ cwd }) => {
1382
1823
  patch(current => ({ ...current, sessionsBusy: true }))
1383
1824
  try {
1384
- await call('/session', { method: 'POST', body: '{}' })
1385
- patch(current => ({ ...current, sessionsBusy: false, sessionsOpen: false }))
1825
+ const data = await call('/session', { method: 'POST', body: JSON.stringify({ cwd }) })
1826
+ patch(current => ({ ...applyFrame(current, { type: 'session', sessionId: data.sessionId }), sessionsBusy: false, sessionsOpen: false }))
1386
1827
  } catch (error) {
1387
1828
  patch(current => ({ ...current, sessionsBusy: false }))
1388
1829
  throw error
@@ -1391,24 +1832,35 @@ window.__ModuleLoader__.load({
1391
1832
  switchSession: async action => {
1392
1833
  patch(current => ({ ...current, sessionsBusy: true }))
1393
1834
  try {
1394
- await call('/session/switch', { method: 'POST', body: JSON.stringify({ sessionId: action.sessionId }) })
1395
- patch(current => ({ ...current, sessionsBusy: false, sessionsOpen: false }))
1835
+ const data = await call('/session/switch', { method: 'POST', body: JSON.stringify({ sessionId: action.sessionId }) })
1836
+ patch(current => ({ ...applyFrame(current, { type: 'session', sessionId: data.sessionId }), sessionsBusy: false, sessionsOpen: false }))
1396
1837
  } catch (error) {
1397
1838
  patch(current => ({ ...current, sessionsBusy: false }))
1398
1839
  throw error
1399
1840
  }
1400
1841
  },
1401
1842
  openRun: async action => {
1843
+ const listed = modelRef.current.workbench?.runs?.find(run => run.id === action.runId)
1844
+ if (!action.original && listed?.parentSessionId && listed.parentSessionId !== modelRef.current.sessionId) {
1845
+ patch(current => ({ ...current, workbenchRun: action.runId, detail: null, preview: null }))
1846
+ return
1847
+ }
1402
1848
  patch(current => ({ ...current, detailBusy: true }))
1403
1849
  try {
1404
1850
  const run = await call(`/runs/${encodeURIComponent(action.runId)}`)
1405
- patch(current => ({ ...current, detail: run, detailBusy: false, answerDraft: '' }))
1851
+ patch(current => ({ ...current, detail: run, workbenchRun: null, workerSession: null, detailBusy: false, answerDraft: '', preview: null }))
1406
1852
  } catch (error) {
1407
1853
  patch(current => ({ ...current, detailBusy: false }))
1408
1854
  throw error
1409
1855
  }
1410
1856
  },
1411
- closeRun: () => patch(current => ({ ...current, detail: null, answerDraft: '', preview: null, previewText: '', previewBusy: false })),
1857
+ openWorker: async ({ runId, childId }) => {
1858
+ const data = await call(`/runs/${encodeURIComponent(runId)}/worker/${encodeURIComponent(childId)}`)
1859
+ const transcript = applyFrame(initialModel(), { type: 'stream.snapshot', records: data.records })
1860
+ patch(current => current.detail?.id === runId ? { ...current, workerSession: { title: data.title, transcript } } : current)
1861
+ },
1862
+ closeWorker: () => patch(current => ({ ...current, workerSession: null })),
1863
+ closeRun: () => patch(current => ({ ...current, workbenchRun: null, workerSession: null, detail: null, answerDraft: '', preview: null, previewText: '', previewError: '', previewBusy: false })),
1412
1864
  cancelRun: async action => {
1413
1865
  await call(`/runs/${encodeURIComponent(action.runId)}/cancel`, { method: 'POST' })
1414
1866
  patch(current => ({
@@ -1454,6 +1906,7 @@ window.__ModuleLoader__.load({
1454
1906
  ...current,
1455
1907
  preview: { name: item.name ?? href, url, kind },
1456
1908
  previewText: '',
1909
+ previewError: '',
1457
1910
  previewBusy: kind === 'md' || kind === 'text',
1458
1911
  }))
1459
1912
  if (kind !== 'md' && kind !== 'text') return
@@ -1461,12 +1914,25 @@ window.__ModuleLoader__.load({
1461
1914
  const res = await fetch(url, { headers: { accept: 'text/plain, text/markdown, */*' } })
1462
1915
  const text = await res.text()
1463
1916
  if (!res.ok) throw new Error(text.slice(0, 200) || `HTTP ${res.status}`)
1917
+ patch(current => ({ ...current, previewBusy: false, previewText: text, previewError: '' }))
1918
+ } catch (error) {
1919
+ patch(current => ({ ...current, previewBusy: false, previewError: `这个产物读不出来:${error.message}` }))
1920
+ }
1921
+ },
1922
+ retryPreview: async () => {
1923
+ const preview = modelRef.current.preview
1924
+ if (!preview) return
1925
+ patch(current => ({ ...current, previewBusy: true, previewError: '', previewText: '' }))
1926
+ try {
1927
+ const res = await fetch(preview.url, { headers: { accept: 'text/plain, text/markdown, */*' } })
1928
+ const text = await res.text()
1929
+ if (!res.ok) throw new Error(text.slice(0, 200) || `HTTP ${res.status}`)
1464
1930
  patch(current => ({ ...current, previewBusy: false, previewText: text }))
1465
1931
  } catch (error) {
1466
- patch(current => ({ ...current, previewBusy: false, previewText: `这个产物读不出来:${error.message}` }))
1932
+ patch(current => ({ ...current, previewBusy: false, previewError: `这个产物读不出来:${error.message}` }))
1467
1933
  }
1468
1934
  },
1469
- closePreview: () => patch(current => ({ ...current, preview: null, previewText: '', previewBusy: false })),
1935
+ closePreview: () => patch(current => ({ ...current, preview: null, previewText: '', previewError: '', previewBusy: false })),
1470
1936
  revealArtifact: async action => {
1471
1937
  const item = action.item ?? {}
1472
1938
  const query = `?path=${encodeURIComponent(item.href ?? '')}&runId=${encodeURIComponent(item.runId ?? '')}`
@@ -1474,7 +1940,7 @@ window.__ModuleLoader__.load({
1474
1940
  },
1475
1941
  downloadArtifact: action => {
1476
1942
  const item = action.item ?? {}
1477
- const url = `${API}/artifact?download=1&path=${encodeURIComponent(item.href ?? '')}`
1943
+ const url = `${API}/artifact?download=1&path=${encodeURIComponent(item.href ?? '')}&runId=${encodeURIComponent(item.runId ?? '')}`
1478
1944
  + `&runId=${encodeURIComponent(item.runId ?? '')}`
1479
1945
  if (typeof window !== 'undefined' && typeof window.open === 'function') window.open(url, '_blank', 'noopener')
1480
1946
  },
@@ -1499,13 +1965,14 @@ window.__ModuleLoader__.load({
1499
1965
  setAttempt(value => value + 1)
1500
1966
  },
1501
1967
  toast: action => patch(current => ({ ...current, toast: { kind: 'err', text: String(action.text ?? '') } })),
1968
+ dismissToast: () => patch(current => ({ ...current, toast: null })),
1502
1969
  }
1503
1970
 
1504
1971
  const dispatch = action => {
1505
1972
  // The shell must survive a failed action: show it, never throw.
1506
1973
  const run = actions[action.type]
1507
1974
  if (!run) return
1508
- Promise.resolve(run(action)).catch(error => {
1975
+ return Promise.resolve().then(() => run(action)).then(() => true).catch(error => {
1509
1976
  patch(current => ({
1510
1977
  ...current,
1511
1978
  reason: error.message,
@@ -1513,6 +1980,7 @@ window.__ModuleLoader__.load({
1513
1980
  toast: { kind: 'err', text: `${error.message}${error.hint ? ` ${error.hint}` : ''}` },
1514
1981
  phase: current.phase === 'loading' ? 'error' : current.phase,
1515
1982
  }))
1983
+ return false
1516
1984
  })
1517
1985
  }
1518
1986
 
@@ -1527,7 +1995,7 @@ window.__ModuleLoader__.load({
1527
1995
  function EntryIcon(props) {
1528
1996
  const size = typeof props?.size === 'number' ? props.size : 16
1529
1997
  const host = ICONS.spark
1530
- if (typeof host === 'function') return h(host, { size })
1998
+ if (isComponent(host)) return h(host, { size })
1531
1999
  return h('svg', {
1532
2000
  viewBox: '0 0 16 16',
1533
2001
  width: size,