tokenmaxxing 1.160.0 → 1.161.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.160.0",
3
+ "version": "1.161.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",
@@ -643,7 +643,7 @@ export async function runSupervisor(argv: string[]): Promise<number> {
643
643
  }
644
644
  if (launched.waitOn !== undefined) {
645
645
  log("supervisor.depleted_wait", { sid: sid.slice(0, 8), account: launched.waitOn.id.slice(0, 8), waitUntil: launched.waitUntil });
646
- if (await countdownWait(launched.waitOn.label, launched.waitUntil, { stream, say })) overriddenUntil = launched.waitUntil;
646
+ if (await countdownWait(launched.waitOn.label, launched.waitUntil, { stream, say, holdSid: noticeSid })) overriddenUntil = launched.waitUntil;
647
647
  continue;
648
648
  }
649
649
 
@@ -17,7 +17,16 @@ export type Say = (terminal: string, text: string) => void;
17
17
 
18
18
  const clockFmt = new Intl.DateTimeFormat("en-US", { hour: "2-digit", minute: "2-digit", hourCycle: "h23", timeZoneName: "short" });
19
19
 
20
- export async function countdownWait(acct: string, until: number, out: { stream: boolean; say: Say }): Promise<boolean> {
20
+ function waitHoldLines(sid: string, until: number): { start: string; stop: string } {
21
+ const line = (fields: Record<string, unknown>): string =>
22
+ `${JSON.stringify({ type: "system", task_id: `tokenmaxxing-wait-${sid}`, uuid: crypto.randomUUID(), session_id: sid, ...fields })}\n`;
23
+ return {
24
+ start: line({ subtype: "task_started", task_type: "local_bash", description: `Waiting until ${clockFmt.format(until)} for a Claude account to reset` }),
25
+ stop: line({ subtype: "task_notification", status: "completed", output_file: "", summary: "The wait for a Claude account to reset ended" }),
26
+ };
27
+ }
28
+
29
+ export async function countdownWait(acct: string, until: number, out: { stream: boolean; say: Say; holdSid?: string }): Promise<boolean> {
21
30
  let aborted = false;
22
31
  const onInt = () => { aborted = true; };
23
32
  process.on("SIGINT", onInt);
@@ -26,6 +35,8 @@ export async function countdownWait(acct: string, until: number, out: { stream:
26
35
  `\n\x1b[36m⏳ tokenmaxxing: all accounts at their limit. Resuming on ${acct} when it resets (Ctrl-C to resume now).\x1b[0m\n`,
27
36
  `tokenmaxxing: all accounts at their limit. Resuming at ${clockFmt.format(until)} (in ${minutes} min) on ${acct}.`,
28
37
  );
38
+ const hold = out.stream && out.holdSid !== undefined ? waitHoldLines(out.holdSid, until) : null;
39
+ if (hold) process.stdout.write(hold.start);
29
40
  while (!aborted && Date.now() < until) {
30
41
  if (!out.stream) {
31
42
  const left = until - Date.now();
@@ -36,6 +47,7 @@ export async function countdownWait(acct: string, until: number, out: { stream:
36
47
  await Bun.sleep(1000);
37
48
  }
38
49
  process.removeListener("SIGINT", onInt);
50
+ if (hold) process.stdout.write(hold.stop);
39
51
  out.say(`\n\x1b[36m↻ resuming on ${acct}...\x1b[0m\n`, `tokenmaxxing: resuming on ${acct}.`);
40
52
  return aborted;
41
53
  }