@emesoft/tokenhub 0.7.0 → 0.7.2
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/LICENSE +21 -0
- package/README.md +101 -21
- package/package.json +15 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Emesoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,36 +1,116 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://tokenhub.aimpact.io.vn/readme/banner.jpg" alt="TokenHub" width="520">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@emesoft/tokenhub"><img src="https://img.shields.io/npm/v/@emesoft/tokenhub" alt="npm version"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/@emesoft/tokenhub?activeTab=code"><img src="https://img.shields.io/npm/l/@emesoft/tokenhub" alt="MIT license"></a>
|
|
8
|
+
<img src="https://img.shields.io/node/v/@emesoft/tokenhub" alt="Node.js 18+">
|
|
9
|
+
</p>
|
|
10
|
+
|
|
1
11
|
# @emesoft/tokenhub
|
|
2
12
|
|
|
3
|
-
|
|
13
|
+
Connect [Claude Code](https://docs.anthropic.com/en/docs/claude-code) to a [TokenHub](https://tokenhub.aimpact.io.vn) pool in one command, and keep an eye on your spend from the terminal.
|
|
4
14
|
|
|
5
|
-
|
|
15
|
+
- **One-step setup:** pair in the browser, no keys to copy.
|
|
16
|
+
- **Spend at a glance:** a status line under the Claude Code prompt, plus `usage` and a live `dashboard`.
|
|
17
|
+
- **Zero dependencies:** Node.js 18 or later, macOS, Linux and Windows.
|
|
6
18
|
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install -g @emesoft/tokenhub
|
|
23
|
+
tokenhub connect
|
|
24
|
+
claude
|
|
7
25
|
```
|
|
8
|
-
npx @emesoft/tokenhub connect
|
|
9
|
-
npx @emesoft/tokenhub connect --no-statusline
|
|
10
|
-
npx @emesoft/tokenhub usage
|
|
11
|
-
npx @emesoft/tokenhub dashboard
|
|
12
|
-
npx @emesoft/tokenhub disconnect
|
|
13
|
-
npx @emesoft/tokenhub connect --admin
|
|
14
|
-
npx @emesoft/tokenhub disconnect --admin
|
|
15
|
-
npx @emesoft/tokenhub overlay
|
|
16
|
-
```
|
|
17
26
|
|
|
18
|
-
|
|
27
|
+
`connect` shows a short code and opens your browser. Sign in to the pool, check the code matches, and confirm. That's it: Claude Code now runs through the pool.
|
|
28
|
+
|
|
29
|
+
<img src="https://tokenhub.aimpact.io.vn/readme/connect.png" alt="tokenhub connect in a terminal, next to the pool's page confirming the same code" width="100%">
|
|
30
|
+
|
|
31
|
+
From then on, today's spend and your credit sit under the Claude Code prompt:
|
|
32
|
+
|
|
33
|
+
<img src="https://tokenhub.aimpact.io.vn/readme/statusline.png" alt="The TokenHub status line under the Claude Code prompt" width="560">
|
|
34
|
+
|
|
35
|
+
Prefer not to install? Use `npx @emesoft/tokenhub connect` instead.
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
| Command | What it does |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| `tokenhub connect [poolUrl]` | Pair this machine with the pool (default `https://tokenhub.aimpact.io.vn`). |
|
|
42
|
+
| `tokenhub usage [--json]` | Today's and this week's spend against your limits, your credit and pool health. |
|
|
43
|
+
| `tokenhub dashboard` | Live full-screen view of spend and your recent requests. |
|
|
44
|
+
| `tokenhub overlay [poolUrl]` | Install the TokenHub desktop overlay (Windows). |
|
|
45
|
+
| `tokenhub disconnect` | Undo `connect`. |
|
|
46
|
+
| `tokenhub --help` / `--version` | Help and version. |
|
|
47
|
+
|
|
48
|
+
### Options
|
|
49
|
+
|
|
50
|
+
| Option | Applies to | Effect |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `--no-statusline` | `connect` | Don't add the spend status line to Claude Code. |
|
|
53
|
+
| `--admin` | `connect`, `disconnect` | Pair (or forget) this machine as an admin device. See [For admins](#for-admins). |
|
|
54
|
+
| `--json` | `usage` | Print the raw report. |
|
|
55
|
+
| `--interval <sec>` | `dashboard` | Refresh rate in seconds (default 3, minimum 2). |
|
|
56
|
+
| `--once` | `dashboard` | Print one frame and exit. |
|
|
57
|
+
|
|
58
|
+
**Exit codes:** `usage` and `dashboard --once` exit `2` while the pool would refuse your requests (out of credit or over budget), so scripts can check before starting a job.
|
|
59
|
+
|
|
60
|
+
## What `connect` changes
|
|
61
|
+
|
|
62
|
+
`connect` edits Claude Code's settings file, `~/.claude/settings.json` (or `$CLAUDE_CONFIG_DIR/settings.json`):
|
|
63
|
+
|
|
64
|
+
- Sets `env.ANTHROPIC_BASE_URL` and `env.ANTHROPIC_AUTH_TOKEN` to the pool and a new key for this machine.
|
|
65
|
+
- Adds a `statusLine` showing today's spend and credit, unless you already have one or pass `--no-statusline`.
|
|
66
|
+
- Keeps every other setting, and saves the previous file as `settings.json.bak`.
|
|
67
|
+
|
|
68
|
+
Each machine gets its own key, which you can revoke from the pool's **Keys** page. `disconnect` removes exactly these entries and nothing else.
|
|
69
|
+
|
|
70
|
+
> If `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN` or `ANTHROPIC_API_KEY` is set in your shell, it takes precedence over `settings.json`. `connect` warns you when it finds one.
|
|
71
|
+
|
|
72
|
+
## Dashboard
|
|
73
|
+
|
|
74
|
+
`tokenhub dashboard` shows your daily and weekly spend as bars against your limits (green below 70%, orange to 90%, red above), your credit, pool health and your latest requests. Press `r` to refresh now and `q` to quit. If the connection drops, it keeps the last screen and reconnects on its own. With `--once`, `NO_COLOR` or no terminal, it prints a single plain frame.
|
|
75
|
+
|
|
76
|
+
<img src="https://tokenhub.aimpact.io.vn/readme/dashboard.png" alt="tokenhub dashboard: daily and weekly spend bars, credit, pool health and recent requests" width="100%">
|
|
77
|
+
|
|
78
|
+
## Desktop overlay
|
|
79
|
+
|
|
80
|
+
`tokenhub overlay` downloads the TokenHub overlay installer from the pool and starts it (Windows). The overlay is a small always-on-top widget that shows your own usage after `connect`, or the whole pool after `connect --admin`.
|
|
81
|
+
|
|
82
|
+
<img src="https://tokenhub.aimpact.io.vn/readme/overlay.jpg" alt="The TokenHub desktop overlay, collapsed and expanded, on a desktop" width="100%">
|
|
83
|
+
|
|
84
|
+
<sub>Screenshots use sample data.</sub>
|
|
85
|
+
|
|
86
|
+
## For admins
|
|
87
|
+
|
|
88
|
+
`tokenhub connect --admin` pairs this machine as an **admin device** for the desktop overlay's pool view:
|
|
89
|
+
|
|
90
|
+
- You confirm the code in the pool's **admin** console, so only a signed-in admin can approve it.
|
|
91
|
+
- The device token is saved to `~/.tokenhub/admin.json` (or `$TOKENHUB_CONFIG_DIR/admin.json`). Claude Code's settings are not touched.
|
|
92
|
+
- The token can read account names and quota levels and switch accounts on or off. It cannot see emails, tokens, members or settings.
|
|
19
93
|
|
|
20
|
-
|
|
94
|
+
Revoke a device from the admin **Devices** page (`/admin/pair`). `tokenhub disconnect --admin` only forgets the token on this machine.
|
|
21
95
|
|
|
22
|
-
|
|
96
|
+
## Privacy
|
|
23
97
|
|
|
24
|
-
|
|
98
|
+
The CLI talks only to the pool you connect to. Requests carry your key and one header, `x-tokenhub-cli: <version>`. Nothing else is collected or sent.
|
|
25
99
|
|
|
26
|
-
|
|
100
|
+
## Troubleshooting
|
|
27
101
|
|
|
28
|
-
|
|
102
|
+
| Problem | Fix |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| `tokenhub: command not found` after `npm install` | Install globally with `-g`. A plain `npm install` puts it in the current folder, which isn't on your `PATH` (only `npx` finds it there). |
|
|
105
|
+
| Command missing after switching Node with nvm | Global packages belong to one Node version. Run `npm install -g @emesoft/tokenhub` again. |
|
|
106
|
+
| `The pool rejected this key` | The key was revoked. Run `tokenhub connect` again. |
|
|
107
|
+
| Claude Code ignores the pool | A shell variable is overriding `settings.json` (see the note under [What `connect` changes](#what-connect-changes)). |
|
|
29
108
|
|
|
30
|
-
|
|
109
|
+
## Links
|
|
31
110
|
|
|
32
|
-
|
|
111
|
+
- Pool: sign in, manage keys and top up at [tokenhub.aimpact.io.vn](https://tokenhub.aimpact.io.vn)
|
|
112
|
+
- Changelog: [npm versions](https://www.npmjs.com/package/@emesoft/tokenhub?activeTab=versions)
|
|
33
113
|
|
|
34
|
-
|
|
114
|
+
## License
|
|
35
115
|
|
|
36
|
-
|
|
116
|
+
MIT © Emesoft. The full text is in the `LICENSE` file shipped with the package.
|
package/package.json
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emesoft/tokenhub",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.7.2",
|
|
4
|
+
"description": "Connect Claude Code to a TokenHub pool in one command, and track your spend from the terminal",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"claude",
|
|
7
|
+
"claude-code",
|
|
8
|
+
"anthropic",
|
|
9
|
+
"tokenhub",
|
|
10
|
+
"cli"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://tokenhub.aimpact.io.vn",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Emesoft",
|
|
5
15
|
"type": "module",
|
|
6
16
|
"bin": {
|
|
7
17
|
"tokenhub": "bin/tokenhub.js"
|
|
@@ -9,13 +19,13 @@
|
|
|
9
19
|
"files": [
|
|
10
20
|
"bin",
|
|
11
21
|
"lib",
|
|
12
|
-
"README.md"
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
13
24
|
],
|
|
14
25
|
"engines": {
|
|
15
26
|
"node": ">=18"
|
|
16
27
|
},
|
|
17
28
|
"publishConfig": {
|
|
18
29
|
"access": "public"
|
|
19
|
-
}
|
|
20
|
-
"license": "UNLICENSED"
|
|
30
|
+
}
|
|
21
31
|
}
|