Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Sources/CodexBarCore/Providers/Gemini/GeminiStatusProbe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,15 @@ public struct GeminiStatusProbe: Sendable {
}
}

// Bundled format: realPath points into a bundle/ dir containing chunk-*.js files
// with OAuth credentials embedded in one of the chunks.
if let result = self.searchBundleDirectory(binDir, fm: fm) {
return result
}
if let result = self.searchBundleDirectory(baseDir + "/bundle", fm: fm) {
return result
}

return nil
}

Expand Down Expand Up @@ -544,6 +553,18 @@ public struct GeminiStatusProbe: Sendable {
return OAuthClientCredentials(clientId: clientId, clientSecret: clientSecret)
}

private static func searchBundleDirectory(_ dir: String, fm: FileManager) -> OAuthClientCredentials? {
guard let entries = try? fm.contentsOfDirectory(atPath: dir) else { return nil }
for entry in entries where entry.hasPrefix("chunk-") && entry.hasSuffix(".js") {
let path = (dir as NSString).appendingPathComponent(entry)
guard let content = try? String(contentsOfFile: path, encoding: .utf8) else { continue }
if let result = self.parseOAuthCredentials(from: content) {
return result
}
}
return nil
}

private static func refreshAccessToken(
refreshToken: String,
timeout: TimeInterval,
Expand Down