@humain/humain-code 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/bundle/chunks/{anthropic-messages-UZB5HJE3.js → anthropic-messages-XFCDMGD6.js} +4 -4
  3. package/dist/bundle/chunks/{azure-openai-responses-J3LCMWPQ.js → azure-openai-responses-F4KQM3NK.js} +3 -3
  4. package/dist/bundle/chunks/{chunk-7EONJCBE.js → chunk-2JNJJ6SZ.js} +1 -1
  5. package/dist/bundle/chunks/{chunk-3CGMVKHA.js → chunk-3E37CJCE.js} +1 -1
  6. package/dist/bundle/chunks/{chunk-SQ7NTRLJ.js → chunk-3PJ7NPWN.js} +20 -17
  7. package/dist/bundle/chunks/{chunk-WRYGY5XG.js → chunk-4MKATHT2.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-ATFZAFMS.js → chunk-65FLSKDA.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-P2Y2H7SD.js → chunk-6JTCRCNF.js} +2 -2
  10. package/dist/bundle/chunks/{chunk-CET2MXXN.js → chunk-6P6MMQUH.js} +1 -1
  11. package/dist/bundle/chunks/{chunk-APNPBT7Y.js → chunk-BRSLXHED.js} +1 -1
  12. package/dist/bundle/chunks/{chunk-KONLZKPL.js → chunk-E4VUW4RI.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-R3VDXQW2.js → chunk-EFY2QPVP.js} +6 -6
  14. package/dist/bundle/chunks/{chunk-4EV7CK26.js → chunk-F2H47FRF.js} +1 -1
  15. package/dist/bundle/chunks/{chunk-KQXXBQ57.js → chunk-G2QMON4O.js} +382 -331
  16. package/dist/bundle/chunks/{chunk-TYN46EVI.js → chunk-GPLWWO5Q.js} +1 -1
  17. package/dist/bundle/chunks/{chunk-JV7VHOAY.js → chunk-H2B3WLIM.js} +2 -2
  18. package/dist/bundle/chunks/chunk-H7UPU2SH.js +2093 -0
  19. package/dist/bundle/chunks/{chunk-NNWNIBLG.js → chunk-JKX5EGOT.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-4SFWYKL5.js → chunk-JQBZUFH7.js} +467 -440
  21. package/dist/bundle/chunks/{chunk-D3KYOSQY.js → chunk-JSHKS7VH.js} +1 -1
  22. package/dist/bundle/chunks/{chunk-C4DHVDYT.js → chunk-JX6YIPNK.js} +1 -1
  23. package/dist/bundle/chunks/{chunk-Z5UFSRO4.js → chunk-KI7CHPWC.js} +1 -1
  24. package/dist/bundle/chunks/{chunk-VKQNYZUA.js → chunk-KRBELWQH.js} +1 -1
  25. package/dist/bundle/chunks/{chunk-AI7EHDAX.js → chunk-LSRXA7OS.js} +1 -1
  26. package/dist/bundle/chunks/{chunk-WBSGWISD.js → chunk-M5TVWJ5T.js} +5 -4
  27. package/dist/bundle/chunks/{chunk-XVIQYONJ.js → chunk-MIAXMK5F.js} +1 -1
  28. package/dist/bundle/chunks/{chunk-WGXMYMPE.js → chunk-PFBAIRCY.js} +2 -2
  29. package/dist/bundle/chunks/{chunk-CU6KU7JK.js → chunk-PJXBU6CR.js} +47 -44
  30. package/dist/bundle/chunks/{chunk-OVDMYBIT.js → chunk-PWFM6AQQ.js} +1 -1
  31. package/dist/bundle/chunks/{chunk-PGVDL4KB.js → chunk-QFDZEUFU.js} +2 -2
  32. package/dist/bundle/chunks/{chunk-DD5UT56Y.js → chunk-R2KD2HFT.js} +67 -66
  33. package/dist/bundle/chunks/{chunk-EMBIUIQ2.js → chunk-T2ZGMEMV.js} +46 -45
  34. package/dist/bundle/chunks/{chunk-IOLLZXQN.js → chunk-U4EAJPMO.js} +138 -126
  35. package/dist/bundle/chunks/chunk-UZOIHLNU.js +23 -0
  36. package/dist/bundle/chunks/{chunk-QRYDGY5I.js → chunk-ZSWU5KKA.js} +1 -1
  37. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-ETKC6B2S.js → cloudflare-workers-ai-system-one-JEZVYITT.js} +1 -1
  38. package/dist/bundle/chunks/{compat-HS4ARZK3.js → compat-ELBUCH6U.js} +6 -6
  39. package/dist/bundle/chunks/{curator-server-TC7RVVN2.js → curator-server-QB4GITGS.js} +1 -1
  40. package/dist/bundle/chunks/{dist-NMEXYUP3.js → dist-CBODG4CA.js} +5 -5
  41. package/dist/bundle/chunks/{dist-5AQPJ2TI.js → dist-NERIS6SW.js} +1 -1
  42. package/dist/bundle/chunks/{dist-DYB3AR7C.js → dist-QSYDYE3Y.js} +7 -7
  43. package/dist/bundle/chunks/{easter-egg-3d-VVUF3C3X.js → easter-egg-3d-VZC5WOYV.js} +1 -1
  44. package/dist/bundle/chunks/{execute-I3WGGPWL.js → execute-6MEJJF2T.js} +2 -2
  45. package/dist/bundle/chunks/{extract-QHZTEVJP.js → extract-L373D6O7.js} +2 -2
  46. package/dist/bundle/chunks/{flow-implementer-QMN3HKE2.js → flow-implementer-3P3BHQ7E.js} +4 -4
  47. package/dist/bundle/chunks/github-copilot.js +53 -56
  48. package/dist/bundle/chunks/{google-generative-ai-ZND73WDQ.js → google-generative-ai-WIASMWS3.js} +2 -2
  49. package/dist/bundle/chunks/{google-vertex-YAH62YRM.js → google-vertex-WSPHRZIZ.js} +3 -3
  50. package/dist/bundle/chunks/{host-Q565BCXB.js → host-WOLZCWQQ.js} +1 -1
  51. package/dist/bundle/chunks/{inprocess-453SLFL5.js → inprocess-3PDJKE5F.js} +5 -5
  52. package/dist/bundle/chunks/interactive-mode-SDUO5OLD.js +5 -0
  53. package/dist/bundle/chunks/{llama-cpp-classify-Z4GZY4GC.js → llama-cpp-classify-KYZT532X.js} +1 -1
  54. package/dist/bundle/chunks/{mistral-conversations-7I5JURDP.js → mistral-conversations-7JYDDRUT.js} +2 -2
  55. package/dist/bundle/chunks/{node-IMSYVRPL.js → node-N7TPBUJB.js} +1 -1
  56. package/dist/bundle/chunks/{openai-codex-responses-LTHOMN37.js → openai-codex-responses-7PAML4NF.js} +3 -3
  57. package/dist/bundle/chunks/{openai-completions-W2X635EE.js → openai-completions-UJDAIGTK.js} +3 -3
  58. package/dist/bundle/chunks/{openai-decisions-TN2GNOYI.js → openai-decisions-JMSDGR7K.js} +1 -1
  59. package/dist/bundle/chunks/{openai-responses-DVY4QXOG.js → openai-responses-2WNCE6AY.js} +3 -3
  60. package/dist/bundle/chunks/{openrouter-images-SE2JMS44.js → openrouter-images-V3UCCO6X.js} +1 -1
  61. package/dist/bundle/chunks/{pi-messages-WAS6Z5L5.js → pi-messages-TQ7LJUNQ.js} +2 -2
  62. package/dist/bundle/chunks/{session-picker-XNVLSJ22.js → session-picker-EYKCMFQR.js} +1 -1
  63. package/dist/bundle/chunks/{startup-ui-3TCT465D.js → startup-ui-7ODOR34R.js} +2 -2
  64. package/dist/bundle/chunks/{trace-command-7ORDQ3JS.js → trace-command-VM7FBWPE.js} +4 -4
  65. package/dist/bundle/chunks/{typesafe-system-one-AAZH6S3I.js → typesafe-system-one-YP7GGN4C.js} +1 -1
  66. package/dist/bundle/chunks/{virtual-modules-CIVXCEAN.js → virtual-modules-IU5KWB2C.js} +10 -10
  67. package/dist/bundle/cli-runtime.js +5 -5
  68. package/dist/bundle/index.js +8 -8
  69. package/dist/bundle/rpc-entry.js +4 -4
  70. package/dist/cli/args.js +1 -1
  71. package/dist/cli/args.js.map +1 -1
  72. package/dist/cli/list-models.d.ts.map +1 -1
  73. package/dist/cli/list-models.js +16 -1
  74. package/dist/cli/list-models.js.map +1 -1
  75. package/dist/cli/setup.d.ts +1 -1
  76. package/dist/cli/setup.d.ts.map +1 -1
  77. package/dist/cli/setup.js +3 -2
  78. package/dist/cli/setup.js.map +1 -1
  79. package/dist/cli.js.map +1 -1
  80. package/dist/core/agent-session-runtime.d.ts +3 -0
  81. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  82. package/dist/core/agent-session-runtime.js +11 -2
  83. package/dist/core/agent-session-runtime.js.map +1 -1
  84. package/dist/core/keybindings.d.ts +24 -0
  85. package/dist/core/keybindings.d.ts.map +1 -1
  86. package/dist/core/keybindings.js +3 -0
  87. package/dist/core/keybindings.js.map +1 -1
  88. package/dist/core/model-registry.d.ts.map +1 -1
  89. package/dist/core/model-registry.js +12 -1
  90. package/dist/core/model-registry.js.map +1 -1
  91. package/dist/core/model-resolver.d.ts.map +1 -1
  92. package/dist/core/model-resolver.js +13 -9
  93. package/dist/core/model-resolver.js.map +1 -1
  94. package/dist/core/model-runtime.d.ts +11 -2
  95. package/dist/core/model-runtime.d.ts.map +1 -1
  96. package/dist/core/model-runtime.js +23 -6
  97. package/dist/core/model-runtime.js.map +1 -1
  98. package/dist/core/oauth-account-pool.d.ts +4 -0
  99. package/dist/core/oauth-account-pool.d.ts.map +1 -1
  100. package/dist/core/oauth-account-pool.js +104 -20
  101. package/dist/core/oauth-account-pool.js.map +1 -1
  102. package/dist/core/sdk.js +2 -2
  103. package/dist/core/sdk.js.map +1 -1
  104. package/dist/core/settings-manager.d.ts +4 -0
  105. package/dist/core/settings-manager.d.ts.map +1 -1
  106. package/dist/core/settings-manager.js +17 -0
  107. package/dist/core/settings-manager.js.map +1 -1
  108. package/dist/core/settings-schema.d.ts +2 -0
  109. package/dist/core/settings-schema.d.ts.map +1 -1
  110. package/dist/core/settings-schema.js +10 -0
  111. package/dist/core/settings-schema.js.map +1 -1
  112. package/dist/core/slash-commands.d.ts.map +1 -1
  113. package/dist/core/slash-commands.js +1 -0
  114. package/dist/core/slash-commands.js.map +1 -1
  115. package/dist/extensions/usage/confirmation.d.ts.map +1 -1
  116. package/dist/extensions/usage/confirmation.js +1 -1
  117. package/dist/extensions/usage/confirmation.js.map +1 -1
  118. package/dist/extensions/usage/index.js +6 -6
  119. package/dist/extensions/usage/index.js.map +1 -1
  120. package/dist/extensions/usage/panes.d.ts +5 -0
  121. package/dist/extensions/usage/panes.d.ts.map +1 -0
  122. package/dist/extensions/usage/panes.js +10 -0
  123. package/dist/extensions/usage/panes.js.map +1 -0
  124. package/dist/extensions/usage/popup.d.ts.map +1 -1
  125. package/dist/extensions/usage/popup.js +9 -18
  126. package/dist/extensions/usage/popup.js.map +1 -1
  127. package/dist/humain/gateway/client.d.ts.map +1 -1
  128. package/dist/humain/gateway/client.js +36 -9
  129. package/dist/humain/gateway/client.js.map +1 -1
  130. package/dist/humain/gateway/http.d.ts.map +1 -1
  131. package/dist/humain/gateway/http.js +26 -6
  132. package/dist/humain/gateway/http.js.map +1 -1
  133. package/dist/humain/gateway/provider.d.ts.map +1 -1
  134. package/dist/humain/gateway/provider.js +9 -2
  135. package/dist/humain/gateway/provider.js.map +1 -1
  136. package/dist/humain/hcode/contracts.d.ts +15 -0
  137. package/dist/humain/hcode/contracts.d.ts.map +1 -1
  138. package/dist/humain/hcode/contracts.js +85 -10
  139. package/dist/humain/hcode/contracts.js.map +1 -1
  140. package/dist/humain/hcode/environment.d.ts.map +1 -1
  141. package/dist/humain/hcode/environment.js +4 -2
  142. package/dist/humain/hcode/environment.js.map +1 -1
  143. package/dist/humain/hcode/facade.d.ts +12 -1
  144. package/dist/humain/hcode/facade.d.ts.map +1 -1
  145. package/dist/humain/hcode/facade.js +35 -8
  146. package/dist/humain/hcode/facade.js.map +1 -1
  147. package/dist/humain/hcode/images.d.ts.map +1 -1
  148. package/dist/humain/hcode/images.js +4 -2
  149. package/dist/humain/hcode/images.js.map +1 -1
  150. package/dist/humain/hcode/login-copy.d.ts.map +1 -1
  151. package/dist/humain/hcode/login-copy.js +11 -1
  152. package/dist/humain/hcode/login-copy.js.map +1 -1
  153. package/dist/humain/hcode/notices.d.ts +22 -1
  154. package/dist/humain/hcode/notices.d.ts.map +1 -1
  155. package/dist/humain/hcode/notices.js +34 -3
  156. package/dist/humain/hcode/notices.js.map +1 -1
  157. package/dist/humain/hcode/provider.d.ts +3 -1
  158. package/dist/humain/hcode/provider.d.ts.map +1 -1
  159. package/dist/humain/hcode/provider.js +126 -46
  160. package/dist/humain/hcode/provider.js.map +1 -1
  161. package/dist/humain/hcode/run-credential.d.ts +21 -0
  162. package/dist/humain/hcode/run-credential.d.ts.map +1 -0
  163. package/dist/humain/hcode/run-credential.js +140 -0
  164. package/dist/humain/hcode/run-credential.js.map +1 -0
  165. package/dist/humain/hcode/sandbox.d.ts +6 -0
  166. package/dist/humain/hcode/sandbox.d.ts.map +1 -0
  167. package/dist/humain/hcode/sandbox.js +139 -0
  168. package/dist/humain/hcode/sandbox.js.map +1 -0
  169. package/dist/humain/hcode/selection.d.ts +7 -2
  170. package/dist/humain/hcode/selection.d.ts.map +1 -1
  171. package/dist/humain/hcode/selection.js +29 -5
  172. package/dist/humain/hcode/selection.js.map +1 -1
  173. package/dist/humain/hcode/transport.d.ts +3 -2
  174. package/dist/humain/hcode/transport.d.ts.map +1 -1
  175. package/dist/humain/hcode/transport.js +22 -7
  176. package/dist/humain/hcode/transport.js.map +1 -1
  177. package/dist/humain/remote/broker.d.ts +84 -0
  178. package/dist/humain/remote/broker.d.ts.map +1 -0
  179. package/dist/humain/remote/broker.js +427 -0
  180. package/dist/humain/remote/broker.js.map +1 -0
  181. package/dist/humain/remote/deny-store.d.ts +12 -0
  182. package/dist/humain/remote/deny-store.d.ts.map +1 -0
  183. package/dist/humain/remote/deny-store.js +164 -0
  184. package/dist/humain/remote/deny-store.js.map +1 -0
  185. package/dist/humain/remote/enablement.d.ts +5 -0
  186. package/dist/humain/remote/enablement.d.ts.map +1 -0
  187. package/dist/humain/remote/enablement.js +8 -0
  188. package/dist/humain/remote/enablement.js.map +1 -0
  189. package/dist/humain/remote/environment.d.ts +11 -0
  190. package/dist/humain/remote/environment.d.ts.map +1 -0
  191. package/dist/humain/remote/environment.js +19 -0
  192. package/dist/humain/remote/environment.js.map +1 -0
  193. package/dist/humain/remote/host-watch.d.ts +21 -0
  194. package/dist/humain/remote/host-watch.d.ts.map +1 -0
  195. package/dist/humain/remote/host-watch.js +186 -0
  196. package/dist/humain/remote/host-watch.js.map +1 -0
  197. package/dist/humain/remote/ipc-posix.d.ts +5 -0
  198. package/dist/humain/remote/ipc-posix.d.ts.map +1 -0
  199. package/dist/humain/remote/ipc-posix.js +29 -0
  200. package/dist/humain/remote/ipc-posix.js.map +1 -0
  201. package/dist/humain/remote/ipc-windows.d.ts +3 -0
  202. package/dist/humain/remote/ipc-windows.d.ts.map +1 -0
  203. package/dist/humain/remote/ipc-windows.js +5 -0
  204. package/dist/humain/remote/ipc-windows.js.map +1 -0
  205. package/dist/humain/remote/ipc.d.ts +10 -0
  206. package/dist/humain/remote/ipc.d.ts.map +1 -0
  207. package/dist/humain/remote/ipc.js +19 -0
  208. package/dist/humain/remote/ipc.js.map +1 -0
  209. package/dist/humain/remote/protocol.d.ts +43 -0
  210. package/dist/humain/remote/protocol.d.ts.map +1 -0
  211. package/dist/humain/remote/protocol.js +76 -0
  212. package/dist/humain/remote/protocol.js.map +1 -0
  213. package/dist/humain/remote/relay-socket.d.ts +30 -0
  214. package/dist/humain/remote/relay-socket.d.ts.map +1 -0
  215. package/dist/humain/remote/relay-socket.js +137 -0
  216. package/dist/humain/remote/relay-socket.js.map +1 -0
  217. package/dist/humain/remote/secure-channel.d.ts +10 -0
  218. package/dist/humain/remote/secure-channel.d.ts.map +1 -0
  219. package/dist/humain/remote/secure-channel.js +5 -0
  220. package/dist/humain/remote/secure-channel.js.map +1 -0
  221. package/dist/humain/remote/terminal.d.ts +48 -0
  222. package/dist/humain/remote/terminal.d.ts.map +1 -0
  223. package/dist/humain/remote/terminal.js +119 -0
  224. package/dist/humain/remote/terminal.js.map +1 -0
  225. package/dist/humain/remote/tickets.d.ts +35 -0
  226. package/dist/humain/remote/tickets.d.ts.map +1 -0
  227. package/dist/humain/remote/tickets.js +132 -0
  228. package/dist/humain/remote/tickets.js.map +1 -0
  229. package/dist/main.d.ts +1 -1
  230. package/dist/main.d.ts.map +1 -1
  231. package/dist/main.js +13 -1
  232. package/dist/main.js.map +1 -1
  233. package/dist/modes/interactive/components/account-picker.d.ts +31 -0
  234. package/dist/modes/interactive/components/account-picker.d.ts.map +1 -0
  235. package/dist/modes/interactive/components/account-picker.js +150 -0
  236. package/dist/modes/interactive/components/account-picker.js.map +1 -0
  237. package/dist/modes/interactive/components/settings-selector.d.ts +6 -0
  238. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  239. package/dist/modes/interactive/components/settings-selector.js +26 -0
  240. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  241. package/dist/modes/interactive/components/status-indicator.d.ts +35 -1
  242. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  243. package/dist/modes/interactive/components/status-indicator.js +179 -3
  244. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  245. package/dist/modes/interactive/components/working-indicator-engine.d.ts +32 -0
  246. package/dist/modes/interactive/components/working-indicator-engine.d.ts.map +1 -0
  247. package/dist/modes/interactive/components/working-indicator-engine.js +112 -0
  248. package/dist/modes/interactive/components/working-indicator-engine.js.map +1 -0
  249. package/dist/modes/interactive/fullscreen.d.ts +13 -0
  250. package/dist/modes/interactive/fullscreen.d.ts.map +1 -0
  251. package/dist/modes/interactive/fullscreen.js +25 -0
  252. package/dist/modes/interactive/fullscreen.js.map +1 -0
  253. package/dist/modes/interactive/interactive-mode.d.ts +19 -3
  254. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  255. package/dist/modes/interactive/interactive-mode.js +341 -54
  256. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  257. package/dist/modes/interactive/oauth-account-format.d.ts +9 -0
  258. package/dist/modes/interactive/oauth-account-format.d.ts.map +1 -1
  259. package/dist/modes/interactive/oauth-account-format.js +31 -22
  260. package/dist/modes/interactive/oauth-account-format.js.map +1 -1
  261. package/dist/modes/interactive/theme/humain-dark.json +5 -4
  262. package/dist/modes/interactive/theme/humain-light.json +6 -5
  263. package/docs/cli.md +1 -1
  264. package/docs/development.md +7 -0
  265. package/docs/forge-run-bootstrap.md +46 -0
  266. package/docs/humain-code.md +2 -2
  267. package/docs/index.md +2 -1
  268. package/docs/keybindings.md +10 -0
  269. package/docs/providers.md +16 -6
  270. package/docs/quickstart.md +16 -2
  271. package/docs/settings.md +20 -0
  272. package/docs/slash-commands.md +4 -2
  273. package/docs/usage.md +2 -0
  274. package/npm-shrinkwrap.json +2 -2
  275. package/package.json +1 -1
  276. package/schemas/keybindings.schema.json +12 -0
  277. package/schemas/settings.schema.json +29 -0
  278. package/dist/bundle/chunks/chunk-IXQYPQRQ.js +0 -2079
  279. package/dist/bundle/chunks/chunk-J5TSAJGC.js +0 -22
  280. package/dist/bundle/chunks/chunk-YPZPCHNV.js +0 -3
  281. package/dist/bundle/chunks/interactive-mode-MVZOJ5OU.js +0 -5
@@ -168,7 +168,8 @@ throw timedOut??error}finally{clearTimeout(timer)}if(timedOut)throw timedOut;res
168
168
  let bunInit={timeout:!1,...init};if(timeoutMs===0)return bunFetch(input,bunInit);let controller=new AbortController,callerSignal=init?.signal??(input instanceof Request?input.signal:void 0);bunInit.signal=callerSignal?AbortSignal.any([callerSignal,controller.signal]):controller.signal;let timer=setTimeout(()=>controller.abort(idleTimeoutError(timeoutMs)),timeoutMs),response;try{response=await bunFetch(input,bunInit)}finally{clearTimeout(timer)}return!response.body||NULL_BODY_STATUSES.has(response.
169
169
  status)?response:withBodyIdleTimeout(response,controller,timeoutMs)};Object.defineProperty(idleTimeoutFetch,Symbol.for("pi-ai.runtimeFetchWrapper"),{value:bunFetch});let preconnect=bunFetch.preconnect;return typeof preconnect=="function"&&Object.assign(idleTimeoutFetch,{preconnect:preconnect.bind(bunFetch)}),idleTimeoutFetch}function configureBunFetch(timeoutMs){let current=globalThis.fetch;if(!(current!==originalGlobalFetch&&current!==installedGlobalFetch)){if(timeoutMs===DEFAULT_HTTP_IDLE_TIMEOUT_MS){
170
170
  globalThis.fetch=originalGlobalFetch,installedGlobalFetch=void 0;return}installedGlobalFetch=createBunIdleTimeoutFetch(originalGlobalFetch,timeoutMs),globalThis.fetch=installedGlobalFetch}}function configureHttpDispatcher(timeoutMs=DEFAULT_HTTP_IDLE_TIMEOUT_MS){let normalizedTimeoutMs=parseHttpIdleTimeoutMs(timeoutMs);if(normalizedTimeoutMs===void 0)throw new Error(`Invalid HTTP idle timeout: ${String(timeoutMs)}`);if(isBunRuntime){configureBunFetch(normalizedTimeoutMs);return}let dispatcher=withUndiciErrorListener(
171
- new undici.EnvHttpProxyAgent({allowH2:!1,proxyTunnel:!0,bodyTimeout:normalizedTimeoutMs,connect:{autoSelectFamilyAttemptTimeout:DEFAULT_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT_MS},headersTimeout:normalizedTimeoutMs,clientFactory:createUndiciClient,factory:createUndiciOriginDispatcher}));undici.setGlobalDispatcher(dispatcher),(installedGlobalFetch===void 0?globalThis.fetch===originalGlobalFetch:globalThis.fetch===installedGlobalFetch)&&(undici.install?.(),installedGlobalFetch=globalThis.fetch)}var import_proper_lockfile=__toESM(require_proper_lockfile(),1);import{randomUUID}from"crypto";import{closeSync,existsSync,fchmodSync,fchownSync,fstatSync,fsyncSync,mkdirSync,openSync,readFileSync,realpathSync,renameSync,rmSync,writeFileSync}from"fs";import{dirname,join}from"path";var CACHE_WARMING_MODES=["off","streaming","idle"],COMPACTION_SETTING_RANGES={reserveTokens:{min:0,max:Number.MAX_SAFE_INTEGER},keepRecentTokens:{min:0,max:Number.MAX_SAFE_INTEGER},thresholdPercent:{min:1,max:100},summaryMaxTokens:{min:1,max:Number.MAX_SAFE_INTEGER}},KEEP_RECENT_WINDOW_PERCENT=5;function isMergeableObject(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}function deepMergeObjects(base,overrides){let result={...base};for(let key of Object.keys(overrides)){
171
+ new undici.EnvHttpProxyAgent({allowH2:!1,proxyTunnel:!0,bodyTimeout:normalizedTimeoutMs,connect:{autoSelectFamilyAttemptTimeout:DEFAULT_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT_MS},headersTimeout:normalizedTimeoutMs,clientFactory:createUndiciClient,factory:createUndiciOriginDispatcher}));undici.setGlobalDispatcher(dispatcher),(installedGlobalFetch===void 0?globalThis.fetch===originalGlobalFetch:globalThis.fetch===installedGlobalFetch)&&(undici.install?.(),installedGlobalFetch=globalThis.fetch)}var ENVIRONMENTS=Object.freeze({dev:Object.freeze({id:"dev",origin:"https://code.dev.humain.com",inferenceBaseUrl:"https://code.dev.humain.com/api/inference"}),staging:Object.freeze({id:"staging",origin:"https://code.stg.humain.com",inferenceBaseUrl:"https://code.stg.humain.com/api/inference"}),production:Object.freeze({id:"production",origin:"https://code.humain.com",inferenceBaseUrl:"https://code.humain.com/api/inference"})});function resolveHcodeEnvironment(value="production"){if(value==="stg")
172
+ return ENVIRONMENTS.staging;if(value==="prod")return ENVIRONMENTS.production;if(value!=="dev"&&value!=="staging"&&value!=="production")throw new Error("Invalid --env. Choose dev, staging, or production.");return ENVIRONMENTS[value]}function hcodeDisplayName(environmentId){return environmentId==="dev"?"HUMAIN Code (Dev)":environmentId==="staging"?"HUMAIN Code (Staging)":"HUMAIN Code"}var import_proper_lockfile=__toESM(require_proper_lockfile(),1);import{randomUUID}from"crypto";import{closeSync,existsSync,fchmodSync,fchownSync,fstatSync,fsyncSync,mkdirSync,openSync,readFileSync,realpathSync,renameSync,rmSync,writeFileSync}from"fs";import{dirname,join}from"path";var CACHE_WARMING_MODES=["off","streaming","idle"],COMPACTION_SETTING_RANGES={reserveTokens:{min:0,max:Number.MAX_SAFE_INTEGER},keepRecentTokens:{min:0,max:Number.MAX_SAFE_INTEGER},thresholdPercent:{min:1,max:100},summaryMaxTokens:{min:1,max:Number.MAX_SAFE_INTEGER}},KEEP_RECENT_WINDOW_PERCENT=5;function isMergeableObject(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}function deepMergeObjects(base,overrides){let result={...base};for(let key of Object.keys(overrides)){
172
173
  let overrideValue=overrides[key];if(overrideValue===void 0)continue;let baseValue=base[key];result[key]=isMergeableObject(baseValue)&&isMergeableObject(overrideValue)?deepMergeObjects(baseValue,overrideValue):overrideValue}return result}var DEFAULT_TOOL_NAMES=["read","bash","jobs","edit","write","subagent"];function isToolModifier(entry){return typeof entry=="string"&&(entry.startsWith("+")||entry.startsWith("-"))}function getToolListError(entries){let modifiers=entries.filter(isToolModifier);if(modifiers.
173
174
  length===0)return;if(modifiers.length<entries.length)return"tool names cannot be mixed with +name or -name entries";let pattern=modifiers.find(entry=>entry.includes("*"));if(pattern)return`+name and -name entries take exact tool names, not patterns: ${pattern}`}function applyToolModifiers(base,entries){let tools=[...base];for(let entry of entries){if(!isToolModifier(entry))continue;let name=entry.slice(1),index=tools.indexOf(name);entry.startsWith("+")&&index===-1&&name?tools.push(name):entry.startsWith(
174
175
  "-")&&index!==-1&&tools.splice(index,1)}return tools}function mergeDefaultTools(base,overrides){return overrides===void 0?base:!Array.isArray(base)||!Array.isArray(overrides)||!overrides.every(isToolModifier)?overrides:[...base,...overrides]}function resolveDefaultTools(entries){let plain=entries.filter(entry=>!isToolModifier(entry));return applyToolModifiers(plain.length>0||entries.length===0?plain:DEFAULT_TOOL_NAMES,entries)}function deepMergeSettings(base,overrides){let merged=deepMergeObjects(
@@ -196,47 +197,48 @@ parsed))throw new Error("Invalid settings object");let currentFileSettings=_Sett
196
197
  for(let nestedKey of nestedModified)if(field==="oauthAccounts"&&nestedKey==="providers"){let providers=isMergeableObject(baseNested.providers)?{...baseNested.providers}:{};for(let[provider,policy]of Object.entries(snapshotSettings.oauthAccounts?.providers??{}))providers[provider]={...isMergeableObject(providers[provider])?providers[provider]:{},...policy};mergedNested.providers=providers}else mergedNested[nestedKey]=inMemoryNested[nestedKey];mergedSettings[field]=mergedNested}else mergedSettings[field]=
197
198
  value}return JSON.stringify(mergedSettings,null,2)},{write:!0})}save(){if(this.settings=deepMergeSettings(this.globalSettings,this.projectSettings),this.globalSettingsLoadError)return;let snapshotGlobalSettings=structuredClone(this.globalSettings),modifiedFields=new Set(this.modifiedFields),modifiedNestedFields=this.cloneModifiedNestedFields(this.modifiedNestedFields);this.enqueueWrite("global",()=>{this.persistScopedSettings("global",snapshotGlobalSettings,modifiedFields,modifiedNestedFields)})}saveProjectSettings(settings){
198
199
  if(this.assertProjectTrustedForWrite(),this.projectSettings=structuredClone(settings),this.settings=deepMergeSettings(this.globalSettings,this.projectSettings),this.projectSettingsLoadError)return;let snapshotProjectSettings=structuredClone(this.projectSettings),modifiedFields=new Set(this.modifiedProjectFields),modifiedNestedFields=this.cloneModifiedNestedFields(this.modifiedProjectNestedFields);this.enqueueWrite("project",()=>{this.persistScopedSettings("project",snapshotProjectSettings,modifiedFields,
199
- modifiedNestedFields)})}updateProjectSettings(field,update){this.assertProjectTrustedForWrite();let projectSettings=structuredClone(this.projectSettings);update(projectSettings),this.markProjectModified(field),this.saveProjectSettings(projectSettings)}async flush(){await this.writeQueue}drainErrors(){let drained=[...this.errors];return this.errors=[],drained}getLastChangelogVersion(){return this.settings.lastChangelogVersion}setLastChangelogVersion(version){this.globalSettings.lastChangelogVersion=
200
- version,this.markModified("lastChangelogVersion"),this.save()}getExtensionChangelogVersion(key){return this.settings.extensionChangelogVersions?.[key]}setExtensionChangelogVersion(key,version){this.globalSettings.extensionChangelogVersions={...this.globalSettings.extensionChangelogVersions??{},[key]:version},this.markModified("extensionChangelogVersions",key),this.save()}getSessionDir(){let sessionDir=this.settings.sessionDir;return sessionDir&&normalizePath(sessionDir)}getDefaultProvider(){return this.
201
- settings.defaultProvider}getDefaultModel(){return this.settings.defaultModel}setDefaultProvider(provider){this.globalSettings.defaultProvider=provider,this.markModified("defaultProvider"),this.save()}setDefaultModel(modelId){this.globalSettings.defaultModel=modelId,this.markModified("defaultModel"),this.save()}setDefaultModelAndProvider(provider,modelId){this.globalSettings.defaultProvider=provider,this.globalSettings.defaultModel=modelId,this.markModified("defaultProvider"),this.markModified("d\
202
- efaultModel"),this.save()}getModelProfiles(){return this.settings.modelProfiles??[]}setModelProfiles(profiles){this.globalSettings.modelProfiles=structuredClone(profiles),this.markModified("modelProfiles"),this.save()}getSteeringMode(){return this.settings.steeringMode||SETTINGS_DEFAULTS.steeringMode}setSteeringMode(mode){this.globalSettings.steeringMode=mode,this.markModified("steeringMode"),this.save()}getFollowUpMode(){return this.settings.followUpMode||SETTINGS_DEFAULTS.followUpMode}setFollowUpMode(mode){
203
- this.globalSettings.followUpMode=mode,this.markModified("followUpMode"),this.save()}getThemeSetting(){let value=this.settings.theme;if(typeof value=="string")return value}getTheme(){let theme=this.getThemeSetting();return theme?.includes("/")?void 0:theme}setTheme(theme){this.globalSettings.theme=theme,this.markModified("theme"),this.save()}getDefaultThinkingLevel(){return this.settings.defaultThinkingLevel}setDefaultThinkingLevel(level){this.globalSettings.defaultThinkingLevel=level,this.markModified(
204
- "defaultThinkingLevel"),this.save()}getModelThinkingLevel(provider,modelId){return this.settings.modelThinkingLevels?.[`${provider}/${modelId}`]}getAllModelThinkingLevels(){return{...this.settings.modelThinkingLevels??{}}}setModelThinkingLevel(provider,modelId,level){this.globalSettings.modelThinkingLevels||(this.globalSettings.modelThinkingLevels={}),this.globalSettings.modelThinkingLevels[`${provider}/${modelId}`]=level,this.markModified("modelThinkingLevels"),this.save()}removeModelThinkingLevel(provider,modelId){
205
- this.globalSettings.modelThinkingLevels&&(delete this.globalSettings.modelThinkingLevels[`${provider}/${modelId}`],Object.keys(this.globalSettings.modelThinkingLevels).length===0&&delete this.globalSettings.modelThinkingLevels,this.markModified("modelThinkingLevels"),this.save())}getTransport(){return this.settings.transport??SETTINGS_DEFAULTS.transport}setTransport(transport){this.globalSettings.transport=transport,this.markModified("transport"),this.save()}getAutoSessionNamerEnabled(){return this.
206
- settings.autoSessionNamer?.enabled!==!1}setAutoSessionNamerEnabled(enabled){this.globalSettings.autoSessionNamer={...this.globalSettings.autoSessionNamer,enabled},this.markModified("autoSessionNamer","enabled"),this.save()}getAutoEffortEnabled(){return this.settings.autoEffort?.enabled===!0}setAutoEffortEnabled(enabled){this.globalSettings.autoEffort={...this.globalSettings.autoEffort,enabled},this.markModified("autoEffort","enabled"),this.save()}getSessionShareDestination(){let destination=this.
207
- settings.sessionShareDestination;return destination==="gist"||destination==="radius"?destination:SETTINGS_DEFAULTS.sessionShareDestination}setSessionShareDestination(destination){this.globalSettings.sessionShareDestination=destination,this.markModified("sessionShareDestination"),this.save()}getCompactionEnabled(){return this.settings.compaction?.enabled??SETTINGS_DEFAULTS.compaction.enabled}setCompactionEnabled(enabled){this.globalSettings.compaction||(this.globalSettings.compaction={}),this.globalSettings.
208
- compaction.enabled=enabled,this.markModified("compaction","enabled"),this.save()}getExplicitCompactionSetting(field,model){let{min,max}=COMPACTION_SETTING_RANGES[field],range2=min===0&&max===Number.MAX_SAFE_INTEGER?"a non-negative safe integer":`an integer from ${min} to ${max}`,isValid=value=>typeof value=="number"&&Number.isSafeInteger(value)&&value>=min&&value<=max,compaction=this.settings.compaction,ordinary=compaction?.[field];if(ordinary!==void 0&&!isValid(ordinary))throw new Error(`Invali\
209
- d compaction.${field} setting: ${String(ordinary)}. Expected ${range2}.`);let modelKey=model?`${model.provider}/${model.id}`:void 0,entry=modelKey!==void 0?compaction?.modelOverrides?.[modelKey]:void 0;if(entry!==void 0&&!isMergeableObject(entry))throw new Error(`Invalid compaction.modelOverrides["${modelKey}"] setting: ${String(entry)}. Expected an object.`);let override=entry?.[field];if(override!==void 0&&!isValid(override))throw new Error(`Invalid compaction.modelOverrides["${modelKey}"].${field}\
210
- setting: ${String(override)}. Expected ${range2}.`);return override??ordinary}getCompactionReserveTokens(model){return this.getExplicitCompactionSetting("reserveTokens",model)??SETTINGS_DEFAULTS.compaction.reserveTokens}getCompactionKeepRecentTokens(model,contextWindow=model?.contextWindow??0){return this.getExplicitCompactionSetting("keepRecentTokens",model)??Math.max(SETTINGS_DEFAULTS.compaction.keepRecentTokens,Math.floor(Math.max(contextWindow,0)*KEEP_RECENT_WINDOW_PERCENT/100))}getCompactionSettings(model,contextWindow=model?.
211
- contextWindow??0){let explicitReserveTokens=this.getExplicitCompactionSetting("reserveTokens",model),thresholdPercent=this.getExplicitCompactionSetting("thresholdPercent",model)??(explicitReserveTokens===void 0?SETTINGS_DEFAULTS.compaction.thresholdPercent:void 0),summaryMaxTokens=this.getExplicitCompactionSetting("summaryMaxTokens",model);return{enabled:this.getCompactionEnabled(),reserveTokens:explicitReserveTokens??SETTINGS_DEFAULTS.compaction.reserveTokens,keepRecentTokens:this.getCompactionKeepRecentTokens(
212
- model,contextWindow),...thresholdPercent===void 0?{}:{thresholdPercent},...summaryMaxTokens===void 0?{}:{summaryMaxTokens},...explicitReserveTokens===void 0&&summaryMaxTokens===void 0?{scaleSummaryWithContextWindow:!0}:{}}}getBranchSummarySettings(){return{reserveTokens:this.settings.branchSummary?.reserveTokens??SETTINGS_DEFAULTS.branchSummary.reserveTokens,skipPrompt:this.settings.branchSummary?.skipPrompt??SETTINGS_DEFAULTS.branchSummary.skipPrompt}}getBranchSummarySkipPrompt(){return this.settings.
213
- branchSummary?.skipPrompt??SETTINGS_DEFAULTS.branchSummary.skipPrompt}getRetryEnabled(){return this.settings.retry?.enabled??SETTINGS_DEFAULTS.retry.enabled}setRetryEnabled(enabled){this.globalSettings.retry||(this.globalSettings.retry={}),this.globalSettings.retry.enabled=enabled,this.markModified("retry","enabled"),this.save()}getRetrySettings(){return{enabled:this.getRetryEnabled(),maxRetries:this.settings.retry?.maxRetries??SETTINGS_DEFAULTS.retry.maxRetries,baseDelayMs:this.settings.retry?.
214
- baseDelayMs??SETTINGS_DEFAULTS.retry.baseDelayMs,maxAgentDelayMs:this.settings.retry?.maxAgentDelayMs??SETTINGS_DEFAULTS.retry.maxAgentDelayMs}}getOAuthAccountsAutoSwitch(providerId){let providers=this.settings.oauthAccounts?.providers,override=providerId&&providers&&Object.hasOwn(providers,providerId)?providers[providerId]?.autoSwitch:void 0,value=override===void 0?this.settings.oauthAccounts?.autoSwitch:override;return value===void 0?!0:value===!0}getOAuthAccountApiKeyFallback(providerId){let providers=this.
215
- globalSettings.oauthAccounts?.providers,key=providers&&Object.hasOwn(providers,providerId)?providers[providerId]?.apiKeyFallback:void 0;return typeof key=="string"&&key.trim()&&key.length<=320&&!/[\p{Cc}\p{Cf}]/u.test(key)&&!(key in Object.prototype)?key:void 0}readOAuthAccountActivationPolicy(providerId){let loaded=_SettingsManager.tryLoadFromStorage(this.storage,"global");if(loaded.error)throw this.recordError("global",loaded.error),new Error("Could not read account policy");let accounts=loaded.
216
- settings.oauthAccounts,stored=accounts?.providers&&Object.hasOwn(accounts.providers,providerId)?accounts.providers[providerId]:void 0,flag=stored?.autoSwitch===void 0?accounts?.autoSwitch:stored.autoSwitch,autoSwitch=(flag===void 0||flag===!0)&&this.getOAuthAccountsAutoSwitch(providerId),apiKeyFallback=this.getOAuthAccountApiKeyFallback(providerId);stored?.apiKeyFallback!==apiKeyFallback&&(apiKeyFallback=void 0);for(let pending of this.pendingAccountPolicies)pending.providerId===providerId&&(pending.
217
- policy.autoSwitch===!1&&(autoSwitch=!1),Object.hasOwn(pending.policy,"apiKeyFallback")&&pending.policy.apiKeyFallback!==apiKeyFallback&&(apiKeyFallback=void 0));return{autoSwitch,apiKeyFallback}}setOAuthAccountProviderPolicy(providerId,policy){if(!providerId.trim()||providerId in Object.prototype||/[\p{Cc}\p{Cf}]/u.test(providerId))throw new Error("Invalid account policy provider");if(policy.autoSwitch!==void 0&&typeof policy.autoSwitch!="boolean")throw new Error("Invalid account auto-switch pol\
218
- icy");let key=policy.apiKeyFallback;if(key!=null&&(typeof key!="string"||!key.trim()||key.length>320||/[\p{Cc}\p{Cf}]/u.test(key)||key in Object.prototype))throw new Error("Invalid account fallback target");if(this.globalSettingsLoadError)throw new Error("Could not save account policy");let changes={...Object.hasOwn(policy,"autoSwitch")?{autoSwitch:policy.autoSwitch}:{},...Object.hasOwn(policy,"apiKeyFallback")?{apiKeyFallback:policy.apiKeyFallback}:{}},snapshot={oauthAccounts:{providers:{[providerId]:changes}}},
219
- pending={providerId,policy:changes};return this.pendingAccountPolicies.add(pending),this.enqueueWrite("global",()=>{this.globalSettings.oauthAccounts??={};let accounts=this.globalSettings.oauthAccounts;accounts.providers??={};let providers=accounts.providers,previous=providers[providerId];providers[providerId]={...previous,...changes};try{this.persistScopedSettings("global",snapshot,new Set(["oauthAccounts"]),new Map([["oauthAccounts",new Set(["providers"])]]))}catch(error){let stored=_SettingsManager.
220
- tryLoadFromStorage(this.storage,"global"),restored=stored.error?previous:stored.settings.oauthAccounts?.providers?.[providerId];throw restored===void 0?delete providers[providerId]:providers[providerId]=restored,error}finally{this.settings=deepMergeSettings(this.globalSettings,this.projectSettings)}},!1).then(failure=>{if(failure)throw new Error("Could not save account policy")}).finally(()=>{this.pendingAccountPolicies.delete(pending)})}getExplicitNoProgressTimeoutMs(){let value=this.settings.noProgressTimeoutMs;
221
- return value===void 0?void 0:validateNoProgressTimeoutMs(value)}getNoProgressTimeoutMs(){return this.getExplicitNoProgressTimeoutMs()??SETTINGS_DEFAULTS.noProgressTimeoutMs}setNoProgressTimeoutMs(timeoutMs){this.globalSettings.noProgressTimeoutMs=validateNoProgressTimeoutMs(timeoutMs),this.markModified("noProgressTimeoutMs"),this.save()}getHttpIdleTimeoutMs(){return parseTimeoutSetting(this.settings.httpIdleTimeoutMs,"httpIdleTimeoutMs")??DEFAULT_HTTP_IDLE_TIMEOUT_MS}setHttpIdleTimeoutMs(timeoutMs){
222
- if(!Number.isFinite(timeoutMs)||timeoutMs<0)throw new Error(`Invalid httpIdleTimeoutMs setting: ${String(timeoutMs)}`);this.globalSettings.httpIdleTimeoutMs=Math.floor(timeoutMs),this.markModified("httpIdleTimeoutMs"),this.save()}getCacheWarmingMode(){let mode=this.globalSettings.cacheWarming;return mode!==void 0&&CACHE_WARMING_MODES.includes(mode)?mode:SETTINGS_DEFAULTS.cacheWarming}setCacheWarmingMode(mode){this.globalSettings.cacheWarming=mode,this.markModified("cacheWarming"),this.save()}getProviderRetrySettings(){
223
- return{timeoutMs:this.settings.retry?.provider?.timeoutMs,maxRetries:this.settings.retry?.provider?.maxRetries,maxRetryDelayMs:this.settings.retry?.provider?.maxRetryDelayMs??SETTINGS_DEFAULTS.retry.provider.maxRetryDelayMs}}getWebSocketConnectTimeoutMs(){return parseTimeoutSetting(this.settings.websocketConnectTimeoutMs,"websocketConnectTimeoutMs")}getHideThinkingBlock(){return this.settings.hideThinkingBlock??SETTINGS_DEFAULTS.hideThinkingBlock}getShowCacheMissNotices(){return this.settings.showCacheMissNotices??
224
- SETTINGS_DEFAULTS.showCacheMissNotices}getExternalEditorCommand(){let configuredEditor=this.settings.externalEditor;if(typeof configuredEditor=="string"&&configuredEditor.trim()!=="")return configuredEditor;let environmentEditor=process.env.VISUAL||process.env.EDITOR;return environmentEditor||(process.platform==="win32"?"notepad":"nano")}setHideThinkingBlock(hide){this.globalSettings.hideThinkingBlock=hide,this.markModified("hideThinkingBlock"),this.save()}setShowCacheMissNotices(show2){this.globalSettings.
225
- showCacheMissNotices=show2,this.markModified("showCacheMissNotices"),this.save()}getShellPath(){let shellPath=this.settings.shellPath;return shellPath&&normalizePath(shellPath)}setShellPath(path2){this.globalSettings.shellPath=path2,this.markModified("shellPath"),this.save()}getQuietStartup(){let value=this.settings.quietStartup;return value===!0||value==="header"?value:SETTINGS_DEFAULTS.quietStartup}getAgentMonitorEnabled(){return this.settings.agentMonitor?.enabled!==!1}getCoordinationEnabled(){
226
- return this.settings.coordination?.enabled!==!1}getCoordinationPeerWakeLimit(){let limit=this.settings.coordination?.peerWakeLimit;return typeof limit!="number"||!Number.isFinite(limit)?6:Math.min(60,Math.max(0,Math.floor(limit)))}setQuietStartup(quiet){this.globalSettings.quietStartup=quiet,this.markModified("quietStartup"),this.save()}getDefaultProjectTrust(){let value=this.globalSettings.defaultProjectTrust;return value==="always"||value==="never"?value:SETTINGS_DEFAULTS.defaultProjectTrust}setDefaultProjectTrust(defaultProjectTrust){
227
- this.globalSettings.defaultProjectTrust=defaultProjectTrust,this.markModified("defaultProjectTrust"),this.save()}getBashOutputHeadTail(){let value=this.settings.bashOutputHeadTail;return typeof value=="boolean"?value:SETTINGS_DEFAULTS.bashOutputHeadTail}getBashOutputCleanup(){let value=this.settings.bashOutputCleanup;return typeof value=="boolean"?value:SETTINGS_DEFAULTS.bashOutputCleanup}getShellCommandPrefix(){return this.settings.shellCommandPrefix}setShellCommandPrefix(prefix2){this.globalSettings.
228
- shellCommandPrefix=prefix2,this.markModified("shellCommandPrefix"),this.save()}getNpmCommand(){return this.settings.npmCommand?[...this.settings.npmCommand]:void 0}setNpmCommand(command){this.globalSettings.npmCommand=command?[...command]:void 0,this.markModified("npmCommand"),this.save()}getCollapseChangelog(){return this.settings.collapseChangelog??SETTINGS_DEFAULTS.collapseChangelog}setCollapseChangelog(collapse){this.globalSettings.collapseChangelog=collapse,this.markModified("collapseChange\
229
- log"),this.save()}getEnableInstallTelemetry(){return this.settings.enableInstallTelemetry??SETTINGS_DEFAULTS.enableInstallTelemetry}setEnableInstallTelemetry(enabled){this.globalSettings.enableInstallTelemetry=enabled,this.markModified("enableInstallTelemetry"),this.save()}getHcodeMetadataDisclosureVersion(){return this.globalSettings.hcodeMetadataDisclosureVersion===1?1:void 0}async acknowledgeHcodeMetadataDisclosure(theme){if(this.globalSettingsLoadError)throw new Error("Could not save metadat\
230
- a disclosure acknowledgment");let snapshot={hcodeMetadataDisclosureVersion:1},fields=new Set(["hcodeMetadataDisclosureVersion"]);if(theme!==void 0&&(snapshot.theme=theme,fields.add("theme")),await this.enqueueWrite("global",()=>{this.persistScopedSettings("global",snapshot,fields,new Map),Object.assign(this.globalSettings,snapshot),this.settings=deepMergeSettings(this.globalSettings,this.projectSettings)},!1))throw new Error("Could not save metadata disclosure acknowledgment")}async acknowledgeHcodeMetadataDisclosureAfterNotice(notice){
231
- let snapshot={hcodeMetadataDisclosureVersion:1};if(await this.enqueueWrite("global",()=>{this.persistScopedSettings("global",snapshot,new Set(["hcodeMetadataDisclosureVersion"]),new Map,stored=>stored.hcodeMetadataDisclosureVersion===1?!1:(notice(),!0)),Object.assign(this.globalSettings,snapshot),this.settings=deepMergeSettings(this.globalSettings,this.projectSettings)},!1))throw new Error("Could not save metadata disclosure acknowledgment")}getOrCreateDeviceId(){return this.globalSettings.deviceId||
232
- (this.globalSettings.deviceId=randomUUID(),this.markModified("deviceId"),this.save()),this.globalSettings.deviceId}getPackages(){return[...this.settings.packages??[]]}setPackages(packages){this.globalSettings.packages=packages,this.markModified("packages"),this.save()}setProjectPackages(packages){this.updateProjectSettings("packages",settings=>{settings.packages=packages})}getExtensionPaths(){return[...this.settings.extensions??[]]}setExtensionPaths(paths){this.globalSettings.extensions=paths,this.
233
- markModified("extensions"),this.save()}setProjectExtensionPaths(paths){this.updateProjectSettings("extensions",settings=>{settings.extensions=paths})}getSkillPaths(){return[...this.settings.skills??[]]}setSkillPaths(paths){this.globalSettings.skills=paths,this.markModified("skills"),this.save()}setProjectSkillPaths(paths){this.updateProjectSettings("skills",settings=>{settings.skills=paths})}getPromptTemplatePaths(){return[...this.settings.prompts??[]]}setPromptTemplatePaths(paths){this.globalSettings.
234
- prompts=paths,this.markModified("prompts"),this.save()}setProjectPromptTemplatePaths(paths){this.updateProjectSettings("prompts",settings=>{settings.prompts=paths})}getThemePaths(){return[...this.settings.themes??[]]}setThemePaths(paths){this.globalSettings.themes=paths,this.markModified("themes"),this.save()}setProjectThemePaths(paths){this.updateProjectSettings("themes",settings=>{settings.themes=paths})}getEnableSkillCommands(){return this.settings.enableSkillCommands??SETTINGS_DEFAULTS.enableSkillCommands}setEnableSkillCommands(enabled){
235
- this.globalSettings.enableSkillCommands=enabled,this.markModified("enableSkillCommands"),this.save()}getThinkingBudgets(){return this.settings.thinkingBudgets}getTerminalCapabilityOverrides(){let terminal=this.settings.terminal,images=terminal?.images;return{...images==="kitty"||images==="iterm2"?{images}:images===!1?{images:null}:{},...typeof terminal?.trueColor=="boolean"?{trueColor:terminal.trueColor}:{},...typeof terminal?.hyperlinks=="boolean"?{hyperlinks:terminal.hyperlinks}:{}}}getShowImages(){
236
- return this.settings.terminal?.showImages??SETTINGS_DEFAULTS.terminal.showImages}setShowImages(show2){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showImages=show2,this.markModified("terminal","showImages"),this.save()}getImageWidthCells(){let width=this.settings.terminal?.imageWidthCells;return typeof width!="number"||!Number.isFinite(width)?SETTINGS_DEFAULTS.terminal.imageWidthCells:Math.max(1,Math.floor(width))}setImageWidthCells(width){this.globalSettings.
237
- terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.imageWidthCells=Math.max(1,Math.floor(width)),this.markModified("terminal","imageWidthCells"),this.save()}getClearOnShrink(){return this.settings.terminal?.clearOnShrink!==void 0?this.settings.terminal.clearOnShrink:process.env.PI_CLEAR_ON_SHRINK==="1"?!0:SETTINGS_DEFAULTS.terminal.clearOnShrink}setClearOnShrink(enabled){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.clearOnShrink=
238
- enabled,this.markModified("terminal","clearOnShrink"),this.save()}getShowTerminalProgress(){return this.settings.terminal?.showTerminalProgress??SETTINGS_DEFAULTS.terminal.showTerminalProgress}setShowTerminalProgress(enabled){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showTerminalProgress=enabled,this.markModified("terminal","showTerminalProgress"),this.save()}getTuiMode(){return this.settings.tuiMode==="regular"?"regular":SETTINGS_DEFAULTS.tuiMode}setTuiMode(mode){
239
- this.globalSettings.tuiMode=mode,this.markModified("tuiMode"),this.save()}getFullscreenExitOutput(){return this.settings.fullscreenExitOutput==="resume-hint"?"resume-hint":SETTINGS_DEFAULTS.fullscreenExitOutput}setFullscreenExitOutput(output){this.globalSettings.fullscreenExitOutput=output,this.markModified("fullscreenExitOutput"),this.save()}getFullscreenScrollbar(){let mode=this.settings.fullscreenScrollbar;return mode==="always"||mode==="hidden"?mode:SETTINGS_DEFAULTS.fullscreenScrollbar}setFullscreenScrollbar(mode){
200
+ modifiedNestedFields)})}updateProjectSettings(field,update){this.assertProjectTrustedForWrite();let projectSettings=structuredClone(this.projectSettings);update(projectSettings),this.markProjectModified(field),this.saveProjectSettings(projectSettings)}async flush(){await this.writeQueue}drainErrors(){let drained=[...this.errors];return this.errors=[],drained}getWorkingIndicator(){let value=this.settings.workingIndicator;return value==="classic"||value==="life"||value==="rain"||value==="decode"?value:
201
+ "rotate"}setWorkingIndicator(value){this.globalSettings.workingIndicator=value,this.markModified("workingIndicator"),this.save()}getReducedMotion(){return this.settings.reducedMotion===!0}setReducedMotion(value){this.globalSettings.reducedMotion=value,this.markModified("reducedMotion"),this.save()}getLastChangelogVersion(){return this.settings.lastChangelogVersion}setLastChangelogVersion(version){this.globalSettings.lastChangelogVersion=version,this.markModified("lastChangelogVersion"),this.save()}getExtensionChangelogVersion(key){
202
+ return this.settings.extensionChangelogVersions?.[key]}setExtensionChangelogVersion(key,version){this.globalSettings.extensionChangelogVersions={...this.globalSettings.extensionChangelogVersions??{},[key]:version},this.markModified("extensionChangelogVersions",key),this.save()}getSessionDir(){let sessionDir=this.settings.sessionDir;return sessionDir&&normalizePath(sessionDir)}getDefaultProvider(){return this.settings.defaultProvider}getDefaultModel(){return this.settings.defaultModel}setDefaultProvider(provider){
203
+ this.globalSettings.defaultProvider=provider,this.markModified("defaultProvider"),this.save()}setDefaultModel(modelId){this.globalSettings.defaultModel=modelId,this.markModified("defaultModel"),this.save()}setDefaultModelAndProvider(provider,modelId){this.globalSettings.defaultProvider=provider,this.globalSettings.defaultModel=modelId,this.markModified("defaultProvider"),this.markModified("defaultModel"),this.save()}getModelProfiles(){return this.settings.modelProfiles??[]}setModelProfiles(profiles){
204
+ this.globalSettings.modelProfiles=structuredClone(profiles),this.markModified("modelProfiles"),this.save()}getSteeringMode(){return this.settings.steeringMode||SETTINGS_DEFAULTS.steeringMode}setSteeringMode(mode){this.globalSettings.steeringMode=mode,this.markModified("steeringMode"),this.save()}getFollowUpMode(){return this.settings.followUpMode||SETTINGS_DEFAULTS.followUpMode}setFollowUpMode(mode){this.globalSettings.followUpMode=mode,this.markModified("followUpMode"),this.save()}getThemeSetting(){
205
+ let value=this.settings.theme;if(typeof value=="string")return value}getTheme(){let theme=this.getThemeSetting();return theme?.includes("/")?void 0:theme}setTheme(theme){this.globalSettings.theme=theme,this.markModified("theme"),this.save()}getDefaultThinkingLevel(){return this.settings.defaultThinkingLevel}setDefaultThinkingLevel(level){this.globalSettings.defaultThinkingLevel=level,this.markModified("defaultThinkingLevel"),this.save()}getModelThinkingLevel(provider,modelId){return this.settings.
206
+ modelThinkingLevels?.[`${provider}/${modelId}`]}getAllModelThinkingLevels(){return{...this.settings.modelThinkingLevels??{}}}setModelThinkingLevel(provider,modelId,level){this.globalSettings.modelThinkingLevels||(this.globalSettings.modelThinkingLevels={}),this.globalSettings.modelThinkingLevels[`${provider}/${modelId}`]=level,this.markModified("modelThinkingLevels"),this.save()}removeModelThinkingLevel(provider,modelId){this.globalSettings.modelThinkingLevels&&(delete this.globalSettings.modelThinkingLevels[`${provider}\
207
+ /${modelId}`],Object.keys(this.globalSettings.modelThinkingLevels).length===0&&delete this.globalSettings.modelThinkingLevels,this.markModified("modelThinkingLevels"),this.save())}getTransport(){return this.settings.transport??SETTINGS_DEFAULTS.transport}setTransport(transport){this.globalSettings.transport=transport,this.markModified("transport"),this.save()}getAutoSessionNamerEnabled(){return this.settings.autoSessionNamer?.enabled!==!1}setAutoSessionNamerEnabled(enabled){this.globalSettings.autoSessionNamer=
208
+ {...this.globalSettings.autoSessionNamer,enabled},this.markModified("autoSessionNamer","enabled"),this.save()}getAutoEffortEnabled(){return this.settings.autoEffort?.enabled===!0}setAutoEffortEnabled(enabled){this.globalSettings.autoEffort={...this.globalSettings.autoEffort,enabled},this.markModified("autoEffort","enabled"),this.save()}getSessionShareDestination(){let destination=this.settings.sessionShareDestination;return destination==="gist"||destination==="radius"?destination:SETTINGS_DEFAULTS.
209
+ sessionShareDestination}setSessionShareDestination(destination){this.globalSettings.sessionShareDestination=destination,this.markModified("sessionShareDestination"),this.save()}getCompactionEnabled(){return this.settings.compaction?.enabled??SETTINGS_DEFAULTS.compaction.enabled}setCompactionEnabled(enabled){this.globalSettings.compaction||(this.globalSettings.compaction={}),this.globalSettings.compaction.enabled=enabled,this.markModified("compaction","enabled"),this.save()}getExplicitCompactionSetting(field,model){
210
+ let{min,max}=COMPACTION_SETTING_RANGES[field],range2=min===0&&max===Number.MAX_SAFE_INTEGER?"a non-negative safe integer":`an integer from ${min} to ${max}`,isValid=value=>typeof value=="number"&&Number.isSafeInteger(value)&&value>=min&&value<=max,compaction=this.settings.compaction,ordinary=compaction?.[field];if(ordinary!==void 0&&!isValid(ordinary))throw new Error(`Invalid compaction.${field} setting: ${String(ordinary)}. Expected ${range2}.`);let modelKey=model?`${model.provider}/${model.id}`:
211
+ void 0,entry=modelKey!==void 0?compaction?.modelOverrides?.[modelKey]:void 0;if(entry!==void 0&&!isMergeableObject(entry))throw new Error(`Invalid compaction.modelOverrides["${modelKey}"] setting: ${String(entry)}. Expected an object.`);let override=entry?.[field];if(override!==void 0&&!isValid(override))throw new Error(`Invalid compaction.modelOverrides["${modelKey}"].${field} setting: ${String(override)}. Expected ${range2}.`);return override??ordinary}getCompactionReserveTokens(model){return this.
212
+ getExplicitCompactionSetting("reserveTokens",model)??SETTINGS_DEFAULTS.compaction.reserveTokens}getCompactionKeepRecentTokens(model,contextWindow=model?.contextWindow??0){return this.getExplicitCompactionSetting("keepRecentTokens",model)??Math.max(SETTINGS_DEFAULTS.compaction.keepRecentTokens,Math.floor(Math.max(contextWindow,0)*KEEP_RECENT_WINDOW_PERCENT/100))}getCompactionSettings(model,contextWindow=model?.contextWindow??0){let explicitReserveTokens=this.getExplicitCompactionSetting("reserveT\
213
+ okens",model),thresholdPercent=this.getExplicitCompactionSetting("thresholdPercent",model)??(explicitReserveTokens===void 0?SETTINGS_DEFAULTS.compaction.thresholdPercent:void 0),summaryMaxTokens=this.getExplicitCompactionSetting("summaryMaxTokens",model);return{enabled:this.getCompactionEnabled(),reserveTokens:explicitReserveTokens??SETTINGS_DEFAULTS.compaction.reserveTokens,keepRecentTokens:this.getCompactionKeepRecentTokens(model,contextWindow),...thresholdPercent===void 0?{}:{thresholdPercent},
214
+ ...summaryMaxTokens===void 0?{}:{summaryMaxTokens},...explicitReserveTokens===void 0&&summaryMaxTokens===void 0?{scaleSummaryWithContextWindow:!0}:{}}}getBranchSummarySettings(){return{reserveTokens:this.settings.branchSummary?.reserveTokens??SETTINGS_DEFAULTS.branchSummary.reserveTokens,skipPrompt:this.settings.branchSummary?.skipPrompt??SETTINGS_DEFAULTS.branchSummary.skipPrompt}}getBranchSummarySkipPrompt(){return this.settings.branchSummary?.skipPrompt??SETTINGS_DEFAULTS.branchSummary.skipPrompt}getRetryEnabled(){
215
+ return this.settings.retry?.enabled??SETTINGS_DEFAULTS.retry.enabled}setRetryEnabled(enabled){this.globalSettings.retry||(this.globalSettings.retry={}),this.globalSettings.retry.enabled=enabled,this.markModified("retry","enabled"),this.save()}getRetrySettings(){return{enabled:this.getRetryEnabled(),maxRetries:this.settings.retry?.maxRetries??SETTINGS_DEFAULTS.retry.maxRetries,baseDelayMs:this.settings.retry?.baseDelayMs??SETTINGS_DEFAULTS.retry.baseDelayMs,maxAgentDelayMs:this.settings.retry?.maxAgentDelayMs??
216
+ SETTINGS_DEFAULTS.retry.maxAgentDelayMs}}getOAuthAccountsAutoSwitch(providerId){let providers=this.settings.oauthAccounts?.providers,override=providerId&&providers&&Object.hasOwn(providers,providerId)?providers[providerId]?.autoSwitch:void 0,value=override===void 0?this.settings.oauthAccounts?.autoSwitch:override;return value===void 0?!0:value===!0}getOAuthAccountApiKeyFallback(providerId){let providers=this.globalSettings.oauthAccounts?.providers,key=providers&&Object.hasOwn(providers,providerId)?
217
+ providers[providerId]?.apiKeyFallback:void 0;return typeof key=="string"&&key.trim()&&key.length<=320&&!/[\p{Cc}\p{Cf}]/u.test(key)&&!(key in Object.prototype)?key:void 0}readOAuthAccountActivationPolicy(providerId){let loaded=_SettingsManager.tryLoadFromStorage(this.storage,"global");if(loaded.error)throw this.recordError("global",loaded.error),new Error("Could not read account policy");let accounts=loaded.settings.oauthAccounts,stored=accounts?.providers&&Object.hasOwn(accounts.providers,providerId)?
218
+ accounts.providers[providerId]:void 0,flag=stored?.autoSwitch===void 0?accounts?.autoSwitch:stored.autoSwitch,autoSwitch=(flag===void 0||flag===!0)&&this.getOAuthAccountsAutoSwitch(providerId),apiKeyFallback=this.getOAuthAccountApiKeyFallback(providerId);stored?.apiKeyFallback!==apiKeyFallback&&(apiKeyFallback=void 0);for(let pending of this.pendingAccountPolicies)pending.providerId===providerId&&(pending.policy.autoSwitch===!1&&(autoSwitch=!1),Object.hasOwn(pending.policy,"apiKeyFallback")&&pending.
219
+ policy.apiKeyFallback!==apiKeyFallback&&(apiKeyFallback=void 0));return{autoSwitch,apiKeyFallback}}setOAuthAccountProviderPolicy(providerId,policy){if(!providerId.trim()||providerId in Object.prototype||/[\p{Cc}\p{Cf}]/u.test(providerId))throw new Error("Invalid account policy provider");if(policy.autoSwitch!==void 0&&typeof policy.autoSwitch!="boolean")throw new Error("Invalid account auto-switch policy");let key=policy.apiKeyFallback;if(key!=null&&(typeof key!="string"||!key.trim()||key.length>
220
+ 320||/[\p{Cc}\p{Cf}]/u.test(key)||key in Object.prototype))throw new Error("Invalid account fallback target");if(this.globalSettingsLoadError)throw new Error("Could not save account policy");let changes={...Object.hasOwn(policy,"autoSwitch")?{autoSwitch:policy.autoSwitch}:{},...Object.hasOwn(policy,"apiKeyFallback")?{apiKeyFallback:policy.apiKeyFallback}:{}},snapshot={oauthAccounts:{providers:{[providerId]:changes}}},pending={providerId,policy:changes};return this.pendingAccountPolicies.add(pending),
221
+ this.enqueueWrite("global",()=>{this.globalSettings.oauthAccounts??={};let accounts=this.globalSettings.oauthAccounts;accounts.providers??={};let providers=accounts.providers,previous=providers[providerId];providers[providerId]={...previous,...changes};try{this.persistScopedSettings("global",snapshot,new Set(["oauthAccounts"]),new Map([["oauthAccounts",new Set(["providers"])]]))}catch(error){let stored=_SettingsManager.tryLoadFromStorage(this.storage,"global"),restored=stored.error?previous:stored.
222
+ settings.oauthAccounts?.providers?.[providerId];throw restored===void 0?delete providers[providerId]:providers[providerId]=restored,error}finally{this.settings=deepMergeSettings(this.globalSettings,this.projectSettings)}},!1).then(failure=>{if(failure)throw new Error("Could not save account policy")}).finally(()=>{this.pendingAccountPolicies.delete(pending)})}getExplicitNoProgressTimeoutMs(){let value=this.settings.noProgressTimeoutMs;return value===void 0?void 0:validateNoProgressTimeoutMs(value)}getNoProgressTimeoutMs(){
223
+ return this.getExplicitNoProgressTimeoutMs()??SETTINGS_DEFAULTS.noProgressTimeoutMs}setNoProgressTimeoutMs(timeoutMs){this.globalSettings.noProgressTimeoutMs=validateNoProgressTimeoutMs(timeoutMs),this.markModified("noProgressTimeoutMs"),this.save()}getHttpIdleTimeoutMs(){return parseTimeoutSetting(this.settings.httpIdleTimeoutMs,"httpIdleTimeoutMs")??DEFAULT_HTTP_IDLE_TIMEOUT_MS}setHttpIdleTimeoutMs(timeoutMs){if(!Number.isFinite(timeoutMs)||timeoutMs<0)throw new Error(`Invalid httpIdleTimeoutM\
224
+ s setting: ${String(timeoutMs)}`);this.globalSettings.httpIdleTimeoutMs=Math.floor(timeoutMs),this.markModified("httpIdleTimeoutMs"),this.save()}getCacheWarmingMode(){let mode=this.globalSettings.cacheWarming;return mode!==void 0&&CACHE_WARMING_MODES.includes(mode)?mode:SETTINGS_DEFAULTS.cacheWarming}setCacheWarmingMode(mode){this.globalSettings.cacheWarming=mode,this.markModified("cacheWarming"),this.save()}getProviderRetrySettings(){return{timeoutMs:this.settings.retry?.provider?.timeoutMs,maxRetries:this.
225
+ settings.retry?.provider?.maxRetries,maxRetryDelayMs:this.settings.retry?.provider?.maxRetryDelayMs??SETTINGS_DEFAULTS.retry.provider.maxRetryDelayMs}}getWebSocketConnectTimeoutMs(){return parseTimeoutSetting(this.settings.websocketConnectTimeoutMs,"websocketConnectTimeoutMs")}getHideThinkingBlock(){return this.settings.hideThinkingBlock??SETTINGS_DEFAULTS.hideThinkingBlock}getShowCacheMissNotices(){return this.settings.showCacheMissNotices??SETTINGS_DEFAULTS.showCacheMissNotices}getExternalEditorCommand(){
226
+ let configuredEditor=this.settings.externalEditor;if(typeof configuredEditor=="string"&&configuredEditor.trim()!=="")return configuredEditor;let environmentEditor=process.env.VISUAL||process.env.EDITOR;return environmentEditor||(process.platform==="win32"?"notepad":"nano")}setHideThinkingBlock(hide){this.globalSettings.hideThinkingBlock=hide,this.markModified("hideThinkingBlock"),this.save()}setShowCacheMissNotices(show2){this.globalSettings.showCacheMissNotices=show2,this.markModified("showCach\
227
+ eMissNotices"),this.save()}getShellPath(){let shellPath=this.settings.shellPath;return shellPath&&normalizePath(shellPath)}setShellPath(path2){this.globalSettings.shellPath=path2,this.markModified("shellPath"),this.save()}getQuietStartup(){let value=this.settings.quietStartup;return value===!0||value==="header"?value:SETTINGS_DEFAULTS.quietStartup}getAgentMonitorEnabled(){return this.settings.agentMonitor?.enabled!==!1}getCoordinationEnabled(){return this.settings.coordination?.enabled!==!1}getCoordinationPeerWakeLimit(){
228
+ let limit=this.settings.coordination?.peerWakeLimit;return typeof limit!="number"||!Number.isFinite(limit)?6:Math.min(60,Math.max(0,Math.floor(limit)))}setQuietStartup(quiet){this.globalSettings.quietStartup=quiet,this.markModified("quietStartup"),this.save()}getDefaultProjectTrust(){let value=this.globalSettings.defaultProjectTrust;return value==="always"||value==="never"?value:SETTINGS_DEFAULTS.defaultProjectTrust}setDefaultProjectTrust(defaultProjectTrust){this.globalSettings.defaultProjectTrust=
229
+ defaultProjectTrust,this.markModified("defaultProjectTrust"),this.save()}getBashOutputHeadTail(){let value=this.settings.bashOutputHeadTail;return typeof value=="boolean"?value:SETTINGS_DEFAULTS.bashOutputHeadTail}getBashOutputCleanup(){let value=this.settings.bashOutputCleanup;return typeof value=="boolean"?value:SETTINGS_DEFAULTS.bashOutputCleanup}getShellCommandPrefix(){return this.settings.shellCommandPrefix}setShellCommandPrefix(prefix2){this.globalSettings.shellCommandPrefix=prefix2,this.markModified(
230
+ "shellCommandPrefix"),this.save()}getNpmCommand(){return this.settings.npmCommand?[...this.settings.npmCommand]:void 0}setNpmCommand(command){this.globalSettings.npmCommand=command?[...command]:void 0,this.markModified("npmCommand"),this.save()}getCollapseChangelog(){return this.settings.collapseChangelog??SETTINGS_DEFAULTS.collapseChangelog}setCollapseChangelog(collapse){this.globalSettings.collapseChangelog=collapse,this.markModified("collapseChangelog"),this.save()}getEnableInstallTelemetry(){
231
+ return this.settings.enableInstallTelemetry??SETTINGS_DEFAULTS.enableInstallTelemetry}setEnableInstallTelemetry(enabled){this.globalSettings.enableInstallTelemetry=enabled,this.markModified("enableInstallTelemetry"),this.save()}getHcodeMetadataDisclosureVersion(){return this.globalSettings.hcodeMetadataDisclosureVersion===1?1:void 0}async acknowledgeHcodeMetadataDisclosure(theme){if(this.globalSettingsLoadError)throw new Error("Could not save metadata disclosure acknowledgment");let snapshot={hcodeMetadataDisclosureVersion:1},
232
+ fields=new Set(["hcodeMetadataDisclosureVersion"]);if(theme!==void 0&&(snapshot.theme=theme,fields.add("theme")),await this.enqueueWrite("global",()=>{this.persistScopedSettings("global",snapshot,fields,new Map),Object.assign(this.globalSettings,snapshot),this.settings=deepMergeSettings(this.globalSettings,this.projectSettings)},!1))throw new Error("Could not save metadata disclosure acknowledgment")}async acknowledgeHcodeMetadataDisclosureAfterNotice(notice){let snapshot={hcodeMetadataDisclosureVersion:1};
233
+ if(await this.enqueueWrite("global",()=>{this.persistScopedSettings("global",snapshot,new Set(["hcodeMetadataDisclosureVersion"]),new Map,stored=>stored.hcodeMetadataDisclosureVersion===1?!1:(notice(),!0)),Object.assign(this.globalSettings,snapshot),this.settings=deepMergeSettings(this.globalSettings,this.projectSettings)},!1))throw new Error("Could not save metadata disclosure acknowledgment")}getOrCreateDeviceId(){return this.globalSettings.deviceId||(this.globalSettings.deviceId=randomUUID(),
234
+ this.markModified("deviceId"),this.save()),this.globalSettings.deviceId}getPackages(){return[...this.settings.packages??[]]}setPackages(packages){this.globalSettings.packages=packages,this.markModified("packages"),this.save()}setProjectPackages(packages){this.updateProjectSettings("packages",settings=>{settings.packages=packages})}getExtensionPaths(){return[...this.settings.extensions??[]]}setExtensionPaths(paths){this.globalSettings.extensions=paths,this.markModified("extensions"),this.save()}setProjectExtensionPaths(paths){
235
+ this.updateProjectSettings("extensions",settings=>{settings.extensions=paths})}getSkillPaths(){return[...this.settings.skills??[]]}setSkillPaths(paths){this.globalSettings.skills=paths,this.markModified("skills"),this.save()}setProjectSkillPaths(paths){this.updateProjectSettings("skills",settings=>{settings.skills=paths})}getPromptTemplatePaths(){return[...this.settings.prompts??[]]}setPromptTemplatePaths(paths){this.globalSettings.prompts=paths,this.markModified("prompts"),this.save()}setProjectPromptTemplatePaths(paths){
236
+ this.updateProjectSettings("prompts",settings=>{settings.prompts=paths})}getThemePaths(){return[...this.settings.themes??[]]}setThemePaths(paths){this.globalSettings.themes=paths,this.markModified("themes"),this.save()}setProjectThemePaths(paths){this.updateProjectSettings("themes",settings=>{settings.themes=paths})}getEnableSkillCommands(){return this.settings.enableSkillCommands??SETTINGS_DEFAULTS.enableSkillCommands}setEnableSkillCommands(enabled){this.globalSettings.enableSkillCommands=enabled,
237
+ this.markModified("enableSkillCommands"),this.save()}getThinkingBudgets(){return this.settings.thinkingBudgets}getTerminalCapabilityOverrides(){let terminal=this.settings.terminal,images=terminal?.images;return{...images==="kitty"||images==="iterm2"?{images}:images===!1?{images:null}:{},...typeof terminal?.trueColor=="boolean"?{trueColor:terminal.trueColor}:{},...typeof terminal?.hyperlinks=="boolean"?{hyperlinks:terminal.hyperlinks}:{}}}getShowImages(){return this.settings.terminal?.showImages??
238
+ SETTINGS_DEFAULTS.terminal.showImages}setShowImages(show2){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showImages=show2,this.markModified("terminal","showImages"),this.save()}getImageWidthCells(){let width=this.settings.terminal?.imageWidthCells;return typeof width!="number"||!Number.isFinite(width)?SETTINGS_DEFAULTS.terminal.imageWidthCells:Math.max(1,Math.floor(width))}setImageWidthCells(width){this.globalSettings.terminal||(this.globalSettings.
239
+ terminal={}),this.globalSettings.terminal.imageWidthCells=Math.max(1,Math.floor(width)),this.markModified("terminal","imageWidthCells"),this.save()}getClearOnShrink(){return this.settings.terminal?.clearOnShrink!==void 0?this.settings.terminal.clearOnShrink:process.env.PI_CLEAR_ON_SHRINK==="1"?!0:SETTINGS_DEFAULTS.terminal.clearOnShrink}setClearOnShrink(enabled){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.clearOnShrink=enabled,this.markModified("t\
240
+ erminal","clearOnShrink"),this.save()}getShowTerminalProgress(){return this.settings.terminal?.showTerminalProgress??SETTINGS_DEFAULTS.terminal.showTerminalProgress}setShowTerminalProgress(enabled){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showTerminalProgress=enabled,this.markModified("terminal","showTerminalProgress"),this.save()}getTuiMode(){return this.settings.tuiMode==="regular"?"regular":SETTINGS_DEFAULTS.tuiMode}setTuiMode(mode){this.globalSettings.
241
+ tuiMode=mode,this.markModified("tuiMode"),this.save()}getFullscreenExitOutput(){return this.settings.fullscreenExitOutput==="resume-hint"?"resume-hint":SETTINGS_DEFAULTS.fullscreenExitOutput}setFullscreenExitOutput(output){this.globalSettings.fullscreenExitOutput=output,this.markModified("fullscreenExitOutput"),this.save()}getFullscreenScrollbar(){let mode=this.settings.fullscreenScrollbar;return mode==="always"||mode==="hidden"?mode:SETTINGS_DEFAULTS.fullscreenScrollbar}setFullscreenScrollbar(mode){
240
242
  this.globalSettings.fullscreenScrollbar=mode,this.markModified("fullscreenScrollbar"),this.save()}getFullscreenCopyOnSelect(){return this.settings.fullscreenCopyOnSelect??SETTINGS_DEFAULTS.fullscreenCopyOnSelect}setFullscreenCopyOnSelect(enabled){this.globalSettings.fullscreenCopyOnSelect=enabled,this.markModified("fullscreenCopyOnSelect"),this.save()}getFullscreenWheelScrollLines(){let lines=this.settings.fullscreenWheelScrollLines;return typeof lines=="number"&&Number.isFinite(lines)?Math.max(
241
243
  1,Math.min(100,Math.floor(lines))):SETTINGS_DEFAULTS.fullscreenWheelScrollLines}setFullscreenWheelScrollLines(lines){this.globalSettings.fullscreenWheelScrollLines=lines==="auto"?lines:Math.max(1,Math.min(100,Math.floor(lines))),this.markModified("fullscreenWheelScrollLines"),this.save()}getImageAutoResize(){return this.settings.images?.autoResize??SETTINGS_DEFAULTS.images.autoResize}setImageAutoResize(enabled){this.globalSettings.images||(this.globalSettings.images={}),this.globalSettings.images.
242
244
  autoResize=enabled,this.markModified("images","autoResize"),this.save()}getBlockImages(){return this.settings.images?.blockImages??SETTINGS_DEFAULTS.images.blockImages}setBlockImages(blocked){this.globalSettings.images||(this.globalSettings.images={}),this.globalSettings.images.blockImages=blocked,this.markModified("images","blockImages"),this.save()}getEnabledModels(){return this.settings.enabledModels}getDefaultTools(){let tools=this.settings.defaultTools;if(tools!==void 0)return resolveDefaultTools(
@@ -244,8 +246,7 @@ Array.isArray(tools)?tools.filter(tool=>typeof tool=="string"):[])}setEnabledMod
244
246
  tools","user-only","labeled-only","all"].includes(mode)?mode:SETTINGS_DEFAULTS.treeFilterMode}setTreeFilterMode(mode){this.globalSettings.treeFilterMode=mode,this.markModified("treeFilterMode"),this.save()}getShowHardwareCursor(){return this.settings.showHardwareCursor!==void 0?this.settings.showHardwareCursor:process.env.HUMAIN_TERMINAL_HARDWARE_CURSOR==="1"||process.env.PI_HARDWARE_CURSOR==="1"}setShowHardwareCursor(enabled){this.globalSettings.showHardwareCursor=enabled,this.markModified("sho\
245
247
  wHardwareCursor"),this.save()}getEditorPaddingX(){return this.settings.editorPaddingX??SETTINGS_DEFAULTS.editorPaddingX}setEditorPaddingX(padding){this.globalSettings.editorPaddingX=Math.max(0,Math.min(3,Math.floor(padding))),this.markModified("editorPaddingX"),this.save()}getOutputPad(){return this.settings.outputPad===0?0:SETTINGS_DEFAULTS.outputPad}setOutputPad(padding){this.globalSettings.outputPad=padding,this.markModified("outputPad"),this.save()}getAutocompleteMaxVisible(){return this.settings.
246
248
  autocompleteMaxVisible??SETTINGS_DEFAULTS.autocompleteMaxVisible}setAutocompleteMaxVisible(maxVisible){this.globalSettings.autocompleteMaxVisible=Math.max(3,Math.min(20,Math.floor(maxVisible))),this.markModified("autocompleteMaxVisible"),this.save()}getCodeBlockIndent(){return this.settings.markdown?.codeBlockIndent??SETTINGS_DEFAULTS.markdown.codeBlockIndent}getMermaidRenderingMode(){let mode=this.settings.markdown?.mermaid;return mode==="off"||mode==="final"?mode:SETTINGS_DEFAULTS.markdown.mermaid}setMermaidRenderingMode(mode){
247
- this.globalSettings.markdown??={},this.globalSettings.markdown.mermaid=mode,this.markModified("markdown","mermaid"),this.save()}getWarnings(){return{...this.settings.warnings??{}}}setWarnings(warnings){this.globalSettings.warnings={...warnings},this.markModified("warnings"),this.save()}};var ENVIRONMENTS=Object.freeze({dev:Object.freeze({id:"dev",origin:"https://code.dev.humain.com",inferenceBaseUrl:"https://code.dev.humain.com/api/inference"}),staging:Object.freeze({id:"staging",origin:"https://code.stg.humain.com",inferenceBaseUrl:"https://code.stg.humain.com/api/inference"}),production:Object.freeze({id:"production",origin:"https://code.humain.com",inferenceBaseUrl:"https://code.humain.com/api/inference"})});function resolveHcodeEnvironment(value="production"){if(value==="stg")
248
- return ENVIRONMENTS.staging;if(value!=="dev"&&value!=="staging"&&value!=="production")throw new Error("Invalid --env. Choose dev, staging, or production.");return ENVIRONMENTS[value]}function hcodeDisplayName(environmentId){return environmentId==="dev"?"HUMAIN Code (DEV)":environmentId==="staging"?"HUMAIN Code (STG)":"HUMAIN Code"}var import_hosted_git_info=__toESM(require_lib(),1);function splitRef(url){let scpLikeMatch=url.match(/^git@([^:]+):(.+)$/);if(scpLikeMatch){let pathWithMaybeRef2=scpLikeMatch[2]??"",refSeparator2=pathWithMaybeRef2.indexOf("@");if(refSeparator2<0)return{repo:url};let repoPath2=pathWithMaybeRef2.slice(0,refSeparator2),ref2=pathWithMaybeRef2.slice(refSeparator2+1);return!repoPath2||!ref2?{repo:url}:{repo:`git@${scpLikeMatch[1]??""}:${repoPath2}`,ref:ref2}}if(url.includes("://"))try{let parsed=new URL(
249
+ this.globalSettings.markdown??={},this.globalSettings.markdown.mermaid=mode,this.markModified("markdown","mermaid"),this.save()}getWarnings(){return{...this.settings.warnings??{}}}setWarnings(warnings){this.globalSettings.warnings={...warnings},this.markModified("warnings"),this.save()}};var import_hosted_git_info=__toESM(require_lib(),1);function splitRef(url){let scpLikeMatch=url.match(/^git@([^:]+):(.+)$/);if(scpLikeMatch){let pathWithMaybeRef2=scpLikeMatch[2]??"",refSeparator2=pathWithMaybeRef2.indexOf("@");if(refSeparator2<0)return{repo:url};let repoPath2=pathWithMaybeRef2.slice(0,refSeparator2),ref2=pathWithMaybeRef2.slice(refSeparator2+1);return!repoPath2||!ref2?{repo:url}:{repo:`git@${scpLikeMatch[1]??""}:${repoPath2}`,ref:ref2}}if(url.includes("://"))try{let parsed=new URL(
249
250
  url),pathWithMaybeRef2=parsed.pathname.replace(/^\/+/,""),refSeparator2=pathWithMaybeRef2.indexOf("@");if(refSeparator2<0)return{repo:url};let repoPath2=pathWithMaybeRef2.slice(0,refSeparator2),ref2=pathWithMaybeRef2.slice(refSeparator2+1);return!repoPath2||!ref2?{repo:url}:(parsed.pathname=`/${repoPath2}`,{repo:parsed.toString().replace(/\/$/,""),ref:ref2})}catch{return{repo:url}}let slashIndex=url.indexOf("/");if(slashIndex<0)return{repo:url};let host=url.slice(0,slashIndex),pathWithMaybeRef=url.
250
251
  slice(slashIndex+1),refSeparator=pathWithMaybeRef.indexOf("@");if(refSeparator<0)return{repo:url};let repoPath=pathWithMaybeRef.slice(0,refSeparator),ref=pathWithMaybeRef.slice(refSeparator+1);return!repoPath||!ref?{repo:url}:{repo:`${host}/${repoPath}`,ref}}function decodeForValidation(value){try{return decodeURIComponent(value)}catch{return null}}function hasUnsafeGitInstallPart(value,allowSlash){let decoded=decodeForValidation(value);if(decoded===null)return!0;let candidates=[value,decoded];for(let candidate of candidates)
251
252
  if(candidate.includes("\0")||candidate.includes("\\")||candidate.startsWith("/")||!allowSlash&&candidate.includes("/")||candidate.split("/").includes(".."))return!0;return!1}function buildGitSource(args){if(args.path.startsWith("/"))return null;let normalizedPath=args.path.replace(/\.git$/,"").replace(/^\/+/,"");return!args.host||!normalizedPath||normalizedPath.split("/").length<2||hasUnsafeGitInstallPart(args.host,!1)||hasUnsafeGitInstallPart(normalizedPath,!0)?null:{type:"git",repo:args.repo,host:args.
@@ -482,5 +483,5 @@ child.stderr?.on("data",data=>{stderr+=data.toString()}),child.once("error",erro
482
483
  : ${stderr||stdout}`))})})}runCommand(command,args,options){return this.commandOutput==="capture"?this.runCommandCaptured(command,args,options):new Promise((resolvePromise,reject)=>{let child=this.spawnCommand(command,args,options);child.on("error",reject),child.on("exit",code=>{code===0?resolvePromise():reject(new Error(`${command} ${args.join(" ")} failed with code ${code}`))})})}async runCommandCaptured(command,args,options){let child=spawnProcess(command,args,{cwd:options?.cwd,stdio:["ignore",
483
484
  "pipe","pipe"],env:getNonInteractiveGitEnv(getEnv())}),output="",append=chunk=>{output=(output+chunk.toString()).slice(-CAPTURED_OUTPUT_TAIL_CHARS)};child.stdout.on("data",append),child.stderr.on("data",append);let code=await waitForChildProcess(child);if(code===0)return;let tail=output.trim(),hint=command==="git"&&GIT_PROMPT_FAILURE.test(tail)?`
484
485
  ${GIT_CREDENTIALS_HINT}`:"";throw new Error(`${command} ${args.join(" ")} failed with code ${code}${tail?`:
485
- ${tail}`:""}${hint}`)}runCommandSync(command,args){let env=getEnv(),result=spawnProcessSync(command,args,{stdio:["ignore","pipe","pipe"],encoding:"utf-8",env});if(result.error||result.status!==0)throw new Error(`Failed to run ${command} ${args.join(" ")}: ${result.error?.message||result.stderr||result.stdout}`);return(result.stdout||result.stderr||"").trim()}};export{HTTP_IDLE_TIMEOUT_CHOICES,formatHttpIdleTimeoutMs,applyHttpProxySettings,configureHttpDispatcher,CACHE_WARMING_MODES,DEFAULT_TOOL_NAMES,isToolModifier,getToolListError,applyToolModifiers,SettingsManager,resolveHcodeEnvironment,hcodeDisplayName,minimatch,Minimatch,require_semver2 as require_semver,require_ignore,parseGitUrl,takeOverStdout,restoreStdout,writeRawStdout,waitForRawStdoutBackpressure,flushRawStdout,readPiManifest,getSourcePackageKey,BUILTIN_PATH_PREFIX,getSyntheticPathSource,isSyntheticPath,
486
+ ${tail}`:""}${hint}`)}runCommandSync(command,args){let env=getEnv(),result=spawnProcessSync(command,args,{stdio:["ignore","pipe","pipe"],encoding:"utf-8",env});if(result.error||result.status!==0)throw new Error(`Failed to run ${command} ${args.join(" ")}: ${result.error?.message||result.stderr||result.stdout}`);return(result.stdout||result.stderr||"").trim()}};export{HTTP_IDLE_TIMEOUT_CHOICES,formatHttpIdleTimeoutMs,applyHttpProxySettings,configureHttpDispatcher,resolveHcodeEnvironment,hcodeDisplayName,CACHE_WARMING_MODES,DEFAULT_TOOL_NAMES,isToolModifier,getToolListError,applyToolModifiers,SettingsManager,minimatch,Minimatch,require_semver2 as require_semver,require_ignore,parseGitUrl,takeOverStdout,restoreStdout,writeRawStdout,waitForRawStdoutBackpressure,flushRawStdout,readPiManifest,getSourcePackageKey,BUILTIN_PATH_PREFIX,getSyntheticPathSource,isSyntheticPath,
486
487
  getResourcePathKey,createSourceInfo,createSyntheticSourceInfo,DefaultPackageManager};