feat(gemini-web): squash all features and fixes for gemini-web

This commit is contained in:
hkfires
2025-09-17 20:24:23 +08:00
parent 172f282e9e
commit e4dd22b260
25 changed files with 3710 additions and 6 deletions

View File

@@ -324,8 +324,16 @@ func (c *CodexClient) SendRawTokenCount(_ context.Context, _ string, _ []byte, _
// Returns:
// - error: An error if the save operation fails, nil otherwise.
func (c *CodexClient) SaveTokenToFile() error {
fileName := filepath.Join(c.cfg.AuthDir, fmt.Sprintf("codex-%s.json", c.tokenStorage.(*codex.CodexTokenStorage).Email))
return c.tokenStorage.SaveTokenToFile(fileName)
// API-key based clients don't have a file-backed token to persist.
if c.apiKeyIndex != -1 {
return nil
}
ts, ok := c.tokenStorage.(*codex.CodexTokenStorage)
if !ok || ts == nil || ts.Email == "" {
return nil
}
fileName := filepath.Join(c.cfg.AuthDir, fmt.Sprintf("codex-%s.json", ts.Email))
return ts.SaveTokenToFile(fileName)
}
// RefreshTokens refreshes the access tokens if needed