@humain/humain-code 0.6.2 → 0.7.0

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 (792) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/README.md +23 -6
  3. package/dist/agent-monitor/entry.lazy.d.ts +3 -0
  4. package/dist/agent-monitor/entry.lazy.d.ts.map +1 -0
  5. package/dist/agent-monitor/entry.lazy.js +3 -0
  6. package/dist/agent-monitor/entry.lazy.js.map +1 -0
  7. package/dist/bundle/agent-monitor.js +1 -1
  8. package/dist/bundle/chunks/adaptive-peer-worker-X2ZNZE3S.js +8 -0
  9. package/dist/bundle/chunks/adaptive-session-host-7KDSQV5I.js +162 -0
  10. package/dist/bundle/chunks/anthropic-messages-TQK3FUV3.js +68 -0
  11. package/dist/bundle/chunks/anthropic.js +13 -10
  12. package/dist/bundle/chunks/{azure-openai-responses-IV74M5OR.js → azure-openai-responses-JY7OSLH2.js} +6 -6
  13. package/dist/bundle/chunks/bedrock-converse-stream.js +79 -74
  14. package/dist/bundle/chunks/chunk-2FYYW6FY.js +2 -0
  15. package/dist/bundle/chunks/{chunk-A2VPLMF2.js → chunk-2G7YVAVF.js} +1 -1
  16. package/dist/bundle/chunks/chunk-32QLLD2P.js +1114 -0
  17. package/dist/bundle/chunks/{chunk-3LP543EX.js → chunk-3EDMWQ35.js} +17 -16
  18. package/dist/bundle/chunks/chunk-3HVHETMU.js +18 -0
  19. package/dist/bundle/chunks/{chunk-XMZGB3H4.js → chunk-4HTVBBJD.js} +11 -6
  20. package/dist/bundle/chunks/chunk-4JRER4XK.js +175 -0
  21. package/dist/bundle/chunks/{chunk-FHLLDO7U.js → chunk-4PRNKB6V.js} +5 -5
  22. package/dist/bundle/chunks/chunk-4QAXV5T6.js +49 -0
  23. package/dist/bundle/chunks/{chunk-JCTQQ3DX.js → chunk-4V5VL2BO.js} +1 -1
  24. package/dist/bundle/chunks/chunk-5B25YXF7.js +24 -0
  25. package/dist/bundle/chunks/chunk-5L4PBYC7.js +11 -0
  26. package/dist/bundle/chunks/chunk-66FZJO75.js +5146 -0
  27. package/dist/bundle/chunks/chunk-6P6GJPYB.js +4 -0
  28. package/dist/bundle/chunks/chunk-6PNQYO6A.js +10 -0
  29. package/dist/bundle/chunks/chunk-7NKUVTBL.js +76 -0
  30. package/dist/bundle/chunks/chunk-AEWYICBL.js +89 -0
  31. package/dist/bundle/chunks/chunk-AQ4EXORZ.js +14 -0
  32. package/dist/bundle/chunks/chunk-AZXVJN6E.js +19 -0
  33. package/dist/bundle/chunks/chunk-CRN54O4D.js +24 -0
  34. package/dist/bundle/chunks/chunk-CTU2ECLD.js +7 -0
  35. package/dist/bundle/chunks/{chunk-BQ3TMEWD.js → chunk-EIC7CQX3.js} +4 -3
  36. package/dist/bundle/chunks/chunk-F6ZAYLU2.js +59 -0
  37. package/dist/bundle/chunks/chunk-G4QPSFBF.js +493 -0
  38. package/dist/bundle/chunks/chunk-GME4AWDG.js +23 -0
  39. package/dist/bundle/chunks/{chunk-SFMDIVZ4.js → chunk-GRJUKEE3.js} +43 -30
  40. package/dist/bundle/chunks/chunk-GTILMMUF.js +12 -0
  41. package/dist/bundle/chunks/chunk-GUHNFZ2Q.js +51 -0
  42. package/dist/bundle/chunks/chunk-GY663MNP.js +11 -0
  43. package/dist/bundle/chunks/chunk-HTA325LJ.js +56 -0
  44. package/dist/bundle/chunks/{chunk-5L4JG6PO.js → chunk-I3NDOUHE.js} +8 -7
  45. package/dist/bundle/chunks/chunk-I5E7RQ5V.js +21 -0
  46. package/dist/bundle/chunks/chunk-IWZQ25I3.js +5 -0
  47. package/dist/bundle/chunks/chunk-IYGHKVUG.js +2 -0
  48. package/dist/bundle/chunks/chunk-J57HOSWD.js +21 -0
  49. package/dist/bundle/chunks/chunk-JF7FYXAI.js +288 -0
  50. package/dist/bundle/chunks/chunk-JSZBTGI6.js +10 -0
  51. package/dist/bundle/chunks/chunk-JYWUOKOI.js +1061 -0
  52. package/dist/bundle/chunks/{chunk-DLCBSLHW.js → chunk-KRCX3ZBA.js} +1 -1
  53. package/dist/bundle/chunks/chunk-KTSJYIYC.js +30 -0
  54. package/dist/bundle/chunks/{chunk-K7SDY3VJ.js → chunk-LB4CIS4F.js} +40 -165
  55. package/dist/bundle/chunks/{chunk-NN53K2QQ.js → chunk-LYZ37DJP.js} +2 -14
  56. package/dist/bundle/chunks/chunk-MD7K7RPN.js +20 -0
  57. package/dist/bundle/chunks/chunk-MX4Q4W6H.js +214 -0
  58. package/dist/bundle/chunks/{chunk-6PD3T2EF.js → chunk-N2SNMUD3.js} +1 -1
  59. package/dist/bundle/chunks/chunk-NXA6NEHE.js +54 -0
  60. package/dist/bundle/chunks/chunk-OB332KMV.js +300 -0
  61. package/dist/bundle/chunks/chunk-P6AXBESH.js +1883 -0
  62. package/dist/bundle/chunks/chunk-PPBDDQHP.js +11 -0
  63. package/dist/bundle/chunks/chunk-PWUDFU5V.js +51 -0
  64. package/dist/bundle/chunks/chunk-Q5RKNQ2T.js +73 -0
  65. package/dist/bundle/chunks/chunk-QT6ZHDMP.js +12 -0
  66. package/dist/bundle/chunks/chunk-R5OOX7RW.js +16 -0
  67. package/dist/bundle/chunks/chunk-R6YQR7TZ.js +25 -0
  68. package/dist/bundle/chunks/{chunk-4ZBGTJJM.js → chunk-RNBZBCH2.js} +1 -1
  69. package/dist/bundle/chunks/chunk-RQU722SY.js +1 -0
  70. package/dist/bundle/chunks/{chunk-RGUZULEE.js → chunk-RS6PZK35.js} +71 -72
  71. package/dist/bundle/chunks/{jiti-loader-6P33XTLC.js → chunk-RW7GT7L3.js} +1 -1
  72. package/dist/bundle/chunks/{chunk-PCTLFSQG.js → chunk-SCINMV4X.js} +1 -1
  73. package/dist/bundle/chunks/{chunk-NCC2FAJN.js → chunk-SSRCVJZK.js} +28 -28
  74. package/dist/bundle/chunks/chunk-T5A6T24H.js +93 -0
  75. package/dist/bundle/chunks/chunk-T7BXP46S.js +3367 -0
  76. package/dist/bundle/chunks/chunk-TGDPZCSW.js +9 -0
  77. package/dist/bundle/chunks/{chunk-4J6BGNX2.js → chunk-TWAHPPXN.js} +434 -429
  78. package/dist/bundle/chunks/chunk-UEW6TUSP.js +36 -0
  79. package/dist/bundle/chunks/chunk-UZNIPOGS.js +323 -0
  80. package/dist/bundle/chunks/{chunk-KM4GQ2BU.js → chunk-VFLVWPLZ.js} +5 -6
  81. package/dist/bundle/chunks/chunk-WAPZN4KP.js +74 -0
  82. package/dist/bundle/chunks/chunk-WCFHG6NO.js +16 -0
  83. package/dist/bundle/chunks/chunk-WQ7EJQIT.js +839 -0
  84. package/dist/bundle/chunks/chunk-WQOOJP7U.js +4 -0
  85. package/dist/bundle/chunks/chunk-XHDVDJM7.js +17 -0
  86. package/dist/bundle/chunks/chunk-YPZPCHNV.js +3 -0
  87. package/dist/bundle/chunks/chunk-Z5YLKK3S.js +41 -0
  88. package/dist/bundle/chunks/chunk-ZJUU6WOV.js +2052 -0
  89. package/dist/bundle/chunks/{cli-N7KOVPLB.js → cli-H4LJNE2V.js} +2 -2
  90. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-KRMHG2L3.js → cloudflare-workers-ai-system-one-T5R2RVFQ.js} +1 -1
  91. package/dist/bundle/chunks/codemode-worker.js +2 -0
  92. package/dist/bundle/chunks/compat-ZK2DIW3P.js +15 -0
  93. package/dist/bundle/chunks/dist-EY7YKQHB.js +11 -0
  94. package/dist/bundle/chunks/dist-FMWWM4H7.js +268 -0
  95. package/dist/bundle/chunks/dist-NHQTBDHT.js +1107 -0
  96. package/dist/bundle/chunks/{easter-egg-3d-O2GG2XIG.js → easter-egg-3d-BUEOC3NO.js} +1 -1
  97. package/dist/bundle/chunks/entry-A2CSLKHC.js +323 -0
  98. package/dist/bundle/chunks/entry-AL54ZGYO.js +2 -0
  99. package/dist/bundle/chunks/{execute-LMBACTKA.js → execute-MY5JSEPV.js} +18 -15
  100. package/dist/bundle/chunks/{extract-CXXLVFC5.js → extract-PTGACPGP.js} +3 -3
  101. package/dist/bundle/chunks/flow-implementer-APJFY4YI.js +21 -0
  102. package/dist/bundle/chunks/github-copilot.js +66 -62
  103. package/dist/bundle/chunks/{google-generative-ai-SBL77OXO.js → google-generative-ai-UL7YEQ6J.js} +2 -3
  104. package/dist/bundle/chunks/{google-vertex-NZBNNXMK.js → google-vertex-OTMSPUYH.js} +3 -3
  105. package/dist/bundle/chunks/host-75YAHLDR.js +3 -0
  106. package/dist/bundle/chunks/index.bundle-THL4EUSU.js +390 -0
  107. package/dist/bundle/chunks/inprocess-5NP5VJHZ.js +32 -0
  108. package/dist/bundle/chunks/interactive-mode-IW4PIVAQ.js +5 -0
  109. package/dist/bundle/chunks/jiti-bun-loader-VSLLRCSD.js +3459 -0
  110. package/dist/bundle/chunks/jiti-loader-TMJL6S2D.js +2 -0
  111. package/dist/bundle/chunks/{llama-cpp-classify-PP63BYDF.js → llama-cpp-classify-GJAXULWL.js} +1 -1
  112. package/dist/bundle/chunks/{mistral-conversations-DX4YKJSO.js → mistral-conversations-E72Y6OC3.js} +2 -2
  113. package/dist/bundle/chunks/{node-UGQUSQE6.js → node-ZFIIS5IM.js} +32 -32
  114. package/dist/bundle/chunks/openai-codex-responses-S7CMCAOY.js +101 -0
  115. package/dist/bundle/chunks/openai-completions-2Z57N7PC.js +87 -0
  116. package/dist/bundle/chunks/{openai-decisions-ALJROWBE.js → openai-decisions-JIOJDB4C.js} +1 -1
  117. package/dist/bundle/chunks/openai-responses-5VBZSTHL.js +27 -0
  118. package/dist/bundle/chunks/{openrouter-images-FCJT7C7I.js → openrouter-images-S6O7DBEJ.js} +1 -1
  119. package/dist/bundle/chunks/{pi-messages-NHTQQOPW.js → pi-messages-SMLN5J2W.js} +10 -7
  120. package/dist/bundle/chunks/runtime-OYTWXIUM.js +2 -0
  121. package/dist/bundle/chunks/session-picker-DM6S37IF.js +4 -0
  122. package/dist/bundle/chunks/startup-ui-4GGLWNSU.js +3 -0
  123. package/dist/bundle/chunks/trace-command-YLDYCL55.js +254 -0
  124. package/dist/bundle/chunks/typesafe-system-one-7BEL3H5N.js +3 -0
  125. package/dist/bundle/chunks/virtual-modules-TI3W24YL.js +28 -0
  126. package/dist/bundle/cli-runtime.js +5 -3
  127. package/dist/bundle/flow/agents/orch-implementation-fast.md +4 -4
  128. package/dist/bundle/flow/agents/orch-implementation-strong.md +5 -5
  129. package/dist/bundle/flow/package.json +35 -3
  130. package/dist/bundle/index.js +20 -17
  131. package/dist/bundle/orchestrate/README.md +37 -0
  132. package/dist/bundle/{flow → orchestrate}/agents/orch-qa-agent.md +1 -1
  133. package/dist/bundle/{flow → orchestrate}/agents/orch-worker.md +1 -1
  134. package/dist/bundle/{flow → orchestrate}/agents/orchestrator-lead.md +1 -1
  135. package/dist/bundle/orchestrate/package.json +29 -0
  136. package/dist/bundle/rpc-entry.js +5 -3
  137. package/dist/cli/args.d.ts +6 -0
  138. package/dist/cli/args.d.ts.map +1 -1
  139. package/dist/cli/args.js +69 -2
  140. package/dist/cli/args.js.map +1 -1
  141. package/dist/cli/auth-check.d.ts +3 -2
  142. package/dist/cli/auth-check.d.ts.map +1 -1
  143. package/dist/cli/auth-check.js +4 -3
  144. package/dist/cli/auth-check.js.map +1 -1
  145. package/dist/cli/config-selector.d.ts.map +1 -1
  146. package/dist/cli/config-selector.js +3 -1
  147. package/dist/cli/config-selector.js.map +1 -1
  148. package/dist/cli/file-processor.d.ts +2 -0
  149. package/dist/cli/file-processor.d.ts.map +1 -1
  150. package/dist/cli/file-processor.js +6 -6
  151. package/dist/cli/file-processor.js.map +1 -1
  152. package/dist/cli/metadata-disclosure.d.ts +4 -0
  153. package/dist/cli/metadata-disclosure.d.ts.map +1 -0
  154. package/dist/cli/metadata-disclosure.js +23 -0
  155. package/dist/cli/metadata-disclosure.js.map +1 -0
  156. package/dist/cli/project-trust.d.ts.map +1 -1
  157. package/dist/cli/project-trust.js +4 -1
  158. package/dist/cli/project-trust.js.map +1 -1
  159. package/dist/cli/session-picker.lazy.d.ts +3 -0
  160. package/dist/cli/session-picker.lazy.d.ts.map +1 -0
  161. package/dist/cli/session-picker.lazy.js +3 -0
  162. package/dist/cli/session-picker.lazy.js.map +1 -0
  163. package/dist/cli/startup-ui.d.ts +4 -4
  164. package/dist/cli/startup-ui.d.ts.map +1 -1
  165. package/dist/cli/startup-ui.js +38 -14
  166. package/dist/cli/startup-ui.js.map +1 -1
  167. package/dist/cli/startup-ui.lazy.d.ts +3 -0
  168. package/dist/cli/startup-ui.lazy.d.ts.map +1 -0
  169. package/dist/cli/startup-ui.lazy.js +3 -0
  170. package/dist/cli/startup-ui.lazy.js.map +1 -0
  171. package/dist/cli/trace-command.lazy.d.ts +3 -0
  172. package/dist/cli/trace-command.lazy.d.ts.map +1 -0
  173. package/dist/cli/trace-command.lazy.js +3 -0
  174. package/dist/cli/trace-command.lazy.js.map +1 -0
  175. package/dist/cli.js.map +1 -1
  176. package/dist/coordination/broker/entry.lazy.d.ts +3 -0
  177. package/dist/coordination/broker/entry.lazy.d.ts.map +1 -0
  178. package/dist/coordination/broker/entry.lazy.js +3 -0
  179. package/dist/coordination/broker/entry.lazy.js.map +1 -0
  180. package/dist/core/acceptance-command.d.ts +15 -0
  181. package/dist/core/acceptance-command.d.ts.map +1 -0
  182. package/dist/core/acceptance-command.js +150 -0
  183. package/dist/core/acceptance-command.js.map +1 -0
  184. package/dist/core/acceptance-ledger.d.ts +52 -0
  185. package/dist/core/acceptance-ledger.d.ts.map +1 -0
  186. package/dist/core/acceptance-ledger.js +341 -0
  187. package/dist/core/acceptance-ledger.js.map +1 -0
  188. package/dist/core/admission-types.d.ts +69 -0
  189. package/dist/core/admission-types.js +2 -0
  190. package/dist/core/admission-types.js.map +1 -0
  191. package/dist/core/agent-session-runtime.d.ts +7 -0
  192. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  193. package/dist/core/agent-session-runtime.js +43 -9
  194. package/dist/core/agent-session-runtime.js.map +1 -1
  195. package/dist/core/agent-session-services.d.ts +8 -0
  196. package/dist/core/agent-session-services.d.ts.map +1 -1
  197. package/dist/core/agent-session-services.js +13 -1
  198. package/dist/core/agent-session-services.js.map +1 -1
  199. package/dist/core/agent-session.d.ts +127 -10
  200. package/dist/core/agent-session.d.ts.map +1 -1
  201. package/dist/core/agent-session.js +1390 -145
  202. package/dist/core/agent-session.js.map +1 -1
  203. package/dist/core/anthropic-subscription-usage.d.ts +1 -1
  204. package/dist/core/anthropic-subscription-usage.d.ts.map +1 -1
  205. package/dist/core/anthropic-subscription-usage.js +31 -3
  206. package/dist/core/anthropic-subscription-usage.js.map +1 -1
  207. package/dist/core/auth-storage.d.ts +2 -1
  208. package/dist/core/auth-storage.d.ts.map +1 -1
  209. package/dist/core/auth-storage.js +13 -10
  210. package/dist/core/auth-storage.js.map +1 -1
  211. package/dist/core/auto-session-namer.d.ts.map +1 -1
  212. package/dist/core/auto-session-namer.js +3 -1
  213. package/dist/core/auto-session-namer.js.map +1 -1
  214. package/dist/core/bash-executor.d.ts.map +1 -1
  215. package/dist/core/bash-executor.js +3 -1
  216. package/dist/core/bash-executor.js.map +1 -1
  217. package/dist/core/bug-report-redaction.d.ts +4 -0
  218. package/dist/core/bug-report-redaction.d.ts.map +1 -0
  219. package/dist/core/bug-report-redaction.js +209 -0
  220. package/dist/core/bug-report-redaction.js.map +1 -0
  221. package/dist/core/bug-report.d.ts +26 -6
  222. package/dist/core/bug-report.d.ts.map +1 -1
  223. package/dist/core/bug-report.js +82 -9
  224. package/dist/core/bug-report.js.map +1 -1
  225. package/dist/core/cache-warmer.d.ts.map +1 -1
  226. package/dist/core/cache-warmer.js +5 -0
  227. package/dist/core/cache-warmer.js.map +1 -1
  228. package/dist/core/compaction/compaction.d.ts +6 -0
  229. package/dist/core/compaction/compaction.d.ts.map +1 -1
  230. package/dist/core/compaction/compaction.js +103 -71
  231. package/dist/core/compaction/compaction.js.map +1 -1
  232. package/dist/core/compaction/utils.d.ts.map +1 -1
  233. package/dist/core/compaction/utils.js +2 -1
  234. package/dist/core/compaction/utils.js.map +1 -1
  235. package/dist/core/extensions/jiti-bun-babel.d.ts +4 -0
  236. package/dist/core/extensions/jiti-bun-babel.d.ts.map +1 -0
  237. package/dist/core/extensions/jiti-bun-babel.js +4 -0
  238. package/dist/core/extensions/jiti-bun-babel.js.map +1 -0
  239. package/dist/core/extensions/jiti-bun-loader.d.ts +4 -0
  240. package/dist/core/extensions/jiti-bun-loader.d.ts.map +1 -0
  241. package/dist/core/extensions/jiti-bun-loader.js +13 -0
  242. package/dist/core/extensions/jiti-bun-loader.js.map +1 -0
  243. package/dist/core/extensions/jiti-bun-loader.lazy.d.ts +3 -0
  244. package/dist/core/extensions/jiti-bun-loader.lazy.d.ts.map +1 -0
  245. package/dist/core/extensions/jiti-bun-loader.lazy.js +3 -0
  246. package/dist/core/extensions/jiti-bun-loader.lazy.js.map +1 -0
  247. package/dist/core/extensions/loader.d.ts.map +1 -1
  248. package/dist/core/extensions/loader.js +9 -3
  249. package/dist/core/extensions/loader.js.map +1 -1
  250. package/dist/core/extensions/runner.d.ts.map +1 -1
  251. package/dist/core/extensions/runner.js +4 -0
  252. package/dist/core/extensions/runner.js.map +1 -1
  253. package/dist/core/extensions/types.d.ts +3 -0
  254. package/dist/core/extensions/types.d.ts.map +1 -1
  255. package/dist/core/extensions/types.js.map +1 -1
  256. package/dist/core/flow-implementer.d.ts +25 -0
  257. package/dist/core/flow-implementer.d.ts.map +1 -0
  258. package/dist/core/flow-implementer.js +301 -0
  259. package/dist/core/flow-implementer.js.map +1 -0
  260. package/dist/core/internal-process.d.ts +23 -0
  261. package/dist/core/internal-process.d.ts.map +1 -0
  262. package/dist/core/internal-process.js +88 -0
  263. package/dist/core/internal-process.js.map +1 -0
  264. package/dist/core/keybindings.d.ts +2 -2
  265. package/dist/core/keybindings.js +1 -1
  266. package/dist/core/keybindings.js.map +1 -1
  267. package/dist/core/model-config.d.ts +52 -0
  268. package/dist/core/model-config.d.ts.map +1 -1
  269. package/dist/core/model-config.js +4 -4
  270. package/dist/core/model-config.js.map +1 -1
  271. package/dist/core/model-registry.d.ts +4 -0
  272. package/dist/core/model-registry.d.ts.map +1 -1
  273. package/dist/core/model-registry.js +8 -0
  274. package/dist/core/model-registry.js.map +1 -1
  275. package/dist/core/model-request-admission.d.ts +51 -0
  276. package/dist/core/model-request-admission.d.ts.map +1 -0
  277. package/dist/core/model-request-admission.js +103 -0
  278. package/dist/core/model-request-admission.js.map +1 -0
  279. package/dist/core/model-resolver.d.ts +4 -0
  280. package/dist/core/model-resolver.d.ts.map +1 -1
  281. package/dist/core/model-resolver.js +109 -2
  282. package/dist/core/model-resolver.js.map +1 -1
  283. package/dist/core/model-runtime.d.ts +56 -1
  284. package/dist/core/model-runtime.d.ts.map +1 -1
  285. package/dist/core/model-runtime.js +482 -40
  286. package/dist/core/model-runtime.js.map +1 -1
  287. package/dist/core/model-selection-intent.d.ts +14 -0
  288. package/dist/core/model-selection-intent.d.ts.map +1 -0
  289. package/dist/core/model-selection-intent.js +15 -0
  290. package/dist/core/model-selection-intent.js.map +1 -0
  291. package/dist/core/oauth-account-pool.d.ts +4 -1
  292. package/dist/core/oauth-account-pool.d.ts.map +1 -1
  293. package/dist/core/oauth-account-pool.js +251 -228
  294. package/dist/core/oauth-account-pool.js.map +1 -1
  295. package/dist/core/os-secret-store.d.ts +25 -0
  296. package/dist/core/os-secret-store.d.ts.map +1 -0
  297. package/dist/core/os-secret-store.js +290 -0
  298. package/dist/core/os-secret-store.js.map +1 -0
  299. package/dist/core/output-guard.d.ts.map +1 -1
  300. package/dist/core/output-guard.js +62 -2
  301. package/dist/core/output-guard.js.map +1 -1
  302. package/dist/core/pi-ai-schemas.d.ts +4 -0
  303. package/dist/core/pi-ai-schemas.d.ts.map +1 -1
  304. package/dist/core/private-windows-path.d.ts +4 -0
  305. package/dist/core/private-windows-path.d.ts.map +1 -0
  306. package/dist/core/private-windows-path.js +44 -0
  307. package/dist/core/private-windows-path.js.map +1 -0
  308. package/dist/core/prompt-templates.d.ts.map +1 -1
  309. package/dist/core/prompt-templates.js +18 -2
  310. package/dist/core/prompt-templates.js.map +1 -1
  311. package/dist/core/provider-composer.d.ts.map +1 -1
  312. package/dist/core/provider-composer.js +1 -1
  313. package/dist/core/provider-composer.js.map +1 -1
  314. package/dist/core/resource-loader.d.ts.map +1 -1
  315. package/dist/core/resource-loader.js +6 -2
  316. package/dist/core/resource-loader.js.map +1 -1
  317. package/dist/core/run-outcome.d.ts +40 -0
  318. package/dist/core/run-outcome.d.ts.map +1 -0
  319. package/dist/core/run-outcome.js +91 -0
  320. package/dist/core/run-outcome.js.map +1 -0
  321. package/dist/core/run-preflight.d.ts +5 -0
  322. package/dist/core/run-preflight.d.ts.map +1 -0
  323. package/dist/core/run-preflight.js +96 -0
  324. package/dist/core/run-preflight.js.map +1 -0
  325. package/dist/core/runtime-credentials.d.ts +18 -2
  326. package/dist/core/runtime-credentials.d.ts.map +1 -1
  327. package/dist/core/runtime-credentials.js +65 -9
  328. package/dist/core/runtime-credentials.js.map +1 -1
  329. package/dist/core/sdk.d.ts +19 -3
  330. package/dist/core/sdk.d.ts.map +1 -1
  331. package/dist/core/sdk.js +115 -20
  332. package/dist/core/sdk.js.map +1 -1
  333. package/dist/core/settings-defaults.d.ts +2 -1
  334. package/dist/core/settings-defaults.d.ts.map +1 -1
  335. package/dist/core/settings-defaults.js +2 -1
  336. package/dist/core/settings-defaults.js.map +1 -1
  337. package/dist/core/settings-manager.d.ts +15 -4
  338. package/dist/core/settings-manager.d.ts.map +1 -1
  339. package/dist/core/settings-manager.js +114 -22
  340. package/dist/core/settings-manager.js.map +1 -1
  341. package/dist/core/settings-schema.d.ts +7 -2
  342. package/dist/core/settings-schema.d.ts.map +1 -1
  343. package/dist/core/settings-schema.js +12 -5
  344. package/dist/core/settings-schema.js.map +1 -1
  345. package/dist/core/skills.d.ts.map +1 -1
  346. package/dist/core/skills.js +11 -0
  347. package/dist/core/skills.js.map +1 -1
  348. package/dist/core/system-prompt.d.ts +3 -0
  349. package/dist/core/system-prompt.d.ts.map +1 -1
  350. package/dist/core/system-prompt.js +10 -2
  351. package/dist/core/system-prompt.js.map +1 -1
  352. package/dist/core/tools/bash-jobs.d.ts +109 -0
  353. package/dist/core/tools/bash-jobs.d.ts.map +1 -0
  354. package/dist/core/tools/bash-jobs.js +563 -0
  355. package/dist/core/tools/bash-jobs.js.map +1 -0
  356. package/dist/core/tools/bash.d.ts +68 -6
  357. package/dist/core/tools/bash.d.ts.map +1 -1
  358. package/dist/core/tools/bash.js +350 -37
  359. package/dist/core/tools/bash.js.map +1 -1
  360. package/dist/core/tools/edit-diff.d.ts +11 -1
  361. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  362. package/dist/core/tools/edit-diff.js +89 -20
  363. package/dist/core/tools/edit-diff.js.map +1 -1
  364. package/dist/core/tools/edit.d.ts.map +1 -1
  365. package/dist/core/tools/edit.js +15 -7
  366. package/dist/core/tools/edit.js.map +1 -1
  367. package/dist/core/tools/file-mutation-custody.d.ts +29 -0
  368. package/dist/core/tools/file-mutation-custody.d.ts.map +1 -0
  369. package/dist/core/tools/file-mutation-custody.js +173 -0
  370. package/dist/core/tools/file-mutation-custody.js.map +1 -0
  371. package/dist/core/tools/find.d.ts +6 -0
  372. package/dist/core/tools/find.d.ts.map +1 -1
  373. package/dist/core/tools/find.js +84 -38
  374. package/dist/core/tools/find.js.map +1 -1
  375. package/dist/core/tools/grep.d.ts +8 -2
  376. package/dist/core/tools/grep.d.ts.map +1 -1
  377. package/dist/core/tools/grep.js +121 -77
  378. package/dist/core/tools/grep.js.map +1 -1
  379. package/dist/core/tools/index.d.ts +3 -1
  380. package/dist/core/tools/index.d.ts.map +1 -1
  381. package/dist/core/tools/index.js +12 -0
  382. package/dist/core/tools/index.js.map +1 -1
  383. package/dist/core/tools/jobs.d.ts +24 -0
  384. package/dist/core/tools/jobs.d.ts.map +1 -0
  385. package/dist/core/tools/jobs.js +86 -0
  386. package/dist/core/tools/jobs.js.map +1 -0
  387. package/dist/core/tools/ls.d.ts.map +1 -1
  388. package/dist/core/tools/ls.js +2 -1
  389. package/dist/core/tools/ls.js.map +1 -1
  390. package/dist/core/tools/output-accumulator.d.ts +12 -1
  391. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  392. package/dist/core/tools/output-accumulator.js +88 -8
  393. package/dist/core/tools/output-accumulator.js.map +1 -1
  394. package/dist/core/tools/output-cleanup.d.ts +40 -0
  395. package/dist/core/tools/output-cleanup.d.ts.map +1 -0
  396. package/dist/core/tools/output-cleanup.js +273 -0
  397. package/dist/core/tools/output-cleanup.js.map +1 -0
  398. package/dist/core/tools/powershell.d.ts.map +1 -1
  399. package/dist/core/tools/powershell.js +15 -2
  400. package/dist/core/tools/powershell.js.map +1 -1
  401. package/dist/core/tools/read.d.ts +21 -0
  402. package/dist/core/tools/read.d.ts.map +1 -1
  403. package/dist/core/tools/read.js +162 -29
  404. package/dist/core/tools/read.js.map +1 -1
  405. package/dist/core/tools/renderers/bash.d.ts.map +1 -1
  406. package/dist/core/tools/renderers/bash.js +3 -1
  407. package/dist/core/tools/renderers/bash.js.map +1 -1
  408. package/dist/core/tools/renderers/index.d.ts.map +1 -1
  409. package/dist/core/tools/renderers/index.js +1 -0
  410. package/dist/core/tools/renderers/index.js.map +1 -1
  411. package/dist/core/tools/subagent.d.ts +5 -1
  412. package/dist/core/tools/subagent.d.ts.map +1 -1
  413. package/dist/core/tools/subagent.js +76 -19
  414. package/dist/core/tools/subagent.js.map +1 -1
  415. package/dist/core/tools/truncate.d.ts +4 -0
  416. package/dist/core/tools/truncate.d.ts.map +1 -1
  417. package/dist/core/tools/truncate.js +24 -1
  418. package/dist/core/tools/truncate.js.map +1 -1
  419. package/dist/core/tools/write.d.ts.map +1 -1
  420. package/dist/core/tools/write.js +6 -1
  421. package/dist/core/tools/write.js.map +1 -1
  422. package/dist/core/trace/config.js +3 -3
  423. package/dist/core/trace/config.js.map +1 -1
  424. package/dist/core/trace/redaction.d.ts.map +1 -1
  425. package/dist/core/trace/redaction.js +12 -9
  426. package/dist/core/trace/redaction.js.map +1 -1
  427. package/dist/core/trace-client/credential-store.d.ts +1 -1
  428. package/dist/core/trace-client/credential-store.d.ts.map +1 -1
  429. package/dist/core/trace-client/credential-store.js +20 -3
  430. package/dist/core/trace-client/credential-store.js.map +1 -1
  431. package/dist/core/usage-ledger.d.ts +35 -0
  432. package/dist/core/usage-ledger.d.ts.map +1 -0
  433. package/dist/core/usage-ledger.js +140 -0
  434. package/dist/core/usage-ledger.js.map +1 -0
  435. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  436. package/dist/extensions/codemode/execute.js +24 -15
  437. package/dist/extensions/codemode/execute.js.map +1 -1
  438. package/dist/extensions/codemode/index.d.ts +4 -2
  439. package/dist/extensions/codemode/index.d.ts.map +1 -1
  440. package/dist/extensions/codemode/index.js +8 -4
  441. package/dist/extensions/codemode/index.js.map +1 -1
  442. package/dist/extensions/codemode/tool.d.ts +4 -2
  443. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  444. package/dist/extensions/codemode/tool.js +34 -12
  445. package/dist/extensions/codemode/tool.js.map +1 -1
  446. package/dist/extensions/llama/client.d.ts +2 -0
  447. package/dist/extensions/llama/client.d.ts.map +1 -1
  448. package/dist/extensions/llama/client.js +23 -2
  449. package/dist/extensions/llama/client.js.map +1 -1
  450. package/dist/extensions/llama/ui.d.ts.map +1 -1
  451. package/dist/extensions/llama/ui.js +15 -3
  452. package/dist/extensions/llama/ui.js.map +1 -1
  453. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  454. package/dist/extensions/mcp/runtime.js +3 -2
  455. package/dist/extensions/mcp/runtime.js.map +1 -1
  456. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  457. package/dist/extensions/tool-search/tool.js +18 -6
  458. package/dist/extensions/tool-search/tool.js.map +1 -1
  459. package/dist/extensions/usage/hcode-overview.d.ts +23 -0
  460. package/dist/extensions/usage/hcode-overview.d.ts.map +1 -0
  461. package/dist/extensions/usage/hcode-overview.js +109 -0
  462. package/dist/extensions/usage/hcode-overview.js.map +1 -0
  463. package/dist/extensions/usage/index.d.ts +5 -0
  464. package/dist/extensions/usage/index.d.ts.map +1 -1
  465. package/dist/extensions/usage/index.js +194 -12
  466. package/dist/extensions/usage/index.js.map +1 -1
  467. package/dist/extensions/usage/overview.d.ts +5 -0
  468. package/dist/extensions/usage/overview.d.ts.map +1 -1
  469. package/dist/extensions/usage/overview.js +21 -1
  470. package/dist/extensions/usage/overview.js.map +1 -1
  471. package/dist/extensions/usage/popup.d.ts +14 -3
  472. package/dist/extensions/usage/popup.d.ts.map +1 -1
  473. package/dist/extensions/usage/popup.js +199 -25
  474. package/dist/extensions/usage/popup.js.map +1 -1
  475. package/dist/humain/adaptive-execution.d.ts +51 -0
  476. package/dist/humain/adaptive-execution.d.ts.map +1 -0
  477. package/dist/humain/adaptive-execution.js +100 -0
  478. package/dist/humain/adaptive-execution.js.map +1 -0
  479. package/dist/humain/adaptive-peer-process.d.ts +44 -0
  480. package/dist/humain/adaptive-peer-process.d.ts.map +1 -0
  481. package/dist/humain/adaptive-peer-process.js +159 -0
  482. package/dist/humain/adaptive-peer-process.js.map +1 -0
  483. package/dist/humain/adaptive-peer-worker.d.ts +3 -0
  484. package/dist/humain/adaptive-peer-worker.d.ts.map +1 -0
  485. package/dist/humain/adaptive-peer-worker.js +122 -0
  486. package/dist/humain/adaptive-peer-worker.js.map +1 -0
  487. package/dist/humain/adaptive-runtime-types.d.ts +621 -0
  488. package/dist/humain/adaptive-runtime-types.d.ts.map +1 -0
  489. package/dist/humain/adaptive-runtime-types.js +3 -0
  490. package/dist/humain/adaptive-runtime-types.js.map +1 -0
  491. package/dist/humain/adaptive-session-host.d.ts +113 -0
  492. package/dist/humain/adaptive-session-host.d.ts.map +1 -0
  493. package/dist/humain/adaptive-session-host.js +1838 -0
  494. package/dist/humain/adaptive-session-host.js.map +1 -0
  495. package/dist/humain/adhd/index.d.ts +2 -2
  496. package/dist/humain/adhd/index.d.ts.map +1 -1
  497. package/dist/humain/adhd/index.js +22 -13
  498. package/dist/humain/adhd/index.js.map +1 -1
  499. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +162 -49
  500. package/dist/humain/caveman/index.d.ts +1 -1
  501. package/dist/humain/caveman/index.d.ts.map +1 -1
  502. package/dist/humain/caveman/index.js +21 -12
  503. package/dist/humain/caveman/index.js.map +1 -1
  504. package/dist/humain/classify-tool.d.ts +4 -0
  505. package/dist/humain/classify-tool.d.ts.map +1 -0
  506. package/dist/humain/classify-tool.js +50 -0
  507. package/dist/humain/classify-tool.js.map +1 -0
  508. package/dist/humain/flow-command.d.ts +1 -1
  509. package/dist/humain/flow-command.d.ts.map +1 -1
  510. package/dist/humain/flow-command.js +21 -3
  511. package/dist/humain/flow-command.js.map +1 -1
  512. package/dist/humain/flow-loader.d.ts +15 -10
  513. package/dist/humain/flow-loader.d.ts.map +1 -1
  514. package/dist/humain/flow-loader.js +72 -18
  515. package/dist/humain/flow-loader.js.map +1 -1
  516. package/dist/humain/fuse-provider.d.ts +5 -0
  517. package/dist/humain/fuse-provider.d.ts.map +1 -0
  518. package/dist/humain/fuse-provider.js +302 -0
  519. package/dist/humain/fuse-provider.js.map +1 -0
  520. package/dist/humain/gateway/provider.d.ts.map +1 -1
  521. package/dist/humain/gateway/provider.js +2 -0
  522. package/dist/humain/gateway/provider.js.map +1 -1
  523. package/dist/humain/gateway/secret-store.d.ts +3 -7
  524. package/dist/humain/gateway/secret-store.d.ts.map +1 -1
  525. package/dist/humain/gateway/secret-store.js +21 -249
  526. package/dist/humain/gateway/secret-store.js.map +1 -1
  527. package/dist/humain/hcode/account-store.d.ts +92 -0
  528. package/dist/humain/hcode/account-store.d.ts.map +1 -0
  529. package/dist/humain/hcode/account-store.js +720 -0
  530. package/dist/humain/hcode/account-store.js.map +1 -0
  531. package/dist/humain/hcode/account.d.ts +42 -0
  532. package/dist/humain/hcode/account.d.ts.map +1 -0
  533. package/dist/humain/hcode/account.js +552 -0
  534. package/dist/humain/hcode/account.js.map +1 -0
  535. package/dist/humain/hcode/catalog.d.ts +6 -0
  536. package/dist/humain/hcode/catalog.d.ts.map +1 -0
  537. package/dist/humain/hcode/catalog.js +47 -0
  538. package/dist/humain/hcode/catalog.js.map +1 -0
  539. package/dist/humain/hcode/contracts.d.ts +389 -0
  540. package/dist/humain/hcode/contracts.d.ts.map +1 -0
  541. package/dist/humain/hcode/contracts.js +1243 -0
  542. package/dist/humain/hcode/contracts.js.map +1 -0
  543. package/dist/humain/hcode/environment.d.ts +9 -0
  544. package/dist/humain/hcode/environment.d.ts.map +1 -0
  545. package/dist/humain/hcode/environment.js +24 -0
  546. package/dist/humain/hcode/environment.js.map +1 -0
  547. package/dist/humain/hcode/facade.d.ts +54 -0
  548. package/dist/humain/hcode/facade.d.ts.map +1 -0
  549. package/dist/humain/hcode/facade.js +326 -0
  550. package/dist/humain/hcode/facade.js.map +1 -0
  551. package/dist/humain/hcode/http.d.ts +10 -0
  552. package/dist/humain/hcode/http.d.ts.map +1 -0
  553. package/dist/humain/hcode/http.js +119 -0
  554. package/dist/humain/hcode/http.js.map +1 -0
  555. package/dist/humain/hcode/notices.d.ts +15 -0
  556. package/dist/humain/hcode/notices.d.ts.map +1 -0
  557. package/dist/humain/hcode/notices.js +69 -0
  558. package/dist/humain/hcode/notices.js.map +1 -0
  559. package/dist/humain/hcode/ports.d.ts +34 -0
  560. package/dist/humain/hcode/ports.d.ts.map +1 -0
  561. package/dist/humain/hcode/ports.js +2 -0
  562. package/dist/humain/hcode/ports.js.map +1 -0
  563. package/dist/humain/hcode/provider.d.ts +15 -0
  564. package/dist/humain/hcode/provider.d.ts.map +1 -0
  565. package/dist/humain/hcode/provider.js +200 -0
  566. package/dist/humain/hcode/provider.js.map +1 -0
  567. package/dist/humain/hcode/selection.d.ts +16 -0
  568. package/dist/humain/hcode/selection.d.ts.map +1 -0
  569. package/dist/humain/hcode/selection.js +37 -0
  570. package/dist/humain/hcode/selection.js.map +1 -0
  571. package/dist/humain/hcode/transport.d.ts +22 -0
  572. package/dist/humain/hcode/transport.d.ts.map +1 -0
  573. package/dist/humain/hcode/transport.js +368 -0
  574. package/dist/humain/hcode/transport.js.map +1 -0
  575. package/dist/humain/hcode/usage.d.ts +5 -0
  576. package/dist/humain/hcode/usage.d.ts.map +1 -0
  577. package/dist/humain/hcode/usage.js +66 -0
  578. package/dist/humain/hcode/usage.js.map +1 -0
  579. package/dist/humain/hcode/wire.d.ts +16 -0
  580. package/dist/humain/hcode/wire.d.ts.map +1 -0
  581. package/dist/humain/hcode/wire.js +104 -0
  582. package/dist/humain/hcode/wire.js.map +1 -0
  583. package/dist/humain/index.d.ts +1 -3
  584. package/dist/humain/index.d.ts.map +1 -1
  585. package/dist/humain/index.js +8 -60
  586. package/dist/humain/index.js.map +1 -1
  587. package/dist/humain/login-menu.d.ts.map +1 -1
  588. package/dist/humain/login-menu.js +8 -1
  589. package/dist/humain/login-menu.js.map +1 -1
  590. package/dist/humain/metadata/contracts.d.ts +82 -0
  591. package/dist/humain/metadata/contracts.d.ts.map +1 -0
  592. package/dist/humain/metadata/contracts.js +214 -0
  593. package/dist/humain/metadata/contracts.js.map +1 -0
  594. package/dist/humain/metadata/identity.d.ts +10 -0
  595. package/dist/humain/metadata/identity.d.ts.map +1 -0
  596. package/dist/humain/metadata/identity.js +209 -0
  597. package/dist/humain/metadata/identity.js.map +1 -0
  598. package/dist/humain/metadata/index.d.ts +41 -0
  599. package/dist/humain/metadata/index.d.ts.map +1 -0
  600. package/dist/humain/metadata/index.js +100 -0
  601. package/dist/humain/metadata/index.js.map +1 -0
  602. package/dist/humain/metadata/sender.d.ts +20 -0
  603. package/dist/humain/metadata/sender.d.ts.map +1 -0
  604. package/dist/humain/metadata/sender.js +302 -0
  605. package/dist/humain/metadata/sender.js.map +1 -0
  606. package/dist/humain/metadata/version.d.ts +8 -0
  607. package/dist/humain/metadata/version.d.ts.map +1 -0
  608. package/dist/humain/metadata/version.js +38 -0
  609. package/dist/humain/metadata/version.js.map +1 -0
  610. package/dist/humain/node-http.d.ts +2 -0
  611. package/dist/humain/node-http.d.ts.map +1 -1
  612. package/dist/humain/node-http.js +9 -4
  613. package/dist/humain/node-http.js.map +1 -1
  614. package/dist/humain/node-provider.d.ts +2 -0
  615. package/dist/humain/node-provider.d.ts.map +1 -1
  616. package/dist/humain/node-provider.js +39 -8
  617. package/dist/humain/node-provider.js.map +1 -1
  618. package/dist/humain/ponytail/vendor/hooks/ponytail-config.d.ts +1 -1
  619. package/dist/humain/ponytail/vendor/hooks/ponytail-config.d.ts.map +1 -1
  620. package/dist/humain/ponytail/vendor/hooks/ponytail-config.js +4 -4
  621. package/dist/humain/ponytail/vendor/hooks/ponytail-config.js.map +1 -1
  622. package/dist/humain/ponytail/vendor/hooks/ponytail-instructions.d.ts.map +1 -1
  623. package/dist/humain/ponytail/vendor/hooks/ponytail-instructions.js +7 -0
  624. package/dist/humain/ponytail/vendor/hooks/ponytail-instructions.js.map +1 -1
  625. package/dist/humain/ponytail/vendor/pi-extension/index.d.ts.map +1 -1
  626. package/dist/humain/ponytail/vendor/pi-extension/index.js +12 -1
  627. package/dist/humain/ponytail/vendor/pi-extension/index.js.map +1 -1
  628. package/dist/humain/systemone.d.ts +23 -0
  629. package/dist/humain/systemone.d.ts.map +1 -0
  630. package/dist/humain/systemone.js +101 -0
  631. package/dist/humain/systemone.js.map +1 -0
  632. package/dist/humain/trace-capture/flow-producer.d.ts.map +1 -1
  633. package/dist/humain/trace-capture/flow-producer.js +3 -3
  634. package/dist/humain/trace-capture/flow-producer.js.map +1 -1
  635. package/dist/index.d.ts +4 -2
  636. package/dist/index.d.ts.map +1 -1
  637. package/dist/index.js.map +1 -1
  638. package/dist/main.d.ts +1 -0
  639. package/dist/main.d.ts.map +1 -1
  640. package/dist/main.js +292 -183
  641. package/dist/main.js.map +1 -1
  642. package/dist/modes/interactive/bug-report.d.ts.map +1 -1
  643. package/dist/modes/interactive/bug-report.js +82 -36
  644. package/dist/modes/interactive/bug-report.js.map +1 -1
  645. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  646. package/dist/modes/interactive/components/assistant-message.js +8 -5
  647. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  648. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  649. package/dist/modes/interactive/components/diff.js +11 -5
  650. package/dist/modes/interactive/components/diff.js.map +1 -1
  651. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  652. package/dist/modes/interactive/components/extension-selector.js +9 -1
  653. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  654. package/dist/modes/interactive/components/first-time-setup.d.ts +10 -5
  655. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  656. package/dist/modes/interactive/components/first-time-setup.js +55 -29
  657. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  658. package/dist/modes/interactive/components/model-selector.d.ts +16 -2
  659. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  660. package/dist/modes/interactive/components/model-selector.js +164 -19
  661. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  662. package/dist/modes/interactive/components/oauth-selector.d.ts +3 -0
  663. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  664. package/dist/modes/interactive/components/oauth-selector.js +19 -2
  665. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  666. package/dist/modes/interactive/components/status-indicator.d.ts +17 -0
  667. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  668. package/dist/modes/interactive/components/status-indicator.js +78 -1
  669. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  670. package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
  671. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  672. package/dist/modes/interactive/components/tree-selector.js +19 -10
  673. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  674. package/dist/modes/interactive/interactive-mode.d.ts +4 -0
  675. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  676. package/dist/modes/interactive/interactive-mode.js +353 -65
  677. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  678. package/dist/modes/interactive/interactive-mode.lazy.d.ts +3 -0
  679. package/dist/modes/interactive/interactive-mode.lazy.d.ts.map +1 -0
  680. package/dist/modes/interactive/interactive-mode.lazy.js +3 -0
  681. package/dist/modes/interactive/interactive-mode.lazy.js.map +1 -0
  682. package/dist/modes/interactive/model-catalog-refresh.d.ts +2 -0
  683. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -1
  684. package/dist/modes/interactive/model-catalog-refresh.js +12 -0
  685. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -1
  686. package/dist/modes/interactive/theme/theme-controller.d.ts +2 -3
  687. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  688. package/dist/modes/interactive/theme/theme-controller.js +4 -5
  689. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  690. package/dist/modes/interactive/theme/theme-schema.js +4 -4
  691. package/dist/modes/interactive/theme/theme-schema.js.map +1 -1
  692. package/dist/modes/interactive/theme/theme.d.ts +2 -0
  693. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  694. package/dist/modes/interactive/theme/theme.js +8 -0
  695. package/dist/modes/interactive/theme/theme.js.map +1 -1
  696. package/dist/modes/json-event.d.ts +2 -1
  697. package/dist/modes/json-event.d.ts.map +1 -1
  698. package/dist/modes/json-event.js.map +1 -1
  699. package/dist/modes/print-mode.d.ts +4 -0
  700. package/dist/modes/print-mode.d.ts.map +1 -1
  701. package/dist/modes/print-mode.js +57 -11
  702. package/dist/modes/print-mode.js.map +1 -1
  703. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  704. package/dist/modes/rpc/rpc-mode.js +68 -16
  705. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  706. package/dist/modes/rpc/rpc-types.d.ts +2 -0
  707. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  708. package/dist/modes/rpc/rpc-types.js.map +1 -1
  709. package/dist/utils/changelog.d.ts +1 -1
  710. package/dist/utils/changelog.d.ts.map +1 -1
  711. package/dist/utils/changelog.js +7 -5
  712. package/dist/utils/changelog.js.map +1 -1
  713. package/dist/utils/image-resize.d.ts.map +1 -1
  714. package/dist/utils/image-resize.js +3 -1
  715. package/dist/utils/image-resize.js.map +1 -1
  716. package/dist/utils/lazy-validator.d.ts +5 -0
  717. package/dist/utils/lazy-validator.d.ts.map +1 -0
  718. package/dist/utils/lazy-validator.js +7 -0
  719. package/dist/utils/lazy-validator.js.map +1 -0
  720. package/dist/utils/shell.d.ts +3 -1
  721. package/dist/utils/shell.d.ts.map +1 -1
  722. package/dist/utils/shell.js +9 -4
  723. package/dist/utils/shell.js.map +1 -1
  724. package/docs/cli.md +23 -5
  725. package/docs/codemode.md +21 -1
  726. package/docs/development.md +18 -0
  727. package/docs/docs.json +4 -0
  728. package/docs/extensions.md +4 -0
  729. package/docs/flow.md +115 -16
  730. package/docs/headless-modes.md +61 -0
  731. package/docs/humain-code-forge-architecture.md +65 -13
  732. package/docs/humain-code-forge-component-scorecard.md +10 -1
  733. package/docs/humain-code-forge-flow-walkthrough.md +54 -55
  734. package/docs/humain-code.md +22 -19
  735. package/docs/index.md +1 -0
  736. package/docs/keybindings.md +1 -1
  737. package/docs/models-configuration.md +6 -1
  738. package/docs/models.md +1 -1
  739. package/docs/prompt-templates.md +1 -1
  740. package/docs/providers.md +67 -15
  741. package/docs/run-preflight.md +47 -0
  742. package/docs/sdk.md +39 -1
  743. package/docs/security.md +1 -1
  744. package/docs/settings.md +12 -5
  745. package/docs/skills.md +2 -0
  746. package/docs/slash-commands.md +5 -3
  747. package/docs/usage.md +29 -0
  748. package/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
  749. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  750. package/examples/tsconfig.json +13 -0
  751. package/npm-shrinkwrap.json +67 -67
  752. package/package.json +25 -19
  753. package/schemas/models.schema.json +30 -0
  754. package/schemas/settings.schema.json +28 -9
  755. package/src/humain/caveman/UPSTREAM.md +19 -3
  756. package/src/humain/caveman/upstream.json +2 -2
  757. package/src/humain/ponytail/UPSTREAM.md +16 -1
  758. package/src/humain/web-access/UPSTREAM.md +10 -0
  759. package/src/humain/web-access/upstream.json +1 -0
  760. package/dist/bundle/chunks/anthropic-messages-MNISFDZA.js +0 -66
  761. package/dist/bundle/chunks/chunk-2HZ2V3HS.js +0 -1985
  762. package/dist/bundle/chunks/chunk-2PZ46FSM.js +0 -6
  763. package/dist/bundle/chunks/chunk-4SQUP6IR.js +0 -88
  764. package/dist/bundle/chunks/chunk-5JSLXC2A.js +0 -3
  765. package/dist/bundle/chunks/chunk-75CQYZ63.js +0 -1336
  766. package/dist/bundle/chunks/chunk-DCPACGLH.js +0 -12267
  767. package/dist/bundle/chunks/chunk-FLVBQ6GS.js +0 -24
  768. package/dist/bundle/chunks/chunk-H7Y4QY7K.js +0 -11
  769. package/dist/bundle/chunks/chunk-JEAM6N22.js +0 -139
  770. package/dist/bundle/chunks/chunk-PS2FJ7M4.js +0 -23
  771. package/dist/bundle/chunks/chunk-TEOMXMW6.js +0 -23
  772. package/dist/bundle/chunks/chunk-WEFEQEIQ.js +0 -28
  773. package/dist/bundle/chunks/chunk-WW4SILXG.js +0 -249
  774. package/dist/bundle/chunks/compat-MXAZPYDN.js +0 -13
  775. package/dist/bundle/chunks/dist-3V7ZSLER.js +0 -3166
  776. package/dist/bundle/chunks/dist-66CW64M2.js +0 -8
  777. package/dist/bundle/chunks/host-SCZ4IKWR.js +0 -2
  778. package/dist/bundle/chunks/openai-codex-responses-LZWBQYVP.js +0 -101
  779. package/dist/bundle/chunks/openai-completions-7NWH423P.js +0 -82
  780. package/dist/bundle/chunks/openai-responses-5YOLHMCF.js +0 -27
  781. package/dist/bundle/chunks/runtime-UVPDE4CX.js +0 -2
  782. package/dist/bundle/chunks/typesafe-system-one-BHJYAZ6E.js +0 -3
  783. package/dist/bundle/chunks/virtual-modules-YQPK57CW.js +0 -23
  784. package/dist/humain/legacy-workflow-tiers.d.ts +0 -3
  785. package/dist/humain/legacy-workflow-tiers.d.ts.map +0 -1
  786. package/dist/humain/legacy-workflow-tiers.js +0 -46
  787. package/dist/humain/legacy-workflow-tiers.js.map +0 -1
  788. /package/dist/bundle/{flow → orchestrate}/agents/orch-architect.md +0 -0
  789. /package/dist/bundle/{flow → orchestrate}/agents/orch-scout.md +0 -0
  790. /package/dist/bundle/{flow → orchestrate}/agents/orch-security-review.md +0 -0
  791. /package/dist/bundle/{flow → orchestrate}/agents/orch-technical-lead.md +0 -0
  792. /package/dist/bundle/{flow → orchestrate}/agents/orch-technical-review.md +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"bash.js","sourceRoot":"","sources":["../../../src/core/tools/bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACN,cAAc,EACd,WAAW,EACX,oBAAoB,EAEpB,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAyB,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAyB,MAAM,eAAe,CAAC;AAExG,MAAM,cAAc,GAAG,aAAa,CAAC;AACrC,+GAA+G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AAC;IACH,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import { constants } from \"node:fs\";\nimport { access as fsAccess } from \"node:fs/promises\";\nimport { constants as osConstants } from \"node:os\";\nimport { spawn } from \"child_process\";\nimport { type Static, Type } from \"typebox\";\nimport { waitForChildProcess } from \"../../utils/child-process.ts\";\nimport {\n\tgetShellConfig,\n\tgetShellEnv,\n\tkillProcessTreeAsync,\n\ttype ShellConfig,\n\ttrackDetachedChildPid,\n\tuntrackDetachedChildPid,\n} from \"../../utils/shell.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport { OutputAccumulator } from \"./output-accumulator.ts\";\nimport { BASH_UPDATE_THROTTLE_MS, createShellRenderers } from \"./renderers/bash.ts\";\nimport { scrubTraceEnv } from \"./subagent-env.ts\";\nimport { type TypeBoxAgentTool, wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult } from \"./truncate.ts\";\n\nconst MAX_TIMEOUT_MS = 2_147_483_647;\n/** Output limit of `structuredContent.output`, which programmatic callers such as codemode scripts receive. */\nconst STRUCTURED_OUTPUT_MAX_BYTES = 1024 * 1024;\nconst MAX_TIMEOUT_SECONDS = MAX_TIMEOUT_MS / 1000;\n\nfunction resolveTimeoutMs(timeout: number | undefined): number | undefined {\n\tif (timeout === undefined) return undefined;\n\tif (!Number.isFinite(timeout) || timeout <= 0) {\n\t\tthrow new Error(\"Invalid timeout: must be a finite number of seconds\");\n\t}\n\n\tconst timeoutMs = timeout * 1000;\n\tif (timeoutMs > MAX_TIMEOUT_MS) {\n\t\tthrow new Error(`Invalid timeout: maximum is ${MAX_TIMEOUT_SECONDS} seconds`);\n\t}\n\treturn timeoutMs;\n}\n\nconst bashSchema = Type.Object({\n\tcommand: Type.String({ description: \"Shell command to execute\" }),\n\ttimeout: Type.Optional(Type.Number({ description: \"Timeout in seconds (optional, no default timeout)\" })),\n});\n\nexport const bashToolSystemPromptContribution = {\n\tsnippet: \"Execute bash commands (ls, grep, find, etc.)\",\n\tguidelines: [\"You can inspect HUMAIN_TERMINAL_* environment variables for current model and session details.\"],\n} as const;\n\nexport type BashToolInput = Static<typeof bashSchema>;\n\n/**\n * Result for programmatic callers such as codemode scripts. A non-zero exit code is an error result for the model, but scripts still resolve to this value.\n * `output` is not limited like the model-facing output: callers decide how much of it reaches the model.\n */\nconst bashOutputSchema = Type.Object({\n\toutput: Type.String({ description: \"Combined stdout and stderr, possibly truncated\" }),\n\ttruncated: Type.Boolean(),\n\tfull_output_path: Type.Optional(Type.String({ description: \"Full output, when truncated\" })),\n\texit_code: Type.Number(),\n\twall_time_seconds: Type.Number(),\n});\n\nexport type BashToolOutput = Static<typeof bashOutputSchema>;\n\nexport interface BashToolDetails {\n\ttruncation?: TruncationResult;\n\tfullOutputPath?: string;\n}\n\n/**\n * Pluggable operations for the bash tool.\n * Override these to delegate command execution to remote systems (for example SSH).\n */\nexport interface BashOperations {\n\t/**\n\t * Execute a command and stream output.\n\t * @param command The command to execute\n\t * @param cwd Working directory\n\t * @param options Execution options\n\t * @returns Promise resolving to the exit code. Report signal terminations as 128 + signal number;\n\t * a null exit code is treated as a failed command.\n\t */\n\texec: (\n\t\tcommand: string,\n\t\tcwd: string,\n\t\toptions: {\n\t\t\t/** Await a returned promise before delivering more stdout or stderr. */\n\t\t\tonData: ((data: Buffer) => void) | ((data: Buffer) => Promise<void>);\n\t\t\tsignal?: AbortSignal;\n\t\t\ttimeout?: number;\n\t\t\tenv?: NodeJS.ProcessEnv;\n\t\t},\n\t) => Promise<{ exitCode: number | null }>;\n}\n\n/** Shared process execution used by the built-in shell tools. */\nexport function createLocalShellOperations(shellName: string, resolveShellConfig: () => ShellConfig): BashOperations {\n\treturn {\n\t\texec: async (command, cwd, { onData, signal, timeout, env }) => {\n\t\t\tconst timeoutMs = resolveTimeoutMs(timeout);\n\t\t\tif (signal?.aborted) {\n\t\t\t\tthrow new Error(\"aborted\");\n\t\t\t}\n\t\t\tconst shellConfig = resolveShellConfig();\n\t\t\ttry {\n\t\t\t\tawait fsAccess(cwd, constants.F_OK);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(`Working directory does not exist: ${cwd}\\nCannot execute ${shellName} commands.`);\n\t\t\t}\n\n\t\t\tconst commandFromStdin = shellConfig.commandTransport === \"stdin\";\n\t\t\tconst child = spawn(shellConfig.shell, commandFromStdin ? shellConfig.args : [...shellConfig.args, command], {\n\t\t\t\tcwd,\n\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\tenv: scrubTraceEnv(env ?? getShellEnv()),\n\t\t\t\tstdio: [commandFromStdin ? \"pipe\" : \"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tif (child.pid) trackDetachedChildPid(child.pid, child);\n\t\t\tif (commandFromStdin) {\n\t\t\t\tchild.stdin?.on(\"error\", () => {});\n\t\t\t\tchild.stdin?.end(command);\n\t\t\t}\n\t\t\tlet timedOut = false;\n\t\t\tlet timeoutHandle: NodeJS.Timeout | undefined;\n\t\t\tlet drainTimer: NodeJS.Timeout | undefined;\n\t\t\tlet termination: Promise<boolean> | undefined;\n\t\t\tlet finished = false;\n\t\t\tlet outputFailure: { error: unknown } | undefined;\n\t\t\tlet pendingOutput: Promise<void> | undefined;\n\t\t\tconst drainController = new AbortController();\n\t\t\tconst drainAborted = new Promise<void>((resolve) => {\n\t\t\t\tdrainController.signal.addEventListener(\"abort\", () => resolve(), { once: true });\n\t\t\t});\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (termination) return;\n\t\t\t\ttermination = child.pid ? killProcessTreeAsync(child.pid, undefined, child) : Promise.resolve(true);\n\t\t\t\tvoid termination.then(() => {\n\t\t\t\t\tif (!finished) drainTimer = setTimeout(() => drainController.abort(), 500);\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst failOutput = (error: unknown) => {\n\t\t\t\toutputFailure = { error };\n\t\t\t\tchild.stdout?.off(\"data\", handleData);\n\t\t\t\tchild.stderr?.off(\"data\", handleData);\n\t\t\t\tonAbort();\n\t\t\t\tchild.stdout?.resume();\n\t\t\t\tchild.stderr?.resume();\n\t\t\t};\n\t\t\tconst handleData = (data: Buffer) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst pending = onData(data);\n\t\t\t\t\tif (pending instanceof Promise) {\n\t\t\t\t\t\t// Both pipes share one sink, so neither may enqueue more until it drains.\n\t\t\t\t\t\tchild.stdout?.pause();\n\t\t\t\t\t\tchild.stderr?.pause();\n\t\t\t\t\t\tpendingOutput = pending.then(() => {\n\t\t\t\t\t\t\tchild.stdout?.resume();\n\t\t\t\t\t\t\tchild.stderr?.resume();\n\t\t\t\t\t\t}, failOutput);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailOutput(error);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\t// Set timeout if provided.\n\t\t\t\tif (timeoutMs !== undefined) {\n\t\t\t\t\ttimeoutHandle = setTimeout(() => {\n\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\tonAbort();\n\t\t\t\t\t}, timeoutMs);\n\t\t\t\t}\n\t\t\t\t// Stream stdout and stderr.\n\t\t\t\tchild.stdout?.on(\"data\", handleData);\n\t\t\t\tchild.stderr?.on(\"data\", handleData);\n\t\t\t\t// Handle abort signal by killing the entire process tree.\n\t\t\t\tif (signal) {\n\t\t\t\t\tif (signal.aborted) onAbort();\n\t\t\t\t\telse signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\t\t\t\t// Handle shell spawn errors and wait for the process to terminate without hanging\n\t\t\t\t// on inherited stdio handles held by detached descendants.\n\t\t\t\tconst exitCode = await waitForChildProcess(child, drainController.signal);\n\t\t\t\tawait Promise.race([pendingOutput, drainAborted]);\n\t\t\t\tif (outputFailure) throw outputFailure.error;\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\tthrow new Error(\"aborted\");\n\t\t\t\t}\n\t\t\t\tif (timedOut) {\n\t\t\t\t\tthrow new Error(`timeout:${timeout}`);\n\t\t\t\t}\n\t\t\t\t// A signal-killed shell has no exit code. Use the standard shell convention so\n\t\t\t\t// callers do not mistake the termination for a successful command.\n\t\t\t\tconst signalCode = child.signalCode;\n\t\t\t\treturn { exitCode: exitCode ?? (signalCode ? 128 + (osConstants.signals[signalCode] ?? 0) : 1) };\n\t\t\t} finally {\n\t\t\t\tfinished = true;\n\t\t\t\tif (drainTimer) clearTimeout(drainTimer);\n\t\t\t\tif (child.pid) untrackDetachedChildPid(child.pid, child);\n\t\t\t\tif (timeoutHandle) clearTimeout(timeoutHandle);\n\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t\tchild.stdout?.off(\"data\", handleData);\n\t\t\t\tchild.stderr?.off(\"data\", handleData);\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Create bash operations using pi's built-in local shell execution backend.\n *\n * This is useful for extensions that intercept user_bash and still want pi's\n * standard local shell behavior while wrapping or rewriting commands.\n */\nexport function createLocalBashOperations(options?: { shellPath?: string }): BashOperations {\n\treturn createLocalShellOperations(\"bash\", () => getShellConfig(options?.shellPath));\n}\n\nexport interface BashSpawnContext {\n\tcommand: string;\n\tcwd: string;\n\tenv: NodeJS.ProcessEnv;\n}\n\nexport type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;\n\nfunction resolveSpawnContext(\n\tcommand: string,\n\tcwd: string,\n\tspawnHook: BashSpawnHook | undefined,\n\texposeSessionEnvironment: boolean,\n\tctx: ExtensionContext | undefined,\n): BashSpawnContext {\n\tconst env = scrubTraceEnv(getShellEnv());\n\tfor (const name of [\n\t\t\"HUMAIN_TERMINAL_SESSION_ID\",\n\t\t\"HUMAIN_TERMINAL_SESSION_FILE\",\n\t\t\"HUMAIN_TERMINAL_PROVIDER\",\n\t\t\"HUMAIN_TERMINAL_MODEL\",\n\t\t\"HUMAIN_TERMINAL_REASONING_LEVEL\",\n\t\t\"PI_SESSION_ID\",\n\t\t\"PI_SESSION_FILE\",\n\t\t\"PI_PROVIDER\",\n\t\t\"PI_MODEL\",\n\t\t\"PI_REASONING_LEVEL\",\n\t]) {\n\t\tdelete env[name];\n\t}\n\tif (exposeSessionEnvironment && ctx) {\n\t\tconst model = ctx.model;\n\t\tconst sessionId = ctx.sessionManager.getSessionId();\n\t\tenv.HUMAIN_TERMINAL_SESSION_ID = sessionId;\n\t\tenv.PI_SESSION_ID = sessionId;\n\t\tconst sessionFile = ctx.sessionManager.getSessionFile();\n\t\tif (sessionFile) {\n\t\t\tenv.HUMAIN_TERMINAL_SESSION_FILE = sessionFile;\n\t\t\tenv.PI_SESSION_FILE = sessionFile;\n\t\t}\n\t\tif (model) {\n\t\t\tenv.HUMAIN_TERMINAL_PROVIDER = model.provider;\n\t\t\tenv.HUMAIN_TERMINAL_MODEL = model.id;\n\t\t\tenv.PI_PROVIDER = model.provider;\n\t\t\tenv.PI_MODEL = model.id;\n\t\t}\n\t\tif (ctx.thinkingLevel) {\n\t\t\tenv.HUMAIN_TERMINAL_REASONING_LEVEL = ctx.thinkingLevel;\n\t\t\tenv.PI_REASONING_LEVEL = ctx.thinkingLevel;\n\t\t}\n\t}\n\tconst baseContext: BashSpawnContext = { command, cwd, env };\n\treturn spawnHook ? spawnHook(baseContext) : baseContext;\n}\n\nexport interface BashToolOptions {\n\t/** Custom operations for command execution. Default: local shell */\n\toperations?: BashOperations;\n\t/** Command prefix prepended to every command (for example shell setup commands) */\n\tcommandPrefix?: string;\n\t/** Optional explicit shell path from settings */\n\tshellPath?: string;\n\t/** Expose current HUMAIN Code CLI session metadata and PI compatibility aliases. Default: true */\n\texposeSessionEnvironment?: boolean;\n\t/** Hook to adjust command, cwd, or env before execution */\n\tspawnHook?: BashSpawnHook;\n}\n\nexport type BashRenderState = {\n\tstartedAt: number | undefined;\n\tendedAt: number | undefined;\n\tinterval: NodeJS.Timeout | undefined;\n};\n\nexport interface ShellToolConfig {\n\tname: string;\n\tlabel: string;\n\tshellName: string;\n\tprompt: string;\n\tpromptSnippet: string;\n\tpromptGuidelines?: readonly string[];\n\ttempFilePrefix: string;\n}\n\nexport function createShellToolDefinition(\n\tcwd: string,\n\tconfig: ShellToolConfig,\n\toptions?: BashToolOptions,\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {\n\tconst ops = options?.operations ?? createLocalBashOperations({ shellPath: options?.shellPath });\n\tconst commandPrefix = options?.commandPrefix;\n\tconst exposeSessionEnvironment = options?.exposeSessionEnvironment ?? true;\n\tconst spawnHook = options?.spawnHook;\n\treturn {\n\t\tname: config.name,\n\t\tlabel: config.label,\n\t\tdescription: `Execute a ${config.shellName} command in the current working directory. Returns stdout and stderr. Output is truncated to last ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). If truncated, full output is saved to a temp file. Optionally provide a timeout in seconds.`,\n\t\tpromptSnippet: config.promptSnippet,\n\t\tpromptGuidelines: exposeSessionEnvironment && config.promptGuidelines ? [...config.promptGuidelines] : undefined,\n\t\tparameters: bashSchema,\n\t\toutputSchema: bashOutputSchema,\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ command, timeout }: { command: string; timeout?: number },\n\t\t\tsignal?: AbortSignal,\n\t\t\tonUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\n\t\t\tconst resolvedCommand = commandPrefix ? `${commandPrefix}\\n${command}` : command;\n\t\t\tconst spawnContext = resolveSpawnContext(\n\t\t\t\tresolvedCommand,\n\t\t\t\tctx?.cwd || cwd,\n\t\t\t\tspawnHook,\n\t\t\t\texposeSessionEnvironment,\n\t\t\t\tctx,\n\t\t\t);\n\t\t\tconst output = new OutputAccumulator({ tempFilePrefix: config.tempFilePrefix });\n\t\t\tlet acceptingOutput = true;\n\t\t\tlet updateTimer: NodeJS.Timeout | undefined;\n\t\t\tlet updateDirty = false;\n\t\t\tlet lastUpdateAt = 0;\n\n\t\t\tconst emitOutputUpdate = () => {\n\t\t\t\tif (!onUpdate || !updateDirty) return;\n\t\t\t\tupdateDirty = false;\n\t\t\t\tlastUpdateAt = Date.now();\n\t\t\t\tconst snapshot = output.snapshot({ persistIfTruncated: true });\n\t\t\t\tonUpdate({\n\t\t\t\t\tcontent: [{ type: \"text\", text: snapshot.content || \"\" }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\ttruncation: snapshot.truncation.truncated ? snapshot.truncation : undefined,\n\t\t\t\t\t\tfullOutputPath: snapshot.fullOutputPath,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst clearUpdateTimer = () => {\n\t\t\t\tif (updateTimer) {\n\t\t\t\t\tclearTimeout(updateTimer);\n\t\t\t\t\tupdateTimer = undefined;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst scheduleOutputUpdate = () => {\n\t\t\t\tif (!onUpdate) return;\n\t\t\t\tupdateDirty = true;\n\t\t\t\tconst delay = BASH_UPDATE_THROTTLE_MS - (Date.now() - lastUpdateAt);\n\t\t\t\tif (delay <= 0) {\n\t\t\t\t\tclearUpdateTimer();\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tupdateTimer ??= setTimeout(() => {\n\t\t\t\t\tupdateTimer = undefined;\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t}, delay);\n\t\t\t};\n\n\t\t\tif (onUpdate) {\n\t\t\t\tonUpdate({ content: [], details: undefined });\n\t\t\t}\n\n\t\t\tconst handleData = (data: Buffer) => {\n\t\t\t\tif (!acceptingOutput) return;\n\t\t\t\tconst pending = output.append(data);\n\t\t\t\tscheduleOutputUpdate();\n\t\t\t\treturn pending;\n\t\t\t};\n\n\t\t\tconst finishOutput = async () => {\n\t\t\t\tacceptingOutput = false;\n\t\t\t\toutput.finish();\n\t\t\t\tclearUpdateTimer();\n\t\t\t\temitOutputUpdate();\n\t\t\t\tconst snapshot = output.snapshot({ persistIfTruncated: true });\n\t\t\t\tawait output.closeTempFile();\n\t\t\t\treturn snapshot;\n\t\t\t};\n\n\t\t\tconst formatOutput = (snapshot: Awaited<ReturnType<typeof finishOutput>>, emptyText = \"(no output)\") => {\n\t\t\t\tconst truncation = snapshot.truncation;\n\t\t\t\tlet text = snapshot.content || emptyText;\n\t\t\t\tlet details: BashToolDetails | undefined;\n\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\tdetails = { truncation, fullOutputPath: snapshot.fullOutputPath };\n\t\t\t\t\tconst startLine = truncation.totalLines - truncation.outputLines + 1;\n\t\t\t\t\tconst endLine = truncation.totalLines;\n\t\t\t\t\tif (truncation.lastLinePartial) {\n\t\t\t\t\t\tconst lastLineSize = formatSize(output.getLastLineBytes());\n\t\t\t\t\t\ttext += `\\n\\n[Showing last ${formatSize(truncation.outputBytes)} of line ${endLine} (line is ${lastLineSize}). Full output: ${snapshot.fullOutputPath}]`;\n\t\t\t\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\t\ttext += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines}. Full output: ${snapshot.fullOutputPath}]`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttext += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Full output: ${snapshot.fullOutputPath}]`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn { text, details };\n\t\t\t};\n\n\t\t\tconst appendStatus = (text: string, status: string) => `${text ? `${text}\\n\\n` : \"\"}${status}`;\n\t\t\tconst startedAt = performance.now();\n\n\t\t\ttry {\n\t\t\t\tlet exitCode: number | null;\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await ops.exec(spawnContext.command, spawnContext.cwd, {\n\t\t\t\t\t\tonData: handleData,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\tenv: spawnContext.env,\n\t\t\t\t\t});\n\t\t\t\t\texitCode = result.exitCode;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconst snapshot = await finishOutput();\n\t\t\t\t\tconst { text } = formatOutput(snapshot, \"\");\n\t\t\t\t\tif (err instanceof Error && err.message === \"aborted\") {\n\t\t\t\t\t\tthrow new Error(appendStatus(text, \"Command aborted\"));\n\t\t\t\t\t}\n\t\t\t\t\tif (err instanceof Error && err.message.startsWith(\"timeout:\")) {\n\t\t\t\t\t\tconst timeoutSecs = err.message.split(\":\")[1];\n\t\t\t\t\t\tthrow new Error(appendStatus(text, `Command timed out after ${timeoutSecs} seconds`));\n\t\t\t\t\t}\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\n\t\t\t\tconst snapshot = await finishOutput();\n\t\t\t\tconst { text: outputText, details } = formatOutput(snapshot);\n\t\t\t\tif (exitCode === null) {\n\t\t\t\t\tthrow new Error(appendStatus(outputText, \"Command terminated without an exit code\"));\n\t\t\t\t}\n\t\t\t\tconst wallTimeSeconds = Math.round((performance.now() - startedAt) / 100) / 10;\n\t\t\t\tconst fullOutput = await output.readFullOutput(STRUCTURED_OUTPUT_MAX_BYTES);\n\t\t\t\tconst structuredContent: BashToolOutput = {\n\t\t\t\t\toutput: fullOutput.content,\n\t\t\t\t\ttruncated: fullOutput.truncated,\n\t\t\t\t\t...(fullOutput.truncated && snapshot.fullOutputPath\n\t\t\t\t\t\t? { full_output_path: snapshot.fullOutputPath }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\texit_code: exitCode,\n\t\t\t\t\twall_time_seconds: wallTimeSeconds,\n\t\t\t\t};\n\t\t\t\tif (exitCode !== 0) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: appendStatus(outputText, `Command exited with code ${exitCode}`) }],\n\t\t\t\t\t\tdetails,\n\t\t\t\t\t\tstructuredContent,\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { content: [{ type: \"text\", text: outputText }], details, structuredContent };\n\t\t\t} finally {\n\t\t\t\tclearUpdateTimer();\n\t\t\t}\n\t\t},\n\t\t...createShellRenderers(config.prompt),\n\t};\n}\n\nconst bashToolConfig: ShellToolConfig = {\n\tname: \"bash\",\n\tlabel: \"bash\",\n\tshellName: \"bash\",\n\tprompt: \"$\",\n\tpromptSnippet: bashToolSystemPromptContribution.snippet,\n\tpromptGuidelines: bashToolSystemPromptContribution.guidelines,\n\ttempFilePrefix: \"pi-bash\",\n};\n\nexport function createBashToolDefinition(\n\tcwd: string,\n\toptions?: BashToolOptions,\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {\n\treturn createShellToolDefinition(cwd, bashToolConfig, options);\n}\n\nexport function createBashTool(cwd: string, options?: BashToolOptions): TypeBoxAgentTool<typeof bashSchema> {\n\tconst definition = createBashToolDefinition(cwd, options);\n\tconst tool = wrapToolDefinition(definition);\n\tObject.assign(tool, {\n\t\tpromptSnippet: definition.promptSnippet,\n\t\tpromptGuidelines: definition.promptGuidelines,\n\t});\n\treturn tool;\n}\n"]}
1
+ {"version":3,"file":"bash.js","sourceRoot":"","sources":["../../../src/core/tools/bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAqB,KAAK,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACN,cAAc,EACd,WAAW,EACX,oBAAoB,EAEpB,qBAAqB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;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AO,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,MAAM,UAAU,GAAG,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC3C,IAAI,KAAK;QAAE,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACnD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QACnB,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;KAC7C,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import { constants } from \"node:fs\";\nimport { access as fsAccess } from \"node:fs/promises\";\nimport { constants as osConstants } from \"node:os\";\nimport { type ChildProcess, spawn } from \"child_process\";\nimport { type Static, Type } from \"typebox\";\nimport { waitForChildProcess } from \"../../utils/child-process.ts\";\nimport {\n\tgetShellConfig,\n\tgetShellEnv,\n\tkillProcessTreeAsync,\n\ttype ShellConfig,\n\ttrackDetachedChildPid,\n} from \"../../utils/shell.ts\";\nimport { readOnlyAcceptanceSpawn } from \"../acceptance-command.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport {\n\tBashJobManager,\n\ttype BashJobOutput,\n\ttype BashJobSnapshot,\n\tbashJobOutputSchema,\n\ttype JobInputResult,\n\tMAX_JOB_INPUT_BYTES,\n} from \"./bash-jobs.ts\";\nimport { OutputAccumulator } from \"./output-accumulator.ts\";\nimport { BASH_UPDATE_THROTTLE_MS, createShellRenderers } from \"./renderers/bash.ts\";\nimport { scrubTraceEnv } from \"./subagent-env.ts\";\nimport { type TypeBoxAgentTool, wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult } from \"./truncate.ts\";\n\nconst DEFAULT_BASH_TIMEOUT_SECONDS = 120;\nconst MAX_TIMEOUT_MS = 2_147_483_647;\n/** Output limit of `structuredContent.output`, which programmatic callers such as codemode scripts receive. */\nconst STRUCTURED_OUTPUT_MAX_BYTES = 1024 * 1024;\nconst MAX_TIMEOUT_SECONDS = MAX_TIMEOUT_MS / 1000;\n\nfunction resolveTimeoutMs(timeout: number | undefined): number | undefined {\n\tif (timeout === undefined) return undefined;\n\tif (!Number.isFinite(timeout) || timeout <= 0) {\n\t\tthrow new Error(\"Invalid timeout: must be a finite number of seconds\");\n\t}\n\n\tconst timeoutMs = timeout * 1000;\n\tif (timeoutMs > MAX_TIMEOUT_MS) {\n\t\tthrow new Error(`Invalid timeout: maximum is ${MAX_TIMEOUT_SECONDS} seconds`);\n\t}\n\treturn timeoutMs;\n}\n\nconst shellSchema = Type.Object({\n\tcommand: Type.String({ description: \"Shell command to execute\" }),\n\ttimeout: Type.Optional(Type.Number({ description: \"Timeout in seconds (optional, no default timeout)\" })),\n});\n\nconst bashSchema = Type.Object({\n\t...shellSchema.properties,\n\tbackground: Type.Optional(Type.Boolean({ description: \"Start session-owned background work and return a job ID\" })),\n\ttimeout: Type.Optional(\n\t\tType.Number({\n\t\t\tdescription: `Timeout in seconds (optional, defaults to ${DEFAULT_BASH_TIMEOUT_SECONDS} seconds)`,\n\t\t}),\n\t),\n});\n\nexport const bashToolSystemPromptContribution = {\n\tsnippet: \"Execute bash commands (ls, grep, find, etc.)\",\n\tguidelines: [\"You can inspect HUMAIN_TERMINAL_* environment variables for current model and session details.\"],\n} as const;\n\nexport type BashToolInput = Static<typeof bashSchema>;\n\n/**\n * Result for programmatic callers such as codemode scripts. A non-zero exit code is an error result for the model, but scripts still resolve to this value.\n * `output` is not limited like the model-facing output: callers decide how much of it reaches the model.\n */\nconst bashOutputSchema = Type.Object({\n\toutput: Type.String({ description: \"Combined stdout and stderr, possibly truncated\" }),\n\ttruncated: Type.Boolean(),\n\tfull_output_path: Type.Optional(Type.String({ description: \"Full output, when truncated\" })),\n\texit_code: Type.Number(),\n\twall_time_seconds: Type.Number(),\n});\n\nexport type BashToolOutput = Static<typeof bashOutputSchema> | BashJobOutput;\n\nexport interface BashToolDetails {\n\ttruncation?: TruncationResult;\n\tfullOutputPath?: string;\n}\n\n/** A background process tree could not be confirmed stopped; retain its effect ownership. */\nexport class BashProcessCleanupError extends Error {}\n\n/** Run-owned custody and time allocation, installed only for explicitly admitted adaptive work. */\nexport interface BashRunContext {\n\trunId: string;\n\townerId: string;\n\tsessionId: string;\n\tgeneration: number;\n\tphase: \"implementation\" | \"verification\";\n\t/** Absolute timestamps in the injected clock's domain. */\n\tdeadline: number;\n\treserveCutoff: number;\n\t/** SHA-256 identity only; never raw environment values. */\n\tenvironmentIdentity: string;\n\tlineage: readonly string[];\n\tnow: () => number;\n\t/** Trusted owner gate; rejects revoked lanes or stale generations. */\n\tassertCurrent: () => void;\n\t/** Wake the existing owner after terminal capture/process cleanup; never dispatch a model. */\n\tonTerminal?: (record: BashJobSnapshot) => void;\n}\n\n/** Validate run admission and return its remaining absolute-deadline allocation in seconds. */\nexport function admitBashRun(context: BashRunContext): number {\n\tcontext.assertCurrent();\n\tconst now = context.now();\n\t// Host-supplied run context is an admission boundary, not model tool input.\n\tif (\n\t\t![now, context.deadline, context.reserveCutoff].every(Number.isFinite) ||\n\t\tcontext.reserveCutoff > context.deadline ||\n\t\t!Number.isSafeInteger(context.generation) ||\n\t\tcontext.generation < 0 ||\n\t\t![context.runId, context.ownerId, context.sessionId].every((id) => typeof id === \"string\" && id.length > 0) ||\n\t\t!/^[a-f0-9]{64}$/.test(context.environmentIdentity) ||\n\t\t!Array.isArray(context.lineage) ||\n\t\t!context.lineage.every((id) => typeof id === \"string\" && id.length > 0) ||\n\t\t![\"implementation\", \"verification\"].includes(context.phase)\n\t)\n\t\tthrow new Error(\"Invalid bash run context\");\n\tif (now >= context.deadline) throw new Error(\"Run deadline exceeded\");\n\tif (context.phase === \"implementation\" && now >= context.reserveCutoff)\n\t\tthrow new Error(\"Run verification reserve reached\");\n\treturn (context.deadline - now) / 1000;\n}\n\nexport interface BashStdin {\n\twrite(input: string, eof?: boolean): Promise<JobInputResult>;\n}\n\n/** Pluggable bash transport; remote implementations opt into stdin only when actually supported. */\nexport interface BashOperations {\n\t/** Only explicitly capable transports may receive an input registration callback. */\n\tsupportsStdin?: boolean;\n\t/**\n\t * Execute a command and stream output.\n\t * @param command The command to execute\n\t * @param cwd Working directory\n\t * @param options Execution options\n\t * @returns Promise resolving to the exit code. Report signal terminations as 128 + signal number;\n\t * a null exit code is treated as a failed command.\n\t */\n\texec: (\n\t\tcommand: string,\n\t\tcwd: string,\n\t\toptions: {\n\t\t\t/** Await a returned promise before delivering more stdout or stderr. */\n\t\t\tonData: ((data: Buffer) => void) | ((data: Buffer) => Promise<void>);\n\t\t\tsignal?: AbortSignal;\n\t\t\ttimeout?: number;\n\t\t\tenv?: NodeJS.ProcessEnv;\n\t\t\t/** Background jobs terminate lingering children before releasing process custody. */\n\t\t\tterminateChildrenOnExit?: boolean;\n\t\t\t/** Absolute deadline and clock from the admitted run; absent for legacy execution. */\n\t\t\tdeadline?: number;\n\t\t\tnow?: () => number;\n\t\t\t/** Recheck run custody/admission immediately before actual process creation. */\n\t\t\tbeforeSpawn?: () => void;\n\t\t\tonStdin?: (stdin: BashStdin | undefined) => void;\n\t\t\t/** Observe the original local process object; persisted PIDs never grant custody. */\n\t\t\tonProcessStarted?: (child: ChildProcess) => void;\n\t\t},\n\t) => Promise<{ exitCode: number | null }>;\n}\n\n/** Signal that a transport could not prove owned-process termination. */\nexport class BashCleanupError extends BashProcessCleanupError {\n\tconstructor() {\n\t\tsuper(\"Owned process cleanup unconfirmed\");\n\t\tthis.name = \"BashCleanupError\";\n\t}\n}\n\n/**\n * Timeout of the local shell backend. Its message keeps the `timeout:<seconds>` form custom operations throw.\n * `shellExit` is set when the shell itself exited before the deadline, so the tool was only still waiting\n * because background processes kept writing to the inherited stdout/stderr pipes (#11613).\n */\nclass ShellTimeoutError extends Error {\n\treadonly shellExit: { exitCode: number; afterSeconds: number } | undefined;\n\n\tconstructor(timeout: number | undefined, shellExit: { exitCode: number; afterSeconds: number } | undefined) {\n\t\tsuper(`timeout:${timeout}`);\n\t\tthis.shellExit = shellExit;\n\t}\n}\n\n/** Whether the executor can rule out effects escaping the shell's process group. */\nexport type ShellProcessCustody = \"bounded\" | \"uncertain\";\n\n// This is a launch-free grammar, not a read-only command allowlist: redirects still mutate files.\n// No expansions, operators, function imports, startup scripts or injected loaders may execute code.\nconst literalShellWord = String.raw`(?:[a-zA-Z0-9_./:=,%@+\\-]+|'[^']*'|\"[^\"$\\x60\\\\]*\")`;\n// Only string printing: printf options can assign/evaluate array subscripts, and %n assigns too.\n// Reject every option spelling and every other conversion rather than interpreting Bash's formats.\nconst literalPrintfFormat = String.raw`(?!['\"]?-)(?:(?:[a-zA-Z0-9_./:=,@+\\-]|%[s%])+|'(?:[^'%]|%[s%])*'|\"(?:[^\"%$\\x60\\\\]|%[s%])*\")`;\nconst launchFreeBuiltin = new RegExp(\n\tString.raw`^[ \\t]*(?:builtin[ \\t]+)?(?:printf[ \\t]+${literalPrintfFormat}|echo|true|false|:)(?:[ \\t]+${literalShellWord})*(?:[ \\t]*>>?[ \\t]*${literalShellWord})?[ \\t]*$`,\n);\n\n/** Shared process execution used by the built-in shell tools. */\nexport function createLocalShellOperations(\n\tshellName: string,\n\tresolveShellConfig: () => ShellConfig,\n\tonProcessStarted?: (child: ChildProcess, custody: ShellProcessCustody) => void,\n): BashOperations {\n\tconst operations: BashOperations = {\n\t\tsupportsStdin: true,\n\t\texec: async (\n\t\t\tcommand,\n\t\t\tcwd,\n\t\t\t{\n\t\t\t\tonData,\n\t\t\t\tsignal,\n\t\t\t\ttimeout,\n\t\t\t\tenv,\n\t\t\t\tterminateChildrenOnExit,\n\t\t\t\tdeadline,\n\t\t\t\tnow,\n\t\t\t\tbeforeSpawn,\n\t\t\t\tonStdin,\n\t\t\t\tonProcessStarted: recordProcessStarted,\n\t\t\t},\n\t\t) => {\n\t\t\tlet timeoutMs = resolveTimeoutMs(timeout);\n\t\t\t// Windows taskkill loses descendant custody once the shell exits; refuse unsafe admission.\n\t\t\tif (terminateChildrenOnExit && process.platform === \"win32\") {\n\t\t\t\tthrow new Error(\"Local background bash jobs are unavailable on Windows\");\n\t\t\t}\n\t\t\tif (signal?.aborted) {\n\t\t\t\tthrow new Error(\"aborted\");\n\t\t\t}\n\t\t\tconst originalShell = resolveShellConfig();\n\t\t\tconst environment = scrubTraceEnv(env ?? getShellEnv());\n\t\t\tconst readOnly = readOnlyAcceptanceSpawn(command, cwd, originalShell, environment);\n\t\t\tconst shellConfig = readOnly ?? originalShell;\n\t\t\ttry {\n\t\t\t\tawait fsAccess(cwd, constants.F_OK);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(`Working directory does not exist: ${cwd}\\nCannot execute ${shellName} commands.`);\n\t\t\t}\n\n\t\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\t\t\tif (deadline !== undefined) {\n\t\t\t\tconst remaining = deadline - (now ?? (() => performance.now()))();\n\t\t\t\tif (remaining <= 0) throw new Error(\"Run deadline exceeded\");\n\t\t\t\ttimeoutMs = Math.min(timeoutMs ?? MAX_TIMEOUT_MS, remaining, MAX_TIMEOUT_MS);\n\t\t\t}\n\t\t\tbeforeSpawn?.();\n\t\t\tconst commandFromStdin = shellConfig.commandTransport === \"stdin\";\n\t\t\tconst child = spawn(shellConfig.shell, commandFromStdin ? shellConfig.args : [...shellConfig.args, command], {\n\t\t\t\tcwd,\n\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\tenv: environment,\n\t\t\t\tstdio: [\n\t\t\t\t\tcommandFromStdin || onStdin ? \"pipe\" : \"ignore\",\n\t\t\t\t\t\"pipe\",\n\t\t\t\t\t\"pipe\",\n\t\t\t\t\t...(readOnly ? [\"pipe\" as const] : []),\n\t\t\t\t],\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tconst filterInput = readOnly ? child.stdio[3] : undefined;\n\t\t\tif (readOnly && filterInput && \"end\" in filterInput) {\n\t\t\t\tfilterInput.on(\"error\", () => {});\n\t\t\t\tfilterInput.end(readOnly.filter);\n\t\t\t}\n\t\t\tif (child.pid) trackDetachedChildPid(child.pid, child);\n\t\t\tconst launchFree =\n\t\t\t\toriginalShell.shell === \"/bin/bash\" &&\n\t\t\t\toriginalShell.args.length === 1 &&\n\t\t\t\toriginalShell.args[0] === \"-c\" &&\n\t\t\t\t!Object.keys(environment).some((name) =>\n\t\t\t\t\t/^(?:BASH_ENV$|ENV$|SSH_CLIENT$|SSH2_CLIENT$|SHELLOPTS$|BASHOPTS$|PS4$|BASH_FUNC_|LD_|DYLD_|GLIBC_TUNABLES$)/.test(\n\t\t\t\t\t\tname,\n\t\t\t\t\t),\n\t\t\t\t) &&\n\t\t\t\tlaunchFreeBuiltin.test(command);\n\t\t\tonProcessStarted?.(child, readOnly || launchFree ? \"bounded\" : \"uncertain\");\n\t\t\trecordProcessStarted?.(child);\n\t\t\t// A broken pipe is a normal input/exit race, not an unhandled process error.\n\t\t\tchild.stdin?.on(\"error\", () => {});\n\t\t\tif (commandFromStdin) child.stdin?.end(command);\n\t\t\tlet writingInput = false;\n\t\t\tlet closeInput: (() => void) | undefined;\n\t\t\tonStdin?.(\n\t\t\t\tcommandFromStdin\n\t\t\t\t\t? undefined\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tasync write(input, eof = false) {\n\t\t\t\t\t\t\t\t// Direct transport callers are also an input trust boundary.\n\t\t\t\t\t\t\t\tif (typeof input !== \"string\" || typeof eof !== \"boolean\")\n\t\t\t\t\t\t\t\t\tthrow new Error(\"Invalid stdin input/eof\");\n\t\t\t\t\t\t\t\tconst bytes = Buffer.byteLength(input);\n\t\t\t\t\t\t\t\tif (bytes > MAX_JOB_INPUT_BYTES || writingInput) return { status: \"backpressure\", bytes: 0 };\n\t\t\t\t\t\t\t\tconst stdin = child.stdin;\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t!stdin ||\n\t\t\t\t\t\t\t\t\tstdin.destroyed ||\n\t\t\t\t\t\t\t\t\tstdin.writableEnded ||\n\t\t\t\t\t\t\t\t\tchild.exitCode !== null ||\n\t\t\t\t\t\t\t\t\tchild.signalCode !== null\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn { status: \"closed\", bytes: 0 };\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\twritingInput = true;\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\treturn await new Promise<JobInputResult>((resolve) => {\n\t\t\t\t\t\t\t\t\t\tlet settled = false;\n\t\t\t\t\t\t\t\t\t\tlet written = false;\n\t\t\t\t\t\t\t\t\t\tlet drained = true;\n\t\t\t\t\t\t\t\t\t\tlet ended = !eof;\n\t\t\t\t\t\t\t\t\t\tconst finish = (result: JobInputResult) => {\n\t\t\t\t\t\t\t\t\t\t\tif (settled) return;\n\t\t\t\t\t\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\t\t\t\t\t\tstdin.off(\"error\", closed);\n\t\t\t\t\t\t\t\t\t\t\tstdin.off(\"close\", closed);\n\t\t\t\t\t\t\t\t\t\t\tstdin.off(\"drain\", drain);\n\t\t\t\t\t\t\t\t\t\t\tresolve(result);\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tconst complete = () => {\n\t\t\t\t\t\t\t\t\t\t\tif (written && drained && ended) finish({ status: \"written\", bytes });\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tconst closed = () => finish({ status: \"closed\", bytes: 0 });\n\t\t\t\t\t\t\t\t\t\tcloseInput = closed;\n\t\t\t\t\t\t\t\t\t\tconst drain = () => {\n\t\t\t\t\t\t\t\t\t\t\tdrained = true;\n\t\t\t\t\t\t\t\t\t\t\tcomplete();\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tstdin.once(\"error\", closed);\n\t\t\t\t\t\t\t\t\t\tstdin.once(\"close\", closed);\n\t\t\t\t\t\t\t\t\t\tconst accepted = stdin.write(input, (error) => {\n\t\t\t\t\t\t\t\t\t\t\tif (settled) return;\n\t\t\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\t\t\tclosed();\n\t\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\twritten = true;\n\t\t\t\t\t\t\t\t\t\t\tif (eof)\n\t\t\t\t\t\t\t\t\t\t\t\tstdin.end(() => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tended = true;\n\t\t\t\t\t\t\t\t\t\t\t\t\tcomplete();\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\tcomplete();\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tdrained = accepted;\n\t\t\t\t\t\t\t\t\t\tif (!drained) stdin.once(\"drain\", drain);\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\t\t\tcloseInput = undefined;\n\t\t\t\t\t\t\t\t\twritingInput = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t);\n\t\t\tconst startedAt = performance.now();\n\t\t\tlet shellExitedAfterMs: number | undefined;\n\t\t\tchild.once(\"exit\", () => {\n\t\t\t\tshellExitedAfterMs = performance.now() - startedAt;\n\t\t\t});\n\t\t\tlet timedOut = false;\n\t\t\tlet exitedBeforeDeadlineAfterMs: number | undefined;\n\t\t\tlet timeoutHandle: NodeJS.Timeout | undefined;\n\t\t\tlet drainTimer: NodeJS.Timeout | undefined;\n\t\t\tlet termination: Promise<boolean> | undefined;\n\t\t\tlet finished = false;\n\t\t\tlet quiescent = true;\n\t\t\tlet outcome: { kind: \"completed\"; exitCode: number | null } | { kind: \"error\"; error: unknown };\n\t\t\tlet outputFailure: { error: unknown } | undefined;\n\t\t\tlet pendingOutput: Promise<void> | undefined;\n\t\t\tconst drainController = new AbortController();\n\t\t\tconst drainAborted = new Promise<void>((resolve) => {\n\t\t\t\tdrainController.signal.addEventListener(\"abort\", () => resolve(), { once: true });\n\t\t\t});\n\t\t\tconst terminateChildren = () =>\n\t\t\t\t(termination ??= child.pid ? killProcessTreeAsync(child.pid, undefined, child) : Promise.resolve(true));\n\t\t\tconst onAbort = () => {\n\t\t\t\tvoid terminateChildren().then(() => {\n\t\t\t\t\tif (!finished && !drainTimer) drainTimer = setTimeout(() => drainController.abort(), 500);\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst failOutput = (error: unknown) => {\n\t\t\t\toutputFailure = { error };\n\t\t\t\tchild.stdout?.off(\"data\", handleData);\n\t\t\t\tchild.stderr?.off(\"data\", handleData);\n\t\t\t\tonAbort();\n\t\t\t\tchild.stdout?.resume();\n\t\t\t\tchild.stderr?.resume();\n\t\t\t};\n\t\t\tconst handleData = (data: Buffer) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst pending = onData(data);\n\t\t\t\t\tif (pending instanceof Promise) {\n\t\t\t\t\t\t// Both pipes share one sink, so neither may enqueue more until it drains.\n\t\t\t\t\t\tchild.stdout?.pause();\n\t\t\t\t\t\tchild.stderr?.pause();\n\t\t\t\t\t\tpendingOutput = pending.then(() => {\n\t\t\t\t\t\t\tchild.stdout?.resume();\n\t\t\t\t\t\t\tchild.stderr?.resume();\n\t\t\t\t\t\t}, failOutput);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailOutput(error);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// Background ownership ends with the shell, even if children keep pipes open.\n\t\t\tif (terminateChildrenOnExit) child.once(\"exit\", terminateChildren);\n\t\t\ttry {\n\t\t\t\t// Set timeout if provided.\n\t\t\t\tif (timeoutMs !== undefined) {\n\t\t\t\t\ttimeoutHandle = setTimeout(() => {\n\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\texitedBeforeDeadlineAfterMs = shellExitedAfterMs;\n\t\t\t\t\t\tonAbort();\n\t\t\t\t\t}, timeoutMs);\n\t\t\t\t}\n\t\t\t\t// Stream stdout and stderr.\n\t\t\t\tchild.stdout?.on(\"data\", handleData);\n\t\t\t\tchild.stderr?.on(\"data\", handleData);\n\t\t\t\t// Handle abort signal by killing the entire process tree.\n\t\t\t\tif (signal) {\n\t\t\t\t\tif (signal.aborted) onAbort();\n\t\t\t\t\telse signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\t\t\t\t// Handle shell spawn errors and wait for the process to terminate without hanging\n\t\t\t\t// on inherited stdio handles held by detached descendants.\n\t\t\t\tconst exitCode = await waitForChildProcess(child, drainController.signal);\n\t\t\t\tawait Promise.race([pendingOutput, drainAborted]);\n\t\t\t\tif (outputFailure) throw outputFailure.error;\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\tthrow new Error(\"aborted\");\n\t\t\t\t}\n\t\t\t\t// A signal-killed shell has no exit code. Use the standard shell convention so\n\t\t\t\t// callers do not mistake the termination for a successful command.\n\t\t\t\tconst signalCode = child.signalCode;\n\t\t\t\tconst resolvedExitCode = exitCode ?? (signalCode ? 128 + (osConstants.signals[signalCode] ?? 0) : 1);\n\t\t\t\tif (timedOut) {\n\t\t\t\t\tthrow new ShellTimeoutError(\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\texitedBeforeDeadlineAfterMs !== undefined\n\t\t\t\t\t\t\t? { exitCode: resolvedExitCode, afterSeconds: Math.round(exitedBeforeDeadlineAfterMs / 100) / 10 }\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (readOnly && resolvedExitCode !== 0) {\n\t\t\t\t\t// Isolation can reject ordinary test writes. Retry the authorized command without a receipt;\n\t\t\t\t\t// the ledger's original invalidation remains in force, including for earlier failed checks.\n\t\t\t\t\tawait onData(\n\t\t\t\t\t\tBuffer.from(\n\t\t\t\t\t\t\t\"\\n[Read-only verification failed; retrying with normal execution, without common-state proof]\\n\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\toutcome = {\n\t\t\t\t\t\tkind: \"completed\",\n\t\t\t\t\t\t...(await readOnly.retry(() =>\n\t\t\t\t\t\t\toperations.exec(command, cwd, {\n\t\t\t\t\t\t\t\tonData,\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\t\t\tenv,\n\t\t\t\t\t\t\t\tterminateChildrenOnExit,\n\t\t\t\t\t\t\t\tdeadline,\n\t\t\t\t\t\t\t\tnow,\n\t\t\t\t\t\t\t\tbeforeSpawn,\n\t\t\t\t\t\t\t\tonStdin,\n\t\t\t\t\t\t\t\tonProcessStarted: recordProcessStarted,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)),\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\tif (resolvedExitCode === 0) readOnly?.completed();\n\t\t\t\t\toutcome = { kind: \"completed\", exitCode: resolvedExitCode };\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\toutcome = { kind: \"error\", error };\n\t\t\t} finally {\n\t\t\t\tfinished = true;\n\t\t\t\t// Local pipe custody ends even when process termination cannot be confirmed.\n\t\t\t\tcloseInput?.();\n\t\t\t\tchild.stdin?.destroy();\n\t\t\t\tif (terminateChildrenOnExit || deadline !== undefined) {\n\t\t\t\t\tchild.off(\"exit\", terminateChildren);\n\t\t\t\t\tquiescent = await terminateChildren();\n\t\t\t\t}\n\t\t\t\tif (drainTimer) clearTimeout(drainTimer);\n\t\t\t\t// The custody monitor releases absent groups; shell return alone must not release live descendants.\n\t\t\t\tif (timeoutHandle) clearTimeout(timeoutHandle);\n\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t\tchild.stdout?.off(\"data\", handleData);\n\t\t\t\tchild.stderr?.off(\"data\", handleData);\n\t\t\t}\n\t\t\tif (deadline !== undefined && !quiescent) throw new BashCleanupError();\n\t\t\tif (!quiescent) throw new BashProcessCleanupError(\"Background process cleanup could not confirm quiescence\");\n\t\t\tif (outcome.kind === \"error\") throw outcome.error;\n\t\t\treturn { exitCode: outcome.exitCode };\n\t\t},\n\t};\n\treturn operations;\n}\n\n/**\n * Create bash operations using pi's built-in local shell execution backend.\n *\n * This is useful for extensions that intercept user_bash and still want pi's\n * standard local shell behavior while wrapping or rewriting commands.\n */\nexport function createLocalBashOperations(options?: {\n\tshellPath?: string;\n\tonProcessStarted?: (child: ChildProcess, custody: ShellProcessCustody) => void;\n}): BashOperations {\n\treturn createLocalShellOperations(\"bash\", () => getShellConfig(options?.shellPath), options?.onProcessStarted);\n}\n\nexport interface BashSpawnContext {\n\tcommand: string;\n\tcwd: string;\n\tenv: NodeJS.ProcessEnv;\n}\n\nexport type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;\n\nfunction resolveSpawnContext(\n\tcommand: string,\n\tcwd: string,\n\tspawnHook: BashSpawnHook | undefined,\n\texposeSessionEnvironment: boolean,\n\tctx: ExtensionContext | undefined,\n\tenvironment: NodeJS.ProcessEnv | undefined,\n): BashSpawnContext {\n\tconst env = scrubTraceEnv(getShellEnv(environment));\n\tfor (const name of [\n\t\t\"HUMAIN_TERMINAL_SESSION_ID\",\n\t\t\"HUMAIN_TERMINAL_SESSION_FILE\",\n\t\t\"HUMAIN_TERMINAL_PROVIDER\",\n\t\t\"HUMAIN_TERMINAL_MODEL\",\n\t\t\"HUMAIN_TERMINAL_REASONING_LEVEL\",\n\t\t\"PI_SESSION_ID\",\n\t\t\"PI_SESSION_FILE\",\n\t\t\"PI_PROVIDER\",\n\t\t\"PI_MODEL\",\n\t\t\"PI_REASONING_LEVEL\",\n\t]) {\n\t\tdelete env[name];\n\t}\n\tif (exposeSessionEnvironment && ctx) {\n\t\tconst model = ctx.model;\n\t\tconst sessionId = ctx.sessionManager.getSessionId();\n\t\tenv.HUMAIN_TERMINAL_SESSION_ID = sessionId;\n\t\tenv.PI_SESSION_ID = sessionId;\n\t\tconst sessionFile = ctx.sessionManager.getSessionFile();\n\t\tif (sessionFile) {\n\t\t\tenv.HUMAIN_TERMINAL_SESSION_FILE = sessionFile;\n\t\t\tenv.PI_SESSION_FILE = sessionFile;\n\t\t}\n\t\tif (model) {\n\t\t\tenv.HUMAIN_TERMINAL_PROVIDER = model.provider;\n\t\t\tenv.HUMAIN_TERMINAL_MODEL = model.id;\n\t\t\tenv.PI_PROVIDER = model.provider;\n\t\t\tenv.PI_MODEL = model.id;\n\t\t}\n\t\tif (ctx.thinkingLevel) {\n\t\t\tenv.HUMAIN_TERMINAL_REASONING_LEVEL = ctx.thinkingLevel;\n\t\t\tenv.PI_REASONING_LEVEL = ctx.thinkingLevel;\n\t\t}\n\t}\n\tconst baseContext: BashSpawnContext = { command, cwd, env };\n\treturn spawnHook ? spawnHook(baseContext) : baseContext;\n}\n\nexport interface BashToolOptions {\n\t/** Session owner required for model-facing background execution. */\n\tjobs?: BashJobManager;\n\t/** Opt-in run-owned admission/deadline. Absent preserves legacy execution. */\n\tgetRunContext?: () => BashRunContext | undefined;\n\t/** Explicit base environment; defaults to the host environment. */\n\tenvironment?: NodeJS.ProcessEnv;\n\t/** Register a local shell immediately after spawn. Must not throw. */\n\tonProcessStarted?: (child: ChildProcess) => void;\n\t/** Custom operations for command execution. Default: local shell */\n\toperations?: BashOperations;\n\t/** Opt-in 8 KiB head-and-tail model-facing output. Structured output is unchanged. */\n\toutputHeadTail?: boolean;\n\t/** Opt-in deterministic cleanup of model-facing bash output; structured output stays raw. */\n\toutputCleanup?: boolean;\n\t/** Command prefix prepended to every command (for example shell setup commands) */\n\tcommandPrefix?: string;\n\t/** Optional explicit shell path from settings */\n\tshellPath?: string;\n\t/** Expose current HUMAIN Code CLI session metadata and PI compatibility aliases. Default: true */\n\texposeSessionEnvironment?: boolean;\n\t/** Remaining session budget at execution time; only model-facing bash uses this cap. */\n\tgetRemainingTimeSeconds?: () => number;\n\t/** Hook to adjust command, cwd, or env before execution */\n\tspawnHook?: BashSpawnHook;\n}\n\nexport type BashRenderState = {\n\tstartedAt: number | undefined;\n\tendedAt: number | undefined;\n\tinterval: NodeJS.Timeout | undefined;\n};\n\nexport interface ShellToolConfig {\n\tname: string;\n\tlabel: string;\n\tshellName: string;\n\tprompt: string;\n\tpromptSnippet: string;\n\tpromptGuidelines?: readonly string[];\n\ttempFilePrefix: string;\n}\n\n// Bind ownership to execution identity so SDK/extension definition copies retain it.\nconst bashToolOwners = new WeakMap<ToolDefinition[\"execute\"], BashJobManager>();\n\n/** Resolve the actual shell owner before the session wraps registered tools. */\nexport function getBashToolOwner(definition: Pick<ToolDefinition, \"execute\">): BashJobManager | undefined {\n\treturn bashToolOwners.get(definition.execute);\n}\n\nexport function createShellToolDefinition(\n\tcwd: string,\n\tconfig: ShellToolConfig,\n\toptions?: BashToolOptions,\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {\n\t// Foreground descendants need an owner even when explicit background admission is disabled.\n\tconst owner = options?.jobs ?? new BashJobManager();\n\tconst ops =\n\t\toptions?.operations ??\n\t\tcreateLocalBashOperations({\n\t\t\tshellPath: options?.shellPath,\n\t\t\tonProcessStarted: (child, custody) => {\n\t\t\t\towner.ownProcess(child, custody);\n\t\t\t\toptions?.onProcessStarted?.(child);\n\t\t\t},\n\t\t});\n\tconst commandPrefix = options?.commandPrefix;\n\tconst exposeSessionEnvironment = options?.exposeSessionEnvironment ?? true;\n\tconst spawnHook = options?.spawnHook;\n\tconst defaultTimeout = config.name === \"bash\" ? DEFAULT_BASH_TIMEOUT_SECONDS : undefined;\n\tconst outputCleanupEnv = (options?.environment ?? process.env).HUMAIN_TERMINAL_BASH_OUTPUT_CLEANUP;\n\tconst outputCleanup =\n\t\tconfig.name === \"bash\" &&\n\t\t(outputCleanupEnv === \"1\" ? true : outputCleanupEnv === \"0\" ? false : options?.outputCleanup === true);\n\tconst outputCapEnv = (options?.environment ?? process.env).HUMAIN_TERMINAL_BASH_OUTPUT_HEAD_TAIL;\n\tconst outputHeadTail =\n\t\tconfig.name === \"bash\" &&\n\t\t(outputCapEnv === \"1\" ? true : outputCapEnv === \"0\" ? false : options?.outputHeadTail === true);\n\tconst definition: ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> = {\n\t\tname: config.name,\n\t\tlabel: config.label,\n\t\tdescription: `Execute a ${config.shellName} command in the current working directory. Returns stdout and stderr. ${outputHeadTail ? \"Output keeps up to 4 KiB each from the head and tail, at most 8 KiB and 2,000 lines combined.\" : `Output is truncated to last ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first).`} If truncated, full output is saved to a temp file. ${defaultTimeout === undefined ? \"Optionally provide a timeout in seconds.\" : `Commands time out after ${defaultTimeout} seconds by default; provide timeout in seconds for longer commands. Use background:true for servers, watchers, builds and solvers taking minutes, then jobs to inspect or wait. Background work has no default timeout; local background jobs require Linux or macOS.`}`,\n\t\tpromptSnippet: config.promptSnippet,\n\t\tpromptGuidelines: exposeSessionEnvironment && config.promptGuidelines ? [...config.promptGuidelines] : undefined,\n\t\t// TypeBox requires optional schema keys in its type even when the runtime schema omits them.\n\t\tparameters: (defaultTimeout === undefined ? shellSchema : bashSchema) as typeof bashSchema,\n\t\toutputSchema:\n\t\t\tdefaultTimeout === undefined ? bashOutputSchema : Type.Union([bashOutputSchema, bashJobOutputSchema]),\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ command, timeout, background }: BashToolInput,\n\t\t\tsignal?: AbortSignal,\n\t\t\tonUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\n\t\t\tconst resolvedCommand = commandPrefix ? `${commandPrefix}\\n${command}` : command;\n\t\t\tconst spawnContext = resolveSpawnContext(\n\t\t\t\tresolvedCommand,\n\t\t\t\tctx?.cwd || cwd,\n\t\t\t\tspawnHook,\n\t\t\t\texposeSessionEnvironment,\n\t\t\t\tctx,\n\t\t\t\toptions?.environment,\n\t\t\t);\n\t\t\tconst runContext = options?.getRunContext?.();\n\t\t\tif (runContext) admitBashRun(runContext);\n\t\t\tif (background) {\n\t\t\t\tif (config.name !== \"bash\" || !options?.jobs) {\n\t\t\t\t\tthrow new Error(\"Background bash requires a session job manager\");\n\t\t\t\t}\n\t\t\t\tresolveTimeoutMs(timeout);\n\t\t\t\tif (signal?.aborted) throw new Error(\"Command aborted\");\n\t\t\t\tconst job = options.jobs.start(ops, spawnContext, timeout, runContext);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Background job ${job.job_id} started. Use jobs to read, wait, or kill it. Output: ${job.full_output_path}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: undefined,\n\t\t\t\t\tstructuredContent: job,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst output = new OutputAccumulator({\n\t\t\t\ttempFilePrefix: config.tempFilePrefix,\n\t\t\t\tcleanup: outputCleanup,\n\t\t\t\t...(outputHeadTail ? { maxBytes: 8 * 1024, headAndTail: true } : {}),\n\t\t\t});\n\t\t\tlet acceptingOutput = true;\n\t\t\tlet updateTimer: NodeJS.Timeout | undefined;\n\t\t\tlet updateDirty = false;\n\t\t\tlet lastUpdateAt = 0;\n\n\t\t\tconst emitOutputUpdate = () => {\n\t\t\t\tif (!onUpdate || !updateDirty) return;\n\t\t\t\tupdateDirty = false;\n\t\t\t\tlastUpdateAt = Date.now();\n\t\t\t\tconst snapshot = output.snapshot({ persistIfTruncated: true });\n\t\t\t\tonUpdate({\n\t\t\t\t\tcontent: [{ type: \"text\", text: snapshot.content || \"\" }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\ttruncation: snapshot.truncation.truncated ? snapshot.truncation : undefined,\n\t\t\t\t\t\tfullOutputPath: snapshot.fullOutputPath,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst clearUpdateTimer = () => {\n\t\t\t\tif (updateTimer) {\n\t\t\t\t\tclearTimeout(updateTimer);\n\t\t\t\t\tupdateTimer = undefined;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst scheduleOutputUpdate = () => {\n\t\t\t\tif (!onUpdate) return;\n\t\t\t\tupdateDirty = true;\n\t\t\t\tconst delay = BASH_UPDATE_THROTTLE_MS - (Date.now() - lastUpdateAt);\n\t\t\t\tif (delay <= 0) {\n\t\t\t\t\tclearUpdateTimer();\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tupdateTimer ??= setTimeout(() => {\n\t\t\t\t\tupdateTimer = undefined;\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t}, delay);\n\t\t\t};\n\n\t\t\tif (onUpdate) {\n\t\t\t\tonUpdate({ content: [], details: undefined });\n\t\t\t}\n\n\t\t\tconst handleData = (data: Buffer) => {\n\t\t\t\tif (!acceptingOutput) return;\n\t\t\t\tconst pending = output.append(data);\n\t\t\t\tscheduleOutputUpdate();\n\t\t\t\treturn pending;\n\t\t\t};\n\n\t\t\tconst finishOutput = async () => {\n\t\t\t\tacceptingOutput = false;\n\t\t\t\toutput.finish();\n\t\t\t\tclearUpdateTimer();\n\t\t\t\temitOutputUpdate();\n\t\t\t\tconst snapshot = output.snapshot({ persistIfTruncated: true });\n\t\t\t\tawait output.closeTempFile();\n\t\t\t\treturn snapshot;\n\t\t\t};\n\n\t\t\tconst formatOutput = (snapshot: Awaited<ReturnType<typeof finishOutput>>, emptyText = \"(no output)\") => {\n\t\t\t\tconst truncation = snapshot.truncation;\n\t\t\t\tlet text = snapshot.content || emptyText;\n\t\t\t\tlet details: BashToolDetails | undefined = outputCleanup\n\t\t\t\t\t? { fullOutputPath: snapshot.fullOutputPath }\n\t\t\t\t\t: undefined;\n\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\tdetails = { truncation, fullOutputPath: snapshot.fullOutputPath };\n\t\t\t\t\tif (outputHeadTail) return { text, details };\n\t\t\t\t\tconst startLine = truncation.totalLines - truncation.outputLines + 1;\n\t\t\t\t\tconst endLine = truncation.totalLines;\n\t\t\t\t\tif (truncation.lastLinePartial) {\n\t\t\t\t\t\tconst lastLineSize = formatSize(output.getLastLineBytes());\n\t\t\t\t\t\ttext += `\\n\\n[Showing last ${formatSize(truncation.outputBytes)} of line ${endLine} (line is ${lastLineSize}). Full output: ${snapshot.fullOutputPath}]`;\n\t\t\t\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\t\ttext += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines}. Full output: ${snapshot.fullOutputPath}]`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttext += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Full output: ${snapshot.fullOutputPath}]`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn { text, details };\n\t\t\t};\n\n\t\t\tconst appendStatus = (text: string, status: string) => `${text ? `${text}\\n\\n` : \"\"}${status}`;\n\t\t\tconst startedAt = performance.now();\n\t\t\tlet timeLimitCapped = false;\n\n\t\t\ttry {\n\t\t\t\tlet exitCode: number | null;\n\t\t\t\ttry {\n\t\t\t\t\tlet effectiveTimeout = timeout === undefined ? defaultTimeout : timeout;\n\t\t\t\t\tif (!runContext && config.name === \"bash\" && options?.getRemainingTimeSeconds) {\n\t\t\t\t\t\t// Validate explicit timeouts before capping so the budget cannot hide invalid input.\n\t\t\t\t\t\tresolveTimeoutMs(effectiveTimeout);\n\t\t\t\t\t\tconst cap = Math.max(5, options.getRemainingTimeSeconds() - 20);\n\t\t\t\t\t\ttimeLimitCapped = effectiveTimeout !== undefined && cap < effectiveTimeout;\n\t\t\t\t\t\tif (timeLimitCapped) effectiveTimeout = cap;\n\t\t\t\t\t}\n\t\t\t\t\tif (runContext) {\n\t\t\t\t\t\tresolveTimeoutMs(effectiveTimeout);\n\t\t\t\t\t\teffectiveTimeout = Math.min(\n\t\t\t\t\t\t\teffectiveTimeout ?? MAX_TIMEOUT_SECONDS,\n\t\t\t\t\t\t\tadmitBashRun(runContext),\n\t\t\t\t\t\t\tMAX_TIMEOUT_SECONDS,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst result = await ops.exec(spawnContext.command, spawnContext.cwd, {\n\t\t\t\t\t\tonData: handleData,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\ttimeout: effectiveTimeout,\n\t\t\t\t\t\tenv: spawnContext.env,\n\t\t\t\t\t\t...(runContext\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tdeadline: runContext.deadline,\n\t\t\t\t\t\t\t\t\tnow: runContext.now,\n\t\t\t\t\t\t\t\t\tterminateChildrenOnExit: true,\n\t\t\t\t\t\t\t\t\tbeforeSpawn: () => {\n\t\t\t\t\t\t\t\t\t\tadmitBashRun(runContext);\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t});\n\t\t\t\t\texitCode = result.exitCode;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconst snapshot = await finishOutput();\n\t\t\t\t\tconst { text } = formatOutput(snapshot, \"\");\n\t\t\t\t\tif (err instanceof Error && err.message === \"aborted\") {\n\t\t\t\t\t\tthrow new Error(appendStatus(text, \"Command aborted\"));\n\t\t\t\t\t}\n\t\t\t\t\tif (err instanceof Error && err.message.startsWith(\"timeout:\")) {\n\t\t\t\t\t\tconst timeoutSecs = err.message.split(\":\")[1];\n\t\t\t\t\t\tconst guidance = timeLimitCapped\n\t\t\t\t\t\t\t? \"; stopped to respect the run's time limit (20-second reserve).\"\n\t\t\t\t\t\t\t: timeout === undefined && defaultTimeout !== undefined\n\t\t\t\t\t\t\t\t? \"; pass a larger timeout for commands that need longer, and start long-running processes (servers, watchers) in the background with output redirected to a file.\"\n\t\t\t\t\t\t\t\t: \"\";\n\t\t\t\t\t\tlet status = `Command timed out after ${timeoutSecs} seconds${guidance}`;\n\t\t\t\t\t\tif (err instanceof ShellTimeoutError && err.shellExit) {\n\t\t\t\t\t\t\tstatus += `. The shell exited with code ${err.shellExit.exitCode} after ${err.shellExit.afterSeconds} seconds, but background processes it started kept writing output until the timeout.`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new Error(appendStatus(text, status));\n\t\t\t\t\t}\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\n\t\t\t\tconst snapshot = await finishOutput();\n\t\t\t\tconst { text: outputText, details } = formatOutput(snapshot);\n\t\t\t\tif (exitCode === null) {\n\t\t\t\t\tthrow new Error(appendStatus(outputText, \"Command terminated without an exit code\"));\n\t\t\t\t}\n\t\t\t\tconst wallTimeSeconds = Math.round((performance.now() - startedAt) / 100) / 10;\n\t\t\t\tconst fullOutput = await output.readFullOutput(STRUCTURED_OUTPUT_MAX_BYTES);\n\t\t\t\tconst structuredContent: BashToolOutput = {\n\t\t\t\t\toutput: fullOutput.content,\n\t\t\t\t\ttruncated: fullOutput.truncated,\n\t\t\t\t\t...(fullOutput.truncated && snapshot.fullOutputPath\n\t\t\t\t\t\t? { full_output_path: snapshot.fullOutputPath }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\texit_code: exitCode,\n\t\t\t\t\twall_time_seconds: wallTimeSeconds,\n\t\t\t\t};\n\t\t\t\tif (exitCode !== 0) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: appendStatus(outputText, `Command exited with code ${exitCode}`) }],\n\t\t\t\t\t\tdetails,\n\t\t\t\t\t\tstructuredContent,\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { content: [{ type: \"text\", text: outputText }], details, structuredContent };\n\t\t\t} finally {\n\t\t\t\tclearUpdateTimer();\n\t\t\t}\n\t\t},\n\t\t...createShellRenderers(config.prompt),\n\t};\n\tbashToolOwners.set(definition.execute, owner);\n\treturn definition;\n}\n\nconst bashToolConfig: ShellToolConfig = {\n\tname: \"bash\",\n\tlabel: \"bash\",\n\tshellName: \"bash\",\n\tprompt: \"$\",\n\tpromptSnippet: bashToolSystemPromptContribution.snippet,\n\tpromptGuidelines: bashToolSystemPromptContribution.guidelines,\n\ttempFilePrefix: \"pi-bash\",\n};\n\nexport function createBashToolDefinition(\n\tcwd: string,\n\toptions?: BashToolOptions,\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {\n\treturn createShellToolDefinition(cwd, bashToolConfig, options);\n}\n\nexport function createBashTool(cwd: string, options?: BashToolOptions): TypeBoxAgentTool<typeof bashSchema> {\n\tconst definition = createBashToolDefinition(cwd, options);\n\tconst tool = wrapToolDefinition(definition);\n\tconst owner = getBashToolOwner(definition);\n\tif (owner) bashToolOwners.set(tool.execute, owner);\n\tObject.assign(tool, {\n\t\tpromptSnippet: definition.promptSnippet,\n\t\tpromptGuidelines: definition.promptGuidelines,\n\t});\n\treturn tool;\n}\n"]}
@@ -3,6 +3,13 @@
3
3
  */
4
4
  export declare function detectLineEnding(content: string): "\r\n" | "\n";
5
5
  export declare function normalizeToLF(text: string): string;
6
+ /**
7
+ * Apply replacements matched in `normalizeToLF(originalContent)` to `originalContent` itself.
8
+ * Text outside the replaced ranges keeps its bytes, including its line endings. Line breaks in
9
+ * the new text get the line ending of the line where the replaced range starts. The result,
10
+ * normalized to LF, equals the replacements applied to the normalized content.
11
+ */
12
+ export declare function applyReplacementsToOriginal(originalContent: string, replacements: TextReplacement[]): string;
6
13
  export declare function restoreLineEndings(text: string, ending: "\r\n" | "\n"): string;
7
14
  /**
8
15
  * Normalize text for fuzzy matching. Applies progressive transformations:
@@ -18,7 +25,8 @@ interface MatchedEdit {
18
25
  matchLength: number;
19
26
  newText: string;
20
27
  }
21
- type TextReplacement = Pick<MatchedEdit, "matchIndex" | "matchLength" | "newText">;
28
+ /** Replacement of `matchLength` characters at `matchIndex` with `newText`. */
29
+ export type TextReplacement = Pick<MatchedEdit, "matchIndex" | "matchLength" | "newText">;
22
30
  /**
23
31
  * Apply replacements matched against `baseContent` to `originalContent` while
24
32
  * preserving unchanged line blocks from the original.
@@ -52,6 +60,8 @@ export interface Edit {
52
60
  export interface AppliedEditsResult {
53
61
  baseContent: string;
54
62
  newContent: string;
63
+ /** Sorted replacements of `baseContent` that turn it into `newContent` */
64
+ replacements: TextReplacement[];
55
65
  }
56
66
  /**
57
67
  * Find oldText in content, trying exact match first, then fuzzy match.
@@ -1 +1 @@
1
- {"version":3,"file":"edit-diff.d.ts","sourceRoot":"","sources":["../../../src/core/tools/edit-diff.ts"],"names":[],"mappings":"AACA;;GAEG;AAOH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM/D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAE9E;AAcD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqB3D;AA0BD,UAAU,WAAW;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,YAAY,GAAG,aAAa,GAAG,SAAS,CAAC,CAAC;AAiDnF;;;;;;;;;GASG;AACH,wBAAgB,yCAAyC,CACxD,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE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;CACrC;AAED,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACrC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,IAAI,EAAE,EACb,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,cAAc,GAAG,aAAa,CAAC,CAyBzC;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,cAAc,GAAG,aAAa,CAAC,CAEzC"}
@@ -18,6 +18,62 @@ export function detectLineEnding(content) {
18
18
  export function normalizeToLF(text) {
19
19
  return text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
20
20
  }
21
+ /**
22
+ * Apply replacements matched in `normalizeToLF(originalContent)` to `originalContent` itself.
23
+ * Text outside the replaced ranges keeps its bytes, including its line endings. Line breaks in
24
+ * the new text get the line ending of the line where the replaced range starts. The result,
25
+ * normalized to LF, equals the replacements applied to the normalized content.
26
+ */
27
+ export function applyReplacementsToOriginal(originalContent, replacements) {
28
+ // Only CRLF changes length when normalizing: the LF of the n-th CRLF (at original offset p) is at
29
+ // p - n in the normalized text. Adding the number of CRLFs before a normalized offset gives the
30
+ // original offset, and a range that covers that LF covers the whole CRLF.
31
+ let crlfBefore = 0;
32
+ let nextCrlf = originalContent.indexOf("\r\n");
33
+ const toOriginal = (offset) => {
34
+ while (nextCrlf !== -1 && nextCrlf - crlfBefore < offset) {
35
+ crlfBefore++;
36
+ nextCrlf = originalContent.indexOf("\r\n", nextCrlf + 2);
37
+ }
38
+ return offset + crlfBefore;
39
+ };
40
+ const parts = [];
41
+ let endsWithCr = false;
42
+ const push = (part) => {
43
+ if (part.length === 0)
44
+ return;
45
+ // A CR before a seam and an LF after it would merge into one CRLF line break, for example a kept
46
+ // lone CR followed by inserted text that starts with LF, or both sides of a deleted range. Adding
47
+ // an LF turns the CR into a CRLF of its own, so the written file has the line breaks the diff shows.
48
+ if (endsWithCr && part[0] === "\n")
49
+ parts.push("\n");
50
+ parts.push(part);
51
+ endsWithCr = part[part.length - 1] === "\r";
52
+ };
53
+ let position = 0;
54
+ for (const replacement of replacements) {
55
+ const start = toOriginal(replacement.matchIndex);
56
+ push(originalContent.slice(position, start));
57
+ const ending = getLineEndingAt(originalContent, start);
58
+ push(ending === "\n" ? replacement.newText : replacement.newText.replaceAll("\n", ending));
59
+ position = toOriginal(replacement.matchIndex + replacement.matchLength);
60
+ }
61
+ push(originalContent.slice(position));
62
+ return parts.join("");
63
+ }
64
+ /**
65
+ * Line ending of the line containing `offset`: its own LF or CRLF, or that of the line before
66
+ * for an unterminated last line. A lone CR only counts in files without any LF (classic Mac
67
+ * line endings); elsewhere it is more likely a control character inside a line.
68
+ */
69
+ function getLineEndingAt(content, offset) {
70
+ let lineFeed = content.indexOf("\n", offset);
71
+ if (lineFeed === -1)
72
+ lineFeed = content.lastIndexOf("\n", offset);
73
+ if (lineFeed === -1)
74
+ return content.includes("\r") ? "\r" : "\n";
75
+ return content[lineFeed - 1] === "\r" ? "\r\n" : "\n";
76
+ }
21
77
  export function restoreLineEndings(text, ending) {
22
78
  return ending === "\r\n" ? text.replace(/\n/g, "\r\n") : text;
23
79
  }
@@ -116,17 +172,17 @@ function applyReplacements(content, replacements, offset = 0) {
116
172
  return result;
117
173
  }
118
174
  /**
119
- * Apply replacements matched against `baseContent` to `originalContent` while
120
- * preserving unchanged line blocks from the original.
175
+ * Turn replacements matched against `baseContent` into replacements of
176
+ * `originalContent` that keep unchanged line blocks from the original.
121
177
  *
122
178
  * This is useful when `baseContent` is a normalized view of the original. Each
123
- * replacement is widened to the lines it actually touches, those touched lines
124
- * are rewritten from the normalized base, and all other lines are copied back
125
- * from `originalContent`. The actual replacement ranges drive preservation so
179
+ * replacement is widened to the lines it actually touches, and those touched
180
+ * lines are rewritten from the normalized base; all other lines keep their
181
+ * original text. The actual replacement ranges drive preservation so
126
182
  * duplicate normalized lines cannot be aligned to the wrong occurrence.
127
183
  */
128
- export function applyReplacementsPreservingUnchangedLines(originalContent, baseContent, replacements) {
129
- const originalLines = splitLinesWithEndings(originalContent);
184
+ function widenReplacementsToLines(originalContent, baseContent, replacements) {
185
+ const originalLines = getLineSpans(originalContent);
130
186
  const baseLines = getLineSpans(baseContent);
131
187
  if (originalLines.length !== baseLines.length) {
132
188
  throw new Error("Cannot preserve unchanged lines because the base content has a different line count.");
@@ -143,17 +199,29 @@ export function applyReplacementsPreservingUnchangedLines(originalContent, baseC
143
199
  }
144
200
  groups.push({ ...range, replacements: [replacement] });
145
201
  }
146
- let originalLineIndex = 0;
147
- let result = "";
148
- for (const group of groups) {
149
- result += originalLines.slice(originalLineIndex, group.startLine).join("");
202
+ return groups.map((group) => {
150
203
  const groupStartOffset = baseLines[group.startLine].start;
151
204
  const groupEndOffset = baseLines[group.endLine - 1].end;
152
- result += applyReplacements(baseContent.slice(groupStartOffset, groupEndOffset), group.replacements, groupStartOffset);
153
- originalLineIndex = group.endLine;
154
- }
155
- result += originalLines.slice(originalLineIndex).join("");
156
- return result;
205
+ const originalStart = originalLines[group.startLine].start;
206
+ return {
207
+ matchIndex: originalStart,
208
+ matchLength: originalLines[group.endLine - 1].end - originalStart,
209
+ newText: applyReplacements(baseContent.slice(groupStartOffset, groupEndOffset), group.replacements, groupStartOffset),
210
+ };
211
+ });
212
+ }
213
+ /**
214
+ * Apply replacements matched against `baseContent` to `originalContent` while
215
+ * preserving unchanged line blocks from the original.
216
+ *
217
+ * This is useful when `baseContent` is a normalized view of the original. Each
218
+ * replacement is widened to the lines it actually touches, those touched lines
219
+ * are rewritten from the normalized base, and all other lines are copied back
220
+ * from `originalContent`. The actual replacement ranges drive preservation so
221
+ * duplicate normalized lines cannot be aligned to the wrong occurrence.
222
+ */
223
+ export function applyReplacementsPreservingUnchangedLines(originalContent, baseContent, replacements) {
224
+ return applyReplacements(originalContent, widenReplacementsToLines(originalContent, baseContent, replacements));
157
225
  }
158
226
  /**
159
227
  * Find oldText in content, trying exact match first, then fuzzy match.
@@ -289,13 +357,14 @@ export function applyEditsToNormalizedContent(normalizedContent, edits, path) {
289
357
  }
290
358
  }
291
359
  const baseContent = normalizedContent;
292
- const newContent = usedFuzzyMatch
293
- ? applyReplacementsPreservingUnchangedLines(normalizedContent, replacementBaseContent, matchedEdits)
294
- : applyReplacements(replacementBaseContent, matchedEdits);
360
+ const replacements = usedFuzzyMatch
361
+ ? widenReplacementsToLines(normalizedContent, replacementBaseContent, matchedEdits)
362
+ : matchedEdits;
363
+ const newContent = applyReplacements(baseContent, replacements);
295
364
  if (baseContent === newContent) {
296
365
  throw getNoChangeError(path, normalizedEdits.length);
297
366
  }
298
- return { baseContent, newContent };
367
+ return { baseContent, newContent, replacements };
299
368
  }
300
369
  /**
301
370
  * The lines of a text as jsdiff tokenizes them (each with its trailing "\n"), split on demand. Splitting