tokenmaxxing 1.166.0 → 1.167.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.166.0",
3
+ "version": "1.167.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",
@@ -436,7 +436,6 @@ export async function runPiSupervisor(argv: string[]): Promise<number> {
436
436
  log("pisupervisor.depleted_exit", { id, pool, account: target.id.slice(0, 8), waitUntil });
437
437
  say(`\n\x1b[36m⏳ tokenmaxxing: all accounts at their limit, so this session stopped. The next reset is at ${clockFmt.format(waitUntil)} on ${target.label}. Start pi again after that to continue.\x1b[0m\n`);
438
438
  clearPresence({ dir: presenceDir, id });
439
- await releaseClaim();
440
439
  return 1;
441
440
  }
442
441
  say(`\n\x1b[36m↻ tokenmaxxing: moving pi to ${target.label} - resuming...\x1b[0m\n`);
@@ -17,7 +17,7 @@ import { teeObservation } from "../lib/sample.ts";
17
17
  import { childStdout, clockFmt, exitStatus, loopGuardTripped, raceMarkerOrExit, recordPresenceOrStop, relayStdout, runPassthrough, SEAT_POLL_MS, SEAT_RETRY_MS, type Say } from "../lib/supervise.ts";
18
18
  import { saveTermios } from "../lib/tty.ts";
19
19
  import { liveSessionId, loadSessionFlags, pruneStaleSessions, saveSessionFlags, writeRespawnMarker } from "../lib/sessions.ts";
20
- import { loadAccounts, loadConfig, readJsonFile, releaseWaitClaim, writeUsage } from "../lib/state.ts";
20
+ import { loadAccounts, loadConfig, readJsonFile, releaseWaitClaim, replaceWaitClaim, writeUsage } from "../lib/state.ts";
21
21
  import { gatedFamilies, modelFromFlag, parseStreamLine, scrubCredEnv } from "../lib/usage.ts";
22
22
  import { CostLineSchema, CostStateRowSchema, JsonTextSchema, RespawnMarkerSchema, type Account, type ApiKey, type Config, type ModelInfo, type SessionCost, type UsageWindows, type Window } from "../lib/types.ts";
23
23
  import { errorMessage, log } from "../lib/log.ts";
@@ -728,8 +728,15 @@ export async function runSupervisor(argv: string[]): Promise<number> {
728
728
  const launched = await withLock(claudePool.lockFile, async () => {
729
729
  if (terminating) return null;
730
730
  releaseClaimLocked(sid);
731
+ if (noticeSid !== sid) releaseClaimLocked(noticeSid);
731
732
  const target = resolveLaunch(wanted, gate.launchedAt, model, refused);
732
733
  if (target?.account && target.depletedUntil !== undefined && target.depletedUntil > gate.launchedAt) {
734
+ try {
735
+ replaceWaitClaim({ sessionId: noticeSid, accountId: target.account.id, at: gate.launchedAt, waitUntil: target.depletedUntil });
736
+ claimSid = null;
737
+ } catch (e) {
738
+ log("supervisor.claim_write_failed", { err: errorMessage(e) });
739
+ }
733
740
  return { waitOn: target.account, waitUntil: target.depletedUntil };
734
741
  }
735
742
  const picked = target?.account ?? null;
@@ -784,7 +791,6 @@ export async function runSupervisor(argv: string[]): Promise<number> {
784
791
  log("supervisor.depleted_exit", { sid: sid.slice(0, 8), account: launched.waitOn.id.slice(0, 8), waitUntil: launched.waitUntil });
785
792
  say(`\n\x1b[36m⏳ tokenmaxxing: all accounts at their limit, so this session stopped. The next reset is at ${clockFmt.format(launched.waitUntil)} on ${launched.waitOn.label}. Run \`claude --resume ${noticeSid}\` after that to continue.\x1b[0m\n`, text);
786
793
  if (stream) process.stdout.write(depletedLines(noticeSid, launched.waitUntil, text));
787
- await releaseClaim();
788
794
  return 1;
789
795
  }
790
796