@rubytech/create-maxy 0.4.8 → 0.4.9
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/package.json
CHANGED
|
@@ -29,6 +29,9 @@ function resetSession(): void {
|
|
|
29
29
|
const CLAUDE_CREDS_PATH = resolve(homedir(), '.claude/.credentials.json')
|
|
30
30
|
|
|
31
31
|
function writeClaudeCredentials(creds: OAuthCredentials): void {
|
|
32
|
+
// Store the OAuth credentials in two places:
|
|
33
|
+
|
|
34
|
+
// 1. ~/.claude/.credentials.json (Claude Code's credential file)
|
|
32
35
|
const claudeDir = resolve(homedir(), '.claude')
|
|
33
36
|
mkdirSync(claudeDir, { recursive: true })
|
|
34
37
|
|
|
@@ -47,6 +50,24 @@ function writeClaudeCredentials(creds: OAuthCredentials): void {
|
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
writeFileSync(CLAUDE_CREDS_PATH, JSON.stringify(data, null, 2), { mode: 0o600 })
|
|
53
|
+
|
|
54
|
+
// 2. ~/.maxy/.claude-oauth.json (persistent, for refresh + service restart)
|
|
55
|
+
const maxyDir = resolve(homedir(), '.maxy')
|
|
56
|
+
mkdirSync(maxyDir, { recursive: true })
|
|
57
|
+
writeFileSync(
|
|
58
|
+
resolve(maxyDir, '.claude-oauth.json'),
|
|
59
|
+
JSON.stringify({
|
|
60
|
+
accessToken: creds.access,
|
|
61
|
+
refreshToken: creds.refresh,
|
|
62
|
+
expiresAt: creds.expires,
|
|
63
|
+
email: creds.email,
|
|
64
|
+
}, null, 2),
|
|
65
|
+
{ mode: 0o600 },
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
// 3. Set the access token as ANTHROPIC_API_KEY in the process environment
|
|
69
|
+
// so the Agent SDK can use it immediately without restarting
|
|
70
|
+
process.env.ANTHROPIC_API_KEY = creds.access
|
|
50
71
|
}
|
|
51
72
|
|
|
52
73
|
// --- Endpoints ---
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { query, type HookCallback } from "@anthropic-ai/claude-agent-sdk";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { readFileSync, readdirSync, existsSync } from "node:fs";
|
|
4
|
+
import { homedir } from "node:os";
|
|
4
5
|
|
|
5
6
|
const PLATFORM_ROOT = resolve(process.cwd(), "../platform");
|
|
6
7
|
const ACCOUNTS_DIR = resolve(PLATFORM_ROOT, "config/accounts");
|
|
7
8
|
|
|
9
|
+
// Load OAuth token from persistent storage if not already in env
|
|
10
|
+
if (!process.env.ANTHROPIC_API_KEY) {
|
|
11
|
+
const oauthFile = resolve(homedir(), ".maxy/.claude-oauth.json");
|
|
12
|
+
if (existsSync(oauthFile)) {
|
|
13
|
+
try {
|
|
14
|
+
const creds = JSON.parse(readFileSync(oauthFile, "utf-8"));
|
|
15
|
+
if (creds.accessToken) {
|
|
16
|
+
process.env.ANTHROPIC_API_KEY = creds.accessToken;
|
|
17
|
+
}
|
|
18
|
+
} catch { /* ignore */ }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
8
22
|
// ---------------------------------------------------------------------------
|
|
9
23
|
// Account resolution
|
|
10
24
|
// ---------------------------------------------------------------------------
|