@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,2510 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
2
+ import { A as colorize, M as theme, R as CONFIG_PATH, j as isRich$1 } from "./entry.js";
3
+ import { Dt as DEFAULT_PROVIDER, E as buildModelAliasIndex, Et as DEFAULT_MODEL, F as resolveConfiguredModelRef, I as resolveDefaultModelForAgent, M as parseModelRef, Ot as resolveAuthProfileDisplayLabel, R as resolveModelRefFromString, Tt as DEFAULT_CONTEXT_TOKENS, at as resolveApiKeyForProvider, b as resolveAnimaAgentDir, d as listProfilesForProvider, dt as getShellEnvAppliedKeys, f as setAuthProfileOrder, gt as shouldEnableShellEnvFallback, h as ensureAuthProfileStore, i as resolveProfileUnusableUntilForDisplay, j as normalizeProviderId, k as modelKey, n as resolveAuthProfileOrder, ot as resolveAwsSdkEnvVarName, p as upsertAuthProfile, rt as getCustomProviderApiKey, st as resolveEnvApiKey, y as resolveAuthStorePathForDisplay } from "./auth-profiles-CxSHydjn.js";
4
+ import { t as formatCliCommand } from "./command-format-G6N2zghg.js";
5
+ import { S as shortenHomePath } from "./utils-DT8uXjFS.js";
6
+ import { a as resolveAgentModelPrimary, c as resolveDefaultAgentId, i as resolveAgentModelFallbacksOverride, r as resolveAgentDir, s as resolveAgentWorkspaceDir, w as resolveDefaultAgentWorkspaceDir } from "./agent-scope-DZgptr9J.js";
7
+ import { n as discoverModels, t as discoverAuthStorage } from "./pi-model-discovery-DzEIEgHL.js";
8
+ import { i as loadConfig, m as parseDurationMs, o as readConfigFileSnapshot } from "./config-CU-Axg8P.js";
9
+ import { g as runEmbeddedPiAgent } from "./timeout-Ddn-5kAO.js";
10
+ import { c as loadProviderUsageSummary, d as resolveUsageProviderId, u as formatUsageWindowSummary } from "./reply-r089HuRA.js";
11
+ import { i as resolveSessionTranscriptPath, s as resolveSessionTranscriptsDirForAgent } from "./paths-DfQGx0_k.js";
12
+ import { A as describeFailoverError, Yt as loadModelCatalog, tt as resolveModel } from "./cli-session-gtuYN2Iq.js";
13
+ import { n as ensureAnimaModelsJson } from "./context-DzgXOckU.js";
14
+ import { r as withProgressTotals } from "./progress-C9Ha1NJh.js";
15
+ import { n as stylePromptMessage, r as stylePromptTitle, t as stylePromptHint } from "./prompt-style-DQi8j03a.js";
16
+ import { t as createClackPrompter } from "./clack-prompter-BI3RDW5w.js";
17
+ import { d as openUrl } from "./onboard-helpers-B8roRwLP.js";
18
+ import { t as renderTable } from "./table-DhXHfRX2.js";
19
+ import { _ as applyAuthProfileConfig, a as resolveProviderMatch, c as resolvePluginProviders, i as pickAuthMethod, kt as validateAnthropicSetupToken, n as applyDefaultModel, o as createVpsAwareOAuthHandlers, r as mergeConfigPatch, s as isRemoteEnvironment } from "./github-copilot-auth-DXpOMSd3.js";
20
+ import { a as normalizeAlias, c as updateConfig, i as isLocalBaseUrl, n as formatMs, o as resolveKnownAgentId, r as formatTokenK, s as resolveModelTarget, t as ensureFlagCompatibility } from "./shared-kzrojZ1B.js";
21
+ import { n as logConfigUpdated } from "./logging-C7lb3Vjc.js";
22
+ import { t as inferParamBFromIdOrName } from "./model-param-b-C4BL7w0Z.js";
23
+ import { n as redactSecrets } from "./format-CjKG6raZ.js";
24
+ import { n as buildAuthHealthSummary, r as formatRemainingShort, t as DEFAULT_OAUTH_WARN_MS } from "./auth-health-B7FqA26_.js";
25
+ import path from "node:path";
26
+ import fs from "node:fs/promises";
27
+ import { complete, getEnvApiKey, getModel } from "@mariozechner/pi-ai";
28
+ import crypto from "node:crypto";
29
+ import { Type } from "@sinclair/typebox";
30
+ import { cancel, confirm, isCancel, multiselect, select, text } from "@clack/prompts";
31
+
32
+ //#region src/commands/models/aliases.ts
33
+ async function modelsAliasesListCommand(opts, runtime) {
34
+ ensureFlagCompatibility(opts);
35
+ const models = loadConfig().agents?.defaults?.models ?? {};
36
+ const aliases = Object.entries(models).reduce((acc, [modelKey, entry]) => {
37
+ const alias = entry?.alias?.trim();
38
+ if (alias) acc[alias] = modelKey;
39
+ return acc;
40
+ }, {});
41
+ if (opts.json) {
42
+ runtime.log(JSON.stringify({ aliases }, null, 2));
43
+ return;
44
+ }
45
+ if (opts.plain) {
46
+ for (const [alias, target] of Object.entries(aliases)) runtime.log(`${alias} ${target}`);
47
+ return;
48
+ }
49
+ runtime.log(`Aliases (${Object.keys(aliases).length}):`);
50
+ if (Object.keys(aliases).length === 0) {
51
+ runtime.log("- none");
52
+ return;
53
+ }
54
+ for (const [alias, target] of Object.entries(aliases)) runtime.log(`- ${alias} -> ${target}`);
55
+ }
56
+ async function modelsAliasesAddCommand(aliasRaw, modelRaw, runtime) {
57
+ const alias = normalizeAlias(aliasRaw);
58
+ const resolved = resolveModelTarget({
59
+ raw: modelRaw,
60
+ cfg: loadConfig()
61
+ });
62
+ await updateConfig((cfg) => {
63
+ const modelKey = `${resolved.provider}/${resolved.model}`;
64
+ const nextModels = { ...cfg.agents?.defaults?.models };
65
+ for (const [key, entry] of Object.entries(nextModels)) {
66
+ const existing = entry?.alias?.trim();
67
+ if (existing && existing === alias && key !== modelKey) throw new Error(`Alias ${alias} already points to ${key}.`);
68
+ }
69
+ nextModels[modelKey] = {
70
+ ...nextModels[modelKey] ?? {},
71
+ alias
72
+ };
73
+ return {
74
+ ...cfg,
75
+ agents: {
76
+ ...cfg.agents,
77
+ defaults: {
78
+ ...cfg.agents?.defaults,
79
+ models: nextModels
80
+ }
81
+ }
82
+ };
83
+ });
84
+ logConfigUpdated(runtime);
85
+ runtime.log(`Alias ${alias} -> ${resolved.provider}/${resolved.model}`);
86
+ }
87
+ async function modelsAliasesRemoveCommand(aliasRaw, runtime) {
88
+ const alias = normalizeAlias(aliasRaw);
89
+ const updated = await updateConfig((cfg) => {
90
+ const nextModels = { ...cfg.agents?.defaults?.models };
91
+ let found = false;
92
+ for (const [key, entry] of Object.entries(nextModels)) if (entry?.alias?.trim() === alias) {
93
+ nextModels[key] = {
94
+ ...entry,
95
+ alias: void 0
96
+ };
97
+ found = true;
98
+ break;
99
+ }
100
+ if (!found) throw new Error(`Alias not found: ${alias}`);
101
+ return {
102
+ ...cfg,
103
+ agents: {
104
+ ...cfg.agents,
105
+ defaults: {
106
+ ...cfg.agents?.defaults,
107
+ models: nextModels
108
+ }
109
+ }
110
+ };
111
+ });
112
+ logConfigUpdated(runtime);
113
+ if (!updated.agents?.defaults?.models || Object.values(updated.agents.defaults.models).every((entry) => !entry?.alias?.trim())) runtime.log("No aliases configured.");
114
+ }
115
+
116
+ //#endregion
117
+ //#region src/commands/models/auth.ts
118
+ const confirm$1 = (params) => confirm({
119
+ ...params,
120
+ message: stylePromptMessage(params.message)
121
+ });
122
+ const text$1 = (params) => text({
123
+ ...params,
124
+ message: stylePromptMessage(params.message)
125
+ });
126
+ const select$1 = (params) => select({
127
+ ...params,
128
+ message: stylePromptMessage(params.message),
129
+ options: params.options.map((opt) => opt.hint === void 0 ? opt : {
130
+ ...opt,
131
+ hint: stylePromptHint(opt.hint)
132
+ })
133
+ });
134
+ function resolveTokenProvider(raw) {
135
+ const trimmed = raw?.trim();
136
+ if (!trimmed) return null;
137
+ if (normalizeProviderId(trimmed) === "anthropic") return "anthropic";
138
+ return "custom";
139
+ }
140
+ function resolveDefaultTokenProfileId(provider) {
141
+ return `${normalizeProviderId(provider)}:manual`;
142
+ }
143
+ async function modelsAuthSetupTokenCommand(opts, runtime) {
144
+ const provider = resolveTokenProvider(opts.provider ?? "anthropic");
145
+ if (provider !== "anthropic") throw new Error("Only --provider anthropic is supported for setup-token.");
146
+ if (!process.stdin.isTTY) throw new Error("setup-token requires an interactive TTY.");
147
+ if (!opts.yes) {
148
+ if (!await confirm$1({
149
+ message: "Have you run `claude setup-token` and copied the token?",
150
+ initialValue: true
151
+ })) return;
152
+ }
153
+ const tokenInput = await text$1({
154
+ message: "Paste Anthropic setup-token",
155
+ validate: (value) => validateAnthropicSetupToken(String(value ?? ""))
156
+ });
157
+ const token = String(tokenInput ?? "").trim();
158
+ const profileId = resolveDefaultTokenProfileId(provider);
159
+ upsertAuthProfile({
160
+ profileId,
161
+ credential: {
162
+ type: "token",
163
+ provider,
164
+ token
165
+ }
166
+ });
167
+ await updateConfig((cfg) => applyAuthProfileConfig(cfg, {
168
+ profileId,
169
+ provider,
170
+ mode: "token"
171
+ }));
172
+ logConfigUpdated(runtime);
173
+ runtime.log(`Auth profile: ${profileId} (${provider}/token)`);
174
+ }
175
+ async function modelsAuthPasteTokenCommand(opts, runtime) {
176
+ const rawProvider = opts.provider?.trim();
177
+ if (!rawProvider) throw new Error("Missing --provider.");
178
+ const provider = normalizeProviderId(rawProvider);
179
+ const profileId = opts.profileId?.trim() || resolveDefaultTokenProfileId(provider);
180
+ const tokenInput = await text$1({
181
+ message: `Paste token for ${provider}`,
182
+ validate: (value) => value?.trim() ? void 0 : "Required"
183
+ });
184
+ const token = String(tokenInput ?? "").trim();
185
+ const expires = opts.expiresIn?.trim() && opts.expiresIn.trim().length > 0 ? Date.now() + parseDurationMs(String(opts.expiresIn ?? "").trim(), { defaultUnit: "d" }) : void 0;
186
+ upsertAuthProfile({
187
+ profileId,
188
+ credential: {
189
+ type: "token",
190
+ provider,
191
+ token,
192
+ ...expires ? { expires } : {}
193
+ }
194
+ });
195
+ await updateConfig((cfg) => applyAuthProfileConfig(cfg, {
196
+ profileId,
197
+ provider,
198
+ mode: "token"
199
+ }));
200
+ logConfigUpdated(runtime);
201
+ runtime.log(`Auth profile: ${profileId} (${provider}/token)`);
202
+ }
203
+ async function modelsAuthAddCommand(_opts, runtime) {
204
+ const provider = await select$1({
205
+ message: "Token provider",
206
+ options: [{
207
+ value: "anthropic",
208
+ label: "anthropic"
209
+ }, {
210
+ value: "custom",
211
+ label: "custom (type provider id)"
212
+ }]
213
+ });
214
+ const providerId = provider === "custom" ? normalizeProviderId(String(await text$1({
215
+ message: "Provider id",
216
+ validate: (value) => value?.trim() ? void 0 : "Required"
217
+ }))) : provider;
218
+ if (await select$1({
219
+ message: "Token method",
220
+ options: [...providerId === "anthropic" ? [{
221
+ value: "setup-token",
222
+ label: "setup-token (claude)",
223
+ hint: "Paste a setup-token from `claude setup-token`"
224
+ }] : [], {
225
+ value: "paste",
226
+ label: "paste token"
227
+ }]
228
+ }) === "setup-token") {
229
+ await modelsAuthSetupTokenCommand({ provider: providerId }, runtime);
230
+ return;
231
+ }
232
+ const profileIdDefault = resolveDefaultTokenProfileId(providerId);
233
+ await modelsAuthPasteTokenCommand({
234
+ provider: providerId,
235
+ profileId: String(await text$1({
236
+ message: "Profile id",
237
+ initialValue: profileIdDefault,
238
+ validate: (value) => value?.trim() ? void 0 : "Required"
239
+ })).trim(),
240
+ expiresIn: await confirm$1({
241
+ message: "Does this token expire?",
242
+ initialValue: false
243
+ }) ? String(await text$1({
244
+ message: "Expires in (duration)",
245
+ initialValue: "365d",
246
+ validate: (value) => {
247
+ try {
248
+ parseDurationMs(String(value ?? ""), { defaultUnit: "d" });
249
+ return;
250
+ } catch {
251
+ return "Invalid duration (e.g. 365d, 12h, 30m)";
252
+ }
253
+ }
254
+ })).trim() : void 0
255
+ }, runtime);
256
+ }
257
+ function resolveRequestedLoginProviderOrThrow(providers, rawProvider) {
258
+ const requested = rawProvider?.trim();
259
+ if (!requested) return null;
260
+ const matched = resolveProviderMatch(providers, requested);
261
+ if (matched) return matched;
262
+ const available = providers.map((provider) => provider.id).filter(Boolean).toSorted((a, b) => a.localeCompare(b));
263
+ const availableText = available.length > 0 ? available.join(", ") : "(none)";
264
+ throw new Error(`Unknown provider "${requested}". Loaded providers: ${availableText}. Verify plugins via \`${formatCliCommand("anima plugins list --json")}\`.`);
265
+ }
266
+ function credentialMode(credential) {
267
+ if (credential.type === "api_key") return "api_key";
268
+ if (credential.type === "token") return "token";
269
+ return "oauth";
270
+ }
271
+ async function modelsAuthLoginCommand(opts, runtime) {
272
+ if (!process.stdin.isTTY) throw new Error("models auth login requires an interactive TTY.");
273
+ const snapshot = await readConfigFileSnapshot();
274
+ if (!snapshot.valid) {
275
+ const issues = snapshot.issues.map((issue) => `- ${issue.path}: ${issue.message}`).join("\n");
276
+ throw new Error(`Invalid config at ${snapshot.path}\n${issues}`);
277
+ }
278
+ const config = snapshot.config;
279
+ const defaultAgentId = resolveDefaultAgentId(config);
280
+ const agentDir = resolveAgentDir(config, defaultAgentId);
281
+ const workspaceDir = resolveAgentWorkspaceDir(config, defaultAgentId) ?? resolveDefaultAgentWorkspaceDir();
282
+ const providers = resolvePluginProviders({
283
+ config,
284
+ workspaceDir
285
+ });
286
+ if (providers.length === 0) throw new Error(`No provider plugins found. Install one via \`${formatCliCommand("anima plugins install")}\`.`);
287
+ const prompter = createClackPrompter();
288
+ const selectedProvider = resolveRequestedLoginProviderOrThrow(providers, opts.provider) ?? await prompter.select({
289
+ message: "Select a provider",
290
+ options: providers.map((provider) => ({
291
+ value: provider.id,
292
+ label: provider.label,
293
+ hint: provider.docsPath ? `Docs: ${provider.docsPath}` : void 0
294
+ }))
295
+ }).then((id) => resolveProviderMatch(providers, String(id)));
296
+ if (!selectedProvider) throw new Error("Unknown provider. Use --provider <id> to pick a provider plugin.");
297
+ const chosenMethod = pickAuthMethod(selectedProvider, opts.method) ?? (selectedProvider.auth.length === 1 ? selectedProvider.auth[0] : await prompter.select({
298
+ message: `Auth method for ${selectedProvider.label}`,
299
+ options: selectedProvider.auth.map((method) => ({
300
+ value: method.id,
301
+ label: method.label,
302
+ hint: method.hint
303
+ }))
304
+ }).then((id) => selectedProvider.auth.find((method) => method.id === String(id))));
305
+ if (!chosenMethod) throw new Error("Unknown auth method. Use --method <id> to select one.");
306
+ const isRemote = isRemoteEnvironment();
307
+ const result = await chosenMethod.run({
308
+ config,
309
+ agentDir,
310
+ workspaceDir,
311
+ prompter,
312
+ runtime,
313
+ isRemote,
314
+ openUrl: async (url) => {
315
+ await openUrl(url);
316
+ },
317
+ oauth: { createVpsAwareHandlers: (params) => createVpsAwareOAuthHandlers(params) }
318
+ });
319
+ for (const profile of result.profiles) upsertAuthProfile({
320
+ profileId: profile.profileId,
321
+ credential: profile.credential,
322
+ agentDir
323
+ });
324
+ await updateConfig((cfg) => {
325
+ let next = cfg;
326
+ if (result.configPatch) next = mergeConfigPatch(next, result.configPatch);
327
+ for (const profile of result.profiles) next = applyAuthProfileConfig(next, {
328
+ profileId: profile.profileId,
329
+ provider: profile.credential.provider,
330
+ mode: credentialMode(profile.credential)
331
+ });
332
+ if (opts.setDefault && result.defaultModel) next = applyDefaultModel(next, result.defaultModel);
333
+ return next;
334
+ });
335
+ logConfigUpdated(runtime);
336
+ for (const profile of result.profiles) runtime.log(`Auth profile: ${profile.profileId} (${profile.credential.provider}/${credentialMode(profile.credential)})`);
337
+ if (result.defaultModel) runtime.log(opts.setDefault ? `Default model set to ${result.defaultModel}` : `Default model available: ${result.defaultModel} (use --set-default to apply)`);
338
+ if (result.notes && result.notes.length > 0) await prompter.note(result.notes.join("\n"), "Provider notes");
339
+ }
340
+
341
+ //#endregion
342
+ //#region src/commands/models/auth-order.ts
343
+ function resolveTargetAgent(cfg, raw) {
344
+ const agentId = resolveKnownAgentId({
345
+ cfg,
346
+ rawAgentId: raw
347
+ }) ?? resolveDefaultAgentId(cfg);
348
+ return {
349
+ agentId,
350
+ agentDir: resolveAgentDir(cfg, agentId)
351
+ };
352
+ }
353
+ function describeOrder(store, provider) {
354
+ const providerKey = normalizeProviderId(provider);
355
+ const order = store.order?.[providerKey];
356
+ return Array.isArray(order) ? order : [];
357
+ }
358
+ async function modelsAuthOrderGetCommand(opts, runtime) {
359
+ const rawProvider = opts.provider?.trim();
360
+ if (!rawProvider) throw new Error("Missing --provider.");
361
+ const provider = normalizeProviderId(rawProvider);
362
+ const { agentId, agentDir } = resolveTargetAgent(loadConfig(), opts.agent);
363
+ const order = describeOrder(ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false }), provider);
364
+ if (opts.json) {
365
+ runtime.log(JSON.stringify({
366
+ agentId,
367
+ agentDir,
368
+ provider,
369
+ authStorePath: shortenHomePath(`${agentDir}/auth-profiles.json`),
370
+ order: order.length > 0 ? order : null
371
+ }, null, 2));
372
+ return;
373
+ }
374
+ runtime.log(`Agent: ${agentId}`);
375
+ runtime.log(`Provider: ${provider}`);
376
+ runtime.log(`Auth file: ${shortenHomePath(`${agentDir}/auth-profiles.json`)}`);
377
+ runtime.log(order.length > 0 ? `Order override: ${order.join(", ")}` : "Order override: (none)");
378
+ }
379
+ async function modelsAuthOrderClearCommand(opts, runtime) {
380
+ const rawProvider = opts.provider?.trim();
381
+ if (!rawProvider) throw new Error("Missing --provider.");
382
+ const provider = normalizeProviderId(rawProvider);
383
+ const { agentId, agentDir } = resolveTargetAgent(loadConfig(), opts.agent);
384
+ if (!await setAuthProfileOrder({
385
+ agentDir,
386
+ provider,
387
+ order: null
388
+ })) throw new Error("Failed to update auth-profiles.json (lock busy?).");
389
+ runtime.log(`Agent: ${agentId}`);
390
+ runtime.log(`Provider: ${provider}`);
391
+ runtime.log("Cleared per-agent order override.");
392
+ }
393
+ async function modelsAuthOrderSetCommand(opts, runtime) {
394
+ const rawProvider = opts.provider?.trim();
395
+ if (!rawProvider) throw new Error("Missing --provider.");
396
+ const provider = normalizeProviderId(rawProvider);
397
+ const { agentId, agentDir } = resolveTargetAgent(loadConfig(), opts.agent);
398
+ const store = ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false });
399
+ const providerKey = normalizeProviderId(provider);
400
+ const requested = (opts.order ?? []).map((entry) => String(entry).trim()).filter(Boolean);
401
+ if (requested.length === 0) throw new Error("Missing profile ids. Provide one or more profile ids.");
402
+ for (const profileId of requested) {
403
+ const cred = store.profiles[profileId];
404
+ if (!cred) throw new Error(`Auth profile "${profileId}" not found in ${agentDir}.`);
405
+ if (normalizeProviderId(cred.provider) !== providerKey) throw new Error(`Auth profile "${profileId}" is for ${cred.provider}, not ${provider}.`);
406
+ }
407
+ const updated = await setAuthProfileOrder({
408
+ agentDir,
409
+ provider,
410
+ order: requested
411
+ });
412
+ if (!updated) throw new Error("Failed to update auth-profiles.json (lock busy?).");
413
+ runtime.log(`Agent: ${agentId}`);
414
+ runtime.log(`Provider: ${provider}`);
415
+ runtime.log(`Order override: ${describeOrder(updated, provider).join(", ")}`);
416
+ }
417
+
418
+ //#endregion
419
+ //#region src/commands/models/fallbacks.ts
420
+ async function modelsFallbacksListCommand(opts, runtime) {
421
+ ensureFlagCompatibility(opts);
422
+ const fallbacks = loadConfig().agents?.defaults?.model?.fallbacks ?? [];
423
+ if (opts.json) {
424
+ runtime.log(JSON.stringify({ fallbacks }, null, 2));
425
+ return;
426
+ }
427
+ if (opts.plain) {
428
+ for (const entry of fallbacks) runtime.log(entry);
429
+ return;
430
+ }
431
+ runtime.log(`Fallbacks (${fallbacks.length}):`);
432
+ if (fallbacks.length === 0) {
433
+ runtime.log("- none");
434
+ return;
435
+ }
436
+ for (const entry of fallbacks) runtime.log(`- ${entry}`);
437
+ }
438
+ async function modelsFallbacksAddCommand(modelRaw, runtime) {
439
+ const updated = await updateConfig((cfg) => {
440
+ const resolved = resolveModelTarget({
441
+ raw: modelRaw,
442
+ cfg
443
+ });
444
+ const targetKey = modelKey(resolved.provider, resolved.model);
445
+ const nextModels = { ...cfg.agents?.defaults?.models };
446
+ if (!nextModels[targetKey]) nextModels[targetKey] = {};
447
+ const aliasIndex = buildModelAliasIndex({
448
+ cfg,
449
+ defaultProvider: DEFAULT_PROVIDER
450
+ });
451
+ const existing = cfg.agents?.defaults?.model?.fallbacks ?? [];
452
+ if (existing.map((entry) => resolveModelRefFromString({
453
+ raw: String(entry ?? ""),
454
+ defaultProvider: DEFAULT_PROVIDER,
455
+ aliasIndex
456
+ })).filter((entry) => Boolean(entry)).map((entry) => modelKey(entry.ref.provider, entry.ref.model)).includes(targetKey)) return cfg;
457
+ const existingModel = cfg.agents?.defaults?.model;
458
+ return {
459
+ ...cfg,
460
+ agents: {
461
+ ...cfg.agents,
462
+ defaults: {
463
+ ...cfg.agents?.defaults,
464
+ model: {
465
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
466
+ fallbacks: [...existing, targetKey]
467
+ },
468
+ models: nextModels
469
+ }
470
+ }
471
+ };
472
+ });
473
+ logConfigUpdated(runtime);
474
+ runtime.log(`Fallbacks: ${(updated.agents?.defaults?.model?.fallbacks ?? []).join(", ")}`);
475
+ }
476
+ async function modelsFallbacksRemoveCommand(modelRaw, runtime) {
477
+ const updated = await updateConfig((cfg) => {
478
+ const resolved = resolveModelTarget({
479
+ raw: modelRaw,
480
+ cfg
481
+ });
482
+ const targetKey = modelKey(resolved.provider, resolved.model);
483
+ const aliasIndex = buildModelAliasIndex({
484
+ cfg,
485
+ defaultProvider: DEFAULT_PROVIDER
486
+ });
487
+ const existing = cfg.agents?.defaults?.model?.fallbacks ?? [];
488
+ const filtered = existing.filter((entry) => {
489
+ const resolvedEntry = resolveModelRefFromString({
490
+ raw: String(entry ?? ""),
491
+ defaultProvider: DEFAULT_PROVIDER,
492
+ aliasIndex
493
+ });
494
+ if (!resolvedEntry) return true;
495
+ return modelKey(resolvedEntry.ref.provider, resolvedEntry.ref.model) !== targetKey;
496
+ });
497
+ if (filtered.length === existing.length) throw new Error(`Fallback not found: ${targetKey}`);
498
+ const existingModel = cfg.agents?.defaults?.model;
499
+ return {
500
+ ...cfg,
501
+ agents: {
502
+ ...cfg.agents,
503
+ defaults: {
504
+ ...cfg.agents?.defaults,
505
+ model: {
506
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
507
+ fallbacks: filtered
508
+ }
509
+ }
510
+ }
511
+ };
512
+ });
513
+ logConfigUpdated(runtime);
514
+ runtime.log(`Fallbacks: ${(updated.agents?.defaults?.model?.fallbacks ?? []).join(", ")}`);
515
+ }
516
+ async function modelsFallbacksClearCommand(runtime) {
517
+ await updateConfig((cfg) => {
518
+ const existingModel = cfg.agents?.defaults?.model;
519
+ return {
520
+ ...cfg,
521
+ agents: {
522
+ ...cfg.agents,
523
+ defaults: {
524
+ ...cfg.agents?.defaults,
525
+ model: {
526
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
527
+ fallbacks: []
528
+ }
529
+ }
530
+ }
531
+ };
532
+ });
533
+ logConfigUpdated(runtime);
534
+ runtime.log("Fallback list cleared.");
535
+ }
536
+
537
+ //#endregion
538
+ //#region src/commands/models/image-fallbacks.ts
539
+ async function modelsImageFallbacksListCommand(opts, runtime) {
540
+ ensureFlagCompatibility(opts);
541
+ const fallbacks = loadConfig().agents?.defaults?.imageModel?.fallbacks ?? [];
542
+ if (opts.json) {
543
+ runtime.log(JSON.stringify({ fallbacks }, null, 2));
544
+ return;
545
+ }
546
+ if (opts.plain) {
547
+ for (const entry of fallbacks) runtime.log(entry);
548
+ return;
549
+ }
550
+ runtime.log(`Image fallbacks (${fallbacks.length}):`);
551
+ if (fallbacks.length === 0) {
552
+ runtime.log("- none");
553
+ return;
554
+ }
555
+ for (const entry of fallbacks) runtime.log(`- ${entry}`);
556
+ }
557
+ async function modelsImageFallbacksAddCommand(modelRaw, runtime) {
558
+ const updated = await updateConfig((cfg) => {
559
+ const resolved = resolveModelTarget({
560
+ raw: modelRaw,
561
+ cfg
562
+ });
563
+ const targetKey = modelKey(resolved.provider, resolved.model);
564
+ const nextModels = { ...cfg.agents?.defaults?.models };
565
+ if (!nextModels[targetKey]) nextModels[targetKey] = {};
566
+ const aliasIndex = buildModelAliasIndex({
567
+ cfg,
568
+ defaultProvider: DEFAULT_PROVIDER
569
+ });
570
+ const existing = cfg.agents?.defaults?.imageModel?.fallbacks ?? [];
571
+ if (existing.map((entry) => resolveModelRefFromString({
572
+ raw: String(entry ?? ""),
573
+ defaultProvider: DEFAULT_PROVIDER,
574
+ aliasIndex
575
+ })).filter((entry) => Boolean(entry)).map((entry) => modelKey(entry.ref.provider, entry.ref.model)).includes(targetKey)) return cfg;
576
+ const existingModel = cfg.agents?.defaults?.imageModel;
577
+ return {
578
+ ...cfg,
579
+ agents: {
580
+ ...cfg.agents,
581
+ defaults: {
582
+ ...cfg.agents?.defaults,
583
+ imageModel: {
584
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
585
+ fallbacks: [...existing, targetKey]
586
+ },
587
+ models: nextModels
588
+ }
589
+ }
590
+ };
591
+ });
592
+ logConfigUpdated(runtime);
593
+ runtime.log(`Image fallbacks: ${(updated.agents?.defaults?.imageModel?.fallbacks ?? []).join(", ")}`);
594
+ }
595
+ async function modelsImageFallbacksRemoveCommand(modelRaw, runtime) {
596
+ const updated = await updateConfig((cfg) => {
597
+ const resolved = resolveModelTarget({
598
+ raw: modelRaw,
599
+ cfg
600
+ });
601
+ const targetKey = modelKey(resolved.provider, resolved.model);
602
+ const aliasIndex = buildModelAliasIndex({
603
+ cfg,
604
+ defaultProvider: DEFAULT_PROVIDER
605
+ });
606
+ const existing = cfg.agents?.defaults?.imageModel?.fallbacks ?? [];
607
+ const filtered = existing.filter((entry) => {
608
+ const resolvedEntry = resolveModelRefFromString({
609
+ raw: String(entry ?? ""),
610
+ defaultProvider: DEFAULT_PROVIDER,
611
+ aliasIndex
612
+ });
613
+ if (!resolvedEntry) return true;
614
+ return modelKey(resolvedEntry.ref.provider, resolvedEntry.ref.model) !== targetKey;
615
+ });
616
+ if (filtered.length === existing.length) throw new Error(`Image fallback not found: ${targetKey}`);
617
+ const existingModel = cfg.agents?.defaults?.imageModel;
618
+ return {
619
+ ...cfg,
620
+ agents: {
621
+ ...cfg.agents,
622
+ defaults: {
623
+ ...cfg.agents?.defaults,
624
+ imageModel: {
625
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
626
+ fallbacks: filtered
627
+ }
628
+ }
629
+ }
630
+ };
631
+ });
632
+ logConfigUpdated(runtime);
633
+ runtime.log(`Image fallbacks: ${(updated.agents?.defaults?.imageModel?.fallbacks ?? []).join(", ")}`);
634
+ }
635
+ async function modelsImageFallbacksClearCommand(runtime) {
636
+ await updateConfig((cfg) => {
637
+ const existingModel = cfg.agents?.defaults?.imageModel;
638
+ return {
639
+ ...cfg,
640
+ agents: {
641
+ ...cfg.agents,
642
+ defaults: {
643
+ ...cfg.agents?.defaults,
644
+ imageModel: {
645
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
646
+ fallbacks: []
647
+ }
648
+ }
649
+ }
650
+ };
651
+ });
652
+ logConfigUpdated(runtime);
653
+ runtime.log("Image fallback list cleared.");
654
+ }
655
+
656
+ //#endregion
657
+ //#region src/agents/model-compat.ts
658
+ function isOpenAiCompletionsModel(model) {
659
+ return model.api === "openai-completions";
660
+ }
661
+ function normalizeModelCompat(model) {
662
+ const baseUrl = model.baseUrl ?? "";
663
+ if (!(model.provider === "zai" || baseUrl.includes("api.z.ai")) || !isOpenAiCompletionsModel(model)) return model;
664
+ const openaiModel = model;
665
+ const compat = openaiModel.compat ?? void 0;
666
+ if (compat?.supportsDeveloperRole === false) return model;
667
+ openaiModel.compat = compat ? {
668
+ ...compat,
669
+ supportsDeveloperRole: false
670
+ } : { supportsDeveloperRole: false };
671
+ return openaiModel;
672
+ }
673
+
674
+ //#endregion
675
+ //#region src/agents/model-forward-compat.ts
676
+ const OPENAI_CODEX_GPT_53_MODEL_ID = "gpt-5.3-codex";
677
+ const OPENAI_CODEX_TEMPLATE_MODEL_IDS = ["gpt-5.2-codex"];
678
+ const ANTHROPIC_OPUS_46_MODEL_ID = "claude-opus-4-6";
679
+ const ANTHROPIC_OPUS_46_DOT_MODEL_ID = "claude-opus-4.6";
680
+ const ANTHROPIC_OPUS_TEMPLATE_MODEL_IDS = ["claude-opus-4-5", "claude-opus-4.5"];
681
+ const ZAI_GLM5_MODEL_ID = "glm-5";
682
+ const ZAI_GLM5_TEMPLATE_MODEL_IDS = ["glm-4.7"];
683
+ const ANTIGRAVITY_OPUS_46_MODEL_ID = "claude-opus-4-6";
684
+ const ANTIGRAVITY_OPUS_46_DOT_MODEL_ID = "claude-opus-4.6";
685
+ const ANTIGRAVITY_OPUS_TEMPLATE_MODEL_IDS = ["claude-opus-4-5", "claude-opus-4.5"];
686
+ const ANTIGRAVITY_OPUS_46_THINKING_MODEL_ID = "claude-opus-4-6-thinking";
687
+ const ANTIGRAVITY_OPUS_46_DOT_THINKING_MODEL_ID = "claude-opus-4.6-thinking";
688
+ const ANTIGRAVITY_OPUS_THINKING_TEMPLATE_MODEL_IDS = ["claude-opus-4-5-thinking", "claude-opus-4.5-thinking"];
689
+ const ANTIGRAVITY_OPUS_46_FORWARD_COMPAT_CANDIDATES = [{
690
+ id: ANTIGRAVITY_OPUS_46_THINKING_MODEL_ID,
691
+ templatePrefixes: ["google-antigravity/claude-opus-4-5-thinking", "google-antigravity/claude-opus-4.5-thinking"]
692
+ }, {
693
+ id: ANTIGRAVITY_OPUS_46_MODEL_ID,
694
+ templatePrefixes: ["google-antigravity/claude-opus-4-5", "google-antigravity/claude-opus-4.5"]
695
+ }];
696
+ function resolveOpenAICodexGpt53FallbackModel(provider, modelId, modelRegistry) {
697
+ const normalizedProvider = normalizeProviderId(provider);
698
+ const trimmedModelId = modelId.trim();
699
+ if (normalizedProvider !== "openai-codex") return;
700
+ if (trimmedModelId.toLowerCase() !== OPENAI_CODEX_GPT_53_MODEL_ID) return;
701
+ for (const templateId of OPENAI_CODEX_TEMPLATE_MODEL_IDS) {
702
+ const template = modelRegistry.find(normalizedProvider, templateId);
703
+ if (!template) continue;
704
+ return normalizeModelCompat({
705
+ ...template,
706
+ id: trimmedModelId,
707
+ name: trimmedModelId
708
+ });
709
+ }
710
+ return normalizeModelCompat({
711
+ id: trimmedModelId,
712
+ name: trimmedModelId,
713
+ api: "openai-codex-responses",
714
+ provider: normalizedProvider,
715
+ baseUrl: "https://chatgpt.com/backend-api",
716
+ reasoning: true,
717
+ input: ["text", "image"],
718
+ cost: {
719
+ input: 0,
720
+ output: 0,
721
+ cacheRead: 0,
722
+ cacheWrite: 0
723
+ },
724
+ contextWindow: DEFAULT_CONTEXT_TOKENS,
725
+ maxTokens: DEFAULT_CONTEXT_TOKENS
726
+ });
727
+ }
728
+ function resolveAnthropicOpus46ForwardCompatModel(provider, modelId, modelRegistry) {
729
+ const normalizedProvider = normalizeProviderId(provider);
730
+ if (normalizedProvider !== "anthropic") return;
731
+ const trimmedModelId = modelId.trim();
732
+ const lower = trimmedModelId.toLowerCase();
733
+ if (!(lower === ANTHROPIC_OPUS_46_MODEL_ID || lower === ANTHROPIC_OPUS_46_DOT_MODEL_ID || lower.startsWith(`${ANTHROPIC_OPUS_46_MODEL_ID}-`) || lower.startsWith(`${ANTHROPIC_OPUS_46_DOT_MODEL_ID}-`))) return;
734
+ const templateIds = [];
735
+ if (lower.startsWith(ANTHROPIC_OPUS_46_MODEL_ID)) templateIds.push(lower.replace(ANTHROPIC_OPUS_46_MODEL_ID, "claude-opus-4-5"));
736
+ if (lower.startsWith(ANTHROPIC_OPUS_46_DOT_MODEL_ID)) templateIds.push(lower.replace(ANTHROPIC_OPUS_46_DOT_MODEL_ID, "claude-opus-4.5"));
737
+ templateIds.push(...ANTHROPIC_OPUS_TEMPLATE_MODEL_IDS);
738
+ for (const templateId of [...new Set(templateIds)].filter(Boolean)) {
739
+ const template = modelRegistry.find(normalizedProvider, templateId);
740
+ if (!template) continue;
741
+ return normalizeModelCompat({
742
+ ...template,
743
+ id: trimmedModelId,
744
+ name: trimmedModelId
745
+ });
746
+ }
747
+ }
748
+ function resolveZaiGlm5ForwardCompatModel(provider, modelId, modelRegistry) {
749
+ if (normalizeProviderId(provider) !== "zai") return;
750
+ const trimmed = modelId.trim();
751
+ const lower = trimmed.toLowerCase();
752
+ if (lower !== ZAI_GLM5_MODEL_ID && !lower.startsWith(`${ZAI_GLM5_MODEL_ID}-`)) return;
753
+ for (const templateId of ZAI_GLM5_TEMPLATE_MODEL_IDS) {
754
+ const template = modelRegistry.find("zai", templateId);
755
+ if (!template) continue;
756
+ return normalizeModelCompat({
757
+ ...template,
758
+ id: trimmed,
759
+ name: trimmed,
760
+ reasoning: true
761
+ });
762
+ }
763
+ return normalizeModelCompat({
764
+ id: trimmed,
765
+ name: trimmed,
766
+ api: "openai-completions",
767
+ provider: "zai",
768
+ reasoning: true,
769
+ input: ["text"],
770
+ cost: {
771
+ input: 0,
772
+ output: 0,
773
+ cacheRead: 0,
774
+ cacheWrite: 0
775
+ },
776
+ contextWindow: DEFAULT_CONTEXT_TOKENS,
777
+ maxTokens: DEFAULT_CONTEXT_TOKENS
778
+ });
779
+ }
780
+ function resolveAntigravityOpus46ForwardCompatModel(provider, modelId, modelRegistry) {
781
+ const normalizedProvider = normalizeProviderId(provider);
782
+ if (normalizedProvider !== "google-antigravity") return;
783
+ const trimmedModelId = modelId.trim();
784
+ const lower = trimmedModelId.toLowerCase();
785
+ const isOpus46 = lower === ANTIGRAVITY_OPUS_46_MODEL_ID || lower === ANTIGRAVITY_OPUS_46_DOT_MODEL_ID || lower.startsWith(`${ANTIGRAVITY_OPUS_46_MODEL_ID}-`) || lower.startsWith(`${ANTIGRAVITY_OPUS_46_DOT_MODEL_ID}-`);
786
+ const isOpus46Thinking = lower === ANTIGRAVITY_OPUS_46_THINKING_MODEL_ID || lower === ANTIGRAVITY_OPUS_46_DOT_THINKING_MODEL_ID || lower.startsWith(`${ANTIGRAVITY_OPUS_46_THINKING_MODEL_ID}-`) || lower.startsWith(`${ANTIGRAVITY_OPUS_46_DOT_THINKING_MODEL_ID}-`);
787
+ if (!isOpus46 && !isOpus46Thinking) return;
788
+ const templateIds = [];
789
+ if (lower.startsWith(ANTIGRAVITY_OPUS_46_MODEL_ID)) templateIds.push(lower.replace(ANTIGRAVITY_OPUS_46_MODEL_ID, "claude-opus-4-5"));
790
+ if (lower.startsWith(ANTIGRAVITY_OPUS_46_DOT_MODEL_ID)) templateIds.push(lower.replace(ANTIGRAVITY_OPUS_46_DOT_MODEL_ID, "claude-opus-4.5"));
791
+ if (lower.startsWith(ANTIGRAVITY_OPUS_46_THINKING_MODEL_ID)) templateIds.push(lower.replace(ANTIGRAVITY_OPUS_46_THINKING_MODEL_ID, "claude-opus-4-5-thinking"));
792
+ if (lower.startsWith(ANTIGRAVITY_OPUS_46_DOT_THINKING_MODEL_ID)) templateIds.push(lower.replace(ANTIGRAVITY_OPUS_46_DOT_THINKING_MODEL_ID, "claude-opus-4.5-thinking"));
793
+ templateIds.push(...ANTIGRAVITY_OPUS_TEMPLATE_MODEL_IDS);
794
+ templateIds.push(...ANTIGRAVITY_OPUS_THINKING_TEMPLATE_MODEL_IDS);
795
+ for (const templateId of [...new Set(templateIds)].filter(Boolean)) {
796
+ const template = modelRegistry.find(normalizedProvider, templateId);
797
+ if (!template) continue;
798
+ return normalizeModelCompat({
799
+ ...template,
800
+ id: trimmedModelId,
801
+ name: trimmedModelId
802
+ });
803
+ }
804
+ }
805
+ function resolveForwardCompatModel(provider, modelId, modelRegistry) {
806
+ return resolveOpenAICodexGpt53FallbackModel(provider, modelId, modelRegistry) ?? resolveAnthropicOpus46ForwardCompatModel(provider, modelId, modelRegistry) ?? resolveZaiGlm5ForwardCompatModel(provider, modelId, modelRegistry) ?? resolveAntigravityOpus46ForwardCompatModel(provider, modelId, modelRegistry);
807
+ }
808
+
809
+ //#endregion
810
+ //#region src/commands/models/list.configured.ts
811
+ function resolveConfiguredEntries(cfg) {
812
+ const resolvedDefault = resolveConfiguredModelRef({
813
+ cfg,
814
+ defaultProvider: DEFAULT_PROVIDER,
815
+ defaultModel: DEFAULT_MODEL
816
+ });
817
+ const aliasIndex = buildModelAliasIndex({
818
+ cfg,
819
+ defaultProvider: DEFAULT_PROVIDER
820
+ });
821
+ const order = [];
822
+ const tagsByKey = /* @__PURE__ */ new Map();
823
+ const aliasesByKey = /* @__PURE__ */ new Map();
824
+ for (const [key, aliases] of aliasIndex.byKey.entries()) aliasesByKey.set(key, aliases);
825
+ const addEntry = (ref, tag) => {
826
+ const key = modelKey(ref.provider, ref.model);
827
+ if (!tagsByKey.has(key)) {
828
+ tagsByKey.set(key, /* @__PURE__ */ new Set());
829
+ order.push(key);
830
+ }
831
+ tagsByKey.get(key)?.add(tag);
832
+ };
833
+ addEntry(resolvedDefault, "default");
834
+ const modelConfig = cfg.agents?.defaults?.model;
835
+ const imageModelConfig = cfg.agents?.defaults?.imageModel;
836
+ const modelFallbacks = typeof modelConfig === "object" ? modelConfig?.fallbacks ?? [] : [];
837
+ const imageFallbacks = typeof imageModelConfig === "object" ? imageModelConfig?.fallbacks ?? [] : [];
838
+ const imagePrimary = imageModelConfig?.primary?.trim() ?? "";
839
+ modelFallbacks.forEach((raw, idx) => {
840
+ const resolved = resolveModelRefFromString({
841
+ raw: String(raw ?? ""),
842
+ defaultProvider: DEFAULT_PROVIDER,
843
+ aliasIndex
844
+ });
845
+ if (!resolved) return;
846
+ addEntry(resolved.ref, `fallback#${idx + 1}`);
847
+ });
848
+ if (imagePrimary) {
849
+ const resolved = resolveModelRefFromString({
850
+ raw: imagePrimary,
851
+ defaultProvider: DEFAULT_PROVIDER,
852
+ aliasIndex
853
+ });
854
+ if (resolved) addEntry(resolved.ref, "image");
855
+ }
856
+ imageFallbacks.forEach((raw, idx) => {
857
+ const resolved = resolveModelRefFromString({
858
+ raw: String(raw ?? ""),
859
+ defaultProvider: DEFAULT_PROVIDER,
860
+ aliasIndex
861
+ });
862
+ if (!resolved) return;
863
+ addEntry(resolved.ref, `img-fallback#${idx + 1}`);
864
+ });
865
+ for (const key of Object.keys(cfg.agents?.defaults?.models ?? {})) {
866
+ const parsed = parseModelRef(String(key ?? ""), DEFAULT_PROVIDER);
867
+ if (!parsed) continue;
868
+ addEntry(parsed, "configured");
869
+ }
870
+ return { entries: order.map((key) => {
871
+ const slash = key.indexOf("/");
872
+ return {
873
+ key,
874
+ ref: {
875
+ provider: slash === -1 ? key : key.slice(0, slash),
876
+ model: slash === -1 ? "" : key.slice(slash + 1)
877
+ },
878
+ tags: tagsByKey.get(key) ?? /* @__PURE__ */ new Set(),
879
+ aliases: aliasesByKey.get(key) ?? []
880
+ };
881
+ }) };
882
+ }
883
+
884
+ //#endregion
885
+ //#region src/commands/models/list.errors.ts
886
+ const MODEL_AVAILABILITY_UNAVAILABLE_CODE = "MODEL_AVAILABILITY_UNAVAILABLE";
887
+ function formatErrorWithStack(err) {
888
+ if (err instanceof Error) return err.stack ?? `${err.name}: ${err.message}`;
889
+ return String(err);
890
+ }
891
+ function shouldFallbackToAuthHeuristics(err) {
892
+ if (!(err instanceof Error)) return false;
893
+ return err.code === MODEL_AVAILABILITY_UNAVAILABLE_CODE;
894
+ }
895
+
896
+ //#endregion
897
+ //#region src/commands/models/list.registry.ts
898
+ const hasAuthForProvider = (provider, cfg, authStore) => {
899
+ if (!cfg || !authStore) return false;
900
+ if (listProfilesForProvider(authStore, provider).length > 0) return true;
901
+ if (provider === "amazon-bedrock" && resolveAwsSdkEnvVarName()) return true;
902
+ if (resolveEnvApiKey(provider)) return true;
903
+ if (getCustomProviderApiKey(cfg, provider)) return true;
904
+ return false;
905
+ };
906
+ function createAvailabilityUnavailableError(message) {
907
+ const err = new Error(message);
908
+ err.code = MODEL_AVAILABILITY_UNAVAILABLE_CODE;
909
+ return err;
910
+ }
911
+ function normalizeAvailabilityError(err) {
912
+ if (shouldFallbackToAuthHeuristics(err) && err instanceof Error) return err;
913
+ return createAvailabilityUnavailableError(`Model availability unavailable: getAvailable() failed.\n${formatErrorWithStack(err)}`);
914
+ }
915
+ function validateAvailableModels(availableModels) {
916
+ if (!Array.isArray(availableModels)) throw createAvailabilityUnavailableError("Model availability unavailable: getAvailable() returned a non-array value.");
917
+ for (const model of availableModels) if (!model || typeof model !== "object" || typeof model.provider !== "string" || typeof model.id !== "string") throw createAvailabilityUnavailableError("Model availability unavailable: getAvailable() returned invalid model entries.");
918
+ return availableModels;
919
+ }
920
+ function loadAvailableModels(registry) {
921
+ let availableModels;
922
+ try {
923
+ availableModels = registry.getAvailable();
924
+ } catch (err) {
925
+ throw normalizeAvailabilityError(err);
926
+ }
927
+ try {
928
+ return validateAvailableModels(availableModels);
929
+ } catch (err) {
930
+ throw normalizeAvailabilityError(err);
931
+ }
932
+ }
933
+ async function loadModelRegistry(cfg) {
934
+ await ensureAnimaModelsJson(cfg);
935
+ const agentDir = resolveAnimaAgentDir();
936
+ const registry = discoverModels(discoverAuthStorage(agentDir), agentDir);
937
+ const appended = appendAntigravityForwardCompatModels(registry.getAll(), registry);
938
+ const models = appended.models;
939
+ const synthesizedForwardCompat = appended.synthesizedForwardCompat;
940
+ let availableKeys;
941
+ let availabilityErrorMessage;
942
+ try {
943
+ const availableModels = loadAvailableModels(registry);
944
+ availableKeys = new Set(availableModels.map((model) => modelKey(model.provider, model.id)));
945
+ for (const synthesized of synthesizedForwardCompat) if (hasAvailableTemplate(availableKeys, synthesized.templatePrefixes)) availableKeys.add(synthesized.key);
946
+ } catch (err) {
947
+ if (!shouldFallbackToAuthHeuristics(err)) throw err;
948
+ availableKeys = void 0;
949
+ if (!availabilityErrorMessage) availabilityErrorMessage = formatErrorWithStack(err);
950
+ }
951
+ return {
952
+ registry,
953
+ models,
954
+ availableKeys,
955
+ availabilityErrorMessage
956
+ };
957
+ }
958
+ function appendAntigravityForwardCompatModels(models, modelRegistry) {
959
+ const nextModels = [...models];
960
+ const synthesizedForwardCompat = [];
961
+ for (const candidate of ANTIGRAVITY_OPUS_46_FORWARD_COMPAT_CANDIDATES) {
962
+ const key = modelKey("google-antigravity", candidate.id);
963
+ if (nextModels.some((model) => modelKey(model.provider, model.id) === key)) continue;
964
+ const fallback = resolveForwardCompatModel("google-antigravity", candidate.id, modelRegistry);
965
+ if (!fallback) continue;
966
+ nextModels.push(fallback);
967
+ synthesizedForwardCompat.push({
968
+ key,
969
+ templatePrefixes: candidate.templatePrefixes
970
+ });
971
+ }
972
+ return {
973
+ models: nextModels,
974
+ synthesizedForwardCompat
975
+ };
976
+ }
977
+ function hasAvailableTemplate(availableKeys, templatePrefixes) {
978
+ for (const key of availableKeys) if (templatePrefixes.some((prefix) => key.startsWith(prefix))) return true;
979
+ return false;
980
+ }
981
+ function toModelRow(params) {
982
+ const { model, key, tags, aliases = [], availableKeys, cfg, authStore } = params;
983
+ if (!model) return {
984
+ key,
985
+ name: key,
986
+ input: "-",
987
+ contextWindow: null,
988
+ local: null,
989
+ available: null,
990
+ tags: [...tags, "missing"],
991
+ missing: true
992
+ };
993
+ const input = model.input.join("+") || "text";
994
+ const local = isLocalBaseUrl(model.baseUrl);
995
+ const available = availableKeys !== void 0 ? availableKeys.has(modelKey(model.provider, model.id)) : cfg && authStore ? hasAuthForProvider(model.provider, cfg, authStore) : false;
996
+ const aliasTags = aliases.length > 0 ? [`alias:${aliases.join(",")}`] : [];
997
+ const mergedTags = new Set(tags);
998
+ if (aliasTags.length > 0) {
999
+ for (const tag of mergedTags) if (tag === "alias" || tag.startsWith("alias:")) mergedTags.delete(tag);
1000
+ for (const tag of aliasTags) mergedTags.add(tag);
1001
+ }
1002
+ return {
1003
+ key,
1004
+ name: model.name || model.id,
1005
+ input,
1006
+ contextWindow: model.contextWindow ?? null,
1007
+ local,
1008
+ available,
1009
+ tags: Array.from(mergedTags),
1010
+ missing: false
1011
+ };
1012
+ }
1013
+
1014
+ //#endregion
1015
+ //#region src/commands/models/list.format.ts
1016
+ const isRich = (opts) => Boolean(isRich$1() && !opts?.json && !opts?.plain);
1017
+ const pad$1 = (value, size) => value.padEnd(size);
1018
+ const formatTag = (tag, rich) => {
1019
+ if (!rich) return tag;
1020
+ if (tag === "default") return theme.success(tag);
1021
+ if (tag === "image") return theme.accentBright(tag);
1022
+ if (tag === "configured") return theme.accent(tag);
1023
+ if (tag === "missing") return theme.error(tag);
1024
+ if (tag.startsWith("fallback#")) return theme.warn(tag);
1025
+ if (tag.startsWith("img-fallback#")) return theme.warn(tag);
1026
+ if (tag.startsWith("alias:")) return theme.accentDim(tag);
1027
+ return theme.muted(tag);
1028
+ };
1029
+ const truncate$1 = (value, max) => {
1030
+ if (value.length <= max) return value;
1031
+ if (max <= 3) return value.slice(0, max);
1032
+ return `${value.slice(0, max - 3)}...`;
1033
+ };
1034
+ const maskApiKey = (value) => {
1035
+ const trimmed = value.trim();
1036
+ if (!trimmed) return "missing";
1037
+ if (trimmed.length <= 16) return trimmed;
1038
+ return `${trimmed.slice(0, 8)}...${trimmed.slice(-8)}`;
1039
+ };
1040
+
1041
+ //#endregion
1042
+ //#region src/commands/models/list.table.ts
1043
+ const MODEL_PAD$1 = 42;
1044
+ const INPUT_PAD = 10;
1045
+ const CTX_PAD$1 = 8;
1046
+ const LOCAL_PAD = 5;
1047
+ const AUTH_PAD = 5;
1048
+ function printModelTable(rows, runtime, opts = {}) {
1049
+ if (opts.json) {
1050
+ runtime.log(JSON.stringify({
1051
+ count: rows.length,
1052
+ models: rows
1053
+ }, null, 2));
1054
+ return;
1055
+ }
1056
+ if (opts.plain) {
1057
+ for (const row of rows) runtime.log(row.key);
1058
+ return;
1059
+ }
1060
+ const rich = isRich(opts);
1061
+ const header = [
1062
+ pad$1("Model", MODEL_PAD$1),
1063
+ pad$1("Input", INPUT_PAD),
1064
+ pad$1("Ctx", CTX_PAD$1),
1065
+ pad$1("Local", LOCAL_PAD),
1066
+ pad$1("Auth", AUTH_PAD),
1067
+ "Tags"
1068
+ ].join(" ");
1069
+ runtime.log(rich ? theme.heading(header) : header);
1070
+ for (const row of rows) {
1071
+ const keyLabel = pad$1(truncate$1(row.key, MODEL_PAD$1), MODEL_PAD$1);
1072
+ const inputLabel = pad$1(row.input || "-", INPUT_PAD);
1073
+ const ctxLabel = pad$1(formatTokenK(row.contextWindow), CTX_PAD$1);
1074
+ const localLabel = pad$1(row.local === null ? "-" : row.local ? "yes" : "no", LOCAL_PAD);
1075
+ const authLabel = pad$1(row.available === null ? "-" : row.available ? "yes" : "no", AUTH_PAD);
1076
+ const tagsLabel = row.tags.length > 0 ? rich ? row.tags.map((tag) => formatTag(tag, rich)).join(",") : row.tags.join(",") : "";
1077
+ const coloredInput = colorize(rich, row.input.includes("image") ? theme.accentBright : theme.info, inputLabel);
1078
+ const coloredLocal = colorize(rich, row.local === null ? theme.muted : row.local ? theme.success : theme.muted, localLabel);
1079
+ const coloredAuth = colorize(rich, row.available === null ? theme.muted : row.available ? theme.success : theme.error, authLabel);
1080
+ const line = [
1081
+ rich ? theme.accent(keyLabel) : keyLabel,
1082
+ coloredInput,
1083
+ ctxLabel,
1084
+ coloredLocal,
1085
+ coloredAuth,
1086
+ tagsLabel
1087
+ ].join(" ");
1088
+ runtime.log(line);
1089
+ }
1090
+ }
1091
+
1092
+ //#endregion
1093
+ //#region src/commands/models/list.list-command.ts
1094
+ async function modelsListCommand(opts, runtime) {
1095
+ ensureFlagCompatibility(opts);
1096
+ const cfg = loadConfig();
1097
+ const authStore = ensureAuthProfileStore();
1098
+ const providerFilter = (() => {
1099
+ const raw = opts.provider?.trim();
1100
+ if (!raw) return;
1101
+ return parseModelRef(`${raw}/_`, DEFAULT_PROVIDER)?.provider ?? raw.toLowerCase();
1102
+ })();
1103
+ let models = [];
1104
+ let modelRegistry;
1105
+ let availableKeys;
1106
+ let availabilityErrorMessage;
1107
+ try {
1108
+ const loaded = await loadModelRegistry(cfg);
1109
+ modelRegistry = loaded.registry;
1110
+ models = loaded.models;
1111
+ availableKeys = loaded.availableKeys;
1112
+ availabilityErrorMessage = loaded.availabilityErrorMessage;
1113
+ } catch (err) {
1114
+ runtime.error(`Model registry unavailable:\n${formatErrorWithStack(err)}`);
1115
+ process.exitCode = 1;
1116
+ return;
1117
+ }
1118
+ if (availabilityErrorMessage !== void 0) runtime.error(`Model availability lookup failed; falling back to auth heuristics for discovered models: ${availabilityErrorMessage}`);
1119
+ const modelByKey = new Map(models.map((model) => [modelKey(model.provider, model.id), model]));
1120
+ const { entries } = resolveConfiguredEntries(cfg);
1121
+ const configuredByKey = new Map(entries.map((entry) => [entry.key, entry]));
1122
+ const rows = [];
1123
+ if (opts.all) {
1124
+ const sorted = [...models].toSorted((a, b) => {
1125
+ const p = a.provider.localeCompare(b.provider);
1126
+ if (p !== 0) return p;
1127
+ return a.id.localeCompare(b.id);
1128
+ });
1129
+ for (const model of sorted) {
1130
+ if (providerFilter && model.provider.toLowerCase() !== providerFilter) continue;
1131
+ if (opts.local && !isLocalBaseUrl(model.baseUrl)) continue;
1132
+ const key = modelKey(model.provider, model.id);
1133
+ const configured = configuredByKey.get(key);
1134
+ rows.push(toModelRow({
1135
+ model,
1136
+ key,
1137
+ tags: configured ? Array.from(configured.tags) : [],
1138
+ aliases: configured?.aliases ?? [],
1139
+ availableKeys,
1140
+ cfg,
1141
+ authStore
1142
+ }));
1143
+ }
1144
+ } else for (const entry of entries) {
1145
+ if (providerFilter && entry.ref.provider.toLowerCase() !== providerFilter) continue;
1146
+ let model = modelByKey.get(entry.key);
1147
+ if (!model && modelRegistry) {
1148
+ const forwardCompat = resolveForwardCompatModel(entry.ref.provider, entry.ref.model, modelRegistry);
1149
+ if (forwardCompat) {
1150
+ model = forwardCompat;
1151
+ modelByKey.set(entry.key, forwardCompat);
1152
+ }
1153
+ }
1154
+ if (!model) model = resolveModel(entry.ref.provider, entry.ref.model, void 0, cfg).model;
1155
+ if (opts.local && model && !isLocalBaseUrl(model.baseUrl)) continue;
1156
+ if (opts.local && !model) continue;
1157
+ rows.push(toModelRow({
1158
+ model,
1159
+ key: entry.key,
1160
+ tags: Array.from(entry.tags),
1161
+ aliases: entry.aliases,
1162
+ availableKeys,
1163
+ cfg,
1164
+ authStore
1165
+ }));
1166
+ }
1167
+ if (rows.length === 0) {
1168
+ runtime.log("No models found.");
1169
+ return;
1170
+ }
1171
+ printModelTable(rows, runtime, opts);
1172
+ }
1173
+
1174
+ //#endregion
1175
+ //#region src/commands/models/list.auth-overview.ts
1176
+ function resolveProviderAuthOverview(params) {
1177
+ const { provider, cfg, store } = params;
1178
+ const now = Date.now();
1179
+ const profiles = listProfilesForProvider(store, provider);
1180
+ const withUnusableSuffix = (base, profileId) => {
1181
+ const unusableUntil = resolveProfileUnusableUntilForDisplay(store, profileId);
1182
+ if (!unusableUntil || now >= unusableUntil) return base;
1183
+ const stats = store.usageStats?.[profileId];
1184
+ return `${base} [${typeof stats?.disabledUntil === "number" && now < stats.disabledUntil ? `disabled${stats.disabledReason ? `:${stats.disabledReason}` : ""}` : "cooldown"} ${formatRemainingShort(unusableUntil - now)}]`;
1185
+ };
1186
+ const labels = profiles.map((profileId) => {
1187
+ const profile = store.profiles[profileId];
1188
+ if (!profile) return `${profileId}=missing`;
1189
+ if (profile.type === "api_key") return withUnusableSuffix(`${profileId}=${maskApiKey(profile.key ?? "")}`, profileId);
1190
+ if (profile.type === "token") return withUnusableSuffix(`${profileId}=token:${maskApiKey(profile.token)}`, profileId);
1191
+ const display = resolveAuthProfileDisplayLabel({
1192
+ cfg,
1193
+ store,
1194
+ profileId
1195
+ });
1196
+ const suffix = display === profileId ? "" : display.startsWith(profileId) ? display.slice(profileId.length).trim() : `(${display})`;
1197
+ return withUnusableSuffix(`${profileId}=OAuth${suffix ? ` ${suffix}` : ""}`, profileId);
1198
+ });
1199
+ const oauthCount = profiles.filter((id) => store.profiles[id]?.type === "oauth").length;
1200
+ const tokenCount = profiles.filter((id) => store.profiles[id]?.type === "token").length;
1201
+ const apiKeyCount = profiles.filter((id) => store.profiles[id]?.type === "api_key").length;
1202
+ const envKey = resolveEnvApiKey(provider);
1203
+ const customKey = getCustomProviderApiKey(cfg, provider);
1204
+ return {
1205
+ provider,
1206
+ effective: (() => {
1207
+ if (profiles.length > 0) return {
1208
+ kind: "profiles",
1209
+ detail: shortenHomePath(resolveAuthStorePathForDisplay())
1210
+ };
1211
+ if (envKey) return {
1212
+ kind: "env",
1213
+ detail: envKey.source.includes("OAUTH_TOKEN") || envKey.source.toLowerCase().includes("oauth") ? "OAuth (env)" : maskApiKey(envKey.apiKey)
1214
+ };
1215
+ if (customKey) return {
1216
+ kind: "models.json",
1217
+ detail: maskApiKey(customKey)
1218
+ };
1219
+ return {
1220
+ kind: "missing",
1221
+ detail: "missing"
1222
+ };
1223
+ })(),
1224
+ profiles: {
1225
+ count: profiles.length,
1226
+ oauth: oauthCount,
1227
+ token: tokenCount,
1228
+ apiKey: apiKeyCount,
1229
+ labels
1230
+ },
1231
+ ...envKey ? { env: {
1232
+ value: envKey.source.includes("OAUTH_TOKEN") || envKey.source.toLowerCase().includes("oauth") ? "OAuth (env)" : maskApiKey(envKey.apiKey),
1233
+ source: envKey.source
1234
+ } } : {},
1235
+ ...customKey ? { modelsJson: {
1236
+ value: maskApiKey(customKey),
1237
+ source: `models.json: ${shortenHomePath(params.modelsPath)}`
1238
+ } } : {}
1239
+ };
1240
+ }
1241
+
1242
+ //#endregion
1243
+ //#region src/commands/models/list.probe.ts
1244
+ const PROBE_PROMPT = "Reply with OK. Do not use tools.";
1245
+ const toStatus = (reason) => {
1246
+ if (!reason) return "unknown";
1247
+ if (reason === "auth") return "auth";
1248
+ if (reason === "rate_limit") return "rate_limit";
1249
+ if (reason === "billing") return "billing";
1250
+ if (reason === "timeout") return "timeout";
1251
+ if (reason === "format") return "format";
1252
+ return "unknown";
1253
+ };
1254
+ function buildCandidateMap(modelCandidates) {
1255
+ const map = /* @__PURE__ */ new Map();
1256
+ for (const raw of modelCandidates) {
1257
+ const parsed = parseModelRef(String(raw ?? ""), DEFAULT_PROVIDER);
1258
+ if (!parsed) continue;
1259
+ const list = map.get(parsed.provider) ?? [];
1260
+ if (!list.includes(parsed.model)) list.push(parsed.model);
1261
+ map.set(parsed.provider, list);
1262
+ }
1263
+ return map;
1264
+ }
1265
+ function selectProbeModel(params) {
1266
+ const { provider, candidates, catalog } = params;
1267
+ const direct = candidates.get(provider);
1268
+ if (direct && direct.length > 0) return {
1269
+ provider,
1270
+ model: direct[0]
1271
+ };
1272
+ const fromCatalog = catalog.find((entry) => entry.provider === provider);
1273
+ if (fromCatalog) return {
1274
+ provider: fromCatalog.provider,
1275
+ model: fromCatalog.id
1276
+ };
1277
+ return null;
1278
+ }
1279
+ function buildProbeTargets(params) {
1280
+ const { cfg, providers, modelCandidates, options } = params;
1281
+ const store = ensureAuthProfileStore();
1282
+ const providerFilter = options.provider?.trim();
1283
+ const providerFilterKey = providerFilter ? normalizeProviderId(providerFilter) : null;
1284
+ const profileFilter = new Set((options.profileIds ?? []).map((id) => id.trim()).filter(Boolean));
1285
+ return loadModelCatalog({ config: cfg }).then((catalog) => {
1286
+ const candidates = buildCandidateMap(modelCandidates);
1287
+ const targets = [];
1288
+ const results = [];
1289
+ for (const provider of providers) {
1290
+ const providerKey = normalizeProviderId(provider);
1291
+ if (providerFilterKey && providerKey !== providerFilterKey) continue;
1292
+ const model = selectProbeModel({
1293
+ provider: providerKey,
1294
+ candidates,
1295
+ catalog
1296
+ });
1297
+ const profileIds = listProfilesForProvider(store, providerKey);
1298
+ const explicitOrder = (() => {
1299
+ const order = store.order;
1300
+ if (order) {
1301
+ for (const [key, value] of Object.entries(order)) if (normalizeProviderId(key) === providerKey) return value;
1302
+ }
1303
+ const cfgOrder = cfg?.auth?.order;
1304
+ if (cfgOrder) {
1305
+ for (const [key, value] of Object.entries(cfgOrder)) if (normalizeProviderId(key) === providerKey) return value;
1306
+ }
1307
+ })();
1308
+ const allowedProfiles = explicitOrder && explicitOrder.length > 0 ? new Set(resolveAuthProfileOrder({
1309
+ cfg,
1310
+ store,
1311
+ provider: providerKey
1312
+ })) : null;
1313
+ const filteredProfiles = profileFilter.size ? profileIds.filter((id) => profileFilter.has(id)) : profileIds;
1314
+ if (filteredProfiles.length > 0) {
1315
+ for (const profileId of filteredProfiles) {
1316
+ const mode = store.profiles[profileId]?.type;
1317
+ const label = resolveAuthProfileDisplayLabel({
1318
+ cfg,
1319
+ store,
1320
+ profileId
1321
+ });
1322
+ if (explicitOrder && !explicitOrder.includes(profileId)) {
1323
+ results.push({
1324
+ provider: providerKey,
1325
+ model: model ? `${model.provider}/${model.model}` : void 0,
1326
+ profileId,
1327
+ label,
1328
+ source: "profile",
1329
+ mode,
1330
+ status: "unknown",
1331
+ error: "Excluded by auth.order for this provider."
1332
+ });
1333
+ continue;
1334
+ }
1335
+ if (allowedProfiles && !allowedProfiles.has(profileId)) {
1336
+ results.push({
1337
+ provider: providerKey,
1338
+ model: model ? `${model.provider}/${model.model}` : void 0,
1339
+ profileId,
1340
+ label,
1341
+ source: "profile",
1342
+ mode,
1343
+ status: "unknown",
1344
+ error: "Auth profile credentials are missing or expired."
1345
+ });
1346
+ continue;
1347
+ }
1348
+ if (!model) {
1349
+ results.push({
1350
+ provider: providerKey,
1351
+ model: void 0,
1352
+ profileId,
1353
+ label,
1354
+ source: "profile",
1355
+ mode,
1356
+ status: "no_model",
1357
+ error: "No model available for probe"
1358
+ });
1359
+ continue;
1360
+ }
1361
+ targets.push({
1362
+ provider: providerKey,
1363
+ model,
1364
+ profileId,
1365
+ label,
1366
+ source: "profile",
1367
+ mode
1368
+ });
1369
+ }
1370
+ continue;
1371
+ }
1372
+ if (profileFilter.size > 0) continue;
1373
+ const envKey = resolveEnvApiKey(providerKey);
1374
+ const customKey = getCustomProviderApiKey(cfg, providerKey);
1375
+ if (!envKey && !customKey) continue;
1376
+ const label = envKey ? "env" : "models.json";
1377
+ const source = envKey ? "env" : "models.json";
1378
+ const mode = envKey?.source.includes("OAUTH_TOKEN") ? "oauth" : "api_key";
1379
+ if (!model) {
1380
+ results.push({
1381
+ provider: providerKey,
1382
+ model: void 0,
1383
+ label,
1384
+ source,
1385
+ mode,
1386
+ status: "no_model",
1387
+ error: "No model available for probe"
1388
+ });
1389
+ continue;
1390
+ }
1391
+ targets.push({
1392
+ provider: providerKey,
1393
+ model,
1394
+ label,
1395
+ source,
1396
+ mode
1397
+ });
1398
+ }
1399
+ return {
1400
+ targets,
1401
+ results
1402
+ };
1403
+ });
1404
+ }
1405
+ async function probeTarget(params) {
1406
+ const { cfg, agentId, agentDir, workspaceDir, sessionDir, target, timeoutMs, maxTokens } = params;
1407
+ if (!target.model) return {
1408
+ provider: target.provider,
1409
+ model: void 0,
1410
+ profileId: target.profileId,
1411
+ label: target.label,
1412
+ source: target.source,
1413
+ mode: target.mode,
1414
+ status: "no_model",
1415
+ error: "No model available for probe"
1416
+ };
1417
+ const sessionId = `probe-${target.provider}-${crypto.randomUUID()}`;
1418
+ const sessionFile = resolveSessionTranscriptPath(sessionId, agentId);
1419
+ await fs.mkdir(sessionDir, { recursive: true });
1420
+ const start = Date.now();
1421
+ try {
1422
+ await runEmbeddedPiAgent({
1423
+ sessionId,
1424
+ sessionFile,
1425
+ agentId,
1426
+ workspaceDir,
1427
+ agentDir,
1428
+ config: cfg,
1429
+ prompt: PROBE_PROMPT,
1430
+ provider: target.model.provider,
1431
+ model: target.model.model,
1432
+ authProfileId: target.profileId,
1433
+ authProfileIdSource: target.profileId ? "user" : void 0,
1434
+ timeoutMs,
1435
+ runId: `probe-${crypto.randomUUID()}`,
1436
+ lane: `auth-probe:${target.provider}:${target.profileId ?? target.source}`,
1437
+ thinkLevel: "off",
1438
+ reasoningLevel: "off",
1439
+ verboseLevel: "off",
1440
+ streamParams: { maxTokens }
1441
+ });
1442
+ return {
1443
+ provider: target.provider,
1444
+ model: `${target.model.provider}/${target.model.model}`,
1445
+ profileId: target.profileId,
1446
+ label: target.label,
1447
+ source: target.source,
1448
+ mode: target.mode,
1449
+ status: "ok",
1450
+ latencyMs: Date.now() - start
1451
+ };
1452
+ } catch (err) {
1453
+ const described = describeFailoverError(err);
1454
+ return {
1455
+ provider: target.provider,
1456
+ model: `${target.model.provider}/${target.model.model}`,
1457
+ profileId: target.profileId,
1458
+ label: target.label,
1459
+ source: target.source,
1460
+ mode: target.mode,
1461
+ status: toStatus(described.reason),
1462
+ error: redactSecrets(described.message),
1463
+ latencyMs: Date.now() - start
1464
+ };
1465
+ }
1466
+ }
1467
+ async function runTargetsWithConcurrency(params) {
1468
+ const { cfg, targets, timeoutMs, maxTokens, onProgress } = params;
1469
+ const concurrency = Math.max(1, Math.min(targets.length || 1, params.concurrency));
1470
+ const agentId = resolveDefaultAgentId(cfg);
1471
+ const agentDir = resolveAnimaAgentDir();
1472
+ const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId) ?? resolveDefaultAgentWorkspaceDir();
1473
+ const sessionDir = resolveSessionTranscriptsDirForAgent(agentId);
1474
+ await fs.mkdir(workspaceDir, { recursive: true });
1475
+ let completed = 0;
1476
+ const results = Array.from({ length: targets.length });
1477
+ let cursor = 0;
1478
+ const worker = async () => {
1479
+ while (true) {
1480
+ const index = cursor;
1481
+ cursor += 1;
1482
+ if (index >= targets.length) return;
1483
+ const target = targets[index];
1484
+ onProgress?.({
1485
+ completed,
1486
+ total: targets.length,
1487
+ label: `Probing ${target.provider}${target.profileId ? ` (${target.label})` : ""}`
1488
+ });
1489
+ results[index] = await probeTarget({
1490
+ cfg,
1491
+ agentId,
1492
+ agentDir,
1493
+ workspaceDir,
1494
+ sessionDir,
1495
+ target,
1496
+ timeoutMs,
1497
+ maxTokens
1498
+ });
1499
+ completed += 1;
1500
+ onProgress?.({
1501
+ completed,
1502
+ total: targets.length
1503
+ });
1504
+ }
1505
+ };
1506
+ await Promise.all(Array.from({ length: concurrency }, () => worker()));
1507
+ return results.filter((entry) => Boolean(entry));
1508
+ }
1509
+ async function runAuthProbes(params) {
1510
+ const startedAt = Date.now();
1511
+ const plan = await buildProbeTargets({
1512
+ cfg: params.cfg,
1513
+ providers: params.providers,
1514
+ modelCandidates: params.modelCandidates,
1515
+ options: params.options
1516
+ });
1517
+ const totalTargets = plan.targets.length;
1518
+ params.onProgress?.({
1519
+ completed: 0,
1520
+ total: totalTargets
1521
+ });
1522
+ const results = totalTargets ? await runTargetsWithConcurrency({
1523
+ cfg: params.cfg,
1524
+ targets: plan.targets,
1525
+ timeoutMs: params.options.timeoutMs,
1526
+ maxTokens: params.options.maxTokens,
1527
+ concurrency: params.options.concurrency,
1528
+ onProgress: params.onProgress
1529
+ }) : [];
1530
+ const finishedAt = Date.now();
1531
+ return {
1532
+ startedAt,
1533
+ finishedAt,
1534
+ durationMs: finishedAt - startedAt,
1535
+ totalTargets,
1536
+ options: params.options,
1537
+ results: [...plan.results, ...results]
1538
+ };
1539
+ }
1540
+ function formatProbeLatency(latencyMs) {
1541
+ if (!latencyMs && latencyMs !== 0) return "-";
1542
+ return formatMs(latencyMs);
1543
+ }
1544
+ function sortProbeResults(results) {
1545
+ return results.slice().toSorted((a, b) => {
1546
+ const provider = a.provider.localeCompare(b.provider);
1547
+ if (provider !== 0) return provider;
1548
+ const aLabel = a.label || a.profileId || "";
1549
+ const bLabel = b.label || b.profileId || "";
1550
+ return aLabel.localeCompare(bLabel);
1551
+ });
1552
+ }
1553
+ function describeProbeSummary(summary) {
1554
+ if (summary.totalTargets === 0) return "No probe targets.";
1555
+ return `Probed ${summary.totalTargets} target${summary.totalTargets === 1 ? "" : "s"} in ${formatMs(summary.durationMs)}`;
1556
+ }
1557
+
1558
+ //#endregion
1559
+ //#region src/commands/models/list.status-command.ts
1560
+ async function modelsStatusCommand(opts, runtime) {
1561
+ ensureFlagCompatibility(opts);
1562
+ if (opts.plain && opts.probe) throw new Error("--probe cannot be used with --plain output.");
1563
+ const cfg = loadConfig();
1564
+ const agentId = resolveKnownAgentId({
1565
+ cfg,
1566
+ rawAgentId: opts.agent
1567
+ });
1568
+ const agentDir = agentId ? resolveAgentDir(cfg, agentId) : resolveAnimaAgentDir();
1569
+ const agentModelPrimary = agentId ? resolveAgentModelPrimary(cfg, agentId) : void 0;
1570
+ const agentFallbacksOverride = agentId ? resolveAgentModelFallbacksOverride(cfg, agentId) : void 0;
1571
+ const resolved = agentId ? resolveDefaultModelForAgent({
1572
+ cfg,
1573
+ agentId
1574
+ }) : resolveConfiguredModelRef({
1575
+ cfg,
1576
+ defaultProvider: DEFAULT_PROVIDER,
1577
+ defaultModel: DEFAULT_MODEL
1578
+ });
1579
+ const modelConfig = cfg.agents?.defaults?.model;
1580
+ const imageConfig = cfg.agents?.defaults?.imageModel;
1581
+ const rawDefaultsModel = typeof modelConfig === "string" ? modelConfig.trim() : modelConfig?.primary?.trim() ?? "";
1582
+ const rawModel = agentModelPrimary ?? rawDefaultsModel;
1583
+ const resolvedLabel = `${resolved.provider}/${resolved.model}`;
1584
+ const defaultLabel = rawModel || resolvedLabel;
1585
+ const defaultsFallbacks = typeof modelConfig === "object" ? modelConfig?.fallbacks ?? [] : [];
1586
+ const fallbacks = agentFallbacksOverride ?? defaultsFallbacks;
1587
+ const imageModel = typeof imageConfig === "string" ? imageConfig.trim() : imageConfig?.primary?.trim() ?? "";
1588
+ const imageFallbacks = typeof imageConfig === "object" ? imageConfig?.fallbacks ?? [] : [];
1589
+ const aliases = Object.entries(cfg.agents?.defaults?.models ?? {}).reduce((acc, [key, entry]) => {
1590
+ const alias = typeof entry?.alias === "string" ? entry.alias.trim() : void 0;
1591
+ if (alias) acc[alias] = key;
1592
+ return acc;
1593
+ }, {});
1594
+ const allowed = Object.keys(cfg.agents?.defaults?.models ?? {});
1595
+ const store = ensureAuthProfileStore(agentDir);
1596
+ const modelsPath = path.join(agentDir, "models.json");
1597
+ const providersFromStore = new Set(Object.values(store.profiles).map((profile) => profile.provider).filter((p) => Boolean(p)));
1598
+ const providersFromConfig = new Set(Object.keys(cfg.models?.providers ?? {}).map((p) => typeof p === "string" ? p.trim() : "").filter(Boolean));
1599
+ const providersFromModels = /* @__PURE__ */ new Set();
1600
+ const providersInUse = /* @__PURE__ */ new Set();
1601
+ for (const raw of [
1602
+ defaultLabel,
1603
+ ...fallbacks,
1604
+ imageModel,
1605
+ ...imageFallbacks,
1606
+ ...allowed
1607
+ ]) {
1608
+ const parsed = parseModelRef(String(raw ?? ""), DEFAULT_PROVIDER);
1609
+ if (parsed?.provider) providersFromModels.add(parsed.provider);
1610
+ }
1611
+ for (const raw of [
1612
+ defaultLabel,
1613
+ ...fallbacks,
1614
+ imageModel,
1615
+ ...imageFallbacks
1616
+ ]) {
1617
+ const parsed = parseModelRef(String(raw ?? ""), DEFAULT_PROVIDER);
1618
+ if (parsed?.provider) providersInUse.add(parsed.provider);
1619
+ }
1620
+ const providersFromEnv = /* @__PURE__ */ new Set();
1621
+ for (const provider of [
1622
+ "anthropic",
1623
+ "github-copilot",
1624
+ "google-vertex",
1625
+ "openai",
1626
+ "google",
1627
+ "groq",
1628
+ "cerebras",
1629
+ "xai",
1630
+ "openrouter",
1631
+ "zai",
1632
+ "mistral",
1633
+ "synthetic"
1634
+ ]) if (resolveEnvApiKey(provider)) providersFromEnv.add(provider);
1635
+ const providers = Array.from(new Set([
1636
+ ...providersFromStore,
1637
+ ...providersFromConfig,
1638
+ ...providersFromModels,
1639
+ ...providersFromEnv
1640
+ ])).map((p) => typeof p === "string" ? p.trim() : "").filter(Boolean).toSorted((a, b) => a.localeCompare(b));
1641
+ const applied = getShellEnvAppliedKeys();
1642
+ const shellFallbackEnabled = shouldEnableShellEnvFallback(process.env) || cfg.env?.shellEnv?.enabled === true;
1643
+ const providerAuth = providers.map((provider) => resolveProviderAuthOverview({
1644
+ provider,
1645
+ cfg,
1646
+ store,
1647
+ modelsPath
1648
+ })).filter((entry) => {
1649
+ return entry.profiles.count > 0 || Boolean(entry.env) || Boolean(entry.modelsJson);
1650
+ });
1651
+ const providerAuthMap = new Map(providerAuth.map((entry) => [entry.provider, entry]));
1652
+ const missingProvidersInUse = Array.from(providersInUse).filter((provider) => !providerAuthMap.has(provider)).toSorted((a, b) => a.localeCompare(b));
1653
+ const probeProfileIds = (() => {
1654
+ if (!opts.probeProfile) return [];
1655
+ return (Array.isArray(opts.probeProfile) ? opts.probeProfile : [opts.probeProfile]).flatMap((value) => String(value ?? "").split(",")).map((value) => value.trim()).filter(Boolean);
1656
+ })();
1657
+ const probeTimeoutMs = opts.probeTimeout ? Number(opts.probeTimeout) : 8e3;
1658
+ if (!Number.isFinite(probeTimeoutMs) || probeTimeoutMs <= 0) throw new Error("--probe-timeout must be a positive number (ms).");
1659
+ const probeConcurrency = opts.probeConcurrency ? Number(opts.probeConcurrency) : 2;
1660
+ if (!Number.isFinite(probeConcurrency) || probeConcurrency <= 0) throw new Error("--probe-concurrency must be > 0.");
1661
+ const probeMaxTokens = opts.probeMaxTokens ? Number(opts.probeMaxTokens) : 8;
1662
+ if (!Number.isFinite(probeMaxTokens) || probeMaxTokens <= 0) throw new Error("--probe-max-tokens must be > 0.");
1663
+ const aliasIndex = buildModelAliasIndex({
1664
+ cfg,
1665
+ defaultProvider: DEFAULT_PROVIDER
1666
+ });
1667
+ const modelCandidates = [
1668
+ rawModel || resolvedLabel,
1669
+ ...fallbacks,
1670
+ imageModel,
1671
+ ...imageFallbacks,
1672
+ ...allowed
1673
+ ].filter(Boolean).map((raw) => resolveModelRefFromString({
1674
+ raw: String(raw ?? ""),
1675
+ defaultProvider: DEFAULT_PROVIDER,
1676
+ aliasIndex
1677
+ })?.ref).filter((ref) => Boolean(ref)).map((ref) => `${ref.provider}/${ref.model}`);
1678
+ let probeSummary;
1679
+ if (opts.probe) probeSummary = await withProgressTotals({
1680
+ label: "Probing auth profiles…",
1681
+ total: 1
1682
+ }, async (update) => {
1683
+ return await runAuthProbes({
1684
+ cfg,
1685
+ providers,
1686
+ modelCandidates,
1687
+ options: {
1688
+ provider: opts.probeProvider,
1689
+ profileIds: probeProfileIds,
1690
+ timeoutMs: probeTimeoutMs,
1691
+ concurrency: probeConcurrency,
1692
+ maxTokens: probeMaxTokens
1693
+ },
1694
+ onProgress: update
1695
+ });
1696
+ });
1697
+ const providersWithOauth = providerAuth.filter((entry) => entry.profiles.oauth > 0 || entry.profiles.token > 0 || entry.env?.value === "OAuth (env)").map((entry) => {
1698
+ const count = entry.profiles.oauth + entry.profiles.token + (entry.env?.value === "OAuth (env)" ? 1 : 0);
1699
+ return `${entry.provider} (${count})`;
1700
+ });
1701
+ const authHealth = buildAuthHealthSummary({
1702
+ store,
1703
+ cfg,
1704
+ warnAfterMs: DEFAULT_OAUTH_WARN_MS,
1705
+ providers
1706
+ });
1707
+ const oauthProfiles = authHealth.profiles.filter((profile) => profile.type === "oauth" || profile.type === "token");
1708
+ const unusableProfiles = (() => {
1709
+ const now = Date.now();
1710
+ const out = [];
1711
+ for (const profileId of Object.keys(store.usageStats ?? {})) {
1712
+ const unusableUntil = resolveProfileUnusableUntilForDisplay(store, profileId);
1713
+ if (!unusableUntil || now >= unusableUntil) continue;
1714
+ const stats = store.usageStats?.[profileId];
1715
+ const kind = typeof stats?.disabledUntil === "number" && now < stats.disabledUntil ? "disabled" : "cooldown";
1716
+ out.push({
1717
+ profileId,
1718
+ provider: store.profiles[profileId]?.provider,
1719
+ kind,
1720
+ reason: stats?.disabledReason,
1721
+ until: unusableUntil,
1722
+ remainingMs: unusableUntil - now
1723
+ });
1724
+ }
1725
+ return out.toSorted((a, b) => a.remainingMs - b.remainingMs);
1726
+ })();
1727
+ const checkStatus = (() => {
1728
+ const hasExpiredOrMissing = oauthProfiles.some((profile) => ["expired", "missing"].includes(profile.status)) || missingProvidersInUse.length > 0;
1729
+ const hasExpiring = oauthProfiles.some((profile) => profile.status === "expiring");
1730
+ if (hasExpiredOrMissing) return 1;
1731
+ if (hasExpiring) return 2;
1732
+ return 0;
1733
+ })();
1734
+ if (opts.json) {
1735
+ runtime.log(JSON.stringify({
1736
+ configPath: CONFIG_PATH,
1737
+ ...agentId ? { agentId } : {},
1738
+ agentDir,
1739
+ defaultModel: defaultLabel,
1740
+ resolvedDefault: resolvedLabel,
1741
+ fallbacks,
1742
+ imageModel: imageModel || null,
1743
+ imageFallbacks,
1744
+ ...agentId ? { modelConfig: {
1745
+ defaultSource: agentModelPrimary ? "agent" : "defaults",
1746
+ fallbacksSource: agentFallbacksOverride !== void 0 ? "agent" : "defaults"
1747
+ } } : {},
1748
+ aliases,
1749
+ allowed,
1750
+ auth: {
1751
+ storePath: resolveAuthStorePathForDisplay(agentDir),
1752
+ shellEnvFallback: {
1753
+ enabled: shellFallbackEnabled,
1754
+ appliedKeys: applied
1755
+ },
1756
+ providersWithOAuth: providersWithOauth,
1757
+ missingProvidersInUse,
1758
+ providers: providerAuth,
1759
+ unusableProfiles,
1760
+ oauth: {
1761
+ warnAfterMs: authHealth.warnAfterMs,
1762
+ profiles: authHealth.profiles,
1763
+ providers: authHealth.providers
1764
+ },
1765
+ probes: probeSummary
1766
+ }
1767
+ }, null, 2));
1768
+ if (opts.check) runtime.exit(checkStatus);
1769
+ return;
1770
+ }
1771
+ if (opts.plain) {
1772
+ runtime.log(resolvedLabel);
1773
+ if (opts.check) runtime.exit(checkStatus);
1774
+ return;
1775
+ }
1776
+ const rich = isRich(opts);
1777
+ const label = (value) => colorize(rich, theme.accent, value.padEnd(14));
1778
+ const labelWithSource = (value, source) => label(source ? `${value} (${source})` : value);
1779
+ const displayDefault = rawModel && rawModel !== resolvedLabel ? `${resolvedLabel} (from ${rawModel})` : resolvedLabel;
1780
+ runtime.log(`${label("Config")}${colorize(rich, theme.muted, ":")} ${colorize(rich, theme.info, shortenHomePath(CONFIG_PATH))}`);
1781
+ runtime.log(`${label("Agent dir")}${colorize(rich, theme.muted, ":")} ${colorize(rich, theme.info, shortenHomePath(agentDir))}`);
1782
+ runtime.log(`${labelWithSource("Default", agentId ? agentModelPrimary ? "agent" : "defaults" : void 0)}${colorize(rich, theme.muted, ":")} ${colorize(rich, theme.success, displayDefault)}`);
1783
+ runtime.log(`${labelWithSource(`Fallbacks (${fallbacks.length || 0})`, agentId ? agentFallbacksOverride !== void 0 ? "agent" : "defaults" : void 0)}${colorize(rich, theme.muted, ":")} ${colorize(rich, fallbacks.length ? theme.warn : theme.muted, fallbacks.length ? fallbacks.join(", ") : "-")}`);
1784
+ runtime.log(`${labelWithSource("Image model", agentId ? "defaults" : void 0)}${colorize(rich, theme.muted, ":")} ${colorize(rich, imageModel ? theme.accentBright : theme.muted, imageModel || "-")}`);
1785
+ runtime.log(`${labelWithSource(`Image fallbacks (${imageFallbacks.length || 0})`, agentId ? "defaults" : void 0)}${colorize(rich, theme.muted, ":")} ${colorize(rich, imageFallbacks.length ? theme.accentBright : theme.muted, imageFallbacks.length ? imageFallbacks.join(", ") : "-")}`);
1786
+ runtime.log(`${label(`Aliases (${Object.keys(aliases).length || 0})`)}${colorize(rich, theme.muted, ":")} ${colorize(rich, Object.keys(aliases).length ? theme.accent : theme.muted, Object.keys(aliases).length ? Object.entries(aliases).map(([alias, target]) => rich ? `${theme.accentDim(alias)} ${theme.muted("->")} ${theme.info(target)}` : `${alias} -> ${target}`).join(", ") : "-")}`);
1787
+ runtime.log(`${label(`Configured models (${allowed.length || 0})`)}${colorize(rich, theme.muted, ":")} ${colorize(rich, allowed.length ? theme.info : theme.muted, allowed.length ? allowed.join(", ") : "all")}`);
1788
+ runtime.log("");
1789
+ runtime.log(colorize(rich, theme.heading, "Auth overview"));
1790
+ runtime.log(`${label("Auth store")}${colorize(rich, theme.muted, ":")} ${colorize(rich, theme.info, shortenHomePath(resolveAuthStorePathForDisplay(agentDir)))}`);
1791
+ runtime.log(`${label("Shell env")}${colorize(rich, theme.muted, ":")} ${colorize(rich, shellFallbackEnabled ? theme.success : theme.muted, shellFallbackEnabled ? "on" : "off")}${applied.length ? colorize(rich, theme.muted, ` (applied: ${applied.join(", ")})`) : ""}`);
1792
+ runtime.log(`${label(`Providers w/ OAuth/tokens (${providersWithOauth.length || 0})`)}${colorize(rich, theme.muted, ":")} ${colorize(rich, providersWithOauth.length ? theme.info : theme.muted, providersWithOauth.length ? providersWithOauth.join(", ") : "-")}`);
1793
+ const formatKey = (key) => colorize(rich, theme.warn, key);
1794
+ const formatKeyValue = (key, value) => `${formatKey(key)}=${colorize(rich, theme.info, value)}`;
1795
+ const formatSeparator = () => colorize(rich, theme.muted, " | ");
1796
+ for (const entry of providerAuth) {
1797
+ const separator = formatSeparator();
1798
+ const bits = [];
1799
+ bits.push(formatKeyValue("effective", `${colorize(rich, theme.accentBright, entry.effective.kind)}:${colorize(rich, theme.muted, entry.effective.detail)}`));
1800
+ if (entry.profiles.count > 0) {
1801
+ bits.push(formatKeyValue("profiles", `${entry.profiles.count} (oauth=${entry.profiles.oauth}, token=${entry.profiles.token}, api_key=${entry.profiles.apiKey})`));
1802
+ if (entry.profiles.labels.length > 0) bits.push(colorize(rich, theme.info, entry.profiles.labels.join(", ")));
1803
+ }
1804
+ if (entry.env) bits.push(formatKeyValue("env", `${entry.env.value}${separator}${formatKeyValue("source", entry.env.source)}`));
1805
+ if (entry.modelsJson) bits.push(formatKeyValue("models.json", `${entry.modelsJson.value}${separator}${formatKeyValue("source", entry.modelsJson.source)}`));
1806
+ runtime.log(`- ${theme.heading(entry.provider)} ${bits.join(separator)}`);
1807
+ }
1808
+ if (missingProvidersInUse.length > 0) {
1809
+ runtime.log("");
1810
+ runtime.log(colorize(rich, theme.heading, "Missing auth"));
1811
+ for (const provider of missingProvidersInUse) {
1812
+ const hint = provider === "anthropic" ? `Run \`claude setup-token\`, then \`${formatCliCommand("anima models auth setup-token")}\` or \`${formatCliCommand("anima configure")}\`.` : `Run \`${formatCliCommand("anima configure")}\` or set an API key env var.`;
1813
+ runtime.log(`- ${theme.heading(provider)} ${hint}`);
1814
+ }
1815
+ }
1816
+ runtime.log("");
1817
+ runtime.log(colorize(rich, theme.heading, "OAuth/token status"));
1818
+ if (oauthProfiles.length === 0) runtime.log(colorize(rich, theme.muted, "- none"));
1819
+ else {
1820
+ const usageByProvider = /* @__PURE__ */ new Map();
1821
+ const usageProviders = Array.from(new Set(oauthProfiles.map((profile) => resolveUsageProviderId(profile.provider)).filter((provider) => Boolean(provider))));
1822
+ if (usageProviders.length > 0) try {
1823
+ const usageSummary = await loadProviderUsageSummary({
1824
+ providers: usageProviders,
1825
+ agentDir,
1826
+ timeoutMs: 3500
1827
+ });
1828
+ for (const snapshot of usageSummary.providers) {
1829
+ const formatted = formatUsageWindowSummary(snapshot, {
1830
+ now: Date.now(),
1831
+ maxWindows: 2,
1832
+ includeResets: true
1833
+ });
1834
+ if (formatted) usageByProvider.set(snapshot.provider, formatted);
1835
+ }
1836
+ } catch {}
1837
+ const formatStatus = (status) => {
1838
+ if (status === "ok") return colorize(rich, theme.success, "ok");
1839
+ if (status === "static") return colorize(rich, theme.muted, "static");
1840
+ if (status === "expiring") return colorize(rich, theme.warn, "expiring");
1841
+ if (status === "missing") return colorize(rich, theme.warn, "unknown");
1842
+ return colorize(rich, theme.error, "expired");
1843
+ };
1844
+ const profilesByProvider = /* @__PURE__ */ new Map();
1845
+ for (const profile of oauthProfiles) {
1846
+ const current = profilesByProvider.get(profile.provider);
1847
+ if (current) current.push(profile);
1848
+ else profilesByProvider.set(profile.provider, [profile]);
1849
+ }
1850
+ for (const [provider, profiles] of profilesByProvider) {
1851
+ const usageKey = resolveUsageProviderId(provider);
1852
+ const usage = usageKey ? usageByProvider.get(usageKey) : void 0;
1853
+ const usageSuffix = usage ? colorize(rich, theme.muted, ` usage: ${usage}`) : "";
1854
+ runtime.log(`- ${colorize(rich, theme.heading, provider)}${usageSuffix}`);
1855
+ for (const profile of profiles) {
1856
+ const labelText = profile.label || profile.profileId;
1857
+ const label = colorize(rich, theme.accent, labelText);
1858
+ const status = formatStatus(profile.status);
1859
+ const expiry = profile.status === "static" ? "" : profile.expiresAt ? ` expires in ${formatRemainingShort(profile.remainingMs)}` : " expires unknown";
1860
+ runtime.log(` - ${label} ${status}${expiry}`);
1861
+ }
1862
+ }
1863
+ }
1864
+ if (probeSummary) {
1865
+ runtime.log("");
1866
+ runtime.log(colorize(rich, theme.heading, "Auth probes"));
1867
+ if (probeSummary.results.length === 0) runtime.log(colorize(rich, theme.muted, "- none"));
1868
+ else {
1869
+ const tableWidth = Math.max(60, (process.stdout.columns ?? 120) - 1);
1870
+ const sorted = sortProbeResults(probeSummary.results);
1871
+ const statusColor = (status) => {
1872
+ if (status === "ok") return theme.success;
1873
+ if (status === "rate_limit") return theme.warn;
1874
+ if (status === "timeout" || status === "billing") return theme.warn;
1875
+ if (status === "auth" || status === "format") return theme.error;
1876
+ if (status === "no_model") return theme.muted;
1877
+ return theme.muted;
1878
+ };
1879
+ const rows = sorted.map((result) => {
1880
+ const status = colorize(rich, statusColor(result.status), result.status);
1881
+ const latency = formatProbeLatency(result.latencyMs);
1882
+ const modelLabel = result.model ?? `${result.provider}/-`;
1883
+ const modeLabel = result.mode ? ` ${colorize(rich, theme.muted, `(${result.mode})`)}` : "";
1884
+ const profile = `${colorize(rich, theme.accent, result.label)}${modeLabel}`;
1885
+ const detail = result.error?.trim();
1886
+ const detailLabel = detail ? `\n${colorize(rich, theme.muted, `↳ ${detail}`)}` : "";
1887
+ const statusLabel = `${status}${colorize(rich, theme.muted, ` · ${latency}`)}${detailLabel}`;
1888
+ return {
1889
+ Model: colorize(rich, theme.heading, modelLabel),
1890
+ Profile: profile,
1891
+ Status: statusLabel
1892
+ };
1893
+ });
1894
+ runtime.log(renderTable({
1895
+ width: tableWidth,
1896
+ columns: [
1897
+ {
1898
+ key: "Model",
1899
+ header: "Model",
1900
+ minWidth: 18
1901
+ },
1902
+ {
1903
+ key: "Profile",
1904
+ header: "Profile",
1905
+ minWidth: 24
1906
+ },
1907
+ {
1908
+ key: "Status",
1909
+ header: "Status",
1910
+ minWidth: 12
1911
+ }
1912
+ ],
1913
+ rows
1914
+ }).trimEnd());
1915
+ runtime.log(colorize(rich, theme.muted, describeProbeSummary(probeSummary)));
1916
+ }
1917
+ }
1918
+ if (opts.check) runtime.exit(checkStatus);
1919
+ }
1920
+
1921
+ //#endregion
1922
+ //#region src/agents/model-scan.ts
1923
+ const OPENROUTER_MODELS_URL = "https://openrouter.ai/api/v1/models";
1924
+ const DEFAULT_TIMEOUT_MS = 12e3;
1925
+ const DEFAULT_CONCURRENCY = 3;
1926
+ const BASE_IMAGE_PNG = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X3mIAAAAASUVORK5CYII=";
1927
+ const TOOL_PING = {
1928
+ name: "ping",
1929
+ description: "Return OK.",
1930
+ parameters: Type.Object({})
1931
+ };
1932
+ function normalizeCreatedAtMs(value) {
1933
+ if (typeof value !== "number" || !Number.isFinite(value)) return null;
1934
+ if (value <= 0) return null;
1935
+ if (value > 0xe8d4a51000) return Math.round(value);
1936
+ return Math.round(value * 1e3);
1937
+ }
1938
+ function parseModality(modality) {
1939
+ if (!modality) return ["text"];
1940
+ return modality.toLowerCase().split(/[^a-z]+/).filter(Boolean).includes("image") ? ["text", "image"] : ["text"];
1941
+ }
1942
+ function parseNumberString(value) {
1943
+ if (typeof value === "number" && Number.isFinite(value)) return value;
1944
+ if (typeof value !== "string") return null;
1945
+ const trimmed = value.trim();
1946
+ if (!trimmed) return null;
1947
+ const num = Number(trimmed);
1948
+ if (!Number.isFinite(num)) return null;
1949
+ return num;
1950
+ }
1951
+ function parseOpenRouterPricing(value) {
1952
+ if (!value || typeof value !== "object") return null;
1953
+ const obj = value;
1954
+ const prompt = parseNumberString(obj.prompt);
1955
+ const completion = parseNumberString(obj.completion);
1956
+ const request = parseNumberString(obj.request) ?? 0;
1957
+ const image = parseNumberString(obj.image) ?? 0;
1958
+ const webSearch = parseNumberString(obj.web_search) ?? 0;
1959
+ const internalReasoning = parseNumberString(obj.internal_reasoning) ?? 0;
1960
+ if (prompt === null || completion === null) return null;
1961
+ return {
1962
+ prompt,
1963
+ completion,
1964
+ request,
1965
+ image,
1966
+ webSearch,
1967
+ internalReasoning
1968
+ };
1969
+ }
1970
+ function isFreeOpenRouterModel(entry) {
1971
+ if (entry.id.endsWith(":free")) return true;
1972
+ if (!entry.pricing) return false;
1973
+ return entry.pricing.prompt === 0 && entry.pricing.completion === 0;
1974
+ }
1975
+ async function withTimeout(timeoutMs, fn) {
1976
+ const controller = new AbortController();
1977
+ const timer = setTimeout(controller.abort.bind(controller), timeoutMs);
1978
+ try {
1979
+ return await fn(controller.signal);
1980
+ } finally {
1981
+ clearTimeout(timer);
1982
+ }
1983
+ }
1984
+ async function fetchOpenRouterModels(fetchImpl) {
1985
+ const res = await fetchImpl(OPENROUTER_MODELS_URL, { headers: { Accept: "application/json" } });
1986
+ if (!res.ok) throw new Error(`OpenRouter /models failed: HTTP ${res.status}`);
1987
+ const payload = await res.json();
1988
+ return (Array.isArray(payload.data) ? payload.data : []).map((entry) => {
1989
+ if (!entry || typeof entry !== "object") return null;
1990
+ const obj = entry;
1991
+ const id = typeof obj.id === "string" ? obj.id.trim() : "";
1992
+ if (!id) return null;
1993
+ const name = typeof obj.name === "string" && obj.name.trim() ? obj.name.trim() : id;
1994
+ const contextLength = typeof obj.context_length === "number" && Number.isFinite(obj.context_length) ? obj.context_length : null;
1995
+ const maxCompletionTokens = typeof obj.max_completion_tokens === "number" && Number.isFinite(obj.max_completion_tokens) ? obj.max_completion_tokens : typeof obj.max_output_tokens === "number" && Number.isFinite(obj.max_output_tokens) ? obj.max_output_tokens : null;
1996
+ const supportedParameters = Array.isArray(obj.supported_parameters) ? obj.supported_parameters.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : [];
1997
+ return {
1998
+ id,
1999
+ name,
2000
+ contextLength,
2001
+ maxCompletionTokens,
2002
+ supportedParameters,
2003
+ supportedParametersCount: supportedParameters.length,
2004
+ supportsToolsMeta: supportedParameters.includes("tools"),
2005
+ modality: typeof obj.modality === "string" && obj.modality.trim() ? obj.modality.trim() : null,
2006
+ inferredParamB: inferParamBFromIdOrName(`${id} ${name}`),
2007
+ createdAtMs: normalizeCreatedAtMs(obj.created_at),
2008
+ pricing: parseOpenRouterPricing(obj.pricing)
2009
+ };
2010
+ }).filter((entry) => Boolean(entry));
2011
+ }
2012
+ async function probeTool(model, apiKey, timeoutMs) {
2013
+ const context = {
2014
+ messages: [{
2015
+ role: "user",
2016
+ content: "Call the ping tool with {} and nothing else.",
2017
+ timestamp: Date.now()
2018
+ }],
2019
+ tools: [TOOL_PING]
2020
+ };
2021
+ const startedAt = Date.now();
2022
+ try {
2023
+ if (!(await withTimeout(timeoutMs, (signal) => complete(model, context, {
2024
+ apiKey,
2025
+ maxTokens: 32,
2026
+ temperature: 0,
2027
+ toolChoice: "required",
2028
+ signal
2029
+ }))).content.some((block) => block.type === "toolCall")) return {
2030
+ ok: false,
2031
+ latencyMs: Date.now() - startedAt,
2032
+ error: "No tool call returned"
2033
+ };
2034
+ return {
2035
+ ok: true,
2036
+ latencyMs: Date.now() - startedAt
2037
+ };
2038
+ } catch (err) {
2039
+ return {
2040
+ ok: false,
2041
+ latencyMs: Date.now() - startedAt,
2042
+ error: err instanceof Error ? err.message : String(err)
2043
+ };
2044
+ }
2045
+ }
2046
+ async function probeImage(model, apiKey, timeoutMs) {
2047
+ const context = { messages: [{
2048
+ role: "user",
2049
+ content: [{
2050
+ type: "text",
2051
+ text: "Reply with OK."
2052
+ }, {
2053
+ type: "image",
2054
+ data: BASE_IMAGE_PNG,
2055
+ mimeType: "image/png"
2056
+ }],
2057
+ timestamp: Date.now()
2058
+ }] };
2059
+ const startedAt = Date.now();
2060
+ try {
2061
+ await withTimeout(timeoutMs, (signal) => complete(model, context, {
2062
+ apiKey,
2063
+ maxTokens: 16,
2064
+ temperature: 0,
2065
+ signal
2066
+ }));
2067
+ return {
2068
+ ok: true,
2069
+ latencyMs: Date.now() - startedAt
2070
+ };
2071
+ } catch (err) {
2072
+ return {
2073
+ ok: false,
2074
+ latencyMs: Date.now() - startedAt,
2075
+ error: err instanceof Error ? err.message : String(err)
2076
+ };
2077
+ }
2078
+ }
2079
+ function ensureImageInput(model) {
2080
+ if (model.input.includes("image")) return model;
2081
+ return {
2082
+ ...model,
2083
+ input: Array.from(new Set([...model.input, "image"]))
2084
+ };
2085
+ }
2086
+ async function mapWithConcurrency(items, concurrency, fn, opts) {
2087
+ const limit = Math.max(1, Math.floor(concurrency));
2088
+ const results = Array.from({ length: items.length }, () => void 0);
2089
+ let nextIndex = 0;
2090
+ let completed = 0;
2091
+ const worker = async () => {
2092
+ while (true) {
2093
+ const current = nextIndex;
2094
+ nextIndex += 1;
2095
+ if (current >= items.length) return;
2096
+ results[current] = await fn(items[current], current);
2097
+ completed += 1;
2098
+ opts?.onProgress?.(completed, items.length);
2099
+ }
2100
+ };
2101
+ if (items.length === 0) {
2102
+ opts?.onProgress?.(0, 0);
2103
+ return results;
2104
+ }
2105
+ await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()));
2106
+ return results;
2107
+ }
2108
+ async function scanOpenRouterModels(options = {}) {
2109
+ const fetchImpl = options.fetchImpl ?? fetch;
2110
+ const probe = options.probe ?? true;
2111
+ const apiKey = options.apiKey?.trim() || getEnvApiKey("openrouter") || "";
2112
+ if (probe && !apiKey) throw new Error("Missing OpenRouter API key. Set OPENROUTER_API_KEY to run models scan.");
2113
+ const timeoutMs = Math.max(1, Math.floor(options.timeoutMs ?? DEFAULT_TIMEOUT_MS));
2114
+ const concurrency = Math.max(1, Math.floor(options.concurrency ?? DEFAULT_CONCURRENCY));
2115
+ const minParamB = Math.max(0, Math.floor(options.minParamB ?? 0));
2116
+ const maxAgeDays = Math.max(0, Math.floor(options.maxAgeDays ?? 0));
2117
+ const providerFilter = options.providerFilter?.trim().toLowerCase() ?? "";
2118
+ const catalog = await fetchOpenRouterModels(fetchImpl);
2119
+ const now = Date.now();
2120
+ const filtered = catalog.filter((entry) => {
2121
+ if (!isFreeOpenRouterModel(entry)) return false;
2122
+ if (providerFilter) {
2123
+ if ((entry.id.split("/")[0]?.toLowerCase() ?? "") !== providerFilter) return false;
2124
+ }
2125
+ if (minParamB > 0) {
2126
+ if ((entry.inferredParamB ?? 0) < minParamB) return false;
2127
+ }
2128
+ if (maxAgeDays > 0 && entry.createdAtMs) {
2129
+ if ((now - entry.createdAtMs) / (1440 * 60 * 1e3) > maxAgeDays) return false;
2130
+ }
2131
+ return true;
2132
+ });
2133
+ const baseModel = getModel("openrouter", "openrouter/auto");
2134
+ options.onProgress?.({
2135
+ phase: "probe",
2136
+ completed: 0,
2137
+ total: filtered.length
2138
+ });
2139
+ return mapWithConcurrency(filtered, concurrency, async (entry) => {
2140
+ const isFree = isFreeOpenRouterModel(entry);
2141
+ if (!probe) return {
2142
+ id: entry.id,
2143
+ name: entry.name,
2144
+ provider: "openrouter",
2145
+ modelRef: `openrouter/${entry.id}`,
2146
+ contextLength: entry.contextLength,
2147
+ maxCompletionTokens: entry.maxCompletionTokens,
2148
+ supportedParametersCount: entry.supportedParametersCount,
2149
+ supportsToolsMeta: entry.supportsToolsMeta,
2150
+ modality: entry.modality,
2151
+ inferredParamB: entry.inferredParamB,
2152
+ createdAtMs: entry.createdAtMs,
2153
+ pricing: entry.pricing,
2154
+ isFree,
2155
+ tool: {
2156
+ ok: false,
2157
+ latencyMs: null,
2158
+ skipped: true
2159
+ },
2160
+ image: {
2161
+ ok: false,
2162
+ latencyMs: null,
2163
+ skipped: true
2164
+ }
2165
+ };
2166
+ const model = {
2167
+ ...baseModel,
2168
+ id: entry.id,
2169
+ name: entry.name || entry.id,
2170
+ contextWindow: entry.contextLength ?? baseModel.contextWindow,
2171
+ maxTokens: entry.maxCompletionTokens ?? baseModel.maxTokens,
2172
+ input: parseModality(entry.modality),
2173
+ reasoning: baseModel.reasoning
2174
+ };
2175
+ const toolResult = await probeTool(model, apiKey, timeoutMs);
2176
+ const imageResult = model.input.includes("image") ? await probeImage(ensureImageInput(model), apiKey, timeoutMs) : {
2177
+ ok: false,
2178
+ latencyMs: null,
2179
+ skipped: true
2180
+ };
2181
+ return {
2182
+ id: entry.id,
2183
+ name: entry.name,
2184
+ provider: "openrouter",
2185
+ modelRef: `openrouter/${entry.id}`,
2186
+ contextLength: entry.contextLength,
2187
+ maxCompletionTokens: entry.maxCompletionTokens,
2188
+ supportedParametersCount: entry.supportedParametersCount,
2189
+ supportsToolsMeta: entry.supportsToolsMeta,
2190
+ modality: entry.modality,
2191
+ inferredParamB: entry.inferredParamB,
2192
+ createdAtMs: entry.createdAtMs,
2193
+ pricing: entry.pricing,
2194
+ isFree,
2195
+ tool: toolResult,
2196
+ image: imageResult
2197
+ };
2198
+ }, { onProgress: (completed, total) => options.onProgress?.({
2199
+ phase: "probe",
2200
+ completed,
2201
+ total
2202
+ }) });
2203
+ }
2204
+
2205
+ //#endregion
2206
+ //#region src/commands/models/scan.ts
2207
+ const MODEL_PAD = 42;
2208
+ const CTX_PAD = 8;
2209
+ const multiselect$1 = (params) => multiselect({
2210
+ ...params,
2211
+ message: stylePromptMessage(params.message),
2212
+ options: params.options.map((opt) => opt.hint === void 0 ? opt : {
2213
+ ...opt,
2214
+ hint: stylePromptHint(opt.hint)
2215
+ })
2216
+ });
2217
+ const pad = (value, size) => value.padEnd(size);
2218
+ const truncate = (value, max) => {
2219
+ if (value.length <= max) return value;
2220
+ if (max <= 3) return value.slice(0, max);
2221
+ return `${value.slice(0, max - 3)}...`;
2222
+ };
2223
+ function sortScanResults(results) {
2224
+ return results.slice().toSorted((a, b) => {
2225
+ const aImage = a.image.ok ? 1 : 0;
2226
+ const bImage = b.image.ok ? 1 : 0;
2227
+ if (aImage !== bImage) return bImage - aImage;
2228
+ const aToolLatency = a.tool.latencyMs ?? Number.POSITIVE_INFINITY;
2229
+ const bToolLatency = b.tool.latencyMs ?? Number.POSITIVE_INFINITY;
2230
+ if (aToolLatency !== bToolLatency) return aToolLatency - bToolLatency;
2231
+ return compareScanMetadata(a, b);
2232
+ });
2233
+ }
2234
+ function sortImageResults(results) {
2235
+ return results.slice().toSorted((a, b) => {
2236
+ const aLatency = a.image.latencyMs ?? Number.POSITIVE_INFINITY;
2237
+ const bLatency = b.image.latencyMs ?? Number.POSITIVE_INFINITY;
2238
+ if (aLatency !== bLatency) return aLatency - bLatency;
2239
+ return compareScanMetadata(a, b);
2240
+ });
2241
+ }
2242
+ function compareScanMetadata(a, b) {
2243
+ const aCtx = a.contextLength ?? 0;
2244
+ const bCtx = b.contextLength ?? 0;
2245
+ if (aCtx !== bCtx) return bCtx - aCtx;
2246
+ const aParams = a.inferredParamB ?? 0;
2247
+ const bParams = b.inferredParamB ?? 0;
2248
+ if (aParams !== bParams) return bParams - aParams;
2249
+ return a.modelRef.localeCompare(b.modelRef);
2250
+ }
2251
+ function buildScanHint(result) {
2252
+ return [
2253
+ result.tool.ok ? `tool ${formatMs(result.tool.latencyMs)}` : "tool fail",
2254
+ result.image.skipped ? "img skip" : result.image.ok ? `img ${formatMs(result.image.latencyMs)}` : "img fail",
2255
+ result.contextLength ? `ctx ${formatTokenK(result.contextLength)}` : "ctx ?",
2256
+ result.inferredParamB ? `${result.inferredParamB}b` : null
2257
+ ].filter(Boolean).join(" | ");
2258
+ }
2259
+ function printScanSummary(results, runtime) {
2260
+ const toolOk = results.filter((r) => r.tool.ok);
2261
+ const imageOk = results.filter((r) => r.image.ok);
2262
+ const toolImageOk = results.filter((r) => r.tool.ok && r.image.ok);
2263
+ const imageOnly = imageOk.filter((r) => !r.tool.ok);
2264
+ runtime.log(`Scan results: tested ${results.length}, tool ok ${toolOk.length}, image ok ${imageOk.length}, tool+image ok ${toolImageOk.length}, image only ${imageOnly.length}`);
2265
+ }
2266
+ function printScanTable(results, runtime) {
2267
+ const header = [
2268
+ pad("Model", MODEL_PAD),
2269
+ pad("Tool", 10),
2270
+ pad("Image", 10),
2271
+ pad("Ctx", CTX_PAD),
2272
+ pad("Params", 8),
2273
+ "Notes"
2274
+ ].join(" ");
2275
+ runtime.log(header);
2276
+ for (const entry of results) {
2277
+ const modelLabel = pad(truncate(entry.modelRef, MODEL_PAD), MODEL_PAD);
2278
+ const toolLabel = pad(entry.tool.ok ? formatMs(entry.tool.latencyMs) : "fail", 10);
2279
+ const imageLabel = pad(entry.image.ok ? formatMs(entry.image.latencyMs) : entry.image.skipped ? "skip" : "fail", 10);
2280
+ const ctxLabel = pad(formatTokenK(entry.contextLength), CTX_PAD);
2281
+ const paramsLabel = pad(entry.inferredParamB ? `${entry.inferredParamB}b` : "-", 8);
2282
+ const notes = entry.modality ? `modality:${entry.modality}` : "";
2283
+ runtime.log([
2284
+ modelLabel,
2285
+ toolLabel,
2286
+ imageLabel,
2287
+ ctxLabel,
2288
+ paramsLabel,
2289
+ notes
2290
+ ].join(" "));
2291
+ }
2292
+ }
2293
+ async function modelsScanCommand(opts, runtime) {
2294
+ const minParams = opts.minParams ? Number(opts.minParams) : void 0;
2295
+ if (minParams !== void 0 && (!Number.isFinite(minParams) || minParams < 0)) throw new Error("--min-params must be >= 0");
2296
+ const maxAgeDays = opts.maxAgeDays ? Number(opts.maxAgeDays) : void 0;
2297
+ if (maxAgeDays !== void 0 && (!Number.isFinite(maxAgeDays) || maxAgeDays < 0)) throw new Error("--max-age-days must be >= 0");
2298
+ const maxCandidates = opts.maxCandidates ? Number(opts.maxCandidates) : 6;
2299
+ if (!Number.isFinite(maxCandidates) || maxCandidates <= 0) throw new Error("--max-candidates must be > 0");
2300
+ const timeout = opts.timeout ? Number(opts.timeout) : void 0;
2301
+ if (timeout !== void 0 && (!Number.isFinite(timeout) || timeout <= 0)) throw new Error("--timeout must be > 0");
2302
+ const concurrency = opts.concurrency ? Number(opts.concurrency) : void 0;
2303
+ if (concurrency !== void 0 && (!Number.isFinite(concurrency) || concurrency <= 0)) throw new Error("--concurrency must be > 0");
2304
+ const cfg = loadConfig();
2305
+ const probe = opts.probe ?? true;
2306
+ let storedKey;
2307
+ if (probe) try {
2308
+ storedKey = (await resolveApiKeyForProvider({
2309
+ provider: "openrouter",
2310
+ cfg
2311
+ })).apiKey;
2312
+ } catch {
2313
+ storedKey = void 0;
2314
+ }
2315
+ const results = await withProgressTotals({
2316
+ label: "Scanning OpenRouter models...",
2317
+ indeterminate: false,
2318
+ enabled: opts.json !== true
2319
+ }, async (update) => await scanOpenRouterModels({
2320
+ apiKey: storedKey ?? void 0,
2321
+ minParamB: minParams,
2322
+ maxAgeDays,
2323
+ providerFilter: opts.provider,
2324
+ timeoutMs: timeout,
2325
+ concurrency,
2326
+ probe,
2327
+ onProgress: ({ phase, completed, total }) => {
2328
+ if (phase !== "probe") return;
2329
+ update({
2330
+ completed,
2331
+ total,
2332
+ label: `${probe ? "Probing models" : "Scanning models"} (${completed}/${total})`
2333
+ });
2334
+ }
2335
+ }));
2336
+ if (!probe) {
2337
+ if (!opts.json) {
2338
+ runtime.log(`Found ${results.length} OpenRouter free models (metadata only; pass --probe to test tools/images).`);
2339
+ printScanTable(sortScanResults(results), runtime);
2340
+ } else runtime.log(JSON.stringify(results, null, 2));
2341
+ return;
2342
+ }
2343
+ const toolOk = results.filter((entry) => entry.tool.ok);
2344
+ if (toolOk.length === 0) throw new Error("No tool-capable OpenRouter free models found.");
2345
+ const sorted = sortScanResults(results);
2346
+ const toolSorted = sortScanResults(toolOk);
2347
+ const imageSorted = sortImageResults(results.filter((entry) => entry.image.ok));
2348
+ const imagePreferred = toolSorted.filter((entry) => entry.image.ok);
2349
+ const preselected = (imagePreferred.length > 0 ? imagePreferred : toolSorted).slice(0, Math.floor(maxCandidates)).map((entry) => entry.modelRef);
2350
+ const imagePreselected = imageSorted.slice(0, Math.floor(maxCandidates)).map((entry) => entry.modelRef);
2351
+ if (!opts.json) {
2352
+ printScanSummary(results, runtime);
2353
+ printScanTable(sorted, runtime);
2354
+ }
2355
+ const noInput = opts.input === false;
2356
+ const canPrompt = process.stdin.isTTY && !opts.yes && !noInput && !opts.json;
2357
+ let selected = preselected;
2358
+ let selectedImages = imagePreselected;
2359
+ if (canPrompt) {
2360
+ const selection = await multiselect$1({
2361
+ message: "Select fallback models (ordered)",
2362
+ options: toolSorted.map((entry) => ({
2363
+ value: entry.modelRef,
2364
+ label: entry.modelRef,
2365
+ hint: buildScanHint(entry)
2366
+ })),
2367
+ initialValues: preselected
2368
+ });
2369
+ if (isCancel(selection)) {
2370
+ cancel(stylePromptTitle("Model scan cancelled.") ?? "Model scan cancelled.");
2371
+ runtime.exit(0);
2372
+ }
2373
+ selected = selection;
2374
+ if (imageSorted.length > 0) {
2375
+ const imageSelection = await multiselect$1({
2376
+ message: "Select image fallback models (ordered)",
2377
+ options: imageSorted.map((entry) => ({
2378
+ value: entry.modelRef,
2379
+ label: entry.modelRef,
2380
+ hint: buildScanHint(entry)
2381
+ })),
2382
+ initialValues: imagePreselected
2383
+ });
2384
+ if (isCancel(imageSelection)) {
2385
+ cancel(stylePromptTitle("Model scan cancelled.") ?? "Model scan cancelled.");
2386
+ runtime.exit(0);
2387
+ }
2388
+ selectedImages = imageSelection;
2389
+ }
2390
+ } else if (!process.stdin.isTTY && !opts.yes && !noInput && !opts.json) throw new Error("Non-interactive scan: pass --yes to apply defaults.");
2391
+ if (selected.length === 0) throw new Error("No models selected for fallbacks.");
2392
+ if (opts.setImage && selectedImages.length === 0) throw new Error("No image-capable models selected for image model.");
2393
+ await updateConfig((cfg) => {
2394
+ const nextModels = { ...cfg.agents?.defaults?.models };
2395
+ for (const entry of selected) if (!nextModels[entry]) nextModels[entry] = {};
2396
+ for (const entry of selectedImages) if (!nextModels[entry]) nextModels[entry] = {};
2397
+ const existingImageModel = cfg.agents?.defaults?.imageModel;
2398
+ const nextImageModel = selectedImages.length > 0 ? {
2399
+ ...existingImageModel?.primary ? { primary: existingImageModel.primary } : void 0,
2400
+ fallbacks: selectedImages,
2401
+ ...opts.setImage ? { primary: selectedImages[0] } : {}
2402
+ } : cfg.agents?.defaults?.imageModel;
2403
+ const existingModel = cfg.agents?.defaults?.model;
2404
+ const defaults = {
2405
+ ...cfg.agents?.defaults,
2406
+ model: {
2407
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
2408
+ fallbacks: selected,
2409
+ ...opts.setDefault ? { primary: selected[0] } : {}
2410
+ },
2411
+ ...nextImageModel ? { imageModel: nextImageModel } : {},
2412
+ models: nextModels
2413
+ };
2414
+ return {
2415
+ ...cfg,
2416
+ agents: {
2417
+ ...cfg.agents,
2418
+ defaults
2419
+ }
2420
+ };
2421
+ });
2422
+ if (opts.json) {
2423
+ runtime.log(JSON.stringify({
2424
+ selected,
2425
+ selectedImages,
2426
+ setDefault: Boolean(opts.setDefault),
2427
+ setImage: Boolean(opts.setImage),
2428
+ results,
2429
+ warnings: []
2430
+ }, null, 2));
2431
+ return;
2432
+ }
2433
+ logConfigUpdated(runtime);
2434
+ runtime.log(`Fallbacks: ${selected.join(", ")}`);
2435
+ if (selectedImages.length > 0) runtime.log(`Image fallbacks: ${selectedImages.join(", ")}`);
2436
+ if (opts.setDefault) runtime.log(`Default model: ${selected[0]}`);
2437
+ if (opts.setImage && selectedImages.length > 0) runtime.log(`Image model: ${selectedImages[0]}`);
2438
+ }
2439
+
2440
+ //#endregion
2441
+ //#region src/commands/models/set.ts
2442
+ async function modelsSetCommand(modelRaw, runtime) {
2443
+ const updated = await updateConfig((cfg) => {
2444
+ const resolved = resolveModelTarget({
2445
+ raw: modelRaw,
2446
+ cfg
2447
+ });
2448
+ const key = `${resolved.provider}/${resolved.model}`;
2449
+ const nextModels = { ...cfg.agents?.defaults?.models };
2450
+ if (!nextModels[key]) nextModels[key] = {};
2451
+ const existingModel = cfg.agents?.defaults?.model;
2452
+ return {
2453
+ ...cfg,
2454
+ agents: {
2455
+ ...cfg.agents,
2456
+ defaults: {
2457
+ ...cfg.agents?.defaults,
2458
+ model: {
2459
+ ...existingModel?.fallbacks ? { fallbacks: existingModel.fallbacks } : void 0,
2460
+ primary: key
2461
+ },
2462
+ models: nextModels
2463
+ }
2464
+ }
2465
+ };
2466
+ });
2467
+ logConfigUpdated(runtime);
2468
+ runtime.log(`Default model: ${updated.agents?.defaults?.model?.primary ?? modelRaw}`);
2469
+ }
2470
+
2471
+ //#endregion
2472
+ //#region src/commands/models/set-image.ts
2473
+ async function modelsSetImageCommand(modelRaw, runtime) {
2474
+ const updated = await updateConfig((cfg) => {
2475
+ const resolved = resolveModelTarget({
2476
+ raw: modelRaw,
2477
+ cfg
2478
+ });
2479
+ const key = `${resolved.provider}/${resolved.model}`;
2480
+ const nextModels = { ...cfg.agents?.defaults?.models };
2481
+ if (!nextModels[key]) nextModels[key] = {};
2482
+ const existingModel = cfg.agents?.defaults?.imageModel;
2483
+ return {
2484
+ ...cfg,
2485
+ agents: {
2486
+ ...cfg.agents,
2487
+ defaults: {
2488
+ ...cfg.agents?.defaults,
2489
+ imageModel: {
2490
+ ...existingModel?.fallbacks ? { fallbacks: existingModel.fallbacks } : void 0,
2491
+ primary: key
2492
+ },
2493
+ models: nextModels
2494
+ }
2495
+ }
2496
+ };
2497
+ });
2498
+ logConfigUpdated(runtime);
2499
+ runtime.log(`Image model: ${updated.agents?.defaults?.imageModel?.primary ?? modelRaw}`);
2500
+ }
2501
+
2502
+ //#endregion
2503
+ //#region src/commands/models.ts
2504
+ var models_exports = /* @__PURE__ */ __exportAll({
2505
+ modelsListCommand: () => modelsListCommand,
2506
+ modelsStatusCommand: () => modelsStatusCommand
2507
+ });
2508
+
2509
+ //#endregion
2510
+ export { modelsAliasesListCommand as C, modelsAliasesAddCommand as S, modelsAuthOrderSetCommand as _, modelsStatusCommand as a, modelsAuthPasteTokenCommand as b, modelsImageFallbacksClearCommand as c, modelsFallbacksAddCommand as d, modelsFallbacksClearCommand as f, modelsAuthOrderGetCommand as g, modelsAuthOrderClearCommand as h, modelsScanCommand as i, modelsImageFallbacksListCommand as l, modelsFallbacksRemoveCommand as m, modelsSetImageCommand as n, modelsListCommand as o, modelsFallbacksListCommand as p, modelsSetCommand as r, modelsImageFallbacksAddCommand as s, models_exports as t, modelsImageFallbacksRemoveCommand as u, modelsAuthAddCommand as v, modelsAliasesRemoveCommand as w, modelsAuthSetupTokenCommand as x, modelsAuthLoginCommand as y };