@rikcodes/teamclaude 1.1.13-rik.5 → 1.1.14-rik.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TeamClaude
2
2
 
3
- > **Fork notice (rikbrown).** This fork adds four features and two reload fixes on top of
3
+ > **Fork notice (rikbrown).** This fork adds three features on top of
4
4
  > [KarpelesLab/teamclaude](https://github.com/KarpelesLab/teamclaude):
5
5
  >
6
6
  > - **[OpenAI models via a Codex sidecar](docs/openai.md)** (`sidecars` + `customModels`, opt-in):
@@ -11,16 +11,11 @@
11
11
  > equal-priority accounts by the weekly window that governs the requested model, continuously — preempt the
12
12
  > current account when another resets more than `poolHours` sooner, and balance `distributeSessions` within
13
13
  > that pool instead of across all accounts. Spends the quota closest to refreshing first, so a window no
14
- > longer rolls over with quota unspent.
14
+ > longer rolls over with quota unspent. Applied live on config reload.
15
15
  > - **[Burn-rate projection](docs/quota.md#burn-rate-projection)** (`projection`, on by default): sample each
16
16
  > bucket's consumption over a rolling window and tag every account row with whichever window binds
17
17
  > first — `Ses TTL 38m` when it runs out before it resets, `Wk 22% unspent` when the reset arrives
18
18
  > first and that much expires. A readout only: no selection code reads it.
19
- > - **[Session titles](docs/usage.md#session-titles-in-the-activity-log)** (`sessionTitles`, off by default):
20
- > name each activity row after the Claude Code session that sent the request, reading the title
21
- > `/rename` writes and the one Claude Code generates. A session with neither keeps its short id.
22
- > - `soonestWeekly` and `distributeSessions` changes now apply on config reload; upstream applies
23
- > `distributeSessions` only at startup.
24
19
  >
25
20
  > Setup and use of each: [Fork features](#fork-features).
26
21
  >
@@ -61,6 +56,12 @@ teamclaude run # in another terminal: Claude Code through the proxy
61
56
 
62
57
  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).
63
58
 
59
+ `teamclaude run` does not require a separate Claude Code login for normal API
60
+ requests. When there is no usable local Claude OAuth (no login, or one that can
61
+ no longer be refreshed), proxy credential mode supplies a local-only bootstrap
62
+ key; the proxy replaces that placeholder
63
+ with the selected TeamClaude account credential before forwarding.
64
+
64
65
  ## What it does
65
66
 
66
67
  - 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.
@@ -191,10 +192,6 @@ Default selection is sticky. It re-ranks only when the current account is exhaus
191
192
 
192
193
  This feature is on by default. Each account row shows which window binds first: `Ses TTL 38m` when the session bucket runs out before it resets, or `Wk 22% unspent` when the weekly reset arrives first and that amount of quota expires. This is a readout only; no selection code reads it. Tune or disable it with `projection: { enabled, windowMinutes, wasteFloor }`. Details: [Quota](docs/quota.md#burn-rate-projection).
193
194
 
194
- ### Session titles
195
-
196
- This feature is off by default. Activity rows use the name of the Claude Code session that sent the request. They use the title written by `/rename` or the title that Claude Code generates; a session with neither keeps its short id. Toggle the feature from the settings screen (**g** → Session titles) or with `sessionTitles: { enabled, width, projectsDir }`. Details: [Usage](docs/usage.md#session-titles-in-the-activity-log).
197
-
198
195
  ## Documentation
199
196
 
200
197
  | Page | Contents |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rikcodes/teamclaude",
3
- "version": "1.1.13-rik.5",
3
+ "version": "1.1.14-rik.2",
4
4
  "description": "Multi-account Claude proxy with automatic quota-based rotation",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -0,0 +1,52 @@
1
+ // The identifier a config account entry carries, and the reason it has to exist.
2
+ //
3
+ // The config list and the AccountManager's are not positionally aligned:
4
+ // resolveAccounts drops every entry without a usable credential, so from the
5
+ // first drop onward a config index and a manager index name different accounts
6
+ // for the life of the process. Nothing on the records recovers the pairing
7
+ // either. Two entries can agree on name, account, organization and credential,
8
+ // and the credential — the one field that might separate two records of one
9
+ // person — is rewritten by the token refresh that makes the pairing matter.
10
+ //
11
+ // So an entry carries an identifier of its own, assigned before anything can
12
+ // read one, never rewritten afterwards, and copied onto the account built from
13
+ // the entry by makeAccount.
14
+
15
+ import { randomUUID } from 'node:crypto';
16
+
17
+ /**
18
+ * A fresh entry id.
19
+ *
20
+ * Minted where an entry and the account built from it are created together — the
21
+ * TUI's add paths — because the two have to agree on an id before anything reads
22
+ * one. An entry created anywhere else reaches memory through loadConfig or an
23
+ * admission from disk, and both of those assign ids, so those paths mint none of
24
+ * their own.
25
+ */
26
+ export function mintAccountId() {
27
+ return randomUUID();
28
+ }
29
+
30
+ /**
31
+ * Give every entry in `accounts` an id that no other entry in the list holds,
32
+ * mutating them in place, and return the list.
33
+ *
34
+ * Entry creation mints an id, so this is for entries that arrive already made:
35
+ * a config written before the field existed, and an entry admitted from disk
36
+ * while the server runs. Calling it as those enter an in-memory list is what
37
+ * makes the uniqueness every lookup assumes true from the first read.
38
+ *
39
+ * A duplicate is re-minted rather than kept. Copying an account section by hand
40
+ * copies its id along with it, and two entries answering to one id collapse
41
+ * onto whichever comes first — the later one would be handed the earlier one's
42
+ * credential, which is the crossing this field exists to prevent.
43
+ */
44
+ export function ensureAccountIds(accounts) {
45
+ const seen = new Set();
46
+ for (const acct of accounts || []) {
47
+ if (!acct) continue;
48
+ if (typeof acct.id !== 'string' || acct.id === '' || seen.has(acct.id)) acct.id = mintAccountId();
49
+ seen.add(acct.id);
50
+ }
51
+ return accounts;
52
+ }