@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
package/docs/providers.md CHANGED
@@ -201,6 +201,9 @@ export AZURE_OPENAI_DEPLOYMENT_NAME_MAP=gpt-4=my-gpt4,gpt-4o=my-gpt4o
201
201
 
202
202
  ### Amazon Bedrock
203
203
 
204
+ Amazon Bedrock requires an explicit verified region scope. A region from `~/.aws/config` is not
205
+ enough: Pi persists and sends `AWS_REGION` explicitly so discovery and runtime requests cannot drift.
206
+
204
207
  ```bash
205
208
  # Option 1: AWS Profile (recommended for IAM Identity Center / SSO)
206
209
  export AWS_PROFILE=your-profile
@@ -212,31 +215,48 @@ export AWS_SECRET_ACCESS_KEY=...
212
215
  # Option 3: Bearer Token
213
216
  export AWS_BEARER_TOKEN_BEDROCK=...
214
217
 
215
- # Optional region (defaults to us-east-1)
216
- export AWS_REGION=us-west-2
218
+ # Required AWS scope. US inference profiles in Ohio use us-east-2.
219
+ export AWS_REGION=us-east-2
217
220
  ```
218
221
 
219
222
  For an SSO profile, AWS CLI v2 is required and the modern `sso-session` profile format is recommended.
220
- Start Pi with `AWS_PROFILE` set, or run `/login amazon-bedrock` and enter the profile name for the
221
- current Pi process. Pi runs `aws sso login --profile <profile>` without a shell. The AWS SDK refreshes
222
- ordinary role credentials; if the underlying SSO session later expires, Pi performs one foreground
223
- login and replays the Bedrock request once, only before a response has started. Background and worker
224
- requests never open a browser and instead return an authentication-required error to the owning
225
- session.
223
+ Run `/login amazon-bedrock`, select SSO, and enter the exact profile and region. For IAM keys, bearer
224
+ tokens, ECS roles, or IRSA, select the ambient-credentials option and enter the exact region. Pi then:
225
+
226
+ 1. verifies the selected profile and region with STS;
227
+ 2. paginates region-scoped system inference profiles;
228
+ 3. selects the current US/EU/APAC/global Claude candidate for each available tier;
229
+ 4. runs a bounded one-token runtime probe for every candidate; and
230
+ 5. persists the exact profile, region, verified model IDs, verification mode, and timestamp in the
231
+ user settings file.
232
+
233
+ Bearer tokens skip STS and control-plane discovery because that auth mode cannot reliably use them;
234
+ Pi instead probes the bounded region-derived candidates directly. A credential alone exposes no
235
+ Bedrock models. If `AWS_PROFILE` or `AWS_REGION` later differs from the saved scope, the saved model
236
+ evidence is rejected until `/login amazon-bedrock` verifies the new scope. Direct Anthropic models are
237
+ unaffected.
238
+
239
+ Pi runs `aws sso login --profile <profile>` without a shell. The AWS SDK refreshes ordinary role
240
+ credentials; if the underlying SSO session later expires, Pi performs one foreground login and
241
+ replays the Bedrock request once, only before a response has started. Background and worker requests
242
+ never open a browser and instead return an authentication-required error to the owning session.
226
243
 
227
244
  Also supports ECS task roles (`AWS_CONTAINER_CREDENTIALS_*`) and IRSA (`AWS_WEB_IDENTITY_TOKEN_FILE`).
228
245
 
229
246
  ```bash
230
- pi --provider amazon-bedrock --model us.anthropic.claude-sonnet-4-20250514-v1:0
247
+ pi --provider amazon-bedrock --model us.anthropic.claude-sonnet-5
231
248
  ```
232
249
 
233
250
  Prompt caching is enabled automatically for Claude models whose ID contains a recognizable model name (base models and system-defined inference profiles). For application inference profiles (whose ARNs don't contain the model name), set `AWS_BEDROCK_FORCE_CACHE=1` to enable cache points:
234
251
 
235
252
  ```bash
236
253
  export AWS_BEDROCK_FORCE_CACHE=1
237
- pi --provider amazon-bedrock --model arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abc123
254
+ pi --provider amazon-bedrock --model arn:aws:bedrock:us-east-2:123456789012:application-inference-profile/abc123
238
255
  ```
239
256
 
257
+ An explicitly configured application-inference-profile ARN remains selectable only when its ARN
258
+ region matches the verified scope. It does not expand the discovered system-model allowlist.
259
+
240
260
  If you are connecting to a Bedrock API proxy, the following environment variables can be used:
241
261
 
242
262
  ```bash
@@ -250,6 +270,10 @@ export AWS_BEDROCK_SKIP_AUTH=1
250
270
  export AWS_BEDROCK_FORCE_HTTP1=1
251
271
  ```
252
272
 
273
+ An explicit unauthenticated proxy (`AWS_BEDROCK_SKIP_AUTH=1` plus
274
+ `AWS_ENDPOINT_URL_BEDROCK_RUNTIME`) is outside AWS account/region verification and retains its custom
275
+ model surface.
276
+
253
277
  ### Cloudflare AI Gateway
254
278
 
255
279
  `CLOUDFLARE_API_KEY` can be set via `/login`. The account ID and gateway slug must be set as environment variables.
package/docs/settings.md CHANGED
@@ -278,7 +278,7 @@ Worker writes use **review-after-apply** semantics: a grant-authorized direct `w
278
278
 
279
279
  Deterministic argument repair is built in and has no settings toggle; schema-valid calls still return unchanged without entering the repair layer. `PI_TOOL_REPAIR_DISABLED=1` remains only an emergency diagnostic kill switch.
280
280
 
281
- Text protocol precedence is: `PI_TEXT_TOOL_CALL_PROTOCOL_DISABLED=1` kills it, then `toolRepair.textProtocol` force-enables or disables it globally, then per-model `textToolCallProtocol` applies, then a persisted `/toolprobe` text-protocol verdict applies to that exact model. Native provider tool calls still take precedence when the model emits them; the text protocol is the fallback lane for pure-text models. Failed calibration is stored per host/model and can be cleared with `/toolprotocol-reset <provider/model>`.
281
+ Text protocol precedence is: `PI_TEXT_TOOL_CALL_PROTOCOL_DISABLED=1` kills it; a persisted `/toolprobe` native verdict then keeps that exact model on native calls; otherwise `toolRepair.textProtocol` force-enables or disables globally, per-model `textToolCallProtocol` applies, and finally a persisted calibrated text-protocol verdict applies. The phone/text protocol is therefore a fallback lane for models without proven native calls, never a replacement for a proven native path. Failed calibration is stored per host/model and can be cleared with `/toolprotocol-reset <provider/model>`.
282
282
 
283
283
  Environment kill switches override their diagnostic layers: `PI_TOOL_REPAIR_DISABLED=1`, `PI_TOOL_REPAIR_TEACH_DISABLED=1`, and `PI_TEXT_TOOL_CALL_PROTOCOL_DISABLED=1`. See [Tool repair](tool-repair.md) for diagnostics, reset controls, and replay.
284
284
 
@@ -7,8 +7,9 @@ not exercised.
7
7
 
8
8
  ## Required invariants
9
9
 
10
- 1. Validate cheap authority, path, identity, availability, and collision facts before asking the model for a
11
- large payload.
10
+ 1. Validate cheap authority, path, identity, availability, and collision facts at the earliest harness-owned
11
+ execution boundary, before payload processing or mutation. Never make the model coordinate preparation, and
12
+ recheck mutable facts inside the serialized mutation boundary immediately before the write.
12
13
  2. Keep coordinators, payload handles, mutable queues, and retry state session-owned unless cross-session
13
14
  coordination is the explicit invariant.
14
15
  3. Store large bytes once, outside the JavaScript heap where practical. Context and telemetry retain bounded
@@ -23,10 +24,10 @@ not exercised.
23
24
 
24
25
  | Boundary | Root cause | Fix | Evidence gate |
25
26
  | --- | --- | --- | --- |
26
- | Write collision | `write` accepted the full content before discovering an occupied destination and could overwrite it. | Two-phase `prepare`/`commit`, path-only collision and parent checks, single-use session intent, and final `wx` no-clobber create. | `test/file-mutation-preflight.test.ts`; `test/file-encoding-policy.test.ts` |
27
- | Missing/stale edit | `edit` accepted replacement payloads before existence checks and could apply a plan prepared against older bytes. | Path-only preparation records file identity; commit consumes the intent and rejects a missing or changed target. | `test/file-mutation-preflight.test.ts`; `test/file-mutation-queue.test.ts` |
27
+ | Write collision | `write` accepted the full content before discovering an occupied destination and could overwrite it. | One semantic model call; the harness preflights collision and parent access, rechecks inside the path queue, and finishes with atomic no-clobber creation. When the generated payload is valid and only the name collides, its exact bytes move to a bounded session cache so repair supplies only a corrected path and opaque reference. | `test/file-mutation-preflight.test.ts`; `test/file-encoding-policy.test.ts`; `test/phone-filesystem-workflow.test.ts` |
28
+ | Missing/stale edit | `edit` accepted replacement payloads before existence checks and could apply a plan prepared against older bytes. | One semantic model call; the harness snapshots path identity, rechecks after queue admission and immediately before writing, and rejects missing or changed targets. Valid edits paired with only a missing/non-file path receive the same bounded retarget treatment and are fully revalidated against each corrected candidate. | `test/file-mutation-preflight.test.ts`; `test/file-mutation-queue.test.ts`; `test/phone-filesystem-workflow.test.ts` |
28
29
  | Repeated exact content | Copying identical generated content to another destination required retransmitting it. | Successful writes/edits return a session-local `contentRef`; the bounded controller hashes the source and performs exclusive verified copies without retaining bytes on the JS heap. | `test/file-mutation-preflight.test.ts` |
29
- | Encoding corruption | An unsafe text edit could be remembered as a retryable operation and teach repair/re-read loops. | The central execution-error catalogue classifies `PI_FILE_ENCODING_CORRUPTION` as change-approach, consumes the edit intent, retains no operation arguments, exposes one bounded directive, and expires it after the next assistant response. | `packages/ai/test/tool-execution-error-catalogue.test.ts`; `packages/agent/test/tool-failure-memory.test.ts` |
30
+ | Encoding corruption | An unsafe text edit could be remembered as a retryable operation and teach repair/re-read loops. | The central execution-error catalogue classifies `PI_FILE_ENCODING_CORRUPTION` as change-approach, retains no operation arguments, exposes one bounded directive, and expires it after the next assistant response. | `packages/ai/test/tool-execution-error-catalogue.test.ts`; `packages/agent/test/tool-failure-memory.test.ts` |
30
31
  | Edit preview flattening | Preview rendering used `JSON.stringify({ path, edits })` during render and result settlement, copying the complete edit payload. | Constant-size request generations fence asynchronous previews; partial renders do not scan accumulated edits. | `test/edit-tool-no-full-redraw.test.ts` |
31
32
  | Write preview flattening | Collapsed streamed previews compared the complete prior content prefix, split and highlighted complete snapshots, and retained duplicate full line arrays. | Collapsed rendering inspects at most 8,192 characters, caches by argument-generation identity, and performs one allocation-free final line count; complete text is materialized only on explicit expansion. | `test/tool-execution-component.test.ts` |
32
33
  | Loop/failure payload retention | Stall and failure signatures serialized complete tool arguments and stored the normalized string in the loop window. | A streaming structural fingerprint returns 32 hex characters; failure display keeps a bounded structural preview and never serializes the original payload. | `packages/agent/test/tool-failure-memory.test.ts` |
@@ -74,11 +75,12 @@ the interpreter. An invalid working directory can therefore waste the entire gen
74
75
 
75
76
  Required design:
76
77
 
77
- - Add a path-only/runtime-only prepare action for inline-code mode and a path/runtime prepare action for script
78
- mode.
79
- - Commit consumes a single-use session intent. Runtime failure or coordinator reset invalidates the intent; the
80
- code is not stored as retry memory.
81
- - Do not add a legacy one-phase fallback.
78
+ - Keep one semantic model call. The harness owns cwd/runtime preflight at the start of execution and performs no
79
+ code evaluation or process creation until it passes.
80
+ - Runtime failure or coordinator reset invalidates any internal lease; code is not stored as retry memory and
81
+ no preparation token is exposed to the model.
82
+ - If a provider exposes a complete path before the remaining arguments, speculative streaming preflight may
83
+ warm the same authority check, but final execution remains authoritative and provider-neutral.
82
84
 
83
85
  Acceptance evidence: invalid cwd/runtime tests prove that no `code` field was accepted; stale and cross-session
84
86
  intents fail; successful warm preparation meets the same p95 budget as P0.1.
@@ -102,8 +104,8 @@ path traversal, and cleanup-failure probes; parent session remains responsive an
102
104
 
103
105
  ### P0.4 Close edit's external-writer race
104
106
 
105
- Evidence: edit commit verifies identity before `readFile()` and later overwrites by path. A non-Pi writer can
106
- replace the file after the identity check but before the final write.
107
+ Evidence: edit now verifies identity before `readFile()` and again immediately before `writeFile()`. A non-Pi
108
+ writer can still replace the file in the final check/write gap because the adapter overwrites by path.
107
109
 
108
110
  Required design: bind read/compare/commit to a file handle or an adapter-owned compare-and-replace primitive;
109
111
  fail closed when identity changes. Define Windows replace/share semantics explicitly and preserve BOM/newlines.
@@ -139,9 +141,9 @@ same-timestamp replacement, Windows sharing violations, abort, and cleanup failu
139
141
  - **Ropes/piece tables for provider payloads:** rejected at the network boundary. Providers still require a
140
142
  contiguous JSON/body representation; chunked message ownership, pruning before formatting, and one terminal
141
143
  serialization are the useful controls.
142
- - **Two-phase preflight for `read`, `grep`, `find`, `ls`, and artifact retrieval:** rejected unless new evidence
143
- shows large arguments. Their requests are small, outputs are bounded or artifact-backed, and an extra model
144
- round trip would cost more than the local validation.
144
+ - **Model-visible two-call preflight for `read`, `grep`, `find`, `ls`, and artifact retrieval:** rejected unless
145
+ new evidence shows large arguments. Their requests are small, outputs are bounded or artifact-backed, and an
146
+ extra model round trip would cost more than harness-owned validation.
145
147
  - **Replacing native JSON globally:** rejected without per-boundary benchmarks. Several provider transports
146
148
  require JSON text; changing parsers cannot remove serialization and may add copies. Optimize duplicate
147
149
  serialization and retained ownership first.
@@ -150,11 +152,12 @@ same-timestamp replacement, Windows sharing violations, abort, and cleanup failu
150
152
 
151
153
  ## Incomplete probes
152
154
 
153
- - Windows timing distributions for local and SSH-backed prepare/commit.
155
+ - Windows timing distributions for local and SSH-backed automatic preflight/final mutation.
156
+ - Live SSH round-trip coverage for remote retained-payload staging, expiry, retarget, and cleanup; the adapter is compile-checked but this cycle used no SSH fixture.
154
157
  - Heap/GC profiles for multi-megabyte skill drafts and extension smoke tests.
155
158
  - External-writer race reproduction on NTFS with antivirus/indexer sharing behavior.
156
- - Provider-specific cost of the extra prepare turn versus rejected-payload tokens across native and text tool
157
- protocols.
159
+ - Provider-specific rejected-payload cost when a one-call mutation fails preflight after response completion,
160
+ plus the portability and cancellation semantics of speculative streaming preflight.
158
161
  - Persistent Python protocol throughput and reset cost; no implementation exists yet, so prior process-spawn
159
162
  timings are not acceptance evidence.
160
163
 
@@ -11,7 +11,7 @@ Execution failures are not argument repairs. Pi removes their potentially large
11
11
  - Repair is built-in and has no settings toggle. `PI_TOOL_REPAIR_DISABLED=1` is only an emergency diagnostic kill switch; normal configuration should leave repair on.
12
12
  - Teaching can be disabled independently with `toolRepair.teach: false` or `PI_TOOL_REPAIR_TEACH_DISABLED=1`. Repairs can still execute; the in-band "Tool argument repair note" is suppressed.
13
13
  - Tool-recovery logging can be disabled with `toolRepair.logging: false`. Repairs still run, but Pi does not enqueue recovery records or spawn the background recovery-log worker.
14
- - Text tool-call protocol calibration can be enabled per model with `textToolCallProtocol: true` in `models.json`. `/toolprobe [provider/model]` can also persist a host-local text-protocol verdict for one model after a live probe. Use `toolRepair.textProtocol` only as a global emergency force/kill switch; `PI_TEXT_TOOL_CALL_PROTOCOL_DISABLED=1` always disables it.
14
+ - Text tool-call protocol calibration can be enabled per model with `textToolCallProtocol: true` in `models.json`. `/toolprobe [provider/model]` probes native calls first and can persist a host-local text-protocol verdict only when native calls are absent. A persisted native verdict always keeps that model off the text protocol, including when global or model settings enable it. Use `toolRepair.textProtocol` only as a global emergency force/kill switch for models without native proof; `PI_TEXT_TOOL_CALL_PROTOCOL_DISABLED=1` always disables it.
15
15
 
16
16
  Example project settings:
17
17
 
@@ -29,7 +29,7 @@ Example project settings:
29
29
 
30
30
  - Interactive tool panels show `[repaired arguments]` when execution used repaired arguments.
31
31
  - RPC `tool_execution_start`, `tool_execution_update`, and `tool_execution_end` events include a `repair` object when arguments were repaired.
32
- - `/toolhealth` prints model adaptation records for this host: tool-probe verdicts, calibrated or failed text protocol, learned standing rules, teach statistics, and recovery-log worker counters.
32
+ - `/toolhealth` prints model adaptation records for this host: tool-probe verdicts, calibrated or failed text protocol, learned standing rules, teach statistics, recovery-log worker counters, and execution-failure counts by phase.
33
33
  - `/toolrule-remove <provider/model> <mode>` removes one learned standing rule from the host-local adaptation store.
34
34
  - `/toolprotocol-reset <provider/model>` removes a stored text protocol calibration or failed-calibration record so the next turn can calibrate again.
35
35
  - `/toolprobe [provider/model]` probes the current fleet or one explicit model for native tool calls first, then text-protocol fallback, persists the verdict in the host-local adaptation store, and prints a report table.
@@ -45,7 +45,7 @@ node scripts/tool-repair-replay.mjs ~/.pi/agent/state/failure-corpus.jsonl --jso
45
45
  node scripts/tool-repair-replay.mjs ~/.pi/agent/sessions/<session>.jsonl --fixtures /tmp/tool-repair-fixtures.json
46
46
  ```
47
47
 
48
- The replay helper reads `tool_validation` corpus records and legacy bounced `tool_argument_validation` session entries. Current recovery telemetry is written by a dedicated `node:worker_threads` worker to `state/tool-recovery-events.jsonl`; bounced records also append sanitized `tool_validation` corpus rows. Records contain shape metadata, failure modes, and error keywords; they do not store full tool arguments.
48
+ The replay helper reads `tool_validation` corpus records and legacy bounced `tool_argument_validation` session entries. Current recovery telemetry is written by a dedicated `node:worker_threads` worker to `state/tool-recovery-events.jsonl`; bounced calls append sanitized `tool_validation` corpus rows, while rejected or failed executions append bounded `tool_execution` rows with phase, failure code, optional redacted diagnostic, and next action. Records do not store full tool arguments.
49
49
 
50
50
  ## Repair modes
51
51
 
package/docs/windows.md CHANGED
@@ -13,7 +13,7 @@ Pi supports native Windows on x64 and ARM64. The Node.js package runs under Wind
13
13
  The model always sees one stable `bash` tool contract. On Windows, a deterministic router classifies every command into one of three tiers instead of parsing the full Bash grammar in one place:
14
14
 
15
15
  1. **PowerShell floor** (always available): one simple command — a bounded set of builtin translations or a quoted external argv — converted deterministically to PowerShell, exactly as before this tier existed.
16
- 2. **Bundled Python engine** (uv-provisioned Python 3.13, on by default): pipelines, redirection, chaining, quoting, expansion, globs, and the coreutils vocabulary below, plus every state-mutating command (`cd`, `export`, `unset`), which the engine always owns so there is a single mutator.
16
+ 2. **Bundled Python engine** (uv-provisioned Python 3.13, on by default): pipelines, redirection, chaining, word-list and arithmetic `for` loops, loop control, quoting, expansion, globs, and the coreutils vocabulary below, plus every state-mutating command (`cd`, `export`, `unset`), which the engine always owns so there is a single mutator.
17
17
 
18
18
  External programs are not reimplemented. A simple `rg` call runs the installed native `rg.exe` through the persistent PowerShell floor; when a pipeline or chain requires the Python coordinator, it spawns that same `rg.exe` directly without resolving or starting PowerShell. A `.ps1` target in an engine-owned command is adapted through the same selected PowerShell executable as the floor, without starting a nested model-authored shell.
19
19
  3. **Named fail-closed refusal**: constructs outside the supported grammar (see below) return an actionable error naming the construct instead of guessing or downgrading silently.
@@ -36,7 +36,9 @@ The PowerShell tier runs with `-NoLogo -NoProfile -NonInteractive -Command` and
36
36
  | Sequencing | `a ; b`, newline-separated, `a && b`, `a \|\| b`, `! pipeline` | Left-to-right / short-circuit / negation, bash-standard. |
37
37
  | Subshell | `( … )` | Isolated cwd/env copy — inner `cd`/`export` do not leak out. |
38
38
  | Brace group | `{ …; }` | Shares state — inner `cd`/`export` persist. |
39
- | Redirection | `>`, `>>`, `1>`, `1>>`, `<`, `2>`, `2>>`, `2>&1`, `&>`, `>&` | `/dev/null` maps to `os.devnull`. A builtin's stderr is merged into its own stdout (one sink) an explicit `2>file` on a builtin does not capture its error text; external commands capture normally. |
39
+ | For loop | `for name in words; do …; done`, `for name; do …; done`, `for ((init; condition; update)); do …; done` | Word lists expand once before iteration; the final value remains in the session environment. The omitted-list form iterates shell positional arguments, which Pi does not supply. Arithmetic clauses support integer variables, updates, assignments, comparisons, logical/bitwise operators, and signed 64-bit wrapping. |
40
+ | Loop control | `break [N]`, `continue [N]` | Works across nested word-list and arithmetic loops. An omitted count means one; invalid counts report status 1 without crashing the coordinator. |
41
+ | Redirection | `>`, `>>`, `1>`, `1>>`, `<`, `2>`, `2>>`, `2>&1`, `&>`, `>&` | `/dev/null` maps to `os.devnull`. Unredirected stderr shares Pi's session output; explicit stderr redirection is honored for builtins, state commands, and external programs. |
40
42
  | Quoting | `'…'`, `"…"`, `\x`, `$'…'` | Standard single/double/backslash/ANSI-C semantics. |
41
43
  | Tilde | `~`, `~/x` | Word-start, unquoted, expands to `$HOME`. `~user` is unsupported (refusal). |
42
44
  | Parameter expansion | `$VAR`, `$?`, `${VAR}`, `${V:-w}`, `${V:=w}`, `${V:+w}`, `${V:?w}`, `${#VAR}` | `$?` is the latest foreground pipeline status. POSIX `:`-prefixed (empty-or-unset) semantics only; other `${…}` operators refuse. |
@@ -53,13 +55,13 @@ Builtins: `cd`, `pwd`, `echo [-n -e -E]`, `printf`, `export`, `unset`, `exit [N]
53
55
  - `wc`/`uniq -c` column widths reproduce GNU's dynamic field width only for the single-count stdin case; multi-count/file-arg forms use fixed deterministic padding.
54
56
  - No shell-variable vs. exported-environment distinction: every `NAME=value` sets engine env.
55
57
  - Sorting is always ordinal (`LC_ALL=C`): globs, `ls`, `find`, and default `sort`.
56
- - A builtin's stderr is merged into its own stdout; only external commands honor an explicit `2>`.
58
+ - Arithmetic loop variables use deterministic signed 64-bit wrapping; invalid shifts, division by zero, negative exponents, and malformed expressions return status 1 with a bounded diagnostic.
57
59
  - Globs expand only the final path segment (`dir/*.py` works; `*/x.py` matches the directory part literally).
58
60
  - `wc -m` counts UTF-8 characters (bash under `LC_ALL=C` counts bytes).
59
61
 
60
62
  ### Named unsupported constructs
61
63
 
62
- Each of these fails closed with a named, actionable error instead of an approximation: `job-control` (trailing `&`, `fg`/`bg`/`jobs`/`wait`/`disown`), `process-substitution` (`<(…)`/`>(…)`), `arithmetic-expansion` (`$((…))`, `((…))`, `let`), `brace-expansion` (`{a,b,c}`), `nested-shell` (`bash`/`sh`/`cmd`/`powershell`/`pwsh`/`wsl`/… as a command word), `exec-builtin`, `heredoc`/`here-string` (`<<`, `<<-`, `<<<`), `function-definition`, `control-flow` (`if`/`for`/`while`/`until`/`case`/`select`), `extended-glob` (`@(…)`, `!(…)`, etc.), `unsupported-builtin` (`eval`, `source`/`.`, `alias`, `trap`, `set`, `shopt`, `read`, `declare`, `local`), `unsupported-flag`, `posix-script` (`*.sh`, `/bin/…`), `cwd-missing`, `tilde-user`, `malformed-syntax` (unbalanced quote/paren/brace, empty pipeline element, missing redirect target), `parameter-expansion` (a `${…}` form outside the supported op set).
64
+ Each of these fails closed with a named, actionable error instead of an approximation: `job-control` (trailing `&`, `fg`/`bg`/`jobs`/`wait`/`disown`), `process-substitution` (`<(…)`/`>(…)`), `arithmetic-expansion` (`$((…))`, standalone `((…))`, and `let`; arithmetic `for` headers are supported), `brace-expansion` (`{a,b,c}`), `nested-shell` (`bash`/`sh`/`cmd`/`powershell`/`pwsh`/`wsl`/… as a command word), `exec-builtin`, `heredoc`/`here-string` (`<<`, `<<-`, `<<<`), `function-definition`, `control-flow` (`if`/`while`/`until`/`case`/`select`), `extended-glob` (`@(…)`, `!(…)`, etc.), `unsupported-builtin` (`eval`, `source`/`.`, `alias`, `trap`, `set`, `shopt`, `read`, `declare`, `local`), `unsupported-flag`, `posix-script` (`*.sh`, `/bin/…`), `cwd-missing`, `tilde-user`, `malformed-syntax` (unbalanced quote/paren/brace, empty pipeline element, missing redirect target, malformed `for` loop), `parameter-expansion` (a `${…}` form outside the supported op set).
63
65
 
64
66
  ### State and session semantics
65
67
 
@@ -73,7 +75,7 @@ The Python interpreter and engine imports stay warm in one coordinator process p
73
75
 
74
76
  `windowsShell.pythonEngine` (default `true`) is the kill switch. Set it to `false` to restore the PowerShell-only contract verbatim: only the simple-command floor is used, and every pipeline/redirection/expansion/chaining form that would have routed to the engine instead returns the same fail-closed error it did before the engine existed.
75
77
 
76
- When the setting is left on but the bundled Python runtime cannot be resolved (uv missing, network failure provisioning Python 3.13, or similar), the engine tier is simply unavailable: simple commands still run on the PowerShell floor exactly as always, and any command that needs the engine returns a named error stating the Python runtime is unavailable, that the simple-command floor still works, and to fix `uv`/network to restore pipelines, redirection, expansion, and chaining. There is no silent approximation — a complex command is never downgraded to a plausible-but-wrong simple execution.
78
+ When the setting is left on but the bundled Python runtime cannot be resolved (uv missing, network failure provisioning Python 3.13, or similar), the engine tier is simply unavailable: simple commands still run on the PowerShell floor exactly as always, and any command that needs the engine returns a named error stating the Python runtime is unavailable, that the simple-command floor still works, and to fix `uv`/network to restore loops, pipelines, redirection, expansion, and chaining. There is no silent approximation — a complex command is never downgraded to a plausible-but-wrong simple execution.
77
79
 
78
80
  The native `python` tool uses the same contract on Windows and Unix-like systems. Pi provisions a pinned uv executable, resolves or installs Python 3.13 through uv, then spawns the interpreter directly with UTF-8 and bytecode-cache suppression. Python calls default to 30 seconds. See [Native Python](python.md).
79
81
 
@@ -237,7 +237,7 @@ export default function (pi: ExtensionAPI) {
237
237
  renderCall(args, theme, _context) {
238
238
  let text = theme.fg("toolTitle", theme.bold("write "));
239
239
  text += theme.fg("accent", args.path);
240
- const writeContent = args.action === "commit" && "content" in args ? args.content : undefined;
240
+ const writeContent = "content" in args ? args.content : undefined;
241
241
  if (writeContent) text += theme.fg("dim", ` (${writeContent.length} characters)`);
242
242
  return new Text(text, 0, 0);
243
243
  },
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "0.85.0",
3
+ "version": "0.85.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "0.85.0",
9
+ "version": "0.85.4",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.52.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-anthropic",
3
3
  "private": true,
4
- "version": "0.85.0",
4
+ "version": "0.85.4",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "0.85.0",
4
+ "version": "0.85.4",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -180,7 +180,7 @@ export default function (pi: ExtensionAPI) {
180
180
  renderCall(args, theme, _context) {
181
181
  const path = shortenPath(args.path || "");
182
182
  const pathDisplay = path ? theme.fg("accent", path) : theme.fg("toolOutput", "...");
183
- const writeContent = args.action === "commit" && "content" in args ? args.content : undefined;
183
+ const writeContent = "content" in args ? args.content : undefined;
184
184
  const sizeInfo = writeContent ? theme.fg("muted", ` (${writeContent.length} characters)`) : "";
185
185
 
186
186
  return new Text(`${theme.fg("toolTitle", theme.bold("write"))} ${pathDisplay}${sizeInfo}`, 0, 0);
@@ -37,13 +37,13 @@ function addToolGuidance(options: BuildSystemPromptOptions, basePrompt: string):
37
37
 
38
38
  if (hasTool("edit")) {
39
39
  parts.push(
40
- "• Use `edit` action=prepare before generating precise replacements, then commit with the returned intent. Match exact content including whitespace.",
40
+ "• Use `edit` once with the target path and precise replacements. The harness owns preflight and rejects stale targets. Match exact content including whitespace.",
41
41
  );
42
42
  }
43
43
 
44
44
  if (hasTool("write")) {
45
45
  parts.push(
46
- "• Use `write` action=prepare before generating content; commit creates a new file and never overwrites.",
46
+ "• Use `write` once with the target path and content. The harness owns preflight, and creation never overwrites an existing file.",
47
47
  );
48
48
  }
49
49
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
- "version": "0.85.0",
3
+ "version": "0.85.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-sandbox",
9
- "version": "0.85.0",
9
+ "version": "0.85.4",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sandbox-runtime": "^0.0.26"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
3
  "private": true,
4
- "version": "0.85.0",
4
+ "version": "0.85.4",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -148,7 +148,24 @@ function createRemoteIntentOps(remote: string, remoteCwd: string, localCwd: stri
148
148
  if (!digest || !/^[0-9a-f]{64}$/i.test(digest)) throw new Error(`Invalid remote sha256 for ${p}`);
149
149
  return digest.toLowerCase();
150
150
  },
151
+ readPayload: (p) =>
152
+ sshExec(remote, `cat -- ${shellQuote(toRemote(p))}`).then((output) => output.toString("utf8")),
151
153
  removeFile: (p) => sshExec(remote, `rm -- ${shellQuote(toRemote(p))}`).then(() => {}),
154
+ async stagePayload(content) {
155
+ const stagedPath = (await sshExec(remote, `umask 077; mktemp "\${TMPDIR:-/tmp}/pi-file-mutation.XXXXXXXXXX"`))
156
+ .toString("utf8")
157
+ .trim();
158
+ if (!stagedPath.startsWith("/") || stagedPath.includes("\n")) {
159
+ throw new Error("Remote mktemp returned an invalid mutation payload path.");
160
+ }
161
+ try {
162
+ await sshExec(remote, `cat > ${shellQuote(stagedPath)}`, content);
163
+ return stagedPath;
164
+ } catch (error) {
165
+ await sshExec(remote, `rm -f -- ${shellQuote(stagedPath)}`).catch(() => {});
166
+ throw error;
167
+ }
168
+ },
152
169
  };
153
170
  }
154
171
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
- "version": "0.85.0",
3
+ "version": "0.85.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-with-deps",
9
- "version": "0.85.0",
9
+ "version": "0.85.4",
10
10
  "dependencies": {
11
11
  "ms": "^2.1.3"
12
12
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
3
  "private": true,
4
- "version": "0.85.0",
4
+ "version": "0.85.4",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",