@noxsoft/anima 2.0.2 → 2.0.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 (829) hide show
  1. package/README.md +1260 -28
  2. package/dist/accounts-Bth3PpPD.js +260 -0
  3. package/dist/accounts-D8CPKNkN.js +259 -0
  4. package/dist/acp-cli-ByK6lS6c.js +1081 -0
  5. package/dist/acp-cli-CaQCjIw4.js +1084 -0
  6. package/dist/agent-BgIkqd3F.js +725 -0
  7. package/dist/agent-N5BDcge4.js +725 -0
  8. package/dist/agent-events-COH7NDW2.js +182 -0
  9. package/dist/agent-scope-CPphqq-U.js +452 -0
  10. package/dist/agent-scope-DZgptr9J.js +452 -0
  11. package/dist/agent-scope-cj2QCT6R.js +112 -0
  12. package/dist/agents-NEudYMdg.js +774 -0
  13. package/dist/agents.config-Bujs-NIy.js +182 -0
  14. package/dist/agents.config-jp7OLssr.js +182 -0
  15. package/dist/argv-BMZMiW7v.js +73 -0
  16. package/dist/audit-C-UJhfdv.js +2401 -0
  17. package/dist/audit-CeCO7SK5.js +2401 -0
  18. package/dist/auth-BNZsOHGF.js +648 -0
  19. package/dist/auth-DMPZWzEa.js +639 -0
  20. package/dist/auth-choice-5VnaGMD-.js +2681 -0
  21. package/dist/auth-choice-DA2k4vs8.js +2681 -0
  22. package/dist/auth-health-B7FqA26_.js +149 -0
  23. package/dist/auth-health-VO_MPqVX.js +149 -0
  24. package/dist/auth-profiles-BDrNYX_n.js +1564 -0
  25. package/dist/auth-profiles-CxSHydjn.js +2689 -0
  26. package/dist/banner-BtDZPRzi.js +294 -0
  27. package/dist/browser-cli-8yQMpxb8.js +1679 -0
  28. package/dist/browser-cli-Czg3JtDH.js +1676 -0
  29. package/dist/build-info.json +3 -3
  30. package/dist/bundled/boot-md/handler.js +16 -16
  31. package/dist/bundled/bootstrap-extra-files/handler.js +4 -4
  32. package/dist/bundled/command-logger/handler.js +1 -1
  33. package/dist/bundled/session-memory/handler.js +5 -5
  34. package/dist/call-BIzCaKZb.js +282 -0
  35. package/dist/call-BYDpTVCZ.js +282 -0
  36. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  37. package/dist/catalog-CqKiUgu6.js +185 -0
  38. package/dist/catalog-DMfEg-oK.js +185 -0
  39. package/dist/channel-options-BrtCtyrT.js +32 -0
  40. package/dist/channel-options-CO21Gl8p.js +33 -0
  41. package/dist/channel-selection-Bbm1lq3P.js +51 -0
  42. package/dist/channel-selection-CqcX7Ocw.js +51 -0
  43. package/dist/channel-web-DrsT6OAE.js +2162 -0
  44. package/dist/channels-cli-Juyh1S6n.js +1304 -0
  45. package/dist/channels-cli-zNvi1m5c.js +1306 -0
  46. package/dist/channels-status-issues-CqzqshW4.js +18 -0
  47. package/dist/channels-status-issues-DdJdO866.js +18 -0
  48. package/dist/chrome-C4dOMO8z.js +1601 -0
  49. package/dist/chrome-DdcDzAtH.js +1629 -0
  50. package/dist/chrome-U3DRzjJD.js +1601 -0
  51. package/dist/chunk-D2nLsrEW.js +348 -0
  52. package/dist/clack-prompter-BI3RDW5w.js +92 -0
  53. package/dist/clack-prompter-Dwr1m_IZ.js +92 -0
  54. package/dist/cli/daemon-cli.js +1 -1
  55. package/dist/cli-C3cpDaz8.js +99 -0
  56. package/dist/cli-CjWUGdGC.js +101 -0
  57. package/dist/cli-session-BVjY_XrW.js +5463 -0
  58. package/dist/cli-session-gtuYN2Iq.js +5408 -0
  59. package/dist/client-Dswwze5_.js +1692 -0
  60. package/dist/client-LRKFjo4A.js +1692 -0
  61. package/dist/clipboard-BZKS9O1u.js +31 -0
  62. package/dist/clipboard-DES8b1AM.js +31 -0
  63. package/dist/command-format-CP1YTNCl.js +52 -0
  64. package/dist/command-format-CVL4K5cj.js +52 -0
  65. package/dist/command-format-G6N2zghg.js +38 -0
  66. package/dist/command-registry-BBvNvysr.js +248 -0
  67. package/dist/commands-AZ3n8Y2c.js +726 -0
  68. package/dist/commands-BMnD_QRY.js +726 -0
  69. package/dist/commands-registry-cFqZ6Ib4.js +766 -0
  70. package/dist/commands-registry-q13H7ng5.js +766 -0
  71. package/dist/common-CX5458fH.js +287 -0
  72. package/dist/common-DJbnT8ws.js +287 -0
  73. package/dist/completion-cli-BADRBcIl.js +432 -0
  74. package/dist/completion-cli-DMQgiObF.js +431 -0
  75. package/dist/config-CU-Axg8P.js +5704 -0
  76. package/dist/config-DaqbUdkI.js +5705 -0
  77. package/dist/config-cli-BPlbwiuA.js +244 -0
  78. package/dist/config-cli-DXgZJkPU.js +247 -0
  79. package/dist/config-guard-Ba49JNds.js +76 -0
  80. package/dist/config-guard-Cu0qMKZJ.js +93 -0
  81. package/dist/config-kVVm5EYV.js +6523 -0
  82. package/dist/config-sync-CzLnLTXt.js +91 -0
  83. package/dist/config-sync-DuydxPWx.js +91 -0
  84. package/dist/configure-CHgacLyi.js +960 -0
  85. package/dist/configure-DfHXDa1L.js +959 -0
  86. package/dist/context-DzgXOckU.js +60 -0
  87. package/dist/control-service-8_wKHwBa.js +72 -0
  88. package/dist/control-service-BtL1Jto_.js +72 -0
  89. package/dist/cron-cli-BCzSR2c0.js +448 -0
  90. package/dist/cron-cli-CCWNkykU.js +451 -0
  91. package/dist/daemon-cli-Bjkbu9Vy.js +565 -0
  92. package/dist/daemon-cli-CmlHcC1J.js +566 -0
  93. package/dist/daemon-cli.js +16 -16
  94. package/dist/daemon-runtime-C0tz7VAC.js +460 -0
  95. package/dist/daemon-runtime-rUTqCVwJ.js +460 -0
  96. package/dist/deliver-BBggsviM.js +1097 -0
  97. package/dist/deliver-CePITOl8.js +1162 -0
  98. package/dist/deliver-DFnVaetP.js +1097 -0
  99. package/dist/delivery-queue-BJQK3oh5.js +220 -0
  100. package/dist/deps-CeEKhrp7.js +42 -0
  101. package/dist/devices-cli-DQrDMrZH.js +198 -0
  102. package/dist/devices-cli-Oe-A1Dv0.js +195 -0
  103. package/dist/diagnostics-DxMFrBLO.js +35 -0
  104. package/dist/diagnostics-m79ZlMmZ.js +35 -0
  105. package/dist/directory-cli-BL6h8cGF.js +246 -0
  106. package/dist/directory-cli-Cjgmi_sj.js +243 -0
  107. package/dist/dispatcher-DAFbQM-c.js +100 -0
  108. package/dist/dispatcher-DNd40gUn.js +100 -0
  109. package/dist/dist-CqDI82ei.js +929 -0
  110. package/dist/dist-DnHRxR5U.js +929 -0
  111. package/dist/dns-cli-CFtV3BXK.js +200 -0
  112. package/dist/dns-cli-NyIHvQ5S.js +197 -0
  113. package/dist/dock-BdXLb5oY.js +753 -0
  114. package/dist/dock-jYICmNcI.js +753 -0
  115. package/dist/docs-cli-CrOaIK_H.js +161 -0
  116. package/dist/docs-cli-D_cmJDSr.js +159 -0
  117. package/dist/doctor-BpGxKrBl.js +1815 -0
  118. package/dist/doctor-D12wNQPU.js +1813 -0
  119. package/dist/doctor-completion-DeOfofek.js +92 -0
  120. package/dist/doctor-completion-DwjqdEcK.js +92 -0
  121. package/dist/doctor-config-flow-BI3mpkbd.js +1232 -0
  122. package/dist/doctor-config-flow-wMHheFkC.js +1232 -0
  123. package/dist/engine-BCtL-AMw.js +563 -0
  124. package/dist/engine-Bk_UT413.js +563 -0
  125. package/dist/entry.js +5 -5
  126. package/dist/env-v6411I8h.js +32 -0
  127. package/dist/exec-B7sUS164.js +1167 -0
  128. package/dist/exec-approvals-CroGJRUg.js +1221 -0
  129. package/dist/exec-approvals-cli-BTxF_RsH.js +371 -0
  130. package/dist/exec-approvals-cli-n1gyGwH2.js +368 -0
  131. package/dist/exec-mhSykkaa.js +255 -0
  132. package/dist/extensionAPI.js +3 -3
  133. package/dist/frontmatter-BmHq0vRD.js +204 -0
  134. package/dist/gateway-cli-DDBadlrS.js +19971 -0
  135. package/dist/gateway-cli-IZNkOMBe.js +19972 -0
  136. package/dist/gateway-rpc-Dtx8HN-n.js +28 -0
  137. package/dist/gateway-rpc-L2PVSqGj.js +28 -0
  138. package/dist/github-copilot-auth-DKyqDaGU.js +1418 -0
  139. package/dist/github-copilot-auth-DXpOMSd3.js +1418 -0
  140. package/dist/gmail-setup-utils-BKNczIJ9.js +428 -0
  141. package/dist/gmail-setup-utils-co0ppccC.js +428 -0
  142. package/dist/health-Bm8ZTvC3.js +1253 -0
  143. package/dist/health-DUf1gt4E.js +1258 -0
  144. package/dist/health-format-BksT6F68.js +208 -0
  145. package/dist/health-format-uzh1xYLD.js +208 -0
  146. package/dist/heartbeat-visibility-1TJb1Zao.js +98 -0
  147. package/dist/heartbeat-visibility-CwodtdcX.js +98 -0
  148. package/dist/help-format-C6cv_aZp.js +17 -0
  149. package/dist/helpers-N-uSFKOn.js +10 -0
  150. package/dist/hooks-cli-1POsXqOl.js +993 -0
  151. package/dist/hooks-cli-BGjILbze.js +991 -0
  152. package/dist/hooks-status-DE07n5RC.js +356 -0
  153. package/dist/hooks-status-Du-d1jde.js +356 -0
  154. package/dist/image-ops-B_AYV3tp.js +541 -0
  155. package/dist/image-ops-Bp0C6Mvr.js +541 -0
  156. package/dist/index.js +82 -82
  157. package/dist/init-9A0s7bWG.js +122 -0
  158. package/dist/init-DoyCHJDC.js +122 -0
  159. package/dist/installs-D1C9wHAq.js +383 -0
  160. package/dist/installs-Dh4dHayM.js +383 -0
  161. package/dist/ipv4-DCItfaJo.js +1964 -0
  162. package/dist/ipv4-DSOUVx0i.js +1964 -0
  163. package/dist/lanes-BvSnHq2h.js +232 -0
  164. package/dist/lifecycle-core-BY4WIf9g.js +388 -0
  165. package/dist/lifecycle-core-TQKyXO-6.js +387 -0
  166. package/dist/links-CNu_8RZl.js +15 -0
  167. package/dist/links-D2tt2ouh.js +15 -0
  168. package/dist/llm-slug-generator.js +4 -4
  169. package/dist/logging-BIeRw0WR.js +15 -0
  170. package/dist/logging-C7lb3Vjc.js +15 -0
  171. package/dist/login-DXWKewA2.js +59 -0
  172. package/dist/login-Fhh4uWmf.js +61 -0
  173. package/dist/login-pPs3UO38.js +61 -0
  174. package/dist/login-qr-CevLD8cV.js +326 -0
  175. package/dist/login-qr-GF2JMIy-.js +323 -0
  176. package/dist/login-qr-ZYYKD6Yt.js +321 -0
  177. package/dist/logs-cli-CzXbX8HZ.js +242 -0
  178. package/dist/logs-cli-D9ngH9PF.js +245 -0
  179. package/dist/manager-BD5rA3w0.js +3244 -0
  180. package/dist/manager-BDPgBQSH.js +3246 -0
  181. package/dist/manager-DRWMWM--.js +3244 -0
  182. package/dist/manifest-registry-DbvPaBXY.js +748 -0
  183. package/dist/manifest-registry-kHX_MFa1.js +748 -0
  184. package/dist/markdown-tables-CqwihY2m.js +347 -0
  185. package/dist/markdown-tables-DJV7eAJZ.js +348 -0
  186. package/dist/media-lUqN-0O9.js +1342 -0
  187. package/dist/memory-cli-BLXSpgnN.js +868 -0
  188. package/dist/memory-cli-BcGVkkRJ.js +869 -0
  189. package/dist/message-channel-D_jIO87f.js +110 -0
  190. package/dist/migrate-BpVOar4L.js +157 -0
  191. package/dist/migrate-CkgGDkWy.js +157 -0
  192. package/dist/model-selection-Cqt6aJ0G.js +2691 -0
  193. package/dist/models-CExsNQPH.js +2510 -0
  194. package/dist/models-cli-Ba3Jmwev.js +2739 -0
  195. package/dist/models-cli-iDAlsbL2.js +258 -0
  196. package/dist/net-0A_zcaQD.js +218 -0
  197. package/dist/node-cli-ATmwCXIk.js +1319 -0
  198. package/dist/node-cli-DYFR_V25.js +1322 -0
  199. package/dist/node-service-CN4LqR1A.js +67 -0
  200. package/dist/node-service-CWt3MdSC.js +67 -0
  201. package/dist/nodes-cli-BeVmhTz3.js +1197 -0
  202. package/dist/nodes-cli-QeJIfa18.js +1200 -0
  203. package/dist/nodes-screen-DHyWAlla.js +234 -0
  204. package/dist/nodes-screen-qs3jRBPk.js +234 -0
  205. package/dist/note-CSlg2BnB.js +73 -0
  206. package/dist/note-Ctvglhp1.js +73 -0
  207. package/dist/npm-registry-spec-DQd4M22q.js +351 -0
  208. package/dist/npm-registry-spec-PxisIMts.js +351 -0
  209. package/dist/onboard-DeruD10m.js +1166 -0
  210. package/dist/onboard-SAcu5N6N.js +1165 -0
  211. package/dist/onboard-channels-C4iSfFXR.js +672 -0
  212. package/dist/onboard-channels-oVTVgoyg.js +672 -0
  213. package/dist/onboard-helpers-B8roRwLP.js +365 -0
  214. package/dist/onboard-helpers-Dgh26hgP.js +365 -0
  215. package/dist/onboarding-Bi-ac8we.js +911 -0
  216. package/dist/onboarding-C2gjB2u8.js +910 -0
  217. package/dist/orchestrator-DlbAYMQP.js +357 -0
  218. package/dist/orchestrator-DlwVRVDA.js +357 -0
  219. package/dist/outbound-CkKgc6iR.js +2062 -0
  220. package/dist/outbound-Vfm5yDh3.js +214 -0
  221. package/dist/outbound-bs_VK51X.js +214 -0
  222. package/dist/outbound-send-deps-DDjiMfEL.js +55 -0
  223. package/dist/pairing-cli-CJYeuEik.js +118 -0
  224. package/dist/pairing-cli-mqopHI8s.js +121 -0
  225. package/dist/pairing-store-BsXzUDPv.js +388 -0
  226. package/dist/pairing-store-DoNj00-X.js +388 -0
  227. package/dist/path-env-C_xpiG8l.js +89 -0
  228. package/dist/path-env-DSSMHu5A.js +89 -0
  229. package/dist/paths-B1vRVCad.js +126 -0
  230. package/dist/paths-BMuHNFxg.js +238 -0
  231. package/dist/paths-BXQQzXGQ.js +129 -0
  232. package/dist/paths-Buw_geoe.js +54 -0
  233. package/dist/paths-DA9WYabg.js +222 -0
  234. package/dist/paths-DfQGx0_k.js +129 -0
  235. package/dist/pi-auth-json-DOPW3e4X.js +78 -0
  236. package/dist/pi-auth-json-MruLmI_X.js +82 -0
  237. package/dist/pi-auth-json-lae_wwwo.js +80 -0
  238. package/dist/pi-model-discovery-7q0GxMrp.js +3 -0
  239. package/dist/pi-tools.policy-Csmla32P.js +200 -0
  240. package/dist/pi-tools.policy-xYdDLEv9.js +200 -0
  241. package/dist/plugin-auto-enable-CViVVWgg.js +282 -0
  242. package/dist/plugin-auto-enable-CjZ238UI.js +282 -0
  243. package/dist/plugin-registry-B4Aw2hzq.js +32 -0
  244. package/dist/plugin-registry-DW81arxW.js +32 -0
  245. package/dist/plugin-sdk/cli/cli-name.d.ts +1 -1
  246. package/dist/plugin-sdk/config/paths.d.ts +2 -2
  247. package/dist/plugin-sdk/index.js +7 -7
  248. package/dist/plugins-DhcGAPDB.js +38 -0
  249. package/dist/plugins-DtghNRtM.js +168 -0
  250. package/dist/plugins-cli-4vWTmOAb.js +736 -0
  251. package/dist/plugins-cli-CdTMbP0X.js +734 -0
  252. package/dist/polls-D6eCdatA.js +1343 -0
  253. package/dist/ports-BtZx-JKD.js +96 -0
  254. package/dist/ports-C8bKN8s0.js +96 -0
  255. package/dist/ports-DHiKnPRX.js +344 -0
  256. package/dist/ports-vd93M_Pt.js +317 -0
  257. package/dist/program-CX3aUVeb.js +176 -0
  258. package/dist/program-context-BPos0ivo.js +496 -0
  259. package/dist/progress-oiAjiiNi.js +133 -0
  260. package/dist/prompt-style-Cm4wOtKm.js +9 -0
  261. package/dist/pw-ai-4QbK5YFe.js +1865 -0
  262. package/dist/pw-ai-BWz3Cxt7.js +1868 -0
  263. package/dist/pw-ai-C83HBue2.js +1867 -0
  264. package/dist/qmd-manager-BcMeZiGD.js +938 -0
  265. package/dist/qmd-manager-CPypGJ0P.js +935 -0
  266. package/dist/qmd-manager-CRrSkfia.js +937 -0
  267. package/dist/register.agent-DDY8KJhn.js +265 -0
  268. package/dist/register.agent-DKawm-9d.js +1003 -0
  269. package/dist/register.anima-CEWUo29k.js +193 -0
  270. package/dist/register.anima-DBWz2rk_.js +193 -0
  271. package/dist/register.configure-BX67qV8k.js +103 -0
  272. package/dist/register.configure-CWsySuiq.js +101 -0
  273. package/dist/register.maintenance-0k-ZNhDg.js +543 -0
  274. package/dist/register.maintenance-BIwx1fzX.js +543 -0
  275. package/dist/register.message-CXPsoakA.js +657 -0
  276. package/dist/register.message-DA3jvfgI.js +660 -0
  277. package/dist/register.onboard-C4HG7Hqv.js +170 -0
  278. package/dist/register.onboard-GOpdif-j.js +170 -0
  279. package/dist/register.setup-B17vZT7C.js +175 -0
  280. package/dist/register.setup-GJyUDCqh.js +175 -0
  281. package/dist/register.status-health-sessions-D5876dGx.js +313 -0
  282. package/dist/register.status-health-sessions-lOewVIZR.js +142 -0
  283. package/dist/register.subclis-Dwnujj5C.js +255 -0
  284. package/dist/reply-CR5T_oQJ.js +32212 -0
  285. package/dist/reply-prefix-BcrS4Umd.js +100 -0
  286. package/dist/reply-prefix-Btb5o2NH.js +100 -0
  287. package/dist/reply-r089HuRA.js +32212 -0
  288. package/dist/routes-B4czFzIb.js +1820 -0
  289. package/dist/routes-ucJWAk5O.js +1820 -0
  290. package/dist/rpc-BnKxnQ0v.js +70 -0
  291. package/dist/rpc-DgE-xnyx.js +70 -0
  292. package/dist/run-main-B74kv84C.js +371 -0
  293. package/dist/runtime-guard-CKFdts2L.js +60 -0
  294. package/dist/sandbox-CJTS3er6.js +858 -0
  295. package/dist/sandbox-DBSiVHt_.js +859 -0
  296. package/dist/sandbox-cli-CrkjyU5M.js +461 -0
  297. package/dist/sandbox-cli-D1r5y6Sz.js +458 -0
  298. package/dist/security-cli-BZUdnkhn.js +462 -0
  299. package/dist/security-cli-DS09ebvA.js +465 -0
  300. package/dist/server-context-C0xZbYhg.js +824 -0
  301. package/dist/server-context-DVh2z7om.js +824 -0
  302. package/dist/server-node-events-bu9lpkMH.js +233 -0
  303. package/dist/server-node-events-i1Rrww31.js +231 -0
  304. package/dist/service-CJJwLEor.js +642 -0
  305. package/dist/service-DxLxBhaU.js +642 -0
  306. package/dist/service-audit-DB4Y3Ekp.js +488 -0
  307. package/dist/service-audit-M8y4TXVb.js +488 -0
  308. package/dist/session-CGxOLFs2.js +179 -0
  309. package/dist/session-DTTbdKb0.js +181 -0
  310. package/dist/session-cost-usage-FcdJl9c3.js +600 -0
  311. package/dist/session-cost-usage-qdfsGU2a.js +600 -0
  312. package/dist/session-yOhWcsD2.js +181 -0
  313. package/dist/sessions-B-Cu7JZq.js +1296 -0
  314. package/dist/sessions-BgLN4KFr.js +180 -0
  315. package/dist/sessions-CnRjwdVr.js +1296 -0
  316. package/dist/sessions-wRKla1Qh.js +2038 -0
  317. package/dist/shared-DS3UaJSP.js +66 -0
  318. package/dist/shared-DxNHzky3.js +77 -0
  319. package/dist/shared-Qpt4hUDi.js +66 -0
  320. package/dist/shared-kzrojZ1B.js +77 -0
  321. package/dist/skill-scanner-DLJji5Ye.js +263 -0
  322. package/dist/skills-BWFIEp4j.js +807 -0
  323. package/dist/skills-DV4zKdCx.js +808 -0
  324. package/dist/skills-cli-BY53ILm2.js +289 -0
  325. package/dist/skills-cli-CO3gxl8A.js +286 -0
  326. package/dist/skills-status-DX5pcqY3.js +166 -0
  327. package/dist/skills-status-zhcKzGkp.js +166 -0
  328. package/dist/sqlite-B6MojU1I.js +321 -0
  329. package/dist/sqlite-CuprTGR7.js +453 -0
  330. package/dist/sqlite-dzD-jMjs.js +368 -0
  331. package/dist/start-Cu3aLoSf.js +297 -0
  332. package/dist/start-Dz7tMAl8.js +296 -0
  333. package/dist/status-CaSxhxfV.js +2132 -0
  334. package/dist/status-D2C0JCX3.js +2137 -0
  335. package/dist/status-DlFMsQzh.js +27 -0
  336. package/dist/status-G0CITnKR.js +27 -0
  337. package/dist/status.update-CHjhVxJY.js +79 -0
  338. package/dist/status.update-DVFelehi.js +79 -0
  339. package/dist/subagent-registry-3Xb4el-8.js +14 -0
  340. package/dist/subagent-registry-CdSjz14I.js +2760 -0
  341. package/dist/subagent-registry-DNDhbHWi.js +2759 -0
  342. package/dist/subsystem-DfKstnEK.js +860 -0
  343. package/dist/system-cli-B5mt0FWa.js +82 -0
  344. package/dist/system-cli-Dg3UQ3Zz.js +79 -0
  345. package/dist/systemd-B43AvOGx.js +452 -0
  346. package/dist/systemd-RpPE0XGg.js +452 -0
  347. package/dist/systemd-hints-DMJT-Bbc.js +36 -0
  348. package/dist/systemd-hints-vRInKcz9.js +36 -0
  349. package/dist/systemd-linger-Dzyxqsod.js +75 -0
  350. package/dist/systemd-linger-EujbmI5A.js +75 -0
  351. package/dist/table-DhXHfRX2.js +279 -0
  352. package/dist/table-bWCLW-3P.js +279 -0
  353. package/dist/timeout-Ddn-5kAO.js +232 -0
  354. package/dist/tokens-3psI_Qk2.js +14 -0
  355. package/dist/tokens-BaM53PEx.js +14 -0
  356. package/dist/trash-Bmxs1Rnm.js +23 -0
  357. package/dist/trash-C39a6hKA.js +23 -0
  358. package/dist/tui-BHgBWhHE.js +3894 -0
  359. package/dist/tui-cli-B9Sq5-cC.js +50 -0
  360. package/dist/tui-cli-Dw7v4JoJ.js +47 -0
  361. package/dist/tui-mUwDwqvd.js +3894 -0
  362. package/dist/update-DF0GHG0j.js +317 -0
  363. package/dist/update-DoZLVjva.js +317 -0
  364. package/dist/update-check-Bt1dVPVN.js +400 -0
  365. package/dist/update-check-D5qAKes7.js +400 -0
  366. package/dist/update-cli-BNu2Oi7H.js +1105 -0
  367. package/dist/update-cli-D36AmALA.js +1105 -0
  368. package/dist/update-runner-CNQQaTwA.js +894 -0
  369. package/dist/update-runner-CvxZmbu-.js +894 -0
  370. package/dist/usage-BGCwNnjk.js +4516 -0
  371. package/dist/utils-DZ8pnOD5.js +243 -0
  372. package/dist/web-B5QG839O.js +46842 -0
  373. package/dist/web-Cmnvk9v0.js +2203 -0
  374. package/dist/web-Cv2KnTnL.js +63 -0
  375. package/dist/webhooks-cli-B6y89Pj_.js +319 -0
  376. package/dist/webhooks-cli-BDzHON4w.js +316 -0
  377. package/dist/whatsapp-actions-C_5MwVxM.js +45 -0
  378. package/dist/whatsapp-actions-hgYA12To.js +53 -0
  379. package/dist/whatsapp-actions-zTiVOoOV.js +49 -0
  380. package/dist/widearea-dns-BeIdnISJ.js +127 -0
  381. package/dist/widearea-dns-CF1gxpJ-.js +127 -0
  382. package/dist/workspace-DLna1IxR.js +649 -0
  383. package/dist/ws-log-Q4wO1Ztb.js +267 -0
  384. package/dist/ws-log-xF0kxDzp.js +267 -0
  385. package/package.json +1 -2
  386. package/dist/accounts-Cc5E4IDO.js +0 -260
  387. package/dist/accounts-CcVrwKqv.js +0 -259
  388. package/dist/acp-cli-DvphOKuh.js +0 -1081
  389. package/dist/acp-cli-p28pQ65a.js +0 -1084
  390. package/dist/agent-Cj7uDJaZ.js +0 -725
  391. package/dist/agent-Cuj9-2sT.js +0 -725
  392. package/dist/agent-events-BEBQsyE5.js +0 -182
  393. package/dist/agent-scope-BVf4aSwY.js +0 -112
  394. package/dist/agent-scope-OZi7lb8S.js +0 -452
  395. package/dist/agent-scope-V1bi9OYL.js +0 -452
  396. package/dist/agents-BUWqn_Ui.js +0 -774
  397. package/dist/agents.config-Dvo2ULxs.js +0 -182
  398. package/dist/agents.config-d6H0_3oj.js +0 -182
  399. package/dist/argv-DqUHKf0o.js +0 -73
  400. package/dist/audit-C6okOOSh.js +0 -2401
  401. package/dist/audit-VWjIdwC7.js +0 -2401
  402. package/dist/auth-91o2YM96.js +0 -648
  403. package/dist/auth-choice-CAmACV13.js +0 -2681
  404. package/dist/auth-choice-p3SeHPj2.js +0 -2681
  405. package/dist/auth-health-B_jXrWe6.js +0 -149
  406. package/dist/auth-health-DCicUKYR.js +0 -149
  407. package/dist/auth-lZ26wsbN.js +0 -639
  408. package/dist/auth-profiles-CCDD56dU.js +0 -1564
  409. package/dist/auth-profiles-DxI8L7bs.js +0 -2689
  410. package/dist/banner-Cohn04J6.js +0 -294
  411. package/dist/browser-cli-DANzjztE.js +0 -1676
  412. package/dist/browser-cli-WjsVH741.js +0 -1679
  413. package/dist/call-BAHvlu2G.js +0 -282
  414. package/dist/call-Ct7EGP_L.js +0 -282
  415. package/dist/catalog-BAayBt1L.js +0 -185
  416. package/dist/catalog-BNsf97BM.js +0 -185
  417. package/dist/channel-options-Dx9nPlX8.js +0 -33
  418. package/dist/channel-options-ZdvXrTGs.js +0 -32
  419. package/dist/channel-selection-CujyiWGM.js +0 -51
  420. package/dist/channel-selection-DfGpCyh2.js +0 -51
  421. package/dist/channel-web-CC0hkgkR.js +0 -2162
  422. package/dist/channels-cli-D7lNBpIb.js +0 -1304
  423. package/dist/channels-cli-DUPG8WDv.js +0 -1306
  424. package/dist/channels-status-issues-DBc1pU_R.js +0 -18
  425. package/dist/channels-status-issues-DjO9MHIG.js +0 -18
  426. package/dist/chrome-Bi6iZ5sG.js +0 -1601
  427. package/dist/chrome-DNSv7Cpy.js +0 -1629
  428. package/dist/chrome-DScZx4Lk.js +0 -1601
  429. package/dist/chunk-mxPVo000.js +0 -348
  430. package/dist/clack-prompter-B0kl7shw.js +0 -92
  431. package/dist/clack-prompter-B1YxZdRy.js +0 -92
  432. package/dist/cli-CfHUkOD0.js +0 -101
  433. package/dist/cli-ClMrIh6l.js +0 -99
  434. package/dist/cli-session-BkPTd9Pk.js +0 -5463
  435. package/dist/cli-session-Dd8DKb5a.js +0 -5408
  436. package/dist/client-C1avc0vD.js +0 -1692
  437. package/dist/client-CC94YZrT.js +0 -1692
  438. package/dist/clipboard-B2fBy8tG.js +0 -31
  439. package/dist/clipboard-BbGnZskJ.js +0 -31
  440. package/dist/command-format-Clp46jkj.js +0 -38
  441. package/dist/command-format-DELazozB.js +0 -52
  442. package/dist/command-format-SkzzRqR1.js +0 -52
  443. package/dist/command-registry-DZ4hkmA0.js +0 -248
  444. package/dist/commands-DtYZJSPn.js +0 -568
  445. package/dist/commands-Dujk1JmY.js +0 -568
  446. package/dist/commands-registry-Bd0xbvwG.js +0 -766
  447. package/dist/commands-registry-DYfRSVF3.js +0 -766
  448. package/dist/common-D6bu0zHC.js +0 -287
  449. package/dist/common-zW9Y2P1B.js +0 -287
  450. package/dist/completion-cli-tSe7Pmqm.js +0 -431
  451. package/dist/completion-cli-vn4IScs5.js +0 -432
  452. package/dist/config-C8rUDJXY.js +0 -5704
  453. package/dist/config-CLZ_XGVw.js +0 -6523
  454. package/dist/config-SY8M0kM_.js +0 -5705
  455. package/dist/config-cli-1V7D2Wsw.js +0 -247
  456. package/dist/config-cli-CjWEC81L.js +0 -244
  457. package/dist/config-guard-BW2gpKj_.js +0 -93
  458. package/dist/config-guard-BvxuzHpo.js +0 -76
  459. package/dist/config-sync-CoIIbEOe.js +0 -91
  460. package/dist/config-sync-DvAttep0.js +0 -91
  461. package/dist/configure-Bf0oupCE.js +0 -959
  462. package/dist/configure-DRM-7zFf.js +0 -960
  463. package/dist/context-D5iEFzv9.js +0 -60
  464. package/dist/control-service-C8m8F9pr.js +0 -72
  465. package/dist/control-service-DKotCWCg.js +0 -72
  466. package/dist/cron-cli-DB_FLYHD.js +0 -448
  467. package/dist/cron-cli-bxm5lrrO.js +0 -451
  468. package/dist/daemon-cli-1LsOnICv.js +0 -566
  469. package/dist/daemon-cli-CC2NrJ7a.js +0 -565
  470. package/dist/daemon-runtime-BXZhtBL9.js +0 -460
  471. package/dist/daemon-runtime-DW4USC7r.js +0 -460
  472. package/dist/deliver-B4HuPwJA.js +0 -1162
  473. package/dist/deliver-LiY5oL52.js +0 -1097
  474. package/dist/deliver-xrmk7xjh.js +0 -1097
  475. package/dist/delivery-queue-TnQykYsg.js +0 -220
  476. package/dist/deps-CMMOiOsF.js +0 -42
  477. package/dist/devices-cli-Be5he2SA.js +0 -195
  478. package/dist/devices-cli-z6ecoFe9.js +0 -198
  479. package/dist/diagnostics-Dj75aEHN.js +0 -35
  480. package/dist/diagnostics-DlIw6fqD.js +0 -35
  481. package/dist/directory-cli-CEy-0nxj.js +0 -243
  482. package/dist/directory-cli-DpzKcigr.js +0 -246
  483. package/dist/dispatcher-10Shiuz3.js +0 -100
  484. package/dist/dispatcher-3Jae6AiW.js +0 -100
  485. package/dist/dns-cli-Bat1pkc-.js +0 -200
  486. package/dist/dns-cli-NohNyEo0.js +0 -197
  487. package/dist/dock-DbxBBv30.js +0 -753
  488. package/dist/dock-cPBY4qGl.js +0 -753
  489. package/dist/docs-cli-BWp6p-Tq.js +0 -161
  490. package/dist/docs-cli-x22FnZfL.js +0 -159
  491. package/dist/doctor-BrT5m_on.js +0 -1815
  492. package/dist/doctor-Pp2HVnjM.js +0 -1813
  493. package/dist/doctor-completion-DNTimX9o.js +0 -92
  494. package/dist/doctor-completion-ylN9QAJ6.js +0 -92
  495. package/dist/doctor-config-flow-D1w3700T.js +0 -1232
  496. package/dist/doctor-config-flow-Dq50iE1R.js +0 -1232
  497. package/dist/engine-B9avUJL5.js +0 -563
  498. package/dist/engine-BiUQ25D4.js +0 -563
  499. package/dist/env-0lJfCPsw.js +0 -32
  500. package/dist/exec-BenD3A5l.js +0 -1167
  501. package/dist/exec-Bv3pyjeM.js +0 -255
  502. package/dist/exec-approvals-CdLmKX2R.js +0 -1221
  503. package/dist/exec-approvals-cli-DXfV6G8H.js +0 -368
  504. package/dist/exec-approvals-cli-J2cZs10o.js +0 -371
  505. package/dist/frontmatter-YijVi0FQ.js +0 -204
  506. package/dist/gateway-cli-DOAbA0pc.js +0 -19972
  507. package/dist/gateway-cli-QpWtBhQy.js +0 -19971
  508. package/dist/gateway-rpc-DJKBil9s.js +0 -28
  509. package/dist/gateway-rpc-DVterpLP.js +0 -28
  510. package/dist/github-copilot-auth-4IUFp669.js +0 -1418
  511. package/dist/github-copilot-auth-C9E0IROs.js +0 -1418
  512. package/dist/gmail-setup-utils-BPo_LkKI.js +0 -428
  513. package/dist/gmail-setup-utils-D3Yqgor7.js +0 -428
  514. package/dist/health-BeZnqp6m.js +0 -1258
  515. package/dist/health-Cn2OoVWZ.js +0 -1253
  516. package/dist/health-format-CdP99j3Y.js +0 -208
  517. package/dist/health-format-JEChH08S.js +0 -208
  518. package/dist/heartbeat-visibility-BL3WAchI.js +0 -98
  519. package/dist/heartbeat-visibility-CQ9QimI7.js +0 -98
  520. package/dist/help-format-Dl4bsrLI.js +0 -17
  521. package/dist/helpers-ZKNRexvX.js +0 -10
  522. package/dist/hooks-cli-D99hXt7K.js +0 -991
  523. package/dist/hooks-cli-DMB8RiEO.js +0 -993
  524. package/dist/hooks-status-B-e96dZj.js +0 -356
  525. package/dist/hooks-status-C_9sE0ox.js +0 -356
  526. package/dist/image-ops-Dlt3T7th.js +0 -541
  527. package/dist/image-ops-omlvdfah.js +0 -541
  528. package/dist/init-Bm04RagW.js +0 -122
  529. package/dist/init-CaJBf4p1.js +0 -122
  530. package/dist/installs-C2iMRBVz.js +0 -383
  531. package/dist/installs-D-cPGdCw.js +0 -383
  532. package/dist/ipv4-Bf7NS3QU.js +0 -1964
  533. package/dist/ipv4-wWNs8IH_.js +0 -1964
  534. package/dist/lanes-CNxj3tit.js +0 -232
  535. package/dist/lifecycle-core-B_7XRcvF.js +0 -388
  536. package/dist/lifecycle-core-By83PVAK.js +0 -387
  537. package/dist/links-BfjHVTB_.js +0 -15
  538. package/dist/links-DPGe0OHw.js +0 -15
  539. package/dist/logging-DB6BQmhi.js +0 -15
  540. package/dist/logging-mcb66J0p.js +0 -15
  541. package/dist/login-BDCg6D0N.js +0 -61
  542. package/dist/login-BDfnbjnZ.js +0 -59
  543. package/dist/login-BqH1itcg.js +0 -61
  544. package/dist/login-qr-CyOw3R4r.js +0 -321
  545. package/dist/login-qr-D8ECtb72.js +0 -323
  546. package/dist/login-qr-RnR7e4Bw.js +0 -326
  547. package/dist/logs-cli--j89L74J.js +0 -245
  548. package/dist/logs-cli-DpEMg_Gq.js +0 -242
  549. package/dist/manager-B4OyvcxT.js +0 -3244
  550. package/dist/manager-Cqc1CeH7.js +0 -3246
  551. package/dist/manager-DUyQPFvj.js +0 -3244
  552. package/dist/manifest-registry-CW1zCyRF.js +0 -748
  553. package/dist/manifest-registry-D4lM2RdV.js +0 -748
  554. package/dist/markdown-tables-BT1X6jqH.js +0 -347
  555. package/dist/markdown-tables-DHgOK2vI.js +0 -348
  556. package/dist/media-THyainiE.js +0 -1342
  557. package/dist/memory-cli-BKocCWXM.js +0 -868
  558. package/dist/memory-cli-Jmma-xI_.js +0 -869
  559. package/dist/message-channel-dSTVVCyX.js +0 -110
  560. package/dist/migrate-BR6iAIjO.js +0 -157
  561. package/dist/migrate-D0EcMs0f.js +0 -157
  562. package/dist/model-selection-YcSr9CgC.js +0 -2691
  563. package/dist/models-1vUQBVfw.js +0 -2510
  564. package/dist/models-cli-BK3BwUhL.js +0 -2739
  565. package/dist/models-cli-DECrM8oA.js +0 -258
  566. package/dist/net-B5lXhYLV.js +0 -218
  567. package/dist/node-cli-cLHUNpPD.js +0 -1319
  568. package/dist/node-cli-fO7Y132S.js +0 -1322
  569. package/dist/node-service-BFxHJsno.js +0 -67
  570. package/dist/node-service-DUnan4uK.js +0 -67
  571. package/dist/nodes-cli-BCq35E6N.js +0 -1200
  572. package/dist/nodes-cli-vD7MwAKP.js +0 -1197
  573. package/dist/nodes-screen-1YiLkqr5.js +0 -234
  574. package/dist/nodes-screen-DZeD8hE5.js +0 -234
  575. package/dist/note-Bi8Wb8DV.js +0 -73
  576. package/dist/note-uiuPxhyX.js +0 -73
  577. package/dist/npm-registry-spec-B-XIShkB.js +0 -351
  578. package/dist/npm-registry-spec-za3itb5Y.js +0 -351
  579. package/dist/onboard-Ds6w_sWo.js +0 -1165
  580. package/dist/onboard-SAVx3bp4.js +0 -1166
  581. package/dist/onboard-channels-Cg_EkBa4.js +0 -672
  582. package/dist/onboard-channels-D7NbA55V.js +0 -672
  583. package/dist/onboard-helpers-DO_hgZb9.js +0 -365
  584. package/dist/onboard-helpers-_XgJgeqh.js +0 -365
  585. package/dist/onboarding-3hLmDd0r.js +0 -911
  586. package/dist/onboarding-B4LKLsbU.js +0 -910
  587. package/dist/orchestrator-BKzmyBWy.js +0 -357
  588. package/dist/orchestrator-BN3QCz2s.js +0 -357
  589. package/dist/outbound-BgA9hNlP.js +0 -2062
  590. package/dist/outbound-CjdvVhUI.js +0 -214
  591. package/dist/outbound-DOGe6qb2.js +0 -214
  592. package/dist/outbound-send-deps-Du5aBpd7.js +0 -55
  593. package/dist/pairing-cli-2vnyg_Nd.js +0 -118
  594. package/dist/pairing-cli-BH1KQtNV.js +0 -121
  595. package/dist/pairing-store-DJz_9Gv0.js +0 -388
  596. package/dist/pairing-store-DmOzxcuk.js +0 -388
  597. package/dist/path-env-Bu6k0jDQ.js +0 -89
  598. package/dist/path-env-C0zQSjw8.js +0 -89
  599. package/dist/paths-BTc4nk-6.js +0 -126
  600. package/dist/paths-BgUi2Z2G.js +0 -54
  601. package/dist/paths-C6VCWKo3.js +0 -238
  602. package/dist/paths-CCxa0o9c.js +0 -222
  603. package/dist/paths-CxRf2rBG.js +0 -129
  604. package/dist/paths-hcX1Gqg5.js +0 -129
  605. package/dist/pi-auth-json-B68R7q7_.js +0 -82
  606. package/dist/pi-auth-json-CR0jXAgq.js +0 -78
  607. package/dist/pi-auth-json-ZYzi3nxs.js +0 -80
  608. package/dist/pi-model-discovery-Cxs4pvC2.js +0 -3
  609. package/dist/pi-tools.policy-D81U5xy0.js +0 -200
  610. package/dist/pi-tools.policy-DSHkkb5b.js +0 -200
  611. package/dist/plugin-auto-enable-CxF4bpDN.js +0 -282
  612. package/dist/plugin-auto-enable-jNaAeyEh.js +0 -282
  613. package/dist/plugin-registry-C7XWotZG.js +0 -32
  614. package/dist/plugin-registry-DcUCbGax.js +0 -32
  615. package/dist/plugins-B362e77G.js +0 -168
  616. package/dist/plugins-CmSUIUNi.js +0 -38
  617. package/dist/plugins-cli-BsCEnoQ7.js +0 -734
  618. package/dist/plugins-cli-QSIsMUG7.js +0 -736
  619. package/dist/polls-CItfB1H8.js +0 -1343
  620. package/dist/ports-BVLMN1Sr.js +0 -96
  621. package/dist/ports-CqLSlU6Z.js +0 -317
  622. package/dist/ports-D94CwCrv.js +0 -344
  623. package/dist/ports-D_NHthOz.js +0 -96
  624. package/dist/program-DkJHjI0R.js +0 -176
  625. package/dist/program-context-DnyGM2SC.js +0 -496
  626. package/dist/progress-Bek_GyWS.js +0 -133
  627. package/dist/prompt-style-lu0clOOE.js +0 -9
  628. package/dist/pw-ai-BLVMuSLv.js +0 -1867
  629. package/dist/pw-ai-DZJWEF_f.js +0 -1865
  630. package/dist/pw-ai-dzf-ptcn.js +0 -1868
  631. package/dist/qmd-manager-Cur_Ekn0.js +0 -937
  632. package/dist/qmd-manager-DNAUuwjK.js +0 -938
  633. package/dist/qmd-manager-DepEoASu.js +0 -935
  634. package/dist/register.agent-CSWvzOkR.js +0 -265
  635. package/dist/register.agent-UeH2NXmH.js +0 -1003
  636. package/dist/register.anima-DOdee0dh.js +0 -193
  637. package/dist/register.anima-HHDWsz6r.js +0 -193
  638. package/dist/register.configure-CSJFxdz9.js +0 -103
  639. package/dist/register.configure-D84Fvcz4.js +0 -101
  640. package/dist/register.maintenance-B3pvNbZb.js +0 -543
  641. package/dist/register.maintenance-BKVOwkw6.js +0 -543
  642. package/dist/register.message-BAO6CPl2.js +0 -657
  643. package/dist/register.message-OXoOKE_6.js +0 -660
  644. package/dist/register.onboard-BK_ixVmD.js +0 -170
  645. package/dist/register.onboard-cfCaPx6j.js +0 -170
  646. package/dist/register.setup-BGfDnzph.js +0 -175
  647. package/dist/register.setup-Y-Q74M-0.js +0 -175
  648. package/dist/register.status-health-sessions-CT14eitH.js +0 -142
  649. package/dist/register.status-health-sessions-TfZMzAUn.js +0 -313
  650. package/dist/register.subclis-BZwdlNHC.js +0 -255
  651. package/dist/reply-mlsExaZm.js +0 -32212
  652. package/dist/reply-prefix-B0CfR4bM.js +0 -100
  653. package/dist/reply-prefix-w4a39ybC.js +0 -100
  654. package/dist/reply-qalRISe_.js +0 -32212
  655. package/dist/routes-CENsHJyg.js +0 -1820
  656. package/dist/routes-DO0HqW2e.js +0 -1820
  657. package/dist/rpc-C0pjNhBi.js +0 -70
  658. package/dist/rpc-DZ44PIXE.js +0 -70
  659. package/dist/run-main-BMpKw8Mp.js +0 -371
  660. package/dist/runtime-guard-BSUFiAQV.js +0 -60
  661. package/dist/sandbox-BIGfMYEI.js +0 -858
  662. package/dist/sandbox-DxP3IpUP.js +0 -859
  663. package/dist/sandbox-cli-DtLGH8sL.js +0 -461
  664. package/dist/sandbox-cli-_Tg7lfJ_.js +0 -458
  665. package/dist/security-cli-BRwgbedo.js +0 -462
  666. package/dist/security-cli-D3bSuyZt.js +0 -465
  667. package/dist/server-context-49XFFxFg.js +0 -824
  668. package/dist/server-context-LrlgrZzS.js +0 -824
  669. package/dist/server-node-events-Dm52i7NW.js +0 -231
  670. package/dist/server-node-events-QX523UyF.js +0 -233
  671. package/dist/service-BNVpYcQe.js +0 -642
  672. package/dist/service-D56aMXUB.js +0 -642
  673. package/dist/service-audit-D0X_XAB2.js +0 -488
  674. package/dist/service-audit-qmf6XMmP.js +0 -488
  675. package/dist/session-CrQQLLhx.js +0 -179
  676. package/dist/session-LocsOOWJ.js +0 -181
  677. package/dist/session-Vlce2BAT.js +0 -181
  678. package/dist/session-cost-usage-BwiTZuKl.js +0 -600
  679. package/dist/session-cost-usage-DT9YNXTJ.js +0 -600
  680. package/dist/sessions-BfV53TbG.js +0 -1296
  681. package/dist/sessions-BimpX_km.js +0 -180
  682. package/dist/sessions-DcXpzig0.js +0 -1296
  683. package/dist/sessions-Wd18dukK.js +0 -2038
  684. package/dist/shared-Bsr69u_7.js +0 -77
  685. package/dist/shared-Cgly1vPb.js +0 -66
  686. package/dist/shared-JOo05hST.js +0 -66
  687. package/dist/shared-f7dvQsi7.js +0 -77
  688. package/dist/skill-scanner-CkaVLABv.js +0 -263
  689. package/dist/skills-B-G7UHOa.js +0 -808
  690. package/dist/skills-B5LQx4lT.js +0 -807
  691. package/dist/skills-cli-DUGe2ZWW.js +0 -286
  692. package/dist/skills-cli-DtOk0bvK.js +0 -289
  693. package/dist/skills-status-Clq9ZnYu.js +0 -166
  694. package/dist/skills-status-JQluhU-P.js +0 -166
  695. package/dist/sqlite-BukcjdJa.js +0 -321
  696. package/dist/sqlite-CGcOZZ0C.js +0 -368
  697. package/dist/sqlite-Ck6f9KWc.js +0 -453
  698. package/dist/start--xmSFepB.js +0 -372
  699. package/dist/start-BdlZbqrr.js +0 -371
  700. package/dist/status-BgoeFm6g.js +0 -2137
  701. package/dist/status-BjjDrUq7.js +0 -27
  702. package/dist/status-Ct0DgOZ-.js +0 -2132
  703. package/dist/status-RA_uNmK0.js +0 -27
  704. package/dist/status.update-BjOH3GlS.js +0 -79
  705. package/dist/status.update-DLU1qBf0.js +0 -79
  706. package/dist/subagent-registry-9RLdKxES.js +0 -2760
  707. package/dist/subagent-registry-Byuex3zp.js +0 -2759
  708. package/dist/subagent-registry-DOBunBYS.js +0 -14
  709. package/dist/subsystem-Dowf8fSU.js +0 -860
  710. package/dist/system-cli-C5oBpzni.js +0 -79
  711. package/dist/system-cli-DXNKD_Id.js +0 -82
  712. package/dist/systemd-BSrHDyeU.js +0 -452
  713. package/dist/systemd-By5xdSB4.js +0 -452
  714. package/dist/systemd-hints-BtjL_5Rh.js +0 -36
  715. package/dist/systemd-hints-sJmr6cjb.js +0 -36
  716. package/dist/systemd-linger-CTmV2Gci.js +0 -75
  717. package/dist/systemd-linger-CmyqQkeC.js +0 -75
  718. package/dist/table-BL0lJzsm.js +0 -279
  719. package/dist/table-DoiRPsn0.js +0 -279
  720. package/dist/timeout-CswI_K-U.js +0 -232
  721. package/dist/tokens-C-X7wDKj.js +0 -14
  722. package/dist/tokens-DkvqA72p.js +0 -14
  723. package/dist/trash-BJLK1vMn.js +0 -23
  724. package/dist/trash-_x5UZ94k.js +0 -23
  725. package/dist/tui-BHjxDFZC.js +0 -3894
  726. package/dist/tui-CgOocwN8.js +0 -3894
  727. package/dist/tui-cli-5ANH8dE5.js +0 -47
  728. package/dist/tui-cli-BQ4P-JW_.js +0 -50
  729. package/dist/update-LFgxHHPd.js +0 -317
  730. package/dist/update-TxptCqk7.js +0 -317
  731. package/dist/update-check-CWc7YXmc.js +0 -400
  732. package/dist/update-check-IhlWaui6.js +0 -400
  733. package/dist/update-cli-PtXU62w7.js +0 -1105
  734. package/dist/update-cli-Va0EtETG.js +0 -1105
  735. package/dist/update-runner-BLeKFkiB.js +0 -894
  736. package/dist/update-runner-Iuzpc-_y.js +0 -894
  737. package/dist/usage-ApGvBLVg.js +0 -4516
  738. package/dist/utils-Bsw__U-F.js +0 -243
  739. package/dist/web-B6_Ky60G.js +0 -63
  740. package/dist/web-EZLQEWXY.js +0 -46842
  741. package/dist/web-pec8YJUX.js +0 -2203
  742. package/dist/webhooks-cli-BYQKTHTp.js +0 -319
  743. package/dist/webhooks-cli-C2_xtsUQ.js +0 -316
  744. package/dist/whatsapp-actions-C72VCq8f.js +0 -49
  745. package/dist/whatsapp-actions-Ck9Uv0Nw.js +0 -45
  746. package/dist/whatsapp-actions-D0reTj2k.js +0 -53
  747. package/dist/widearea-dns-B6ocX23x.js +0 -127
  748. package/dist/widearea-dns-NsEUNYwz.js +0 -127
  749. package/dist/workspace-Dcfoy5JJ.js +0 -649
  750. package/dist/ws-log-N8R5MvGE.js +0 -267
  751. package/dist/ws-log-gwFxPxj5.js +0 -267
  752. /package/dist/{auto-update-CUeF99gI.js → auto-update-CpF0fycd.js} +0 -0
  753. /package/dist/{auto-update-cgkp9ZTJ.js → auto-update-DNWdO7uF.js} +0 -0
  754. /package/dist/{brew-CVZkr0GU.js → brew-nqf_MiE4.js} +0 -0
  755. /package/dist/{budget-DxYQSekw.js → budget-CPedI-qW.js} +0 -0
  756. /package/dist/{budget-BWBp8Res.js → budget-CRpvqDRX.js} +0 -0
  757. /package/dist/{cli-utils-DtAxdCte.js → cli-utils-C1YHVD4o.js} +0 -0
  758. /package/dist/{command-options-CSbuuqHr.js → command-options-BbponVnw.js} +0 -0
  759. /package/dist/{command-options-Cp1tf96a.js → command-options-s0gnvXnS.js} +0 -0
  760. /package/dist/{constants-O8yBqCBv.js → constants-Dhb6zSIV.js} +0 -0
  761. /package/dist/{dangerous-tools-5ObDWy1N.js → dangerous-tools-DGTtJ_JR.js} +0 -0
  762. /package/dist/{dangerous-tools-Jwr7jqNw.js → dangerous-tools-DxrfTOfT.js} +0 -0
  763. /package/dist/{delivery-queue-B6IHz4Ry.js → delivery-queue-Bxm0nzw7.js} +0 -0
  764. /package/dist/{display-BDOsXu8F.js → display-Jy3UdGzA.js} +0 -0
  765. /package/dist/{errors-CHow2wtt.js → errors-CKaCqKga.js} +0 -0
  766. /package/dist/{exec-BizYYQgP.js → exec-DDmuVVNq.js} +0 -0
  767. /package/dist/{format-Mq6iU0_5.js → format-ByEjgyTF.js} +0 -0
  768. /package/dist/{format-duration-DhWzz_5b.js → format-duration-Aaj5tjJd.js} +0 -0
  769. /package/dist/{format-relative-C6kUHuOj.js → format-relative-79_Y1n2Y.js} +0 -0
  770. /package/dist/{help-format-DUBI91Ti.js → help-format-BMKzarov.js} +0 -0
  771. /package/dist/{helpers-eJFa4K6r.js → helpers-DpEB9Mh0.js} +0 -0
  772. /package/dist/{helpers-DLgbkcEn.js → helpers-FMld9sBT.js} +0 -0
  773. /package/dist/{input-provenance-DJBdpeKk.js → input-provenance-Cy_KnBlP.js} +0 -0
  774. /package/dist/{is-main-Dt9DTcH1.js → is-main-yjaVwMtJ.js} +0 -0
  775. /package/dist/{loader-l2OBdJ8x.js → loader-Br7Vr0zn.js} +0 -0
  776. /package/dist/{loader-BoYxRfcW.js → loader-CkmOrXcC.js} +0 -0
  777. /package/dist/{logging-BdnOSVPD.js → logging-CY-Q5cwf.js} +0 -0
  778. /package/dist/{message-channel-w4F2b2F6.js → message-channel-dua8OOGJ.js} +0 -0
  779. /package/dist/{mime-B1ZoR53M.js → mime-CBg4KybI.js} +0 -0
  780. /package/dist/{model-param-b-DPwyNGn8.js → model-param-b-DW9f0NN8.js} +0 -0
  781. /package/dist/{node-match-8XZnaid6.js → node-match-BV8bTBd4.js} +0 -0
  782. /package/dist/{normalize-GDK8JTNW.js → normalize-_lmlBOW9.js} +0 -0
  783. /package/dist/{openclaw-root-C85WMnVV.js → openclaw-root-JPvmPTf7.js} +0 -0
  784. /package/dist/{outbound-send-deps-ANnAhImn.js → outbound-send-deps-BfUvuWGa.js} +0 -0
  785. /package/dist/{parse-6-2MDhdT.js → parse-CZRwKocn.js} +0 -0
  786. /package/dist/{parse-log-line-Bqh1SSzC.js → parse-log-line-CvrZEK6A.js} +0 -0
  787. /package/dist/{parse-log-line-DUZCjXbl.js → parse-log-line-mLdat0AH.js} +0 -0
  788. /package/dist/{parse-port-BKB9Exlg.js → parse-port-BSOOdo7I.js} +0 -0
  789. /package/dist/{parse-port-DrfvwwiL.js → parse-port-Y0NK62x1.js} +0 -0
  790. /package/dist/{parse-timeout-Di_tcEmi.js → parse-timeout-DVPQ3n9j.js} +0 -0
  791. /package/dist/{paths-DcVEkYX5.js → paths-DHjlJ6cn.js} +0 -0
  792. /package/dist/{pi-model-discovery-DsRqYJLy.js → pi-model-discovery-DzEIEgHL.js} +0 -0
  793. /package/dist/{plugins-CDJw924T.js → plugins-D6PBOdkn.js} +0 -0
  794. /package/dist/{program-context-Bvn8046-.js → program-context-Q1hkT73c.js} +0 -0
  795. /package/dist/{progress-CbZ2D53A.js → progress-C9Ha1NJh.js} +0 -0
  796. /package/dist/{prompt-style-DKy6qQxR.js → prompt-style-DQi8j03a.js} +0 -0
  797. /package/dist/{prompts-BI__va99.js → prompts-BEHxUC3w.js} +0 -0
  798. /package/dist/{prompts-_dDWkCAz.js → prompts-CSOhuiqe.js} +0 -0
  799. /package/dist/{queue-D_u34pbL.js → queue-BJGo7kAB.js} +0 -0
  800. /package/dist/{queue-PG591iID.js → queue-DYgUbdoq.js} +0 -0
  801. /package/dist/{redact-ClVwO7Nn.js → redact-CyKvdFrg.js} +0 -0
  802. /package/dist/{registry-Bs_DJK9E.js → registry-C5MAYD4V.js} +0 -0
  803. /package/dist/{registry-D_zlP1U-.js → registry-CRrXXVs0.js} +0 -0
  804. /package/dist/{requirements-BzZxj2Wu.js → requirements-CGkxTCu4.js} +0 -0
  805. /package/dist/{requirements-DIW1svgA.js → requirements-CIDaOcbO.js} +0 -0
  806. /package/dist/{runtime-guard-DeOXA_86.js → runtime-guard-nL3Lp8T-.js} +0 -0
  807. /package/dist/{secret-equal-Dghy3xsA.js → secret-equal-DJpmLXlG.js} +0 -0
  808. /package/dist/{send-BhAfdGII.js → send-CTcxgDDU.js} +0 -0
  809. /package/dist/{send-ga9udK1_.js → send-DPezUR3-.js} +0 -0
  810. /package/dist/{send-C2t9xpXI.js → send-DZQTaG7-.js} +0 -0
  811. /package/dist/{send-DigO-i9j.js → send-VDff2gra.js} +0 -0
  812. /package/dist/{send-Dz2BDHll.js → send-bgQNV8d1.js} +0 -0
  813. /package/dist/{session-key-BGiG_JcT.js → session-key-CQT-NR6w.js} +0 -0
  814. /package/dist/{shell-argv-CAq1mLa2.js → shell-argv-n9IueeJQ.js} +0 -0
  815. /package/dist/{skill-scanner-Coo4QoCd.js → skill-scanner-o6NgVMD9.js} +0 -0
  816. /package/dist/{status-CMnlcBVc.js → status-C53kTIXF.js} +0 -0
  817. /package/dist/{status-tDZPwewW.js → status-CZDDA_Sy.js} +0 -0
  818. /package/dist/{system-run-command-X9lDJIy0.js → system-run-command-BCjUffN9.js} +0 -0
  819. /package/dist/{system-run-command-DGk7dwQP.js → system-run-command-CqAqKL9K.js} +0 -0
  820. /package/dist/{tailnet-CuiNECdL.js → tailnet-Ciwjv243.js} +0 -0
  821. /package/dist/{templates-CeYJjVzw.js → templates-37RKpACb.js} +0 -0
  822. /package/dist/{templates-I3Z0xplD.js → templates-DPalk30o.js} +0 -0
  823. /package/dist/{thinking-BXEswx1X.js → thinking-2hxwmvTl.js} +0 -0
  824. /package/dist/{transcript-events-C1hdue6u.js → transcript-events-Bp7fGnwv.js} +0 -0
  825. /package/dist/{transcript-tools-DuyYOkUq.js → transcript-tools-D4Lbxlka.js} +0 -0
  826. /package/dist/{usage-format-BAirWUSO.js → usage-format-6Uar63S0.js} +0 -0
  827. /package/dist/{utils-C9sj30YY.js → utils-DT8uXjFS.js} +0 -0
  828. /package/dist/{wsl-CqyuRvtM.js → wsl-CrPvx2kZ.js} +0 -0
  829. /package/dist/{wsl-ymJYvc9Q.js → wsl-UvJ5dHah.js} +0 -0
@@ -0,0 +1,2691 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
2
+ import { g as resolveStateDir, h as resolveOAuthPath } from "./paths-BMuHNFxg.js";
3
+ import { t as createSubsystemLogger } from "./subsystem-DfKstnEK.js";
4
+ import { b as resolveUserPath } from "./utils-DZ8pnOD5.js";
5
+ import { n as DEFAULT_AGENT_ID } from "./session-key-DxcgHezu.js";
6
+ import { a as resolveAgentModelPrimary } from "./agent-scope-CPphqq-U.js";
7
+ import { t as formatCliCommand } from "./command-format-CVL4K5cj.js";
8
+ import { t as isTruthyEnvValue } from "./env-v6411I8h.js";
9
+ import fs from "node:fs";
10
+ import path from "node:path";
11
+ import fs$1 from "node:fs/promises";
12
+ import { execFileSync, execSync } from "node:child_process";
13
+ import { createHash, randomBytes, randomUUID } from "node:crypto";
14
+ import { getEnvApiKey, getOAuthApiKey, getOAuthProviders } from "@mariozechner/pi-ai";
15
+
16
+ //#region src/agents/defaults.ts
17
+ const DEFAULT_PROVIDER = "anthropic";
18
+ const DEFAULT_MODEL = "claude-opus-4-6";
19
+ const DEFAULT_CONTEXT_TOKENS = 2e5;
20
+
21
+ //#endregion
22
+ //#region src/agents/auth-profiles/constants.ts
23
+ const AUTH_STORE_VERSION = 1;
24
+ const AUTH_PROFILE_FILENAME = "auth-profiles.json";
25
+ const LEGACY_AUTH_FILENAME = "auth.json";
26
+ const CLAUDE_CLI_PROFILE_ID = "anthropic:claude-cli";
27
+ const CODEX_CLI_PROFILE_ID = "openai-codex:codex-cli";
28
+ const QWEN_CLI_PROFILE_ID = "qwen-portal:qwen-cli";
29
+ const MINIMAX_CLI_PROFILE_ID = "minimax-portal:minimax-cli";
30
+ const AUTH_STORE_LOCK_OPTIONS = {
31
+ retries: {
32
+ retries: 10,
33
+ factor: 2,
34
+ minTimeout: 100,
35
+ maxTimeout: 1e4,
36
+ randomize: true
37
+ },
38
+ stale: 3e4
39
+ };
40
+ const EXTERNAL_CLI_SYNC_TTL_MS = 900 * 1e3;
41
+ const EXTERNAL_CLI_NEAR_EXPIRY_MS = 600 * 1e3;
42
+ const log$1 = createSubsystemLogger("agents/auth-profiles");
43
+
44
+ //#endregion
45
+ //#region src/agents/auth-profiles/display.ts
46
+ function resolveAuthProfileDisplayLabel(params) {
47
+ const { cfg, store, profileId } = params;
48
+ const profile = store.profiles[profileId];
49
+ const email = cfg?.auth?.profiles?.[profileId]?.email?.trim() || (profile && "email" in profile ? profile.email?.trim() : void 0);
50
+ if (email) return `${profileId} (${email})`;
51
+ return profileId;
52
+ }
53
+
54
+ //#endregion
55
+ //#region src/utils/normalize-secret-input.ts
56
+ /**
57
+ * Secret normalization for copy/pasted credentials.
58
+ *
59
+ * Common footgun: line breaks (especially `\r`) embedded in API keys/tokens.
60
+ * We strip line breaks anywhere, then trim whitespace at the ends.
61
+ *
62
+ * Intentionally does NOT remove ordinary spaces inside the string to avoid
63
+ * silently altering "Bearer <token>" style values.
64
+ */
65
+ function normalizeSecretInput(value) {
66
+ if (typeof value !== "string") return "";
67
+ return value.replace(/[\r\n\u2028\u2029]+/g, "").trim();
68
+ }
69
+ function normalizeOptionalSecretInput(value) {
70
+ const normalized = normalizeSecretInput(value);
71
+ return normalized ? normalized : void 0;
72
+ }
73
+
74
+ //#endregion
75
+ //#region src/plugin-sdk/file-lock.ts
76
+ const HELD_LOCKS_KEY = Symbol.for("anima.fileLockHeldLocks");
77
+ function resolveHeldLocks() {
78
+ const proc = process;
79
+ if (!proc[HELD_LOCKS_KEY]) proc[HELD_LOCKS_KEY] = /* @__PURE__ */ new Map();
80
+ return proc[HELD_LOCKS_KEY];
81
+ }
82
+ const HELD_LOCKS = resolveHeldLocks();
83
+ function isAlive(pid) {
84
+ if (!Number.isFinite(pid) || pid <= 0) return false;
85
+ try {
86
+ process.kill(pid, 0);
87
+ return true;
88
+ } catch {
89
+ return false;
90
+ }
91
+ }
92
+ function computeDelayMs(retries, attempt) {
93
+ const base = Math.min(retries.maxTimeout, Math.max(retries.minTimeout, retries.minTimeout * retries.factor ** attempt));
94
+ const jitter = retries.randomize ? 1 + Math.random() : 1;
95
+ return Math.min(retries.maxTimeout, Math.round(base * jitter));
96
+ }
97
+ async function readLockPayload(lockPath) {
98
+ try {
99
+ const raw = await fs$1.readFile(lockPath, "utf8");
100
+ const parsed = JSON.parse(raw);
101
+ if (typeof parsed.pid !== "number" || typeof parsed.createdAt !== "string") return null;
102
+ return {
103
+ pid: parsed.pid,
104
+ createdAt: parsed.createdAt
105
+ };
106
+ } catch {
107
+ return null;
108
+ }
109
+ }
110
+ async function resolveNormalizedFilePath(filePath) {
111
+ const resolved = path.resolve(filePath);
112
+ const dir = path.dirname(resolved);
113
+ await fs$1.mkdir(dir, { recursive: true });
114
+ try {
115
+ const realDir = await fs$1.realpath(dir);
116
+ return path.join(realDir, path.basename(resolved));
117
+ } catch {
118
+ return resolved;
119
+ }
120
+ }
121
+ async function isStaleLock(lockPath, staleMs) {
122
+ const payload = await readLockPayload(lockPath);
123
+ if (payload?.pid && !isAlive(payload.pid)) return true;
124
+ if (payload?.createdAt) {
125
+ const createdAt = Date.parse(payload.createdAt);
126
+ if (!Number.isFinite(createdAt) || Date.now() - createdAt > staleMs) return true;
127
+ }
128
+ try {
129
+ const stat = await fs$1.stat(lockPath);
130
+ return Date.now() - stat.mtimeMs > staleMs;
131
+ } catch {
132
+ return true;
133
+ }
134
+ }
135
+ async function acquireFileLock(filePath, options) {
136
+ const normalizedFile = await resolveNormalizedFilePath(filePath);
137
+ const lockPath = `${normalizedFile}.lock`;
138
+ const held = HELD_LOCKS.get(normalizedFile);
139
+ if (held) {
140
+ held.count += 1;
141
+ return {
142
+ lockPath,
143
+ release: async () => {
144
+ const current = HELD_LOCKS.get(normalizedFile);
145
+ if (!current) return;
146
+ current.count -= 1;
147
+ if (current.count > 0) return;
148
+ HELD_LOCKS.delete(normalizedFile);
149
+ await current.handle.close().catch(() => void 0);
150
+ await fs$1.rm(current.lockPath, { force: true }).catch(() => void 0);
151
+ }
152
+ };
153
+ }
154
+ const attempts = Math.max(1, options.retries.retries + 1);
155
+ for (let attempt = 0; attempt < attempts; attempt += 1) try {
156
+ const handle = await fs$1.open(lockPath, "wx");
157
+ await handle.writeFile(JSON.stringify({
158
+ pid: process.pid,
159
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
160
+ }, null, 2), "utf8");
161
+ HELD_LOCKS.set(normalizedFile, {
162
+ count: 1,
163
+ handle,
164
+ lockPath
165
+ });
166
+ return {
167
+ lockPath,
168
+ release: async () => {
169
+ const current = HELD_LOCKS.get(normalizedFile);
170
+ if (!current) return;
171
+ current.count -= 1;
172
+ if (current.count > 0) return;
173
+ HELD_LOCKS.delete(normalizedFile);
174
+ await current.handle.close().catch(() => void 0);
175
+ await fs$1.rm(current.lockPath, { force: true }).catch(() => void 0);
176
+ }
177
+ };
178
+ } catch (err) {
179
+ if (err.code !== "EEXIST") throw err;
180
+ if (await isStaleLock(lockPath, options.stale)) {
181
+ await fs$1.rm(lockPath, { force: true }).catch(() => void 0);
182
+ continue;
183
+ }
184
+ if (attempt >= attempts - 1) break;
185
+ await new Promise((resolve) => setTimeout(resolve, computeDelayMs(options.retries, attempt)));
186
+ }
187
+ throw new Error(`file lock timeout for ${normalizedFile}`);
188
+ }
189
+ async function withFileLock(filePath, options, fn) {
190
+ const lock = await acquireFileLock(filePath, options);
191
+ try {
192
+ return await fn();
193
+ } finally {
194
+ await lock.release();
195
+ }
196
+ }
197
+
198
+ //#endregion
199
+ //#region src/infra/json-file.ts
200
+ function loadJsonFile(pathname) {
201
+ try {
202
+ if (!fs.existsSync(pathname)) return;
203
+ const raw = fs.readFileSync(pathname, "utf8");
204
+ return JSON.parse(raw);
205
+ } catch {
206
+ return;
207
+ }
208
+ }
209
+ function saveJsonFile(pathname, data) {
210
+ const dir = path.dirname(pathname);
211
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, {
212
+ recursive: true,
213
+ mode: 448
214
+ });
215
+ fs.writeFileSync(pathname, `${JSON.stringify(data, null, 2)}\n`, "utf8");
216
+ fs.chmodSync(pathname, 384);
217
+ }
218
+
219
+ //#endregion
220
+ //#region src/agents/cli-credentials.ts
221
+ const log = createSubsystemLogger("agents/auth-profiles");
222
+ const QWEN_CLI_CREDENTIALS_RELATIVE_PATH = ".qwen/oauth_creds.json";
223
+ const MINIMAX_CLI_CREDENTIALS_RELATIVE_PATH = ".minimax/oauth_creds.json";
224
+ let qwenCliCache = null;
225
+ let minimaxCliCache = null;
226
+ function resolveQwenCliCredentialsPath(homeDir) {
227
+ const baseDir = homeDir ?? resolveUserPath("~");
228
+ return path.join(baseDir, QWEN_CLI_CREDENTIALS_RELATIVE_PATH);
229
+ }
230
+ function resolveMiniMaxCliCredentialsPath(homeDir) {
231
+ const baseDir = homeDir ?? resolveUserPath("~");
232
+ return path.join(baseDir, MINIMAX_CLI_CREDENTIALS_RELATIVE_PATH);
233
+ }
234
+ function readQwenCliCredentials(options) {
235
+ return readPortalCliOauthCredentials(resolveQwenCliCredentialsPath(options?.homeDir), "qwen-portal");
236
+ }
237
+ function readPortalCliOauthCredentials(credPath, provider) {
238
+ const raw = loadJsonFile(credPath);
239
+ if (!raw || typeof raw !== "object") return null;
240
+ const data = raw;
241
+ const accessToken = data.access_token;
242
+ const refreshToken = data.refresh_token;
243
+ const expiresAt = data.expiry_date;
244
+ if (typeof accessToken !== "string" || !accessToken) return null;
245
+ if (typeof refreshToken !== "string" || !refreshToken) return null;
246
+ if (typeof expiresAt !== "number" || !Number.isFinite(expiresAt)) return null;
247
+ return {
248
+ type: "oauth",
249
+ provider,
250
+ access: accessToken,
251
+ refresh: refreshToken,
252
+ expires: expiresAt
253
+ };
254
+ }
255
+ function readMiniMaxCliCredentials(options) {
256
+ return readPortalCliOauthCredentials(resolveMiniMaxCliCredentialsPath(options?.homeDir), "minimax-portal");
257
+ }
258
+ function readQwenCliCredentialsCached(options) {
259
+ const ttlMs = options?.ttlMs ?? 0;
260
+ const now = Date.now();
261
+ const cacheKey = resolveQwenCliCredentialsPath(options?.homeDir);
262
+ if (ttlMs > 0 && qwenCliCache && qwenCliCache.cacheKey === cacheKey && now - qwenCliCache.readAt < ttlMs) return qwenCliCache.value;
263
+ const value = readQwenCliCredentials({ homeDir: options?.homeDir });
264
+ if (ttlMs > 0) qwenCliCache = {
265
+ value,
266
+ readAt: now,
267
+ cacheKey
268
+ };
269
+ return value;
270
+ }
271
+ function readMiniMaxCliCredentialsCached(options) {
272
+ const ttlMs = options?.ttlMs ?? 0;
273
+ const now = Date.now();
274
+ const cacheKey = resolveMiniMaxCliCredentialsPath(options?.homeDir);
275
+ if (ttlMs > 0 && minimaxCliCache && minimaxCliCache.cacheKey === cacheKey && now - minimaxCliCache.readAt < ttlMs) return minimaxCliCache.value;
276
+ const value = readMiniMaxCliCredentials({ homeDir: options?.homeDir });
277
+ if (ttlMs > 0) minimaxCliCache = {
278
+ value,
279
+ readAt: now,
280
+ cacheKey
281
+ };
282
+ return value;
283
+ }
284
+
285
+ //#endregion
286
+ //#region src/agents/auth-profiles/external-cli-sync.ts
287
+ function shallowEqualOAuthCredentials(a, b) {
288
+ if (!a) return false;
289
+ if (a.type !== "oauth") return false;
290
+ return a.provider === b.provider && a.access === b.access && a.refresh === b.refresh && a.expires === b.expires && a.email === b.email && a.enterpriseUrl === b.enterpriseUrl && a.projectId === b.projectId && a.accountId === b.accountId;
291
+ }
292
+ function isExternalProfileFresh(cred, now) {
293
+ if (!cred) return false;
294
+ if (cred.type !== "oauth" && cred.type !== "token") return false;
295
+ if (cred.provider !== "qwen-portal" && cred.provider !== "minimax-portal") return false;
296
+ if (typeof cred.expires !== "number") return true;
297
+ return cred.expires > now + EXTERNAL_CLI_NEAR_EXPIRY_MS;
298
+ }
299
+ /** Sync external CLI credentials into the store for a given provider. */
300
+ function syncExternalCliCredentialsForProvider(store, profileId, provider, readCredentials, now) {
301
+ const existing = store.profiles[profileId];
302
+ const creds = !existing || existing.provider !== provider || !isExternalProfileFresh(existing, now) ? readCredentials() : null;
303
+ if (!creds) return false;
304
+ const existingOAuth = existing?.type === "oauth" ? existing : void 0;
305
+ if ((!existingOAuth || existingOAuth.provider !== provider || existingOAuth.expires <= now || creds.expires > existingOAuth.expires) && !shallowEqualOAuthCredentials(existingOAuth, creds)) {
306
+ store.profiles[profileId] = creds;
307
+ log$1.info(`synced ${provider} credentials from external cli`, {
308
+ profileId,
309
+ expires: new Date(creds.expires).toISOString()
310
+ });
311
+ return true;
312
+ }
313
+ return false;
314
+ }
315
+ /**
316
+ * Sync OAuth credentials from external CLI tools (Qwen Code CLI, MiniMax CLI) into the store.
317
+ *
318
+ * Returns true if any credentials were updated.
319
+ */
320
+ function syncExternalCliCredentials(store) {
321
+ let mutated = false;
322
+ const now = Date.now();
323
+ const existingQwen = store.profiles[QWEN_CLI_PROFILE_ID];
324
+ const qwenCreds = !existingQwen || existingQwen.provider !== "qwen-portal" || !isExternalProfileFresh(existingQwen, now) ? readQwenCliCredentialsCached({ ttlMs: EXTERNAL_CLI_SYNC_TTL_MS }) : null;
325
+ if (qwenCreds) {
326
+ const existing = store.profiles[QWEN_CLI_PROFILE_ID];
327
+ const existingOAuth = existing?.type === "oauth" ? existing : void 0;
328
+ if ((!existingOAuth || existingOAuth.provider !== "qwen-portal" || existingOAuth.expires <= now || qwenCreds.expires > existingOAuth.expires) && !shallowEqualOAuthCredentials(existingOAuth, qwenCreds)) {
329
+ store.profiles[QWEN_CLI_PROFILE_ID] = qwenCreds;
330
+ mutated = true;
331
+ log$1.info("synced qwen credentials from qwen cli", {
332
+ profileId: QWEN_CLI_PROFILE_ID,
333
+ expires: new Date(qwenCreds.expires).toISOString()
334
+ });
335
+ }
336
+ }
337
+ if (syncExternalCliCredentialsForProvider(store, MINIMAX_CLI_PROFILE_ID, "minimax-portal", () => readMiniMaxCliCredentialsCached({ ttlMs: EXTERNAL_CLI_SYNC_TTL_MS }), now)) mutated = true;
338
+ return mutated;
339
+ }
340
+
341
+ //#endregion
342
+ //#region src/agents/agent-paths.ts
343
+ function resolveAnimaAgentDir() {
344
+ const override = process.env.ANIMA_AGENT_DIR?.trim() || process.env.OPENCLAW_AGENT_DIR?.trim() || process.env.PI_CODING_AGENT_DIR?.trim();
345
+ if (override) return resolveUserPath(override);
346
+ return resolveUserPath(path.join(resolveStateDir(), "agents", DEFAULT_AGENT_ID, "agent"));
347
+ }
348
+
349
+ //#endregion
350
+ //#region src/agents/auth-profiles/paths.ts
351
+ function resolveAuthStorePath(agentDir) {
352
+ const resolved = resolveUserPath(agentDir ?? resolveAnimaAgentDir());
353
+ return path.join(resolved, AUTH_PROFILE_FILENAME);
354
+ }
355
+ function resolveLegacyAuthStorePath(agentDir) {
356
+ const resolved = resolveUserPath(agentDir ?? resolveAnimaAgentDir());
357
+ return path.join(resolved, LEGACY_AUTH_FILENAME);
358
+ }
359
+ function resolveAuthStorePathForDisplay(agentDir) {
360
+ const pathname = resolveAuthStorePath(agentDir);
361
+ return pathname.startsWith("~") ? pathname : resolveUserPath(pathname);
362
+ }
363
+ function ensureAuthStoreFile(pathname) {
364
+ if (fs.existsSync(pathname)) return;
365
+ saveJsonFile(pathname, {
366
+ version: AUTH_STORE_VERSION,
367
+ profiles: {}
368
+ });
369
+ }
370
+
371
+ //#endregion
372
+ //#region src/agents/auth-profiles/store.ts
373
+ async function updateAuthProfileStoreWithLock(params) {
374
+ const authPath = resolveAuthStorePath(params.agentDir);
375
+ ensureAuthStoreFile(authPath);
376
+ try {
377
+ return await withFileLock(authPath, AUTH_STORE_LOCK_OPTIONS, async () => {
378
+ const store = ensureAuthProfileStore(params.agentDir);
379
+ if (params.updater(store)) saveAuthProfileStore(store, params.agentDir);
380
+ return store;
381
+ });
382
+ } catch {
383
+ return null;
384
+ }
385
+ }
386
+ function coerceLegacyStore(raw) {
387
+ if (!raw || typeof raw !== "object") return null;
388
+ const record = raw;
389
+ if ("profiles" in record) return null;
390
+ const entries = {};
391
+ for (const [key, value] of Object.entries(record)) {
392
+ if (!value || typeof value !== "object") continue;
393
+ const typed = value;
394
+ if (typed.type !== "api_key" && typed.type !== "oauth" && typed.type !== "token") continue;
395
+ entries[key] = {
396
+ ...typed,
397
+ provider: String(typed.provider ?? key)
398
+ };
399
+ }
400
+ return Object.keys(entries).length > 0 ? entries : null;
401
+ }
402
+ function coerceAuthStore(raw) {
403
+ if (!raw || typeof raw !== "object") return null;
404
+ const record = raw;
405
+ if (!record.profiles || typeof record.profiles !== "object") return null;
406
+ const profiles = record.profiles;
407
+ const normalized = {};
408
+ for (const [key, value] of Object.entries(profiles)) {
409
+ if (!value || typeof value !== "object") continue;
410
+ const typed = value;
411
+ if (typed.type !== "api_key" && typed.type !== "oauth" && typed.type !== "token") continue;
412
+ if (!typed.provider) continue;
413
+ normalized[key] = typed;
414
+ }
415
+ const order = record.order && typeof record.order === "object" ? Object.entries(record.order).reduce((acc, [provider, value]) => {
416
+ if (!Array.isArray(value)) return acc;
417
+ const list = value.map((entry) => typeof entry === "string" ? entry.trim() : "").filter(Boolean);
418
+ if (list.length === 0) return acc;
419
+ acc[provider] = list;
420
+ return acc;
421
+ }, {}) : void 0;
422
+ return {
423
+ version: Number(record.version ?? AUTH_STORE_VERSION),
424
+ profiles: normalized,
425
+ order,
426
+ lastGood: record.lastGood && typeof record.lastGood === "object" ? record.lastGood : void 0,
427
+ usageStats: record.usageStats && typeof record.usageStats === "object" ? record.usageStats : void 0
428
+ };
429
+ }
430
+ function mergeRecord(base, override) {
431
+ if (!base && !override) return;
432
+ if (!base) return { ...override };
433
+ if (!override) return { ...base };
434
+ return {
435
+ ...base,
436
+ ...override
437
+ };
438
+ }
439
+ function mergeAuthProfileStores(base, override) {
440
+ if (Object.keys(override.profiles).length === 0 && !override.order && !override.lastGood && !override.usageStats) return base;
441
+ return {
442
+ version: Math.max(base.version, override.version ?? base.version),
443
+ profiles: {
444
+ ...base.profiles,
445
+ ...override.profiles
446
+ },
447
+ order: mergeRecord(base.order, override.order),
448
+ lastGood: mergeRecord(base.lastGood, override.lastGood),
449
+ usageStats: mergeRecord(base.usageStats, override.usageStats)
450
+ };
451
+ }
452
+ function mergeOAuthFileIntoStore(store) {
453
+ const oauthRaw = loadJsonFile(resolveOAuthPath());
454
+ if (!oauthRaw || typeof oauthRaw !== "object") return false;
455
+ const oauthEntries = oauthRaw;
456
+ let mutated = false;
457
+ for (const [provider, creds] of Object.entries(oauthEntries)) {
458
+ if (!creds || typeof creds !== "object") continue;
459
+ const profileId = `${provider}:default`;
460
+ if (store.profiles[profileId]) continue;
461
+ store.profiles[profileId] = {
462
+ type: "oauth",
463
+ provider,
464
+ ...creds
465
+ };
466
+ mutated = true;
467
+ }
468
+ return mutated;
469
+ }
470
+ function applyLegacyStore(store, legacy) {
471
+ for (const [provider, cred] of Object.entries(legacy)) {
472
+ const profileId = `${provider}:default`;
473
+ if (cred.type === "api_key") {
474
+ store.profiles[profileId] = {
475
+ type: "api_key",
476
+ provider: String(cred.provider ?? provider),
477
+ key: cred.key,
478
+ ...cred.email ? { email: cred.email } : {}
479
+ };
480
+ continue;
481
+ }
482
+ if (cred.type === "token") {
483
+ store.profiles[profileId] = {
484
+ type: "token",
485
+ provider: String(cred.provider ?? provider),
486
+ token: cred.token,
487
+ ...typeof cred.expires === "number" ? { expires: cred.expires } : {},
488
+ ...cred.email ? { email: cred.email } : {}
489
+ };
490
+ continue;
491
+ }
492
+ store.profiles[profileId] = {
493
+ type: "oauth",
494
+ provider: String(cred.provider ?? provider),
495
+ access: cred.access,
496
+ refresh: cred.refresh,
497
+ expires: cred.expires,
498
+ ...cred.enterpriseUrl ? { enterpriseUrl: cred.enterpriseUrl } : {},
499
+ ...cred.projectId ? { projectId: cred.projectId } : {},
500
+ ...cred.accountId ? { accountId: cred.accountId } : {},
501
+ ...cred.email ? { email: cred.email } : {}
502
+ };
503
+ }
504
+ }
505
+ function loadAuthProfileStore() {
506
+ const authPath = resolveAuthStorePath();
507
+ const asStore = coerceAuthStore(loadJsonFile(authPath));
508
+ if (asStore) {
509
+ if (syncExternalCliCredentials(asStore)) saveJsonFile(authPath, asStore);
510
+ return asStore;
511
+ }
512
+ const legacy = coerceLegacyStore(loadJsonFile(resolveLegacyAuthStorePath()));
513
+ if (legacy) {
514
+ const store = {
515
+ version: AUTH_STORE_VERSION,
516
+ profiles: {}
517
+ };
518
+ applyLegacyStore(store, legacy);
519
+ syncExternalCliCredentials(store);
520
+ return store;
521
+ }
522
+ const store = {
523
+ version: AUTH_STORE_VERSION,
524
+ profiles: {}
525
+ };
526
+ syncExternalCliCredentials(store);
527
+ return store;
528
+ }
529
+ function loadAuthProfileStoreForAgent(agentDir, _options) {
530
+ const authPath = resolveAuthStorePath(agentDir);
531
+ const asStore = coerceAuthStore(loadJsonFile(authPath));
532
+ if (asStore) {
533
+ if (syncExternalCliCredentials(asStore)) saveJsonFile(authPath, asStore);
534
+ return asStore;
535
+ }
536
+ if (agentDir) {
537
+ const mainStore = coerceAuthStore(loadJsonFile(resolveAuthStorePath()));
538
+ if (mainStore && Object.keys(mainStore.profiles).length > 0) {
539
+ saveJsonFile(authPath, mainStore);
540
+ log$1.info("inherited auth-profiles from main agent", { agentDir });
541
+ return mainStore;
542
+ }
543
+ }
544
+ const legacy = coerceLegacyStore(loadJsonFile(resolveLegacyAuthStorePath(agentDir)));
545
+ const store = {
546
+ version: AUTH_STORE_VERSION,
547
+ profiles: {}
548
+ };
549
+ if (legacy) applyLegacyStore(store, legacy);
550
+ const mergedOAuth = mergeOAuthFileIntoStore(store);
551
+ const syncedCli = syncExternalCliCredentials(store);
552
+ const shouldWrite = legacy !== null || mergedOAuth || syncedCli;
553
+ if (shouldWrite) saveJsonFile(authPath, store);
554
+ if (shouldWrite && legacy !== null) {
555
+ const legacyPath = resolveLegacyAuthStorePath(agentDir);
556
+ try {
557
+ fs.unlinkSync(legacyPath);
558
+ } catch (err) {
559
+ if (err?.code !== "ENOENT") log$1.warn("failed to delete legacy auth.json after migration", {
560
+ err,
561
+ legacyPath
562
+ });
563
+ }
564
+ }
565
+ return store;
566
+ }
567
+ function ensureAuthProfileStore(agentDir, options) {
568
+ const store = loadAuthProfileStoreForAgent(agentDir, options);
569
+ const authPath = resolveAuthStorePath(agentDir);
570
+ const mainAuthPath = resolveAuthStorePath();
571
+ if (!agentDir || authPath === mainAuthPath) return store;
572
+ return mergeAuthProfileStores(loadAuthProfileStoreForAgent(void 0, options), store);
573
+ }
574
+ function saveAuthProfileStore(store, agentDir) {
575
+ saveJsonFile(resolveAuthStorePath(agentDir), {
576
+ version: AUTH_STORE_VERSION,
577
+ profiles: store.profiles,
578
+ order: store.order ?? void 0,
579
+ lastGood: store.lastGood ?? void 0,
580
+ usageStats: store.usageStats ?? void 0
581
+ });
582
+ }
583
+
584
+ //#endregion
585
+ //#region src/agents/auth-profiles/profiles.ts
586
+ async function setAuthProfileOrder(params) {
587
+ const providerKey = normalizeProviderId(params.provider);
588
+ const sanitized = params.order && Array.isArray(params.order) ? params.order.map((entry) => String(entry).trim()).filter(Boolean) : [];
589
+ const deduped = [];
590
+ for (const entry of sanitized) if (!deduped.includes(entry)) deduped.push(entry);
591
+ return await updateAuthProfileStoreWithLock({
592
+ agentDir: params.agentDir,
593
+ updater: (store) => {
594
+ store.order = store.order ?? {};
595
+ if (deduped.length === 0) {
596
+ if (!store.order[providerKey]) return false;
597
+ delete store.order[providerKey];
598
+ if (Object.keys(store.order).length === 0) store.order = void 0;
599
+ return true;
600
+ }
601
+ store.order[providerKey] = deduped;
602
+ return true;
603
+ }
604
+ });
605
+ }
606
+ function upsertAuthProfile(params) {
607
+ const credential = params.credential.type === "api_key" ? {
608
+ ...params.credential,
609
+ ...typeof params.credential.key === "string" ? { key: normalizeSecretInput(params.credential.key) } : {}
610
+ } : params.credential.type === "token" ? {
611
+ ...params.credential,
612
+ token: normalizeSecretInput(params.credential.token)
613
+ } : params.credential;
614
+ const store = ensureAuthProfileStore(params.agentDir);
615
+ store.profiles[params.profileId] = credential;
616
+ saveAuthProfileStore(store, params.agentDir);
617
+ }
618
+ async function upsertAuthProfileWithLock(params) {
619
+ return await updateAuthProfileStoreWithLock({
620
+ agentDir: params.agentDir,
621
+ updater: (store) => {
622
+ store.profiles[params.profileId] = params.credential;
623
+ return true;
624
+ }
625
+ });
626
+ }
627
+ function listProfilesForProvider(store, provider) {
628
+ const providerKey = normalizeProviderId(provider);
629
+ return Object.entries(store.profiles).filter(([, cred]) => normalizeProviderId(cred.provider) === providerKey).map(([id]) => id);
630
+ }
631
+
632
+ //#endregion
633
+ //#region src/agents/auth-profiles/repair.ts
634
+ function getProfileSuffix(profileId) {
635
+ const idx = profileId.indexOf(":");
636
+ if (idx < 0) return "";
637
+ return profileId.slice(idx + 1);
638
+ }
639
+ function isEmailLike(value) {
640
+ const trimmed = value.trim();
641
+ if (!trimmed) return false;
642
+ return trimmed.includes("@") && trimmed.includes(".");
643
+ }
644
+ function suggestOAuthProfileIdForLegacyDefault(params) {
645
+ const providerKey = normalizeProviderId(params.provider);
646
+ if (getProfileSuffix(params.legacyProfileId) !== "default") return null;
647
+ const legacyCfg = params.cfg?.auth?.profiles?.[params.legacyProfileId];
648
+ if (legacyCfg && normalizeProviderId(legacyCfg.provider) === providerKey && legacyCfg.mode !== "oauth") return null;
649
+ const oauthProfiles = listProfilesForProvider(params.store, providerKey).filter((id) => params.store.profiles[id]?.type === "oauth");
650
+ if (oauthProfiles.length === 0) return null;
651
+ const configuredEmail = legacyCfg?.email?.trim();
652
+ if (configuredEmail) {
653
+ const byEmail = oauthProfiles.find((id) => {
654
+ const cred = params.store.profiles[id];
655
+ if (!cred || cred.type !== "oauth") return false;
656
+ return cred.email?.trim() === configuredEmail || id === `${providerKey}:${configuredEmail}`;
657
+ });
658
+ if (byEmail) return byEmail;
659
+ }
660
+ const lastGood = params.store.lastGood?.[providerKey] ?? params.store.lastGood?.[params.provider];
661
+ if (lastGood && oauthProfiles.includes(lastGood)) return lastGood;
662
+ const nonLegacy = oauthProfiles.filter((id) => id !== params.legacyProfileId);
663
+ if (nonLegacy.length === 1) return nonLegacy[0] ?? null;
664
+ const emailLike = nonLegacy.filter((id) => isEmailLike(getProfileSuffix(id)));
665
+ if (emailLike.length === 1) return emailLike[0] ?? null;
666
+ return null;
667
+ }
668
+ function repairOAuthProfileIdMismatch(params) {
669
+ const legacyProfileId = params.legacyProfileId ?? `${normalizeProviderId(params.provider)}:default`;
670
+ const legacyCfg = params.cfg.auth?.profiles?.[legacyProfileId];
671
+ if (!legacyCfg) return {
672
+ config: params.cfg,
673
+ changes: [],
674
+ migrated: false
675
+ };
676
+ if (legacyCfg.mode !== "oauth") return {
677
+ config: params.cfg,
678
+ changes: [],
679
+ migrated: false
680
+ };
681
+ if (normalizeProviderId(legacyCfg.provider) !== normalizeProviderId(params.provider)) return {
682
+ config: params.cfg,
683
+ changes: [],
684
+ migrated: false
685
+ };
686
+ const toProfileId = suggestOAuthProfileIdForLegacyDefault({
687
+ cfg: params.cfg,
688
+ store: params.store,
689
+ provider: params.provider,
690
+ legacyProfileId
691
+ });
692
+ if (!toProfileId || toProfileId === legacyProfileId) return {
693
+ config: params.cfg,
694
+ changes: [],
695
+ migrated: false
696
+ };
697
+ const toCred = params.store.profiles[toProfileId];
698
+ const toEmail = toCred?.type === "oauth" ? toCred.email?.trim() : void 0;
699
+ const nextProfiles = { ...params.cfg.auth?.profiles };
700
+ delete nextProfiles[legacyProfileId];
701
+ nextProfiles[toProfileId] = {
702
+ ...legacyCfg,
703
+ ...toEmail ? { email: toEmail } : {}
704
+ };
705
+ const providerKey = normalizeProviderId(params.provider);
706
+ const nextOrder = (() => {
707
+ const order = params.cfg.auth?.order;
708
+ if (!order) return;
709
+ const resolvedKey = Object.keys(order).find((key) => normalizeProviderId(key) === providerKey);
710
+ if (!resolvedKey) return order;
711
+ const existing = order[resolvedKey];
712
+ if (!Array.isArray(existing)) return order;
713
+ const replaced = existing.map((id) => id === legacyProfileId ? toProfileId : id).filter((id) => typeof id === "string" && id.trim().length > 0);
714
+ const deduped = [];
715
+ for (const entry of replaced) if (!deduped.includes(entry)) deduped.push(entry);
716
+ return {
717
+ ...order,
718
+ [resolvedKey]: deduped
719
+ };
720
+ })();
721
+ return {
722
+ config: {
723
+ ...params.cfg,
724
+ auth: {
725
+ ...params.cfg.auth,
726
+ profiles: nextProfiles,
727
+ ...nextOrder ? { order: nextOrder } : {}
728
+ }
729
+ },
730
+ changes: [`Auth: migrate ${legacyProfileId} → ${toProfileId} (OAuth profile id)`],
731
+ migrated: true,
732
+ fromProfileId: legacyProfileId,
733
+ toProfileId
734
+ };
735
+ }
736
+
737
+ //#endregion
738
+ //#region src/agents/auth-profiles/doctor.ts
739
+ function formatAuthDoctorHint(params) {
740
+ const providerKey = normalizeProviderId(params.provider);
741
+ if (providerKey !== "anthropic") return "";
742
+ const legacyProfileId = params.profileId ?? "anthropic:default";
743
+ const suggested = suggestOAuthProfileIdForLegacyDefault({
744
+ cfg: params.cfg,
745
+ store: params.store,
746
+ provider: providerKey,
747
+ legacyProfileId
748
+ });
749
+ if (!suggested || suggested === legacyProfileId) return "";
750
+ const storeOauthProfiles = listProfilesForProvider(params.store, providerKey).filter((id) => params.store.profiles[id]?.type === "oauth").join(", ");
751
+ const cfgMode = params.cfg?.auth?.profiles?.[legacyProfileId]?.mode;
752
+ const cfgProvider = params.cfg?.auth?.profiles?.[legacyProfileId]?.provider;
753
+ return [
754
+ "Doctor hint (for GitHub issue):",
755
+ `- provider: ${providerKey}`,
756
+ `- config: ${legacyProfileId}${cfgProvider || cfgMode ? ` (provider=${cfgProvider ?? "?"}, mode=${cfgMode ?? "?"})` : ""}`,
757
+ `- auth store oauth profiles: ${storeOauthProfiles || "(none)"}`,
758
+ `- suggested profile: ${suggested}`,
759
+ `Fix: run "${formatCliCommand("anima doctor --yes")}"`
760
+ ].join("\n");
761
+ }
762
+
763
+ //#endregion
764
+ //#region src/providers/qwen-portal-oauth.ts
765
+ async function refreshQwenPortalCredentials(_opts) {
766
+ return null;
767
+ }
768
+
769
+ //#endregion
770
+ //#region src/agents/chutes-oauth.ts
771
+ const CHUTES_OAUTH_ISSUER = "https://api.chutes.ai";
772
+ const CHUTES_AUTHORIZE_ENDPOINT = `${CHUTES_OAUTH_ISSUER}/idp/authorize`;
773
+ const CHUTES_TOKEN_ENDPOINT = `${CHUTES_OAUTH_ISSUER}/idp/token`;
774
+ const CHUTES_USERINFO_ENDPOINT = `${CHUTES_OAUTH_ISSUER}/idp/userinfo`;
775
+ const DEFAULT_EXPIRES_BUFFER_MS = 300 * 1e3;
776
+ function generateChutesPkce() {
777
+ const verifier = randomBytes(32).toString("hex");
778
+ return {
779
+ verifier,
780
+ challenge: createHash("sha256").update(verifier).digest("base64url")
781
+ };
782
+ }
783
+ function parseOAuthCallbackInput(input, expectedState) {
784
+ const trimmed = input.trim();
785
+ if (!trimmed) return { error: "No input provided" };
786
+ let url;
787
+ try {
788
+ url = new URL(trimmed);
789
+ } catch {
790
+ if (!/\s/.test(trimmed) && !trimmed.includes("://") && !trimmed.includes("?") && !trimmed.includes("=")) return { error: "Paste the full redirect URL (must include code + state)." };
791
+ const qs = trimmed.startsWith("?") ? trimmed : `?${trimmed}`;
792
+ try {
793
+ url = new URL(`http://localhost/${qs}`);
794
+ } catch {
795
+ return { error: "Paste the full redirect URL (must include code + state)." };
796
+ }
797
+ }
798
+ const code = url.searchParams.get("code")?.trim();
799
+ const state = url.searchParams.get("state")?.trim();
800
+ if (!code) return { error: "Missing 'code' parameter in URL" };
801
+ if (!state) return { error: "Missing 'state' parameter. Paste the full redirect URL." };
802
+ if (state !== expectedState) return { error: "OAuth state mismatch - possible CSRF attack. Please retry login." };
803
+ return {
804
+ code,
805
+ state
806
+ };
807
+ }
808
+ function coerceExpiresAt(expiresInSeconds, now) {
809
+ const value = now + Math.max(0, Math.floor(expiresInSeconds)) * 1e3 - DEFAULT_EXPIRES_BUFFER_MS;
810
+ return Math.max(value, now + 3e4);
811
+ }
812
+ async function fetchChutesUserInfo(params) {
813
+ const response = await (params.fetchFn ?? fetch)(CHUTES_USERINFO_ENDPOINT, { headers: { Authorization: `Bearer ${params.accessToken}` } });
814
+ if (!response.ok) return null;
815
+ const data = await response.json();
816
+ if (!data || typeof data !== "object") return null;
817
+ return data;
818
+ }
819
+ async function exchangeChutesCodeForTokens(params) {
820
+ const fetchFn = params.fetchFn ?? fetch;
821
+ const now = params.now ?? Date.now();
822
+ const body = new URLSearchParams({
823
+ grant_type: "authorization_code",
824
+ client_id: params.app.clientId,
825
+ code: params.code,
826
+ redirect_uri: params.app.redirectUri,
827
+ code_verifier: params.codeVerifier
828
+ });
829
+ if (params.app.clientSecret) body.set("client_secret", params.app.clientSecret);
830
+ const response = await fetchFn(CHUTES_TOKEN_ENDPOINT, {
831
+ method: "POST",
832
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
833
+ body
834
+ });
835
+ if (!response.ok) {
836
+ const text = await response.text();
837
+ throw new Error(`Chutes token exchange failed: ${text}`);
838
+ }
839
+ const data = await response.json();
840
+ const access = data.access_token?.trim();
841
+ const refresh = data.refresh_token?.trim();
842
+ const expiresIn = data.expires_in ?? 0;
843
+ if (!access) throw new Error("Chutes token exchange returned no access_token");
844
+ if (!refresh) throw new Error("Chutes token exchange returned no refresh_token");
845
+ const info = await fetchChutesUserInfo({
846
+ accessToken: access,
847
+ fetchFn
848
+ });
849
+ return {
850
+ access,
851
+ refresh,
852
+ expires: coerceExpiresAt(expiresIn, now),
853
+ email: info?.username,
854
+ accountId: info?.sub,
855
+ clientId: params.app.clientId
856
+ };
857
+ }
858
+ async function refreshChutesTokens(params) {
859
+ const fetchFn = params.fetchFn ?? fetch;
860
+ const now = params.now ?? Date.now();
861
+ const refreshToken = params.credential.refresh?.trim();
862
+ if (!refreshToken) throw new Error("Chutes OAuth credential is missing refresh token");
863
+ const clientId = params.credential.clientId?.trim() ?? process.env.CHUTES_CLIENT_ID?.trim();
864
+ if (!clientId) throw new Error("Missing CHUTES_CLIENT_ID for Chutes OAuth refresh (set env var or re-auth).");
865
+ const clientSecret = process.env.CHUTES_CLIENT_SECRET?.trim() || void 0;
866
+ const body = new URLSearchParams({
867
+ grant_type: "refresh_token",
868
+ client_id: clientId,
869
+ refresh_token: refreshToken
870
+ });
871
+ if (clientSecret) body.set("client_secret", clientSecret);
872
+ const response = await fetchFn(CHUTES_TOKEN_ENDPOINT, {
873
+ method: "POST",
874
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
875
+ body
876
+ });
877
+ if (!response.ok) {
878
+ const text = await response.text();
879
+ throw new Error(`Chutes token refresh failed: ${text}`);
880
+ }
881
+ const data = await response.json();
882
+ const access = data.access_token?.trim();
883
+ const newRefresh = data.refresh_token?.trim();
884
+ const expiresIn = data.expires_in ?? 0;
885
+ if (!access) throw new Error("Chutes token refresh returned no access_token");
886
+ return {
887
+ ...params.credential,
888
+ access,
889
+ refresh: newRefresh || refreshToken,
890
+ expires: coerceExpiresAt(expiresIn, now),
891
+ clientId
892
+ };
893
+ }
894
+
895
+ //#endregion
896
+ //#region src/agents/auth-profiles/oauth.ts
897
+ const OAUTH_PROVIDER_IDS = new Set(getOAuthProviders().map((provider) => provider.id));
898
+ const isOAuthProvider = (provider) => OAUTH_PROVIDER_IDS.has(provider);
899
+ const resolveOAuthProvider = (provider) => isOAuthProvider(provider) ? provider : null;
900
+ function buildOAuthApiKey(provider, credentials) {
901
+ return provider === "google-gemini-cli" || provider === "google-antigravity" ? JSON.stringify({
902
+ token: credentials.access,
903
+ projectId: credentials.projectId
904
+ }) : credentials.access;
905
+ }
906
+ async function refreshOAuthTokenWithLock(params) {
907
+ const authPath = resolveAuthStorePath(params.agentDir);
908
+ ensureAuthStoreFile(authPath);
909
+ return await withFileLock(authPath, AUTH_STORE_LOCK_OPTIONS, async () => {
910
+ const store = ensureAuthProfileStore(params.agentDir);
911
+ const cred = store.profiles[params.profileId];
912
+ if (!cred || cred.type !== "oauth") return null;
913
+ if (Date.now() < cred.expires) return {
914
+ apiKey: buildOAuthApiKey(cred.provider, cred),
915
+ newCredentials: cred
916
+ };
917
+ const oauthCreds = { [cred.provider]: cred };
918
+ const result = String(cred.provider) === "chutes" ? await (async () => {
919
+ const newCredentials = await refreshChutesTokens({ credential: cred });
920
+ return {
921
+ apiKey: newCredentials.access,
922
+ newCredentials
923
+ };
924
+ })() : String(cred.provider) === "qwen-portal" ? await (async () => {
925
+ const newCredentials = await refreshQwenPortalCredentials(cred);
926
+ return {
927
+ apiKey: newCredentials.access,
928
+ newCredentials
929
+ };
930
+ })() : await (async () => {
931
+ const oauthProvider = resolveOAuthProvider(cred.provider);
932
+ if (!oauthProvider) return null;
933
+ return await getOAuthApiKey(oauthProvider, oauthCreds);
934
+ })();
935
+ if (!result) return null;
936
+ store.profiles[params.profileId] = {
937
+ ...cred,
938
+ ...result.newCredentials,
939
+ type: "oauth"
940
+ };
941
+ saveAuthProfileStore(store, params.agentDir);
942
+ return result;
943
+ });
944
+ }
945
+ async function tryResolveOAuthProfile(params) {
946
+ const { cfg, store, profileId } = params;
947
+ const cred = store.profiles[profileId];
948
+ if (!cred || cred.type !== "oauth") return null;
949
+ const profileConfig = cfg?.auth?.profiles?.[profileId];
950
+ if (profileConfig && profileConfig.provider !== cred.provider) return null;
951
+ if (profileConfig && profileConfig.mode !== cred.type) return null;
952
+ if (Date.now() < cred.expires) return {
953
+ apiKey: buildOAuthApiKey(cred.provider, cred),
954
+ provider: cred.provider,
955
+ email: cred.email
956
+ };
957
+ const refreshed = await refreshOAuthTokenWithLock({
958
+ profileId,
959
+ agentDir: params.agentDir
960
+ });
961
+ if (!refreshed) return null;
962
+ return {
963
+ apiKey: refreshed.apiKey,
964
+ provider: cred.provider,
965
+ email: cred.email
966
+ };
967
+ }
968
+ async function resolveApiKeyForProfile(params) {
969
+ const { cfg, store, profileId } = params;
970
+ const cred = store.profiles[profileId];
971
+ if (!cred) return null;
972
+ const profileConfig = cfg?.auth?.profiles?.[profileId];
973
+ if (profileConfig && profileConfig.provider !== cred.provider) return null;
974
+ if (profileConfig && profileConfig.mode !== cred.type) {
975
+ if (!(profileConfig.mode === "oauth" && cred.type === "token")) return null;
976
+ }
977
+ if (cred.type === "api_key") {
978
+ const key = cred.key?.trim();
979
+ if (!key) return null;
980
+ return {
981
+ apiKey: key,
982
+ provider: cred.provider,
983
+ email: cred.email
984
+ };
985
+ }
986
+ if (cred.type === "token") {
987
+ const token = cred.token?.trim();
988
+ if (!token) return null;
989
+ if (typeof cred.expires === "number" && Number.isFinite(cred.expires) && cred.expires > 0 && Date.now() >= cred.expires) return null;
990
+ return {
991
+ apiKey: token,
992
+ provider: cred.provider,
993
+ email: cred.email
994
+ };
995
+ }
996
+ if (Date.now() < cred.expires) return {
997
+ apiKey: buildOAuthApiKey(cred.provider, cred),
998
+ provider: cred.provider,
999
+ email: cred.email
1000
+ };
1001
+ try {
1002
+ const result = await refreshOAuthTokenWithLock({
1003
+ profileId,
1004
+ agentDir: params.agentDir
1005
+ });
1006
+ if (!result) return null;
1007
+ return {
1008
+ apiKey: result.apiKey,
1009
+ provider: cred.provider,
1010
+ email: cred.email
1011
+ };
1012
+ } catch (error) {
1013
+ const refreshedStore = ensureAuthProfileStore(params.agentDir);
1014
+ const refreshed = refreshedStore.profiles[profileId];
1015
+ if (refreshed?.type === "oauth" && Date.now() < refreshed.expires) return {
1016
+ apiKey: buildOAuthApiKey(refreshed.provider, refreshed),
1017
+ provider: refreshed.provider,
1018
+ email: refreshed.email ?? cred.email
1019
+ };
1020
+ const fallbackProfileId = suggestOAuthProfileIdForLegacyDefault({
1021
+ cfg,
1022
+ store: refreshedStore,
1023
+ provider: cred.provider,
1024
+ legacyProfileId: profileId
1025
+ });
1026
+ if (fallbackProfileId && fallbackProfileId !== profileId) try {
1027
+ const fallbackResolved = await tryResolveOAuthProfile({
1028
+ cfg,
1029
+ store: refreshedStore,
1030
+ profileId: fallbackProfileId,
1031
+ agentDir: params.agentDir
1032
+ });
1033
+ if (fallbackResolved) return fallbackResolved;
1034
+ } catch {}
1035
+ if (params.agentDir) try {
1036
+ const mainCred = ensureAuthProfileStore(void 0).profiles[profileId];
1037
+ if (mainCred?.type === "oauth" && Date.now() < mainCred.expires) {
1038
+ refreshedStore.profiles[profileId] = { ...mainCred };
1039
+ saveAuthProfileStore(refreshedStore, params.agentDir);
1040
+ log$1.info("inherited fresh OAuth credentials from main agent", {
1041
+ profileId,
1042
+ agentDir: params.agentDir,
1043
+ expires: new Date(mainCred.expires).toISOString()
1044
+ });
1045
+ return {
1046
+ apiKey: buildOAuthApiKey(mainCred.provider, mainCred),
1047
+ provider: mainCred.provider,
1048
+ email: mainCred.email
1049
+ };
1050
+ }
1051
+ } catch {}
1052
+ const message = error instanceof Error ? error.message : String(error);
1053
+ const hint = formatAuthDoctorHint({
1054
+ cfg,
1055
+ store: refreshedStore,
1056
+ provider: cred.provider,
1057
+ profileId
1058
+ });
1059
+ throw new Error(`OAuth token refresh failed for ${cred.provider}: ${message}. Please try again or re-authenticate.` + (hint ? `\n\n${hint}` : ""), { cause: error });
1060
+ }
1061
+ }
1062
+
1063
+ //#endregion
1064
+ //#region src/agents/auth-profiles/usage.ts
1065
+ function resolveProfileUnusableUntil$1(stats) {
1066
+ const values = [stats.cooldownUntil, stats.disabledUntil].filter((value) => typeof value === "number").filter((value) => Number.isFinite(value) && value > 0);
1067
+ if (values.length === 0) return null;
1068
+ return Math.max(...values);
1069
+ }
1070
+ /**
1071
+ * Check if a profile is currently in cooldown (due to rate limiting or errors).
1072
+ */
1073
+ function isProfileInCooldown(store, profileId) {
1074
+ const stats = store.usageStats?.[profileId];
1075
+ if (!stats) return false;
1076
+ const unusableUntil = resolveProfileUnusableUntil$1(stats);
1077
+ return unusableUntil ? Date.now() < unusableUntil : false;
1078
+ }
1079
+ function resolveProfileUnusableUntilForDisplay(store, profileId) {
1080
+ const stats = store.usageStats?.[profileId];
1081
+ if (!stats) return null;
1082
+ return resolveProfileUnusableUntil$1(stats);
1083
+ }
1084
+
1085
+ //#endregion
1086
+ //#region src/agents/auth-profiles/order.ts
1087
+ function resolveProfileUnusableUntil(stats) {
1088
+ const values = [stats.cooldownUntil, stats.disabledUntil].filter((value) => typeof value === "number").filter((value) => Number.isFinite(value) && value > 0);
1089
+ if (values.length === 0) return null;
1090
+ return Math.max(...values);
1091
+ }
1092
+ function resolveAuthProfileOrder(params) {
1093
+ const { cfg, store, provider, preferredProfile } = params;
1094
+ const providerKey = normalizeProviderId(provider);
1095
+ const now = Date.now();
1096
+ const storedOrder = (() => {
1097
+ const order = store.order;
1098
+ if (!order) return;
1099
+ for (const [key, value] of Object.entries(order)) if (normalizeProviderId(key) === providerKey) return value;
1100
+ })();
1101
+ const configuredOrder = (() => {
1102
+ const order = cfg?.auth?.order;
1103
+ if (!order) return;
1104
+ for (const [key, value] of Object.entries(order)) if (normalizeProviderId(key) === providerKey) return value;
1105
+ })();
1106
+ const explicitOrder = storedOrder ?? configuredOrder;
1107
+ const explicitProfiles = cfg?.auth?.profiles ? Object.entries(cfg.auth.profiles).filter(([, profile]) => normalizeProviderId(profile.provider) === providerKey).map(([profileId]) => profileId) : [];
1108
+ const baseOrder = explicitOrder ?? (explicitProfiles.length > 0 ? explicitProfiles : listProfilesForProvider(store, providerKey));
1109
+ if (baseOrder.length === 0) return [];
1110
+ const filtered = baseOrder.filter((profileId) => {
1111
+ const cred = store.profiles[profileId];
1112
+ if (!cred) return false;
1113
+ if (normalizeProviderId(cred.provider) !== providerKey) return false;
1114
+ const profileConfig = cfg?.auth?.profiles?.[profileId];
1115
+ if (profileConfig) {
1116
+ if (normalizeProviderId(profileConfig.provider) !== providerKey) return false;
1117
+ if (profileConfig.mode !== cred.type) {
1118
+ if (!(profileConfig.mode === "oauth" && cred.type === "token")) return false;
1119
+ }
1120
+ }
1121
+ if (cred.type === "api_key") return Boolean(cred.key?.trim());
1122
+ if (cred.type === "token") {
1123
+ if (!cred.token?.trim()) return false;
1124
+ if (typeof cred.expires === "number" && Number.isFinite(cred.expires) && cred.expires > 0 && now >= cred.expires) return false;
1125
+ return true;
1126
+ }
1127
+ if (cred.type === "oauth") return Boolean(cred.access?.trim() || cred.refresh?.trim());
1128
+ return false;
1129
+ });
1130
+ const deduped = [];
1131
+ for (const entry of filtered) if (!deduped.includes(entry)) deduped.push(entry);
1132
+ if (explicitOrder && explicitOrder.length > 0) {
1133
+ const available = [];
1134
+ const inCooldown = [];
1135
+ for (const profileId of deduped) {
1136
+ const cooldownUntil = resolveProfileUnusableUntil(store.usageStats?.[profileId] ?? {}) ?? 0;
1137
+ if (typeof cooldownUntil === "number" && Number.isFinite(cooldownUntil) && cooldownUntil > 0 && now < cooldownUntil) inCooldown.push({
1138
+ profileId,
1139
+ cooldownUntil
1140
+ });
1141
+ else available.push(profileId);
1142
+ }
1143
+ const cooldownSorted = inCooldown.toSorted((a, b) => a.cooldownUntil - b.cooldownUntil).map((entry) => entry.profileId);
1144
+ const ordered = [...available, ...cooldownSorted];
1145
+ if (preferredProfile && ordered.includes(preferredProfile)) return [preferredProfile, ...ordered.filter((e) => e !== preferredProfile)];
1146
+ return ordered;
1147
+ }
1148
+ const sorted = orderProfilesByMode(deduped, store);
1149
+ if (preferredProfile && sorted.includes(preferredProfile)) return [preferredProfile, ...sorted.filter((e) => e !== preferredProfile)];
1150
+ return sorted;
1151
+ }
1152
+ function orderProfilesByMode(order, store) {
1153
+ const now = Date.now();
1154
+ const available = [];
1155
+ const inCooldown = [];
1156
+ for (const profileId of order) if (isProfileInCooldown(store, profileId)) inCooldown.push(profileId);
1157
+ else available.push(profileId);
1158
+ const sorted = available.map((profileId) => {
1159
+ const type = store.profiles[profileId]?.type;
1160
+ return {
1161
+ profileId,
1162
+ typeScore: type === "oauth" ? 0 : type === "token" ? 1 : type === "api_key" ? 2 : 3,
1163
+ lastUsed: store.usageStats?.[profileId]?.lastUsed ?? 0
1164
+ };
1165
+ }).toSorted((a, b) => {
1166
+ if (a.typeScore !== b.typeScore) return a.typeScore - b.typeScore;
1167
+ return a.lastUsed - b.lastUsed;
1168
+ }).map((entry) => entry.profileId);
1169
+ const cooldownSorted = inCooldown.map((profileId) => ({
1170
+ profileId,
1171
+ cooldownUntil: resolveProfileUnusableUntil(store.usageStats?.[profileId] ?? {}) ?? now
1172
+ })).toSorted((a, b) => a.cooldownUntil - b.cooldownUntil).map((entry) => entry.profileId);
1173
+ return [...sorted, ...cooldownSorted];
1174
+ }
1175
+
1176
+ //#endregion
1177
+ //#region src/agents/auth-profiles.ts
1178
+ var auth_profiles_exports = /* @__PURE__ */ __exportAll({ ensureAuthProfileStore: () => ensureAuthProfileStore });
1179
+
1180
+ //#endregion
1181
+ //#region src/agents/cloudflare-ai-gateway.ts
1182
+ const CLOUDFLARE_AI_GATEWAY_PROVIDER_ID = "cloudflare-ai-gateway";
1183
+ const CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_ID = "claude-sonnet-4-5";
1184
+ const CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF = `${CLOUDFLARE_AI_GATEWAY_PROVIDER_ID}/${CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_ID}`;
1185
+ const CLOUDFLARE_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW = 2e5;
1186
+ const CLOUDFLARE_AI_GATEWAY_DEFAULT_MAX_TOKENS = 64e3;
1187
+ const CLOUDFLARE_AI_GATEWAY_DEFAULT_COST = {
1188
+ input: 3,
1189
+ output: 15,
1190
+ cacheRead: .3,
1191
+ cacheWrite: 3.75
1192
+ };
1193
+ function buildCloudflareAiGatewayModelDefinition(params) {
1194
+ return {
1195
+ id: params?.id?.trim() || CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_ID,
1196
+ name: params?.name ?? "Claude Sonnet 4.5",
1197
+ reasoning: params?.reasoning ?? true,
1198
+ input: params?.input ?? ["text", "image"],
1199
+ cost: CLOUDFLARE_AI_GATEWAY_DEFAULT_COST,
1200
+ contextWindow: CLOUDFLARE_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW,
1201
+ maxTokens: CLOUDFLARE_AI_GATEWAY_DEFAULT_MAX_TOKENS
1202
+ };
1203
+ }
1204
+ function resolveCloudflareAiGatewayBaseUrl(params) {
1205
+ const accountId = params.accountId.trim();
1206
+ const gatewayId = params.gatewayId.trim();
1207
+ if (!accountId || !gatewayId) return "";
1208
+ return `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/anthropic`;
1209
+ }
1210
+
1211
+ //#endregion
1212
+ //#region src/agents/huggingface-models.ts
1213
+ /** Hugging Face Inference Providers (router) — OpenAI-compatible chat completions. */
1214
+ const HUGGINGFACE_BASE_URL = "https://router.huggingface.co/v1";
1215
+ /** Router policy suffixes: router picks backend by cost or speed; no specific provider selection. */
1216
+ const HUGGINGFACE_POLICY_SUFFIXES = ["cheapest", "fastest"];
1217
+ /**
1218
+ * True when the model ref uses :cheapest or :fastest. When true, provider choice is locked
1219
+ * (router decides); do not show an interactive "prefer specific backend" option.
1220
+ */
1221
+ function isHuggingfacePolicyLocked(modelRef) {
1222
+ const ref = String(modelRef).trim();
1223
+ return HUGGINGFACE_POLICY_SUFFIXES.some((s) => ref.endsWith(`:${s}`) || ref === s);
1224
+ }
1225
+ /** Default cost when not in static catalog (HF pricing varies by provider). */
1226
+ const HUGGINGFACE_DEFAULT_COST = {
1227
+ input: 0,
1228
+ output: 0,
1229
+ cacheRead: 0,
1230
+ cacheWrite: 0
1231
+ };
1232
+ /** Defaults for models discovered from GET /v1/models. */
1233
+ const HUGGINGFACE_DEFAULT_CONTEXT_WINDOW = 131072;
1234
+ const HUGGINGFACE_DEFAULT_MAX_TOKENS = 8192;
1235
+ const HUGGINGFACE_MODEL_CATALOG = [
1236
+ {
1237
+ id: "deepseek-ai/DeepSeek-R1",
1238
+ name: "DeepSeek R1",
1239
+ reasoning: true,
1240
+ input: ["text"],
1241
+ contextWindow: 131072,
1242
+ maxTokens: 8192,
1243
+ cost: {
1244
+ input: 3,
1245
+ output: 7,
1246
+ cacheRead: 3,
1247
+ cacheWrite: 3
1248
+ }
1249
+ },
1250
+ {
1251
+ id: "deepseek-ai/DeepSeek-V3.1",
1252
+ name: "DeepSeek V3.1",
1253
+ reasoning: false,
1254
+ input: ["text"],
1255
+ contextWindow: 131072,
1256
+ maxTokens: 8192,
1257
+ cost: {
1258
+ input: .6,
1259
+ output: 1.25,
1260
+ cacheRead: .6,
1261
+ cacheWrite: .6
1262
+ }
1263
+ },
1264
+ {
1265
+ id: "meta-llama/Llama-3.3-70B-Instruct-Turbo",
1266
+ name: "Llama 3.3 70B Instruct Turbo",
1267
+ reasoning: false,
1268
+ input: ["text"],
1269
+ contextWindow: 131072,
1270
+ maxTokens: 8192,
1271
+ cost: {
1272
+ input: .88,
1273
+ output: .88,
1274
+ cacheRead: .88,
1275
+ cacheWrite: .88
1276
+ }
1277
+ },
1278
+ {
1279
+ id: "openai/gpt-oss-120b",
1280
+ name: "GPT-OSS 120B",
1281
+ reasoning: false,
1282
+ input: ["text"],
1283
+ contextWindow: 131072,
1284
+ maxTokens: 8192,
1285
+ cost: {
1286
+ input: 0,
1287
+ output: 0,
1288
+ cacheRead: 0,
1289
+ cacheWrite: 0
1290
+ }
1291
+ }
1292
+ ];
1293
+ function buildHuggingfaceModelDefinition(model) {
1294
+ return {
1295
+ id: model.id,
1296
+ name: model.name,
1297
+ reasoning: model.reasoning,
1298
+ input: model.input,
1299
+ cost: model.cost,
1300
+ contextWindow: model.contextWindow,
1301
+ maxTokens: model.maxTokens
1302
+ };
1303
+ }
1304
+ /**
1305
+ * Infer reasoning and display name from Hub-style model id (e.g. "deepseek-ai/DeepSeek-R1").
1306
+ */
1307
+ function inferredMetaFromModelId(id) {
1308
+ const base = id.split("/").pop() ?? id;
1309
+ const reasoning = /r1|reasoning|thinking|reason/i.test(id) || /-\d+[tb]?-thinking/i.test(base);
1310
+ return {
1311
+ name: base.replace(/-/g, " ").replace(/\b(\w)/g, (c) => c.toUpperCase()),
1312
+ reasoning
1313
+ };
1314
+ }
1315
+ /** Prefer API-supplied display name, then owned_by/id, then inferred from id. */
1316
+ function displayNameFromApiEntry(entry, inferredName) {
1317
+ const fromApi = typeof entry.name === "string" && entry.name.trim() || typeof entry.title === "string" && entry.title.trim() || typeof entry.display_name === "string" && entry.display_name.trim();
1318
+ if (fromApi) return fromApi;
1319
+ if (typeof entry.owned_by === "string" && entry.owned_by.trim()) {
1320
+ const base = entry.id.split("/").pop() ?? entry.id;
1321
+ return `${entry.owned_by.trim()}/${base}`;
1322
+ }
1323
+ return inferredName;
1324
+ }
1325
+ /**
1326
+ * Discover chat-completion models from Hugging Face Inference Providers (GET /v1/models).
1327
+ * Requires a valid HF token. Falls back to static catalog on failure or in test env.
1328
+ */
1329
+ async function discoverHuggingfaceModels(apiKey) {
1330
+ if (process.env.VITEST === "true" || false) return HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
1331
+ const trimmedKey = apiKey?.trim();
1332
+ if (!trimmedKey) return HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
1333
+ try {
1334
+ const response = await fetch(`${HUGGINGFACE_BASE_URL}/models`, {
1335
+ signal: AbortSignal.timeout(1e4),
1336
+ headers: {
1337
+ Authorization: `Bearer ${trimmedKey}`,
1338
+ "Content-Type": "application/json"
1339
+ }
1340
+ });
1341
+ if (!response.ok) {
1342
+ console.warn(`[huggingface-models] GET /v1/models failed: HTTP ${response.status}, using static catalog`);
1343
+ return HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
1344
+ }
1345
+ const data = (await response.json())?.data;
1346
+ if (!Array.isArray(data) || data.length === 0) {
1347
+ console.warn("[huggingface-models] No models in response, using static catalog");
1348
+ return HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
1349
+ }
1350
+ const catalogById = new Map(HUGGINGFACE_MODEL_CATALOG.map((m) => [m.id, m]));
1351
+ const seen = /* @__PURE__ */ new Set();
1352
+ const models = [];
1353
+ for (const entry of data) {
1354
+ const id = typeof entry?.id === "string" ? entry.id.trim() : "";
1355
+ if (!id || seen.has(id)) continue;
1356
+ seen.add(id);
1357
+ const catalogEntry = catalogById.get(id);
1358
+ if (catalogEntry) models.push(buildHuggingfaceModelDefinition(catalogEntry));
1359
+ else {
1360
+ const inferred = inferredMetaFromModelId(id);
1361
+ const name = displayNameFromApiEntry(entry, inferred.name);
1362
+ const modalities = entry.architecture?.input_modalities;
1363
+ const input = Array.isArray(modalities) && modalities.includes("image") ? ["text", "image"] : ["text"];
1364
+ const contextLength = (Array.isArray(entry.providers) ? entry.providers : []).find((p) => typeof p?.context_length === "number" && p.context_length > 0)?.context_length ?? HUGGINGFACE_DEFAULT_CONTEXT_WINDOW;
1365
+ models.push({
1366
+ id,
1367
+ name,
1368
+ reasoning: inferred.reasoning,
1369
+ input,
1370
+ cost: HUGGINGFACE_DEFAULT_COST,
1371
+ contextWindow: contextLength,
1372
+ maxTokens: HUGGINGFACE_DEFAULT_MAX_TOKENS
1373
+ });
1374
+ }
1375
+ }
1376
+ return models.length > 0 ? models : HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
1377
+ } catch (error) {
1378
+ console.warn(`[huggingface-models] Discovery failed: ${String(error)}, using static catalog`);
1379
+ return HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
1380
+ }
1381
+ }
1382
+
1383
+ //#endregion
1384
+ //#region src/infra/shell-env.ts
1385
+ const DEFAULT_TIMEOUT_MS = 15e3;
1386
+ const DEFAULT_MAX_BUFFER_BYTES = 2 * 1024 * 1024;
1387
+ let lastAppliedKeys = [];
1388
+ let cachedShellPath;
1389
+ function resolveShell(env) {
1390
+ const shell = env.SHELL?.trim();
1391
+ return shell && shell.length > 0 ? shell : "/bin/sh";
1392
+ }
1393
+ function parseShellEnv(stdout) {
1394
+ const shellEnv = /* @__PURE__ */ new Map();
1395
+ const parts = stdout.toString("utf8").split("\0");
1396
+ for (const part of parts) {
1397
+ if (!part) continue;
1398
+ const eq = part.indexOf("=");
1399
+ if (eq <= 0) continue;
1400
+ const key = part.slice(0, eq);
1401
+ const value = part.slice(eq + 1);
1402
+ if (!key) continue;
1403
+ shellEnv.set(key, value);
1404
+ }
1405
+ return shellEnv;
1406
+ }
1407
+ function loadShellEnvFallback(opts) {
1408
+ const logger = opts.logger ?? console;
1409
+ const exec = opts.exec ?? execFileSync;
1410
+ if (!opts.enabled) {
1411
+ lastAppliedKeys = [];
1412
+ return {
1413
+ ok: true,
1414
+ applied: [],
1415
+ skippedReason: "disabled"
1416
+ };
1417
+ }
1418
+ if (opts.expectedKeys.some((key) => Boolean(opts.env[key]?.trim()))) {
1419
+ lastAppliedKeys = [];
1420
+ return {
1421
+ ok: true,
1422
+ applied: [],
1423
+ skippedReason: "already-has-keys"
1424
+ };
1425
+ }
1426
+ const timeoutMs = typeof opts.timeoutMs === "number" && Number.isFinite(opts.timeoutMs) ? Math.max(0, opts.timeoutMs) : DEFAULT_TIMEOUT_MS;
1427
+ const shell = resolveShell(opts.env);
1428
+ let stdout;
1429
+ try {
1430
+ stdout = exec(shell, [
1431
+ "-l",
1432
+ "-c",
1433
+ "env -0"
1434
+ ], {
1435
+ encoding: "buffer",
1436
+ timeout: timeoutMs,
1437
+ maxBuffer: DEFAULT_MAX_BUFFER_BYTES,
1438
+ env: opts.env,
1439
+ stdio: [
1440
+ "ignore",
1441
+ "pipe",
1442
+ "pipe"
1443
+ ]
1444
+ });
1445
+ } catch (err) {
1446
+ const msg = err instanceof Error ? err.message : String(err);
1447
+ logger.warn(`[anima] shell env fallback failed: ${msg}`);
1448
+ lastAppliedKeys = [];
1449
+ return {
1450
+ ok: false,
1451
+ error: msg,
1452
+ applied: []
1453
+ };
1454
+ }
1455
+ const shellEnv = parseShellEnv(stdout);
1456
+ const applied = [];
1457
+ for (const key of opts.expectedKeys) {
1458
+ if (opts.env[key]?.trim()) continue;
1459
+ const value = shellEnv.get(key);
1460
+ if (!value?.trim()) continue;
1461
+ opts.env[key] = value;
1462
+ applied.push(key);
1463
+ }
1464
+ lastAppliedKeys = applied;
1465
+ return {
1466
+ ok: true,
1467
+ applied
1468
+ };
1469
+ }
1470
+ function shouldEnableShellEnvFallback(env) {
1471
+ return isTruthyEnvValue(env.ANIMA_LOAD_SHELL_ENV);
1472
+ }
1473
+ function shouldDeferShellEnvFallback(env) {
1474
+ return isTruthyEnvValue(env.ANIMA_DEFER_SHELL_ENV_FALLBACK);
1475
+ }
1476
+ function resolveShellEnvFallbackTimeoutMs(env) {
1477
+ const raw = env.ANIMA_SHELL_ENV_TIMEOUT_MS?.trim();
1478
+ if (!raw) return DEFAULT_TIMEOUT_MS;
1479
+ const parsed = Number.parseInt(raw, 10);
1480
+ if (!Number.isFinite(parsed)) return DEFAULT_TIMEOUT_MS;
1481
+ return Math.max(0, parsed);
1482
+ }
1483
+ function getShellPathFromLoginShell(opts) {
1484
+ if (cachedShellPath !== void 0) return cachedShellPath;
1485
+ if (process.platform === "win32") {
1486
+ cachedShellPath = null;
1487
+ return cachedShellPath;
1488
+ }
1489
+ const exec = opts.exec ?? execFileSync;
1490
+ const timeoutMs = typeof opts.timeoutMs === "number" && Number.isFinite(opts.timeoutMs) ? Math.max(0, opts.timeoutMs) : DEFAULT_TIMEOUT_MS;
1491
+ const shell = resolveShell(opts.env);
1492
+ let stdout;
1493
+ try {
1494
+ stdout = exec(shell, [
1495
+ "-l",
1496
+ "-c",
1497
+ "env -0"
1498
+ ], {
1499
+ encoding: "buffer",
1500
+ timeout: timeoutMs,
1501
+ maxBuffer: DEFAULT_MAX_BUFFER_BYTES,
1502
+ env: opts.env,
1503
+ stdio: [
1504
+ "ignore",
1505
+ "pipe",
1506
+ "pipe"
1507
+ ]
1508
+ });
1509
+ } catch {
1510
+ cachedShellPath = null;
1511
+ return cachedShellPath;
1512
+ }
1513
+ const shellPath = parseShellEnv(stdout).get("PATH")?.trim();
1514
+ cachedShellPath = shellPath && shellPath.length > 0 ? shellPath : null;
1515
+ return cachedShellPath;
1516
+ }
1517
+ function getShellEnvAppliedKeys() {
1518
+ return [...lastAppliedKeys];
1519
+ }
1520
+
1521
+ //#endregion
1522
+ //#region src/agents/model-auth.ts
1523
+ const AWS_BEARER_ENV = "AWS_BEARER_TOKEN_BEDROCK";
1524
+ const AWS_ACCESS_KEY_ENV = "AWS_ACCESS_KEY_ID";
1525
+ const AWS_SECRET_KEY_ENV = "AWS_SECRET_ACCESS_KEY";
1526
+ const AWS_PROFILE_ENV = "AWS_PROFILE";
1527
+ function resolveProviderConfig(cfg, provider) {
1528
+ const providers = cfg?.models?.providers ?? {};
1529
+ const direct = providers[provider];
1530
+ if (direct) return direct;
1531
+ const normalized = normalizeProviderId(provider);
1532
+ if (normalized === provider) return Object.entries(providers).find(([key]) => normalizeProviderId(key) === normalized)?.[1];
1533
+ return providers[normalized] ?? Object.entries(providers).find(([key]) => normalizeProviderId(key) === normalized)?.[1];
1534
+ }
1535
+ function getCustomProviderApiKey(cfg, provider) {
1536
+ return normalizeOptionalSecretInput(resolveProviderConfig(cfg, provider)?.apiKey);
1537
+ }
1538
+ function resolveProviderAuthOverride(cfg, provider) {
1539
+ const auth = resolveProviderConfig(cfg, provider)?.auth;
1540
+ if (auth === "api-key" || auth === "aws-sdk" || auth === "oauth" || auth === "token") return auth;
1541
+ }
1542
+ function resolveEnvSourceLabel(params) {
1543
+ return `${params.envVars.some((envVar) => params.applied.has(envVar)) ? "shell env: " : "env: "}${params.label}`;
1544
+ }
1545
+ function resolveAwsSdkEnvVarName(env = process.env) {
1546
+ if (env[AWS_BEARER_ENV]?.trim()) return AWS_BEARER_ENV;
1547
+ if (env[AWS_ACCESS_KEY_ENV]?.trim() && env[AWS_SECRET_KEY_ENV]?.trim()) return AWS_ACCESS_KEY_ENV;
1548
+ if (env[AWS_PROFILE_ENV]?.trim()) return AWS_PROFILE_ENV;
1549
+ }
1550
+ function resolveAwsSdkAuthInfo() {
1551
+ const applied = new Set(getShellEnvAppliedKeys());
1552
+ if (process.env[AWS_BEARER_ENV]?.trim()) return {
1553
+ mode: "aws-sdk",
1554
+ source: resolveEnvSourceLabel({
1555
+ applied,
1556
+ envVars: [AWS_BEARER_ENV],
1557
+ label: AWS_BEARER_ENV
1558
+ })
1559
+ };
1560
+ if (process.env[AWS_ACCESS_KEY_ENV]?.trim() && process.env[AWS_SECRET_KEY_ENV]?.trim()) return {
1561
+ mode: "aws-sdk",
1562
+ source: resolveEnvSourceLabel({
1563
+ applied,
1564
+ envVars: [AWS_ACCESS_KEY_ENV, AWS_SECRET_KEY_ENV],
1565
+ label: `${AWS_ACCESS_KEY_ENV} + ${AWS_SECRET_KEY_ENV}`
1566
+ })
1567
+ };
1568
+ if (process.env[AWS_PROFILE_ENV]?.trim()) return {
1569
+ mode: "aws-sdk",
1570
+ source: resolveEnvSourceLabel({
1571
+ applied,
1572
+ envVars: [AWS_PROFILE_ENV],
1573
+ label: AWS_PROFILE_ENV
1574
+ })
1575
+ };
1576
+ return {
1577
+ mode: "aws-sdk",
1578
+ source: "aws-sdk default chain"
1579
+ };
1580
+ }
1581
+ async function resolveApiKeyForProvider(params) {
1582
+ const { provider, cfg, profileId, preferredProfile } = params;
1583
+ const store = params.store ?? ensureAuthProfileStore(params.agentDir);
1584
+ if (profileId) {
1585
+ const resolved = await resolveApiKeyForProfile({
1586
+ cfg,
1587
+ store,
1588
+ profileId,
1589
+ agentDir: params.agentDir
1590
+ });
1591
+ if (!resolved) throw new Error(`No credentials found for profile "${profileId}".`);
1592
+ const mode = store.profiles[profileId]?.type;
1593
+ return {
1594
+ apiKey: resolved.apiKey,
1595
+ profileId,
1596
+ source: `profile:${profileId}`,
1597
+ mode: mode === "oauth" ? "oauth" : mode === "token" ? "token" : "api-key"
1598
+ };
1599
+ }
1600
+ const authOverride = resolveProviderAuthOverride(cfg, provider);
1601
+ if (authOverride === "aws-sdk") return resolveAwsSdkAuthInfo();
1602
+ const order = resolveAuthProfileOrder({
1603
+ cfg,
1604
+ store,
1605
+ provider,
1606
+ preferredProfile
1607
+ });
1608
+ for (const candidate of order) try {
1609
+ const resolved = await resolveApiKeyForProfile({
1610
+ cfg,
1611
+ store,
1612
+ profileId: candidate,
1613
+ agentDir: params.agentDir
1614
+ });
1615
+ if (resolved) {
1616
+ const mode = store.profiles[candidate]?.type;
1617
+ return {
1618
+ apiKey: resolved.apiKey,
1619
+ profileId: candidate,
1620
+ source: `profile:${candidate}`,
1621
+ mode: mode === "oauth" ? "oauth" : mode === "token" ? "token" : "api-key"
1622
+ };
1623
+ }
1624
+ } catch {}
1625
+ const envResolved = resolveEnvApiKey(provider);
1626
+ if (envResolved) return {
1627
+ apiKey: envResolved.apiKey,
1628
+ source: envResolved.source,
1629
+ mode: envResolved.source.includes("OAUTH_TOKEN") ? "oauth" : "api-key"
1630
+ };
1631
+ const customKey = getCustomProviderApiKey(cfg, provider);
1632
+ if (customKey) return {
1633
+ apiKey: customKey,
1634
+ source: "models.json",
1635
+ mode: "api-key"
1636
+ };
1637
+ const normalized = normalizeProviderId(provider);
1638
+ if (authOverride === void 0 && normalized === "amazon-bedrock") return resolveAwsSdkAuthInfo();
1639
+ if (provider === "openai") {
1640
+ if (listProfilesForProvider(store, "openai-codex").length > 0) throw new Error("No API key found for provider \"openai\". You are authenticated with OpenAI Codex OAuth. Use openai-codex/gpt-5.3-codex (OAuth) or set OPENAI_API_KEY to use openai/gpt-5.1-codex.");
1641
+ }
1642
+ const authStorePath = resolveAuthStorePathForDisplay(params.agentDir);
1643
+ const resolvedAgentDir = path.dirname(authStorePath);
1644
+ throw new Error([
1645
+ `No API key found for provider "${provider}".`,
1646
+ `Auth store: ${authStorePath} (agentDir: ${resolvedAgentDir}).`,
1647
+ `Configure auth for this agent (${formatCliCommand("anima agents add <id>")}) or copy auth-profiles.json from the main agentDir.`
1648
+ ].join(" "));
1649
+ }
1650
+ function resolveEnvApiKey(provider) {
1651
+ const normalized = normalizeProviderId(provider);
1652
+ const applied = new Set(getShellEnvAppliedKeys());
1653
+ const pick = (envVar) => {
1654
+ const value = normalizeOptionalSecretInput(process.env[envVar]);
1655
+ if (!value) return null;
1656
+ return {
1657
+ apiKey: value,
1658
+ source: applied.has(envVar) ? `shell env: ${envVar}` : `env: ${envVar}`
1659
+ };
1660
+ };
1661
+ if (normalized === "github-copilot") return pick("COPILOT_GITHUB_TOKEN") ?? pick("GH_TOKEN") ?? pick("GITHUB_TOKEN");
1662
+ if (normalized === "anthropic") return pick("ANTHROPIC_OAUTH_TOKEN") ?? pick("ANTHROPIC_API_KEY");
1663
+ if (normalized === "chutes") return pick("CHUTES_OAUTH_TOKEN") ?? pick("CHUTES_API_KEY");
1664
+ if (normalized === "zai") return pick("ZAI_API_KEY") ?? pick("Z_AI_API_KEY");
1665
+ if (normalized === "google-vertex") {
1666
+ const envKey = getEnvApiKey(normalized);
1667
+ if (!envKey) return null;
1668
+ return {
1669
+ apiKey: envKey,
1670
+ source: "gcloud adc"
1671
+ };
1672
+ }
1673
+ if (normalized === "opencode") return pick("OPENCODE_API_KEY") ?? pick("OPENCODE_ZEN_API_KEY");
1674
+ if (normalized === "qwen-portal") return pick("QWEN_OAUTH_TOKEN") ?? pick("QWEN_PORTAL_API_KEY");
1675
+ if (normalized === "minimax-portal") return pick("MINIMAX_OAUTH_TOKEN") ?? pick("MINIMAX_API_KEY");
1676
+ if (normalized === "kimi-coding") return pick("KIMI_API_KEY") ?? pick("KIMICODE_API_KEY");
1677
+ if (normalized === "huggingface") return pick("HUGGINGFACE_HUB_TOKEN") ?? pick("HF_TOKEN");
1678
+ const envVar = {
1679
+ openai: "OPENAI_API_KEY",
1680
+ google: "GEMINI_API_KEY",
1681
+ voyage: "VOYAGE_API_KEY",
1682
+ groq: "GROQ_API_KEY",
1683
+ deepgram: "DEEPGRAM_API_KEY",
1684
+ cerebras: "CEREBRAS_API_KEY",
1685
+ xai: "XAI_API_KEY",
1686
+ openrouter: "OPENROUTER_API_KEY",
1687
+ litellm: "LITELLM_API_KEY",
1688
+ "vercel-ai-gateway": "AI_GATEWAY_API_KEY",
1689
+ "cloudflare-ai-gateway": "CLOUDFLARE_AI_GATEWAY_API_KEY",
1690
+ moonshot: "MOONSHOT_API_KEY",
1691
+ minimax: "MINIMAX_API_KEY",
1692
+ nvidia: "NVIDIA_API_KEY",
1693
+ xiaomi: "XIAOMI_API_KEY",
1694
+ synthetic: "SYNTHETIC_API_KEY",
1695
+ venice: "VENICE_API_KEY",
1696
+ mistral: "MISTRAL_API_KEY",
1697
+ opencode: "OPENCODE_API_KEY",
1698
+ together: "TOGETHER_API_KEY",
1699
+ qianfan: "QIANFAN_API_KEY",
1700
+ ollama: "OLLAMA_API_KEY",
1701
+ vllm: "VLLM_API_KEY"
1702
+ }[normalized];
1703
+ if (!envVar) return null;
1704
+ return pick(envVar);
1705
+ }
1706
+ function resolveModelAuthMode(provider, cfg, store) {
1707
+ const resolved = provider?.trim();
1708
+ if (!resolved) return;
1709
+ const authOverride = resolveProviderAuthOverride(cfg, resolved);
1710
+ if (authOverride === "aws-sdk") return "aws-sdk";
1711
+ const authStore = store ?? ensureAuthProfileStore();
1712
+ const profiles = listProfilesForProvider(authStore, resolved);
1713
+ if (profiles.length > 0) {
1714
+ const modes = new Set(profiles.map((id) => authStore.profiles[id]?.type).filter((mode) => Boolean(mode)));
1715
+ if ([
1716
+ "oauth",
1717
+ "token",
1718
+ "api_key"
1719
+ ].filter((k) => modes.has(k)).length >= 2) return "mixed";
1720
+ if (modes.has("oauth")) return "oauth";
1721
+ if (modes.has("token")) return "token";
1722
+ if (modes.has("api_key")) return "api-key";
1723
+ }
1724
+ if (authOverride === void 0 && normalizeProviderId(resolved) === "amazon-bedrock") return "aws-sdk";
1725
+ const envKey = resolveEnvApiKey(resolved);
1726
+ if (envKey?.apiKey) return envKey.source.includes("OAUTH_TOKEN") ? "oauth" : "api-key";
1727
+ if (getCustomProviderApiKey(cfg, resolved)) return "api-key";
1728
+ return "unknown";
1729
+ }
1730
+ async function getApiKeyForModel(params) {
1731
+ return resolveApiKeyForProvider({
1732
+ provider: params.model.provider,
1733
+ cfg: params.cfg,
1734
+ profileId: params.profileId,
1735
+ preferredProfile: params.preferredProfile,
1736
+ store: params.store,
1737
+ agentDir: params.agentDir
1738
+ });
1739
+ }
1740
+ function requireApiKey(auth, provider) {
1741
+ const key = normalizeSecretInput(auth.apiKey);
1742
+ if (key) return key;
1743
+ throw new Error(`No API key resolved for provider "${provider}" (auth mode: ${auth.mode}).`);
1744
+ }
1745
+
1746
+ //#endregion
1747
+ //#region src/agents/synthetic-models.ts
1748
+ const SYNTHETIC_BASE_URL = "https://api.synthetic.new/anthropic";
1749
+ const SYNTHETIC_DEFAULT_MODEL_ID = "hf:MiniMaxAI/MiniMax-M2.1";
1750
+ const SYNTHETIC_DEFAULT_MODEL_REF = `synthetic/${SYNTHETIC_DEFAULT_MODEL_ID}`;
1751
+ const SYNTHETIC_DEFAULT_COST = {
1752
+ input: 0,
1753
+ output: 0,
1754
+ cacheRead: 0,
1755
+ cacheWrite: 0
1756
+ };
1757
+ const SYNTHETIC_MODEL_CATALOG = [
1758
+ {
1759
+ id: SYNTHETIC_DEFAULT_MODEL_ID,
1760
+ name: "MiniMax M2.1",
1761
+ reasoning: false,
1762
+ input: ["text"],
1763
+ contextWindow: 192e3,
1764
+ maxTokens: 65536
1765
+ },
1766
+ {
1767
+ id: "hf:moonshotai/Kimi-K2-Thinking",
1768
+ name: "Kimi K2 Thinking",
1769
+ reasoning: true,
1770
+ input: ["text"],
1771
+ contextWindow: 256e3,
1772
+ maxTokens: 8192
1773
+ },
1774
+ {
1775
+ id: "hf:zai-org/GLM-4.7",
1776
+ name: "GLM-4.7",
1777
+ reasoning: false,
1778
+ input: ["text"],
1779
+ contextWindow: 198e3,
1780
+ maxTokens: 128e3
1781
+ },
1782
+ {
1783
+ id: "hf:deepseek-ai/DeepSeek-R1-0528",
1784
+ name: "DeepSeek R1 0528",
1785
+ reasoning: false,
1786
+ input: ["text"],
1787
+ contextWindow: 128e3,
1788
+ maxTokens: 8192
1789
+ },
1790
+ {
1791
+ id: "hf:deepseek-ai/DeepSeek-V3-0324",
1792
+ name: "DeepSeek V3 0324",
1793
+ reasoning: false,
1794
+ input: ["text"],
1795
+ contextWindow: 128e3,
1796
+ maxTokens: 8192
1797
+ },
1798
+ {
1799
+ id: "hf:deepseek-ai/DeepSeek-V3.1",
1800
+ name: "DeepSeek V3.1",
1801
+ reasoning: false,
1802
+ input: ["text"],
1803
+ contextWindow: 128e3,
1804
+ maxTokens: 8192
1805
+ },
1806
+ {
1807
+ id: "hf:deepseek-ai/DeepSeek-V3.1-Terminus",
1808
+ name: "DeepSeek V3.1 Terminus",
1809
+ reasoning: false,
1810
+ input: ["text"],
1811
+ contextWindow: 128e3,
1812
+ maxTokens: 8192
1813
+ },
1814
+ {
1815
+ id: "hf:deepseek-ai/DeepSeek-V3.2",
1816
+ name: "DeepSeek V3.2",
1817
+ reasoning: false,
1818
+ input: ["text"],
1819
+ contextWindow: 159e3,
1820
+ maxTokens: 8192
1821
+ },
1822
+ {
1823
+ id: "hf:meta-llama/Llama-3.3-70B-Instruct",
1824
+ name: "Llama 3.3 70B Instruct",
1825
+ reasoning: false,
1826
+ input: ["text"],
1827
+ contextWindow: 128e3,
1828
+ maxTokens: 8192
1829
+ },
1830
+ {
1831
+ id: "hf:meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",
1832
+ name: "Llama 4 Maverick 17B 128E Instruct FP8",
1833
+ reasoning: false,
1834
+ input: ["text"],
1835
+ contextWindow: 524e3,
1836
+ maxTokens: 8192
1837
+ },
1838
+ {
1839
+ id: "hf:moonshotai/Kimi-K2-Instruct-0905",
1840
+ name: "Kimi K2 Instruct 0905",
1841
+ reasoning: false,
1842
+ input: ["text"],
1843
+ contextWindow: 256e3,
1844
+ maxTokens: 8192
1845
+ },
1846
+ {
1847
+ id: "hf:moonshotai/Kimi-K2.5",
1848
+ name: "Kimi K2.5",
1849
+ reasoning: true,
1850
+ input: ["text"],
1851
+ contextWindow: 256e3,
1852
+ maxTokens: 8192
1853
+ },
1854
+ {
1855
+ id: "hf:openai/gpt-oss-120b",
1856
+ name: "GPT OSS 120B",
1857
+ reasoning: false,
1858
+ input: ["text"],
1859
+ contextWindow: 128e3,
1860
+ maxTokens: 8192
1861
+ },
1862
+ {
1863
+ id: "hf:Qwen/Qwen3-235B-A22B-Instruct-2507",
1864
+ name: "Qwen3 235B A22B Instruct 2507",
1865
+ reasoning: false,
1866
+ input: ["text"],
1867
+ contextWindow: 256e3,
1868
+ maxTokens: 8192
1869
+ },
1870
+ {
1871
+ id: "hf:Qwen/Qwen3-Coder-480B-A35B-Instruct",
1872
+ name: "Qwen3 Coder 480B A35B Instruct",
1873
+ reasoning: false,
1874
+ input: ["text"],
1875
+ contextWindow: 256e3,
1876
+ maxTokens: 8192
1877
+ },
1878
+ {
1879
+ id: "hf:Qwen/Qwen3-VL-235B-A22B-Instruct",
1880
+ name: "Qwen3 VL 235B A22B Instruct",
1881
+ reasoning: false,
1882
+ input: ["text", "image"],
1883
+ contextWindow: 25e4,
1884
+ maxTokens: 8192
1885
+ },
1886
+ {
1887
+ id: "hf:zai-org/GLM-4.5",
1888
+ name: "GLM-4.5",
1889
+ reasoning: false,
1890
+ input: ["text"],
1891
+ contextWindow: 128e3,
1892
+ maxTokens: 128e3
1893
+ },
1894
+ {
1895
+ id: "hf:zai-org/GLM-4.6",
1896
+ name: "GLM-4.6",
1897
+ reasoning: false,
1898
+ input: ["text"],
1899
+ contextWindow: 198e3,
1900
+ maxTokens: 128e3
1901
+ },
1902
+ {
1903
+ id: "hf:zai-org/GLM-5",
1904
+ name: "GLM-5",
1905
+ reasoning: true,
1906
+ input: ["text", "image"],
1907
+ contextWindow: 256e3,
1908
+ maxTokens: 128e3
1909
+ },
1910
+ {
1911
+ id: "hf:deepseek-ai/DeepSeek-V3",
1912
+ name: "DeepSeek V3",
1913
+ reasoning: false,
1914
+ input: ["text"],
1915
+ contextWindow: 128e3,
1916
+ maxTokens: 8192
1917
+ },
1918
+ {
1919
+ id: "hf:Qwen/Qwen3-235B-A22B-Thinking-2507",
1920
+ name: "Qwen3 235B A22B Thinking 2507",
1921
+ reasoning: true,
1922
+ input: ["text"],
1923
+ contextWindow: 256e3,
1924
+ maxTokens: 8192
1925
+ }
1926
+ ];
1927
+ function buildSyntheticModelDefinition(entry) {
1928
+ return {
1929
+ id: entry.id,
1930
+ name: entry.name,
1931
+ reasoning: entry.reasoning,
1932
+ input: [...entry.input],
1933
+ cost: SYNTHETIC_DEFAULT_COST,
1934
+ contextWindow: entry.contextWindow,
1935
+ maxTokens: entry.maxTokens
1936
+ };
1937
+ }
1938
+
1939
+ //#endregion
1940
+ //#region src/agents/together-models.ts
1941
+ const TOGETHER_BASE_URL = "https://api.together.xyz/v1";
1942
+ const TOGETHER_MODEL_CATALOG = [
1943
+ {
1944
+ id: "zai-org/GLM-4.7",
1945
+ name: "GLM 4.7 Fp8",
1946
+ reasoning: false,
1947
+ input: ["text"],
1948
+ contextWindow: 202752,
1949
+ maxTokens: 8192,
1950
+ cost: {
1951
+ input: .45,
1952
+ output: 2,
1953
+ cacheRead: .45,
1954
+ cacheWrite: 2
1955
+ }
1956
+ },
1957
+ {
1958
+ id: "moonshotai/Kimi-K2.5",
1959
+ name: "Kimi K2.5",
1960
+ reasoning: true,
1961
+ input: ["text", "image"],
1962
+ cost: {
1963
+ input: .5,
1964
+ output: 2.8,
1965
+ cacheRead: .5,
1966
+ cacheWrite: 2.8
1967
+ },
1968
+ contextWindow: 262144,
1969
+ maxTokens: 32768
1970
+ },
1971
+ {
1972
+ id: "meta-llama/Llama-3.3-70B-Instruct-Turbo",
1973
+ name: "Llama 3.3 70B Instruct Turbo",
1974
+ reasoning: false,
1975
+ input: ["text"],
1976
+ contextWindow: 131072,
1977
+ maxTokens: 8192,
1978
+ cost: {
1979
+ input: .88,
1980
+ output: .88,
1981
+ cacheRead: .88,
1982
+ cacheWrite: .88
1983
+ }
1984
+ },
1985
+ {
1986
+ id: "meta-llama/Llama-4-Scout-17B-16E-Instruct",
1987
+ name: "Llama 4 Scout 17B 16E Instruct",
1988
+ reasoning: false,
1989
+ input: ["text", "image"],
1990
+ contextWindow: 1e7,
1991
+ maxTokens: 32768,
1992
+ cost: {
1993
+ input: .18,
1994
+ output: .59,
1995
+ cacheRead: .18,
1996
+ cacheWrite: .18
1997
+ }
1998
+ },
1999
+ {
2000
+ id: "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",
2001
+ name: "Llama 4 Maverick 17B 128E Instruct FP8",
2002
+ reasoning: false,
2003
+ input: ["text", "image"],
2004
+ contextWindow: 2e7,
2005
+ maxTokens: 32768,
2006
+ cost: {
2007
+ input: .27,
2008
+ output: .85,
2009
+ cacheRead: .27,
2010
+ cacheWrite: .27
2011
+ }
2012
+ },
2013
+ {
2014
+ id: "deepseek-ai/DeepSeek-V3.1",
2015
+ name: "DeepSeek V3.1",
2016
+ reasoning: false,
2017
+ input: ["text"],
2018
+ contextWindow: 131072,
2019
+ maxTokens: 8192,
2020
+ cost: {
2021
+ input: .6,
2022
+ output: 1.25,
2023
+ cacheRead: .6,
2024
+ cacheWrite: .6
2025
+ }
2026
+ },
2027
+ {
2028
+ id: "deepseek-ai/DeepSeek-R1",
2029
+ name: "DeepSeek R1",
2030
+ reasoning: true,
2031
+ input: ["text"],
2032
+ contextWindow: 131072,
2033
+ maxTokens: 8192,
2034
+ cost: {
2035
+ input: 3,
2036
+ output: 7,
2037
+ cacheRead: 3,
2038
+ cacheWrite: 3
2039
+ }
2040
+ },
2041
+ {
2042
+ id: "moonshotai/Kimi-K2-Instruct-0905",
2043
+ name: "Kimi K2-Instruct 0905",
2044
+ reasoning: false,
2045
+ input: ["text"],
2046
+ contextWindow: 262144,
2047
+ maxTokens: 8192,
2048
+ cost: {
2049
+ input: 1,
2050
+ output: 3,
2051
+ cacheRead: 1,
2052
+ cacheWrite: 3
2053
+ }
2054
+ }
2055
+ ];
2056
+ function buildTogetherModelDefinition(model) {
2057
+ return {
2058
+ id: model.id,
2059
+ name: model.name,
2060
+ api: "openai-completions",
2061
+ reasoning: model.reasoning,
2062
+ input: model.input,
2063
+ cost: model.cost,
2064
+ contextWindow: model.contextWindow,
2065
+ maxTokens: model.maxTokens
2066
+ };
2067
+ }
2068
+
2069
+ //#endregion
2070
+ //#region src/agents/venice-models.ts
2071
+ const VENICE_BASE_URL = "https://api.venice.ai/api/v1";
2072
+ const VENICE_DEFAULT_MODEL_ID = "llama-3.3-70b";
2073
+ const VENICE_DEFAULT_MODEL_REF = `venice/${VENICE_DEFAULT_MODEL_ID}`;
2074
+ const VENICE_DEFAULT_COST = {
2075
+ input: 0,
2076
+ output: 0,
2077
+ cacheRead: 0,
2078
+ cacheWrite: 0
2079
+ };
2080
+ /**
2081
+ * Complete catalog of Venice AI models.
2082
+ *
2083
+ * Venice provides two privacy modes:
2084
+ * - "private": Fully private inference, no logging, ephemeral
2085
+ * - "anonymized": Proxied through Venice with metadata stripped (for proprietary models)
2086
+ *
2087
+ * Note: The `privacy` field is included for documentation purposes but is not
2088
+ * propagated to ModelDefinitionConfig as it's not part of the core model schema.
2089
+ * Privacy mode is determined by the model itself, not configurable at runtime.
2090
+ *
2091
+ * This catalog serves as a fallback when the Venice API is unreachable.
2092
+ */
2093
+ const VENICE_MODEL_CATALOG = [
2094
+ {
2095
+ id: "llama-3.3-70b",
2096
+ name: "Llama 3.3 70B",
2097
+ reasoning: false,
2098
+ input: ["text"],
2099
+ contextWindow: 131072,
2100
+ maxTokens: 8192,
2101
+ privacy: "private"
2102
+ },
2103
+ {
2104
+ id: "llama-3.2-3b",
2105
+ name: "Llama 3.2 3B",
2106
+ reasoning: false,
2107
+ input: ["text"],
2108
+ contextWindow: 131072,
2109
+ maxTokens: 8192,
2110
+ privacy: "private"
2111
+ },
2112
+ {
2113
+ id: "hermes-3-llama-3.1-405b",
2114
+ name: "Hermes 3 Llama 3.1 405B",
2115
+ reasoning: false,
2116
+ input: ["text"],
2117
+ contextWindow: 131072,
2118
+ maxTokens: 8192,
2119
+ privacy: "private"
2120
+ },
2121
+ {
2122
+ id: "qwen3-235b-a22b-thinking-2507",
2123
+ name: "Qwen3 235B Thinking",
2124
+ reasoning: true,
2125
+ input: ["text"],
2126
+ contextWindow: 131072,
2127
+ maxTokens: 8192,
2128
+ privacy: "private"
2129
+ },
2130
+ {
2131
+ id: "qwen3-235b-a22b-instruct-2507",
2132
+ name: "Qwen3 235B Instruct",
2133
+ reasoning: false,
2134
+ input: ["text"],
2135
+ contextWindow: 131072,
2136
+ maxTokens: 8192,
2137
+ privacy: "private"
2138
+ },
2139
+ {
2140
+ id: "qwen3-coder-480b-a35b-instruct",
2141
+ name: "Qwen3 Coder 480B",
2142
+ reasoning: false,
2143
+ input: ["text"],
2144
+ contextWindow: 262144,
2145
+ maxTokens: 8192,
2146
+ privacy: "private"
2147
+ },
2148
+ {
2149
+ id: "qwen3-next-80b",
2150
+ name: "Qwen3 Next 80B",
2151
+ reasoning: false,
2152
+ input: ["text"],
2153
+ contextWindow: 262144,
2154
+ maxTokens: 8192,
2155
+ privacy: "private"
2156
+ },
2157
+ {
2158
+ id: "qwen3-vl-235b-a22b",
2159
+ name: "Qwen3 VL 235B (Vision)",
2160
+ reasoning: false,
2161
+ input: ["text", "image"],
2162
+ contextWindow: 262144,
2163
+ maxTokens: 8192,
2164
+ privacy: "private"
2165
+ },
2166
+ {
2167
+ id: "qwen3-4b",
2168
+ name: "Venice Small (Qwen3 4B)",
2169
+ reasoning: true,
2170
+ input: ["text"],
2171
+ contextWindow: 32768,
2172
+ maxTokens: 8192,
2173
+ privacy: "private"
2174
+ },
2175
+ {
2176
+ id: "deepseek-v3.2",
2177
+ name: "DeepSeek V3.2",
2178
+ reasoning: true,
2179
+ input: ["text"],
2180
+ contextWindow: 163840,
2181
+ maxTokens: 8192,
2182
+ privacy: "private"
2183
+ },
2184
+ {
2185
+ id: "venice-uncensored",
2186
+ name: "Venice Uncensored (Dolphin-Mistral)",
2187
+ reasoning: false,
2188
+ input: ["text"],
2189
+ contextWindow: 32768,
2190
+ maxTokens: 8192,
2191
+ privacy: "private"
2192
+ },
2193
+ {
2194
+ id: "mistral-31-24b",
2195
+ name: "Venice Medium (Mistral)",
2196
+ reasoning: false,
2197
+ input: ["text", "image"],
2198
+ contextWindow: 131072,
2199
+ maxTokens: 8192,
2200
+ privacy: "private"
2201
+ },
2202
+ {
2203
+ id: "google-gemma-3-27b-it",
2204
+ name: "Google Gemma 3 27B Instruct",
2205
+ reasoning: false,
2206
+ input: ["text", "image"],
2207
+ contextWindow: 202752,
2208
+ maxTokens: 8192,
2209
+ privacy: "private"
2210
+ },
2211
+ {
2212
+ id: "openai-gpt-oss-120b",
2213
+ name: "OpenAI GPT OSS 120B",
2214
+ reasoning: false,
2215
+ input: ["text"],
2216
+ contextWindow: 131072,
2217
+ maxTokens: 8192,
2218
+ privacy: "private"
2219
+ },
2220
+ {
2221
+ id: "zai-org-glm-4.7",
2222
+ name: "GLM 4.7",
2223
+ reasoning: true,
2224
+ input: ["text"],
2225
+ contextWindow: 202752,
2226
+ maxTokens: 8192,
2227
+ privacy: "private"
2228
+ },
2229
+ {
2230
+ id: "claude-opus-45",
2231
+ name: "Claude Opus 4.5 (via Venice)",
2232
+ reasoning: true,
2233
+ input: ["text", "image"],
2234
+ contextWindow: 202752,
2235
+ maxTokens: 8192,
2236
+ privacy: "anonymized"
2237
+ },
2238
+ {
2239
+ id: "claude-sonnet-45",
2240
+ name: "Claude Sonnet 4.5 (via Venice)",
2241
+ reasoning: true,
2242
+ input: ["text", "image"],
2243
+ contextWindow: 202752,
2244
+ maxTokens: 8192,
2245
+ privacy: "anonymized"
2246
+ },
2247
+ {
2248
+ id: "openai-gpt-52",
2249
+ name: "GPT-5.2 (via Venice)",
2250
+ reasoning: true,
2251
+ input: ["text"],
2252
+ contextWindow: 262144,
2253
+ maxTokens: 8192,
2254
+ privacy: "anonymized"
2255
+ },
2256
+ {
2257
+ id: "openai-gpt-52-codex",
2258
+ name: "GPT-5.2 Codex (via Venice)",
2259
+ reasoning: true,
2260
+ input: ["text", "image"],
2261
+ contextWindow: 262144,
2262
+ maxTokens: 8192,
2263
+ privacy: "anonymized"
2264
+ },
2265
+ {
2266
+ id: "gemini-3-pro-preview",
2267
+ name: "Gemini 3 Pro (via Venice)",
2268
+ reasoning: true,
2269
+ input: ["text", "image"],
2270
+ contextWindow: 202752,
2271
+ maxTokens: 8192,
2272
+ privacy: "anonymized"
2273
+ },
2274
+ {
2275
+ id: "gemini-3-flash-preview",
2276
+ name: "Gemini 3 Flash (via Venice)",
2277
+ reasoning: true,
2278
+ input: ["text", "image"],
2279
+ contextWindow: 262144,
2280
+ maxTokens: 8192,
2281
+ privacy: "anonymized"
2282
+ },
2283
+ {
2284
+ id: "grok-41-fast",
2285
+ name: "Grok 4.1 Fast (via Venice)",
2286
+ reasoning: true,
2287
+ input: ["text", "image"],
2288
+ contextWindow: 262144,
2289
+ maxTokens: 8192,
2290
+ privacy: "anonymized"
2291
+ },
2292
+ {
2293
+ id: "grok-code-fast-1",
2294
+ name: "Grok Code Fast 1 (via Venice)",
2295
+ reasoning: true,
2296
+ input: ["text"],
2297
+ contextWindow: 262144,
2298
+ maxTokens: 8192,
2299
+ privacy: "anonymized"
2300
+ },
2301
+ {
2302
+ id: "kimi-k2-thinking",
2303
+ name: "Kimi K2 Thinking (via Venice)",
2304
+ reasoning: true,
2305
+ input: ["text"],
2306
+ contextWindow: 262144,
2307
+ maxTokens: 8192,
2308
+ privacy: "anonymized"
2309
+ },
2310
+ {
2311
+ id: "minimax-m21",
2312
+ name: "MiniMax M2.1 (via Venice)",
2313
+ reasoning: true,
2314
+ input: ["text"],
2315
+ contextWindow: 202752,
2316
+ maxTokens: 8192,
2317
+ privacy: "anonymized"
2318
+ }
2319
+ ];
2320
+ /**
2321
+ * Build a ModelDefinitionConfig from a Venice catalog entry.
2322
+ *
2323
+ * Note: The `privacy` field from the catalog is not included in the output
2324
+ * as ModelDefinitionConfig doesn't support custom metadata fields. Privacy
2325
+ * mode is inherent to each model and documented in the catalog/docs.
2326
+ */
2327
+ function buildVeniceModelDefinition(entry) {
2328
+ return {
2329
+ id: entry.id,
2330
+ name: entry.name,
2331
+ reasoning: entry.reasoning,
2332
+ input: [...entry.input],
2333
+ cost: VENICE_DEFAULT_COST,
2334
+ contextWindow: entry.contextWindow,
2335
+ maxTokens: entry.maxTokens,
2336
+ compat: { supportsUsageInStreaming: false }
2337
+ };
2338
+ }
2339
+
2340
+ //#endregion
2341
+ //#region src/agents/models-config.providers.ts
2342
+ const XIAOMI_BASE_URL = "https://api.xiaomimimo.com/anthropic";
2343
+ const XIAOMI_DEFAULT_MODEL_ID = "mimo-v2-flash";
2344
+ const XIAOMI_DEFAULT_CONTEXT_WINDOW = 262144;
2345
+ const XIAOMI_DEFAULT_MAX_TOKENS = 8192;
2346
+ const XIAOMI_DEFAULT_COST = {
2347
+ input: 0,
2348
+ output: 0,
2349
+ cacheRead: 0,
2350
+ cacheWrite: 0
2351
+ };
2352
+ const QIANFAN_BASE_URL = "https://qianfan.baidubce.com/v2";
2353
+ const QIANFAN_DEFAULT_MODEL_ID = "deepseek-v3.2";
2354
+ const QIANFAN_DEFAULT_CONTEXT_WINDOW = 98304;
2355
+ const QIANFAN_DEFAULT_MAX_TOKENS = 32768;
2356
+ const QIANFAN_DEFAULT_COST = {
2357
+ input: 0,
2358
+ output: 0,
2359
+ cacheRead: 0,
2360
+ cacheWrite: 0
2361
+ };
2362
+ function normalizeGoogleModelId(id) {
2363
+ if (id === "gemini-3-pro") return "gemini-3-pro-preview";
2364
+ if (id === "gemini-3-flash") return "gemini-3-flash-preview";
2365
+ return id;
2366
+ }
2367
+ function buildXiaomiProvider() {
2368
+ return {
2369
+ baseUrl: XIAOMI_BASE_URL,
2370
+ api: "anthropic-messages",
2371
+ models: [{
2372
+ id: XIAOMI_DEFAULT_MODEL_ID,
2373
+ name: "Xiaomi MiMo V2 Flash",
2374
+ reasoning: false,
2375
+ input: ["text"],
2376
+ cost: XIAOMI_DEFAULT_COST,
2377
+ contextWindow: XIAOMI_DEFAULT_CONTEXT_WINDOW,
2378
+ maxTokens: XIAOMI_DEFAULT_MAX_TOKENS
2379
+ }]
2380
+ };
2381
+ }
2382
+ function buildQianfanProvider() {
2383
+ return {
2384
+ baseUrl: QIANFAN_BASE_URL,
2385
+ api: "openai-completions",
2386
+ models: [{
2387
+ id: QIANFAN_DEFAULT_MODEL_ID,
2388
+ name: "DEEPSEEK V3.2",
2389
+ reasoning: true,
2390
+ input: ["text"],
2391
+ cost: QIANFAN_DEFAULT_COST,
2392
+ contextWindow: QIANFAN_DEFAULT_CONTEXT_WINDOW,
2393
+ maxTokens: QIANFAN_DEFAULT_MAX_TOKENS
2394
+ }, {
2395
+ id: "ernie-5.0-thinking-preview",
2396
+ name: "ERNIE-5.0-Thinking-Preview",
2397
+ reasoning: true,
2398
+ input: ["text", "image"],
2399
+ cost: QIANFAN_DEFAULT_COST,
2400
+ contextWindow: 119e3,
2401
+ maxTokens: 64e3
2402
+ }]
2403
+ };
2404
+ }
2405
+
2406
+ //#endregion
2407
+ //#region src/agents/model-selection.ts
2408
+ const ANTHROPIC_MODEL_ALIASES = {
2409
+ "opus-4.6": "claude-opus-4-6",
2410
+ "opus-4.5": "claude-opus-4-5",
2411
+ "sonnet-4.5": "claude-sonnet-4-5"
2412
+ };
2413
+ const OPENAI_CODEX_OAUTH_MODEL_PREFIXES = ["gpt-5.3-codex"];
2414
+ function normalizeAliasKey(value) {
2415
+ return value.trim().toLowerCase();
2416
+ }
2417
+ function modelKey(provider, model) {
2418
+ return `${provider}/${model}`;
2419
+ }
2420
+ function normalizeProviderId(provider) {
2421
+ const normalized = provider.trim().toLowerCase();
2422
+ if (normalized === "z.ai" || normalized === "z-ai") return "zai";
2423
+ if (normalized === "opencode-zen") return "opencode";
2424
+ if (normalized === "qwen") return "qwen-portal";
2425
+ if (normalized === "kimi-code") return "kimi-coding";
2426
+ return normalized;
2427
+ }
2428
+ function isCliProvider(provider, cfg) {
2429
+ const normalized = normalizeProviderId(provider);
2430
+ if (normalized === "claude-cli") return true;
2431
+ if (normalized === "codex-cli") return true;
2432
+ const backends = cfg?.agents?.defaults?.cliBackends ?? {};
2433
+ return Object.keys(backends).some((key) => normalizeProviderId(key) === normalized);
2434
+ }
2435
+ function normalizeAnthropicModelId(model) {
2436
+ const trimmed = model.trim();
2437
+ if (!trimmed) return trimmed;
2438
+ return ANTHROPIC_MODEL_ALIASES[trimmed.toLowerCase()] ?? trimmed;
2439
+ }
2440
+ function normalizeProviderModelId(provider, model) {
2441
+ if (provider === "anthropic") return normalizeAnthropicModelId(model);
2442
+ if (provider === "google") return normalizeGoogleModelId(model);
2443
+ return model;
2444
+ }
2445
+ function shouldUseOpenAICodexProvider(provider, model) {
2446
+ if (provider !== "openai") return false;
2447
+ const normalized = model.trim().toLowerCase();
2448
+ if (!normalized) return false;
2449
+ return OPENAI_CODEX_OAUTH_MODEL_PREFIXES.some((prefix) => normalized === prefix || normalized.startsWith(`${prefix}-`));
2450
+ }
2451
+ function normalizeModelRef(provider, model) {
2452
+ const normalizedProvider = normalizeProviderId(provider);
2453
+ const normalizedModel = normalizeProviderModelId(normalizedProvider, model.trim());
2454
+ if (shouldUseOpenAICodexProvider(normalizedProvider, normalizedModel)) return {
2455
+ provider: "openai-codex",
2456
+ model: normalizedModel
2457
+ };
2458
+ return {
2459
+ provider: normalizedProvider,
2460
+ model: normalizedModel
2461
+ };
2462
+ }
2463
+ function parseModelRef(raw, defaultProvider) {
2464
+ const trimmed = raw.trim();
2465
+ if (!trimmed) return null;
2466
+ const slash = trimmed.indexOf("/");
2467
+ if (slash === -1) return normalizeModelRef(defaultProvider, trimmed);
2468
+ const providerRaw = trimmed.slice(0, slash).trim();
2469
+ const model = trimmed.slice(slash + 1).trim();
2470
+ if (!providerRaw || !model) return null;
2471
+ return normalizeModelRef(providerRaw, model);
2472
+ }
2473
+ function resolveAllowlistModelKey(raw, defaultProvider) {
2474
+ const parsed = parseModelRef(raw, defaultProvider);
2475
+ if (!parsed) return null;
2476
+ return modelKey(parsed.provider, parsed.model);
2477
+ }
2478
+ function buildConfiguredAllowlistKeys(params) {
2479
+ const rawAllowlist = Object.keys(params.cfg?.agents?.defaults?.models ?? {});
2480
+ if (rawAllowlist.length === 0) return null;
2481
+ const keys = /* @__PURE__ */ new Set();
2482
+ for (const raw of rawAllowlist) {
2483
+ const key = resolveAllowlistModelKey(String(raw ?? ""), params.defaultProvider);
2484
+ if (key) keys.add(key);
2485
+ }
2486
+ return keys.size > 0 ? keys : null;
2487
+ }
2488
+ function buildModelAliasIndex(params) {
2489
+ const byAlias = /* @__PURE__ */ new Map();
2490
+ const byKey = /* @__PURE__ */ new Map();
2491
+ const rawModels = params.cfg.agents?.defaults?.models ?? {};
2492
+ for (const [keyRaw, entryRaw] of Object.entries(rawModels)) {
2493
+ const parsed = parseModelRef(String(keyRaw ?? ""), params.defaultProvider);
2494
+ if (!parsed) continue;
2495
+ const alias = String(entryRaw?.alias ?? "").trim();
2496
+ if (!alias) continue;
2497
+ const aliasKey = normalizeAliasKey(alias);
2498
+ byAlias.set(aliasKey, {
2499
+ alias,
2500
+ ref: parsed
2501
+ });
2502
+ const key = modelKey(parsed.provider, parsed.model);
2503
+ const existing = byKey.get(key) ?? [];
2504
+ existing.push(alias);
2505
+ byKey.set(key, existing);
2506
+ }
2507
+ return {
2508
+ byAlias,
2509
+ byKey
2510
+ };
2511
+ }
2512
+ function resolveModelRefFromString(params) {
2513
+ const trimmed = params.raw.trim();
2514
+ if (!trimmed) return null;
2515
+ if (!trimmed.includes("/")) {
2516
+ const aliasKey = normalizeAliasKey(trimmed);
2517
+ const aliasMatch = params.aliasIndex?.byAlias.get(aliasKey);
2518
+ if (aliasMatch) return {
2519
+ ref: aliasMatch.ref,
2520
+ alias: aliasMatch.alias
2521
+ };
2522
+ }
2523
+ const parsed = parseModelRef(trimmed, params.defaultProvider);
2524
+ if (!parsed) return null;
2525
+ return { ref: parsed };
2526
+ }
2527
+ function resolveConfiguredModelRef(params) {
2528
+ const rawModel = (() => {
2529
+ const raw = params.cfg.agents?.defaults?.model;
2530
+ if (typeof raw === "string") return raw.trim();
2531
+ return raw?.primary?.trim() ?? "";
2532
+ })();
2533
+ if (rawModel) {
2534
+ const trimmed = rawModel.trim();
2535
+ const aliasIndex = buildModelAliasIndex({
2536
+ cfg: params.cfg,
2537
+ defaultProvider: params.defaultProvider
2538
+ });
2539
+ if (!trimmed.includes("/")) {
2540
+ const aliasKey = normalizeAliasKey(trimmed);
2541
+ const aliasMatch = aliasIndex.byAlias.get(aliasKey);
2542
+ if (aliasMatch) return aliasMatch.ref;
2543
+ console.warn(`[anima] Model "${trimmed}" specified without provider. Falling back to "anthropic/${trimmed}". Please use "anthropic/${trimmed}" in your config.`);
2544
+ return {
2545
+ provider: "anthropic",
2546
+ model: trimmed
2547
+ };
2548
+ }
2549
+ const resolved = resolveModelRefFromString({
2550
+ raw: trimmed,
2551
+ defaultProvider: params.defaultProvider,
2552
+ aliasIndex
2553
+ });
2554
+ if (resolved) return resolved.ref;
2555
+ }
2556
+ return {
2557
+ provider: params.defaultProvider,
2558
+ model: params.defaultModel
2559
+ };
2560
+ }
2561
+ function resolveDefaultModelForAgent(params) {
2562
+ const agentModelOverride = params.agentId ? resolveAgentModelPrimary(params.cfg, params.agentId) : void 0;
2563
+ return resolveConfiguredModelRef({
2564
+ cfg: agentModelOverride && agentModelOverride.length > 0 ? {
2565
+ ...params.cfg,
2566
+ agents: {
2567
+ ...params.cfg.agents,
2568
+ defaults: {
2569
+ ...params.cfg.agents?.defaults,
2570
+ model: {
2571
+ ...typeof params.cfg.agents?.defaults?.model === "object" ? params.cfg.agents.defaults.model : void 0,
2572
+ primary: agentModelOverride
2573
+ }
2574
+ }
2575
+ }
2576
+ } : params.cfg,
2577
+ defaultProvider: DEFAULT_PROVIDER,
2578
+ defaultModel: DEFAULT_MODEL
2579
+ });
2580
+ }
2581
+ function buildAllowedModelSet(params) {
2582
+ const rawAllowlist = (() => {
2583
+ const modelMap = params.cfg.agents?.defaults?.models ?? {};
2584
+ return Object.keys(modelMap);
2585
+ })();
2586
+ const allowAny = rawAllowlist.length === 0;
2587
+ const defaultModel = params.defaultModel?.trim();
2588
+ const defaultKey = defaultModel && params.defaultProvider ? modelKey(params.defaultProvider, defaultModel) : void 0;
2589
+ const catalogKeys = new Set(params.catalog.map((entry) => modelKey(entry.provider, entry.id)));
2590
+ if (allowAny) {
2591
+ if (defaultKey) catalogKeys.add(defaultKey);
2592
+ return {
2593
+ allowAny: true,
2594
+ allowedCatalog: params.catalog,
2595
+ allowedKeys: catalogKeys
2596
+ };
2597
+ }
2598
+ const allowedKeys = /* @__PURE__ */ new Set();
2599
+ const configuredProviders = params.cfg.models?.providers ?? {};
2600
+ for (const raw of rawAllowlist) {
2601
+ const parsed = parseModelRef(String(raw), params.defaultProvider);
2602
+ if (!parsed) continue;
2603
+ const key = modelKey(parsed.provider, parsed.model);
2604
+ const providerKey = normalizeProviderId(parsed.provider);
2605
+ if (isCliProvider(parsed.provider, params.cfg)) allowedKeys.add(key);
2606
+ else if (catalogKeys.has(key)) allowedKeys.add(key);
2607
+ else if (configuredProviders[providerKey] != null) allowedKeys.add(key);
2608
+ }
2609
+ if (defaultKey) allowedKeys.add(defaultKey);
2610
+ const allowedCatalog = params.catalog.filter((entry) => allowedKeys.has(modelKey(entry.provider, entry.id)));
2611
+ if (allowedCatalog.length === 0 && allowedKeys.size === 0) {
2612
+ if (defaultKey) catalogKeys.add(defaultKey);
2613
+ return {
2614
+ allowAny: true,
2615
+ allowedCatalog: params.catalog,
2616
+ allowedKeys: catalogKeys
2617
+ };
2618
+ }
2619
+ return {
2620
+ allowAny: false,
2621
+ allowedCatalog,
2622
+ allowedKeys
2623
+ };
2624
+ }
2625
+ function getModelRefStatus(params) {
2626
+ const allowed = buildAllowedModelSet({
2627
+ cfg: params.cfg,
2628
+ catalog: params.catalog,
2629
+ defaultProvider: params.defaultProvider,
2630
+ defaultModel: params.defaultModel
2631
+ });
2632
+ const key = modelKey(params.ref.provider, params.ref.model);
2633
+ return {
2634
+ key,
2635
+ inCatalog: params.catalog.some((entry) => modelKey(entry.provider, entry.id) === key),
2636
+ allowAny: allowed.allowAny,
2637
+ allowed: allowed.allowAny || allowed.allowedKeys.has(key)
2638
+ };
2639
+ }
2640
+ function resolveAllowedModelRef(params) {
2641
+ const trimmed = params.raw.trim();
2642
+ if (!trimmed) return { error: "invalid model: empty" };
2643
+ const aliasIndex = buildModelAliasIndex({
2644
+ cfg: params.cfg,
2645
+ defaultProvider: params.defaultProvider
2646
+ });
2647
+ const resolved = resolveModelRefFromString({
2648
+ raw: trimmed,
2649
+ defaultProvider: params.defaultProvider,
2650
+ aliasIndex
2651
+ });
2652
+ if (!resolved) return { error: `invalid model: ${trimmed}` };
2653
+ const status = getModelRefStatus({
2654
+ cfg: params.cfg,
2655
+ catalog: params.catalog,
2656
+ ref: resolved.ref,
2657
+ defaultProvider: params.defaultProvider,
2658
+ defaultModel: params.defaultModel
2659
+ });
2660
+ if (!status.allowed) return { error: `model not allowed: ${status.key}` };
2661
+ return {
2662
+ ref: resolved.ref,
2663
+ key: status.key
2664
+ };
2665
+ }
2666
+ function resolveThinkingDefault(params) {
2667
+ const configured = params.cfg.agents?.defaults?.thinkingDefault;
2668
+ if (configured) return configured;
2669
+ if ((params.catalog?.find((entry) => entry.provider === params.provider && entry.id === params.model))?.reasoning) return "low";
2670
+ return "off";
2671
+ }
2672
+ /**
2673
+ * Resolve the model configured for Gmail hook processing.
2674
+ * Returns null if hooks.gmail.model is not set.
2675
+ */
2676
+ function resolveHooksGmailModel(params) {
2677
+ const hooksModel = params.cfg.hooks?.gmail?.model;
2678
+ if (!hooksModel?.trim()) return null;
2679
+ const aliasIndex = buildModelAliasIndex({
2680
+ cfg: params.cfg,
2681
+ defaultProvider: params.defaultProvider
2682
+ });
2683
+ return resolveModelRefFromString({
2684
+ raw: hooksModel,
2685
+ defaultProvider: params.defaultProvider,
2686
+ aliasIndex
2687
+ })?.ref ?? null;
2688
+ }
2689
+
2690
+ //#endregion
2691
+ export { resolveCloudflareAiGatewayBaseUrl as $, SYNTHETIC_DEFAULT_MODEL_REF as A, DEFAULT_PROVIDER as At, getShellEnvAppliedKeys as B, VENICE_DEFAULT_MODEL_REF as C, normalizeOptionalSecretInput as Ct, TOGETHER_MODEL_CATALOG as D, CODEX_CLI_PROFILE_ID as Dt, TOGETHER_BASE_URL as E, CLAUDE_CLI_PROFILE_ID as Et, requireApiKey as F, shouldEnableShellEnvFallback as G, loadShellEnvFallback as H, resolveApiKeyForProvider as I, buildHuggingfaceModelDefinition as J, HUGGINGFACE_BASE_URL as K, resolveAwsSdkEnvVarName as L, buildSyntheticModelDefinition as M, getApiKeyForModel as N, buildTogetherModelDefinition as O, DEFAULT_CONTEXT_TOKENS as Ot, getCustomProviderApiKey as P, buildCloudflareAiGatewayModelDefinition as Q, resolveEnvApiKey as R, VENICE_BASE_URL as S, withFileLock as St, buildVeniceModelDefinition as T, resolveAuthProfileDisplayLabel as Tt, resolveShellEnvFallbackTimeoutMs as U, getShellPathFromLoginShell as V, shouldDeferShellEnvFallback as W, isHuggingfacePolicyLocked as X, discoverHuggingfaceModels as Y, CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF as Z, QIANFAN_BASE_URL as _, resolveAuthStorePath as _t, isCliProvider as a, CHUTES_AUTHORIZE_ENDPOINT as at, buildQianfanProvider as b, loadJsonFile as bt, normalizeProviderId as c, parseOAuthCallbackInput as ct, resolveAllowlistModelKey as d, setAuthProfileOrder as dt, auth_profiles_exports as et, resolveConfiguredModelRef as f, upsertAuthProfile as ft, resolveThinkingDefault as g, updateAuthProfileStoreWithLock as gt, resolveModelRefFromString as h, loadAuthProfileStore as ht, getModelRefStatus as i, resolveApiKeyForProfile as it, SYNTHETIC_MODEL_CATALOG as j, SYNTHETIC_BASE_URL as k, DEFAULT_MODEL as kt, parseModelRef as l, repairOAuthProfileIdMismatch as lt, resolveHooksGmailModel as m, ensureAuthProfileStore as mt, buildConfiguredAllowlistKeys as n, isProfileInCooldown as nt, modelKey as o, exchangeChutesCodeForTokens as ot, resolveDefaultModelForAgent as p, upsertAuthProfileWithLock as pt, HUGGINGFACE_MODEL_CATALOG as q, buildModelAliasIndex as r, resolveProfileUnusableUntilForDisplay as rt, normalizeModelRef as s, generateChutesPkce as st, buildAllowedModelSet as t, resolveAuthProfileOrder as tt, resolveAllowedModelRef as u, listProfilesForProvider as ut, QIANFAN_DEFAULT_MODEL_ID as v, resolveAuthStorePathForDisplay as vt, VENICE_MODEL_CATALOG as w, normalizeSecretInput as wt, buildXiaomiProvider as x, saveJsonFile as xt, XIAOMI_DEFAULT_MODEL_ID as y, resolveAnimaAgentDir as yt, resolveModelAuthMode as z };