sideby 0.36.1 → 0.37.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 +1 -1
- package/dist/src/cli/commands.js +7 -3
- package/dist/src/cli/main.js +1 -1
- package/dist/src/core/browser-profiles.d.ts +5 -3
- package/dist/src/core/browser-profiles.js +31 -4
- package/dist/src/panel/background.d.ts +8 -3
- package/dist/src/panel/background.js +35 -3
- package/dist/src/panel/handler.js +4 -3
- package/dist/src/panel/i18n.d.ts +8 -0
- package/dist/src/panel/i18n.js +16 -0
- package/dist/src/panel/page-script.js +52 -11
- package/dist/src/panel/page-styles.js +4 -0
- package/package.json +1 -1
- package/skills/sideby/SKILL.md +2 -2
- package/skills/sideby/references/quota.md +1 -1
package/dist/build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"20261113T180128-45a583"}
|
package/dist/src/cli/commands.js
CHANGED
|
@@ -1471,11 +1471,15 @@ function resetWindowLine(w, now) {
|
|
|
1471
1471
|
* it. A spend that got no final answer fails with the `operationId` to retry.
|
|
1472
1472
|
*/
|
|
1473
1473
|
export async function cmdQuotaReset(a, io, runtime) {
|
|
1474
|
-
const usage = 'usage: sideby quota reset <account> [--yes] [--operation <id>] [--open] [--json]';
|
|
1474
|
+
const usage = 'usage: sideby quota reset <account> [--yes] [--operation <id>] [--open [--profile <browser user>]] [--json]';
|
|
1475
1475
|
const ref = a.positionals[1];
|
|
1476
1476
|
if (!ref || a.positionals.length !== 2 || a.rest.length || a.flags.has('refresh'))
|
|
1477
1477
|
throw new UsageError(usage);
|
|
1478
1478
|
const operation = a.flags.get('operation');
|
|
1479
|
+
// Which Chrome browser user `--open` opens the page in (folder, name or Google account); without it, the Account's own.
|
|
1480
|
+
const profile = a.flags.get('profile');
|
|
1481
|
+
if (profile !== undefined && !a.flags.has('open'))
|
|
1482
|
+
throw new UsageError(`--profile chooses the browser user that --open opens the page in; add --open\n${usage}`);
|
|
1479
1483
|
const asJson = a.flags.has('json');
|
|
1480
1484
|
const rt = runtime ?? (await createRuntime());
|
|
1481
1485
|
const now = rt.readContext().now;
|
|
@@ -1492,7 +1496,7 @@ export async function cmdQuotaReset(a, io, runtime) {
|
|
|
1492
1496
|
long: QUOTA_LONG_WARN_PERCENT,
|
|
1493
1497
|
});
|
|
1494
1498
|
const tight = quota.status === 'ok' ? (offer?.tight ?? []).map((i) => quota.windows[i]) : [];
|
|
1495
|
-
const opened = a.flags.has('open') ? await openVendorPage(rt, account) : undefined;
|
|
1499
|
+
const opened = a.flags.has('open') ? await openVendorPage(rt, account, profile) : undefined;
|
|
1496
1500
|
const who = st.identity?.email;
|
|
1497
1501
|
const message = `${f.title} cannot use a limit reset from the command line: it is used on the vendor's page, and then applies to ${f.title} too. sideby cannot see whether ${account.ref} holds one.`;
|
|
1498
1502
|
if (asJson) {
|
|
@@ -1532,7 +1536,7 @@ export async function cmdQuotaReset(a, io, runtime) {
|
|
|
1532
1536
|
if (!f.limitReset?.vendorPage)
|
|
1533
1537
|
throw new UserError(`--open is for an account whose limit reset is used on the vendor's page (Claude Code); for ${account.ref} run \`sideby quota reset ${account.ref}\``, { code: 'no-vendor-page' });
|
|
1534
1538
|
// A Family whose Host can use one and that has a vendor page too: `--open` only opens the page, and uses nothing.
|
|
1535
|
-
const opened = await openVendorPage(rt, account);
|
|
1539
|
+
const opened = await openVendorPage(rt, account, profile);
|
|
1536
1540
|
const message = `Opened ${opened.url}${opened.profile ? ` in the browser user ${opened.profile.name}` : ' in your browser'}: the vendor's page for the limit resets of ${account.ref}. Nothing was used from here; to use one through ${f.title} itself, run \`sideby quota reset ${account.ref}\`.`;
|
|
1537
1541
|
if (asJson)
|
|
1538
1542
|
json(io, {
|
package/dist/src/cli/main.js
CHANGED
|
@@ -481,7 +481,7 @@ const COMMANDS = {
|
|
|
481
481
|
new: { flags: ['api', 'json', 'next'], valued: ['alias', 'vendor'] },
|
|
482
482
|
alias: { flags: ['json', 'yes'], valued: ['pick'] },
|
|
483
483
|
doctor: { flags: ['fix', 'force', 'json'] },
|
|
484
|
-
quota: { flags: ['json', 'yes', 'refresh', 'open'], valued: ['operation'] },
|
|
484
|
+
quota: { flags: ['json', 'yes', 'refresh', 'open'], valued: ['operation', 'profile'] },
|
|
485
485
|
tune: { flags: ['json', 'yes'] },
|
|
486
486
|
model: { flags: ['json', 'yes'], valued: ['effort'] },
|
|
487
487
|
'remote-control': { flags: ['json', 'yes'] },
|
|
@@ -74,10 +74,12 @@ export interface VendorPageOpen {
|
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Opens the page where a Limit Reset of `account` is spent (`FamilyDef.limitReset.vendorPage`, ADR-0072): in the
|
|
77
|
-
* Browser Profile
|
|
78
|
-
*
|
|
77
|
+
* Browser Profile given (folder, name or Google account), else the one the user chose for the Account, or the only one
|
|
78
|
+
* found signed in to it, else in the default browser. A `profile` that cannot be opened is an error, never a silent
|
|
79
|
+
* fall back to another browser. sideby never reads which login that browser has. The url passed the loader's https
|
|
80
|
+
* check; no other is opened.
|
|
79
81
|
*/
|
|
80
|
-
export declare function openVendorPage(rt: Runtime, account: Account): Promise<VendorPageOpen>;
|
|
82
|
+
export declare function openVendorPage(rt: Runtime, account: Account, profile?: string): Promise<VendorPageOpen>;
|
|
81
83
|
export interface BrowserChoice {
|
|
82
84
|
ref: string;
|
|
83
85
|
/** The browser user now chosen, or null when sideby finds it again by itself. */
|
|
@@ -348,10 +348,12 @@ export async function openInBrowser(rt, account, profile) {
|
|
|
348
348
|
}
|
|
349
349
|
/**
|
|
350
350
|
* Opens the page where a Limit Reset of `account` is spent (`FamilyDef.limitReset.vendorPage`, ADR-0072): in the
|
|
351
|
-
* Browser Profile
|
|
352
|
-
*
|
|
351
|
+
* Browser Profile given (folder, name or Google account), else the one the user chose for the Account, or the only one
|
|
352
|
+
* found signed in to it, else in the default browser. A `profile` that cannot be opened is an error, never a silent
|
|
353
|
+
* fall back to another browser. sideby never reads which login that browser has. The url passed the loader's https
|
|
354
|
+
* check; no other is opened.
|
|
353
355
|
*/
|
|
354
|
-
export async function openVendorPage(rt, account) {
|
|
356
|
+
export async function openVendorPage(rt, account, profile) {
|
|
355
357
|
const url = account.kind === 'api' ? undefined : rt.families.get(account.family)?.limitReset?.vendorPage;
|
|
356
358
|
if (!url)
|
|
357
359
|
throw new UserError(`${account.ref} has no page for limit resets; check the vendor's own usage page`, {
|
|
@@ -359,11 +361,36 @@ export async function openVendorPage(rt, account) {
|
|
|
359
361
|
});
|
|
360
362
|
const deps = depsFor(rt);
|
|
361
363
|
const run = async (cmd, args) => (await deps.exec(cmd, args)).code === 0;
|
|
364
|
+
const canPick = deps.platform === 'darwin' || Boolean(deps.wslMount);
|
|
365
|
+
if (profile) {
|
|
366
|
+
// The user named the browser user: it opens there or says why not, with the address to open by hand.
|
|
367
|
+
if (!canPick)
|
|
368
|
+
throw new UserError(`opening a browser user works on macOS and WSL only for now (this is ${deps.platform}); open ${url} yourself`, { code: 'unsupported' });
|
|
369
|
+
const problems = [];
|
|
370
|
+
const launch = await chromeLauncher(deps, problems);
|
|
371
|
+
if (!launch)
|
|
372
|
+
throw new UserError(`${CHROME.title} is not installed; get it from ${CHROME_DOWNLOAD}, or open ${url} yourself`, { code: 'not-installed' });
|
|
373
|
+
const entries = (await profileEntries(launch.userData ?? chromeUserData(rt.paths.home), problems)) ?? [];
|
|
374
|
+
if (!entries.length)
|
|
375
|
+
throw new UserError(`${CHROME.title} has no browser users yet; open it once, then try again`, {
|
|
376
|
+
code: 'no-profiles',
|
|
377
|
+
});
|
|
378
|
+
const pick = findProfile(entries, profile);
|
|
379
|
+
const [cmd, ...args] = launch.command(`--profile-directory=${pick.dir}`, url);
|
|
380
|
+
if (!(await run(cmd, args)))
|
|
381
|
+
throw new UserError(`could not open ${CHROME.title}; open ${url} yourself`, { code: 'open-failed' });
|
|
382
|
+
return {
|
|
383
|
+
ref: account.ref,
|
|
384
|
+
url,
|
|
385
|
+
profile: { dir: pick.dir, name: pick.name },
|
|
386
|
+
command: [cmd, ...args],
|
|
387
|
+
};
|
|
388
|
+
}
|
|
362
389
|
// The Account's own Browser Profile, when one is known without asking; any problem falls back to the default browser.
|
|
363
390
|
// Nothing of a browser is read unless the user chose a Browser Profile for this Account or turned Browser Sign-ins on.
|
|
364
391
|
const chosen = rt.config.browser?.choices?.[account.ref];
|
|
365
392
|
const findIt = rt.config.browser?.signIns === true;
|
|
366
|
-
if (
|
|
393
|
+
if (canPick && (chosen || findIt)) {
|
|
367
394
|
const problems = [];
|
|
368
395
|
const launch = await chromeLauncher(deps, problems).catch(() => null);
|
|
369
396
|
const entries = launch
|
|
@@ -8,14 +8,19 @@ export interface PanelPidFile {
|
|
|
8
8
|
startedAt: string;
|
|
9
9
|
/** Random id the Panel also returns on `/api/health`. */
|
|
10
10
|
instance: string;
|
|
11
|
-
/**
|
|
11
|
+
/** When the process started (`processStartTime`), when it could be read; a reused pid has another. */
|
|
12
12
|
processStart?: string;
|
|
13
13
|
}
|
|
14
14
|
export declare const pidFilePath: (p: Paths) => string;
|
|
15
15
|
export declare const logFilePath: (p: Paths) => string;
|
|
16
16
|
export declare function readPidFile(p: Paths): Promise<PanelPidFile | undefined>;
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* When `pid` started; with the pid it names one process, which a reused pid does not match. On Linux it is the start
|
|
19
|
+
* in clock ticks since boot from `/proc/<pid>/stat` (`ticks:<n>`): `ps -o lstart` adds that to the boot time, which
|
|
20
|
+
* moves when the system clock is adjusted (under WSL by seconds within minutes), so the same process would stop
|
|
21
|
+
* matching its own pid file. Elsewhere it is `ps -o lstart`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function processStartTime(pid: number): Promise<string | undefined>;
|
|
19
24
|
/** The port of this state directory's background Panel when it runs and answers as itself, else null. */
|
|
20
25
|
export declare function backgroundPanelPort(p: Paths): Promise<number | null>;
|
|
21
26
|
/** URL of a running background Panel, or of any sideby Panel on `port`; removes a stale pid file. */
|
|
@@ -43,8 +43,40 @@ function psField(pid, field) {
|
|
|
43
43
|
execFile('ps', ['-ww', '-o', `${field}=`, '-p', String(pid)], { timeout: 3000, env: { ...process.env, LC_ALL: 'C' } }, (err, stdout) => resolve(err ? undefined : stdout.trim() || undefined));
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
/**
|
|
47
|
-
|
|
46
|
+
/**
|
|
47
|
+
* When `pid` started; with the pid it names one process, which a reused pid does not match. On Linux it is the start
|
|
48
|
+
* in clock ticks since boot from `/proc/<pid>/stat` (`ticks:<n>`): `ps -o lstart` adds that to the boot time, which
|
|
49
|
+
* moves when the system clock is adjusted (under WSL by seconds within minutes), so the same process would stop
|
|
50
|
+
* matching its own pid file. Elsewhere it is `ps -o lstart`.
|
|
51
|
+
*/
|
|
52
|
+
export async function processStartTime(pid) {
|
|
53
|
+
if (process.platform === 'linux') {
|
|
54
|
+
try {
|
|
55
|
+
const stat = await readFile(`/proc/${pid}/stat`, 'utf8');
|
|
56
|
+
// Fields after the command name, which is in parentheses and may hold spaces; starttime is field 22.
|
|
57
|
+
const ticks = stat.slice(stat.lastIndexOf(')') + 2).split(' ')[19];
|
|
58
|
+
if (ticks && /^\d+$/.test(ticks))
|
|
59
|
+
return `ticks:${ticks}`;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// gone, or no /proc: fall back to ps
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return psField(pid, 'lstart');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Whether a pid file's start time names this process. One written in another form (an older sideby wrote `ps -o lstart`
|
|
69
|
+
* on Linux too) cannot be compared and is not held against it; the command line and the Panel's answer still have to
|
|
70
|
+
* match.
|
|
71
|
+
*/
|
|
72
|
+
async function sameStart(pid, recorded) {
|
|
73
|
+
const now = await processStartTime(pid);
|
|
74
|
+
if (!now)
|
|
75
|
+
return false;
|
|
76
|
+
if (now.startsWith('ticks:') !== recorded.startsWith('ticks:'))
|
|
77
|
+
return true;
|
|
78
|
+
return now === recorded;
|
|
79
|
+
}
|
|
48
80
|
/**
|
|
49
81
|
* Checks that the pid file names a live detached Panel: the process is alive, started when the pid file says,
|
|
50
82
|
* runs `ui --serve-detached`, and the Panel on the recorded port answers with the same instance id and pid.
|
|
@@ -55,7 +87,7 @@ async function checkPanel(rec) {
|
|
|
55
87
|
return stale('it names no panel instance');
|
|
56
88
|
if (!alive(rec.pid))
|
|
57
89
|
return stale(`process ${rec.pid} is not running`);
|
|
58
|
-
if (rec.processStart && (await
|
|
90
|
+
if (rec.processStart && !(await sameStart(rec.pid, rec.processStart)))
|
|
59
91
|
return stale(`process ${rec.pid} is not the one that wrote it`);
|
|
60
92
|
const cmd = await psField(rec.pid, 'command');
|
|
61
93
|
if (!(cmd && / ui( |$)/.test(cmd) && cmd.includes(`--${DETACHED_FLAG}`)))
|
|
@@ -2274,15 +2274,16 @@ export function createPanelHandler(opts) {
|
|
|
2274
2274
|
return { result: await rt.limitResetUse(account, operationId) };
|
|
2275
2275
|
},
|
|
2276
2276
|
},
|
|
2277
|
-
// Opens the vendor's page where a Limit Reset is spent (Claude Code, ADR-0072)
|
|
2278
|
-
// when one is known, else the default browser. It starts a program, so a read-only
|
|
2277
|
+
// Opens the vendor's page where a Limit Reset is spent (Claude Code, ADR-0072): in the Browser Profile the page
|
|
2278
|
+
// names, else the Account's own when one is known, else the default browser. It starts a program, so a read-only
|
|
2279
|
+
// Panel refuses it.
|
|
2279
2280
|
'/api/quota/reset/open': {
|
|
2280
2281
|
async run(body) {
|
|
2281
2282
|
const ref = optString(body, 'account');
|
|
2282
2283
|
if (!ref)
|
|
2283
2284
|
throw new HttpError(400, '"account" is required');
|
|
2284
2285
|
const rt = await getRuntime();
|
|
2285
|
-
const r = await openVendorPage(rt, await rt.resolve(ref));
|
|
2286
|
+
const r = await openVendorPage(rt, await rt.resolve(ref), optString(body, 'profile'));
|
|
2286
2287
|
return { ref: r.ref, url: r.url, ...(r.profile ? { profile: r.profile } : {}) };
|
|
2287
2288
|
},
|
|
2288
2289
|
},
|
package/dist/src/panel/i18n.d.ts
CHANGED
|
@@ -336,6 +336,14 @@ declare const en: {
|
|
|
336
336
|
'reset.page.opened': string;
|
|
337
337
|
'reset.page.openedIn': string;
|
|
338
338
|
'reset.page.failed': string;
|
|
339
|
+
'reset.in.hint': string;
|
|
340
|
+
'reset.in.pick': string;
|
|
341
|
+
'reset.in.pickHint': string;
|
|
342
|
+
'reset.in.default': string;
|
|
343
|
+
'reset.in.defaultHint': string;
|
|
344
|
+
'reset.in.title': string;
|
|
345
|
+
'reset.in.intro': string;
|
|
346
|
+
'reset.in.useDefault': string;
|
|
339
347
|
'reset.title': string;
|
|
340
348
|
'reset.peers': string;
|
|
341
349
|
'reset.reading': string;
|
package/dist/src/panel/i18n.js
CHANGED
|
@@ -338,6 +338,14 @@ const en = {
|
|
|
338
338
|
'reset.page.opened': 'Opened {site} in your browser. Check that it is signed in as {who} before you use a reset.',
|
|
339
339
|
'reset.page.openedIn': 'Opened {site} in the browser user {name}. Check that it is signed in as {who} before you use a reset.',
|
|
340
340
|
'reset.page.failed': 'Could not open the page: {msg}. Open {url} yourself.',
|
|
341
|
+
'reset.in.hint': 'Opens {site} in the Chrome browser user {name}. Click to open it in another one.',
|
|
342
|
+
'reset.in.pick': 'Choose browser',
|
|
343
|
+
'reset.in.pickHint': "sideby is not sure which Chrome browser user is this account's. Choose the one to open {site} in.",
|
|
344
|
+
'reset.in.default': 'Default browser',
|
|
345
|
+
'reset.in.defaultHint': 'Opens {site} in your default browser. Click to choose a Chrome browser user instead.',
|
|
346
|
+
'reset.in.title': 'Use a reset: which browser',
|
|
347
|
+
'reset.in.intro': 'A reset counts for the login of the page. Open {site} in the browser user that is signed in as {who}.',
|
|
348
|
+
'reset.in.useDefault': 'Use my default browser',
|
|
341
349
|
'reset.title': 'Use a limit reset',
|
|
342
350
|
'reset.peers': 'Same login as {names}: one reset applies to all of them.',
|
|
343
351
|
'reset.reading': 'Reading the numbers from {host}…',
|
|
@@ -2075,6 +2083,14 @@ const zh = {
|
|
|
2075
2083
|
'reset.page.opened': '已在浏览器打开 {site}。使用重置前,请确认网页登录的是 {who}。',
|
|
2076
2084
|
'reset.page.openedIn': '已在浏览器用户 {name} 里打开 {site}。使用重置前,请确认网页登录的是 {who}。',
|
|
2077
2085
|
'reset.page.failed': '打不开页面:{msg}。请自己打开 {url}。',
|
|
2086
|
+
'reset.in.hint': '会在 Chrome 浏览器用户 {name} 里打开 {site}。点这里换一个。',
|
|
2087
|
+
'reset.in.pick': '选浏览器',
|
|
2088
|
+
'reset.in.pickHint': 'sideby 拿不准这个账号对应哪个 Chrome 浏览器用户。选一个来打开 {site}。',
|
|
2089
|
+
'reset.in.default': '默认浏览器',
|
|
2090
|
+
'reset.in.defaultHint': '会在默认浏览器里打开 {site}。点这里改用某个 Chrome 浏览器用户。',
|
|
2091
|
+
'reset.in.title': '使用重置:在哪个浏览器打开',
|
|
2092
|
+
'reset.in.intro': '重置算在网页登录的那个账号上。请在登录了 {who} 的浏览器用户里打开 {site}。',
|
|
2093
|
+
'reset.in.useDefault': '用默认浏览器打开',
|
|
2078
2094
|
'reset.title': '使用一次重置',
|
|
2079
2095
|
'reset.peers': '与 {names} 是同一登录:用一次重置,这些账号都生效。',
|
|
2080
2096
|
'reset.reading': '正在向 {host} 读取最新数字…',
|
|
@@ -1635,9 +1635,14 @@ const MAIN = String.raw `
|
|
|
1635
1635
|
const offer = kind ? limitResetOffer(q, kind, now, { short: WARN, long: LONG.warn }) : null
|
|
1636
1636
|
if (!offer) { noteClass(a.ref + ':resetbtn', '', false); return null }
|
|
1637
1637
|
const busy = ui.resetRef === a.ref
|
|
1638
|
-
const cls = noteClass(a.ref + ':resetbtn', 'btn btn-sm q-reset-btn', true)
|
|
1639
|
-
if (kind === 'page')
|
|
1640
|
-
|
|
1638
|
+
const cls = noteClass(a.ref + ':resetbtn', kind === 'page' ? 'q-reset' : 'btn btn-sm q-reset-btn', true)
|
|
1639
|
+
if (kind === 'page') {
|
|
1640
|
+
// One quiet line: the link that opens the page, then the browser user it opens in, which is also where to change it.
|
|
1641
|
+
const where = resetWhere(a)
|
|
1642
|
+
return h('span', { class: cls },
|
|
1643
|
+
h('button', { class: 'link-btn q-reset-go', type: 'button', disabled: busy, 'aria-busy': busy ? 'true' : null, title: resetPageHint(a, q, offer), onclick: (e) => { e.stopPropagation(); openResetPage(a) } }, busy ? spinner() : icon('refresh'), t('reset.usePage', { site: resetSite(a) })),
|
|
1644
|
+
where ? h('button', { class: 'email-btn br-btn q-reset-in', type: 'button', title: where.hint, 'aria-label': where.hint, onclick: (e) => { e.stopPropagation(); openBrowserDialog(a, 'reset') } }, icon('globe', 'br-ico'), h('span', { class: 'br-name' }, where.label), icon('chevron', 'br-ico')) : null)
|
|
1645
|
+
}
|
|
1641
1646
|
const why = [offer.tight.length ? t('reset.page.tight', { list: offer.tight.map((i) => resetWindowName(q.windows[i]) + ' ' + Math.round(q.windows[i].usedPercent) + '%').join(', ') }) : '', offer.expiring && q.limitResets.nextExpiresAt ? t('reset.expires', { at: clock(q.limitResets.nextExpiresAt) }) : '', t('reset.useHint')].filter(Boolean).join('\n')
|
|
1642
1647
|
return h('button', { class: cls, type: 'button', disabled: busy, title: why, onclick: (e) => { e.stopPropagation(); openReset(a) } }, t('reset.use'))
|
|
1643
1648
|
}
|
|
@@ -1651,14 +1656,40 @@ const MAIN = String.raw `
|
|
|
1651
1656
|
if (q && q.limitResets && !(q.limitResets.available > 0)) return null
|
|
1652
1657
|
return { icon: 'refresh', label: t('reset.useMenu'), hint: q && q.limitResets ? tn('reset.count', q.limitResets.available) : '', run: () => openReset(a) }
|
|
1653
1658
|
}
|
|
1659
|
+
// The browser user the vendor's page opens in when nobody is asked: the one chosen for the account, else the only
|
|
1660
|
+
// one found signed in to it. Null: not known (the default browser, or the user picks).
|
|
1661
|
+
function resetBrowser(a) {
|
|
1662
|
+
const info = browserFor(a)
|
|
1663
|
+
if (!info) return null
|
|
1664
|
+
const chosen = browserChosen(a)
|
|
1665
|
+
if (chosen) return info.b.profiles.find((p) => p.dir === chosen) || { dir: chosen, name: chosen }
|
|
1666
|
+
return info.found.length === 1 ? info.found[0] : null
|
|
1667
|
+
}
|
|
1668
|
+
// Whether a click asks which browser user first: Chrome's are known here, and none of them is this account's for sure.
|
|
1669
|
+
function resetAsks(a) {
|
|
1670
|
+
const info = browserFor(a)
|
|
1671
|
+
return Boolean(info && info.b.enabled && info.b.found && info.b.profiles.length && !resetBrowser(a))
|
|
1672
|
+
}
|
|
1673
|
+
// Next to the link: where the page will open, and the way to change it. Nothing where sideby cannot pick a browser user.
|
|
1674
|
+
function resetWhere(a) {
|
|
1675
|
+
if (!browserFor(a)) return null
|
|
1676
|
+
const p = resetBrowser(a)
|
|
1677
|
+
if (p) return { label: profileLabel(p), hint: t('reset.in.hint', { name: profileLabel(p), site: resetSite(a) }) }
|
|
1678
|
+
return resetAsks(a) ? { label: t('reset.in.pick'), hint: t('reset.in.pickHint', { site: resetSite(a) }) } : { label: t('reset.in.default'), hint: t('reset.in.defaultHint', { site: resetSite(a) }) }
|
|
1679
|
+
}
|
|
1654
1680
|
// After the jump to the vendor's page: when the user is back on this page, that account's quota is asked once.
|
|
1655
1681
|
const resetJump = { ref: null, away: false }
|
|
1656
|
-
|
|
1682
|
+
// p: the browser user picked in the dialog. direct: do not ask, open where sideby would by itself.
|
|
1683
|
+
async function openResetPage(a, p, direct) {
|
|
1657
1684
|
if (ui.resetRef) return
|
|
1685
|
+
if (!p && !direct && resetAsks(a)) { openBrowserDialog(a, 'reset'); return }
|
|
1686
|
+
const inDialog = Boolean(dlg.el && dlg.el.open)
|
|
1658
1687
|
ui.resetRef = a.ref
|
|
1659
1688
|
renderAccounts()
|
|
1689
|
+
if (dlg.kind === 'browser') renderBrowser()
|
|
1660
1690
|
try {
|
|
1661
|
-
const r = await api('/api/quota/reset/open', { account: a.ref })
|
|
1691
|
+
const r = await api('/api/quota/reset/open', { account: a.ref, ...(p ? { profile: p.dir } : {}) })
|
|
1692
|
+
if (inDialog && dlg.el.open) dlg.el.close()
|
|
1662
1693
|
resetJump.ref = a.ref
|
|
1663
1694
|
resetJump.away = document.visibilityState !== 'visible' || !document.hasFocus()
|
|
1664
1695
|
const who = a.identity && a.identity.email ? emailText(a.identity.email) : a.ref
|
|
@@ -1666,6 +1697,7 @@ const MAIN = String.raw `
|
|
|
1666
1697
|
} catch (e) { toast(t('reset.page.failed', { url: family(a.family).limitResetPage || '', msg: e.message }), { kind: 'fail' }) }
|
|
1667
1698
|
ui.resetRef = null
|
|
1668
1699
|
renderAccounts()
|
|
1700
|
+
if (dlg.kind === 'browser') renderBrowser()
|
|
1669
1701
|
}
|
|
1670
1702
|
function resetLeft() { if (resetJump.ref) resetJump.away = true }
|
|
1671
1703
|
async function resetReturned() {
|
|
@@ -1796,7 +1828,7 @@ const MAIN = String.raw `
|
|
|
1796
1828
|
const q = a.quota && a.quota.status === 'ok' ? a.quota : null
|
|
1797
1829
|
const page = resetKind(a) === 'page'
|
|
1798
1830
|
const peers = (a.sameLogin || []).map(refName)
|
|
1799
|
-
return h('li', null, h('button', { class: 'rs-pick-btn', type: 'button', onclick: () => { if (page)
|
|
1831
|
+
return h('li', null, h('button', { class: 'rs-pick-btn', type: 'button', onclick: () => { if (page) openResetPage(a); else openReset(a) } },
|
|
1800
1832
|
badge(a.family, 'sm'),
|
|
1801
1833
|
h('span', { class: 'rs-pick-main' }, h('b', null, a.ref), peers.length ? h('span', { class: 'muted small' }, ' = ' + peers.join(', ')) : null,
|
|
1802
1834
|
h('span', { class: 'rs-pick-sub' }, page ? t('reset.usePage', { site: resetSite(a) }) : q && q.limitResets ? tn('reset.count', q.limitResets.available) : t('reset.pick.unknown'))),
|
|
@@ -2103,8 +2135,9 @@ const MAIN = String.raw `
|
|
|
2103
2135
|
if (dlg.kind === 'browser') renderBrowser()
|
|
2104
2136
|
}
|
|
2105
2137
|
let br = null
|
|
2106
|
-
|
|
2107
|
-
|
|
2138
|
+
// mode 'reset': the same choice, for the page where a Limit Reset is used; "Open" opens that page.
|
|
2139
|
+
function openBrowserDialog(a, mode) {
|
|
2140
|
+
br = { ref: a.ref, busy: false, error: null, mode: mode || null }
|
|
2108
2141
|
showDialog('browser')
|
|
2109
2142
|
// Rows skip background renders while a dialog is open; turning the finding on changes what they show.
|
|
2110
2143
|
dlg.onClose = () => renderAccounts()
|
|
@@ -2126,12 +2159,13 @@ const MAIN = String.raw `
|
|
|
2126
2159
|
renderBrowser()
|
|
2127
2160
|
}
|
|
2128
2161
|
function brProfileRow(a, p) {
|
|
2129
|
-
const
|
|
2162
|
+
const reset = br.mode === 'reset'
|
|
2163
|
+
const busy = (reset ? ui.resetRef : ui.browserRef) === a.ref
|
|
2130
2164
|
const chosen = browserChosen(a) === p.dir
|
|
2131
2165
|
return h('li', { class: 'br-row' },
|
|
2132
2166
|
h('span', null, h('b', null, profileName(p.name)), p.email ? h('span', { class: 'muted small' }, ' · ' + emailText(p.email)) : null, ' ', h('span', { class: 'muted small mono' }, p.dir), p.changedAt ? h('span', { class: 'muted small' }, ' · ' + t('br.changed', { when: ago(p.changedAt) })) : null),
|
|
2133
2167
|
h('span', { class: 'br-acts' },
|
|
2134
|
-
h('button', { class: 'btn btn-sm', type: 'button', disabled: Boolean(ui.browserRef), 'aria-busy': busy ? 'true' : null, onclick: () => openBrowser(a, p) }, t('br.openIt')),
|
|
2168
|
+
h('button', { class: 'btn btn-sm', type: 'button', disabled: Boolean(ui.browserRef || ui.resetRef), 'aria-busy': busy ? 'true' : null, onclick: () => (reset ? openResetPage(a, p) : openBrowser(a, p)) }, t('br.openIt')),
|
|
2135
2169
|
chosen ? h('span', { class: 'tag', title: t('br.chosenHint') }, t('br.chosen'))
|
|
2136
2170
|
: h('button', { class: 'link-btn small', type: 'button', disabled: br.busy, title: t('br.chooseHint', { ref: a.ref }), onclick: () => brChoose(a, p.dir) }, t('br.choose'))))
|
|
2137
2171
|
}
|
|
@@ -2154,8 +2188,15 @@ const MAIN = String.raw `
|
|
|
2154
2188
|
const info = a && browserFor(a)
|
|
2155
2189
|
if (!info) { dlg.el.close(); return }
|
|
2156
2190
|
const url = siteOf(info.b, a.family)
|
|
2191
|
+
const reset = br.mode === 'reset'
|
|
2157
2192
|
const body = []
|
|
2158
2193
|
const foot = [h('button', { class: 'btn', type: 'button', disabled: br.busy, onclick: () => dlg.el.close() }, t('btn.close'))]
|
|
2194
|
+
if (reset) {
|
|
2195
|
+
// A reset belongs to the login of the page, so the dialog says who to look for, and keeps the plain way open.
|
|
2196
|
+
const who = a.identity && a.identity.email ? emailText(a.identity.email) : a.ref
|
|
2197
|
+
body.push(h('p', null, t('reset.in.intro', { site: resetSite(a), who })))
|
|
2198
|
+
if (!resetBrowser(a)) foot.push(h('button', { class: 'btn', type: 'button', disabled: br.busy || Boolean(ui.resetRef), onclick: () => openResetPage(a, null, true) }, t('reset.in.useDefault')))
|
|
2199
|
+
}
|
|
2159
2200
|
if (!info.b.enabled) {
|
|
2160
2201
|
body.push(h('p', null, t('br.offIntro', { ref: a.ref, url })))
|
|
2161
2202
|
body.push(h('p', { class: 'small' }, t('br.reads')), h('ul', { class: 'small' }, ['br.read1', 'br.read2', 'br.read3'].map((k) => h('li', null, t(k)))))
|
|
@@ -2175,7 +2216,7 @@ const MAIN = String.raw `
|
|
|
2175
2216
|
foot.unshift(h('button', { class: 'btn', type: 'button', disabled: br.busy, onclick: () => brSwitch(false) }, t('br.disable')))
|
|
2176
2217
|
}
|
|
2177
2218
|
if (br.error) body.push(errorNote(br.error, null))
|
|
2178
|
-
setKids(dlg.el, dialogFrame(t('br.title') + ' · ' + a.ref, a.family, body, foot))
|
|
2219
|
+
setKids(dlg.el, dialogFrame(t(reset ? 'reset.in.title' : 'br.title') + ' · ' + a.ref, a.family, body, foot))
|
|
2179
2220
|
}
|
|
2180
2221
|
// How to get a Host that cannot run: the sentence, then on its own line the install command to copy (with the
|
|
2181
2222
|
// install page next to it) when the Family has one; without a command the sentence ends with the page's link.
|
|
@@ -237,6 +237,10 @@ code, .mono { font-family: var(--mono); font-size: 12px; }
|
|
|
237
237
|
.q-asof .ic, .q-resets .ic { width: 11px; height: 11px; }
|
|
238
238
|
.q-reset-btn { height: 22px; padding: 0 8px; gap: 4px; font-size: 11px; }
|
|
239
239
|
.q-reset-btn .ic, .q-reset-btn .spin { width: 11px; height: 11px; }
|
|
240
|
+
.q-reset { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px 10px; min-width: 0; max-width: 100%; }
|
|
241
|
+
.q-reset-go { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; white-space: nowrap; }
|
|
242
|
+
.q-reset-go .ic, .q-reset-go .spin { width: 11px; height: 11px; }
|
|
243
|
+
.q-reset-in { font-size: 11px; }
|
|
240
244
|
/* While a reset is being used or the quota is asked after the vendor's page: the old bars stay and breathe. */
|
|
241
245
|
.quota.is-resetting .bar > span, .rs-win.is-busy .bar > span { animation: rs-wait 1.2s var(--ease-out) infinite alternate; }
|
|
242
246
|
@keyframes rs-wait { from { opacity: 1; } to { opacity: .45; } }
|
package/package.json
CHANGED
package/skills/sideby/SKILL.md
CHANGED
|
@@ -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.
|
|
5
|
+
version: "0.37.0"
|
|
6
6
|
requires:
|
|
7
7
|
bins: [sideby, node]
|
|
8
8
|
cliHelp: sideby --help
|
|
@@ -53,7 +53,7 @@ Account refs are `<family>:<name>`; a bare `<name>` works only when it is unique
|
|
|
53
53
|
| Hide or show a tool or an account in the lists ("too many shown", "hide pi") | `sideby hide <family\|ref> --json`, `sideby unhide <family\|ref> --json`, `sideby list --all` | `references/panel.md` |
|
|
54
54
|
| Turn quota checks on or off, or fix outdated Codex/Grok quota | `sideby quota check <family> on|off --json`, `sideby quota [family] --refresh --json` | `references/quota.md` |
|
|
55
55
|
| See whether an account holds a limit reset ("do I have a reset?", "有没有重置次数", "还能重置几次"), or how old a quota number is | `sideby quota [family] --json` (`quota.limitResets`, each window's `observedAt`) | `references/quota.md` |
|
|
56
|
-
| Use a limit reset ("use a reset", "reset my Codex quota", "用一次重置", "把额度重置一下", "去 claude.ai 用重置") | `sideby quota reset <ref> --json` (exit 10: the plan; show it and ask the user), then `sideby quota reset <ref> --yes --operation <operationId> --json`; Claude: `sideby quota reset <ref> --open` | `references/quota.md` |
|
|
56
|
+
| Use a limit reset ("use a reset", "reset my Codex quota", "用一次重置", "把额度重置一下", "去 claude.ai 用重置") | `sideby quota reset <ref> --json` (exit 10: the plan; show it and ask the user), then `sideby quota reset <ref> --yes --operation <operationId> --json`; Claude: `sideby quota reset <ref> --open [--profile <browser user>]` | `references/quota.md` |
|
|
57
57
|
| Set the model, effort, Remote Control or the Advisor | `sideby model <ref> --json`, `sideby remote-control --json`, `sideby advisor --json` | `references/panel.md` |
|
|
58
58
|
| Start sideby at login ("开机启动", "start the panel when I log in") | `sideby autostart --json`, `sideby autostart on --json` (exit 10 first) | `references/panel.md` |
|
|
59
59
|
| Show quota in the macOS menu bar ("状态栏显示额度", "menu bar"), its icon is missing ("状态栏没有图标"), or change its shortcut ("换个快捷键", "帮我挑个顺手的快捷键") | `sideby menubar --json`, `sideby menubar on --json` (exit 10 first), `sideby menubar snapshot --json`, `sideby menubar hotkey [<keys>] --json` | `references/panel.md` |
|
|
@@ -34,7 +34,7 @@ Using a limit reset cannot be undone. **Never add `--yes` on your own**: not to
|
|
|
34
34
|
|
|
35
35
|
sideby never changes the count or the bars itself: report only what `quota` says.
|
|
36
36
|
|
|
37
|
-
**Claude Code** (only Claude's website can use one): `sideby quota reset <ref> --json` answers `outcome: "open-vendor-page"` with `url` (`https://claude.ai/settings/usage`), `identity` (the account's email) and `tight` (the windows at their warning level). sideby cannot see whether the account holds a reset. Tell the user to use it on that page, signed in as that email; `sideby quota reset <ref> --open` opens the page in the account's browser profile (ask first: it opens a window). Afterwards `sideby quota <ref> --refresh --json` reads the new numbers. Which limit it restores is Anthropic's rule: a Fable reset gives back the Fable share of the week, and a 5-hour reset restores that window whole.
|
|
37
|
+
**Claude Code** (only Claude's website can use one): `sideby quota reset <ref> --json` answers `outcome: "open-vendor-page"` with `url` (`https://claude.ai/settings/usage`), `identity` (the account's email) and `tight` (the windows at their warning level). sideby cannot see whether the account holds a reset. Tell the user to use it on that page, signed in as that email; `sideby quota reset <ref> --open` opens the page in the account's browser profile (ask first: it opens a window); add `--profile <name>` to open it in another Chrome browser user (a folder, name or Google account from `sideby browser --json`), for example when the user says which browser is signed in as that account. Afterwards `sideby quota <ref> --refresh --json` reads the new numbers. Which limit it restores is Anthropic's rule: a Fable reset gives back the Fable share of the week, and a 5-hour reset restores that window whole.
|
|
38
38
|
|
|
39
39
|
Any other tool answers `code: "no-limit-reset"`: say sideby cannot use one there and point to the vendor's own usage page.
|
|
40
40
|
|