@gonzih/cc-tg 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/claude.d.ts CHANGED
@@ -15,7 +15,7 @@ export interface ClaudeMessage {
15
15
  export interface ClaudeOptions {
16
16
  cwd?: string;
17
17
  systemPrompt?: string;
18
- /** CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY value */
18
+ /** OAuth token (sk-ant-oat01-...) or API key (sk-ant-api03-...) */
19
19
  token?: string;
20
20
  }
21
21
  export declare interface ClaudeProcess {
package/dist/claude.js CHANGED
@@ -23,8 +23,17 @@ export class ClaudeProcess extends EventEmitter {
23
23
  }
24
24
  const env = { ...process.env };
25
25
  if (opts.token) {
26
- // Try as OAuth token first; Claude Code accepts both env vars
27
- env.CLAUDE_CODE_OAUTH_TOKEN = opts.token;
26
+ // OAuth tokens start with sk-ant-oat set CLAUDE_CODE_OAUTH_TOKEN only
27
+ // API keys start with sk-ant-api — set ANTHROPIC_API_KEY only
28
+ // Mixing them causes "Invalid API key" errors
29
+ if (opts.token.startsWith("sk-ant-oat")) {
30
+ env.CLAUDE_CODE_OAUTH_TOKEN = opts.token;
31
+ delete env.ANTHROPIC_API_KEY;
32
+ }
33
+ else {
34
+ env.ANTHROPIC_API_KEY = opts.token;
35
+ delete env.CLAUDE_CODE_OAUTH_TOKEN;
36
+ }
28
37
  }
29
38
  this.proc = spawn("claude", args, {
30
39
  cwd: opts.cwd ?? process.cwd(),
package/dist/index.js CHANGED
@@ -34,12 +34,13 @@ Or add to your shell profile / .env file.
34
34
  return val;
35
35
  }
36
36
  const telegramToken = required("TELEGRAM_BOT_TOKEN");
37
- // Accept either CLAUDE_CODE_TOKEN or ANTHROPIC_API_KEY
37
+ // Accept CLAUDE_CODE_TOKEN, CLAUDE_CODE_OAUTH_TOKEN, or ANTHROPIC_API_KEY
38
38
  const claudeToken = process.env.CLAUDE_CODE_TOKEN ??
39
+ process.env.CLAUDE_CODE_OAUTH_TOKEN ??
39
40
  process.env.ANTHROPIC_API_KEY;
40
41
  if (!claudeToken) {
41
42
  console.error(`
42
- ERROR: Neither CLAUDE_CODE_TOKEN nor ANTHROPIC_API_KEY is set.
43
+ ERROR: No Claude token set. Set one of: CLAUDE_CODE_TOKEN, CLAUDE_CODE_OAUTH_TOKEN, or ANTHROPIC_API_KEY.
43
44
 
44
45
  Set one and run again:
45
46
  TELEGRAM_BOT_TOKEN=xxx CLAUDE_CODE_TOKEN=yyy npx @gonzih/cc-tg
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-tg",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Claude Code Telegram bot — chat with Claude Code via Telegram",
5
5
  "type": "module",
6
6
  "bin": {