@xiangyixie/dsh-superagent 0.16.10 → 0.17.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/CHANGELOG.md CHANGED
@@ -8,6 +8,26 @@ along with the next code release. A doc-only version leaves `lib/` and `bin/`
8
8
  byte-identical to the version before it, and the pinned install line in the
9
9
  README is updated to the version being released.
10
10
 
11
+ ## 0.17.0 — 2026-11-17
12
+
13
+ ### 新增
14
+
15
+ - **面板终于能进控制台的能力了。** 标题栏新增「会话」:当前对话、最近 12 条
16
+ 历史、「新对话」都在一步之内;点击历史直接切换,不再需要另开控制台页面。
17
+ - **任务线可点开。** 右侧「调度的会话」每一行不再是死的状态条,点开后能看到
18
+ 这条 run 的状态、正在等你回答的问题、报告里引用的产物和执行报告;可以单独
19
+ 停止这一条 run。
20
+ - **回答待决策。** 详情里直接显示 `attention` 问题,输入答案即调
21
+ `POST /answer`,不需要回到控制台页。
22
+ - **上传与产物预览。** 输入卡左侧「+」把文件收进当前对话工作区,成功后路径
23
+ 自动落进输入框;产物点开走同源中继的 `/artifact`,不再需要手拼 token。
24
+
25
+ ### 说明
26
+
27
+ - 入口复用已有的 `/superagent/api` 同源中继,没有引入 iframe,也没有把 token
28
+ 带到浏览器;`/superagent/console-address` 仍保留给需要独立页的场景。
29
+ - 缺口清单与后续阶段见 `docs/GAPS-TRAEB.md`。
30
+
11
31
  ## 0.16.10 — 2026-11-17
12
32
 
13
33
  ### 修复
package/README.en.md CHANGED
@@ -36,12 +36,12 @@ Three steps. The desktop app and the CLI install the same plugin; each step says
36
36
 
37
37
  ### 1. Install
38
38
 
39
- Desktop: **Plugins** → **Add plugin** → enter `@xiangyixie/dsh-superagent@0.16.10` → install.
39
+ Desktop: **Plugins** → **Add plugin** → enter `@xiangyixie/dsh-superagent@0.17.0` → install.
40
40
 
41
41
  CLI:
42
42
 
43
43
  ```bash
44
- dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.10
44
+ dsh plugin --profile web add @xiangyixie/dsh-superagent@0.17.0
45
45
  ```
46
46
 
47
47
  **Restart DSH** afterwards — plugins are loaded once at host startup. You can also add the [plugin index](https://raw.githubusercontent.com/LittleChenLiya/dsh-superagent/main/plugin-index.json) on the **Discover** page for one-click installs; upgrades are always remove-then-add.
@@ -1666,7 +1666,7 @@ appears to "hang" until the ignored-abort child returns.
1666
1666
 
1667
1667
  | What you see | What it means | What to do |
1668
1668
  | --- | --- | --- |
1669
- | `superagent_*` tools do not exist | The bundle row is not mounted, or the host refused to load the plugin. | Run `--dump-config` and check for the `@xiangyixie/dsh-superagent` block; reinstall with `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.16.10` and read the host log for `[dsh-superagent]` lines. |
1669
+ | `superagent_*` tools do not exist | The bundle row is not mounted, or the host refused to load the plugin. | Run `--dump-config` and check for the `@xiangyixie/dsh-superagent` block; reinstall with `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.17.0` and read the host log for `[dsh-superagent]` lines. |
1670
1670
  | `Cannot find module .../lib/control.js` (or `watch.js` / `report.js` / `wizard.js`), or `[dsh-superagent] dsh-superagent failed to load because a file it imports is missing: ...` in the host log | The copy in that profile is incomplete — an `add` that was interrupted leaves a partial extraction. From 0.14.3 the entry point names the missing file itself. The published package is not the cause: every version ships all thirty-four `lib/` files. | Delete the plugin's directory under the profile's `node_modules` (scoped `@xiangyixie/dsh-superagent`, or unscoped `dsh-superagent` from an older tarball install) and run the same `add` command again, with the version number. Do not copy files in by hand. |
1671
1671
  | `[error] the model provider rejected the API key` | The key env var is missing in the process that started the host. | Export `DEEPSEEK_API_KEY` (the default route) or the variable your route names, then restart `dsh`. |
1672
1672
  | `MISSING_CREDENTIAL ... no API key for provider route "..."` | The profile's route has no credential in the environment. | Set the env var named for that route and restart. The error line names the route, so use that, not this page. |
package/README.md CHANGED
@@ -36,12 +36,12 @@ dsh-superagent 把这件事接过去:你说一句目标,它负责拆、负
36
36
 
37
37
  ### 1. 装
38
38
 
39
- 桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.16.10` → 安装。
39
+ 桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.17.0` → 安装。
40
40
 
41
41
  命令行:
42
42
 
43
43
  ```bash
44
- dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.10
44
+ dsh plugin --profile web add @xiangyixie/dsh-superagent@0.17.0
45
45
  ```
46
46
 
47
47
  装完**重启 DSH**(插件只在宿主启动时加载一次)。也可以从「发现」页添加[插件索引](https://raw.githubusercontent.com/LittleChenLiya/dsh-superagent/main/plugin-index.json)一键安装;升级一律先 `remove` 再 `add`。
@@ -1090,7 +1090,7 @@ SHA-256)。`--format html` 把同样的内容写成一个自包含
1090
1090
 
1091
1091
  | 你看到的 | 含义 | 怎么办 |
1092
1092
  | --- | --- | --- |
1093
- | `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.16.10` 重装,并在宿主日志里找 `[dsh-superagent]` 行。 |
1093
+ | `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.17.0` 重装,并在宿主日志里找 `[dsh-superagent]` 行。 |
1094
1094
  | `Cannot find module .../lib/control.js`(或 `watch.js` / `report.js` / `wizard.js`),或宿主日志里的 `[dsh-superagent] dsh-superagent failed to load because a file it imports is missing: ...` | 那个 profile 里的副本不完整——被中断的 `add` 会留下残缺的解包结果。0.14.3 起的入口会直接点名缺哪个文件。已发布的包不是原因:每个版本都带全部三十四个 `lib/` 文件。 | 删掉 profile 的 `node_modules` 下该插件的目录(带 scope 的 `@xiangyixie/dsh-superagent`,或旧 tarball 安装留下的无 scope 的 `dsh-superagent`),再用同一条 `add` 命令重装,并带上版本号。不要手工拷贝文件进去。 |
1095
1095
  | `[error] the model provider rejected the API key` | 启动宿主的那个进程里缺 key 环境变量。 | 导出 `DEEPSEEK_API_KEY`(默认路由)或你那条路由声明的变量,然后重启 `dsh`。 |
1096
1096
  | `MISSING_CREDENTIAL ... no API key for provider route "..."` | profile 的路由在环境里没有凭据。 | 设置该路由对应的环境变量并重启。错误行里写了路由名,以它为准,不要照本文。 |
package/README.zh.md CHANGED
@@ -36,12 +36,12 @@ dsh-superagent 把这件事接过去:你说一句目标,它负责拆、负
36
36
 
37
37
  ### 1. 装
38
38
 
39
- 桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.16.10` → 安装。
39
+ 桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.17.0` → 安装。
40
40
 
41
41
  命令行:
42
42
 
43
43
  ```bash
44
- dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.10
44
+ dsh plugin --profile web add @xiangyixie/dsh-superagent@0.17.0
45
45
  ```
46
46
 
47
47
  装完**重启 DSH**(插件只在宿主启动时加载一次)。也可以从「发现」页添加[插件索引](https://raw.githubusercontent.com/LittleChenLiya/dsh-superagent/main/plugin-index.json)一键安装;升级一律先 `remove` 再 `add`。
@@ -1090,7 +1090,7 @@ SHA-256)。`--format html` 把同样的内容写成一个自包含
1090
1090
 
1091
1091
  | 你看到的 | 含义 | 怎么办 |
1092
1092
  | --- | --- | --- |
1093
- | `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.16.10` 重装,并在宿主日志里找 `[dsh-superagent]` 行。 |
1093
+ | `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.17.0` 重装,并在宿主日志里找 `[dsh-superagent]` 行。 |
1094
1094
  | `Cannot find module .../lib/control.js`(或 `watch.js` / `report.js` / `wizard.js`),或宿主日志里的 `[dsh-superagent] dsh-superagent failed to load because a file it imports is missing: ...` | 那个 profile 里的副本不完整——被中断的 `add` 会留下残缺的解包结果。0.14.3 起的入口会直接点名缺哪个文件。已发布的包不是原因:每个版本都带全部三十四个 `lib/` 文件。 | 删掉 profile 的 `node_modules` 下该插件的目录(带 scope 的 `@xiangyixie/dsh-superagent`,或旧 tarball 安装留下的无 scope 的 `dsh-superagent`),再用同一条 `add` 命令重装,并带上版本号。不要手工拷贝文件进去。 |
1095
1095
  | `[error] the model provider rejected the API key` | 启动宿主的那个进程里缺 key 环境变量。 | 导出 `DEEPSEEK_API_KEY`(默认路由)或你那条路由声明的变量,然后重启 `dsh`。 |
1096
1096
  | `MISSING_CREDENTIAL ... no API key for provider route "..."` | profile 的路由在环境里没有凭据。 | 设置该路由对应的环境变量并重启。错误行里写了路由名,以它为准,不要照本文。 |
package/lib/client.js CHANGED
@@ -244,6 +244,28 @@ window.__ModuleLoader__.load({
244
244
  .dsa-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-caption,rgb(129,133,140))}
245
245
  .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}
246
246
  .dsa-toast[data-kind=err]{color:var(--dsw-alias-state-error-primary,#f25a5a)}
247
+ .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))}
248
+ .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))}
249
+ .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)}
250
+ .dsa-sessions-new:hover,.dsa-linkbtn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}
251
+ .dsa-sessions-list{display:flex;flex-direction:column;gap:2px;min-height:0;overflow-y:auto}
252
+ .dsa-session-row{height:40px;gap:8px;cursor:pointer}
253
+ .dsa-session-row[data-current=true]{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}
254
+ .dsa-session-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px}
255
+ .dsa-session-meta{flex:none;font-size:10px;line-height:16px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
256
+ .dsa-sessions-foot{display:flex;justify-content:flex-end;padding-top:6px}
257
+ .dsa-detail{position:absolute;inset:0;z-index:20;display:flex;flex-direction:column;background:var(--dsw-alias-bg-base,rgb(21,21,23))}
258
+ .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))}
259
+ .dsa-detail-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;font-weight:500}
260
+ .dsa-detail-body{flex:1;min-height:0;overflow-y:auto;padding:12px 16px;display:flex;flex-direction:column;gap:12px}
261
+ .dsa-detail-sec{display:flex;flex-direction:column;gap:6px}
262
+ .dsa-detail-label{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
263
+ .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))}
264
+ .dsa-detail-q{font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary,#f9fafb);white-space:pre-wrap}
265
+ .dsa-answer-row{display:flex;gap:6px}
266
+ .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}
267
+ .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}
268
+ .dsa-artifact-link:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}
247
269
  `
248
270
 
249
271
  /** Inject the sheet once; the panel is mounted once per window. */
@@ -319,6 +341,14 @@ window.__ModuleLoader__.load({
319
341
  typing: false,
320
342
  sending: false,
321
343
  currentId: null,
344
+ sessions: [],
345
+ sessionsOpen: false,
346
+ sessionsBusy: false,
347
+ detail: null,
348
+ detailBusy: false,
349
+ answerDraft: '',
350
+ uploadInsert: '',
351
+ uploading: false,
322
352
  }
323
353
  }
324
354
 
@@ -495,7 +525,19 @@ window.__ModuleLoader__.load({
495
525
  return { ...model, sessionId: frame.sessionId ?? model.sessionId, capabilities: frame.capabilities ?? model.capabilities }
496
526
  case 'session':
497
527
  if (!frame.sessionId || frame.sessionId === model.sessionId) return model
498
- return { ...model, sessionId: frame.sessionId, messages: [], approvals: [], approvalBusy: {}, currentId: null, typing: false, canceling: false }
528
+ return {
529
+ ...model,
530
+ sessionId: frame.sessionId,
531
+ messages: [],
532
+ approvals: [],
533
+ approvalBusy: {},
534
+ currentId: null,
535
+ typing: false,
536
+ canceling: false,
537
+ sessionsOpen: false,
538
+ detail: null,
539
+ answerDraft: '',
540
+ }
499
541
  case 'stream.snapshot': {
500
542
  let next = { ...model, messages: [], currentId: null }
501
543
  if (frame.header?.id) next.sessionId = frame.header.id
@@ -527,8 +569,11 @@ window.__ModuleLoader__.load({
527
569
  }
528
570
  return model
529
571
  }
530
- case 'runs':
531
- return { ...model, runs: Array.isArray(frame.runs) ? frame.runs : [] }
572
+ case 'runs': {
573
+ const runs = Array.isArray(frame.runs) ? frame.runs : []
574
+ const detail = model.detail ? runs.find(run => run.id === model.detail.id) ?? model.detail : null
575
+ return { ...model, runs, detail }
576
+ }
532
577
  case 'canceling':
533
578
  return { ...model, canceling: true }
534
579
  default:
@@ -537,12 +582,19 @@ window.__ModuleLoader__.load({
537
582
  }
538
583
 
539
584
  function Header(props) {
540
- const { railOpen, runningCount, onToggleRail } = props
585
+ const { railOpen, runningCount, onToggleRail, onToggleSessions, sessionsOpen } = props
541
586
  const toggleLabel = railOpen ? '收起任务栏(Ctrl+Shift+B)' : '展开任务栏(Ctrl+Shift+B)'
542
587
  return h('header', { className: 'dsa-header' },
543
588
  h('div', { className: 'dsa-crumbs' },
544
589
  h('span', { className: 'dsa-crumb dsa-crumb-current' }, PANEL_LABEL)),
545
590
  h('div', { className: 'dsa-head-actions' },
591
+ tipped('会话', h('button', {
592
+ type: 'button',
593
+ className: 'dsa-iconbtn',
594
+ 'aria-label': '会话',
595
+ 'aria-expanded': sessionsOpen ? 'true' : 'false',
596
+ onClick: onToggleSessions,
597
+ }, h(Icon, { of: 'clock' })), 'bottom'),
546
598
  tipped(toggleLabel, h('button', {
547
599
  type: 'button',
548
600
  className: 'dsa-iconbtn dsa-railtoggle',
@@ -662,6 +714,32 @@ window.__ModuleLoader__.load({
662
714
  const { hero, disabled, onSend } = props
663
715
  const [text, setText] = react.useState('')
664
716
  const areaRef = react.useRef(null)
717
+ const fileRef = react.useRef(null)
718
+
719
+ // An uploaded file lands as a path the user can see and edit before sending.
720
+ react.useEffect(() => {
721
+ if (!props.insert) return
722
+ setText(current => (current ? `${current}\n${props.insert}` : props.insert))
723
+ props.onInserted?.()
724
+ }, [props.insert])
725
+
726
+ const pickFile = () => {
727
+ const input = fileRef.current
728
+ if (!input) return
729
+ input.value = ''
730
+ input.click()
731
+ }
732
+
733
+ const uploadFile = file => {
734
+ if (!file || !props.onUpload) return
735
+ const reader = new FileReader()
736
+ reader.onload = () => {
737
+ const data = String(reader.result ?? '').replace(/^data:[^,]*,/, '')
738
+ props.onUpload({ name: file.name, data })
739
+ }
740
+ reader.onerror = () => props.onUpload({ name: file.name, data: '', error: '文件读不出来' })
741
+ reader.readAsDataURL(file)
742
+ }
665
743
 
666
744
  const grow = () => {
667
745
  const area = areaRef.current
@@ -699,6 +777,19 @@ window.__ModuleLoader__.load({
699
777
  },
700
778
  }),
701
779
  h('div', { className: 'dsa-row' },
780
+ h('input', {
781
+ ref: fileRef,
782
+ type: 'file',
783
+ style: { display: 'none' },
784
+ onChange: event => uploadFile(event.target.files?.[0]),
785
+ }),
786
+ tipped('添加文件到工作区', h('button', {
787
+ type: 'button',
788
+ className: 'dsa-add',
789
+ 'aria-label': '添加文件',
790
+ disabled: disabled || props.uploading === true,
791
+ onClick: pickFile,
792
+ }, props.uploading === true ? h('span', { className: 'dsa-spin' }) : '+'), 'top'),
702
793
  h('div', { className: 'dsa-trailing' },
703
794
  props.running
704
795
  ? tipped('停止本轮', h('button', {
@@ -736,15 +827,132 @@ window.__ModuleLoader__.load({
736
827
  h('div', { className: 'dsa-rail-list' },
737
828
  runs.length === 0
738
829
  ? h('div', { className: 'dsa-hint', style: { padding: '8px' } }, '超级智能体还没有调度新的会话')
739
- : runs.map(run => tipped(run.goal ?? '', h('div', {
830
+ : runs.map(run => tipped(run.goal ?? '', h('button', {
740
831
  key: run.id,
832
+ type: 'button',
741
833
  className: 'dsa-rowitem',
834
+ title: '查看任务详情',
835
+ onClick: () => props.onOpen?.(run.id),
742
836
  },
743
837
  h('span', { className: 'dsa-rowdot', 'data-status': run.status }),
744
838
  h('span', { className: 'dsa-rowtitle' }, run.goal ?? '调度中的会话'),
745
839
  h('span', { className: 'dsa-rowtime' }, run.status === 'running' ? '运行中' : run.status === 'completed' ? '完成' : '已停')), 'left', run.id))))
746
840
  }
747
841
 
842
+ /** Artifacts are whatever the run report links to, same rule as the console page. */
843
+ function artifactsOf(run) {
844
+ const report = typeof run?.report === 'string' ? run.report : ''
845
+ const found = []
846
+ const pattern = /\[([^\]\n]{1,80})\]\(<?([^)>\n]+)>?\)/g
847
+ let match = pattern.exec(report)
848
+ while (match) {
849
+ const href = match[2].trim()
850
+ if (href && !/^[a-z][a-z0-9+.-]*:\/\//i.test(href) && !href.startsWith('#')) {
851
+ if (!found.some(item => item.href === href)) found.push({ name: match[1].trim(), href, runId: run.id })
852
+ }
853
+ if (found.length >= 20) break
854
+ match = pattern.exec(report)
855
+ }
856
+ return found
857
+ }
858
+
859
+ /** History and the "new conversation" entry, opened from the title bar. */
860
+ function SessionsPanel(props) {
861
+ const { model } = props
862
+ if (!model.sessionsOpen) return null
863
+ const sessions = Array.isArray(model.sessions) ? model.sessions : []
864
+ const busy = model.sessionsBusy === true
865
+ return h('div', { className: 'dsa-sessions', role: 'dialog', 'aria-label': '会话' },
866
+ h('div', { className: 'dsa-sessions-head' },
867
+ h('span', null, '会话'),
868
+ h('button', {
869
+ type: 'button',
870
+ className: 'dsa-sessions-new',
871
+ disabled: busy,
872
+ onClick: () => props.onNew?.(),
873
+ }, '新对话')),
874
+ h('div', { className: 'dsa-sessions-list' },
875
+ sessions.length === 0
876
+ ? h('div', { className: 'dsa-hint', style: { padding: '8px' } }, '还没有历史会话')
877
+ : sessions.map(item => h('button', {
878
+ key: item.sessionId,
879
+ type: 'button',
880
+ className: 'dsa-rowitem dsa-session-row',
881
+ 'data-current': item.sessionId === model.sessionId ? 'true' : 'false',
882
+ disabled: busy,
883
+ onClick: () => props.onSwitch?.(item.sessionId),
884
+ },
885
+ h('span', { className: 'dsa-session-title' }, item.title || item.first || item.sessionId.slice(0, 12)),
886
+ h('span', { className: 'dsa-session-meta' }, `${item.runs ?? 0} 轮`)))),
887
+ h('div', { className: 'dsa-sessions-foot' },
888
+ h('button', { type: 'button', className: 'dsa-linkbtn', onClick: () => props.onClose?.() }, '关闭')))
889
+ }
890
+
891
+ /** One delegated run: status, questions waiting for the user, artifacts. */
892
+ function RunDetail(props) {
893
+ const { model } = props
894
+ const run = model.detail
895
+ if (!run) return null
896
+ const attention = Array.isArray(run.attention) ? run.attention : []
897
+ const artifacts = artifactsOf(run)
898
+ const busy = model.detailBusy === true
899
+ return h('div', { className: 'dsa-detail', role: 'dialog', 'aria-label': '任务详情' },
900
+ h('div', { className: 'dsa-detail-head' },
901
+ h('span', { className: 'dsa-detail-title' }, run.goal ?? '任务详情'),
902
+ h('button', {
903
+ type: 'button',
904
+ className: 'dsa-linkbtn',
905
+ onClick: () => props.onCancelRun?.(run.id),
906
+ }, run.status === 'running' ? '停止' : '已停'),
907
+ h('button', { type: 'button', className: 'dsa-linkbtn', onClick: () => props.onClose?.() }, '关闭')),
908
+ h('div', { className: 'dsa-detail-body' },
909
+ h('div', { className: 'dsa-detail-sec' },
910
+ h('div', { className: 'dsa-detail-label' }, '状态'),
911
+ h('div', { className: 'dsa-detail-q' }, `${run.status ?? '未知'}${run.startedAt ? ` · ${run.startedAt}` : ''}`)),
912
+ attention.length > 0
913
+ ? h('div', { className: 'dsa-detail-sec' },
914
+ h('div', { className: 'dsa-detail-label' }, '等你决定'),
915
+ attention.map(item => h('div', { key: item.id, className: 'dsa-detail-item' },
916
+ h('div', { className: 'dsa-detail-q' }, item.question ?? '有一个问题需要你回答'),
917
+ h('div', { className: 'dsa-answer-row' },
918
+ h('input', {
919
+ className: 'dsa-answer-input',
920
+ value: model.answerDraft,
921
+ placeholder: '写下你的回答',
922
+ onInput: event => props.onDraft?.(event.target.value),
923
+ onKeyDown: event => {
924
+ if (event.key === 'Enter' && !event.nativeEvent?.isComposing) {
925
+ event.preventDefault()
926
+ props.onAnswer?.(run.id, item.id, model.answerDraft)
927
+ }
928
+ },
929
+ }),
930
+ h(Button ?? 'button', {
931
+ variant: Button ? 'primary' : undefined,
932
+ type: Button ? undefined : 'button',
933
+ disabled: busy || !String(model.answerDraft ?? '').trim(),
934
+ onClick: () => props.onAnswer?.(run.id, item.id, model.answerDraft),
935
+ }, '回答')))))
936
+ : null,
937
+ artifacts.length > 0
938
+ ? h('div', { className: 'dsa-detail-sec' },
939
+ h('div', { className: 'dsa-detail-label' }, '产物'),
940
+ artifacts.map(item => h('button', {
941
+ key: item.href,
942
+ type: 'button',
943
+ className: 'dsa-artifact-link',
944
+ onClick: () => props.onArtifact?.(item),
945
+ }, item.name)))
946
+ : h('div', { className: 'dsa-detail-sec' },
947
+ h('div', { className: 'dsa-detail-label' }, '产物'),
948
+ h('div', { className: 'dsa-hint' }, '这条任务还没有报告产物')),
949
+ run.report
950
+ ? h('div', { className: 'dsa-detail-sec' },
951
+ h('div', { className: 'dsa-detail-label' }, '报告'),
952
+ h('div', { className: 'dsa-md-plain' }, run.report))
953
+ : null))
954
+ }
955
+
748
956
  function Hero(props) {
749
957
  const ready = props.model.capabilities?.chat !== false
750
958
  return h('div', { className: 'dsa-hero' },
@@ -813,7 +1021,15 @@ window.__ModuleLoader__.load({
813
1021
  h(Header, {
814
1022
  railOpen,
815
1023
  runningCount,
1024
+ sessionsOpen: model.sessionsOpen === true,
816
1025
  onToggleRail: toggleRail,
1026
+ onToggleSessions: () => dispatch({ type: 'sessions' }),
1027
+ }),
1028
+ h(SessionsPanel, {
1029
+ model,
1030
+ onNew: () => dispatch({ type: 'newSession' }),
1031
+ onSwitch: sessionId => dispatch({ type: 'switchSession', sessionId }),
1032
+ onClose: () => dispatch({ type: 'sessions', open: false }),
817
1033
  }),
818
1034
  h(Toast, { toast: model.toast }),
819
1035
  h('div', { className: 'dsa-body', 'data-rail': railOpen ? 'open' : 'closed' },
@@ -824,6 +1040,10 @@ window.__ModuleLoader__.load({
824
1040
  disabled: model.sending,
825
1041
  running: model.typing,
826
1042
  canceling: model.canceling,
1043
+ insert: model.uploadInsert,
1044
+ uploading: model.uploading === true,
1045
+ onInserted: () => dispatch({ type: 'inserted' }),
1046
+ onUpload: file => dispatch({ type: 'upload', file }),
827
1047
  onStop: () => dispatch({ type: 'cancel' }),
828
1048
  onSend: text => dispatch({ type: 'send', text }),
829
1049
  })
@@ -838,10 +1058,22 @@ window.__ModuleLoader__.load({
838
1058
  disabled: model.sending || model.capabilities?.chat === false,
839
1059
  running: model.typing,
840
1060
  canceling: model.canceling,
1061
+ insert: model.uploadInsert,
1062
+ uploading: model.uploading === true,
1063
+ onInserted: () => dispatch({ type: 'inserted' }),
1064
+ onUpload: file => dispatch({ type: 'upload', file }),
841
1065
  onStop: () => dispatch({ type: 'cancel' }),
842
1066
  onSend: text => dispatch({ type: 'send', text }),
1067
+ }),
1068
+ h(RunDetail, {
1069
+ model,
1070
+ onClose: () => dispatch({ type: 'closeRun' }),
1071
+ onCancelRun: runId => dispatch({ type: 'cancelRun', runId }),
1072
+ onDraft: value => dispatch({ type: 'draft', value }),
1073
+ onAnswer: (runId, attentionId, answer) => dispatch({ type: 'answer', runId, attentionId, answer }),
1074
+ onArtifact: item => dispatch({ type: 'artifact', item }),
843
1075
  })),
844
- h(Rail, { model })))
1076
+ h(Rail, { model, onOpen: runId => dispatch({ type: 'openRun', runId }) })))
845
1077
  }
846
1078
 
847
1079
  /** One-line status above the composer; errors stay until replaced. */
@@ -975,6 +1207,105 @@ window.__ModuleLoader__.load({
975
1207
  throw error
976
1208
  }
977
1209
  },
1210
+ sessions: async action => {
1211
+ const open = typeof action.open === 'boolean' ? action.open : modelRef.current.sessionsOpen !== true
1212
+ if (!open) {
1213
+ patch(current => ({ ...current, sessionsOpen: false }))
1214
+ return
1215
+ }
1216
+ patch(current => ({ ...current, sessionsOpen: true, sessionsBusy: true }))
1217
+ try {
1218
+ const data = await call('/sessions')
1219
+ patch(current => ({
1220
+ ...current,
1221
+ sessionsBusy: false,
1222
+ sessions: Array.isArray(data?.sessions) ? data.sessions : [],
1223
+ }))
1224
+ } catch (error) {
1225
+ patch(current => ({ ...current, sessionsBusy: false }))
1226
+ throw error
1227
+ }
1228
+ },
1229
+ newSession: async () => {
1230
+ patch(current => ({ ...current, sessionsBusy: true }))
1231
+ try {
1232
+ await call('/session', { method: 'POST', body: '{}' })
1233
+ patch(current => ({ ...current, sessionsBusy: false, sessionsOpen: false }))
1234
+ } catch (error) {
1235
+ patch(current => ({ ...current, sessionsBusy: false }))
1236
+ throw error
1237
+ }
1238
+ },
1239
+ switchSession: async action => {
1240
+ patch(current => ({ ...current, sessionsBusy: true }))
1241
+ try {
1242
+ await call('/session/switch', { method: 'POST', body: JSON.stringify({ sessionId: action.sessionId }) })
1243
+ patch(current => ({ ...current, sessionsBusy: false, sessionsOpen: false }))
1244
+ } catch (error) {
1245
+ patch(current => ({ ...current, sessionsBusy: false }))
1246
+ throw error
1247
+ }
1248
+ },
1249
+ openRun: async action => {
1250
+ patch(current => ({ ...current, detailBusy: true }))
1251
+ try {
1252
+ const run = await call(`/runs/${encodeURIComponent(action.runId)}`)
1253
+ patch(current => ({ ...current, detail: run, detailBusy: false, answerDraft: '' }))
1254
+ } catch (error) {
1255
+ patch(current => ({ ...current, detailBusy: false }))
1256
+ throw error
1257
+ }
1258
+ },
1259
+ closeRun: () => patch(current => ({ ...current, detail: null, answerDraft: '' })),
1260
+ cancelRun: async action => {
1261
+ await call(`/runs/${encodeURIComponent(action.runId)}/cancel`, { method: 'POST' })
1262
+ patch(current => ({
1263
+ ...current,
1264
+ detail: current.detail && current.detail.id === action.runId
1265
+ ? { ...current.detail, status: 'cancelling' }
1266
+ : current.detail,
1267
+ }))
1268
+ },
1269
+ draft: action => patch(current => ({ ...current, answerDraft: String(action.value ?? '') })),
1270
+ answer: async action => {
1271
+ const answer = String(action.answer ?? '').trim()
1272
+ if (!answer) return
1273
+ await call('/answer', {
1274
+ method: 'POST',
1275
+ body: JSON.stringify({ runId: action.runId, attentionId: action.attentionId, answer }),
1276
+ })
1277
+ patch(current => ({
1278
+ ...current,
1279
+ answerDraft: '',
1280
+ detail: current.detail && current.detail.id === action.runId
1281
+ ? {
1282
+ ...current.detail,
1283
+ attention: (current.detail.attention ?? []).filter(item => item.id !== action.attentionId),
1284
+ }
1285
+ : current.detail,
1286
+ }))
1287
+ },
1288
+ artifact: action => {
1289
+ const item = action.item ?? {}
1290
+ const url = `${API}/artifact?path=${encodeURIComponent(item.href ?? '')}&runId=${encodeURIComponent(item.runId ?? '')}`
1291
+ if (typeof window !== 'undefined' && typeof window.open === 'function') window.open(url, '_blank', 'noopener')
1292
+ },
1293
+ upload: async action => {
1294
+ const file = action.file ?? {}
1295
+ if (file.error) throw new Error(file.error)
1296
+ patch(current => ({ ...current, uploading: true }))
1297
+ try {
1298
+ const data = await call('/upload', {
1299
+ method: 'POST',
1300
+ body: JSON.stringify({ name: file.name, data: file.data, sessionId: modelRef.current.sessionId }),
1301
+ })
1302
+ patch(current => ({ ...current, uploading: false, uploadInsert: data?.path ?? '' }))
1303
+ } catch (error) {
1304
+ patch(current => ({ ...current, uploading: false }))
1305
+ throw error
1306
+ }
1307
+ },
1308
+ inserted: () => patch(current => ({ ...current, uploadInsert: '' })),
978
1309
  retry: () => {
979
1310
  patch(current => ({ ...current, phase: 'loading', reason: '' }))
980
1311
  setAttempt(value => value + 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiangyixie/dsh-superagent",
3
- "version": "0.16.10",
3
+ "version": "0.17.0",
4
4
  "description": "长周期自主执行插件:一个目标拆成可并行的子任务,交付一份合并报告,重启后仍可继续。",
5
5
  "author": "Admire (LittleChenLiya)",
6
6
  "type": "module",
@@ -99,7 +99,7 @@
99
99
  "dsh": ">=0.2.2-rc.1 <0.3.0-0"
100
100
  },
101
101
  "scripts": {
102
- "test": "node --test test/orchestrator.test.mjs test/direct-and-queue.test.mjs test/dialog.test.mjs test/workspace.test.mjs test/store.test.mjs test/errors.test.mjs test/plugin.test.mjs test/overhead.test.mjs test/guard.test.mjs test/goal.test.mjs test/cron.test.mjs test/schedule.test.mjs test/audit.test.mjs test/inject.test.mjs test/sync.test.mjs test/workbench.test.mjs test/usage.test.mjs test/cost.test.mjs test/ledger.test.mjs test/control.test.mjs test/watch.test.mjs test/report.test.mjs test/memory.test.mjs test/user-memory.test.mjs test/notify.test.mjs test/templates.test.mjs test/archive.test.mjs test/doctor.test.mjs test/pack.test.mjs test/runtime-control.test.mjs test/console.test.mjs test/client-bundle.test.mjs test/wizard.test.mjs test/board.test.mjs test/long-goal.test.mjs",
102
+ "test": "node --test test/orchestrator.test.mjs test/direct-and-queue.test.mjs test/dialog.test.mjs test/workspace.test.mjs test/store.test.mjs test/errors.test.mjs test/plugin.test.mjs test/overhead.test.mjs test/guard.test.mjs test/goal.test.mjs test/cron.test.mjs test/schedule.test.mjs test/audit.test.mjs test/inject.test.mjs test/sync.test.mjs test/workbench.test.mjs test/usage.test.mjs test/cost.test.mjs test/ledger.test.mjs test/control.test.mjs test/watch.test.mjs test/report.test.mjs test/memory.test.mjs test/user-memory.test.mjs test/notify.test.mjs test/templates.test.mjs test/archive.test.mjs test/doctor.test.mjs test/pack.test.mjs test/runtime-control.test.mjs test/console.test.mjs test/client-bundle.test.mjs test/client-entries.test.mjs test/wizard.test.mjs test/board.test.mjs test/long-goal.test.mjs",
103
103
  "check-pack": "node scripts/check-pack.mjs"
104
104
  },
105
105
  "keywords": [