@rubytech/create-maxy 0.4.8 → 0.4.10

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-maxy",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "description": "Install Maxy — your personal AI assistant",
5
5
  "bin": {
6
6
  "create-maxy": "./dist/index.js"
@@ -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 CLAUDE_CODE_OAUTH_TOKEN in the process environment
69
+ // so Claude Code / the Agent SDK can use it immediately without restarting
70
+ process.env.CLAUDE_CODE_OAUTH_TOKEN = creds.access
50
71
  }
51
72
 
52
73
  // --- Endpoints ---
@@ -1,10 +1,25 @@
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
+ // Claude Code reads CLAUDE_CODE_OAUTH_TOKEN for OAuth access tokens.
11
+ if (!process.env.CLAUDE_CODE_OAUTH_TOKEN) {
12
+ const oauthFile = resolve(homedir(), ".maxy/.claude-oauth.json");
13
+ if (existsSync(oauthFile)) {
14
+ try {
15
+ const creds = JSON.parse(readFileSync(oauthFile, "utf-8"));
16
+ if (creds.accessToken) {
17
+ process.env.CLAUDE_CODE_OAUTH_TOKEN = creds.accessToken;
18
+ }
19
+ } catch { /* ignore */ }
20
+ }
21
+ }
22
+
8
23
  // ---------------------------------------------------------------------------
9
24
  // Account resolution
10
25
  // ---------------------------------------------------------------------------