@oyasmi/pipiclaw 0.9.3-beta.4 → 0.9.3-beta.5

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.
Files changed (38) hide show
  1. package/README.en.md +12 -12
  2. package/README.md +12 -12
  3. package/dist/agent/channel-runner.js +1 -1
  4. package/dist/agent/job-manager.js +1 -2
  5. package/dist/channel/channel-context.d.ts +2 -2
  6. package/dist/channel/channel-context.js +2 -2
  7. package/dist/channel/channel-event.d.ts +3 -3
  8. package/dist/playbooks/agent-delegation.md +15 -11
  9. package/dist/playbooks/background-jobs.md +1 -1
  10. package/dist/playbooks/runtime-orientation.md +2 -0
  11. package/dist/playbooks/task-loop.md +1 -1
  12. package/dist/runtime/bootstrap.js +12 -9
  13. package/dist/runtime/delivery.d.ts +1 -2
  14. package/dist/runtime/delivery.js +57 -62
  15. package/dist/runtime/dingtalk.d.ts +15 -8
  16. package/dist/runtime/dingtalk.js +101 -35
  17. package/dist/subagents/discovery.js +4 -2
  18. package/dist/subagents/external/claude-code.js +3 -1
  19. package/dist/subagents/external/harness.d.ts +4 -2
  20. package/dist/subagents/external/run.js +12 -3
  21. package/dist/subagents/runs.js +1 -2
  22. package/examples/sub-agents/README.md +65 -81
  23. package/examples/sub-agents/agents/claude-high.md +23 -0
  24. package/examples/sub-agents/agents/claude-main.md +23 -0
  25. package/examples/sub-agents/agents/codex-flash.md +23 -0
  26. package/examples/sub-agents/agents/codex-high.md +23 -0
  27. package/examples/sub-agents/agents/codex-main.md +23 -0
  28. package/examples/sub-agents/agents/glm-flash.md +23 -0
  29. package/examples/sub-agents/agents/glm-high.md +23 -0
  30. package/package.json +1 -1
  31. /package/examples/sub-agents/{builder-hard.md → roles/builder-hard.md} +0 -0
  32. /package/examples/sub-agents/{builder.md → roles/builder.md} +0 -0
  33. /package/examples/sub-agents/{explorer.md → roles/explorer.md} +0 -0
  34. /package/examples/sub-agents/{git-committer.md → roles/git-committer.md} +0 -0
  35. /package/examples/sub-agents/{planner.md → roles/planner.md} +0 -0
  36. /package/examples/sub-agents/{reviewer.md → roles/reviewer.md} +0 -0
  37. /package/examples/sub-agents/{verifier.md → roles/verifier.md} +0 -0
  38. /package/examples/sub-agents/{worker.md → roles/worker.md} +0 -0
package/README.en.md CHANGED
@@ -18,11 +18,11 @@ What you see is one assistant, but behind it can be a well-divided AI engineerin
18
18
 
19
19
  Pipiclaw supports two kinds of delegation at once: built-in sub-agents do lightweight work in-process such as retrieval and log triage; external agents launch real Claude Code, Codex CLI, or any script to handle heavy tasks that need long runs, many files, and repeated self-testing.
20
20
 
21
- In DingTalk daemon mode, external tasks keep running in the background after dispatch and automatically wake the originating channel on completion. You can use `/subagents` at any time to check run status, the actual command, and outputs, use `/subagents cancel` to terminate directly, and let the main agent keep asking follow-up questions on a finished Claude Code / Codex session. The repo ships explorer, builder, reviewer, verifier, and git-committer role templates that are ready to adapt.
21
+ In DingTalk daemon mode, external tasks keep running in the background after dispatch and automatically wake the originating channel on completion. You can use `/subagents` at any time to check run status, the actual command, and outputs, use `/subagents cancel` to terminate directly, and let the main agent keep asking follow-up questions on a finished Claude Code / Codex session. The repo ships recommended capability-and-cost entries plus earlier job-style role templates for reference.
22
22
 
23
23
  ### Work does not end when a conversation ends
24
24
 
25
- Every session has its own current state, long-term memory, and history summary. The task ledger persists goals, done criteria, progress, next steps, and verification records to Markdown files; the built-in task driver resumes work at the right time — continuing when there is progress, backing off when stalled, and stopping and telling you when a boundary is crossed.
25
+ Every session has its own current state, long-term memory, and history summary. The task ledger persists goals, done criteria, progress, next steps, and verification records to Markdown files; the built-in task driver resumes work from waiting tickets and schedules, and stops with a notice when a budget, idle-loop, or repeated-expiry boundary is reached.
26
26
 
27
27
  ### Natively at home in DingTalk
28
28
 
@@ -50,7 +50,7 @@ Pipiclaw today targets individuals and small teams, self-hosted, single-instance
50
50
 
51
51
  ## Quick start
52
52
 
53
- Below are three progressive paths: verify a model in the terminal first, then connect DingTalk, then enable external agents. If you already have a clear goal, jump straight to the relevant part.
53
+ The steps below cover local verification, DingTalk setup, and external-agent configuration in order. If you already have a clear goal, jump straight to the relevant part.
54
54
 
55
55
  ### 1. Install and confirm the CLI
56
56
 
@@ -95,10 +95,10 @@ pipiclaw tui
95
95
  It can also be used for scripted one-shot requests:
96
96
 
97
97
  ```bash
98
- pipiclaw tui --print "Review the current project and give me the three highest-priority risks"
98
+ pipiclaw tui --print "Reply with only: Pipiclaw model call succeeded"
99
99
  ```
100
100
 
101
- To connect an enterprise gateway, a local model, or set a default model, see [Configuration reference](https://github.com/oyasmi/pipiclaw/blob/main/docs/configuration.md).
101
+ Only an actual model reply proves that the request path works; `pipiclaw tui --help` and `/model` only prove that the CLI or model catalog is visible. Before real work, use `/project` to confirm the current project directory. To connect an enterprise gateway, a local model, or set a default model, see [Configuration reference](https://github.com/oyasmi/pipiclaw/blob/main/docs/configuration.md).
102
102
 
103
103
  ### 3. Connect DingTalk
104
104
 
@@ -134,7 +134,7 @@ Start the daemon:
134
134
  pipiclaw
135
135
  ```
136
136
 
137
- In DingTalk, send `/model` first to confirm the model is available, then send:
137
+ In DingTalk, send `/model` to inspect the model reference, then send a normal message to verify a real call:
138
138
 
139
139
  ```text
140
140
  Please introduce yourself and explain what you can do right now
@@ -144,12 +144,12 @@ If the first message does not succeed, start from [Deployment and operations](ht
144
144
 
145
145
  ### 4. Enable external agent delegation
146
146
 
147
- First install and log in to the target CLI under the same account that runs Pipiclaw, then copy the roles you need. The example below enables both a Claude Code builder and a Codex reviewer:
147
+ First install and log in to the target CLI under the same account that runs Pipiclaw, then copy the capability entries you need. This enables the main Claude Code and Codex entries:
148
148
 
149
149
  ```bash
150
150
  mkdir -p ~/.pipiclaw/workspace/sub-agents
151
151
  PIPICLAW_PACKAGE_DIR="$(npm root -g)/@oyasmi/pipiclaw"
152
- cp "$PIPICLAW_PACKAGE_DIR"/examples/sub-agents/{builder,reviewer}.md \
152
+ cp "$PIPICLAW_PACKAGE_DIR"/examples/sub-agents/agents/{claude-main,codex-main}.md \
153
153
  ~/.pipiclaw/workspace/sub-agents/
154
154
  ```
155
155
 
@@ -159,10 +159,10 @@ Role file changes are rediscovered at runtime. Send:
159
159
  /subagents roles
160
160
  ```
161
161
 
162
- Once the roles show as available, you can describe a goal and name a role directly:
162
+ Once the entries show as available, describe the goal and acceptance criteria and let the main agent select an executor:
163
163
 
164
164
  ```text
165
- Please hand this cross-module implementation to the builder, and once it's done have the reviewer check it independently.
165
+ Please hand this cross-module implementation to a suitable executor, then independently check the final changes.
166
166
  ```
167
167
 
168
168
  Common control entry points:
@@ -175,7 +175,7 @@ Common control entry points:
175
175
  /subagents roles [name] # view the role directory and a single role's config
176
176
  ```
177
177
 
178
- External agents do not go through Pipiclaw's command and path guards. Before using the example roles, read the authorization, security boundary, and sandbox notes in the [Agent delegation guide](https://github.com/oyasmi/pipiclaw/blob/main/docs/sub-agents.md).
178
+ External agents do not go through Pipiclaw's command and path guards. The recommended entries above use permissive CLI flags; before using them, read the authorization, security boundary, and sandbox notes in the [Agent delegation guide](https://github.com/oyasmi/pipiclaw/blob/main/docs/sub-agents.md).
179
179
 
180
180
  Long-running external delegations should run in the DingTalk daemon; the TUI currently does not provide completion notifications for external runs or re-adoption after exit.
181
181
 
@@ -243,7 +243,7 @@ npm run build
243
243
  npm run check # lint + typecheck + deadcode + test
244
244
  ```
245
245
 
246
- Minimal verification: `npm run typecheck` and `npm run test`. Real-model E2E uses `npm run test:e2e` and is not part of the daily unit tests.
246
+ Minimal verification: `npm run typecheck` and `npm run test`. `npm run test:e2e` is deterministic, offline, and credential-free; the small real-model smoke suite uses `npm run test:e2e:live`.
247
247
 
248
248
  ## License
249
249
 
package/README.md CHANGED
@@ -18,11 +18,11 @@ Pipiclaw 是一个面向个人和团队的 AI coding assistant runtime。它让
18
18
 
19
19
  Pipiclaw 同时支持两类委派:内置子智能体在进程内完成检索、日志筛查等轻量工作;外部智能体则启动真实的 Claude Code、Codex CLI 或任意脚本,处理需要长时间运行、跨多个文件和反复自测的重型任务。
20
20
 
21
- 在钉钉常驻模式中,外部任务派发后在后台继续执行,完成时自动唤醒原频道。你可以随时用 `/subagents` 查看运行状态、实际命令和产出,用 `/subagents cancel` 直接终止,也可以让主智能体在已结束的 Claude Code / Codex 会话上继续追问。仓库附带 explorer、builder、reviewer、verifier、git-committer 等可直接改造的角色模板。
21
+ 在钉钉常驻模式中,外部任务派发后在后台继续执行,完成时自动唤醒原频道。你可以随时用 `/subagents` 查看运行状态、实际命令和产出,用 `/subagents cancel` 直接终止,也可以让主智能体在已结束的 Claude Code / Codex 会话上继续追问。仓库附带按能力与成本组织的推荐条目,以及可参考的早期岗位角色模板。
22
22
 
23
23
  ### 工作不会随着一次对话结束
24
24
 
25
- 每个会话都有独立的当前状态、长期记忆和历史摘要。任务台账把目标、完成标准、进度、下一步和验收记录持久化到 Markdown 文件;内建 task driver 会在合适的时间恢复工作,有进展就继续,停滞则退避,超过边界就停止并告诉你。
25
+ 每个会话都有独立的当前状态、长期记忆和历史摘要。任务台账把目标、完成标准、进度、下一步和验收记录持久化到 Markdown 文件;内建 task driver 根据等待票和周期调度恢复工作,预算耗尽、空转或连续无法兑现等待时会停止并告诉你。
26
26
 
27
27
  ### 原生工作在钉钉里
28
28
 
@@ -50,7 +50,7 @@ Pipiclaw 当前定位是个人与小团队、自托管、单实例运行。它
50
50
 
51
51
  ## 快速开始
52
52
 
53
- 下面提供三条递进路径:先在终端验证模型,再接入钉钉,最后启用外部智能体。已经有明确目标时可以直接跳到对应部分。
53
+ 下面按顺序完成本地验证、钉钉接入和外部智能体配置;已经有明确目标时可以直接跳到对应部分。
54
54
 
55
55
  ### 1. 安装并确认 CLI
56
56
 
@@ -95,10 +95,10 @@ pipiclaw tui
95
95
  也可以用于脚本化的一次性请求:
96
96
 
97
97
  ```bash
98
- pipiclaw tui --print "检查当前项目并给出三个最高优先级风险"
98
+ pipiclaw tui --print "只回复:Pipiclaw 模型调用成功"
99
99
  ```
100
100
 
101
- 如需接入企业网关、本地模型或指定默认模型,请看[配置速查](https://github.com/oyasmi/pipiclaw/blob/main/docs/configuration.md)。
101
+ 看到模型实际回复才表示调用链路已经跑通;`pipiclaw tui --help` 或 `/model` 只能证明 CLI 或模型目录可见。正式工作前可用 `/project` 确认当前项目目录。如需接入企业网关、本地模型或指定默认模型,请看[配置速查](https://github.com/oyasmi/pipiclaw/blob/main/docs/configuration.md)。
102
102
 
103
103
  ### 3. 接入钉钉
104
104
 
@@ -134,7 +134,7 @@ pipiclaw tui --print "检查当前项目并给出三个最高优先级风险"
134
134
  pipiclaw
135
135
  ```
136
136
 
137
- 先在钉钉里发送 `/model`,确认模型可用,再发送:
137
+ 先在钉钉里发送 `/model` 检查模型引用,再发送一条普通消息验证真实调用:
138
138
 
139
139
  ```text
140
140
  请介绍一下你自己,并说明你现在能做什么
@@ -144,12 +144,12 @@ pipiclaw
144
144
 
145
145
  ### 4. 启用外部智能体委派
146
146
 
147
- 先在运行 Pipiclaw 的同一账号下安装并登录目标 CLI,然后复制需要的角色。下面的示例同时启用 Claude Code builder 和 Codex reviewer:
147
+ 先在运行 Pipiclaw 的同一账号下安装并登录目标 CLI,然后复制需要的能力条目。下面启用 Claude Code 与 Codex 的两个主力条目:
148
148
 
149
149
  ```bash
150
150
  mkdir -p ~/.pipiclaw/workspace/sub-agents
151
151
  PIPICLAW_PACKAGE_DIR="$(npm root -g)/@oyasmi/pipiclaw"
152
- cp "$PIPICLAW_PACKAGE_DIR"/examples/sub-agents/{builder,reviewer}.md \
152
+ cp "$PIPICLAW_PACKAGE_DIR"/examples/sub-agents/agents/{claude-main,codex-main}.md \
153
153
  ~/.pipiclaw/workspace/sub-agents/
154
154
  ```
155
155
 
@@ -159,10 +159,10 @@ cp "$PIPICLAW_PACKAGE_DIR"/examples/sub-agents/{builder,reviewer}.md \
159
159
  /subagents roles
160
160
  ```
161
161
 
162
- 确认角色显示为可用后,可以直接描述目标并指定角色:
162
+ 确认条目显示为可用后,直接描述目标和验收要求,由主智能体选择执行器:
163
163
 
164
164
  ```text
165
- 请把这个跨模块实现交给 builder 完成,完成后再让 reviewer 独立检查。
165
+ 请把这个跨模块实现交给合适的执行器,完成后独立检查最终改动。
166
166
  ```
167
167
 
168
168
  常用控制入口:
@@ -175,7 +175,7 @@ cp "$PIPICLAW_PACKAGE_DIR"/examples/sub-agents/{builder,reviewer}.md \
175
175
  /subagents roles [name] # 查看角色目录和单个角色配置
176
176
  ```
177
177
 
178
- 外部智能体不会经过 Pipiclaw 的命令和路径守卫。使用示例角色前,请阅读[智能体委派指南](https://github.com/oyasmi/pipiclaw/blob/main/docs/sub-agents.md)中的授权、安全边界和 sandbox 说明。
178
+ 外部智能体不会经过 Pipiclaw 的命令和路径守卫。上述推荐条目使用放开权限的 CLI 参数;使用前必须阅读[智能体委派指南](https://github.com/oyasmi/pipiclaw/blob/main/docs/sub-agents.md)中的授权、安全边界和 sandbox 说明。
179
179
 
180
180
  长时间外部委派应运行在钉钉 daemon 中;TUI 当前不提供外部 run 的完成通知和退出后的重新认领。
181
181
 
@@ -243,7 +243,7 @@ npm run build
243
243
  npm run check # lint + typecheck + deadcode + test
244
244
  ```
245
245
 
246
- 最小验证:`npm run typecheck` 和 `npm run test`。真实模型 E2E 使用 `npm run test:e2e`,不包含在日常单元测试中。
246
+ 最小验证:`npm run typecheck` 和 `npm run test`。`npm run test:e2e` 是离线、无凭据的确定性全栈测试;少量真实模型 smoke 使用 `npm run test:e2e:live`。
247
247
 
248
248
  ## 许可证
249
249
 
@@ -462,7 +462,7 @@ export class ChannelRunner {
462
462
  else if (isSilentOutcome(finalOutcome)) {
463
463
  try {
464
464
  await ctx.deleteMessage();
465
- log.logInfo("Silent response - deleted message");
465
+ log.logInfo("Silent response - ended progress delivery");
466
466
  }
467
467
  catch (err) {
468
468
  const errMsg = errorMessage(err);
@@ -710,8 +710,7 @@ export class ChannelJobManager {
710
710
  ts: String(Date.now()),
711
711
  conversationType: this.channelId.startsWith("group_") ? "2" : "1",
712
712
  dispatchId: `job:${this.channelId}:${record.id}:done`,
713
- // P0-2: a user is waiting on this job's result — render the resulting turn's progress
714
- // instead of the "none" style autonomous check-ins get.
713
+ // The result is awaited; the wake itself still runs without a progress card.
715
714
  presentation: "awaited",
716
715
  ...(record.contract.taskId
717
716
  ? {
@@ -77,6 +77,7 @@ export interface ChannelContext {
77
77
  respondInThread: (text: string) => Promise<void>;
78
78
  setTyping: (isTyping: boolean) => Promise<void>;
79
79
  setWorking: (working: boolean) => Promise<void>;
80
+ /** End without a final answer. Transports may preserve already-visible progress. */
80
81
  deleteMessage: () => Promise<void>;
81
82
  primeCard: (delayMs: number) => void;
82
83
  flush: () => Promise<void>;
@@ -93,7 +94,6 @@ export interface ChannelContext {
93
94
  * something to say routes it through `task_step_end`'s `notify` — which the runtime delivers on
94
95
  * the real context after the step ends.
95
96
  *
96
- * Card/typing/lifecycle calls pass through: they affect no transcript and keep the transport's
97
- * own state machine consistent.
97
+ * Lifecycle calls pass through for cleanup; card priming is a visible write and is muted too.
98
98
  */
99
99
  export declare function muteChannelContext(ctx: ChannelContext): ChannelContext;
@@ -25,8 +25,7 @@
25
25
  * something to say routes it through `task_step_end`'s `notify` — which the runtime delivers on
26
26
  * the real context after the step ends.
27
27
  *
28
- * Card/typing/lifecycle calls pass through: they affect no transcript and keep the transport's
29
- * own state machine consistent.
28
+ * Lifecycle calls pass through for cleanup; card priming is a visible write and is muted too.
30
29
  */
31
30
  export function muteChannelContext(ctx) {
32
31
  return {
@@ -35,5 +34,6 @@ export function muteChannelContext(ctx) {
35
34
  respondPlain: async () => true,
36
35
  replaceMessage: async () => undefined,
37
36
  respondInThread: async () => undefined,
37
+ primeCard: () => undefined,
38
38
  };
39
39
  }
@@ -74,9 +74,9 @@ export interface ChannelEvent {
74
74
  /**
75
75
  * Purely a display hint: `"awaited"` marks a synthetic wake a human is actually waiting on (a
76
76
  * delegation or background job finishing), as opposed to an autonomous check-in (task-driver
77
- * polling, a scheduled event) that normally has nothing to say. The runtime uses it to decide
78
- * whether the resulting turn renders progress or stays silent until a final answer — it must
79
- * never gate task activation or any other trust decision; that stays on `internalWake` alone.
77
+ * polling, a scheduled event) that normally has nothing to say. All synthetic wakes now
78
+ * deliver only their result; this metadata does not enable progress cards or gate task
79
+ * activation. Trust decisions stay on `internalWake` alone.
80
80
  */
81
81
  presentation?: "awaited";
82
82
  }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: agent-delegation
3
- description: 判断是否值得委派内部子代理(subagent)或外部 AI Agent,选择角色、交代上下文、并行隔离、等待与续接时。
3
+ description: 判断是否值得委派内部子代理(subagent)或外部 AI Agent,按能力与成本选执行器、交代上下文、并行隔离、等待与续接时。
4
4
  order: 60
5
5
  ---
6
6
 
@@ -10,17 +10,21 @@ order: 60
10
10
 
11
11
  普通临时委派无需 task;需要跨回合保留目标、预算和验收状态才建 task。正式验收用 `purpose: verify` 且必须有现存 `taskId`;普通调查和审查用 `purpose: work`,在 task 文本里写清检查要求即可。
12
12
 
13
- ## 选角色
13
+ ## 选执行器
14
14
 
15
- 优先 `subagent` 调用目录里合适的角色;按 description、light/heavy 工作量、read/write 行为和实际能力选择,不按底层 harness 名字选。内置角色通常同步返回,超过 120 秒自动转异步;外部角色一律异步,转换不是失败。
15
+ 把目录条目的 `description`、runtime、工具/模型、成本、`mutates` 和可用状态当作选择依据;条目正文可能包含部署者设定的岗位或流程约束,不能假定所有目录都按某套命名或档位组织。优先选能以最低背景重建和整合成本满足本轮验收的已配置条目:明确重复工作用低成本能力,常规实现与排查用主力能力,只有确需新判断、专用输入或更强推理时才升级。
16
16
 
17
- 没有合适角色且工具可用时才用 `subagent_inline`。按角色调用只提供本次任务、目录与 purpose/taskId,工具、模型、预算、上下文策略由角色文件决定;inline 才自行提供 systemPrompt、工具和 effort 等控制参数。放宽预算不能代替清晰的任务要求。
17
+ 外部条目不经过 Pipiclaw 的工具守卫,实际权限由条目命令、CLI sandbox、宿主账号与环境决定;任务文本只表达授权范围,不能代替强制边界。声明 `mutates: write` 的委派会取得目录写 lease,同一或父子目录的并行写入必须使用独立 worktree。外部或其他 advisory verifier 的 PASS 仍需按风险核对真实产物、diff 和检查输出。
18
18
 
19
- 角色 unavailable 时先判断主代理或其他可用角色能否以相同验收标准完成,必要时拆成真正独立的小分片;缺少必需能力才说明需要部署者补什么。light/heavy 本身不是能力证明。
19
+ 需要独立判断时(评审、验收、复核别人的结论),**独立性必须写进 task**:给同一份要求和验收口径、指明待检版本与检查入口,并写明「你是检查者,不修实现,不把实现者的总结当作预期行为的来源」。换一个条目不会自动带来独立性。
20
+
21
+ 先使用匹配的已配置条目;目录没有合适条目时,才用 `subagent_inline` 做一次性内置工作并自行提供 systemPrompt、工具和 effort。按条目调用只提供 `task`、`workingDirectory` 和 purpose/taskId,模型、推理档和预算由条目文件决定。放宽预算不能代替清晰要求。内置委派通常同步返回,超过 120 秒自动转异步;外部条目一律异步,转换不是失败。
22
+
23
+ 条目 unavailable 时先判断主代理或其他可用条目能否以相同验收标准完成,必要时拆成真正独立的小分片;缺少必需能力才说明需要部署者补什么。light/heavy 本身不是能力证明。
20
24
 
21
25
  ## 任务指令:执行者看不到本会话
22
26
 
23
- 内置从隔离上下文启动,外部是另一个进程;`context: index` 也只有背景索引,没有本次聊天。每次 `task` 都要自足,角色提示词只提供稳定能力。
27
+ 内置从隔离上下文启动,外部是另一个进程;即使配置注入背景索引,也没有本次聊天的完整语义。每次 `task` 都要自足,不能依赖条目正文替你交代本轮目标、范围或验收。
24
28
 
25
29
  紧凑地交代:**本轮结果 → 已有证据 → 适用要求 → 工作入口与边界 → 交付和验收标准**。来源不确定的假设单独标明;给少量关键路径/符号/复现入口,让执行者自己探索,不先重做一遍它的调查。用户要求应同时交给执行者和验收者。
26
30
 
@@ -36,18 +40,18 @@ order: 60
36
40
 
37
41
  ## 每次决定工作目录与写入边界
38
42
 
39
- 省略 workingDirectory 默认当前频道的 ProjectRoot,角色文件没有默认目录。项目边界启用时显式目录也必须在项目内。
43
+ 省略 workingDirectory 默认当前频道的 ProjectRoot,条目文件没有默认目录。项目边界启用时显式目录也必须在项目内。
40
44
 
41
45
  - 并行写分片各建独立 worktree,并显式传 workingDirectory;用完清理自己创建的 worktree。默认目录不会自动隔离。
42
46
  - runtime 只对声明 `mutates: write` 的委派提供排他写 lease;遇到冲突按错误中的持有者 runId 等待或重选工作目录。
43
47
  - 主代理自己的 write/edit/bash 不受 lease 保护;活跃写委派的工作树不要同时修改。
44
- - 内置 mutates 默认从 write/edit 工具推断,bash 也能写但不会被自动识别;外部 mutates 是声明,不是 sandbox。inline 需要写入时显式声明 write;已配置角色声明有误时由部署者改角色文件,模型不能 write/edit `sub-agents/`,也不要换 bash 绕过。
48
+ - 内置 mutates 默认从 write/edit 工具推断,bash 也能写但不会被自动识别;外部 mutates 是声明,不是 sandbox。inline 需要写入时显式声明 write;已配置条目声明有误时由部署者改条目文件,模型不能 write/edit `sub-agents/`,也不要换 bash 绕过。
45
49
 
46
- 外部 Agent 的权限边界是角色命令、CLI sandbox、宿主账号与环境,它不经过 Pipiclaw 的工具守卫。给它的外部动作范围必须清楚。
50
+ 外部 Agent 的权限边界是条目命令、CLI sandbox、宿主账号与环境,它不经过 Pipiclaw 的工具守卫;放开权限运行的条目只剩宿主账号这一层。给它的外部动作范围必须清楚。
47
51
 
48
52
  ## 返回、等待与恢复
49
53
 
50
- **结果已返回**:读取并检查,不再 park 或等第二次通知。**仍在运行**:记录 runId,完成其他独立工作/派发;只剩等待时结束回合,不轮询、重派或用后台 job/event 包一层等待。
54
+ **结果已返回**:读取并检查,不再 park 或等第二次通知。**仍在运行**:记录 runId,完成其他独立工作/派发;在具备完成唤醒的 DingTalk daemon 中,只剩等待时结束回合,不轮询、重派或用后台 job/event 包一层等待。TUI 不负责外部 run 的完成通知或退出后认领,长跑委派不要依赖它托管。
51
55
 
52
56
  关联 task 的委派从首次派发就带 taskId。**在 task 步骤内**等待时,用 `task_step_end` park 到 `{"kind":"run","id":"<runId>"}`;若提示已结算,读取结果并继续。多个 run 同属任务时,票指向当前真正阻塞下一阶段的 run,醒来再查看其余状态。普通聊天没有 task_step_end。
53
57
 
@@ -61,6 +65,6 @@ daemon 重启后内置 run 判 lost,外部通常继续;外部启动信息尚
61
65
 
62
66
  `subagent_run op=follow_up` 只支持已结束的 claude-code/codex-cli run,产生新的 runId;追加内容只写原契约的变化。目标不变、反馈局部、旧上下文可靠时续接,避免重建背景。换方向、反复沿错误假设尝试、需要独立判断时开新委派。
63
67
 
64
- 内置和 exec 不支持续接,带已有产出重新委派。角色 command/model/shell 改过时续接会拒绝,也应新开。明确阻塞、循环、崩溃、需纠偏或用户要求时才 cancel;耗时长本身不是取消理由。取消不再唤醒,用户 `/stop` 不会连带取消委派。
68
+ 内置和 exec 不支持续接,带已有产出重新委派。条目 command/model/shell 改过时续接会拒绝,也应新开。明确阻塞、循环、崩溃、需纠偏或用户要求时才 cancel;耗时长本身不是取消理由。取消不再唤醒,用户 `/stop` 不会连带取消委派。
65
69
 
66
70
  需要正式 task 验收时,再读 `task-loop.md` 的“独立验收”;证明强度、PASS 失效和返工裁决由那里统一说明。普通审查无需走该协议,但同样要核实证据、达标即停。
@@ -17,7 +17,7 @@ order: 50
17
17
 
18
18
  ## 派发与收尾
19
19
 
20
- 启动后先完成互不依赖的工作或派发;只剩等待时结束回合,不连续 poll 或建回访事件。作业终态会带回退出码、耗时、输出尾部和完整输出路径。
20
+ 启动后先完成互不依赖的工作或派发。在具备完成唤醒的 DingTalk daemon 中,只剩等待时结束回合,不连续 poll 或建回访事件;TUI 没有常驻完成投递,退出前不要依赖它托管待返回的作业。作业终态会带回退出码、耗时、输出尾部和完整输出路径。
21
21
 
22
22
  属于 task 的作业启动时传 `taskId`;**当前是 task 步骤时**用 `task_step_end` park 到 `{"kind":"job","id":"<jobId>"}`。若已结束、票被拒,读取输出并继续,不重跑命令。票过期等恢复问题才读 `task-loop.md` 的“等待与恢复”。
23
23
 
@@ -14,6 +14,8 @@ order: 10
14
14
  - **任务步骤**(`[TASK_STEP:<id>]`,有 `task_step_end`):在独立的 cycle 会话里推进当前契约。没有 `task_create`、`memory_save`、`event_manage`;缺少这些工具是执行边界,不要换文件写入来绕过。
15
15
  - **子代理**:不继承聊天历史;上下文与工作目录由本次委派决定。准备委派时读 `agent-delegation.md` 的“任务指令”。
16
16
 
17
+ DingTalk daemon 是长期宿主,负责 task driver、后台 job/委派完成唤醒和外部 run 重启对账。TUI 适合前台回合,不提供这些常驻保证;不要在 TUI 中建立依赖退出后自动恢复的工作。
18
+
17
19
  ## 已有上下文
18
20
 
19
21
  先用已注入的信息,缺什么再查什么:
@@ -56,7 +56,7 @@ run/job 派发时即带 taskId;先完成独立工作和必要的并行派发
56
56
 
57
57
  signal 事件必须在聊天侧预建为 task.<channelId>.<taskId>.<use> 的 periodic;循环先检查条件,未满足才等待。缺少事件且不能自主继续时 blocked 说明缺什么,不绕过工具限制。
58
58
 
59
- 票自带 runtime 兜底。过期后的 brief 会标明等待来源:先检查真实状态,再继续或换票;同 cycle 第二次过期停止并通知用户。预算任一项耗尽也会停止;这些回执由 runtime 发出,无需再花模型回合解释。用户命令 `/tasks resume <id>` 恢复、`/tasks reply <id> ...` 回答阻塞问题。
59
+ 票自带 runtime 兜底。过期后的 brief 会标明等待来源:先检查真实状态,再继续或换票;同 cycle 第二次过期停止并通知用户。预算任一项耗尽也会停止;回执由 runtime 发出。用户用 `/tasks reply <id> ...` 回答阻塞问题;手工暂停或票过期可直接 `/tasks resume <id>`,`steps`/`rounds`/`usd` 耗尽要同时 `+...` 加码,`wallMin`/`until` 耗尽则先让 Agent 用 `task_update` 调整预算再恢复。
60
60
 
61
61
  ## 外部动作
62
62
 
@@ -514,6 +514,7 @@ function createDingTalkHandler(deps) {
514
514
  await getDurableDispatch()?.markStarted(event.dispatchId);
515
515
  let structuredWakeFinalized = event.internalWake === undefined;
516
516
  const task = (async () => {
517
+ let baseCtx;
517
518
  try {
518
519
  // Computed before archiving so a command's own text can be excluded from
519
520
  // memory-extraction input (review 2026-08-24 §1.2): it is control-plane
@@ -530,16 +531,15 @@ function createDingTalkHandler(deps) {
530
531
  images: relativeImagePaths(options.paths.workspaceDir, event.channelId, event.images),
531
532
  }, "user message");
532
533
  // Background wakes deliver their result, not their process: no progress card, no
533
- // thinking stream, nothing to delete when the check-in ends `[SILENT]`. An "awaited"
534
- // wake (a delegation or job finishing) is the opposite — a human is actually waiting
535
- // on it — so it renders progress the same way a normal message does (P0-2).
536
- const backgroundOnly = Boolean(_isEvent) && event.presentation !== "awaited";
534
+ // thinking stream, nothing to clean up when a check-in ends `[SILENT]`.
535
+ // Awaited completions deliver their result too, without opening another progress card.
536
+ const backgroundOnly = Boolean(_isEvent);
537
537
  // Spec 051, D3: a task-driver dispatch runs as a *task step* — in the task cycle's
538
538
  // own session, with a brief instead of the wake text, and silent unless the step
539
539
  // asked for a notify. Everything below (busy state, /stop, delivery) is unchanged;
540
540
  // only which session the turn is bound to, and what reaches the channel, differ.
541
541
  let taskStep;
542
- let baseCtx = createDingTalkContext(event, bot, store, backgroundOnly ? "none" : undefined);
542
+ baseCtx = createDingTalkContext(event, bot, store, backgroundOnly ? "none" : undefined);
543
543
  let ctx = baseCtx;
544
544
  if (builtInCommand) {
545
545
  const commandStartedAt = Date.now();
@@ -592,9 +592,6 @@ function createDingTalkHandler(deps) {
592
592
  ctx: { channelId: event.channelId, userName: event.userName },
593
593
  fields: { messageLength: event.text.length, source: _isEvent ? "event" : "message" },
594
594
  });
595
- if (!backgroundOnly) {
596
- ctx.primeCard(350);
597
- }
598
595
  // Both wake formats below carry an unauthenticated claim in plain text: anything
599
596
  // that can put a message on this channel can *write* "[JOB:x] ... belongs to task
600
597
  // y." or "[SUBAGENT:x] ... belongs to task y." — including another user, or an
@@ -659,10 +656,13 @@ function createDingTalkHandler(deps) {
659
656
  // first: routing directly from user-controlled wake text would grant task-only tools.
660
657
  taskStep = await prepareTaskStep(event, runner);
661
658
  if (taskStep) {
659
+ await baseCtx.close();
662
660
  event = { ...event, text: taskStep.brief };
663
- baseCtx = createDingTalkContext(event, bot, store, backgroundOnly ? "none" : undefined);
661
+ baseCtx = createDingTalkContext(event, bot, store, "none");
664
662
  ctx = muteChannelContext(baseCtx);
665
663
  }
664
+ if (!backgroundOnly && !taskStep)
665
+ ctx.primeCard(1500);
666
666
  const result = await runner.run(ctx, store);
667
667
  if (taskStep)
668
668
  await finishTaskStep(event.channelId, taskStep.taskId, bot);
@@ -677,6 +677,9 @@ function createDingTalkHandler(deps) {
677
677
  });
678
678
  }
679
679
  finally {
680
+ await baseCtx?.close().catch((error) => {
681
+ log.logWarning(`[${event.channelId}] Failed to close delivery`, errorMessage(error));
682
+ });
680
683
  if (structuredWakeFinalized)
681
684
  await getDurableDispatch()?.markCompleted(event.dispatchId);
682
685
  else
@@ -7,8 +7,7 @@ import type { DingTalkBot } from "./dingtalk.js";
7
7
  *
8
8
  * `progressStyleOverride` lets the caller quiet a turn the user did not ask for. Background wakes
9
9
  * (task driver, finished jobs, scheduled events) pass `"none"`: without it every autonomous step
10
- * created an AI card in the human's conversation, streamed the model's thinking into it, and — for
11
- * the `[SILENT]` turns that are the *normal* outcome of a check-in — deleted the card again. The
10
+ * created an AI card in the human's conversation even when the check-in ended `[SILENT]`. The
12
11
  * final answer is unaffected; it is delivered by `respondPlain`/`replaceMessage` either way, so a
13
12
  * background turn that has something to say still says it.
14
13
  */