@cortexkit/opencode-antigravity-auth 3.0.34 → 3.0.36
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 +413 -182
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +196 -69
- package/dist/index.js +506 -245
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +217 -90
- package/dist/server.js +1185 -860
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/auth-menu/accounts.js +9 -3
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +5 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.js +14 -5
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +11 -8
- package/dist/src/common-auth-embedded/claustrum/custody.js +26 -15
- package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +2 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.js +7 -0
- package/dist/src/common-auth-embedded/claustrum/host.d.ts +8 -0
- package/dist/src/common-auth-embedded/claustrum/host.js +113 -0
- package/dist/src/common-auth-embedded/claustrum/hub.d.ts +5 -1
- package/dist/src/common-auth-embedded/claustrum/hub.js +5 -2
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +2 -1
- package/dist/src/common-auth-embedded/claustrum/index.js +2 -1
- package/dist/src/common-auth-embedded/opencode2/install.js +42 -9
- package/dist/src/common-auth-embedded/opencode2/types.d.ts +3 -1
- package/dist/src/common-auth-embedded/setup/command.js +8 -4
- package/dist/src/common-auth-embedded/setup/enroll.js +3 -0
- package/dist/src/common-auth-embedded/source-output.json +68 -52
- package/dist/src/ga/rpc/protocol.d.ts +1 -0
- package/dist/src/ga/rpc/protocol.d.ts.map +1 -1
- package/dist/src/ga/rpc/protocol.js +4 -1
- package/dist/src/ga/rpc/protocol.js.map +1 -1
- package/dist/src/ga/server/auth.d.ts.map +1 -1
- package/dist/src/ga/server/auth.js +27 -4
- package/dist/src/ga/server/auth.js.map +1 -1
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +5 -1
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/ga/tui/host-ga.d.ts +22 -58
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +161 -248
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.d.ts +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +4 -4
- package/dist/src/plugin/auth-loader.js +1 -1
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/background-vault-quota-refresh.js +1 -1
- package/dist/src/plugin/background-vault-quota-refresh.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts +1 -0
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +87 -51
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +2 -2
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/shared/source-sidebar.js +1 -1
- package/dist/src/plugin/shared/source-sidebar.js.map +1 -1
- package/dist/src/plugin/vault-activation.d.ts.map +1 -1
- package/dist/src/plugin/vault-activation.js +10 -2
- package/dist/src/plugin/vault-activation.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +25 -3
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/src/runtime-layout.js +3 -3
- package/dist/src/runtime-layout.js.map +1 -1
- package/dist/src/setup.d.ts.map +1 -1
- package/dist/src/setup.js +8 -5
- package/dist/src/setup.js.map +1 -1
- package/dist/tui-build-map.json +1 -1
- package/dist/tui-ga-build-map.json +5 -5
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +5 -1
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +11 -8
- package/dist/types/src/common-auth-embedded/claustrum/enrollment.d.ts +2 -0
- package/dist/types/src/common-auth-embedded/claustrum/host.d.ts +8 -0
- package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +5 -1
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +3 -1
- package/dist/types/src/ga/rpc/protocol.d.ts +1 -0
- package/dist/types/src/ga/rpc/protocol.d.ts.map +1 -1
- package/dist/types/src/ga/server/auth.d.ts.map +1 -1
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/plugin/ga-location-services.d.ts +1 -0
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-activation.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/types/src/setup.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common-auth-embedded/auth-menu/accounts.js +9 -3
- package/src/common-auth-embedded/claustrum/consumer.d.ts +5 -1
- package/src/common-auth-embedded/claustrum/consumer.js +14 -5
- package/src/common-auth-embedded/claustrum/custody.d.ts +11 -8
- package/src/common-auth-embedded/claustrum/custody.js +26 -15
- package/src/common-auth-embedded/claustrum/enrollment.d.ts +2 -0
- package/src/common-auth-embedded/claustrum/enrollment.js +7 -0
- package/src/common-auth-embedded/claustrum/host.d.ts +8 -0
- package/src/common-auth-embedded/claustrum/host.js +113 -0
- package/src/common-auth-embedded/claustrum/hub.d.ts +5 -1
- package/src/common-auth-embedded/claustrum/hub.js +5 -2
- package/src/common-auth-embedded/claustrum/index.d.ts +2 -1
- package/src/common-auth-embedded/claustrum/index.js +2 -1
- package/src/common-auth-embedded/opencode2/install.js +42 -9
- package/src/common-auth-embedded/opencode2/types.d.ts +3 -1
- package/src/common-auth-embedded/setup/command.js +8 -4
- package/src/common-auth-embedded/setup/enroll.js +3 -0
- package/src/common-auth-embedded/source-output.json +68 -52
- package/src/tui-ga-compiled/host-ga.js +133 -241
- package/src/tui-ga-raw/host-ga.tsx +222 -315
|
@@ -31,11 +31,10 @@
|
|
|
31
31
|
* not match is refused and logged by field name only.
|
|
32
32
|
*
|
|
33
33
|
* The wire shapes mirror the facade's `ga/rpc/protocol.ts` (clean v1:
|
|
34
|
-
* accounts carry opaque `selector`s
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* it; after every apply the menu is rebuilt from a fresh `state` read.
|
|
34
|
+
* accounts carry opaque `selector`s and every snapshot carries the location's
|
|
35
|
+
* settings). Notifications and apply answers carry the server's shared menu.
|
|
36
|
+
* The drawer keeps its presentation while submitting the issued menu item
|
|
37
|
+
* and action ids, never a sidebar selector or an account position.
|
|
39
38
|
*
|
|
40
39
|
* Nothing here imports account storage, tokens, OAuth, the vault client or
|
|
41
40
|
* server code, and nothing writes to the terminal or forces a theme.
|
|
@@ -59,10 +58,15 @@ import {
|
|
|
59
58
|
type MenuAction,
|
|
60
59
|
type MenuApplyRequest,
|
|
61
60
|
type MenuApplyResult,
|
|
61
|
+
type MenuDialogPayload,
|
|
62
62
|
type MenuModel,
|
|
63
|
+
type MenuNotifyPayload,
|
|
63
64
|
type MenuParseResult,
|
|
64
65
|
type MenuSection,
|
|
65
66
|
type MenuUi,
|
|
67
|
+
parseMenuApplyResult,
|
|
68
|
+
parseMenuDialogPayload,
|
|
69
|
+
parseMenuNotifyPayload,
|
|
66
70
|
} from "./shared/07365a7d2ccade4c-host-api.js"
|
|
67
71
|
import {
|
|
68
72
|
AntigravitySidebar,
|
|
@@ -186,16 +190,6 @@ export type GaScope =
|
|
|
186
190
|
| { readonly kind: 'session'; readonly sessionID: string }
|
|
187
191
|
| { readonly kind: 'sessionless' }
|
|
188
192
|
|
|
189
|
-
/** The dialog commands the server names in notifications and text applies. */
|
|
190
|
-
export const GA_COMMANDS = [
|
|
191
|
-
'antigravity-quota',
|
|
192
|
-
'antigravity-account',
|
|
193
|
-
'antigravity-killswitch',
|
|
194
|
-
'antigravity-dump',
|
|
195
|
-
'antigravity-logging',
|
|
196
|
-
] as const
|
|
197
|
-
export type GaCommand = (typeof GA_COMMANDS)[number]
|
|
198
|
-
|
|
199
193
|
export const GA_LOG_LEVELS = [
|
|
200
194
|
'error',
|
|
201
195
|
'warn',
|
|
@@ -207,9 +201,7 @@ export type GaLogLevel = (typeof GA_LOG_LEVELS)[number]
|
|
|
207
201
|
|
|
208
202
|
export interface GaNotification {
|
|
209
203
|
readonly cursor: number
|
|
210
|
-
readonly
|
|
211
|
-
readonly command: GaCommand
|
|
212
|
-
readonly text: string
|
|
204
|
+
readonly payload: MenuDialogPayload | MenuNotifyPayload
|
|
213
205
|
}
|
|
214
206
|
|
|
215
207
|
/** A redacted account plus the opaque selector that names its credential. */
|
|
@@ -233,6 +225,7 @@ export type GaAccountsStatus =
|
|
|
233
225
|
| { readonly kind: 'over-limit'; readonly count: number; readonly limit: 64 }
|
|
234
226
|
|
|
235
227
|
export interface GaSnapshot {
|
|
228
|
+
readonly vaultHostStatus?: 'Served by Thalamus'
|
|
236
229
|
readonly kind: 'snapshot'
|
|
237
230
|
readonly generation: string
|
|
238
231
|
readonly scope: GaScope
|
|
@@ -253,39 +246,9 @@ export type GaStateOutput =
|
|
|
253
246
|
| GaSnapshot
|
|
254
247
|
| { readonly kind: 'disposed'; readonly generation: string }
|
|
255
248
|
|
|
256
|
-
/** A typed account action; accounts are named only by selector. */
|
|
257
|
-
export type GaAccountAction =
|
|
258
|
-
| {
|
|
259
|
-
readonly kind: 'select'
|
|
260
|
-
readonly selector: string
|
|
261
|
-
readonly target: 'active' | 'claude' | 'gemini'
|
|
262
|
-
}
|
|
263
|
-
| { readonly kind: 'enable'; readonly selector: string }
|
|
264
|
-
| { readonly kind: 'disable'; readonly selector: string }
|
|
265
|
-
| { readonly kind: 'remove'; readonly selector: string }
|
|
266
|
-
|
|
267
249
|
/** What the client sends besides version, generation and scope. */
|
|
268
|
-
export
|
|
269
|
-
|
|
270
|
-
| {
|
|
271
|
-
readonly command: 'antigravity-account'
|
|
272
|
-
readonly action: GaAccountAction
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
export type GaTargetOutcome =
|
|
276
|
-
| 'applied'
|
|
277
|
-
| 'stale-target'
|
|
278
|
-
| 'unknown-target'
|
|
279
|
-
| 'unsupported-index-action'
|
|
280
|
-
| 'failed'
|
|
281
|
-
|
|
282
|
-
/** The command result fields this TUI reads; the rest are validated only. */
|
|
283
|
-
export interface GaCommandResult {
|
|
284
|
-
readonly command: GaCommand
|
|
285
|
-
readonly status: 'applied' | 'rejected' | 'failed'
|
|
286
|
-
readonly text: string
|
|
287
|
-
readonly authorizationUrl?: string | null
|
|
288
|
-
readonly targetOutcome?: GaTargetOutcome | null
|
|
250
|
+
export interface GaApplyBody {
|
|
251
|
+
readonly request: MenuApplyRequest
|
|
289
252
|
}
|
|
290
253
|
|
|
291
254
|
export type GaApplyOutput =
|
|
@@ -293,7 +256,7 @@ export type GaApplyOutput =
|
|
|
293
256
|
readonly kind: 'applied'
|
|
294
257
|
readonly generation: string
|
|
295
258
|
readonly scope: GaScope
|
|
296
|
-
readonly result:
|
|
259
|
+
readonly result: MenuApplyResult
|
|
297
260
|
}
|
|
298
261
|
| { readonly kind: 'stale-generation'; readonly generation: string }
|
|
299
262
|
| { readonly kind: 'disposed'; readonly generation: string }
|
|
@@ -303,13 +266,6 @@ const SESSION_ID = /^[\x21-\x7e]{1,256}$/
|
|
|
303
266
|
const ACCOUNT_ID = /^acct-(0|[1-9][0-9]{0,5})$/
|
|
304
267
|
const ACCOUNT_LABEL = /^Account [1-9][0-9]{0,5}$/
|
|
305
268
|
const SELECTOR = /^sel-[A-Za-z0-9_-]{32}$/
|
|
306
|
-
const TARGET_OUTCOMES: readonly GaTargetOutcome[] = [
|
|
307
|
-
'applied',
|
|
308
|
-
'stale-target',
|
|
309
|
-
'unknown-target',
|
|
310
|
-
'unsupported-index-action',
|
|
311
|
-
'failed',
|
|
312
|
-
]
|
|
313
269
|
|
|
314
270
|
type Issues = string[]
|
|
315
271
|
|
|
@@ -586,17 +542,16 @@ function checkNotification(value: unknown, path: string, issues: Issues) {
|
|
|
586
542
|
issues.push(`${path}: expected a notification`)
|
|
587
543
|
return
|
|
588
544
|
}
|
|
589
|
-
keys(value, ['cursor', '
|
|
545
|
+
keys(value, ['cursor', 'payload'], [], path, issues)
|
|
590
546
|
if (!isCursor(value.cursor) || value.cursor < 1) {
|
|
591
547
|
issues.push(`${path}.cursor: expected a positive cursor`)
|
|
592
548
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
if (typeof value.text !== 'string') issues.push(`${path}.text: expected text`)
|
|
549
|
+
const parsed =
|
|
550
|
+
isRecord(value.payload) && Object.hasOwn(value.payload, 'notify')
|
|
551
|
+
? parseMenuNotifyPayload(value.payload)
|
|
552
|
+
: parseMenuDialogPayload(value.payload)
|
|
553
|
+
if (!parsed.ok)
|
|
554
|
+
issues.push(...parsed.issues.map((issue) => `${path}.payload: ${issue}`))
|
|
600
555
|
}
|
|
601
556
|
|
|
602
557
|
function checkBool(value: unknown, path: string, issues: Issues) {
|
|
@@ -670,77 +625,6 @@ function checkAccountsStatus(value: unknown, path: string, issues: Issues) {
|
|
|
670
625
|
issues.push(`${path}.kind: unknown accounts status`)
|
|
671
626
|
}
|
|
672
627
|
|
|
673
|
-
function checkAccountList(value: unknown, path: string, issues: Issues) {
|
|
674
|
-
if (value === null) return
|
|
675
|
-
if (!Array.isArray(value) || value.length > 64) {
|
|
676
|
-
issues.push(`${path}: expected at most 64 accounts`)
|
|
677
|
-
return
|
|
678
|
-
}
|
|
679
|
-
value.forEach((entry, index) => {
|
|
680
|
-
checkAccount(entry, `${path}.${index}`, issues)
|
|
681
|
-
})
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
/** One command result, with the closed field list of its command. */
|
|
685
|
-
function checkCommandResult(value: unknown, path: string, issues: Issues) {
|
|
686
|
-
if (!isRecord(value)) {
|
|
687
|
-
issues.push(`${path}: expected a command result`)
|
|
688
|
-
return
|
|
689
|
-
}
|
|
690
|
-
const base = ['command', 'status', 'text']
|
|
691
|
-
if (
|
|
692
|
-
value.status !== 'applied' &&
|
|
693
|
-
value.status !== 'rejected' &&
|
|
694
|
-
value.status !== 'failed'
|
|
695
|
-
) {
|
|
696
|
-
issues.push(`${path}.status: unknown status`)
|
|
697
|
-
}
|
|
698
|
-
if (typeof value.text !== 'string') issues.push(`${path}.text: expected text`)
|
|
699
|
-
switch (value.command) {
|
|
700
|
-
case 'antigravity-quota':
|
|
701
|
-
keys(value, [...base, 'accounts'], [], path, issues)
|
|
702
|
-
checkAccountList(value.accounts, `${path}.accounts`, issues)
|
|
703
|
-
return
|
|
704
|
-
case 'antigravity-account':
|
|
705
|
-
keys(
|
|
706
|
-
value,
|
|
707
|
-
[...base, 'accounts', 'authorizationUrl', 'targetOutcome'],
|
|
708
|
-
[],
|
|
709
|
-
path,
|
|
710
|
-
issues,
|
|
711
|
-
)
|
|
712
|
-
checkAccountList(value.accounts, `${path}.accounts`, issues)
|
|
713
|
-
if (
|
|
714
|
-
value.authorizationUrl !== null &&
|
|
715
|
-
!(
|
|
716
|
-
typeof value.authorizationUrl === 'string' &&
|
|
717
|
-
/^https:\/\//.test(value.authorizationUrl) &&
|
|
718
|
-
value.authorizationUrl.length <= 4096
|
|
719
|
-
)
|
|
720
|
-
) {
|
|
721
|
-
issues.push(`${path}.authorizationUrl: expected an https link or null`)
|
|
722
|
-
}
|
|
723
|
-
if (
|
|
724
|
-
value.targetOutcome !== null &&
|
|
725
|
-
!TARGET_OUTCOMES.includes(value.targetOutcome as GaTargetOutcome)
|
|
726
|
-
) {
|
|
727
|
-
issues.push(`${path}.targetOutcome: unknown outcome`)
|
|
728
|
-
}
|
|
729
|
-
return
|
|
730
|
-
case 'antigravity-killswitch':
|
|
731
|
-
keys(value, [...base, 'killswitch'], [], path, issues)
|
|
732
|
-
return
|
|
733
|
-
case 'antigravity-dump':
|
|
734
|
-
keys(value, [...base, 'dump'], [], path, issues)
|
|
735
|
-
return
|
|
736
|
-
case 'antigravity-logging':
|
|
737
|
-
keys(value, [...base, 'logLevel'], [], path, issues)
|
|
738
|
-
return
|
|
739
|
-
default:
|
|
740
|
-
issues.push(`${path}.command: unknown command`)
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
|
|
744
628
|
/** Unwraps the host's `{ output }` answer. */
|
|
745
629
|
function unwrap(raw: unknown, issues: Issues): unknown {
|
|
746
630
|
if (!isRecord(raw)) {
|
|
@@ -794,11 +678,16 @@ export function parseGaStateAnswer(
|
|
|
794
678
|
'status',
|
|
795
679
|
'settings',
|
|
796
680
|
],
|
|
797
|
-
[],
|
|
681
|
+
['vaultHostStatus'],
|
|
798
682
|
'output',
|
|
799
683
|
issues,
|
|
800
684
|
)
|
|
801
685
|
if (!isCursor(output.readSeq)) issues.push('output.readSeq: expected a count')
|
|
686
|
+
if (
|
|
687
|
+
Object.hasOwn(output, 'vaultHostStatus') &&
|
|
688
|
+
output.vaultHostStatus !== 'Served by Thalamus'
|
|
689
|
+
)
|
|
690
|
+
issues.push('output.vaultHostStatus: expected the hosted vault status')
|
|
802
691
|
checkAccountsStatus(output.accountsStatus, 'output.accountsStatus', issues)
|
|
803
692
|
checkSettings(output.settings, 'output.settings', issues)
|
|
804
693
|
checkGeneration(output.generation, 'output.generation', issues)
|
|
@@ -864,7 +753,8 @@ export function parseGaApplyAnswer(
|
|
|
864
753
|
)
|
|
865
754
|
checkGeneration(output.generation, 'output.generation', issues)
|
|
866
755
|
checkScope(output.scope, 'output.scope', issues)
|
|
867
|
-
|
|
756
|
+
const result = parseMenuApplyResult(output.result)
|
|
757
|
+
if (!result.ok) issues.push(...result.issues)
|
|
868
758
|
return finish(output, issues)
|
|
869
759
|
}
|
|
870
760
|
|
|
@@ -906,7 +796,7 @@ export interface GaLocationClient {
|
|
|
906
796
|
/** The next cursor this client sends for `scope`. */
|
|
907
797
|
cursor(scope: GaScope): number
|
|
908
798
|
pull(scope: GaScope): Promise<GaPullResult>
|
|
909
|
-
apply(scope: GaScope, body: GaApplyBody): Promise<
|
|
799
|
+
apply(scope: GaScope, body: GaApplyBody): Promise<MenuApplyResult>
|
|
910
800
|
dispose(): void
|
|
911
801
|
disposed(): boolean
|
|
912
802
|
}
|
|
@@ -1026,26 +916,6 @@ export function createGaLocationClient(options: {
|
|
|
1026
916
|
|
|
1027
917
|
// ── Menu over the native state ──────────────────────────────────────────────
|
|
1028
918
|
|
|
1029
|
-
/**
|
|
1030
|
-
* GA notifications name only a dialog command, so this host builds the
|
|
1031
|
-
* `/antigravity` menu itself from the latest `state` answer: the accounts
|
|
1032
|
-
* with their opaque selectors and the location's settings, both read fresh
|
|
1033
|
-
* for that answer. The shared drawer renders it like the OpenCode 1 menu.
|
|
1034
|
-
* Each item and action id encodes what the action sends; an account is named
|
|
1035
|
-
* only by its selector, never by position or `acct-<n>` id.
|
|
1036
|
-
*/
|
|
1037
|
-
const SECTION_FOR_COMMAND: Readonly<Record<GaCommand, string>> = {
|
|
1038
|
-
'antigravity-account': 'accounts',
|
|
1039
|
-
'antigravity-quota': 'quota',
|
|
1040
|
-
'antigravity-killswitch': 'limits',
|
|
1041
|
-
'antigravity-dump': 'diagnostics',
|
|
1042
|
-
'antigravity-logging': 'diagnostics',
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
export function sectionForCommand(command: GaCommand): string {
|
|
1046
|
-
return SECTION_FOR_COMMAND[command]
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
919
|
const ACCOUNT_ITEM_PREFIX = 'account:'
|
|
1050
920
|
|
|
1051
921
|
function onOff(value: boolean): string {
|
|
@@ -1124,27 +994,35 @@ export function buildGaMenu(snapshot: GaSnapshot, now: number): MenuModel {
|
|
|
1124
994
|
'Use for Gemini',
|
|
1125
995
|
'Make this the current Gemini account.',
|
|
1126
996
|
),
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
997
|
+
...(snapshot.vaultHostStatus ||
|
|
998
|
+
settings.selectionStrategy === 'vault'
|
|
999
|
+
? []
|
|
1000
|
+
: [
|
|
1001
|
+
{
|
|
1002
|
+
id: 'remove',
|
|
1003
|
+
label: 'Remove',
|
|
1004
|
+
description: 'Delete this account from this machine.',
|
|
1005
|
+
knobs: [],
|
|
1006
|
+
confirm: {
|
|
1007
|
+
message: `Remove ${account.label}? This cannot be undone.`,
|
|
1008
|
+
irreversible: true,
|
|
1009
|
+
},
|
|
1010
|
+
},
|
|
1011
|
+
]),
|
|
1137
1012
|
],
|
|
1138
1013
|
}
|
|
1139
1014
|
}),
|
|
1140
|
-
actions:
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1015
|
+
actions:
|
|
1016
|
+
snapshot.vaultHostStatus || settings.selectionStrategy === 'vault'
|
|
1017
|
+
? []
|
|
1018
|
+
: [
|
|
1019
|
+
{
|
|
1020
|
+
id: 'add',
|
|
1021
|
+
label: 'Add account',
|
|
1022
|
+
description: 'Sign in with Google in your browser.',
|
|
1023
|
+
knobs: [],
|
|
1024
|
+
},
|
|
1025
|
+
],
|
|
1148
1026
|
},
|
|
1149
1027
|
{
|
|
1150
1028
|
id: 'quota',
|
|
@@ -1257,11 +1135,23 @@ export function buildGaMenu(snapshot: GaSnapshot, now: number): MenuModel {
|
|
|
1257
1135
|
return {
|
|
1258
1136
|
command: ANTIGRAVITY_MENU_COMMAND,
|
|
1259
1137
|
title: ANTIGRAVITY_MENU_TITLE,
|
|
1260
|
-
sections
|
|
1138
|
+
sections: snapshot.vaultHostStatus
|
|
1139
|
+
? [
|
|
1140
|
+
...sections,
|
|
1141
|
+
{
|
|
1142
|
+
id: 'vault',
|
|
1143
|
+
slot: 'extra',
|
|
1144
|
+
title: 'Vault',
|
|
1145
|
+
lines: [snapshot.vaultHostStatus],
|
|
1146
|
+
items: [],
|
|
1147
|
+
actions: [],
|
|
1148
|
+
},
|
|
1149
|
+
]
|
|
1150
|
+
: sections,
|
|
1261
1151
|
}
|
|
1262
1152
|
}
|
|
1263
1153
|
|
|
1264
|
-
/**
|
|
1154
|
+
/** A displayed choice is no longer present in the server-issued menu. */
|
|
1265
1155
|
export class GaMenuChoiceError extends Error {
|
|
1266
1156
|
constructor(message: string) {
|
|
1267
1157
|
super(message)
|
|
@@ -1269,130 +1159,144 @@ export class GaMenuChoiceError extends Error {
|
|
|
1269
1159
|
}
|
|
1270
1160
|
}
|
|
1271
1161
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
},
|
|
1277
|
-
'quota/refresh': { command: 'antigravity-quota', arguments: 'refresh' },
|
|
1278
|
-
'limits/killswitch-on': {
|
|
1279
|
-
command: 'antigravity-killswitch',
|
|
1280
|
-
arguments: 'enabled=true',
|
|
1281
|
-
},
|
|
1282
|
-
'limits/killswitch-off': {
|
|
1283
|
-
command: 'antigravity-killswitch',
|
|
1284
|
-
arguments: 'enabled=false',
|
|
1285
|
-
},
|
|
1286
|
-
'diagnostics/dump-on': { command: 'antigravity-dump', arguments: 'on' },
|
|
1287
|
-
'diagnostics/dump-off': { command: 'antigravity-dump', arguments: 'off' },
|
|
1162
|
+
export interface GaMenuPresentation {
|
|
1163
|
+
readonly menu: MenuModel
|
|
1164
|
+
readonly source: MenuModel
|
|
1165
|
+
request(choice: MenuApplyRequest): MenuApplyRequest
|
|
1288
1166
|
}
|
|
1289
1167
|
|
|
1290
1168
|
/**
|
|
1291
|
-
*
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
1169
|
+
* Keep the drawer's labels and order, but bind every choice to an action
|
|
1170
|
+
* actually issued by the server. Snapshot selectors are display data, not
|
|
1171
|
+
* shared-menu item ids. The bindings retain the server's exact item id even
|
|
1172
|
+
* when the roster changes before a choice arrives.
|
|
1295
1173
|
*/
|
|
1296
|
-
export function
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
throw new GaMenuChoiceError('Unknown menu entry.')
|
|
1328
|
-
}
|
|
1329
|
-
const fixed = TEXT_ACTIONS[key]
|
|
1330
|
-
if (fixed) return fixed
|
|
1331
|
-
if (key === 'limits/killswitch-minimum') {
|
|
1332
|
-
const percent = request.values.percent
|
|
1333
|
-
if (
|
|
1334
|
-
typeof percent !== 'number' ||
|
|
1335
|
-
!Number.isInteger(percent) ||
|
|
1336
|
-
percent < 0 ||
|
|
1337
|
-
percent > 100
|
|
1338
|
-
) {
|
|
1339
|
-
throw new GaMenuChoiceError(
|
|
1340
|
-
'The minimum must be a whole number from 0 to 100.',
|
|
1341
|
-
)
|
|
1342
|
-
}
|
|
1174
|
+
export function presentGaMenu(
|
|
1175
|
+
snapshot: GaSnapshot,
|
|
1176
|
+
now: number,
|
|
1177
|
+
source: MenuModel,
|
|
1178
|
+
): GaMenuPresentation {
|
|
1179
|
+
const bindings = new Map<
|
|
1180
|
+
string,
|
|
1181
|
+
(choice: MenuApplyRequest) => MenuApplyRequest
|
|
1182
|
+
>()
|
|
1183
|
+
const key = (
|
|
1184
|
+
sectionId: string,
|
|
1185
|
+
itemId: string | undefined,
|
|
1186
|
+
actionId: string,
|
|
1187
|
+
) => JSON.stringify([sectionId, itemId, actionId])
|
|
1188
|
+
const bind = (
|
|
1189
|
+
sectionId: string,
|
|
1190
|
+
itemId: string | undefined,
|
|
1191
|
+
display: MenuAction,
|
|
1192
|
+
action: MenuAction,
|
|
1193
|
+
values: (
|
|
1194
|
+
choice: MenuApplyRequest['values'],
|
|
1195
|
+
) => MenuApplyRequest['values'] = (choice) => choice,
|
|
1196
|
+
): MenuAction => {
|
|
1197
|
+
bindings.set(key(sectionId, itemId, display.id), (choice) => ({
|
|
1198
|
+
command: source.command,
|
|
1199
|
+
sectionId,
|
|
1200
|
+
...(itemId === undefined ? {} : { itemId }),
|
|
1201
|
+
actionId: action.id,
|
|
1202
|
+
values: values(choice.values),
|
|
1203
|
+
...(choice.confirmed ? { confirmed: true } : {}),
|
|
1204
|
+
}))
|
|
1343
1205
|
return {
|
|
1344
|
-
|
|
1345
|
-
|
|
1206
|
+
...display,
|
|
1207
|
+
...(action.confirm ? { confirm: action.confirm } : {}),
|
|
1346
1208
|
}
|
|
1347
1209
|
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
)
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1210
|
+
const display = buildGaMenu(snapshot, now)
|
|
1211
|
+
const sections = display.sections
|
|
1212
|
+
.filter((section) => section.slot !== 'extra')
|
|
1213
|
+
.flatMap((section) => {
|
|
1214
|
+
const actual = source.sections.find(
|
|
1215
|
+
(candidate) => candidate.id === section.id,
|
|
1216
|
+
)
|
|
1217
|
+
if (!actual) return []
|
|
1218
|
+
const actions = section.actions.flatMap((action) => {
|
|
1219
|
+
const id =
|
|
1220
|
+
section.id === 'limits'
|
|
1221
|
+
? 'set'
|
|
1222
|
+
: action.id === 'log-level'
|
|
1223
|
+
? 'logging'
|
|
1224
|
+
: action.id.startsWith('dump-')
|
|
1225
|
+
? 'dump'
|
|
1226
|
+
: action.id
|
|
1227
|
+
const offered = actual.actions.find((candidate) => candidate.id === id)
|
|
1228
|
+
if (!offered) return []
|
|
1229
|
+
const values =
|
|
1230
|
+
section.id !== 'limits'
|
|
1231
|
+
? undefined
|
|
1232
|
+
: action.id === 'killswitch-minimum'
|
|
1233
|
+
? (input: MenuApplyRequest['values']) => ({
|
|
1234
|
+
minimumRemainingPercent: input.percent ?? null,
|
|
1235
|
+
})
|
|
1236
|
+
: () => ({ enabled: action.id === 'killswitch-on' })
|
|
1237
|
+
return [bind(actual.id, undefined, action, offered, values)]
|
|
1238
|
+
})
|
|
1239
|
+
const items = actual.items.map((item) => {
|
|
1240
|
+
const projected = section.items.find(
|
|
1241
|
+
(candidate) => candidate.label === item.label,
|
|
1242
|
+
)
|
|
1243
|
+
if (!projected) return { ...item, actions: [] }
|
|
1244
|
+
return {
|
|
1245
|
+
...projected,
|
|
1246
|
+
id: item.id,
|
|
1247
|
+
actions: projected.actions.flatMap((action) => {
|
|
1248
|
+
const target = action.id.startsWith('select-')
|
|
1249
|
+
? action.id.slice('select-'.length)
|
|
1250
|
+
: undefined
|
|
1251
|
+
const offered = item.actions.find(
|
|
1252
|
+
(candidate) => candidate.id === (target ? 'select' : action.id),
|
|
1253
|
+
)
|
|
1254
|
+
if (!offered) return []
|
|
1255
|
+
return [
|
|
1256
|
+
bind(
|
|
1257
|
+
actual.id,
|
|
1258
|
+
item.id,
|
|
1259
|
+
action,
|
|
1260
|
+
offered,
|
|
1261
|
+
target ? () => ({ target }) : undefined,
|
|
1262
|
+
),
|
|
1263
|
+
]
|
|
1264
|
+
}),
|
|
1265
|
+
}
|
|
1266
|
+
})
|
|
1267
|
+
return [{ ...section, items, actions }]
|
|
1268
|
+
})
|
|
1269
|
+
// Enrollment and hosted status remain the server's own sections, including
|
|
1270
|
+
// their authority-dependent Connect/Disconnect actions and read-only host.
|
|
1271
|
+
for (const section of source.sections.filter(
|
|
1272
|
+
(candidate) => candidate.slot === 'extra',
|
|
1273
|
+
)) {
|
|
1274
|
+
sections.push({
|
|
1275
|
+
...section,
|
|
1276
|
+
actions: section.actions.map((action) =>
|
|
1277
|
+
bind(section.id, undefined, action, action),
|
|
1278
|
+
),
|
|
1279
|
+
items: section.items.map((item) => ({
|
|
1280
|
+
...item,
|
|
1281
|
+
actions: item.actions.map((action) =>
|
|
1282
|
+
bind(section.id, item.id, action, action),
|
|
1283
|
+
),
|
|
1284
|
+
})),
|
|
1285
|
+
})
|
|
1389
1286
|
}
|
|
1390
1287
|
return {
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1288
|
+
menu: { ...display, sections },
|
|
1289
|
+
source,
|
|
1290
|
+
request(choice) {
|
|
1291
|
+
const resolve = bindings.get(
|
|
1292
|
+
key(choice.sectionId, choice.itemId, choice.actionId),
|
|
1293
|
+
)
|
|
1294
|
+
if (choice.command !== source.command || !resolve)
|
|
1295
|
+
throw new GaMenuChoiceError(
|
|
1296
|
+
'That action is no longer offered. Open the menu again.',
|
|
1297
|
+
)
|
|
1298
|
+
return resolve(choice)
|
|
1299
|
+
},
|
|
1396
1300
|
}
|
|
1397
1301
|
}
|
|
1398
1302
|
|
|
@@ -1677,7 +1581,7 @@ export function setupGaTui(
|
|
|
1677
1581
|
),
|
|
1678
1582
|
})
|
|
1679
1583
|
|
|
1680
|
-
//
|
|
1584
|
+
// Sidebar readings and presentation are scoped to the menu's own session.
|
|
1681
1585
|
const latest = new Map<string, GaSnapshot>()
|
|
1682
1586
|
|
|
1683
1587
|
const showSnapshot = (snapshot: GaSnapshot) => {
|
|
@@ -1693,45 +1597,42 @@ export function setupGaTui(
|
|
|
1693
1597
|
}
|
|
1694
1598
|
|
|
1695
1599
|
/**
|
|
1696
|
-
* Pulls fresh state for `scope
|
|
1600
|
+
* Pulls fresh state for `scope`. Any
|
|
1697
1601
|
* notifications the pull carries are handled like a poll tick's.
|
|
1698
1602
|
*/
|
|
1699
|
-
const
|
|
1700
|
-
let fresh: GaSnapshot | undefined
|
|
1603
|
+
const refresh = async (scope: GaScope): Promise<void> => {
|
|
1701
1604
|
await pollGaOnce({
|
|
1702
1605
|
client,
|
|
1703
1606
|
scope: () => scope,
|
|
1704
1607
|
onSnapshot: (snapshot) => {
|
|
1705
|
-
fresh = snapshot
|
|
1706
1608
|
showSnapshot(snapshot)
|
|
1707
1609
|
},
|
|
1708
1610
|
onNotification,
|
|
1709
1611
|
...(logger ? { logger } : {}),
|
|
1710
1612
|
})
|
|
1711
|
-
return fresh ? buildGaMenu(fresh, now()) : undefined
|
|
1712
1613
|
}
|
|
1713
1614
|
|
|
1714
1615
|
const applyChoice = async (
|
|
1715
1616
|
scope: GaScope,
|
|
1716
1617
|
request: MenuApplyRequest,
|
|
1717
|
-
shown:
|
|
1618
|
+
shown: GaMenuPresentation,
|
|
1718
1619
|
): Promise<MenuApplyResult> => {
|
|
1719
1620
|
const refused = async (text: string, code: string) => ({
|
|
1720
1621
|
command: ANTIGRAVITY_MENU_COMMAND,
|
|
1721
1622
|
ok: false,
|
|
1722
1623
|
text,
|
|
1723
1624
|
code,
|
|
1724
|
-
menu:
|
|
1625
|
+
menu: shown.source,
|
|
1725
1626
|
})
|
|
1726
1627
|
let body: GaApplyBody
|
|
1727
1628
|
try {
|
|
1728
|
-
body =
|
|
1629
|
+
body = { request: shown.request(request) }
|
|
1729
1630
|
} catch (error) {
|
|
1730
1631
|
if (error instanceof GaMenuChoiceError)
|
|
1731
1632
|
return refused(error.message, 'invalid-choice')
|
|
1732
1633
|
throw error
|
|
1733
1634
|
}
|
|
1734
|
-
let result:
|
|
1635
|
+
let result: MenuApplyResult
|
|
1735
1636
|
try {
|
|
1736
1637
|
result = await client.apply(scope, body)
|
|
1737
1638
|
} catch (error) {
|
|
@@ -1739,23 +1640,30 @@ export function setupGaTui(
|
|
|
1739
1640
|
return refused(error.message, error.reason)
|
|
1740
1641
|
throw error
|
|
1741
1642
|
}
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
const menu = (await freshMenu(scope)) ?? shown()
|
|
1745
|
-
return gaMenuResult(result, menu)
|
|
1643
|
+
await refresh(scope)
|
|
1644
|
+
return result
|
|
1746
1645
|
}
|
|
1747
1646
|
|
|
1748
1647
|
function onNotification(notification: GaNotification, scope: GaScope) {
|
|
1648
|
+
const payload = notification.payload
|
|
1649
|
+
if ('notify' in payload) {
|
|
1650
|
+
ui.toast(payload.notify.message, payload.notify.kind)
|
|
1651
|
+
return
|
|
1652
|
+
}
|
|
1749
1653
|
const snapshot = latest.get(scopeKey(scope))
|
|
1750
1654
|
if (!snapshot) return
|
|
1751
|
-
let shown =
|
|
1655
|
+
let shown = presentGaMenu(snapshot, now(), payload.menu)
|
|
1752
1656
|
void openAntigravityMenu(
|
|
1753
1657
|
{
|
|
1754
1658
|
ui,
|
|
1755
1659
|
apply: async (request) => {
|
|
1756
|
-
const result = await applyChoice(scope, request,
|
|
1757
|
-
shown =
|
|
1758
|
-
|
|
1660
|
+
const result = await applyChoice(scope, request, shown)
|
|
1661
|
+
shown = presentGaMenu(
|
|
1662
|
+
latest.get(scopeKey(scope)) ?? snapshot,
|
|
1663
|
+
now(),
|
|
1664
|
+
result.menu,
|
|
1665
|
+
)
|
|
1666
|
+
return { ...result, menu: shown.menu }
|
|
1759
1667
|
},
|
|
1760
1668
|
...(context.renderer?.copyToClipboardOSC52
|
|
1761
1669
|
? {
|
|
@@ -1764,9 +1672,8 @@ export function setupGaTui(
|
|
|
1764
1672
|
}
|
|
1765
1673
|
: {}),
|
|
1766
1674
|
onError: (message, detail) => logger?.warn(message, detail),
|
|
1767
|
-
startSection: sectionForCommand(notification.command),
|
|
1768
1675
|
},
|
|
1769
|
-
{ command: ANTIGRAVITY_MENU_COMMAND, menu: shown },
|
|
1676
|
+
{ command: ANTIGRAVITY_MENU_COMMAND, menu: shown.menu },
|
|
1770
1677
|
).catch((error: unknown) => {
|
|
1771
1678
|
logger?.warn('menu-drawer-failed', {
|
|
1772
1679
|
error: error instanceof Error ? error.name : typeof error,
|