@humain/humain-code 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (792) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/README.md +23 -6
  3. package/dist/agent-monitor/entry.lazy.d.ts +3 -0
  4. package/dist/agent-monitor/entry.lazy.d.ts.map +1 -0
  5. package/dist/agent-monitor/entry.lazy.js +3 -0
  6. package/dist/agent-monitor/entry.lazy.js.map +1 -0
  7. package/dist/bundle/agent-monitor.js +1 -1
  8. package/dist/bundle/chunks/adaptive-peer-worker-X2ZNZE3S.js +8 -0
  9. package/dist/bundle/chunks/adaptive-session-host-7KDSQV5I.js +162 -0
  10. package/dist/bundle/chunks/anthropic-messages-TQK3FUV3.js +68 -0
  11. package/dist/bundle/chunks/anthropic.js +13 -10
  12. package/dist/bundle/chunks/{azure-openai-responses-IV74M5OR.js → azure-openai-responses-JY7OSLH2.js} +6 -6
  13. package/dist/bundle/chunks/bedrock-converse-stream.js +79 -74
  14. package/dist/bundle/chunks/chunk-2FYYW6FY.js +2 -0
  15. package/dist/bundle/chunks/{chunk-A2VPLMF2.js → chunk-2G7YVAVF.js} +1 -1
  16. package/dist/bundle/chunks/chunk-32QLLD2P.js +1114 -0
  17. package/dist/bundle/chunks/{chunk-3LP543EX.js → chunk-3EDMWQ35.js} +17 -16
  18. package/dist/bundle/chunks/chunk-3HVHETMU.js +18 -0
  19. package/dist/bundle/chunks/{chunk-XMZGB3H4.js → chunk-4HTVBBJD.js} +11 -6
  20. package/dist/bundle/chunks/chunk-4JRER4XK.js +175 -0
  21. package/dist/bundle/chunks/{chunk-FHLLDO7U.js → chunk-4PRNKB6V.js} +5 -5
  22. package/dist/bundle/chunks/chunk-4QAXV5T6.js +49 -0
  23. package/dist/bundle/chunks/{chunk-JCTQQ3DX.js → chunk-4V5VL2BO.js} +1 -1
  24. package/dist/bundle/chunks/chunk-5B25YXF7.js +24 -0
  25. package/dist/bundle/chunks/chunk-5L4PBYC7.js +11 -0
  26. package/dist/bundle/chunks/chunk-66FZJO75.js +5146 -0
  27. package/dist/bundle/chunks/chunk-6P6GJPYB.js +4 -0
  28. package/dist/bundle/chunks/chunk-6PNQYO6A.js +10 -0
  29. package/dist/bundle/chunks/chunk-7NKUVTBL.js +76 -0
  30. package/dist/bundle/chunks/chunk-AEWYICBL.js +89 -0
  31. package/dist/bundle/chunks/chunk-AQ4EXORZ.js +14 -0
  32. package/dist/bundle/chunks/chunk-AZXVJN6E.js +19 -0
  33. package/dist/bundle/chunks/chunk-CRN54O4D.js +24 -0
  34. package/dist/bundle/chunks/chunk-CTU2ECLD.js +7 -0
  35. package/dist/bundle/chunks/{chunk-BQ3TMEWD.js → chunk-EIC7CQX3.js} +4 -3
  36. package/dist/bundle/chunks/chunk-F6ZAYLU2.js +59 -0
  37. package/dist/bundle/chunks/chunk-G4QPSFBF.js +493 -0
  38. package/dist/bundle/chunks/chunk-GME4AWDG.js +23 -0
  39. package/dist/bundle/chunks/{chunk-SFMDIVZ4.js → chunk-GRJUKEE3.js} +43 -30
  40. package/dist/bundle/chunks/chunk-GTILMMUF.js +12 -0
  41. package/dist/bundle/chunks/chunk-GUHNFZ2Q.js +51 -0
  42. package/dist/bundle/chunks/chunk-GY663MNP.js +11 -0
  43. package/dist/bundle/chunks/chunk-HTA325LJ.js +56 -0
  44. package/dist/bundle/chunks/{chunk-5L4JG6PO.js → chunk-I3NDOUHE.js} +8 -7
  45. package/dist/bundle/chunks/chunk-I5E7RQ5V.js +21 -0
  46. package/dist/bundle/chunks/chunk-IWZQ25I3.js +5 -0
  47. package/dist/bundle/chunks/chunk-IYGHKVUG.js +2 -0
  48. package/dist/bundle/chunks/chunk-J57HOSWD.js +21 -0
  49. package/dist/bundle/chunks/chunk-JF7FYXAI.js +288 -0
  50. package/dist/bundle/chunks/chunk-JSZBTGI6.js +10 -0
  51. package/dist/bundle/chunks/chunk-JYWUOKOI.js +1061 -0
  52. package/dist/bundle/chunks/{chunk-DLCBSLHW.js → chunk-KRCX3ZBA.js} +1 -1
  53. package/dist/bundle/chunks/chunk-KTSJYIYC.js +30 -0
  54. package/dist/bundle/chunks/{chunk-K7SDY3VJ.js → chunk-LB4CIS4F.js} +40 -165
  55. package/dist/bundle/chunks/{chunk-NN53K2QQ.js → chunk-LYZ37DJP.js} +2 -14
  56. package/dist/bundle/chunks/chunk-MD7K7RPN.js +20 -0
  57. package/dist/bundle/chunks/chunk-MX4Q4W6H.js +214 -0
  58. package/dist/bundle/chunks/{chunk-6PD3T2EF.js → chunk-N2SNMUD3.js} +1 -1
  59. package/dist/bundle/chunks/chunk-NXA6NEHE.js +54 -0
  60. package/dist/bundle/chunks/chunk-OB332KMV.js +300 -0
  61. package/dist/bundle/chunks/chunk-P6AXBESH.js +1883 -0
  62. package/dist/bundle/chunks/chunk-PPBDDQHP.js +11 -0
  63. package/dist/bundle/chunks/chunk-PWUDFU5V.js +51 -0
  64. package/dist/bundle/chunks/chunk-Q5RKNQ2T.js +73 -0
  65. package/dist/bundle/chunks/chunk-QT6ZHDMP.js +12 -0
  66. package/dist/bundle/chunks/chunk-R5OOX7RW.js +16 -0
  67. package/dist/bundle/chunks/chunk-R6YQR7TZ.js +25 -0
  68. package/dist/bundle/chunks/{chunk-4ZBGTJJM.js → chunk-RNBZBCH2.js} +1 -1
  69. package/dist/bundle/chunks/chunk-RQU722SY.js +1 -0
  70. package/dist/bundle/chunks/{chunk-RGUZULEE.js → chunk-RS6PZK35.js} +71 -72
  71. package/dist/bundle/chunks/{jiti-loader-6P33XTLC.js → chunk-RW7GT7L3.js} +1 -1
  72. package/dist/bundle/chunks/{chunk-PCTLFSQG.js → chunk-SCINMV4X.js} +1 -1
  73. package/dist/bundle/chunks/{chunk-NCC2FAJN.js → chunk-SSRCVJZK.js} +28 -28
  74. package/dist/bundle/chunks/chunk-T5A6T24H.js +93 -0
  75. package/dist/bundle/chunks/chunk-T7BXP46S.js +3367 -0
  76. package/dist/bundle/chunks/chunk-TGDPZCSW.js +9 -0
  77. package/dist/bundle/chunks/{chunk-4J6BGNX2.js → chunk-TWAHPPXN.js} +434 -429
  78. package/dist/bundle/chunks/chunk-UEW6TUSP.js +36 -0
  79. package/dist/bundle/chunks/chunk-UZNIPOGS.js +323 -0
  80. package/dist/bundle/chunks/{chunk-KM4GQ2BU.js → chunk-VFLVWPLZ.js} +5 -6
  81. package/dist/bundle/chunks/chunk-WAPZN4KP.js +74 -0
  82. package/dist/bundle/chunks/chunk-WCFHG6NO.js +16 -0
  83. package/dist/bundle/chunks/chunk-WQ7EJQIT.js +839 -0
  84. package/dist/bundle/chunks/chunk-WQOOJP7U.js +4 -0
  85. package/dist/bundle/chunks/chunk-XHDVDJM7.js +17 -0
  86. package/dist/bundle/chunks/chunk-YPZPCHNV.js +3 -0
  87. package/dist/bundle/chunks/chunk-Z5YLKK3S.js +41 -0
  88. package/dist/bundle/chunks/chunk-ZJUU6WOV.js +2052 -0
  89. package/dist/bundle/chunks/{cli-N7KOVPLB.js → cli-H4LJNE2V.js} +2 -2
  90. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-KRMHG2L3.js → cloudflare-workers-ai-system-one-T5R2RVFQ.js} +1 -1
  91. package/dist/bundle/chunks/codemode-worker.js +2 -0
  92. package/dist/bundle/chunks/compat-ZK2DIW3P.js +15 -0
  93. package/dist/bundle/chunks/dist-EY7YKQHB.js +11 -0
  94. package/dist/bundle/chunks/dist-FMWWM4H7.js +268 -0
  95. package/dist/bundle/chunks/dist-NHQTBDHT.js +1107 -0
  96. package/dist/bundle/chunks/{easter-egg-3d-O2GG2XIG.js → easter-egg-3d-BUEOC3NO.js} +1 -1
  97. package/dist/bundle/chunks/entry-A2CSLKHC.js +323 -0
  98. package/dist/bundle/chunks/entry-AL54ZGYO.js +2 -0
  99. package/dist/bundle/chunks/{execute-LMBACTKA.js → execute-MY5JSEPV.js} +18 -15
  100. package/dist/bundle/chunks/{extract-CXXLVFC5.js → extract-PTGACPGP.js} +3 -3
  101. package/dist/bundle/chunks/flow-implementer-APJFY4YI.js +21 -0
  102. package/dist/bundle/chunks/github-copilot.js +66 -62
  103. package/dist/bundle/chunks/{google-generative-ai-SBL77OXO.js → google-generative-ai-UL7YEQ6J.js} +2 -3
  104. package/dist/bundle/chunks/{google-vertex-NZBNNXMK.js → google-vertex-OTMSPUYH.js} +3 -3
  105. package/dist/bundle/chunks/host-75YAHLDR.js +3 -0
  106. package/dist/bundle/chunks/index.bundle-THL4EUSU.js +390 -0
  107. package/dist/bundle/chunks/inprocess-5NP5VJHZ.js +32 -0
  108. package/dist/bundle/chunks/interactive-mode-IW4PIVAQ.js +5 -0
  109. package/dist/bundle/chunks/jiti-bun-loader-VSLLRCSD.js +3459 -0
  110. package/dist/bundle/chunks/jiti-loader-TMJL6S2D.js +2 -0
  111. package/dist/bundle/chunks/{llama-cpp-classify-PP63BYDF.js → llama-cpp-classify-GJAXULWL.js} +1 -1
  112. package/dist/bundle/chunks/{mistral-conversations-DX4YKJSO.js → mistral-conversations-E72Y6OC3.js} +2 -2
  113. package/dist/bundle/chunks/{node-UGQUSQE6.js → node-ZFIIS5IM.js} +32 -32
  114. package/dist/bundle/chunks/openai-codex-responses-S7CMCAOY.js +101 -0
  115. package/dist/bundle/chunks/openai-completions-2Z57N7PC.js +87 -0
  116. package/dist/bundle/chunks/{openai-decisions-ALJROWBE.js → openai-decisions-JIOJDB4C.js} +1 -1
  117. package/dist/bundle/chunks/openai-responses-5VBZSTHL.js +27 -0
  118. package/dist/bundle/chunks/{openrouter-images-FCJT7C7I.js → openrouter-images-S6O7DBEJ.js} +1 -1
  119. package/dist/bundle/chunks/{pi-messages-NHTQQOPW.js → pi-messages-SMLN5J2W.js} +10 -7
  120. package/dist/bundle/chunks/runtime-OYTWXIUM.js +2 -0
  121. package/dist/bundle/chunks/session-picker-DM6S37IF.js +4 -0
  122. package/dist/bundle/chunks/startup-ui-4GGLWNSU.js +3 -0
  123. package/dist/bundle/chunks/trace-command-YLDYCL55.js +254 -0
  124. package/dist/bundle/chunks/typesafe-system-one-7BEL3H5N.js +3 -0
  125. package/dist/bundle/chunks/virtual-modules-TI3W24YL.js +28 -0
  126. package/dist/bundle/cli-runtime.js +5 -3
  127. package/dist/bundle/flow/agents/orch-implementation-fast.md +4 -4
  128. package/dist/bundle/flow/agents/orch-implementation-strong.md +5 -5
  129. package/dist/bundle/flow/package.json +35 -3
  130. package/dist/bundle/index.js +20 -17
  131. package/dist/bundle/orchestrate/README.md +37 -0
  132. package/dist/bundle/{flow → orchestrate}/agents/orch-qa-agent.md +1 -1
  133. package/dist/bundle/{flow → orchestrate}/agents/orch-worker.md +1 -1
  134. package/dist/bundle/{flow → orchestrate}/agents/orchestrator-lead.md +1 -1
  135. package/dist/bundle/orchestrate/package.json +29 -0
  136. package/dist/bundle/rpc-entry.js +5 -3
  137. package/dist/cli/args.d.ts +6 -0
  138. package/dist/cli/args.d.ts.map +1 -1
  139. package/dist/cli/args.js +69 -2
  140. package/dist/cli/args.js.map +1 -1
  141. package/dist/cli/auth-check.d.ts +3 -2
  142. package/dist/cli/auth-check.d.ts.map +1 -1
  143. package/dist/cli/auth-check.js +4 -3
  144. package/dist/cli/auth-check.js.map +1 -1
  145. package/dist/cli/config-selector.d.ts.map +1 -1
  146. package/dist/cli/config-selector.js +3 -1
  147. package/dist/cli/config-selector.js.map +1 -1
  148. package/dist/cli/file-processor.d.ts +2 -0
  149. package/dist/cli/file-processor.d.ts.map +1 -1
  150. package/dist/cli/file-processor.js +6 -6
  151. package/dist/cli/file-processor.js.map +1 -1
  152. package/dist/cli/metadata-disclosure.d.ts +4 -0
  153. package/dist/cli/metadata-disclosure.d.ts.map +1 -0
  154. package/dist/cli/metadata-disclosure.js +23 -0
  155. package/dist/cli/metadata-disclosure.js.map +1 -0
  156. package/dist/cli/project-trust.d.ts.map +1 -1
  157. package/dist/cli/project-trust.js +4 -1
  158. package/dist/cli/project-trust.js.map +1 -1
  159. package/dist/cli/session-picker.lazy.d.ts +3 -0
  160. package/dist/cli/session-picker.lazy.d.ts.map +1 -0
  161. package/dist/cli/session-picker.lazy.js +3 -0
  162. package/dist/cli/session-picker.lazy.js.map +1 -0
  163. package/dist/cli/startup-ui.d.ts +4 -4
  164. package/dist/cli/startup-ui.d.ts.map +1 -1
  165. package/dist/cli/startup-ui.js +38 -14
  166. package/dist/cli/startup-ui.js.map +1 -1
  167. package/dist/cli/startup-ui.lazy.d.ts +3 -0
  168. package/dist/cli/startup-ui.lazy.d.ts.map +1 -0
  169. package/dist/cli/startup-ui.lazy.js +3 -0
  170. package/dist/cli/startup-ui.lazy.js.map +1 -0
  171. package/dist/cli/trace-command.lazy.d.ts +3 -0
  172. package/dist/cli/trace-command.lazy.d.ts.map +1 -0
  173. package/dist/cli/trace-command.lazy.js +3 -0
  174. package/dist/cli/trace-command.lazy.js.map +1 -0
  175. package/dist/cli.js.map +1 -1
  176. package/dist/coordination/broker/entry.lazy.d.ts +3 -0
  177. package/dist/coordination/broker/entry.lazy.d.ts.map +1 -0
  178. package/dist/coordination/broker/entry.lazy.js +3 -0
  179. package/dist/coordination/broker/entry.lazy.js.map +1 -0
  180. package/dist/core/acceptance-command.d.ts +15 -0
  181. package/dist/core/acceptance-command.d.ts.map +1 -0
  182. package/dist/core/acceptance-command.js +150 -0
  183. package/dist/core/acceptance-command.js.map +1 -0
  184. package/dist/core/acceptance-ledger.d.ts +52 -0
  185. package/dist/core/acceptance-ledger.d.ts.map +1 -0
  186. package/dist/core/acceptance-ledger.js +341 -0
  187. package/dist/core/acceptance-ledger.js.map +1 -0
  188. package/dist/core/admission-types.d.ts +69 -0
  189. package/dist/core/admission-types.js +2 -0
  190. package/dist/core/admission-types.js.map +1 -0
  191. package/dist/core/agent-session-runtime.d.ts +7 -0
  192. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  193. package/dist/core/agent-session-runtime.js +43 -9
  194. package/dist/core/agent-session-runtime.js.map +1 -1
  195. package/dist/core/agent-session-services.d.ts +8 -0
  196. package/dist/core/agent-session-services.d.ts.map +1 -1
  197. package/dist/core/agent-session-services.js +13 -1
  198. package/dist/core/agent-session-services.js.map +1 -1
  199. package/dist/core/agent-session.d.ts +127 -10
  200. package/dist/core/agent-session.d.ts.map +1 -1
  201. package/dist/core/agent-session.js +1390 -145
  202. package/dist/core/agent-session.js.map +1 -1
  203. package/dist/core/anthropic-subscription-usage.d.ts +1 -1
  204. package/dist/core/anthropic-subscription-usage.d.ts.map +1 -1
  205. package/dist/core/anthropic-subscription-usage.js +31 -3
  206. package/dist/core/anthropic-subscription-usage.js.map +1 -1
  207. package/dist/core/auth-storage.d.ts +2 -1
  208. package/dist/core/auth-storage.d.ts.map +1 -1
  209. package/dist/core/auth-storage.js +13 -10
  210. package/dist/core/auth-storage.js.map +1 -1
  211. package/dist/core/auto-session-namer.d.ts.map +1 -1
  212. package/dist/core/auto-session-namer.js +3 -1
  213. package/dist/core/auto-session-namer.js.map +1 -1
  214. package/dist/core/bash-executor.d.ts.map +1 -1
  215. package/dist/core/bash-executor.js +3 -1
  216. package/dist/core/bash-executor.js.map +1 -1
  217. package/dist/core/bug-report-redaction.d.ts +4 -0
  218. package/dist/core/bug-report-redaction.d.ts.map +1 -0
  219. package/dist/core/bug-report-redaction.js +209 -0
  220. package/dist/core/bug-report-redaction.js.map +1 -0
  221. package/dist/core/bug-report.d.ts +26 -6
  222. package/dist/core/bug-report.d.ts.map +1 -1
  223. package/dist/core/bug-report.js +82 -9
  224. package/dist/core/bug-report.js.map +1 -1
  225. package/dist/core/cache-warmer.d.ts.map +1 -1
  226. package/dist/core/cache-warmer.js +5 -0
  227. package/dist/core/cache-warmer.js.map +1 -1
  228. package/dist/core/compaction/compaction.d.ts +6 -0
  229. package/dist/core/compaction/compaction.d.ts.map +1 -1
  230. package/dist/core/compaction/compaction.js +103 -71
  231. package/dist/core/compaction/compaction.js.map +1 -1
  232. package/dist/core/compaction/utils.d.ts.map +1 -1
  233. package/dist/core/compaction/utils.js +2 -1
  234. package/dist/core/compaction/utils.js.map +1 -1
  235. package/dist/core/extensions/jiti-bun-babel.d.ts +4 -0
  236. package/dist/core/extensions/jiti-bun-babel.d.ts.map +1 -0
  237. package/dist/core/extensions/jiti-bun-babel.js +4 -0
  238. package/dist/core/extensions/jiti-bun-babel.js.map +1 -0
  239. package/dist/core/extensions/jiti-bun-loader.d.ts +4 -0
  240. package/dist/core/extensions/jiti-bun-loader.d.ts.map +1 -0
  241. package/dist/core/extensions/jiti-bun-loader.js +13 -0
  242. package/dist/core/extensions/jiti-bun-loader.js.map +1 -0
  243. package/dist/core/extensions/jiti-bun-loader.lazy.d.ts +3 -0
  244. package/dist/core/extensions/jiti-bun-loader.lazy.d.ts.map +1 -0
  245. package/dist/core/extensions/jiti-bun-loader.lazy.js +3 -0
  246. package/dist/core/extensions/jiti-bun-loader.lazy.js.map +1 -0
  247. package/dist/core/extensions/loader.d.ts.map +1 -1
  248. package/dist/core/extensions/loader.js +9 -3
  249. package/dist/core/extensions/loader.js.map +1 -1
  250. package/dist/core/extensions/runner.d.ts.map +1 -1
  251. package/dist/core/extensions/runner.js +4 -0
  252. package/dist/core/extensions/runner.js.map +1 -1
  253. package/dist/core/extensions/types.d.ts +3 -0
  254. package/dist/core/extensions/types.d.ts.map +1 -1
  255. package/dist/core/extensions/types.js.map +1 -1
  256. package/dist/core/flow-implementer.d.ts +25 -0
  257. package/dist/core/flow-implementer.d.ts.map +1 -0
  258. package/dist/core/flow-implementer.js +301 -0
  259. package/dist/core/flow-implementer.js.map +1 -0
  260. package/dist/core/internal-process.d.ts +23 -0
  261. package/dist/core/internal-process.d.ts.map +1 -0
  262. package/dist/core/internal-process.js +88 -0
  263. package/dist/core/internal-process.js.map +1 -0
  264. package/dist/core/keybindings.d.ts +2 -2
  265. package/dist/core/keybindings.js +1 -1
  266. package/dist/core/keybindings.js.map +1 -1
  267. package/dist/core/model-config.d.ts +52 -0
  268. package/dist/core/model-config.d.ts.map +1 -1
  269. package/dist/core/model-config.js +4 -4
  270. package/dist/core/model-config.js.map +1 -1
  271. package/dist/core/model-registry.d.ts +4 -0
  272. package/dist/core/model-registry.d.ts.map +1 -1
  273. package/dist/core/model-registry.js +8 -0
  274. package/dist/core/model-registry.js.map +1 -1
  275. package/dist/core/model-request-admission.d.ts +51 -0
  276. package/dist/core/model-request-admission.d.ts.map +1 -0
  277. package/dist/core/model-request-admission.js +103 -0
  278. package/dist/core/model-request-admission.js.map +1 -0
  279. package/dist/core/model-resolver.d.ts +4 -0
  280. package/dist/core/model-resolver.d.ts.map +1 -1
  281. package/dist/core/model-resolver.js +109 -2
  282. package/dist/core/model-resolver.js.map +1 -1
  283. package/dist/core/model-runtime.d.ts +56 -1
  284. package/dist/core/model-runtime.d.ts.map +1 -1
  285. package/dist/core/model-runtime.js +482 -40
  286. package/dist/core/model-runtime.js.map +1 -1
  287. package/dist/core/model-selection-intent.d.ts +14 -0
  288. package/dist/core/model-selection-intent.d.ts.map +1 -0
  289. package/dist/core/model-selection-intent.js +15 -0
  290. package/dist/core/model-selection-intent.js.map +1 -0
  291. package/dist/core/oauth-account-pool.d.ts +4 -1
  292. package/dist/core/oauth-account-pool.d.ts.map +1 -1
  293. package/dist/core/oauth-account-pool.js +251 -228
  294. package/dist/core/oauth-account-pool.js.map +1 -1
  295. package/dist/core/os-secret-store.d.ts +25 -0
  296. package/dist/core/os-secret-store.d.ts.map +1 -0
  297. package/dist/core/os-secret-store.js +290 -0
  298. package/dist/core/os-secret-store.js.map +1 -0
  299. package/dist/core/output-guard.d.ts.map +1 -1
  300. package/dist/core/output-guard.js +62 -2
  301. package/dist/core/output-guard.js.map +1 -1
  302. package/dist/core/pi-ai-schemas.d.ts +4 -0
  303. package/dist/core/pi-ai-schemas.d.ts.map +1 -1
  304. package/dist/core/private-windows-path.d.ts +4 -0
  305. package/dist/core/private-windows-path.d.ts.map +1 -0
  306. package/dist/core/private-windows-path.js +44 -0
  307. package/dist/core/private-windows-path.js.map +1 -0
  308. package/dist/core/prompt-templates.d.ts.map +1 -1
  309. package/dist/core/prompt-templates.js +18 -2
  310. package/dist/core/prompt-templates.js.map +1 -1
  311. package/dist/core/provider-composer.d.ts.map +1 -1
  312. package/dist/core/provider-composer.js +1 -1
  313. package/dist/core/provider-composer.js.map +1 -1
  314. package/dist/core/resource-loader.d.ts.map +1 -1
  315. package/dist/core/resource-loader.js +6 -2
  316. package/dist/core/resource-loader.js.map +1 -1
  317. package/dist/core/run-outcome.d.ts +40 -0
  318. package/dist/core/run-outcome.d.ts.map +1 -0
  319. package/dist/core/run-outcome.js +91 -0
  320. package/dist/core/run-outcome.js.map +1 -0
  321. package/dist/core/run-preflight.d.ts +5 -0
  322. package/dist/core/run-preflight.d.ts.map +1 -0
  323. package/dist/core/run-preflight.js +96 -0
  324. package/dist/core/run-preflight.js.map +1 -0
  325. package/dist/core/runtime-credentials.d.ts +18 -2
  326. package/dist/core/runtime-credentials.d.ts.map +1 -1
  327. package/dist/core/runtime-credentials.js +65 -9
  328. package/dist/core/runtime-credentials.js.map +1 -1
  329. package/dist/core/sdk.d.ts +19 -3
  330. package/dist/core/sdk.d.ts.map +1 -1
  331. package/dist/core/sdk.js +115 -20
  332. package/dist/core/sdk.js.map +1 -1
  333. package/dist/core/settings-defaults.d.ts +2 -1
  334. package/dist/core/settings-defaults.d.ts.map +1 -1
  335. package/dist/core/settings-defaults.js +2 -1
  336. package/dist/core/settings-defaults.js.map +1 -1
  337. package/dist/core/settings-manager.d.ts +15 -4
  338. package/dist/core/settings-manager.d.ts.map +1 -1
  339. package/dist/core/settings-manager.js +114 -22
  340. package/dist/core/settings-manager.js.map +1 -1
  341. package/dist/core/settings-schema.d.ts +7 -2
  342. package/dist/core/settings-schema.d.ts.map +1 -1
  343. package/dist/core/settings-schema.js +12 -5
  344. package/dist/core/settings-schema.js.map +1 -1
  345. package/dist/core/skills.d.ts.map +1 -1
  346. package/dist/core/skills.js +11 -0
  347. package/dist/core/skills.js.map +1 -1
  348. package/dist/core/system-prompt.d.ts +3 -0
  349. package/dist/core/system-prompt.d.ts.map +1 -1
  350. package/dist/core/system-prompt.js +10 -2
  351. package/dist/core/system-prompt.js.map +1 -1
  352. package/dist/core/tools/bash-jobs.d.ts +109 -0
  353. package/dist/core/tools/bash-jobs.d.ts.map +1 -0
  354. package/dist/core/tools/bash-jobs.js +563 -0
  355. package/dist/core/tools/bash-jobs.js.map +1 -0
  356. package/dist/core/tools/bash.d.ts +68 -6
  357. package/dist/core/tools/bash.d.ts.map +1 -1
  358. package/dist/core/tools/bash.js +350 -37
  359. package/dist/core/tools/bash.js.map +1 -1
  360. package/dist/core/tools/edit-diff.d.ts +11 -1
  361. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  362. package/dist/core/tools/edit-diff.js +89 -20
  363. package/dist/core/tools/edit-diff.js.map +1 -1
  364. package/dist/core/tools/edit.d.ts.map +1 -1
  365. package/dist/core/tools/edit.js +15 -7
  366. package/dist/core/tools/edit.js.map +1 -1
  367. package/dist/core/tools/file-mutation-custody.d.ts +29 -0
  368. package/dist/core/tools/file-mutation-custody.d.ts.map +1 -0
  369. package/dist/core/tools/file-mutation-custody.js +173 -0
  370. package/dist/core/tools/file-mutation-custody.js.map +1 -0
  371. package/dist/core/tools/find.d.ts +6 -0
  372. package/dist/core/tools/find.d.ts.map +1 -1
  373. package/dist/core/tools/find.js +84 -38
  374. package/dist/core/tools/find.js.map +1 -1
  375. package/dist/core/tools/grep.d.ts +8 -2
  376. package/dist/core/tools/grep.d.ts.map +1 -1
  377. package/dist/core/tools/grep.js +121 -77
  378. package/dist/core/tools/grep.js.map +1 -1
  379. package/dist/core/tools/index.d.ts +3 -1
  380. package/dist/core/tools/index.d.ts.map +1 -1
  381. package/dist/core/tools/index.js +12 -0
  382. package/dist/core/tools/index.js.map +1 -1
  383. package/dist/core/tools/jobs.d.ts +24 -0
  384. package/dist/core/tools/jobs.d.ts.map +1 -0
  385. package/dist/core/tools/jobs.js +86 -0
  386. package/dist/core/tools/jobs.js.map +1 -0
  387. package/dist/core/tools/ls.d.ts.map +1 -1
  388. package/dist/core/tools/ls.js +2 -1
  389. package/dist/core/tools/ls.js.map +1 -1
  390. package/dist/core/tools/output-accumulator.d.ts +12 -1
  391. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  392. package/dist/core/tools/output-accumulator.js +88 -8
  393. package/dist/core/tools/output-accumulator.js.map +1 -1
  394. package/dist/core/tools/output-cleanup.d.ts +40 -0
  395. package/dist/core/tools/output-cleanup.d.ts.map +1 -0
  396. package/dist/core/tools/output-cleanup.js +273 -0
  397. package/dist/core/tools/output-cleanup.js.map +1 -0
  398. package/dist/core/tools/powershell.d.ts.map +1 -1
  399. package/dist/core/tools/powershell.js +15 -2
  400. package/dist/core/tools/powershell.js.map +1 -1
  401. package/dist/core/tools/read.d.ts +21 -0
  402. package/dist/core/tools/read.d.ts.map +1 -1
  403. package/dist/core/tools/read.js +162 -29
  404. package/dist/core/tools/read.js.map +1 -1
  405. package/dist/core/tools/renderers/bash.d.ts.map +1 -1
  406. package/dist/core/tools/renderers/bash.js +3 -1
  407. package/dist/core/tools/renderers/bash.js.map +1 -1
  408. package/dist/core/tools/renderers/index.d.ts.map +1 -1
  409. package/dist/core/tools/renderers/index.js +1 -0
  410. package/dist/core/tools/renderers/index.js.map +1 -1
  411. package/dist/core/tools/subagent.d.ts +5 -1
  412. package/dist/core/tools/subagent.d.ts.map +1 -1
  413. package/dist/core/tools/subagent.js +76 -19
  414. package/dist/core/tools/subagent.js.map +1 -1
  415. package/dist/core/tools/truncate.d.ts +4 -0
  416. package/dist/core/tools/truncate.d.ts.map +1 -1
  417. package/dist/core/tools/truncate.js +24 -1
  418. package/dist/core/tools/truncate.js.map +1 -1
  419. package/dist/core/tools/write.d.ts.map +1 -1
  420. package/dist/core/tools/write.js +6 -1
  421. package/dist/core/tools/write.js.map +1 -1
  422. package/dist/core/trace/config.js +3 -3
  423. package/dist/core/trace/config.js.map +1 -1
  424. package/dist/core/trace/redaction.d.ts.map +1 -1
  425. package/dist/core/trace/redaction.js +12 -9
  426. package/dist/core/trace/redaction.js.map +1 -1
  427. package/dist/core/trace-client/credential-store.d.ts +1 -1
  428. package/dist/core/trace-client/credential-store.d.ts.map +1 -1
  429. package/dist/core/trace-client/credential-store.js +20 -3
  430. package/dist/core/trace-client/credential-store.js.map +1 -1
  431. package/dist/core/usage-ledger.d.ts +35 -0
  432. package/dist/core/usage-ledger.d.ts.map +1 -0
  433. package/dist/core/usage-ledger.js +140 -0
  434. package/dist/core/usage-ledger.js.map +1 -0
  435. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  436. package/dist/extensions/codemode/execute.js +24 -15
  437. package/dist/extensions/codemode/execute.js.map +1 -1
  438. package/dist/extensions/codemode/index.d.ts +4 -2
  439. package/dist/extensions/codemode/index.d.ts.map +1 -1
  440. package/dist/extensions/codemode/index.js +8 -4
  441. package/dist/extensions/codemode/index.js.map +1 -1
  442. package/dist/extensions/codemode/tool.d.ts +4 -2
  443. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  444. package/dist/extensions/codemode/tool.js +34 -12
  445. package/dist/extensions/codemode/tool.js.map +1 -1
  446. package/dist/extensions/llama/client.d.ts +2 -0
  447. package/dist/extensions/llama/client.d.ts.map +1 -1
  448. package/dist/extensions/llama/client.js +23 -2
  449. package/dist/extensions/llama/client.js.map +1 -1
  450. package/dist/extensions/llama/ui.d.ts.map +1 -1
  451. package/dist/extensions/llama/ui.js +15 -3
  452. package/dist/extensions/llama/ui.js.map +1 -1
  453. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  454. package/dist/extensions/mcp/runtime.js +3 -2
  455. package/dist/extensions/mcp/runtime.js.map +1 -1
  456. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  457. package/dist/extensions/tool-search/tool.js +18 -6
  458. package/dist/extensions/tool-search/tool.js.map +1 -1
  459. package/dist/extensions/usage/hcode-overview.d.ts +23 -0
  460. package/dist/extensions/usage/hcode-overview.d.ts.map +1 -0
  461. package/dist/extensions/usage/hcode-overview.js +109 -0
  462. package/dist/extensions/usage/hcode-overview.js.map +1 -0
  463. package/dist/extensions/usage/index.d.ts +5 -0
  464. package/dist/extensions/usage/index.d.ts.map +1 -1
  465. package/dist/extensions/usage/index.js +194 -12
  466. package/dist/extensions/usage/index.js.map +1 -1
  467. package/dist/extensions/usage/overview.d.ts +5 -0
  468. package/dist/extensions/usage/overview.d.ts.map +1 -1
  469. package/dist/extensions/usage/overview.js +21 -1
  470. package/dist/extensions/usage/overview.js.map +1 -1
  471. package/dist/extensions/usage/popup.d.ts +14 -3
  472. package/dist/extensions/usage/popup.d.ts.map +1 -1
  473. package/dist/extensions/usage/popup.js +199 -25
  474. package/dist/extensions/usage/popup.js.map +1 -1
  475. package/dist/humain/adaptive-execution.d.ts +51 -0
  476. package/dist/humain/adaptive-execution.d.ts.map +1 -0
  477. package/dist/humain/adaptive-execution.js +100 -0
  478. package/dist/humain/adaptive-execution.js.map +1 -0
  479. package/dist/humain/adaptive-peer-process.d.ts +44 -0
  480. package/dist/humain/adaptive-peer-process.d.ts.map +1 -0
  481. package/dist/humain/adaptive-peer-process.js +159 -0
  482. package/dist/humain/adaptive-peer-process.js.map +1 -0
  483. package/dist/humain/adaptive-peer-worker.d.ts +3 -0
  484. package/dist/humain/adaptive-peer-worker.d.ts.map +1 -0
  485. package/dist/humain/adaptive-peer-worker.js +122 -0
  486. package/dist/humain/adaptive-peer-worker.js.map +1 -0
  487. package/dist/humain/adaptive-runtime-types.d.ts +621 -0
  488. package/dist/humain/adaptive-runtime-types.d.ts.map +1 -0
  489. package/dist/humain/adaptive-runtime-types.js +3 -0
  490. package/dist/humain/adaptive-runtime-types.js.map +1 -0
  491. package/dist/humain/adaptive-session-host.d.ts +113 -0
  492. package/dist/humain/adaptive-session-host.d.ts.map +1 -0
  493. package/dist/humain/adaptive-session-host.js +1838 -0
  494. package/dist/humain/adaptive-session-host.js.map +1 -0
  495. package/dist/humain/adhd/index.d.ts +2 -2
  496. package/dist/humain/adhd/index.d.ts.map +1 -1
  497. package/dist/humain/adhd/index.js +22 -13
  498. package/dist/humain/adhd/index.js.map +1 -1
  499. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +162 -49
  500. package/dist/humain/caveman/index.d.ts +1 -1
  501. package/dist/humain/caveman/index.d.ts.map +1 -1
  502. package/dist/humain/caveman/index.js +21 -12
  503. package/dist/humain/caveman/index.js.map +1 -1
  504. package/dist/humain/classify-tool.d.ts +4 -0
  505. package/dist/humain/classify-tool.d.ts.map +1 -0
  506. package/dist/humain/classify-tool.js +50 -0
  507. package/dist/humain/classify-tool.js.map +1 -0
  508. package/dist/humain/flow-command.d.ts +1 -1
  509. package/dist/humain/flow-command.d.ts.map +1 -1
  510. package/dist/humain/flow-command.js +21 -3
  511. package/dist/humain/flow-command.js.map +1 -1
  512. package/dist/humain/flow-loader.d.ts +15 -10
  513. package/dist/humain/flow-loader.d.ts.map +1 -1
  514. package/dist/humain/flow-loader.js +72 -18
  515. package/dist/humain/flow-loader.js.map +1 -1
  516. package/dist/humain/fuse-provider.d.ts +5 -0
  517. package/dist/humain/fuse-provider.d.ts.map +1 -0
  518. package/dist/humain/fuse-provider.js +302 -0
  519. package/dist/humain/fuse-provider.js.map +1 -0
  520. package/dist/humain/gateway/provider.d.ts.map +1 -1
  521. package/dist/humain/gateway/provider.js +2 -0
  522. package/dist/humain/gateway/provider.js.map +1 -1
  523. package/dist/humain/gateway/secret-store.d.ts +3 -7
  524. package/dist/humain/gateway/secret-store.d.ts.map +1 -1
  525. package/dist/humain/gateway/secret-store.js +21 -249
  526. package/dist/humain/gateway/secret-store.js.map +1 -1
  527. package/dist/humain/hcode/account-store.d.ts +92 -0
  528. package/dist/humain/hcode/account-store.d.ts.map +1 -0
  529. package/dist/humain/hcode/account-store.js +720 -0
  530. package/dist/humain/hcode/account-store.js.map +1 -0
  531. package/dist/humain/hcode/account.d.ts +42 -0
  532. package/dist/humain/hcode/account.d.ts.map +1 -0
  533. package/dist/humain/hcode/account.js +552 -0
  534. package/dist/humain/hcode/account.js.map +1 -0
  535. package/dist/humain/hcode/catalog.d.ts +6 -0
  536. package/dist/humain/hcode/catalog.d.ts.map +1 -0
  537. package/dist/humain/hcode/catalog.js +47 -0
  538. package/dist/humain/hcode/catalog.js.map +1 -0
  539. package/dist/humain/hcode/contracts.d.ts +389 -0
  540. package/dist/humain/hcode/contracts.d.ts.map +1 -0
  541. package/dist/humain/hcode/contracts.js +1243 -0
  542. package/dist/humain/hcode/contracts.js.map +1 -0
  543. package/dist/humain/hcode/environment.d.ts +9 -0
  544. package/dist/humain/hcode/environment.d.ts.map +1 -0
  545. package/dist/humain/hcode/environment.js +24 -0
  546. package/dist/humain/hcode/environment.js.map +1 -0
  547. package/dist/humain/hcode/facade.d.ts +54 -0
  548. package/dist/humain/hcode/facade.d.ts.map +1 -0
  549. package/dist/humain/hcode/facade.js +326 -0
  550. package/dist/humain/hcode/facade.js.map +1 -0
  551. package/dist/humain/hcode/http.d.ts +10 -0
  552. package/dist/humain/hcode/http.d.ts.map +1 -0
  553. package/dist/humain/hcode/http.js +119 -0
  554. package/dist/humain/hcode/http.js.map +1 -0
  555. package/dist/humain/hcode/notices.d.ts +15 -0
  556. package/dist/humain/hcode/notices.d.ts.map +1 -0
  557. package/dist/humain/hcode/notices.js +69 -0
  558. package/dist/humain/hcode/notices.js.map +1 -0
  559. package/dist/humain/hcode/ports.d.ts +34 -0
  560. package/dist/humain/hcode/ports.d.ts.map +1 -0
  561. package/dist/humain/hcode/ports.js +2 -0
  562. package/dist/humain/hcode/ports.js.map +1 -0
  563. package/dist/humain/hcode/provider.d.ts +15 -0
  564. package/dist/humain/hcode/provider.d.ts.map +1 -0
  565. package/dist/humain/hcode/provider.js +200 -0
  566. package/dist/humain/hcode/provider.js.map +1 -0
  567. package/dist/humain/hcode/selection.d.ts +16 -0
  568. package/dist/humain/hcode/selection.d.ts.map +1 -0
  569. package/dist/humain/hcode/selection.js +37 -0
  570. package/dist/humain/hcode/selection.js.map +1 -0
  571. package/dist/humain/hcode/transport.d.ts +22 -0
  572. package/dist/humain/hcode/transport.d.ts.map +1 -0
  573. package/dist/humain/hcode/transport.js +368 -0
  574. package/dist/humain/hcode/transport.js.map +1 -0
  575. package/dist/humain/hcode/usage.d.ts +5 -0
  576. package/dist/humain/hcode/usage.d.ts.map +1 -0
  577. package/dist/humain/hcode/usage.js +66 -0
  578. package/dist/humain/hcode/usage.js.map +1 -0
  579. package/dist/humain/hcode/wire.d.ts +16 -0
  580. package/dist/humain/hcode/wire.d.ts.map +1 -0
  581. package/dist/humain/hcode/wire.js +104 -0
  582. package/dist/humain/hcode/wire.js.map +1 -0
  583. package/dist/humain/index.d.ts +1 -3
  584. package/dist/humain/index.d.ts.map +1 -1
  585. package/dist/humain/index.js +8 -60
  586. package/dist/humain/index.js.map +1 -1
  587. package/dist/humain/login-menu.d.ts.map +1 -1
  588. package/dist/humain/login-menu.js +8 -1
  589. package/dist/humain/login-menu.js.map +1 -1
  590. package/dist/humain/metadata/contracts.d.ts +82 -0
  591. package/dist/humain/metadata/contracts.d.ts.map +1 -0
  592. package/dist/humain/metadata/contracts.js +214 -0
  593. package/dist/humain/metadata/contracts.js.map +1 -0
  594. package/dist/humain/metadata/identity.d.ts +10 -0
  595. package/dist/humain/metadata/identity.d.ts.map +1 -0
  596. package/dist/humain/metadata/identity.js +209 -0
  597. package/dist/humain/metadata/identity.js.map +1 -0
  598. package/dist/humain/metadata/index.d.ts +41 -0
  599. package/dist/humain/metadata/index.d.ts.map +1 -0
  600. package/dist/humain/metadata/index.js +100 -0
  601. package/dist/humain/metadata/index.js.map +1 -0
  602. package/dist/humain/metadata/sender.d.ts +20 -0
  603. package/dist/humain/metadata/sender.d.ts.map +1 -0
  604. package/dist/humain/metadata/sender.js +302 -0
  605. package/dist/humain/metadata/sender.js.map +1 -0
  606. package/dist/humain/metadata/version.d.ts +8 -0
  607. package/dist/humain/metadata/version.d.ts.map +1 -0
  608. package/dist/humain/metadata/version.js +38 -0
  609. package/dist/humain/metadata/version.js.map +1 -0
  610. package/dist/humain/node-http.d.ts +2 -0
  611. package/dist/humain/node-http.d.ts.map +1 -1
  612. package/dist/humain/node-http.js +9 -4
  613. package/dist/humain/node-http.js.map +1 -1
  614. package/dist/humain/node-provider.d.ts +2 -0
  615. package/dist/humain/node-provider.d.ts.map +1 -1
  616. package/dist/humain/node-provider.js +39 -8
  617. package/dist/humain/node-provider.js.map +1 -1
  618. package/dist/humain/ponytail/vendor/hooks/ponytail-config.d.ts +1 -1
  619. package/dist/humain/ponytail/vendor/hooks/ponytail-config.d.ts.map +1 -1
  620. package/dist/humain/ponytail/vendor/hooks/ponytail-config.js +4 -4
  621. package/dist/humain/ponytail/vendor/hooks/ponytail-config.js.map +1 -1
  622. package/dist/humain/ponytail/vendor/hooks/ponytail-instructions.d.ts.map +1 -1
  623. package/dist/humain/ponytail/vendor/hooks/ponytail-instructions.js +7 -0
  624. package/dist/humain/ponytail/vendor/hooks/ponytail-instructions.js.map +1 -1
  625. package/dist/humain/ponytail/vendor/pi-extension/index.d.ts.map +1 -1
  626. package/dist/humain/ponytail/vendor/pi-extension/index.js +12 -1
  627. package/dist/humain/ponytail/vendor/pi-extension/index.js.map +1 -1
  628. package/dist/humain/systemone.d.ts +23 -0
  629. package/dist/humain/systemone.d.ts.map +1 -0
  630. package/dist/humain/systemone.js +101 -0
  631. package/dist/humain/systemone.js.map +1 -0
  632. package/dist/humain/trace-capture/flow-producer.d.ts.map +1 -1
  633. package/dist/humain/trace-capture/flow-producer.js +3 -3
  634. package/dist/humain/trace-capture/flow-producer.js.map +1 -1
  635. package/dist/index.d.ts +4 -2
  636. package/dist/index.d.ts.map +1 -1
  637. package/dist/index.js.map +1 -1
  638. package/dist/main.d.ts +1 -0
  639. package/dist/main.d.ts.map +1 -1
  640. package/dist/main.js +292 -183
  641. package/dist/main.js.map +1 -1
  642. package/dist/modes/interactive/bug-report.d.ts.map +1 -1
  643. package/dist/modes/interactive/bug-report.js +82 -36
  644. package/dist/modes/interactive/bug-report.js.map +1 -1
  645. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  646. package/dist/modes/interactive/components/assistant-message.js +8 -5
  647. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  648. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  649. package/dist/modes/interactive/components/diff.js +11 -5
  650. package/dist/modes/interactive/components/diff.js.map +1 -1
  651. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  652. package/dist/modes/interactive/components/extension-selector.js +9 -1
  653. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  654. package/dist/modes/interactive/components/first-time-setup.d.ts +10 -5
  655. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  656. package/dist/modes/interactive/components/first-time-setup.js +55 -29
  657. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  658. package/dist/modes/interactive/components/model-selector.d.ts +16 -2
  659. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  660. package/dist/modes/interactive/components/model-selector.js +164 -19
  661. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  662. package/dist/modes/interactive/components/oauth-selector.d.ts +3 -0
  663. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  664. package/dist/modes/interactive/components/oauth-selector.js +19 -2
  665. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  666. package/dist/modes/interactive/components/status-indicator.d.ts +17 -0
  667. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  668. package/dist/modes/interactive/components/status-indicator.js +78 -1
  669. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  670. package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
  671. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  672. package/dist/modes/interactive/components/tree-selector.js +19 -10
  673. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  674. package/dist/modes/interactive/interactive-mode.d.ts +4 -0
  675. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  676. package/dist/modes/interactive/interactive-mode.js +353 -65
  677. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  678. package/dist/modes/interactive/interactive-mode.lazy.d.ts +3 -0
  679. package/dist/modes/interactive/interactive-mode.lazy.d.ts.map +1 -0
  680. package/dist/modes/interactive/interactive-mode.lazy.js +3 -0
  681. package/dist/modes/interactive/interactive-mode.lazy.js.map +1 -0
  682. package/dist/modes/interactive/model-catalog-refresh.d.ts +2 -0
  683. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -1
  684. package/dist/modes/interactive/model-catalog-refresh.js +12 -0
  685. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -1
  686. package/dist/modes/interactive/theme/theme-controller.d.ts +2 -3
  687. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  688. package/dist/modes/interactive/theme/theme-controller.js +4 -5
  689. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  690. package/dist/modes/interactive/theme/theme-schema.js +4 -4
  691. package/dist/modes/interactive/theme/theme-schema.js.map +1 -1
  692. package/dist/modes/interactive/theme/theme.d.ts +2 -0
  693. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  694. package/dist/modes/interactive/theme/theme.js +8 -0
  695. package/dist/modes/interactive/theme/theme.js.map +1 -1
  696. package/dist/modes/json-event.d.ts +2 -1
  697. package/dist/modes/json-event.d.ts.map +1 -1
  698. package/dist/modes/json-event.js.map +1 -1
  699. package/dist/modes/print-mode.d.ts +4 -0
  700. package/dist/modes/print-mode.d.ts.map +1 -1
  701. package/dist/modes/print-mode.js +57 -11
  702. package/dist/modes/print-mode.js.map +1 -1
  703. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  704. package/dist/modes/rpc/rpc-mode.js +68 -16
  705. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  706. package/dist/modes/rpc/rpc-types.d.ts +2 -0
  707. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  708. package/dist/modes/rpc/rpc-types.js.map +1 -1
  709. package/dist/utils/changelog.d.ts +1 -1
  710. package/dist/utils/changelog.d.ts.map +1 -1
  711. package/dist/utils/changelog.js +7 -5
  712. package/dist/utils/changelog.js.map +1 -1
  713. package/dist/utils/image-resize.d.ts.map +1 -1
  714. package/dist/utils/image-resize.js +3 -1
  715. package/dist/utils/image-resize.js.map +1 -1
  716. package/dist/utils/lazy-validator.d.ts +5 -0
  717. package/dist/utils/lazy-validator.d.ts.map +1 -0
  718. package/dist/utils/lazy-validator.js +7 -0
  719. package/dist/utils/lazy-validator.js.map +1 -0
  720. package/dist/utils/shell.d.ts +3 -1
  721. package/dist/utils/shell.d.ts.map +1 -1
  722. package/dist/utils/shell.js +9 -4
  723. package/dist/utils/shell.js.map +1 -1
  724. package/docs/cli.md +23 -5
  725. package/docs/codemode.md +21 -1
  726. package/docs/development.md +18 -0
  727. package/docs/docs.json +4 -0
  728. package/docs/extensions.md +4 -0
  729. package/docs/flow.md +115 -16
  730. package/docs/headless-modes.md +61 -0
  731. package/docs/humain-code-forge-architecture.md +65 -13
  732. package/docs/humain-code-forge-component-scorecard.md +10 -1
  733. package/docs/humain-code-forge-flow-walkthrough.md +54 -55
  734. package/docs/humain-code.md +22 -19
  735. package/docs/index.md +1 -0
  736. package/docs/keybindings.md +1 -1
  737. package/docs/models-configuration.md +6 -1
  738. package/docs/models.md +1 -1
  739. package/docs/prompt-templates.md +1 -1
  740. package/docs/providers.md +67 -15
  741. package/docs/run-preflight.md +47 -0
  742. package/docs/sdk.md +39 -1
  743. package/docs/security.md +1 -1
  744. package/docs/settings.md +12 -5
  745. package/docs/skills.md +2 -0
  746. package/docs/slash-commands.md +5 -3
  747. package/docs/usage.md +29 -0
  748. package/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
  749. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  750. package/examples/tsconfig.json +13 -0
  751. package/npm-shrinkwrap.json +67 -67
  752. package/package.json +25 -19
  753. package/schemas/models.schema.json +30 -0
  754. package/schemas/settings.schema.json +28 -9
  755. package/src/humain/caveman/UPSTREAM.md +19 -3
  756. package/src/humain/caveman/upstream.json +2 -2
  757. package/src/humain/ponytail/UPSTREAM.md +16 -1
  758. package/src/humain/web-access/UPSTREAM.md +10 -0
  759. package/src/humain/web-access/upstream.json +1 -0
  760. package/dist/bundle/chunks/anthropic-messages-MNISFDZA.js +0 -66
  761. package/dist/bundle/chunks/chunk-2HZ2V3HS.js +0 -1985
  762. package/dist/bundle/chunks/chunk-2PZ46FSM.js +0 -6
  763. package/dist/bundle/chunks/chunk-4SQUP6IR.js +0 -88
  764. package/dist/bundle/chunks/chunk-5JSLXC2A.js +0 -3
  765. package/dist/bundle/chunks/chunk-75CQYZ63.js +0 -1336
  766. package/dist/bundle/chunks/chunk-DCPACGLH.js +0 -12267
  767. package/dist/bundle/chunks/chunk-FLVBQ6GS.js +0 -24
  768. package/dist/bundle/chunks/chunk-H7Y4QY7K.js +0 -11
  769. package/dist/bundle/chunks/chunk-JEAM6N22.js +0 -139
  770. package/dist/bundle/chunks/chunk-PS2FJ7M4.js +0 -23
  771. package/dist/bundle/chunks/chunk-TEOMXMW6.js +0 -23
  772. package/dist/bundle/chunks/chunk-WEFEQEIQ.js +0 -28
  773. package/dist/bundle/chunks/chunk-WW4SILXG.js +0 -249
  774. package/dist/bundle/chunks/compat-MXAZPYDN.js +0 -13
  775. package/dist/bundle/chunks/dist-3V7ZSLER.js +0 -3166
  776. package/dist/bundle/chunks/dist-66CW64M2.js +0 -8
  777. package/dist/bundle/chunks/host-SCZ4IKWR.js +0 -2
  778. package/dist/bundle/chunks/openai-codex-responses-LZWBQYVP.js +0 -101
  779. package/dist/bundle/chunks/openai-completions-7NWH423P.js +0 -82
  780. package/dist/bundle/chunks/openai-responses-5YOLHMCF.js +0 -27
  781. package/dist/bundle/chunks/runtime-UVPDE4CX.js +0 -2
  782. package/dist/bundle/chunks/typesafe-system-one-BHJYAZ6E.js +0 -3
  783. package/dist/bundle/chunks/virtual-modules-YQPK57CW.js +0 -23
  784. package/dist/humain/legacy-workflow-tiers.d.ts +0 -3
  785. package/dist/humain/legacy-workflow-tiers.d.ts.map +0 -1
  786. package/dist/humain/legacy-workflow-tiers.js +0 -46
  787. package/dist/humain/legacy-workflow-tiers.js.map +0 -1
  788. /package/dist/bundle/{flow → orchestrate}/agents/orch-architect.md +0 -0
  789. /package/dist/bundle/{flow → orchestrate}/agents/orch-scout.md +0 -0
  790. /package/dist/bundle/{flow → orchestrate}/agents/orch-security-review.md +0 -0
  791. /package/dist/bundle/{flow → orchestrate}/agents/orch-technical-lead.md +0 -0
  792. /package/dist/bundle/{flow → orchestrate}/agents/orch-technical-review.md +0 -0
@@ -0,0 +1,1243 @@
1
+ import * as wire from "./wire.js";
2
+ /** Complete SSE envelope: retained UTF-8 content/signatures may expand sixfold in JSON. */
3
+ export const MAX_PI_EVENT_FRAME_BYTES = 54525952;
4
+ export { parseCliDeliveryResult, parseCliMetadataBatch } from "../metadata/contracts.js";
5
+ export const HCODE_ERROR_STATUS = {
6
+ unauthorized: new Set([401]),
7
+ forbidden: new Set([403]),
8
+ legal_acknowledgment_required: new Set([403]),
9
+ auth_dependency_unavailable: new Set([503]),
10
+ hcode_unavailable: new Set([503]),
11
+ invalid_request: new Set([400, 413, 415]),
12
+ unsupported_capability: new Set([422]),
13
+ model_unavailable: new Set([409]),
14
+ hcode_busy: new Set([429]),
15
+ quota_exceeded: new Set([429]),
16
+ idempotency_conflict: new Set([409]),
17
+ request_in_progress: new Set([409]),
18
+ outcome_unknown: new Set([409]),
19
+ upstream_unavailable: new Set([502]),
20
+ settlement_unavailable: new Set([503]),
21
+ };
22
+ function source(value) {
23
+ return wire.member(value, ["forge_web", "cli", "legacy_unknown"]);
24
+ }
25
+ /** Parse trusted-origin discovery data before the account owner qualifies the issuer. */
26
+ export function parseHcodeCliConfig(value) {
27
+ const v = wire.object(value, ["schemaVersion", "environmentId", "origin", "inferenceBaseUrl", "auth"]);
28
+ const auth = wire.object(v.auth, [
29
+ "kind",
30
+ "issuer",
31
+ "clientId",
32
+ "audience",
33
+ "scopes",
34
+ "qualification",
35
+ "maxAccessTokenSeconds",
36
+ "deviceAuthorizationEndpoint",
37
+ "tokenEndpoint",
38
+ "revocationEndpoint",
39
+ "verificationUri",
40
+ "revocation",
41
+ ]);
42
+ const origin = wire.member(v.origin, [
43
+ "https://code.dev.humain.com",
44
+ "https://code.stg.humain.com",
45
+ "https://code.humain.com",
46
+ ]);
47
+ const inferenceBaseUrl = wire.https(v.inferenceBaseUrl);
48
+ if (inferenceBaseUrl !== `${origin}/api/inference`)
49
+ return wire.invalid();
50
+ const scopes = wire.array(auth.scopes, (entry) => {
51
+ const scope = wire.string(entry, 128);
52
+ if (!/^[\x21\x23-\x5b\x5d-\x7e]+$/.test(scope))
53
+ return wire.invalid();
54
+ return scope;
55
+ }, 32, 1);
56
+ if (wire.https(auth.issuer).endsWith("/"))
57
+ return wire.invalid();
58
+ if (new Set(scopes).size !== scopes.length)
59
+ return wire.invalid();
60
+ return {
61
+ schemaVersion: wire.literal(v.schemaVersion, 1),
62
+ environmentId: wire.string(v.environmentId),
63
+ origin,
64
+ inferenceBaseUrl,
65
+ auth: {
66
+ kind: wire.literal(auth.kind, "oidc-device"),
67
+ qualification: wire.literal(auth.qualification, "owner-qualified-native-device"),
68
+ maxAccessTokenSeconds: wire.integer(auth.maxAccessTokenSeconds, 86400, 1),
69
+ deviceAuthorizationEndpoint: wire.https(auth.deviceAuthorizationEndpoint),
70
+ tokenEndpoint: wire.https(auth.tokenEndpoint),
71
+ revocationEndpoint: wire.https(auth.revocationEndpoint),
72
+ verificationUri: wire.https(auth.verificationUri),
73
+ revocation: wire.literal(auth.revocation, "isolated-device-family"),
74
+ issuer: wire.https(auth.issuer),
75
+ clientId: wire.string(auth.clientId),
76
+ audience: wire.string(auth.audience),
77
+ scopes,
78
+ },
79
+ };
80
+ }
81
+ export function parseHcodeAccount(value) {
82
+ const v = wire.object(value, [
83
+ "schemaVersion",
84
+ "accountId",
85
+ "environmentId",
86
+ "displayName",
87
+ "email",
88
+ "role",
89
+ "eligibility",
90
+ ]);
91
+ const eligibility = wire.object(v.eligibility, ["kind"]);
92
+ const email = wire.nullable(v.email, (entry) => wire.string(entry, 320));
93
+ if (email !== null &&
94
+ !/^(?:[A-Za-z0-9_'+-]+\.)*[A-Za-z0-9_'+-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/.test(email))
95
+ return wire.invalid();
96
+ return {
97
+ schemaVersion: wire.literal(v.schemaVersion, 1),
98
+ accountId: wire.string(v.accountId),
99
+ environmentId: wire.string(v.environmentId),
100
+ displayName: wire.nullable(v.displayName, (entry) => wire.string(entry, 256, 0)),
101
+ email,
102
+ role: wire.member(v.role, ["user", "admin"]),
103
+ eligibility: { kind: wire.literal(eligibility.kind, "eligible") },
104
+ };
105
+ }
106
+ function parseValue(value) {
107
+ const v = wire.object(value, ["kind", "value"]);
108
+ if (v.kind === "known")
109
+ return { kind: "known", value: wire.integer(v.value) };
110
+ wire.object(value, ["kind"]);
111
+ return { kind: wire.member(v.kind, ["unknown", "redacted", "unavailable"]) };
112
+ }
113
+ function parseTokens(value, max = 2147483647) {
114
+ const v = wire.object(value, ["input", "output", "cacheRead", "cacheWrite", "total"]);
115
+ const result = {
116
+ input: parseValue(v.input),
117
+ output: parseValue(v.output),
118
+ cacheRead: parseValue(v.cacheRead),
119
+ cacheWrite: parseValue(v.cacheWrite),
120
+ total: parseValue(v.total),
121
+ };
122
+ for (const token of Object.values(result))
123
+ if (token.kind === "known")
124
+ wire.integer(token.value, max);
125
+ if (result.input.kind === "known") {
126
+ if (result.output.kind === "known" &&
127
+ result.total.kind === "known" &&
128
+ (!Number.isSafeInteger(result.input.value + result.output.value) ||
129
+ result.total.value !== result.input.value + result.output.value))
130
+ return wire.invalid();
131
+ if ((result.cacheRead.kind === "known" ? result.cacheRead.value : 0) +
132
+ (result.cacheWrite.kind === "known" ? result.cacheWrite.value : 0) >
133
+ result.input.value)
134
+ return wire.invalid();
135
+ }
136
+ return result;
137
+ }
138
+ function parseAllowance(value) {
139
+ const v = wire.object(value, ["kind", "limitMicrocents"]);
140
+ if (v.kind === "limited")
141
+ return { kind: "limited", limitMicrocents: wire.integer(v.limitMicrocents) };
142
+ wire.object(value, ["kind"]);
143
+ return { kind: wire.literal(v.kind, "unlimited") };
144
+ }
145
+ function parseUsageSource(value) {
146
+ const v = wire.object(value, ["surface", "actual", "reserved", "tokens"]);
147
+ return {
148
+ surface: source(v.surface),
149
+ actual: parseValue(v.actual),
150
+ reserved: parseValue(v.reserved),
151
+ tokens: parseTokens(v.tokens, Number.MAX_SAFE_INTEGER),
152
+ };
153
+ }
154
+ function parseUsageItem(value) {
155
+ const v = wire.object(value, [
156
+ "id",
157
+ "at",
158
+ "surface",
159
+ "source",
160
+ "capability",
161
+ "operation",
162
+ "provider",
163
+ "model",
164
+ "status",
165
+ "outcome",
166
+ "cost",
167
+ "hold",
168
+ "tokens",
169
+ "complete",
170
+ ]);
171
+ return {
172
+ id: wire.string(v.id),
173
+ at: wire.time(v.at),
174
+ surface: source(v.surface),
175
+ source: wire.member(v.source, ["run", "utility"]),
176
+ capability: wire.string(v.capability),
177
+ operation: wire.string(v.operation),
178
+ provider: wire.nullable(v.provider, wire.string),
179
+ model: wire.nullable(v.model, wire.string),
180
+ status: wire.member(v.status, ["reserved", "succeeded", "failed", "blocked"]),
181
+ outcome: wire.member(v.outcome, ["pending", "succeeded", "failed", "cancelled", "unknown"]),
182
+ cost: parseValue(v.cost),
183
+ hold: parseValue(v.hold),
184
+ tokens: parseTokens(v.tokens),
185
+ complete: wire.boolean(v.complete),
186
+ };
187
+ }
188
+ export function parseHcodeUsage(value) {
189
+ const v = wire.object(value, [
190
+ "schemaVersion",
191
+ "accountId",
192
+ "environmentId",
193
+ "asOf",
194
+ "freshness",
195
+ "period",
196
+ "currency",
197
+ "unit",
198
+ "allowance",
199
+ "allowanceSource",
200
+ "actual",
201
+ "reserved",
202
+ "committed",
203
+ "remaining",
204
+ "costComplete",
205
+ "unsettledCount",
206
+ "unknownCostCount",
207
+ "tokens",
208
+ "sources",
209
+ "items",
210
+ "nextCursor",
211
+ ]);
212
+ const snapshot = parseAllowanceSnapshot(Object.fromEntries(snapshotFields.map((field) => [field, v[field]])));
213
+ const sources = wire.array(v.sources, parseUsageSource, 3);
214
+ if (new Set(sources.map((entry) => entry.surface)).size !== sources.length)
215
+ return wire.invalid();
216
+ return {
217
+ schemaVersion: wire.literal(v.schemaVersion, 1),
218
+ accountId: wire.string(v.accountId),
219
+ environmentId: wire.string(v.environmentId),
220
+ ...snapshot,
221
+ freshness: wire.member(v.freshness, ["current", "stale"]),
222
+ allowanceSource: wire.member(v.allowanceSource, ["global", "override"]),
223
+ unsettledCount: wire.integer(v.unsettledCount),
224
+ unknownCostCount: wire.integer(v.unknownCostCount),
225
+ tokens: parseTokens(v.tokens, Number.MAX_SAFE_INTEGER),
226
+ sources,
227
+ items: wire.array(v.items, parseUsageItem, 50),
228
+ nextCursor: wire.nullable(v.nextCursor, (entry) => wire.string(entry, 2048)),
229
+ };
230
+ }
231
+ export function parseHcodeUsageQuery(value) {
232
+ const v = wire.query(value);
233
+ let limit = v.limit;
234
+ if (typeof limit === "string" && /^[1-9][0-9]*$/.test(limit))
235
+ limit = Number(limit);
236
+ return {
237
+ ...(v.surface === undefined ? {} : { surface: source(v.surface) }),
238
+ ...(v.cursor === undefined ? {} : { cursor: wire.string(v.cursor, 2048) }),
239
+ limit: limit === undefined ? 20 : wire.integer(limit, 50, 1),
240
+ };
241
+ }
242
+ const efforts = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
243
+ const bytes = (value) => new TextEncoder().encode(value).length;
244
+ function scalar(value, max = 1048576, min = 0) {
245
+ const text = wire.string(value, max, min);
246
+ if (bytes(text) > max || /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(text))
247
+ return wire.invalid();
248
+ return text;
249
+ }
250
+ function ascii(value, max = 256) {
251
+ const text = scalar(value, max, 1);
252
+ if (!/^[\x20-\x7e]+$/.test(text))
253
+ return wire.invalid();
254
+ return text;
255
+ }
256
+ function toolName(value) {
257
+ const text = scalar(value, 64, 1);
258
+ if (!/^[A-Za-z0-9_-]+$/.test(text))
259
+ return wire.invalid();
260
+ return text;
261
+ }
262
+ function boundedJson(value, maxDepth = 32, maxNodes = 8192) {
263
+ let nodes = 0;
264
+ const ancestors = new Set();
265
+ function visit(entry, depth) {
266
+ if (++nodes > maxNodes || depth > maxDepth)
267
+ return wire.invalid();
268
+ if (entry === null || typeof entry === "boolean")
269
+ return entry;
270
+ if (typeof entry === "number")
271
+ return wire.number(entry, -Number.MAX_VALUE);
272
+ if (typeof entry === "string")
273
+ return scalar(entry, 12582912);
274
+ if (typeof entry !== "object" || ancestors.has(entry))
275
+ return wire.invalid();
276
+ ancestors.add(entry);
277
+ if (Object.getOwnPropertySymbols(entry).length)
278
+ return wire.invalid();
279
+ let result;
280
+ if (Array.isArray(entry)) {
281
+ if (Object.keys(entry).length !== entry.length)
282
+ return wire.invalid();
283
+ result = Array.from({ length: entry.length }, (_, index) => {
284
+ const descriptor = Object.getOwnPropertyDescriptor(entry, String(index));
285
+ if (!descriptor || !("value" in descriptor))
286
+ return wire.invalid();
287
+ return visit(descriptor.value, depth + 1);
288
+ });
289
+ }
290
+ else {
291
+ const v = wire.object(entry, Object.keys(entry));
292
+ const out = {};
293
+ for (const key of Object.keys(v)) {
294
+ scalar(key, 1048576);
295
+ if (["__proto__", "constructor", "prototype"].includes(key))
296
+ return wire.invalid();
297
+ const descriptor = Object.getOwnPropertyDescriptor(v, key);
298
+ if (!descriptor || !("value" in descriptor))
299
+ return wire.invalid();
300
+ out[key] = visit(descriptor.value, depth + 1);
301
+ }
302
+ result = out;
303
+ }
304
+ ancestors.delete(entry);
305
+ return result;
306
+ }
307
+ return visit(value, 0);
308
+ }
309
+ function jsonObject(value, maxBytes) {
310
+ const parsed = boundedJson(value);
311
+ wire.object(parsed, parsed !== null && typeof parsed === "object" ? Object.keys(parsed) : []);
312
+ if (wire.jsonBytes(parsed) > maxBytes)
313
+ return wire.invalid();
314
+ return parsed;
315
+ }
316
+ function jsonSchema(value) {
317
+ const parsed = jsonObject(value, 131072);
318
+ function refs(entry, position) {
319
+ if (entry === null || typeof entry !== "object")
320
+ return;
321
+ if (Array.isArray(entry)) {
322
+ for (const child of entry)
323
+ refs(child, position === "array" ? "schema" : "data");
324
+ return;
325
+ }
326
+ for (const [key, child] of Object.entries(entry)) {
327
+ let next = "data";
328
+ if (position === "map")
329
+ next = "schema";
330
+ if (position === "schema") {
331
+ if (["$ref", "$dynamicRef", "$recursiveRef", "$id"].includes(key) &&
332
+ (typeof child !== "string" || !child.startsWith("#")))
333
+ wire.invalid();
334
+ if (["properties", "patternProperties", "$defs", "definitions", "dependentSchemas", "dependencies"].includes(key))
335
+ next = "map";
336
+ else if (["allOf", "anyOf", "oneOf", "prefixItems"].includes(key) ||
337
+ (key === "items" && Array.isArray(child)))
338
+ next = "array";
339
+ else if ([
340
+ "additionalProperties",
341
+ "unevaluatedProperties",
342
+ "propertyNames",
343
+ "contains",
344
+ "additionalItems",
345
+ "unevaluatedItems",
346
+ "items",
347
+ "not",
348
+ "if",
349
+ "then",
350
+ "else",
351
+ "contentSchema",
352
+ ].includes(key))
353
+ next = "schema";
354
+ }
355
+ refs(child, next);
356
+ }
357
+ }
358
+ refs(parsed, "schema");
359
+ return parsed;
360
+ }
361
+ function rates(value, tier = false) {
362
+ const v = wire.object(value, ["input", "output", "cacheRead", "cacheWrite", ...(tier ? ["inputTokensAbove"] : [])]);
363
+ return {
364
+ input: wire.number(v.input),
365
+ output: wire.number(v.output),
366
+ cacheRead: wire.number(v.cacheRead),
367
+ cacheWrite: wire.number(v.cacheWrite),
368
+ ...(tier ? { inputTokensAbove: wire.integer(v.inputTokensAbove) } : {}),
369
+ };
370
+ }
371
+ function parseModel(value) {
372
+ const v = wire.object(value, [
373
+ "id",
374
+ "name",
375
+ "api",
376
+ "provider",
377
+ "baseUrl",
378
+ "type",
379
+ "tools",
380
+ "reasoning",
381
+ "input",
382
+ "contextWindow",
383
+ "maxTokens",
384
+ "cost",
385
+ "thinkingLevelMap",
386
+ "inputLimits",
387
+ ]);
388
+ const contextWindow = wire.integer(v.contextWindow, Number.MAX_SAFE_INTEGER, 1), maxTokens = wire.integer(v.maxTokens, contextWindow, 1);
389
+ const input = wire.array(v.input, (entry) => wire.member(entry, ["text", "image"]), 2, 1);
390
+ if (input[0] !== "text" || (input.length === 2 && input[1] !== "image"))
391
+ return wire.invalid();
392
+ const map = wire.object(v.thinkingLevelMap, efforts);
393
+ const thinkingLevelMap = {};
394
+ for (const effort of efforts)
395
+ thinkingLevelMap[effort] = map[effort] === null ? null : wire.literal(map[effort], effort);
396
+ const reasoning = wire.boolean(v.reasoning);
397
+ if (!reasoning && efforts.some((e) => e !== "off" && thinkingLevelMap[e] !== null))
398
+ return wire.invalid();
399
+ if (!efforts.some((e) => thinkingLevelMap[e] !== null) ||
400
+ (reasoning && !efforts.some((e) => e !== "off" && thinkingLevelMap[e] !== null)))
401
+ return wire.invalid();
402
+ const costRecord = wire.object(v.cost, ["input", "output", "cacheRead", "cacheWrite", "tiers"]);
403
+ const cost = {
404
+ ...rates({
405
+ input: costRecord.input,
406
+ output: costRecord.output,
407
+ cacheRead: costRecord.cacheRead,
408
+ cacheWrite: costRecord.cacheWrite,
409
+ }),
410
+ };
411
+ if (costRecord.tiers !== undefined) {
412
+ const tiers = wire.array(costRecord.tiers, (entry) => {
413
+ const r = rates(entry, true);
414
+ return { ...r, inputTokensAbove: wire.integer(r.inputTokensAbove) };
415
+ }, 1024);
416
+ if (tiers.some((entry, i) => entry.inputTokensAbove <= (tiers[i - 1]?.inputTokensAbove ?? -1)))
417
+ return wire.invalid();
418
+ cost.tiers = tiers;
419
+ }
420
+ const limits = wire.object(v.inputLimits, ["maxRequestBytes", "images"]);
421
+ const inputLimits = {};
422
+ if (limits.maxRequestBytes !== undefined)
423
+ inputLimits.maxRequestBytes = wire.integer(limits.maxRequestBytes, 12582912, 1);
424
+ if (limits.images !== undefined) {
425
+ if (input.length !== 2)
426
+ return wire.invalid();
427
+ const image = wire.object(limits.images, ["resize", "maxPerMessage", "maxPerRequest"]), resize = wire.object(image.resize, ["maxWidth", "maxHeight", "maxBytes", "jpegQuality"]);
428
+ inputLimits.images = {
429
+ maxPerMessage: wire.integer(image.maxPerMessage, 4, 1),
430
+ maxPerRequest: wire.integer(image.maxPerRequest, 4, 1),
431
+ resize: {
432
+ maxWidth: wire.integer(resize.maxWidth, 4096, 1),
433
+ maxHeight: wire.integer(resize.maxHeight, 4096, 1),
434
+ maxBytes: wire.integer(resize.maxBytes, 4194304, 1),
435
+ ...(resize.jpegQuality === undefined ? {} : { jpegQuality: wire.integer(resize.jpegQuality, 100, 1) }),
436
+ },
437
+ };
438
+ }
439
+ if (input.length === 2 && !inputLimits.images)
440
+ return wire.invalid();
441
+ const baseUrl = wire.https(v.baseUrl);
442
+ if (!["https://code.dev.humain.com", "https://code.stg.humain.com", "https://code.humain.com"].some((origin) => baseUrl === `${origin}/api/inference`))
443
+ return wire.invalid();
444
+ return {
445
+ id: scalar(v.id, 256, 1),
446
+ name: scalar(v.name, 256, 1),
447
+ api: wire.literal(v.api, "pi-messages"),
448
+ provider: wire.literal(v.provider, "humain-code-account"),
449
+ baseUrl,
450
+ type: wire.literal(v.type, "chat"),
451
+ tools: wire.boolean(v.tools),
452
+ reasoning,
453
+ input: input,
454
+ contextWindow,
455
+ maxTokens,
456
+ cost,
457
+ thinkingLevelMap,
458
+ inputLimits,
459
+ };
460
+ }
461
+ export function parseHcodeModelList(value) {
462
+ boundedJson(value, 32, 131072);
463
+ const v = wire.object(value, ["object", "data"]);
464
+ const data = wire.array(v.data, parseModel, 1024);
465
+ if (new Set(data.map((model) => model.id)).size !== data.length)
466
+ return wire.invalid();
467
+ return { object: wire.literal(v.object, "list"), data };
468
+ }
469
+ function textBlock(value) {
470
+ const v = wire.object(value, ["type", "text", "textSignature"]);
471
+ return {
472
+ type: wire.literal(v.type, "text"),
473
+ text: scalar(v.text),
474
+ ...(v.textSignature === undefined ? {} : { textSignature: scalar(v.textSignature, 262144) }),
475
+ };
476
+ }
477
+ function imageBlock(value) {
478
+ const v = wire.object(value, ["type", "data", "mimeType"]);
479
+ const data = scalar(v.data, 4194304, 4);
480
+ if (data.length % 4 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(data))
481
+ return wire.invalid();
482
+ const padding = data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0;
483
+ const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
484
+ if ((padding === 2 && (alphabet.indexOf(data.charAt(data.length - 3)) & 15) !== 0) ||
485
+ (padding === 1 && (alphabet.indexOf(data.charAt(data.length - 2)) & 3) !== 0))
486
+ return wire.invalid();
487
+ return {
488
+ type: wire.literal(v.type, "image"),
489
+ data,
490
+ mimeType: wire.member(v.mimeType, ["image/png", "image/jpeg", "image/webp"]),
491
+ };
492
+ }
493
+ function thinkingBlock(value) {
494
+ const v = wire.object(value, ["type", "thinking", "thinkingSignature", "redacted"]);
495
+ const result = {
496
+ type: wire.literal(v.type, "thinking"),
497
+ thinking: scalar(v.thinking),
498
+ ...(v.thinkingSignature === undefined ? {} : { thinkingSignature: scalar(v.thinkingSignature, 262144) }),
499
+ ...(v.redacted === undefined ? {} : { redacted: wire.boolean(v.redacted) }),
500
+ };
501
+ if (result.redacted && (!result.thinkingSignature || result.thinking !== ""))
502
+ return wire.invalid();
503
+ return result;
504
+ }
505
+ function toolCall(value) {
506
+ const v = wire.object(value, ["type", "id", "name", "arguments", "thoughtSignature", "namespace", "argumentsError"]);
507
+ const result = {
508
+ type: wire.literal(v.type, "toolCall"),
509
+ id: ascii(v.id),
510
+ name: toolName(v.name),
511
+ arguments: jsonObject(v.arguments, 65536),
512
+ ...(v.thoughtSignature === undefined ? {} : { thoughtSignature: scalar(v.thoughtSignature, 262144) }),
513
+ ...(v.namespace === undefined ? {} : { namespace: ascii(v.namespace, 128) }),
514
+ ...(v.argumentsError === undefined ? {} : { argumentsError: scalar(v.argumentsError, 65536, 1) }),
515
+ };
516
+ if (result.argumentsError && Object.keys(result.arguments).length)
517
+ return wire.invalid();
518
+ return result;
519
+ }
520
+ function tool(value) {
521
+ const v = wire.object(value, ["name", "description", "parameters", "constrainedSampling"]);
522
+ const result = {
523
+ name: toolName(v.name),
524
+ description: scalar(v.description),
525
+ parameters: jsonSchema(v.parameters),
526
+ };
527
+ if (v.constrainedSampling !== undefined) {
528
+ if (v.constrainedSampling === false)
529
+ result.constrainedSampling = false;
530
+ else {
531
+ const mode = wire.object(v.constrainedSampling, ["type", "strict"]);
532
+ result.constrainedSampling = {
533
+ type: wire.literal(mode.type, "json_schema"),
534
+ strict: wire.member(mode.strict, ["prefer", "require"]),
535
+ };
536
+ }
537
+ }
538
+ return result;
539
+ }
540
+ function content(value, images) {
541
+ if (typeof value === "string")
542
+ return scalar(value);
543
+ return wire.array(value, (entry) => {
544
+ const v = wire.object(entry, ["type", "text", "textSignature", "data", "mimeType"]);
545
+ return v.type === "image" && images ? imageBlock(entry) : textBlock(entry);
546
+ }, 2048);
547
+ }
548
+ function history(v) {
549
+ for (const key of [
550
+ "usage",
551
+ "diagnostics",
552
+ "timing",
553
+ "durationMs",
554
+ "retryAfterMs",
555
+ "errorMessage",
556
+ "rawStopReason",
557
+ "endTurn",
558
+ "responseId",
559
+ "responseModel",
560
+ "thinkingLevel",
561
+ "details",
562
+ "nestedCalls",
563
+ ]) {
564
+ if (v[key] === undefined)
565
+ continue;
566
+ if (key === "usage") {
567
+ const usage = wire.object(v[key], [
568
+ "input",
569
+ "output",
570
+ "cacheRead",
571
+ "cacheWrite",
572
+ "totalTokens",
573
+ "reasoning",
574
+ "cacheWrite1h",
575
+ "usageIncomplete",
576
+ "cost",
577
+ ]);
578
+ const cost = wire.object(usage.cost, [
579
+ "input",
580
+ "output",
581
+ "cacheRead",
582
+ "cacheWrite",
583
+ "total",
584
+ "totalFromProvider",
585
+ ]);
586
+ if (cost.totalFromProvider !== undefined)
587
+ wire.boolean(cost.totalFromProvider);
588
+ parseHcodePiUsage({ ...usage, cost: { ...cost, totalFromProvider: false } });
589
+ }
590
+ else if (key === "timing") {
591
+ const timing = wire.object(v[key], ["requestStartedAt", "firstTokenMs", "durationMs", "chunkCount"]);
592
+ wire.integer(timing.requestStartedAt);
593
+ if (timing.firstTokenMs !== null)
594
+ wire.number(timing.firstTokenMs, 0, Number.MAX_SAFE_INTEGER);
595
+ wire.number(timing.durationMs, 0, Number.MAX_SAFE_INTEGER);
596
+ wire.integer(timing.chunkCount);
597
+ }
598
+ else if (["durationMs", "retryAfterMs"].includes(key))
599
+ wire.number(v[key], 0, Number.MAX_SAFE_INTEGER);
600
+ else if (key === "endTurn")
601
+ wire.boolean(v[key]);
602
+ else if (["errorMessage", "rawStopReason", "responseId", "responseModel", "thinkingLevel"].includes(key))
603
+ scalar(v[key]);
604
+ else
605
+ boundedJson(v[key]);
606
+ }
607
+ }
608
+ function parseMessage(value) {
609
+ const base = wire.object(value, [
610
+ "role",
611
+ "content",
612
+ "timestamp",
613
+ "sections",
614
+ "toolsAdded",
615
+ "toolsRemoved",
616
+ "api",
617
+ "provider",
618
+ "model",
619
+ "stopReason",
620
+ "providerThinkingLevel",
621
+ "toolCallId",
622
+ "toolName",
623
+ "isError",
624
+ "usage",
625
+ "diagnostics",
626
+ "timing",
627
+ "durationMs",
628
+ "retryAfterMs",
629
+ "errorMessage",
630
+ "rawStopReason",
631
+ "endTurn",
632
+ "responseId",
633
+ "responseModel",
634
+ "thinkingLevel",
635
+ "details",
636
+ "nestedCalls",
637
+ ]);
638
+ const timestamp = wire.integer(base.timestamp);
639
+ if (base.role === "system") {
640
+ const v = wire.object(value, ["role", "content", "timestamp", "sections", "toolsAdded", "toolsRemoved"]);
641
+ const result = {
642
+ role: "system",
643
+ content: content(v.content, false),
644
+ timestamp,
645
+ };
646
+ if (v.sections !== undefined) {
647
+ const sections = wire.object(v.sections, Object.keys(v.sections));
648
+ if (Object.keys(sections).length > 64)
649
+ return wire.invalid();
650
+ result.sections = {};
651
+ for (const [key, entry] of Object.entries(sections)) {
652
+ scalar(key, 128, 1);
653
+ result.sections[key] = entry === null ? null : scalar(entry);
654
+ }
655
+ }
656
+ if (v.toolsAdded !== undefined)
657
+ result.toolsAdded = wire.array(v.toolsAdded, tool, 64);
658
+ if (v.toolsRemoved !== undefined)
659
+ result.toolsRemoved = wire.array(v.toolsRemoved, (entry) => {
660
+ const r = wire.object(entry, ["name"]);
661
+ return { name: toolName(r.name) };
662
+ }, 64);
663
+ return result;
664
+ }
665
+ if (base.role === "user") {
666
+ const v = wire.object(value, ["role", "content", "timestamp"]);
667
+ return { role: "user", content: content(v.content, true), timestamp };
668
+ }
669
+ if (base.role === "assistant") {
670
+ const v = wire.object(value, [
671
+ "role",
672
+ "content",
673
+ "timestamp",
674
+ "api",
675
+ "provider",
676
+ "model",
677
+ "stopReason",
678
+ "providerThinkingLevel",
679
+ "usage",
680
+ "diagnostics",
681
+ "timing",
682
+ "durationMs",
683
+ "retryAfterMs",
684
+ "errorMessage",
685
+ "rawStopReason",
686
+ "endTurn",
687
+ "responseId",
688
+ "responseModel",
689
+ "thinkingLevel",
690
+ ]);
691
+ history(v);
692
+ return {
693
+ role: "assistant",
694
+ content: wire.array(v.content, (entry) => {
695
+ const record = wire.object(entry, [
696
+ "type",
697
+ "text",
698
+ "textSignature",
699
+ "thinking",
700
+ "thinkingSignature",
701
+ "redacted",
702
+ "id",
703
+ "name",
704
+ "arguments",
705
+ "thoughtSignature",
706
+ "namespace",
707
+ "argumentsError",
708
+ ]);
709
+ return record.type === "thinking"
710
+ ? thinkingBlock(entry)
711
+ : record.type === "toolCall"
712
+ ? toolCall(entry)
713
+ : textBlock(entry);
714
+ }, 2048),
715
+ api: scalar(v.api, 256, 1),
716
+ provider: scalar(v.provider, 256, 1),
717
+ model: scalar(v.model, 256, 1),
718
+ stopReason: wire.member(v.stopReason, ["stop", "length", "toolUse", "error", "aborted"]),
719
+ timestamp,
720
+ ...(v.providerThinkingLevel === undefined
721
+ ? {}
722
+ : { providerThinkingLevel: ascii(v.providerThinkingLevel, 128) }),
723
+ };
724
+ }
725
+ const v = wire.object(value, [
726
+ "role",
727
+ "content",
728
+ "timestamp",
729
+ "toolCallId",
730
+ "toolName",
731
+ "isError",
732
+ "details",
733
+ "usage",
734
+ "nestedCalls",
735
+ "durationMs",
736
+ ]);
737
+ history(v);
738
+ return {
739
+ role: wire.literal(v.role, "toolResult"),
740
+ toolCallId: ascii(v.toolCallId),
741
+ toolName: toolName(v.toolName),
742
+ content: wire.array(v.content, (entry) => {
743
+ const record = wire.object(entry, ["type", "text", "textSignature", "data", "mimeType"]);
744
+ return record.type === "image" ? imageBlock(entry) : textBlock(entry);
745
+ }, 2048),
746
+ isError: wire.boolean(v.isError),
747
+ timestamp,
748
+ };
749
+ }
750
+ const ignoredOptions = [
751
+ "headers",
752
+ "metadata",
753
+ "provider",
754
+ "baseUrl",
755
+ "apiKey",
756
+ "env",
757
+ "samplingParams",
758
+ "transport",
759
+ "thinkingBudgets",
760
+ "maxRetries",
761
+ "maxRetryDelayMs",
762
+ "timeoutMs",
763
+ "noProgressTimeoutMs",
764
+ "websocketConnectTimeoutMs",
765
+ ];
766
+ function parseOptions(value) {
767
+ const v = wire.object(value, [
768
+ "temperature",
769
+ "maxTokens",
770
+ "reasoning",
771
+ "cacheRetention",
772
+ "sessionId",
773
+ "toolChoice",
774
+ ...ignoredOptions,
775
+ ]);
776
+ for (const key of ignoredOptions)
777
+ if (v[key] !== undefined)
778
+ boundedJson(v[key]);
779
+ const result = {};
780
+ if (v.temperature !== undefined)
781
+ result.temperature = wire.number(v.temperature, 0, 2);
782
+ if (v.maxTokens !== undefined)
783
+ result.maxTokens = wire.integer(v.maxTokens, Number.MAX_SAFE_INTEGER, 1);
784
+ if (v.reasoning !== undefined)
785
+ result.reasoning = wire.member(v.reasoning, ["minimal", "low", "medium", "high", "xhigh", "max"]);
786
+ if (v.cacheRetention !== undefined)
787
+ result.cacheRetention = wire.member(v.cacheRetention, ["none", "short", "long"]);
788
+ if (v.sessionId !== undefined)
789
+ result.sessionId = ascii(v.sessionId);
790
+ if (v.toolChoice !== undefined) {
791
+ if (typeof v.toolChoice === "string")
792
+ result.toolChoice = wire.member(v.toolChoice, ["auto", "none", "required"]);
793
+ else {
794
+ const choice = wire.object(v.toolChoice, ["type", "function"]), f = wire.object(choice.function, ["name"]);
795
+ result.toolChoice = { type: wire.literal(choice.type, "function"), function: { name: toolName(f.name) } };
796
+ }
797
+ }
798
+ return result;
799
+ }
800
+ export function parseHcodeMessagesRequest(value) {
801
+ const raw = boundedJson(value, 48, 1048576);
802
+ if (wire.jsonBytes(raw) > 12582912)
803
+ return wire.invalid();
804
+ const v = wire.object(raw, ["model", "context", "options"]), context = wire.object(v.context, ["messages"]);
805
+ const messages = wire.array(context.messages, parseMessage, 512, 1);
806
+ const result = {
807
+ model: scalar(v.model, 256, 1),
808
+ context: { messages },
809
+ ...(v.options === undefined ? {} : { options: parseOptions(v.options) }),
810
+ };
811
+ let blocks = 0, images = 0, imageBytes = 0, schemaBytes = 0;
812
+ const active = new Map(), seen = new Set(), pending = new Map();
813
+ for (const message of messages) {
814
+ if (message.role === "system") {
815
+ const added = message.toolsAdded ?? [], removed = message.toolsRemoved ?? [];
816
+ if (new Set(added.map((t) => t.name)).size !== added.length ||
817
+ new Set(removed.map((t) => t.name)).size !== removed.length ||
818
+ removed.some((r) => added.some((a) => a.name === r.name)))
819
+ return wire.invalid();
820
+ for (const t of removed)
821
+ if (!active.delete(t.name))
822
+ return wire.invalid();
823
+ for (const t of added) {
824
+ active.set(t.name, t);
825
+ schemaBytes += wire.jsonBytes(t.parameters);
826
+ }
827
+ if (active.size > 64 || schemaBytes > 131072)
828
+ return wire.invalid();
829
+ }
830
+ else if (message.role === "toolResult") {
831
+ if (pending.get(message.toolCallId) !== message.toolName)
832
+ return wire.invalid();
833
+ pending.delete(message.toolCallId);
834
+ }
835
+ else {
836
+ if (pending.size)
837
+ return wire.invalid();
838
+ if (message.role === "assistant") {
839
+ const calls = message.content.filter((block) => block.type === "toolCall");
840
+ if (calls.length > 64)
841
+ return wire.invalid();
842
+ for (const call of calls) {
843
+ if (seen.has(call.id) || !active.has(call.name) || call.argumentsError)
844
+ return wire.invalid();
845
+ seen.add(call.id);
846
+ pending.set(call.id, call.name);
847
+ }
848
+ if (seen.size > 512)
849
+ return wire.invalid();
850
+ }
851
+ }
852
+ blocks += typeof message.content === "string" ? 1 : message.content.length;
853
+ if (typeof message.content !== "string") {
854
+ let perMessage = 0;
855
+ for (const block of message.content)
856
+ if (block.type === "image") {
857
+ images++;
858
+ perMessage++;
859
+ const padding = block.data.endsWith("==") ? 2 : block.data.endsWith("=") ? 1 : 0;
860
+ const decoded = (block.data.length / 4) * 3 - padding;
861
+ if (decoded > 3145728)
862
+ return wire.invalid();
863
+ imageBytes += decoded;
864
+ }
865
+ if (perMessage > 4)
866
+ return wire.invalid();
867
+ }
868
+ }
869
+ if (pending.size || blocks > 2048 || images > 4 || imageBytes > 8388608)
870
+ return wire.invalid();
871
+ const choice = result.options?.toolChoice;
872
+ if (choice !== undefined && (!active.size || (typeof choice === "object" && !active.has(choice.function.name))))
873
+ return wire.invalid();
874
+ // Count the raw envelope, including ignored bookkeeping, with only actual image payloads emptied.
875
+ const nonImage = wire.jsonBytes(raw) -
876
+ messages.reduce((sum, message) => sum +
877
+ (typeof message.content === "string"
878
+ ? 0
879
+ : message.content.reduce((n, block) => n + (block.type === "image" ? block.data.length : 0), 0)), 0);
880
+ if (nonImage > 1048576)
881
+ return wire.invalid();
882
+ return result;
883
+ }
884
+ export function parseHcodePiUsage(value) {
885
+ const v = wire.object(value, [
886
+ "input",
887
+ "output",
888
+ "cacheRead",
889
+ "cacheWrite",
890
+ "totalTokens",
891
+ "reasoning",
892
+ "cacheWrite1h",
893
+ "usageIncomplete",
894
+ "cost",
895
+ ]);
896
+ const input = wire.integer(v.input, 2147483647), output = wire.integer(v.output, 2147483647), cacheRead = wire.integer(v.cacheRead, 2147483647), cacheWrite = wire.integer(v.cacheWrite, 2147483647), totalTokens = wire.integer(v.totalTokens, 2147483647);
897
+ if (totalTokens !== input + output + cacheRead + cacheWrite)
898
+ return wire.invalid();
899
+ const cost = wire.object(v.cost, ["input", "output", "cacheRead", "cacheWrite", "total", "totalFromProvider"]);
900
+ const costResult = {
901
+ input: wire.number(cost.input, 0, Number.MAX_SAFE_INTEGER),
902
+ output: wire.number(cost.output, 0, Number.MAX_SAFE_INTEGER),
903
+ cacheRead: wire.number(cost.cacheRead, 0, Number.MAX_SAFE_INTEGER),
904
+ cacheWrite: wire.number(cost.cacheWrite, 0, Number.MAX_SAFE_INTEGER),
905
+ total: wire.number(cost.total, 0, Number.MAX_SAFE_INTEGER),
906
+ ...(cost.totalFromProvider === undefined
907
+ ? {}
908
+ : { totalFromProvider: wire.literal(cost.totalFromProvider, false) }),
909
+ };
910
+ return {
911
+ input,
912
+ output,
913
+ cacheRead,
914
+ cacheWrite,
915
+ totalTokens,
916
+ cost: costResult,
917
+ ...(v.reasoning === undefined ? {} : { reasoning: wire.integer(v.reasoning, output) }),
918
+ ...(v.cacheWrite1h === undefined ? {} : { cacheWrite1h: wire.integer(v.cacheWrite1h, cacheWrite) }),
919
+ ...(v.usageIncomplete === undefined ? {} : { usageIncomplete: wire.boolean(v.usageIncomplete) }),
920
+ };
921
+ }
922
+ const safeStreamErrors = [
923
+ "Upstream unavailable.",
924
+ "Settlement unavailable.",
925
+ "Invalid request.",
926
+ "HUMAIN Code account unavailable.",
927
+ "Request aborted.",
928
+ ];
929
+ export function parseHcodePiEvent(value) {
930
+ boundedJson(value, 40, 32768);
931
+ const v = wire.object(value, [
932
+ "type",
933
+ "contentIndex",
934
+ "delta",
935
+ "content",
936
+ "contentSignature",
937
+ "redacted",
938
+ "id",
939
+ "toolName",
940
+ "toolCall",
941
+ "reason",
942
+ "usage",
943
+ "errorMessage",
944
+ "responseId",
945
+ "responseModel",
946
+ "providerThinkingLevel",
947
+ ]);
948
+ if (v.type === "start") {
949
+ wire.object(value, ["type"]);
950
+ return { type: "start" };
951
+ }
952
+ if (v.type === "done" || v.type === "error") {
953
+ wire.object(value, [
954
+ "type",
955
+ "reason",
956
+ "usage",
957
+ "responseId",
958
+ "responseModel",
959
+ "providerThinkingLevel",
960
+ ...(v.type === "error" ? ["errorMessage"] : []),
961
+ ]);
962
+ const terminal = {
963
+ usage: parseHcodePiUsage(v.usage),
964
+ ...(v.responseId === undefined ? {} : { responseId: ascii(v.responseId) }),
965
+ ...(v.responseModel === undefined ? {} : { responseModel: scalar(v.responseModel, 256, 1) }),
966
+ ...(v.providerThinkingLevel === undefined
967
+ ? {}
968
+ : { providerThinkingLevel: ascii(v.providerThinkingLevel, 128) }),
969
+ };
970
+ if (v.type === "done") {
971
+ if (terminal.usage.usageIncomplete === true)
972
+ return wire.invalid();
973
+ return { type: "done", reason: wire.member(v.reason, ["stop", "length", "toolUse"]), ...terminal };
974
+ }
975
+ return {
976
+ type: "error",
977
+ reason: wire.member(v.reason, ["aborted", "error"]),
978
+ ...terminal,
979
+ ...(v.errorMessage === undefined ? {} : { errorMessage: wire.member(v.errorMessage, safeStreamErrors) }),
980
+ };
981
+ }
982
+ const contentIndex = wire.integer(v.contentIndex, 2047);
983
+ if (v.type === "text_start" || v.type === "thinking_start") {
984
+ wire.object(value, ["type", "contentIndex"]);
985
+ return { type: v.type, contentIndex };
986
+ }
987
+ if (v.type === "text_delta" || v.type === "thinking_delta" || v.type === "toolcall_delta") {
988
+ wire.object(value, ["type", "contentIndex", "delta"]);
989
+ return { type: v.type, contentIndex, delta: scalar(v.delta, v.type === "toolcall_delta" ? 65536 : 1048576) };
990
+ }
991
+ if (v.type === "text_end" || v.type === "thinking_end") {
992
+ wire.object(value, [
993
+ "type",
994
+ "contentIndex",
995
+ "content",
996
+ "contentSignature",
997
+ ...(v.type === "thinking_end" ? ["redacted"] : []),
998
+ ]);
999
+ const end = {
1000
+ contentIndex,
1001
+ content: scalar(v.content, 8388608),
1002
+ ...(v.contentSignature === undefined ? {} : { contentSignature: scalar(v.contentSignature, 262144) }),
1003
+ };
1004
+ if (v.type === "text_end")
1005
+ return { type: "text_end", ...end };
1006
+ const redacted = v.redacted === undefined ? undefined : wire.boolean(v.redacted);
1007
+ if (redacted && (!end.contentSignature || end.content !== ""))
1008
+ return wire.invalid();
1009
+ return { type: "thinking_end", ...end, ...(redacted === undefined ? {} : { redacted }) };
1010
+ }
1011
+ if (v.type === "toolcall_start") {
1012
+ wire.object(value, ["type", "contentIndex", "id", "toolName"]);
1013
+ return { type: "toolcall_start", contentIndex, id: ascii(v.id), toolName: toolName(v.toolName) };
1014
+ }
1015
+ wire.object(value, ["type", "contentIndex", "toolCall"]);
1016
+ return { type: wire.literal(v.type, "toolcall_end"), contentIndex, toolCall: toolCall(v.toolCall) };
1017
+ }
1018
+ export function createHcodePiEventValidator() {
1019
+ let started = false, terminal = false, failed = false, retained = 0, malformed = false;
1020
+ const blocks = [], ids = new Set();
1021
+ return {
1022
+ parse(value) {
1023
+ try {
1024
+ if (terminal || failed)
1025
+ return wire.invalid();
1026
+ const event = parseHcodePiEvent(value);
1027
+ if (event.type === "start") {
1028
+ if (started)
1029
+ return wire.invalid();
1030
+ started = true;
1031
+ return event;
1032
+ }
1033
+ if (!started)
1034
+ return wire.invalid();
1035
+ if (event.type === "done" || event.type === "error") {
1036
+ if (event.type === "done" && (blocks.some((b) => !b.ended) || malformed))
1037
+ return wire.invalid();
1038
+ terminal = true;
1039
+ return event;
1040
+ }
1041
+ const kind = event.type.slice(0, event.type.indexOf("_"));
1042
+ if (event.type.endsWith("_start")) {
1043
+ if (event.contentIndex !== blocks.length)
1044
+ return wire.invalid();
1045
+ if (event.type === "toolcall_start") {
1046
+ if (ids.has(event.id) || ids.size >= 64)
1047
+ return wire.invalid();
1048
+ ids.add(event.id);
1049
+ blocks.push({ kind, ended: false, bytes: 0, id: event.id, name: event.toolName });
1050
+ }
1051
+ else
1052
+ blocks.push({ kind, ended: false, bytes: 0 });
1053
+ }
1054
+ else {
1055
+ const block = blocks[event.contentIndex];
1056
+ if (!block || block.ended || block.kind !== kind)
1057
+ return wire.invalid();
1058
+ if ("delta" in event) {
1059
+ const n = bytes(event.delta);
1060
+ block.bytes += n;
1061
+ retained += n;
1062
+ if (kind === "toolcall" && block.bytes > 65536)
1063
+ return wire.invalid();
1064
+ }
1065
+ else {
1066
+ let n;
1067
+ if (event.type === "toolcall_end") {
1068
+ if (event.toolCall.id !== block.id || event.toolCall.name !== block.name)
1069
+ return wire.invalid();
1070
+ malformed ||= event.toolCall.argumentsError !== undefined;
1071
+ n = wire.jsonBytes(event.toolCall);
1072
+ }
1073
+ else if (event.type === "text_end" || event.type === "thinking_end")
1074
+ n = bytes(event.content) + bytes(event.contentSignature ?? "");
1075
+ else
1076
+ return wire.invalid();
1077
+ retained += n - block.bytes;
1078
+ block.bytes = n;
1079
+ block.ended = true;
1080
+ }
1081
+ }
1082
+ if (retained > 8388608)
1083
+ return wire.invalid();
1084
+ return event;
1085
+ }
1086
+ catch {
1087
+ failed = true;
1088
+ return wire.invalid();
1089
+ }
1090
+ },
1091
+ finish() {
1092
+ if (failed || !started || !terminal)
1093
+ return wire.invalid();
1094
+ },
1095
+ };
1096
+ }
1097
+ const snapshotFields = [
1098
+ "asOf",
1099
+ "currency",
1100
+ "unit",
1101
+ "period",
1102
+ "allowance",
1103
+ "actual",
1104
+ "reserved",
1105
+ "committed",
1106
+ "remaining",
1107
+ "costComplete",
1108
+ ];
1109
+ function checkAllowanceConsistency(value) {
1110
+ if ((value.allowance.kind === "unlimited") !== (value.remaining.kind === "unlimited"))
1111
+ wire.invalid();
1112
+ if (value.actual.kind === "known" &&
1113
+ value.reserved.kind === "known" &&
1114
+ value.committed.kind === "known" &&
1115
+ (!Number.isSafeInteger(value.actual.value + value.reserved.value) ||
1116
+ value.committed.value !== value.actual.value + value.reserved.value))
1117
+ wire.invalid();
1118
+ if (value.allowance.kind === "limited" &&
1119
+ value.committed.kind === "known" &&
1120
+ value.remaining.kind === "known" &&
1121
+ value.remaining.value !== Math.max(0, value.allowance.limitMicrocents - value.committed.value))
1122
+ wire.invalid();
1123
+ }
1124
+ export function parseAllowanceSnapshot(value) {
1125
+ const v = wire.object(value, snapshotFields), period = wire.object(v.period, ["start", "resetAt"]);
1126
+ const start = wire.time(period.start), resetAt = wire.time(period.resetAt);
1127
+ if (Date.parse(start) >= Date.parse(resetAt))
1128
+ return wire.invalid();
1129
+ const r = wire.object(v.remaining, ["kind", "value"]);
1130
+ const remaining = r.kind === "unlimited"
1131
+ ? { kind: wire.literal(wire.object(v.remaining, ["kind"]).kind, "unlimited") }
1132
+ : parseValue(v.remaining);
1133
+ const result = {
1134
+ asOf: wire.time(v.asOf),
1135
+ currency: wire.literal(v.currency, "USD"),
1136
+ unit: wire.literal(v.unit, "microcent"),
1137
+ period: { start, resetAt },
1138
+ allowance: parseAllowance(v.allowance),
1139
+ actual: parseValue(v.actual),
1140
+ reserved: parseValue(v.reserved),
1141
+ committed: parseValue(v.committed),
1142
+ remaining,
1143
+ costComplete: wire.boolean(v.costComplete),
1144
+ };
1145
+ checkAllowanceConsistency(result);
1146
+ return result;
1147
+ }
1148
+ export function parseHcodeAdminResolutionEvidence(value) {
1149
+ const v = wire.object(value, [
1150
+ "kind",
1151
+ "resolutionId",
1152
+ "environmentId",
1153
+ "operationId",
1154
+ "actorId",
1155
+ "at",
1156
+ "expectedRevision",
1157
+ "decision",
1158
+ "costMicrocents",
1159
+ "costSource",
1160
+ "basis",
1161
+ "reason",
1162
+ "evidenceReference",
1163
+ "tokens",
1164
+ ]);
1165
+ const reason = scalar(v.reason, 2000, 1), evidenceReference = scalar(v.evidenceReference, 1024, 1);
1166
+ if (!reason.trim() || !evidenceReference.trim())
1167
+ return wire.invalid();
1168
+ const decision = wire.member(v.decision, ["charged", "not-charged"]), basis = wire.member(v.basis, ["provider-evidence", "no-charge-evidence", "administrative-waiver"]), costMicrocents = wire.integer(v.costMicrocents);
1169
+ if (decision === "charged" ? basis !== "provider-evidence" : costMicrocents !== 0 || basis === "provider-evidence")
1170
+ return wire.invalid();
1171
+ return {
1172
+ kind: wire.literal(v.kind, "admin-resolution"),
1173
+ resolutionId: wire.string(v.resolutionId),
1174
+ environmentId: wire.string(v.environmentId),
1175
+ operationId: wire.string(v.operationId),
1176
+ actorId: wire.string(v.actorId),
1177
+ at: wire.time(v.at),
1178
+ expectedRevision: wire.integer(v.expectedRevision),
1179
+ decision,
1180
+ costMicrocents,
1181
+ costSource: wire.literal(v.costSource, "admin_resolved"),
1182
+ basis,
1183
+ reason,
1184
+ evidenceReference,
1185
+ tokens: parseTokens(v.tokens),
1186
+ };
1187
+ }
1188
+ const errorMessages = {
1189
+ unauthorized: "Authentication required.",
1190
+ forbidden: "Access denied.",
1191
+ legal_acknowledgment_required: "Legal acknowledgment required.",
1192
+ auth_dependency_unavailable: "Authentication unavailable.",
1193
+ hcode_unavailable: "HUMAIN Code account unavailable.",
1194
+ invalid_request: "Invalid request.",
1195
+ unsupported_capability: "Unsupported capability.",
1196
+ model_unavailable: "Model unavailable.",
1197
+ hcode_busy: "HUMAIN Code is busy, retry shortly.",
1198
+ quota_exceeded: "You've reached your monthly allowance.",
1199
+ idempotency_conflict: "Operation already settled.",
1200
+ request_in_progress: "Operation in progress.",
1201
+ outcome_unknown: "Operation outcome unknown.",
1202
+ upstream_unavailable: "Upstream unavailable.",
1203
+ settlement_unavailable: "Settlement unavailable.",
1204
+ };
1205
+ export const HCODE_ALLOWANCE_ESTIMATE_MESSAGE = "Your remaining monthly allowance cannot cover this request.";
1206
+ export function parseHcodeInferenceError(value) {
1207
+ const outer = wire.object(value, ["error"]), v = wire.object(outer.error, ["code", "message", "details"]);
1208
+ const code = wire.member(v.code, Object.keys(errorMessages));
1209
+ if (code === "hcode_busy") {
1210
+ const d = wire.object(v.details, ["dispatched", "automaticRetryAllowed", "retryAfterMs"]);
1211
+ return {
1212
+ error: {
1213
+ code,
1214
+ message: wire.literal(v.message, errorMessages[code]),
1215
+ details: {
1216
+ dispatched: wire.literal(d.dispatched, false),
1217
+ automaticRetryAllowed: wire.literal(d.automaticRetryAllowed, false),
1218
+ retryAfterMs: wire.literal(d.retryAfterMs, 1000),
1219
+ },
1220
+ },
1221
+ };
1222
+ }
1223
+ if (code === "quota_exceeded") {
1224
+ const d = wire.object(v.details, ["dispatched", "automaticRetryAllowed", "usage"]);
1225
+ return {
1226
+ error: {
1227
+ code,
1228
+ message: wire.member(v.message, [errorMessages[code], HCODE_ALLOWANCE_ESTIMATE_MESSAGE]),
1229
+ details: {
1230
+ dispatched: wire.literal(d.dispatched, false),
1231
+ automaticRetryAllowed: wire.literal(d.automaticRetryAllowed, false),
1232
+ usage: parseAllowanceSnapshot(d.usage),
1233
+ },
1234
+ },
1235
+ };
1236
+ }
1237
+ if (v.details !== null)
1238
+ return wire.invalid();
1239
+ return {
1240
+ error: { code, message: wire.literal(v.message, errorMessages[code]), details: null },
1241
+ };
1242
+ }
1243
+ //# sourceMappingURL=contracts.js.map