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,154 @@
1
+ /**
2
+ * How much of a still-arriving answer the live frame is allowed to show.
3
+ *
4
+ * Ink repaints the live (non-`<Static>`) region by erasing the lines it wrote
5
+ * last time — but only while that region fits the terminal. As soon as the frame
6
+ * is taller than the viewport, `shouldClearTerminalForFrame()` in `ink/ink.js`
7
+ * takes over and each render writes `clearTerminal + the whole static transcript`
8
+ * straight to stdout, bypassing the throttled log. At text-delta rate that is the
9
+ * flicker a long answer produces, and `clearTerminal` erases the scrollback with
10
+ * it, so the transcript scrolled away too. Measured in
11
+ * `spike/probe-live-frame-overflow.tsx`: 43 whole-screen clears for a 60-line
12
+ * answer in a 24-row terminal, 0 once the region is bounded.
13
+ *
14
+ * So the streaming text is shown as a *tail*: the newest rows that fit, with a
15
+ * count of what scrolled out. Nothing is lost — the assembled block still enters
16
+ * `<Static>` history in full when it closes (`turn-state.ts`), which is the one
17
+ * write that may safely be taller than the screen.
18
+ *
19
+ * The wrapping is done here rather than by Ink because the row count has to be
20
+ * exact: the caller renders one `<Text wrap="truncate-end">` per row, so the
21
+ * block's height is what this module says it is and cannot grow under Ink's own
22
+ * word wrap.
23
+ */
24
+ import { cellWidth } from './prompt-editor.js';
25
+ const segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
26
+ /**
27
+ * The `agent` label above the text and the blank row below it.
28
+ *
29
+ * Exported because the block's *claim* on the frame is stated in `App` and its
30
+ * height is decided here: a claim that forgot the label would be short by two rows.
31
+ */
32
+ export const LIVE_BLOCK_CHROME_ROWS = 2;
33
+ /**
34
+ * Shortest block this can draw: the label, one row of answer, the notice that
35
+ * says rows are missing, and the bottom margin. Below it the block does not
36
+ * shrink further — it yields the frame entirely, because the streaming answer is
37
+ * the one participant whose text is already guaranteed to reach `<Static>` history
38
+ * in full, and a block that "stops shrinking" is a block that overflows.
39
+ */
40
+ export const MINIMUM_LIVE_BLOCK_ROWS = LIVE_BLOCK_CHROME_ROWS + 2;
41
+ /** Same visible tab stop the prompt editor uses, so row widths stay honest. */
42
+ const TAB = ' ';
43
+ const EMPTY = { rows: [], hiddenRows: 0 };
44
+ /**
45
+ * The tail of `text` that fits `maxRows` terminal rows.
46
+ *
47
+ * `maxRows` covers the whole block the caller draws — the `agent` label, its
48
+ * bottom margin, and the "scrolled out" notice — not just the text, because the
49
+ * budget it comes from is a slice of the viewport, and a label that overflows
50
+ * costs exactly as much as a line of answer would.
51
+ */
52
+ export function liveTextView(text, columns, maxRows) {
53
+ if (text === '')
54
+ return EMPTY;
55
+ const rows = liveRows(text, columns);
56
+ if (maxRows < MINIMUM_LIVE_BLOCK_ROWS) {
57
+ // Too short for label + one row + notice + margin. Show the whole answer if it
58
+ // happens to fit anyway, otherwise draw nothing at all: this is the
59
+ // participant that yields first, and it yields completely rather than
60
+ // overflowing by the rows its own notice would need.
61
+ return rows.length + LIVE_BLOCK_CHROME_ROWS <= maxRows ? { rows, hiddenRows: 0 } : EMPTY;
62
+ }
63
+ const budget = Math.max(1, maxRows - LIVE_BLOCK_CHROME_ROWS);
64
+ if (rows.length <= budget)
65
+ return { rows, hiddenRows: 0 };
66
+ // One row of the budget pays for the notice that says rows are missing: a tail
67
+ // that silently starts mid-sentence reads as lost output.
68
+ const kept = Math.max(1, budget - 1);
69
+ return { rows: rows.slice(rows.length - kept), hiddenRows: rows.length - kept };
70
+ }
71
+ /** One line of prose about the rows that no longer fit. */
72
+ export function hiddenRowsNotice(hiddenRows) {
73
+ return `… ${hiddenRows} earlier line${hiddenRows === 1 ? '' : 's'} scrolled out of the live view`;
74
+ }
75
+ /**
76
+ * Wraps `text` into terminal rows the way the live block draws them.
77
+ *
78
+ * The last column is left empty: terminals disagree about whether writing the
79
+ * final cell wraps immediately or on the next character, and a row that wraps
80
+ * on its own is a row Ink did not count.
81
+ */
82
+ export function wrapToRows(text, columns) {
83
+ return liveRows(text, columns).map((row) => row.text);
84
+ }
85
+ /** The wrapped rows with their source logical line — one wrapping calculation. */
86
+ function liveRows(text, columns) {
87
+ const width = Math.max(1, columns - 1);
88
+ const rows = [];
89
+ text.split('\n').forEach((line, index) => {
90
+ for (const row of wrapLine(line.replaceAll('\t', TAB), width))
91
+ rows.push({ text: row, line: index });
92
+ });
93
+ return rows;
94
+ }
95
+ /**
96
+ * Greedy word wrap, falling back to a grapheme break for a word wider than the
97
+ * terminal. An empty logical line stays one row: it is a paragraph break, and
98
+ * dropping it would move the text under the cursor as the answer arrives.
99
+ */
100
+ function wrapLine(line, width) {
101
+ const rows = [];
102
+ let row = '';
103
+ let rowWidth = 0;
104
+ /** True once this row exists only because a wrap started it. */
105
+ let wrapped = false;
106
+ const flush = () => {
107
+ // A space that survived to the end of a row is invisible but still cost a
108
+ // cell, which is how a wrapped row ends up one column wider than the width.
109
+ rows.push(row.replace(/\s+$/u, ''));
110
+ row = '';
111
+ rowWidth = 0;
112
+ wrapped = true;
113
+ };
114
+ for (const token of line.match(/\s+|\S+/gu) ?? []) {
115
+ const tokenWidth = textWidth(token);
116
+ if (/^\s/u.test(token)) {
117
+ // Runs of spaces are dropped at a wrap point, but kept at the start of a
118
+ // logical line: that indentation is the shape of the code being printed.
119
+ if (rowWidth === 0 && wrapped)
120
+ continue;
121
+ if (rowWidth + tokenWidth > width) {
122
+ flush();
123
+ continue;
124
+ }
125
+ row += token;
126
+ rowWidth += tokenWidth;
127
+ continue;
128
+ }
129
+ if (rowWidth > 0 && rowWidth + tokenWidth > width)
130
+ flush();
131
+ if (tokenWidth <= width) {
132
+ row += token;
133
+ rowWidth += tokenWidth;
134
+ continue;
135
+ }
136
+ // A single token wider than the terminal — a path, a URL, a base64 blob.
137
+ for (const { segment } of segmenter.segment(token)) {
138
+ const graphemeWidth = cellWidth(segment);
139
+ if (rowWidth > 0 && rowWidth + graphemeWidth > width)
140
+ flush();
141
+ row += segment;
142
+ rowWidth += graphemeWidth;
143
+ }
144
+ }
145
+ rows.push(row);
146
+ return rows;
147
+ }
148
+ function textWidth(text) {
149
+ let width = 0;
150
+ for (const { segment } of segmenter.segment(text))
151
+ width += cellWidth(segment);
152
+ return width;
153
+ }
154
+ //# sourceMappingURL=live-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-text.js","sourceRoot":"","sources":["../../../src/tui/live-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,GAAG,CAAC,CAAC;AAElE,+EAA+E;AAC/E,MAAM,GAAG,GAAG,MAAM,CAAC;AAqBnB,MAAM,KAAK,GAAiB,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,OAAe,EAAE,OAAe;IACzE,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IAE9B,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,IAAI,OAAO,GAAG,uBAAuB,EAAE,CAAC;QACtC,+EAA+E;QAC/E,oEAAoE;QACpE,sEAAsE;QACtE,qDAAqD;QACrD,OAAO,IAAI,CAAC,MAAM,GAAG,sBAAsB,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,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,CAAC,IAAI,QAAQ,GAAG,UAAU,GAAG,KAAK;YAAE,KAAK,EAAE,CAAC;QAC3D,IAAI,UAAU,IAAI,KAAK,EAAE,CAAC;YACxB,GAAG,IAAI,KAAK,CAAC;YACb,QAAQ,IAAI,UAAU,CAAC;YACvB,SAAS;QACX,CAAC;QAED,yEAAyE;QACzE,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACnD,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;YACzC,IAAI,QAAQ,GAAG,CAAC,IAAI,QAAQ,GAAG,aAAa,GAAG,KAAK;gBAAE,KAAK,EAAE,CAAC;YAC9D,GAAG,IAAI,OAAO,CAAC;YACf,QAAQ,IAAI,aAAa,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,KAAK,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/E,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Markdown-aware styling of assistant answer text, as a pure projection.
3
+ *
4
+ * The committed answer text is the source of truth and is never altered
5
+ * (`turn-state.ts` commits exact plain lines; the trajectory record, `/export`
6
+ * and replay read that text): this module only says how to *draw* it. Every
7
+ * character of the input survives into the output spans — markers like `**`
8
+ * and ``` are de-emphasized in place, never stripped — so ANSI-stripped output
9
+ * is identical to the plain text, and pty assertions keep matching substrings.
10
+ * That holds for block structure too: a list marker, a blockquote `>` prefix and
11
+ * a table row's `|` separators become dim marker spans exactly where they are,
12
+ * never re-indented, renumbered or column-aligned.
13
+ *
14
+ * Line-oriented and dependency-free on purpose. An answer reaches `<Static>`
15
+ * history in pieces that Ink never redraws, so the one piece of state that
16
+ * must travel between pieces — inside or outside a fenced code block — is a
17
+ * boolean (`fenceOpenAfter`), decided when the piece is pushed. The fence
18
+ * classifier is therefore deliberately a boolean toggle (any ```/~~~ line
19
+ * opens a block; inside one, a bare ```/~~~ line closes it): a classifier
20
+ * that needed the opening fence's character or length would need more state
21
+ * than the boolean the reducer carries.
22
+ *
23
+ * Syntax highlighting of code by language is explicitly out of scope.
24
+ */
25
+ /** How one span of a line is drawn; concatenated spans are the line, verbatim. */
26
+ export type MarkdownSpanStyle = 'plain' | 'marker' | 'bold' | 'italic' | 'code';
27
+ export interface MarkdownSpan {
28
+ readonly text: string;
29
+ readonly style: MarkdownSpanStyle;
30
+ }
31
+ /**
32
+ * What one logical line *is*: prose (`text`), a heading, a fence delimiter,
33
+ * a line inside a fenced code block, a thematic break (`rule`), a list item, a
34
+ * blockquote line, or a pipe-fenced table row.
35
+ *
36
+ * The block kinds exist so a line's *leading* structure — a bullet or ordered
37
+ * marker, a `>` prefix, a row's `|` separators — becomes a dim `marker` span
38
+ * instead of falling through to prose. It is what gives a `* item` line its
39
+ * marker: `inlineSpans` deliberately refuses to read that `*` as emphasis.
40
+ */
41
+ export type MarkdownLineKind = 'text' | 'heading' | 'fence' | 'code' | 'rule' | 'list' | 'quote' | 'table';
42
+ export interface MarkdownLine {
43
+ readonly kind: MarkdownLineKind;
44
+ /** Inline spans; empty for an empty line. Joined, they are the line. */
45
+ readonly spans: readonly MarkdownSpan[];
46
+ }
47
+ /**
48
+ * Classifies every line of `text` and splits prose lines into inline spans.
49
+ * `codeOpen` is the fence state at the start of the text — for a `middle`/`last`
50
+ * answer piece, the state the previous pieces left behind.
51
+ */
52
+ export declare function markdownLines(text: string, codeOpen?: boolean): readonly MarkdownLine[];
53
+ /**
54
+ * The fence state after every line of `text`, starting from `codeOpen`.
55
+ *
56
+ * This is the minimal state carried across answer piece boundaries
57
+ * (`turn-state.ts` stores it on each assistant history item at push time) and
58
+ * into the live region: both sides derive it with this one function, which is
59
+ * what keeps a re-render of the live region from disagreeing with what
60
+ * `<Static>` already wrote.
61
+ */
62
+ export declare function fenceOpenAfter(text: string, codeOpen?: boolean): boolean;
@@ -0,0 +1,244 @@
1
+ /**
2
+ * Markdown-aware styling of assistant answer text, as a pure projection.
3
+ *
4
+ * The committed answer text is the source of truth and is never altered
5
+ * (`turn-state.ts` commits exact plain lines; the trajectory record, `/export`
6
+ * and replay read that text): this module only says how to *draw* it. Every
7
+ * character of the input survives into the output spans — markers like `**`
8
+ * and ``` are de-emphasized in place, never stripped — so ANSI-stripped output
9
+ * is identical to the plain text, and pty assertions keep matching substrings.
10
+ * That holds for block structure too: a list marker, a blockquote `>` prefix and
11
+ * a table row's `|` separators become dim marker spans exactly where they are,
12
+ * never re-indented, renumbered or column-aligned.
13
+ *
14
+ * Line-oriented and dependency-free on purpose. An answer reaches `<Static>`
15
+ * history in pieces that Ink never redraws, so the one piece of state that
16
+ * must travel between pieces — inside or outside a fenced code block — is a
17
+ * boolean (`fenceOpenAfter`), decided when the piece is pushed. The fence
18
+ * classifier is therefore deliberately a boolean toggle (any ```/~~~ line
19
+ * opens a block; inside one, a bare ```/~~~ line closes it): a classifier
20
+ * that needed the opening fence's character or length would need more state
21
+ * than the boolean the reducer carries.
22
+ *
23
+ * Syntax highlighting of code by language is explicitly out of scope.
24
+ */
25
+ /** A ```/~~~ line that opens a block (an info string like ```ts may follow). */
26
+ const FENCE_OPEN = /^ {0,3}(?:`{3,}|~{3,})/u;
27
+ /** A bare ```/~~~ line that closes the block it is inside. */
28
+ const FENCE_CLOSE = /^ {0,3}(?:`{3,}|~{3,})[ \t]*$/u;
29
+ /** ATX heading: 1–6 `#` then whitespace (or nothing at all). */
30
+ const HEADING = /^(#{1,6})([ \t]+)(.*)$/u;
31
+ const HEADING_BARE = /^#{1,6}$/u;
32
+ /** Thematic break: ---, *** or ___ (three or more). */
33
+ const RULE = /^ {0,3}(?:-{3,}|\*{3,}|_{3,})[ \t]*$/u;
34
+ /** Blockquote: a `>` run after at most three spaces, plus the space after it. */
35
+ const QUOTE = /^([ \t]{0,3}>[ \t>]*)(.*)$/u;
36
+ /**
37
+ * List item: a `-`/`*`/`+` bullet or an `N.`/`N)` ordered marker, followed by at
38
+ * least one space or tab (so `-fast` and `*emphasis*` are prose, not items).
39
+ * Leading indent is captured with the marker: nesting depth is preserved as the
40
+ * literal whitespace it already is, never re-indented.
41
+ */
42
+ const LIST_ITEM = /^([ \t]*)((?:[-*+]|\d{1,9}[.)])[ \t]+)(.*)$/u;
43
+ /**
44
+ * A table row, decided conservatively: it must both start (after at most three
45
+ * spaces) and end with `|`. A line merely *containing* a pipe — `cmd | grep x`,
46
+ * `a | b` in prose — stays prose, because dimming those false positives is a
47
+ * worse failure than leaving a pipe-less table row undecorated.
48
+ */
49
+ const TABLE_ROW = /^ {0,3}\|.*\|[ \t]*$/u;
50
+ /**
51
+ * Classifies every line of `text` and splits prose lines into inline spans.
52
+ * `codeOpen` is the fence state at the start of the text — for a `middle`/`last`
53
+ * answer piece, the state the previous pieces left behind.
54
+ */
55
+ export function markdownLines(text, codeOpen = false) {
56
+ let open = codeOpen;
57
+ return text.split('\n').map((line) => {
58
+ if (open) {
59
+ if (FENCE_CLOSE.test(line)) {
60
+ open = false;
61
+ return { kind: 'fence', spans: [{ text: line, style: 'marker' }] };
62
+ }
63
+ return { kind: 'code', spans: line === '' ? [] : [{ text: line, style: 'code' }] };
64
+ }
65
+ if (FENCE_OPEN.test(line)) {
66
+ open = true;
67
+ return { kind: 'fence', spans: [{ text: line, style: 'marker' }] };
68
+ }
69
+ const heading = HEADING.exec(line);
70
+ if (heading !== null) {
71
+ const marker = `${heading[1]}${heading[2]}`;
72
+ const rest = heading[3];
73
+ return {
74
+ kind: 'heading',
75
+ spans: rest === ''
76
+ ? [{ text: marker, style: 'marker' }]
77
+ : [{ text: marker, style: 'marker' }, { text: rest, style: 'plain' }],
78
+ };
79
+ }
80
+ if (HEADING_BARE.test(line)) {
81
+ return { kind: 'heading', spans: [{ text: line, style: 'marker' }] };
82
+ }
83
+ if (RULE.test(line)) {
84
+ return { kind: 'rule', spans: [{ text: line, style: 'marker' }] };
85
+ }
86
+ const quote = QUOTE.exec(line);
87
+ if (quote !== null) {
88
+ return { kind: 'quote', spans: markedSpans(quote[1], quote[2]) };
89
+ }
90
+ const item = LIST_ITEM.exec(line);
91
+ if (item !== null) {
92
+ return {
93
+ kind: 'list',
94
+ spans: markedSpans(`${item[1]}${item[2]}`, item[3]),
95
+ };
96
+ }
97
+ if (TABLE_ROW.test(line)) {
98
+ return { kind: 'table', spans: tableSpans(line) };
99
+ }
100
+ return { kind: 'text', spans: line === '' ? [] : inlineSpans(line) };
101
+ });
102
+ }
103
+ /** A leading `marker` span plus the inline spans of what follows it. */
104
+ function markedSpans(marker, rest) {
105
+ const spans = [{ text: marker, style: 'marker' }];
106
+ if (rest !== '')
107
+ spans.push(...inlineSpans(rest));
108
+ return spans;
109
+ }
110
+ /**
111
+ * A table row: every `|` is its own `marker` span, every cell keeps ordinary
112
+ * inline spans. Column widths are never touched — the row's own spacing is part
113
+ * of the cell text, so the drawn row is exactly as wide as the committed one.
114
+ */
115
+ function tableSpans(line) {
116
+ const spans = [];
117
+ let cell = '';
118
+ const flush = () => {
119
+ if (cell !== '')
120
+ spans.push(...inlineSpans(cell));
121
+ cell = '';
122
+ };
123
+ for (const char of line) {
124
+ if (char === '|') {
125
+ flush();
126
+ spans.push({ text: '|', style: 'marker' });
127
+ continue;
128
+ }
129
+ cell += char;
130
+ }
131
+ flush();
132
+ return spans;
133
+ }
134
+ /**
135
+ * The fence state after every line of `text`, starting from `codeOpen`.
136
+ *
137
+ * This is the minimal state carried across answer piece boundaries
138
+ * (`turn-state.ts` stores it on each assistant history item at push time) and
139
+ * into the live region: both sides derive it with this one function, which is
140
+ * what keeps a re-render of the live region from disagreeing with what
141
+ * `<Static>` already wrote.
142
+ */
143
+ export function fenceOpenAfter(text, codeOpen = false) {
144
+ let open = codeOpen;
145
+ if (text === '')
146
+ return open;
147
+ for (const line of text.split('\n')) {
148
+ if (open) {
149
+ if (FENCE_CLOSE.test(line))
150
+ open = false;
151
+ }
152
+ else if (FENCE_OPEN.test(line)) {
153
+ open = true;
154
+ }
155
+ }
156
+ return open;
157
+ }
158
+ /**
159
+ * Inline spans of one prose line: `` `code` ``, `**bold**` and `*italic*`,
160
+ * scanned left to right with inline code taking precedence. Unclosed markers
161
+ * stay plain text; emphasis content may not start or end with whitespace, so
162
+ * `a * b * c` and bullet `* item` lines never turn italic. `_underscore_`
163
+ * emphasis is deliberately not recognized — snake_case identifiers are far
164
+ * more common in answers than underscore emphasis, and mis-styling an
165
+ * identifier costs more than leaving emphasis plain.
166
+ */
167
+ function inlineSpans(line) {
168
+ const spans = [];
169
+ let plain = '';
170
+ const flush = () => {
171
+ if (plain !== '') {
172
+ spans.push({ text: plain, style: 'plain' });
173
+ plain = '';
174
+ }
175
+ };
176
+ let index = 0;
177
+ while (index < line.length) {
178
+ const char = line[index];
179
+ if (char === '`') {
180
+ const run = /^`+/u.exec(line.slice(index))[0];
181
+ const close = findRun(line, index + run.length, run);
182
+ if (close !== -1) {
183
+ flush();
184
+ spans.push({ text: run, style: 'marker' });
185
+ const content = line.slice(index + run.length, close);
186
+ if (content !== '')
187
+ spans.push({ text: content, style: 'code' });
188
+ spans.push({ text: run, style: 'marker' });
189
+ index = close + run.length;
190
+ continue;
191
+ }
192
+ plain += run;
193
+ index += run.length;
194
+ continue;
195
+ }
196
+ if (char === '*') {
197
+ const marker = line.startsWith('**', index) ? '**' : '*';
198
+ const close = findEmphasisClose(line, index + marker.length, marker);
199
+ if (close !== -1) {
200
+ flush();
201
+ spans.push({ text: marker, style: 'marker' });
202
+ spans.push({ text: line.slice(index + marker.length, close), style: marker === '**' ? 'bold' : 'italic' });
203
+ spans.push({ text: marker, style: 'marker' });
204
+ index = close + marker.length;
205
+ continue;
206
+ }
207
+ plain += char;
208
+ index += 1;
209
+ continue;
210
+ }
211
+ plain += char;
212
+ index += 1;
213
+ }
214
+ flush();
215
+ return spans;
216
+ }
217
+ /** First occurrence of exactly `run` (not part of a longer backtick run) at or after `from`. */
218
+ function findRun(line, from, run) {
219
+ let at = line.indexOf(run, from);
220
+ while (at !== -1) {
221
+ const before = at > 0 ? line[at - 1] : '';
222
+ const after = line[at + run.length] ?? '';
223
+ if (before !== run[0] && after !== run[0])
224
+ return at;
225
+ at = line.indexOf(run, at + 1);
226
+ }
227
+ return -1;
228
+ }
229
+ /**
230
+ * The closing `marker` for an emphasis span opened just before `from`, or -1.
231
+ * Content must be non-empty and must not start or end with whitespace.
232
+ */
233
+ function findEmphasisClose(line, from, marker) {
234
+ if (from >= line.length || /\s/u.test(line[from]))
235
+ return -1;
236
+ let at = line.indexOf(marker, from + 1);
237
+ while (at !== -1) {
238
+ if (!/\s/u.test(line[at - 1]))
239
+ return at;
240
+ at = line.indexOf(marker, at + 1);
241
+ }
242
+ return -1;
243
+ }
244
+ //# sourceMappingURL=markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../../src/tui/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AA4BH,gFAAgF;AAChF,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAC7C,8DAA8D;AAC9D,MAAM,WAAW,GAAG,gCAAgC,CAAC;AACrD,gEAAgE;AAChE,MAAM,OAAO,GAAG,yBAAyB,CAAC;AAC1C,MAAM,YAAY,GAAG,WAAW,CAAC;AACjC,uDAAuD;AACvD,MAAM,IAAI,GAAG,uCAAuC,CAAC;AACrD,iFAAiF;AACjF,MAAM,KAAK,GAAG,6BAA6B,CAAC;AAC5C;;;;;GAKG;AACH,MAAM,SAAS,GAAG,8CAA8C,CAAC;AACjE;;;;;GAKG;AACH,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAE1C;;;;GAIG;AACH,M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;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAC,IAAY,EAAE,IAAY,EAAE,MAAc;IACnE,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAW,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IACvE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;IACxC,OAAO,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAW,CAAC;YAAE,OAAO,EAAE,CAAC;QACnD,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { McpServerStatus } from '../mcp/registry.js';
2
+ /**
3
+ * Tool names shown per server before the report says `… N more`. MCP tool
4
+ * listings can be large — OpenCode warns about exactly this cost — so the report
5
+ * is bounded by construction, never an unbounded dump.
6
+ */
7
+ export declare const MAX_MCP_TOOL_NAMES = 8;
8
+ /** The config provenance the report states alongside the servers. */
9
+ export interface McpConfigSources {
10
+ /** Every contributing config path, global first and project second. */
11
+ configPaths: readonly string[];
12
+ /** Server names whose global entry was replaced by the project layer. */
13
+ overriddenServerNames: readonly string[];
14
+ /** Root `.mcp.json` left unread because `.darwin/mcp.json` took precedence. */
15
+ ignoredConfigPath: string | undefined;
16
+ /** Every file darwin looked for, named when nothing is configured. */
17
+ candidatePaths: readonly string[];
18
+ }
19
+ /**
20
+ * The `/mcp` report: every configured server with its connection state and a
21
+ * bounded list of registered tool names, then the config source(s) in effect.
22
+ *
23
+ * Pure text over an already-taken projection — this function reads no client and
24
+ * so cannot connect one. A failed server is stated as failed and contributing no
25
+ * tools, never omitted: silently missing tools are the problem this report
26
+ * exists to answer. Exported for the free spike, like `formatUsageReport`.
27
+ */
28
+ export declare function formatMcpReport(servers: readonly McpServerStatus[], sources: McpConfigSources): string;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Tool names shown per server before the report says `… N more`. MCP tool
3
+ * listings can be large — OpenCode warns about exactly this cost — so the report
4
+ * is bounded by construction, never an unbounded dump.
5
+ */
6
+ export const MAX_MCP_TOOL_NAMES = 8;
7
+ /**
8
+ * The `/mcp` report: every configured server with its connection state and a
9
+ * bounded list of registered tool names, then the config source(s) in effect.
10
+ *
11
+ * Pure text over an already-taken projection — this function reads no client and
12
+ * so cannot connect one. A failed server is stated as failed and contributing no
13
+ * tools, never omitted: silently missing tools are the problem this report
14
+ * exists to answer. Exported for the free spike, like `formatUsageReport`.
15
+ */
16
+ export function formatMcpReport(servers, sources) {
17
+ if (servers.length === 0) {
18
+ const looked = sources.configPaths.length > 0
19
+ ? `config read: ${sources.configPaths.join(', ')} — it defines no enabled servers`
20
+ : `looked for ${sources.candidatePaths.join(', ')}`;
21
+ return `no MCP servers configured\n ${looked}`;
22
+ }
23
+ const nameWidth = Math.max(...servers.map((server) => server.name.length));
24
+ const rows = servers.map((server) => ` ${server.name.padEnd(nameWidth)} ${describeServer(server)}`);
25
+ return [`mcp servers (${servers.length})`, ...rows, ...sourceLines(sources)].join('\n');
26
+ }
27
+ /** One server's state and bounded tool listing, on the row its name labels. */
28
+ function describeServer(server) {
29
+ switch (server.state) {
30
+ case 'connected':
31
+ return `connected · ${describeTools(server.toolNames)}`;
32
+ case 'failed':
33
+ // continueOnError swallowed the connection failure at startup; the SDK said
34
+ // so once at log level and the server has contributed zero tools since.
35
+ return 'failed — could not connect; contributing no tools (restart darwin to retry)';
36
+ case 'disconnected':
37
+ // Never connected (or already disconnected). Stated honestly rather than
38
+ // connecting to count tools: reading state must not mutate state.
39
+ return 'not connected — tools unknown (no connection attempted by this report)';
40
+ }
41
+ }
42
+ /** Registered tool names, capped with an explicit remainder — or their absence. */
43
+ function describeTools(toolNames) {
44
+ if (toolNames === undefined)
45
+ return 'tool names unavailable in this SDK build';
46
+ if (toolNames.length === 0)
47
+ return 'no tools';
48
+ const shown = toolNames.slice(0, MAX_MCP_TOOL_NAMES);
49
+ const remainder = toolNames.length - shown.length;
50
+ const suffix = remainder > 0 ? ` … ${remainder} more` : '';
51
+ return `${toolNames.length} tool${toolNames.length === 1 ? '' : 's'}: ${shown.join(', ')}${suffix}`;
52
+ }
53
+ /** Which file(s) produced this server list, and which were overridden or ignored. */
54
+ function sourceLines(sources) {
55
+ const labels = sources.configPaths.map((configPath, index, all) => {
56
+ const label = all.length === 2 ? (index === 0 ? ' (global)' : ' (project)') : '';
57
+ return ` config: ${configPath}${label}`;
58
+ });
59
+ const overrides = sources.overriddenServerNames.length > 0
60
+ ? [` project config overrides global for: ${sources.overriddenServerNames.join(', ')}`]
61
+ : [];
62
+ const ignored = sources.ignoredConfigPath === undefined
63
+ ? []
64
+ : [` ignored: ${sources.ignoredConfigPath} — .darwin/mcp.json takes precedence`];
65
+ return [...labels, ...overrides, ...ignored];
66
+ }
67
+ //# sourceMappingURL=mcp-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-format.js","sourceRoot":"","sources":["../../../src/tui/mcp-format.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAcpC;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAmC,EACnC,OAAyB;IAEzB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,MAAM,GACV,OAAO,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;YAC5B,CAAC,CAAC,gBAAgB,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,kCAAkC;YAClF,CAAC,CAAC,cAAc,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC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