@oyasmi/pipiclaw 0.9.5-beta.2 → 0.9.5-beta.3

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 (272) hide show
  1. package/README.en.md +9 -11
  2. package/README.md +9 -11
  3. package/dist/agent/channel-runner.d.ts +12 -24
  4. package/dist/agent/channel-runner.js +74 -30
  5. package/dist/agent/maintenance-context.d.ts +2 -0
  6. package/dist/agent/maintenance-context.js +15 -0
  7. package/dist/agent/prompt/sections.js +8 -6
  8. package/dist/agent/prompt/types.d.ts +1 -1
  9. package/dist/agent/runner-factory.js +1 -1
  10. package/dist/agent/session/command-extension.js +11 -0
  11. package/dist/agent/session/compaction-summary.js +6 -2
  12. package/dist/agent/session/execution-trace.d.ts +14 -0
  13. package/dist/agent/session/execution-trace.js +57 -0
  14. package/dist/agent/session/session-events.d.ts +2 -7
  15. package/dist/agent/session/session-events.js +35 -12
  16. package/dist/agent/session/session-host.d.ts +12 -22
  17. package/dist/agent/session/session-host.js +46 -65
  18. package/dist/agent/turn/task-digest.d.ts +1 -2
  19. package/dist/agent/turn/task-digest.js +33 -33
  20. package/dist/agent/turn/turn-context.d.ts +1 -1
  21. package/dist/agent/turn/turn-context.js +1 -1
  22. package/dist/agent/turn/turn-finish.d.ts +2 -2
  23. package/dist/agent/turn/turn-finish.js +3 -2
  24. package/dist/agent/turn/turn-pipeline.d.ts +4 -2
  25. package/dist/agent/turn/turn-pipeline.js +33 -5
  26. package/dist/agent/types.d.ts +64 -14
  27. package/dist/agent/types.js +3 -0
  28. package/dist/app/home.js +3 -4
  29. package/dist/channel/channel-event.d.ts +4 -12
  30. package/dist/channel/ingress.d.ts +1 -9
  31. package/dist/channel/store.d.ts +1 -1
  32. package/dist/commands/catalog.js +25 -19
  33. package/dist/commands/router.d.ts +5 -2
  34. package/dist/commands/router.js +9 -4
  35. package/dist/config/settings.d.ts +5 -12
  36. package/dist/config/settings.js +0 -7
  37. package/dist/config/tools.d.ts +2 -2
  38. package/dist/config/tools.js +2 -2
  39. package/dist/dingtalk/bot.d.ts +2 -0
  40. package/dist/dingtalk/bot.js +4 -0
  41. package/dist/dingtalk/cards.d.ts +7 -0
  42. package/dist/dingtalk/cards.js +32 -2
  43. package/dist/dingtalk/delivery.d.ts +5 -1
  44. package/dist/dingtalk/delivery.js +157 -142
  45. package/dist/dingtalk/progress.d.ts +55 -6
  46. package/dist/dingtalk/progress.js +195 -16
  47. package/dist/file-store.d.ts +4 -0
  48. package/dist/file-store.js +6 -1
  49. package/dist/jobs/completion-observer.d.ts +20 -0
  50. package/dist/jobs/completion-observer.js +107 -0
  51. package/dist/jobs/completion-signal.d.ts +9 -0
  52. package/dist/jobs/completion-signal.js +32 -0
  53. package/dist/jobs/completion-wake.d.ts +1 -1
  54. package/dist/jobs/completion-wake.js +2 -13
  55. package/dist/jobs/manager.d.ts +11 -29
  56. package/dist/jobs/manager.js +103 -176
  57. package/dist/jobs/probe.d.ts +3 -0
  58. package/dist/jobs/probe.js +42 -0
  59. package/dist/jobs/record.d.ts +3 -6
  60. package/dist/jobs/runtime.d.ts +28 -0
  61. package/dist/jobs/runtime.js +69 -0
  62. package/dist/memory/boundary-work.d.ts +2 -0
  63. package/dist/memory/boundary-work.js +79 -37
  64. package/dist/memory/commands.js +4 -1
  65. package/dist/memory/index-budget.js +18 -15
  66. package/dist/memory/journal.js +2 -1
  67. package/dist/memory/lifecycle.d.ts +4 -8
  68. package/dist/memory/lifecycle.js +21 -51
  69. package/dist/memory/reflect-job.d.ts +0 -6
  70. package/dist/memory/reflect-job.js +13 -34
  71. package/dist/memory/reflect.d.ts +4 -0
  72. package/dist/memory/reflect.js +32 -5
  73. package/dist/memory/review-log.d.ts +13 -0
  74. package/dist/memory/review-log.js +49 -0
  75. package/dist/memory/search.js +7 -4
  76. package/dist/memory/source-window.d.ts +18 -1
  77. package/dist/memory/source-window.js +59 -9
  78. package/dist/memory/store.d.ts +2 -0
  79. package/dist/memory/store.js +45 -13
  80. package/dist/playbooks/agent-delegation.md +10 -4
  81. package/dist/playbooks/background-jobs.md +4 -4
  82. package/dist/playbooks/event-scheduling.md +2 -2
  83. package/dist/playbooks/memory-and-learning.md +3 -3
  84. package/dist/playbooks/outbound-media.md +2 -2
  85. package/dist/playbooks/runtime-orientation.md +10 -6
  86. package/dist/playbooks/task-lead.md +54 -33
  87. package/dist/runtime/bootstrap.d.ts +11 -24
  88. package/dist/runtime/bootstrap.js +92 -59
  89. package/dist/runtime/channel-queue.d.ts +2 -0
  90. package/dist/runtime/channel-queue.js +5 -1
  91. package/dist/runtime/durable-dispatch.d.ts +7 -0
  92. package/dist/runtime/durable-dispatch.js +66 -7
  93. package/dist/runtime/ingress-busy.d.ts +1 -2
  94. package/dist/runtime/ingress-busy.js +2 -35
  95. package/dist/runtime/ingress-commands.d.ts +1 -1
  96. package/dist/runtime/ingress-commands.js +28 -20
  97. package/dist/runtime/ingress-deps.d.ts +4 -7
  98. package/dist/runtime/ingress.js +23 -13
  99. package/dist/runtime/shutdown.d.ts +1 -1
  100. package/dist/runtime/shutdown.js +2 -2
  101. package/dist/runtime/task-close.d.ts +4 -0
  102. package/dist/runtime/task-close.js +102 -0
  103. package/dist/runtime/task-control.d.ts +34 -0
  104. package/dist/runtime/task-control.js +225 -0
  105. package/dist/runtime/task-input.d.ts +13 -0
  106. package/dist/runtime/task-input.js +129 -0
  107. package/dist/runtime/task-lane-types.d.ts +123 -0
  108. package/dist/runtime/task-lane-types.js +14 -0
  109. package/dist/runtime/task-lane.d.ts +99 -0
  110. package/dist/runtime/task-lane.js +703 -0
  111. package/dist/runtime/task-pending.d.ts +8 -0
  112. package/dist/runtime/task-pending.js +40 -0
  113. package/dist/runtime/task-spawn.d.ts +4 -4
  114. package/dist/runtime/task-spawn.js +4 -4
  115. package/dist/runtime/task-step.d.ts +32 -0
  116. package/dist/runtime/task-step.js +276 -0
  117. package/dist/runtime/turn-run.d.ts +4 -16
  118. package/dist/runtime/turn-run.js +17 -155
  119. package/dist/runtime/wake-coalescing.d.ts +1 -3
  120. package/dist/runtime/wake-coalescing.js +2 -4
  121. package/dist/shared/format.d.ts +0 -6
  122. package/dist/shared/format.js +0 -17
  123. package/dist/shared/host-process.d.ts +2 -0
  124. package/dist/shared/host-process.js +16 -1
  125. package/dist/shared/jsonl-appender.d.ts +5 -0
  126. package/dist/shared/jsonl-appender.js +25 -2
  127. package/dist/skills/catalog.d.ts +9 -0
  128. package/dist/skills/catalog.js +34 -0
  129. package/dist/skills/commands.d.ts +3 -12
  130. package/dist/skills/commands.js +36 -22
  131. package/dist/skills/loader.d.ts +2 -31
  132. package/dist/skills/loader.js +101 -68
  133. package/dist/skills/roots.d.ts +12 -0
  134. package/dist/skills/roots.js +18 -0
  135. package/dist/skills/types.d.ts +24 -0
  136. package/dist/skills/types.js +1 -0
  137. package/dist/subagents/completion-wake.js +0 -10
  138. package/dist/subagents/discovery.d.ts +1 -1
  139. package/dist/subagents/discovery.js +10 -16
  140. package/dist/subagents/dispatch.js +8 -16
  141. package/dist/subagents/external/cursor-cli.d.ts +2 -0
  142. package/dist/subagents/external/cursor-cli.js +256 -0
  143. package/dist/subagents/external/harness.d.ts +5 -5
  144. package/dist/subagents/external/reconciliation.d.ts +7 -0
  145. package/dist/subagents/external/reconciliation.js +105 -0
  146. package/dist/subagents/external/recovery.d.ts +20 -0
  147. package/dist/subagents/external/recovery.js +71 -0
  148. package/dist/subagents/external/registry.js +2 -0
  149. package/dist/subagents/external/role-warnings.d.ts +17 -0
  150. package/dist/subagents/external/role-warnings.js +42 -0
  151. package/dist/subagents/external/run.js +18 -22
  152. package/dist/subagents/format.d.ts +1 -1
  153. package/dist/subagents/format.js +1 -1
  154. package/dist/subagents/grace.d.ts +2 -2
  155. package/dist/subagents/grace.js +3 -3
  156. package/dist/subagents/internal/run.js +7 -5
  157. package/dist/subagents/internal/worker.js +31 -2
  158. package/dist/subagents/result.js +2 -3
  159. package/dist/subagents/run-record.d.ts +4 -7
  160. package/dist/subagents/run-record.js +2 -2
  161. package/dist/subagents/runs.d.ts +33 -46
  162. package/dist/subagents/runs.js +126 -245
  163. package/dist/subagents/task-settlement.d.ts +3 -0
  164. package/dist/subagents/task-settlement.js +20 -0
  165. package/dist/subagents/types.d.ts +1 -2
  166. package/dist/subagents/workspace-summary.js +5 -1
  167. package/dist/tasks/archive.d.ts +11 -0
  168. package/dist/tasks/archive.js +141 -0
  169. package/dist/tasks/board.d.ts +5 -12
  170. package/dist/tasks/board.js +4 -30
  171. package/dist/tasks/bound-work.d.ts +12 -6
  172. package/dist/tasks/bound-work.js +37 -24
  173. package/dist/tasks/brief.d.ts +38 -14
  174. package/dist/tasks/brief.js +128 -70
  175. package/dist/tasks/budget.d.ts +3 -3
  176. package/dist/tasks/budget.js +9 -4
  177. package/dist/tasks/commands.d.ts +14 -9
  178. package/dist/tasks/commands.js +190 -121
  179. package/dist/tasks/completion.d.ts +12 -0
  180. package/dist/tasks/completion.js +35 -0
  181. package/dist/tasks/contract.d.ts +8 -17
  182. package/dist/tasks/contract.js +41 -43
  183. package/dist/tasks/control.d.ts +138 -0
  184. package/dist/tasks/control.js +1 -0
  185. package/dist/tasks/create.d.ts +1 -1
  186. package/dist/tasks/create.js +3 -3
  187. package/dist/tasks/delivery.d.ts +24 -0
  188. package/dist/tasks/delivery.js +221 -0
  189. package/dist/tasks/file-mutation.d.ts +5 -0
  190. package/dist/tasks/file-mutation.js +38 -0
  191. package/dist/tasks/frontmatter.d.ts +43 -28
  192. package/dist/tasks/frontmatter.js +83 -40
  193. package/dist/tasks/input-receipts.d.ts +7 -0
  194. package/dist/tasks/input-receipts.js +60 -0
  195. package/dist/tasks/loop-log.d.ts +147 -28
  196. package/dist/tasks/loop-log.js +239 -28
  197. package/dist/tasks/receipts.d.ts +19 -0
  198. package/dist/tasks/receipts.js +48 -0
  199. package/dist/tasks/state.d.ts +93 -0
  200. package/dist/tasks/state.js +156 -0
  201. package/dist/tasks/store.d.ts +81 -49
  202. package/dist/tasks/store.js +244 -147
  203. package/dist/tools/bash.d.ts +3 -5
  204. package/dist/tools/bash.js +8 -22
  205. package/dist/tools/contract/details.d.ts +6 -6
  206. package/dist/tools/contract/details.js +6 -6
  207. package/dist/tools/contract/execution-trace.d.ts +4 -0
  208. package/dist/tools/contract/execution-trace.js +23 -0
  209. package/dist/tools/contract/presentation.js +6 -2
  210. package/dist/tools/edit.d.ts +1 -0
  211. package/dist/tools/edit.js +45 -42
  212. package/dist/tools/index.d.ts +8 -12
  213. package/dist/tools/index.js +16 -6
  214. package/dist/tools/memory-manage.js +8 -1
  215. package/dist/tools/registry.d.ts +7 -11
  216. package/dist/tools/registry.js +52 -25
  217. package/dist/tools/skill.d.ts +2 -2
  218. package/dist/tools/skill.js +24 -10
  219. package/dist/tools/subagent-manage.js +7 -4
  220. package/dist/tools/subagent.d.ts +0 -2
  221. package/dist/tools/subagent.js +2 -7
  222. package/dist/tools/task-manage/control-tools.d.ts +4 -0
  223. package/dist/tools/task-manage/control-tools.js +65 -0
  224. package/dist/tools/task-manage/create.js +2 -1
  225. package/dist/tools/task-manage/factory.d.ts +12 -6
  226. package/dist/tools/task-manage/factory.js +72 -57
  227. package/dist/tools/task-manage/lifecycle.d.ts +7 -12
  228. package/dist/tools/task-manage/lifecycle.js +118 -66
  229. package/dist/tools/task-manage/log-view.js +8 -5
  230. package/dist/tools/task-manage/schema.d.ts +21 -26
  231. package/dist/tools/task-manage/schema.js +29 -35
  232. package/dist/tools/task-manage/shared.d.ts +8 -39
  233. package/dist/tools/task-manage/shared.js +19 -68
  234. package/dist/tools/task-manage/step-tools.d.ts +5 -0
  235. package/dist/tools/task-manage/step-tools.js +103 -0
  236. package/dist/tools/task-manage/types.d.ts +25 -18
  237. package/dist/tools/write-content.d.ts +1 -0
  238. package/dist/tools/write-content.js +6 -1
  239. package/dist/tools/write.d.ts +1 -0
  240. package/dist/tools/write.js +1 -0
  241. package/dist/usage/ledger.d.ts +4 -4
  242. package/dist/usage/render.js +2 -2
  243. package/dist/web/search-providers.js +0 -33
  244. package/dist/webapi/request-policy.js +1 -1
  245. package/examples/sub-agents/README.md +23 -16
  246. package/examples/sub-agents/agents/claude-high.md +1 -1
  247. package/examples/sub-agents/agents/claude-main.md +1 -1
  248. package/examples/sub-agents/agents/codex-flash.md +1 -1
  249. package/examples/sub-agents/agents/codex-high.md +1 -1
  250. package/examples/sub-agents/agents/codex-main.md +4 -4
  251. package/examples/sub-agents/agents/cursor-high.md +22 -0
  252. package/examples/sub-agents/agents/cursor-main.md +22 -0
  253. package/examples/sub-agents/agents/glm-flash.md +1 -1
  254. package/examples/sub-agents/agents/glm-high.md +2 -2
  255. package/examples/sub-agents/agents/scout.md +30 -0
  256. package/package.json +6 -6
  257. package/dist/runtime/task-driver.d.ts +0 -116
  258. package/dist/runtime/task-driver.js +0 -443
  259. package/dist/runtime/task-wake.d.ts +0 -48
  260. package/dist/runtime/task-wake.js +0 -32
  261. package/dist/shared/wake-claim.d.ts +0 -23
  262. package/dist/shared/wake-claim.js +0 -26
  263. package/dist/skills/validation.d.ts +0 -8
  264. package/dist/skills/validation.js +0 -91
  265. package/dist/skills/workspace.d.ts +0 -33
  266. package/dist/skills/workspace.js +0 -116
  267. package/dist/tasks/steer.d.ts +0 -8
  268. package/dist/tasks/steer.js +0 -81
  269. package/dist/tasks/ticket.d.ts +0 -71
  270. package/dist/tasks/ticket.js +0 -138
  271. package/dist/tools/task-manage/step-end.d.ts +0 -11
  272. package/dist/tools/task-manage/step-end.js +0 -117
package/README.en.md CHANGED
@@ -4,9 +4,7 @@
4
4
 
5
5
  **Turn DingTalk into an AI engineering entry point that keeps working.**
6
6
 
7
- Pipiclaw is an AI coding assistant runtime for individuals and teams. It lets an AI assistant do more than answer a single question: it stays in your DingTalk, understands context, operates your workspace, remembers long-term conventions, keeps tasks moving on a plan, and delegates the heavy lifting to Claude Code, Codex CLI, or your own executor.
8
-
9
- What you see is one assistant, but behind it can be a well-divided AI engineering team: the main agent owns understanding goals and delivering results, lightweight sub-agents handle retrieval and triage, and external agents handle cross-file implementation, independent review, and verification runs. All work has state, artifacts, and control entry points, instead of being scattered across a few terminal windows as throwaway conversations.
7
+ Pipiclaw is a DingTalk-first AI coding assistant runtime for individual developers. Assign a goal from DingTalk or the terminal, keep its working context, and let it progress in the background using your existing models, Claude Code, Codex CLI, or custom executors. Follow progress, add instructions, pause or cancel work, and retrieve the result with its verification evidence.
10
8
 
11
9
  - npm: [`@oyasmi/pipiclaw`](https://www.npmjs.com/package/@oyasmi/pipiclaw)
12
10
  - Runtime: Node.js `>= 22.19.0`, Linux / macOS; on Windows use WSL2
@@ -14,7 +12,7 @@ What you see is one assistant, but behind it can be a well-divided AI engineerin
14
12
 
15
13
  ## Why Pipiclaw
16
14
 
17
- ### One entry point, coordinating multiple agents
15
+ ### Use your existing executors as needed
18
16
 
19
17
  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
18
 
@@ -22,7 +20,7 @@ In DingTalk daemon mode, external tasks keep running in the background after dis
22
20
 
23
21
  ### Work does not end when a conversation ends
24
22
 
25
- Pipiclaw is one personal assistant: by default the terminal, DingTalk DMs and group chats all share long-term memory, a daily journal, tasks, scheduled events and working files (kept in the default desk, `default`), while each keeps its own conversation — just start chatting. Sharing also means that something you tell the assistant in a DM may be recalled in a group; when you want to keep a project or purpose apart, use the advanced [desk mechanism](https://github.com/oyasmi/pipiclaw/blob/main/docs/scaling-and-concurrency.md#按需分开工位): each desk has its own memory, tasks and files. Each task is a one-off project with goals, done criteria, and work items in a Markdown contract, and steps, dispatches, and settlements in a JSONL loop log; the built-in task driver advances runnable tasks, redeems due time tickets, and handles ticket expiry. Scheduled and recurring work uses event templates to create an independent task instance per occurrence. The runtime stops with a notice when a budget, idle-loop, or repeated-expiry boundary is reached.
23
+ Pipiclaw is one personal assistant: by default the terminal, DingTalk DMs and group chats all share long-term memory, a daily journal, tasks, scheduled events and working files (kept in the default desk, `default`), while each keeps its own conversation — just start chatting. Sharing also means that something you tell the assistant in a DM may be recalled in a group; when you want to keep a project or purpose apart, use the advanced [desk mechanism](https://github.com/oyasmi/pipiclaw/blob/main/docs/scaling-and-concurrency.md#按需分开工位): each desk has its own memory, tasks and files. Each task is a one-off project with goals, done criteria, and work items in a Markdown contract, and steps, dispatches, and settlements in a JSONL task log; tasks run in a background task lane, independent of chat, and you can check progress, add instructions, pause or cancel them with `/tasks` at any time. Scheduled and recurring work uses event templates to create an independent task instance per occurrence. The runtime pauses a task with a notice when a budget, idle-loop, step-timeout or repeated-error boundary is reached.
26
24
 
27
25
  ### Natively at home in DingTalk
28
26
 
@@ -36,17 +34,17 @@ Scheduled events are good for reminders, periodic checks, and zero-token conditi
36
34
 
37
35
  ### Your config, data, and way of working
38
36
 
39
- Models support built-in providers, OpenAI-compatible gateways, API keys, and subscription login. Memory, tasks, roles, events, and team rules are all stored in human-readable files on your machine. Pipiclaw provides command, path, and network guards plus an audit log; when you need stronger isolation, you can put the whole process in its own account or container.
37
+ Models support built-in providers, OpenAI-compatible gateways, API keys, and subscription login. Memory, tasks, roles, events, and working rules are all stored in human-readable files on your machine. Pipiclaw provides command, path, and network guards plus an audit log; when you need stronger isolation, you can put the whole process in its own account or container.
40
38
 
41
39
  ## What it's good for
42
40
 
43
41
  - Providing an always-online dev assistant, internal tech support, or ops collaboration entry point in DingTalk
44
- - Handing requirement analysis, implementation, review, verification, and documentation to different AI agents working together
42
+ - Delivering complete changes with code, tests, documentation, and appropriate checks, with independent review based on risk
45
43
  - Following up on coding, investigation, migration, reporting, and periodic work that spans hours or days
46
44
  - Keeping a separate conversation per group and direct chat, sharing one body of memory by default and splitting it with desks when needed
47
- - Reusing existing model gateways, Claude Code / Codex CLI accounts, and team working conventions
45
+ - Reusing existing model gateways, Claude Code / Codex CLI accounts, and personal or project conventions
48
46
 
49
- Pipiclaw today targets individuals and small teams, self-hosted, single-instance. It is not a hard multi-tenant SaaS, and it does not provide an OS-level sandbox; the real permissions an external agent holds are determined together by the target CLI's sandbox parameters, the run account, and the host environment.
47
+ Pipiclaw targets individual developers and supports self-hosted, single-instance operation. It is not a hard multi-tenant SaaS, and it does not provide an OS-level sandbox; the real permissions an external agent holds are determined together by the target CLI's sandbox parameters, the run account, and the host environment.
50
48
 
51
49
  ## Quick start
52
50
 
@@ -126,7 +124,7 @@ Edit `~/.pipiclaw/channel.json`:
126
124
  }
127
125
  ```
128
126
 
129
- - The `dingtalk` and `webapi` sections each have an `enabled` switch; turn on at least one. `webapi` lets scripts and other services use Pipiclaw through the official OpenAI SDK (see [Web API](https://github.com/oyasmi/pipiclaw/blob/main/docs/webapi.md)).
127
+ - The `dingtalk` and `webapi` sections each have an `enabled` switch; turn on at least one. `webapi` lets scripts and other clients connect to your assistant through the official OpenAI SDK using the implemented Responses subset (see [Web API](https://github.com/oyasmi/pipiclaw/blob/main/docs/webapi.md)).
130
128
  - The only hard-required DingTalk fields are `clientId` and `clientSecret`.
131
129
  - When `robotCode` is empty it falls back to `clientId`.
132
130
  - `cardTemplateId` can be left empty for now; configuring an AI Card is recommended for real use.
@@ -186,7 +184,7 @@ Long-running external delegations should run in the long-lived daemon; without o
186
184
 
187
185
  ### 5. Optional: enable web tools
188
186
 
189
- `web_search` / `web_fetch` are off by default. Edit `~/.pipiclaw/tools.json`, set `tools.web.enable: true`, and configure a search provider. DuckDuckGo, Brave, Tavily, Jina, and SearXNG are supported; see [Configuration reference](https://github.com/oyasmi/pipiclaw/blob/main/docs/configuration.md) for the full fields.
187
+ `web_search` / `web_fetch` are off by default. Edit `~/.pipiclaw/tools.json`, set `tools.web.enable: true`, and configure a search provider. DuckDuckGo, Tavily, Jina, and SearXNG are supported; DuckDuckGo is the default. See [Configuration reference](https://github.com/oyasmi/pipiclaw/blob/main/docs/configuration.md) for the full fields.
190
188
 
191
189
  <details>
192
190
  <summary>Let your favorite AI agent install it for you</summary>
package/README.md CHANGED
@@ -4,9 +4,7 @@
4
4
 
5
5
  **把钉钉变成一个能持续工作的 AI 工程入口。**
6
6
 
7
- Pipiclaw 是一个面向个人和团队的 AI coding assistant runtime。它让 AI 助手不只回答一轮问题,而是能留在你的钉钉里理解上下文、操作工作区、记住长期约定、按计划继续任务,还能把重活委派给 Claude Code、Codex CLI 或你自己的执行器。
8
-
9
- 你看到的是一个助手,背后可以是一支分工明确的 AI 工程团队:主智能体负责理解目标和交付结果,轻量子智能体负责检索与整理,外部智能体负责跨文件实现、独立评审和运行验收。所有工作都有状态、有产物、有控制入口,而不是散落在几个终端窗口里的临时对话。
7
+ Pipiclaw 是面向个人开发者、以钉钉为主要入口的 AI 编程助手运行时。你可以在钉钉或终端交办目标,让它保留工作上下文、在后台持续推进,并按需要调用你已有的模型、Claude Code、Codex CLI 或自定义执行器;过程中可查看进展、补充要求、暂停或取消,最终取得成果和检查依据。
10
8
 
11
9
  - npm:[`@oyasmi/pipiclaw`](https://www.npmjs.com/package/@oyasmi/pipiclaw)
12
10
  - 运行环境:Node.js `>= 22.19.0`,Linux / macOS;Windows 请使用 WSL2
@@ -14,7 +12,7 @@ Pipiclaw 是一个面向个人和团队的 AI coding assistant runtime。它让
14
12
 
15
13
  ## 为什么用 Pipiclaw
16
14
 
17
- ### 一个入口,协调多个智能体
15
+ ### 按需使用已有执行器
18
16
 
19
17
  Pipiclaw 同时支持两类委派:内置子智能体在进程内完成检索、日志筛查等轻量工作;外部智能体则启动真实的 Claude Code、Codex CLI 或任意脚本,处理需要长时间运行、跨多个文件和反复自测的重型任务。
20
18
 
@@ -22,7 +20,7 @@ Pipiclaw 同时支持两类委派:内置子智能体在进程内完成检索
22
20
 
23
21
  ### 工作不会随着一次对话结束
24
22
 
25
- Pipiclaw 是你的同一个个人助手:终端、钉钉私聊和多个群聊默认共享长期记忆、按天日志、任务、定时事件和工作文件(都记在默认工位 `default` 里),各自保留独立对话,直接聊天即可。共享也意味着私聊里告诉助手的事,可能在群里被想起;需要把项目或用途分开时,再使用进阶的 [工位机制](https://github.com/oyasmi/pipiclaw/blob/main/docs/scaling-and-concurrency.md#按需分开工位):每个工位有独立的记忆、任务和文件。任务是一次性项目,用 Markdown 保存目标、完成标准和工作项,用 JSONL 循环日志记录步骤、派发与结算;内建 task driver 推进可运行任务、兑现到期等待票并处理兜底超时,周期与定时工作由事件模板每次生成独立任务实例,预算耗尽、空转或连续无法兑现等待时会停止并告诉你。
23
+ Pipiclaw 是你的同一个个人助手:终端、钉钉私聊和多个群聊默认共享长期记忆、按天日志、任务、定时事件和工作文件(都记在默认工位 `default` 里),各自保留独立对话,直接聊天即可。共享也意味着私聊里告诉助手的事,可能在群里被想起;需要把项目或用途分开时,再使用进阶的 [工位机制](https://github.com/oyasmi/pipiclaw/blob/main/docs/scaling-and-concurrency.md#按需分开工位):每个工位有独立的记忆、任务和文件。任务是一次性项目,用 Markdown 保存目标、完成标准和工作项,用 JSONL 任务记录步骤、派发与结算;任务在后台的任务车道里独立执行,不占用聊天,你可以随时用 `/tasks` 查看进度、补充指示、暂停或取消,周期与定时工作由事件模板每次生成独立任务实例,预算耗尽、空转、单步超时或连续出错时会停止并告诉你。
26
24
 
27
25
  ### 原生工作在钉钉里
28
26
 
@@ -36,17 +34,17 @@ Pipiclaw 使用钉钉 Stream Mode,不需要自建消息中转服务或公网 I
36
34
 
37
35
  ### 配置、数据和工作方式归你所有
38
36
 
39
- 模型支持内置 provider、OpenAI-compatible 网关、API key 和订阅登录。记忆、任务、角色、事件与团队规则都保存在本机可阅读文件中。Pipiclaw 提供命令、路径和网络守卫以及审计记录;需要更强隔离时,可把整个进程放进独立账号或容器。
37
+ 模型支持内置 provider、OpenAI-compatible 网关、API key 和订阅登录。记忆、任务、角色、事件与工作规则都保存在本机可阅读文件中。Pipiclaw 提供命令、路径和网络守卫以及审计记录;需要更强隔离时,可把整个进程放进独立账号或容器。
40
38
 
41
39
  ## 适合做什么
42
40
 
43
41
  - 在钉钉中提供长期在线的研发助手、内部技术支持或运维协作入口
44
- - 把需求分析、实现、评审、验证、文档整理交给不同 AI 智能体协作完成
42
+ - 交付包含实现、测试、文档和必要检查的完整改动,按风险安排独立检查
45
43
  - 跟进跨小时或跨天的编码、调查、迁移、报告和周期性工作
46
44
  - 在多个群和私聊中保留各自独立的对话;默认共享同一份积累,需要分开时再用工位
47
- - 复用现有模型网关、Claude Code / Codex CLI 账号和团队工作规范
45
+ - 复用现有模型网关、Claude Code / Codex CLI 账号和个人或项目工作规范
48
46
 
49
- Pipiclaw 当前定位是个人与小团队、自托管、单实例运行。它不是强多租户 SaaS,也不提供 OS 级沙箱;外部智能体拥有的真实权限由目标 CLI 的 sandbox 参数、运行账号和宿主环境共同决定。
47
+ Pipiclaw 面向个人开发者,支持自托管和单实例运行。它不是强多租户 SaaS,也不提供 OS 级沙箱;外部智能体拥有的真实权限由目标 CLI 的 sandbox 参数、运行账号和宿主环境共同决定。
50
48
 
51
49
  ## 快速开始
52
50
 
@@ -126,7 +124,7 @@ pipiclaw tui --print "只回复:Pipiclaw 模型调用成功"
126
124
  }
127
125
  ```
128
126
 
129
- - `dingtalk` 和 `webapi` 两段各有 `enabled` 开关,至少打开一个;`webapi` 让脚本和其他服务用官方 OpenAI SDK 使用 Pipiclaw(见 [Web API](https://github.com/oyasmi/pipiclaw/blob/main/docs/webapi.md))。
127
+ - `dingtalk` 和 `webapi` 两段各有 `enabled` 开关,至少打开一个;`webapi` 让脚本和其他客户端通过官方 OpenAI SDK 连接自己的助手(支持已实现的 Responses 子集)(见 [Web API](https://github.com/oyasmi/pipiclaw/blob/main/docs/webapi.md))。
130
128
  - 硬性必填只有 `clientId` 和 `clientSecret`。
131
129
  - `robotCode` 留空时回退到 `clientId`。
132
130
  - `cardTemplateId` 可暂时留空;正式使用建议配置 AI Card。
@@ -186,7 +184,7 @@ cp "$PIPICLAW_PACKAGE_DIR"/examples/sub-agents/agents/{claude-main,codex-main}.m
186
184
 
187
185
  ### 5. 可选:启用 Web 工具
188
186
 
189
- `web_search` / `web_fetch` 默认关闭。编辑 `~/.pipiclaw/tools.json`,设置 `tools.web.enable: true` 并配置搜索 provider。支持 DuckDuckGo、Brave、Tavily、Jina 和 SearXNG;完整字段见[配置速查](https://github.com/oyasmi/pipiclaw/blob/main/docs/configuration.md)。
187
+ `web_search` / `web_fetch` 默认关闭。编辑 `~/.pipiclaw/tools.json`,设置 `tools.web.enable: true` 并配置搜索 provider。支持 DuckDuckGo、Tavily、Jina 和 SearXNG,默认使用 DuckDuckGo;完整字段见[配置速查](https://github.com/oyasmi/pipiclaw/blob/main/docs/configuration.md)。
190
188
 
191
189
  <details>
192
190
  <summary>让你常用的 AI Agent 帮忙安装</summary>
@@ -6,9 +6,8 @@ import { type RunnerBuiltInCommand } from "../commands/catalog.js";
6
6
  import type { DeskConversation } from "../desk/types.js";
7
7
  import type { MemoryMaintenanceRuntimeContext } from "../memory/scheduler.js";
8
8
  import type { SubAgentDiscoveryResult } from "../subagents/discovery.js";
9
- import type { UsageTotals } from "../usage/totals.js";
10
9
  import type { RunnerDeps, RunnerFactoryPaths } from "./types.js";
11
- import { type AgentRunner, type RunnerStatusSnapshot, type TurnStatus } from "./types.js";
10
+ import { type AgentRunner, type RunnerActivity, type RunnerStatusSnapshot, type TurnStatus } from "./types.js";
12
11
  export declare class ChannelRunner implements AgentRunner {
13
12
  private readonly executor;
14
13
  private readonly jobManager;
@@ -31,7 +30,7 @@ export declare class ChannelRunner implements AgentRunner {
31
30
  private readonly turnFinisher;
32
31
  private readonly pipeline;
33
32
  private readonly memoryLifecycle;
34
- private readonly requestScoped;
33
+ private readonly profile;
35
34
  private readonly ledger;
36
35
  private readonly memoryActivityRecorder;
37
36
  private readonly models;
@@ -50,14 +49,7 @@ export declare class ChannelRunner implements AgentRunner {
50
49
  isBusy(): boolean;
51
50
  requestStop(): void;
52
51
  getTurnStatus(): TurnStatus;
53
- run(info: TurnInfo, channel: ChannelContext, store: ChannelStore): Promise<{
54
- stopReason: string;
55
- errorMessage?: string;
56
- usage: UsageTotals;
57
- costKnown: boolean;
58
- durationMs: number;
59
- silent: boolean;
60
- }>;
52
+ run(info: TurnInfo, channel: ChannelContext, store: ChannelStore): ReturnType<AgentRunner["run"]>;
61
53
  handleBuiltinCommand(command: RunnerBuiltInCommand): Promise<string>;
62
54
  /**
63
55
  * True if `text` is a slash command the runtime or session layer can handle:
@@ -67,7 +59,10 @@ export declare class ChannelRunner implements AgentRunner {
67
59
  * full LLM turn.
68
60
  */
69
61
  isKnownSlashCommand(text: string): boolean;
70
- queueSteer(text: string, userName?: string, images?: InboundImage[]): Promise<void>;
62
+ private taskQueueSeq?;
63
+ get generation(): string;
64
+ queueSteer(text: string, userName?: string, images?: InboundImage[], scope?: import("./types.js").TaskSteerScope): Promise<"queued" | "stale">;
65
+ clearTaskStepQueue(seq: number): void;
71
66
  flushMemoryForShutdown(): Promise<void>;
72
67
  dispose(): Promise<void>;
73
68
  getMemoryMaintenanceContext(): Promise<MemoryMaintenanceRuntimeContext>;
@@ -85,18 +80,11 @@ export declare class ChannelRunner implements AgentRunner {
85
80
  renderContextReport(args?: string): string;
86
81
  /** `/subagents list`'s role-directory health tail — whatever this runner already discovered. */
87
82
  getSubAgentDiscoverySnapshot(): SubAgentDiscoveryResult;
88
- /**
89
- * Bind this runner to a task cycle's own session (spec 051, D3/INV-5): task work must not
90
- * accumulate in the channel's chat transcript, so each task turn runs in its own bounded session
91
- * while turn state, `/stop` and delivery stay exactly where they already are.
92
- */
93
- bindTaskSession(taskId: string): Promise<void>;
94
- /** Return to the channel's chat session after a task step. Safe to call when already bound. */
95
- bindChatSession(): Promise<void>;
96
- /** Which task loop this runner is currently bound to, if any. */
97
- getTaskLoop(): {
98
- taskId: string;
99
- } | undefined;
83
+ getActivity(): RunnerActivity;
84
+ contextIncludes(needle: string): Promise<boolean>;
85
+ /** The session file this profile opens: the channel's active chat session, a task's own, or none (a request lives in memory). */
86
+ private openSessionFile;
87
+ private openSessionManager;
100
88
  /**
101
89
  * Buffer one activity event. The write itself is batched by the recorder (see
102
90
  * `createMemoryActivityRecorder`); `run()` flushes at the end of every turn, which is the
@@ -4,8 +4,9 @@
4
4
  * `turn/`. Owns the turn state machine.
5
5
  */
6
6
  import { SessionManager } from "@earendil-works/pi-coding-agent";
7
+ import { mkdirSync } from "fs";
7
8
  import { mkdir } from "fs/promises";
8
- import { join } from "path";
9
+ import { dirname, join } from "path";
9
10
  import { resolveActiveSessionFile } from "../channel/active-session-store.js";
10
11
  import { isKnownCommandName, slashCommandName } from "../commands/catalog.js";
11
12
  import * as log from "../log.js";
@@ -42,7 +43,7 @@ export class ChannelRunner {
42
43
  this.retired = false;
43
44
  // --- Per run ---
44
45
  this.runState = createEmptyRunState();
45
- this.requestScoped = paths.requestScoped === true;
46
+ this.profile = paths.profile ?? { kind: "chat" };
46
47
  const { channelId, conversationDir } = conversation;
47
48
  this.conversation = conversation;
48
49
  this.channelId = channelId;
@@ -59,15 +60,17 @@ export class ChannelRunner {
59
60
  this.loadSecurityConfig = deps.loadSecurityConfig;
60
61
  this.workspaceDir = paths.workspaceDir;
61
62
  // Initial skill summaries
62
- const initialSkills = loadPipiclawSkills(this.workspaceDir);
63
+ const initialSkills = loadPipiclawSkills({
64
+ workspaceDir: this.workspaceDir,
65
+ securityConfig: this.loadSecurityConfig().config,
66
+ securityContext: { agentWorkspaceDir: this.workspaceDir, cwd: conversation.cwd },
67
+ });
63
68
  // Create session manager, opening whichever session this conversation's active-session ref
64
69
  // (or the context.jsonl default, for a conversation that has never run a topology op) names
65
70
  // (spec 043, D1). The cwd override is the desk's working directory: `desk.json` can change
66
71
  // its `cwd` after a session was created, so the header's cwd may be stale.
67
- const activeSessionFile = this.requestScoped ? "context.jsonl" : resolveActiveSessionFile(conversationDir);
68
- const sessionManager = this.requestScoped
69
- ? SessionManager.inMemory(conversation.cwd)
70
- : SessionManager.open(join(conversationDir, activeSessionFile), conversationDir, conversation.cwd);
72
+ const sessionFile = this.openSessionFile();
73
+ const sessionManager = this.openSessionManager(sessionFile);
71
74
  // Per-runner recovery barrier (spec 043, D10 point 2): repairs must run against this exact
72
75
  // SessionManager instance, before anything else touches it — a second `open()` of the same
73
76
  // file would mutate a branch this instance never sees, silently desyncing the two. The
@@ -81,7 +84,7 @@ export class ChannelRunner {
81
84
  });
82
85
  if (recoveryOutcome.kind === "blocked") {
83
86
  throw new Error(`[${channelId}] Cannot start channel: session left in an unrecoverable state after a restart (${recoveryOutcome.reason}). ` +
84
- `Back up ${join(conversationDir, activeSessionFile)} on the host, move it aside, then use /new to start a fresh session.`);
87
+ `Back up ${sessionFile} on the host, move it aside, then use /new to start a fresh session.`);
85
88
  }
86
89
  if (recoveryOutcome.kind === "repaired") {
87
90
  log.logWarn("agent.turn.repaired", "Interrupted turn repaired on restart", {
@@ -109,7 +112,7 @@ export class ChannelRunner {
109
112
  getModelRegistry: () => this.host.modelRegistry,
110
113
  });
111
114
  this.memoryLifecycle = new MemoryLifecycle({
112
- enabled: !this.requestScoped,
115
+ enabled: this.profile.kind === "chat",
113
116
  conversation,
114
117
  workspaceDir: this.workspaceDir,
115
118
  appHomeDir: this.appHomeDir,
@@ -120,7 +123,8 @@ export class ChannelRunner {
120
123
  recordMemoryActivity: (event) => this.recordMemoryActivity(event),
121
124
  });
122
125
  this.host = new SessionHost({
123
- requestScoped: this.requestScoped,
126
+ profile: this.profile,
127
+ getTaskControl: paths.getTaskControl,
124
128
  conversation,
125
129
  workspaceDir: this.workspaceDir,
126
130
  appHomeDir: this.appHomeDir,
@@ -145,6 +149,7 @@ export class ChannelRunner {
145
149
  markStreaming: () => this.turnState.markStreaming(),
146
150
  });
147
151
  this.pipeline = new TurnPipeline({
152
+ profile: this.profile,
148
153
  conversation,
149
154
  workspaceDir: this.workspaceDir,
150
155
  describeChannel: paths.describeChannel,
@@ -155,7 +160,7 @@ export class ChannelRunner {
155
160
  getRunState: () => this.runState,
156
161
  });
157
162
  this.turnFinisher = new TurnFinisher({
158
- requestScoped: this.requestScoped,
163
+ profile: this.profile,
159
164
  conversation,
160
165
  host: this.host,
161
166
  models: this.models,
@@ -230,7 +235,7 @@ export class ChannelRunner {
230
235
  ? { clippedInput: info.text, userMessage: info.text, preserveRawInput: true }
231
236
  : await this.pipeline.prepareUserInput(info, ctx);
232
237
  // Ensure the conversation directory (and with it the desk directory) exists.
233
- if (!this.requestScoped)
238
+ if (this.profile.kind === "chat")
234
239
  await mkdir(this.conversationDir, { recursive: true });
235
240
  const channelCapsule = await this.pipeline.gatherTurnContext(input.preserveRawInput, turn);
236
241
  const assembled = assembleTurnPrompt({
@@ -286,6 +291,13 @@ export class ChannelRunner {
286
291
  costKnown: this.runState.usageSources > 0 && this.runState.costKnown,
287
292
  durationMs: Date.now() - startedAt,
288
293
  silent: this.runState.finalOutcome.kind === "silent",
294
+ finalText: this.runState.lastAssistantText,
295
+ toolsUsed: [...this.runState.toolsUsed],
296
+ assistantCost: {
297
+ usd: this.runState.assistantUsage.cost.total,
298
+ estimated: false,
299
+ known: this.runState.assistantUsageSources > 0 && this.runState.assistantCostKnown,
300
+ },
289
301
  };
290
302
  }
291
303
  async handleBuiltinCommand(command) {
@@ -320,8 +332,28 @@ export class ChannelRunner {
320
332
  }
321
333
  return this.session.promptTemplates.some((template) => template.name.toLowerCase() === name);
322
334
  }
323
- async queueSteer(text, userName, images) {
324
- await this.pipeline.queueBusyMessage(requireQueuedMessage(text, "steer"), userName, images);
335
+ get generation() {
336
+ return this.host.trace.generation;
337
+ }
338
+ async queueSteer(text, userName, images, scope) {
339
+ const result = await this.pipeline.queueBusyMessage(requireQueuedMessage(text, "steer"), userName, images, scope);
340
+ if (scope && result === "queued")
341
+ this.taskQueueSeq = scope.seq;
342
+ return result;
343
+ }
344
+ clearTaskStepQueue(seq) {
345
+ if (this.retired || this.profile.kind !== "task" || !this.host.sessionInitialized)
346
+ return;
347
+ try {
348
+ if (this.profile.session.seq() !== seq)
349
+ return;
350
+ }
351
+ catch {
352
+ // A stopped step still owns this runner until the lane finishes its teardown.
353
+ if (this.taskQueueSeq !== seq)
354
+ return;
355
+ }
356
+ this.session.clearQueue();
325
357
  }
326
358
  async flushMemoryForShutdown() {
327
359
  this.host.compaction.cancel("shutdown");
@@ -384,9 +416,9 @@ export class ChannelRunner {
384
416
  return true;
385
417
  }
386
418
  retireForNewSession() {
387
- if (!this.retired && this.session)
388
- this.memoryLifecycle.noteNewSessionBoundary();
389
419
  this.retireForRecovery();
420
+ if (this.host.sessionInitialized)
421
+ void this.memoryLifecycle.resumeBoundaryReflect();
390
422
  }
391
423
  retireForRecovery() {
392
424
  if (this.retired)
@@ -421,21 +453,33 @@ export class ChannelRunner {
421
453
  getSubAgentDiscoverySnapshot() {
422
454
  return this.host.subAgentDiscovery;
423
455
  }
424
- /**
425
- * Bind this runner to a task cycle's own session (spec 051, D3/INV-5): task work must not
426
- * accumulate in the channel's chat transcript, so each task turn runs in its own bounded session
427
- * while turn state, `/stop` and delivery stay exactly where they already are.
428
- */
429
- bindTaskSession(taskId) {
430
- return this.retired ? Promise.resolve() : this.host.bindTaskSession(taskId);
456
+ getActivity() {
457
+ return { pendingTools: [...this.runState.pendingTools.values()], toolsDone: this.runState.toolsUsed.length };
431
458
  }
432
- /** Return to the channel's chat session after a task step. Safe to call when already bound. */
433
- bindChatSession() {
434
- return this.retired ? Promise.resolve() : this.host.bindChatSession();
459
+ async contextIncludes(needle) {
460
+ await this.host.ensureSessionReady();
461
+ return this.host.contextIncludes((text) => text.includes(needle));
462
+ }
463
+ /** The session file this profile opens: the channel's active chat session, a task's own, or none (a request lives in memory). */
464
+ openSessionFile() {
465
+ switch (this.profile.kind) {
466
+ case "chat":
467
+ return join(this.conversationDir, resolveActiveSessionFile(this.conversationDir));
468
+ case "task":
469
+ return this.profile.sessionPath;
470
+ case "request":
471
+ return "context.jsonl";
472
+ }
435
473
  }
436
- /** Which task loop this runner is currently bound to, if any. */
437
- getTaskLoop() {
438
- return this.host.taskLoop;
474
+ openSessionManager(sessionFile) {
475
+ const { cwd } = this.conversation;
476
+ if (this.profile.kind === "request")
477
+ return SessionManager.inMemory(cwd);
478
+ // The cwd override is the desk's working directory: `desk.json` can change its `cwd` after a
479
+ // session was created, so the header's cwd may be stale (spec 043, D1).
480
+ if (this.profile.kind === "task")
481
+ mkdirSync(dirname(sessionFile), { recursive: true });
482
+ return SessionManager.open(sessionFile, this.profile.kind === "task" ? dirname(sessionFile) : this.conversationDir, cwd);
439
483
  }
440
484
  // === Private helpers ===
441
485
  /**
@@ -444,7 +488,7 @@ export class ChannelRunner {
444
488
  * point the maintenance gates actually start looking at this state.
445
489
  */
446
490
  recordMemoryActivity(event) {
447
- if (this.requestScoped)
491
+ if (this.profile.kind !== "chat")
448
492
  return;
449
493
  const eventTime = parseLocalTime(event.timestamp);
450
494
  const eligibleAfter = eventTime !== undefined
@@ -1,6 +1,8 @@
1
1
  import type { PipiclawSettingsManager } from "../config/settings.js";
2
2
  import type { DeskConversation } from "../desk/types.js";
3
3
  import type { MemoryMaintenanceRuntimeContext } from "../memory/scheduler.js";
4
+ /** /new's local persistence path: no runner, credentials, inference, or memory queue. */
5
+ export declare function preserveMemoryBeforeNewSession(conversation: DeskConversation): Promise<void>;
4
6
  export interface DetachedMaintenanceContextOptions {
5
7
  conversation: DeskConversation;
6
8
  workspaceDir: string;
@@ -2,8 +2,23 @@ import { statSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { SessionManager } from "@earendil-works/pi-coding-agent";
4
4
  import { peekActiveSessionFile } from "../channel/active-session-store.js";
5
+ import { enqueueBoundaryReflectEntries } from "../memory/boundary-work.js";
5
6
  import { getApiKeyForModel } from "../models/api-keys.js";
6
7
  import { createModelRuntime, resolveInitialModel, wrapModelRegistry } from "../models/runtime.js";
8
+ /** /new's local persistence path: no runner, credentials, inference, or memory queue. */
9
+ export async function preserveMemoryBeforeNewSession(conversation) {
10
+ const file = join(conversation.conversationDir, peekActiveSessionFile(conversation.conversationDir));
11
+ try {
12
+ statSync(file);
13
+ }
14
+ catch (error) {
15
+ if (error.code === "ENOENT")
16
+ return;
17
+ throw error;
18
+ }
19
+ const session = SessionManager.open(file, conversation.conversationDir, conversation.cwd);
20
+ await enqueueBoundaryReflectEntries(conversation, session.getBranch());
21
+ }
7
22
  // The maintenance scheduler visits idle conversations every tick; re-parsing an
8
23
  // unchanged session file each time would be pure I/O waste for long-dead
9
24
  // conversations. Keyed by session file, replaced whenever the file changes.
@@ -20,6 +20,7 @@
20
20
  * definitions and the runtime guides.
21
21
  */
22
22
  import { renderPlaybookCatalog } from "../../playbooks/catalog.js";
23
+ import { CHAT_SYNC_GRACE_MS } from "../../subagents/grace.js";
23
24
  function hasTool(context, name) {
24
25
  return context.tools.some((tool) => tool.name === name);
25
26
  }
@@ -57,7 +58,7 @@ export const EXECUTION_SECTION = {
57
58
  "## Working Contract",
58
59
  "- For actionable requests, continue until the requested outcome exists or you are genuinely blocked. Inspect before changing and verify material results.",
59
60
  "- State what remains unverified. Tool definitions are the source of truth for available capabilities and parameters.",
60
- "- Jobs and delegations you start wake this channel on completion. Finish independent work and dispatches; when only waiting remains, end the turn without polling or check-in events.",
61
+ "- Jobs and delegations you start wake whoever started them — this chat, or the task whose step started them. Finish independent work and dispatches; when only waiting remains, end the turn without polling or check-in events.",
61
62
  "- Before non-trivial use of a runtime mechanism or workspace procedure, read its guide or skill; reuse it while it remains in context.",
62
63
  ].join("\n"),
63
64
  };
@@ -86,12 +87,12 @@ export const TASK_CORE_SECTION = {
86
87
  source: "runtime/tasks",
87
88
  authority: "runtime-hard",
88
89
  cacheClass: "runtime-stable",
89
- requiresAllTools: ["task_create", "task_update", "task_close"],
90
+ requiresAllTools: ["task_create", "task_close"],
90
91
  maxChars: 600,
91
92
  overflow: "error",
92
93
  render: () => [
93
94
  "## Persistent Work",
94
- "Use a task when work must survive this turn, has several pieces to delegate, or needs to wait on results; you lead it — split, delegate, check, report. Recurring or scheduled work is an event with a task template. Chat creates or manages tasks; the runtime drives them in task sessions. Follow the task's contract and runtime guide without expanding its scope.",
95
+ "Use a task when work must survive this turn, has several pieces to delegate, or needs to wait on results; you lead it — split, delegate, check, report. Recurring or scheduled work is an event with a task template. Chat creates and manages tasks; the runtime runs each in the background in its own session, in parallel with this chat. Follow the task's contract and runtime guide without expanding its scope.",
95
96
  ].join("\n"),
96
97
  };
97
98
  export const PLAYBOOKS_SECTION = {
@@ -169,9 +170,10 @@ function renderSubAgentDirectory(subAgents) {
169
170
  "A sub-agent starts blank: state the goal, scope, paths, constraints and acceptance criteria in the task you hand it.",
170
171
  ];
171
172
  for (const group of sortedGroups) {
172
- // internal is always sync up to SYNC_GRACE_MS, then converts to async by itself (D2) — the
173
- // model does not choose this, it is just told what to expect.
174
- const mode = group.runtime === "external" ? "async" : "sync (auto-async past 120s)";
173
+ // The runtime chooses delivery; the model is told the same production policy.
174
+ const mode = group.runtime === "external"
175
+ ? "async"
176
+ : `chat: shared ${CHAT_SYNC_GRACE_MS / 1000}s quick return, then async; task: async`;
175
177
  lines.push("", `${group.runtime} · ${group.workload} · ${group.mutates} · ${mode}`);
176
178
  for (const agent of group.agents) {
177
179
  const suffix = agent.unavailable ? ` (unavailable: ${agent.unavailable})` : "";
@@ -41,7 +41,7 @@ export interface SubAgentSummary {
41
41
  description: string;
42
42
  /** Defaults to "internal"; drives the D11 directory grouping (runtime · workload · mutates). */
43
43
  runtime: "internal" | "external";
44
- harness?: "claude-code" | "codex-cli" | "exec";
44
+ harness?: "claude-code" | "codex-cli" | "cursor-cli" | "exec";
45
45
  /** Always resolved (D11 default: external→heavy, internal→light) — never undefined here. */
46
46
  workload: "light" | "heavy";
47
47
  /** Resolved for internal (inferred from tools) and required for external; undefined only for a malformed record. */
@@ -11,7 +11,7 @@ import { ChannelRunner } from "./channel-runner.js";
11
11
  export function createRunner(conversation, paths) {
12
12
  return new ChannelRunner(conversation, paths, {
13
13
  executor: createExecutor(),
14
- fileStore: createFileStore(),
14
+ fileStore: paths.fileStore ?? createFileStore(),
15
15
  loadSecurityConfig: () => loadSecurityConfigWithDiagnostics(paths.appHomeDir),
16
16
  });
17
17
  }
@@ -165,6 +165,17 @@ ${available}`);
165
165
  }
166
166
  },
167
167
  });
168
+ pi.registerCommand("reload", {
169
+ description: sessionCommandDescription("reload"),
170
+ handler: async (args) => {
171
+ if (args.trim()) {
172
+ sendCommandResult(pi, "参数无效。请发送 `/reload`,无需附加参数。");
173
+ return;
174
+ }
175
+ await options.refreshSessionResources();
176
+ sendCommandResult(pi, "已请求重新加载会话资源,下一条消息起生效。");
177
+ },
178
+ });
168
179
  pi.registerCommand("compact", {
169
180
  description: sessionCommandDescription("compact"),
170
181
  handler: async (args, ctx) => {
@@ -9,7 +9,7 @@ import { addUsage, createEmptyUsageTotals } from "../../usage/totals.js";
9
9
  import { reduceSummaryPayloads, splitSummaryInput } from "./compaction-input.js";
10
10
  export const COMPACTION_TIMEOUT_MS = 60_000;
11
11
  export const COMPACTION_IDLE_TIMEOUT_MS = 20_000;
12
- const SUMMARY_RESERVE_TOKENS = 5_120; // SDK's 0.8 multiplier gives a 4096-token output cap.
12
+ const SUMMARY_RESERVE_TOKENS = 5_120; // Input headroom; the summary stream caps output separately.
13
13
  const SUMMARY_INSTRUCTIONS = `Write a concise working checkpoint, aiming for 1500-2500 tokens.
14
14
  Preserve the current goal, user constraints and prohibitions, verified results versus assumptions,
15
15
  unresolved errors, exact paths/identifiers and the next concrete actions. Remove superseded and
@@ -68,7 +68,11 @@ export class CompactionSummary {
68
68
  const chunks = splitSummaryInput(reduceSummaryPayloads([...event.preparation.messagesToSummarize, ...event.preparation.turnPrefixMessages], event.branchEntries, session.sessionManager.getSessionFile()), model.contextWindow - Math.max(previousTokens, SUMMARY_RESERVE_TOKENS * 2), reserveTokens);
69
69
  const stream = async (target, context, options) => {
70
70
  signal.throwIfAborted();
71
- const response = await session.agent.streamFunction(target, context, options);
71
+ // Preserve our 4096-token ceiling (lower for small models); Pi 1.4 ignores reserveTokens here.
72
+ const response = await session.agent.streamFunction(target, context, {
73
+ ...options,
74
+ maxTokens: Math.min(Math.floor(reserveTokens * 0.8), target.maxTokens > 0 ? target.maxTokens : Number.POSITIVE_INFINITY, options?.maxTokens ?? Number.POSITIVE_INFINITY),
75
+ });
72
76
  // The SDK awaits result(); consuming deltas here does not change the result promise.
73
77
  void (async () => {
74
78
  for await (const item of response) {
@@ -0,0 +1,14 @@
1
+ import type { RunnerProfile } from "../types.js";
2
+ /** Request, batch and runner identifiers shared by provider and tool execution logs. */
3
+ export declare class SessionExecutionTrace {
4
+ private readonly profile;
5
+ private readonly context;
6
+ readonly generation: `${string}-${string}-${string}-${string}-${string}`;
7
+ private request;
8
+ private startedAt;
9
+ private firstOutput;
10
+ constructor(profile: RunnerProfile, context: () => Record<string, unknown>);
11
+ fields(): Record<string, unknown>;
12
+ startRequest(): void;
13
+ observe(event: unknown): void;
14
+ }