sideby 0.36.0 → 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 +21 -8
- package/dist/src/cli/main.js +1 -1
- package/dist/src/core/advisor.d.ts +11 -0
- package/dist/src/core/advisor.js +113 -66
- package/dist/src/core/browser-profiles.d.ts +5 -3
- package/dist/src/core/browser-profiles.js +31 -4
- package/dist/src/core/claude-settings-file.d.ts +14 -0
- package/dist/src/core/claude-settings-file.js +62 -23
- package/dist/src/panel/background.d.ts +8 -3
- package/dist/src/panel/background.js +35 -3
- package/dist/src/panel/handler.js +31 -10
- package/dist/src/panel/i18n.d.ts +8 -0
- package/dist/src/panel/i18n.js +16 -0
- package/dist/src/panel/page-script.js +56 -13
- package/dist/src/panel/page-styles.js +4 -0
- package/dist/src/runtime.d.ts +4 -2
- package/dist/src/runtime.js +1 -0
- package/package.json +1 -1
- package/skills/sideby/SKILL.md +2 -2
- package/skills/sideby/references/panel.md +1 -1
- 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
|
@@ -1194,12 +1194,21 @@ export async function cmdAdvisor(a, io, runtime) {
|
|
|
1194
1194
|
? `Use ${name} as the advisor?`
|
|
1195
1195
|
: 'Put back the advisor setting sideby replaced?');
|
|
1196
1196
|
for (const g of todo) {
|
|
1197
|
-
const to = choice === 'off' ? 'removed' : choice ? `"${choice}"` : 'what it was before';
|
|
1198
1197
|
const file = tildify(g.file, home);
|
|
1199
|
-
if (
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1198
|
+
if (choice) {
|
|
1199
|
+
const to = choice === 'off' ? 'removed' : `"${choice}"`;
|
|
1200
|
+
if (g.state !== choice)
|
|
1201
|
+
io.out(` ${file}: advisorModel ${advisorValue(g)} -> ${to}`);
|
|
1202
|
+
if (plan?.betas.includes(g))
|
|
1203
|
+
io.out(` ${file}: env.${BETAS_VAR} ${g.betasValue} -> removed`);
|
|
1204
|
+
}
|
|
1205
|
+
else {
|
|
1206
|
+
// Only what undo really puts back: a change that kept the model only removed the env entry.
|
|
1207
|
+
if (g.undoModel)
|
|
1208
|
+
io.out(` ${file}: advisorModel ${advisorValue(g)} -> ${g.undoModel}`);
|
|
1209
|
+
if (g.undoBetas)
|
|
1210
|
+
io.out(` ${file}: env.${BETAS_VAR} absent -> ${g.undoBetas}`);
|
|
1211
|
+
}
|
|
1203
1212
|
io.out(c.dim(` used by ${g.accounts.join(', ')}`));
|
|
1204
1213
|
if (g.apiAccounts?.length && (plan ? plan.betas.includes(g) : g.undoApiBetas))
|
|
1205
1214
|
io.out(c.dim(` and by API accounts ${g.apiAccounts.join(', ')}`));
|
|
@@ -1462,11 +1471,15 @@ function resetWindowLine(w, now) {
|
|
|
1462
1471
|
* it. A spend that got no final answer fails with the `operationId` to retry.
|
|
1463
1472
|
*/
|
|
1464
1473
|
export async function cmdQuotaReset(a, io, runtime) {
|
|
1465
|
-
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]';
|
|
1466
1475
|
const ref = a.positionals[1];
|
|
1467
1476
|
if (!ref || a.positionals.length !== 2 || a.rest.length || a.flags.has('refresh'))
|
|
1468
1477
|
throw new UsageError(usage);
|
|
1469
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}`);
|
|
1470
1483
|
const asJson = a.flags.has('json');
|
|
1471
1484
|
const rt = runtime ?? (await createRuntime());
|
|
1472
1485
|
const now = rt.readContext().now;
|
|
@@ -1483,7 +1496,7 @@ export async function cmdQuotaReset(a, io, runtime) {
|
|
|
1483
1496
|
long: QUOTA_LONG_WARN_PERCENT,
|
|
1484
1497
|
});
|
|
1485
1498
|
const tight = quota.status === 'ok' ? (offer?.tight ?? []).map((i) => quota.windows[i]) : [];
|
|
1486
|
-
const opened = a.flags.has('open') ? await openVendorPage(rt, account) : undefined;
|
|
1499
|
+
const opened = a.flags.has('open') ? await openVendorPage(rt, account, profile) : undefined;
|
|
1487
1500
|
const who = st.identity?.email;
|
|
1488
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.`;
|
|
1489
1502
|
if (asJson) {
|
|
@@ -1523,7 +1536,7 @@ export async function cmdQuotaReset(a, io, runtime) {
|
|
|
1523
1536
|
if (!f.limitReset?.vendorPage)
|
|
1524
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' });
|
|
1525
1538
|
// A Family whose Host can use one and that has a vendor page too: `--open` only opens the page, and uses nothing.
|
|
1526
|
-
const opened = await openVendorPage(rt, account);
|
|
1539
|
+
const opened = await openVendorPage(rt, account, profile);
|
|
1527
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}\`.`;
|
|
1528
1541
|
if (asJson)
|
|
1529
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'] },
|
|
@@ -50,6 +50,13 @@ export interface AdvisorGroup {
|
|
|
50
50
|
undo: boolean;
|
|
51
51
|
/** With `undo`: the change turned config `claude.apiBetasOff` on for this file's API Accounts, and undo turns it back. */
|
|
52
52
|
undoApiBetas?: true;
|
|
53
|
+
/**
|
|
54
|
+
* With `undo`: undo changes `advisorModel`, back to this value as JSON, or `removed` when the file had none. Absent
|
|
55
|
+
* when the change kept the model the file already named (it only removed the `env` entry).
|
|
56
|
+
*/
|
|
57
|
+
undoModel?: string;
|
|
58
|
+
/** With `undo`: undo puts `env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` back, with this value as JSON. */
|
|
59
|
+
undoBetas?: string;
|
|
53
60
|
}
|
|
54
61
|
export interface AdvisorStatus {
|
|
55
62
|
groups: AdvisorGroup[];
|
|
@@ -65,6 +72,8 @@ export interface AdvisorConfigState {
|
|
|
65
72
|
unlock: boolean;
|
|
66
73
|
apiBetasOff: boolean;
|
|
67
74
|
}
|
|
75
|
+
/** What a preview showed of one file: a change refuses a file that no longer holds this (`AdvisorGroup` fields). */
|
|
76
|
+
export type AdvisorSeen = Pick<AdvisorGroup, 'file' | 'state' | 'model' | 'betasValue'>;
|
|
68
77
|
export interface AdvisorChange {
|
|
69
78
|
ok: boolean;
|
|
70
79
|
/** One line per group that was meant to change. */
|
|
@@ -152,6 +161,8 @@ export declare function advisorNothingToDo(action: AdvisorChoice | 'undo', scope
|
|
|
152
161
|
export declare function setAdvisor(accounts: readonly Account[], ctx: ReadContext, to: AdvisorChoice, opts: AdvisorConfigState & {
|
|
153
162
|
configFile: string;
|
|
154
163
|
account?: string;
|
|
164
|
+
/** The files as a preview showed them; a file missing here or no longer like this is not written. */
|
|
165
|
+
seen?: readonly AdvisorSeen[];
|
|
155
166
|
}): Promise<AdvisorChange>;
|
|
156
167
|
/** Groups sideby can put back: it wrote there and the key still holds what it wrote. */
|
|
157
168
|
export declare function advisorGroupsToUndo(groups: readonly AdvisorGroup[]): AdvisorGroup[];
|
package/dist/src/core/advisor.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// change turns config `claude.apiBetasOff` on, and sideby then sets it when it starts them (gateways often reject the
|
|
10
10
|
// headers experimental features send).
|
|
11
11
|
import { rm } from 'node:fs/promises';
|
|
12
|
-
import { isObj, keyRecordPath, readKeyRecord, readSettingsGroups, writeKeyRecord, writeSettingsKey, } from './claude-settings-file.js';
|
|
12
|
+
import { isObj, keyRecordPath, lockedSettingsChange, readKeyRecord, readSettingsGroups, writeKeyRecord, writeSettingsKey, } from './claude-settings-file.js';
|
|
13
13
|
import { editConfigAdvisor, editConfigClaude } from './config.js';
|
|
14
14
|
import { UserError } from './errors.js';
|
|
15
15
|
export const ADVISOR_KEY = 'advisorModel';
|
|
@@ -29,6 +29,14 @@ export const ADVISOR_OFF_VARS = ['CLAUDE_CODE_DISABLE_ADVISOR_TOOL', BETAS_VAR];
|
|
|
29
29
|
const TITLE = { fable: 'Fable', opus: 'Opus', sonnet: 'Sonnet' };
|
|
30
30
|
const RECORDS = 'advisor';
|
|
31
31
|
const ENV_NOT_OBJECT = 'settings.json has an `env` that is not a JSON object; fix it in the file, then try again';
|
|
32
|
+
/** Whether `obj` still holds what `seen` showed: the same `advisorModel` reading and the same true env entry. */
|
|
33
|
+
function looksAsSeen(obj, seen) {
|
|
34
|
+
const now = stateOf(obj[ADVISOR_KEY]);
|
|
35
|
+
const betas = isObj(obj.env) ? obj.env[BETAS_VAR] : undefined;
|
|
36
|
+
const value = truthy(betas) ? JSON.stringify(betas) : undefined;
|
|
37
|
+
return now.state === seen.state && now.model === seen.model && value === seen.betasValue;
|
|
38
|
+
}
|
|
39
|
+
const CHANGED_SINCE = 'settings.json changed after sideby read it, so nothing was changed. Look again and try again.';
|
|
32
40
|
const MODEL_ID = /^[A-Za-z0-9][A-Za-z0-9._:@[\]-]{0,99}$/;
|
|
33
41
|
function stateOf(v) {
|
|
34
42
|
if (v === undefined)
|
|
@@ -92,6 +100,17 @@ async function readRecord(stateDir, file) {
|
|
|
92
100
|
delete r.apiBetas;
|
|
93
101
|
return r;
|
|
94
102
|
}
|
|
103
|
+
/** What undo would change in `obj`, from the record of the change it undoes (`AdvisorGroup.undoModel` and on). */
|
|
104
|
+
function undoParts(obj, r) {
|
|
105
|
+
const model = r.removed ? r.hadKey : !(r.hadKey && same(r.previous, r.wrote));
|
|
106
|
+
const env = obj.env;
|
|
107
|
+
const betas = r.betas !== undefined && (env === undefined || (isObj(env) && !Object.hasOwn(env, BETAS_VAR)));
|
|
108
|
+
return {
|
|
109
|
+
...(r.apiBetas ? { undoApiBetas: true } : {}),
|
|
110
|
+
...(model ? { undoModel: r.hadKey ? JSON.stringify(r.previous) : 'removed' } : {}),
|
|
111
|
+
...(betas ? { undoBetas: JSON.stringify(r.betas?.previous) } : {}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
95
114
|
/** `obj` with `key` set to `value` at `index` among its keys (at the end without one), keeping the others' order. */
|
|
96
115
|
function insertAt(obj, key, value, index) {
|
|
97
116
|
const entries = Object.entries(obj).filter(([k]) => k !== key);
|
|
@@ -131,7 +150,7 @@ export async function advisorGroups(accounts, ctx) {
|
|
|
131
150
|
...stateOf(g.obj[ADVISOR_KEY]),
|
|
132
151
|
...(truthy(betas) ? { betasOff: true, betasValue: JSON.stringify(betas) } : {}),
|
|
133
152
|
undo,
|
|
134
|
-
...(undo
|
|
153
|
+
...(undo ? undoParts(g.obj, record) : {}),
|
|
135
154
|
});
|
|
136
155
|
}
|
|
137
156
|
}
|
|
@@ -247,46 +266,50 @@ async function restoreApiBetas(configFile, previous) {
|
|
|
247
266
|
* an undo record of exactly those two entries, and of `apiBetas` (the earlier config `claude.apiBetasOff`) when the
|
|
248
267
|
* same change turned that on for this file's API Accounts.
|
|
249
268
|
*/
|
|
250
|
-
async function writeGroup(stateDir, g, to, apiBetas) {
|
|
269
|
+
async function writeGroup(stateDir, g, to, apiBetas, seen = g) {
|
|
251
270
|
const dropBetas = to !== 'off';
|
|
252
271
|
const box = {};
|
|
253
|
-
const failed = await
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
r.previous = obj[ADVISOR_KEY];
|
|
261
|
-
if (to === 'off') {
|
|
262
|
-
r.removed = true;
|
|
272
|
+
const failed = await lockedSettingsChange(stateDir, g.file, async () => {
|
|
273
|
+
const failed = await writeSettingsKey(g.file, (obj) => {
|
|
274
|
+
const r = {
|
|
275
|
+
file: g.file,
|
|
276
|
+
hadKey: Object.hasOwn(obj, ADVISOR_KEY),
|
|
277
|
+
at: new Date().toISOString(),
|
|
278
|
+
};
|
|
263
279
|
if (r.hadKey)
|
|
264
|
-
r.
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
280
|
+
r.previous = obj[ADVISOR_KEY];
|
|
281
|
+
if (to === 'off') {
|
|
282
|
+
r.removed = true;
|
|
283
|
+
if (r.hadKey)
|
|
284
|
+
r.index = Object.keys(obj).indexOf(ADVISOR_KEY);
|
|
285
|
+
delete obj[ADVISOR_KEY];
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
r.wrote = to;
|
|
289
|
+
obj[ADVISOR_KEY] = to;
|
|
290
|
+
}
|
|
291
|
+
const env = obj.env;
|
|
292
|
+
if (dropBetas && isObj(env) && truthy(env[BETAS_VAR])) {
|
|
293
|
+
r.betas = { previous: env[BETAS_VAR], index: Object.keys(env).indexOf(BETAS_VAR) };
|
|
294
|
+
obj.env = Object.fromEntries(Object.entries(env).filter(([k]) => k !== BETAS_VAR));
|
|
295
|
+
if (apiBetas && g.apiAccounts?.length)
|
|
296
|
+
r.apiBetas = apiBetas;
|
|
297
|
+
}
|
|
298
|
+
box.record = r;
|
|
299
|
+
return obj;
|
|
300
|
+
}, (obj) => {
|
|
301
|
+
if (obj.env !== undefined && !isObj(obj.env))
|
|
302
|
+
return `${ENV_NOT_OBJECT}.`;
|
|
303
|
+
const betas = dropBetas && isObj(obj.env) && truthy(obj.env[BETAS_VAR]);
|
|
304
|
+
if (stateOf(obj[ADVISOR_KEY]).state === to && !betas)
|
|
305
|
+
return 'It was set that way meanwhile; nothing changed.';
|
|
306
|
+
// Read under the lock: the write must be the one the plan (or the Panel's preview) was made for.
|
|
307
|
+
return looksAsSeen(obj, seen) ? null : CHANGED_SINCE;
|
|
308
|
+
});
|
|
309
|
+
if (!failed && box.record)
|
|
310
|
+
await writeKeyRecord(stateDir, RECORDS, g.file, box.record);
|
|
311
|
+
return failed;
|
|
287
312
|
});
|
|
288
|
-
if (!failed && box.record)
|
|
289
|
-
await writeKeyRecord(stateDir, RECORDS, g.file, box.record);
|
|
290
313
|
const betas = !failed && box.record?.betas !== undefined;
|
|
291
314
|
const done = (to === 'off' ? 'Turned off.' : `Set to ${to}.`) + (betas ? ` Removed env.${BETAS_VAR}.` : '');
|
|
292
315
|
return {
|
|
@@ -326,8 +349,20 @@ export async function setAdvisor(accounts, ctx, to, opts) {
|
|
|
326
349
|
}
|
|
327
350
|
}
|
|
328
351
|
const written = [];
|
|
329
|
-
for (const g of plan.todo)
|
|
330
|
-
|
|
352
|
+
for (const g of plan.todo) {
|
|
353
|
+
const seen = opts.seen ? opts.seen.find((s) => s.file === g.file) : g;
|
|
354
|
+
if (seen)
|
|
355
|
+
written.push(await writeGroup(ctx.stateDir, g, to, apiPrev, seen));
|
|
356
|
+
else
|
|
357
|
+
written.push({
|
|
358
|
+
file: g.file,
|
|
359
|
+
accounts: g.accounts,
|
|
360
|
+
ok: false,
|
|
361
|
+
message: CHANGED_SINCE,
|
|
362
|
+
betas: false,
|
|
363
|
+
api: false,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
331
366
|
const results = written.map(({ betas: _b, api: _a, ...r }) => r);
|
|
332
367
|
// No file the API Accounts use lost the variable after all: the config goes back as it was.
|
|
333
368
|
const apiOn = apiPrev !== undefined && written.some((r) => r.api);
|
|
@@ -380,33 +415,45 @@ export async function undoAdvisor(accounts, ctx, opts) {
|
|
|
380
415
|
let apiPrev;
|
|
381
416
|
let apiBack = true;
|
|
382
417
|
for (const g of todo) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
continue;
|
|
418
|
+
// The record is read under the lock, so it is the one of the last change that finished.
|
|
419
|
+
const box = {};
|
|
386
420
|
let back = false;
|
|
387
|
-
const failed = await
|
|
388
|
-
|
|
389
|
-
if (record
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
421
|
+
const failed = await lockedSettingsChange(ctx.stateDir, g.file, async () => {
|
|
422
|
+
const record = await readRecord(ctx.stateDir, g.file);
|
|
423
|
+
if (!record)
|
|
424
|
+
return null;
|
|
425
|
+
box.record = record;
|
|
426
|
+
const failed = await writeSettingsKey(g.file, (obj) => {
|
|
427
|
+
let out = obj;
|
|
428
|
+
if (record.removed) {
|
|
429
|
+
if (record.hadKey)
|
|
430
|
+
out = insertAt(out, ADVISOR_KEY, record.previous, record.index);
|
|
431
|
+
}
|
|
432
|
+
else if (record.hadKey)
|
|
433
|
+
out[ADVISOR_KEY] = record.previous;
|
|
434
|
+
else
|
|
435
|
+
delete out[ADVISOR_KEY];
|
|
436
|
+
const b = record.betas;
|
|
437
|
+
if (b) {
|
|
438
|
+
if (out.env === undefined)
|
|
439
|
+
out.env = { [BETAS_VAR]: b.previous };
|
|
440
|
+
else if (isObj(out.env) && !Object.hasOwn(out.env, BETAS_VAR))
|
|
441
|
+
out.env = insertAt(out.env, BETAS_VAR, b.previous, b.index);
|
|
442
|
+
}
|
|
443
|
+
back = isObj(out.env) && truthy(out.env[BETAS_VAR]);
|
|
444
|
+
return out;
|
|
445
|
+
}, (obj) => holds(obj, record) ? null : 'The setting was changed after sideby set it, so it was left alone.');
|
|
446
|
+
if (!failed)
|
|
447
|
+
await rm(keyRecordPath(ctx.stateDir, RECORDS, g.file), { force: true });
|
|
448
|
+
return failed;
|
|
449
|
+
});
|
|
450
|
+
const record = box.record;
|
|
451
|
+
if (!record && !failed)
|
|
452
|
+
continue;
|
|
453
|
+
// The lock stayed held, so its record was not read: the file may still need config claude.apiBetasOff.
|
|
454
|
+
if (!record)
|
|
455
|
+
apiBack = false;
|
|
456
|
+
if (record?.apiBetas) {
|
|
410
457
|
apiPrev ??= record.apiBetas.previous;
|
|
411
458
|
if (failed || !back)
|
|
412
459
|
apiBack = false;
|
|
@@ -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
|
|
@@ -27,6 +27,20 @@ export declare function settingsFileGroups(accounts: readonly Account[]): Promis
|
|
|
27
27
|
* else what went wrong in plain words.
|
|
28
28
|
*/
|
|
29
29
|
export declare function writeSettingsKey(file: string, change: (obj: Json) => Json, expect: (obj: Json) => string | null): Promise<string | null>;
|
|
30
|
+
/** How long a change waits for another one of the same file. Mutable for tests only. */
|
|
31
|
+
export declare const settingsLockWait: {
|
|
32
|
+
timeoutMs: number;
|
|
33
|
+
pollMs: number;
|
|
34
|
+
};
|
|
35
|
+
/** What a change says when another sideby change of the same file held it for too long. */
|
|
36
|
+
export declare const SETTINGS_BUSY = "Another sideby change of this settings file is still running, so nothing was changed. Try again in a moment.";
|
|
37
|
+
/**
|
|
38
|
+
* Runs one change of `file` and its undo record while no other sideby process (the CLI, the Panel) changes that file,
|
|
39
|
+
* so a record always describes the write it follows and one change never replaces another's record halfway. The lock
|
|
40
|
+
* is `<state>/settings-locks/<hash of file>.lock`. Returns `fn`'s answer, or `SETTINGS_BUSY` when the lock stayed
|
|
41
|
+
* held.
|
|
42
|
+
*/
|
|
43
|
+
export declare function lockedSettingsChange(stateDir: string, file: string, fn: () => Promise<string | null>): Promise<string | null>;
|
|
30
44
|
/** Where sideby keeps the undo record of one key it wrote in `file`: `<state>/<dir>/<hash of file>.json`. */
|
|
31
45
|
export declare const keyRecordPath: (stateDir: string, dir: string, file: string) => string;
|
|
32
46
|
/** Writes an undo record (mode 600) under the state directory. */
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { mkdir, readFile, rm, stat } from 'node:fs/promises';
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { lstatOrNull, realpathOrNull, sha256, writeFileAtomic, writeIfUnchanged } from './fs-safe.js';
|
|
7
|
+
import { takeFileLock } from './lock.js';
|
|
7
8
|
const MAX_BYTES = 5_000_000;
|
|
8
9
|
export const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
9
10
|
function detectIndent(text) {
|
|
@@ -83,6 +84,33 @@ export async function writeSettingsKey(file, change, expect) {
|
|
|
83
84
|
const wrote = await writeIfUnchanged(file, sha256(read.text), render(change({ ...read.obj }), read.text), mode);
|
|
84
85
|
return wrote ? null : 'settings.json changed while sideby was writing, so nothing was changed. Try again.';
|
|
85
86
|
}
|
|
87
|
+
/** How long a change waits for another one of the same file. Mutable for tests only. */
|
|
88
|
+
export const settingsLockWait = { timeoutMs: 10_000, pollMs: 50 };
|
|
89
|
+
/** What a change says when another sideby change of the same file held it for too long. */
|
|
90
|
+
export const SETTINGS_BUSY = 'Another sideby change of this settings file is still running, so nothing was changed. Try again in a moment.';
|
|
91
|
+
/**
|
|
92
|
+
* Runs one change of `file` and its undo record while no other sideby process (the CLI, the Panel) changes that file,
|
|
93
|
+
* so a record always describes the write it follows and one change never replaces another's record halfway. The lock
|
|
94
|
+
* is `<state>/settings-locks/<hash of file>.lock`. Returns `fn`'s answer, or `SETTINGS_BUSY` when the lock stayed
|
|
95
|
+
* held.
|
|
96
|
+
*/
|
|
97
|
+
export async function lockedSettingsChange(stateDir, file, fn) {
|
|
98
|
+
const dir = join(stateDir, 'settings-locks');
|
|
99
|
+
await mkdir(dir, { recursive: true, mode: 0o700 });
|
|
100
|
+
const release = await takeFileLock(join(dir, `${sha256(file).slice(0, 16)}.lock`), {
|
|
101
|
+
staleMs: 15_000,
|
|
102
|
+
beatMs: 3_000,
|
|
103
|
+
wait: { ...settingsLockWait },
|
|
104
|
+
});
|
|
105
|
+
if (!release)
|
|
106
|
+
return SETTINGS_BUSY;
|
|
107
|
+
try {
|
|
108
|
+
return await fn();
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
await release();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
86
114
|
/** Where sideby keeps the undo record of one key it wrote in `file`: `<state>/<dir>/<hash of file>.json`. */
|
|
87
115
|
export const keyRecordPath = (stateDir, dir, file) => join(stateDir, dir, `${sha256(file).slice(0, 16)}.json`);
|
|
88
116
|
/** Writes an undo record (mode 600) under the state directory. */
|
|
@@ -133,16 +161,19 @@ export function settingsKey(key, records, opts = {}) {
|
|
|
133
161
|
async set(stateDir, groups, to, expect, done) {
|
|
134
162
|
const results = [];
|
|
135
163
|
for (const g of groups) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
164
|
+
const failed = await lockedSettingsChange(stateDir, g.file, async () => {
|
|
165
|
+
let before = { hadKey: false };
|
|
166
|
+
const failed = await writeSettingsKey(g.file, (obj) => {
|
|
167
|
+
before = key in obj ? { hadKey: true, previous: obj[key] } : { hadKey: false };
|
|
168
|
+
obj[key] = to;
|
|
169
|
+
return obj;
|
|
170
|
+
}, (obj) => expect(obj[key]));
|
|
171
|
+
if (!failed) {
|
|
172
|
+
const record = { file: g.file, ...before, wrote: to, at: new Date().toISOString() };
|
|
173
|
+
await writeKeyRecord(stateDir, records, g.file, record);
|
|
174
|
+
}
|
|
175
|
+
return failed;
|
|
176
|
+
});
|
|
146
177
|
results.push({ file: g.file, accounts: g.accounts, ok: !failed, message: failed ?? done });
|
|
147
178
|
}
|
|
148
179
|
return results;
|
|
@@ -151,20 +182,28 @@ export function settingsKey(key, records, opts = {}) {
|
|
|
151
182
|
async undo(stateDir, groups) {
|
|
152
183
|
const results = [];
|
|
153
184
|
for (const g of groups) {
|
|
154
|
-
|
|
155
|
-
|
|
185
|
+
// The record is read under the lock, so it is the one of the last change that finished.
|
|
186
|
+
let found = false;
|
|
187
|
+
const failed = await lockedSettingsChange(stateDir, g.file, async () => {
|
|
188
|
+
const record = await readRecord(stateDir, g.file);
|
|
189
|
+
if (!record)
|
|
190
|
+
return null;
|
|
191
|
+
found = true;
|
|
192
|
+
const failed = await writeSettingsKey(g.file, (obj) => {
|
|
193
|
+
if (record.hadKey)
|
|
194
|
+
obj[key] = record.previous;
|
|
195
|
+
else
|
|
196
|
+
delete obj[key];
|
|
197
|
+
return obj;
|
|
198
|
+
}, (obj) => same(obj[key], record.wrote)
|
|
199
|
+
? null
|
|
200
|
+
: 'The setting was changed after sideby set it, so it was left alone.');
|
|
201
|
+
if (!failed)
|
|
202
|
+
await rm(keyRecordPath(stateDir, records, g.file), { force: true });
|
|
203
|
+
return failed;
|
|
204
|
+
});
|
|
205
|
+
if (!found && !failed)
|
|
156
206
|
continue;
|
|
157
|
-
const failed = await writeSettingsKey(g.file, (obj) => {
|
|
158
|
-
if (record.hadKey)
|
|
159
|
-
obj[key] = record.previous;
|
|
160
|
-
else
|
|
161
|
-
delete obj[key];
|
|
162
|
-
return obj;
|
|
163
|
-
}, (obj) => same(obj[key], record.wrote)
|
|
164
|
-
? null
|
|
165
|
-
: 'The setting was changed after sideby set it, so it was left alone.');
|
|
166
|
-
if (!failed)
|
|
167
|
-
await rm(keyRecordPath(stateDir, records, g.file), { force: true });
|
|
168
207
|
results.push({ file: g.file, accounts: g.accounts, ok: !failed, message: failed ?? 'Put back.' });
|
|
169
208
|
}
|
|
170
209
|
return results;
|
|
@@ -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}`)))
|
|
@@ -1081,24 +1081,41 @@ export function createPanelHandler(opts) {
|
|
|
1081
1081
|
* A change of one key in Claude's settings files that the page showed file by file before the user confirmed
|
|
1082
1082
|
* (Remote Control, spec §3.22; receiving Messages, ADR-0045). Without `confirm` it writes nothing and names the
|
|
1083
1083
|
* files; with it, `files` must be exactly the files the page showed, or nothing is written and `changedSince` says
|
|
1084
|
-
* so, because a file the user never saw in the preview must not change.
|
|
1085
|
-
*
|
|
1084
|
+
* so, because a file the user never saw in the preview must not change. Where what a file holds decides what the
|
|
1085
|
+
* write does (Advisor: whether `env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` goes too), `shown` names that part of a
|
|
1086
|
+
* group: the page sends the groups it showed as `groups`, and a file whose part differs now refuses the same way.
|
|
1087
|
+
* Remote Control and receiving Messages need none: they write one fixed value, whatever the file held. Undo passes
|
|
1088
|
+
* no `todo`: it only puts back what sideby wrote, only while the file still holds that (spec §3.22), and its toast
|
|
1089
|
+
* runs before the page has read the new state.
|
|
1086
1090
|
*/
|
|
1087
1091
|
const previewedChange = (change) => ({
|
|
1088
1092
|
writes: (body) => body.confirm === true,
|
|
1089
1093
|
async run(body) {
|
|
1090
1094
|
const rt = await getRuntime();
|
|
1091
1095
|
const home = rt.paths.home;
|
|
1092
|
-
const
|
|
1096
|
+
const raw = change.todo ? await change.todo(rt, body) : undefined;
|
|
1097
|
+
const todo = raw?.map((g) => ({ ...g, file: tildify(g.file, home) }));
|
|
1098
|
+
const files = todo?.map((g) => g.file);
|
|
1093
1099
|
if (!optBool(body, 'confirm'))
|
|
1094
1100
|
return { applied: false, ...(files ? { files } : {}) };
|
|
1095
|
-
if (files) {
|
|
1101
|
+
if (todo && files) {
|
|
1096
1102
|
const saw = body.files;
|
|
1097
1103
|
const same = Array.isArray(saw) && saw.length === files.length && files.every((f) => saw.includes(f));
|
|
1098
1104
|
if (!same)
|
|
1099
1105
|
return { applied: false, changedSince: true, files };
|
|
1106
|
+
const shown = change.shown;
|
|
1107
|
+
if (shown) {
|
|
1108
|
+
const seen = (Array.isArray(body.groups) ? body.groups : []).filter((x) => typeof x === 'object' && x !== null && !Array.isArray(x));
|
|
1109
|
+
const key = (g) => JSON.stringify(shown(g) ?? null);
|
|
1110
|
+
const alike = todo.every((g) => {
|
|
1111
|
+
const s = seen.find((x) => x.file === g.file);
|
|
1112
|
+
return s !== undefined && key(s) === key(g);
|
|
1113
|
+
});
|
|
1114
|
+
if (!alike)
|
|
1115
|
+
return { applied: false, changedSince: true, files };
|
|
1116
|
+
}
|
|
1100
1117
|
}
|
|
1101
|
-
const r = await change.apply(rt, body);
|
|
1118
|
+
const r = await change.apply(rt, body, raw);
|
|
1102
1119
|
return { ...r, applied: true, results: r.results.map((x) => ({ ...x, file: tildify(x.file, home) })) };
|
|
1103
1120
|
},
|
|
1104
1121
|
});
|
|
@@ -1477,9 +1494,12 @@ export function createPanelHandler(opts) {
|
|
|
1477
1494
|
const st = await rt.advisor();
|
|
1478
1495
|
return advisorPlan(advisorScope(st.groups, account), to, st).todo;
|
|
1479
1496
|
},
|
|
1480
|
-
|
|
1497
|
+
// What decides the write besides the model the body names: the env entry it removes, and who shares the file.
|
|
1498
|
+
shown: (g) => [g.state ?? null, g.model ?? null, g.betasValue ?? null, g.apiAccounts ?? []],
|
|
1499
|
+
// The files as the page showed them, checked again under each file's lock right before the write.
|
|
1500
|
+
async apply(rt, body, checked) {
|
|
1481
1501
|
const { to, account } = await advisorBody(rt, body);
|
|
1482
|
-
return rt.advisorSet(to, account ? { account } : {});
|
|
1502
|
+
return rt.advisorSet(to, { ...(account ? { account } : {}), ...(checked ? { seen: checked } : {}) });
|
|
1483
1503
|
},
|
|
1484
1504
|
}),
|
|
1485
1505
|
'/api/advisor/undo': previewedChange({ apply: (rt) => rt.advisorUndo() }),
|
|
@@ -2254,15 +2274,16 @@ export function createPanelHandler(opts) {
|
|
|
2254
2274
|
return { result: await rt.limitResetUse(account, operationId) };
|
|
2255
2275
|
},
|
|
2256
2276
|
},
|
|
2257
|
-
// Opens the vendor's page where a Limit Reset is spent (Claude Code, ADR-0072)
|
|
2258
|
-
// 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.
|
|
2259
2280
|
'/api/quota/reset/open': {
|
|
2260
2281
|
async run(body) {
|
|
2261
2282
|
const ref = optString(body, 'account');
|
|
2262
2283
|
if (!ref)
|
|
2263
2284
|
throw new HttpError(400, '"account" is required');
|
|
2264
2285
|
const rt = await getRuntime();
|
|
2265
|
-
const r = await openVendorPage(rt, await rt.resolve(ref));
|
|
2286
|
+
const r = await openVendorPage(rt, await rt.resolve(ref), optString(body, 'profile'));
|
|
2266
2287
|
return { ref: r.ref, url: r.url, ...(r.profile ? { profile: r.profile } : {}) };
|
|
2267
2288
|
},
|
|
2268
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.
|
|
@@ -7980,10 +8021,12 @@ const MAIN = String.raw `
|
|
|
7980
8021
|
async function setAdvisorModel(to) {
|
|
7981
8022
|
const st = advState()
|
|
7982
8023
|
if (!st) return
|
|
7983
|
-
const
|
|
8024
|
+
const groups = advPlan(st, to).todo
|
|
8025
|
+
const files = groups.map((g) => g.file)
|
|
7984
8026
|
advBusy(true)
|
|
7985
8027
|
try {
|
|
7986
|
-
|
|
8028
|
+
// The groups as shown, so the server refuses when a file now holds something the preview did not show.
|
|
8029
|
+
const r = await api('/api/advisor/set', { confirm: true, to, files, groups })
|
|
7987
8030
|
if (r.changedSince) toast(t('as.changedSince'), { kind: 'fail' })
|
|
7988
8031
|
else if (r.ok) {
|
|
7989
8032
|
// Show the new state now; the reload that follows confirms it.
|
|
@@ -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/dist/src/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AccountRefError } from './core/accounts.ts';
|
|
2
|
-
import { type AdvisorChange, type AdvisorChoice, type AdvisorStatus } from './core/advisor.ts';
|
|
2
|
+
import { type AdvisorChange, type AdvisorChoice, type AdvisorSeen, type AdvisorStatus } from './core/advisor.ts';
|
|
3
3
|
import { type Config, type DisplayConfig, type HandoffSettings } from './core/config.ts';
|
|
4
4
|
import { type CreateResult } from './core/create.ts';
|
|
5
5
|
import { type DesktopDeps } from './core/desktop-app.ts';
|
|
@@ -426,10 +426,12 @@ export interface Runtime {
|
|
|
426
426
|
advisor(): Promise<AdvisorStatus>;
|
|
427
427
|
/**
|
|
428
428
|
* Sets `advisorModel` to `to` (`off` removes it) in every settings file that does not hold it yet, or only in the one
|
|
429
|
-
* `opts.account` uses, remembering how to undo it; a model also turns config `advisor.unlock` on.
|
|
429
|
+
* `opts.account` uses, remembering how to undo it; a model also turns config `advisor.unlock` on. With `opts.seen`
|
|
430
|
+
* (the files as a preview showed them), a file that no longer looks like that is not written.
|
|
430
431
|
*/
|
|
431
432
|
advisorSet(to: AdvisorChoice, opts?: {
|
|
432
433
|
account?: string;
|
|
434
|
+
seen?: readonly AdvisorSeen[];
|
|
433
435
|
}): Promise<AdvisorChange>;
|
|
434
436
|
/** Puts back what `advisorSet` replaced, only where the key still holds what it wrote. */
|
|
435
437
|
advisorUndo(): Promise<AdvisorChange>;
|
package/dist/src/runtime.js
CHANGED
|
@@ -1505,6 +1505,7 @@ export async function createRuntime(opts = {}) {
|
|
|
1505
1505
|
configFile: paths.configFile,
|
|
1506
1506
|
...advisorConfig(),
|
|
1507
1507
|
...(account ? { account } : {}),
|
|
1508
|
+
...(opts.seen ? { seen: opts.seen } : {}),
|
|
1508
1509
|
});
|
|
1509
1510
|
await reloadAdvisorConfig();
|
|
1510
1511
|
return r;
|
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` |
|
|
@@ -60,7 +60,7 @@ Use `sideby remote-control off --json`, `on --json` or `undo --json`. Exit 10 sh
|
|
|
60
60
|
|
|
61
61
|
Claude Code's Advisor lets a session consult a stronger model (Fable, Opus or Sonnet) at key moments. `/advisor` is hidden ("Unknown command: /advisor") until it is unlocked: sideby unlocks it in sessions it starts while config `advisor.unlock` is on.
|
|
62
62
|
|
|
63
|
-
`sideby advisor --json` returns `action: "status"`, `groups`, `unlock` and optional `envOff`. Each group has `file`, `accounts`, `state`, `undo`, optional `model`, `reason`, `betasOff` and `betasValue`. `state` is `fable`, `opus`, `sonnet`, `other` (another value; `model` holds it when it is a plain model id), `off` (`advisorModel` not set), `missing` (no settings.json: suggest `sideby doctor --fix`) or `blocked`. Only Claude subscription accounts appear; API accounts are left out. `betasOff: true` means that file's `env` sets `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` to a true value (`betasValue` is that value as JSON, such as `"1"`): it blocks the Advisor ("/advisor isn't available in this environment") even when unlocked. `envOff` names a variable in the user's own shell environment that hides the Advisor in every session, those sideby starts too: tell the user to remove it from their shell profile; sideby never overrides it. Top-level `apiBetasOff` is config `claude.apiBetasOff`: while it is true, sideby adds `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1` whenever it starts a Claude API account (never a subscription account; a value in the account's `proxy.env` or the environment wins). A group's `apiAccounts` lists the API accounts that share its file (they are not in `accounts`), and `undoApiBetas: true` means undo also turns that config back.
|
|
63
|
+
`sideby advisor --json` returns `action: "status"`, `groups`, `unlock` and optional `envOff`. Each group has `file`, `accounts`, `state`, `undo`, optional `model`, `reason`, `betasOff` and `betasValue`. `state` is `fable`, `opus`, `sonnet`, `other` (another value; `model` holds it when it is a plain model id), `off` (`advisorModel` not set), `missing` (no settings.json: suggest `sideby doctor --fix`) or `blocked`. Only Claude subscription accounts appear; API accounts are left out. `betasOff: true` means that file's `env` sets `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` to a true value (`betasValue` is that value as JSON, such as `"1"`): it blocks the Advisor ("/advisor isn't available in this environment") even when unlocked. `envOff` names a variable in the user's own shell environment that hides the Advisor in every session, those sideby starts too: tell the user to remove it from their shell profile; sideby never overrides it. Top-level `apiBetasOff` is config `claude.apiBetasOff`: while it is true, sideby adds `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1` whenever it starts a Claude API account (never a subscription account; a value in the account's `proxy.env` or the environment wins). A group's `apiAccounts` lists the API accounts that share its file (they are not in `accounts`), and `undoApiBetas: true` means undo also turns that config back. With `undo`, `undoModel` is the `advisorModel` value undo puts back (JSON, or `removed`; absent when the last change kept the model) and `undoBetas` the env value it puts back: name only these when you tell the user what undo changes.
|
|
64
64
|
|
|
65
65
|
Use `sideby advisor opus --json` (or `fable`, `sonnet`, `off`; `--account <ref>` for one account's file only), `sideby advisor undo --json` or `sideby advisor unlock on|off --json`. Exit 10 is a preview with `applied: false`: show each `groups` entry (the file, `advisorModel` from and to, its accounts), any `skipped` files, and, when `unlocks` is true, that sideby will also turn `advisor.unlock` on. When `removesBetas` is true, the preview also removes `env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` from the files with `betasOff` (only that entry; every other `env` entry stays): before the user agrees, tell them this also turns Claude Code's other experimental features back on, and that `undo` puts it back. When the preview has `apiAccounts`, those API accounts share a file that loses the variable, which their gateway may need (it stops `anthropic-beta` headers some gateways reject): with `apiBetasOn: true` the same change turns `claude.apiBetasOff` on (preview line `sideby config: claude.apiBetasOff false -> true`) so sideby gives them the variable at launch; without it, they already get it. Name those accounts to the user. An undo preview with `apiBetasBack: true` also turns the config back to its earlier value; if undo cannot (the config changed, or a file did not get the variable back), it stays on and the message names `sideby config set claude.apiBetasOff false`. Confirm, then rerun with `--yes`. A result has `applied`, `results` (`file`, `accounts`, `ok`, `message`), `unlocked`, `unlock`, `apiBetasOff` and `message`. Exit 1 with `applied: false` and a message means nothing to change (already that model and unlocked, nothing to undo, every file missing or blocked, no subscription account): tell the user, do not retry. `off` removes the key and never touches the env entry; `off` and `undo` leave `advisor.unlock` as it is; `sideby advisor unlock off` stops unlocking.
|
|
66
66
|
|
|
@@ -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
|
|