@noxsoft/anima 5.1.2 → 6.0.0

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 (488) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +2 -2
  3. package/dist/{APEv2Parser-DV7AH14P.js → APEv2Parser-Dvsbp_2R.js} +3 -3
  4. package/dist/{AbstractID3Parser-C3RlCr-Y.js → AbstractID3Parser-IB9gxozg.js} +5 -5
  5. package/dist/{AiffParser-DaFyNU8n.js → AiffParser-R2IhrBzL.js} +4 -4
  6. package/dist/{AsfParser-CDCRfCXr.js → AsfParser-DJEueUMg.js} +4 -4
  7. package/dist/{DsdiffParser-BX31LICZ.js → DsdiffParser-DXLYn9tT.js} +4 -4
  8. package/dist/{DsfParser-C3JBjE-C.js → DsfParser-D2--NF0i.js} +5 -5
  9. package/dist/{FlacParser-DY4m-7v1.js → FlacParser-8cDAjrth.js} +5 -5
  10. package/dist/{ID3v1Parser-DL9AGlNt.js → ID3v1Parser-B494XuP9.js} +3 -3
  11. package/dist/{ID3v2Parser-Mr8o-5GJ.js → ID3v2Parser-DlxcNqv5.js} +4 -4
  12. package/dist/{ID3v2Token-DQqGh8AB.js → ID3v2Token-CSLSVrSQ.js} +2 -2
  13. package/dist/{MP4Parser-DkunlEqI.js → MP4Parser-COql2J-w.js} +6 -6
  14. package/dist/{MatroskaParser-IKjHx0h7.js → MatroskaParser-bNP5wC2F.js} +3 -3
  15. package/dist/{MpegParser-EecSeRWJ.js → MpegParser-C1gjfYqq.js} +4 -4
  16. package/dist/{MusepackParser-CkfsAeuE.js → MusepackParser-DBdYf7kV.js} +5 -5
  17. package/dist/{OggParser-z3QlSd8U.js → OggParser-CxajqbK3.js} +5 -5
  18. package/dist/{Util-DDVY6AaC.js → Util-BRZxoY1Q.js} +1 -1
  19. package/dist/{WavPackParser-PimUUBRx.js → WavPackParser-CtH9QFia.js} +4 -4
  20. package/dist/{WaveParser-B539YtoQ.js → WaveParser-yufLki1G.js} +5 -5
  21. package/dist/{accounts-CL0JV_xk.js → accounts-B_2nt5Cd.js} +2 -2
  22. package/dist/{accounts-CYEa4ttU.js → accounts-COxGcLGB.js} +1 -1
  23. package/dist/{accounts-Bj5MvaDs.js → accounts-DIES085e.js} +11 -11
  24. package/dist/{accounts-DZsqyow2.js → accounts-TUsfghIW.js} +38 -38
  25. package/dist/{acp-cli-ynoZZhYQ.js → acp-cli-CWgqDQQH.js} +6 -6
  26. package/dist/{acp-cli-BFAoKBvs.js → acp-cli-D0wfP8-l.js} +16 -16
  27. package/dist/{active-listener-BWPgtTZp.js → active-listener-BKtsWhsb.js} +4 -4
  28. package/dist/{active-listener-GJR3nLhX.js → active-listener-D2r8IO7g.js} +5 -5
  29. package/dist/{agent-DUAarfNl.js → agent-CnS0SRpT.js} +93 -236
  30. package/dist/{agent-CaaEZsXl.js → agent-VRQM14Xp.js} +98 -229
  31. package/dist/{agent-scope-C9CiVcmh.js → agent-scope-ByIGrCTT.js} +2 -2
  32. package/dist/{agent-scope-D3HZp64M.js → agent-scope-CXxC8FFX.js} +2 -2
  33. package/dist/{agent-scope-BZ8hjIt_.js → agent-scope-CxBzAozu.js} +3 -3
  34. package/dist/{agents-t54YcbvK.js → agents-CvMRplDx.js} +15 -13
  35. package/dist/{agents.config-J7iEgdW_.js → agents.config-BR5JLtud.js} +1 -1
  36. package/dist/{anthropic-direct-runner-B12V2Q5H.js → anthropic-direct-runner-BeYCnvZ8.js} +37 -15
  37. package/dist/{anthropic-direct-runner-CzQb7QkD.js → anthropic-direct-runner-C2Kwju-r.js} +29 -7
  38. package/dist/{audit-ByHmjh-G.js → audit-B05W5ckN.js} +23 -34
  39. package/dist/{audit-HJOpXfgY.js → audit-DDz7UOIx.js} +18 -15
  40. package/dist/{auth-DXrALxdm.js → auth-DsC5pZ_0.js} +2 -2
  41. package/dist/{prompts-CneQ6SeF.js → auth-choice-DY1saszS.js} +12 -107
  42. package/dist/{auth-choice-DPWnLV_w.js → auth-choice-Dc5TAJwT.js} +10 -9
  43. package/dist/{auth-health-DmrnGklu.js → auth-health-Cc8-vy8y.js} +1 -1
  44. package/dist/auth-health-Dhr8p2SD.js +149 -0
  45. package/dist/{auth-profiles-BF5x9Ej0.js → auth-profiles-Brxz2ojJ.js} +193 -42
  46. package/dist/{auth-profiles-DjCH4kWT.js → auth-profiles-C-LuhW6c.js} +195 -44
  47. package/dist/{auth-profiles-PJVsRqf4.js → auth-profiles-DKu7ZUzl.js} +189 -29
  48. package/dist/{auth-profiles-eZzmaeR3.js → auth-profiles-DtWUl1-k.js} +198 -38
  49. package/dist/{auth-store-CnRrUELz.js → auth-store-Bd0GoqEL.js} +13 -13
  50. package/dist/{auth-store-KnWGteIV.js → auth-store-BpYI9t_y.js} +3 -3
  51. package/dist/{auth-store-DjcQlyze.js → auth-store-Jvgz2_l1.js} +2 -2
  52. package/dist/{banner-D9JyV5SF.js → banner-DAMtSjUF.js} +1 -1
  53. package/dist/{bonjour-discovery-QsoaZ8Pr.js → bonjour-discovery-Co-b97Dz.js} +2 -2
  54. package/dist/build-info.json +3 -3
  55. package/dist/bundled/boot-md/handler.js +222 -151
  56. package/dist/bundled/bootstrap-extra-files/handler.js +5 -5
  57. package/dist/bundled/command-logger/handler.js +1 -1
  58. package/dist/bundled/session-memory/handler.js +24 -24
  59. package/dist/{call-DHZ76BNg.js → call-B4lhqS6H.js} +3 -3
  60. package/dist/{call-DQjoz63V.js → call-CDPbPDAr.js} +4 -4
  61. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  62. package/dist/{catalog-AZNRamJ4.js → catalog-CsXv59Tq.js} +2 -2
  63. package/dist/{channel-web-CQIbtfme.js → channel-web-B8mzTSaY.js} +15 -15
  64. package/dist/{channels-status-issues-DdjvFHx9.js → channels-status-issues-WkG3Tmxk.js} +4 -4
  65. package/dist/{chrome-HTuFjVWW.js → chrome-B8EnYGj1.js} +9 -9
  66. package/dist/{chrome-BNggURXT.js → chrome-BaU-H9m7.js} +3 -3
  67. package/dist/{chrome-Cfak4A3i.js → chrome-DLUBPBPz.js} +12 -12
  68. package/dist/{chunk-CyT-_QsQ.js → chunk-B4Kx-ocg.js} +11 -9
  69. package/dist/{chunk-Dffz_QIs.js → chunk-CFSle8n5.js} +1 -1
  70. package/dist/{chunk-D3vyM2EQ.js → chunk-Cy0Bj0F3.js} +1 -1
  71. package/dist/{chunk-DFqo_u5A.js → chunk-DJXDX69U.js} +11 -9
  72. package/dist/{clack-prompter-QbDK4ABC.js → clack-prompter-0JW5kry0.js} +3 -3
  73. package/dist/{clack-prompter-rXuqdPbx.js → clack-prompter-fZSmnHda.js} +5 -5
  74. package/dist/cli/daemon-cli.js +1 -1
  75. package/dist/{cli-kT9Mb3dT.js → cli-D8exVpuI.js} +30 -29
  76. package/dist/cli-hcHk5KuP.js +102 -0
  77. package/dist/{cli-utils-BdkJVXjy.js → cli-utils-D2X_bDLt.js} +9 -1
  78. package/dist/{cli-utils-DGnL8raH.js → cli-utils-DcDBK4C5.js} +9 -1
  79. package/dist/{client-D9E5Wwb_.js → client-BWkoTfOH.js} +3 -2
  80. package/dist/{client-DzIcZx4J.js → client-CfLiulzK.js} +2 -1
  81. package/dist/{command-registry-vEVxxxzI.js → command-registry-D3VhxpWx.js} +21 -12
  82. package/dist/{commands-NIY0IDXe.js → commands-DE8FNH0v.js} +92 -20
  83. package/dist/{commands-eY0Ao0wt.js → commands-Mekaw9WG.js} +92 -20
  84. package/dist/{common-C2wAYEWA.js → common-BCW6hLGI.js} +2 -2
  85. package/dist/{common-BzPvZcxT.js → common-Bf_TG87Y.js} +2 -2
  86. package/dist/{common-6Fcbzr42.js → common-DT_obM-k.js} +2 -2
  87. package/dist/{completion-cli-BBKG6buM.js → completion-cli-B3BqQJq9.js} +3 -3
  88. package/dist/{completion-cli-C84I5l8a.js → completion-cli-CepDzeW1.js} +2 -2
  89. package/dist/{config-Ofh9gKvs.js → config-BrVuTQ8R.js} +14 -2
  90. package/dist/{config-6FVC8hW0.js → config-CweTwOtr.js} +40 -28
  91. package/dist/{config-DqwH4y-D.js → config-DaD4FsAn.js} +19 -7
  92. package/dist/{config-D2kCn7yR.js → config-ZYN8tezd.js} +18 -6
  93. package/dist/{config-cli-CQzq5yWB.js → config-cli-3CaIxSKo.js} +4 -4
  94. package/dist/config-cli-B6Np85rk.js +15 -0
  95. package/dist/{config-guard-B1plY6aQ.js → config-guard-C4b2dksv.js} +2 -2
  96. package/dist/{config-guard-CYlpjNN7.js → config-guard-CWhoBtB3.js} +20 -20
  97. package/dist/{config-sync-CYX9Tzyr.js → config-sync-CCVp-tVX.js} +2 -2
  98. package/dist/{config-sync-CDUhjDom.js → config-sync-CMO_5lyl.js} +2 -2
  99. package/dist/{configure-G6h2Ppk0.js → configure-D882Bg7c.js} +39 -15
  100. package/dist/{configure-Bv6mqD0j.js → configure-D88dg6mE.js} +79 -77
  101. package/dist/{configure-DxQqSUJs.js → configure-xpjwedvJ.js} +50 -49
  102. package/dist/{configure-B-dfdPKX.js → configure-zXK6UZ51.js} +49 -24
  103. package/dist/{context-CpsnZLOp.js → context-B5X720Bs.js} +1 -1
  104. package/dist/{control-service-D1oxSXVg.js → control-service-3CI4vt1h.js} +2 -2
  105. package/dist/{control-service-CzAfyR4e.js → control-service-5YtMvm7D.js} +5 -5
  106. package/dist/control-ui/assets/index-C4ejMN5U.js +72 -0
  107. package/dist/control-ui/assets/index-C4ejMN5U.js.map +1 -0
  108. package/dist/control-ui/assets/index-CcPNqN3R.css +1 -0
  109. package/dist/control-ui/assets/index-D7Bf6Say.js +3 -0
  110. package/dist/control-ui/assets/index-D7Bf6Say.js.map +1 -0
  111. package/dist/control-ui/assets/index-yhFuaOnc.js +2 -0
  112. package/dist/control-ui/assets/index-yhFuaOnc.js.map +1 -0
  113. package/dist/control-ui/assets/observers-V7q9lNYt.js +2 -0
  114. package/dist/control-ui/assets/observers-V7q9lNYt.js.map +1 -0
  115. package/dist/control-ui/assets/rrweb-plugin-console-record-sPdhR0i8.js +138 -0
  116. package/dist/control-ui/assets/rrweb-plugin-console-record-sPdhR0i8.js.map +1 -0
  117. package/dist/control-ui/assets/rrweb-record-CMVXB7aO.js +129 -0
  118. package/dist/control-ui/assets/rrweb-record-CMVXB7aO.js.map +1 -0
  119. package/dist/control-ui/index.html +2 -2
  120. package/dist/{cron-cli-C4qZZo4e.js → cron-cli-Cht6Itx6.js} +18 -18
  121. package/dist/{cron-cli-CSivg2i9.js → cron-cli-D9XrF-Gx.js} +8 -8
  122. package/dist/{daemon-cli-DfxT-pQ4.js → daemon-cli-9zrnYRjh.js} +8 -8
  123. package/dist/{daemon-cli-KMzjJH_D.js → daemon-cli-CrdPhSxr.js} +15 -15
  124. package/dist/daemon-cli.js +34 -6
  125. package/dist/{daemon-runtime-CIE27usH.js → daemon-runtime-BrUj88ZO.js} +2 -2
  126. package/dist/{daemon-runtime-BfgstLVI.js → daemon-runtime-DCqwraWR.js} +1 -1
  127. package/dist/{deliver-8r6UbXnC.js → deliver-B-dPbUIs.js} +18 -28
  128. package/dist/{deliver-ahx1N11n.js → deliver-BKzX3YoN.js} +7 -7
  129. package/dist/{deliver-DVt8TbK9.js → deliver-C1L5nO0K.js} +3 -3
  130. package/dist/{deliver-D2hQZ9X0.js → deliver-d-CaN0uL.js} +59 -69
  131. package/dist/deps-DyT32VfN.js +23 -0
  132. package/dist/{diagnostics-DXeDqA_-.js → diagnostics-Cu9pZAFn.js} +1 -1
  133. package/dist/{dispatcher-DpSnqIL0.js → dispatcher-BQQugU-7.js} +1 -1
  134. package/dist/{dispatcher-DzT6jltc.js → dispatcher-DzwzLQRk.js} +2 -2
  135. package/dist/{dns-cli-D9ka2fZD.js → dns-cli-C8KIX4P3.js} +12 -12
  136. package/dist/{dns-cli-D2Orvc8E.js → dns-cli-V2bo6vSt.js} +3 -3
  137. package/dist/{docs-cli-CKfzGqYM.js → docs-cli-Bt-YV3xs.js} +2 -2
  138. package/dist/{docs-cli-DWYXJd-j.js → docs-cli-D2cVJxjP.js} +7 -7
  139. package/dist/{doctor-vXt5qjNJ.js → doctor-DEnSKgHu.js} +21 -21
  140. package/dist/{doctor-DumyG85t.js → doctor-WpKCNZeO.js} +36 -181
  141. package/dist/{doctor-completion-lAyxyd7X.js → doctor-completion-CPff9UlF.js} +2 -2
  142. package/dist/{doctor-completion-C8JSWfqN.js → doctor-completion-CypXc1Uo.js} +2 -2
  143. package/dist/{doctor-config-flow-DA50eWp5.js → doctor-config-flow-Bgl0Cc20.js} +6 -6
  144. package/dist/{doctor-config-flow-BjfGQ1Br.js → doctor-config-flow-Dxy7RIm0.js} +4 -4
  145. package/dist/{engine-BVchKo5_.js → engine-DpbYPop7.js} +9 -9
  146. package/dist/{engine-CKqNpVwE.js → engine-zmn3SOYa.js} +10 -9
  147. package/dist/entry.js +19 -28
  148. package/dist/{env-DVJCc7dM.js → env-DlTia1B4.js} +1 -1
  149. package/dist/{exec-cazBMA02.js → exec-BylR5qWS.js} +1 -1
  150. package/dist/{exec-gKbUce2p.js → exec-C6tXfeqA.js} +1 -1
  151. package/dist/{exec-Bfd4ztFZ.js → exec-DUzVF5_D.js} +7 -7
  152. package/dist/{exec-approvals-cli-BPwW6GIK.js → exec-approvals-cli-CN2WeH7y.js} +20 -20
  153. package/dist/{exec-approvals-cli-6HndodnP.js → exec-approvals-cli-DYZVBnqS.js} +8 -8
  154. package/dist/extensionAPI.js +22 -22
  155. package/dist/format-BCAtE7cT.js +20 -0
  156. package/dist/{frontmatter-BP4GSt5L.js → frontmatter-Dsa7N963.js} +2 -2
  157. package/dist/{gateway-cli-CHhTweWb.js → gateway-cli-B_xsx5Nv.js} +104 -101
  158. package/dist/{gateway-cli-B60L2z4a.js → gateway-cli-D3VBOA_i.js} +69 -66
  159. package/dist/{gateway-rpc-CrSglZPE.js → gateway-rpc-Cj_h2sVM.js} +3 -3
  160. package/dist/{gateway-rpc-BtOX_e53.js → gateway-rpc-CnXMGsxp.js} +3 -3
  161. package/dist/{gmail-setup-utils-D2uUKNlF.js → gmail-setup-utils-DaJoXV_3.js} +3 -3
  162. package/dist/{health-BttJ1Qeh.js → health-C8KCBhuo.js} +8 -8
  163. package/dist/{health-D8fJ6U_k.js → health-CabOEPQ0.js} +13 -13
  164. package/dist/{health-format-CH6JWH45.js → health-format-D-JJ5_S4.js} +2 -2
  165. package/dist/{heartbeat-visibility-DcGQOTXe.js → heartbeat-visibility-BjYY-mKG.js} +1 -1
  166. package/dist/{heartbeat-visibility-B2MDtPTL.js → heartbeat-visibility-ZfNSbFcq.js} +1 -1
  167. package/dist/{help-format-7YidDC5Z.js → help-format-Dt-I_Mls.js} +1 -1
  168. package/dist/{hooks-cli-DRUryj5H.js → hooks-cli-Cs7GUa7G.js} +34 -33
  169. package/dist/{hooks-cli-BMZF6RF3.js → hooks-cli-DOs9WZ3K.js} +56 -55
  170. package/dist/{hooks-status-VvwKn90L.js → hooks-status-DdweuSIj.js} +4 -4
  171. package/dist/{image-ops-BUy__GHL.js → image-ops-Ct3GueyT.js} +1 -1
  172. package/dist/index.js +79 -71
  173. package/dist/{init-B8PBeUpi.js → init-CFndGgTJ.js} +1 -1
  174. package/dist/{init-DxkAVKP0.js → init-DkBwXNme.js} +1 -1
  175. package/dist/{installs-sayrGjx1.js → installs-Bi6UipiE.js} +6 -6
  176. package/dist/{installs-BcnNDR54.js → installs-a4Vz_J08.js} +3 -3
  177. package/dist/ipv4-DfMwLQ0d.js +14 -0
  178. package/dist/{lib-D4dE4_XZ.js → lib-6xd5SQjU.js} +20 -20
  179. package/dist/{lifecycle-core-BerWWP7p.js → lifecycle-core-B8PI1NZJ.js} +3 -3
  180. package/dist/{links-OhvsEkVw.js → links-DcilUrqq.js} +1 -1
  181. package/dist/llm-slug-generator.js +25 -25
  182. package/dist/{loader-CLNb0v_s.js → loader-Bw2wdN4l.js} +159 -3
  183. package/dist/{loader-Bww_qb65.js → loader-C87TLS4J.js} +159 -3
  184. package/dist/{logging-DhXRGHWg.js → logging-Chc1Sj6N.js} +1 -1
  185. package/dist/{login-BovU8kno.js → login-BHnvW9HA.js} +6 -6
  186. package/dist/{login-BPtmlRRv.js → login-BTOKtSQN.js} +5 -5
  187. package/dist/{login-C54B66KM.js → login-CrMpAZ0n.js} +4 -4
  188. package/dist/{login-C4mptULi.js → login-DKkQ3Czu.js} +5 -5
  189. package/dist/{login-qr-bim3Nkyu.js → login-qr-BGbHImRb.js} +8 -8
  190. package/dist/{login-qr-pFbvowe5.js → login-qr-CsAVGp00.js} +12 -12
  191. package/dist/{login-qr-657mh7cI.js → login-qr-DILcBA_q.js} +6 -6
  192. package/dist/{login-qr-BxNKHxcf.js → login-qr-OUAGpDsU.js} +10 -10
  193. package/dist/{logs-cli-CQStwrGd.js → logs-cli-Bc6IOyHA.js} +8 -8
  194. package/dist/{logs-cli-De79vyiP.js → logs-cli-BiAJbjnq.js} +15 -15
  195. package/dist/{manager-B043uMPT.js → manager-BYu34CX3.js} +12 -12
  196. package/dist/{manager-Cvmm95Pf.js → manager-C6L_DH0O.js} +2 -2
  197. package/dist/{manager-BtrVJ8Ve.js → manager-D8VCuzru.js} +9 -9
  198. package/dist/{manager-A3pC-CW-.js → manager-b_aZwo00.js} +16 -16
  199. package/dist/{manifest-registry-D-DOtLzo.js → manifest-registry-qF960vMH.js} +1 -1
  200. package/dist/{memory-cli-COl5xoIl.js → memory-cli-B0kKl-9T.js} +7 -7
  201. package/dist/{memory-cli-691NgCXx.js → memory-cli-DLtBA6r5.js} +11 -11
  202. package/dist/{message-channel-DZYYDt1_.js → message-channel-CMsexA3K.js} +9 -7
  203. package/dist/{message-channel-DdOBO6Qm.js → message-channel-DIHHKJhk.js} +8 -6
  204. package/dist/{migrate-DkBWjPPs.js → migrate-DuohB_ur.js} +3 -3
  205. package/dist/{migrate-BLjwxe9X.js → migrate-bgeTT_GR.js} +3 -3
  206. package/dist/{model-auth-DKhjNVHc.js → model-auth-CHB3EySM.js} +10 -5
  207. package/dist/{model-auth-CxAB4iZ0.js → model-auth-KpsOXKDc.js} +3 -3
  208. package/dist/model-param-b-C1QDqzQp.js +16 -0
  209. package/dist/{model-selection-BPkpXepz.js → model-selection-CLcoOT3e.js} +25 -7
  210. package/dist/{model-selection-wCaVeFbb.js → model-selection-CY6r_3wt.js} +25 -7
  211. package/dist/{model-selection-DFbDH9o2.js → model-selection-DcO3qJOu.js} +24 -6
  212. package/dist/{model-selection-BI8CKPwQ.js → model-selection-DjsJGv1R.js} +67 -8
  213. package/dist/models-BM2_NkMu.js +2707 -0
  214. package/dist/models-cli-BjY8wA-C.js +272 -0
  215. package/dist/models-cli-BpjeKsUz.js +2946 -0
  216. package/dist/{node-cli-Ajhng-5p.js → node-cli-BmuVEJ1C.js} +12 -12
  217. package/dist/{node-cli-t3N6HE9R.js → node-cli-DU_oREff.js} +27 -27
  218. package/dist/{node-service-4B-0AjmA.js → node-service-qZXF7T7A.js} +1 -1
  219. package/dist/{note-De2zPKl3.js → note-iMYVGjpA.js} +2 -2
  220. package/dist/noxsoft-bootstrap-C4dSx7K_.js +77 -0
  221. package/dist/noxsoft-bootstrap-CrlkSFzd.js +77 -0
  222. package/dist/{npm-registry-spec-CFp4OEe4.js → npm-registry-spec-Br4B4I_3.js} +2 -2
  223. package/dist/{npm-registry-spec-DVDcgWxm.js → npm-registry-spec-jf7Mowdn.js} +1 -1
  224. package/dist/{onboard-xSPFmM29.js → onboard-DM9gULJN.js} +24 -19
  225. package/dist/{onboard-i4CJtSb9.js → onboard-_-D81kAy.js} +19 -15
  226. package/dist/{onboard-channels-RsbA6EaD.js → onboard-channels-CtT-RN60.js} +8 -8
  227. package/dist/{onboard-channels-D6Gt3CsX.js → onboard-channels-UkphAdCy.js} +4 -4
  228. package/dist/{onboard-helpers-IeOtcIME.js → onboard-helpers-CFudIoX4.js} +3 -3
  229. package/dist/{onboard-helpers-DPqXrhma.js → onboard-helpers-CJ3HzoUO.js} +7 -7
  230. package/dist/{onboarding-CZBVMwFn.js → onboarding-BB9PteK8.js} +20 -17
  231. package/dist/{onboarding-Cao0a_Z1.js → onboarding-Djmm0PEM.js} +27 -23
  232. package/dist/{orchestrator-COMX8CF2.js → orchestrator-C1nWKIJS.js} +7 -3
  233. package/dist/{orchestrator-BLXpTTgr.js → orchestrator-C2ypFiPL.js} +6 -3
  234. package/dist/{outbound-DWfSyfZC.js → outbound-Bmft-5um.js} +4 -4
  235. package/dist/{outbound-Rs0fFC2g.js → outbound-C577aWZp.js} +1 -1
  236. package/dist/{outbound-DLCmFGfJ.js → outbound-DW2eod1S.js} +4 -4
  237. package/dist/{outbound-uxBpmALx.js → outbound-fPqdCDR4.js} +4 -4
  238. package/dist/outbound-send-deps-DVfWC4E8.js +14 -0
  239. package/dist/outbound-send-deps-T_FgdfgW.js +36 -0
  240. package/dist/{parse-timeout-DkOL1T_l.js → parse-timeout-C4WLf3Qy.js} +3 -3
  241. package/dist/{parse-timeout-DlU4ymhF.js → parse-timeout-D4UO8pY_.js} +1 -1
  242. package/dist/{path-env-CjpH-KWH.js → path-env-DLQPf9qj.js} +2 -2
  243. package/dist/{paths-D2eokayo.js → paths-B-AkG5FD.js} +3 -3
  244. package/dist/{paths-DQMKfv60.js → paths-CAQJvbeZ.js} +2 -2
  245. package/dist/{paths-Cwszsz1I.js → paths-Q6h5HODL.js} +2 -2
  246. package/dist/{pi-auth-json-BLdaEAx2.js → pi-auth-json-B_lKNFK6.js} +5 -5
  247. package/dist/{pi-auth-json-BH7uvkKr.js → pi-auth-json-BmdBnmlZ.js} +8 -9
  248. package/dist/{pi-auth-json-DjxzPUt3.js → pi-auth-json-DkYqdjrV.js} +2 -2
  249. package/dist/{pi-auth-json-smxh_Xud.js → pi-auth-json-WTvcP2gz.js} +9 -8
  250. package/dist/{pi-embedded-D4eEfxIU.js → pi-embedded-BMbtgOzv.js} +825 -319
  251. package/dist/{pi-embedded-DifnZvKk.js → pi-embedded-DfbM3fAT.js} +888 -382
  252. package/dist/{pi-embedded-helpers-B6wVA0hU.js → pi-embedded-helpers-BZ9GspxK.js} +1 -1
  253. package/dist/{pi-tools.policy-CDgjN_3f.js → pi-tools.policy-D2FusuQa.js} +3 -3
  254. package/dist/{pi-tools.policy-ox141hP6.js → pi-tools.policy-WdTAfqbV.js} +6 -6
  255. package/dist/{plugin-auto-enable-Mj7AnofW.js → plugin-auto-enable-CtYcdTju.js} +5 -5
  256. package/dist/{plugin-auto-enable-OqDAK-ap.js → plugin-auto-enable-DhuD30Je.js} +2 -2
  257. package/dist/{plugin-registry-CpXm8ADp.js → plugin-registry-DePMxn4z.js} +4 -4
  258. package/dist/{plugin-registry-CkZnT8Fb.js → plugin-registry-QTkplP4s.js} +2 -2
  259. package/dist/plugin-sdk/agents/cli-backends.d.ts +4 -1
  260. package/dist/plugin-sdk/agents/cli-credentials.d.ts +0 -10
  261. package/dist/plugin-sdk/agents/cli-runner.d.ts +2 -0
  262. package/dist/plugin-sdk/agents/defaults.d.ts +2 -2
  263. package/dist/plugin-sdk/agents/model-auto.d.ts +43 -0
  264. package/dist/plugin-sdk/agents/model-fallback.d.ts +5 -0
  265. package/dist/plugin-sdk/agents/model-preference.d.ts +25 -0
  266. package/dist/plugin-sdk/agents/noxsoft-runner.d.ts +94 -0
  267. package/dist/plugin-sdk/agents/pi-embedded-runner/run/params.d.ts +6 -3
  268. package/dist/plugin-sdk/agents/pi-embedded.d.ts +6 -50
  269. package/dist/plugin-sdk/agents/runner-capabilities.d.ts +2 -0
  270. package/dist/plugin-sdk/agents/sandbox/constants.d.ts +1 -1
  271. package/dist/plugin-sdk/auth/noxsoft-auth.d.ts +55 -0
  272. package/dist/plugin-sdk/channels/registry.d.ts +2 -2
  273. package/dist/plugin-sdk/cli/deps.d.ts +2 -1
  274. package/dist/plugin-sdk/cli/outbound-send-deps.d.ts +10 -0
  275. package/dist/plugin-sdk/commands/agent/types.d.ts +2 -0
  276. package/dist/plugin-sdk/config/types.agent-defaults.d.ts +14 -0
  277. package/dist/plugin-sdk/config/types.models.d.ts +1 -1
  278. package/dist/plugin-sdk/config/zod-schema.agent-defaults.d.ts +13 -0
  279. package/dist/plugin-sdk/config/zod-schema.agents.d.ts +13 -0
  280. package/dist/plugin-sdk/config/zod-schema.d.ts +13 -0
  281. package/dist/plugin-sdk/gateway/protocol/schema/agent.d.ts +1 -0
  282. package/dist/plugin-sdk/identity/loader.d.ts +1 -0
  283. package/dist/plugin-sdk/identity/trust-graph.d.ts +32 -0
  284. package/dist/plugin-sdk/index.js +57 -47
  285. package/dist/plugin-sdk/utils/message-channel.d.ts +2 -1
  286. package/dist/{plugins-DnJgmFJR.js → plugins-DYcg0qBW.js} +1 -1
  287. package/dist/{plugins-cli-CrrkMAYM.js → plugins-cli-Bc9oU1ld.js} +58 -57
  288. package/dist/{plugins-cli-D4VxQKaJ.js → plugins-cli-Dv0KQTWo.js} +36 -35
  289. package/dist/{polls-DuwPgAV7.js → polls-DFISjV7H.js} +5 -5
  290. package/dist/{ports-B1b1r9Dz.js → ports-DaVrZDUq.js} +2 -2
  291. package/dist/{ports-BX00e96t.js → ports-q535r1PZ.js} +2 -2
  292. package/dist/{program-CTDFmZNx.js → program-CuwbF8YO.js} +48 -40
  293. package/dist/{program-context-Hl6bnPfB.js → program-context-CxPfy-Wr.js} +51 -35
  294. package/dist/{progress-B-VBLfHr.js → progress-CVLvQV_t.js} +1 -1
  295. package/dist/{prompt-style-DU9Vjqe5.js → prompt-style-BI53UVgE.js} +1 -1
  296. package/dist/{prompts-D6b3zLVO.js → prompts-BmgT_kkv.js} +33 -2
  297. package/dist/prompts-Bq4QGFQM.js +158 -0
  298. package/dist/{pw-ai-BV57RRmp.js → pw-ai-CB-zeR7h.js} +5 -5
  299. package/dist/{pw-ai-CY-VcqJp.js → pw-ai-C_1-7IgH.js} +4 -4
  300. package/dist/{pw-ai-CTHtrCEC.js → pw-ai-DxNrJcCA.js} +3 -3
  301. package/dist/{qmd-manager-DJeQYS-r.js → qmd-manager-C_XBZ_bT.js} +5 -5
  302. package/dist/{qmd-manager-CwbYv6nJ.js → qmd-manager-CpNYgSrx.js} +7 -7
  303. package/dist/{qmd-manager-Cbm03z8H.js → qmd-manager-Q0OSDQ-e.js} +5 -5
  304. package/dist/{register.agent-CMoYTJqj.js → register.agent-DFQmkIEH.js} +53 -50
  305. package/dist/{register.agent-BKINbWbs.js → register.agent-DUjwGw9d.js} +77 -73
  306. package/dist/{register.anima-BHrZ90Sv.js → register.anima-CRFHJu2J.js} +21 -21
  307. package/dist/{register.anima-CnEy5VFQ.js → register.anima-CtKNrpE8.js} +21 -21
  308. package/dist/{register.configure-Cv5NkGH2.js → register.configure-CSSN07XN.js} +50 -49
  309. package/dist/register.configure-CnEKV57N.js +107 -0
  310. package/dist/register.maintenance-CU1A-90-.js +102 -0
  311. package/dist/{register.maintenance-DtAw8E_a.js → register.maintenance-fhcCB7ih.js} +48 -47
  312. package/dist/register.message-C1a0y2ZR.js +661 -0
  313. package/dist/register.message-fM0jSKB8.js +659 -0
  314. package/dist/register.onboard-B7Gavmvt.js +128 -0
  315. package/dist/{register.onboard-U3lIfaw_.js → register.onboard-BhPlqjFi.js} +50 -49
  316. package/dist/{register.setup-CLkGhR-e.js → register.setup-0jPnMgnz.js} +96 -92
  317. package/dist/{register.setup-Dyp5L_GQ.js → register.setup-CADdQUEN.js} +72 -69
  318. package/dist/{register.status-health-sessions-Dx-qZMol.js → register.status-health-sessions-Cu5fDT-z.js} +68 -67
  319. package/dist/{register.status-health-sessions-Cc2Y5gSj.js → register.status-health-sessions-DdQsABr_.js} +40 -39
  320. package/dist/{register.subclis-L55mGheS.js → register.subclis-CZ91ufCy.js} +28 -21
  321. package/dist/{reply-BgPvB-gR.js → reply-DtHlnzOx.js} +6631 -6172
  322. package/dist/{reply-prefix-37W_P4kH.js → reply-prefix-C8dIgJur.js} +1 -1
  323. package/dist/{reply-prefix-DBRqtDEq.js → reply-prefix-DmWGtcH-.js} +1 -1
  324. package/dist/{routes-ZlpnlJFF.js → routes-CWCAc8uJ.js} +2 -2
  325. package/dist/{routes-DeDgHj5Y.js → routes-FT0Us8Md.js} +6 -6
  326. package/dist/{run-DEHnKm2x.js → run-Dfz_7j7t.js} +1256 -166
  327. package/dist/{run-BFPM6M2S.js → run-DqBQ-bGn.js} +1230 -140
  328. package/dist/{run-main-Cxmjk1SF.js → run-main-DGDW0fhx.js} +51 -50
  329. package/dist/{runtime-guard-cBL2D5J8.js → runtime-guard-D14Z_QY6.js} +1 -1
  330. package/dist/{sandbox-DDOFuJU9.js → sandbox-D-N7M7lp.js} +2 -2
  331. package/dist/{sandbox-cli-GhcxR1Va.js → sandbox-cli-CQKz2I1X.js} +9 -9
  332. package/dist/{sandbox-cli-CGJvhJ4L.js → sandbox-cli-DHNFlTo-.js} +23 -23
  333. package/dist/{sandbox-B8Nza4lP.js → sandbox-pBHlfFdB.js} +6 -6
  334. package/dist/{security-cli-B7VIDDSL.js → security-cli-Bdi7MuP6.js} +14 -22
  335. package/dist/{security-cli-gsyz4Wrw.js → security-cli-C3aI09uy.js} +27 -35
  336. package/dist/{semantic-C3Z-zhNi.js → semantic-9rgWUrz3.js} +1 -1
  337. package/dist/{semantic-CG6X3rBo.js → semantic-C1UN3bb9.js} +1 -1
  338. package/dist/{semantic-DCd6zBnV.js → semantic-CQApJNO_.js} +1 -1
  339. package/dist/{server-context-Dkz4Ce8z.js → server-context-Clykq0XU.js} +1 -1
  340. package/dist/{server-context-BlJi7pjP.js → server-context-Yx4pgBqJ.js} +7 -7
  341. package/dist/{server-node-events-DBOg36in.js → server-node-events-BR1aXVlu.js} +55 -53
  342. package/dist/{server-node-events-CmZXzWcd.js → server-node-events-Ca797E1d.js} +34 -31
  343. package/dist/{service-QlHhVsQf.js → service-Dd1DfPia.js} +1 -1
  344. package/dist/{service-audit-D4xG05j8.js → service-audit-Bwpoc2LD.js} +1 -1
  345. package/dist/{service-audit-BaoBb09i.js → service-audit-KzOtcw_V.js} +3 -3
  346. package/dist/{session-BJ9XCJBg.js → session-5YO_H-Ra.js} +1 -1
  347. package/dist/{session-3MLbl1-K.js → session-BiA6jrcs.js} +1 -1
  348. package/dist/session-C7IGnhd1.js +190 -0
  349. package/dist/{session-KNXzWBht.js → session-CSmfU0D3.js} +1 -1
  350. package/dist/{session-CqKJvPTq.js → session-DLevr8Vd.js} +5 -5
  351. package/dist/session-DfsMJNG3.js +190 -0
  352. package/dist/{session-TAOVpONo.js → session-FmXsucR7.js} +2 -2
  353. package/dist/{session-cost-usage-BamtB1rn.js → session-cost-usage-BWqR-ik6.js} +1 -1
  354. package/dist/{sessions-C2th3rm6.js → sessions-BOzeFzuL.js} +12 -22
  355. package/dist/{sessions-1XK2mH6L.js → sessions-C_3wTmSA.js} +9 -19
  356. package/dist/{sessions-BrQHxX_o.js → sessions-Dj7_4mkr.js} +4 -4
  357. package/dist/{settings-cli-CCtkuc1r.js → settings-cli-DxNeu6kx.js} +79 -77
  358. package/dist/{settings-cli-Ccizggz2.js → settings-cli-Dytfop1H.js} +50 -49
  359. package/dist/{setup-token-Dqtgnjxw.js → setup-token-B802CZwe.js} +13 -18
  360. package/dist/{setup-token-Bcer2kX8.js → setup-token-DYh2QzJ-.js} +29 -34
  361. package/dist/{shared-Hnu5dChj.js → shared-C-rqLtIT.js} +2 -2
  362. package/dist/{shell-env-KRrv3dPW.js → shell-env-CMI9f7-7.js} +1 -1
  363. package/dist/{shell-env-B4ae4lFh.js → shell-env-HkVWMh--.js} +1 -1
  364. package/dist/{shell-env-PnmcBTp4.js → shell-env-iPnSIi-t.js} +1 -1
  365. package/dist/{skills-CQoUYlGu.js → skills-4v6-kw0C.js} +3 -3
  366. package/dist/{skills-cli-DQuLxQUM.js → skills-cli-BoasNTpZ.js} +15 -15
  367. package/dist/{skills-cli-CNNy0FxN.js → skills-cli-TeAq3fRG.js} +3 -3
  368. package/dist/{skills-install-2DbC1Yo2.js → skills-install-D6_qpRjW.js} +7 -7
  369. package/dist/{skills-install-CE6djAWL.js → skills-install-Qw2oU8L8.js} +2 -2
  370. package/dist/{skills-status-ybjSmiHu.js → skills-status-CvH7AUoY.js} +4 -4
  371. package/dist/{soul-Bt57OdSx.js → soul-BiIdv3Wp.js} +125 -5
  372. package/dist/{soul-DFeEGG5h.js → soul-Bt8UNmTq.js} +126 -5
  373. package/dist/{soul-CwWWw7cs.js → soul-D9k5zulC.js} +2 -2
  374. package/dist/{soul-Bru-rRjk.js → soul-DQSYs-4l.js} +1 -1
  375. package/dist/{sqlite-BTcAhNls.js → sqlite-BMMt7osH.js} +2 -2
  376. package/dist/{sqlite-ClLAW1iQ.js → sqlite-CZ1vD4VS.js} +4 -4
  377. package/dist/{sqlite-CLZ1eR5Q.js → sqlite-CpAJt-JS.js} +1 -1
  378. package/dist/{start-DfC7PlAH.js → start-BqnPia0t.js} +66 -63
  379. package/dist/start-C3fuLzX0.js +157 -0
  380. package/dist/{status-BVAoIQ0V.js → status-CHGNPonc.js} +26 -44
  381. package/dist/{status-BU6h4wUP.js → status-CxF6k_jr.js} +2 -2
  382. package/dist/{status-C9B6cEM0.js → status-DfZJJqNs.js} +15 -15
  383. package/dist/{status-BaEcHPtc.js → status-tLgozFYL.js} +4 -4
  384. package/dist/{status.update-CbIRaeaV.js → status.update-B6Tdpk07.js} +2 -2
  385. package/dist/{status.update-CPACVnCc.js → status.update-E9dSFk_b.js} +1 -1
  386. package/dist/{subagent-registry-MZIxVf8W.js → subagent-registry-CPtElVX0.js} +807 -348
  387. package/dist/{subsystem-BMsbqSb4.js → subsystem-BAADN1B8.js} +18 -27
  388. package/dist/{subsystem-CucjNlOk.js → subsystem-D-Xta-sj.js} +17 -26
  389. package/dist/{subsystem-DA3Cno1i.js → subsystem-D1AJZPgG.js} +38 -47
  390. package/dist/{system-cli-BKicxULp.js → system-cli-CP7JrhR0.js} +15 -15
  391. package/dist/{system-cli-Unb-WFAR.js → system-cli-DoLzi2Sn.js} +8 -8
  392. package/dist/{systemd-5KGZ3NHE.js → systemd-Bx76sJ3M.js} +2 -2
  393. package/dist/{systemd-linger-B-uyzDap.js → systemd-linger-BVwGXVS0.js} +2 -2
  394. package/dist/{systemd-linger-CS_pA1-a.js → systemd-linger-CxGmIy_5.js} +1 -1
  395. package/dist/{table-CdHBo5d1.js → table-Blmz7glr.js} +2 -2
  396. package/dist/{tokens-DGhK0fpG.js → tokens-SP2Q7i59.js} +1 -1
  397. package/dist/{tool-images-DK97edts.js → tool-images-2qproko3.js} +2 -2
  398. package/dist/{tool-images-Dq55i0mz.js → tool-images-C6cKHTbj.js} +2 -2
  399. package/dist/{tool-images-J0rGmoDV.js → tool-images-CgDT0Xzv.js} +2 -2
  400. package/dist/{tui-Bm8FEW0b.js → tui-C2eLfbhA.js} +5 -5
  401. package/dist/{tui-cli-BGjsxGle.js → tui-cli-BgcbCtgc.js} +12 -12
  402. package/dist/{tui-cli-TwCYv-a7.js → tui-cli-cLSYBQu9.js} +27 -27
  403. package/dist/{tui-DtGKiHUr.js → tui-r4qpJhNk.js} +10 -10
  404. package/dist/{update-Dfi92PZJ.js → update-CqKpX3cX.js} +3 -3
  405. package/dist/{update-Dle5MRUz.js → update-DA91za97.js} +1 -1
  406. package/dist/{update-cli-QMVW2eiR.js → update-cli-BuCw75tM.js} +87 -85
  407. package/dist/{update-cli-D1e-DsWy.js → update-cli-C-er5av6.js} +55 -54
  408. package/dist/{update-runner-DPmSGXS3.js → update-runner-czCqHZCu.js} +5 -5
  409. package/dist/{update-runner-iLJQF6VA.js → update-runner-kE8AMQt4.js} +1 -1
  410. package/dist/{utils-B60lF9Wq.js → utils-CLYlhJuc.js} +1 -1
  411. package/dist/{web-DJRRkHG8.js → web-BHGK5GtV.js} +24 -24
  412. package/dist/web-CyYunanU.js +65 -0
  413. package/dist/{web-DDAkSrtZ.js → web-DvTXV-fo.js} +35 -34
  414. package/dist/{web-DBQRQY6n.js → web-so3pGceM.js} +27 -27
  415. package/dist/{webhooks-cli-Cg0F2mU6.js → webhooks-cli-k3QMf7Rs.js} +4 -4
  416. package/dist/{webhooks-cli-BsWx7MgH.js → webhooks-cli-vlEfXEKm.js} +12 -12
  417. package/dist/{whatsapp-actions-gpz6-vPI.js → whatsapp-actions-6fPRKwPV.js} +11 -11
  418. package/dist/{whatsapp-actions-DJpQVKnT.js → whatsapp-actions-BJn-z76S.js} +17 -17
  419. package/dist/{whatsapp-actions-tWRWRZ4X.js → whatsapp-actions-C0tlEdLy.js} +5 -5
  420. package/dist/{whatsapp-actions-CMEP8v3k.js → whatsapp-actions-Hr-W8vjY.js} +13 -13
  421. package/dist/{widearea-dns-BDtWuGCY.js → widearea-dns-CHAT20aR.js} +1 -1
  422. package/dist/{workspace-BQkffCaR.js → workspace-BFIZCnGo.js} +5 -5
  423. package/dist/{ws-log-Bc4grA6W.js → ws-log-CUobU2tD.js} +1 -1
  424. package/package.json +1 -1
  425. package/templates/profiles/nox.profile.json5 +5 -5
  426. package/dist/cli--Gal7v4I.js +0 -101
  427. package/dist/config-cli-cyvL43DG.js +0 -15
  428. package/dist/control-ui/assets/index-B7CJLRZD.css +0 -1
  429. package/dist/control-ui/assets/index-DLPYIcs0.js +0 -58
  430. package/dist/control-ui/assets/index-DLPYIcs0.js.map +0 -1
  431. package/dist/deps-CeyVMZf1.js +0 -13
  432. package/dist/models-ByeH7ZKb.js +0 -1350
  433. package/dist/register.configure-3GfqcGLK.js +0 -105
  434. package/dist/register.maintenance-YZDsMymb.js +0 -100
  435. package/dist/register.onboard-Dswys-iV.js +0 -126
  436. package/dist/start-BPye9w5U.js +0 -154
  437. package/dist/web-DE-hmqXy.js +0 -64
  438. /package/dist/{BasicParser-BiEpjka-.js → BasicParser-D4BHCxVb.js} +0 -0
  439. /package/dist/{agents.config-DibGEnBs.js → agents.config-Br4ULmK0.js} +0 -0
  440. /package/dist/{archive-BIKRyvqD.js → archive-CNqghdwQ.js} +0 -0
  441. /package/dist/{archive-5e-Ytlq-.js → archive-D-dHRz-v.js} +0 -0
  442. /package/dist/{argv-B6vsXQtF.js → argv-nNQ109_K.js} +0 -0
  443. /package/dist/{auth-store-Vfd6oc1G.js → auth-store-BEfSfCbW.js} +0 -0
  444. /package/dist/{auto-update-BUbllW1X.js → auto-update-Cvd8YJrT.js} +0 -0
  445. /package/dist/{auto-update-DdH8fo63.js → auto-update-DO4nHkfM.js} +0 -0
  446. /package/dist/{brew-Bkf_MwX9.js → brew-DHWnVWm3.js} +0 -0
  447. /package/dist/{budget-CV0a771W.js → budget-DvjICb0t.js} +0 -0
  448. /package/dist/{budget-GiXjG9eW.js → budget-e0R5xsU3.js} +0 -0
  449. /package/dist/{command-options-DfPEZwUK.js → command-options-DtJ8-EC7.js} +0 -0
  450. /package/dist/{command-options-mgpP-XId.js → command-options-eC-m_qJx.js} +0 -0
  451. /package/dist/{delivery-queue-DGnDKL02.js → delivery-queue-BKQk1j0k.js} +0 -0
  452. /package/dist/{delivery-queue-DZ_ibFDu.js → delivery-queue-CExaJXRz.js} +0 -0
  453. /package/dist/{display-BwSYYxVE.js → display-4p3-O9mP.js} +0 -0
  454. /package/dist/{display-Dck2kudh.js → display-Bo8pBhMp.js} +0 -0
  455. /package/dist/{exec-approvals-BJikgQkX.js → exec-approvals-DK5-KCUz.js} +0 -0
  456. /package/dist/{format-wiLVr0D3.js → format-9DMvWYUJ.js} +0 -0
  457. /package/dist/{format-duration-C5oKCGwB.js → format-duration-CnGkTPRF.js} +0 -0
  458. /package/dist/{gmail-setup-utils-CR33Gqfc.js → gmail-setup-utils-BIXtKTpT.js} +0 -0
  459. /package/dist/{help-format-DJx5Rwy2.js → help-format-ZKxl6UCb.js} +0 -0
  460. /package/dist/{helpers-8O7IVGO-.js → helpers-CWQnEONe.js} +0 -0
  461. /package/dist/{hooks-status-DiqubDlK.js → hooks-status-DqfJDvYl.js} +0 -0
  462. /package/dist/{ipv4-BYbwrpG-.js → ipv4-CExV55ho.js} +0 -0
  463. /package/dist/{is-main-BnikY3ud.js → is-main-H-hpHkdq.js} +0 -0
  464. /package/dist/{lib-D1DXSMt_.js → lib-D0_kW-B6.js} +0 -0
  465. /package/dist/{links-3c7gzW-G.js → links-BjjDMNIq.js} +0 -0
  466. /package/dist/{logging-Bpf6Cepz.js → logging-DWwOqnTW.js} +0 -0
  467. /package/dist/{logging-DcXIbpwk.js → logging-_rCcBkls.js} +0 -0
  468. /package/dist/{model-param-b-BcBBSgiD.js → model-param-b-2KmFir_0.js} +0 -0
  469. /package/dist/{node-service-BDlDNv3t.js → node-service-cOoW5hLa.js} +0 -0
  470. /package/dist/{note-BaOKDvcy.js → note-CeLGcHqv.js} +0 -0
  471. /package/dist/{noxsoft-auth-Bmict45b.js → noxsoft-auth-CE75mBXE.js} +0 -0
  472. /package/dist/{noxsoft-auth-DpwLJIW0.js → noxsoft-auth-CgCk5707.js} +0 -0
  473. /package/dist/{pi-model-discovery-ClWISQ3j.js → pi-model-discovery-Bu4Zr7nI.js} +0 -0
  474. /package/dist/{ports-aNJUI3Mi.js → ports-BGLuwt2Z.js} +0 -0
  475. /package/dist/{progress-Dj2aBWOI.js → progress-glCgu57m.js} +0 -0
  476. /package/dist/{qmd-manager-DrDX4o7e.js → qmd-manager-CO795NK4.js} +0 -0
  477. /package/dist/{queue-B77yV52t.js → queue-DDq0uzy5.js} +0 -0
  478. /package/dist/{queue-wFYwitx0.js → queue-DtQ5sbyD.js} +0 -0
  479. /package/dist/{registry-gaRST__4.js → registry-BvymIcVf.js} +0 -0
  480. /package/dist/{registry-Cv8RtADU.js → registry-DwaHkd_j.js} +0 -0
  481. /package/dist/{requirements-CEowKaVY.js → requirements-Ct4XnMiK.js} +0 -0
  482. /package/dist/{skill-scanner-DGoUYV22.js → skill-scanner-5_Y3u6SU.js} +0 -0
  483. /package/dist/{skill-scanner-FO7SyxAD.js → skill-scanner-Dld2ijVw.js} +0 -0
  484. /package/dist/{templates-D-h5PNIK.js → templates-4_And8I_.js} +0 -0
  485. /package/dist/{templates-ndPXOyGA.js → templates-5Z-UIDze.js} +0 -0
  486. /package/dist/{types-DSS9sywz.js → types-BQk_oAin.js} +0 -0
  487. /package/dist/{usage-format-BtlQ-77V.js → usage-format-BSa7cHyK.js} +0 -0
  488. /package/dist/{ws-log-BA9w1cJs.js → ws-log-CG6cvCZW.js} +0 -0
@@ -0,0 +1,2946 @@
1
+ import { t as CONFIG_PATH } from "./paths-zhVksOvm.js";
2
+ import { B as isRich$1, V as theme, d as defaultRuntime, t as createSubsystemLogger, z as colorize } from "./subsystem-BAADN1B8.js";
3
+ import { C as shortenHomePath } from "./utils-CLYlhJuc.js";
4
+ import "./pi-embedded-helpers-BZ9GspxK.js";
5
+ import { Dt as formatUsageWindowSummary, L as runNoxSoftEmbeddedAgent, Ot as resolveUsageProviderId, St as loadProviderUsageSummary, dr as loadModelCatalog, fr as ensureAnimaModelsJson, hr as describeFailoverError, sn as loadAnimaPlugins } from "./reply-DtHlnzOx.js";
6
+ import { d as resolveAgentIdFromSessionKey } from "./session-key-DAZmp8ll.js";
7
+ import "./exec-BylR5qWS.js";
8
+ import { a as resolveAgentModelPrimary, c as resolveDefaultAgentId, i as resolveAgentModelFallbacksOverride, r as resolveAgentDir, s as resolveAgentWorkspaceDir, w as resolveDefaultAgentWorkspaceDir } from "./agent-scope-CXxC8FFX.js";
9
+ import { _ as DEFAULT_MODEL, c as normalizeProviderId, d as resolveConfiguredModelRef, f as resolveDefaultModelForAgent, g as DEFAULT_CONTEXT_TOKENS, l as parseModelRef, m as resolveModelRefFromString, o as modelKey, r as buildModelAliasIndex, v as DEFAULT_PROVIDER } from "./model-selection-CY6r_3wt.js";
10
+ import { i as loadConfig, m as parseDurationMs, o as readConfigFileSnapshot } from "./config-DaD4FsAn.js";
11
+ import "./boolean-B8-BqKGQ.js";
12
+ import "./env-DlTia1B4.js";
13
+ import { o as shouldEnableShellEnvFallback, t as getShellEnvAppliedKeys } from "./shell-env-iPnSIi-t.js";
14
+ import "./manifest-registry-qF960vMH.js";
15
+ import "./sessions-BOzeFzuL.js";
16
+ import "./image-ops-Ct3GueyT.js";
17
+ import "./polls-DFISjV7H.js";
18
+ import "./sandbox-pBHlfFdB.js";
19
+ import "./chrome-BaU-H9m7.js";
20
+ import { t as formatCliCommand } from "./command-format-BCtkuvqF.js";
21
+ import "./auth-DsC5pZ_0.js";
22
+ import "./server-context-Yx4pgBqJ.js";
23
+ import "./skills-4v6-kw0C.js";
24
+ import "./routes-FT0Us8Md.js";
25
+ import "./ports-q535r1PZ.js";
26
+ import "./message-channel-CMsexA3K.js";
27
+ import "./plugins-DYcg0qBW.js";
28
+ import { i as resolveSessionTranscriptPath, s as resolveSessionTranscriptsDirForAgent } from "./paths-Dazi-gYo.js";
29
+ import "./tool-images-CgDT0Xzv.js";
30
+ import { d as setAuthProfileOrder, f as upsertAuthProfile, l as listProfilesForProvider, n as resolveAuthProfileOrder, o as resolveProfileUnusableUntilForDisplay, p as ensureAuthProfileStore, v as resolveAuthStorePathForDisplay, w as resolveAuthProfileDisplayLabel, y as resolveAnimaAgentDir } from "./auth-profiles-C-LuhW6c.js";
31
+ import "./file-lock-Z53aFHvY.js";
32
+ import { a as resolveAwsSdkEnvVarName, i as resolveApiKeyForProvider, n as getCustomProviderApiKey, o as resolveEnvApiKey } from "./model-auth-CHB3EySM.js";
33
+ import "./tokens-SP2Q7i59.js";
34
+ import { Q as resolveModel } from "./anthropic-direct-runner-BeYCnvZ8.js";
35
+ import "./deliver-BKzX3YoN.js";
36
+ import "./memory-cli-DLtBA6r5.js";
37
+ import "./manager-D8VCuzru.js";
38
+ import "./sqlite-CpAJt-JS.js";
39
+ import "./redact-SnxRsHjf.js";
40
+ import "./session-CSmfU0D3.js";
41
+ import "./semantic-9rgWUrz3.js";
42
+ import "./loader-Bw2wdN4l.js";
43
+ import "./soul-D9k5zulC.js";
44
+ import "./common-BCW6hLGI.js";
45
+ import "./chunk-CFSle8n5.js";
46
+ import "./parse-timeout-C4WLf3Qy.js";
47
+ import "./client-BWkoTfOH.js";
48
+ import "./call-CDPbPDAr.js";
49
+ import { t as formatDocsLink } from "./links-DcilUrqq.js";
50
+ import { n as runCommandWithRuntime, t as resolveOptionFromCommand } from "./cli-utils-DcDBK4C5.js";
51
+ import { r as withProgressTotals } from "./progress-CVLvQV_t.js";
52
+ import "./pi-tools.policy-WdTAfqbV.js";
53
+ import "./logging-BstmzK9-.js";
54
+ import "./auth-store-Jvgz2_l1.js";
55
+ import "./control-service-5YtMvm7D.js";
56
+ import "./dispatcher-DzwzLQRk.js";
57
+ import { n as discoverModels, t as discoverAuthStorage } from "./pi-model-discovery-Bu4Zr7nI.js";
58
+ import "./noxsoft-auth-CE75mBXE.js";
59
+ import "./delivery-queue-CExaJXRz.js";
60
+ import "./session-cost-usage-BWqR-ik6.js";
61
+ import { d as openUrl } from "./onboard-helpers-CJ3HzoUO.js";
62
+ import { n as isWSLEnv } from "./wsl-jdLWdiKy.js";
63
+ import { n as stylePromptMessage, r as stylePromptTitle, t as stylePromptHint } from "./prompt-style-BI53UVgE.js";
64
+ import { t as renderTable } from "./table-Blmz7glr.js";
65
+ import { a as isLocalBaseUrl, c as resolveModelTarget, i as formatTokenK, l as updateConfig, n as ensureFlagCompatibility, o as normalizeAlias, r as formatMs, s as resolveKnownAgentId, u as applyAuthProfileConfig } from "./prompts-Bq4QGFQM.js";
66
+ import { n as logConfigUpdated } from "./logging-Chc1Sj6N.js";
67
+ import "./note-iMYVGjpA.js";
68
+ import { r as resolveAgentModelSelection, t as resolveSession } from "./session-DfsMJNG3.js";
69
+ import { t as inferParamBFromIdOrName } from "./model-param-b-C1QDqzQp.js";
70
+ import { n as redactSecrets } from "./format-9DMvWYUJ.js";
71
+ import { t as createClackPrompter } from "./clack-prompter-fZSmnHda.js";
72
+ import { n as buildAuthHealthSummary, r as formatRemainingShort, t as DEFAULT_OAUTH_WARN_MS } from "./auth-health-Cc8-vy8y.js";
73
+ import path from "node:path";
74
+ import fs from "node:fs/promises";
75
+ import crypto from "node:crypto";
76
+ import { complete, getEnvApiKey, getModel } from "@mariozechner/pi-ai";
77
+ import { Type } from "@sinclair/typebox";
78
+ import { cancel, confirm, isCancel, multiselect, select, text } from "@clack/prompts";
79
+
80
+ //#region src/commands/models/aliases.ts
81
+ async function modelsAliasesListCommand(opts, runtime) {
82
+ ensureFlagCompatibility(opts);
83
+ const models = loadConfig().agents?.defaults?.models ?? {};
84
+ const aliases = Object.entries(models).reduce((acc, [modelKey, entry]) => {
85
+ const alias = entry?.alias?.trim();
86
+ if (alias) acc[alias] = modelKey;
87
+ return acc;
88
+ }, {});
89
+ if (opts.json) {
90
+ runtime.log(JSON.stringify({ aliases }, null, 2));
91
+ return;
92
+ }
93
+ if (opts.plain) {
94
+ for (const [alias, target] of Object.entries(aliases)) runtime.log(`${alias} ${target}`);
95
+ return;
96
+ }
97
+ runtime.log(`Aliases (${Object.keys(aliases).length}):`);
98
+ if (Object.keys(aliases).length === 0) {
99
+ runtime.log("- none");
100
+ return;
101
+ }
102
+ for (const [alias, target] of Object.entries(aliases)) runtime.log(`- ${alias} -> ${target}`);
103
+ }
104
+ async function modelsAliasesAddCommand(aliasRaw, modelRaw, runtime) {
105
+ const alias = normalizeAlias(aliasRaw);
106
+ const resolved = resolveModelTarget({
107
+ raw: modelRaw,
108
+ cfg: loadConfig()
109
+ });
110
+ await updateConfig((cfg) => {
111
+ const modelKey = `${resolved.provider}/${resolved.model}`;
112
+ const nextModels = { ...cfg.agents?.defaults?.models };
113
+ for (const [key, entry] of Object.entries(nextModels)) {
114
+ const existing = entry?.alias?.trim();
115
+ if (existing && existing === alias && key !== modelKey) throw new Error(`Alias ${alias} already points to ${key}.`);
116
+ }
117
+ nextModels[modelKey] = {
118
+ ...nextModels[modelKey] ?? {},
119
+ alias
120
+ };
121
+ return {
122
+ ...cfg,
123
+ agents: {
124
+ ...cfg.agents,
125
+ defaults: {
126
+ ...cfg.agents?.defaults,
127
+ models: nextModels
128
+ }
129
+ }
130
+ };
131
+ });
132
+ logConfigUpdated(runtime);
133
+ runtime.log(`Alias ${alias} -> ${resolved.provider}/${resolved.model}`);
134
+ }
135
+ async function modelsAliasesRemoveCommand(aliasRaw, runtime) {
136
+ const alias = normalizeAlias(aliasRaw);
137
+ const updated = await updateConfig((cfg) => {
138
+ const nextModels = { ...cfg.agents?.defaults?.models };
139
+ let found = false;
140
+ for (const [key, entry] of Object.entries(nextModels)) if (entry?.alias?.trim() === alias) {
141
+ nextModels[key] = {
142
+ ...entry,
143
+ alias: void 0
144
+ };
145
+ found = true;
146
+ break;
147
+ }
148
+ if (!found) throw new Error(`Alias not found: ${alias}`);
149
+ return {
150
+ ...cfg,
151
+ agents: {
152
+ ...cfg.agents,
153
+ defaults: {
154
+ ...cfg.agents?.defaults,
155
+ models: nextModels
156
+ }
157
+ }
158
+ };
159
+ });
160
+ logConfigUpdated(runtime);
161
+ if (!updated.agents?.defaults?.models || Object.values(updated.agents.defaults.models).every((entry) => !entry?.alias?.trim())) runtime.log("No aliases configured.");
162
+ }
163
+
164
+ //#endregion
165
+ //#region src/plugins/providers.ts
166
+ const log = createSubsystemLogger("plugins");
167
+ function resolvePluginProviders(params) {
168
+ return loadAnimaPlugins({
169
+ config: params.config,
170
+ workspaceDir: params.workspaceDir,
171
+ logger: {
172
+ info: (msg) => log.info(msg),
173
+ warn: (msg) => log.warn(msg),
174
+ error: (msg) => log.error(msg),
175
+ debug: (msg) => log.debug(msg)
176
+ }
177
+ }).providers.map((entry) => entry.provider);
178
+ }
179
+
180
+ //#endregion
181
+ //#region src/commands/auth-token.ts
182
+ const ANTHROPIC_SETUP_TOKEN_PREFIX = "sk-ant-oat01-";
183
+ const ANTHROPIC_SETUP_TOKEN_MIN_LENGTH = 80;
184
+ function validateAnthropicSetupToken(raw) {
185
+ const trimmed = raw.trim();
186
+ if (!trimmed) return "Required";
187
+ if (!trimmed.startsWith(ANTHROPIC_SETUP_TOKEN_PREFIX)) return `Expected token starting with ${ANTHROPIC_SETUP_TOKEN_PREFIX}`;
188
+ if (trimmed.length < ANTHROPIC_SETUP_TOKEN_MIN_LENGTH) return "Token looks too short; paste the full setup-token";
189
+ }
190
+
191
+ //#endregion
192
+ //#region src/commands/oauth-env.ts
193
+ function isRemoteEnvironment() {
194
+ if (process.env.SSH_CLIENT || process.env.SSH_TTY || process.env.SSH_CONNECTION) return true;
195
+ if (process.env.REMOTE_CONTAINERS || process.env.CODESPACES) return true;
196
+ if (process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY && !isWSLEnv()) return true;
197
+ return false;
198
+ }
199
+
200
+ //#endregion
201
+ //#region src/commands/oauth-flow.ts
202
+ const validateRequiredInput = (value) => value.trim().length > 0 ? void 0 : "Required";
203
+ function createVpsAwareOAuthHandlers(params) {
204
+ const manualPromptMessage = params.manualPromptMessage ?? "Paste the redirect URL";
205
+ let manualCodePromise;
206
+ return {
207
+ onAuth: async ({ url }) => {
208
+ if (params.isRemote) {
209
+ params.spin.stop("OAuth URL ready");
210
+ params.runtime.log(`\nOpen this URL in your LOCAL browser:\n\n${url}\n`);
211
+ manualCodePromise = params.prompter.text({
212
+ message: manualPromptMessage,
213
+ validate: validateRequiredInput
214
+ }).then((value) => String(value));
215
+ return;
216
+ }
217
+ params.spin.update(params.localBrowserMessage);
218
+ await params.openUrl(url);
219
+ params.runtime.log(`Open: ${url}`);
220
+ },
221
+ onPrompt: async (prompt) => {
222
+ if (manualCodePromise) return manualCodePromise;
223
+ const code = await params.prompter.text({
224
+ message: prompt.message,
225
+ placeholder: prompt.placeholder,
226
+ validate: validateRequiredInput
227
+ });
228
+ return String(code);
229
+ }
230
+ };
231
+ }
232
+
233
+ //#endregion
234
+ //#region src/commands/provider-auth-helpers.ts
235
+ function resolveProviderMatch(providers, rawProvider) {
236
+ const raw = rawProvider?.trim();
237
+ if (!raw) return null;
238
+ const normalized = normalizeProviderId(raw);
239
+ return providers.find((provider) => normalizeProviderId(provider.id) === normalized) ?? providers.find((provider) => provider.aliases?.some((alias) => normalizeProviderId(alias) === normalized) ?? false) ?? null;
240
+ }
241
+ function pickAuthMethod(provider, rawMethod) {
242
+ const raw = rawMethod?.trim();
243
+ if (!raw) return null;
244
+ const normalized = raw.toLowerCase();
245
+ return provider.auth.find((method) => method.id.toLowerCase() === normalized) ?? provider.auth.find((method) => method.label.toLowerCase() === normalized) ?? null;
246
+ }
247
+ function isPlainRecord(value) {
248
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
249
+ }
250
+ function mergeConfigPatch(base, patch) {
251
+ if (!isPlainRecord(base) || !isPlainRecord(patch)) return patch;
252
+ const next = { ...base };
253
+ for (const [key, value] of Object.entries(patch)) {
254
+ const existing = next[key];
255
+ if (isPlainRecord(existing) && isPlainRecord(value)) next[key] = mergeConfigPatch(existing, value);
256
+ else next[key] = value;
257
+ }
258
+ return next;
259
+ }
260
+ function applyDefaultModel(cfg, model) {
261
+ const models = { ...cfg.agents?.defaults?.models };
262
+ models[model] = models[model] ?? {};
263
+ const existingModel = cfg.agents?.defaults?.model;
264
+ return {
265
+ ...cfg,
266
+ agents: {
267
+ ...cfg.agents,
268
+ defaults: {
269
+ ...cfg.agents?.defaults,
270
+ models,
271
+ model: {
272
+ ...existingModel && typeof existingModel === "object" && "fallbacks" in existingModel ? { fallbacks: existingModel.fallbacks } : void 0,
273
+ primary: model
274
+ }
275
+ }
276
+ }
277
+ };
278
+ }
279
+
280
+ //#endregion
281
+ //#region src/commands/models/auth.ts
282
+ const confirm$1 = (params) => confirm({
283
+ ...params,
284
+ message: stylePromptMessage(params.message)
285
+ });
286
+ const text$1 = (params) => text({
287
+ ...params,
288
+ message: stylePromptMessage(params.message)
289
+ });
290
+ const select$1 = (params) => select({
291
+ ...params,
292
+ message: stylePromptMessage(params.message),
293
+ options: params.options.map((opt) => opt.hint === void 0 ? opt : {
294
+ ...opt,
295
+ hint: stylePromptHint(opt.hint)
296
+ })
297
+ });
298
+ function resolveTokenProvider(raw) {
299
+ const trimmed = raw?.trim();
300
+ if (!trimmed) return null;
301
+ if (normalizeProviderId(trimmed) === "anthropic") return "anthropic";
302
+ return "custom";
303
+ }
304
+ function resolveDefaultTokenProfileId(provider) {
305
+ return `${normalizeProviderId(provider)}:manual`;
306
+ }
307
+ async function modelsAuthSetupTokenCommand(opts, runtime) {
308
+ const provider = resolveTokenProvider(opts.provider ?? "anthropic");
309
+ if (provider !== "anthropic") throw new Error("Only --provider anthropic is supported for setup-token.");
310
+ if (!process.stdin.isTTY) throw new Error("setup-token requires an interactive TTY.");
311
+ if (!opts.yes) {
312
+ if (!await confirm$1({
313
+ message: "Have you run `claude setup-token` and copied the token?",
314
+ initialValue: true
315
+ })) return;
316
+ }
317
+ const tokenInput = await text$1({
318
+ message: "Paste Anthropic setup-token",
319
+ validate: (value) => validateAnthropicSetupToken(String(value ?? ""))
320
+ });
321
+ const token = String(tokenInput ?? "").trim();
322
+ const profileId = resolveDefaultTokenProfileId(provider);
323
+ upsertAuthProfile({
324
+ profileId,
325
+ credential: {
326
+ type: "token",
327
+ provider,
328
+ token
329
+ }
330
+ });
331
+ await updateConfig((cfg) => applyAuthProfileConfig(cfg, {
332
+ profileId,
333
+ provider,
334
+ mode: "token"
335
+ }));
336
+ logConfigUpdated(runtime);
337
+ runtime.log(`Auth profile: ${profileId} (${provider}/token)`);
338
+ }
339
+ async function modelsAuthPasteTokenCommand(opts, runtime) {
340
+ const rawProvider = opts.provider?.trim();
341
+ if (!rawProvider) throw new Error("Missing --provider.");
342
+ const provider = normalizeProviderId(rawProvider);
343
+ const profileId = opts.profileId?.trim() || resolveDefaultTokenProfileId(provider);
344
+ const tokenInput = await text$1({
345
+ message: `Paste token for ${provider}`,
346
+ validate: (value) => value?.trim() ? void 0 : "Required"
347
+ });
348
+ const token = String(tokenInput ?? "").trim();
349
+ const expires = opts.expiresIn?.trim() && opts.expiresIn.trim().length > 0 ? Date.now() + parseDurationMs(String(opts.expiresIn ?? "").trim(), { defaultUnit: "d" }) : void 0;
350
+ upsertAuthProfile({
351
+ profileId,
352
+ credential: {
353
+ type: "token",
354
+ provider,
355
+ token,
356
+ ...expires ? { expires } : {}
357
+ }
358
+ });
359
+ await updateConfig((cfg) => applyAuthProfileConfig(cfg, {
360
+ profileId,
361
+ provider,
362
+ mode: "token"
363
+ }));
364
+ logConfigUpdated(runtime);
365
+ runtime.log(`Auth profile: ${profileId} (${provider}/token)`);
366
+ }
367
+ async function modelsAuthAddCommand(_opts, runtime) {
368
+ const provider = await select$1({
369
+ message: "Token provider",
370
+ options: [{
371
+ value: "anthropic",
372
+ label: "anthropic"
373
+ }, {
374
+ value: "custom",
375
+ label: "custom (type provider id)"
376
+ }]
377
+ });
378
+ const providerId = provider === "custom" ? normalizeProviderId(String(await text$1({
379
+ message: "Provider id",
380
+ validate: (value) => value?.trim() ? void 0 : "Required"
381
+ }))) : provider;
382
+ if (await select$1({
383
+ message: "Token method",
384
+ options: [...providerId === "anthropic" ? [{
385
+ value: "setup-token",
386
+ label: "setup-token (claude)",
387
+ hint: "Paste a setup-token from `claude setup-token`"
388
+ }] : [], {
389
+ value: "paste",
390
+ label: "paste token"
391
+ }]
392
+ }) === "setup-token") {
393
+ await modelsAuthSetupTokenCommand({ provider: providerId }, runtime);
394
+ return;
395
+ }
396
+ const profileIdDefault = resolveDefaultTokenProfileId(providerId);
397
+ await modelsAuthPasteTokenCommand({
398
+ provider: providerId,
399
+ profileId: String(await text$1({
400
+ message: "Profile id",
401
+ initialValue: profileIdDefault,
402
+ validate: (value) => value?.trim() ? void 0 : "Required"
403
+ })).trim(),
404
+ expiresIn: await confirm$1({
405
+ message: "Does this token expire?",
406
+ initialValue: false
407
+ }) ? String(await text$1({
408
+ message: "Expires in (duration)",
409
+ initialValue: "365d",
410
+ validate: (value) => {
411
+ try {
412
+ parseDurationMs(String(value ?? ""), { defaultUnit: "d" });
413
+ return;
414
+ } catch {
415
+ return "Invalid duration (e.g. 365d, 12h, 30m)";
416
+ }
417
+ }
418
+ })).trim() : void 0
419
+ }, runtime);
420
+ }
421
+ function resolveRequestedLoginProviderOrThrow(providers, rawProvider) {
422
+ const requested = rawProvider?.trim();
423
+ if (!requested) return null;
424
+ const matched = resolveProviderMatch(providers, requested);
425
+ if (matched) return matched;
426
+ const available = providers.map((provider) => provider.id).filter(Boolean).toSorted((a, b) => a.localeCompare(b));
427
+ const availableText = available.length > 0 ? available.join(", ") : "(none)";
428
+ throw new Error(`Unknown provider "${requested}". Loaded providers: ${availableText}. Verify plugins via \`${formatCliCommand("anima plugins list --json")}\`.`);
429
+ }
430
+ function credentialMode(credential) {
431
+ if (credential.type === "api_key") return "api_key";
432
+ if (credential.type === "token") return "token";
433
+ return "oauth";
434
+ }
435
+ async function modelsAuthLoginCommand(opts, runtime) {
436
+ if (!process.stdin.isTTY) throw new Error("models auth login requires an interactive TTY.");
437
+ const snapshot = await readConfigFileSnapshot();
438
+ if (!snapshot.valid) {
439
+ const issues = snapshot.issues.map((issue) => `- ${issue.path}: ${issue.message}`).join("\n");
440
+ throw new Error(`Invalid config at ${snapshot.path}\n${issues}`);
441
+ }
442
+ const config = snapshot.config;
443
+ const defaultAgentId = resolveDefaultAgentId(config);
444
+ const agentDir = resolveAgentDir(config, defaultAgentId);
445
+ const workspaceDir = resolveAgentWorkspaceDir(config, defaultAgentId) ?? resolveDefaultAgentWorkspaceDir();
446
+ const providers = resolvePluginProviders({
447
+ config,
448
+ workspaceDir
449
+ });
450
+ if (providers.length === 0) throw new Error(`No provider plugins found. Install one via \`${formatCliCommand("anima plugins install")}\`.`);
451
+ const prompter = createClackPrompter();
452
+ const selectedProvider = resolveRequestedLoginProviderOrThrow(providers, opts.provider) ?? await prompter.select({
453
+ message: "Select a provider",
454
+ options: providers.map((provider) => ({
455
+ value: provider.id,
456
+ label: provider.label,
457
+ hint: provider.docsPath ? `Docs: ${provider.docsPath}` : void 0
458
+ }))
459
+ }).then((id) => resolveProviderMatch(providers, String(id)));
460
+ if (!selectedProvider) throw new Error("Unknown provider. Use --provider <id> to pick a provider plugin.");
461
+ const chosenMethod = pickAuthMethod(selectedProvider, opts.method) ?? (selectedProvider.auth.length === 1 ? selectedProvider.auth[0] : await prompter.select({
462
+ message: `Auth method for ${selectedProvider.label}`,
463
+ options: selectedProvider.auth.map((method) => ({
464
+ value: method.id,
465
+ label: method.label,
466
+ hint: method.hint
467
+ }))
468
+ }).then((id) => selectedProvider.auth.find((method) => method.id === String(id))));
469
+ if (!chosenMethod) throw new Error("Unknown auth method. Use --method <id> to select one.");
470
+ const isRemote = isRemoteEnvironment();
471
+ const result = await chosenMethod.run({
472
+ config,
473
+ agentDir,
474
+ workspaceDir,
475
+ prompter,
476
+ runtime,
477
+ isRemote,
478
+ openUrl: async (url) => {
479
+ await openUrl(url);
480
+ },
481
+ oauth: { createVpsAwareHandlers: (params) => createVpsAwareOAuthHandlers(params) }
482
+ });
483
+ for (const profile of result.profiles) upsertAuthProfile({
484
+ profileId: profile.profileId,
485
+ credential: profile.credential,
486
+ agentDir
487
+ });
488
+ await updateConfig((cfg) => {
489
+ let next = cfg;
490
+ if (result.configPatch) next = mergeConfigPatch(next, result.configPatch);
491
+ for (const profile of result.profiles) next = applyAuthProfileConfig(next, {
492
+ profileId: profile.profileId,
493
+ provider: profile.credential.provider,
494
+ mode: credentialMode(profile.credential)
495
+ });
496
+ if (opts.setDefault && result.defaultModel) next = applyDefaultModel(next, result.defaultModel);
497
+ return next;
498
+ });
499
+ logConfigUpdated(runtime);
500
+ for (const profile of result.profiles) runtime.log(`Auth profile: ${profile.profileId} (${profile.credential.provider}/${credentialMode(profile.credential)})`);
501
+ if (result.defaultModel) runtime.log(opts.setDefault ? `Default model set to ${result.defaultModel}` : `Default model available: ${result.defaultModel} (use --set-default to apply)`);
502
+ if (result.notes && result.notes.length > 0) await prompter.note(result.notes.join("\n"), "Provider notes");
503
+ }
504
+ async function githubCopilotLoginCommand(_opts, runtime) {
505
+ await modelsAuthLoginCommand({ provider: "github-copilot" }, runtime);
506
+ }
507
+
508
+ //#endregion
509
+ //#region src/commands/models/auth-order.ts
510
+ function resolveTargetAgent(cfg, raw) {
511
+ const agentId = resolveKnownAgentId({
512
+ cfg,
513
+ rawAgentId: raw
514
+ }) ?? resolveDefaultAgentId(cfg);
515
+ return {
516
+ agentId,
517
+ agentDir: resolveAgentDir(cfg, agentId)
518
+ };
519
+ }
520
+ function describeOrder(store, provider) {
521
+ const providerKey = normalizeProviderId(provider);
522
+ const order = store.order?.[providerKey];
523
+ return Array.isArray(order) ? order : [];
524
+ }
525
+ async function modelsAuthOrderGetCommand(opts, runtime) {
526
+ const rawProvider = opts.provider?.trim();
527
+ if (!rawProvider) throw new Error("Missing --provider.");
528
+ const provider = normalizeProviderId(rawProvider);
529
+ const { agentId, agentDir } = resolveTargetAgent(loadConfig(), opts.agent);
530
+ const order = describeOrder(ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false }), provider);
531
+ if (opts.json) {
532
+ runtime.log(JSON.stringify({
533
+ agentId,
534
+ agentDir,
535
+ provider,
536
+ authStorePath: shortenHomePath(`${agentDir}/auth-profiles.json`),
537
+ order: order.length > 0 ? order : null
538
+ }, null, 2));
539
+ return;
540
+ }
541
+ runtime.log(`Agent: ${agentId}`);
542
+ runtime.log(`Provider: ${provider}`);
543
+ runtime.log(`Auth file: ${shortenHomePath(`${agentDir}/auth-profiles.json`)}`);
544
+ runtime.log(order.length > 0 ? `Order override: ${order.join(", ")}` : "Order override: (none)");
545
+ }
546
+ async function modelsAuthOrderClearCommand(opts, runtime) {
547
+ const rawProvider = opts.provider?.trim();
548
+ if (!rawProvider) throw new Error("Missing --provider.");
549
+ const provider = normalizeProviderId(rawProvider);
550
+ const { agentId, agentDir } = resolveTargetAgent(loadConfig(), opts.agent);
551
+ if (!await setAuthProfileOrder({
552
+ agentDir,
553
+ provider,
554
+ order: null
555
+ })) throw new Error("Failed to update auth-profiles.json (lock busy?).");
556
+ runtime.log(`Agent: ${agentId}`);
557
+ runtime.log(`Provider: ${provider}`);
558
+ runtime.log("Cleared per-agent order override.");
559
+ }
560
+ async function modelsAuthOrderSetCommand(opts, runtime) {
561
+ const rawProvider = opts.provider?.trim();
562
+ if (!rawProvider) throw new Error("Missing --provider.");
563
+ const provider = normalizeProviderId(rawProvider);
564
+ const { agentId, agentDir } = resolveTargetAgent(loadConfig(), opts.agent);
565
+ const store = ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false });
566
+ const providerKey = normalizeProviderId(provider);
567
+ const requested = (opts.order ?? []).map((entry) => String(entry).trim()).filter(Boolean);
568
+ if (requested.length === 0) throw new Error("Missing profile ids. Provide one or more profile ids.");
569
+ for (const profileId of requested) {
570
+ const cred = store.profiles[profileId];
571
+ if (!cred) throw new Error(`Auth profile "${profileId}" not found in ${agentDir}.`);
572
+ if (normalizeProviderId(cred.provider) !== providerKey) throw new Error(`Auth profile "${profileId}" is for ${cred.provider}, not ${provider}.`);
573
+ }
574
+ const updated = await setAuthProfileOrder({
575
+ agentDir,
576
+ provider,
577
+ order: requested
578
+ });
579
+ if (!updated) throw new Error("Failed to update auth-profiles.json (lock busy?).");
580
+ runtime.log(`Agent: ${agentId}`);
581
+ runtime.log(`Provider: ${provider}`);
582
+ runtime.log(`Order override: ${describeOrder(updated, provider).join(", ")}`);
583
+ }
584
+
585
+ //#endregion
586
+ //#region src/commands/models/fallbacks.ts
587
+ async function modelsFallbacksListCommand(opts, runtime) {
588
+ ensureFlagCompatibility(opts);
589
+ const fallbacks = loadConfig().agents?.defaults?.model?.fallbacks ?? [];
590
+ if (opts.json) {
591
+ runtime.log(JSON.stringify({ fallbacks }, null, 2));
592
+ return;
593
+ }
594
+ if (opts.plain) {
595
+ for (const entry of fallbacks) runtime.log(entry);
596
+ return;
597
+ }
598
+ runtime.log(`Fallbacks (${fallbacks.length}):`);
599
+ if (fallbacks.length === 0) {
600
+ runtime.log("- none");
601
+ return;
602
+ }
603
+ for (const entry of fallbacks) runtime.log(`- ${entry}`);
604
+ }
605
+ async function modelsFallbacksAddCommand(modelRaw, runtime) {
606
+ const updated = await updateConfig((cfg) => {
607
+ const resolved = resolveModelTarget({
608
+ raw: modelRaw,
609
+ cfg
610
+ });
611
+ const targetKey = modelKey(resolved.provider, resolved.model);
612
+ const nextModels = { ...cfg.agents?.defaults?.models };
613
+ if (!nextModels[targetKey]) nextModels[targetKey] = {};
614
+ const aliasIndex = buildModelAliasIndex({
615
+ cfg,
616
+ defaultProvider: DEFAULT_PROVIDER
617
+ });
618
+ const existing = cfg.agents?.defaults?.model?.fallbacks ?? [];
619
+ if (existing.map((entry) => resolveModelRefFromString({
620
+ raw: String(entry ?? ""),
621
+ defaultProvider: DEFAULT_PROVIDER,
622
+ aliasIndex
623
+ })).filter((entry) => Boolean(entry)).map((entry) => modelKey(entry.ref.provider, entry.ref.model)).includes(targetKey)) return cfg;
624
+ const existingModel = cfg.agents?.defaults?.model;
625
+ return {
626
+ ...cfg,
627
+ agents: {
628
+ ...cfg.agents,
629
+ defaults: {
630
+ ...cfg.agents?.defaults,
631
+ model: {
632
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
633
+ fallbacks: [...existing, targetKey]
634
+ },
635
+ models: nextModels
636
+ }
637
+ }
638
+ };
639
+ });
640
+ logConfigUpdated(runtime);
641
+ runtime.log(`Fallbacks: ${(updated.agents?.defaults?.model?.fallbacks ?? []).join(", ")}`);
642
+ }
643
+ async function modelsFallbacksRemoveCommand(modelRaw, runtime) {
644
+ const updated = await updateConfig((cfg) => {
645
+ const resolved = resolveModelTarget({
646
+ raw: modelRaw,
647
+ cfg
648
+ });
649
+ const targetKey = modelKey(resolved.provider, resolved.model);
650
+ const aliasIndex = buildModelAliasIndex({
651
+ cfg,
652
+ defaultProvider: DEFAULT_PROVIDER
653
+ });
654
+ const existing = cfg.agents?.defaults?.model?.fallbacks ?? [];
655
+ const filtered = existing.filter((entry) => {
656
+ const resolvedEntry = resolveModelRefFromString({
657
+ raw: String(entry ?? ""),
658
+ defaultProvider: DEFAULT_PROVIDER,
659
+ aliasIndex
660
+ });
661
+ if (!resolvedEntry) return true;
662
+ return modelKey(resolvedEntry.ref.provider, resolvedEntry.ref.model) !== targetKey;
663
+ });
664
+ if (filtered.length === existing.length) throw new Error(`Fallback not found: ${targetKey}`);
665
+ const existingModel = cfg.agents?.defaults?.model;
666
+ return {
667
+ ...cfg,
668
+ agents: {
669
+ ...cfg.agents,
670
+ defaults: {
671
+ ...cfg.agents?.defaults,
672
+ model: {
673
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
674
+ fallbacks: filtered
675
+ }
676
+ }
677
+ }
678
+ };
679
+ });
680
+ logConfigUpdated(runtime);
681
+ runtime.log(`Fallbacks: ${(updated.agents?.defaults?.model?.fallbacks ?? []).join(", ")}`);
682
+ }
683
+ async function modelsFallbacksClearCommand(runtime) {
684
+ await updateConfig((cfg) => {
685
+ const existingModel = cfg.agents?.defaults?.model;
686
+ return {
687
+ ...cfg,
688
+ agents: {
689
+ ...cfg.agents,
690
+ defaults: {
691
+ ...cfg.agents?.defaults,
692
+ model: {
693
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
694
+ fallbacks: []
695
+ }
696
+ }
697
+ }
698
+ };
699
+ });
700
+ logConfigUpdated(runtime);
701
+ runtime.log("Fallback list cleared.");
702
+ }
703
+
704
+ //#endregion
705
+ //#region src/commands/models/image-fallbacks.ts
706
+ async function modelsImageFallbacksListCommand(opts, runtime) {
707
+ ensureFlagCompatibility(opts);
708
+ const fallbacks = loadConfig().agents?.defaults?.imageModel?.fallbacks ?? [];
709
+ if (opts.json) {
710
+ runtime.log(JSON.stringify({ fallbacks }, null, 2));
711
+ return;
712
+ }
713
+ if (opts.plain) {
714
+ for (const entry of fallbacks) runtime.log(entry);
715
+ return;
716
+ }
717
+ runtime.log(`Image fallbacks (${fallbacks.length}):`);
718
+ if (fallbacks.length === 0) {
719
+ runtime.log("- none");
720
+ return;
721
+ }
722
+ for (const entry of fallbacks) runtime.log(`- ${entry}`);
723
+ }
724
+ async function modelsImageFallbacksAddCommand(modelRaw, runtime) {
725
+ const updated = await updateConfig((cfg) => {
726
+ const resolved = resolveModelTarget({
727
+ raw: modelRaw,
728
+ cfg
729
+ });
730
+ const targetKey = modelKey(resolved.provider, resolved.model);
731
+ const nextModels = { ...cfg.agents?.defaults?.models };
732
+ if (!nextModels[targetKey]) nextModels[targetKey] = {};
733
+ const aliasIndex = buildModelAliasIndex({
734
+ cfg,
735
+ defaultProvider: DEFAULT_PROVIDER
736
+ });
737
+ const existing = cfg.agents?.defaults?.imageModel?.fallbacks ?? [];
738
+ if (existing.map((entry) => resolveModelRefFromString({
739
+ raw: String(entry ?? ""),
740
+ defaultProvider: DEFAULT_PROVIDER,
741
+ aliasIndex
742
+ })).filter((entry) => Boolean(entry)).map((entry) => modelKey(entry.ref.provider, entry.ref.model)).includes(targetKey)) return cfg;
743
+ const existingModel = cfg.agents?.defaults?.imageModel;
744
+ return {
745
+ ...cfg,
746
+ agents: {
747
+ ...cfg.agents,
748
+ defaults: {
749
+ ...cfg.agents?.defaults,
750
+ imageModel: {
751
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
752
+ fallbacks: [...existing, targetKey]
753
+ },
754
+ models: nextModels
755
+ }
756
+ }
757
+ };
758
+ });
759
+ logConfigUpdated(runtime);
760
+ runtime.log(`Image fallbacks: ${(updated.agents?.defaults?.imageModel?.fallbacks ?? []).join(", ")}`);
761
+ }
762
+ async function modelsImageFallbacksRemoveCommand(modelRaw, runtime) {
763
+ const updated = await updateConfig((cfg) => {
764
+ const resolved = resolveModelTarget({
765
+ raw: modelRaw,
766
+ cfg
767
+ });
768
+ const targetKey = modelKey(resolved.provider, resolved.model);
769
+ const aliasIndex = buildModelAliasIndex({
770
+ cfg,
771
+ defaultProvider: DEFAULT_PROVIDER
772
+ });
773
+ const existing = cfg.agents?.defaults?.imageModel?.fallbacks ?? [];
774
+ const filtered = existing.filter((entry) => {
775
+ const resolvedEntry = resolveModelRefFromString({
776
+ raw: String(entry ?? ""),
777
+ defaultProvider: DEFAULT_PROVIDER,
778
+ aliasIndex
779
+ });
780
+ if (!resolvedEntry) return true;
781
+ return modelKey(resolvedEntry.ref.provider, resolvedEntry.ref.model) !== targetKey;
782
+ });
783
+ if (filtered.length === existing.length) throw new Error(`Image fallback not found: ${targetKey}`);
784
+ const existingModel = cfg.agents?.defaults?.imageModel;
785
+ return {
786
+ ...cfg,
787
+ agents: {
788
+ ...cfg.agents,
789
+ defaults: {
790
+ ...cfg.agents?.defaults,
791
+ imageModel: {
792
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
793
+ fallbacks: filtered
794
+ }
795
+ }
796
+ }
797
+ };
798
+ });
799
+ logConfigUpdated(runtime);
800
+ runtime.log(`Image fallbacks: ${(updated.agents?.defaults?.imageModel?.fallbacks ?? []).join(", ")}`);
801
+ }
802
+ async function modelsImageFallbacksClearCommand(runtime) {
803
+ await updateConfig((cfg) => {
804
+ const existingModel = cfg.agents?.defaults?.imageModel;
805
+ return {
806
+ ...cfg,
807
+ agents: {
808
+ ...cfg.agents,
809
+ defaults: {
810
+ ...cfg.agents?.defaults,
811
+ imageModel: {
812
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
813
+ fallbacks: []
814
+ }
815
+ }
816
+ }
817
+ };
818
+ });
819
+ logConfigUpdated(runtime);
820
+ runtime.log("Image fallback list cleared.");
821
+ }
822
+
823
+ //#endregion
824
+ //#region src/agents/model-compat.ts
825
+ function isOpenAiCompletionsModel(model) {
826
+ return model.api === "openai-completions";
827
+ }
828
+ function normalizeModelCompat(model) {
829
+ const baseUrl = model.baseUrl ?? "";
830
+ if (!(model.provider === "zai" || baseUrl.includes("api.z.ai")) || !isOpenAiCompletionsModel(model)) return model;
831
+ const openaiModel = model;
832
+ const compat = openaiModel.compat ?? void 0;
833
+ if (compat?.supportsDeveloperRole === false) return model;
834
+ openaiModel.compat = compat ? {
835
+ ...compat,
836
+ supportsDeveloperRole: false
837
+ } : { supportsDeveloperRole: false };
838
+ return openaiModel;
839
+ }
840
+
841
+ //#endregion
842
+ //#region src/agents/model-forward-compat.ts
843
+ const OPENAI_CODEX_GPT_53_MODEL_ID = "gpt-5.3-codex";
844
+ const OPENAI_CODEX_TEMPLATE_MODEL_IDS = ["gpt-5.2-codex"];
845
+ const ANTHROPIC_OPUS_46_MODEL_ID = "claude-opus-4-6";
846
+ const ANTHROPIC_OPUS_46_DOT_MODEL_ID = "claude-opus-4.6";
847
+ const ANTHROPIC_OPUS_TEMPLATE_MODEL_IDS = ["claude-opus-4-5", "claude-opus-4.5"];
848
+ const ZAI_GLM5_MODEL_ID = "glm-5";
849
+ const ZAI_GLM5_TEMPLATE_MODEL_IDS = ["glm-4.7"];
850
+ const ANTIGRAVITY_OPUS_46_MODEL_ID = "claude-opus-4-6";
851
+ const ANTIGRAVITY_OPUS_46_DOT_MODEL_ID = "claude-opus-4.6";
852
+ const ANTIGRAVITY_OPUS_TEMPLATE_MODEL_IDS = ["claude-opus-4-5", "claude-opus-4.5"];
853
+ const ANTIGRAVITY_OPUS_46_THINKING_MODEL_ID = "claude-opus-4-6-thinking";
854
+ const ANTIGRAVITY_OPUS_46_DOT_THINKING_MODEL_ID = "claude-opus-4.6-thinking";
855
+ const ANTIGRAVITY_OPUS_THINKING_TEMPLATE_MODEL_IDS = ["claude-opus-4-5-thinking", "claude-opus-4.5-thinking"];
856
+ const ANTIGRAVITY_OPUS_46_FORWARD_COMPAT_CANDIDATES = [{
857
+ id: ANTIGRAVITY_OPUS_46_THINKING_MODEL_ID,
858
+ templatePrefixes: ["google-antigravity/claude-opus-4-5-thinking", "google-antigravity/claude-opus-4.5-thinking"]
859
+ }, {
860
+ id: ANTIGRAVITY_OPUS_46_MODEL_ID,
861
+ templatePrefixes: ["google-antigravity/claude-opus-4-5", "google-antigravity/claude-opus-4.5"]
862
+ }];
863
+ function resolveOpenAICodexGpt53FallbackModel(provider, modelId, modelRegistry) {
864
+ const normalizedProvider = normalizeProviderId(provider);
865
+ const trimmedModelId = modelId.trim();
866
+ if (normalizedProvider !== "openai-codex") return;
867
+ if (trimmedModelId.toLowerCase() !== OPENAI_CODEX_GPT_53_MODEL_ID) return;
868
+ for (const templateId of OPENAI_CODEX_TEMPLATE_MODEL_IDS) {
869
+ const template = modelRegistry.find(normalizedProvider, templateId);
870
+ if (!template) continue;
871
+ return normalizeModelCompat({
872
+ ...template,
873
+ id: trimmedModelId,
874
+ name: trimmedModelId
875
+ });
876
+ }
877
+ return normalizeModelCompat({
878
+ id: trimmedModelId,
879
+ name: trimmedModelId,
880
+ api: "openai-codex-responses",
881
+ provider: normalizedProvider,
882
+ baseUrl: "https://chatgpt.com/backend-api",
883
+ reasoning: true,
884
+ input: ["text", "image"],
885
+ cost: {
886
+ input: 0,
887
+ output: 0,
888
+ cacheRead: 0,
889
+ cacheWrite: 0
890
+ },
891
+ contextWindow: DEFAULT_CONTEXT_TOKENS,
892
+ maxTokens: DEFAULT_CONTEXT_TOKENS
893
+ });
894
+ }
895
+ function resolveOpenAICodexGpt52FallbackModel(provider, modelId, modelRegistry) {
896
+ const normalizedProvider = normalizeProviderId(provider);
897
+ const trimmedModelId = modelId.trim();
898
+ if (normalizedProvider !== "openai-codex") return;
899
+ if (trimmedModelId.toLowerCase() !== "gpt-5.2-codex") return;
900
+ const template = modelRegistry.find(normalizedProvider, "gpt-5.2-codex");
901
+ if (template) return normalizeModelCompat(template);
902
+ return normalizeModelCompat({
903
+ id: trimmedModelId,
904
+ name: trimmedModelId,
905
+ api: "openai-codex-responses",
906
+ provider: normalizedProvider,
907
+ baseUrl: "https://chatgpt.com/backend-api",
908
+ reasoning: true,
909
+ input: ["text", "image"],
910
+ cost: {
911
+ input: 0,
912
+ output: 0,
913
+ cacheRead: 0,
914
+ cacheWrite: 0
915
+ },
916
+ contextWindow: DEFAULT_CONTEXT_TOKENS,
917
+ maxTokens: DEFAULT_CONTEXT_TOKENS
918
+ });
919
+ }
920
+ function resolveAnthropicOpus46ForwardCompatModel(provider, modelId, modelRegistry) {
921
+ const normalizedProvider = normalizeProviderId(provider);
922
+ if (normalizedProvider !== "anthropic") return;
923
+ const trimmedModelId = modelId.trim();
924
+ const lower = trimmedModelId.toLowerCase();
925
+ 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;
926
+ const templateIds = [];
927
+ if (lower.startsWith(ANTHROPIC_OPUS_46_MODEL_ID)) templateIds.push(lower.replace(ANTHROPIC_OPUS_46_MODEL_ID, "claude-opus-4-5"));
928
+ if (lower.startsWith(ANTHROPIC_OPUS_46_DOT_MODEL_ID)) templateIds.push(lower.replace(ANTHROPIC_OPUS_46_DOT_MODEL_ID, "claude-opus-4.5"));
929
+ templateIds.push(...ANTHROPIC_OPUS_TEMPLATE_MODEL_IDS);
930
+ for (const templateId of [...new Set(templateIds)].filter(Boolean)) {
931
+ const template = modelRegistry.find(normalizedProvider, templateId);
932
+ if (!template) continue;
933
+ return normalizeModelCompat({
934
+ ...template,
935
+ id: trimmedModelId,
936
+ name: trimmedModelId
937
+ });
938
+ }
939
+ }
940
+ function resolveZaiGlm5ForwardCompatModel(provider, modelId, modelRegistry) {
941
+ if (normalizeProviderId(provider) !== "zai") return;
942
+ const trimmed = modelId.trim();
943
+ const lower = trimmed.toLowerCase();
944
+ if (lower !== ZAI_GLM5_MODEL_ID && !lower.startsWith(`${ZAI_GLM5_MODEL_ID}-`)) return;
945
+ for (const templateId of ZAI_GLM5_TEMPLATE_MODEL_IDS) {
946
+ const template = modelRegistry.find("zai", templateId);
947
+ if (!template) continue;
948
+ return normalizeModelCompat({
949
+ ...template,
950
+ id: trimmed,
951
+ name: trimmed,
952
+ reasoning: true
953
+ });
954
+ }
955
+ return normalizeModelCompat({
956
+ id: trimmed,
957
+ name: trimmed,
958
+ api: "openai-completions",
959
+ provider: "zai",
960
+ reasoning: true,
961
+ input: ["text"],
962
+ cost: {
963
+ input: 0,
964
+ output: 0,
965
+ cacheRead: 0,
966
+ cacheWrite: 0
967
+ },
968
+ contextWindow: DEFAULT_CONTEXT_TOKENS,
969
+ maxTokens: DEFAULT_CONTEXT_TOKENS
970
+ });
971
+ }
972
+ function resolveAntigravityOpus46ForwardCompatModel(provider, modelId, modelRegistry) {
973
+ const normalizedProvider = normalizeProviderId(provider);
974
+ if (normalizedProvider !== "google-antigravity") return;
975
+ const trimmedModelId = modelId.trim();
976
+ const lower = trimmedModelId.toLowerCase();
977
+ 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}-`);
978
+ 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}-`);
979
+ if (!isOpus46 && !isOpus46Thinking) return;
980
+ const templateIds = [];
981
+ if (lower.startsWith(ANTIGRAVITY_OPUS_46_MODEL_ID)) templateIds.push(lower.replace(ANTIGRAVITY_OPUS_46_MODEL_ID, "claude-opus-4-5"));
982
+ if (lower.startsWith(ANTIGRAVITY_OPUS_46_DOT_MODEL_ID)) templateIds.push(lower.replace(ANTIGRAVITY_OPUS_46_DOT_MODEL_ID, "claude-opus-4.5"));
983
+ if (lower.startsWith(ANTIGRAVITY_OPUS_46_THINKING_MODEL_ID)) templateIds.push(lower.replace(ANTIGRAVITY_OPUS_46_THINKING_MODEL_ID, "claude-opus-4-5-thinking"));
984
+ 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"));
985
+ templateIds.push(...ANTIGRAVITY_OPUS_TEMPLATE_MODEL_IDS);
986
+ templateIds.push(...ANTIGRAVITY_OPUS_THINKING_TEMPLATE_MODEL_IDS);
987
+ for (const templateId of [...new Set(templateIds)].filter(Boolean)) {
988
+ const template = modelRegistry.find(normalizedProvider, templateId);
989
+ if (!template) continue;
990
+ return normalizeModelCompat({
991
+ ...template,
992
+ id: trimmedModelId,
993
+ name: trimmedModelId
994
+ });
995
+ }
996
+ }
997
+ function resolveForwardCompatModel(provider, modelId, modelRegistry) {
998
+ return resolveOpenAICodexGpt52FallbackModel(provider, modelId, modelRegistry) ?? resolveOpenAICodexGpt53FallbackModel(provider, modelId, modelRegistry) ?? resolveAnthropicOpus46ForwardCompatModel(provider, modelId, modelRegistry) ?? resolveZaiGlm5ForwardCompatModel(provider, modelId, modelRegistry) ?? resolveAntigravityOpus46ForwardCompatModel(provider, modelId, modelRegistry);
999
+ }
1000
+
1001
+ //#endregion
1002
+ //#region src/commands/models/list.configured.ts
1003
+ function resolveConfiguredEntries(cfg) {
1004
+ const resolvedDefault = resolveConfiguredModelRef({
1005
+ cfg,
1006
+ defaultProvider: DEFAULT_PROVIDER,
1007
+ defaultModel: DEFAULT_MODEL
1008
+ });
1009
+ const aliasIndex = buildModelAliasIndex({
1010
+ cfg,
1011
+ defaultProvider: DEFAULT_PROVIDER
1012
+ });
1013
+ const order = [];
1014
+ const tagsByKey = /* @__PURE__ */ new Map();
1015
+ const aliasesByKey = /* @__PURE__ */ new Map();
1016
+ for (const [key, aliases] of aliasIndex.byKey.entries()) aliasesByKey.set(key, aliases);
1017
+ const addEntry = (ref, tag) => {
1018
+ const key = modelKey(ref.provider, ref.model);
1019
+ if (!tagsByKey.has(key)) {
1020
+ tagsByKey.set(key, /* @__PURE__ */ new Set());
1021
+ order.push(key);
1022
+ }
1023
+ tagsByKey.get(key)?.add(tag);
1024
+ };
1025
+ addEntry(resolvedDefault, "default");
1026
+ const modelConfig = cfg.agents?.defaults?.model;
1027
+ const imageModelConfig = cfg.agents?.defaults?.imageModel;
1028
+ const modelFallbacks = typeof modelConfig === "object" ? modelConfig?.fallbacks ?? [] : [];
1029
+ const imageFallbacks = typeof imageModelConfig === "object" ? imageModelConfig?.fallbacks ?? [] : [];
1030
+ const imagePrimary = imageModelConfig?.primary?.trim() ?? "";
1031
+ modelFallbacks.forEach((raw, idx) => {
1032
+ const resolved = resolveModelRefFromString({
1033
+ raw: String(raw ?? ""),
1034
+ defaultProvider: DEFAULT_PROVIDER,
1035
+ aliasIndex
1036
+ });
1037
+ if (!resolved) return;
1038
+ addEntry(resolved.ref, `fallback#${idx + 1}`);
1039
+ });
1040
+ if (imagePrimary) {
1041
+ const resolved = resolveModelRefFromString({
1042
+ raw: imagePrimary,
1043
+ defaultProvider: DEFAULT_PROVIDER,
1044
+ aliasIndex
1045
+ });
1046
+ if (resolved) addEntry(resolved.ref, "image");
1047
+ }
1048
+ imageFallbacks.forEach((raw, idx) => {
1049
+ const resolved = resolveModelRefFromString({
1050
+ raw: String(raw ?? ""),
1051
+ defaultProvider: DEFAULT_PROVIDER,
1052
+ aliasIndex
1053
+ });
1054
+ if (!resolved) return;
1055
+ addEntry(resolved.ref, `img-fallback#${idx + 1}`);
1056
+ });
1057
+ for (const key of Object.keys(cfg.agents?.defaults?.models ?? {})) {
1058
+ const parsed = parseModelRef(String(key ?? ""), DEFAULT_PROVIDER);
1059
+ if (!parsed) continue;
1060
+ addEntry(parsed, "configured");
1061
+ }
1062
+ return { entries: order.map((key) => {
1063
+ const slash = key.indexOf("/");
1064
+ return {
1065
+ key,
1066
+ ref: {
1067
+ provider: slash === -1 ? key : key.slice(0, slash),
1068
+ model: slash === -1 ? "" : key.slice(slash + 1)
1069
+ },
1070
+ tags: tagsByKey.get(key) ?? /* @__PURE__ */ new Set(),
1071
+ aliases: aliasesByKey.get(key) ?? []
1072
+ };
1073
+ }) };
1074
+ }
1075
+
1076
+ //#endregion
1077
+ //#region src/commands/models/list.errors.ts
1078
+ const MODEL_AVAILABILITY_UNAVAILABLE_CODE = "MODEL_AVAILABILITY_UNAVAILABLE";
1079
+ function formatErrorWithStack(err) {
1080
+ if (err instanceof Error) return err.stack ?? `${err.name}: ${err.message}`;
1081
+ return String(err);
1082
+ }
1083
+ function shouldFallbackToAuthHeuristics(err) {
1084
+ if (!(err instanceof Error)) return false;
1085
+ return err.code === MODEL_AVAILABILITY_UNAVAILABLE_CODE;
1086
+ }
1087
+
1088
+ //#endregion
1089
+ //#region src/commands/models/list.registry.ts
1090
+ const hasAuthForProvider = (provider, cfg, authStore) => {
1091
+ if (!cfg || !authStore) return false;
1092
+ if (listProfilesForProvider(authStore, provider).length > 0) return true;
1093
+ if (provider === "amazon-bedrock" && resolveAwsSdkEnvVarName()) return true;
1094
+ if (resolveEnvApiKey(provider)) return true;
1095
+ if (getCustomProviderApiKey(cfg, provider)) return true;
1096
+ return false;
1097
+ };
1098
+ function createAvailabilityUnavailableError(message) {
1099
+ const err = new Error(message);
1100
+ err.code = MODEL_AVAILABILITY_UNAVAILABLE_CODE;
1101
+ return err;
1102
+ }
1103
+ function normalizeAvailabilityError(err) {
1104
+ if (shouldFallbackToAuthHeuristics(err) && err instanceof Error) return err;
1105
+ return createAvailabilityUnavailableError(`Model availability unavailable: getAvailable() failed.\n${formatErrorWithStack(err)}`);
1106
+ }
1107
+ function validateAvailableModels(availableModels) {
1108
+ if (!Array.isArray(availableModels)) throw createAvailabilityUnavailableError("Model availability unavailable: getAvailable() returned a non-array value.");
1109
+ 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.");
1110
+ return availableModels;
1111
+ }
1112
+ function loadAvailableModels(registry) {
1113
+ let availableModels;
1114
+ try {
1115
+ availableModels = registry.getAvailable();
1116
+ } catch (err) {
1117
+ throw normalizeAvailabilityError(err);
1118
+ }
1119
+ try {
1120
+ return validateAvailableModels(availableModels);
1121
+ } catch (err) {
1122
+ throw normalizeAvailabilityError(err);
1123
+ }
1124
+ }
1125
+ async function loadModelRegistry(cfg) {
1126
+ await ensureAnimaModelsJson(cfg);
1127
+ const agentDir = resolveAnimaAgentDir();
1128
+ const registry = discoverModels(discoverAuthStorage(agentDir), agentDir);
1129
+ const appended = appendAntigravityForwardCompatModels(registry.getAll(), registry);
1130
+ const models = appended.models;
1131
+ const synthesizedForwardCompat = appended.synthesizedForwardCompat;
1132
+ let availableKeys;
1133
+ let availabilityErrorMessage;
1134
+ try {
1135
+ const availableModels = loadAvailableModels(registry);
1136
+ availableKeys = new Set(availableModels.map((model) => modelKey(model.provider, model.id)));
1137
+ for (const synthesized of synthesizedForwardCompat) if (hasAvailableTemplate(availableKeys, synthesized.templatePrefixes)) availableKeys.add(synthesized.key);
1138
+ } catch (err) {
1139
+ if (!shouldFallbackToAuthHeuristics(err)) throw err;
1140
+ availableKeys = void 0;
1141
+ if (!availabilityErrorMessage) availabilityErrorMessage = formatErrorWithStack(err);
1142
+ }
1143
+ return {
1144
+ registry,
1145
+ models,
1146
+ availableKeys,
1147
+ availabilityErrorMessage
1148
+ };
1149
+ }
1150
+ function appendAntigravityForwardCompatModels(models, modelRegistry) {
1151
+ const nextModels = [...models];
1152
+ const synthesizedForwardCompat = [];
1153
+ for (const candidate of ANTIGRAVITY_OPUS_46_FORWARD_COMPAT_CANDIDATES) {
1154
+ const key = modelKey("google-antigravity", candidate.id);
1155
+ if (nextModels.some((model) => modelKey(model.provider, model.id) === key)) continue;
1156
+ const fallback = resolveForwardCompatModel("google-antigravity", candidate.id, modelRegistry);
1157
+ if (!fallback) continue;
1158
+ nextModels.push(fallback);
1159
+ synthesizedForwardCompat.push({
1160
+ key,
1161
+ templatePrefixes: candidate.templatePrefixes
1162
+ });
1163
+ }
1164
+ return {
1165
+ models: nextModels,
1166
+ synthesizedForwardCompat
1167
+ };
1168
+ }
1169
+ function hasAvailableTemplate(availableKeys, templatePrefixes) {
1170
+ for (const key of availableKeys) if (templatePrefixes.some((prefix) => key.startsWith(prefix))) return true;
1171
+ return false;
1172
+ }
1173
+ function toModelRow(params) {
1174
+ const { model, key, tags, aliases = [], availableKeys, cfg, authStore } = params;
1175
+ if (!model) return {
1176
+ key,
1177
+ name: key,
1178
+ input: "-",
1179
+ contextWindow: null,
1180
+ local: null,
1181
+ available: null,
1182
+ tags: [...tags, "missing"],
1183
+ missing: true
1184
+ };
1185
+ const input = model.input.join("+") || "text";
1186
+ const local = isLocalBaseUrl(model.baseUrl);
1187
+ const available = availableKeys !== void 0 ? availableKeys.has(modelKey(model.provider, model.id)) : cfg && authStore ? hasAuthForProvider(model.provider, cfg, authStore) : false;
1188
+ const aliasTags = aliases.length > 0 ? [`alias:${aliases.join(",")}`] : [];
1189
+ const mergedTags = new Set(tags);
1190
+ if (aliasTags.length > 0) {
1191
+ for (const tag of mergedTags) if (tag === "alias" || tag.startsWith("alias:")) mergedTags.delete(tag);
1192
+ for (const tag of aliasTags) mergedTags.add(tag);
1193
+ }
1194
+ return {
1195
+ key,
1196
+ name: model.name || model.id,
1197
+ input,
1198
+ contextWindow: model.contextWindow ?? null,
1199
+ local,
1200
+ available,
1201
+ tags: Array.from(mergedTags),
1202
+ missing: false
1203
+ };
1204
+ }
1205
+
1206
+ //#endregion
1207
+ //#region src/commands/models/list.format.ts
1208
+ const isRich = (opts) => Boolean(isRich$1() && !opts?.json && !opts?.plain);
1209
+ const pad$1 = (value, size) => value.padEnd(size);
1210
+ const formatTag = (tag, rich) => {
1211
+ if (!rich) return tag;
1212
+ if (tag === "default") return theme.success(tag);
1213
+ if (tag === "image") return theme.accentBright(tag);
1214
+ if (tag === "configured") return theme.accent(tag);
1215
+ if (tag === "missing") return theme.error(tag);
1216
+ if (tag.startsWith("fallback#")) return theme.warn(tag);
1217
+ if (tag.startsWith("img-fallback#")) return theme.warn(tag);
1218
+ if (tag.startsWith("alias:")) return theme.accentDim(tag);
1219
+ return theme.muted(tag);
1220
+ };
1221
+ const truncate$1 = (value, max) => {
1222
+ if (value.length <= max) return value;
1223
+ if (max <= 3) return value.slice(0, max);
1224
+ return `${value.slice(0, max - 3)}...`;
1225
+ };
1226
+ const maskApiKey = (value) => {
1227
+ const trimmed = value.trim();
1228
+ if (!trimmed) return "missing";
1229
+ if (trimmed.length <= 16) return trimmed;
1230
+ return `${trimmed.slice(0, 8)}...${trimmed.slice(-8)}`;
1231
+ };
1232
+
1233
+ //#endregion
1234
+ //#region src/commands/models/list.table.ts
1235
+ const MODEL_PAD$1 = 42;
1236
+ const INPUT_PAD = 10;
1237
+ const CTX_PAD$1 = 8;
1238
+ const LOCAL_PAD = 5;
1239
+ const AUTH_PAD = 5;
1240
+ function printModelTable(rows, runtime, opts = {}) {
1241
+ if (opts.json) {
1242
+ runtime.log(JSON.stringify({
1243
+ count: rows.length,
1244
+ models: rows
1245
+ }, null, 2));
1246
+ return;
1247
+ }
1248
+ if (opts.plain) {
1249
+ for (const row of rows) runtime.log(row.key);
1250
+ return;
1251
+ }
1252
+ const rich = isRich(opts);
1253
+ const header = [
1254
+ pad$1("Model", MODEL_PAD$1),
1255
+ pad$1("Input", INPUT_PAD),
1256
+ pad$1("Ctx", CTX_PAD$1),
1257
+ pad$1("Local", LOCAL_PAD),
1258
+ pad$1("Auth", AUTH_PAD),
1259
+ "Tags"
1260
+ ].join(" ");
1261
+ runtime.log(rich ? theme.heading(header) : header);
1262
+ for (const row of rows) {
1263
+ const keyLabel = pad$1(truncate$1(row.key, MODEL_PAD$1), MODEL_PAD$1);
1264
+ const inputLabel = pad$1(row.input || "-", INPUT_PAD);
1265
+ const ctxLabel = pad$1(formatTokenK(row.contextWindow), CTX_PAD$1);
1266
+ const localLabel = pad$1(row.local === null ? "-" : row.local ? "yes" : "no", LOCAL_PAD);
1267
+ const authLabel = pad$1(row.available === null ? "-" : row.available ? "yes" : "no", AUTH_PAD);
1268
+ const tagsLabel = row.tags.length > 0 ? rich ? row.tags.map((tag) => formatTag(tag, rich)).join(",") : row.tags.join(",") : "";
1269
+ const coloredInput = colorize(rich, row.input.includes("image") ? theme.accentBright : theme.info, inputLabel);
1270
+ const coloredLocal = colorize(rich, row.local === null ? theme.muted : row.local ? theme.success : theme.muted, localLabel);
1271
+ const coloredAuth = colorize(rich, row.available === null ? theme.muted : row.available ? theme.success : theme.error, authLabel);
1272
+ const line = [
1273
+ rich ? theme.accent(keyLabel) : keyLabel,
1274
+ coloredInput,
1275
+ ctxLabel,
1276
+ coloredLocal,
1277
+ coloredAuth,
1278
+ tagsLabel
1279
+ ].join(" ");
1280
+ runtime.log(line);
1281
+ }
1282
+ }
1283
+
1284
+ //#endregion
1285
+ //#region src/commands/models/list.list-command.ts
1286
+ async function modelsListCommand(opts, runtime) {
1287
+ ensureFlagCompatibility(opts);
1288
+ const cfg = loadConfig();
1289
+ const authStore = ensureAuthProfileStore();
1290
+ const providerFilter = (() => {
1291
+ const raw = opts.provider?.trim();
1292
+ if (!raw) return;
1293
+ return parseModelRef(`${raw}/_`, DEFAULT_PROVIDER)?.provider ?? raw.toLowerCase();
1294
+ })();
1295
+ let models = [];
1296
+ let modelRegistry;
1297
+ let availableKeys;
1298
+ let availabilityErrorMessage;
1299
+ try {
1300
+ const loaded = await loadModelRegistry(cfg);
1301
+ modelRegistry = loaded.registry;
1302
+ models = loaded.models;
1303
+ availableKeys = loaded.availableKeys;
1304
+ availabilityErrorMessage = loaded.availabilityErrorMessage;
1305
+ } catch (err) {
1306
+ runtime.error(`Model registry unavailable:\n${formatErrorWithStack(err)}`);
1307
+ process.exitCode = 1;
1308
+ return;
1309
+ }
1310
+ if (availabilityErrorMessage !== void 0) runtime.error(`Model availability lookup failed; falling back to auth heuristics for discovered models: ${availabilityErrorMessage}`);
1311
+ const modelByKey = new Map(models.map((model) => [modelKey(model.provider, model.id), model]));
1312
+ const { entries } = resolveConfiguredEntries(cfg);
1313
+ const configuredByKey = new Map(entries.map((entry) => [entry.key, entry]));
1314
+ const rows = [];
1315
+ if (opts.all) {
1316
+ const sorted = [...models].toSorted((a, b) => {
1317
+ const p = a.provider.localeCompare(b.provider);
1318
+ if (p !== 0) return p;
1319
+ return a.id.localeCompare(b.id);
1320
+ });
1321
+ for (const model of sorted) {
1322
+ if (providerFilter && model.provider.toLowerCase() !== providerFilter) continue;
1323
+ if (opts.local && !isLocalBaseUrl(model.baseUrl)) continue;
1324
+ const key = modelKey(model.provider, model.id);
1325
+ const configured = configuredByKey.get(key);
1326
+ rows.push(toModelRow({
1327
+ model,
1328
+ key,
1329
+ tags: configured ? Array.from(configured.tags) : [],
1330
+ aliases: configured?.aliases ?? [],
1331
+ availableKeys,
1332
+ cfg,
1333
+ authStore
1334
+ }));
1335
+ }
1336
+ } else for (const entry of entries) {
1337
+ if (providerFilter && entry.ref.provider.toLowerCase() !== providerFilter) continue;
1338
+ let model = modelByKey.get(entry.key);
1339
+ if (!model && modelRegistry) {
1340
+ const forwardCompat = resolveForwardCompatModel(entry.ref.provider, entry.ref.model, modelRegistry);
1341
+ if (forwardCompat) {
1342
+ model = forwardCompat;
1343
+ modelByKey.set(entry.key, forwardCompat);
1344
+ }
1345
+ }
1346
+ if (!model) model = resolveModel(entry.ref.provider, entry.ref.model, void 0, cfg).model;
1347
+ if (opts.local && model && !isLocalBaseUrl(model.baseUrl)) continue;
1348
+ if (opts.local && !model) continue;
1349
+ rows.push(toModelRow({
1350
+ model,
1351
+ key: entry.key,
1352
+ tags: Array.from(entry.tags),
1353
+ aliases: entry.aliases,
1354
+ availableKeys,
1355
+ cfg,
1356
+ authStore
1357
+ }));
1358
+ }
1359
+ if (rows.length === 0) {
1360
+ runtime.log("No models found.");
1361
+ return;
1362
+ }
1363
+ printModelTable(rows, runtime, opts);
1364
+ }
1365
+
1366
+ //#endregion
1367
+ //#region src/commands/models/list.auth-overview.ts
1368
+ function resolveProviderAuthOverview(params) {
1369
+ const { provider, cfg, store } = params;
1370
+ const now = Date.now();
1371
+ const profiles = listProfilesForProvider(store, provider);
1372
+ const withUnusableSuffix = (base, profileId) => {
1373
+ const unusableUntil = resolveProfileUnusableUntilForDisplay(store, profileId);
1374
+ if (!unusableUntil || now >= unusableUntil) return base;
1375
+ const stats = store.usageStats?.[profileId];
1376
+ return `${base} [${typeof stats?.disabledUntil === "number" && now < stats.disabledUntil ? `disabled${stats.disabledReason ? `:${stats.disabledReason}` : ""}` : "cooldown"} ${formatRemainingShort(unusableUntil - now)}]`;
1377
+ };
1378
+ const labels = profiles.map((profileId) => {
1379
+ const profile = store.profiles[profileId];
1380
+ if (!profile) return `${profileId}=missing`;
1381
+ if (profile.type === "api_key") return withUnusableSuffix(`${profileId}=${maskApiKey(profile.key ?? "")}`, profileId);
1382
+ if (profile.type === "token") return withUnusableSuffix(`${profileId}=token:${maskApiKey(profile.token)}`, profileId);
1383
+ const display = resolveAuthProfileDisplayLabel({
1384
+ cfg,
1385
+ store,
1386
+ profileId
1387
+ });
1388
+ const suffix = display === profileId ? "" : display.startsWith(profileId) ? display.slice(profileId.length).trim() : `(${display})`;
1389
+ return withUnusableSuffix(`${profileId}=OAuth${suffix ? ` ${suffix}` : ""}`, profileId);
1390
+ });
1391
+ const oauthCount = profiles.filter((id) => store.profiles[id]?.type === "oauth").length;
1392
+ const tokenCount = profiles.filter((id) => store.profiles[id]?.type === "token").length;
1393
+ const apiKeyCount = profiles.filter((id) => store.profiles[id]?.type === "api_key").length;
1394
+ const envKey = resolveEnvApiKey(provider);
1395
+ const customKey = getCustomProviderApiKey(cfg, provider);
1396
+ return {
1397
+ provider,
1398
+ effective: (() => {
1399
+ if (profiles.length > 0) return {
1400
+ kind: "profiles",
1401
+ detail: shortenHomePath(resolveAuthStorePathForDisplay())
1402
+ };
1403
+ if (envKey) return {
1404
+ kind: "env",
1405
+ detail: envKey.source.includes("OAUTH_TOKEN") || envKey.source.toLowerCase().includes("oauth") ? "OAuth (env)" : maskApiKey(envKey.apiKey)
1406
+ };
1407
+ if (customKey) return {
1408
+ kind: "models.json",
1409
+ detail: maskApiKey(customKey)
1410
+ };
1411
+ return {
1412
+ kind: "missing",
1413
+ detail: "missing"
1414
+ };
1415
+ })(),
1416
+ profiles: {
1417
+ count: profiles.length,
1418
+ oauth: oauthCount,
1419
+ token: tokenCount,
1420
+ apiKey: apiKeyCount,
1421
+ labels
1422
+ },
1423
+ ...envKey ? { env: {
1424
+ value: envKey.source.includes("OAUTH_TOKEN") || envKey.source.toLowerCase().includes("oauth") ? "OAuth (env)" : maskApiKey(envKey.apiKey),
1425
+ source: envKey.source
1426
+ } } : {},
1427
+ ...customKey ? { modelsJson: {
1428
+ value: maskApiKey(customKey),
1429
+ source: `models.json: ${shortenHomePath(params.modelsPath)}`
1430
+ } } : {}
1431
+ };
1432
+ }
1433
+
1434
+ //#endregion
1435
+ //#region src/commands/models/list.probe.ts
1436
+ const PROBE_PROMPT = "Reply with OK. Do not use tools.";
1437
+ const toStatus = (reason) => {
1438
+ if (!reason) return "unknown";
1439
+ if (reason === "auth") return "auth";
1440
+ if (reason === "rate_limit") return "rate_limit";
1441
+ if (reason === "billing") return "billing";
1442
+ if (reason === "timeout") return "timeout";
1443
+ if (reason === "format") return "format";
1444
+ return "unknown";
1445
+ };
1446
+ function buildCandidateMap(modelCandidates) {
1447
+ const map = /* @__PURE__ */ new Map();
1448
+ for (const raw of modelCandidates) {
1449
+ const parsed = parseModelRef(String(raw ?? ""), DEFAULT_PROVIDER);
1450
+ if (!parsed) continue;
1451
+ const list = map.get(parsed.provider) ?? [];
1452
+ if (!list.includes(parsed.model)) list.push(parsed.model);
1453
+ map.set(parsed.provider, list);
1454
+ }
1455
+ return map;
1456
+ }
1457
+ function selectProbeModel(params) {
1458
+ const { provider, candidates, catalog } = params;
1459
+ const direct = candidates.get(provider);
1460
+ if (direct && direct.length > 0) return {
1461
+ provider,
1462
+ model: direct[0]
1463
+ };
1464
+ const fromCatalog = catalog.find((entry) => entry.provider === provider);
1465
+ if (fromCatalog) return {
1466
+ provider: fromCatalog.provider,
1467
+ model: fromCatalog.id
1468
+ };
1469
+ return null;
1470
+ }
1471
+ function buildProbeTargets(params) {
1472
+ const { cfg, providers, modelCandidates, options } = params;
1473
+ const store = ensureAuthProfileStore();
1474
+ const providerFilter = options.provider?.trim();
1475
+ const providerFilterKey = providerFilter ? normalizeProviderId(providerFilter) : null;
1476
+ const profileFilter = new Set((options.profileIds ?? []).map((id) => id.trim()).filter(Boolean));
1477
+ return loadModelCatalog({ config: cfg }).then((catalog) => {
1478
+ const candidates = buildCandidateMap(modelCandidates);
1479
+ const targets = [];
1480
+ const results = [];
1481
+ for (const provider of providers) {
1482
+ const providerKey = normalizeProviderId(provider);
1483
+ if (providerFilterKey && providerKey !== providerFilterKey) continue;
1484
+ const model = selectProbeModel({
1485
+ provider: providerKey,
1486
+ candidates,
1487
+ catalog
1488
+ });
1489
+ const profileIds = listProfilesForProvider(store, providerKey);
1490
+ const explicitOrder = (() => {
1491
+ const order = store.order;
1492
+ if (order) {
1493
+ for (const [key, value] of Object.entries(order)) if (normalizeProviderId(key) === providerKey) return value;
1494
+ }
1495
+ const cfgOrder = cfg?.auth?.order;
1496
+ if (cfgOrder) {
1497
+ for (const [key, value] of Object.entries(cfgOrder)) if (normalizeProviderId(key) === providerKey) return value;
1498
+ }
1499
+ })();
1500
+ const allowedProfiles = explicitOrder && explicitOrder.length > 0 ? new Set(resolveAuthProfileOrder({
1501
+ cfg,
1502
+ store,
1503
+ provider: providerKey
1504
+ })) : null;
1505
+ const filteredProfiles = profileFilter.size ? profileIds.filter((id) => profileFilter.has(id)) : profileIds;
1506
+ if (filteredProfiles.length > 0) {
1507
+ for (const profileId of filteredProfiles) {
1508
+ const mode = store.profiles[profileId]?.type;
1509
+ const label = resolveAuthProfileDisplayLabel({
1510
+ cfg,
1511
+ store,
1512
+ profileId
1513
+ });
1514
+ if (explicitOrder && !explicitOrder.includes(profileId)) {
1515
+ results.push({
1516
+ provider: providerKey,
1517
+ model: model ? `${model.provider}/${model.model}` : void 0,
1518
+ profileId,
1519
+ label,
1520
+ source: "profile",
1521
+ mode,
1522
+ status: "unknown",
1523
+ error: "Excluded by auth.order for this provider."
1524
+ });
1525
+ continue;
1526
+ }
1527
+ if (allowedProfiles && !allowedProfiles.has(profileId)) {
1528
+ results.push({
1529
+ provider: providerKey,
1530
+ model: model ? `${model.provider}/${model.model}` : void 0,
1531
+ profileId,
1532
+ label,
1533
+ source: "profile",
1534
+ mode,
1535
+ status: "unknown",
1536
+ error: "Auth profile credentials are missing or expired."
1537
+ });
1538
+ continue;
1539
+ }
1540
+ if (!model) {
1541
+ results.push({
1542
+ provider: providerKey,
1543
+ model: void 0,
1544
+ profileId,
1545
+ label,
1546
+ source: "profile",
1547
+ mode,
1548
+ status: "no_model",
1549
+ error: "No model available for probe"
1550
+ });
1551
+ continue;
1552
+ }
1553
+ targets.push({
1554
+ provider: providerKey,
1555
+ model,
1556
+ profileId,
1557
+ label,
1558
+ source: "profile",
1559
+ mode
1560
+ });
1561
+ }
1562
+ continue;
1563
+ }
1564
+ if (profileFilter.size > 0) continue;
1565
+ const envKey = resolveEnvApiKey(providerKey);
1566
+ const customKey = getCustomProviderApiKey(cfg, providerKey);
1567
+ if (!envKey && !customKey) continue;
1568
+ const label = envKey ? "env" : "models.json";
1569
+ const source = envKey ? "env" : "models.json";
1570
+ const mode = envKey?.source.includes("OAUTH_TOKEN") ? "oauth" : "api_key";
1571
+ if (!model) {
1572
+ results.push({
1573
+ provider: providerKey,
1574
+ model: void 0,
1575
+ label,
1576
+ source,
1577
+ mode,
1578
+ status: "no_model",
1579
+ error: "No model available for probe"
1580
+ });
1581
+ continue;
1582
+ }
1583
+ targets.push({
1584
+ provider: providerKey,
1585
+ model,
1586
+ label,
1587
+ source,
1588
+ mode
1589
+ });
1590
+ }
1591
+ return {
1592
+ targets,
1593
+ results
1594
+ };
1595
+ });
1596
+ }
1597
+ async function probeTarget(params) {
1598
+ const { cfg, agentId, agentDir, workspaceDir, sessionDir, target, timeoutMs, maxTokens } = params;
1599
+ if (!target.model) return {
1600
+ provider: target.provider,
1601
+ model: void 0,
1602
+ profileId: target.profileId,
1603
+ label: target.label,
1604
+ source: target.source,
1605
+ mode: target.mode,
1606
+ status: "no_model",
1607
+ error: "No model available for probe"
1608
+ };
1609
+ const sessionId = `probe-${target.provider}-${crypto.randomUUID()}`;
1610
+ const sessionFile = resolveSessionTranscriptPath(sessionId, agentId);
1611
+ await fs.mkdir(sessionDir, { recursive: true });
1612
+ const start = Date.now();
1613
+ try {
1614
+ await runNoxSoftEmbeddedAgent({
1615
+ sessionId,
1616
+ sessionFile,
1617
+ agentId,
1618
+ workspaceDir,
1619
+ agentDir,
1620
+ config: cfg,
1621
+ prompt: PROBE_PROMPT,
1622
+ provider: target.model.provider,
1623
+ model: target.model.model,
1624
+ authProfileId: target.profileId,
1625
+ authProfileIdSource: target.profileId ? "user" : void 0,
1626
+ timeoutMs,
1627
+ runId: `probe-${crypto.randomUUID()}`,
1628
+ lane: `auth-probe:${target.provider}:${target.profileId ?? target.source}`,
1629
+ thinkLevel: "off",
1630
+ reasoningLevel: "off",
1631
+ verboseLevel: "off",
1632
+ streamParams: { maxTokens }
1633
+ });
1634
+ return {
1635
+ provider: target.provider,
1636
+ model: `${target.model.provider}/${target.model.model}`,
1637
+ profileId: target.profileId,
1638
+ label: target.label,
1639
+ source: target.source,
1640
+ mode: target.mode,
1641
+ status: "ok",
1642
+ latencyMs: Date.now() - start
1643
+ };
1644
+ } catch (err) {
1645
+ const described = describeFailoverError(err);
1646
+ return {
1647
+ provider: target.provider,
1648
+ model: `${target.model.provider}/${target.model.model}`,
1649
+ profileId: target.profileId,
1650
+ label: target.label,
1651
+ source: target.source,
1652
+ mode: target.mode,
1653
+ status: toStatus(described.reason),
1654
+ error: redactSecrets(described.message),
1655
+ latencyMs: Date.now() - start
1656
+ };
1657
+ }
1658
+ }
1659
+ async function runTargetsWithConcurrency(params) {
1660
+ const { cfg, targets, timeoutMs, maxTokens, onProgress } = params;
1661
+ const concurrency = Math.max(1, Math.min(targets.length || 1, params.concurrency));
1662
+ const agentId = resolveDefaultAgentId(cfg);
1663
+ const agentDir = resolveAnimaAgentDir();
1664
+ const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId) ?? resolveDefaultAgentWorkspaceDir();
1665
+ const sessionDir = resolveSessionTranscriptsDirForAgent(agentId);
1666
+ await fs.mkdir(workspaceDir, { recursive: true });
1667
+ let completed = 0;
1668
+ const results = Array.from({ length: targets.length });
1669
+ let cursor = 0;
1670
+ const worker = async () => {
1671
+ while (true) {
1672
+ const index = cursor;
1673
+ cursor += 1;
1674
+ if (index >= targets.length) return;
1675
+ const target = targets[index];
1676
+ onProgress?.({
1677
+ completed,
1678
+ total: targets.length,
1679
+ label: `Probing ${target.provider}${target.profileId ? ` (${target.label})` : ""}`
1680
+ });
1681
+ results[index] = await probeTarget({
1682
+ cfg,
1683
+ agentId,
1684
+ agentDir,
1685
+ workspaceDir,
1686
+ sessionDir,
1687
+ target,
1688
+ timeoutMs,
1689
+ maxTokens
1690
+ });
1691
+ completed += 1;
1692
+ onProgress?.({
1693
+ completed,
1694
+ total: targets.length
1695
+ });
1696
+ }
1697
+ };
1698
+ await Promise.all(Array.from({ length: concurrency }, () => worker()));
1699
+ return results.filter((entry) => Boolean(entry));
1700
+ }
1701
+ async function runAuthProbes(params) {
1702
+ const startedAt = Date.now();
1703
+ const plan = await buildProbeTargets({
1704
+ cfg: params.cfg,
1705
+ providers: params.providers,
1706
+ modelCandidates: params.modelCandidates,
1707
+ options: params.options
1708
+ });
1709
+ const totalTargets = plan.targets.length;
1710
+ params.onProgress?.({
1711
+ completed: 0,
1712
+ total: totalTargets
1713
+ });
1714
+ const results = totalTargets ? await runTargetsWithConcurrency({
1715
+ cfg: params.cfg,
1716
+ targets: plan.targets,
1717
+ timeoutMs: params.options.timeoutMs,
1718
+ maxTokens: params.options.maxTokens,
1719
+ concurrency: params.options.concurrency,
1720
+ onProgress: params.onProgress
1721
+ }) : [];
1722
+ const finishedAt = Date.now();
1723
+ return {
1724
+ startedAt,
1725
+ finishedAt,
1726
+ durationMs: finishedAt - startedAt,
1727
+ totalTargets,
1728
+ options: params.options,
1729
+ results: [...plan.results, ...results]
1730
+ };
1731
+ }
1732
+ function formatProbeLatency(latencyMs) {
1733
+ if (!latencyMs && latencyMs !== 0) return "-";
1734
+ return formatMs(latencyMs);
1735
+ }
1736
+ function sortProbeResults(results) {
1737
+ return results.slice().toSorted((a, b) => {
1738
+ const provider = a.provider.localeCompare(b.provider);
1739
+ if (provider !== 0) return provider;
1740
+ const aLabel = a.label || a.profileId || "";
1741
+ const bLabel = b.label || b.profileId || "";
1742
+ return aLabel.localeCompare(bLabel);
1743
+ });
1744
+ }
1745
+ function describeProbeSummary(summary) {
1746
+ if (summary.totalTargets === 0) return "No probe targets.";
1747
+ return `Probed ${summary.totalTargets} target${summary.totalTargets === 1 ? "" : "s"} in ${formatMs(summary.durationMs)}`;
1748
+ }
1749
+
1750
+ //#endregion
1751
+ //#region src/commands/models/list.status-command.ts
1752
+ async function modelsStatusCommand(opts, runtime) {
1753
+ ensureFlagCompatibility(opts);
1754
+ if (opts.plain && opts.probe) throw new Error("--probe cannot be used with --plain output.");
1755
+ const cfg = loadConfig();
1756
+ const agentId = resolveKnownAgentId({
1757
+ cfg,
1758
+ rawAgentId: opts.agent
1759
+ });
1760
+ const agentDir = agentId ? resolveAgentDir(cfg, agentId) : resolveAnimaAgentDir();
1761
+ const agentModelPrimary = agentId ? resolveAgentModelPrimary(cfg, agentId) : void 0;
1762
+ const agentFallbacksOverride = agentId ? resolveAgentModelFallbacksOverride(cfg, agentId) : void 0;
1763
+ const resolved = agentId ? resolveDefaultModelForAgent({
1764
+ cfg,
1765
+ agentId
1766
+ }) : resolveConfiguredModelRef({
1767
+ cfg,
1768
+ defaultProvider: DEFAULT_PROVIDER,
1769
+ defaultModel: DEFAULT_MODEL
1770
+ });
1771
+ const modelConfig = cfg.agents?.defaults?.model;
1772
+ const imageConfig = cfg.agents?.defaults?.imageModel;
1773
+ const rawDefaultsModel = typeof modelConfig === "string" ? modelConfig.trim() : modelConfig?.primary?.trim() ?? "";
1774
+ const rawModel = agentModelPrimary ?? rawDefaultsModel;
1775
+ const resolvedLabel = `${resolved.provider}/${resolved.model}`;
1776
+ const defaultLabel = rawModel || resolvedLabel;
1777
+ const defaultsFallbacks = typeof modelConfig === "object" ? modelConfig?.fallbacks ?? [] : [];
1778
+ const fallbacks = agentFallbacksOverride ?? defaultsFallbacks;
1779
+ const imageModel = typeof imageConfig === "string" ? imageConfig.trim() : imageConfig?.primary?.trim() ?? "";
1780
+ const imageFallbacks = typeof imageConfig === "object" ? imageConfig?.fallbacks ?? [] : [];
1781
+ const aliases = Object.entries(cfg.agents?.defaults?.models ?? {}).reduce((acc, [key, entry]) => {
1782
+ const alias = typeof entry?.alias === "string" ? entry.alias.trim() : void 0;
1783
+ if (alias) acc[alias] = key;
1784
+ return acc;
1785
+ }, {});
1786
+ const allowed = Object.keys(cfg.agents?.defaults?.models ?? {});
1787
+ const store = ensureAuthProfileStore(agentDir);
1788
+ const modelsPath = path.join(agentDir, "models.json");
1789
+ const providersFromStore = new Set(Object.values(store.profiles).map((profile) => profile.provider).filter((p) => Boolean(p)));
1790
+ const providersFromConfig = new Set(Object.keys(cfg.models?.providers ?? {}).map((p) => typeof p === "string" ? p.trim() : "").filter(Boolean));
1791
+ const providersFromModels = /* @__PURE__ */ new Set();
1792
+ const providersInUse = /* @__PURE__ */ new Set();
1793
+ for (const raw of [
1794
+ defaultLabel,
1795
+ ...fallbacks,
1796
+ imageModel,
1797
+ ...imageFallbacks,
1798
+ ...allowed
1799
+ ]) {
1800
+ const parsed = parseModelRef(String(raw ?? ""), DEFAULT_PROVIDER);
1801
+ if (parsed?.provider) providersFromModels.add(parsed.provider);
1802
+ }
1803
+ for (const raw of [
1804
+ defaultLabel,
1805
+ ...fallbacks,
1806
+ imageModel,
1807
+ ...imageFallbacks
1808
+ ]) {
1809
+ const parsed = parseModelRef(String(raw ?? ""), DEFAULT_PROVIDER);
1810
+ if (parsed?.provider) providersInUse.add(parsed.provider);
1811
+ }
1812
+ const providersFromEnv = /* @__PURE__ */ new Set();
1813
+ for (const provider of [
1814
+ "anthropic",
1815
+ "github-copilot",
1816
+ "google-vertex",
1817
+ "openai",
1818
+ "google",
1819
+ "groq",
1820
+ "cerebras",
1821
+ "xai",
1822
+ "openrouter",
1823
+ "zai",
1824
+ "mistral",
1825
+ "synthetic"
1826
+ ]) if (resolveEnvApiKey(provider)) providersFromEnv.add(provider);
1827
+ const providers = Array.from(new Set([
1828
+ ...providersFromStore,
1829
+ ...providersFromConfig,
1830
+ ...providersFromModels,
1831
+ ...providersFromEnv
1832
+ ])).map((p) => typeof p === "string" ? p.trim() : "").filter(Boolean).toSorted((a, b) => a.localeCompare(b));
1833
+ const applied = getShellEnvAppliedKeys();
1834
+ const shellFallbackEnabled = shouldEnableShellEnvFallback(process.env) || cfg.env?.shellEnv?.enabled === true;
1835
+ const providerAuth = providers.map((provider) => resolveProviderAuthOverview({
1836
+ provider,
1837
+ cfg,
1838
+ store,
1839
+ modelsPath
1840
+ })).filter((entry) => {
1841
+ return entry.profiles.count > 0 || Boolean(entry.env) || Boolean(entry.modelsJson);
1842
+ });
1843
+ const providerAuthMap = new Map(providerAuth.map((entry) => [entry.provider, entry]));
1844
+ const missingProvidersInUse = Array.from(providersInUse).filter((provider) => !providerAuthMap.has(provider)).toSorted((a, b) => a.localeCompare(b));
1845
+ const probeProfileIds = (() => {
1846
+ if (!opts.probeProfile) return [];
1847
+ return (Array.isArray(opts.probeProfile) ? opts.probeProfile : [opts.probeProfile]).flatMap((value) => String(value ?? "").split(",")).map((value) => value.trim()).filter(Boolean);
1848
+ })();
1849
+ const probeTimeoutMs = opts.probeTimeout ? Number(opts.probeTimeout) : 8e3;
1850
+ if (!Number.isFinite(probeTimeoutMs) || probeTimeoutMs <= 0) throw new Error("--probe-timeout must be a positive number (ms).");
1851
+ const probeConcurrency = opts.probeConcurrency ? Number(opts.probeConcurrency) : 2;
1852
+ if (!Number.isFinite(probeConcurrency) || probeConcurrency <= 0) throw new Error("--probe-concurrency must be > 0.");
1853
+ const probeMaxTokens = opts.probeMaxTokens ? Number(opts.probeMaxTokens) : 8;
1854
+ if (!Number.isFinite(probeMaxTokens) || probeMaxTokens <= 0) throw new Error("--probe-max-tokens must be > 0.");
1855
+ const aliasIndex = buildModelAliasIndex({
1856
+ cfg,
1857
+ defaultProvider: DEFAULT_PROVIDER
1858
+ });
1859
+ const modelCandidates = [
1860
+ rawModel || resolvedLabel,
1861
+ ...fallbacks,
1862
+ imageModel,
1863
+ ...imageFallbacks,
1864
+ ...allowed
1865
+ ].filter(Boolean).map((raw) => resolveModelRefFromString({
1866
+ raw: String(raw ?? ""),
1867
+ defaultProvider: DEFAULT_PROVIDER,
1868
+ aliasIndex
1869
+ })?.ref).filter((ref) => Boolean(ref)).map((ref) => `${ref.provider}/${ref.model}`);
1870
+ let probeSummary;
1871
+ if (opts.probe) probeSummary = await withProgressTotals({
1872
+ label: "Probing auth profiles…",
1873
+ total: 1
1874
+ }, async (update) => {
1875
+ return await runAuthProbes({
1876
+ cfg,
1877
+ providers,
1878
+ modelCandidates,
1879
+ options: {
1880
+ provider: opts.probeProvider,
1881
+ profileIds: probeProfileIds,
1882
+ timeoutMs: probeTimeoutMs,
1883
+ concurrency: probeConcurrency,
1884
+ maxTokens: probeMaxTokens
1885
+ },
1886
+ onProgress: update
1887
+ });
1888
+ });
1889
+ const providersWithOauth = providerAuth.filter((entry) => entry.profiles.oauth > 0 || entry.profiles.token > 0 || entry.env?.value === "OAuth (env)").map((entry) => {
1890
+ const count = entry.profiles.oauth + entry.profiles.token + (entry.env?.value === "OAuth (env)" ? 1 : 0);
1891
+ return `${entry.provider} (${count})`;
1892
+ });
1893
+ const authHealth = buildAuthHealthSummary({
1894
+ store,
1895
+ cfg,
1896
+ warnAfterMs: DEFAULT_OAUTH_WARN_MS,
1897
+ providers
1898
+ });
1899
+ const oauthProfiles = authHealth.profiles.filter((profile) => profile.type === "oauth" || profile.type === "token");
1900
+ const unusableProfiles = (() => {
1901
+ const now = Date.now();
1902
+ const out = [];
1903
+ for (const profileId of Object.keys(store.usageStats ?? {})) {
1904
+ const unusableUntil = resolveProfileUnusableUntilForDisplay(store, profileId);
1905
+ if (!unusableUntil || now >= unusableUntil) continue;
1906
+ const stats = store.usageStats?.[profileId];
1907
+ const kind = typeof stats?.disabledUntil === "number" && now < stats.disabledUntil ? "disabled" : "cooldown";
1908
+ out.push({
1909
+ profileId,
1910
+ provider: store.profiles[profileId]?.provider,
1911
+ kind,
1912
+ reason: stats?.disabledReason,
1913
+ until: unusableUntil,
1914
+ remainingMs: unusableUntil - now
1915
+ });
1916
+ }
1917
+ return out.toSorted((a, b) => a.remainingMs - b.remainingMs);
1918
+ })();
1919
+ const checkStatus = (() => {
1920
+ const hasExpiredOrMissing = oauthProfiles.some((profile) => ["expired", "missing"].includes(profile.status)) || missingProvidersInUse.length > 0;
1921
+ const hasExpiring = oauthProfiles.some((profile) => profile.status === "expiring");
1922
+ if (hasExpiredOrMissing) return 1;
1923
+ if (hasExpiring) return 2;
1924
+ return 0;
1925
+ })();
1926
+ if (opts.json) {
1927
+ runtime.log(JSON.stringify({
1928
+ configPath: CONFIG_PATH,
1929
+ ...agentId ? { agentId } : {},
1930
+ agentDir,
1931
+ defaultModel: defaultLabel,
1932
+ resolvedDefault: resolvedLabel,
1933
+ fallbacks,
1934
+ imageModel: imageModel || null,
1935
+ imageFallbacks,
1936
+ ...agentId ? { modelConfig: {
1937
+ defaultSource: agentModelPrimary ? "agent" : "defaults",
1938
+ fallbacksSource: agentFallbacksOverride !== void 0 ? "agent" : "defaults"
1939
+ } } : {},
1940
+ aliases,
1941
+ allowed,
1942
+ auth: {
1943
+ storePath: resolveAuthStorePathForDisplay(agentDir),
1944
+ shellEnvFallback: {
1945
+ enabled: shellFallbackEnabled,
1946
+ appliedKeys: applied
1947
+ },
1948
+ providersWithOAuth: providersWithOauth,
1949
+ missingProvidersInUse,
1950
+ providers: providerAuth,
1951
+ unusableProfiles,
1952
+ oauth: {
1953
+ warnAfterMs: authHealth.warnAfterMs,
1954
+ profiles: authHealth.profiles,
1955
+ providers: authHealth.providers
1956
+ },
1957
+ probes: probeSummary
1958
+ }
1959
+ }, null, 2));
1960
+ if (opts.check) runtime.exit(checkStatus);
1961
+ return;
1962
+ }
1963
+ if (opts.plain) {
1964
+ runtime.log(resolvedLabel);
1965
+ if (opts.check) runtime.exit(checkStatus);
1966
+ return;
1967
+ }
1968
+ const rich = isRich(opts);
1969
+ const label = (value) => colorize(rich, theme.accent, value.padEnd(14));
1970
+ const labelWithSource = (value, source) => label(source ? `${value} (${source})` : value);
1971
+ const displayDefault = rawModel && rawModel !== resolvedLabel ? `${resolvedLabel} (from ${rawModel})` : resolvedLabel;
1972
+ runtime.log(`${label("Config")}${colorize(rich, theme.muted, ":")} ${colorize(rich, theme.info, shortenHomePath(CONFIG_PATH))}`);
1973
+ runtime.log(`${label("Agent dir")}${colorize(rich, theme.muted, ":")} ${colorize(rich, theme.info, shortenHomePath(agentDir))}`);
1974
+ runtime.log(`${labelWithSource("Default", agentId ? agentModelPrimary ? "agent" : "defaults" : void 0)}${colorize(rich, theme.muted, ":")} ${colorize(rich, theme.success, displayDefault)}`);
1975
+ 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(", ") : "-")}`);
1976
+ runtime.log(`${labelWithSource("Image model", agentId ? "defaults" : void 0)}${colorize(rich, theme.muted, ":")} ${colorize(rich, imageModel ? theme.accentBright : theme.muted, imageModel || "-")}`);
1977
+ 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(", ") : "-")}`);
1978
+ 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(", ") : "-")}`);
1979
+ 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")}`);
1980
+ runtime.log("");
1981
+ runtime.log(colorize(rich, theme.heading, "Auth overview"));
1982
+ runtime.log(`${label("Auth store")}${colorize(rich, theme.muted, ":")} ${colorize(rich, theme.info, shortenHomePath(resolveAuthStorePathForDisplay(agentDir)))}`);
1983
+ 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(", ")})`) : ""}`);
1984
+ 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(", ") : "-")}`);
1985
+ const formatKey = (key) => colorize(rich, theme.warn, key);
1986
+ const formatKeyValue = (key, value) => `${formatKey(key)}=${colorize(rich, theme.info, value)}`;
1987
+ const formatSeparator = () => colorize(rich, theme.muted, " | ");
1988
+ for (const entry of providerAuth) {
1989
+ const separator = formatSeparator();
1990
+ const bits = [];
1991
+ bits.push(formatKeyValue("effective", `${colorize(rich, theme.accentBright, entry.effective.kind)}:${colorize(rich, theme.muted, entry.effective.detail)}`));
1992
+ if (entry.profiles.count > 0) {
1993
+ bits.push(formatKeyValue("profiles", `${entry.profiles.count} (oauth=${entry.profiles.oauth}, token=${entry.profiles.token}, api_key=${entry.profiles.apiKey})`));
1994
+ if (entry.profiles.labels.length > 0) bits.push(colorize(rich, theme.info, entry.profiles.labels.join(", ")));
1995
+ }
1996
+ if (entry.env) bits.push(formatKeyValue("env", `${entry.env.value}${separator}${formatKeyValue("source", entry.env.source)}`));
1997
+ if (entry.modelsJson) bits.push(formatKeyValue("models.json", `${entry.modelsJson.value}${separator}${formatKeyValue("source", entry.modelsJson.source)}`));
1998
+ runtime.log(`- ${theme.heading(entry.provider)} ${bits.join(separator)}`);
1999
+ }
2000
+ if (missingProvidersInUse.length > 0) {
2001
+ runtime.log("");
2002
+ runtime.log(colorize(rich, theme.heading, "Missing auth"));
2003
+ for (const provider of missingProvidersInUse) {
2004
+ 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.`;
2005
+ runtime.log(`- ${theme.heading(provider)} ${hint}`);
2006
+ }
2007
+ }
2008
+ runtime.log("");
2009
+ runtime.log(colorize(rich, theme.heading, "OAuth/token status"));
2010
+ if (oauthProfiles.length === 0) runtime.log(colorize(rich, theme.muted, "- none"));
2011
+ else {
2012
+ const usageByProvider = /* @__PURE__ */ new Map();
2013
+ const usageProviders = Array.from(new Set(oauthProfiles.map((profile) => resolveUsageProviderId(profile.provider)).filter((provider) => Boolean(provider))));
2014
+ if (usageProviders.length > 0) try {
2015
+ const usageSummary = await loadProviderUsageSummary({
2016
+ providers: usageProviders,
2017
+ agentDir,
2018
+ timeoutMs: 3500
2019
+ });
2020
+ for (const snapshot of usageSummary.providers) {
2021
+ const formatted = formatUsageWindowSummary(snapshot, {
2022
+ now: Date.now(),
2023
+ maxWindows: 2,
2024
+ includeResets: true
2025
+ });
2026
+ if (formatted) usageByProvider.set(snapshot.provider, formatted);
2027
+ }
2028
+ } catch {}
2029
+ const formatStatus = (status) => {
2030
+ if (status === "ok") return colorize(rich, theme.success, "ok");
2031
+ if (status === "static") return colorize(rich, theme.muted, "static");
2032
+ if (status === "expiring") return colorize(rich, theme.warn, "expiring");
2033
+ if (status === "missing") return colorize(rich, theme.warn, "unknown");
2034
+ return colorize(rich, theme.error, "expired");
2035
+ };
2036
+ const profilesByProvider = /* @__PURE__ */ new Map();
2037
+ for (const profile of oauthProfiles) {
2038
+ const current = profilesByProvider.get(profile.provider);
2039
+ if (current) current.push(profile);
2040
+ else profilesByProvider.set(profile.provider, [profile]);
2041
+ }
2042
+ for (const [provider, profiles] of profilesByProvider) {
2043
+ const usageKey = resolveUsageProviderId(provider);
2044
+ const usage = usageKey ? usageByProvider.get(usageKey) : void 0;
2045
+ const usageSuffix = usage ? colorize(rich, theme.muted, ` usage: ${usage}`) : "";
2046
+ runtime.log(`- ${colorize(rich, theme.heading, provider)}${usageSuffix}`);
2047
+ for (const profile of profiles) {
2048
+ const labelText = profile.label || profile.profileId;
2049
+ const label = colorize(rich, theme.accent, labelText);
2050
+ const status = formatStatus(profile.status);
2051
+ const expiry = profile.status === "static" ? "" : profile.expiresAt ? ` expires in ${formatRemainingShort(profile.remainingMs)}` : " expires unknown";
2052
+ runtime.log(` - ${label} ${status}${expiry}`);
2053
+ }
2054
+ }
2055
+ }
2056
+ if (probeSummary) {
2057
+ runtime.log("");
2058
+ runtime.log(colorize(rich, theme.heading, "Auth probes"));
2059
+ if (probeSummary.results.length === 0) runtime.log(colorize(rich, theme.muted, "- none"));
2060
+ else {
2061
+ const tableWidth = Math.max(60, (process.stdout.columns ?? 120) - 1);
2062
+ const sorted = sortProbeResults(probeSummary.results);
2063
+ const statusColor = (status) => {
2064
+ if (status === "ok") return theme.success;
2065
+ if (status === "rate_limit") return theme.warn;
2066
+ if (status === "timeout" || status === "billing") return theme.warn;
2067
+ if (status === "auth" || status === "format") return theme.error;
2068
+ if (status === "no_model") return theme.muted;
2069
+ return theme.muted;
2070
+ };
2071
+ const rows = sorted.map((result) => {
2072
+ const status = colorize(rich, statusColor(result.status), result.status);
2073
+ const latency = formatProbeLatency(result.latencyMs);
2074
+ const modelLabel = result.model ?? `${result.provider}/-`;
2075
+ const modeLabel = result.mode ? ` ${colorize(rich, theme.muted, `(${result.mode})`)}` : "";
2076
+ const profile = `${colorize(rich, theme.accent, result.label)}${modeLabel}`;
2077
+ const detail = result.error?.trim();
2078
+ const detailLabel = detail ? `\n${colorize(rich, theme.muted, `↳ ${detail}`)}` : "";
2079
+ const statusLabel = `${status}${colorize(rich, theme.muted, ` · ${latency}`)}${detailLabel}`;
2080
+ return {
2081
+ Model: colorize(rich, theme.heading, modelLabel),
2082
+ Profile: profile,
2083
+ Status: statusLabel
2084
+ };
2085
+ });
2086
+ runtime.log(renderTable({
2087
+ width: tableWidth,
2088
+ columns: [
2089
+ {
2090
+ key: "Model",
2091
+ header: "Model",
2092
+ minWidth: 18
2093
+ },
2094
+ {
2095
+ key: "Profile",
2096
+ header: "Profile",
2097
+ minWidth: 24
2098
+ },
2099
+ {
2100
+ key: "Status",
2101
+ header: "Status",
2102
+ minWidth: 12
2103
+ }
2104
+ ],
2105
+ rows
2106
+ }).trimEnd());
2107
+ runtime.log(colorize(rich, theme.muted, describeProbeSummary(probeSummary)));
2108
+ }
2109
+ }
2110
+ if (opts.check) runtime.exit(checkStatus);
2111
+ }
2112
+
2113
+ //#endregion
2114
+ //#region src/commands/models/current.ts
2115
+ async function modelsCurrentCommand(opts, runtime) {
2116
+ ensureFlagCompatibility(opts);
2117
+ const cfg = loadConfig();
2118
+ const agentId = resolveKnownAgentId({
2119
+ cfg,
2120
+ rawAgentId: opts.agent
2121
+ }) ?? resolveAgentIdFromSessionKey(opts.sessionKey?.trim());
2122
+ const session = resolveSession({
2123
+ cfg,
2124
+ to: opts.to,
2125
+ sessionId: opts.sessionId,
2126
+ sessionKey: opts.sessionKey,
2127
+ agentId
2128
+ });
2129
+ const resolved = await resolveAgentModelSelection({
2130
+ cfg,
2131
+ agentId,
2132
+ sessionEntry: session.sessionEntry
2133
+ });
2134
+ const current = `${resolved.provider}/${resolved.model}`;
2135
+ const lastUsed = session.sessionEntry?.modelProvider && session.sessionEntry?.model ? `${session.sessionEntry.modelProvider}/${session.sessionEntry.model}` : void 0;
2136
+ if (opts.json) {
2137
+ runtime.log(JSON.stringify({
2138
+ agentId: agentId ?? resolveAgentIdFromSessionKey(session.sessionKey),
2139
+ sessionId: session.sessionId,
2140
+ sessionKey: session.sessionKey,
2141
+ current,
2142
+ provider: resolved.provider,
2143
+ model: resolved.model,
2144
+ source: resolved.source,
2145
+ default: `${resolved.defaultProvider}/${resolved.defaultModel}`,
2146
+ lastUsed
2147
+ }, null, 2));
2148
+ return;
2149
+ }
2150
+ if (opts.plain) {
2151
+ runtime.log(current);
2152
+ return;
2153
+ }
2154
+ runtime.log(`Current model: ${current}`);
2155
+ runtime.log(`Source: ${resolved.source}`);
2156
+ runtime.log(`Default: ${resolved.defaultProvider}/${resolved.defaultModel}`);
2157
+ if (lastUsed) runtime.log(`Last used: ${lastUsed}`);
2158
+ if (session.sessionKey) runtime.log(`Session: ${session.sessionKey}`);
2159
+ }
2160
+
2161
+ //#endregion
2162
+ //#region src/agents/model-scan.ts
2163
+ const OPENROUTER_MODELS_URL = "https://openrouter.ai/api/v1/models";
2164
+ const DEFAULT_TIMEOUT_MS = 12e3;
2165
+ const DEFAULT_CONCURRENCY = 3;
2166
+ const BASE_IMAGE_PNG = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X3mIAAAAASUVORK5CYII=";
2167
+ const TOOL_PING = {
2168
+ name: "ping",
2169
+ description: "Return OK.",
2170
+ parameters: Type.Object({})
2171
+ };
2172
+ function normalizeCreatedAtMs(value) {
2173
+ if (typeof value !== "number" || !Number.isFinite(value)) return null;
2174
+ if (value <= 0) return null;
2175
+ if (value > 0xe8d4a51000) return Math.round(value);
2176
+ return Math.round(value * 1e3);
2177
+ }
2178
+ function parseModality(modality) {
2179
+ if (!modality) return ["text"];
2180
+ return modality.toLowerCase().split(/[^a-z]+/).filter(Boolean).includes("image") ? ["text", "image"] : ["text"];
2181
+ }
2182
+ function parseNumberString(value) {
2183
+ if (typeof value === "number" && Number.isFinite(value)) return value;
2184
+ if (typeof value !== "string") return null;
2185
+ const trimmed = value.trim();
2186
+ if (!trimmed) return null;
2187
+ const num = Number(trimmed);
2188
+ if (!Number.isFinite(num)) return null;
2189
+ return num;
2190
+ }
2191
+ function parseOpenRouterPricing(value) {
2192
+ if (!value || typeof value !== "object") return null;
2193
+ const obj = value;
2194
+ const prompt = parseNumberString(obj.prompt);
2195
+ const completion = parseNumberString(obj.completion);
2196
+ const request = parseNumberString(obj.request) ?? 0;
2197
+ const image = parseNumberString(obj.image) ?? 0;
2198
+ const webSearch = parseNumberString(obj.web_search) ?? 0;
2199
+ const internalReasoning = parseNumberString(obj.internal_reasoning) ?? 0;
2200
+ if (prompt === null || completion === null) return null;
2201
+ return {
2202
+ prompt,
2203
+ completion,
2204
+ request,
2205
+ image,
2206
+ webSearch,
2207
+ internalReasoning
2208
+ };
2209
+ }
2210
+ function isFreeOpenRouterModel(entry) {
2211
+ if (entry.id.endsWith(":free")) return true;
2212
+ if (!entry.pricing) return false;
2213
+ return entry.pricing.prompt === 0 && entry.pricing.completion === 0;
2214
+ }
2215
+ async function withTimeout(timeoutMs, fn) {
2216
+ const controller = new AbortController();
2217
+ const timer = setTimeout(controller.abort.bind(controller), timeoutMs);
2218
+ try {
2219
+ return await fn(controller.signal);
2220
+ } finally {
2221
+ clearTimeout(timer);
2222
+ }
2223
+ }
2224
+ async function fetchOpenRouterModels(fetchImpl) {
2225
+ const res = await fetchImpl(OPENROUTER_MODELS_URL, { headers: { Accept: "application/json" } });
2226
+ if (!res.ok) throw new Error(`OpenRouter /models failed: HTTP ${res.status}`);
2227
+ const payload = await res.json();
2228
+ return (Array.isArray(payload.data) ? payload.data : []).map((entry) => {
2229
+ if (!entry || typeof entry !== "object") return null;
2230
+ const obj = entry;
2231
+ const id = typeof obj.id === "string" ? obj.id.trim() : "";
2232
+ if (!id) return null;
2233
+ const name = typeof obj.name === "string" && obj.name.trim() ? obj.name.trim() : id;
2234
+ const contextLength = typeof obj.context_length === "number" && Number.isFinite(obj.context_length) ? obj.context_length : null;
2235
+ 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;
2236
+ const supportedParameters = Array.isArray(obj.supported_parameters) ? obj.supported_parameters.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : [];
2237
+ return {
2238
+ id,
2239
+ name,
2240
+ contextLength,
2241
+ maxCompletionTokens,
2242
+ supportedParameters,
2243
+ supportedParametersCount: supportedParameters.length,
2244
+ supportsToolsMeta: supportedParameters.includes("tools"),
2245
+ modality: typeof obj.modality === "string" && obj.modality.trim() ? obj.modality.trim() : null,
2246
+ inferredParamB: inferParamBFromIdOrName(`${id} ${name}`),
2247
+ createdAtMs: normalizeCreatedAtMs(obj.created_at),
2248
+ pricing: parseOpenRouterPricing(obj.pricing)
2249
+ };
2250
+ }).filter((entry) => Boolean(entry));
2251
+ }
2252
+ async function probeTool(model, apiKey, timeoutMs) {
2253
+ const context = {
2254
+ messages: [{
2255
+ role: "user",
2256
+ content: "Call the ping tool with {} and nothing else.",
2257
+ timestamp: Date.now()
2258
+ }],
2259
+ tools: [TOOL_PING]
2260
+ };
2261
+ const startedAt = Date.now();
2262
+ try {
2263
+ if (!(await withTimeout(timeoutMs, (signal) => complete(model, context, {
2264
+ apiKey,
2265
+ maxTokens: 32,
2266
+ temperature: 0,
2267
+ toolChoice: "required",
2268
+ signal
2269
+ }))).content.some((block) => block.type === "toolCall")) return {
2270
+ ok: false,
2271
+ latencyMs: Date.now() - startedAt,
2272
+ error: "No tool call returned"
2273
+ };
2274
+ return {
2275
+ ok: true,
2276
+ latencyMs: Date.now() - startedAt
2277
+ };
2278
+ } catch (err) {
2279
+ return {
2280
+ ok: false,
2281
+ latencyMs: Date.now() - startedAt,
2282
+ error: err instanceof Error ? err.message : String(err)
2283
+ };
2284
+ }
2285
+ }
2286
+ async function probeImage(model, apiKey, timeoutMs) {
2287
+ const context = { messages: [{
2288
+ role: "user",
2289
+ content: [{
2290
+ type: "text",
2291
+ text: "Reply with OK."
2292
+ }, {
2293
+ type: "image",
2294
+ data: BASE_IMAGE_PNG,
2295
+ mimeType: "image/png"
2296
+ }],
2297
+ timestamp: Date.now()
2298
+ }] };
2299
+ const startedAt = Date.now();
2300
+ try {
2301
+ await withTimeout(timeoutMs, (signal) => complete(model, context, {
2302
+ apiKey,
2303
+ maxTokens: 16,
2304
+ temperature: 0,
2305
+ signal
2306
+ }));
2307
+ return {
2308
+ ok: true,
2309
+ latencyMs: Date.now() - startedAt
2310
+ };
2311
+ } catch (err) {
2312
+ return {
2313
+ ok: false,
2314
+ latencyMs: Date.now() - startedAt,
2315
+ error: err instanceof Error ? err.message : String(err)
2316
+ };
2317
+ }
2318
+ }
2319
+ function ensureImageInput(model) {
2320
+ if (model.input.includes("image")) return model;
2321
+ return {
2322
+ ...model,
2323
+ input: Array.from(new Set([...model.input, "image"]))
2324
+ };
2325
+ }
2326
+ async function mapWithConcurrency(items, concurrency, fn, opts) {
2327
+ const limit = Math.max(1, Math.floor(concurrency));
2328
+ const results = Array.from({ length: items.length }, () => void 0);
2329
+ let nextIndex = 0;
2330
+ let completed = 0;
2331
+ const worker = async () => {
2332
+ while (true) {
2333
+ const current = nextIndex;
2334
+ nextIndex += 1;
2335
+ if (current >= items.length) return;
2336
+ results[current] = await fn(items[current], current);
2337
+ completed += 1;
2338
+ opts?.onProgress?.(completed, items.length);
2339
+ }
2340
+ };
2341
+ if (items.length === 0) {
2342
+ opts?.onProgress?.(0, 0);
2343
+ return results;
2344
+ }
2345
+ await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()));
2346
+ return results;
2347
+ }
2348
+ async function scanOpenRouterModels(options = {}) {
2349
+ const fetchImpl = options.fetchImpl ?? fetch;
2350
+ const probe = options.probe ?? true;
2351
+ const apiKey = options.apiKey?.trim() || getEnvApiKey("openrouter") || "";
2352
+ if (probe && !apiKey) throw new Error("Missing OpenRouter API key. Set OPENROUTER_API_KEY to run models scan.");
2353
+ const timeoutMs = Math.max(1, Math.floor(options.timeoutMs ?? DEFAULT_TIMEOUT_MS));
2354
+ const concurrency = Math.max(1, Math.floor(options.concurrency ?? DEFAULT_CONCURRENCY));
2355
+ const minParamB = Math.max(0, Math.floor(options.minParamB ?? 0));
2356
+ const maxAgeDays = Math.max(0, Math.floor(options.maxAgeDays ?? 0));
2357
+ const providerFilter = options.providerFilter?.trim().toLowerCase() ?? "";
2358
+ const catalog = await fetchOpenRouterModels(fetchImpl);
2359
+ const now = Date.now();
2360
+ const filtered = catalog.filter((entry) => {
2361
+ if (!isFreeOpenRouterModel(entry)) return false;
2362
+ if (providerFilter) {
2363
+ if ((entry.id.split("/")[0]?.toLowerCase() ?? "") !== providerFilter) return false;
2364
+ }
2365
+ if (minParamB > 0) {
2366
+ if ((entry.inferredParamB ?? 0) < minParamB) return false;
2367
+ }
2368
+ if (maxAgeDays > 0 && entry.createdAtMs) {
2369
+ if ((now - entry.createdAtMs) / (1440 * 60 * 1e3) > maxAgeDays) return false;
2370
+ }
2371
+ return true;
2372
+ });
2373
+ const baseModel = getModel("openrouter", "openrouter/auto");
2374
+ options.onProgress?.({
2375
+ phase: "probe",
2376
+ completed: 0,
2377
+ total: filtered.length
2378
+ });
2379
+ return mapWithConcurrency(filtered, concurrency, async (entry) => {
2380
+ const isFree = isFreeOpenRouterModel(entry);
2381
+ if (!probe) return {
2382
+ id: entry.id,
2383
+ name: entry.name,
2384
+ provider: "openrouter",
2385
+ modelRef: `openrouter/${entry.id}`,
2386
+ contextLength: entry.contextLength,
2387
+ maxCompletionTokens: entry.maxCompletionTokens,
2388
+ supportedParametersCount: entry.supportedParametersCount,
2389
+ supportsToolsMeta: entry.supportsToolsMeta,
2390
+ modality: entry.modality,
2391
+ inferredParamB: entry.inferredParamB,
2392
+ createdAtMs: entry.createdAtMs,
2393
+ pricing: entry.pricing,
2394
+ isFree,
2395
+ tool: {
2396
+ ok: false,
2397
+ latencyMs: null,
2398
+ skipped: true
2399
+ },
2400
+ image: {
2401
+ ok: false,
2402
+ latencyMs: null,
2403
+ skipped: true
2404
+ }
2405
+ };
2406
+ const model = {
2407
+ ...baseModel,
2408
+ id: entry.id,
2409
+ name: entry.name || entry.id,
2410
+ contextWindow: entry.contextLength ?? baseModel.contextWindow,
2411
+ maxTokens: entry.maxCompletionTokens ?? baseModel.maxTokens,
2412
+ input: parseModality(entry.modality),
2413
+ reasoning: baseModel.reasoning
2414
+ };
2415
+ const toolResult = await probeTool(model, apiKey, timeoutMs);
2416
+ const imageResult = model.input.includes("image") ? await probeImage(ensureImageInput(model), apiKey, timeoutMs) : {
2417
+ ok: false,
2418
+ latencyMs: null,
2419
+ skipped: true
2420
+ };
2421
+ return {
2422
+ id: entry.id,
2423
+ name: entry.name,
2424
+ provider: "openrouter",
2425
+ modelRef: `openrouter/${entry.id}`,
2426
+ contextLength: entry.contextLength,
2427
+ maxCompletionTokens: entry.maxCompletionTokens,
2428
+ supportedParametersCount: entry.supportedParametersCount,
2429
+ supportsToolsMeta: entry.supportsToolsMeta,
2430
+ modality: entry.modality,
2431
+ inferredParamB: entry.inferredParamB,
2432
+ createdAtMs: entry.createdAtMs,
2433
+ pricing: entry.pricing,
2434
+ isFree,
2435
+ tool: toolResult,
2436
+ image: imageResult
2437
+ };
2438
+ }, { onProgress: (completed, total) => options.onProgress?.({
2439
+ phase: "probe",
2440
+ completed,
2441
+ total
2442
+ }) });
2443
+ }
2444
+
2445
+ //#endregion
2446
+ //#region src/commands/models/scan.ts
2447
+ const MODEL_PAD = 42;
2448
+ const CTX_PAD = 8;
2449
+ const multiselect$1 = (params) => multiselect({
2450
+ ...params,
2451
+ message: stylePromptMessage(params.message),
2452
+ options: params.options.map((opt) => opt.hint === void 0 ? opt : {
2453
+ ...opt,
2454
+ hint: stylePromptHint(opt.hint)
2455
+ })
2456
+ });
2457
+ const pad = (value, size) => value.padEnd(size);
2458
+ const truncate = (value, max) => {
2459
+ if (value.length <= max) return value;
2460
+ if (max <= 3) return value.slice(0, max);
2461
+ return `${value.slice(0, max - 3)}...`;
2462
+ };
2463
+ function sortScanResults(results) {
2464
+ return results.slice().toSorted((a, b) => {
2465
+ const aImage = a.image.ok ? 1 : 0;
2466
+ const bImage = b.image.ok ? 1 : 0;
2467
+ if (aImage !== bImage) return bImage - aImage;
2468
+ const aToolLatency = a.tool.latencyMs ?? Number.POSITIVE_INFINITY;
2469
+ const bToolLatency = b.tool.latencyMs ?? Number.POSITIVE_INFINITY;
2470
+ if (aToolLatency !== bToolLatency) return aToolLatency - bToolLatency;
2471
+ return compareScanMetadata(a, b);
2472
+ });
2473
+ }
2474
+ function sortImageResults(results) {
2475
+ return results.slice().toSorted((a, b) => {
2476
+ const aLatency = a.image.latencyMs ?? Number.POSITIVE_INFINITY;
2477
+ const bLatency = b.image.latencyMs ?? Number.POSITIVE_INFINITY;
2478
+ if (aLatency !== bLatency) return aLatency - bLatency;
2479
+ return compareScanMetadata(a, b);
2480
+ });
2481
+ }
2482
+ function compareScanMetadata(a, b) {
2483
+ const aCtx = a.contextLength ?? 0;
2484
+ const bCtx = b.contextLength ?? 0;
2485
+ if (aCtx !== bCtx) return bCtx - aCtx;
2486
+ const aParams = a.inferredParamB ?? 0;
2487
+ const bParams = b.inferredParamB ?? 0;
2488
+ if (aParams !== bParams) return bParams - aParams;
2489
+ return a.modelRef.localeCompare(b.modelRef);
2490
+ }
2491
+ function buildScanHint(result) {
2492
+ return [
2493
+ result.tool.ok ? `tool ${formatMs(result.tool.latencyMs)}` : "tool fail",
2494
+ result.image.skipped ? "img skip" : result.image.ok ? `img ${formatMs(result.image.latencyMs)}` : "img fail",
2495
+ result.contextLength ? `ctx ${formatTokenK(result.contextLength)}` : "ctx ?",
2496
+ result.inferredParamB ? `${result.inferredParamB}b` : null
2497
+ ].filter(Boolean).join(" | ");
2498
+ }
2499
+ function printScanSummary(results, runtime) {
2500
+ const toolOk = results.filter((r) => r.tool.ok);
2501
+ const imageOk = results.filter((r) => r.image.ok);
2502
+ const toolImageOk = results.filter((r) => r.tool.ok && r.image.ok);
2503
+ const imageOnly = imageOk.filter((r) => !r.tool.ok);
2504
+ runtime.log(`Scan results: tested ${results.length}, tool ok ${toolOk.length}, image ok ${imageOk.length}, tool+image ok ${toolImageOk.length}, image only ${imageOnly.length}`);
2505
+ }
2506
+ function printScanTable(results, runtime) {
2507
+ const header = [
2508
+ pad("Model", MODEL_PAD),
2509
+ pad("Tool", 10),
2510
+ pad("Image", 10),
2511
+ pad("Ctx", CTX_PAD),
2512
+ pad("Params", 8),
2513
+ "Notes"
2514
+ ].join(" ");
2515
+ runtime.log(header);
2516
+ for (const entry of results) {
2517
+ const modelLabel = pad(truncate(entry.modelRef, MODEL_PAD), MODEL_PAD);
2518
+ const toolLabel = pad(entry.tool.ok ? formatMs(entry.tool.latencyMs) : "fail", 10);
2519
+ const imageLabel = pad(entry.image.ok ? formatMs(entry.image.latencyMs) : entry.image.skipped ? "skip" : "fail", 10);
2520
+ const ctxLabel = pad(formatTokenK(entry.contextLength), CTX_PAD);
2521
+ const paramsLabel = pad(entry.inferredParamB ? `${entry.inferredParamB}b` : "-", 8);
2522
+ const notes = entry.modality ? `modality:${entry.modality}` : "";
2523
+ runtime.log([
2524
+ modelLabel,
2525
+ toolLabel,
2526
+ imageLabel,
2527
+ ctxLabel,
2528
+ paramsLabel,
2529
+ notes
2530
+ ].join(" "));
2531
+ }
2532
+ }
2533
+ async function modelsScanCommand(opts, runtime) {
2534
+ const minParams = opts.minParams ? Number(opts.minParams) : void 0;
2535
+ if (minParams !== void 0 && (!Number.isFinite(minParams) || minParams < 0)) throw new Error("--min-params must be >= 0");
2536
+ const maxAgeDays = opts.maxAgeDays ? Number(opts.maxAgeDays) : void 0;
2537
+ if (maxAgeDays !== void 0 && (!Number.isFinite(maxAgeDays) || maxAgeDays < 0)) throw new Error("--max-age-days must be >= 0");
2538
+ const maxCandidates = opts.maxCandidates ? Number(opts.maxCandidates) : 6;
2539
+ if (!Number.isFinite(maxCandidates) || maxCandidates <= 0) throw new Error("--max-candidates must be > 0");
2540
+ const timeout = opts.timeout ? Number(opts.timeout) : void 0;
2541
+ if (timeout !== void 0 && (!Number.isFinite(timeout) || timeout <= 0)) throw new Error("--timeout must be > 0");
2542
+ const concurrency = opts.concurrency ? Number(opts.concurrency) : void 0;
2543
+ if (concurrency !== void 0 && (!Number.isFinite(concurrency) || concurrency <= 0)) throw new Error("--concurrency must be > 0");
2544
+ const cfg = loadConfig();
2545
+ const probe = opts.probe ?? true;
2546
+ let storedKey;
2547
+ if (probe) try {
2548
+ storedKey = (await resolveApiKeyForProvider({
2549
+ provider: "openrouter",
2550
+ cfg
2551
+ })).apiKey;
2552
+ } catch {
2553
+ storedKey = void 0;
2554
+ }
2555
+ const results = await withProgressTotals({
2556
+ label: "Scanning OpenRouter models...",
2557
+ indeterminate: false,
2558
+ enabled: opts.json !== true
2559
+ }, async (update) => await scanOpenRouterModels({
2560
+ apiKey: storedKey ?? void 0,
2561
+ minParamB: minParams,
2562
+ maxAgeDays,
2563
+ providerFilter: opts.provider,
2564
+ timeoutMs: timeout,
2565
+ concurrency,
2566
+ probe,
2567
+ onProgress: ({ phase, completed, total }) => {
2568
+ if (phase !== "probe") return;
2569
+ update({
2570
+ completed,
2571
+ total,
2572
+ label: `${probe ? "Probing models" : "Scanning models"} (${completed}/${total})`
2573
+ });
2574
+ }
2575
+ }));
2576
+ if (!probe) {
2577
+ if (!opts.json) {
2578
+ runtime.log(`Found ${results.length} OpenRouter free models (metadata only; pass --probe to test tools/images).`);
2579
+ printScanTable(sortScanResults(results), runtime);
2580
+ } else runtime.log(JSON.stringify(results, null, 2));
2581
+ return;
2582
+ }
2583
+ const toolOk = results.filter((entry) => entry.tool.ok);
2584
+ if (toolOk.length === 0) throw new Error("No tool-capable OpenRouter free models found.");
2585
+ const sorted = sortScanResults(results);
2586
+ const toolSorted = sortScanResults(toolOk);
2587
+ const imageSorted = sortImageResults(results.filter((entry) => entry.image.ok));
2588
+ const imagePreferred = toolSorted.filter((entry) => entry.image.ok);
2589
+ const preselected = (imagePreferred.length > 0 ? imagePreferred : toolSorted).slice(0, Math.floor(maxCandidates)).map((entry) => entry.modelRef);
2590
+ const imagePreselected = imageSorted.slice(0, Math.floor(maxCandidates)).map((entry) => entry.modelRef);
2591
+ if (!opts.json) {
2592
+ printScanSummary(results, runtime);
2593
+ printScanTable(sorted, runtime);
2594
+ }
2595
+ const noInput = opts.input === false;
2596
+ const canPrompt = process.stdin.isTTY && !opts.yes && !noInput && !opts.json;
2597
+ let selected = preselected;
2598
+ let selectedImages = imagePreselected;
2599
+ if (canPrompt) {
2600
+ const selection = await multiselect$1({
2601
+ message: "Select fallback models (ordered)",
2602
+ options: toolSorted.map((entry) => ({
2603
+ value: entry.modelRef,
2604
+ label: entry.modelRef,
2605
+ hint: buildScanHint(entry)
2606
+ })),
2607
+ initialValues: preselected
2608
+ });
2609
+ if (isCancel(selection)) {
2610
+ cancel(stylePromptTitle("Model scan cancelled.") ?? "Model scan cancelled.");
2611
+ runtime.exit(0);
2612
+ }
2613
+ selected = selection;
2614
+ if (imageSorted.length > 0) {
2615
+ const imageSelection = await multiselect$1({
2616
+ message: "Select image fallback models (ordered)",
2617
+ options: imageSorted.map((entry) => ({
2618
+ value: entry.modelRef,
2619
+ label: entry.modelRef,
2620
+ hint: buildScanHint(entry)
2621
+ })),
2622
+ initialValues: imagePreselected
2623
+ });
2624
+ if (isCancel(imageSelection)) {
2625
+ cancel(stylePromptTitle("Model scan cancelled.") ?? "Model scan cancelled.");
2626
+ runtime.exit(0);
2627
+ }
2628
+ selectedImages = imageSelection;
2629
+ }
2630
+ } else if (!process.stdin.isTTY && !opts.yes && !noInput && !opts.json) throw new Error("Non-interactive scan: pass --yes to apply defaults.");
2631
+ if (selected.length === 0) throw new Error("No models selected for fallbacks.");
2632
+ if (opts.setImage && selectedImages.length === 0) throw new Error("No image-capable models selected for image model.");
2633
+ await updateConfig((cfg) => {
2634
+ const nextModels = { ...cfg.agents?.defaults?.models };
2635
+ for (const entry of selected) if (!nextModels[entry]) nextModels[entry] = {};
2636
+ for (const entry of selectedImages) if (!nextModels[entry]) nextModels[entry] = {};
2637
+ const existingImageModel = cfg.agents?.defaults?.imageModel;
2638
+ const nextImageModel = selectedImages.length > 0 ? {
2639
+ ...existingImageModel?.primary ? { primary: existingImageModel.primary } : void 0,
2640
+ fallbacks: selectedImages,
2641
+ ...opts.setImage ? { primary: selectedImages[0] } : {}
2642
+ } : cfg.agents?.defaults?.imageModel;
2643
+ const existingModel = cfg.agents?.defaults?.model;
2644
+ const defaults = {
2645
+ ...cfg.agents?.defaults,
2646
+ model: {
2647
+ ...existingModel?.primary ? { primary: existingModel.primary } : void 0,
2648
+ fallbacks: selected,
2649
+ ...opts.setDefault ? { primary: selected[0] } : {}
2650
+ },
2651
+ ...nextImageModel ? { imageModel: nextImageModel } : {},
2652
+ models: nextModels
2653
+ };
2654
+ return {
2655
+ ...cfg,
2656
+ agents: {
2657
+ ...cfg.agents,
2658
+ defaults
2659
+ }
2660
+ };
2661
+ });
2662
+ if (opts.json) {
2663
+ runtime.log(JSON.stringify({
2664
+ selected,
2665
+ selectedImages,
2666
+ setDefault: Boolean(opts.setDefault),
2667
+ setImage: Boolean(opts.setImage),
2668
+ results,
2669
+ warnings: []
2670
+ }, null, 2));
2671
+ return;
2672
+ }
2673
+ logConfigUpdated(runtime);
2674
+ runtime.log(`Fallbacks: ${selected.join(", ")}`);
2675
+ if (selectedImages.length > 0) runtime.log(`Image fallbacks: ${selectedImages.join(", ")}`);
2676
+ if (opts.setDefault) runtime.log(`Default model: ${selected[0]}`);
2677
+ if (opts.setImage && selectedImages.length > 0) runtime.log(`Image model: ${selectedImages[0]}`);
2678
+ }
2679
+
2680
+ //#endregion
2681
+ //#region src/commands/models/set.ts
2682
+ async function modelsSetCommand(modelRaw, runtime) {
2683
+ const updated = await updateConfig((cfg) => {
2684
+ const resolved = resolveModelTarget({
2685
+ raw: modelRaw,
2686
+ cfg
2687
+ });
2688
+ const key = `${resolved.provider}/${resolved.model}`;
2689
+ const nextModels = { ...cfg.agents?.defaults?.models };
2690
+ if (!nextModels[key]) nextModels[key] = {};
2691
+ const existingModel = cfg.agents?.defaults?.model;
2692
+ return {
2693
+ ...cfg,
2694
+ agents: {
2695
+ ...cfg.agents,
2696
+ defaults: {
2697
+ ...cfg.agents?.defaults,
2698
+ model: {
2699
+ ...existingModel?.fallbacks ? { fallbacks: existingModel.fallbacks } : void 0,
2700
+ primary: key
2701
+ },
2702
+ models: nextModels
2703
+ }
2704
+ }
2705
+ };
2706
+ });
2707
+ logConfigUpdated(runtime);
2708
+ runtime.log(`Default model: ${updated.agents?.defaults?.model?.primary ?? modelRaw}`);
2709
+ }
2710
+
2711
+ //#endregion
2712
+ //#region src/commands/models/set-image.ts
2713
+ async function modelsSetImageCommand(modelRaw, runtime) {
2714
+ const updated = await updateConfig((cfg) => {
2715
+ const resolved = resolveModelTarget({
2716
+ raw: modelRaw,
2717
+ cfg
2718
+ });
2719
+ const key = `${resolved.provider}/${resolved.model}`;
2720
+ const nextModels = { ...cfg.agents?.defaults?.models };
2721
+ if (!nextModels[key]) nextModels[key] = {};
2722
+ const existingModel = cfg.agents?.defaults?.imageModel;
2723
+ return {
2724
+ ...cfg,
2725
+ agents: {
2726
+ ...cfg.agents,
2727
+ defaults: {
2728
+ ...cfg.agents?.defaults,
2729
+ imageModel: {
2730
+ ...existingModel?.fallbacks ? { fallbacks: existingModel.fallbacks } : void 0,
2731
+ primary: key
2732
+ },
2733
+ models: nextModels
2734
+ }
2735
+ }
2736
+ };
2737
+ });
2738
+ logConfigUpdated(runtime);
2739
+ runtime.log(`Image model: ${updated.agents?.defaults?.imageModel?.primary ?? modelRaw}`);
2740
+ }
2741
+
2742
+ //#endregion
2743
+ //#region src/cli/models-cli.ts
2744
+ function runModelsCommand(action) {
2745
+ return runCommandWithRuntime(defaultRuntime, action);
2746
+ }
2747
+ function registerModelsCli(program) {
2748
+ const models = program.command("models").description("Model discovery, auth profiles, and provider 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 ANIMA_AGENT_DIR/PI_CODING_AGENT_DIR)").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/cli/models", "docs.noxsoft.net/anima/cli/models")}\n`);
2749
+ models.command("list").description("List available and configured models").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) => {
2750
+ await runModelsCommand(async () => {
2751
+ await modelsListCommand(opts, defaultRuntime);
2752
+ });
2753
+ });
2754
+ models.command("status").description("Show model provider status and auth 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) => {
2755
+ const next = Array.isArray(previous) ? previous : previous ? [previous] : [];
2756
+ next.push(value);
2757
+ return next;
2758
+ }).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 ANIMA_AGENT_DIR/PI_CODING_AGENT_DIR)").action(async (opts, command) => {
2759
+ const agent = resolveOptionFromCommand(command, "agent") ?? opts.agent;
2760
+ await runModelsCommand(async () => {
2761
+ await modelsStatusCommand({
2762
+ json: Boolean(opts.json),
2763
+ plain: Boolean(opts.plain),
2764
+ check: Boolean(opts.check),
2765
+ probe: Boolean(opts.probe),
2766
+ probeProvider: opts.probeProvider,
2767
+ probeProfile: opts.probeProfile,
2768
+ probeTimeout: opts.probeTimeout,
2769
+ probeConcurrency: opts.probeConcurrency,
2770
+ probeMaxTokens: opts.probeMaxTokens,
2771
+ agent
2772
+ }, defaultRuntime);
2773
+ });
2774
+ });
2775
+ models.command("current").description("Show the current effective model for an agent or session").option("--agent <id>", "Agent id to inspect").option("--to <number>", "Resolve the session key from an E.164 recipient").option("--session-id <id>", "Inspect a specific session id").option("--session-key <key>", "Inspect a specific session key").option("--json", "Output JSON", false).option("--plain", "Plain output", false).action(async (opts) => {
2776
+ await runModelsCommand(async () => {
2777
+ await modelsCurrentCommand({
2778
+ agent: opts.agent,
2779
+ to: opts.to,
2780
+ sessionId: opts.sessionId,
2781
+ sessionKey: opts.sessionKey,
2782
+ json: Boolean(opts.json),
2783
+ plain: Boolean(opts.plain)
2784
+ }, defaultRuntime);
2785
+ });
2786
+ });
2787
+ models.command("set").description("Set the primary inference model").argument("<model>", "Model id or alias").action(async (model) => {
2788
+ await runModelsCommand(async () => {
2789
+ await modelsSetCommand(model, defaultRuntime);
2790
+ });
2791
+ });
2792
+ models.command("set-image").description("Set the image generation model").argument("<model>", "Model id or alias").action(async (model) => {
2793
+ await runModelsCommand(async () => {
2794
+ await modelsSetImageCommand(model, defaultRuntime);
2795
+ });
2796
+ });
2797
+ const aliases = models.command("aliases").description("Create and manage model aliases");
2798
+ aliases.command("list").description("List all model aliases").option("--json", "Output JSON", false).option("--plain", "Plain output", false).action(async (opts) => {
2799
+ await runModelsCommand(async () => {
2800
+ await modelsAliasesListCommand(opts, defaultRuntime);
2801
+ });
2802
+ });
2803
+ aliases.command("add").description("Create or update a model alias").argument("<alias>", "Alias name").argument("<model>", "Model id or alias").action(async (alias, model) => {
2804
+ await runModelsCommand(async () => {
2805
+ await modelsAliasesAddCommand(alias, model, defaultRuntime);
2806
+ });
2807
+ });
2808
+ aliases.command("remove").description("Delete a model alias").argument("<alias>", "Alias name").action(async (alias) => {
2809
+ await runModelsCommand(async () => {
2810
+ await modelsAliasesRemoveCommand(alias, defaultRuntime);
2811
+ });
2812
+ });
2813
+ const fallbacks = models.command("fallbacks").description("Configure model fallback chain");
2814
+ fallbacks.command("list").description("List the model fallback chain").option("--json", "Output JSON", false).option("--plain", "Plain output", false).action(async (opts) => {
2815
+ await runModelsCommand(async () => {
2816
+ await modelsFallbacksListCommand(opts, defaultRuntime);
2817
+ });
2818
+ });
2819
+ fallbacks.command("add").description("Append a model to the fallback chain").argument("<model>", "Model id or alias").action(async (model) => {
2820
+ await runModelsCommand(async () => {
2821
+ await modelsFallbacksAddCommand(model, defaultRuntime);
2822
+ });
2823
+ });
2824
+ fallbacks.command("remove").description("Remove a model from the fallback chain").argument("<model>", "Model id or alias").action(async (model) => {
2825
+ await runModelsCommand(async () => {
2826
+ await modelsFallbacksRemoveCommand(model, defaultRuntime);
2827
+ });
2828
+ });
2829
+ fallbacks.command("clear").description("Clear the entire fallback chain").action(async () => {
2830
+ await runModelsCommand(async () => {
2831
+ await modelsFallbacksClearCommand(defaultRuntime);
2832
+ });
2833
+ });
2834
+ const imageFallbacks = models.command("image-fallbacks").description("Configure image model fallback chain");
2835
+ imageFallbacks.command("list").description("List the image model fallback chain").option("--json", "Output JSON", false).option("--plain", "Plain output", false).action(async (opts) => {
2836
+ await runModelsCommand(async () => {
2837
+ await modelsImageFallbacksListCommand(opts, defaultRuntime);
2838
+ });
2839
+ });
2840
+ imageFallbacks.command("add").description("Append a model to the image fallback chain").argument("<model>", "Model id or alias").action(async (model) => {
2841
+ await runModelsCommand(async () => {
2842
+ await modelsImageFallbacksAddCommand(model, defaultRuntime);
2843
+ });
2844
+ });
2845
+ imageFallbacks.command("remove").description("Remove a model from the image fallback chain").argument("<model>", "Model id or alias").action(async (model) => {
2846
+ await runModelsCommand(async () => {
2847
+ await modelsImageFallbacksRemoveCommand(model, defaultRuntime);
2848
+ });
2849
+ });
2850
+ imageFallbacks.command("clear").description("Clear the entire image fallback chain").action(async () => {
2851
+ await runModelsCommand(async () => {
2852
+ await modelsImageFallbacksClearCommand(defaultRuntime);
2853
+ });
2854
+ });
2855
+ models.command("scan").description("Scan and probe available models for tool and image support").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) => {
2856
+ await runModelsCommand(async () => {
2857
+ await modelsScanCommand(opts, defaultRuntime);
2858
+ });
2859
+ });
2860
+ models.action(async (opts) => {
2861
+ await runModelsCommand(async () => {
2862
+ await modelsStatusCommand({
2863
+ json: Boolean(opts?.statusJson),
2864
+ plain: Boolean(opts?.statusPlain),
2865
+ agent: opts?.agent
2866
+ }, defaultRuntime);
2867
+ });
2868
+ });
2869
+ const auth = models.command("auth").description("Manage provider authentication profiles");
2870
+ auth.option("--agent <id>", "Agent id for auth order get/set/clear");
2871
+ auth.action(() => {
2872
+ auth.help();
2873
+ });
2874
+ auth.command("add").description("Interactive authentication setup wizard").action(async () => {
2875
+ await runModelsCommand(async () => {
2876
+ await modelsAuthAddCommand({}, defaultRuntime);
2877
+ });
2878
+ });
2879
+ auth.command("login").description("Authenticate with a provider via OAuth or 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) => {
2880
+ await runModelsCommand(async () => {
2881
+ await modelsAuthLoginCommand({
2882
+ provider: opts.provider,
2883
+ method: opts.method,
2884
+ setDefault: Boolean(opts.setDefault)
2885
+ }, defaultRuntime);
2886
+ });
2887
+ });
2888
+ auth.command("setup-token").description("Create or sync a provider token via CLI").option("--provider <name>", "Provider id (default: anthropic)").option("--yes", "Skip confirmation", false).action(async (opts) => {
2889
+ await runModelsCommand(async () => {
2890
+ await modelsAuthSetupTokenCommand({
2891
+ provider: opts.provider,
2892
+ yes: Boolean(opts.yes)
2893
+ }, defaultRuntime);
2894
+ });
2895
+ });
2896
+ auth.command("paste-token").description("Store a provider token directly into auth profiles").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) => {
2897
+ await runModelsCommand(async () => {
2898
+ await modelsAuthPasteTokenCommand({
2899
+ provider: opts.provider,
2900
+ profileId: opts.profileId,
2901
+ expiresIn: opts.expiresIn
2902
+ }, defaultRuntime);
2903
+ });
2904
+ });
2905
+ auth.command("login-github-copilot").description("Authenticate with GitHub Copilot via device flow").option("--profile-id <id>", "Auth profile id (default: github-copilot:github)").option("--yes", "Overwrite existing profile without prompting", false).action(async (opts) => {
2906
+ await runModelsCommand(async () => {
2907
+ await githubCopilotLoginCommand({
2908
+ profileId: opts.profileId,
2909
+ yes: Boolean(opts.yes)
2910
+ }, defaultRuntime);
2911
+ });
2912
+ });
2913
+ const order = auth.command("order").description("Control per-agent authentication priority");
2914
+ order.command("get").description("Show the auth profile priority for an agent").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) => {
2915
+ const agent = resolveOptionFromCommand(command, "agent") ?? opts.agent;
2916
+ await runModelsCommand(async () => {
2917
+ await modelsAuthOrderGetCommand({
2918
+ provider: opts.provider,
2919
+ agent,
2920
+ json: Boolean(opts.json)
2921
+ }, defaultRuntime);
2922
+ });
2923
+ });
2924
+ order.command("set").description("Lock an agent to a specific auth profile rotation").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) => {
2925
+ const agent = resolveOptionFromCommand(command, "agent") ?? opts.agent;
2926
+ await runModelsCommand(async () => {
2927
+ await modelsAuthOrderSetCommand({
2928
+ provider: opts.provider,
2929
+ agent,
2930
+ order: profileIds
2931
+ }, defaultRuntime);
2932
+ });
2933
+ });
2934
+ order.command("clear").description("Reset auth priority to default round-robin rotation").requiredOption("--provider <name>", "Provider id (e.g. anthropic)").option("--agent <id>", "Agent id (default: configured default agent)").action(async (opts, command) => {
2935
+ const agent = resolveOptionFromCommand(command, "agent") ?? opts.agent;
2936
+ await runModelsCommand(async () => {
2937
+ await modelsAuthOrderClearCommand({
2938
+ provider: opts.provider,
2939
+ agent
2940
+ }, defaultRuntime);
2941
+ });
2942
+ });
2943
+ }
2944
+
2945
+ //#endregion
2946
+ export { registerModelsCli };