@humain/humain-code 0.4.18 → 0.5.3

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 (519) hide show
  1. package/CHANGELOG.md +284 -1
  2. package/README.md +3 -1
  3. package/dist/agent-monitor/client.d.ts +2 -2
  4. package/dist/agent-monitor/client.d.ts.map +1 -1
  5. package/dist/agent-monitor/client.js +3 -2
  6. package/dist/agent-monitor/client.js.map +1 -1
  7. package/dist/bundle/agent-monitor.js +1 -1
  8. package/dist/bundle/chunks/anthropic-messages-ZP5KUK52.js +67 -0
  9. package/dist/bundle/chunks/anthropic.js +10 -9
  10. package/dist/bundle/chunks/azure-openai-responses-QJFYQ3DF.js +15 -0
  11. package/dist/bundle/chunks/bedrock-converse-stream.js +152 -200
  12. package/dist/bundle/chunks/chunk-2GCMACT4.js +1956 -0
  13. package/dist/bundle/chunks/{chunk-QEF72EIZ.js → chunk-A6B2QMA7.js} +40 -96
  14. package/dist/bundle/chunks/{chunk-YMBXWW36.js → chunk-AO6FF5JL.js} +9 -8
  15. package/dist/bundle/chunks/{chunk-OWLBGSXY.js → chunk-CN3Q5UNB.js} +388 -310
  16. package/dist/bundle/chunks/{chunk-SCIGZFN5.js → chunk-DNGJMRJW.js} +11 -11
  17. package/dist/bundle/chunks/chunk-DU6POZ7E.js +10 -0
  18. package/dist/bundle/chunks/chunk-EY3LZOUP.js +1963 -0
  19. package/dist/bundle/chunks/{chunk-G6ABHCPB.js → chunk-FO2NYB6O.js} +655 -663
  20. package/dist/bundle/chunks/{chunk-RXOCQRBG.js → chunk-GEISZXXH.js} +1 -1
  21. package/dist/bundle/chunks/{chunk-OKALNPTJ.js → chunk-HIZWUSPN.js} +24 -24
  22. package/dist/bundle/chunks/{chunk-MVYV6MJY.js → chunk-HT5YN3LX.js} +1 -1
  23. package/dist/bundle/chunks/chunk-IDU5BNNI.js +15 -0
  24. package/dist/bundle/chunks/{chunk-TIFFHHW6.js → chunk-JCXXRCP6.js} +5 -5
  25. package/dist/bundle/chunks/{chunk-QYCOHSI7.js → chunk-KKCMWB63.js} +8 -7
  26. package/dist/bundle/chunks/{chunk-L5OUCJ7N.js → chunk-L2VKM23Q.js} +87 -13
  27. package/dist/bundle/chunks/{chunk-SCBU5WOP.js → chunk-M74U5X4S.js} +30 -23
  28. package/dist/bundle/chunks/{chunk-AWCJWXGD.js → chunk-MIJHJNNQ.js} +3 -2
  29. package/dist/bundle/chunks/{chunk-Y26OS23T.js → chunk-N7CQ3UV3.js} +4 -4
  30. package/dist/bundle/chunks/{chunk-XQZG5HPT.js → chunk-O4DO5RWS.js} +11 -6
  31. package/dist/bundle/chunks/{chunk-P4UKLIQB.js → chunk-ODJUBJK2.js} +4 -4
  32. package/dist/bundle/chunks/chunk-OR25QDSS.js +365 -0
  33. package/dist/bundle/chunks/{chunk-7PRU6YW3.js → chunk-OZNC2W4B.js} +306 -286
  34. package/dist/bundle/chunks/{chunk-Z33NNMNB.js → chunk-PH7UP57J.js} +1 -1
  35. package/dist/bundle/chunks/{chunk-HPSQKIWK.js → chunk-PS7DGA7B.js} +1 -1
  36. package/dist/bundle/chunks/chunk-QW6PTCAB.js +10 -0
  37. package/dist/bundle/chunks/{chunk-5CDES42D.js → chunk-QWXPGBAG.js} +1 -1
  38. package/dist/bundle/chunks/{chunk-NCQ6WAQK.js → chunk-ROZV2IYD.js} +1 -1
  39. package/dist/bundle/chunks/{chunk-3XDL5ZE4.js → chunk-RTXDU3AA.js} +148 -122
  40. package/dist/bundle/chunks/{chunk-FZUJXM6D.js → chunk-UDB6NI4G.js} +309 -240
  41. package/dist/bundle/chunks/{chunk-3UXBFT4Q.js → chunk-UJLCKIMZ.js} +1906 -1661
  42. package/dist/bundle/chunks/chunk-UTNHGOFS.js +88 -0
  43. package/dist/bundle/chunks/{chunk-H2FY3PEV.js → chunk-V62QBESW.js} +4 -3
  44. package/dist/bundle/chunks/{chunk-NSMMDV3N.js → chunk-XA7CJAYH.js} +4 -3
  45. package/dist/bundle/chunks/chunk-XQX7S3GM.js +7 -0
  46. package/dist/bundle/chunks/{chunk-7VY5IL74.js → chunk-Y3OPKKDR.js} +3 -77
  47. package/dist/bundle/chunks/chunk-YFOLLX5D.js +23 -0
  48. package/dist/bundle/chunks/{chunk-YRCLNWFV.js → chunk-ZI7TK7HM.js} +1 -1
  49. package/dist/bundle/chunks/{chunk-V76YPIMT.js → chunk-ZR4GF4WU.js} +21 -15
  50. package/dist/bundle/chunks/{cli-2NKM2RNJ.js → cli-ENEFJH2B.js} +1 -1
  51. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-T7TPP7SQ.js +4 -0
  52. package/dist/bundle/chunks/codemode-worker.js +27 -27
  53. package/dist/bundle/chunks/compat-CJBWWYHE.js +13 -0
  54. package/dist/bundle/chunks/{dist-XVXV2CL4.js → dist-IBUWEKEE.js} +3 -3
  55. package/dist/bundle/chunks/{dist-ZJIYY3GA.js → dist-RKNCFFGM.js} +452 -448
  56. package/dist/bundle/chunks/dist-YFMJEHPH.js +8 -0
  57. package/dist/bundle/chunks/{dist-cjs-AXBW3N4F.js → dist-cjs-HTASUQXQ.js} +82 -80
  58. package/dist/bundle/chunks/{easter-egg-3d-VGJ77XZQ.js → easter-egg-3d-YOPLCOVW.js} +2 -2
  59. package/dist/bundle/chunks/es-YEFEOGR3.js +1905 -0
  60. package/dist/bundle/chunks/{esm-GIR7QH65.js → esm-R6HJ4QEG.js} +5 -5
  61. package/dist/bundle/chunks/{event-streams-NXFTZDSF.js → event-streams-BR2IL6C5.js} +1 -1
  62. package/dist/bundle/chunks/{execute-ZBEZNJ4E.js → execute-2JXEKQ2X.js} +17 -8
  63. package/dist/bundle/chunks/{extract-RFWEHH6W.js → extract-OTCGZGTL.js} +50 -47
  64. package/dist/bundle/chunks/github-copilot.js +44 -40
  65. package/dist/bundle/chunks/google-generative-ai-HVPCGIZ6.js +21 -0
  66. package/dist/bundle/chunks/google-vertex-UM5MAALA.js +25 -0
  67. package/dist/bundle/chunks/host-ZHEL5XQW.js +2 -0
  68. package/dist/bundle/chunks/{https-proxy-agent-7CAXVAFH.js → https-proxy-agent-JQICCRPH.js} +1 -1
  69. package/dist/bundle/chunks/{llama-cpp-classify-AGCW7HYN.js → llama-cpp-classify-B3G57LVR.js} +5 -5
  70. package/dist/bundle/chunks/{mistral-conversations-G3GN6CMT.js → mistral-conversations-AH72RLXK.js} +11 -11
  71. package/dist/bundle/chunks/{node-A6SZ3T7E.js → node-SJPZTR4K.js} +190 -190
  72. package/dist/bundle/chunks/{node-DZCAT4Q6.js → node-VSA4ZN7D.js} +1 -1
  73. package/dist/bundle/chunks/openai-chatgpt.js +2 -2
  74. package/dist/bundle/chunks/{openai-codex-responses-FJFDAWHI.js → openai-codex-responses-L366637C.js} +48 -47
  75. package/dist/bundle/chunks/openai-codex.js +10 -9
  76. package/dist/bundle/chunks/openai-completions-ZP62QXJX.js +83 -0
  77. package/dist/bundle/chunks/{openai-decisions-HESOHYZB.js → openai-decisions-WOWUC65P.js} +1 -1
  78. package/dist/bundle/chunks/openai-responses-DXUGSUTN.js +26 -0
  79. package/dist/bundle/chunks/openrouter-images-5K47HDAT.js +8 -0
  80. package/dist/bundle/chunks/openrouter.js +10 -9
  81. package/dist/bundle/chunks/{pi-messages-SAOV3JNW.js → pi-messages-MOQQDZBK.js} +5 -4
  82. package/dist/bundle/chunks/radius.js +9 -8
  83. package/dist/bundle/chunks/{runtime-HJEUOD4R.js → runtime-K3F2QDQP.js} +1 -1
  84. package/dist/bundle/chunks/typesafe-system-one-43OCHGKP.js +3 -0
  85. package/dist/bundle/chunks/{undici-4BK3MVJV.js → undici-EK3EUI2E.js} +1 -1
  86. package/dist/bundle/chunks/virtual-modules-5D6QIJPN.js +5 -0
  87. package/dist/bundle/cli-runtime.js +3 -3
  88. package/dist/bundle/flow/package.json +4 -4
  89. package/dist/bundle/index.js +6 -6
  90. package/dist/bundle/rpc-entry.js +3 -3
  91. package/dist/cli/args.d.ts +6 -0
  92. package/dist/cli/args.d.ts.map +1 -1
  93. package/dist/cli/args.js +11 -0
  94. package/dist/cli/args.js.map +1 -1
  95. package/dist/coordination/adapter/tool.d.ts.map +1 -1
  96. package/dist/coordination/adapter/tool.js +3 -1
  97. package/dist/coordination/adapter/tool.js.map +1 -1
  98. package/dist/coordination/broker/broker.d.ts +6 -2
  99. package/dist/coordination/broker/broker.d.ts.map +1 -1
  100. package/dist/coordination/broker/broker.js +20 -8
  101. package/dist/coordination/broker/broker.js.map +1 -1
  102. package/dist/coordination/client/client.d.ts.map +1 -1
  103. package/dist/coordination/client/client.js +4 -2
  104. package/dist/coordination/client/client.js.map +1 -1
  105. package/dist/coordination/transport/discovery.d.ts +10 -3
  106. package/dist/coordination/transport/discovery.d.ts.map +1 -1
  107. package/dist/coordination/transport/discovery.js +18 -5
  108. package/dist/coordination/transport/discovery.js.map +1 -1
  109. package/dist/core/agent-session.d.ts +35 -2
  110. package/dist/core/agent-session.d.ts.map +1 -1
  111. package/dist/core/agent-session.js +163 -40
  112. package/dist/core/agent-session.js.map +1 -1
  113. package/dist/core/anthropic-subscription-usage.d.ts +47 -0
  114. package/dist/core/anthropic-subscription-usage.d.ts.map +1 -0
  115. package/dist/core/anthropic-subscription-usage.js +170 -0
  116. package/dist/core/anthropic-subscription-usage.js.map +1 -0
  117. package/dist/core/bash-executor.d.ts.map +1 -1
  118. package/dist/core/bash-executor.js +7 -1
  119. package/dist/core/bash-executor.js.map +1 -1
  120. package/dist/core/client-identity.d.ts +13 -0
  121. package/dist/core/client-identity.d.ts.map +1 -0
  122. package/dist/core/client-identity.js +25 -0
  123. package/dist/core/client-identity.js.map +1 -0
  124. package/dist/core/codex-usage.d.ts +37 -1
  125. package/dist/core/codex-usage.d.ts.map +1 -1
  126. package/dist/core/codex-usage.js +104 -11
  127. package/dist/core/codex-usage.js.map +1 -1
  128. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  129. package/dist/core/compaction/branch-summarization.js +1 -2
  130. package/dist/core/compaction/branch-summarization.js.map +1 -1
  131. package/dist/core/compaction/compaction.d.ts +2 -2
  132. package/dist/core/compaction/compaction.d.ts.map +1 -1
  133. package/dist/core/compaction/compaction.js +20 -15
  134. package/dist/core/compaction/compaction.js.map +1 -1
  135. package/dist/core/export-html/index.d.ts.map +1 -1
  136. package/dist/core/export-html/index.js +2 -0
  137. package/dist/core/export-html/index.js.map +1 -1
  138. package/dist/core/export-html/template.html +1 -0
  139. package/dist/core/export-html/template.js +2 -1
  140. package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  141. package/dist/core/export-html/vendor/marked.min.js +30 -29
  142. package/dist/core/extensions/loader.d.ts.map +1 -1
  143. package/dist/core/extensions/loader.js +3 -0
  144. package/dist/core/extensions/loader.js.map +1 -1
  145. package/dist/core/extensions/runner.d.ts +14 -0
  146. package/dist/core/extensions/runner.d.ts.map +1 -1
  147. package/dist/core/extensions/runner.js +86 -2
  148. package/dist/core/extensions/runner.js.map +1 -1
  149. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  150. package/dist/core/extensions/virtual-modules.js +3 -0
  151. package/dist/core/extensions/virtual-modules.js.map +1 -1
  152. package/dist/core/model-config.d.ts +920 -0
  153. package/dist/core/model-config.d.ts.map +1 -1
  154. package/dist/core/model-config.js +48 -24
  155. package/dist/core/model-config.js.map +1 -1
  156. package/dist/core/model-registry.d.ts +18 -0
  157. package/dist/core/model-registry.d.ts.map +1 -1
  158. package/dist/core/model-registry.js +20 -0
  159. package/dist/core/model-registry.js.map +1 -1
  160. package/dist/core/model-resolver.d.ts.map +1 -1
  161. package/dist/core/model-resolver.js +33 -7
  162. package/dist/core/model-resolver.js.map +1 -1
  163. package/dist/core/model-runtime.d.ts +9 -0
  164. package/dist/core/model-runtime.d.ts.map +1 -1
  165. package/dist/core/model-runtime.js +123 -14
  166. package/dist/core/model-runtime.js.map +1 -1
  167. package/dist/core/output-guard.d.ts +13 -1
  168. package/dist/core/output-guard.d.ts.map +1 -1
  169. package/dist/core/output-guard.js +101 -11
  170. package/dist/core/output-guard.js.map +1 -1
  171. package/dist/core/provider-composer.d.ts +2 -1
  172. package/dist/core/provider-composer.d.ts.map +1 -1
  173. package/dist/core/provider-composer.js +7 -3
  174. package/dist/core/provider-composer.js.map +1 -1
  175. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  176. package/dist/core/remote-catalog-provider.js +7 -2
  177. package/dist/core/remote-catalog-provider.js.map +1 -1
  178. package/dist/core/safe-credential-error.d.ts +11 -0
  179. package/dist/core/safe-credential-error.d.ts.map +1 -0
  180. package/dist/core/safe-credential-error.js +14 -0
  181. package/dist/core/safe-credential-error.js.map +1 -0
  182. package/dist/core/sdk.d.ts.map +1 -1
  183. package/dist/core/sdk.js +12 -10
  184. package/dist/core/sdk.js.map +1 -1
  185. package/dist/core/session-manager.d.ts +4 -0
  186. package/dist/core/session-manager.d.ts.map +1 -1
  187. package/dist/core/session-manager.js +242 -26
  188. package/dist/core/session-manager.js.map +1 -1
  189. package/dist/core/settings-schema.d.ts +3 -0
  190. package/dist/core/settings-schema.d.ts.map +1 -1
  191. package/dist/core/settings-schema.js +6 -0
  192. package/dist/core/settings-schema.js.map +1 -1
  193. package/dist/core/system-prompt.d.ts +6 -1
  194. package/dist/core/system-prompt.d.ts.map +1 -1
  195. package/dist/core/system-prompt.js +93 -1
  196. package/dist/core/system-prompt.js.map +1 -1
  197. package/dist/core/tools/grep.d.ts.map +1 -1
  198. package/dist/core/tools/grep.js +3 -1
  199. package/dist/core/tools/grep.js.map +1 -1
  200. package/dist/core/tools/ls.d.ts.map +1 -1
  201. package/dist/core/tools/ls.js +37 -12
  202. package/dist/core/tools/ls.js.map +1 -1
  203. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  204. package/dist/extensions/codemode/execute.js +102 -24
  205. package/dist/extensions/codemode/execute.js.map +1 -1
  206. package/dist/extensions/index.d.ts.map +1 -1
  207. package/dist/extensions/index.js +3 -1
  208. package/dist/extensions/index.js.map +1 -1
  209. package/dist/extensions/mcp/config.d.ts.map +1 -1
  210. package/dist/extensions/mcp/config.js +3 -2
  211. package/dist/extensions/mcp/config.js.map +1 -1
  212. package/dist/extensions/usage/index.d.ts +15 -0
  213. package/dist/extensions/usage/index.d.ts.map +1 -0
  214. package/dist/extensions/usage/index.js +110 -0
  215. package/dist/extensions/usage/index.js.map +1 -0
  216. package/dist/extensions/usage/overview.d.ts +90 -0
  217. package/dist/extensions/usage/overview.d.ts.map +1 -0
  218. package/dist/extensions/usage/overview.js +215 -0
  219. package/dist/extensions/usage/overview.js.map +1 -0
  220. package/dist/extensions/usage/popup.d.ts +21 -0
  221. package/dist/extensions/usage/popup.d.ts.map +1 -0
  222. package/dist/extensions/usage/popup.js +98 -0
  223. package/dist/extensions/usage/popup.js.map +1 -0
  224. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +21 -2
  225. package/dist/humain/bundled-extension-names.d.ts +6 -0
  226. package/dist/humain/bundled-extension-names.d.ts.map +1 -0
  227. package/dist/humain/bundled-extension-names.js +9 -0
  228. package/dist/humain/bundled-extension-names.js.map +1 -0
  229. package/dist/humain/gateway/catalog.d.ts +36 -0
  230. package/dist/humain/gateway/catalog.d.ts.map +1 -0
  231. package/dist/humain/gateway/catalog.js +74 -0
  232. package/dist/humain/gateway/catalog.js.map +1 -0
  233. package/dist/humain/gateway/client.d.ts +58 -0
  234. package/dist/humain/gateway/client.d.ts.map +1 -0
  235. package/dist/humain/gateway/client.js +212 -0
  236. package/dist/humain/gateway/client.js.map +1 -0
  237. package/dist/humain/gateway/constants.d.ts +23 -0
  238. package/dist/humain/gateway/constants.d.ts.map +1 -0
  239. package/dist/humain/gateway/constants.js +32 -0
  240. package/dist/humain/gateway/constants.js.map +1 -0
  241. package/dist/humain/gateway/http.d.ts +18 -0
  242. package/dist/humain/gateway/http.d.ts.map +1 -0
  243. package/dist/humain/gateway/http.js +274 -0
  244. package/dist/humain/gateway/http.js.map +1 -0
  245. package/dist/humain/gateway/login.d.ts +13 -0
  246. package/dist/humain/gateway/login.d.ts.map +1 -0
  247. package/dist/humain/gateway/login.js +121 -0
  248. package/dist/humain/gateway/login.js.map +1 -0
  249. package/dist/humain/gateway/provider.d.ts +34 -0
  250. package/dist/humain/gateway/provider.d.ts.map +1 -0
  251. package/dist/humain/gateway/provider.js +253 -0
  252. package/dist/humain/gateway/provider.js.map +1 -0
  253. package/dist/humain/gateway/secret-store.d.ts +19 -0
  254. package/dist/humain/gateway/secret-store.d.ts.map +1 -0
  255. package/dist/humain/gateway/secret-store.js +252 -0
  256. package/dist/humain/gateway/secret-store.js.map +1 -0
  257. package/dist/humain/gateway/session-store.d.ts +42 -0
  258. package/dist/humain/gateway/session-store.d.ts.map +1 -0
  259. package/dist/humain/gateway/session-store.js +175 -0
  260. package/dist/humain/gateway/session-store.js.map +1 -0
  261. package/dist/humain/index.d.ts +2 -2
  262. package/dist/humain/index.d.ts.map +1 -1
  263. package/dist/humain/index.js +5 -2
  264. package/dist/humain/index.js.map +1 -1
  265. package/dist/humain/login-menu.d.ts +14 -0
  266. package/dist/humain/login-menu.d.ts.map +1 -0
  267. package/dist/humain/login-menu.js +21 -0
  268. package/dist/humain/login-menu.js.map +1 -0
  269. package/dist/humain/node-http.d.ts.map +1 -1
  270. package/dist/humain/node-http.js +6 -31
  271. package/dist/humain/node-http.js.map +1 -1
  272. package/dist/humain/redact-assistant-message.d.ts +4 -0
  273. package/dist/humain/redact-assistant-message.d.ts.map +1 -0
  274. package/dist/humain/redact-assistant-message.js +34 -0
  275. package/dist/humain/redact-assistant-message.js.map +1 -0
  276. package/dist/humain/web-access/vendor/anysearch.d.ts.map +1 -1
  277. package/dist/humain/web-access/vendor/anysearch.js +3 -3
  278. package/dist/humain/web-access/vendor/anysearch.js.map +1 -1
  279. package/dist/humain/web-access/vendor/bocha.d.ts.map +1 -1
  280. package/dist/humain/web-access/vendor/bocha.js +3 -3
  281. package/dist/humain/web-access/vendor/bocha.js.map +1 -1
  282. package/dist/humain/web-access/vendor/brightdata-unlocker.d.ts.map +1 -1
  283. package/dist/humain/web-access/vendor/brightdata-unlocker.js +2 -2
  284. package/dist/humain/web-access/vendor/brightdata-unlocker.js.map +1 -1
  285. package/dist/humain/web-access/vendor/brightdata.d.ts.map +1 -1
  286. package/dist/humain/web-access/vendor/brightdata.js +3 -3
  287. package/dist/humain/web-access/vendor/brightdata.js.map +1 -1
  288. package/dist/humain/web-access/vendor/ceramic.d.ts.map +1 -1
  289. package/dist/humain/web-access/vendor/ceramic.js +2 -2
  290. package/dist/humain/web-access/vendor/ceramic.js.map +1 -1
  291. package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
  292. package/dist/humain/web-access/vendor/curator-page.js +3 -1
  293. package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
  294. package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
  295. package/dist/humain/web-access/vendor/curator-server.js +2 -0
  296. package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
  297. package/dist/humain/web-access/vendor/deepseek.d.ts +11 -1
  298. package/dist/humain/web-access/vendor/deepseek.d.ts.map +1 -1
  299. package/dist/humain/web-access/vendor/deepseek.js +170 -5
  300. package/dist/humain/web-access/vendor/deepseek.js.map +1 -1
  301. package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
  302. package/dist/humain/web-access/vendor/extract.js +63 -6
  303. package/dist/humain/web-access/vendor/extract.js.map +1 -1
  304. package/dist/humain/web-access/vendor/gemini-search.d.ts +5 -3
  305. package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
  306. package/dist/humain/web-access/vendor/gemini-search.js +33 -7
  307. package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
  308. package/dist/humain/web-access/vendor/index.d.ts +1 -0
  309. package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
  310. package/dist/humain/web-access/vendor/index.js +18 -3
  311. package/dist/humain/web-access/vendor/index.js.map +1 -1
  312. package/dist/humain/web-access/vendor/jina-search.d.ts.map +1 -1
  313. package/dist/humain/web-access/vendor/jina-search.js +6 -4
  314. package/dist/humain/web-access/vendor/jina-search.js.map +1 -1
  315. package/dist/humain/web-access/vendor/kagi.d.ts.map +1 -1
  316. package/dist/humain/web-access/vendor/kagi.js +4 -4
  317. package/dist/humain/web-access/vendor/kagi.js.map +1 -1
  318. package/dist/humain/web-access/vendor/keenable.d.ts.map +1 -1
  319. package/dist/humain/web-access/vendor/keenable.js +2 -2
  320. package/dist/humain/web-access/vendor/keenable.js.map +1 -1
  321. package/dist/humain/web-access/vendor/linkup.d.ts +6 -0
  322. package/dist/humain/web-access/vendor/linkup.d.ts.map +1 -0
  323. package/dist/humain/web-access/vendor/linkup.js +167 -0
  324. package/dist/humain/web-access/vendor/linkup.js.map +1 -0
  325. package/dist/humain/web-access/vendor/mistral-search.d.ts.map +1 -1
  326. package/dist/humain/web-access/vendor/mistral-search.js +3 -3
  327. package/dist/humain/web-access/vendor/mistral-search.js.map +1 -1
  328. package/dist/humain/web-access/vendor/ollama.d.ts.map +1 -1
  329. package/dist/humain/web-access/vendor/ollama.js +4 -4
  330. package/dist/humain/web-access/vendor/ollama.js.map +1 -1
  331. package/dist/humain/web-access/vendor/parallel.js +6 -7
  332. package/dist/humain/web-access/vendor/parallel.js.map +1 -1
  333. package/dist/humain/web-access/vendor/perplexity.d.ts.map +1 -1
  334. package/dist/humain/web-access/vendor/perplexity.js +4 -3
  335. package/dist/humain/web-access/vendor/perplexity.js.map +1 -1
  336. package/dist/humain/web-access/vendor/querit.d.ts.map +1 -1
  337. package/dist/humain/web-access/vendor/querit.js +3 -3
  338. package/dist/humain/web-access/vendor/querit.js.map +1 -1
  339. package/dist/humain/web-access/vendor/search1api.d.ts.map +1 -1
  340. package/dist/humain/web-access/vendor/search1api.js +3 -3
  341. package/dist/humain/web-access/vendor/search1api.js.map +1 -1
  342. package/dist/humain/web-access/vendor/searchinfinity.d.ts.map +1 -1
  343. package/dist/humain/web-access/vendor/searchinfinity.js +3 -3
  344. package/dist/humain/web-access/vendor/searchinfinity.js.map +1 -1
  345. package/dist/humain/web-access/vendor/serpapi.d.ts.map +1 -1
  346. package/dist/humain/web-access/vendor/serpapi.js +6 -5
  347. package/dist/humain/web-access/vendor/serpapi.js.map +1 -1
  348. package/dist/humain/web-access/vendor/serpbase.d.ts.map +1 -1
  349. package/dist/humain/web-access/vendor/serpbase.js +4 -4
  350. package/dist/humain/web-access/vendor/serpbase.js.map +1 -1
  351. package/dist/humain/web-access/vendor/serpdive.d.ts.map +1 -1
  352. package/dist/humain/web-access/vendor/serpdive.js +3 -3
  353. package/dist/humain/web-access/vendor/serpdive.js.map +1 -1
  354. package/dist/humain/web-access/vendor/serper.d.ts.map +1 -1
  355. package/dist/humain/web-access/vendor/serper.js +5 -4
  356. package/dist/humain/web-access/vendor/serper.js.map +1 -1
  357. package/dist/humain/web-access/vendor/serply.d.ts.map +1 -1
  358. package/dist/humain/web-access/vendor/serply.js +2 -2
  359. package/dist/humain/web-access/vendor/serply.js.map +1 -1
  360. package/dist/humain/web-access/vendor/utils.d.ts +3 -1
  361. package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
  362. package/dist/humain/web-access/vendor/utils.js +27 -2
  363. package/dist/humain/web-access/vendor/utils.js.map +1 -1
  364. package/dist/humain/web-access/vendor/valyu.d.ts.map +1 -1
  365. package/dist/humain/web-access/vendor/valyu.js +3 -3
  366. package/dist/humain/web-access/vendor/valyu.js.map +1 -1
  367. package/dist/humain/web-access/vendor/web-tool-core.d.ts +2 -0
  368. package/dist/humain/web-access/vendor/web-tool-core.d.ts.map +1 -1
  369. package/dist/humain/web-access/vendor/web-tool-core.js +3 -0
  370. package/dist/humain/web-access/vendor/web-tool-core.js.map +1 -1
  371. package/dist/humain/web-access/vendor/xai-search.d.ts.map +1 -1
  372. package/dist/humain/web-access/vendor/xai-search.js +51 -8
  373. package/dist/humain/web-access/vendor/xai-search.js.map +1 -1
  374. package/dist/humain/web-access/vendor/xcrawl.d.ts.map +1 -1
  375. package/dist/humain/web-access/vendor/xcrawl.js +3 -3
  376. package/dist/humain/web-access/vendor/xcrawl.js.map +1 -1
  377. package/dist/humain/web-access/vendor/you.d.ts.map +1 -1
  378. package/dist/humain/web-access/vendor/you.js +2 -2
  379. package/dist/humain/web-access/vendor/you.js.map +1 -1
  380. package/dist/main.d.ts.map +1 -1
  381. package/dist/main.js +32 -6
  382. package/dist/main.js.map +1 -1
  383. package/dist/modes/interactive/components/assistant-message.d.ts +14 -2
  384. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  385. package/dist/modes/interactive/components/assistant-message.js +62 -7
  386. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  387. package/dist/modes/interactive/components/config-selector.js +1 -1
  388. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  389. package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
  390. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  391. package/dist/modes/interactive/components/custom-editor.js +6 -1
  392. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  393. package/dist/modes/interactive/components/easter-egg-3d.js +1 -1
  394. package/dist/modes/interactive/components/easter-egg-3d.js.map +1 -1
  395. package/dist/modes/interactive/components/footer.d.ts +10 -2
  396. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  397. package/dist/modes/interactive/components/footer.js +141 -66
  398. package/dist/modes/interactive/components/footer.js.map +1 -1
  399. package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
  400. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  401. package/dist/modes/interactive/components/login-dialog.js +3 -2
  402. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  403. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  404. package/dist/modes/interactive/components/mermaid.js +16 -3
  405. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  406. package/dist/modes/interactive/components/model-selector.d.ts +11 -0
  407. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  408. package/dist/modes/interactive/components/model-selector.js +17 -4
  409. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  410. package/dist/modes/interactive/components/radius-login-selector.d.ts +5 -4
  411. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -1
  412. package/dist/modes/interactive/components/radius-login-selector.js +11 -9
  413. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -1
  414. package/dist/modes/interactive/components/themed-text.d.ts.map +1 -1
  415. package/dist/modes/interactive/components/themed-text.js +3 -2
  416. package/dist/modes/interactive/components/themed-text.js.map +1 -1
  417. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  418. package/dist/modes/interactive/components/tool-execution.js +17 -6
  419. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  420. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  421. package/dist/modes/interactive/components/user-message.js +3 -2
  422. package/dist/modes/interactive/components/user-message.js.map +1 -1
  423. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  424. package/dist/modes/interactive/components/visual-truncate.js +4 -2
  425. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  426. package/dist/modes/interactive/interactive-mode.d.ts +15 -17
  427. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  428. package/dist/modes/interactive/interactive-mode.js +143 -158
  429. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  430. package/dist/modes/print-mode.d.ts.map +1 -1
  431. package/dist/modes/print-mode.js +2 -5
  432. package/dist/modes/print-mode.js.map +1 -1
  433. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  434. package/dist/modes/rpc/rpc-mode.js +2 -3
  435. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  436. package/dist/package-manager-cli.d.ts.map +1 -1
  437. package/dist/package-manager-cli.js +2 -1
  438. package/dist/package-manager-cli.js.map +1 -1
  439. package/dist/utils/child-process.d.ts.map +1 -1
  440. package/dist/utils/child-process.js +3 -2
  441. package/dist/utils/child-process.js.map +1 -1
  442. package/dist/utils/clipboard-command.d.ts.map +1 -1
  443. package/dist/utils/clipboard-command.js +3 -0
  444. package/dist/utils/clipboard-command.js.map +1 -1
  445. package/dist/utils/pi-user-agent.d.ts +1 -0
  446. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  447. package/dist/utils/pi-user-agent.js +3 -2
  448. package/dist/utils/pi-user-agent.js.map +1 -1
  449. package/dist/utils/shell.d.ts.map +1 -1
  450. package/dist/utils/shell.js +45 -13
  451. package/dist/utils/shell.js.map +1 -1
  452. package/dist/utils/sleep.d.ts +1 -1
  453. package/dist/utils/sleep.d.ts.map +1 -1
  454. package/dist/utils/sleep.js +10 -6
  455. package/dist/utils/sleep.js.map +1 -1
  456. package/dist/utils/tools-manager.d.ts.map +1 -1
  457. package/dist/utils/tools-manager.js +4 -3
  458. package/dist/utils/tools-manager.js.map +1 -1
  459. package/docs/codemode.md +2 -2
  460. package/docs/compaction.md +3 -3
  461. package/docs/coordination.md +1 -1
  462. package/docs/custom-provider.md +53 -1
  463. package/docs/docs.json +4 -0
  464. package/docs/environment-variables.md +2 -0
  465. package/docs/extensions.md +133 -10
  466. package/docs/humain-code.md +13 -1
  467. package/docs/index.md +1 -1
  468. package/docs/models-configuration.md +197 -0
  469. package/docs/models.md +24 -6
  470. package/docs/providers.md +58 -2
  471. package/docs/quickstart.md +8 -1
  472. package/docs/settings.md +1 -1
  473. package/docs/slash-commands.md +10 -0
  474. package/docs/tui.md +70 -0
  475. package/docs/windows.md +16 -2
  476. package/examples/extensions/custom-provider-anthropic/package.json +2 -2
  477. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  478. package/examples/extensions/gondolin/package-lock.json +2 -2
  479. package/examples/extensions/gondolin/package.json +1 -1
  480. package/examples/extensions/sandbox/package-lock.json +2 -2
  481. package/examples/extensions/sandbox/package.json +2 -2
  482. package/examples/extensions/with-deps/package.json +1 -1
  483. package/examples/plugins/pi-example-plugin/package.json +2 -2
  484. package/npm-shrinkwrap.json +243 -219
  485. package/package.json +21 -20
  486. package/schemas/models.schema.json +84 -30
  487. package/schemas/settings.schema.json +19 -0
  488. package/src/coordination/UPSTREAM.md +36 -3
  489. package/src/coordination/upstream.json +3 -3
  490. package/src/humain/web-access/UPSTREAM.md +72 -1
  491. package/src/humain/web-access/upstream.json +5 -4
  492. package/dist/bundle/chunks/anthropic-messages-TSNY5MWH.js +0 -67
  493. package/dist/bundle/chunks/azure-openai-responses-Z4DCXO2G.js +0 -15
  494. package/dist/bundle/chunks/chunk-26EAEXO5.js +0 -167
  495. package/dist/bundle/chunks/chunk-2ZFUMXOZ.js +0 -1790
  496. package/dist/bundle/chunks/chunk-5K5RFXXO.js +0 -74
  497. package/dist/bundle/chunks/chunk-PY7SOXCA.js +0 -10
  498. package/dist/bundle/chunks/chunk-UGJAAWNC.js +0 -7
  499. package/dist/bundle/chunks/chunk-UGXYG7HN.js +0 -22
  500. package/dist/bundle/chunks/chunk-VEYTRNQC.js +0 -5
  501. package/dist/bundle/chunks/chunk-X3O5MCKJ.js +0 -7
  502. package/dist/bundle/chunks/chunk-YLYOJQQX.js +0 -1951
  503. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MUJQ6LT2.js +0 -4
  504. package/dist/bundle/chunks/compat-VDGEZSVM.js +0 -13
  505. package/dist/bundle/chunks/dist-LKDZAEUQ.js +0 -7
  506. package/dist/bundle/chunks/es-N6YFJOD7.js +0 -1901
  507. package/dist/bundle/chunks/google-generative-ai-4OVYRP24.js +0 -21
  508. package/dist/bundle/chunks/google-vertex-3WQAZJQD.js +0 -25
  509. package/dist/bundle/chunks/host-63SNKK5Y.js +0 -2
  510. package/dist/bundle/chunks/openai-completions-IC7WRLTI.js +0 -82
  511. package/dist/bundle/chunks/openai-responses-XXCYDFSM.js +0 -24
  512. package/dist/bundle/chunks/openrouter-images-DT2HMZNO.js +0 -8
  513. package/dist/bundle/chunks/typesafe-system-one-HCMGHK6A.js +0 -2
  514. package/dist/bundle/chunks/virtual-modules-CFJTDIXL.js +0 -5
  515. package/dist/core/provider-attribution.d.ts +0 -4
  516. package/dist/core/provider-attribution.d.ts.map +0 -1
  517. package/dist/core/provider-attribution.js +0 -85
  518. package/dist/core/provider-attribution.js.map +0 -1
  519. /package/dist/bundle/chunks/{chunk-WZMA7HAJ.js → chunk-XQRYOCHA.js} +0 -0
@@ -86,6 +86,7 @@ These variables are read by HUMAIN Code CLI itself:
86
86
  | `HUMAIN_TERMINAL_CODING_AGENT_SESSION_DIR` | Override session storage; overridden by `--session-dir` |
87
87
  | `HUMAIN_TERMINAL_PACKAGE_DIR` | Override the package directory, useful for Nix/Guix store paths |
88
88
  | `HUMAIN_TERMINAL_CODEMODE_MODE` | Set to `on` or `only` to override the `codemode.mode` setting for this process; see [Codemode](codemode.md). Flow sets `only` for its codemode-only implementer children |
89
+ | `HUMAIN_TERMINAL_CODEMODE_MAX_WORKERS` | Maximum codemode workers alive at once across all sessions in the process; default `2`. Each worker's script may use up to 256 MB. Raise it when one process runs several sessions, such as in-process subagents. Further scripts wait for a free worker. See [Codemode](codemode.md) |
89
90
  | `HUMAIN_FLOW_IMPLEMENTER_CODEMODE` | `off` gives the Flow SMALL/MEDIUM implementer its plain tool list instead of the default codemode-only tools; `only` forces codemode-only. Overrides the `codemode.flowImplementer` setting; see [Flow](flow.md#codemode-only-implementer) |
90
91
  | `HUMAIN_TERMINAL_OFFLINE` | Disable startup network operations, including update checks, package updates, and install/update telemetry |
91
92
  | `HUMAIN_TERMINAL_COORDINATION_WORKTREE_HINT` | Set to `1` to add separate-worktree guidance to the one-time shared-worktree warning. Defaults off; other values leave the warning unchanged. See [Session coordination](coordination.md#shared-worktrees-and-the-single-writer). |
@@ -99,6 +100,7 @@ These variables are read by HUMAIN Code CLI itself:
99
100
  | `HUMAIN_TERMINAL_PROGRAM_STATUS` | Override OSC 7501 program status detection: `1` always reports, `0` never reports; otherwise HUMAIN Code CLI reports only after the terminal confirms support. See [Terminal setup](terminal-setup.md#program-status) |
100
101
  | `HUMAIN_TERMINAL_IMAGE_PROTOCOL` | Override inline image detection with `kitty`, `iterm2`, `none`, or `auto` |
101
102
  | `HUMAIN_TERMINAL_TRUE_COLOR` | Override truecolor detection with `1`, `0`, or `auto` |
103
+ | `HUMAIN_TERMINAL_TUI_ESC_TIMEOUT` | How long to wait after a lone ESC before treating it as Escape, in milliseconds; defaults to `100` over SSH and `10` otherwise. Increase if Alt-key input is misread as Escape |
102
104
  | `HUMAIN_TERMINAL_CLIPBOARD_OSC52` | Set to `1` to also send copied text to the terminal with OSC 52 after the local clipboard write, as HUMAIN Code CLI does over SSH. Use it when a remote client reaches HUMAIN Code CLI without SSH variables, such as a multiplexer attached from another machine or a remote IDE daemon |
103
105
  | `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
104
106
  | `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
@@ -55,7 +55,7 @@ Reload replaces the extension runtime, so code after `await ctx.reload()` must n
55
55
 
56
56
  <a id="understand-the-lifecycle"></a>
57
57
 
58
- ## Respect the runtime lifecycle
58
+ ## Understand the runtime lifecycle
59
59
 
60
60
  The factory can be synchronous or asynchronous. HUMAIN Code CLI waits for an asynchronous factory before startup continues, allowing it to fetch configuration or register providers needed during startup.
61
61
 
@@ -63,13 +63,112 @@ Do not start processes, sockets, watchers, or timers in the factory because some
63
63
  Start long-lived resources from `session_start` or from the command or tool that needs them.
64
64
  Close session-scoped resources from an idempotent `session_shutdown` handler.
65
65
 
66
- A run proceeds from input and `before_agent_start`, through model, message, and tool events, to `agent_end`.
67
- Pi counts as busy while a run starts, including the compaction check and `before_agent_start`, so messages sent meanwhile go into the starting run.
68
- Automatic retries, recovery, compaction, or queued work can continue afterward.
66
+ A normal prompt starts a run. The run repeats turns, then checks whether more work starts another low-level agent run:
67
+
68
+ ```mermaid
69
+ flowchart TD
70
+ Input["input"] --> Before["before_agent_start"]
71
+ Before --> AgentStart["agent_start"]
72
+ AgentStart --> Turns[["turns"]]
73
+ Turns --> AgentEnd["agent_end"]
74
+ AgentEnd --> MoreRuns{"More work?"}
75
+ MoreRuns -->|yes| AgentStart
76
+ MoreRuns -->|no| BeforeSettle["agent_before_settle"]
77
+ BeforeSettle --> Continue{"Continuation requested?"}
78
+ Continue -->|yes| AgentStart
79
+ Continue -->|no| Settled["agent_settled"]
80
+ ```
81
+
82
+ More work means a retry, recovery, compaction retry, or queued work.
83
+
84
+ Each turn sends one model request and executes the tool calls in the assistant response:
85
+
86
+ ```mermaid
87
+ flowchart TD
88
+ TurnStart["turn_start"] --> Request[["model request"]]
89
+ Request --> ToolDecision{"Tool calls?"}
90
+ ToolDecision -->|yes| Tools[["tool execution"]]
91
+ Tools --> TurnEnd["turn_end"]
92
+ ToolDecision -->|no| TurnEnd
93
+ TurnEnd --> MoreTurns{"Another turn?"}
94
+ MoreTurns -->|yes| TurnStart
95
+ MoreTurns -->|no| AgentEnd(["agent_end"])
96
+ ```
97
+
98
+ The model request runs these hooks in order:
99
+
100
+ 1. `context`
101
+ 2. `context_with_system`
102
+ 3. `before_provider_headers`
103
+ 4. `before_provider_request`
104
+ 5. `after_provider_response`
105
+ 6. `provider_stream_event` and assistant message events
106
+
107
+ Tool execution runs these hooks in order for each tool call:
108
+
109
+ 1. `tool_execution_start`
110
+ 2. `tool_call`
111
+ 3. `tool_execution_update` while the tool executes
112
+ 4. `tool_result`
113
+ 5. `tool_execution_end`
114
+
115
+ The lifecycle involves these event groups:
116
+
117
+ | Area | Events |
118
+ |---|---|
119
+ | Input preparation | `input`, `before_agent_start` |
120
+ | Agent run | `agent_start`, `agent_end` |
121
+ | Model turn | `turn_start`, `context`, `context_with_system`, `turn_end` |
122
+ | Provider call | `before_provider_headers`, `before_provider_request`, `after_provider_response`, `provider_stream_event` |
123
+ | Message lifecycle | `message_start`, `message_update`, `message_end` |
124
+ | Tool execution | `tool_execution_start`, `tool_call`, `tool_execution_update`, `tool_result`, `tool_execution_end` |
125
+ | Settlement | `agent_before_settle`, `agent_settled` |
126
+
127
+ HUMAIN Code CLI counts as busy while a run starts, including the compaction check and `before_agent_start`, so messages sent meanwhile go into the starting run. Message lifecycle events also cover user and tool-result messages; the model request list places only the assistant stream where it occurs in each turn.
128
+
129
+ Tool hooks run for each tool call, and one assistant response can start another turn by returning tool calls. Provider hooks run only when that transport exposes the corresponding stage. See the exported declarations in [`extensions/types.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/extensions/types.ts) for exact event payloads and result types.
130
+
131
+ Session startup and replacement follow a separate lifecycle:
132
+
133
+ ```mermaid
134
+ flowchart TD
135
+ Startup["Process startup"] --> Trust["project_trust when needed"]
136
+ Trust --> SessionStart["session_start"]
137
+ Switch["/new or /resume"] --> BeforeSwitch["session_before_switch"]
138
+ Fork["/fork or /clone"] --> BeforeFork["session_before_fork"]
139
+ BeforeSwitch --> Shutdown["session_shutdown"]
140
+ BeforeFork --> Shutdown
141
+ Reload["reload"] --> Shutdown
142
+ Shutdown --> Replacing{"Replacing the runtime?"}
143
+ Replacing -->|yes| Replacement["load replacement extension runtime"]
144
+ Replacement --> SessionStart
145
+ Replacing -->|no| Stop["process exits"]
146
+ SessionStart --> Discover["resources_discover"]
147
+ ```
148
+
149
+ `project_trust` runs before trusted project resources load and can run again when session replacement enters a new working directory. Retries, recovery, compaction, and queued messages can start another agent run after `agent_end`, so `agent_end` is not a final-idle signal. Reload and session replacement invalidate the old runtime. Code after `await ctx.reload()` still belongs to the old runtime and must not reuse its session-bound state.
150
+
151
+ ### Choose an event by intent
152
+
153
+ | Goal | Event |
154
+ |---|---|
155
+ | Inspect, transform, or consume raw user input | `input` |
156
+ | Change prompt sections, active tools, or add context before a run | `before_agent_start` |
157
+ | Observe one low-level agent run | `agent_start`, `agent_end` |
158
+ | Act after one model response and its tool calls | `turn_end` |
159
+ | Filter conversation messages for one provider request | `context` |
160
+ | Transform the complete transcript, including system messages | `context_with_system` |
161
+ | Change request headers or the serialized provider payload | `before_provider_headers`, `before_provider_request` |
162
+ | Observe provider response metadata or parsed stream events | `after_provider_response`, `provider_stream_event` |
163
+ | Authorize or modify a tool call | `tool_call` |
164
+ | Redact, annotate, or replace a tool result | `tool_result` |
165
+ | Append final entries or request one last continuation | `agent_before_settle` |
166
+ | Run notification work after automatic processing has stopped | `agent_settled` |
167
+ | Initialize or release session-scoped resources | `session_start`, `session_shutdown` |
168
+
69
169
  <a id="agent_start--agent_end--agent_before_settle--agent_settled"></a>
70
170
 
71
- `agent_before_settle` is the final actionable boundary: it can append entries and request one continuation.
72
- `agent_settled` is final and notification-only; use it when an integration needs to know HUMAIN Code CLI will not continue automatically.
171
+ Use `agent_before_settle` when an extension must append entries or request one final continuation. Use `agent_settled` for notification-only work that should run after HUMAIN Code CLI has no automatic continuation remaining.
73
172
 
74
173
  <a id="extensionapi-methods"></a>
75
174
 
@@ -105,6 +204,19 @@ Use each event’s declared result type rather than assuming every return value
105
204
 
106
205
  Events cover resource discovery, sessions, agent and message lifecycle, providers, tools, and raw input.
107
206
 
207
+ #### Understand handler composition
208
+
209
+ | Pattern | Behavior |
210
+ |---|---|
211
+ | Notification | Return values are ignored. Use the event for observation only. |
212
+ | In-place mutation | Later handlers see changes to values such as `before_provider_headers.headers`, `before_agent_start.systemPromptOptions`, and `tool_call.input`. |
213
+ | Chained transformation | Later handlers receive the value returned by earlier `input`, `context`, `context_with_system`, `message_end`, `tool_result`, and `before_provider_request` handlers. |
214
+ | Gate | A handled input, blocked tool call, cancelled session operation, or handled `user_bash` command stops that operation's normal fallback path. |
215
+ | Actionable boundary | Each `turn_end` or `agent_before_settle` handler sees the entries and continuation decision proposed so far. |
216
+ | Last override | The last `cache_warming_decision` handler that returns an action wins. |
217
+
218
+ Notification handlers should not perform slow work on a streaming event. Transform handlers should preserve fields they do not intentionally own, and gate handlers should fail closed when their safety decision cannot be made.
219
+
108
220
  `before_agent_start` exposes both the current prompt and its structured `systemPromptOptions`. `event.messageType` says what started the run: `"user"` for a prompt or `pi.sendUserMessage()`, with `prompt` and `images`; `"custom"` for `pi.sendMessage(..., { triggerTurn: true })`, with the starting `message` and no `prompt`. A returned `message` is added to either kind of run; check `messageType` to skip runs started by custom messages. Prefer changing prompt sections, selected tools, or guidelines so HUMAIN Code CLI can append a transcript delta. Returning `systemPrompt`, or setting `forceSystemPrompt`, replaces the whole prompt for that run while the transcript continues recording the structured sections. Providers receive the forced text as their leading system prompt.
109
221
 
110
222
  `message_end` can replace a finalized message while preserving its role. `tool_call` can mutate input or block execution. `tool_result` handlers compose, with each handler seeing prior changes.
@@ -282,7 +394,18 @@ Use `ctx.shutdown()` to request an orderly process shutdown.
282
394
 
283
395
  ## Examples and reference
284
396
 
285
- The checked [extension examples](../examples/extensions/) cover tools, lifecycle events, commands, flags, shortcuts, state, rendering, providers, OAuth, remote execution, and terminal components.
286
- Start with the smallest example matching your integration point.
287
-
288
- Use [Custom Providers](custom-provider.md) for model-service integrations, [Terminal UI](tui.md) for custom components, and [HUMAIN Code CLI Packages](packages.md) to install or distribute extensions with other resources.
397
+ The checked [extension examples](../examples/extensions/) are the implementation reference. Start with the smallest example matching the behavior you need:
398
+
399
+ | Goal | Start with | Why |
400
+ |---|---|---|
401
+ | Confirm or block tool calls | [`permission-gate.ts`](../examples/extensions/permission-gate.ts) | Combines `tool_call`, mode-aware UI, and fail-closed behavior. |
402
+ | Modify prompt sections for a run | [`prompt-customizer.ts`](../examples/extensions/prompt-customizer.ts) | Uses structured prompt options instead of replacing the complete prompt. |
403
+ | Keep branch-aware tool state | [`todo.ts`](../examples/extensions/todo.ts) | Reconstructs state from persisted entries and renders it in the TUI. |
404
+ | Register tools after startup | [`dynamic-tools.ts`](../examples/extensions/dynamic-tools.ts) | Shares registration logic between lifecycle and command handlers. |
405
+ | Run cancellable model work from a command | [`qna.ts`](../examples/extensions/qna.ts) | Combines nested model calls, cancellation, and custom UI. |
406
+ | Replace the main editor | [`modal-editor.ts`](../examples/extensions/modal-editor.ts) | Extends `CustomEditor` while preserving application controls. |
407
+ | Run finalization at shutdown | [`auto-commit-on-exit.ts`](../examples/extensions/auto-commit-on-exit.ts) | Uses the session shutdown hook for finalization work. |
408
+ | Route built-in tools to another machine | [`ssh.ts`](../examples/extensions/ssh.ts) | Reuses tool operation interfaces instead of recreating tool contracts. |
409
+ | Add OAuth and provider-specific streaming | [`custom-provider-gitlab-duo/`](../examples/extensions/custom-provider-gitlab-duo/) | Shows a complete provider integration while delegating supported protocols. |
410
+
411
+ Use [Custom Providers](custom-provider.md) for model-service integrations, [Terminal UI](tui.md) for custom components, and [HUMAIN Code CLI Packages](packages.md) to install or distribute extensions with other resources. Use the exported declarations for exact signatures, payloads, and result schemas; this guide focuses on lifecycle choices, composition, and durable implementation patterns.
@@ -83,10 +83,22 @@ Sending `normal mode` as the whole message disables all three for the session. A
83
83
 
84
84
  ## HUMAIN Node
85
85
 
86
- Use `/login humain-node` to enter a masked API key and optional base URL (default `https://api.node.humain.com/v1`). Alternatively, set `HUMAIN_NODE_API_KEY` and optionally `HUMAIN_NODE_BASE_URL` in your environment.
86
+ Use `/login humain-node` (or **Sign in with HUMAIN** → **HUMAIN Node** in `/login`) to enter a masked API key and optional base URL (default `https://api.node.humain.com/v1`). Alternatively, set `HUMAIN_NODE_API_KEY` and optionally `HUMAIN_NODE_BASE_URL` in your environment.
87
87
 
88
88
  HUMAIN Code CLI discovers the models available to that key before offering them in `/model`. Supported models use Node's Responses, Chat Completions, or Messages endpoint with normal streaming, tools, and reported token usage. Account spend, remaining quota, and pricing are not available from the supplied inference API. See [HUMAIN Node setup](providers.md#humain-node).
89
89
 
90
+ ## HUMAIN Gateway
91
+
92
+ [HUMAIN Gateway](https://gateway.humain.services) gives HUMAIN accounts access to approved models under per-user budgets and limits. HUMAIN Code CLI connects to it natively: no API key and no separate Gateway CLI.
93
+
94
+ Run `/login`, choose **Sign in with HUMAIN**, then **HUMAIN Gateway**. Sign-in opens Microsoft in your browser and returns to the terminal on its own. Over SSH, open the paste-code link instead and paste the one-time code into the masked prompt. Then use `/model` to choose one of the chat models your account is entitled to. `/accounts` shows the signed-in environment and email; `/logout` removes the session.
95
+
96
+ - The session token is stored only in the OS keychain: macOS Keychain, Linux Secret Service, or Windows Credential Manager. Sign-in fails with a clear message when no keychain is available; there is no plaintext fallback. CI and unattended use are not supported.
97
+ - Requests go only to the Gateway, which applies your budget, rate limits, and content checks. Failed requests are never resent automatically once a model may have accepted them.
98
+ - Models blocked for HUMAIN Code by the Gateway are hidden, with the reason shown. Cost shows 0 when the Gateway does not report it; that means unknown, not free.
99
+
100
+ HUMAIN Code CLI uses the production Gateway by default. Internal testers can switch to staging with `"humainGateway": { "environment": "staging" }` in `~/.humain-terminal/agent/settings.json`; project settings cannot change the environment. See [HUMAIN Gateway setup](providers.md#humain-gateway) for step-by-step instructions, print mode, and troubleshooting, and the [staging guide](../../../docs/humain-gateway-staging.md) for internal testers.
101
+
90
102
  ## Local Models
91
103
 
92
104
  Set `HUMAIN_TERMINAL_LOCAL_BASE_URL` to an OpenAI-compatible `/v1` endpoint. Models come from `HUMAIN_TERMINAL_LOCAL_MODELS` when set, otherwise HUMAIN Code CLI performs a bounded `/v1/models` discovery request.
package/docs/index.md CHANGED
@@ -40,7 +40,7 @@ HUMAIN Code CLI's tools and extensions run with the permissions of the HUMAIN Co
40
40
 
41
41
  ## HUMAIN Code CLI integrations
42
42
 
43
- - [HUMAIN Code CLI](humain-code.md) - branded command names, bundled web access/MCP integration, HUMAIN Node, and Forge/DeployNow setup.
43
+ - [HUMAIN Code CLI](humain-code.md) - branded command names, bundled web access/MCP integration, HUMAIN Gateway, HUMAIN Node, and Forge/DeployNow setup.
44
44
  - [Run Flow](flow.md) - hierarchical Flow runs with `/flow`, run controls, and limits.
45
45
  - [Configure Flow Profiles](flow-profiles.md) - Flow profile models, limits, and spend caps.
46
46
  - [Agent activity traces](trace.md) - proposal: record, upload and review what an agent did during a run.
@@ -0,0 +1,197 @@
1
+ # Models Configuration
2
+
3
+ <!-- This file is generated from TypeScript source. Do not edit it manually; run npm run generate:references. -->
4
+
5
+ This reference lists the fields of `models.json`. See [Configure a compatible endpoint](models.md#configure-a-compatible-endpoint) for examples and [Configuration](configuration.md#agent-directory) for the file location.
6
+
7
+ Add `"$schema": "https://pi.dev/schemas/models.schema.json"` to `models.json` for editor validation and completion.
8
+
9
+ ## Providers
10
+
11
+ Each key under `providers` is a provider ID. A built-in provider ID changes that provider. Any other ID adds a provider, which needs `baseUrl` and an `api` at provider or model level.
12
+
13
+ | Field | Type | Default | Description |
14
+ |---|---|---|---|
15
+ | `name` | string | | Display name. |
16
+ | `baseUrl` | string | | API base URL. Also applies to the provider's built-in models. |
17
+ | `apiKey` | string | | Literal key, "$NAME" environment interpolation, or "!command" output. |
18
+ | `api` | string | | API for the provider's models, such as "openai-completions", "openai-responses", "anthropic-messages", or "google-generative-ai". |
19
+ | `oauth` | `"radius"` | | OAuth login flow. Requires baseUrl. |
20
+ | `headers` | object | | Request headers. Values resolve like apiKey. |
21
+ | `compat` | [object](#compatibility) | | Provider and model compatibility overrides. |
22
+ | `authHeader` | boolean | `false` | Whether to send the resolved API key as Authorization: Bearer. |
23
+ | `models` | [`object[]`](#models) | | |
24
+ | `modelOverrides` | [object](#model-overrides) | | |
25
+
26
+ ## Models
27
+
28
+ Each `models` entry adds a model to the provider. An entry whose `id` matches an existing model replaces it.
29
+
30
+ | Field | Type | Default | Description |
31
+ |---|---|---|---|
32
+ | `id` | string | | Required. Model ID sent to the API. |
33
+ | `name` | string | | Display name, also matched by --model patterns. |
34
+ | `api` | string | | Overrides the provider api. |
35
+ | `baseUrl` | string | | Overrides the provider baseUrl. |
36
+ | `reasoning` | boolean | `false` | Whether the model supports thinking. |
37
+ | `thinkingLevelMap` | object | | Provider value sent for each thinking level. null marks a level unsupported. Levels the model does not map use the provider's default value through high; xhigh and max are unsupported. |
38
+ | `input` | `("text" \| "image")[]` | `["text"]` | |
39
+ | `inputLimits` | [object](#input-limits) | | |
40
+ | `cost` | object | | |
41
+ | `cost.input` | number | | Required. Input cost in USD per million tokens. |
42
+ | `cost.output` | number | | Required. Output cost in USD per million tokens. |
43
+ | `cost.cacheRead` | number | | Required. Cache-read cost in USD per million tokens. |
44
+ | `cost.cacheWrite` | number | | Required. Cache-write cost in USD per million tokens. |
45
+ | `cost.tiers` | `object[]` | | Request-wide pricing tiers. The highest matching input threshold applies to the full request. |
46
+ | `cost.tiers[].inputTokensAbove` | number | | Required. Use this tier when total request input exceeds this token count. |
47
+ | `cost.tiers[].input` | number | | Required. Input cost in USD per million tokens. |
48
+ | `cost.tiers[].output` | number | | Required. Output cost in USD per million tokens. |
49
+ | `cost.tiers[].cacheRead` | number | | Required. Cache-read cost in USD per million tokens. |
50
+ | `cost.tiers[].cacheWrite` | number | | Required. Cache-write cost in USD per million tokens. |
51
+ | `promptCache` | object | | Best-effort prompt cache lifetime in seconds for the short and long retention tiers. Pi warms only tiers with a known lifetime. |
52
+ | `contextWindow` | number | `128000` | Context window in tokens. |
53
+ | `maxTokens` | number | `16384` | Maximum output tokens. |
54
+ | `samplingParams` | object | | Fields merged into every request body. Applies only to OpenAI-compatible APIs. |
55
+ | `samplingParamsByThinkingLevel` | object | | samplingParams per thinking level, merged over samplingParams. |
56
+ | `headers` | object | | Request headers. Values resolve like apiKey. |
57
+ | `compat` | [object](#compatibility) | | Provider and model compatibility overrides. |
58
+
59
+ ## Model overrides
60
+
61
+ Each `modelOverrides` key is the ID of a built-in or extension model. Unknown IDs are ignored. Object fields, such as `cost`, merge with the model's value field by field; other fields replace it.
62
+
63
+ | Field | Type | Default | Description |
64
+ |---|---|---|---|
65
+ | `name` | string | | Display name, also matched by --model patterns. |
66
+ | `reasoning` | boolean | | Whether the model supports thinking. |
67
+ | `thinkingLevelMap` | object | | Provider value sent for each thinking level. null marks a level unsupported. Levels the model does not map use the provider's default value through high; xhigh and max are unsupported. |
68
+ | `input` | `("text" \| "image")[]` | | |
69
+ | `inputLimits` | [object](#input-limits) | | |
70
+ | `cost` | object | | |
71
+ | `cost.input` | number | | Input cost in USD per million tokens. |
72
+ | `cost.output` | number | | Output cost in USD per million tokens. |
73
+ | `cost.cacheRead` | number | | Cache-read cost in USD per million tokens. |
74
+ | `cost.cacheWrite` | number | | Cache-write cost in USD per million tokens. |
75
+ | `cost.tiers` | `object[]` | | Request-wide pricing tiers. The highest matching input threshold applies to the full request. |
76
+ | `cost.tiers[].inputTokensAbove` | number | | Required. Use this tier when total request input exceeds this token count. |
77
+ | `cost.tiers[].input` | number | | Required. Input cost in USD per million tokens. |
78
+ | `cost.tiers[].output` | number | | Required. Output cost in USD per million tokens. |
79
+ | `cost.tiers[].cacheRead` | number | | Required. Cache-read cost in USD per million tokens. |
80
+ | `cost.tiers[].cacheWrite` | number | | Required. Cache-write cost in USD per million tokens. |
81
+ | `promptCache` | object | | Best-effort prompt cache lifetime in seconds for the short and long retention tiers. Pi warms only tiers with a known lifetime. |
82
+ | `contextWindow` | number | | Context window in tokens. |
83
+ | `maxTokens` | number | | Maximum output tokens. |
84
+ | `samplingParams` | object | | Fields merged into every request body. Applies only to OpenAI-compatible APIs. |
85
+ | `samplingParamsByThinkingLevel` | object | | samplingParams per thinking level, merged over samplingParams. |
86
+ | `headers` | object | | Request headers. Values resolve like apiKey. |
87
+ | `compat` | [object](#compatibility) | | Provider and model compatibility overrides. |
88
+
89
+ ## Input limits
90
+
91
+ See [Describe model input and caching](models.md#describe-model-input-and-caching).
92
+
93
+ | Field | Type | Default | Description |
94
+ |---|---|---|---|
95
+ | `maxRequestBytes` | integer | | Maximum serialized provider request size in bytes. |
96
+ | `images` | object | | |
97
+ | `images.resize` | object | | Cache-safe resize profile applied before a new image enters conversation history. |
98
+ | `images.resize.maxWidth` | integer | | |
99
+ | `images.resize.maxHeight` | integer | | |
100
+ | `images.resize.maxBytes` | integer | | Maximum base64-encoded payload size in bytes. |
101
+ | `images.resize.jpegQuality` | integer | | |
102
+ | `images.maxPerMessage` | integer | | Maximum images accepted in one provider message. |
103
+ | `images.maxPerRequest` | integer | | Maximum images accepted across one provider request. |
104
+
105
+ ## Compatibility
106
+
107
+ `compat` describes verified differences from an API's standard request and response behavior. Model values override provider values per field. The fields that apply depend on the model's `api`.
108
+
109
+ ### `openai-completions`
110
+
111
+ | Field | Type | Default | Description |
112
+ |---|---|---|---|
113
+ | `supportsStore` | boolean | | Whether the provider supports the store field. Default: auto-detected from URL. |
114
+ | `supportsDeveloperRole` | boolean | | Whether the provider supports the developer role instead of system. Default: auto-detected from URL. |
115
+ | `supportsReasoningEffort` | boolean | | Whether the provider supports reasoning_effort. Default: auto-detected from URL. |
116
+ | `supportsUsageInStreaming` | boolean | `true` | Whether the provider supports stream_options.include_usage for token usage in streaming responses. |
117
+ | `supportsFinishReason` | boolean | `true` | Whether streamed responses include finish_reason. When false, pi infers stop or toolUse when the stream ends. |
118
+ | `maxTokensField` | `"max_completion_tokens" \| "max_tokens"` | | Which field to use for max tokens. Default: auto-detected from URL. |
119
+ | `requiresToolResultName` | boolean | | Whether tool results require the name field. Default: auto-detected from URL. |
120
+ | `requiresAssistantAfterToolResult` | boolean | | Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL. |
121
+ | `requiresThinkingAsText` | boolean | | Whether thinking blocks must be converted to text blocks with &lt;thinking> delimiters. Default: auto-detected from URL. |
122
+ | `requiresReasoningContentOnAssistantMessages` | boolean | | Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL. |
123
+ | `inlineThinkTags` | boolean | | Whether a leading &lt;think>...&lt;/think> section in streamed content is reasoning and is parsed into thinking blocks. Default: false. |
124
+ | `thinkingFormat` | `"openai" \| "openrouter" \| "deepseek" \| "together" \| "baseten" \| "zai" \| "qwen" \| "chat-template" \| "qwen-chat-template" \| "string-thinking" \| "ant-ling"` | | Format for reasoning or thinking parameters. When omitted, Pi auto-detects the format from the provider URL. "openai" uses reasoning_effort, "openrouter" uses reasoning.effort, "deepseek" uses thinking.type plus reasoning_effort when supported, "together" uses reasoning.enabled plus reasoning_effort when supported, "baseten" uses configurable chat_template_args plus reasoning_effort when supported, "zai" uses thinking.type, "qwen" uses top-level enable_thinking, "qwen-chat-template" uses chat_template_kwargs.enable_thinking and preserve_thinking, "chat-template" uses configurable chat_template_kwargs, "string-thinking" uses top-level thinking, and "ant-ling" uses reasoning.effort only when the mapped effort is non-null. |
125
+ | `chatTemplateKwargs` | object | | Kwargs sent as chat_template_kwargs when thinkingFormat is "chat-template". Use $var with "thinking.enabled", "thinking.effort", or "thinking.budget" for pi-controlled values. |
126
+ | `chatTemplateArgs` | object | | Arguments sent as chat_template_args when thinkingFormat is "baseten". Use $var with "thinking.enabled", "thinking.effort", or "thinking.budget" for pi-controlled values. |
127
+ | `openRouterRouting` | object | | OpenRouter provider routing preferences. Controls which upstream providers OpenRouter routes requests to. Sent as the provider field in the OpenRouter API request body. See https://openrouter.ai/docs/guides/routing/provider-selection. |
128
+ | `vercelGatewayRouting` | object | | Vercel AI Gateway routing preferences. Controls which upstream providers the gateway routes requests to. See https://vercel.com/docs/ai-gateway/models-and-providers/provider-options. |
129
+ | `zaiToolStream` | boolean | `false` | Whether z.ai supports top-level tool_stream for streaming tool call deltas. |
130
+ | `thinkingTokenBudgetField` | `"thinking_token_budget" \| "thinking_budget" \| "thinking_budget_tokens"` | | Top-level request field used to cap reasoning tokens from thinkingBudgets. Reasoning and the answer share max_tokens on these endpoints. "thinking_token_budget" is vLLM, "thinking_budget" is Qwen, DashScope, or SGLang, and "thinking_budget_tokens" is llama.cpp. Off by default and not set on the generated catalog. |
131
+ | `supportsThinkingTokenBudget` | boolean | `false` | Alias for thinkingTokenBudgetField: "thinking_token_budget" (vLLM). Prefer thinkingTokenBudgetField. |
132
+ | `supportsOpenAIGrammarTools` | boolean | `false` | Whether the provider supports OpenAI custom tools with Lark or regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. The generated catalog enables this for capable models. |
133
+ | `supportsMidConvoSystemMessages` | boolean | `false` | Whether the exact model accepts system or developer messages after the conversation has started. When false, later system messages are folded into the leading system message. The generated catalog enables this for verified models. |
134
+ | `supportsMidConvoToolAdditions` | boolean | `false` | Whether system messages can introduce additional tools mid-conversation. Requires supportsMidConvoSystemMessages. The generated catalog enables this for capable models. |
135
+ | `supportsStrictMode` | boolean | `false` | Whether the provider supports the strict field in tool definitions. Generated capable models enable it explicitly. |
136
+ | `cacheControlFormat` | `"anthropic"` | | Cache control convention for prompt caching. Anthropic applies cache_control markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content. |
137
+ | `sendSessionAffinityHeaders` | boolean | | Whether to send session-affinity data from options.sessionId. Default: true for OpenRouter endpoints, false otherwise. |
138
+ | `sessionAffinityFormat` | `"openai" \| "openai-nosession" \| "openrouter"` | | Session-affinity header format. openai sends session_id, x-client-request-id, and x-session-affinity; openai-nosession sends x-client-request-id and x-session-affinity; openrouter sends x-session-id. Does not affect prompt_cache_key. Default: auto-detected. |
139
+ | `supportsLongCacheRetention` | boolean | | Whether the provider supports long prompt cache retention (prompt_cache_retention: "24h" or Anthropic-style cache_control.ttl: "1h", depending on format). Default: auto-detected from provider and URL. |
140
+ | `vllmPriority` | number | | vLLM scheduler priority sent as the top-level priority request field. Lower values are handled earlier and the server default is 0. Only meaningful with --scheduling-policy priority. Off by default and not set on the generated catalog. |
141
+
142
+ ### `openai-responses`
143
+
144
+ Also applies to `azure-openai-responses` and `openai-codex-responses`.
145
+
146
+ | Field | Type | Default | Description |
147
+ |---|---|---|---|
148
+ | `supportsDeveloperRole` | boolean | `true` | Whether the provider supports the developer role instead of system. |
149
+ | `supportsMidConvoSystemMessages` | boolean | `false` | Whether the exact model accepts developer or system messages after the conversation has started. When false, later system messages are folded into the leading system message. The generated catalog enables this for verified models. |
150
+ | `sessionAffinityFormat` | `"openai" \| "openai-nosession" \| "openrouter"` | | Session-affinity header format. openai sends session_id and x-client-request-id; openai-nosession sends x-client-request-id; openrouter sends x-session-id. Does not affect prompt_cache_key. Default: auto-detected. |
151
+ | `supportsLongCacheRetention` | boolean | `true` | Whether the provider supports long prompt cache retention. This uses prompt_cache_options.ttl: "30m" on GPT-5.6+ and prompt_cache_retention: "24h" on earlier models. |
152
+ | `supportsStrictMode` | boolean | | Whether the provider supports strict JSON-schema function tools. Defaults are API-specific; generated OpenAI models enable it explicitly. |
153
+ | `supportsOpenAIGrammarTools` | boolean | `false` | Whether to emit OpenAI custom tools with Lark or regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. The generated catalog enables this for capable models. |
154
+ | `supportsAdditionalTools` | boolean | `false` | Whether the model supports message-anchored additional_tools input items. |
155
+ | `supportsToolSearch` | boolean | `false` | Whether the model supports client-executed tool search for transcript-anchored additions. |
156
+ | `supportsExplicitPromptCacheMode` | boolean | `false` | Whether the model accepts prompt_cache_options. Older OpenAI models reject the parameter. |
157
+ | `supportsMidConvoEffort` | boolean | `false` | Whether thinking level changes are sent as configuration_update input items instead of changing reasoning.effort, so a change keeps the prompt cache. Only used by the openai-responses API, and ignored with Sign in with ChatGPT on the openai provider. |
158
+ | `supportsMaxOutputTokens` | boolean | `true` | Whether the provider accepts max_output_tokens. Some Codex-protocol gateways reject it. |
159
+
160
+ ### `anthropic-messages`
161
+
162
+ | Field | Type | Default | Description |
163
+ |---|---|---|---|
164
+ | `supportsEagerToolInputStreaming` | boolean | `true` | Whether the provider accepts per-tool eager_input_streaming. When false, the Anthropic provider omits tools[].eager_input_streaming and sends the legacy fine-grained-tool-streaming-2025-05-14 beta header for tool-enabled requests. |
165
+ | `supportsLongCacheRetention` | boolean | `true` | Whether the provider supports Anthropic long cache retention through cache_control.ttl. |
166
+ | `sendSessionAffinityHeaders` | boolean | | Whether to send x-session-affinity from options.sessionId when caching is enabled. Required for providers like Fireworks that use session affinity for prompt cache routing; requests to the same replica maximize cache hits. Default: true for OpenRouter endpoints, false otherwise. |
167
+ | `sessionAffinityFormat` | `"openrouter"` | | Session-affinity format. openrouter sends x-session-id; when unset, sends x-session-affinity. |
168
+ | `supportsCacheControlOnTools` | boolean | `true` | Whether the provider supports Anthropic-style cache_control markers on tool definitions. When false, cache_control is omitted from tool parameters. Some Anthropic-compatible providers, such as Fireworks, do not support this field on tools and may reject or ignore it. |
169
+ | `supportsTemperature` | boolean | `true` | Ignored. The Anthropic Messages API version in use (2026-10-21) has no temperature field, so temperature is never sent. |
170
+ | `forceAdaptiveThinking` | boolean | `false` | Whether to force adaptive thinking (thinking.type: adaptive plus output_config.effort) regardless of model ID. Built-in models that require adaptive thinking set this in generated metadata. Custom Anthropic-compatible providers can set this to true for any model whose upstream requires the adaptive format. Set false to opt out on overridden built-in models. |
171
+ | `allowEmptySignature` | boolean | `false` | Whether to replay empty thinking signatures instead of converting thinking to text. |
172
+ | `supportsStrictTools` | boolean | `false` | Whether the provider supports Anthropic strict tool schemas. Generated Anthropic models enable it explicitly. |
173
+ | `supportsMidConvoEffort` | boolean | `false` | Whether the exact model transport supports effort-only system messages and thinking binding controls. |
174
+ | `supportsMidConvoSystemMessages` | boolean | `false` | Whether the exact model accepts system-role messages inside the conversation. When false, later system messages are folded into the top-level system prompt. |
175
+ | `supportsMidConvoToolChanges` | boolean | `false` | Whether the exact model accepts mid-conversation tool_addition and tool_removal blocks. Requires supportsMidConvoSystemMessages. |
176
+ | `allowedFallbackModels` | `object[]` | | Models Anthropic accepts for server-side refusal fallback, with local pricing metadata for returned fallback responses. When absent or empty, callers must omit fallbacks; Anthropic rejects the field for models with no permitted fallback targets. |
177
+
178
+ ### `bedrock-converse-stream`
179
+
180
+ | Field | Type | Default | Description |
181
+ |---|---|---|---|
182
+ | `supportsStrictMode` | boolean | `false` | Whether the model supports Bedrock strict tool schemas. |
183
+
184
+ ### `mistral-conversations`
185
+
186
+ | Field | Type | Default | Description |
187
+ |---|---|---|---|
188
+ | `supportsMidConvoSystemMessages` | boolean | `false` | Whether the exact model accepts system messages after the conversation has started. When false, later system messages are folded into the leading system message. |
189
+
190
+ ### `typesafe-system-one`
191
+
192
+ Also applies to `cloudflare-workers-ai-system-one`.
193
+
194
+ | Field | Type | Default | Description |
195
+ |---|---|---|---|
196
+ | `imageInput` | `"assets" \| "images" \| "state-image-urls"` | | How the service takes classifier images. "assets" sends TypeSafe's assets map (PNG and JPEG) and references the images from the state, as TypeSafe and Jev on Workers AI expect. "images" sends Clef's images list of data URLs (PNG, JPEG, and WebP, at most four), as Clef on Workers AI expects. "state-image-urls" places image_url parts before the state, as OpenRouter expects; OpenRouter drops assets without an error. Auto-detected from the provider, baseUrl, and model ID. Classifier models read it from the provider-level compat; models and modelOverrides entries apply to chat models only. |
197
+ | `sendImageOptInHeader` | boolean | | Whether requests with images send the TypeSafe-Danger-Zone-Images: true header, which TypeSafe's own API requires for its experimental image input. Defaults to true for the typesafe-system-one API unless the model is detected as OpenRouter. |
package/docs/models.md CHANGED
@@ -6,6 +6,8 @@ For a built-in provider, start with `/login`, then choose a model with `/model`.
6
6
 
7
7
  | What you have | Recommended setup |
8
8
  |---|---|
9
+ | A HUMAIN account | `/login` → **Sign in with HUMAIN** → **HUMAIN Gateway** (Microsoft sign-in, no API key) |
10
+ | A HUMAIN Node API key | `/login` → **Sign in with HUMAIN** → **HUMAIN Node**, or set `HUMAIN_NODE_API_KEY` |
9
11
  | A supported subscription | Sign in through `/login` |
10
12
  | A provider API key | Store it through `/login` or set its environment variable |
11
13
  | A local GGUF model | Connect HUMAIN Code CLI to the llama.cpp router |
@@ -26,7 +28,7 @@ Keep `auth.json` and any credential commands private. Project settings and exten
26
28
 
27
29
  ## Select a model
28
30
 
29
- Run `/model` to search available models. The picker shows models whose providers have usable authentication. Press `Ctrl+S` on a model to save it as the default for new sessions.
31
+ Run `/model` to search available models. The picker shows models whose providers have usable authentication. Press Enter to use a model for the current session, or `Ctrl+S` to also save it as the default for new sessions.
30
32
 
31
33
  Run `/thinking` to select the thinking level for the current model. Press `Ctrl+S` there to save the startup level. HUMAIN Code CLI limits the choices to levels supported by the selected model.
32
34
 
@@ -62,10 +64,22 @@ Use [`models.json`](configuration.md#agent-directory) when an endpoint speaks an
62
64
  }
63
65
  ```
64
66
 
65
- The dummy key makes the model available to HUMAIN Code CLI; Ollama ignores it. For an authenticated endpoint, `apiKey` and header values can use `$NAME` or `${NAME}` environment interpolation, a literal value, or a leading `!command`. Commands in `models.json` run at request time and are not cached by HUMAIN Code CLI.
67
+ The dummy key makes the model available to HUMAIN Code CLI; Ollama ignores it. For an authenticated endpoint, `apiKey` and header values can use `$NAME` or `${NAME}` environment interpolation, a literal value, or a leading `!command`. `$$` and `$!` produce a literal `$` and `!`. Commands in `models.json` run at request time and are not cached by HUMAIN Code CLI.
66
68
 
67
69
  Opening `/model` reloads the file. A `models` entry adds or replaces a model with the same ID on that provider. Use `modelOverrides` to change metadata for an existing built-in or extension-provided model without replacing the provider's model list. Unknown override IDs are ignored.
68
70
 
71
+ To route a built-in provider through a proxy, set only its `baseUrl`. Its models and authentication stay unchanged:
72
+
73
+ ```json
74
+ {
75
+ "providers": {
76
+ "anthropic": { "baseUrl": "https://proxy.example.com/v1" }
77
+ }
78
+ }
79
+ ```
80
+
81
+ [Models Configuration](models-configuration.md) lists every field.
82
+
69
83
  ### Describe model input and caching
70
84
 
71
85
  Use `inputLimits.images.resize` to control how HUMAIN Code CLI encodes new image attachments, `read` results, and tool-result images before storing them in conversation history:
@@ -129,20 +143,20 @@ Compatibility settings should describe verified differences in the endpoint's re
129
143
 
130
144
  ## Use classifier models
131
145
 
132
- Classifier models do not chat. They answer typed questions about JSON state: pick one of several choices, answer yes or no, or give a score, each with probabilities. HUMAIN Code CLI includes TypeSafe's Jev model from these providers, Cloudflare's Clef and Clef Flash models from Workers AI, and OpenAI's GPT-6 Luna through the [Decisions API](https://developers.openai.com/api/docs/guides/decisions):
146
+ Classifier models do not chat. They answer typed questions about JSON state: pick one of several choices, answer yes or no, or give a score, each with probabilities. HUMAIN Code CLI includes TypeSafe's Jev model from these providers, Cloudflare's Clef, Clef Flash, and Clef Omni models from Workers AI and OpenRouter, and OpenAI's GPT-6 Luna through the [Decisions API](https://developers.openai.com/api/docs/guides/decisions):
133
147
 
134
148
  | Provider | Model IDs | Authentication |
135
149
  |---|---|---|
136
150
  | `typesafe` | `jev-latest` | `TYPESAFE_API_KEY` |
137
- | `openrouter` | `typesafe/jev-1.13`, `~typesafe/jev-latest` | `OPENROUTER_API_KEY` or `/login` |
138
- | `cloudflare-workers-ai` | `typesafe/jev`, `@cf/cloudflare/clef`, `@cf/cloudflare/clef-flash` | `CLOUDFLARE_API_KEY` and `CLOUDFLARE_ACCOUNT_ID` |
151
+ | `openrouter` | `typesafe/jev-1.13`, `typesafe/jev-1.14`, `~typesafe/jev-latest`, `cloudflare/clef`, `cloudflare/clef-flash`, `cloudflare/clef-omni` | `OPENROUTER_API_KEY` or `/login` |
152
+ | `cloudflare-workers-ai` | `typesafe/jev`, `typesafe/jev-1.14.0`, `@cf/cloudflare/clef`, `@cf/cloudflare/clef-flash`, `@cf/cloudflare/clef-omni` | `CLOUDFLARE_API_KEY` and `CLOUDFLARE_ACCOUNT_ID` |
139
153
  | `vercel-ai-gateway` | `typesafe-ai/jev` | `AI_GATEWAY_API_KEY` |
140
154
  | `opencode` | `jev-1.13`, `jev-1.13-free` | `OPENCODE_API_KEY` |
141
155
  | `openai` | `gpt-6-luna` | `OPENAI_API_KEY` |
142
156
 
143
157
  Chat models on a [llama.cpp router](llama-cpp.md#classification) are also listed as classifier models.
144
158
 
145
- OpenAI's Decisions API needs an API key. Sign in with ChatGPT credentials do not work with it, so `gpt-6-luna` is not listed as available while `openai` is logged in through `/login`, even when `OPENAI_API_KEY` is set; log out of `openai` to use the key. GPT-6 Luna also judges images passed in `images` (see [Codemode](codemode.md#classify)); other classifier models return an error for them. The API rejects inputs above 922K tokens, but requests that run longer than about five seconds, currently above roughly 600K input tokens, fail with a gateway timeout.
159
+ OpenAI's Decisions API needs an API key. Sign in with ChatGPT credentials do not work with it, so `gpt-6-luna` is not listed as available while `openai` is logged in through `/login`, even when `OPENAI_API_KEY` is set; log out of `openai` to use the key. The API rejects inputs above 922K tokens, but requests that run longer than about five seconds, currently above roughly 600K input tokens, fail with a gateway timeout.
146
160
 
147
161
  Classifier models do not appear in `/model`. The model reaches them through the [`codemode`](cli.md#enable-codemode) tool, which is off unless an MCP server turned it on. Enable it with `"defaultTools": ["+codemode"]` in [settings](settings.md#tools). Scripts then list classifier models with `models.getAvailableOfType("classifier")` and call `models.classify(model, { state, questions })`:
148
162
 
@@ -163,6 +177,10 @@ return result.answers;
163
177
 
164
178
  [Codemode](codemode.md#classify) describes the question and answer types.
165
179
 
180
+ Classifier models whose `input` includes `"image"` also judge images passed in `images`; other classifier models return an error for them. Image input works with GPT-6 Luna, with Jev from `typesafe` and `cloudflare-workers-ai`, with Clef from `cloudflare-workers-ai`, and with the OpenRouter models whose catalog lists image input. Jev takes PNG and JPEG images, and image input is experimental on TypeSafe's own API. Clef takes PNG, JPEG, and WebP images, at most four per request. Jev from `vercel-ai-gateway` and `opencode` takes text only.
181
+
182
+ Each System One service takes images in its own request format, set by the model's `compat.imageInput`. Built-in models set it, so overriding a provider's `baseUrl` keeps it. A custom provider that proxies another service's classifiers sets it in its provider-level `compat` in `models.json` (see [System One compatibility](models-configuration.md#typesafe-system-one)). OpenRouter in particular answers requests in TypeSafe's format without an error but drops the images.
183
+
166
184
  When the service reports token counts, as all System One services do, `result.usage` carries them with their cost. HUMAIN Code CLI adds the usage of a script's classifier calls to the `codemode` tool result, so it counts toward the session cost in the footer and `/session`. The cost uses the model's catalog price; models without one, such as TypeSafe's direct `jev-latest`, report tokens at no cost.
167
185
 
168
186
  Extensions call classifiers through `ctx.modelRegistry.classify()`, without codemode. [Virtual models](virtual-models.md#route-requests) can use them to route requests; see the `jev-router.ts` example.
package/docs/providers.md CHANGED
@@ -118,7 +118,7 @@ A stored API-key credential can include an `env` object. Its values take priorit
118
118
 
119
119
  Radius is a service crafted for Pi by the builders of Pi, Earendil Works. It provides a customizable AI gateway with organization-level controls and analytics built in, and artifacts for sharing what you create with Pi.
120
120
 
121
- To get started, run `/login radius` in Pi. This adds Radius as a provider, and its models appear in `/model` like any other provider's.
121
+ To get started, run `/login radius` in Pi. This adds Radius as a provider, and its models appear in `/model` like any other provider's. HUMAIN Code CLI does not list Radius in the top-level `/login` menu; `/login radius` and the **Sign in with an account** list still reach it.
122
122
 
123
123
  Radius also has an MCP server, so Pi can manage Radius for you.
124
124
 
@@ -261,9 +261,65 @@ gcloud auth application-default login
261
261
 
262
262
  To use a service-account key file instead, set `GOOGLE_APPLICATION_CREDENTIALS` along with the project and location.
263
263
 
264
+ ## HUMAIN Gateway
265
+
266
+ [HUMAIN Gateway](https://gateway.humain.services) gives HUMAIN accounts the models, budget, and limits assigned to them. HUMAIN Code CLI signs in with your Microsoft account; there is no API key to create, paste, or store, and you do not need the separate `humain` Gateway CLI.
267
+
268
+ ### 1. Environment
269
+
270
+ HUMAIN Code CLI uses the production Gateway (`https://gateway.humain.services/ai-gateway`) by default; no setting is needed. Internal testers can switch to staging in `~/.humain-terminal/agent/settings.json` (global settings only; project settings are ignored) and restart HUMAIN Code CLI:
271
+
272
+ ```json
273
+ { "humainGateway": { "environment": "staging" } }
274
+ ```
275
+
276
+ Both Gateway hosts are reachable only from the HUMAIN corporate network.
277
+
278
+ ### 2. Sign in
279
+
280
+ 1. Run `/login`.
281
+ 2. Choose **Sign in with HUMAIN**, then **HUMAIN Gateway**. (It is also listed under **Sign in with an API key**, because its session is a per-user key, even though you never handle it.)
282
+ 3. Your browser opens the Gateway's Microsoft sign-in. Sign in; the page shows **Authentication successful** and the terminal continues on its own.
283
+
284
+ Over SSH or on a machine whose browser cannot reach the terminal, open the **HUMAIN Gateway sign-in (paste code)** link shown in the terminal on any machine, sign in, and paste the one-time `hc_...` code into the masked prompt. The code expires after 2 minutes and works once.
285
+
286
+ The Gateway issues a personal session key, which HUMAIN Code CLI stores in the OS keychain: macOS Keychain, Linux Secret Service (needs a D-Bus session and `secret-tool`), or Windows Credential Manager. `auth.json` keeps only the environment, a session ID, and your email. Sign-in stops with a clear message when no keychain is available.
287
+
288
+ ### 3. Choose a model
289
+
290
+ Run `/model` and pick a `humain-gateway` model. Only chat models your account is entitled to appear; models the Gateway blocks for HUMAIN Code are hidden and named in a warning with the reason. Press `Ctrl+S` on a model to make it the default for new sessions.
291
+
292
+ For print mode, sign in interactively once, then pass the provider and model:
293
+
294
+ ```bash
295
+ humain-code --list-models | grep humain-gateway
296
+ humain-code --provider humain-gateway --model zai-org/GLM-5.3-Flash -p "Say hello"
297
+ ```
298
+
299
+ CI and unattended runs are not supported: every session needs an interactive Microsoft sign-in, and the key never comes from an environment variable.
300
+
301
+ ### Accounts, logout, and limits
302
+
303
+ - `/accounts` shows the HUMAIN Gateway session with its environment and email.
304
+ - `/logout` → **HUMAIN Gateway** removes the local session. The Gateway revokes it on the next interactive start or the next sign-in.
305
+ - Signing in again replaces the session; the old one is revoked automatically afterwards.
306
+ - Your monthly budget and request limits apply. A used-up budget shows the Gateway's budget message and is not retried. Rate limits and "no deployments available" are retried at most three times after the Gateway's suggested delay; other failures are never resent, so a request is not billed twice.
307
+ - Cost shows 0 when the Gateway does not report it; that means unknown, not free.
308
+ - `models.json` entries for `humain-gateway` are ignored; requests always go to the Gateway host for the selected environment.
309
+
310
+ ### Troubleshooting
311
+
312
+ | Message | Fix |
313
+ | --- | --- |
314
+ | `Could not reach HUMAIN Gateway to finish sign-in.` / browser shows `ERR_CONNECTION_CLOSED` | Connect to the HUMAIN corporate network. Staging may require separate access from the Gateway team. |
315
+ | `HUMAIN Gateway sign-in code is invalid or expired.` | Run `/login` again; codes last 2 minutes and work once. |
316
+ | `HUMAIN Gateway requires a newer HUMAIN Code CLI.` | Update HUMAIN Code CLI, then sign in again. |
317
+ | Keychain or Secret Service error | Unlock the keychain, or on Linux start a desktop session with Secret Service. |
318
+ | `HUMAIN Gateway CLI session unavailable. Sign in again.` | Your access was revoked or rotated; run `/login` again. |
319
+
264
320
  ## HUMAIN Node
265
321
 
266
- Run `/login humain-node` (or select **HUMAIN Node** in `/login`). Enter the API key in the masked terminal prompt, then accept `https://api.node.humain.com/v1` or enter a custom base URL. Login validates the key with `GET /models` using the `x-api-key` header before saving credentials.
322
+ Run `/login humain-node`, or choose **Sign in with HUMAIN** → **HUMAIN Node** in `/login`. Enter the API key in the masked terminal prompt, then accept `https://api.node.humain.com/v1` or enter a custom base URL. Login validates the key with `GET /models` using the `x-api-key` header before saving credentials.
267
323
 
268
324
  To obtain a key, open your Team's **Users** page in HUMAIN Node, select the user for this workload and environment, and create an API key. Save it in your local environment as `HUMAIN_NODE_API_KEY` or in a secret manager. Never paste it into chat. If the environment variable is set, leave the login key prompt blank to use it without copying the key into `auth.json`.
269
325
 
@@ -47,7 +47,14 @@ In HUMAIN Code CLI, run:
47
47
  /login
48
48
  ```
49
49
 
50
- Choose a provider, then follow the prompts to use a subscription or store an API key. Run `/model` afterward if you want to select a different available model.
50
+ With a HUMAIN account, choose **Sign in with HUMAIN**, then:
51
+
52
+ - **HUMAIN Gateway** to sign in with your Microsoft account in the browser (no API key), or
53
+ - **HUMAIN Node** to paste an API key from your HUMAIN Node team's **Users** page.
54
+
55
+ Otherwise choose **Sign in with an account** for a subscription, or **Sign in with an API key** for another provider, and follow the prompts.
56
+
57
+ Run `/model` afterward to choose a model: **Enter** uses it for this session, and **Ctrl+S** saves it as your default for new sessions. See [HUMAIN Gateway](providers.md#humain-gateway) and [HUMAIN Node](providers.md#humain-node) for details.
51
58
 
52
59
  See [Choose a model and provider](models.md) for supported providers, environment-variable authentication, local models, and custom endpoints.
53
60
 
package/docs/settings.md CHANGED
@@ -120,7 +120,7 @@ CLI tool options override this setting for one invocation. `--tools` with only `
120
120
  | Setting | Type | Default | Description |
121
121
  |---|---|---|---|
122
122
  | `compaction.enabled` | boolean | `true` | Enable automatic compaction. |
123
- | `compaction.reserveTokens` | number | `16384` | Tokens reserved for the model response. |
123
+ | `compaction.reserveTokens` | number | `16384` | Free context tokens below which automatic compaction starts. |
124
124
  | `compaction.keepRecentTokens` | number | `20000` | Recent tokens retained without summarization. |
125
125
  | `compaction.modelOverrides` | object | None | Per-model token settings keyed by exact `provider/modelId`. |
126
126