Skip to content
Open
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: 20 additions & 1 deletion server/modules/workflow/agents/providers/usage-cli-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,27 @@ export function createUsageCliTools(deps: CreateUsageCliToolsDeps) {
checkAuth: () => {
const home = os.homedir();
const claudeJson = path.join(home, ".claude.json");

// Legacy/local auth footprints used by older Claude Code releases.
if (jsonHasKey(claudeJson, "oauthAccount") || jsonHasKey(claudeJson, "session")) return true;
return fileExistsNonEmpty(path.join(home, ".claude", "auth.json"));
if (fileExistsNonEmpty(path.join(home, ".claude", "auth.json"))) return true;

// Current OAuth storage path (and macOS keychain bridge) used by usage endpoint fetch.
if (readClaudeToken()) return true;

// Last-resort runtime probe: rely on Claude CLI status exit behavior.
// If authenticated, this command exits successfully in current releases.
try {
const cmd = process.platform === "win32" ? "cmd" : "claude";
const args = process.platform === "win32" ? ["/c", "claude auth status"] : ["auth", "status"];
execFileSync(cmd, args, {
timeout: 4000,
stdio: ["ignore", "pipe", "pipe"],
});
Comment thread
eat-happy marked this conversation as resolved.
return true;
} catch {
return false;
}
},
},
{
Expand Down