@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
|
@@ -33,11 +33,10 @@ import { createComponent as _$createComponent } from "opentui:runtime-module:%40
|
|
|
33
33
|
* not match is refused and logged by field name only.
|
|
34
34
|
*
|
|
35
35
|
* The wire shapes mirror the facade's `ga/rpc/protocol.ts` (clean v1:
|
|
36
|
-
* accounts carry opaque `selector`s
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* it; after every apply the menu is rebuilt from a fresh `state` read.
|
|
36
|
+
* accounts carry opaque `selector`s and every snapshot carries the location's
|
|
37
|
+
* settings). Notifications and apply answers carry the server's shared menu.
|
|
38
|
+
* The drawer keeps its presentation while submitting the issued menu item
|
|
39
|
+
* and action ids, never a sidebar selector or an account position.
|
|
41
40
|
*
|
|
42
41
|
* Nothing here imports account storage, tokens, OAuth, the vault client or
|
|
43
42
|
* server code, and nothing writes to the terminal or forces a theme.
|
|
@@ -46,7 +45,7 @@ import { createComponent as _$createComponent } from "opentui:runtime-module:%40
|
|
|
46
45
|
import { createSignal } from "opentui:runtime-module:solid-js";
|
|
47
46
|
import { projectAccount, projectSidebar } from "./shared/8ae1927e5910ea81-sidebar-projection.js";
|
|
48
47
|
import { MenuRefusedError, openAntigravityMenu } from "./shared/0e19a88ff3535906-command-dialogs.js";
|
|
49
|
-
import { ANTIGRAVITY_MENU_COMMAND, ANTIGRAVITY_MENU_TITLE } from "./shared/07365a7d2ccade4c-host-api.js";
|
|
48
|
+
import { ANTIGRAVITY_MENU_COMMAND, ANTIGRAVITY_MENU_TITLE, parseMenuApplyResult, parseMenuDialogPayload, parseMenuNotifyPayload } from "./shared/07365a7d2ccade4c-host-api.js";
|
|
50
49
|
import { AntigravitySidebar, DEFAULT_FRAME_SETTINGS } from "./shared/ced204104a639c9c-sidebar-frame.js";
|
|
51
50
|
export const GA_TUI_ID = 'cortexkit.antigravity-auth';
|
|
52
51
|
export const GA_RPC_ID = 'antigravity-auth';
|
|
@@ -69,26 +68,19 @@ const MAX_PULLS_PER_TICK = 4;
|
|
|
69
68
|
|
|
70
69
|
// ── Wire shapes ─────────────────────────────────────────────────────────────
|
|
71
70
|
|
|
72
|
-
/** The dialog commands the server names in notifications and text applies. */
|
|
73
|
-
export const GA_COMMANDS = ['antigravity-quota', 'antigravity-account', 'antigravity-killswitch', 'antigravity-dump', 'antigravity-logging'];
|
|
74
71
|
export const GA_LOG_LEVELS = ['error', 'warn', 'info', 'debug', 'trace'];
|
|
75
72
|
|
|
76
73
|
/** A redacted account plus the opaque selector that names its credential. */
|
|
77
74
|
|
|
78
75
|
/** The location's operator settings, read fresh for every `state` answer. */
|
|
79
76
|
|
|
80
|
-
/** A typed account action; accounts are named only by selector. */
|
|
81
|
-
|
|
82
77
|
/** What the client sends besides version, generation and scope. */
|
|
83
78
|
|
|
84
|
-
/** The command result fields this TUI reads; the rest are validated only. */
|
|
85
|
-
|
|
86
79
|
const GENERATION = /^[A-Za-z0-9_-]{1,64}$/;
|
|
87
80
|
const SESSION_ID = /^[\x21-\x7e]{1,256}$/;
|
|
88
81
|
const ACCOUNT_ID = /^acct-(0|[1-9][0-9]{0,5})$/;
|
|
89
82
|
const ACCOUNT_LABEL = /^Account [1-9][0-9]{0,5}$/;
|
|
90
83
|
const SELECTOR = /^sel-[A-Za-z0-9_-]{32}$/;
|
|
91
|
-
const TARGET_OUTCOMES = ['applied', 'stale-target', 'unknown-target', 'unsupported-index-action', 'failed'];
|
|
92
84
|
function isRecord(value) {
|
|
93
85
|
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
94
86
|
return false;
|
|
@@ -268,17 +260,12 @@ function checkNotification(value, path, issues) {
|
|
|
268
260
|
issues.push(`${path}: expected a notification`);
|
|
269
261
|
return;
|
|
270
262
|
}
|
|
271
|
-
keys(value, ['cursor', '
|
|
263
|
+
keys(value, ['cursor', 'payload'], [], path, issues);
|
|
272
264
|
if (!isCursor(value.cursor) || value.cursor < 1) {
|
|
273
265
|
issues.push(`${path}.cursor: expected a positive cursor`);
|
|
274
266
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
if (!GA_COMMANDS.includes(value.command)) {
|
|
279
|
-
issues.push(`${path}.command: unknown command`);
|
|
280
|
-
}
|
|
281
|
-
if (typeof value.text !== 'string') issues.push(`${path}.text: expected text`);
|
|
267
|
+
const parsed = isRecord(value.payload) && Object.hasOwn(value.payload, 'notify') ? parseMenuNotifyPayload(value.payload) : parseMenuDialogPayload(value.payload);
|
|
268
|
+
if (!parsed.ok) issues.push(...parsed.issues.map(issue => `${path}.payload: ${issue}`));
|
|
282
269
|
}
|
|
283
270
|
function checkBool(value, path, issues) {
|
|
284
271
|
if (typeof value !== 'boolean') issues.push(`${path}: expected true/false`);
|
|
@@ -326,56 +313,6 @@ function checkAccountsStatus(value, path, issues) {
|
|
|
326
313
|
}
|
|
327
314
|
issues.push(`${path}.kind: unknown accounts status`);
|
|
328
315
|
}
|
|
329
|
-
function checkAccountList(value, path, issues) {
|
|
330
|
-
if (value === null) return;
|
|
331
|
-
if (!Array.isArray(value) || value.length > 64) {
|
|
332
|
-
issues.push(`${path}: expected at most 64 accounts`);
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
value.forEach((entry, index) => {
|
|
336
|
-
checkAccount(entry, `${path}.${index}`, issues);
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/** One command result, with the closed field list of its command. */
|
|
341
|
-
function checkCommandResult(value, path, issues) {
|
|
342
|
-
if (!isRecord(value)) {
|
|
343
|
-
issues.push(`${path}: expected a command result`);
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
const base = ['command', 'status', 'text'];
|
|
347
|
-
if (value.status !== 'applied' && value.status !== 'rejected' && value.status !== 'failed') {
|
|
348
|
-
issues.push(`${path}.status: unknown status`);
|
|
349
|
-
}
|
|
350
|
-
if (typeof value.text !== 'string') issues.push(`${path}.text: expected text`);
|
|
351
|
-
switch (value.command) {
|
|
352
|
-
case 'antigravity-quota':
|
|
353
|
-
keys(value, [...base, 'accounts'], [], path, issues);
|
|
354
|
-
checkAccountList(value.accounts, `${path}.accounts`, issues);
|
|
355
|
-
return;
|
|
356
|
-
case 'antigravity-account':
|
|
357
|
-
keys(value, [...base, 'accounts', 'authorizationUrl', 'targetOutcome'], [], path, issues);
|
|
358
|
-
checkAccountList(value.accounts, `${path}.accounts`, issues);
|
|
359
|
-
if (value.authorizationUrl !== null && !(typeof value.authorizationUrl === 'string' && /^https:\/\//.test(value.authorizationUrl) && value.authorizationUrl.length <= 4096)) {
|
|
360
|
-
issues.push(`${path}.authorizationUrl: expected an https link or null`);
|
|
361
|
-
}
|
|
362
|
-
if (value.targetOutcome !== null && !TARGET_OUTCOMES.includes(value.targetOutcome)) {
|
|
363
|
-
issues.push(`${path}.targetOutcome: unknown outcome`);
|
|
364
|
-
}
|
|
365
|
-
return;
|
|
366
|
-
case 'antigravity-killswitch':
|
|
367
|
-
keys(value, [...base, 'killswitch'], [], path, issues);
|
|
368
|
-
return;
|
|
369
|
-
case 'antigravity-dump':
|
|
370
|
-
keys(value, [...base, 'dump'], [], path, issues);
|
|
371
|
-
return;
|
|
372
|
-
case 'antigravity-logging':
|
|
373
|
-
keys(value, [...base, 'logLevel'], [], path, issues);
|
|
374
|
-
return;
|
|
375
|
-
default:
|
|
376
|
-
issues.push(`${path}.command: unknown command`);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
316
|
|
|
380
317
|
/** Unwraps the host's `{ output }` answer. */
|
|
381
318
|
function unwrap(raw, issues) {
|
|
@@ -420,8 +357,9 @@ export function parseGaStateAnswer(raw) {
|
|
|
420
357
|
issues: ['output.kind: unknown answer']
|
|
421
358
|
};
|
|
422
359
|
}
|
|
423
|
-
keys(output, ['version', 'kind', 'generation', 'scope', 'reset', 'cursor', 'dropped', 'more', 'notifications', 'readSeq', 'accountsStatus', 'accounts', 'route', 'status', 'settings'], [], 'output', issues);
|
|
360
|
+
keys(output, ['version', 'kind', 'generation', 'scope', 'reset', 'cursor', 'dropped', 'more', 'notifications', 'readSeq', 'accountsStatus', 'accounts', 'route', 'status', 'settings'], ['vaultHostStatus'], 'output', issues);
|
|
424
361
|
if (!isCursor(output.readSeq)) issues.push('output.readSeq: expected a count');
|
|
362
|
+
if (Object.hasOwn(output, 'vaultHostStatus') && output.vaultHostStatus !== 'Served by Thalamus') issues.push('output.vaultHostStatus: expected the hosted vault status');
|
|
425
363
|
checkAccountsStatus(output.accountsStatus, 'output.accountsStatus', issues);
|
|
426
364
|
checkSettings(output.settings, 'output.settings', issues);
|
|
427
365
|
checkGeneration(output.generation, 'output.generation', issues);
|
|
@@ -478,7 +416,8 @@ export function parseGaApplyAnswer(raw) {
|
|
|
478
416
|
keys(output, ['version', 'kind', 'generation', 'scope', 'result'], [], 'output', issues);
|
|
479
417
|
checkGeneration(output.generation, 'output.generation', issues);
|
|
480
418
|
checkScope(output.scope, 'output.scope', issues);
|
|
481
|
-
|
|
419
|
+
const result = parseMenuApplyResult(output.result);
|
|
420
|
+
if (!result.ok) issues.push(...result.issues);
|
|
482
421
|
return finish(output, issues);
|
|
483
422
|
}
|
|
484
423
|
|
|
@@ -617,24 +556,6 @@ export function createGaLocationClient(options) {
|
|
|
617
556
|
|
|
618
557
|
// ── Menu over the native state ──────────────────────────────────────────────
|
|
619
558
|
|
|
620
|
-
/**
|
|
621
|
-
* GA notifications name only a dialog command, so this host builds the
|
|
622
|
-
* `/antigravity` menu itself from the latest `state` answer: the accounts
|
|
623
|
-
* with their opaque selectors and the location's settings, both read fresh
|
|
624
|
-
* for that answer. The shared drawer renders it like the OpenCode 1 menu.
|
|
625
|
-
* Each item and action id encodes what the action sends; an account is named
|
|
626
|
-
* only by its selector, never by position or `acct-<n>` id.
|
|
627
|
-
*/
|
|
628
|
-
const SECTION_FOR_COMMAND = {
|
|
629
|
-
'antigravity-account': 'accounts',
|
|
630
|
-
'antigravity-quota': 'quota',
|
|
631
|
-
'antigravity-killswitch': 'limits',
|
|
632
|
-
'antigravity-dump': 'diagnostics',
|
|
633
|
-
'antigravity-logging': 'diagnostics'
|
|
634
|
-
};
|
|
635
|
-
export function sectionForCommand(command) {
|
|
636
|
-
return SECTION_FOR_COMMAND[command];
|
|
637
|
-
}
|
|
638
559
|
const ACCOUNT_ITEM_PREFIX = 'account:';
|
|
639
560
|
function onOff(value) {
|
|
640
561
|
return value ? 'on' : 'off';
|
|
@@ -675,7 +596,7 @@ export function buildGaMenu(snapshot, now) {
|
|
|
675
596
|
id: `${ACCOUNT_ITEM_PREFIX}${account.selector}`,
|
|
676
597
|
label: account.label,
|
|
677
598
|
detail: `${projected.status} · ${projected.health}`,
|
|
678
|
-
actions: [account.enabled ? use('disable', 'Disable', 'Stop routing requests to this account.') : use('enable', 'Enable', 'Route requests to this account again.'), use('select-active', 'Use for all models', 'Make this the current account.'), use('select-claude', 'Use for Claude', 'Make this the current Claude account.'), use('select-gemini', 'Use for Gemini', 'Make this the current Gemini account.'), {
|
|
599
|
+
actions: [account.enabled ? use('disable', 'Disable', 'Stop routing requests to this account.') : use('enable', 'Enable', 'Route requests to this account again.'), use('select-active', 'Use for all models', 'Make this the current account.'), use('select-claude', 'Use for Claude', 'Make this the current Claude account.'), use('select-gemini', 'Use for Gemini', 'Make this the current Gemini account.'), ...(snapshot.vaultHostStatus || settings.selectionStrategy === 'vault' ? [] : [{
|
|
679
600
|
id: 'remove',
|
|
680
601
|
label: 'Remove',
|
|
681
602
|
description: 'Delete this account from this machine.',
|
|
@@ -684,10 +605,10 @@ export function buildGaMenu(snapshot, now) {
|
|
|
684
605
|
message: `Remove ${account.label}? This cannot be undone.`,
|
|
685
606
|
irreversible: true
|
|
686
607
|
}
|
|
687
|
-
}]
|
|
608
|
+
}])]
|
|
688
609
|
};
|
|
689
610
|
}),
|
|
690
|
-
actions: [{
|
|
611
|
+
actions: snapshot.vaultHostStatus || settings.selectionStrategy === 'vault' ? [] : [{
|
|
691
612
|
id: 'add',
|
|
692
613
|
label: 'Add account',
|
|
693
614
|
description: 'Sign in with Google in your browser.',
|
|
@@ -769,149 +690,116 @@ export function buildGaMenu(snapshot, now) {
|
|
|
769
690
|
return {
|
|
770
691
|
command: ANTIGRAVITY_MENU_COMMAND,
|
|
771
692
|
title: ANTIGRAVITY_MENU_TITLE,
|
|
772
|
-
sections
|
|
693
|
+
sections: snapshot.vaultHostStatus ? [...sections, {
|
|
694
|
+
id: 'vault',
|
|
695
|
+
slot: 'extra',
|
|
696
|
+
title: 'Vault',
|
|
697
|
+
lines: [snapshot.vaultHostStatus],
|
|
698
|
+
items: [],
|
|
699
|
+
actions: []
|
|
700
|
+
}] : sections
|
|
773
701
|
};
|
|
774
702
|
}
|
|
775
703
|
|
|
776
|
-
/**
|
|
704
|
+
/** A displayed choice is no longer present in the server-issued menu. */
|
|
777
705
|
export class GaMenuChoiceError extends Error {
|
|
778
706
|
constructor(message) {
|
|
779
707
|
super(message);
|
|
780
708
|
this.name = 'GaMenuChoiceError';
|
|
781
709
|
}
|
|
782
710
|
}
|
|
783
|
-
const TEXT_ACTIONS = {
|
|
784
|
-
'accounts/add': {
|
|
785
|
-
command: 'antigravity-account',
|
|
786
|
-
arguments: 'add-oauth-start'
|
|
787
|
-
},
|
|
788
|
-
'quota/refresh': {
|
|
789
|
-
command: 'antigravity-quota',
|
|
790
|
-
arguments: 'refresh'
|
|
791
|
-
},
|
|
792
|
-
'limits/killswitch-on': {
|
|
793
|
-
command: 'antigravity-killswitch',
|
|
794
|
-
arguments: 'enabled=true'
|
|
795
|
-
},
|
|
796
|
-
'limits/killswitch-off': {
|
|
797
|
-
command: 'antigravity-killswitch',
|
|
798
|
-
arguments: 'enabled=false'
|
|
799
|
-
},
|
|
800
|
-
'diagnostics/dump-on': {
|
|
801
|
-
command: 'antigravity-dump',
|
|
802
|
-
arguments: 'on'
|
|
803
|
-
},
|
|
804
|
-
'diagnostics/dump-off': {
|
|
805
|
-
command: 'antigravity-dump',
|
|
806
|
-
arguments: 'off'
|
|
807
|
-
}
|
|
808
|
-
};
|
|
809
|
-
|
|
810
711
|
/**
|
|
811
|
-
*
|
|
812
|
-
*
|
|
813
|
-
*
|
|
814
|
-
*
|
|
712
|
+
* Keep the drawer's labels and order, but bind every choice to an action
|
|
713
|
+
* actually issued by the server. Snapshot selectors are display data, not
|
|
714
|
+
* shared-menu item ids. The bindings retain the server's exact item id even
|
|
715
|
+
* when the roster changes before a choice arrives.
|
|
815
716
|
*/
|
|
816
|
-
export function
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
} : request.actionId === 'remove' ? {
|
|
833
|
-
kind: 'remove',
|
|
834
|
-
selector
|
|
835
|
-
} : request.actionId === 'select-active' ? {
|
|
836
|
-
kind: 'select',
|
|
837
|
-
selector,
|
|
838
|
-
target: 'active'
|
|
839
|
-
} : request.actionId === 'select-claude' ? {
|
|
840
|
-
kind: 'select',
|
|
841
|
-
selector,
|
|
842
|
-
target: 'claude'
|
|
843
|
-
} : request.actionId === 'select-gemini' ? {
|
|
844
|
-
kind: 'select',
|
|
845
|
-
selector,
|
|
846
|
-
target: 'gemini'
|
|
847
|
-
} : undefined;
|
|
848
|
-
if (!action) throw new GaMenuChoiceError('Unknown account action.');
|
|
849
|
-
if (action.kind === 'remove' && request.confirmed !== true) {
|
|
850
|
-
throw new GaMenuChoiceError('Removing an account needs a confirmation.');
|
|
851
|
-
}
|
|
852
|
-
return {
|
|
853
|
-
command: 'antigravity-account',
|
|
854
|
-
action
|
|
855
|
-
};
|
|
856
|
-
}
|
|
857
|
-
if (request.itemId !== undefined) {
|
|
858
|
-
throw new GaMenuChoiceError('Unknown menu entry.');
|
|
859
|
-
}
|
|
860
|
-
const fixed = TEXT_ACTIONS[key];
|
|
861
|
-
if (fixed) return fixed;
|
|
862
|
-
if (key === 'limits/killswitch-minimum') {
|
|
863
|
-
const percent = request.values.percent;
|
|
864
|
-
if (typeof percent !== 'number' || !Number.isInteger(percent) || percent < 0 || percent > 100) {
|
|
865
|
-
throw new GaMenuChoiceError('The minimum must be a whole number from 0 to 100.');
|
|
866
|
-
}
|
|
867
|
-
return {
|
|
868
|
-
command: 'antigravity-killswitch',
|
|
869
|
-
arguments: `minimum_remaining_percent=${percent}`
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
if (key === 'diagnostics/log-level') {
|
|
873
|
-
const level = request.values.level;
|
|
874
|
-
if (!GA_LOG_LEVELS.includes(level)) {
|
|
875
|
-
throw new GaMenuChoiceError('Unknown log level.');
|
|
876
|
-
}
|
|
717
|
+
export function presentGaMenu(snapshot, now, source) {
|
|
718
|
+
const bindings = new Map();
|
|
719
|
+
const key = (sectionId, itemId, actionId) => JSON.stringify([sectionId, itemId, actionId]);
|
|
720
|
+
const bind = (sectionId, itemId, display, action, values = choice => choice) => {
|
|
721
|
+
bindings.set(key(sectionId, itemId, display.id), choice => ({
|
|
722
|
+
command: source.command,
|
|
723
|
+
sectionId,
|
|
724
|
+
...(itemId === undefined ? {} : {
|
|
725
|
+
itemId
|
|
726
|
+
}),
|
|
727
|
+
actionId: action.id,
|
|
728
|
+
values: values(choice.values),
|
|
729
|
+
...(choice.confirmed ? {
|
|
730
|
+
confirmed: true
|
|
731
|
+
} : {})
|
|
732
|
+
}));
|
|
877
733
|
return {
|
|
878
|
-
|
|
879
|
-
|
|
734
|
+
...display,
|
|
735
|
+
...(action.confirm ? {
|
|
736
|
+
confirm: action.confirm
|
|
737
|
+
} : {})
|
|
880
738
|
};
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
const
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
739
|
+
};
|
|
740
|
+
const display = buildGaMenu(snapshot, now);
|
|
741
|
+
const sections = display.sections.filter(section => section.slot !== 'extra').flatMap(section => {
|
|
742
|
+
const actual = source.sections.find(candidate => candidate.id === section.id);
|
|
743
|
+
if (!actual) return [];
|
|
744
|
+
const actions = section.actions.flatMap(action => {
|
|
745
|
+
const id = section.id === 'limits' ? 'set' : action.id === 'log-level' ? 'logging' : action.id.startsWith('dump-') ? 'dump' : action.id;
|
|
746
|
+
const offered = actual.actions.find(candidate => candidate.id === id);
|
|
747
|
+
if (!offered) return [];
|
|
748
|
+
const values = section.id !== 'limits' ? undefined : action.id === 'killswitch-minimum' ? input => ({
|
|
749
|
+
minimumRemainingPercent: input.percent ?? null
|
|
750
|
+
}) : () => ({
|
|
751
|
+
enabled: action.id === 'killswitch-on'
|
|
752
|
+
});
|
|
753
|
+
return [bind(actual.id, undefined, action, offered, values)];
|
|
754
|
+
});
|
|
755
|
+
const items = actual.items.map(item => {
|
|
756
|
+
const projected = section.items.find(candidate => candidate.label === item.label);
|
|
757
|
+
if (!projected) return {
|
|
758
|
+
...item,
|
|
759
|
+
actions: []
|
|
760
|
+
};
|
|
761
|
+
return {
|
|
762
|
+
...projected,
|
|
763
|
+
id: item.id,
|
|
764
|
+
actions: projected.actions.flatMap(action => {
|
|
765
|
+
const target = action.id.startsWith('select-') ? action.id.slice('select-'.length) : undefined;
|
|
766
|
+
const offered = item.actions.find(candidate => candidate.id === (target ? 'select' : action.id));
|
|
767
|
+
if (!offered) return [];
|
|
768
|
+
return [bind(actual.id, item.id, action, offered, target ? () => ({
|
|
769
|
+
target
|
|
770
|
+
}) : undefined)];
|
|
771
|
+
})
|
|
772
|
+
};
|
|
773
|
+
});
|
|
774
|
+
return [{
|
|
775
|
+
...section,
|
|
776
|
+
items,
|
|
777
|
+
actions
|
|
778
|
+
}];
|
|
779
|
+
});
|
|
780
|
+
// Enrollment and hosted status remain the server's own sections, including
|
|
781
|
+
// their authority-dependent Connect/Disconnect actions and read-only host.
|
|
782
|
+
for (const section of source.sections.filter(candidate => candidate.slot === 'extra')) {
|
|
783
|
+
sections.push({
|
|
784
|
+
...section,
|
|
785
|
+
actions: section.actions.map(action => bind(section.id, undefined, action, action)),
|
|
786
|
+
items: section.items.map(item => ({
|
|
787
|
+
...item,
|
|
788
|
+
actions: item.actions.map(action => bind(section.id, item.id, action, action))
|
|
789
|
+
}))
|
|
790
|
+
});
|
|
906
791
|
}
|
|
907
792
|
return {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
793
|
+
menu: {
|
|
794
|
+
...display,
|
|
795
|
+
sections
|
|
796
|
+
},
|
|
797
|
+
source,
|
|
798
|
+
request(choice) {
|
|
799
|
+
const resolve = bindings.get(key(choice.sectionId, choice.itemId, choice.actionId));
|
|
800
|
+
if (choice.command !== source.command || !resolve) throw new GaMenuChoiceError('That action is no longer offered. Open the menu again.');
|
|
801
|
+
return resolve(choice);
|
|
802
|
+
}
|
|
915
803
|
};
|
|
916
804
|
}
|
|
917
805
|
|
|
@@ -1167,7 +1055,7 @@ export function setupGaTui(context, options = {}) {
|
|
|
1167
1055
|
})
|
|
1168
1056
|
});
|
|
1169
1057
|
|
|
1170
|
-
//
|
|
1058
|
+
// Sidebar readings and presentation are scoped to the menu's own session.
|
|
1171
1059
|
const latest = new Map();
|
|
1172
1060
|
const showSnapshot = snapshot => {
|
|
1173
1061
|
latest.set(scopeKey(snapshot.scope), snapshot);
|
|
@@ -1182,16 +1070,14 @@ export function setupGaTui(context, options = {}) {
|
|
|
1182
1070
|
};
|
|
1183
1071
|
|
|
1184
1072
|
/**
|
|
1185
|
-
* Pulls fresh state for `scope
|
|
1073
|
+
* Pulls fresh state for `scope`. Any
|
|
1186
1074
|
* notifications the pull carries are handled like a poll tick's.
|
|
1187
1075
|
*/
|
|
1188
|
-
const
|
|
1189
|
-
let fresh;
|
|
1076
|
+
const refresh = async scope => {
|
|
1190
1077
|
await pollGaOnce({
|
|
1191
1078
|
client,
|
|
1192
1079
|
scope: () => scope,
|
|
1193
1080
|
onSnapshot: snapshot => {
|
|
1194
|
-
fresh = snapshot;
|
|
1195
1081
|
showSnapshot(snapshot);
|
|
1196
1082
|
},
|
|
1197
1083
|
onNotification,
|
|
@@ -1199,7 +1085,6 @@ export function setupGaTui(context, options = {}) {
|
|
|
1199
1085
|
logger
|
|
1200
1086
|
} : {})
|
|
1201
1087
|
});
|
|
1202
|
-
return fresh ? buildGaMenu(fresh, now()) : undefined;
|
|
1203
1088
|
};
|
|
1204
1089
|
const applyChoice = async (scope, request, shown) => {
|
|
1205
1090
|
const refused = async (text, code) => ({
|
|
@@ -1207,11 +1092,13 @@ export function setupGaTui(context, options = {}) {
|
|
|
1207
1092
|
ok: false,
|
|
1208
1093
|
text,
|
|
1209
1094
|
code,
|
|
1210
|
-
menu:
|
|
1095
|
+
menu: shown.source
|
|
1211
1096
|
});
|
|
1212
1097
|
let body;
|
|
1213
1098
|
try {
|
|
1214
|
-
body =
|
|
1099
|
+
body = {
|
|
1100
|
+
request: shown.request(request)
|
|
1101
|
+
};
|
|
1215
1102
|
} catch (error) {
|
|
1216
1103
|
if (error instanceof GaMenuChoiceError) return refused(error.message, 'invalid-choice');
|
|
1217
1104
|
throw error;
|
|
@@ -1223,30 +1110,35 @@ export function setupGaTui(context, options = {}) {
|
|
|
1223
1110
|
if (error instanceof GaStaleError) return refused(error.message, error.reason);
|
|
1224
1111
|
throw error;
|
|
1225
1112
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
const menu = (await freshMenu(scope)) ?? shown();
|
|
1229
|
-
return gaMenuResult(result, menu);
|
|
1113
|
+
await refresh(scope);
|
|
1114
|
+
return result;
|
|
1230
1115
|
};
|
|
1231
1116
|
function onNotification(notification, scope) {
|
|
1117
|
+
const payload = notification.payload;
|
|
1118
|
+
if ('notify' in payload) {
|
|
1119
|
+
ui.toast(payload.notify.message, payload.notify.kind);
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1232
1122
|
const snapshot = latest.get(scopeKey(scope));
|
|
1233
1123
|
if (!snapshot) return;
|
|
1234
|
-
let shown =
|
|
1124
|
+
let shown = presentGaMenu(snapshot, now(), payload.menu);
|
|
1235
1125
|
void openAntigravityMenu({
|
|
1236
1126
|
ui,
|
|
1237
1127
|
apply: async request => {
|
|
1238
|
-
const result = await applyChoice(scope, request,
|
|
1239
|
-
shown = result.menu;
|
|
1240
|
-
return
|
|
1128
|
+
const result = await applyChoice(scope, request, shown);
|
|
1129
|
+
shown = presentGaMenu(latest.get(scopeKey(scope)) ?? snapshot, now(), result.menu);
|
|
1130
|
+
return {
|
|
1131
|
+
...result,
|
|
1132
|
+
menu: shown.menu
|
|
1133
|
+
};
|
|
1241
1134
|
},
|
|
1242
1135
|
...(context.renderer?.copyToClipboardOSC52 ? {
|
|
1243
1136
|
copy: text => context.renderer?.copyToClipboardOSC52?.(text) === true
|
|
1244
1137
|
} : {}),
|
|
1245
|
-
onError: (message, detail) => logger?.warn(message, detail)
|
|
1246
|
-
startSection: sectionForCommand(notification.command)
|
|
1138
|
+
onError: (message, detail) => logger?.warn(message, detail)
|
|
1247
1139
|
}, {
|
|
1248
1140
|
command: ANTIGRAVITY_MENU_COMMAND,
|
|
1249
|
-
menu: shown
|
|
1141
|
+
menu: shown.menu
|
|
1250
1142
|
}).catch(error => {
|
|
1251
1143
|
logger?.warn('menu-drawer-failed', {
|
|
1252
1144
|
error: error instanceof Error ? error.name : typeof error
|