@humain/humain-code 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (735) hide show
  1. package/CHANGELOG.md +160 -0
  2. package/README.md +2 -2
  3. package/dist/bundle/agent-monitor.js +1 -1
  4. package/dist/bundle/chunks/anthropic-messages-XFCDMGD6.js +77 -0
  5. package/dist/bundle/chunks/anthropic.js +25 -24
  6. package/dist/bundle/chunks/azure-openai-responses-F4KQM3NK.js +15 -0
  7. package/dist/bundle/chunks/bedrock-converse-stream.js +460 -431
  8. package/dist/bundle/chunks/bowser-DXKSTXFQ.js +89 -0
  9. package/dist/bundle/chunks/{chunk-2G7YVAVF.js → chunk-2JNJJ6SZ.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-HTA325LJ.js → chunk-2NVGOSBN.js} +1 -1
  11. package/dist/bundle/chunks/{chunk-5B25YXF7.js → chunk-3CGMVKHA.js} +13 -3
  12. package/dist/bundle/chunks/{chunk-SCINMV4X.js → chunk-46C6D7UC.js} +22 -21
  13. package/dist/bundle/chunks/chunk-4MKATHT2.js +24 -0
  14. package/dist/bundle/chunks/{chunk-TGDPZCSW.js → chunk-4TDNOR36.js} +1 -1
  15. package/dist/bundle/chunks/{chunk-C6VERWRZ.js → chunk-4XF5JX7X.js} +1 -1
  16. package/dist/bundle/chunks/{chunk-4HTVBBJD.js → chunk-65FLSKDA.js} +2 -2
  17. package/dist/bundle/chunks/chunk-6HTHDVJC.js +4 -0
  18. package/dist/bundle/chunks/{chunk-4PRNKB6V.js → chunk-6P6MMQUH.js} +7 -7
  19. package/dist/bundle/chunks/{chunk-66FZJO75.js → chunk-6TTMNQXI.js} +472 -3924
  20. package/dist/bundle/chunks/{chunk-32QLLD2P.js → chunk-6YVORXTX.js} +410 -352
  21. package/dist/bundle/chunks/chunk-7H2WNBX7.js +11 -0
  22. package/dist/bundle/chunks/{chunk-2FYYW6FY.js → chunk-7OZNMWAJ.js} +1 -1
  23. package/dist/bundle/chunks/{chunk-R6YQR7TZ.js → chunk-7WE77IE3.js} +1 -1
  24. package/dist/bundle/chunks/{chunk-Z5YLKK3S.js → chunk-7WETECIB.js} +1 -1
  25. package/dist/bundle/chunks/chunk-7X6DNT45.js +78 -0
  26. package/dist/bundle/chunks/{chunk-KRCX3ZBA.js → chunk-APNPBT7Y.js} +1 -1
  27. package/dist/bundle/chunks/{chunk-R5OOX7RW.js → chunk-B47PNNLL.js} +9 -2
  28. package/dist/bundle/chunks/{chunk-PPBDDQHP.js → chunk-CQ2CE3RB.js} +7 -6
  29. package/dist/bundle/chunks/{chunk-MD7K7RPN.js → chunk-D3KYOSQY.js} +1 -1
  30. package/dist/bundle/chunks/{chunk-I3NDOUHE.js → chunk-DCXHRP6C.js} +1 -1
  31. package/dist/bundle/chunks/{chunk-OB332KMV.js → chunk-DD5UT56Y.js} +46 -32
  32. package/dist/bundle/chunks/{chunk-I5E7RQ5V.js → chunk-DJG2WUNM.js} +5 -5
  33. package/dist/bundle/chunks/{chunk-4QAXV5T6.js → chunk-E7OBH44W.js} +9 -9
  34. package/dist/bundle/chunks/{chunk-Q7VXYXY3.js → chunk-ENBDASDN.js} +2 -2
  35. package/dist/bundle/chunks/{chunk-RS6PZK35.js → chunk-F2H47FRF.js} +249 -216
  36. package/dist/bundle/chunks/{chunk-2H3LUS62.js → chunk-FJIISX5W.js} +241 -229
  37. package/dist/bundle/chunks/chunk-FQ4KS5S4.js +23 -0
  38. package/dist/bundle/chunks/{chunk-SSRCVJZK.js → chunk-GPLWWO5Q.js} +5 -5
  39. package/dist/bundle/chunks/{chunk-WQOOJP7U.js → chunk-GV5OVRKK.js} +1 -1
  40. package/dist/bundle/chunks/{chunk-KTSJYIYC.js → chunk-HHWVVNGG.js} +1 -1
  41. package/dist/bundle/chunks/{chunk-4JRER4XK.js → chunk-HQMUDHC3.js} +19 -19
  42. package/dist/bundle/chunks/{chunk-G4QPSFBF.js → chunk-IMUFBWEK.js} +216 -223
  43. package/dist/bundle/chunks/{chunk-RU7ADKA7.js → chunk-J4GII2EE.js} +112 -96
  44. package/dist/bundle/chunks/{chunk-QT6ZHDMP.js → chunk-JBSWWCT5.js} +1 -1
  45. package/dist/bundle/chunks/{chunk-PWUDFU5V.js → chunk-JWOPWHVH.js} +4 -4
  46. package/dist/bundle/chunks/{chunk-AEWYICBL.js → chunk-KI7CHPWC.js} +2 -2
  47. package/dist/bundle/chunks/{chunk-4V5VL2BO.js → chunk-KLSRGGOH.js} +131 -154
  48. package/dist/bundle/chunks/{chunk-JF7FYXAI.js → chunk-KONLZKPL.js} +7 -6
  49. package/dist/bundle/chunks/{chunk-N2SNMUD3.js → chunk-KRBELWQH.js} +1 -1
  50. package/dist/bundle/chunks/{chunk-UZNIPOGS.js → chunk-L4J7SMJB.js} +1 -1
  51. package/dist/bundle/chunks/{chunk-EIC7CQX3.js → chunk-LSRXA7OS.js} +1 -1
  52. package/dist/bundle/chunks/{chunk-GRJUKEE3.js → chunk-MIAXMK5F.js} +4 -4
  53. package/dist/bundle/chunks/chunk-MPRAQ6ZI.js +41 -0
  54. package/dist/bundle/chunks/{chunk-GUHNFZ2Q.js → chunk-NICPFMOP.js} +20 -19
  55. package/dist/bundle/chunks/{chunk-WAPZN4KP.js → chunk-P2Y2H7SD.js} +2 -2
  56. package/dist/bundle/chunks/{chunk-T7BXP46S.js → chunk-P42E6YY6.js} +1892 -1680
  57. package/dist/bundle/chunks/{chunk-3EDMWQ35.js → chunk-PFBAIRCY.js} +17 -15
  58. package/dist/bundle/chunks/{chunk-XHDVDJM7.js → chunk-PVNXN2TC.js} +7 -7
  59. package/dist/bundle/chunks/{chunk-TWAHPPXN.js → chunk-PWFM6AQQ.js} +1307 -1194
  60. package/dist/bundle/chunks/{chunk-RNBZBCH2.js → chunk-QJB5YI3I.js} +1 -1
  61. package/dist/bundle/chunks/{chunk-P6AXBESH.js → chunk-QRRVZYTG.js} +1119 -1098
  62. package/dist/bundle/chunks/{chunk-WQ7EJQIT.js → chunk-ROFZVEFN.js} +247 -250
  63. package/dist/bundle/chunks/chunk-SKCJ25SX.js +24 -0
  64. package/dist/bundle/chunks/{chunk-AZXVJN6E.js → chunk-SXOIQWNX.js} +1 -1
  65. package/dist/bundle/chunks/{chunk-6E6RHNOU.js → chunk-UXM4WFLH.js} +12 -11
  66. package/dist/bundle/chunks/{chunk-LB4CIS4F.js → chunk-VCMXBP5S.js} +17 -17
  67. package/dist/bundle/chunks/{chunk-JYWUOKOI.js → chunk-WBSGWISD.js} +367 -353
  68. package/dist/bundle/chunks/chunk-XZ7FTBXS.js +2102 -0
  69. package/dist/bundle/chunks/chunk-YSWDFV2L.js +11 -0
  70. package/dist/bundle/chunks/chunk-ZG74NES2.js +2 -0
  71. package/dist/bundle/chunks/chunk-ZTG5OKI7.js +3 -0
  72. package/dist/bundle/chunks/{cli-H4LJNE2V.js → cli-6DJO467D.js} +2 -2
  73. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-T5R2RVFQ.js → cloudflare-workers-ai-system-one-JEZVYITT.js} +1 -1
  74. package/dist/bundle/chunks/codemode-worker.js +68 -68
  75. package/dist/bundle/chunks/compat-SRCNS6OQ.js +15 -0
  76. package/dist/bundle/chunks/curator-server-QB4GITGS.js +3600 -0
  77. package/dist/bundle/chunks/dist-35STTNYA.js +37 -0
  78. package/dist/bundle/chunks/{dist-FMWWM4H7.js → dist-4OMLHRJE.js} +2 -2
  79. package/dist/bundle/chunks/dist-CBODG4CA.js +11 -0
  80. package/dist/bundle/chunks/{dist-NHQTBDHT.js → dist-TRAK7EXI.js} +91 -257
  81. package/dist/bundle/chunks/dist-cjs-EROMDUKS.js +193 -0
  82. package/dist/bundle/chunks/{easter-egg-3d-BUEOC3NO.js → easter-egg-3d-VVUF3C3X.js} +1 -1
  83. package/dist/bundle/chunks/entry-2GZ3PTWQ.js +2 -0
  84. package/dist/bundle/chunks/{entry-A2CSLKHC.js → entry-SRYLSS5P.js} +3 -3
  85. package/dist/bundle/chunks/{event-streams-7YGFEPBZ.js → event-streams-F67JLS6B.js} +1 -1
  86. package/dist/bundle/chunks/{execute-MY5JSEPV.js → execute-I3WGGPWL.js} +2 -2
  87. package/dist/bundle/chunks/{extract-PTGACPGP.js → extract-L373D6O7.js} +68 -65
  88. package/dist/bundle/chunks/{flow-implementer-APJFY4YI.js → flow-implementer-4KO3Q4B5.js} +8 -9
  89. package/dist/bundle/chunks/github-copilot.js +53 -46
  90. package/dist/bundle/chunks/google-generative-ai-WIASMWS3.js +22 -0
  91. package/dist/bundle/chunks/google-vertex-WSPHRZIZ.js +25 -0
  92. package/dist/bundle/chunks/host-WOLZCWQQ.js +3 -0
  93. package/dist/bundle/chunks/image-resize-worker.js +3 -3
  94. package/dist/bundle/chunks/{index.bundle-THL4EUSU.js → index.bundle-HONF3PUD.js} +177 -176
  95. package/dist/bundle/chunks/{inprocess-5NP5VJHZ.js → inprocess-TOBRVK4C.js} +6 -6
  96. package/dist/bundle/chunks/interactive-mode-BJJKPBXD.js +5 -0
  97. package/dist/bundle/chunks/{llama-cpp-classify-GJAXULWL.js → llama-cpp-classify-KYZT532X.js} +1 -1
  98. package/dist/bundle/chunks/mistral-conversations-7JYDDRUT.js +43 -0
  99. package/dist/bundle/chunks/{node-UNHECG4X.js → node-MHHE76P4.js} +475 -440
  100. package/dist/bundle/chunks/{node-ZFIIS5IM.js → node-N7TPBUJB.js} +53 -30
  101. package/dist/bundle/chunks/{openai-codex-responses-S7CMCAOY.js → openai-codex-responses-7PAML4NF.js} +30 -29
  102. package/dist/bundle/chunks/openai-codex.js +9 -8
  103. package/dist/bundle/chunks/{openai-completions-2Z57N7PC.js → openai-completions-UJDAIGTK.js} +22 -22
  104. package/dist/bundle/chunks/{openai-decisions-JIOJDB4C.js → openai-decisions-JMSDGR7K.js} +1 -1
  105. package/dist/bundle/chunks/{openai-responses-5VBZSTHL.js → openai-responses-2WNCE6AY.js} +4 -5
  106. package/dist/bundle/chunks/{openrouter-images-S6O7DBEJ.js → openrouter-images-V3UCCO6X.js} +1 -1
  107. package/dist/bundle/chunks/openrouter.js +9 -8
  108. package/dist/bundle/chunks/pdfjs-FE3L72A6.js +3662 -0
  109. package/dist/bundle/chunks/{pdfjs-decoders-OFXX4HDZ.js → pdfjs-decoders-VCMCTQJ2.js} +1 -1
  110. package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-I4K6AIV4.js +295 -0
  111. package/dist/bundle/chunks/pdfjs-openjpeg-PYQCV6CM.js +590 -0
  112. package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-G363SGDI.js +775 -0
  113. package/dist/bundle/chunks/{pi-messages-SMLN5J2W.js → pi-messages-TQ7LJUNQ.js} +11 -11
  114. package/dist/bundle/chunks/radius.js +8 -7
  115. package/dist/bundle/chunks/{runtime-OYTWXIUM.js → runtime-H7LYNKCZ.js} +1 -1
  116. package/dist/bundle/chunks/session-picker-4JQEGLDD.js +4 -0
  117. package/dist/bundle/chunks/startup-ui-AKTA4NDP.js +3 -0
  118. package/dist/bundle/chunks/{trace-command-YLDYCL55.js → trace-command-7ORDQ3JS.js} +4 -4
  119. package/dist/bundle/chunks/{typesafe-system-one-7BEL3H5N.js → typesafe-system-one-YP7GGN4C.js} +1 -1
  120. package/dist/bundle/chunks/{undici-C6S56CGI.js → undici-WVNE45GY.js} +1 -1
  121. package/dist/bundle/chunks/virtual-modules-3CT5BMBA.js +28 -0
  122. package/dist/bundle/cli-runtime.js +5 -5
  123. package/dist/bundle/flow/package.json +5 -5
  124. package/dist/bundle/index.js +13 -13
  125. package/dist/bundle/orchestrate/package.json +22 -6
  126. package/dist/bundle/rpc-entry.js +4 -5
  127. package/dist/cli/args.d.ts.map +1 -1
  128. package/dist/cli/args.js +4 -3
  129. package/dist/cli/args.js.map +1 -1
  130. package/dist/cli/config-selector.d.ts.map +1 -1
  131. package/dist/cli/config-selector.js +9 -6
  132. package/dist/cli/config-selector.js.map +1 -1
  133. package/dist/cli/list-models.d.ts.map +1 -1
  134. package/dist/cli/list-models.js +16 -1
  135. package/dist/cli/list-models.js.map +1 -1
  136. package/dist/cli/session-picker.d.ts.map +1 -1
  137. package/dist/cli/session-picker.js +9 -6
  138. package/dist/cli/session-picker.js.map +1 -1
  139. package/dist/cli/setup.d.ts +1 -1
  140. package/dist/cli/setup.d.ts.map +1 -1
  141. package/dist/cli/setup.js +3 -2
  142. package/dist/cli/setup.js.map +1 -1
  143. package/dist/cli/startup-ui.d.ts.map +1 -1
  144. package/dist/cli/startup-ui.js +8 -4
  145. package/dist/cli/startup-ui.js.map +1 -1
  146. package/dist/cli.js.map +1 -1
  147. package/dist/core/agent-session-runtime.d.ts +14 -0
  148. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  149. package/dist/core/agent-session-runtime.js +30 -2
  150. package/dist/core/agent-session-runtime.js.map +1 -1
  151. package/dist/core/agent-session-services.d.ts +0 -2
  152. package/dist/core/agent-session-services.d.ts.map +1 -1
  153. package/dist/core/agent-session-services.js +0 -2
  154. package/dist/core/agent-session-services.js.map +1 -1
  155. package/dist/core/agent-session.d.ts +31 -39
  156. package/dist/core/agent-session.d.ts.map +1 -1
  157. package/dist/core/agent-session.js +231 -535
  158. package/dist/core/agent-session.js.map +1 -1
  159. package/dist/core/anthropic-subscription-usage.d.ts +4 -2
  160. package/dist/core/anthropic-subscription-usage.d.ts.map +1 -1
  161. package/dist/core/anthropic-subscription-usage.js +32 -16
  162. package/dist/core/anthropic-subscription-usage.js.map +1 -1
  163. package/dist/core/auto-session-namer.js +1 -1
  164. package/dist/core/auto-session-namer.js.map +1 -1
  165. package/dist/core/cache-warmer.d.ts.map +1 -1
  166. package/dist/core/cache-warmer.js +2 -0
  167. package/dist/core/cache-warmer.js.map +1 -1
  168. package/dist/core/exec.d.ts +1 -0
  169. package/dist/core/exec.d.ts.map +1 -1
  170. package/dist/core/exec.js +4 -1
  171. package/dist/core/exec.js.map +1 -1
  172. package/dist/core/export-html/ansi-to-html.d.ts +6 -1
  173. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  174. package/dist/core/export-html/ansi-to-html.js +57 -20
  175. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  176. package/dist/core/export-html/template.js +1 -1
  177. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  178. package/dist/core/export-html/tool-renderer.js +2 -3
  179. package/dist/core/export-html/tool-renderer.js.map +1 -1
  180. package/dist/core/extensions/loader.d.ts.map +1 -1
  181. package/dist/core/extensions/loader.js +18 -1
  182. package/dist/core/extensions/loader.js.map +1 -1
  183. package/dist/core/extensions/runner.d.ts.map +1 -1
  184. package/dist/core/extensions/runner.js +5 -0
  185. package/dist/core/extensions/runner.js.map +1 -1
  186. package/dist/core/extensions/types.d.ts +5 -0
  187. package/dist/core/extensions/types.d.ts.map +1 -1
  188. package/dist/core/extensions/types.js.map +1 -1
  189. package/dist/core/flow-implementer.d.ts.map +1 -1
  190. package/dist/core/flow-implementer.js +3 -9
  191. package/dist/core/flow-implementer.js.map +1 -1
  192. package/dist/core/keybindings.d.ts +64 -0
  193. package/dist/core/keybindings.d.ts.map +1 -1
  194. package/dist/core/keybindings.js +8 -0
  195. package/dist/core/keybindings.js.map +1 -1
  196. package/dist/core/model-config.d.ts +13 -0
  197. package/dist/core/model-config.d.ts.map +1 -1
  198. package/dist/core/model-registry.d.ts +3 -0
  199. package/dist/core/model-registry.d.ts.map +1 -1
  200. package/dist/core/model-registry.js +44 -9
  201. package/dist/core/model-registry.js.map +1 -1
  202. package/dist/core/model-resolver.d.ts +0 -1
  203. package/dist/core/model-resolver.d.ts.map +1 -1
  204. package/dist/core/model-resolver.js +14 -17
  205. package/dist/core/model-resolver.js.map +1 -1
  206. package/dist/core/model-runtime.d.ts +28 -8
  207. package/dist/core/model-runtime.d.ts.map +1 -1
  208. package/dist/core/model-runtime.js +64 -14
  209. package/dist/core/model-runtime.js.map +1 -1
  210. package/dist/core/oauth-account-pool.d.ts +9 -0
  211. package/dist/core/oauth-account-pool.d.ts.map +1 -1
  212. package/dist/core/oauth-account-pool.js +138 -23
  213. package/dist/core/oauth-account-pool.js.map +1 -1
  214. package/dist/core/package-manager.d.ts +16 -0
  215. package/dist/core/package-manager.d.ts.map +1 -1
  216. package/dist/core/package-manager.js +46 -3
  217. package/dist/core/package-manager.js.map +1 -1
  218. package/dist/core/pi-ai-schemas.d.ts +1 -0
  219. package/dist/core/pi-ai-schemas.d.ts.map +1 -1
  220. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  221. package/dist/core/remote-catalog-provider.js +7 -0
  222. package/dist/core/remote-catalog-provider.js.map +1 -1
  223. package/dist/core/resource-loader.d.ts +5 -1
  224. package/dist/core/resource-loader.d.ts.map +1 -1
  225. package/dist/core/resource-loader.js +2 -0
  226. package/dist/core/resource-loader.js.map +1 -1
  227. package/dist/core/run-outcome.d.ts +6 -3
  228. package/dist/core/run-outcome.d.ts.map +1 -1
  229. package/dist/core/run-outcome.js +36 -9
  230. package/dist/core/run-outcome.js.map +1 -1
  231. package/dist/core/run-preflight.d.ts +1 -1
  232. package/dist/core/run-preflight.d.ts.map +1 -1
  233. package/dist/core/run-preflight.js +19 -11
  234. package/dist/core/run-preflight.js.map +1 -1
  235. package/dist/core/sdk.d.ts +0 -6
  236. package/dist/core/sdk.d.ts.map +1 -1
  237. package/dist/core/sdk.js +9 -18
  238. package/dist/core/sdk.js.map +1 -1
  239. package/dist/core/settings-manager.d.ts +0 -5
  240. package/dist/core/settings-manager.d.ts.map +1 -1
  241. package/dist/core/settings-manager.js +0 -9
  242. package/dist/core/settings-manager.js.map +1 -1
  243. package/dist/core/settings-schema.d.ts +0 -4
  244. package/dist/core/settings-schema.d.ts.map +1 -1
  245. package/dist/core/settings-schema.js +0 -1
  246. package/dist/core/settings-schema.js.map +1 -1
  247. package/dist/core/slash-commands.d.ts.map +1 -1
  248. package/dist/core/slash-commands.js +1 -0
  249. package/dist/core/slash-commands.js.map +1 -1
  250. package/dist/core/tools/bash-jobs.d.ts.map +1 -1
  251. package/dist/core/tools/bash-jobs.js +2 -9
  252. package/dist/core/tools/bash-jobs.js.map +1 -1
  253. package/dist/core/tools/find.d.ts.map +1 -1
  254. package/dist/core/tools/find.js +28 -16
  255. package/dist/core/tools/find.js.map +1 -1
  256. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  257. package/dist/core/tools/output-accumulator.js +4 -1
  258. package/dist/core/tools/output-accumulator.js.map +1 -1
  259. package/dist/core/tools/read.d.ts +8 -4
  260. package/dist/core/tools/read.d.ts.map +1 -1
  261. package/dist/core/tools/read.js +10 -15
  262. package/dist/core/tools/read.js.map +1 -1
  263. package/dist/core/tools/renderers/read.d.ts.map +1 -1
  264. package/dist/core/tools/renderers/read.js +6 -2
  265. package/dist/core/tools/renderers/read.js.map +1 -1
  266. package/dist/core/tools/subagent-worktree.d.ts.map +1 -1
  267. package/dist/core/tools/subagent-worktree.js +2 -10
  268. package/dist/core/tools/subagent-worktree.js.map +1 -1
  269. package/dist/core/trace-client/credential-store.d.ts.map +1 -1
  270. package/dist/core/trace-client/credential-store.js +9 -5
  271. package/dist/core/trace-client/credential-store.js.map +1 -1
  272. package/dist/extensions/codemode/execute.js +2 -2
  273. package/dist/extensions/codemode/execute.js.map +1 -1
  274. package/dist/extensions/llama/provider.d.ts +1 -1
  275. package/dist/extensions/llama/provider.d.ts.map +1 -1
  276. package/dist/extensions/llama/provider.js +6 -4
  277. package/dist/extensions/llama/provider.js.map +1 -1
  278. package/dist/extensions/usage/account-reconnect.d.ts +5 -0
  279. package/dist/extensions/usage/account-reconnect.d.ts.map +1 -0
  280. package/dist/extensions/usage/account-reconnect.js +12 -0
  281. package/dist/extensions/usage/account-reconnect.js.map +1 -0
  282. package/dist/extensions/usage/confirmation.d.ts.map +1 -1
  283. package/dist/extensions/usage/confirmation.js +1 -1
  284. package/dist/extensions/usage/confirmation.js.map +1 -1
  285. package/dist/extensions/usage/hcode-overview.d.ts +6 -19
  286. package/dist/extensions/usage/hcode-overview.d.ts.map +1 -1
  287. package/dist/extensions/usage/hcode-overview.js +86 -100
  288. package/dist/extensions/usage/hcode-overview.js.map +1 -1
  289. package/dist/extensions/usage/index.d.ts.map +1 -1
  290. package/dist/extensions/usage/index.js +75 -99
  291. package/dist/extensions/usage/index.js.map +1 -1
  292. package/dist/extensions/usage/overview.d.ts +22 -17
  293. package/dist/extensions/usage/overview.d.ts.map +1 -1
  294. package/dist/extensions/usage/overview.js +98 -13
  295. package/dist/extensions/usage/overview.js.map +1 -1
  296. package/dist/extensions/usage/panes.d.ts +5 -0
  297. package/dist/extensions/usage/panes.d.ts.map +1 -0
  298. package/dist/extensions/usage/panes.js +10 -0
  299. package/dist/extensions/usage/panes.js.map +1 -0
  300. package/dist/extensions/usage/popup.d.ts +9 -14
  301. package/dist/extensions/usage/popup.d.ts.map +1 -1
  302. package/dist/extensions/usage/popup.js +87 -183
  303. package/dist/extensions/usage/popup.js.map +1 -1
  304. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +4 -1
  305. package/dist/humain/flow-command.js +1 -1
  306. package/dist/humain/flow-command.js.map +1 -1
  307. package/dist/humain/flow-loader.d.ts +9 -4
  308. package/dist/humain/flow-loader.d.ts.map +1 -1
  309. package/dist/humain/flow-loader.js +30 -21
  310. package/dist/humain/flow-loader.js.map +1 -1
  311. package/dist/humain/gateway/client.d.ts +3 -1
  312. package/dist/humain/gateway/client.d.ts.map +1 -1
  313. package/dist/humain/gateway/client.js +10 -5
  314. package/dist/humain/gateway/client.js.map +1 -1
  315. package/dist/humain/gateway/login.d.ts.map +1 -1
  316. package/dist/humain/gateway/login.js +160 -53
  317. package/dist/humain/gateway/login.js.map +1 -1
  318. package/dist/humain/hcode/account-store.d.ts +29 -5
  319. package/dist/humain/hcode/account-store.d.ts.map +1 -1
  320. package/dist/humain/hcode/account-store.js +224 -124
  321. package/dist/humain/hcode/account-store.js.map +1 -1
  322. package/dist/humain/hcode/account.d.ts +6 -0
  323. package/dist/humain/hcode/account.d.ts.map +1 -1
  324. package/dist/humain/hcode/account.js +348 -129
  325. package/dist/humain/hcode/account.js.map +1 -1
  326. package/dist/humain/hcode/catalog-watch.d.ts +21 -0
  327. package/dist/humain/hcode/catalog-watch.d.ts.map +1 -0
  328. package/dist/humain/hcode/catalog-watch.js +46 -0
  329. package/dist/humain/hcode/catalog-watch.js.map +1 -0
  330. package/dist/humain/hcode/contracts.d.ts +31 -1
  331. package/dist/humain/hcode/contracts.d.ts.map +1 -1
  332. package/dist/humain/hcode/contracts.js +205 -136
  333. package/dist/humain/hcode/contracts.js.map +1 -1
  334. package/dist/humain/hcode/environment.d.ts +3 -1
  335. package/dist/humain/hcode/environment.d.ts.map +1 -1
  336. package/dist/humain/hcode/environment.js +14 -2
  337. package/dist/humain/hcode/environment.js.map +1 -1
  338. package/dist/humain/hcode/facade.d.ts +26 -6
  339. package/dist/humain/hcode/facade.d.ts.map +1 -1
  340. package/dist/humain/hcode/facade.js +148 -38
  341. package/dist/humain/hcode/facade.js.map +1 -1
  342. package/dist/humain/hcode/http.d.ts +3 -1
  343. package/dist/humain/hcode/http.d.ts.map +1 -1
  344. package/dist/humain/hcode/http.js +44 -23
  345. package/dist/humain/hcode/http.js.map +1 -1
  346. package/dist/humain/hcode/images.d.ts +67 -0
  347. package/dist/humain/hcode/images.d.ts.map +1 -0
  348. package/dist/humain/hcode/images.js +465 -0
  349. package/dist/humain/hcode/images.js.map +1 -0
  350. package/dist/humain/hcode/login-copy.d.ts +28 -0
  351. package/dist/humain/hcode/login-copy.d.ts.map +1 -0
  352. package/dist/humain/hcode/login-copy.js +74 -0
  353. package/dist/humain/hcode/login-copy.js.map +1 -0
  354. package/dist/humain/hcode/login-failure.d.ts +26 -0
  355. package/dist/humain/hcode/login-failure.d.ts.map +1 -0
  356. package/dist/humain/hcode/login-failure.js +50 -0
  357. package/dist/humain/hcode/login-failure.js.map +1 -0
  358. package/dist/humain/hcode/notices.d.ts +45 -1
  359. package/dist/humain/hcode/notices.d.ts.map +1 -1
  360. package/dist/humain/hcode/notices.js +124 -7
  361. package/dist/humain/hcode/notices.js.map +1 -1
  362. package/dist/humain/hcode/provider.d.ts +9 -3
  363. package/dist/humain/hcode/provider.d.ts.map +1 -1
  364. package/dist/humain/hcode/provider.js +204 -20
  365. package/dist/humain/hcode/provider.js.map +1 -1
  366. package/dist/humain/hcode/run-credential.d.ts +21 -0
  367. package/dist/humain/hcode/run-credential.d.ts.map +1 -0
  368. package/dist/humain/hcode/run-credential.js +140 -0
  369. package/dist/humain/hcode/run-credential.js.map +1 -0
  370. package/dist/humain/hcode/sandbox.d.ts +6 -0
  371. package/dist/humain/hcode/sandbox.d.ts.map +1 -0
  372. package/dist/humain/hcode/sandbox.js +139 -0
  373. package/dist/humain/hcode/sandbox.js.map +1 -0
  374. package/dist/humain/hcode/selection.d.ts +9 -2
  375. package/dist/humain/hcode/selection.d.ts.map +1 -1
  376. package/dist/humain/hcode/selection.js +37 -6
  377. package/dist/humain/hcode/selection.js.map +1 -1
  378. package/dist/humain/hcode/transport.d.ts +14 -10
  379. package/dist/humain/hcode/transport.d.ts.map +1 -1
  380. package/dist/humain/hcode/transport.js +119 -149
  381. package/dist/humain/hcode/transport.js.map +1 -1
  382. package/dist/humain/hcode/wire.d.ts +3 -0
  383. package/dist/humain/hcode/wire.d.ts.map +1 -1
  384. package/dist/humain/hcode/wire.js +11 -0
  385. package/dist/humain/hcode/wire.js.map +1 -1
  386. package/dist/humain/metadata/contracts.d.ts +1 -0
  387. package/dist/humain/metadata/contracts.d.ts.map +1 -1
  388. package/dist/humain/metadata/contracts.js +2 -1
  389. package/dist/humain/metadata/contracts.js.map +1 -1
  390. package/dist/humain/remote/broker.d.ts +84 -0
  391. package/dist/humain/remote/broker.d.ts.map +1 -0
  392. package/dist/humain/remote/broker.js +427 -0
  393. package/dist/humain/remote/broker.js.map +1 -0
  394. package/dist/humain/remote/deny-store.d.ts +12 -0
  395. package/dist/humain/remote/deny-store.d.ts.map +1 -0
  396. package/dist/humain/remote/deny-store.js +164 -0
  397. package/dist/humain/remote/deny-store.js.map +1 -0
  398. package/dist/humain/remote/enablement.d.ts +5 -0
  399. package/dist/humain/remote/enablement.d.ts.map +1 -0
  400. package/dist/humain/remote/enablement.js +8 -0
  401. package/dist/humain/remote/enablement.js.map +1 -0
  402. package/dist/humain/remote/environment.d.ts +11 -0
  403. package/dist/humain/remote/environment.d.ts.map +1 -0
  404. package/dist/humain/remote/environment.js +19 -0
  405. package/dist/humain/remote/environment.js.map +1 -0
  406. package/dist/humain/remote/host-watch.d.ts +21 -0
  407. package/dist/humain/remote/host-watch.d.ts.map +1 -0
  408. package/dist/humain/remote/host-watch.js +186 -0
  409. package/dist/humain/remote/host-watch.js.map +1 -0
  410. package/dist/humain/remote/ipc-posix.d.ts +5 -0
  411. package/dist/humain/remote/ipc-posix.d.ts.map +1 -0
  412. package/dist/humain/remote/ipc-posix.js +29 -0
  413. package/dist/humain/remote/ipc-posix.js.map +1 -0
  414. package/dist/humain/remote/ipc-windows.d.ts +3 -0
  415. package/dist/humain/remote/ipc-windows.d.ts.map +1 -0
  416. package/dist/humain/remote/ipc-windows.js +5 -0
  417. package/dist/humain/remote/ipc-windows.js.map +1 -0
  418. package/dist/humain/remote/ipc.d.ts +10 -0
  419. package/dist/humain/remote/ipc.d.ts.map +1 -0
  420. package/dist/humain/remote/ipc.js +19 -0
  421. package/dist/humain/remote/ipc.js.map +1 -0
  422. package/dist/humain/remote/protocol.d.ts +43 -0
  423. package/dist/humain/remote/protocol.d.ts.map +1 -0
  424. package/dist/humain/remote/protocol.js +76 -0
  425. package/dist/humain/remote/protocol.js.map +1 -0
  426. package/dist/humain/remote/relay-socket.d.ts +30 -0
  427. package/dist/humain/remote/relay-socket.d.ts.map +1 -0
  428. package/dist/humain/remote/relay-socket.js +137 -0
  429. package/dist/humain/remote/relay-socket.js.map +1 -0
  430. package/dist/humain/remote/secure-channel.d.ts +10 -0
  431. package/dist/humain/remote/secure-channel.d.ts.map +1 -0
  432. package/dist/humain/remote/secure-channel.js +5 -0
  433. package/dist/humain/remote/secure-channel.js.map +1 -0
  434. package/dist/humain/remote/terminal.d.ts +48 -0
  435. package/dist/humain/remote/terminal.d.ts.map +1 -0
  436. package/dist/humain/remote/terminal.js +119 -0
  437. package/dist/humain/remote/terminal.js.map +1 -0
  438. package/dist/humain/remote/tickets.d.ts +35 -0
  439. package/dist/humain/remote/tickets.d.ts.map +1 -0
  440. package/dist/humain/remote/tickets.js +132 -0
  441. package/dist/humain/remote/tickets.js.map +1 -0
  442. package/dist/humain/web-access/vendor/anysearch.d.ts.map +1 -1
  443. package/dist/humain/web-access/vendor/anysearch.js +7 -3
  444. package/dist/humain/web-access/vendor/anysearch.js.map +1 -1
  445. package/dist/humain/web-access/vendor/autom.d.ts +4 -0
  446. package/dist/humain/web-access/vendor/autom.d.ts.map +1 -0
  447. package/dist/humain/web-access/vendor/autom.js +191 -0
  448. package/dist/humain/web-access/vendor/autom.js.map +1 -0
  449. package/dist/humain/web-access/vendor/cloro.d.ts +4 -0
  450. package/dist/humain/web-access/vendor/cloro.d.ts.map +1 -0
  451. package/dist/humain/web-access/vendor/cloro.js +236 -0
  452. package/dist/humain/web-access/vendor/cloro.js.map +1 -0
  453. package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
  454. package/dist/humain/web-access/vendor/curator-page.js +7 -1
  455. package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
  456. package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
  457. package/dist/humain/web-access/vendor/curator-server.js +6 -0
  458. package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
  459. package/dist/humain/web-access/vendor/domain-filter-normalization.d.ts +8 -0
  460. package/dist/humain/web-access/vendor/domain-filter-normalization.d.ts.map +1 -1
  461. package/dist/humain/web-access/vendor/domain-filter-normalization.js +37 -0
  462. package/dist/humain/web-access/vendor/domain-filter-normalization.js.map +1 -1
  463. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts +28 -8
  464. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts.map +1 -1
  465. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js +135 -34
  466. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js.map +1 -1
  467. package/dist/humain/web-access/vendor/duckduckgo.d.ts +1 -1
  468. package/dist/humain/web-access/vendor/duckduckgo.d.ts.map +1 -1
  469. package/dist/humain/web-access/vendor/duckduckgo.js +10 -3
  470. package/dist/humain/web-access/vendor/duckduckgo.js.map +1 -1
  471. package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
  472. package/dist/humain/web-access/vendor/extract.js +61 -5
  473. package/dist/humain/web-access/vendor/extract.js.map +1 -1
  474. package/dist/humain/web-access/vendor/gemini-search.d.ts +3 -3
  475. package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
  476. package/dist/humain/web-access/vendor/gemini-search.js +35 -5
  477. package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
  478. package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
  479. package/dist/humain/web-access/vendor/index.js +8 -1
  480. package/dist/humain/web-access/vendor/index.js.map +1 -1
  481. package/dist/humain/web-access/vendor/page-query.d.ts +5 -0
  482. package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
  483. package/dist/humain/web-access/vendor/page-query.js +12 -2
  484. package/dist/humain/web-access/vendor/page-query.js.map +1 -1
  485. package/dist/humain/web-access/vendor/specstream.d.ts +6 -0
  486. package/dist/humain/web-access/vendor/specstream.d.ts.map +1 -0
  487. package/dist/humain/web-access/vendor/specstream.js +253 -0
  488. package/dist/humain/web-access/vendor/specstream.js.map +1 -0
  489. package/dist/humain/web-access/vendor/tool-activation.d.ts.map +1 -1
  490. package/dist/humain/web-access/vendor/tool-activation.js +21 -5
  491. package/dist/humain/web-access/vendor/tool-activation.js.map +1 -1
  492. package/dist/humain/web-access/vendor/upgrade-notice.d.ts +1 -1
  493. package/dist/humain/web-access/vendor/upgrade-notice.js +1 -1
  494. package/dist/humain/web-access/vendor/upgrade-notice.js.map +1 -1
  495. package/dist/humain/web-access/vendor/utils.d.ts +1 -0
  496. package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
  497. package/dist/humain/web-access/vendor/utils.js +3 -0
  498. package/dist/humain/web-access/vendor/utils.js.map +1 -1
  499. package/dist/humain/web-access/vendor/video-extract.js +2 -2
  500. package/dist/humain/web-access/vendor/video-extract.js.map +1 -1
  501. package/dist/humain/web-access/vendor/web-tool-core.d.ts +13 -0
  502. package/dist/humain/web-access/vendor/web-tool-core.d.ts.map +1 -1
  503. package/dist/humain/web-access/vendor/web-tool-core.js +16 -5
  504. package/dist/humain/web-access/vendor/web-tool-core.js.map +1 -1
  505. package/dist/humain/web-access/vendor/youtube-extract.js +2 -2
  506. package/dist/humain/web-access/vendor/youtube-extract.js.map +1 -1
  507. package/dist/index.d.ts +0 -2
  508. package/dist/index.d.ts.map +1 -1
  509. package/dist/index.js.map +1 -1
  510. package/dist/main.d.ts +1 -1
  511. package/dist/main.d.ts.map +1 -1
  512. package/dist/main.js +109 -29
  513. package/dist/main.js.map +1 -1
  514. package/dist/modes/diagnostics-stderr.d.ts +4 -0
  515. package/dist/modes/diagnostics-stderr.d.ts.map +1 -0
  516. package/dist/modes/diagnostics-stderr.js +11 -0
  517. package/dist/modes/diagnostics-stderr.js.map +1 -0
  518. package/dist/modes/interactive/components/account-picker.d.ts +31 -0
  519. package/dist/modes/interactive/components/account-picker.d.ts.map +1 -0
  520. package/dist/modes/interactive/components/account-picker.js +150 -0
  521. package/dist/modes/interactive/components/account-picker.js.map +1 -0
  522. package/dist/modes/interactive/components/assistant-message.d.ts +1 -1
  523. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  524. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  525. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  526. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  527. package/dist/modes/interactive/components/config-selector.js +5 -2
  528. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  529. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  530. package/dist/modes/interactive/components/extension-selector.js +14 -5
  531. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  532. package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
  533. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  534. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  535. package/dist/modes/interactive/components/keybinding-hints.d.ts +2 -0
  536. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  537. package/dist/modes/interactive/components/keybinding-hints.js +6 -0
  538. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  539. package/dist/modes/interactive/components/model-selector.d.ts +10 -0
  540. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  541. package/dist/modes/interactive/components/model-selector.js +101 -23
  542. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  543. package/dist/modes/interactive/components/oauth-selector.d.ts +5 -0
  544. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  545. package/dist/modes/interactive/components/oauth-selector.js +17 -6
  546. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  547. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -1
  548. package/dist/modes/interactive/components/radius-login-selector.js +2 -1
  549. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -1
  550. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  551. package/dist/modes/interactive/components/scoped-models-selector.js +13 -6
  552. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  553. package/dist/modes/interactive/components/session-selector.d.ts +8 -1
  554. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  555. package/dist/modes/interactive/components/session-selector.js +41 -9
  556. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  557. package/dist/modes/interactive/components/settings-submenu.d.ts +1 -1
  558. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  559. package/dist/modes/interactive/components/settings-submenu.js +5 -1
  560. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  561. package/dist/modes/interactive/components/status-indicator.d.ts +0 -17
  562. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  563. package/dist/modes/interactive/components/status-indicator.js +1 -78
  564. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  565. package/dist/modes/interactive/components/themed-text.d.ts +1 -1
  566. package/dist/modes/interactive/components/themed-text.d.ts.map +1 -1
  567. package/dist/modes/interactive/components/themed-text.js.map +1 -1
  568. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  569. package/dist/modes/interactive/components/thinking-selector.js +5 -1
  570. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  571. package/dist/modes/interactive/components/tool-execution.d.ts +1 -1
  572. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  573. package/dist/modes/interactive/components/tool-execution.js +3 -1
  574. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  575. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
  576. package/dist/modes/interactive/components/trust-selector.js +14 -5
  577. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  578. package/dist/modes/interactive/components/user-message.d.ts +1 -1
  579. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  580. package/dist/modes/interactive/components/user-message.js.map +1 -1
  581. package/dist/modes/interactive/components/visual-truncate.d.ts +2 -2
  582. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  583. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  584. package/dist/modes/interactive/interactive-mode.d.ts +35 -4
  585. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  586. package/dist/modes/interactive/interactive-mode.js +821 -250
  587. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  588. package/dist/modes/interactive/model-catalog-refresh.d.ts +4 -0
  589. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -1
  590. package/dist/modes/interactive/model-catalog-refresh.js +40 -1
  591. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -1
  592. package/dist/modes/interactive/oauth-account-format.d.ts +15 -2
  593. package/dist/modes/interactive/oauth-account-format.d.ts.map +1 -1
  594. package/dist/modes/interactive/oauth-account-format.js +39 -21
  595. package/dist/modes/interactive/oauth-account-format.js.map +1 -1
  596. package/dist/modes/interactive/session-share.js +2 -0
  597. package/dist/modes/interactive/session-share.js.map +1 -1
  598. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  599. package/dist/modes/interactive/theme/theme.js +1 -0
  600. package/dist/modes/interactive/theme/theme.js.map +1 -1
  601. package/dist/modes/print-mode.d.ts.map +1 -1
  602. package/dist/modes/print-mode.js +30 -32
  603. package/dist/modes/print-mode.js.map +1 -1
  604. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  605. package/dist/modes/rpc/rpc-mode.js +26 -39
  606. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  607. package/dist/modes/rpc/rpc-types.d.ts +1 -0
  608. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  609. package/dist/modes/rpc/rpc-types.js.map +1 -1
  610. package/dist/package-manager-cli.d.ts.map +1 -1
  611. package/dist/package-manager-cli.js +14 -1
  612. package/dist/package-manager-cli.js.map +1 -1
  613. package/dist/utils/abort.d.ts +5 -0
  614. package/dist/utils/abort.d.ts.map +1 -1
  615. package/dist/utils/abort.js +9 -0
  616. package/dist/utils/abort.js.map +1 -1
  617. package/dist/utils/changelog.d.ts.map +1 -1
  618. package/dist/utils/changelog.js +3 -2
  619. package/dist/utils/changelog.js.map +1 -1
  620. package/dist/utils/flush-stdout.d.ts +8 -0
  621. package/dist/utils/flush-stdout.d.ts.map +1 -0
  622. package/dist/utils/flush-stdout.js +23 -0
  623. package/dist/utils/flush-stdout.js.map +1 -0
  624. package/dist/utils/image-process.d.ts +2 -0
  625. package/dist/utils/image-process.d.ts.map +1 -1
  626. package/dist/utils/image-process.js +3 -3
  627. package/dist/utils/image-process.js.map +1 -1
  628. package/dist/utils/image-resize-core.js +2 -2
  629. package/dist/utils/image-resize-core.js.map +1 -1
  630. package/dist/utils/shell.d.ts +2 -0
  631. package/dist/utils/shell.d.ts.map +1 -1
  632. package/dist/utils/shell.js +19 -0
  633. package/dist/utils/shell.js.map +1 -1
  634. package/docs/cli.md +1 -1
  635. package/docs/development.md +0 -13
  636. package/docs/extensions.md +6 -4
  637. package/docs/flow.md +4 -62
  638. package/docs/forge-run-bootstrap.md +46 -0
  639. package/docs/humain-code-forge-architecture.md +1 -47
  640. package/docs/humain-code-forge-flow-walkthrough.md +1 -1
  641. package/docs/humain-code.md +2 -2
  642. package/docs/index.md +2 -1
  643. package/docs/keybindings.md +12 -0
  644. package/docs/llama-cpp.md +5 -5
  645. package/docs/models-configuration.md +4 -2
  646. package/docs/nvidia-rtx-llama-cpp.md +5 -5
  647. package/docs/providers.md +14 -9
  648. package/docs/quickstart.md +16 -2
  649. package/docs/rpc-commands.md +1 -1
  650. package/docs/run-preflight.md +1 -1
  651. package/docs/slash-commands.md +5 -3
  652. package/docs/tui.md +2 -0
  653. package/examples/README.md +0 -3
  654. package/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
  655. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  656. package/examples/extensions/gondolin/index.ts +4 -7
  657. package/examples/tsconfig.json +96 -76
  658. package/npm-shrinkwrap.json +285 -764
  659. package/package.json +24 -37
  660. package/schemas/keybindings.schema.json +32 -0
  661. package/schemas/models.schema.json +5 -1
  662. package/schemas/settings.schema.json +0 -13
  663. package/src/humain/web-access/UPSTREAM.md +52 -1
  664. package/src/humain/web-access/upstream.json +5 -5
  665. package/src/humain/web-access/vendor/CHANGELOG.md +29 -0
  666. package/dist/bundle/chunks/adaptive-peer-worker-X2ZNZE3S.js +0 -8
  667. package/dist/bundle/chunks/adaptive-session-host-7KDSQV5I.js +0 -162
  668. package/dist/bundle/chunks/anthropic-messages-TQK3FUV3.js +0 -68
  669. package/dist/bundle/chunks/azure-openai-responses-JY7OSLH2.js +0 -15
  670. package/dist/bundle/chunks/chunk-5L4PBYC7.js +0 -11
  671. package/dist/bundle/chunks/chunk-6PNQYO6A.js +0 -10
  672. package/dist/bundle/chunks/chunk-CRN54O4D.js +0 -24
  673. package/dist/bundle/chunks/chunk-CTU2ECLD.js +0 -7
  674. package/dist/bundle/chunks/chunk-DBL35X7L.js +0 -3
  675. package/dist/bundle/chunks/chunk-GME4AWDG.js +0 -23
  676. package/dist/bundle/chunks/chunk-GTILMMUF.js +0 -12
  677. package/dist/bundle/chunks/chunk-J57HOSWD.js +0 -21
  678. package/dist/bundle/chunks/chunk-KQM7ZGL6.js +0 -11
  679. package/dist/bundle/chunks/chunk-MX4Q4W6H.js +0 -214
  680. package/dist/bundle/chunks/chunk-NXA6NEHE.js +0 -54
  681. package/dist/bundle/chunks/chunk-PJACZCIR.js +0 -2
  682. package/dist/bundle/chunks/chunk-T5A6T24H.js +0 -93
  683. package/dist/bundle/chunks/chunk-WCFHG6NO.js +0 -16
  684. package/dist/bundle/chunks/chunk-ZJUU6WOV.js +0 -2052
  685. package/dist/bundle/chunks/compat-ZK2DIW3P.js +0 -15
  686. package/dist/bundle/chunks/dist-EY7YKQHB.js +0 -11
  687. package/dist/bundle/chunks/dist-J5IUPLMH.js +0 -37
  688. package/dist/bundle/chunks/dist-cjs-2SKN226B.js +0 -184
  689. package/dist/bundle/chunks/entry-AL54ZGYO.js +0 -2
  690. package/dist/bundle/chunks/es5-GYTRHFKS.js +0 -77
  691. package/dist/bundle/chunks/google-generative-ai-UL7YEQ6J.js +0 -21
  692. package/dist/bundle/chunks/google-vertex-OTMSPUYH.js +0 -26
  693. package/dist/bundle/chunks/host-75YAHLDR.js +0 -3
  694. package/dist/bundle/chunks/interactive-mode-IW4PIVAQ.js +0 -5
  695. package/dist/bundle/chunks/mistral-conversations-E72Y6OC3.js +0 -43
  696. package/dist/bundle/chunks/pdfjs-AKD6EBKN.js +0 -3614
  697. package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-FH3KJM4H.js +0 -326
  698. package/dist/bundle/chunks/pdfjs-openjpeg-SKR7C34X.js +0 -671
  699. package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-VUBL7UEE.js +0 -974
  700. package/dist/bundle/chunks/session-picker-DM6S37IF.js +0 -4
  701. package/dist/bundle/chunks/startup-ui-4GGLWNSU.js +0 -3
  702. package/dist/bundle/chunks/virtual-modules-TI3W24YL.js +0 -28
  703. package/dist/core/internal-process.d.ts +0 -23
  704. package/dist/core/internal-process.d.ts.map +0 -1
  705. package/dist/core/internal-process.js +0 -88
  706. package/dist/core/internal-process.js.map +0 -1
  707. package/dist/humain/adaptive-execution.d.ts +0 -51
  708. package/dist/humain/adaptive-execution.d.ts.map +0 -1
  709. package/dist/humain/adaptive-execution.js +0 -100
  710. package/dist/humain/adaptive-execution.js.map +0 -1
  711. package/dist/humain/adaptive-peer-process.d.ts +0 -44
  712. package/dist/humain/adaptive-peer-process.d.ts.map +0 -1
  713. package/dist/humain/adaptive-peer-process.js +0 -159
  714. package/dist/humain/adaptive-peer-process.js.map +0 -1
  715. package/dist/humain/adaptive-peer-worker.d.ts +0 -3
  716. package/dist/humain/adaptive-peer-worker.d.ts.map +0 -1
  717. package/dist/humain/adaptive-peer-worker.js +0 -122
  718. package/dist/humain/adaptive-peer-worker.js.map +0 -1
  719. package/dist/humain/adaptive-runtime-types.d.ts +0 -621
  720. package/dist/humain/adaptive-runtime-types.d.ts.map +0 -1
  721. package/dist/humain/adaptive-runtime-types.js +0 -3
  722. package/dist/humain/adaptive-runtime-types.js.map +0 -1
  723. package/dist/humain/adaptive-session-host.d.ts +0 -113
  724. package/dist/humain/adaptive-session-host.d.ts.map +0 -1
  725. package/dist/humain/adaptive-session-host.js +0 -1838
  726. package/dist/humain/adaptive-session-host.js.map +0 -1
  727. package/dist/utils/deprecation.d.ts +0 -4
  728. package/dist/utils/deprecation.d.ts.map +0 -1
  729. package/dist/utils/deprecation.js +0 -13
  730. package/dist/utils/deprecation.js.map +0 -1
  731. package/examples/plugins/pi-example-plugin/README.md +0 -38
  732. package/examples/plugins/pi-example-plugin/package.json +0 -10
  733. package/examples/plugins/pi-example-plugin/src/contract.ts +0 -13
  734. package/examples/plugins/pi-example-plugin/src/session.ts +0 -24
  735. package/examples/plugins/pi-example-plugin/src/tui.ts +0 -31
@@ -6,7 +6,7 @@
6
6
  import * as fs from "node:fs";
7
7
  import * as path from "node:path";
8
8
  import { Agent } from "@earendil-works/pi-agent-core";
9
- import { getSupportedThinkingLevels } from "@earendil-works/pi-ai";
9
+ import { clampThinkingLevel, modelsAreEqual } from "@earendil-works/pi-ai";
10
10
  import { isRetryableAssistantError, } from "@earendil-works/pi-ai/compat";
11
11
  import * as TuiLayouts from "@earendil-works/pi-tui";
12
12
  import { CombinedAutocompleteProvider, Container, fuzzyFilter, getCapabilities, hyperlink, Markdown, matchesKey, onCapabilitiesChange, Spacer, setCapabilityOverrides, setKeybindings, Text, TruncatedText, TuiAltScreen, TuiMainScreen, visibleWidth, } from "@earendil-works/pi-tui";
@@ -43,22 +43,32 @@ import { isInstallTelemetryEnabled } from "../../core/telemetry.js";
43
43
  import { withBuiltInRenderers } from "../../core/tools/renderers/index.js";
44
44
  import { hasTrustRequiringProjectResources, ProjectTrustStore } from "../../core/trust-manager.js";
45
45
  import { getUsageCostBreakdown } from "../../core/usage-totals.js";
46
+ import { getBranchSelection, isVirtualModel } from "../../core/virtual-models.js";
46
47
  import { loadMcpConfig } from "../../extensions/mcp/config.js";
48
+ import { bindClaudeUsageReconnect } from "../../extensions/usage/account-reconnect.js";
49
+ import { readClaudeUsage } from "../../extensions/usage/overview.js";
47
50
  import { resolveAdhdSessionMode } from "../../humain/adhd/index.js";
48
51
  import { renderHumainCodeIcon } from "../../humain/brand-logo.js";
49
52
  import { CAVEMAN_LEVELS, getCavemanDefaultMode, resolveCavemanSessionMode } from "../../humain/caveman/index.js";
50
53
  import { bindFlowAccountsHost, createFlowAccountReporter, FLOW_ACCOUNT_PERSISTENCE_NOTICE, flowUsageTargets, formatFlowAccountAdvanced, listFlowAccountMetadata, nodeLabelContainsStoredKey, readFlowNodeFallbackState, refreshFlowCatalog, updateFlowNodeFallback, } from "../../humain/flow-accounts-host.js";
51
54
  import { HUMAIN_FUSE_PROVIDER } from "../../humain/fuse-provider.js";
52
55
  import { HCODE_SESSION_ONLY_NOTICE } from "../../humain/hcode/account.js";
56
+ import { sameReference } from "../../humain/hcode/account-store.js";
57
+ import { watchHcodeCatalog } from "../../humain/hcode/catalog-watch.js";
58
+ import { hcodeDisplayName } from "../../humain/hcode/environment.js";
53
59
  import { HCODE_PROVIDER } from "../../humain/hcode/http.js";
54
- import { HCODE_LOGIN_LABEL } from "../../humain/hcode/provider.js";
55
- import { assertHcodeSelection, captureHcodeSelection, HCODE_SELECTION_CHANGED_MESSAGE, HCODE_UNSUPPORTED_THINKING_MESSAGE, } from "../../humain/hcode/selection.js";
60
+ import { HCODE_LOGIN_MISMATCH_DETAILS, hcodeEmptyCatalogNotice, hcodeEmptyCatalogReason, hcodeLoginAvailability, hcodeSignedInElsewhereNotice, } from "../../humain/hcode/login-copy.js";
61
+ import { availableHcodeSelection, HCODE_SELECTION_CHANGED_MESSAGE, HCODE_UNSUPPORTED_THINKING_MESSAGE, hcodeExcludedSelection, hcodeSelectionUnavailable, } from "../../humain/hcode/selection.js";
56
62
  import { ACCOUNT_LOGIN_LABEL, API_KEY_LOGIN_LABEL, HUMAIN_LOGIN_LABEL, HUMAIN_SHIMMER_COLORS, humainLoginProviders, topLevelLoginOptions, } from "../../humain/login-menu.js";
57
63
  import { RUNTIME_MODES, readDefaultMode, resolveSessionMode as resolvePonytailSessionMode, } from "../../humain/ponytail/index.js";
58
- import { raceWithAbortSignal } from "../../utils/abort.js";
64
+ import { isRemoteHostEnabled } from "../../humain/remote/enablement.js";
65
+ import { watchCurrentBranch } from "../../humain/remote/host-watch.js";
66
+ import { bindRemoteTerminalSession, runRemoteCommand, } from "../../humain/remote/terminal.js";
67
+ import { raceWithAbortSignal, timerSignal } from "../../utils/abort.js";
59
68
  import { getChangelogPath, getNewEntries, normalizeChangelogLinks, parseChangelog } from "../../utils/changelog.js";
60
69
  import { copyToClipboard, readClipboardFilePaths, readClipboardText } from "../../utils/clipboard.js";
61
70
  import { readClipboardImage, writePastedImage } from "../../utils/clipboard-image.js";
71
+ import { flushStdout } from "../../utils/flush-stdout.js";
62
72
  import { parseGitUrl } from "../../utils/git.js";
63
73
  import { ensurePngTranscoderOnFirstUse } from "../../utils/image-convert.js";
64
74
  import { getCwdRelativePath, shortenHomePath } from "../../utils/paths.js";
@@ -70,6 +80,7 @@ import { checkForNewPiVersion } from "../../utils/version-check.js";
70
80
  import { waitForSignalShutdown } from "../signal-shutdown.js";
71
81
  import { reportBug } from "./bug-report.js";
72
82
  import { createChatViewport } from "./chat-viewport.js";
83
+ import { AccountPickerComponent, } from "./components/account-picker.js";
73
84
  import { ArminComponent } from "./components/armin.js";
74
85
  import { AssistantMessageComponent } from "./components/assistant-message.js";
75
86
  import { BashExecutionComponent } from "./components/bash-execution.js";
@@ -95,7 +106,7 @@ import { ScopedModelsSelectorComponent } from "./components/scoped-models-select
95
106
  import { SessionSelectorComponent } from "./components/session-selector.js";
96
107
  import { SettingsSelectorComponent } from "./components/settings-selector.js";
97
108
  import { SkillInvocationMessageComponent } from "./components/skill-invocation-message.js";
98
- import { AdaptiveStatusIndicator, BranchSummaryStatusIndicator, CompactionStatusIndicator, IdleStatus, RetryStatusIndicator, WorkingStatusIndicator, } from "./components/status-indicator.js";
109
+ import { BranchSummaryStatusIndicator, CompactionStatusIndicator, IdleStatus, RetryStatusIndicator, WorkingStatusIndicator, } from "./components/status-indicator.js";
99
110
  import { ThemedText } from "./components/themed-text.js";
100
111
  import { ThinkingSelectorComponent } from "./components/thinking-selector.js";
101
112
  import { ToolExecutionComponent } from "./components/tool-execution.js";
@@ -105,9 +116,9 @@ import { TrustSelectorComponent } from "./components/trust-selector.js";
105
116
  import { UserMessageComponent } from "./components/user-message.js";
106
117
  import { UserMessageSelectorComponent } from "./components/user-message-selector.js";
107
118
  import { editInExternalEditor } from "./external-editor.js";
108
- import { refreshModelCatalogs, refreshStartupModelCatalogs } from "./model-catalog-refresh.js";
119
+ import { checkWatchedHcodeCatalog, refreshModelCatalogs, refreshStartupModelCatalogs, retryHcodeCatalog, } from "./model-catalog-refresh.js";
109
120
  import { getModelSearchText } from "./model-search.js";
110
- import { formatOAuthAccountOption, formatOAuthAccountResetTime, } from "./oauth-account-format.js";
121
+ import { formatOAuthAccountOption, formatOAuthAccountResetTime, formatOAuthAccountUsage, subscriptionAccountUsage, } from "./oauth-account-format.js";
111
122
  import { ProgramStatusReporter } from "./program-status-reporter.js";
112
123
  import { shareSession } from "./session-share.js";
113
124
  import { DEFAULT_THEME_NAME, getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getSelectListTheme, getThemeByName, onThemeChange, setRegisteredThemes, stopThemeWatcher, Theme, theme, } from "./theme/theme.js";
@@ -207,6 +218,13 @@ function llamaCppPostLoginGuidance(actionLabel, loadedModelCount) {
207
218
  : `${actionLabel}. Use /model to select a loaded llama.cpp model, or /llama to manage models.`;
208
219
  }
209
220
  const RADIUS_LOGIN_INTRO = "Radius is a service by Earendil Works";
221
+ // Bounds a stalled HUMAIN Code sign-in check; its config and discovery requests time out sooner.
222
+ const HCODE_LOGIN_CHECK_TIMEOUT_MS = 10_000;
223
+ // Inline spinner for a /login row that is waiting on its connection check.
224
+ const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
225
+ const SPINNER_INTERVAL_MS = 80;
226
+ // Footer status key for the signed-in-without-models state.
227
+ const HCODE_STATUS_KEY = "humain-code";
210
228
  const EXTERNAL_SOURCE_NOTICE = "External sources are read-only in /accounts. Change the runtime, environment or configuration outside /accounts. Runtime overrides stored selection; stored credentials block models.json; models.json precedes ambient credentials. Selection is global. Stored configuration references cannot be replaced here; use /logout to explicitly remove the stored credential before selecting an account.";
211
229
  const AUTH_TYPE_ORDER = { oauth: 0, api_key: 1 };
212
230
  function createFuzzyAutocompleteItems(items, prefix, getSearchText, toAutocompleteItem) {
@@ -247,6 +265,41 @@ function formatLoginProviderCompletionDescription(provider) {
247
265
  .join("/");
248
266
  return provider.name === provider.id ? authTypes : `${provider.name} · ${authTypes}`;
249
267
  }
268
+ /** Assistant diagnostics that list reasoning a provider withheld from the model, by diagnostic type. */
269
+ const REASONING_DROP_DIAGNOSTICS = new Map([
270
+ [
271
+ "anthropic_input_transformations",
272
+ { provider: "Anthropic", droppedType: "thinking_dropped", noun: ["thinking block", "thinking blocks"] },
273
+ ],
274
+ [
275
+ "openai_input_transformations",
276
+ { provider: "OpenAI", droppedType: "reasoning", noun: ["reasoning item", "reasoning items"] },
277
+ ],
278
+ ]);
279
+ /** Count the reasoning blocks a provider reported as withheld from the request that produced `message`. */
280
+ function getDroppedReasoning(message) {
281
+ for (const diagnostic of message.diagnostics ?? []) {
282
+ const kind = REASONING_DROP_DIAGNOSTICS.get(diagnostic.type);
283
+ if (!kind)
284
+ continue;
285
+ // Session data: diagnostics details are untyped JSON.
286
+ const transformations = diagnostic.details?.transformations;
287
+ if (!Array.isArray(transformations))
288
+ continue;
289
+ const dropped = transformations.filter((transformation) => typeof transformation === "object" &&
290
+ transformation !== null &&
291
+ transformation.type === kind.droppedType);
292
+ if (dropped.length === 0)
293
+ continue;
294
+ const reasons = new Set();
295
+ for (const transformation of dropped) {
296
+ if (typeof transformation.reason === "string")
297
+ reasons.add(transformation.reason);
298
+ }
299
+ return { diagnostic: kind, count: dropped.length, reasons: [...reasons] };
300
+ }
301
+ return undefined;
302
+ }
250
303
  export class InteractiveMode {
251
304
  extensionOverlays = new Map();
252
305
  runtimeHost;
@@ -281,7 +334,6 @@ export class InteractiveMode {
281
334
  onInputCallback;
282
335
  pendingUserInputs = [];
283
336
  activeStatusIndicator = undefined;
284
- adaptiveStatus;
285
337
  activeWorkingIndicatorEmbedded = false;
286
338
  idleStatus = new IdleStatus();
287
339
  workingMessage = undefined;
@@ -297,6 +349,10 @@ export class InteractiveMode {
297
349
  startupNoticesShown = false;
298
350
  /** The /model save-as-default tip is shown once per run. */
299
351
  modelSaveTipShown = false;
352
+ /** Background re-check of an empty HUMAIN Code catalog after sign-in, whether its last load failed, and its status line. */
353
+ hcodeCatalogWatch;
354
+ hcodeCatalogFailed = false;
355
+ hcodeCatalogStatus;
300
356
  anthropicSubscriptionWarningShown = false;
301
357
  // Status line tracking (for mutating immediately-sequential status updates)
302
358
  lastStatusSpacer = undefined;
@@ -340,6 +396,7 @@ export class InteractiveMode {
340
396
  shutdownRequested = false;
341
397
  /** Releases the Flow accounts host bound to the current session's registry. */
342
398
  flowAccountsRelease;
399
+ claudeUsageReconnectRelease;
343
400
  /** Set while a Flow account interaction is open; cancels its login dialogs when the host aborts. */
344
401
  activeFlowAccountsSignal;
345
402
  /** Session-bound usage reporter; created lazily and cancelled when the host is released. */
@@ -369,6 +426,9 @@ export class InteractiveMode {
369
426
  // Custom header from extension (undefined = use built-in header)
370
427
  customHeader = undefined;
371
428
  options;
429
+ remoteTerminalLifetime;
430
+ remoteTerminalStopped = false;
431
+ remoteTerminal;
372
432
  onRightClickPaste = () => {
373
433
  void this.handleRightClickPaste();
374
434
  };
@@ -395,11 +455,15 @@ export class InteractiveMode {
395
455
  this.options = { ...options, tuiMode };
396
456
  this.autoTrustOnReloadCwd = options.autoTrustOnReloadCwd;
397
457
  this.runtimeHost.setBeforeSessionInvalidate(() => {
458
+ this.remoteTerminal = undefined;
459
+ // The next session may bring a new model runtime; its account starts without the re-check.
460
+ this.hcodeCatalogWatch?.stop();
398
461
  this.resetExtensionUI();
399
462
  });
400
463
  this.runtimeHost.setRebindSession(async () => {
401
464
  await this.rebindCurrentSession({ renderBeforeBind: true });
402
465
  this.themeController.applyFromSettings();
466
+ this.showRuntimeDiagnostics(this.runtimeHost.takeUnreportedDiagnostics());
403
467
  });
404
468
  this.version = VERSION;
405
469
  this.renderer = createInteractiveTui({
@@ -537,11 +601,14 @@ export class InteractiveMode {
537
601
  if (loginCommand) {
538
602
  loginCommand.getArgumentCompletions = (prefix) => {
539
603
  const providers = getLoginProviderCompletionOptions(this.getLoginProviderOptions());
540
- return createFuzzyAutocompleteItems(providers, prefix, getLoginProviderSearchText, (provider) => ({
604
+ const items = createFuzzyAutocompleteItems(providers, prefix, getLoginProviderSearchText, (provider) => ({
541
605
  value: provider.id,
542
606
  label: provider.id,
543
607
  description: formatLoginProviderCompletionDescription(provider),
544
- }));
608
+ })) ?? [];
609
+ if ("status".startsWith(prefix.trim().toLowerCase()))
610
+ items.push({ value: "status", label: "status", description: "HUMAIN Code sign-in status" });
611
+ return items.length ? items : null;
545
612
  };
546
613
  }
547
614
  const accountsCommand = slashCommands.find((command) => command.name === "accounts");
@@ -697,6 +764,7 @@ export class InteractiveMode {
697
764
  });
698
765
  nextUi.setClearOnShrink(clearOnShrink);
699
766
  nextUi.onDebug = onDebug;
767
+ nextUi.setSuspendSignalHandler(() => this.handleCtrlZ());
700
768
  if (nextUi instanceof TuiMainScreen && this.mainScreenRenderState) {
701
769
  nextUi.restoreRenderState(this.mainScreenRenderState);
702
770
  }
@@ -766,6 +834,8 @@ export class InteractiveMode {
766
834
  this.ui.invalidate();
767
835
  this.ui.requestRender();
768
836
  });
837
+ // An external SIGTSTP (kill -TSTP) restores the terminal like Ctrl+Z (#12272).
838
+ this.ui.setSuspendSignalHandler(() => this.handleCtrlZ());
769
839
  // Start the UI before initializing extensions so session_start handlers can use interactive dialogs
770
840
  this.ui.start();
771
841
  this.isInitialized = true;
@@ -899,6 +969,15 @@ export class InteractiveMode {
899
969
  */
900
970
  async run() {
901
971
  await this.init();
972
+ const startupSession = this.session;
973
+ const hcode = startupSession.modelRuntime.hcode;
974
+ const savedSignIn = hcode.account.status(hcode.environment.id);
975
+ if (!savedSignIn) {
976
+ const elsewhere = hcodeSignedInElsewhereNotice(hcode.environment.id, this.session.modelRuntime.hcodeSignedInElsewhere());
977
+ if (elsewhere)
978
+ this.showStatus(elsewhere);
979
+ }
980
+ let restoringHcode;
902
981
  if (!(process.env[ENV_OFFLINE] || process.env.PI_OFFLINE)) {
903
982
  const controller = new AbortController();
904
983
  const timeout = setTimeout(() => controller.abort(), 15_000);
@@ -906,6 +985,27 @@ export class InteractiveMode {
906
985
  .then(() => this.updateAvailableProviderCount())
907
986
  .catch(() => { })
908
987
  .finally(() => clearTimeout(timeout));
988
+ // Read the saved account's catalog without holding open a login or model selector.
989
+ const runtime = startupSession.modelRuntime;
990
+ if (savedSignIn && !runtime.hcodeCatalogLoaded()) {
991
+ const saved = this.options.restoreSavedHcodeModel && !startupSession.agent.selectedModel
992
+ ? (getBranchSelection(startupSession.sessionManager.getBranch(), (provider, id) => runtime.getModel(provider, id)) ?? {
993
+ provider: this.settingsManager.getDefaultProvider(),
994
+ modelId: this.settingsManager.getDefaultModel(),
995
+ })
996
+ : undefined;
997
+ const savedId = saved?.provider === HCODE_PROVIDER ? saved.modelId : undefined;
998
+ const refresh = this.refreshSavedHcodeCatalog(savedId);
999
+ if (savedId)
1000
+ restoringHcode = refresh;
1001
+ }
1002
+ // The readiness check outlives unrelated provider refreshes.
1003
+ const readiness = this.checkHcodeLogin(AbortSignal.timeout(15_000));
1004
+ if (savedSignIn)
1005
+ void this.showStartupHcodeSignIn(savedSignIn, readiness);
1006
+ }
1007
+ else if (savedSignIn) {
1008
+ this.showStatus(`${hcodeDisplayName(hcode.environment.id)}: signed in · offline`);
909
1009
  }
910
1010
  // Start version check asynchronously
911
1011
  checkForNewPiVersion(this.version).then((newRelease) => {
@@ -935,17 +1035,7 @@ export class InteractiveMode {
935
1035
  });
936
1036
  // Show startup warnings
937
1037
  const { migratedProviders, startupDiagnostics, modelFallbackMessage, initialMessage, initialImages, initialMessages, } = this.options;
938
- for (const diagnostic of startupDiagnostics ?? []) {
939
- if (diagnostic.type === "error") {
940
- this.showError(diagnostic.message);
941
- }
942
- else if (diagnostic.type === "warning") {
943
- this.showWarning(diagnostic.message);
944
- }
945
- else {
946
- this.showStatus(diagnostic.message);
947
- }
948
- }
1038
+ this.showRuntimeDiagnostics(startupDiagnostics ?? []);
949
1039
  if (migratedProviders && migratedProviders.length > 0) {
950
1040
  this.showWarning(`Migrated credentials to auth.json: ${migratedProviders.join(", ")}`);
951
1041
  }
@@ -953,7 +1043,7 @@ export class InteractiveMode {
953
1043
  if (modelsJsonError) {
954
1044
  this.showError(`models.json error: ${modelsJsonError}`);
955
1045
  }
956
- if (modelFallbackMessage) {
1046
+ if (modelFallbackMessage && !restoringHcode) {
957
1047
  this.showWarning(modelFallbackMessage);
958
1048
  }
959
1049
  const crash = takeUnnotifiedCrash();
@@ -962,7 +1052,9 @@ export class InteractiveMode {
962
1052
  this.showWarning(`${APP_TITLE} crashed on ${when} (${crash.message}). Run /bug to export a report zip; the crash details are attached automatically.`);
963
1053
  }
964
1054
  void this.maybeWarnAboutAnthropicSubscriptionAuth();
965
- // Process initial messages
1055
+ // Initial and typed prompts use the saved model, not an uninitialized selection.
1056
+ if (initialMessage || initialMessages?.length)
1057
+ await restoringHcode;
966
1058
  if (initialMessage) {
967
1059
  try {
968
1060
  await this.session.prompt(initialMessage, { images: initialImages });
@@ -986,6 +1078,8 @@ export class InteractiveMode {
986
1078
  // Main interactive loop
987
1079
  while (true) {
988
1080
  const userInput = await this.getUserInput();
1081
+ if (this.session === startupSession && !startupSession.agent.selectedModel)
1082
+ await restoringHcode;
989
1083
  const session = this.session;
990
1084
  const messages = session.messages;
991
1085
  try {
@@ -1005,6 +1099,56 @@ export class InteractiveMode {
1005
1099
  }
1006
1100
  }
1007
1101
  }
1102
+ async refreshSavedHcodeCatalog(savedId) {
1103
+ const session = this.session;
1104
+ const runtime = session.modelRuntime;
1105
+ const initialScope = session.scopedModels;
1106
+ const reference = runtime.hcode.account.status(runtime.hcode.environment.id);
1107
+ const isCurrent = () => this.session === session &&
1108
+ sameReference(runtime.hcode.account.status(runtime.hcode.environment.id), reference);
1109
+ const signal = AbortSignal.timeout(15_000);
1110
+ const result = await retryHcodeCatalog(runtime, signal).catch(() => undefined);
1111
+ if (!isCurrent())
1112
+ return;
1113
+ this.hcodeCatalogFailed = !result || result.aborted || result.errors.size > 0;
1114
+ if (this.options.restoreSavedModelScope && !this.hcodeCatalogFailed && session.scopedModels === initialScope) {
1115
+ const patterns = this.settingsManager.getEnabledModels();
1116
+ if (patterns?.length) {
1117
+ const { scopedModels } = resolveModelScopeFromModels(patterns, runtime.getAvailableSnapshot());
1118
+ session.setScopedModels(scopedModels);
1119
+ }
1120
+ }
1121
+ if (savedId && !session.agent.selectedModel && !session.hasRequestedModelSelection) {
1122
+ const model = availableHcodeSelection(runtime, savedId);
1123
+ if (model) {
1124
+ const existing = session.sessionManager.buildSessionContext();
1125
+ const recorded = session.sessionManager
1126
+ .getBranch()
1127
+ .findLast((entry) => entry.type === "thinking_level_change");
1128
+ const requested = (existing.messages.length
1129
+ ? recorded?.thinkingLevel
1130
+ : this.settingsManager.getModelThinkingLevel(model.provider, model.id)) ??
1131
+ this.settingsManager.getDefaultThinkingLevel() ??
1132
+ DEFAULT_THINKING_LEVEL;
1133
+ const thinkingLevel = clampThinkingLevel(model, requested);
1134
+ try {
1135
+ await session.setModel(model, { thinkingLevel, signal });
1136
+ if (thinkingLevel !== requested)
1137
+ this.showStatus(`Thinking level adjusted from ${requested} to ${thinkingLevel}.`);
1138
+ }
1139
+ catch {
1140
+ if (isCurrent() && !session.agent.selectedModel)
1141
+ this.showWarning("Couldn't restore the saved HUMAIN Code model. Use /model to retry.");
1142
+ }
1143
+ }
1144
+ else {
1145
+ this.showWarning(this.hcodeCatalogFailed
1146
+ ? "Signed in to HUMAIN Code, but the model list could not be loaded. Use /model to retry."
1147
+ : hcodeSelectionUnavailable(runtime, [savedId]));
1148
+ }
1149
+ }
1150
+ await this.updateAvailableProviderCount();
1151
+ }
1008
1152
  async checkForPackageUpdates() {
1009
1153
  if (process.env[ENV_OFFLINE] || process.env.PI_OFFLINE) {
1010
1154
  return [];
@@ -1732,6 +1876,19 @@ export class InteractiveMode {
1732
1876
  this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);
1733
1877
  }
1734
1878
  }
1879
+ showRuntimeDiagnostics(diagnostics) {
1880
+ for (const diagnostic of diagnostics) {
1881
+ if (diagnostic.type === "error") {
1882
+ this.showError(diagnostic.message);
1883
+ }
1884
+ else if (diagnostic.type === "warning") {
1885
+ this.showWarning(diagnostic.message);
1886
+ }
1887
+ else {
1888
+ this.showStatus(diagnostic.message);
1889
+ }
1890
+ }
1891
+ }
1735
1892
  async rebindCurrentSession(options = {}) {
1736
1893
  const session = this.session;
1737
1894
  this.unsubscribe?.();
@@ -1770,6 +1927,7 @@ export class InteractiveMode {
1770
1927
  await this.runtimeHost.dispose();
1771
1928
  }
1772
1929
  finally {
1930
+ await flushStdout();
1773
1931
  process.exit(1);
1774
1932
  }
1775
1933
  }
@@ -1930,8 +2088,7 @@ export class InteractiveMode {
1930
2088
  }
1931
2089
  setEditorWorkingStatusIndicator(indicator) {
1932
2090
  this.defaultEditor.setWorkingStatusIndicator(undefined);
1933
- // Keep adaptive status separate from the editor border so its detail shortcut stays visible.
1934
- if (indicator instanceof AdaptiveStatusIndicator || !isEmbeddedStatus(this.editor))
2091
+ if (!isEmbeddedStatus(this.editor))
1935
2092
  return false;
1936
2093
  this.editor.setWorkingStatusIndicator(indicator);
1937
2094
  return true;
@@ -1967,16 +2124,6 @@ export class InteractiveMode {
1967
2124
  }
1968
2125
  }
1969
2126
  showWorkingStatusIndicator() {
1970
- if (this.adaptiveStatus) {
1971
- if (this.activeStatusIndicator instanceof AdaptiveStatusIndicator) {
1972
- this.activeStatusIndicator.setStatus(this.adaptiveStatus);
1973
- return;
1974
- }
1975
- const indicator = new AdaptiveStatusIndicator(this.ui, this.adaptiveStatus, () => this.setToolsExpanded(false), this.workingIndicatorOptions);
1976
- this.showStatusIndicator(indicator);
1977
- indicator.setExpanded(this.toolOutputExpanded);
1978
- return;
1979
- }
1980
2127
  const colorFn = isEmbeddedStatus(this.editor)
1981
2128
  ? (text) => (this.editor.borderColor ?? theme.getThinkingBorderColor(this.session.thinkingLevel || "off"))(text)
1982
2129
  : undefined;
@@ -1989,7 +2136,7 @@ export class InteractiveMode {
1989
2136
  this.ui.requestRender();
1990
2137
  return;
1991
2138
  }
1992
- if ((this.session.isStreaming || this.adaptiveStatus) && this.activeStatusIndicator?.kind !== "working") {
2139
+ if (this.session.isStreaming && this.activeStatusIndicator?.kind !== "working") {
1993
2140
  this.showWorkingStatusIndicator();
1994
2141
  }
1995
2142
  this.ui.requestRender();
@@ -2062,9 +2209,6 @@ export class InteractiveMode {
2062
2209
  this.renderWidgets();
2063
2210
  }
2064
2211
  resetExtensionUI() {
2065
- this.adaptiveStatus = undefined;
2066
- if (this.activeStatusIndicator instanceof AdaptiveStatusIndicator)
2067
- this.clearStatusIndicator();
2068
2212
  this.disposeActiveSelector();
2069
2213
  // Release first: aborting resolves pending account dialogs before their UI is hidden.
2070
2214
  this.releaseFlowAccountsHost();
@@ -2080,6 +2224,9 @@ export class InteractiveMode {
2080
2224
  this.setExtensionHeader(undefined);
2081
2225
  this.clearExtensionWidgets();
2082
2226
  this.footerDataProvider.clearExtensionStatuses();
2227
+ // The HUMAIN Code status line belongs to the account, not to an extension.
2228
+ if (this.hcodeCatalogStatus)
2229
+ this.footerDataProvider.setExtensionStatus(HCODE_STATUS_KEY, this.hcodeCatalogStatus);
2083
2230
  this.footer.invalidate();
2084
2231
  this.autocompleteProviderWrappers = [];
2085
2232
  this.extensionEditorAccent = undefined;
@@ -2231,8 +2378,7 @@ export class InteractiveMode {
2231
2378
  setStatus: (key, text) => this.setExtensionStatus(key, text),
2232
2379
  setWorkingMessage: (message) => {
2233
2380
  this.workingMessage = message;
2234
- if (this.activeStatusIndicator?.kind === "working" &&
2235
- !(this.activeStatusIndicator instanceof AdaptiveStatusIndicator)) {
2381
+ if (this.activeStatusIndicator?.kind === "working") {
2236
2382
  this.activeStatusIndicator.setMessage(message ?? this.defaultWorkingMessage);
2237
2383
  }
2238
2384
  },
@@ -2286,12 +2432,15 @@ export class InteractiveMode {
2286
2432
  /**
2287
2433
  * Show an extension dialog in the editor slot.
2288
2434
  * Dialogs form a stack: a new dialog hides the visible one, and closing the visible dialog shows
2289
- * the previous one again. Every dialog stays answerable, so no dialog promise is left pending,
2290
- * and dialogs opened from inside another dialog (for example a confirm from a custom component) work.
2435
+ * the previous one again, unless it requires uninterrupted local attention (Remote consent).
2436
+ * Dialogs opened from inside another dialog can still return to their parent.
2291
2437
  */
2292
- pushExtensionDialog(component, blocked, cancel) {
2438
+ pushExtensionDialog(component, blocked, cancel, visibility) {
2293
2439
  this.disposeActiveSelector();
2294
- this.extensionDialogs.push({ component, blocked, cancel });
2440
+ const covered = this.extensionDialogs.at(-1);
2441
+ this.extensionDialogs.push({ component, blocked, cancel, dismissOnCover: visibility === "foreground-only" });
2442
+ if (covered?.dismissOnCover)
2443
+ covered.cancel?.();
2295
2444
  this.showTopExtensionDialog();
2296
2445
  }
2297
2446
  /** Close every extension dialog and settle its pending promise, then show the editor. */
@@ -2353,6 +2502,84 @@ export class InteractiveMode {
2353
2502
  });
2354
2503
  return result === "Yes";
2355
2504
  }
2505
+ async handleRemoteCommand(input) {
2506
+ if (this.remoteTerminalStopped)
2507
+ return;
2508
+ const label = hcodeDisplayName(this.session.modelRuntime.hcode.environment.id);
2509
+ const owner = this.runtimeHost.sessionLifetime;
2510
+ let flags = this.options.featureFlags;
2511
+ const lookup = this.options.remoteFlagLookup;
2512
+ if (lookup) {
2513
+ try {
2514
+ flags = await lookup(owner);
2515
+ }
2516
+ catch {
2517
+ // Owner decision: a failed lookup must not block Remote; detail is withheld because it may carry credentials.
2518
+ this.showWarning(`${label}: Remote flag lookup failed; Remote stays available.`);
2519
+ }
2520
+ if (this.remoteTerminalStopped || owner.aborted)
2521
+ return;
2522
+ }
2523
+ // Disabled: no binding, broker, relay or pairing is ever touched.
2524
+ if (!isRemoteHostEnabled(flags)) {
2525
+ this.showWarning(`${label}: Remote is not enabled.`);
2526
+ return;
2527
+ }
2528
+ const binding = this.options.remoteWatch;
2529
+ if (binding)
2530
+ this.remoteTerminalLifetime ??= new AbortController();
2531
+ const terminal = this.remoteTerminalLifetime?.signal;
2532
+ if (owner.aborted || terminal?.aborted)
2533
+ return;
2534
+ const remote = this.remoteTerminal;
2535
+ const lifetime = remote?.owner === owner ? remote.lifetime : terminal ? AbortSignal.any([owner, terminal]) : owner;
2536
+ const ui = {
2537
+ notice: (message) => {
2538
+ if (!lifetime.aborted)
2539
+ this.showWarning(message);
2540
+ },
2541
+ confirm: (title, message, signal) => this.showRemoteConfirm(title, message, signal ? AbortSignal.any([signal, lifetime]) : lifetime),
2542
+ };
2543
+ if (binding && remote?.owner !== owner) {
2544
+ this.remoteTerminal = {
2545
+ owner,
2546
+ lifetime,
2547
+ session: bindRemoteTerminalSession({
2548
+ ...binding,
2549
+ environment: this.session.modelRuntime.hcode.environment,
2550
+ lifetime,
2551
+ source: watchCurrentBranch(this.session),
2552
+ ui,
2553
+ }),
2554
+ };
2555
+ }
2556
+ await runRemoteCommand(input, ui, this.remoteTerminal?.session, this.session.modelRuntime.hcode.environment.id);
2557
+ }
2558
+ /** Remote consent is local UI, not an agent question or a published blocked status. */
2559
+ showRemoteConfirm(title, message, signal) {
2560
+ if (signal?.aborted ||
2561
+ this.extensionDialogs.length ||
2562
+ this.activeSelectorToken ||
2563
+ this.extensionOverlays.size ||
2564
+ this.editorContainer.children[0] !== this.editor) {
2565
+ return Promise.resolve(false);
2566
+ }
2567
+ return new Promise((resolve) => {
2568
+ const finish = (allow) => {
2569
+ const current = this.extensionDialogs.at(-1)?.component === selector &&
2570
+ this.editorContainer.children[0] === selector &&
2571
+ !this.extensionOverlays.size;
2572
+ signal?.removeEventListener("abort", cancel);
2573
+ this.removeExtensionDialog(selector);
2574
+ resolve(allow && current && !signal?.aborted);
2575
+ };
2576
+ const cancel = () => finish(false);
2577
+ const selector = new ExtensionSelectorComponent(`${title}\n${message}`, ["No", "Yes"], (option) => finish(option === "Yes"), cancel);
2578
+ signal?.addEventListener("abort", cancel, { once: true });
2579
+ // Never resume a preselected Remote action after a different dialog takes focus.
2580
+ this.pushExtensionDialog(selector, undefined, cancel, "foreground-only");
2581
+ });
2582
+ }
2356
2583
  async promptForMissingSessionCwd(error) {
2357
2584
  const confirmed = await this.showExtensionConfirm("Session cwd not found", formatMissingSessionCwdPrompt(error.issue));
2358
2585
  return confirmed ? error.issue.fallbackCwd : undefined;
@@ -2546,7 +2773,12 @@ export class InteractiveMode {
2546
2773
  const w = c.width;
2547
2774
  return w ? { width: w } : undefined;
2548
2775
  };
2549
- overlayHandle = this.ui.showOverlay(c, resolveOptions());
2776
+ const overlayOptions = resolveOptions();
2777
+ const covered = this.extensionDialogs.at(-1);
2778
+ // Dismiss before mounting so dialog cleanup cannot steal the overlay's focus.
2779
+ if (covered?.dismissOnCover)
2780
+ covered.cancel?.();
2781
+ overlayHandle = this.ui.showOverlay(c, overlayOptions);
2550
2782
  this.extensionOverlays.set(overlayHandle, removeOverlay);
2551
2783
  // Expose handle to caller for visibility control
2552
2784
  options?.onHandle?.(overlayHandle);
@@ -2699,6 +2931,20 @@ export class InteractiveMode {
2699
2931
  }
2700
2932
  const image = await readClipboardImage();
2701
2933
  if (image) {
2934
+ const model = this.session.model;
2935
+ if (!this.isBashMode && model && !isVirtualModel(model) && !model.input.includes("image")) {
2936
+ const candidates = [
2937
+ ...new Set(this.session.modelRuntime
2938
+ .getAvailableSnapshot()
2939
+ .filter((candidate) => candidate.input.includes("image"))
2940
+ .map(({ provider, id }) => `${provider}/${id}`.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu, ""))),
2941
+ ];
2942
+ const guidance = candidates.length
2943
+ ? `Choose an image-capable model with /model: ${candidates.slice(0, 3).join(", ")}${candidates.length > 3 ? ", …" : ""}.`
2944
+ : "No image-capable models are available.";
2945
+ this.showStatus(`Image not attached. ${guidance} Send your text without the image.`);
2946
+ return;
2947
+ }
2702
2948
  this.editor.insertTextAtCursor?.(writePastedImage(image));
2703
2949
  this.ui.requestRender();
2704
2950
  return;
@@ -2757,6 +3003,11 @@ export class InteractiveMode {
2757
3003
  this.editor.setText("");
2758
3004
  return;
2759
3005
  }
3006
+ if (/^\/remote(?:\s|$)/.test(text)) {
3007
+ this.editor.setText("");
3008
+ await this.handleRemoteCommand(text);
3009
+ return;
3010
+ }
2760
3011
  if (text === "/share") {
2761
3012
  await this.handleShareCommand();
2762
3013
  this.editor.setText("");
@@ -2959,12 +3210,6 @@ export class InteractiveMode {
2959
3210
  this.footer.markActivity();
2960
3211
  }
2961
3212
  switch (event.type) {
2962
- case "adaptive_status":
2963
- this.adaptiveStatus = event.status;
2964
- if (this.workingVisible)
2965
- this.showWorkingStatusIndicator();
2966
- this.ui.requestRender();
2967
- break;
2968
3213
  case "agent_start":
2969
3214
  this.pendingTools.clear();
2970
3215
  // Restore main escape handler if retry handler is still active
@@ -3046,6 +3291,10 @@ export class InteractiveMode {
3046
3291
  this.footer.invalidate();
3047
3292
  this.updateEditorBorderColor();
3048
3293
  break;
3294
+ case "request_thinking_clamped":
3295
+ case "request_images_omitted":
3296
+ this.showStatus(event.message);
3297
+ break;
3049
3298
  case "message_start":
3050
3299
  if (event.message.role === "custom") {
3051
3300
  this.addMessageToChat(event.message);
@@ -3141,6 +3390,9 @@ export class InteractiveMode {
3141
3390
  }
3142
3391
  this.ui.requestRender();
3143
3392
  break;
3393
+ case "thinking_level_adjusted":
3394
+ this.showStatus(event.notice);
3395
+ break;
3144
3396
  case "bash_execution_update":
3145
3397
  // The bash execution callback handles TUI output rendering.
3146
3398
  break;
@@ -3193,9 +3445,7 @@ export class InteractiveMode {
3193
3445
  if (this.settingsManager.getShowTerminalProgress()) {
3194
3446
  this.ui.terminal.setProgress(false);
3195
3447
  }
3196
- // Primary agent_end precedes adaptive Check/review and is not run settlement.
3197
- if (!this.adaptiveStatus)
3198
- this.clearStatusIndicator("working");
3448
+ this.clearStatusIndicator("working");
3199
3449
  if (this.streamingComponent) {
3200
3450
  this.chatContainer.removeChild(this.streamingComponent);
3201
3451
  this.streamingComponent = undefined;
@@ -3205,11 +3455,6 @@ export class InteractiveMode {
3205
3455
  this.ui.requestRender();
3206
3456
  break;
3207
3457
  case "agent_settled":
3208
- if (this.adaptiveStatus) {
3209
- this.adaptiveStatus = undefined;
3210
- this.workingMessage = undefined;
3211
- this.clearStatusIndicator("working");
3212
- }
3213
3458
  // The session records deferred user bash results when the run settles; show them there too.
3214
3459
  this.flushPendingBashComponents();
3215
3460
  this.ui.requestRender();
@@ -3647,42 +3892,30 @@ export class InteractiveMode {
3647
3892
  this.chatContainer.addChild(new Spacer(1));
3648
3893
  this.chatContainer.addChild(new ThemedText(() => theme.fg("warning", `${label}: ${formatTokens(tokens)} tokens billed${cost}`), 1, 0));
3649
3894
  }
3650
- static countDroppedThinkingBlocks(message) {
3651
- let count = 0;
3652
- for (const diagnostic of message.diagnostics ?? []) {
3653
- if (diagnostic.type !== "anthropic_input_transformations")
3654
- continue;
3655
- const transformations = diagnostic.details?.transformations;
3656
- if (!Array.isArray(transformations))
3657
- continue;
3658
- count += transformations.filter((transformation) => typeof transformation === "object" &&
3659
- transformation !== null &&
3660
- transformation.type === "thinking_dropped").length;
3661
- }
3662
- return count;
3663
- }
3664
3895
  maybeShowThinkingDropNotice(message) {
3665
3896
  if (!this.settingsManager.getShowCacheMissNotices())
3666
3897
  return;
3667
- const droppedCount = InteractiveMode.countDroppedThinkingBlocks(message);
3668
- if (droppedCount === 0)
3898
+ const dropped = getDroppedReasoning(message);
3899
+ if (!dropped)
3669
3900
  return;
3670
- let previousDroppedCount = 0;
3671
- // message_end reaches the UI before the current message is persisted,
3672
- // so the branch's last assistant message is the previous response.
3901
+ // Providers report a withheld block again on every later request that replays it, so only
3902
+ // a count above the previous response's means new losses. message_end reaches the UI before
3903
+ // the current message is persisted, so the branch's last assistant message is the previous response.
3673
3904
  const branch = this.sessionManager.getBranch();
3674
3905
  for (let i = branch.length - 1; i >= 0; i--) {
3675
3906
  const entry = branch[i];
3676
3907
  if (entry.type === "message" && entry.message.role === "assistant") {
3677
- previousDroppedCount = InteractiveMode.countDroppedThinkingBlocks(entry.message);
3908
+ const previous = getDroppedReasoning(entry.message);
3909
+ if (previous?.diagnostic === dropped.diagnostic && dropped.count <= previous.count)
3910
+ return;
3678
3911
  break;
3679
3912
  }
3680
3913
  }
3681
- if (droppedCount <= previousDroppedCount)
3682
- return;
3683
- const noun = droppedCount === 1 ? "thinking block" : "thinking blocks";
3914
+ const { provider, noun: nouns } = dropped.diagnostic;
3915
+ const noun = nouns[dropped.count === 1 ? 0 : 1];
3916
+ const reasons = dropped.reasons.length > 0 ? `: ${dropped.reasons.join(", ")}` : "";
3684
3917
  this.chatContainer.addChild(new Spacer(1));
3685
- this.chatContainer.addChild(new ThemedText(() => theme.fg("warning", `Anthropic dropped ${droppedCount} ${noun} (details in session)`), 1, 0));
3918
+ this.chatContainer.addChild(new ThemedText(() => theme.fg("warning", `${provider} dropped ${dropped.count} ${noun}${reasons} (details in session)`), 1, 0));
3686
3919
  }
3687
3920
  /**
3688
3921
  * Show a transcript notice when a completed assistant message paid for a
@@ -3779,6 +4012,8 @@ export class InteractiveMode {
3779
4012
  if (this.isShuttingDown)
3780
4013
  return;
3781
4014
  this.isShuttingDown = true;
4015
+ this.remoteTerminalStopped = true;
4016
+ this.remoteTerminalLifetime?.abort();
3782
4017
  this.releaseFlowAccountsHost();
3783
4018
  const termination = killTrackedDetachedChildrenAsync();
3784
4019
  // Keep signal handlers registered until terminal cleanup has completed.
@@ -3801,6 +4036,7 @@ export class InteractiveMode {
3801
4036
  this.themeController.disableAutoSync();
3802
4037
  await this.ui.terminal.drainInput(1000);
3803
4038
  this.stop();
4039
+ await flushStdout();
3804
4040
  process.exit(0);
3805
4041
  }
3806
4042
  // Interactive quit (Ctrl+D, Ctrl+C, /quit, extension shutdown()). Stop the
@@ -3819,8 +4055,10 @@ export class InteractiveMode {
3819
4055
  }
3820
4056
  const resumeCommand = formatResumeCommand(this.sessionManager);
3821
4057
  if (resumeCommand) {
3822
- process.stdout.write(`${chalk.dim("To resume this session:")} ${resumeCommand}\n`);
4058
+ // Own line so the command can be selected with a triple-click (#12237).
4059
+ process.stdout.write(`${chalk.dim("To resume this session:")}\n${resumeCommand}\n`);
3823
4060
  }
4061
+ await flushStdout();
3824
4062
  process.exit(0);
3825
4063
  }
3826
4064
  emergencyTerminalExit() {
@@ -4057,6 +4295,8 @@ export class InteractiveMode {
4057
4295
  void this.refreshOAuthAccountFooter();
4058
4296
  const thinkingStr = result.model.reasoning && result.thinkingLevel !== "off" ? ` (thinking: ${result.thinkingLevel})` : "";
4059
4297
  this.showStatus(`Switched to ${result.model.name || result.model.id}${thinkingStr}`);
4298
+ if (result.notice)
4299
+ this.showStatus(result.notice);
4060
4300
  void this.maybeWarnAboutAnthropicSubscriptionAuth(result.model);
4061
4301
  }
4062
4302
  }
@@ -4071,8 +4311,6 @@ export class InteractiveMode {
4071
4311
  if (expanded === this.toolOutputExpanded)
4072
4312
  return;
4073
4313
  this.toolOutputExpanded = expanded;
4074
- if (isExpandable(this.activeStatusIndicator))
4075
- this.activeStatusIndicator.setExpanded(expanded);
4076
4314
  const activeHeader = this.customHeader ?? this.builtInHeader;
4077
4315
  if (isExpandable(activeHeader)) {
4078
4316
  activeHeader.setExpanded(expanded);
@@ -4722,13 +4960,27 @@ export class InteractiveMode {
4722
4960
  this.showModelSelector();
4723
4961
  return;
4724
4962
  }
4963
+ const session = this.session;
4964
+ await this.reloadHcodeAccount();
4965
+ if (this.session !== session)
4966
+ return;
4725
4967
  const model = await this.findExactModelMatch(searchTerm);
4968
+ if (this.session !== session)
4969
+ return;
4970
+ // An explicitly managed ID cannot fall through to another provider's literal ID.
4971
+ if (!model || searchTerm.trim().toLowerCase().startsWith(`${HCODE_PROVIDER}/`)) {
4972
+ const excluded = hcodeExcludedSelection(session.modelRuntime, searchTerm);
4973
+ if (excluded) {
4974
+ this.showError(excluded);
4975
+ return;
4976
+ }
4977
+ }
4726
4978
  if (model) {
4727
4979
  try {
4728
- await this.session.setModel(model, { persist: false });
4980
+ const notice = await this.session.setModelKeepingThinking(model);
4729
4981
  this.footer.invalidate();
4730
4982
  this.updateEditorBorderColor();
4731
- this.showStatus(`Model: ${model.id}`);
4983
+ this.showStatus(`Model: ${model.id}${notice ? ` · ${notice}` : ""}`);
4732
4984
  void this.maybeWarnAboutAnthropicSubscriptionAuth(model);
4733
4985
  }
4734
4986
  catch (error) {
@@ -4739,11 +4991,23 @@ export class InteractiveMode {
4739
4991
  this.showModelSelector(searchTerm);
4740
4992
  }
4741
4993
  async findExactModelMatch(searchTerm) {
4742
- const cachedModels = this.session.scopedModels.length > 0
4743
- ? this.session.scopedModels.map((scoped) => scoped.model)
4744
- : [...this.session.modelRuntime.getAvailableSnapshot()];
4745
- const cachedMatch = findExactModelReferenceMatch(searchTerm, cachedModels);
4746
- if (cachedMatch || this.session.scopedModels.length > 0)
4994
+ const session = this.session;
4995
+ const runtime = session.modelRuntime;
4996
+ const scope = session.scopedModels;
4997
+ if (scope.length > 0) {
4998
+ const match = findExactModelReferenceMatch(searchTerm, scope.map(({ model }) => model));
4999
+ if (match?.provider !== HCODE_PROVIDER)
5000
+ return match;
5001
+ const current = () => runtime.getAvailableSnapshot().find((model) => modelsAreEqual(model, match));
5002
+ const cached = current();
5003
+ if (cached)
5004
+ return cached;
5005
+ this.showStatus("Refreshing HUMAIN Code models…");
5006
+ await retryHcodeCatalog(runtime, AbortSignal.timeout(15_000)).catch(() => undefined);
5007
+ return session.scopedModels === scope ? current() : undefined;
5008
+ }
5009
+ const cachedMatch = findExactModelReferenceMatch(searchTerm, runtime.getAvailableSnapshot());
5010
+ if (cachedMatch)
4747
5011
  return cachedMatch;
4748
5012
  this.showStatus("Refreshing model catalogs…");
4749
5013
  const controller = new AbortController();
@@ -4753,7 +5017,7 @@ export class InteractiveMode {
4753
5017
  controller.abort();
4754
5018
  }, 15_000);
4755
5019
  try {
4756
- const result = await refreshModelCatalogs(this.session.modelRuntime, controller.signal);
5020
+ const result = await refreshModelCatalogs(runtime, controller.signal);
4757
5021
  if (result.aborted && timedOut) {
4758
5022
  this.showWarning("Model refresh timed out; searching cached models.");
4759
5023
  }
@@ -4769,7 +5033,7 @@ export class InteractiveMode {
4769
5033
  finally {
4770
5034
  clearTimeout(timeout);
4771
5035
  }
4772
- return findExactModelReferenceMatch(searchTerm, [...this.session.modelRuntime.getAvailableSnapshot()]);
5036
+ return findExactModelReferenceMatch(searchTerm, runtime.getAvailableSnapshot());
4773
5037
  }
4774
5038
  /** Update the footer's available provider count from the current snapshot without refreshing catalogs. */
4775
5039
  updateAvailableProviderCount() {
@@ -4881,73 +5145,42 @@ export class InteractiveMode {
4881
5145
  const session = this.session;
4882
5146
  this.showSelector((done) => {
4883
5147
  const controller = new AbortController();
4884
- let owner = "model";
4885
- let finishSelection = done;
4886
5148
  const cancelSelection = () => {
4887
- finishSelection();
5149
+ done();
4888
5150
  if (selectionContext.kind === "hcode" && this.session === session)
4889
- this.showStatus(`Signed in to ${HCODE_LOGIN_LABEL}. No model selected. Use /model when you're ready.`);
5151
+ this.showStatus(`Signed in to ${hcodeDisplayName(session.modelRuntime.hcode.environment.id)}. No model selected. Use /model when you're ready.`);
4890
5152
  this.ui.requestRender();
4891
5153
  };
4892
5154
  const selectModel = async (model, persist) => {
4893
5155
  try {
4894
- const reference = model.provider === HCODE_PROVIDER ? captureHcodeSelection(session.modelRuntime, model) : undefined;
4895
- let thinkingLevel = session.settingsManager.getModelThinkingLevel(model.provider, model.id) ??
4896
- session.settingsManager.getDefaultThinkingLevel() ??
4897
- session.thinkingLevel;
4898
- const levels = getSupportedThinkingLevels(model);
4899
- if (reference && !levels.includes(thinkingLevel)) {
4900
- owner = "thinking";
4901
- const chosen = await new Promise((resolve) => {
4902
- this.showSelector((finish) => {
4903
- finishSelection = finish;
4904
- const selector = new ThinkingSelectorComponent(thinkingLevel, levels, (level) => resolve(level), () => {
4905
- resolve(undefined);
4906
- cancelSelection();
4907
- });
4908
- return {
4909
- component: selector,
4910
- focus: selector,
4911
- dispose: () => {
4912
- controller.abort();
4913
- resolve(undefined);
4914
- },
4915
- };
4916
- });
4917
- });
4918
- if (chosen === undefined || this.session !== session)
4919
- return;
4920
- thinkingLevel = chosen;
4921
- }
4922
5156
  if (this.session !== session || controller.signal.aborted)
4923
5157
  return;
4924
- if (reference)
4925
- assertHcodeSelection(session.modelRuntime, model, reference);
4926
- await session.setModel(model, { persist, thinkingLevel, signal: controller.signal });
5158
+ const notice = await session.setModelKeepingThinking(model, { persist, signal: controller.signal });
4927
5159
  if (this.session !== session)
4928
5160
  return;
4929
5161
  this.updateAvailableProviderCount();
4930
5162
  this.footer.invalidate();
4931
5163
  this.updateEditorBorderColor();
4932
- finishSelection();
5164
+ done();
4933
5165
  const isDefault = this.settingsManager.getDefaultProvider() === model.provider &&
4934
5166
  this.settingsManager.getDefaultModel() === model.id;
4935
5167
  const showTip = !persist && !isDefault && !this.modelSaveTipShown;
4936
5168
  if (showTip)
4937
5169
  this.modelSaveTipShown = true;
4938
- this.showStatus(modelSelectionStatus({
5170
+ const status = modelSelectionStatus({
4939
5171
  model,
4940
5172
  persist,
4941
5173
  isDefault,
4942
5174
  showTip,
4943
5175
  saveKey: keyDisplayText("app.models.save"),
4944
- }));
5176
+ });
5177
+ this.showStatus(notice ? `${status} · ${notice}` : status);
4945
5178
  void this.maybeWarnAboutAnthropicSubscriptionAuth(model);
4946
5179
  }
4947
5180
  catch (error) {
4948
5181
  if (controller.signal.aborted || this.session !== session)
4949
5182
  return;
4950
- finishSelection();
5183
+ done();
4951
5184
  this.showError(error instanceof Error ? error.message : String(error));
4952
5185
  }
4953
5186
  };
@@ -4958,9 +5191,10 @@ export class InteractiveMode {
4958
5191
  component: selector,
4959
5192
  focus: selector,
4960
5193
  dispose: () => {
4961
- if (owner === "model")
4962
- controller.abort();
5194
+ controller.abort();
4963
5195
  selector.dispose();
5196
+ // /model refreshes HUMAIN Code too; announce models that appeared after an empty sign-in.
5197
+ this.hcodeCatalogWatch?.observe();
4964
5198
  },
4965
5199
  };
4966
5200
  });
@@ -5440,7 +5674,9 @@ export class InteractiveMode {
5440
5674
  this.releaseFlowAccountsHost();
5441
5675
  const runtime = this.session.modelRuntime;
5442
5676
  const reporter = this.getFlowAccountReporter();
5443
- this.flowAccountsRelease = bindFlowAccountsHost(this.session.extensionRunner.getModelRegistry(), {
5677
+ const registry = this.session.extensionRunner.getModelRegistry();
5678
+ this.claudeUsageReconnectRelease = bindClaudeUsageReconnect(registry, (accountKey) => this.reauthenticateAccount(ANTHROPIC_USAGE_PROVIDER_ID, "oauth", accountKey));
5679
+ this.flowAccountsRelease = bindFlowAccountsHost(registry, {
5444
5680
  openAccounts: (signal) => this.runFlowAccountsInteraction(signal),
5445
5681
  refreshCatalog: (providerId, signal) => refreshFlowCatalog(runtime, providerId, signal),
5446
5682
  refreshAccountUsage: (target, signal) => reporter.refreshAccountUsage(target, signal),
@@ -5450,6 +5686,8 @@ export class InteractiveMode {
5450
5686
  });
5451
5687
  }
5452
5688
  releaseFlowAccountsHost() {
5689
+ this.claudeUsageReconnectRelease?.();
5690
+ this.claudeUsageReconnectRelease = undefined;
5453
5691
  this.flowAccountsRelease?.();
5454
5692
  this.flowAccountsRelease = undefined;
5455
5693
  this.flowAccountReporter?.cancelAll();
@@ -5612,8 +5850,9 @@ export class InteractiveMode {
5612
5850
  }
5613
5851
  await this.startProviderLogin(method);
5614
5852
  }
5615
- async showOAuthAccountSelector(provider, mode = "manage") {
5853
+ async showOAuthAccountSelector(provider, mode = "manage", refreshKey) {
5616
5854
  const runtime = this.session.modelRuntime;
5855
+ const isClaude = provider.id === ANTHROPIC_USAGE_PROVIDER_ID;
5617
5856
  const pool = runtime.oauthAccounts;
5618
5857
  let accounts;
5619
5858
  let sources;
@@ -5621,7 +5860,10 @@ export class InteractiveMode {
5621
5860
  let unidentified = false;
5622
5861
  try {
5623
5862
  const options = { signal: AbortSignal.timeout(15_000) };
5624
- accounts = await runtime.accounts.list(provider.id, options);
5863
+ accounts = await runtime.accounts.list(provider.id, {
5864
+ ...options,
5865
+ ...(mode === "manage" ? { distinctForDisplay: true } : {}),
5866
+ });
5625
5867
  sources = await runtime.accounts.sources(provider.id, options);
5626
5868
  usageAccounts = provider.id === CODEX_USAGE_PROVIDER_ID ? await pool.list(provider.id, options) : [];
5627
5869
  unidentified =
@@ -5636,10 +5878,12 @@ export class InteractiveMode {
5636
5878
  }
5637
5879
  const now = Date.now();
5638
5880
  const labelCounts = new Map();
5639
- for (const account of accounts)
5640
- labelCounts.set(account.label, (labelCounts.get(account.label) ?? 0) + 1);
5881
+ for (const account of accounts) {
5882
+ const label = account.displayLabel ?? account.label;
5883
+ labelCounts.set(label, (labelCounts.get(label) ?? 0) + 1);
5884
+ }
5641
5885
  const isCodex = provider.id === CODEX_USAGE_PROVIDER_ID;
5642
- const hasSubscriptionUsage = isCodex || provider.id === ANTHROPIC_USAGE_PROVIDER_ID;
5886
+ const hasSubscriptionUsage = isCodex || isClaude;
5643
5887
  const accountLabel = (account) => {
5644
5888
  const auth = runtime.getProvider(provider.id)?.auth;
5645
5889
  const subscription = account.type === "oauth" ? auth?.oauth?.isSubscription : auth?.apiKey?.isSubscription;
@@ -5657,6 +5901,7 @@ export class InteractiveMode {
5657
5901
  return `${label} (${markers.join(", ")})`;
5658
5902
  };
5659
5903
  const usageStates = accounts.map((account) => hasSubscriptionUsage && account.type === "oauth" ? { kind: "loading" } : { kind: "none" });
5904
+ const claudeActions = new Map();
5660
5905
  const sourceOptions = sources.map((source) => `${source.label} [read-only] (${source.effective ? "effective" : "shadowed"})`);
5661
5906
  const addAccountOption = "Add another account…";
5662
5907
  const policyOption = "Provider policy…";
@@ -5671,10 +5916,13 @@ export class InteractiveMode {
5671
5916
  ...extraOptions,
5672
5917
  ];
5673
5918
  this.showSelector((done) => {
5674
- const selector = new ExtensionSelectorComponent(mode === "logout"
5675
- ? `HUMAIN Code / Accounts — Remove which ${provider.name} account?`
5676
- : `HUMAIN Code / Accounts — ${provider.name}:`, currentOptions, (option) => {
5919
+ const cancel = () => {
5677
5920
  done();
5921
+ this.ui.requestRender();
5922
+ };
5923
+ const select = (index, action) => {
5924
+ done();
5925
+ const option = extraOptions[index - accounts.length];
5678
5926
  if (option === unidentifiedOption) {
5679
5927
  void this.removeUnidentifiedCredential(provider);
5680
5928
  return;
@@ -5687,44 +5935,123 @@ export class InteractiveMode {
5687
5935
  void this.showAccountPolicy(provider);
5688
5936
  return;
5689
5937
  }
5690
- if (sourceOptions.includes(option)) {
5938
+ if (option && sourceOptions.includes(option)) {
5691
5939
  void this.showExtensionSelector(`${option}\n${EXTERNAL_SOURCE_NOTICE}`, ["Back"]).then(() => this.showOAuthAccountSelector(provider));
5692
5940
  return;
5693
5941
  }
5694
- const index = currentOptions.indexOf(option);
5695
- if (index < 0 || index >= accounts.length)
5696
- return;
5697
5942
  const account = accounts[index];
5698
5943
  if (!account)
5699
5944
  return;
5700
- if (mode === "logout") {
5945
+ if (mode === "logout" || action === "remove") {
5701
5946
  void this.removeOAuthAccount(provider, account.key);
5702
5947
  }
5948
+ else if (action === "reconnect") {
5949
+ void this.reauthenticateAccount(provider.id, account.type, account.key);
5950
+ }
5703
5951
  else {
5704
- void this.showOAuthAccountActions(provider, account);
5952
+ void this.showOAuthAccountActions(provider, account, undefined, claudeActions.get(account.key), action === "choose" ? "Use for future requests" : undefined);
5705
5953
  }
5706
- }, () => {
5707
- done();
5708
- this.ui.requestRender();
5709
- });
5954
+ };
5955
+ const getRows = () => {
5956
+ const occurrences = new Map();
5957
+ const auth = runtime.getProvider(provider.id)?.auth;
5958
+ return [
5959
+ ...accounts.map((account, index) => {
5960
+ const state = usageStates[index];
5961
+ const usage = subscriptionAccountUsage(state.kind === "subscription" ? state.result : undefined);
5962
+ const loading = state.kind === "loading";
5963
+ const cooldown = account.exhaustedUntil !== undefined && account.exhaustedUntil > Date.now()
5964
+ ? formatOAuthAccountResetTime(account.exhaustedUntil)
5965
+ : undefined;
5966
+ const status = usage.expired
5967
+ ? "Sign-in expired"
5968
+ : usage.availability === "blocked" || cooldown
5969
+ ? "Blocked"
5970
+ : account.active
5971
+ ? "Active"
5972
+ : usage.weeklyLeft !== undefined
5973
+ ? "Ready"
5974
+ : "Saved";
5975
+ const subscription = account.type === "oauth" ? auth?.oauth?.isSubscription : auth?.apiKey?.isSubscription;
5976
+ const label = account.displayLabel ?? account.label;
5977
+ const occurrence = (occurrences.get(label) ?? 0) + 1;
5978
+ occurrences.set(label, occurrence);
5979
+ const duplicate = (labelCounts.get(label) ?? 0) > 1;
5980
+ return {
5981
+ kind: "account",
5982
+ label: duplicate ? `${occurrence}. ${label}` : label,
5983
+ status,
5984
+ loading,
5985
+ weeklyLeft: usage.weeklyLeft,
5986
+ details: [
5987
+ label,
5988
+ ...(duplicate ? [`Account ID: ${account.key}`] : []),
5989
+ `${account.type === "oauth" ? "OAuth" : "API key"}${subscription ? " subscription" : ""}`,
5990
+ `Status: ${status}${status !== "Active" && account.active ? " · Active" : ""}${account.effective ? " · Effective" : ""}`,
5991
+ `Provider: ${provider.name}${usage.availability ? ` · ${usage.availability === "unknown" ? "Unknown" : usage.availability === "allowed" ? "Allowed" : "Blocked"}` : ""}`,
5992
+ ...(cooldown ? [`Cached cooldown until ${cooldown}`] : []),
5993
+ ...(state.kind === "subscription" && state.status ? [state.status] : []),
5994
+ ...(state.kind === "none"
5995
+ ? []
5996
+ : loading
5997
+ ? ["Weekly usage: Loading…"]
5998
+ : [
5999
+ `Weekly left: ${usage.weeklyLeft === undefined ? "Unavailable" : `${usage.weeklyLeft}%`}`,
6000
+ ...(usage.reset ? [`Next reset: ${usage.reset}`] : []),
6001
+ `Saved resets: ${usage.savedResets}`,
6002
+ `Paid credits: ${usage.paidCredits}`,
6003
+ ...(usage.extraUsage ? [`Extra usage: ${usage.extraUsage}`] : []),
6004
+ ]),
6005
+ ],
6006
+ };
6007
+ }),
6008
+ ...extraOptions.map((label) => ({
6009
+ kind: "action",
6010
+ label,
6011
+ details: [
6012
+ label,
6013
+ label === addAccountOption
6014
+ ? "Connect another account for this provider."
6015
+ : label === policyOption
6016
+ ? "Configure auto-switch and API-key fallback."
6017
+ : EXTERNAL_SOURCE_NOTICE,
6018
+ ],
6019
+ })),
6020
+ ];
6021
+ };
6022
+ const logoutSelector = mode === "logout"
6023
+ ? new ExtensionSelectorComponent(`HUMAIN Code / Accounts — Remove which ${provider.name} account?`, currentOptions, (option) => select(currentOptions.indexOf(option), "choose"), cancel)
6024
+ : undefined;
6025
+ const selector = logoutSelector ??
6026
+ new AccountPickerComponent(`Manage accounts · ${provider.name}`, getRows, () => Math.max(1, (this.ui.terminal?.rows ?? 24) - 5), select, cancel);
5710
6027
  const controller = new AbortController();
5711
6028
  let closed = false;
5712
6029
  if (hasSubscriptionUsage) {
5713
6030
  const subscriptionAccounts = accounts.filter((account) => account.type === "oauth");
6031
+ const registry = this.session.extensionRunner?.getModelRegistry();
5714
6032
  let nextIndex = 0;
5715
6033
  const worker = async () => {
5716
6034
  while (!closed && nextIndex < subscriptionAccounts.length) {
5717
6035
  const account = subscriptionAccounts[nextIndex++];
5718
6036
  const signal = AbortSignal.any([controller.signal, AbortSignal.timeout(10_000)]);
6037
+ const options = { accountKey: account.key, signal };
5719
6038
  let result;
5720
- try {
5721
- const registry = this.session.extensionRunner.getModelRegistry();
5722
- const options = { accountKey: account.key, signal };
5723
- result = await (isCodex ? registry.getCodexUsage(options) : registry.getAnthropicUsage(options));
5724
- }
5725
- catch {
5726
- // Account removal or lookup failure must not hide other accounts or expose backend errors.
6039
+ if (isCodex) {
6040
+ try {
6041
+ result = await registry?.getCodexUsage(options);
6042
+ }
6043
+ catch {
6044
+ // Account removal or lookup failure must not hide other accounts or expose backend errors.
6045
+ }
5727
6046
  }
6047
+ if (closed)
6048
+ return;
6049
+ const claude = isClaude && registry
6050
+ ? await readClaudeUsage(registry, account.key, {
6051
+ signal,
6052
+ ...(account.key === refreshKey ? { bypassCache: true } : {}),
6053
+ })
6054
+ : undefined;
5728
6055
  if (closed)
5729
6056
  return;
5730
6057
  const index = accounts.indexOf(account);
@@ -5746,12 +6073,23 @@ export class InteractiveMode {
5746
6073
  }
5747
6074
  if (closed)
5748
6075
  return;
5749
- usageStates[index] = { kind: "subscription", result };
6076
+ const fallback = claude?.fallback;
6077
+ const state = {
6078
+ kind: "subscription",
6079
+ result: claude?.result ?? result,
6080
+ status: fallback &&
6081
+ [fallback.status, fallback.reconnect === "required" ? "Reconnect required" : undefined]
6082
+ .filter(Boolean)
6083
+ .join(" · "),
6084
+ };
6085
+ usageStates[index] = state;
6086
+ if (claude)
6087
+ claudeActions.set(account.key, { state, reconnect: fallback?.reconnect });
5750
6088
  currentOptions = [
5751
6089
  ...accounts.map((entry, accountIndex) => formatOAuthAccountOption(accountLabel(entry), usageStates[accountIndex])),
5752
6090
  ...extraOptions,
5753
6091
  ];
5754
- selector.setOptions(currentOptions);
6092
+ logoutSelector?.setOptions(currentOptions);
5755
6093
  this.ui.requestRender();
5756
6094
  }
5757
6095
  };
@@ -5813,17 +6151,29 @@ export class InteractiveMode {
5813
6151
  this.showError("Could not read or save account policy. Reopen /accounts to check current state.");
5814
6152
  }
5815
6153
  }
6154
+ async reauthenticateAccount(providerId, type, accountKey) {
6155
+ const method = this.getLoginProviderOptions(type).find((entry) => entry.id === providerId);
6156
+ if (method)
6157
+ await this.startProviderLogin(method, undefined, accountKey);
6158
+ else
6159
+ this.showError("Login method is no longer available.");
6160
+ }
5816
6161
  /** `flow` runs the actions inside the awaited Flow setup, where Back and Add another account stay in that flow. */
5817
- async showOAuthAccountActions(provider, account, flow) {
6162
+ async showOAuthAccountActions(provider, account, flow, claudeUsage, directAction) {
5818
6163
  const signal = flow?.signal;
5819
- const action = await this.showExtensionSelector(`HUMAIN Code / Accounts — ${provider.name}: ${account.label}\nSelection is global. OAuth plans may bill extra usage at the provider. OAuth logins without provider identity cannot detect duplicates; use Reauthenticate to keep the same entry.${flow ? `\n${FLOW_ACCOUNT_PERSISTENCE_NOTICE}` : ""}`, [
5820
- "Use for future requests",
5821
- "Rename…",
5822
- "Add another account…",
5823
- "Reauthenticate…",
5824
- "Remove from HUMAIN Code…",
5825
- "Back",
5826
- ], { signal });
6164
+ const canRefresh = !flow && provider.id === ANTHROPIC_USAGE_PROVIDER_ID && account.type === "oauth";
6165
+ const usageText = claudeUsage ? `\n${formatOAuthAccountUsage(claudeUsage.state)}` : "";
6166
+ const reauthenticate = claudeUsage?.reconnect ? "Reconnect…" : "Reauthenticate…";
6167
+ const action = directAction ??
6168
+ (await this.showExtensionSelector(`HUMAIN Code / Accounts — ${provider.name}: ${account.label}${usageText}\nSelection is global. OAuth plans may bill extra usage at the provider. OAuth logins without provider identity cannot detect duplicates; reconnect this account to keep the same entry.${flow ? `\n${FLOW_ACCOUNT_PERSISTENCE_NOTICE}` : ""}`, [
6169
+ "Use for future requests",
6170
+ "Rename…",
6171
+ "Add another account…",
6172
+ ...(canRefresh ? ["Refresh"] : []),
6173
+ reauthenticate,
6174
+ "Remove from HUMAIN Code…",
6175
+ "Back",
6176
+ ], { signal }));
5827
6177
  if (action === "Back") {
5828
6178
  if (!flow)
5829
6179
  await this.showOAuthAccountSelector(provider);
@@ -5836,12 +6186,11 @@ export class InteractiveMode {
5836
6186
  else
5837
6187
  await this.handleLoginCommand(provider.id);
5838
6188
  }
5839
- else if (action === "Reauthenticate…") {
5840
- const method = this.getLoginProviderOptions(account.type).find((entry) => entry.id === provider.id);
5841
- if (method)
5842
- await this.startProviderLogin(method, undefined, account.key);
5843
- else
5844
- this.showError("Login method is no longer available.");
6189
+ else if (action === "Refresh" && canRefresh) {
6190
+ await this.showOAuthAccountSelector(provider, "manage", account.key);
6191
+ }
6192
+ else if (action === reauthenticate) {
6193
+ await this.reauthenticateAccount(provider.id, account.type, account.key);
5845
6194
  }
5846
6195
  else if (action === "Rename…" || action === "Use for future requests") {
5847
6196
  try {
@@ -5951,11 +6300,32 @@ export class InteractiveMode {
5951
6300
  return this.getLoginProviderOptions().filter((provider) => provider.id.toLowerCase() === normalizedProviderRef ||
5952
6301
  provider.name.toLowerCase() === normalizedProviderRef);
5953
6302
  }
6303
+ /** Picks up a sign-in or sign-out that another humain-code process saved for this environment. */
6304
+ async reloadHcodeAccount() {
6305
+ const session = this.session;
6306
+ let changed;
6307
+ try {
6308
+ changed = await session.modelRuntime.reloadHcodeAccount(AbortSignal.timeout(5_000));
6309
+ }
6310
+ catch {
6311
+ // Unreadable shared storage keeps the current state; sign-in itself reports storage failures.
6312
+ return;
6313
+ }
6314
+ if (!changed || this.session !== session)
6315
+ return;
6316
+ this.updateAvailableProviderCount();
6317
+ this.footer.invalidate();
6318
+ }
5954
6319
  async handleLoginCommand(providerRef) {
6320
+ await this.reloadHcodeAccount();
5955
6321
  if (!providerRef) {
5956
6322
  this.showLoginAuthTypeSelector();
5957
6323
  return;
5958
6324
  }
6325
+ if (providerRef === "status") {
6326
+ await this.showHcodeLoginStatus();
6327
+ return;
6328
+ }
5959
6329
  const providerOptions = this.findLoginProviderOptions(providerRef);
5960
6330
  if (providerOptions.length === 1) {
5961
6331
  await this.startProviderLogin(providerOptions[0]);
@@ -5978,16 +6348,24 @@ export class InteractiveMode {
5978
6348
  let close = () => { };
5979
6349
  this.showSelector((done) => {
5980
6350
  close = done;
5981
- const selector = new ExtensionSelectorComponent(`Checking ${HCODE_LOGIN_LABEL} availability…`, ["Cancel"], () => done(), () => done());
6351
+ const selector = new ExtensionSelectorComponent(`Checking ${providerOption.name} availability…`, ["Cancel"], () => done(), () => done());
5982
6352
  return { component: selector, focus: selector, dispose: () => controller.abort() };
5983
6353
  });
5984
- const ready = await this.checkHcodeLogin(controller.signal);
6354
+ const readiness = await this.checkHcodeLogin(controller.signal);
5985
6355
  if (controller.signal.aborted || this.session !== session)
5986
6356
  return;
5987
6357
  close();
5988
6358
  this.ui.requestRender();
5989
- if (!ready) {
5990
- this.showStatus(`${HCODE_LOGIN_LABEL} is unavailable for this environment. Try /login again later.`);
6359
+ if (readiness.kind === "unreachable") {
6360
+ this.showStatus(`Can't reach ${readiness.host}: check VPN/Zscaler, then try /login again.`);
6361
+ return;
6362
+ }
6363
+ if (readiness.kind === "mismatch") {
6364
+ this.showWarning(HCODE_LOGIN_MISMATCH_DETAILS);
6365
+ return;
6366
+ }
6367
+ if (readiness.kind !== "ready") {
6368
+ this.showStatus(`${providerOption.name} is unavailable for this environment. Try /login again later.`);
5991
6369
  return;
5992
6370
  }
5993
6371
  }
@@ -6061,19 +6439,77 @@ export class InteractiveMode {
6061
6439
  });
6062
6440
  }
6063
6441
  async checkHcodeLogin(signal) {
6064
- const bounded = AbortSignal.any([signal, AbortSignal.timeout(5000)]);
6442
+ const runtime = this.session.modelRuntime;
6443
+ const timeout = timerSignal(HCODE_LOGIN_CHECK_TIMEOUT_MS);
6444
+ const bounded = AbortSignal.any([signal, timeout]);
6065
6445
  try {
6066
- return ((await raceWithAbortSignal(this.session.modelRuntime.probeHcodeLogin(bounded), bounded)).kind === "ready");
6446
+ return await raceWithAbortSignal(runtime.probeHcodeLogin(bounded), bounded);
6067
6447
  }
6068
6448
  catch {
6069
- return false;
6449
+ // The check's own requests time out sooner; this bound only covers a stalled check.
6450
+ return timeout.aborted && !signal.aborted
6451
+ ? { kind: "unreachable", host: new URL(runtime.hcode.environment.origin).host }
6452
+ : { kind: "unavailable" };
6070
6453
  }
6071
6454
  }
6455
+ async showStartupHcodeSignIn(reference, readiness) {
6456
+ const session = this.session;
6457
+ const { environment, account } = session.modelRuntime.hcode;
6458
+ const chat = this.chatContainer;
6459
+ const spacer = new Spacer(1);
6460
+ let server = hcodeLoginAvailability(undefined).text;
6461
+ const line = new ThemedText(() => theme.fg("dim", `${hcodeDisplayName(environment.id)}: signed in · ${server}`), 1, 0);
6462
+ chat.addChild(spacer);
6463
+ chat.addChild(line);
6464
+ this.ui.requestRender();
6465
+ const availability = hcodeLoginAvailability(await readiness);
6466
+ if (this.session !== session || !sameReference(account.status(environment.id), reference)) {
6467
+ chat.removeChild(line);
6468
+ chat.removeChild(spacer);
6469
+ }
6470
+ else {
6471
+ server =
6472
+ availability.state === "ready"
6473
+ ? availability.text
6474
+ : `${availability.text.replace(/ \[(Retry|Details)\]$/, "")} · /login for details`;
6475
+ line.invalidate();
6476
+ }
6477
+ this.ui.requestRender();
6478
+ }
6479
+ async showHcodeLoginStatus() {
6480
+ const session = this.session;
6481
+ const runtime = session.modelRuntime;
6482
+ const environmentId = runtime.hcode.environment.id;
6483
+ const name = hcodeDisplayName(environmentId);
6484
+ const reference = runtime.hcode.account.status(environmentId);
6485
+ const lines = [];
6486
+ if (!reference)
6487
+ lines.push(hcodeSignedInElsewhereNotice(environmentId, runtime.hcodeSignedInElsewhere()) ??
6488
+ `${name}: not signed in. Use /login to sign in.`);
6489
+ else {
6490
+ const email = runtime.hcodeAccountEmail(reference);
6491
+ const count = runtime.getAvailableSnapshot().filter((model) => model.provider === HCODE_PROVIDER).length;
6492
+ lines.push(`${name}: signed in${email ? ` as ${email}` : ""} · ${count} models`);
6493
+ if (count === 0 && !this.hcodeCatalogFailed && !runtime.hcodeCatalogLoaded())
6494
+ lines.push(" Model list not loaded yet. /model to check.");
6495
+ else if (count === 0) {
6496
+ const { reason, fix } = hcodeEmptyCatalogReason(this.hcodeCatalogFailed
6497
+ ? { kind: "failed" }
6498
+ : { kind: "empty", reason: runtime.hcodeCatalogEmptyReason() });
6499
+ lines.push(` No models available in the CLI yet: ${reason}.`, ` ${fix}`, " /model to retry.");
6500
+ }
6501
+ }
6502
+ // Show the account at once; the server line updates in place when the (usually cached) check settles.
6503
+ const show = (server) => this.showStatus([...lines, ` Sign-in server: ${server}`].join("\n"));
6504
+ show(hcodeLoginAvailability(undefined).text);
6505
+ const readiness = hcodeLoginAvailability(await this.checkHcodeLogin(new AbortController().signal));
6506
+ if (this.session === session)
6507
+ show(readiness.text.replace(/ \[(Retry|Details)\]$/, ""));
6508
+ }
6072
6509
  showLoginProviderSelector(authType, initialSearchInput, humainOnly = false) {
6073
6510
  const session = this.session;
6074
6511
  const available = this.getLoginProviderOptions().filter((provider) => provider.id === HCODE_PROVIDER ? authType !== "api_key" : !authType || provider.authType === authType);
6075
6512
  const ordered = humainOnly ? humainLoginProviders(available) : available;
6076
- let providerOptions = ordered.filter((provider) => provider.id !== HCODE_PROVIDER);
6077
6513
  if (ordered.length === 0) {
6078
6514
  const message = humainOnly
6079
6515
  ? "No HUMAIN providers available."
@@ -6085,14 +6521,78 @@ export class InteractiveMode {
6085
6521
  this.showStatus(message);
6086
6522
  return;
6087
6523
  }
6524
+ const code = ordered.find((provider) => provider.id === HCODE_PROVIDER);
6088
6525
  this.showSelector((done) => {
6089
- const selector = new OAuthSelectorComponent("login", providerOptions, async (providerId, selectedAuthType) => {
6526
+ const controller = new AbortController();
6527
+ // HUMAIN Code renders at once and shows its connection check; selecting it before the check
6528
+ // finishes waits inline with a spinner and continues on its own once ready.
6529
+ let readiness;
6530
+ let spinner;
6531
+ let frame = 0;
6532
+ const providers = () => ordered.map((provider) => {
6533
+ if (provider !== code)
6534
+ return provider;
6535
+ const availability = hcodeLoginAvailability(readiness);
6536
+ return {
6537
+ ...provider,
6538
+ availability: spinner
6539
+ ? {
6540
+ ...availability,
6541
+ text: `${SPINNER_FRAMES[frame % SPINNER_FRAMES.length]} ${availability.text}`,
6542
+ }
6543
+ : availability,
6544
+ };
6545
+ });
6546
+ const update = () => {
6547
+ selector.setProviders(providers());
6548
+ this.ui.requestRender();
6549
+ };
6550
+ const start = (provider) => {
6090
6551
  done();
6091
- const providerOption = providerOptions.find((provider) => provider.id === providerId && provider.authType === selectedAuthType);
6092
- if (!providerOption) {
6552
+ void this.startProviderLogin(provider, () => this.showLoginProviderSelector(authType, initialSearchInput, humainOnly));
6553
+ };
6554
+ const check = () => {
6555
+ readiness = undefined;
6556
+ void this.checkHcodeLogin(controller.signal).then((result) => {
6557
+ if (controller.signal.aborted || this.session !== session)
6558
+ return;
6559
+ readiness = result;
6560
+ const waiting = spinner !== undefined;
6561
+ clearInterval(spinner);
6562
+ spinner = undefined;
6563
+ if (waiting && code && result.kind === "ready")
6564
+ start(code);
6565
+ else
6566
+ update();
6567
+ });
6568
+ };
6569
+ const wait = () => {
6570
+ frame = 0;
6571
+ spinner = setInterval(() => {
6572
+ frame++;
6573
+ update();
6574
+ }, SPINNER_INTERVAL_MS);
6575
+ update();
6576
+ };
6577
+ const selector = new OAuthSelectorComponent("login", providers(), (providerId, selectedAuthType) => {
6578
+ const providerOption = ordered.find((provider) => provider.id === providerId && provider.authType === selectedAuthType);
6579
+ if (!providerOption)
6580
+ return;
6581
+ if (providerOption === code && readiness?.kind !== "ready") {
6582
+ if (spinner)
6583
+ return;
6584
+ if (readiness?.kind === "mismatch") {
6585
+ done();
6586
+ this.showWarning(HCODE_LOGIN_MISMATCH_DETAILS);
6587
+ return;
6588
+ }
6589
+ // Retry after a failure; otherwise join the check already running.
6590
+ if (readiness)
6591
+ check();
6592
+ wait();
6093
6593
  return;
6094
6594
  }
6095
- await this.startProviderLogin(providerOption, () => this.showLoginProviderSelector(authType, initialSearchInput, humainOnly));
6595
+ start(providerOption);
6096
6596
  }, () => {
6097
6597
  done();
6098
6598
  if (authType || humainOnly) {
@@ -6102,15 +6602,16 @@ export class InteractiveMode {
6102
6602
  this.ui.requestRender();
6103
6603
  }
6104
6604
  }, initialSearchInput);
6105
- const controller = new AbortController();
6106
- void this.checkHcodeLogin(controller.signal).then((ready) => {
6107
- if (controller.signal.aborted || this.session !== session)
6108
- return;
6109
- providerOptions = ready ? ordered : ordered.filter((provider) => provider.id !== HCODE_PROVIDER);
6110
- selector.setProviders(providerOptions);
6111
- this.ui.requestRender();
6112
- });
6113
- return { component: selector, focus: selector, dispose: () => controller.abort() };
6605
+ if (code)
6606
+ check();
6607
+ return {
6608
+ component: selector,
6609
+ focus: selector,
6610
+ dispose: () => {
6611
+ controller.abort();
6612
+ clearInterval(spinner);
6613
+ },
6614
+ };
6114
6615
  });
6115
6616
  }
6116
6617
  async showOAuthSelector(mode) {
@@ -6150,30 +6651,17 @@ export class InteractiveMode {
6150
6651
  const fresh = getModelSelectionIntent(this.session.sessionManager).kind === "fresh";
6151
6652
  if (providerId === HCODE_PROVIDER) {
6152
6653
  if (this.session.modelRuntime.getProviderAuthStatus(providerId).source === "runtime")
6153
- this.showStatus(`Signed in to ${HCODE_LOGIN_LABEL} for this session only. Nothing from this sign-in was saved.`);
6154
- this.showStatus(fresh
6155
- ? `Signed in to ${HCODE_LOGIN_LABEL}.`
6156
- : `Signed in to ${HCODE_LOGIN_LABEL}. Your current model was kept. Use /model to choose a HUMAIN Code model.`);
6654
+ this.showStatus(`Signed in to ${providerName} for this session only. Nothing from this sign-in was saved.`);
6157
6655
  }
6158
6656
  else
6159
6657
  this.showStatus(`Saved API key for ${providerName}. Credentials saved to ${getAuthPath()}`);
6160
6658
  this.updateAvailableProviderCount();
6161
6659
  this.footer.invalidate();
6162
6660
  this.updateEditorBorderColor();
6163
- if (providerId === HCODE_PROVIDER && fresh) {
6164
- const runtime = this.session.modelRuntime;
6165
- const reference = runtime.hcode.account.status(runtime.hcode.environment.id);
6166
- if (!reference) {
6167
- this.showStatus(HCODE_SELECTION_CHANGED_MESSAGE);
6168
- return;
6169
- }
6170
- // Reuse Agent's unselected sentinel without resetting messages, tools or user history.
6171
- this.session.agent.state.model = new Agent({ streamFn: this.session.agent.streamFunction }).state.model;
6172
- this.showModelSelector(undefined, { kind: "hcode", reference });
6173
- }
6174
- else {
6661
+ if (providerId === HCODE_PROVIDER)
6662
+ await this.finishHcodeSignIn(fresh);
6663
+ else
6175
6664
  await this.refreshLoginCatalog(providerId, providerName);
6176
- }
6177
6665
  return;
6178
6666
  }
6179
6667
  const actionLabel = authType === "oauth" ? `Logged in to ${providerName}` : `Saved API key for ${providerName}`;
@@ -6269,41 +6757,119 @@ export class InteractiveMode {
6269
6757
  })
6270
6758
  .finally(() => clearTimeout(timeout));
6271
6759
  }
6760
+ /** Load the new account's models; an empty list returns to the prompt with a notice and a background re-check. */
6761
+ async finishHcodeSignIn(fresh) {
6762
+ const session = this.session;
6763
+ const runtime = session.modelRuntime;
6764
+ this.hcodeCatalogWatch?.stop();
6765
+ this.hcodeCatalogFailed = false;
6766
+ const name = hcodeDisplayName(runtime.hcode.environment.id);
6767
+ const loaded = await this.loadLoginCatalog(HCODE_PROVIDER, name);
6768
+ if (this.session !== session)
6769
+ return;
6770
+ if (!loaded) {
6771
+ this.showStatus(`Signed in to ${name}. Use /model to load its models.`);
6772
+ return;
6773
+ }
6774
+ const reference = runtime.hcode.account.status(runtime.hcode.environment.id);
6775
+ if (!reference) {
6776
+ this.showStatus(HCODE_SELECTION_CHANGED_MESSAGE);
6777
+ return;
6778
+ }
6779
+ if (loaded === "ready") {
6780
+ this.showStatus(fresh
6781
+ ? `Signed in to ${name}.`
6782
+ : `Signed in to ${name}. Your current model was kept. Use /model to choose a HUMAIN Code model.`);
6783
+ if (!fresh)
6784
+ return;
6785
+ // Reuse Agent's unselected sentinel without resetting messages, tools or user history.
6786
+ session.agent.state.model = new Agent({ streamFn: session.agent.streamFunction }).state.model;
6787
+ this.showModelSelector(undefined, { kind: "hcode", reference });
6788
+ return;
6789
+ }
6790
+ // Keep the sign-in and the current model; the user can go on with other providers.
6791
+ const cause = loaded === "failed" ? { kind: "failed" } : { kind: "empty", reason: runtime.hcodeCatalogEmptyReason() };
6792
+ this.showStatus(hcodeEmptyCatalogNotice(runtime.hcode.environment.id, runtime.hcodeAccountEmail(reference), cause));
6793
+ this.hcodeCatalogFailed = loaded === "failed";
6794
+ this.hcodeCatalogWatch = watchHcodeCatalog({
6795
+ refresh: async (signal) => {
6796
+ try {
6797
+ const result = await checkWatchedHcodeCatalog(runtime, signal);
6798
+ if (result && !signal.aborted)
6799
+ this.hcodeCatalogFailed = result.aborted || result.errors.size > 0;
6800
+ }
6801
+ catch {
6802
+ // An account/session stop says nothing about the catalog.
6803
+ if (!signal.aborted ||
6804
+ (signal.reason instanceof DOMException && signal.reason.name === "TimeoutError")) {
6805
+ this.hcodeCatalogFailed = true;
6806
+ }
6807
+ }
6808
+ },
6809
+ count: () => runtime.getAvailableSnapshot().filter((model) => model.provider === HCODE_PROVIDER).length,
6810
+ setStatus: (text) => {
6811
+ this.hcodeCatalogStatus = text;
6812
+ this.footerDataProvider.setExtensionStatus(HCODE_STATUS_KEY, text);
6813
+ this.footer.invalidate();
6814
+ this.ui.requestRender();
6815
+ },
6816
+ announce: (count) => {
6817
+ this.updateAvailableProviderCount();
6818
+ // Someone who already picked one in /model needs no pointer back to it.
6819
+ if (this.session.model?.provider === HCODE_PROVIDER)
6820
+ return;
6821
+ this.showStatus(count === 1
6822
+ ? `1 ${name} model is now available. Use /model to choose it.`
6823
+ : `${count} ${name} models are now available. Use /model to choose one.`);
6824
+ },
6825
+ subscribe: (listener) => runtime.hcode.account.subscribe((next) => {
6826
+ if (!sameReference(next, reference))
6827
+ listener();
6828
+ }),
6829
+ }, runtime.hcode.environment.id);
6830
+ }
6831
+ /** Refresh one provider's catalog behind a cancellable loading menu; `undefined` when cancelled or replaced. */
6832
+ async loadLoginCatalog(providerId, providerName) {
6833
+ const session = this.session;
6834
+ const controller = new AbortController();
6835
+ let close = () => { };
6836
+ this.showSelector((done) => {
6837
+ close = done;
6838
+ const selector = new ExtensionSelectorComponent(`Loading ${providerName} models…`, ["Cancel"], done, done);
6839
+ return { component: selector, focus: selector, dispose: () => controller.abort() };
6840
+ });
6841
+ const signal = AbortSignal.any([controller.signal, AbortSignal.timeout(15_000)]);
6842
+ let failed = false;
6843
+ try {
6844
+ const result = await raceWithAbortSignal(session.modelRuntime.refresh({ providers: [providerId], signal }), signal);
6845
+ failed = result.aborted || result.errors.size > 0;
6846
+ }
6847
+ catch {
6848
+ failed = true;
6849
+ }
6850
+ if (controller.signal.aborted || this.session !== session)
6851
+ return undefined;
6852
+ close();
6853
+ this.ui.requestRender();
6854
+ this.updateAvailableProviderCount();
6855
+ this.footer.invalidate();
6856
+ if (failed)
6857
+ return "failed";
6858
+ return session.modelRuntime.getAvailableSnapshot().some((model) => model.provider === providerId)
6859
+ ? "ready"
6860
+ : "empty";
6861
+ }
6272
6862
  async refreshLoginCatalog(providerId, providerName) {
6273
6863
  const session = this.session;
6274
6864
  do {
6275
- const controller = new AbortController();
6276
- let close = () => { };
6277
- this.showSelector((done) => {
6278
- close = done;
6279
- const selector = new ExtensionSelectorComponent(`Loading ${providerName} models…`, ["Cancel"], done, done);
6280
- return { component: selector, focus: selector, dispose: () => controller.abort() };
6281
- });
6282
- const signal = AbortSignal.any([controller.signal, AbortSignal.timeout(15_000)]);
6283
- let failed = false;
6284
- try {
6285
- const result = await raceWithAbortSignal(session.modelRuntime.refresh({ providers: [providerId], signal }), signal);
6286
- failed = result.aborted || result.errors.size > 0;
6287
- }
6288
- catch {
6289
- failed = true;
6290
- }
6291
- if (controller.signal.aborted || this.session !== session)
6865
+ const loaded = await this.loadLoginCatalog(providerId, providerName);
6866
+ if (!loaded)
6292
6867
  return;
6293
- close();
6294
- this.ui.requestRender();
6295
- this.updateAvailableProviderCount();
6296
- this.footer.invalidate();
6297
- if (!failed && session.modelRuntime.getAvailableSnapshot().some((model) => model.provider === providerId)) {
6298
- if (providerId !== HCODE_PROVIDER)
6299
- this.showStatus(`Use /model to select a ${providerName} model. Your current model was not changed.`);
6868
+ if (loaded === "ready") {
6869
+ this.showStatus(`Use /model to select a ${providerName} model. Your current model was not changed.`);
6300
6870
  return;
6301
6871
  }
6302
- const message = failed
6303
- ? "Couldn't load models."
6304
- : providerId === HCODE_PROVIDER
6305
- ? "Your admin hasn't enabled CLI models yet."
6306
- : "No HUMAIN Fuse models are available.";
6872
+ const message = loaded === "failed" ? "Couldn't load models." : "No HUMAIN Fuse models are available.";
6307
6873
  if ((await this.showExtensionSelector(message, ["Retry", "Cancel"])) !== "Retry")
6308
6874
  return;
6309
6875
  } while (this.session === session);
@@ -6389,10 +6955,12 @@ export class InteractiveMode {
6389
6955
  const errorMsg = error instanceof Error ? error.message : String(error);
6390
6956
  if (error instanceof CredentialSynchronizationError) {
6391
6957
  this.showError(providerId === HCODE_PROVIDER
6392
- ? `Signed in to ${HCODE_LOGIN_LABEL}, but local model state could not be synchronized: ${errorMsg}`
6958
+ ? `Signed in to ${providerName}, but local model state could not be synchronized: ${errorMsg}`
6393
6959
  : `Saved API key for ${providerName}, but local model state could not be synchronized: ${errorMsg}`);
6394
6960
  }
6395
6961
  else if (errorMsg === "Login cancelled") {
6962
+ if (providerId === HCODE_PROVIDER)
6963
+ this.showStatus(`${providerName} sign-in cancelled.`);
6396
6964
  onBack?.();
6397
6965
  }
6398
6966
  else if (error instanceof SafeCredentialError) {
@@ -6400,7 +6968,7 @@ export class InteractiveMode {
6400
6968
  }
6401
6969
  else {
6402
6970
  this.showError(providerId === HCODE_PROVIDER
6403
- ? `Sign-in failed for ${HCODE_LOGIN_LABEL}: ${errorMsg}`
6971
+ ? `Sign-in failed for ${providerName}: ${errorMsg}`
6404
6972
  : `Failed to save API key for ${providerName}: ${errorMsg}`);
6405
6973
  }
6406
6974
  }
@@ -7032,7 +7600,7 @@ export class InteractiveMode {
7032
7600
  | \`${cycleThinkingLevel}\` | Cycle thinking level |
7033
7601
  | \`${cycleModelForward}\` / \`${cycleModelBackward}\` | Cycle models |
7034
7602
  | \`${selectModel}\` | Open model selector |
7035
- | \`${expandTools}\` | Toggle tool output and adaptive criteria/evidence expansion |
7603
+ | \`${expandTools}\` | Toggle tool output expansion |
7036
7604
  | \`${toggleThinking}\` | Toggle thinking block visibility |
7037
7605
  | \`${externalEditor}\` | Edit message in external editor |
7038
7606
  | \`${copyMessage}\` | Copy selection or last assistant message |
@@ -7206,6 +7774,9 @@ export class InteractiveMode {
7206
7774
  }
7207
7775
  }
7208
7776
  stop(fullscreenExitOutput = this.settingsManager.getFullscreenExitOutput()) {
7777
+ this.remoteTerminalStopped = true;
7778
+ this.remoteTerminalLifetime?.abort();
7779
+ this.remoteTerminal = undefined;
7209
7780
  this.disposeActiveSelector();
7210
7781
  if (this.settingsManager.getShowTerminalProgress()) {
7211
7782
  this.ui.terminal.setProgress(false);