sideby 0.35.8 → 0.36.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.d.ts +12 -0
- package/dist/src/cli/commands.js +480 -6
- package/dist/src/cli/format.d.ts +12 -1
- package/dist/src/cli/format.js +23 -3
- package/dist/src/cli/json-schemas.js +166 -1
- package/dist/src/cli/main.js +18 -4
- package/dist/src/core/advisor.d.ts +176 -0
- package/dist/src/core/advisor.js +472 -0
- package/dist/src/core/after-install.js +11 -4
- package/dist/src/core/ask.d.ts +6 -1
- package/dist/src/core/ask.js +16 -5
- package/dist/src/core/browser-profiles.d.ts +16 -0
- package/dist/src/core/browser-profiles.js +45 -0
- package/dist/src/core/cli-commands.js +25 -1
- package/dist/src/core/config.d.ts +29 -0
- package/dist/src/core/config.js +25 -0
- package/dist/src/core/handoff-select.d.ts +13 -2
- package/dist/src/core/handoff-select.js +6 -2
- package/dist/src/core/launch.d.ts +4 -0
- package/dist/src/core/launch.js +7 -0
- package/dist/src/core/limit-reset.d.ts +198 -0
- package/dist/src/core/limit-reset.js +299 -0
- package/dist/src/core/local-build.d.ts +4 -3
- package/dist/src/core/local-build.js +6 -4
- package/dist/src/core/quota-fetch.d.ts +57 -2
- package/dist/src/core/quota-fetch.js +291 -13
- package/dist/src/core/quota-levels.d.ts +70 -0
- package/dist/src/core/quota-levels.js +80 -0
- package/dist/src/core/quota-store.d.ts +15 -1
- package/dist/src/core/quota-store.js +26 -1
- package/dist/src/core/same-login.d.ts +8 -0
- package/dist/src/core/same-login.js +39 -2
- package/dist/src/core/search-catalog.js +38 -0
- package/dist/src/families/claude/index.js +2 -0
- package/dist/src/families/codex/index.js +3 -1
- package/dist/src/families/codex/quota.d.ts +23 -1
- package/dist/src/families/codex/quota.js +122 -21
- package/dist/src/families/grok/quota-log.d.ts +1 -0
- package/dist/src/menubar/script.js +70 -18
- package/dist/src/menubar/snapshot.d.ts +33 -1
- package/dist/src/menubar/snapshot.js +79 -11
- package/dist/src/menubar/strings.d.ts +16 -0
- package/dist/src/menubar/strings.js +16 -0
- package/dist/src/panel/handler.d.ts +21 -0
- package/dist/src/panel/handler.js +111 -9
- package/dist/src/panel/i18n.d.ts +87 -0
- package/dist/src/panel/i18n.js +174 -0
- package/dist/src/panel/page-logic.d.ts +17 -0
- package/dist/src/panel/page-logic.js +23 -0
- package/dist/src/panel/page-script.js +440 -19
- package/dist/src/panel/page-styles.js +38 -2
- package/dist/src/plugins/loader.d.ts +2 -0
- package/dist/src/plugins/loader.js +27 -0
- package/dist/src/runtime.d.ts +63 -1
- package/dist/src/runtime.js +529 -9
- package/dist/src/types.d.ts +67 -0
- package/package.json +1 -1
- package/schemas/advisor.json +332 -0
- package/schemas/config.json +22 -0
- package/schemas/error.json +4 -0
- package/schemas/menubar-reset.json +93 -0
- package/schemas/menubar-snapshot.json +70 -2
- package/schemas/quota-reset.json +369 -0
- package/schemas/quota.json +30 -0
- package/schemas/update.json +4 -0
- package/skills/sideby/SKILL.md +6 -2
- package/skills/sideby/references/ai-tasks.md +1 -1
- package/skills/sideby/references/panel.md +14 -0
- package/skills/sideby/references/quota.md +27 -0
- package/skills/sideby/references/update.md +1 -1
package/dist/src/cli/format.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { windowLevel } from '../core/quota-levels.js';
|
|
1
|
+
import { quotaAge, windowLevel } from '../core/quota-levels.js';
|
|
2
2
|
import { MIN_CALLS } from '../core/tuning.js';
|
|
3
3
|
import { resetWhen } from '../panel/page-logic.js';
|
|
4
4
|
const useColor = () => !process.env.NO_COLOR && Boolean(process.stdout.isTTY);
|
|
@@ -103,11 +103,31 @@ export const QUOTA_REASON = {
|
|
|
103
103
|
'api-account': 'API account',
|
|
104
104
|
'fetch-failed': 'could not get it',
|
|
105
105
|
};
|
|
106
|
-
|
|
106
|
+
/** `1 reset available`, with when the next one expires where the Host told (ADR-0072); empty for none. */
|
|
107
|
+
export function limitResetsText(q, now) {
|
|
108
|
+
const r = q.status === 'ok' ? q.limitResets : undefined;
|
|
109
|
+
if (!r || r.available < 1)
|
|
110
|
+
return '';
|
|
111
|
+
const expires = r.nextExpiresAt ? `, next expires ${clock(r.nextExpiresAt, now)}` : '';
|
|
112
|
+
return `${r.available} ${r.available === 1 ? 'reset' : 'resets'} available${expires}`;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* One Account's Quota as a line. A window read at another time than the rest says so after its numbers, and numbers
|
|
116
|
+
* that count as old by the shared rule (`quotaAge`, ADR-0073) say so after the read time. `lastUseAt` is the newest
|
|
117
|
+
* use of the login on this computer; `resets: false` leaves the Limit Resets out (another row of the same login
|
|
118
|
+
* says them).
|
|
119
|
+
*/
|
|
120
|
+
export function quotaText(q, now, o = {}) {
|
|
107
121
|
if (q.status === 'unavailable')
|
|
108
122
|
return c.dim(QUOTA_REASON[q.reason] ?? q.reason);
|
|
109
123
|
const failed = q.fetchError ? c.yellow(' (latest check failed)') : '';
|
|
110
|
-
|
|
124
|
+
const old = !q.fetchError && quotaAge(q, now.getTime(), o.lastUseAt).stale ? c.yellow(' (may be out of date)') : '';
|
|
125
|
+
const windows = q.windows.map((w) => {
|
|
126
|
+
const own = w.observedAt && w.observedAt !== q.observedAt ? c.dim(` (read ${ago(w.observedAt, now)})`) : '';
|
|
127
|
+
return `${windowText(w, now)}${own}`;
|
|
128
|
+
});
|
|
129
|
+
const resets = o.resets === false ? '' : limitResetsText(q, now);
|
|
130
|
+
return `${windows.join(' ')} ${c.dim(ago(q.observedAt, now))}${failed}${old}${resets ? ` ${c.cyan(resets)}` : ''}`;
|
|
111
131
|
}
|
|
112
132
|
export function compactNumber(n) {
|
|
113
133
|
if (n < 1000)
|
|
@@ -201,6 +201,19 @@ const QuotaWindow = Type.Object({
|
|
|
201
201
|
windowMinutes: Type.Number(),
|
|
202
202
|
usedPercent: Type.Number(),
|
|
203
203
|
resetsAt: Str,
|
|
204
|
+
observedAt: Type.Optional(Type.String({
|
|
205
|
+
description: "When this window was read, when that is not the quota's `observedAt` (a newer reading did not cover it); left out, it is as old as the quota.",
|
|
206
|
+
})),
|
|
207
|
+
source: Type.Optional(Type.String({ description: "Where this window was read from, when that is not the quota's `source`." })),
|
|
208
|
+
});
|
|
209
|
+
const LimitResets = Type.Object({
|
|
210
|
+
available: Type.Number({ description: 'How many the account can use now; 0 when its Host says none.' }),
|
|
211
|
+
observedAt: Type.String({ description: 'When the count was read.' }),
|
|
212
|
+
nextExpiresAt: Type.Optional(Type.String({
|
|
213
|
+
description: 'When the next one to expire does; left out when that is not known for all of them.',
|
|
214
|
+
})),
|
|
215
|
+
}, {
|
|
216
|
+
description: "The Limit Resets the account holds: one-time credits from the vendor that restore quota before a window's own reset time (ADR-0072). Only from a Host that tells the count (Codex); left out when the Host cannot tell, which never means zero.",
|
|
204
217
|
});
|
|
205
218
|
const Quota = Type.Union([
|
|
206
219
|
Type.Object({
|
|
@@ -209,6 +222,7 @@ const Quota = Type.Union([
|
|
|
209
222
|
observedAt: Str,
|
|
210
223
|
source: Str,
|
|
211
224
|
plan: Type.Optional(Str),
|
|
225
|
+
limitResets: Type.Optional(LimitResets),
|
|
212
226
|
from: Type.Optional(Type.String({
|
|
213
227
|
description: 'The account this reading was taken from, when it is another account of the same login (spec §3.21); observedAt is its time.',
|
|
214
228
|
})),
|
|
@@ -436,7 +450,12 @@ const MenubarRow = Type.Object({
|
|
|
436
450
|
level: MenubarLevel,
|
|
437
451
|
recommended: Type.Boolean({ description: 'The account `sideby next` would pick in this Family.' }),
|
|
438
452
|
observedAt: Type.Union([Str, Type.Null()], { description: 'When the quota was observed, not checked.' }),
|
|
439
|
-
stale: Type.Boolean({
|
|
453
|
+
stale: Type.Boolean({
|
|
454
|
+
description: 'The quota is old, undated, or its last query failed; true when any window of the row is.',
|
|
455
|
+
}),
|
|
456
|
+
barsStale: Type.Optional(Type.Boolean({
|
|
457
|
+
description: "Whether the account's own bars are old, when that differs from `stale` (a model group under them was read at another time); left out, `stale` stands for them.",
|
|
458
|
+
})),
|
|
440
459
|
tip: Type.String({
|
|
441
460
|
description: "Hover text: when the numbers were read, each window's use and reset, and what a click does.",
|
|
442
461
|
}),
|
|
@@ -450,6 +469,9 @@ const MenubarRow = Type.Object({
|
|
|
450
469
|
reset: Str,
|
|
451
470
|
...ResetParts,
|
|
452
471
|
tip: Str,
|
|
472
|
+
stale: Type.Optional(Type.Boolean({
|
|
473
|
+
description: "This group's numbers are old by their own read time; left out, the row's `stale` stands for it.",
|
|
474
|
+
})),
|
|
453
475
|
})),
|
|
454
476
|
Type.Null(),
|
|
455
477
|
], {
|
|
@@ -468,6 +490,18 @@ const MenubarRow = Type.Object({
|
|
|
468
490
|
note: Type.String({
|
|
469
491
|
description: 'A no-quota explanation, or an old-reading warning beside the bars.',
|
|
470
492
|
}),
|
|
493
|
+
limitResets: Type.Optional(Type.String({
|
|
494
|
+
description: 'The Limit Resets the account holds, in words (`1 reset available`); left out for none or when the Host cannot tell.',
|
|
495
|
+
})),
|
|
496
|
+
useReset: Type.Optional(Type.Object({
|
|
497
|
+
title: Type.String({ description: 'The words of the line, such as `Use a reset…`.' }),
|
|
498
|
+
tip: Type.String({ description: 'Its hover text: which page a click opens.' }),
|
|
499
|
+
}, {
|
|
500
|
+
description: "A line under the account that leads to using a Limit Reset; a click runs `sideby menubar reset <account>`, which opens the Panel on that account's confirmation or the vendor's page and never uses one. Left out when nothing is offered.",
|
|
501
|
+
})),
|
|
502
|
+
age: Type.Optional(Type.String({
|
|
503
|
+
description: "How old the numbers are, in words (`read 25m ago`), once older than the Family's check interval or old; left out while they are current.",
|
|
504
|
+
})),
|
|
471
505
|
});
|
|
472
506
|
const MessageReceipt = Type.Object({
|
|
473
507
|
id: Type.String({
|
|
@@ -677,6 +711,82 @@ export const OUTPUT_SCHEMAS = {
|
|
|
677
711
|
results: Type.Optional(Type.Array(Type.Object({ file: Str, accounts: Type.Array(Str), ok: Type.Boolean(), message: Str }))),
|
|
678
712
|
message: Type.Optional(Str),
|
|
679
713
|
}, { title: 'sideby remote-control [off|undo] --json' }),
|
|
714
|
+
advisor: Type.Object({
|
|
715
|
+
schemaVersion: Version,
|
|
716
|
+
action: Type.Union([
|
|
717
|
+
Type.Literal('status'),
|
|
718
|
+
Type.Literal('set'),
|
|
719
|
+
Type.Literal('undo'),
|
|
720
|
+
Type.Literal('unlock'),
|
|
721
|
+
]),
|
|
722
|
+
to: Type.Optional(Type.Union([
|
|
723
|
+
Type.Literal('fable'),
|
|
724
|
+
Type.Literal('opus'),
|
|
725
|
+
Type.Literal('sonnet'),
|
|
726
|
+
Type.Literal('off'),
|
|
727
|
+
Type.Literal('on'),
|
|
728
|
+
], { description: 'For set: the model chosen, or off. For unlock: on or off.' })),
|
|
729
|
+
applied: Type.Optional(Type.Boolean({ description: 'True once the change was written (or undone).' })),
|
|
730
|
+
groups: Type.Optional(Type.Array(Type.Object({
|
|
731
|
+
file: Str,
|
|
732
|
+
accounts: Type.Array(Str, {
|
|
733
|
+
description: 'Claude subscription accounts whose settings.json is this file.',
|
|
734
|
+
}),
|
|
735
|
+
state: Type.Union([
|
|
736
|
+
Type.Literal('fable'),
|
|
737
|
+
Type.Literal('opus'),
|
|
738
|
+
Type.Literal('sonnet'),
|
|
739
|
+
Type.Literal('other'),
|
|
740
|
+
Type.Literal('off'),
|
|
741
|
+
Type.Literal('missing'),
|
|
742
|
+
Type.Literal('blocked'),
|
|
743
|
+
], {
|
|
744
|
+
description: 'fable, opus, sonnet: advisorModel names that model; other: another value (see model); off: not set or empty; missing: no settings.json; blocked: cannot be changed safely (see reason).',
|
|
745
|
+
}),
|
|
746
|
+
model: Type.Optional(Str),
|
|
747
|
+
betasOff: Type.Optional(Type.Literal(true, {
|
|
748
|
+
description: "The file's env sets CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS to a true value, which turns off Claude Code's experimental features, the advisor among them. Choosing a model removes it.",
|
|
749
|
+
})),
|
|
750
|
+
betasValue: Type.Optional(Type.String({ description: 'That value as JSON, such as "1"; only with betasOff.' })),
|
|
751
|
+
apiAccounts: Type.Optional(Type.Array(Str, {
|
|
752
|
+
description: 'Claude API accounts that use this same file. Where the variable is removed, config claude.apiBetasOff gives it to them at launch instead.',
|
|
753
|
+
})),
|
|
754
|
+
why: Type.Optional(Type.Union([Type.Literal('no-settings'), Type.Literal('broken-link'), Type.Literal('unsafe')])),
|
|
755
|
+
reason: Type.Optional(Str),
|
|
756
|
+
undo: Type.Boolean({ description: 'sideby changed it here and can put the earlier value back.' }),
|
|
757
|
+
undoApiBetas: Type.Optional(Type.Literal(true, {
|
|
758
|
+
description: 'With undo: that change turned config claude.apiBetasOff on for this file, and undo puts it back.',
|
|
759
|
+
})),
|
|
760
|
+
}), { description: 'For status, every file; for a preview, the files that would change.' })),
|
|
761
|
+
skipped: Type.Optional(Type.Array(Type.Object({ file: Str, accounts: Type.Array(Str), state: Str, reason: Type.Optional(Str) }), {
|
|
762
|
+
description: 'For a preview: files of the scope sideby cannot change (no settings.json, or unsafe).',
|
|
763
|
+
})),
|
|
764
|
+
unlock: Type.Optional(Type.Boolean({
|
|
765
|
+
description: 'Config advisor.unlock: sessions sideby starts for Claude subscription accounts get CLAUDE_CODE_ENABLE_EXPERIMENTAL_ADVISOR_TOOL=1.',
|
|
766
|
+
})),
|
|
767
|
+
unlocks: Type.Optional(Type.Boolean({ description: 'For a preview: the change also turns advisor.unlock on.' })),
|
|
768
|
+
removesBetas: Type.Optional(Type.Boolean({
|
|
769
|
+
description: 'For a preview of a model: the listed groups with betasOff also lose env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS in the same write.',
|
|
770
|
+
})),
|
|
771
|
+
unlocked: Type.Optional(Type.Boolean({ description: 'This change turned advisor.unlock on.' })),
|
|
772
|
+
apiBetasOff: Type.Optional(Type.Boolean({
|
|
773
|
+
description: 'Config claude.apiBetasOff: Claude API accounts sideby starts get CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 (a value in their proxy.env or the environment wins). After a change, its new value.',
|
|
774
|
+
})),
|
|
775
|
+
apiAccounts: Type.Optional(Type.Array(Str, {
|
|
776
|
+
description: 'For a preview of a model: API accounts whose settings file loses the variable; they keep it through claude.apiBetasOff.',
|
|
777
|
+
})),
|
|
778
|
+
apiBetasOn: Type.Optional(Type.Boolean({
|
|
779
|
+
description: 'For a preview of a model: the change also turns claude.apiBetasOff on.',
|
|
780
|
+
})),
|
|
781
|
+
apiBetasBack: Type.Optional(Type.Boolean({
|
|
782
|
+
description: 'For a preview of undo: claude.apiBetasOff also goes back to its earlier value.',
|
|
783
|
+
})),
|
|
784
|
+
envOff: Type.Optional(Type.String({
|
|
785
|
+
description: 'A variable in the environment that makes Claude Code hide the advisor.',
|
|
786
|
+
})),
|
|
787
|
+
results: Type.Optional(Type.Array(Type.Object({ file: Str, accounts: Type.Array(Str), ok: Type.Boolean(), message: Str }))),
|
|
788
|
+
message: Type.Optional(Str),
|
|
789
|
+
}, { title: 'sideby advisor [fable|opus|sonnet|off|undo|unlock on|off] --json' }),
|
|
680
790
|
model: Type.Object({
|
|
681
791
|
schemaVersion: Version,
|
|
682
792
|
account: Str,
|
|
@@ -775,6 +885,46 @@ export const OUTPUT_SCHEMAS = {
|
|
|
775
885
|
})),
|
|
776
886
|
}, { title: 'sideby next --json' }),
|
|
777
887
|
'quota-setup': Type.Object({ schemaVersion: Version, family: Str, applied: Type.Boolean(), plan: QuotaSetupPlan }, { title: 'sideby quota setup --json' }),
|
|
888
|
+
'quota-reset': Type.Object({
|
|
889
|
+
schemaVersion: Version,
|
|
890
|
+
account: Type.String({ description: 'The account the command named.' }),
|
|
891
|
+
confirmationRequired: Type.Optional(Type.Boolean({
|
|
892
|
+
description: 'Only without `--yes` (the plan; nothing was spent). True: show the plan to the user and, after a yes, run again with `--yes --operation <operationId>` (exit 10). False: it cannot be used now, see `blocked` (exit 1).',
|
|
893
|
+
})),
|
|
894
|
+
operationId: Type.Optional(Type.String({
|
|
895
|
+
description: 'The operation: in a plan, the one to confirm; in a result, the one that ran. One operation sends one idempotency key, however often it is retried.',
|
|
896
|
+
})),
|
|
897
|
+
via: Type.Optional(Type.String({
|
|
898
|
+
description: 'The account whose Host sends the request (the first signed-in one of the login).',
|
|
899
|
+
})),
|
|
900
|
+
sameLogin: Type.Optional(Type.Array(Str, {
|
|
901
|
+
description: 'The other accounts signed in as the same login; a limit reset applies to all of them.',
|
|
902
|
+
})),
|
|
903
|
+
unresolved: Type.Optional(Type.Literal(true, {
|
|
904
|
+
description: 'In a plan: an earlier attempt for this login got no final answer; confirming asks the Host again with that same request.',
|
|
905
|
+
})),
|
|
906
|
+
quota: Type.Optional(Quota),
|
|
907
|
+
limitResets: Type.Optional(LimitResets),
|
|
908
|
+
expectedAfter: Type.Optional(Type.Number({ description: 'In a plan: the count expected after one is used; not a promise.' })),
|
|
909
|
+
canUse: Type.Optional(Type.Boolean()),
|
|
910
|
+
blocked: Type.Optional(Type.String({ description: 'In a plan that cannot be confirmed: why, and what to do.' })),
|
|
911
|
+
outcome: Type.Optional(Type.Union(['reset', 'nothing-to-reset', 'none-left', 'already-done', 'open-vendor-page'].map((k) => Type.Literal(k)), {
|
|
912
|
+
description: 'With `--yes`: `reset` (one was used), `already-done` (this operation had already used one; nothing more was spent), `nothing-to-reset` or `none-left` (nothing was spent; exit 1). `open-vendor-page`: this Host cannot use one from the command line; `url` is the page where it is used (Claude Code).',
|
|
913
|
+
})),
|
|
914
|
+
resumed: Type.Optional(Type.Literal(true, { description: 'This run finished an earlier attempt with its own key.' })),
|
|
915
|
+
replayed: Type.Optional(Type.Literal(true, {
|
|
916
|
+
description: 'The outcome was already known for this operation; no request to use one was sent now. `quota` is read again when the kept numbers are from before the spend.',
|
|
917
|
+
})),
|
|
918
|
+
quotaPending: Type.Optional(Type.Literal(true, {
|
|
919
|
+
description: 'One was used, but the quota could not be read afterwards; the numbers on show are still old.',
|
|
920
|
+
})),
|
|
921
|
+
url: Type.Optional(Type.String({ description: "With `open-vendor-page`: the vendor's page." })),
|
|
922
|
+
opened: Type.Optional(Type.Boolean({ description: 'Whether `--open` opened the page.' })),
|
|
923
|
+
profile: Type.Optional(Type.Object({ dir: Str, name: Str }, { description: 'The browser user the page was opened in.' })),
|
|
924
|
+
identity: Type.Optional(Type.Object({ email: Str, org: Type.Optional(Str) }, { description: 'Who the account is signed in as; the page must be signed in as the same login.' })),
|
|
925
|
+
tight: Type.Optional(Type.Array(Type.Object({ label: Str, name: Type.Optional(Str), usedPercent: Type.Number(), resetsAt: Str }), { description: 'With `open-vendor-page`: the windows at their warning level now.' })),
|
|
926
|
+
message: Type.String({ description: 'What happened or what confirming does, in plain words.' }),
|
|
927
|
+
}, { title: 'sideby quota reset --json' }),
|
|
778
928
|
'handoff-status': Type.Object({
|
|
779
929
|
schemaVersion: Version,
|
|
780
930
|
overview: Type.Optional(Overview),
|
|
@@ -1447,6 +1597,9 @@ export const OUTPUT_SCHEMAS = {
|
|
|
1447
1597
|
skillUpdated: Type.Optional(Type.Boolean({
|
|
1448
1598
|
description: 'The skill was updated too (true) or that failed (false); absent when not tried.',
|
|
1449
1599
|
})),
|
|
1600
|
+
skillMessage: Type.Optional(Type.String({
|
|
1601
|
+
description: 'Set with `skillUpdated` after an Update: when it is false, why the skill update failed and what to run instead; when true, that the skill was updated.',
|
|
1602
|
+
})),
|
|
1450
1603
|
output: Type.Optional(Type.String({ description: 'What the failed install command printed.' })),
|
|
1451
1604
|
}, { title: 'sideby update --json' }),
|
|
1452
1605
|
error: Type.Object({
|
|
@@ -1458,6 +1611,9 @@ export const OUTPUT_SCHEMAS = {
|
|
|
1458
1611
|
reason: Type.Optional(Type.String({
|
|
1459
1612
|
description: 'Same as `code`, for a refused Task Spec (`sideby ask --spec -`): `spec-invalid`, `spec-too-large`, `bad-cwd`, or `spec-version` (exit 2: update sideby).',
|
|
1460
1613
|
})),
|
|
1614
|
+
operationId: Type.Optional(Type.String({
|
|
1615
|
+
description: 'Only from `sideby quota reset`: the operation this failure belongs to. With `code: outcome-unknown` the Host gave no final answer; run `sideby quota reset <account> --yes --operation <operationId>` to ask again with the same request, which cannot use a second limit reset. With `code: outcome-not-saved` the Host answered (`error` says what) but sideby could not record it; run the same command once the file `error` names can be written.',
|
|
1616
|
+
})),
|
|
1461
1617
|
}, { title: 'sideby error --json' }),
|
|
1462
1618
|
ask: Type.Object({
|
|
1463
1619
|
schemaVersion: Version,
|
|
@@ -1649,6 +1805,15 @@ export const OUTPUT_SCHEMAS = {
|
|
|
1649
1805
|
})),
|
|
1650
1806
|
detail: Type.Optional(Type.String({ description: 'What to do next, for a person.' })),
|
|
1651
1807
|
}),
|
|
1808
|
+
'menubar-reset': Type.Object({
|
|
1809
|
+
schemaVersion: Version,
|
|
1810
|
+
account: Str,
|
|
1811
|
+
url: Type.String({
|
|
1812
|
+
description: "The page that was opened: the Panel on this account's limit reset confirmation, or the vendor's page where a limit reset is used. Opening it uses nothing.",
|
|
1813
|
+
}),
|
|
1814
|
+
opened: Type.Boolean(),
|
|
1815
|
+
profile: Type.Optional(Type.String({ description: 'The Browser Profile it opened in, when not the default browser.' })),
|
|
1816
|
+
}),
|
|
1652
1817
|
'config-get': Type.Object({
|
|
1653
1818
|
schemaVersion: Version,
|
|
1654
1819
|
file: Type.Optional(Str),
|
package/dist/src/cli/main.js
CHANGED
|
@@ -255,6 +255,7 @@ in the npx cache or a temporary folder, a file that is not sideby's) or failed;
|
|
|
255
255
|
menubar: `sideby menubar [on|off] [--yes] [--json]
|
|
256
256
|
sideby menubar snapshot [--refresh] [--lang en|zh] [--json]
|
|
257
257
|
sideby menubar start <account> [--json]
|
|
258
|
+
sideby menubar reset <account> [--json]
|
|
258
259
|
sideby menubar hotkey [<keys>|off|default] [--json]
|
|
259
260
|
|
|
260
261
|
Show quota in the macOS menu bar: a gauge with one percent, how much the account sideby would pick next has used
|
|
@@ -264,7 +265,9 @@ icon. macOS only for now (a LaunchAgent, ~/Library/LaunchAgents/dev.sideby.menub
|
|
|
264
265
|
|
|
265
266
|
Without on or off it says whether it is on, off, out of date or blocked by a file that is not sideby's. on and off
|
|
266
267
|
show the file first; --yes does it. snapshot prints what the menu shows (the menu bar item runs it every 2 minutes).
|
|
267
|
-
start opens an account in your preferred terminal, as clicking it does.
|
|
268
|
+
start opens an account in your preferred terminal, as clicking it does. reset is what "Use a reset…" under an
|
|
269
|
+
account runs: it opens the panel on that account's confirmation (Codex) or the vendor's page (Claude Code), and
|
|
270
|
+
never uses a reset itself. hotkey shows or changes the shortcut that
|
|
268
271
|
opens the menu from anywhere (⌥X by default): opt, cmd or ctrl, any of shift, and one letter or digit; off turns
|
|
269
272
|
it off. A running menu bar item takes the new one within seconds, without a restart.
|
|
270
273
|
|
|
@@ -456,7 +459,7 @@ const COMMANDS = {
|
|
|
456
459
|
autostart: { flags: ['json', 'yes', 'refresh'] },
|
|
457
460
|
menubar: {
|
|
458
461
|
flags: ['json', 'yes', 'refresh', 'cached'],
|
|
459
|
-
valued: ['lang', 'hotkey', 'hotkey-label', 'icon', 'refreshing-since'],
|
|
462
|
+
valued: ['lang', 'hotkey', 'hotkey-label', 'icon', 'refreshing-since', 'ask'],
|
|
460
463
|
},
|
|
461
464
|
config: { flags: ['json', 'yes'] },
|
|
462
465
|
theme: { flags: ['json', 'yes', 'undo'], valued: ['id', 'out'] },
|
|
@@ -478,10 +481,11 @@ const COMMANDS = {
|
|
|
478
481
|
new: { flags: ['api', 'json', 'next'], valued: ['alias', 'vendor'] },
|
|
479
482
|
alias: { flags: ['json', 'yes'], valued: ['pick'] },
|
|
480
483
|
doctor: { flags: ['fix', 'force', 'json'] },
|
|
481
|
-
quota: { flags: ['json', 'yes', 'refresh'] },
|
|
484
|
+
quota: { flags: ['json', 'yes', 'refresh', 'open'], valued: ['operation'] },
|
|
482
485
|
tune: { flags: ['json', 'yes'] },
|
|
483
486
|
model: { flags: ['json', 'yes'], valued: ['effort'] },
|
|
484
487
|
'remote-control': { flags: ['json', 'yes'] },
|
|
488
|
+
advisor: { flags: ['json', 'yes'], valued: ['account'] },
|
|
485
489
|
handoff: {
|
|
486
490
|
flags: ['json', 'yes', 'same-family', 'no-same-family', 'other-ai', 'no-other-ai', 'api', 'no-api'],
|
|
487
491
|
valued: ['brief', 'to', 'order', 'ai-order', 'prepare-at', 'threshold', 'wait-minutes', 'countdown'],
|
|
@@ -710,7 +714,15 @@ export async function main(argv) {
|
|
|
710
714
|
if (wantsJson) {
|
|
711
715
|
const { UserError } = await import('../core/errors.js');
|
|
712
716
|
const code = usage ? 'usage' : err instanceof UserError && err.code ? err.code : 'error';
|
|
713
|
-
|
|
717
|
+
// A Limit Reset that got no final answer names its operation, so a retry reuses it (spec §3.40, ADR-0072).
|
|
718
|
+
const operationId = err?.operationId;
|
|
719
|
+
console.log(JSON.stringify({
|
|
720
|
+
schemaVersion: 1,
|
|
721
|
+
error: message,
|
|
722
|
+
code,
|
|
723
|
+
...(err instanceof UserError && typeof operationId === 'string' ? { operationId } : {}),
|
|
724
|
+
...(notice ? { _notice: notice } : {}),
|
|
725
|
+
}, null, 2));
|
|
714
726
|
}
|
|
715
727
|
else
|
|
716
728
|
console.error(`sideby: ${message}`);
|
|
@@ -764,6 +776,8 @@ async function dispatch(cmd, parsed, io, cmds) {
|
|
|
764
776
|
return await cmds.cmdModel(parsed, io);
|
|
765
777
|
case 'remote-control':
|
|
766
778
|
return await cmds.cmdRemoteControl(parsed, io);
|
|
779
|
+
case 'advisor':
|
|
780
|
+
return await cmds.cmdAdvisor(parsed, io);
|
|
767
781
|
case 'handoff':
|
|
768
782
|
return await cmds.cmdHandoff(parsed, io);
|
|
769
783
|
case 'ui':
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import type { Account, Env, ReadContext } from '../types.ts';
|
|
2
|
+
import { type KeyResult, type SettingsProblem } from './claude-settings-file.ts';
|
|
3
|
+
export declare const ADVISOR_KEY = "advisorModel";
|
|
4
|
+
/** The aliases Claude Code's `/advisor` takes, in the order the Panel and the CLI show them. */
|
|
5
|
+
export declare const ADVISOR_MODELS: readonly ['fable', 'opus', 'sonnet'];
|
|
6
|
+
export type AdvisorModel = (typeof ADVISOR_MODELS)[number];
|
|
7
|
+
export type AdvisorChoice = AdvisorModel | 'off';
|
|
8
|
+
export declare const ADVISOR_CHOICES: readonly AdvisorChoice[];
|
|
9
|
+
export declare const isAdvisorChoice: (v: unknown) => v is AdvisorChoice;
|
|
10
|
+
/** Set at launch while config `advisor.unlock` is on: Claude Code then offers the advisor without waiting for Anthropic's rollout. */
|
|
11
|
+
export declare const ADVISOR_UNLOCK_VAR = "CLAUDE_CODE_ENABLE_EXPERIMENTAL_ADVISOR_TOOL";
|
|
12
|
+
/**
|
|
13
|
+
* Turns off every experimental feature of Claude Code, the advisor among them, also with `ADVISOR_UNLOCK_VAR` set
|
|
14
|
+
* (tried with Claude Code 2.1.322 on 2026-11-13). Users often keep it in a settings file's `env`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const BETAS_VAR = "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS";
|
|
17
|
+
/** Variables that make Claude Code hide the advisor whatever else is set. sideby never changes them in the shell. */
|
|
18
|
+
export declare const ADVISOR_OFF_VARS: readonly ['CLAUDE_CODE_DISABLE_ADVISOR_TOOL', "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS"];
|
|
19
|
+
/**
|
|
20
|
+
* A model alias: the advisor asks that model; `other`: a value sideby does not offer (a full model id, kept in `model`
|
|
21
|
+
* when it looks like one); `off`: not set or empty; `missing`: the Account has no `settings.json`; `blocked`: see
|
|
22
|
+
* `reason`.
|
|
23
|
+
*/
|
|
24
|
+
export type AdvisorState = AdvisorModel | 'other' | 'off' | 'missing' | 'blocked';
|
|
25
|
+
export interface AdvisorGroup {
|
|
26
|
+
/** The real settings file (canonical); for `missing`, where it would be. */
|
|
27
|
+
file: string;
|
|
28
|
+
/** Refs of the subscription Accounts whose `settings.json` is `file`, in discovery order. */
|
|
29
|
+
accounts: string[];
|
|
30
|
+
state: AdvisorState;
|
|
31
|
+
/** For `other`: the model id the file names, when it is a plain model id (letters, digits, `.-_:@[]`). */
|
|
32
|
+
model?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The file's `env` sets `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` to a true value, so Claude Code turns off its
|
|
35
|
+
* experimental features there, the advisor among them. Choosing a model offers to remove it.
|
|
36
|
+
*/
|
|
37
|
+
betasOff?: true;
|
|
38
|
+
/** That value as JSON (`"1"`, `"true"`, …), for a preview; only with `betasOff`. */
|
|
39
|
+
betasValue?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Refs of the API Accounts that use this same file. Gateways often reject the headers experimental features send, so
|
|
42
|
+
* where the variable is removed for the advisor, config `claude.apiBetasOff` gives it to these at launch instead.
|
|
43
|
+
*/
|
|
44
|
+
apiAccounts?: string[];
|
|
45
|
+
/** For `blocked` and `missing`: why, as a code the Panel words in its language. */
|
|
46
|
+
why?: SettingsProblem;
|
|
47
|
+
/** For `blocked` and `missing`: why, and what to do. */
|
|
48
|
+
reason?: string;
|
|
49
|
+
/** sideby set it here and can put the earlier value back. */
|
|
50
|
+
undo: boolean;
|
|
51
|
+
/** With `undo`: the change turned config `claude.apiBetasOff` on for this file's API Accounts, and undo turns it back. */
|
|
52
|
+
undoApiBetas?: true;
|
|
53
|
+
}
|
|
54
|
+
export interface AdvisorStatus {
|
|
55
|
+
groups: AdvisorGroup[];
|
|
56
|
+
/** Config `advisor.unlock`: sessions sideby starts get `CLAUDE_CODE_ENABLE_EXPERIMENTAL_ADVISOR_TOOL=1`. */
|
|
57
|
+
unlock: boolean;
|
|
58
|
+
/** Config `claude.apiBetasOff`: Claude API Accounts sideby starts get `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`. */
|
|
59
|
+
apiBetasOff: boolean;
|
|
60
|
+
/** The variable in sideby's own environment that makes Claude Code hide the advisor, when one is set. */
|
|
61
|
+
envOff?: string;
|
|
62
|
+
}
|
|
63
|
+
/** The two sideby settings a change reads: config `advisor.unlock` and config `claude.apiBetasOff`. */
|
|
64
|
+
export interface AdvisorConfigState {
|
|
65
|
+
unlock: boolean;
|
|
66
|
+
apiBetasOff: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface AdvisorChange {
|
|
69
|
+
ok: boolean;
|
|
70
|
+
/** One line per group that was meant to change. */
|
|
71
|
+
results: KeyResult[];
|
|
72
|
+
/** This change turned config `advisor.unlock` on. */
|
|
73
|
+
unlocked: boolean;
|
|
74
|
+
/** This change set config `claude.apiBetasOff` to this value (on with a change, back off with an undo). */
|
|
75
|
+
apiBetas?: boolean;
|
|
76
|
+
message: string;
|
|
77
|
+
}
|
|
78
|
+
/** The first variable of `ADVISOR_OFF_VARS` that `env` sets to a true value, or undefined. */
|
|
79
|
+
export declare function advisorOffVar(env: Env): string | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Unlocks the advisor in `env` for a Claude subscription Account's Launch: sets `ADVISOR_UNLOCK_VAR` unless the
|
|
82
|
+
* environment already sets it or one of `ADVISOR_OFF_VARS`. Returns whether it set it.
|
|
83
|
+
*/
|
|
84
|
+
export declare function unlockAdvisorEnv(env: Env, familyId: string, account: Pick<Account, 'kind'>): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Config `claude.apiBetasOff` at a Claude API Account's Launch: sets `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1` unless
|
|
87
|
+
* the environment already sets it. Runs before the Account's Secret File is read, so `proxy.env` still decides.
|
|
88
|
+
* Returns whether it set it.
|
|
89
|
+
*/
|
|
90
|
+
export declare function apiBetasEnv(env: Env, familyId: string, account: Pick<Account, 'kind'>): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Every Claude subscription Account's advisor, grouped by the file it lives in, with the API Accounts that share each
|
|
93
|
+
* file. Writes nothing. A file only API Accounts use is left out: the advisor needs a Claude login.
|
|
94
|
+
*/
|
|
95
|
+
export declare function advisorGroups(accounts: readonly Account[], ctx: ReadContext): Promise<AdvisorGroup[]>;
|
|
96
|
+
/**
|
|
97
|
+
* The groups, the two sideby settings and any variable in sideby's own environment that hides the advisor. Writes
|
|
98
|
+
* nothing.
|
|
99
|
+
*/
|
|
100
|
+
export declare function advisorStatus(accounts: readonly Account[], ctx: ReadContext, cfg: AdvisorConfigState): Promise<AdvisorStatus>;
|
|
101
|
+
/** `account` when the advisor can be set for it; else a UserError that says what to do. */
|
|
102
|
+
export declare function checkAdvisorAccount(account: Account): Account;
|
|
103
|
+
/** The groups `account` (a ref) uses, or every group without one. */
|
|
104
|
+
export declare function advisorScope<G extends {
|
|
105
|
+
accounts: readonly string[];
|
|
106
|
+
}>(groups: readonly G[], account?: string): G[];
|
|
107
|
+
/**
|
|
108
|
+
* What choosing `to` changes, the one rule for the CLI, the Panel's server and its page: `todo`, the groups sideby can
|
|
109
|
+
* write that do not hold `to` yet or, for a model, whose `env` turns experimental features off (also when they already
|
|
110
|
+
* name it); `unlocks`, whether config `advisor.unlock` turns on (a model, while it is off, when some group has or gets
|
|
111
|
+
* that model); and `apiBetas`, whether config `claude.apiBetasOff` turns on (while it is off, when the variable leaves
|
|
112
|
+
* a file that API Accounts also use, so they keep it). Choosing the model the files already name is still a change
|
|
113
|
+
* while either is set. Self-contained, so the Panel page runs this same function (page-script.ts).
|
|
114
|
+
*/
|
|
115
|
+
export declare function advisorPending<G extends {
|
|
116
|
+
state: string;
|
|
117
|
+
betasOff?: boolean;
|
|
118
|
+
apiAccounts?: readonly string[];
|
|
119
|
+
}>(groups: readonly G[], to: string, cfg: {
|
|
120
|
+
unlock: boolean;
|
|
121
|
+
apiBetasOff: boolean;
|
|
122
|
+
}): {
|
|
123
|
+
todo: G[];
|
|
124
|
+
unlocks: boolean;
|
|
125
|
+
apiBetas: boolean;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* What choosing `to` would do in `scope` (`advisorPending`), with the groups whose
|
|
129
|
+
* `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` is removed with it, the API Accounts that use those files, and the groups
|
|
130
|
+
* sideby cannot change. Nothing to do when there are no groups to write and no unlock.
|
|
131
|
+
*/
|
|
132
|
+
export declare function advisorPlan<G extends {
|
|
133
|
+
state: string;
|
|
134
|
+
betasOff?: boolean;
|
|
135
|
+
apiAccounts?: readonly string[];
|
|
136
|
+
}>(scope: readonly G[], to: AdvisorChoice, cfg: AdvisorConfigState): {
|
|
137
|
+
todo: G[];
|
|
138
|
+
betas: G[];
|
|
139
|
+
apiAccounts: string[];
|
|
140
|
+
skipped: G[];
|
|
141
|
+
unlock: boolean;
|
|
142
|
+
apiBetas: boolean;
|
|
143
|
+
};
|
|
144
|
+
/** What a change says when there is nothing to do: always `ok: false`, so the CLI exits 1. */
|
|
145
|
+
export declare function advisorNothingToDo(action: AdvisorChoice | 'undo', scope: readonly AdvisorGroup[]): AdvisorChange;
|
|
146
|
+
/**
|
|
147
|
+
* Sets `advisorModel` to `to` (`off` removes the key) in every group of the scope that does not hold it yet, and for a
|
|
148
|
+
* model removes a true `env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS`, remembering how to undo it. Where that file also
|
|
149
|
+
* serves API Accounts, config `claude.apiBetasOff` turns on first, so they never start without the variable. A model
|
|
150
|
+
* also turns config `advisor.unlock` on when it is off, once a file was written or none needed it.
|
|
151
|
+
*/
|
|
152
|
+
export declare function setAdvisor(accounts: readonly Account[], ctx: ReadContext, to: AdvisorChoice, opts: AdvisorConfigState & {
|
|
153
|
+
configFile: string;
|
|
154
|
+
account?: string;
|
|
155
|
+
}): Promise<AdvisorChange>;
|
|
156
|
+
/** Groups sideby can put back: it wrote there and the key still holds what it wrote. */
|
|
157
|
+
export declare function advisorGroupsToUndo(groups: readonly AdvisorGroup[]): AdvisorGroup[];
|
|
158
|
+
/**
|
|
159
|
+
* Puts back what each file had before the last change, each entry at its old place, only while `advisorModel` still
|
|
160
|
+
* holds what sideby wrote; a removed `env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` comes back only while it is still
|
|
161
|
+
* absent. Then config `claude.apiBetasOff` goes back to its earlier value, when that change turned it on, it still
|
|
162
|
+
* holds `true` and no file the API Accounts use still lacks the variable because of sideby. Leaves config
|
|
163
|
+
* `advisor.unlock` as it is.
|
|
164
|
+
*/
|
|
165
|
+
export declare function undoAdvisor(accounts: readonly Account[], ctx: ReadContext, opts: AdvisorConfigState & {
|
|
166
|
+
configFile: string;
|
|
167
|
+
}): Promise<AdvisorChange>;
|
|
168
|
+
/**
|
|
169
|
+
* Turns config `advisor.unlock` on or off. Off removes the key (and the section once it is empty). `ok: false` when it
|
|
170
|
+
* already was, so the CLI exits 1.
|
|
171
|
+
*/
|
|
172
|
+
export declare function setAdvisorUnlock(configFile: string, on: boolean): Promise<{
|
|
173
|
+
ok: boolean;
|
|
174
|
+
unlock: boolean;
|
|
175
|
+
message: string;
|
|
176
|
+
}>;
|