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