tokenmaxxing 1.75.0 → 1.76.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/package.json +1 -1
- package/src/lib/decide.ts +3 -5
- package/src/lib/presence.ts +2 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokenmaxxing",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.76.0",
|
|
4
4
|
"description": "Automatic Claude Code account switching: pool multiple accounts, start each session on its own account, and resume a session on a fresher account when quota fills.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/lib/decide.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { countBy } from "es-toolkit";
|
|
1
2
|
import { withLock } from "./lock.ts";
|
|
2
3
|
import { loadAccounts, loadConfig, liveWaitClaims, releaseWaitClaim, replaceWaitClaim, saveAccounts } from "./state.ts";
|
|
3
4
|
import { isExhausted, limitWindows, liveUsed, nextWeeklyReset, pickBest, pickWaitTarget, sessionWindow, thresholdBars, weeklyWindow, type PickCtx } from "./picker.ts";
|
|
@@ -157,11 +158,8 @@ export async function evaluateAndMaybeSwap(p: Provider, now = Date.now(), canRes
|
|
|
157
158
|
const fresh = loadAccounts(p.pool);
|
|
158
159
|
const current = seatOf(fresh);
|
|
159
160
|
const ctx: PickCtx = { now, thresholds: bars, currentId: current?.id ?? null, families: switchFamilies, seats };
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
if (claim.sessionId === waiterId) continue;
|
|
163
|
-
waiters.set(claim.accountId, (waiters.get(claim.accountId) ?? 0) + 1);
|
|
164
|
-
}
|
|
161
|
+
const others = liveWaitClaims(now).filter((c) => c.sessionId !== waiterId);
|
|
162
|
+
const waiters = new Map(Object.entries(countBy(others, (c) => c.accountId)));
|
|
165
163
|
const target = pickWaitTarget(usable(fresh.accounts), ctx, waiters, MAX_WAITERS_PER_ACCOUNT, now + cfg.policy.maxWaitMs);
|
|
166
164
|
|
|
167
165
|
if (!target) {
|
package/src/lib/presence.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, rmSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { countBy } from "es-toolkit";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
import { writeFileAtomic } from "./atomic.ts";
|
|
5
6
|
import { pidExists, pidStartTime } from "./proc.ts";
|
|
@@ -70,7 +71,5 @@ export function livingPresences(dir: string): LivingPresence[] {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
export function seatCounts(dir: string): Map<string, number> {
|
|
73
|
-
|
|
74
|
-
for (const presence of livingPresences(dir)) counts.set(presence.accountId, (counts.get(presence.accountId) ?? 0) + 1);
|
|
75
|
-
return counts;
|
|
74
|
+
return new Map(Object.entries(countBy(livingPresences(dir), (p) => p.accountId)));
|
|
76
75
|
}
|