@cortexkit/opencode-antigravity-auth 3.0.20 → 3.0.21
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 +75 -32
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +31 -11
- package/dist/index.js +75 -32
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +31 -11
- package/dist/server.js +75 -32
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/custody.js +25 -0
- package/dist/src/common-auth-embedded/claustrum/hub.js +20 -1
- package/dist/src/common-auth-embedded/claustrum/insula.js +6 -0
- package/dist/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
- package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +630 -0
- package/dist/src/common-auth-embedded/source-output.json +37 -17
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +2 -2
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/src/tui/quota-layout.d.ts +4 -58
- package/dist/src/tui/quota-layout.d.ts.map +1 -1
- package/dist/src/tui/quota-layout.js +4 -90
- package/dist/src/tui/quota-layout.js.map +1 -1
- package/dist/src/tui/sidebar-frame.d.ts +4 -34
- package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
- package/dist/src/tui/sidebar-frame.js +91 -167
- package/dist/src/tui/sidebar-frame.js.map +1 -1
- package/dist/src/tui.js +2 -2
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +27 -13
- package/dist/tui-ga-build-map.json +28 -13
- package/package.json +2 -2
- package/src/common-auth-embedded/claustrum/custody.js +25 -0
- package/src/common-auth-embedded/claustrum/hub.js +20 -1
- package/src/common-auth-embedded/claustrum/insula.js +6 -0
- package/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
- package/src/common-auth-embedded/quota-sidebar/index.tsx +630 -0
- package/src/common-auth-embedded/source-output.json +37 -17
- package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +666 -0
- package/src/tui-compiled/tui/quota-layout.js +5 -330
- package/src/tui-compiled/tui/sidebar-frame.js +241 -466
- package/src/tui-compiled/tui.js +2 -2
- package/src/tui-ga-compiled/host-ga.js +2 -2
- package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +241 -466
- package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +5 -330
- package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +666 -0
- package/src/tui-ga-raw/host-ga.tsx +2 -2
- package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +211 -399
- package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +10 -301
- package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +630 -0
- package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +630 -0
- package/src/tui-raw/tui/quota-layout.tsx +10 -301
- package/src/tui-raw/tui/sidebar-frame.tsx +211 -399
- package/src/tui-raw/tui.tsx +2 -2
- package/src/tui.tsx +2 -2
|
@@ -1,50 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* reading age once per account, plain-word group headers and one width-fitted
|
|
7
|
-
* row per quota window.
|
|
8
|
-
*
|
|
9
|
-
* Each renderer supplies its own data source and colors. This module imports
|
|
10
|
-
* only the pure quota presentation helpers, so it stays inside both TUI
|
|
11
|
-
* import graphs: no sidebar file, preferences file, RPC, account store,
|
|
12
|
-
* OAuth, token or host SDK module, and nothing that writes to the terminal.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import type { RGBA } from "@opentui/core"
|
|
16
|
-
import { For, type JSX, Show } from "solid-js"
|
|
1
|
+
/** Pure account-window inputs shared by the two sidebar hosts. */
|
|
2
|
+
import type {
|
|
3
|
+
SidebarAppearance,
|
|
4
|
+
Tone,
|
|
5
|
+
} from "./e4ec36f367492969-index.tsx"
|
|
17
6
|
import {
|
|
18
|
-
NO_QUOTA_READING,
|
|
19
7
|
type QuotaReading,
|
|
20
8
|
type QuotaWindowText,
|
|
21
|
-
quotaReadingAge,
|
|
22
9
|
quotaWindowText,
|
|
23
10
|
} from "./98cc0c186c46c42d-quota-presentation.js"
|
|
24
11
|
|
|
25
|
-
export type
|
|
26
|
-
|
|
27
|
-
/** A text color; `undefined` leaves the host's default color in place. */
|
|
28
|
-
export type QuotaColor = string | RGBA | undefined
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* How a renderer colors the quota layout. OpenCode 1 maps these onto its live
|
|
32
|
-
* host theme; a renderer without a theme returns `undefined` everywhere.
|
|
33
|
-
*/
|
|
34
|
-
export interface QuotaPalette {
|
|
35
|
-
readonly text: () => QuotaColor
|
|
36
|
-
readonly muted: () => QuotaColor
|
|
37
|
-
readonly tone: (tone: QuotaTone) => QuotaColor
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** The bar and threshold settings the layout reads. */
|
|
41
|
-
export interface QuotaAppearance {
|
|
42
|
-
readonly barWidth: number
|
|
43
|
-
readonly barFilledChar: string
|
|
44
|
-
readonly barEmptyChar: string
|
|
45
|
-
readonly warnThreshold: number
|
|
46
|
-
readonly errorThreshold: number
|
|
47
|
-
}
|
|
12
|
+
export type QuotaAppearance = SidebarAppearance
|
|
48
13
|
|
|
49
14
|
/**
|
|
50
15
|
* The OpenCode 1 preference defaults for the quota bar, for a renderer that
|
|
@@ -98,59 +63,12 @@ export const QUOTA_ORDER: readonly QuotaGroupKey[] = [
|
|
|
98
63
|
'gemini-argon',
|
|
99
64
|
]
|
|
100
65
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// Content width used until the first layout pass reports the real one. It
|
|
106
|
-
// fits the narrowest OpenCode sidebar.
|
|
107
|
-
export const ASSUMED_CONTENT_WIDTH = 28
|
|
108
|
-
|
|
109
|
-
// A window row is `<name> <bar> <figure> <reset>`. The bar shrinks to this
|
|
110
|
-
// before the reset column is dropped; below it the bar is dropped too.
|
|
111
|
-
const MIN_BAR_WIDTH = 4
|
|
112
|
-
// The widest figure the formatter writes: `100% left`.
|
|
113
|
-
const FIGURE_WIDTH = 9
|
|
114
|
-
// A window name (`5h`, `7d`) and the space after it.
|
|
115
|
-
const NAME_WIDTH = 3
|
|
116
|
-
|
|
117
|
-
export function quotaTone(
|
|
118
|
-
usedPct: number,
|
|
119
|
-
appearance: QuotaAppearance,
|
|
120
|
-
): QuotaTone {
|
|
121
|
-
if (usedPct < appearance.warnThreshold) return 'ok'
|
|
122
|
-
if (usedPct < appearance.errorThreshold) return 'warn'
|
|
123
|
-
return 'err'
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
interface BarSegment {
|
|
127
|
-
text: string
|
|
128
|
-
tone: QuotaTone
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function quotaBarSegments(
|
|
132
|
-
remainingPct: number,
|
|
133
|
-
width: number,
|
|
134
|
-
appearance: QuotaAppearance,
|
|
135
|
-
): BarSegment[] {
|
|
136
|
-
const usedCells = Math.max(
|
|
137
|
-
0,
|
|
138
|
-
Math.min(Math.round((remainingPct / 100) * width), width),
|
|
139
|
-
)
|
|
140
|
-
const tone = quotaTone(100 - remainingPct, appearance)
|
|
141
|
-
return [
|
|
142
|
-
{ text: appearance.barFilledChar.repeat(usedCells), tone },
|
|
143
|
-
{ text: appearance.barEmptyChar.repeat(width - usedCells), tone },
|
|
144
|
-
].filter((segment) => segment.text.length > 0)
|
|
66
|
+
export function quotaTone(usedPct: number, appearance: QuotaAppearance): Tone {
|
|
67
|
+
if (usedPct < appearance.warnThreshold) return 'success'
|
|
68
|
+
if (usedPct < appearance.errorThreshold) return 'warning'
|
|
69
|
+
return 'error'
|
|
145
70
|
}
|
|
146
71
|
|
|
147
|
-
// --- Width-fitted quota rows ------------------------------------------------
|
|
148
|
-
//
|
|
149
|
-
// The host sidebars are about 20 to 48 columns wide. Every quota line is
|
|
150
|
-
// sized from the measured content width so that it fits on one line: text is
|
|
151
|
-
// never left to the renderer's wrapping, which breaks a row mid-word or down
|
|
152
|
-
// to one character per line once the right-hand column runs out of room.
|
|
153
|
-
|
|
154
72
|
export interface AccountWindow {
|
|
155
73
|
key: QuotaGroupKey
|
|
156
74
|
reading: QuotaReading
|
|
@@ -187,212 +105,3 @@ export function accountWindows(
|
|
|
187
105
|
}
|
|
188
106
|
return result
|
|
189
107
|
}
|
|
190
|
-
|
|
191
|
-
// A window shows its figure only while no reset has happened since it was
|
|
192
|
-
// read and it has a read time at all.
|
|
193
|
-
export function showsFigure(window: AccountWindow): boolean {
|
|
194
|
-
return window.text.remaining != null && !window.text.resetSinceReading
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
interface WindowRowLayout {
|
|
198
|
-
bar: number
|
|
199
|
-
reset: boolean
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Column widths for one `<name> <bar> <figure> <reset>` row within `width`
|
|
203
|
-
// cells. The bar shrinks first, down to MIN_BAR_WIDTH; then the reset column
|
|
204
|
-
// is dropped; when even that leaves less than MIN_BAR_WIDTH cells for the
|
|
205
|
-
// bar, the bar is left out and the row is just the name and figure.
|
|
206
|
-
function windowRowLayout(
|
|
207
|
-
width: number,
|
|
208
|
-
named: boolean,
|
|
209
|
-
resetWidth: number,
|
|
210
|
-
maxBar: number,
|
|
211
|
-
): WindowRowLayout {
|
|
212
|
-
const room = width - (named ? NAME_WIDTH : 0) - FIGURE_WIDTH
|
|
213
|
-
if (resetWidth > 0) {
|
|
214
|
-
const bar = Math.min(maxBar, room - resetWidth - 2)
|
|
215
|
-
if (bar >= MIN_BAR_WIDTH) return { bar, reset: true }
|
|
216
|
-
}
|
|
217
|
-
const bar = Math.min(maxBar, room - 1)
|
|
218
|
-
return { bar: bar >= MIN_BAR_WIDTH ? bar : 0, reset: false }
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Shorten a label to `max` cells, marking the cut with an ellipsis.
|
|
222
|
-
export function fitLabel(label: string, max: number): string {
|
|
223
|
-
if (label.length <= max) return label
|
|
224
|
-
if (max <= 0) return ''
|
|
225
|
-
if (max === 1) return '…'
|
|
226
|
-
return `${label.slice(0, max - 1)}…`
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// One quota window on one line. The bar fills with remaining quota; the
|
|
230
|
-
// figure and reset come from the shared formatter. A window that reset since
|
|
231
|
-
// its reading shows that fact, dim, in place of the stale figure.
|
|
232
|
-
function WindowRow(props: {
|
|
233
|
-
palette: QuotaPalette
|
|
234
|
-
appearance: QuotaAppearance
|
|
235
|
-
window: AccountWindow
|
|
236
|
-
layout: WindowRowLayout
|
|
237
|
-
}): JSX.Element {
|
|
238
|
-
const text = () => props.window.text
|
|
239
|
-
const tone = () => quotaTone(100 - (text().remaining ?? 0), props.appearance)
|
|
240
|
-
return (
|
|
241
|
-
<box width='100%' flexDirection='row'>
|
|
242
|
-
<Show when={text().name !== ''}>
|
|
243
|
-
<text
|
|
244
|
-
width={NAME_WIDTH}
|
|
245
|
-
flexShrink={0}
|
|
246
|
-
wrapMode='none'
|
|
247
|
-
fg={props.palette.muted()}
|
|
248
|
-
>
|
|
249
|
-
{text().name}
|
|
250
|
-
</text>
|
|
251
|
-
</Show>
|
|
252
|
-
<Show
|
|
253
|
-
when={showsFigure(props.window)}
|
|
254
|
-
fallback={
|
|
255
|
-
<text flexShrink={1} wrapMode='none' fg={props.palette.muted()}>
|
|
256
|
-
{text().resetSinceReading ? RESET_SINCE_READING : text().figure}
|
|
257
|
-
</text>
|
|
258
|
-
}
|
|
259
|
-
>
|
|
260
|
-
<Show when={props.layout.bar > 0}>
|
|
261
|
-
<box width={props.layout.bar + 1} flexShrink={0} flexDirection='row'>
|
|
262
|
-
<For
|
|
263
|
-
each={quotaBarSegments(
|
|
264
|
-
text().remaining ?? 0,
|
|
265
|
-
props.layout.bar,
|
|
266
|
-
props.appearance,
|
|
267
|
-
)}
|
|
268
|
-
>
|
|
269
|
-
{(segment) => (
|
|
270
|
-
<text wrapMode='none' fg={props.palette.tone(segment.tone)}>
|
|
271
|
-
{segment.text}
|
|
272
|
-
</text>
|
|
273
|
-
)}
|
|
274
|
-
</For>
|
|
275
|
-
</box>
|
|
276
|
-
</Show>
|
|
277
|
-
<text flexShrink={0} wrapMode='none' fg={props.palette.tone(tone())}>
|
|
278
|
-
{text().figure}
|
|
279
|
-
</text>
|
|
280
|
-
<box flexGrow={1} />
|
|
281
|
-
<Show when={props.layout.reset && text().reset !== ''}>
|
|
282
|
-
<text flexShrink={0} wrapMode='none' fg={props.palette.muted()}>
|
|
283
|
-
{text().reset}
|
|
284
|
-
</text>
|
|
285
|
-
</Show>
|
|
286
|
-
</Show>
|
|
287
|
-
</box>
|
|
288
|
-
)
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* One account's quota block. The header line is the account label, the
|
|
293
|
-
* reading age when the oldest reading is stale, and the caller's status word
|
|
294
|
-
* right-aligned; the age moves to its own dim line when the three do not
|
|
295
|
-
* fit. Below it each quota group present gets a plain-word header and one
|
|
296
|
-
* row per window, or a single dim line when there is no reading at all.
|
|
297
|
-
* `children`, when given, render after the quota rows.
|
|
298
|
-
*/
|
|
299
|
-
export function QuotaAccountBlock(props: {
|
|
300
|
-
palette: QuotaPalette
|
|
301
|
-
appearance: QuotaAppearance
|
|
302
|
-
account: QuotaLayoutAccount
|
|
303
|
-
status: string
|
|
304
|
-
statusTone: QuotaTone
|
|
305
|
-
now: () => number
|
|
306
|
-
width: () => number
|
|
307
|
-
marginTop?: number
|
|
308
|
-
children?: JSX.Element
|
|
309
|
-
}): JSX.Element {
|
|
310
|
-
const windows = () => accountWindows(props.account, props.now())
|
|
311
|
-
const age = () =>
|
|
312
|
-
quotaReadingAge(
|
|
313
|
-
windows().map((window) => window.reading),
|
|
314
|
-
props.now(),
|
|
315
|
-
)
|
|
316
|
-
const ageInline = () =>
|
|
317
|
-
age() !== '' &&
|
|
318
|
-
props.account.label.length + 3 + age().length + 1 + props.status.length <=
|
|
319
|
-
props.width()
|
|
320
|
-
const label = () =>
|
|
321
|
-
fitLabel(props.account.label, props.width() - 1 - props.status.length)
|
|
322
|
-
// One reset column width per account, so bars line up across its rows.
|
|
323
|
-
const resetWidth = () =>
|
|
324
|
-
Math.max(
|
|
325
|
-
0,
|
|
326
|
-
...windows()
|
|
327
|
-
.filter(showsFigure)
|
|
328
|
-
.map((window) => window.text.reset.length),
|
|
329
|
-
)
|
|
330
|
-
const layoutFor = (window: AccountWindow) =>
|
|
331
|
-
windowRowLayout(
|
|
332
|
-
props.width(),
|
|
333
|
-
window.text.name !== '',
|
|
334
|
-
resetWidth(),
|
|
335
|
-
props.appearance.barWidth,
|
|
336
|
-
)
|
|
337
|
-
const groups = () =>
|
|
338
|
-
QUOTA_ORDER.map((key) => ({
|
|
339
|
-
key,
|
|
340
|
-
windows: windows().filter((window) => window.key === key),
|
|
341
|
-
})).filter((group) => group.windows.length > 0)
|
|
342
|
-
return (
|
|
343
|
-
<box width='100%' flexDirection='column' marginTop={props.marginTop ?? 0}>
|
|
344
|
-
<box width='100%' flexDirection='row'>
|
|
345
|
-
<text flexShrink={0} wrapMode='none' fg={props.palette.text()}>
|
|
346
|
-
<b>{label()}</b>
|
|
347
|
-
</text>
|
|
348
|
-
<Show when={ageInline()}>
|
|
349
|
-
<text flexShrink={0} wrapMode='none' fg={props.palette.muted()}>
|
|
350
|
-
{` · ${age()}`}
|
|
351
|
-
</text>
|
|
352
|
-
</Show>
|
|
353
|
-
<box flexGrow={1} />
|
|
354
|
-
<text
|
|
355
|
-
flexShrink={0}
|
|
356
|
-
wrapMode='none'
|
|
357
|
-
fg={props.palette.tone(props.statusTone)}
|
|
358
|
-
>
|
|
359
|
-
<b>{props.status}</b>
|
|
360
|
-
</text>
|
|
361
|
-
</box>
|
|
362
|
-
<Show when={age() !== '' && !ageInline()}>
|
|
363
|
-
<text wrapMode='none' fg={props.palette.muted()}>
|
|
364
|
-
{age()}
|
|
365
|
-
</text>
|
|
366
|
-
</Show>
|
|
367
|
-
<Show
|
|
368
|
-
when={groups().length > 0}
|
|
369
|
-
fallback={
|
|
370
|
-
<text wrapMode='none' fg={props.palette.muted()}>
|
|
371
|
-
{NO_QUOTA_READING}
|
|
372
|
-
</text>
|
|
373
|
-
}
|
|
374
|
-
>
|
|
375
|
-
<For each={groups()}>
|
|
376
|
-
{(group) => (
|
|
377
|
-
<>
|
|
378
|
-
<text wrapMode='none' fg={props.palette.muted()}>
|
|
379
|
-
{GROUP_NAMES[group.key]}
|
|
380
|
-
</text>
|
|
381
|
-
<For each={group.windows}>
|
|
382
|
-
{(window) => (
|
|
383
|
-
<WindowRow
|
|
384
|
-
palette={props.palette}
|
|
385
|
-
appearance={props.appearance}
|
|
386
|
-
window={window}
|
|
387
|
-
layout={layoutFor(window)}
|
|
388
|
-
/>
|
|
389
|
-
)}
|
|
390
|
-
</For>
|
|
391
|
-
</>
|
|
392
|
-
)}
|
|
393
|
-
</For>
|
|
394
|
-
</Show>
|
|
395
|
-
{props.children}
|
|
396
|
-
</box>
|
|
397
|
-
)
|
|
398
|
-
}
|