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