66 "io"
77 "net/http"
88 "os"
9- "path/filepath"
109 "strings"
1110 "time"
1211
@@ -60,16 +59,10 @@ func claudeAuthPath() (string, error) {
6059 return config .ClaudeSubscriptionAuthPath ()
6160}
6261
62+ // codexAuthPath returns clovapi's own Codex OAuth store (independent from
63+ // Codex CLI's ~/.codex/auth.json). Auth status and logout operate on this file only.
6364func codexAuthPath () (string , error ) {
64- codexHome := strings .TrimSpace (os .Getenv ("CODEX_HOME" ))
65- if codexHome == "" {
66- home , err := os .UserHomeDir ()
67- if err != nil {
68- return "" , err
69- }
70- codexHome = filepath .Join (home , ".codex" )
71- }
72- return filepath .Join (codexHome , "auth.json" ), nil
65+ return config .CodexSubscriptionAuthPath ()
7366}
7467
7568func authPathForProvider (providerID string ) (string , error ) {
@@ -196,6 +189,8 @@ func providerLoggedIn(providerID string, data map[string]any) bool {
196189}
197190
198191// AuthStatus reports subscription OAuth status for built-in providers.
192+ // Subscription login and model fetch are independent of whether the agent CLI
193+ // binary is installed; Installed is informational only.
199194func AuthStatus () AuthStatusResult {
200195 items := make ([]AuthStatusItem , 0 , len (authProviders ))
201196 for _ , cfg := range authProviders {
@@ -211,21 +206,15 @@ func AuthStatus() AuthStatusResult {
211206 if cmdPath != "" {
212207 item .CommandPath = cmdPath
213208 }
214- if ! installed {
215- item .Summary = "CLI not installed"
216- items = append (items , item )
217- continue
218- }
219209 authPath , err := authPathForProvider (cfg .ID )
220- if err != nil {
221- items = append (items , item )
222- continue
210+ if err == nil {
211+ if data , ok := readAuthJSON (authPath ); ok {
212+ item .LoggedIn = providerLoggedIn (cfg .ID , data )
213+ item .Active = providerSubscriptionActive (cfg .ID , item .LoggedIn , data )
214+ item .Summary = summarizeAuthStatus (cfg .ID , item .LoggedIn , data )
215+ }
223216 }
224- if data , ok := readAuthJSON (authPath ); ok {
225- item .LoggedIn = providerLoggedIn (cfg .ID , data )
226- item .Active = providerSubscriptionActive (cfg .ID , item .LoggedIn , data )
227- item .Summary = summarizeAuthStatus (cfg .ID , item .LoggedIn , data )
228- } else if cfg .ID == provider .ClaudeCodeProviderID {
217+ if ! item .LoggedIn && cfg .ID == provider .ClaudeCodeProviderID {
229218 if data , ok := profile .ClaudeAuthRoot (); ok {
230219 item .LoggedIn = providerLoggedIn (cfg .ID , data )
231220 item .Active = providerSubscriptionActive (cfg .ID , item .LoggedIn , data )
0 commit comments