@rikcodes/teamclaude 1.1.13-rik.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KarpelesLab
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 ADDED
@@ -0,0 +1,122 @@
1
+ # TeamClaude
2
+
3
+ > **Fork notice (rikbrown).** This fork adds one feature and two reload fixes on top of
4
+ > [KarpelesLab/teamclaude](https://github.com/KarpelesLab/teamclaude):
5
+ >
6
+ > - **[Soonest-weekly rotation](docs/routing.md#soonest-weekly-rotation)** (`soonestWeekly`, opt-in): rank
7
+ > equal-priority accounts by the weekly window that governs the requested model, continuously — preempt the
8
+ > current account when another resets more than `poolHours` sooner, and balance `distributeSessions` within
9
+ > that pool instead of across all accounts. Spends the quota closest to refreshing first, so a window no
10
+ > longer rolls over with quota unspent.
11
+ > - `soonestWeekly` and `distributeSessions` changes now apply on config reload; upstream applies
12
+ > `distributeSessions` only at startup.
13
+ >
14
+ > Published as [`@rikcodes/teamclaude`](https://www.npmjs.com/package/@rikcodes/teamclaude); self-update
15
+ > tracks that package, so installs of this fork can never be replaced by an upstream release.
16
+ >
17
+ > ```bash
18
+ > npm install -g @rikcodes/teamclaude
19
+ > ```
20
+ >
21
+ > Branch: `rik/soonest-weekly-pool`. Everything else matches upstream.
22
+
23
+ [![CI](https://github.com/KarpelesLab/teamclaude/actions/workflows/ci.yml/badge.svg)](https://github.com/KarpelesLab/teamclaude/actions/workflows/ci.yml)
24
+ [![npm version](https://img.shields.io/npm/v/@karpeleslab/teamclaude.svg)](https://www.npmjs.com/package/@karpeleslab/teamclaude)
25
+ [![node](https://img.shields.io/node/v/@karpeleslab/teamclaude.svg)](https://nodejs.org)
26
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
27
+
28
+ Multi-account Claude proxy with automatic quota-based rotation for [Claude Code](https://claude.ai/claude-code).
29
+
30
+ It sits between Claude Code and the Anthropic API, holds several Claude Max (or API key) accounts, and moves to the next one when the current account gets close to its session or weekly limit. The session keeps running instead of stopping on a 429.
31
+
32
+ ![TeamClaude TUI](screenshots/teamclaude.png)
33
+
34
+ ## Quick start
35
+
36
+ Node.js 20+ required.
37
+
38
+ ```bash
39
+ npm install -g @rikcodes/teamclaude
40
+
41
+ teamclaude login # browser OAuth, run it once per account
42
+ teamclaude server # start the proxy, shows the TUI
43
+ teamclaude run # in another terminal: Claude Code through the proxy
44
+ ```
45
+
46
+ Already logged into Claude Code? `teamclaude import` takes its credentials instead of a fresh OAuth round. API keys, and one email holding accounts in several orgs, are covered in [docs/accounts.md](docs/accounts.md).
47
+
48
+ ## What it does
49
+
50
+ - Rotates to the next account when the 5h session or 7d weekly bucket reaches the threshold (98% by default), preferring the account whose weekly quota resets soonest.
51
+ - Tracks the per-model weekly cap separately, so an account out of Fable quota is skipped for Fable requests and still serves Opus and Sonnet.
52
+ - Tells a spent quota bucket apart from a per-minute rate limit and only rotates on the first one. Rotating on a rate limit would just move the burst to the next account and drop the warm cache, so it paces the same account instead.
53
+ - Paces requests onto a freshly switched account, so a herd of agents failing over at the same instant doesn't throttle it and cascade down the fleet.
54
+ - TUI with quota bars, reset countdowns, activity log, and settings you can change while it runs, including adding and removing accounts.
55
+ - Catches hardcoded `api.anthropic.com` endpoints (the Claude Design MCP, for one) through a local MITM forward proxy, not only what `ANTHROPIC_BASE_URL` covers.
56
+ - Holds the request open until quota resets instead of returning 429 when every account is spent, so an unattended run finishes on its own (`holdSeconds`, off by default).
57
+ - Refreshes OAuth tokens before they expire and writes them back to config. Client refreshes pass through untouched.
58
+ - Takes any Anthropic-compatible API (DeepSeek, GLM) as a low-priority fallback for when the Claude accounts are done.
59
+ - No dependencies. Node built-ins only.
60
+
61
+ ## Everyday commands
62
+
63
+ ```bash
64
+ teamclaude accounts # accounts with tier and token status
65
+ teamclaude status # live proxy status, needs a running server
66
+ teamclaude disable <name> # pause an account without removing it
67
+ teamclaude priority <name> 1 # rotation order, lower = preferred
68
+ teamclaude alias --install # make plain `claude` go through the proxy
69
+ teamclaude help # everything else
70
+ ```
71
+
72
+ Full reference: [docs/usage.md](docs/usage.md).
73
+
74
+ ## Configuration
75
+
76
+ Config is at `~/.config/teamclaude.json` (`$XDG_CONFIG_HOME` honoured) and is meant to be hand-editable. A proxy API key is generated on first use. Observed quota goes to a separate `teamclaude.state.json` next to it, safe to delete since quota gets re-learned from traffic.
77
+
78
+ Every field, plus environment variables and network tuning: [docs/configuration.md](docs/configuration.md).
79
+
80
+ ## How it works
81
+
82
+ 1. Claude Code talks to the local proxy instead of `api.anthropic.com`.
83
+ 2. The proxy picks an eligible account, injects that account's real token, and rewrites `account_uuid` in the body to match.
84
+ 3. `anthropic-ratelimit-unified-*` response headers feed the session (5h) and weekly (7d) quota view, which survives a restart.
85
+ 4. At the threshold, rotation moves on. On a quota 429 the request is resent on another account, so the client never sees the limit while some account still has headroom.
86
+ 5. Expiring tokens, transient network errors and client token refreshes are handled inside the proxy, so none of them interrupt the session.
87
+
88
+ Step-by-step lifecycle: [docs/routing.md](docs/routing.md#request-lifecycle).
89
+
90
+ ## Documentation
91
+
92
+ | Page | Contents |
93
+ | --- | --- |
94
+ | [Accounts](docs/accounts.md) | OAuth login, import, API keys, multiple orgs, third-party backends |
95
+ | [Usage](docs/usage.md) | Server and TUI, running Claude Code, shell alias, command reference, logging |
96
+ | [Routing](docs/routing.md) | Rotation, the two kinds of 429, storm control, model routes, session spreading, pinning, prompt cache |
97
+ | [Quota](docs/quota.md) | Quota probe, keep-warm, holding on exhaustion |
98
+ | [Configuration](docs/configuration.md) | Config format, every field, environment variables, network tuning |
99
+ | [Proxy modes](docs/proxy-modes.md) | MITM forward proxy, sx.org residential egress |
100
+ | [Compliance](docs/compliance.md) | Terms of service notes |
101
+
102
+ ## Security
103
+
104
+ The only canonical sources for TeamClaude are this repository (https://github.com/KarpelesLab/teamclaude) and the [`@karpeleslab/teamclaude`](https://www.npmjs.com/package/@karpeleslab/teamclaude) npm package. TeamClaude is **never** distributed as a downloadable binary archive, so be wary of soft-forks that bundle a `.zip` and tell you to extract and run it. See [SECURITY.md](SECURITY.md) for details and how to report issues.
105
+
106
+ ## Compliance
107
+
108
+ TeamClaude is a local proxy holding your own credentials and driving your own Claude Code CLI. How that lines up with Anthropic's terms, including the multi-subscription question people ask most, is written up in [docs/compliance.md](docs/compliance.md). Not legal advice.
109
+
110
+ ## Star history
111
+
112
+ <a href="https://www.star-history.com/?repos=KarpelesLab%2Fteamclaude&type=date&legend=top-left">
113
+ <picture>
114
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=KarpelesLab/teamclaude&type=date&theme=dark&legend=top-left" />
115
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=KarpelesLab/teamclaude&type=date&legend=top-left" />
116
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=KarpelesLab/teamclaude&type=date&legend=top-left" />
117
+ </picture>
118
+ </a>
119
+
120
+ ## License
121
+
122
+ MIT — see [LICENSE](LICENSE).
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@rikcodes/teamclaude",
3
+ "version": "1.1.13-rik.1",
4
+ "description": "Multi-account Claude proxy with automatic quota-based rotation",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "bin": {
8
+ "teamclaude": "src/index.js"
9
+ },
10
+ "files": [
11
+ "src/"
12
+ ],
13
+ "keywords": [
14
+ "claude",
15
+ "anthropic",
16
+ "proxy",
17
+ "load-balancer",
18
+ "multi-account"
19
+ ],
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/rikbrown/teamclaude.git"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/rikbrown/teamclaude/issues"
27
+ },
28
+ "homepage": "https://github.com/rikbrown/teamclaude#readme",
29
+ "engines": {
30
+ "node": ">=20.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "eslint": "^9.0.0"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "scripts": {
39
+ "start": "node src/index.js",
40
+ "test": "node --test --test-timeout=120000",
41
+ "lint": "eslint ."
42
+ }
43
+ }