sideby 0.21.0 → 0.23.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/README.md +1 -0
- package/ai-tasks.json +14 -0
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.d.ts +7 -0
- package/dist/src/cli/commands.js +441 -31
- package/dist/src/cli/format.js +3 -2
- package/dist/src/cli/json-schemas.js +157 -47
- package/dist/src/cli/main.js +38 -7
- package/dist/src/core/accounts.d.ts +6 -1
- package/dist/src/core/accounts.js +16 -3
- package/dist/src/core/ask.d.ts +2 -1
- package/dist/src/core/ask.js +12 -4
- package/dist/src/core/claude-settings-file.d.ts +57 -0
- package/dist/src/core/claude-settings-file.js +104 -2
- package/dist/src/core/config.d.ts +34 -16
- package/dist/src/core/config.js +58 -5
- package/dist/src/core/create.js +4 -1
- package/dist/src/core/desktop-app.js +5 -1
- package/dist/src/core/handoff-overview.d.ts +4 -1
- package/dist/src/core/handoff-overview.js +3 -2
- package/dist/src/core/handoff-rules.d.ts +34 -0
- package/dist/src/core/handoff-rules.js +115 -0
- package/dist/src/core/handoff-select.js +45 -28
- package/dist/src/core/handoff-status.d.ts +37 -7
- package/dist/src/core/handoff-status.js +95 -19
- package/dist/src/core/handoff.d.ts +4 -1
- package/dist/src/core/handoff.js +8 -5
- package/dist/src/core/inbound.d.ts +11 -3
- package/dist/src/core/inbound.js +26 -74
- package/dist/src/core/launch.js +6 -4
- package/dist/src/core/quota-levels.d.ts +13 -2
- package/dist/src/core/quota-levels.js +21 -3
- package/dist/src/core/remote-control.d.ts +10 -12
- package/dist/src/core/remote-control.js +29 -86
- package/dist/src/core/themes.d.ts +107 -0
- package/dist/src/core/themes.js +463 -0
- package/dist/src/core/tuning-apply.js +12 -20
- package/dist/src/families/agy/index.d.ts +8 -0
- package/dist/src/families/agy/index.js +53 -0
- package/dist/src/families/agy/quota.d.ts +9 -0
- package/dist/src/families/agy/quota.js +110 -0
- package/dist/src/families/index.js +7 -0
- package/dist/src/families/logos.d.ts +10 -0
- package/dist/src/families/logos.js +12 -1
- package/dist/src/menubar/script.js +26 -3
- package/dist/src/menubar/snapshot.d.ts +33 -6
- package/dist/src/menubar/snapshot.js +138 -43
- package/dist/src/menubar/strings.d.ts +18 -2
- package/dist/src/menubar/strings.js +18 -2
- package/dist/src/panel/handler.d.ts +4 -1
- package/dist/src/panel/handler.js +206 -46
- package/dist/src/panel/i18n.d.ts +106 -7
- package/dist/src/panel/i18n.js +260 -62
- package/dist/src/panel/page-logic.d.ts +67 -20
- package/dist/src/panel/page-logic.js +74 -7
- package/dist/src/panel/page-script.js +522 -124
- package/dist/src/panel/page-styles.d.ts +2 -0
- package/dist/src/panel/page-styles.js +157 -34
- package/dist/src/panel/page.js +3 -3
- package/dist/src/panel/theme.d.ts +6 -1
- package/dist/src/panel/theme.js +4 -0
- package/dist/src/panel/themes.d.ts +14 -0
- package/dist/src/panel/themes.js +162 -0
- package/dist/src/plugins/check.js +27 -13
- package/dist/src/plugins/loader.d.ts +11 -0
- package/dist/src/plugins/loader.js +47 -1
- package/dist/src/runtime.d.ts +9 -2
- package/dist/src/runtime.js +12 -5
- package/dist/src/types.d.ts +35 -5
- package/package.json +2 -2
- package/schemas/config.json +45 -2
- package/schemas/families.json +13 -5
- package/schemas/handoff-disable.json +22 -0
- package/schemas/handoff-enable.json +22 -0
- package/schemas/handoff-rules.json +302 -0
- package/schemas/handoff-status.json +26 -0
- package/schemas/hide.json +157 -0
- package/schemas/list.json +15 -0
- package/schemas/menubar-snapshot.json +309 -2
- package/schemas/order.json +26 -1
- package/schemas/pin.json +17 -0
- package/schemas/theme-check.json +140 -0
- package/schemas/theme-export.json +86 -0
- package/schemas/theme-import.json +92 -0
- package/schemas/theme-preview.json +86 -0
- package/schemas/theme-remove.json +87 -0
- package/schemas/theme-use.json +88 -0
- package/schemas/theme.json +137 -0
- package/schemas/unhide.json +157 -0
- package/schemas/unpin.json +17 -0
- package/skills/sideby/SKILL.md +5 -2
- package/skills/sideby/references/accounts.md +1 -0
- package/skills/sideby/references/ai-tasks.md +1 -1
- package/skills/sideby/references/handoff.md +7 -3
- package/skills/sideby/references/panel.md +9 -0
- package/skills/sideby/references/quota.md +3 -1
- package/skills/sideby/references/themes.md +47 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Asks Antigravity CLI for the Main Account's Quota (spec §3.26, ADR-0048): `agy -p /usage --output-format json` runs
|
|
2
|
+
// the `/usage` command with agy's own sign-in and starts no model turn (`num_turns` 0, every token count 0; tried with
|
|
3
|
+
// agy 1.4.4 on 2026-10-21). sideby never reads the sign-in and sends no request of its own.
|
|
4
|
+
import { spawn } from 'node:child_process';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
export const AGY_QUOTA_ARGS = ['-p', '/usage', '--output-format', 'json'];
|
|
7
|
+
/** agy answers in about 6 s; anything far larger than its answer is not one. */
|
|
8
|
+
const MAX_OUTPUT = 256 * 1024;
|
|
9
|
+
const failed = (detail) => ({ status: 'unavailable', reason: 'fetch-failed', detail });
|
|
10
|
+
const WINDOWS = {
|
|
11
|
+
'5h': { label: '5h', minutes: 300 },
|
|
12
|
+
weekly: { label: '7d', minutes: 7 * 24 * 60 },
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The Quota in agy's JSON answer: one window per bucket, named after its model group, since each limit covers only
|
|
16
|
+
* that group's models. Only group names, windows, percentages and reset times are kept.
|
|
17
|
+
*/
|
|
18
|
+
export function agyQuota(answer, observedAt) {
|
|
19
|
+
if (typeof answer !== 'object' || answer === null)
|
|
20
|
+
return null;
|
|
21
|
+
const a = answer;
|
|
22
|
+
if (a.status !== 'SUCCESS')
|
|
23
|
+
return null;
|
|
24
|
+
const groups = a.command?.data?.groups;
|
|
25
|
+
if (!Array.isArray(groups))
|
|
26
|
+
return null;
|
|
27
|
+
const windows = [];
|
|
28
|
+
for (const g of groups) {
|
|
29
|
+
const name = typeof g?.name === 'string' ? g.name.slice(0, 60) : undefined;
|
|
30
|
+
if (!name || !Array.isArray(g.buckets))
|
|
31
|
+
continue;
|
|
32
|
+
for (const b of g.buckets) {
|
|
33
|
+
const w = WINDOWS[b?.window];
|
|
34
|
+
const left = b?.remaining_fraction;
|
|
35
|
+
if (!w || typeof left !== 'number' || !Number.isFinite(left))
|
|
36
|
+
continue;
|
|
37
|
+
const resets = typeof b.reset_time === 'string' ? Date.parse(b.reset_time) : Number.NaN;
|
|
38
|
+
if (!Number.isFinite(resets))
|
|
39
|
+
continue;
|
|
40
|
+
windows.push({
|
|
41
|
+
label: w.label,
|
|
42
|
+
name,
|
|
43
|
+
windowMinutes: w.minutes,
|
|
44
|
+
usedPercent: Math.round(Math.min(1, Math.max(0, 1 - left)) * 100),
|
|
45
|
+
resetsAt: new Date(resets).toISOString(),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return windows.length ? { status: 'ok', windows, observedAt, source: 'agy /usage' } : null;
|
|
50
|
+
}
|
|
51
|
+
/** Why agy's answer gave no Quota, and what to do. agy's own words are only matched, never repeated. */
|
|
52
|
+
function errorDetail(account, answer) {
|
|
53
|
+
const { status, error } = (answer ?? {});
|
|
54
|
+
if (status === 'SUCCESS')
|
|
55
|
+
return 'Antigravity CLI answered in a form sideby does not recognise; update sideby';
|
|
56
|
+
if (typeof error === 'string' && /auth/i.test(error))
|
|
57
|
+
return `Antigravity CLI is not signed in; run \`sideby login ${account.ref}\` and sign in with Google`;
|
|
58
|
+
return 'Antigravity CLI could not report the quota; sideby asks again later, or start agy once';
|
|
59
|
+
}
|
|
60
|
+
export async function fetchAgyQuota(account, ctx) {
|
|
61
|
+
if (ctx.signal.aborted)
|
|
62
|
+
return failed('the quota check was stopped');
|
|
63
|
+
const child = spawn('agy', [...AGY_QUOTA_ARGS], {
|
|
64
|
+
cwd: tmpdir(),
|
|
65
|
+
env: ctx.hostEnv,
|
|
66
|
+
// stderr holds a sign-in link when signed out: never read.
|
|
67
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
68
|
+
});
|
|
69
|
+
const stop = () => {
|
|
70
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
71
|
+
child.kill('SIGTERM');
|
|
72
|
+
};
|
|
73
|
+
ctx.signal.addEventListener('abort', stop, { once: true });
|
|
74
|
+
try {
|
|
75
|
+
return await new Promise((resolve) => {
|
|
76
|
+
const chunks = [];
|
|
77
|
+
let size = 0;
|
|
78
|
+
child.stdout.on('data', (b) => {
|
|
79
|
+
size += b.length;
|
|
80
|
+
if (size > MAX_OUTPUT)
|
|
81
|
+
return stop();
|
|
82
|
+
chunks.push(b);
|
|
83
|
+
});
|
|
84
|
+
child.on('error', (err) => resolve(failed(err.code === 'ENOENT'
|
|
85
|
+
? 'Antigravity CLI is not installed or not on PATH; install it, then refresh'
|
|
86
|
+
: `could not start Antigravity CLI (${err.code ?? 'error'})`)));
|
|
87
|
+
child.on('close', () => {
|
|
88
|
+
if (ctx.signal.aborted)
|
|
89
|
+
return resolve(failed('the quota check was stopped'));
|
|
90
|
+
let answer;
|
|
91
|
+
try {
|
|
92
|
+
answer = JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return resolve(failed('Antigravity CLI exited without answering; sideby asks again later'));
|
|
96
|
+
}
|
|
97
|
+
resolve(agyQuota(answer, ctx.now.toISOString()) ?? failed(errorDetail(account, answer)));
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
ctx.signal.removeEventListener('abort', stop);
|
|
103
|
+
stop();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export const agyQuotaFetch = {
|
|
107
|
+
everyMinutes: 15,
|
|
108
|
+
summary: 'Antigravity CLI asks Google for its quota, at most every 15 minutes',
|
|
109
|
+
fetch: fetchAgyQuota,
|
|
110
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { packageVersion } from '../core/version.js';
|
|
2
2
|
import { accountScript } from '../plugins/account-script.js';
|
|
3
|
+
import { agyPlugin } from './agy/index.js';
|
|
3
4
|
import { claudePlugin } from './claude/index.js';
|
|
4
5
|
import { codexPlugin } from './codex/index.js';
|
|
5
6
|
import { grokPlugin } from './grok/index.js';
|
|
@@ -31,6 +32,12 @@ export const BUILTIN_PLUGINS = [
|
|
|
31
32
|
description: 'pi family (~/.pi/agent, PI_CODING_AGENT_DIR)',
|
|
32
33
|
defaultEnabled: true,
|
|
33
34
|
},
|
|
35
|
+
{
|
|
36
|
+
plugin: agyPlugin,
|
|
37
|
+
version: VERSION,
|
|
38
|
+
description: 'Antigravity CLI family (~/.gemini/antigravity-cli, main account only)',
|
|
39
|
+
defaultEnabled: true,
|
|
40
|
+
},
|
|
34
41
|
{
|
|
35
42
|
plugin: accountScript,
|
|
36
43
|
version: VERSION,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Built-in Family marks for the Panel (FamilyDef.logo): 24x24 single-path SVG icons, drawn inline because the page CSP
|
|
2
2
|
// allows no external images.
|
|
3
3
|
// Sources: Claude, OpenAI and pi from Simple Icons (CC0 1.0, https://simpleicons.org; OpenAI from v15.0.0, the last release
|
|
4
|
-
// that ships it; pi is the mark from https://pi.dev). Grok from LobeHub Icons (MIT, Copyright (c) 2023 LobeHub,
|
|
4
|
+
// that ships it; pi is the mark from https://pi.dev). Grok and Antigravity (v1.95.1) from LobeHub Icons (MIT, Copyright (c) 2023 LobeHub,
|
|
5
5
|
// https://github.com/lobehub/lobe-icons). The marks are trademarks of their owners and only identify each Host.
|
|
6
6
|
/** Logos of the built-in Families, by Family id; each Family sets its own as `logo`. */
|
|
7
7
|
export const BUILTIN_LOGOS = {
|
|
@@ -23,4 +23,15 @@ export const BUILTIN_LOGOS = {
|
|
|
23
23
|
title: 'pi',
|
|
24
24
|
path: 'M0 0v24h6v-6h6v-6H6V6h6v6h6V0Zm18 12v12h6V12Z',
|
|
25
25
|
},
|
|
26
|
+
agy: {
|
|
27
|
+
title: 'Antigravity',
|
|
28
|
+
// The mark is a blue base with green, yellow and red washing in from the top, as in LobeHub's colour version.
|
|
29
|
+
color: '#3186FF',
|
|
30
|
+
gradients: [
|
|
31
|
+
{ from: [4, 8], to: [10, 15], color: '#00B95C' },
|
|
32
|
+
{ from: [8, 2], to: [12, 8], color: '#FFE432' },
|
|
33
|
+
{ from: [18, 2], to: [14, 10], color: '#FC413D' },
|
|
34
|
+
],
|
|
35
|
+
path: 'M21.751 22.607c1.34 1.005 3.35.335 1.508-1.508C17.73 15.74 18.904 1 12.037 1 5.17 1 6.342 15.74.815 21.1c-2.01 2.009.167 2.511 1.507 1.506 5.192-3.517 4.857-9.714 9.715-9.714 4.857 0 4.522 6.197 9.714 9.715z',
|
|
36
|
+
},
|
|
26
37
|
};
|
|
@@ -267,10 +267,21 @@ function run(argv) {
|
|
|
267
267
|
// headers cannot be clicked, and macOS greys a template image on an item that cannot be clicked.
|
|
268
268
|
var rule = logo.fillRule ? ' fill-rule="' + logo.fillRule + '"' : '';
|
|
269
269
|
var fill = /^#[0-9a-f]{3,8}$/i.test(logo.color || '') ? logo.color : dark() ? '#f5f5f7' : '#1d1d1f';
|
|
270
|
-
|
|
270
|
+
// A multicoloured mark: the shape again per wash, each filled with a gradient that fades out. Only numbers and
|
|
271
|
+
// hex colours reach the markup.
|
|
272
|
+
var defs = '', washes = '';
|
|
273
|
+
(logo.gradients || []).forEach(function (g, i) {
|
|
274
|
+
var n = [g.from[0], g.from[1], g.to[0], g.to[1]].map(Number);
|
|
275
|
+
if (!n.every(isFinite) || !/^#[0-9a-f]{3,8}$/i.test(g.color || '')) return;
|
|
276
|
+
defs += '<linearGradient id="w' + i + '" gradientUnits="userSpaceOnUse" x1="' + n[0] + '" y1="' + n[1] + '" x2="' + n[2] + '" y2="' + n[3] + '"><stop offset="0" stop-color="' + g.color + '"/><stop offset="1" stop-color="' + g.color + '" stop-opacity="0"/></linearGradient>';
|
|
277
|
+
washes += '<path' + rule + ' fill="url(#w' + i + ')" d="' + logo.path + '"/>';
|
|
278
|
+
});
|
|
279
|
+
return svgImage('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14">' + (defs ? '<defs>' + defs + '</defs>' : '') + '<path' + rule + ' fill="' + fill + '" d="' + logo.path + '"/>' + washes + '</svg>', 14, false);
|
|
271
280
|
}
|
|
272
281
|
|
|
273
282
|
var GUTTER = $.NSImage.alloc.initWithSize($.NSMakeSize(14, 14));
|
|
283
|
+
// Model group lines sit a little in from their account's name.
|
|
284
|
+
var GROUP_INDENT = '\u2003';
|
|
274
285
|
// Where a menu item draws its image and its title (macOS 26 and 27), for the header views that line up with them.
|
|
275
286
|
var HEAD_X = 15, HEAD_TEXT_X = 34;
|
|
276
287
|
|
|
@@ -308,7 +319,10 @@ function run(argv) {
|
|
|
308
319
|
sections.forEach(function (s) {
|
|
309
320
|
nameW = Math.max(nameW, width(s.title, L.head));
|
|
310
321
|
if (s.columns[0]) first = true;
|
|
311
|
-
s.rows.concat(s.more ? s.more.rows : []).forEach(function (r) {
|
|
322
|
+
s.rows.concat(s.more ? s.more.rows : []).forEach(function (r) {
|
|
323
|
+
nameW = Math.max(nameW, width(r.label, L.font));
|
|
324
|
+
(r.groups || []).forEach(function (g) { nameW = Math.max(nameW, width(GROUP_INDENT + g.label, L.font)); });
|
|
325
|
+
});
|
|
312
326
|
});
|
|
313
327
|
var pctW = width('100%', L.mono), x = Math.ceil(nameW) + 20, stops = [], at = [];
|
|
314
328
|
function tab(pos) { stops.push($.NSTextTab.alloc.initWithTextAlignmentLocationOptions($.NSTextAlignmentLeft, pos, $())); }
|
|
@@ -365,6 +379,15 @@ function run(argv) {
|
|
|
365
379
|
mi.attributedTitle = t;
|
|
366
380
|
}
|
|
367
381
|
}
|
|
382
|
+
// A Host that gives each model group its own limits: a line per group under the account, with that group's bars.
|
|
383
|
+
// Clicking one starts the same account.
|
|
384
|
+
(r.groups || []).forEach(function (g) {
|
|
385
|
+
refs.push(r.ref);
|
|
386
|
+
var gi = add(menu, g.label, 'start:', refs.length);
|
|
387
|
+
gi.attributedTitle = rowTitle({ label: GROUP_INDENT + g.label, bars: g.bars, reset: g.reset, stale: r.stale, note: g.reset }, L);
|
|
388
|
+
gi.image = GUTTER;
|
|
389
|
+
gi.toolTip = g.tip;
|
|
390
|
+
});
|
|
368
391
|
return mi;
|
|
369
392
|
}
|
|
370
393
|
// A tool's header: its mark, its name, and the window names over the bar columns. A view, not a title: macOS dims
|
|
@@ -375,7 +398,7 @@ function run(argv) {
|
|
|
375
398
|
line.appendAttributedString(str(s.title, attrs($.NSColor.labelColor, L.head, L.headPara)));
|
|
376
399
|
var cols = L.first ? s.columns : [s.columns[1]];
|
|
377
400
|
cols.forEach(function (c) { line.appendAttributedString(str('\t' + (c || ''), attrs($.NSColor.secondaryLabelColor, L.small, L.headPara))); });
|
|
378
|
-
if (s.rows.some(function (r) { return r.reset; }))
|
|
401
|
+
if (s.rows.some(function (r) { return r.reset || (r.groups || []).some(function (g) { return g.reset; }); }))
|
|
379
402
|
line.appendAttributedString(str('\t' + snap.labels.resetsHeader, attrs($.NSColor.secondaryLabelColor, L.small, L.headPara)));
|
|
380
403
|
var W = Math.max(280, L.width), H = 24;
|
|
381
404
|
var v = $.NSView.alloc.initWithFrame($.NSMakeRect(0, 0, W, H));
|
|
@@ -20,13 +20,23 @@ export interface MenubarRow {
|
|
|
20
20
|
observedAt: string | null;
|
|
21
21
|
/** An old or undated reading, or a failed quota query. */
|
|
22
22
|
stale: boolean;
|
|
23
|
-
/** Hover text: when each window
|
|
23
|
+
/** Hover text: when the numbers were read, each window's use and reset, and what a click does. */
|
|
24
24
|
tip: string;
|
|
25
25
|
/**
|
|
26
26
|
* The bars, in two columns: the shorter window, then the longer one. A Family with one window (such as `7d`) fills
|
|
27
27
|
* the second, so the long windows of all Families line up. Null when the row has no Quota to draw.
|
|
28
28
|
*/
|
|
29
29
|
bars: [MenubarBar | null, MenubarBar | null] | null;
|
|
30
|
+
/**
|
|
31
|
+
* A Host whose every limit covers one model group (Antigravity CLI): a line per group under the account, each with
|
|
32
|
+
* its own two bars, reset and hover text, while the account's own `bars` stay null. Null otherwise.
|
|
33
|
+
*/
|
|
34
|
+
groups: {
|
|
35
|
+
label: string;
|
|
36
|
+
bars: MenubarRow['bars'];
|
|
37
|
+
reset: string;
|
|
38
|
+
tip: string;
|
|
39
|
+
}[] | null;
|
|
30
40
|
/** How long until the fullest window resets, such as `4d 17h`; empty when nothing is used. */
|
|
31
41
|
reset: string;
|
|
32
42
|
/** A no-quota explanation, or an old-reading warning beside the bars. */
|
|
@@ -39,11 +49,7 @@ export interface MenubarSection {
|
|
|
39
49
|
* The Family's mark before its title, as the Panel draws it: in its brand `color` when it has one, else in the
|
|
40
50
|
* menu's text colour; null when the Family has no mark.
|
|
41
51
|
*/
|
|
42
|
-
logo:
|
|
43
|
-
path: string;
|
|
44
|
-
fillRule?: 'nonzero' | 'evenodd';
|
|
45
|
-
color?: string;
|
|
46
|
-
} | null;
|
|
52
|
+
logo: Pick<FamilyLogo, 'path' | 'fillRule' | 'color' | 'gradients'> | null;
|
|
47
53
|
/** The window names above the two bar columns, such as `5h` and `7d`; null where no row has that column. */
|
|
48
54
|
columns: [string | null, string | null];
|
|
49
55
|
/** The recommended account first, then the others in Display Order. */
|
|
@@ -84,6 +90,11 @@ export interface MenubarFamilyInput {
|
|
|
84
90
|
id: string;
|
|
85
91
|
title: string;
|
|
86
92
|
logo?: FamilyLogo | null;
|
|
93
|
+
/**
|
|
94
|
+
* Whether "Refresh" asks the Host for new numbers (the Family has `fetchQuota`). False for Claude Code, whose Quota
|
|
95
|
+
* changes only when a session runs in the account; old readings then say so. Default true.
|
|
96
|
+
*/
|
|
97
|
+
refreshable?: boolean;
|
|
87
98
|
/** Its Handoff ranking (`sideby next`); null when the Family has no Quota source. */
|
|
88
99
|
plan: HandoffPlan | null;
|
|
89
100
|
/** In Display Order. */
|
|
@@ -95,6 +106,11 @@ export interface MenubarFamilyInput {
|
|
|
95
106
|
quota: QuotaResult;
|
|
96
107
|
/** The other refs of its Same Login: the same subscription, so one quota. */
|
|
97
108
|
sameLogin?: readonly string[];
|
|
109
|
+
/**
|
|
110
|
+
* The newest use of its login on this computer (its own and its Same Login's sessions), when known. A reading
|
|
111
|
+
* older than an hour with no use since is not marked old (`quotaIsStale`).
|
|
112
|
+
*/
|
|
113
|
+
lastUseAt?: string;
|
|
98
114
|
}[];
|
|
99
115
|
}
|
|
100
116
|
/** A shortcut as the menu bar script registers it: a macOS virtual key code and Carbon modifier flags. */
|
|
@@ -109,6 +125,17 @@ export declare const DEFAULT_MENUBAR_HOTKEY = "opt+x";
|
|
|
109
125
|
export declare function menubarHotkey(value: string | undefined): MenubarHotkey | null;
|
|
110
126
|
/** `2h 5m`, `3d 4h` or `12m` until `at`; at least one minute. */
|
|
111
127
|
export declare function untilText(at: string, now: Date, s: MenubarStrings): string;
|
|
128
|
+
/**
|
|
129
|
+
* The model groups of a Quota whose every window covers one group (Antigravity CLI), in the order the Host lists them,
|
|
130
|
+
* as the Panel shows them: each with its own windows, so the menu draws a line per group with its `5h` and `7d` bars.
|
|
131
|
+
* Null when some window covers every model.
|
|
132
|
+
*/
|
|
133
|
+
export declare function quotaGroups(quota: QuotaResult): {
|
|
134
|
+
name: string;
|
|
135
|
+
quota: QuotaResult & {
|
|
136
|
+
status: 'ok';
|
|
137
|
+
};
|
|
138
|
+
}[] | null;
|
|
112
139
|
/**
|
|
113
140
|
* Each Family's number is the Quota Pressure of the account `sideby next` would pick, or, when every account is past
|
|
114
141
|
* the fail level, the lowest of theirs; the title shows the highest of these, so it turns red when some tool has
|
|
@@ -65,7 +65,11 @@ export function menubarHotkey(value) {
|
|
|
65
65
|
}
|
|
66
66
|
/** `2h 5m`, `3d 4h` or `12m` until `at`; at least one minute. */
|
|
67
67
|
export function untilText(at, now, s) {
|
|
68
|
-
|
|
68
|
+
return durationText(Math.ceil((Date.parse(at) - now.getTime()) / 60000), s);
|
|
69
|
+
}
|
|
70
|
+
/** `2h 5m`, `3d 4h` or `12m` for a number of minutes; at least one minute. */
|
|
71
|
+
function durationText(minutes, s) {
|
|
72
|
+
const total = Math.max(1, minutes);
|
|
69
73
|
const d = Math.floor(total / 1440);
|
|
70
74
|
const h = Math.floor((total % 1440) / 60);
|
|
71
75
|
const m = total % 60;
|
|
@@ -75,7 +79,75 @@ export function untilText(at, now, s) {
|
|
|
75
79
|
return fill(s.hoursMinutes, { h, m });
|
|
76
80
|
return fill(s.minutes, { m });
|
|
77
81
|
}
|
|
78
|
-
|
|
82
|
+
/**
|
|
83
|
+
* The model groups of a Quota whose every window covers one group (Antigravity CLI), in the order the Host lists them,
|
|
84
|
+
* as the Panel shows them: each with its own windows, so the menu draws a line per group with its `5h` and `7d` bars.
|
|
85
|
+
* Null when some window covers every model.
|
|
86
|
+
*/
|
|
87
|
+
export function quotaGroups(quota) {
|
|
88
|
+
if (quota.status !== 'ok' || !quota.windows.length || quota.windows.some((w) => !w.name))
|
|
89
|
+
return null;
|
|
90
|
+
const groups = new Map();
|
|
91
|
+
for (const { name, ...w } of quota.windows)
|
|
92
|
+
groups.set(name, [...(groups.get(name) ?? []), w]);
|
|
93
|
+
return [...groups].map(([name, windows]) => ({ name, quota: { ...quota, windows } }));
|
|
94
|
+
}
|
|
95
|
+
/** A model group's name over its line, without a trailing "models" so it fits. */
|
|
96
|
+
function groupLabel(name) {
|
|
97
|
+
return name.replace(/\s+models$/i, '') || name;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* What a Quota whose windows cover every model draws: two bar columns (the shortest window, then the fullest of the
|
|
101
|
+
* others, so a third window that is used up still shows; a single window fills the second), the time until the fullest
|
|
102
|
+
* resets, and one hover line per window with its use and reset.
|
|
103
|
+
*/
|
|
104
|
+
function drawn(quota, now, s) {
|
|
105
|
+
const open = openWindows(quota, now) ?? [];
|
|
106
|
+
const windows = quota.windows
|
|
107
|
+
.filter((w) => !w.name)
|
|
108
|
+
.sort((x, y) => (x.windowMinutes ?? 0) - (y.windowMinutes ?? 0));
|
|
109
|
+
const openOf = (w) => open.find((o) => o.label === w.label);
|
|
110
|
+
const bar = (w) => {
|
|
111
|
+
const percent = Math.round(openOf(w)?.usedPercent ?? 0);
|
|
112
|
+
return { label: w.label, percent, level: quotaLevel(percent) };
|
|
113
|
+
};
|
|
114
|
+
const longer = windows
|
|
115
|
+
.slice(1)
|
|
116
|
+
.map(bar)
|
|
117
|
+
.reduce((best, b) => (!best || b.percent > best.percent ? b : best), null);
|
|
118
|
+
const bars = !windows.length
|
|
119
|
+
? null
|
|
120
|
+
: longer
|
|
121
|
+
? [bar(windows[0]), longer]
|
|
122
|
+
: [null, bar(windows[0])];
|
|
123
|
+
const fullest = open.reduce((best, w) => (!best || w.usedPercent > best.usedPercent ? w : best), null);
|
|
124
|
+
const reset = fullest && fullest.usedPercent > 0 ? untilText(fullest.resetsAt, now, s) : '';
|
|
125
|
+
const lines = windows.map((w) => {
|
|
126
|
+
const o = openOf(w);
|
|
127
|
+
const p = bar(w).percent;
|
|
128
|
+
return o && p > 0
|
|
129
|
+
? fill(s.windowResetsTip, { label: w.label, p, time: untilText(o.resetsAt, now, s) })
|
|
130
|
+
: fill(s.windowTip, { label: w.label, p });
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
bars,
|
|
134
|
+
fullest,
|
|
135
|
+
reset,
|
|
136
|
+
parts: windows.map((w) => fill(s.window, { label: w.label, p: bar(w).percent })),
|
|
137
|
+
lines,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/** When the numbers were read, in words: "just now", "25 min ago", or the time itself when the date is unknown. */
|
|
141
|
+
function observedText(observedAt, now, s) {
|
|
142
|
+
const at = Date.parse(observedAt);
|
|
143
|
+
if (!Number.isFinite(at))
|
|
144
|
+
return fill(s.observedAt, { time: '?' });
|
|
145
|
+
const minutes = Math.max(0, Math.floor((now.getTime() - at) / 60000));
|
|
146
|
+
if (minutes < 1)
|
|
147
|
+
return s.observedJustNow;
|
|
148
|
+
return fill(s.observedAgo, { time: durationText(minutes, s) });
|
|
149
|
+
}
|
|
150
|
+
function row(a, plan, now, s, refreshable) {
|
|
79
151
|
const recommended = Boolean(plan?.hasQuota && plan.pick === a.ref);
|
|
80
152
|
const startTip = fill(s.startTip, { account: a.ref });
|
|
81
153
|
const base = {
|
|
@@ -84,6 +156,7 @@ function row(a, plan, now, s) {
|
|
|
84
156
|
recommended,
|
|
85
157
|
tip: startTip,
|
|
86
158
|
bars: null,
|
|
159
|
+
groups: null,
|
|
87
160
|
reset: '',
|
|
88
161
|
observedAt: null,
|
|
89
162
|
stale: false,
|
|
@@ -93,56 +166,72 @@ function row(a, plan, now, s) {
|
|
|
93
166
|
return noted(s.api);
|
|
94
167
|
if (a.login === 'logged-out')
|
|
95
168
|
return noted(s.signedOut);
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
169
|
+
const quota = a.quota;
|
|
170
|
+
if (quota.status !== 'ok')
|
|
98
171
|
return noted(s.noData);
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
.
|
|
112
|
-
.map(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
172
|
+
const stale = quotaIsStale(quota, now.getTime(), a.lastUseAt);
|
|
173
|
+
// Over an hour old but unused here since: the numbers stand, and the hover text says what it cannot see.
|
|
174
|
+
const quiet = !stale && now.getTime() - Date.parse(quota.observedAt) > 3600_000;
|
|
175
|
+
// The head of the hover text: when the numbers were read, and why they may be old.
|
|
176
|
+
const head = [
|
|
177
|
+
observedText(quota.observedAt, now, s),
|
|
178
|
+
...(stale ? [refreshable ? s.olderReadingTip : s.olderReadingSessionTip] : []),
|
|
179
|
+
...(quiet ? [s.quietTip] : []),
|
|
180
|
+
...(quota.fetchError ? [fill(s.fetchFailed, { error: quota.fetchError })] : []),
|
|
181
|
+
];
|
|
182
|
+
const groups = quotaGroups(quota);
|
|
183
|
+
if (groups) {
|
|
184
|
+
// One line per model group under the account, each with its own 5h and 7d bars (spec §3.31).
|
|
185
|
+
const drawnGroups = groups.map((g) => ({ name: g.name, d: drawn(g.quota, now, s) }));
|
|
186
|
+
const fullest = drawnGroups
|
|
187
|
+
.map((g) => g.d.fullest)
|
|
188
|
+
.reduce((best, w) => (w && (!best || w.usedPercent > best.usedPercent) ? w : best), null);
|
|
189
|
+
const groupTip = (g) => [g.name, ...g.d.lines.map((l) => ` ${l}`)];
|
|
190
|
+
return {
|
|
191
|
+
...base,
|
|
192
|
+
observedAt: quota.observedAt,
|
|
193
|
+
stale,
|
|
194
|
+
detail: [
|
|
195
|
+
...drawnGroups.map((g) => `${groupLabel(g.name)} ${g.d.parts.join(' ')}`),
|
|
196
|
+
...(stale ? [s.olderReading] : []),
|
|
197
|
+
].join(s.sep),
|
|
198
|
+
level: quotaLevel(fullest?.usedPercent ?? 0),
|
|
199
|
+
tip: [...head, '', ...drawnGroups.flatMap(groupTip), '', startTip].join('\n'),
|
|
200
|
+
groups: drawnGroups.map((g) => ({
|
|
201
|
+
label: groupLabel(g.name),
|
|
202
|
+
bars: g.d.bars,
|
|
203
|
+
reset: g.d.reset,
|
|
204
|
+
tip: [...head, '', ...groupTip(g), '', startTip].join('\n'),
|
|
205
|
+
})),
|
|
206
|
+
note: stale ? s.olderReading : '',
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (openWindows(quota, now) === null)
|
|
210
|
+
return noted(s.noData);
|
|
211
|
+
const d = drawn(quota, now, s);
|
|
212
|
+
const parts = [...d.parts];
|
|
213
|
+
if (d.reset)
|
|
214
|
+
parts.push(fill(s.resets, { time: d.reset }));
|
|
120
215
|
if (stale)
|
|
121
216
|
parts.push(s.olderReading);
|
|
122
|
-
const tips = open
|
|
123
|
-
.filter((w) => w.usedPercent > 0)
|
|
124
|
-
.map((w) => fill(s.resetsTip, { label: w.label, time: untilText(w.resetsAt, now, s) }));
|
|
125
217
|
return {
|
|
126
218
|
...base,
|
|
127
|
-
observedAt,
|
|
219
|
+
observedAt: quota.observedAt,
|
|
128
220
|
stale,
|
|
129
221
|
detail: parts.join(s.sep),
|
|
130
|
-
level: quotaLevel(fullest?.usedPercent ?? 0),
|
|
131
|
-
tip: [
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
...(a.quota.fetchError ? [a.quota.fetchError] : []),
|
|
135
|
-
...tips,
|
|
136
|
-
startTip,
|
|
137
|
-
].join('\n'),
|
|
138
|
-
bars,
|
|
139
|
-
reset,
|
|
222
|
+
level: quotaLevel(d.fullest?.usedPercent ?? 0),
|
|
223
|
+
tip: [...head, '', ...d.lines, '', startTip].join('\n'),
|
|
224
|
+
bars: d.bars,
|
|
225
|
+
reset: d.reset,
|
|
140
226
|
note: stale ? s.olderReading : '',
|
|
141
227
|
};
|
|
142
228
|
}
|
|
143
229
|
/** The recommended row first; API key and signed-out rows into `more` while other rows remain to show. */
|
|
144
230
|
function columns(rows) {
|
|
145
|
-
const at = (i) => rows
|
|
231
|
+
const at = (i) => rows
|
|
232
|
+
.flatMap((r) => [r.bars, ...(r.groups ?? []).map((g) => g.bars)])
|
|
233
|
+
.map((bars) => bars?.[i]?.label)
|
|
234
|
+
.find((l) => l !== undefined) ?? null;
|
|
146
235
|
return [at(0), at(1)];
|
|
147
236
|
}
|
|
148
237
|
function section(f, now, s) {
|
|
@@ -151,9 +240,10 @@ function section(f, now, s) {
|
|
|
151
240
|
path: f.logo.path,
|
|
152
241
|
...(f.logo.fillRule ? { fillRule: f.logo.fillRule } : {}),
|
|
153
242
|
...(f.logo.color ? { color: f.logo.color } : {}),
|
|
243
|
+
...(f.logo.gradients?.length ? { gradients: f.logo.gradients } : {}),
|
|
154
244
|
}
|
|
155
245
|
: null;
|
|
156
|
-
const all = f.accounts.map((a) => ({ a, r: row(a, f.plan, now, s) }));
|
|
246
|
+
const all = f.accounts.map((a) => ({ a, r: row(a, f.plan, now, s, f.refreshable !== false) }));
|
|
157
247
|
const aside = (a) => a.kind === 'api' || a.login === 'logged-out';
|
|
158
248
|
// A Same Login is one quota, so one row, named like the Panel's: after the directory first in Display Order (the
|
|
159
249
|
// Panel's "Set as shown name" moves one there). It is recommended when any of its directories is. The other
|
|
@@ -233,6 +323,11 @@ export function menubarSnapshot(families, now, lang, hotkey = null) {
|
|
|
233
323
|
: {};
|
|
234
324
|
const low = worst !== null && quotaLevel(worst.value) !== 'ok';
|
|
235
325
|
const old = sections.some((s) => s.rows.some((r) => r.stale));
|
|
326
|
+
// "Refresh" brings new numbers only for a Family that can be asked; otherwise a session in that account must run.
|
|
327
|
+
const oldSays = old &&
|
|
328
|
+
sections.every((sec) => !sec.rows.some((r) => r.stale) || families.find((f) => f.id === sec.family)?.refreshable === false)
|
|
329
|
+
? s.detailOldSession
|
|
330
|
+
: s.detailOld;
|
|
236
331
|
const { recommended, empty, loading, addAccount, resetsHeader, updatedJustNow, updatedMinutes, refreshing, refreshFailed, refresh, openPanel, hide, hideTitle, hideBody, hideYes, cancel, hotkeyTaken, } = s;
|
|
237
332
|
return {
|
|
238
333
|
schemaVersion: 1,
|
|
@@ -240,7 +335,7 @@ export function menubarSnapshot(families, now, lang, hotkey = null) {
|
|
|
240
335
|
level: worst && !old ? quotaLevel(worst.value) : 'none',
|
|
241
336
|
tooltip: [
|
|
242
337
|
old
|
|
243
|
-
? `${s.statusOld} · ${
|
|
338
|
+
? `${s.statusOld} · ${oldSays}`
|
|
244
339
|
: worst
|
|
245
340
|
? fill(low ? s.tooltipLow : s.tooltipOk, values)
|
|
246
341
|
: s.tooltipEmpty,
|
|
@@ -251,7 +346,7 @@ export function menubarSnapshot(families, now, lang, hotkey = null) {
|
|
|
251
346
|
card: worst
|
|
252
347
|
? {
|
|
253
348
|
status: old ? s.statusOld : fill(low ? s.statusLow : s.statusOk, values),
|
|
254
|
-
detail: old ?
|
|
349
|
+
detail: old ? oldSays : fill(low ? s.detailLow : s.detailOk, values),
|
|
255
350
|
level: old ? 'none' : quotaLevel(worst.value),
|
|
256
351
|
}
|
|
257
352
|
: null,
|
|
@@ -10,6 +10,7 @@ export declare const MENUBAR_STRINGS: {
|
|
|
10
10
|
readonly statusOk: 'Plenty of quota';
|
|
11
11
|
readonly statusOld: 'Quota needs refreshing';
|
|
12
12
|
readonly detailOld: 'Some readings are old · refresh to check';
|
|
13
|
+
readonly detailOldSession: 'Some readings are old · they update when a session runs in that account';
|
|
13
14
|
readonly statusLow: '{tool} is running low';
|
|
14
15
|
readonly detailOk: 'Highest next account: {account} ({p}% used)';
|
|
15
16
|
readonly detailLow: '{account} is at {p}% · switch tools or wait';
|
|
@@ -21,9 +22,16 @@ export declare const MENUBAR_STRINGS: {
|
|
|
21
22
|
readonly noData: 'no quota yet';
|
|
22
23
|
readonly olderReading: 'older reading';
|
|
23
24
|
readonly observedAt: 'Quota recorded at {time}';
|
|
25
|
+
readonly observedJustNow: 'Quota read just now';
|
|
26
|
+
readonly observedAgo: 'Quota read {time} ago';
|
|
27
|
+
readonly olderReadingTip: 'These numbers may be old · click Refresh to check again';
|
|
28
|
+
readonly olderReadingSessionTip: 'These numbers may be old · they update when a session runs in this account';
|
|
29
|
+
readonly quietTip: 'Not used on this computer since · use on the web or other computers is not included';
|
|
30
|
+
readonly fetchFailed: 'The last check failed: {error}';
|
|
31
|
+
readonly windowTip: '{label}: {p}% used';
|
|
32
|
+
readonly windowResetsTip: '{label}: {p}% used · resets in {time}';
|
|
24
33
|
readonly window: '{label} {p}%';
|
|
25
34
|
readonly resets: 'resets in {time}';
|
|
26
|
-
readonly resetsTip: '{label} resets in {time}';
|
|
27
35
|
readonly moreApi: 'API keys ({n})';
|
|
28
36
|
readonly moreSignedOut: '{n} signed out';
|
|
29
37
|
readonly moreMixed: '{n} more';
|
|
@@ -60,6 +68,7 @@ export declare const MENUBAR_STRINGS: {
|
|
|
60
68
|
readonly statusOk: '各工具额度充足';
|
|
61
69
|
readonly statusOld: '额度需要更新';
|
|
62
70
|
readonly detailOld: '部分额度是旧数据 · 请刷新确认';
|
|
71
|
+
readonly detailOldSession: '部分额度是旧数据 · 在对应账号开一次会话就会更新';
|
|
63
72
|
readonly statusLow: '{tool} 额度吃紧';
|
|
64
73
|
readonly detailOk: '首选账号中最高:{account}(已用 {p}%)';
|
|
65
74
|
readonly detailLow: '首选 {account} 已用 {p}% · 可换工具或等重置';
|
|
@@ -71,9 +80,16 @@ export declare const MENUBAR_STRINGS: {
|
|
|
71
80
|
readonly noData: '暂无额度';
|
|
72
81
|
readonly olderReading: '旧数据';
|
|
73
82
|
readonly observedAt: '额度记录时间:{time}';
|
|
83
|
+
readonly observedJustNow: '额度刚刚读取';
|
|
84
|
+
readonly observedAgo: '额度读于 {time}前';
|
|
85
|
+
readonly olderReadingTip: '这些数字可能已经过时 · 点“刷新”重新检查';
|
|
86
|
+
readonly olderReadingSessionTip: '这些数字可能已经过时 · 在这个账号开一次会话就会更新';
|
|
87
|
+
readonly quietTip: '之后这台电脑没用过这个账号 · 网页或其他电脑上的用量不在内';
|
|
88
|
+
readonly fetchFailed: '上次检查没成功:{error}';
|
|
89
|
+
readonly windowTip: '{label}:已用 {p}%';
|
|
90
|
+
readonly windowResetsTip: '{label}:已用 {p}% · {time}后重置';
|
|
74
91
|
readonly window: '{label} {p}%';
|
|
75
92
|
readonly resets: '{time}后重置';
|
|
76
|
-
readonly resetsTip: '{label}额度将在 {time}后重置';
|
|
77
93
|
readonly moreApi: '{n} 个 API 密钥账号';
|
|
78
94
|
readonly moreSignedOut: '{n} 个未登录账号';
|
|
79
95
|
readonly moreMixed: '另外 {n} 个账号';
|