@humain/humain-code 0.8.2 → 0.8.4

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 (946) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/dist/bundle/agent-monitor.js +1 -1
  3. package/dist/bundle/chunks/anthropic-messages-42CGJCSR.js +82 -0
  4. package/dist/bundle/chunks/ask-VH7GNX75.js +97 -0
  5. package/dist/bundle/chunks/azure-openai-responses-DOKKMBUN.js +15 -0
  6. package/dist/bundle/chunks/bedrock-converse-stream.js +200 -179
  7. package/dist/bundle/chunks/bowser-UX7KDMIY.js +92 -0
  8. package/dist/bundle/chunks/{chunk-46C6D7UC.js → chunk-2CYGUEQO.js} +1 -1
  9. package/dist/bundle/chunks/chunk-3RXT35Y3.js +3 -0
  10. package/dist/bundle/chunks/chunk-4BNDLR6C.js +177 -0
  11. package/dist/bundle/chunks/{chunk-MPRAQ6ZI.js → chunk-4LGBXPUD.js} +1 -1
  12. package/dist/bundle/chunks/chunk-4SL6URR3.js +90 -0
  13. package/dist/bundle/chunks/{chunk-PJXBU6CR.js → chunk-52642TYH.js} +394 -204
  14. package/dist/bundle/chunks/{chunk-LSRXA7OS.js → chunk-5C5K4EVJ.js} +3 -3
  15. package/dist/bundle/chunks/{chunk-2JNJJ6SZ.js → chunk-5KUCY54O.js} +3 -3
  16. package/dist/bundle/chunks/{chunk-4TDNOR36.js → chunk-625QJSFJ.js} +1 -1
  17. package/dist/bundle/chunks/chunk-73YX5XGR.js +2461 -0
  18. package/dist/bundle/chunks/chunk-7DIRHF4H.js +17 -0
  19. package/dist/bundle/chunks/{chunk-QJB5YI3I.js → chunk-7PAXKU7M.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-R2KD2HFT.js → chunk-7YB3HRRN.js} +83 -196
  21. package/dist/bundle/chunks/{chunk-DCXHRP6C.js → chunk-A2UZYK23.js} +13 -13
  22. package/dist/bundle/chunks/chunk-A5ZMBTTM.js +12 -0
  23. package/dist/bundle/chunks/{chunk-JKX5EGOT.js → chunk-AER66CNP.js} +13 -13
  24. package/dist/bundle/chunks/chunk-ARTF7ZMQ.js +5 -0
  25. package/dist/bundle/chunks/chunk-B3FT6L6S.js +131 -0
  26. package/dist/bundle/chunks/chunk-BIC5BSNX.js +13 -0
  27. package/dist/bundle/chunks/{chunk-JSHKS7VH.js → chunk-BNZZJ4LO.js} +1 -1
  28. package/dist/bundle/chunks/{chunk-4MKATHT2.js → chunk-CG43CMFH.js} +1 -1
  29. package/dist/bundle/chunks/{chunk-EFY2QPVP.js → chunk-CIAXW64K.js} +16 -16
  30. package/dist/bundle/chunks/{chunk-VFLVWPLZ.js → chunk-CKFLQGJN.js} +20 -16
  31. package/dist/bundle/chunks/chunk-D4UCXXDP.js +115 -0
  32. package/dist/bundle/chunks/{chunk-HQMUDHC3.js → chunk-D6ZWWDW5.js} +6 -5
  33. package/dist/bundle/chunks/{chunk-U4EAJPMO.js → chunk-EVDQRT3I.js} +252 -371
  34. package/dist/bundle/chunks/{chunk-FJIISX5W.js → chunk-F74XLJPC.js} +195 -192
  35. package/dist/bundle/chunks/chunk-FDRBTGFJ.js +4 -0
  36. package/dist/bundle/chunks/{chunk-E4VUW4RI.js → chunk-FLWO3H5J.js} +12 -12
  37. package/dist/bundle/chunks/{chunk-KLSRGGOH.js → chunk-G2PFPQX7.js} +2 -2
  38. package/dist/bundle/chunks/chunk-GMPJWLZS.js +57 -0
  39. package/dist/bundle/chunks/{chunk-M5TVWJ5T.js → chunk-H35P7ROY.js} +462 -441
  40. package/dist/bundle/chunks/chunk-HCHCYBNK.js +2 -0
  41. package/dist/bundle/chunks/{chunk-7WE77IE3.js → chunk-HRNYDRL7.js} +1 -1
  42. package/dist/bundle/chunks/chunk-HWFAAGYK.js +23 -0
  43. package/dist/bundle/chunks/{chunk-G2QMON4O.js → chunk-HWXQCJDP.js} +408 -392
  44. package/dist/bundle/chunks/{chunk-PVNXN2TC.js → chunk-II5C7G67.js} +1 -1
  45. package/dist/bundle/chunks/{chunk-F2H47FRF.js → chunk-IMRZP5SC.js} +182 -137
  46. package/dist/bundle/chunks/{chunk-H2B3WLIM.js → chunk-J5YFXMTM.js} +4 -4
  47. package/dist/bundle/chunks/chunk-J64VNQ6D.js +13 -0
  48. package/dist/bundle/chunks/{chunk-65FLSKDA.js → chunk-K5EFEIFP.js} +5 -4
  49. package/dist/bundle/chunks/{chunk-KI7CHPWC.js → chunk-KJ3QRSSY.js} +46 -43
  50. package/dist/bundle/chunks/{cli-6DJO467D.js → chunk-KSEO2LRK.js} +12 -10
  51. package/dist/bundle/chunks/{chunk-HHWVVNGG.js → chunk-MA2WCMSN.js} +2 -2
  52. package/dist/bundle/chunks/{chunk-L4J7SMJB.js → chunk-MAEKQSFU.js} +1 -1
  53. package/dist/bundle/chunks/chunk-MHQNLTZR.js +8 -0
  54. package/dist/bundle/chunks/chunk-MLOUZAVZ.js +122 -0
  55. package/dist/bundle/chunks/chunk-MQYR4Q6X.js +5 -0
  56. package/dist/bundle/chunks/chunk-MXF3KYLZ.js +4 -0
  57. package/dist/bundle/chunks/{chunk-GY663MNP.js → chunk-MZRTVX7F.js} +1 -1
  58. package/dist/bundle/chunks/chunk-MZYHSWHX.js +59 -0
  59. package/dist/bundle/chunks/{chunk-6HTHDVJC.js → chunk-NPVRWPGX.js} +1 -1
  60. package/dist/bundle/chunks/{chunk-BRSLXHED.js → chunk-O44A4E4K.js} +1 -1
  61. package/dist/bundle/chunks/{chunk-T2ZGMEMV.js → chunk-OADQOW67.js} +175 -260
  62. package/dist/bundle/chunks/chunk-OTVHRZ67.js +17 -0
  63. package/dist/bundle/chunks/{chunk-J4GII2EE.js → chunk-P7SLTLSZ.js} +51 -46
  64. package/dist/bundle/chunks/{chunk-7OZNMWAJ.js → chunk-PPGSQZZF.js} +1 -1
  65. package/dist/bundle/chunks/chunk-PYX6ZCC7.js +29 -0
  66. package/dist/bundle/chunks/chunk-PZ7NYBHJ.js +8 -0
  67. package/dist/bundle/chunks/{chunk-VCMXBP5S.js → chunk-QESIDBMW.js} +1 -7
  68. package/dist/bundle/chunks/chunk-QUWVILLB.js +3 -0
  69. package/dist/bundle/chunks/chunk-QZWUXGY7.js +99 -0
  70. package/dist/bundle/chunks/{chunk-MIAXMK5F.js → chunk-QZXLTW7V.js} +8 -7
  71. package/dist/bundle/chunks/chunk-RP6MWUAP.js +4 -0
  72. package/dist/bundle/chunks/chunk-S2US54IU.js +37 -0
  73. package/dist/bundle/chunks/{chunk-H7UPU2SH.js → chunk-SOE25WIS.js} +1218 -1239
  74. package/dist/bundle/chunks/{chunk-JSZBTGI6.js → chunk-SZZ5PNP6.js} +2 -2
  75. package/dist/bundle/chunks/chunk-T5WECB2D.js +7 -0
  76. package/dist/bundle/chunks/{chunk-2NVGOSBN.js → chunk-T7F2TEIS.js} +37 -13
  77. package/dist/bundle/chunks/{chunk-ZSWU5KKA.js → chunk-UOSJTMCL.js} +7 -3
  78. package/dist/bundle/chunks/{chunk-6P6MMQUH.js → chunk-UTRUALFN.js} +3 -3
  79. package/dist/bundle/chunks/{chunk-PWFM6AQQ.js → chunk-V2HTCZRF.js} +70 -67
  80. package/dist/bundle/chunks/{chunk-JX6YIPNK.js → chunk-WCKS2DPT.js} +1 -1
  81. package/dist/bundle/chunks/chunk-XGOJCV6Z.js +2 -0
  82. package/dist/bundle/chunks/chunk-XGSJX23G.js +1151 -0
  83. package/dist/bundle/chunks/{chunk-7WETECIB.js → chunk-Z7BWHPJ2.js} +1 -1
  84. package/dist/bundle/chunks/chunk-ZFFDBTG3.js +17 -0
  85. package/dist/bundle/chunks/cli-NJLV3XDZ.js +3 -0
  86. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-JEZVYITT.js → cloudflare-workers-ai-system-one-ZAZW4M4B.js} +1 -1
  87. package/dist/bundle/chunks/{compat-ELBUCH6U.js → compat-7UJJAO4E.js} +12 -12
  88. package/dist/bundle/chunks/{curator-server-QB4GITGS.js → curator-server-MW645JI3.js} +2 -2
  89. package/dist/bundle/chunks/{dist-NERIS6SW.js → dist-7PCCEUQF.js} +2 -2
  90. package/dist/bundle/chunks/{dist-QSYDYE3Y.js → dist-I53JI67E.js} +9 -9
  91. package/dist/bundle/chunks/{dist-35STTNYA.js → dist-NI2PTSLH.js} +1 -1
  92. package/dist/bundle/chunks/{dist-CBODG4CA.js → dist-VXQT3DQY.js} +6 -6
  93. package/dist/bundle/chunks/{dist-cjs-EROMDUKS.js → dist-cjs-4JQA6W3S.js} +31 -31
  94. package/dist/bundle/chunks/doctor-KJVAYG3F.js +83 -0
  95. package/dist/bundle/chunks/{easter-egg-3d-VZC5WOYV.js → easter-egg-3d-Z24JLXD4.js} +1 -1
  96. package/dist/bundle/chunks/entry-3EL6GOWK.js +2 -0
  97. package/dist/bundle/chunks/{entry-SRYLSS5P.js → entry-4IMREZBD.js} +80 -79
  98. package/dist/bundle/chunks/{execute-6MEJJF2T.js → execute-C4BZQRPQ.js} +23 -22
  99. package/dist/bundle/chunks/{extract-L373D6O7.js → extract-XVQCIS7D.js} +5 -5
  100. package/dist/bundle/chunks/{flow-implementer-3P3BHQ7E.js → flow-implementer-GE2ARQKR.js} +5 -5
  101. package/dist/bundle/chunks/github-copilot.js +57 -56
  102. package/dist/bundle/chunks/google-generative-ai-P2P45MYP.js +22 -0
  103. package/dist/bundle/chunks/google-vertex-SHY4IS5F.js +26 -0
  104. package/dist/bundle/chunks/{host-WOLZCWQQ.js → host-YESS2VAB.js} +1 -1
  105. package/dist/bundle/chunks/{index.bundle-HONF3PUD.js → index.bundle-TZT64KLH.js} +102 -89
  106. package/dist/bundle/chunks/{inprocess-3PDJKE5F.js → inprocess-MGMVI6HN.js} +6 -6
  107. package/dist/bundle/chunks/interactive-mode-HHWOE4FD.js +5 -0
  108. package/dist/bundle/chunks/{llama-cpp-classify-KYZT532X.js → llama-cpp-classify-RSRH4KV2.js} +5 -5
  109. package/dist/bundle/chunks/mistral-conversations-YTMJKHHI.js +42 -0
  110. package/dist/bundle/chunks/{node-N7TPBUJB.js → node-FF6QQQLH.js} +1 -1
  111. package/dist/bundle/chunks/openai-codex-responses-NUCJOJSZ.js +97 -0
  112. package/dist/bundle/chunks/openai-completions-E5NRJUHA.js +91 -0
  113. package/dist/bundle/chunks/{openai-decisions-JMSDGR7K.js → openai-decisions-342J5ZYG.js} +1 -1
  114. package/dist/bundle/chunks/openai-responses-BN5Z4HFI.js +26 -0
  115. package/dist/bundle/chunks/openrouter-images-7RNG3JVF.js +12 -0
  116. package/dist/bundle/chunks/{pdfjs-FE3L72A6.js → pdfjs-LSTLRXQW.js} +1415 -1416
  117. package/dist/bundle/chunks/pi-messages-2L7FV5OK.js +22 -0
  118. package/dist/bundle/chunks/questionnaire-session-XEVAK7JS.js +123 -0
  119. package/dist/bundle/chunks/runtime-2FSZRUG5.js +2 -0
  120. package/dist/bundle/chunks/session-picker-666KJIVM.js +4 -0
  121. package/dist/bundle/chunks/startup-ui-INEVSNGK.js +3 -0
  122. package/dist/bundle/chunks/{trace-command-VM7FBWPE.js → trace-command-BCVMZ5ZD.js} +4 -4
  123. package/dist/bundle/chunks/typesafe-system-one-UJUNSZG4.js +3 -0
  124. package/dist/bundle/chunks/{undici-WVNE45GY.js → undici-7IGAYA4S.js} +1 -1
  125. package/dist/bundle/chunks/virtual-modules-UXSSFNV5.js +29 -0
  126. package/dist/bundle/cli-runtime.js +5 -5
  127. package/dist/bundle/flow/package.json +3 -3
  128. package/dist/bundle/index.js +13 -13
  129. package/dist/bundle/orchestrate/package.json +1 -1
  130. package/dist/bundle/rpc-entry.js +5 -4
  131. package/dist/cli/agent-dir-arg.d.ts +12 -0
  132. package/dist/cli/agent-dir-arg.d.ts.map +1 -0
  133. package/dist/cli/agent-dir-arg.js +15 -0
  134. package/dist/cli/agent-dir-arg.js.map +1 -0
  135. package/dist/cli/args.d.ts +9 -0
  136. package/dist/cli/args.d.ts.map +1 -1
  137. package/dist/cli/args.js +19 -5
  138. package/dist/cli/args.js.map +1 -1
  139. package/dist/cli/auth-check.d.ts +1 -1
  140. package/dist/cli/auth-check.d.ts.map +1 -1
  141. package/dist/cli/auth-check.js +4 -2
  142. package/dist/cli/auth-check.js.map +1 -1
  143. package/dist/cli/doctor-config.d.ts +14 -0
  144. package/dist/cli/doctor-config.d.ts.map +1 -0
  145. package/dist/cli/doctor-config.js +92 -0
  146. package/dist/cli/doctor-config.js.map +1 -0
  147. package/dist/cli/doctor-system.d.ts +12 -0
  148. package/dist/cli/doctor-system.d.ts.map +1 -0
  149. package/dist/cli/doctor-system.js +109 -0
  150. package/dist/cli/doctor-system.js.map +1 -0
  151. package/dist/cli/doctor.d.ts +11 -0
  152. package/dist/cli/doctor.d.ts.map +1 -0
  153. package/dist/cli/doctor.js +323 -0
  154. package/dist/cli/doctor.js.map +1 -0
  155. package/dist/cli/doctor.lazy.d.ts +3 -0
  156. package/dist/cli/doctor.lazy.d.ts.map +1 -0
  157. package/dist/cli/doctor.lazy.js +3 -0
  158. package/dist/cli/doctor.lazy.js.map +1 -0
  159. package/dist/cli/list-models.d.ts.map +1 -1
  160. package/dist/cli/list-models.js +0 -4
  161. package/dist/cli/list-models.js.map +1 -1
  162. package/dist/cli/project-trust.d.ts.map +1 -1
  163. package/dist/cli/project-trust.js +6 -6
  164. package/dist/cli/project-trust.js.map +1 -1
  165. package/dist/cli/startup-ui.d.ts +3 -2
  166. package/dist/cli/startup-ui.d.ts.map +1 -1
  167. package/dist/cli/startup-ui.js +23 -10
  168. package/dist/cli/startup-ui.js.map +1 -1
  169. package/dist/config.d.ts +5 -1
  170. package/dist/config.d.ts.map +1 -1
  171. package/dist/config.js +13 -3
  172. package/dist/config.js.map +1 -1
  173. package/dist/coordination/adapter/delivery.d.ts +27 -0
  174. package/dist/coordination/adapter/delivery.d.ts.map +1 -1
  175. package/dist/coordination/adapter/delivery.js +164 -4
  176. package/dist/coordination/adapter/delivery.js.map +1 -1
  177. package/dist/coordination/adapter/index.d.ts.map +1 -1
  178. package/dist/coordination/adapter/index.js +31 -5
  179. package/dist/coordination/adapter/index.js.map +1 -1
  180. package/dist/coordination/adapter/presence.d.ts +5 -0
  181. package/dist/coordination/adapter/presence.d.ts.map +1 -1
  182. package/dist/coordination/adapter/presence.js +25 -3
  183. package/dist/coordination/adapter/presence.js.map +1 -1
  184. package/dist/coordination/adapter/question-routing.d.ts +7 -0
  185. package/dist/coordination/adapter/question-routing.d.ts.map +1 -0
  186. package/dist/coordination/adapter/question-routing.js +40 -0
  187. package/dist/coordination/adapter/question-routing.js.map +1 -0
  188. package/dist/coordination/adapter/receipts.d.ts +7 -0
  189. package/dist/coordination/adapter/receipts.d.ts.map +1 -1
  190. package/dist/coordination/adapter/receipts.js +25 -2
  191. package/dist/coordination/adapter/receipts.js.map +1 -1
  192. package/dist/coordination/adapter/tool.d.ts +19 -3
  193. package/dist/coordination/adapter/tool.d.ts.map +1 -1
  194. package/dist/coordination/adapter/tool.js +93 -19
  195. package/dist/coordination/adapter/tool.js.map +1 -1
  196. package/dist/coordination/broker/broker.d.ts +3 -3
  197. package/dist/coordination/broker/broker.d.ts.map +1 -1
  198. package/dist/coordination/broker/broker.js +15 -7
  199. package/dist/coordination/broker/broker.js.map +1 -1
  200. package/dist/coordination/client/client.d.ts +2 -2
  201. package/dist/coordination/client/client.d.ts.map +1 -1
  202. package/dist/coordination/client/client.js +4 -0
  203. package/dist/coordination/client/client.js.map +1 -1
  204. package/dist/coordination/transport/protocol.d.ts.map +1 -1
  205. package/dist/coordination/transport/protocol.js +23 -0
  206. package/dist/coordination/transport/protocol.js.map +1 -1
  207. package/dist/coordination/transport/types.d.ts +11 -1
  208. package/dist/coordination/transport/types.d.ts.map +1 -1
  209. package/dist/coordination/transport/types.js.map +1 -1
  210. package/dist/core/acceptance-command.d.ts +6 -3
  211. package/dist/core/acceptance-command.d.ts.map +1 -1
  212. package/dist/core/acceptance-command.js +43 -12
  213. package/dist/core/acceptance-command.js.map +1 -1
  214. package/dist/core/acceptance-ledger.d.ts +2 -0
  215. package/dist/core/acceptance-ledger.d.ts.map +1 -1
  216. package/dist/core/acceptance-ledger.js +14 -3
  217. package/dist/core/acceptance-ledger.js.map +1 -1
  218. package/dist/core/agent-session-runtime.d.ts +11 -4
  219. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  220. package/dist/core/agent-session-runtime.js +13 -4
  221. package/dist/core/agent-session-runtime.js.map +1 -1
  222. package/dist/core/agent-session-services.d.ts.map +1 -1
  223. package/dist/core/agent-session-services.js +6 -0
  224. package/dist/core/agent-session-services.js.map +1 -1
  225. package/dist/core/agent-session.d.ts +19 -1
  226. package/dist/core/agent-session.d.ts.map +1 -1
  227. package/dist/core/agent-session.js +131 -36
  228. package/dist/core/agent-session.js.map +1 -1
  229. package/dist/core/auth-storage.d.ts.map +1 -1
  230. package/dist/core/auth-storage.js +7 -1
  231. package/dist/core/auth-storage.js.map +1 -1
  232. package/dist/core/bash-executor.d.ts +3 -1
  233. package/dist/core/bash-executor.d.ts.map +1 -1
  234. package/dist/core/bash-executor.js +18 -8
  235. package/dist/core/bash-executor.js.map +1 -1
  236. package/dist/core/compaction/branch-summarization.d.ts +2 -2
  237. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  238. package/dist/core/compaction/branch-summarization.js +9 -15
  239. package/dist/core/compaction/branch-summarization.js.map +1 -1
  240. package/dist/core/compaction/compaction.d.ts.map +1 -1
  241. package/dist/core/compaction/compaction.js +3 -0
  242. package/dist/core/compaction/compaction.js.map +1 -1
  243. package/dist/core/export-html/index.d.ts.map +1 -1
  244. package/dist/core/export-html/index.js +12 -10
  245. package/dist/core/export-html/index.js.map +1 -1
  246. package/dist/core/export-html/template.js +23 -1
  247. package/dist/core/extensions/runner.d.ts.map +1 -1
  248. package/dist/core/extensions/runner.js +13 -2
  249. package/dist/core/extensions/runner.js.map +1 -1
  250. package/dist/core/extensions/types.d.ts +9 -1
  251. package/dist/core/extensions/types.d.ts.map +1 -1
  252. package/dist/core/extensions/types.js.map +1 -1
  253. package/dist/core/footer-data-provider.d.ts.map +1 -1
  254. package/dist/core/footer-data-provider.js +2 -4
  255. package/dist/core/footer-data-provider.js.map +1 -1
  256. package/dist/core/http-dispatcher.d.ts +5 -2
  257. package/dist/core/http-dispatcher.d.ts.map +1 -1
  258. package/dist/core/http-dispatcher.js +6 -3
  259. package/dist/core/http-dispatcher.js.map +1 -1
  260. package/dist/core/keybindings.d.ts +20 -0
  261. package/dist/core/keybindings.d.ts.map +1 -1
  262. package/dist/core/keybindings.js +4 -1
  263. package/dist/core/keybindings.js.map +1 -1
  264. package/dist/core/mcp-servers.d.ts +29 -0
  265. package/dist/core/mcp-servers.d.ts.map +1 -1
  266. package/dist/core/mcp-servers.js +63 -17
  267. package/dist/core/mcp-servers.js.map +1 -1
  268. package/dist/core/messages.d.ts +4 -0
  269. package/dist/core/messages.d.ts.map +1 -1
  270. package/dist/core/messages.js +10 -2
  271. package/dist/core/messages.js.map +1 -1
  272. package/dist/core/model-config.d.ts +36 -0
  273. package/dist/core/model-config.d.ts.map +1 -1
  274. package/dist/core/model-resolver.js +1 -1
  275. package/dist/core/model-resolver.js.map +1 -1
  276. package/dist/core/model-runtime.d.ts.map +1 -1
  277. package/dist/core/model-runtime.js +20 -10
  278. package/dist/core/model-runtime.js.map +1 -1
  279. package/dist/core/nested-tool-calls.d.ts +6 -5
  280. package/dist/core/nested-tool-calls.d.ts.map +1 -1
  281. package/dist/core/nested-tool-calls.js +1 -3
  282. package/dist/core/nested-tool-calls.js.map +1 -1
  283. package/dist/core/oauth-account-pool.d.ts +14 -0
  284. package/dist/core/oauth-account-pool.d.ts.map +1 -1
  285. package/dist/core/oauth-account-pool.js +166 -14
  286. package/dist/core/oauth-account-pool.js.map +1 -1
  287. package/dist/core/os-secret-store.js +1 -1
  288. package/dist/core/os-secret-store.js.map +1 -1
  289. package/dist/core/package-manager.d.ts +3 -1
  290. package/dist/core/package-manager.d.ts.map +1 -1
  291. package/dist/core/package-manager.js +25 -4
  292. package/dist/core/package-manager.js.map +1 -1
  293. package/dist/core/pi-ai-schemas.d.ts +4 -0
  294. package/dist/core/pi-ai-schemas.d.ts.map +1 -1
  295. package/dist/core/project-trust.d.ts.map +1 -1
  296. package/dist/core/project-trust.js +1 -1
  297. package/dist/core/project-trust.js.map +1 -1
  298. package/dist/core/provider-composer.d.ts +1 -0
  299. package/dist/core/provider-composer.d.ts.map +1 -1
  300. package/dist/core/provider-composer.js +1 -0
  301. package/dist/core/provider-composer.js.map +1 -1
  302. package/dist/core/resolve-config-value.d.ts +4 -0
  303. package/dist/core/resolve-config-value.d.ts.map +1 -1
  304. package/dist/core/resolve-config-value.js +14 -3
  305. package/dist/core/resolve-config-value.js.map +1 -1
  306. package/dist/core/resource-loader.d.ts.map +1 -1
  307. package/dist/core/resource-loader.js +40 -2
  308. package/dist/core/resource-loader.js.map +1 -1
  309. package/dist/core/run-outcome.d.ts +1 -1
  310. package/dist/core/run-outcome.d.ts.map +1 -1
  311. package/dist/core/run-outcome.js +2 -2
  312. package/dist/core/run-outcome.js.map +1 -1
  313. package/dist/core/run-preflight.d.ts.map +1 -1
  314. package/dist/core/run-preflight.js +15 -8
  315. package/dist/core/run-preflight.js.map +1 -1
  316. package/dist/core/runtime-credentials.d.ts.map +1 -1
  317. package/dist/core/runtime-credentials.js +11 -7
  318. package/dist/core/runtime-credentials.js.map +1 -1
  319. package/dist/core/sdk.d.ts.map +1 -1
  320. package/dist/core/sdk.js +8 -4
  321. package/dist/core/sdk.js.map +1 -1
  322. package/dist/core/session-manager.d.ts +22 -1
  323. package/dist/core/session-manager.d.ts.map +1 -1
  324. package/dist/core/session-manager.js +227 -37
  325. package/dist/core/session-manager.js.map +1 -1
  326. package/dist/core/settings-defaults.d.ts +10 -1
  327. package/dist/core/settings-defaults.d.ts.map +1 -1
  328. package/dist/core/settings-defaults.js +7 -1
  329. package/dist/core/settings-defaults.js.map +1 -1
  330. package/dist/core/settings-manager.d.ts +14 -4
  331. package/dist/core/settings-manager.d.ts.map +1 -1
  332. package/dist/core/settings-manager.js +48 -15
  333. package/dist/core/settings-manager.js.map +1 -1
  334. package/dist/core/settings-schema.d.ts +20 -2
  335. package/dist/core/settings-schema.d.ts.map +1 -1
  336. package/dist/core/settings-schema.js +27 -4
  337. package/dist/core/settings-schema.js.map +1 -1
  338. package/dist/core/slash-commands.d.ts.map +1 -1
  339. package/dist/core/slash-commands.js +2 -0
  340. package/dist/core/slash-commands.js.map +1 -1
  341. package/dist/core/tools/bash-jobs.js +2 -2
  342. package/dist/core/tools/bash-jobs.js.map +1 -1
  343. package/dist/core/tools/bash.d.ts +3 -0
  344. package/dist/core/tools/bash.d.ts.map +1 -1
  345. package/dist/core/tools/bash.js +78 -46
  346. package/dist/core/tools/bash.js.map +1 -1
  347. package/dist/core/tools/edit-diff.d.ts +7 -1
  348. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  349. package/dist/core/tools/edit-diff.js +139 -75
  350. package/dist/core/tools/edit-diff.js.map +1 -1
  351. package/dist/core/tools/edit.d.ts.map +1 -1
  352. package/dist/core/tools/edit.js +4 -1
  353. package/dist/core/tools/edit.js.map +1 -1
  354. package/dist/core/tools/output-accumulator.d.ts +21 -6
  355. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  356. package/dist/core/tools/output-accumulator.js +90 -76
  357. package/dist/core/tools/output-accumulator.js.map +1 -1
  358. package/dist/core/tools/render-utils.d.ts +7 -2
  359. package/dist/core/tools/render-utils.d.ts.map +1 -1
  360. package/dist/core/tools/render-utils.js +14 -1
  361. package/dist/core/tools/render-utils.js.map +1 -1
  362. package/dist/core/tools/renderers/bash.d.ts.map +1 -1
  363. package/dist/core/tools/renderers/bash.js +9 -3
  364. package/dist/core/tools/renderers/bash.js.map +1 -1
  365. package/dist/core/tools/truncate.d.ts +1 -1
  366. package/dist/core/tools/truncate.d.ts.map +1 -1
  367. package/dist/core/tools/truncate.js +16 -7
  368. package/dist/core/tools/truncate.js.map +1 -1
  369. package/dist/core/tools/write.d.ts.map +1 -1
  370. package/dist/core/tools/write.js +2 -0
  371. package/dist/core/tools/write.js.map +1 -1
  372. package/dist/core/trust-manager.d.ts +2 -0
  373. package/dist/core/trust-manager.d.ts.map +1 -1
  374. package/dist/core/trust-manager.js +5 -4
  375. package/dist/core/trust-manager.js.map +1 -1
  376. package/dist/core/usage-totals.d.ts.map +1 -1
  377. package/dist/core/usage-totals.js +3 -0
  378. package/dist/core/usage-totals.js.map +1 -1
  379. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  380. package/dist/extensions/codemode/execute.js +64 -20
  381. package/dist/extensions/codemode/execute.js.map +1 -1
  382. package/dist/extensions/codemode/renderer.d.ts.map +1 -1
  383. package/dist/extensions/codemode/renderer.js +8 -3
  384. package/dist/extensions/codemode/renderer.js.map +1 -1
  385. package/dist/extensions/codemode/tool.d.ts +5 -0
  386. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  387. package/dist/extensions/codemode/tool.js.map +1 -1
  388. package/dist/extensions/llama/client.d.ts.map +1 -1
  389. package/dist/extensions/llama/client.js +3 -13
  390. package/dist/extensions/llama/client.js.map +1 -1
  391. package/dist/extensions/llama/ui.d.ts.map +1 -1
  392. package/dist/extensions/llama/ui.js +2 -1
  393. package/dist/extensions/llama/ui.js.map +1 -1
  394. package/dist/extensions/mcp/cli.d.ts +7 -0
  395. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  396. package/dist/extensions/mcp/cli.js +35 -8
  397. package/dist/extensions/mcp/cli.js.map +1 -1
  398. package/dist/extensions/mcp/config.d.ts +33 -0
  399. package/dist/extensions/mcp/config.d.ts.map +1 -1
  400. package/dist/extensions/mcp/config.js +11 -2
  401. package/dist/extensions/mcp/config.js.map +1 -1
  402. package/dist/extensions/mcp/index.d.ts +8 -0
  403. package/dist/extensions/mcp/index.d.ts.map +1 -1
  404. package/dist/extensions/mcp/index.js +16 -0
  405. package/dist/extensions/mcp/index.js.map +1 -1
  406. package/dist/extensions/mcp/resources.d.ts +1 -1
  407. package/dist/extensions/mcp/resources.d.ts.map +1 -1
  408. package/dist/extensions/mcp/resources.js +4 -3
  409. package/dist/extensions/mcp/resources.js.map +1 -1
  410. package/dist/extensions/mcp/runtime.d.ts +1 -1
  411. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  412. package/dist/extensions/mcp/runtime.js +15 -14
  413. package/dist/extensions/mcp/runtime.js.map +1 -1
  414. package/dist/extensions/mcp/tools.d.ts +1 -24
  415. package/dist/extensions/mcp/tools.d.ts.map +1 -1
  416. package/dist/extensions/mcp/tools.js +10 -163
  417. package/dist/extensions/mcp/tools.js.map +1 -1
  418. package/dist/humain/ask-user-question/index.d.ts +4 -0
  419. package/dist/humain/ask-user-question/index.d.ts.map +1 -0
  420. package/dist/humain/ask-user-question/index.js +18 -0
  421. package/dist/humain/ask-user-question/index.js.map +1 -0
  422. package/dist/humain/ask-user-question/vendor/ask/answer-channel.d.ts +38 -0
  423. package/dist/humain/ask-user-question/vendor/ask/answer-channel.d.ts.map +1 -0
  424. package/dist/humain/ask-user-question/vendor/ask/answer-channel.js +97 -0
  425. package/dist/humain/ask-user-question/vendor/ask/answer-channel.js.map +1 -0
  426. package/dist/humain/ask-user-question/vendor/ask/ask-user-question.d.ts +41 -0
  427. package/dist/humain/ask-user-question/vendor/ask/ask-user-question.d.ts.map +1 -0
  428. package/dist/humain/ask-user-question/vendor/ask/ask-user-question.js +441 -0
  429. package/dist/humain/ask-user-question/vendor/ask/ask-user-question.js.map +1 -0
  430. package/dist/humain/ask-user-question/vendor/ask/config.d.ts +39 -0
  431. package/dist/humain/ask-user-question/vendor/ask/config.d.ts.map +1 -0
  432. package/dist/humain/ask-user-question/vendor/ask/config.js +95 -0
  433. package/dist/humain/ask-user-question/vendor/ask/config.js.map +1 -0
  434. package/dist/humain/ask-user-question/vendor/ask/events.d.ts +132 -0
  435. package/dist/humain/ask-user-question/vendor/ask/events.d.ts.map +1 -0
  436. package/dist/humain/ask-user-question/vendor/ask/events.js +50 -0
  437. package/dist/humain/ask-user-question/vendor/ask/events.js.map +1 -0
  438. package/dist/humain/ask-user-question/vendor/ask/index.d.ts +5 -0
  439. package/dist/humain/ask-user-question/vendor/ask/index.d.ts.map +1 -0
  440. package/dist/humain/ask-user-question/vendor/ask/index.js +15 -0
  441. package/dist/humain/ask-user-question/vendor/ask/index.js.map +1 -0
  442. package/dist/humain/ask-user-question/vendor/ask/presentation.d.ts +81 -0
  443. package/dist/humain/ask-user-question/vendor/ask/presentation.d.ts.map +1 -0
  444. package/dist/humain/ask-user-question/vendor/ask/presentation.js +105 -0
  445. package/dist/humain/ask-user-question/vendor/ask/presentation.js.map +1 -0
  446. package/dist/humain/ask-user-question/vendor/ask/reconcile.d.ts +28 -0
  447. package/dist/humain/ask-user-question/vendor/ask/reconcile.d.ts.map +1 -0
  448. package/dist/humain/ask-user-question/vendor/ask/reconcile.js +45 -0
  449. package/dist/humain/ask-user-question/vendor/ask/reconcile.js.map +1 -0
  450. package/dist/humain/ask-user-question/vendor/ask/rpc-fallback.d.ts +41 -0
  451. package/dist/humain/ask-user-question/vendor/ask/rpc-fallback.d.ts.map +1 -0
  452. package/dist/humain/ask-user-question/vendor/ask/rpc-fallback.js +166 -0
  453. package/dist/humain/ask-user-question/vendor/ask/rpc-fallback.js.map +1 -0
  454. package/dist/humain/ask-user-question/vendor/ask/state/build-questionnaire.d.ts +46 -0
  455. package/dist/humain/ask-user-question/vendor/ask/state/build-questionnaire.d.ts.map +1 -0
  456. package/dist/humain/ask-user-question/vendor/ask/state/build-questionnaire.js +247 -0
  457. package/dist/humain/ask-user-question/vendor/ask/state/build-questionnaire.js.map +1 -0
  458. package/dist/humain/ask-user-question/vendor/ask/state/external-editor.d.ts +11 -0
  459. package/dist/humain/ask-user-question/vendor/ask/state/external-editor.d.ts.map +1 -0
  460. package/dist/humain/ask-user-question/vendor/ask/state/external-editor.js +56 -0
  461. package/dist/humain/ask-user-question/vendor/ask/state/external-editor.js.map +1 -0
  462. package/dist/humain/ask-user-question/vendor/ask/state/i18n-bridge.d.ts +6 -0
  463. package/dist/humain/ask-user-question/vendor/ask/state/i18n-bridge.d.ts.map +1 -0
  464. package/dist/humain/ask-user-question/vendor/ask/state/i18n-bridge.js +10 -0
  465. package/dist/humain/ask-user-question/vendor/ask/state/i18n-bridge.js.map +1 -0
  466. package/dist/humain/ask-user-question/vendor/ask/state/key-router.d.ts +57 -0
  467. package/dist/humain/ask-user-question/vendor/ask/state/key-router.d.ts.map +1 -0
  468. package/dist/humain/ask-user-question/vendor/ask/state/key-router.js +357 -0
  469. package/dist/humain/ask-user-question/vendor/ask/state/key-router.js.map +1 -0
  470. package/dist/humain/ask-user-question/vendor/ask/state/questionnaire-session.d.ts +112 -0
  471. package/dist/humain/ask-user-question/vendor/ask/state/questionnaire-session.d.ts.map +1 -0
  472. package/dist/humain/ask-user-question/vendor/ask/state/questionnaire-session.js +240 -0
  473. package/dist/humain/ask-user-question/vendor/ask/state/questionnaire-session.js.map +1 -0
  474. package/dist/humain/ask-user-question/vendor/ask/state/row-intent.d.ts +87 -0
  475. package/dist/humain/ask-user-question/vendor/ask/state/row-intent.d.ts.map +1 -0
  476. package/dist/humain/ask-user-question/vendor/ask/state/row-intent.js +79 -0
  477. package/dist/humain/ask-user-question/vendor/ask/state/row-intent.js.map +1 -0
  478. package/dist/humain/ask-user-question/vendor/ask/state/selectors/contract.d.ts +22 -0
  479. package/dist/humain/ask-user-question/vendor/ask/state/selectors/contract.d.ts.map +1 -0
  480. package/dist/humain/ask-user-question/vendor/ask/state/selectors/contract.js +2 -0
  481. package/dist/humain/ask-user-question/vendor/ask/state/selectors/contract.js.map +1 -0
  482. package/dist/humain/ask-user-question/vendor/ask/state/selectors/derivations.d.ts +27 -0
  483. package/dist/humain/ask-user-question/vendor/ask/state/selectors/derivations.d.ts.map +1 -0
  484. package/dist/humain/ask-user-question/vendor/ask/state/selectors/derivations.js +48 -0
  485. package/dist/humain/ask-user-question/vendor/ask/state/selectors/derivations.js.map +1 -0
  486. package/dist/humain/ask-user-question/vendor/ask/state/selectors/focus.d.ts +13 -0
  487. package/dist/humain/ask-user-question/vendor/ask/state/selectors/focus.d.ts.map +1 -0
  488. package/dist/humain/ask-user-question/vendor/ask/state/selectors/focus.js +15 -0
  489. package/dist/humain/ask-user-question/vendor/ask/state/selectors/focus.js.map +1 -0
  490. package/dist/humain/ask-user-question/vendor/ask/state/selectors/projections.d.ts +14 -0
  491. package/dist/humain/ask-user-question/vendor/ask/state/selectors/projections.d.ts.map +1 -0
  492. package/dist/humain/ask-user-question/vendor/ask/state/selectors/projections.js +96 -0
  493. package/dist/humain/ask-user-question/vendor/ask/state/selectors/projections.js.map +1 -0
  494. package/dist/humain/ask-user-question/vendor/ask/state/state-reducer.d.ts +58 -0
  495. package/dist/humain/ask-user-question/vendor/ask/state/state-reducer.d.ts.map +1 -0
  496. package/dist/humain/ask-user-question/vendor/ask/state/state-reducer.js +310 -0
  497. package/dist/humain/ask-user-question/vendor/ask/state/state-reducer.js.map +1 -0
  498. package/dist/humain/ask-user-question/vendor/ask/state/state.d.ts +68 -0
  499. package/dist/humain/ask-user-question/vendor/ask/state/state.d.ts.map +1 -0
  500. package/dist/humain/ask-user-question/vendor/ask/state/state.js +2 -0
  501. package/dist/humain/ask-user-question/vendor/ask/state/state.js.map +1 -0
  502. package/dist/humain/ask-user-question/vendor/ask/tool/external-answer.d.ts +24 -0
  503. package/dist/humain/ask-user-question/vendor/ask/tool/external-answer.d.ts.map +1 -0
  504. package/dist/humain/ask-user-question/vendor/ask/tool/external-answer.js +114 -0
  505. package/dist/humain/ask-user-question/vendor/ask/tool/external-answer.js.map +1 -0
  506. package/dist/humain/ask-user-question/vendor/ask/tool/format-answer.d.ts +18 -0
  507. package/dist/humain/ask-user-question/vendor/ask/tool/format-answer.d.ts.map +1 -0
  508. package/dist/humain/ask-user-question/vendor/ask/tool/format-answer.js +29 -0
  509. package/dist/humain/ask-user-question/vendor/ask/tool/format-answer.js.map +1 -0
  510. package/dist/humain/ask-user-question/vendor/ask/tool/normalize-params.d.ts +41 -0
  511. package/dist/humain/ask-user-question/vendor/ask/tool/normalize-params.d.ts.map +1 -0
  512. package/dist/humain/ask-user-question/vendor/ask/tool/normalize-params.js +99 -0
  513. package/dist/humain/ask-user-question/vendor/ask/tool/normalize-params.js.map +1 -0
  514. package/dist/humain/ask-user-question/vendor/ask/tool/response-envelope.d.ts +37 -0
  515. package/dist/humain/ask-user-question/vendor/ask/tool/response-envelope.d.ts.map +1 -0
  516. package/dist/humain/ask-user-question/vendor/ask/tool/response-envelope.js +70 -0
  517. package/dist/humain/ask-user-question/vendor/ask/tool/response-envelope.js.map +1 -0
  518. package/dist/humain/ask-user-question/vendor/ask/tool/types.d.ts +129 -0
  519. package/dist/humain/ask-user-question/vendor/ask/tool/types.d.ts.map +1 -0
  520. package/dist/humain/ask-user-question/vendor/ask/tool/types.js +76 -0
  521. package/dist/humain/ask-user-question/vendor/ask/tool/types.js.map +1 -0
  522. package/dist/humain/ask-user-question/vendor/ask/tool/validate-questionnaire.d.ts +21 -0
  523. package/dist/humain/ask-user-question/vendor/ask/tool/validate-questionnaire.d.ts.map +1 -0
  524. package/dist/humain/ask-user-question/vendor/ask/tool/validate-questionnaire.js +49 -0
  525. package/dist/humain/ask-user-question/vendor/ask/tool/validate-questionnaire.js.map +1 -0
  526. package/dist/humain/ask-user-question/vendor/ask/view/component-binding.d.ts +23 -0
  527. package/dist/humain/ask-user-question/vendor/ask/view/component-binding.d.ts.map +1 -0
  528. package/dist/humain/ask-user-question/vendor/ask/view/component-binding.js +16 -0
  529. package/dist/humain/ask-user-question/vendor/ask/view/component-binding.js.map +1 -0
  530. package/dist/humain/ask-user-question/vendor/ask/view/components/inline-input.d.ts +21 -0
  531. package/dist/humain/ask-user-question/vendor/ask/view/components/inline-input.d.ts.map +1 -0
  532. package/dist/humain/ask-user-question/vendor/ask/view/components/inline-input.js +49 -0
  533. package/dist/humain/ask-user-question/vendor/ask/view/components/inline-input.js.map +1 -0
  534. package/dist/humain/ask-user-question/vendor/ask/view/components/multi-select-view.d.ts +43 -0
  535. package/dist/humain/ask-user-question/vendor/ask/view/components/multi-select-view.d.ts.map +1 -0
  536. package/dist/humain/ask-user-question/vendor/ask/view/components/multi-select-view.js +130 -0
  537. package/dist/humain/ask-user-question/vendor/ask/view/components/multi-select-view.js.map +1 -0
  538. package/dist/humain/ask-user-question/vendor/ask/view/components/option-list-view.d.ts +45 -0
  539. package/dist/humain/ask-user-question/vendor/ask/view/components/option-list-view.d.ts.map +1 -0
  540. package/dist/humain/ask-user-question/vendor/ask/view/components/option-list-view.js +39 -0
  541. package/dist/humain/ask-user-question/vendor/ask/view/components/option-list-view.js.map +1 -0
  542. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/markdown-content-cache.d.ts +36 -0
  543. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/markdown-content-cache.d.ts.map +1 -0
  544. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/markdown-content-cache.js +72 -0
  545. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/markdown-content-cache.js.map +1 -0
  546. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-block-renderer.d.ts +61 -0
  547. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-block-renderer.d.ts.map +1 -0
  548. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-block-renderer.js +108 -0
  549. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-block-renderer.js.map +1 -0
  550. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-box-renderer.d.ts +39 -0
  551. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-box-renderer.d.ts.map +1 -0
  552. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-box-renderer.js +76 -0
  553. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-box-renderer.js.map +1 -0
  554. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-layout-decider.d.ts +123 -0
  555. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-layout-decider.d.ts.map +1 -0
  556. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-layout-decider.js +180 -0
  557. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-layout-decider.js.map +1 -0
  558. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-pane.d.ts +108 -0
  559. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-pane.d.ts.map +1 -0
  560. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-pane.js +235 -0
  561. package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-pane.js.map +1 -0
  562. package/dist/humain/ask-user-question/vendor/ask/view/components/submit-picker.d.ts +37 -0
  563. package/dist/humain/ask-user-question/vendor/ask/view/components/submit-picker.d.ts.map +1 -0
  564. package/dist/humain/ask-user-question/vendor/ask/view/components/submit-picker.js +47 -0
  565. package/dist/humain/ask-user-question/vendor/ask/view/components/submit-picker.js.map +1 -0
  566. package/dist/humain/ask-user-question/vendor/ask/view/components/tab-bar.d.ts +31 -0
  567. package/dist/humain/ask-user-question/vendor/ask/view/components/tab-bar.d.ts.map +1 -0
  568. package/dist/humain/ask-user-question/vendor/ask/view/components/tab-bar.js +35 -0
  569. package/dist/humain/ask-user-question/vendor/ask/view/components/tab-bar.js.map +1 -0
  570. package/dist/humain/ask-user-question/vendor/ask/view/components/wrapping-select.d.ts +124 -0
  571. package/dist/humain/ask-user-question/vendor/ask/view/components/wrapping-select.d.ts.map +1 -0
  572. package/dist/humain/ask-user-question/vendor/ask/view/components/wrapping-select.js +205 -0
  573. package/dist/humain/ask-user-question/vendor/ask/view/components/wrapping-select.js.map +1 -0
  574. package/dist/humain/ask-user-question/vendor/ask/view/dialog-builder.d.ts +83 -0
  575. package/dist/humain/ask-user-question/vendor/ask/view/dialog-builder.d.ts.map +1 -0
  576. package/dist/humain/ask-user-question/vendor/ask/view/dialog-builder.js +186 -0
  577. package/dist/humain/ask-user-question/vendor/ask/view/dialog-builder.js.map +1 -0
  578. package/dist/humain/ask-user-question/vendor/ask/view/dialog-copy.d.ts +47 -0
  579. package/dist/humain/ask-user-question/vendor/ask/view/dialog-copy.d.ts.map +1 -0
  580. package/dist/humain/ask-user-question/vendor/ask/view/dialog-copy.js +48 -0
  581. package/dist/humain/ask-user-question/vendor/ask/view/dialog-copy.js.map +1 -0
  582. package/dist/humain/ask-user-question/vendor/ask/view/props-adapter.d.ts +58 -0
  583. package/dist/humain/ask-user-question/vendor/ask/view/props-adapter.d.ts.map +1 -0
  584. package/dist/humain/ask-user-question/vendor/ask/view/props-adapter.js +84 -0
  585. package/dist/humain/ask-user-question/vendor/ask/view/props-adapter.js.map +1 -0
  586. package/dist/humain/ask-user-question/vendor/ask/view/scroll-window.d.ts +20 -0
  587. package/dist/humain/ask-user-question/vendor/ask/view/scroll-window.d.ts.map +1 -0
  588. package/dist/humain/ask-user-question/vendor/ask/view/scroll-window.js +55 -0
  589. package/dist/humain/ask-user-question/vendor/ask/view/scroll-window.js.map +1 -0
  590. package/dist/humain/ask-user-question/vendor/ask/view/stateful-view.d.ts +23 -0
  591. package/dist/humain/ask-user-question/vendor/ask/view/stateful-view.d.ts.map +1 -0
  592. package/dist/humain/ask-user-question/vendor/ask/view/stateful-view.js +2 -0
  593. package/dist/humain/ask-user-question/vendor/ask/view/stateful-view.js.map +1 -0
  594. package/dist/humain/ask-user-question/vendor/ask/view/tab-components.d.ts +15 -0
  595. package/dist/humain/ask-user-question/vendor/ask/view/tab-components.d.ts.map +1 -0
  596. package/dist/humain/ask-user-question/vendor/ask/view/tab-components.js +2 -0
  597. package/dist/humain/ask-user-question/vendor/ask/view/tab-components.js.map +1 -0
  598. package/dist/humain/ask-user-question/vendor/ask/view/tab-content-strategy.d.ts +98 -0
  599. package/dist/humain/ask-user-question/vendor/ask/view/tab-content-strategy.d.ts.map +1 -0
  600. package/dist/humain/ask-user-question/vendor/ask/view/tab-content-strategy.js +248 -0
  601. package/dist/humain/ask-user-question/vendor/ask/view/tab-content-strategy.js.map +1 -0
  602. package/dist/humain/ask-user-question/vendor/ask/view/transcript.d.ts +23 -0
  603. package/dist/humain/ask-user-question/vendor/ask/view/transcript.d.ts.map +1 -0
  604. package/dist/humain/ask-user-question/vendor/ask/view/transcript.js +131 -0
  605. package/dist/humain/ask-user-question/vendor/ask/view/transcript.js.map +1 -0
  606. package/dist/humain/ask-user-question/vendor/config/config.d.ts +132 -0
  607. package/dist/humain/ask-user-question/vendor/config/config.d.ts.map +1 -0
  608. package/dist/humain/ask-user-question/vendor/config/config.js +286 -0
  609. package/dist/humain/ask-user-question/vendor/config/config.js.map +1 -0
  610. package/dist/humain/ask-user-question/vendor/config/index.d.ts +2 -0
  611. package/dist/humain/ask-user-question/vendor/config/index.d.ts.map +1 -0
  612. package/dist/humain/ask-user-question/vendor/config/index.js +2 -0
  613. package/dist/humain/ask-user-question/vendor/config/index.js.map +1 -0
  614. package/dist/humain/ask-user-question/vendor/i18n/i18n.d.ts +64 -0
  615. package/dist/humain/ask-user-question/vendor/i18n/i18n.d.ts.map +1 -0
  616. package/dist/humain/ask-user-question/vendor/i18n/i18n.js +185 -0
  617. package/dist/humain/ask-user-question/vendor/i18n/i18n.js.map +1 -0
  618. package/dist/humain/ask-user-question/vendor/i18n/loader.d.ts +44 -0
  619. package/dist/humain/ask-user-question/vendor/i18n/loader.d.ts.map +1 -0
  620. package/dist/humain/ask-user-question/vendor/i18n/loader.js +55 -0
  621. package/dist/humain/ask-user-question/vendor/i18n/loader.js.map +1 -0
  622. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +26 -16
  623. package/dist/humain/brand-logo.d.ts +2 -0
  624. package/dist/humain/brand-logo.d.ts.map +1 -1
  625. package/dist/humain/brand-logo.js +4 -0
  626. package/dist/humain/brand-logo.js.map +1 -1
  627. package/dist/humain/bundled-extension-names.d.ts +1 -0
  628. package/dist/humain/bundled-extension-names.d.ts.map +1 -1
  629. package/dist/humain/bundled-extension-names.js +1 -0
  630. package/dist/humain/bundled-extension-names.js.map +1 -1
  631. package/dist/humain/checklist/footer-progress.d.ts +7 -0
  632. package/dist/humain/checklist/footer-progress.d.ts.map +1 -0
  633. package/dist/humain/checklist/footer-progress.js +15 -0
  634. package/dist/humain/checklist/footer-progress.js.map +1 -0
  635. package/dist/humain/checklist/glyphs.d.ts +7 -0
  636. package/dist/humain/checklist/glyphs.d.ts.map +1 -0
  637. package/dist/humain/checklist/glyphs.js +8 -0
  638. package/dist/humain/checklist/glyphs.js.map +1 -0
  639. package/dist/humain/checklist/index.d.ts +6 -0
  640. package/dist/humain/checklist/index.d.ts.map +1 -0
  641. package/dist/humain/checklist/index.js +37 -0
  642. package/dist/humain/checklist/index.js.map +1 -0
  643. package/dist/humain/checklist/progress.d.ts +37 -0
  644. package/dist/humain/checklist/progress.d.ts.map +1 -0
  645. package/dist/humain/checklist/progress.js +234 -0
  646. package/dist/humain/checklist/progress.js.map +1 -0
  647. package/dist/humain/checklist/projector.d.ts +53 -0
  648. package/dist/humain/checklist/projector.d.ts.map +1 -0
  649. package/dist/humain/checklist/projector.js +198 -0
  650. package/dist/humain/checklist/projector.js.map +1 -0
  651. package/dist/humain/checklist/sidebar.d.ts +18 -0
  652. package/dist/humain/checklist/sidebar.d.ts.map +1 -0
  653. package/dist/humain/checklist/sidebar.js +38 -0
  654. package/dist/humain/checklist/sidebar.js.map +1 -0
  655. package/dist/humain/checklist/status-segment.d.ts +19 -0
  656. package/dist/humain/checklist/status-segment.d.ts.map +1 -0
  657. package/dist/humain/checklist/status-segment.js +59 -0
  658. package/dist/humain/checklist/status-segment.js.map +1 -0
  659. package/dist/humain/checklist/vendor/add-task-dialog.d.ts +54 -0
  660. package/dist/humain/checklist/vendor/add-task-dialog.d.ts.map +1 -0
  661. package/dist/humain/checklist/vendor/add-task-dialog.js +238 -0
  662. package/dist/humain/checklist/vendor/add-task-dialog.js.map +1 -0
  663. package/dist/humain/checklist/vendor/commands.d.ts +38 -0
  664. package/dist/humain/checklist/vendor/commands.d.ts.map +1 -0
  665. package/dist/humain/checklist/vendor/commands.js +193 -0
  666. package/dist/humain/checklist/vendor/commands.js.map +1 -0
  667. package/dist/humain/checklist/vendor/index.d.ts +3 -0
  668. package/dist/humain/checklist/vendor/index.d.ts.map +1 -0
  669. package/dist/humain/checklist/vendor/index.js +276 -0
  670. package/dist/humain/checklist/vendor/index.js.map +1 -0
  671. package/dist/humain/checklist/vendor/render.d.ts +97 -0
  672. package/dist/humain/checklist/vendor/render.d.ts.map +1 -0
  673. package/dist/humain/checklist/vendor/render.js +354 -0
  674. package/dist/humain/checklist/vendor/render.js.map +1 -0
  675. package/dist/humain/checklist/vendor/settings.d.ts +11 -0
  676. package/dist/humain/checklist/vendor/settings.d.ts.map +1 -0
  677. package/dist/humain/checklist/vendor/settings.js +8 -0
  678. package/dist/humain/checklist/vendor/settings.js.map +1 -0
  679. package/dist/humain/checklist/vendor/store.d.ts +120 -0
  680. package/dist/humain/checklist/vendor/store.d.ts.map +1 -0
  681. package/dist/humain/checklist/vendor/store.js +990 -0
  682. package/dist/humain/checklist/vendor/store.js.map +1 -0
  683. package/dist/humain/checklist/vendor/tools.d.ts +21 -0
  684. package/dist/humain/checklist/vendor/tools.d.ts.map +1 -0
  685. package/dist/humain/checklist/vendor/tools.js +162 -0
  686. package/dist/humain/checklist/vendor/tools.js.map +1 -0
  687. package/dist/humain/checklist/vendor/types.d.ts +188 -0
  688. package/dist/humain/checklist/vendor/types.d.ts.map +1 -0
  689. package/dist/humain/checklist/vendor/types.js +32 -0
  690. package/dist/humain/checklist/vendor/types.js.map +1 -0
  691. package/dist/humain/gateway/catalog.d.ts +1 -0
  692. package/dist/humain/gateway/catalog.d.ts.map +1 -1
  693. package/dist/humain/gateway/catalog.js +1 -0
  694. package/dist/humain/gateway/catalog.js.map +1 -1
  695. package/dist/humain/gateway/client.d.ts +1 -0
  696. package/dist/humain/gateway/client.d.ts.map +1 -1
  697. package/dist/humain/gateway/client.js +8 -1
  698. package/dist/humain/gateway/client.js.map +1 -1
  699. package/dist/humain/gateway/http.d.ts.map +1 -1
  700. package/dist/humain/gateway/http.js +11 -3
  701. package/dist/humain/gateway/http.js.map +1 -1
  702. package/dist/humain/gateway/images.d.ts +3 -0
  703. package/dist/humain/gateway/images.d.ts.map +1 -0
  704. package/dist/humain/gateway/images.js +73 -0
  705. package/dist/humain/gateway/images.js.map +1 -0
  706. package/dist/humain/gateway/provider.js +1 -1
  707. package/dist/humain/gateway/provider.js.map +1 -1
  708. package/dist/humain/hcode/account-store.d.ts.map +1 -1
  709. package/dist/humain/hcode/account-store.js +3 -1
  710. package/dist/humain/hcode/account-store.js.map +1 -1
  711. package/dist/humain/hcode/account.d.ts.map +1 -1
  712. package/dist/humain/hcode/account.js +23 -13
  713. package/dist/humain/hcode/account.js.map +1 -1
  714. package/dist/humain/hcode/images.d.ts.map +1 -1
  715. package/dist/humain/hcode/images.js +19 -13
  716. package/dist/humain/hcode/images.js.map +1 -1
  717. package/dist/humain/hcode/login-failure.d.ts +1 -0
  718. package/dist/humain/hcode/login-failure.d.ts.map +1 -1
  719. package/dist/humain/hcode/login-failure.js +1 -0
  720. package/dist/humain/hcode/login-failure.js.map +1 -1
  721. package/dist/humain/hcode/provider.d.ts.map +1 -1
  722. package/dist/humain/hcode/provider.js +2 -1
  723. package/dist/humain/hcode/provider.js.map +1 -1
  724. package/dist/humain/hcode/run-credential.d.ts +1 -0
  725. package/dist/humain/hcode/run-credential.d.ts.map +1 -1
  726. package/dist/humain/hcode/run-credential.js +12 -4
  727. package/dist/humain/hcode/run-credential.js.map +1 -1
  728. package/dist/humain/index.d.ts.map +1 -1
  729. package/dist/humain/index.js +4 -0
  730. package/dist/humain/index.js.map +1 -1
  731. package/dist/humain/node-provider.d.ts.map +1 -1
  732. package/dist/humain/node-provider.js +37 -8
  733. package/dist/humain/node-provider.js.map +1 -1
  734. package/dist/main.d.ts +1 -1
  735. package/dist/main.d.ts.map +1 -1
  736. package/dist/main.js +38 -26
  737. package/dist/main.js.map +1 -1
  738. package/dist/modes/interactive/chat-viewport.js +1 -1
  739. package/dist/modes/interactive/chat-viewport.js.map +1 -1
  740. package/dist/modes/interactive/components/bash-execution.d.ts +2 -1
  741. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  742. package/dist/modes/interactive/components/bash-execution.js +7 -4
  743. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  744. package/dist/modes/interactive/components/config-selector.js +1 -1
  745. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  746. package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
  747. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  748. package/dist/modes/interactive/components/custom-editor.js +20 -1
  749. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  750. package/dist/modes/interactive/components/extension-editor.d.ts +1 -1
  751. package/dist/modes/interactive/components/extension-editor.js +2 -2
  752. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  753. package/dist/modes/interactive/components/footer.d.ts +7 -0
  754. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  755. package/dist/modes/interactive/components/footer.js +74 -1
  756. package/dist/modes/interactive/components/footer.js.map +1 -1
  757. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  758. package/dist/modes/interactive/components/mermaid.js +11 -4
  759. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  760. package/dist/modes/interactive/components/model-selector.d.ts +2 -0
  761. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  762. package/dist/modes/interactive/components/model-selector.js +56 -8
  763. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  764. package/dist/modes/interactive/components/oauth-selector.d.ts +13 -1
  765. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  766. package/dist/modes/interactive/components/oauth-selector.js +10 -9
  767. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  768. package/dist/modes/interactive/components/session-selector.js +3 -3
  769. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  770. package/dist/modes/interactive/components/settings-selector.d.ts +4 -3
  771. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  772. package/dist/modes/interactive/components/settings-selector.js +83 -37
  773. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  774. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  775. package/dist/modes/interactive/components/settings-submenu.js +3 -3
  776. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  777. package/dist/modes/interactive/components/status-indicator.d.ts +18 -7
  778. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  779. package/dist/modes/interactive/components/status-indicator.js +70 -24
  780. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  781. package/dist/modes/interactive/components/status-line.d.ts +16 -0
  782. package/dist/modes/interactive/components/status-line.d.ts.map +1 -0
  783. package/dist/modes/interactive/components/status-line.js +51 -0
  784. package/dist/modes/interactive/components/status-line.js.map +1 -0
  785. package/dist/modes/interactive/components/tool-execution.d.ts +5 -0
  786. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  787. package/dist/modes/interactive/components/tool-execution.js +8 -1
  788. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  789. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  790. package/dist/modes/interactive/components/visual-truncate.js +11 -3
  791. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  792. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  793. package/dist/modes/interactive/external-editor.js +13 -3
  794. package/dist/modes/interactive/external-editor.js.map +1 -1
  795. package/dist/modes/interactive/interactive-mode.d.ts +17 -1
  796. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  797. package/dist/modes/interactive/interactive-mode.js +232 -108
  798. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  799. package/dist/modes/interactive/program-status-reporter.d.ts +2 -0
  800. package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -1
  801. package/dist/modes/interactive/program-status-reporter.js +4 -0
  802. package/dist/modes/interactive/program-status-reporter.js.map +1 -1
  803. package/dist/modes/interactive/session-share.d.ts.map +1 -1
  804. package/dist/modes/interactive/session-share.js +9 -1
  805. package/dist/modes/interactive/session-share.js.map +1 -1
  806. package/dist/modes/print-mode.d.ts.map +1 -1
  807. package/dist/modes/print-mode.js +34 -7
  808. package/dist/modes/print-mode.js.map +1 -1
  809. package/dist/modes/rpc/jsonl.js +6 -5
  810. package/dist/modes/rpc/jsonl.js.map +1 -1
  811. package/dist/modes/rpc/rpc-client.d.ts +2 -0
  812. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  813. package/dist/modes/rpc/rpc-client.js +9 -2
  814. package/dist/modes/rpc/rpc-client.js.map +1 -1
  815. package/dist/modes/rpc/rpc-mode.d.ts +2 -1
  816. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  817. package/dist/modes/rpc/rpc-mode.js +113 -13
  818. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  819. package/dist/modes/rpc/rpc-types.d.ts +22 -1
  820. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  821. package/dist/modes/rpc/rpc-types.js.map +1 -1
  822. package/dist/modes/uncaught-errors.d.ts +20 -0
  823. package/dist/modes/uncaught-errors.d.ts.map +1 -0
  824. package/dist/modes/uncaught-errors.js +56 -0
  825. package/dist/modes/uncaught-errors.js.map +1 -0
  826. package/dist/package-manager-cli.d.ts.map +1 -1
  827. package/dist/package-manager-cli.js +10 -1
  828. package/dist/package-manager-cli.js.map +1 -1
  829. package/dist/utils/clipboard-image.js +1 -1
  830. package/dist/utils/clipboard-image.js.map +1 -1
  831. package/dist/utils/clipboard.js +2 -2
  832. package/dist/utils/clipboard.js.map +1 -1
  833. package/dist/utils/image-process.d.ts +5 -0
  834. package/dist/utils/image-process.d.ts.map +1 -1
  835. package/dist/utils/image-process.js +22 -4
  836. package/dist/utils/image-process.js.map +1 -1
  837. package/dist/utils/output-files.d.ts +44 -7
  838. package/dist/utils/output-files.d.ts.map +1 -1
  839. package/dist/utils/output-files.js +206 -12
  840. package/dist/utils/output-files.js.map +1 -1
  841. package/dist/utils/piped-stdin.d.ts +21 -0
  842. package/dist/utils/piped-stdin.d.ts.map +1 -0
  843. package/dist/utils/piped-stdin.js +60 -0
  844. package/dist/utils/piped-stdin.js.map +1 -0
  845. package/dist/utils/shell.d.ts +5 -2
  846. package/dist/utils/shell.d.ts.map +1 -1
  847. package/dist/utils/shell.js +77 -8
  848. package/dist/utils/shell.js.map +1 -1
  849. package/dist/utils/syntax-highlight.d.ts +33 -2
  850. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  851. package/dist/utils/syntax-highlight.js +77 -10
  852. package/dist/utils/syntax-highlight.js.map +1 -1
  853. package/dist/utils/tools-manager.d.ts +1 -0
  854. package/dist/utils/tools-manager.d.ts.map +1 -1
  855. package/dist/utils/tools-manager.js +9 -8
  856. package/dist/utils/tools-manager.js.map +1 -1
  857. package/dist/utils/wsl.d.ts +8 -2
  858. package/dist/utils/wsl.d.ts.map +1 -1
  859. package/dist/utils/wsl.js +12 -3
  860. package/dist/utils/wsl.js.map +1 -1
  861. package/docs/cli.md +45 -3
  862. package/docs/codemode.md +7 -3
  863. package/docs/compaction.md +1 -1
  864. package/docs/coordination.md +16 -4
  865. package/docs/development.md +6 -0
  866. package/docs/environment-variables.md +5 -3
  867. package/docs/extensions.md +19 -5
  868. package/docs/keybindings.md +2 -0
  869. package/docs/llama-cpp.md +2 -2
  870. package/docs/message-types.md +1 -0
  871. package/docs/models-configuration.md +14 -3
  872. package/docs/models.md +29 -7
  873. package/docs/providers.md +25 -3
  874. package/docs/rpc-commands.md +25 -2
  875. package/docs/rpc.md +20 -0
  876. package/docs/run-preflight.md +2 -2
  877. package/docs/session-format.md +9 -0
  878. package/docs/settings.md +35 -5
  879. package/docs/shell-aliases.md +1 -1
  880. package/docs/slash-commands.md +3 -1
  881. package/docs/terminal-setup.md +25 -0
  882. package/docs/windows.md +2 -1
  883. package/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
  884. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  885. package/examples/rpc-extension-ui.ts +8 -7
  886. package/npm-shrinkwrap.json +209 -180
  887. package/package.json +26 -20
  888. package/schemas/keybindings.schema.json +12 -0
  889. package/schemas/models.schema.json +20 -7
  890. package/schemas/settings.schema.json +43 -5
  891. package/src/coordination/UPSTREAM.md +27 -1
  892. package/src/coordination/upstream.json +3 -3
  893. package/src/humain/ask-user-question/UPSTREAM.md +31 -0
  894. package/src/humain/ask-user-question/upstream.json +258 -0
  895. package/src/humain/ask-user-question/vendor/ask/LICENSE +21 -0
  896. package/src/humain/ask-user-question/vendor/ask/locales/de.json +38 -0
  897. package/src/humain/ask-user-question/vendor/ask/locales/en.json +41 -0
  898. package/src/humain/ask-user-question/vendor/ask/locales/es.json +38 -0
  899. package/src/humain/ask-user-question/vendor/ask/locales/fr.json +38 -0
  900. package/src/humain/ask-user-question/vendor/ask/locales/pt-BR.json +38 -0
  901. package/src/humain/ask-user-question/vendor/ask/locales/pt.json +38 -0
  902. package/src/humain/ask-user-question/vendor/ask/locales/ru.json +38 -0
  903. package/src/humain/ask-user-question/vendor/ask/locales/uk.json +38 -0
  904. package/src/humain/ask-user-question/vendor/ask/locales/zh.json +40 -0
  905. package/src/humain/ask-user-question/vendor/config/LICENSE +21 -0
  906. package/src/humain/ask-user-question/vendor/i18n/LICENSE +21 -0
  907. package/src/humain/caveman/UPSTREAM.md +44 -11
  908. package/src/humain/caveman/upstream.json +3 -3
  909. package/src/humain/caveman/vendor/NOTICE +4 -0
  910. package/dist/bundle/chunks/anthropic-messages-XFCDMGD6.js +0 -77
  911. package/dist/bundle/chunks/azure-openai-responses-F4KQM3NK.js +0 -15
  912. package/dist/bundle/chunks/bowser-DXKSTXFQ.js +0 -89
  913. package/dist/bundle/chunks/chunk-3E37CJCE.js +0 -34
  914. package/dist/bundle/chunks/chunk-3HVHETMU.js +0 -18
  915. package/dist/bundle/chunks/chunk-3PJ7NPWN.js +0 -80
  916. package/dist/bundle/chunks/chunk-6JTCRCNF.js +0 -74
  917. package/dist/bundle/chunks/chunk-F77J5EQZ.js +0 -3
  918. package/dist/bundle/chunks/chunk-GPLWWO5Q.js +0 -121
  919. package/dist/bundle/chunks/chunk-GV5OVRKK.js +0 -4
  920. package/dist/bundle/chunks/chunk-JBSWWCT5.js +0 -12
  921. package/dist/bundle/chunks/chunk-JQBZUFH7.js +0 -3580
  922. package/dist/bundle/chunks/chunk-JWOPWHVH.js +0 -51
  923. package/dist/bundle/chunks/chunk-KRBELWQH.js +0 -7
  924. package/dist/bundle/chunks/chunk-PFBAIRCY.js +0 -56
  925. package/dist/bundle/chunks/chunk-Q5RKNQ2T.js +0 -73
  926. package/dist/bundle/chunks/chunk-QFDZEUFU.js +0 -12
  927. package/dist/bundle/chunks/chunk-SKCJ25SX.js +0 -24
  928. package/dist/bundle/chunks/chunk-UEW6TUSP.js +0 -36
  929. package/dist/bundle/chunks/chunk-UZOIHLNU.js +0 -23
  930. package/dist/bundle/chunks/chunk-YSWDFV2L.js +0 -11
  931. package/dist/bundle/chunks/chunk-YZMQXAJM.js +0 -8
  932. package/dist/bundle/chunks/entry-2GZ3PTWQ.js +0 -2
  933. package/dist/bundle/chunks/google-generative-ai-WIASMWS3.js +0 -22
  934. package/dist/bundle/chunks/google-vertex-WSPHRZIZ.js +0 -25
  935. package/dist/bundle/chunks/interactive-mode-SDUO5OLD.js +0 -5
  936. package/dist/bundle/chunks/mistral-conversations-7JYDDRUT.js +0 -43
  937. package/dist/bundle/chunks/openai-codex-responses-7PAML4NF.js +0 -102
  938. package/dist/bundle/chunks/openai-completions-UJDAIGTK.js +0 -87
  939. package/dist/bundle/chunks/openai-responses-2WNCE6AY.js +0 -26
  940. package/dist/bundle/chunks/openrouter-images-V3UCCO6X.js +0 -8
  941. package/dist/bundle/chunks/pi-messages-TQ7LJUNQ.js +0 -28
  942. package/dist/bundle/chunks/runtime-H7LYNKCZ.js +0 -2
  943. package/dist/bundle/chunks/session-picker-EYKCMFQR.js +0 -4
  944. package/dist/bundle/chunks/startup-ui-7ODOR34R.js +0 -3
  945. package/dist/bundle/chunks/typesafe-system-one-YP7GGN4C.js +0 -3
  946. package/dist/bundle/chunks/virtual-modules-IU5KWB2C.js +0 -28
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { CodemodeSandbox, loadQuickJSWasm, parseCodemodeSource, renderToolSample, toCodemodeIdentifier, } from "@earendil-works/pi-codemode";
6
6
  import { getCodemodeWorkerSpecifier, getQuickJSWasmPath } from "../../config.js";
7
+ import { NESTED_CALL_LIMITS } from "../../core/nested-tool-calls.js";
7
8
  import { formatSize, sliceHead, sliceTail } from "../../core/tools/truncate.js";
8
9
  import { combineUsage } from "../../core/usage-totals.js";
9
10
  import { writeOutputFile } from "../../utils/output-files.js";
@@ -312,12 +313,13 @@ function joinAdjacentText(items) {
312
313
  flush();
313
314
  return joined;
314
315
  }
315
- function formatCallSummary(calls) {
316
+ function formatCallSummary({ calls, omittedCalls }) {
316
317
  if (calls.length === 0)
317
318
  return "No tool calls were made.";
318
- return `Tool calls made before the failure (they are not undone): ${calls.map((call) => `${call.name} (${call.status})`).join(", ")}`;
319
+ const omitted = omittedCalls ? `, and ${omittedCalls} later calls not listed` : "";
320
+ return `Tool calls made before the failure (they are not undone): ${calls.map((call) => `${call.name} (${call.status})`).join(", ")}${omitted}`;
319
321
  }
320
- function formatError(result, calls) {
322
+ function formatError(result, details) {
321
323
  const { error } = result;
322
324
  const head = error.kind === "script"
323
325
  ? (error.stack ?? `${error.name ?? "Error"}: ${error.message}`)
@@ -326,7 +328,7 @@ function formatError(result, calls) {
326
328
  : error.kind === "aborted"
327
329
  ? `Script aborted: ${error.message}`
328
330
  : `Script sandbox failed: ${error.message}`;
329
- return `${head}\n\n${formatCallSummary(calls)}`;
331
+ return `${head}\n\n${formatCallSummary(details)}`;
330
332
  }
331
333
  /** Write the full text output to a temp file, like bash does for truncated output. */
332
334
  async function spillOutput(text) {
@@ -421,6 +423,52 @@ function toScriptValue(tool, outcome) {
421
423
  throw new Error(text || `Tool "${tool.name}" failed`);
422
424
  return text;
423
425
  }
426
+ /**
427
+ * The nested call rows of one script, published through `onUpdate` as they change. Each update
428
+ * copies every row, so a script that loops over calls would cost quadratic time and memory (in RPC
429
+ * mode, every update is queued as a JSON line). Like the session's nested-call record, it lists at
430
+ * most `NESTED_CALL_LIMITS.maxCalls` rows; later calls are only counted, with their cost.
431
+ */
432
+ class CodemodeCallLog {
433
+ calls = [];
434
+ omittedCalls = 0;
435
+ omittedCost = 0;
436
+ onUpdate;
437
+ constructor(onUpdate) {
438
+ this.onUpdate = onUpdate;
439
+ }
440
+ /** Add the row of a starting call, or count the call once the list is full. */
441
+ start(record) {
442
+ if (this.calls.length >= NESTED_CALL_LIMITS.maxCalls) {
443
+ this.omittedCalls++;
444
+ // One update marks the list incomplete; omitted calls publish nothing else.
445
+ if (this.omittedCalls === 1)
446
+ this.publish();
447
+ return;
448
+ }
449
+ this.calls.push(record);
450
+ this.publish();
451
+ }
452
+ /** Publish the finished row, or add the cost of an omitted call. */
453
+ finish(record) {
454
+ if (!this.calls.includes(record)) {
455
+ this.omittedCost += record.cost ?? 0;
456
+ return;
457
+ }
458
+ this.publish();
459
+ }
460
+ snapshot() {
461
+ const details = { calls: this.calls.map((call) => ({ ...call })) };
462
+ if (this.omittedCalls > 0) {
463
+ details.omittedCalls = this.omittedCalls;
464
+ details.omittedCost = this.omittedCost;
465
+ }
466
+ return details;
467
+ }
468
+ publish() {
469
+ this.onUpdate?.({ content: [], details: this.snapshot() });
470
+ }
471
+ }
424
472
  /**
425
473
  * Run one script. Without a session context (a plain Agent or a direct call) scripts cannot call
426
474
  * tools, `store()` starts empty, and writes are dropped.
@@ -428,7 +476,7 @@ function toScriptValue(tool, outcome) {
428
476
  export async function executeCodemode(toolCallId, input, signal, onUpdate, ctx, options = {}) {
429
477
  const startedAt = performance.now();
430
478
  const { code, options: sourceOptions } = parseCodemodeSource(input.code);
431
- const calls = [];
479
+ const log = new CodemodeCallLog(onUpdate);
432
480
  // Usage of the script's `models.*` calls. Nested tool calls report theirs through the session.
433
481
  let modelUsage;
434
482
  // Images returned by `models.generateImages()`, to notice a script that never shows them.
@@ -439,10 +487,8 @@ export async function executeCodemode(toolCallId, input, signal, onUpdate, ctx,
439
487
  const addModelUsage = (usage) => {
440
488
  modelUsage = modelUsage ? combineUsage(modelUsage, usage) : usage;
441
489
  };
442
- const snapshot = () => ({ calls: calls.map((call) => ({ ...call })) });
443
- const publish = () => onUpdate?.({ content: [], details: snapshot() });
444
490
  // Show the script as running before its first nested call, so the row's timer starts.
445
- publish();
491
+ log.publish();
446
492
  const callable = ctx ? getCodemodeCallableTools(ctx.tools) : [];
447
493
  // ALL_TOOLS entries carry the declaration.
448
494
  const guidelines = options.getToolGuidelines?.();
@@ -457,8 +503,7 @@ export async function executeCodemode(toolCallId, input, signal, onUpdate, ctx,
457
503
  args: previewArgs(args),
458
504
  status: "running",
459
505
  };
460
- calls.push(record);
461
- publish();
506
+ log.start(record);
462
507
  const callStartedAt = performance.now();
463
508
  // Only tools from ctx.tools are callable, so ctx is set here.
464
509
  if (!ctx)
@@ -473,7 +518,7 @@ export async function executeCodemode(toolCallId, input, signal, onUpdate, ctx,
473
518
  else {
474
519
  record.status = "ok";
475
520
  }
476
- publish();
521
+ log.finish(record);
477
522
  return toScriptValue(tool, outcome);
478
523
  },
479
524
  }));
@@ -495,7 +540,7 @@ export async function executeCodemode(toolCallId, input, signal, onUpdate, ctx,
495
540
  { type: "text", text: `Script failed\nWall time ${waited} seconds\nOutput:\n` },
496
541
  { type: "text", text: `Script error:\n${error}\n\nThe script did not start.` },
497
542
  ],
498
- details: snapshot(),
543
+ details: log.snapshot(),
499
544
  isError: true,
500
545
  };
501
546
  }
@@ -516,7 +561,7 @@ export async function executeCodemode(toolCallId, input, signal, onUpdate, ctx,
516
561
  globals: [
517
562
  ...createDiscoveryGlobals(callable, samples, options),
518
563
  ...(options.models && ctx
519
- ? createModelGlobals(ctx.modelRegistry, toolCallId, calls, publish, addModelUsage, addGeneratedImages)
564
+ ? createModelGlobals(ctx.modelRegistry, toolCallId, log, addModelUsage, addGeneratedImages)
520
565
  : []),
521
566
  ].map(own),
522
567
  environment: options.environment,
@@ -545,7 +590,7 @@ export async function executeCodemode(toolCallId, input, signal, onUpdate, ctx,
545
590
  }
546
591
  }
547
592
  // Calls still marked running were cut off by the script ending, a timeout, or an abort.
548
- for (const call of calls) {
593
+ for (const call of log.calls) {
549
594
  if (call.status === "running")
550
595
  call.status = "cancelled";
551
596
  }
@@ -557,7 +602,7 @@ export async function executeCodemode(toolCallId, input, signal, onUpdate, ctx,
557
602
  }
558
603
  const items = formatOutput(result.output);
559
604
  if (!result.ok)
560
- items.push({ type: "text", text: `Script error:\n${formatError(result, calls)}` });
605
+ items.push({ type: "text", text: `Script error:\n${formatError(result, log.snapshot())}` });
561
606
  if (generatedImages > 0 && !items.some((item) => item.type === "image")) {
562
607
  items.push({
563
608
  type: "text",
@@ -570,7 +615,7 @@ export async function executeCodemode(toolCallId, input, signal, onUpdate, ctx,
570
615
  const output = joinAdjacentText(await saveImages(truncated.items));
571
616
  const wallTime = ((performance.now() - startedAt) / 1000).toFixed(1);
572
617
  const header = `${result.ok ? "Script completed" : "Script failed"}\nWall time ${wallTime} seconds\nOutput:\n`;
573
- const details = snapshot();
618
+ const details = log.snapshot();
574
619
  if (truncated.fullOutputPath)
575
620
  details.fullOutputPath = truncated.fullOutputPath;
576
621
  return {
@@ -664,7 +709,7 @@ function createDiscoveryGlobals(tools, samples, options) {
664
709
  * Classifier and image calls appear as nested call rows so the renderer shows them, and their usage
665
710
  * goes to `addUsage`. Rows show only the model, never prompts or image data.
666
711
  */
667
- function createModelGlobals(models, toolCallId, calls, publish, addUsage, addGeneratedImages) {
712
+ function createModelGlobals(models, toolCallId, log, addUsage, addGeneratedImages) {
668
713
  const limit = createLimiter(MAX_CONCURRENT_MODEL_CALLS);
669
714
  let callCount = 0;
670
715
  /**
@@ -698,8 +743,7 @@ function createModelGlobals(models, toolCallId, calls, publish, addUsage, addGen
698
743
  args: `${resolved.provider}/${resolved.id}`,
699
744
  status: "running",
700
745
  };
701
- calls.push(record);
702
- publish();
746
+ log.start(record);
703
747
  const startedAt = performance.now();
704
748
  const result = await limit(() => run(resolved, checked));
705
749
  record.durationMs = performance.now() - startedAt;
@@ -710,7 +754,7 @@ function createModelGlobals(models, toolCallId, calls, publish, addUsage, addGen
710
754
  record.cost = result.usage.cost.total;
711
755
  addUsage(result.usage);
712
756
  }
713
- publish();
757
+ log.finish(record);
714
758
  return result;
715
759
  };
716
760
  const implementations = {
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/extensions/codemode/execute.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,EAGN,eAAe,EAEf,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGjF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EACN,kBAAkB,EAClB,yBAAyB,EAOzB,wBAAwB,EACxB,qBAAqB,GACrB,MAAM,WAAW,CAAC;AAEnB,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,4IAA4I;AAC5I,MAAM,0BAA0B,GAAG,CAAC,CAAC;AACrC;;;;GAIG;AACH,MAAM,2BAA2B,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AACtD,qGAAqG;AACrG,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAEvC;;;GAGG;AACH,SAAS,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,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAC9C;QACF,uBAAuB,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAC7C,YAAY,CACX,uBAAuB,EACvB,OAAO,EACP,IAAiB,EACjB,kBAAkB,EAClB,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;YAC3B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;YAC1E,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;YACnF,OAAO,MAAM,CAAC;QACf,CAAC,CACD;KACF,CAAC;IACF,OAAO,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AACpG,CAAC","sourcesContent":["/**\n * Runs one codemode script in the sandbox. Split from tool.ts and loaded through\n * execute.lazy.ts so the sandbox runtime only loads when a script runs.\n */\n\nimport type { AgentTool, AgentToolCallOutcome, AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport type {\n\tAnyModel,\n\tClassifierContext,\n\tImageContent,\n\tImagesContext,\n\tModelType,\n\tModelTypeMap,\n\tTextContent,\n\tUsage,\n} from \"@earendil-works/pi-ai\";\nimport {\n\ttype CodemodeOutputItem,\n\ttype CodemodeResult,\n\tCodemodeSandbox,\n\ttype CodemodeTool,\n\tloadQuickJSWasm,\n\tparseCodemodeSource,\n\trenderToolSample,\n\ttoCodemodeIdentifier,\n} from \"@earendil-works/pi-codemode\";\nimport { getCodemodeWorkerSpecifier, getQuickJSWasmPath } from \"../../config.ts\";\nimport type { ExtensionToolContext, ToolNamespace } from \"../../core/extensions/types.ts\";\nimport type { SessionEntry } from \"../../core/session-manager.ts\";\nimport { formatSize, sliceHead, sliceTail } from \"../../core/tools/truncate.ts\";\nimport { combineUsage } from \"../../core/usage-totals.ts\";\nimport { writeOutputFile } from \"../../utils/output-files.ts\";\nimport { Bm25Ranker, createToolSearchDocument, DEFAULT_TOOL_SEARCH_LIMIT } from \"../tool-search/tool.ts\";\nimport {\n\tCODEMODE_DOCS_PATH,\n\tCODEMODE_STORE_ENTRY_TYPE,\n\ttype CodemodeModelRuntime,\n\ttype CodemodeNestedCall,\n\ttype CodemodeStoreEntryData,\n\ttype CodemodeToolDetails,\n\ttype CodemodeToolInput,\n\ttype CodemodeToolOptions,\n\tgetCodemodeCallableTools,\n\ttoCodemodeDeclaration,\n} from \"./tool.ts\";\n\nconst ARGS_PREVIEW_CHARS = 200;\nconst ERROR_PREVIEW_CHARS = 500;\n/** `models.classify()` and `models.generateImages()` calls one script may have in flight; `Promise.all` over many items queues the rest. */\nconst MAX_CONCURRENT_MODEL_CALLS = 4;\n/**\n * Heap limit for the QuickJS VM. The worker shares the HUMAIN Code CLI process, so without a limit a runaway\n * script can grow to wasm32's 4 GiB and take the session down. Overruns end the script with\n * `InternalError: out of memory`, which the script cannot catch.\n */\nconst CODEMODE_MEMORY_LIMIT_BYTES = 256 * 1024 * 1024;\n// Shared across calls and sessions. Allow one replacement while a cancelled worker is still exiting.\nconst DEFAULT_MAX_CODEMODE_WORKERS = 2;\n\n/**\n * `HUMAIN_TERMINAL_CODEMODE_MAX_WORKERS` (or upstream's `PI_CODEMODE_MAX_WORKERS`) if it is a positive integer.\n * Read per call so SDK hosts can set it at runtime.\n */\nfunction maxCodemodeWorkers(environment: NodeJS.ProcessEnv = process.env): number {\n\tconst value = Number(environment.HUMAIN_TERMINAL_CODEMODE_MAX_WORKERS || environment.PI_CODEMODE_MAX_WORKERS);\n\treturn Number.isInteger(value) && value > 0 ? value : DEFAULT_MAX_CODEMODE_WORKERS;\n}\n/**\n * How long a script waits for a free worker before failing. Bounds the wait when every worker is\n * held by a script that waits on another script, for example an in-process subagent that uses codemode.\n */\nconst CODEMODE_WORKER_WAIT_MS = 60_000;\nlet activeCodemodeWorkers = 0;\n/** Scripts waiting for a worker, in arrival order. */\nconst codemodeWorkerWaiters: { grant(): void; environment?: NodeJS.ProcessEnv }[] = [];\n\n/**\n * Reserve one worker slot, waiting in arrival order while all are taken. Resolves with why it could\n * not reserve one: the signal aborted, or `timeoutMs` passed.\n */\nfunction reserveCodemodeWorker(\n\tsignal: AbortSignal | undefined,\n\ttimeoutMs: number,\n\tenvironment?: NodeJS.ProcessEnv,\n): Promise<\"reserved\" | \"aborted\" | \"timeout\"> {\n\tif (signal?.aborted) return Promise.resolve(\"aborted\");\n\treturn new Promise((resolve) => {\n\t\tconst settle = (outcome: \"reserved\" | \"aborted\" | \"timeout\") => {\n\t\t\tclearTimeout(timer);\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tconst index = codemodeWorkerWaiters.findIndex((waiter) => waiter.grant === grant);\n\t\t\tif (index >= 0) codemodeWorkerWaiters.splice(index, 1);\n\t\t\tresolve(outcome);\n\t\t};\n\t\tconst grant = () => settle(\"reserved\");\n\t\tconst onAbort = () => settle(\"aborted\");\n\t\tconst timer = setTimeout(() => settle(\"timeout\"), timeoutMs);\n\t\tcodemodeWorkerWaiters.push({ grant, environment });\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\tadmitCodemodeWorkers();\n\t});\n}\n\n/** Give free slots to waiting scripts in arrival order. */\nfunction admitCodemodeWorkers(): void {\n\twhile (\n\t\tcodemodeWorkerWaiters.length > 0 &&\n\t\tactiveCodemodeWorkers < maxCodemodeWorkers(codemodeWorkerWaiters[0].environment)\n\t) {\n\t\tactiveCodemodeWorkers++;\n\t\tcodemodeWorkerWaiters.shift()?.grant();\n\t}\n}\n\nfunction releaseCodemodeWorker(): void {\n\tactiveCodemodeWorkers--;\n\tadmitCodemodeWorkers();\n}\nconst MODEL_TYPES: ReadonlySet<string> = new Set<ModelType>([\"chat\", \"image\", \"classifier\"]);\n\nfunction truncateText(text: string, maxChars: number): string {\n\treturn text.length > maxChars ? `${sliceHead(text, maxChars - 3)}...` : text;\n}\n\nfunction previewArgs(args: unknown): string {\n\tif (args === undefined) return \"\";\n\ttry {\n\t\treturn truncateText(JSON.stringify(args) ?? \"\", ARGS_PREVIEW_CHARS);\n\t} catch {\n\t\treturn \"\";\n\t}\n}\n\nfunction textOf(result: AgentToolResult<unknown>): string {\n\treturn (result.content ?? [])\n\t\t.filter((block): block is TextContent => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.join(\"\\n\");\n}\n\nfunction toModelType(value: unknown): ModelType {\n\tif (typeof value === \"string\" && MODEL_TYPES.has(value)) return value as ModelType;\n\tthrow new Error(`Unknown model type ${JSON.stringify(value)}. Use \"chat\", \"image\", or \"classifier\".`);\n}\n\nfunction toProvider(value: unknown): string | undefined {\n\tif (value === undefined || value === null) return undefined;\n\tif (typeof value !== \"string\") throw new Error(\"provider must be a string\");\n\treturn value;\n}\n\n/** Catalog entry for scripts. `headers` is dropped because models.json headers can carry credentials. */\nfunction toModelInfo(model: AnyModel): Record<string, unknown> {\n\tconst info: Record<string, unknown> = { ...model };\n\tdelete info.headers;\n\treturn info;\n}\n\n/** `an image`, `a classifier`. */\nfunction withArticle(word: string): string {\n\treturn `${/^[aeiou]/.test(word) ? \"an\" : \"a\"} ${word}`;\n}\n\n/** A JSON value from a script, read field by field: values that are not objects have no fields. */\ntype ScriptValue = { readonly [key: string]: unknown } | null | undefined;\n\n/** A script value in an error message: `undefined`, `a string`, `an array`, or its keys (`{ prompt }`). */\nfunction describeValue(value: unknown): string {\n\tif (value === undefined || value === null) return String(value);\n\tif (Array.isArray(value)) return value.length === 0 ? \"an empty array\" : \"an array\";\n\tif (typeof value === \"object\") {\n\t\tconst keys = Object.keys(value);\n\t\tif (keys.length === 0) return \"{}\";\n\t\treturn `{ ${keys.slice(0, 6).join(\", \")}${keys.length > 6 ? \", ...\" : \"\"} }`;\n\t}\n\treturn typeof value === \"string\" ? \"a string\" : `a ${typeof value}`;\n}\n\nconst CLASSIFIER_CONTEXT_SHAPE =\n\t'{ state: { ... }, images?: [{ type: \"image\", data: <base64>, mimeType }], questions: { <id>: { type: \"choice\", instructions, criteria: { <label>: <meaning> } } | { type: \"score\", instructions, criteria: [<lowest level>, ..., <highest level>] } | { type: \"bool\", instructions, criteria: { true: <meaning>, false: <meaning> } } } }';\n\n/** Check a script's classifier context, so mistakes fail with the expected shape instead of a provider error. */\nfunction checkClassifierContext(context: unknown): ClassifierContext {\n\tconst fail = (problem: string) =>\n\t\tnew Error(\n\t\t\t`models.classify() ${problem}. Expected context: ${CLASSIFIER_CONTEXT_SHAPE}. See \"Classify\" in ${CODEMODE_DOCS_PATH}.`,\n\t\t);\n\tif (typeof context !== \"object\" || context === null || Array.isArray(context)) {\n\t\tthrow fail(`expects a context object as its second argument, got ${describeValue(context)}`);\n\t}\n\tconst { state, images, questions } = context as Record<string, unknown>;\n\tif (typeof state !== \"object\" || state === null || Array.isArray(state)) {\n\t\tthrow fail(`context.state must be an object, got ${describeValue(state)}`);\n\t}\n\tif (images !== undefined) {\n\t\tif (!Array.isArray(images)) throw fail(`context.images must be an array, got ${describeValue(images)}`);\n\t\timages.forEach((image: ScriptValue, index) => {\n\t\t\tif (image?.type !== \"image\" || typeof image.data !== \"string\" || typeof image.mimeType !== \"string\") {\n\t\t\t\tthrow fail(`context.images[${index}] must be an image block, got ${describeValue(image)}`);\n\t\t\t}\n\t\t});\n\t}\n\tif (\n\t\ttypeof questions !== \"object\" ||\n\t\tquestions === null ||\n\t\tArray.isArray(questions) ||\n\t\tObject.keys(questions).length === 0\n\t) {\n\t\tthrow fail(`context.questions must map question IDs to questions, got ${describeValue(questions)}`);\n\t}\n\tconst isStrings = (values: unknown[]) => values.length > 0 && values.every((value) => typeof value === \"string\");\n\tfor (const [id, question] of Object.entries(questions)) {\n\t\tconst at = `context.questions.${id}`;\n\t\tif (typeof question !== \"object\" || question === null || Array.isArray(question)) {\n\t\t\tthrow fail(`${at} must be a question object, got ${describeValue(question)}`);\n\t\t}\n\t\tconst { type, instructions, criteria } = question as Record<string, unknown>;\n\t\tif (typeof instructions !== \"string\") throw fail(`${at}.instructions must be a string`);\n\t\tif (type === \"choice\") {\n\t\t\tif (\n\t\t\t\ttypeof criteria !== \"object\" ||\n\t\t\t\tcriteria === null ||\n\t\t\t\tArray.isArray(criteria) ||\n\t\t\t\t!isStrings(Object.values(criteria))\n\t\t\t) {\n\t\t\t\tthrow fail(`${at} is a \"choice\" question, so criteria must map each label to its meaning`);\n\t\t\t}\n\t\t} else if (type === \"score\") {\n\t\t\tif (!Array.isArray(criteria) || !isStrings(criteria)) {\n\t\t\t\tthrow fail(`${at} is a \"score\" question, so criteria must list the levels as strings, lowest first`);\n\t\t\t}\n\t\t} else if (type === \"bool\") {\n\t\t\tconst labels = criteria as ScriptValue;\n\t\t\tif (typeof labels?.true !== \"string\" || typeof labels.false !== \"string\") {\n\t\t\t\tthrow fail(`${at} is a \"bool\" question, so criteria must be { true: string, false: string }`);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow fail(`${at}.type must be \"choice\", \"score\", or \"bool\", got ${JSON.stringify(type)}`);\n\t\t}\n\t}\n\treturn context as unknown as ClassifierContext;\n}\n\n/** Check a script's image context, so mistakes such as `{ prompt }` fail with the expected shape. */\nfunction checkImagesContext(context: unknown): ImagesContext {\n\tconst fail = (problem: string) =>\n\t\tnew Error(\n\t\t\t`models.generateImages() ${problem}. Expected context: { input: [{ type: \"text\", text: <prompt> }, ...optional { type: \"image\", data: <base64>, mimeType } references] }. See \"Generate images\" in ${CODEMODE_DOCS_PATH}.`,\n\t\t);\n\tif (typeof context !== \"object\" || context === null || Array.isArray(context)) {\n\t\tthrow fail(`expects a context object as its second argument, got ${describeValue(context)}`);\n\t}\n\tconst { input } = context as Record<string, unknown>;\n\tif (!Array.isArray(input) || input.length === 0) {\n\t\tthrow fail(`context.input must be a non-empty array of blocks, got ${describeValue(input)}`);\n\t}\n\tinput.forEach((block: ScriptValue, index) => {\n\t\tif (block?.type === \"text\" && typeof block.text === \"string\") return;\n\t\tif (block?.type === \"image\" && typeof block.data === \"string\" && typeof block.mimeType === \"string\") return;\n\t\tthrow fail(`context.input[${index}] must be a text or image block, got ${describeValue(block)}`);\n\t});\n\treturn context as unknown as ImagesContext;\n}\n\n/** The fields of `ClassifierResult` and `AssistantImages` that a nested call row reports. */\ninterface ModelCallResult {\n\tstopReason: \"stop\" | \"error\" | \"aborted\";\n\terrorMessage?: string;\n\tusage?: Usage;\n}\n\n/** Runs at most `limit` calls at once, in call order. */\nfunction createLimiter(limit: number): <T>(run: () => Promise<T>) => Promise<T> {\n\tlet active = 0;\n\tconst waiting: (() => void)[] = [];\n\treturn async (run) => {\n\t\tif (active >= limit) await new Promise<void>((resolve) => waiting.push(resolve));\n\t\tactive++;\n\t\ttry {\n\t\t\treturn await run();\n\t\t} finally {\n\t\t\tactive--;\n\t\t\twaiting.shift()?.();\n\t\t}\n\t};\n}\n\nfunction isStoreEntryData(data: unknown): data is CodemodeStoreEntryData {\n\tif (typeof data !== \"object\" || data === null) return false;\n\tconst { set, delete: deleted } = data as Partial<CodemodeStoreEntryData>;\n\treturn (\n\t\ttypeof set === \"object\" &&\n\t\tset !== null &&\n\t\tArray.isArray(deleted) &&\n\t\tdeleted.every((key: unknown) => typeof key === \"string\")\n\t);\n}\n\n/** Values of `load()`: the `codemode-store` entries on the branch, applied from the root. */\nexport function readCodemodeStore(branch: readonly SessionEntry[]): Record<string, unknown> {\n\tconst store = new Map<string, unknown>();\n\tfor (const entry of branch) {\n\t\tif (entry.type !== \"custom\" || entry.customType !== CODEMODE_STORE_ENTRY_TYPE || !isStoreEntryData(entry.data)) {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const key of entry.data.delete) store.delete(key);\n\t\tfor (const [key, value] of Object.entries(entry.data.set)) store.set(key, value);\n\t}\n\treturn Object.fromEntries(store);\n}\n\n/** Default token budget for script output. */\nconst DEFAULT_MAX_OUTPUT_TOKENS = 10_000;\n/** Characters per token when estimating. */\nconst CHARS_PER_TOKEN = 4;\n\n/**\n * Lay out the script's output so the model can tell items apart: providers join adjacent text\n * blocks with a newline or with nothing. With more than one text item (`text()` or the returned\n * value), each starts with a `==> text N/M <==` line. `console.*` lines follow all other output in\n * one `<console_output>` block.\n */\nfunction formatOutput(output: readonly CodemodeOutputItem[]): (TextContent | ImageContent)[] {\n\tconst total = output.filter((item) => item.type === \"text\" && !item.console).length;\n\tconst items: (TextContent | ImageContent)[] = [];\n\tconst consoleLines: string[] = [];\n\tlet index = 0;\n\tfor (const item of output) {\n\t\tif (item.type === \"image\") {\n\t\t\titems.push(item);\n\t\t} else if (item.console) {\n\t\t\tconsoleLines.push(item.text);\n\t\t} else {\n\t\t\tindex++;\n\t\t\titems.push({ type: \"text\", text: total > 1 ? `==> text ${index}/${total} <==\\n${item.text}` : item.text });\n\t\t}\n\t}\n\tif (consoleLines.length > 0) {\n\t\titems.push({ type: \"text\", text: `<console_output>\\n${consoleLines.join(\"\\n\")}\\n</console_output>` });\n\t}\n\treturn items;\n}\n\n/**\n * Join adjacent text items into one, each part starting on its own line. The separator check looks\n * at the last non-empty part, not the joined text: reading the end of a growing concatenation makes\n * V8 copy it on every item, which is quadratic (#10678).\n */\nfunction joinAdjacentText(items: (TextContent | ImageContent)[]): (TextContent | ImageContent)[] {\n\tconst joined: (TextContent | ImageContent)[] = [];\n\tlet parts: string[] = [];\n\tlet lastPart = \"\";\n\tconst flush = () => {\n\t\tif (parts.length > 0) joined.push({ type: \"text\", text: parts.join(\"\") });\n\t\tparts = [];\n\t\tlastPart = \"\";\n\t};\n\tfor (const item of items) {\n\t\tif (item.type !== \"text\") {\n\t\t\tflush();\n\t\t\tjoined.push(item);\n\t\t\tcontinue;\n\t\t}\n\t\tif (lastPart !== \"\" && !lastPart.endsWith(\"\\n\")) {\n\t\t\tparts.push(\"\\n\");\n\t\t\tlastPart = \"\\n\";\n\t\t}\n\t\tparts.push(item.text);\n\t\tif (item.text !== \"\") lastPart = item.text;\n\t}\n\tflush();\n\treturn joined;\n}\n\nfunction formatCallSummary(calls: readonly CodemodeNestedCall[]): string {\n\tif (calls.length === 0) return \"No tool calls were made.\";\n\treturn `Tool calls made before the failure (they are not undone): ${calls.map((call) => `${call.name} (${call.status})`).join(\", \")}`;\n}\n\nfunction formatError(result: Extract<CodemodeResult, { ok: false }>, calls: readonly CodemodeNestedCall[]): string {\n\tconst { error } = result;\n\tconst head =\n\t\terror.kind === \"script\"\n\t\t\t? (error.stack ?? `${error.name ?? \"Error\"}: ${error.message}`)\n\t\t\t: error.kind === \"timeout\"\n\t\t\t\t? `Script timed out: ${error.message}`\n\t\t\t\t: error.kind === \"aborted\"\n\t\t\t\t\t? `Script aborted: ${error.message}`\n\t\t\t\t\t: `Script sandbox failed: ${error.message}`;\n\treturn `${head}\\n\\n${formatCallSummary(calls)}`;\n}\n\n/** Write the full text output to a temp file, like bash does for truncated output. */\nasync function spillOutput(text: string): Promise<{ path: string } | { error: string }> {\n\ttry {\n\t\treturn { path: await writeOutputFile(\"pi-codemode\", \".txt\", text) };\n\t} catch (error) {\n\t\treturn { error: error instanceof Error ? error.message : String(error) };\n\t}\n}\n\n/** File extensions of the image types `image()` accepts. Must list every type the sandbox's `image()` detects. */\nconst IMAGE_EXTENSIONS: Record<string, string> = {\n\t\"image/png\": \".png\",\n\t\"image/jpeg\": \".jpg\",\n\t\"image/gif\": \".gif\",\n\t\"image/webp\": \".webp\",\n};\n\n/**\n * Save each image to a temp file and put a text item with its path before it. The model sees the\n * image but has no other way to reach its bytes: scripts cannot write files, and `write` only takes\n * text. Images shown more than once are saved once.\n */\nasync function saveImages(items: (TextContent | ImageContent)[]): Promise<(TextContent | ImageContent)[]> {\n\tconst labels = new Map<string, Promise<string>>();\n\tconst label = async ({ data, mimeType }: ImageContent): Promise<string> => {\n\t\tconst bytes = Buffer.from(data, \"base64\");\n\t\tconst kind = `${mimeType}, ${formatSize(bytes.length)}`;\n\t\tconst extension = IMAGE_EXTENSIONS[mimeType];\n\t\tif (!extension) throw new Error(`No file extension for image type ${mimeType}`);\n\t\t// A failed write (disk full, unwritable temp dir) must not discard the result of a script whose\n\t\t// tool calls already ran, so it becomes part of the label.\n\t\ttry {\n\t\t\tconst path = await writeOutputFile(\"pi-codemode\", extension, bytes);\n\t\t\treturn `[Image saved to ${path} (${kind})]`;\n\t\t} catch (error) {\n\t\t\treturn `[Image (${kind}) could not be saved: ${error instanceof Error ? error.message : String(error)}]`;\n\t\t}\n\t};\n\tconst result = await Promise.all(\n\t\titems.map(async (item): Promise<(TextContent | ImageContent)[]> => {\n\t\t\tif (item.type !== \"image\") return [item];\n\t\t\tlet pending = labels.get(item.data);\n\t\t\tif (!pending) {\n\t\t\t\tpending = label(item);\n\t\t\t\tlabels.set(item.data, pending);\n\t\t\t}\n\t\t\treturn [{ type: \"text\", text: await pending }, item];\n\t\t}),\n\t);\n\treturn result.flat();\n}\n\n/**\n * Apply the token budget: when the combined text exceeds it, the text items become one\n * item that keeps the start and end of the text, and images follow it. The full text is written to\n * a temp file.\n */\nasync function truncateOutput(\n\titems: (TextContent | ImageContent)[],\n\tmaxTokens: number,\n): Promise<{ items: (TextContent | ImageContent)[]; fullOutputPath?: string }> {\n\tconst texts = items.filter((item): item is TextContent => item.type === \"text\").map((item) => item.text);\n\tconst combined = texts.join(\"\\n\");\n\tconst budget = maxTokens * CHARS_PER_TOKEN;\n\tif (texts.length === 0 || combined.length <= budget) return { items };\n\tconst headChars = Math.floor(budget / 2);\n\tconst tailChars = budget - headChars;\n\tconst removed = combined.length - headChars - tailChars;\n\tconst head = sliceHead(combined, headChars);\n\tconst tail = sliceTail(combined, tailChars);\n\tlet text = `Warning: truncated output (original token count: ${Math.ceil(combined.length / CHARS_PER_TOKEN)})\\nTotal output lines: ${combined.split(\"\\n\").length}\\n\\n${head}…${Math.ceil(removed / CHARS_PER_TOKEN)} tokens truncated…${tail}`;\n\tconst spilled = await spillOutput(combined);\n\ttext +=\n\t\t\"path\" in spilled\n\t\t\t? `\\n\\n[Full output: ${spilled.path} (read with offset/limit)]`\n\t\t\t: `\\n\\n[Could not save the full output: ${spilled.error}]`;\n\treturn {\n\t\titems: [{ type: \"text\", text }, ...items.filter((item) => item.type === \"image\")],\n\t\t...(\"path\" in spilled ? { fullOutputPath: spilled.path } : {}),\n\t};\n}\n\n/**\n * The value a script receives for a nested call: a tool that declares\n * `outputSchema` resolves to its `structuredContent`, also for error results that carry one (such\n * as MCP results with `isError`); any other tool resolves to its text content. Other failures\n * reject with the tool's error text.\n */\nfunction toScriptValue(tool: AgentTool<any>, outcome: AgentToolCallOutcome): unknown {\n\tconst { result } = outcome;\n\tif (tool.outputSchema && result.structuredContent !== undefined) return result.structuredContent;\n\tconst text = textOf(result);\n\tif (outcome.isError) throw new Error(text || `Tool \"${tool.name}\" failed`);\n\treturn text;\n}\n\n/**\n * Run one script. Without a session context (a plain Agent or a direct call) scripts cannot call\n * tools, `store()` starts empty, and writes are dropped.\n */\nexport async function executeCodemode(\n\ttoolCallId: string,\n\tinput: CodemodeToolInput,\n\tsignal: AbortSignal | undefined,\n\tonUpdate: ((result: AgentToolResult<CodemodeToolDetails>) => void) | undefined,\n\tctx: ExtensionToolContext | undefined,\n\toptions: CodemodeToolOptions = {},\n): Promise<AgentToolResult<CodemodeToolDetails>> {\n\tconst startedAt = performance.now();\n\tconst { code, options: sourceOptions } = parseCodemodeSource(input.code);\n\tconst calls: CodemodeNestedCall[] = [];\n\t// Usage of the script's `models.*` calls. Nested tool calls report theirs through the session.\n\tlet modelUsage: Usage | undefined;\n\t// Images returned by `models.generateImages()`, to notice a script that never shows them.\n\tlet generatedImages = 0;\n\tconst addGeneratedImages = (count: number) => {\n\t\tgeneratedImages += count;\n\t};\n\tconst addModelUsage = (usage: Usage) => {\n\t\tmodelUsage = modelUsage ? combineUsage(modelUsage, usage) : usage;\n\t};\n\n\tconst snapshot = (): CodemodeToolDetails => ({ calls: calls.map((call) => ({ ...call })) });\n\tconst publish = () => onUpdate?.({ content: [], details: snapshot() });\n\t// Show the script as running before its first nested call, so the row's timer starts.\n\tpublish();\n\n\tconst callable = ctx ? getCodemodeCallableTools(ctx.tools) : [];\n\t// ALL_TOOLS entries carry the declaration.\n\tconst guidelines = options.getToolGuidelines?.();\n\tconst samples = new Map(\n\t\tcallable.map((tool) => [tool.name, renderToolSample(toCodemodeDeclaration(tool, guidelines?.get(tool.name)))]),\n\t);\n\tconst sandboxTools: CodemodeTool[] = callable.map((tool) => ({\n\t\tname: tool.name,\n\t\tdescription: samples.get(tool.name),\n\t\texecute: async (args, { signal: callSignal }) => {\n\t\t\tconst record: CodemodeNestedCall = {\n\t\t\t\tid: `${toolCallId}/?`,\n\t\t\t\tname: tool.name,\n\t\t\t\targs: previewArgs(args),\n\t\t\t\tstatus: \"running\",\n\t\t\t};\n\t\t\tcalls.push(record);\n\t\t\tpublish();\n\t\t\tconst callStartedAt = performance.now();\n\t\t\t// Only tools from ctx.tools are callable, so ctx is set here.\n\t\t\tif (!ctx) throw new Error(\"Tool calls need a session\");\n\t\t\tconst outcome = await ctx.executeTool(tool.name, args, { signal: callSignal });\n\t\t\trecord.id = outcome.toolCall.id;\n\t\t\trecord.durationMs = performance.now() - callStartedAt;\n\t\t\tif (outcome.isError) {\n\t\t\t\trecord.status = callSignal.aborted ? \"cancelled\" : \"error\";\n\t\t\t\trecord.error = truncateText(textOf(outcome.result) || `Tool \"${tool.name}\" failed`, ERROR_PREVIEW_CHARS);\n\t\t\t} else {\n\t\t\t\trecord.status = \"ok\";\n\t\t\t}\n\t\t\tpublish();\n\t\t\treturn toScriptValue(tool, outcome);\n\t\t},\n\t}));\n\n\t// The wait for a worker counts toward the script's deadline.\n\tconst deadline = sourceOptions.timeoutMs ?? Number.POSITIVE_INFINITY;\n\tconst waitStartedAt = performance.now();\n\tconst admission = await reserveCodemodeWorker(\n\t\tsignal,\n\t\tMath.min(deadline, CODEMODE_WORKER_WAIT_MS),\n\t\toptions.environment,\n\t);\n\tconst waitedMs = performance.now() - waitStartedAt;\n\tif (admission !== \"reserved\") {\n\t\tconst waited = ((performance.now() - startedAt) / 1000).toFixed(1);\n\t\tconst reason = signal?.reason;\n\t\tconst error =\n\t\t\tadmission === \"aborted\"\n\t\t\t\t? `Script aborted: ${reason instanceof Error ? reason.message : \"Execution aborted\"}`\n\t\t\t\t: deadline <= CODEMODE_WORKER_WAIT_MS\n\t\t\t\t\t? `Script timed out: Execution timed out after ${deadline} ms while waiting for a free codemode worker`\n\t\t\t\t\t: `No codemode worker became free within ${CODEMODE_WORKER_WAIT_MS / 1000} seconds. All ${maxCodemodeWorkers(options.environment)} workers, shared by every session in this process, are held by other scripts. Retry after they finish.`;\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{ type: \"text\", text: `Script failed\\nWall time ${waited} seconds\\nOutput:\\n` },\n\t\t\t\t{ type: \"text\", text: `Script error:\\n${error}\\n\\nThe script did not start.` },\n\t\t\t],\n\t\t\tdetails: snapshot(),\n\t\t\tisError: true,\n\t\t};\n\t}\n\t// The reservation covers the one worker this script starts. A launch that resumes after the result\n\t// settled finds it released and starts no worker.\n\tlet reserved = true;\n\n\tlet sandbox: CodemodeSandbox | undefined;\n\tlet result: CodemodeResult;\n\ttry {\n\t\tconst own = (tool: CodemodeTool): CodemodeTool =>\n\t\t\toptions.runHostCall\n\t\t\t\t? {\n\t\t\t\t\t\t...tool,\n\t\t\t\t\t\texecute: (args, context) => options.runHostCall!(() => tool.execute(args, context), tool.name),\n\t\t\t\t\t}\n\t\t\t\t: tool;\n\t\tsandbox = new CodemodeSandbox({\n\t\t\ttools: sandboxTools.map(own),\n\t\t\tglobals: [\n\t\t\t\t...createDiscoveryGlobals(callable, samples, options),\n\t\t\t\t...(options.models && ctx\n\t\t\t\t\t? createModelGlobals(ctx.modelRegistry, toolCallId, calls, publish, addModelUsage, addGeneratedImages)\n\t\t\t\t\t: []),\n\t\t\t].map(own),\n\t\t\tenvironment: options.environment,\n\t\t\tonWorkerStarted: options.onWorkerStarted,\n\t\t\ttimeoutMs: Math.max(1, Math.round(deadline - waitedMs)),\n\t\t\tmemoryLimitBytes: CODEMODE_MEMORY_LIMIT_BYTES,\n\t\t\twasm: loadQuickJSWasm(getQuickJSWasmPath()),\n\t\t\tworkerUrl: getCodemodeWorkerSpecifier(),\n\t\t\tacquireWorker: () => {\n\t\t\t\tif (!reserved) throw new Error(\"The script already settled\");\n\t\t\t\t// From here the sandbox releases the slot when the worker actually exits.\n\t\t\t\treserved = false;\n\t\t\t\treturn releaseCodemodeWorker;\n\t\t\t},\n\t\t});\n\t\tconst store = ctx ? readCodemodeStore(ctx.sessionManager.getBranch()) : {};\n\t\t// HUMAIN extension: a returned value is appended like text(), inside the VM's hard output limits.\n\t\tresult = await sandbox.execute(code, { signal, store, returnAsOutput: true });\n\t} finally {\n\t\tawait sandbox?.close();\n\t\tif (reserved) {\n\t\t\treserved = false;\n\t\t\treleaseCodemodeWorker();\n\t\t}\n\t}\n\t// Calls still marked running were cut off by the script ending, a timeout, or an abort.\n\tfor (const call of calls) {\n\t\tif (call.status === \"running\") call.status = \"cancelled\";\n\t}\n\n\tif (result.ok) {\n\t\tconst { set, delete: deleted } = result.storeWrites;\n\t\tif (Object.keys(set).length > 0 || deleted.length > 0) {\n\t\t\toptions.appendEntry?.(CODEMODE_STORE_ENTRY_TYPE, { set, delete: deleted });\n\t\t}\n\t}\n\tconst items = formatOutput(result.output);\n\tif (!result.ok) items.push({ type: \"text\", text: `Script error:\\n${formatError(result, calls)}` });\n\tif (generatedImages > 0 && !items.some((item) => item.type === \"image\")) {\n\t\titems.push({\n\t\t\ttype: \"text\",\n\t\t\ttext: `Note: models.generateImages() returned ${generatedImages} image${generatedImages === 1 ? \"\" : \"s\"} that the script did not show. Show each image block of result.output with image(block).`,\n\t\t});\n\t}\n\n\tconst truncated = await truncateOutput(\n\t\tjoinAdjacentText(items),\n\t\tsourceOptions.maxOutputTokens ?? DEFAULT_MAX_OUTPUT_TOKENS,\n\t);\n\t// After truncation, which joins the text items and moves images after them, so each path stays\n\t// next to its image and is never cut.\n\tconst output = joinAdjacentText(await saveImages(truncated.items));\n\tconst wallTime = ((performance.now() - startedAt) / 1000).toFixed(1);\n\tconst header = `${result.ok ? \"Script completed\" : \"Script failed\"}\\nWall time ${wallTime} seconds\\nOutput:\\n`;\n\tconst details = snapshot();\n\tif (truncated.fullOutputPath) details.fullOutputPath = truncated.fullOutputPath;\n\treturn {\n\t\tcontent: [{ type: \"text\", text: header }, ...output],\n\t\tdetails,\n\t\t...(modelUsage ? { usage: modelUsage } : {}),\n\t\t...(result.ok ? {} : { isError: true }),\n\t};\n}\n\n/**\n * Whether `query` names the namespace: its name or one of its aliases, as written or as the same\n * script identifier (`dev-radius` and `dev_radius` are both `dev_radius`).\n */\nfunction isNamespaceName(namespace: ToolNamespace, query: string): boolean {\n\tconst queryId = toCodemodeIdentifier(query);\n\treturn [namespace.name, ...(namespace.aliases ?? [])].some(\n\t\t(name) => name === query || toCodemodeIdentifier(name) === queryId,\n\t);\n}\n\n/**\n * `searchTools()`, `describeTool()`, and `describeNamespace()`: ranked search and lookup over the\n * script's nested tools and their namespaces.\n */\nfunction createDiscoveryGlobals(\n\ttools: readonly AgentTool<any>[],\n\tsamples: ReadonlyMap<string, string>,\n\toptions: CodemodeToolOptions,\n): CodemodeTool[] {\n\tconst ranker = new Bm25Ranker();\n\tconst entry = (name: string) => ({ name: toCodemodeIdentifier(name), description: samples.get(name) ?? \"\" });\n\treturn [\n\t\t{\n\t\t\tname: \"searchTools\",\n\t\t\tspread: true,\n\t\t\texecute: (args) => {\n\t\t\t\tconst [query, searchOptions] = args as [unknown, { limit?: unknown; namespace?: unknown } | undefined];\n\t\t\t\tif (typeof query !== \"string\") throw new Error(\"searchTools() expects a query string\");\n\t\t\t\tconst limit = searchOptions?.limit ?? DEFAULT_TOOL_SEARCH_LIMIT;\n\t\t\t\tif (typeof limit !== \"number\" || !Number.isInteger(limit) || limit <= 0) {\n\t\t\t\t\tthrow new Error(\"searchTools() limit must be a positive integer\");\n\t\t\t\t}\n\t\t\t\tconst namespace = searchOptions?.namespace;\n\t\t\t\tif (namespace !== undefined && namespace !== null && typeof namespace !== \"string\") {\n\t\t\t\t\tthrow new Error(\"searchTools() namespace must be a string\");\n\t\t\t\t}\n\t\t\t\tconst documents = tools.flatMap((tool) => {\n\t\t\t\t\tconst toolNamespace = options.getToolNamespace?.(tool.name);\n\t\t\t\t\tif (namespace && (!toolNamespace || !isNamespaceName(toolNamespace, namespace))) return [];\n\t\t\t\t\treturn [createToolSearchDocument(tool, toolNamespace)];\n\t\t\t\t});\n\t\t\t\treturn ranker.rank(query, documents, limit).map((match) => entry(match.name));\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"describeTool\",\n\t\t\tspread: true,\n\t\t\texecute: (args) => {\n\t\t\t\tconst [name] = args as unknown[];\n\t\t\t\tif (typeof name !== \"string\") throw new Error(\"describeTool() expects a tool name\");\n\t\t\t\tconst tool = tools.find(\n\t\t\t\t\t(candidate) => candidate.name === name || toCodemodeIdentifier(candidate.name) === name,\n\t\t\t\t);\n\t\t\t\treturn tool ? samples.get(tool.name) : undefined;\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"describeNamespace\",\n\t\t\tspread: true,\n\t\t\texecute: (args) => {\n\t\t\t\tconst [name] = args as unknown[];\n\t\t\t\tif (typeof name !== \"string\") throw new Error(\"describeNamespace() expects a namespace name\");\n\t\t\t\tlet namespace: ToolNamespace | undefined;\n\t\t\t\tconst names: string[] = [];\n\t\t\t\tfor (const tool of tools) {\n\t\t\t\t\tconst toolNamespace = options.getToolNamespace?.(tool.name);\n\t\t\t\t\tif (!toolNamespace || !isNamespaceName(toolNamespace, name)) continue;\n\t\t\t\t\tnamespace ??= toolNamespace;\n\t\t\t\t\tnames.push(toCodemodeIdentifier(tool.name));\n\t\t\t\t}\n\t\t\t\tif (!namespace) return undefined;\n\t\t\t\treturn {\n\t\t\t\t\tname: namespace.name,\n\t\t\t\t\t...(namespace.description ? { description: namespace.description } : {}),\n\t\t\t\t\t...(namespace.instructions ? { instructions: namespace.instructions } : {}),\n\t\t\t\t\ttools: names,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t];\n}\n\n/**\n * `models.*` for scripts: the model registry methods documented in docs/codemode.md.\n * Classifier and image calls appear as nested call rows so the renderer shows them, and their usage\n * goes to `addUsage`. Rows show only the model, never prompts or image data.\n */\nfunction createModelGlobals(\n\tmodels: CodemodeModelRuntime,\n\ttoolCallId: string,\n\tcalls: CodemodeNestedCall[],\n\tpublish: () => void,\n\taddUsage: (usage: Usage) => void,\n\taddGeneratedImages: (count: number) => void,\n): CodemodeTool[] {\n\tconst limit = createLimiter(MAX_CONCURRENT_MODEL_CALLS);\n\tlet callCount = 0;\n\n\t/**\n\t * Resolve the script's model by provider and id only, check the context, then run the call as a\n\t * nested call row. A script-supplied baseUrl or headers must never receive the credentials.\n\t */\n\tconst runModelCall = async <TType extends \"classifier\" | \"image\", TContext, TResult extends ModelCallResult>(\n\t\tname: string,\n\t\ttype: TType,\n\t\t[model, context]: unknown[],\n\t\tcheckContext: (context: unknown) => TContext,\n\t\trun: (resolved: ModelTypeMap[TType], context: TContext) => Promise<TResult>,\n\t): Promise<TResult> => {\n\t\tconst listHint = `List the ${type} models you can use with models.getAvailableOfType(\"${type}\").`;\n\t\tconst given = model as ScriptValue;\n\t\tif (typeof given?.provider !== \"string\" || typeof given.id !== \"string\") {\n\t\t\t// undefined arrives as null: spread arguments cross the sandbox as a JSON array.\n\t\t\tconst undefinedHint =\n\t\t\t\tmodel === undefined || model === null\n\t\t\t\t\t? \" models.getModelOfType() returns undefined for an unknown provider or id.\"\n\t\t\t\t\t: \"\";\n\t\t\tthrow new Error(\n\t\t\t\t`${name}() expects ${withArticle(type)} model as its first argument, got ${describeValue(model)}.${undefinedHint} ${listHint}`,\n\t\t\t);\n\t\t}\n\t\tconst provider = given.provider;\n\t\tconst id = given.id;\n\t\tconst ref = `${provider}/${id}`;\n\t\tconst resolved = models.getModelOfType(type, provider, id);\n\t\tif (!resolved) {\n\t\t\tconst actualType = [...MODEL_TYPES].find(\n\t\t\t\t(other) => other !== type && models.getModelOfType(other as ModelType, provider, id) !== undefined,\n\t\t\t);\n\t\t\tthrow new Error(\n\t\t\t\tactualType\n\t\t\t\t\t? `\"${ref}\" is ${withArticle(actualType)} model, not ${withArticle(type)} model. ${listHint}`\n\t\t\t\t\t: `Unknown ${type} model \"${ref}\". ${listHint}`,\n\t\t\t);\n\t\t}\n\t\tconst checked = checkContext(context);\n\n\t\tconst record: CodemodeNestedCall = {\n\t\t\tid: `${toolCallId}/${name}/${++callCount}`,\n\t\t\tname,\n\t\t\targs: `${resolved.provider}/${resolved.id}`,\n\t\t\tstatus: \"running\",\n\t\t};\n\t\tcalls.push(record);\n\t\tpublish();\n\t\tconst startedAt = performance.now();\n\t\tconst result = await limit(() => run(resolved, checked));\n\t\trecord.durationMs = performance.now() - startedAt;\n\t\trecord.status = result.stopReason === \"stop\" ? \"ok\" : result.stopReason === \"aborted\" ? \"cancelled\" : \"error\";\n\t\tif (result.errorMessage) record.error = truncateText(result.errorMessage, ERROR_PREVIEW_CHARS);\n\t\tif (result.usage) {\n\t\t\trecord.cost = result.usage.cost.total;\n\t\t\taddUsage(result.usage);\n\t\t}\n\t\tpublish();\n\t\treturn result;\n\t};\n\tconst implementations: Record<string, CodemodeTool[\"execute\"]> = {\n\t\t\"models.getModelsOfType\": (args) => {\n\t\t\tconst [type, provider] = args as unknown[];\n\t\t\treturn models.getModelsOfType(toModelType(type), toProvider(provider)).map(toModelInfo);\n\t\t},\n\t\t\"models.getAvailableOfType\": async (args, { signal }) => {\n\t\t\tconst [type, provider] = args as unknown[];\n\t\t\tconst available = await models.getAvailableOfType(toModelType(type), toProvider(provider), { signal });\n\t\t\treturn available.map(toModelInfo);\n\t\t},\n\t\t\"models.getModelOfType\": (args) => {\n\t\t\tconst [type, provider, id] = args as unknown[];\n\t\t\tif (typeof provider !== \"string\" || typeof id !== \"string\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`models.getModelOfType(type, provider, id) expects three strings, got (${(args as unknown[]).map(describeValue).join(\", \")}). The provider and the id are separate arguments, for example models.getModelOfType(\"classifier\", \"typesafe\", \"jev-latest\").`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst model = models.getModelOfType(toModelType(type), provider, id);\n\t\t\treturn model === undefined ? undefined : toModelInfo(model);\n\t\t},\n\t\t\"models.classify\": (args, { signal }) =>\n\t\t\trunModelCall(\"models.classify\", \"classifier\", args as unknown[], checkClassifierContext, (resolved, context) =>\n\t\t\t\tmodels.classify(resolved, context, { signal }),\n\t\t\t),\n\t\t\"models.generateImages\": (args, { signal }) =>\n\t\t\trunModelCall(\n\t\t\t\t\"models.generateImages\",\n\t\t\t\t\"image\",\n\t\t\t\targs as unknown[],\n\t\t\t\tcheckImagesContext,\n\t\t\t\tasync (resolved, context) => {\n\t\t\t\t\tconst result = await models.generateImages(resolved, context, { signal });\n\t\t\t\t\taddGeneratedImages(result.output.filter((block) => block.type === \"image\").length);\n\t\t\t\t\treturn result;\n\t\t\t\t},\n\t\t\t),\n\t};\n\treturn Object.entries(implementations).map(([name, execute]) => ({ name, spread: true, execute }));\n}\n"]}
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/extensions/codemode/execute.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,EAGN,eAAe,EAEf,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAEr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ACf,CAAC,CACD;KACF,CAAC;IACF,OAAO,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AACpG,CAAC","sourcesContent":["/**\n * Runs one codemode script in the sandbox. Split from tool.ts and loaded through\n * execute.lazy.ts so the sandbox runtime only loads when a script runs.\n */\n\nimport type { AgentTool, AgentToolCallOutcome, AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport type {\n\tAnyModel,\n\tClassifierContext,\n\tImageContent,\n\tImagesContext,\n\tModelType,\n\tModelTypeMap,\n\tTextContent,\n\tUsage,\n} from \"@earendil-works/pi-ai\";\nimport {\n\ttype CodemodeOutputItem,\n\ttype CodemodeResult,\n\tCodemodeSandbox,\n\ttype CodemodeTool,\n\tloadQuickJSWasm,\n\tparseCodemodeSource,\n\trenderToolSample,\n\ttoCodemodeIdentifier,\n} from \"@earendil-works/pi-codemode\";\nimport { getCodemodeWorkerSpecifier, getQuickJSWasmPath } from \"../../config.ts\";\nimport type { ExtensionToolContext, ToolNamespace } from \"../../core/extensions/types.ts\";\nimport { NESTED_CALL_LIMITS } from \"../../core/nested-tool-calls.ts\";\nimport type { SessionEntry } from \"../../core/session-manager.ts\";\nimport { formatSize, sliceHead, sliceTail } from \"../../core/tools/truncate.ts\";\nimport { combineUsage } from \"../../core/usage-totals.ts\";\nimport { writeOutputFile } from \"../../utils/output-files.ts\";\nimport { Bm25Ranker, createToolSearchDocument, DEFAULT_TOOL_SEARCH_LIMIT } from \"../tool-search/tool.ts\";\nimport {\n\tCODEMODE_DOCS_PATH,\n\tCODEMODE_STORE_ENTRY_TYPE,\n\ttype CodemodeModelRuntime,\n\ttype CodemodeNestedCall,\n\ttype CodemodeStoreEntryData,\n\ttype CodemodeToolDetails,\n\ttype CodemodeToolInput,\n\ttype CodemodeToolOptions,\n\tgetCodemodeCallableTools,\n\ttoCodemodeDeclaration,\n} from \"./tool.ts\";\n\nconst ARGS_PREVIEW_CHARS = 200;\nconst ERROR_PREVIEW_CHARS = 500;\n/** `models.classify()` and `models.generateImages()` calls one script may have in flight; `Promise.all` over many items queues the rest. */\nconst MAX_CONCURRENT_MODEL_CALLS = 4;\n/**\n * Heap limit for the QuickJS VM. The worker shares the HUMAIN Code CLI process, so without a limit a runaway\n * script can grow to wasm32's 4 GiB and take the session down. Overruns end the script with\n * `InternalError: out of memory`, which the script cannot catch.\n */\nconst CODEMODE_MEMORY_LIMIT_BYTES = 256 * 1024 * 1024;\n// Shared across calls and sessions. Allow one replacement while a cancelled worker is still exiting.\nconst DEFAULT_MAX_CODEMODE_WORKERS = 2;\n\n/**\n * `HUMAIN_TERMINAL_CODEMODE_MAX_WORKERS` (or upstream's `PI_CODEMODE_MAX_WORKERS`) if it is a positive integer.\n * Read per call so SDK hosts can set it at runtime.\n */\nfunction maxCodemodeWorkers(environment: NodeJS.ProcessEnv = process.env): number {\n\tconst value = Number(environment.HUMAIN_TERMINAL_CODEMODE_MAX_WORKERS || environment.PI_CODEMODE_MAX_WORKERS);\n\treturn Number.isInteger(value) && value > 0 ? value : DEFAULT_MAX_CODEMODE_WORKERS;\n}\n/**\n * How long a script waits for a free worker before failing. Bounds the wait when every worker is\n * held by a script that waits on another script, for example an in-process subagent that uses codemode.\n */\nconst CODEMODE_WORKER_WAIT_MS = 60_000;\nlet activeCodemodeWorkers = 0;\n/** Scripts waiting for a worker, in arrival order. */\nconst codemodeWorkerWaiters: { grant(): void; environment?: NodeJS.ProcessEnv }[] = [];\n\n/**\n * Reserve one worker slot, waiting in arrival order while all are taken. Resolves with why it could\n * not reserve one: the signal aborted, or `timeoutMs` passed.\n */\nfunction reserveCodemodeWorker(\n\tsignal: AbortSignal | undefined,\n\ttimeoutMs: number,\n\tenvironment?: NodeJS.ProcessEnv,\n): Promise<\"reserved\" | \"aborted\" | \"timeout\"> {\n\tif (signal?.aborted) return Promise.resolve(\"aborted\");\n\treturn new Promise((resolve) => {\n\t\tconst settle = (outcome: \"reserved\" | \"aborted\" | \"timeout\") => {\n\t\t\tclearTimeout(timer);\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tconst index = codemodeWorkerWaiters.findIndex((waiter) => waiter.grant === grant);\n\t\t\tif (index >= 0) codemodeWorkerWaiters.splice(index, 1);\n\t\t\tresolve(outcome);\n\t\t};\n\t\tconst grant = () => settle(\"reserved\");\n\t\tconst onAbort = () => settle(\"aborted\");\n\t\tconst timer = setTimeout(() => settle(\"timeout\"), timeoutMs);\n\t\tcodemodeWorkerWaiters.push({ grant, environment });\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\tadmitCodemodeWorkers();\n\t});\n}\n\n/** Give free slots to waiting scripts in arrival order. */\nfunction admitCodemodeWorkers(): void {\n\twhile (\n\t\tcodemodeWorkerWaiters.length > 0 &&\n\t\tactiveCodemodeWorkers < maxCodemodeWorkers(codemodeWorkerWaiters[0].environment)\n\t) {\n\t\tactiveCodemodeWorkers++;\n\t\tcodemodeWorkerWaiters.shift()?.grant();\n\t}\n}\n\nfunction releaseCodemodeWorker(): void {\n\tactiveCodemodeWorkers--;\n\tadmitCodemodeWorkers();\n}\nconst MODEL_TYPES: ReadonlySet<string> = new Set<ModelType>([\"chat\", \"image\", \"classifier\"]);\n\nfunction truncateText(text: string, maxChars: number): string {\n\treturn text.length > maxChars ? `${sliceHead(text, maxChars - 3)}...` : text;\n}\n\nfunction previewArgs(args: unknown): string {\n\tif (args === undefined) return \"\";\n\ttry {\n\t\treturn truncateText(JSON.stringify(args) ?? \"\", ARGS_PREVIEW_CHARS);\n\t} catch {\n\t\treturn \"\";\n\t}\n}\n\nfunction textOf(result: AgentToolResult<unknown>): string {\n\treturn (result.content ?? [])\n\t\t.filter((block): block is TextContent => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.join(\"\\n\");\n}\n\nfunction toModelType(value: unknown): ModelType {\n\tif (typeof value === \"string\" && MODEL_TYPES.has(value)) return value as ModelType;\n\tthrow new Error(`Unknown model type ${JSON.stringify(value)}. Use \"chat\", \"image\", or \"classifier\".`);\n}\n\nfunction toProvider(value: unknown): string | undefined {\n\tif (value === undefined || value === null) return undefined;\n\tif (typeof value !== \"string\") throw new Error(\"provider must be a string\");\n\treturn value;\n}\n\n/** Catalog entry for scripts. `headers` is dropped because models.json headers can carry credentials. */\nfunction toModelInfo(model: AnyModel): Record<string, unknown> {\n\tconst info: Record<string, unknown> = { ...model };\n\tdelete info.headers;\n\treturn info;\n}\n\n/** `an image`, `a classifier`. */\nfunction withArticle(word: string): string {\n\treturn `${/^[aeiou]/.test(word) ? \"an\" : \"a\"} ${word}`;\n}\n\n/** A JSON value from a script, read field by field: values that are not objects have no fields. */\ntype ScriptValue = { readonly [key: string]: unknown } | null | undefined;\n\n/** A script value in an error message: `undefined`, `a string`, `an array`, or its keys (`{ prompt }`). */\nfunction describeValue(value: unknown): string {\n\tif (value === undefined || value === null) return String(value);\n\tif (Array.isArray(value)) return value.length === 0 ? \"an empty array\" : \"an array\";\n\tif (typeof value === \"object\") {\n\t\tconst keys = Object.keys(value);\n\t\tif (keys.length === 0) return \"{}\";\n\t\treturn `{ ${keys.slice(0, 6).join(\", \")}${keys.length > 6 ? \", ...\" : \"\"} }`;\n\t}\n\treturn typeof value === \"string\" ? \"a string\" : `a ${typeof value}`;\n}\n\nconst CLASSIFIER_CONTEXT_SHAPE =\n\t'{ state: { ... }, images?: [{ type: \"image\", data: <base64>, mimeType }], questions: { <id>: { type: \"choice\", instructions, criteria: { <label>: <meaning> } } | { type: \"score\", instructions, criteria: [<lowest level>, ..., <highest level>] } | { type: \"bool\", instructions, criteria: { true: <meaning>, false: <meaning> } } } }';\n\n/** Check a script's classifier context, so mistakes fail with the expected shape instead of a provider error. */\nfunction checkClassifierContext(context: unknown): ClassifierContext {\n\tconst fail = (problem: string) =>\n\t\tnew Error(\n\t\t\t`models.classify() ${problem}. Expected context: ${CLASSIFIER_CONTEXT_SHAPE}. See \"Classify\" in ${CODEMODE_DOCS_PATH}.`,\n\t\t);\n\tif (typeof context !== \"object\" || context === null || Array.isArray(context)) {\n\t\tthrow fail(`expects a context object as its second argument, got ${describeValue(context)}`);\n\t}\n\tconst { state, images, questions } = context as Record<string, unknown>;\n\tif (typeof state !== \"object\" || state === null || Array.isArray(state)) {\n\t\tthrow fail(`context.state must be an object, got ${describeValue(state)}`);\n\t}\n\tif (images !== undefined) {\n\t\tif (!Array.isArray(images)) throw fail(`context.images must be an array, got ${describeValue(images)}`);\n\t\timages.forEach((image: ScriptValue, index) => {\n\t\t\tif (image?.type !== \"image\" || typeof image.data !== \"string\" || typeof image.mimeType !== \"string\") {\n\t\t\t\tthrow fail(`context.images[${index}] must be an image block, got ${describeValue(image)}`);\n\t\t\t}\n\t\t});\n\t}\n\tif (\n\t\ttypeof questions !== \"object\" ||\n\t\tquestions === null ||\n\t\tArray.isArray(questions) ||\n\t\tObject.keys(questions).length === 0\n\t) {\n\t\tthrow fail(`context.questions must map question IDs to questions, got ${describeValue(questions)}`);\n\t}\n\tconst isStrings = (values: unknown[]) => values.length > 0 && values.every((value) => typeof value === \"string\");\n\tfor (const [id, question] of Object.entries(questions)) {\n\t\tconst at = `context.questions.${id}`;\n\t\tif (typeof question !== \"object\" || question === null || Array.isArray(question)) {\n\t\t\tthrow fail(`${at} must be a question object, got ${describeValue(question)}`);\n\t\t}\n\t\tconst { type, instructions, criteria } = question as Record<string, unknown>;\n\t\tif (typeof instructions !== \"string\") throw fail(`${at}.instructions must be a string`);\n\t\tif (type === \"choice\") {\n\t\t\tif (\n\t\t\t\ttypeof criteria !== \"object\" ||\n\t\t\t\tcriteria === null ||\n\t\t\t\tArray.isArray(criteria) ||\n\t\t\t\t!isStrings(Object.values(criteria))\n\t\t\t) {\n\t\t\t\tthrow fail(`${at} is a \"choice\" question, so criteria must map each label to its meaning`);\n\t\t\t}\n\t\t} else if (type === \"score\") {\n\t\t\tif (!Array.isArray(criteria) || !isStrings(criteria)) {\n\t\t\t\tthrow fail(`${at} is a \"score\" question, so criteria must list the levels as strings, lowest first`);\n\t\t\t}\n\t\t} else if (type === \"bool\") {\n\t\t\tconst labels = criteria as ScriptValue;\n\t\t\tif (typeof labels?.true !== \"string\" || typeof labels.false !== \"string\") {\n\t\t\t\tthrow fail(`${at} is a \"bool\" question, so criteria must be { true: string, false: string }`);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow fail(`${at}.type must be \"choice\", \"score\", or \"bool\", got ${JSON.stringify(type)}`);\n\t\t}\n\t}\n\treturn context as unknown as ClassifierContext;\n}\n\n/** Check a script's image context, so mistakes such as `{ prompt }` fail with the expected shape. */\nfunction checkImagesContext(context: unknown): ImagesContext {\n\tconst fail = (problem: string) =>\n\t\tnew Error(\n\t\t\t`models.generateImages() ${problem}. Expected context: { input: [{ type: \"text\", text: <prompt> }, ...optional { type: \"image\", data: <base64>, mimeType } references] }. See \"Generate images\" in ${CODEMODE_DOCS_PATH}.`,\n\t\t);\n\tif (typeof context !== \"object\" || context === null || Array.isArray(context)) {\n\t\tthrow fail(`expects a context object as its second argument, got ${describeValue(context)}`);\n\t}\n\tconst { input } = context as Record<string, unknown>;\n\tif (!Array.isArray(input) || input.length === 0) {\n\t\tthrow fail(`context.input must be a non-empty array of blocks, got ${describeValue(input)}`);\n\t}\n\tinput.forEach((block: ScriptValue, index) => {\n\t\tif (block?.type === \"text\" && typeof block.text === \"string\") return;\n\t\tif (block?.type === \"image\" && typeof block.data === \"string\" && typeof block.mimeType === \"string\") return;\n\t\tthrow fail(`context.input[${index}] must be a text or image block, got ${describeValue(block)}`);\n\t});\n\treturn context as unknown as ImagesContext;\n}\n\n/** The fields of `ClassifierResult` and `AssistantImages` that a nested call row reports. */\ninterface ModelCallResult {\n\tstopReason: \"stop\" | \"error\" | \"aborted\";\n\terrorMessage?: string;\n\tusage?: Usage;\n}\n\n/** Runs at most `limit` calls at once, in call order. */\nfunction createLimiter(limit: number): <T>(run: () => Promise<T>) => Promise<T> {\n\tlet active = 0;\n\tconst waiting: (() => void)[] = [];\n\treturn async (run) => {\n\t\tif (active >= limit) await new Promise<void>((resolve) => waiting.push(resolve));\n\t\tactive++;\n\t\ttry {\n\t\t\treturn await run();\n\t\t} finally {\n\t\t\tactive--;\n\t\t\twaiting.shift()?.();\n\t\t}\n\t};\n}\n\nfunction isStoreEntryData(data: unknown): data is CodemodeStoreEntryData {\n\tif (typeof data !== \"object\" || data === null) return false;\n\tconst { set, delete: deleted } = data as Partial<CodemodeStoreEntryData>;\n\treturn (\n\t\ttypeof set === \"object\" &&\n\t\tset !== null &&\n\t\tArray.isArray(deleted) &&\n\t\tdeleted.every((key: unknown) => typeof key === \"string\")\n\t);\n}\n\n/** Values of `load()`: the `codemode-store` entries on the branch, applied from the root. */\nexport function readCodemodeStore(branch: readonly SessionEntry[]): Record<string, unknown> {\n\tconst store = new Map<string, unknown>();\n\tfor (const entry of branch) {\n\t\tif (entry.type !== \"custom\" || entry.customType !== CODEMODE_STORE_ENTRY_TYPE || !isStoreEntryData(entry.data)) {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const key of entry.data.delete) store.delete(key);\n\t\tfor (const [key, value] of Object.entries(entry.data.set)) store.set(key, value);\n\t}\n\treturn Object.fromEntries(store);\n}\n\n/** Default token budget for script output. */\nconst DEFAULT_MAX_OUTPUT_TOKENS = 10_000;\n/** Characters per token when estimating. */\nconst CHARS_PER_TOKEN = 4;\n\n/**\n * Lay out the script's output so the model can tell items apart: providers join adjacent text\n * blocks with a newline or with nothing. With more than one text item (`text()` or the returned\n * value), each starts with a `==> text N/M <==` line. `console.*` lines follow all other output in\n * one `<console_output>` block.\n */\nfunction formatOutput(output: readonly CodemodeOutputItem[]): (TextContent | ImageContent)[] {\n\tconst total = output.filter((item) => item.type === \"text\" && !item.console).length;\n\tconst items: (TextContent | ImageContent)[] = [];\n\tconst consoleLines: string[] = [];\n\tlet index = 0;\n\tfor (const item of output) {\n\t\tif (item.type === \"image\") {\n\t\t\titems.push(item);\n\t\t} else if (item.console) {\n\t\t\tconsoleLines.push(item.text);\n\t\t} else {\n\t\t\tindex++;\n\t\t\titems.push({ type: \"text\", text: total > 1 ? `==> text ${index}/${total} <==\\n${item.text}` : item.text });\n\t\t}\n\t}\n\tif (consoleLines.length > 0) {\n\t\titems.push({ type: \"text\", text: `<console_output>\\n${consoleLines.join(\"\\n\")}\\n</console_output>` });\n\t}\n\treturn items;\n}\n\n/**\n * Join adjacent text items into one, each part starting on its own line. The separator check looks\n * at the last non-empty part, not the joined text: reading the end of a growing concatenation makes\n * V8 copy it on every item, which is quadratic (#10678).\n */\nfunction joinAdjacentText(items: (TextContent | ImageContent)[]): (TextContent | ImageContent)[] {\n\tconst joined: (TextContent | ImageContent)[] = [];\n\tlet parts: string[] = [];\n\tlet lastPart = \"\";\n\tconst flush = () => {\n\t\tif (parts.length > 0) joined.push({ type: \"text\", text: parts.join(\"\") });\n\t\tparts = [];\n\t\tlastPart = \"\";\n\t};\n\tfor (const item of items) {\n\t\tif (item.type !== \"text\") {\n\t\t\tflush();\n\t\t\tjoined.push(item);\n\t\t\tcontinue;\n\t\t}\n\t\tif (lastPart !== \"\" && !lastPart.endsWith(\"\\n\")) {\n\t\t\tparts.push(\"\\n\");\n\t\t\tlastPart = \"\\n\";\n\t\t}\n\t\tparts.push(item.text);\n\t\tif (item.text !== \"\") lastPart = item.text;\n\t}\n\tflush();\n\treturn joined;\n}\n\nfunction formatCallSummary({ calls, omittedCalls }: CodemodeToolDetails): string {\n\tif (calls.length === 0) return \"No tool calls were made.\";\n\tconst omitted = omittedCalls ? `, and ${omittedCalls} later calls not listed` : \"\";\n\treturn `Tool calls made before the failure (they are not undone): ${calls.map((call) => `${call.name} (${call.status})`).join(\", \")}${omitted}`;\n}\n\nfunction formatError(result: Extract<CodemodeResult, { ok: false }>, details: CodemodeToolDetails): string {\n\tconst { error } = result;\n\tconst head =\n\t\terror.kind === \"script\"\n\t\t\t? (error.stack ?? `${error.name ?? \"Error\"}: ${error.message}`)\n\t\t\t: error.kind === \"timeout\"\n\t\t\t\t? `Script timed out: ${error.message}`\n\t\t\t\t: error.kind === \"aborted\"\n\t\t\t\t\t? `Script aborted: ${error.message}`\n\t\t\t\t\t: `Script sandbox failed: ${error.message}`;\n\treturn `${head}\\n\\n${formatCallSummary(details)}`;\n}\n\n/** Write the full text output to a temp file, like bash does for truncated output. */\nasync function spillOutput(text: string): Promise<{ path: string } | { error: string }> {\n\ttry {\n\t\treturn { path: await writeOutputFile(\"pi-codemode\", \".txt\", text) };\n\t} catch (error) {\n\t\treturn { error: error instanceof Error ? error.message : String(error) };\n\t}\n}\n\n/** File extensions of the image types `image()` accepts. Must list every type the sandbox's `image()` detects. */\nconst IMAGE_EXTENSIONS: Record<string, string> = {\n\t\"image/png\": \".png\",\n\t\"image/jpeg\": \".jpg\",\n\t\"image/gif\": \".gif\",\n\t\"image/webp\": \".webp\",\n};\n\n/**\n * Save each image to a temp file and put a text item with its path before it. The model sees the\n * image but has no other way to reach its bytes: scripts cannot write files, and `write` only takes\n * text. Images shown more than once are saved once.\n */\nasync function saveImages(items: (TextContent | ImageContent)[]): Promise<(TextContent | ImageContent)[]> {\n\tconst labels = new Map<string, Promise<string>>();\n\tconst label = async ({ data, mimeType }: ImageContent): Promise<string> => {\n\t\tconst bytes = Buffer.from(data, \"base64\");\n\t\tconst kind = `${mimeType}, ${formatSize(bytes.length)}`;\n\t\tconst extension = IMAGE_EXTENSIONS[mimeType];\n\t\tif (!extension) throw new Error(`No file extension for image type ${mimeType}`);\n\t\t// A failed write (disk full, unwritable temp dir) must not discard the result of a script whose\n\t\t// tool calls already ran, so it becomes part of the label.\n\t\ttry {\n\t\t\tconst path = await writeOutputFile(\"pi-codemode\", extension, bytes);\n\t\t\treturn `[Image saved to ${path} (${kind})]`;\n\t\t} catch (error) {\n\t\t\treturn `[Image (${kind}) could not be saved: ${error instanceof Error ? error.message : String(error)}]`;\n\t\t}\n\t};\n\tconst result = await Promise.all(\n\t\titems.map(async (item): Promise<(TextContent | ImageContent)[]> => {\n\t\t\tif (item.type !== \"image\") return [item];\n\t\t\tlet pending = labels.get(item.data);\n\t\t\tif (!pending) {\n\t\t\t\tpending = label(item);\n\t\t\t\tlabels.set(item.data, pending);\n\t\t\t}\n\t\t\treturn [{ type: \"text\", text: await pending }, item];\n\t\t}),\n\t);\n\treturn result.flat();\n}\n\n/**\n * Apply the token budget: when the combined text exceeds it, the text items become one\n * item that keeps the start and end of the text, and images follow it. The full text is written to\n * a temp file.\n */\nasync function truncateOutput(\n\titems: (TextContent | ImageContent)[],\n\tmaxTokens: number,\n): Promise<{ items: (TextContent | ImageContent)[]; fullOutputPath?: string }> {\n\tconst texts = items.filter((item): item is TextContent => item.type === \"text\").map((item) => item.text);\n\tconst combined = texts.join(\"\\n\");\n\tconst budget = maxTokens * CHARS_PER_TOKEN;\n\tif (texts.length === 0 || combined.length <= budget) return { items };\n\tconst headChars = Math.floor(budget / 2);\n\tconst tailChars = budget - headChars;\n\tconst removed = combined.length - headChars - tailChars;\n\tconst head = sliceHead(combined, headChars);\n\tconst tail = sliceTail(combined, tailChars);\n\tlet text = `Warning: truncated output (original token count: ${Math.ceil(combined.length / CHARS_PER_TOKEN)})\\nTotal output lines: ${combined.split(\"\\n\").length}\\n\\n${head}…${Math.ceil(removed / CHARS_PER_TOKEN)} tokens truncated…${tail}`;\n\tconst spilled = await spillOutput(combined);\n\ttext +=\n\t\t\"path\" in spilled\n\t\t\t? `\\n\\n[Full output: ${spilled.path} (read with offset/limit)]`\n\t\t\t: `\\n\\n[Could not save the full output: ${spilled.error}]`;\n\treturn {\n\t\titems: [{ type: \"text\", text }, ...items.filter((item) => item.type === \"image\")],\n\t\t...(\"path\" in spilled ? { fullOutputPath: spilled.path } : {}),\n\t};\n}\n\n/**\n * The value a script receives for a nested call: a tool that declares\n * `outputSchema` resolves to its `structuredContent`, also for error results that carry one (such\n * as MCP results with `isError`); any other tool resolves to its text content. Other failures\n * reject with the tool's error text.\n */\nfunction toScriptValue(tool: AgentTool<any>, outcome: AgentToolCallOutcome): unknown {\n\tconst { result } = outcome;\n\tif (tool.outputSchema && result.structuredContent !== undefined) return result.structuredContent;\n\tconst text = textOf(result);\n\tif (outcome.isError) throw new Error(text || `Tool \"${tool.name}\" failed`);\n\treturn text;\n}\n\n/**\n * The nested call rows of one script, published through `onUpdate` as they change. Each update\n * copies every row, so a script that loops over calls would cost quadratic time and memory (in RPC\n * mode, every update is queued as a JSON line). Like the session's nested-call record, it lists at\n * most `NESTED_CALL_LIMITS.maxCalls` rows; later calls are only counted, with their cost.\n */\nclass CodemodeCallLog {\n\treadonly calls: CodemodeNestedCall[] = [];\n\tprivate omittedCalls = 0;\n\tprivate omittedCost = 0;\n\tprivate readonly onUpdate: ((result: AgentToolResult<CodemodeToolDetails>) => void) | undefined;\n\n\tconstructor(onUpdate: ((result: AgentToolResult<CodemodeToolDetails>) => void) | undefined) {\n\t\tthis.onUpdate = onUpdate;\n\t}\n\n\t/** Add the row of a starting call, or count the call once the list is full. */\n\tstart(record: CodemodeNestedCall): void {\n\t\tif (this.calls.length >= NESTED_CALL_LIMITS.maxCalls) {\n\t\t\tthis.omittedCalls++;\n\t\t\t// One update marks the list incomplete; omitted calls publish nothing else.\n\t\t\tif (this.omittedCalls === 1) this.publish();\n\t\t\treturn;\n\t\t}\n\t\tthis.calls.push(record);\n\t\tthis.publish();\n\t}\n\n\t/** Publish the finished row, or add the cost of an omitted call. */\n\tfinish(record: CodemodeNestedCall): void {\n\t\tif (!this.calls.includes(record)) {\n\t\t\tthis.omittedCost += record.cost ?? 0;\n\t\t\treturn;\n\t\t}\n\t\tthis.publish();\n\t}\n\n\tsnapshot(): CodemodeToolDetails {\n\t\tconst details: CodemodeToolDetails = { calls: this.calls.map((call) => ({ ...call })) };\n\t\tif (this.omittedCalls > 0) {\n\t\t\tdetails.omittedCalls = this.omittedCalls;\n\t\t\tdetails.omittedCost = this.omittedCost;\n\t\t}\n\t\treturn details;\n\t}\n\n\tpublish(): void {\n\t\tthis.onUpdate?.({ content: [], details: this.snapshot() });\n\t}\n}\n\n/**\n * Run one script. Without a session context (a plain Agent or a direct call) scripts cannot call\n * tools, `store()` starts empty, and writes are dropped.\n */\nexport async function executeCodemode(\n\ttoolCallId: string,\n\tinput: CodemodeToolInput,\n\tsignal: AbortSignal | undefined,\n\tonUpdate: ((result: AgentToolResult<CodemodeToolDetails>) => void) | undefined,\n\tctx: ExtensionToolContext | undefined,\n\toptions: CodemodeToolOptions = {},\n): Promise<AgentToolResult<CodemodeToolDetails>> {\n\tconst startedAt = performance.now();\n\tconst { code, options: sourceOptions } = parseCodemodeSource(input.code);\n\tconst log = new CodemodeCallLog(onUpdate);\n\t// Usage of the script's `models.*` calls. Nested tool calls report theirs through the session.\n\tlet modelUsage: Usage | undefined;\n\t// Images returned by `models.generateImages()`, to notice a script that never shows them.\n\tlet generatedImages = 0;\n\tconst addGeneratedImages = (count: number) => {\n\t\tgeneratedImages += count;\n\t};\n\tconst addModelUsage = (usage: Usage) => {\n\t\tmodelUsage = modelUsage ? combineUsage(modelUsage, usage) : usage;\n\t};\n\n\t// Show the script as running before its first nested call, so the row's timer starts.\n\tlog.publish();\n\n\tconst callable = ctx ? getCodemodeCallableTools(ctx.tools) : [];\n\t// ALL_TOOLS entries carry the declaration.\n\tconst guidelines = options.getToolGuidelines?.();\n\tconst samples = new Map(\n\t\tcallable.map((tool) => [tool.name, renderToolSample(toCodemodeDeclaration(tool, guidelines?.get(tool.name)))]),\n\t);\n\tconst sandboxTools: CodemodeTool[] = callable.map((tool) => ({\n\t\tname: tool.name,\n\t\tdescription: samples.get(tool.name),\n\t\texecute: async (args, { signal: callSignal }) => {\n\t\t\tconst record: CodemodeNestedCall = {\n\t\t\t\tid: `${toolCallId}/?`,\n\t\t\t\tname: tool.name,\n\t\t\t\targs: previewArgs(args),\n\t\t\t\tstatus: \"running\",\n\t\t\t};\n\t\t\tlog.start(record);\n\t\t\tconst callStartedAt = performance.now();\n\t\t\t// Only tools from ctx.tools are callable, so ctx is set here.\n\t\t\tif (!ctx) throw new Error(\"Tool calls need a session\");\n\t\t\tconst outcome = await ctx.executeTool(tool.name, args, { signal: callSignal });\n\t\t\trecord.id = outcome.toolCall.id;\n\t\t\trecord.durationMs = performance.now() - callStartedAt;\n\t\t\tif (outcome.isError) {\n\t\t\t\trecord.status = callSignal.aborted ? \"cancelled\" : \"error\";\n\t\t\t\trecord.error = truncateText(textOf(outcome.result) || `Tool \"${tool.name}\" failed`, ERROR_PREVIEW_CHARS);\n\t\t\t} else {\n\t\t\t\trecord.status = \"ok\";\n\t\t\t}\n\t\t\tlog.finish(record);\n\t\t\treturn toScriptValue(tool, outcome);\n\t\t},\n\t}));\n\n\t// The wait for a worker counts toward the script's deadline.\n\tconst deadline = sourceOptions.timeoutMs ?? Number.POSITIVE_INFINITY;\n\tconst waitStartedAt = performance.now();\n\tconst admission = await reserveCodemodeWorker(\n\t\tsignal,\n\t\tMath.min(deadline, CODEMODE_WORKER_WAIT_MS),\n\t\toptions.environment,\n\t);\n\tconst waitedMs = performance.now() - waitStartedAt;\n\tif (admission !== \"reserved\") {\n\t\tconst waited = ((performance.now() - startedAt) / 1000).toFixed(1);\n\t\tconst reason = signal?.reason;\n\t\tconst error =\n\t\t\tadmission === \"aborted\"\n\t\t\t\t? `Script aborted: ${reason instanceof Error ? reason.message : \"Execution aborted\"}`\n\t\t\t\t: deadline <= CODEMODE_WORKER_WAIT_MS\n\t\t\t\t\t? `Script timed out: Execution timed out after ${deadline} ms while waiting for a free codemode worker`\n\t\t\t\t\t: `No codemode worker became free within ${CODEMODE_WORKER_WAIT_MS / 1000} seconds. All ${maxCodemodeWorkers(options.environment)} workers, shared by every session in this process, are held by other scripts. Retry after they finish.`;\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{ type: \"text\", text: `Script failed\\nWall time ${waited} seconds\\nOutput:\\n` },\n\t\t\t\t{ type: \"text\", text: `Script error:\\n${error}\\n\\nThe script did not start.` },\n\t\t\t],\n\t\t\tdetails: log.snapshot(),\n\t\t\tisError: true,\n\t\t};\n\t}\n\t// The reservation covers the one worker this script starts. A launch that resumes after the result\n\t// settled finds it released and starts no worker.\n\tlet reserved = true;\n\n\tlet sandbox: CodemodeSandbox | undefined;\n\tlet result: CodemodeResult;\n\ttry {\n\t\tconst own = (tool: CodemodeTool): CodemodeTool =>\n\t\t\toptions.runHostCall\n\t\t\t\t? {\n\t\t\t\t\t\t...tool,\n\t\t\t\t\t\texecute: (args, context) => options.runHostCall!(() => tool.execute(args, context), tool.name),\n\t\t\t\t\t}\n\t\t\t\t: tool;\n\t\tsandbox = new CodemodeSandbox({\n\t\t\ttools: sandboxTools.map(own),\n\t\t\tglobals: [\n\t\t\t\t...createDiscoveryGlobals(callable, samples, options),\n\t\t\t\t...(options.models && ctx\n\t\t\t\t\t? createModelGlobals(ctx.modelRegistry, toolCallId, log, addModelUsage, addGeneratedImages)\n\t\t\t\t\t: []),\n\t\t\t].map(own),\n\t\t\tenvironment: options.environment,\n\t\t\tonWorkerStarted: options.onWorkerStarted,\n\t\t\ttimeoutMs: Math.max(1, Math.round(deadline - waitedMs)),\n\t\t\tmemoryLimitBytes: CODEMODE_MEMORY_LIMIT_BYTES,\n\t\t\twasm: loadQuickJSWasm(getQuickJSWasmPath()),\n\t\t\tworkerUrl: getCodemodeWorkerSpecifier(),\n\t\t\tacquireWorker: () => {\n\t\t\t\tif (!reserved) throw new Error(\"The script already settled\");\n\t\t\t\t// From here the sandbox releases the slot when the worker actually exits.\n\t\t\t\treserved = false;\n\t\t\t\treturn releaseCodemodeWorker;\n\t\t\t},\n\t\t});\n\t\tconst store = ctx ? readCodemodeStore(ctx.sessionManager.getBranch()) : {};\n\t\t// HUMAIN extension: a returned value is appended like text(), inside the VM's hard output limits.\n\t\tresult = await sandbox.execute(code, { signal, store, returnAsOutput: true });\n\t} finally {\n\t\tawait sandbox?.close();\n\t\tif (reserved) {\n\t\t\treserved = false;\n\t\t\treleaseCodemodeWorker();\n\t\t}\n\t}\n\t// Calls still marked running were cut off by the script ending, a timeout, or an abort.\n\tfor (const call of log.calls) {\n\t\tif (call.status === \"running\") call.status = \"cancelled\";\n\t}\n\n\tif (result.ok) {\n\t\tconst { set, delete: deleted } = result.storeWrites;\n\t\tif (Object.keys(set).length > 0 || deleted.length > 0) {\n\t\t\toptions.appendEntry?.(CODEMODE_STORE_ENTRY_TYPE, { set, delete: deleted });\n\t\t}\n\t}\n\tconst items = formatOutput(result.output);\n\tif (!result.ok) items.push({ type: \"text\", text: `Script error:\\n${formatError(result, log.snapshot())}` });\n\tif (generatedImages > 0 && !items.some((item) => item.type === \"image\")) {\n\t\titems.push({\n\t\t\ttype: \"text\",\n\t\t\ttext: `Note: models.generateImages() returned ${generatedImages} image${generatedImages === 1 ? \"\" : \"s\"} that the script did not show. Show each image block of result.output with image(block).`,\n\t\t});\n\t}\n\n\tconst truncated = await truncateOutput(\n\t\tjoinAdjacentText(items),\n\t\tsourceOptions.maxOutputTokens ?? DEFAULT_MAX_OUTPUT_TOKENS,\n\t);\n\t// After truncation, which joins the text items and moves images after them, so each path stays\n\t// next to its image and is never cut.\n\tconst output = joinAdjacentText(await saveImages(truncated.items));\n\tconst wallTime = ((performance.now() - startedAt) / 1000).toFixed(1);\n\tconst header = `${result.ok ? \"Script completed\" : \"Script failed\"}\\nWall time ${wallTime} seconds\\nOutput:\\n`;\n\tconst details = log.snapshot();\n\tif (truncated.fullOutputPath) details.fullOutputPath = truncated.fullOutputPath;\n\treturn {\n\t\tcontent: [{ type: \"text\", text: header }, ...output],\n\t\tdetails,\n\t\t...(modelUsage ? { usage: modelUsage } : {}),\n\t\t...(result.ok ? {} : { isError: true }),\n\t};\n}\n\n/**\n * Whether `query` names the namespace: its name or one of its aliases, as written or as the same\n * script identifier (`dev-radius` and `dev_radius` are both `dev_radius`).\n */\nfunction isNamespaceName(namespace: ToolNamespace, query: string): boolean {\n\tconst queryId = toCodemodeIdentifier(query);\n\treturn [namespace.name, ...(namespace.aliases ?? [])].some(\n\t\t(name) => name === query || toCodemodeIdentifier(name) === queryId,\n\t);\n}\n\n/**\n * `searchTools()`, `describeTool()`, and `describeNamespace()`: ranked search and lookup over the\n * script's nested tools and their namespaces.\n */\nfunction createDiscoveryGlobals(\n\ttools: readonly AgentTool<any>[],\n\tsamples: ReadonlyMap<string, string>,\n\toptions: CodemodeToolOptions,\n): CodemodeTool[] {\n\tconst ranker = new Bm25Ranker();\n\tconst entry = (name: string) => ({ name: toCodemodeIdentifier(name), description: samples.get(name) ?? \"\" });\n\treturn [\n\t\t{\n\t\t\tname: \"searchTools\",\n\t\t\tspread: true,\n\t\t\texecute: (args) => {\n\t\t\t\tconst [query, searchOptions] = args as [unknown, { limit?: unknown; namespace?: unknown } | undefined];\n\t\t\t\tif (typeof query !== \"string\") throw new Error(\"searchTools() expects a query string\");\n\t\t\t\tconst limit = searchOptions?.limit ?? DEFAULT_TOOL_SEARCH_LIMIT;\n\t\t\t\tif (typeof limit !== \"number\" || !Number.isInteger(limit) || limit <= 0) {\n\t\t\t\t\tthrow new Error(\"searchTools() limit must be a positive integer\");\n\t\t\t\t}\n\t\t\t\tconst namespace = searchOptions?.namespace;\n\t\t\t\tif (namespace !== undefined && namespace !== null && typeof namespace !== \"string\") {\n\t\t\t\t\tthrow new Error(\"searchTools() namespace must be a string\");\n\t\t\t\t}\n\t\t\t\tconst documents = tools.flatMap((tool) => {\n\t\t\t\t\tconst toolNamespace = options.getToolNamespace?.(tool.name);\n\t\t\t\t\tif (namespace && (!toolNamespace || !isNamespaceName(toolNamespace, namespace))) return [];\n\t\t\t\t\treturn [createToolSearchDocument(tool, toolNamespace)];\n\t\t\t\t});\n\t\t\t\treturn ranker.rank(query, documents, limit).map((match) => entry(match.name));\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"describeTool\",\n\t\t\tspread: true,\n\t\t\texecute: (args) => {\n\t\t\t\tconst [name] = args as unknown[];\n\t\t\t\tif (typeof name !== \"string\") throw new Error(\"describeTool() expects a tool name\");\n\t\t\t\tconst tool = tools.find(\n\t\t\t\t\t(candidate) => candidate.name === name || toCodemodeIdentifier(candidate.name) === name,\n\t\t\t\t);\n\t\t\t\treturn tool ? samples.get(tool.name) : undefined;\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"describeNamespace\",\n\t\t\tspread: true,\n\t\t\texecute: (args) => {\n\t\t\t\tconst [name] = args as unknown[];\n\t\t\t\tif (typeof name !== \"string\") throw new Error(\"describeNamespace() expects a namespace name\");\n\t\t\t\tlet namespace: ToolNamespace | undefined;\n\t\t\t\tconst names: string[] = [];\n\t\t\t\tfor (const tool of tools) {\n\t\t\t\t\tconst toolNamespace = options.getToolNamespace?.(tool.name);\n\t\t\t\t\tif (!toolNamespace || !isNamespaceName(toolNamespace, name)) continue;\n\t\t\t\t\tnamespace ??= toolNamespace;\n\t\t\t\t\tnames.push(toCodemodeIdentifier(tool.name));\n\t\t\t\t}\n\t\t\t\tif (!namespace) return undefined;\n\t\t\t\treturn {\n\t\t\t\t\tname: namespace.name,\n\t\t\t\t\t...(namespace.description ? { description: namespace.description } : {}),\n\t\t\t\t\t...(namespace.instructions ? { instructions: namespace.instructions } : {}),\n\t\t\t\t\ttools: names,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t];\n}\n\n/**\n * `models.*` for scripts: the model registry methods documented in docs/codemode.md.\n * Classifier and image calls appear as nested call rows so the renderer shows them, and their usage\n * goes to `addUsage`. Rows show only the model, never prompts or image data.\n */\nfunction createModelGlobals(\n\tmodels: CodemodeModelRuntime,\n\ttoolCallId: string,\n\tlog: CodemodeCallLog,\n\taddUsage: (usage: Usage) => void,\n\taddGeneratedImages: (count: number) => void,\n): CodemodeTool[] {\n\tconst limit = createLimiter(MAX_CONCURRENT_MODEL_CALLS);\n\tlet callCount = 0;\n\n\t/**\n\t * Resolve the script's model by provider and id only, check the context, then run the call as a\n\t * nested call row. A script-supplied baseUrl or headers must never receive the credentials.\n\t */\n\tconst runModelCall = async <TType extends \"classifier\" | \"image\", TContext, TResult extends ModelCallResult>(\n\t\tname: string,\n\t\ttype: TType,\n\t\t[model, context]: unknown[],\n\t\tcheckContext: (context: unknown) => TContext,\n\t\trun: (resolved: ModelTypeMap[TType], context: TContext) => Promise<TResult>,\n\t): Promise<TResult> => {\n\t\tconst listHint = `List the ${type} models you can use with models.getAvailableOfType(\"${type}\").`;\n\t\tconst given = model as ScriptValue;\n\t\tif (typeof given?.provider !== \"string\" || typeof given.id !== \"string\") {\n\t\t\t// undefined arrives as null: spread arguments cross the sandbox as a JSON array.\n\t\t\tconst undefinedHint =\n\t\t\t\tmodel === undefined || model === null\n\t\t\t\t\t? \" models.getModelOfType() returns undefined for an unknown provider or id.\"\n\t\t\t\t\t: \"\";\n\t\t\tthrow new Error(\n\t\t\t\t`${name}() expects ${withArticle(type)} model as its first argument, got ${describeValue(model)}.${undefinedHint} ${listHint}`,\n\t\t\t);\n\t\t}\n\t\tconst provider = given.provider;\n\t\tconst id = given.id;\n\t\tconst ref = `${provider}/${id}`;\n\t\tconst resolved = models.getModelOfType(type, provider, id);\n\t\tif (!resolved) {\n\t\t\tconst actualType = [...MODEL_TYPES].find(\n\t\t\t\t(other) => other !== type && models.getModelOfType(other as ModelType, provider, id) !== undefined,\n\t\t\t);\n\t\t\tthrow new Error(\n\t\t\t\tactualType\n\t\t\t\t\t? `\"${ref}\" is ${withArticle(actualType)} model, not ${withArticle(type)} model. ${listHint}`\n\t\t\t\t\t: `Unknown ${type} model \"${ref}\". ${listHint}`,\n\t\t\t);\n\t\t}\n\t\tconst checked = checkContext(context);\n\n\t\tconst record: CodemodeNestedCall = {\n\t\t\tid: `${toolCallId}/${name}/${++callCount}`,\n\t\t\tname,\n\t\t\targs: `${resolved.provider}/${resolved.id}`,\n\t\t\tstatus: \"running\",\n\t\t};\n\t\tlog.start(record);\n\t\tconst startedAt = performance.now();\n\t\tconst result = await limit(() => run(resolved, checked));\n\t\trecord.durationMs = performance.now() - startedAt;\n\t\trecord.status = result.stopReason === \"stop\" ? \"ok\" : result.stopReason === \"aborted\" ? \"cancelled\" : \"error\";\n\t\tif (result.errorMessage) record.error = truncateText(result.errorMessage, ERROR_PREVIEW_CHARS);\n\t\tif (result.usage) {\n\t\t\trecord.cost = result.usage.cost.total;\n\t\t\taddUsage(result.usage);\n\t\t}\n\t\tlog.finish(record);\n\t\treturn result;\n\t};\n\tconst implementations: Record<string, CodemodeTool[\"execute\"]> = {\n\t\t\"models.getModelsOfType\": (args) => {\n\t\t\tconst [type, provider] = args as unknown[];\n\t\t\treturn models.getModelsOfType(toModelType(type), toProvider(provider)).map(toModelInfo);\n\t\t},\n\t\t\"models.getAvailableOfType\": async (args, { signal }) => {\n\t\t\tconst [type, provider] = args as unknown[];\n\t\t\tconst available = await models.getAvailableOfType(toModelType(type), toProvider(provider), { signal });\n\t\t\treturn available.map(toModelInfo);\n\t\t},\n\t\t\"models.getModelOfType\": (args) => {\n\t\t\tconst [type, provider, id] = args as unknown[];\n\t\t\tif (typeof provider !== \"string\" || typeof id !== \"string\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`models.getModelOfType(type, provider, id) expects three strings, got (${(args as unknown[]).map(describeValue).join(\", \")}). The provider and the id are separate arguments, for example models.getModelOfType(\"classifier\", \"typesafe\", \"jev-latest\").`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst model = models.getModelOfType(toModelType(type), provider, id);\n\t\t\treturn model === undefined ? undefined : toModelInfo(model);\n\t\t},\n\t\t\"models.classify\": (args, { signal }) =>\n\t\t\trunModelCall(\"models.classify\", \"classifier\", args as unknown[], checkClassifierContext, (resolved, context) =>\n\t\t\t\tmodels.classify(resolved, context, { signal }),\n\t\t\t),\n\t\t\"models.generateImages\": (args, { signal }) =>\n\t\t\trunModelCall(\n\t\t\t\t\"models.generateImages\",\n\t\t\t\t\"image\",\n\t\t\t\targs as unknown[],\n\t\t\t\tcheckImagesContext,\n\t\t\t\tasync (resolved, context) => {\n\t\t\t\t\tconst result = await models.generateImages(resolved, context, { signal });\n\t\t\t\t\taddGeneratedImages(result.output.filter((block) => block.type === \"image\").length);\n\t\t\t\t\treturn result;\n\t\t\t\t},\n\t\t\t),\n\t};\n\treturn Object.entries(implementations).map(([name, execute]) => ({ name, spread: true, execute }));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../src/extensions/codemode/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAKrE,OAAO,KAAK,EAAsB,mBAAmB,EAAE,MAAM,WAAW,CAAC;AA4DzE,eAAO,MAAM,iBAAiB,EAAE,IAAI,CACnC,cAAc,CAAC,GAAG,EAAE,mBAAmB,GAAG,SAAS,CAAC,EACpD,YAAY,GAAG,cAAc,CA6F7B,CAAC"}
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../src/extensions/codemode/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAKrE,OAAO,KAAK,EAAsB,mBAAmB,EAAE,MAAM,WAAW,CAAC;AA4DzE,eAAO,MAAM,iBAAiB,EAAE,IAAI,CACnC,cAAc,CAAC,GAAG,EAAE,mBAAmB,GAAG,SAAS,CAAC,EACpD,YAAY,GAAG,cAAc,CAiG7B,CAAC"}
@@ -95,16 +95,21 @@ export const codemodeRenderers = {
95
95
  const component = context.lastComponent ?? new Container();
96
96
  component.clear();
97
97
  const calls = result.details?.calls ?? [];
98
+ const omittedCalls = result.details?.omittedCalls ?? 0;
99
+ const omittedCost = result.details?.omittedCost ?? 0;
98
100
  if (calls.length > 0) {
99
101
  const shown = options.expanded ? calls : calls.slice(-CALL_PREVIEW_COUNT);
100
102
  const lines = shown.map((call) => formatCall(call, theme, options.expanded));
101
103
  if (shown.length < calls.length) {
102
104
  lines.unshift(`${theme.fg("muted", `... (${calls.length - shown.length} earlier calls,`)} ${keyHint("app.tools.expand", "to expand")}${theme.fg("muted", ")")}`);
103
105
  }
104
- // Collapsed rows hide earlier calls, so the total covers every call.
106
+ // Calls past the list's limit are only counted, so expanding does not show them.
107
+ if (omittedCalls > 0)
108
+ lines.push(theme.fg("muted", `... (${omittedCalls} later calls not listed)`));
109
+ // Collapsed rows hide earlier calls and the list omits later ones, so the total covers every call.
105
110
  const priced = calls.filter((call) => call.cost);
106
- if (priced.length > 1) {
107
- const total = priced.reduce((sum, call) => sum + (call.cost ?? 0), 0);
111
+ if (priced.length > 1 || omittedCost > 0) {
112
+ const total = priced.reduce((sum, call) => sum + (call.cost ?? 0), omittedCost);
108
113
  lines.push(theme.fg("muted", `Model calls: ${formatCost(total)}`));
109
114
  }
110
115
  component.addChild(new Spacer(1));