tokenmaxxing 1.85.0 → 1.86.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.85.0",
3
+ "version": "1.86.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",
@@ -498,7 +498,12 @@ export async function runSupervisor(argv: string[]): Promise<number> {
498
498
  delete compactEnv.TOKENMAXXING_SESSION_ID;
499
499
  delete compactEnv.TOKENMAXXING_LAUNCHED_AT;
500
500
  delete compactEnv.TOKENMAXXING_MODEL;
501
- const outcome = await compactClaudeSession({ real, sid: m.sessionId, transcript, env: compactEnv });
501
+ const outcome = await compactClaudeSession({ real, sid: m.sessionId, transcript, env: compactEnv, onSpawn: (p) => { child = p; } });
502
+ child = null;
503
+ if (terminating) {
504
+ await releaseClaim();
505
+ return 143;
506
+ }
502
507
  log("supervisor.compact", { sid: m.sessionId.slice(0, 8), seat: seat.id.slice(0, 8), ok: outcome.ok, reason: outcome.ok ? undefined : outcome.reason });
503
508
  if (!outcome.ok) say(`\x1b[33m compaction did not land (${outcome.reason}) - resuming with the full context\x1b[0m\n`, `tokenmaxxing: compaction did not land; resuming with the full context. (${outcome.reason})`);
504
509
  compacted = outcome.ok;
@@ -1,4 +1,5 @@
1
1
  import { statSync } from "node:fs";
2
+ import type { Subprocess } from "bun";
2
3
  import { delay } from "es-toolkit";
3
4
  import { z } from "zod";
4
5
  import pkg from "../../package.json" with { type: "json" };
@@ -13,7 +14,7 @@ const PIPE_GRACE_MS = 2_000;
13
14
 
14
15
  const CompactBoundarySchema = z.looseObject({ type: z.literal("system"), subtype: z.literal("compact_boundary") });
15
16
 
16
- export async function compactClaudeSession(input: { real: string; sid: string; transcript: string; env: Record<string, string | undefined> }): Promise<CompactOutcome> {
17
+ export async function compactClaudeSession(input: { real: string; sid: string; transcript: string; env: Record<string, string | undefined>; onSpawn: (child: Subprocess) => void }): Promise<CompactOutcome> {
17
18
  const offset = statSync(input.transcript).size;
18
19
  const p = Bun.spawn([input.real, "-p", "--resume", input.sid, "/compact"], {
19
20
  env: input.env,
@@ -23,6 +24,7 @@ export async function compactClaudeSession(input: { real: string; sid: string; t
23
24
  timeout: CLAUDE_COMPACT_KILL_MS,
24
25
  killSignal: "SIGKILL",
25
26
  });
27
+ input.onSpawn(p);
26
28
  const reads = Promise.all([p.stdout.text(), p.stderr.text()]);
27
29
  const settled = await Promise.race([reads, p.exited.then(() => delay(PIPE_GRACE_MS)).then(() => null)]);
28
30
  await p.exited;