clauddy 1.0.0 → 1.1.0
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/auth.js +6 -1
- package/main.js +14 -2
- package/package.json +1 -1
- package/usage.js +2 -1
package/auth.js
CHANGED
|
@@ -11,7 +11,12 @@ const TOKEN_URL = 'https://platform.claude.com/v1/oauth/token'
|
|
|
11
11
|
const USAGE_URL = 'https://api.anthropic.com/api/oauth/usage'
|
|
12
12
|
const SCOPE = 'org:create_api_key user:profile user:inference'
|
|
13
13
|
const UA = 'claude-cli/2.1.181 (external, cli)'
|
|
14
|
-
|
|
14
|
+
// when CLAUDE_CONFIG_DIR is set (e.g. via direnv for multi-account setups),
|
|
15
|
+
// keep the widget's data alongside that account's Claude config
|
|
16
|
+
const DATA_DIR = process.env.CLAUDE_CONFIG_DIR
|
|
17
|
+
? path.join(process.env.CLAUDE_CONFIG_DIR, 'usage-monitor')
|
|
18
|
+
: path.join(os.homedir(), '.claude-usage-monitor')
|
|
19
|
+
const TOKEN_PATH = path.join(DATA_DIR, 'auth.json')
|
|
15
20
|
|
|
16
21
|
const b64url = (buf) =>
|
|
17
22
|
buf.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')
|
package/main.js
CHANGED
|
@@ -5,8 +5,20 @@ const os = require('node:os')
|
|
|
5
5
|
const { getUsage } = require('./usage')
|
|
6
6
|
const auth = require('./auth')
|
|
7
7
|
|
|
8
|
-
// data dir: kept outside the project folder so moving the repo doesn't break it
|
|
9
|
-
|
|
8
|
+
// data dir: kept outside the project folder so moving the repo doesn't break it.
|
|
9
|
+
// when CLAUDE_CONFIG_DIR is set (e.g. via direnv for multi-account setups), nest
|
|
10
|
+
// the widget's data under that account's Claude config dir so each account gets
|
|
11
|
+
// its own auth.json, config.json, and Electron userData.
|
|
12
|
+
const DATA_DIR = process.env.CLAUDE_CONFIG_DIR
|
|
13
|
+
? path.join(process.env.CLAUDE_CONFIG_DIR, 'usage-monitor')
|
|
14
|
+
: path.join(os.homedir(), '.claude-usage-monitor')
|
|
15
|
+
// when isolating per-account, also pin Electron's userData under DATA_DIR so two
|
|
16
|
+
// widgets can run in parallel without fighting over cookies/cache. left untouched
|
|
17
|
+
// in the default case so existing installs keep their window position etc.
|
|
18
|
+
if (process.env.CLAUDE_CONFIG_DIR) {
|
|
19
|
+
fs.mkdirSync(DATA_DIR, { recursive: true })
|
|
20
|
+
app.setPath('userData', path.join(DATA_DIR, 'electron'))
|
|
21
|
+
}
|
|
10
22
|
// external config: edit without rebuilding the .app
|
|
11
23
|
const EXTERNAL_CONFIG = path.join(DATA_DIR, 'config.json')
|
|
12
24
|
// debug channel: `./pet <state>` writes here to force a state (dev only)
|
package/package.json
CHANGED
package/usage.js
CHANGED
|
@@ -2,7 +2,8 @@ const fs = require('node:fs')
|
|
|
2
2
|
const path = require('node:path')
|
|
3
3
|
const os = require('node:os')
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const CLAUDE_DIR = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude')
|
|
6
|
+
const PROJECTS_DIR = path.join(CLAUDE_DIR, 'projects')
|
|
6
7
|
|
|
7
8
|
function labelFor(model) {
|
|
8
9
|
if (!model) return 'desconhecido'
|