@suifei/dsh-ai-team 0.4.93 → 0.4.95

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
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.95 - 2026-11-15
4
+
5
+ **一个成员一个会话:插件不再自动新建子智能体**
6
+
7
+ 官方契约(`reference/subsystems/subagent`):可续接子智能体只在首次 `startActivation` 时创建,之后一律
8
+ `subagents.sendMessage`——运行中则插话,离线由宿主冷恢复,生命周期归 SubagentManager。插件此前在唤醒失败
9
+ (`NOT_RESUMABLE`)时「自愈」重建会话:il2c 在 11-12/13 两天重建 322 次,PMO 的子智能体列表涨到 330 个。
10
+ 现在规矩前置:会话只在成员还没有会话时创建;续接永远复用;新建只来自 Human(手动重建、改 provider/model)。
11
+
12
+ - 唤醒时原会话无法续接:不再新建子智能体;成员记为 failed(waker 不再唤醒,不会循环),并给 Human 一条
13
+ `member_failure` 决策项(新失败类别 `session`),由 Human 手动重建或复用同一会话(`member.bind`)。
14
+ 会话被占用(write handle busy)是瞬时状态,不算失败。诊断 `member.session.unresumable.fail`;
15
+ - 运行时不可用恢复后(boot 对账):已有会话的成员重新绑定**同一会话**(`member.session.reused`),不再 force 重建;
16
+ - 技能优化评审前不再强制重建评审官会话(旧逻辑每调用一次就多一个子智能体);
17
+ - 移除配置 `autoReseatLimitPer30Min`(自动重建已不存在);
18
+ - 测试:`node --test` **333 通过 / 1 跳过**;`host.test` 新增「`NOT_RESUMABLE` 不新建子智能体、成员 failed、
19
+ 复用同一会话恢复」(旧代码即失败),新增 `member-one-session.test`;
20
+ - E2E(隔离 DSH_HOME):rc.1 / rc.3 上移走成员会话后派卡——会话目录数不增、成员 failed、Human 决策项 1 条;
21
+ rc.1 完整排序任务一轮:PMO + 3 成员共 4 个会话,6 次唤醒全部投递原会话,每成员只绑定过 1 个会话。
22
+
23
+ ## 0.4.94 - 2026-11-15
24
+
25
+ **成员会话重建后,旧会话从工作区摘下**
26
+
27
+ 成员会话不可恢复(`NOT_RESUMABLE` 等)时插件会自愈重建一个新会话,但被替换的旧会话仍挂在项目工作区下。
28
+ 宿主没有删除会话的 API,于是每次重建都在工作区列表里多留一个永不再用的会话——实机 il2c 在 11-12/13 两天
29
+ 自愈重建 322 次,il2c 工作区下累积 323 个死成员会话(`workspace.json` 里 354 个会话只有 25 个在用或属于 Human)。
30
+
31
+ - `index.js` `activateMember`:force 重建成功、新会话挂上工作区后,对旧会话调用工作区的 `detachSession`;
32
+ 诊断行 `workspace.detach`(`errors` 级可见)/ `workspace.detach.fail`;
33
+ - `member.autoreseat` 诊断行补记触发的 `failureCode` 与唤醒 `reason`,之后能区分重建成因;
34
+ - 测试:`node --test` **332 通过 / 1 跳过**;`host.test` 新增「旧会话摘下、新会话挂上」断言(去掉修复即失败);
35
+ - E2E(隔离 DSH_HOME,rc.1 与 rc.3):`member.reseat` 后 `workspace.json` 中旧会话不在、新会话在,诊断有 `workspace.detach` 行。
36
+
3
37
  ## 0.4.93 - 2026-11-14
4
38
 
5
39
  **rc.2+ 宿主上成员能激活了:`startActivation` 同时给出扁平与嵌套两种 spec**
package/README.md CHANGED
@@ -1,233 +1,233 @@
1
- <p align="center">
2
- <img src="./icon.svg" width="88" height="88" alt="文渊阁" />
3
- </p>
4
-
5
- <h1 align="center">文渊阁</h1>
6
-
7
- <p align="center">
8
- <strong>把工作交给一支 AI 团队:它们把事做到底,你定方向、把关键的关。</strong>
9
- </p>
10
-
11
- <p align="center">
12
- <a href="https://www.npmjs.com/package/@suifei/dsh-ai-team"><img alt="npm" src="https://img.shields.io/npm/v/@suifei/dsh-ai-team?color=2f6feb&label=npm"></a>
13
- <a href="https://github.com/suifei/dsh-ai-team/releases"><img alt="release" src="https://img.shields.io/github/v/release/suifei/dsh-ai-team?color=2f6feb"></a>
14
- <a href="./LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-2f6feb"></a>
15
- <img alt="tests" src="https://img.shields.io/badge/tests-82%20passing-2ea043">
16
- <img alt="dsh" src="https://img.shields.io/badge/DeepSeek%20Harness-plugin-6f42c1">
17
- </p>
18
-
19
- > 文渊阁,藏修、校勘、纂辑之地。
20
- > 在这里,Human 不在环里逐条调度,而是在环上定方向、守信任、做最后那一步。
21
-
22
- `@suifei/dsh-ai-team` 是 DeepSeek Harness 的按需启用插件:装进专用 `ai-team` profile 后,DSH 里出现一个三栏工作台——左侧 Project 与成员,中间主对话 / 看板 / 态势,右侧 Thread。Agent 自己认领 Task、互相交接,由做的人以外的成员验收;Human 只处理方向、信任和不可撤回的决定。
23
-
24
- 新 Project 自带一组可改的默认成员:**墨渊(主理人)**、**青岚(执行)**、**白砚(验收)**、**玄策(编程)**。名字、职责、个性、模型都可以改;模型提供商和模型名称直接读取 DSH 的 `llm` 目录,不需要手填 id。
25
-
26
- ---
27
-
28
- ## 为什么是「文渊阁」
29
-
30
- - **成员是持久的。** 每个 Agent 有名字、角色、personality、notes、skills 和 session;DSH 重启、上下文压缩、换代之后,它还是它。
31
- - **每个结果都有 owner。** Project 有具名 owner;Task 有唯一 accountable owner,由它推到验收。
32
- - **做的人不验收。** Agent 只能验收已进入待验收、且自己从未认领过的 Task;QA Task 只有 QA 成员能验收。
33
- - **房间是为 Agent 设计的。** 成员从自己的 inbox 拉取消息,而不是被每条消息推着走;对着已经变化的 Thread 写的回复会被退回,并附上变化摘要。
34
- - **一切有记录。** Main stream、Thread、Task、收件箱都是同一本 append-only 账本的视图。
35
- - **没有定时器。** Agent 只由 Team 事件(消息、@、交接、验收请求)唤醒;团队完全安静时不会自己醒来。
36
-
37
- ---
38
-
39
- ## 快速开始
40
-
41
- ### 1. 建专用 profile
42
-
43
- ```powershell
44
- dsh --profile ai-team --from-default-profile web --dump-config
45
- ```
46
-
47
- ### 2. 从 npm 安装
48
-
49
- ```powershell
50
- dsh plugin --profile ai-team add @suifei/dsh-ai-team
51
- ```
52
-
53
- 或从 checkout 安装:
54
-
55
- ```powershell
56
- dsh plugin --profile ai-team add E:/works/dsh-ai-team
57
- ```
58
-
59
- ### 3. 启动
60
-
61
- ```powershell
62
- dsh --profile ai-team --no-open --port 33271
63
- ```
64
-
65
- 打开终端输出的 URL,点侧栏 **文渊阁**。
66
-
67
- 第一次进入 Project 先设置 **工作目录**:工作目录编辑器会自动弹出,并预填宿主给出的建议值——配置项 `defaultWorkspace` → 当前进程目录 → **`~/works`**(Windows 为 `%USERPROFILE%\works`,Linux/macOS 为 `~/works`;不存在时自动创建)。点「选择目录」或用输入框改成任意已存在的目录即可;**新建项目必须填工作目录**(服务端强制,空目录会被 400 拒绝)。每个 Project 独立一个目录,成员只在这个目录里执行 Task。
68
-
69
- > 插件只应安装在可信机器 / 可信 Workspace:成员以 `danger-full-access` 运行,且 profile patch 会把 sandbox / approval / permission 固定为 `danger-full-access / never`。普通 `desktop`/`web` profile 不安装时保持原有 preset roster。
70
-
71
- ---
72
-
73
- ## 界面
74
-
75
- ```text
76
- ┌ 文渊阁 ───────────────────────────────────────────────────────────┐
77
- │ Projects │ Main stream / Board / Situation │ Thread │
78
- │ # 我的项目 │ 主对话:一句话开工 │ 回复 │
79
- │ # UI 项目 │ 看板:待处理 / 进行中 / 待验收 / 完成│ 验收 / 退回 │
80
- │ │ 态势:需要你 / 团队在做 / 等待受阻 / 最近完成 │ 任务动作 │
81
- │ Agents │ │ │
82
- │ 墨渊 (Lead) │ │ │
83
- │ 白砚 (QA) │ │ │
84
- └─────────────────┴────────────────────────────────────┴─────────────┘
85
- ```
86
-
87
- - **主对话**:Human 的一句话进入 Main stream,Project owner 拆 Task;顶部「团队动态」直接显示正在推进的 Task 和运行中的成员,点击 Task 可打开 Thread。
88
- - **PMO 全自动**:Project header 的「PMO 自动」默认开启;每 60s 按最高价值建议自动处理 Human 决策,无 active Task 时自动唤醒 owner 续派下一批 Task;关闭后决策回到收件箱。PMO 只能由插件算法执行,不接受外部人工/脚本指挥。
89
- - **看板**:四列;进行中的卡片显示 accountable owner 与执行者;数量只统计 active Task。
90
- - **态势**:四象限——需要你、团队在做、等待受阻、最近完成。点击条目打开对应 Task 的 Thread。
91
- - **收件箱**:跨 Project 聚合;顶部「待你处理 · N」一键进入;只放真正需要 Human 的决策/失败,Agent 的进度汇报留在 Thread/动态,不制造“打开 Task 后无事可做”。
92
- - **直接对话**:点击成员名字直接打开该 Agent 的 DSH 原生 Session;没有 session 会先激活;打不开时落到成员资料,资料里有「直接对话」按钮。
93
- - **成员任务**:成员资料里点「他的任务」,查看他 owner/assignee 的 Task。
94
- - **成员资料**:点「⋯」改名、职责、personality、provider/model、运行配方、notes、skills、re-distill、离队/人才库。
95
-
96
- ---
97
-
98
- ## 能力地图
99
-
100
- | 能力 | 说明 |
101
- |---|---|
102
- | Project | 具名 owner;独立工作目录;并发 runtime;每 Project 独立账本、Waker、SSE |
103
- | Task | 唯一 accountable owner;pending / in_progress / pending_acceptance / done / cancelled |
104
- | Thread | append-only;回复带 `baseSeq`,旧基线会被拒并说明变化 |
105
- | 验收 | maker 不能验收;QA 硬门禁;`qaChecklist` 逐项通过 |
106
- | 收件箱 | Human/Agent 各自拉取;跨 Project 聚合;顶部待办入口;`askHuman` 结构化问题与选项直接展开并提交 |
107
- | 关注 | 关注 Task;完成后收到 `followed_task_update` |
108
- | 默认成员 | 新 Project 初始化墨渊 / 青岚 / 白砚 / 玄策;可改名、改职责、改个性、改模型 |
109
- | 成员 | 持久 session;点击名字直接对话;「⋯」资料里有任务视图与直接对话 |
110
- | 模型 | Provider / Model 下拉读取 DSH `llm` 目录;可跟随系统默认 |
111
- | 进化 | `team.evolve` 只改自己的 personality;验收后 reflection wake |
112
- | 人才库 | leave/rejoin;遗留 Task 可被接管(taken-over) |
113
- | 运行配方 | `standard` / `ptc` / `minimal` / `cordis` |
114
- | 技能 | DSH `skill` 工具真实加载;SkillOpt 7 工具内置 |
115
- | 重启恢复 | `team/startup` 恢复未完成 Task,无定时器 |
116
- | 安全 | 每次成员工具调用前守卫 `danger-full-access` |
117
-
118
- ---
119
-
120
- ## 架构
121
-
122
- ```mermaid
123
- flowchart TB
124
- H[Human] --> UI[文渊阁 Workbench]
125
- UI --> HOST[Host /ai-team/api]
126
- HOST --> R1[ProjectRuntime prj_main]
127
- HOST --> R2[ProjectRuntime prj_ui]
128
- R1 --> L1[(append-only ledger)]
129
- R2 --> L2[(append-only ledger)]
130
- R1 --> S1[TeamService]
131
- R2 --> S2[TeamService]
132
- S1 --> M1[Member sessions]
133
- S2 --> M2[Member sessions]
134
- L1 -. Waker / SSE .-> M1
135
- L2 -. Waker / SSE .-> M2
136
- ```
137
-
138
- - **Host**:路由、命令、SSE、Waker、成员 runtime、权限守卫。
139
- - **ProjectRuntime**:一个 Project 一个 ledger + TeamService;启动时全部打开。
140
- - **Ledger**:JSONL + SHA-256 hash chain + checkpoint + 纯函数 fold。
141
- - **MemberRuntime**:真实 DSH Agent session,直接 `agents.create` / `followup`,没有模拟执行。
142
- - **Waker**:只从账本 append / HTTP 命令结果计划唤醒;没有 heartbeat/timer。
143
-
144
- ### API 速览
145
-
146
- ```text
147
- GET /ai-team/api/health
148
- GET /ai-team/api/bootstrap?project=<id>
149
- GET /ai-team/api/projects/<id>/board
150
- GET /ai-team/api/projects/<id>/quadrants
151
- GET /ai-team/api/projects/<id>/events # SSE
152
- POST /ai-team/api/projects/<id>/commands
153
- ```
154
-
155
- 命令覆盖 `task.create/claim/submit/accept/request_changes/cancel/reopen/delete/reassign`、`member.add/activate/config.update/profile.update/message/leave/rejoin/takeover`、`project.create/activate`、`inbox.ack` 等。
156
-
157
- ---
158
-
159
- ## 技能与 SkillOpt
160
-
161
- - 成员资料可追加 notes / skills,activation / wake prompt 会注入有界技能目录;
162
- - 完整技能正文由成员自己的 `skill` 工具加载;
163
- - `ai-team-files` provider 会读取:
164
- - `<DSH_HOME>/skills`
165
- - `<cwd>/.dsh/skills`
166
- - `<cwd>/.agents/skills`
167
- - **Microsoft SkillOpt 已内置**:7 个 `skillopt_*` 工具、Python engine bootstrap、`skillopt-sleep` 技能随插件分发,不需要单独安装 `dsh-skillopt`。
168
-
169
- ---
170
-
171
- ## 验证
172
-
173
- - `node --test`:**269 通过 / 1 跳过**(跳过项是目录 junction 用例,本机沙箱不允许创建)
174
- - 真实账本副本干跑(`.ptc/rounds/dryrun-real-ledger.mjs`,可重复运行、不写生产数据):
175
- 用**已安装的 npm 产物**启动真实项目账本,核对 `health` / `bootstrap` / `/people` /
176
- `project.repair`(`acceptedRange` + `seqGaps`)/ 新建项目空目录被 400 拒绝
177
- - 重启后验证清单:`.ptc/rounds` 与 `docs/重启后验证清单-*.md`(6 步,含命令与预期)
178
- - npm 产物一致性:远端 tarball 与本地安装副本逐文件 SHA256 比对
179
- - 真实 E2E 覆盖:
180
- - 两 Agent claim → Thread → 独立验收;
181
- - 一句话 → Lead 开卡 → QA 自动验收 → owner 自进化;
182
- - 强停重启 → `startup_resume` → 继续 Task(`NOT_RESUMABLE` 时自动重建会话,见 `member.autoreseat`);
183
- - 真实浏览器私信成员;
184
- - 四运行配方分别执行 `run_code` / `pwsh`;
185
- - 并发 Project + 跨 Project 收件箱;
186
- - DeepSeek + Zhipu 双订阅 SSE 分桶;
187
- - V-10 turn 中途权限降级后工具前修复;
188
- - billing 402 / ECONNRESET 三次重试与恢复;
189
- - 从 npm 安装后在独立 profile 启动 health 200;
190
- - 归档 host 自动解归档(`host.repair.ok`,带解归档数量);
191
- - 诊断日志分级:发布默认 `errors` 只保留失败与关键成功行(`host.repair.ok` / `member.autoreseat`),且诊断目录跟随 `DSH_HOME`。
192
-
193
- 证据目录(本机 `.ptc/rounds/`,不随 npm 发布):
194
-
195
- ```text
196
- round-02 两 Agent 独立验收
197
- round-06 验收后 self-evolve
198
- round-09 重启 startup_resume
199
- round-10 资料抽屉私信
200
- round-11 多 Project 新建/切换
201
- round-12 成员工具链 + skill 加载
202
- round-13 四种运行配方
203
- round-14 安装/卸载 smoke
204
- round-15 并发/收件箱/V-10/billing
205
- round-16 四技能安装
206
- round-17 SkillOpt 内置 + 冷恢复
207
- round-18 跨 Project 打开 Task + SSE 分桶
208
- round-19 DeepSeek + Zhipu 双 provider
209
- ```
210
-
211
- ---
212
-
213
- ## 文档(仅本地)
214
-
215
- 需求、架构、UI 研究、验收报告保存在本机 `docs/`,**不随 GitHub 仓库或 npm 包发布**。
216
- 仓库只保留 README、CHANGELOG 与运行所需的源码 / 技能。
217
-
218
- ---
219
-
220
- ## 当前边界
221
-
222
- - 单机、单 Human;不支持多 Human 共享 Team;
223
- - billing/网络注入是测试 adapter,不是物理断网;
224
- - SSE 分桶用两个真实 provider 的独立订阅端验证,不是两个浏览器窗口;
225
- - distilly / darwin 不内置,有则用、无则不用;`huashu-nuwa` 已被 Team 技能目录排除。
226
- - desktop profile 由插件 patch 固定为 `danger-full-access / never`,只应在可信机器使用。
227
-
228
- ---
229
-
230
- ## License
231
-
232
- MIT。
233
- Bundled SkillOpt integration derives from [Microsoft SkillOpt](https://github.com/microsoft/SkillOpt) `plugins/dsh` (MIT); its license lives at `lib/vendor/skillopt/LICENSE`.
1
+ <p align="center">
2
+ <img src="./icon.svg" width="88" height="88" alt="文渊阁" />
3
+ </p>
4
+
5
+ <h1 align="center">文渊阁</h1>
6
+
7
+ <p align="center">
8
+ <strong>把工作交给一支 AI 团队:它们把事做到底,你定方向、把关键的关。</strong>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/@suifei/dsh-ai-team"><img alt="npm" src="https://img.shields.io/npm/v/@suifei/dsh-ai-team?color=2f6feb&label=npm"></a>
13
+ <a href="https://github.com/suifei/dsh-ai-team/releases"><img alt="release" src="https://img.shields.io/github/v/release/suifei/dsh-ai-team?color=2f6feb"></a>
14
+ <a href="./LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-2f6feb"></a>
15
+ <img alt="tests" src="https://img.shields.io/badge/tests-82%20passing-2ea043">
16
+ <img alt="dsh" src="https://img.shields.io/badge/DeepSeek%20Harness-plugin-6f42c1">
17
+ </p>
18
+
19
+ > 文渊阁,藏修、校勘、纂辑之地。
20
+ > 在这里,Human 不在环里逐条调度,而是在环上定方向、守信任、做最后那一步。
21
+
22
+ `@suifei/dsh-ai-team` 是 DeepSeek Harness 的按需启用插件:装进专用 `ai-team` profile 后,DSH 里出现一个三栏工作台——左侧 Project 与成员,中间主对话 / 看板 / 态势,右侧 Thread。Agent 自己认领 Task、互相交接,由做的人以外的成员验收;Human 只处理方向、信任和不可撤回的决定。
23
+
24
+ 新 Project 自带一组可改的默认成员:**墨渊(主理人)**、**青岚(执行)**、**白砚(验收)**、**玄策(编程)**。名字、职责、个性、模型都可以改;模型提供商和模型名称直接读取 DSH 的 `llm` 目录,不需要手填 id。
25
+
26
+ ---
27
+
28
+ ## 为什么是「文渊阁」
29
+
30
+ - **成员是持久的。** 每个 Agent 有名字、角色、personality、notes、skills 和 session;DSH 重启、上下文压缩、换代之后,它还是它。
31
+ - **每个结果都有 owner。** Project 有具名 owner;Task 有唯一 accountable owner,由它推到验收。
32
+ - **做的人不验收。** Agent 只能验收已进入待验收、且自己从未认领过的 Task;QA Task 只有 QA 成员能验收。
33
+ - **房间是为 Agent 设计的。** 成员从自己的 inbox 拉取消息,而不是被每条消息推着走;对着已经变化的 Thread 写的回复会被退回,并附上变化摘要。
34
+ - **一切有记录。** Main stream、Thread、Task、收件箱都是同一本 append-only 账本的视图。
35
+ - **没有定时器。** Agent 只由 Team 事件(消息、@、交接、验收请求)唤醒;团队完全安静时不会自己醒来。
36
+
37
+ ---
38
+
39
+ ## 快速开始
40
+
41
+ ### 1. 建专用 profile
42
+
43
+ ```powershell
44
+ dsh --profile ai-team --from-default-profile web --dump-config
45
+ ```
46
+
47
+ ### 2. 从 npm 安装
48
+
49
+ ```powershell
50
+ dsh plugin --profile ai-team add @suifei/dsh-ai-team
51
+ ```
52
+
53
+ 或从 checkout 安装:
54
+
55
+ ```powershell
56
+ dsh plugin --profile ai-team add E:/works/dsh-ai-team
57
+ ```
58
+
59
+ ### 3. 启动
60
+
61
+ ```powershell
62
+ dsh --profile ai-team --no-open --port 33271
63
+ ```
64
+
65
+ 打开终端输出的 URL,点侧栏 **文渊阁**。
66
+
67
+ 第一次进入 Project 先设置 **工作目录**:工作目录编辑器会自动弹出,并预填宿主给出的建议值——配置项 `defaultWorkspace` → 当前进程目录 → **`~/works`**(Windows 为 `%USERPROFILE%\works`,Linux/macOS 为 `~/works`;不存在时自动创建)。点「选择目录」或用输入框改成任意已存在的目录即可;**新建项目必须填工作目录**(服务端强制,空目录会被 400 拒绝)。每个 Project 独立一个目录,成员只在这个目录里执行 Task。
68
+
69
+ > 插件只应安装在可信机器 / 可信 Workspace:成员以 `danger-full-access` 运行,且 profile patch 会把 sandbox / approval / permission 固定为 `danger-full-access / never`。普通 `desktop`/`web` profile 不安装时保持原有 preset roster。
70
+
71
+ ---
72
+
73
+ ## 界面
74
+
75
+ ```text
76
+ ┌ 文渊阁 ───────────────────────────────────────────────────────────┐
77
+ │ Projects │ Main stream / Board / Situation │ Thread │
78
+ │ # 我的项目 │ 主对话:一句话开工 │ 回复 │
79
+ │ # UI 项目 │ 看板:待处理 / 进行中 / 待验收 / 完成│ 验收 / 退回 │
80
+ │ │ 态势:需要你 / 团队在做 / 等待受阻 / 最近完成 │ 任务动作 │
81
+ │ Agents │ │ │
82
+ │ 墨渊 (Lead) │ │ │
83
+ │ 白砚 (QA) │ │ │
84
+ └─────────────────┴────────────────────────────────────┴─────────────┘
85
+ ```
86
+
87
+ - **主对话**:Human 的一句话进入 Main stream,Project owner 拆 Task;顶部「团队动态」直接显示正在推进的 Task 和运行中的成员,点击 Task 可打开 Thread。
88
+ - **PMO 全自动**:Project header 的「PMO 自动」默认开启;每 60s 按最高价值建议自动处理 Human 决策,无 active Task 时自动唤醒 owner 续派下一批 Task;关闭后决策回到收件箱。PMO 只能由插件算法执行,不接受外部人工/脚本指挥。
89
+ - **看板**:四列;进行中的卡片显示 accountable owner 与执行者;数量只统计 active Task。
90
+ - **态势**:四象限——需要你、团队在做、等待受阻、最近完成。点击条目打开对应 Task 的 Thread。
91
+ - **收件箱**:跨 Project 聚合;顶部「待你处理 · N」一键进入;只放真正需要 Human 的决策/失败,Agent 的进度汇报留在 Thread/动态,不制造“打开 Task 后无事可做”。
92
+ - **直接对话**:点击成员名字直接打开该 Agent 的 DSH 原生 Session;没有 session 会先激活;打不开时落到成员资料,资料里有「直接对话」按钮。
93
+ - **成员任务**:成员资料里点「他的任务」,查看他 owner/assignee 的 Task。
94
+ - **成员资料**:点「⋯」改名、职责、personality、provider/model、运行配方、notes、skills、re-distill、离队/人才库。
95
+
96
+ ---
97
+
98
+ ## 能力地图
99
+
100
+ | 能力 | 说明 |
101
+ |---|---|
102
+ | Project | 具名 owner;独立工作目录;并发 runtime;每 Project 独立账本、Waker、SSE |
103
+ | Task | 唯一 accountable owner;pending / in_progress / pending_acceptance / done / cancelled |
104
+ | Thread | append-only;回复带 `baseSeq`,旧基线会被拒并说明变化 |
105
+ | 验收 | maker 不能验收;QA 硬门禁;`qaChecklist` 逐项通过 |
106
+ | 收件箱 | Human/Agent 各自拉取;跨 Project 聚合;顶部待办入口;`askHuman` 结构化问题与选项直接展开并提交 |
107
+ | 关注 | 关注 Task;完成后收到 `followed_task_update` |
108
+ | 默认成员 | 新 Project 初始化墨渊 / 青岚 / 白砚 / 玄策;可改名、改职责、改个性、改模型 |
109
+ | 成员 | 持久 session;点击名字直接对话;「⋯」资料里有任务视图与直接对话 |
110
+ | 模型 | Provider / Model 下拉读取 DSH `llm` 目录;可跟随系统默认 |
111
+ | 进化 | `team.evolve` 只改自己的 personality;验收后 reflection wake |
112
+ | 人才库 | leave/rejoin;遗留 Task 可被接管(taken-over) |
113
+ | 运行配方 | `standard` / `ptc` / `minimal` / `cordis` |
114
+ | 技能 | DSH `skill` 工具真实加载;SkillOpt 7 工具内置 |
115
+ | 重启恢复 | `team/startup` 恢复未完成 Task,无定时器 |
116
+ | 安全 | 每次成员工具调用前守卫 `danger-full-access` |
117
+
118
+ ---
119
+
120
+ ## 架构
121
+
122
+ ```mermaid
123
+ flowchart TB
124
+ H[Human] --> UI[文渊阁 Workbench]
125
+ UI --> HOST[Host /ai-team/api]
126
+ HOST --> R1[ProjectRuntime prj_main]
127
+ HOST --> R2[ProjectRuntime prj_ui]
128
+ R1 --> L1[(append-only ledger)]
129
+ R2 --> L2[(append-only ledger)]
130
+ R1 --> S1[TeamService]
131
+ R2 --> S2[TeamService]
132
+ S1 --> M1[Member sessions]
133
+ S2 --> M2[Member sessions]
134
+ L1 -. Waker / SSE .-> M1
135
+ L2 -. Waker / SSE .-> M2
136
+ ```
137
+
138
+ - **Host**:路由、命令、SSE、Waker、成员 runtime、权限守卫。
139
+ - **ProjectRuntime**:一个 Project 一个 ledger + TeamService;启动时全部打开。
140
+ - **Ledger**:JSONL + SHA-256 hash chain + checkpoint + 纯函数 fold。
141
+ - **MemberRuntime**:真实 DSH Agent session,直接 `agents.create` / `followup`,没有模拟执行。
142
+ - **Waker**:只从账本 append / HTTP 命令结果计划唤醒;没有 heartbeat/timer。
143
+
144
+ ### API 速览
145
+
146
+ ```text
147
+ GET /ai-team/api/health
148
+ GET /ai-team/api/bootstrap?project=<id>
149
+ GET /ai-team/api/projects/<id>/board
150
+ GET /ai-team/api/projects/<id>/quadrants
151
+ GET /ai-team/api/projects/<id>/events # SSE
152
+ POST /ai-team/api/projects/<id>/commands
153
+ ```
154
+
155
+ 命令覆盖 `task.create/claim/submit/accept/request_changes/cancel/reopen/delete/reassign`、`member.add/activate/config.update/profile.update/message/leave/rejoin/takeover`、`project.create/activate`、`inbox.ack` 等。
156
+
157
+ ---
158
+
159
+ ## 技能与 SkillOpt
160
+
161
+ - 成员资料可追加 notes / skills,activation / wake prompt 会注入有界技能目录;
162
+ - 完整技能正文由成员自己的 `skill` 工具加载;
163
+ - `ai-team-files` provider 会读取:
164
+ - `<DSH_HOME>/skills`
165
+ - `<cwd>/.dsh/skills`
166
+ - `<cwd>/.agents/skills`
167
+ - **Microsoft SkillOpt 已内置**:7 个 `skillopt_*` 工具、Python engine bootstrap、`skillopt-sleep` 技能随插件分发,不需要单独安装 `dsh-skillopt`。
168
+
169
+ ---
170
+
171
+ ## 验证
172
+
173
+ - `node --test`:**269 通过 / 1 跳过**(跳过项是目录 junction 用例,本机沙箱不允许创建)
174
+ - 真实账本副本干跑(`.ptc/rounds/dryrun-real-ledger.mjs`,可重复运行、不写生产数据):
175
+ 用**已安装的 npm 产物**启动真实项目账本,核对 `health` / `bootstrap` / `/people` /
176
+ `project.repair`(`acceptedRange` + `seqGaps`)/ 新建项目空目录被 400 拒绝
177
+ - 重启后验证清单:`.ptc/rounds` 与 `docs/重启后验证清单-*.md`(6 步,含命令与预期)
178
+ - npm 产物一致性:远端 tarball 与本地安装副本逐文件 SHA256 比对
179
+ - 真实 E2E 覆盖:
180
+ - 两 Agent claim → Thread → 独立验收;
181
+ - 一句话 → Lead 开卡 → QA 自动验收 → owner 自进化;
182
+ - 强停重启 → `startup_resume` → 继续 Task(一个成员一个会话:续接走 `subagents.sendMessage` 冷恢复;会话确实无法续接时不新建子智能体,成员转 failed 并给 Human 决策项,见 `member.session.unresumable.fail`);
183
+ - 真实浏览器私信成员;
184
+ - 四运行配方分别执行 `run_code` / `pwsh`;
185
+ - 并发 Project + 跨 Project 收件箱;
186
+ - DeepSeek + Zhipu 双订阅 SSE 分桶;
187
+ - V-10 turn 中途权限降级后工具前修复;
188
+ - billing 402 / ECONNRESET 三次重试与恢复;
189
+ - 从 npm 安装后在独立 profile 启动 health 200;
190
+ - 归档 host 自动解归档(`host.repair.ok`,带解归档数量);
191
+ - 诊断日志分级:发布默认 `errors` 只保留失败与关键成功行(`host.repair.ok` / `member.session.reused` / `workspace.detach`),且诊断目录跟随 `DSH_HOME`。
192
+
193
+ 证据目录(本机 `.ptc/rounds/`,不随 npm 发布):
194
+
195
+ ```text
196
+ round-02 两 Agent 独立验收
197
+ round-06 验收后 self-evolve
198
+ round-09 重启 startup_resume
199
+ round-10 资料抽屉私信
200
+ round-11 多 Project 新建/切换
201
+ round-12 成员工具链 + skill 加载
202
+ round-13 四种运行配方
203
+ round-14 安装/卸载 smoke
204
+ round-15 并发/收件箱/V-10/billing
205
+ round-16 四技能安装
206
+ round-17 SkillOpt 内置 + 冷恢复
207
+ round-18 跨 Project 打开 Task + SSE 分桶
208
+ round-19 DeepSeek + Zhipu 双 provider
209
+ ```
210
+
211
+ ---
212
+
213
+ ## 文档(仅本地)
214
+
215
+ 需求、架构、UI 研究、验收报告保存在本机 `docs/`,**不随 GitHub 仓库或 npm 包发布**。
216
+ 仓库只保留 README、CHANGELOG 与运行所需的源码 / 技能。
217
+
218
+ ---
219
+
220
+ ## 当前边界
221
+
222
+ - 单机、单 Human;不支持多 Human 共享 Team;
223
+ - billing/网络注入是测试 adapter,不是物理断网;
224
+ - SSE 分桶用两个真实 provider 的独立订阅端验证,不是两个浏览器窗口;
225
+ - distilly / darwin 不内置,有则用、无则不用;`huashu-nuwa` 已被 Team 技能目录排除。
226
+ - desktop profile 由插件 patch 固定为 `danger-full-access / never`,只应在可信机器使用。
227
+
228
+ ---
229
+
230
+ ## License
231
+
232
+ MIT。
233
+ Bundled SkillOpt integration derives from [Microsoft SkillOpt](https://github.com/microsoft/SkillOpt) `plugins/dsh` (MIT); its license lives at `lib/vendor/skillopt/LICENSE`.
package/client.js CHANGED
@@ -317,6 +317,7 @@ window.__ModuleLoader__.load({
317
317
  failureContextOverflow: '上下文超出模型窗口',
318
318
  failurePolicy: '内容被安全策略拒绝',
319
319
  failureUnknown: '未知失败',
320
+ failureSession: '会话不可续接,已停止自动重建(请手动重建)',
320
321
  shortcutTitle: '键盘快捷键',
321
322
  shortcutInbox: '收件箱',
322
323
  shortcutBoard: '任务看板',
@@ -734,6 +735,7 @@ window.__ModuleLoader__.load({
734
735
  failureContextOverflow: 'Context exceeds the model window',
735
736
  failurePolicy: 'Content rejected by safety policy',
736
737
  failureUnknown: 'Unknown failure',
738
+ failureSession: 'Session not resumable; auto-rebuild stopped (rebuild manually)',
737
739
  shortcutTitle: 'Keyboard shortcuts',
738
740
  shortcutInbox: 'Inbox',
739
741
  shortcutBoard: 'Task board',
package/index.js CHANGED
@@ -107,8 +107,6 @@ export const Config = z.object({
107
107
  defaultWorkspace: z.string().default(''),
108
108
  // 启动成员会话用的 subagent provider 名;留空按宿主实际注册的自动解析(默认 spawn)。
109
109
  subagentProviderName: z.string().default('spawn'),
110
- // 同一成员 30 分钟内允许的自动重建次数(失败→自愈→再失败的死循环闸门)。
111
- autoReseatLimitPer30Min: z.number().step(1).min(1).max(100).default(6),
112
110
  // 成员 shell 风险守卫:'warn' 只记诊断(默认),'block' 直接拒绝,'off' 不介入。
113
111
  // 实机事故:成员写 serve.ps1 并用隐藏窗口拉起常驻进程,触发杀软报毒。
114
112
  shellGuard: z.union(['off', 'warn', 'block']).default('warn'),
@@ -414,6 +412,20 @@ export function apply(ctx, config = {}) {
414
412
  console.warn('[ai-team] member session workspace attach failed:', error?.message ?? error, '— reseat the member (team member.reseat) to recreate its session in the project workspace');
415
413
  }
416
414
  };
415
+ // 重建(reseat)替换掉的旧成员会话从工作区摘下。宿主没有删会话的 API,
416
+ // 不摘的话每次重建都在工作区列表里多挂一个永不再用的会话(实机 il2c:
417
+ // 11-12/13 两天 322 次自愈重建 → 323 个死会话挂在 il2c 工作区下)。
418
+ const detachMemberWorkspace = async (projectRuntime, sessionId) => {
419
+ if (typeof sessionId !== 'string' || sessionId === '') return;
420
+ const workspace = await workspaceForProject(projectRuntime);
421
+ if (workspace === null || workspace === undefined || typeof workspace.detachSession !== 'function') return;
422
+ try {
423
+ await workspace.detachSession(sessionId);
424
+ diag.append({ ev: 'workspace.detach', sessionId, projectId: projectRuntime?.id ?? null });
425
+ } catch (error) {
426
+ diag.append({ ev: 'workspace.detach.fail', sessionId, projectId: projectRuntime?.id ?? null, message: error?.message ?? String(error) });
427
+ }
428
+ };
417
429
  // A restored member session has no live AgentOptions; without a recorded
418
430
  // model/selection event its prompt renders with an unresolvable {{model}}.
419
431
  const modelSelectionLogged = new Map();
@@ -469,15 +481,26 @@ export function apply(ctx, config = {}) {
469
481
  const runtimeUnavailable = isRuntimeUnavailableFailure(member);
470
482
  if (member.routeStale !== true && runtimeUnavailable !== true) continue;
471
483
  if (member.status === 'retired') continue;
472
- const budget = activationBudget.take(member.id);
473
- if (budget.allowed !== true) {
474
- diag.append({ ev: 'member.route-reconcile.suppressed.fail', projectId: runtime.id, memberId: member.id, count: budget.count, limit: budget.limit });
484
+ // 一个成员一个会话:只有「路由过期」(Human 换了 provider/model,会话的路由在
485
+ // 创建时钉死)才新建会话。运行时不可用恢复后,已有会话原样复用——重新绑定同一
486
+ // 会话把成员拉回 running,之后照常经 subagents.sendMessage 投递(冷恢复归宿主);
487
+ // 还没有会话的才首次创建。
488
+ const reuse = member.routeStale !== true && typeof member.sessionId === 'string' && member.sessionId !== '';
489
+ if (reuse) {
490
+ void runtime.service.bindMemberSession(
491
+ { actor: { kind: 'human', memberId: HUMAN_ID }, projectId: runtime.id },
492
+ { memberId: member.id, sessionId: member.sessionId },
493
+ ).then(() => {
494
+ diag.append({ ev: 'member.session.reused', projectId: runtime.id, memberId: member.id, sessionId: member.sessionId });
495
+ }).catch((error) => {
496
+ diag.append({ ev: 'member.route-reconcile.fail', projectId: runtime.id, memberId: member.id, message: error?.message ?? String(error) });
497
+ });
475
498
  continue;
476
499
  }
477
500
  void activateMember({
478
501
  payload: {
479
502
  memberId: member.id,
480
- force: true,
503
+ ...(member.routeStale === true ? { force: true } : {}),
481
504
  prompt: runtimeUnavailable && member.routeStale !== true
482
505
  ? '运行时已恢复(此前因 subagent provider 不可用而中断)。先读 tasks 与 thread 的当前状态,继续未完成的工作,不要重复已完成的事。'
483
506
  : '模型/提供方已切换,会话按新路由重建。先读 tasks 与 thread 的当前状态,继续未完成的工作,不要重复已完成的事。',
@@ -767,10 +790,6 @@ export function apply(ctx, config = {}) {
767
790
  // 本次请求的连续失败计数(按成员会话、10 分钟窗口)。
768
791
  const requestAttempts = new Map();
769
792
  const activationTasks = new Map();
770
- // 自动重建预算:见 lib/runtime/activation-budget.js(issue #1 的 7 小时循环)。
771
- const activationBudget = createActivationBudget({
772
- limit: Number.isSafeInteger(config?.autoReseatLimitPer30Min) ? config.autoReseatLimitPer30Min : 6,
773
- });
774
793
  const pmoLastKick = new Map();
775
794
  const pmoQuiet = new Set();
776
795
  const pmoLastStall = new Map();
@@ -1009,10 +1028,9 @@ export function apply(ctx, config = {}) {
1009
1028
  cause: causeChain,
1010
1029
  });
1011
1030
  console.warn('[ai-team] wake failed:', plan.memberId, error?.code ?? error?.message ?? error);
1012
- // 一次性迁移自愈:旧形态成员会话(历史上由 agents.create 创建、
1013
- // 不在 subagent catalog)或重启后不可恢复的会话(NOT_RESUMABLE /
1014
- // is unavailable)无法经父→子通道投递。识别该失败后自动以 subagent
1015
- // 形态重建一次(重置会话),避免成员静默不再被唤醒。
1031
+ // 会话续接失败:不自动新建子智能体(见下方 legacySession 分支),只把成员
1032
+ // 记为 failed 并交给 Human;会话被占用(write handle busy)是瞬时状态,
1033
+ // 不算失败,下一次唤醒照常投递到同一会话。
1016
1034
  // 注意:member 是 try 块内变量,catch 里必须从 state 取成员。
1017
1035
  const targetMember = projectRuntime.service.state.members?.[plan.memberId];
1018
1036
  const failureText = `${error?.code ?? ''} ${error?.message ?? String(error)}`;
@@ -1033,6 +1051,7 @@ export function apply(ctx, config = {}) {
1033
1051
  || failureCode === 'NOT_RESUMABLE'
1034
1052
  || failureCode === 'ENOTFOUND';
1035
1053
  const legacySession = deadSessionPool
1054
+ && classifyWakeFailure(causeChain) !== 'wake.session-busy'
1036
1055
  && typeof targetMember?.sessionId === 'string' && targetMember.sessionId !== '';
1037
1056
  diag.append({
1038
1057
  ev: 'wake.catch.probe.fail',
@@ -1042,48 +1061,27 @@ export function apply(ctx, config = {}) {
1042
1061
  hasActivateMember: typeof activateMember === 'function',
1043
1062
  });
1044
1063
  if (legacySession) {
1045
- // 自动重建必须限额:issue #1 的「7 小时 / 200+ 子代理」就是这条路径
1046
- // 无上限地循环。超额后不再重建,成员保持 failed 并留可见诊断。
1047
- const budget = activationBudget.take(plan.memberId);
1048
- if (budget.allowed !== true) {
1049
- diag.append({
1050
- ev: 'member.reseat.suppressed.fail',
1051
- projectId: projectRuntime.id,
1052
- memberId: plan.memberId,
1053
- reason: plan.reason,
1054
- count: budget.count,
1055
- limit: budget.limit,
1056
- windowMs: budget.windowMs,
1057
- });
1058
- return;
1059
- }
1064
+ // 一个成员一个会话(官方契约:可续接子智能体只在首次 startActivation 创建,
1065
+ // 之后一律 subagents.sendMessage,离线由宿主冷恢复)。原会话续接不上时插件
1066
+ // **不新建**子智能体:成员记为 failed(waker 不再唤醒它),给 Human 一条决策项,
1067
+ // 由 Human 手动重建(member.reseat)或排查宿主。实机教训:自愈重建在 il2c 两天
1068
+ // 建了 322 个子智能体(issue #1 也是这条路径)。
1069
+ diag.append({
1070
+ ev: 'member.session.unresumable.fail',
1071
+ projectId: projectRuntime.id,
1072
+ memberId: plan.memberId,
1073
+ sessionId: targetMember.sessionId,
1074
+ reason: plan.reason,
1075
+ failureCode,
1076
+ });
1060
1077
  try {
1061
- const reseated = await activateMember({
1062
- payload: {
1063
- memberId: plan.memberId,
1064
- force: true,
1065
- // 重建 = 上下文清零:把当前 Task 与 Thread 尾巴直接递到手上,
1066
- // 不让成员靠猜测恢复现场(数据来自账本投影,不另存一份)。
1067
- prompt: `会话已重建(原会话不可恢复)。先读 tasks/thread 当前状态,继续推进;不要重复已完成的工作。${describeTaskContext(projectRuntime.service.state, plan.taskId, { includeThread: true })}`,
1068
- },
1069
- }, projectRuntime);
1070
- diag.append({
1071
- ev: 'member.autoreseat',
1072
- projectId: projectRuntime.id,
1073
- memberId: plan.memberId,
1074
- oldSessionId: targetMember.sessionId,
1075
- newSessionId: reseated?.sessionId ?? null,
1076
- ok: reseated?.error === undefined,
1077
- error: reseated?.error ?? null,
1078
- });
1079
- } catch (reseatError) {
1080
- diag.append({
1081
- ev: 'member.autoreseat.fail',
1082
- projectId: projectRuntime.id,
1083
- memberId: plan.memberId,
1084
- message: reseatError?.message ?? String(reseatError),
1085
- });
1086
- }
1078
+ await projectRuntime.service.recordMemberFailure(plan.memberId, {
1079
+ category: 'session',
1080
+ code: failureCode,
1081
+ taskId: plan.taskId ?? null,
1082
+ message: `会话 ${targetMember.sessionId} 无法续接(${failureCode})。插件不会自动新建子智能体;请手动重建该成员或排查宿主。`,
1083
+ }, projectRuntime.id);
1084
+ } catch { /* ledger may be closed */ }
1087
1085
  }
1088
1086
  try {
1089
1087
  await projectRuntime.service.recordWake(plan.memberId, {
@@ -1487,25 +1485,8 @@ export function apply(ctx, config = {}) {
1487
1485
  if (runtime === null) return '[skillopt optimize] no active project runtime';
1488
1486
  const jobId = 'job_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
1489
1487
  const actor = { kind: 'human', memberId: HUMAN_ID };
1490
- // 评审前先刷新评审官会话:subagent provider 不提供 continuable
1491
- // 会话,旧会话在重启/回合结束后即不可投递(NOT_RESUMABLE)。
1492
- // 这一步让评审投递落在**新鲜会话**上,闭环才成立。
1493
- try {
1494
- const reviewer = Object.values(runtime.service.state.members ?? {})
1495
- .find((member) => member.kind === 'agent' && (member.role === '评审' || member.name === '评审官'));
1496
- if (reviewer !== undefined) {
1497
- const refreshed = await activateMember({
1498
- payload: {
1499
- memberId: reviewer.id,
1500
- force: true,
1501
- prompt: '会话已刷新(评审官)。职责不变:只做 A/B 盲评,把一行 JSON 结论用 team 工具发到评审卡。',
1502
- },
1503
- }, runtime);
1504
- diag.append({ ev: refreshed.error === undefined ? 'skillopt.reviewer.refreshed' : 'skillopt.reviewer.refresh.fail', projectId: runtime.id, memberId: reviewer.id, sessionId: refreshed.sessionId ?? null, message: refreshed.error?.message ?? null });
1505
- }
1506
- } catch (error) {
1507
- diag.append({ ev: 'skillopt.reviewer.refresh.fail', projectId: runtime.id, message: error?.message ?? String(error) });
1508
- }
1488
+ // 评审投递走评审官原有会话(subagents.sendMessage 负责冷恢复,0.4.88 起)。
1489
+ // 旧版本在每次评审前 force 重建评审官会话——每调一次就多一个子智能体。
1509
1490
  const jobRecord = {
1510
1491
  id: jobId,
1511
1492
  state: 'judging',
@@ -1920,8 +1901,10 @@ export function apply(ctx, config = {}) {
1920
1901
  // 久管理,插件不再持有或唤醒它;新会话落在当前项目工作目录。这是
1921
1902
  // 修复历史"账本目录兜底 cwd"游离会话的唯一路径(会话 cwd 创建时
1922
1903
  // 钉死,resume 不覆盖,DSH 不提供原地改 cwd 的 API)。
1923
- if (typeof member.sessionId === 'string' && member.sessionId !== '' && body.payload?.force === true) {
1924
- const staleId = member.sessionId;
1904
+ const staleId = typeof member.sessionId === 'string' && member.sessionId !== '' && body.payload?.force === true
1905
+ ? member.sessionId
1906
+ : null;
1907
+ if (staleId !== null) {
1925
1908
  const staleActivation = activations.get(staleId);
1926
1909
  if (staleActivation !== undefined) {
1927
1910
  activations.delete(staleId);
@@ -2002,6 +1985,7 @@ export function apply(ctx, config = {}) {
2002
1985
  }
2003
1986
  activations.set(result.childId, result.activation);
2004
1987
  await attachMemberWorkspace(projectRuntime, result.childId);
1988
+ if (staleId !== null && staleId !== result.childId) await detachMemberWorkspace(projectRuntime, staleId);
2005
1989
  persistModelSelection(result.childId, activationMember.config, member.name);
2006
1990
  return {
2007
1991
  ok: true,
@@ -2230,11 +2214,7 @@ export function apply(ctx, config = {}) {
2230
2214
  const eligible = includeAll ? member.status === 'failed' : isRuntimeUnavailableFailure(member);
2231
2215
  if (eligible !== true) continue;
2232
2216
  if (member.status === 'running') { skipped.push({ memberId: member.id, reason: 'running' }); continue; }
2233
- const budget = activationBudget.take(member.id);
2234
- if (budget.allowed !== true) {
2235
- skipped.push({ memberId: member.id, reason: 'budget' });
2236
- continue;
2237
- }
2217
+ // Human 点的批量恢复:显式意图,不受自动重建冷却限制。
2238
2218
  const result = await activateMember({
2239
2219
  payload: {
2240
2220
  memberId: member.id,
package/lib/diaglog.js CHANGED
@@ -32,11 +32,13 @@ export function isErrorEvent(ev) {
32
32
  // 归档修复的**成功**行必须留在 `errors` 级别:否则「修没修」永远无法
33
33
  // 判定(只有 boot 瞬间那一行 deferred.fail 可见)。
34
34
  || ev === 'host.repair.ok'
35
- // 成员会话自愈(NOT_RESUMABLE → 重建)同理:它决定「成员还会不会被唤醒」,
36
- // 必须在发布默认级别可见,否则只能看到一连串 wake.fail 而不知道有没有救回来。
37
- || ev === 'member.autoreseat'
35
+ // 运行时恢复后复用原会话(不新建子智能体)同理:它决定「成员还会不会被唤醒」,
36
+ // 必须在发布默认级别可见,否则只能看到失败行而不知道有没有救回来。
37
+ || ev === 'member.session.reused'
38
38
  // Human 停止时中断了哪些成员:决定「停了之后还在跑」是不是插件的锅。
39
- || ev === 'team.interrupt');
39
+ || ev === 'team.interrupt'
40
+ // 重建后旧会话有没有从工作区摘掉:决定工作区列表是否随自愈累积死会话。
41
+ || ev === 'workspace.detach');
40
42
  }
41
43
 
42
44
  /**
@@ -1030,7 +1030,8 @@ export class TeamService {
1030
1030
  // 之后 member.bind 就能把 ta 复活)。直接忽略,不写事件。
1031
1031
  if (member.status === 'retired') return null;
1032
1032
  const attempt = Number.isSafeInteger(failure.attempt) ? failure.attempt : (member.lastFailure?.attempt ?? 0) + 1;
1033
- const fatal = failure.category === 'auth' || failure.category === 'billing' || failure.category === 'policy' || failure.category === 'unknown';
1033
+ const fatal = failure.category === 'auth' || failure.category === 'billing' || failure.category === 'policy' || failure.category === 'unknown'
1034
+ || failure.category === 'session';
1034
1035
  // Tool-argument and provider dumps can run to kilobytes; the ledger and
1035
1036
  // the risk list only ever need a human-readable first act of the error.
1036
1037
  const message = typeof failure.message === 'string' && failure.message.length > 400
@@ -1,46 +1,46 @@
1
- /**
2
- * 自动重建预算:把「失败 → 自愈重建 → 再失败」的死循环挡在插件这一侧。
3
- *
4
- * 实机报告(issue #1):一句「在吗」跑了 7 小时、派了两百多个子代理。触发链是
5
- * 「唤醒失败(会话不可恢复/认证失败)→ 自动重建 → 新会话再失败 → 下一次唤醒再重建」;
6
- * 只要唤醒源源不断(thread 回复、PMO 心跳),这个循环就没有上限。
7
- *
8
- * 这里给自动重建加一个滑动窗口额度:同一成员在 windowMs 内最多重建 limit 次,
9
- * 超出后**不再自动重建**,改为写一条可见诊断并让成员保持 failed(等 Human 处理)。
10
- * 正常团队工作远达不到这个阈值,只有循环才会撞上。
11
- */
12
-
13
- const DEFAULT_LIMIT = 6;
14
- const DEFAULT_WINDOW_MS = 30 * 60 * 1000;
15
-
16
- /**
17
- * @param {{ limit?: number, windowMs?: number }} options
18
- */
19
- export function createActivationBudget(options = {}) {
20
- const limit = Number.isSafeInteger(options.limit) && options.limit > 0 ? options.limit : DEFAULT_LIMIT;
21
- const windowMs = Number.isSafeInteger(options.windowMs) && options.windowMs > 0 ? options.windowMs : DEFAULT_WINDOW_MS;
22
- /** @type {Map<string, number[]>} memberId -> 最近一次重建的时间戳 */
23
- const taken = new Map();
24
- return {
25
- /** 记录一次重建并返回是否允许(先判后记,拒绝时不消耗额度)。 */
26
- take(memberId, now = Date.now()) {
27
- if (typeof memberId !== 'string' || memberId === '') return { allowed: true, count: 0 };
28
- const recent = (taken.get(memberId) ?? []).filter((at) => now - at < windowMs);
29
- if (recent.length >= limit) {
30
- taken.set(memberId, recent);
31
- return { allowed: false, count: recent.length, limit, windowMs };
32
- }
33
- recent.push(now);
34
- taken.set(memberId, recent);
35
- return { allowed: true, count: recent.length, limit, windowMs };
36
- },
37
- /** 只读查询,不消耗额度。 */
38
- peek(memberId, now = Date.now()) {
39
- const recent = (taken.get(memberId) ?? []).filter((at) => now - at < windowMs);
40
- return recent.length;
41
- },
42
- reset(memberId) {
43
- taken.delete(memberId);
44
- },
45
- };
46
- }
1
+ /**
2
+ * 自动重建预算:把「失败 → 自愈重建 → 再失败」的死循环挡在插件这一侧。
3
+ *
4
+ * 实机报告(issue #1):一句「在吗」跑了 7 小时、派了两百多个子代理。触发链是
5
+ * 「唤醒失败(会话不可恢复/认证失败)→ 自动重建 → 新会话再失败 → 下一次唤醒再重建」;
6
+ * 只要唤醒源源不断(thread 回复、PMO 心跳),这个循环就没有上限。
7
+ *
8
+ * 这里给自动重建加一个滑动窗口额度:同一成员在 windowMs 内最多重建 limit 次,
9
+ * 超出后**不再自动重建**,改为写一条可见诊断并让成员保持 failed(等 Human 处理)。
10
+ * 正常团队工作远达不到这个阈值,只有循环才会撞上。
11
+ */
12
+
13
+ const DEFAULT_LIMIT = 6;
14
+ const DEFAULT_WINDOW_MS = 30 * 60 * 1000;
15
+
16
+ /**
17
+ * @param {{ limit?: number, windowMs?: number }} options
18
+ */
19
+ export function createActivationBudget(options = {}) {
20
+ const limit = Number.isSafeInteger(options.limit) && options.limit > 0 ? options.limit : DEFAULT_LIMIT;
21
+ const windowMs = Number.isSafeInteger(options.windowMs) && options.windowMs > 0 ? options.windowMs : DEFAULT_WINDOW_MS;
22
+ /** @type {Map<string, number[]>} memberId -> 最近一次重建的时间戳 */
23
+ const taken = new Map();
24
+ return {
25
+ /** 记录一次重建并返回是否允许(先判后记,拒绝时不消耗额度)。 */
26
+ take(memberId, now = Date.now()) {
27
+ if (typeof memberId !== 'string' || memberId === '') return { allowed: true, count: 0 };
28
+ const recent = (taken.get(memberId) ?? []).filter((at) => now - at < windowMs);
29
+ if (recent.length >= limit) {
30
+ taken.set(memberId, recent);
31
+ return { allowed: false, count: recent.length, limit, windowMs };
32
+ }
33
+ recent.push(now);
34
+ taken.set(memberId, recent);
35
+ return { allowed: true, count: recent.length, limit, windowMs };
36
+ },
37
+ /** 只读查询,不消耗额度。 */
38
+ peek(memberId, now = Date.now()) {
39
+ const recent = (taken.get(memberId) ?? []).filter((at) => now - at < windowMs);
40
+ return recent.length;
41
+ },
42
+ reset(memberId) {
43
+ taken.delete(memberId);
44
+ },
45
+ };
46
+ }
@@ -1,155 +1,157 @@
1
- /**
2
- * LLM failure classification and the deterministic retry/fallback decision.
3
- *
4
- * The listener on `agent/request-error` owns the retry for transient
5
- * server/network failures and re-dispatches the same request immediately
6
- * (DSH's agent loop supports that via `{ kind: 'retry' }`). There are no
7
- * timers: a fallback patch only rewrites the member's persisted config, so it
8
- * takes effect on the next wake — the current turn ends (`fail`). Rate limits
9
- * also end the turn: hammering the same route at once burns the retry budget
10
- * without a backoff clock. Auth/billing/policy failures are fail-closed and
11
- * require a Human or the Project owner to change the environment.
12
- */
13
-
14
- export const FAILURE_CATEGORY = Object.freeze({
15
- AUTH: 'auth',
16
- BILLING: 'billing',
17
- RATE_LIMIT: 'rate_limit',
18
- NETWORK: 'network',
19
- SERVER: 'server',
20
- MODEL_UNAVAILABLE: 'model_unavailable',
21
- CONTEXT_OVERFLOW: 'context_overflow',
22
- POLICY: 'policy',
23
- UNKNOWN: 'unknown',
24
- });
25
-
26
- const NETWORK_CODES = new Set([
27
- 'ECONNRESET', 'ECONNREFUSED', 'ETIMEDOUT', 'ENOTFOUND', 'EAI_AGAIN', 'EPIPE', 'UND_ERR_CONNECT_TIMEOUT',
28
- ]);
29
-
30
- function statusOf(error) {
31
- const value = error?.status ?? error?.statusCode ?? error?.response?.status ?? error?.details?.status;
32
- return Number.isSafeInteger(value) ? value : null;
33
- }
34
-
35
- function codeOf(error) {
36
- return String(error?.code ?? error?.details?.code ?? '').toUpperCase();
37
- }
38
-
39
- function textOf(error) {
40
- return String(error?.message ?? error?.details?.message ?? '').toLowerCase();
41
- }
42
-
43
- /** Map a provider/network error to one stable category + policy. */
44
- export function classifyLlmFailure(error) {
45
- const status = statusOf(error);
46
- const code = codeOf(error);
47
- const text = textOf(error);
48
- const base = { status, code: code || null, message: error?.message ?? '' };
49
-
50
- if (status === 401 || status === 403 || code.includes('INVALID_API_KEY') || code.includes('UNAUTHORIZED')) {
51
- return { ...base, category: FAILURE_CATEGORY.AUTH, retryable: false, humanRequired: true, action: 'stop' };
52
- }
53
- // 429 必须先判:限流响应常带 "quota"/"insufficient" 字样,若先走 billing
54
- // 分支就会被当成致命计费错误,永远不重试也不换路。
55
- if (status === 429 || code.includes('RATE_LIMIT') || /rate limit/.test(text)) {
56
- return { ...base, category: FAILURE_CATEGORY.RATE_LIMIT, retryable: true, humanRequired: false, action: 'retry_or_fallback' };
57
- }
58
- if (
59
- status === 402 ||
60
- /insufficient|balance|quota|billing|payment|credit/.test(code) ||
61
- /insufficient|balance|quota|billing|payment|credit/.test(text)
62
- ) {
63
- return { ...base, category: FAILURE_CATEGORY.BILLING, retryable: false, humanRequired: true, action: 'stop' };
64
- }
65
- if (status !== null && status >= 500) {
66
- return { ...base, category: FAILURE_CATEGORY.SERVER, retryable: true, humanRequired: false, action: 'retry_or_fallback' };
67
- }
68
- if (NETWORK_CODES.has(code) || /network|timeout|timed out|socket|connection reset|dns/.test(text)) {
69
- return { ...base, category: FAILURE_CATEGORY.NETWORK, retryable: true, humanRequired: false, action: 'retry_or_fallback' };
70
- }
71
- if (status === 404 || /model.*(not found|unavailable)|unknown model/.test(text)) {
72
- return { ...base, category: FAILURE_CATEGORY.MODEL_UNAVAILABLE, retryable: false, humanRequired: false, action: 'fallback' };
73
- }
74
- if (/context.*(length|window|overflow)|too many tokens|maximum context/.test(text)) {
75
- return { ...base, category: FAILURE_CATEGORY.CONTEXT_OVERFLOW, retryable: false, humanRequired: false, action: 'compact_or_fallback' };
76
- }
77
- if (status === 400 && /content|policy|refus|safety/.test(text)) {
78
- return { ...base, category: FAILURE_CATEGORY.POLICY, retryable: false, humanRequired: true, action: 'stop' };
79
- }
80
- return { ...base, category: FAILURE_CATEGORY.UNKNOWN, retryable: false, humanRequired: true, action: 'stop' };
81
- }
82
-
83
- function fallbackAt(config, index) {
84
- const list = Array.isArray(config?.fallback) ? config.fallback : [];
85
- return list[index] ?? null;
86
- }
87
-
88
- /**
89
- * Decide what the request-error listener does next. `retry` re-dispatches the
90
- * same request immediately; `fallback` writes the config patch and ends the
91
- * turn (it can only take effect on the next wake, because a step's route is
92
- * captured before dispatch); `fail` ends the turn unchanged.
93
- */
94
- /**
95
- * 本次请求的连续失败次数。
96
- *
97
- * 此前调用方把 `member.attempts`(成员**生命周期**里的失败计数)当成本次尝试数传进来,
98
- * 于是换路索引被跳过、重试预算被历史失败提前耗尽。这里按会话维护一个窗口内的计数:
99
- * 窗口过期即视为新请求(成员被唤醒重试时应当拿到完整预算)。
100
- */
101
- export function nextRequestAttempt(store, sessionId, now = Date.now(), windowMs = 10 * 60_000) {
102
- const key = typeof sessionId === 'string' && sessionId !== '' ? sessionId : '(unknown)';
103
- const prior = store?.get?.(key);
104
- const attempt = prior !== undefined && typeof prior.at === 'number' && now - prior.at < windowMs
105
- ? prior.count + 1
106
- : 1;
107
- store?.set?.(key, { count: attempt, at: now });
108
- return attempt;
109
- }
110
-
111
- export function retryDecision(failure, config = {}, attempt = 1) {
112
- const maxAttempts = Number.isSafeInteger(config.retry?.maxAttempts)
113
- ? Math.max(1, Math.min(config.retry.maxAttempts, 5))
114
- : 3;
115
- // 换路(fallback)能否执行取决于“路由可变”,与“同路由立刻重试”不同:
116
- // model_unavailable / context_overflow 明确声明了 fallback 语义且 retryable=false,
117
- // 若这里按 retryable 一刀切返回 fail,它们的 fallback 声明就永远不可达。
118
- const fallbackCapable = failure?.retryable === true
119
- || failure?.action === 'fallback'
120
- || failure?.action === 'compact_or_fallback';
121
- if (!fallbackCapable) return { action: 'fail', attempt, reason: `${failure?.category ?? 'unknown'} has no recoverable action` };
122
- const nextFallbackIndex = attempt - 1;
123
- const fallback = fallbackAt(config, nextFallbackIndex);
124
- if (fallback !== null) {
125
- // 换路优先于预算:fallback 不是同路由重试,预算钳制它会让 maxAttempts=1
126
- // 的配置永远走不到备用路由。
127
- return {
128
- action: 'fallback',
129
- attempt,
130
- fallbackIndex: nextFallbackIndex,
131
- patch: {
132
- provider: fallback.provider ?? config.provider,
133
- model: fallback.model ?? config.model,
134
- ...(fallback.reasoningEffort === undefined ? {} : { reasoningEffort: fallback.reasoningEffort }),
135
- ...(fallback.maxTokens === undefined ? {} : { maxTokens: fallback.maxTokens }),
136
- },
137
- reason: `fallback to ${fallback.provider ?? config.provider}/${fallback.model ?? config.model}`,
138
- };
139
- }
140
- if (failure?.retryable !== true) {
141
- return { action: 'fail', attempt, reason: `${failure?.category ?? 'unknown'} is not retryable and has no fallback route` };
142
- }
143
- if (attempt >= maxAttempts) return { action: 'fail', attempt, reason: `retry budget exhausted (${maxAttempts})` };
144
- // No fallback route configured: a rate limit would hit again at once
145
- // without a backoff clock — end the turn and let the next event/startup
146
- // try fresh instead of burning the budget on a throttled route.
147
- if (failure.category === FAILURE_CATEGORY.RATE_LIMIT) {
148
- return { action: 'fail', attempt, reason: 'rate limited; left to the next wake' };
149
- }
150
- return { action: 'retry', attempt, reason: 'same route, immediate retry' };
151
- }
152
-
153
- export function describeFailure(failure) {
154
- return `${failure.category}${failure.status ? ` HTTP ${failure.status}` : ''}${failure.code ? ` ${failure.code}` : ''}`;
155
- }
1
+ /**
2
+ * LLM failure classification and the deterministic retry/fallback decision.
3
+ *
4
+ * The listener on `agent/request-error` owns the retry for transient
5
+ * server/network failures and re-dispatches the same request immediately
6
+ * (DSH's agent loop supports that via `{ kind: 'retry' }`). There are no
7
+ * timers: a fallback patch only rewrites the member's persisted config, so it
8
+ * takes effect on the next wake — the current turn ends (`fail`). Rate limits
9
+ * also end the turn: hammering the same route at once burns the retry budget
10
+ * without a backoff clock. Auth/billing/policy failures are fail-closed and
11
+ * require a Human or the Project owner to change the environment.
12
+ */
13
+
14
+ export const FAILURE_CATEGORY = Object.freeze({
15
+ AUTH: 'auth',
16
+ BILLING: 'billing',
17
+ RATE_LIMIT: 'rate_limit',
18
+ NETWORK: 'network',
19
+ SERVER: 'server',
20
+ MODEL_UNAVAILABLE: 'model_unavailable',
21
+ CONTEXT_OVERFLOW: 'context_overflow',
22
+ POLICY: 'policy',
23
+ // 成员会话不可续接且已用掉自动重建额度(见 activation-budget.js autoReseatAllowed)。
24
+ SESSION: 'session',
25
+ UNKNOWN: 'unknown',
26
+ });
27
+
28
+ const NETWORK_CODES = new Set([
29
+ 'ECONNRESET', 'ECONNREFUSED', 'ETIMEDOUT', 'ENOTFOUND', 'EAI_AGAIN', 'EPIPE', 'UND_ERR_CONNECT_TIMEOUT',
30
+ ]);
31
+
32
+ function statusOf(error) {
33
+ const value = error?.status ?? error?.statusCode ?? error?.response?.status ?? error?.details?.status;
34
+ return Number.isSafeInteger(value) ? value : null;
35
+ }
36
+
37
+ function codeOf(error) {
38
+ return String(error?.code ?? error?.details?.code ?? '').toUpperCase();
39
+ }
40
+
41
+ function textOf(error) {
42
+ return String(error?.message ?? error?.details?.message ?? '').toLowerCase();
43
+ }
44
+
45
+ /** Map a provider/network error to one stable category + policy. */
46
+ export function classifyLlmFailure(error) {
47
+ const status = statusOf(error);
48
+ const code = codeOf(error);
49
+ const text = textOf(error);
50
+ const base = { status, code: code || null, message: error?.message ?? '' };
51
+
52
+ if (status === 401 || status === 403 || code.includes('INVALID_API_KEY') || code.includes('UNAUTHORIZED')) {
53
+ return { ...base, category: FAILURE_CATEGORY.AUTH, retryable: false, humanRequired: true, action: 'stop' };
54
+ }
55
+ // 429 必须先判:限流响应常带 "quota"/"insufficient" 字样,若先走 billing
56
+ // 分支就会被当成致命计费错误,永远不重试也不换路。
57
+ if (status === 429 || code.includes('RATE_LIMIT') || /rate limit/.test(text)) {
58
+ return { ...base, category: FAILURE_CATEGORY.RATE_LIMIT, retryable: true, humanRequired: false, action: 'retry_or_fallback' };
59
+ }
60
+ if (
61
+ status === 402 ||
62
+ /insufficient|balance|quota|billing|payment|credit/.test(code) ||
63
+ /insufficient|balance|quota|billing|payment|credit/.test(text)
64
+ ) {
65
+ return { ...base, category: FAILURE_CATEGORY.BILLING, retryable: false, humanRequired: true, action: 'stop' };
66
+ }
67
+ if (status !== null && status >= 500) {
68
+ return { ...base, category: FAILURE_CATEGORY.SERVER, retryable: true, humanRequired: false, action: 'retry_or_fallback' };
69
+ }
70
+ if (NETWORK_CODES.has(code) || /network|timeout|timed out|socket|connection reset|dns/.test(text)) {
71
+ return { ...base, category: FAILURE_CATEGORY.NETWORK, retryable: true, humanRequired: false, action: 'retry_or_fallback' };
72
+ }
73
+ if (status === 404 || /model.*(not found|unavailable)|unknown model/.test(text)) {
74
+ return { ...base, category: FAILURE_CATEGORY.MODEL_UNAVAILABLE, retryable: false, humanRequired: false, action: 'fallback' };
75
+ }
76
+ if (/context.*(length|window|overflow)|too many tokens|maximum context/.test(text)) {
77
+ return { ...base, category: FAILURE_CATEGORY.CONTEXT_OVERFLOW, retryable: false, humanRequired: false, action: 'compact_or_fallback' };
78
+ }
79
+ if (status === 400 && /content|policy|refus|safety/.test(text)) {
80
+ return { ...base, category: FAILURE_CATEGORY.POLICY, retryable: false, humanRequired: true, action: 'stop' };
81
+ }
82
+ return { ...base, category: FAILURE_CATEGORY.UNKNOWN, retryable: false, humanRequired: true, action: 'stop' };
83
+ }
84
+
85
+ function fallbackAt(config, index) {
86
+ const list = Array.isArray(config?.fallback) ? config.fallback : [];
87
+ return list[index] ?? null;
88
+ }
89
+
90
+ /**
91
+ * Decide what the request-error listener does next. `retry` re-dispatches the
92
+ * same request immediately; `fallback` writes the config patch and ends the
93
+ * turn (it can only take effect on the next wake, because a step's route is
94
+ * captured before dispatch); `fail` ends the turn unchanged.
95
+ */
96
+ /**
97
+ * 本次请求的连续失败次数。
98
+ *
99
+ * 此前调用方把 `member.attempts`(成员**生命周期**里的失败计数)当成本次尝试数传进来,
100
+ * 于是换路索引被跳过、重试预算被历史失败提前耗尽。这里按会话维护一个窗口内的计数:
101
+ * 窗口过期即视为新请求(成员被唤醒重试时应当拿到完整预算)。
102
+ */
103
+ export function nextRequestAttempt(store, sessionId, now = Date.now(), windowMs = 10 * 60_000) {
104
+ const key = typeof sessionId === 'string' && sessionId !== '' ? sessionId : '(unknown)';
105
+ const prior = store?.get?.(key);
106
+ const attempt = prior !== undefined && typeof prior.at === 'number' && now - prior.at < windowMs
107
+ ? prior.count + 1
108
+ : 1;
109
+ store?.set?.(key, { count: attempt, at: now });
110
+ return attempt;
111
+ }
112
+
113
+ export function retryDecision(failure, config = {}, attempt = 1) {
114
+ const maxAttempts = Number.isSafeInteger(config.retry?.maxAttempts)
115
+ ? Math.max(1, Math.min(config.retry.maxAttempts, 5))
116
+ : 3;
117
+ // 换路(fallback)能否执行取决于“路由可变”,与“同路由立刻重试”不同:
118
+ // model_unavailable / context_overflow 明确声明了 fallback 语义且 retryable=false,
119
+ // 若这里按 retryable 一刀切返回 fail,它们的 fallback 声明就永远不可达。
120
+ const fallbackCapable = failure?.retryable === true
121
+ || failure?.action === 'fallback'
122
+ || failure?.action === 'compact_or_fallback';
123
+ if (!fallbackCapable) return { action: 'fail', attempt, reason: `${failure?.category ?? 'unknown'} has no recoverable action` };
124
+ const nextFallbackIndex = attempt - 1;
125
+ const fallback = fallbackAt(config, nextFallbackIndex);
126
+ if (fallback !== null) {
127
+ // 换路优先于预算:fallback 不是同路由重试,预算钳制它会让 maxAttempts=1
128
+ // 的配置永远走不到备用路由。
129
+ return {
130
+ action: 'fallback',
131
+ attempt,
132
+ fallbackIndex: nextFallbackIndex,
133
+ patch: {
134
+ provider: fallback.provider ?? config.provider,
135
+ model: fallback.model ?? config.model,
136
+ ...(fallback.reasoningEffort === undefined ? {} : { reasoningEffort: fallback.reasoningEffort }),
137
+ ...(fallback.maxTokens === undefined ? {} : { maxTokens: fallback.maxTokens }),
138
+ },
139
+ reason: `fallback to ${fallback.provider ?? config.provider}/${fallback.model ?? config.model}`,
140
+ };
141
+ }
142
+ if (failure?.retryable !== true) {
143
+ return { action: 'fail', attempt, reason: `${failure?.category ?? 'unknown'} is not retryable and has no fallback route` };
144
+ }
145
+ if (attempt >= maxAttempts) return { action: 'fail', attempt, reason: `retry budget exhausted (${maxAttempts})` };
146
+ // No fallback route configured: a rate limit would hit again at once
147
+ // without a backoff clock — end the turn and let the next event/startup
148
+ // try fresh instead of burning the budget on a throttled route.
149
+ if (failure.category === FAILURE_CATEGORY.RATE_LIMIT) {
150
+ return { action: 'fail', attempt, reason: 'rate limited; left to the next wake' };
151
+ }
152
+ return { action: 'retry', attempt, reason: 'same route, immediate retry' };
153
+ }
154
+
155
+ export function describeFailure(failure) {
156
+ return `${failure.category}${failure.status ? ` HTTP ${failure.status}` : ''}${failure.code ? ` ${failure.code}` : ''}`;
157
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.93",
3
+ "version": "0.4.95",
4
4
  "type": "module",
5
5
  "description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
6
6
  "license": "MIT",