Skip to content

Commit a1e678b

Browse files
committed
allow CODEBUFF_API_KEY instead of logging in
1 parent f8b26f6 commit a1e678b

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

common/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export const EXISTING_CODE_MARKER = '[[**REPLACE_WITH_EXISTING_CODE**]]'
66
export const AGENT_TEMPLATES_DIR = '.agents/'
77
export const AGENT_CONFIG_FILE = 'agent-config.d.ts'
88

9+
export const API_KEY_ENV_VAR = 'CODEBUFF_API_KEY'
10+
911
// Enable async agents to run tool calls even when main user input is cancelled
1012
export const ASYNC_AGENTS_ENABLED = true
1113

npm-app/src/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
SHOULD_ASK_CONFIG,
2626
UserState,
2727
ASYNC_AGENTS_ENABLED,
28+
API_KEY_ENV_VAR,
2829
} from '@codebuff/common/constants'
2930
import { AnalyticsEvent } from '@codebuff/common/constants/analytics-events'
3031
import { codebuffConfigFile as CONFIG_FILE_NAME } from '@codebuff/common/json-config/constants'
@@ -1055,7 +1056,7 @@ export class Client {
10551056
sessionState: this.sessionState,
10561057
toolResults,
10571058
fingerprintId: await this.fingerprintId,
1058-
authToken: this.user?.authToken,
1059+
authToken: process.env[API_KEY_ENV_VAR] || this.user?.authToken,
10591060
costMode: this.costMode,
10601061
model: this.model,
10611062
repoUrl: loggerContext.repoUrl,

sdk/src/client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { execFileSync } from 'child_process'
22

3+
import { API_KEY_ENV_VAR } from '@codebuff/common/constants'
4+
35
import { CODEBUFF_BINARY } from './constants'
46
import { processStream } from './process-stream'
57

@@ -26,7 +28,7 @@ export class CodebuffClient {
2628
this.authToken =
2729
apiKey.type === 'string'
2830
? apiKey.value
29-
: process.env.CODEBUFF_API_KEY ?? ''
31+
: process.env[API_KEY_ENV_VAR] ?? ''
3032
this.cwd = cwd
3133
}
3234

0 commit comments

Comments
 (0)