tokenmaxxing 1.73.0 → 1.74.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/entries/codexstophook.ts +0 -2
- package/src/lib/claudebin.ts +1 -2
- package/src/lib/codex.ts +1 -2
- package/src/lib/codexauth.ts +0 -1
- package/src/lib/grok.ts +1 -2
- package/src/lib/install.ts +1 -4
- package/src/lib/opencodego.ts +1 -2
- package/src/lib/presence.ts +1 -2
- package/src/lib/sessions.ts +1 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokenmaxxing",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.74.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",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { mkdirSync } from "node:fs";
|
|
3
2
|
import type { z } from "zod";
|
|
4
3
|
import { codexPaths, optionalEnv } from "../lib/paths.ts";
|
|
5
4
|
import { writeFileAtomic } from "../lib/atomic.ts";
|
|
@@ -50,7 +49,6 @@ async function handleCodexStop(rawStdin: string): Promise<void> {
|
|
|
50
49
|
await compactBeforeMove({ sessionId, now });
|
|
51
50
|
const decision = await evaluateAndMaybeSwap(codex, now);
|
|
52
51
|
if (decision.swapped && decision.account) {
|
|
53
|
-
mkdirSync(codexPaths.respawnDir, { recursive: true });
|
|
54
52
|
const payload: z.infer<typeof CodexRespawnMarkerSchema> = { accountId: decision.account.id, sessionId, ts: Date.now() };
|
|
55
53
|
writeFileAtomic(join(codexPaths.respawnDir, supervisorId), JSON.stringify(payload));
|
|
56
54
|
log("codexstop.marker", { supervisorId: supervisorId.slice(0, 8) });
|
package/src/lib/claudebin.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync,
|
|
1
|
+
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { uniq } from "es-toolkit";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -30,7 +30,6 @@ export function wrapperEntryRateTripped(now: number): boolean {
|
|
|
30
30
|
entries = entries.filter((t) => now - t < WRAP_RATE_WINDOW_MS);
|
|
31
31
|
entries.push(now);
|
|
32
32
|
try {
|
|
33
|
-
mkdirSync(paths.home, { recursive: true });
|
|
34
33
|
writeFileAtomic(file, JSON.stringify({ entries }));
|
|
35
34
|
} catch { }
|
|
36
35
|
return entries.length > WRAP_RATE_MAX;
|
package/src/lib/codex.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync,
|
|
1
|
+
import { existsSync, readFileSync, rmSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { writeFileAtomic } from "./atomic.ts";
|
|
4
4
|
import { MAX_WRAP_DEPTH, WRAP_DEPTH_ENV } from "./claudebin.ts";
|
|
@@ -116,7 +116,6 @@ async function login(): Promise<Harvest | null> {
|
|
|
116
116
|
const real = resolveRealCodex();
|
|
117
117
|
const onboardDir = codexPaths.onboardDir;
|
|
118
118
|
rmSync(onboardDir, { recursive: true, force: true });
|
|
119
|
-
mkdirSync(onboardDir, { recursive: true });
|
|
120
119
|
writeFileAtomic(join(onboardDir, "config.toml"), 'cli_auth_credentials_store = "file"\n');
|
|
121
120
|
|
|
122
121
|
const savedTermios = saveTermios();
|
package/src/lib/codexauth.ts
CHANGED
|
@@ -32,7 +32,6 @@ export function codexStoreUsable(accountId: string): boolean {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export function writeCodexStoreAuth(accountId: string, auth: CodexAuthJson): void {
|
|
35
|
-
mkdirSync(codexStoreDirFor(accountId), { recursive: true });
|
|
36
35
|
writeFileAtomic(codexAuthJsonFor(accountId), JSON.stringify(CodexAuthJsonSchema.parse(auth), null, 2), 0o600);
|
|
37
36
|
}
|
|
38
37
|
|
package/src/lib/grok.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { writeFileAtomic } from "./atomic.ts";
|
|
@@ -31,7 +31,6 @@ function harvestOf(id: string, key: string, entry: GrokAuthEntry): Harvest {
|
|
|
31
31
|
tier: null,
|
|
32
32
|
sample: null,
|
|
33
33
|
park: async () => {
|
|
34
|
-
mkdirSync(grokStoreDirFor(id), { recursive: true });
|
|
35
34
|
writeFileAtomic(grokAuthJsonFor(id), JSON.stringify({ [key]: entry }, null, 2), 0o600);
|
|
36
35
|
},
|
|
37
36
|
};
|
package/src/lib/install.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { accessSync, appendFileSync, constants, existsSync,
|
|
1
|
+
import { accessSync, appendFileSync, constants, existsSync, readFileSync, realpathSync, rmSync, statSync } from "node:fs";
|
|
2
2
|
import { userInfo } from "node:os";
|
|
3
3
|
import { basename, dirname, join, resolve } from "node:path";
|
|
4
4
|
import { escape } from "es-toolkit";
|
|
@@ -89,7 +89,6 @@ exec ${JSON.stringify(bun)} --no-env-file run ${JSON.stringify(entry)} "$@"
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export function installSupervisor(): InstallOutcome {
|
|
92
|
-
mkdirSync(paths.binDir, { recursive: true });
|
|
93
92
|
const target = installedBin();
|
|
94
93
|
const entry = realpathSync(Bun.main);
|
|
95
94
|
if (isNixPackaged()) {
|
|
@@ -147,7 +146,6 @@ export function installCodexStopHook(): void {
|
|
|
147
146
|
],
|
|
148
147
|
},
|
|
149
148
|
};
|
|
150
|
-
mkdirSync(codexPaths.home, { recursive: true });
|
|
151
149
|
writeFileAtomic(codexPaths.hooksJson, JSON.stringify(next, null, 2) + "\n");
|
|
152
150
|
}
|
|
153
151
|
|
|
@@ -198,7 +196,6 @@ export function codexSupervisorLink(): string {
|
|
|
198
196
|
}
|
|
199
197
|
|
|
200
198
|
export function installCodexSupervisor(): void {
|
|
201
|
-
mkdirSync(paths.binDir, { recursive: true });
|
|
202
199
|
writeFileAtomic(codexSupervisorLink(), `#!/bin/sh\nexec ${JSON.stringify(installedBin())} __supervise-codex "$@"\n`, 0o755);
|
|
203
200
|
installCodexStopHook();
|
|
204
201
|
}
|
package/src/lib/opencodego.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { writeFileAtomic } from "./atomic.ts";
|
|
@@ -29,7 +29,6 @@ function harvestOf(key: string): Harvest {
|
|
|
29
29
|
tier: "go",
|
|
30
30
|
sample: null,
|
|
31
31
|
park: async () => {
|
|
32
|
-
mkdirSync(opencodeGoStoreDirFor(id), { recursive: true });
|
|
33
32
|
writeFileAtomic(opencodeGoAuthJsonFor(id), JSON.stringify({ "opencode-go": { type: "api", key } }, null, 2), 0o600);
|
|
34
33
|
},
|
|
35
34
|
};
|
package/src/lib/presence.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync,
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, rmSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { writeFileAtomic } from "./atomic.ts";
|
|
@@ -14,7 +14,6 @@ const PresenceSchema = z.object({
|
|
|
14
14
|
export function writePresence(input: { dir: string; id: string; accountId: string; pid: number }): void {
|
|
15
15
|
const startedAt = pidStartTime(input.pid);
|
|
16
16
|
if (startedAt == null) throw new Error(`could not read pid ${input.pid}'s start time (ps lstart) - refusing to write an unverifiable presence file`);
|
|
17
|
-
mkdirSync(input.dir, { recursive: true });
|
|
18
17
|
writeFileAtomic(join(input.dir, input.id), JSON.stringify(PresenceSchema.parse({ accountId: input.accountId, pid: input.pid, startedAt })));
|
|
19
18
|
}
|
|
20
19
|
|
package/src/lib/sessions.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync,
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, realpathSync, rmSync, statSync, type Dirent } from "node:fs";
|
|
2
2
|
import { basename, join, sep } from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { errorMessage, log } from "./log.ts";
|
|
@@ -19,7 +19,6 @@ function sessionFile(sid: string): string {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function saveSessionFlags(sid: string, flags: string[], cwd: string): void {
|
|
22
|
-
mkdirSync(sessionsDir(), { recursive: true });
|
|
23
22
|
writeFileAtomic(sessionFile(sid), JSON.stringify({ flags, cwd }));
|
|
24
23
|
}
|
|
25
24
|
|
|
@@ -39,7 +38,6 @@ export function liveSessionId(sid: string): string {
|
|
|
39
38
|
|
|
40
39
|
function recordLiveSession(sid: string, current: string): void {
|
|
41
40
|
const session = loadSession(sid);
|
|
42
|
-
mkdirSync(sessionsDir(), { recursive: true });
|
|
43
41
|
writeFileAtomic(sessionFile(sid), JSON.stringify({ flags: session?.flags ?? [], cwd: session?.cwd ?? process.cwd(), current }));
|
|
44
42
|
}
|
|
45
43
|
|
|
@@ -126,7 +124,6 @@ export function adoptLiveSession(session: SupervisedSession, stdinSid: string |
|
|
|
126
124
|
}
|
|
127
125
|
|
|
128
126
|
export function writeRespawnMarker(input: { session: SupervisedSession; accountId: string; waitUntil: number; compact: boolean }): void {
|
|
129
|
-
mkdirSync(paths.respawnDir, { recursive: true });
|
|
130
127
|
const payload: z.infer<typeof RespawnMarkerSchema> = {
|
|
131
128
|
accountId: input.accountId,
|
|
132
129
|
ts: Date.now(),
|