@caupulican/pi-adaptative 0.85.0 → 0.85.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dist/bundled-resources/runtimes/pi-shell-engine/arithmetic.py +364 -0
  3. package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +2 -1
  4. package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +16 -0
  5. package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +137 -14
  6. package/dist/bundled-resources/runtimes/pi-shell-engine/nodes.py +23 -2
  7. package/dist/bundled-resources/runtimes/pi-shell-engine/parser.py +134 -6
  8. package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +25 -2
  9. package/dist/core/agent-session-services.d.ts.map +1 -1
  10. package/dist/core/agent-session-services.js +2 -0
  11. package/dist/core/agent-session-services.js.map +1 -1
  12. package/dist/core/agent-session.d.ts +6 -5
  13. package/dist/core/agent-session.d.ts.map +1 -1
  14. package/dist/core/agent-session.js +84 -87
  15. package/dist/core/agent-session.js.map +1 -1
  16. package/dist/core/auth-guidance.d.ts.map +1 -1
  17. package/dist/core/auth-guidance.js +3 -0
  18. package/dist/core/auth-guidance.js.map +1 -1
  19. package/dist/core/autonomy/lane-tool-surface.d.ts +2 -0
  20. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  21. package/dist/core/autonomy/lane-tool-surface.js +4 -3
  22. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  23. package/dist/core/background-lane-controller.d.ts +4 -0
  24. package/dist/core/background-lane-controller.d.ts.map +1 -1
  25. package/dist/core/background-lane-controller.js +2 -0
  26. package/dist/core/background-lane-controller.js.map +1 -1
  27. package/dist/core/background-tool-task-controller.d.ts +12 -7
  28. package/dist/core/background-tool-task-controller.d.ts.map +1 -1
  29. package/dist/core/background-tool-task-controller.js +55 -19
  30. package/dist/core/background-tool-task-controller.js.map +1 -1
  31. package/dist/core/bedrock-scope.d.ts +26 -0
  32. package/dist/core/bedrock-scope.d.ts.map +1 -0
  33. package/dist/core/bedrock-scope.js +178 -0
  34. package/dist/core/bedrock-scope.js.map +1 -0
  35. package/dist/core/compaction-controller.d.ts +2 -0
  36. package/dist/core/compaction-controller.d.ts.map +1 -1
  37. package/dist/core/compaction-controller.js +35 -13
  38. package/dist/core/compaction-controller.js.map +1 -1
  39. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  40. package/dist/core/delegation/worker-delegation-controller.js +6 -0
  41. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  42. package/dist/core/extensions/loader.d.ts.map +1 -1
  43. package/dist/core/extensions/loader.js +3 -0
  44. package/dist/core/extensions/loader.js.map +1 -1
  45. package/dist/core/failure-corpus.d.ts +26 -1
  46. package/dist/core/failure-corpus.d.ts.map +1 -1
  47. package/dist/core/failure-corpus.js +17 -0
  48. package/dist/core/failure-corpus.js.map +1 -1
  49. package/dist/core/foreground-recovery-controller.d.ts +25 -2
  50. package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
  51. package/dist/core/foreground-recovery-controller.js +111 -2
  52. package/dist/core/foreground-recovery-controller.js.map +1 -1
  53. package/dist/core/foreground-terminal-handoff-controller.d.ts +27 -0
  54. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -0
  55. package/dist/core/foreground-terminal-handoff-controller.js +56 -0
  56. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -0
  57. package/dist/core/goal-loop-controller.d.ts.map +1 -1
  58. package/dist/core/goal-loop-controller.js +5 -0
  59. package/dist/core/goal-loop-controller.js.map +1 -1
  60. package/dist/core/goals/goal-auto-continue-controller.d.ts +3 -0
  61. package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
  62. package/dist/core/goals/goal-auto-continue-controller.js +28 -7
  63. package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
  64. package/dist/core/human-input-controller.d.ts +9 -0
  65. package/dist/core/human-input-controller.d.ts.map +1 -1
  66. package/dist/core/human-input-controller.js +60 -5
  67. package/dist/core/human-input-controller.js.map +1 -1
  68. package/dist/core/human-input.d.ts +12 -0
  69. package/dist/core/human-input.d.ts.map +1 -1
  70. package/dist/core/human-input.js +59 -12
  71. package/dist/core/human-input.js.map +1 -1
  72. package/dist/core/local-runtime-controller.d.ts.map +1 -1
  73. package/dist/core/local-runtime-controller.js +15 -9
  74. package/dist/core/local-runtime-controller.js.map +1 -1
  75. package/dist/core/memory/providers/file-store.d.ts +1 -0
  76. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  77. package/dist/core/memory/providers/file-store.js +252 -125
  78. package/dist/core/memory/providers/file-store.js.map +1 -1
  79. package/dist/core/model-capability.d.ts +15 -1
  80. package/dist/core/model-capability.d.ts.map +1 -1
  81. package/dist/core/model-capability.js +24 -1
  82. package/dist/core/model-capability.js.map +1 -1
  83. package/dist/core/model-registry.d.ts +5 -0
  84. package/dist/core/model-registry.d.ts.map +1 -1
  85. package/dist/core/model-registry.js +18 -0
  86. package/dist/core/model-registry.js.map +1 -1
  87. package/dist/core/model-router-controller.d.ts +6 -6
  88. package/dist/core/model-router-controller.d.ts.map +1 -1
  89. package/dist/core/model-router-controller.js +5 -5
  90. package/dist/core/model-router-controller.js.map +1 -1
  91. package/dist/core/model-tool-protocol.d.ts +3 -2
  92. package/dist/core/model-tool-protocol.d.ts.map +1 -1
  93. package/dist/core/model-tool-protocol.js +5 -1
  94. package/dist/core/model-tool-protocol.js.map +1 -1
  95. package/dist/core/models/context-sizing.d.ts +1 -0
  96. package/dist/core/models/context-sizing.d.ts.map +1 -1
  97. package/dist/core/models/context-sizing.js +4 -1
  98. package/dist/core/models/context-sizing.js.map +1 -1
  99. package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
  100. package/dist/core/models/default-model-suggestions.js +20 -10
  101. package/dist/core/models/default-model-suggestions.js.map +1 -1
  102. package/dist/core/models/llamacpp-runtime.d.ts +32 -11
  103. package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
  104. package/dist/core/models/llamacpp-runtime.js +79 -28
  105. package/dist/core/models/llamacpp-runtime.js.map +1 -1
  106. package/dist/core/models/local-execution-planner.d.ts +24 -0
  107. package/dist/core/models/local-execution-planner.d.ts.map +1 -0
  108. package/dist/core/models/local-execution-planner.js +119 -0
  109. package/dist/core/models/local-execution-planner.js.map +1 -0
  110. package/dist/core/models/local-inference-profile.d.ts +34 -0
  111. package/dist/core/models/local-inference-profile.d.ts.map +1 -0
  112. package/dist/core/models/local-inference-profile.js +74 -0
  113. package/dist/core/models/local-inference-profile.js.map +1 -0
  114. package/dist/core/models/local-runtime.d.ts +23 -4
  115. package/dist/core/models/local-runtime.d.ts.map +1 -1
  116. package/dist/core/models/local-runtime.js +11 -8
  117. package/dist/core/models/local-runtime.js.map +1 -1
  118. package/dist/core/models/managed-ollama-model.d.ts +26 -0
  119. package/dist/core/models/managed-ollama-model.d.ts.map +1 -0
  120. package/dist/core/models/managed-ollama-model.js +59 -0
  121. package/dist/core/models/managed-ollama-model.js.map +1 -0
  122. package/dist/core/models/model-ref.js +11 -11
  123. package/dist/core/models/model-ref.js.map +1 -1
  124. package/dist/core/models/prism-llamacpp-lifecycle.d.ts +10 -20
  125. package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -1
  126. package/dist/core/models/prism-llamacpp-lifecycle.js +11 -31
  127. package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -1
  128. package/dist/core/models/prism-llamacpp-server-probe.d.ts +10 -0
  129. package/dist/core/models/prism-llamacpp-server-probe.d.ts.map +1 -0
  130. package/dist/core/models/prism-llamacpp-server-probe.js +36 -0
  131. package/dist/core/models/prism-llamacpp-server-probe.js.map +1 -0
  132. package/dist/core/models/runtime-arbiter.d.ts +3 -0
  133. package/dist/core/models/runtime-arbiter.d.ts.map +1 -1
  134. package/dist/core/models/runtime-arbiter.js +2 -1
  135. package/dist/core/models/runtime-arbiter.js.map +1 -1
  136. package/dist/core/models/runtime-process.d.ts +7 -1
  137. package/dist/core/models/runtime-process.d.ts.map +1 -1
  138. package/dist/core/models/runtime-process.js +4 -2
  139. package/dist/core/models/runtime-process.js.map +1 -1
  140. package/dist/core/process-matrix/runtime.js +43 -11
  141. package/dist/core/process-matrix/runtime.js.map +1 -1
  142. package/dist/core/research/research-lane-controller.d.ts.map +1 -1
  143. package/dist/core/research/research-lane-controller.js +14 -5
  144. package/dist/core/research/research-lane-controller.js.map +1 -1
  145. package/dist/core/resource-loader.d.ts +2 -0
  146. package/dist/core/resource-loader.d.ts.map +1 -1
  147. package/dist/core/resource-loader.js +18 -6
  148. package/dist/core/resource-loader.js.map +1 -1
  149. package/dist/core/runtime-builder.d.ts +5 -1
  150. package/dist/core/runtime-builder.d.ts.map +1 -1
  151. package/dist/core/runtime-builder.js +37 -4
  152. package/dist/core/runtime-builder.js.map +1 -1
  153. package/dist/core/scout-controller.d.ts +3 -2
  154. package/dist/core/scout-controller.d.ts.map +1 -1
  155. package/dist/core/scout-controller.js +1 -0
  156. package/dist/core/scout-controller.js.map +1 -1
  157. package/dist/core/sdk.d.ts.map +1 -1
  158. package/dist/core/sdk.js +10 -8
  159. package/dist/core/sdk.js.map +1 -1
  160. package/dist/core/settings-manager.d.ts +13 -0
  161. package/dist/core/settings-manager.d.ts.map +1 -1
  162. package/dist/core/settings-manager.js +59 -0
  163. package/dist/core/settings-manager.js.map +1 -1
  164. package/dist/core/system-prompt-builder.d.ts +5 -2
  165. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  166. package/dist/core/system-prompt-builder.js +22 -10
  167. package/dist/core/system-prompt-builder.js.map +1 -1
  168. package/dist/core/system-prompt.d.ts +3 -0
  169. package/dist/core/system-prompt.d.ts.map +1 -1
  170. package/dist/core/system-prompt.js +181 -55
  171. package/dist/core/system-prompt.js.map +1 -1
  172. package/dist/core/tool-protocol-controller.d.ts.map +1 -1
  173. package/dist/core/tool-protocol-controller.js +5 -3
  174. package/dist/core/tool-protocol-controller.js.map +1 -1
  175. package/dist/core/tool-recovery-log-records.d.ts +33 -1
  176. package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
  177. package/dist/core/tool-recovery-log-records.js +59 -12
  178. package/dist/core/tool-recovery-log-records.js.map +1 -1
  179. package/dist/core/tool-recovery-logger.d.ts +12 -1
  180. package/dist/core/tool-recovery-logger.d.ts.map +1 -1
  181. package/dist/core/tool-recovery-logger.js +24 -1
  182. package/dist/core/tool-recovery-logger.js.map +1 -1
  183. package/dist/core/tool-repair-health.d.ts.map +1 -1
  184. package/dist/core/tool-repair-health.js +6 -0
  185. package/dist/core/tool-repair-health.js.map +1 -1
  186. package/dist/core/tools/bash.d.ts +2 -2
  187. package/dist/core/tools/bash.d.ts.map +1 -1
  188. package/dist/core/tools/bash.js +2 -2
  189. package/dist/core/tools/bash.js.map +1 -1
  190. package/dist/core/tools/edit-diff.d.ts +2 -0
  191. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  192. package/dist/core/tools/edit-diff.js +9 -1
  193. package/dist/core/tools/edit-diff.js.map +1 -1
  194. package/dist/core/tools/edit.d.ts +5 -8
  195. package/dist/core/tools/edit.d.ts.map +1 -1
  196. package/dist/core/tools/edit.js +88 -55
  197. package/dist/core/tools/edit.js.map +1 -1
  198. package/dist/core/tools/file-mutation-intent.d.ts +42 -15
  199. package/dist/core/tools/file-mutation-intent.d.ts.map +1 -1
  200. package/dist/core/tools/file-mutation-intent.js +271 -77
  201. package/dist/core/tools/file-mutation-intent.js.map +1 -1
  202. package/dist/core/tools/find.d.ts +2 -1
  203. package/dist/core/tools/find.d.ts.map +1 -1
  204. package/dist/core/tools/find.js +2 -6
  205. package/dist/core/tools/find.js.map +1 -1
  206. package/dist/core/tools/grep.d.ts +2 -1
  207. package/dist/core/tools/grep.d.ts.map +1 -1
  208. package/dist/core/tools/grep.js +2 -6
  209. package/dist/core/tools/grep.js.map +1 -1
  210. package/dist/core/tools/index.d.ts +1 -1
  211. package/dist/core/tools/index.d.ts.map +1 -1
  212. package/dist/core/tools/index.js +1 -1
  213. package/dist/core/tools/index.js.map +1 -1
  214. package/dist/core/tools/managed-search-tool.d.ts +8 -0
  215. package/dist/core/tools/managed-search-tool.d.ts.map +1 -0
  216. package/dist/core/tools/managed-search-tool.js +10 -0
  217. package/dist/core/tools/managed-search-tool.js.map +1 -0
  218. package/dist/core/tools/shell-command-parser.d.ts +4 -3
  219. package/dist/core/tools/shell-command-parser.d.ts.map +1 -1
  220. package/dist/core/tools/shell-command-parser.js +32 -7
  221. package/dist/core/tools/shell-command-parser.js.map +1 -1
  222. package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
  223. package/dist/core/tools/shell-contract-router.js +23 -1
  224. package/dist/core/tools/shell-contract-router.js.map +1 -1
  225. package/dist/core/tools/windows-shell-engine.js +1 -1
  226. package/dist/core/tools/windows-shell-engine.js.map +1 -1
  227. package/dist/core/tools/write.d.ts +5 -10
  228. package/dist/core/tools/write.d.ts.map +1 -1
  229. package/dist/core/tools/write.js +92 -73
  230. package/dist/core/tools/write.js.map +1 -1
  231. package/dist/index.d.ts +1 -1
  232. package/dist/index.d.ts.map +1 -1
  233. package/dist/index.js +1 -1
  234. package/dist/index.js.map +1 -1
  235. package/dist/modes/interactive/auth-dialogs-controller.d.ts +6 -0
  236. package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
  237. package/dist/modes/interactive/auth-dialogs-controller.js +59 -12
  238. package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
  239. package/dist/modes/interactive/local-model-commands.d.ts +1 -1
  240. package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
  241. package/dist/modes/interactive/local-model-commands.js +51 -8
  242. package/dist/modes/interactive/local-model-commands.js.map +1 -1
  243. package/dist/utils/paths.js +1 -1
  244. package/dist/utils/paths.js.map +1 -1
  245. package/dist/utils/tools-manager.d.ts +18 -1
  246. package/dist/utils/tools-manager.d.ts.map +1 -1
  247. package/dist/utils/tools-manager.js +73 -43
  248. package/dist/utils/tools-manager.js.map +1 -1
  249. package/docs/models.md +1 -1
  250. package/docs/providers.md +34 -10
  251. package/docs/settings.md +1 -1
  252. package/docs/tool-boundary-performance-roadmap-2026-08-02.md +21 -18
  253. package/docs/tool-repair.md +3 -3
  254. package/docs/windows.md +7 -5
  255. package/examples/extensions/built-in-tool-renderer.ts +1 -1
  256. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  257. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  258. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  259. package/examples/extensions/minimal-mode.ts +1 -1
  260. package/examples/extensions/prompt-customizer.ts +2 -2
  261. package/examples/extensions/sandbox/package-lock.json +2 -2
  262. package/examples/extensions/sandbox/package.json +1 -1
  263. package/examples/extensions/ssh.ts +17 -0
  264. package/examples/extensions/with-deps/package-lock.json +2 -2
  265. package/examples/extensions/with-deps/package.json +1 -1
  266. package/npm-shrinkwrap.json +240 -260
  267. package/package.json +6 -6
@@ -9,12 +9,7 @@ type EditRenderState = {
9
9
  callComponent?: EditCallRenderComponent;
10
10
  };
11
11
  declare const editSchema: Type.TUnion<[Type.TObject<{
12
- action: Type.TLiteral<"prepare">;
13
12
  path: Type.TString;
14
- }>, Type.TObject<{
15
- action: Type.TLiteral<"commit">;
16
- path: Type.TString;
17
- intentId: Type.TString;
18
13
  edits: Type.TArray<Type.TObject<{
19
14
  oldText: Type.TString;
20
15
  newText: Type.TString;
@@ -23,11 +18,13 @@ declare const editSchema: Type.TUnion<[Type.TObject<{
23
18
  endLine: Type.TInteger;
24
19
  }>>;
25
20
  }>>;
21
+ }>, Type.TObject<{
22
+ path: Type.TString;
23
+ payloadRef: Type.TString;
26
24
  }>]>;
27
25
  export type EditToolInput = Static<typeof editSchema>;
28
26
  export interface EditToolDetails {
29
- phase: "prepared" | "committed";
30
- intentId?: string;
27
+ phase: "edited";
31
28
  contentRef?: string;
32
29
  /** Display-oriented diff of the changes made */
33
30
  diff?: string;
@@ -51,7 +48,7 @@ export interface EditOperations {
51
48
  export interface EditToolOptions {
52
49
  /** Custom operations for file editing. Default: local filesystem */
53
50
  operations?: EditOperations;
54
- /** Session-owned two-phase intent and exact-content-reference authority. */
51
+ /** Session-owned harness preflight and exact-content-reference authority. */
55
52
  intentController?: FileMutationIntentController;
56
53
  }
57
54
  type EditCallRenderComponent = Box & {
@@ -1 +1 @@
1
- {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,GAAG,EAA2B,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAMN,KAAK,aAAa,EAClB,KAAK,cAAc,EAOnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAMzE,KAAK,WAAW,GAAG,cAAc,GAAG,aAAa,CAAC;AAElD,KAAK,eAAe,GAAG;IACtB,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACxC,CAAC;AAoBF,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;IAmBd,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAUtD,MAAM,WAAW,eAAe;IAC/B,KAAK,EAAE,UAAU,GAAG,WAAW,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wFAAwF;IACxF,eAAe,CAAC,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wMF,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,eAAe,GACvB,cAAc,CAAC,OAAO,UAAU,EAAE,eAAe,GAAG,SAAS,EAAE,eAAe,CAAC,CA+LjF;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAEnG"}
@@ -2,9 +2,9 @@ import { Box, Container, Spacer, Text } from "@caupulican/pi-tui";
2
2
  import { readFile as fsReadFile, writeFile as fsWriteFile } from "fs/promises";
3
3
  import { Type } from "typebox";
4
4
  import { renderDiff } from "../../modes/interactive/components/diff.js";
5
- import { applyEditMatchPlan, applyEditsToNormalizedContent, computeEditsPlannedDiff, detectLineEnding, generateDiffString, generateUnifiedPatch, normalizeToLF, restoreLineEndings, stripBom, } from "./edit-diff.js";
5
+ import { applyEditMatchPlan, applyEditsToNormalizedContent, computeEditsPlannedDiff, detectLineEnding, digestNormalizedEditSource, generateDiffString, generateUnifiedPatch, normalizeToLF, restoreLineEndings, stripBom, } from "./edit-diff.js";
6
6
  import { isValidUTF8 } from "./file-encoding-policy.js";
7
- import { FileMutationIntentController } from "./file-mutation-intent.js";
7
+ import { FileMutationIntentController, FileMutationPreflightError, } from "./file-mutation-intent.js";
8
8
  import { withFileMutationQueue } from "./file-mutation-queue.js";
9
9
  import { resolveToCwd } from "./path-utils.js";
10
10
  import { renderToolPath, str } from "./render-utils.js";
@@ -20,43 +20,52 @@ const replaceEditSchema = Type.Object({
20
20
  const editPathSchema = Type.String({ minLength: 1 });
21
21
  const editSchema = Type.Union([
22
22
  Type.Object({
23
- action: Type.Literal("prepare"),
24
23
  path: editPathSchema,
25
- }, { additionalProperties: false }),
26
- Type.Object({
27
- action: Type.Literal("commit"),
28
- path: editPathSchema,
29
- intentId: Type.String({ minLength: 1 }),
30
24
  edits: Type.Array(replaceEditSchema, {
31
25
  minItems: 1,
32
26
  }),
33
27
  }, { additionalProperties: false }),
28
+ Type.Object({
29
+ path: editPathSchema,
30
+ payloadRef: Type.String({ minLength: 1 }),
31
+ }, { additionalProperties: false }),
34
32
  ]);
35
33
  const defaultEditOperations = {
36
34
  readFile: (path) => fsReadFile(path),
37
35
  writeFile: (path, content) => fsWriteFile(path, content, "utf-8"),
38
36
  };
39
37
  function prepareEditArguments(input) {
40
- if (!input || typeof input !== "object") {
38
+ if (!input || typeof input !== "object" || Array.isArray(input)) {
41
39
  return input;
42
40
  }
43
- const args = input;
41
+ let args = input;
44
42
  const legacy = args;
45
- if (typeof legacy.oldText !== "string" || typeof legacy.newText !== "string") {
46
- return args;
43
+ if (typeof legacy.oldText === "string" && typeof legacy.newText === "string") {
44
+ const edits = Array.isArray(legacy.edits) ? [...legacy.edits] : [];
45
+ edits.push({ oldText: legacy.oldText, newText: legacy.newText });
46
+ const { oldText: _oldText, newText: _newText, ...rest } = legacy;
47
+ args = { ...rest, edits };
47
48
  }
48
- const edits = Array.isArray(legacy.edits) ? [...legacy.edits] : [];
49
- edits.push({ oldText: legacy.oldText, newText: legacy.newText });
50
- const { oldText: _oldText, newText: _newText, ...rest } = legacy;
51
- return { ...rest, edits };
49
+ return args;
52
50
  }
53
- function validateEditInput(input) {
54
- if (input.action === "prepare")
55
- return input;
56
- if (!Array.isArray(input.edits) || input.edits.length === 0) {
51
+ function validateEdits(edits) {
52
+ if (!Array.isArray(edits) || edits.length === 0) {
57
53
  throw new Error("Edit tool input is invalid. edits must contain at least one replacement.");
58
54
  }
59
- return { action: "commit", path: input.path, intentId: input.intentId, edits: input.edits };
55
+ for (const edit of edits) {
56
+ if (typeof edit !== "object" ||
57
+ edit === null ||
58
+ typeof edit.oldText !== "string" ||
59
+ typeof edit.newText !== "string") {
60
+ throw new Error("Edit tool input is invalid. Every edit requires string oldText and newText fields.");
61
+ }
62
+ }
63
+ return edits;
64
+ }
65
+ function validateEditInput(input) {
66
+ if ("payloadRef" in input)
67
+ return { path: input.path, payloadRef: input.payloadRef };
68
+ return { path: input.path, edits: validateEdits(input.edits) };
60
69
  }
61
70
  function createEditCallRenderComponent() {
62
71
  return Object.assign(new Box(1, 1, (text) => text), {
@@ -83,21 +92,17 @@ function getRenderablePreviewInput(args) {
83
92
  if (!args) {
84
93
  return null;
85
94
  }
86
- if (args.action !== "commit")
87
- return null;
88
95
  const path = typeof args.path === "string" ? args.path : typeof args.file_path === "string" ? args.file_path : null;
89
96
  if (!path) {
90
97
  return null;
91
98
  }
92
- if (typeof args.intentId !== "string" || args.intentId.length === 0)
93
- return null;
94
99
  if (Array.isArray(args.edits) &&
95
100
  args.edits.length > 0 &&
96
101
  args.edits.every((edit) => typeof edit?.oldText === "string" && typeof edit?.newText === "string")) {
97
- return { path, intentId: args.intentId, edits: args.edits };
102
+ return { path, edits: args.edits };
98
103
  }
99
104
  if (typeof args.oldText === "string" && typeof args.newText === "string") {
100
- return { path, intentId: args.intentId, edits: [{ oldText: args.oldText, newText: args.newText }] };
105
+ return { path, edits: [{ oldText: args.oldText, newText: args.newText }] };
101
106
  }
102
107
  return null;
103
108
  }
@@ -125,8 +130,7 @@ function editsMatch(left, right) {
125
130
  }
126
131
  function formatEditCall(args, theme, cwd) {
127
132
  const pathDisplay = renderToolPath(str(args?.file_path ?? args?.path), theme, cwd);
128
- const action = args?.action === "prepare" ? "prepare" : args?.action === "commit" ? "commit" : undefined;
129
- return `${theme.fg("toolTitle", theme.bold("edit"))}${action ? ` ${theme.fg("muted", action)}` : ""} ${pathDisplay}`;
133
+ return `${theme.fg("toolTitle", theme.bold("edit"))} ${pathDisplay}`;
130
134
  }
131
135
  function formatEditResult(args, preview, result, theme, isError) {
132
136
  const rawPath = str(args?.file_path ?? args?.path);
@@ -148,6 +152,23 @@ function formatEditResult(args, preview, result, theme, isError) {
148
152
  }
149
153
  return undefined;
150
154
  }
155
+ async function editPathFailureWithRetainedPayload(error, validated, intentController, signal) {
156
+ const failureIdentity = error.reason === "edit_missing" ? "edit_missing (ENOENT)" : "edit_not_file";
157
+ if (validated.payloadRef) {
158
+ await intentController.assertMutationPayload(validated.payloadRef, "edit", signal);
159
+ return new Error(`PI_FILE_MUTATION_RETARGET ${failureIdentity}: payloadRef ${validated.payloadRef}. Choose only a corrected path naming an existing file; the exact valid edit payload is retained for full revalidation.`);
160
+ }
161
+ try {
162
+ const retained = await intentController.retainMutationPayload("edit", JSON.stringify(validated.edits));
163
+ if (retained) {
164
+ return new Error(`PI_FILE_MUTATION_RETARGET ${failureIdentity}: payloadRef ${retained.payloadRef}. Choose only a corrected path naming an existing file; the exact valid edit payload is retained for full revalidation.`);
165
+ }
166
+ }
167
+ catch {
168
+ // The path failure remains authoritative when the bounded retry cache is unavailable.
169
+ }
170
+ return new Error(`${error.message} The edit payload could not be retained within the secure retry-cache bound.`);
171
+ }
151
172
  function getEditHeaderBg(preview, settledError, theme) {
152
173
  if (preview) {
153
174
  if ("error" in preview) {
@@ -195,10 +216,11 @@ export function createEditToolDefinition(cwd, options) {
195
216
  return {
196
217
  name: "edit",
197
218
  label: "edit",
198
- description: "Edit existing UTF-8 text: prepare(path), then commit(path,intentId,edits). oldText must be exact, unique, and non-overlapping; optional inclusive line ranges bind matches to prior reads; stale targets are rejected.",
199
- promptSnippet: "Preflight existing files; commit exact, stale-safe edits",
219
+ description: "Edit existing UTF-8 text in one call. Send path and all edits; after a path-only failure, reuse the returned payloadRef with only the corrected path. The harness preflights, revalidates, and stale-checks every exact replacement.",
220
+ promptSnippet: "Preflight existing files; apply exact, stale-safe edits",
200
221
  promptGuidelines: [
201
- "Before replacements, prepare(path); then commit once with intentId and all edits.",
222
+ "Call edit once with path and all replacements; preparation and stale-target checks are harness-owned.",
223
+ "If a path failure returns payloadRef, choose the correct existing path and reuse that reference instead of regenerating edits.",
202
224
  "oldText is exact, unique, minimal, and original-file based; pass the inclusive line range from the supplying read when known, batch separate edits, and merge overlaps.",
203
225
  ],
204
226
  parameters: editSchema,
@@ -208,6 +230,17 @@ export function createEditToolDefinition(cwd, options) {
208
230
  const validated = validateEditInput(input);
209
231
  const { path } = validated;
210
232
  const absolutePath = resolveToCwd(path, cwd);
233
+ let lease;
234
+ try {
235
+ lease = await intentController.prepare("edit", absolutePath, signal, path);
236
+ }
237
+ catch (error) {
238
+ if (error instanceof FileMutationPreflightError &&
239
+ (error.reason === "edit_missing" || error.reason === "edit_not_file")) {
240
+ throw await editPathFailureWithRetainedPayload(error, validated, intentController, signal);
241
+ }
242
+ throw error;
243
+ }
211
244
  return withFileMutationQueue(absolutePath, async () => {
212
245
  // Do not reject from an abort event listener here: that would release the
213
246
  // mutation queue while an in-flight filesystem operation may still finish.
@@ -218,20 +251,15 @@ export function createEditToolDefinition(cwd, options) {
218
251
  throw new Error("Operation aborted");
219
252
  };
220
253
  throwIfAborted();
221
- if (validated.action === "prepare") {
222
- const prepared = await intentController.prepare("edit", absolutePath, signal, path);
223
- return {
224
- content: [
225
- {
226
- type: "text",
227
- text: `Edit target accepted. Commit ${path} with intentId ${prepared.intentId}.`,
228
- },
229
- ],
230
- details: { phase: "prepared", intentId: prepared.intentId },
231
- };
254
+ let payloadRef;
255
+ let edits;
256
+ if (validated.edits !== undefined) {
257
+ edits = validated.edits;
258
+ }
259
+ else {
260
+ payloadRef = validated.payloadRef;
261
+ edits = validateEdits(JSON.parse(await intentController.readMutationPayload(payloadRef, "edit", signal)));
232
262
  }
233
- const { edits, intentId } = validated;
234
- const lease = intentController.consume(intentId, "edit", absolutePath);
235
263
  await intentController.assertCurrent(lease, signal);
236
264
  throwIfAborted();
237
265
  // Read the file.
@@ -245,33 +273,38 @@ export function createEditToolDefinition(cwd, options) {
245
273
  const { bom, text: content } = stripBom(rawContent);
246
274
  const originalEnding = detectLineEnding(content);
247
275
  const normalizedContent = normalizeToLF(content);
248
- const cachedForIntent = cachedMatchPlan?.intentId === intentId ? cachedMatchPlan : undefined;
249
- if (cachedForIntent)
276
+ const cachedForInput = cachedMatchPlan?.absolutePath === absolutePath && editsMatch(cachedMatchPlan.edits, edits)
277
+ ? cachedMatchPlan
278
+ : undefined;
279
+ if (cachedForInput)
250
280
  cachedMatchPlan = undefined;
251
- const matchPlanReused = cachedForIntent !== undefined &&
252
- cachedForIntent.absolutePath === absolutePath &&
253
- editsMatch(cachedForIntent.edits, edits);
281
+ const matchPlanReused = cachedForInput !== undefined &&
282
+ cachedForInput.sourceDigest === digestNormalizedEditSource(normalizedContent);
254
283
  const { baseContent, newContent } = matchPlanReused
255
- ? applyEditMatchPlan(normalizedContent, cachedForIntent.plan, path)
284
+ ? applyEditMatchPlan(normalizedContent, cachedForInput.plan, path)
256
285
  : applyEditsToNormalizedContent(normalizedContent, edits, path);
257
286
  throwIfAborted();
258
287
  const finalContent = bom + restoreLineEndings(newContent, originalEnding);
288
+ await intentController.assertCurrent(lease, signal);
289
+ throwIfAborted();
259
290
  await ops.writeFile(absolutePath, finalContent);
260
291
  throwIfAborted();
261
292
  const contentReference = intentController.rememberContent(absolutePath, finalContent);
293
+ if (payloadRef)
294
+ await intentController.discardMutationPayload(payloadRef);
262
295
  const diffResult = matchPlanReused
263
- ? { diff: cachedForIntent.diff, firstChangedLine: cachedForIntent.firstChangedLine }
296
+ ? { diff: cachedForInput.diff, firstChangedLine: cachedForInput.firstChangedLine }
264
297
  : generateDiffString(baseContent, newContent);
265
298
  const patch = generateUnifiedPatch(path, baseContent, newContent);
266
299
  return {
267
300
  content: [
268
301
  {
269
302
  type: "text",
270
- text: `Successfully replaced ${edits.length} block(s) in ${path}. Reuse exact bytes with contentRef ${contentReference.contentRef}.`,
303
+ text: `Successfully replaced ${edits.length} block(s) in ${path}; this edit is complete, so do not call edit again for this path. To copy these exact bytes to a different new path, call write once for that path with contentRef ${contentReference.contentRef}.`,
271
304
  },
272
305
  ],
273
306
  details: {
274
- phase: "committed",
307
+ phase: "edited",
275
308
  contentRef: contentReference.contentRef,
276
309
  diff: diffResult.diff,
277
310
  patch,
@@ -297,10 +330,10 @@ export function createEditToolDefinition(cwd, options) {
297
330
  if (component.previewRequestId === requestId) {
298
331
  if (!("error" in preview) && !options?.operations) {
299
332
  cachedMatchPlan = {
300
- intentId: previewInput.intentId,
301
333
  absolutePath: resolveToCwd(previewInput.path, context.cwd),
302
334
  edits: snapshotEdits(previewInput.edits),
303
335
  plan: preview.plan,
336
+ sourceDigest: preview.sourceDigest,
304
337
  diff: preview.diff,
305
338
  firstChangedLine: preview.firstChangedLine,
306
339
  };
@@ -1 +1 @@
1
- {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAGxE,OAAO,EACN,kBAAkB,EAClB,6BAA6B,EAC7B,uBAAuB,EACvB,gBAAgB,EAKhB,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAClB,QAAQ,GACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAQlE,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CACpC;IACC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACtC,OAAO,E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,CAAC,CAAC;YAC3G,MAAM,SAAS,GAAI,OAAO,CAAC,aAAuC,IAAI,IAAI,SAAS,EAAE,CAAC;YACtF,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,EAAE,CAAC;gBACb,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,SAAS,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC3C,OAAO,SAAS,CAAC;QAClB,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport { Box, Container, Spacer, Text } from \"@caupulican/pi-tui\";\nimport { readFile as fsReadFile, writeFile as fsWriteFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { renderDiff } from \"../../modes/interactive/components/diff.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport {\n\tapplyEditMatchPlan,\n\tapplyEditsToNormalizedContent,\n\tcomputeEditsPlannedDiff,\n\tdetectLineEnding,\n\ttype Edit,\n\ttype EditDiffError,\n\ttype EditDiffResult,\n\ttype EditMatchPlan,\n\tgenerateDiffString,\n\tgenerateUnifiedPatch,\n\tnormalizeToLF,\n\trestoreLineEndings,\n\tstripBom,\n} from \"./edit-diff.ts\";\nimport { isValidUTF8 } from \"./file-encoding-policy.ts\";\nimport { FileMutationIntentController } from \"./file-mutation-intent.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { renderToolPath, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\ntype EditPreview = EditDiffResult | EditDiffError;\n\ntype EditRenderState = {\n\tcallComponent?: EditCallRenderComponent;\n};\n\nconst replaceEditSchema = Type.Object(\n\t{\n\t\toldText: Type.String({ minLength: 1 }),\n\t\tnewText: Type.String(),\n\t\trange: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tstartLine: Type.Integer({ minimum: 1 }),\n\t\t\t\t\tendLine: Type.Integer({ minimum: 1 }),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst editPathSchema = Type.String({ minLength: 1 });\nconst editSchema = Type.Union([\n\tType.Object(\n\t\t{\n\t\t\taction: Type.Literal(\"prepare\"),\n\t\t\tpath: editPathSchema,\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n\tType.Object(\n\t\t{\n\t\t\taction: Type.Literal(\"commit\"),\n\t\t\tpath: editPathSchema,\n\t\t\tintentId: Type.String({ minLength: 1 }),\n\t\t\tedits: Type.Array(replaceEditSchema, {\n\t\t\t\tminItems: 1,\n\t\t\t}),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n]);\n\nexport type EditToolInput = Static<typeof editSchema>;\ntype LegacyEditToolInput = {\n\taction?: unknown;\n\tpath?: unknown;\n\tintentId?: unknown;\n\tedits?: unknown;\n\toldText?: unknown;\n\tnewText?: unknown;\n};\n\nexport interface EditToolDetails {\n\tphase: \"prepared\" | \"committed\";\n\tintentId?: string;\n\tcontentRef?: string;\n\t/** Display-oriented diff of the changes made */\n\tdiff?: string;\n\t/** Standard unified patch of the changes made */\n\tpatch?: string;\n\t/** Line number of the first change in the new file (for editor navigation) */\n\tfirstChangedLine?: number;\n\t/** True when execution reused the match plan already validated for the call preview. */\n\tmatchPlanReused?: boolean;\n}\n\n/**\n * Pluggable operations for the edit tool.\n * Override these to delegate file editing to remote systems (for example SSH).\n */\nexport interface EditOperations {\n\t/** Read file contents as a Buffer */\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\t/** Write content to a file */\n\twriteFile: (absolutePath: string, content: string) => Promise<void>;\n}\n\nconst defaultEditOperations: EditOperations = {\n\treadFile: (path) => fsReadFile(path),\n\twriteFile: (path, content) => fsWriteFile(path, content, \"utf-8\"),\n};\n\nexport interface EditToolOptions {\n\t/** Custom operations for file editing. Default: local filesystem */\n\toperations?: EditOperations;\n\t/** Session-owned two-phase intent and exact-content-reference authority. */\n\tintentController?: FileMutationIntentController;\n}\n\nfunction prepareEditArguments(input: unknown): EditToolInput {\n\tif (!input || typeof input !== \"object\") {\n\t\treturn input as EditToolInput;\n\t}\n\n\tconst args = input as Record<string, unknown>;\n\n\tconst legacy = args as LegacyEditToolInput;\n\tif (typeof legacy.oldText !== \"string\" || typeof legacy.newText !== \"string\") {\n\t\treturn args as EditToolInput;\n\t}\n\n\tconst edits = Array.isArray(legacy.edits) ? [...legacy.edits] : [];\n\tedits.push({ oldText: legacy.oldText, newText: legacy.newText });\n\tconst { oldText: _oldText, newText: _newText, ...rest } = legacy;\n\treturn { ...rest, edits } as EditToolInput;\n}\n\nfunction validateEditInput(\n\tinput: EditToolInput,\n): { action: \"prepare\"; path: string } | { action: \"commit\"; path: string; intentId: string; edits: Edit[] } {\n\tif (input.action === \"prepare\") return input;\n\tif (!Array.isArray(input.edits) || input.edits.length === 0) {\n\t\tthrow new Error(\"Edit tool input is invalid. edits must contain at least one replacement.\");\n\t}\n\treturn { action: \"commit\", path: input.path, intentId: input.intentId, edits: input.edits };\n}\n\ntype RenderableEditArgs = {\n\taction?: string;\n\tpath?: string;\n\tfile_path?: string;\n\tintentId?: string;\n\tedits?: Edit[];\n\toldText?: string;\n\tnewText?: string;\n};\n\ntype EditToolResultLike = {\n\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\tdetails?: EditToolDetails;\n};\n\ntype EditCallRenderComponent = Box & {\n\tpreview?: EditPreview;\n\tpreviewRequestId: number;\n\tpreviewPending?: boolean;\n\tsettledError?: boolean;\n};\n\nfunction createEditCallRenderComponent(): EditCallRenderComponent {\n\treturn Object.assign(new Box(1, 1, (text: string) => text), {\n\t\tpreview: undefined as EditPreview | undefined,\n\t\tpreviewRequestId: 0,\n\t\tpreviewPending: false,\n\t\tsettledError: false,\n\t});\n}\n\nfunction getEditCallRenderComponent(state: EditRenderState, lastComponent: unknown): EditCallRenderComponent {\n\tif (lastComponent instanceof Box) {\n\t\tconst component = lastComponent as EditCallRenderComponent;\n\t\tstate.callComponent = component;\n\t\treturn component;\n\t}\n\tif (state.callComponent) {\n\t\treturn state.callComponent;\n\t}\n\tconst component = createEditCallRenderComponent();\n\tstate.callComponent = component;\n\treturn component;\n}\n\nfunction getRenderablePreviewInput(\n\targs: RenderableEditArgs | undefined,\n): { path: string; intentId: string; edits: Edit[] } | null {\n\tif (!args) {\n\t\treturn null;\n\t}\n\tif (args.action !== \"commit\") return null;\n\n\tconst path = typeof args.path === \"string\" ? args.path : typeof args.file_path === \"string\" ? args.file_path : null;\n\tif (!path) {\n\t\treturn null;\n\t}\n\tif (typeof args.intentId !== \"string\" || args.intentId.length === 0) return null;\n\n\tif (\n\t\tArray.isArray(args.edits) &&\n\t\targs.edits.length > 0 &&\n\t\targs.edits.every((edit) => typeof edit?.oldText === \"string\" && typeof edit?.newText === \"string\")\n\t) {\n\t\treturn { path, intentId: args.intentId, edits: args.edits };\n\t}\n\n\tif (typeof args.oldText === \"string\" && typeof args.newText === \"string\") {\n\t\treturn { path, intentId: args.intentId, edits: [{ oldText: args.oldText, newText: args.newText }] };\n\t}\n\n\treturn null;\n}\n\ninterface CachedEditMatchPlan {\n\tintentId: string;\n\tabsolutePath: string;\n\tedits: Edit[];\n\tplan: EditMatchPlan;\n\tdiff: string;\n\tfirstChangedLine: number | undefined;\n}\n\nfunction snapshotEdits(edits: Edit[]): Edit[] {\n\treturn edits.map((edit) => ({\n\t\toldText: edit.oldText,\n\t\tnewText: edit.newText,\n\t\t...(edit.range ? { range: { startLine: edit.range.startLine, endLine: edit.range.endLine } } : {}),\n\t}));\n}\n\nfunction editsMatch(left: Edit[], right: Edit[]): boolean {\n\tif (left.length !== right.length) return false;\n\tfor (let index = 0; index < left.length; index++) {\n\t\tconst leftEdit = left[index];\n\t\tconst rightEdit = right[index];\n\t\tif (\n\t\t\tleftEdit.oldText !== rightEdit.oldText ||\n\t\t\tleftEdit.newText !== rightEdit.newText ||\n\t\t\tleftEdit.range?.startLine !== rightEdit.range?.startLine ||\n\t\t\tleftEdit.range?.endLine !== rightEdit.range?.endLine\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction formatEditCall(args: RenderableEditArgs | undefined, theme: Theme, cwd: string): string {\n\tconst pathDisplay = renderToolPath(str(args?.file_path ?? args?.path), theme, cwd);\n\tconst action = args?.action === \"prepare\" ? \"prepare\" : args?.action === \"commit\" ? \"commit\" : undefined;\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"edit\"))}${action ? ` ${theme.fg(\"muted\", action)}` : \"\"} ${pathDisplay}`;\n}\n\nfunction formatEditResult(\n\targs: RenderableEditArgs | undefined,\n\tpreview: EditPreview | undefined,\n\tresult: EditToolResultLike,\n\ttheme: Theme,\n\tisError: boolean,\n): string | undefined {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst previewDiff = preview && !(\"error\" in preview) ? preview.diff : undefined;\n\tconst previewError = preview && \"error\" in preview ? preview.error : undefined;\n\tif (isError) {\n\t\tconst errorText = result.content\n\t\t\t.filter((c) => c.type === \"text\")\n\t\t\t.map((c) => c.text || \"\")\n\t\t\t.join(\"\\n\");\n\t\tif (!errorText || errorText === previewError) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn theme.fg(\"error\", errorText);\n\t}\n\n\tconst resultDiff = result.details?.diff;\n\tif (resultDiff && resultDiff !== previewDiff) {\n\t\treturn renderDiff(resultDiff, { filePath: rawPath ?? undefined });\n\t}\n\n\treturn undefined;\n}\n\nfunction getEditHeaderBg(\n\tpreview: EditPreview | undefined,\n\tsettledError: boolean | undefined,\n\ttheme: Theme,\n): (text: string) => string {\n\tif (preview) {\n\t\tif (\"error\" in preview) {\n\t\t\treturn (text: string) => theme.bg(\"toolErrorBg\", text);\n\t\t}\n\t\treturn (text: string) => theme.bg(\"toolSuccessBg\", text);\n\t}\n\tif (settledError) {\n\t\treturn (text: string) => theme.bg(\"toolErrorBg\", text);\n\t}\n\treturn (text: string) => theme.bg(\"toolPendingBg\", text);\n}\n\nfunction buildEditCallComponent(\n\tcomponent: EditCallRenderComponent,\n\targs: RenderableEditArgs | undefined,\n\ttheme: Theme,\n\tcwd: string,\n): EditCallRenderComponent {\n\tcomponent.setBgFn(getEditHeaderBg(component.preview, component.settledError, theme));\n\tcomponent.clear();\n\tcomponent.addChild(new Text(formatEditCall(args, theme, cwd), 0, 0));\n\n\tif (!component.preview) {\n\t\treturn component;\n\t}\n\n\tconst body =\n\t\t\"error\" in component.preview ? theme.fg(\"error\", component.preview.error) : renderDiff(component.preview.diff);\n\tcomponent.addChild(new Spacer(1));\n\tcomponent.addChild(new Text(body, 0, 0));\n\treturn component;\n}\n\nfunction setEditPreview(component: EditCallRenderComponent, preview: EditPreview): boolean {\n\tconst current = component.preview;\n\tconst changed =\n\t\tcurrent === undefined ||\n\t\t(\"error\" in current && \"error\" in preview\n\t\t\t? current.error !== preview.error\n\t\t\t: \"error\" in current !== \"error\" in preview) ||\n\t\t(!(\"error\" in current) &&\n\t\t\t!(\"error\" in preview) &&\n\t\t\t(current.diff !== preview.diff || current.firstChangedLine !== preview.firstChangedLine));\n\tcomponent.preview = preview;\n\tcomponent.previewPending = false;\n\treturn changed;\n}\n\nexport function createEditToolDefinition(\n\tcwd: string,\n\toptions?: EditToolOptions,\n): ToolDefinition<typeof editSchema, EditToolDetails | undefined, EditRenderState> {\n\tconst ops = options?.operations ?? defaultEditOperations;\n\tif (options?.operations && !options.intentController) {\n\t\tthrow new Error(\"Custom edit operations require a matching file mutation intent controller.\");\n\t}\n\tconst intentController = options?.intentController ?? new FileMutationIntentController();\n\tlet cachedMatchPlan: CachedEditMatchPlan | undefined;\n\treturn {\n\t\tname: \"edit\",\n\t\tlabel: \"edit\",\n\t\tdescription:\n\t\t\t\"Edit existing UTF-8 text: prepare(path), then commit(path,intentId,edits). oldText must be exact, unique, and non-overlapping; optional inclusive line ranges bind matches to prior reads; stale targets are rejected.\",\n\t\tpromptSnippet: \"Preflight existing files; commit exact, stale-safe edits\",\n\t\tpromptGuidelines: [\n\t\t\t\"Before replacements, prepare(path); then commit once with intentId and all edits.\",\n\t\t\t\"oldText is exact, unique, minimal, and original-file based; pass the inclusive line range from the supplying read when known, batch separate edits, and merge overlaps.\",\n\t\t],\n\t\tparameters: editSchema,\n\t\trenderShell: \"self\",\n\t\tprepareArguments: prepareEditArguments,\n\t\tasync execute(_toolCallId, input: EditToolInput, signal?: AbortSignal, _onUpdate?, _ctx?) {\n\t\t\tconst validated = validateEditInput(input);\n\t\t\tconst { path } = validated;\n\t\t\tconst absolutePath = resolveToCwd(path, cwd);\n\n\t\t\treturn withFileMutationQueue(absolutePath, async () => {\n\t\t\t\t// Do not reject from an abort event listener here: that would release the\n\t\t\t\t// mutation queue while an in-flight filesystem operation may still finish.\n\t\t\t\t// Checking signal.aborted after each await observes the same aborts while\n\t\t\t\t// keeping the queue locked until the current operation has settled.\n\t\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t};\n\n\t\t\t\tthrowIfAborted();\n\t\t\t\tif (validated.action === \"prepare\") {\n\t\t\t\t\tconst prepared = await intentController.prepare(\"edit\", absolutePath, signal, path);\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: `Edit target accepted. Commit ${path} with intentId ${prepared.intentId}.`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: { phase: \"prepared\" as const, intentId: prepared.intentId },\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst { edits, intentId } = validated;\n\t\t\t\tconst lease = intentController.consume(intentId, \"edit\", absolutePath);\n\t\t\t\tawait intentController.assertCurrent(lease, signal);\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\t// Read the file.\n\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\tif (!isValidUTF8(buffer)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`PI_FILE_ENCODING_CORRUPTION: ${path} is not valid UTF-8 text; exact text replacement is unsafe and could corrupt its bytes.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst rawContent = buffer.toString(\"utf-8\");\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\t// Strip BOM before matching. The model will not include an invisible BOM in oldText.\n\t\t\t\tconst { bom, text: content } = stripBom(rawContent);\n\t\t\t\tconst originalEnding = detectLineEnding(content);\n\t\t\t\tconst normalizedContent = normalizeToLF(content);\n\t\t\t\tconst cachedForIntent = cachedMatchPlan?.intentId === intentId ? cachedMatchPlan : undefined;\n\t\t\t\tif (cachedForIntent) cachedMatchPlan = undefined;\n\t\t\t\tconst matchPlanReused =\n\t\t\t\t\tcachedForIntent !== undefined &&\n\t\t\t\t\tcachedForIntent.absolutePath === absolutePath &&\n\t\t\t\t\teditsMatch(cachedForIntent.edits, edits);\n\t\t\t\tconst { baseContent, newContent } = matchPlanReused\n\t\t\t\t\t? applyEditMatchPlan(normalizedContent, cachedForIntent.plan, path)\n\t\t\t\t\t: applyEditsToNormalizedContent(normalizedContent, edits, path);\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tconst finalContent = bom + restoreLineEndings(newContent, originalEnding);\n\t\t\t\tawait ops.writeFile(absolutePath, finalContent);\n\t\t\t\tthrowIfAborted();\n\t\t\t\tconst contentReference = intentController.rememberContent(absolutePath, finalContent);\n\n\t\t\t\tconst diffResult = matchPlanReused\n\t\t\t\t\t? { diff: cachedForIntent.diff, firstChangedLine: cachedForIntent.firstChangedLine }\n\t\t\t\t\t: generateDiffString(baseContent, newContent);\n\t\t\t\tconst patch = generateUnifiedPatch(path, baseContent, newContent);\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\",\n\t\t\t\t\t\t\ttext: `Successfully replaced ${edits.length} block(s) in ${path}. Reuse exact bytes with contentRef ${contentReference.contentRef}.`,\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\tphase: \"committed\" as const,\n\t\t\t\t\t\tcontentRef: contentReference.contentRef,\n\t\t\t\t\t\tdiff: diffResult.diff,\n\t\t\t\t\t\tpatch,\n\t\t\t\t\t\tfirstChangedLine: diffResult.firstChangedLine,\n\t\t\t\t\t\tmatchPlanReused,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst component = getEditCallRenderComponent(context.state, context.lastComponent);\n\t\t\tconst previewInput = getRenderablePreviewInput(args as RenderableEditArgs | undefined);\n\n\t\t\tif ((!context.argsComplete || !previewInput) && (component.preview || component.previewPending)) {\n\t\t\t\tcomponent.preview = undefined;\n\t\t\t\tcomponent.previewPending = false;\n\t\t\t\tcomponent.settledError = false;\n\t\t\t\tcomponent.previewRequestId++;\n\t\t\t}\n\n\t\t\tif (context.argsComplete && previewInput && !component.preview && !component.previewPending) {\n\t\t\t\tcomponent.previewPending = true;\n\t\t\t\tconst requestId = ++component.previewRequestId;\n\t\t\t\tvoid computeEditsPlannedDiff(previewInput.path, previewInput.edits, context.cwd).then((preview) => {\n\t\t\t\t\tif (component.previewRequestId === requestId) {\n\t\t\t\t\t\tif (!(\"error\" in preview) && !options?.operations) {\n\t\t\t\t\t\t\tcachedMatchPlan = {\n\t\t\t\t\t\t\t\tintentId: previewInput.intentId,\n\t\t\t\t\t\t\t\tabsolutePath: resolveToCwd(previewInput.path, context.cwd),\n\t\t\t\t\t\t\t\tedits: snapshotEdits(previewInput.edits),\n\t\t\t\t\t\t\t\tplan: preview.plan,\n\t\t\t\t\t\t\t\tdiff: preview.diff,\n\t\t\t\t\t\t\t\tfirstChangedLine: preview.firstChangedLine,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetEditPreview(component, preview);\n\t\t\t\t\t\tcontext.invalidate();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn buildEditCallComponent(component, args, theme, context.cwd);\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst callComponent = context.state.callComponent;\n\t\t\tconst typedResult = result as EditToolResultLike;\n\t\t\tconst resultDiff = !context.isError ? typedResult.details?.diff : undefined;\n\t\t\tlet changed = false;\n\t\t\tif (callComponent) {\n\t\t\t\tcallComponent.previewRequestId++;\n\t\t\t\tif (typeof resultDiff === \"string\") {\n\t\t\t\t\tchanged =\n\t\t\t\t\t\tsetEditPreview(callComponent, {\n\t\t\t\t\t\t\tdiff: resultDiff,\n\t\t\t\t\t\t\tfirstChangedLine: typedResult.details?.firstChangedLine,\n\t\t\t\t\t\t}) || changed;\n\t\t\t\t}\n\t\t\t\tif (callComponent.settledError !== context.isError) {\n\t\t\t\t\tcallComponent.settledError = context.isError;\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t\tif (changed) {\n\t\t\t\t\tbuildEditCallComponent(\n\t\t\t\t\t\tcallComponent,\n\t\t\t\t\t\tcontext.args as RenderableEditArgs | undefined,\n\t\t\t\t\t\ttheme,\n\t\t\t\t\t\tcontext.cwd,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst output = formatEditResult(context.args, callComponent?.preview, typedResult, theme, context.isError);\n\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\tcomponent.clear();\n\t\t\tif (!output) {\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\tcomponent.addChild(new Spacer(1));\n\t\t\tcomponent.addChild(new Text(output, 1, 0));\n\t\t\treturn component;\n\t\t},\n\t};\n}\n\nexport function createEditTool(cwd: string, options?: EditToolOptions): AgentTool<typeof editSchema> {\n\treturn wrapToolDefinition(createEditToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAGxE,OAAO,EACN,kBAAkB,EAClB,6BAA6B,EAC7B,uBAAuB,EACvB,gBAAgB,EAChB,0BAA0B,EAK1B,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAClB,QAAQ,GACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EACN,4BAA4B,EAE5B,0BAA0B,GAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAQlE,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CACpC;IACC,OAAO,EAAE,IAAI,C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;gBACb,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,SAAS,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC3C,OAAO,SAAS,CAAC;QAClB,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport { Box, Container, Spacer, Text } from \"@caupulican/pi-tui\";\nimport { readFile as fsReadFile, writeFile as fsWriteFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { renderDiff } from \"../../modes/interactive/components/diff.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport {\n\tapplyEditMatchPlan,\n\tapplyEditsToNormalizedContent,\n\tcomputeEditsPlannedDiff,\n\tdetectLineEnding,\n\tdigestNormalizedEditSource,\n\ttype Edit,\n\ttype EditDiffError,\n\ttype EditDiffResult,\n\ttype EditMatchPlan,\n\tgenerateDiffString,\n\tgenerateUnifiedPatch,\n\tnormalizeToLF,\n\trestoreLineEndings,\n\tstripBom,\n} from \"./edit-diff.ts\";\nimport { isValidUTF8 } from \"./file-encoding-policy.ts\";\nimport {\n\tFileMutationIntentController,\n\ttype FileMutationLease,\n\tFileMutationPreflightError,\n} from \"./file-mutation-intent.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { renderToolPath, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\ntype EditPreview = EditDiffResult | EditDiffError;\n\ntype EditRenderState = {\n\tcallComponent?: EditCallRenderComponent;\n};\n\nconst replaceEditSchema = Type.Object(\n\t{\n\t\toldText: Type.String({ minLength: 1 }),\n\t\tnewText: Type.String(),\n\t\trange: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tstartLine: Type.Integer({ minimum: 1 }),\n\t\t\t\t\tendLine: Type.Integer({ minimum: 1 }),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst editPathSchema = Type.String({ minLength: 1 });\nconst editSchema = Type.Union([\n\tType.Object(\n\t\t{\n\t\t\tpath: editPathSchema,\n\t\t\tedits: Type.Array(replaceEditSchema, {\n\t\t\t\tminItems: 1,\n\t\t\t}),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n\tType.Object(\n\t\t{\n\t\t\tpath: editPathSchema,\n\t\t\tpayloadRef: Type.String({ minLength: 1 }),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n]);\n\nexport type EditToolInput = Static<typeof editSchema>;\ntype LegacyEditToolInput = {\n\tpath?: unknown;\n\tedits?: unknown;\n\tpayloadRef?: unknown;\n\toldText?: unknown;\n\tnewText?: unknown;\n};\n\nexport interface EditToolDetails {\n\tphase: \"edited\";\n\tcontentRef?: string;\n\t/** Display-oriented diff of the changes made */\n\tdiff?: string;\n\t/** Standard unified patch of the changes made */\n\tpatch?: string;\n\t/** Line number of the first change in the new file (for editor navigation) */\n\tfirstChangedLine?: number;\n\t/** True when execution reused the match plan already validated for the call preview. */\n\tmatchPlanReused?: boolean;\n}\n\n/**\n * Pluggable operations for the edit tool.\n * Override these to delegate file editing to remote systems (for example SSH).\n */\nexport interface EditOperations {\n\t/** Read file contents as a Buffer */\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\t/** Write content to a file */\n\twriteFile: (absolutePath: string, content: string) => Promise<void>;\n}\n\nconst defaultEditOperations: EditOperations = {\n\treadFile: (path) => fsReadFile(path),\n\twriteFile: (path, content) => fsWriteFile(path, content, \"utf-8\"),\n};\n\nexport interface EditToolOptions {\n\t/** Custom operations for file editing. Default: local filesystem */\n\toperations?: EditOperations;\n\t/** Session-owned harness preflight and exact-content-reference authority. */\n\tintentController?: FileMutationIntentController;\n}\n\nfunction prepareEditArguments(input: unknown): EditToolInput {\n\tif (!input || typeof input !== \"object\" || Array.isArray(input)) {\n\t\treturn input as EditToolInput;\n\t}\n\n\tlet args = input as Record<string, unknown>;\n\n\tconst legacy = args as LegacyEditToolInput;\n\tif (typeof legacy.oldText === \"string\" && typeof legacy.newText === \"string\") {\n\t\tconst edits = Array.isArray(legacy.edits) ? [...legacy.edits] : [];\n\t\tedits.push({ oldText: legacy.oldText, newText: legacy.newText });\n\t\tconst { oldText: _oldText, newText: _newText, ...rest } = legacy;\n\t\targs = { ...rest, edits };\n\t}\n\n\treturn args as EditToolInput;\n}\n\nfunction validateEdits(edits: unknown): Edit[] {\n\tif (!Array.isArray(edits) || edits.length === 0) {\n\t\tthrow new Error(\"Edit tool input is invalid. edits must contain at least one replacement.\");\n\t}\n\tfor (const edit of edits) {\n\t\tif (\n\t\t\ttypeof edit !== \"object\" ||\n\t\t\tedit === null ||\n\t\t\ttypeof edit.oldText !== \"string\" ||\n\t\t\ttypeof edit.newText !== \"string\"\n\t\t) {\n\t\t\tthrow new Error(\"Edit tool input is invalid. Every edit requires string oldText and newText fields.\");\n\t\t}\n\t}\n\treturn edits as Edit[];\n}\n\nfunction validateEditInput(\n\tinput: EditToolInput,\n): { path: string; edits: Edit[]; payloadRef?: undefined } | { path: string; edits?: undefined; payloadRef: string } {\n\tif (\"payloadRef\" in input) return { path: input.path, payloadRef: input.payloadRef };\n\treturn { path: input.path, edits: validateEdits(input.edits) };\n}\n\ntype RenderableEditArgs = {\n\tpath?: string;\n\tfile_path?: string;\n\tedits?: Edit[];\n\tpayloadRef?: string;\n\toldText?: string;\n\tnewText?: string;\n};\n\ntype EditToolResultLike = {\n\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\tdetails?: EditToolDetails;\n};\n\ntype EditCallRenderComponent = Box & {\n\tpreview?: EditPreview;\n\tpreviewRequestId: number;\n\tpreviewPending?: boolean;\n\tsettledError?: boolean;\n};\n\nfunction createEditCallRenderComponent(): EditCallRenderComponent {\n\treturn Object.assign(new Box(1, 1, (text: string) => text), {\n\t\tpreview: undefined as EditPreview | undefined,\n\t\tpreviewRequestId: 0,\n\t\tpreviewPending: false,\n\t\tsettledError: false,\n\t});\n}\n\nfunction getEditCallRenderComponent(state: EditRenderState, lastComponent: unknown): EditCallRenderComponent {\n\tif (lastComponent instanceof Box) {\n\t\tconst component = lastComponent as EditCallRenderComponent;\n\t\tstate.callComponent = component;\n\t\treturn component;\n\t}\n\tif (state.callComponent) {\n\t\treturn state.callComponent;\n\t}\n\tconst component = createEditCallRenderComponent();\n\tstate.callComponent = component;\n\treturn component;\n}\n\nfunction getRenderablePreviewInput(args: RenderableEditArgs | undefined): { path: string; edits: Edit[] } | null {\n\tif (!args) {\n\t\treturn null;\n\t}\n\n\tconst path = typeof args.path === \"string\" ? args.path : typeof args.file_path === \"string\" ? args.file_path : null;\n\tif (!path) {\n\t\treturn null;\n\t}\n\n\tif (\n\t\tArray.isArray(args.edits) &&\n\t\targs.edits.length > 0 &&\n\t\targs.edits.every((edit) => typeof edit?.oldText === \"string\" && typeof edit?.newText === \"string\")\n\t) {\n\t\treturn { path, edits: args.edits };\n\t}\n\n\tif (typeof args.oldText === \"string\" && typeof args.newText === \"string\") {\n\t\treturn { path, edits: [{ oldText: args.oldText, newText: args.newText }] };\n\t}\n\n\treturn null;\n}\n\ninterface CachedEditMatchPlan {\n\tabsolutePath: string;\n\tedits: Edit[];\n\tplan: EditMatchPlan;\n\tsourceDigest: string;\n\tdiff: string;\n\tfirstChangedLine: number | undefined;\n}\n\nfunction snapshotEdits(edits: Edit[]): Edit[] {\n\treturn edits.map((edit) => ({\n\t\toldText: edit.oldText,\n\t\tnewText: edit.newText,\n\t\t...(edit.range ? { range: { startLine: edit.range.startLine, endLine: edit.range.endLine } } : {}),\n\t}));\n}\n\nfunction editsMatch(left: Edit[], right: Edit[]): boolean {\n\tif (left.length !== right.length) return false;\n\tfor (let index = 0; index < left.length; index++) {\n\t\tconst leftEdit = left[index];\n\t\tconst rightEdit = right[index];\n\t\tif (\n\t\t\tleftEdit.oldText !== rightEdit.oldText ||\n\t\t\tleftEdit.newText !== rightEdit.newText ||\n\t\t\tleftEdit.range?.startLine !== rightEdit.range?.startLine ||\n\t\t\tleftEdit.range?.endLine !== rightEdit.range?.endLine\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction formatEditCall(args: RenderableEditArgs | undefined, theme: Theme, cwd: string): string {\n\tconst pathDisplay = renderToolPath(str(args?.file_path ?? args?.path), theme, cwd);\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"edit\"))} ${pathDisplay}`;\n}\n\nfunction formatEditResult(\n\targs: RenderableEditArgs | undefined,\n\tpreview: EditPreview | undefined,\n\tresult: EditToolResultLike,\n\ttheme: Theme,\n\tisError: boolean,\n): string | undefined {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst previewDiff = preview && !(\"error\" in preview) ? preview.diff : undefined;\n\tconst previewError = preview && \"error\" in preview ? preview.error : undefined;\n\tif (isError) {\n\t\tconst errorText = result.content\n\t\t\t.filter((c) => c.type === \"text\")\n\t\t\t.map((c) => c.text || \"\")\n\t\t\t.join(\"\\n\");\n\t\tif (!errorText || errorText === previewError) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn theme.fg(\"error\", errorText);\n\t}\n\n\tconst resultDiff = result.details?.diff;\n\tif (resultDiff && resultDiff !== previewDiff) {\n\t\treturn renderDiff(resultDiff, { filePath: rawPath ?? undefined });\n\t}\n\n\treturn undefined;\n}\n\nasync function editPathFailureWithRetainedPayload(\n\terror: FileMutationPreflightError,\n\tvalidated:\n\t\t| { path: string; edits: Edit[]; payloadRef?: undefined }\n\t\t| { path: string; edits?: undefined; payloadRef: string },\n\tintentController: FileMutationIntentController,\n\tsignal?: AbortSignal,\n): Promise<Error> {\n\tconst failureIdentity = error.reason === \"edit_missing\" ? \"edit_missing (ENOENT)\" : \"edit_not_file\";\n\tif (validated.payloadRef) {\n\t\tawait intentController.assertMutationPayload(validated.payloadRef, \"edit\", signal);\n\t\treturn new Error(\n\t\t\t`PI_FILE_MUTATION_RETARGET ${failureIdentity}: payloadRef ${validated.payloadRef}. Choose only a corrected path naming an existing file; the exact valid edit payload is retained for full revalidation.`,\n\t\t);\n\t}\n\n\ttry {\n\t\tconst retained = await intentController.retainMutationPayload(\"edit\", JSON.stringify(validated.edits));\n\t\tif (retained) {\n\t\t\treturn new Error(\n\t\t\t\t`PI_FILE_MUTATION_RETARGET ${failureIdentity}: payloadRef ${retained.payloadRef}. Choose only a corrected path naming an existing file; the exact valid edit payload is retained for full revalidation.`,\n\t\t\t);\n\t\t}\n\t} catch {\n\t\t// The path failure remains authoritative when the bounded retry cache is unavailable.\n\t}\n\treturn new Error(`${error.message} The edit payload could not be retained within the secure retry-cache bound.`);\n}\n\nfunction getEditHeaderBg(\n\tpreview: EditPreview | undefined,\n\tsettledError: boolean | undefined,\n\ttheme: Theme,\n): (text: string) => string {\n\tif (preview) {\n\t\tif (\"error\" in preview) {\n\t\t\treturn (text: string) => theme.bg(\"toolErrorBg\", text);\n\t\t}\n\t\treturn (text: string) => theme.bg(\"toolSuccessBg\", text);\n\t}\n\tif (settledError) {\n\t\treturn (text: string) => theme.bg(\"toolErrorBg\", text);\n\t}\n\treturn (text: string) => theme.bg(\"toolPendingBg\", text);\n}\n\nfunction buildEditCallComponent(\n\tcomponent: EditCallRenderComponent,\n\targs: RenderableEditArgs | undefined,\n\ttheme: Theme,\n\tcwd: string,\n): EditCallRenderComponent {\n\tcomponent.setBgFn(getEditHeaderBg(component.preview, component.settledError, theme));\n\tcomponent.clear();\n\tcomponent.addChild(new Text(formatEditCall(args, theme, cwd), 0, 0));\n\n\tif (!component.preview) {\n\t\treturn component;\n\t}\n\n\tconst body =\n\t\t\"error\" in component.preview ? theme.fg(\"error\", component.preview.error) : renderDiff(component.preview.diff);\n\tcomponent.addChild(new Spacer(1));\n\tcomponent.addChild(new Text(body, 0, 0));\n\treturn component;\n}\n\nfunction setEditPreview(component: EditCallRenderComponent, preview: EditPreview): boolean {\n\tconst current = component.preview;\n\tconst changed =\n\t\tcurrent === undefined ||\n\t\t(\"error\" in current && \"error\" in preview\n\t\t\t? current.error !== preview.error\n\t\t\t: \"error\" in current !== \"error\" in preview) ||\n\t\t(!(\"error\" in current) &&\n\t\t\t!(\"error\" in preview) &&\n\t\t\t(current.diff !== preview.diff || current.firstChangedLine !== preview.firstChangedLine));\n\tcomponent.preview = preview;\n\tcomponent.previewPending = false;\n\treturn changed;\n}\n\nexport function createEditToolDefinition(\n\tcwd: string,\n\toptions?: EditToolOptions,\n): ToolDefinition<typeof editSchema, EditToolDetails | undefined, EditRenderState> {\n\tconst ops = options?.operations ?? defaultEditOperations;\n\tif (options?.operations && !options.intentController) {\n\t\tthrow new Error(\"Custom edit operations require a matching file mutation intent controller.\");\n\t}\n\tconst intentController = options?.intentController ?? new FileMutationIntentController();\n\tlet cachedMatchPlan: CachedEditMatchPlan | undefined;\n\treturn {\n\t\tname: \"edit\",\n\t\tlabel: \"edit\",\n\t\tdescription:\n\t\t\t\"Edit existing UTF-8 text in one call. Send path and all edits; after a path-only failure, reuse the returned payloadRef with only the corrected path. The harness preflights, revalidates, and stale-checks every exact replacement.\",\n\t\tpromptSnippet: \"Preflight existing files; apply exact, stale-safe edits\",\n\t\tpromptGuidelines: [\n\t\t\t\"Call edit once with path and all replacements; preparation and stale-target checks are harness-owned.\",\n\t\t\t\"If a path failure returns payloadRef, choose the correct existing path and reuse that reference instead of regenerating edits.\",\n\t\t\t\"oldText is exact, unique, minimal, and original-file based; pass the inclusive line range from the supplying read when known, batch separate edits, and merge overlaps.\",\n\t\t],\n\t\tparameters: editSchema,\n\t\trenderShell: \"self\",\n\t\tprepareArguments: prepareEditArguments,\n\t\tasync execute(_toolCallId, input: EditToolInput, signal?: AbortSignal, _onUpdate?, _ctx?) {\n\t\t\tconst validated = validateEditInput(input);\n\t\t\tconst { path } = validated;\n\t\t\tconst absolutePath = resolveToCwd(path, cwd);\n\t\t\tlet lease: FileMutationLease;\n\t\t\ttry {\n\t\t\t\tlease = await intentController.prepare(\"edit\", absolutePath, signal, path);\n\t\t\t} catch (error) {\n\t\t\t\tif (\n\t\t\t\t\terror instanceof FileMutationPreflightError &&\n\t\t\t\t\t(error.reason === \"edit_missing\" || error.reason === \"edit_not_file\")\n\t\t\t\t) {\n\t\t\t\t\tthrow await editPathFailureWithRetainedPayload(error, validated, intentController, signal);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn withFileMutationQueue(absolutePath, async () => {\n\t\t\t\t// Do not reject from an abort event listener here: that would release the\n\t\t\t\t// mutation queue while an in-flight filesystem operation may still finish.\n\t\t\t\t// Checking signal.aborted after each await observes the same aborts while\n\t\t\t\t// keeping the queue locked until the current operation has settled.\n\t\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t};\n\n\t\t\t\tthrowIfAborted();\n\t\t\t\tlet payloadRef: string | undefined;\n\t\t\t\tlet edits: Edit[];\n\t\t\t\tif (validated.edits !== undefined) {\n\t\t\t\t\tedits = validated.edits;\n\t\t\t\t} else {\n\t\t\t\t\tpayloadRef = validated.payloadRef;\n\t\t\t\t\tedits = validateEdits(\n\t\t\t\t\t\tJSON.parse(await intentController.readMutationPayload(payloadRef, \"edit\", signal)),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait intentController.assertCurrent(lease, signal);\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\t// Read the file.\n\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\tif (!isValidUTF8(buffer)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`PI_FILE_ENCODING_CORRUPTION: ${path} is not valid UTF-8 text; exact text replacement is unsafe and could corrupt its bytes.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst rawContent = buffer.toString(\"utf-8\");\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\t// Strip BOM before matching. The model will not include an invisible BOM in oldText.\n\t\t\t\tconst { bom, text: content } = stripBom(rawContent);\n\t\t\t\tconst originalEnding = detectLineEnding(content);\n\t\t\t\tconst normalizedContent = normalizeToLF(content);\n\t\t\t\tconst cachedForInput =\n\t\t\t\t\tcachedMatchPlan?.absolutePath === absolutePath && editsMatch(cachedMatchPlan.edits, edits)\n\t\t\t\t\t\t? cachedMatchPlan\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (cachedForInput) cachedMatchPlan = undefined;\n\t\t\t\tconst matchPlanReused =\n\t\t\t\t\tcachedForInput !== undefined &&\n\t\t\t\t\tcachedForInput.sourceDigest === digestNormalizedEditSource(normalizedContent);\n\t\t\t\tconst { baseContent, newContent } = matchPlanReused\n\t\t\t\t\t? applyEditMatchPlan(normalizedContent, cachedForInput.plan, path)\n\t\t\t\t\t: applyEditsToNormalizedContent(normalizedContent, edits, path);\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tconst finalContent = bom + restoreLineEndings(newContent, originalEnding);\n\t\t\t\tawait intentController.assertCurrent(lease, signal);\n\t\t\t\tthrowIfAborted();\n\t\t\t\tawait ops.writeFile(absolutePath, finalContent);\n\t\t\t\tthrowIfAborted();\n\t\t\t\tconst contentReference = intentController.rememberContent(absolutePath, finalContent);\n\t\t\t\tif (payloadRef) await intentController.discardMutationPayload(payloadRef);\n\n\t\t\t\tconst diffResult = matchPlanReused\n\t\t\t\t\t? { diff: cachedForInput.diff, firstChangedLine: cachedForInput.firstChangedLine }\n\t\t\t\t\t: generateDiffString(baseContent, newContent);\n\t\t\t\tconst patch = generateUnifiedPatch(path, baseContent, newContent);\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\",\n\t\t\t\t\t\t\ttext: `Successfully replaced ${edits.length} block(s) in ${path}; this edit is complete, so do not call edit again for this path. To copy these exact bytes to a different new path, call write once for that path with contentRef ${contentReference.contentRef}.`,\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\tphase: \"edited\" as const,\n\t\t\t\t\t\tcontentRef: contentReference.contentRef,\n\t\t\t\t\t\tdiff: diffResult.diff,\n\t\t\t\t\t\tpatch,\n\t\t\t\t\t\tfirstChangedLine: diffResult.firstChangedLine,\n\t\t\t\t\t\tmatchPlanReused,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst component = getEditCallRenderComponent(context.state, context.lastComponent);\n\t\t\tconst previewInput = getRenderablePreviewInput(args as RenderableEditArgs | undefined);\n\n\t\t\tif ((!context.argsComplete || !previewInput) && (component.preview || component.previewPending)) {\n\t\t\t\tcomponent.preview = undefined;\n\t\t\t\tcomponent.previewPending = false;\n\t\t\t\tcomponent.settledError = false;\n\t\t\t\tcomponent.previewRequestId++;\n\t\t\t}\n\n\t\t\tif (context.argsComplete && previewInput && !component.preview && !component.previewPending) {\n\t\t\t\tcomponent.previewPending = true;\n\t\t\t\tconst requestId = ++component.previewRequestId;\n\t\t\t\tvoid computeEditsPlannedDiff(previewInput.path, previewInput.edits, context.cwd).then((preview) => {\n\t\t\t\t\tif (component.previewRequestId === requestId) {\n\t\t\t\t\t\tif (!(\"error\" in preview) && !options?.operations) {\n\t\t\t\t\t\t\tcachedMatchPlan = {\n\t\t\t\t\t\t\t\tabsolutePath: resolveToCwd(previewInput.path, context.cwd),\n\t\t\t\t\t\t\t\tedits: snapshotEdits(previewInput.edits),\n\t\t\t\t\t\t\t\tplan: preview.plan,\n\t\t\t\t\t\t\t\tsourceDigest: preview.sourceDigest,\n\t\t\t\t\t\t\t\tdiff: preview.diff,\n\t\t\t\t\t\t\t\tfirstChangedLine: preview.firstChangedLine,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetEditPreview(component, preview);\n\t\t\t\t\t\tcontext.invalidate();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn buildEditCallComponent(component, args, theme, context.cwd);\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst callComponent = context.state.callComponent;\n\t\t\tconst typedResult = result as EditToolResultLike;\n\t\t\tconst resultDiff = !context.isError ? typedResult.details?.diff : undefined;\n\t\t\tlet changed = false;\n\t\t\tif (callComponent) {\n\t\t\t\tcallComponent.previewRequestId++;\n\t\t\t\tif (typeof resultDiff === \"string\") {\n\t\t\t\t\tchanged =\n\t\t\t\t\t\tsetEditPreview(callComponent, {\n\t\t\t\t\t\t\tdiff: resultDiff,\n\t\t\t\t\t\t\tfirstChangedLine: typedResult.details?.firstChangedLine,\n\t\t\t\t\t\t}) || changed;\n\t\t\t\t}\n\t\t\t\tif (callComponent.settledError !== context.isError) {\n\t\t\t\t\tcallComponent.settledError = context.isError;\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t\tif (changed) {\n\t\t\t\t\tbuildEditCallComponent(\n\t\t\t\t\t\tcallComponent,\n\t\t\t\t\t\tcontext.args as RenderableEditArgs | undefined,\n\t\t\t\t\t\ttheme,\n\t\t\t\t\t\tcontext.cwd,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst output = formatEditResult(context.args, callComponent?.preview, typedResult, theme, context.isError);\n\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\tcomponent.clear();\n\t\t\tif (!output) {\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\tcomponent.addChild(new Spacer(1));\n\t\t\tcomponent.addChild(new Text(output, 1, 0));\n\t\t\treturn component;\n\t\t},\n\t};\n}\n\nexport function createEditTool(cwd: string, options?: EditToolOptions): AgentTool<typeof editSchema> {\n\treturn wrapToolDefinition(createEditToolDefinition(cwd, options));\n}\n"]}
@@ -16,55 +16,82 @@ export interface FileMutationIntentOperations {
16
16
  access(path: string, mode: number): Promise<void>;
17
17
  copyFileExclusive(sourcePath: string, targetPath: string): Promise<void>;
18
18
  hashFile(path: string, signal?: AbortSignal): Promise<string>;
19
+ readPayload(path: string): Promise<string>;
19
20
  removeFile(path: string): Promise<void>;
21
+ stagePayload(content: string, ttlMs: number): Promise<string>;
20
22
  }
21
- export interface PreparedFileMutation {
22
- intentId: string;
23
+ export interface FileMutationLease {
23
24
  kind: FileMutationKind;
24
25
  path: string;
25
26
  displayPath: string;
26
- }
27
- export interface FileMutationLease extends PreparedFileMutation {
28
27
  identity?: FilePathIdentity;
29
28
  }
30
29
  export interface FileContentReference {
31
30
  contentRef: string;
32
31
  byteLength: number;
33
32
  }
33
+ export interface FileMutationPayloadReference {
34
+ payloadRef: string;
35
+ byteLength: number;
36
+ }
37
+ export type FileMutationPreflightFailureReason = "write_collision" | "edit_missing" | "edit_not_file";
38
+ export declare class FileMutationPreflightError extends Error {
39
+ readonly reason: FileMutationPreflightFailureReason;
40
+ constructor(reason: FileMutationPreflightFailureReason, message: string);
41
+ }
34
42
  export interface FileMutationIntentControllerOptions {
35
43
  operations?: FileMutationIntentOperations;
36
- intentLimit?: number;
37
44
  contentReferenceLimit?: number;
38
- intentTtlMs?: number;
39
45
  contentReferenceTtlMs?: number;
46
+ mutationPayloadLimit?: number;
47
+ mutationPayloadByteLimit?: number;
48
+ mutationPayloadTtlMs?: number;
40
49
  now?: () => number;
41
50
  }
42
51
  export declare const localFileMutationIntentOperations: FileMutationIntentOperations;
43
52
  /**
44
- * Session-owned authority for two-phase file mutation intents and bounded exact-content references.
45
- * It retains only fixed-size metadata; file bytes remain owned by the filesystem.
53
+ * Session-owned harness authority for file-mutation preflight, stale-target checks,
54
+ * and bounded exact-content references. It retains only fixed-size metadata; file
55
+ * bytes remain owned by the filesystem.
46
56
  */
47
57
  export declare class FileMutationIntentController {
48
58
  private readonly operations;
49
- private readonly intentLimit;
50
59
  private readonly contentReferenceLimit;
51
- private readonly intentTtlMs;
52
60
  private readonly contentReferenceTtlMs;
61
+ private readonly mutationPayloadLimit;
62
+ private readonly mutationPayloadByteLimit;
63
+ private readonly mutationPayloadTtlMs;
53
64
  private readonly now;
54
- private readonly intents;
55
- private readonly intentByPath;
56
65
  private readonly contentReferences;
66
+ private readonly mutationPayloads;
67
+ private mutationPayloadBytes;
68
+ private lastMutationPayloadExpiresAt;
69
+ private mutationPayloadOperationTail;
57
70
  constructor(options?: FileMutationIntentControllerOptions);
58
- prepare(kind: FileMutationKind, path: string, signal?: AbortSignal, displayPath?: string): Promise<PreparedFileMutation>;
59
- consume(intentId: string, kind: FileMutationKind, path: string): FileMutationLease;
71
+ prepare(kind: FileMutationKind, path: string, signal?: AbortSignal, displayPath?: string): Promise<FileMutationLease>;
60
72
  assertCurrent(lease: FileMutationLease, signal?: AbortSignal): Promise<void>;
61
73
  rememberContent(sourcePath: string, content: string): FileContentReference;
74
+ retainMutationPayload(kind: FileMutationKind, payload: string): Promise<FileMutationPayloadReference | undefined>;
75
+ readMutationPayload(payloadRef: string, kind: FileMutationKind, signal?: AbortSignal): Promise<string>;
76
+ assertMutationPayload(payloadRef: string, kind: FileMutationKind, signal?: AbortSignal): Promise<void>;
77
+ assertContentReference(contentRef: string, signal?: AbortSignal): Promise<void>;
78
+ copyMutationPayload(payloadRef: string, targetPath: string, signal?: AbortSignal): Promise<FileContentReference>;
79
+ discardMutationPayload(payloadRef: string): Promise<void>;
80
+ /** Release every payload owned by this controller without touching another controller's files. */
81
+ dispose(): Promise<void>;
62
82
  copyReferencedContent(contentRef: string, targetPath: string, signal?: AbortSignal): Promise<FileContentReference>;
83
+ private requireVerifiedContentReference;
84
+ private requireMutationPayload;
85
+ private requireVerifiedMutationPayload;
86
+ private verifySource;
87
+ private copyVerifiedSource;
63
88
  private assertCreatableParent;
64
89
  private rememberContentDigest;
65
90
  private touchContentReference;
66
91
  private removeFailedCopy;
67
- private deleteIntent;
92
+ private deleteMutationPayload;
93
+ private runMutationPayloadOperation;
94
+ private pruneExpiredMutationPayloads;
68
95
  private pruneExpired;
69
96
  }
70
97
  //# sourceMappingURL=file-mutation-intent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-mutation-intent.d.ts","sourceRoot":"","sources":["../../../src/core/tools/file-mutation-intent.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC;IACrC,QAAQ,EAAE,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,4BAA4B;IAC5C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;IACxF,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,C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