@cortexkit/opencode-antigravity-auth 3.0.20 → 3.0.22

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.
Files changed (107) hide show
  1. package/dist/cli.js +354 -278
  2. package/dist/cli.js.map +3 -3
  3. package/dist/cli.meta.json +66 -21
  4. package/dist/index.js +841 -392
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +123 -28
  7. package/dist/server.js +860 -411
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/claustrum/custody.js +25 -0
  11. package/dist/src/common-auth-embedded/claustrum/hub.js +20 -1
  12. package/dist/src/common-auth-embedded/claustrum/insula.js +6 -0
  13. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
  14. package/dist/src/common-auth-embedded/fs/with-lock.js +37 -10
  15. package/dist/src/common-auth-embedded/quota/format.d.ts +9 -4
  16. package/dist/src/common-auth-embedded/quota/format.js +45 -26
  17. package/dist/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
  18. package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +654 -0
  19. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  20. package/dist/src/common-auth-embedded/routing-accessor/index.js +128 -0
  21. package/dist/src/common-auth-embedded/source-output.json +69 -29
  22. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  23. package/dist/src/ga/tui/host-ga.js +2 -2
  24. package/dist/src/ga/tui/host-ga.js.map +1 -1
  25. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  26. package/dist/src/plugin/index.d.ts.map +1 -1
  27. package/dist/src/plugin/index.js +2 -0
  28. package/dist/src/plugin/index.js.map +1 -1
  29. package/dist/src/plugin/request.d.ts.map +1 -1
  30. package/dist/src/plugin/request.js +1 -0
  31. package/dist/src/plugin/request.js.map +1 -1
  32. package/dist/src/plugin/shared/request-services.d.ts +6 -0
  33. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  34. package/dist/src/plugin/shared/request-services.js +89 -2
  35. package/dist/src/plugin/shared/request-services.js.map +1 -1
  36. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  37. package/dist/src/plugin/shared/vault-request-credentials.js +4 -0
  38. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  39. package/dist/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
  40. package/dist/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
  41. package/dist/src/plugin/shared/vault-routing-purpose.js +18 -0
  42. package/dist/src/plugin/shared/vault-routing-purpose.js.map +1 -0
  43. package/dist/src/plugin/shared/vault-routing.d.ts +36 -0
  44. package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -0
  45. package/dist/src/plugin/shared/vault-routing.js +213 -0
  46. package/dist/src/plugin/shared/vault-routing.js.map +1 -0
  47. package/dist/src/plugin/types.d.ts +1 -0
  48. package/dist/src/plugin/types.d.ts.map +1 -1
  49. package/dist/src/tui/quota-layout.d.ts +4 -58
  50. package/dist/src/tui/quota-layout.d.ts.map +1 -1
  51. package/dist/src/tui/quota-layout.js +4 -90
  52. package/dist/src/tui/quota-layout.js.map +1 -1
  53. package/dist/src/tui/sidebar-frame.d.ts +4 -34
  54. package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
  55. package/dist/src/tui/sidebar-frame.js +93 -167
  56. package/dist/src/tui/sidebar-frame.js.map +1 -1
  57. package/dist/src/tui.js +2 -2
  58. package/dist/src/tui.js.map +1 -1
  59. package/dist/tui-build-map.json +31 -17
  60. package/dist/tui-ga-build-map.json +32 -17
  61. package/dist/types/src/common-auth-embedded/quota/format.d.ts +9 -4
  62. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  63. package/dist/types/src/plugin/index.d.ts.map +1 -1
  64. package/dist/types/src/plugin/request.d.ts.map +1 -1
  65. package/dist/types/src/plugin/shared/request-services.d.ts +6 -0
  66. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  67. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  68. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
  69. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
  70. package/dist/types/src/plugin/shared/vault-routing.d.ts +36 -0
  71. package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -0
  72. package/dist/types/src/plugin/types.d.ts +1 -0
  73. package/dist/types/src/plugin/types.d.ts.map +1 -1
  74. package/package.json +2 -2
  75. package/src/common-auth-embedded/claustrum/custody.js +25 -0
  76. package/src/common-auth-embedded/claustrum/hub.js +20 -1
  77. package/src/common-auth-embedded/claustrum/insula.js +6 -0
  78. package/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
  79. package/src/common-auth-embedded/fs/with-lock.js +37 -10
  80. package/src/common-auth-embedded/quota/format.d.ts +9 -4
  81. package/src/common-auth-embedded/quota/format.js +45 -26
  82. package/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
  83. package/src/common-auth-embedded/quota-sidebar/index.tsx +654 -0
  84. package/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  85. package/src/common-auth-embedded/routing-accessor/index.js +128 -0
  86. package/src/common-auth-embedded/source-output.json +69 -29
  87. package/src/tui-compiled/common-auth-embedded/quota/format.js +45 -26
  88. package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +683 -0
  89. package/src/tui-compiled/tui/quota-layout.js +5 -330
  90. package/src/tui-compiled/tui/sidebar-frame.js +243 -467
  91. package/src/tui-compiled/tui.js +2 -2
  92. package/src/tui-ga-compiled/host-ga.js +2 -2
  93. package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +45 -26
  94. package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +243 -467
  95. package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +5 -330
  96. package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +683 -0
  97. package/src/tui-ga-raw/host-ga.tsx +2 -2
  98. package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +45 -26
  99. package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +214 -400
  100. package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +10 -301
  101. package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +654 -0
  102. package/src/tui-raw/common-auth-embedded/quota/format.js +45 -26
  103. package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +654 -0
  104. package/src/tui-raw/tui/quota-layout.tsx +10 -301
  105. package/src/tui-raw/tui/sidebar-frame.tsx +214 -400
  106. package/src/tui-raw/tui.tsx +2 -2
  107. package/src/tui.tsx +2 -2
@@ -1,50 +1,15 @@
1
- /** @jsxImportSource @opentui/solid */
2
-
3
- /**
4
- * Quota layout shared by the OpenCode 1 sidebar (`tui.tsx`) and the OpenCode 2
5
- * sidebar (`ga/tui/host-ga.tsx`): one account block with its header line, the
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 QuotaTone = 'ok' | 'warn' | 'err' | 'muted' | 'accent' | 'text'
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
- // Shown instead of a stored figure once the window has reset since it was
102
- // read: the stored figure describes the window before the reset.
103
- export const RESET_SINCE_READING = 'reset since last check'
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
- }