strands-darwin 0.0.3

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 (417) hide show
  1. package/README.md +140 -0
  2. package/README.zh-CN.md +140 -0
  3. package/dist/patches/@strands-agents+sdk+1.16.0.patch +1443 -0
  4. package/dist/src/agent/background-delegation.d.ts +67 -0
  5. package/dist/src/agent/background-delegation.js +159 -0
  6. package/dist/src/agent/background-delegation.js.map +1 -0
  7. package/dist/src/agent/call-stats.d.ts +118 -0
  8. package/dist/src/agent/call-stats.js +128 -0
  9. package/dist/src/agent/call-stats.js.map +1 -0
  10. package/dist/src/agent/compact.d.ts +108 -0
  11. package/dist/src/agent/compact.js +192 -0
  12. package/dist/src/agent/compact.js.map +1 -0
  13. package/dist/src/agent/context-anchor.d.ts +64 -0
  14. package/dist/src/agent/context-anchor.js +43 -0
  15. package/dist/src/agent/context-anchor.js.map +1 -0
  16. package/dist/src/agent/cost.d.ts +56 -0
  17. package/dist/src/agent/cost.js +44 -0
  18. package/dist/src/agent/cost.js.map +1 -0
  19. package/dist/src/agent/diagnostics.d.ts +212 -0
  20. package/dist/src/agent/diagnostics.js +374 -0
  21. package/dist/src/agent/diagnostics.js.map +1 -0
  22. package/dist/src/agent/instructions.d.ts +54 -0
  23. package/dist/src/agent/instructions.js +118 -0
  24. package/dist/src/agent/instructions.js.map +1 -0
  25. package/dist/src/agent/max-tokens-recovery.d.ts +17 -0
  26. package/dist/src/agent/max-tokens-recovery.js +65 -0
  27. package/dist/src/agent/max-tokens-recovery.js.map +1 -0
  28. package/dist/src/agent/model-call-budget.d.ts +8 -0
  29. package/dist/src/agent/model-call-budget.js +24 -0
  30. package/dist/src/agent/model-call-budget.js.map +1 -0
  31. package/dist/src/agent/model-retry.d.ts +134 -0
  32. package/dist/src/agent/model-retry.js +256 -0
  33. package/dist/src/agent/model-retry.js.map +1 -0
  34. package/dist/src/agent/permission-rules.d.ts +47 -0
  35. package/dist/src/agent/permission-rules.js +260 -0
  36. package/dist/src/agent/permission-rules.js.map +1 -0
  37. package/dist/src/agent/permission.d.ts +361 -0
  38. package/dist/src/agent/permission.js +797 -0
  39. package/dist/src/agent/permission.js.map +1 -0
  40. package/dist/src/agent/prompt-cache.d.ts +66 -0
  41. package/dist/src/agent/prompt-cache.js +194 -0
  42. package/dist/src/agent/prompt-cache.js.map +1 -0
  43. package/dist/src/agent/refusal.d.ts +20 -0
  44. package/dist/src/agent/refusal.js +23 -0
  45. package/dist/src/agent/refusal.js.map +1 -0
  46. package/dist/src/agent/retry-guard.d.ts +26 -0
  47. package/dist/src/agent/retry-guard.js +193 -0
  48. package/dist/src/agent/retry-guard.js.map +1 -0
  49. package/dist/src/agent/rewind.d.ts +29 -0
  50. package/dist/src/agent/rewind.js +118 -0
  51. package/dist/src/agent/rewind.js.map +1 -0
  52. package/dist/src/agent/runtime.d.ts +814 -0
  53. package/dist/src/agent/runtime.js +1596 -0
  54. package/dist/src/agent/runtime.js.map +1 -0
  55. package/dist/src/agent/safety-classifier.d.ts +11 -0
  56. package/dist/src/agent/safety-classifier.js +0 -0
  57. package/dist/src/agent/safety-classifier.js.map +1 -0
  58. package/dist/src/agent/sdk-logging.d.ts +49 -0
  59. package/dist/src/agent/sdk-logging.js +110 -0
  60. package/dist/src/agent/sdk-logging.js.map +1 -0
  61. package/dist/src/agent/session.d.ts +102 -0
  62. package/dist/src/agent/session.js +244 -0
  63. package/dist/src/agent/session.js.map +1 -0
  64. package/dist/src/agent/stream-resumption.d.ts +16 -0
  65. package/dist/src/agent/stream-resumption.js +33 -0
  66. package/dist/src/agent/stream-resumption.js.map +1 -0
  67. package/dist/src/agent/system-prompt.d.ts +50 -0
  68. package/dist/src/agent/system-prompt.js +161 -0
  69. package/dist/src/agent/system-prompt.js.map +1 -0
  70. package/dist/src/agent/thinking.d.ts +99 -0
  71. package/dist/src/agent/thinking.js +145 -0
  72. package/dist/src/agent/thinking.js.map +1 -0
  73. package/dist/src/agent/usage.d.ts +132 -0
  74. package/dist/src/agent/usage.js +233 -0
  75. package/dist/src/agent/usage.js.map +1 -0
  76. package/dist/src/agent/working-context.d.ts +51 -0
  77. package/dist/src/agent/working-context.js +160 -0
  78. package/dist/src/agent/working-context.js.map +1 -0
  79. package/dist/src/agents/child-recipe.d.ts +33 -0
  80. package/dist/src/agents/child-recipe.js +98 -0
  81. package/dist/src/agents/child-recipe.js.map +1 -0
  82. package/dist/src/agents/concurrency-limit.d.ts +25 -0
  83. package/dist/src/agents/concurrency-limit.js +43 -0
  84. package/dist/src/agents/concurrency-limit.js.map +1 -0
  85. package/dist/src/agents/dispatch-registry.d.ts +180 -0
  86. package/dist/src/agents/dispatch-registry.js +289 -0
  87. package/dist/src/agents/dispatch-registry.js.map +1 -0
  88. package/dist/src/agents/failed-child-text.d.ts +44 -0
  89. package/dist/src/agents/failed-child-text.js +69 -0
  90. package/dist/src/agents/failed-child-text.js.map +1 -0
  91. package/dist/src/agents/loader.d.ts +26 -0
  92. package/dist/src/agents/loader.js +134 -0
  93. package/dist/src/agents/loader.js.map +1 -0
  94. package/dist/src/agents/report-projection.d.ts +31 -0
  95. package/dist/src/agents/report-projection.js +125 -0
  96. package/dist/src/agents/report-projection.js.map +1 -0
  97. package/dist/src/agents/subagent-tool.d.ts +61 -0
  98. package/dist/src/agents/subagent-tool.js +180 -0
  99. package/dist/src/agents/subagent-tool.js.map +1 -0
  100. package/dist/src/agents/workflow-tool.d.ts +85 -0
  101. package/dist/src/agents/workflow-tool.js +530 -0
  102. package/dist/src/agents/workflow-tool.js.map +1 -0
  103. package/dist/src/cli-args.d.ts +39 -0
  104. package/dist/src/cli-args.js +198 -0
  105. package/dist/src/cli-args.js.map +1 -0
  106. package/dist/src/cli-doctor.d.ts +26 -0
  107. package/dist/src/cli-doctor.js +398 -0
  108. package/dist/src/cli-doctor.js.map +1 -0
  109. package/dist/src/cli-main.d.ts +1 -0
  110. package/dist/src/cli-main.js +279 -0
  111. package/dist/src/cli-main.js.map +1 -0
  112. package/dist/src/cli-sessions.d.ts +17 -0
  113. package/dist/src/cli-sessions.js +136 -0
  114. package/dist/src/cli-sessions.js.map +1 -0
  115. package/dist/src/cli-trajectory.d.ts +37 -0
  116. package/dist/src/cli-trajectory.js +303 -0
  117. package/dist/src/cli-trajectory.js.map +1 -0
  118. package/dist/src/cli-usage.d.ts +18 -0
  119. package/dist/src/cli-usage.js +53 -0
  120. package/dist/src/cli-usage.js.map +1 -0
  121. package/dist/src/cli.d.ts +2 -0
  122. package/dist/src/cli.js +29 -0
  123. package/dist/src/cli.js.map +1 -0
  124. package/dist/src/commands/custom-commands.d.ts +43 -0
  125. package/dist/src/commands/custom-commands.js +155 -0
  126. package/dist/src/commands/custom-commands.js.map +1 -0
  127. package/dist/src/commands/workflow-command.d.ts +26 -0
  128. package/dist/src/commands/workflow-command.js +56 -0
  129. package/dist/src/commands/workflow-command.js.map +1 -0
  130. package/dist/src/config.d.ts +463 -0
  131. package/dist/src/config.js +1457 -0
  132. package/dist/src/config.js.map +1 -0
  133. package/dist/src/context-overflow-error.d.ts +7 -0
  134. package/dist/src/context-overflow-error.js +26 -0
  135. package/dist/src/context-overflow-error.js.map +1 -0
  136. package/dist/src/dev-repl.d.ts +1 -0
  137. package/dist/src/dev-repl.js +365 -0
  138. package/dist/src/dev-repl.js.map +1 -0
  139. package/dist/src/headless-protocol.d.ts +147 -0
  140. package/dist/src/headless-protocol.js +359 -0
  141. package/dist/src/headless-protocol.js.map +1 -0
  142. package/dist/src/headless-runner.d.ts +30 -0
  143. package/dist/src/headless-runner.js +405 -0
  144. package/dist/src/headless-runner.js.map +1 -0
  145. package/dist/src/headless-stdin.d.ts +28 -0
  146. package/dist/src/headless-stdin.js +78 -0
  147. package/dist/src/headless-stdin.js.map +1 -0
  148. package/dist/src/headless.d.ts +106 -0
  149. package/dist/src/headless.js +229 -0
  150. package/dist/src/headless.js.map +1 -0
  151. package/dist/src/hooks/codex-hook-runner.d.ts +92 -0
  152. package/dist/src/hooks/codex-hook-runner.js +446 -0
  153. package/dist/src/hooks/codex-hook-runner.js.map +1 -0
  154. package/dist/src/hooks/codex-hooks.d.ts +23 -0
  155. package/dist/src/hooks/codex-hooks.js +152 -0
  156. package/dist/src/hooks/codex-hooks.js.map +1 -0
  157. package/dist/src/hooks/hook-process.d.ts +23 -0
  158. package/dist/src/hooks/hook-process.js +241 -0
  159. package/dist/src/hooks/hook-process.js.map +1 -0
  160. package/dist/src/hooks/lifecycle-hooks.d.ts +37 -0
  161. package/dist/src/hooks/lifecycle-hooks.js +153 -0
  162. package/dist/src/hooks/lifecycle-hooks.js.map +1 -0
  163. package/dist/src/hooks/tool-hooks.d.ts +63 -0
  164. package/dist/src/hooks/tool-hooks.js +350 -0
  165. package/dist/src/hooks/tool-hooks.js.map +1 -0
  166. package/dist/src/mcp/codegraph-preflight.d.ts +29 -0
  167. package/dist/src/mcp/codegraph-preflight.js +232 -0
  168. package/dist/src/mcp/codegraph-preflight.js.map +1 -0
  169. package/dist/src/mcp/registry.d.ts +133 -0
  170. package/dist/src/mcp/registry.js +209 -0
  171. package/dist/src/mcp/registry.js.map +1 -0
  172. package/dist/src/mcp/web-search-empty-results.d.ts +14 -0
  173. package/dist/src/mcp/web-search-empty-results.js +94 -0
  174. package/dist/src/mcp/web-search-empty-results.js.map +1 -0
  175. package/dist/src/memory/command.d.ts +11 -0
  176. package/dist/src/memory/command.js +253 -0
  177. package/dist/src/memory/command.js.map +1 -0
  178. package/dist/src/memory/controller.d.ts +51 -0
  179. package/dist/src/memory/controller.js +316 -0
  180. package/dist/src/memory/controller.js.map +1 -0
  181. package/dist/src/memory/prompt.d.ts +4 -0
  182. package/dist/src/memory/prompt.js +22 -0
  183. package/dist/src/memory/prompt.js.map +1 -0
  184. package/dist/src/memory/scheduler.d.ts +33 -0
  185. package/dist/src/memory/scheduler.js +134 -0
  186. package/dist/src/memory/scheduler.js.map +1 -0
  187. package/dist/src/memory/state.d.ts +112 -0
  188. package/dist/src/memory/state.js +355 -0
  189. package/dist/src/memory/state.js.map +1 -0
  190. package/dist/src/memory/store.d.ts +19 -0
  191. package/dist/src/memory/store.js +130 -0
  192. package/dist/src/memory/store.js.map +1 -0
  193. package/dist/src/memory/tools.d.ts +29 -0
  194. package/dist/src/memory/tools.js +22 -0
  195. package/dist/src/memory/tools.js.map +1 -0
  196. package/dist/src/memory/validation.d.ts +33 -0
  197. package/dist/src/memory/validation.js +159 -0
  198. package/dist/src/memory/validation.js.map +1 -0
  199. package/dist/src/npm-package/generate-patch.d.ts +23 -0
  200. package/dist/src/npm-package/generate-patch.js +88 -0
  201. package/dist/src/npm-package/generate-patch.js.map +1 -0
  202. package/dist/src/npm-package/patch-package-format.d.ts +43 -0
  203. package/dist/src/npm-package/patch-package-format.js +66 -0
  204. package/dist/src/npm-package/patch-package-format.js.map +1 -0
  205. package/dist/src/paths.d.ts +39 -0
  206. package/dist/src/paths.js +105 -0
  207. package/dist/src/paths.js.map +1 -0
  208. package/dist/src/pricing/cost.d.ts +182 -0
  209. package/dist/src/pricing/cost.js +215 -0
  210. package/dist/src/pricing/cost.js.map +1 -0
  211. package/dist/src/pricing/model-prices.d.ts +112 -0
  212. package/dist/src/pricing/model-prices.js +320 -0
  213. package/dist/src/pricing/model-prices.js.map +1 -0
  214. package/dist/src/sdk-patch-preflight.d.ts +23 -0
  215. package/dist/src/sdk-patch-preflight.js +71 -0
  216. package/dist/src/sdk-patch-preflight.js.map +1 -0
  217. package/dist/src/skills/builtin/commit-message/SKILL.md +45 -0
  218. package/dist/src/skills/builtin/commit-message/references/types.md +8 -0
  219. package/dist/src/skills/builtin/developer/SKILL.md +107 -0
  220. package/dist/src/skills/builtin/self-evolution-research/SKILL.md +150 -0
  221. package/dist/src/skills/builtin/self-evolution-research/scripts/roll-research-path.mjs +208 -0
  222. package/dist/src/skills/builtin/self-reflection/SKILL.md +172 -0
  223. package/dist/src/skills/builtin/self-reflection/references/reflection-template.md +90 -0
  224. package/dist/src/skills/builtin/self-reflection/scripts/locate-trajectory.mjs +175 -0
  225. package/dist/src/skills/loader.d.ts +26 -0
  226. package/dist/src/skills/loader.js +186 -0
  227. package/dist/src/skills/loader.js.map +1 -0
  228. package/dist/src/skills/plugin.d.ts +34 -0
  229. package/dist/src/skills/plugin.js +137 -0
  230. package/dist/src/skills/plugin.js.map +1 -0
  231. package/dist/src/skills/prompt.d.ts +8 -0
  232. package/dist/src/skills/prompt.js +214 -0
  233. package/dist/src/skills/prompt.js.map +1 -0
  234. package/dist/src/skills/resource-safety.d.ts +15 -0
  235. package/dist/src/skills/resource-safety.js +149 -0
  236. package/dist/src/skills/resource-safety.js.map +1 -0
  237. package/dist/src/tools/background-bash.d.ts +95 -0
  238. package/dist/src/tools/background-bash.js +639 -0
  239. package/dist/src/tools/background-bash.js.map +1 -0
  240. package/dist/src/tools/background-tail.d.ts +28 -0
  241. package/dist/src/tools/background-tail.js +75 -0
  242. package/dist/src/tools/background-tail.js.map +1 -0
  243. package/dist/src/tools/background-wait-contract.d.ts +4 -0
  244. package/dist/src/tools/background-wait-contract.js +7 -0
  245. package/dist/src/tools/background-wait-contract.js.map +1 -0
  246. package/dist/src/tools/file-editor-serial.d.ts +24 -0
  247. package/dist/src/tools/file-editor-serial.js +99 -0
  248. package/dist/src/tools/file-editor-serial.js.map +1 -0
  249. package/dist/src/tools/image-viewer.d.ts +43 -0
  250. package/dist/src/tools/image-viewer.js +256 -0
  251. package/dist/src/tools/image-viewer.js.map +1 -0
  252. package/dist/src/tools/update-plan.d.ts +30 -0
  253. package/dist/src/tools/update-plan.js +65 -0
  254. package/dist/src/tools/update-plan.js.map +1 -0
  255. package/dist/src/tools/web-fetch.d.ts +70 -0
  256. package/dist/src/tools/web-fetch.js +667 -0
  257. package/dist/src/tools/web-fetch.js.map +1 -0
  258. package/dist/src/trajectory/export.d.ts +31 -0
  259. package/dist/src/trajectory/export.js +116 -0
  260. package/dist/src/trajectory/export.js.map +1 -0
  261. package/dist/src/trajectory/fork.d.ts +19 -0
  262. package/dist/src/trajectory/fork.js +110 -0
  263. package/dist/src/trajectory/fork.js.map +1 -0
  264. package/dist/src/trajectory/memory-tool.d.ts +20 -0
  265. package/dist/src/trajectory/memory-tool.js +98 -0
  266. package/dist/src/trajectory/memory-tool.js.map +1 -0
  267. package/dist/src/trajectory/prompt-history.d.ts +62 -0
  268. package/dist/src/trajectory/prompt-history.js +256 -0
  269. package/dist/src/trajectory/prompt-history.js.map +1 -0
  270. package/dist/src/trajectory/reader.d.ts +21 -0
  271. package/dist/src/trajectory/reader.js +62 -0
  272. package/dist/src/trajectory/reader.js.map +1 -0
  273. package/dist/src/trajectory/record.d.ts +417 -0
  274. package/dist/src/trajectory/record.js +394 -0
  275. package/dist/src/trajectory/record.js.map +1 -0
  276. package/dist/src/trajectory/replay.d.ts +74 -0
  277. package/dist/src/trajectory/replay.js +285 -0
  278. package/dist/src/trajectory/replay.js.map +1 -0
  279. package/dist/src/trajectory/resume-recap.d.ts +43 -0
  280. package/dist/src/trajectory/resume-recap.js +68 -0
  281. package/dist/src/trajectory/resume-recap.js.map +1 -0
  282. package/dist/src/trajectory/search.d.ts +40 -0
  283. package/dist/src/trajectory/search.js +127 -0
  284. package/dist/src/trajectory/search.js.map +1 -0
  285. package/dist/src/trajectory/spend.d.ts +157 -0
  286. package/dist/src/trajectory/spend.js +264 -0
  287. package/dist/src/trajectory/spend.js.map +1 -0
  288. package/dist/src/trajectory/stream.d.ts +30 -0
  289. package/dist/src/trajectory/stream.js +30 -0
  290. package/dist/src/trajectory/stream.js.map +1 -0
  291. package/dist/src/trajectory/writer.d.ts +310 -0
  292. package/dist/src/trajectory/writer.js +636 -0
  293. package/dist/src/trajectory/writer.js.map +1 -0
  294. package/dist/src/tui/App.d.ts +109 -0
  295. package/dist/src/tui/App.js +2660 -0
  296. package/dist/src/tui/App.js.map +1 -0
  297. package/dist/src/tui/InputBox.d.ts +90 -0
  298. package/dist/src/tui/InputBox.js +129 -0
  299. package/dist/src/tui/InputBox.js.map +1 -0
  300. package/dist/src/tui/MarkdownText.d.ts +16 -0
  301. package/dist/src/tui/MarkdownText.js +117 -0
  302. package/dist/src/tui/MarkdownText.js.map +1 -0
  303. package/dist/src/tui/MessageList.d.ts +27 -0
  304. package/dist/src/tui/MessageList.js +61 -0
  305. package/dist/src/tui/MessageList.js.map +1 -0
  306. package/dist/src/tui/PermissionPrompt.d.ts +18 -0
  307. package/dist/src/tui/PermissionPrompt.js +114 -0
  308. package/dist/src/tui/PermissionPrompt.js.map +1 -0
  309. package/dist/src/tui/PlanChecklist.d.ts +7 -0
  310. package/dist/src/tui/PlanChecklist.js +12 -0
  311. package/dist/src/tui/PlanChecklist.js.map +1 -0
  312. package/dist/src/tui/QueuedMessages.d.ts +8 -0
  313. package/dist/src/tui/QueuedMessages.js +24 -0
  314. package/dist/src/tui/QueuedMessages.js.map +1 -0
  315. package/dist/src/tui/StartupScreen.d.ts +25 -0
  316. package/dist/src/tui/StartupScreen.js +51 -0
  317. package/dist/src/tui/StartupScreen.js.map +1 -0
  318. package/dist/src/tui/ToolCallPanel.d.ts +33 -0
  319. package/dist/src/tui/ToolCallPanel.js +112 -0
  320. package/dist/src/tui/ToolCallPanel.js.map +1 -0
  321. package/dist/src/tui/WelcomeHeader.d.ts +30 -0
  322. package/dist/src/tui/WelcomeHeader.js +69 -0
  323. package/dist/src/tui/WelcomeHeader.js.map +1 -0
  324. package/dist/src/tui/background-tool-presentation.d.ts +22 -0
  325. package/dist/src/tui/background-tool-presentation.js +209 -0
  326. package/dist/src/tui/background-tool-presentation.js.map +1 -0
  327. package/dist/src/tui/busy-suffix.d.ts +37 -0
  328. package/dist/src/tui/busy-suffix.js +39 -0
  329. package/dist/src/tui/busy-suffix.js.map +1 -0
  330. package/dist/src/tui/clipboard-image.d.ts +18 -0
  331. package/dist/src/tui/clipboard-image.js +109 -0
  332. package/dist/src/tui/clipboard-image.js.map +1 -0
  333. package/dist/src/tui/context-format.d.ts +43 -0
  334. package/dist/src/tui/context-format.js +71 -0
  335. package/dist/src/tui/context-format.js.map +1 -0
  336. package/dist/src/tui/copy-command.d.ts +68 -0
  337. package/dist/src/tui/copy-command.js +182 -0
  338. package/dist/src/tui/copy-command.js.map +1 -0
  339. package/dist/src/tui/edit-diff.d.ts +135 -0
  340. package/dist/src/tui/edit-diff.js +356 -0
  341. package/dist/src/tui/edit-diff.js.map +1 -0
  342. package/dist/src/tui/frame-budget.d.ts +351 -0
  343. package/dist/src/tui/frame-budget.js +446 -0
  344. package/dist/src/tui/frame-budget.js.map +1 -0
  345. package/dist/src/tui/help-format.d.ts +17 -0
  346. package/dist/src/tui/help-format.js +38 -0
  347. package/dist/src/tui/help-format.js.map +1 -0
  348. package/dist/src/tui/live-text.d.ts +51 -0
  349. package/dist/src/tui/live-text.js +154 -0
  350. package/dist/src/tui/live-text.js.map +1 -0
  351. package/dist/src/tui/markdown.d.ts +62 -0
  352. package/dist/src/tui/markdown.js +244 -0
  353. package/dist/src/tui/markdown.js.map +1 -0
  354. package/dist/src/tui/mcp-format.d.ts +28 -0
  355. package/dist/src/tui/mcp-format.js +67 -0
  356. package/dist/src/tui/mcp-format.js.map +1 -0
  357. package/dist/src/tui/path-completion.d.ts +119 -0
  358. package/dist/src/tui/path-completion.js +305 -0
  359. package/dist/src/tui/path-completion.js.map +1 -0
  360. package/dist/src/tui/permission-queue.d.ts +61 -0
  361. package/dist/src/tui/permission-queue.js +129 -0
  362. package/dist/src/tui/permission-queue.js.map +1 -0
  363. package/dist/src/tui/plan-format.d.ts +9 -0
  364. package/dist/src/tui/plan-format.js +30 -0
  365. package/dist/src/tui/plan-format.js.map +1 -0
  366. package/dist/src/tui/prompt-completion.d.ts +22 -0
  367. package/dist/src/tui/prompt-completion.js +46 -0
  368. package/dist/src/tui/prompt-completion.js.map +1 -0
  369. package/dist/src/tui/prompt-editor.d.ts +102 -0
  370. package/dist/src/tui/prompt-editor.js +379 -0
  371. package/dist/src/tui/prompt-editor.js.map +1 -0
  372. package/dist/src/tui/prompt-history-search.d.ts +53 -0
  373. package/dist/src/tui/prompt-history-search.js +123 -0
  374. package/dist/src/tui/prompt-history-search.js.map +1 -0
  375. package/dist/src/tui/prompt-queue.d.ts +58 -0
  376. package/dist/src/tui/prompt-queue.js +74 -0
  377. package/dist/src/tui/prompt-queue.js.map +1 -0
  378. package/dist/src/tui/prompt-recall.d.ts +74 -0
  379. package/dist/src/tui/prompt-recall.js +90 -0
  380. package/dist/src/tui/prompt-recall.js.map +1 -0
  381. package/dist/src/tui/react-environment.d.ts +11 -0
  382. package/dist/src/tui/react-environment.js +24 -0
  383. package/dist/src/tui/react-environment.js.map +1 -0
  384. package/dist/src/tui/rewind-search.d.ts +34 -0
  385. package/dist/src/tui/rewind-search.js +68 -0
  386. package/dist/src/tui/rewind-search.js.map +1 -0
  387. package/dist/src/tui/shell-command.d.ts +114 -0
  388. package/dist/src/tui/shell-command.js +310 -0
  389. package/dist/src/tui/shell-command.js.map +1 -0
  390. package/dist/src/tui/spend-advisory.d.ts +52 -0
  391. package/dist/src/tui/spend-advisory.js +64 -0
  392. package/dist/src/tui/spend-advisory.js.map +1 -0
  393. package/dist/src/tui/status-format.d.ts +120 -0
  394. package/dist/src/tui/status-format.js +192 -0
  395. package/dist/src/tui/status-format.js.map +1 -0
  396. package/dist/src/tui/subagent-format.d.ts +49 -0
  397. package/dist/src/tui/subagent-format.js +146 -0
  398. package/dist/src/tui/subagent-format.js.map +1 -0
  399. package/dist/src/tui/task-format.d.ts +29 -0
  400. package/dist/src/tui/task-format.js +87 -0
  401. package/dist/src/tui/task-format.js.map +1 -0
  402. package/dist/src/tui/terminal-bell.d.ts +20 -0
  403. package/dist/src/tui/terminal-bell.js +33 -0
  404. package/dist/src/tui/terminal-bell.js.map +1 -0
  405. package/dist/src/tui/tool-detail-presentation.d.ts +60 -0
  406. package/dist/src/tui/tool-detail-presentation.js +206 -0
  407. package/dist/src/tui/tool-detail-presentation.js.map +1 -0
  408. package/dist/src/tui/turn-state.d.ts +195 -0
  409. package/dist/src/tui/turn-state.js +548 -0
  410. package/dist/src/tui/turn-state.js.map +1 -0
  411. package/dist/src/tui/visual-language.d.ts +45 -0
  412. package/dist/src/tui/visual-language.js +57 -0
  413. package/dist/src/tui/visual-language.js.map +1 -0
  414. package/dist/src/version.d.ts +7 -0
  415. package/dist/src/version.js +38 -0
  416. package/dist/src/version.js.map +1 -0
  417. package/package.json +60 -0
@@ -0,0 +1,71 @@
1
+ /** One transcript line: tokens, window share, and message count. */
2
+ export function formatContextReport(estimate) {
3
+ const label = estimate.measuredTokens === undefined ? 'estimated context' : 'context';
4
+ return `${label} — ${formatContextValue(estimate)}`;
5
+ }
6
+ /**
7
+ * The value half of the report, without the label — shared with `/status` so the
8
+ * two commands cannot describe the same estimate differently (the `/export`
9
+ * reuses-`formatReplay` precedent, at line scale).
10
+ */
11
+ export function formatContextValue(estimate) {
12
+ const tokens = `~${groupDigits(estimate.estimatedTokens)} tokens${formatBasis(estimate)}`;
13
+ const window = estimate.windowTokens === undefined
14
+ ? 'window unknown'
15
+ : `${formatWindowShare(estimate.estimatedTokens, estimate.windowTokens)} of ${groupDigits(estimate.windowTokens)} window`;
16
+ return `${tokens} · ${window} · ${estimate.messageCount} message(s)`;
17
+ }
18
+ /**
19
+ * How the total was arrived at, when part of it was measured: `(measured M + ~T new)`,
20
+ * or `(measured M + tail unknown)` when counting the appended messages failed. Empty
21
+ * when there is no measurement — an absent metric is absent, never rendered as 0.
22
+ */
23
+ function formatBasis(estimate) {
24
+ if (estimate.measuredTokens === undefined)
25
+ return '';
26
+ const tail = estimate.tailTokens === undefined ? 'tail unknown' : `~${groupDigits(estimate.tailTokens)} new`;
27
+ return ` (measured ${groupDigits(estimate.measuredTokens)} + ${tail})`;
28
+ }
29
+ /**
30
+ * Integer percent, except that a nonzero share below 1% shows `<1%`: rounding a
31
+ * young conversation to `0%` would claim the context is empty when it is not.
32
+ */
33
+ export function formatWindowShare(tokens, windowTokens) {
34
+ if (windowTokens <= 0)
35
+ return 'share unknown';
36
+ const percent = (tokens / windowTokens) * 100;
37
+ if (percent > 0 && percent < 1)
38
+ return '<1%';
39
+ return `${Math.round(percent)}%`;
40
+ }
41
+ export function createContextWarnLatch() {
42
+ let aboveThreshold = false;
43
+ return {
44
+ check(estimate, warnRatio) {
45
+ if (warnRatio <= 0 ||
46
+ !Number.isFinite(estimate.estimatedTokens) ||
47
+ estimate.estimatedTokens < 0 ||
48
+ estimate.windowTokens === undefined ||
49
+ !Number.isFinite(estimate.windowTokens) ||
50
+ estimate.windowTokens <= 0) {
51
+ return null;
52
+ }
53
+ const share = estimate.estimatedTokens / estimate.windowTokens;
54
+ if (share >= warnRatio) {
55
+ if (aboveThreshold)
56
+ return null; // already warned; don't repeat
57
+ aboveThreshold = true;
58
+ const pct = Math.round(share * 100);
59
+ return (`context pressure is high (~${pct}% of the model window) — consider /compact before ` +
60
+ 'the next broad implementation or verification turn');
61
+ }
62
+ aboveThreshold = false; // re-arm after dropping below
63
+ return null;
64
+ },
65
+ };
66
+ }
67
+ /** Explicit locale: the report should read the same on every machine. */
68
+ function groupDigits(value) {
69
+ return value.toLocaleString('en-US');
70
+ }
71
+ //# sourceMappingURL=context-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-format.js","sourceRoot":"","sources":["../../../src/tui/context-format.ts"],"names":[],"mappings":"AAcA,oEAAoE;AACpE,MAAM,UAAU,mBAAmB,CAAC,QAAyB;IAC3D,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;IACtF,OAAO,GAAG,KAAK,MAAM,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAyB;IAC1D,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC1F,MAAM,MAAM,GACV,QAAQ,CAA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AC5B,QAAQ,CAAC,YAAY,KAAK,SAAS;gBACnC,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC;gBACvC,QAAQ,CAAC,YAAY,IAAI,CAAC,EAC1B,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,KAAK,GAAG,QAAQ,CAAC,eAAe,GAAG,QAAQ,CAAC,YAAY,CAAC;YAC/D,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;gBACvB,IAAI,cAAc;oBAAE,OAAO,IAAI,CAAC,CAAG,+BAA+B;gBAClE,cAAc,GAAG,IAAI,CAAC;gBACtB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC;gBACpC,OAAO,CACL,8BAA8B,GAAG,oDAAoD;oBACrF,oDAAoD,CACrD,CAAC;YACJ,CAAC;YACD,cAAc,GAAG,KAAK,CAAC,CAAc,8BAA8B;YACnE,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,68 @@
1
+ import type { HistoryItem } from './turn-state.js';
2
+ /**
3
+ * UTF-8 bytes of answer text one `/copy` may carry. Base64 grows the OSC 52
4
+ * payload by 4/3, and terminals cap the sequence they accept; 256 KiB of text is
5
+ * far more than an answer, and a longer one is stated as `copied N of M bytes`
6
+ * rather than silently cut by the terminal.
7
+ */
8
+ export declare const MAX_COPY_BYTES = 262144;
9
+ export declare const COPY_TOOL_TIMEOUT_MS = 5000;
10
+ export declare const COPY_COMMAND_USAGE = "/copy takes no arguments";
11
+ export declare const NOTHING_TO_COPY_NOTICE = "nothing to copy \u2014 no completed answer in this session yet";
12
+ export interface CopyPayload {
13
+ /** The bytes both transports receive: the answer, cut on a code-point boundary at the cap. */
14
+ readonly bytes: Buffer;
15
+ readonly copiedBytes: number;
16
+ readonly totalBytes: number;
17
+ }
18
+ export interface ClipboardWriteCommand {
19
+ readonly command: string;
20
+ readonly args: readonly string[];
21
+ }
22
+ export interface CopyToolOutcome {
23
+ readonly name: string;
24
+ /** Present when the helper failed; the failure is stated, never thrown. */
25
+ readonly failure?: string;
26
+ }
27
+ export interface CopyCommandOptions {
28
+ readonly history: readonly HistoryItem[];
29
+ /** Ink's stdout writer (`useStdout().write`) — the existing output path. */
30
+ readonly writeToTerminal: (data: string) => void;
31
+ readonly env?: NodeJS.ProcessEnv;
32
+ readonly platform?: NodeJS.Platform;
33
+ readonly timeoutMs?: number;
34
+ /** Test seam: replaces the spawn-based helper; resolves to a failure message or nothing. */
35
+ readonly runTool?: (selected: ClipboardWriteCommand, bytes: Buffer) => Promise<string | undefined>;
36
+ }
37
+ export interface CopyCommandResult {
38
+ readonly text: string;
39
+ readonly severity: 'info' | 'warn';
40
+ }
41
+ /**
42
+ * The newest answer whose closing piece (`whole` or `last`) is in history.
43
+ *
44
+ * An answer still arriving has `first`/`middle` pieces and no `last` yet, so scanning
45
+ * back from the end skips it and lands on the previous completed one — which is what
46
+ * a mid-turn `/copy` should copy. Non-assistant items between the pieces of one
47
+ * answer (a notice) are stepped over; the previous answer's own close ends the walk.
48
+ */
49
+ export declare function latestCompletedAnswer(history: readonly HistoryItem[]): string | undefined;
50
+ /** Cuts the UTF-8 bytes at the cap on a code-point boundary, counting what was left. */
51
+ export declare function boundCopyPayload(text: string, cap?: number): CopyPayload;
52
+ /** `ESC ] 52 ; c ; <base64> BEL` — the clipboard selection, base64 of the given bytes. */
53
+ export declare function osc52Sequence(bytes: Uint8Array): string;
54
+ /** The platform copy tool a display makes usable, or nothing (SSH without forwarding). */
55
+ export declare function clipboardCopyCommand(platform: NodeJS.Platform, env: NodeJS.ProcessEnv): ClipboardWriteCommand | undefined;
56
+ /**
57
+ * Pipes the bytes into the helper's stdin. Resolves to a failure message, or nothing
58
+ * on success; it never rejects, so a missing or broken tool is a clause of the notice.
59
+ */
60
+ export declare function writeClipboardCommand(selected: ClipboardWriteCommand, bytes: Buffer, env: NodeJS.ProcessEnv, timeoutMs?: number): Promise<string | undefined>;
61
+ /** One bounded notice: what was copied, through which transports, and what failed. */
62
+ export declare function formatCopyNotice(payload: CopyPayload, tool: CopyToolOutcome | undefined): CopyCommandResult;
63
+ /**
64
+ * Runs `/copy` against the given history: OSC 52 through the terminal writer first,
65
+ * then the platform tool when a display makes one usable. Resolves to the one
66
+ * transcript notice; nothing here throws.
67
+ */
68
+ export declare function runCopyCommand(options: CopyCommandOptions): Promise<CopyCommandResult>;
@@ -0,0 +1,182 @@
1
+ /**
2
+ * `/copy` — the last completed answer's committed text onto the clipboard.
3
+ *
4
+ * The text is exactly what the `<Static>` transcript holds and `/export` writes: the
5
+ * answer's `AnswerPart` pieces (`turn-state.ts`) joined by newlines, empty closing
6
+ * pieces contributing nothing — the same rule `formatReplay` applies. Nothing is
7
+ * re-read from disk, re-derived from the model, or recorded: this module reads
8
+ * history, writes one OSC 52 sequence through the writer it is handed, and at most
9
+ * runs one platform clipboard helper. It never touches `Ctrl+O` (image attach).
10
+ */
11
+ import { spawn } from 'node:child_process';
12
+ /**
13
+ * UTF-8 bytes of answer text one `/copy` may carry. Base64 grows the OSC 52
14
+ * payload by 4/3, and terminals cap the sequence they accept; 256 KiB of text is
15
+ * far more than an answer, and a longer one is stated as `copied N of M bytes`
16
+ * rather than silently cut by the terminal.
17
+ */
18
+ export const MAX_COPY_BYTES = 262_144;
19
+ export const COPY_TOOL_TIMEOUT_MS = 5_000;
20
+ export const COPY_COMMAND_USAGE = '/copy takes no arguments';
21
+ export const NOTHING_TO_COPY_NOTICE = 'nothing to copy — no completed answer in this session yet';
22
+ /**
23
+ * The newest answer whose closing piece (`whole` or `last`) is in history.
24
+ *
25
+ * An answer still arriving has `first`/`middle` pieces and no `last` yet, so scanning
26
+ * back from the end skips it and lands on the previous completed one — which is what
27
+ * a mid-turn `/copy` should copy. Non-assistant items between the pieces of one
28
+ * answer (a notice) are stepped over; the previous answer's own close ends the walk.
29
+ */
30
+ export function latestCompletedAnswer(history) {
31
+ for (let end = history.length - 1; end >= 0; end -= 1) {
32
+ const closing = history[end];
33
+ if (closing.kind !== 'assistant')
34
+ continue;
35
+ if (closing.part === 'first' || closing.part === 'middle')
36
+ continue;
37
+ if (closing.part === 'whole')
38
+ return closing.text;
39
+ const pieces = [closing.text];
40
+ for (let start = end - 1; start >= 0; start -= 1) {
41
+ const piece = history[start];
42
+ if (piece.kind !== 'assistant')
43
+ continue;
44
+ if (piece.part === 'whole' || piece.part === 'last')
45
+ break;
46
+ pieces.unshift(piece.text);
47
+ if (piece.part === 'first')
48
+ break;
49
+ }
50
+ return pieces.filter((text) => text !== '').join('\n');
51
+ }
52
+ return undefined;
53
+ }
54
+ /** Cuts the UTF-8 bytes at the cap on a code-point boundary, counting what was left. */
55
+ export function boundCopyPayload(text, cap = MAX_COPY_BYTES) {
56
+ const whole = Buffer.from(text, 'utf8');
57
+ if (whole.byteLength <= cap) {
58
+ return { bytes: whole, copiedBytes: whole.byteLength, totalBytes: whole.byteLength };
59
+ }
60
+ let cut = cap;
61
+ // A continuation byte (10xxxxxx) means the cap fell inside a code point; back up
62
+ // to the byte that starts it so the copied text stays valid UTF-8.
63
+ while (cut > 0 && (whole[cut] & 0xc0) === 0x80)
64
+ cut -= 1;
65
+ return { bytes: whole.subarray(0, cut), copiedBytes: cut, totalBytes: whole.byteLength };
66
+ }
67
+ /** `ESC ] 52 ; c ; <base64> BEL` — the clipboard selection, base64 of the given bytes. */
68
+ export function osc52Sequence(bytes) {
69
+ return `\u001B]52;c;${Buffer.from(bytes).toString('base64')}\u0007`;
70
+ }
71
+ /** The platform copy tool a display makes usable, or nothing (SSH without forwarding). */
72
+ export function clipboardCopyCommand(platform, env) {
73
+ if (platform === 'darwin')
74
+ return { command: 'pbcopy', args: [] };
75
+ if (platform !== 'linux')
76
+ return undefined;
77
+ if (env['WAYLAND_DISPLAY'])
78
+ return { command: 'wl-copy', args: [] };
79
+ if (env['DISPLAY'])
80
+ return { command: 'xclip', args: ['-selection', 'clipboard'] };
81
+ return undefined;
82
+ }
83
+ /**
84
+ * Pipes the bytes into the helper's stdin. Resolves to a failure message, or nothing
85
+ * on success; it never rejects, so a missing or broken tool is a clause of the notice.
86
+ */
87
+ export async function writeClipboardCommand(selected, bytes, env, timeoutMs = COPY_TOOL_TIMEOUT_MS) {
88
+ return new Promise((resolve) => {
89
+ let settled = false;
90
+ let stderr = '';
91
+ const finish = (failure) => {
92
+ if (settled)
93
+ return;
94
+ settled = true;
95
+ clearTimeout(timer);
96
+ resolve(failure);
97
+ };
98
+ let child;
99
+ try {
100
+ child = spawn(selected.command, [...selected.args], {
101
+ env,
102
+ shell: false,
103
+ stdio: ['pipe', 'ignore', 'pipe'],
104
+ });
105
+ }
106
+ catch (error) {
107
+ finish(`${selected.command} failed: ${describe(error)}`);
108
+ return;
109
+ }
110
+ const timer = setTimeout(() => {
111
+ child.kill('SIGTERM');
112
+ finish(`${selected.command} timed out after ${timeoutMs}ms`);
113
+ }, timeoutMs);
114
+ timer.unref();
115
+ child.on('error', (error) => {
116
+ const hint = error.code === 'ENOENT'
117
+ ? `${selected.command} is not installed`
118
+ : `${selected.command} failed: ${describe(error)}`;
119
+ finish(hint);
120
+ });
121
+ child.stderr?.on('data', (chunk) => {
122
+ if (stderr.length < 512)
123
+ stderr += chunk.toString('utf8', 0, 512 - stderr.length);
124
+ });
125
+ child.on('close', (code, signal) => {
126
+ if (code === 0) {
127
+ finish();
128
+ return;
129
+ }
130
+ const detail = stderr.trim().replace(/\s+/g, ' ').slice(0, 240);
131
+ finish(`${selected.command} exited ${signal ?? code ?? 'without a status'}${detail === '' ? '' : `: ${detail}`}`);
132
+ });
133
+ // EPIPE on a helper that exits early surfaces as 'error' above, never as a throw.
134
+ child.stdin?.on('error', () => { });
135
+ child.stdin?.end(bytes);
136
+ });
137
+ }
138
+ /** One bounded notice: what was copied, through which transports, and what failed. */
139
+ export function formatCopyNotice(payload, tool) {
140
+ const truncated = payload.copiedBytes < payload.totalBytes;
141
+ const what = truncated
142
+ ? `copied ${payload.copiedBytes} of ${payload.totalBytes} bytes of the last answer to the clipboard (cap ${MAX_COPY_BYTES} bytes)`
143
+ : `copied the last answer to the clipboard (${payload.totalBytes} bytes)`;
144
+ let via = ' via OSC 52';
145
+ if (tool !== undefined) {
146
+ via += tool.failure === undefined ? ` and ${tool.name}` : `; ${tool.failure}`;
147
+ }
148
+ return {
149
+ text: `${what}${via}`,
150
+ severity: truncated || tool?.failure !== undefined ? 'warn' : 'info',
151
+ };
152
+ }
153
+ /**
154
+ * Runs `/copy` against the given history: OSC 52 through the terminal writer first,
155
+ * then the platform tool when a display makes one usable. Resolves to the one
156
+ * transcript notice; nothing here throws.
157
+ */
158
+ export async function runCopyCommand(options) {
159
+ const answer = latestCompletedAnswer(options.history);
160
+ if (answer === undefined)
161
+ return { text: NOTHING_TO_COPY_NOTICE, severity: 'info' };
162
+ const payload = boundCopyPayload(answer);
163
+ options.writeToTerminal(osc52Sequence(payload.bytes));
164
+ const env = options.env ?? process.env;
165
+ const selected = clipboardCopyCommand(options.platform ?? process.platform, env);
166
+ if (selected === undefined)
167
+ return formatCopyNotice(payload, undefined);
168
+ const run = options.runTool ??
169
+ ((command, bytes) => writeClipboardCommand(command, bytes, env, options.timeoutMs ?? COPY_TOOL_TIMEOUT_MS));
170
+ let failure;
171
+ try {
172
+ failure = await run(selected, payload.bytes);
173
+ }
174
+ catch (error) {
175
+ failure = `${selected.command} failed: ${describe(error)}`;
176
+ }
177
+ return formatCopyNotice(payload, failure === undefined ? { name: selected.command } : { name: selected.command, failure });
178
+ }
179
+ function describe(error) {
180
+ return error instanceof Error ? error.message : String(error);
181
+ }
182
+ //# sourceMappingURL=copy-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-command.js","sourceRoot":"","sources":["../../../src/tui/copy-command.ts"],"names":[],"mappings":"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KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Line-diff projection of a `fileEditor` write input.
3
+ *
4
+ * The permission gate has always exposed the raw tool input "for a UI that wants
5
+ * to show or diff it itself" (`PermissionRequest.input`); this module is that UI's
6
+ * projection. It is pure and dependency-free on purpose: the diff is computed from
7
+ * the strings already in the input — `str_replace` diffs `old_str` against
8
+ * `new_str`, `create`/`insert` are all additions — so **no file is ever read** and
9
+ * nothing here can disagree with what approving actually writes.
10
+ *
11
+ * Output vocabulary is three two-character plain-text markers, chosen so the
12
+ * distinction survives ANSI stripping, monochrome terminals and pty tests
13
+ * (`docs/architecture/load-bearing-decisions.md` § File-edit diffs):
14
+ *
15
+ * `- ` removed line · `+ ` added line · ` ` context line
16
+ *
17
+ * Information equivalence is structural, not aspirational: every source line
18
+ * appears exactly once under its marker, so stripping the two-character marker
19
+ * recovers the old value from the `- `/` ` lines and the new value from the
20
+ * `+ `/` ` lines. That also keeps "delete the matched text" (`new_str` absent —
21
+ * removals only) distinguishable from "replace with the empty string" (`new_str`
22
+ * of `''` — removals plus one empty addition). Bounding is *not* done here: the
23
+ * diff text flows through the same `permissionDetail` / `expandedToolInput`
24
+ * budgets as every other block, so truncation stays explicit and single-sourced.
25
+ *
26
+ * Everything vivid is derived from those same markers and never rewrites them:
27
+ * {@link diffStat} counts them, {@link diffLineEmphasis} pairs them into replaced
28
+ * lines and names the changed span — both projections of the diff text, so the
29
+ * ANSI-stripped output stays byte-identical to the plain diff.
30
+ */
31
+ import type { PermissionDetail } from '../agent/permission.js';
32
+ /** Markers are prepended verbatim; {@link diffLineTone} reads them back. */
33
+ export declare const DIFF_ADDED = "+ ";
34
+ export declare const DIFF_REMOVED = "- ";
35
+ export declare const DIFF_CONTEXT = " ";
36
+ /**
37
+ * The one header row a `str_replace` carrying `replace_all: true` adds to its
38
+ * projections (SER-055). Input-derived like everything else here: the diff still
39
+ * shows the one `old_str` → `new_str` pair the model sent, and this row states
40
+ * that the pair applies to every occurrence — the file is never read to count
41
+ * them. It is a header row, not a marker line, so {@link diffLineTone} and
42
+ * {@link diffStat} ignore it and the `+N -N` stat stays the one pair's.
43
+ */
44
+ export declare const REPLACE_ALL_ROW = "replace_all: every occurrence";
45
+ /** The semantic tone of one marker-prefixed diff line; `undefined` for context and markers. */
46
+ export declare function diffLineTone(line: string): 'add' | 'remove' | undefined;
47
+ /** Added/removed line counts of one marker-prefixed diff text. */
48
+ export interface DiffStat {
49
+ readonly added: number;
50
+ readonly removed: number;
51
+ }
52
+ /**
53
+ * Change stats derived from the same marker vocabulary the diff states — never a
54
+ * second diff calculation, so the counts cannot disagree with the rows shown.
55
+ * Compute it on the *untruncated* diff: a bounded excerpt has fewer rows, and the
56
+ * stat's job is to state the whole edit's size on the one row that always fits.
57
+ */
58
+ export declare function diffStat(diffText: string): DiffStat;
59
+ /** The one textual shape of a stat: `+N -N`, assertable after ANSI stripping. */
60
+ export declare function formatDiffStat(stat: DiffStat): string;
61
+ /**
62
+ * The intraline changed span of one diff line, as UTF-16 offsets into the full
63
+ * marker-prefixed line text. Enhancement only (bold layered over the row tone):
64
+ * it never changes any text, so ANSI-stripped output stays byte-identical to the
65
+ * plain diff and the two-character markers remain the durable statement.
66
+ */
67
+ export interface DiffEmphasis {
68
+ readonly start: number;
69
+ readonly end: number;
70
+ }
71
+ /**
72
+ * Per-line intraline emphasis for marker-prefixed diff lines, index-aligned with
73
+ * `lines`.
74
+ *
75
+ * A changed run — consecutive `- ` lines followed immediately by consecutive
76
+ * `+ ` lines — is treated as replaced line pairs **only when it has equally many
77
+ * removals and additions**; the k-th removal is paired with the k-th addition,
78
+ * mirroring how `diffMiddle` prints removals before the additions of the same
79
+ * run. For each pair the common code-point prefix and suffix are trimmed (never
80
+ * splitting a surrogate pair) and the middle is the emphasis span. Pairs that
81
+ * share no edge context are unrelated lines, not an intraline edit, and an empty
82
+ * middle says nothing — both yield `undefined`, as do context lines, unequal
83
+ * runs and the bare `+`/`-` a truncation can leave.
84
+ */
85
+ export declare function diffLineEmphasis(lines: readonly string[]): readonly (DiffEmphasis | undefined)[];
86
+ /**
87
+ * The three slices an emphasis span splits a text into. Pure string slicing, so
88
+ * every renderer that bolds a span draws exactly the same characters it would
89
+ * have drawn plain — concatenating the slices is the identity.
90
+ */
91
+ export declare function emphasisSpans(text: string, emphasis: DiffEmphasis): {
92
+ pre: string;
93
+ mid: string;
94
+ post: string;
95
+ };
96
+ /**
97
+ * The marker-prefixed line diff of one `fileEditor` write input, or `undefined`
98
+ * when the input is not a well-formed write — the caller then falls back to the
99
+ * raw presentation, so a shape this module does not recognize loses nothing.
100
+ */
101
+ export declare function fileEditorDiff(rawInput: unknown): string | undefined;
102
+ /**
103
+ * The expanded-input projection for the same calls: the non-content input fields
104
+ * as labelled header lines, then the diff. Same information as the JSON it
105
+ * replaces, in the shape the permission box already taught the user to read.
106
+ */
107
+ export declare function fileEditorInputProjection(rawInput: unknown): string | undefined;
108
+ /**
109
+ * Whether a `fileEditor` input is a recognized `str_replace` carrying
110
+ * `replace_all: true` — the one fact the compact finished row states above the
111
+ * bare diff. `false`, absent, or any unrecognized shape is `false`.
112
+ */
113
+ export declare function fileEditorReplaceAll(rawInput: unknown): boolean;
114
+ /** One permission detail block as the box should draw it. */
115
+ export interface PermissionDisplayDetail {
116
+ label: string;
117
+ value: string;
118
+ /** Whether the value is diff text whose rows carry {@link diffLineTone} colour. */
119
+ diff: boolean;
120
+ }
121
+ /**
122
+ * The detail blocks the permission box presents.
123
+ *
124
+ * For a `fileEditor` write whose input yields a diff, the gate's `editContent`
125
+ * blocks — and only those — collapse into one `Diff` block at the position of the
126
+ * first; `Path`, `Operation`, `At line` and an escalated `Classifier` block stay
127
+ * stated exactly as classified. Everything else (any other tool, or an input
128
+ * {@link fileEditorDiff} does not recognize) passes through untouched, so this
129
+ * projection can degrade but never omit.
130
+ */
131
+ export declare function permissionDisplayDetails(request: {
132
+ readonly toolName: string;
133
+ readonly details: readonly PermissionDetail[];
134
+ readonly input: unknown;
135
+ }): PermissionDisplayDetail[];