@humain/humain-code 0.5.4 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (694) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/dist/bundle/agent-monitor.js +1 -1
  3. package/dist/bundle/chunks/anthropic-messages-FGFIMZUF.js +66 -0
  4. package/dist/bundle/chunks/azure-openai-responses-6JNTC7KO.js +15 -0
  5. package/dist/bundle/chunks/bedrock-converse-stream.js +261 -237
  6. package/dist/bundle/chunks/chunk-2H3LUS62.js +1966 -0
  7. package/dist/bundle/chunks/{chunk-GEISZXXH.js → chunk-4ZBGTJJM.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-QWXPGBAG.js → chunk-5JSLXC2A.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-L2VKM23Q.js → chunk-6DE7LJKV.js} +21 -21
  10. package/dist/bundle/chunks/{chunk-V62QBESW.js → chunk-6E6RHNOU.js} +11 -10
  11. package/dist/bundle/chunks/chunk-7RZ5BS7U.js +2 -0
  12. package/dist/bundle/chunks/chunk-AHSNQWZU.js +24 -0
  13. package/dist/bundle/chunks/{chunk-UJLCKIMZ.js → chunk-AOH2O5CP.js} +3469 -3133
  14. package/dist/bundle/chunks/{chunk-ODJUBJK2.js → chunk-B7NJMF7B.js} +11 -11
  15. package/dist/bundle/chunks/chunk-BQ3TMEWD.js +7 -0
  16. package/dist/bundle/chunks/{chunk-KKCMWB63.js → chunk-C6VERWRZ.js} +1 -1
  17. package/dist/bundle/chunks/{chunk-CN3Q5UNB.js → chunk-CFHOPLW5.js} +658 -574
  18. package/dist/bundle/chunks/chunk-CVC2GV26.js +1986 -0
  19. package/dist/bundle/chunks/{chunk-DU6POZ7E.js → chunk-DHW3REC5.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-UTNHGOFS.js → chunk-EDONIPUJ.js} +38 -38
  21. package/dist/bundle/chunks/{chunk-FO2NYB6O.js → chunk-FDGW5ZTG.js} +1147 -1110
  22. package/dist/bundle/chunks/{chunk-XQX7S3GM.js → chunk-GICL5V54.js} +1 -1
  23. package/dist/bundle/chunks/chunk-H7Y4QY7K.js +11 -0
  24. package/dist/bundle/chunks/chunk-HW6HMUXS.js +188 -0
  25. package/dist/bundle/chunks/chunk-I6AQOITY.js +53 -0
  26. package/dist/bundle/chunks/{chunk-ZI7TK7HM.js → chunk-IADQJFNH.js} +21 -17
  27. package/dist/bundle/chunks/chunk-J7AP2BUJ.js +3 -0
  28. package/dist/bundle/chunks/chunk-JFE52VSN.js +120 -0
  29. package/dist/bundle/chunks/{chunk-MIJHJNNQ.js → chunk-LDGCU6PD.js} +127 -3
  30. package/dist/bundle/chunks/{chunk-PS7DGA7B.js → chunk-M4CHQBAI.js} +1 -1
  31. package/dist/bundle/chunks/{chunk-YDBNMIA3.js → chunk-NN53K2QQ.js} +19 -1
  32. package/dist/bundle/chunks/{chunk-RTXDU3AA.js → chunk-ONR6Q3II.js} +255 -195
  33. package/dist/bundle/chunks/{chunk-Y3OPKKDR.js → chunk-P4P7OZ7R.js} +34 -32
  34. package/dist/bundle/chunks/{chunk-OZNC2W4B.js → chunk-PCTLFSQG.js} +444 -411
  35. package/dist/bundle/chunks/{chunk-YFBDR4IW.js → chunk-PNGNZXOI.js} +3 -3
  36. package/dist/bundle/chunks/{chunk-UDB6NI4G.js → chunk-RGUZULEE.js} +593 -481
  37. package/dist/bundle/chunks/chunk-RO5YPAJH.js +23 -0
  38. package/dist/bundle/chunks/{chunk-A6B2QMA7.js → chunk-RU7ADKA7.js} +176 -162
  39. package/dist/bundle/chunks/{chunk-JCXXRCP6.js → chunk-T3KDZFM4.js} +16 -16
  40. package/dist/bundle/chunks/{chunk-HT5YN3LX.js → chunk-TEOMXMW6.js} +3 -3
  41. package/dist/bundle/chunks/{chunk-HIZWUSPN.js → chunk-VEGJT52D.js} +77 -77
  42. package/dist/bundle/chunks/{chunk-IDU5BNNI.js → chunk-XMZGB3H4.js} +12 -3
  43. package/dist/bundle/chunks/chunk-YEPHPMQC.js +647 -0
  44. package/dist/bundle/chunks/{chunk-XA7CJAYH.js → chunk-YRUIJ5AH.js} +48 -42
  45. package/dist/bundle/chunks/{cli-ENEFJH2B.js → cli-BNCWK54K.js} +21 -17
  46. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-T7TPP7SQ.js → cloudflare-workers-ai-system-one-KI6W3USX.js} +1 -1
  47. package/dist/bundle/chunks/codemode-worker.js +81 -75
  48. package/dist/bundle/chunks/compat-I5VPOXFT.js +13 -0
  49. package/dist/bundle/chunks/dist-J5IUPLMH.js +37 -0
  50. package/dist/bundle/chunks/{dist-RKNCFFGM.js → dist-SKBR3C7C.js} +720 -696
  51. package/dist/bundle/chunks/dist-TVRQXUY6.js +8 -0
  52. package/dist/bundle/chunks/{dist-cjs-HTASUQXQ.js → dist-cjs-2SKN226B.js} +77 -77
  53. package/dist/bundle/chunks/{easter-egg-3d-YOPLCOVW.js → easter-egg-3d-673VRP6Y.js} +1 -1
  54. package/dist/bundle/chunks/{esm-R6HJ4QEG.js → esm-WPALMLUO.js} +3 -3
  55. package/dist/bundle/chunks/{event-streams-BR2IL6C5.js → event-streams-7YGFEPBZ.js} +1 -1
  56. package/dist/bundle/chunks/{execute-2JXEKQ2X.js → execute-PIUR5MUV.js} +23 -23
  57. package/dist/bundle/chunks/{extract-OTCGZGTL.js → extract-4O5Z5725.js} +74 -71
  58. package/dist/bundle/chunks/github-copilot.js +50 -51
  59. package/dist/bundle/chunks/google-generative-ai-635YZEHN.js +22 -0
  60. package/dist/bundle/chunks/google-vertex-I3ZJ3SB2.js +26 -0
  61. package/dist/bundle/chunks/host-OQOEIWHK.js +2 -0
  62. package/dist/bundle/chunks/image-resize-worker.js +3 -2
  63. package/dist/bundle/chunks/kimi-coding.js +13 -14
  64. package/dist/bundle/chunks/{llama-cpp-classify-B3G57LVR.js → llama-cpp-classify-PP63BYDF.js} +1 -1
  65. package/dist/bundle/chunks/meta.js +10 -10
  66. package/dist/bundle/chunks/mistral-conversations-OKG5GKXR.js +42 -0
  67. package/dist/bundle/chunks/{node-VSA4ZN7D.js → node-UGQUSQE6.js} +1 -1
  68. package/dist/bundle/chunks/{node-SJPZTR4K.js → node-UNHECG4X.js} +168 -157
  69. package/dist/bundle/chunks/openai-codex-responses-6JYZIFT4.js +100 -0
  70. package/dist/bundle/chunks/openai-completions-YBNI6CAP.js +82 -0
  71. package/dist/bundle/chunks/{openai-decisions-WOWUC65P.js → openai-decisions-5G5YBFRQ.js} +1 -1
  72. package/dist/bundle/chunks/openai-responses-C3APJ6MK.js +27 -0
  73. package/dist/bundle/chunks/{openrouter-images-5K47HDAT.js → openrouter-images-FCJT7C7I.js} +2 -2
  74. package/dist/bundle/chunks/{pdfjs-EK6K7CXX.js → pdfjs-AKD6EBKN.js} +196 -175
  75. package/dist/bundle/chunks/pdfjs-decoders-OFXX4HDZ.js +2 -0
  76. package/dist/bundle/chunks/pdfjs-jbig2-TXR26KRI.js +278 -0
  77. package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-FH3KJM4H.js +326 -0
  78. package/dist/bundle/chunks/pdfjs-openjpeg-SKR7C34X.js +671 -0
  79. package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-VUBL7UEE.js +974 -0
  80. package/dist/bundle/chunks/pi-messages-UHYZYEOC.js +25 -0
  81. package/dist/bundle/chunks/radius.js +8 -8
  82. package/dist/bundle/chunks/{runtime-K3F2QDQP.js → runtime-KE3HDSRT.js} +1 -1
  83. package/dist/bundle/chunks/{turndown.cjs-U7XOXH4O.js → turndown.cjs-WKGZX7NZ.js} +1 -1
  84. package/dist/bundle/chunks/{typesafe-system-one-43OCHGKP.js → typesafe-system-one-VYVAMWQV.js} +1 -1
  85. package/dist/bundle/chunks/{undici-EK3EUI2E.js → undici-C6S56CGI.js} +1 -1
  86. package/dist/bundle/chunks/virtual-modules-KDUZIB3W.js +23 -0
  87. package/dist/bundle/cli-runtime.js +3 -3
  88. package/dist/bundle/flow/package.json +5 -5
  89. package/dist/bundle/index.js +10 -10
  90. package/dist/bundle/rpc-entry.js +3 -3
  91. package/dist/cli/args.d.ts.map +1 -1
  92. package/dist/cli/args.js +9 -8
  93. package/dist/cli/args.js.map +1 -1
  94. package/dist/config.d.ts +12 -0
  95. package/dist/config.d.ts.map +1 -1
  96. package/dist/config.js +29 -5
  97. package/dist/config.js.map +1 -1
  98. package/dist/coordination/adapter/tool.d.ts +8 -5
  99. package/dist/coordination/adapter/tool.d.ts.map +1 -1
  100. package/dist/coordination/adapter/tool.js +32 -6
  101. package/dist/coordination/adapter/tool.js.map +1 -1
  102. package/dist/coordination/client/client.d.ts.map +1 -1
  103. package/dist/coordination/client/client.js +19 -1
  104. package/dist/coordination/client/client.js.map +1 -1
  105. package/dist/core/agent-session-runtime.js +3 -3
  106. package/dist/core/agent-session-runtime.js.map +1 -1
  107. package/dist/core/agent-session.d.ts +23 -3
  108. package/dist/core/agent-session.d.ts.map +1 -1
  109. package/dist/core/agent-session.js +142 -39
  110. package/dist/core/agent-session.js.map +1 -1
  111. package/dist/core/anthropic-subscription-usage.d.ts +4 -0
  112. package/dist/core/anthropic-subscription-usage.d.ts.map +1 -1
  113. package/dist/core/anthropic-subscription-usage.js +71 -1
  114. package/dist/core/anthropic-subscription-usage.js.map +1 -1
  115. package/dist/core/bug-report.d.ts +4 -4
  116. package/dist/core/codex-reset.d.ts +45 -0
  117. package/dist/core/codex-reset.d.ts.map +1 -0
  118. package/dist/core/codex-reset.js +190 -0
  119. package/dist/core/codex-reset.js.map +1 -0
  120. package/dist/core/codex-usage.d.ts +4 -2
  121. package/dist/core/codex-usage.d.ts.map +1 -1
  122. package/dist/core/codex-usage.js +9 -4
  123. package/dist/core/codex-usage.js.map +1 -1
  124. package/dist/core/compaction/branch-summarization.d.ts +3 -1
  125. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  126. package/dist/core/compaction/branch-summarization.js +25 -10
  127. package/dist/core/compaction/branch-summarization.js.map +1 -1
  128. package/dist/core/compaction/compaction.d.ts +37 -3
  129. package/dist/core/compaction/compaction.d.ts.map +1 -1
  130. package/dist/core/compaction/compaction.js +274 -65
  131. package/dist/core/compaction/compaction.js.map +1 -1
  132. package/dist/core/compaction/utils.d.ts +19 -6
  133. package/dist/core/compaction/utils.d.ts.map +1 -1
  134. package/dist/core/compaction/utils.js +49 -11
  135. package/dist/core/compaction/utils.js.map +1 -1
  136. package/dist/core/exec.d.ts +9 -1
  137. package/dist/core/exec.d.ts.map +1 -1
  138. package/dist/core/exec.js +105 -61
  139. package/dist/core/exec.js.map +1 -1
  140. package/dist/core/export-html/template.css +9 -0
  141. package/dist/core/export-html/template.html +2 -0
  142. package/dist/core/export-html/template.js +200 -62
  143. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  144. package/dist/core/export-html/tool-renderer.js +3 -0
  145. package/dist/core/export-html/tool-renderer.js.map +1 -1
  146. package/dist/core/extensions/index.d.ts +1 -1
  147. package/dist/core/extensions/index.d.ts.map +1 -1
  148. package/dist/core/extensions/index.js.map +1 -1
  149. package/dist/core/extensions/loader.d.ts.map +1 -1
  150. package/dist/core/extensions/loader.js +7 -6
  151. package/dist/core/extensions/loader.js.map +1 -1
  152. package/dist/core/extensions/pi-ai-extension-view.d.ts +19 -0
  153. package/dist/core/extensions/pi-ai-extension-view.d.ts.map +1 -0
  154. package/dist/core/extensions/pi-ai-extension-view.js +22 -0
  155. package/dist/core/extensions/pi-ai-extension-view.js.map +1 -0
  156. package/dist/core/extensions/types.d.ts +27 -4
  157. package/dist/core/extensions/types.d.ts.map +1 -1
  158. package/dist/core/extensions/types.js.map +1 -1
  159. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  160. package/dist/core/extensions/virtual-modules.js +8 -7
  161. package/dist/core/extensions/virtual-modules.js.map +1 -1
  162. package/dist/core/http-dispatcher.d.ts +7 -0
  163. package/dist/core/http-dispatcher.d.ts.map +1 -1
  164. package/dist/core/http-dispatcher.js +107 -0
  165. package/dist/core/http-dispatcher.js.map +1 -1
  166. package/dist/core/keybindings.d.ts +56 -0
  167. package/dist/core/keybindings.d.ts.map +1 -1
  168. package/dist/core/keybindings.js +14 -2
  169. package/dist/core/keybindings.js.map +1 -1
  170. package/dist/core/mcp-servers.d.ts +9 -4
  171. package/dist/core/mcp-servers.d.ts.map +1 -1
  172. package/dist/core/mcp-servers.js +15 -5
  173. package/dist/core/mcp-servers.js.map +1 -1
  174. package/dist/core/model-config.d.ts +1691 -2042
  175. package/dist/core/model-config.d.ts.map +1 -1
  176. package/dist/core/model-config.js +2 -3
  177. package/dist/core/model-config.js.map +1 -1
  178. package/dist/core/model-registry.d.ts +35 -4
  179. package/dist/core/model-registry.d.ts.map +1 -1
  180. package/dist/core/model-registry.js +70 -8
  181. package/dist/core/model-registry.js.map +1 -1
  182. package/dist/core/model-resolver.d.ts.map +1 -1
  183. package/dist/core/model-resolver.js +16 -10
  184. package/dist/core/model-resolver.js.map +1 -1
  185. package/dist/core/model-runtime.d.ts.map +1 -1
  186. package/dist/core/model-runtime.js +21 -17
  187. package/dist/core/model-runtime.js.map +1 -1
  188. package/dist/core/package-manager.d.ts +29 -0
  189. package/dist/core/package-manager.d.ts.map +1 -1
  190. package/dist/core/package-manager.js +311 -60
  191. package/dist/core/package-manager.js.map +1 -1
  192. package/dist/core/pi-ai-schemas.d.ts +164 -0
  193. package/dist/core/pi-ai-schemas.d.ts.map +1 -0
  194. package/dist/core/pi-ai-schemas.js +21 -0
  195. package/dist/core/pi-ai-schemas.js.map +1 -0
  196. package/dist/core/pi-manifest.d.ts +1 -0
  197. package/dist/core/pi-manifest.d.ts.map +1 -1
  198. package/dist/core/pi-manifest.js +4 -0
  199. package/dist/core/pi-manifest.js.map +1 -1
  200. package/dist/core/project-trust.js +1 -1
  201. package/dist/core/project-trust.js.map +1 -1
  202. package/dist/core/resource-loader.d.ts +4 -1
  203. package/dist/core/resource-loader.d.ts.map +1 -1
  204. package/dist/core/resource-loader.js +38 -23
  205. package/dist/core/resource-loader.js.map +1 -1
  206. package/dist/core/sdk.d.ts.map +1 -1
  207. package/dist/core/sdk.js +4 -1
  208. package/dist/core/sdk.js.map +1 -1
  209. package/dist/core/session-manager.d.ts +7 -0
  210. package/dist/core/session-manager.d.ts.map +1 -1
  211. package/dist/core/session-manager.js +66 -26
  212. package/dist/core/session-manager.js.map +1 -1
  213. package/dist/core/settings-defaults.d.ts +2 -0
  214. package/dist/core/settings-defaults.d.ts.map +1 -1
  215. package/dist/core/settings-defaults.js +2 -0
  216. package/dist/core/settings-defaults.js.map +1 -1
  217. package/dist/core/settings-manager.d.ts +19 -8
  218. package/dist/core/settings-manager.d.ts.map +1 -1
  219. package/dist/core/settings-manager.js +70 -16
  220. package/dist/core/settings-manager.js.map +1 -1
  221. package/dist/core/settings-schema.d.ts +15 -2
  222. package/dist/core/settings-schema.d.ts.map +1 -1
  223. package/dist/core/settings-schema.js +37 -3
  224. package/dist/core/settings-schema.js.map +1 -1
  225. package/dist/core/skills.d.ts.map +1 -1
  226. package/dist/core/skills.js +6 -14
  227. package/dist/core/skills.js.map +1 -1
  228. package/dist/core/slash-commands.js +2 -2
  229. package/dist/core/slash-commands.js.map +1 -1
  230. package/dist/core/source-info.d.ts +9 -0
  231. package/dist/core/source-info.d.ts.map +1 -1
  232. package/dist/core/source-info.js +13 -0
  233. package/dist/core/source-info.js.map +1 -1
  234. package/dist/core/subscription-credits.d.ts +14 -0
  235. package/dist/core/subscription-credits.d.ts.map +1 -0
  236. package/dist/core/subscription-credits.js +10 -0
  237. package/dist/core/subscription-credits.js.map +1 -0
  238. package/dist/core/subscription-reset-status.d.ts +10 -0
  239. package/dist/core/subscription-reset-status.d.ts.map +1 -0
  240. package/dist/core/subscription-reset-status.js +2 -0
  241. package/dist/core/subscription-reset-status.js.map +1 -0
  242. package/dist/core/system-prompt.d.ts.map +1 -1
  243. package/dist/core/system-prompt.js +5 -6
  244. package/dist/core/system-prompt.js.map +1 -1
  245. package/dist/core/tools/bash.d.ts +2 -2
  246. package/dist/core/tools/bash.d.ts.map +1 -1
  247. package/dist/core/tools/bash.js.map +1 -1
  248. package/dist/core/tools/edit.d.ts +3 -3
  249. package/dist/core/tools/edit.d.ts.map +1 -1
  250. package/dist/core/tools/edit.js +2 -4
  251. package/dist/core/tools/edit.js.map +1 -1
  252. package/dist/core/tools/find.d.ts +2 -2
  253. package/dist/core/tools/find.d.ts.map +1 -1
  254. package/dist/core/tools/find.js.map +1 -1
  255. package/dist/core/tools/grep.d.ts +2 -2
  256. package/dist/core/tools/grep.d.ts.map +1 -1
  257. package/dist/core/tools/grep.js +7 -3
  258. package/dist/core/tools/grep.js.map +1 -1
  259. package/dist/core/tools/ls.d.ts +2 -2
  260. package/dist/core/tools/ls.d.ts.map +1 -1
  261. package/dist/core/tools/ls.js.map +1 -1
  262. package/dist/core/tools/read.d.ts +2 -2
  263. package/dist/core/tools/read.d.ts.map +1 -1
  264. package/dist/core/tools/read.js.map +1 -1
  265. package/dist/core/tools/render-utils.d.ts +4 -0
  266. package/dist/core/tools/render-utils.d.ts.map +1 -1
  267. package/dist/core/tools/render-utils.js +42 -12
  268. package/dist/core/tools/render-utils.js.map +1 -1
  269. package/dist/core/tools/renderers/edit.d.ts.map +1 -1
  270. package/dist/core/tools/renderers/edit.js +3 -3
  271. package/dist/core/tools/renderers/edit.js.map +1 -1
  272. package/dist/core/tools/renderers/write.d.ts.map +1 -1
  273. package/dist/core/tools/renderers/write.js +37 -29
  274. package/dist/core/tools/renderers/write.js.map +1 -1
  275. package/dist/core/tools/subagent.d.ts +9 -8
  276. package/dist/core/tools/subagent.d.ts.map +1 -1
  277. package/dist/core/tools/subagent.js +8 -5
  278. package/dist/core/tools/subagent.js.map +1 -1
  279. package/dist/core/tools/tool-definition-wrapper.d.ts +11 -1
  280. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  281. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  282. package/dist/core/tools/write.d.ts +2 -2
  283. package/dist/core/tools/write.d.ts.map +1 -1
  284. package/dist/core/tools/write.js.map +1 -1
  285. package/dist/core/trust-manager.d.ts.map +1 -1
  286. package/dist/core/trust-manager.js +14 -8
  287. package/dist/core/trust-manager.js.map +1 -1
  288. package/dist/core/usage-totals.d.ts.map +1 -1
  289. package/dist/core/usage-totals.js +2 -0
  290. package/dist/core/usage-totals.js.map +1 -1
  291. package/dist/extensions/codemode/renderer.d.ts.map +1 -1
  292. package/dist/extensions/codemode/renderer.js +17 -9
  293. package/dist/extensions/codemode/renderer.js.map +1 -1
  294. package/dist/extensions/codemode/tool.d.ts +2 -1
  295. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  296. package/dist/extensions/codemode/tool.js +33 -8
  297. package/dist/extensions/codemode/tool.js.map +1 -1
  298. package/dist/extensions/llama/ui.d.ts.map +1 -1
  299. package/dist/extensions/llama/ui.js +16 -4
  300. package/dist/extensions/llama/ui.js.map +1 -1
  301. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  302. package/dist/extensions/mcp/cli.js +34 -8
  303. package/dist/extensions/mcp/cli.js.map +1 -1
  304. package/dist/extensions/mcp/index.js +4 -3
  305. package/dist/extensions/mcp/index.js.map +1 -1
  306. package/dist/extensions/mcp/oauth.d.ts +1 -1
  307. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  308. package/dist/extensions/mcp/oauth.js +7 -3
  309. package/dist/extensions/mcp/oauth.js.map +1 -1
  310. package/dist/extensions/mcp/ui.d.ts +1 -0
  311. package/dist/extensions/mcp/ui.d.ts.map +1 -1
  312. package/dist/extensions/mcp/ui.js +56 -28
  313. package/dist/extensions/mcp/ui.js.map +1 -1
  314. package/dist/extensions/tool-search/tool.d.ts +21 -6
  315. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  316. package/dist/extensions/tool-search/tool.js +104 -36
  317. package/dist/extensions/tool-search/tool.js.map +1 -1
  318. package/dist/extensions/usage/confirmation.d.ts +40 -0
  319. package/dist/extensions/usage/confirmation.d.ts.map +1 -0
  320. package/dist/extensions/usage/confirmation.js +198 -0
  321. package/dist/extensions/usage/confirmation.js.map +1 -0
  322. package/dist/extensions/usage/index.d.ts +4 -4
  323. package/dist/extensions/usage/index.d.ts.map +1 -1
  324. package/dist/extensions/usage/index.js +352 -33
  325. package/dist/extensions/usage/index.js.map +1 -1
  326. package/dist/extensions/usage/overview.d.ts +8 -1
  327. package/dist/extensions/usage/overview.d.ts.map +1 -1
  328. package/dist/extensions/usage/overview.js +54 -11
  329. package/dist/extensions/usage/overview.js.map +1 -1
  330. package/dist/extensions/usage/popup.d.ts +37 -6
  331. package/dist/extensions/usage/popup.d.ts.map +1 -1
  332. package/dist/extensions/usage/popup.js +396 -45
  333. package/dist/extensions/usage/popup.js.map +1 -1
  334. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +564 -130
  335. package/dist/humain/node-provider.d.ts.map +1 -1
  336. package/dist/humain/node-provider.js +1 -0
  337. package/dist/humain/node-provider.js.map +1 -1
  338. package/dist/humain/web-access/host.d.ts +2 -1
  339. package/dist/humain/web-access/host.d.ts.map +1 -1
  340. package/dist/humain/web-access/host.js +1 -1
  341. package/dist/humain/web-access/host.js.map +1 -1
  342. package/dist/humain/web-access/vendor/brave-rate-limit.d.ts +2 -0
  343. package/dist/humain/web-access/vendor/brave-rate-limit.d.ts.map +1 -1
  344. package/dist/humain/web-access/vendor/brave-rate-limit.js +2 -2
  345. package/dist/humain/web-access/vendor/brave-rate-limit.js.map +1 -1
  346. package/dist/humain/web-access/vendor/cloudflare-search.d.ts +5 -0
  347. package/dist/humain/web-access/vendor/cloudflare-search.d.ts.map +1 -0
  348. package/dist/humain/web-access/vendor/cloudflare-search.js +230 -0
  349. package/dist/humain/web-access/vendor/cloudflare-search.js.map +1 -0
  350. package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
  351. package/dist/humain/web-access/vendor/curator-page.js +18 -1
  352. package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
  353. package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
  354. package/dist/humain/web-access/vendor/curator-server.js +12 -0
  355. package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
  356. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts +33 -0
  357. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts.map +1 -0
  358. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js +84 -0
  359. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js.map +1 -0
  360. package/dist/humain/web-access/vendor/duckduckgo.d.ts +3 -0
  361. package/dist/humain/web-access/vendor/duckduckgo.d.ts.map +1 -1
  362. package/dist/humain/web-access/vendor/duckduckgo.js +54 -49
  363. package/dist/humain/web-access/vendor/duckduckgo.js.map +1 -1
  364. package/dist/humain/web-access/vendor/exa.d.ts +8 -3
  365. package/dist/humain/web-access/vendor/exa.d.ts.map +1 -1
  366. package/dist/humain/web-access/vendor/exa.js +129 -14
  367. package/dist/humain/web-access/vendor/exa.js.map +1 -1
  368. package/dist/humain/web-access/vendor/extract.d.ts +1 -1
  369. package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
  370. package/dist/humain/web-access/vendor/extract.js +68 -10
  371. package/dist/humain/web-access/vendor/extract.js.map +1 -1
  372. package/dist/humain/web-access/vendor/fetch-params.d.ts +2 -1
  373. package/dist/humain/web-access/vendor/fetch-params.d.ts.map +1 -1
  374. package/dist/humain/web-access/vendor/fetch-params.js +2 -2
  375. package/dist/humain/web-access/vendor/fetch-params.js.map +1 -1
  376. package/dist/humain/web-access/vendor/field-extract.d.ts +38 -0
  377. package/dist/humain/web-access/vendor/field-extract.d.ts.map +1 -0
  378. package/dist/humain/web-access/vendor/field-extract.js +350 -0
  379. package/dist/humain/web-access/vendor/field-extract.js.map +1 -0
  380. package/dist/humain/web-access/vendor/gemini-search.d.ts +15 -4
  381. package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
  382. package/dist/humain/web-access/vendor/gemini-search.js +198 -16
  383. package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
  384. package/dist/humain/web-access/vendor/github-api.js +1 -1
  385. package/dist/humain/web-access/vendor/github-api.js.map +1 -1
  386. package/dist/humain/web-access/vendor/github-extract.d.ts.map +1 -1
  387. package/dist/humain/web-access/vendor/github-extract.js +3 -2
  388. package/dist/humain/web-access/vendor/github-extract.js.map +1 -1
  389. package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
  390. package/dist/humain/web-access/vendor/index.js +137 -118
  391. package/dist/humain/web-access/vendor/index.js.map +1 -1
  392. package/dist/humain/web-access/vendor/mistral-search.js +1 -1
  393. package/dist/humain/web-access/vendor/mistral-search.js.map +1 -1
  394. package/dist/humain/web-access/vendor/ninerouter.d.ts +4 -0
  395. package/dist/humain/web-access/vendor/ninerouter.d.ts.map +1 -0
  396. package/dist/humain/web-access/vendor/ninerouter.js +110 -0
  397. package/dist/humain/web-access/vendor/ninerouter.js.map +1 -0
  398. package/dist/humain/web-access/vendor/offtopic-judge.d.ts +27 -0
  399. package/dist/humain/web-access/vendor/offtopic-judge.d.ts.map +1 -0
  400. package/dist/humain/web-access/vendor/offtopic-judge.js +61 -0
  401. package/dist/humain/web-access/vendor/offtopic-judge.js.map +1 -0
  402. package/dist/humain/web-access/vendor/openai-search.d.ts +1 -1
  403. package/dist/humain/web-access/vendor/openai-search.d.ts.map +1 -1
  404. package/dist/humain/web-access/vendor/openai-search.js +39 -13
  405. package/dist/humain/web-access/vendor/openai-search.js.map +1 -1
  406. package/dist/humain/web-access/vendor/outcrawl.d.ts +4 -0
  407. package/dist/humain/web-access/vendor/outcrawl.d.ts.map +1 -0
  408. package/dist/humain/web-access/vendor/outcrawl.js +196 -0
  409. package/dist/humain/web-access/vendor/outcrawl.js.map +1 -0
  410. package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
  411. package/dist/humain/web-access/vendor/page-query.js +13 -3
  412. package/dist/humain/web-access/vendor/page-query.js.map +1 -1
  413. package/dist/humain/web-access/vendor/pdf-extract.d.ts +1 -3
  414. package/dist/humain/web-access/vendor/pdf-extract.d.ts.map +1 -1
  415. package/dist/humain/web-access/vendor/pdf-extract.js +0 -2
  416. package/dist/humain/web-access/vendor/pdf-extract.js.map +1 -1
  417. package/dist/humain/web-access/vendor/perplexity.d.ts +3 -0
  418. package/dist/humain/web-access/vendor/perplexity.d.ts.map +1 -1
  419. package/dist/humain/web-access/vendor/perplexity.js.map +1 -1
  420. package/dist/humain/web-access/vendor/query-rewrite.d.ts +2 -2
  421. package/dist/humain/web-access/vendor/query-rewrite.d.ts.map +1 -1
  422. package/dist/humain/web-access/vendor/query-rewrite.js +39 -13
  423. package/dist/humain/web-access/vendor/query-rewrite.js.map +1 -1
  424. package/dist/humain/web-access/vendor/searchapi.d.ts +4 -0
  425. package/dist/humain/web-access/vendor/searchapi.d.ts.map +1 -0
  426. package/dist/humain/web-access/vendor/searchapi.js +195 -0
  427. package/dist/humain/web-access/vendor/searchapi.js.map +1 -0
  428. package/dist/humain/web-access/vendor/sofya.d.ts +4 -0
  429. package/dist/humain/web-access/vendor/sofya.d.ts.map +1 -0
  430. package/dist/humain/web-access/vendor/sofya.js +193 -0
  431. package/dist/humain/web-access/vendor/sofya.js.map +1 -0
  432. package/dist/humain/web-access/vendor/source-check.d.ts +5 -1
  433. package/dist/humain/web-access/vendor/source-check.d.ts.map +1 -1
  434. package/dist/humain/web-access/vendor/source-check.js +34 -16
  435. package/dist/humain/web-access/vendor/source-check.js.map +1 -1
  436. package/dist/humain/web-access/vendor/ssrf-protection.d.ts +7 -0
  437. package/dist/humain/web-access/vendor/ssrf-protection.d.ts.map +1 -1
  438. package/dist/humain/web-access/vendor/ssrf-protection.js +24 -1
  439. package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -1
  440. package/dist/humain/web-access/vendor/summary-model-scope.d.ts +8 -3
  441. package/dist/humain/web-access/vendor/summary-model-scope.d.ts.map +1 -1
  442. package/dist/humain/web-access/vendor/summary-model-scope.js +15 -1
  443. package/dist/humain/web-access/vendor/summary-model-scope.js.map +1 -1
  444. package/dist/humain/web-access/vendor/summary-review.d.ts +7 -2
  445. package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -1
  446. package/dist/humain/web-access/vendor/summary-review.js +32 -28
  447. package/dist/humain/web-access/vendor/summary-review.js.map +1 -1
  448. package/dist/humain/web-access/vendor/tabstack.d.ts +6 -0
  449. package/dist/humain/web-access/vendor/tabstack.d.ts.map +1 -0
  450. package/dist/humain/web-access/vendor/tabstack.js +236 -0
  451. package/dist/humain/web-access/vendor/tabstack.js.map +1 -0
  452. package/dist/humain/web-access/vendor/tool-arguments.js +1 -1
  453. package/dist/humain/web-access/vendor/tool-arguments.js.map +1 -1
  454. package/dist/humain/web-access/vendor/upgrade-notice.d.ts +8 -0
  455. package/dist/humain/web-access/vendor/upgrade-notice.d.ts.map +1 -0
  456. package/dist/humain/web-access/vendor/upgrade-notice.js +46 -0
  457. package/dist/humain/web-access/vendor/upgrade-notice.js.map +1 -0
  458. package/dist/humain/web-access/vendor/utils.d.ts +9 -0
  459. package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
  460. package/dist/humain/web-access/vendor/utils.js +113 -27
  461. package/dist/humain/web-access/vendor/utils.js.map +1 -1
  462. package/dist/humain/web-access/vendor/web-tool-contract.d.ts +4 -0
  463. package/dist/humain/web-access/vendor/web-tool-contract.d.ts.map +1 -1
  464. package/dist/humain/web-access/vendor/web-tool-contract.js.map +1 -1
  465. package/dist/humain/web-access/vendor/web-tool-core.d.ts +17 -1
  466. package/dist/humain/web-access/vendor/web-tool-core.d.ts.map +1 -1
  467. package/dist/humain/web-access/vendor/web-tool-core.js +99 -22
  468. package/dist/humain/web-access/vendor/web-tool-core.js.map +1 -1
  469. package/dist/humain/web-access/vendor/xai-search.d.ts +1 -1
  470. package/dist/humain/web-access/vendor/xai-search.d.ts.map +1 -1
  471. package/dist/humain/web-access/vendor/xai-search.js +6 -5
  472. package/dist/humain/web-access/vendor/xai-search.js.map +1 -1
  473. package/dist/index.d.ts +3 -3
  474. package/dist/index.d.ts.map +1 -1
  475. package/dist/index.js.map +1 -1
  476. package/dist/main.d.ts.map +1 -1
  477. package/dist/main.js +20 -9
  478. package/dist/main.js.map +1 -1
  479. package/dist/modes/interactive/components/assistant-code-block.d.ts +34 -0
  480. package/dist/modes/interactive/components/assistant-code-block.d.ts.map +1 -0
  481. package/dist/modes/interactive/components/assistant-code-block.js +160 -0
  482. package/dist/modes/interactive/components/assistant-code-block.js.map +1 -0
  483. package/dist/modes/interactive/components/assistant-message.d.ts +31 -10
  484. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  485. package/dist/modes/interactive/components/assistant-message.js +276 -73
  486. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  487. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  488. package/dist/modes/interactive/components/compaction-summary-message.js +2 -1
  489. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  490. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  491. package/dist/modes/interactive/components/config-selector.js +4 -17
  492. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  493. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  494. package/dist/modes/interactive/components/custom-editor.js +7 -0
  495. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  496. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  497. package/dist/modes/interactive/components/custom-entry.js +2 -1
  498. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  499. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  500. package/dist/modes/interactive/components/custom-message.js +2 -1
  501. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  502. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  503. package/dist/modes/interactive/components/diff.js +3 -1
  504. package/dist/modes/interactive/components/diff.js.map +1 -1
  505. package/dist/modes/interactive/components/extension-editor.d.ts +2 -0
  506. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  507. package/dist/modes/interactive/components/extension-editor.js +4 -0
  508. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  509. package/dist/modes/interactive/components/footer.d.ts +4 -1
  510. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  511. package/dist/modes/interactive/components/footer.js +6 -5
  512. package/dist/modes/interactive/components/footer.js.map +1 -1
  513. package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
  514. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  515. package/dist/modes/interactive/components/login-dialog.js +107 -11
  516. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  517. package/dist/modes/interactive/components/markdown-transform.d.ts +2 -1
  518. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
  519. package/dist/modes/interactive/components/markdown-transform.js +3 -2
  520. package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
  521. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  522. package/dist/modes/interactive/components/mermaid.js +18 -6
  523. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  524. package/dist/modes/interactive/components/model-selector.d.ts +1 -0
  525. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  526. package/dist/modes/interactive/components/model-selector.js +17 -6
  527. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  528. package/dist/modes/interactive/components/oauth-selector.d.ts +1 -0
  529. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  530. package/dist/modes/interactive/components/oauth-selector.js +13 -4
  531. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  532. package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
  533. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  534. package/dist/modes/interactive/components/scoped-models-selector.js +14 -3
  535. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  536. package/dist/modes/interactive/components/session-selector-search.d.ts +4 -0
  537. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  538. package/dist/modes/interactive/components/session-selector-search.js +86 -22
  539. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  540. package/dist/modes/interactive/components/session-selector.d.ts +2 -1
  541. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  542. package/dist/modes/interactive/components/session-selector.js +16 -24
  543. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  544. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  545. package/dist/modes/interactive/components/settings-submenu.js +2 -0
  546. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  547. package/dist/modes/interactive/components/tool-execution.d.ts +2 -0
  548. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  549. package/dist/modes/interactive/components/tool-execution.js +15 -5
  550. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  551. package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
  552. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  553. package/dist/modes/interactive/components/tree-selector.js +5 -6
  554. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  555. package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
  556. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  557. package/dist/modes/interactive/components/user-message-selector.js +9 -1
  558. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  559. package/dist/modes/interactive/components/user-message.d.ts +4 -3
  560. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  561. package/dist/modes/interactive/components/user-message.js +20 -18
  562. package/dist/modes/interactive/components/user-message.js.map +1 -1
  563. package/dist/modes/interactive/external-editor.d.ts +1 -0
  564. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  565. package/dist/modes/interactive/external-editor.js +16 -4
  566. package/dist/modes/interactive/external-editor.js.map +1 -1
  567. package/dist/modes/interactive/interactive-mode.d.ts +6 -0
  568. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  569. package/dist/modes/interactive/interactive-mode.js +259 -83
  570. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  571. package/dist/modes/interactive/model-search.d.ts +10 -0
  572. package/dist/modes/interactive/model-search.d.ts.map +1 -1
  573. package/dist/modes/interactive/model-search.js +21 -0
  574. package/dist/modes/interactive/model-search.js.map +1 -1
  575. package/dist/modes/interactive/oauth-account-format.d.ts +10 -1
  576. package/dist/modes/interactive/oauth-account-format.d.ts.map +1 -1
  577. package/dist/modes/interactive/oauth-account-format.js +42 -0
  578. package/dist/modes/interactive/oauth-account-format.js.map +1 -1
  579. package/dist/modes/interactive/theme/theme.d.ts +10 -0
  580. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  581. package/dist/modes/interactive/theme/theme.js +28 -24
  582. package/dist/modes/interactive/theme/theme.js.map +1 -1
  583. package/dist/modes/print-mode.d.ts.map +1 -1
  584. package/dist/modes/print-mode.js +3 -2
  585. package/dist/modes/print-mode.js.map +1 -1
  586. package/dist/package-manager-cli.d.ts.map +1 -1
  587. package/dist/package-manager-cli.js +55 -4
  588. package/dist/package-manager-cli.js.map +1 -1
  589. package/dist/utils/ansi.d.ts.map +1 -1
  590. package/dist/utils/ansi.js +5 -2
  591. package/dist/utils/ansi.js.map +1 -1
  592. package/dist/utils/clipboard-command.d.ts.map +1 -1
  593. package/dist/utils/clipboard-command.js +4 -0
  594. package/dist/utils/clipboard-command.js.map +1 -1
  595. package/dist/utils/clipboard-image.d.ts +8 -0
  596. package/dist/utils/clipboard-image.d.ts.map +1 -1
  597. package/dist/utils/clipboard-image.js +31 -1
  598. package/dist/utils/clipboard-image.js.map +1 -1
  599. package/dist/utils/git.d.ts +1 -1
  600. package/dist/utils/git.d.ts.map +1 -1
  601. package/dist/utils/git.js.map +1 -1
  602. package/dist/utils/image-resize-core.d.ts.map +1 -1
  603. package/dist/utils/image-resize-core.js +5 -3
  604. package/dist/utils/image-resize-core.js.map +1 -1
  605. package/dist/utils/open-browser.d.ts.map +1 -1
  606. package/dist/utils/open-browser.js +96 -6
  607. package/dist/utils/open-browser.js.map +1 -1
  608. package/dist/utils/paths.d.ts +17 -0
  609. package/dist/utils/paths.d.ts.map +1 -1
  610. package/dist/utils/paths.js +42 -1
  611. package/dist/utils/paths.js.map +1 -1
  612. package/dist/utils/shell.d.ts +2 -1
  613. package/dist/utils/shell.d.ts.map +1 -1
  614. package/dist/utils/shell.js +12 -2
  615. package/dist/utils/shell.js.map +1 -1
  616. package/dist/utils/syntax-highlight.d.ts +5 -0
  617. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  618. package/dist/utils/syntax-highlight.js +156 -11
  619. package/dist/utils/syntax-highlight.js.map +1 -1
  620. package/dist/utils/tools-manager.d.ts.map +1 -1
  621. package/dist/utils/tools-manager.js +30 -35
  622. package/dist/utils/tools-manager.js.map +1 -1
  623. package/docs/cli.md +22 -12
  624. package/docs/compaction.md +32 -8
  625. package/docs/coordination.md +2 -0
  626. package/docs/custom-provider.md +4 -2
  627. package/docs/environment-variables.md +2 -0
  628. package/docs/extensions.md +3169 -229
  629. package/docs/flow.md +2 -0
  630. package/docs/keybindings.md +24 -2
  631. package/docs/llama-cpp.md +30 -19
  632. package/docs/mcp.md +4 -2
  633. package/docs/message-types.md +7 -7
  634. package/docs/packages.md +27 -1
  635. package/docs/sessions.md +11 -3
  636. package/docs/settings.md +21 -9
  637. package/docs/slash-commands.md +51 -11
  638. package/docs/terminal-setup.md +3 -1
  639. package/docs/tmux.md +6 -0
  640. package/docs/tui.md +3 -1
  641. package/docs/windows.md +27 -0
  642. package/examples/extensions/README.md +2 -1
  643. package/examples/extensions/custom-provider-anthropic/index.ts +27 -31
  644. package/examples/extensions/custom-provider-anthropic/package-lock.json +7 -7
  645. package/examples/extensions/custom-provider-anthropic/package.json +2 -2
  646. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  647. package/examples/extensions/debug-provider.ts +2 -2
  648. package/examples/extensions/gondolin/package-lock.json +14 -24
  649. package/examples/extensions/gondolin/package.json +2 -2
  650. package/examples/extensions/preset.ts +2 -0
  651. package/examples/extensions/reload-runtime.ts +17 -5
  652. package/examples/extensions/todo.ts +7 -0
  653. package/examples/extensions/tools.ts +2 -0
  654. package/examples/extensions/with-deps/package-lock.json +2 -2
  655. package/examples/extensions/with-deps/package.json +1 -1
  656. package/examples/tsconfig.json +252 -0
  657. package/npm-shrinkwrap.json +289 -277
  658. package/package.json +29 -29
  659. package/schemas/keybindings.schema.json +28 -0
  660. package/schemas/models.schema.json +36 -36
  661. package/schemas/settings.schema.json +49 -0
  662. package/src/humain/ponytail/UPSTREAM.md +16 -2
  663. package/src/humain/ponytail/upstream.json +4 -4
  664. package/src/humain/web-access/UPSTREAM.md +48 -1
  665. package/src/humain/web-access/upstream.json +9 -6
  666. package/src/humain/web-access/vendor/CHANGELOG.md +1223 -0
  667. package/dist/bundle/chunks/anthropic-messages-ZP5KUK52.js +0 -67
  668. package/dist/bundle/chunks/azure-openai-responses-QJFYQ3DF.js +0 -15
  669. package/dist/bundle/chunks/chunk-2GCMACT4.js +0 -1956
  670. package/dist/bundle/chunks/chunk-AO6FF5JL.js +0 -21
  671. package/dist/bundle/chunks/chunk-EY3LZOUP.js +0 -1963
  672. package/dist/bundle/chunks/chunk-M74U5X4S.js +0 -119
  673. package/dist/bundle/chunks/chunk-N7CQ3UV3.js +0 -80
  674. package/dist/bundle/chunks/chunk-OR25QDSS.js +0 -365
  675. package/dist/bundle/chunks/chunk-PH7UP57J.js +0 -6
  676. package/dist/bundle/chunks/chunk-QW6PTCAB.js +0 -10
  677. package/dist/bundle/chunks/chunk-ROZV2IYD.js +0 -125
  678. package/dist/bundle/chunks/chunk-YFOLLX5D.js +0 -23
  679. package/dist/bundle/chunks/chunk-ZR4GF4WU.js +0 -54
  680. package/dist/bundle/chunks/compat-CJBWWYHE.js +0 -13
  681. package/dist/bundle/chunks/dist-IBUWEKEE.js +0 -24
  682. package/dist/bundle/chunks/dist-YFMJEHPH.js +0 -8
  683. package/dist/bundle/chunks/google-generative-ai-HVPCGIZ6.js +0 -21
  684. package/dist/bundle/chunks/google-vertex-UM5MAALA.js +0 -25
  685. package/dist/bundle/chunks/host-ZHEL5XQW.js +0 -2
  686. package/dist/bundle/chunks/mistral-conversations-AH72RLXK.js +0 -44
  687. package/dist/bundle/chunks/openai-codex-responses-L366637C.js +0 -98
  688. package/dist/bundle/chunks/openai-completions-ZP62QXJX.js +0 -83
  689. package/dist/bundle/chunks/openai-responses-DXUGSUTN.js +0 -26
  690. package/dist/bundle/chunks/pi-messages-MOQQDZBK.js +0 -23
  691. package/dist/bundle/chunks/virtual-modules-5D6QIJPN.js +0 -5
  692. package/examples/extensions/sandbox/index.ts +0 -321
  693. package/examples/extensions/sandbox/package-lock.json +0 -66
  694. package/examples/extensions/sandbox/package.json +0 -19
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
2
  import{ArrayOptions,Evaluate,Flatten,Get,Get2,Instantiate,Intersect,IsArray,IsBigInt,IsBoolean,IsCodec,IsConstructor,IsCyclic,IsEnum,IsFunction,IsInteger,IsIntersect,IsLiteral,IsLiteralBigInt,IsLiteralBoolean,IsLiteralNumber,IsLiteralString,IsNever,IsNull,IsNumber,IsObject,IsOptional,IsRecord,IsRef,IsRefine,IsSchema,IsString,IsSymbol,IsTemplateLiteral,IsTuple,IsUndefined,IsUnion,IsVoid,Literal,Priority,Record,RecordPattern,RecordValue,Ref,String as String2,TemplateLiteralDecode,Tuple,Union,Unknown,
3
- Unreachable,With,_Array_,_Object_,arguments_exports,emit_exports,environment_exports,globals_exports,guard_default,guard_exports,hash_exports,memory_exports,settings_exports}from"./chunk-HIZWUSPN.js";import{__export}from"./chunk-JXWJOIH4.js";var value_exports2={};__export(value_exports2,{Assert:()=>Assert,AssertError:()=>AssertError,Check:()=>Check2,Clean:()=>Clean,Clone:()=>Clone,Convert:()=>Convert,Create:()=>Create,CreateError:()=>CreateError,Decode:()=>Decode9,DecodeError:()=>DecodeError,DecodeUnsafe:()=>DecodeUnsafe,Default:()=>Default,Delete:()=>Delete2,Diff:()=>Diff,Edit:()=>Edit,Encode:()=>Encode9,EncodeError:()=>EncodeError,EncodeUnsafe:()=>EncodeUnsafe,Equal:()=>Equal,Errors:()=>Errors2,HasCodec:()=>HasCodec,Hash:()=>Hash,
3
+ Unreachable,With,_Array_,_Object_,arguments_exports,emit_exports,environment_exports,globals_exports,guard_default,guard_exports,hash_exports,memory_exports,settings_exports,typebox_exports}from"./chunk-VEGJT52D.js";import{ENV_PREFIX,getAgentDir,getPackageDir,isBunBinary,isBunRuntime,isBundledNode}from"./chunk-IADQJFNH.js";import{__export}from"./chunk-JXWJOIH4.js";var value_exports2={};__export(value_exports2,{Assert:()=>Assert,AssertError:()=>AssertError,Check:()=>Check2,Clean:()=>Clean,Clone:()=>Clone,Convert:()=>Convert,Create:()=>Create,CreateError:()=>CreateError,Decode:()=>Decode9,DecodeError:()=>DecodeError,DecodeUnsafe:()=>DecodeUnsafe,Default:()=>Default,Delete:()=>Delete2,Diff:()=>Diff,Edit:()=>Edit,Encode:()=>Encode9,EncodeError:()=>EncodeError,EncodeUnsafe:()=>EncodeUnsafe,Equal:()=>Equal,Errors:()=>Errors2,HasCodec:()=>HasCodec,Hash:()=>Hash,
4
4
  Insert:()=>Insert,IsOptionalUndefined:()=>IsOptionalUndefined,Parse:()=>Parse,ParseError:()=>ParseError,Parser:()=>Parser,Patch:()=>Patch,Pipeline:()=>Pipeline,Pointer:()=>pointer_exports,Repair:()=>Repair,UnionPrioritySort:()=>UnionPrioritySort,UnionScoreSelect:()=>UnionScoreSelect,Update:()=>Update,Value:()=>value_exports,default:()=>value_default});function IsRefine2(value){return guard_exports.HasPropertyKey(value,"~refine")&&guard_exports.IsArray(value["~refine"])&&guard_exports.Every(value["~refine"],0,value2=>guard_exports.IsObject(value2)&&guard_exports.HasPropertyKey(value2,"check")&&guard_exports.HasPropertyKey(value2,"error")&&guard_exports.IsFunction(value2.check)&&guard_exports.IsFunction(value2.error))}function IsSchemaObject(value){return guard_exports.IsObject(value)&&!guard_exports.IsArray(value)}function IsSchemaBoolean(value){return guard_exports.IsBoolean(value)}function IsSchema2(value){return IsSchemaObject(value)||IsSchemaBoolean(value)}function IsAdditionalItems(schema){return guard_exports.HasPropertyKey(schema,"additionalItems")&&IsSchema2(schema.additionalItems)}function IsAdditionalProperties(schema){return guard_exports.HasPropertyKey(schema,"additionalProperties")&&IsSchema2(schema.additionalProperties)}function IsAllOf(schema){return guard_exports.HasPropertyKey(schema,"allOf")&&guard_exports.IsArray(schema.allOf)&&schema.allOf.every(value=>IsSchema2(value))}function IsAnchor(schema){return guard_exports.HasPropertyKey(schema,"$anchor")&&guard_exports.IsString(schema.$anchor)}function IsAnyOf(schema){return guard_exports.HasPropertyKey(schema,"anyOf")&&guard_exports.IsArray(schema.anyOf)&&schema.anyOf.every(value=>IsSchema2(value))}function IsConst(value){return guard_exports.HasPropertyKey(value,"const")}function IsContains(schema){return guard_exports.HasPropertyKey(schema,"contains")&&IsSchema2(schema.contains)}function IsDefault(schema){return guard_exports.HasPropertyKey(schema,"default")}function IsDependencies(schema){return guard_exports.HasPropertyKey(schema,"dependencies")&&guard_exports.IsObject(schema.dependencies)&&Object.values(schema.dependencies).every(value=>IsSchema2(value)||guard_exports.IsArray(value)&&value.every(value2=>guard_exports.IsString(value2)))}function IsDependentRequired(schema){return guard_exports.HasPropertyKey(schema,"dependentRequired")&&guard_exports.IsObject(schema.dependentRequired)&&Object.values(schema.dependentRequired).every(value=>guard_exports.IsArray(value)&&value.every(value2=>guard_exports.IsString(value2)))}function IsDependentSchemas(schema){return guard_exports.HasPropertyKey(schema,"dependentSchemas")&&guard_exports.IsObject(schema.dependentSchemas)&&Object.values(schema.dependentSchemas).every(value=>IsSchema2(value))}function IsDynamicAnchor(schema){return guard_exports.HasPropertyKey(schema,"$dynamicAnchor")&&guard_exports.IsString(schema.$dynamicAnchor)}function IsDynamicRef(schema){return guard_exports.HasPropertyKey(schema,"$dynamicRef")&&guard_exports.IsString(schema.$dynamicRef)}function IsElse(schema){return guard_exports.HasPropertyKey(schema,"else")&&IsSchema2(schema.else)}function IsEnum2(schema){return guard_exports.HasPropertyKey(schema,"enum")&&guard_exports.IsArray(schema.enum)}function IsExclusiveMaximum(schema){return guard_exports.HasPropertyKey(schema,"exclusiveMaximum")&&(guard_exports.IsNumber(schema.exclusiveMaximum)||guard_exports.IsBigInt(schema.exclusiveMaximum))}function IsExclusiveMinimum(schema){return guard_exports.HasPropertyKey(schema,"exclusiveMinimum")&&(guard_exports.IsNumber(schema.exclusiveMinimum)||guard_exports.IsBigInt(schema.exclusiveMinimum))}function IsFormat(schema){return guard_exports.HasPropertyKey(schema,"format")&&guard_exports.IsString(schema.format)}function IsId(schema){return guard_exports.HasPropertyKey(schema,"$id")&&guard_exports.IsString(schema.$id)}function IsIf(schema){return guard_exports.HasPropertyKey(schema,"if")&&IsSchema2(schema.if)}function IsItems(schema){return guard_exports.HasPropertyKey(schema,"items")&&(IsSchema2(schema.items)||guard_exports.IsArray(schema.items)&&schema.items.every(value=>IsSchema2(value)))}function IsItemsSized(schema){return IsItems(schema)&&guard_exports.IsArray(schema.items)}function IsMaximum(schema){return guard_exports.HasPropertyKey(schema,"maximum")&&(guard_exports.IsNumber(schema.maximum)||guard_exports.IsBigInt(schema.maximum))}function IsMaxContains(schema){return guard_exports.HasPropertyKey(schema,"maxContains")&&guard_exports.IsNumber(schema.maxContains)}function IsMaxItems(schema){return guard_exports.HasPropertyKey(schema,"maxItems")&&guard_exports.IsNumber(schema.maxItems)}function IsMaxLength(schema){return guard_exports.HasPropertyKey(schema,"maxLength")&&guard_exports.IsNumber(schema.maxLength)}function IsMaxProperties(schema){return guard_exports.HasPropertyKey(schema,"maxProperties")&&guard_exports.IsNumber(schema.maxProperties)}function IsMinimum(schema){return guard_exports.HasPropertyKey(schema,"minimum")&&(guard_exports.IsNumber(schema.minimum)||guard_exports.IsBigInt(schema.minimum))}function IsMinContains(schema){return guard_exports.HasPropertyKey(schema,"minContains")&&guard_exports.IsNumber(schema.minContains)}function IsMinItems(schema){return guard_exports.HasPropertyKey(schema,"minItems")&&guard_exports.IsNumber(schema.minItems)}function IsMinLength(schema){return guard_exports.HasPropertyKey(schema,"minLength")&&guard_exports.IsNumber(schema.minLength)}function IsMinProperties(schema){return guard_exports.HasPropertyKey(schema,"minProperties")&&guard_exports.IsNumber(schema.minProperties)}function IsMultipleOf(schema){return guard_exports.HasPropertyKey(schema,"multipleOf")&&(guard_exports.IsNumber(schema.multipleOf)||guard_exports.IsBigInt(schema.multipleOf))}function IsNot(schema){return guard_exports.HasPropertyKey(schema,"not")&&IsSchema2(schema.not)}function IsOneOf(schema){return guard_exports.HasPropertyKey(schema,"oneOf")&&guard_exports.IsArray(schema.oneOf)&&schema.oneOf.every(value=>IsSchema2(value))}function IsPattern(schema){return guard_exports.HasPropertyKey(schema,"pattern")&&(guard_exports.IsString(schema.pattern)||schema.pattern instanceof RegExp)}function IsPatternProperties(schema){return guard_exports.HasPropertyKey(schema,"patternProperties")&&guard_exports.IsObject(schema.patternProperties)&&Object.values(schema.patternProperties).every(value=>IsSchema2(value))}function IsPrefixItems(schema){return guard_exports.HasPropertyKey(schema,"prefixItems")&&guard_exports.IsArray(schema.prefixItems)&&schema.prefixItems.every(schema2=>IsSchema2(schema2))}function IsProperties(schema){return guard_exports.HasPropertyKey(schema,"properties")&&guard_exports.IsObject(schema.properties)&&Object.values(schema.properties).every(value=>IsSchema2(value))}function IsPropertyNames(schema){return guard_exports.HasPropertyKey(schema,"propertyNames")&&(guard_exports.IsObject(schema.propertyNames)||IsSchema2(schema.propertyNames))}function IsRecursiveAnchor(schema){return guard_exports.HasPropertyKey(schema,"$recursiveAnchor")&&guard_exports.IsBoolean(schema.$recursiveAnchor)}function IsRecursiveAnchorTrue(schema){return IsRecursiveAnchor(schema)&&guard_exports.IsEqual(schema.$recursiveAnchor,!0)}function IsRecursiveRef(schema){return guard_exports.HasPropertyKey(schema,"$recursiveRef")&&guard_exports.IsString(schema.$recursiveRef)}function IsRef2(schema){return guard_exports.HasPropertyKey(schema,"$ref")&&guard_exports.IsString(schema.$ref)}function IsRequired(schema){return guard_exports.HasPropertyKey(schema,"required")&&guard_exports.IsArray(schema.required)&&schema.required.every(value=>guard_exports.IsString(value))}function IsThen(schema){return guard_exports.HasPropertyKey(schema,"then")&&IsSchema2(schema.then)}function IsType(schema){return guard_exports.HasPropertyKey(schema,"type")&&(guard_exports.IsString(schema.type)||guard_exports.IsArray(schema.type)&&schema.type.every(value=>guard_exports.IsString(value)))}function IsUniqueItems(schema){return guard_exports.HasPropertyKey(schema,"uniqueItems")&&guard_exports.IsBoolean(schema.uniqueItems)}function IsUnevaluatedItems(schema){return guard_exports.HasPropertyKey(schema,"unevaluatedItems")&&IsSchema2(schema.unevaluatedItems)}function IsUnevaluatedProperties(schema){return guard_exports.HasPropertyKey(schema,"unevaluatedProperties")&&IsSchema2(schema.unevaluatedProperties)}function HasUnevaluatedFromObject(value){return IsUnevaluatedItems(value)||IsUnevaluatedProperties(value)||guard_exports.Some(guard_exports.Keys(value),key=>HasUnevaluatedFromUnknown(value[key]))}function HasUnevaluatedFromArray(value){return guard_exports.Some(value,value2=>HasUnevaluatedFromUnknown(value2))}function HasUnevaluatedFromUnknown(value){return guard_exports.IsArray(value)?HasUnevaluatedFromArray(value):guard_exports.IsObject(value)?HasUnevaluatedFromObject(value):!1}function HasUnevaluated(context,schema){
5
5
  return HasUnevaluatedFromUnknown(schema)||guard_exports.Some(guard_exports.Keys(context),key=>HasUnevaluatedFromUnknown(context[key]))}var BuildContext=class{constructor(hasUnevaluated){this.hasUnevaluated=hasUnevaluated}UseUnevaluated(){return this.hasUnevaluated}Push(){return emit_exports.Call(emit_exports.Member("context","Push"),[])}Pop(){return emit_exports.Call(emit_exports.Member("context","Pop"),[])}AddIndex(index3){return emit_exports.Call(emit_exports.Member("context","AddIndex"),[index3])}AddKey(key){
6
6
  return emit_exports.Call(emit_exports.Member("context","AddKey"),[key])}Merge(results){return emit_exports.Call(emit_exports.Member("context","Merge"),[results])}},CheckContext=class{constructor(){let indices=new Set,keys=new Set;this.stack=[{indices,keys}]}Push(){let indices=new Set,keys=new Set;return this.stack.push({indices,keys}),!0}Pop(){return this.stack.pop(),!0}AddIndex(index3){return this.GetIndices().add(index3),!0}AddKey(key){return this.GetKeys().add(key),!0}GetIndices(){return this.
@@ -75,7 +75,8 @@ PUNYCODE_BASE){let t=k<=bias?PUNYCODE_TMIN:k>=bias+PUNYCODE_TMAX?PUNYCODE_TMAX:k
75
75
  chars[0]))return!1;let hasJapanese=!1;for(let i=0;i<length;i++){let codePoint=codePoints[i],char=chars[i];if(RE_RFC5892_DISALLOWED.test(char)||!RE_PERMITTED_CATEGORY.test(char))return!1;RE_SCRIPT_JAPANESE.test(char)&&(hasJapanese=!0);let prev=codePoints[i-1],next=codePoints[i+1];switch(codePoint){case 183:if(prev!==108||next!==108)return!1;break;case 885:if(!next||!RE_SCRIPT_GREEK.test(chars[i+1]))return!1;break;case 1523:case 1524:if(!prev||!RE_SCRIPT_HEBREW.test(chars[i-1]))return!1;break;case 8204:
76
76
  if(!prev||prev<128&&!RE_VIRAMA.test(chars[i-1]))return!1;break;case 8205:if(!prev||!RE_VIRAMA.test(chars[i-1]))return!1;break;case 12539:break}}return!(value.includes("\u30FB")&&!hasJapanese)}function IsPunyLabel(value){if(!IsAcePrefixed(value))return!1;try{let body=value.slice(4).toLowerCase();if(body.lastIndexOf("-")===0)return!1;let decoded=Decode(body);return RE_NON_ASCII.test(decoded)?IsUnicodeLabel(decoded):!1}catch{return!1}}function IsValidLabelLength(value){return value.length>0&&value.length<=63}function IsLabel(value){return IsValidLabelLength(value)&&(IsPunyLabel(value)||IsAsciiLabel(value))}function IsHostname(value){return value.length===0||value.length>253||value.charCodeAt(value.length-1)===46?!1:value.split(".").every(label=>IsLabel(label))}function IsValidLabelLength2(value){return value.length>0&&value.length<=63}function IsLabel2(value){return IsValidLabelLength2(value)&&(IsPunyLabel(value)||IsUnicodeLabel(value))}function NormalizeHostname(value){return value.replace(/[\uff01-\uff5e]/g,char=>String.fromCharCode(char.charCodeAt(0)-65248)).normalize("NFC").replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu,"").replace(/[\u002E\u3002\uFF0E\uFF61]/g,".")}function IsIdnHostname(value){if(value.length===0||
77
77
  value.includes(" "))return!1;let normalized=NormalizeHostname(value);if(normalized.length>253)return!1;let labels=normalized.split("."),hasBidiChars=labels.some(label=>HasBidiChars(label));return labels.every(label=>IsLabel2(label)&&(!hasBidiChars||SatisfiesBidiRule(label)))}function IsHostname2(value){return IsHostname(value)}var IdnEmail=/^(?:[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;function IsIdnEmail(value){return IdnEmail.test(value.normalize("NFC"))}function IsIdnHostname2(value){return IsIdnHostname(value)}var IPv4=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function IsIPv4(value){return IPv4.test(value)}var IPv6=/^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;
78
- function IsIPv6(value){return IPv6.test(value)}var InvalidIriChars=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,MalformedScheme=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function IsIriReference(value){return!InvalidIriChars.test(value)&&!MalformedScheme.test(value)&&URL.canParse(value,"http://example.com")}var InvalidIriChars2=/[\x00-\x20<>\^`{|}\\]/,InvalidPercentEncoding=/%(?![0-9a-fA-F]{2})/;function IsIri(value){return InvalidIriChars2.test(value)||InvalidPercentEncoding.test(value)?!1:URL.canParse(value)}var JsonPointerUriFragment=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function IsJsonPointerUriFragment(value){return JsonPointerUriFragment.test(value)}var JsonPointer=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function IsJsonPointer(value){return JsonPointer.test(value)}function IsRegex(value){try{return new RegExp(value,"u"),!0}catch{return!1}}var RelativeJsonPointer=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function IsRelativeJsonPointer(value){return RelativeJsonPointer.test(value)}var UriReference=/^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
78
+ function IsIPv6(value){return IPv6.test(value)}var InvalidIriReferenceChars=/[\x00-\x20\x7f"<>\^`{|}\\]|%(?![0-9a-fA-F]{2})/,MalformedScheme=/^(?:[a-z][a-z\d+\-.]*\/\/|(?!(?:[a-z][a-z\d+\-.]*:))[^/?#]*:)/i,MultipleAuthorityAtSigns=/^(?:[a-z][a-z\d+\-.]*:)?\/\/[^/?#@]*@[^/?#@]*@/i,BracketedPath=/^(?:[a-z][a-z\d+\-.]*:\/\/[^/?#]*\/|\/\/[^/?#]*\/|[a-z][a-z\d+\-.]*:(?!\/\/)|(?![a-z][a-z\d+\-.]*:|\/\/))[^?#]*[\[\]]/i;function IsIriReference(value){return!InvalidIriReferenceChars.test(value)&&!MalformedScheme.test(value)&&!MultipleAuthorityAtSigns.
79
+ test(value)&&!BracketedPath.test(value)&&URL.canParse(value,"http://example.com")}var AbsoluteIriScheme=/^[a-z][a-z\d+\-.]*:/i;function IsIri(value){return AbsoluteIriScheme.test(value)&&IsIriReference(value)}var JsonPointerUriFragment=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function IsJsonPointerUriFragment(value){return JsonPointerUriFragment.test(value)}var JsonPointer=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function IsJsonPointer(value){return JsonPointer.test(value)}function IsRegex(value){try{return new RegExp(value,"u"),!0}catch{return!1}}var RelativeJsonPointer=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function IsRelativeJsonPointer(value){return RelativeJsonPointer.test(value)}var UriReference=/^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
79
80
  function IsUriReference(value){return UriReference.test(value)}var UriTemplate=/^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;function IsUriTemplate(value){return UriTemplate.test(value)}var Uri=/^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
80
81
  function IsUri(value){return Uri.test(value)}function IsUrl(value){return URL.canParse(value)}var Uuid=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function IsUuid(value){return Uuid.test(value)}var formats=new Map;function Clear(){formats.clear()}function Entries(){return[...formats.entries()]}function Set3(format,check){formats.set(format,check)}function Has2(format){return formats.has(format)}function Get4(format){return formats.get(format)}function Test(format,value){return formats.get(format)?.(value)??!0}function Reset(){Clear(),formats.set("date-time",IsDateTime),formats.set("date",IsDate),formats.set("duration",IsDuration),formats.set("email",IsEmail),formats.set("hostname",IsHostname2),
81
82
  formats.set("idn-email",IsIdnEmail),formats.set("idn-hostname",IsIdnHostname2),formats.set("ipv4",IsIPv4),formats.set("ipv6",IsIPv6),formats.set("iri-reference",IsIriReference),formats.set("iri",IsIri),formats.set("json-pointer-uri-fragment",IsJsonPointerUriFragment),formats.set("json-pointer",IsJsonPointer),formats.set("regex",IsRegex),formats.set("relative-json-pointer",IsRelativeJsonPointer),formats.set("time",IsTime),formats.set("uri-reference",IsUriReference),formats.set("uri-template",IsUriTemplate),
@@ -210,4 +211,127 @@ return build.Functions().map(func=>[Separator(),TsIgnore(),`${func};`].join(`
210
211
  `
211
212
  `);return{External:build.External(),Code:code}}var Validator=class{constructor(context,type){this.hasCodec=HasCodec(context,type),this.buildResult=Build(context,type),this.evaluateResult=this.buildResult.Evaluate()}IsAccelerated(){return this.evaluateResult.IsAccelerated()}Context(){return this.buildResult.Context()}Type(){return this.buildResult.Schema()}Code(){return this.evaluateResult.Code()}Check(value){return this.evaluateResult.Check(value)}Parse(value){if(this.Check(value))return value;if(settings_exports.Get().correctiveParse)return Parser(
212
213
  this.Context(),this.Type(),value);EnableParseErrors();let errors=this.Errors(value);throw DisableParseErrors(),new ParseError(value,errors)}Errors(value){return this.IsAccelerated()&&this.Check(value)?[]:Errors2(this.Context(),this.Type(),value)}Clean(value){return Clean(this.Context(),this.Type(),value)}Convert(value){return Convert(this.Context(),this.Type(),value)}Create(){return Create(this.Context(),this.Type())}Default(value){return Default(this.Context(),this.Type(),value)}Decode(value){return this.
213
- hasCodec?Decode9(this.Context(),this.Type(),value):this.Parse(value)}Encode(value){return this.hasCodec?Encode9(this.Context(),this.Type(),value):this.Parse(value)}};function Compile(...args){let[context,type]=arguments_exports.Match(args,{2:(context2,type2)=>[context2,type2],1:type2=>[{},type2]});return new Validator(context,type)}var compile_default=Compile;export{value_exports,value_exports2,Compile,compile_exports};
214
+ hasCodec?Decode9(this.Context(),this.Type(),value):this.Parse(value)}Encode(value){return this.hasCodec?Encode9(this.Context(),this.Type(),value):this.Parse(value)}};function Compile(...args){let[context,type]=arguments_exports.Match(args,{2:(context2,type2)=>[context2,type2],1:type2=>[{},type2]});return new Validator(context,type)}var compile_default=Compile;var FLOW_ID_PATTERN="^[a-z0-9][a-z0-9_.:-]{0,127}$",FLOW_MODEL_ID_PATTERN="^(?=.{1,128}$)[a-z0-9][a-z0-9_.:-]*(?:/[a-z0-9][a-z0-9_.:-]*)?$",FLOW_DIGEST_PATTERN="^[a-f0-9]{64}$",FLOW_TS_PATTERN="^\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\\d|3[01])T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d{1,9})?(?:Z|[+-](?:[01]\\d|2[0-3]):[0-5]\\d)$",FLOW_CONTRACT_ERROR_CODES={profile_invalid:"Invalid flow profile",admission_invalid:"Invalid flow run admission",event_invalid:"Invalid flow event",command_invalid:"\
215
+ Invalid flow control command",receipt_invalid:"Invalid flow control receipt",status_invalid:"Invalid flow status",digest_mismatch:"Flow digest mismatch",digest_unverifiable:"Flow digest cannot be verified",canonical_invalid:"Flow data cannot be canonicalized",receipt_conflict:"Flow receipt conflicts with the first receipt"},FlowContractError=class extends Error{code;constructor(code){super(FLOW_CONTRACT_ERROR_CODES[code]),this.name="FlowContractError",this.code=code}},lit=(...values)=>typebox_exports.
216
+ Union(values.map(value=>typebox_exports.Literal(value))),StrictObject=properties=>typebox_exports.Object(properties,{additionalProperties:!1}),FlowIdSchema=typebox_exports.String({pattern:FLOW_ID_PATTERN}),FlowDigestSchema=typebox_exports.String({pattern:FLOW_DIGEST_PATTERN}),DAYS_IN_MONTH=[31,28,31,30,31,30,31,31,30,31,30,31];function isRealCalendarDate(timestamp){let year=Number(timestamp.slice(0,4)),month=Number(timestamp.slice(5,7)),day=Number(timestamp.slice(8,10)),leap=year%4===0&&year%100!==
217
+ 0||year%400===0;return day<=(month===2&&leap?29:DAYS_IN_MONTH[month-1]??0)}var FlowTimestampSchema=typebox_exports.Refine(typebox_exports.String({pattern:FLOW_TS_PATTERN}),isRealCalendarDate),FlowMicrousdSchema=typebox_exports.Integer({minimum:0,maximum:Number.MAX_SAFE_INTEGER}),FlowCountSchema=typebox_exports.Integer({minimum:0,maximum:Number.MAX_SAFE_INTEGER}),FlowPositiveIntSchema=typebox_exports.Integer({minimum:1,maximum:Number.MAX_SAFE_INTEGER}),FlowModelRefSchema=StrictObject({provider:FlowIdSchema,
218
+ model:typebox_exports.String({pattern:FLOW_MODEL_ID_PATTERN})}),FLOW_ROLES=["scout","worker","implementer","lead","lead_large","architect","reviewer","security_reviewer","qa","triage"],FlowRoleSchema=typebox_exports.Union([typebox_exports.Literal("scout"),typebox_exports.Literal("worker"),typebox_exports.Literal("implementer"),typebox_exports.Literal("lead"),typebox_exports.Literal("lead_large"),typebox_exports.Literal("architect"),typebox_exports.Literal("reviewer"),typebox_exports.Literal("sec\
219
+ urity_reviewer"),typebox_exports.Literal("qa"),typebox_exports.Literal("triage")]),partialByRole=schema=>StrictObject({scout:typebox_exports.Optional(schema),worker:typebox_exports.Optional(schema),implementer:typebox_exports.Optional(schema),lead:typebox_exports.Optional(schema),lead_large:typebox_exports.Optional(schema),architect:typebox_exports.Optional(schema),reviewer:typebox_exports.Optional(schema),security_reviewer:typebox_exports.Optional(schema),qa:typebox_exports.Optional(schema),triage:typebox_exports.
220
+ Optional(schema)});var FlowSizeSchema=typebox_exports.Union([typebox_exports.Literal("small"),typebox_exports.Literal("medium"),typebox_exports.Literal("large")]);var FlowFailureClassSchema=typebox_exports.Union([typebox_exports.Literal("provider_error"),typebox_exports.Literal("provider_unreachable"),typebox_exports.Literal("rate_limit"),typebox_exports.Literal("timeout"),typebox_exports.Literal("check_failed"),typebox_exports.Literal("review_rejected"),typebox_exports.Literal("qa_failed"),typebox_exports.Literal("budget_stop"),typebox_exports.Literal("cancelled"),typebox_exports.Literal("crash"),typebox_exports.Literal("unsafe_scope"),typebox_exports.Literal(
221
+ "stalled"),typebox_exports.Literal("config_invalid"),typebox_exports.Literal("internal"),typebox_exports.Literal("review_verdict_missing"),typebox_exports.Literal("verification_unavailable"),typebox_exports.Literal("unsupported_configuration"),typebox_exports.Literal("blocked"),typebox_exports.Literal("review_findings")]),FlowReasonClassSchema=typebox_exports.Union([FlowFailureClassSchema,typebox_exports.Literal("size_underestimated")]),FlowProfileRefSchema=StrictObject({id:FlowIdSchema,version:FlowPositiveIntSchema,
222
+ digest:FlowDigestSchema});function verifyFlowDigest(hasher,text,expected){let actual;try{actual=hasher.sha256Hex(text)}catch{throw new FlowContractError("digest_unverifiable")}if(typeof actual!="string")throw new FlowContractError("digest_unverifiable");return actual===expected}var MAX_SNAPSHOT_DEPTH=16,MAX_SNAPSHOT_NODES=1e4,MAX_SNAPSHOT_STRING=65536;function isIndexKey(key,length){let index3=Number(key);return Number.isInteger(index3)&&index3>=0&&index3<length&&String(index3)===key}function snapshotValue(value,depth,budget){
223
+ if(budget.nodes+=1,depth>MAX_SNAPSHOT_DEPTH||budget.nodes>MAX_SNAPSHOT_NODES)throw new Error("bounds");if(value===null||typeof value=="boolean")return value;if(typeof value=="string"){if(value.length>MAX_SNAPSHOT_STRING||!value.isWellFormed())throw new Error("string");return value}if(typeof value=="number"){if(!Number.isFinite(value))throw new Error("number");return value}if(typeof value!="object")throw new Error("type");if(Array.isArray(value)){let length=value.length;if(length>MAX_SNAPSHOT_NODES)
224
+ throw new Error("bounds");for(let key of Reflect.ownKeys(value))if(typeof key!="string"||key!=="length"&&!isIndexKey(key,length))throw new Error("array");let out2=[];for(let index3=0;index3<length;index3+=1){let descriptor=Object.getOwnPropertyDescriptor(value,String(index3));if(descriptor===void 0||!("value"in descriptor))throw new Error("array");out2.push(snapshotValue(descriptor.value,depth+1,budget))}return out2}let proto=Object.getPrototypeOf(value);if(proto!==null&&Object.getPrototypeOf(proto)!==
225
+ null)throw new Error("prototype");let out={};for(let key of Reflect.ownKeys(value)){if(typeof key!="string"||!key.isWellFormed())throw new Error("key");let descriptor=Object.getOwnPropertyDescriptor(value,key);if(descriptor===void 0||!("value"in descriptor)||descriptor.enumerable!==!0)throw new Error("property");descriptor.value!==void 0&&Object.defineProperty(out,key,{value:snapshotValue(descriptor.value,depth+1,budget),enumerable:!0,writable:!0,configurable:!0})}return out}function snapshotFlowData(input){
226
+ return snapshotValue(input,0,{nodes:0})}function parseFlowData(code,input,validate){let snapshot=trySnapshotFlowData(code,input);if(!validate(snapshot))throw new FlowContractError(code);return snapshot}function trySnapshotFlowData(code,input){try{return snapshotFlowData(input)}catch{throw new FlowContractError(code)}}function compileFlow(schema){return Compile(schema)}function modelKey(ref){return`${ref.provider}\0${ref.model}`}function hasDuplicateModels(refs){return new Set(refs.map(modelKey)).
227
+ size!==refs.length}function canonicalFlowJson(value){if(value===null||typeof value=="boolean")return JSON.stringify(value);if(typeof value=="string"){if(!value.isWellFormed())throw new FlowContractError("canonical_invalid");return JSON.stringify(value)}if(typeof value=="number"){if(!Number.isFinite(value))throw new FlowContractError("canonical_invalid");return JSON.stringify(value)}if(Array.isArray(value))return`[${value.map(canonicalFlowJson).join(",")}]`;if(typeof value!="object")throw new FlowContractError(
228
+ "canonical_invalid");let record=value,parts=[];for(let key of Object.keys(record).sort()){if(!key.isWellFormed())throw new FlowContractError("canonical_invalid");record[key]!==void 0&&parts.push(`${JSON.stringify(key)}:${canonicalFlowJson(record[key])}`)}return`{${parts.join(",")}}`}function canonicalWithout(doc,omit){let copy={...doc};return delete copy[omit],canonicalFlowJson(copy)}var SUBAGENT_WORKER_STATUSES=["queued","waiting","running","completed","failed","cancelled","skipped","unresolved"],SUBAGENT_CANCELLATION_OUTCOMES=["none","not_started","direct_worker_terminated","unconfirmed"],SUBAGENT_FAILURE_KINDS=["spawn_failed","process_error","model_error","merge_failed"],SUBAGENT_RUN_MODES=["single","parallel","chain"];var SUBAGENT_PROGRESS_UUID_PATTERN="^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",SUBAGENT_PROGRESS_IDENTIFIER_PATTERN="^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",SUBAGENT_PROGRESS_MODEL_PATTERN="^[A-Za-z0-9][A-Za-z0-9._:/@+-]{0,127}$",SUBAGENT_PROGRESS_TOOL_CALL_ID_PATTERN="^[\\x21-\\x7E]{1,256}$",SUBAGENT_PROGRESS_TEXT_PATTERN="^[^\\u0000-\\u001F\\u007F-\\u009F\\u00AD\\u034F\\u061C\\u180E\\u200B-\\u200F\\u2028-\\u202E\\u2060-\\u2069\\uFEFF]+$",UUID_REGEX=new RegExp(SUBAGENT_PROGRESS_UUID_PATTERN),
229
+ IDENTIFIER_REGEX=new RegExp(SUBAGENT_PROGRESS_IDENTIFIER_PATTERN),MODEL_REGEX=new RegExp(SUBAGENT_PROGRESS_MODEL_PATTERN),TOOL_CALL_ID_REGEX=new RegExp(SUBAGENT_PROGRESS_TOOL_CALL_ID_PATTERN);function isCanonicalSubagentProgressUuid(value){return typeof value=="string"&&value.length===36&&UUID_REGEX.test(value)}var progressTextEncoder=new TextEncoder;function measureSubagentProgressJson(value){let text;try{text=JSON.stringify(value)}catch{throw invalidSnapshot()}if(typeof text!="string")throw invalidSnapshot();
230
+ return{utf8Bytes:progressTextEncoder.encode(text).length,codeUnits:text.length}}function isForbiddenTextCodeUnit(unit){return unit<=31||unit>=127&&unit<=159||unit===173||unit===847||unit===1564||unit===6158||unit>=8203&&unit<=8207||unit>=8232&&unit<=8238||unit>=8288&&unit<=8297||unit===65279}function isHighSurrogate(unit){return unit>=55296&&unit<=56319}function isLowSurrogate(unit){return unit>=56320&&unit<=57343}function isSubagentPresentationText(value,max){if(typeof value!="string"||value.length===
231
+ 0||value.length>max||value!==value.trim())return!1;for(let i=0;i<value.length;i++){let unit=value.charCodeAt(i);if(isHighSurrogate(unit)){if(!isLowSurrogate(value.charCodeAt(i+1)))return!1;i+=1}else if(isLowSurrogate(unit)||isForbiddenTextCodeUnit(unit))return!1}return!0}var SUBAGENT_PRESENTATION_SCAN_WINDOW_CODE_UNITS=4096,WHITESPACE_UNIT_REGEX=/\s/;function isSeparatorAt(input,index3){let unit=input.charCodeAt(index3);return isHighSurrogate(unit)?!isLowSurrogate(input.charCodeAt(index3+1)):isLowSurrogate(
232
+ unit)||isForbiddenTextCodeUnit(unit)||WHITESPACE_UNIT_REGEX.test(input[index3])}function toSubagentPresentationText(input,max){if(typeof input!="string"||max<2)return null;let length=input.length,i=0,skipEnd=Math.min(length,SUBAGENT_PRESENTATION_SCAN_WINDOW_CODE_UNITS);for(;i<skipEnd&&isSeparatorAt(input,i);)i+=1;if(i===length||i===skipEnd)return null;let collectEnd=Math.min(length,i+SUBAGENT_PRESENTATION_SCAN_WINDOW_CODE_UNITS),out="",pendingSpace=!1,truncated=!1;for(;i<collectEnd;){if(isSeparatorAt(
233
+ input,i)){pendingSpace=!0,i+=1;continue}let width=isHighSurrogate(input.charCodeAt(i))?2:1;if(out.length+(pendingSpace?1:0)+width>max){truncated=!0;break}pendingSpace&&(out+=" ",pendingSpace=!1),out+=input.slice(i,i+width),i+=width}if(!truncated&&i<length&&(truncated=!0),!truncated)return out;let end=Math.min(out.length,max-1);return isHighSurrogate(out.charCodeAt(end-1))&&(end-=1),out.charCodeAt(end-1)===32&&(end-=1),`${out.slice(0,end)}\u2026`}function invalidSnapshot(){return new Error("Inval\
234
+ id subagent progress snapshot")}function isTerminalStatus(status){return status!=="queued"&&status!=="waiting"&&status!=="running"}function assertWorkerInvariants(worker,runFinal){let{status,attempt,cancelRequested,cancellationOutcome:outcome}=worker,valid=!0;if(status==="unresolved"&&!runFinal&&(valid=!1),runFinal&&!isTerminalStatus(status)&&(valid=!1),status==="unresolved"&&attempt<1&&(valid=!1),status==="unresolved"&&cancelRequested&&outcome!=="unconfirmed"&&(valid=!1),!isTerminalStatus(status)&&
235
+ cancelRequested&&outcome!=="unconfirmed"&&(valid=!1),!cancelRequested&&outcome!=="none"&&(valid=!1),status==="cancelled"?(!cancelRequested||outcome!=="not_started"&&outcome!=="direct_worker_terminated")&&(valid=!1):(outcome==="not_started"||outcome==="direct_worker_terminated")&&(valid=!1),outcome==="not_started"&&attempt!==0&&(valid=!1),outcome==="direct_worker_terminated"&&attempt<1&&(valid=!1),(status==="running"||status==="completed")&&attempt<1&&(valid=!1),(status==="queued"||status==="wait\
236
+ ing"||status==="skipped")&&attempt!==0&&(valid=!1),worker.failureKind!==null&&status!=="failed"&&(valid=!1),worker.resultPreview!==null&&status!=="completed"&&status!=="failed"&&(valid=!1),worker.startedAt!==null!=attempt>=1&&(valid=!1),worker.endedAt!==null&&(worker.startedAt===null||!isTerminalStatus(status)||worker.endedAt<worker.startedAt)&&(valid=!1),!valid)throw invalidSnapshot()}function assertRunInvariants(run){if(run.endedAt!==null!==run.final||run.endedAt!==null&&run.endedAt<run.startedAt)
237
+ throw invalidSnapshot();let workerIds=new Set;for(let worker of run.workers){if(workerIds.has(worker.workerId))throw invalidSnapshot();workerIds.add(worker.workerId),assertWorkerInvariants(worker,run.final)}let size=measureSubagentProgressJson(run);if(size.utf8Bytes>65536||size.codeUnits>65536)throw invalidSnapshot()}var RUN_KEYS=["runId","seq","final","workers","toolCallId","mode","startedAt","endedAt"],WORKER_KEYS=["workerId","attempt","status","cancelRequested","cancellationOutcome","agent","\
238
+ label","task","model","startedAt","endedAt","turns","toolCalls","failureKind","resultPreview"],ENVELOPE_KEYS=["schemaVersion","runtimeId","sessionEpoch","complete","runs"];function readPlainFields(value,keys){if(value===null||typeof value!="object"||Array.isArray(value))throw invalidSnapshot();let proto=Object.getPrototypeOf(value);if(proto!==Object.prototype&&proto!==null||Reflect.ownKeys(value).length!==keys.length)throw invalidSnapshot();let out={};for(let key of keys){let descriptor=Object.getOwnPropertyDescriptor(
239
+ value,key);if(!descriptor?.enumerable||!("value"in descriptor))throw invalidSnapshot();out[key]=descriptor.value}return out}function readPlainArray(value,maxItems){if(!Array.isArray(value)||Object.getPrototypeOf(value)!==Array.prototype)throw invalidSnapshot();let length=Object.getOwnPropertyDescriptor(value,"length")?.value;if(typeof length!="number"||!Number.isInteger(length)||length<0||length>maxItems)throw invalidSnapshot();let own=Reflect.ownKeys(value);if(own.length!==length+1||own[length]!==
240
+ "length")throw invalidSnapshot();let out=[];for(let i=0;i<length;i++){if(own[i]!==String(i))throw invalidSnapshot();let descriptor=Object.getOwnPropertyDescriptor(value,i);if(!descriptor?.enumerable||!("value"in descriptor))throw invalidSnapshot();out.push(descriptor.value)}return out}function readUuid(value){if(!isCanonicalSubagentProgressUuid(value))throw invalidSnapshot();return value}function readBoolean(value){if(typeof value!="boolean")throw invalidSnapshot();return value}function readInteger(value,minimum){
241
+ if(typeof value!="number"||!Number.isSafeInteger(value)||value<minimum)throw invalidSnapshot();return value}function readNullableInteger(value){return value===null?null:readInteger(value,0)}function readMember(value,allowed){let member=allowed.find(candidate=>candidate===value);if(member===void 0)throw invalidSnapshot();return member}function readNullableMember(value,allowed){return value===null?null:readMember(value,allowed)}function readNullablePattern(value,pattern){if(value===null)return null;
242
+ if(typeof value!="string"||!pattern.test(value))throw invalidSnapshot();return value}function readNullableText(value,max){if(value===null)return null;if(!isSubagentPresentationText(value,max))throw invalidSnapshot();return value}function readWorker(value){let f=readPlainFields(value,WORKER_KEYS);return{workerId:readUuid(f.workerId),attempt:readInteger(f.attempt,0),status:readMember(f.status,SUBAGENT_WORKER_STATUSES),cancelRequested:readBoolean(f.cancelRequested),cancellationOutcome:readMember(f.
243
+ cancellationOutcome,SUBAGENT_CANCELLATION_OUTCOMES),agent:readNullablePattern(f.agent,IDENTIFIER_REGEX),label:readNullablePattern(f.label,IDENTIFIER_REGEX),task:readNullableText(f.task,120),model:readNullablePattern(f.model,MODEL_REGEX),startedAt:readNullableInteger(f.startedAt),endedAt:readNullableInteger(f.endedAt),turns:readInteger(f.turns,0),toolCalls:readInteger(f.toolCalls,0),failureKind:readNullableMember(f.failureKind,SUBAGENT_FAILURE_KINDS),resultPreview:readNullableText(f.resultPreview,
244
+ 160)}}function readRun(value){let f=readPlainFields(value,RUN_KEYS);return{runId:readUuid(f.runId),seq:readInteger(f.seq,1),final:readBoolean(f.final),workers:readPlainArray(f.workers,32).map(readWorker),toolCallId:readNullablePattern(f.toolCallId,TOOL_CALL_ID_REGEX),mode:readMember(f.mode,SUBAGENT_RUN_MODES),startedAt:readInteger(f.startedAt,0),endedAt:readNullableInteger(f.endedAt)}}function readEnvelope(value){let f=readPlainFields(value,ENVELOPE_KEYS);if(f.schemaVersion!==1)throw invalidSnapshot();
245
+ return{schemaVersion:1,runtimeId:readUuid(f.runtimeId),sessionEpoch:readUuid(f.sessionEpoch),complete:readBoolean(f.complete),runs:readPlainArray(f.runs,64).map(readRun)}}function parseSubagentRunSnapshot(value){try{let run=readRun(value);return assertRunInvariants(run),deepFreeze(run)}catch{throw invalidSnapshot()}}function parseSubagentProgressSnapshot(value){try{let snapshot=readEnvelope(value),runIds=new Set,finalized=0;for(let run of snapshot.runs){if(runIds.has(run.runId))throw invalidSnapshot();
246
+ runIds.add(run.runId),run.final&&(finalized+=1),assertRunInvariants(run)}if(finalized>16)throw invalidSnapshot();let size=measureSubagentProgressJson(snapshot);if(size.utf8Bytes>4259840||size.codeUnits>4259840)throw invalidSnapshot();return deepFreeze(snapshot)}catch{throw invalidSnapshot()}}function deepFreeze(value){if(value===null||typeof value!="object"||Object.isFrozen(value))return value;Object.freeze(value);for(let child of Object.values(value))deepFreeze(child);return value}var StrictObject2=properties=>typebox_exports.Object(properties,{additionalProperties:!1}),PositiveInteger=typebox_exports.Integer({minimum:1,maximum:Number.MAX_SAFE_INTEGER}),NonnegativeInteger=typebox_exports.Integer({minimum:0,maximum:Number.MAX_SAFE_INTEGER}),Digest=typebox_exports.String({pattern:"^[a-f0-9]{64}$"}),ORCHESTRATION_CONTRACT_VERSION=1,ORCHESTRATION_CAPABILITIES=["architect","technical_lead","implementation_fast","implementation_strong","technical_review","security_review"],ORCHESTRATION_EFFORTS=[
247
+ "low","medium","high"],ORCHESTRATION_RISKS=["low","medium","high","critical"],OrchestrationCapabilitySchema=typebox_exports.Union([typebox_exports.Literal(ORCHESTRATION_CAPABILITIES[0]),typebox_exports.Literal(ORCHESTRATION_CAPABILITIES[1]),typebox_exports.Literal(ORCHESTRATION_CAPABILITIES[2]),typebox_exports.Literal(ORCHESTRATION_CAPABILITIES[3]),typebox_exports.Literal(ORCHESTRATION_CAPABILITIES[4]),typebox_exports.Literal(ORCHESTRATION_CAPABILITIES[5])]),OrchestrationEffortSchema=typebox_exports.
248
+ Union([typebox_exports.Literal(ORCHESTRATION_EFFORTS[0]),typebox_exports.Literal(ORCHESTRATION_EFFORTS[1]),typebox_exports.Literal(ORCHESTRATION_EFFORTS[2])]),OrchestrationRiskSchema=typebox_exports.Union([typebox_exports.Literal(ORCHESTRATION_RISKS[0]),typebox_exports.Literal(ORCHESTRATION_RISKS[1]),typebox_exports.Literal(ORCHESTRATION_RISKS[2]),typebox_exports.Literal(ORCHESTRATION_RISKS[3])]),OrchestrationPackageSchema=StrictObject2({route:typebox_exports.String({minLength:1}),effort:OrchestrationEffortSchema,
249
+ contextBudget:PositiveInteger,model:typebox_exports.String({minLength:1}),independentFrom:typebox_exports.Optional(typebox_exports.Array(OrchestrationCapabilitySchema))}),OrchestrationTopologySchema=StrictObject2({maxDepth:typebox_exports.Integer({minimum:1,maximum:3}),maxWorkers:typebox_exports.Integer({minimum:1,maximum:16}),maxConcurrent:typebox_exports.Integer({minimum:1,maximum:8}),maxWorktrees:typebox_exports.Integer({minimum:0,maximum:8})}),OrchestrationRunClassSchema=StrictObject2({taskClass:typebox_exports.
250
+ String({minLength:1}),complexity:typebox_exports.Integer({minimum:1,maximum:10}),risk:OrchestrationRiskSchema,classificationSource:typebox_exports.Union([typebox_exports.Literal("deterministic"),typebox_exports.Literal("classifier"),typebox_exports.Literal("fallback"),typebox_exports.Literal("architect")])}),OrchestrationFeaturesSchema=StrictObject2({adaptiveRouting:typebox_exports.Union([typebox_exports.Literal("off"),typebox_exports.Literal("observe"),typebox_exports.Literal("recommend"),typebox_exports.
251
+ Literal("enforce")]),exploration:typebox_exports.Boolean(),shadowRouting:typebox_exports.Union([typebox_exports.Literal("off"),typebox_exports.Literal("estimate")]),budget:typebox_exports.Union([typebox_exports.Literal("monitor"),typebox_exports.Literal("warn"),typebox_exports.Literal("enforce")]),budgetMicrocents:NonnegativeInteger,timeBudgetMs:NonnegativeInteger,autoMerge:typebox_exports.Literal(!1),destructiveOps:typebox_exports.Literal("deny"),dependencyChanges:typebox_exports.Union([typebox_exports.
252
+ Literal("deny"),typebox_exports.Literal("ask")])}),OrchestrationDecisionV1Schema=StrictObject2({defaultPackage:typebox_exports.Optional(typebox_exports.Record(typebox_exports.String(),OrchestrationPackageSchema)),recommendedPackage:typebox_exports.Optional(typebox_exports.Record(typebox_exports.String(),OrchestrationPackageSchema)),selected:typebox_exports.Union([typebox_exports.Literal("default"),typebox_exports.Literal("recommended"),typebox_exports.Literal("explored"),typebox_exports.Literal(
253
+ "canary")]),sampleCount:NonnegativeInteger,minSamples:PositiveInteger,explored:typebox_exports.Boolean(),canary:typebox_exports.Boolean(),shadowEstimate:typebox_exports.Optional(StrictObject2({costMicrocents:NonnegativeInteger,durationMs:NonnegativeInteger}))}),OrchestrationPolicyV1Schema=StrictObject2({contractVersion:typebox_exports.Literal(ORCHESTRATION_CONTRACT_VERSION),policyId:Digest,runClass:OrchestrationRunClassSchema,topology:OrchestrationTopologySchema,packages:typebox_exports.Record(typebox_exports.
254
+ String(),OrchestrationPackageSchema),agentCapabilities:typebox_exports.Record(typebox_exports.String(),OrchestrationCapabilitySchema),escalation:typebox_exports.Array(OrchestrationCapabilitySchema),verification:StrictObject2({depth:typebox_exports.Union([typebox_exports.Literal("none"),typebox_exports.Literal("targeted"),typebox_exports.Literal("broad"),typebox_exports.Literal("full")]),review:typebox_exports.Union([typebox_exports.Literal("off"),typebox_exports.Literal("sampled"),typebox_exports.
255
+ Literal("risk_based"),typebox_exports.Literal("always")]),gate:typebox_exports.Union([typebox_exports.Literal("off"),typebox_exports.Literal("on")])}),features:OrchestrationFeaturesSchema,decision:OrchestrationDecisionV1Schema,approvedDependencyChanges:typebox_exports.Optional(typebox_exports.Array(typebox_exports.String({minLength:1})))}),OrchestrationPolicyValidator=Compile(OrchestrationPolicyV1Schema),ORCHESTRATION_CAPABILITY_SET=new Set(ORCHESTRATION_CAPABILITIES);var RunOrchestrationDecisionV1Schema=StrictObject2({schemaVersion:typebox_exports.Literal(1),policyId:typebox_exports.Union([Digest,typebox_exports.Null()]),contractVersion:typebox_exports.Literal(ORCHESTRATION_CONTRACT_VERSION),runClass:typebox_exports.Union([OrchestrationRunClassSchema,typebox_exports.Null()]),topology:typebox_exports.Union([OrchestrationTopologySchema,typebox_exports.Null()]),decision:typebox_exports.Union([OrchestrationDecisionV1Schema,typebox_exports.Null()]),degradationReason:typebox_exports.
256
+ Union([typebox_exports.Literal("orchestration-unsupported"),typebox_exports.Literal("orchestration-disabled"),typebox_exports.Null()])}),SubagentTaskEventSchema=typebox_exports.Union([StrictObject2({type:typebox_exports.Literal("schedule"),taskId:typebox_exports.String(),dependsOn:typebox_exports.Array(typebox_exports.String()),ownerPaths:typebox_exports.Array(typebox_exports.String()),baseRevision:typebox_exports.Optional(typebox_exports.String()),at:NonnegativeInteger}),StrictObject2({type:typebox_exports.
257
+ Literal("wait"),taskId:typebox_exports.String(),reason:typebox_exports.Literal("concurrency"),at:NonnegativeInteger}),StrictObject2({type:typebox_exports.Literal("serialize"),taskId:typebox_exports.String(),after:typebox_exports.Array(typebox_exports.String()),at:NonnegativeInteger}),StrictObject2({type:typebox_exports.Literal("start"),taskId:typebox_exports.String(),attempt:PositiveInteger,at:NonnegativeInteger}),StrictObject2({type:typebox_exports.Literal("complete"),taskId:typebox_exports.String(),
258
+ attempt:PositiveInteger,at:NonnegativeInteger}),StrictObject2({type:typebox_exports.Literal("fail"),taskId:typebox_exports.String(),attempt:PositiveInteger,reason:typebox_exports.String(),at:NonnegativeInteger}),StrictObject2({type:typebox_exports.Literal("escalate"),taskId:typebox_exports.String(),fromAttempt:PositiveInteger,toAttempt:PositiveInteger,model:typebox_exports.Optional(typebox_exports.String()),thinking:typebox_exports.Optional(typebox_exports.String()),at:NonnegativeInteger}),StrictObject2(
259
+ {type:typebox_exports.Literal("skip"),taskId:typebox_exports.String(),failedDependency:typebox_exports.String(),at:NonnegativeInteger})]),SubagentTaskEventValidator=Compile(SubagentTaskEventSchema);var SubagentIdentityEnvelopeSchema=StrictObject2({taskId:typebox_exports.Optional(typebox_exports.String({minLength:1})),parentTaskId:typebox_exports.Optional(typebox_exports.String({minLength:1})),depth:typebox_exports.Optional(typebox_exports.Integer({minimum:1,maximum:3}))}),ProgressUuid=typebox_exports.String({pattern:SUBAGENT_PROGRESS_UUID_PATTERN,minLength:36,maxLength:36}),Nullable=schema=>typebox_exports.Union([schema,typebox_exports.Null()]),ProgressIdentifier=Nullable(typebox_exports.String(
260
+ {pattern:SUBAGENT_PROGRESS_IDENTIFIER_PATTERN,minLength:1,maxLength:64})),ProgressModel=Nullable(typebox_exports.String({pattern:SUBAGENT_PROGRESS_MODEL_PATTERN,minLength:1,maxLength:128})),ProgressToolCallId=Nullable(typebox_exports.String({pattern:SUBAGENT_PROGRESS_TOOL_CALL_ID_PATTERN,minLength:1,maxLength:256})),ProgressText=maxLength=>Nullable(typebox_exports.String({pattern:SUBAGENT_PROGRESS_TEXT_PATTERN,minLength:1,maxLength})),SubagentWorkerStatusSchema=typebox_exports.Union([typebox_exports.
261
+ Literal(SUBAGENT_WORKER_STATUSES[0]),typebox_exports.Literal(SUBAGENT_WORKER_STATUSES[1]),typebox_exports.Literal(SUBAGENT_WORKER_STATUSES[2]),typebox_exports.Literal(SUBAGENT_WORKER_STATUSES[3]),typebox_exports.Literal(SUBAGENT_WORKER_STATUSES[4]),typebox_exports.Literal(SUBAGENT_WORKER_STATUSES[5]),typebox_exports.Literal(SUBAGENT_WORKER_STATUSES[6]),typebox_exports.Literal(SUBAGENT_WORKER_STATUSES[7])]),SubagentCancellationOutcomeSchema=typebox_exports.Union([typebox_exports.Literal(SUBAGENT_CANCELLATION_OUTCOMES[0]),
262
+ typebox_exports.Literal(SUBAGENT_CANCELLATION_OUTCOMES[1]),typebox_exports.Literal(SUBAGENT_CANCELLATION_OUTCOMES[2]),typebox_exports.Literal(SUBAGENT_CANCELLATION_OUTCOMES[3])]),SubagentFailureKindSchema=typebox_exports.Union([typebox_exports.Literal(SUBAGENT_FAILURE_KINDS[0]),typebox_exports.Literal(SUBAGENT_FAILURE_KINDS[1]),typebox_exports.Literal(SUBAGENT_FAILURE_KINDS[2]),typebox_exports.Literal(SUBAGENT_FAILURE_KINDS[3]),typebox_exports.Null()]),SubagentRunModeSchema=typebox_exports.Union(
263
+ [typebox_exports.Literal(SUBAGENT_RUN_MODES[0]),typebox_exports.Literal(SUBAGENT_RUN_MODES[1]),typebox_exports.Literal(SUBAGENT_RUN_MODES[2])]),SubagentWorkerSnapshotSchema=StrictObject2({workerId:ProgressUuid,attempt:NonnegativeInteger,status:SubagentWorkerStatusSchema,cancelRequested:typebox_exports.Boolean(),cancellationOutcome:SubagentCancellationOutcomeSchema,agent:ProgressIdentifier,label:ProgressIdentifier,task:ProgressText(120),model:ProgressModel,startedAt:Nullable(NonnegativeInteger),endedAt:Nullable(
264
+ NonnegativeInteger),turns:NonnegativeInteger,toolCalls:NonnegativeInteger,failureKind:SubagentFailureKindSchema,resultPreview:ProgressText(160)}),SubagentRunSnapshotSchema=StrictObject2({runId:ProgressUuid,seq:PositiveInteger,final:typebox_exports.Boolean(),workers:typebox_exports.Array(SubagentWorkerSnapshotSchema,{maxItems:32}),toolCallId:ProgressToolCallId,mode:SubagentRunModeSchema,startedAt:NonnegativeInteger,endedAt:Nullable(NonnegativeInteger)}),SubagentProgressSnapshotSchema=StrictObject2(
265
+ {schemaVersion:typebox_exports.Literal(1),runtimeId:ProgressUuid,sessionEpoch:ProgressUuid,complete:typebox_exports.Boolean(),runs:typebox_exports.Array(SubagentRunSnapshotSchema,{maxItems:64})});var HUMAIN_AGENT_EXECUTION_SCHEMA_VERSION=1,HUMAIN_AGENT_ARTIFACT_KINDS=["candidate-patch","dependency-output","source-observation","validation-report"],StrictObject3=properties=>typebox_exports.Object(properties,{additionalProperties:!1}),StableIdentifier=typebox_exports.String({minLength:1,maxLength:256}),PositiveInteger2=typebox_exports.Integer({minimum:1,maximum:Number.MAX_SAFE_INTEGER}),NonnegativeInteger2=typebox_exports.Integer({minimum:0,maximum:Number.MAX_SAFE_INTEGER}),Digest2=typebox_exports.
266
+ String({pattern:"^[a-f0-9]{64}$"}),SafeArtifactReference=typebox_exports.String({minLength:1,maxLength:512,pattern:"^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))[A-Za-z0-9._-]+(?:/[A-Za-z0-9._-]+)*$"}),HumainAgentRouteRefSchema=typebox_exports.Union([typebox_exports.Literal("route:fast"),typebox_exports.Literal("route:balanced"),typebox_exports.Literal("route:thorough")]),HumainAgentArtifactSchema=StrictObject3({id:StableIdentifier,kind:typebox_exports.Union([typebox_exports.Literal(HUMAIN_AGENT_ARTIFACT_KINDS[0]),
267
+ typebox_exports.Literal(HUMAIN_AGENT_ARTIFACT_KINDS[1]),typebox_exports.Literal(HUMAIN_AGENT_ARTIFACT_KINDS[2]),typebox_exports.Literal(HUMAIN_AGENT_ARTIFACT_KINDS[3])]),reference:SafeArtifactReference,digest:Digest2}),HumainAgentExecutionControlsSchema=StrictObject3({maxConcurrency:typebox_exports.Integer({minimum:1,maximum:16}),maxDepth:typebox_exports.Integer({minimum:1,maximum:16}),depth:typebox_exports.Integer({minimum:0,maximum:16}),timeoutMs:typebox_exports.Integer({minimum:1,maximum:864e5})}),
268
+ HumainAgentExecutionClaimSchema=StrictObject3({workUnitId:StableIdentifier,nodeId:StableIdentifier,attemptNumber:PositiveInteger2,attemptFence:PositiveInteger2,segmentFence:PositiveInteger2,routeRef:HumainAgentRouteRefSchema,task:typebox_exports.String({minLength:1,maxLength:1e5}),controls:HumainAgentExecutionControlsSchema,input:StrictObject3({artifacts:typebox_exports.Array(HumainAgentArtifactSchema,{maxItems:16})})}),HumainAgentExecutionRequestSchema=StrictObject3({schemaVersion:typebox_exports.
269
+ Literal(HUMAIN_AGENT_EXECUTION_SCHEMA_VERSION),kind:typebox_exports.Literal("execute"),mode:typebox_exports.Union([typebox_exports.Literal("node"),typebox_exports.Literal("workflow")]),invocationId:StableIdentifier,batchId:typebox_exports.Optional(StableIdentifier),claims:typebox_exports.Array(HumainAgentExecutionClaimSchema,{minItems:1,maxItems:8})}),HumainAgentUsageSchema=typebox_exports.Union([StrictObject3({status:typebox_exports.Literal("unknown")}),StrictObject3({status:typebox_exports.Literal(
270
+ "measured"),totalCalls:typebox_exports.Optional(NonnegativeInteger2),totalTurns:typebox_exports.Optional(NonnegativeInteger2),totalTokens:NonnegativeInteger2,costMicrocents:NonnegativeInteger2})]),HUMAIN_AGENT_EXECUTION_FAILURE_CODES=["adapter_execution_failed","incompatible_adapter_capability","invalid_adapter_result","invalid_execution_request","provider_timeout","provider_unavailable","reused_execution_context","transport_interrupted"],HumainAgentExecutionFailureCodeSchema=typebox_exports.Union(
271
+ [typebox_exports.Literal(HUMAIN_AGENT_EXECUTION_FAILURE_CODES[0]),typebox_exports.Literal(HUMAIN_AGENT_EXECUTION_FAILURE_CODES[1]),typebox_exports.Literal(HUMAIN_AGENT_EXECUTION_FAILURE_CODES[2]),typebox_exports.Literal(HUMAIN_AGENT_EXECUTION_FAILURE_CODES[3]),typebox_exports.Literal(HUMAIN_AGENT_EXECUTION_FAILURE_CODES[4]),typebox_exports.Literal(HUMAIN_AGENT_EXECUTION_FAILURE_CODES[5]),typebox_exports.Literal(HUMAIN_AGENT_EXECUTION_FAILURE_CODES[6]),typebox_exports.Literal(HUMAIN_AGENT_EXECUTION_FAILURE_CODES[7])]),
272
+ OutcomeIdentity={workUnitId:StableIdentifier,nodeId:StableIdentifier,attemptNumber:PositiveInteger2,attemptFence:PositiveInteger2,segmentFence:PositiveInteger2},HumainAgentExecutionOutcomeSchema=typebox_exports.Union([StrictObject3({...OutcomeIdentity,kind:typebox_exports.Literal("succeeded"),output:StrictObject3({summary:typebox_exports.String({minLength:1,maxLength:512}),artifacts:typebox_exports.Array(HumainAgentArtifactSchema,{maxItems:16})}),usage:HumainAgentUsageSchema}),StrictObject3({...OutcomeIdentity,
273
+ kind:typebox_exports.Literal("failed"),failureCode:HumainAgentExecutionFailureCodeSchema,usage:HumainAgentUsageSchema}),StrictObject3({...OutcomeIdentity,kind:typebox_exports.Literal("cancelled"),terminationConfirmed:typebox_exports.Boolean(),usage:HumainAgentUsageSchema})]),HumainAgentExecutionResponseSchema=StrictObject3({schemaVersion:typebox_exports.Literal(HUMAIN_AGENT_EXECUTION_SCHEMA_VERSION),kind:typebox_exports.Literal("result"),mode:typebox_exports.Union([typebox_exports.Literal("node"),
274
+ typebox_exports.Literal("workflow")]),invocationId:StableIdentifier,batchId:typebox_exports.Optional(StableIdentifier),termination:typebox_exports.Union([typebox_exports.Literal("not-requested"),typebox_exports.Literal("confirmed"),typebox_exports.Literal("unconfirmed")]),outcomes:typebox_exports.Array(HumainAgentExecutionOutcomeSchema,{minItems:1,maxItems:8})}),RequestValidator=Compile(HumainAgentExecutionRequestSchema),ResponseValidator=Compile(HumainAgentExecutionResponseSchema),ArtifactReferenceValidator=Compile(
275
+ SafeArtifactReference);function isSafeHumainAgentExecutionSummary(value){return typeof value=="string"&&value.length>=1&&value.length<=512&&value===value.trim()&&/^[\p{L}\p{N}][\p{L}\p{N} .,;:!?()&'-]*$/u.test(value)&&!/\b(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}(?::\d{1,5})?\b/u.test(value)&&!/\b(?:\d{1,3}\.){3}\d{1,3}(?::\d{1,5})?\b/u.test(value)&&!/^(?:rm|curl|wget|sh|bash|zsh|fish|pwsh|powershell|cmd|node|bun|deno|npx|npm|pnpm|yarn|python(?:3)?|perl|ruby|git|docker|kubectl|ssh|scp|sudo|cat|ls|cd|mkdir|touch|chmod|chown|env|export|set|eval|exec)\b/iu.
276
+ test(value)&&!/\b(?:api[- ]?key|secret|token|credential|password)\s*:/iu.test(value)&&!/\b(?:claude|gpt|gemini|llama|mistral|zai|glm|qwen|deepseek|grok|nova|o\d+)[-_.:][A-Za-z0-9._:-]+\b/iu.test(value)}function parseHumainAgentExecutionRequest(input){if(!RequestValidator.Check(input))throw new Error("Invalid HUMAIN agent execution request");if(input.mode==="node"&&(input.claims.length!==1||input.batchId!==void 0))throw new Error("Invalid HUMAIN agent execution request: node mode requires one cla\
277
+ im and no batch identity");if(input.mode==="workflow"&&input.batchId===void 0)throw new Error("Invalid HUMAIN agent execution request: workflow mode requires a batch identity");let workUnitIds=new Set(input.claims.map(({workUnitId})=>workUnitId)),nodeIds=new Set(input.claims.map(({nodeId})=>nodeId));if(workUnitIds.size!==input.claims.length||nodeIds.size!==input.claims.length)throw new Error("Invalid HUMAIN agent execution request: claim identities must be unique");if(input.claims.some(({controls})=>controls.
278
+ depth>=controls.maxDepth))throw new Error("Invalid HUMAIN agent execution request: delegation depth limit is exhausted");return deepFreeze2(structuredClone(input))}function parseHumainAgentExecutionResponse(requestInput,responseInput){let request=parseHumainAgentExecutionRequest(requestInput);if(!ResponseValidator.Check(responseInput))throw new Error("Invalid HUMAIN agent execution response");let response=responseInput;if(response.outcomes.some(outcome=>outcome.kind==="succeeded"&&!isSafeHumainAgentExecutionSummary(
279
+ outcome.output.summary)))throw new Error("Invalid HUMAIN agent execution response");if(response.mode!==request.mode||response.invocationId!==request.invocationId||response.batchId!==request.batchId)throw new Error("HUMAIN agent result envelope mismatch");if(response.outcomes.length!==request.claims.length)throw new Error("HUMAIN agent result cardinality mismatch");for(let[index3,outcome]of response.outcomes.entries()){let claim=request.claims[index3];if(!claim||outcome.workUnitId!==claim.workUnitId||
280
+ outcome.nodeId!==claim.nodeId||outcome.attemptNumber!==claim.attemptNumber||outcome.attemptFence!==claim.attemptFence||outcome.segmentFence!==claim.segmentFence)throw new Error("HUMAIN agent result identity mismatch")}let cancelled=response.outcomes.filter(outcome=>outcome.kind==="cancelled"),expectedTermination=cancelled.length===0?"not-requested":cancelled.every(outcome=>outcome.terminationConfirmed)?"confirmed":"unconfirmed";if(response.termination!==expectedTermination)throw new Error("HUMAI\
281
+ N agent result termination evidence mismatch");return deepFreeze2(structuredClone(response))}function deepFreeze2(value){if(value===null||typeof value!="object"||Object.isFrozen(value))return value;Object.freeze(value);for(let child of Object.values(value))deepFreeze2(child);return value}import{join}from"node:path";import{fileURLToPath}from"node:url";var COORDINATION_BROKER_COMMAND="__humain-coordination-broker",COORDINATION_ROLE_ENV=`${ENV_PREFIX}_INTERNAL_ROLE`,COORDINATION_ROLE="coordination-broker",REPOSITORY_KEY=/^[a-f0-9]{16}$/;function detectLaunchRuntime(){return isBunBinary?"bun-binary":isBundledNode?"bundled-node":isBunRuntime?"bun-source":"node-source"}function getInternalCommandLaunchSpec(runtime,tail,execPath=process.execPath){let cliSource=fileURLToPath(new URL("../../cli.ts",import.meta.url));switch(runtime){case"bun-binary":return{
282
+ command:execPath,args:tail};case"bundled-node":return{command:execPath,args:[join(getPackageDir(),"dist","bundle","cli.js"),...tail]};case"bun-source":return{command:execPath,args:[cliSource,...tail]};case"node-source":return{command:execPath,args:["--import",new URL("../../experimental/source-resolver.ts",import.meta.url).href,cliSource,...tail]}}}function getBrokerLaunchSpec(runtime,repositoryKey,execPath=process.execPath){if(!REPOSITORY_KEY.test(repositoryKey))throw new Error(`Invalid reposit\
283
+ ory key: ${repositoryKey}`);return getInternalCommandLaunchSpec(runtime,[COORDINATION_BROKER_COMMAND,repositoryKey],execPath)}import{createHash as createHash2}from"node:crypto";import{mkdirSync as mkdirSync2,realpathSync as realpathSync2}from"node:fs";import{join as join3}from"node:path";import{createHash}from"node:crypto";import{chmodSync,closeSync,constants,fchmodSync,fstatSync,lstatSync,mkdirSync,openSync,realpathSync}from"node:fs";import{dirname,join as join2,resolve}from"node:path";var COORDINATION_DIR_MODE=448,COORDINATION_FILE_MODE=384,COORDINATION_PROTOCOL_NAME="humain-coordination",COORDINATION_PROTOCOL_VERSION=2,MAX_MESSAGE_TEXT_BYTES=65536,MAX_SOCKET_PATH_BYTES=100,REPOSITORY_KEY2=/^[a-f0-9]{16}$/,canonicalTmpDir;function getCanonicalTmpDir(){return canonicalTmpDir??=
284
+ realpathSync("/tmp"),canonicalTmpDir}function assertRepositoryKey(repositoryKey){if(repositoryKey!=="device"&&!REPOSITORY_KEY2.test(repositoryKey))throw new Error(`Invalid repository key: ${repositoryKey}`)}function getCoordinationRuntimePaths(agentDir,repositoryKey,uid=process.getuid?.()??0){assertRepositoryKey(repositoryKey);let runtimeDir=join2(agentDir,"coordination",repositoryKey),defaultSocket=join2(runtimeDir,"broker.sock"),socketPath=Buffer.byteLength(defaultSocket,"utf8")<=MAX_SOCKET_PATH_BYTES?
285
+ defaultSocket:join2(getCanonicalTmpDir(),`humain-coord-${uid}`,`${repositoryKey==="device"?`${createHash("sha256").update(agentDir).digest("hex").slice(0,16)}-device`:repositoryKey}.sock`);return{runtimeDir,socketPath,pidPath:join2(runtimeDir,"broker.pid"),spawnLockPath:join2(runtimeDir,"broker.spawn.lock"),mailboxPath:join2(runtimeDir,"mailbox.json"),pendingAsksDir:join2(runtimeDir,"pending-asks"),artifactsDir:join2(runtimeDir,"artifacts")}}function currentUid(){return process.getuid?.()}function resolveCoordinationRuntimePaths(agentDir,repositoryKey,uid){
286
+ assertRepositoryKey(repositoryKey),mkdirSync(agentDir,{recursive:!0,mode:COORDINATION_DIR_MODE});let canonicalAgentDir=realpathSync(agentDir);return assertSafeAncestors(join2(canonicalAgentDir,"coordination"),uid??currentUid()),getCoordinationRuntimePaths(canonicalAgentDir,repositoryKey,uid)}function assertOwnedByUser(path,stats,uid){if(uid!==void 0&&stats.uid!==uid)throw new Error(`Refusing to use ${path}: it is owned by uid ${stats.uid}, not the current user (uid ${uid})`)}function assertRealDirectory(path,stats,uid){
287
+ if(stats.isSymbolicLink())throw new Error(`Refusing to use ${path}: it is a symbolic link`);if(!stats.isDirectory())throw new Error(`Refusing to use ${path}: it is not a directory`);assertOwnedByUser(path,stats,uid)}var STICKY_BIT=512,GROUP_OTHER_WRITE=18;function assertSafeAncestors(dir,uid=currentUid()){let current=realpathSync(dirname(resolve(dir)));for(;;){let stats=lstatSync(current);if(!stats.isDirectory())throw new Error(`Refusing to use ${dir}: ancestor ${current} is not a directory`);if(uid!==
288
+ void 0&&stats.uid!==uid&&stats.uid!==0)throw new Error(`Refusing to use ${dir}: ancestor ${current} is owned by uid ${stats.uid}, not the current user (uid ${uid}) or root`);if((stats.mode&GROUP_OTHER_WRITE)!==0&&(stats.mode&STICKY_BIT)===0){let mode=(stats.mode&4095).toString(8).padStart(4,"0");throw new Error(`Refusing to use ${dir}: ancestor ${current} is writable by other users (mode ${mode}) without the sticky bit`)}let parent=dirname(current);if(parent===current)return;current=parent}}function assertCanonicalRuntimeDir(runtimeDir){
289
+ if(resolve(runtimeDir)!==runtimeDir)throw new Error(`Refusing to use ${runtimeDir}: it is not canonical (not an absolute, normalized path); derive paths with resolveCoordinationRuntimePaths`);let existing=runtimeDir;for(;;){try{lstatSync(existing);break}catch(error){if(error.code!=="ENOENT")throw error}let parent=dirname(existing);if(parent===existing)break;existing=parent}let canonical=realpathSync(existing);if(canonical!==existing)throw new Error(`Refusing to use ${runtimeDir}: ${existing} is \
290
+ not canonical (it resolves through a symbolic link or is not absolute, to ${canonical}); derive paths with resolveCoordinationRuntimePaths`)}function ensureRuntimeDir(dir,uid=currentUid()){mkdirSync(dir,{recursive:!0,mode:COORDINATION_DIR_MODE}),assertSafeAncestors(dir,uid);let checked=lstatSync(dir);assertRealDirectory(dir,checked,uid);let fd=openSync(dir,constants.O_RDONLY|constants.O_DIRECTORY|constants.O_NOFOLLOW);try{let opened=fstatSync(fd);if(opened.dev!==checked.dev||opened.ino!==checked.
291
+ ino)throw new Error(`Refusing to use ${dir}: it changed while being verified`);if(fchmodSync(fd,COORDINATION_DIR_MODE),(fstatSync(fd).mode&63)!==0)throw new Error(`Refusing to use ${dir}: its permissions could not be restricted to owner-only`)}finally{closeSync(fd)}}function ensureCoordinationRuntimeDir(paths,uid=currentUid()){ensureRuntimeDir(dirname(paths.runtimeDir),uid),ensureRuntimeDir(paths.runtimeDir,uid);let socketDir=dirname(paths.socketPath);socketDir!==paths.runtimeDir&&ensureRuntimeDir(
292
+ socketDir,uid)}function assertPrivateSocket(socketPath,uid=currentUid()){let parent=dirname(socketPath),parentStats=lstatSync(parent);if(assertRealDirectory(parent,parentStats,uid),(parentStats.mode&63)!==0)throw new Error(`Refusing to connect to ${socketPath}: directory ${parent} is accessible to other users`);let socketStats=lstatSync(socketPath);if(!socketStats.isSocket())throw new Error(`Refusing to connect to ${socketPath}: it is not a socket`);assertOwnedByUser(socketPath,socketStats,uid)}
293
+ function restrictRuntimeFile(filePath){chmodSync(filePath,COORDINATION_FILE_MODE)}var AGENT_MONITOR_PROTOCOL={name:"humain-agent-monitor",version:1},AGENT_MONITOR_COMMAND="__humain-agent-monitor",AGENT_MONITOR_ROLE="agent-monitor",MAX_REPORT_FRAME_BYTES=64*1024,MAX_SNAPSHOT_FRAME_BYTES=256*1024,MAX_AGENTS=512,MAX_CHILDREN=32,MAX_TEXT=160,MAX_PATH_TEXT=1024,MAX_ID=256,MAX_SOCKET_PATH_BYTES2=100;function resolveAgentMonitorPaths(agentDir,uid=process.getuid?.()){mkdirSync2(agentDir,{recursive:!0,mode:COORDINATION_DIR_MODE});let runtimeDir=join3(realpathSync2(agentDir),"agent-mon\
294
+ itor","run");assertSafeAncestors(join3(runtimeDir,".."),uid);let defaultSocket=join3(runtimeDir,"monitor.sock"),hash=createHash2("sha256").update(runtimeDir).digest("hex").slice(0,16),socketPath=Buffer.byteLength(defaultSocket,"utf8")<=MAX_SOCKET_PATH_BYTES2?defaultSocket:join3(getCanonicalTmpDir(),`humain-agent-monitor-${uid??0}`,`${hash}.sock`);return{runtimeDir,socketPath,pidPath:join3(runtimeDir,"monitor.pid"),spawnLockPath:join3(runtimeDir,"monitor.spawn.lock")}}function cleanText(value,max=MAX_TEXT){
295
+ return toSubagentPresentationText(value,max)??void 0}function isRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}function isTime(value){return typeof value=="number"&&Number.isSafeInteger(value)&&value>=0}function isId(value){return typeof value=="string"&&value.length>0&&value.length<=MAX_ID}function isPid(value){return typeof value=="number"&&Number.isSafeInteger(value)&&value>0}var MODES=["tui","print","json","rpc"],TOOLS=["humain","claude","codex"],STATUSES=["\
296
+ attention","working","idle","unknown"];function parseHello(value){if(!(!isRecord(value)||value.type!=="hello")&&!(typeof value.protocol!="string"||typeof value.version!="number"||!isPid(value.pid)))return{type:"hello",protocol:value.protocol,version:value.version,pid:value.pid}}function parseReport(value){if(!isRecord(value)||value.type!=="report"||!isRecord(value.session)||!Array.isArray(value.children)||value.children.length>MAX_CHILDREN||value.truncated!==void 0&&typeof value.truncated!="bool\
297
+ ean")return;let session=value.session,mode=MODES.find(candidate=>candidate===session.mode);if("mode"in session&&!mode||!isId(session.id)||!isTime(session.updatedAt))return;let status=session.status;if(status!=="attention"&&status!=="working"&&status!=="idle")return;let children=[];for(let child of value.children){if(!isRecord(child)||!isId(child.id)||!isTime(child.updatedAt))return;children.push({id:child.id,name:cleanText(child.name)??"subagent",updatedAt:child.updatedAt})}let reason=status==="\
298
+ attention"?cleanText(session.reason):void 0;return{type:"report",session:{id:session.id,...mode!==void 0?{mode}:{},name:cleanText(session.name)??"Unnamed session",cwd:cleanText(session.cwd,MAX_PATH_TEXT)??"",status,...reason!==void 0?{reason}:{},updatedAt:session.updatedAt},children,...value.truncated!==void 0?{truncated:value.truncated}:{}}}function parseRow(value){if(!isRecord(value)||!isId(value.id)||!isPid(value.pid)||!isTime(value.updatedAt))return;let mode=MODES.find(candidate=>candidate===
299
+ value.mode);if("mode"in value&&!mode)return;let tool=TOOLS.find(candidate=>candidate===value.tool),status=STATUSES.find(candidate=>candidate===value.status);if(!tool||!status||value.source!=="native"&&value.source!=="process"||value.parentId!==void 0&&!isId(value.parentId))return;let cwd=cleanText(value.cwd,MAX_PATH_TEXT),reason=cleanText(value.reason);return{id:value.id,...value.parentId!==void 0?{parentId:value.parentId}:{},tool,...mode!==void 0?{mode}:{},name:cleanText(value.name)??"agent",...cwd!==
300
+ void 0?{cwd}:{},pid:value.pid,status,...reason!==void 0?{reason}:{},updatedAt:value.updatedAt,source:value.source}}function parseSnapshot(value){if(!isRecord(value)||value.type!=="snapshot"||!Array.isArray(value.agents)||value.agents.length>MAX_AGENTS||value.coverage!=="complete"&&value.coverage!=="partial")return;let agents=[];for(let candidate of value.agents){let row=parseRow(candidate);if(!row)return;agents.push(row)}let note=cleanText(value.note);return{type:"snapshot",agents,coverage:value.
301
+ coverage,...note!==void 0?{note}:{}}}import{lstatSync as lstatSync2,unlinkSync as unlinkSync2}from"node:fs";import net from"node:net";import{randomBytes}from"node:crypto";import{closeSync as closeSync2,constants as constants2,fchmodSync as fchmodSync2,fstatSync as fstatSync2,fsyncSync,linkSync,openSync as openSync2,readSync,renameSync,unlinkSync,writeSync}from"node:fs";import{dirname as dirname2}from"node:path";var MAX_RUNTIME_TEXT_FILE_BYTES=4096;function fsyncDirectory(dir){let fd;try{fd=openSync2(dir,constants2.O_RDONLY),fsyncSync(fd)}catch{}finally{if(fd!==void 0)try{closeSync2(fd)}catch{}}}function removeQuietly(path){try{unlinkSync(path)}catch{}}function errorCode(error){if(!(typeof error!="object"||error===null||!("code"in error)))return typeof error.code=="string"?error.code:void 0}function writeAll(fd,body){let offset=0;for(;offset<body.length;)offset+=writeSync(fd,body,offset)}function temporaryPathFor(path){
302
+ return`${path}.${randomBytes(6).toString("hex")}.tmp`}function writeBytesAtomic(path,body){let tempPath=temporaryPathFor(path),fd=openSync2(tempPath,constants2.O_WRONLY|constants2.O_CREAT|constants2.O_EXCL,COORDINATION_FILE_MODE),fdOpen=!0,renamed=!1;try{writeAll(fd,body),fchmodSync2(fd,COORDINATION_FILE_MODE),fsyncSync(fd),fdOpen=!1,closeSync2(fd),renameSync(tempPath,path),renamed=!0}finally{if(fdOpen)try{closeSync2(fd)}catch{}renamed||removeQuietly(tempPath)}fsyncDirectory(dirname2(path))}function writeJsonAtomic(path,value,maxBytes){
303
+ writeTextAtomic(path,`${JSON.stringify(value)}
304
+ `,maxBytes)}function writeTextAtomic(path,text,maxBytes){let body=Buffer.from(text,"utf8");if(body.length>maxBytes)throw new Error(`Snapshot exceeds ${maxBytes} bytes`);writeBytesAtomic(path,body)}function createFileExclusive(path,content){let body=Buffer.from(content,"utf8"),tempPath=temporaryPathFor(path),fd=openSync2(tempPath,constants2.O_WRONLY|constants2.O_CREAT|constants2.O_EXCL,COORDINATION_FILE_MODE);try{try{writeAll(fd,body),fchmodSync2(fd,COORDINATION_FILE_MODE)}finally{closeSync2(fd)}
305
+ return linkSync(tempPath,path),!0}catch(error){if(errorCode(error)==="EEXIST")return!1;throw error}finally{removeQuietly(tempPath)}}function readBoundedTextFile(path,maxBytes){let fd;try{fd=openSync2(path,constants2.O_RDONLY|constants2.O_NOFOLLOW|constants2.O_NONBLOCK)}catch(error){if(errorCode(error)==="ENOENT")return;throw error}try{let stats=fstatSync2(fd);if(!stats.isFile())throw new Error(`${path} is not a regular file`);if(stats.size>maxBytes)throw new Error(`${path} exceeds ${maxBytes} by\
306
+ tes`);let limit=Math.min(stats.size,maxBytes)+1,buffer=Buffer.allocUnsafe(limit),length=0;for(;length<limit;){let read=readSync(fd,buffer,length,limit-length,null);if(read===0)break;length+=read}if(length>stats.size)throw new Error(`${path} changed while being read`);return{text:buffer.toString("utf8",0,length),dev:stats.dev,ino:stats.ino,mtimeMs:stats.mtimeMs}}finally{closeSync2(fd)}}function readTextFile(path,maxBytes){return readBoundedTextFile(path,maxBytes)?.text}function readJsonFile(path,maxBytes){
307
+ let file=readBoundedTextFile(path,maxBytes);return file===void 0?void 0:JSON.parse(file.text)}function framePayloadBytes(msg){return Buffer.byteLength(JSON.stringify(msg),"utf-8")}var MAX_SOCKET_WRITE_BACKLOG_BYTES=8*1024*1024;function writeMessage(socket,msg){let json=JSON.stringify(msg),payloadLength=Buffer.byteLength(json,"utf-8"),frame=Buffer.allocUnsafeSlow(4+payloadLength);frame.writeUInt32BE(payloadLength,0),frame.write(json,4,payloadLength,"utf-8"),socket.write(frame),socket.writableLength>MAX_SOCKET_WRITE_BACKLOG_BYTES&&socket.destroy()}function createMessageReader(onMessage,onError,maxFrameBytes=1048576){
308
+ let header=Buffer.allocUnsafe(4),headerBytes=0,payload=null,payloadBytes=0,payloadLength=0;function reportMessage(framePayload){let msg;try{msg=JSON.parse(framePayload.toString("utf-8"))}catch(error){let message=error instanceof Error?error.message:String(error);return onError(new Error(`Failed to parse intercom message: ${message}`,{cause:error})),!1}try{return onMessage(msg),!0}catch(error){let message=error instanceof Error?error.message:String(error);return onError(new Error(`Failed to handl\
309
+ e intercom message: ${message}`,{cause:error})),!1}}return data=>{let offset=0;for(;offset<data.length;){if(headerBytes<4){let bytes2=Math.min(4-headerBytes,data.length-offset);if(data.copy(header,headerBytes,offset,offset+bytes2),headerBytes+=bytes2,offset+=bytes2,headerBytes<4)return;if(payloadLength=header.readUInt32BE(0),payloadLength>maxFrameBytes){headerBytes=0,onError(new Error(`Intercom frame length ${payloadLength} exceeds maximum ${maxFrameBytes} bytes`));return}}if(payloadBytes===0&&data.
310
+ length-offset>=payloadLength){let framePayload2=data.subarray(offset,offset+payloadLength);if(offset+=payloadLength,headerBytes=0,payload=null,payloadLength=0,!reportMessage(framePayload2))return;continue}(payload===null||payload.length!==payloadLength)&&(payload=Buffer.allocUnsafe(payloadLength));let bytes=Math.min(payloadLength-payloadBytes,data.length-offset);if(data.copy(payload,payloadBytes,offset,offset+bytes),payloadBytes+=bytes,offset+=bytes,payloadBytes<payloadLength)return;let framePayload=payload;
311
+ if(headerBytes=0,payload=null,payloadBytes=0,payloadLength=0,!reportMessage(framePayload))return}}}import{execFile}from"node:child_process";import{readlink}from"node:fs/promises";import{basename}from"node:path";import{promisify}from"node:util";var execFileAsync=promisify(execFile),PS_TIMEOUT_MS=2e3,PS_MAX_BYTES=8*1024*1024,CWD_TIMEOUT_MS=2e3,UNAVAILABLE_NOTE="Claude Code and Codex discovery is unavailable.",TOOL_NAMES={claude:"Claude Code",codex:"Codex"},NO_TTY=new Set(["?","??","-"]),LINE=/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+([A-Z][a-z]{2}\s+[A-Z][a-z]{2}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+\d{4})\s+(.*)$/;
312
+ function parsePsOutput(stdout){let entries=[];for(let line of stdout.split(`
313
+ `)){let match=LINE.exec(line);if(!match)continue;let tool=classifyProcess(match[6]??"");entries.push({uid:Number(match[1]),pid:Number(match[2]),ppid:Number(match[3]),tty:match[4]??"",started:match[5]??"",...tool?{tool}:{}})}return entries}function classifyProcess(args){let[first="",second=""]=args.trim().split(/\s+/,2),executable=basename(first);if(executable==="claude")return"claude";if(executable==="codex")return"codex";if(!(executable!=="node"&&executable!=="bun")){if(/[\\/]@anthropic-ai[\\/]claude-code[\\/]cli\.js$/.
314
+ test(second))return"claude";if(/[\\/]@openai[\\/]codex[\\/]bin[\\/]codex\.js$/.test(second))return"codex"}}function findExternalAgents(entries,uid){let candidates=new Map;for(let entry of entries){if(entry.uid!==uid||NO_TTY.has(entry.tty))continue;let{tool}=entry;tool&&candidates.set(entry.pid,{tool,pid:entry.pid,ppid:entry.ppid,started:entry.started})}return[...candidates.values()].filter(candidate=>candidates.get(candidate.ppid)?.tool!==candidate.tool)}async function defaultListProcesses(){let{
315
+ stdout}=await execFileAsync("ps",["-A","-o","uid=,pid=,ppid=,tty=,lstart=,args="],{timeout:PS_TIMEOUT_MS,maxBuffer:PS_MAX_BYTES,env:{PATH:process.env.PATH??"/usr/bin:/bin",LC_ALL:"C"}});return stdout}async function defaultReadCwd(pid){if(process.platform==="linux")return await readlink(`/proc/${pid}/cwd`).catch(()=>{});let{stdout}=await execFileAsync("lsof",["-a","-p",String(pid),"-d","cwd","-Fn"],{timeout:CWD_TIMEOUT_MS,maxBuffer:64*1024,env:{PATH:process.env.PATH??"/usr/bin:/bin:/usr/sbin",LC_ALL:"\
316
+ C"}});return/^n(.+)$/m.exec(stdout)?.[1]}var ExternalDiscovery=class{deps;known=new Map;constructor(deps={}){this.deps={listProcesses:deps.listProcesses??defaultListProcesses,readCwd:deps.readCwd??defaultReadCwd,uid:deps.uid??process.getuid?.()??-1,now:deps.now??Date.now}}async scan(){let entries;try{entries=parsePsOutput(await this.deps.listProcesses())}catch{return this.known.clear(),{agents:[],coverage:"partial",note:UNAVAILABLE_NOTE}}let candidates=findExternalAgents(entries,this.deps.uid).map(
317
+ candidate=>({...candidate,id:`${candidate.tool}:${candidate.pid}:${candidate.started}`}));await Promise.all(candidates.filter(candidate=>!this.known.has(candidate.id)).map(async candidate=>{this.known.set(candidate.id,{cwd:await this.deps.readCwd(candidate.pid).catch(()=>{}),firstSeen:this.deps.now()})}));let next=new Map,agents=[];for(let candidate of candidates){let{id}=candidate,info=this.known.get(id);next.set(id,info),agents.push({id,tool:candidate.tool,name:TOOL_NAMES[candidate.tool],...info.
318
+ cwd!==void 0?{cwd:info.cwd}:{},pid:candidate.pid,status:"unknown",updatedAt:info.firstSeen,source:"process"})}return this.known=next,{agents,coverage:"complete"}}};var MAX_CONNECTIONS=128,HELLO_TIMEOUT_MS=5e3,TRUNCATED_NOTE="Too many agents to show; the list is incomplete.",TRUNCATED_CHILDREN_NOTE="Too many subagents to show; the list is incomplete.",NON_TUI_VISIBILITY_DELAY_MS=5e3,MonitorAlreadyRunningError=class extends Error{constructor(socketPath){super(`Agent monitor already running (socket ${socketPath} is in use); not starting another`),this.name="MonitorAlreadyRunningError"}};function errorCode2(error){return error?.code}function isListening(socketPath){
319
+ return new Promise(resolve2=>{let socket=net.connect(socketPath),settle=live=>{clearTimeout(timer),socket.destroy(),resolve2(live)},timer=setTimeout(()=>settle(!0),1e3);socket.once("connect",()=>settle(!0)),socket.once("error",error=>{let code=errorCode2(error);settle(code!=="ECONNREFUSED"&&code!=="ENOENT")})})}function unlinkQuietly(path){try{unlinkSync2(path)}catch{}}function fitFrame(agents){let budget=MAX_SNAPSHOT_FRAME_BYTES-4096,kept=[];for(let agent of agents.slice(0,MAX_AGENTS)){if(budget-=
320
+ Buffer.byteLength(JSON.stringify(agent),"utf8")+1,budget<0)break;kept.push(agent)}return{agents:kept,truncated:kept.length<agents.length}}var AgentMonitorServer=class{paths;discover;scanIntervalMs;idleShutdownMs;pushDelayMs;now;visibilityDelayMs;onExit;server;connections=new Set;consumers=new Map;external={agents:[],coverage:"complete"};scanTimer;pushTimer;idleTimer;scanning=!1;serving=!1;stopped=!1;constructor(options){this.paths=options.paths,this.discover=options.discover??(()=>{let discovery=new ExternalDiscovery;
321
+ return()=>discovery.scan()})(),this.scanIntervalMs=options.scanIntervalMs??2e3,this.idleShutdownMs=options.idleShutdownMs??5e3,this.pushDelayMs=options.pushDelayMs??100,this.now=options.now??Date.now,this.visibilityDelayMs=options.visibilityDelayMs??NON_TUI_VISIBILITY_DELAY_MS,this.onExit=options.onExit??(code=>process.exit(code)),ensureCoordinationRuntimeDir(this.paths),this.server=net.createServer(socket=>this.accept(socket))}async start(){await this.claimSocket(),this.server.on("error",()=>this.
322
+ shutdown()),this.serving=!0,restrictRuntimeFile(this.paths.socketPath),writeTextAtomic(this.paths.pidPath,String(process.pid),MAX_RUNTIME_TEXT_FILE_BYTES),this.armIdle()}listen(){return new Promise((resolve2,reject)=>{let onError=error=>{this.server.off("listening",onListening),reject(error)},onListening=()=>{this.server.off("error",onError),resolve2()};this.server.once("error",onError),this.server.once("listening",onListening),this.server.listen(this.paths.socketPath)})}async claimSocket(){try{
323
+ await this.listen();return}catch(error){if(errorCode2(error)!=="EADDRINUSE")throw error}if(await isListening(this.paths.socketPath))throw new MonitorAlreadyRunningError(this.paths.socketPath);if(!lstatSync2(this.paths.socketPath).isSocket())throw new Error(`Refusing to remove ${this.paths.socketPath}: it is not a socket`);unlinkSync2(this.paths.socketPath);try{await this.listen()}catch(error){throw errorCode2(error)==="EADDRINUSE"?new MonitorAlreadyRunningError(this.paths.socketPath):error}}accept(socket){
324
+ if(this.stopped||this.connections.size>=MAX_CONNECTIONS){socket.destroy();return}this.connections.add(socket);let helloTimer=setTimeout(()=>{this.consumers.has(socket)||socket.destroy()},HELLO_TIMEOUT_MS);socket.on("data",createMessageReader(message=>this.handle(socket,message),()=>socket.destroy(),MAX_REPORT_FRAME_BYTES)),socket.on("error",()=>{}),socket.on("close",()=>{clearTimeout(helloTimer),this.connections.delete(socket);let consumer=this.consumers.get(socket);consumer&&(clearTimeout(consumer.
325
+ revealTimer),this.consumers.delete(socket),this.schedulePush(),this.updateIdle())})}hasViewer(){for(let consumer of this.consumers.values()){let mode=consumer.report?.session.mode;if(mode===void 0||mode==="tui")return!0}return!1}updateIdle(){this.hasViewer()?(this.cancelIdle(),this.startScanning()):(this.stopScanning(),this.armIdle())}handle(socket,message){if(typeof message!="object"||message===null||!("type"in message))throw new Error("Invalid message");let typed=message;if(typed.type==="healt\
326
+ h"&&typeof typed.requestId=="string"){writeMessage(socket,{type:"health_ok",requestId:typed.requestId,protocol:AGENT_MONITOR_PROTOCOL.name,version:AGENT_MONITOR_PROTOCOL.version});return}if(typed.type==="hello"){let hello=parseHello(message);if(!hello)throw new Error("Invalid hello");if(hello.protocol!==AGENT_MONITOR_PROTOCOL.name||hello.version!==AGENT_MONITOR_PROTOCOL.version){writeMessage(socket,{type:"incompatible",version:AGENT_MONITOR_PROTOCOL.version}),socket.end();return}if(this.consumers.
327
+ has(socket))throw new Error("Duplicate hello");let consumer2={pid:hello.pid,connectedAt:this.now(),revealed:!1,revealTimer:setTimeout(()=>{consumer2.revealed=!0,this.schedulePush()},this.visibilityDelayMs)};consumer2.revealTimer.unref(),this.consumers.set(socket,consumer2),writeMessage(socket,{type:"welcome"}),this.updateIdle(),this.schedulePush();return}let consumer=this.consumers.get(socket);if(!consumer)throw new Error("Message before hello");if(typed.type!=="report")throw new Error("Unknown \
328
+ message");let report=parseReport(message);if(!report)throw new Error("Invalid report");consumer.report=report,this.updateIdle(),this.schedulePush()}startScanning(){this.scanTimer||(this.scan(),this.scanTimer=setInterval(()=>{this.scan()},this.scanIntervalMs))}stopScanning(){this.scanTimer&&clearInterval(this.scanTimer),this.scanTimer=void 0}async scan(){if(!(this.scanning||this.stopped)){this.scanning=!0;try{this.external=await this.discover()}catch{this.external={agents:[],coverage:"partial",note:UNAVAILABLE_NOTE}}finally{
329
+ this.scanning=!1}this.schedulePush()}}snapshot(){let all=[],childrenTruncated=!1;for(let consumer of this.consumers.values()){let report=consumer.report;if(!report||report.session.mode!==void 0&&report.session.mode!=="tui"&&!consumer.revealed&&this.now()-consumer.connectedAt<this.visibilityDelayMs)continue;report.truncated&&(childrenTruncated=!0);let id=`humain:${consumer.pid}:${report.session.id}`,{session}=report;all.push({id,tool:"humain",...session.mode!==void 0?{mode:session.mode}:{},name:session.
330
+ name,...session.cwd?{cwd:session.cwd}:{},pid:consumer.pid,status:session.status,...session.reason!==void 0?{reason:session.reason}:{},updatedAt:session.updatedAt,source:"native"});for(let child of report.children)all.push({id:`${id}/${child.id}`,parentId:id,tool:"humain",...session.mode!==void 0?{mode:session.mode}:{},name:child.name,...session.cwd?{cwd:session.cwd}:{},pid:consumer.pid,status:"working",updatedAt:child.updatedAt,source:"native"})}all.push(...this.external.agents);let{agents,truncated}=fitFrame(
331
+ all),note=[truncated?TRUNCATED_NOTE:void 0,childrenTruncated?TRUNCATED_CHILDREN_NOTE:void 0,this.external.note].filter(note2=>note2!==void 0).join(" ");return{type:"snapshot",agents,coverage:truncated||childrenTruncated||this.external.coverage==="partial"?"partial":"complete",...note?{note}:{}}}schedulePush(){this.pushTimer||this.stopped||(this.pushTimer=setTimeout(()=>{this.pushTimer=void 0,this.push()},this.pushDelayMs))}push(){let snapshot=this.snapshot(),payload=JSON.stringify(snapshot);for(let[
332
+ socket,consumer]of this.consumers)consumer.lastSent!==payload&&(consumer.lastSent=payload,writeMessage(socket,snapshot))}armIdle(){this.idleTimer||this.stopped||(this.idleTimer=setTimeout(()=>{this.idleTimer=void 0,this.hasViewer()||this.shutdown()},this.idleShutdownMs))}cancelIdle(){this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=void 0}shutdown(){if(!this.stopped){this.stopped=!0,this.cancelIdle(),this.stopScanning(),this.pushTimer&&clearTimeout(this.pushTimer);for(let consumer of this.
333
+ consumers.values())clearTimeout(consumer.revealTimer);for(let socket of this.connections)socket.destroy();this.serving&&(unlinkQuietly(this.paths.socketPath),unlinkQuietly(this.paths.pidPath)),this.server.close(),this.onExit(0)}}};async function runAgentMonitorCommand(env){let role=env[COORDINATION_ROLE_ENV];if(delete env[COORDINATION_ROLE_ENV],role!==AGENT_MONITOR_ROLE)return console.error("This command is internal to HUMAIN Code CLI."),2;process.stderr.on("error",()=>{}),process.stdout.on("error",()=>{});let server;try{server=new AgentMonitorServer({paths:resolveAgentMonitorPaths(getAgentDir())}),await server.start()}catch(error){return console.error(error instanceof MonitorAlreadyRunningError?error.message:`Agent monit\
334
+ or failed to start: ${error instanceof Error?error.message:String(error)}`),1}let stop=()=>server.shutdown();return process.on("SIGTERM",stop),process.on("SIGINT",stop),process.on("SIGHUP",stop),await new Promise(()=>{})}export{COORDINATION_BROKER_COMMAND,COORDINATION_ROLE_ENV,COORDINATION_ROLE,detectLaunchRuntime,getInternalCommandLaunchSpec,getBrokerLaunchSpec,value_exports2 as value_exports,Compile,compile_exports,FLOW_ID_PATTERN,FLOW_MODEL_ID_PATTERN,FLOW_DIGEST_PATTERN,FlowContractError,lit,StrictObject,FlowIdSchema,FlowDigestSchema,FlowTimestampSchema,FlowMicrousdSchema,FlowCountSchema,FlowPositiveIntSchema,FlowModelRefSchema,FLOW_ROLES,FlowRoleSchema,partialByRole,FlowSizeSchema,FlowFailureClassSchema,FlowReasonClassSchema,
335
+ FlowProfileRefSchema,verifyFlowDigest,parseFlowData,compileFlow,hasDuplicateModels,canonicalFlowJson,canonicalWithout,SUBAGENT_FAILURE_KINDS,SUBAGENT_RUN_MODES,SUBAGENT_PROGRESS_IDENTIFIER_PATTERN,SUBAGENT_PROGRESS_MODEL_PATTERN,SUBAGENT_PROGRESS_TOOL_CALL_ID_PATTERN,isCanonicalSubagentProgressUuid,toSubagentPresentationText,parseSubagentRunSnapshot,parseSubagentProgressSnapshot,HUMAIN_AGENT_EXECUTION_SCHEMA_VERSION,HumainAgentRouteRefSchema,HumainAgentArtifactSchema,HumainAgentExecutionControlsSchema,
336
+ HumainAgentExecutionClaimSchema,HumainAgentExecutionRequestSchema,HumainAgentUsageSchema,HUMAIN_AGENT_EXECUTION_FAILURE_CODES,HumainAgentExecutionOutcomeSchema,HumainAgentExecutionResponseSchema,parseHumainAgentExecutionRequest,parseHumainAgentExecutionResponse,COORDINATION_FILE_MODE,COORDINATION_PROTOCOL_NAME,COORDINATION_PROTOCOL_VERSION,MAX_MESSAGE_TEXT_BYTES,getCoordinationRuntimePaths,resolveCoordinationRuntimePaths,assertSafeAncestors,assertCanonicalRuntimeDir,ensureRuntimeDir,ensureCoordinationRuntimeDir,
337
+ assertPrivateSocket,restrictRuntimeFile,AGENT_MONITOR_PROTOCOL,AGENT_MONITOR_COMMAND,AGENT_MONITOR_ROLE,MAX_SNAPSHOT_FRAME_BYTES,MAX_CHILDREN,MAX_ID,resolveAgentMonitorPaths,parseSnapshot,MAX_RUNTIME_TEXT_FILE_BYTES,fsyncDirectory,writeJsonAtomic,writeTextAtomic,createFileExclusive,readBoundedTextFile,readTextFile,readJsonFile,framePayloadBytes,writeMessage,createMessageReader,runAgentMonitorCommand};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{theme}from"./chunk-CN3Q5UNB.js";var ARMIN_WIDTH=31,ARMIN_HEIGHT=36,WIDTH=ARMIN_WIDTH,HEIGHT=ARMIN_HEIGHT,BITS=[255,255,255,127,255,240,255,127,255,237,255,127,255,219,255,127,255,183,255,127,255,119,254,127,63,248,254,127,223,255,254,127,223,63,252,127,159,195,251,127,111,252,244,127,247,15,247,127,247,255,247,127,247,255,227,127,247,7,232,127,239,248,103,112,15,255,187,111,241,0,208,91,253,63,236,83,193,255,239,87,159,253,238,95,159,252,174,95,31,120,172,95,63,0,80,108,127,0,220,119,255,192,63,120,255,1,248,127,255,3,156,120,
2
+ import{theme}from"./chunk-CFHOPLW5.js";var ARMIN_WIDTH=31,ARMIN_HEIGHT=36,WIDTH=ARMIN_WIDTH,HEIGHT=ARMIN_HEIGHT,BITS=[255,255,255,127,255,240,255,127,255,237,255,127,255,219,255,127,255,183,255,127,255,119,254,127,63,248,254,127,223,255,254,127,223,63,252,127,159,195,251,127,111,252,244,127,247,15,247,127,247,255,247,127,247,255,227,127,247,7,232,127,239,248,103,112,15,255,187,111,241,0,208,91,253,63,236,83,193,255,239,87,159,253,238,95,159,252,174,95,31,120,172,95,63,0,80,108,127,0,220,119,255,192,63,120,255,1,248,127,255,3,156,120,
3
3
  255,7,140,124,255,15,206,120,255,255,207,127,255,255,207,120,255,255,223,120,255,255,223,125,255,255,63,126,255,255,255,127],BYTES_PER_ROW=Math.ceil(WIDTH/8),DISPLAY_HEIGHT=Math.ceil(HEIGHT/2),EFFECTS=["typewriter","scanline","rain","fade","crt","glitch","dissolve"];function isArminPixel(x,y){if(y>=HEIGHT)return!1;let byteIndex=y*BYTES_PER_ROW+Math.floor(x/8),bitIndex=x%8;return(BITS[byteIndex]>>bitIndex&1)===0}function getChar(x,row){let upper=isArminPixel(x,row*2),lower=isArminPixel(x,row*2+1);
4
4
  return upper&&lower?"\u2588":upper?"\u2580":lower?"\u2584":" "}function buildFinalGrid(){let grid=[];for(let row=0;row<DISPLAY_HEIGHT;row++){let line=[];for(let x=0;x<WIDTH;x++)line.push(getChar(x,row));grid.push(line)}return grid}var ArminComponent=class{ui;interval=null;effect;finalGrid;currentGrid;effectState={};cachedLines=[];cachedWidth=0;gridVersion=0;cachedVersion=-1;constructor(ui){this.ui=ui,this.effect=EFFECTS[Math.floor(Math.random()*EFFECTS.length)],this.finalGrid=buildFinalGrid(),this.
5
5
  currentGrid=this.createEmptyGrid(),this.initEffect(),this.startAnimation()}invalidate(){this.cachedWidth=0}render(width){if(width===this.cachedWidth&&this.cachedVersion===this.gridVersion)return this.cachedLines;let padding=1,availableWidth=width-padding;this.cachedLines=this.currentGrid.map(row=>{let clipped=row.slice(0,availableWidth).join(""),padRight=Math.max(0,width-padding-clipped.length);return` ${theme.fg("accent",clipped)}${" ".repeat(padRight)}`});let message="ARMIN SAYS HI",msgPadRight=Math.
@@ -31,4 +31,22 @@ committed.pop(),endValue(i);else if(code===123||code===91)scan.closers.push(code
31
31
  closer===125?OBJECT_KEY:VALUE;else if(code===closer)scan.closers.pop(),scan.committed.pop(),endValue(i);else{scan.valid=!1;return}}else{scan.valid=!1;return}}}function parsePartialJsonPrefix(scan,text){if(scan.text.length>0&&text.length>=scan.text.length&&text.startsWith(scan.text)?scan.valid&&scanPartialJson(scan,text,scan.text.length):(Object.assign(scan,createPartialJsonScan()),scanPartialJson(scan,text,0)),scan.text=text,!scan.valid||scan.protoKey||scan.closers.length===0)return;let completed,
32
32
  state=scan.state;if(state===AFTER_VALUE)completed=text;else if(state===LITERAL)completed=text+scan.literal.slice(scan.literalIndex);else if(state===NUMBER){if(!isNumberComplete(scan.numberState))return;completed=text}else if(state===VALUE_STRING){let end=text.length;for(;end>scan.stringStart+1&&isTrimmedByTrim(text.charCodeAt(end-1));)end--;end<text.length?completed=`${text.slice(0,end)}"`:scan.escapeStart!==-1?completed=`${text.slice(0,scan.escapeStart)}"`:completed=`${text}"`}else completed=text.
33
33
  slice(0,scan.committed[scan.committed.length-1]);for(let level=scan.closers.length-1;level>=0;level--)completed+=scan.closers[level]===125?"}":"]";try{return JSON.parse(completed)}catch{return}}var lengthsParsedWhileStreaming=new WeakMap,textsParsedWhileStreaming=new WeakMap,scansWhileStreaming=new WeakMap;function parseStreamingJsonWhileStreaming(block,partialJson,current){let length=partialJson?.length??0,parsed=lengthsParsedWhileStreaming.get(block);if(current!==void 0&&parsed!==void 0&&(length>
34
- parsed||partialJson===textsParsedWhileStreaming.get(block))&&length-parsed<(parsed<1024?1:parsed>>3))return current;lengthsParsedWhileStreaming.set(block,length),textsParsedWhileStreaming.set(block,partialJson);let scan=scansWhileStreaming.get(block);return scan||(scan=createPartialJsonScan(),scansWhileStreaming.set(block,scan)),parseStreamingJsonWith(partialJson,scan)}export{require_dist,repairJson,parseJsonWithRepair,parseToolCallArguments,parseStreamingJson,parseStreamingJsonWhileStreaming};
34
+ parsed||partialJson===textsParsedWhileStreaming.get(block))&&length-parsed<(parsed<1024?1:parsed>>3))return current;lengthsParsedWhileStreaming.set(block,length),textsParsedWhileStreaming.set(block,partialJson);let scan=scansWhileStreaming.get(block);return scan||(scan=createPartialJsonScan(),scansWhileStreaming.set(block,scan)),parseStreamingJsonWith(partialJson,scan)}var MAX_REPORTED_DEPTH=32,ROOT_SLOT={kind:"root"},CREDIT_PER_APPEND=256,CREDIT_PER_CHARACTER=8,MAX_PENDING_SCALAR_LENGTH=64,NUMBER2=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/,NUMBER_WITHOUT_EXPONENT_DIGITS=/^(-?(?:0|[1-9]\d*)(?:\.\d+)?)[eE][+-]?$/,LITERALS=[["true",!0],["false",!1],["null",null]],QUOTE=34,BACKSLASH=92,StreamingJsonParser=class{#root=void 0;#done=!1;#stack=[];#string=void 0;#scalar="";#scalarSlot=void 0;#pathCost=0;#credit=0;#dirty=!1;#snapshot=void 0;#changes=[];append(text){
35
+ this.#credit+=CREDIT_PER_APPEND+CREDIT_PER_CHARACTER*text.length,this.#changes=[],this.#string!==void 0&&(this.#string.change=void 0);let index=0;for(;index<text.length&&!this.#done;){let open=this.#string;open!==void 0?index=this.#readString(open,text,index):this.#scalar!==""?index=this.#readScalar(text,index):this.#structural(text[index++])}return this.#changes}snapshot(){if(!this.#dirty)return this.#snapshot;let pending=this.#pendingScalar(),cost=this.#pathCost+(pending===void 0?0:1);return cost>
36
+ this.#credit?this.#snapshot:(this.#credit-=cost,this.#dirty=!1,this.#snapshot=this.#copyOpenPath(pending),this.#snapshot)}#readString(open,text,start){let runStart=start;for(let index=start;index<text.length;index++){let code=text.charCodeAt(index);if(open.escape!==""){if(this.#continueEscape(open,text[index])){runStart=index+1;continue}runStart=index}if(code===QUOTE)return index>runStart&&this.#appendString(open,text.slice(runStart,index)),this.#endString(open),index+1;code===BACKSLASH&&(index>
37
+ runStart&&this.#appendString(open,text.slice(runStart,index)),open.escape="\\",runStart=index+1)}return text.length>runStart&&this.#appendString(open,text.slice(runStart)),text.length}#readScalar(text,start){let end=start;for(;end<text.length&&!isDelimiter(text[end]);)end++;return end>start&&(this.#scalar+=text.slice(start,end),this.#scalarSlot!==void 0&&(this.#dirty=!0)),end<text.length&&this.#endScalar(),end}#structural(char){switch(char){case" ":case" ":case`
38
+ `:case"\r":return;case'"':this.#startString();return;case"{":case"[":this.#openContainer(char==="{"?{}:[]);return;case"}":case"]":this.#closeContainer();return;case":":{let frame=this.#stack.at(-1);frame!==void 0&&!Array.isArray(frame.container)&&frame.phase==="colon"&&(frame.phase="value");return}case",":{let frame=this.#stack.at(-1);frame!==void 0&&(frame.phase=Array.isArray(frame.container)?"value":"key");return}default:this.#scalar=char,this.#scalarSlot=this.#valueSlot(),this.#scalarSlot!==void 0&&
39
+ (this.#dirty=!0)}}#valueSlot(){let frame=this.#stack.at(-1);if(frame===void 0)return this.#root===void 0?ROOT_SLOT:void 0;if(Array.isArray(frame.container))return{kind:"element",index:frame.container.length};if((frame.phase==="value"||frame.phase==="colon")&&frame.key!==void 0)return{kind:"member",key:frame.key}}#startString(){let frame=this.#stack.at(-1);if(frame!==void 0&&!Array.isArray(frame.container)&&(frame.phase==="key"||frame.phase==="comma")){this.#string={target:"key",slot:void 0,text:"",
40
+ escape:"",path:void 0,change:void 0};return}let slot=this.#valueSlot(),path=this.#reportedPath(slot);this.#string={target:"value",slot,text:"",escape:"",path,change:void 0},this.#place(slot,""),path!==void 0&&(this.#string.change=this.#report({kind:"set",path,value:""}))}#reportedPath(slot){if(slot===void 0)return;if(slot.kind==="root")return[];let frame=this.#stack.at(-1);if(frame.reportsInside)return[...frame.path,slot.kind==="member"?slot.key:slot.index]}#report(change){return this.#changes.push(
41
+ change),change}#continueEscape(open,char){if(open.escape==="\\"){let decoded=SIMPLE_ESCAPES[char];return decoded!==void 0?(open.escape="",this.#appendString(open,decoded),!0):char==="u"?(open.escape="\\u",!0):(open.escape="",this.#appendString(open,"\\"),!1)}if(isHexDigit2(char)){if(open.escape+=char,open.escape.length<6)return!0;let decoded=String.fromCharCode(Number.parseInt(open.escape.slice(2),16));return open.escape="",this.#appendString(open,decoded),!0}let literal=open.escape;return open.
42
+ escape="",this.#appendString(open,literal),!1}#appendString(open,text){if(open.text+=text,open.target!=="value"||(this.#place(open.slot,open.text),open.path===void 0))return;let change=open.change;if(change!==void 0&&this.#changes.at(-1)===change){change.kind==="set"?change.value=change.value+text:change.text+=text;return}open.change=this.#report({kind:"append",path:open.path,text})}#endString(open){this.#string=void 0;let frame=this.#stack.at(-1);if(open.target==="key"){if(frame===void 0)return;
43
+ frame.key=open.text,frame.phase="colon";return}this.#valueEnded(frame)}#endScalar(){let token=this.#scalar,slot=this.#scalarSlot;this.#scalar="",this.#scalarSlot=void 0;let value=scalarValue(token);if(value!==void 0){this.#place(slot,value);let path=this.#reportedPath(slot);path!==void 0&&this.#report({kind:"set",path,value})}this.#valueEnded(this.#stack.at(-1))}#pendingScalar(){let slot=this.#scalarSlot,token=this.#scalar;if(slot===void 0||token===""||token.length>MAX_PENDING_SCALAR_LENGTH)return;
44
+ let value=pendingScalarValue(token);return value===void 0?void 0:{slot,value}}#openContainer(container){let slot=this.#valueSlot(),path=this.#reportedPath(slot);this.#place(slot,container),this.#stack.push({container,slot,path,reportsInside:path!==void 0&&path.length<MAX_REPORTED_DEPTH,size:0,key:void 0,phase:Array.isArray(container)?"value":"key"}),this.#pathCost+=1,this.#dirty=!0,path!==void 0&&this.#report({kind:"set",path,value:Array.isArray(container)?[]:{}})}#closeContainer(){let frame=this.#stack.
45
+ pop();frame!==void 0&&(this.#pathCost-=frame.size+1,this.#dirty=!0,frame.path!==void 0&&!frame.reportsInside&&this.#report({kind:"set",path:frame.path,value:frame.container}),this.#valueEnded(this.#stack.at(-1)))}#valueEnded(frame){if(frame===void 0){this.#root!==void 0&&(this.#done=!0);return}frame.phase="comma"}#place(slot,value){if(slot===void 0)return;if(this.#dirty=!0,slot.kind==="root"){this.#root=value;return}let frame=this.#stack.at(-1);if(slot.kind==="element"){let elements=frame.container;
46
+ slot.index===elements.length&&(frame.size++,this.#pathCost++),elements[slot.index]=value;return}let members=frame.container;Object.hasOwn(members,slot.key)||(frame.size++,this.#pathCost++),setMember(members,slot.key,value)}#copyOpenPath(pending){if(this.#stack.length===0)return pending?.slot.kind==="root"?pending.value:this.#root;let child,childSlot;for(let depth=this.#stack.length-1;depth>=0;depth--){let frame=this.#stack[depth],copy=Array.isArray(frame.container)?frame.container.slice():{...frame.
47
+ container};depth===this.#stack.length-1&&pending!==void 0&&setSlot(copy,pending.slot,pending.value),child!==void 0&&childSlot!==void 0&&setSlot(copy,childSlot,child),child=copy,childSlot=frame.slot}return childSlot?.kind==="root"?child:this.#root}},ToolCallArgumentsStream=class{#text="";#parser=new StreamingJsonParser;#snapshot=void 0;#arguments={};get text(){return this.#text}append(delta){return this.#text+=delta,this.#parser.append(delta),this.#partial()}replace(text){if(text.startsWith(this.#text)){
48
+ let delta=text.slice(this.#text.length);return{delta,arguments:delta===""?this.#partial():this.append(delta)}}return this.#text="",this.#parser=new StreamingJsonParser,{delta:void 0,arguments:this.append(text)}}finish(){return parseToolCallArguments(this.#text)}#partial(){let snapshot=this.#parser.snapshot();return snapshot===this.#snapshot?this.#arguments:(this.#snapshot=snapshot,this.#arguments=typeof snapshot=="object"&&snapshot!==null&&!Array.isArray(snapshot)?snapshot:{},this.#arguments)}},
49
+ SIMPLE_ESCAPES={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
50
+ `,r:"\r",t:" "};function isDelimiter(char){return char===" "||char===" "||char===`
51
+ `||char==="\r"||char===","||char===":"||char==="{"||char==="}"||char==="["||char==="]"||char==='"'}function isHexDigit2(char){return char>="0"&&char<="9"||char>="a"&&char<="f"||char>="A"&&char<="F"}function scalarValue(token){for(let[literal,value]of LITERALS)if(token===literal)return value;return NUMBER2.test(token)?Number(token):void 0}function pendingScalarValue(token){for(let[literal,value]of LITERALS)if(literal.startsWith(token))return value;if(NUMBER2.test(token))return Number(token);let mantissa=NUMBER_WITHOUT_EXPONENT_DIGITS.
52
+ exec(token);return mantissa===null?void 0:Number(mantissa[1])}function setSlot(container,slot,value){slot.kind==="element"?container[slot.index]=value:slot.kind==="member"&&setMember(container,slot.key,value)}function setMember(members,key,value){key==="__proto__"?Object.defineProperty(members,key,{value,writable:!0,enumerable:!0,configurable:!0}):members[key]=value}export{require_dist,repairJson,parseJsonWithRepair,parseToolCallArguments,parseStreamingJson,parseStreamingJsonWhileStreaming,StreamingJsonParser,ToolCallArgumentsStream};