Support Claude Code Max via OAuth token
Publish Image / publish (push) Successful in 21s
Details
Publish Image / publish (push) Successful in 21s
Details
Pass CLAUDE_CODE_OAUTH_TOKEN to workspaces so they use the Max subscription instead of pay-per-use API credits. Falls back to ANTHROPIC_API_KEY if OAuth token not set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9bca465565
commit
abbe47b1b9
|
|
@ -196,6 +196,15 @@ data "coder_parameter" "callback_url" {
|
|||
mutable = false
|
||||
}
|
||||
|
||||
data "coder_parameter" "claude_oauth_token" {
|
||||
name = "claude_oauth_token"
|
||||
display_name = "Claude OAuth Token"
|
||||
description = "OAuth token for Claude Code Max subscription"
|
||||
type = "string"
|
||||
default = ""
|
||||
mutable = false
|
||||
}
|
||||
|
||||
data "coder_parameter" "deploy_env" {
|
||||
name = "deploy_env"
|
||||
display_name = "Deploy Environment"
|
||||
|
|
@ -415,6 +424,7 @@ resource "coder_agent" "main" {
|
|||
|
||||
env = {
|
||||
ANTHROPIC_API_KEY = data.coder_parameter.anthropic_api_key.value
|
||||
CLAUDE_CODE_OAUTH_TOKEN = data.coder_parameter.claude_oauth_token.value
|
||||
GITHUB_TOKEN = data.coder_external_auth.github.access_token
|
||||
GITEA_TOKEN = data.coder_parameter.gitea_token.value
|
||||
GITEA_ORG = data.coder_parameter.gitea_org.value
|
||||
|
|
@ -576,6 +586,11 @@ resource "kubernetes_deployment_v1" "workspace" {
|
|||
value = data.coder_parameter.anthropic_api_key.value
|
||||
}
|
||||
|
||||
env {
|
||||
name = "CLAUDE_CODE_OAUTH_TOKEN"
|
||||
value = data.coder_parameter.claude_oauth_token.value
|
||||
}
|
||||
|
||||
env {
|
||||
name = "GITHUB_TOKEN"
|
||||
value = data.coder_external_auth.github.access_token
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ export interface Config {
|
|||
giteaDevToken: string;
|
||||
/** Gitea API token for the review bot account */
|
||||
giteaReviewToken: string;
|
||||
/** Anthropic API key passed to Claude Code in workspaces */
|
||||
/** Anthropic API key passed to Claude Code in workspaces (fallback) */
|
||||
anthropicApiKey: string;
|
||||
/** Claude Code OAuth token for Max subscription (preferred) */
|
||||
claudeOauthToken: string;
|
||||
/** Username of the dev bot (to filter out self-replies) */
|
||||
botDevUsername: string;
|
||||
/** Username of the review bot (to filter out self-replies) */
|
||||
|
|
@ -41,7 +43,8 @@ export function loadConfig(): Config {
|
|||
coderTemplateId: required("CODER_TEMPLATE_ID"),
|
||||
giteaDevToken: required("GITEA_DEV_TOKEN"),
|
||||
giteaReviewToken: required("GITEA_REVIEW_TOKEN"),
|
||||
anthropicApiKey: required("ANTHROPIC_API_KEY"),
|
||||
anthropicApiKey: process.env.ANTHROPIC_API_KEY || "",
|
||||
claudeOauthToken: process.env.CLAUDE_OAUTH_TOKEN || "",
|
||||
botDevUsername: process.env.BOT_DEV_USERNAME || "claude-dev",
|
||||
botReviewUsername: process.env.BOT_REVIEW_USERNAME || "claude-review",
|
||||
giteaUrl: process.env.GITEA_URL || "https://gitea.samson.media",
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ export class CoderClient {
|
|||
private token: string;
|
||||
private templateId: string;
|
||||
private anthropicApiKey: string;
|
||||
private claudeOauthToken: string;
|
||||
private callbackUrl: string;
|
||||
|
||||
constructor(config: Config) {
|
||||
|
|
@ -14,6 +15,7 @@ export class CoderClient {
|
|||
this.token = config.coderToken;
|
||||
this.templateId = config.coderTemplateId;
|
||||
this.anthropicApiKey = config.anthropicApiKey;
|
||||
this.claudeOauthToken = config.claudeOauthToken;
|
||||
this.callbackUrl = config.callbackUrl;
|
||||
}
|
||||
|
||||
|
|
@ -31,6 +33,7 @@ export class CoderClient {
|
|||
{ name: "gitea_org", value: task.giteaOrg },
|
||||
{ name: "gitea_repo", value: task.giteaRepo },
|
||||
{ name: "anthropic_api_key", value: this.anthropicApiKey },
|
||||
{ name: "claude_oauth_token", value: this.claudeOauthToken },
|
||||
{ name: "callback_url", value: `${this.callbackUrl}/webhook/task-complete/${name}` },
|
||||
...(task.deployEnv
|
||||
? [{ name: "deploy_env", value: task.deployEnv }]
|
||||
|
|
|
|||
Loading…
Reference in New Issue