sideby 0.45.0 → 0.46.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/dist/build.json CHANGED
@@ -1 +1 @@
1
- {"id":"20261124T055449-607979"}
1
+ {"id":"20261124T140330-8fd8f0"}
@@ -26,13 +26,14 @@ export async function pickTaskAccount(rt, opts = {}) {
26
26
  const a = await rt.resolve(opts.account);
27
27
  if (opts.family && a.family !== opts.family)
28
28
  throw new UserError('Choose an account of the requested family; run `sideby list`.');
29
- if (a.kind === 'api' || (await rt.status(a)).login === 'logged-in')
29
+ // A named Account runs unless known to be signed out: an `unknown` one (a Keychain sign-in) asks in its Host.
30
+ if (a.kind === 'api' || (await rt.status(a)).login !== 'logged-out')
30
31
  return { account: a };
31
32
  return { reason: 'none-signed-in' };
32
33
  }
33
- // A remembered choice may be an API Account; only the automatic pick below skips them.
34
+ // A remembered choice may be an API Account or one of unknown sign-in; only the automatic pick below skips them.
34
35
  const preferred = all.find((a) => a.ref === rt.config.ask?.account);
35
- if (preferred && (preferred.kind === 'api' || (await rt.status(preferred)).login === 'logged-in'))
36
+ if (preferred && (preferred.kind === 'api' || (await rt.status(preferred)).login !== 'logged-out'))
36
37
  return { account: preferred };
37
38
  if (!all.length)
38
39
  return { reason: 'no-accounts' };
@@ -38,11 +38,24 @@ export interface QuotaAskHint {
38
38
  * due.
39
39
  */
40
40
  changedAt?: () => Promise<number | undefined>;
41
+ /**
42
+ * When this login was last used on this computer (real ms; the newest local Usage `lastActivityAt` of the Account
43
+ * and its Same Login), read when called and only when it can change the interval (`activeEveryMinutes`, ADR-0085).
44
+ */
45
+ lastActive?: () => Promise<number | undefined>;
41
46
  }
47
+ /** How recent a local use must be for the login to count as in use (`activeEveryMinutes`, ADR-0085). */
48
+ export declare const IN_USE_MS: number;
49
+ /**
50
+ * `fq` with the interval this read goes by (ADR-0085): `activeEveryMinutes` while the login was used within
51
+ * `IN_USE_MS`, else `everyMinutes` as it is. The use is read only when the two intervals could judge differently: the
52
+ * kept answer's ask, or the local reading, is older than the short interval and younger than the long one.
53
+ */
54
+ export declare function pacedFetch(fq: QuotaFetch, kept: QuotaStoreEntry | null, local: QuotaResult | null | undefined, hint: QuotaAskHint, now: Date): Promise<QuotaFetch>;
42
55
  /**
43
56
  * Whether a local reading stands in for a due ask (spec §3.26): it was taken within `everyMinutes`, after every
44
57
  * window of the kept answer was read and after each of their reset times that has passed, and it shows every window
45
- * the kept answer holds. A kept model-group window the local reading cannot see (Claude Code's status line has only
58
+ * the kept answer holds, none of them lower than the kept one (ADR-0085). A kept model-group window the local reading cannot see (Claude Code's status line has only
46
59
  * the plan-wide ones), or a kept count of Limit Resets, still needs the Host. Never for a Family whose local records
47
60
  * can replay old numbers (`localFallbackOnly`, Codex), nor before a first answer is kept.
48
61
  */
@@ -65,11 +78,11 @@ export declare function quotaCheckOff(family: string, config: {
65
78
  */
66
79
  export declare function passedResets(kept: QuotaStoreEntry | null, now: Date, peers?: readonly (QuotaStoreEntry | null)[]): string[];
67
80
  /**
68
- * The kept answer for `account`, after asking again when `mode` says so and it is due: older than `everyMinutes`, or
69
- * one of its windows passed its published reset time since it was taken and that instant was not asked for yet
70
- * (ADR-0073).
81
+ * The kept answer for `account`, after asking again when `mode` says so and it is due: older than `everyMinutes`
82
+ * (`activeEveryMinutes` while the login is in use, ADR-0085), or one of its windows passed its published reset time
83
+ * since it was taken and that instant was not asked for yet (ADR-0073).
71
84
  */
72
- export declare function fetchedQuota(fq: QuotaFetch, account: Account, ctx: ReadContext, hostEnv: Env, mode: QuotaFetchMode, hint?: QuotaAskHint): Promise<QuotaStoreEntry | null>;
85
+ export declare function fetchedQuota(family: QuotaFetch, account: Account, ctx: ReadContext, hostEnv: Env, mode: QuotaFetchMode, hint?: QuotaAskHint): Promise<QuotaStoreEntry | null>;
73
86
  /**
74
87
  * The Expired Login of a signed-in Subscription Account (ADR-0071), from what its Host wrote (`events`) and the kept
75
88
  * Quota answer: expired when the newest sign that the login expired is newer than every sign that it works (a
@@ -78,6 +91,7 @@ export declare function fetchedQuota(fq: QuotaFetch, account: Account, ctx: Read
78
91
  export declare function loginProblemOf(ref: string, events: LoginEvents | undefined, kept: QuotaStoreEntry | null, signedInAt?: string): LoginProblem | undefined;
79
92
  /**
80
93
  * What sideby shows from a Family that fetches Quota: the newer reading, or the kept answer when local events can
81
- * replay old snapshots (`localFallbackOnly`); else why there is none (`off` is why fetching is off, or null).
94
+ * replay old snapshots (`localFallbackOnly`); else why there is none (`off` is why fetching is off, or null). Under a
95
+ * newer local reading, a kept window higher than the local one of the same window stays (ADR-0085).
82
96
  */
83
97
  export declare function shownQuota(local: QuotaResult | null, kept: QuotaStoreEntry | null, off: string | null, localFallbackOnly?: boolean): QuotaResult;
@@ -1,21 +1,59 @@
1
1
  // When sideby calls a Family's `fetchQuota`, and what it shows from the answer (spec §3.26, ADR-0025): the last answer
2
- // is kept per Account, asked again only when it is older than the Family's `everyMinutes`, when one of its windows
3
- // passed its published reset time (once per reset instant, ADR-0073) or the user refreshes, and not while a local
4
- // reading newer than that covers all of it (`localCovers`); one fetch per Account at
5
- // a time, in this process and across processes, at most four fetches on the machine at once, 20 seconds each; the
6
- // newer of the kept answer and the local reading is shown.
2
+ // is kept per Account, asked again only when it is older than the Family's `everyMinutes` (`activeEveryMinutes` while
3
+ // the login is in use, ADR-0085), when one of its windows passed its published reset time (once per reset instant,
4
+ // ADR-0073) or the user refreshes, and not while a local reading newer than that covers all of it (`localCovers`);
5
+ // one fetch per Account at a time, in this process and across processes, at most four fetches on the machine at once,
6
+ // 20 seconds each; the newer of the kept answer and the local reading is shown, except that a newer local window lower
7
+ // than the kept one of the same window loses to it.
7
8
  import { mkdir } from 'node:fs/promises';
8
9
  import { dirname, join } from 'node:path';
9
10
  import { takeFileLock } from './lock.js';
10
11
  import { windowLevel } from './quota-levels.js';
11
12
  import { keptQuota, quotaStoreFile, readQuotaStore, writeQuotaStore, } from './quota-store.js';
12
13
  import { inCi } from './update.js';
14
+ /** How recent a local use must be for the login to count as in use (`activeEveryMinutes`, ADR-0085). */
15
+ export const IN_USE_MS = 5 * 60_000;
16
+ /**
17
+ * `fq` with the interval this read goes by (ADR-0085): `activeEveryMinutes` while the login was used within
18
+ * `IN_USE_MS`, else `everyMinutes` as it is. The use is read only when the two intervals could judge differently: the
19
+ * kept answer's ask, or the local reading, is older than the short interval and younger than the long one.
20
+ */
21
+ export async function pacedFetch(fq, kept, local, hint, now) {
22
+ const short = fq.activeEveryMinutes;
23
+ if (!hint.lastActive || !(typeof short === 'number' && short > 0 && short < fq.everyMinutes))
24
+ return fq;
25
+ const between = (at) => {
26
+ const age = now.getTime() - at;
27
+ return age >= short * 60_000 && age < fq.everyMinutes * 60_000;
28
+ };
29
+ const keptAt = Date.parse(kept?.attemptedAt ?? '');
30
+ const localAt = local?.status === 'ok' ? Date.parse(local.observedAt) : Number.NaN;
31
+ if (!between(keptAt) && !between(localAt))
32
+ return fq;
33
+ const used = await hint.lastActive().catch(() => undefined);
34
+ const since = used === undefined ? Number.NaN : now.getTime() - used;
35
+ if (!(since < IN_USE_MS && since >= -60_000))
36
+ return fq;
37
+ // A view of `fq`, not a copy: a plugin's `fetch` may live on a prototype and use `this`.
38
+ return Object.create(fq, { everyMinutes: { value: short, enumerable: true } });
39
+ }
40
+ /** How far apart two reset times of one window may be: `/usage` gives minutes, the status line seconds (ADR-0085). */
41
+ const SAME_RESET_MS = 5 * 60_000;
42
+ /** Whether two windows are the same window of the vendor: same group and label, reset times a few minutes apart. */
43
+ const sameWindow = (a, b) => (a.name ?? '') === (b.name ?? '') &&
44
+ a.label === b.label &&
45
+ Math.abs(Date.parse(a.resetsAt) - Date.parse(b.resetsAt)) <= SAME_RESET_MS;
46
+ /**
47
+ * Whether `local` is a lower reading of the same window as `fetched`, by a whole point at least: `/usage` rounds to
48
+ * whole percents and the status line does not, so 34.6 against 35 is one reading.
49
+ */
50
+ const lowerThan = (local, fetched) => sameWindow(local, fetched) && fetched.usedPercent - local.usedPercent >= 1;
13
51
  /** Whether the ask that gave `entry` began at or after `notBefore` (real ms); false when it does not say. */
14
52
  const beganAfter = (entry, notBefore) => Date.parse(entry?.startedAt ?? '') >= notBefore;
15
53
  /**
16
54
  * Whether a local reading stands in for a due ask (spec §3.26): it was taken within `everyMinutes`, after every
17
55
  * window of the kept answer was read and after each of their reset times that has passed, and it shows every window
18
- * the kept answer holds. A kept model-group window the local reading cannot see (Claude Code's status line has only
56
+ * the kept answer holds, none of them lower than the kept one (ADR-0085). A kept model-group window the local reading cannot see (Claude Code's status line has only
19
57
  * the plan-wide ones), or a kept count of Limit Resets, still needs the Host. Never for a Family whose local records
20
58
  * can replay old numbers (`localFallbackOnly`, Codex), nor before a first answer is kept.
21
59
  */
@@ -35,6 +73,10 @@ export function localCovers(fq, local, kept, now) {
35
73
  const own = mine.get(`${w.name ?? ''}\0${w.label}`);
36
74
  if (!own)
37
75
  return false;
76
+ // Lower than the kept reading of the same window: shown, the kept number wins (`shownQuota`), so only the Host
77
+ // can move it (ADR-0085).
78
+ if (lowerThan(own, w))
79
+ return false;
38
80
  const at = Date.parse(own.observedAt ?? local.observedAt);
39
81
  if (!fresh(at))
40
82
  return false;
@@ -305,15 +347,17 @@ function olderThanInterval(fq, kept, now) {
305
347
  /** Whether a kept answer has a window that counts toward Quota Pressure at or over its warning level. */
306
348
  const tight = (kept) => (kept?.quota?.windows ?? []).some((w) => !w.name && windowLevel(w) !== 'ok');
307
349
  /**
308
- * The kept answer for `account`, after asking again when `mode` says so and it is due: older than `everyMinutes`, or
309
- * one of its windows passed its published reset time since it was taken and that instant was not asked for yet
310
- * (ADR-0073).
350
+ * The kept answer for `account`, after asking again when `mode` says so and it is due: older than `everyMinutes`
351
+ * (`activeEveryMinutes` while the login is in use, ADR-0085), or one of its windows passed its published reset time
352
+ * since it was taken and that instant was not asked for yet (ADR-0073).
311
353
  */
312
- export async function fetchedQuota(fq, account, ctx, hostEnv, mode, hint = {}) {
354
+ export async function fetchedQuota(family, account, ctx, hostEnv, mode, hint = {}) {
313
355
  const file = quotaStoreFile(ctx.stateDir, account.family, account.name);
314
356
  const kept = await readQuotaStore(file);
315
357
  if (mode === 'never')
316
358
  return kept;
359
+ // Every judgement below, the one under the lock and the timeout's message included, uses this read's interval.
360
+ const fq = mode === 'force' ? family : await pacedFetch(family, kept, hint.local, hint, ctx.now);
317
361
  // A local reading that is newer than the Family asks, and shows all the kept answer holds, spares the Host.
318
362
  if (mode !== 'force' && localCovers(fq, hint.local, kept, ctx.now))
319
363
  return kept;
@@ -377,7 +421,8 @@ export function loginProblemOf(ref, events, kept, signedInAt) {
377
421
  }
378
422
  /**
379
423
  * What sideby shows from a Family that fetches Quota: the newer reading, or the kept answer when local events can
380
- * replay old snapshots (`localFallbackOnly`); else why there is none (`off` is why fetching is off, or null).
424
+ * replay old snapshots (`localFallbackOnly`); else why there is none (`off` is why fetching is off, or null). Under a
425
+ * newer local reading, a kept window higher than the local one of the same window stays (ADR-0085).
381
426
  */
382
427
  export function shownQuota(local, kept, off, localFallbackOnly = false) {
383
428
  const fetched = kept?.quota
@@ -387,13 +432,9 @@ export function shownQuota(local, kept, off, localFallbackOnly = false) {
387
432
  if (fetched && own) {
388
433
  if (localFallbackOnly || Date.parse(own.observedAt) <= Date.parse(fetched.observedAt))
389
434
  return fetched;
390
- // A local reading (Claude's status line) sees only the plan-wide windows. Keep the fetched model-group windows it
391
- // cannot see, so a group's line (such as Fable) does not come and go with whichever reading is newer.
392
- const seen = new Set(own.windows.map((w) => `${w.name ?? ''}\0${w.label}`));
393
- // Those windows keep the time and source they were read at: the newer reading did not cover them (ADR-0073).
394
- const groups = fetched.windows
395
- .filter((w) => w.name && !seen.has(`${w.name}\0${w.label}`))
396
- .map((w) => {
435
+ // A fetched window shown under the newer local reading keeps the time and source it was read at: that reading did
436
+ // not cover it (ADR-0073).
437
+ const stamped = (w) => {
397
438
  const observedAt = w.observedAt ?? fetched.observedAt;
398
439
  const source = w.source ?? fetched.source;
399
440
  return {
@@ -401,12 +442,27 @@ export function shownQuota(local, kept, off, localFallbackOnly = false) {
401
442
  ...(observedAt !== own.observedAt ? { observedAt } : {}),
402
443
  ...(source !== own.source ? { source } : {}),
403
444
  };
445
+ };
446
+ // Within one window the use only grows: a local window lower than the fetched one of the same window repeats
447
+ // older numbers, and the fetched one shows (ADR-0085). Only this way round: a newer fetched answer that fell may
448
+ // follow a Limit Reset, which sideby cannot see for Claude Code.
449
+ let lowered = false;
450
+ const windows = own.windows.map((w) => {
451
+ const higher = fetched.windows.find((f) => lowerThan(w, f));
452
+ if (!higher)
453
+ return w;
454
+ lowered = true;
455
+ return stamped(higher);
404
456
  });
457
+ // A local reading (Claude's status line) sees only the plan-wide windows. Keep the fetched model-group windows it
458
+ // cannot see, so a group's line (such as Fable) does not come and go with whichever reading is newer.
459
+ const seen = new Set(own.windows.map((w) => `${w.name ?? ''}\0${w.label}`));
460
+ const groups = fetched.windows.filter((w) => w.name && !seen.has(`${w.name}\0${w.label}`)).map(stamped);
405
461
  // A local reading knows nothing of Limit Resets; the Host's own count stays, with its own read time.
406
462
  const limitResets = own.limitResets ?? fetched.limitResets;
407
- if (!groups.length && !limitResets)
463
+ if (!lowered && !groups.length && !limitResets)
408
464
  return own;
409
- return { ...own, windows: [...own.windows, ...groups], ...(limitResets ? { limitResets } : {}) };
465
+ return { ...own, windows: [...windows, ...groups], ...(limitResets ? { limitResets } : {}) };
410
466
  }
411
467
  if (fetched)
412
468
  return fetched;
@@ -4,7 +4,7 @@ export type FetchedQuota = Extract<QuotaResult, {
4
4
  }>;
5
5
  export interface QuotaStoreEntry {
6
6
  version: 1;
7
- /** When the latest fetch finished, good or not; the next one waits `everyMinutes` from here. */
7
+ /** When the latest fetch finished, good or not; the next one waits `everyMinutes` (`activeEveryMinutes` in use) from here. */
8
8
  attemptedAt: string;
9
9
  /**
10
10
  * When that fetch began asking the Host (the real clock). What it answers is the Quota of some moment after this,
@@ -185,13 +185,20 @@ export async function taskChoices(rt) {
185
185
  const pick = await pickTaskAccount(rt);
186
186
  const signedIn = [];
187
187
  const api = [];
188
+ // `unknown`: the sign-in is in the Keychain, which sideby never reads (agy); offered, since only the Host can tell.
189
+ const unknown = [];
188
190
  const signedOut = [];
189
191
  const all = [...(await rt.accounts())].sort((a, b) => (a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0));
190
192
  for (const a of all) {
191
- if (a.kind === 'api')
193
+ if (a.kind === 'api') {
192
194
  api.push({ ref: a.ref, label: `${a.ref} · API`, signedIn: true });
193
- else if ((await rt.status(a)).login === 'logged-in')
195
+ continue;
196
+ }
197
+ const login = (await rt.status(a)).login;
198
+ if (login === 'logged-in')
194
199
  signedIn.push({ ref: a.ref, label: a.ref, signedIn: true });
200
+ else if (login === 'unknown')
201
+ unknown.push({ ref: a.ref, label: a.ref, signedIn: true });
195
202
  else
196
203
  signedOut.push({ ref: a.ref, label: a.ref, signedIn: false });
197
204
  }
@@ -200,7 +207,7 @@ export async function taskChoices(rt) {
200
207
  return {
201
208
  schemaVersion: 1,
202
209
  account: 'account' in pick ? pick.account.ref : null,
203
- accounts: [...signedIn, ...api, ...signedOut],
210
+ accounts: [...signedIn, ...api, ...unknown, ...signedOut],
204
211
  terminal: t.guess.id,
205
212
  terminals: t.installed.map((i) => ({ id: i.id, label: name(i.id) })),
206
213
  reason: 'reason' in pick ? pick.reason : null,
@@ -3,8 +3,11 @@
3
3
  import { openWindows } from '../../core/quota-levels.js';
4
4
  import { field } from '../../handoff/reader.js';
5
5
  import { accountNameFromEnv, cacheStateDir, readQuotaCache } from './quota-cache.js';
6
- /** Claude Code's wording when a subscription window is used up (as opposed to an overloaded server). */
7
- const USED_UP = /usage limit|limit reached|out of (extra )?usage/i;
6
+ /**
7
+ * Claude Code's wording when a subscription window is used up (as opposed to an overloaded server or a throttle).
8
+ * Since 2.1.312 it says "You've hit your 5-hour limit" or "You've hit your weekly limit"; "rate limit" is a throttle.
9
+ */
10
+ const USED_UP = /usage[ _]limit|(?<!rate )limit reached|out of (?:extra )?usage|hit your [\w -]{0,24}(?<!rate )limit/i;
8
11
  export const claudeHookReader = {
9
12
  async windows(_input, env, now) {
10
13
  const name = accountNameFromEnv(env);
@@ -245,6 +245,8 @@ export async function fetchClaudeQuota(account, ctx) {
245
245
  }
246
246
  export const claudeQuotaFetch = {
247
247
  everyMinutes: 15,
248
- summary: 'Ask Claude Code for each account’s quota (its /usage command, no model turn) every 15 minutes',
248
+ // A long turn can fill the 5-hour window between two asks of 15 minutes (ADR-0085).
249
+ activeEveryMinutes: 5,
250
+ summary: 'Ask Claude Code for each account’s quota (its /usage command, no model turn) every 15 minutes, every 5 while the account is in use',
249
251
  fetch: fetchClaudeQuota,
250
252
  };
@@ -1489,7 +1489,7 @@ const en = {
1489
1489
  'set.g.accounts': 'Accounts',
1490
1490
  'set.g.quota': 'Quota checks',
1491
1491
  'set.g.ai': 'Let AI help',
1492
- 'set.quotaChecksHint': 'Each tool asks for its own quota, at most every {n} minutes per account. sideby does not read their sign-ins.',
1492
+ 'set.quotaChecksHint': 'Each tool asks for its own quota, at most every {n} minutes per account; Claude Code every 5 minutes while the account is in use. sideby does not read their sign-ins.',
1493
1493
  'set.ahHint': 'When an account is about to run out, the task moves on to another account by itself.',
1494
1494
  'net.title': 'Network check',
1495
1495
  'net.hint': 'Stops Claude and Codex when your requests would leave from a country you did not allow, for example when the proxy stopped.',
@@ -3385,7 +3385,7 @@ const zh = {
3385
3385
  'set.g.accounts': '账号',
3386
3386
  'set.g.quota': '额度查询',
3387
3387
  'set.g.ai': '让 AI 帮我',
3388
- 'set.quotaChecksHint': '各工具自己查询每个账号的额度,最多每 {n} 分钟一次。sideby 不读它们的登录信息。',
3388
+ 'set.quotaChecksHint': '各工具自己查询每个账号的额度,最多每 {n} 分钟一次;Claude Code 账号在用时每 5 分钟一次。sideby 不读它们的登录信息。',
3389
3389
  'set.ahHint': '账号额度快用完时,任务自己换到另一个账号接着做。',
3390
3390
  'net.title': '网络检查',
3391
3391
  'net.hint': '请求要从你没允许的国家或地区发出时(比如代理断了),拦下 Claude 和 Codex。',
@@ -382,6 +382,26 @@ export async function createRuntime(opts = {}) {
382
382
  peers: () => Promise.all(peers.map((r) => readQuotaStore(quotaStoreFile(paths.stateDir, account.family, r.slice(r.indexOf(':') + 1))))),
383
383
  }
384
384
  : {}),
385
+ // While the login is in use on this computer, a Family may be asked more often (ADR-0085): the newest local
386
+ // Usage activity of this Account and its Same Login, the source ADR-0051 also goes by.
387
+ ...(families.get(account.family)?.fetchQuota?.activeEveryMinutes
388
+ ? {
389
+ lastActive: async () => {
390
+ const f = familyOf(account.family);
391
+ const others = peers.length
392
+ ? (await discoverAccounts(f, paths.home, ignore)).filter((a) => peers.includes(a.ref))
393
+ : [];
394
+ let newest;
395
+ for (const a of [account, ...others]) {
396
+ const u = await rt.usage(a).catch(() => null);
397
+ const at = u?.status === 'ok' ? Date.parse(u.lastActivityAt ?? '') : Number.NaN;
398
+ if (Number.isFinite(at) && (newest === undefined || at > newest))
399
+ newest = at;
400
+ }
401
+ return newest;
402
+ },
403
+ }
404
+ : {}),
385
405
  // An answer asked for before a Limit Reset was used for this Account's login is not kept after it (ADR-0072).
386
406
  ...(families.get(account.family)?.limitReset?.use
387
407
  ? {
@@ -431,13 +431,19 @@ export interface ReadContext {
431
431
  }
432
432
  /**
433
433
  * How sideby asks for a Family's Quota when that costs a request (spec §3.26). sideby keeps each Account's last
434
- * answer in its state directory and calls `fetch` at most every `everyMinutes`, or when the user refreshes; never
435
- * from the status line or the handoff hook, for an API Account or a signed-out one, in CI, or when the user turned it
436
- * off (config `quota.check.<family>: false`).
434
+ * answer in its state directory and calls `fetch` at most every `everyMinutes` (`activeEveryMinutes` while the login
435
+ * is in use), or when the user refreshes; never from the status line or the handoff hook, for an API Account or a
436
+ * signed-out one, in CI, or when the user turned it off (config `quota.check.<family>: false`).
437
437
  */
438
438
  export interface QuotaFetch {
439
439
  /** At most one `fetch` per Account in this many minutes, unless the user refreshes. */
440
440
  everyMinutes: number;
441
+ /**
442
+ * A shorter interval, in minutes, used instead of `everyMinutes` while the login was used on this computer in the
443
+ * last 5 minutes (its local Usage `lastActivityAt`, the Account's or a Same Login's; ADR-0085). Left out, or not
444
+ * shorter than `everyMinutes`, the interval never changes.
445
+ */
446
+ activeEveryMinutes?: number;
441
447
  /** What a fetch does, in one plain sentence, shown next to the setting that turns it off. */
442
448
  summary: string;
443
449
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sideby",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "description": "Run work, personal and API-key accounts at the same time, without their configs drifting apart.",
5
5
  "license": "MIT",
6
6
  "author": "Adonis0123 (https://github.com/Adonis0123)",
@@ -2,7 +2,7 @@
2
2
  name: sideby
3
3
  description: Use when the user runs, or wants to run, several AI coding accounts (Claude Code, Codex, Grok Build, pi) side by side. Covers installing sideby and setting up a new account ("install sideby", "set up another Claude account", "add cc008", "配置一个 cc00x", "再加一个 Codex 账号"), explaining what accounts share and what stays separate ("what do my accounts share?", "这些账号共享了什么"), showing which account a session is ("show [cc001] in the status line", "加上账号标识"), finding a past session of any account ("找一下我上周改登录页的那个会话"), telling another running session something, in any account ("告诉 cc002 ……", "给跑构建的那个会话发消息"; Claude Code's own SendMessage reaches only sessions of the same account), seeing accounts, quota and usage, moving on when one hits its 5-hour or weekly limit, moving the current task to another account ("用 cc008 继续", "交回 cc008"), adding a short command (alias) or a pick command that starts whichever account has the most quota ("加个 cc"), adding an API account from a vendor's docs ("加一个 DeepSeek API 账号"), supporting a new tool, and repairing drifted account directories (skills, hooks, rules or settings not shared, wrong symlinks, credential file permissions). Drives the `sideby` CLI with `--json`; the agent does every step except browser sign-in, filling in secrets and starting interactive sessions, which it hands to the user as one command (inside an Auto Handoff session, `sideby handoff ready --to` moves the task itself).
4
4
  metadata:
5
- version: "0.45.0"
5
+ version: "0.46.0"
6
6
  requires:
7
7
  bins: [sideby, node]
8
8
  cliHelp: sideby --help
@@ -1,10 +1,10 @@
1
1
  # Claude quota
2
2
 
3
- Claude quota needs no setup: sideby asks Claude Code itself (ADR-0063). For each signed-in subscription account it runs `claude -p /usage --no-session-persistence --output-format json` with that account's config directory, with the user's hooks and MCP servers off, at most every 15 minutes. Claude Code answers with its own sign-in and starts no model turn (tried with Claude Code 2.1.314 on 2026-10-30); sideby reads no credential and keeps only the 5-hour, weekly and per-model weekly windows. `sideby quota claude --refresh` asks again now. `sideby quota check claude off --json` (config `quota.check.claude: false`) turns it off, as does CI. On `reason: "fetch-failed"`, relay the next step in `detail` (update Claude Code or sideby, or `sideby login <ref>`). A window with a model `name` (Claude Code's `Current week (<model>)`) covers only that model: show it, but it does not decide which account is picked.
3
+ Claude quota needs no setup: sideby asks Claude Code itself (ADR-0063). For each signed-in subscription account it runs `claude -p /usage --no-session-persistence --output-format json` with that account's config directory, with the user's hooks and MCP servers off, at most every 15 minutes, or every 5 minutes while the account was used on this computer in the last 5 minutes (ADR-0085). Claude Code answers with its own sign-in and starts no model turn (tried with Claude Code 2.1.314 on 2026-10-30); sideby reads no credential and keeps only the 5-hour, weekly and per-model weekly windows. `sideby quota claude --refresh` asks again now. `sideby quota check claude off --json` (config `quota.check.claude: false`) turns it off, as does CI. On `reason: "fetch-failed"`, relay the next step in `detail` (update Claude Code or sideby, or `sideby login <ref>`). A window with a model `name` (Claude Code's `Current week (<model>)`) covers only that model: show it, but it does not decide which account is picked.
4
4
 
5
5
  ## Live quota for Auto Handoff (the status line tap)
6
6
 
7
- While a session runs, Claude Code also hands each reply's official `rate_limits` (5-hour and 7-day used percent and reset time) to its status line command; sideby shows the newer of that and the `/usage` answer. Auto Handoff reads only this one, so it needs a one-time change to `~/.claude/settings.json`: the status line command becomes `sideby statusline-tap --orig-b64 <base64 of the original command>`, and sideby caches the readings per account. Nothing is sent anywhere. Offer it when the user turns on Auto Handoff, not just to see quota.
7
+ While a session runs, Claude Code also hands each reply's official `rate_limits` (5-hour and 7-day used percent and reset time) to its status line command; sideby shows the newer of that and the `/usage` answer, except that a newer status line number lower than `/usage`'s for the same window counts as old and the higher one shows (ADR-0085). Auto Handoff reads only this one, so it needs a one-time change to `~/.claude/settings.json`: the status line command becomes `sideby statusline-tap --orig-b64 <base64 of the original command>`, and sideby caches the readings per account. Nothing is sent anywhere. Offer it when the user turns on Auto Handoff, not just to see quota.
8
8
 
9
9
  1. sideby must be installed globally (`npm i -g sideby`), because Claude Code runs the wrapper on every status line refresh. Setup is refused when `sideby` is missing from PATH or comes from the npx cache; tell the user to install it rather than working around it.
10
10
  2. Run `sideby quota setup claude`. It prints the diff, changes nothing and exits **10**: show the diff to the user.