@humain/humain-code 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (650) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/README.md +2 -2
  3. package/dist/bundle/agent-monitor.js +1 -1
  4. package/dist/bundle/chunks/anthropic-messages-UZB5HJE3.js +77 -0
  5. package/dist/bundle/chunks/anthropic.js +25 -24
  6. package/dist/bundle/chunks/azure-openai-responses-J3LCMWPQ.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-HTA325LJ.js → chunk-2NVGOSBN.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-5B25YXF7.js → chunk-3CGMVKHA.js} +13 -3
  11. package/dist/bundle/chunks/{chunk-SCINMV4X.js → chunk-46C6D7UC.js} +22 -21
  12. package/dist/bundle/chunks/{chunk-RS6PZK35.js → chunk-4EV7CK26.js} +249 -216
  13. package/dist/bundle/chunks/{chunk-T7BXP46S.js → chunk-4SFWYKL5.js} +1848 -1662
  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-6HTHDVJC.js +4 -0
  17. package/dist/bundle/chunks/{chunk-2G7YVAVF.js → chunk-7EONJCBE.js} +1 -1
  18. package/dist/bundle/chunks/chunk-7H2WNBX7.js +11 -0
  19. package/dist/bundle/chunks/{chunk-2FYYW6FY.js → chunk-7OZNMWAJ.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-R6YQR7TZ.js → chunk-7WE77IE3.js} +1 -1
  21. package/dist/bundle/chunks/{chunk-Z5YLKK3S.js → chunk-7WETECIB.js} +1 -1
  22. package/dist/bundle/chunks/{chunk-EIC7CQX3.js → chunk-AI7EHDAX.js} +1 -1
  23. package/dist/bundle/chunks/{chunk-KRCX3ZBA.js → chunk-APNPBT7Y.js} +1 -1
  24. package/dist/bundle/chunks/{chunk-4HTVBBJD.js → chunk-ATFZAFMS.js} +2 -2
  25. package/dist/bundle/chunks/{chunk-R5OOX7RW.js → chunk-B47PNNLL.js} +9 -2
  26. package/dist/bundle/chunks/{chunk-AZXVJN6E.js → chunk-C4DHVDYT.js} +1 -1
  27. package/dist/bundle/chunks/{chunk-4PRNKB6V.js → chunk-CET2MXXN.js} +7 -7
  28. package/dist/bundle/chunks/{chunk-66FZJO75.js → chunk-CU6KU7JK.js} +472 -3924
  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-G4QPSFBF.js → chunk-EMBIUIQ2.js} +216 -223
  33. package/dist/bundle/chunks/{chunk-Q7VXYXY3.js → chunk-ENBDASDN.js} +2 -2
  34. package/dist/bundle/chunks/{chunk-2H3LUS62.js → chunk-FJIISX5W.js} +241 -229
  35. package/dist/bundle/chunks/{chunk-WQOOJP7U.js → chunk-GV5OVRKK.js} +1 -1
  36. package/dist/bundle/chunks/{chunk-KTSJYIYC.js → chunk-HHWVVNGG.js} +1 -1
  37. package/dist/bundle/chunks/{chunk-4JRER4XK.js → chunk-HQMUDHC3.js} +19 -19
  38. package/dist/bundle/chunks/{chunk-WQ7EJQIT.js → chunk-IOLLZXQN.js} +225 -239
  39. package/dist/bundle/chunks/chunk-IXQYPQRQ.js +2079 -0
  40. package/dist/bundle/chunks/{chunk-RU7ADKA7.js → chunk-J4GII2EE.js} +112 -96
  41. package/dist/bundle/chunks/chunk-J5TSAJGC.js +22 -0
  42. package/dist/bundle/chunks/{chunk-QT6ZHDMP.js → chunk-JBSWWCT5.js} +1 -1
  43. package/dist/bundle/chunks/{chunk-P6AXBESH.js → chunk-JV7VHOAY.js} +1119 -1098
  44. package/dist/bundle/chunks/{chunk-PWUDFU5V.js → chunk-JWOPWHVH.js} +4 -4
  45. package/dist/bundle/chunks/{chunk-4V5VL2BO.js → chunk-KLSRGGOH.js} +131 -154
  46. package/dist/bundle/chunks/{chunk-JF7FYXAI.js → chunk-KONLZKPL.js} +7 -6
  47. package/dist/bundle/chunks/{chunk-32QLLD2P.js → chunk-KQXXBQ57.js} +360 -332
  48. package/dist/bundle/chunks/{chunk-UZNIPOGS.js → chunk-L4J7SMJB.js} +1 -1
  49. package/dist/bundle/chunks/chunk-MPRAQ6ZI.js +41 -0
  50. package/dist/bundle/chunks/{chunk-GUHNFZ2Q.js → chunk-NNWNIBLG.js} +20 -19
  51. package/dist/bundle/chunks/{chunk-TWAHPPXN.js → chunk-OVDMYBIT.js} +1307 -1194
  52. package/dist/bundle/chunks/{chunk-WAPZN4KP.js → chunk-P2Y2H7SD.js} +2 -2
  53. package/dist/bundle/chunks/{chunk-PPBDDQHP.js → chunk-PGVDL4KB.js} +7 -6
  54. package/dist/bundle/chunks/{chunk-XHDVDJM7.js → chunk-PVNXN2TC.js} +7 -7
  55. package/dist/bundle/chunks/{chunk-RNBZBCH2.js → chunk-QJB5YI3I.js} +1 -1
  56. package/dist/bundle/chunks/{chunk-I5E7RQ5V.js → chunk-QRYDGY5I.js} +5 -5
  57. package/dist/bundle/chunks/{chunk-4QAXV5T6.js → chunk-R3VDXQW2.js} +9 -9
  58. package/dist/bundle/chunks/chunk-SKCJ25SX.js +24 -0
  59. package/dist/bundle/chunks/chunk-SQ7NTRLJ.js +77 -0
  60. package/dist/bundle/chunks/{chunk-SSRCVJZK.js → chunk-TYN46EVI.js} +5 -5
  61. package/dist/bundle/chunks/{chunk-6E6RHNOU.js → chunk-UXM4WFLH.js} +12 -11
  62. package/dist/bundle/chunks/{chunk-LB4CIS4F.js → chunk-VCMXBP5S.js} +17 -17
  63. package/dist/bundle/chunks/{chunk-N2SNMUD3.js → chunk-VKQNYZUA.js} +1 -1
  64. package/dist/bundle/chunks/{chunk-JYWUOKOI.js → chunk-WBSGWISD.js} +367 -353
  65. package/dist/bundle/chunks/{chunk-3EDMWQ35.js → chunk-WGXMYMPE.js} +17 -15
  66. package/dist/bundle/chunks/chunk-WRYGY5XG.js +24 -0
  67. package/dist/bundle/chunks/{chunk-GRJUKEE3.js → chunk-XVIQYONJ.js} +4 -4
  68. package/dist/bundle/chunks/chunk-YSWDFV2L.js +11 -0
  69. package/dist/bundle/chunks/{chunk-AEWYICBL.js → chunk-Z5UFSRO4.js} +2 -2
  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-ETKC6B2S.js} +1 -1
  74. package/dist/bundle/chunks/codemode-worker.js +68 -68
  75. package/dist/bundle/chunks/compat-HS4ARZK3.js +15 -0
  76. package/dist/bundle/chunks/curator-server-TC7RVVN2.js +3600 -0
  77. package/dist/bundle/chunks/dist-35STTNYA.js +37 -0
  78. package/dist/bundle/chunks/{dist-FMWWM4H7.js → dist-5AQPJ2TI.js} +2 -2
  79. package/dist/bundle/chunks/{dist-NHQTBDHT.js → dist-DYB3AR7C.js} +91 -257
  80. package/dist/bundle/chunks/dist-NMEXYUP3.js +11 -0
  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-QHZTEVJP.js} +68 -65
  88. package/dist/bundle/chunks/{flow-implementer-APJFY4YI.js → flow-implementer-QMN3HKE2.js} +8 -9
  89. package/dist/bundle/chunks/github-copilot.js +55 -45
  90. package/dist/bundle/chunks/google-generative-ai-ZND73WDQ.js +22 -0
  91. package/dist/bundle/chunks/google-vertex-YAH62YRM.js +25 -0
  92. package/dist/bundle/chunks/host-Q565BCXB.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-453SLFL5.js} +6 -6
  96. package/dist/bundle/chunks/interactive-mode-MVZOJ5OU.js +5 -0
  97. package/dist/bundle/chunks/{llama-cpp-classify-GJAXULWL.js → llama-cpp-classify-Z4GZY4GC.js} +1 -1
  98. package/dist/bundle/chunks/mistral-conversations-7I5JURDP.js +43 -0
  99. package/dist/bundle/chunks/{node-ZFIIS5IM.js → node-IMSYVRPL.js} +53 -30
  100. package/dist/bundle/chunks/{node-UNHECG4X.js → node-MHHE76P4.js} +475 -440
  101. package/dist/bundle/chunks/{openai-codex-responses-S7CMCAOY.js → openai-codex-responses-LTHOMN37.js} +30 -29
  102. package/dist/bundle/chunks/openai-codex.js +9 -8
  103. package/dist/bundle/chunks/{openai-completions-2Z57N7PC.js → openai-completions-W2X635EE.js} +22 -22
  104. package/dist/bundle/chunks/{openai-decisions-JIOJDB4C.js → openai-decisions-TN2GNOYI.js} +1 -1
  105. package/dist/bundle/chunks/{openai-responses-5VBZSTHL.js → openai-responses-DVY4QXOG.js} +4 -5
  106. package/dist/bundle/chunks/{openrouter-images-S6O7DBEJ.js → openrouter-images-SE2JMS44.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-WAS6Z5L5.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-XNVLSJ22.js +4 -0
  117. package/dist/bundle/chunks/startup-ui-3TCT465D.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-AAZH6S3I.js} +1 -1
  120. package/dist/bundle/chunks/{undici-C6S56CGI.js → undici-WVNE45GY.js} +1 -1
  121. package/dist/bundle/chunks/virtual-modules-CIVXCEAN.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/session-picker.d.ts.map +1 -1
  134. package/dist/cli/session-picker.js +9 -6
  135. package/dist/cli/session-picker.js.map +1 -1
  136. package/dist/cli/startup-ui.d.ts.map +1 -1
  137. package/dist/cli/startup-ui.js +8 -4
  138. package/dist/cli/startup-ui.js.map +1 -1
  139. package/dist/cli.js.map +1 -1
  140. package/dist/core/agent-session-runtime.d.ts +11 -0
  141. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  142. package/dist/core/agent-session-runtime.js +19 -0
  143. package/dist/core/agent-session-runtime.js.map +1 -1
  144. package/dist/core/agent-session-services.d.ts +0 -2
  145. package/dist/core/agent-session-services.d.ts.map +1 -1
  146. package/dist/core/agent-session-services.js +0 -2
  147. package/dist/core/agent-session-services.js.map +1 -1
  148. package/dist/core/agent-session.d.ts +31 -39
  149. package/dist/core/agent-session.d.ts.map +1 -1
  150. package/dist/core/agent-session.js +231 -535
  151. package/dist/core/agent-session.js.map +1 -1
  152. package/dist/core/anthropic-subscription-usage.d.ts +4 -2
  153. package/dist/core/anthropic-subscription-usage.d.ts.map +1 -1
  154. package/dist/core/anthropic-subscription-usage.js +32 -16
  155. package/dist/core/anthropic-subscription-usage.js.map +1 -1
  156. package/dist/core/auto-session-namer.js +1 -1
  157. package/dist/core/auto-session-namer.js.map +1 -1
  158. package/dist/core/cache-warmer.d.ts.map +1 -1
  159. package/dist/core/cache-warmer.js +2 -0
  160. package/dist/core/cache-warmer.js.map +1 -1
  161. package/dist/core/exec.d.ts +1 -0
  162. package/dist/core/exec.d.ts.map +1 -1
  163. package/dist/core/exec.js +4 -1
  164. package/dist/core/exec.js.map +1 -1
  165. package/dist/core/export-html/ansi-to-html.d.ts +6 -1
  166. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  167. package/dist/core/export-html/ansi-to-html.js +57 -20
  168. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  169. package/dist/core/export-html/template.js +1 -1
  170. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  171. package/dist/core/export-html/tool-renderer.js +2 -3
  172. package/dist/core/export-html/tool-renderer.js.map +1 -1
  173. package/dist/core/extensions/loader.d.ts.map +1 -1
  174. package/dist/core/extensions/loader.js +18 -1
  175. package/dist/core/extensions/loader.js.map +1 -1
  176. package/dist/core/extensions/runner.d.ts.map +1 -1
  177. package/dist/core/extensions/runner.js +5 -0
  178. package/dist/core/extensions/runner.js.map +1 -1
  179. package/dist/core/extensions/types.d.ts +5 -0
  180. package/dist/core/extensions/types.d.ts.map +1 -1
  181. package/dist/core/extensions/types.js.map +1 -1
  182. package/dist/core/flow-implementer.d.ts.map +1 -1
  183. package/dist/core/flow-implementer.js +3 -9
  184. package/dist/core/flow-implementer.js.map +1 -1
  185. package/dist/core/keybindings.d.ts +40 -0
  186. package/dist/core/keybindings.d.ts.map +1 -1
  187. package/dist/core/keybindings.js +5 -0
  188. package/dist/core/keybindings.js.map +1 -1
  189. package/dist/core/model-config.d.ts +13 -0
  190. package/dist/core/model-config.d.ts.map +1 -1
  191. package/dist/core/model-registry.d.ts +3 -0
  192. package/dist/core/model-registry.d.ts.map +1 -1
  193. package/dist/core/model-registry.js +32 -8
  194. package/dist/core/model-registry.js.map +1 -1
  195. package/dist/core/model-resolver.d.ts +0 -1
  196. package/dist/core/model-resolver.d.ts.map +1 -1
  197. package/dist/core/model-resolver.js +3 -10
  198. package/dist/core/model-resolver.js.map +1 -1
  199. package/dist/core/model-runtime.d.ts +18 -7
  200. package/dist/core/model-runtime.d.ts.map +1 -1
  201. package/dist/core/model-runtime.js +41 -8
  202. package/dist/core/model-runtime.js.map +1 -1
  203. package/dist/core/oauth-account-pool.d.ts +5 -0
  204. package/dist/core/oauth-account-pool.d.ts.map +1 -1
  205. package/dist/core/oauth-account-pool.js +34 -3
  206. package/dist/core/oauth-account-pool.js.map +1 -1
  207. package/dist/core/package-manager.d.ts +16 -0
  208. package/dist/core/package-manager.d.ts.map +1 -1
  209. package/dist/core/package-manager.js +46 -3
  210. package/dist/core/package-manager.js.map +1 -1
  211. package/dist/core/pi-ai-schemas.d.ts +1 -0
  212. package/dist/core/pi-ai-schemas.d.ts.map +1 -1
  213. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  214. package/dist/core/remote-catalog-provider.js +7 -0
  215. package/dist/core/remote-catalog-provider.js.map +1 -1
  216. package/dist/core/resource-loader.d.ts +5 -1
  217. package/dist/core/resource-loader.d.ts.map +1 -1
  218. package/dist/core/resource-loader.js +2 -0
  219. package/dist/core/resource-loader.js.map +1 -1
  220. package/dist/core/run-outcome.d.ts +6 -3
  221. package/dist/core/run-outcome.d.ts.map +1 -1
  222. package/dist/core/run-outcome.js +36 -9
  223. package/dist/core/run-outcome.js.map +1 -1
  224. package/dist/core/run-preflight.d.ts +1 -1
  225. package/dist/core/run-preflight.d.ts.map +1 -1
  226. package/dist/core/run-preflight.js +19 -11
  227. package/dist/core/run-preflight.js.map +1 -1
  228. package/dist/core/sdk.d.ts +0 -6
  229. package/dist/core/sdk.d.ts.map +1 -1
  230. package/dist/core/sdk.js +7 -16
  231. package/dist/core/sdk.js.map +1 -1
  232. package/dist/core/settings-manager.d.ts +0 -5
  233. package/dist/core/settings-manager.d.ts.map +1 -1
  234. package/dist/core/settings-manager.js +0 -9
  235. package/dist/core/settings-manager.js.map +1 -1
  236. package/dist/core/settings-schema.d.ts +0 -4
  237. package/dist/core/settings-schema.d.ts.map +1 -1
  238. package/dist/core/settings-schema.js +0 -1
  239. package/dist/core/settings-schema.js.map +1 -1
  240. package/dist/core/tools/bash-jobs.d.ts.map +1 -1
  241. package/dist/core/tools/bash-jobs.js +2 -9
  242. package/dist/core/tools/bash-jobs.js.map +1 -1
  243. package/dist/core/tools/find.d.ts.map +1 -1
  244. package/dist/core/tools/find.js +28 -16
  245. package/dist/core/tools/find.js.map +1 -1
  246. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  247. package/dist/core/tools/output-accumulator.js +4 -1
  248. package/dist/core/tools/output-accumulator.js.map +1 -1
  249. package/dist/core/tools/read.d.ts +8 -4
  250. package/dist/core/tools/read.d.ts.map +1 -1
  251. package/dist/core/tools/read.js +10 -15
  252. package/dist/core/tools/read.js.map +1 -1
  253. package/dist/core/tools/renderers/read.d.ts.map +1 -1
  254. package/dist/core/tools/renderers/read.js +6 -2
  255. package/dist/core/tools/renderers/read.js.map +1 -1
  256. package/dist/core/tools/subagent-worktree.d.ts.map +1 -1
  257. package/dist/core/tools/subagent-worktree.js +2 -10
  258. package/dist/core/tools/subagent-worktree.js.map +1 -1
  259. package/dist/core/trace-client/credential-store.d.ts.map +1 -1
  260. package/dist/core/trace-client/credential-store.js +9 -5
  261. package/dist/core/trace-client/credential-store.js.map +1 -1
  262. package/dist/extensions/codemode/execute.js +2 -2
  263. package/dist/extensions/codemode/execute.js.map +1 -1
  264. package/dist/extensions/llama/provider.d.ts +1 -1
  265. package/dist/extensions/llama/provider.d.ts.map +1 -1
  266. package/dist/extensions/llama/provider.js +6 -4
  267. package/dist/extensions/llama/provider.js.map +1 -1
  268. package/dist/extensions/usage/account-reconnect.d.ts +5 -0
  269. package/dist/extensions/usage/account-reconnect.d.ts.map +1 -0
  270. package/dist/extensions/usage/account-reconnect.js +12 -0
  271. package/dist/extensions/usage/account-reconnect.js.map +1 -0
  272. package/dist/extensions/usage/hcode-overview.d.ts +6 -19
  273. package/dist/extensions/usage/hcode-overview.d.ts.map +1 -1
  274. package/dist/extensions/usage/hcode-overview.js +86 -100
  275. package/dist/extensions/usage/hcode-overview.js.map +1 -1
  276. package/dist/extensions/usage/index.d.ts.map +1 -1
  277. package/dist/extensions/usage/index.js +74 -98
  278. package/dist/extensions/usage/index.js.map +1 -1
  279. package/dist/extensions/usage/overview.d.ts +22 -17
  280. package/dist/extensions/usage/overview.d.ts.map +1 -1
  281. package/dist/extensions/usage/overview.js +98 -13
  282. package/dist/extensions/usage/overview.js.map +1 -1
  283. package/dist/extensions/usage/popup.d.ts +9 -14
  284. package/dist/extensions/usage/popup.d.ts.map +1 -1
  285. package/dist/extensions/usage/popup.js +78 -165
  286. package/dist/extensions/usage/popup.js.map +1 -1
  287. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +4 -1
  288. package/dist/humain/flow-command.js +1 -1
  289. package/dist/humain/flow-command.js.map +1 -1
  290. package/dist/humain/flow-loader.d.ts +9 -4
  291. package/dist/humain/flow-loader.d.ts.map +1 -1
  292. package/dist/humain/flow-loader.js +30 -21
  293. package/dist/humain/flow-loader.js.map +1 -1
  294. package/dist/humain/gateway/client.d.ts +3 -1
  295. package/dist/humain/gateway/client.d.ts.map +1 -1
  296. package/dist/humain/gateway/client.js +10 -5
  297. package/dist/humain/gateway/client.js.map +1 -1
  298. package/dist/humain/gateway/login.d.ts.map +1 -1
  299. package/dist/humain/gateway/login.js +160 -53
  300. package/dist/humain/gateway/login.js.map +1 -1
  301. package/dist/humain/hcode/account-store.d.ts +29 -5
  302. package/dist/humain/hcode/account-store.d.ts.map +1 -1
  303. package/dist/humain/hcode/account-store.js +224 -124
  304. package/dist/humain/hcode/account-store.js.map +1 -1
  305. package/dist/humain/hcode/account.d.ts +6 -0
  306. package/dist/humain/hcode/account.d.ts.map +1 -1
  307. package/dist/humain/hcode/account.js +348 -129
  308. package/dist/humain/hcode/account.js.map +1 -1
  309. package/dist/humain/hcode/catalog-watch.d.ts +21 -0
  310. package/dist/humain/hcode/catalog-watch.d.ts.map +1 -0
  311. package/dist/humain/hcode/catalog-watch.js +46 -0
  312. package/dist/humain/hcode/catalog-watch.js.map +1 -0
  313. package/dist/humain/hcode/contracts.d.ts +16 -1
  314. package/dist/humain/hcode/contracts.d.ts.map +1 -1
  315. package/dist/humain/hcode/contracts.js +122 -128
  316. package/dist/humain/hcode/contracts.js.map +1 -1
  317. package/dist/humain/hcode/environment.d.ts +3 -1
  318. package/dist/humain/hcode/environment.d.ts.map +1 -1
  319. package/dist/humain/hcode/environment.js +12 -2
  320. package/dist/humain/hcode/environment.js.map +1 -1
  321. package/dist/humain/hcode/facade.d.ts +26 -6
  322. package/dist/humain/hcode/facade.d.ts.map +1 -1
  323. package/dist/humain/hcode/facade.js +148 -38
  324. package/dist/humain/hcode/facade.js.map +1 -1
  325. package/dist/humain/hcode/http.d.ts +3 -1
  326. package/dist/humain/hcode/http.d.ts.map +1 -1
  327. package/dist/humain/hcode/http.js +44 -23
  328. package/dist/humain/hcode/http.js.map +1 -1
  329. package/dist/humain/hcode/images.d.ts +67 -0
  330. package/dist/humain/hcode/images.d.ts.map +1 -0
  331. package/dist/humain/hcode/images.js +463 -0
  332. package/dist/humain/hcode/images.js.map +1 -0
  333. package/dist/humain/hcode/login-copy.d.ts +28 -0
  334. package/dist/humain/hcode/login-copy.d.ts.map +1 -0
  335. package/dist/humain/hcode/login-copy.js +74 -0
  336. package/dist/humain/hcode/login-copy.js.map +1 -0
  337. package/dist/humain/hcode/login-failure.d.ts +26 -0
  338. package/dist/humain/hcode/login-failure.d.ts.map +1 -0
  339. package/dist/humain/hcode/login-failure.js +50 -0
  340. package/dist/humain/hcode/login-failure.js.map +1 -0
  341. package/dist/humain/hcode/notices.d.ts +24 -1
  342. package/dist/humain/hcode/notices.d.ts.map +1 -1
  343. package/dist/humain/hcode/notices.js +93 -7
  344. package/dist/humain/hcode/notices.js.map +1 -1
  345. package/dist/humain/hcode/provider.d.ts +7 -3
  346. package/dist/humain/hcode/provider.d.ts.map +1 -1
  347. package/dist/humain/hcode/provider.js +123 -19
  348. package/dist/humain/hcode/provider.js.map +1 -1
  349. package/dist/humain/hcode/selection.d.ts +2 -0
  350. package/dist/humain/hcode/selection.d.ts.map +1 -1
  351. package/dist/humain/hcode/selection.js +8 -1
  352. package/dist/humain/hcode/selection.js.map +1 -1
  353. package/dist/humain/hcode/transport.d.ts +13 -10
  354. package/dist/humain/hcode/transport.d.ts.map +1 -1
  355. package/dist/humain/hcode/transport.js +103 -148
  356. package/dist/humain/hcode/transport.js.map +1 -1
  357. package/dist/humain/hcode/wire.d.ts +3 -0
  358. package/dist/humain/hcode/wire.d.ts.map +1 -1
  359. package/dist/humain/hcode/wire.js +11 -0
  360. package/dist/humain/hcode/wire.js.map +1 -1
  361. package/dist/humain/metadata/contracts.d.ts +1 -0
  362. package/dist/humain/metadata/contracts.d.ts.map +1 -1
  363. package/dist/humain/metadata/contracts.js +2 -1
  364. package/dist/humain/metadata/contracts.js.map +1 -1
  365. package/dist/humain/web-access/vendor/anysearch.d.ts.map +1 -1
  366. package/dist/humain/web-access/vendor/anysearch.js +7 -3
  367. package/dist/humain/web-access/vendor/anysearch.js.map +1 -1
  368. package/dist/humain/web-access/vendor/autom.d.ts +4 -0
  369. package/dist/humain/web-access/vendor/autom.d.ts.map +1 -0
  370. package/dist/humain/web-access/vendor/autom.js +191 -0
  371. package/dist/humain/web-access/vendor/autom.js.map +1 -0
  372. package/dist/humain/web-access/vendor/cloro.d.ts +4 -0
  373. package/dist/humain/web-access/vendor/cloro.d.ts.map +1 -0
  374. package/dist/humain/web-access/vendor/cloro.js +236 -0
  375. package/dist/humain/web-access/vendor/cloro.js.map +1 -0
  376. package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
  377. package/dist/humain/web-access/vendor/curator-page.js +7 -1
  378. package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
  379. package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
  380. package/dist/humain/web-access/vendor/curator-server.js +6 -0
  381. package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
  382. package/dist/humain/web-access/vendor/domain-filter-normalization.d.ts +8 -0
  383. package/dist/humain/web-access/vendor/domain-filter-normalization.d.ts.map +1 -1
  384. package/dist/humain/web-access/vendor/domain-filter-normalization.js +37 -0
  385. package/dist/humain/web-access/vendor/domain-filter-normalization.js.map +1 -1
  386. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts +28 -8
  387. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts.map +1 -1
  388. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js +135 -34
  389. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js.map +1 -1
  390. package/dist/humain/web-access/vendor/duckduckgo.d.ts +1 -1
  391. package/dist/humain/web-access/vendor/duckduckgo.d.ts.map +1 -1
  392. package/dist/humain/web-access/vendor/duckduckgo.js +10 -3
  393. package/dist/humain/web-access/vendor/duckduckgo.js.map +1 -1
  394. package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
  395. package/dist/humain/web-access/vendor/extract.js +61 -5
  396. package/dist/humain/web-access/vendor/extract.js.map +1 -1
  397. package/dist/humain/web-access/vendor/gemini-search.d.ts +3 -3
  398. package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
  399. package/dist/humain/web-access/vendor/gemini-search.js +35 -5
  400. package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
  401. package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
  402. package/dist/humain/web-access/vendor/index.js +8 -1
  403. package/dist/humain/web-access/vendor/index.js.map +1 -1
  404. package/dist/humain/web-access/vendor/page-query.d.ts +5 -0
  405. package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
  406. package/dist/humain/web-access/vendor/page-query.js +12 -2
  407. package/dist/humain/web-access/vendor/page-query.js.map +1 -1
  408. package/dist/humain/web-access/vendor/specstream.d.ts +6 -0
  409. package/dist/humain/web-access/vendor/specstream.d.ts.map +1 -0
  410. package/dist/humain/web-access/vendor/specstream.js +253 -0
  411. package/dist/humain/web-access/vendor/specstream.js.map +1 -0
  412. package/dist/humain/web-access/vendor/tool-activation.d.ts.map +1 -1
  413. package/dist/humain/web-access/vendor/tool-activation.js +21 -5
  414. package/dist/humain/web-access/vendor/tool-activation.js.map +1 -1
  415. package/dist/humain/web-access/vendor/upgrade-notice.d.ts +1 -1
  416. package/dist/humain/web-access/vendor/upgrade-notice.js +1 -1
  417. package/dist/humain/web-access/vendor/upgrade-notice.js.map +1 -1
  418. package/dist/humain/web-access/vendor/utils.d.ts +1 -0
  419. package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
  420. package/dist/humain/web-access/vendor/utils.js +3 -0
  421. package/dist/humain/web-access/vendor/utils.js.map +1 -1
  422. package/dist/humain/web-access/vendor/video-extract.js +2 -2
  423. package/dist/humain/web-access/vendor/video-extract.js.map +1 -1
  424. package/dist/humain/web-access/vendor/web-tool-core.d.ts +13 -0
  425. package/dist/humain/web-access/vendor/web-tool-core.d.ts.map +1 -1
  426. package/dist/humain/web-access/vendor/web-tool-core.js +16 -5
  427. package/dist/humain/web-access/vendor/web-tool-core.js.map +1 -1
  428. package/dist/humain/web-access/vendor/youtube-extract.js +2 -2
  429. package/dist/humain/web-access/vendor/youtube-extract.js.map +1 -1
  430. package/dist/index.d.ts +0 -2
  431. package/dist/index.d.ts.map +1 -1
  432. package/dist/index.js.map +1 -1
  433. package/dist/main.d.ts.map +1 -1
  434. package/dist/main.js +96 -28
  435. package/dist/main.js.map +1 -1
  436. package/dist/modes/diagnostics-stderr.d.ts +4 -0
  437. package/dist/modes/diagnostics-stderr.d.ts.map +1 -0
  438. package/dist/modes/diagnostics-stderr.js +11 -0
  439. package/dist/modes/diagnostics-stderr.js.map +1 -0
  440. package/dist/modes/interactive/components/assistant-message.d.ts +1 -1
  441. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  442. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  443. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  444. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  445. package/dist/modes/interactive/components/config-selector.js +5 -2
  446. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  447. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  448. package/dist/modes/interactive/components/extension-selector.js +14 -5
  449. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  450. package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
  451. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  452. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  453. package/dist/modes/interactive/components/keybinding-hints.d.ts +2 -0
  454. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  455. package/dist/modes/interactive/components/keybinding-hints.js +6 -0
  456. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  457. package/dist/modes/interactive/components/model-selector.d.ts +10 -0
  458. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  459. package/dist/modes/interactive/components/model-selector.js +101 -23
  460. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  461. package/dist/modes/interactive/components/oauth-selector.d.ts +5 -0
  462. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  463. package/dist/modes/interactive/components/oauth-selector.js +17 -6
  464. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  465. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -1
  466. package/dist/modes/interactive/components/radius-login-selector.js +2 -1
  467. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -1
  468. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  469. package/dist/modes/interactive/components/scoped-models-selector.js +13 -6
  470. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  471. package/dist/modes/interactive/components/session-selector.d.ts +8 -1
  472. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  473. package/dist/modes/interactive/components/session-selector.js +41 -9
  474. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  475. package/dist/modes/interactive/components/settings-submenu.d.ts +1 -1
  476. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  477. package/dist/modes/interactive/components/settings-submenu.js +5 -1
  478. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  479. package/dist/modes/interactive/components/status-indicator.d.ts +0 -17
  480. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  481. package/dist/modes/interactive/components/status-indicator.js +1 -78
  482. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  483. package/dist/modes/interactive/components/themed-text.d.ts +1 -1
  484. package/dist/modes/interactive/components/themed-text.d.ts.map +1 -1
  485. package/dist/modes/interactive/components/themed-text.js.map +1 -1
  486. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  487. package/dist/modes/interactive/components/thinking-selector.js +5 -1
  488. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  489. package/dist/modes/interactive/components/tool-execution.d.ts +1 -1
  490. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  491. package/dist/modes/interactive/components/tool-execution.js +3 -1
  492. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  493. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
  494. package/dist/modes/interactive/components/trust-selector.js +14 -5
  495. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  496. package/dist/modes/interactive/components/user-message.d.ts +1 -1
  497. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  498. package/dist/modes/interactive/components/user-message.js.map +1 -1
  499. package/dist/modes/interactive/components/visual-truncate.d.ts +2 -2
  500. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  501. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  502. package/dist/modes/interactive/interactive-mode.d.ts +20 -2
  503. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  504. package/dist/modes/interactive/interactive-mode.js +605 -223
  505. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  506. package/dist/modes/interactive/model-catalog-refresh.d.ts +4 -0
  507. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -1
  508. package/dist/modes/interactive/model-catalog-refresh.js +40 -1
  509. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -1
  510. package/dist/modes/interactive/oauth-account-format.d.ts +6 -2
  511. package/dist/modes/interactive/oauth-account-format.d.ts.map +1 -1
  512. package/dist/modes/interactive/oauth-account-format.js +12 -3
  513. package/dist/modes/interactive/oauth-account-format.js.map +1 -1
  514. package/dist/modes/interactive/session-share.js +2 -0
  515. package/dist/modes/interactive/session-share.js.map +1 -1
  516. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  517. package/dist/modes/interactive/theme/theme.js +1 -0
  518. package/dist/modes/interactive/theme/theme.js.map +1 -1
  519. package/dist/modes/print-mode.d.ts.map +1 -1
  520. package/dist/modes/print-mode.js +30 -32
  521. package/dist/modes/print-mode.js.map +1 -1
  522. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  523. package/dist/modes/rpc/rpc-mode.js +26 -39
  524. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  525. package/dist/modes/rpc/rpc-types.d.ts +1 -0
  526. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  527. package/dist/modes/rpc/rpc-types.js.map +1 -1
  528. package/dist/package-manager-cli.d.ts.map +1 -1
  529. package/dist/package-manager-cli.js +14 -1
  530. package/dist/package-manager-cli.js.map +1 -1
  531. package/dist/utils/abort.d.ts +5 -0
  532. package/dist/utils/abort.d.ts.map +1 -1
  533. package/dist/utils/abort.js +9 -0
  534. package/dist/utils/abort.js.map +1 -1
  535. package/dist/utils/changelog.d.ts.map +1 -1
  536. package/dist/utils/changelog.js +3 -2
  537. package/dist/utils/changelog.js.map +1 -1
  538. package/dist/utils/flush-stdout.d.ts +8 -0
  539. package/dist/utils/flush-stdout.d.ts.map +1 -0
  540. package/dist/utils/flush-stdout.js +23 -0
  541. package/dist/utils/flush-stdout.js.map +1 -0
  542. package/dist/utils/image-process.d.ts +2 -0
  543. package/dist/utils/image-process.d.ts.map +1 -1
  544. package/dist/utils/image-process.js +3 -3
  545. package/dist/utils/image-process.js.map +1 -1
  546. package/dist/utils/image-resize-core.js +2 -2
  547. package/dist/utils/image-resize-core.js.map +1 -1
  548. package/dist/utils/shell.d.ts +2 -0
  549. package/dist/utils/shell.d.ts.map +1 -1
  550. package/dist/utils/shell.js +19 -0
  551. package/dist/utils/shell.js.map +1 -1
  552. package/docs/cli.md +1 -1
  553. package/docs/development.md +0 -13
  554. package/docs/extensions.md +6 -4
  555. package/docs/flow.md +4 -62
  556. package/docs/humain-code-forge-architecture.md +1 -47
  557. package/docs/humain-code-forge-flow-walkthrough.md +1 -1
  558. package/docs/humain-code.md +1 -1
  559. package/docs/keybindings.md +2 -0
  560. package/docs/llama-cpp.md +5 -5
  561. package/docs/models-configuration.md +4 -2
  562. package/docs/nvidia-rtx-llama-cpp.md +5 -5
  563. package/docs/providers.md +14 -9
  564. package/docs/rpc-commands.md +1 -1
  565. package/docs/run-preflight.md +1 -1
  566. package/docs/slash-commands.md +1 -1
  567. package/docs/tui.md +2 -0
  568. package/examples/README.md +0 -3
  569. package/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
  570. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  571. package/examples/extensions/gondolin/index.ts +4 -7
  572. package/examples/tsconfig.json +96 -76
  573. package/npm-shrinkwrap.json +285 -764
  574. package/package.json +24 -37
  575. package/schemas/keybindings.schema.json +20 -0
  576. package/schemas/models.schema.json +5 -1
  577. package/schemas/settings.schema.json +0 -13
  578. package/src/humain/web-access/UPSTREAM.md +52 -1
  579. package/src/humain/web-access/upstream.json +5 -5
  580. package/src/humain/web-access/vendor/CHANGELOG.md +29 -0
  581. package/dist/bundle/chunks/adaptive-peer-worker-X2ZNZE3S.js +0 -8
  582. package/dist/bundle/chunks/adaptive-session-host-7KDSQV5I.js +0 -162
  583. package/dist/bundle/chunks/anthropic-messages-TQK3FUV3.js +0 -68
  584. package/dist/bundle/chunks/azure-openai-responses-JY7OSLH2.js +0 -15
  585. package/dist/bundle/chunks/chunk-5L4PBYC7.js +0 -11
  586. package/dist/bundle/chunks/chunk-6PNQYO6A.js +0 -10
  587. package/dist/bundle/chunks/chunk-CRN54O4D.js +0 -24
  588. package/dist/bundle/chunks/chunk-CTU2ECLD.js +0 -7
  589. package/dist/bundle/chunks/chunk-DBL35X7L.js +0 -3
  590. package/dist/bundle/chunks/chunk-GME4AWDG.js +0 -23
  591. package/dist/bundle/chunks/chunk-GTILMMUF.js +0 -12
  592. package/dist/bundle/chunks/chunk-J57HOSWD.js +0 -21
  593. package/dist/bundle/chunks/chunk-KQM7ZGL6.js +0 -11
  594. package/dist/bundle/chunks/chunk-MX4Q4W6H.js +0 -214
  595. package/dist/bundle/chunks/chunk-NXA6NEHE.js +0 -54
  596. package/dist/bundle/chunks/chunk-PJACZCIR.js +0 -2
  597. package/dist/bundle/chunks/chunk-T5A6T24H.js +0 -93
  598. package/dist/bundle/chunks/chunk-WCFHG6NO.js +0 -16
  599. package/dist/bundle/chunks/chunk-ZJUU6WOV.js +0 -2052
  600. package/dist/bundle/chunks/compat-ZK2DIW3P.js +0 -15
  601. package/dist/bundle/chunks/dist-EY7YKQHB.js +0 -11
  602. package/dist/bundle/chunks/dist-J5IUPLMH.js +0 -37
  603. package/dist/bundle/chunks/dist-cjs-2SKN226B.js +0 -184
  604. package/dist/bundle/chunks/entry-AL54ZGYO.js +0 -2
  605. package/dist/bundle/chunks/es5-GYTRHFKS.js +0 -77
  606. package/dist/bundle/chunks/google-generative-ai-UL7YEQ6J.js +0 -21
  607. package/dist/bundle/chunks/google-vertex-OTMSPUYH.js +0 -26
  608. package/dist/bundle/chunks/host-75YAHLDR.js +0 -3
  609. package/dist/bundle/chunks/interactive-mode-IW4PIVAQ.js +0 -5
  610. package/dist/bundle/chunks/mistral-conversations-E72Y6OC3.js +0 -43
  611. package/dist/bundle/chunks/pdfjs-AKD6EBKN.js +0 -3614
  612. package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-FH3KJM4H.js +0 -326
  613. package/dist/bundle/chunks/pdfjs-openjpeg-SKR7C34X.js +0 -671
  614. package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-VUBL7UEE.js +0 -974
  615. package/dist/bundle/chunks/session-picker-DM6S37IF.js +0 -4
  616. package/dist/bundle/chunks/startup-ui-4GGLWNSU.js +0 -3
  617. package/dist/bundle/chunks/virtual-modules-TI3W24YL.js +0 -28
  618. package/dist/core/internal-process.d.ts +0 -23
  619. package/dist/core/internal-process.d.ts.map +0 -1
  620. package/dist/core/internal-process.js +0 -88
  621. package/dist/core/internal-process.js.map +0 -1
  622. package/dist/humain/adaptive-execution.d.ts +0 -51
  623. package/dist/humain/adaptive-execution.d.ts.map +0 -1
  624. package/dist/humain/adaptive-execution.js +0 -100
  625. package/dist/humain/adaptive-execution.js.map +0 -1
  626. package/dist/humain/adaptive-peer-process.d.ts +0 -44
  627. package/dist/humain/adaptive-peer-process.d.ts.map +0 -1
  628. package/dist/humain/adaptive-peer-process.js +0 -159
  629. package/dist/humain/adaptive-peer-process.js.map +0 -1
  630. package/dist/humain/adaptive-peer-worker.d.ts +0 -3
  631. package/dist/humain/adaptive-peer-worker.d.ts.map +0 -1
  632. package/dist/humain/adaptive-peer-worker.js +0 -122
  633. package/dist/humain/adaptive-peer-worker.js.map +0 -1
  634. package/dist/humain/adaptive-runtime-types.d.ts +0 -621
  635. package/dist/humain/adaptive-runtime-types.d.ts.map +0 -1
  636. package/dist/humain/adaptive-runtime-types.js +0 -3
  637. package/dist/humain/adaptive-runtime-types.js.map +0 -1
  638. package/dist/humain/adaptive-session-host.d.ts +0 -113
  639. package/dist/humain/adaptive-session-host.d.ts.map +0 -1
  640. package/dist/humain/adaptive-session-host.js +0 -1838
  641. package/dist/humain/adaptive-session-host.js.map +0 -1
  642. package/dist/utils/deprecation.d.ts +0 -4
  643. package/dist/utils/deprecation.d.ts.map +0 -1
  644. package/dist/utils/deprecation.js +0 -13
  645. package/dist/utils/deprecation.js.map +0 -1
  646. package/examples/plugins/pi-example-plugin/README.md +0 -38
  647. package/examples/plugins/pi-example-plugin/package.json +0 -10
  648. package/examples/plugins/pi-example-plugin/src/contract.ts +0 -13
  649. package/examples/plugins/pi-example-plugin/src/session.ts +0 -24
  650. package/examples/plugins/pi-example-plugin/src/tui.ts +0 -31
@@ -0,0 +1,74 @@
1
+ import { hcodeDisplayName } from "./environment.js";
2
+ /** Guidance for a direct login when the server's sign-in settings don't match this CLI. */
3
+ export const HCODE_LOGIN_MISMATCH_DETAILS = "HUMAIN Code's sign-in settings (/api/cli/config or issuer discovery) don't match what this CLI version accepts. Update the CLI with `humain-code update`, or ask the HUMAIN Code platform team to check the server's CLI sign-in configuration.";
4
+ const EMPTY_REASONS = {
5
+ no_cli_models_approved: {
6
+ reason: "no model is approved for CLI",
7
+ fix: "Ask an admin to set a model to Web + CLI or CLI only in Settings > Model Access.",
8
+ },
9
+ provider_key_not_cli_enabled: {
10
+ reason: "the provider key isn't enabled for CLI",
11
+ fix: "Ask an admin to enable CLI on the key in Settings > Provider Keys.",
12
+ },
13
+ cli_capacity_unconfigured: {
14
+ reason: "CLI capacity hasn't been configured",
15
+ fix: "Ask the HUMAIN Code platform team to check the deployment's CLI capacity limits.",
16
+ },
17
+ provider_key_not_dedicated: {
18
+ reason: "the provider key is shared or isn't approved for CLI use",
19
+ fix: "Ask an admin to configure a dedicated key for HUMAIN Code CLI.",
20
+ },
21
+ models_not_qualified: {
22
+ reason: "this server hasn't finished CLI setup for the approved models",
23
+ fix: "Ask an admin to report it to the HUMAIN Code platform team.",
24
+ },
25
+ };
26
+ /** Say why the account's catalog is empty and what to do; servers without a reason keep the generic text. */
27
+ export function hcodeEmptyCatalogMessage(reason) {
28
+ if (!reason)
29
+ return "Your admin hasn't enabled CLI models yet.";
30
+ const { reason: why, fix } = EMPTY_REASONS[reason];
31
+ return `No models are available in the CLI: ${why}. ${fix}`;
32
+ }
33
+ /** The short reason and who can fix it: an admin, the server's configuration or the network. */
34
+ export function hcodeEmptyCatalogReason(cause) {
35
+ if (cause.kind === "failed")
36
+ return { reason: "the model list couldn't be loaded", fix: "Check your network, VPN or Zscaler." };
37
+ return cause.reason
38
+ ? EMPTY_REASONS[cause.reason]
39
+ : { reason: "your admin hasn't enabled CLI models yet", fix: "Ask an admin to enable a model for CLI." };
40
+ }
41
+ /** Non-blocking notice after a sign-in that produced no models. */
42
+ export function hcodeEmptyCatalogNotice(environmentId, email, cause) {
43
+ const { reason, fix } = hcodeEmptyCatalogReason(cause);
44
+ return [
45
+ `✓ Signed in to ${hcodeDisplayName(environmentId)}${email ? ` as ${email}` : ""}`,
46
+ ` No models available in the CLI yet: ${reason}.`,
47
+ ` ${fix}`,
48
+ " You can keep using your other providers. I'll check again automatically.",
49
+ " /model to retry · /login status for details",
50
+ ].join("\n");
51
+ }
52
+ /** `/login` row state for a readiness check; `undefined` means the check is still running. */
53
+ export function hcodeLoginAvailability(readiness) {
54
+ if (!readiness)
55
+ return { state: "pending", text: "checking connection…" };
56
+ switch (readiness.kind) {
57
+ case "ready":
58
+ return { state: "ready", text: "connected" };
59
+ case "unreachable":
60
+ return { state: "failed", text: `Can't reach ${readiness.host}: check VPN/Zscaler [Retry]` };
61
+ case "mismatch":
62
+ return { state: "failed", text: "Server sign-in settings don't match this CLI version [Details]" };
63
+ case "unavailable":
64
+ return { state: "failed", text: "Sign-in is not available in this environment [Retry]" };
65
+ }
66
+ }
67
+ /** Says that the saved sign-in belongs to another environment and how to use it, e.g. after starting without --env. */
68
+ export function hcodeSignedInElsewhereNotice(environmentId, elsewhere) {
69
+ const other = elsewhere[0];
70
+ if (!other)
71
+ return undefined;
72
+ return `${hcodeDisplayName(environmentId)}: not signed in. Your saved sign-in is for ${hcodeDisplayName(other)}: start humain-code with --env ${other} to use it, or /login to sign in here.`;
73
+ }
74
+ //# sourceMappingURL=login-copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login-copy.js","sourceRoot":"","sources":["../../../src/humain/hcode/login-copy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAMpD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,4BAA4B,GACxC,iPAAiP,CAAC;AAEnP,MAAM,aAAa,GAA+E;IACjG,sBAAsB,EAAE;QACvB,MAAM,EAAE,8BAA8B;QACtC,GAAG,EAAE,kFAAkF;KACvF;IACD,4BAA4B,EAAE;QAC7B,MAAM,EAAE,wCAAwC;QAChD,GAAG,EAAE,oEAAoE;KACzE;IACD,yBAAyB,EAAE;QAC1B,MAAM,EAAE,qCAAqC;QAC7C,GAAG,EAA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FAA8F;AAC9F,MAAM,UAAU,sBAAsB,CAAC,SAA0C;IAIhF,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC;IAC1E,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,OAAO;YACX,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;QAC9C,KAAK,aAAa;YACjB,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,SAAS,CAAC,IAAI,6BAA6B,EAAE,CAAC;QAC9F,KAAK,UAAU;YACd,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,gEAAgE,EAAE,CAAC;QACpG,KAAK,aAAa;YACjB,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,sDAAsD,EAAE,CAAC;IAC3F,CAAC;AACF,CAAC;AAED,uHAAuH;AACvH,MAAM,UAAU,4BAA4B,CAAC,aAAqB,EAAE,SAA4B;IAC/F,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,OAAO,GAAG,gBAAgB,CAAC,aAAa,CAAC,8CAA8C,gBAAgB,CAAC,KAAK,CAAC,kCAAkC,KAAK,wCAAwC,CAAC;AAC/L,CAAC","sourcesContent":["// Plain-language copy for HUMAIN Code sign-in readiness and an empty model list; fixed text only, never server text.\nimport type { HcodeCatalogEmptyReason } from \"./contracts.ts\";\nimport { hcodeDisplayName } from \"./environment.ts\";\nimport type { HcodeLoginReadiness } from \"./facade.ts\";\n\n/** Why a signed-in account has no models: Forge's reason (if it sent one), or the list couldn't be loaded. */\nexport type HcodeEmptyCatalogCause = { kind: \"empty\"; reason?: HcodeCatalogEmptyReason } | { kind: \"failed\" };\n\n/** Guidance for a direct login when the server's sign-in settings don't match this CLI. */\nexport const HCODE_LOGIN_MISMATCH_DETAILS =\n\t\"HUMAIN Code's sign-in settings (/api/cli/config or issuer discovery) don't match what this CLI version accepts. Update the CLI with `humain-code update`, or ask the HUMAIN Code platform team to check the server's CLI sign-in configuration.\";\n\nconst EMPTY_REASONS: Readonly<Record<HcodeCatalogEmptyReason, { reason: string; fix: string }>> = {\n\tno_cli_models_approved: {\n\t\treason: \"no model is approved for CLI\",\n\t\tfix: \"Ask an admin to set a model to Web + CLI or CLI only in Settings > Model Access.\",\n\t},\n\tprovider_key_not_cli_enabled: {\n\t\treason: \"the provider key isn't enabled for CLI\",\n\t\tfix: \"Ask an admin to enable CLI on the key in Settings > Provider Keys.\",\n\t},\n\tcli_capacity_unconfigured: {\n\t\treason: \"CLI capacity hasn't been configured\",\n\t\tfix: \"Ask the HUMAIN Code platform team to check the deployment's CLI capacity limits.\",\n\t},\n\tprovider_key_not_dedicated: {\n\t\treason: \"the provider key is shared or isn't approved for CLI use\",\n\t\tfix: \"Ask an admin to configure a dedicated key for HUMAIN Code CLI.\",\n\t},\n\tmodels_not_qualified: {\n\t\treason: \"this server hasn't finished CLI setup for the approved models\",\n\t\tfix: \"Ask an admin to report it to the HUMAIN Code platform team.\",\n\t},\n};\n\n/** Say why the account's catalog is empty and what to do; servers without a reason keep the generic text. */\nexport function hcodeEmptyCatalogMessage(reason: HcodeCatalogEmptyReason | undefined): string {\n\tif (!reason) return \"Your admin hasn't enabled CLI models yet.\";\n\tconst { reason: why, fix } = EMPTY_REASONS[reason];\n\treturn `No models are available in the CLI: ${why}. ${fix}`;\n}\n\n/** The short reason and who can fix it: an admin, the server's configuration or the network. */\nexport function hcodeEmptyCatalogReason(cause: HcodeEmptyCatalogCause): { reason: string; fix: string } {\n\tif (cause.kind === \"failed\")\n\t\treturn { reason: \"the model list couldn't be loaded\", fix: \"Check your network, VPN or Zscaler.\" };\n\treturn cause.reason\n\t\t? EMPTY_REASONS[cause.reason]\n\t\t: { reason: \"your admin hasn't enabled CLI models yet\", fix: \"Ask an admin to enable a model for CLI.\" };\n}\n\n/** Non-blocking notice after a sign-in that produced no models. */\nexport function hcodeEmptyCatalogNotice(\n\tenvironmentId: string,\n\temail: string | undefined,\n\tcause: HcodeEmptyCatalogCause,\n): string {\n\tconst { reason, fix } = hcodeEmptyCatalogReason(cause);\n\treturn [\n\t\t`✓ Signed in to ${hcodeDisplayName(environmentId)}${email ? ` as ${email}` : \"\"}`,\n\t\t` No models available in the CLI yet: ${reason}.`,\n\t\t` ${fix}`,\n\t\t\" You can keep using your other providers. I'll check again automatically.\",\n\t\t\" /model to retry · /login status for details\",\n\t].join(\"\\n\");\n}\n\n/** `/login` row state for a readiness check; `undefined` means the check is still running. */\nexport function hcodeLoginAvailability(readiness: HcodeLoginReadiness | undefined): {\n\tstate: \"pending\" | \"ready\" | \"failed\";\n\ttext: string;\n} {\n\tif (!readiness) return { state: \"pending\", text: \"checking connection…\" };\n\tswitch (readiness.kind) {\n\t\tcase \"ready\":\n\t\t\treturn { state: \"ready\", text: \"connected\" };\n\t\tcase \"unreachable\":\n\t\t\treturn { state: \"failed\", text: `Can't reach ${readiness.host}: check VPN/Zscaler [Retry]` };\n\t\tcase \"mismatch\":\n\t\t\treturn { state: \"failed\", text: \"Server sign-in settings don't match this CLI version [Details]\" };\n\t\tcase \"unavailable\":\n\t\t\treturn { state: \"failed\", text: \"Sign-in is not available in this environment [Retry]\" };\n\t}\n}\n\n/** Says that the saved sign-in belongs to another environment and how to use it, e.g. after starting without --env. */\nexport function hcodeSignedInElsewhereNotice(environmentId: string, elsewhere: readonly string[]): string | undefined {\n\tconst other = elsewhere[0];\n\tif (!other) return undefined;\n\treturn `${hcodeDisplayName(environmentId)}: not signed in. Your saved sign-in is for ${hcodeDisplayName(other)}: start humain-code with --env ${other} to use it, or /login to sign in here.`;\n}\n"]}
@@ -0,0 +1,26 @@
1
+ /** User-visible text for each sign-in stage; persistence stages keep the possible-state-change wording. */
2
+ export declare const HCODE_LOGIN_FAILURES: {
3
+ readonly configuration: "HUMAIN Code sign-in failed (configuration): the sign-in configuration was unavailable or did not match this environment.";
4
+ readonly discovery: "HUMAIN Code sign-in failed: the issuer metadata doesn’t match the sign-in configuration.";
5
+ readonly discoveryUnavailable: "HUMAIN Code sign-in failed: the issuer discovery service could not be reached or rejected the request.";
6
+ readonly device: "HUMAIN Code sign-in failed: the sign-in server sent an unexpected reply.";
7
+ readonly deviceUnavailable: "HUMAIN Code sign-in failed: the sign-in server could not be reached or rejected the device request.";
8
+ readonly networkTimeout: "HUMAIN Code sign-in failed: the network request timed out. Check your connection and try again.";
9
+ readonly denied: "HUMAIN Code sign-in was denied.";
10
+ readonly expired: "The HUMAIN Code sign-in code expired.";
11
+ readonly accountChanged: "Another session changed your HUMAIN Code sign-in. Refresh local models and try signing in again.";
12
+ readonly accountTransport: "HUMAIN Code sign-in failed (account request): the account service could not be reached or timed out.";
13
+ readonly accountResponse: "HUMAIN Code sign-in failed (account response): the account service returned an unreadable response.";
14
+ readonly accountSchema: "HUMAIN Code sign-in failed (account details): the account details had an unexpected format.";
15
+ readonly accountEnvironment: "HUMAIN Code sign-in failed (account environment): the account belongs to a different environment.";
16
+ readonly localStorage: "HUMAIN Code sign-in failed (local secure storage): saving the account failed. Stored state may have changed. Inspect accounts and refresh local models before retrying.";
17
+ readonly publication: "HUMAIN Code sign-in failed (account reference): publishing the saved account failed. Stored state may have changed. Inspect accounts and refresh local models before retrying.";
18
+ };
19
+ /** Safe classification for a rejected HTTP request or one that exceeded the local deadline. */
20
+ export declare class HcodeHttpError extends Error {
21
+ readonly kind: "unavailable" | "timeout";
22
+ constructor(kind: "unavailable" | "timeout");
23
+ }
24
+ /** Runs one sign-in stage; its unexpected failures become fixed text, while safe errors and cancellation pass unchanged. */
25
+ export declare function hcodeLoginStage<T>(stage: keyof typeof HCODE_LOGIN_FAILURES, signal: AbortSignal, work: () => Promise<T>): Promise<T>;
26
+ //# sourceMappingURL=login-failure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login-failure.d.ts","sourceRoot":"","sources":["../../../src/humain/hcode/login-failure.ts"],"names":[],"mappings":"AAMA,2GAA2G;AAC3G,eAAO,MAAM,oBAAoB;aAChC,aAAa,EACZ,0HAA0H;aAC3H,SAAS,EAAE,0FAA0F;aACrG,oBAAoB,EACnB,wGAAwG;aACzG,MAAM,EAAE,0EAA0E;aAClF,iBAAiB,EAChB,qGAAqG;aACtG,cAAc,EAAE,iGAAiG;aACjH,MAAM,EAAE,iCAAiC;aACzC,OAAO,EAAE,uCAAuC;aAChD,cAAc,EAAE,kGAAkG;aAClH,gBAAgB,EACf,sGAAsG;aACvG,eAAe,EACd,qGAAqG;aACtG,aAAa,EAAE,6FAA6F;aAC5G,kBAAkB,EACjB,mGAAmG;aACpG,YAAY;aACZ,WAAW;CACF,CAAC;AAEX,+FAA+F;AAC/F,qBAAa,cAAe,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzC,YAAY,IAAI,EAAE,aAAa,GAAG,SAAS,EAG1C;CACD;AAED,4HAA4H;AAC5H,wBAAsB,eAAe,CAAC,CAAC,EACtC,KAAK,EAAE,MAAM,OAAO,oBAAoB,EACxC,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACpB,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
@@ -0,0 +1,50 @@
1
+ // Fixed, allowlisted sign-in failure stages. The text never carries underlying errors, URLs, paths, claims or tokens.
2
+ import { SafeCredentialError } from "../../core/safe-credential-error.js";
3
+ const STATE_MAY_HAVE_CHANGED = "Stored state may have changed. Inspect accounts and refresh local models before retrying.";
4
+ /** User-visible text for each sign-in stage; persistence stages keep the possible-state-change wording. */
5
+ export const HCODE_LOGIN_FAILURES = {
6
+ configuration: "HUMAIN Code sign-in failed (configuration): the sign-in configuration was unavailable or did not match this environment.",
7
+ discovery: "HUMAIN Code sign-in failed: the issuer metadata doesn’t match the sign-in configuration.",
8
+ discoveryUnavailable: "HUMAIN Code sign-in failed: the issuer discovery service could not be reached or rejected the request.",
9
+ device: "HUMAIN Code sign-in failed: the sign-in server sent an unexpected reply.",
10
+ deviceUnavailable: "HUMAIN Code sign-in failed: the sign-in server could not be reached or rejected the device request.",
11
+ networkTimeout: "HUMAIN Code sign-in failed: the network request timed out. Check your connection and try again.",
12
+ denied: "HUMAIN Code sign-in was denied.",
13
+ expired: "The HUMAIN Code sign-in code expired.",
14
+ accountChanged: "Another session changed your HUMAIN Code sign-in. Refresh local models and try signing in again.",
15
+ accountTransport: "HUMAIN Code sign-in failed (account request): the account service could not be reached or timed out.",
16
+ accountResponse: "HUMAIN Code sign-in failed (account response): the account service returned an unreadable response.",
17
+ accountSchema: "HUMAIN Code sign-in failed (account details): the account details had an unexpected format.",
18
+ accountEnvironment: "HUMAIN Code sign-in failed (account environment): the account belongs to a different environment.",
19
+ localStorage: `HUMAIN Code sign-in failed (local secure storage): saving the account failed. ${STATE_MAY_HAVE_CHANGED}`,
20
+ publication: `HUMAIN Code sign-in failed (account reference): publishing the saved account failed. ${STATE_MAY_HAVE_CHANGED}`,
21
+ };
22
+ /** Safe classification for a rejected HTTP request or one that exceeded the local deadline. */
23
+ export class HcodeHttpError extends Error {
24
+ kind;
25
+ constructor(kind) {
26
+ super("HUMAIN Code request unavailable.");
27
+ this.kind = kind;
28
+ }
29
+ }
30
+ /** Runs one sign-in stage; its unexpected failures become fixed text, while safe errors and cancellation pass unchanged. */
31
+ export async function hcodeLoginStage(stage, signal, work) {
32
+ try {
33
+ return await work();
34
+ }
35
+ catch (error) {
36
+ if (error instanceof SafeCredentialError || signal.aborted)
37
+ throw error;
38
+ const failure = error instanceof HcodeHttpError
39
+ ? error.kind === "timeout"
40
+ ? "networkTimeout"
41
+ : stage === "device"
42
+ ? "deviceUnavailable"
43
+ : stage === "discovery"
44
+ ? "discoveryUnavailable"
45
+ : stage
46
+ : stage;
47
+ throw new SafeCredentialError(HCODE_LOGIN_FAILURES[failure]);
48
+ }
49
+ }
50
+ //# sourceMappingURL=login-failure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login-failure.js","sourceRoot":"","sources":["../../../src/humain/hcode/login-failure.ts"],"names":[],"mappings":"AAAA,sHAAsH;AACtH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,MAAM,sBAAsB,GAC3B,2FAA2F,CAAC;AAE7F,2GAA2G;AAC3G,MAAM,CAAC,MAAM,oBAAoB,GAAG;IACnC,aAAa,EACZ,0HAA0H;IAC3H,SAAS,EAAE,0FAA0F;IACrG,oBAAoB,EACnB,wGAAwG;IACzG,MAAM,EAAE,0EAA0E;IAClF,iBAAiB,EAChB,qGAAqG;IACtG,cAAc,EAAE,iGAAiG;IACjH,MAAM,EAAE,iCAAiC;IACzC,OAAO,EAAE,uCAAuC;IAChD,cAAc,EAAE,kGAAkG;IAClH,gBAAgB,EACf,sGAAsG;IACvG,eAAe,EACd,qGAAqG;IACtG,aAAa,EAAE,6FAA6F;IAC5G,kBAAkB,EACjB,mGAAmG;IACpG,YAAY,EAAE,iFAAiF,sBAAsB,EAAE;IACvH,WAAW,EAAE,wFAAwF,sBAAsB,EAAE;CACpH,CAAC;AAEX,+FAA+F;AAC/F,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC/B,IAAI,CAA4B;IAEzC,YAAY,IAA+B;QAC1C,KAAK,CAAC,kCAAkC,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAED,4HAA4H;AAC5H,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,KAAwC,EACxC,MAAmB,EACnB,IAAsB;IAEtB,IAAI,CAAC;QACJ,OAAO,MAAM,IAAI,EAAE,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,KAAK,YAAY,mBAAmB,IAAI,MAAM,CAAC,OAAO;YAAE,MAAM,KAAK,CAAC;QACxE,MAAM,OAAO,GACZ,KAAK,YAAY,cAAc;YAC9B,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS;gBACzB,CAAC,CAAC,gBAAgB;gBAClB,CAAC,CAAC,KAAK,KAAK,QAAQ;oBACnB,CAAC,CAAC,mBAAmB;oBACrB,CAAC,CAAC,KAAK,KAAK,WAAW;wBACtB,CAAC,CAAC,sBAAsB;wBACxB,CAAC,CAAC,KAAK;YACV,CAAC,CAAC,KAAK,CAAC;QACV,MAAM,IAAI,mBAAmB,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9D,CAAC;AACF,CAAC","sourcesContent":["// Fixed, allowlisted sign-in failure stages. The text never carries underlying errors, URLs, paths, claims or tokens.\nimport { SafeCredentialError } from \"../../core/safe-credential-error.ts\";\n\nconst STATE_MAY_HAVE_CHANGED =\n\t\"Stored state may have changed. Inspect accounts and refresh local models before retrying.\";\n\n/** User-visible text for each sign-in stage; persistence stages keep the possible-state-change wording. */\nexport const HCODE_LOGIN_FAILURES = {\n\tconfiguration:\n\t\t\"HUMAIN Code sign-in failed (configuration): the sign-in configuration was unavailable or did not match this environment.\",\n\tdiscovery: \"HUMAIN Code sign-in failed: the issuer metadata doesn’t match the sign-in configuration.\",\n\tdiscoveryUnavailable:\n\t\t\"HUMAIN Code sign-in failed: the issuer discovery service could not be reached or rejected the request.\",\n\tdevice: \"HUMAIN Code sign-in failed: the sign-in server sent an unexpected reply.\",\n\tdeviceUnavailable:\n\t\t\"HUMAIN Code sign-in failed: the sign-in server could not be reached or rejected the device request.\",\n\tnetworkTimeout: \"HUMAIN Code sign-in failed: the network request timed out. Check your connection and try again.\",\n\tdenied: \"HUMAIN Code sign-in was denied.\",\n\texpired: \"The HUMAIN Code sign-in code expired.\",\n\taccountChanged: \"Another session changed your HUMAIN Code sign-in. Refresh local models and try signing in again.\",\n\taccountTransport:\n\t\t\"HUMAIN Code sign-in failed (account request): the account service could not be reached or timed out.\",\n\taccountResponse:\n\t\t\"HUMAIN Code sign-in failed (account response): the account service returned an unreadable response.\",\n\taccountSchema: \"HUMAIN Code sign-in failed (account details): the account details had an unexpected format.\",\n\taccountEnvironment:\n\t\t\"HUMAIN Code sign-in failed (account environment): the account belongs to a different environment.\",\n\tlocalStorage: `HUMAIN Code sign-in failed (local secure storage): saving the account failed. ${STATE_MAY_HAVE_CHANGED}`,\n\tpublication: `HUMAIN Code sign-in failed (account reference): publishing the saved account failed. ${STATE_MAY_HAVE_CHANGED}`,\n} as const;\n\n/** Safe classification for a rejected HTTP request or one that exceeded the local deadline. */\nexport class HcodeHttpError extends Error {\n\treadonly kind: \"unavailable\" | \"timeout\";\n\n\tconstructor(kind: \"unavailable\" | \"timeout\") {\n\t\tsuper(\"HUMAIN Code request unavailable.\");\n\t\tthis.kind = kind;\n\t}\n}\n\n/** Runs one sign-in stage; its unexpected failures become fixed text, while safe errors and cancellation pass unchanged. */\nexport async function hcodeLoginStage<T>(\n\tstage: keyof typeof HCODE_LOGIN_FAILURES,\n\tsignal: AbortSignal,\n\twork: () => Promise<T>,\n): Promise<T> {\n\ttry {\n\t\treturn await work();\n\t} catch (error) {\n\t\tif (error instanceof SafeCredentialError || signal.aborted) throw error;\n\t\tconst failure =\n\t\t\terror instanceof HcodeHttpError\n\t\t\t\t? error.kind === \"timeout\"\n\t\t\t\t\t? \"networkTimeout\"\n\t\t\t\t\t: stage === \"device\"\n\t\t\t\t\t\t? \"deviceUnavailable\"\n\t\t\t\t\t\t: stage === \"discovery\"\n\t\t\t\t\t\t\t? \"discoveryUnavailable\"\n\t\t\t\t\t\t\t: stage\n\t\t\t\t: stage;\n\t\tthrow new SafeCredentialError(HCODE_LOGIN_FAILURES[failure]);\n\t}\n}\n"]}
@@ -2,14 +2,37 @@ import type { AssistantMessage } from "@earendil-works/pi-ai";
2
2
  import { type HcodeInferenceError } from "./contracts.ts";
3
3
  export declare const HCODE_PENDING_EXPLANATION = "Pending usage is awaiting provider confirmation. It remains reserved until confirmed or reviewed by an admin. It is not a final charge and is not free usage.";
4
4
  export declare const HCODE_AMBIGUOUS_NOTICE = "HUMAIN Code couldn't confirm this request's outcome. It may still be charged. No automatic retry was sent. Check /usage before trying again.";
5
+ declare const localReasons: {
6
+ readonly account: "The selected HUMAIN Code account or model is no longer current.";
7
+ readonly transport: "HUMAIN Code only supports SSE for this request.";
8
+ readonly envelope: "The CLI could not build a valid HUMAIN Code request envelope.";
9
+ readonly size: "The request exceeds the HUMAIN Code model's request size limit.";
10
+ readonly model: "The request model does not match the selected HUMAIN Code model.";
11
+ readonly reasoning: "The selected HUMAIN Code model does not support the requested thinking level or thinking history.";
12
+ readonly output: "The requested output token limit exceeds the HUMAIN Code model's limit.";
13
+ readonly cache: "HUMAIN Code requires cache retention to be disabled.";
14
+ readonly tools: "The selected HUMAIN Code model does not support tools.";
15
+ readonly strictTools: "HUMAIN Code does not support required strict tool sampling.";
16
+ readonly images: "An image is unsupported or exceeds the selected HUMAIN Code model's limits.";
17
+ readonly cancelled: "The HUMAIN Code request was cancelled before submission.";
18
+ };
19
+ export type HcodeLocalReason = keyof typeof localReasons;
20
+ /** Header names and closed reason values Forge sends with deterministic refusals. */
21
+ export declare const HCODE_REFUSAL_REASON_HEADERS: {
22
+ readonly model_unavailable: readonly ["x-hcode-model-unavailable-reason", string[]];
23
+ readonly unsupported_capability: readonly ["x-hcode-unsupported-capability-reason", string[]];
24
+ };
25
+ /** Render a closed, non-reflecting reason for an inference that never reached the send boundary. */
26
+ export declare function formatHcodeLocalRefusal(reason: unknown): string | undefined;
5
27
  /** Format the server's reset instant in UTC, independently of the host timezone. */
6
28
  export declare function formatHcodeReset(resetAt: string): string;
7
29
  /** Render schema-validated service facts without reading raw diagnostics or granting automatic retry. */
8
- export declare function formatHcodeNotice(failure: HcodeInferenceError, receivedAt: number): {
30
+ export declare function formatHcodeNotice(failure: HcodeInferenceError, receivedAt: number, reason?: unknown): {
9
31
  message: string;
10
32
  lines: readonly string[];
11
33
  retryAfterMs?: number;
12
34
  };
13
35
  /** Shared print/interactive boundary for validated refusals and separate uncertain-outcome warnings. */
14
36
  export declare function formatHcodeMessageNotice(message: AssistantMessage): string | undefined;
37
+ export {};
15
38
  //# sourceMappingURL=notices.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notices.d.ts","sourceRoot":"","sources":["../../../src/humain/hcode/notices.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,KAAK,mBAAmB,EAA6C,MAAM,gBAAgB,CAAC;AAGrG,eAAO,MAAM,yBAAyB,kKAC0H,CAAC;AAEjK,eAAO,MAAM,sBAAsB,iJAC4G,CAAC;AAEhJ,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,yGAAyG;AACzG,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,mBAAmB,EAC5B,UAAU,EAAE,MAAM,GAChB;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAwCA;AAED,wGAAwG;AACxG,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAgBtF"}
1
+ {"version":3,"file":"notices.d.ts","sourceRoot":"","sources":["../../../src/humain/hcode/notices.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,KAAK,mBAAmB,EAA6C,MAAM,gBAAgB,CAAC;AAGrG,eAAO,MAAM,yBAAyB,kKAC0H,CAAC;AAEjK,eAAO,MAAM,sBAAsB,iJAC4G,CAAC;AAEhJ,QAAA,MAAM,YAAY;aACjB,OAAO,EAAE,iEAAiE;aAC1E,SAAS,EAAE,iDAAiD;aAC5D,QAAQ,EAAE,+DAA+D;aACzE,IAAI,EAAE,iEAAiE;aACvE,KAAK,EAAE,kEAAkE;aACzE,SAAS,EAAE,mGAAmG;aAC9G,MAAM,EAAE,yEAAyE;aACjF,KAAK,EAAE,sDAAsD;aAC7D,KAAK,EAAE,wDAAwD;aAC/D,WAAW,EAAE,6DAA6D;aAC1E,MAAM,EAAE,6EAA6E;aACrF,SAAS,EAAE,0DAA0D;CAC5D,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,YAAY,CAAC;AA8BzD,qFAAqF;AACrF,eAAO,MAAM,4BAA4B;;;CAGuE,CAAC;AA0BjH,oGAAoG;AACpG,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG3E;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,yGAAyG;AACzG,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,mBAAmB,EAC5B,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,OAAO,GACd;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAkDA;AAED,wGAAwG;AACxG,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAsBtF"}
@@ -2,22 +2,100 @@ import { parseHcodeInferenceError } from "./contracts.js";
2
2
  import { HCODE_PROVIDER } from "./http.js";
3
3
  export const HCODE_PENDING_EXPLANATION = "Pending usage is awaiting provider confirmation. It remains reserved until confirmed or reviewed by an admin. It is not a final charge and is not free usage.";
4
4
  export const HCODE_AMBIGUOUS_NOTICE = "HUMAIN Code couldn't confirm this request's outcome. It may still be charged. No automatic retry was sent. Check /usage before trying again.";
5
+ const localReasons = {
6
+ account: "The selected HUMAIN Code account or model is no longer current.",
7
+ transport: "HUMAIN Code only supports SSE for this request.",
8
+ envelope: "The CLI could not build a valid HUMAIN Code request envelope.",
9
+ size: "The request exceeds the HUMAIN Code model's request size limit.",
10
+ model: "The request model does not match the selected HUMAIN Code model.",
11
+ reasoning: "The selected HUMAIN Code model does not support the requested thinking level or thinking history.",
12
+ output: "The requested output token limit exceeds the HUMAIN Code model's limit.",
13
+ cache: "HUMAIN Code requires cache retention to be disabled.",
14
+ tools: "The selected HUMAIN Code model does not support tools.",
15
+ strictTools: "HUMAIN Code does not support required strict tool sampling.",
16
+ images: "An image is unsupported or exceeds the selected HUMAIN Code model's limits.",
17
+ cancelled: "The HUMAIN Code request was cancelled before submission.",
18
+ };
19
+ /** Forge's closed `x-hcode-model-unavailable-reason` values, in plain words. */
20
+ const modelUnavailableReasons = {
21
+ catalog_entry_unavailable: "This model is no longer in your HUMAIN Code catalog.",
22
+ credential_unavailable: "HUMAIN Code has no usable provider key for this model.",
23
+ execution_credentials_unavailable: "HUMAIN Code has no usable provider key for this model.",
24
+ provider_quota_isolation_unverified: "This model's provider key isn't dedicated to HUMAIN Code.",
25
+ quota_mapping_unavailable: "This model's capacity isn't set up for HUMAIN Code yet.",
26
+ configuration_changed: "An admin changed this model's configuration.",
27
+ execution_config_unavailable: "HUMAIN Code couldn't load this model's configuration.",
28
+ execution_model_mismatch: "HUMAIN Code's configuration for this model doesn't match its catalog entry.",
29
+ execution_endpoint_mismatch: "HUMAIN Code's endpoint for this model doesn't match its catalog entry.",
30
+ execution_region_mismatch: "HUMAIN Code's provider key is set to a region this model can't run in.",
31
+ };
32
+ /** Forge's closed `x-hcode-unsupported-capability-reason` values, in plain words. */
33
+ const unsupportedCapabilityReasons = {
34
+ reasoning: "This model doesn't support the requested thinking level.",
35
+ tool_choice: "This model can't force a tool call while thinking.",
36
+ temperature: "This model doesn't accept a temperature setting.",
37
+ cache_retention: "This model doesn't support the requested prompt caching.",
38
+ tools: "This model doesn't support tools.",
39
+ strict_tools: "This model doesn't support strict tool schemas.",
40
+ thinking_history: "This model can't replay thinking from earlier turns of this conversation.",
41
+ tool_call_history: "This model can't replay tool calls from earlier turns of this conversation.",
42
+ images: "This model can't accept these images.",
43
+ estimate: "HUMAIN Code couldn't estimate this request's cost.",
44
+ };
45
+ /** Header names and closed reason values Forge sends with deterministic refusals. */
46
+ export const HCODE_REFUSAL_REASON_HEADERS = {
47
+ model_unavailable: ["x-hcode-model-unavailable-reason", Object.keys(modelUnavailableReasons)],
48
+ unsupported_capability: ["x-hcode-unsupported-capability-reason", Object.keys(unsupportedCapabilityReasons)],
49
+ };
50
+ // Refusals Forge returns before any provider dispatch; each settles as not dispatched, so nothing is charged.
51
+ const predispatchCodes = new Set([
52
+ "unauthorized",
53
+ "forbidden",
54
+ "legal_acknowledgment_required",
55
+ "auth_dependency_unavailable",
56
+ "invalid_request",
57
+ "unsupported_capability",
58
+ "model_unavailable",
59
+ ]);
60
+ const NOT_CHARGED = "HUMAIN Code refused this request before running it, so nothing was charged. No automatic retry was sent.";
61
+ function refusalReason(code, reason) {
62
+ if (typeof reason !== "string")
63
+ return undefined;
64
+ const table = code === "model_unavailable"
65
+ ? modelUnavailableReasons
66
+ : code === "unsupported_capability"
67
+ ? unsupportedCapabilityReasons
68
+ : {};
69
+ return Object.hasOwn(table, reason) ? table[reason] : undefined;
70
+ }
71
+ /** Render a closed, non-reflecting reason for an inference that never reached the send boundary. */
72
+ export function formatHcodeLocalRefusal(reason) {
73
+ if (typeof reason !== "string" || !Object.hasOwn(localReasons, reason))
74
+ return undefined;
75
+ return `${localReasons[reason]} No request was sent or charged.`;
76
+ }
5
77
  /** Format the server's reset instant in UTC, independently of the host timezone. */
6
78
  export function formatHcodeReset(resetAt) {
7
79
  return `Resets ${new Date(resetAt).toISOString().slice(0, 16).replace("T", " ")} UTC`;
8
80
  }
9
81
  /** Render schema-validated service facts without reading raw diagnostics or granting automatic retry. */
10
- export function formatHcodeNotice(failure, receivedAt) {
82
+ export function formatHcodeNotice(failure, receivedAt, reason) {
11
83
  const error = failure.error;
12
- if (error.code === "hcode_busy")
84
+ if (error.code === "hcode_busy") {
85
+ const retryAt = new Date(receivedAt + error.details.retryAfterMs);
86
+ // A valid delay can exceed Date's range. Omit the time, not the no-dispatch fact.
87
+ const retryTime = Number.isNaN(retryAt.getTime())
88
+ ? undefined
89
+ : retryAt.toISOString().split(".")[0].replace("T", " ");
13
90
  return {
14
91
  message: error.message,
15
92
  lines: [
16
- `Retry after ${new Date(receivedAt + error.details.retryAfterMs).toISOString().slice(0, 19).replace("T", " ")} UTC.`,
93
+ ...(retryTime ? [`Retry after ${retryTime} UTC.`] : []),
17
94
  "No request was dispatched. No automatic retry was sent.",
18
95
  ],
19
96
  retryAfterMs: error.details.retryAfterMs,
20
97
  };
98
+ }
21
99
  if (error.code === "quota_exceeded") {
22
100
  const usage = error.details.usage;
23
101
  const money = (value) => value.kind === "known"
@@ -39,11 +117,16 @@ export function formatHcodeNotice(failure, receivedAt) {
39
117
  : error.code === "legal_acknowledgment_required"
40
118
  ? "Accept terms in the web app, then try again."
41
119
  : error.code === "model_unavailable"
42
- ? "Choose an available model with /model."
43
- : undefined;
120
+ ? "Choose another model with /model, or ask your admin."
121
+ : error.code === "unsupported_capability"
122
+ ? "Change the setting, start a new conversation with /new, or choose another model with /model."
123
+ : undefined;
124
+ if (!predispatchCodes.has(error.code))
125
+ return { message: error.message, lines: [HCODE_AMBIGUOUS_NOTICE] };
126
+ const detail = refusalReason(error.code, reason);
44
127
  return {
45
128
  message: error.message,
46
- lines: recovery ? [recovery, "No automatic retry was sent."] : [HCODE_AMBIGUOUS_NOTICE],
129
+ lines: [...(detail ? [detail] : []), ...(recovery ? [recovery] : []), NOT_CHARGED],
47
130
  };
48
131
  }
49
132
  /** Shared print/interactive boundary for validated refusals and separate uncertain-outcome warnings. */
@@ -52,11 +135,14 @@ export function formatHcodeMessageNotice(message) {
52
135
  return undefined;
53
136
  if (message.stopReason === "error") {
54
137
  const diagnostic = message.diagnostics?.findLast((entry) => entry.type === "provider_http_error");
138
+ const local = formatHcodeLocalRefusal(diagnostic?.details?.hcodeLocalReason);
139
+ if (local)
140
+ return local;
55
141
  const refusal = diagnostic?.details?.hcode;
56
142
  if (refusal && typeof refusal === "object" && "error" in refusal) {
57
143
  try {
58
144
  // Persisted diagnostics are untrusted. Revalidate only the closed service envelope, never raw error text.
59
- const notice = formatHcodeNotice(parseHcodeInferenceError({ error: refusal.error }), diagnostic.timestamp);
145
+ const notice = formatHcodeNotice(parseHcodeInferenceError({ error: refusal.error }), diagnostic.timestamp, "reason" in refusal ? refusal.reason : undefined);
60
146
  return [notice.message, ...notice.lines].join("\n");
61
147
  }
62
148
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"notices.js","sourceRoot":"","sources":["../../../src/humain/hcode/notices.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6C,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,CAAC,MAAM,yBAAyB,GACrC,+JAA+J,CAAC;AAEjK,MAAM,CAAC,MAAM,sBAAsB,GAClC,8IAA8I,CAAC;AAEhJ,oFAAoF;AACpF,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC/C,OAAO,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC;AACvF,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,iBAAiB,CAChC,OAA4B,EAC5B,UAAkB;IAMlB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY;QAC9B,OAAO;YACN,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE;gBACN,eAAe,IAAI,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,WAAW,E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CAAC,wCAAwC;gBAC1C,CAAC,CAAC,SAAS,CAAC;IAChB,OAAO;QACN,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,8BAA8B,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC;KACvF,CAAC;AACH,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,wBAAwB,CAAC,OAAyB;IACjE,IAAI,OAAO,CAAC,QAAQ,KAAK,cAAc;QAAE,OAAO,SAAS,CAAC;IAC1D,IAAI,OAAO,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,qBAAqB,CAAC,CAAC;QAClG,MAAM,OAAO,GAAG,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;YAClE,IAAI,CAAC;gBACJ,0GAA0G;gBAC1G,MAAM,MAAM,GAAG,iBAAiB,CAAC,wBAAwB,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,UAAW,CAAC,SAAS,CAAC,CAAC;gBAC5G,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;YAAC,MAAM,CAAC;gBACR,sFAAsF;YACvF,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,sBAAsB,CAAC;AAC/B,CAAC","sourcesContent":["// Local, typed presentation of managed refusal facts; never schedules a request or reads a later balance.\nimport type { AssistantMessage } from \"@earendil-works/pi-ai\";\nimport { type HcodeInferenceError, type HcodeValue, parseHcodeInferenceError } from \"./contracts.ts\";\nimport { HCODE_PROVIDER } from \"./http.ts\";\n\nexport const HCODE_PENDING_EXPLANATION =\n\t\"Pending usage is awaiting provider confirmation. It remains reserved until confirmed or reviewed by an admin. It is not a final charge and is not free usage.\";\n\nexport const HCODE_AMBIGUOUS_NOTICE =\n\t\"HUMAIN Code couldn't confirm this request's outcome. It may still be charged. No automatic retry was sent. Check /usage before trying again.\";\n\n/** Format the server's reset instant in UTC, independently of the host timezone. */\nexport function formatHcodeReset(resetAt: string): string {\n\treturn `Resets ${new Date(resetAt).toISOString().slice(0, 16).replace(\"T\", \" \")} UTC`;\n}\n\n/** Render schema-validated service facts without reading raw diagnostics or granting automatic retry. */\nexport function formatHcodeNotice(\n\tfailure: HcodeInferenceError,\n\treceivedAt: number,\n): {\n\tmessage: string;\n\tlines: readonly string[];\n\tretryAfterMs?: number;\n} {\n\tconst error = failure.error;\n\tif (error.code === \"hcode_busy\")\n\t\treturn {\n\t\t\tmessage: error.message,\n\t\t\tlines: [\n\t\t\t\t`Retry after ${new Date(receivedAt + error.details.retryAfterMs).toISOString().slice(0, 19).replace(\"T\", \" \")} UTC.`,\n\t\t\t\t\"No request was dispatched. No automatic retry was sent.\",\n\t\t\t],\n\t\t\tretryAfterMs: error.details.retryAfterMs,\n\t\t};\n\tif (error.code === \"quota_exceeded\") {\n\t\tconst usage = error.details.usage;\n\t\tconst money = (value: HcodeValue | { kind: \"unlimited\" }) =>\n\t\t\tvalue.kind === \"known\"\n\t\t\t\t? `${value.value} ${usage.currency} ${usage.unit}${value.value === 1 ? \"\" : \"s\"}`\n\t\t\t\t: value.kind;\n\t\treturn {\n\t\t\tmessage: error.message,\n\t\t\tlines: [\n\t\t\t\t`Used${usage.costComplete ? \"\" : \" (known subtotal)\"} ${money(usage.actual)}`,\n\t\t\t\t`Pending ${money(usage.reserved)}`,\n\t\t\t\t`Remaining ${money(usage.remaining)}`,\n\t\t\t\tformatHcodeReset(usage.period.resetAt),\n\t\t\t\t\"No request was dispatched. No automatic retry was sent.\",\n\t\t\t],\n\t\t};\n\t}\n\tconst recovery =\n\t\terror.code === \"unauthorized\"\n\t\t\t? \"Sign in again with /login.\"\n\t\t\t: error.code === \"legal_acknowledgment_required\"\n\t\t\t\t? \"Accept terms in the web app, then try again.\"\n\t\t\t\t: error.code === \"model_unavailable\"\n\t\t\t\t\t? \"Choose an available model with /model.\"\n\t\t\t\t\t: undefined;\n\treturn {\n\t\tmessage: error.message,\n\t\tlines: recovery ? [recovery, \"No automatic retry was sent.\"] : [HCODE_AMBIGUOUS_NOTICE],\n\t};\n}\n\n/** Shared print/interactive boundary for validated refusals and separate uncertain-outcome warnings. */\nexport function formatHcodeMessageNotice(message: AssistantMessage): string | undefined {\n\tif (message.provider !== HCODE_PROVIDER) return undefined;\n\tif (message.stopReason === \"error\") {\n\t\tconst diagnostic = message.diagnostics?.findLast((entry) => entry.type === \"provider_http_error\");\n\t\tconst refusal = diagnostic?.details?.hcode;\n\t\tif (refusal && typeof refusal === \"object\" && \"error\" in refusal) {\n\t\t\ttry {\n\t\t\t\t// Persisted diagnostics are untrusted. Revalidate only the closed service envelope, never raw error text.\n\t\t\t\tconst notice = formatHcodeNotice(parseHcodeInferenceError({ error: refusal.error }), diagnostic!.timestamp);\n\t\t\t\treturn [notice.message, ...notice.lines].join(\"\\n\");\n\t\t\t} catch {\n\t\t\t\t// Malformed or ordinary-provider diagnostics retain their existing safe presentation.\n\t\t\t}\n\t\t}\n\t}\n\treturn HCODE_AMBIGUOUS_NOTICE;\n}\n"]}
1
+ {"version":3,"file":"notices.js","sourceRoot":"","sources":["../../../src/humain/hcode/notices.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6C,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,CAAC,MAAM,yBAAyB,GACrC,+JAA+J,CAAC;AAEjK,MAAM,CAAC,MAAM,sBAAsB,GAClC,8IAA8I,CAAC;AAEhJ,MAAM,Y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IACjE,IAAI,OAAO,CAAC,QAAQ,KAAK,cAAc;QAAE,OAAO,SAAS,CAAC;IAC1D,IAAI,OAAO,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,qBAAqB,CAAC,CAAC;QAClG,MAAM,KAAK,GAAG,uBAAuB,CAAC,UAAU,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAC7E,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;QACxB,MAAM,OAAO,GAAG,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;YAClE,IAAI,CAAC;gBACJ,0GAA0G;gBAC1G,MAAM,MAAM,GAAG,iBAAiB,CAC/B,wBAAwB,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,EAClD,UAAW,CAAC,SAAS,EACrB,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAChD,CAAC;gBACF,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;YAAC,MAAM,CAAC;gBACR,sFAAsF;YACvF,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,sBAAsB,CAAC;AAC/B,CAAC","sourcesContent":["// Local, typed presentation of managed refusal facts; never schedules a request or reads a later balance.\nimport type { AssistantMessage } from \"@earendil-works/pi-ai\";\nimport { type HcodeInferenceError, type HcodeValue, parseHcodeInferenceError } from \"./contracts.ts\";\nimport { HCODE_PROVIDER } from \"./http.ts\";\n\nexport const HCODE_PENDING_EXPLANATION =\n\t\"Pending usage is awaiting provider confirmation. It remains reserved until confirmed or reviewed by an admin. It is not a final charge and is not free usage.\";\n\nexport const HCODE_AMBIGUOUS_NOTICE =\n\t\"HUMAIN Code couldn't confirm this request's outcome. It may still be charged. No automatic retry was sent. Check /usage before trying again.\";\n\nconst localReasons = {\n\taccount: \"The selected HUMAIN Code account or model is no longer current.\",\n\ttransport: \"HUMAIN Code only supports SSE for this request.\",\n\tenvelope: \"The CLI could not build a valid HUMAIN Code request envelope.\",\n\tsize: \"The request exceeds the HUMAIN Code model's request size limit.\",\n\tmodel: \"The request model does not match the selected HUMAIN Code model.\",\n\treasoning: \"The selected HUMAIN Code model does not support the requested thinking level or thinking history.\",\n\toutput: \"The requested output token limit exceeds the HUMAIN Code model's limit.\",\n\tcache: \"HUMAIN Code requires cache retention to be disabled.\",\n\ttools: \"The selected HUMAIN Code model does not support tools.\",\n\tstrictTools: \"HUMAIN Code does not support required strict tool sampling.\",\n\timages: \"An image is unsupported or exceeds the selected HUMAIN Code model's limits.\",\n\tcancelled: \"The HUMAIN Code request was cancelled before submission.\",\n} as const;\n\nexport type HcodeLocalReason = keyof typeof localReasons;\n\n/** Forge's closed `x-hcode-model-unavailable-reason` values, in plain words. */\nconst modelUnavailableReasons = {\n\tcatalog_entry_unavailable: \"This model is no longer in your HUMAIN Code catalog.\",\n\tcredential_unavailable: \"HUMAIN Code has no usable provider key for this model.\",\n\texecution_credentials_unavailable: \"HUMAIN Code has no usable provider key for this model.\",\n\tprovider_quota_isolation_unverified: \"This model's provider key isn't dedicated to HUMAIN Code.\",\n\tquota_mapping_unavailable: \"This model's capacity isn't set up for HUMAIN Code yet.\",\n\tconfiguration_changed: \"An admin changed this model's configuration.\",\n\texecution_config_unavailable: \"HUMAIN Code couldn't load this model's configuration.\",\n\texecution_model_mismatch: \"HUMAIN Code's configuration for this model doesn't match its catalog entry.\",\n\texecution_endpoint_mismatch: \"HUMAIN Code's endpoint for this model doesn't match its catalog entry.\",\n\texecution_region_mismatch: \"HUMAIN Code's provider key is set to a region this model can't run in.\",\n} as const;\n\n/** Forge's closed `x-hcode-unsupported-capability-reason` values, in plain words. */\nconst unsupportedCapabilityReasons = {\n\treasoning: \"This model doesn't support the requested thinking level.\",\n\ttool_choice: \"This model can't force a tool call while thinking.\",\n\ttemperature: \"This model doesn't accept a temperature setting.\",\n\tcache_retention: \"This model doesn't support the requested prompt caching.\",\n\ttools: \"This model doesn't support tools.\",\n\tstrict_tools: \"This model doesn't support strict tool schemas.\",\n\tthinking_history: \"This model can't replay thinking from earlier turns of this conversation.\",\n\ttool_call_history: \"This model can't replay tool calls from earlier turns of this conversation.\",\n\timages: \"This model can't accept these images.\",\n\testimate: \"HUMAIN Code couldn't estimate this request's cost.\",\n} as const;\n\n/** Header names and closed reason values Forge sends with deterministic refusals. */\nexport const HCODE_REFUSAL_REASON_HEADERS = {\n\tmodel_unavailable: [\"x-hcode-model-unavailable-reason\", Object.keys(modelUnavailableReasons)],\n\tunsupported_capability: [\"x-hcode-unsupported-capability-reason\", Object.keys(unsupportedCapabilityReasons)],\n} as const satisfies Partial<Record<HcodeInferenceError[\"error\"][\"code\"], readonly [string, readonly string[]]>>;\n\n// Refusals Forge returns before any provider dispatch; each settles as not dispatched, so nothing is charged.\nconst predispatchCodes = new Set<HcodeInferenceError[\"error\"][\"code\"]>([\n\t\"unauthorized\",\n\t\"forbidden\",\n\t\"legal_acknowledgment_required\",\n\t\"auth_dependency_unavailable\",\n\t\"invalid_request\",\n\t\"unsupported_capability\",\n\t\"model_unavailable\",\n]);\nconst NOT_CHARGED =\n\t\"HUMAIN Code refused this request before running it, so nothing was charged. No automatic retry was sent.\";\n\nfunction refusalReason(code: HcodeInferenceError[\"error\"][\"code\"], reason: unknown): string | undefined {\n\tif (typeof reason !== \"string\") return undefined;\n\tconst table: Record<string, string> =\n\t\tcode === \"model_unavailable\"\n\t\t\t? modelUnavailableReasons\n\t\t\t: code === \"unsupported_capability\"\n\t\t\t\t? unsupportedCapabilityReasons\n\t\t\t\t: {};\n\treturn Object.hasOwn(table, reason) ? table[reason] : undefined;\n}\n\n/** Render a closed, non-reflecting reason for an inference that never reached the send boundary. */\nexport function formatHcodeLocalRefusal(reason: unknown): string | undefined {\n\tif (typeof reason !== \"string\" || !Object.hasOwn(localReasons, reason)) return undefined;\n\treturn `${localReasons[reason as HcodeLocalReason]} No request was sent or charged.`;\n}\n\n/** Format the server's reset instant in UTC, independently of the host timezone. */\nexport function formatHcodeReset(resetAt: string): string {\n\treturn `Resets ${new Date(resetAt).toISOString().slice(0, 16).replace(\"T\", \" \")} UTC`;\n}\n\n/** Render schema-validated service facts without reading raw diagnostics or granting automatic retry. */\nexport function formatHcodeNotice(\n\tfailure: HcodeInferenceError,\n\treceivedAt: number,\n\treason?: unknown,\n): {\n\tmessage: string;\n\tlines: readonly string[];\n\tretryAfterMs?: number;\n} {\n\tconst error = failure.error;\n\tif (error.code === \"hcode_busy\") {\n\t\tconst retryAt = new Date(receivedAt + error.details.retryAfterMs);\n\t\t// A valid delay can exceed Date's range. Omit the time, not the no-dispatch fact.\n\t\tconst retryTime = Number.isNaN(retryAt.getTime())\n\t\t\t? undefined\n\t\t\t: retryAt.toISOString().split(\".\")[0].replace(\"T\", \" \");\n\t\treturn {\n\t\t\tmessage: error.message,\n\t\t\tlines: [\n\t\t\t\t...(retryTime ? [`Retry after ${retryTime} UTC.`] : []),\n\t\t\t\t\"No request was dispatched. No automatic retry was sent.\",\n\t\t\t],\n\t\t\tretryAfterMs: error.details.retryAfterMs,\n\t\t};\n\t}\n\tif (error.code === \"quota_exceeded\") {\n\t\tconst usage = error.details.usage;\n\t\tconst money = (value: HcodeValue | { kind: \"unlimited\" }) =>\n\t\t\tvalue.kind === \"known\"\n\t\t\t\t? `${value.value} ${usage.currency} ${usage.unit}${value.value === 1 ? \"\" : \"s\"}`\n\t\t\t\t: value.kind;\n\t\treturn {\n\t\t\tmessage: error.message,\n\t\t\tlines: [\n\t\t\t\t`Used${usage.costComplete ? \"\" : \" (known subtotal)\"} ${money(usage.actual)}`,\n\t\t\t\t`Pending ${money(usage.reserved)}`,\n\t\t\t\t`Remaining ${money(usage.remaining)}`,\n\t\t\t\tformatHcodeReset(usage.period.resetAt),\n\t\t\t\t\"No request was dispatched. No automatic retry was sent.\",\n\t\t\t],\n\t\t};\n\t}\n\tconst recovery =\n\t\terror.code === \"unauthorized\"\n\t\t\t? \"Sign in again with /login.\"\n\t\t\t: error.code === \"legal_acknowledgment_required\"\n\t\t\t\t? \"Accept terms in the web app, then try again.\"\n\t\t\t\t: error.code === \"model_unavailable\"\n\t\t\t\t\t? \"Choose another model with /model, or ask your admin.\"\n\t\t\t\t\t: error.code === \"unsupported_capability\"\n\t\t\t\t\t\t? \"Change the setting, start a new conversation with /new, or choose another model with /model.\"\n\t\t\t\t\t\t: undefined;\n\tif (!predispatchCodes.has(error.code)) return { message: error.message, lines: [HCODE_AMBIGUOUS_NOTICE] };\n\tconst detail = refusalReason(error.code, reason);\n\treturn {\n\t\tmessage: error.message,\n\t\tlines: [...(detail ? [detail] : []), ...(recovery ? [recovery] : []), NOT_CHARGED],\n\t};\n}\n\n/** Shared print/interactive boundary for validated refusals and separate uncertain-outcome warnings. */\nexport function formatHcodeMessageNotice(message: AssistantMessage): string | undefined {\n\tif (message.provider !== HCODE_PROVIDER) return undefined;\n\tif (message.stopReason === \"error\") {\n\t\tconst diagnostic = message.diagnostics?.findLast((entry) => entry.type === \"provider_http_error\");\n\t\tconst local = formatHcodeLocalRefusal(diagnostic?.details?.hcodeLocalReason);\n\t\tif (local) return local;\n\t\tconst refusal = diagnostic?.details?.hcode;\n\t\tif (refusal && typeof refusal === \"object\" && \"error\" in refusal) {\n\t\t\ttry {\n\t\t\t\t// Persisted diagnostics are untrusted. Revalidate only the closed service envelope, never raw error text.\n\t\t\t\tconst notice = formatHcodeNotice(\n\t\t\t\t\tparseHcodeInferenceError({ error: refusal.error }),\n\t\t\t\t\tdiagnostic!.timestamp,\n\t\t\t\t\t\"reason\" in refusal ? refusal.reason : undefined,\n\t\t\t\t);\n\t\t\t\treturn [notice.message, ...notice.lines].join(\"\\n\");\n\t\t\t} catch {\n\t\t\t\t// Malformed or ordinary-provider diagnostics retain their existing safe presentation.\n\t\t\t}\n\t\t}\n\t}\n\treturn HCODE_AMBIGUOUS_NOTICE;\n}\n"]}
@@ -1,15 +1,19 @@
1
- import { type ApiKeyCredential, type Provider } from "@earendil-works/pi-ai";
1
+ import { type Api, type ApiKeyCredential, type Model, type Provider, type TranscriptContext } from "@earendil-works/pi-ai";
2
+ import { type HcodeCatalogEmptyReason } from "./contracts.ts";
2
3
  import { type HcodeEnvironment } from "./environment.ts";
3
4
  import type { HcodeAccountPort, HcodeAccountRef } from "./ports.ts";
4
- /** User-facing account option name; never used as the provider or credential identity. */
5
- export declare const HCODE_LOGIN_LABEL = "HUMAIN Code login (DEV)";
6
5
  /** Account-bound native provider whose owning runtime must dispose its subscription and catalog. */
7
6
  export interface HcodeProvider extends Provider<"pi-messages"> {
8
7
  /** Release account observation and prevent further catalog/auth/request work. */
9
8
  dispose(): void;
9
+ /** Forge's reason the current account's catalog is empty, if it sent a known one. */
10
+ catalogEmptyReason(): HcodeCatalogEmptyReason | undefined;
11
+ /** Whether this process has read the current account's catalog; a new process reads it when /model opens. */
12
+ catalogLoaded(): boolean;
10
13
  }
11
14
  /** Returns only the keyless local reference allowed in the generic credential pool. */
12
15
  export declare function hcodeReferenceCredential(ref: HcodeAccountRef): ApiKeyCredential;
16
+ export declare function projectHcodeContext(context: TranscriptContext, model: Pick<Model<Api>, "id" | "reasoning">): TranscriptContext;
13
17
  /** Creates the dormant provider; no registration-time credential reads, probes or network work occur. */
14
18
  export declare function createHcodeProvider(account: HcodeAccountPort, environment?: HcodeEnvironment): HcodeProvider;
15
19
  //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/humain/hcode/provider.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,KAAK,gBAAg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