@gonzih/cc-tg 0.1.6 → 0.1.8
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/README.md +12 -0
- package/dist/claude.js +8 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,18 @@ That's it. Open your bot in Telegram and start chatting.
|
|
|
26
26
|
|
|
27
27
|
*One of CLAUDE_CODE_TOKEN or ANTHROPIC_API_KEY is required.
|
|
28
28
|
|
|
29
|
+
## How to get your Claude Code token
|
|
30
|
+
|
|
31
|
+
Run this once to generate a long-lived OAuth token:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx @anthropic-ai/claude-code setup-token
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
It opens a browser, logs you in with your Anthropic account, and prints a token starting with `sk-ant-oat`. Paste that as `CLAUDE_CODE_TOKEN`.
|
|
38
|
+
|
|
39
|
+
Alternatively, use an `ANTHROPIC_API_KEY` from [console.anthropic.com](https://console.anthropic.com) (API key starts with `sk-ant-api`).
|
|
40
|
+
|
|
29
41
|
## How to get your Telegram user ID
|
|
30
42
|
|
|
31
43
|
Message [@userinfobot](https://t.me/userinfobot) on Telegram — it replies with your ID.
|
package/dist/claude.js
CHANGED
|
@@ -17,23 +17,25 @@ export class ClaudeProcess extends EventEmitter {
|
|
|
17
17
|
"--input-format", "stream-json",
|
|
18
18
|
"--print",
|
|
19
19
|
"--verbose",
|
|
20
|
+
"--dangerously-skip-permissions",
|
|
20
21
|
];
|
|
21
22
|
if (opts.systemPrompt) {
|
|
22
23
|
args.push("--system-prompt", opts.systemPrompt);
|
|
23
24
|
}
|
|
24
25
|
const env = { ...process.env };
|
|
25
26
|
if (opts.token) {
|
|
26
|
-
// OAuth tokens start with sk-ant-oat — set CLAUDE_CODE_OAUTH_TOKEN only
|
|
27
27
|
// API keys start with sk-ant-api — set ANTHROPIC_API_KEY only
|
|
28
|
+
// Everything else (OAuth sk-ant-oat, setup-token format with #, etc.)
|
|
29
|
+
// goes into CLAUDE_CODE_OAUTH_TOKEN
|
|
28
30
|
// Mixing them causes "Invalid API key" errors
|
|
29
|
-
if (opts.token.startsWith("sk-ant-
|
|
30
|
-
env.CLAUDE_CODE_OAUTH_TOKEN = opts.token;
|
|
31
|
-
delete env.ANTHROPIC_API_KEY;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
31
|
+
if (opts.token.startsWith("sk-ant-api")) {
|
|
34
32
|
env.ANTHROPIC_API_KEY = opts.token;
|
|
35
33
|
delete env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
36
34
|
}
|
|
35
|
+
else {
|
|
36
|
+
env.CLAUDE_CODE_OAUTH_TOKEN = opts.token;
|
|
37
|
+
delete env.ANTHROPIC_API_KEY;
|
|
38
|
+
}
|
|
37
39
|
}
|
|
38
40
|
this.proc = spawn("claude", args, {
|
|
39
41
|
cwd: opts.cwd ?? process.cwd(),
|