@caupulican/pi-adaptative 0.85.3 → 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 (192) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/core/agent-session-services.d.ts.map +1 -1
  3. package/dist/core/agent-session-services.js +2 -0
  4. package/dist/core/agent-session-services.js.map +1 -1
  5. package/dist/core/agent-session.d.ts +6 -5
  6. package/dist/core/agent-session.d.ts.map +1 -1
  7. package/dist/core/agent-session.js +76 -87
  8. package/dist/core/agent-session.js.map +1 -1
  9. package/dist/core/auth-guidance.d.ts.map +1 -1
  10. package/dist/core/auth-guidance.js +3 -0
  11. package/dist/core/auth-guidance.js.map +1 -1
  12. package/dist/core/autonomy/lane-tool-surface.d.ts +2 -0
  13. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  14. package/dist/core/autonomy/lane-tool-surface.js +4 -3
  15. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  16. package/dist/core/background-lane-controller.d.ts +4 -0
  17. package/dist/core/background-lane-controller.d.ts.map +1 -1
  18. package/dist/core/background-lane-controller.js +2 -0
  19. package/dist/core/background-lane-controller.js.map +1 -1
  20. package/dist/core/background-tool-task-controller.d.ts +12 -7
  21. package/dist/core/background-tool-task-controller.d.ts.map +1 -1
  22. package/dist/core/background-tool-task-controller.js +55 -19
  23. package/dist/core/background-tool-task-controller.js.map +1 -1
  24. package/dist/core/bedrock-scope.d.ts +26 -0
  25. package/dist/core/bedrock-scope.d.ts.map +1 -0
  26. package/dist/core/bedrock-scope.js +178 -0
  27. package/dist/core/bedrock-scope.js.map +1 -0
  28. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  29. package/dist/core/delegation/worker-delegation-controller.js +6 -0
  30. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  31. package/dist/core/extensions/loader.d.ts.map +1 -1
  32. package/dist/core/extensions/loader.js +3 -0
  33. package/dist/core/extensions/loader.js.map +1 -1
  34. package/dist/core/foreground-recovery-controller.d.ts +25 -2
  35. package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
  36. package/dist/core/foreground-recovery-controller.js +111 -2
  37. package/dist/core/foreground-recovery-controller.js.map +1 -1
  38. package/dist/core/foreground-terminal-handoff-controller.d.ts +27 -0
  39. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -0
  40. package/dist/core/foreground-terminal-handoff-controller.js +56 -0
  41. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -0
  42. package/dist/core/goal-loop-controller.d.ts.map +1 -1
  43. package/dist/core/goal-loop-controller.js +5 -0
  44. package/dist/core/goal-loop-controller.js.map +1 -1
  45. package/dist/core/goals/goal-auto-continue-controller.d.ts +3 -0
  46. package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
  47. package/dist/core/goals/goal-auto-continue-controller.js +28 -7
  48. package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
  49. package/dist/core/human-input-controller.d.ts +9 -0
  50. package/dist/core/human-input-controller.d.ts.map +1 -1
  51. package/dist/core/human-input-controller.js +60 -5
  52. package/dist/core/human-input-controller.js.map +1 -1
  53. package/dist/core/human-input.d.ts +12 -0
  54. package/dist/core/human-input.d.ts.map +1 -1
  55. package/dist/core/human-input.js +59 -12
  56. package/dist/core/human-input.js.map +1 -1
  57. package/dist/core/local-runtime-controller.d.ts.map +1 -1
  58. package/dist/core/local-runtime-controller.js +15 -9
  59. package/dist/core/local-runtime-controller.js.map +1 -1
  60. package/dist/core/memory/providers/file-store.d.ts +1 -0
  61. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  62. package/dist/core/memory/providers/file-store.js +252 -125
  63. package/dist/core/memory/providers/file-store.js.map +1 -1
  64. package/dist/core/model-capability.d.ts +15 -1
  65. package/dist/core/model-capability.d.ts.map +1 -1
  66. package/dist/core/model-capability.js +24 -1
  67. package/dist/core/model-capability.js.map +1 -1
  68. package/dist/core/model-registry.d.ts +5 -0
  69. package/dist/core/model-registry.d.ts.map +1 -1
  70. package/dist/core/model-registry.js +18 -0
  71. package/dist/core/model-registry.js.map +1 -1
  72. package/dist/core/model-router-controller.d.ts +6 -6
  73. package/dist/core/model-router-controller.d.ts.map +1 -1
  74. package/dist/core/model-router-controller.js +5 -5
  75. package/dist/core/model-router-controller.js.map +1 -1
  76. package/dist/core/models/context-sizing.d.ts +1 -0
  77. package/dist/core/models/context-sizing.d.ts.map +1 -1
  78. package/dist/core/models/context-sizing.js +4 -1
  79. package/dist/core/models/context-sizing.js.map +1 -1
  80. package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
  81. package/dist/core/models/default-model-suggestions.js +20 -10
  82. package/dist/core/models/default-model-suggestions.js.map +1 -1
  83. package/dist/core/models/llamacpp-runtime.d.ts +32 -11
  84. package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
  85. package/dist/core/models/llamacpp-runtime.js +79 -28
  86. package/dist/core/models/llamacpp-runtime.js.map +1 -1
  87. package/dist/core/models/local-execution-planner.d.ts +24 -0
  88. package/dist/core/models/local-execution-planner.d.ts.map +1 -0
  89. package/dist/core/models/local-execution-planner.js +119 -0
  90. package/dist/core/models/local-execution-planner.js.map +1 -0
  91. package/dist/core/models/local-inference-profile.d.ts +34 -0
  92. package/dist/core/models/local-inference-profile.d.ts.map +1 -0
  93. package/dist/core/models/local-inference-profile.js +74 -0
  94. package/dist/core/models/local-inference-profile.js.map +1 -0
  95. package/dist/core/models/local-runtime.d.ts +23 -4
  96. package/dist/core/models/local-runtime.d.ts.map +1 -1
  97. package/dist/core/models/local-runtime.js +11 -8
  98. package/dist/core/models/local-runtime.js.map +1 -1
  99. package/dist/core/models/managed-ollama-model.d.ts +26 -0
  100. package/dist/core/models/managed-ollama-model.d.ts.map +1 -0
  101. package/dist/core/models/managed-ollama-model.js +59 -0
  102. package/dist/core/models/managed-ollama-model.js.map +1 -0
  103. package/dist/core/models/model-ref.js +11 -11
  104. package/dist/core/models/model-ref.js.map +1 -1
  105. package/dist/core/models/prism-llamacpp-lifecycle.d.ts +10 -20
  106. package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -1
  107. package/dist/core/models/prism-llamacpp-lifecycle.js +11 -31
  108. package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -1
  109. package/dist/core/models/prism-llamacpp-server-probe.d.ts +10 -0
  110. package/dist/core/models/prism-llamacpp-server-probe.d.ts.map +1 -0
  111. package/dist/core/models/prism-llamacpp-server-probe.js +36 -0
  112. package/dist/core/models/prism-llamacpp-server-probe.js.map +1 -0
  113. package/dist/core/models/runtime-arbiter.d.ts +3 -0
  114. package/dist/core/models/runtime-arbiter.d.ts.map +1 -1
  115. package/dist/core/models/runtime-arbiter.js +2 -1
  116. package/dist/core/models/runtime-arbiter.js.map +1 -1
  117. package/dist/core/research/research-lane-controller.d.ts.map +1 -1
  118. package/dist/core/research/research-lane-controller.js +14 -5
  119. package/dist/core/research/research-lane-controller.js.map +1 -1
  120. package/dist/core/runtime-builder.d.ts +5 -1
  121. package/dist/core/runtime-builder.d.ts.map +1 -1
  122. package/dist/core/runtime-builder.js +37 -4
  123. package/dist/core/runtime-builder.js.map +1 -1
  124. package/dist/core/scout-controller.d.ts +3 -2
  125. package/dist/core/scout-controller.d.ts.map +1 -1
  126. package/dist/core/scout-controller.js +1 -0
  127. package/dist/core/scout-controller.js.map +1 -1
  128. package/dist/core/sdk.d.ts.map +1 -1
  129. package/dist/core/sdk.js +10 -8
  130. package/dist/core/sdk.js.map +1 -1
  131. package/dist/core/settings-manager.d.ts +13 -0
  132. package/dist/core/settings-manager.d.ts.map +1 -1
  133. package/dist/core/settings-manager.js +59 -0
  134. package/dist/core/settings-manager.js.map +1 -1
  135. package/dist/core/system-prompt-builder.d.ts +5 -2
  136. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  137. package/dist/core/system-prompt-builder.js +22 -10
  138. package/dist/core/system-prompt-builder.js.map +1 -1
  139. package/dist/core/system-prompt.d.ts +3 -0
  140. package/dist/core/system-prompt.d.ts.map +1 -1
  141. package/dist/core/system-prompt.js +181 -55
  142. package/dist/core/system-prompt.js.map +1 -1
  143. package/dist/core/tool-protocol-controller.d.ts.map +1 -1
  144. package/dist/core/tool-protocol-controller.js +5 -3
  145. package/dist/core/tool-protocol-controller.js.map +1 -1
  146. package/dist/core/tools/edit-diff.d.ts +2 -0
  147. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  148. package/dist/core/tools/edit-diff.js +9 -1
  149. package/dist/core/tools/edit-diff.js.map +1 -1
  150. package/dist/core/tools/edit.d.ts +5 -8
  151. package/dist/core/tools/edit.d.ts.map +1 -1
  152. package/dist/core/tools/edit.js +88 -55
  153. package/dist/core/tools/edit.js.map +1 -1
  154. package/dist/core/tools/file-mutation-intent.d.ts +42 -15
  155. package/dist/core/tools/file-mutation-intent.d.ts.map +1 -1
  156. package/dist/core/tools/file-mutation-intent.js +271 -77
  157. package/dist/core/tools/file-mutation-intent.js.map +1 -1
  158. package/dist/core/tools/index.d.ts +1 -1
  159. package/dist/core/tools/index.d.ts.map +1 -1
  160. package/dist/core/tools/index.js +1 -1
  161. package/dist/core/tools/index.js.map +1 -1
  162. package/dist/core/tools/write.d.ts +5 -10
  163. package/dist/core/tools/write.d.ts.map +1 -1
  164. package/dist/core/tools/write.js +92 -73
  165. package/dist/core/tools/write.js.map +1 -1
  166. package/dist/index.d.ts +1 -1
  167. package/dist/index.d.ts.map +1 -1
  168. package/dist/index.js +1 -1
  169. package/dist/index.js.map +1 -1
  170. package/dist/modes/interactive/auth-dialogs-controller.d.ts +6 -0
  171. package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
  172. package/dist/modes/interactive/auth-dialogs-controller.js +59 -12
  173. package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
  174. package/dist/modes/interactive/local-model-commands.d.ts +1 -1
  175. package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
  176. package/dist/modes/interactive/local-model-commands.js +51 -8
  177. package/dist/modes/interactive/local-model-commands.js.map +1 -1
  178. package/docs/providers.md +34 -10
  179. package/docs/tool-boundary-performance-roadmap-2026-08-02.md +21 -18
  180. package/examples/extensions/built-in-tool-renderer.ts +1 -1
  181. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  182. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  183. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  184. package/examples/extensions/minimal-mode.ts +1 -1
  185. package/examples/extensions/prompt-customizer.ts +2 -2
  186. package/examples/extensions/sandbox/package-lock.json +2 -2
  187. package/examples/extensions/sandbox/package.json +1 -1
  188. package/examples/extensions/ssh.ts +17 -0
  189. package/examples/extensions/with-deps/package-lock.json +2 -2
  190. package/examples/extensions/with-deps/package.json +1 -1
  191. package/npm-shrinkwrap.json +240 -260
  192. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAChC,0BAA0B,EAC1B,oCAAoC,GACpC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,kCAAkC,EAClC,+BAA+B,GAC/B,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,sBAAsB,EACtB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,gCAAgC,EAChC,iBAAiB,GACjB,MAAM,o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O,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAiBpC;AAED,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,YAAY,EACtB,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC1C,IAAI,EAAE,CAUR;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E;AAED,wBAAgB,cAAc,CAC7B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,YAAY,EACtB,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC1C,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAiBjC"}
@@ -4,7 +4,7 @@ export { createBashTool, createBashToolDefinition, createLocalBashOperations, cr
4
4
  export { CONTEXT_SCOUT_GUIDANCE, createContextScoutToolDefinition, formatScoutResult, } from "./context-scout.js";
5
5
  export { createEditTool, createEditToolDefinition, } from "./edit.js";
6
6
  export { createExtensionifyTool, createExtensionifyToolDefinition, } from "./extensionify.js";
7
- export { FileMutationIntentController, localFileMutationIntentOperations, } from "./file-mutation-intent.js";
7
+ export { FileMutationIntentController, FileMutationPreflightError, localFileMutationIntentOperations, } from "./file-mutation-intent.js";
8
8
  export { withFileMutationQueue } from "./file-mutation-queue.js";
9
9
  export { createFindTool, createFindToolDefinition, } from "./find.js";
10
10
  export { createGrepTool, createGrepToolDefinition, } from "./grep.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAIN,0BAA0B,EAC1B,oCAAoC,GACpC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAON,cAA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,CAAC;QAC7C,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC;QAChD,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QAClC,WAAW,EAAE,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,CAAC;QAC5D,QAAQ,EAAE,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC;QACpD,YAAY,EAAE,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,CAAC;QAChE,iBAAiB,EAAE,0BAA0B,CAAC,GAAG,EAAE,OAAO,EAAE,iBAAiB,CAAC;KAC9E,CAAC;AACH,CAAC","sourcesContent":["export {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"@caupulican/pi-agent-core/node\";\nexport {\n\ttype ArtifactRetrieveToolDetails,\n\ttype ArtifactRetrieveToolInput,\n\ttype ArtifactRetrieveToolOptions,\n\tcreateArtifactRetrieveTool,\n\tcreateArtifactRetrieveToolDefinition,\n} from \"./artifact-retrieve.ts\";\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLocalPlatformShellOperations,\n\tcreateLocalPowerShellOperations,\n} from \"./bash.ts\";\nexport {\n\tCONTEXT_SCOUT_GUIDANCE,\n\ttype ContextScoutToolDependencies,\n\ttype ContextScoutToolDetails,\n\ttype ContextScoutToolInput,\n\tcreateContextScoutToolDefinition,\n\tformatScoutResult,\n} from \"./context-scout.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport {\n\tcreateExtensionifyTool,\n\tcreateExtensionifyToolDefinition,\n\ttype ExtensionifyInput,\n\ttype ExtensionifyReport,\n\ttype ExtensionifyToolDetails,\n\ttype ExtensionifyToolOptions,\n} from \"./extensionify.ts\";\nexport {\n\ttype FileContentReference,\n\tFileMutationIntentController,\n\ttype FileMutationIntentControllerOptions,\n\ttype FileMutationIntentOperations,\n\ttype FileMutationKind,\n\ttype FileMutationLease,\n\ttype FilePathIdentity,\n\ttype FilePathInspection,\n\tlocalFileMutationIntentOperations,\n\ttype PreparedFileMutation,\n} from \"./file-mutation-intent.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateProfileWriterToolDefinition,\n\ttype ProfileWriterToolDetails,\n\ttype ProfileWriterToolInput,\n} from \"./profile-writer.ts\";\nexport {\n\tcreatePythonTool,\n\tcreatePythonToolDefinition,\n\tDEFAULT_PYTHON_TIMEOUT_SECONDS,\n\tMAX_PYTHON_OUTPUT_BYTES,\n\tMAX_PYTHON_TIMEOUT_SECONDS,\n\ttype PythonExecutionRequest,\n\ttype PythonExecutionResult,\n\ttype PythonOperations,\n\ttype PythonToolDetails,\n\ttype PythonToolInput,\n\ttype PythonToolOptions,\n\tresolvePythonToolPath,\n} from \"./python.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tcreateSecretStoreToolDefinition,\n\ttype SecretStoreStatus,\n\ttype SecretStoreToolDetails,\n\ttype SecretStoreToolInput,\n\ttype SecretStoreToolOptions,\n} from \"./secret-store.ts\";\nexport {\n\tcreateSkillAuditTool,\n\tcreateSkillAuditToolDefinition,\n\tjaccard,\n\ttype SkillAuditInput,\n\ttype SkillAuditReport,\n\ttype SkillAuditToolDetails,\n\ttype SkillAuditToolOptions,\n\ttokenize,\n} from \"./skill-audit.ts\";\nexport {\n\tcreateSkillifyTool,\n\tcreateSkillifyToolDefinition,\n\ttype SkillifyInput,\n\ttype SkillifyReport,\n\ttype SkillifyToolDetails,\n\ttype SkillifyToolOptions,\n} from \"./skillify.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolDetails,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport {\n\ttype ArtifactRetrieveToolOptions,\n\tcreateArtifactRetrieveTool,\n\tcreateArtifactRetrieveToolDefinition,\n} from \"./artifact-retrieve.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport {\n\tcreateExtensionifyTool,\n\tcreateExtensionifyToolDefinition,\n\ttype ExtensionifyToolOptions,\n} from \"./extensionify.ts\";\nimport { FileMutationIntentController } from \"./file-mutation-intent.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createPythonTool, createPythonToolDefinition, type PythonToolOptions } from \"./python.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createSkillAuditTool, createSkillAuditToolDefinition, type SkillAuditToolOptions } from \"./skill-audit.ts\";\nimport { createSkillifyTool, createSkillifyToolDefinition, type SkillifyToolOptions } from \"./skillify.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"python\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"grep\"\n\t| \"find\"\n\t| \"ls\"\n\t| \"skill_audit\"\n\t| \"skillify\"\n\t| \"extensionify\"\n\t| \"artifact_retrieve\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"python\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"skill_audit\",\n\t\"skillify\",\n\t\"extensionify\",\n\t\"artifact_retrieve\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\tpython?: PythonToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n\tskill_audit?: SkillAuditToolOptions;\n\tskillify?: SkillifyToolOptions;\n\textensionify?: ExtensionifyToolOptions;\n\tartifact_retrieve?: ArtifactRetrieveToolOptions;\n}\n\nfunction withSharedFileMutationIntents(options?: ToolsOptions): ToolsOptions {\n\tconst writeController = options?.write?.intentController;\n\tconst editController = options?.edit?.intentController;\n\tif ((options?.write?.operations || options?.edit?.operations) && !writeController && !editController) {\n\t\tthrow new Error(\"Custom file operations require an explicit shared file mutation intent controller.\");\n\t}\n\tif (writeController && editController && writeController !== editController) {\n\t\tthrow new Error(\"Write and edit tools in one surface must share one file mutation intent controller.\");\n\t}\n\tconst intentController = writeController ?? editController ?? new FileMutationIntentController();\n\treturn {\n\t\t...options,\n\t\twrite: { ...options?.write, intentController },\n\t\tedit: { ...options?.edit, intentController },\n\t};\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"python\":\n\t\t\treturn createPythonToolDefinition(cwd, options?.python);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"skill_audit\":\n\t\t\treturn createSkillAuditToolDefinition(cwd, options?.skill_audit);\n\t\tcase \"skillify\":\n\t\t\treturn createSkillifyToolDefinition(cwd, options?.skillify);\n\t\tcase \"extensionify\":\n\t\t\treturn createExtensionifyToolDefinition(cwd, options?.extensionify);\n\t\tcase \"artifact_retrieve\":\n\t\t\treturn createArtifactRetrieveToolDefinition(cwd, options?.artifact_retrieve);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"python\":\n\t\t\treturn createPythonTool(cwd, options?.python);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"skill_audit\":\n\t\t\treturn createSkillAuditTool(cwd, options?.skill_audit);\n\t\tcase \"skillify\":\n\t\t\treturn createSkillifyTool(cwd, options?.skillify);\n\t\tcase \"extensionify\":\n\t\t\treturn createExtensionifyTool(cwd, options?.extensionify);\n\t\tcase \"artifact_retrieve\":\n\t\t\treturn createArtifactRetrieveTool(cwd, options?.artifact_retrieve);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): ToolDef[] {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, bashOptions),\n\t\tcreatePythonToolDefinition(cwd, options?.python),\n\t\tcreateEditToolDefinition(cwd, sharedOptions.edit),\n\t\tcreateWriteToolDefinition(cwd, sharedOptions.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): Partial<Record<ToolName, ToolDef>> {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, bashOptions),\n\t\tpython: createPythonToolDefinition(cwd, options?.python),\n\t\tedit: createEditToolDefinition(cwd, sharedOptions.edit),\n\t\twrite: createWriteToolDefinition(cwd, sharedOptions.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tskill_audit: createSkillAuditToolDefinition(cwd, options?.skill_audit),\n\t\tskillify: createSkillifyToolDefinition(cwd, options?.skillify),\n\t\textensionify: createExtensionifyToolDefinition(cwd, options?.extensionify),\n\t\tartifact_retrieve: createArtifactRetrieveToolDefinition(cwd, options?.artifact_retrieve),\n\t};\n}\n\nexport function createCodingTools(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): Tool[] {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, bashOptions),\n\t\tcreatePythonTool(cwd, options?.python),\n\t\tcreateEditTool(cwd, sharedOptions.edit),\n\t\tcreateWriteTool(cwd, sharedOptions.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): Partial<Record<ToolName, Tool>> {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, bashOptions),\n\t\tpython: createPythonTool(cwd, options?.python),\n\t\tedit: createEditTool(cwd, sharedOptions.edit),\n\t\twrite: createWriteTool(cwd, sharedOptions.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tskill_audit: createSkillAuditTool(cwd, options?.skill_audit),\n\t\tskillify: createSkillifyTool(cwd, options?.skillify),\n\t\textensionify: createExtensionifyTool(cwd, options?.extensionify),\n\t\tartifact_retrieve: createArtifactRetrieveTool(cwd, options?.artifact_retrieve),\n\t};\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAIN,0BAA0B,EAC1B,oCAAoC,GACpC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,kCAAkC,EAClC,+BAA+B,GAC/B,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,sBAAsB,EAItB,gCAAgC,EAChC,iBAAiB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,sBAAsB,EACtB,gCAAgC,GAKhC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEN,4BAA4B,EAM5B,0BAA0B,EAI1B,iCAAiC,GACjC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,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,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,CAAC;QAChE,iBAAiB,EAAE,0BAA0B,CAAC,GAAG,EAAE,OAAO,EAAE,iBAAiB,CAAC;KAC9E,CAAC;AACH,CAAC","sourcesContent":["export {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"@caupulican/pi-agent-core/node\";\nexport {\n\ttype ArtifactRetrieveToolDetails,\n\ttype ArtifactRetrieveToolInput,\n\ttype ArtifactRetrieveToolOptions,\n\tcreateArtifactRetrieveTool,\n\tcreateArtifactRetrieveToolDefinition,\n} from \"./artifact-retrieve.ts\";\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLocalPlatformShellOperations,\n\tcreateLocalPowerShellOperations,\n} from \"./bash.ts\";\nexport {\n\tCONTEXT_SCOUT_GUIDANCE,\n\ttype ContextScoutToolDependencies,\n\ttype ContextScoutToolDetails,\n\ttype ContextScoutToolInput,\n\tcreateContextScoutToolDefinition,\n\tformatScoutResult,\n} from \"./context-scout.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport {\n\tcreateExtensionifyTool,\n\tcreateExtensionifyToolDefinition,\n\ttype ExtensionifyInput,\n\ttype ExtensionifyReport,\n\ttype ExtensionifyToolDetails,\n\ttype ExtensionifyToolOptions,\n} from \"./extensionify.ts\";\nexport {\n\ttype FileContentReference,\n\tFileMutationIntentController,\n\ttype FileMutationIntentControllerOptions,\n\ttype FileMutationIntentOperations,\n\ttype FileMutationKind,\n\ttype FileMutationLease,\n\ttype FileMutationPayloadReference,\n\tFileMutationPreflightError,\n\ttype FileMutationPreflightFailureReason,\n\ttype FilePathIdentity,\n\ttype FilePathInspection,\n\tlocalFileMutationIntentOperations,\n} from \"./file-mutation-intent.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateProfileWriterToolDefinition,\n\ttype ProfileWriterToolDetails,\n\ttype ProfileWriterToolInput,\n} from \"./profile-writer.ts\";\nexport {\n\tcreatePythonTool,\n\tcreatePythonToolDefinition,\n\tDEFAULT_PYTHON_TIMEOUT_SECONDS,\n\tMAX_PYTHON_OUTPUT_BYTES,\n\tMAX_PYTHON_TIMEOUT_SECONDS,\n\ttype PythonExecutionRequest,\n\ttype PythonExecutionResult,\n\ttype PythonOperations,\n\ttype PythonToolDetails,\n\ttype PythonToolInput,\n\ttype PythonToolOptions,\n\tresolvePythonToolPath,\n} from \"./python.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tcreateSecretStoreToolDefinition,\n\ttype SecretStoreStatus,\n\ttype SecretStoreToolDetails,\n\ttype SecretStoreToolInput,\n\ttype SecretStoreToolOptions,\n} from \"./secret-store.ts\";\nexport {\n\tcreateSkillAuditTool,\n\tcreateSkillAuditToolDefinition,\n\tjaccard,\n\ttype SkillAuditInput,\n\ttype SkillAuditReport,\n\ttype SkillAuditToolDetails,\n\ttype SkillAuditToolOptions,\n\ttokenize,\n} from \"./skill-audit.ts\";\nexport {\n\tcreateSkillifyTool,\n\tcreateSkillifyToolDefinition,\n\ttype SkillifyInput,\n\ttype SkillifyReport,\n\ttype SkillifyToolDetails,\n\ttype SkillifyToolOptions,\n} from \"./skillify.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolDetails,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport {\n\ttype ArtifactRetrieveToolOptions,\n\tcreateArtifactRetrieveTool,\n\tcreateArtifactRetrieveToolDefinition,\n} from \"./artifact-retrieve.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport {\n\tcreateExtensionifyTool,\n\tcreateExtensionifyToolDefinition,\n\ttype ExtensionifyToolOptions,\n} from \"./extensionify.ts\";\nimport { FileMutationIntentController } from \"./file-mutation-intent.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createPythonTool, createPythonToolDefinition, type PythonToolOptions } from \"./python.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createSkillAuditTool, createSkillAuditToolDefinition, type SkillAuditToolOptions } from \"./skill-audit.ts\";\nimport { createSkillifyTool, createSkillifyToolDefinition, type SkillifyToolOptions } from \"./skillify.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"python\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"grep\"\n\t| \"find\"\n\t| \"ls\"\n\t| \"skill_audit\"\n\t| \"skillify\"\n\t| \"extensionify\"\n\t| \"artifact_retrieve\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"python\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"skill_audit\",\n\t\"skillify\",\n\t\"extensionify\",\n\t\"artifact_retrieve\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\tpython?: PythonToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n\tskill_audit?: SkillAuditToolOptions;\n\tskillify?: SkillifyToolOptions;\n\textensionify?: ExtensionifyToolOptions;\n\tartifact_retrieve?: ArtifactRetrieveToolOptions;\n}\n\nfunction withSharedFileMutationIntents(options?: ToolsOptions): ToolsOptions {\n\tconst writeController = options?.write?.intentController;\n\tconst editController = options?.edit?.intentController;\n\tif ((options?.write?.operations || options?.edit?.operations) && !writeController && !editController) {\n\t\tthrow new Error(\"Custom file operations require an explicit shared file mutation intent controller.\");\n\t}\n\tif (writeController && editController && writeController !== editController) {\n\t\tthrow new Error(\"Write and edit tools in one surface must share one file mutation intent controller.\");\n\t}\n\tconst intentController = writeController ?? editController ?? new FileMutationIntentController();\n\treturn {\n\t\t...options,\n\t\twrite: { ...options?.write, intentController },\n\t\tedit: { ...options?.edit, intentController },\n\t};\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"python\":\n\t\t\treturn createPythonToolDefinition(cwd, options?.python);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"skill_audit\":\n\t\t\treturn createSkillAuditToolDefinition(cwd, options?.skill_audit);\n\t\tcase \"skillify\":\n\t\t\treturn createSkillifyToolDefinition(cwd, options?.skillify);\n\t\tcase \"extensionify\":\n\t\t\treturn createExtensionifyToolDefinition(cwd, options?.extensionify);\n\t\tcase \"artifact_retrieve\":\n\t\t\treturn createArtifactRetrieveToolDefinition(cwd, options?.artifact_retrieve);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"python\":\n\t\t\treturn createPythonTool(cwd, options?.python);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"skill_audit\":\n\t\t\treturn createSkillAuditTool(cwd, options?.skill_audit);\n\t\tcase \"skillify\":\n\t\t\treturn createSkillifyTool(cwd, options?.skillify);\n\t\tcase \"extensionify\":\n\t\t\treturn createExtensionifyTool(cwd, options?.extensionify);\n\t\tcase \"artifact_retrieve\":\n\t\t\treturn createArtifactRetrieveTool(cwd, options?.artifact_retrieve);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): ToolDef[] {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, bashOptions),\n\t\tcreatePythonToolDefinition(cwd, options?.python),\n\t\tcreateEditToolDefinition(cwd, sharedOptions.edit),\n\t\tcreateWriteToolDefinition(cwd, sharedOptions.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): Partial<Record<ToolName, ToolDef>> {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, bashOptions),\n\t\tpython: createPythonToolDefinition(cwd, options?.python),\n\t\tedit: createEditToolDefinition(cwd, sharedOptions.edit),\n\t\twrite: createWriteToolDefinition(cwd, sharedOptions.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tskill_audit: createSkillAuditToolDefinition(cwd, options?.skill_audit),\n\t\tskillify: createSkillifyToolDefinition(cwd, options?.skillify),\n\t\textensionify: createExtensionifyToolDefinition(cwd, options?.extensionify),\n\t\tartifact_retrieve: createArtifactRetrieveToolDefinition(cwd, options?.artifact_retrieve),\n\t};\n}\n\nexport function createCodingTools(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): Tool[] {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, bashOptions),\n\t\tcreatePythonTool(cwd, options?.python),\n\t\tcreateEditTool(cwd, sharedOptions.edit),\n\t\tcreateWriteTool(cwd, sharedOptions.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): Partial<Record<ToolName, Tool>> {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, bashOptions),\n\t\tpython: createPythonTool(cwd, options?.python),\n\t\tedit: createEditTool(cwd, sharedOptions.edit),\n\t\twrite: createWriteTool(cwd, sharedOptions.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tskill_audit: createSkillAuditTool(cwd, options?.skill_audit),\n\t\tskillify: createSkillifyTool(cwd, options?.skillify),\n\t\textensionify: createExtensionifyTool(cwd, options?.extensionify),\n\t\tartifact_retrieve: createArtifactRetrieveTool(cwd, options?.artifact_retrieve),\n\t};\n}\n"]}
@@ -3,18 +3,14 @@ import { type Static, Type } from "typebox";
3
3
  import type { ToolDefinition } from "../extensions/types.ts";
4
4
  import { FileMutationIntentController } from "./file-mutation-intent.ts";
5
5
  declare const writeSchema: Type.TUnion<[Type.TObject<{
6
- action: Type.TLiteral<"prepare">;
7
6
  path: Type.TString;
8
- }>, Type.TObject<{
9
- action: Type.TLiteral<"commit">;
10
- path: Type.TString;
11
- intentId: Type.TString;
12
7
  content: Type.TString;
13
8
  }>, Type.TObject<{
14
- action: Type.TLiteral<"commit">;
15
9
  path: Type.TString;
16
- intentId: Type.TString;
17
10
  contentRef: Type.TString;
11
+ }>, Type.TObject<{
12
+ path: Type.TString;
13
+ payloadRef: Type.TString;
18
14
  }>]>;
19
15
  export type WriteToolInput = Static<typeof writeSchema>;
20
16
  /**
@@ -30,12 +26,11 @@ export interface WriteOperations {
30
26
  export interface WriteToolOptions {
31
27
  /** Custom operations for file writing. Default: local filesystem */
32
28
  operations?: WriteOperations;
33
- /** Session-owned two-phase intent and exact-content-reference authority. */
29
+ /** Session-owned harness preflight and exact-content-reference authority. */
34
30
  intentController?: FileMutationIntentController;
35
31
  }
36
32
  export interface WriteToolDetails {
37
- phase: "prepared" | "committed";
38
- intentId?: string;
33
+ phase: "written";
39
34
  contentRef?: string;
40
35
  byteCount?: number;
41
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAA6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M,wBAAwB,CAAC;AACtF,OAAO,EAEN,4BAA4B,EAE5B,MAAM,2BAA2B,CAAC;AAOnC,QAAA,MAAM,WAAW;;;;;;;;;IAsBf,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,oFAAoF;IACpF,UAAU,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,mCAAmC;IACnC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAOD,MAAM,WAAW,gBAAgB;IAChC,oEAAoE;IACpE,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,4BAA4B,CAAC;CAChD;AAED,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AA6ND,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,gBAAgB,GACxB,cAAc,CAAC,OAAO,WAAW,EAAE,gBAAgB,CAAC,CAoItD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC,OAAO,WAAW,CAAC,CAEtG"}
@@ -4,30 +4,25 @@ import { Container, Text } from "@caupulican/pi-tui";
4
4
  import { Type } from "typebox";
5
5
  import { keyHint } from "../../modes/interactive/components/keybinding-hints.js";
6
6
  import { getLanguageFromPath, highlightCode } from "../../modes/interactive/theme/theme.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 { normalizeDisplayText, renderToolPath, replaceTabs, str } from "./render-utils.js";
11
11
  import { wrapToolDefinition } from "./tool-definition-wrapper.js";
12
12
  const writePathSchema = Type.String({ minLength: 1 });
13
- const writeCommitProperties = {
14
- action: Type.Literal("commit"),
15
- path: writePathSchema,
16
- intentId: Type.String({ minLength: 1 }),
17
- };
18
13
  const writeSchema = Type.Union([
19
14
  Type.Object({
20
- action: Type.Literal("prepare"),
21
15
  path: writePathSchema,
22
- }, { additionalProperties: false }),
23
- Type.Object({
24
- ...writeCommitProperties,
25
16
  content: Type.String(),
26
17
  }, { additionalProperties: false }),
27
18
  Type.Object({
28
- ...writeCommitProperties,
19
+ path: writePathSchema,
29
20
  contentRef: Type.String({ minLength: 1 }),
30
21
  }, { additionalProperties: false }),
22
+ Type.Object({
23
+ path: writePathSchema,
24
+ payloadRef: Type.String({ minLength: 1 }),
25
+ }, { additionalProperties: false }),
31
26
  ]);
32
27
  const defaultWriteOperations = {
33
28
  createFile: (path, content) => fsWriteFile(path, content, { encoding: "utf-8", flag: "wx" }),
@@ -129,9 +124,8 @@ function formatWriteCall(args, options, theme, cache, cwd) {
129
124
  const fileContent = str(args?.content);
130
125
  const hasContent = typeof args?.content === "string";
131
126
  const pathDisplay = renderToolPath(rawPath, theme, cwd);
132
- const action = args?.action === "prepare" ? "prepare" : args?.action === "commit" ? "commit" : undefined;
133
- let text = `${theme.fg("toolTitle", theme.bold("write"))}${action ? ` ${theme.fg("muted", action)}` : ""} ${pathDisplay}`;
134
- if (args?.action === "commit" && !hasContent && typeof args.contentRef !== "string") {
127
+ let text = `${theme.fg("toolTitle", theme.bold("write"))} ${pathDisplay}`;
128
+ if (!hasContent && typeof args?.contentRef !== "string" && typeof args?.payloadRef !== "string") {
135
129
  text += `\n\n${theme.fg("error", "[invalid content arg - expected string]")}`;
136
130
  }
137
131
  else if (hasContent && fileContent) {
@@ -158,8 +152,32 @@ function formatWriteCall(args, options, theme, cache, cwd) {
158
152
  else if (args?.contentRef) {
159
153
  text += `\n\n${theme.fg("muted", `reuse ${args.contentRef}`)}`;
160
154
  }
155
+ else if (args?.payloadRef) {
156
+ text += `\n\n${theme.fg("muted", `retarget ${args.payloadRef}`)}`;
157
+ }
161
158
  return text;
162
159
  }
160
+ async function writeCollisionWithRetainedPayload(error, input, intentController, signal) {
161
+ const retargetError = (reference) => new Error(`PI_FILE_MUTATION_RETARGET write_collision: ${reference}. Choose only a corrected path; the exact valid write payload is retained.`);
162
+ if ("contentRef" in input) {
163
+ await intentController.assertContentReference(input.contentRef, signal);
164
+ return retargetError(`contentRef ${input.contentRef}`);
165
+ }
166
+ if ("payloadRef" in input) {
167
+ await intentController.assertMutationPayload(input.payloadRef, "write", signal);
168
+ return retargetError(`payloadRef ${input.payloadRef}`);
169
+ }
170
+ try {
171
+ const retained = await intentController.retainMutationPayload("write", input.content);
172
+ if (retained) {
173
+ return retargetError(`payloadRef ${retained.payloadRef}`);
174
+ }
175
+ }
176
+ catch {
177
+ // The collision remains authoritative when the bounded retry cache is unavailable.
178
+ }
179
+ return new Error(`${error.message} The payload could not be retained within the secure retry-cache bound.`);
180
+ }
163
181
  function formatWriteResult(result, theme) {
164
182
  if (!result.isError) {
165
183
  return undefined;
@@ -182,81 +200,82 @@ export function createWriteToolDefinition(cwd, options) {
182
200
  return {
183
201
  name: "write",
184
202
  label: "write",
185
- description: "Create a file without overwriting: prepare(path), then commit(path,intentId,content|contentRef). Prepare rejects collisions before content generation; commit rechecks atomically.",
203
+ description: "Create a new file without overwriting. Send path and exactly one of content or contentRef. After a path-only collision, use the returned payloadRef with only a corrected path. The harness owns preflight, bounded payload retention, and atomic rechecks.",
186
204
  promptSnippet: "Preflight new paths; never overwrite",
187
205
  promptGuidelines: [
188
- "Before content generation, prepare(path); then commit with intentId and one of content or contentRef.",
206
+ "Call write once with path and exactly one of content or contentRef; preparation and collision checks are harness-owned.",
207
+ "If a collision result returns payloadRef, choose a new path and reuse that reference instead of regenerating content.",
189
208
  "Write is create-only; edit existing files. Reuse contentRef for exact copies.",
190
209
  ],
191
210
  parameters: writeSchema,
192
211
  async execute(_toolCallId, input, signal, _onUpdate, _ctx) {
193
212
  const { path } = input;
194
213
  const absolutePath = resolveToCwd(path, cwd);
195
- return withFileMutationQueue(absolutePath, async () => {
196
- // Do not reject from an abort event listener here: that would release the
197
- // mutation queue while an in-flight filesystem operation may still finish.
198
- // Checking signal.aborted after each await observes the same aborts while
199
- // keeping the queue locked until the current operation has settled.
200
- const throwIfAborted = () => {
201
- if (signal?.aborted)
202
- throw new Error("Operation aborted");
203
- };
204
- throwIfAborted();
205
- if (input.action === "prepare") {
206
- const prepared = await intentController.prepare("write", absolutePath, signal, path);
214
+ const content = "content" in input && typeof input.content === "string" ? input.content : undefined;
215
+ const contentRef = "contentRef" in input && typeof input.contentRef === "string" ? input.contentRef : undefined;
216
+ const payloadRef = "payloadRef" in input && typeof input.payloadRef === "string" ? input.payloadRef : undefined;
217
+ if ([content, contentRef, payloadRef].filter((value) => value !== undefined).length !== 1) {
218
+ throw new Error("Write requires exactly one of content, contentRef, or payloadRef.");
219
+ }
220
+ try {
221
+ const lease = await intentController.prepare("write", absolutePath, signal, path);
222
+ return await withFileMutationQueue(absolutePath, async () => {
223
+ // Do not reject from an abort event listener here: that would release the
224
+ // mutation queue while an in-flight filesystem operation may still finish.
225
+ // Checking signal.aborted after each await observes the same aborts while
226
+ // keeping the queue locked until the current operation has settled.
227
+ const throwIfAborted = () => {
228
+ if (signal?.aborted)
229
+ throw new Error("Operation aborted");
230
+ };
231
+ throwIfAborted();
232
+ await intentController.assertCurrent(lease, signal);
233
+ await ops.mkdir(dirname(absolutePath));
234
+ throwIfAborted();
235
+ let contentReference;
236
+ try {
237
+ if (content !== undefined) {
238
+ await ops.createFile(absolutePath, content);
239
+ contentReference = intentController.rememberContent(absolutePath, content);
240
+ }
241
+ else if (contentRef !== undefined) {
242
+ contentReference = await intentController.copyReferencedContent(contentRef, absolutePath, signal);
243
+ }
244
+ else {
245
+ if (payloadRef === undefined)
246
+ throw new Error("Write requires a payload reference.");
247
+ contentReference = await intentController.copyMutationPayload(payloadRef, absolutePath, signal);
248
+ }
249
+ }
250
+ catch (error) {
251
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "EEXIST") {
252
+ throw new FileMutationPreflightError("write_collision", `Write collision: ${path} already exists; no content was overwritten.`);
253
+ }
254
+ throw error;
255
+ }
256
+ throwIfAborted();
257
+ const byteCount = contentReference.byteLength;
207
258
  return {
208
259
  content: [
209
260
  {
210
261
  type: "text",
211
- text: `Write path accepted. Commit ${path} with intentId ${prepared.intentId}.`,
262
+ text: `Successfully wrote ${byteCount} bytes to ${path}; this write is complete, so do not call write again for this path. To copy these exact bytes to a different new path, call write once for that path with contentRef ${contentReference.contentRef}.`,
212
263
  },
213
264
  ],
214
- details: { phase: "prepared", intentId: prepared.intentId },
265
+ details: {
266
+ phase: "written",
267
+ contentRef: contentReference.contentRef,
268
+ byteCount,
269
+ },
215
270
  };
271
+ });
272
+ }
273
+ catch (error) {
274
+ if (error instanceof FileMutationPreflightError && error.reason === "write_collision") {
275
+ throw await writeCollisionWithRetainedPayload(error, input, intentController, signal);
216
276
  }
217
- const content = "content" in input && typeof input.content === "string" ? input.content : undefined;
218
- const contentRef = "contentRef" in input && typeof input.contentRef === "string" ? input.contentRef : undefined;
219
- if ((content === undefined) === (contentRef === undefined)) {
220
- throw new Error("Write commit requires exactly one of content or contentRef.");
221
- }
222
- const lease = intentController.consume(input.intentId, "write", absolutePath);
223
- await intentController.assertCurrent(lease, signal);
224
- await ops.mkdir(dirname(absolutePath));
225
- throwIfAborted();
226
- let contentReference;
227
- try {
228
- if (content !== undefined) {
229
- await ops.createFile(absolutePath, content);
230
- contentReference = intentController.rememberContent(absolutePath, content);
231
- }
232
- else {
233
- if (contentRef === undefined)
234
- throw new Error("Write commit requires content or contentRef.");
235
- contentReference = await intentController.copyReferencedContent(contentRef, absolutePath, signal);
236
- }
237
- }
238
- catch (error) {
239
- if (typeof error === "object" && error !== null && "code" in error && error.code === "EEXIST") {
240
- throw new Error(`Write collision: ${path} already exists; no content was overwritten.`);
241
- }
242
- throw error;
243
- }
244
- throwIfAborted();
245
- const byteCount = contentReference.byteLength;
246
- return {
247
- content: [
248
- {
249
- type: "text",
250
- text: `Successfully wrote ${byteCount} bytes to ${path}. Reuse exact bytes with contentRef ${contentReference.contentRef}.`,
251
- },
252
- ],
253
- details: {
254
- phase: "committed",
255
- contentRef: contentReference.contentRef,
256
- byteCount,
257
- },
258
- };
259
- });
277
+ throw error;
278
+ }
260
279
  },
261
280
  renderCall(args, theme, context) {
262
281
  const renderArgs = args;
@@ -1 +1 @@
1
- {"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAc,MAAM,wCAAwC,CAAC;AAExG,OAAO,EAA6B,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACpG,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,eAAe,GAAG,IAAI,CAAC,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,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;YACjF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACb,MAAM,SAAS,GAAI,OAAO,CAAC,aAAuC,IAAI,IAAI,SAAS,EAAE,CAAC;gBACtF,SAAS,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,OAA0B;IACtE,OAAO,kBAAkB,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import { mkdir as fsMkdir, writeFile as fsWriteFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport { Container, Text } from \"@caupulican/pi-tui\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { type FileContentReference, FileMutationIntentController } from \"./file-mutation-intent.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { normalizeDisplayText, renderToolPath, replaceTabs, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst writePathSchema = Type.String({ minLength: 1 });\nconst writeCommitProperties = {\n\taction: Type.Literal(\"commit\"),\n\tpath: writePathSchema,\n\tintentId: Type.String({ minLength: 1 }),\n};\nconst writeSchema = Type.Union([\n\tType.Object(\n\t\t{\n\t\t\taction: Type.Literal(\"prepare\"),\n\t\t\tpath: writePathSchema,\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n\tType.Object(\n\t\t{\n\t\t\t...writeCommitProperties,\n\t\t\tcontent: Type.String(),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n\tType.Object(\n\t\t{\n\t\t\t...writeCommitProperties,\n\t\t\tcontentRef: Type.String({ minLength: 1 }),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n]);\n\nexport type WriteToolInput = Static<typeof writeSchema>;\n\n/**\n * Pluggable operations for the write tool.\n * Override these to delegate file writing to remote systems (for example SSH).\n */\nexport interface WriteOperations {\n\t/** Atomically create a new file and fail if any entry already occupies the path. */\n\tcreateFile: (absolutePath: string, content: string) => Promise<void>;\n\t/** Create directory recursively */\n\tmkdir: (dir: string) => Promise<void>;\n}\n\nconst defaultWriteOperations: WriteOperations = {\n\tcreateFile: (path, content) => fsWriteFile(path, content, { encoding: \"utf-8\", flag: \"wx\" }),\n\tmkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => {}),\n};\n\nexport interface WriteToolOptions {\n\t/** Custom operations for file writing. Default: local filesystem */\n\toperations?: WriteOperations;\n\t/** Session-owned two-phase intent and exact-content-reference authority. */\n\tintentController?: FileMutationIntentController;\n}\n\nexport interface WriteToolDetails {\n\tphase: \"prepared\" | \"committed\";\n\tintentId?: string;\n\tcontentRef?: string;\n\tbyteCount?: number;\n}\n\ntype WriteHighlightCache = {\n\targsRef: unknown;\n\trawPath: string | null;\n\tcountCompleteLines: boolean;\n\texpanded: boolean;\n\trenderedLines: string[];\n\ttotalLines?: number;\n\tcappedByCharacters: boolean;\n\tcappedByLines: boolean;\n};\n\nclass WriteCallRenderComponent extends Text {\n\tcache?: WriteHighlightCache;\n\n\tconstructor() {\n\t\tsuper(\"\", 0, 0);\n\t}\n}\n\nconst WRITE_COLLAPSED_PREVIEW_LINES = 10;\nconst WRITE_COLLAPSED_PREVIEW_CHARS = 8_192;\n\nfunction countWriteDisplayLines(fileContent: string): number {\n\tlet lastContentIndex = fileContent.length - 1;\n\twhile (lastContentIndex >= 0) {\n\t\tconst code = fileContent.charCodeAt(lastContentIndex);\n\t\tif (code !== 10 && code !== 13) break;\n\t\tlastContentIndex--;\n\t}\n\tif (lastContentIndex < 0) return 0;\n\n\tlet lines = 1;\n\tfor (let i = 0; i <= lastContentIndex; i++) {\n\t\tif (fileContent.charCodeAt(i) === 10) lines++;\n\t}\n\treturn lines;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction buildCollapsedWriteSource(fileContent: string): {\n\tsource: string;\n\tcappedByCharacters: boolean;\n\tcappedByLines: boolean;\n} {\n\tconst rawPrefix = fileContent.slice(0, WRITE_COLLAPSED_PREVIEW_CHARS);\n\tconst normalizedPrefix = replaceTabs(normalizeDisplayText(rawPrefix));\n\tlet end = normalizedPrefix.length;\n\tlet newlineCount = 0;\n\tfor (let i = 0; i < normalizedPrefix.length; i++) {\n\t\tif (normalizedPrefix.charCodeAt(i) !== 10) continue;\n\t\tnewlineCount++;\n\t\tif (newlineCount === WRITE_COLLAPSED_PREVIEW_LINES) {\n\t\t\tend = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tconst cappedByLines = end < normalizedPrefix.length;\n\treturn {\n\t\tsource: normalizedPrefix.slice(0, end),\n\t\tcappedByCharacters: !cappedByLines && rawPrefix.length < fileContent.length,\n\t\tcappedByLines,\n\t};\n}\n\nfunction buildWriteHighlightCache(\n\targsRef: unknown,\n\trawPath: string | null,\n\tfileContent: string,\n\tcountCompleteLines: boolean,\n\texpanded: boolean,\n): WriteHighlightCache {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (expanded) {\n\t\tconst source = replaceTabs(normalizeDisplayText(fileContent));\n\t\tconst renderedLines = trimTrailingEmptyLines(lang ? highlightCode(source, lang) : source.split(\"\\n\"));\n\t\treturn {\n\t\t\targsRef,\n\t\t\trawPath,\n\t\t\tcountCompleteLines,\n\t\t\texpanded,\n\t\t\trenderedLines,\n\t\t\ttotalLines: renderedLines.length,\n\t\t\tcappedByCharacters: false,\n\t\t\tcappedByLines: false,\n\t\t};\n\t}\n\n\tconst preview = buildCollapsedWriteSource(fileContent);\n\tconst renderedLines = trimTrailingEmptyLines(\n\t\tlang ? highlightCode(preview.source, lang) : preview.source.split(\"\\n\"),\n\t);\n\treturn {\n\t\targsRef,\n\t\trawPath,\n\t\tcountCompleteLines,\n\t\texpanded,\n\t\trenderedLines,\n\t\ttotalLines: countCompleteLines ? countWriteDisplayLines(fileContent) : undefined,\n\t\tcappedByCharacters: preview.cappedByCharacters,\n\t\tcappedByLines: preview.cappedByLines,\n\t};\n}\n\nfunction getWriteHighlightCache(\n\tcache: WriteHighlightCache | undefined,\n\targsRef: unknown,\n\trawPath: string | null,\n\tfileContent: string,\n\tcountCompleteLines: boolean,\n\texpanded: boolean,\n): WriteHighlightCache {\n\tif (\n\t\tcache &&\n\t\tcache.argsRef === argsRef &&\n\t\tcache.rawPath === rawPath &&\n\t\tcache.countCompleteLines === countCompleteLines &&\n\t\tcache.expanded === expanded\n\t) {\n\t\treturn cache;\n\t}\n\treturn buildWriteHighlightCache(argsRef, rawPath, fileContent, countCompleteLines, expanded);\n}\n\nfunction formatWriteCall(\n\targs: { action?: string; path?: string; file_path?: string; content?: string; contentRef?: string } | undefined,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tcache: WriteHighlightCache | undefined,\n\tcwd: string,\n): string {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst fileContent = str(args?.content);\n\tconst hasContent = typeof args?.content === \"string\";\n\tconst pathDisplay = renderToolPath(rawPath, theme, cwd);\n\tconst action = args?.action === \"prepare\" ? \"prepare\" : args?.action === \"commit\" ? \"commit\" : undefined;\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"write\"))}${action ? ` ${theme.fg(\"muted\", action)}` : \"\"} ${pathDisplay}`;\n\n\tif (args?.action === \"commit\" && !hasContent && typeof args.contentRef !== \"string\") {\n\t\ttext += `\\n\\n${theme.fg(\"error\", \"[invalid content arg - expected string]\")}`;\n\t} else if (hasContent && fileContent) {\n\t\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\t\tconst displayLines = cache?.renderedLines ?? [];\n\t\ttext += `\\n\\n${displayLines.map((line) => (lang ? line : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\t\tif (!options.expanded && cache && (cache.cappedByCharacters || cache.cappedByLines)) {\n\t\t\tconst total = cache.totalLines;\n\t\t\tif (cache.cappedByCharacters) {\n\t\t\t\tconst totalSuffix = total === undefined ? \"\" : `; ${total} total line${total === 1 ? \"\" : \"s\"}`;\n\t\t\t\ttext += `${theme.fg(\"muted\", `\\n... (preview capped at ${WRITE_COLLAPSED_PREVIEW_CHARS} characters${totalSuffix},`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t\t} else if (total === undefined) {\n\t\t\t\ttext += `${theme.fg(\"muted\", \"\\n... (preview capped,\")} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t\t} else {\n\t\t\t\tconst remaining = Math.max(0, total - displayLines.length);\n\t\t\t\tif (remaining > 0) {\n\t\t\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines, ${total} total,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (args?.contentRef) {\n\t\ttext += `\\n\\n${theme.fg(\"muted\", `reuse ${args.contentRef}`)}`;\n\t}\n\n\treturn text;\n}\n\nfunction formatWriteResult(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }>; isError?: boolean },\n\ttheme: Theme,\n): string | undefined {\n\tif (!result.isError) {\n\t\treturn undefined;\n\t}\n\tconst output = result.content\n\t\t.filter((c) => c.type === \"text\")\n\t\t.map((c) => c.text || \"\")\n\t\t.join(\"\\n\");\n\tif (!output) {\n\t\treturn undefined;\n\t}\n\treturn `\\n${theme.fg(\"error\", output)}`;\n}\n\nexport function createWriteToolDefinition(\n\tcwd: string,\n\toptions?: WriteToolOptions,\n): ToolDefinition<typeof writeSchema, WriteToolDetails> {\n\tconst ops = options?.operations ?? defaultWriteOperations;\n\tif (options?.operations && !options.intentController) {\n\t\tthrow new Error(\"Custom write operations require a matching file mutation intent controller.\");\n\t}\n\tconst intentController = options?.intentController ?? new FileMutationIntentController();\n\treturn {\n\t\tname: \"write\",\n\t\tlabel: \"write\",\n\t\tdescription:\n\t\t\t\"Create a file without overwriting: prepare(path), then commit(path,intentId,content|contentRef). Prepare rejects collisions before content generation; commit rechecks atomically.\",\n\t\tpromptSnippet: \"Preflight new paths; never overwrite\",\n\t\tpromptGuidelines: [\n\t\t\t\"Before content generation, prepare(path); then commit with intentId and one of content or contentRef.\",\n\t\t\t\"Write is create-only; edit existing files. Reuse contentRef for exact copies.\",\n\t\t],\n\t\tparameters: writeSchema,\n\t\tasync execute(_toolCallId, input: WriteToolInput, signal?: AbortSignal, _onUpdate?, _ctx?) {\n\t\t\tconst { path } = input;\n\t\t\tconst absolutePath = resolveToCwd(path, cwd);\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 (input.action === \"prepare\") {\n\t\t\t\t\tconst prepared = await intentController.prepare(\"write\", 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: `Write path 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 content = \"content\" in input && typeof input.content === \"string\" ? input.content : undefined;\n\t\t\t\tconst contentRef =\n\t\t\t\t\t\"contentRef\" in input && typeof input.contentRef === \"string\" ? input.contentRef : undefined;\n\t\t\t\tif ((content === undefined) === (contentRef === undefined)) {\n\t\t\t\t\tthrow new Error(\"Write commit requires exactly one of content or contentRef.\");\n\t\t\t\t}\n\t\t\t\tconst lease = intentController.consume(input.intentId, \"write\", absolutePath);\n\t\t\t\tawait intentController.assertCurrent(lease, signal);\n\t\t\t\tawait ops.mkdir(dirname(absolutePath));\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tlet contentReference: FileContentReference;\n\t\t\t\ttry {\n\t\t\t\t\tif (content !== undefined) {\n\t\t\t\t\t\tawait ops.createFile(absolutePath, content);\n\t\t\t\t\t\tcontentReference = intentController.rememberContent(absolutePath, content);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (contentRef === undefined) throw new Error(\"Write commit requires content or contentRef.\");\n\t\t\t\t\t\tcontentReference = await intentController.copyReferencedContent(contentRef, absolutePath, signal);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"EEXIST\") {\n\t\t\t\t\t\tthrow new Error(`Write collision: ${path} already exists; no content was overwritten.`);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tconst byteCount = contentReference.byteLength;\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `Successfully wrote ${byteCount} bytes to ${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\tbyteCount,\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 renderArgs = args as\n\t\t\t\t| { action?: string; path?: string; file_path?: string; content?: string; contentRef?: string }\n\t\t\t\t| undefined;\n\t\t\tconst rawPath = str(renderArgs?.file_path ?? renderArgs?.path);\n\t\t\tconst fileContent = str(renderArgs?.content);\n\t\t\tconst component =\n\t\t\t\t(context.lastComponent as WriteCallRenderComponent | undefined) ?? new WriteCallRenderComponent();\n\t\t\tif (fileContent !== null) {\n\t\t\t\tcomponent.cache = getWriteHighlightCache(\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t\targs,\n\t\t\t\t\trawPath,\n\t\t\t\t\tfileContent,\n\t\t\t\t\tcontext.argsComplete && !context.toolGroupSummary,\n\t\t\t\t\tcontext.expanded,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcomponent.cache = undefined;\n\t\t\t}\n\t\t\tcomponent.setText(\n\t\t\t\tformatWriteCall(\n\t\t\t\t\trenderArgs,\n\t\t\t\t\t{ expanded: context.expanded, isPartial: context.isPartial },\n\t\t\t\t\ttheme,\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t\tcontext.cwd,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn component;\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst output = formatWriteResult({ ...result, isError: context.isError }, theme);\n\t\t\tif (!output) {\n\t\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\t\tcomponent.clear();\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(output);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createWriteTool(cwd: string, options?: WriteToolOptions): AgentTool<typeof writeSchema> {\n\treturn wrapToolDefinition(createWriteToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAc,MAAM,wCAAwC,CAAC;AAExG,OAAO,EAEN,4BAA4B,EAC5B,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,oBAAoB,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;AACtD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC;IAC9B,IAAI,CAAC,MAAM,CACV;QACC,IAAI,EAAE,eAAe;QAC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AO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,OAA0B;IACtE,OAAO,kBAAkB,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import { mkdir as fsMkdir, writeFile as fsWriteFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport { Container, Text } from \"@caupulican/pi-tui\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport {\n\ttype FileContentReference,\n\tFileMutationIntentController,\n\tFileMutationPreflightError,\n} from \"./file-mutation-intent.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { normalizeDisplayText, renderToolPath, replaceTabs, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst writePathSchema = Type.String({ minLength: 1 });\nconst writeSchema = Type.Union([\n\tType.Object(\n\t\t{\n\t\t\tpath: writePathSchema,\n\t\t\tcontent: Type.String(),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n\tType.Object(\n\t\t{\n\t\t\tpath: writePathSchema,\n\t\t\tcontentRef: Type.String({ minLength: 1 }),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n\tType.Object(\n\t\t{\n\t\t\tpath: writePathSchema,\n\t\t\tpayloadRef: Type.String({ minLength: 1 }),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n]);\n\nexport type WriteToolInput = Static<typeof writeSchema>;\n\n/**\n * Pluggable operations for the write tool.\n * Override these to delegate file writing to remote systems (for example SSH).\n */\nexport interface WriteOperations {\n\t/** Atomically create a new file and fail if any entry already occupies the path. */\n\tcreateFile: (absolutePath: string, content: string) => Promise<void>;\n\t/** Create directory recursively */\n\tmkdir: (dir: string) => Promise<void>;\n}\n\nconst defaultWriteOperations: WriteOperations = {\n\tcreateFile: (path, content) => fsWriteFile(path, content, { encoding: \"utf-8\", flag: \"wx\" }),\n\tmkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => {}),\n};\n\nexport interface WriteToolOptions {\n\t/** Custom operations for file writing. Default: local filesystem */\n\toperations?: WriteOperations;\n\t/** Session-owned harness preflight and exact-content-reference authority. */\n\tintentController?: FileMutationIntentController;\n}\n\nexport interface WriteToolDetails {\n\tphase: \"written\";\n\tcontentRef?: string;\n\tbyteCount?: number;\n}\n\ntype WriteHighlightCache = {\n\targsRef: unknown;\n\trawPath: string | null;\n\tcountCompleteLines: boolean;\n\texpanded: boolean;\n\trenderedLines: string[];\n\ttotalLines?: number;\n\tcappedByCharacters: boolean;\n\tcappedByLines: boolean;\n};\n\nclass WriteCallRenderComponent extends Text {\n\tcache?: WriteHighlightCache;\n\n\tconstructor() {\n\t\tsuper(\"\", 0, 0);\n\t}\n}\n\nconst WRITE_COLLAPSED_PREVIEW_LINES = 10;\nconst WRITE_COLLAPSED_PREVIEW_CHARS = 8_192;\n\nfunction countWriteDisplayLines(fileContent: string): number {\n\tlet lastContentIndex = fileContent.length - 1;\n\twhile (lastContentIndex >= 0) {\n\t\tconst code = fileContent.charCodeAt(lastContentIndex);\n\t\tif (code !== 10 && code !== 13) break;\n\t\tlastContentIndex--;\n\t}\n\tif (lastContentIndex < 0) return 0;\n\n\tlet lines = 1;\n\tfor (let i = 0; i <= lastContentIndex; i++) {\n\t\tif (fileContent.charCodeAt(i) === 10) lines++;\n\t}\n\treturn lines;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction buildCollapsedWriteSource(fileContent: string): {\n\tsource: string;\n\tcappedByCharacters: boolean;\n\tcappedByLines: boolean;\n} {\n\tconst rawPrefix = fileContent.slice(0, WRITE_COLLAPSED_PREVIEW_CHARS);\n\tconst normalizedPrefix = replaceTabs(normalizeDisplayText(rawPrefix));\n\tlet end = normalizedPrefix.length;\n\tlet newlineCount = 0;\n\tfor (let i = 0; i < normalizedPrefix.length; i++) {\n\t\tif (normalizedPrefix.charCodeAt(i) !== 10) continue;\n\t\tnewlineCount++;\n\t\tif (newlineCount === WRITE_COLLAPSED_PREVIEW_LINES) {\n\t\t\tend = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tconst cappedByLines = end < normalizedPrefix.length;\n\treturn {\n\t\tsource: normalizedPrefix.slice(0, end),\n\t\tcappedByCharacters: !cappedByLines && rawPrefix.length < fileContent.length,\n\t\tcappedByLines,\n\t};\n}\n\nfunction buildWriteHighlightCache(\n\targsRef: unknown,\n\trawPath: string | null,\n\tfileContent: string,\n\tcountCompleteLines: boolean,\n\texpanded: boolean,\n): WriteHighlightCache {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (expanded) {\n\t\tconst source = replaceTabs(normalizeDisplayText(fileContent));\n\t\tconst renderedLines = trimTrailingEmptyLines(lang ? highlightCode(source, lang) : source.split(\"\\n\"));\n\t\treturn {\n\t\t\targsRef,\n\t\t\trawPath,\n\t\t\tcountCompleteLines,\n\t\t\texpanded,\n\t\t\trenderedLines,\n\t\t\ttotalLines: renderedLines.length,\n\t\t\tcappedByCharacters: false,\n\t\t\tcappedByLines: false,\n\t\t};\n\t}\n\n\tconst preview = buildCollapsedWriteSource(fileContent);\n\tconst renderedLines = trimTrailingEmptyLines(\n\t\tlang ? highlightCode(preview.source, lang) : preview.source.split(\"\\n\"),\n\t);\n\treturn {\n\t\targsRef,\n\t\trawPath,\n\t\tcountCompleteLines,\n\t\texpanded,\n\t\trenderedLines,\n\t\ttotalLines: countCompleteLines ? countWriteDisplayLines(fileContent) : undefined,\n\t\tcappedByCharacters: preview.cappedByCharacters,\n\t\tcappedByLines: preview.cappedByLines,\n\t};\n}\n\nfunction getWriteHighlightCache(\n\tcache: WriteHighlightCache | undefined,\n\targsRef: unknown,\n\trawPath: string | null,\n\tfileContent: string,\n\tcountCompleteLines: boolean,\n\texpanded: boolean,\n): WriteHighlightCache {\n\tif (\n\t\tcache &&\n\t\tcache.argsRef === argsRef &&\n\t\tcache.rawPath === rawPath &&\n\t\tcache.countCompleteLines === countCompleteLines &&\n\t\tcache.expanded === expanded\n\t) {\n\t\treturn cache;\n\t}\n\treturn buildWriteHighlightCache(argsRef, rawPath, fileContent, countCompleteLines, expanded);\n}\n\nfunction formatWriteCall(\n\targs: { path?: string; file_path?: string; content?: string; contentRef?: string; payloadRef?: string } | undefined,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tcache: WriteHighlightCache | undefined,\n\tcwd: string,\n): string {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst fileContent = str(args?.content);\n\tconst hasContent = typeof args?.content === \"string\";\n\tconst pathDisplay = renderToolPath(rawPath, theme, cwd);\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"write\"))} ${pathDisplay}`;\n\n\tif (!hasContent && typeof args?.contentRef !== \"string\" && typeof args?.payloadRef !== \"string\") {\n\t\ttext += `\\n\\n${theme.fg(\"error\", \"[invalid content arg - expected string]\")}`;\n\t} else if (hasContent && fileContent) {\n\t\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\t\tconst displayLines = cache?.renderedLines ?? [];\n\t\ttext += `\\n\\n${displayLines.map((line) => (lang ? line : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\t\tif (!options.expanded && cache && (cache.cappedByCharacters || cache.cappedByLines)) {\n\t\t\tconst total = cache.totalLines;\n\t\t\tif (cache.cappedByCharacters) {\n\t\t\t\tconst totalSuffix = total === undefined ? \"\" : `; ${total} total line${total === 1 ? \"\" : \"s\"}`;\n\t\t\t\ttext += `${theme.fg(\"muted\", `\\n... (preview capped at ${WRITE_COLLAPSED_PREVIEW_CHARS} characters${totalSuffix},`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t\t} else if (total === undefined) {\n\t\t\t\ttext += `${theme.fg(\"muted\", \"\\n... (preview capped,\")} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t\t} else {\n\t\t\t\tconst remaining = Math.max(0, total - displayLines.length);\n\t\t\t\tif (remaining > 0) {\n\t\t\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines, ${total} total,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (args?.contentRef) {\n\t\ttext += `\\n\\n${theme.fg(\"muted\", `reuse ${args.contentRef}`)}`;\n\t} else if (args?.payloadRef) {\n\t\ttext += `\\n\\n${theme.fg(\"muted\", `retarget ${args.payloadRef}`)}`;\n\t}\n\n\treturn text;\n}\n\nasync function writeCollisionWithRetainedPayload(\n\terror: FileMutationPreflightError,\n\tinput: WriteToolInput,\n\tintentController: FileMutationIntentController,\n\tsignal?: AbortSignal,\n): Promise<Error> {\n\tconst retargetError = (reference: string): Error =>\n\t\tnew Error(\n\t\t\t`PI_FILE_MUTATION_RETARGET write_collision: ${reference}. Choose only a corrected path; the exact valid write payload is retained.`,\n\t\t);\n\tif (\"contentRef\" in input) {\n\t\tawait intentController.assertContentReference(input.contentRef, signal);\n\t\treturn retargetError(`contentRef ${input.contentRef}`);\n\t}\n\tif (\"payloadRef\" in input) {\n\t\tawait intentController.assertMutationPayload(input.payloadRef, \"write\", signal);\n\t\treturn retargetError(`payloadRef ${input.payloadRef}`);\n\t}\n\n\ttry {\n\t\tconst retained = await intentController.retainMutationPayload(\"write\", input.content);\n\t\tif (retained) {\n\t\t\treturn retargetError(`payloadRef ${retained.payloadRef}`);\n\t\t}\n\t} catch {\n\t\t// The collision remains authoritative when the bounded retry cache is unavailable.\n\t}\n\treturn new Error(`${error.message} The payload could not be retained within the secure retry-cache bound.`);\n}\n\nfunction formatWriteResult(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }>; isError?: boolean },\n\ttheme: Theme,\n): string | undefined {\n\tif (!result.isError) {\n\t\treturn undefined;\n\t}\n\tconst output = result.content\n\t\t.filter((c) => c.type === \"text\")\n\t\t.map((c) => c.text || \"\")\n\t\t.join(\"\\n\");\n\tif (!output) {\n\t\treturn undefined;\n\t}\n\treturn `\\n${theme.fg(\"error\", output)}`;\n}\n\nexport function createWriteToolDefinition(\n\tcwd: string,\n\toptions?: WriteToolOptions,\n): ToolDefinition<typeof writeSchema, WriteToolDetails> {\n\tconst ops = options?.operations ?? defaultWriteOperations;\n\tif (options?.operations && !options.intentController) {\n\t\tthrow new Error(\"Custom write operations require a matching file mutation intent controller.\");\n\t}\n\tconst intentController = options?.intentController ?? new FileMutationIntentController();\n\treturn {\n\t\tname: \"write\",\n\t\tlabel: \"write\",\n\t\tdescription:\n\t\t\t\"Create a new file without overwriting. Send path and exactly one of content or contentRef. After a path-only collision, use the returned payloadRef with only a corrected path. The harness owns preflight, bounded payload retention, and atomic rechecks.\",\n\t\tpromptSnippet: \"Preflight new paths; never overwrite\",\n\t\tpromptGuidelines: [\n\t\t\t\"Call write once with path and exactly one of content or contentRef; preparation and collision checks are harness-owned.\",\n\t\t\t\"If a collision result returns payloadRef, choose a new path and reuse that reference instead of regenerating content.\",\n\t\t\t\"Write is create-only; edit existing files. Reuse contentRef for exact copies.\",\n\t\t],\n\t\tparameters: writeSchema,\n\t\tasync execute(_toolCallId, input: WriteToolInput, signal?: AbortSignal, _onUpdate?, _ctx?) {\n\t\t\tconst { path } = input;\n\t\t\tconst absolutePath = resolveToCwd(path, cwd);\n\t\t\tconst content = \"content\" in input && typeof input.content === \"string\" ? input.content : undefined;\n\t\t\tconst contentRef =\n\t\t\t\t\"contentRef\" in input && typeof input.contentRef === \"string\" ? input.contentRef : undefined;\n\t\t\tconst payloadRef =\n\t\t\t\t\"payloadRef\" in input && typeof input.payloadRef === \"string\" ? input.payloadRef : undefined;\n\t\t\tif ([content, contentRef, payloadRef].filter((value) => value !== undefined).length !== 1) {\n\t\t\t\tthrow new Error(\"Write requires exactly one of content, contentRef, or payloadRef.\");\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst lease = await intentController.prepare(\"write\", absolutePath, signal, path);\n\t\t\t\treturn await withFileMutationQueue(absolutePath, async () => {\n\t\t\t\t\t// Do not reject from an abort event listener here: that would release the\n\t\t\t\t\t// mutation queue while an in-flight filesystem operation may still finish.\n\t\t\t\t\t// Checking signal.aborted after each await observes the same aborts while\n\t\t\t\t\t// keeping the queue locked until the current operation has settled.\n\t\t\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t\t};\n\n\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\tawait intentController.assertCurrent(lease, signal);\n\t\t\t\t\tawait ops.mkdir(dirname(absolutePath));\n\t\t\t\t\tthrowIfAborted();\n\n\t\t\t\t\tlet contentReference: FileContentReference;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (content !== undefined) {\n\t\t\t\t\t\t\tawait ops.createFile(absolutePath, content);\n\t\t\t\t\t\t\tcontentReference = intentController.rememberContent(absolutePath, content);\n\t\t\t\t\t\t} else if (contentRef !== undefined) {\n\t\t\t\t\t\t\tcontentReference = await intentController.copyReferencedContent(contentRef, absolutePath, signal);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (payloadRef === undefined) throw new Error(\"Write requires a payload reference.\");\n\t\t\t\t\t\t\tcontentReference = await intentController.copyMutationPayload(payloadRef, absolutePath, signal);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"EEXIST\") {\n\t\t\t\t\t\t\tthrow new FileMutationPreflightError(\n\t\t\t\t\t\t\t\t\"write_collision\",\n\t\t\t\t\t\t\t\t`Write collision: ${path} already exists; no content was overwritten.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t\tthrowIfAborted();\n\n\t\t\t\t\tconst byteCount = contentReference.byteLength;\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: `Successfully wrote ${byteCount} bytes to ${path}; this write is complete, so do not call write 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\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: {\n\t\t\t\t\t\t\tphase: \"written\" as const,\n\t\t\t\t\t\t\tcontentRef: contentReference.contentRef,\n\t\t\t\t\t\t\tbyteCount,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof FileMutationPreflightError && error.reason === \"write_collision\") {\n\t\t\t\t\tthrow await writeCollisionWithRetainedPayload(error, input, intentController, signal);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst renderArgs = args as\n\t\t\t\t| { path?: string; file_path?: string; content?: string; contentRef?: string; payloadRef?: string }\n\t\t\t\t| undefined;\n\t\t\tconst rawPath = str(renderArgs?.file_path ?? renderArgs?.path);\n\t\t\tconst fileContent = str(renderArgs?.content);\n\t\t\tconst component =\n\t\t\t\t(context.lastComponent as WriteCallRenderComponent | undefined) ?? new WriteCallRenderComponent();\n\t\t\tif (fileContent !== null) {\n\t\t\t\tcomponent.cache = getWriteHighlightCache(\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t\targs,\n\t\t\t\t\trawPath,\n\t\t\t\t\tfileContent,\n\t\t\t\t\tcontext.argsComplete && !context.toolGroupSummary,\n\t\t\t\t\tcontext.expanded,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcomponent.cache = undefined;\n\t\t\t}\n\t\t\tcomponent.setText(\n\t\t\t\tformatWriteCall(\n\t\t\t\t\trenderArgs,\n\t\t\t\t\t{ expanded: context.expanded, isPartial: context.isPartial },\n\t\t\t\t\ttheme,\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t\tcontext.cwd,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn component;\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst output = formatWriteResult({ ...result, isError: context.isError }, theme);\n\t\t\tif (!output) {\n\t\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\t\tcomponent.clear();\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(output);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createWriteTool(cwd: string, options?: WriteToolOptions): AgentTool<typeof writeSchema> {\n\treturn wrapToolDefinition(createWriteToolDefinition(cwd, options));\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -31,7 +31,7 @@ export { type CompactionSettings, type DirectoryResourceProfileInfo, getDirector
31
31
  export { formatSkillsForPrompt, type LoadSkillsFromDirOptions, type LoadSkillsResult, loadSkills, loadSkillsFromDir, type Skill, type SkillFrontmatter, } from "./core/skills.ts";
32
32
  export { createSyntheticSourceInfo } from "./core/source-info.ts";
33
33
  export { type AskQuestion, type AskQuestionAnswer, AskQuestionDialog, type AskQuestionStopReason, type AskQuestionToolDetails, type AskQuestionToolInput, type AskQuestionToolOptions, createAskQuestionToolDefinition, } from "./core/tools/ask-question.ts";
34
- export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, createBashToolDefinition, createEditToolDefinition, createFindToolDefinition, createGrepToolDefinition, createLocalBashOperations, createLsToolDefinition, createReadToolDefinition, createSecretStoreToolDefinition, createWriteToolDefinition, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, type FileContentReference, FileMutationIntentController, type FileMutationIntentControllerOptions, type FileMutationIntentOperations, type FileMutationKind, type FileMutationLease, type FilePathIdentity, type FilePathInspection, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, formatSize, type GrepOperations, type GrepToolDetails, type GrepToolInput, type GrepToolOptions, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, type SecretStoreStatus, type SecretStoreToolDetails, type SecretStoreToolInput, type SecretStoreToolOptions, type ToolsOptions, type TruncationOptions, type TruncationResult, truncateHead, truncateLine, truncateTail, type WriteOperations, type WriteToolDetails, type WriteToolInput, type WriteToolOptions, withFileMutationQueue, } from "./core/tools/index.ts";
34
+ export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, createBashToolDefinition, createEditToolDefinition, createFindToolDefinition, createGrepToolDefinition, createLocalBashOperations, createLsToolDefinition, createReadToolDefinition, createSecretStoreToolDefinition, createWriteToolDefinition, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, type FileContentReference, FileMutationIntentController, type FileMutationIntentControllerOptions, type FileMutationIntentOperations, type FileMutationKind, type FileMutationLease, type FileMutationPayloadReference, FileMutationPreflightError, type FileMutationPreflightFailureReason, type FilePathIdentity, type FilePathInspection, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, formatSize, type GrepOperations, type GrepToolDetails, type GrepToolInput, type GrepToolOptions, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, type SecretStoreStatus, type SecretStoreToolDetails, type SecretStoreToolInput, type SecretStoreToolOptions, type ToolsOptions, type TruncationOptions, type TruncationResult, truncateHead, truncateLine, truncateTail, type WriteOperations, type WriteToolDetails, type WriteToolInput, type WriteToolOptions, withFileMutationQueue, } from "./core/tools/index.ts";
35
35
  export { jaccard, runSkillAudit, type SkillAuditReport, type SkillSummary, tokenize, } from "./core/tools/skill-audit.ts";
36
36
  export { hasProjectTrustInputs, type ProjectTrustDecision, ProjectTrustStore } from "./core/trust-manager.ts";
37
37
  export { type MainOptions, main } from "./main.ts";