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

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 +4 -1
  44. package/dist/dingtalk/delivery.js +104 -191
  45. package/dist/dingtalk/progress.d.ts +41 -6
  46. package/dist/dingtalk/progress.js +173 -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
@@ -0,0 +1,23 @@
1
+ import * as log from "../../log.js";
2
+ /** Trace actual adapter entry separately from the SDK's preparation events, without tool data. */
3
+ export function withExecutionTrace(tool, context) {
4
+ return {
5
+ ...tool,
6
+ execute: async (...args) => {
7
+ const startedAt = Date.now();
8
+ const fields = { ...context(), toolCallId: args[0], tool: tool.name };
9
+ log.logEvent("debug", "agent.tool.execute_started", "Tool execution started", { fields });
10
+ let failed = true;
11
+ try {
12
+ const result = await tool.execute(...args);
13
+ failed = result.isError === true;
14
+ return result;
15
+ }
16
+ finally {
17
+ log.logEvent("debug", "agent.tool.execute_finished", "Tool execution finished", {
18
+ fields: { ...fields, elapsedMs: Date.now() - startedAt, failed },
19
+ });
20
+ }
21
+ },
22
+ };
23
+ }
@@ -79,10 +79,14 @@ const DESCRIBERS = {
79
79
  event_manage: (args) => `事件 ${str(args, "action") ?? "?"} ${str(args, "name") ?? ""}`.trim(),
80
80
  task_list: () => "列出任务",
81
81
  task_create: (args) => `创建任务 ${str(args, "id") ?? "?"}`,
82
- task_update: (args) => `更新任务 ${str(args, "id") ?? "?"}`,
83
82
  task_close: (args) => `关闭任务 ${str(args, "id") ?? "?"}(${str(args, "outcome") ?? "?"})`,
84
83
  task_log: (args) => `读取任务日志 ${str(args, "id") ?? "?"}`,
85
- task_step_end: (args) => `结束任务步骤(${str(args, "outcome") ?? "?"})`,
84
+ task_message: (args) => `转达给任务 ${str(args, "id") ?? "?"}`,
85
+ task_pause: (args) => `暂停任务 ${str(args, "id") ?? "?"}`,
86
+ task_resume: (args) => `恢复任务 ${str(args, "id") ?? "?"}`,
87
+ task_report: () => "向用户汇报",
88
+ task_ask: () => "向用户提问",
89
+ task_wait: (args) => `约定等到 ${str(args, "until") ?? "?"}`,
86
90
  subagent: (args) => {
87
91
  const who = str(args, "agent") ?? "?";
88
92
  const task = str(args, "task");
@@ -9,6 +9,7 @@ declare const editSchema: Type.TObject<{
9
9
  replaceAll: Type.TOptional<Type.TBoolean>;
10
10
  }>;
11
11
  export interface EditToolOptions {
12
+ deskDir?: string;
12
13
  securityConfig?: SecurityConfig;
13
14
  securityContext?: SecurityRuntimeContext;
14
15
  channelId?: string;
@@ -4,6 +4,7 @@ import { fingerprintOf, fingerprintsEqual } from "../file-store.js";
4
4
  import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
5
5
  import { checkPathGuard } from "../security/path-guard-check.js";
6
6
  import { RecoverableToolError } from "../shared/recoverable-error.js";
7
+ import { withTaskFileMutation } from "../tasks/file-mutation.js";
7
8
  /**
8
9
  * Generate a unified diff string with line numbers and context. `startLineOld`/`startLineNew` let
9
10
  * a caller render a *window* of a larger file (spec 044, D2.3) while still printing the file's real
@@ -293,49 +294,51 @@ export function createEditTool(fileStore, options = {}) {
293
294
  tool: "edit",
294
295
  channelId: options.channelId,
295
296
  });
296
- const before = await fileStore.stat(target);
297
- if (!before || !before.isFile) {
298
- throw new RecoverableToolError(`File not found: ${path}`);
299
- }
300
- const needle = Buffer.from(oldText, "utf-8");
301
- const replacement = Buffer.from(newText, "utf-8");
302
- const isNoopPayload = needle.equals(replacement);
303
- const applyNoop = () => {
304
- const noopKey = `${path}\x00${oldText}\x00${newText}`;
305
- const streak = (noopCounts.get(noopKey) ?? 0) + 1;
306
- noopCounts.set(noopKey, streak);
307
- if (streak >= NOOP_HARD_LIMIT) {
308
- throw new Error(`STOP. This exact edit to ${path} has been a no-op ${streak} times in a row. ` +
309
- `The bug is somewhere else — re-read the file to verify the anchor text before editing again. ` +
310
- `Do NOT widen oldText or add lines to force a match.`);
297
+ return withTaskFileMutation(options.deskDir, target, async () => {
298
+ const before = await fileStore.stat(target);
299
+ if (!before || !before.isFile) {
300
+ throw new RecoverableToolError(`File not found: ${path}`);
311
301
  }
312
- throw new RecoverableToolError(`No changes made to ${path}: oldText and newText are byte-identical at the match, so the replacement produced no change. ` +
313
- `Re-read the file to confirm what actually needs changing before editing again.`);
314
- };
315
- let result;
316
- if (before.size <= EDIT_INLINE_MAX_BYTES) {
317
- result = await editInline(fileStore, target, path, before, needle, replacement, replaceAll === true, signal);
318
- }
319
- else {
320
- result = await editStreaming(fileStore, target, path, before, needle, replacement, replaceAll === true, isNoopPayload, signal);
321
- }
322
- if (isNoopPayload) {
323
- applyNoop();
324
- }
325
- // A real edit breaks any no-op streak.
326
- noopCounts.clear();
327
- const replacementSummary = replaceAll
328
- ? `Replaced ${result.occurrences} occurrence${result.occurrences === 1 ? "" : "s"} in ${path}.`
329
- : `Successfully replaced text in ${path}. Changed ${oldText.length} characters to ${newText.length} characters.`;
330
- const echoedDiff = result.diff.trim() ? `\n\n${clampDiffForEcho(result.diff)}` : "";
331
- return {
332
- content: [{ type: "text", text: `${replacementSummary}${echoedDiff}` }],
333
- details: {
334
- path: target,
335
- diff: result.diff,
336
- patch: result.patch,
337
- },
338
- };
302
+ const needle = Buffer.from(oldText, "utf-8");
303
+ const replacement = Buffer.from(newText, "utf-8");
304
+ const isNoopPayload = needle.equals(replacement);
305
+ const applyNoop = () => {
306
+ const noopKey = `${path}\x00${oldText}\x00${newText}`;
307
+ const streak = (noopCounts.get(noopKey) ?? 0) + 1;
308
+ noopCounts.set(noopKey, streak);
309
+ if (streak >= NOOP_HARD_LIMIT) {
310
+ throw new Error(`STOP. This exact edit to ${path} has been a no-op ${streak} times in a row. ` +
311
+ `The bug is somewhere else — re-read the file to verify the anchor text before editing again. ` +
312
+ `Do NOT widen oldText or add lines to force a match.`);
313
+ }
314
+ throw new RecoverableToolError(`No changes made to ${path}: oldText and newText are byte-identical at the match, so the replacement produced no change. ` +
315
+ `Re-read the file to confirm what actually needs changing before editing again.`);
316
+ };
317
+ let result;
318
+ if (before.size <= EDIT_INLINE_MAX_BYTES) {
319
+ result = await editInline(fileStore, target, path, before, needle, replacement, replaceAll === true, signal);
320
+ }
321
+ else {
322
+ result = await editStreaming(fileStore, target, path, before, needle, replacement, replaceAll === true, isNoopPayload, signal);
323
+ }
324
+ if (isNoopPayload) {
325
+ applyNoop();
326
+ }
327
+ // A real edit breaks any no-op streak.
328
+ noopCounts.clear();
329
+ const replacementSummary = replaceAll
330
+ ? `Replaced ${result.occurrences} occurrence${result.occurrences === 1 ? "" : "s"} in ${path}.`
331
+ : `Successfully replaced text in ${path}. Changed ${oldText.length} characters to ${newText.length} characters.`;
332
+ const echoedDiff = result.diff.trim() ? `\n\n${clampDiffForEcho(result.diff)}` : "";
333
+ return {
334
+ content: [{ type: "text", text: `${replacementSummary}${echoedDiff}` }],
335
+ details: {
336
+ path: target,
337
+ diff: result.diff,
338
+ patch: result.patch,
339
+ },
340
+ };
341
+ });
339
342
  },
340
343
  };
341
344
  }
@@ -9,7 +9,7 @@ import type { DeskJobManager } from "../jobs/manager.js";
9
9
  import type { SecurityConfig } from "../security/types.js";
10
10
  import { type SubAgentDiscoveryResult } from "../subagents/discovery.js";
11
11
  import type { SubAgentRunManager } from "../subagents/runs.js";
12
- import type { TaskStepCost } from "./task-manage/types.js";
12
+ import type { TaskControl, TaskSessionContext } from "../tasks/control.js";
13
13
  export interface CreatePipiclawToolsOptions {
14
14
  jobManager: DeskJobManager;
15
15
  runManager: SubAgentRunManager;
@@ -36,17 +36,13 @@ export interface CreatePipiclawToolsOptions {
36
36
  /** Transport-provided attachment port; when present, enables the `send_media` tool. */
37
37
  sendMedia?: SendMedia;
38
38
  /**
39
- * Present only while this tool set belongs to a task loop step (spec 051, D3). It enables
40
- * `task_step_end` and removes the three tools a task must not use: `task_create` (a task does
41
- * not spawn tasks), `memory_save` (task state is not a channel fact — this was memory v2's
42
- * single biggest pollution source) and `event_manage`.
39
+ * Present only while this tool set belongs to a task session (spec 064, D13). It selects the
40
+ * task-session surface (`task_report`, `task_ask`, `task_wait`), binds every delegation and job
41
+ * started here to the task, and removes the two tools a task must not use: `memory_save` (task
42
+ * state is not a channel fact — memory v2's single biggest pollution source) and `event_manage`.
43
43
  */
44
- taskLoop?: {
45
- taskId: string;
46
- };
47
- /** Tools completed in the current turn; only `task_step_end` reads it. */
48
- getToolsUsed?: () => string[];
49
- /** The current turn's own model cost so far; only `task_step_end` reads it. */
50
- getStepCost?: () => TaskStepCost;
44
+ taskSession?: TaskSessionContext;
45
+ /** Chat only: the task lane's control port. */
46
+ taskControl?: TaskControl;
51
47
  }
52
48
  export declare function createPipiclawTools(options: CreatePipiclawToolsOptions): AgentTool<any>[];
@@ -16,7 +16,7 @@ export function createPipiclawTools(options) {
16
16
  // registry so this set, the sub-agent set, and the prompt hints share one source.
17
17
  // The `subagent` tool is appended separately: it is never available to sub-agents
18
18
  // and needs dispatch-time context the registry does not model.
19
- const taskLoopExcluded = new Set(["task_create", "memory_save", "event_manage"]);
19
+ const taskSessionExcluded = new Set(["memory_save", "event_manage"]);
20
20
  const leafTools = buildToolSet({
21
21
  executor: options.executor,
22
22
  fileStore: options.fileStore,
@@ -37,9 +37,8 @@ export function createPipiclawTools(options) {
37
37
  resolveApiKey: options.resolveApiKey,
38
38
  getSessionSearchSettings: options.getSessionSearchSettings,
39
39
  sendMedia: options.sendMedia,
40
- taskLoop: options.taskLoop,
41
- getToolsUsed: options.getToolsUsed,
42
- getStepCost: options.getStepCost,
40
+ taskSession: options.taskSession,
41
+ taskControl: options.taskControl,
43
42
  });
44
43
  const subAgentToolOptions = {
45
44
  buildWorkerTools: (request) => buildToolSet(request, { forSubagent: true }),
@@ -66,7 +65,7 @@ export function createPipiclawTools(options) {
66
65
  channelId: options.channelId,
67
66
  },
68
67
  // Inside a task session every delegation binds to that task automatically (spec 052, D4).
69
- boundTaskId: options.taskLoop?.taskId,
68
+ boundTaskId: options.taskSession?.taskId,
70
69
  };
71
70
  const subAgentManageOptions = {
72
71
  runManager: options.runManager,
@@ -90,5 +89,16 @@ export function createPipiclawTools(options) {
90
89
  withToolDetails(createSubAgentListTool(subAgentManageOptions), "subagent_list"),
91
90
  withToolDetails(createSubAgentRunTool(subAgentManageOptions), "subagent_run"),
92
91
  ];
93
- return options.taskLoop ? all.filter((tool) => !taskLoopExcluded.has(tool.name)) : all;
92
+ if (!options.taskSession)
93
+ return all;
94
+ return all
95
+ .filter((tool) => !taskSessionExcluded.has(tool.name))
96
+ .map((tool) => ({
97
+ ...tool,
98
+ execute: (...args) => {
99
+ args[2]?.throwIfAborted();
100
+ options.taskSession?.assertActive?.();
101
+ return tool.execute(...args);
102
+ },
103
+ }));
94
104
  }
@@ -66,6 +66,9 @@ function buildMemoryClosures(options) {
66
66
  throw new RecoverableToolError(`"${args.name}" is not a valid memory name. Use lowercase letters, digits, and hyphens only (e.g. deploy-window-thursday).`);
67
67
  }
68
68
  const replaces = args.replaces && args.replaces !== "none" ? args.replaces : undefined;
69
+ if (replaces && !isValidMemoryName(replaces)) {
70
+ throw new RecoverableToolError("Invalid replaces name. Use a lowercase kebab-case name from memory_search.");
71
+ }
69
72
  // The near-duplicate judgment ("read existing facts → decide → write") has to run inside the
70
73
  // same per-desk critical section as the write, or two concurrent saves of the same fact
71
74
  // each see "no duplicate" and both add it. A `null` return means "blocked by near-duplicates,
@@ -87,6 +90,7 @@ function buildMemoryClosures(options) {
87
90
  ? {
88
91
  op: "update",
89
92
  name: replaces,
93
+ source: "user",
90
94
  description: content,
91
95
  type: args.type,
92
96
  details: args.details,
@@ -113,7 +117,7 @@ function buildMemoryClosures(options) {
113
117
  // Report what actually landed on disk — never a name for an entry that was not written.
114
118
  // The old code read `replaces ?? result.added[0]` unconditionally, so a skipped add
115
119
  // rendered "Saved ... as `undefined`." and told the user a lie the model could not see.
116
- if (replaces) {
120
+ if (replaces && result.updated.includes(replaces)) {
117
121
  await logMemorySave(options, replaces, "update");
118
122
  return textResult(`Replaced desk memory \`${replaces}\`.`, { saved: true, name: replaces });
119
123
  }
@@ -178,6 +182,9 @@ function buildMemoryClosures(options) {
178
182
  if (!trimmed) {
179
183
  throw new RecoverableToolError("memory_forget requires a non-empty name.");
180
184
  }
185
+ if (!isValidMemoryName(trimmed)) {
186
+ throw new RecoverableToolError("Invalid memory name. Use a lowercase kebab-case name from memory_search.");
187
+ }
181
188
  const entry = await readMemoryEntry(options.deskDir, trimmed);
182
189
  if (!entry) {
183
190
  return textResult(`No memory named "${trimmed}" exists in this desk; nothing was removed.`, {
@@ -8,8 +8,8 @@ import type { FileStore } from "../file-store.js";
8
8
  import type { DeskJobManager } from "../jobs/manager.js";
9
9
  import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
10
10
  import type { SubAgentRunManager } from "../subagents/runs.js";
11
+ import type { TaskControl, TaskSessionContext } from "../tasks/control.js";
11
12
  import { type ToolDetailsKind } from "./contract/details.js";
12
- import type { TaskStepCost } from "./task-manage/types.js";
13
13
  /**
14
14
  * Unified build context passed to every tool's `create` closure. It carries the union
15
15
  * of everything any registered tool might need; each closure reads only its own fields.
@@ -62,17 +62,13 @@ export interface ToolBuildContext {
62
62
  */
63
63
  sendMedia?: SendMedia;
64
64
  /**
65
- * Present only inside a task loop step (spec 051, D3): which task this tool set belongs to.
66
- * `task_step_end` is registered only when this is set, so the chat surface can never end a
67
- * step that is not running.
65
+ * Present only in a task session (spec 064, D13/D21): which task this tool set belongs to and how
66
+ * its step reports back to the lane. The step tools (`task_report`, `task_ask`, `task_wait`) are
67
+ * registered only when this is set, and the chat management tools only when it is not.
68
68
  */
69
- taskLoop?: {
70
- taskId: string;
71
- };
72
- /** Tools completed in the current turn; only the task loop reads it. */
73
- getToolsUsed?: () => string[];
74
- /** The current turn's own model cost so far; only the task loop reads it. */
75
- getStepCost?: () => TaskStepCost;
69
+ taskSession?: TaskSessionContext;
70
+ /** Chat only: the lane's control port, behind `task_message`, `task_pause`, `task_resume` and the live part of `task_list`. */
71
+ taskControl?: TaskControl;
76
72
  }
77
73
  export interface ToolRegistration {
78
74
  /** Also the tool's `details.kind`: the name is the authoritative discriminator. */
@@ -11,7 +11,7 @@ import { createReadTool } from "./read.js";
11
11
  import { createSendMediaTool } from "./send-media.js";
12
12
  import { createSessionSearchTool } from "./session-search.js";
13
13
  import { createSkillTool } from "./skill.js";
14
- import { createTaskCloseTool, createTaskCreateTool, createTaskListTool, createTaskLogTool, createTaskStepEndTool, createTaskUpdateTool, } from "./task-manage/factory.js";
14
+ import { createTaskAskTool, createTaskCloseTool, createTaskCreateTool, createTaskListTool, createTaskLogTool, createTaskMessageTool, createTaskPauseTool, createTaskReportTool, createTaskResumeTool, createTaskWaitTool, } from "./task-manage/factory.js";
15
15
  import { createWebFetchTool } from "./web-fetch.js";
16
16
  import { createWebSearchTool } from "./web-search.js";
17
17
  import { createWriteTool } from "./write.js";
@@ -40,10 +40,24 @@ function taskToolOptions(ctx) {
40
40
  return {
41
41
  jobManager: req(ctx.jobManager, "jobManager"),
42
42
  runManager: req(ctx.runManager, "runManager"),
43
+ desk: req(ctx.desk, "desk"),
43
44
  deskDir: ctx.deskDir,
44
45
  channelId: ctx.channelId,
46
+ control: ctx.taskControl,
47
+ session: ctx.taskSession,
45
48
  };
46
49
  }
50
+ /** `tools.tasks` is the master switch for the whole background-task mechanism: the lane and the per-turn agenda honor it too. */
51
+ function tasksEnabled(ctx) {
52
+ return ctx.toolsConfig?.tools.tasks.enabled !== false;
53
+ }
54
+ /** Chat-only tools: managing tasks is the chat's job, a task session works inside one. */
55
+ function chatTasksEnabled(ctx) {
56
+ return tasksEnabled(ctx) && ctx.taskSession === undefined;
57
+ }
58
+ function taskSessionEnabled(ctx) {
59
+ return tasksEnabled(ctx) && ctx.taskSession !== undefined;
60
+ }
47
61
  function webEnabled(ctx) {
48
62
  return ctx.webConfig != null && ctx.webConfig.enable !== false;
49
63
  }
@@ -66,7 +80,7 @@ export const TOOL_REGISTRY = [
66
80
  interceptorEnabled: ctx.toolsConfig?.tools.bashInterceptor.enabled === true,
67
81
  // Sub-agents get no channel dir (their guard context has none); their spill stays in tmpdir.
68
82
  ...(ctx.forSubagent ? {} : { deskDir: ctx.deskDir }),
69
- ...(ctx.taskLoop ? { boundTaskId: ctx.taskLoop.taskId } : {}),
83
+ ...(ctx.taskSession ? { boundTaskId: ctx.taskSession.taskId } : {}),
70
84
  ...(ctx.jobManager ? { jobManager: ctx.jobManager } : {}),
71
85
  ...(ctx.bashDefaultTimeoutSeconds !== undefined
72
86
  ? { defaultTimeoutSeconds: ctx.bashDefaultTimeoutSeconds }
@@ -75,7 +89,7 @@ export const TOOL_REGISTRY = [
75
89
  },
76
90
  {
77
91
  name: "edit",
78
- create: (ctx) => createEditTool(ctx.fileStore, fileToolOptions(ctx)),
92
+ create: (ctx) => createEditTool(ctx.fileStore, { ...fileToolOptions(ctx), deskDir: ctx.deskDir }),
79
93
  },
80
94
  {
81
95
  name: "grep",
@@ -87,7 +101,7 @@ export const TOOL_REGISTRY = [
87
101
  },
88
102
  {
89
103
  name: "write",
90
- create: (ctx) => createWriteTool(ctx.fileStore, fileToolOptions(ctx)),
104
+ create: (ctx) => createWriteTool(ctx.fileStore, { ...fileToolOptions(ctx), deskDir: ctx.deskDir }),
91
105
  },
92
106
  {
93
107
  name: "web_search",
@@ -159,44 +173,57 @@ export const TOOL_REGISTRY = [
159
173
  commandGuardConfig: ctx.securityConfig.commandGuard,
160
174
  }),
161
175
  },
162
- // tools.tasks is the master switch for the whole autonomous long-running task mechanism;
163
- // the TaskDriver and per-turn task digest honor the same flag. Five tools, one per payload
164
- // shape (spec 046, D3.1) — all share it, since none is meaningful without the others.
176
+ // Spec 064, D21: two surfaces. Chat creates, lists, messages, pauses, resumes, closes and reads
177
+ // tasks; a task session reads, closes and talks to the user. Each tool has one call shape (spec 046).
165
178
  {
166
179
  name: "task_list",
167
- enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false,
180
+ enabledBy: chatTasksEnabled,
168
181
  create: (ctx) => createTaskListTool(taskToolOptions(ctx)),
169
182
  },
170
183
  {
171
184
  name: "task_create",
172
- enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false,
185
+ enabledBy: chatTasksEnabled,
173
186
  create: (ctx) => createTaskCreateTool(taskToolOptions(ctx)),
174
187
  },
175
- {
176
- name: "task_update",
177
- enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false,
178
- create: (ctx) => createTaskUpdateTool(taskToolOptions(ctx)),
179
- },
180
188
  {
181
189
  name: "task_close",
182
- enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false,
190
+ enabledBy: tasksEnabled,
183
191
  create: (ctx) => createTaskCloseTool(taskToolOptions(ctx)),
184
192
  },
185
193
  {
186
194
  name: "task_log",
187
- enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false,
195
+ enabledBy: tasksEnabled,
188
196
  create: (ctx) => createTaskLogTool(taskToolOptions(ctx)),
189
197
  },
190
198
  {
191
- name: "task_step_end",
192
- // Only inside a task session: it is the loop's closing move, not a chat action.
193
- enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false && ctx.taskLoop !== undefined,
194
- create: (ctx) => createTaskStepEndTool({
195
- ...taskToolOptions(ctx),
196
- taskId: ctx.taskLoop?.taskId,
197
- getToolsUsed: ctx.getToolsUsed,
198
- getStepCost: ctx.getStepCost,
199
- }),
199
+ name: "task_message",
200
+ enabledBy: chatTasksEnabled,
201
+ create: (ctx) => createTaskMessageTool(taskToolOptions(ctx)),
202
+ },
203
+ {
204
+ name: "task_pause",
205
+ enabledBy: chatTasksEnabled,
206
+ create: (ctx) => createTaskPauseTool(taskToolOptions(ctx)),
207
+ },
208
+ {
209
+ name: "task_resume",
210
+ enabledBy: chatTasksEnabled,
211
+ create: (ctx) => createTaskResumeTool(taskToolOptions(ctx)),
212
+ },
213
+ {
214
+ name: "task_report",
215
+ enabledBy: taskSessionEnabled,
216
+ create: (ctx) => createTaskReportTool(taskToolOptions(ctx)),
217
+ },
218
+ {
219
+ name: "task_ask",
220
+ enabledBy: taskSessionEnabled,
221
+ create: (ctx) => createTaskAskTool(taskToolOptions(ctx)),
222
+ },
223
+ {
224
+ name: "task_wait",
225
+ enabledBy: taskSessionEnabled,
226
+ create: (ctx) => createTaskWaitTool(taskToolOptions(ctx)),
200
227
  },
201
228
  {
202
229
  name: "job",
@@ -1,6 +1,6 @@
1
1
  import type { AgentTool } from "@earendil-works/pi-agent-core";
2
2
  import { Type } from "typebox";
3
- import { type WorkspaceSkillOptions } from "../skills/workspace.js";
3
+ import type { SkillOptions } from "../skills/types.js";
4
4
  /**
5
5
  * `skill` is deliberately read-only. Authoring a workspace skill goes through the generic
6
6
  * `write`/`edit` tools writing `workspace/skills/<name>/SKILL.md` directly — a low-frequency path
@@ -12,5 +12,5 @@ declare const skillSchema: Type.TObject<{
12
12
  action: Type.TUnion<[Type.TLiteral<"list">, Type.TLiteral<"read">]>;
13
13
  name: Type.TOptional<Type.TString>;
14
14
  }>;
15
- export declare function createSkillTool(options: WorkspaceSkillOptions): AgentTool<typeof skillSchema>;
15
+ export declare function createSkillTool(options: SkillOptions): AgentTool<typeof skillSchema>;
16
16
  export {};
@@ -1,7 +1,8 @@
1
1
  import { dirname } from "node:path";
2
2
  import { Type } from "typebox";
3
3
  import { RecoverableToolError } from "../shared/recoverable-error.js";
4
- import { listWorkspaceSkills, loadWorkspaceSkillFile } from "../skills/workspace.js";
4
+ import { loadSkillFile } from "../skills/catalog.js";
5
+ import { loadPipiclawSkills } from "../skills/loader.js";
5
6
  import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
6
7
  /**
7
8
  * `skill` is deliberately read-only. Authoring a workspace skill goes through the generic
@@ -12,12 +13,12 @@ import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
12
13
  */
13
14
  const skillSchema = Type.Object({
14
15
  action: Type.Union([Type.Literal("list"), Type.Literal("read")], {
15
- description: '"list" workspace skills, or "read" one skill\'s full SKILL.md content.',
16
+ description: '"list" available skills, or "read" one skill\'s full SKILL.md content.',
16
17
  }),
17
- name: Type.Optional(Type.String({ description: "Exact workspace skill name from the list (required for read)." })),
18
+ name: Type.Optional(Type.String({ description: "Exact skill name from the list (required for read)." })),
18
19
  });
19
- async function readWorkspaceSkill(options, name) {
20
- const file = await loadWorkspaceSkillFile(options, name);
20
+ async function readSkill(options, name) {
21
+ const file = await loadSkillFile(options, name);
21
22
  const truncation = truncateHead(file.content);
22
23
  let body = truncation.content;
23
24
  if (truncation.truncated) {
@@ -32,22 +33,35 @@ async function readWorkspaceSkill(options, name) {
32
33
  `</skill>`;
33
34
  return {
34
35
  content: [{ type: "text", text: envelope }],
35
- details: { action: "read", name: file.name, path: file.path, truncated: truncation.truncated },
36
+ details: {
37
+ action: "read",
38
+ name: file.name,
39
+ path: file.path,
40
+ source: file.source,
41
+ truncated: truncation.truncated,
42
+ },
36
43
  };
37
44
  }
38
45
  export function createSkillTool(options) {
39
46
  return {
40
47
  name: "skill",
41
48
  label: "skill",
42
- description: "List or read workspace-level Pipiclaw skills (procedural memory) under workspace/skills/. Read-only: " +
49
+ description: "List or read Pipiclaw skills from ~/.agents/skills/ and workspace/skills/. Valid workspace skills override shared names. Read-only: " +
43
50
  "to author or update a skill, write workspace/skills/<name>/SKILL.md directly with the write/edit tools " +
44
51
  '(frontmatter needs "name" and "description" fields).',
45
52
  parameters: skillSchema,
46
53
  execute: async (_toolCallId, args) => {
47
54
  if (args.action === "list") {
48
- const skills = await listWorkspaceSkills(options);
55
+ const catalog = loadPipiclawSkills(options);
56
+ const skills = catalog.skills.map((skill) => ({
57
+ name: skill.name,
58
+ description: skill.description,
59
+ path: skill.filePath,
60
+ source: skill.source,
61
+ disableModelInvocation: skill.disableModelInvocation,
62
+ }));
49
63
  return {
50
- content: [{ type: "text", text: JSON.stringify({ skills }) }],
64
+ content: [{ type: "text", text: JSON.stringify({ skills, diagnostics: catalog.diagnostics }) }],
51
65
  details: { action: "list", count: skills.length },
52
66
  };
53
67
  }
@@ -57,7 +71,7 @@ export function createSkillTool(options) {
57
71
  if (!args.name) {
58
72
  throw new RecoverableToolError('Action "read" requires a skill name.');
59
73
  }
60
- return readWorkspaceSkill(options, args.name);
74
+ return readSkill(options, args.name);
61
75
  },
62
76
  };
63
77
  }
@@ -93,12 +93,15 @@ async function formatRunShow(record) {
93
93
  }
94
94
  return lines.join("\n");
95
95
  }
96
- /** Resumable harnesses only: `claude-code`/`codex-cli`. `exec` has no session concept, and internal
97
- * runs have no persisted transcript by design (spec 040, non-goals). */
96
+ /** Resumable harnesses only: `claude-code`/`codex-cli`/`cursor-cli`. `exec` has no session concept,
97
+ * and internal runs have no persisted transcript by design (spec 040, non-goals). */
98
98
  function resumableHarnessOf(record) {
99
99
  if (record.runtime !== "external")
100
100
  return undefined;
101
- return record.harness === "codex-cli" || record.harness === "claude-code" ? record.harness : undefined;
101
+ if (record.harness === "codex-cli" || record.harness === "claude-code" || record.harness === "cursor-cli") {
102
+ return record.harness;
103
+ }
104
+ return undefined;
102
105
  }
103
106
  export function createSubAgentListTool(options) {
104
107
  const manager = options.runManager;
@@ -308,7 +311,7 @@ export function createSubAgentRunTool(options) {
308
311
  content: [
309
312
  {
310
313
  type: "text",
311
- text: `Follow-up dispatched as runId=${newRunId} (resuming ${resolvedRunId}). This channel will be woken when it finishes.`,
314
+ text: `Follow-up dispatched as runId=${newRunId} (resuming ${resolvedRunId}). Whoever dispatched it (this chat, or the task whose step did) will be woken when it finishes.`,
312
315
  },
313
316
  ],
314
317
  details: { op, runId: newRunId, resumedFrom: resolvedRunId },
@@ -16,7 +16,6 @@ declare const subagentSchema: Type.TObject<{
16
16
  task: Type.TString;
17
17
  workingDirectory: Type.TOptional<Type.TString>;
18
18
  purpose: Type.TOptional<Type.TUnion<[Type.TLiteral<"work">, Type.TLiteral<"verify">]>>;
19
- taskId: Type.TOptional<Type.TString>;
20
19
  item: Type.TOptional<Type.TString>;
21
20
  }>;
22
21
  /**
@@ -34,7 +33,6 @@ declare const subagentInlineSchema: Type.TObject<{
34
33
  mutates: Type.TOptional<Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"write">]>>;
35
34
  workingDirectory: Type.TOptional<Type.TString>;
36
35
  purpose: Type.TOptional<Type.TUnion<[Type.TLiteral<"work">, Type.TLiteral<"verify">]>>;
37
- taskId: Type.TOptional<Type.TString>;
38
36
  item: Type.TOptional<Type.TString>;
39
37
  }>;
40
38
  /** The shape consumers read post-wrap, once `withToolDetails` has stamped `kind`. */
@@ -9,11 +9,8 @@ const workingDirectoryField = Type.Optional(Type.String({
9
9
  const purposeField = Type.Optional(Type.Union([Type.Literal("work"), Type.Literal("verify")], {
10
10
  description: 'Use "verify" for an independent check: the sub-agent is given the checker protocol and ends with VERDICT: PASS|FAIL. The verdict is information for you to weigh, not a gate.',
11
11
  }));
12
- const taskIdField = Type.Optional(Type.String({
13
- description: "Persistent task this work belongs to. Inside a task session it is bound automatically — omit it. In chat, pass it to have the result recorded on that task's board.",
14
- }));
15
12
  const itemField = Type.Optional(Type.String({
16
- description: 'The task\'s Work Item this delegation is for, e.g. "W2". Requires a task (bound automatically in a task session).',
13
+ description: 'The task\'s Work Item this delegation is for, e.g. "W2". Only valid inside a task step, where the delegation is bound to the task automatically.',
17
14
  }));
18
15
  /**
19
16
  * Role-based delegation (spec 046, D2.1): the common path. No override fields beyond routing
@@ -25,7 +22,6 @@ const subagentSchema = Type.Object({
25
22
  task: Type.String({ description: "Complete task description for the sub-agent" }),
26
23
  workingDirectory: workingDirectoryField,
27
24
  purpose: purposeField,
28
- taskId: taskIdField,
29
25
  item: itemField,
30
26
  });
31
27
  /**
@@ -60,7 +56,6 @@ const subagentInlineSchema = Type.Object({
60
56
  })),
61
57
  workingDirectory: workingDirectoryField,
62
58
  purpose: purposeField,
63
- taskId: taskIdField,
64
59
  item: itemField,
65
60
  });
66
61
  export function createSubAgentTool(options) {
@@ -96,7 +91,7 @@ export function createSubAgentInlineTool(options) {
96
91
  return {
97
92
  name: "subagent_inline",
98
93
  label: "subagent_inline",
99
- description: "Advanced fallback only, not the default: use `subagent` first whenever any configured role in the workspace `sub-agents/` can do the work. `subagent` is the normal role-based path: pass its `agent` and complete `task`; the role file supplies the tools, model, budget and context policy. Use `subagent_inline` only when no configured role is suitable. It is a raw one-shot meta-executor, not a shorthand for `subagent`: there is no role file to supply those settings. Build a complete valid inline call yourself — `task` and `systemPrompt` are required; choose valid values for any needed `tools`, `model`, `effort`, `context`, `thinkingLevel`, `mutates`, `workingDirectory`, `purpose` and `taskId` fields. Do not send a partial role-style payload or choose this tool just because it is available. Sub-agents never receive the subagent tool, so they cannot create nested agents.",
94
+ description: "Advanced fallback only, not the default: use `subagent` first whenever any configured role in the workspace `sub-agents/` can do the work. `subagent` is the normal role-based path: pass its `agent` and complete `task`; the role file supplies the tools, model, budget and context policy. Use `subagent_inline` only when no configured role is suitable. It is a raw one-shot meta-executor, not a shorthand for `subagent`: there is no role file to supply those settings. Build a complete valid inline call yourself — `task` and `systemPrompt` are required; choose valid values for any needed `tools`, `model`, `effort`, `context`, `thinkingLevel`, `mutates`, `workingDirectory`, and `purpose` fields. Do not send a partial role-style payload or choose this tool just because it is available. Sub-agents never receive the subagent tool, so they cannot create nested agents.",
100
95
  parameters: subagentInlineSchema,
101
96
  execute: async (_toolCallId, params, signal, onUpdate) => {
102
97
  if (signal?.aborted) {
@@ -0,0 +1,4 @@
1
+ import type { TaskManageResult, TaskManageToolOptions, TaskMessageRequest, TaskPauseRequest, TaskResumeRequest } from "./types.js";
2
+ export declare function messageTask(options: TaskManageToolOptions, request: TaskMessageRequest): Promise<TaskManageResult>;
3
+ export declare function pauseTask(options: TaskManageToolOptions, request: TaskPauseRequest): Promise<TaskManageResult>;
4
+ export declare function resumeTask(options: TaskManageToolOptions, request: TaskResumeRequest): Promise<TaskManageResult>;