tokenmaxxing 1.133.0 → 1.135.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 -2
- package/src/lib/types.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokenmaxxing",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.135.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
|
@@ -235,10 +235,11 @@ export async function evaluateAndMaybeSwap(p: Provider, now = Date.now(), canRes
|
|
|
235
235
|
const ctx: PickCtx = { now, thresholds: bars, currentId: current?.id ?? null, families: switchFamilies, seats };
|
|
236
236
|
const others = liveWaitClaims(now).filter((c) => c.sessionId !== waiterId);
|
|
237
237
|
const waiters = new Map(Object.entries(countBy(others, (c) => c.accountId)));
|
|
238
|
-
const
|
|
238
|
+
const waitable = usable(fresh.accounts).filter((a) => keyId == null || !opts.refused?.includes(a.id));
|
|
239
|
+
const target = pickWaitTarget(waitable, ctx, waiters, MAX_WAITERS_PER_ACCOUNT, now + cfg.policy.maxWaitMs, now + 2 * cfg.policy.maxWaitMs);
|
|
239
240
|
|
|
240
241
|
if (!target) {
|
|
241
|
-
const soonest = pickWaitTarget(
|
|
242
|
+
const soonest = pickWaitTarget(waitable, ctx, new Map(), MAX_WAITERS_PER_ACCOUNT, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
242
243
|
const waitUntil = soonest?.availableAt ?? Number.POSITIVE_INFINITY;
|
|
243
244
|
log("decide.depleted", { waitUntil: Number.isFinite(waitUntil) ? waitUntil : 0 });
|
|
244
245
|
return { swapped: false, account: null, reason: "all-depleted", ...(Number.isFinite(waitUntil) ? { waitUntil } : {}) };
|
package/src/lib/types.ts
CHANGED
|
@@ -195,10 +195,10 @@ export const SessionCostSchema = z.object({ sessionId: z.string(), usd: z.number
|
|
|
195
195
|
export type SessionCost = z.infer<typeof SessionCostSchema>;
|
|
196
196
|
|
|
197
197
|
export const CostLineSchema = z
|
|
198
|
-
.looseObject({ session_id: z.string(), total_cost_usd: z.number().optional(), cost: z.looseObject({ total_cost_usd: z.number() }).nullable().optional() })
|
|
198
|
+
.looseObject({ session_id: z.string(), num_turns: z.number().optional(), total_cost_usd: z.number().optional(), cost: z.looseObject({ total_cost_usd: z.number() }).nullable().optional() })
|
|
199
199
|
.transform((line): SessionCost | null => {
|
|
200
200
|
const usd = line.total_cost_usd ?? line.cost?.total_cost_usd;
|
|
201
|
-
return usd == null ? null : { sessionId: line.session_id, usd };
|
|
201
|
+
return usd == null || (usd === 0 && line.num_turns === 0) ? null : { sessionId: line.session_id, usd };
|
|
202
202
|
});
|
|
203
203
|
|
|
204
204
|
export const EpochSecondsSchema = z.number().transform((seconds) => seconds * 1000);
|