Skip to content

Commit 41deff7

Browse files
committed
feat: add option to authenticate with claude token
1 parent c8a9e8e commit 41deff7

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

env.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export const env = createEnv({
2727
CHAT_SDK_BOT_NAME: z.string().default("blazebot"),
2828

2929
// Agent
30-
ANTHROPIC_API_KEY: z.string().min(1),
30+
ANTHROPIC_API_KEY: z.string().min(1).optional(),
31+
CLAUDE_CODE_OAUTH_TOKEN: z.string().min(1).optional(),
3132
CLAUDE_MODEL: z.string().default("claude-opus-4-6"),
3233
COMMIT_AUTHOR: z.string().default("ai-workflow-blazity"),
3334
COMMIT_EMAIL: z.string().default("ai-workflow@blazity.com"),

src/sandbox/manager.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export interface SandboxConfig {
1414
githubToken: string;
1515
owner: string;
1616
repo: string;
17-
anthropicApiKey: string;
17+
anthropicApiKey?: string;
18+
claudeCodeOauthToken?: string;
1819
claudeModel: string;
1920
commitAuthor: string;
2021
commitEmail: string;
@@ -61,7 +62,9 @@ export class SandboxManager {
6162
runtime: "node24",
6263
timeout: this.config.jobTimeoutMs,
6364
env: {
64-
ANTHROPIC_API_KEY: this.config.anthropicApiKey,
65+
...(this.config.claudeCodeOauthToken
66+
? { CLAUDE_CODE_OAUTH_TOKEN: this.config.claudeCodeOauthToken }
67+
: { ANTHROPIC_API_KEY: this.config.anthropicApiKey! }),
6568
CLAUDE_MODEL: this.config.claudeModel,
6669
},
6770
});
@@ -75,6 +78,14 @@ export class SandboxManager {
7578
// Install Claude Code
7679
await sandbox.runCommand("npm", ["install", "-g", "@anthropic-ai/claude-code"]);
7780

81+
// Skip interactive onboarding (required for headless OAuth token auth)
82+
if (this.config.claudeCodeOauthToken) {
83+
await sandbox.runCommand("bash", [
84+
"-c",
85+
`mkdir -p ~/.claude && echo '{"hasCompletedOnboarding":true}' > ~/.claude.json`,
86+
]);
87+
}
88+
7889
// Install skills globally (outside the client repo)
7990
await this.installGlobalSkills(sandbox);
8091

src/workflows/implementation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ async function runAgentInSandbox(
5454
owner: env.GITHUB_OWNER,
5555
repo: env.GITHUB_REPO,
5656
anthropicApiKey: env.ANTHROPIC_API_KEY,
57+
claudeCodeOauthToken: env.CLAUDE_CODE_OAUTH_TOKEN,
5758
claudeModel: env.CLAUDE_MODEL,
5859
commitAuthor: env.COMMIT_AUTHOR,
5960
commitEmail: env.COMMIT_EMAIL,

src/workflows/review-fix.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ async function runFixingAgentInSandbox(
7171
owner: env.GITHUB_OWNER,
7272
repo: env.GITHUB_REPO,
7373
anthropicApiKey: env.ANTHROPIC_API_KEY,
74+
claudeCodeOauthToken: env.CLAUDE_CODE_OAUTH_TOKEN,
7475
claudeModel: env.CLAUDE_MODEL,
7576
commitAuthor: env.COMMIT_AUTHOR,
7677
commitEmail: env.COMMIT_EMAIL,

0 commit comments

Comments
 (0)