@humain/humain-code 0.5.3 → 0.6.1

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 (696) hide show
  1. package/CHANGELOG.md +180 -0
  2. package/README.md +2 -2
  3. package/dist/bundle/agent-monitor.js +1 -1
  4. package/dist/bundle/chunks/anthropic-messages-FGFIMZUF.js +66 -0
  5. package/dist/bundle/chunks/azure-openai-responses-6JNTC7KO.js +15 -0
  6. package/dist/bundle/chunks/bedrock-converse-stream.js +261 -237
  7. package/dist/bundle/chunks/chunk-2H3LUS62.js +1966 -0
  8. package/dist/bundle/chunks/{chunk-GEISZXXH.js → chunk-4ZBGTJJM.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-QWXPGBAG.js → chunk-5JSLXC2A.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-L2VKM23Q.js → chunk-6DE7LJKV.js} +21 -21
  11. package/dist/bundle/chunks/{chunk-V62QBESW.js → chunk-6E6RHNOU.js} +11 -10
  12. package/dist/bundle/chunks/chunk-7RZ5BS7U.js +2 -0
  13. package/dist/bundle/chunks/chunk-AHSNQWZU.js +24 -0
  14. package/dist/bundle/chunks/{chunk-UJLCKIMZ.js → chunk-AOH2O5CP.js} +3469 -3133
  15. package/dist/bundle/chunks/{chunk-ODJUBJK2.js → chunk-B7NJMF7B.js} +11 -11
  16. package/dist/bundle/chunks/chunk-BQ3TMEWD.js +7 -0
  17. package/dist/bundle/chunks/{chunk-KKCMWB63.js → chunk-C6VERWRZ.js} +1 -1
  18. package/dist/bundle/chunks/{chunk-CN3Q5UNB.js → chunk-CFHOPLW5.js} +658 -574
  19. package/dist/bundle/chunks/chunk-CVC2GV26.js +1986 -0
  20. package/dist/bundle/chunks/{chunk-DU6POZ7E.js → chunk-DHW3REC5.js} +1 -1
  21. package/dist/bundle/chunks/{chunk-UTNHGOFS.js → chunk-EDONIPUJ.js} +38 -38
  22. package/dist/bundle/chunks/{chunk-FO2NYB6O.js → chunk-FDGW5ZTG.js} +1147 -1110
  23. package/dist/bundle/chunks/{chunk-XQX7S3GM.js → chunk-GICL5V54.js} +1 -1
  24. package/dist/bundle/chunks/chunk-H7Y4QY7K.js +11 -0
  25. package/dist/bundle/chunks/chunk-HW6HMUXS.js +188 -0
  26. package/dist/bundle/chunks/chunk-I6AQOITY.js +53 -0
  27. package/dist/bundle/chunks/{chunk-ZI7TK7HM.js → chunk-IADQJFNH.js} +21 -17
  28. package/dist/bundle/chunks/chunk-J7AP2BUJ.js +3 -0
  29. package/dist/bundle/chunks/chunk-JFE52VSN.js +120 -0
  30. package/dist/bundle/chunks/{chunk-MIJHJNNQ.js → chunk-LDGCU6PD.js} +127 -3
  31. package/dist/bundle/chunks/{chunk-PS7DGA7B.js → chunk-M4CHQBAI.js} +1 -1
  32. package/dist/bundle/chunks/{chunk-YDBNMIA3.js → chunk-NN53K2QQ.js} +19 -1
  33. package/dist/bundle/chunks/{chunk-RTXDU3AA.js → chunk-ONR6Q3II.js} +255 -195
  34. package/dist/bundle/chunks/{chunk-Y3OPKKDR.js → chunk-P4P7OZ7R.js} +34 -32
  35. package/dist/bundle/chunks/{chunk-OZNC2W4B.js → chunk-PCTLFSQG.js} +444 -411
  36. package/dist/bundle/chunks/{chunk-YFBDR4IW.js → chunk-PNGNZXOI.js} +3 -3
  37. package/dist/bundle/chunks/{chunk-UDB6NI4G.js → chunk-RGUZULEE.js} +593 -481
  38. package/dist/bundle/chunks/chunk-RO5YPAJH.js +23 -0
  39. package/dist/bundle/chunks/{chunk-A6B2QMA7.js → chunk-RU7ADKA7.js} +176 -162
  40. package/dist/bundle/chunks/{chunk-JCXXRCP6.js → chunk-T3KDZFM4.js} +16 -16
  41. package/dist/bundle/chunks/{chunk-HT5YN3LX.js → chunk-TEOMXMW6.js} +3 -3
  42. package/dist/bundle/chunks/{chunk-HIZWUSPN.js → chunk-VEGJT52D.js} +77 -77
  43. package/dist/bundle/chunks/{chunk-IDU5BNNI.js → chunk-XMZGB3H4.js} +12 -3
  44. package/dist/bundle/chunks/chunk-YEPHPMQC.js +647 -0
  45. package/dist/bundle/chunks/{chunk-XA7CJAYH.js → chunk-YRUIJ5AH.js} +48 -42
  46. package/dist/bundle/chunks/{cli-ENEFJH2B.js → cli-BNCWK54K.js} +21 -17
  47. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-T7TPP7SQ.js → cloudflare-workers-ai-system-one-KI6W3USX.js} +1 -1
  48. package/dist/bundle/chunks/codemode-worker.js +81 -75
  49. package/dist/bundle/chunks/compat-I5VPOXFT.js +13 -0
  50. package/dist/bundle/chunks/dist-J5IUPLMH.js +37 -0
  51. package/dist/bundle/chunks/{dist-RKNCFFGM.js → dist-SKBR3C7C.js} +720 -696
  52. package/dist/bundle/chunks/dist-TVRQXUY6.js +8 -0
  53. package/dist/bundle/chunks/{dist-cjs-HTASUQXQ.js → dist-cjs-2SKN226B.js} +77 -77
  54. package/dist/bundle/chunks/{easter-egg-3d-YOPLCOVW.js → easter-egg-3d-673VRP6Y.js} +1 -1
  55. package/dist/bundle/chunks/{esm-R6HJ4QEG.js → esm-WPALMLUO.js} +3 -3
  56. package/dist/bundle/chunks/{event-streams-BR2IL6C5.js → event-streams-7YGFEPBZ.js} +1 -1
  57. package/dist/bundle/chunks/{execute-2JXEKQ2X.js → execute-PIUR5MUV.js} +23 -23
  58. package/dist/bundle/chunks/{extract-OTCGZGTL.js → extract-4O5Z5725.js} +74 -71
  59. package/dist/bundle/chunks/github-copilot.js +50 -51
  60. package/dist/bundle/chunks/google-generative-ai-635YZEHN.js +22 -0
  61. package/dist/bundle/chunks/google-vertex-I3ZJ3SB2.js +26 -0
  62. package/dist/bundle/chunks/host-OQOEIWHK.js +2 -0
  63. package/dist/bundle/chunks/image-resize-worker.js +3 -2
  64. package/dist/bundle/chunks/kimi-coding.js +13 -14
  65. package/dist/bundle/chunks/{llama-cpp-classify-B3G57LVR.js → llama-cpp-classify-PP63BYDF.js} +1 -1
  66. package/dist/bundle/chunks/meta.js +10 -10
  67. package/dist/bundle/chunks/mistral-conversations-OKG5GKXR.js +42 -0
  68. package/dist/bundle/chunks/{node-VSA4ZN7D.js → node-UGQUSQE6.js} +1 -1
  69. package/dist/bundle/chunks/{node-SJPZTR4K.js → node-UNHECG4X.js} +168 -157
  70. package/dist/bundle/chunks/openai-codex-responses-6JYZIFT4.js +100 -0
  71. package/dist/bundle/chunks/openai-completions-YBNI6CAP.js +82 -0
  72. package/dist/bundle/chunks/{openai-decisions-WOWUC65P.js → openai-decisions-5G5YBFRQ.js} +1 -1
  73. package/dist/bundle/chunks/openai-responses-C3APJ6MK.js +27 -0
  74. package/dist/bundle/chunks/{openrouter-images-5K47HDAT.js → openrouter-images-FCJT7C7I.js} +2 -2
  75. package/dist/bundle/chunks/{pdfjs-EK6K7CXX.js → pdfjs-AKD6EBKN.js} +196 -175
  76. package/dist/bundle/chunks/pdfjs-decoders-OFXX4HDZ.js +2 -0
  77. package/dist/bundle/chunks/pdfjs-jbig2-TXR26KRI.js +278 -0
  78. package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-FH3KJM4H.js +326 -0
  79. package/dist/bundle/chunks/pdfjs-openjpeg-SKR7C34X.js +671 -0
  80. package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-VUBL7UEE.js +974 -0
  81. package/dist/bundle/chunks/pi-messages-UHYZYEOC.js +25 -0
  82. package/dist/bundle/chunks/radius.js +8 -8
  83. package/dist/bundle/chunks/{runtime-K3F2QDQP.js → runtime-KE3HDSRT.js} +1 -1
  84. package/dist/bundle/chunks/{turndown.cjs-U7XOXH4O.js → turndown.cjs-WKGZX7NZ.js} +1 -1
  85. package/dist/bundle/chunks/{typesafe-system-one-43OCHGKP.js → typesafe-system-one-VYVAMWQV.js} +1 -1
  86. package/dist/bundle/chunks/{undici-EK3EUI2E.js → undici-C6S56CGI.js} +1 -1
  87. package/dist/bundle/chunks/virtual-modules-KDUZIB3W.js +23 -0
  88. package/dist/bundle/cli-runtime.js +3 -3
  89. package/dist/bundle/flow/package.json +5 -5
  90. package/dist/bundle/index.js +10 -10
  91. package/dist/bundle/rpc-entry.js +3 -3
  92. package/dist/cli/args.d.ts.map +1 -1
  93. package/dist/cli/args.js +9 -8
  94. package/dist/cli/args.js.map +1 -1
  95. package/dist/config.d.ts +12 -0
  96. package/dist/config.d.ts.map +1 -1
  97. package/dist/config.js +29 -5
  98. package/dist/config.js.map +1 -1
  99. package/dist/coordination/adapter/tool.d.ts +8 -5
  100. package/dist/coordination/adapter/tool.d.ts.map +1 -1
  101. package/dist/coordination/adapter/tool.js +32 -6
  102. package/dist/coordination/adapter/tool.js.map +1 -1
  103. package/dist/coordination/client/client.d.ts.map +1 -1
  104. package/dist/coordination/client/client.js +19 -1
  105. package/dist/coordination/client/client.js.map +1 -1
  106. package/dist/core/agent-session-runtime.js +3 -3
  107. package/dist/core/agent-session-runtime.js.map +1 -1
  108. package/dist/core/agent-session.d.ts +23 -3
  109. package/dist/core/agent-session.d.ts.map +1 -1
  110. package/dist/core/agent-session.js +142 -39
  111. package/dist/core/agent-session.js.map +1 -1
  112. package/dist/core/anthropic-subscription-usage.d.ts +4 -0
  113. package/dist/core/anthropic-subscription-usage.d.ts.map +1 -1
  114. package/dist/core/anthropic-subscription-usage.js +71 -1
  115. package/dist/core/anthropic-subscription-usage.js.map +1 -1
  116. package/dist/core/bug-report.d.ts +4 -4
  117. package/dist/core/codex-reset.d.ts +45 -0
  118. package/dist/core/codex-reset.d.ts.map +1 -0
  119. package/dist/core/codex-reset.js +190 -0
  120. package/dist/core/codex-reset.js.map +1 -0
  121. package/dist/core/codex-usage.d.ts +4 -2
  122. package/dist/core/codex-usage.d.ts.map +1 -1
  123. package/dist/core/codex-usage.js +9 -4
  124. package/dist/core/codex-usage.js.map +1 -1
  125. package/dist/core/compaction/branch-summarization.d.ts +3 -1
  126. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  127. package/dist/core/compaction/branch-summarization.js +25 -10
  128. package/dist/core/compaction/branch-summarization.js.map +1 -1
  129. package/dist/core/compaction/compaction.d.ts +37 -3
  130. package/dist/core/compaction/compaction.d.ts.map +1 -1
  131. package/dist/core/compaction/compaction.js +274 -65
  132. package/dist/core/compaction/compaction.js.map +1 -1
  133. package/dist/core/compaction/utils.d.ts +19 -6
  134. package/dist/core/compaction/utils.d.ts.map +1 -1
  135. package/dist/core/compaction/utils.js +49 -11
  136. package/dist/core/compaction/utils.js.map +1 -1
  137. package/dist/core/exec.d.ts +9 -1
  138. package/dist/core/exec.d.ts.map +1 -1
  139. package/dist/core/exec.js +105 -61
  140. package/dist/core/exec.js.map +1 -1
  141. package/dist/core/export-html/template.css +9 -0
  142. package/dist/core/export-html/template.html +2 -0
  143. package/dist/core/export-html/template.js +200 -62
  144. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  145. package/dist/core/export-html/tool-renderer.js +3 -0
  146. package/dist/core/export-html/tool-renderer.js.map +1 -1
  147. package/dist/core/extensions/index.d.ts +1 -1
  148. package/dist/core/extensions/index.d.ts.map +1 -1
  149. package/dist/core/extensions/index.js.map +1 -1
  150. package/dist/core/extensions/loader.d.ts.map +1 -1
  151. package/dist/core/extensions/loader.js +7 -6
  152. package/dist/core/extensions/loader.js.map +1 -1
  153. package/dist/core/extensions/pi-ai-extension-view.d.ts +19 -0
  154. package/dist/core/extensions/pi-ai-extension-view.d.ts.map +1 -0
  155. package/dist/core/extensions/pi-ai-extension-view.js +22 -0
  156. package/dist/core/extensions/pi-ai-extension-view.js.map +1 -0
  157. package/dist/core/extensions/types.d.ts +27 -4
  158. package/dist/core/extensions/types.d.ts.map +1 -1
  159. package/dist/core/extensions/types.js.map +1 -1
  160. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  161. package/dist/core/extensions/virtual-modules.js +8 -7
  162. package/dist/core/extensions/virtual-modules.js.map +1 -1
  163. package/dist/core/http-dispatcher.d.ts +7 -0
  164. package/dist/core/http-dispatcher.d.ts.map +1 -1
  165. package/dist/core/http-dispatcher.js +107 -0
  166. package/dist/core/http-dispatcher.js.map +1 -1
  167. package/dist/core/keybindings.d.ts +56 -0
  168. package/dist/core/keybindings.d.ts.map +1 -1
  169. package/dist/core/keybindings.js +14 -2
  170. package/dist/core/keybindings.js.map +1 -1
  171. package/dist/core/mcp-servers.d.ts +9 -4
  172. package/dist/core/mcp-servers.d.ts.map +1 -1
  173. package/dist/core/mcp-servers.js +15 -5
  174. package/dist/core/mcp-servers.js.map +1 -1
  175. package/dist/core/model-config.d.ts +1691 -2042
  176. package/dist/core/model-config.d.ts.map +1 -1
  177. package/dist/core/model-config.js +2 -3
  178. package/dist/core/model-config.js.map +1 -1
  179. package/dist/core/model-registry.d.ts +35 -4
  180. package/dist/core/model-registry.d.ts.map +1 -1
  181. package/dist/core/model-registry.js +70 -8
  182. package/dist/core/model-registry.js.map +1 -1
  183. package/dist/core/model-resolver.d.ts.map +1 -1
  184. package/dist/core/model-resolver.js +16 -10
  185. package/dist/core/model-resolver.js.map +1 -1
  186. package/dist/core/model-runtime.d.ts.map +1 -1
  187. package/dist/core/model-runtime.js +21 -17
  188. package/dist/core/model-runtime.js.map +1 -1
  189. package/dist/core/package-manager.d.ts +29 -0
  190. package/dist/core/package-manager.d.ts.map +1 -1
  191. package/dist/core/package-manager.js +311 -60
  192. package/dist/core/package-manager.js.map +1 -1
  193. package/dist/core/pi-ai-schemas.d.ts +164 -0
  194. package/dist/core/pi-ai-schemas.d.ts.map +1 -0
  195. package/dist/core/pi-ai-schemas.js +21 -0
  196. package/dist/core/pi-ai-schemas.js.map +1 -0
  197. package/dist/core/pi-manifest.d.ts +1 -0
  198. package/dist/core/pi-manifest.d.ts.map +1 -1
  199. package/dist/core/pi-manifest.js +4 -0
  200. package/dist/core/pi-manifest.js.map +1 -1
  201. package/dist/core/project-trust.js +1 -1
  202. package/dist/core/project-trust.js.map +1 -1
  203. package/dist/core/resource-loader.d.ts +4 -1
  204. package/dist/core/resource-loader.d.ts.map +1 -1
  205. package/dist/core/resource-loader.js +38 -23
  206. package/dist/core/resource-loader.js.map +1 -1
  207. package/dist/core/sdk.d.ts.map +1 -1
  208. package/dist/core/sdk.js +4 -1
  209. package/dist/core/sdk.js.map +1 -1
  210. package/dist/core/session-manager.d.ts +7 -0
  211. package/dist/core/session-manager.d.ts.map +1 -1
  212. package/dist/core/session-manager.js +66 -26
  213. package/dist/core/session-manager.js.map +1 -1
  214. package/dist/core/settings-defaults.d.ts +2 -0
  215. package/dist/core/settings-defaults.d.ts.map +1 -1
  216. package/dist/core/settings-defaults.js +2 -0
  217. package/dist/core/settings-defaults.js.map +1 -1
  218. package/dist/core/settings-manager.d.ts +19 -8
  219. package/dist/core/settings-manager.d.ts.map +1 -1
  220. package/dist/core/settings-manager.js +70 -16
  221. package/dist/core/settings-manager.js.map +1 -1
  222. package/dist/core/settings-schema.d.ts +15 -2
  223. package/dist/core/settings-schema.d.ts.map +1 -1
  224. package/dist/core/settings-schema.js +37 -3
  225. package/dist/core/settings-schema.js.map +1 -1
  226. package/dist/core/skills.d.ts.map +1 -1
  227. package/dist/core/skills.js +6 -14
  228. package/dist/core/skills.js.map +1 -1
  229. package/dist/core/slash-commands.js +2 -2
  230. package/dist/core/slash-commands.js.map +1 -1
  231. package/dist/core/source-info.d.ts +9 -0
  232. package/dist/core/source-info.d.ts.map +1 -1
  233. package/dist/core/source-info.js +13 -0
  234. package/dist/core/source-info.js.map +1 -1
  235. package/dist/core/subscription-credits.d.ts +14 -0
  236. package/dist/core/subscription-credits.d.ts.map +1 -0
  237. package/dist/core/subscription-credits.js +10 -0
  238. package/dist/core/subscription-credits.js.map +1 -0
  239. package/dist/core/subscription-reset-status.d.ts +10 -0
  240. package/dist/core/subscription-reset-status.d.ts.map +1 -0
  241. package/dist/core/subscription-reset-status.js +2 -0
  242. package/dist/core/subscription-reset-status.js.map +1 -0
  243. package/dist/core/system-prompt.d.ts.map +1 -1
  244. package/dist/core/system-prompt.js +5 -6
  245. package/dist/core/system-prompt.js.map +1 -1
  246. package/dist/core/tools/bash.d.ts +2 -2
  247. package/dist/core/tools/bash.d.ts.map +1 -1
  248. package/dist/core/tools/bash.js.map +1 -1
  249. package/dist/core/tools/edit.d.ts +3 -3
  250. package/dist/core/tools/edit.d.ts.map +1 -1
  251. package/dist/core/tools/edit.js +2 -4
  252. package/dist/core/tools/edit.js.map +1 -1
  253. package/dist/core/tools/find.d.ts +2 -2
  254. package/dist/core/tools/find.d.ts.map +1 -1
  255. package/dist/core/tools/find.js.map +1 -1
  256. package/dist/core/tools/grep.d.ts +2 -2
  257. package/dist/core/tools/grep.d.ts.map +1 -1
  258. package/dist/core/tools/grep.js +7 -3
  259. package/dist/core/tools/grep.js.map +1 -1
  260. package/dist/core/tools/ls.d.ts +2 -2
  261. package/dist/core/tools/ls.d.ts.map +1 -1
  262. package/dist/core/tools/ls.js.map +1 -1
  263. package/dist/core/tools/read.d.ts +2 -2
  264. package/dist/core/tools/read.d.ts.map +1 -1
  265. package/dist/core/tools/read.js.map +1 -1
  266. package/dist/core/tools/render-utils.d.ts +4 -0
  267. package/dist/core/tools/render-utils.d.ts.map +1 -1
  268. package/dist/core/tools/render-utils.js +42 -12
  269. package/dist/core/tools/render-utils.js.map +1 -1
  270. package/dist/core/tools/renderers/edit.d.ts.map +1 -1
  271. package/dist/core/tools/renderers/edit.js +3 -3
  272. package/dist/core/tools/renderers/edit.js.map +1 -1
  273. package/dist/core/tools/renderers/write.d.ts.map +1 -1
  274. package/dist/core/tools/renderers/write.js +37 -29
  275. package/dist/core/tools/renderers/write.js.map +1 -1
  276. package/dist/core/tools/subagent.d.ts +9 -8
  277. package/dist/core/tools/subagent.d.ts.map +1 -1
  278. package/dist/core/tools/subagent.js +8 -5
  279. package/dist/core/tools/subagent.js.map +1 -1
  280. package/dist/core/tools/tool-definition-wrapper.d.ts +11 -1
  281. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  282. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  283. package/dist/core/tools/write.d.ts +2 -2
  284. package/dist/core/tools/write.d.ts.map +1 -1
  285. package/dist/core/tools/write.js.map +1 -1
  286. package/dist/core/trust-manager.d.ts.map +1 -1
  287. package/dist/core/trust-manager.js +14 -8
  288. package/dist/core/trust-manager.js.map +1 -1
  289. package/dist/core/usage-totals.d.ts.map +1 -1
  290. package/dist/core/usage-totals.js +2 -0
  291. package/dist/core/usage-totals.js.map +1 -1
  292. package/dist/extensions/codemode/renderer.d.ts.map +1 -1
  293. package/dist/extensions/codemode/renderer.js +17 -9
  294. package/dist/extensions/codemode/renderer.js.map +1 -1
  295. package/dist/extensions/codemode/tool.d.ts +2 -1
  296. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  297. package/dist/extensions/codemode/tool.js +33 -8
  298. package/dist/extensions/codemode/tool.js.map +1 -1
  299. package/dist/extensions/llama/ui.d.ts.map +1 -1
  300. package/dist/extensions/llama/ui.js +16 -4
  301. package/dist/extensions/llama/ui.js.map +1 -1
  302. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  303. package/dist/extensions/mcp/cli.js +34 -8
  304. package/dist/extensions/mcp/cli.js.map +1 -1
  305. package/dist/extensions/mcp/index.js +4 -3
  306. package/dist/extensions/mcp/index.js.map +1 -1
  307. package/dist/extensions/mcp/oauth.d.ts +1 -1
  308. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  309. package/dist/extensions/mcp/oauth.js +7 -3
  310. package/dist/extensions/mcp/oauth.js.map +1 -1
  311. package/dist/extensions/mcp/ui.d.ts +1 -0
  312. package/dist/extensions/mcp/ui.d.ts.map +1 -1
  313. package/dist/extensions/mcp/ui.js +56 -28
  314. package/dist/extensions/mcp/ui.js.map +1 -1
  315. package/dist/extensions/tool-search/tool.d.ts +21 -6
  316. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  317. package/dist/extensions/tool-search/tool.js +104 -36
  318. package/dist/extensions/tool-search/tool.js.map +1 -1
  319. package/dist/extensions/usage/confirmation.d.ts +40 -0
  320. package/dist/extensions/usage/confirmation.d.ts.map +1 -0
  321. package/dist/extensions/usage/confirmation.js +198 -0
  322. package/dist/extensions/usage/confirmation.js.map +1 -0
  323. package/dist/extensions/usage/index.d.ts +4 -4
  324. package/dist/extensions/usage/index.d.ts.map +1 -1
  325. package/dist/extensions/usage/index.js +352 -33
  326. package/dist/extensions/usage/index.js.map +1 -1
  327. package/dist/extensions/usage/overview.d.ts +8 -1
  328. package/dist/extensions/usage/overview.d.ts.map +1 -1
  329. package/dist/extensions/usage/overview.js +54 -11
  330. package/dist/extensions/usage/overview.js.map +1 -1
  331. package/dist/extensions/usage/popup.d.ts +37 -6
  332. package/dist/extensions/usage/popup.d.ts.map +1 -1
  333. package/dist/extensions/usage/popup.js +396 -45
  334. package/dist/extensions/usage/popup.js.map +1 -1
  335. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +564 -130
  336. package/dist/humain/node-provider.d.ts.map +1 -1
  337. package/dist/humain/node-provider.js +1 -0
  338. package/dist/humain/node-provider.js.map +1 -1
  339. package/dist/humain/web-access/host.d.ts +2 -1
  340. package/dist/humain/web-access/host.d.ts.map +1 -1
  341. package/dist/humain/web-access/host.js +1 -1
  342. package/dist/humain/web-access/host.js.map +1 -1
  343. package/dist/humain/web-access/vendor/brave-rate-limit.d.ts +2 -0
  344. package/dist/humain/web-access/vendor/brave-rate-limit.d.ts.map +1 -1
  345. package/dist/humain/web-access/vendor/brave-rate-limit.js +2 -2
  346. package/dist/humain/web-access/vendor/brave-rate-limit.js.map +1 -1
  347. package/dist/humain/web-access/vendor/cloudflare-search.d.ts +5 -0
  348. package/dist/humain/web-access/vendor/cloudflare-search.d.ts.map +1 -0
  349. package/dist/humain/web-access/vendor/cloudflare-search.js +230 -0
  350. package/dist/humain/web-access/vendor/cloudflare-search.js.map +1 -0
  351. package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
  352. package/dist/humain/web-access/vendor/curator-page.js +18 -1
  353. package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
  354. package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
  355. package/dist/humain/web-access/vendor/curator-server.js +12 -0
  356. package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
  357. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts +33 -0
  358. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts.map +1 -0
  359. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js +84 -0
  360. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js.map +1 -0
  361. package/dist/humain/web-access/vendor/duckduckgo.d.ts +3 -0
  362. package/dist/humain/web-access/vendor/duckduckgo.d.ts.map +1 -1
  363. package/dist/humain/web-access/vendor/duckduckgo.js +54 -49
  364. package/dist/humain/web-access/vendor/duckduckgo.js.map +1 -1
  365. package/dist/humain/web-access/vendor/exa.d.ts +8 -3
  366. package/dist/humain/web-access/vendor/exa.d.ts.map +1 -1
  367. package/dist/humain/web-access/vendor/exa.js +129 -14
  368. package/dist/humain/web-access/vendor/exa.js.map +1 -1
  369. package/dist/humain/web-access/vendor/extract.d.ts +1 -1
  370. package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
  371. package/dist/humain/web-access/vendor/extract.js +68 -10
  372. package/dist/humain/web-access/vendor/extract.js.map +1 -1
  373. package/dist/humain/web-access/vendor/fetch-params.d.ts +2 -1
  374. package/dist/humain/web-access/vendor/fetch-params.d.ts.map +1 -1
  375. package/dist/humain/web-access/vendor/fetch-params.js +2 -2
  376. package/dist/humain/web-access/vendor/fetch-params.js.map +1 -1
  377. package/dist/humain/web-access/vendor/field-extract.d.ts +38 -0
  378. package/dist/humain/web-access/vendor/field-extract.d.ts.map +1 -0
  379. package/dist/humain/web-access/vendor/field-extract.js +350 -0
  380. package/dist/humain/web-access/vendor/field-extract.js.map +1 -0
  381. package/dist/humain/web-access/vendor/gemini-search.d.ts +15 -4
  382. package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
  383. package/dist/humain/web-access/vendor/gemini-search.js +198 -16
  384. package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
  385. package/dist/humain/web-access/vendor/github-api.js +1 -1
  386. package/dist/humain/web-access/vendor/github-api.js.map +1 -1
  387. package/dist/humain/web-access/vendor/github-extract.d.ts.map +1 -1
  388. package/dist/humain/web-access/vendor/github-extract.js +3 -2
  389. package/dist/humain/web-access/vendor/github-extract.js.map +1 -1
  390. package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
  391. package/dist/humain/web-access/vendor/index.js +137 -118
  392. package/dist/humain/web-access/vendor/index.js.map +1 -1
  393. package/dist/humain/web-access/vendor/mistral-search.js +1 -1
  394. package/dist/humain/web-access/vendor/mistral-search.js.map +1 -1
  395. package/dist/humain/web-access/vendor/ninerouter.d.ts +4 -0
  396. package/dist/humain/web-access/vendor/ninerouter.d.ts.map +1 -0
  397. package/dist/humain/web-access/vendor/ninerouter.js +110 -0
  398. package/dist/humain/web-access/vendor/ninerouter.js.map +1 -0
  399. package/dist/humain/web-access/vendor/offtopic-judge.d.ts +27 -0
  400. package/dist/humain/web-access/vendor/offtopic-judge.d.ts.map +1 -0
  401. package/dist/humain/web-access/vendor/offtopic-judge.js +61 -0
  402. package/dist/humain/web-access/vendor/offtopic-judge.js.map +1 -0
  403. package/dist/humain/web-access/vendor/openai-search.d.ts +1 -1
  404. package/dist/humain/web-access/vendor/openai-search.d.ts.map +1 -1
  405. package/dist/humain/web-access/vendor/openai-search.js +39 -13
  406. package/dist/humain/web-access/vendor/openai-search.js.map +1 -1
  407. package/dist/humain/web-access/vendor/outcrawl.d.ts +4 -0
  408. package/dist/humain/web-access/vendor/outcrawl.d.ts.map +1 -0
  409. package/dist/humain/web-access/vendor/outcrawl.js +196 -0
  410. package/dist/humain/web-access/vendor/outcrawl.js.map +1 -0
  411. package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
  412. package/dist/humain/web-access/vendor/page-query.js +13 -3
  413. package/dist/humain/web-access/vendor/page-query.js.map +1 -1
  414. package/dist/humain/web-access/vendor/pdf-extract.d.ts +1 -3
  415. package/dist/humain/web-access/vendor/pdf-extract.d.ts.map +1 -1
  416. package/dist/humain/web-access/vendor/pdf-extract.js +0 -2
  417. package/dist/humain/web-access/vendor/pdf-extract.js.map +1 -1
  418. package/dist/humain/web-access/vendor/perplexity.d.ts +3 -0
  419. package/dist/humain/web-access/vendor/perplexity.d.ts.map +1 -1
  420. package/dist/humain/web-access/vendor/perplexity.js.map +1 -1
  421. package/dist/humain/web-access/vendor/query-rewrite.d.ts +2 -2
  422. package/dist/humain/web-access/vendor/query-rewrite.d.ts.map +1 -1
  423. package/dist/humain/web-access/vendor/query-rewrite.js +39 -13
  424. package/dist/humain/web-access/vendor/query-rewrite.js.map +1 -1
  425. package/dist/humain/web-access/vendor/searchapi.d.ts +4 -0
  426. package/dist/humain/web-access/vendor/searchapi.d.ts.map +1 -0
  427. package/dist/humain/web-access/vendor/searchapi.js +195 -0
  428. package/dist/humain/web-access/vendor/searchapi.js.map +1 -0
  429. package/dist/humain/web-access/vendor/sofya.d.ts +4 -0
  430. package/dist/humain/web-access/vendor/sofya.d.ts.map +1 -0
  431. package/dist/humain/web-access/vendor/sofya.js +193 -0
  432. package/dist/humain/web-access/vendor/sofya.js.map +1 -0
  433. package/dist/humain/web-access/vendor/source-check.d.ts +5 -1
  434. package/dist/humain/web-access/vendor/source-check.d.ts.map +1 -1
  435. package/dist/humain/web-access/vendor/source-check.js +34 -16
  436. package/dist/humain/web-access/vendor/source-check.js.map +1 -1
  437. package/dist/humain/web-access/vendor/ssrf-protection.d.ts +7 -0
  438. package/dist/humain/web-access/vendor/ssrf-protection.d.ts.map +1 -1
  439. package/dist/humain/web-access/vendor/ssrf-protection.js +24 -1
  440. package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -1
  441. package/dist/humain/web-access/vendor/summary-model-scope.d.ts +8 -3
  442. package/dist/humain/web-access/vendor/summary-model-scope.d.ts.map +1 -1
  443. package/dist/humain/web-access/vendor/summary-model-scope.js +15 -1
  444. package/dist/humain/web-access/vendor/summary-model-scope.js.map +1 -1
  445. package/dist/humain/web-access/vendor/summary-review.d.ts +7 -2
  446. package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -1
  447. package/dist/humain/web-access/vendor/summary-review.js +32 -28
  448. package/dist/humain/web-access/vendor/summary-review.js.map +1 -1
  449. package/dist/humain/web-access/vendor/tabstack.d.ts +6 -0
  450. package/dist/humain/web-access/vendor/tabstack.d.ts.map +1 -0
  451. package/dist/humain/web-access/vendor/tabstack.js +236 -0
  452. package/dist/humain/web-access/vendor/tabstack.js.map +1 -0
  453. package/dist/humain/web-access/vendor/tool-arguments.js +1 -1
  454. package/dist/humain/web-access/vendor/tool-arguments.js.map +1 -1
  455. package/dist/humain/web-access/vendor/upgrade-notice.d.ts +8 -0
  456. package/dist/humain/web-access/vendor/upgrade-notice.d.ts.map +1 -0
  457. package/dist/humain/web-access/vendor/upgrade-notice.js +46 -0
  458. package/dist/humain/web-access/vendor/upgrade-notice.js.map +1 -0
  459. package/dist/humain/web-access/vendor/utils.d.ts +9 -0
  460. package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
  461. package/dist/humain/web-access/vendor/utils.js +113 -27
  462. package/dist/humain/web-access/vendor/utils.js.map +1 -1
  463. package/dist/humain/web-access/vendor/web-tool-contract.d.ts +4 -0
  464. package/dist/humain/web-access/vendor/web-tool-contract.d.ts.map +1 -1
  465. package/dist/humain/web-access/vendor/web-tool-contract.js.map +1 -1
  466. package/dist/humain/web-access/vendor/web-tool-core.d.ts +17 -1
  467. package/dist/humain/web-access/vendor/web-tool-core.d.ts.map +1 -1
  468. package/dist/humain/web-access/vendor/web-tool-core.js +99 -22
  469. package/dist/humain/web-access/vendor/web-tool-core.js.map +1 -1
  470. package/dist/humain/web-access/vendor/xai-search.d.ts +1 -1
  471. package/dist/humain/web-access/vendor/xai-search.d.ts.map +1 -1
  472. package/dist/humain/web-access/vendor/xai-search.js +6 -5
  473. package/dist/humain/web-access/vendor/xai-search.js.map +1 -1
  474. package/dist/index.d.ts +3 -3
  475. package/dist/index.d.ts.map +1 -1
  476. package/dist/index.js.map +1 -1
  477. package/dist/main.d.ts.map +1 -1
  478. package/dist/main.js +20 -9
  479. package/dist/main.js.map +1 -1
  480. package/dist/modes/interactive/components/assistant-code-block.d.ts +34 -0
  481. package/dist/modes/interactive/components/assistant-code-block.d.ts.map +1 -0
  482. package/dist/modes/interactive/components/assistant-code-block.js +160 -0
  483. package/dist/modes/interactive/components/assistant-code-block.js.map +1 -0
  484. package/dist/modes/interactive/components/assistant-message.d.ts +31 -10
  485. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  486. package/dist/modes/interactive/components/assistant-message.js +276 -73
  487. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  488. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  489. package/dist/modes/interactive/components/compaction-summary-message.js +2 -1
  490. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  491. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  492. package/dist/modes/interactive/components/config-selector.js +4 -17
  493. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  494. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  495. package/dist/modes/interactive/components/custom-editor.js +7 -0
  496. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  497. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  498. package/dist/modes/interactive/components/custom-entry.js +2 -1
  499. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  500. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  501. package/dist/modes/interactive/components/custom-message.js +2 -1
  502. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  503. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  504. package/dist/modes/interactive/components/diff.js +3 -1
  505. package/dist/modes/interactive/components/diff.js.map +1 -1
  506. package/dist/modes/interactive/components/extension-editor.d.ts +2 -0
  507. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  508. package/dist/modes/interactive/components/extension-editor.js +4 -0
  509. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  510. package/dist/modes/interactive/components/footer.d.ts +4 -1
  511. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  512. package/dist/modes/interactive/components/footer.js +6 -5
  513. package/dist/modes/interactive/components/footer.js.map +1 -1
  514. package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
  515. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  516. package/dist/modes/interactive/components/login-dialog.js +107 -11
  517. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  518. package/dist/modes/interactive/components/markdown-transform.d.ts +2 -1
  519. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
  520. package/dist/modes/interactive/components/markdown-transform.js +3 -2
  521. package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
  522. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  523. package/dist/modes/interactive/components/mermaid.js +18 -6
  524. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  525. package/dist/modes/interactive/components/model-selector.d.ts +1 -0
  526. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  527. package/dist/modes/interactive/components/model-selector.js +17 -6
  528. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  529. package/dist/modes/interactive/components/oauth-selector.d.ts +1 -0
  530. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  531. package/dist/modes/interactive/components/oauth-selector.js +13 -4
  532. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  533. package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
  534. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  535. package/dist/modes/interactive/components/scoped-models-selector.js +14 -3
  536. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  537. package/dist/modes/interactive/components/session-selector-search.d.ts +4 -0
  538. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  539. package/dist/modes/interactive/components/session-selector-search.js +86 -22
  540. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  541. package/dist/modes/interactive/components/session-selector.d.ts +2 -1
  542. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  543. package/dist/modes/interactive/components/session-selector.js +16 -24
  544. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  545. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  546. package/dist/modes/interactive/components/settings-submenu.js +2 -0
  547. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  548. package/dist/modes/interactive/components/tool-execution.d.ts +2 -0
  549. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  550. package/dist/modes/interactive/components/tool-execution.js +15 -5
  551. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  552. package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
  553. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  554. package/dist/modes/interactive/components/tree-selector.js +5 -6
  555. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  556. package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
  557. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  558. package/dist/modes/interactive/components/user-message-selector.js +9 -1
  559. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  560. package/dist/modes/interactive/components/user-message.d.ts +4 -3
  561. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  562. package/dist/modes/interactive/components/user-message.js +20 -18
  563. package/dist/modes/interactive/components/user-message.js.map +1 -1
  564. package/dist/modes/interactive/external-editor.d.ts +1 -0
  565. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  566. package/dist/modes/interactive/external-editor.js +16 -4
  567. package/dist/modes/interactive/external-editor.js.map +1 -1
  568. package/dist/modes/interactive/interactive-mode.d.ts +6 -0
  569. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  570. package/dist/modes/interactive/interactive-mode.js +259 -83
  571. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  572. package/dist/modes/interactive/model-search.d.ts +10 -0
  573. package/dist/modes/interactive/model-search.d.ts.map +1 -1
  574. package/dist/modes/interactive/model-search.js +21 -0
  575. package/dist/modes/interactive/model-search.js.map +1 -1
  576. package/dist/modes/interactive/oauth-account-format.d.ts +10 -1
  577. package/dist/modes/interactive/oauth-account-format.d.ts.map +1 -1
  578. package/dist/modes/interactive/oauth-account-format.js +42 -0
  579. package/dist/modes/interactive/oauth-account-format.js.map +1 -1
  580. package/dist/modes/interactive/theme/theme.d.ts +10 -0
  581. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  582. package/dist/modes/interactive/theme/theme.js +28 -24
  583. package/dist/modes/interactive/theme/theme.js.map +1 -1
  584. package/dist/modes/print-mode.d.ts.map +1 -1
  585. package/dist/modes/print-mode.js +3 -2
  586. package/dist/modes/print-mode.js.map +1 -1
  587. package/dist/package-manager-cli.d.ts.map +1 -1
  588. package/dist/package-manager-cli.js +55 -4
  589. package/dist/package-manager-cli.js.map +1 -1
  590. package/dist/utils/ansi.d.ts.map +1 -1
  591. package/dist/utils/ansi.js +5 -2
  592. package/dist/utils/ansi.js.map +1 -1
  593. package/dist/utils/clipboard-command.d.ts.map +1 -1
  594. package/dist/utils/clipboard-command.js +4 -0
  595. package/dist/utils/clipboard-command.js.map +1 -1
  596. package/dist/utils/clipboard-image.d.ts +8 -0
  597. package/dist/utils/clipboard-image.d.ts.map +1 -1
  598. package/dist/utils/clipboard-image.js +31 -1
  599. package/dist/utils/clipboard-image.js.map +1 -1
  600. package/dist/utils/git.d.ts +1 -1
  601. package/dist/utils/git.d.ts.map +1 -1
  602. package/dist/utils/git.js.map +1 -1
  603. package/dist/utils/image-resize-core.d.ts.map +1 -1
  604. package/dist/utils/image-resize-core.js +5 -3
  605. package/dist/utils/image-resize-core.js.map +1 -1
  606. package/dist/utils/open-browser.d.ts.map +1 -1
  607. package/dist/utils/open-browser.js +96 -6
  608. package/dist/utils/open-browser.js.map +1 -1
  609. package/dist/utils/paths.d.ts +17 -0
  610. package/dist/utils/paths.d.ts.map +1 -1
  611. package/dist/utils/paths.js +42 -1
  612. package/dist/utils/paths.js.map +1 -1
  613. package/dist/utils/shell.d.ts +2 -1
  614. package/dist/utils/shell.d.ts.map +1 -1
  615. package/dist/utils/shell.js +12 -2
  616. package/dist/utils/shell.js.map +1 -1
  617. package/dist/utils/syntax-highlight.d.ts +5 -0
  618. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  619. package/dist/utils/syntax-highlight.js +156 -11
  620. package/dist/utils/syntax-highlight.js.map +1 -1
  621. package/dist/utils/tools-manager.d.ts.map +1 -1
  622. package/dist/utils/tools-manager.js +30 -35
  623. package/dist/utils/tools-manager.js.map +1 -1
  624. package/docs/assets/humain-code-logo.svg +8 -0
  625. package/docs/cli.md +22 -12
  626. package/docs/compaction.md +32 -8
  627. package/docs/coordination.md +2 -0
  628. package/docs/custom-provider.md +4 -2
  629. package/docs/environment-variables.md +2 -0
  630. package/docs/extensions.md +3169 -229
  631. package/docs/flow.md +2 -0
  632. package/docs/keybindings.md +24 -2
  633. package/docs/llama-cpp.md +30 -19
  634. package/docs/mcp.md +4 -2
  635. package/docs/message-types.md +7 -7
  636. package/docs/packages.md +27 -1
  637. package/docs/sessions.md +11 -3
  638. package/docs/settings.md +21 -9
  639. package/docs/slash-commands.md +51 -11
  640. package/docs/terminal-setup.md +3 -1
  641. package/docs/tmux.md +6 -0
  642. package/docs/tui.md +3 -1
  643. package/docs/windows.md +27 -0
  644. package/examples/extensions/README.md +2 -1
  645. package/examples/extensions/custom-provider-anthropic/index.ts +27 -31
  646. package/examples/extensions/custom-provider-anthropic/package-lock.json +7 -7
  647. package/examples/extensions/custom-provider-anthropic/package.json +2 -2
  648. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  649. package/examples/extensions/debug-provider.ts +2 -2
  650. package/examples/extensions/gondolin/package-lock.json +14 -24
  651. package/examples/extensions/gondolin/package.json +2 -2
  652. package/examples/extensions/preset.ts +2 -0
  653. package/examples/extensions/reload-runtime.ts +17 -5
  654. package/examples/extensions/todo.ts +7 -0
  655. package/examples/extensions/tools.ts +2 -0
  656. package/examples/extensions/with-deps/package-lock.json +2 -2
  657. package/examples/extensions/with-deps/package.json +1 -1
  658. package/examples/tsconfig.json +252 -0
  659. package/npm-shrinkwrap.json +289 -277
  660. package/package.json +29 -29
  661. package/schemas/keybindings.schema.json +28 -0
  662. package/schemas/models.schema.json +36 -36
  663. package/schemas/settings.schema.json +49 -0
  664. package/src/humain/ponytail/UPSTREAM.md +16 -2
  665. package/src/humain/ponytail/upstream.json +4 -4
  666. package/src/humain/web-access/UPSTREAM.md +48 -1
  667. package/src/humain/web-access/upstream.json +9 -6
  668. package/src/humain/web-access/vendor/CHANGELOG.md +1223 -0
  669. package/dist/bundle/chunks/anthropic-messages-ZP5KUK52.js +0 -67
  670. package/dist/bundle/chunks/azure-openai-responses-QJFYQ3DF.js +0 -15
  671. package/dist/bundle/chunks/chunk-2GCMACT4.js +0 -1956
  672. package/dist/bundle/chunks/chunk-AO6FF5JL.js +0 -21
  673. package/dist/bundle/chunks/chunk-EY3LZOUP.js +0 -1963
  674. package/dist/bundle/chunks/chunk-M74U5X4S.js +0 -119
  675. package/dist/bundle/chunks/chunk-N7CQ3UV3.js +0 -80
  676. package/dist/bundle/chunks/chunk-OR25QDSS.js +0 -365
  677. package/dist/bundle/chunks/chunk-PH7UP57J.js +0 -6
  678. package/dist/bundle/chunks/chunk-QW6PTCAB.js +0 -10
  679. package/dist/bundle/chunks/chunk-ROZV2IYD.js +0 -125
  680. package/dist/bundle/chunks/chunk-YFOLLX5D.js +0 -23
  681. package/dist/bundle/chunks/chunk-ZR4GF4WU.js +0 -54
  682. package/dist/bundle/chunks/compat-CJBWWYHE.js +0 -13
  683. package/dist/bundle/chunks/dist-IBUWEKEE.js +0 -24
  684. package/dist/bundle/chunks/dist-YFMJEHPH.js +0 -8
  685. package/dist/bundle/chunks/google-generative-ai-HVPCGIZ6.js +0 -21
  686. package/dist/bundle/chunks/google-vertex-UM5MAALA.js +0 -25
  687. package/dist/bundle/chunks/host-ZHEL5XQW.js +0 -2
  688. package/dist/bundle/chunks/mistral-conversations-AH72RLXK.js +0 -44
  689. package/dist/bundle/chunks/openai-codex-responses-L366637C.js +0 -98
  690. package/dist/bundle/chunks/openai-completions-ZP62QXJX.js +0 -83
  691. package/dist/bundle/chunks/openai-responses-DXUGSUTN.js +0 -26
  692. package/dist/bundle/chunks/pi-messages-MOQQDZBK.js +0 -23
  693. package/dist/bundle/chunks/virtual-modules-5D6QIJPN.js +0 -5
  694. package/examples/extensions/sandbox/index.ts +0 -321
  695. package/examples/extensions/sandbox/package-lock.json +0 -66
  696. package/examples/extensions/sandbox/package.json +0 -19
@@ -6,13 +6,18 @@
6
6
  * load the execution path or its typebox parameter schema. `write.ts` spreads these into its
7
7
  * definition, so the tool's public shape is unchanged.
8
8
  */
9
- import { Container, Text } from "@earendil-works/pi-tui";
9
+ import { Container, sanitizeTerminalText, Text } from "@earendil-works/pi-tui";
10
10
  import { keyHint } from "../../../modes/interactive/components/keybinding-hints.js";
11
- import { getLanguageFromPath, highlightCode } from "../../../modes/interactive/theme/theme.js";
11
+ import { CodeHighlighter, getLanguageFromPath, highlightCode, } from "../../../modes/interactive/theme/theme.js";
12
12
  import { normalizeDisplayText, renderToolPath, replaceTabs, str } from "../render-utils.js";
13
13
  import { declarePathHighlightingRenderers } from "./highlighting.js";
14
14
  class WriteCallRenderComponent extends Text {
15
+ // Line by line highlighting of a call whose content is still streaming.
15
16
  cache;
17
+ // A streamed call highlights its first lines on every delta, which stop changing once the file is longer, and a
18
+ // complete call highlights the whole file on every update and expand toggle. Either way the row reuses the last
19
+ // highlighting; it also holds the only copy of a complete call's displayed source.
20
+ highlighter = new CodeHighlighter();
16
21
  constructor() {
17
22
  super("", 0, 0);
18
23
  }
@@ -29,7 +34,7 @@ function highlightSingleLine(line, lang) {
29
34
  const highlighted = highlightCode(line, lang);
30
35
  return highlighted[0] ?? "";
31
36
  }
32
- function refreshWriteHighlightPrefix(cache) {
37
+ function refreshWriteHighlightPrefix(cache, highlighter) {
33
38
  const prefixCount = Math.min(WRITE_PARTIAL_FULL_HIGHLIGHT_LINES, cache.normalizedLines.length);
34
39
  if (prefixCount === 0)
35
40
  return;
@@ -37,13 +42,13 @@ function refreshWriteHighlightPrefix(cache) {
37
42
  if (cache.prefixSource === prefixSource)
38
43
  return;
39
44
  cache.prefixSource = prefixSource;
40
- const prefixHighlighted = highlightCode(prefixSource, cache.lang);
45
+ const prefixHighlighted = highlighter.highlight(prefixSource, cache.lang);
41
46
  for (let i = 0; i < prefixCount; i++) {
42
47
  cache.highlightedLines[i] =
43
48
  prefixHighlighted[i] ?? highlightSingleLine(cache.normalizedLines[i] ?? "", cache.lang);
44
49
  }
45
50
  }
46
- function rebuildWriteHighlightCacheFull(rawPath, fileContent) {
51
+ function rebuildWriteHighlightCacheFull(rawPath, fileContent, highlighter) {
47
52
  const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
48
53
  if (!lang)
49
54
  return undefined;
@@ -54,12 +59,13 @@ function rebuildWriteHighlightCacheFull(rawPath, fileContent) {
54
59
  lang,
55
60
  rawContent: fileContent,
56
61
  normalizedLines: normalized.split("\n"),
57
- highlightedLines: highlightCode(normalized, lang),
62
+ highlightedLines: [...highlighter.highlight(normalized, lang)],
58
63
  all: true,
64
+ complete: true,
59
65
  };
60
66
  }
61
67
  /** The cache for a call shown collapsed: the first lines highlighted, as they are while the file streams in. */
62
- function rebuildWriteHighlightCacheCollapsed(rawPath, fileContent) {
68
+ function rebuildWriteHighlightCacheCollapsed(rawPath, fileContent, highlighter) {
63
69
  const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
64
70
  if (!lang)
65
71
  return undefined;
@@ -71,7 +77,7 @@ function rebuildWriteHighlightCacheCollapsed(rawPath, fileContent) {
71
77
  highlightedLines: [],
72
78
  all: false,
73
79
  };
74
- refreshWriteHighlightPrefix(cache);
80
+ refreshWriteHighlightPrefix(cache, highlighter);
75
81
  cache.all = cache.normalizedLines.length <= WRITE_PARTIAL_FULL_HIGHLIGHT_LINES;
76
82
  return cache;
77
83
  }
@@ -84,37 +90,36 @@ function highlightRemainingLines(cache) {
84
90
  }
85
91
  cache.all = true;
86
92
  }
87
- function updateWriteHighlightCacheIncremental(cache, rawPath, fileContent, expanded) {
93
+ function updateWriteHighlightCacheIncremental(cache, rawPath, fileContent, expanded, highlighter) {
88
94
  const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
89
95
  if (!lang)
90
96
  return undefined;
91
- const rebuild = expanded ? rebuildWriteHighlightCacheFull : rebuildWriteHighlightCacheCollapsed;
92
- if (!cache)
93
- return rebuild(rawPath, fileContent);
94
- if (cache.lang !== lang || cache.rawPath !== rawPath)
95
- return rebuild(rawPath, fileContent);
96
- if (!fileContent.startsWith(cache.rawContent))
97
- return rebuild(rawPath, fileContent);
98
- if (cache.lineCount !== undefined && (expanded || fileContent.length !== cache.rawContent.length)) {
99
- return rebuild(rawPath, fileContent);
97
+ if (!cache ||
98
+ cache.lang !== lang ||
99
+ cache.rawPath !== rawPath ||
100
+ !fileContent.startsWith(cache.rawContent) ||
101
+ (cache.lineCount !== undefined && (expanded || fileContent.length !== cache.rawContent.length))) {
102
+ return expanded
103
+ ? rebuildWriteHighlightCacheFull(rawPath, fileContent, highlighter)
104
+ : rebuildWriteHighlightCacheCollapsed(rawPath, fileContent, highlighter);
100
105
  }
101
106
  if (expanded)
102
107
  highlightRemainingLines(cache);
103
108
  if (fileContent.length === cache.rawContent.length)
104
109
  return cache;
110
+ cache.complete = false;
105
111
  if (!expanded) {
106
112
  // Collapsed: the lines are kept, and the first of them highlighted.
107
113
  const added = replaceTabs(normalizeDisplayText(fileContent.slice(cache.rawContent.length))).split("\n");
108
114
  cache.rawContent = fileContent;
109
115
  cache.all = false;
110
- cache.complete = false;
111
116
  if (cache.normalizedLines.length === 0)
112
117
  cache.normalizedLines.push("");
113
118
  const lastLine = cache.normalizedLines.length - 1;
114
119
  cache.normalizedLines[lastLine] += added[0];
115
120
  for (let i = 1; i < added.length; i++)
116
121
  cache.normalizedLines.push(added[i]);
117
- refreshWriteHighlightPrefix(cache);
122
+ refreshWriteHighlightPrefix(cache, highlighter);
118
123
  // (While the first lines are all the lines, every line is highlighted.)
119
124
  cache.all = cache.normalizedLines.length <= WRITE_PARTIAL_FULL_HIGHLIGHT_LINES;
120
125
  return cache;
@@ -135,7 +140,7 @@ function updateWriteHighlightCacheIncremental(cache, rawPath, fileContent, expan
135
140
  cache.normalizedLines.push(segments[i]);
136
141
  cache.highlightedLines.push(highlightSingleLine(segments[i], cache.lang));
137
142
  }
138
- refreshWriteHighlightPrefix(cache);
143
+ refreshWriteHighlightPrefix(cache, highlighter);
139
144
  return cache;
140
145
  }
141
146
  /** The lines of a collapsed cache that are counted: without the empty lines at the end, as formatWriteCall() counts them. */
@@ -158,7 +163,7 @@ function trimTrailingEmptyLines(lines) {
158
163
  }
159
164
  return lines.slice(0, end);
160
165
  }
161
- function formatWriteCall(args, options, theme, cache, cwd) {
166
+ function formatWriteCall(args, options, theme, cache, highlighter, cwd) {
162
167
  const rawPath = str(args?.file_path ?? args?.path);
163
168
  const fileContent = str(args?.content);
164
169
  const pathDisplay = renderToolPath(rawPath, theme, cwd);
@@ -178,7 +183,7 @@ function formatWriteCall(args, options, theme, cache, cwd) {
178
183
  }
179
184
  else {
180
185
  const renderedLines = lang
181
- ? (cache?.highlightedLines ?? highlightCode(replaceTabs(normalizeDisplayText(fileContent)), lang))
186
+ ? (cache?.highlightedLines ?? highlighter.highlight(replaceTabs(normalizeDisplayText(fileContent)), lang))
182
187
  : normalizeDisplayText(fileContent).split("\n");
183
188
  const lines = trimTrailingEmptyLines(renderedLines);
184
189
  totalLines = lines.length;
@@ -204,7 +209,7 @@ function formatWriteResult(result, theme) {
204
209
  if (!output) {
205
210
  return undefined;
206
211
  }
207
- return `\n${theme.fg("error", output)}`;
212
+ return `\n${theme.fg("error", sanitizeTerminalText(output))}`;
208
213
  }
209
214
  export const writeRenderers = {
210
215
  renderCall(args, theme, context) {
@@ -216,18 +221,21 @@ export const writeRenderers = {
216
221
  // Expanded, the whole file is highlighted once it is complete. Collapsed, the first lines are, as they were
217
222
  // while it streamed in.
218
223
  if (!context.argsComplete) {
219
- component.cache = updateWriteHighlightCacheIncremental(component.cache, rawPath, fileContent, context.expanded);
224
+ component.cache = updateWriteHighlightCacheIncremental(component.cache, rawPath, fileContent, context.expanded, component.highlighter);
220
225
  }
221
226
  else if (context.expanded) {
222
- component.cache = rebuildWriteHighlightCacheFull(rawPath, fileContent);
227
+ const cache = component.cache;
228
+ if (!cache?.complete || !cache.all || cache.rawPath !== rawPath || cache.rawContent !== fileContent) {
229
+ component.cache = rebuildWriteHighlightCacheFull(rawPath, fileContent, component.highlighter);
230
+ }
223
231
  }
224
232
  else {
225
233
  const cache = component.cache;
226
234
  if (cache?.complete && !cache.all && cache.rawPath === rawPath && cache.rawContent === fileContent) {
227
- refreshWriteHighlightPrefix(cache);
235
+ refreshWriteHighlightPrefix(cache, component.highlighter);
228
236
  }
229
237
  else {
230
- component.cache = rebuildWriteHighlightCacheCollapsed(rawPath, fileContent);
238
+ component.cache = rebuildWriteHighlightCacheCollapsed(rawPath, fileContent, component.highlighter);
231
239
  if (component.cache)
232
240
  component.cache.complete = true;
233
241
  }
@@ -241,7 +249,7 @@ export const writeRenderers = {
241
249
  cache.lineCount = countCollapsedLines(cache);
242
250
  cache.normalizedLines = cache.normalizedLines.slice(0, WRITE_PARTIAL_FULL_HIGHLIGHT_LINES);
243
251
  }
244
- component.setText(formatWriteCall(renderArgs, { expanded: context.expanded, isPartial: context.isPartial }, theme, component.cache, context.cwd));
252
+ component.setText(formatWriteCall(renderArgs, { expanded: context.expanded, isPartial: context.isPartial }, theme, component.cache, component.highlighter, context.cwd));
245
253
  return component;
246
254
  },
247
255
  renderResult(result, _options, theme, context) {
@@ -1 +1 @@
1
- {"version":3,"file":"write.js","source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YAClB,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC;AAEF,gCAAgC,CAAC,cAAc,CAAC,CAAC","sourcesContent":["// Derived from Pi-Bolt (MIT, Copyright (c) 2026 OpenSec (Pi-Bolt)), commit b93895d2; modified for HUMAIN Code CLI.\n/**\n * Presentation for the write tool.\n *\n * Renderers live apart from the implementation so a process that only displays tool output does not\n * load the execution path or its typebox parameter schema. `write.ts` spreads these into its\n * definition, so the tool's public shape is unchanged.\n */\n\nimport { Container, Text } from \"@earendil-works/pi-tui\";\nimport { keyHint } from \"../../../modes/interactive/components/keybinding-hints.ts\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../../modes/interactive/theme/theme.ts\";\nimport type { ToolRenderers, ToolRenderResultOptions } from \"../../extensions/types.ts\";\nimport { normalizeDisplayText, renderToolPath, replaceTabs, str } from \"../render-utils.ts\";\nimport { declarePathHighlightingRenderers } from \"./highlighting.ts\";\n\ntype WriteHighlightCache = {\n\trawPath: string | null;\n\tlang: string;\n\trawContent: string;\n\tnormalizedLines: string[];\n\t/**\n\t * The lines highlighted. When the call is shown collapsed, only the first lines are: the lines after the ones that can\n\t * be shown are highlighted when the call is expanded (`all`), not as each one arrives and again when the file is\n\t * complete, which for a large file stops everything for as long as highlighting all of it takes.\n\t */\n\thighlightedLines: string[];\n\tall: boolean;\n\t/** Made from the complete file, not from the pieces it arrived in. */\n\tcomplete?: boolean;\n\t/**\n\t * Set once the call has its result and is shown collapsed: the count of lines shown when expanded, with\n\t * normalizedLines cut to the first lines. A collapsed call needs no more of them, and every write of a session stays in\n\t * the chat: keeping each file split into lines again holds more memory than the files themselves.\n\t */\n\tlineCount?: number;\n\tprefixSource?: string;\n};\nclass WriteCallRenderComponent extends Text {\n\tcache?: WriteHighlightCache;\n\n\tconstructor() {\n\t\tsuper(\"\", 0, 0);\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\t// Theme changes invalidate the highlighted prefix as well as the rendered text.\n\t\tthis.cache = undefined;\n\t}\n}\nconst WRITE_PARTIAL_FULL_HIGHLIGHT_LINES = 50;\n/** The lines of a collapsed call that are shown. */\nconst WRITE_COLLAPSED_LINES = 10;\nfunction highlightSingleLine(line: string, lang: string): string {\n\tconst highlighted = highlightCode(line, lang);\n\treturn highlighted[0] ?? \"\";\n}\nfunction refreshWriteHighlightPrefix(cache: WriteHighlightCache): void {\n\tconst prefixCount = Math.min(WRITE_PARTIAL_FULL_HIGHLIGHT_LINES, cache.normalizedLines.length);\n\tif (prefixCount === 0) return;\n\tconst prefixSource = cache.normalizedLines.slice(0, prefixCount).join(\"\\n\");\n\tif (cache.prefixSource === prefixSource) return;\n\tcache.prefixSource = prefixSource;\n\tconst prefixHighlighted = highlightCode(prefixSource, cache.lang);\n\tfor (let i = 0; i < prefixCount; i++) {\n\t\tcache.highlightedLines[i] =\n\t\t\tprefixHighlighted[i] ?? highlightSingleLine(cache.normalizedLines[i] ?? \"\", cache.lang);\n\t}\n}\nfunction rebuildWriteHighlightCacheFull(rawPath: string | null, fileContent: string): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tconst displayContent = normalizeDisplayText(fileContent);\n\tconst normalized = replaceTabs(displayContent);\n\treturn {\n\t\trawPath,\n\t\tlang,\n\t\trawContent: fileContent,\n\t\tnormalizedLines: normalized.split(\"\\n\"),\n\t\thighlightedLines: highlightCode(normalized, lang),\n\t\tall: true,\n\t};\n}\n/** The cache for a call shown collapsed: the first lines highlighted, as they are while the file streams in. */\nfunction rebuildWriteHighlightCacheCollapsed(\n\trawPath: string | null,\n\tfileContent: string,\n): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tconst cache: WriteHighlightCache = {\n\t\trawPath,\n\t\tlang,\n\t\trawContent: fileContent,\n\t\tnormalizedLines: replaceTabs(normalizeDisplayText(fileContent)).split(\"\\n\"),\n\t\thighlightedLines: [],\n\t\tall: false,\n\t};\n\trefreshWriteHighlightPrefix(cache);\n\tcache.all = cache.normalizedLines.length <= WRITE_PARTIAL_FULL_HIGHLIGHT_LINES;\n\treturn cache;\n}\n/** Highlights, each on its own, the lines after the first ones that a collapsed call left unhighlighted. */\nfunction highlightRemainingLines(cache: WriteHighlightCache): void {\n\tif (cache.all) return;\n\tfor (\n\t\tlet i = Math.min(WRITE_PARTIAL_FULL_HIGHLIGHT_LINES, cache.normalizedLines.length);\n\t\ti < cache.normalizedLines.length;\n\t\ti++\n\t) {\n\t\tcache.highlightedLines[i] = highlightSingleLine(cache.normalizedLines[i], cache.lang);\n\t}\n\tcache.all = true;\n}\nfunction updateWriteHighlightCacheIncremental(\n\tcache: WriteHighlightCache | undefined,\n\trawPath: string | null,\n\tfileContent: string,\n\texpanded: boolean,\n): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tconst rebuild = expanded ? rebuildWriteHighlightCacheFull : rebuildWriteHighlightCacheCollapsed;\n\tif (!cache) return rebuild(rawPath, fileContent);\n\tif (cache.lang !== lang || cache.rawPath !== rawPath) return rebuild(rawPath, fileContent);\n\tif (!fileContent.startsWith(cache.rawContent)) return rebuild(rawPath, fileContent);\n\tif (cache.lineCount !== undefined && (expanded || fileContent.length !== cache.rawContent.length)) {\n\t\treturn rebuild(rawPath, fileContent);\n\t}\n\tif (expanded) highlightRemainingLines(cache);\n\tif (fileContent.length === cache.rawContent.length) return cache;\n\tif (!expanded) {\n\t\t// Collapsed: the lines are kept, and the first of them highlighted.\n\t\tconst added = replaceTabs(normalizeDisplayText(fileContent.slice(cache.rawContent.length))).split(\"\\n\");\n\t\tcache.rawContent = fileContent;\n\t\tcache.all = false;\n\t\tcache.complete = false;\n\t\tif (cache.normalizedLines.length === 0) cache.normalizedLines.push(\"\");\n\t\tconst lastLine = cache.normalizedLines.length - 1;\n\t\tcache.normalizedLines[lastLine] += added[0];\n\t\tfor (let i = 1; i < added.length; i++) cache.normalizedLines.push(added[i]);\n\t\trefreshWriteHighlightPrefix(cache);\n\t\t// (While the first lines are all the lines, every line is highlighted.)\n\t\tcache.all = cache.normalizedLines.length <= WRITE_PARTIAL_FULL_HIGHLIGHT_LINES;\n\t\treturn cache;\n\t}\n\n\tconst deltaRaw = fileContent.slice(cache.rawContent.length);\n\tconst deltaDisplay = normalizeDisplayText(deltaRaw);\n\tconst deltaNormalized = replaceTabs(deltaDisplay);\n\tcache.rawContent = fileContent;\n\tif (cache.normalizedLines.length === 0) {\n\t\tcache.normalizedLines.push(\"\");\n\t\tcache.highlightedLines.push(\"\");\n\t}\n\n\tconst segments = deltaNormalized.split(\"\\n\");\n\tconst lastIndex = cache.normalizedLines.length - 1;\n\tcache.normalizedLines[lastIndex] += segments[0];\n\tcache.highlightedLines[lastIndex] = highlightSingleLine(cache.normalizedLines[lastIndex], cache.lang);\n\tfor (let i = 1; i < segments.length; i++) {\n\t\tcache.normalizedLines.push(segments[i]);\n\t\tcache.highlightedLines.push(highlightSingleLine(segments[i], cache.lang));\n\t}\n\trefreshWriteHighlightPrefix(cache);\n\treturn cache;\n}\n/** The lines of a collapsed cache that are counted: without the empty lines at the end, as formatWriteCall() counts them. */\nfunction countCollapsedLines(cache: WriteHighlightCache): number {\n\tif (cache.lineCount !== undefined) return cache.lineCount;\n\tlet totalLines = cache.normalizedLines.length;\n\t// Without the empty lines at the end, unless an empty line is not empty once highlighted (in a language without a\n\t// highlighter, every line is colored).\n\tif (highlightSingleLine(\"\", cache.lang) === \"\") {\n\t\twhile (totalLines > 0 && cache.normalizedLines[totalLines - 1] === \"\") totalLines--;\n\t}\n\treturn totalLines;\n}\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\nfunction formatWriteCall(\n\targs: { path?: string; file_path?: string; content?: string } | undefined,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tcache: WriteHighlightCache | undefined,\n\tcwd: string,\n): string {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst fileContent = str(args?.content);\n\tconst pathDisplay = renderToolPath(rawPath, theme, cwd);\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"write\"))} ${pathDisplay}`;\n\n\tif (fileContent === null) {\n\t\ttext += `\\n\\n${theme.fg(\"error\", \"[invalid content arg - expected string]\")}`;\n\t} else if (fileContent) {\n\t\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\t\tlet totalLines: number;\n\t\tlet displayLines: string[];\n\t\tif (lang && cache && !cache.all && !options.expanded) {\n\t\t\t// Collapsed, with only the first lines highlighted. The lines are counted as they are when all are\n\t\t\t// highlighted.\n\t\t\ttotalLines = countCollapsedLines(cache);\n\t\t\tdisplayLines = cache.highlightedLines.slice(0, Math.min(WRITE_COLLAPSED_LINES, totalLines));\n\t\t} else {\n\t\t\tconst renderedLines = lang\n\t\t\t\t? (cache?.highlightedLines ?? highlightCode(replaceTabs(normalizeDisplayText(fileContent)), lang))\n\t\t\t\t: normalizeDisplayText(fileContent).split(\"\\n\");\n\t\t\tconst lines = trimTrailingEmptyLines(renderedLines);\n\t\t\ttotalLines = lines.length;\n\t\t\tdisplayLines = lines.slice(0, options.expanded ? lines.length : WRITE_COLLAPSED_LINES);\n\t\t}\n\t\tconst maxLines = options.expanded ? totalLines : WRITE_COLLAPSED_LINES;\n\t\tconst remaining = totalLines - maxLines;\n\t\ttext += `\\n\\n${displayLines.map((line) => (lang ? line : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines, ${totalLines} total,`)} ${keyHint(\"app.tools.expand\", \"to expand\")}${theme.fg(\"muted\", \")\")}`;\n\t\t}\n\t}\n\n\treturn text;\n}\nfunction formatWriteResult(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }>; isError?: boolean },\n\ttheme: Theme,\n): string | undefined {\n\tif (!result.isError) {\n\t\treturn undefined;\n\t}\n\tconst output = result.content\n\t\t.filter((c) => c.type === \"text\")\n\t\t.map((c) => c.text || \"\")\n\t\t.join(\"\\n\");\n\tif (!output) {\n\t\treturn undefined;\n\t}\n\treturn `\\n${theme.fg(\"error\", output)}`;\n}\n\nexport const writeRenderers: Pick<ToolRenderers, \"renderCall\" | \"renderResult\"> = {\n\trenderCall(args, theme, context) {\n\t\tconst renderArgs = args as { path?: string; file_path?: string; content?: string } | undefined;\n\t\tconst rawPath = str(renderArgs?.file_path ?? renderArgs?.path);\n\t\tconst fileContent = str(renderArgs?.content);\n\t\tconst component =\n\t\t\t(context.lastComponent as WriteCallRenderComponent | undefined) ?? new WriteCallRenderComponent();\n\t\tif (fileContent !== null) {\n\t\t\t// Expanded, the whole file is highlighted once it is complete. Collapsed, the first lines are, as they were\n\t\t\t// while it streamed in.\n\t\t\tif (!context.argsComplete) {\n\t\t\t\tcomponent.cache = updateWriteHighlightCacheIncremental(\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t\trawPath,\n\t\t\t\t\tfileContent,\n\t\t\t\t\tcontext.expanded,\n\t\t\t\t);\n\t\t\t} else if (context.expanded) {\n\t\t\t\tcomponent.cache = rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\t\t\t} else {\n\t\t\t\tconst cache = component.cache;\n\t\t\t\tif (cache?.complete && !cache.all && cache.rawPath === rawPath && cache.rawContent === fileContent) {\n\t\t\t\t\trefreshWriteHighlightPrefix(cache);\n\t\t\t\t} else {\n\t\t\t\t\tcomponent.cache = rebuildWriteHighlightCacheCollapsed(rawPath, fileContent);\n\t\t\t\t\tif (component.cache) component.cache.complete = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tcomponent.cache = undefined;\n\t\t}\n\t\tconst cache = component.cache;\n\t\tif (cache && !cache.all && !context.expanded && !context.isPartial && cache.lineCount === undefined) {\n\t\t\tcache.lineCount = countCollapsedLines(cache);\n\t\t\tcache.normalizedLines = cache.normalizedLines.slice(0, WRITE_PARTIAL_FULL_HIGHLIGHT_LINES);\n\t\t}\n\t\tcomponent.setText(\n\t\t\tformatWriteCall(\n\t\t\t\trenderArgs,\n\t\t\t\t{ expanded: context.expanded, isPartial: context.isPartial },\n\t\t\t\ttheme,\n\t\t\t\tcomponent.cache,\n\t\t\t\tcontext.cwd,\n\t\t\t),\n\t\t);\n\t\treturn component;\n\t},\n\trenderResult(result, _options, theme, context) {\n\t\tconst output = formatWriteResult({ ...result, isError: context.isError }, theme);\n\t\tif (!output) {\n\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\tcomponent.clear();\n\t\t\treturn component;\n\t\t}\n\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\ttext.setText(output);\n\t\treturn text;\n\t},\n};\n\ndeclarePathHighlightingRenderers(writeRenderers);\n"]}
1
+ {"version":3,"file":"write.js","sourceRoot":"","sources":["../../../../src/core/tools/renderers/write.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,2DAA2D,CAAC;AACpF,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,aAAa,GAEb,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EA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MAAM,EAAE,CAAC;YACb,MAAM,SAAS,GAAI,OAAO,CAAC,aAAuC,IAAI,IAAI,SAAS,EAAE,CAAC;YACtF,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC;AAEF,gCAAgC,CAAC,cAAc,CAAC,CAAC","sourcesContent":["// Derived from Pi-Bolt (MIT, Copyright (c) 2026 OpenSec (Pi-Bolt)), commit b93895d2; modified for HUMAIN Code CLI.\n/**\n * Presentation for the write tool.\n *\n * Renderers live apart from the implementation so a process that only displays tool output does not\n * load the execution path or its typebox parameter schema. `write.ts` spreads these into its\n * definition, so the tool's public shape is unchanged.\n */\n\nimport { Container, sanitizeTerminalText, Text } from \"@earendil-works/pi-tui\";\nimport { keyHint } from \"../../../modes/interactive/components/keybinding-hints.ts\";\nimport {\n\tCodeHighlighter,\n\tgetLanguageFromPath,\n\thighlightCode,\n\ttype Theme,\n} from \"../../../modes/interactive/theme/theme.ts\";\nimport type { ToolRenderers, ToolRenderResultOptions } from \"../../extensions/types.ts\";\nimport { normalizeDisplayText, renderToolPath, replaceTabs, str } from \"../render-utils.ts\";\nimport { declarePathHighlightingRenderers } from \"./highlighting.ts\";\n\ntype WriteHighlightCache = {\n\trawPath: string | null;\n\tlang: string;\n\trawContent: string;\n\tnormalizedLines: string[];\n\t/**\n\t * The lines highlighted. When the call is shown collapsed, only the first lines are: the lines after the ones that can\n\t * be shown are highlighted when the call is expanded (`all`), not as each one arrives and again when the file is\n\t * complete, which for a large file stops everything for as long as highlighting all of it takes.\n\t */\n\thighlightedLines: string[];\n\tall: boolean;\n\t/** Made from the complete file, not from the pieces it arrived in. */\n\tcomplete?: boolean;\n\t/**\n\t * Set once the call has its result and is shown collapsed: the count of lines shown when expanded, with\n\t * normalizedLines cut to the first lines. A collapsed call needs no more of them, and every write of a session stays in\n\t * the chat: keeping each file split into lines again holds more memory than the files themselves.\n\t */\n\tlineCount?: number;\n\tprefixSource?: string;\n};\nclass WriteCallRenderComponent extends Text {\n\t// Line by line highlighting of a call whose content is still streaming.\n\tcache?: WriteHighlightCache;\n\t// A streamed call highlights its first lines on every delta, which stop changing once the file is longer, and a\n\t// complete call highlights the whole file on every update and expand toggle. Either way the row reuses the last\n\t// highlighting; it also holds the only copy of a complete call's displayed source.\n\treadonly highlighter = new CodeHighlighter();\n\n\tconstructor() {\n\t\tsuper(\"\", 0, 0);\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\t// Theme changes invalidate the highlighted prefix as well as the rendered text.\n\t\tthis.cache = undefined;\n\t}\n}\nconst WRITE_PARTIAL_FULL_HIGHLIGHT_LINES = 50;\n/** The lines of a collapsed call that are shown. */\nconst WRITE_COLLAPSED_LINES = 10;\nfunction highlightSingleLine(line: string, lang: string): string {\n\tconst highlighted = highlightCode(line, lang);\n\treturn highlighted[0] ?? \"\";\n}\nfunction refreshWriteHighlightPrefix(cache: WriteHighlightCache, highlighter: CodeHighlighter): void {\n\tconst prefixCount = Math.min(WRITE_PARTIAL_FULL_HIGHLIGHT_LINES, cache.normalizedLines.length);\n\tif (prefixCount === 0) return;\n\tconst prefixSource = cache.normalizedLines.slice(0, prefixCount).join(\"\\n\");\n\tif (cache.prefixSource === prefixSource) return;\n\tcache.prefixSource = prefixSource;\n\tconst prefixHighlighted = highlighter.highlight(prefixSource, cache.lang);\n\tfor (let i = 0; i < prefixCount; i++) {\n\t\tcache.highlightedLines[i] =\n\t\t\tprefixHighlighted[i] ?? highlightSingleLine(cache.normalizedLines[i] ?? \"\", cache.lang);\n\t}\n}\nfunction rebuildWriteHighlightCacheFull(\n\trawPath: string | null,\n\tfileContent: string,\n\thighlighter: CodeHighlighter,\n): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tconst displayContent = normalizeDisplayText(fileContent);\n\tconst normalized = replaceTabs(displayContent);\n\treturn {\n\t\trawPath,\n\t\tlang,\n\t\trawContent: fileContent,\n\t\tnormalizedLines: normalized.split(\"\\n\"),\n\t\thighlightedLines: [...highlighter.highlight(normalized, lang)],\n\t\tall: true,\n\t\tcomplete: true,\n\t};\n}\n/** The cache for a call shown collapsed: the first lines highlighted, as they are while the file streams in. */\nfunction rebuildWriteHighlightCacheCollapsed(\n\trawPath: string | null,\n\tfileContent: string,\n\thighlighter: CodeHighlighter,\n): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tconst cache: WriteHighlightCache = {\n\t\trawPath,\n\t\tlang,\n\t\trawContent: fileContent,\n\t\tnormalizedLines: replaceTabs(normalizeDisplayText(fileContent)).split(\"\\n\"),\n\t\thighlightedLines: [],\n\t\tall: false,\n\t};\n\trefreshWriteHighlightPrefix(cache, highlighter);\n\tcache.all = cache.normalizedLines.length <= WRITE_PARTIAL_FULL_HIGHLIGHT_LINES;\n\treturn cache;\n}\n/** Highlights, each on its own, the lines after the first ones that a collapsed call left unhighlighted. */\nfunction highlightRemainingLines(cache: WriteHighlightCache): void {\n\tif (cache.all) return;\n\tfor (\n\t\tlet i = Math.min(WRITE_PARTIAL_FULL_HIGHLIGHT_LINES, cache.normalizedLines.length);\n\t\ti < cache.normalizedLines.length;\n\t\ti++\n\t) {\n\t\tcache.highlightedLines[i] = highlightSingleLine(cache.normalizedLines[i], cache.lang);\n\t}\n\tcache.all = true;\n}\nfunction updateWriteHighlightCacheIncremental(\n\tcache: WriteHighlightCache | undefined,\n\trawPath: string | null,\n\tfileContent: string,\n\texpanded: boolean,\n\thighlighter: CodeHighlighter,\n): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tif (\n\t\t!cache ||\n\t\tcache.lang !== lang ||\n\t\tcache.rawPath !== rawPath ||\n\t\t!fileContent.startsWith(cache.rawContent) ||\n\t\t(cache.lineCount !== undefined && (expanded || fileContent.length !== cache.rawContent.length))\n\t) {\n\t\treturn expanded\n\t\t\t? rebuildWriteHighlightCacheFull(rawPath, fileContent, highlighter)\n\t\t\t: rebuildWriteHighlightCacheCollapsed(rawPath, fileContent, highlighter);\n\t}\n\tif (expanded) highlightRemainingLines(cache);\n\tif (fileContent.length === cache.rawContent.length) return cache;\n\tcache.complete = false;\n\tif (!expanded) {\n\t\t// Collapsed: the lines are kept, and the first of them highlighted.\n\t\tconst added = replaceTabs(normalizeDisplayText(fileContent.slice(cache.rawContent.length))).split(\"\\n\");\n\t\tcache.rawContent = fileContent;\n\t\tcache.all = false;\n\t\tif (cache.normalizedLines.length === 0) cache.normalizedLines.push(\"\");\n\t\tconst lastLine = cache.normalizedLines.length - 1;\n\t\tcache.normalizedLines[lastLine] += added[0];\n\t\tfor (let i = 1; i < added.length; i++) cache.normalizedLines.push(added[i]);\n\t\trefreshWriteHighlightPrefix(cache, highlighter);\n\t\t// (While the first lines are all the lines, every line is highlighted.)\n\t\tcache.all = cache.normalizedLines.length <= WRITE_PARTIAL_FULL_HIGHLIGHT_LINES;\n\t\treturn cache;\n\t}\n\n\tconst deltaRaw = fileContent.slice(cache.rawContent.length);\n\tconst deltaDisplay = normalizeDisplayText(deltaRaw);\n\tconst deltaNormalized = replaceTabs(deltaDisplay);\n\tcache.rawContent = fileContent;\n\tif (cache.normalizedLines.length === 0) {\n\t\tcache.normalizedLines.push(\"\");\n\t\tcache.highlightedLines.push(\"\");\n\t}\n\n\tconst segments = deltaNormalized.split(\"\\n\");\n\tconst lastIndex = cache.normalizedLines.length - 1;\n\tcache.normalizedLines[lastIndex] += segments[0];\n\tcache.highlightedLines[lastIndex] = highlightSingleLine(cache.normalizedLines[lastIndex], cache.lang);\n\tfor (let i = 1; i < segments.length; i++) {\n\t\tcache.normalizedLines.push(segments[i]);\n\t\tcache.highlightedLines.push(highlightSingleLine(segments[i], cache.lang));\n\t}\n\trefreshWriteHighlightPrefix(cache, highlighter);\n\treturn cache;\n}\n/** The lines of a collapsed cache that are counted: without the empty lines at the end, as formatWriteCall() counts them. */\nfunction countCollapsedLines(cache: WriteHighlightCache): number {\n\tif (cache.lineCount !== undefined) return cache.lineCount;\n\tlet totalLines = cache.normalizedLines.length;\n\t// Without the empty lines at the end, unless an empty line is not empty once highlighted (in a language without a\n\t// highlighter, every line is colored).\n\tif (highlightSingleLine(\"\", cache.lang) === \"\") {\n\t\twhile (totalLines > 0 && cache.normalizedLines[totalLines - 1] === \"\") totalLines--;\n\t}\n\treturn totalLines;\n}\nfunction trimTrailingEmptyLines(lines: readonly string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\nfunction formatWriteCall(\n\targs: { path?: string; file_path?: string; content?: string } | undefined,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tcache: WriteHighlightCache | undefined,\n\thighlighter: CodeHighlighter,\n\tcwd: string,\n): string {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst fileContent = str(args?.content);\n\tconst pathDisplay = renderToolPath(rawPath, theme, cwd);\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"write\"))} ${pathDisplay}`;\n\n\tif (fileContent === null) {\n\t\ttext += `\\n\\n${theme.fg(\"error\", \"[invalid content arg - expected string]\")}`;\n\t} else if (fileContent) {\n\t\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\t\tlet totalLines: number;\n\t\tlet displayLines: string[];\n\t\tif (lang && cache && !cache.all && !options.expanded) {\n\t\t\t// Collapsed, with only the first lines highlighted. The lines are counted as they are when all are\n\t\t\t// highlighted.\n\t\t\ttotalLines = countCollapsedLines(cache);\n\t\t\tdisplayLines = cache.highlightedLines.slice(0, Math.min(WRITE_COLLAPSED_LINES, totalLines));\n\t\t} else {\n\t\t\tconst renderedLines = lang\n\t\t\t\t? (cache?.highlightedLines ?? highlighter.highlight(replaceTabs(normalizeDisplayText(fileContent)), lang))\n\t\t\t\t: normalizeDisplayText(fileContent).split(\"\\n\");\n\t\t\tconst lines = trimTrailingEmptyLines(renderedLines);\n\t\t\ttotalLines = lines.length;\n\t\t\tdisplayLines = lines.slice(0, options.expanded ? lines.length : WRITE_COLLAPSED_LINES);\n\t\t}\n\t\tconst maxLines = options.expanded ? totalLines : WRITE_COLLAPSED_LINES;\n\t\tconst remaining = totalLines - maxLines;\n\t\ttext += `\\n\\n${displayLines.map((line) => (lang ? line : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines, ${totalLines} total,`)} ${keyHint(\"app.tools.expand\", \"to expand\")}${theme.fg(\"muted\", \")\")}`;\n\t\t}\n\t}\n\n\treturn text;\n}\nfunction formatWriteResult(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }>; isError?: boolean },\n\ttheme: Theme,\n): string | undefined {\n\tif (!result.isError) {\n\t\treturn undefined;\n\t}\n\tconst output = result.content\n\t\t.filter((c) => c.type === \"text\")\n\t\t.map((c) => c.text || \"\")\n\t\t.join(\"\\n\");\n\tif (!output) {\n\t\treturn undefined;\n\t}\n\treturn `\\n${theme.fg(\"error\", sanitizeTerminalText(output))}`;\n}\n\nexport const writeRenderers: Pick<ToolRenderers, \"renderCall\" | \"renderResult\"> = {\n\trenderCall(args, theme, context) {\n\t\tconst renderArgs = args as { path?: string; file_path?: string; content?: string } | undefined;\n\t\tconst rawPath = str(renderArgs?.file_path ?? renderArgs?.path);\n\t\tconst fileContent = str(renderArgs?.content);\n\t\tconst component =\n\t\t\t(context.lastComponent as WriteCallRenderComponent | undefined) ?? new WriteCallRenderComponent();\n\t\tif (fileContent !== null) {\n\t\t\t// Expanded, the whole file is highlighted once it is complete. Collapsed, the first lines are, as they were\n\t\t\t// while it streamed in.\n\t\t\tif (!context.argsComplete) {\n\t\t\t\tcomponent.cache = updateWriteHighlightCacheIncremental(\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t\trawPath,\n\t\t\t\t\tfileContent,\n\t\t\t\t\tcontext.expanded,\n\t\t\t\t\tcomponent.highlighter,\n\t\t\t\t);\n\t\t\t} else if (context.expanded) {\n\t\t\t\tconst cache = component.cache;\n\t\t\t\tif (!cache?.complete || !cache.all || cache.rawPath !== rawPath || cache.rawContent !== fileContent) {\n\t\t\t\t\tcomponent.cache = rebuildWriteHighlightCacheFull(rawPath, fileContent, component.highlighter);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst cache = component.cache;\n\t\t\t\tif (cache?.complete && !cache.all && cache.rawPath === rawPath && cache.rawContent === fileContent) {\n\t\t\t\t\trefreshWriteHighlightPrefix(cache, component.highlighter);\n\t\t\t\t} else {\n\t\t\t\t\tcomponent.cache = rebuildWriteHighlightCacheCollapsed(rawPath, fileContent, component.highlighter);\n\t\t\t\t\tif (component.cache) component.cache.complete = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tcomponent.cache = undefined;\n\t\t}\n\t\tconst cache = component.cache;\n\t\tif (cache && !cache.all && !context.expanded && !context.isPartial && cache.lineCount === undefined) {\n\t\t\tcache.lineCount = countCollapsedLines(cache);\n\t\t\tcache.normalizedLines = cache.normalizedLines.slice(0, WRITE_PARTIAL_FULL_HIGHLIGHT_LINES);\n\t\t}\n\t\tcomponent.setText(\n\t\t\tformatWriteCall(\n\t\t\t\trenderArgs,\n\t\t\t\t{ expanded: context.expanded, isPartial: context.isPartial },\n\t\t\t\ttheme,\n\t\t\t\tcomponent.cache,\n\t\t\t\tcomponent.highlighter,\n\t\t\t\tcontext.cwd,\n\t\t\t),\n\t\t);\n\t\treturn component;\n\t},\n\trenderResult(result, _options, theme, context) {\n\t\tconst output = formatWriteResult({ ...result, isError: context.isError }, theme);\n\t\tif (!output) {\n\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\tcomponent.clear();\n\t\t\treturn component;\n\t\t}\n\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\ttext.setText(output);\n\t\treturn text;\n\t},\n};\n\ndeclarePathHighlightingRenderers(writeRenderers);\n"]}
@@ -18,6 +18,7 @@ import type { ToolDefinition } from "../extensions/types.ts";
18
18
  import type { UsageEntry } from "../session-manager.ts";
19
19
  export { SUBAGENT_DEPTH_ENV } from "./subagent-env.ts";
20
20
  import { type SubagentIsolation, type SubagentMergeOutcome } from "./subagent-worktree.ts";
21
+ import { type TypeBoxAgentTool } from "./tool-definition-wrapper.ts";
21
22
  export type AgentScope = "user" | "project" | "both";
22
23
  export interface AgentConfig {
23
24
  name: string;
@@ -193,21 +194,21 @@ declare const SubagentParams: Type.TObject<{
193
194
  agent: Type.TOptional<Type.TString>;
194
195
  task: Type.TOptional<Type.TString>;
195
196
  model: Type.TOptional<Type.TString>;
196
- thinking: Type.TOptional<Type.TUnsafe<"high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh">>;
197
+ thinking: Type.TOptional<Type.TEnum<["off", "minimal", "low", "medium", "high", "xhigh", "max"]>>;
197
198
  tasks: Type.TOptional<Type.TArray<Type.TObject<{
198
199
  agent: Type.TString;
199
200
  task: Type.TString;
200
201
  id: Type.TOptional<Type.TString>;
201
- thinking: Type.TOptional<Type.TUnsafe<"high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh">>;
202
+ thinking: Type.TOptional<Type.TEnum<["off", "minimal", "low", "medium", "high", "xhigh", "max"]>>;
202
203
  model: Type.TOptional<Type.TString>;
203
204
  cwd: Type.TOptional<Type.TString>;
204
- isolation: Type.TOptional<Type.TUnsafe<"shared" | "worktree">>;
205
+ isolation: Type.TOptional<Type.TEnum<["shared", "worktree"]>>;
205
206
  dependsOn: Type.TOptional<Type.TArray<Type.TString>>;
206
207
  ownerPaths: Type.TOptional<Type.TArray<Type.TString>>;
207
208
  onFailure: Type.TOptional<Type.TObject<{
208
209
  retryWith: Type.TOptional<Type.TObject<{
209
210
  model: Type.TOptional<Type.TString>;
210
- thinking: Type.TOptional<Type.TUnsafe<"high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh">>;
211
+ thinking: Type.TOptional<Type.TEnum<["off", "minimal", "low", "medium", "high", "xhigh", "max"]>>;
211
212
  }>>;
212
213
  maxAttempts: Type.TOptional<Type.TInteger>;
213
214
  }>>;
@@ -221,14 +222,14 @@ declare const SubagentParams: Type.TObject<{
221
222
  agent: Type.TString;
222
223
  task: Type.TString;
223
224
  model: Type.TOptional<Type.TString>;
224
- thinking: Type.TOptional<Type.TUnsafe<"high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh">>;
225
+ thinking: Type.TOptional<Type.TEnum<["off", "minimal", "low", "medium", "high", "xhigh", "max"]>>;
225
226
  cwd: Type.TOptional<Type.TString>;
226
227
  }>>>;
227
- agentScope: Type.TOptional<Type.TUnsafe<"both" | "project" | "user">>;
228
+ agentScope: Type.TOptional<Type.TEnum<["user", "project", "both"]>>;
228
229
  confirmProjectAgents: Type.TOptional<Type.TBoolean>;
229
230
  cwd: Type.TOptional<Type.TString>;
230
- isolation: Type.TOptional<Type.TUnsafe<"shared" | "worktree">>;
231
+ isolation: Type.TOptional<Type.TEnum<["shared", "worktree"]>>;
231
232
  }>;
232
233
  export declare function createSubagentToolDefinition(cwd: string): ToolDefinition<typeof SubagentParams, SubagentDetails>;
233
- export declare function createSubagentTool(cwd: string): import("@earendil-works/pi-agent-core").AgentTool<any, SubagentDetails>;
234
+ export declare function createSubagentTool(cwd: string): TypeBoxAgentTool<typeof SubagentParams, SubagentDetails>;
234
235
  //# sourceMappingURL=subagent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subagent.d.ts","sourceRoot":"","sources":["../../../src/core/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;AAC/F,eAAO,MAAM,wBAAwB,qCAAqC,CAAC;AAE3E,yHAAyH;AACzH,eAAO,MAAM,6BAA6B,QAAa,CAAC;AACxD,gHAAgH;AAChH,eAAO,MAAM,2BAA2B,mCAAmC,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,SAAS,CAgCjF;AAimBD,uJAAuJ;AACvJ,MAAM,WAAW,WAAW;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAkED,uHAAuH;AACvH,eAAO,MAAM,mBAAmB,wCAAwC,CAAC;AAkDzE,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBlB,CAAC;AAwRH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC,OAAO,cAAc,EAAE,eAAe,CAAC,CA83BhH;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC,OAAO,cAAc,EAAE,eAAe,CAAC,CAExG"}
@@ -15,7 +15,6 @@ import { spawn } from "node:child_process";
15
15
  import * as fs from "node:fs";
16
16
  import * as os from "node:os";
17
17
  import * as path from "node:path";
18
- import { StringEnum } from "@earendil-works/pi-ai";
19
18
  import { Container, Markdown, Spacer, Text } from "@earendil-works/pi-tui";
20
19
  import { SUBAGENT_PROGRESS_MAX_WORKERS_PER_RUN, } from "@humain/humain-code-contracts";
21
20
  import { Type } from "typebox";
@@ -977,7 +976,8 @@ async function runSingleAgent(defaultCwd, agents, agentDiagnostics, agentName, t
977
976
  options.traceChild?.finishAttempt(currentResult, isFailedResult(currentResult));
978
977
  return currentResult;
979
978
  }
980
- const ThinkingLevelSchema = StringEnum(["off", "minimal", "low", "medium", "high", "xhigh", "max"], {
979
+ const ThinkingLevelSchema = Type.Enum(["off", "minimal", "low", "medium", "high", "xhigh", "max"], {
980
+ type: "string",
981
981
  description: "Reasoning effort for this child. Maps to the CLI --thinking level. Defaults to the child's own default.",
982
982
  });
983
983
  const TaskItem = Type.Object({
@@ -989,7 +989,8 @@ const TaskItem = Type.Object({
989
989
  description: "Optional canonical provider/model for this child. Defaults to the parent provider/model.",
990
990
  })),
991
991
  cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
992
- isolation: Type.Optional(StringEnum(["shared", "worktree"], {
992
+ isolation: Type.Optional(Type.Enum(["shared", "worktree"], {
993
+ type: "string",
993
994
  description: "Filesystem isolation for this child. 'worktree' runs it in a disposable git worktree and merges its changes back; the caller's policy sets this, not the model.",
994
995
  })),
995
996
  dependsOn: Type.Optional(Type.Array(Type.String(), {
@@ -1054,7 +1055,8 @@ const ChainItem = Type.Object({
1054
1055
  thinking: Type.Optional(ThinkingLevelSchema),
1055
1056
  cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
1056
1057
  });
1057
- const AgentScopeSchema = StringEnum(["user", "project", "both"], {
1058
+ const AgentScopeSchema = Type.Enum(["user", "project", "both"], {
1059
+ type: "string",
1058
1060
  description: 'Which agent directories to use. Default: "user". Use "both" to include project-local agents.',
1059
1061
  default: "user",
1060
1062
  });
@@ -1070,7 +1072,8 @@ const SubagentParams = Type.Object({
1070
1072
  agentScope: Type.Optional(AgentScopeSchema),
1071
1073
  confirmProjectAgents: Type.Optional(Type.Boolean({ description: "Prompt before running project-local agents. Default: true.", default: true })),
1072
1074
  cwd: Type.Optional(Type.String({ description: "Working directory for the agent process (single mode)" })),
1073
- isolation: Type.Optional(StringEnum(["shared", "worktree"], {
1075
+ isolation: Type.Optional(Type.Enum(["shared", "worktree"], {
1076
+ type: "string",
1074
1077
  description: "Filesystem isolation for this child. 'worktree' runs it in a disposable git worktree and merges its changes back; the caller's policy sets this, not the model.",
1075
1078
  })),
1076
1079
  });