tokenmaxxing 1.69.0 → 1.70.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenmaxxing",
3
- "version": "1.69.0",
3
+ "version": "1.70.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",
@@ -169,7 +169,7 @@ function latestSessionForCwd(): string | null {
169
169
  .filter((f) => f.endsWith(".jsonl"))
170
170
  .map((f) => ({ f, m: statSync(join(projDir, f)).mtimeMs }));
171
171
  const newest = maxBy(files, (x) => x.m);
172
- return newest ? newest.f.replace(/\.jsonl$/, "") : null;
172
+ return newest ? basename(newest.f, ".jsonl") : null;
173
173
  } catch {
174
174
  return null;
175
175
  }
@@ -1,4 +1,4 @@
1
- import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, rmSync, symlinkSync } from "node:fs";
1
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, symlinkSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { z } from "zod";
4
4
  import { writeFileAtomic } from "./atomic.ts";
@@ -45,25 +45,11 @@ export function ensureCodexStoreHome(accountId: string): string {
45
45
  mkdirSync(store, { recursive: true });
46
46
  mkdirSync(codexPaths.home, { recursive: true });
47
47
  mkdirSync(join(codexPaths.home, "sessions"), { recursive: true });
48
- let names: string[] = [];
49
- try {
50
- names = readdirSync(codexPaths.home);
51
- } catch (e) {
52
- if (ErrnoSchema.safeParse(e).data?.code === "ENOENT") return store;
53
- throw e;
54
- }
55
- for (const name of names) {
48
+ for (const name of readdirSync(codexPaths.home)) {
56
49
  if (name === "auth.json") continue;
57
50
  const target = join(codexPaths.home, name);
58
51
  const link = join(store, name);
59
- if (existsSync(link)) {
60
- try {
61
- if (lstatSync(link).isSymbolicLink()) continue;
62
- } catch {
63
- continue;
64
- }
65
- continue;
66
- }
52
+ if (existsSync(link)) continue;
67
53
  try {
68
54
  symlinkSync(target, link);
69
55
  } catch (e) {
package/src/lib/sample.ts CHANGED
@@ -11,7 +11,7 @@ import type { Account, Config, UsageWindows } from "./types.ts";
11
11
 
12
12
  export type SampleOutcome = { ok: true; usage: UsageWindows; via: "get" } | { ok: false; reason: string; retryAt?: number };
13
13
 
14
- type PreparedSample = { ok: true; token: string | null } | { ok: false; reason: string };
14
+ type PreparedSample = { ok: true; token: string } | { ok: false; reason: string };
15
15
 
16
16
  export function teeObservation(account: Account): Observation | null {
17
17
  const stored = account.lastUsageAt != null ? { windows: account.windows, at: account.lastUsageAt } : null;
@@ -56,8 +56,7 @@ function rateLimitedReason(retryAt: number, now: number): string {
56
56
  return `the usage endpoint rate limited this account, next read in ${Math.ceil((retryAt - now) / 60_000)}m`;
57
57
  }
58
58
 
59
- export async function runSample(account: Account, token: string | null): Promise<SampleOutcome> {
60
- if (!token) return { ok: false, reason: "no usable access token in the store - run `tokenmaxxing auth`" };
59
+ export async function runSample(account: Account, token: string): Promise<SampleOutcome> {
61
60
  const read = await fetchUsageDirect(token);
62
61
  if (read.ok) return { ok: true, usage: read.usage, via: "get" };
63
62
  if (read.retryAt == null) return { ok: false, reason: "usage read failed (see log)" };
@@ -91,7 +90,7 @@ export async function sampleOldest(cfg: Config): Promise<void> {
91
90
  if (dirty) saveAccounts(claudePool, idx);
92
91
  return [];
93
92
  }
94
- const batch: { account: Account; token: string | null }[] = [];
93
+ const batch: { account: Account; token: string }[] = [];
95
94
  for (const target of stale) {
96
95
  target.lastProbeAt = now;
97
96
  const prepared = await prepareSample(target);