@cortexkit/opencode-antigravity-auth 3.0.6 → 3.0.8
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/cli.js +1621 -183
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +228 -62
- package/dist/index.js +2728 -883
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +291 -104
- package/dist/server.js +2255 -390
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/availability.d.ts +89 -0
- package/dist/src/common-auth-embedded/claustrum/availability.js +106 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +41 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.js +152 -6
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +135 -14
- package/dist/src/common-auth-embedded/claustrum/custody.js +311 -16
- package/dist/src/common-auth-embedded/claustrum/errors.d.ts +1 -0
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +5 -3
- package/dist/src/common-auth-embedded/claustrum/index.js +4 -1
- package/dist/src/common-auth-embedded/claustrum/insula.d.ts +48 -0
- package/dist/src/common-auth-embedded/claustrum/insula.js +286 -21
- package/dist/src/common-auth-embedded/claustrum/watch.d.ts +141 -0
- package/dist/src/common-auth-embedded/claustrum/watch.js +254 -0
- package/dist/src/common-auth-embedded/fs/private-files.js +10 -2
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +6 -1
- package/dist/src/common-auth-embedded/pi-slot/lock.js +7 -3
- package/dist/src/common-auth-embedded/quota/format.d.ts +17 -3
- package/dist/src/common-auth-embedded/quota/format.js +203 -18
- package/dist/src/common-auth-embedded/quota/index.d.ts +2 -2
- package/dist/src/common-auth-embedded/quota/index.js +1 -1
- package/dist/src/common-auth-embedded/quota/projection.d.ts +16 -0
- package/dist/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/dist/src/common-auth-embedded/setup/command-error.js +79 -0
- package/dist/src/common-auth-embedded/setup/command-runner.js +118 -24
- package/dist/src/common-auth-embedded/setup/command.js +75 -19
- package/dist/src/common-auth-embedded/setup/enroll.js +17 -5
- package/dist/src/common-auth-embedded/setup/index.d.ts +2 -1
- package/dist/src/common-auth-embedded/setup/index.js +1 -0
- package/dist/src/common-auth-embedded/setup/register.js +8 -2
- package/dist/src/common-auth-embedded/setup/types.d.ts +14 -0
- package/dist/src/common-auth-embedded/source-output.json +142 -94
- package/dist/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/dist/src/common-auth-embedded/store/pool.js +0 -1
- package/dist/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/dist/src/common-auth-embedded/store/refresh-lock.js +0 -1
- package/dist/src/ga/server/index.d.ts +2 -0
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +18 -3
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +37 -3
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/auth-loader.d.ts +2 -1
- package/dist/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/src/plugin/auth-loader.js +5 -4
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/src/plugin/config/schema.js +2 -1
- package/dist/src/plugin/config/schema.js.map +1 -1
- package/dist/src/plugin/fetch-interceptor.d.ts +2 -1
- package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/src/plugin/fetch-interceptor.js +8 -6
- package/dist/src/plugin/fetch-interceptor.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +7 -3
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/src/plugin/gemini-dump.js +2 -5
- package/dist/src/plugin/gemini-dump.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +3 -3
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/logging-utils.d.ts.map +1 -1
- package/dist/src/plugin/logging-utils.js +2 -5
- package/dist/src/plugin/logging-utils.js.map +1 -1
- package/dist/src/plugin/request.d.ts +1 -2
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +8 -12
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/shared/after-handoff.d.ts +14 -0
- package/dist/src/plugin/shared/after-handoff.d.ts.map +1 -0
- package/dist/src/plugin/shared/after-handoff.js +89 -0
- package/dist/src/plugin/shared/after-handoff.js.map +1 -0
- package/dist/src/plugin/shared/request-services.d.ts +16 -3
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +193 -90
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.d.ts +13 -4
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.js +17 -1
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts +16 -1
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +60 -10
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/src/sidebar-projection.d.ts +4 -0
- package/dist/src/sidebar-projection.d.ts.map +1 -1
- package/dist/src/sidebar-projection.js +6 -2
- package/dist/src/sidebar-projection.js.map +1 -1
- package/dist/src/tui/quota-layout.d.ts +94 -0
- package/dist/src/tui/quota-layout.d.ts.map +1 -0
- package/dist/src/tui/quota-layout.js +139 -0
- package/dist/src/tui/quota-layout.js.map +1 -0
- package/dist/src/tui/route-layout.d.ts +8 -0
- package/dist/src/tui/route-layout.d.ts.map +1 -0
- package/dist/src/tui/route-layout.js +36 -0
- package/dist/src/tui/route-layout.js.map +1 -0
- package/dist/src/tui.d.ts.map +1 -1
- package/dist/src/tui.js +105 -191
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +60 -31
- package/dist/tui-ga-build-map.json +46 -17
- package/dist/types/src/common-auth-embedded/claustrum/availability.d.ts +89 -0
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +41 -1
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +135 -14
- package/dist/types/src/common-auth-embedded/claustrum/errors.d.ts +1 -0
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +5 -3
- package/dist/types/src/common-auth-embedded/claustrum/insula.d.ts +48 -0
- package/dist/types/src/common-auth-embedded/claustrum/watch.d.ts +141 -0
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/dist/types/src/common-auth-embedded/quota/format.d.ts +17 -3
- package/dist/types/src/common-auth-embedded/quota/index.d.ts +2 -2
- package/dist/types/src/common-auth-embedded/quota/projection.d.ts +16 -0
- package/dist/types/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/dist/types/src/common-auth-embedded/setup/index.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/setup/types.d.ts +14 -0
- package/dist/types/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/dist/types/src/ga/server/index.d.ts +2 -0
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/plugin/auth-loader.d.ts +2 -1
- package/dist/types/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/types/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/types/src/plugin/fetch-interceptor.d.ts +2 -1
- package/dist/types/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/types/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/logging-utils.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts +1 -2
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/after-handoff.d.ts +14 -0
- package/dist/types/src/plugin/shared/after-handoff.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/request-services.d.ts +16 -3
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +13 -4
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts +16 -1
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/common-auth-embedded/claustrum/availability.d.ts +89 -0
- package/src/common-auth-embedded/claustrum/availability.js +106 -0
- package/src/common-auth-embedded/claustrum/consumer.d.ts +41 -1
- package/src/common-auth-embedded/claustrum/consumer.js +152 -6
- package/src/common-auth-embedded/claustrum/custody.d.ts +135 -14
- package/src/common-auth-embedded/claustrum/custody.js +311 -16
- package/src/common-auth-embedded/claustrum/errors.d.ts +1 -0
- package/src/common-auth-embedded/claustrum/index.d.ts +5 -3
- package/src/common-auth-embedded/claustrum/index.js +4 -1
- package/src/common-auth-embedded/claustrum/insula.d.ts +48 -0
- package/src/common-auth-embedded/claustrum/insula.js +286 -21
- package/src/common-auth-embedded/claustrum/watch.d.ts +141 -0
- package/src/common-auth-embedded/claustrum/watch.js +254 -0
- package/src/common-auth-embedded/fs/private-files.js +10 -2
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/src/common-auth-embedded/fs/refresh-file-lock.js +6 -1
- package/src/common-auth-embedded/pi-slot/lock.js +7 -3
- package/src/common-auth-embedded/quota/format.d.ts +17 -3
- package/src/common-auth-embedded/quota/format.js +203 -18
- package/src/common-auth-embedded/quota/index.d.ts +2 -2
- package/src/common-auth-embedded/quota/index.js +1 -1
- package/src/common-auth-embedded/quota/projection.d.ts +16 -0
- package/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/src/common-auth-embedded/setup/command-error.js +79 -0
- package/src/common-auth-embedded/setup/command-runner.js +118 -24
- package/src/common-auth-embedded/setup/command.js +75 -19
- package/src/common-auth-embedded/setup/enroll.js +17 -5
- package/src/common-auth-embedded/setup/index.d.ts +2 -1
- package/src/common-auth-embedded/setup/index.js +1 -0
- package/src/common-auth-embedded/setup/register.js +8 -2
- package/src/common-auth-embedded/setup/types.d.ts +14 -0
- package/src/common-auth-embedded/source-output.json +142 -94
- package/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/src/common-auth-embedded/store/pool.js +0 -1
- package/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/src/common-auth-embedded/store/refresh-lock.js +0 -1
- package/src/tui-compiled/common-auth-embedded/fs/private-files.js +10 -2
- package/src/tui-compiled/common-auth-embedded/quota/format.js +203 -18
- package/src/tui-compiled/common-auth-embedded/quota/index.js +1 -1
- package/src/tui-compiled/tui/quota-layout.js +378 -0
- package/src/tui-compiled/tui/route-layout.js +30 -0
- package/src/tui-compiled/tui.js +245 -501
- package/src/tui-ga-compiled/host-ga.js +82 -52
- package/src/tui-ga-compiled/shared/6ca47cd4ec33fe72-route-layout.js +30 -0
- package/src/tui-ga-compiled/shared/8ae1927e5910ea81-sidebar-projection.js +2 -2
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +203 -18
- package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +1 -1
- package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +378 -0
- package/src/tui-ga-raw/host-ga.tsx +71 -30
- package/src/tui-ga-raw/shared/6ca47cd4ec33fe72-route-layout.js +30 -0
- package/src/tui-ga-raw/shared/8ae1927e5910ea81-sidebar-projection.js +2 -2
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +203 -18
- package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +1 -1
- package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +391 -0
- package/src/tui-raw/common-auth-embedded/fs/private-files.js +10 -2
- package/src/tui-raw/common-auth-embedded/quota/format.js +203 -18
- package/src/tui-raw/common-auth-embedded/quota/index.js +1 -1
- package/src/tui-raw/tui/quota-layout.tsx +391 -0
- package/src/tui-raw/tui/route-layout.js +30 -0
- package/src/tui-raw/tui.tsx +171 -411
- package/src/tui.tsx +171 -411
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { insertNode as _$insertNode } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
2
|
+
import { memo as _$memo } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
3
|
+
import { createComponent as _$createComponent } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
4
|
+
import { effect as _$effect } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
5
|
+
import { insert as _$insert } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
6
|
+
import { setProp as _$setProp } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
7
|
+
import { createElement as _$createElement } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
8
|
+
/** @jsxImportSource @opentui/solid */
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Quota layout shared by the OpenCode 1 sidebar (`tui.tsx`) and the OpenCode 2
|
|
12
|
+
* sidebar (`ga/tui/host-ga.tsx`): one account block with its header line, the
|
|
13
|
+
* reading age once per account, plain-word group headers and one width-fitted
|
|
14
|
+
* row per quota window.
|
|
15
|
+
*
|
|
16
|
+
* Each renderer supplies its own data source and colors. This module imports
|
|
17
|
+
* only the pure quota presentation helpers, so it stays inside both TUI
|
|
18
|
+
* import graphs: no sidebar file, preferences file, RPC, account store,
|
|
19
|
+
* OAuth, token or host SDK module, and nothing that writes to the terminal.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { For, Show } from "opentui:runtime-module:solid-js";
|
|
23
|
+
import { NO_QUOTA_READING, quotaReadingAge, quotaWindowText } from "./98cc0c186c46c42d-quota-presentation.js";
|
|
24
|
+
|
|
25
|
+
/** A text color; `undefined` leaves the host's default color in place. */
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* How a renderer colors the quota layout. OpenCode 1 maps these onto its live
|
|
29
|
+
* host theme; a renderer without a theme returns `undefined` everywhere.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** The bar and threshold settings the layout reads. */
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The OpenCode 1 preference defaults for the quota bar, for a renderer that
|
|
36
|
+
* has no preferences file. A test keeps it equal to `DEFAULT_PREFS.appearance`.
|
|
37
|
+
*/
|
|
38
|
+
export const DEFAULT_QUOTA_APPEARANCE = {
|
|
39
|
+
barWidth: 10,
|
|
40
|
+
barFilledChar: '█',
|
|
41
|
+
barEmptyChar: '░',
|
|
42
|
+
warnThreshold: 50,
|
|
43
|
+
errorThreshold: 80
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** The account fields the quota layout reads, and nothing else. */
|
|
47
|
+
|
|
48
|
+
// Group headers name each quota pool in plain words.
|
|
49
|
+
export const GROUP_NAMES = {
|
|
50
|
+
gemini: 'Gemini',
|
|
51
|
+
'non-gemini': 'Other models'
|
|
52
|
+
};
|
|
53
|
+
export const QUOTA_ORDER = ['gemini', 'non-gemini'];
|
|
54
|
+
|
|
55
|
+
// Shown instead of a stored figure once the window has reset since it was
|
|
56
|
+
// read: the stored figure describes the window before the reset.
|
|
57
|
+
export const RESET_SINCE_READING = 'reset since last check';
|
|
58
|
+
|
|
59
|
+
// Content width used until the first layout pass reports the real one. It
|
|
60
|
+
// fits the narrowest OpenCode sidebar.
|
|
61
|
+
export const ASSUMED_CONTENT_WIDTH = 28;
|
|
62
|
+
|
|
63
|
+
// A window row is `<name> <bar> <figure> <reset>`. The bar shrinks to this
|
|
64
|
+
// before the reset column is dropped; below it the bar is dropped too.
|
|
65
|
+
const MIN_BAR_WIDTH = 4;
|
|
66
|
+
// The widest figure the formatter writes: `100% left`.
|
|
67
|
+
const FIGURE_WIDTH = 9;
|
|
68
|
+
// A window name (`5h`, `7d`) and the space after it.
|
|
69
|
+
const NAME_WIDTH = 3;
|
|
70
|
+
export function quotaTone(usedPct, appearance) {
|
|
71
|
+
if (usedPct < appearance.warnThreshold) return 'ok';
|
|
72
|
+
if (usedPct < appearance.errorThreshold) return 'warn';
|
|
73
|
+
return 'err';
|
|
74
|
+
}
|
|
75
|
+
function quotaBarSegments(remainingPct, width, appearance) {
|
|
76
|
+
const usedCells = Math.max(0, Math.min(Math.round(remainingPct / 100 * width), width));
|
|
77
|
+
const tone = quotaTone(100 - remainingPct, appearance);
|
|
78
|
+
return [{
|
|
79
|
+
text: appearance.barFilledChar.repeat(usedCells),
|
|
80
|
+
tone
|
|
81
|
+
}, {
|
|
82
|
+
text: appearance.barEmptyChar.repeat(width - usedCells),
|
|
83
|
+
tone
|
|
84
|
+
}].filter(segment => segment.text.length > 0);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// --- Width-fitted quota rows ------------------------------------------------
|
|
88
|
+
//
|
|
89
|
+
// The host sidebars are about 20 to 48 columns wide. Every quota line is
|
|
90
|
+
// sized from the measured content width so that it fits on one line: text is
|
|
91
|
+
// never left to the renderer's wrapping, which breaks a row mid-word or down
|
|
92
|
+
// to one character per line once the right-hand column runs out of room.
|
|
93
|
+
|
|
94
|
+
// One entry per stored window, in group order. A pool stored before
|
|
95
|
+
// per-window readings existed contributes one window without a name.
|
|
96
|
+
export function accountWindows(account, now) {
|
|
97
|
+
const result = [];
|
|
98
|
+
for (const key of QUOTA_ORDER) {
|
|
99
|
+
const entry = account.quota[key];
|
|
100
|
+
if (!entry) continue;
|
|
101
|
+
const readings = entry.windows && entry.windows.length > 0 ? entry.windows.map(window => ({
|
|
102
|
+
window: window.window,
|
|
103
|
+
remainingPercent: window.remainingPercent,
|
|
104
|
+
resetAt: window.resetAt,
|
|
105
|
+
checkedAt: window.checkedAt
|
|
106
|
+
})) : [{
|
|
107
|
+
remainingPercent: entry.remainingPercent,
|
|
108
|
+
resetAt: entry.resetAt,
|
|
109
|
+
checkedAt: entry.checkedAt
|
|
110
|
+
}];
|
|
111
|
+
for (const reading of readings) result.push({
|
|
112
|
+
key,
|
|
113
|
+
reading,
|
|
114
|
+
text: quotaWindowText(reading, now)
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// A window shows its figure only while no reset has happened since it was
|
|
121
|
+
// read and it has a read time at all.
|
|
122
|
+
export function showsFigure(window) {
|
|
123
|
+
return window.text.remaining != null && !window.text.resetSinceReading;
|
|
124
|
+
}
|
|
125
|
+
// Column widths for one `<name> <bar> <figure> <reset>` row within `width`
|
|
126
|
+
// cells. The bar shrinks first, down to MIN_BAR_WIDTH; then the reset column
|
|
127
|
+
// is dropped; when even that leaves less than MIN_BAR_WIDTH cells for the
|
|
128
|
+
// bar, the bar is left out and the row is just the name and figure.
|
|
129
|
+
function windowRowLayout(width, named, resetWidth, maxBar) {
|
|
130
|
+
const room = width - (named ? NAME_WIDTH : 0) - FIGURE_WIDTH;
|
|
131
|
+
if (resetWidth > 0) {
|
|
132
|
+
const bar = Math.min(maxBar, room - resetWidth - 2);
|
|
133
|
+
if (bar >= MIN_BAR_WIDTH) return {
|
|
134
|
+
bar,
|
|
135
|
+
reset: true
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const bar = Math.min(maxBar, room - 1);
|
|
139
|
+
return {
|
|
140
|
+
bar: bar >= MIN_BAR_WIDTH ? bar : 0,
|
|
141
|
+
reset: false
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Shorten a label to `max` cells, marking the cut with an ellipsis.
|
|
146
|
+
export function fitLabel(label, max) {
|
|
147
|
+
if (label.length <= max) return label;
|
|
148
|
+
if (max <= 0) return '';
|
|
149
|
+
if (max === 1) return '…';
|
|
150
|
+
return `${label.slice(0, max - 1)}…`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// One quota window on one line. The bar fills with remaining quota; the
|
|
154
|
+
// figure and reset come from the shared formatter. A window that reset since
|
|
155
|
+
// its reading shows that fact, dim, in place of the stale figure.
|
|
156
|
+
function WindowRow(props) {
|
|
157
|
+
const text = () => props.window.text;
|
|
158
|
+
const tone = () => quotaTone(100 - (text().remaining ?? 0), props.appearance);
|
|
159
|
+
return (() => {
|
|
160
|
+
var _el$ = _$createElement("box");
|
|
161
|
+
_$setProp(_el$, "width", '100%');
|
|
162
|
+
_$setProp(_el$, "flexDirection", 'row');
|
|
163
|
+
_$insert(_el$, _$createComponent(Show, {
|
|
164
|
+
get when() {
|
|
165
|
+
return text().name !== '';
|
|
166
|
+
},
|
|
167
|
+
get children() {
|
|
168
|
+
var _el$2 = _$createElement("text");
|
|
169
|
+
_$setProp(_el$2, "width", 3);
|
|
170
|
+
_$setProp(_el$2, "flexShrink", 0);
|
|
171
|
+
_$setProp(_el$2, "wrapMode", 'none');
|
|
172
|
+
_$insert(_el$2, () => text().name);
|
|
173
|
+
_$effect(_$p => _$setProp(_el$2, "fg", props.palette.muted(), _$p));
|
|
174
|
+
return _el$2;
|
|
175
|
+
}
|
|
176
|
+
}), null);
|
|
177
|
+
_$insert(_el$, _$createComponent(Show, {
|
|
178
|
+
get when() {
|
|
179
|
+
return showsFigure(props.window);
|
|
180
|
+
},
|
|
181
|
+
get fallback() {
|
|
182
|
+
return (() => {
|
|
183
|
+
var _el$7 = _$createElement("text");
|
|
184
|
+
_$setProp(_el$7, "flexShrink", 1);
|
|
185
|
+
_$setProp(_el$7, "wrapMode", 'none');
|
|
186
|
+
_$insert(_el$7, (() => {
|
|
187
|
+
var _c$ = _$memo(() => !!text().resetSinceReading);
|
|
188
|
+
return () => _c$() ? RESET_SINCE_READING : text().figure;
|
|
189
|
+
})());
|
|
190
|
+
_$effect(_$p => _$setProp(_el$7, "fg", props.palette.muted(), _$p));
|
|
191
|
+
return _el$7;
|
|
192
|
+
})();
|
|
193
|
+
},
|
|
194
|
+
get children() {
|
|
195
|
+
return [_$createComponent(Show, {
|
|
196
|
+
get when() {
|
|
197
|
+
return props.layout.bar > 0;
|
|
198
|
+
},
|
|
199
|
+
get children() {
|
|
200
|
+
var _el$3 = _$createElement("box");
|
|
201
|
+
_$setProp(_el$3, "flexShrink", 0);
|
|
202
|
+
_$setProp(_el$3, "flexDirection", 'row');
|
|
203
|
+
_$insert(_el$3, _$createComponent(For, {
|
|
204
|
+
get each() {
|
|
205
|
+
return quotaBarSegments(text().remaining ?? 0, props.layout.bar, props.appearance);
|
|
206
|
+
},
|
|
207
|
+
children: segment => (() => {
|
|
208
|
+
var _el$8 = _$createElement("text");
|
|
209
|
+
_$setProp(_el$8, "wrapMode", 'none');
|
|
210
|
+
_$insert(_el$8, () => segment.text);
|
|
211
|
+
_$effect(_$p => _$setProp(_el$8, "fg", props.palette.tone(segment.tone), _$p));
|
|
212
|
+
return _el$8;
|
|
213
|
+
})()
|
|
214
|
+
}));
|
|
215
|
+
_$effect(_$p => _$setProp(_el$3, "width", props.layout.bar + 1, _$p));
|
|
216
|
+
return _el$3;
|
|
217
|
+
}
|
|
218
|
+
}), (() => {
|
|
219
|
+
var _el$4 = _$createElement("text");
|
|
220
|
+
_$setProp(_el$4, "flexShrink", 0);
|
|
221
|
+
_$setProp(_el$4, "wrapMode", 'none');
|
|
222
|
+
_$insert(_el$4, () => text().figure);
|
|
223
|
+
_$effect(_$p => _$setProp(_el$4, "fg", props.palette.tone(tone()), _$p));
|
|
224
|
+
return _el$4;
|
|
225
|
+
})(), (() => {
|
|
226
|
+
var _el$5 = _$createElement("box");
|
|
227
|
+
_$setProp(_el$5, "flexGrow", 1);
|
|
228
|
+
return _el$5;
|
|
229
|
+
})(), _$createComponent(Show, {
|
|
230
|
+
get when() {
|
|
231
|
+
return _$memo(() => !!props.layout.reset)() && text().reset !== '';
|
|
232
|
+
},
|
|
233
|
+
get children() {
|
|
234
|
+
var _el$6 = _$createElement("text");
|
|
235
|
+
_$setProp(_el$6, "flexShrink", 0);
|
|
236
|
+
_$setProp(_el$6, "wrapMode", 'none');
|
|
237
|
+
_$insert(_el$6, () => text().reset);
|
|
238
|
+
_$effect(_$p => _$setProp(_el$6, "fg", props.palette.muted(), _$p));
|
|
239
|
+
return _el$6;
|
|
240
|
+
}
|
|
241
|
+
})];
|
|
242
|
+
}
|
|
243
|
+
}), null);
|
|
244
|
+
return _el$;
|
|
245
|
+
})();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* One account's quota block. The header line is the account label, the
|
|
250
|
+
* reading age when the oldest reading is stale, and the caller's status word
|
|
251
|
+
* right-aligned; the age moves to its own dim line when the three do not
|
|
252
|
+
* fit. Below it each quota group present gets a plain-word header and one
|
|
253
|
+
* row per window, or a single dim line when there is no reading at all.
|
|
254
|
+
* `children` render after the quota rows (the OpenCode 2 health line).
|
|
255
|
+
*/
|
|
256
|
+
export function QuotaAccountBlock(props) {
|
|
257
|
+
const windows = () => accountWindows(props.account, props.now());
|
|
258
|
+
const age = () => quotaReadingAge(windows().map(window => window.reading), props.now());
|
|
259
|
+
const ageInline = () => age() !== '' && props.account.label.length + 3 + age().length + 1 + props.status.length <= props.width();
|
|
260
|
+
const label = () => fitLabel(props.account.label, props.width() - 1 - props.status.length);
|
|
261
|
+
// One reset column width per account, so bars line up across its rows.
|
|
262
|
+
const resetWidth = () => Math.max(0, ...windows().filter(showsFigure).map(window => window.text.reset.length));
|
|
263
|
+
const layoutFor = window => windowRowLayout(props.width(), window.text.name !== '', resetWidth(), props.appearance.barWidth);
|
|
264
|
+
const groups = () => QUOTA_ORDER.map(key => ({
|
|
265
|
+
key,
|
|
266
|
+
windows: windows().filter(window => window.key === key)
|
|
267
|
+
})).filter(group => group.windows.length > 0);
|
|
268
|
+
return (() => {
|
|
269
|
+
var _el$9 = _$createElement("box"),
|
|
270
|
+
_el$0 = _$createElement("box"),
|
|
271
|
+
_el$1 = _$createElement("text"),
|
|
272
|
+
_el$10 = _$createElement("b"),
|
|
273
|
+
_el$12 = _$createElement("box"),
|
|
274
|
+
_el$13 = _$createElement("text"),
|
|
275
|
+
_el$14 = _$createElement("b");
|
|
276
|
+
_$insertNode(_el$9, _el$0);
|
|
277
|
+
_$setProp(_el$9, "width", '100%');
|
|
278
|
+
_$setProp(_el$9, "flexDirection", 'column');
|
|
279
|
+
_$insertNode(_el$0, _el$1);
|
|
280
|
+
_$insertNode(_el$0, _el$12);
|
|
281
|
+
_$insertNode(_el$0, _el$13);
|
|
282
|
+
_$setProp(_el$0, "width", '100%');
|
|
283
|
+
_$setProp(_el$0, "flexDirection", 'row');
|
|
284
|
+
_$insertNode(_el$1, _el$10);
|
|
285
|
+
_$setProp(_el$1, "flexShrink", 0);
|
|
286
|
+
_$setProp(_el$1, "wrapMode", 'none');
|
|
287
|
+
_$insert(_el$10, label);
|
|
288
|
+
_$insert(_el$0, _$createComponent(Show, {
|
|
289
|
+
get when() {
|
|
290
|
+
return ageInline();
|
|
291
|
+
},
|
|
292
|
+
get children() {
|
|
293
|
+
var _el$11 = _$createElement("text");
|
|
294
|
+
_$setProp(_el$11, "flexShrink", 0);
|
|
295
|
+
_$setProp(_el$11, "wrapMode", 'none');
|
|
296
|
+
_$insert(_el$11, () => ` · ${age()}`);
|
|
297
|
+
_$effect(_$p => _$setProp(_el$11, "fg", props.palette.muted(), _$p));
|
|
298
|
+
return _el$11;
|
|
299
|
+
}
|
|
300
|
+
}), _el$12);
|
|
301
|
+
_$setProp(_el$12, "flexGrow", 1);
|
|
302
|
+
_$insertNode(_el$13, _el$14);
|
|
303
|
+
_$setProp(_el$13, "flexShrink", 0);
|
|
304
|
+
_$setProp(_el$13, "wrapMode", 'none');
|
|
305
|
+
_$insert(_el$14, () => props.status);
|
|
306
|
+
_$insert(_el$9, _$createComponent(Show, {
|
|
307
|
+
get when() {
|
|
308
|
+
return _$memo(() => age() !== '')() && !ageInline();
|
|
309
|
+
},
|
|
310
|
+
get children() {
|
|
311
|
+
var _el$15 = _$createElement("text");
|
|
312
|
+
_$setProp(_el$15, "wrapMode", 'none');
|
|
313
|
+
_$insert(_el$15, age);
|
|
314
|
+
_$effect(_$p => _$setProp(_el$15, "fg", props.palette.muted(), _$p));
|
|
315
|
+
return _el$15;
|
|
316
|
+
}
|
|
317
|
+
}), null);
|
|
318
|
+
_$insert(_el$9, _$createComponent(Show, {
|
|
319
|
+
get when() {
|
|
320
|
+
return groups().length > 0;
|
|
321
|
+
},
|
|
322
|
+
get fallback() {
|
|
323
|
+
return (() => {
|
|
324
|
+
var _el$16 = _$createElement("text");
|
|
325
|
+
_$setProp(_el$16, "wrapMode", 'none');
|
|
326
|
+
_$insert(_el$16, NO_QUOTA_READING);
|
|
327
|
+
_$effect(_$p => _$setProp(_el$16, "fg", props.palette.muted(), _$p));
|
|
328
|
+
return _el$16;
|
|
329
|
+
})();
|
|
330
|
+
},
|
|
331
|
+
get children() {
|
|
332
|
+
return _$createComponent(For, {
|
|
333
|
+
get each() {
|
|
334
|
+
return groups();
|
|
335
|
+
},
|
|
336
|
+
children: group => [(() => {
|
|
337
|
+
var _el$17 = _$createElement("text");
|
|
338
|
+
_$setProp(_el$17, "wrapMode", 'none');
|
|
339
|
+
_$insert(_el$17, () => GROUP_NAMES[group.key]);
|
|
340
|
+
_$effect(_$p => _$setProp(_el$17, "fg", props.palette.muted(), _$p));
|
|
341
|
+
return _el$17;
|
|
342
|
+
})(), _$createComponent(For, {
|
|
343
|
+
get each() {
|
|
344
|
+
return group.windows;
|
|
345
|
+
},
|
|
346
|
+
children: window => _$createComponent(WindowRow, {
|
|
347
|
+
get palette() {
|
|
348
|
+
return props.palette;
|
|
349
|
+
},
|
|
350
|
+
get appearance() {
|
|
351
|
+
return props.appearance;
|
|
352
|
+
},
|
|
353
|
+
window: window,
|
|
354
|
+
get layout() {
|
|
355
|
+
return layoutFor(window);
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
})]
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}), null);
|
|
362
|
+
_$insert(_el$9, () => props.children, null);
|
|
363
|
+
_$effect(_p$ => {
|
|
364
|
+
var _v$ = props.marginTop ?? 0,
|
|
365
|
+
_v$2 = props.palette.text(),
|
|
366
|
+
_v$3 = props.palette.tone(props.statusTone);
|
|
367
|
+
_v$ !== _p$.e && (_p$.e = _$setProp(_el$9, "marginTop", _v$, _p$.e));
|
|
368
|
+
_v$2 !== _p$.t && (_p$.t = _$setProp(_el$1, "fg", _v$2, _p$.t));
|
|
369
|
+
_v$3 !== _p$.a && (_p$.a = _$setProp(_el$13, "fg", _v$3, _p$.a));
|
|
370
|
+
return _p$;
|
|
371
|
+
}, {
|
|
372
|
+
e: undefined,
|
|
373
|
+
t: undefined,
|
|
374
|
+
a: undefined
|
|
375
|
+
});
|
|
376
|
+
return _el$9;
|
|
377
|
+
})();
|
|
378
|
+
}
|
|
@@ -65,6 +65,13 @@ import {
|
|
|
65
65
|
type MenuSection,
|
|
66
66
|
type MenuUi,
|
|
67
67
|
} from "./shared/07365a7d2ccade4c-host-api.js"
|
|
68
|
+
import {
|
|
69
|
+
ASSUMED_CONTENT_WIDTH,
|
|
70
|
+
DEFAULT_QUOTA_APPEARANCE,
|
|
71
|
+
QuotaAccountBlock,
|
|
72
|
+
type QuotaPalette,
|
|
73
|
+
} from "./shared/dd4c9e1a907f8ef0-quota-layout.tsx"
|
|
74
|
+
import { fitRouteParts } from "./shared/6ca47cd4ec33fe72-route-layout.js"
|
|
68
75
|
|
|
69
76
|
export const GA_TUI_ID = 'cortexkit.antigravity-auth' as const
|
|
70
77
|
export const GA_RPC_ID = 'antigravity-auth' as const
|
|
@@ -1466,7 +1473,19 @@ export async function pollGaOnce(options: GaPollerOptions): Promise<void> {
|
|
|
1466
1473
|
|
|
1467
1474
|
interface SidebarView {
|
|
1468
1475
|
readonly scope: GaScope
|
|
1476
|
+
/** The snapshot's accounts; the quota layout reads their stored windows. */
|
|
1477
|
+
readonly accounts: readonly ProjectionAccount[]
|
|
1469
1478
|
readonly projected: ProjectedSidebar
|
|
1479
|
+
/** The clock reading the projection was made at; the quota rows use it too. */
|
|
1480
|
+
readonly readAt: number
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
// The GA context carries no theme, so the quota layout keeps the host's
|
|
1484
|
+
// default text color everywhere.
|
|
1485
|
+
const HOST_COLORS: QuotaPalette = {
|
|
1486
|
+
text: () => undefined,
|
|
1487
|
+
muted: () => undefined,
|
|
1488
|
+
tone: () => undefined,
|
|
1470
1489
|
}
|
|
1471
1490
|
|
|
1472
1491
|
function GaSidebar(props: {
|
|
@@ -1482,43 +1501,62 @@ function GaSidebar(props: {
|
|
|
1482
1501
|
? view.projected.route
|
|
1483
1502
|
: null
|
|
1484
1503
|
}
|
|
1504
|
+
const routeLine = () => {
|
|
1505
|
+
const value = route()
|
|
1506
|
+
if (value === null) return null
|
|
1507
|
+
return `Route ${fitRouteParts('Route', value.split(' · '), contentWidth())}`
|
|
1508
|
+
}
|
|
1509
|
+
// The quota rows are sized to the sidebar's width so none of them wraps.
|
|
1510
|
+
// Layout reports the width during a render pass, so the signal is updated
|
|
1511
|
+
// afterwards rather than rebuilding rows mid-pass.
|
|
1512
|
+
const [contentWidth, setContentWidth] = createSignal(ASSUMED_CONTENT_WIDTH)
|
|
1513
|
+
let titleRow: { width: number } | undefined
|
|
1514
|
+
const measureContentWidth = (): void => {
|
|
1515
|
+
const width = titleRow?.width
|
|
1516
|
+
if (typeof width !== 'number' || width <= 0) return
|
|
1517
|
+
queueMicrotask(() => {
|
|
1518
|
+
if (width !== contentWidth()) setContentWidth(width)
|
|
1519
|
+
})
|
|
1520
|
+
}
|
|
1485
1521
|
return (
|
|
1486
1522
|
<box flexDirection='column' width='100%'>
|
|
1487
|
-
<
|
|
1488
|
-
|
|
1489
|
-
|
|
1523
|
+
<box
|
|
1524
|
+
ref={(element) => {
|
|
1525
|
+
titleRow = element
|
|
1526
|
+
}}
|
|
1527
|
+
onSizeChange={measureContentWidth}
|
|
1528
|
+
width='100%'
|
|
1529
|
+
flexDirection='row'
|
|
1530
|
+
>
|
|
1531
|
+
<text>
|
|
1532
|
+
<b>Antigravity</b>
|
|
1533
|
+
</text>
|
|
1534
|
+
</box>
|
|
1490
1535
|
<Show when={props.view()} fallback={<text>connecting…</text>}>
|
|
1491
1536
|
{(view) => (
|
|
1492
1537
|
<>
|
|
1493
1538
|
<For each={view().projected.accounts}>
|
|
1494
|
-
{(account) => (
|
|
1495
|
-
<
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
<text>{`${row.label.padEnd(6)}${row.figure}`}</text>
|
|
1512
|
-
<text>{row.reset}</text>
|
|
1513
|
-
</box>
|
|
1514
|
-
)}
|
|
1515
|
-
</For>
|
|
1516
|
-
<text>{` ${account.health}`}</text>
|
|
1517
|
-
</box>
|
|
1539
|
+
{(account, index) => (
|
|
1540
|
+
<Show when={view().accounts[index()]}>
|
|
1541
|
+
{(source) => (
|
|
1542
|
+
<QuotaAccountBlock
|
|
1543
|
+
palette={HOST_COLORS}
|
|
1544
|
+
appearance={DEFAULT_QUOTA_APPEARANCE}
|
|
1545
|
+
account={source()}
|
|
1546
|
+
status={account.status}
|
|
1547
|
+
statusTone={account.statusTone}
|
|
1548
|
+
now={() => view().readAt}
|
|
1549
|
+
width={contentWidth}
|
|
1550
|
+
marginTop={index() === 0 ? 0 : 1}
|
|
1551
|
+
>
|
|
1552
|
+
<text>{` ${account.health}`}</text>
|
|
1553
|
+
</QuotaAccountBlock>
|
|
1554
|
+
)}
|
|
1555
|
+
</Show>
|
|
1518
1556
|
)}
|
|
1519
1557
|
</For>
|
|
1520
|
-
<Show when={
|
|
1521
|
-
{(line) => <text>{
|
|
1558
|
+
<Show when={routeLine()}>
|
|
1559
|
+
{(line) => <text wrapMode='none'>{line()}</text>}
|
|
1522
1560
|
</Show>
|
|
1523
1561
|
<For each={view().projected.notices}>
|
|
1524
1562
|
{(notice) => <text>{notice}</text>}
|
|
@@ -1575,14 +1613,17 @@ export function setupGaTui(
|
|
|
1575
1613
|
|
|
1576
1614
|
const showSnapshot = (snapshot: GaSnapshot) => {
|
|
1577
1615
|
latest.set(scopeKey(snapshot.scope), snapshot)
|
|
1616
|
+
const readAt = now()
|
|
1578
1617
|
setView({
|
|
1579
1618
|
scope: snapshot.scope,
|
|
1619
|
+
accounts: snapshot.accounts,
|
|
1580
1620
|
projected: projectSidebar({
|
|
1581
1621
|
accounts: snapshot.accounts,
|
|
1582
1622
|
route: snapshot.route,
|
|
1583
1623
|
status: snapshot.status,
|
|
1584
|
-
now:
|
|
1624
|
+
now: readAt,
|
|
1585
1625
|
}),
|
|
1626
|
+
readAt,
|
|
1586
1627
|
})
|
|
1587
1628
|
}
|
|
1588
1629
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function routeLineFits(label, value, width) {
|
|
2
|
+
return label.length + 1 + value.length <= width;
|
|
3
|
+
}
|
|
4
|
+
function fitPrimaryPart(value, maxWidth) {
|
|
5
|
+
if (value.length <= maxWidth)
|
|
6
|
+
return value;
|
|
7
|
+
if (maxWidth <= 0)
|
|
8
|
+
return "";
|
|
9
|
+
let fitted = "";
|
|
10
|
+
for (const word of value.trim().split(/\s+/)) {
|
|
11
|
+
const candidate = fitted ? `${fitted} ${word}` : word;
|
|
12
|
+
if (candidate.length > maxWidth) {
|
|
13
|
+
const marked = fitted ? `${fitted}\u2026` : "\u2026";
|
|
14
|
+
return marked.length <= maxWidth ? marked : fitted;
|
|
15
|
+
}
|
|
16
|
+
fitted = candidate;
|
|
17
|
+
}
|
|
18
|
+
return fitted;
|
|
19
|
+
}
|
|
20
|
+
export function fitRouteParts(label, parts, width) {
|
|
21
|
+
const [primary = "", ...optional] = parts;
|
|
22
|
+
let value = fitPrimaryPart(primary, width - label.length - 1);
|
|
23
|
+
for (const part of optional) {
|
|
24
|
+
const candidate = `${value} \xB7 ${part}`;
|
|
25
|
+
if (!routeLineFits(label, candidate, width))
|
|
26
|
+
break;
|
|
27
|
+
value = candidate;
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { quotaReadingParts } from "./98cc0c186c46c42d-quota-presentation.js";
|
|
2
2
|
export const QUOTA_POOL_LABELS = {
|
|
3
|
-
gemini: "
|
|
4
|
-
"non-gemini": "
|
|
3
|
+
gemini: "Gemini",
|
|
4
|
+
"non-gemini": "Other models"
|
|
5
5
|
};
|
|
6
6
|
const POOL_ORDER = ["gemini", "non-gemini"];
|
|
7
7
|
function clamp(value) {
|