@caupulican/pi-adaptative 0.86.17 → 0.90.2

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 (297) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +1 -1
  3. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
  4. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +14 -15
  5. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
  6. package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +14 -16
  7. package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +4 -4
  8. package/dist/core/agent-session.d.ts +23 -33
  9. package/dist/core/agent-session.d.ts.map +1 -1
  10. package/dist/core/agent-session.js +81 -110
  11. package/dist/core/agent-session.js.map +1 -1
  12. package/dist/core/autonomy/contracts.d.ts +1 -1
  13. package/dist/core/autonomy/contracts.js.map +1 -1
  14. package/dist/core/autonomy/gates.d.ts.map +1 -1
  15. package/dist/core/autonomy/gates.js +16 -0
  16. package/dist/core/autonomy/gates.js.map +1 -1
  17. package/dist/core/autonomy/subagent-prompt.d.ts +2 -1
  18. package/dist/core/autonomy/subagent-prompt.d.ts.map +1 -1
  19. package/dist/core/autonomy/subagent-prompt.js +2 -18
  20. package/dist/core/autonomy/subagent-prompt.js.map +1 -1
  21. package/dist/core/background-tool-task-controller.js +5 -5
  22. package/dist/core/background-tool-task-controller.js.map +1 -1
  23. package/dist/core/compaction-controller.d.ts +22 -2
  24. package/dist/core/compaction-controller.d.ts.map +1 -1
  25. package/dist/core/compaction-controller.js +75 -39
  26. package/dist/core/compaction-controller.js.map +1 -1
  27. package/dist/core/context/brain-curator.d.ts +2 -3
  28. package/dist/core/context/brain-curator.d.ts.map +1 -1
  29. package/dist/core/context/brain-curator.js +3 -20
  30. package/dist/core/context/brain-curator.js.map +1 -1
  31. package/dist/core/context/context-composition.d.ts +2 -1
  32. package/dist/core/context/context-composition.d.ts.map +1 -1
  33. package/dist/core/context/context-composition.js +6 -1
  34. package/dist/core/context/context-composition.js.map +1 -1
  35. package/dist/core/context/memory-prompt-block.js +1 -1
  36. package/dist/core/context/memory-prompt-block.js.map +1 -1
  37. package/dist/core/context/tool-output-packer.js +1 -1
  38. package/dist/core/context/tool-output-packer.js.map +1 -1
  39. package/dist/core/context-gc.js +10 -10
  40. package/dist/core/context-gc.js.map +1 -1
  41. package/dist/core/context-pipeline.d.ts +4 -4
  42. package/dist/core/context-pipeline.js +4 -4
  43. package/dist/core/context-pipeline.js.map +1 -1
  44. package/dist/core/default-tool-surface.d.ts.map +1 -1
  45. package/dist/core/default-tool-surface.js +1 -2
  46. package/dist/core/default-tool-surface.js.map +1 -1
  47. package/dist/core/delegation/session-worker-claim.d.ts +2 -2
  48. package/dist/core/delegation/session-worker-claim.js +2 -2
  49. package/dist/core/delegation/session-worker-claim.js.map +1 -1
  50. package/dist/core/delegation/worker-agent-control-coordinator.js +1 -1
  51. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
  52. package/dist/core/delegation/worker-resource-materializer.js +3 -3
  53. package/dist/core/delegation/worker-resource-materializer.js.map +1 -1
  54. package/dist/core/delegation/worker-runner.d.ts +2 -13
  55. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  56. package/dist/core/delegation/worker-runner.js +5 -67
  57. package/dist/core/delegation/worker-runner.js.map +1 -1
  58. package/dist/core/extensions/builtin.js +4 -4
  59. package/dist/core/extensions/builtin.js.map +1 -1
  60. package/dist/core/extensions/runner.d.ts +6 -2
  61. package/dist/core/extensions/runner.d.ts.map +1 -1
  62. package/dist/core/extensions/runner.js +21 -9
  63. package/dist/core/extensions/runner.js.map +1 -1
  64. package/dist/core/extensions/types.d.ts +9 -2
  65. package/dist/core/extensions/types.d.ts.map +1 -1
  66. package/dist/core/extensions/types.js.map +1 -1
  67. package/dist/core/foreground-terminal-handoff-controller.js +2 -2
  68. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  69. package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
  70. package/dist/core/goals/compact-goal-context.js +13 -9
  71. package/dist/core/goals/compact-goal-context.js.map +1 -1
  72. package/dist/core/goals/goal-continuation-prompt.js +1 -1
  73. package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
  74. package/dist/core/goals/goal-session-controller.d.ts +6 -0
  75. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  76. package/dist/core/goals/goal-session-controller.js +16 -13
  77. package/dist/core/goals/goal-session-controller.js.map +1 -1
  78. package/dist/core/human-input-controller.js +1 -1
  79. package/dist/core/human-input-controller.js.map +1 -1
  80. package/dist/core/improvement-loop.js +13 -13
  81. package/dist/core/improvement-loop.js.map +1 -1
  82. package/dist/core/learning/reflection-engine.d.ts +2 -1
  83. package/dist/core/learning/reflection-engine.d.ts.map +1 -1
  84. package/dist/core/learning/reflection-engine.js +4 -24
  85. package/dist/core/learning/reflection-engine.js.map +1 -1
  86. package/dist/core/model-capability.d.ts.map +1 -1
  87. package/dist/core/model-capability.js +1 -1
  88. package/dist/core/model-capability.js.map +1 -1
  89. package/dist/core/model-router/route-judge.d.ts +2 -1
  90. package/dist/core/model-router/route-judge.d.ts.map +1 -1
  91. package/dist/core/model-router/route-judge.js +4 -12
  92. package/dist/core/model-router/route-judge.js.map +1 -1
  93. package/dist/core/models/perf-profile.d.ts +1 -1
  94. package/dist/core/models/perf-profile.d.ts.map +1 -1
  95. package/dist/core/models/perf-profile.js +2 -8
  96. package/dist/core/models/perf-profile.js.map +1 -1
  97. package/dist/core/orchestration/lane-tool-manifests.d.ts +1 -1
  98. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
  99. package/dist/core/orchestration/lane-tool-manifests.js +1 -6
  100. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
  101. package/dist/core/process-matrix/resume-launcher.js +3 -3
  102. package/dist/core/process-matrix/resume-launcher.js.map +1 -1
  103. package/dist/core/process-matrix/runtime.d.ts +2 -0
  104. package/dist/core/process-matrix/runtime.d.ts.map +1 -1
  105. package/dist/core/process-matrix/runtime.js +23 -19
  106. package/dist/core/process-matrix/runtime.js.map +1 -1
  107. package/dist/core/provider-prompt-contracts.d.ts +34 -0
  108. package/dist/core/provider-prompt-contracts.d.ts.map +1 -0
  109. package/dist/core/provider-prompt-contracts.js +133 -0
  110. package/dist/core/provider-prompt-contracts.js.map +1 -0
  111. package/dist/core/provider-request-context-controller.d.ts +40 -0
  112. package/dist/core/provider-request-context-controller.d.ts.map +1 -0
  113. package/dist/core/provider-request-context-controller.js +68 -0
  114. package/dist/core/provider-request-context-controller.js.map +1 -0
  115. package/dist/core/provider-request-runtime-controller.d.ts +22 -0
  116. package/dist/core/provider-request-runtime-controller.d.ts.map +1 -0
  117. package/dist/core/provider-request-runtime-controller.js +87 -0
  118. package/dist/core/provider-request-runtime-controller.js.map +1 -0
  119. package/dist/core/provider-tool-text.d.ts +7 -0
  120. package/dist/core/provider-tool-text.d.ts.map +1 -0
  121. package/dist/core/provider-tool-text.js +42 -0
  122. package/dist/core/provider-tool-text.js.map +1 -0
  123. package/dist/core/research/model-fitness.d.ts +2 -5
  124. package/dist/core/research/model-fitness.d.ts.map +1 -1
  125. package/dist/core/research/model-fitness.js +2 -20
  126. package/dist/core/research/model-fitness.js.map +1 -1
  127. package/dist/core/research/research-runner.d.ts +2 -1
  128. package/dist/core/research/research-runner.d.ts.map +1 -1
  129. package/dist/core/research/research-runner.js +6 -21
  130. package/dist/core/research/research-runner.js.map +1 -1
  131. package/dist/core/risk-classifier.d.ts.map +1 -1
  132. package/dist/core/risk-classifier.js +9 -1
  133. package/dist/core/risk-classifier.js.map +1 -1
  134. package/dist/core/runtime-builder.d.ts +3 -0
  135. package/dist/core/runtime-builder.d.ts.map +1 -1
  136. package/dist/core/runtime-builder.js +20 -25
  137. package/dist/core/runtime-builder.js.map +1 -1
  138. package/dist/core/scout-controller.d.ts +2 -1
  139. package/dist/core/scout-controller.d.ts.map +1 -1
  140. package/dist/core/scout-controller.js +2 -16
  141. package/dist/core/scout-controller.js.map +1 -1
  142. package/dist/core/sdk.d.ts +1 -1
  143. package/dist/core/sdk.js.map +1 -1
  144. package/dist/core/secrets/credential-exposure-guard.js +6 -6
  145. package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
  146. package/dist/core/secrets/credential-manager.d.ts +11 -1
  147. package/dist/core/secrets/credential-manager.d.ts.map +1 -1
  148. package/dist/core/secrets/credential-manager.js +28 -7
  149. package/dist/core/secrets/credential-manager.js.map +1 -1
  150. package/dist/core/secrets/credential-migration-source.d.ts +20 -0
  151. package/dist/core/secrets/credential-migration-source.d.ts.map +1 -0
  152. package/dist/core/secrets/credential-migration-source.js +113 -0
  153. package/dist/core/secrets/credential-migration-source.js.map +1 -0
  154. package/dist/core/secrets/credential-session-connection.d.ts +9 -0
  155. package/dist/core/secrets/credential-session-connection.d.ts.map +1 -0
  156. package/dist/core/secrets/credential-session-connection.js +39 -0
  157. package/dist/core/secrets/credential-session-connection.js.map +1 -0
  158. package/dist/core/security/untrusted-boundary.d.ts +2 -2
  159. package/dist/core/security/untrusted-boundary.d.ts.map +1 -1
  160. package/dist/core/security/untrusted-boundary.js +3 -10
  161. package/dist/core/security/untrusted-boundary.js.map +1 -1
  162. package/dist/core/session-role.d.ts.map +1 -1
  163. package/dist/core/session-role.js +1 -2
  164. package/dist/core/session-role.js.map +1 -1
  165. package/dist/core/skill-vault.d.ts +98 -0
  166. package/dist/core/skill-vault.d.ts.map +1 -0
  167. package/dist/core/skill-vault.js +270 -0
  168. package/dist/core/skill-vault.js.map +1 -0
  169. package/dist/core/skills.d.ts +10 -9
  170. package/dist/core/skills.d.ts.map +1 -1
  171. package/dist/core/skills.js +42 -50
  172. package/dist/core/skills.js.map +1 -1
  173. package/dist/core/system-prompt-builder.d.ts +1 -1
  174. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  175. package/dist/core/system-prompt-builder.js +20 -60
  176. package/dist/core/system-prompt-builder.js.map +1 -1
  177. package/dist/core/system-prompt.d.ts +4 -4
  178. package/dist/core/system-prompt.d.ts.map +1 -1
  179. package/dist/core/system-prompt.js +87 -121
  180. package/dist/core/system-prompt.js.map +1 -1
  181. package/dist/core/tasks/task-state.d.ts.map +1 -1
  182. package/dist/core/tasks/task-state.js +6 -7
  183. package/dist/core/tasks/task-state.js.map +1 -1
  184. package/dist/core/tool-capability-policy.d.ts.map +1 -1
  185. package/dist/core/tool-capability-policy.js +2 -1
  186. package/dist/core/tool-capability-policy.js.map +1 -1
  187. package/dist/core/tool-protocol-controller.d.ts.map +1 -1
  188. package/dist/core/tool-protocol-controller.js +4 -7
  189. package/dist/core/tool-protocol-controller.js.map +1 -1
  190. package/dist/core/tool-selection/promotion.d.ts.map +1 -1
  191. package/dist/core/tool-selection/promotion.js +2 -6
  192. package/dist/core/tool-selection/promotion.js.map +1 -1
  193. package/dist/core/toolkit/reflex-interpreter.d.ts +2 -1
  194. package/dist/core/toolkit/reflex-interpreter.d.ts.map +1 -1
  195. package/dist/core/toolkit/reflex-interpreter.js +2 -14
  196. package/dist/core/toolkit/reflex-interpreter.js.map +1 -1
  197. package/dist/core/tools/ask-question.js +6 -6
  198. package/dist/core/tools/ask-question.js.map +1 -1
  199. package/dist/core/tools/bash.d.ts.map +1 -1
  200. package/dist/core/tools/bash.js +8 -7
  201. package/dist/core/tools/bash.js.map +1 -1
  202. package/dist/core/tools/delegate-status.d.ts +17 -13
  203. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  204. package/dist/core/tools/delegate-status.js +111 -226
  205. package/dist/core/tools/delegate-status.js.map +1 -1
  206. package/dist/core/tools/delegate.d.ts +29 -2
  207. package/dist/core/tools/delegate.d.ts.map +1 -1
  208. package/dist/core/tools/delegate.js +149 -48
  209. package/dist/core/tools/delegate.js.map +1 -1
  210. package/dist/core/tools/edit.js +3 -3
  211. package/dist/core/tools/edit.js.map +1 -1
  212. package/dist/core/tools/extensionify-runtime.js +4 -4
  213. package/dist/core/tools/extensionify-runtime.js.map +1 -1
  214. package/dist/core/tools/find.d.ts.map +1 -1
  215. package/dist/core/tools/find.js +2 -4
  216. package/dist/core/tools/find.js.map +1 -1
  217. package/dist/core/tools/goal.js +3 -3
  218. package/dist/core/tools/goal.js.map +1 -1
  219. package/dist/core/tools/grep.js +2 -2
  220. package/dist/core/tools/grep.js.map +1 -1
  221. package/dist/core/tools/index.d.ts +1 -1
  222. package/dist/core/tools/index.d.ts.map +1 -1
  223. package/dist/core/tools/index.js +1 -1
  224. package/dist/core/tools/index.js.map +1 -1
  225. package/dist/core/tools/model-fitness.js +4 -4
  226. package/dist/core/tools/model-fitness.js.map +1 -1
  227. package/dist/core/tools/profile-writer.d.ts +30 -16
  228. package/dist/core/tools/profile-writer.d.ts.map +1 -1
  229. package/dist/core/tools/profile-writer.js +98 -59
  230. package/dist/core/tools/profile-writer.js.map +1 -1
  231. package/dist/core/tools/python.js +6 -6
  232. package/dist/core/tools/python.js.map +1 -1
  233. package/dist/core/tools/run-process.js +4 -4
  234. package/dist/core/tools/run-process.js.map +1 -1
  235. package/dist/core/tools/run-toolkit-script.js +4 -4
  236. package/dist/core/tools/run-toolkit-script.js.map +1 -1
  237. package/dist/core/tools/secret-store.d.ts +32 -3
  238. package/dist/core/tools/secret-store.d.ts.map +1 -1
  239. package/dist/core/tools/secret-store.js +141 -34
  240. package/dist/core/tools/secret-store.js.map +1 -1
  241. package/dist/core/tools/skill.d.ts +29 -0
  242. package/dist/core/tools/skill.d.ts.map +1 -0
  243. package/dist/core/tools/skill.js +79 -0
  244. package/dist/core/tools/skill.js.map +1 -0
  245. package/dist/core/tools/task-steps.js +4 -4
  246. package/dist/core/tools/task-steps.js.map +1 -1
  247. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  248. package/dist/core/tools/tool-definition-wrapper.js +2 -0
  249. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  250. package/dist/core/tools/tool-task.d.ts.map +1 -1
  251. package/dist/core/tools/tool-task.js +4 -0
  252. package/dist/core/tools/tool-task.js.map +1 -1
  253. package/dist/core/tools/worktree-sync.js +6 -6
  254. package/dist/core/tools/worktree-sync.js.map +1 -1
  255. package/dist/core/tools/write.js +3 -3
  256. package/dist/core/tools/write.js.map +1 -1
  257. package/dist/index.d.ts +5 -2
  258. package/dist/index.d.ts.map +1 -1
  259. package/dist/index.js +4 -1
  260. package/dist/index.js.map +1 -1
  261. package/dist/modes/interactive/interactive-event-controller.js +1 -1
  262. package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
  263. package/dist/modes/interactive/interactive-mode.js +1 -1
  264. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  265. package/dist/modes/interactive/report-commands.js +1 -1
  266. package/dist/modes/interactive/report-commands.js.map +1 -1
  267. package/dist/modes/interactive/secret-menu-controller.d.ts.map +1 -1
  268. package/dist/modes/interactive/secret-menu-controller.js +2 -18
  269. package/dist/modes/interactive/secret-menu-controller.js.map +1 -1
  270. package/dist/modes/interactive/session-flow-commands.js +1 -1
  271. package/dist/modes/interactive/session-flow-commands.js.map +1 -1
  272. package/docs/compaction.md +45 -25
  273. package/docs/extensions.md +23 -7
  274. package/docs/settings.md +3 -3
  275. package/docs/skills.md +14 -10
  276. package/docs/task-steps.md +2 -2
  277. package/docs/tmux-agent-manager.md +1 -1
  278. package/docs/tool-repair.md +18 -1
  279. package/docs/usage.md +4 -2
  280. package/docs/worker-profiles.md +3 -3
  281. package/docs/worktree-sync.md +2 -2
  282. package/examples/extensions/custom-compaction.ts +5 -17
  283. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  284. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  285. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  286. package/examples/extensions/sandbox/package-lock.json +2 -2
  287. package/examples/extensions/sandbox/package.json +1 -1
  288. package/examples/extensions/summarize.ts +3 -5
  289. package/examples/extensions/with-deps/package-lock.json +2 -2
  290. package/examples/extensions/with-deps/package.json +1 -1
  291. package/examples/sdk/04-skills.ts +1 -1
  292. package/npm-shrinkwrap.json +12 -12
  293. package/package.json +4 -4
  294. package/dist/core/util/json-size.d.ts +0 -3
  295. package/dist/core/util/json-size.d.ts.map +0 -1
  296. package/dist/core/util/json-size.js +0 -95
  297. package/dist/core/util/json-size.js.map +0 -1
@@ -0,0 +1,79 @@
1
+ import { Type } from "typebox";
2
+ const skillSchema = Type.Object({
3
+ action: Type.Union([Type.Literal("search"), Type.Literal("load"), Type.Literal("unload"), Type.Literal("status")], { description: "search | load | unload | status" }),
4
+ query: Type.Optional(Type.String({ description: "search query" })),
5
+ name: Type.Optional(Type.String({ description: "exact load name" })),
6
+ }, { additionalProperties: false });
7
+ function searchText(result) {
8
+ if (result.candidates.length === 0)
9
+ return "skill search: no match";
10
+ return result.candidates.map((candidate) => `${candidate.name}: ${candidate.description}`).join("\n");
11
+ }
12
+ function statusText(result) {
13
+ if (result.state === "unloaded")
14
+ return `skill state: unloaded${result.reason ? `, ${result.reason}` : ""}`;
15
+ if (result.state === "loaded_pending")
16
+ return `skill state: loaded_pending, ${result.name}, applies next request`;
17
+ return `skill state: active, ${result.name}, idle ${Math.round(result.idleForMs ?? 0)}ms, expires ${Math.round(result.expiresInMs ?? 0)}ms`;
18
+ }
19
+ /** One compact agent surface over the host-owned skill lifecycle. */
20
+ export function createSkillVaultToolDefinition(vault) {
21
+ return {
22
+ name: "skill",
23
+ label: "skill",
24
+ description: "Skill vault. Specialist guidance useful: search, load exact name before work. Host injects body transiently, expires idle; unload optional.",
25
+ promptSnippet: "Search/load skill.",
26
+ parameters: skillSchema,
27
+ async execute(_toolCallId, input) {
28
+ switch (input.action) {
29
+ case "search": {
30
+ if (!input.query?.trim()) {
31
+ const result = { candidates: [] };
32
+ return {
33
+ content: [{ type: "text", text: "skill search requires query" }],
34
+ details: { action: "search", result },
35
+ isError: true,
36
+ };
37
+ }
38
+ const result = vault.search(input.query);
39
+ return {
40
+ content: [{ type: "text", text: searchText(result) }],
41
+ details: { action: "search", result },
42
+ };
43
+ }
44
+ case "load": {
45
+ const result = input.name?.trim()
46
+ ? vault.load(input.name.trim(), "model")
47
+ : { ok: false, reason: "not_found", message: "skill load requires exact name" };
48
+ return {
49
+ content: [
50
+ {
51
+ type: "text",
52
+ text: result.ok
53
+ ? `skill loaded: ${result.name}, applies next request`
54
+ : `skill load failed: ${result.message}`,
55
+ },
56
+ ],
57
+ details: { action: "load", result },
58
+ isError: !result.ok,
59
+ };
60
+ }
61
+ case "unload": {
62
+ const result = vault.unload();
63
+ return {
64
+ content: [{ type: "text", text: `skill unloaded: ${result.unloaded ?? "none"}` }],
65
+ details: { action: "unload", result },
66
+ };
67
+ }
68
+ case "status": {
69
+ const result = vault.status();
70
+ return {
71
+ content: [{ type: "text", text: statusText(result) }],
72
+ details: { action: "status", result },
73
+ };
74
+ }
75
+ }
76
+ },
77
+ };
78
+ }
79
+ //# sourceMappingURL=skill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill.js","sourceRoot":"","sources":["../../../src/core/tools/skill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAC9B;IACC,MAAM,EAAE,IAAI,CAAC,KAAK,CACjB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAC9F,EAAE,WAAW,EAAE,iCAAiC,EAAE,CAClD;IACD,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC;IAClE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC,CAAC;C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AM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;oBAC9B,OAAO;wBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,mBAAmB,MAAM,CAAC,QAAQ,IAAI,MAAM,EAAE,EAAE,CAAC;wBAC1F,OAAO,EAAE,EAAE,MAAM,EAAE,QAAiB,EAAE,MAAM,EAAE;qBAC9C,CAAC;gBACH,CAAC;gBACD,KAAK,QAAQ,EAAE,CAAC;oBACf,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;oBAC9B,OAAO;wBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;wBAC9D,OAAO,EAAE,EAAE,MAAM,EAAE,QAAiB,EAAE,MAAM,EAAE;qBAC9C,CAAC;gBACH,CAAC;YACF,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport type { SkillLoadResult, SkillSearchResult, SkillVaultController, SkillVaultStatus } from \"../skill-vault.ts\";\n\nconst skillSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[Type.Literal(\"search\"), Type.Literal(\"load\"), Type.Literal(\"unload\"), Type.Literal(\"status\")],\n\t\t\t{ description: \"search | load | unload | status\" },\n\t\t),\n\t\tquery: Type.Optional(Type.String({ description: \"search query\" })),\n\t\tname: Type.Optional(Type.String({ description: \"exact load name\" })),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type SkillToolInput = Static<typeof skillSchema>;\nexport type SkillToolDetails =\n\t| { action: \"search\"; result: SkillSearchResult }\n\t| { action: \"load\"; result: SkillLoadResult }\n\t| { action: \"unload\"; result: { ok: true; unloaded?: string } }\n\t| { action: \"status\"; result: SkillVaultStatus };\n\nfunction searchText(result: SkillSearchResult): string {\n\tif (result.candidates.length === 0) return \"skill search: no match\";\n\treturn result.candidates.map((candidate) => `${candidate.name}: ${candidate.description}`).join(\"\\n\");\n}\n\nfunction statusText(result: SkillVaultStatus): string {\n\tif (result.state === \"unloaded\") return `skill state: unloaded${result.reason ? `, ${result.reason}` : \"\"}`;\n\tif (result.state === \"loaded_pending\") return `skill state: loaded_pending, ${result.name}, applies next request`;\n\treturn `skill state: active, ${result.name}, idle ${Math.round(result.idleForMs ?? 0)}ms, expires ${Math.round(result.expiresInMs ?? 0)}ms`;\n}\n\n/** One compact agent surface over the host-owned skill lifecycle. */\nexport function createSkillVaultToolDefinition(vault: SkillVaultController): ToolDefinition<typeof skillSchema> {\n\treturn {\n\t\tname: \"skill\",\n\t\tlabel: \"skill\",\n\t\tdescription:\n\t\t\t\"Skill vault. Specialist guidance useful: search, load exact name before work. Host injects body transiently, expires idle; unload optional.\",\n\t\tpromptSnippet: \"Search/load skill.\",\n\t\tparameters: skillSchema,\n\t\tasync execute(_toolCallId, input) {\n\t\t\tswitch (input.action) {\n\t\t\t\tcase \"search\": {\n\t\t\t\t\tif (!input.query?.trim()) {\n\t\t\t\t\t\tconst result: SkillSearchResult = { candidates: [] };\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: \"skill search requires query\" }],\n\t\t\t\t\t\t\tdetails: { action: \"search\" as const, result },\n\t\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst result = vault.search(input.query);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: searchText(result) }],\n\t\t\t\t\t\tdetails: { action: \"search\" as const, result },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase \"load\": {\n\t\t\t\t\tconst result: SkillLoadResult = input.name?.trim()\n\t\t\t\t\t\t? vault.load(input.name.trim(), \"model\")\n\t\t\t\t\t\t: { ok: false, reason: \"not_found\", message: \"skill load requires exact name\" };\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\t\ttext: result.ok\n\t\t\t\t\t\t\t\t\t? `skill loaded: ${result.name}, applies next request`\n\t\t\t\t\t\t\t\t\t: `skill load failed: ${result.message}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: { action: \"load\" as const, result },\n\t\t\t\t\t\tisError: !result.ok,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase \"unload\": {\n\t\t\t\t\tconst result = vault.unload();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `skill unloaded: ${result.unloaded ?? \"none\"}` }],\n\t\t\t\t\t\tdetails: { action: \"unload\" as const, result },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase \"status\": {\n\t\t\t\t\tconst result = vault.status();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: statusText(result) }],\n\t\t\t\t\t\tdetails: { action: \"status\" as const, result },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
@@ -175,10 +175,10 @@ export function createTaskStepsToolDefinition(deps) {
175
175
  description: "Track the session's ordered multi-step checklist with status, notes, and evidence. Use goal for durable outcomes and delegate for workers.",
176
176
  promptSnippet: "Track multi-step session work.",
177
177
  promptGuidelines: [
178
- "Use for complex or explicitly tracked work; skip simple one-step work. Keep one step in_progress.",
179
- "Batch known transitions. Address the first open step; record evidence or a blocker, and never call only to narrate unchanged state.",
180
- "Use intake to preserve every supplied item; link steps to active goal requirementIds.",
181
- "Before final output, clear stale in_progress state and discuss or defer remaining work. Goal owns outcomes; delegate/delegate_status own workers.",
178
+ "Use for complex/explicitly tracked work, not one-step work. Keep one in_progress step.",
179
+ "Batch transitions. Address first open step; record evidence/blocker. Never call only to narrate unchanged state.",
180
+ "intake preserves every supplied item; link steps to active goal requirementIds.",
181
+ "Before final: clear stale in_progress, discuss/defer remainder. Goal owns outcomes; delegate owns workers.",
182
182
  ],
183
183
  parameters: taskStepsSchema,
184
184
  renderShell: "self",
@@ -1 +1 @@
1
- {"version":3,"file":"task-steps.js","sourceRoot":"","sources":["../../../src/core/tools/task-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,cAAc,EACd,uBAAuB,EACvB,YAAY,EAIZ,cAAc,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,sBAAsB,EACtB,2BAA2B,EAE3B,gBAAgB,GAChB,MAAM,0BAA0B,CAAC;AAElC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC;IAC/B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IAC3B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IACzB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAEvG,SAAS,sBAAsB,CAAC,yBAAiC;IAChE,OAAO;QACN,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QACnC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;QACvC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAA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AG,WAAW;wBACd,aAAa,EAAE,KAAK,CAAC,aAAa;wBAClC,iBAAiB,EAAE,eAAe;wBAClC,cAAc,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;qBACvC;iBAChC,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;YACnG,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport {\n\taddTaskStep,\n\tclearTaskSteps,\n\tcompactTaskSteps,\n\tcreateTaskStepsState,\n\tfindOpenDuplicateStep,\n\tformatTaskSteps,\n\thasUnverifiedCompletedStep,\n\tMAX_TASK_STEPS,\n\tresolveTaskStepSelector,\n\tsetTaskSteps,\n\ttype TaskStep,\n\ttype TaskStepInput,\n\ttype TaskStepsState,\n\tupdateTaskStep,\n} from \"../tasks/task-state.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n\ttaskStepPanelRow,\n} from \"./orchestration-panel.ts\";\n\nconst statusSchema = Type.Union([\n\tType.Literal(\"pending\"),\n\tType.Literal(\"in_progress\"),\n\tType.Literal(\"completed\"),\n\tType.Literal(\"blocked\"),\n\tType.Literal(\"cancelled\"),\n]);\n\nconst prioritySchema = Type.Union([Type.Literal(\"low\"), Type.Literal(\"normal\"), Type.Literal(\"high\")]);\n\nfunction optionalTaskStepFields(requirementIdsDescription: string) {\n\treturn {\n\t\tstatus: Type.Optional(statusSchema),\n\t\tpriority: Type.Optional(prioritySchema),\n\t\towner: Type.Optional(Type.String({ maxLength: 200 })),\n\t\trequirementIds: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1, maxLength: 200 }), {\n\t\t\t\tmaxItems: 32,\n\t\t\t\tdescription: requirementIdsDescription,\n\t\t\t}),\n\t\t),\n\t\tnote: Type.Optional(Type.String({ maxLength: 4_000 })),\n\t\tevidence: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 2_000 }), { maxItems: 32 })),\n\t};\n}\n\nconst stepInputSchema = Type.Object(\n\t{\n\t\tcontent: Type.String({ minLength: 1, maxLength: 2_000, description: \"Imperative task step text.\" }),\n\t\tactiveForm: Type.Optional(\n\t\t\tType.String({ minLength: 1, maxLength: 2_000, description: \"Short present-progress label for active UI.\" }),\n\t\t),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances.\"),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst taskStepsSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"set\"),\n\t\t\t\tType.Literal(\"add\"),\n\t\t\t\tType.Literal(\"update\"),\n\t\t\t\tType.Literal(\"list\"),\n\t\t\t\tType.Literal(\"clear\"),\n\t\t\t\tType.Literal(\"compact\"),\n\t\t\t\tType.Literal(\"intake\"),\n\t\t\t],\n\t\t\t{ description: \"Checklist action. Use list to read without mutation.\" },\n\t\t),\n\t\tsteps: Type.Optional(\n\t\t\tType.Array(stepInputSchema, {\n\t\t\t\tmaxItems: MAX_TASK_STEPS,\n\t\t\t\tdescription: \"Complete replacement list for set/intake. Intake preserves every supplied item in order.\",\n\t\t\t}),\n\t\t),\n\t\tid: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"For update: current/active, exact step id, unique id prefix, or unique content selector.\",\n\t\t\t}),\n\t\t),\n\t\tcontent: Type.Optional(Type.String({ minLength: 1, maxLength: 2_000 })),\n\t\tactiveForm: Type.Optional(Type.String({ maxLength: 2_000 })),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances; [] clears existing links.\"),\n\t\tclearCompleted: Type.Optional(\n\t\t\tType.Boolean({ description: \"For list: compact completed and cancelled steps before rendering.\" }),\n\t\t),\n\t\tshowCompleted: Type.Optional(Type.Boolean({ description: \"Include completed and cancelled steps in output.\" })),\n\t\tmaxItems: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_TASK_STEPS })),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type TaskStepsToolInput = Static<typeof taskStepsSchema>;\nexport type TaskStepsAction = TaskStepsToolInput[\"action\"];\n\nexport interface TaskStepsToolDetails {\n\taction: TaskStepsAction;\n\tapplied: boolean;\n\terror?: string;\n\tstate?: TaskStepsState;\n\tstepCount?: number;\n\topenStepCount?: number;\n\tverificationNudgeNeeded?: boolean;\n\tshowCompleted?: boolean;\n\t/** Set when `add` was a no-op because an open step already carries this content. */\n\tduplicateOfStepId?: string;\n\t/** Step ids silently demoted to pending because another step became active in this call. */\n\tdemotedStepIds?: readonly string[];\n}\n\nexport interface TaskStepsToolDependencies {\n\tgetTaskStepsState: () => TaskStepsState | undefined;\n\tsaveTaskStepsState: (state: TaskStepsState) => void;\n\tnow?: () => string;\n}\n\nfunction toTaskStepInput(input: TaskStepsToolInput): TaskStepInput {\n\treturn {\n\t\tcontent: input.content ?? \"\",\n\t\tactiveForm: input.activeForm,\n\t\tstatus: input.status,\n\t\tpriority: input.priority,\n\t\towner: input.owner,\n\t\trequirementIds: input.requirementIds,\n\t\tnote: input.note,\n\t\tevidence: input.evidence,\n\t};\n}\n\nfunction counts(\n\tstate: TaskStepsState,\n): Pick<TaskStepsToolDetails, \"stepCount\" | \"openStepCount\" | \"verificationNudgeNeeded\"> {\n\tconst openStepCount = state.steps.filter(\n\t\t(step) => step.status !== \"completed\" && step.status !== \"cancelled\",\n\t).length;\n\treturn {\n\t\tstepCount: state.steps.length,\n\t\topenStepCount,\n\t\tverificationNudgeNeeded: hasUnverifiedCompletedStep(state),\n\t};\n}\n\n/** Ids (from `resultSteps`, index-aligned with `inputs`) whose status was set explicitly by the caller. */\nfunction explicitStatusStepIds(inputs: readonly TaskStepInput[], resultSteps: readonly TaskStep[]): Set<string> {\n\tconst ids = new Set<string>();\n\tinputs.forEach((stepInput, index) => {\n\t\tif (stepInput.status !== undefined) {\n\t\t\tconst id = resultSteps[index]?.id;\n\t\t\tif (id) ids.add(id);\n\t\t}\n\t});\n\treturn ids;\n}\n\n/**\n * Steps that were in_progress before this call and are pending after, excluding any step whose\n * new status was set explicitly by the caller (an explicit change is not a \"silent\" demotion).\n */\nfunction computeDemotedStepIds(\n\tbefore: TaskStepsState,\n\tafter: TaskStepsState,\n\texcludeIds: ReadonlySet<string>,\n): string[] {\n\tconst beforeActiveIds = new Set(before.steps.filter((step) => step.status === \"in_progress\").map((step) => step.id));\n\treturn after.steps\n\t\t.filter((step) => beforeActiveIds.has(step.id) && step.status === \"pending\" && !excludeIds.has(step.id))\n\t\t.map((step) => step.id);\n}\n\nfunction errorResult(action: TaskStepsAction, error: string, state?: TaskStepsState) {\n\treturn {\n\t\tcontent: [{ type: \"text\" as const, text: `task_steps ${action} failed: ${error}` }],\n\t\tdetails: { action, applied: false, error, state, ...(state ? counts(state) : {}) } satisfies TaskStepsToolDetails,\n\t};\n}\n\nfunction taskStepsPanelModel(details: TaskStepsToolDetails, expanded: boolean): OrchestrationPanelModel {\n\tconst state = details.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"task steps\",\n\t\t\taction: details.action,\n\t\t\tstatus: details.error ? \"error\" : \"idle\",\n\t\t\temptyText: details.error ?? \"No checklist state.\",\n\t\t};\n\t}\n\tconst active = state.steps.filter((step) => step.status === \"in_progress\");\n\tconst blocked = state.steps.filter((step) => step.status === \"blocked\");\n\tconst pending = state.steps.filter((step) => step.status === \"pending\");\n\tconst completed = state.steps.filter((step) => step.status === \"completed\");\n\tconst cancelled = state.steps.filter((step) => step.status === \"cancelled\");\n\tconst open = [...active, ...blocked, ...pending];\n\tconst terminal = details.showCompleted ? [...completed, ...cancelled] : [];\n\tconst candidates = [...open, ...terminal];\n\tconst limit = expanded ? 24 : 8;\n\tconst rows = candidates.slice(0, limit).map(taskStepPanelRow);\n\tconst archivedDone = state.archive.completed + state.archive.cancelled;\n\tconst done = completed.length + state.archive.completed;\n\tconst summary = [\n\t\tactive.length ? `${active.length} working` : undefined,\n\t\t`${open.length} open`,\n\t\t`${done} done`,\n\t\tblocked.length ? `${blocked.length} blocked` : undefined,\n\t\tarchivedDone ? `${archivedDone} archived` : undefined,\n\t].filter((value): value is string => value !== undefined);\n\tconst notices = [];\n\tif (!details.showCompleted && completed.length + cancelled.length > 0) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${completed.length + cancelled.length} finished step${completed.length + cancelled.length === 1 ? \"\" : \"s\"} hidden`,\n\t\t});\n\t}\n\tif (details.duplicateOfStepId) {\n\t\tnotices.push({ status: \"info\" as const, text: \"Duplicate open step ignored.\" });\n\t}\n\tif (details.demotedStepIds?.length) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${details.demotedStepIds.length} previous working step${details.demotedStepIds.length === 1 ? \"\" : \"s\"} returned to pending.`,\n\t\t});\n\t}\n\tif (details.verificationNudgeNeeded) {\n\t\tnotices.push({ status: \"warning\" as const, text: \"Completed work still needs attached evidence.\" });\n\t}\n\tconst status = details.error\n\t\t? \"error\"\n\t\t: blocked.length > 0\n\t\t\t? \"warning\"\n\t\t\t: active.length > 0\n\t\t\t\t? \"running\"\n\t\t\t\t: open.length === 0 && state.steps.length > 0\n\t\t\t\t\t? \"success\"\n\t\t\t\t\t: \"idle\";\n\treturn {\n\t\tlabel: \"task steps\",\n\t\taction: details.action,\n\t\tstatus,\n\t\tsummary,\n\t\trows,\n\t\tnotices,\n\t\temptyText: state.steps.length === 0 ? \"No tracked steps.\" : \"All open steps are done.\",\n\t\thiddenRowCount: Math.max(0, candidates.length - rows.length),\n\t};\n}\n\nexport function createTaskStepsToolDefinition(deps: TaskStepsToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"task_steps\",\n\t\tlabel: \"Task Steps\",\n\t\tdescription:\n\t\t\t\"Track the session's ordered multi-step checklist with status, notes, and evidence. Use goal for durable outcomes and delegate for workers.\",\n\t\tpromptSnippet: \"Track multi-step session work.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use for complex or explicitly tracked work; skip simple one-step work. Keep one step in_progress.\",\n\t\t\t\"Batch known transitions. Address the first open step; record evidence or a blocker, and never call only to narrate unchanged state.\",\n\t\t\t\"Use intake to preserve every supplied item; link steps to active goal requirementIds.\",\n\t\t\t\"Before final output, clear stale in_progress state and discuss or defer remaining work. Goal owns outcomes; delegate/delegate_status own workers.\",\n\t\t],\n\t\tparameters: taskStepsSchema,\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tif (isPartial) return emptyOrchestrationCall();\n\t\t\tconst details = result.details as TaskStepsToolDetails | undefined;\n\t\t\tif (!details) {\n\t\t\t\treturn new OrchestrationPanelComponent(theme, {\n\t\t\t\t\tlabel: \"task steps\",\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\temptyText: \"No task-step details were returned.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (!expanded && details.applied) return emptyOrchestrationCall();\n\t\t\treturn new OrchestrationPanelComponent(theme, taskStepsPanelModel(details, expanded), expanded);\n\t\t},\n\t\tasync execute(_toolCallId, input: TaskStepsToolInput) {\n\t\t\tconst timestamp = now();\n\t\t\tconst current = deps.getTaskStepsState();\n\t\t\tconst before = current ?? createTaskStepsState(timestamp);\n\t\t\tlet state = before;\n\t\t\tlet duplicateStepId: string | undefined;\n\t\t\tlet demotedStepIds: readonly string[] = [];\n\t\t\ttry {\n\t\t\t\tswitch (input.action) {\n\t\t\t\t\tcase \"set\":\n\t\t\t\t\t\tif (!input.steps) return errorResult(input.action, \"set requires steps[].\", current);\n\t\t\t\t\t\tstate = setTaskSteps(state, input.steps, timestamp);\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(\n\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\texplicitStatusStepIds(input.steps, state.steps),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"intake\":\n\t\t\t\t\t\tif (!input.steps)\n\t\t\t\t\t\t\treturn errorResult(input.action, \"intake requires a complete steps[] list.\", current);\n\t\t\t\t\t\tstate = setTaskSteps(state, input.steps, timestamp);\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(\n\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\texplicitStatusStepIds(input.steps, state.steps),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"add\":\n\t\t\t\t\t\tstate = addTaskStep(state, toTaskStepInput(input), timestamp);\n\t\t\t\t\t\tif (state === before) {\n\t\t\t\t\t\t\t// The reducer returned the unchanged state: an open step already carries this\n\t\t\t\t\t\t\t// content, so nothing was created. Name the existing step in the response.\n\t\t\t\t\t\t\tduplicateStepId = findOpenDuplicateStep(before.steps, input.content ?? \"\")?.id;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"update\": {\n\t\t\t\t\t\tif (!input.id?.trim())\n\t\t\t\t\t\t\treturn errorResult(input.action, \"update requires id or a unique selector.\", current);\n\t\t\t\t\t\tconst selected = resolveTaskStepSelector(before.steps, input.id);\n\t\t\t\t\t\tstate = updateTaskStep(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tinput.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: input.content,\n\t\t\t\t\t\t\t\tactiveForm: input.activeForm,\n\t\t\t\t\t\t\t\tstatus: input.status,\n\t\t\t\t\t\t\t\tpriority: input.priority,\n\t\t\t\t\t\t\t\towner: input.owner,\n\t\t\t\t\t\t\t\trequirementIds: input.requirementIds,\n\t\t\t\t\t\t\t\tnote: input.note,\n\t\t\t\t\t\t\t\tevidence: input.evidence,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// Exclude the explicitly targeted step: its own status change was requested by\n\t\t\t\t\t\t// the caller, so it is never a \"silent\" demotion even if it moved to pending.\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(before, state, new Set([selected.id]));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"clear\":\n\t\t\t\t\t\tstate = clearTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"compact\":\n\t\t\t\t\t\tstate = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\tif (input.clearCompleted) state = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst isNoopDuplicateAdd = input.action === \"add\" && state === before;\n\t\t\t\tconst mutated = (input.action !== \"list\" || input.clearCompleted === true) && !isNoopDuplicateAdd;\n\t\t\t\tif (mutated) deps.saveTaskStepsState(state);\n\n\t\t\t\tconst stateCounts = counts(state);\n\t\t\t\tconst noticeLines: string[] = [];\n\t\t\t\tif (duplicateStepId) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t`Duplicate open step ignored; existing ${duplicateStepId} already tracks this content.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (demotedStepIds.length > 0) {\n\t\t\t\t\tnoticeLines.push(`Demoted to pending because another step became active: ${demotedStepIds.join(\", \")}.`);\n\t\t\t\t}\n\t\t\t\tif (stateCounts.verificationNudgeNeeded) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t\"Reminder: a completed step has no evidence attached; attach evidence via update before treating it as verified.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst notices = noticeLines.length > 0 ? `\\n${noticeLines.join(\"\\n\")}` : \"\";\n\n\t\t\t\tconst headerAction =\n\t\t\t\t\tinput.action === \"list\"\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: `task_steps ${input.action} ${duplicateStepId ? \"ignored (duplicate)\" : \"recorded\"}.\\n`;\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `${headerAction}${formatTaskSteps(state, {\n\t\t\t\t\t\t\t\tincludeTerminal: input.showCompleted,\n\t\t\t\t\t\t\t\tmaxItems: input.maxItems,\n\t\t\t\t\t\t\t})}${notices}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\taction: input.action,\n\t\t\t\t\t\tapplied: true,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t...stateCounts,\n\t\t\t\t\t\tshowCompleted: input.showCompleted,\n\t\t\t\t\t\tduplicateOfStepId: duplicateStepId,\n\t\t\t\t\t\tdemotedStepIds: demotedStepIds.length > 0 ? demotedStepIds : undefined,\n\t\t\t\t\t} satisfies TaskStepsToolDetails,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn errorResult(input.action, error instanceof Error ? error.message : String(error), current);\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"task-steps.js","sourceRoot":"","sources":["../../../src/core/tools/task-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,cAAc,EACd,uBAAuB,EACvB,YAAY,EAIZ,cAAc,GACd,MA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ACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport {\n\taddTaskStep,\n\tclearTaskSteps,\n\tcompactTaskSteps,\n\tcreateTaskStepsState,\n\tfindOpenDuplicateStep,\n\tformatTaskSteps,\n\thasUnverifiedCompletedStep,\n\tMAX_TASK_STEPS,\n\tresolveTaskStepSelector,\n\tsetTaskSteps,\n\ttype TaskStep,\n\ttype TaskStepInput,\n\ttype TaskStepsState,\n\tupdateTaskStep,\n} from \"../tasks/task-state.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n\ttaskStepPanelRow,\n} from \"./orchestration-panel.ts\";\n\nconst statusSchema = Type.Union([\n\tType.Literal(\"pending\"),\n\tType.Literal(\"in_progress\"),\n\tType.Literal(\"completed\"),\n\tType.Literal(\"blocked\"),\n\tType.Literal(\"cancelled\"),\n]);\n\nconst prioritySchema = Type.Union([Type.Literal(\"low\"), Type.Literal(\"normal\"), Type.Literal(\"high\")]);\n\nfunction optionalTaskStepFields(requirementIdsDescription: string) {\n\treturn {\n\t\tstatus: Type.Optional(statusSchema),\n\t\tpriority: Type.Optional(prioritySchema),\n\t\towner: Type.Optional(Type.String({ maxLength: 200 })),\n\t\trequirementIds: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1, maxLength: 200 }), {\n\t\t\t\tmaxItems: 32,\n\t\t\t\tdescription: requirementIdsDescription,\n\t\t\t}),\n\t\t),\n\t\tnote: Type.Optional(Type.String({ maxLength: 4_000 })),\n\t\tevidence: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 2_000 }), { maxItems: 32 })),\n\t};\n}\n\nconst stepInputSchema = Type.Object(\n\t{\n\t\tcontent: Type.String({ minLength: 1, maxLength: 2_000, description: \"Imperative task step text.\" }),\n\t\tactiveForm: Type.Optional(\n\t\t\tType.String({ minLength: 1, maxLength: 2_000, description: \"Short present-progress label for active UI.\" }),\n\t\t),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances.\"),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst taskStepsSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"set\"),\n\t\t\t\tType.Literal(\"add\"),\n\t\t\t\tType.Literal(\"update\"),\n\t\t\t\tType.Literal(\"list\"),\n\t\t\t\tType.Literal(\"clear\"),\n\t\t\t\tType.Literal(\"compact\"),\n\t\t\t\tType.Literal(\"intake\"),\n\t\t\t],\n\t\t\t{ description: \"Checklist action. Use list to read without mutation.\" },\n\t\t),\n\t\tsteps: Type.Optional(\n\t\t\tType.Array(stepInputSchema, {\n\t\t\t\tmaxItems: MAX_TASK_STEPS,\n\t\t\t\tdescription: \"Complete replacement list for set/intake. Intake preserves every supplied item in order.\",\n\t\t\t}),\n\t\t),\n\t\tid: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"For update: current/active, exact step id, unique id prefix, or unique content selector.\",\n\t\t\t}),\n\t\t),\n\t\tcontent: Type.Optional(Type.String({ minLength: 1, maxLength: 2_000 })),\n\t\tactiveForm: Type.Optional(Type.String({ maxLength: 2_000 })),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances; [] clears existing links.\"),\n\t\tclearCompleted: Type.Optional(\n\t\t\tType.Boolean({ description: \"For list: compact completed and cancelled steps before rendering.\" }),\n\t\t),\n\t\tshowCompleted: Type.Optional(Type.Boolean({ description: \"Include completed and cancelled steps in output.\" })),\n\t\tmaxItems: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_TASK_STEPS })),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type TaskStepsToolInput = Static<typeof taskStepsSchema>;\nexport type TaskStepsAction = TaskStepsToolInput[\"action\"];\n\nexport interface TaskStepsToolDetails {\n\taction: TaskStepsAction;\n\tapplied: boolean;\n\terror?: string;\n\tstate?: TaskStepsState;\n\tstepCount?: number;\n\topenStepCount?: number;\n\tverificationNudgeNeeded?: boolean;\n\tshowCompleted?: boolean;\n\t/** Set when `add` was a no-op because an open step already carries this content. */\n\tduplicateOfStepId?: string;\n\t/** Step ids silently demoted to pending because another step became active in this call. */\n\tdemotedStepIds?: readonly string[];\n}\n\nexport interface TaskStepsToolDependencies {\n\tgetTaskStepsState: () => TaskStepsState | undefined;\n\tsaveTaskStepsState: (state: TaskStepsState) => void;\n\tnow?: () => string;\n}\n\nfunction toTaskStepInput(input: TaskStepsToolInput): TaskStepInput {\n\treturn {\n\t\tcontent: input.content ?? \"\",\n\t\tactiveForm: input.activeForm,\n\t\tstatus: input.status,\n\t\tpriority: input.priority,\n\t\towner: input.owner,\n\t\trequirementIds: input.requirementIds,\n\t\tnote: input.note,\n\t\tevidence: input.evidence,\n\t};\n}\n\nfunction counts(\n\tstate: TaskStepsState,\n): Pick<TaskStepsToolDetails, \"stepCount\" | \"openStepCount\" | \"verificationNudgeNeeded\"> {\n\tconst openStepCount = state.steps.filter(\n\t\t(step) => step.status !== \"completed\" && step.status !== \"cancelled\",\n\t).length;\n\treturn {\n\t\tstepCount: state.steps.length,\n\t\topenStepCount,\n\t\tverificationNudgeNeeded: hasUnverifiedCompletedStep(state),\n\t};\n}\n\n/** Ids (from `resultSteps`, index-aligned with `inputs`) whose status was set explicitly by the caller. */\nfunction explicitStatusStepIds(inputs: readonly TaskStepInput[], resultSteps: readonly TaskStep[]): Set<string> {\n\tconst ids = new Set<string>();\n\tinputs.forEach((stepInput, index) => {\n\t\tif (stepInput.status !== undefined) {\n\t\t\tconst id = resultSteps[index]?.id;\n\t\t\tif (id) ids.add(id);\n\t\t}\n\t});\n\treturn ids;\n}\n\n/**\n * Steps that were in_progress before this call and are pending after, excluding any step whose\n * new status was set explicitly by the caller (an explicit change is not a \"silent\" demotion).\n */\nfunction computeDemotedStepIds(\n\tbefore: TaskStepsState,\n\tafter: TaskStepsState,\n\texcludeIds: ReadonlySet<string>,\n): string[] {\n\tconst beforeActiveIds = new Set(before.steps.filter((step) => step.status === \"in_progress\").map((step) => step.id));\n\treturn after.steps\n\t\t.filter((step) => beforeActiveIds.has(step.id) && step.status === \"pending\" && !excludeIds.has(step.id))\n\t\t.map((step) => step.id);\n}\n\nfunction errorResult(action: TaskStepsAction, error: string, state?: TaskStepsState) {\n\treturn {\n\t\tcontent: [{ type: \"text\" as const, text: `task_steps ${action} failed: ${error}` }],\n\t\tdetails: { action, applied: false, error, state, ...(state ? counts(state) : {}) } satisfies TaskStepsToolDetails,\n\t};\n}\n\nfunction taskStepsPanelModel(details: TaskStepsToolDetails, expanded: boolean): OrchestrationPanelModel {\n\tconst state = details.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"task steps\",\n\t\t\taction: details.action,\n\t\t\tstatus: details.error ? \"error\" : \"idle\",\n\t\t\temptyText: details.error ?? \"No checklist state.\",\n\t\t};\n\t}\n\tconst active = state.steps.filter((step) => step.status === \"in_progress\");\n\tconst blocked = state.steps.filter((step) => step.status === \"blocked\");\n\tconst pending = state.steps.filter((step) => step.status === \"pending\");\n\tconst completed = state.steps.filter((step) => step.status === \"completed\");\n\tconst cancelled = state.steps.filter((step) => step.status === \"cancelled\");\n\tconst open = [...active, ...blocked, ...pending];\n\tconst terminal = details.showCompleted ? [...completed, ...cancelled] : [];\n\tconst candidates = [...open, ...terminal];\n\tconst limit = expanded ? 24 : 8;\n\tconst rows = candidates.slice(0, limit).map(taskStepPanelRow);\n\tconst archivedDone = state.archive.completed + state.archive.cancelled;\n\tconst done = completed.length + state.archive.completed;\n\tconst summary = [\n\t\tactive.length ? `${active.length} working` : undefined,\n\t\t`${open.length} open`,\n\t\t`${done} done`,\n\t\tblocked.length ? `${blocked.length} blocked` : undefined,\n\t\tarchivedDone ? `${archivedDone} archived` : undefined,\n\t].filter((value): value is string => value !== undefined);\n\tconst notices = [];\n\tif (!details.showCompleted && completed.length + cancelled.length > 0) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${completed.length + cancelled.length} finished step${completed.length + cancelled.length === 1 ? \"\" : \"s\"} hidden`,\n\t\t});\n\t}\n\tif (details.duplicateOfStepId) {\n\t\tnotices.push({ status: \"info\" as const, text: \"Duplicate open step ignored.\" });\n\t}\n\tif (details.demotedStepIds?.length) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${details.demotedStepIds.length} previous working step${details.demotedStepIds.length === 1 ? \"\" : \"s\"} returned to pending.`,\n\t\t});\n\t}\n\tif (details.verificationNudgeNeeded) {\n\t\tnotices.push({ status: \"warning\" as const, text: \"Completed work still needs attached evidence.\" });\n\t}\n\tconst status = details.error\n\t\t? \"error\"\n\t\t: blocked.length > 0\n\t\t\t? \"warning\"\n\t\t\t: active.length > 0\n\t\t\t\t? \"running\"\n\t\t\t\t: open.length === 0 && state.steps.length > 0\n\t\t\t\t\t? \"success\"\n\t\t\t\t\t: \"idle\";\n\treturn {\n\t\tlabel: \"task steps\",\n\t\taction: details.action,\n\t\tstatus,\n\t\tsummary,\n\t\trows,\n\t\tnotices,\n\t\temptyText: state.steps.length === 0 ? \"No tracked steps.\" : \"All open steps are done.\",\n\t\thiddenRowCount: Math.max(0, candidates.length - rows.length),\n\t};\n}\n\nexport function createTaskStepsToolDefinition(deps: TaskStepsToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"task_steps\",\n\t\tlabel: \"Task Steps\",\n\t\tdescription:\n\t\t\t\"Track the session's ordered multi-step checklist with status, notes, and evidence. Use goal for durable outcomes and delegate for workers.\",\n\t\tpromptSnippet: \"Track multi-step session work.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use for complex/explicitly tracked work, not one-step work. Keep one in_progress step.\",\n\t\t\t\"Batch transitions. Address first open step; record evidence/blocker. Never call only to narrate unchanged state.\",\n\t\t\t\"intake preserves every supplied item; link steps to active goal requirementIds.\",\n\t\t\t\"Before final: clear stale in_progress, discuss/defer remainder. Goal owns outcomes; delegate owns workers.\",\n\t\t],\n\t\tparameters: taskStepsSchema,\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tif (isPartial) return emptyOrchestrationCall();\n\t\t\tconst details = result.details as TaskStepsToolDetails | undefined;\n\t\t\tif (!details) {\n\t\t\t\treturn new OrchestrationPanelComponent(theme, {\n\t\t\t\t\tlabel: \"task steps\",\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\temptyText: \"No task-step details were returned.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (!expanded && details.applied) return emptyOrchestrationCall();\n\t\t\treturn new OrchestrationPanelComponent(theme, taskStepsPanelModel(details, expanded), expanded);\n\t\t},\n\t\tasync execute(_toolCallId, input: TaskStepsToolInput) {\n\t\t\tconst timestamp = now();\n\t\t\tconst current = deps.getTaskStepsState();\n\t\t\tconst before = current ?? createTaskStepsState(timestamp);\n\t\t\tlet state = before;\n\t\t\tlet duplicateStepId: string | undefined;\n\t\t\tlet demotedStepIds: readonly string[] = [];\n\t\t\ttry {\n\t\t\t\tswitch (input.action) {\n\t\t\t\t\tcase \"set\":\n\t\t\t\t\t\tif (!input.steps) return errorResult(input.action, \"set requires steps[].\", current);\n\t\t\t\t\t\tstate = setTaskSteps(state, input.steps, timestamp);\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(\n\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\texplicitStatusStepIds(input.steps, state.steps),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"intake\":\n\t\t\t\t\t\tif (!input.steps)\n\t\t\t\t\t\t\treturn errorResult(input.action, \"intake requires a complete steps[] list.\", current);\n\t\t\t\t\t\tstate = setTaskSteps(state, input.steps, timestamp);\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(\n\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\texplicitStatusStepIds(input.steps, state.steps),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"add\":\n\t\t\t\t\t\tstate = addTaskStep(state, toTaskStepInput(input), timestamp);\n\t\t\t\t\t\tif (state === before) {\n\t\t\t\t\t\t\t// The reducer returned the unchanged state: an open step already carries this\n\t\t\t\t\t\t\t// content, so nothing was created. Name the existing step in the response.\n\t\t\t\t\t\t\tduplicateStepId = findOpenDuplicateStep(before.steps, input.content ?? \"\")?.id;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"update\": {\n\t\t\t\t\t\tif (!input.id?.trim())\n\t\t\t\t\t\t\treturn errorResult(input.action, \"update requires id or a unique selector.\", current);\n\t\t\t\t\t\tconst selected = resolveTaskStepSelector(before.steps, input.id);\n\t\t\t\t\t\tstate = updateTaskStep(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tinput.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: input.content,\n\t\t\t\t\t\t\t\tactiveForm: input.activeForm,\n\t\t\t\t\t\t\t\tstatus: input.status,\n\t\t\t\t\t\t\t\tpriority: input.priority,\n\t\t\t\t\t\t\t\towner: input.owner,\n\t\t\t\t\t\t\t\trequirementIds: input.requirementIds,\n\t\t\t\t\t\t\t\tnote: input.note,\n\t\t\t\t\t\t\t\tevidence: input.evidence,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// Exclude the explicitly targeted step: its own status change was requested by\n\t\t\t\t\t\t// the caller, so it is never a \"silent\" demotion even if it moved to pending.\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(before, state, new Set([selected.id]));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"clear\":\n\t\t\t\t\t\tstate = clearTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"compact\":\n\t\t\t\t\t\tstate = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\tif (input.clearCompleted) state = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst isNoopDuplicateAdd = input.action === \"add\" && state === before;\n\t\t\t\tconst mutated = (input.action !== \"list\" || input.clearCompleted === true) && !isNoopDuplicateAdd;\n\t\t\t\tif (mutated) deps.saveTaskStepsState(state);\n\n\t\t\t\tconst stateCounts = counts(state);\n\t\t\t\tconst noticeLines: string[] = [];\n\t\t\t\tif (duplicateStepId) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t`Duplicate open step ignored; existing ${duplicateStepId} already tracks this content.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (demotedStepIds.length > 0) {\n\t\t\t\t\tnoticeLines.push(`Demoted to pending because another step became active: ${demotedStepIds.join(\", \")}.`);\n\t\t\t\t}\n\t\t\t\tif (stateCounts.verificationNudgeNeeded) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t\"Reminder: a completed step has no evidence attached; attach evidence via update before treating it as verified.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst notices = noticeLines.length > 0 ? `\\n${noticeLines.join(\"\\n\")}` : \"\";\n\n\t\t\t\tconst headerAction =\n\t\t\t\t\tinput.action === \"list\"\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: `task_steps ${input.action} ${duplicateStepId ? \"ignored (duplicate)\" : \"recorded\"}.\\n`;\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `${headerAction}${formatTaskSteps(state, {\n\t\t\t\t\t\t\t\tincludeTerminal: input.showCompleted,\n\t\t\t\t\t\t\t\tmaxItems: input.maxItems,\n\t\t\t\t\t\t\t})}${notices}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\taction: input.action,\n\t\t\t\t\t\tapplied: true,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t...stateCounts,\n\t\t\t\t\t\tshowCompleted: input.showCompleted,\n\t\t\t\t\t\tduplicateOfStepId: duplicateStepId,\n\t\t\t\t\t\tdemotedStepIds: demotedStepIds.length > 0 ? demotedStepIds : undefined,\n\t\t\t\t\t} satisfies TaskStepsToolDetails,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn errorResult(input.action, error instanceof Error ? error.message : String(error), current);\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tool-definition-wrapper.d.ts","sourceRoot":"","sources":["../../../src/core/tools/tool-definition-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE/E,oEAAoE;AACpE,wBAAgB,kBAAkB,CAAC,QAAQ,GAAG,OAAO,EACpD,UAAU,EAAE,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC,EACzC,UAAU,CAAC,EAAE,MAAM,gBAAgB,GACjC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,CAY1B;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAClC,WAAW,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EACvC,UAAU,CAAC,EAAE,MAAM,gBAAgB,GACjC,SAAS,CAAC,GAAG,CAAC,EAAE,CAElB;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAWpG"}
1
+ {"version":3,"file":"tool-definition-wrapper.d.ts","sourceRoot":"","sources":["../../../src/core/tools/tool-definition-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE/E,oEAAoE;AACpE,wBAAgB,kBAAkB,CAAC,QAAQ,GAAG,OAAO,EACpD,UAAU,EAAE,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC,EACzC,UAAU,CAAC,EAAE,MAAM,gBAAgB,GACjC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,CAa1B;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAClC,WAAW,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EACvC,UAAU,CAAC,EAAE,MAAM,gBAAgB,GACjC,SAAS,CAAC,GAAG,CAAC,EAAE,CAElB;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAYpG"}
@@ -4,6 +4,7 @@ export function wrapToolDefinition(definition, ctxFactory) {
4
4
  name: definition.name,
5
5
  label: definition.label,
6
6
  description: definition.description,
7
+ providerDescription: definition.promptSnippet,
7
8
  parameters: definition.parameters,
8
9
  prepareArguments: definition.prepareArguments,
9
10
  failureRecovery: definition.failureRecovery,
@@ -26,6 +27,7 @@ export function createToolDefinitionFromAgentTool(tool) {
26
27
  name: tool.name,
27
28
  label: tool.label,
28
29
  description: tool.description,
30
+ promptSnippet: tool.providerDescription,
29
31
  parameters: tool.parameters,
30
32
  prepareArguments: tool.prepareArguments,
31
33
  failureRecovery: tool.failureRecovery,
@@ -1 +1 @@
1
- {"version":3,"file":"tool-definition-wrapper.js","sourceRoot":"","sources":["../../../src/core/tools/tool-definition-wrapper.ts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AE,QAAQ,CAAC;KAC3G,CAAC;AACH,CAAC","sourcesContent":["import type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\n\n/** Wrap a ToolDefinition into an AgentTool for the core runtime. */\nexport function wrapToolDefinition<TDetails = unknown>(\n\tdefinition: ToolDefinition<any, TDetails>,\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<any, TDetails> {\n\treturn {\n\t\tname: definition.name,\n\t\tlabel: definition.label,\n\t\tdescription: definition.description,\n\t\tparameters: definition.parameters,\n\t\tprepareArguments: definition.prepareArguments,\n\t\tfailureRecovery: definition.failureRecovery,\n\t\texecutionMode: definition.executionMode,\n\t\texecute: (toolCallId, params, signal, onUpdate) =>\n\t\t\tdefinition.execute(toolCallId, params, signal, onUpdate, ctxFactory?.() as ExtensionContext),\n\t};\n}\n\n/** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */\nexport function wrapToolDefinitions(\n\tdefinitions: ToolDefinition<any, any>[],\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<any>[] {\n\treturn definitions.map((definition) => wrapToolDefinition(definition, ctxFactory));\n}\n\n/**\n * Synthesize a minimal ToolDefinition from an AgentTool.\n *\n * This keeps AgentSession's internal registry definition-first even when a caller\n * provides plain AgentTool overrides that do not include prompt metadata or renderers.\n */\nexport function createToolDefinitionFromAgentTool(tool: AgentTool<any>): ToolDefinition<any, unknown> {\n\treturn {\n\t\tname: tool.name,\n\t\tlabel: tool.label,\n\t\tdescription: tool.description,\n\t\tparameters: tool.parameters as any,\n\t\tprepareArguments: tool.prepareArguments,\n\t\tfailureRecovery: tool.failureRecovery,\n\t\texecutionMode: tool.executionMode,\n\t\texecute: async (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),\n\t};\n}\n"]}
1
+ {"version":3,"file":"tool-definition-wrapper.js","sourceRoot":"","sources":["../../../src/core/tools/tool-definition-wrapper.ts"],"names":[],"mappings":"AAGA,o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AAI,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;KAC3G,CAAC;AACH,CAAC","sourcesContent":["import type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\n\n/** Wrap a ToolDefinition into an AgentTool for the core runtime. */\nexport function wrapToolDefinition<TDetails = unknown>(\n\tdefinition: ToolDefinition<any, TDetails>,\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<any, TDetails> {\n\treturn {\n\t\tname: definition.name,\n\t\tlabel: definition.label,\n\t\tdescription: definition.description,\n\t\tproviderDescription: definition.promptSnippet,\n\t\tparameters: definition.parameters,\n\t\tprepareArguments: definition.prepareArguments,\n\t\tfailureRecovery: definition.failureRecovery,\n\t\texecutionMode: definition.executionMode,\n\t\texecute: (toolCallId, params, signal, onUpdate) =>\n\t\t\tdefinition.execute(toolCallId, params, signal, onUpdate, ctxFactory?.() as ExtensionContext),\n\t};\n}\n\n/** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */\nexport function wrapToolDefinitions(\n\tdefinitions: ToolDefinition<any, any>[],\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<any>[] {\n\treturn definitions.map((definition) => wrapToolDefinition(definition, ctxFactory));\n}\n\n/**\n * Synthesize a minimal ToolDefinition from an AgentTool.\n *\n * This keeps AgentSession's internal registry definition-first even when a caller\n * provides plain AgentTool overrides that do not include prompt metadata or renderers.\n */\nexport function createToolDefinitionFromAgentTool(tool: AgentTool<any>): ToolDefinition<any, unknown> {\n\treturn {\n\t\tname: tool.name,\n\t\tlabel: tool.label,\n\t\tdescription: tool.description,\n\t\tpromptSnippet: tool.providerDescription,\n\t\tparameters: tool.parameters as any,\n\t\tprepareArguments: tool.prepareArguments,\n\t\tfailureRecovery: tool.failureRecovery,\n\t\texecutionMode: tool.executionMode,\n\t\texecute: async (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tool-task.d.ts","sourceRoot":"","sources":["../../../src/core/tools/tool-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAK7D,QAAA,MAAM,MAAM;;;EAcX,CAAC;AAIF,MAAM,WAAW,oBAAoB;IACpC,IAAI,IAAI,wBAAwB,EAAE,CAAC;IACnC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC9E,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAmBD,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CAAC,OAAO,MAAM,CAAC,CAgEtG"}
1
+ {"version":3,"file":"tool-task.d.ts","sourceRoot":"","sources":["../../../src/core/tools/tool-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAK7D,QAAA,MAAM,MAAM;;;EAcX,CAAC;AAIF,MAAM,WAAW,oBAAoB;IACpC,IAAI,IAAI,wBAAwB,EAAE,CAAC;IACnC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC9E,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAmBD,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CAAC,OAAO,MAAM,CAAC,CAoEtG"}
@@ -48,6 +48,7 @@ export function createToolTaskToolDefinition(deps) {
48
48
  return {
49
49
  content: [{ type: "text", text: `${input.action} requires a valid taskId.` }],
50
50
  details: { kind: "error", reason: "invalid_task_id" },
51
+ isError: true,
51
52
  };
52
53
  }
53
54
  if (input.action === "cancel") {
@@ -70,6 +71,7 @@ export function createToolTaskToolDefinition(deps) {
70
71
  }
71
72
  try {
72
73
  const record = await deps.wait(taskId, signal);
74
+ const isError = record.status !== "completed";
73
75
  return {
74
76
  content: [{ type: "text", text: record.output || record.summary }],
75
77
  details: {
@@ -78,6 +80,7 @@ export function createToolTaskToolDefinition(deps) {
78
80
  status: record.status,
79
81
  ...(record.artifactId ? { artifactId: record.artifactId } : {}),
80
82
  },
83
+ ...(isError ? { isError: true } : {}),
81
84
  };
82
85
  }
83
86
  catch (error) {
@@ -85,6 +88,7 @@ export function createToolTaskToolDefinition(deps) {
85
88
  return {
86
89
  content: [{ type: "text", text: reason }],
87
90
  details: { kind: "error", taskId, reason },
91
+ isError: true,
88
92
  };
89
93
  }
90
94
  },
@@ -1 +1 @@
1
- {"version":3,"file":"tool-task.js","sourceRoot":"","sources":["../../../src/core/tools/tool-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CACzB;IACC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;QAChC,WAAW,EAAE,+DAA+D;KAC5E,CAAC;IACF,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,IAAI,CAAC,MAAM,CAAC;QACX,SAAS,EAAE,iBAAiB;QAC5B,WAAW,EAAE,oCAAoC;KACjD,CAAC,CACF;CACD,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAmBF,SAAS,WAAW,CAAC,KAAyB;IAC7C,MAAM,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,iBAAiB;QAAE,OAAO,SAAS,CAAC;IACnE,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,QAAQ,CAAC,OAA4C;IAC7D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,2CAA2C,CAAC;IAC7E,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IACjD,OAAO;QACN,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,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CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { BackgroundToolTaskRecord } from \"../background-tool-task-controller.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\n\nconst MAX_TASK_ID_CHARS = 128;\nconst MAX_LISTED_TASKS = 32;\n\nconst schema = Type.Object(\n\t{\n\t\taction: Type.String({\n\t\t\tenum: [\"list\", \"wait\", \"cancel\"],\n\t\t\tdescription: \"List once, wait once for a dependency, or cancel. Never poll.\",\n\t\t}),\n\t\ttaskId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tmaxLength: MAX_TASK_ID_CHARS,\n\t\t\t\tdescription: \"Task id; required for wait/cancel.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\ntype Input = Static<typeof schema>;\n\nexport interface ToolTaskDependencies {\n\tlist(): BackgroundToolTaskRecord[];\n\twait(taskId: string, signal?: AbortSignal): Promise<BackgroundToolTaskRecord>;\n\tcancel(taskId: string): boolean;\n}\n\nexport interface ToolTaskDetails {\n\tkind: \"list\" | \"wait\" | \"cancel\" | \"error\";\n\tcount?: number;\n\ttaskId?: string;\n\tstatus?: BackgroundToolTaskRecord[\"status\"];\n\tartifactId?: string;\n\treason?: string;\n}\n\nfunction validTaskId(value: string | undefined): string | undefined {\n\tconst taskId = value?.trim();\n\tif (!taskId || taskId.length > MAX_TASK_ID_CHARS) return undefined;\n\treturn taskId;\n}\n\nfunction listText(records: readonly BackgroundToolTaskRecord[]): string {\n\tif (records.length === 0) return \"No background tool tasks in this session.\";\n\tconst included = records.slice(-MAX_LISTED_TASKS);\n\tconst omitted = records.length - included.length;\n\treturn [\n\t\t...included.map((record) => `${record.taskId}: ${record.status} — ${record.summary}`),\n\t\t...(omitted > 0 ? [`${omitted} older task(s) omitted from this bounded snapshot.`] : []),\n\t\t\"Do not poll. Continue independent work, or call wait once only when a running task is a dependency.\",\n\t].join(\"\\n\");\n}\n\nexport function createToolTaskToolDefinition(deps: ToolTaskDependencies): ToolDefinition<typeof schema> {\n\treturn {\n\t\tname: \"tool_task\",\n\t\tlabel: \"tool_task\",\n\t\tdescription:\n\t\t\t\"List, wait for, or cancel this session's background tool calls. Continue other work; wait is event-driven, never poll.\",\n\t\tpromptSnippet: \"Event-driven background tool control; wait once, never poll.\",\n\t\tparameters: schema,\n\t\tasync execute(_toolCallId, input: Input, signal) {\n\t\t\tif (input.action === \"list\") {\n\t\t\t\tconst records = deps.list();\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: listText(records) }],\n\t\t\t\t\tdetails: { kind: \"list\" as const, count: records.length },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst taskId = validTaskId(input.taskId);\n\t\t\tif (!taskId) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `${input.action} requires a valid taskId.` }],\n\t\t\t\t\tdetails: { kind: \"error\" as const, reason: \"invalid_task_id\" },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (input.action === \"cancel\") {\n\t\t\t\tconst canceled = deps.cancel(taskId);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: canceled\n\t\t\t\t\t\t\t\t? `Cancellation requested for ${taskId}.`\n\t\t\t\t\t\t\t\t: `No running background tool task named ${taskId}.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tkind: \"cancel\" as const,\n\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\t...(canceled ? {} : { reason: \"not_running\" }),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst record = await deps.wait(taskId, signal);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: record.output || record.summary }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tkind: \"wait\" as const,\n\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\tstatus: record.status,\n\t\t\t\t\t\t...(record.artifactId ? { artifactId: record.artifactId } : {}),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: reason }],\n\t\t\t\t\tdetails: { kind: \"error\" as const, taskId, reason },\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"tool-task.js","sourceRoot":"","sources":["../../../src/core/tools/tool-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CACzB;IACC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;QAChC,WAAW,EAAE,+DAA+D;KAC5E,CAAC;IACF,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,IAAI,CAAC,MAAM,CAAC;QACX,SAAS,EAAE,iBAAiB;QAC5B,WAAW,EAAE,oCAAoC;KACjD,CAAC,CACF;CACD,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAmBF,SAAS,WAAW,CAAC,KAAyB;IAC7C,MAAM,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,iBAAiB;QAAE,OAAO,SAAS,CAAC;IACnE,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,QAAQ,CAAC,OAA4C;IAC7D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,2C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GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACrC,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACtE,OAAO;oBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oBAClD,OAAO,EAAE,EAAE,IAAI,EAAE,OAAgB,EAAE,MAAM,EAAE,MAAM,EAAE;oBACnD,OAAO,EAAE,IAAI;iBACb,CAAC;YACH,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { BackgroundToolTaskRecord } from \"../background-tool-task-controller.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\n\nconst MAX_TASK_ID_CHARS = 128;\nconst MAX_LISTED_TASKS = 32;\n\nconst schema = Type.Object(\n\t{\n\t\taction: Type.String({\n\t\t\tenum: [\"list\", \"wait\", \"cancel\"],\n\t\t\tdescription: \"List once, wait once for a dependency, or cancel. Never poll.\",\n\t\t}),\n\t\ttaskId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tmaxLength: MAX_TASK_ID_CHARS,\n\t\t\t\tdescription: \"Task id; required for wait/cancel.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\ntype Input = Static<typeof schema>;\n\nexport interface ToolTaskDependencies {\n\tlist(): BackgroundToolTaskRecord[];\n\twait(taskId: string, signal?: AbortSignal): Promise<BackgroundToolTaskRecord>;\n\tcancel(taskId: string): boolean;\n}\n\nexport interface ToolTaskDetails {\n\tkind: \"list\" | \"wait\" | \"cancel\" | \"error\";\n\tcount?: number;\n\ttaskId?: string;\n\tstatus?: BackgroundToolTaskRecord[\"status\"];\n\tartifactId?: string;\n\treason?: string;\n}\n\nfunction validTaskId(value: string | undefined): string | undefined {\n\tconst taskId = value?.trim();\n\tif (!taskId || taskId.length > MAX_TASK_ID_CHARS) return undefined;\n\treturn taskId;\n}\n\nfunction listText(records: readonly BackgroundToolTaskRecord[]): string {\n\tif (records.length === 0) return \"No background tool tasks in this session.\";\n\tconst included = records.slice(-MAX_LISTED_TASKS);\n\tconst omitted = records.length - included.length;\n\treturn [\n\t\t...included.map((record) => `${record.taskId}: ${record.status} — ${record.summary}`),\n\t\t...(omitted > 0 ? [`${omitted} older task(s) omitted from this bounded snapshot.`] : []),\n\t\t\"Do not poll. Continue independent work, or call wait once only when a running task is a dependency.\",\n\t].join(\"\\n\");\n}\n\nexport function createToolTaskToolDefinition(deps: ToolTaskDependencies): ToolDefinition<typeof schema> {\n\treturn {\n\t\tname: \"tool_task\",\n\t\tlabel: \"tool_task\",\n\t\tdescription:\n\t\t\t\"List, wait for, or cancel this session's background tool calls. Continue other work; wait is event-driven, never poll.\",\n\t\tpromptSnippet: \"Event-driven background tool control; wait once, never poll.\",\n\t\tparameters: schema,\n\t\tasync execute(_toolCallId, input: Input, signal) {\n\t\t\tif (input.action === \"list\") {\n\t\t\t\tconst records = deps.list();\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: listText(records) }],\n\t\t\t\t\tdetails: { kind: \"list\" as const, count: records.length },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst taskId = validTaskId(input.taskId);\n\t\t\tif (!taskId) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `${input.action} requires a valid taskId.` }],\n\t\t\t\t\tdetails: { kind: \"error\" as const, reason: \"invalid_task_id\" },\n\t\t\t\t\tisError: true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (input.action === \"cancel\") {\n\t\t\t\tconst canceled = deps.cancel(taskId);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: canceled\n\t\t\t\t\t\t\t\t? `Cancellation requested for ${taskId}.`\n\t\t\t\t\t\t\t\t: `No running background tool task named ${taskId}.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tkind: \"cancel\" as const,\n\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\t...(canceled ? {} : { reason: \"not_running\" }),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst record = await deps.wait(taskId, signal);\n\t\t\t\tconst isError = record.status !== \"completed\";\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: record.output || record.summary }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tkind: \"wait\" as const,\n\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\tstatus: record.status,\n\t\t\t\t\t\t...(record.artifactId ? { artifactId: record.artifactId } : {}),\n\t\t\t\t\t},\n\t\t\t\t\t...(isError ? { isError: true } : {}),\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: reason }],\n\t\t\t\t\tdetails: { kind: \"error\" as const, taskId, reason },\n\t\t\t\t\tisError: true,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
@@ -93,18 +93,18 @@ function formatStatus(status) {
93
93
  return lines;
94
94
  }
95
95
  const WORKTREE_SYNC_PROMPT_GUIDELINES = [
96
- "Work ONLY inside your lane worktree on your lane branch; never edit the hub checkout or touch main directly -- main moves exclusively through the land action.",
97
- "Commit your work on the lane branch, then land. Landing is refused while the lane is stale (G3): call sync first, resolve conflicts locally, then land.",
98
- "When a sync stops on conflicts, edit exactly the listed files, then call continue -- staging, marker verification, and rebase continuation are mechanical.",
99
- "After any other lane lands, your lane becomes stale; under the mandatory policy your file mutations are refused until you sync. git add/commit stay available to save WIP first.",
100
- "Check status when unsure -- it is the deterministic full picture; never infer sync state from raw git output.",
96
+ "Work ONLY in lane worktree/branch; never hub/main. main moves only through land.",
97
+ "Commit lane, then land. stale lane: sync, resolve conflicts locally, land.",
98
+ "sync conflict: edit listed files, call continue; staging/marker checks/rebase are mechanical.",
99
+ "After another land, mutations fail until sync; git add/commit may save WIP first.",
100
+ "status is authoritative sync state; never infer from raw git.",
101
101
  ];
102
102
  export function createWorktreeSyncToolDefinition(deps) {
103
103
  return {
104
104
  name: "worktree_sync",
105
105
  label: "worktree_sync",
106
106
  description: "Hard-gated worktree-per-lane parallel work: each agent works in its own git worktree/branch; integration is always rebase-onto-main + ff-only land, serialized under one integration lock with the gate command verified at the exact landing tip. status/create_lane/sync/continue/abort_sync/land/release_lane/reconcile. Every outcome is a tagged code with the exact recovery step; landing while stale is structurally impossible.",
107
- promptSnippet: "Coordinate parallel work: lane worktrees, rebase-onto-main sync, serialized gated landing.",
107
+ promptSnippet: "Coordinate lane worktrees, rebase-to-main sync, gated serialized land.",
108
108
  promptGuidelines: WORKTREE_SYNC_PROMPT_GUIDELINES,
109
109
  parameters: worktreeSyncSchema,
110
110
  executionMode: "sequential",
@@ -1 +1 @@
1
- {"version":3,"file":"worktree-sync.js","sourceRoot":"","sources":["../../../src/core/tools/worktree-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,EACN,SAAS,EACT,eAAe,EACf,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,QAAQ,GAER,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE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type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport type { ResolvedWorktreeSyncSettings } from \"../settings-manager.ts\";\nimport type { ConflictWorklist, SyncStatus } from \"../worktree-sync/codes.ts\";\nimport {\n\tabortSync,\n\tbuildSyncStatus,\n\tcontinueSync,\n\tcreateLane,\n\tlandLane,\n\treconcile,\n\treleaseLane,\n\tresolveRepoContext,\n\tsyncLane,\n\ttype WorktreeSyncEngineDeps,\n} from \"../worktree-sync/git-engine.ts\";\nimport { resolveLaneMutationPath } from \"../worktree-sync/lane-gate.ts\";\nimport { readLane } from \"../worktree-sync/store.ts\";\n\n/**\n * `worktree_sync` -- the ENTIRE agent-facing surface of the worktree-per-lane workflow: a closed\n * action set over the engine (`core/worktree-sync/git-engine.ts`) so agents never improvise git\n * ceremony. Every outcome carries a tagged code in `details`; refusal text always names the exact\n * recovery step. See docs/worktree-sync.md for the workflow and the G1-G11 gate table.\n */\n\nfunction createWorktreeSyncSchema() {\n\treturn Type.Object(\n\t\t{\n\t\t\taction: Type.Union(\n\t\t\t\t[\n\t\t\t\t\tType.Literal(\"status\"),\n\t\t\t\t\tType.Literal(\"git_status\"),\n\t\t\t\t\tType.Literal(\"git_diff\"),\n\t\t\t\t\tType.Literal(\"git_add\"),\n\t\t\t\t\tType.Literal(\"git_commit\"),\n\t\t\t\t\tType.Literal(\"check\"),\n\t\t\t\t\tType.Literal(\"create_lane\"),\n\t\t\t\t\tType.Literal(\"sync\"),\n\t\t\t\t\tType.Literal(\"continue\"),\n\t\t\t\t\tType.Literal(\"abort_sync\"),\n\t\t\t\t\tType.Literal(\"land\"),\n\t\t\t\t\tType.Literal(\"release_lane\"),\n\t\t\t\t\tType.Literal(\"reconcile\"),\n\t\t\t\t],\n\t\t\t\t{\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"status: the deterministic full picture (epoch, hub, lock, per-lane freshness/staleness, advice). git_status/git_diff: read the bound lane with fixed argv. git_add: stage only explicitly validated paths inside the lane. git_commit: commit with a literal message. check: run only the owner-configured trusted check command. create_lane: new worktree+branch off main. sync: rebase current main into a lane (conflicts return a worklist and leave the rebase in progress). continue: verify resolved conflicts (zero markers, mechanically checked), stage, drive on. abort_sync: abort the in-progress rebase. land: the ONLY door to main -- serialized, freshness-checked, gate-command-verified, ff-only. release_lane: remove a fully-landed lane (discarding unlanded work needs confirm). reconcile: re-sync the registry with git reality.\",\n\t\t\t\t},\n\t\t\t),\n\t\t\tlaneKey: Type.Optional(\n\t\t\t\tType.String({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Target lane. Defaults to this session's bound lane (PI_WORKTREE_LANE) for sync/continue/abort_sync/land.\",\n\t\t\t\t}),\n\t\t\t),\n\t\t\tgoalId: Type.Optional(\n\t\t\t\tType.String({ description: \"create_lane: goal to scope the auto-allocated lane key by.\" }),\n\t\t\t),\n\t\t\trequirementId: Type.Optional(Type.String({ description: \"create_lane: requirement this lane will work.\" })),\n\t\t\tpaths: Type.Optional(\n\t\t\t\tType.Array(Type.String(), {\n\t\t\t\t\tdescription: \"git_diff/git_add: explicit relative paths inside the bound lane.\",\n\t\t\t\t}),\n\t\t\t),\n\t\t\tmessage: Type.Optional(Type.String({ description: \"git_commit: literal commit message.\" })),\n\t\t\tconfirm: Type.Optional(\n\t\t\t\tType.String({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'release_lane: pass exactly \"yes-discard-lane\" to release a lane that still has unlanded commits or dirty files (G11: never silent).',\n\t\t\t\t}),\n\t\t\t),\n\t\t},\n\t\t{ additionalProperties: false },\n\t);\n}\n\nconst worktreeSyncSchema = createWorktreeSyncSchema();\n\nexport type WorktreeSyncToolInput = Static<typeof worktreeSyncSchema>;\n\nexport interface WorktreeSyncToolDeps {\n\tengineDeps: () => WorktreeSyncEngineDeps;\n\tsettings: () => ResolvedWorktreeSyncSettings;\n\tboundLaneKey: () => string | undefined;\n\t/** True iff this is a worker session (see session-role.ts) -- narrows the action surface below. */\n\tisWorker: () => boolean;\n}\n\n/** Actions a worker session may run unconditionally -- read-only status plus the sync/conflict\n * cycle on its own bound lane. Everything else is refused as `role_forbidden`, EXCEPT `land`,\n * which is instead gated by the `worktreeSync.workerLand` setting (still subject to normal\n * ownership/freshness gating downstream when allowed). */\nconst WORKER_ALLOWED_ACTIONS: ReadonlySet<WorktreeSyncToolInput[\"action\"]> = new Set([\n\t\"status\",\n\t\"git_status\",\n\t\"git_diff\",\n\t\"git_add\",\n\t\"git_commit\",\n\t\"check\",\n\t\"sync\",\n\t\"continue\",\n\t\"abort_sync\",\n]);\n\nfunction formatWorklist(worklist: ConflictWorklist): string[] {\n\tconst lines = [\n\t\t`Conflicts at rebase step ${worklist.step}${worklist.stoppedAtCommit ? ` (replaying ${worklist.stoppedAtCommit.sha.slice(0, 12)}: ${worklist.stoppedAtCommit.subject})` : \"\"}:`,\n\t];\n\tfor (const file of worklist.files) {\n\t\tlines.push(`- ${file.path} [${file.kind}]`);\n\t}\n\tlines.push(\n\t\t'Resolve the zdiff3 hunks in exactly these files (base section included), save, then call {\"action\":\"continue\"}. Staging and marker verification are automatic.',\n\t);\n\treturn lines;\n}\n\nfunction formatStatus(status: SyncStatus): string[] {\n\tconst lines = [\n\t\t`epoch ${status.epoch} | main ${status.mainBranch}@${status.mainSha.slice(0, 12)}` +\n\t\t\t`${status.hub ? ` | hub ${status.hub.clean ? \"clean\" : \"has local changes\"}` : \" | hub: main not checked out\"}` +\n\t\t\t`${status.lock.held ? ` | LOCK held by pid ${status.lock.holder?.pid ?? \"?\"}` : \"\"}`,\n\t];\n\tfor (const lane of status.lanes) {\n\t\tconst flags = [\n\t\t\tlane.registrationStatus !== \"active\" ? lane.registrationStatus : undefined,\n\t\t\tlane.rebaseInProgress ? \"REBASE-IN-PROGRESS\" : undefined,\n\t\t\tlane.syncRequired ? \"SYNC-REQUIRED\" : lane.stale ? \"stale\" : \"fresh\",\n\t\t\tlane.dirty ? \"dirty\" : undefined,\n\t\t]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\", \");\n\t\tlines.push(\n\t\t\t`- ${lane.laneKey} (${lane.branch}) +${lane.aheadOfMain}/-${lane.behindMain} [${flags}]` +\n\t\t\t\t`${lane.overlapWithLastLand.length > 0 ? ` overlap: ${lane.overlapWithLastLand.slice(0, 5).join(\", \")}` : \"\"}`,\n\t\t);\n\t}\n\tif (status.lanes.length === 0) lines.push(\"(no lanes)\");\n\tif (status.advice) lines.push(`advice: ${status.advice}`);\n\treturn lines;\n}\n\nconst WORKTREE_SYNC_PROMPT_GUIDELINES = [\n\t\"Work ONLY inside your lane worktree on your lane branch; never edit the hub checkout or touch main directly -- main moves exclusively through the land action.\",\n\t\"Commit your work on the lane branch, then land. Landing is refused while the lane is stale (G3): call sync first, resolve conflicts locally, then land.\",\n\t\"When a sync stops on conflicts, edit exactly the listed files, then call continue -- staging, marker verification, and rebase continuation are mechanical.\",\n\t\"After any other lane lands, your lane becomes stale; under the mandatory policy your file mutations are refused until you sync. git add/commit stay available to save WIP first.\",\n\t\"Check status when unsure -- it is the deterministic full picture; never infer sync state from raw git output.\",\n];\n\nexport function createWorktreeSyncToolDefinition(deps: WorktreeSyncToolDeps): ToolDefinition {\n\treturn {\n\t\tname: \"worktree_sync\",\n\t\tlabel: \"worktree_sync\",\n\t\tdescription:\n\t\t\t\"Hard-gated worktree-per-lane parallel work: each agent works in its own git worktree/branch; integration is always rebase-onto-main + ff-only land, serialized under one integration lock with the gate command verified at the exact landing tip. status/create_lane/sync/continue/abort_sync/land/release_lane/reconcile. Every outcome is a tagged code with the exact recovery step; landing while stale is structurally impossible.\",\n\t\tpromptSnippet: \"Coordinate parallel work: lane worktrees, rebase-onto-main sync, serialized gated landing.\",\n\t\tpromptGuidelines: WORKTREE_SYNC_PROMPT_GUIDELINES,\n\t\tparameters: worktreeSyncSchema,\n\t\texecutionMode: \"sequential\",\n\t\tasync execute(_toolCallId, input: WorktreeSyncToolInput, signal) {\n\t\t\tconst engineDeps: WorktreeSyncEngineDeps = { ...deps.engineDeps(), ...(signal ? { signal } : {}) };\n\t\t\tconst settings = deps.settings();\n\t\t\tconst laneKey = input.laneKey ?? deps.boundLaneKey();\n\n\t\t\tconst respond = (lines: string[], details: unknown) => ({\n\t\t\t\tcontent: [{ type: \"text\" as const, text: lines.join(\"\\n\") }],\n\t\t\t\tdetails: details as Record<string, unknown>,\n\t\t\t});\n\t\t\tconst needLane = (): string | undefined => {\n\t\t\t\tif (laneKey) return undefined;\n\t\t\t\treturn \"laneKey required: pass laneKey, or run inside a lane-bound session (PI_WORKTREE_LANE).\";\n\t\t\t};\n\n\t\t\tconst runTypedLaneAction = async (): Promise<ReturnType<typeof respond>> => {\n\t\t\t\tconst missingLane = needLane();\n\t\t\t\tif (missingLane) return respond([missingLane], { code: \"lane_not_found\", message: missingLane });\n\t\t\t\tconst context = await resolveRepoContext(engineDeps);\n\t\t\t\tif (\"code\" in context) return respond([`[${context.code}] ${context.message}`], context);\n\t\t\t\tconst lane = await readLane(context.paths, laneKey!);\n\t\t\t\tif (!lane || lane.status !== \"active\") {\n\t\t\t\t\tconst message = `active lane '${laneKey}' is not available`;\n\t\t\t\t\treturn respond([`[lane_not_found] ${message}`], { code: \"lane_not_found\", message });\n\t\t\t\t}\n\t\t\t\tconst execInLane = (command: string, args: string[], timeout: number) =>\n\t\t\t\t\tengineDeps.exec(command, args, {\n\t\t\t\t\t\tcwd: lane.worktreePath,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\tsignal: engineDeps.signal,\n\t\t\t\t\t\tmaxBuffer: 1024 * 1024,\n\t\t\t\t\t});\n\n\t\t\t\tconst requestedPaths = input.paths ?? [];\n\t\t\t\tconst gitPaths: string[] = [];\n\t\t\t\tfor (const requestedPath of requestedPaths) {\n\t\t\t\t\tif (!requestedPath || isAbsolute(requestedPath) || requestedPath.includes(\"\\0\")) {\n\t\t\t\t\t\tconst message = \"git path must be a non-empty relative path without NUL\";\n\t\t\t\t\t\treturn respond([`[path_outside_lane] ${message}`], { code: \"path_outside_lane\", message });\n\t\t\t\t\t}\n\t\t\t\t\tconst resolved = resolveLaneMutationPath(lane.worktreePath, requestedPath);\n\t\t\t\t\tif (!resolved) {\n\t\t\t\t\t\tconst message = `path '${requestedPath}' escapes the lane worktree`;\n\t\t\t\t\t\treturn respond([`[path_outside_lane] ${message}`], { code: \"path_outside_lane\", message });\n\t\t\t\t\t}\n\t\t\t\t\tgitPaths.push(relative(lane.worktreePath, resolved) || \".\");\n\t\t\t\t}\n\n\t\t\t\tlet command: string;\n\t\t\t\tlet args: string[];\n\t\t\t\tswitch (input.action) {\n\t\t\t\t\tcase \"git_status\":\n\t\t\t\t\t\tcommand = \"git\";\n\t\t\t\t\t\targs = [\"status\", \"--short\", \"--branch\"];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"git_diff\":\n\t\t\t\t\t\tcommand = \"git\";\n\t\t\t\t\t\targs = [\"diff\", \"--\", ...gitPaths];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"git_add\":\n\t\t\t\t\t\tif (gitPaths.length === 0) {\n\t\t\t\t\t\t\tconst message = \"git_add requires one or more explicit in-lane paths\";\n\t\t\t\t\t\t\treturn respond([`[path_outside_lane] ${message}`], { code: \"path_outside_lane\", message });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcommand = \"git\";\n\t\t\t\t\t\targs = [\"add\", \"--\", ...gitPaths];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"git_commit\":\n\t\t\t\t\t\tif (!input.message?.trim() || input.message.includes(\"\\0\")) {\n\t\t\t\t\t\t\tconst message = \"git_commit requires a non-empty literal message\";\n\t\t\t\t\t\t\treturn respond([`[git_failed] ${message}`], { code: \"git_failed\", message });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcommand = \"git\";\n\t\t\t\t\t\targs = [\"commit\", \"-m\", input.message];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"check\": {\n\t\t\t\t\t\tconst trustedCommand = settings.gateCommand?.trim();\n\t\t\t\t\t\tif (!trustedCommand) {\n\t\t\t\t\t\t\tconst message = \"no trusted worktree check is configured\";\n\t\t\t\t\t\t\treturn respond([`[gate_command_unset] ${message}`], { code: \"gate_command_unset\", message });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst shell = process.platform === \"win32\" ? \"cmd\" : \"sh\";\n\t\t\t\t\t\tconst shellFlag = process.platform === \"win32\" ? \"/c\" : \"-c\";\n\t\t\t\t\t\tconst result = await execInLane(shell, [shellFlag, trustedCommand], 900_000);\n\t\t\t\t\t\tconst output = `${result.stdout}\\n${result.stderr}`.trim().slice(-8000);\n\t\t\t\t\t\tif (result.code !== 0) {\n\t\t\t\t\t\t\treturn respond([`[gate_failed] ${output || `trusted check exited ${result.code}`}`], {\n\t\t\t\t\t\t\t\tcode: \"gate_failed\",\n\t\t\t\t\t\t\t\texitCode: result.code,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn respond([output || \"trusted check passed\"], { code: \"ok\", action: input.action });\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn respond([\"typed lane action is unavailable for this request\"], { code: \"role_forbidden\" });\n\t\t\t\t}\n\n\t\t\t\tconst result = await execInLane(command, args, 60_000);\n\t\t\t\tconst output = `${result.stdout}\\n${result.stderr}`.trim().slice(-8000);\n\t\t\t\tif (result.code !== 0) {\n\t\t\t\t\treturn respond([`[git_failed] ${output || `${command} exited ${result.code}`}`], {\n\t\t\t\t\t\tcode: \"git_failed\",\n\t\t\t\t\t\taction: input.action,\n\t\t\t\t\t\texitCode: result.code,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn respond([output || `${input.action} completed`], { code: \"ok\", action: input.action });\n\t\t\t};\n\n\t\t\tif (deps.isWorker()) {\n\t\t\t\tconst bound = deps.boundLaneKey();\n\t\t\t\tif (input.laneKey !== undefined && input.laneKey !== bound) {\n\t\t\t\t\tconst message = \"workers may only target their bound lane\";\n\t\t\t\t\treturn respond([message], { code: \"role_forbidden\", message });\n\t\t\t\t}\n\t\t\t\tconst landAllowed = input.action === \"land\" && settings.workerLand === \"allow\";\n\t\t\t\tif (!WORKER_ALLOWED_ACTIONS.has(input.action) && !landAllowed) {\n\t\t\t\t\tconst message =\n\t\t\t\t\t\tinput.action === \"land\"\n\t\t\t\t\t\t\t? 'workers may not land (worktreeSync.workerLand is \"deny\")'\n\t\t\t\t\t\t\t: `workers may not run action \"${input.action}\"`;\n\t\t\t\t\treturn respond([message], { code: \"role_forbidden\", message });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch (input.action) {\n\t\t\t\tcase \"git_status\":\n\t\t\t\tcase \"git_diff\":\n\t\t\t\tcase \"git_add\":\n\t\t\t\tcase \"git_commit\":\n\t\t\t\tcase \"check\":\n\t\t\t\t\treturn runTypedLaneAction();\n\t\t\t\tcase \"status\": {\n\t\t\t\t\tconst status = await buildSyncStatus(engineDeps, { policy: settings.syncPolicy });\n\t\t\t\t\tif (status.code !== \"ok\") return respond([`[${status.code}] ${status.message}`], status);\n\t\t\t\t\treturn respond(formatStatus(status), status);\n\t\t\t\t}\n\t\t\t\tcase \"create_lane\": {\n\t\t\t\t\tconst created = await createLane(engineDeps, {\n\t\t\t\t\t\t...(input.laneKey !== undefined ? { laneKey: input.laneKey } : {}),\n\t\t\t\t\t\t...(input.goalId !== undefined ? { goalId: input.goalId } : {}),\n\t\t\t\t\t\t...(input.requirementId !== undefined ? { requirementId: input.requirementId } : {}),\n\t\t\t\t\t});\n\t\t\t\t\tif (created.code !== \"ok\") return respond([`[${created.code}] ${created.message}`], created);\n\t\t\t\t\treturn respond(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t`lane '${created.lane.laneKey}' created: branch ${created.lane.branch}, checkout ${created.lane.worktreePath}`,\n\t\t\t\t\t\t],\n\t\t\t\t\t\tcreated,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase \"sync\": {\n\t\t\t\t\tconst missing = needLane();\n\t\t\t\t\tif (missing) return respond([missing], { code: \"lane_not_found\", message: missing });\n\t\t\t\t\tconst synced = await syncLane(engineDeps, { laneKey: laneKey as string });\n\t\t\t\t\tif (synced.code === \"sync_clean\") {\n\t\t\t\t\t\treturn respond(\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tsynced.alreadyFresh\n\t\t\t\t\t\t\t\t\t? `lane '${synced.laneKey}' already contains current main -- nothing to do`\n\t\t\t\t\t\t\t\t\t: `lane '${synced.laneKey}' rebased onto current main (auto-continued ${synced.autoContinued} step(s))`,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tsynced,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (synced.code === \"sync_conflicts\") return respond(formatWorklist(synced.worklist), synced);\n\t\t\t\t\treturn respond(\n\t\t\t\t\t\t[`[${synced.code}] ${synced.message}${synced.paths ? `\\n${synced.paths.join(\"\\n\")}` : \"\"}`],\n\t\t\t\t\t\tsynced,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase \"continue\": {\n\t\t\t\t\tconst missing = needLane();\n\t\t\t\t\tif (missing) return respond([missing], { code: \"lane_not_found\", message: missing });\n\t\t\t\t\tconst continued = await continueSync(engineDeps, { laneKey: laneKey as string });\n\t\t\t\t\tif (continued.code === \"sync_clean\") {\n\t\t\t\t\t\treturn respond(\n\t\t\t\t\t\t\t[`lane '${continued.laneKey}' rebase completed -- lane is fresh relative to the synced main`],\n\t\t\t\t\t\t\tcontinued,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (continued.code === \"sync_conflicts\") return respond(formatWorklist(continued.worklist), continued);\n\t\t\t\t\treturn respond(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t`[${continued.code}] ${continued.message}${continued.paths ? `\\n${continued.paths.join(\"\\n\")}` : \"\"}`,\n\t\t\t\t\t\t],\n\t\t\t\t\t\tcontinued,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase \"abort_sync\": {\n\t\t\t\t\tconst missing = needLane();\n\t\t\t\t\tif (missing) return respond([missing], { code: \"lane_not_found\", message: missing });\n\t\t\t\t\tconst aborted = await abortSync(engineDeps, { laneKey: laneKey as string });\n\t\t\t\t\tif (aborted.code !== \"ok\") return respond([`[${aborted.code}] ${aborted.message}`], aborted);\n\t\t\t\t\treturn respond(\n\t\t\t\t\t\t[`lane '${aborted.laneKey}' rebase aborted -- back to its pre-sync tip (still stale)`],\n\t\t\t\t\t\taborted,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase \"land\": {\n\t\t\t\t\tconst missing = needLane();\n\t\t\t\t\tif (missing) return respond([missing], { code: \"lane_not_found\", message: missing });\n\t\t\t\t\tconst landed = await landLane(engineDeps, {\n\t\t\t\t\t\tlaneKey: laneKey as string,\n\t\t\t\t\t\tgate: settings.gate,\n\t\t\t\t\t\t...(settings.gateCommand !== undefined ? { gateCommand: settings.gateCommand } : {}),\n\t\t\t\t\t\tgateTimeoutMs: settings.gateTimeoutMs,\n\t\t\t\t\t});\n\t\t\t\t\tif (landed.code !== \"ok\") {\n\t\t\t\t\t\treturn respond(\n\t\t\t\t\t\t\t[`[${landed.code}] ${landed.message}${landed.paths ? `\\n${landed.paths.join(\"\\n\")}` : \"\"}`],\n\t\t\t\t\t\t\tlanded,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn respond(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t`lane '${landed.laneKey}' LANDED: epoch ${landed.epoch}, main is now ${landed.mainSha.slice(0, 12)} (gate: ${landed.gate}). All other lanes must sync before their next land.`,\n\t\t\t\t\t\t],\n\t\t\t\t\t\tlanded,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase \"release_lane\": {\n\t\t\t\t\tconst missing = needLane();\n\t\t\t\t\tif (missing) return respond([missing], { code: \"lane_not_found\", message: missing });\n\t\t\t\t\tconst released = await releaseLane(engineDeps, {\n\t\t\t\t\t\tlaneKey: laneKey as string,\n\t\t\t\t\t\t...(input.confirm !== undefined ? { confirm: input.confirm } : {}),\n\t\t\t\t\t});\n\t\t\t\t\tif (released.code !== \"released\") return respond([`[${released.code}] ${released.message}`], released);\n\t\t\t\t\treturn respond([`lane '${released.laneKey}' released`], released);\n\t\t\t\t}\n\t\t\t\tcase \"reconcile\": {\n\t\t\t\t\tconst reconciled = await reconcile(engineDeps);\n\t\t\t\t\tif (reconciled.code !== \"reconciled\")\n\t\t\t\t\t\treturn respond([`[${reconciled.code}] ${reconciled.message}`], reconciled);\n\t\t\t\t\treturn respond(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t`reconciled: ${reconciled.orphanedLaneKeys.length} orphaned, ${reconciled.reRegisteredLaneKeys.length} re-registered, ${reconciled.ownerClearedLaneKeys.length} owners cleared${reconciled.staleLockReleased ? \", stale lock released\" : \"\"}`,\n\t\t\t\t\t\t],\n\t\t\t\t\t\treconciled,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"worktree-sync.js","sourceRoot":"","sources":["../../../src/core/tools/worktree-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,EACN,SAAS,EACT,eAAe,EACf,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,QAAQ,GAER,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD;;;;;GAKG;AAEH,SAAS,wBAAwB;IAChC,OAAO,IAAI,CAAC,MAAM,CACjB;QACC,MAAM,EAAE,IAAI,CAAC,KAAK,CACjB;YACC,IAAI,CAAC,OAAO,CAAC,QAAQ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wBAC1B,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBAClE,CAAC,CAAC;oBACH,IAAI,QAAQ,CAAC,IAAI,KAAK,UAAU;wBAAE,OAAO,OAAO,CAAC,CAAC,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;oBACvG,OAAO,OAAO,CAAC,CAAC,SAAS,QAAQ,CAAC,OAAO,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC;gBACnE,CAAC;gBACD,KAAK,WAAW,EAAE,CAAC;oBAClB,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,CAAC;oBAC/C,IAAI,UAAU,CAAC,IAAI,KAAK,YAAY;wBACnC,OAAO,OAAO,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;oBAC5E,OAAO,OAAO,CACb;wBACC,eAAe,UAAU,CAAC,gBAAgB,CAAC,MAAM,cAAc,UAAU,CAAC,oBAAoB,CAAC,MAAM,mBAAmB,UAAU,CAAC,oBAAoB,CAAC,MAAM,kBAAkB,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,EAAE;qBAC7O,EACD,UAAU,CACV,CAAC;gBACH,CAAC;YACF,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { isAbsolute, relative } from \"node:path\";\nimport { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport type { ResolvedWorktreeSyncSettings } from \"../settings-manager.ts\";\nimport type { ConflictWorklist, SyncStatus } from \"../worktree-sync/codes.ts\";\nimport {\n\tabortSync,\n\tbuildSyncStatus,\n\tcontinueSync,\n\tcreateLane,\n\tlandLane,\n\treconcile,\n\treleaseLane,\n\tresolveRepoContext,\n\tsyncLane,\n\ttype WorktreeSyncEngineDeps,\n} from \"../worktree-sync/git-engine.ts\";\nimport { resolveLaneMutationPath } from \"../worktree-sync/lane-gate.ts\";\nimport { readLane } from \"../worktree-sync/store.ts\";\n\n/**\n * `worktree_sync` -- the ENTIRE agent-facing surface of the worktree-per-lane workflow: a closed\n * action set over the engine (`core/worktree-sync/git-engine.ts`) so agents never improvise git\n * ceremony. Every outcome carries a tagged code in `details`; refusal text always names the exact\n * recovery step. See docs/worktree-sync.md for the workflow and the G1-G11 gate table.\n */\n\nfunction createWorktreeSyncSchema() {\n\treturn Type.Object(\n\t\t{\n\t\t\taction: Type.Union(\n\t\t\t\t[\n\t\t\t\t\tType.Literal(\"status\"),\n\t\t\t\t\tType.Literal(\"git_status\"),\n\t\t\t\t\tType.Literal(\"git_diff\"),\n\t\t\t\t\tType.Literal(\"git_add\"),\n\t\t\t\t\tType.Literal(\"git_commit\"),\n\t\t\t\t\tType.Literal(\"check\"),\n\t\t\t\t\tType.Literal(\"create_lane\"),\n\t\t\t\t\tType.Literal(\"sync\"),\n\t\t\t\t\tType.Literal(\"continue\"),\n\t\t\t\t\tType.Literal(\"abort_sync\"),\n\t\t\t\t\tType.Literal(\"land\"),\n\t\t\t\t\tType.Literal(\"release_lane\"),\n\t\t\t\t\tType.Literal(\"reconcile\"),\n\t\t\t\t],\n\t\t\t\t{\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"status: the deterministic full picture (epoch, hub, lock, per-lane freshness/staleness, advice). git_status/git_diff: read the bound lane with fixed argv. git_add: stage only explicitly validated paths inside the lane. git_commit: commit with a literal message. check: run only the owner-configured trusted check command. create_lane: new worktree+branch off main. sync: rebase current main into a lane (conflicts return a worklist and leave the rebase in progress). continue: verify resolved conflicts (zero markers, mechanically checked), stage, drive on. abort_sync: abort the in-progress rebase. land: the ONLY door to main -- serialized, freshness-checked, gate-command-verified, ff-only. release_lane: remove a fully-landed lane (discarding unlanded work needs confirm). reconcile: re-sync the registry with git reality.\",\n\t\t\t\t},\n\t\t\t),\n\t\t\tlaneKey: Type.Optional(\n\t\t\t\tType.String({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Target lane. Defaults to this session's bound lane (PI_WORKTREE_LANE) for sync/continue/abort_sync/land.\",\n\t\t\t\t}),\n\t\t\t),\n\t\t\tgoalId: Type.Optional(\n\t\t\t\tType.String({ description: \"create_lane: goal to scope the auto-allocated lane key by.\" }),\n\t\t\t),\n\t\t\trequirementId: Type.Optional(Type.String({ description: \"create_lane: requirement this lane will work.\" })),\n\t\t\tpaths: Type.Optional(\n\t\t\t\tType.Array(Type.String(), {\n\t\t\t\t\tdescription: \"git_diff/git_add: explicit relative paths inside the bound lane.\",\n\t\t\t\t}),\n\t\t\t),\n\t\t\tmessage: Type.Optional(Type.String({ description: \"git_commit: literal commit message.\" })),\n\t\t\tconfirm: Type.Optional(\n\t\t\t\tType.String({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'release_lane: pass exactly \"yes-discard-lane\" to release a lane that still has unlanded commits or dirty files (G11: never silent).',\n\t\t\t\t}),\n\t\t\t),\n\t\t},\n\t\t{ additionalProperties: false },\n\t);\n}\n\nconst worktreeSyncSchema = createWorktreeSyncSchema();\n\nexport type WorktreeSyncToolInput = Static<typeof worktreeSyncSchema>;\n\nexport interface WorktreeSyncToolDeps {\n\tengineDeps: () => WorktreeSyncEngineDeps;\n\tsettings: () => ResolvedWorktreeSyncSettings;\n\tboundLaneKey: () => string | undefined;\n\t/** True iff this is a worker session (see session-role.ts) -- narrows the action surface below. */\n\tisWorker: () => boolean;\n}\n\n/** Actions a worker session may run unconditionally -- read-only status plus the sync/conflict\n * cycle on its own bound lane. Everything else is refused as `role_forbidden`, EXCEPT `land`,\n * which is instead gated by the `worktreeSync.workerLand` setting (still subject to normal\n * ownership/freshness gating downstream when allowed). */\nconst WORKER_ALLOWED_ACTIONS: ReadonlySet<WorktreeSyncToolInput[\"action\"]> = new Set([\n\t\"status\",\n\t\"git_status\",\n\t\"git_diff\",\n\t\"git_add\",\n\t\"git_commit\",\n\t\"check\",\n\t\"sync\",\n\t\"continue\",\n\t\"abort_sync\",\n]);\n\nfunction formatWorklist(worklist: ConflictWorklist): string[] {\n\tconst lines = [\n\t\t`Conflicts at rebase step ${worklist.step}${worklist.stoppedAtCommit ? ` (replaying ${worklist.stoppedAtCommit.sha.slice(0, 12)}: ${worklist.stoppedAtCommit.subject})` : \"\"}:`,\n\t];\n\tfor (const file of worklist.files) {\n\t\tlines.push(`- ${file.path} [${file.kind}]`);\n\t}\n\tlines.push(\n\t\t'Resolve the zdiff3 hunks in exactly these files (base section included), save, then call {\"action\":\"continue\"}. Staging and marker verification are automatic.',\n\t);\n\treturn lines;\n}\n\nfunction formatStatus(status: SyncStatus): string[] {\n\tconst lines = [\n\t\t`epoch ${status.epoch} | main ${status.mainBranch}@${status.mainSha.slice(0, 12)}` +\n\t\t\t`${status.hub ? ` | hub ${status.hub.clean ? \"clean\" : \"has local changes\"}` : \" | hub: main not checked out\"}` +\n\t\t\t`${status.lock.held ? ` | LOCK held by pid ${status.lock.holder?.pid ?? \"?\"}` : \"\"}`,\n\t];\n\tfor (const lane of status.lanes) {\n\t\tconst flags = [\n\t\t\tlane.registrationStatus !== \"active\" ? lane.registrationStatus : undefined,\n\t\t\tlane.rebaseInProgress ? \"REBASE-IN-PROGRESS\" : undefined,\n\t\t\tlane.syncRequired ? \"SYNC-REQUIRED\" : lane.stale ? \"stale\" : \"fresh\",\n\t\t\tlane.dirty ? \"dirty\" : undefined,\n\t\t]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\", \");\n\t\tlines.push(\n\t\t\t`- ${lane.laneKey} (${lane.branch}) +${lane.aheadOfMain}/-${lane.behindMain} [${flags}]` +\n\t\t\t\t`${lane.overlapWithLastLand.length > 0 ? ` overlap: ${lane.overlapWithLastLand.slice(0, 5).join(\", \")}` : \"\"}`,\n\t\t);\n\t}\n\tif (status.lanes.length === 0) lines.push(\"(no lanes)\");\n\tif (status.advice) lines.push(`advice: ${status.advice}`);\n\treturn lines;\n}\n\nconst WORKTREE_SYNC_PROMPT_GUIDELINES = [\n\t\"Work ONLY in lane worktree/branch; never hub/main. main moves only through land.\",\n\t\"Commit lane, then land. stale lane: sync, resolve conflicts locally, land.\",\n\t\"sync conflict: edit listed files, call continue; staging/marker checks/rebase are mechanical.\",\n\t\"After another land, mutations fail until sync; git add/commit may save WIP first.\",\n\t\"status is authoritative sync state; never infer from raw git.\",\n];\n\nexport function createWorktreeSyncToolDefinition(deps: WorktreeSyncToolDeps): ToolDefinition {\n\treturn {\n\t\tname: \"worktree_sync\",\n\t\tlabel: \"worktree_sync\",\n\t\tdescription:\n\t\t\t\"Hard-gated worktree-per-lane parallel work: each agent works in its own git worktree/branch; integration is always rebase-onto-main + ff-only land, serialized under one integration lock with the gate command verified at the exact landing tip. status/create_lane/sync/continue/abort_sync/land/release_lane/reconcile. Every outcome is a tagged code with the exact recovery step; landing while stale is structurally impossible.\",\n\t\tpromptSnippet: \"Coordinate lane worktrees, rebase-to-main sync, gated serialized land.\",\n\t\tpromptGuidelines: WORKTREE_SYNC_PROMPT_GUIDELINES,\n\t\tparameters: worktreeSyncSchema,\n\t\texecutionMode: \"sequential\",\n\t\tasync execute(_toolCallId, input: WorktreeSyncToolInput, signal) {\n\t\t\tconst engineDeps: WorktreeSyncEngineDeps = { ...deps.engineDeps(), ...(signal ? { signal } : {}) };\n\t\t\tconst settings = deps.settings();\n\t\t\tconst laneKey = input.laneKey ?? deps.boundLaneKey();\n\n\t\t\tconst respond = (lines: string[], details: unknown) => ({\n\t\t\t\tcontent: [{ type: \"text\" as const, text: lines.join(\"\\n\") }],\n\t\t\t\tdetails: details as Record<string, unknown>,\n\t\t\t});\n\t\t\tconst needLane = (): string | undefined => {\n\t\t\t\tif (laneKey) return undefined;\n\t\t\t\treturn \"laneKey required: pass laneKey, or run inside a lane-bound session (PI_WORKTREE_LANE).\";\n\t\t\t};\n\n\t\t\tconst runTypedLaneAction = async (): Promise<ReturnType<typeof respond>> => {\n\t\t\t\tconst missingLane = needLane();\n\t\t\t\tif (missingLane) return respond([missingLane], { code: \"lane_not_found\", message: missingLane });\n\t\t\t\tconst context = await resolveRepoContext(engineDeps);\n\t\t\t\tif (\"code\" in context) return respond([`[${context.code}] ${context.message}`], context);\n\t\t\t\tconst lane = await readLane(context.paths, laneKey!);\n\t\t\t\tif (!lane || lane.status !== \"active\") {\n\t\t\t\t\tconst message = `active lane '${laneKey}' is not available`;\n\t\t\t\t\treturn respond([`[lane_not_found] ${message}`], { code: \"lane_not_found\", message });\n\t\t\t\t}\n\t\t\t\tconst execInLane = (command: string, args: string[], timeout: number) =>\n\t\t\t\t\tengineDeps.exec(command, args, {\n\t\t\t\t\t\tcwd: lane.worktreePath,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\tsignal: engineDeps.signal,\n\t\t\t\t\t\tmaxBuffer: 1024 * 1024,\n\t\t\t\t\t});\n\n\t\t\t\tconst requestedPaths = input.paths ?? [];\n\t\t\t\tconst gitPaths: string[] = [];\n\t\t\t\tfor (const requestedPath of requestedPaths) {\n\t\t\t\t\tif (!requestedPath || isAbsolute(requestedPath) || requestedPath.includes(\"\\0\")) {\n\t\t\t\t\t\tconst message = \"git path must be a non-empty relative path without NUL\";\n\t\t\t\t\t\treturn respond([`[path_outside_lane] ${message}`], { code: \"path_outside_lane\", message });\n\t\t\t\t\t}\n\t\t\t\t\tconst resolved = resolveLaneMutationPath(lane.worktreePath, requestedPath);\n\t\t\t\t\tif (!resolved) {\n\t\t\t\t\t\tconst message = `path '${requestedPath}' escapes the lane worktree`;\n\t\t\t\t\t\treturn respond([`[path_outside_lane] ${message}`], { code: \"path_outside_lane\", message });\n\t\t\t\t\t}\n\t\t\t\t\tgitPaths.push(relative(lane.worktreePath, resolved) || \".\");\n\t\t\t\t}\n\n\t\t\t\tlet command: string;\n\t\t\t\tlet args: string[];\n\t\t\t\tswitch (input.action) {\n\t\t\t\t\tcase \"git_status\":\n\t\t\t\t\t\tcommand = \"git\";\n\t\t\t\t\t\targs = [\"status\", \"--short\", \"--branch\"];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"git_diff\":\n\t\t\t\t\t\tcommand = \"git\";\n\t\t\t\t\t\targs = [\"diff\", \"--\", ...gitPaths];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"git_add\":\n\t\t\t\t\t\tif (gitPaths.length === 0) {\n\t\t\t\t\t\t\tconst message = \"git_add requires one or more explicit in-lane paths\";\n\t\t\t\t\t\t\treturn respond([`[path_outside_lane] ${message}`], { code: \"path_outside_lane\", message });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcommand = \"git\";\n\t\t\t\t\t\targs = [\"add\", \"--\", ...gitPaths];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"git_commit\":\n\t\t\t\t\t\tif (!input.message?.trim() || input.message.includes(\"\\0\")) {\n\t\t\t\t\t\t\tconst message = \"git_commit requires a non-empty literal message\";\n\t\t\t\t\t\t\treturn respond([`[git_failed] ${message}`], { code: \"git_failed\", message });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcommand = \"git\";\n\t\t\t\t\t\targs = [\"commit\", \"-m\", input.message];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"check\": {\n\t\t\t\t\t\tconst trustedCommand = settings.gateCommand?.trim();\n\t\t\t\t\t\tif (!trustedCommand) {\n\t\t\t\t\t\t\tconst message = \"no trusted worktree check is configured\";\n\t\t\t\t\t\t\treturn respond([`[gate_command_unset] ${message}`], { code: \"gate_command_unset\", message });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst shell = process.platform === \"win32\" ? \"cmd\" : \"sh\";\n\t\t\t\t\t\tconst shellFlag = process.platform === \"win32\" ? \"/c\" : \"-c\";\n\t\t\t\t\t\tconst result = await execInLane(shell, [shellFlag, trustedCommand], 900_000);\n\t\t\t\t\t\tconst output = `${result.stdout}\\n${result.stderr}`.trim().slice(-8000);\n\t\t\t\t\t\tif (result.code !== 0) {\n\t\t\t\t\t\t\treturn respond([`[gate_failed] ${output || `trusted check exited ${result.code}`}`], {\n\t\t\t\t\t\t\t\tcode: \"gate_failed\",\n\t\t\t\t\t\t\t\texitCode: result.code,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn respond([output || \"trusted check passed\"], { code: \"ok\", action: input.action });\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn respond([\"typed lane action is unavailable for this request\"], { code: \"role_forbidden\" });\n\t\t\t\t}\n\n\t\t\t\tconst result = await execInLane(command, args, 60_000);\n\t\t\t\tconst output = `${result.stdout}\\n${result.stderr}`.trim().slice(-8000);\n\t\t\t\tif (result.code !== 0) {\n\t\t\t\t\treturn respond([`[git_failed] ${output || `${command} exited ${result.code}`}`], {\n\t\t\t\t\t\tcode: \"git_failed\",\n\t\t\t\t\t\taction: input.action,\n\t\t\t\t\t\texitCode: result.code,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn respond([output || `${input.action} completed`], { code: \"ok\", action: input.action });\n\t\t\t};\n\n\t\t\tif (deps.isWorker()) {\n\t\t\t\tconst bound = deps.boundLaneKey();\n\t\t\t\tif (input.laneKey !== undefined && input.laneKey !== bound) {\n\t\t\t\t\tconst message = \"workers may only target their bound lane\";\n\t\t\t\t\treturn respond([message], { code: \"role_forbidden\", message });\n\t\t\t\t}\n\t\t\t\tconst landAllowed = input.action === \"land\" && settings.workerLand === \"allow\";\n\t\t\t\tif (!WORKER_ALLOWED_ACTIONS.has(input.action) && !landAllowed) {\n\t\t\t\t\tconst message =\n\t\t\t\t\t\tinput.action === \"land\"\n\t\t\t\t\t\t\t? 'workers may not land (worktreeSync.workerLand is \"deny\")'\n\t\t\t\t\t\t\t: `workers may not run action \"${input.action}\"`;\n\t\t\t\t\treturn respond([message], { code: \"role_forbidden\", message });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch (input.action) {\n\t\t\t\tcase \"git_status\":\n\t\t\t\tcase \"git_diff\":\n\t\t\t\tcase \"git_add\":\n\t\t\t\tcase \"git_commit\":\n\t\t\t\tcase \"check\":\n\t\t\t\t\treturn runTypedLaneAction();\n\t\t\t\tcase \"status\": {\n\t\t\t\t\tconst status = await buildSyncStatus(engineDeps, { policy: settings.syncPolicy });\n\t\t\t\t\tif (status.code !== \"ok\") return respond([`[${status.code}] ${status.message}`], status);\n\t\t\t\t\treturn respond(formatStatus(status), status);\n\t\t\t\t}\n\t\t\t\tcase \"create_lane\": {\n\t\t\t\t\tconst created = await createLane(engineDeps, {\n\t\t\t\t\t\t...(input.laneKey !== undefined ? { laneKey: input.laneKey } : {}),\n\t\t\t\t\t\t...(input.goalId !== undefined ? { goalId: input.goalId } : {}),\n\t\t\t\t\t\t...(input.requirementId !== undefined ? { requirementId: input.requirementId } : {}),\n\t\t\t\t\t});\n\t\t\t\t\tif (created.code !== \"ok\") return respond([`[${created.code}] ${created.message}`], created);\n\t\t\t\t\treturn respond(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t`lane '${created.lane.laneKey}' created: branch ${created.lane.branch}, checkout ${created.lane.worktreePath}`,\n\t\t\t\t\t\t],\n\t\t\t\t\t\tcreated,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase \"sync\": {\n\t\t\t\t\tconst missing = needLane();\n\t\t\t\t\tif (missing) return respond([missing], { code: \"lane_not_found\", message: missing });\n\t\t\t\t\tconst synced = await syncLane(engineDeps, { laneKey: laneKey as string });\n\t\t\t\t\tif (synced.code === \"sync_clean\") {\n\t\t\t\t\t\treturn respond(\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tsynced.alreadyFresh\n\t\t\t\t\t\t\t\t\t? `lane '${synced.laneKey}' already contains current main -- nothing to do`\n\t\t\t\t\t\t\t\t\t: `lane '${synced.laneKey}' rebased onto current main (auto-continued ${synced.autoContinued} step(s))`,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tsynced,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (synced.code === \"sync_conflicts\") return respond(formatWorklist(synced.worklist), synced);\n\t\t\t\t\treturn respond(\n\t\t\t\t\t\t[`[${synced.code}] ${synced.message}${synced.paths ? `\\n${synced.paths.join(\"\\n\")}` : \"\"}`],\n\t\t\t\t\t\tsynced,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase \"continue\": {\n\t\t\t\t\tconst missing = needLane();\n\t\t\t\t\tif (missing) return respond([missing], { code: \"lane_not_found\", message: missing });\n\t\t\t\t\tconst continued = await continueSync(engineDeps, { laneKey: laneKey as string });\n\t\t\t\t\tif (continued.code === \"sync_clean\") {\n\t\t\t\t\t\treturn respond(\n\t\t\t\t\t\t\t[`lane '${continued.laneKey}' rebase completed -- lane is fresh relative to the synced main`],\n\t\t\t\t\t\t\tcontinued,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (continued.code === \"sync_conflicts\") return respond(formatWorklist(continued.worklist), continued);\n\t\t\t\t\treturn respond(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t`[${continued.code}] ${continued.message}${continued.paths ? `\\n${continued.paths.join(\"\\n\")}` : \"\"}`,\n\t\t\t\t\t\t],\n\t\t\t\t\t\tcontinued,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase \"abort_sync\": {\n\t\t\t\t\tconst missing = needLane();\n\t\t\t\t\tif (missing) return respond([missing], { code: \"lane_not_found\", message: missing });\n\t\t\t\t\tconst aborted = await abortSync(engineDeps, { laneKey: laneKey as string });\n\t\t\t\t\tif (aborted.code !== \"ok\") return respond([`[${aborted.code}] ${aborted.message}`], aborted);\n\t\t\t\t\treturn respond(\n\t\t\t\t\t\t[`lane '${aborted.laneKey}' rebase aborted -- back to its pre-sync tip (still stale)`],\n\t\t\t\t\t\taborted,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase \"land\": {\n\t\t\t\t\tconst missing = needLane();\n\t\t\t\t\tif (missing) return respond([missing], { code: \"lane_not_found\", message: missing });\n\t\t\t\t\tconst landed = await landLane(engineDeps, {\n\t\t\t\t\t\tlaneKey: laneKey as string,\n\t\t\t\t\t\tgate: settings.gate,\n\t\t\t\t\t\t...(settings.gateCommand !== undefined ? { gateCommand: settings.gateCommand } : {}),\n\t\t\t\t\t\tgateTimeoutMs: settings.gateTimeoutMs,\n\t\t\t\t\t});\n\t\t\t\t\tif (landed.code !== \"ok\") {\n\t\t\t\t\t\treturn respond(\n\t\t\t\t\t\t\t[`[${landed.code}] ${landed.message}${landed.paths ? `\\n${landed.paths.join(\"\\n\")}` : \"\"}`],\n\t\t\t\t\t\t\tlanded,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn respond(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t`lane '${landed.laneKey}' LANDED: epoch ${landed.epoch}, main is now ${landed.mainSha.slice(0, 12)} (gate: ${landed.gate}). All other lanes must sync before their next land.`,\n\t\t\t\t\t\t],\n\t\t\t\t\t\tlanded,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcase \"release_lane\": {\n\t\t\t\t\tconst missing = needLane();\n\t\t\t\t\tif (missing) return respond([missing], { code: \"lane_not_found\", message: missing });\n\t\t\t\t\tconst released = await releaseLane(engineDeps, {\n\t\t\t\t\t\tlaneKey: laneKey as string,\n\t\t\t\t\t\t...(input.confirm !== undefined ? { confirm: input.confirm } : {}),\n\t\t\t\t\t});\n\t\t\t\t\tif (released.code !== \"released\") return respond([`[${released.code}] ${released.message}`], released);\n\t\t\t\t\treturn respond([`lane '${released.laneKey}' released`], released);\n\t\t\t\t}\n\t\t\t\tcase \"reconcile\": {\n\t\t\t\t\tconst reconciled = await reconcile(engineDeps);\n\t\t\t\t\tif (reconciled.code !== \"reconciled\")\n\t\t\t\t\t\treturn respond([`[${reconciled.code}] ${reconciled.message}`], reconciled);\n\t\t\t\t\treturn respond(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t`reconciled: ${reconciled.orphanedLaneKeys.length} orphaned, ${reconciled.reRegisteredLaneKeys.length} re-registered, ${reconciled.ownerClearedLaneKeys.length} owners cleared${reconciled.staleLockReleased ? \", stale lock released\" : \"\"}`,\n\t\t\t\t\t\t],\n\t\t\t\t\t\treconciled,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
@@ -207,9 +207,9 @@ export function createWriteToolDefinition(cwd, options) {
207
207
  description: "Create a new file without overwriting. Send path and exactly one of content or contentRef. After a path-only collision, use the returned payloadRef with only a corrected path. The harness owns preflight, bounded payload retention, and atomic rechecks.",
208
208
  promptSnippet: "Preflight new paths; never overwrite",
209
209
  promptGuidelines: [
210
- "Call write once with path and exactly one of content or contentRef; preparation and collision checks are harness-owned.",
211
- "If a collision result returns payloadRef, choose a new path and reuse that reference instead of regenerating content.",
212
- "Write is create-only; edit existing files. Reuse contentRef for exact copies.",
210
+ "Call once: path plus exactly one of content/contentRef; harness owns preparation/collision checks.",
211
+ "Collision with payloadRef: choose new path, reuse reference; never regenerate content.",
212
+ "write is create-only; edit existing files. Reuse contentRef for exact copies.",
213
213
  ],
214
214
  parameters: writeSchema,
215
215
  failureRecovery: {