@code-yeongyu/senpi 2026.6.4 → 2026.6.10-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1190) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/README.md +116 -99
  3. package/dist/bun/cli.d.ts.map +1 -1
  4. package/dist/bun/cli.js.map +1 -1
  5. package/dist/bun/register-bedrock.d.ts.map +1 -1
  6. package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
  7. package/dist/bun/restore-sandbox-env.js.map +1 -1
  8. package/dist/cli/args.d.ts +1 -0
  9. package/dist/cli/args.d.ts.map +1 -1
  10. package/dist/cli/args.js +13 -4
  11. package/dist/cli/args.js.map +1 -1
  12. package/dist/cli/config-selector.d.ts.map +1 -1
  13. package/dist/cli/config-selector.js.map +1 -1
  14. package/dist/cli/file-processor.d.ts.map +1 -1
  15. package/dist/cli/file-processor.js.map +1 -1
  16. package/dist/cli/initial-message.d.ts +1 -1
  17. package/dist/cli/initial-message.d.ts.map +1 -1
  18. package/dist/cli/initial-message.js.map +1 -1
  19. package/dist/cli/list-models.d.ts.map +1 -1
  20. package/dist/cli/list-models.js.map +1 -1
  21. package/dist/cli/project-trust.d.ts +10 -0
  22. package/dist/cli/project-trust.d.ts.map +1 -0
  23. package/dist/cli/project-trust.js +48 -0
  24. package/dist/cli/project-trust.js.map +1 -0
  25. package/dist/cli/session-picker.d.ts.map +1 -1
  26. package/dist/cli/session-picker.js.map +1 -1
  27. package/dist/cli/startup-ui.d.ts +7 -0
  28. package/dist/cli/startup-ui.d.ts.map +1 -0
  29. package/dist/cli/startup-ui.js +59 -0
  30. package/dist/cli/startup-ui.js.map +1 -0
  31. package/dist/cli-main.d.ts.map +1 -1
  32. package/dist/cli-main.js.map +1 -1
  33. package/dist/cli.d.ts.map +1 -1
  34. package/dist/cli.js +10 -1
  35. package/dist/cli.js.map +1 -1
  36. package/dist/config.d.ts.map +1 -1
  37. package/dist/config.js.map +1 -1
  38. package/dist/core/agent-session-runtime.d.ts +3 -1
  39. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  40. package/dist/core/agent-session-runtime.js +4 -9
  41. package/dist/core/agent-session-runtime.js.map +1 -1
  42. package/dist/core/agent-session-services.d.ts +2 -1
  43. package/dist/core/agent-session-services.d.ts.map +1 -1
  44. package/dist/core/agent-session-services.js +2 -2
  45. package/dist/core/agent-session-services.js.map +1 -1
  46. package/dist/core/agent-session.d.ts +33 -0
  47. package/dist/core/agent-session.d.ts.map +1 -1
  48. package/dist/core/agent-session.js +57 -79
  49. package/dist/core/agent-session.js.map +1 -1
  50. package/dist/core/auth-guidance.d.ts.map +1 -1
  51. package/dist/core/auth-guidance.js.map +1 -1
  52. package/dist/core/auth-storage.d.ts +4 -0
  53. package/dist/core/auth-storage.d.ts.map +1 -1
  54. package/dist/core/auth-storage.js +4 -8
  55. package/dist/core/auth-storage.js.map +1 -1
  56. package/dist/core/bash-executor.d.ts.map +1 -1
  57. package/dist/core/bash-executor.js.map +1 -1
  58. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  59. package/dist/core/compaction/branch-summarization.js.map +1 -1
  60. package/dist/core/compaction/compaction.d.ts.map +1 -1
  61. package/dist/core/compaction/compaction.js.map +1 -1
  62. package/dist/core/compaction/index.d.ts.map +1 -1
  63. package/dist/core/compaction/utils.d.ts +1 -1
  64. package/dist/core/compaction/utils.d.ts.map +1 -1
  65. package/dist/core/compaction/utils.js +1 -1
  66. package/dist/core/compaction/utils.js.map +1 -1
  67. package/dist/core/defaults.d.ts.map +1 -1
  68. package/dist/core/diagnostics.d.ts.map +1 -1
  69. package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
  70. package/dist/core/dynamic-prompt/build.js.map +1 -1
  71. package/dist/core/dynamic-prompt/exploration.d.ts.map +1 -1
  72. package/dist/core/dynamic-prompt/exploration.js.map +1 -1
  73. package/dist/core/dynamic-prompt/identity.d.ts.map +1 -1
  74. package/dist/core/dynamic-prompt/identity.js.map +1 -1
  75. package/dist/core/dynamic-prompt/index.d.ts.map +1 -1
  76. package/dist/core/dynamic-prompt/intent-gate.d.ts.map +1 -1
  77. package/dist/core/dynamic-prompt/intent-gate.js.map +1 -1
  78. package/dist/core/dynamic-prompt/parallel-tools.d.ts.map +1 -1
  79. package/dist/core/dynamic-prompt/parallel-tools.js.map +1 -1
  80. package/dist/core/dynamic-prompt/policies.d.ts.map +1 -1
  81. package/dist/core/dynamic-prompt/policies.js.map +1 -1
  82. package/dist/core/dynamic-prompt/style.d.ts.map +1 -1
  83. package/dist/core/dynamic-prompt/style.js.map +1 -1
  84. package/dist/core/dynamic-prompt/tool-categorization.d.ts.map +1 -1
  85. package/dist/core/dynamic-prompt/tool-categorization.js.map +1 -1
  86. package/dist/core/dynamic-prompt/tool-section.d.ts.map +1 -1
  87. package/dist/core/dynamic-prompt/tool-section.js.map +1 -1
  88. package/dist/core/dynamic-prompt/types.d.ts.map +1 -1
  89. package/dist/core/dynamic-prompt/verification.d.ts.map +1 -1
  90. package/dist/core/dynamic-prompt/verification.js.map +1 -1
  91. package/dist/core/event-bus.d.ts.map +1 -1
  92. package/dist/core/event-bus.js.map +1 -1
  93. package/dist/core/exec.d.ts.map +1 -1
  94. package/dist/core/exec.js.map +1 -1
  95. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  96. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  97. package/dist/core/export-html/index.d.ts.map +1 -1
  98. package/dist/core/export-html/index.js.map +1 -1
  99. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  100. package/dist/core/export-html/tool-renderer.js.map +1 -1
  101. package/dist/core/extensions/builtin/anthropic-bash/index.d.ts.map +1 -1
  102. package/dist/core/extensions/builtin/anthropic-bash/index.js.map +1 -1
  103. package/dist/core/extensions/builtin/anthropic-web-search/index.d.ts.map +1 -1
  104. package/dist/core/extensions/builtin/anthropic-web-search/index.js.map +1 -1
  105. package/dist/core/extensions/builtin/bash-timeout/index.d.ts.map +1 -1
  106. package/dist/core/extensions/builtin/bash-timeout/index.js.map +1 -1
  107. package/dist/core/extensions/builtin/bash-timeout/timeout.d.ts.map +1 -1
  108. package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
  109. package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts.map +1 -1
  110. package/dist/core/extensions/builtin/compaction/checkpoint-state.js.map +1 -1
  111. package/dist/core/extensions/builtin/compaction/circuit-breaker.d.ts.map +1 -1
  112. package/dist/core/extensions/builtin/compaction/circuit-breaker.js.map +1 -1
  113. package/dist/core/extensions/builtin/compaction/context-reduction.d.ts.map +1 -1
  114. package/dist/core/extensions/builtin/compaction/context-reduction.js +1 -1
  115. package/dist/core/extensions/builtin/compaction/context-reduction.js.map +1 -1
  116. package/dist/core/extensions/builtin/compaction/degradation-monitor.d.ts +0 -1
  117. package/dist/core/extensions/builtin/compaction/degradation-monitor.d.ts.map +1 -1
  118. package/dist/core/extensions/builtin/compaction/degradation-monitor.js +0 -1
  119. package/dist/core/extensions/builtin/compaction/degradation-monitor.js.map +1 -1
  120. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  121. package/dist/core/extensions/builtin/compaction/index.js +4 -4
  122. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  123. package/dist/core/extensions/builtin/compaction/openai-remote.d.ts.map +1 -1
  124. package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -1
  125. package/dist/core/extensions/builtin/compaction/per-turn-cap.d.ts.map +1 -1
  126. package/dist/core/extensions/builtin/compaction/per-turn-cap.js.map +1 -1
  127. package/dist/core/extensions/builtin/compaction/policy.d.ts +0 -5
  128. package/dist/core/extensions/builtin/compaction/policy.d.ts.map +1 -1
  129. package/dist/core/extensions/builtin/compaction/policy.js +0 -4
  130. package/dist/core/extensions/builtin/compaction/policy.js.map +1 -1
  131. package/dist/core/extensions/builtin/compaction/prompts.d.ts.map +1 -1
  132. package/dist/core/extensions/builtin/compaction/prompts.js.map +1 -1
  133. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts.map +1 -1
  134. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js.map +1 -1
  135. package/dist/core/extensions/builtin/compaction/restoration-tracker.d.ts.map +1 -1
  136. package/dist/core/extensions/builtin/compaction/restoration-tracker.js.map +1 -1
  137. package/dist/core/extensions/builtin/compaction/speculative.d.ts +0 -6
  138. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  139. package/dist/core/extensions/builtin/compaction/speculative.js +0 -3
  140. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  141. package/dist/core/extensions/builtin/compaction/state.d.ts.map +1 -1
  142. package/dist/core/extensions/builtin/compaction/state.js.map +1 -1
  143. package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts.map +1 -1
  144. package/dist/core/extensions/builtin/compaction/todo-bridge.js.map +1 -1
  145. package/dist/core/extensions/builtin/compaction/tool-truncation.d.ts.map +1 -1
  146. package/dist/core/extensions/builtin/compaction/tool-truncation.js.map +1 -1
  147. package/dist/core/extensions/builtin/diff.d.ts.map +1 -1
  148. package/dist/core/extensions/builtin/diff.js.map +1 -1
  149. package/dist/core/extensions/builtin/files.d.ts.map +1 -1
  150. package/dist/core/extensions/builtin/files.js.map +1 -1
  151. package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts.map +1 -1
  152. package/dist/core/extensions/builtin/gpt-apply-patch/apply.js.map +1 -1
  153. package/dist/core/extensions/builtin/gpt-apply-patch/constants.d.ts.map +1 -1
  154. package/dist/core/extensions/builtin/gpt-apply-patch/constants.js.map +1 -1
  155. package/dist/core/extensions/builtin/gpt-apply-patch/errors.d.ts.map +1 -1
  156. package/dist/core/extensions/builtin/gpt-apply-patch/errors.js +0 -2
  157. package/dist/core/extensions/builtin/gpt-apply-patch/errors.js.map +1 -1
  158. package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts +1 -1
  159. package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts.map +1 -1
  160. package/dist/core/extensions/builtin/gpt-apply-patch/extension.js +10 -2
  161. package/dist/core/extensions/builtin/gpt-apply-patch/extension.js.map +1 -1
  162. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts.map +1 -1
  163. package/dist/core/extensions/builtin/gpt-apply-patch/params.d.ts.map +1 -1
  164. package/dist/core/extensions/builtin/gpt-apply-patch/params.js.map +1 -1
  165. package/dist/core/extensions/builtin/gpt-apply-patch/parser.d.ts.map +1 -1
  166. package/dist/core/extensions/builtin/gpt-apply-patch/parser.js.map +1 -1
  167. package/dist/core/extensions/builtin/gpt-apply-patch/patch-diff.d.ts.map +1 -1
  168. package/dist/core/extensions/builtin/gpt-apply-patch/patch-diff.js.map +1 -1
  169. package/dist/core/extensions/builtin/gpt-apply-patch/patch-replace.d.ts.map +1 -1
  170. package/dist/core/extensions/builtin/gpt-apply-patch/patch-replace.js.map +1 -1
  171. package/dist/core/extensions/builtin/gpt-apply-patch/preview-format.d.ts.map +1 -1
  172. package/dist/core/extensions/builtin/gpt-apply-patch/preview-format.js.map +1 -1
  173. package/dist/core/extensions/builtin/gpt-apply-patch/preview.d.ts.map +1 -1
  174. package/dist/core/extensions/builtin/gpt-apply-patch/preview.js.map +1 -1
  175. package/dist/core/extensions/builtin/gpt-apply-patch/seek-sequence.d.ts.map +1 -1
  176. package/dist/core/extensions/builtin/gpt-apply-patch/seek-sequence.js.map +1 -1
  177. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.d.ts.map +1 -1
  178. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.js +7 -5
  179. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.js.map +1 -1
  180. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-render.d.ts.map +1 -1
  181. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-render.js.map +1 -1
  182. package/dist/core/extensions/builtin/gpt-apply-patch/text.d.ts.map +1 -1
  183. package/dist/core/extensions/builtin/gpt-apply-patch/text.js.map +1 -1
  184. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts.map +1 -1
  185. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
  186. package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts.map +1 -1
  187. package/dist/core/extensions/builtin/gpt-apply-patch/workspace.d.ts.map +1 -1
  188. package/dist/core/extensions/builtin/gpt-apply-patch/workspace.js.map +1 -1
  189. package/dist/core/extensions/builtin/history-search/filter.d.ts.map +1 -1
  190. package/dist/core/extensions/builtin/history-search/filter.js.map +1 -1
  191. package/dist/core/extensions/builtin/history-search/index.d.ts.map +1 -1
  192. package/dist/core/extensions/builtin/history-search/index.js.map +1 -1
  193. package/dist/core/extensions/builtin/history-search/indexer.d.ts.map +1 -1
  194. package/dist/core/extensions/builtin/history-search/indexer.js.map +1 -1
  195. package/dist/core/extensions/builtin/history-search/overlay.d.ts.map +1 -1
  196. package/dist/core/extensions/builtin/history-search/overlay.js +3 -6
  197. package/dist/core/extensions/builtin/history-search/overlay.js.map +1 -1
  198. package/dist/core/extensions/builtin/history-search/types.d.ts.map +1 -1
  199. package/dist/core/extensions/builtin/index.d.ts.map +1 -1
  200. package/dist/core/extensions/builtin/kimi-web-search/index.d.ts.map +1 -1
  201. package/dist/core/extensions/builtin/kimi-web-search/index.js.map +1 -1
  202. package/dist/core/extensions/builtin/openai-web-search/index.d.ts.map +1 -1
  203. package/dist/core/extensions/builtin/openai-web-search/index.js.map +1 -1
  204. package/dist/core/extensions/builtin/permission-system/arity.d.ts.map +1 -1
  205. package/dist/core/extensions/builtin/permission-system/arity.js.map +1 -1
  206. package/dist/core/extensions/builtin/permission-system/cli.d.ts +0 -3
  207. package/dist/core/extensions/builtin/permission-system/cli.d.ts.map +1 -1
  208. package/dist/core/extensions/builtin/permission-system/cli.js +0 -13
  209. package/dist/core/extensions/builtin/permission-system/cli.js.map +1 -1
  210. package/dist/core/extensions/builtin/permission-system/config.d.ts.map +1 -1
  211. package/dist/core/extensions/builtin/permission-system/config.js.map +1 -1
  212. package/dist/core/extensions/builtin/permission-system/evaluate.d.ts.map +1 -1
  213. package/dist/core/extensions/builtin/permission-system/evaluate.js.map +1 -1
  214. package/dist/core/extensions/builtin/permission-system/events.d.ts.map +1 -1
  215. package/dist/core/extensions/builtin/permission-system/events.js.map +1 -1
  216. package/dist/core/extensions/builtin/permission-system/external-dir.d.ts.map +1 -1
  217. package/dist/core/extensions/builtin/permission-system/external-dir.js.map +1 -1
  218. package/dist/core/extensions/builtin/permission-system/index.d.ts.map +1 -1
  219. package/dist/core/extensions/builtin/permission-system/index.js.map +1 -1
  220. package/dist/core/extensions/builtin/permission-system/non-interactive.d.ts.map +1 -1
  221. package/dist/core/extensions/builtin/permission-system/non-interactive.js.map +1 -1
  222. package/dist/core/extensions/builtin/permission-system/parsers.d.ts.map +1 -1
  223. package/dist/core/extensions/builtin/permission-system/parsers.js +3 -1
  224. package/dist/core/extensions/builtin/permission-system/parsers.js.map +1 -1
  225. package/dist/core/extensions/builtin/permission-system/prompt.d.ts.map +1 -1
  226. package/dist/core/extensions/builtin/permission-system/prompt.js.map +1 -1
  227. package/dist/core/extensions/builtin/permission-system/service.d.ts.map +1 -1
  228. package/dist/core/extensions/builtin/permission-system/service.js +2 -5
  229. package/dist/core/extensions/builtin/permission-system/service.js.map +1 -1
  230. package/dist/core/extensions/builtin/permission-system/settings.d.ts.map +1 -1
  231. package/dist/core/extensions/builtin/permission-system/settings.js.map +1 -1
  232. package/dist/core/extensions/builtin/permission-system/storage.d.ts.map +1 -1
  233. package/dist/core/extensions/builtin/permission-system/storage.js.map +1 -1
  234. package/dist/core/extensions/builtin/permission-system/types.d.ts.map +1 -1
  235. package/dist/core/extensions/builtin/permission-system/types.js +3 -5
  236. package/dist/core/extensions/builtin/permission-system/types.js.map +1 -1
  237. package/dist/core/extensions/builtin/permission-system/wildcard.d.ts.map +1 -1
  238. package/dist/core/extensions/builtin/permission-system/wildcard.js.map +1 -1
  239. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts.map +1 -1
  240. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js.map +1 -1
  241. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts.map +1 -1
  242. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js.map +1 -1
  243. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts.map +1 -1
  244. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js.map +1 -1
  245. package/dist/core/extensions/builtin/prompt-preset/file-operations.d.ts.map +1 -1
  246. package/dist/core/extensions/builtin/prompt-preset/file-operations.js.map +1 -1
  247. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.d.ts.map +1 -1
  248. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js.map +1 -1
  249. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.d.ts.map +1 -1
  250. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js.map +1 -1
  251. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.d.ts.map +1 -1
  252. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js.map +1 -1
  253. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.d.ts.map +1 -1
  254. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
  255. package/dist/core/extensions/builtin/prompt-preset/gpt-5.d.ts.map +1 -1
  256. package/dist/core/extensions/builtin/prompt-preset/gpt-5.js.map +1 -1
  257. package/dist/core/extensions/builtin/prompt-preset/index.d.ts.map +1 -1
  258. package/dist/core/extensions/builtin/prompt-preset/index.js.map +1 -1
  259. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.d.ts.map +1 -1
  260. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js.map +1 -1
  261. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
  262. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
  263. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
  264. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
  265. package/dist/core/extensions/builtin/prompt-url-widget.d.ts.map +1 -1
  266. package/dist/core/extensions/builtin/prompt-url-widget.js.map +1 -1
  267. package/dist/core/extensions/builtin/redraws.d.ts.map +1 -1
  268. package/dist/core/extensions/builtin/redraws.js.map +1 -1
  269. package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
  270. package/dist/core/extensions/builtin/service-tier.js.map +1 -1
  271. package/dist/core/extensions/builtin/session-observer/index.d.ts.map +1 -1
  272. package/dist/core/extensions/builtin/session-observer/index.js.map +1 -1
  273. package/dist/core/extensions/builtin/session-observer/loader.d.ts.map +1 -1
  274. package/dist/core/extensions/builtin/session-observer/loader.js.map +1 -1
  275. package/dist/core/extensions/builtin/session-observer/overlay-format.d.ts.map +1 -1
  276. package/dist/core/extensions/builtin/session-observer/overlay-format.js.map +1 -1
  277. package/dist/core/extensions/builtin/session-observer/overlay.d.ts.map +1 -1
  278. package/dist/core/extensions/builtin/session-observer/overlay.js +13 -18
  279. package/dist/core/extensions/builtin/session-observer/overlay.js.map +1 -1
  280. package/dist/core/extensions/builtin/session-observer/scanner.d.ts.map +1 -1
  281. package/dist/core/extensions/builtin/session-observer/scanner.js.map +1 -1
  282. package/dist/core/extensions/builtin/session-observer/text.d.ts.map +1 -1
  283. package/dist/core/extensions/builtin/session-observer/text.js.map +1 -1
  284. package/dist/core/extensions/builtin/session-observer/transcript-entries.d.ts.map +1 -1
  285. package/dist/core/extensions/builtin/session-observer/transcript-entries.js.map +1 -1
  286. package/dist/core/extensions/builtin/session-observer/transcript-format.d.ts.map +1 -1
  287. package/dist/core/extensions/builtin/session-observer/transcript-format.js.map +1 -1
  288. package/dist/core/extensions/builtin/session-observer/transcript.d.ts.map +1 -1
  289. package/dist/core/extensions/builtin/session-observer/transcript.js.map +1 -1
  290. package/dist/core/extensions/builtin/session-observer/types.d.ts.map +1 -1
  291. package/dist/core/extensions/builtin/todotools/index.d.ts.map +1 -1
  292. package/dist/core/extensions/builtin/todotools/index.js +0 -2
  293. package/dist/core/extensions/builtin/todotools/index.js.map +1 -1
  294. package/dist/core/extensions/builtin/todotools/prompt.d.ts +1 -1
  295. package/dist/core/extensions/builtin/todotools/prompt.d.ts.map +1 -1
  296. package/dist/core/extensions/builtin/todotools/prompt.js +0 -2
  297. package/dist/core/extensions/builtin/todotools/prompt.js.map +1 -1
  298. package/dist/core/extensions/builtin/todotools/state.d.ts.map +1 -1
  299. package/dist/core/extensions/builtin/todotools/state.js.map +1 -1
  300. package/dist/core/extensions/builtin/todotools/tools/todoread.d.ts.map +1 -1
  301. package/dist/core/extensions/builtin/todotools/tools/todoread.js.map +1 -1
  302. package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts.map +1 -1
  303. package/dist/core/extensions/builtin/todotools/tools/todowrite.js.map +1 -1
  304. package/dist/core/extensions/builtin/tool-pair-guard/index.d.ts.map +1 -1
  305. package/dist/core/extensions/builtin/tool-pair-guard/index.js.map +1 -1
  306. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts.map +1 -1
  307. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js.map +1 -1
  308. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-chat-completions-payload.d.ts.map +1 -1
  309. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-chat-completions-payload.js.map +1 -1
  310. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-responses-payload.d.ts.map +1 -1
  311. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-responses-payload.js.map +1 -1
  312. package/dist/core/extensions/builtin/tps.d.ts.map +1 -1
  313. package/dist/core/extensions/builtin/tps.js.map +1 -1
  314. package/dist/core/extensions/index.d.ts +1 -1
  315. package/dist/core/extensions/index.d.ts.map +1 -1
  316. package/dist/core/extensions/index.js.map +1 -1
  317. package/dist/core/extensions/loader.d.ts +1 -1
  318. package/dist/core/extensions/loader.d.ts.map +1 -1
  319. package/dist/core/extensions/loader.js +4 -4
  320. package/dist/core/extensions/loader.js.map +1 -1
  321. package/dist/core/extensions/runner.d.ts +7 -2
  322. package/dist/core/extensions/runner.d.ts.map +1 -1
  323. package/dist/core/extensions/runner.js +69 -43
  324. package/dist/core/extensions/runner.js.map +1 -1
  325. package/dist/core/extensions/types.d.ts +22 -2
  326. package/dist/core/extensions/types.d.ts.map +1 -1
  327. package/dist/core/extensions/types.js.map +1 -1
  328. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  329. package/dist/core/extensions/wrapper.js.map +1 -1
  330. package/dist/core/footer-data-provider.d.ts.map +1 -1
  331. package/dist/core/footer-data-provider.js +17 -18
  332. package/dist/core/footer-data-provider.js.map +1 -1
  333. package/dist/core/http-dispatcher.d.ts.map +1 -1
  334. package/dist/core/http-dispatcher.js.map +1 -1
  335. package/dist/core/keybindings.d.ts +1 -1
  336. package/dist/core/keybindings.d.ts.map +1 -1
  337. package/dist/core/keybindings.js +0 -1
  338. package/dist/core/keybindings.js.map +1 -1
  339. package/dist/core/messages.d.ts.map +1 -1
  340. package/dist/core/messages.js.map +1 -1
  341. package/dist/core/model-registry.d.ts +3 -4
  342. package/dist/core/model-registry.d.ts.map +1 -1
  343. package/dist/core/model-registry.js +31 -16
  344. package/dist/core/model-registry.js.map +1 -1
  345. package/dist/core/model-resolver.d.ts.map +1 -1
  346. package/dist/core/model-resolver.js.map +1 -1
  347. package/dist/core/output-guard.d.ts.map +1 -1
  348. package/dist/core/output-guard.js.map +1 -1
  349. package/dist/core/package-manager.d.ts +1 -0
  350. package/dist/core/package-manager.d.ts.map +1 -1
  351. package/dist/core/package-manager.js +25 -13
  352. package/dist/core/package-manager.js.map +1 -1
  353. package/dist/core/project-trust.d.ts +15 -0
  354. package/dist/core/project-trust.d.ts.map +1 -0
  355. package/dist/core/project-trust.js +58 -0
  356. package/dist/core/project-trust.js.map +1 -0
  357. package/dist/core/prompt-templates.d.ts +2 -1
  358. package/dist/core/prompt-templates.d.ts.map +1 -1
  359. package/dist/core/prompt-templates.js +24 -26
  360. package/dist/core/prompt-templates.js.map +1 -1
  361. package/dist/core/provider-attribution.d.ts.map +1 -1
  362. package/dist/core/provider-attribution.js.map +1 -1
  363. package/dist/core/provider-display-names.d.ts.map +1 -1
  364. package/dist/core/resolve-config-value.d.ts +0 -4
  365. package/dist/core/resolve-config-value.d.ts.map +1 -1
  366. package/dist/core/resolve-config-value.js +0 -15
  367. package/dist/core/resolve-config-value.js.map +1 -1
  368. package/dist/core/resource-loader.d.ts +14 -2
  369. package/dist/core/resource-loader.d.ts.map +1 -1
  370. package/dist/core/resource-loader.js +117 -74
  371. package/dist/core/resource-loader.js.map +1 -1
  372. package/dist/core/sdk.d.ts.map +1 -1
  373. package/dist/core/sdk.js.map +1 -1
  374. package/dist/core/session-cwd.d.ts.map +1 -1
  375. package/dist/core/session-cwd.js +0 -1
  376. package/dist/core/session-cwd.js.map +1 -1
  377. package/dist/core/session-manager.d.ts +3 -0
  378. package/dist/core/session-manager.d.ts.map +1 -1
  379. package/dist/core/session-manager.js +41 -28
  380. package/dist/core/session-manager.js.map +1 -1
  381. package/dist/core/session-resident-store.d.ts +16 -0
  382. package/dist/core/session-resident-store.d.ts.map +1 -0
  383. package/dist/core/session-resident-store.js +48 -0
  384. package/dist/core/session-resident-store.js.map +1 -0
  385. package/dist/core/session-work-barrier.d.ts.map +1 -1
  386. package/dist/core/session-work-barrier.js +5 -3
  387. package/dist/core/session-work-barrier.js.map +1 -1
  388. package/dist/core/settings-manager.d.ts +14 -2
  389. package/dist/core/settings-manager.d.ts.map +1 -1
  390. package/dist/core/settings-manager.js +86 -46
  391. package/dist/core/settings-manager.js.map +1 -1
  392. package/dist/core/skills.d.ts.map +1 -1
  393. package/dist/core/skills.js.map +1 -1
  394. package/dist/core/slash-commands.d.ts.map +1 -1
  395. package/dist/core/slash-commands.js +1 -0
  396. package/dist/core/slash-commands.js.map +1 -1
  397. package/dist/core/source-info.d.ts.map +1 -1
  398. package/dist/core/source-info.js.map +1 -1
  399. package/dist/core/system-prompt.d.ts.map +1 -1
  400. package/dist/core/system-prompt.js.map +1 -1
  401. package/dist/core/telemetry.d.ts.map +1 -1
  402. package/dist/core/telemetry.js.map +1 -1
  403. package/dist/core/thinking-levels.d.ts.map +1 -1
  404. package/dist/core/thinking-levels.js.map +1 -1
  405. package/dist/core/timings.d.ts.map +1 -1
  406. package/dist/core/timings.js.map +1 -1
  407. package/dist/core/tools/bash.d.ts.map +1 -1
  408. package/dist/core/tools/bash.js +9 -6
  409. package/dist/core/tools/bash.js.map +1 -1
  410. package/dist/core/tools/diff-render.d.ts.map +1 -1
  411. package/dist/core/tools/diff-render.js.map +1 -1
  412. package/dist/core/tools/edit-diff.d.ts +0 -5
  413. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  414. package/dist/core/tools/edit-diff.js +0 -7
  415. package/dist/core/tools/edit-diff.js.map +1 -1
  416. package/dist/core/tools/edit.d.ts.map +1 -1
  417. package/dist/core/tools/edit.js.map +1 -1
  418. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  419. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  420. package/dist/core/tools/find.d.ts.map +1 -1
  421. package/dist/core/tools/find.js +1 -1
  422. package/dist/core/tools/find.js.map +1 -1
  423. package/dist/core/tools/grep.d.ts.map +1 -1
  424. package/dist/core/tools/grep.js +1 -1
  425. package/dist/core/tools/grep.js.map +1 -1
  426. package/dist/core/tools/index.d.ts +0 -5
  427. package/dist/core/tools/index.d.ts.map +1 -1
  428. package/dist/core/tools/index.js +0 -67
  429. package/dist/core/tools/index.js.map +1 -1
  430. package/dist/core/tools/ls.d.ts.map +1 -1
  431. package/dist/core/tools/ls.js +1 -1
  432. package/dist/core/tools/ls.js.map +1 -1
  433. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  434. package/dist/core/tools/output-accumulator.js +12 -18
  435. package/dist/core/tools/output-accumulator.js.map +1 -1
  436. package/dist/core/tools/path-utils.d.ts.map +1 -1
  437. package/dist/core/tools/path-utils.js.map +1 -1
  438. package/dist/core/tools/read.d.ts.map +1 -1
  439. package/dist/core/tools/read.js +1 -1
  440. package/dist/core/tools/read.js.map +1 -1
  441. package/dist/core/tools/render-utils.d.ts.map +1 -1
  442. package/dist/core/tools/render-utils.js.map +1 -1
  443. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  444. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  445. package/dist/core/tools/truncate.d.ts.map +1 -1
  446. package/dist/core/tools/truncate.js.map +1 -1
  447. package/dist/core/tools/write.d.ts.map +1 -1
  448. package/dist/core/tools/write.js +1 -2
  449. package/dist/core/tools/write.js.map +1 -1
  450. package/dist/core/trust-manager.d.ts +31 -0
  451. package/dist/core/trust-manager.d.ts.map +1 -0
  452. package/dist/core/trust-manager.js +186 -0
  453. package/dist/core/trust-manager.js.map +1 -0
  454. package/dist/index.d.ts +5 -4
  455. package/dist/index.d.ts.map +1 -1
  456. package/dist/index.js +2 -1
  457. package/dist/index.js.map +1 -1
  458. package/dist/main.d.ts.map +1 -1
  459. package/dist/main.js +101 -86
  460. package/dist/main.js.map +1 -1
  461. package/dist/migrations.d.ts.map +1 -1
  462. package/dist/migrations.js +39 -34
  463. package/dist/migrations.js.map +1 -1
  464. package/dist/modes/index.d.ts +1 -1
  465. package/dist/modes/index.d.ts.map +1 -1
  466. package/dist/modes/index.js.map +1 -1
  467. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  468. package/dist/modes/interactive/components/armin.js +6 -10
  469. package/dist/modes/interactive/components/armin.js.map +1 -1
  470. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  471. package/dist/modes/interactive/components/assistant-message.js +2 -11
  472. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  473. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  474. package/dist/modes/interactive/components/bash-execution.js +6 -11
  475. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  476. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  477. package/dist/modes/interactive/components/bordered-loader.js +0 -3
  478. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  479. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  480. package/dist/modes/interactive/components/branch-summary-message.js +1 -3
  481. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  482. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  483. package/dist/modes/interactive/components/compaction-summary-message.js +1 -3
  484. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  485. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  486. package/dist/modes/interactive/components/config-selector.js +5 -15
  487. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  488. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  489. package/dist/modes/interactive/components/countdown-timer.js +0 -5
  490. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  491. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  492. package/dist/modes/interactive/components/custom-editor.js +1 -8
  493. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  494. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  495. package/dist/modes/interactive/components/custom-message.js +1 -6
  496. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  497. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  498. package/dist/modes/interactive/components/daxnuts.js +6 -8
  499. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  500. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  501. package/dist/modes/interactive/components/diff.js +2 -2
  502. package/dist/modes/interactive/components/diff.js.map +1 -1
  503. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  504. package/dist/modes/interactive/components/dynamic-border.js +0 -1
  505. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  506. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  507. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  508. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  509. package/dist/modes/interactive/components/extension-editor.js +1 -6
  510. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  511. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  512. package/dist/modes/interactive/components/extension-input.js +2 -8
  513. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  514. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  515. package/dist/modes/interactive/components/extension-selector.js +1 -9
  516. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  517. package/dist/modes/interactive/components/favorite-models-selector.d.ts.map +1 -1
  518. package/dist/modes/interactive/components/favorite-models-selector.js +9 -15
  519. package/dist/modes/interactive/components/favorite-models-selector.js.map +1 -1
  520. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  521. package/dist/modes/interactive/components/footer.js +10 -3
  522. package/dist/modes/interactive/components/footer.js.map +1 -1
  523. package/dist/modes/interactive/components/index.d.ts +1 -0
  524. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  525. package/dist/modes/interactive/components/index.js +1 -0
  526. package/dist/modes/interactive/components/index.js.map +1 -1
  527. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  528. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  529. package/dist/modes/interactive/components/login-dialog.d.ts +1 -0
  530. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  531. package/dist/modes/interactive/components/login-dialog.js +10 -10
  532. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  533. package/dist/modes/interactive/components/model-favorites.d.ts.map +1 -1
  534. package/dist/modes/interactive/components/model-favorites.js.map +1 -1
  535. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  536. package/dist/modes/interactive/components/model-selector.js +9 -22
  537. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  538. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  539. package/dist/modes/interactive/components/oauth-selector.js +3 -12
  540. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  541. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  542. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  543. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  544. package/dist/modes/interactive/components/session-selector.js +33 -58
  545. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  546. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  547. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  548. package/dist/modes/interactive/components/settings-selector.js +20 -4
  549. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  550. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  551. package/dist/modes/interactive/components/show-images-selector.js +0 -1
  552. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  553. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  554. package/dist/modes/interactive/components/skill-invocation-message.js +1 -3
  555. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  556. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  557. package/dist/modes/interactive/components/theme-selector.js +0 -2
  558. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  559. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  560. package/dist/modes/interactive/components/thinking-selector.js +0 -1
  561. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  562. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  563. package/dist/modes/interactive/components/tool-execution.js +35 -32
  564. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  565. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  566. package/dist/modes/interactive/components/tree-selector.js +18 -32
  567. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  568. package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
  569. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
  570. package/dist/modes/interactive/components/trust-selector.js +85 -0
  571. package/dist/modes/interactive/components/trust-selector.js.map +1 -0
  572. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  573. package/dist/modes/interactive/components/user-message-selector.js +3 -6
  574. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  575. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  576. package/dist/modes/interactive/components/user-message.js +0 -1
  577. package/dist/modes/interactive/components/user-message.js.map +1 -1
  578. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  579. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  580. package/dist/modes/interactive/interactive-mode.d.ts +39 -0
  581. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  582. package/dist/modes/interactive/interactive-mode.js +264 -114
  583. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  584. package/dist/modes/interactive/session-info-format.d.ts.map +1 -1
  585. package/dist/modes/interactive/session-info-format.js.map +1 -1
  586. package/dist/modes/interactive/startup-tools.d.ts.map +1 -1
  587. package/dist/modes/interactive/startup-tools.js.map +1 -1
  588. package/dist/modes/interactive/theme/theme.d.ts +0 -4
  589. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  590. package/dist/modes/interactive/theme/theme.js +0 -13
  591. package/dist/modes/interactive/theme/theme.js.map +1 -1
  592. package/dist/modes/interactive/working-status.d.ts +2 -0
  593. package/dist/modes/interactive/working-status.d.ts.map +1 -1
  594. package/dist/modes/interactive/working-status.js +34 -0
  595. package/dist/modes/interactive/working-status.js.map +1 -1
  596. package/dist/modes/print-mode.d.ts.map +1 -1
  597. package/dist/modes/print-mode.js.map +1 -1
  598. package/dist/modes/provider-native-rendering.d.ts.map +1 -1
  599. package/dist/modes/provider-native-rendering.js.map +1 -1
  600. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  601. package/dist/modes/rpc/jsonl.js.map +1 -1
  602. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  603. package/dist/modes/rpc/rpc-client.js +7 -8
  604. package/dist/modes/rpc/rpc-client.js.map +1 -1
  605. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  606. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  607. package/dist/modes/rpc/rpc-types.d.ts +0 -1
  608. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  609. package/dist/modes/rpc/rpc-types.js.map +1 -1
  610. package/dist/package-manager-cli.d.ts +6 -2
  611. package/dist/package-manager-cli.d.ts.map +1 -1
  612. package/dist/package-manager-cli.js +105 -11
  613. package/dist/package-manager-cli.js.map +1 -1
  614. package/dist/self-update-bootstrap.d.ts.map +1 -1
  615. package/dist/self-update-bootstrap.js.map +1 -1
  616. package/dist/senpi +10 -1
  617. package/dist/utils/ansi.d.ts.map +1 -1
  618. package/dist/utils/ansi.js.map +1 -1
  619. package/dist/utils/changelog.d.ts +1 -0
  620. package/dist/utils/changelog.d.ts.map +1 -1
  621. package/dist/utils/changelog.js +78 -0
  622. package/dist/utils/changelog.js.map +1 -1
  623. package/dist/utils/child-process.d.ts.map +1 -1
  624. package/dist/utils/child-process.js.map +1 -1
  625. package/dist/utils/clipboard-image.d.ts.map +1 -1
  626. package/dist/utils/clipboard-image.js.map +1 -1
  627. package/dist/utils/clipboard-native.d.ts.map +1 -1
  628. package/dist/utils/clipboard-native.js.map +1 -1
  629. package/dist/utils/clipboard.d.ts.map +1 -1
  630. package/dist/utils/clipboard.js.map +1 -1
  631. package/dist/utils/deprecation.d.ts.map +1 -1
  632. package/dist/utils/deprecation.js.map +1 -1
  633. package/dist/utils/exif-orientation.d.ts.map +1 -1
  634. package/dist/utils/exif-orientation.js.map +1 -1
  635. package/dist/utils/frontmatter.d.ts.map +1 -1
  636. package/dist/utils/frontmatter.js.map +1 -1
  637. package/dist/utils/fs-watch.d.ts.map +1 -1
  638. package/dist/utils/fs-watch.js.map +1 -1
  639. package/dist/utils/git.d.ts.map +1 -1
  640. package/dist/utils/git.js.map +1 -1
  641. package/dist/utils/html.d.ts.map +1 -1
  642. package/dist/utils/html.js.map +1 -1
  643. package/dist/utils/image-convert.d.ts.map +1 -1
  644. package/dist/utils/image-convert.js.map +1 -1
  645. package/dist/utils/image-resize-core.d.ts.map +1 -1
  646. package/dist/utils/image-resize-core.js.map +1 -1
  647. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  648. package/dist/utils/image-resize-worker.js.map +1 -1
  649. package/dist/utils/image-resize.d.ts.map +1 -1
  650. package/dist/utils/image-resize.js.map +1 -1
  651. package/dist/utils/json.d.ts.map +1 -1
  652. package/dist/utils/json.js.map +1 -1
  653. package/dist/utils/mime.d.ts.map +1 -1
  654. package/dist/utils/mime.js.map +1 -1
  655. package/dist/utils/open-browser.d.ts.map +1 -1
  656. package/dist/utils/open-browser.js.map +1 -1
  657. package/dist/utils/paths.d.ts.map +1 -1
  658. package/dist/utils/paths.js.map +1 -1
  659. package/dist/utils/photon.d.ts.map +1 -1
  660. package/dist/utils/photon.js.map +1 -1
  661. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  662. package/dist/utils/pi-user-agent.js.map +1 -1
  663. package/dist/utils/shell.d.ts.map +1 -1
  664. package/dist/utils/shell.js.map +1 -1
  665. package/dist/utils/sleep.d.ts.map +1 -1
  666. package/dist/utils/sleep.js.map +1 -1
  667. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  668. package/dist/utils/syntax-highlight.js.map +1 -1
  669. package/dist/utils/tools-manager.d.ts.map +1 -1
  670. package/dist/utils/tools-manager.js.map +1 -1
  671. package/dist/utils/version-check.d.ts.map +1 -1
  672. package/dist/utils/version-check.js.map +1 -1
  673. package/dist/utils/windows-self-update.d.ts.map +1 -1
  674. package/dist/utils/windows-self-update.js.map +1 -1
  675. package/docs/compaction-guide.md +9 -9
  676. package/docs/compaction.md +2 -2
  677. package/docs/containerization.md +22 -22
  678. package/docs/custom-provider.md +13 -13
  679. package/docs/development.md +4 -2
  680. package/docs/docs.json +4 -0
  681. package/docs/extensions.md +46 -18
  682. package/docs/index.md +5 -4
  683. package/docs/json.md +21 -15
  684. package/docs/keybindings.md +6 -3
  685. package/docs/models.md +10 -43
  686. package/docs/packages.md +12 -12
  687. package/docs/prompt-templates.md +11 -4
  688. package/docs/providers.md +9 -9
  689. package/docs/rpc.md +14 -13
  690. package/docs/sdk.md +18 -9
  691. package/docs/security.md +55 -0
  692. package/docs/session-format.md +4 -4
  693. package/docs/sessions.md +14 -14
  694. package/docs/settings.md +20 -7
  695. package/docs/skills.md +11 -11
  696. package/docs/terminal-setup.md +38 -4
  697. package/docs/termux.md +3 -3
  698. package/docs/themes.md +1 -1
  699. package/docs/tmux.md +4 -2
  700. package/docs/tui.md +4 -4
  701. package/docs/usage.md +60 -50
  702. package/examples/extensions/README.md +1 -0
  703. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  704. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  705. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  706. package/examples/extensions/gondolin/package-lock.json +2 -2
  707. package/examples/extensions/gondolin/package.json +1 -1
  708. package/examples/extensions/minimal-mode.ts +6 -6
  709. package/examples/extensions/project-trust.ts +64 -0
  710. package/examples/extensions/sandbox/package-lock.json +2 -2
  711. package/examples/extensions/sandbox/package.json +1 -1
  712. package/examples/extensions/with-deps/package-lock.json +2 -2
  713. package/examples/extensions/with-deps/package.json +1 -1
  714. package/node_modules/@earendil-works/pi-agent-core/README.md +4 -3
  715. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  716. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +125 -77
  717. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  718. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +7 -0
  719. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
  720. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +2 -27
  721. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
  722. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
  723. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +7 -20
  724. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
  725. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts.map +1 -1
  726. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js.map +1 -1
  727. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts +1 -1
  728. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -1
  729. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +1 -1
  730. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js.map +1 -1
  731. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts.map +1 -1
  732. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js.map +1 -1
  733. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
  734. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +0 -3
  735. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
  736. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts.map +1 -1
  737. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js.map +1 -1
  738. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.d.ts.map +1 -1
  739. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js.map +1 -1
  740. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts.map +1 -1
  741. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -3
  742. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js.map +1 -1
  743. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts.map +1 -1
  744. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -7
  745. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js.map +1 -1
  746. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts.map +1 -1
  747. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +3 -1
  748. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js.map +1 -1
  749. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts.map +1 -1
  750. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -5
  751. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js.map +1 -1
  752. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts.map +1 -1
  753. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js.map +1 -1
  754. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
  755. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +0 -1
  756. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
  757. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.d.ts.map +1 -1
  758. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.js.map +1 -1
  759. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.d.ts.map +1 -1
  760. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js.map +1 -1
  761. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.d.ts.map +1 -1
  762. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.js.map +1 -1
  763. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +0 -2
  764. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
  765. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js +0 -20
  766. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
  767. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -1
  768. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js.map +1 -1
  769. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.d.ts.map +1 -1
  770. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js.map +1 -1
  771. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
  772. package/node_modules/@earendil-works/pi-agent-core/dist/node.d.ts.map +1 -1
  773. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
  774. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  775. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +7 -4
  776. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
  777. package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
  778. package/node_modules/@earendil-works/pi-agent-core/package.json +6 -6
  779. package/node_modules/@earendil-works/pi-ai/README.md +4 -5
  780. package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts +0 -1
  781. package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts.map +1 -1
  782. package/node_modules/@earendil-works/pi-ai/dist/api-registry.js +0 -3
  783. package/node_modules/@earendil-works/pi-ai/dist/api-registry.js.map +1 -1
  784. package/node_modules/@earendil-works/pi-ai/dist/bedrock-provider.d.ts.map +1 -1
  785. package/node_modules/@earendil-works/pi-ai/dist/cli.d.ts.map +1 -1
  786. package/node_modules/@earendil-works/pi-ai/dist/cli.js.map +1 -1
  787. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
  788. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
  789. package/node_modules/@earendil-works/pi-ai/dist/image-models.d.ts.map +1 -1
  790. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +30 -0
  791. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
  792. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +30 -0
  793. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
  794. package/node_modules/@earendil-works/pi-ai/dist/image-models.js.map +1 -1
  795. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts.map +1 -1
  796. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js.map +1 -1
  797. package/node_modules/@earendil-works/pi-ai/dist/images.d.ts.map +1 -1
  798. package/node_modules/@earendil-works/pi-ai/dist/images.js.map +1 -1
  799. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  800. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
  801. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +584 -397
  802. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  803. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +578 -509
  804. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
  805. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  806. package/node_modules/@earendil-works/pi-ai/dist/oauth.d.ts.map +1 -1
  807. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
  808. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +15 -7
  809. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
  810. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts +1 -1
  811. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  812. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +17 -7
  813. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
  814. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
  815. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +1 -0
  816. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
  817. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.d.ts.map +1 -1
  818. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.js.map +1 -1
  819. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
  820. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
  821. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -1
  822. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.js.map +1 -1
  823. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.d.ts +0 -4
  824. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.d.ts.map +1 -1
  825. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.js +0 -13
  826. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.js.map +1 -1
  827. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.d.ts.map +1 -1
  828. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js.map +1 -1
  829. package/node_modules/@earendil-works/pi-ai/dist/providers/google.d.ts.map +1 -1
  830. package/node_modules/@earendil-works/pi-ai/dist/providers/google.js.map +1 -1
  831. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.d.ts.map +1 -1
  832. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.js.map +1 -1
  833. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts.map +1 -1
  834. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js.map +1 -1
  835. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.d.ts.map +1 -1
  836. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.js +3 -3
  837. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.js.map +1 -1
  838. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -1
  839. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js +0 -7
  840. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js.map +1 -1
  841. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  842. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +5 -4
  843. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js.map +1 -1
  844. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.d.ts.map +1 -1
  845. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.js.map +1 -1
  846. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.d.ts.map +1 -1
  847. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.js +2 -1
  848. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.js.map +1 -1
  849. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
  850. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +3 -2
  851. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js.map +1 -1
  852. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
  853. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.js.map +1 -1
  854. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts +1 -7
  855. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
  856. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js +2 -16
  857. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js.map +1 -1
  858. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.d.ts.map +1 -1
  859. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.js.map +1 -1
  860. package/node_modules/@earendil-works/pi-ai/dist/session-resources.d.ts.map +1 -1
  861. package/node_modules/@earendil-works/pi-ai/dist/session-resources.js.map +1 -1
  862. package/node_modules/@earendil-works/pi-ai/dist/stream.d.ts.map +1 -1
  863. package/node_modules/@earendil-works/pi-ai/dist/stream.js.map +1 -1
  864. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.d.ts.map +1 -1
  865. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js.map +1 -1
  866. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts.map +1 -1
  867. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js.map +1 -1
  868. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts.map +1 -1
  869. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js +10 -8
  870. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js.map +1 -1
  871. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/hermes.d.ts.map +1 -1
  872. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/hermes.js.map +1 -1
  873. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.d.ts.map +1 -1
  874. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js.map +1 -1
  875. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.d.ts.map +1 -1
  876. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js.map +1 -1
  877. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/xml-tool-tag-scanner.d.ts.map +1 -1
  878. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/xml-tool-tag-scanner.js.map +1 -1
  879. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.d.ts.map +1 -1
  880. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js.map +1 -1
  881. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.d.ts.map +1 -1
  882. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js.map +1 -1
  883. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts.map +1 -1
  884. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +6 -2
  885. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  886. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  887. package/node_modules/@earendil-works/pi-ai/dist/utils/abort-signals.d.ts.map +1 -1
  888. package/node_modules/@earendil-works/pi-ai/dist/utils/abort-signals.js.map +1 -1
  889. package/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.d.ts.map +1 -1
  890. package/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.js.map +1 -1
  891. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
  892. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js +3 -7
  893. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js.map +1 -1
  894. package/node_modules/@earendil-works/pi-ai/dist/utils/hash.d.ts.map +1 -1
  895. package/node_modules/@earendil-works/pi-ai/dist/utils/hash.js.map +1 -1
  896. package/node_modules/@earendil-works/pi-ai/dist/utils/headers.d.ts.map +1 -1
  897. package/node_modules/@earendil-works/pi-ai/dist/utils/headers.js.map +1 -1
  898. package/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.d.ts.map +1 -1
  899. package/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.js.map +1 -1
  900. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.d.ts.map +1 -1
  901. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js.map +1 -1
  902. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.d.ts.map +1 -1
  903. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.js.map +1 -1
  904. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.d.ts.map +1 -1
  905. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.js.map +1 -1
  906. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
  907. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -1
  908. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.d.ts.map +1 -1
  909. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js.map +1 -1
  910. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.d.ts.map +1 -1
  911. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.js.map +1 -1
  912. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.d.ts.map +1 -1
  913. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js.map +1 -1
  914. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.d.ts.map +1 -1
  915. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.js.map +1 -1
  916. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.d.ts.map +1 -1
  917. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts +0 -4
  918. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
  919. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +0 -6
  920. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
  921. package/node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.d.ts.map +1 -1
  922. package/node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.js.map +1 -1
  923. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.d.ts.map +1 -1
  924. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js.map +1 -1
  925. package/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.d.ts.map +1 -1
  926. package/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.js.map +1 -1
  927. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.d.ts.map +1 -1
  928. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.js.map +1 -1
  929. package/node_modules/@earendil-works/pi-ai/package.json +5 -5
  930. package/node_modules/@earendil-works/pi-tui/README.md +1 -2
  931. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +3 -1
  932. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -1
  933. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +0 -3
  934. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -1
  935. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +1 -1
  936. package/node_modules/@earendil-works/pi-tui/dist/components/box.js +1 -6
  937. package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +1 -1
  938. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts.map +1 -1
  939. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js +4 -3
  940. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js.map +1 -1
  941. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +6 -1
  942. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
  943. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +132 -93
  944. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
  945. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
  946. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +0 -8
  947. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
  948. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +1 -1
  949. package/node_modules/@earendil-works/pi-tui/dist/components/input.js +14 -14
  950. package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +1 -1
  951. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +5 -0
  952. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts.map +1 -1
  953. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js +29 -17
  954. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js.map +1 -1
  955. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +1 -1
  956. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +0 -11
  957. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +1 -1
  958. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +1 -1
  959. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +4 -9
  960. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +1 -1
  961. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +1 -1
  962. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +4 -12
  963. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +1 -1
  964. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts.map +1 -1
  965. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js +0 -1
  966. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js.map +1 -1
  967. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +1 -1
  968. package/node_modules/@earendil-works/pi-tui/dist/components/text.js +0 -8
  969. package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +1 -1
  970. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts.map +1 -1
  971. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js +0 -3
  972. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js.map +1 -1
  973. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts.map +1 -1
  974. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts.map +1 -1
  975. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +131 -61
  976. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js.map +1 -1
  977. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +1 -1
  978. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  979. package/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
  980. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  981. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
  982. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +2 -4
  983. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
  984. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +1 -1
  985. package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +1 -1
  986. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts.map +1 -1
  987. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js +3 -1
  988. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js.map +1 -1
  989. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts.map +1 -1
  990. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js.map +1 -1
  991. package/node_modules/@earendil-works/pi-tui/dist/slash-command-autocomplete.d.ts.map +1 -1
  992. package/node_modules/@earendil-works/pi-tui/dist/slash-command-autocomplete.js.map +1 -1
  993. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +1 -1
  994. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +4 -6
  995. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +1 -1
  996. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +0 -1
  997. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
  998. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +4 -7
  999. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
  1000. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +4 -7
  1001. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
  1002. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +60 -103
  1003. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
  1004. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  1005. package/node_modules/@earendil-works/pi-tui/dist/tui.js +39 -31
  1006. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  1007. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts.map +1 -1
  1008. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js +3 -1
  1009. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js.map +1 -1
  1010. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +0 -4
  1011. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -1
  1012. package/node_modules/@earendil-works/pi-tui/dist/utils.js +57 -33
  1013. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
  1014. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts.map +1 -1
  1015. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js.map +1 -1
  1016. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  1017. package/node_modules/@types/node/README.md +3 -3
  1018. package/node_modules/@types/node/assert/strict.d.ts +3 -55
  1019. package/node_modules/@types/node/assert.d.ts +49 -177
  1020. package/node_modules/@types/node/async_hooks.d.ts +151 -43
  1021. package/node_modules/@types/node/buffer.buffer.d.ts +2 -8
  1022. package/node_modules/@types/node/buffer.d.ts +43 -212
  1023. package/node_modules/@types/node/child_process.d.ts +23 -133
  1024. package/node_modules/@types/node/cluster.d.ts +238 -384
  1025. package/node_modules/@types/node/compatibility/iterators.d.ts +1 -0
  1026. package/node_modules/@types/node/console.d.ts +45 -404
  1027. package/node_modules/@types/node/constants.d.ts +3 -10
  1028. package/node_modules/@types/node/crypto.d.ts +640 -1127
  1029. package/node_modules/@types/node/dgram.d.ts +14 -77
  1030. package/node_modules/@types/node/diagnostics_channel.d.ts +3 -29
  1031. package/node_modules/@types/node/dns/promises.d.ts +4 -10
  1032. package/node_modules/@types/node/dns.d.ts +130 -177
  1033. package/node_modules/@types/node/domain.d.ts +12 -32
  1034. package/node_modules/@types/node/events.d.ts +872 -840
  1035. package/node_modules/@types/node/fs/promises.d.ts +193 -20
  1036. package/node_modules/@types/node/fs.d.ts +754 -435
  1037. package/node_modules/@types/node/globals.d.ts +8 -30
  1038. package/node_modules/@types/node/globals.typedarray.d.ts +63 -0
  1039. package/node_modules/@types/node/http.d.ts +363 -305
  1040. package/node_modules/@types/node/http2.d.ts +545 -781
  1041. package/node_modules/@types/node/https.d.ts +64 -243
  1042. package/node_modules/@types/node/index.d.ts +26 -6
  1043. package/node_modules/@types/node/inspector/promises.d.ts +35 -0
  1044. package/node_modules/@types/node/inspector.d.ts +68 -57
  1045. package/node_modules/@types/node/inspector.generated.d.ts +764 -410
  1046. package/node_modules/@types/node/module.d.ts +53 -189
  1047. package/node_modules/@types/node/net.d.ts +101 -207
  1048. package/node_modules/@types/node/os.d.ts +11 -19
  1049. package/node_modules/@types/node/package.json +13 -3
  1050. package/node_modules/@types/node/path/posix.d.ts +8 -0
  1051. package/node_modules/@types/node/path/win32.d.ts +8 -0
  1052. package/node_modules/@types/node/path.d.ts +119 -141
  1053. package/node_modules/@types/node/perf_hooks.d.ts +317 -673
  1054. package/node_modules/@types/node/process.d.ts +277 -157
  1055. package/node_modules/@types/node/punycode.d.ts +3 -31
  1056. package/node_modules/@types/node/querystring.d.ts +3 -16
  1057. package/node_modules/@types/node/quic.d.ts +897 -0
  1058. package/node_modules/@types/node/readline/promises.d.ts +3 -6
  1059. package/node_modules/@types/node/readline.d.ts +65 -152
  1060. package/node_modules/@types/node/repl.d.ts +101 -109
  1061. package/node_modules/@types/node/sea.d.ts +9 -115
  1062. package/node_modules/@types/node/sqlite.d.ts +415 -68
  1063. package/node_modules/@types/node/stream/consumers.d.ts +91 -15
  1064. package/node_modules/@types/node/stream/iter.d.ts +301 -0
  1065. package/node_modules/@types/node/stream/promises.d.ts +136 -15
  1066. package/node_modules/@types/node/stream/web.d.ts +179 -501
  1067. package/node_modules/@types/node/stream.d.ts +577 -490
  1068. package/node_modules/@types/node/string_decoder.d.ts +3 -43
  1069. package/node_modules/@types/node/test/reporters.d.ts +59 -0
  1070. package/node_modules/@types/node/test.d.ts +402 -286
  1071. package/node_modules/@types/node/timers/promises.d.ts +3 -18
  1072. package/node_modules/@types/node/timers.d.ts +3 -141
  1073. package/node_modules/@types/node/tls.d.ts +115 -241
  1074. package/node_modules/@types/node/trace_events.d.ts +3 -97
  1075. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +2 -8
  1076. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  1077. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +2 -0
  1078. package/node_modules/@types/node/ts5.6/index.d.ts +28 -6
  1079. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  1080. package/node_modules/@types/node/ts5.7/index.d.ts +119 -0
  1081. package/node_modules/@types/node/tty.d.ts +57 -40
  1082. package/node_modules/@types/node/url.d.ts +156 -584
  1083. package/node_modules/@types/node/util/types.d.ts +558 -0
  1084. package/node_modules/@types/node/util.d.ts +167 -1096
  1085. package/node_modules/@types/node/v8.d.ts +75 -15
  1086. package/node_modules/@types/node/vm.d.ts +334 -198
  1087. package/node_modules/@types/node/wasi.d.ts +24 -74
  1088. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +27 -2
  1089. package/node_modules/@types/node/web-globals/blob.d.ts +23 -0
  1090. package/node_modules/@types/node/web-globals/console.d.ts +9 -0
  1091. package/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
  1092. package/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
  1093. package/node_modules/@types/node/web-globals/events.d.ts +9 -0
  1094. package/node_modules/@types/node/web-globals/fetch.d.ts +14 -0
  1095. package/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
  1096. package/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
  1097. package/node_modules/@types/node/web-globals/navigator.d.ts +3 -0
  1098. package/node_modules/@types/node/web-globals/performance.d.ts +45 -0
  1099. package/node_modules/@types/node/web-globals/streams.d.ts +115 -0
  1100. package/node_modules/@types/node/web-globals/timers.d.ts +44 -0
  1101. package/node_modules/@types/node/web-globals/url.d.ts +24 -0
  1102. package/node_modules/@types/node/worker_threads.d.ts +280 -393
  1103. package/node_modules/@types/node/zlib/iter.d.ts +131 -0
  1104. package/node_modules/@types/node/zlib.d.ts +7 -165
  1105. package/node_modules/undici-types/agent.d.ts +13 -12
  1106. package/node_modules/undici-types/api.d.ts +26 -26
  1107. package/node_modules/undici-types/balanced-pool.d.ts +13 -12
  1108. package/node_modules/undici-types/cache-interceptor.d.ts +179 -0
  1109. package/node_modules/undici-types/client-stats.d.ts +15 -0
  1110. package/node_modules/undici-types/client.d.ts +34 -19
  1111. package/node_modules/undici-types/connector.d.ts +4 -2
  1112. package/node_modules/undici-types/cookies.d.ts +2 -0
  1113. package/node_modules/undici-types/diagnostics-channel.d.ts +18 -10
  1114. package/node_modules/undici-types/dispatcher.d.ts +127 -104
  1115. package/node_modules/undici-types/env-http-proxy-agent.d.ts +4 -3
  1116. package/node_modules/undici-types/errors.d.ts +82 -54
  1117. package/node_modules/undici-types/eventsource.d.ts +9 -4
  1118. package/node_modules/undici-types/fetch.d.ts +22 -20
  1119. package/node_modules/undici-types/formdata.d.ts +7 -7
  1120. package/node_modules/undici-types/global-dispatcher.d.ts +4 -4
  1121. package/node_modules/undici-types/global-origin.d.ts +5 -5
  1122. package/node_modules/undici-types/h2c-client.d.ts +73 -0
  1123. package/node_modules/undici-types/handlers.d.ts +8 -8
  1124. package/node_modules/undici-types/header.d.ts +157 -1
  1125. package/node_modules/undici-types/index.d.ts +67 -47
  1126. package/node_modules/undici-types/interceptors.d.ts +71 -8
  1127. package/node_modules/undici-types/mock-agent.d.ts +36 -18
  1128. package/node_modules/undici-types/mock-call-history.d.ts +111 -0
  1129. package/node_modules/undici-types/mock-client.d.ts +6 -4
  1130. package/node_modules/undici-types/mock-errors.d.ts +3 -3
  1131. package/node_modules/undici-types/mock-interceptor.d.ts +21 -20
  1132. package/node_modules/undici-types/mock-pool.d.ts +6 -4
  1133. package/node_modules/undici-types/package.json +1 -1
  1134. package/node_modules/undici-types/patch.d.ts +0 -4
  1135. package/node_modules/undici-types/pool-stats.d.ts +8 -8
  1136. package/node_modules/undici-types/pool.d.ts +15 -13
  1137. package/node_modules/undici-types/proxy-agent.d.ts +5 -4
  1138. package/node_modules/undici-types/readable.d.ts +19 -16
  1139. package/node_modules/undici-types/retry-agent.d.ts +1 -1
  1140. package/node_modules/undici-types/retry-handler.d.ts +19 -10
  1141. package/node_modules/undici-types/round-robin-pool.d.ts +41 -0
  1142. package/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  1143. package/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
  1144. package/node_modules/undici-types/util.d.ts +3 -3
  1145. package/node_modules/undici-types/utility.d.ts +7 -0
  1146. package/node_modules/undici-types/webidl.d.ts +148 -29
  1147. package/node_modules/undici-types/websocket.d.ts +48 -10
  1148. package/npm-shrinkwrap.json +21 -21
  1149. package/package.json +13 -12
  1150. package/dist/core/extensions/builtin/compaction/overflow-detection.d.ts +0 -11
  1151. package/dist/core/extensions/builtin/compaction/overflow-detection.d.ts.map +0 -1
  1152. package/dist/core/extensions/builtin/compaction/overflow-detection.js +0 -40
  1153. package/dist/core/extensions/builtin/compaction/overflow-detection.js.map +0 -1
  1154. package/dist/core/extensions/builtin/system-messages.d.ts +0 -47
  1155. package/dist/core/extensions/builtin/system-messages.d.ts.map +0 -1
  1156. package/dist/core/extensions/builtin/system-messages.js +0 -117
  1157. package/dist/core/extensions/builtin/system-messages.js.map +0 -1
  1158. package/dist/core/extensions/builtin/todotools/continuation/config.d.ts +0 -10
  1159. package/dist/core/extensions/builtin/todotools/continuation/config.d.ts.map +0 -1
  1160. package/dist/core/extensions/builtin/todotools/continuation/config.js +0 -33
  1161. package/dist/core/extensions/builtin/todotools/continuation/config.js.map +0 -1
  1162. package/dist/core/extensions/builtin/todotools/continuation/index.d.ts +0 -2
  1163. package/dist/core/extensions/builtin/todotools/continuation/index.d.ts.map +0 -1
  1164. package/dist/core/extensions/builtin/todotools/continuation/index.js +0 -2
  1165. package/dist/core/extensions/builtin/todotools/continuation/index.js.map +0 -1
  1166. package/dist/core/extensions/builtin/todotools/continuation/prompt.d.ts +0 -5
  1167. package/dist/core/extensions/builtin/todotools/continuation/prompt.d.ts.map +0 -1
  1168. package/dist/core/extensions/builtin/todotools/continuation/prompt.js +0 -34
  1169. package/dist/core/extensions/builtin/todotools/continuation/prompt.js.map +0 -1
  1170. package/dist/core/extensions/builtin/todotools/continuation/runtime.d.ts +0 -11
  1171. package/dist/core/extensions/builtin/todotools/continuation/runtime.d.ts.map +0 -1
  1172. package/dist/core/extensions/builtin/todotools/continuation/runtime.js +0 -201
  1173. package/dist/core/extensions/builtin/todotools/continuation/runtime.js.map +0 -1
  1174. package/dist/core/extensions/builtin/todotools/settings.d.ts +0 -6
  1175. package/dist/core/extensions/builtin/todotools/settings.d.ts.map +0 -1
  1176. package/dist/core/extensions/builtin/todotools/settings.js +0 -58
  1177. package/dist/core/extensions/builtin/todotools/settings.js.map +0 -1
  1178. package/dist/core/extensions/builtin/todotools/system-messages.d.ts +0 -34
  1179. package/dist/core/extensions/builtin/todotools/system-messages.d.ts.map +0 -1
  1180. package/dist/core/extensions/builtin/todotools/system-messages.js +0 -82
  1181. package/dist/core/extensions/builtin/todotools/system-messages.js.map +0 -1
  1182. package/dist/core/index.d.ts +0 -12
  1183. package/dist/core/index.d.ts.map +0 -1
  1184. package/dist/core/index.js +0 -12
  1185. package/dist/core/index.js.map +0 -1
  1186. package/node_modules/@types/node/compatibility/disposable.d.ts +0 -14
  1187. package/node_modules/@types/node/compatibility/index.d.ts +0 -9
  1188. package/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
  1189. package/node_modules/undici-types/file.d.ts +0 -39
  1190. package/node_modules/undici-types/filereader.d.ts +0 -54
@@ -1 +1 @@
1
- {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AAItF,OAAO,EAIN,KAAK,gBAAgB,EAGrB,MAAM,eAAe,CAAC;AAEvB,QAAA,MAAM,UAAU;;;;;;;;EAYd,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAGtD,MAAM,WAAW,eAAe;IAC/B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,mEAAmE;IACnE,WAAW,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAClE,2CAA2C;IAC3C,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;CAC7D;AAOD,MAAM,WAAW,eAAe;IAC/B,yEAAyE;IACzE,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AAyDD,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,eAAe,GACvB,cAAc,CAAC,OAAO,UAAU,EAAE,eAAe,GAAG,SAAS,CAAC,CA+PhE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAEnG","sourcesContent":["import { readFile as fsReadFile, stat as fsStat } from \"node:fs/promises\";\nimport { createInterface } from \"node:readline\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { spawn } from \"child_process\";\nimport path from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { ensureTool } from \"../../utils/tools-manager.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, invalidArgText, shortenPath, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport {\n\tDEFAULT_MAX_BYTES,\n\tformatSize,\n\tGREP_MAX_LINE_LENGTH,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n} from \"./truncate.ts\";\n\nconst grepSchema = Type.Object({\n\tpattern: Type.String({ description: \"Search pattern (regex or literal string)\" }),\n\tpath: Type.Optional(Type.String({ description: \"Directory or file to search (default: current directory)\" })),\n\tglob: Type.Optional(Type.String({ description: \"Filter files by glob pattern, e.g. '*.ts' or '**/*.spec.ts'\" })),\n\tignoreCase: Type.Optional(Type.Boolean({ description: \"Case-insensitive search (default: false)\" })),\n\tliteral: Type.Optional(\n\t\tType.Boolean({ description: \"Treat pattern as literal string instead of regex (default: false)\" }),\n\t),\n\tcontext: Type.Optional(\n\t\tType.Number({ description: \"Number of lines to show before and after each match (default: 0)\" }),\n\t),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of matches to return (default: 100)\" })),\n});\n\nexport type GrepToolInput = Static<typeof grepSchema>;\nconst DEFAULT_LIMIT = 100;\n\nexport interface GrepToolDetails {\n\ttruncation?: TruncationResult;\n\tmatchLimitReached?: number;\n\tlinesTruncated?: boolean;\n}\n\n/**\n * Pluggable operations for the grep tool.\n * Override these to delegate search to remote systems (for example SSH).\n */\nexport interface GrepOperations {\n\t/** Check if path is a directory. Throws if path does not exist. */\n\tisDirectory: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Read file contents for context lines */\n\treadFile: (absolutePath: string) => Promise<string> | string;\n}\n\nconst defaultGrepOperations: GrepOperations = {\n\tisDirectory: async (p) => (await fsStat(p)).isDirectory(),\n\treadFile: (p) => fsReadFile(p, \"utf-8\"),\n};\n\nexport interface GrepToolOptions {\n\t/** Custom operations for grep. Default: local filesystem plus ripgrep */\n\toperations?: GrepOperations;\n}\n\nfunction formatGrepCall(\n\targs: { pattern: string; path?: string; glob?: string; limit?: number } | undefined,\n\ttheme: Theme,\n): string {\n\tconst pattern = str(args?.pattern);\n\tconst rawPath = str(args?.path);\n\tconst path = rawPath !== null ? shortenPath(rawPath || \".\") : null;\n\tconst glob = str(args?.glob);\n\tconst limit = args?.limit;\n\tconst invalidArg = invalidArgText(theme);\n\tlet text =\n\t\ttheme.fg(\"toolTitle\", theme.bold(\"grep\")) +\n\t\t\" \" +\n\t\t(pattern === null ? invalidArg : theme.fg(\"accent\", `/${pattern || \"\"}/`)) +\n\t\ttheme.fg(\"toolOutput\", ` in ${path === null ? invalidArg : path}`);\n\tif (glob) text += theme.fg(\"toolOutput\", ` (${glob})`);\n\tif (limit !== undefined) text += theme.fg(\"toolOutput\", ` limit ${limit}`);\n\treturn text;\n}\n\nfunction formatGrepResult(\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: GrepToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n): string {\n\tconst output = getTextOutput(result, showImages).trim();\n\tlet text = \"\";\n\tif (output) {\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst maxLines = options.expanded ? lines.length : 15;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n${displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t}\n\t}\n\n\tconst matchLimit = result.details?.matchLimitReached;\n\tconst truncation = result.details?.truncation;\n\tconst linesTruncated = result.details?.linesTruncated;\n\tif (matchLimit || truncation?.truncated || linesTruncated) {\n\t\tconst warnings: string[] = [];\n\t\tif (matchLimit) warnings.push(`${matchLimit} matches limit`);\n\t\tif (truncation?.truncated) warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);\n\t\tif (linesTruncated) warnings.push(\"some lines truncated\");\n\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${warnings.join(\", \")}]`)}`;\n\t}\n\treturn text;\n}\n\nexport function createGrepToolDefinition(\n\tcwd: string,\n\toptions?: GrepToolOptions,\n): ToolDefinition<typeof grepSchema, GrepToolDetails | undefined> {\n\tconst customOps = options?.operations;\n\treturn {\n\t\tname: \"grep\",\n\t\tlabel: \"grep\",\n\t\tdescription: `Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} matches or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Long lines are truncated to ${GREP_MAX_LINE_LENGTH} chars.`,\n\t\tpromptSnippet: \"Search file contents for patterns (respects .gitignore)\",\n\t\tparameters: grepSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{\n\t\t\t\tpattern,\n\t\t\t\tpath: searchDir,\n\t\t\t\tglob,\n\t\t\t\tignoreCase,\n\t\t\t\tliteral,\n\t\t\t\tcontext,\n\t\t\t\tlimit,\n\t\t\t}: {\n\t\t\t\tpattern: string;\n\t\t\t\tpath?: string;\n\t\t\t\tglob?: string;\n\t\t\t\tignoreCase?: boolean;\n\t\t\t\tliteral?: boolean;\n\t\t\t\tcontext?: number;\n\t\t\t\tlimit?: number;\n\t\t\t},\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet settled = false;\n\t\t\t\tconst settle = (fn: () => void) => {\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\tfn();\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst rgPath = await ensureTool(\"rg\", true);\n\t\t\t\t\t\tif (!rgPath) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"ripgrep (rg) is not available and could not be downloaded\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst searchPath = resolveToCwd(searchDir || \".\", cwd);\n\t\t\t\t\t\tconst ops = customOps ?? defaultGrepOperations;\n\t\t\t\t\t\tlet isDirectory: boolean;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tisDirectory = await ops.isDirectory(searchPath);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Path not found: ${searchPath}`)));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst contextValue = context && context > 0 ? context : 0;\n\t\t\t\t\t\tconst effectiveLimit = Math.max(1, limit ?? DEFAULT_LIMIT);\n\t\t\t\t\t\tconst formatPath = (filePath: string): string => {\n\t\t\t\t\t\t\tif (isDirectory) {\n\t\t\t\t\t\t\t\tconst relative = path.relative(searchPath, filePath);\n\t\t\t\t\t\t\t\tif (relative && !relative.startsWith(\"..\")) {\n\t\t\t\t\t\t\t\t\treturn relative.replace(/\\\\/g, \"/\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn path.basename(filePath);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst fileCache = new Map<string, string[]>();\n\t\t\t\t\t\tconst getFileLines = async (filePath: string): Promise<string[]> => {\n\t\t\t\t\t\t\tlet lines = fileCache.get(filePath);\n\t\t\t\t\t\t\tif (!lines) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst content = await ops.readFile(filePath);\n\t\t\t\t\t\t\t\t\tlines = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\").split(\"\\n\");\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tlines = [];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfileCache.set(filePath, lines);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn lines;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst args: string[] = [\"--json\", \"--line-number\", \"--color=never\", \"--hidden\"];\n\t\t\t\t\t\tif (ignoreCase) args.push(\"--ignore-case\");\n\t\t\t\t\t\tif (literal) args.push(\"--fixed-strings\");\n\t\t\t\t\t\tif (glob) args.push(\"--glob\", glob);\n\t\t\t\t\t\targs.push(\"--\", pattern, searchPath);\n\n\t\t\t\t\t\tconst child = spawn(rgPath, args, { stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n\t\t\t\t\t\tconst rl = createInterface({ input: child.stdout });\n\t\t\t\t\t\tlet stderr = \"\";\n\t\t\t\t\t\tlet matchCount = 0;\n\t\t\t\t\t\tlet matchLimitReached = false;\n\t\t\t\t\t\tlet linesTruncated = false;\n\t\t\t\t\t\tlet aborted = false;\n\t\t\t\t\t\tlet killedDueToLimit = false;\n\t\t\t\t\t\tconst outputLines: string[] = [];\n\n\t\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\t\trl.close();\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst stopChild = (dueToLimit = false) => {\n\t\t\t\t\t\t\tif (!child.killed) {\n\t\t\t\t\t\t\t\tkilledDueToLimit = dueToLimit;\n\t\t\t\t\t\t\t\tchild.kill();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\t\tstopChild();\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\t\t\t\t\tstderr += chunk.toString();\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst formatBlock = async (filePath: string, lineNumber: number): Promise<string[]> => {\n\t\t\t\t\t\t\tconst relativePath = formatPath(filePath);\n\t\t\t\t\t\t\tconst lines = await getFileLines(filePath);\n\t\t\t\t\t\t\tif (!lines.length) return [`${relativePath}:${lineNumber}: (unable to read file)`];\n\t\t\t\t\t\t\tconst block: string[] = [];\n\t\t\t\t\t\t\tconst start = contextValue > 0 ? Math.max(1, lineNumber - contextValue) : lineNumber;\n\t\t\t\t\t\t\tconst end = contextValue > 0 ? Math.min(lines.length, lineNumber + contextValue) : lineNumber;\n\t\t\t\t\t\t\tfor (let current = start; current <= end; current++) {\n\t\t\t\t\t\t\t\tconst lineText = lines[current - 1] ?? \"\";\n\t\t\t\t\t\t\t\tconst sanitized = lineText.replace(/\\r/g, \"\");\n\t\t\t\t\t\t\t\tconst isMatchLine = current === lineNumber;\n\t\t\t\t\t\t\t\t// Truncate long lines so grep output stays compact.\n\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\tif (isMatchLine) block.push(`${relativePath}:${current}: ${truncatedText}`);\n\t\t\t\t\t\t\t\telse block.push(`${relativePath}-${current}- ${truncatedText}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn block;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// Collect matches during streaming, then format them after rg exits.\n\t\t\t\t\t\tconst matches: Array<{ filePath: string; lineNumber: number; lineText?: string }> = [];\n\t\t\t\t\t\trl.on(\"line\", (line) => {\n\t\t\t\t\t\t\tif (!line.trim() || matchCount >= effectiveLimit) return;\n\t\t\t\t\t\t\tlet event: any;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tevent = JSON.parse(line);\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (event.type === \"match\") {\n\t\t\t\t\t\t\t\tmatchCount++;\n\t\t\t\t\t\t\t\tconst filePath = event.data?.path?.text;\n\t\t\t\t\t\t\t\tconst lineNumber = event.data?.line_number;\n\t\t\t\t\t\t\t\tconst lineText = event.data?.lines?.text;\n\t\t\t\t\t\t\t\tif (filePath && typeof lineNumber === \"number\")\n\t\t\t\t\t\t\t\t\tmatches.push({ filePath, lineNumber, lineText });\n\t\t\t\t\t\t\t\tif (matchCount >= effectiveLimit) {\n\t\t\t\t\t\t\t\t\tmatchLimitReached = true;\n\t\t\t\t\t\t\t\t\tstopChild(true);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Failed to run ripgrep: ${error.message}`)));\n\t\t\t\t\t\t});\n\t\t\t\t\t\tchild.on(\"close\", async (code) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!killedDueToLimit && code !== 0 && code !== 1) {\n\t\t\t\t\t\t\t\tconst errorMsg = stderr.trim() || `ripgrep exited with code ${code}`;\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(errorMsg)));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (matchCount === 0) {\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: \"No matches found\" }], details: undefined }),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Format matches after streaming finishes so custom readFile() backends can be async.\n\t\t\t\t\t\t\tfor (const match of matches) {\n\t\t\t\t\t\t\t\tif (contextValue === 0 && match.lineText !== undefined) {\n\t\t\t\t\t\t\t\t\tconst relativePath = formatPath(match.filePath);\n\t\t\t\t\t\t\t\t\tconst sanitized = match.lineText\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r\\n/g, \"\\n\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r/g, \"\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\n$/, \"\");\n\t\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\t\toutputLines.push(`${relativePath}:${match.lineNumber}: ${truncatedText}`);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst block = await formatBlock(match.filePath, match.lineNumber);\n\t\t\t\t\t\t\t\t\toutputLines.push(...block);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst rawOutput = outputLines.join(\"\\n\");\n\t\t\t\t\t\t\t// Apply byte truncation. There is no line limit here because the match limit already capped rows.\n\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\t\tconst details: GrepToolDetails = {};\n\t\t\t\t\t\t\t// Build actionable notices for truncation and match limits.\n\t\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\t\tif (matchLimitReached) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.matchLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (linesTruncated) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.linesTruncated = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (notices.length > 0) output += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tsettle(() => reject(err as Error));\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 text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepCall(args, theme));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepResult(result as any, options, theme, context.showImages));\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createGrepTool(cwd: string, options?: GrepToolOptions): AgentTool<typeof grepSchema> {\n\treturn wrapToolDefinition(createGrepToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AAItF,OAAO,EAIN,KAAK,gBAAgB,EAGrB,MAAM,eAAe,CAAC;AAEvB,QAAA,MAAM,UAAU;;;;;;;;EAYd,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAGtD,MAAM,WAAW,eAAe;IAC/B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,mEAAmE;IACnE,WAAW,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAClE,2CAA2C;IAC3C,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;CAC7D;AAOD,MAAM,WAAW,eAAe;IAC/B,yEAAyE;IACzE,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AAyDD,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,eAAe,GACvB,cAAc,CAAC,OAAO,UAAU,EAAE,eAAe,GAAG,SAAS,CAAC,CA+PhE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAEnG"}
@@ -51,7 +51,7 @@ function formatGrepResult(result, options, theme, showImages) {
51
51
  const remaining = lines.length - maxLines;
52
52
  text += `\n${displayLines.map((line) => theme.fg("toolOutput", line)).join("\n")}`;
53
53
  if (remaining > 0) {
54
- text += `${theme.fg("muted", `\n... (${remaining} more lines,`)} ${keyHint("app.tools.expand", "to expand")})`;
54
+ text += `${theme.fg("muted", `\n... (${remaining} more lines,`)} ${keyHint("app.tools.expand", "to expand")}${theme.fg("muted", ")")}`;
55
55
  }
56
56
  }
57
57
  const matchLimit = result.details?.matchLimitReached;
@@ -1 +1 @@
1
- {"version":3,"file":"grep.js","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,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CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC;QAAA,CACZ;QACD,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YAC7C,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAa,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;YAClF,OAAO,IAAI,CAAC;QAAA,CACZ;KACD,CAAC;AAAA,CACF;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB,EAAgC;IACpG,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,CAClE","sourcesContent":["import { readFile as fsReadFile, stat as fsStat } from \"node:fs/promises\";\nimport { createInterface } from \"node:readline\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { spawn } from \"child_process\";\nimport path from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { ensureTool } from \"../../utils/tools-manager.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, invalidArgText, shortenPath, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport {\n\tDEFAULT_MAX_BYTES,\n\tformatSize,\n\tGREP_MAX_LINE_LENGTH,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n} from \"./truncate.ts\";\n\nconst grepSchema = Type.Object({\n\tpattern: Type.String({ description: \"Search pattern (regex or literal string)\" }),\n\tpath: Type.Optional(Type.String({ description: \"Directory or file to search (default: current directory)\" })),\n\tglob: Type.Optional(Type.String({ description: \"Filter files by glob pattern, e.g. '*.ts' or '**/*.spec.ts'\" })),\n\tignoreCase: Type.Optional(Type.Boolean({ description: \"Case-insensitive search (default: false)\" })),\n\tliteral: Type.Optional(\n\t\tType.Boolean({ description: \"Treat pattern as literal string instead of regex (default: false)\" }),\n\t),\n\tcontext: Type.Optional(\n\t\tType.Number({ description: \"Number of lines to show before and after each match (default: 0)\" }),\n\t),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of matches to return (default: 100)\" })),\n});\n\nexport type GrepToolInput = Static<typeof grepSchema>;\nconst DEFAULT_LIMIT = 100;\n\nexport interface GrepToolDetails {\n\ttruncation?: TruncationResult;\n\tmatchLimitReached?: number;\n\tlinesTruncated?: boolean;\n}\n\n/**\n * Pluggable operations for the grep tool.\n * Override these to delegate search to remote systems (for example SSH).\n */\nexport interface GrepOperations {\n\t/** Check if path is a directory. Throws if path does not exist. */\n\tisDirectory: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Read file contents for context lines */\n\treadFile: (absolutePath: string) => Promise<string> | string;\n}\n\nconst defaultGrepOperations: GrepOperations = {\n\tisDirectory: async (p) => (await fsStat(p)).isDirectory(),\n\treadFile: (p) => fsReadFile(p, \"utf-8\"),\n};\n\nexport interface GrepToolOptions {\n\t/** Custom operations for grep. Default: local filesystem plus ripgrep */\n\toperations?: GrepOperations;\n}\n\nfunction formatGrepCall(\n\targs: { pattern: string; path?: string; glob?: string; limit?: number } | undefined,\n\ttheme: Theme,\n): string {\n\tconst pattern = str(args?.pattern);\n\tconst rawPath = str(args?.path);\n\tconst path = rawPath !== null ? shortenPath(rawPath || \".\") : null;\n\tconst glob = str(args?.glob);\n\tconst limit = args?.limit;\n\tconst invalidArg = invalidArgText(theme);\n\tlet text =\n\t\ttheme.fg(\"toolTitle\", theme.bold(\"grep\")) +\n\t\t\" \" +\n\t\t(pattern === null ? invalidArg : theme.fg(\"accent\", `/${pattern || \"\"}/`)) +\n\t\ttheme.fg(\"toolOutput\", ` in ${path === null ? invalidArg : path}`);\n\tif (glob) text += theme.fg(\"toolOutput\", ` (${glob})`);\n\tif (limit !== undefined) text += theme.fg(\"toolOutput\", ` limit ${limit}`);\n\treturn text;\n}\n\nfunction formatGrepResult(\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: GrepToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n): string {\n\tconst output = getTextOutput(result, showImages).trim();\n\tlet text = \"\";\n\tif (output) {\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst maxLines = options.expanded ? lines.length : 15;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n${displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t}\n\t}\n\n\tconst matchLimit = result.details?.matchLimitReached;\n\tconst truncation = result.details?.truncation;\n\tconst linesTruncated = result.details?.linesTruncated;\n\tif (matchLimit || truncation?.truncated || linesTruncated) {\n\t\tconst warnings: string[] = [];\n\t\tif (matchLimit) warnings.push(`${matchLimit} matches limit`);\n\t\tif (truncation?.truncated) warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);\n\t\tif (linesTruncated) warnings.push(\"some lines truncated\");\n\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${warnings.join(\", \")}]`)}`;\n\t}\n\treturn text;\n}\n\nexport function createGrepToolDefinition(\n\tcwd: string,\n\toptions?: GrepToolOptions,\n): ToolDefinition<typeof grepSchema, GrepToolDetails | undefined> {\n\tconst customOps = options?.operations;\n\treturn {\n\t\tname: \"grep\",\n\t\tlabel: \"grep\",\n\t\tdescription: `Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} matches or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Long lines are truncated to ${GREP_MAX_LINE_LENGTH} chars.`,\n\t\tpromptSnippet: \"Search file contents for patterns (respects .gitignore)\",\n\t\tparameters: grepSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{\n\t\t\t\tpattern,\n\t\t\t\tpath: searchDir,\n\t\t\t\tglob,\n\t\t\t\tignoreCase,\n\t\t\t\tliteral,\n\t\t\t\tcontext,\n\t\t\t\tlimit,\n\t\t\t}: {\n\t\t\t\tpattern: string;\n\t\t\t\tpath?: string;\n\t\t\t\tglob?: string;\n\t\t\t\tignoreCase?: boolean;\n\t\t\t\tliteral?: boolean;\n\t\t\t\tcontext?: number;\n\t\t\t\tlimit?: number;\n\t\t\t},\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet settled = false;\n\t\t\t\tconst settle = (fn: () => void) => {\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\tfn();\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst rgPath = await ensureTool(\"rg\", true);\n\t\t\t\t\t\tif (!rgPath) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"ripgrep (rg) is not available and could not be downloaded\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst searchPath = resolveToCwd(searchDir || \".\", cwd);\n\t\t\t\t\t\tconst ops = customOps ?? defaultGrepOperations;\n\t\t\t\t\t\tlet isDirectory: boolean;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tisDirectory = await ops.isDirectory(searchPath);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Path not found: ${searchPath}`)));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst contextValue = context && context > 0 ? context : 0;\n\t\t\t\t\t\tconst effectiveLimit = Math.max(1, limit ?? DEFAULT_LIMIT);\n\t\t\t\t\t\tconst formatPath = (filePath: string): string => {\n\t\t\t\t\t\t\tif (isDirectory) {\n\t\t\t\t\t\t\t\tconst relative = path.relative(searchPath, filePath);\n\t\t\t\t\t\t\t\tif (relative && !relative.startsWith(\"..\")) {\n\t\t\t\t\t\t\t\t\treturn relative.replace(/\\\\/g, \"/\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn path.basename(filePath);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst fileCache = new Map<string, string[]>();\n\t\t\t\t\t\tconst getFileLines = async (filePath: string): Promise<string[]> => {\n\t\t\t\t\t\t\tlet lines = fileCache.get(filePath);\n\t\t\t\t\t\t\tif (!lines) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst content = await ops.readFile(filePath);\n\t\t\t\t\t\t\t\t\tlines = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\").split(\"\\n\");\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tlines = [];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfileCache.set(filePath, lines);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn lines;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst args: string[] = [\"--json\", \"--line-number\", \"--color=never\", \"--hidden\"];\n\t\t\t\t\t\tif (ignoreCase) args.push(\"--ignore-case\");\n\t\t\t\t\t\tif (literal) args.push(\"--fixed-strings\");\n\t\t\t\t\t\tif (glob) args.push(\"--glob\", glob);\n\t\t\t\t\t\targs.push(\"--\", pattern, searchPath);\n\n\t\t\t\t\t\tconst child = spawn(rgPath, args, { stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n\t\t\t\t\t\tconst rl = createInterface({ input: child.stdout });\n\t\t\t\t\t\tlet stderr = \"\";\n\t\t\t\t\t\tlet matchCount = 0;\n\t\t\t\t\t\tlet matchLimitReached = false;\n\t\t\t\t\t\tlet linesTruncated = false;\n\t\t\t\t\t\tlet aborted = false;\n\t\t\t\t\t\tlet killedDueToLimit = false;\n\t\t\t\t\t\tconst outputLines: string[] = [];\n\n\t\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\t\trl.close();\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst stopChild = (dueToLimit = false) => {\n\t\t\t\t\t\t\tif (!child.killed) {\n\t\t\t\t\t\t\t\tkilledDueToLimit = dueToLimit;\n\t\t\t\t\t\t\t\tchild.kill();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\t\tstopChild();\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\t\t\t\t\tstderr += chunk.toString();\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst formatBlock = async (filePath: string, lineNumber: number): Promise<string[]> => {\n\t\t\t\t\t\t\tconst relativePath = formatPath(filePath);\n\t\t\t\t\t\t\tconst lines = await getFileLines(filePath);\n\t\t\t\t\t\t\tif (!lines.length) return [`${relativePath}:${lineNumber}: (unable to read file)`];\n\t\t\t\t\t\t\tconst block: string[] = [];\n\t\t\t\t\t\t\tconst start = contextValue > 0 ? Math.max(1, lineNumber - contextValue) : lineNumber;\n\t\t\t\t\t\t\tconst end = contextValue > 0 ? Math.min(lines.length, lineNumber + contextValue) : lineNumber;\n\t\t\t\t\t\t\tfor (let current = start; current <= end; current++) {\n\t\t\t\t\t\t\t\tconst lineText = lines[current - 1] ?? \"\";\n\t\t\t\t\t\t\t\tconst sanitized = lineText.replace(/\\r/g, \"\");\n\t\t\t\t\t\t\t\tconst isMatchLine = current === lineNumber;\n\t\t\t\t\t\t\t\t// Truncate long lines so grep output stays compact.\n\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\tif (isMatchLine) block.push(`${relativePath}:${current}: ${truncatedText}`);\n\t\t\t\t\t\t\t\telse block.push(`${relativePath}-${current}- ${truncatedText}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn block;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// Collect matches during streaming, then format them after rg exits.\n\t\t\t\t\t\tconst matches: Array<{ filePath: string; lineNumber: number; lineText?: string }> = [];\n\t\t\t\t\t\trl.on(\"line\", (line) => {\n\t\t\t\t\t\t\tif (!line.trim() || matchCount >= effectiveLimit) return;\n\t\t\t\t\t\t\tlet event: any;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tevent = JSON.parse(line);\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (event.type === \"match\") {\n\t\t\t\t\t\t\t\tmatchCount++;\n\t\t\t\t\t\t\t\tconst filePath = event.data?.path?.text;\n\t\t\t\t\t\t\t\tconst lineNumber = event.data?.line_number;\n\t\t\t\t\t\t\t\tconst lineText = event.data?.lines?.text;\n\t\t\t\t\t\t\t\tif (filePath && typeof lineNumber === \"number\")\n\t\t\t\t\t\t\t\t\tmatches.push({ filePath, lineNumber, lineText });\n\t\t\t\t\t\t\t\tif (matchCount >= effectiveLimit) {\n\t\t\t\t\t\t\t\t\tmatchLimitReached = true;\n\t\t\t\t\t\t\t\t\tstopChild(true);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Failed to run ripgrep: ${error.message}`)));\n\t\t\t\t\t\t});\n\t\t\t\t\t\tchild.on(\"close\", async (code) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!killedDueToLimit && code !== 0 && code !== 1) {\n\t\t\t\t\t\t\t\tconst errorMsg = stderr.trim() || `ripgrep exited with code ${code}`;\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(errorMsg)));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (matchCount === 0) {\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: \"No matches found\" }], details: undefined }),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Format matches after streaming finishes so custom readFile() backends can be async.\n\t\t\t\t\t\t\tfor (const match of matches) {\n\t\t\t\t\t\t\t\tif (contextValue === 0 && match.lineText !== undefined) {\n\t\t\t\t\t\t\t\t\tconst relativePath = formatPath(match.filePath);\n\t\t\t\t\t\t\t\t\tconst sanitized = match.lineText\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r\\n/g, \"\\n\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r/g, \"\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\n$/, \"\");\n\t\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\t\toutputLines.push(`${relativePath}:${match.lineNumber}: ${truncatedText}`);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst block = await formatBlock(match.filePath, match.lineNumber);\n\t\t\t\t\t\t\t\t\toutputLines.push(...block);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst rawOutput = outputLines.join(\"\\n\");\n\t\t\t\t\t\t\t// Apply byte truncation. There is no line limit here because the match limit already capped rows.\n\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\t\tconst details: GrepToolDetails = {};\n\t\t\t\t\t\t\t// Build actionable notices for truncation and match limits.\n\t\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\t\tif (matchLimitReached) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.matchLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (linesTruncated) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.linesTruncated = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (notices.length > 0) output += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tsettle(() => reject(err as Error));\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 text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepCall(args, theme));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepResult(result as any, options, theme, context.showImages));\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createGrepTool(cwd: string, options?: GrepToolOptions): AgentTool<typeof grepSchema> {\n\treturn wrapToolDefinition(createGrepToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"grep.js","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE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,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAa,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;YAClF,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { readFile as fsReadFile, stat as fsStat } from \"node:fs/promises\";\nimport { createInterface } from \"node:readline\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { spawn } from \"child_process\";\nimport path from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { ensureTool } from \"../../utils/tools-manager.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, invalidArgText, shortenPath, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport {\n\tDEFAULT_MAX_BYTES,\n\tformatSize,\n\tGREP_MAX_LINE_LENGTH,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n} from \"./truncate.ts\";\n\nconst grepSchema = Type.Object({\n\tpattern: Type.String({ description: \"Search pattern (regex or literal string)\" }),\n\tpath: Type.Optional(Type.String({ description: \"Directory or file to search (default: current directory)\" })),\n\tglob: Type.Optional(Type.String({ description: \"Filter files by glob pattern, e.g. '*.ts' or '**/*.spec.ts'\" })),\n\tignoreCase: Type.Optional(Type.Boolean({ description: \"Case-insensitive search (default: false)\" })),\n\tliteral: Type.Optional(\n\t\tType.Boolean({ description: \"Treat pattern as literal string instead of regex (default: false)\" }),\n\t),\n\tcontext: Type.Optional(\n\t\tType.Number({ description: \"Number of lines to show before and after each match (default: 0)\" }),\n\t),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of matches to return (default: 100)\" })),\n});\n\nexport type GrepToolInput = Static<typeof grepSchema>;\nconst DEFAULT_LIMIT = 100;\n\nexport interface GrepToolDetails {\n\ttruncation?: TruncationResult;\n\tmatchLimitReached?: number;\n\tlinesTruncated?: boolean;\n}\n\n/**\n * Pluggable operations for the grep tool.\n * Override these to delegate search to remote systems (for example SSH).\n */\nexport interface GrepOperations {\n\t/** Check if path is a directory. Throws if path does not exist. */\n\tisDirectory: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Read file contents for context lines */\n\treadFile: (absolutePath: string) => Promise<string> | string;\n}\n\nconst defaultGrepOperations: GrepOperations = {\n\tisDirectory: async (p) => (await fsStat(p)).isDirectory(),\n\treadFile: (p) => fsReadFile(p, \"utf-8\"),\n};\n\nexport interface GrepToolOptions {\n\t/** Custom operations for grep. Default: local filesystem plus ripgrep */\n\toperations?: GrepOperations;\n}\n\nfunction formatGrepCall(\n\targs: { pattern: string; path?: string; glob?: string; limit?: number } | undefined,\n\ttheme: Theme,\n): string {\n\tconst pattern = str(args?.pattern);\n\tconst rawPath = str(args?.path);\n\tconst path = rawPath !== null ? shortenPath(rawPath || \".\") : null;\n\tconst glob = str(args?.glob);\n\tconst limit = args?.limit;\n\tconst invalidArg = invalidArgText(theme);\n\tlet text =\n\t\ttheme.fg(\"toolTitle\", theme.bold(\"grep\")) +\n\t\t\" \" +\n\t\t(pattern === null ? invalidArg : theme.fg(\"accent\", `/${pattern || \"\"}/`)) +\n\t\ttheme.fg(\"toolOutput\", ` in ${path === null ? invalidArg : path}`);\n\tif (glob) text += theme.fg(\"toolOutput\", ` (${glob})`);\n\tif (limit !== undefined) text += theme.fg(\"toolOutput\", ` limit ${limit}`);\n\treturn text;\n}\n\nfunction formatGrepResult(\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: GrepToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n): string {\n\tconst output = getTextOutput(result, showImages).trim();\n\tlet text = \"\";\n\tif (output) {\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst maxLines = options.expanded ? lines.length : 15;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n${displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")}${theme.fg(\"muted\", \")\")}`;\n\t\t}\n\t}\n\n\tconst matchLimit = result.details?.matchLimitReached;\n\tconst truncation = result.details?.truncation;\n\tconst linesTruncated = result.details?.linesTruncated;\n\tif (matchLimit || truncation?.truncated || linesTruncated) {\n\t\tconst warnings: string[] = [];\n\t\tif (matchLimit) warnings.push(`${matchLimit} matches limit`);\n\t\tif (truncation?.truncated) warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);\n\t\tif (linesTruncated) warnings.push(\"some lines truncated\");\n\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${warnings.join(\", \")}]`)}`;\n\t}\n\treturn text;\n}\n\nexport function createGrepToolDefinition(\n\tcwd: string,\n\toptions?: GrepToolOptions,\n): ToolDefinition<typeof grepSchema, GrepToolDetails | undefined> {\n\tconst customOps = options?.operations;\n\treturn {\n\t\tname: \"grep\",\n\t\tlabel: \"grep\",\n\t\tdescription: `Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} matches or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Long lines are truncated to ${GREP_MAX_LINE_LENGTH} chars.`,\n\t\tpromptSnippet: \"Search file contents for patterns (respects .gitignore)\",\n\t\tparameters: grepSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{\n\t\t\t\tpattern,\n\t\t\t\tpath: searchDir,\n\t\t\t\tglob,\n\t\t\t\tignoreCase,\n\t\t\t\tliteral,\n\t\t\t\tcontext,\n\t\t\t\tlimit,\n\t\t\t}: {\n\t\t\t\tpattern: string;\n\t\t\t\tpath?: string;\n\t\t\t\tglob?: string;\n\t\t\t\tignoreCase?: boolean;\n\t\t\t\tliteral?: boolean;\n\t\t\t\tcontext?: number;\n\t\t\t\tlimit?: number;\n\t\t\t},\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet settled = false;\n\t\t\t\tconst settle = (fn: () => void) => {\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\tfn();\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst rgPath = await ensureTool(\"rg\", true);\n\t\t\t\t\t\tif (!rgPath) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"ripgrep (rg) is not available and could not be downloaded\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst searchPath = resolveToCwd(searchDir || \".\", cwd);\n\t\t\t\t\t\tconst ops = customOps ?? defaultGrepOperations;\n\t\t\t\t\t\tlet isDirectory: boolean;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tisDirectory = await ops.isDirectory(searchPath);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Path not found: ${searchPath}`)));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst contextValue = context && context > 0 ? context : 0;\n\t\t\t\t\t\tconst effectiveLimit = Math.max(1, limit ?? DEFAULT_LIMIT);\n\t\t\t\t\t\tconst formatPath = (filePath: string): string => {\n\t\t\t\t\t\t\tif (isDirectory) {\n\t\t\t\t\t\t\t\tconst relative = path.relative(searchPath, filePath);\n\t\t\t\t\t\t\t\tif (relative && !relative.startsWith(\"..\")) {\n\t\t\t\t\t\t\t\t\treturn relative.replace(/\\\\/g, \"/\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn path.basename(filePath);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst fileCache = new Map<string, string[]>();\n\t\t\t\t\t\tconst getFileLines = async (filePath: string): Promise<string[]> => {\n\t\t\t\t\t\t\tlet lines = fileCache.get(filePath);\n\t\t\t\t\t\t\tif (!lines) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst content = await ops.readFile(filePath);\n\t\t\t\t\t\t\t\t\tlines = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\").split(\"\\n\");\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tlines = [];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfileCache.set(filePath, lines);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn lines;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst args: string[] = [\"--json\", \"--line-number\", \"--color=never\", \"--hidden\"];\n\t\t\t\t\t\tif (ignoreCase) args.push(\"--ignore-case\");\n\t\t\t\t\t\tif (literal) args.push(\"--fixed-strings\");\n\t\t\t\t\t\tif (glob) args.push(\"--glob\", glob);\n\t\t\t\t\t\targs.push(\"--\", pattern, searchPath);\n\n\t\t\t\t\t\tconst child = spawn(rgPath, args, { stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n\t\t\t\t\t\tconst rl = createInterface({ input: child.stdout });\n\t\t\t\t\t\tlet stderr = \"\";\n\t\t\t\t\t\tlet matchCount = 0;\n\t\t\t\t\t\tlet matchLimitReached = false;\n\t\t\t\t\t\tlet linesTruncated = false;\n\t\t\t\t\t\tlet aborted = false;\n\t\t\t\t\t\tlet killedDueToLimit = false;\n\t\t\t\t\t\tconst outputLines: string[] = [];\n\n\t\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\t\trl.close();\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst stopChild = (dueToLimit = false) => {\n\t\t\t\t\t\t\tif (!child.killed) {\n\t\t\t\t\t\t\t\tkilledDueToLimit = dueToLimit;\n\t\t\t\t\t\t\t\tchild.kill();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\t\tstopChild();\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\t\t\t\t\tstderr += chunk.toString();\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst formatBlock = async (filePath: string, lineNumber: number): Promise<string[]> => {\n\t\t\t\t\t\t\tconst relativePath = formatPath(filePath);\n\t\t\t\t\t\t\tconst lines = await getFileLines(filePath);\n\t\t\t\t\t\t\tif (!lines.length) return [`${relativePath}:${lineNumber}: (unable to read file)`];\n\t\t\t\t\t\t\tconst block: string[] = [];\n\t\t\t\t\t\t\tconst start = contextValue > 0 ? Math.max(1, lineNumber - contextValue) : lineNumber;\n\t\t\t\t\t\t\tconst end = contextValue > 0 ? Math.min(lines.length, lineNumber + contextValue) : lineNumber;\n\t\t\t\t\t\t\tfor (let current = start; current <= end; current++) {\n\t\t\t\t\t\t\t\tconst lineText = lines[current - 1] ?? \"\";\n\t\t\t\t\t\t\t\tconst sanitized = lineText.replace(/\\r/g, \"\");\n\t\t\t\t\t\t\t\tconst isMatchLine = current === lineNumber;\n\t\t\t\t\t\t\t\t// Truncate long lines so grep output stays compact.\n\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\tif (isMatchLine) block.push(`${relativePath}:${current}: ${truncatedText}`);\n\t\t\t\t\t\t\t\telse block.push(`${relativePath}-${current}- ${truncatedText}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn block;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// Collect matches during streaming, then format them after rg exits.\n\t\t\t\t\t\tconst matches: Array<{ filePath: string; lineNumber: number; lineText?: string }> = [];\n\t\t\t\t\t\trl.on(\"line\", (line) => {\n\t\t\t\t\t\t\tif (!line.trim() || matchCount >= effectiveLimit) return;\n\t\t\t\t\t\t\tlet event: any;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tevent = JSON.parse(line);\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (event.type === \"match\") {\n\t\t\t\t\t\t\t\tmatchCount++;\n\t\t\t\t\t\t\t\tconst filePath = event.data?.path?.text;\n\t\t\t\t\t\t\t\tconst lineNumber = event.data?.line_number;\n\t\t\t\t\t\t\t\tconst lineText = event.data?.lines?.text;\n\t\t\t\t\t\t\t\tif (filePath && typeof lineNumber === \"number\")\n\t\t\t\t\t\t\t\t\tmatches.push({ filePath, lineNumber, lineText });\n\t\t\t\t\t\t\t\tif (matchCount >= effectiveLimit) {\n\t\t\t\t\t\t\t\t\tmatchLimitReached = true;\n\t\t\t\t\t\t\t\t\tstopChild(true);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Failed to run ripgrep: ${error.message}`)));\n\t\t\t\t\t\t});\n\t\t\t\t\t\tchild.on(\"close\", async (code) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!killedDueToLimit && code !== 0 && code !== 1) {\n\t\t\t\t\t\t\t\tconst errorMsg = stderr.trim() || `ripgrep exited with code ${code}`;\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(errorMsg)));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (matchCount === 0) {\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: \"No matches found\" }], details: undefined }),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Format matches after streaming finishes so custom readFile() backends can be async.\n\t\t\t\t\t\t\tfor (const match of matches) {\n\t\t\t\t\t\t\t\tif (contextValue === 0 && match.lineText !== undefined) {\n\t\t\t\t\t\t\t\t\tconst relativePath = formatPath(match.filePath);\n\t\t\t\t\t\t\t\t\tconst sanitized = match.lineText\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r\\n/g, \"\\n\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r/g, \"\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\n$/, \"\");\n\t\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\t\toutputLines.push(`${relativePath}:${match.lineNumber}: ${truncatedText}`);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst block = await formatBlock(match.filePath, match.lineNumber);\n\t\t\t\t\t\t\t\t\toutputLines.push(...block);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst rawOutput = outputLines.join(\"\\n\");\n\t\t\t\t\t\t\t// Apply byte truncation. There is no line limit here because the match limit already capped rows.\n\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\t\tconst details: GrepToolDetails = {};\n\t\t\t\t\t\t\t// Build actionable notices for truncation and match limits.\n\t\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\t\tif (matchLimitReached) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.matchLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (linesTruncated) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.linesTruncated = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (notices.length > 0) output += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tsettle(() => reject(err as Error));\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 text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepCall(args, theme));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepResult(result as any, options, theme, context.showImages));\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createGrepTool(cwd: string, options?: GrepToolOptions): AgentTool<typeof grepSchema> {\n\treturn wrapToolDefinition(createGrepToolDefinition(cwd, options));\n}\n"]}
@@ -29,12 +29,7 @@ export interface ToolsOptions {
29
29
  find?: FindToolOptions;
30
30
  ls?: LsToolOptions;
31
31
  }
32
- export declare function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef;
33
- export declare function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool;
34
- export declare function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[];
35
- export declare function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[];
36
32
  export declare function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef>;
37
33
  export declare function createCodingTools(cwd: string, options?: ToolsOptions): Tool[];
38
34
  export declare function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[];
39
- export declare function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool>;
40
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,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,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,eAAe,EACf,yBAAyB,EACzB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,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AO,CAAC,EAAE,YAAY,GAAG,OAAO,CAmBrG;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAmBxF;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAO1F;AAED,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAO5F;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAUvG;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAU1F","sourcesContent":["export {\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} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.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\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.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 { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\";\nexport const allToolNames: Set<ToolName> = new Set([\"read\", \"bash\", \"edit\", \"write\", \"grep\", \"find\", \"ls\"]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\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 \"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\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 \"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\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.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(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.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(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t};\n}\n"]}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,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,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,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BAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAUvG;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E"}
@@ -15,62 +15,6 @@ import { createLsTool, createLsToolDefinition } from "./ls.js";
15
15
  import { createReadTool, createReadToolDefinition } from "./read.js";
16
16
  import { createWriteTool, createWriteToolDefinition } from "./write.js";
17
17
  export const allToolNames = new Set(["read", "bash", "edit", "write", "grep", "find", "ls"]);
18
- export function createToolDefinition(toolName, cwd, options) {
19
- switch (toolName) {
20
- case "read":
21
- return createReadToolDefinition(cwd, options?.read);
22
- case "bash":
23
- return createBashToolDefinition(cwd, options?.bash);
24
- case "edit":
25
- return createEditToolDefinition(cwd, options?.edit);
26
- case "write":
27
- return createWriteToolDefinition(cwd, options?.write);
28
- case "grep":
29
- return createGrepToolDefinition(cwd, options?.grep);
30
- case "find":
31
- return createFindToolDefinition(cwd, options?.find);
32
- case "ls":
33
- return createLsToolDefinition(cwd, options?.ls);
34
- default:
35
- throw new Error(`Unknown tool name: ${toolName}`);
36
- }
37
- }
38
- export function createTool(toolName, cwd, options) {
39
- switch (toolName) {
40
- case "read":
41
- return createReadTool(cwd, options?.read);
42
- case "bash":
43
- return createBashTool(cwd, options?.bash);
44
- case "edit":
45
- return createEditTool(cwd, options?.edit);
46
- case "write":
47
- return createWriteTool(cwd, options?.write);
48
- case "grep":
49
- return createGrepTool(cwd, options?.grep);
50
- case "find":
51
- return createFindTool(cwd, options?.find);
52
- case "ls":
53
- return createLsTool(cwd, options?.ls);
54
- default:
55
- throw new Error(`Unknown tool name: ${toolName}`);
56
- }
57
- }
58
- export function createCodingToolDefinitions(cwd, options) {
59
- return [
60
- createReadToolDefinition(cwd, options?.read),
61
- createBashToolDefinition(cwd, options?.bash),
62
- createEditToolDefinition(cwd, options?.edit),
63
- createWriteToolDefinition(cwd, options?.write),
64
- ];
65
- }
66
- export function createReadOnlyToolDefinitions(cwd, options) {
67
- return [
68
- createReadToolDefinition(cwd, options?.read),
69
- createGrepToolDefinition(cwd, options?.grep),
70
- createFindToolDefinition(cwd, options?.find),
71
- createLsToolDefinition(cwd, options?.ls),
72
- ];
73
- }
74
18
  export function createAllToolDefinitions(cwd, options) {
75
19
  return {
76
20
  read: createReadToolDefinition(cwd, options?.read),
@@ -98,15 +42,4 @@ export function createReadOnlyTools(cwd, options) {
98
42
  createLsTool(cwd, options?.ls),
99
43
  ];
100
44
  }
101
- export function createAllTools(cwd, options) {
102
- return {
103
- read: createReadTool(cwd, options?.read),
104
- bash: createBashTool(cwd, options?.bash),
105
- edit: createEditTool(cwd, options?.edit),
106
- write: createWriteTool(cwd, options?.write),
107
- grep: createGrepTool(cwd, options?.grep),
108
- find: createFindTool(cwd, options?.find),
109
- ls: createLsTool(cwd, options?.ls),
110
- };
111
- }
112
45
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,GAKtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,wBAAwB,GA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E,OAAO,EAAE,IAAI,CAAC;QAClC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QAClC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QAClC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC;KACpC,CAAC;AAAA,CACF;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAW,EAAE,OAAsB,EAAU;IAChF,OAAO;QACN,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QAClC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QAClC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QAClC,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;KAC9B,CAAC;AAAA,CACF;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAsB,EAA0B;IAC3F,OAAO;QACN,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,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;KAClC,CAAC;AAAA,CACF","sourcesContent":["export {\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} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.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\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.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 { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\";\nexport const allToolNames: Set<ToolName> = new Set([\"read\", \"bash\", \"edit\", \"write\", \"grep\", \"find\", \"ls\"]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\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 \"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\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 \"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\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.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(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.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(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t};\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,GAKtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,eAAe,EACf,yBAAyB,GAIzB,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAwB,cAAc,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAwB,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAwB,MAAM,WAAW,CAAC;AAC3F,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,OAAO,EAAE,KAAK,CAAC;KACpC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAW,EAAE,OAAsB;IACtE,OAAO;QACN,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QAClC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QAClC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QAClC,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;KAC9B,CAAC;AACH,CAAC","sourcesContent":["export {\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} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.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\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.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 { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\";\nexport const allToolNames: Set<ToolName> = new Set([\"read\", \"bash\", \"edit\", \"write\", \"grep\", \"find\", \"ls\"]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../../src/core/tools/ls.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AAItF,OAAO,EAAiC,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAEnG,QAAA,MAAM,QAAQ;;;EAGZ,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC;AAIlD,MAAM,WAAW,aAAa;IAC7B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC5B,2BAA2B;IAC3B,MAAM,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAC7D,wDAAwD;IACxD,IAAI,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,OAAO,CAAA;KAAE,CAAC,GAAG;QAAE,WAAW,EAAE,MAAM,OAAO,CAAA;KAAE,CAAC;IACzG,6BAA6B;IAC7B,OAAO,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;CAChE;AAQD,MAAM,WAAW,aAAa;IAC7B,yEAAyE;IACzE,UAAU,CAAC,EAAE,YAAY,CAAC;CAC1B;AA6CD,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,aAAa,GACrB,cAAc,CAAC,OAAO,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAC,CA2H5D;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC,OAAO,QAAQ,CAAC,CAE7F","sourcesContent":["import { readdir as fsReaddir, stat as fsStat } from \"node:fs/promises\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport nodePath from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { pathExists, resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, renderToolPath, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst lsSchema = Type.Object({\n\tpath: Type.Optional(Type.String({ description: \"Directory to list (default: current directory)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of entries to return (default: 500)\" })),\n});\n\nexport type LsToolInput = Static<typeof lsSchema>;\n\nconst DEFAULT_LIMIT = 500;\n\nexport interface LsToolDetails {\n\ttruncation?: TruncationResult;\n\tentryLimitReached?: number;\n}\n\n/**\n * Pluggable operations for the ls tool.\n * Override these to delegate directory listing to remote systems (for example SSH).\n */\nexport interface LsOperations {\n\t/** Check if path exists */\n\texists: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Get file or directory stats. Throws if not found. */\n\tstat: (absolutePath: string) => Promise<{ isDirectory: () => boolean }> | { isDirectory: () => boolean };\n\t/** Read directory entries */\n\treaddir: (absolutePath: string) => Promise<string[]> | string[];\n}\n\nconst defaultLsOperations: LsOperations = {\n\texists: pathExists,\n\tstat: fsStat,\n\treaddir: fsReaddir,\n};\n\nexport interface LsToolOptions {\n\t/** Custom operations for directory listing. Default: local filesystem */\n\toperations?: LsOperations;\n}\n\nfunction formatLsCall(args: { path?: string; limit?: number } | undefined, theme: Theme, cwd: string): string {\n\tconst limit = args?.limit;\n\tconst pathDisplay = renderToolPath(str(args?.path), theme, cwd, { emptyFallback: \".\" });\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"ls\"))} ${pathDisplay}`;\n\tif (limit !== undefined) {\n\t\ttext += theme.fg(\"toolOutput\", ` (limit ${limit})`);\n\t}\n\treturn text;\n}\n\nfunction formatLsResult(\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: LsToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n): string {\n\tconst output = getTextOutput(result, showImages).trim();\n\tlet text = \"\";\n\tif (output) {\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst maxLines = options.expanded ? lines.length : 20;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n${displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t}\n\t}\n\n\tconst entryLimit = result.details?.entryLimitReached;\n\tconst truncation = result.details?.truncation;\n\tif (entryLimit || truncation?.truncated) {\n\t\tconst warnings: string[] = [];\n\t\tif (entryLimit) warnings.push(`${entryLimit} entries limit`);\n\t\tif (truncation?.truncated) warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);\n\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${warnings.join(\", \")}]`)}`;\n\t}\n\treturn text;\n}\n\nexport function createLsToolDefinition(\n\tcwd: string,\n\toptions?: LsToolOptions,\n): ToolDefinition<typeof lsSchema, LsToolDetails | undefined> {\n\tconst ops = options?.operations ?? defaultLsOperations;\n\treturn {\n\t\tname: \"ls\",\n\t\tlabel: \"ls\",\n\t\tdescription: `List directory contents. Returns entries sorted alphabetically, with '/' suffix for directories. Includes dotfiles. Output is truncated to ${DEFAULT_LIMIT} entries or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first).`,\n\t\tpromptSnippet: \"List directory contents\",\n\t\tparameters: lsSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ path, limit }: { path?: string; limit?: number },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst onAbort = () => reject(new Error(\"Operation aborted\"));\n\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst dirPath = resolveToCwd(path || \".\", cwd);\n\t\t\t\t\t\tconst effectiveLimit = limit ?? DEFAULT_LIMIT;\n\n\t\t\t\t\t\t// Check if path exists.\n\t\t\t\t\t\tif (!(await ops.exists(dirPath))) {\n\t\t\t\t\t\t\treject(new Error(`Path not found: ${dirPath}`));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Check if path is a directory.\n\t\t\t\t\t\tconst stat = await ops.stat(dirPath);\n\t\t\t\t\t\tif (!stat.isDirectory()) {\n\t\t\t\t\t\t\treject(new Error(`Not a directory: ${dirPath}`));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Read directory entries.\n\t\t\t\t\t\tlet entries: string[];\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tentries = await ops.readdir(dirPath);\n\t\t\t\t\t\t} catch (e: any) {\n\t\t\t\t\t\t\treject(new Error(`Cannot read directory: ${e.message}`));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Sort alphabetically, case-insensitive.\n\t\t\t\t\t\tentries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));\n\n\t\t\t\t\t\t// Format entries with directory indicators.\n\t\t\t\t\t\tconst results: string[] = [];\n\t\t\t\t\t\tlet entryLimitReached = false;\n\t\t\t\t\t\tfor (const entry of entries) {\n\t\t\t\t\t\t\tif (results.length >= effectiveLimit) {\n\t\t\t\t\t\t\t\tentryLimitReached = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst fullPath = nodePath.join(dirPath, entry);\n\t\t\t\t\t\t\tlet suffix = \"\";\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst entryStat = await ops.stat(fullPath);\n\t\t\t\t\t\t\t\tif (entryStat.isDirectory()) suffix = \"/\";\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t// Skip entries we cannot stat.\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tresults.push(entry + suffix);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\n\t\t\t\t\t\tif (results.length === 0) {\n\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: \"(empty directory)\" }], details: undefined });\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst rawOutput = results.join(\"\\n\");\n\t\t\t\t\t\t// Apply byte truncation. There is no separate line limit because entry count is already capped.\n\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\tconst details: LsToolDetails = {};\n\t\t\t\t\t\t// Build actionable notices for truncation and entry limits.\n\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\tif (entryLimitReached) {\n\t\t\t\t\t\t\tnotices.push(`${effectiveLimit} entries limit reached. Use limit=${effectiveLimit * 2} for more`);\n\t\t\t\t\t\t\tdetails.entryLimitReached = effectiveLimit;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (notices.length > 0) {\n\t\t\t\t\t\t\toutput += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (e: any) {\n\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\treject(e);\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 text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatLsCall(args, theme, context.cwd));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatLsResult(result as any, options, theme, context.showImages));\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createLsTool(cwd: string, options?: LsToolOptions): AgentTool<typeof lsSchema> {\n\treturn wrapToolDefinition(createLsToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../../src/core/tools/ls.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AAItF,OAAO,EAAiC,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAEnG,QAAA,MAAM,QAAQ;;;EAGZ,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC;AAIlD,MAAM,WAAW,aAAa;IAC7B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC5B,2BAA2B;IAC3B,MAAM,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAC7D,wDAAwD;IACxD,IAAI,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,OAAO,CAAA;KAAE,CAAC,GAAG;QAAE,WAAW,EAAE,MAAM,OAAO,CAAA;KAAE,CAAC;IACzG,6BAA6B;IAC7B,OAAO,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;CAChE;AAQD,MAAM,WAAW,aAAa;IAC7B,yEAAyE;IACzE,UAAU,CAAC,EAAE,YAAY,CAAC;CAC1B;AA6CD,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,aAAa,GACrB,cAAc,CAAC,OAAO,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAC,CA2H5D;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC,OAAO,QAAQ,CAAC,CAE7F"}
@@ -36,7 +36,7 @@ function formatLsResult(result, options, theme, showImages) {
36
36
  const remaining = lines.length - maxLines;
37
37
  text += `\n${displayLines.map((line) => theme.fg("toolOutput", line)).join("\n")}`;
38
38
  if (remaining > 0) {
39
- text += `${theme.fg("muted", `\n... (${remaining} more lines,`)} ${keyHint("app.tools.expand", "to expand")})`;
39
+ text += `${theme.fg("muted", `\n... (${remaining} more lines,`)} ${keyHint("app.tools.expand", "to expand")}${theme.fg("muted", ")")}`;
40
40
  }
41
41
  }
42
42
  const entryLimit = result.details?.entryLimitReached;
@@ -1 +1 @@
1
- {"version":3,"file":"ls.js","sourceRoot":"","sources":["../../../src/core/tools/ls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAExE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,QAAQ,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AAGjF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACvE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MAAa,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;YAChF,OAAO,IAAI,CAAC;QAAA,CACZ;KACD,CAAC;AAAA,CACF;AAED,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,OAAuB,EAA8B;IAC9F,OAAO,kBAAkB,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,CAChE","sourcesContent":["import { readdir as fsReaddir, stat as fsStat } from \"node:fs/promises\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport nodePath from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { pathExists, resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, renderToolPath, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst lsSchema = Type.Object({\n\tpath: Type.Optional(Type.String({ description: \"Directory to list (default: current directory)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of entries to return (default: 500)\" })),\n});\n\nexport type LsToolInput = Static<typeof lsSchema>;\n\nconst DEFAULT_LIMIT = 500;\n\nexport interface LsToolDetails {\n\ttruncation?: TruncationResult;\n\tentryLimitReached?: number;\n}\n\n/**\n * Pluggable operations for the ls tool.\n * Override these to delegate directory listing to remote systems (for example SSH).\n */\nexport interface LsOperations {\n\t/** Check if path exists */\n\texists: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Get file or directory stats. Throws if not found. */\n\tstat: (absolutePath: string) => Promise<{ isDirectory: () => boolean }> | { isDirectory: () => boolean };\n\t/** Read directory entries */\n\treaddir: (absolutePath: string) => Promise<string[]> | string[];\n}\n\nconst defaultLsOperations: LsOperations = {\n\texists: pathExists,\n\tstat: fsStat,\n\treaddir: fsReaddir,\n};\n\nexport interface LsToolOptions {\n\t/** Custom operations for directory listing. Default: local filesystem */\n\toperations?: LsOperations;\n}\n\nfunction formatLsCall(args: { path?: string; limit?: number } | undefined, theme: Theme, cwd: string): string {\n\tconst limit = args?.limit;\n\tconst pathDisplay = renderToolPath(str(args?.path), theme, cwd, { emptyFallback: \".\" });\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"ls\"))} ${pathDisplay}`;\n\tif (limit !== undefined) {\n\t\ttext += theme.fg(\"toolOutput\", ` (limit ${limit})`);\n\t}\n\treturn text;\n}\n\nfunction formatLsResult(\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: LsToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n): string {\n\tconst output = getTextOutput(result, showImages).trim();\n\tlet text = \"\";\n\tif (output) {\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst maxLines = options.expanded ? lines.length : 20;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n${displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t}\n\t}\n\n\tconst entryLimit = result.details?.entryLimitReached;\n\tconst truncation = result.details?.truncation;\n\tif (entryLimit || truncation?.truncated) {\n\t\tconst warnings: string[] = [];\n\t\tif (entryLimit) warnings.push(`${entryLimit} entries limit`);\n\t\tif (truncation?.truncated) warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);\n\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${warnings.join(\", \")}]`)}`;\n\t}\n\treturn text;\n}\n\nexport function createLsToolDefinition(\n\tcwd: string,\n\toptions?: LsToolOptions,\n): ToolDefinition<typeof lsSchema, LsToolDetails | undefined> {\n\tconst ops = options?.operations ?? defaultLsOperations;\n\treturn {\n\t\tname: \"ls\",\n\t\tlabel: \"ls\",\n\t\tdescription: `List directory contents. Returns entries sorted alphabetically, with '/' suffix for directories. Includes dotfiles. Output is truncated to ${DEFAULT_LIMIT} entries or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first).`,\n\t\tpromptSnippet: \"List directory contents\",\n\t\tparameters: lsSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ path, limit }: { path?: string; limit?: number },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst onAbort = () => reject(new Error(\"Operation aborted\"));\n\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst dirPath = resolveToCwd(path || \".\", cwd);\n\t\t\t\t\t\tconst effectiveLimit = limit ?? DEFAULT_LIMIT;\n\n\t\t\t\t\t\t// Check if path exists.\n\t\t\t\t\t\tif (!(await ops.exists(dirPath))) {\n\t\t\t\t\t\t\treject(new Error(`Path not found: ${dirPath}`));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Check if path is a directory.\n\t\t\t\t\t\tconst stat = await ops.stat(dirPath);\n\t\t\t\t\t\tif (!stat.isDirectory()) {\n\t\t\t\t\t\t\treject(new Error(`Not a directory: ${dirPath}`));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Read directory entries.\n\t\t\t\t\t\tlet entries: string[];\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tentries = await ops.readdir(dirPath);\n\t\t\t\t\t\t} catch (e: any) {\n\t\t\t\t\t\t\treject(new Error(`Cannot read directory: ${e.message}`));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Sort alphabetically, case-insensitive.\n\t\t\t\t\t\tentries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));\n\n\t\t\t\t\t\t// Format entries with directory indicators.\n\t\t\t\t\t\tconst results: string[] = [];\n\t\t\t\t\t\tlet entryLimitReached = false;\n\t\t\t\t\t\tfor (const entry of entries) {\n\t\t\t\t\t\t\tif (results.length >= effectiveLimit) {\n\t\t\t\t\t\t\t\tentryLimitReached = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst fullPath = nodePath.join(dirPath, entry);\n\t\t\t\t\t\t\tlet suffix = \"\";\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst entryStat = await ops.stat(fullPath);\n\t\t\t\t\t\t\t\tif (entryStat.isDirectory()) suffix = \"/\";\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t// Skip entries we cannot stat.\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tresults.push(entry + suffix);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\n\t\t\t\t\t\tif (results.length === 0) {\n\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: \"(empty directory)\" }], details: undefined });\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst rawOutput = results.join(\"\\n\");\n\t\t\t\t\t\t// Apply byte truncation. There is no separate line limit because entry count is already capped.\n\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\tconst details: LsToolDetails = {};\n\t\t\t\t\t\t// Build actionable notices for truncation and entry limits.\n\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\tif (entryLimitReached) {\n\t\t\t\t\t\t\tnotices.push(`${effectiveLimit} entries limit reached. Use limit=${effectiveLimit * 2} for more`);\n\t\t\t\t\t\t\tdetails.entryLimitReached = effectiveLimit;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (notices.length > 0) {\n\t\t\t\t\t\t\toutput += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (e: any) {\n\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\treject(e);\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 text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatLsCall(args, theme, context.cwd));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatLsResult(result as any, options, theme, context.showImages));\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createLsTool(cwd: string, options?: LsToolOptions): AgentTool<typeof lsSchema> {\n\treturn wrapToolDefinition(createLsToolDefinition(cwd, options));\n}\n"]}
1
+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AAC,IAAI,EAAE,KAAK,EAAE,OAAO;YAC9B,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;YACrD,OAAO,IAAI,CAAC;QACb,CAAC;QACD,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;YAC3C,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAa,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;YAChF,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,OAAuB;IAChE,OAAO,kBAAkB,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { readdir as fsReaddir, stat as fsStat } from \"node:fs/promises\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport nodePath from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { pathExists, resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, renderToolPath, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst lsSchema = Type.Object({\n\tpath: Type.Optional(Type.String({ description: \"Directory to list (default: current directory)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of entries to return (default: 500)\" })),\n});\n\nexport type LsToolInput = Static<typeof lsSchema>;\n\nconst DEFAULT_LIMIT = 500;\n\nexport interface LsToolDetails {\n\ttruncation?: TruncationResult;\n\tentryLimitReached?: number;\n}\n\n/**\n * Pluggable operations for the ls tool.\n * Override these to delegate directory listing to remote systems (for example SSH).\n */\nexport interface LsOperations {\n\t/** Check if path exists */\n\texists: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Get file or directory stats. Throws if not found. */\n\tstat: (absolutePath: string) => Promise<{ isDirectory: () => boolean }> | { isDirectory: () => boolean };\n\t/** Read directory entries */\n\treaddir: (absolutePath: string) => Promise<string[]> | string[];\n}\n\nconst defaultLsOperations: LsOperations = {\n\texists: pathExists,\n\tstat: fsStat,\n\treaddir: fsReaddir,\n};\n\nexport interface LsToolOptions {\n\t/** Custom operations for directory listing. Default: local filesystem */\n\toperations?: LsOperations;\n}\n\nfunction formatLsCall(args: { path?: string; limit?: number } | undefined, theme: Theme, cwd: string): string {\n\tconst limit = args?.limit;\n\tconst pathDisplay = renderToolPath(str(args?.path), theme, cwd, { emptyFallback: \".\" });\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"ls\"))} ${pathDisplay}`;\n\tif (limit !== undefined) {\n\t\ttext += theme.fg(\"toolOutput\", ` (limit ${limit})`);\n\t}\n\treturn text;\n}\n\nfunction formatLsResult(\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: LsToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n): string {\n\tconst output = getTextOutput(result, showImages).trim();\n\tlet text = \"\";\n\tif (output) {\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst maxLines = options.expanded ? lines.length : 20;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n${displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")}${theme.fg(\"muted\", \")\")}`;\n\t\t}\n\t}\n\n\tconst entryLimit = result.details?.entryLimitReached;\n\tconst truncation = result.details?.truncation;\n\tif (entryLimit || truncation?.truncated) {\n\t\tconst warnings: string[] = [];\n\t\tif (entryLimit) warnings.push(`${entryLimit} entries limit`);\n\t\tif (truncation?.truncated) warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);\n\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${warnings.join(\", \")}]`)}`;\n\t}\n\treturn text;\n}\n\nexport function createLsToolDefinition(\n\tcwd: string,\n\toptions?: LsToolOptions,\n): ToolDefinition<typeof lsSchema, LsToolDetails | undefined> {\n\tconst ops = options?.operations ?? defaultLsOperations;\n\treturn {\n\t\tname: \"ls\",\n\t\tlabel: \"ls\",\n\t\tdescription: `List directory contents. Returns entries sorted alphabetically, with '/' suffix for directories. Includes dotfiles. Output is truncated to ${DEFAULT_LIMIT} entries or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first).`,\n\t\tpromptSnippet: \"List directory contents\",\n\t\tparameters: lsSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ path, limit }: { path?: string; limit?: number },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst onAbort = () => reject(new Error(\"Operation aborted\"));\n\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst dirPath = resolveToCwd(path || \".\", cwd);\n\t\t\t\t\t\tconst effectiveLimit = limit ?? DEFAULT_LIMIT;\n\n\t\t\t\t\t\t// Check if path exists.\n\t\t\t\t\t\tif (!(await ops.exists(dirPath))) {\n\t\t\t\t\t\t\treject(new Error(`Path not found: ${dirPath}`));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Check if path is a directory.\n\t\t\t\t\t\tconst stat = await ops.stat(dirPath);\n\t\t\t\t\t\tif (!stat.isDirectory()) {\n\t\t\t\t\t\t\treject(new Error(`Not a directory: ${dirPath}`));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Read directory entries.\n\t\t\t\t\t\tlet entries: string[];\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tentries = await ops.readdir(dirPath);\n\t\t\t\t\t\t} catch (e: any) {\n\t\t\t\t\t\t\treject(new Error(`Cannot read directory: ${e.message}`));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Sort alphabetically, case-insensitive.\n\t\t\t\t\t\tentries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));\n\n\t\t\t\t\t\t// Format entries with directory indicators.\n\t\t\t\t\t\tconst results: string[] = [];\n\t\t\t\t\t\tlet entryLimitReached = false;\n\t\t\t\t\t\tfor (const entry of entries) {\n\t\t\t\t\t\t\tif (results.length >= effectiveLimit) {\n\t\t\t\t\t\t\t\tentryLimitReached = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst fullPath = nodePath.join(dirPath, entry);\n\t\t\t\t\t\t\tlet suffix = \"\";\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst entryStat = await ops.stat(fullPath);\n\t\t\t\t\t\t\t\tif (entryStat.isDirectory()) suffix = \"/\";\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t// Skip entries we cannot stat.\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tresults.push(entry + suffix);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\n\t\t\t\t\t\tif (results.length === 0) {\n\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: \"(empty directory)\" }], details: undefined });\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst rawOutput = results.join(\"\\n\");\n\t\t\t\t\t\t// Apply byte truncation. There is no separate line limit because entry count is already capped.\n\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\tconst details: LsToolDetails = {};\n\t\t\t\t\t\t// Build actionable notices for truncation and entry limits.\n\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\tif (entryLimitReached) {\n\t\t\t\t\t\t\tnotices.push(`${effectiveLimit} entries limit reached. Use limit=${effectiveLimit * 2} for more`);\n\t\t\t\t\t\t\tdetails.entryLimitReached = effectiveLimit;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (notices.length > 0) {\n\t\t\t\t\t\t\toutput += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (e: any) {\n\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\treject(e);\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 text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatLsCall(args, theme, context.cwd));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatLsResult(result as any, options, theme, context.showImages));\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createLsTool(cwd: string, options?: LsToolOptions): AgentTool<typeof lsSchema> {\n\treturn wrapToolDefinition(createLsToolDefinition(cwd, options));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"output-accumulator.d.ts","sourceRoot":"","sources":["../../../src/core/tools/output-accumulator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwC,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAE1G,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAWD;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAE7C,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,wBAAwB,CAAQ;IACxC,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,cAAc,CAA0B;IAEhD,YAAY,OAAO,GAAE,wBAA6B,EAKjD;IAED,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAczB;IAED,MAAM,IAAI,IAAI,CASb;IAED,QAAQ,CAAC,OAAO,GAAE;QAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,cAAc,CA4BvE;IAEK,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAqBnC;IAED,gBAAgB,IAAI,MAAM,CAEzB;IAED,OAAO,CAAC,iBAAiB;IA+BzB,OAAO,CAAC,QAAQ;IAiBhB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,cAAc;CAWtB","sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport { createWriteStream, type WriteStream } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, type TruncationResult, truncateTail } from \"./truncate.ts\";\n\nexport interface OutputAccumulatorOptions {\n\tmaxLines?: number;\n\tmaxBytes?: number;\n\ttempFilePrefix?: string;\n}\n\nexport interface OutputSnapshot {\n\tcontent: string;\n\ttruncation: TruncationResult;\n\tfullOutputPath?: string;\n}\n\nfunction defaultTempFilePath(prefix: string): string {\n\tconst id = randomBytes(8).toString(\"hex\");\n\treturn join(tmpdir(), `${prefix}-${id}.log`);\n}\n\nfunction byteLength(text: string): number {\n\treturn Buffer.byteLength(text, \"utf-8\");\n}\n\n/**\n * Incrementally tracks streaming output with bounded memory.\n *\n * Appends decode chunks with a streaming UTF-8 decoder, keeps only a decoded\n * tail for display snapshots, and opens a temp file when the full output needs\n * to be preserved.\n */\nexport class OutputAccumulator {\n\tprivate readonly maxLines: number;\n\tprivate readonly maxBytes: number;\n\tprivate readonly maxRollingBytes: number;\n\tprivate readonly tempFilePrefix: string;\n\tprivate readonly decoder = new TextDecoder();\n\n\tprivate rawChunks: Buffer[] = [];\n\tprivate tailText = \"\";\n\tprivate tailBytes = 0;\n\tprivate tailStartsAtLineBoundary = true;\n\tprivate totalRawBytes = 0;\n\tprivate totalDecodedBytes = 0;\n\tprivate completedLines = 0;\n\tprivate totalLines = 0;\n\tprivate currentLineBytes = 0;\n\tprivate hasOpenLine = false;\n\tprivate finished = false;\n\n\tprivate tempFilePath: string | undefined;\n\tprivate tempFileStream: WriteStream | undefined;\n\n\tconstructor(options: OutputAccumulatorOptions = {}) {\n\t\tthis.maxLines = options.maxLines ?? DEFAULT_MAX_LINES;\n\t\tthis.maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n\t\tthis.maxRollingBytes = Math.max(this.maxBytes * 2, 1);\n\t\tthis.tempFilePrefix = options.tempFilePrefix ?? \"pi-output\";\n\t}\n\n\tappend(data: Buffer): void {\n\t\tif (this.finished) {\n\t\t\tthrow new Error(\"Cannot append to a finished output accumulator\");\n\t\t}\n\n\t\tthis.totalRawBytes += data.length;\n\t\tthis.appendDecodedText(this.decoder.decode(data, { stream: true }));\n\n\t\tif (this.tempFileStream || this.shouldUseTempFile()) {\n\t\t\tthis.ensureTempFile();\n\t\t\tthis.tempFileStream?.write(data);\n\t\t} else if (data.length > 0) {\n\t\t\tthis.rawChunks.push(data);\n\t\t}\n\t}\n\n\tfinish(): void {\n\t\tif (this.finished) {\n\t\t\treturn;\n\t\t}\n\t\tthis.finished = true;\n\t\tthis.appendDecodedText(this.decoder.decode());\n\t\tif (this.shouldUseTempFile()) {\n\t\t\tthis.ensureTempFile();\n\t\t}\n\t}\n\n\tsnapshot(options: { persistIfTruncated?: boolean } = {}): OutputSnapshot {\n\t\tconst tailTruncation = truncateTail(this.getSnapshotText(), {\n\t\t\tmaxLines: this.maxLines,\n\t\t\tmaxBytes: this.maxBytes,\n\t\t});\n\t\tconst truncated = this.totalLines > this.maxLines || this.totalDecodedBytes > this.maxBytes;\n\t\tconst truncatedBy = truncated\n\t\t\t? (tailTruncation.truncatedBy ?? (this.totalDecodedBytes > this.maxBytes ? \"bytes\" : \"lines\"))\n\t\t\t: null;\n\t\tconst truncation: TruncationResult = {\n\t\t\t...tailTruncation,\n\t\t\ttruncated,\n\t\t\ttruncatedBy,\n\t\t\ttotalLines: this.totalLines,\n\t\t\ttotalBytes: this.totalDecodedBytes,\n\t\t\tmaxLines: this.maxLines,\n\t\t\tmaxBytes: this.maxBytes,\n\t\t};\n\n\t\tif (options.persistIfTruncated && truncation.truncated) {\n\t\t\tthis.ensureTempFile();\n\t\t}\n\n\t\treturn {\n\t\t\tcontent: truncation.content,\n\t\t\ttruncation,\n\t\t\tfullOutputPath: this.tempFilePath,\n\t\t};\n\t}\n\n\tasync closeTempFile(): Promise<void> {\n\t\tif (!this.tempFileStream) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst stream = this.tempFileStream;\n\t\tthis.tempFileStream = undefined;\n\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst onError = (error: Error) => {\n\t\t\t\tstream.off(\"finish\", onFinish);\n\t\t\t\treject(error);\n\t\t\t};\n\t\t\tconst onFinish = () => {\n\t\t\t\tstream.off(\"error\", onError);\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tstream.once(\"error\", onError);\n\t\t\tstream.once(\"finish\", onFinish);\n\t\t\tstream.end();\n\t\t});\n\t}\n\n\tgetLastLineBytes(): number {\n\t\treturn this.currentLineBytes;\n\t}\n\n\tprivate appendDecodedText(text: string): void {\n\t\tif (text.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst bytes = byteLength(text);\n\t\tthis.totalDecodedBytes += bytes;\n\t\tthis.tailText += text;\n\t\tthis.tailBytes += bytes;\n\t\tif (this.tailBytes > this.maxRollingBytes * 2) {\n\t\t\tthis.trimTail();\n\t\t}\n\n\t\tlet newlines = 0;\n\t\tlet lastNewline = -1;\n\t\tfor (let i = text.indexOf(\"\\n\"); i !== -1; i = text.indexOf(\"\\n\", i + 1)) {\n\t\t\tnewlines++;\n\t\t\tlastNewline = i;\n\t\t}\n\t\tif (newlines === 0) {\n\t\t\tthis.currentLineBytes += bytes;\n\t\t\tthis.hasOpenLine = true;\n\t\t} else {\n\t\t\tthis.completedLines += newlines;\n\t\t\tconst tail = text.slice(lastNewline + 1);\n\t\t\tthis.currentLineBytes = byteLength(tail);\n\t\t\tthis.hasOpenLine = tail.length > 0;\n\t\t}\n\t\tthis.totalLines = this.completedLines + (this.hasOpenLine ? 1 : 0);\n\t}\n\n\tprivate trimTail(): void {\n\t\tconst buffer = Buffer.from(this.tailText, \"utf-8\");\n\t\tif (buffer.length <= this.maxRollingBytes) {\n\t\t\tthis.tailBytes = buffer.length;\n\t\t\treturn;\n\t\t}\n\n\t\tlet start = buffer.length - this.maxRollingBytes;\n\t\twhile (start < buffer.length && (buffer[start] & 0xc0) === 0x80) {\n\t\t\tstart++;\n\t\t}\n\n\t\tthis.tailStartsAtLineBoundary = start === 0 ? this.tailStartsAtLineBoundary : buffer[start - 1] === 0x0a;\n\t\tthis.tailText = buffer.subarray(start).toString(\"utf-8\");\n\t\tthis.tailBytes = byteLength(this.tailText);\n\t}\n\n\tprivate getSnapshotText(): string {\n\t\tif (this.tailStartsAtLineBoundary) {\n\t\t\treturn this.tailText;\n\t\t}\n\n\t\tconst firstNewline = this.tailText.indexOf(\"\\n\");\n\t\treturn firstNewline === -1 ? this.tailText : this.tailText.slice(firstNewline + 1);\n\t}\n\n\tprivate shouldUseTempFile(): boolean {\n\t\treturn (\n\t\t\tthis.totalRawBytes > this.maxBytes || this.totalDecodedBytes > this.maxBytes || this.totalLines > this.maxLines\n\t\t);\n\t}\n\n\tprivate ensureTempFile(): void {\n\t\tif (this.tempFilePath) {\n\t\t\treturn;\n\t\t}\n\t\tthis.tempFilePath = defaultTempFilePath(this.tempFilePrefix);\n\t\tthis.tempFileStream = createWriteStream(this.tempFilePath);\n\t\tfor (const chunk of this.rawChunks) {\n\t\t\tthis.tempFileStream.write(chunk);\n\t\t}\n\t\tthis.rawChunks = [];\n\t}\n}\n"]}
1
+ {"version":3,"file":"output-accumulator.d.ts","sourceRoot":"","sources":["../../../src/core/tools/output-accumulator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwC,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAE1G,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAWD;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAE7C,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,wBAAwB,CAAQ;IACxC,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,cAAc,CAA0B;IAEhD,YAAY,OAAO,GAAE,wBAA6B,EAKjD;IAED,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAczB;IAED,MAAM,IAAI,IAAI,CASb;IAED,QAAQ,CAAC,OAAO,GAAE;QAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,cAAc,CA4BvE;IAEK,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAqBnC;IAED,gBAAgB,IAAI,MAAM,CAEzB;IAED,OAAO,CAAC,iBAAiB;IA+BzB,OAAO,CAAC,QAAQ;IAiBhB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,cAAc;CAWtB"}
@@ -18,25 +18,19 @@ function byteLength(text) {
18
18
  * to be preserved.
19
19
  */
20
20
  export class OutputAccumulator {
21
- maxLines;
22
- maxBytes;
23
- maxRollingBytes;
24
- tempFilePrefix;
25
- decoder = new TextDecoder();
26
- rawChunks = [];
27
- tailText = "";
28
- tailBytes = 0;
29
- tailStartsAtLineBoundary = true;
30
- totalRawBytes = 0;
31
- totalDecodedBytes = 0;
32
- completedLines = 0;
33
- totalLines = 0;
34
- currentLineBytes = 0;
35
- hasOpenLine = false;
36
- finished = false;
37
- tempFilePath;
38
- tempFileStream;
39
21
  constructor(options = {}) {
22
+ this.decoder = new TextDecoder();
23
+ this.rawChunks = [];
24
+ this.tailText = "";
25
+ this.tailBytes = 0;
26
+ this.tailStartsAtLineBoundary = true;
27
+ this.totalRawBytes = 0;
28
+ this.totalDecodedBytes = 0;
29
+ this.completedLines = 0;
30
+ this.totalLines = 0;
31
+ this.currentLineBytes = 0;
32
+ this.hasOpenLine = false;
33
+ this.finished = false;
40
34
  this.maxLines = options.maxLines ?? DEFAULT_MAX_LINES;
41
35
  this.maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
42
36
  this.maxRollingBytes = Math.max(this.maxBytes * 2, 1);