@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 @@ import { jsx as _jsx } from "@opentui/solid/jsx-runtime";
|
|
|
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.
|
|
@@ -43,7 +42,7 @@ import { jsx as _jsx } from "@opentui/solid/jsx-runtime";
|
|
|
43
42
|
import { createSignal } from 'solid-js';
|
|
44
43
|
import { projectAccount, projectSidebar, } from '../../sidebar-projection';
|
|
45
44
|
import { MenuRefusedError, openAntigravityMenu, } from '../../tui/command-dialogs';
|
|
46
|
-
import { ANTIGRAVITY_MENU_COMMAND, ANTIGRAVITY_MENU_TITLE, } from '../../tui/host-api';
|
|
45
|
+
import { ANTIGRAVITY_MENU_COMMAND, ANTIGRAVITY_MENU_TITLE, parseMenuApplyResult, parseMenuDialogPayload, parseMenuNotifyPayload, } from '../../tui/host-api';
|
|
47
46
|
import { AntigravitySidebar, DEFAULT_FRAME_SETTINGS, } from '../../tui/sidebar-frame';
|
|
48
47
|
export const GA_TUI_ID = 'cortexkit.antigravity-auth';
|
|
49
48
|
export const GA_RPC_ID = 'antigravity-auth';
|
|
@@ -52,14 +51,6 @@ export const GA_RPC_VERSION = 1;
|
|
|
52
51
|
export const GA_SIDEBAR_PULL_MS = 1_000;
|
|
53
52
|
/** Pulls in one tick while the server reports more notifications waiting. */
|
|
54
53
|
const MAX_PULLS_PER_TICK = 4;
|
|
55
|
-
/** The dialog commands the server names in notifications and text applies. */
|
|
56
|
-
export const GA_COMMANDS = [
|
|
57
|
-
'antigravity-quota',
|
|
58
|
-
'antigravity-account',
|
|
59
|
-
'antigravity-killswitch',
|
|
60
|
-
'antigravity-dump',
|
|
61
|
-
'antigravity-logging',
|
|
62
|
-
];
|
|
63
54
|
export const GA_LOG_LEVELS = [
|
|
64
55
|
'error',
|
|
65
56
|
'warn',
|
|
@@ -72,13 +63,6 @@ const SESSION_ID = /^[\x21-\x7e]{1,256}$/;
|
|
|
72
63
|
const ACCOUNT_ID = /^acct-(0|[1-9][0-9]{0,5})$/;
|
|
73
64
|
const ACCOUNT_LABEL = /^Account [1-9][0-9]{0,5}$/;
|
|
74
65
|
const SELECTOR = /^sel-[A-Za-z0-9_-]{32}$/;
|
|
75
|
-
const TARGET_OUTCOMES = [
|
|
76
|
-
'applied',
|
|
77
|
-
'stale-target',
|
|
78
|
-
'unknown-target',
|
|
79
|
-
'unsupported-index-action',
|
|
80
|
-
'failed',
|
|
81
|
-
];
|
|
82
66
|
function isRecord(value) {
|
|
83
67
|
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
84
68
|
return false;
|
|
@@ -282,18 +266,15 @@ function checkNotification(value, path, issues) {
|
|
|
282
266
|
issues.push(`${path}: expected a notification`);
|
|
283
267
|
return;
|
|
284
268
|
}
|
|
285
|
-
keys(value, ['cursor', '
|
|
269
|
+
keys(value, ['cursor', 'payload'], [], path, issues);
|
|
286
270
|
if (!isCursor(value.cursor) || value.cursor < 1) {
|
|
287
271
|
issues.push(`${path}.cursor: expected a positive cursor`);
|
|
288
272
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (!
|
|
293
|
-
issues.push(`${path}.
|
|
294
|
-
}
|
|
295
|
-
if (typeof value.text !== 'string')
|
|
296
|
-
issues.push(`${path}.text: expected text`);
|
|
273
|
+
const parsed = isRecord(value.payload) && Object.hasOwn(value.payload, 'notify')
|
|
274
|
+
? parseMenuNotifyPayload(value.payload)
|
|
275
|
+
: parseMenuDialogPayload(value.payload);
|
|
276
|
+
if (!parsed.ok)
|
|
277
|
+
issues.push(...parsed.issues.map((issue) => `${path}.payload: ${issue}`));
|
|
297
278
|
}
|
|
298
279
|
function checkBool(value, path, issues) {
|
|
299
280
|
if (typeof value !== 'boolean')
|
|
@@ -345,63 +326,6 @@ function checkAccountsStatus(value, path, issues) {
|
|
|
345
326
|
}
|
|
346
327
|
issues.push(`${path}.kind: unknown accounts status`);
|
|
347
328
|
}
|
|
348
|
-
function checkAccountList(value, path, issues) {
|
|
349
|
-
if (value === null)
|
|
350
|
-
return;
|
|
351
|
-
if (!Array.isArray(value) || value.length > 64) {
|
|
352
|
-
issues.push(`${path}: expected at most 64 accounts`);
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
value.forEach((entry, index) => {
|
|
356
|
-
checkAccount(entry, `${path}.${index}`, issues);
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
/** One command result, with the closed field list of its command. */
|
|
360
|
-
function checkCommandResult(value, path, issues) {
|
|
361
|
-
if (!isRecord(value)) {
|
|
362
|
-
issues.push(`${path}: expected a command result`);
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
const base = ['command', 'status', 'text'];
|
|
366
|
-
if (value.status !== 'applied' &&
|
|
367
|
-
value.status !== 'rejected' &&
|
|
368
|
-
value.status !== 'failed') {
|
|
369
|
-
issues.push(`${path}.status: unknown status`);
|
|
370
|
-
}
|
|
371
|
-
if (typeof value.text !== 'string')
|
|
372
|
-
issues.push(`${path}.text: expected text`);
|
|
373
|
-
switch (value.command) {
|
|
374
|
-
case 'antigravity-quota':
|
|
375
|
-
keys(value, [...base, 'accounts'], [], path, issues);
|
|
376
|
-
checkAccountList(value.accounts, `${path}.accounts`, issues);
|
|
377
|
-
return;
|
|
378
|
-
case 'antigravity-account':
|
|
379
|
-
keys(value, [...base, 'accounts', 'authorizationUrl', 'targetOutcome'], [], path, issues);
|
|
380
|
-
checkAccountList(value.accounts, `${path}.accounts`, issues);
|
|
381
|
-
if (value.authorizationUrl !== null &&
|
|
382
|
-
!(typeof value.authorizationUrl === 'string' &&
|
|
383
|
-
/^https:\/\//.test(value.authorizationUrl) &&
|
|
384
|
-
value.authorizationUrl.length <= 4096)) {
|
|
385
|
-
issues.push(`${path}.authorizationUrl: expected an https link or null`);
|
|
386
|
-
}
|
|
387
|
-
if (value.targetOutcome !== null &&
|
|
388
|
-
!TARGET_OUTCOMES.includes(value.targetOutcome)) {
|
|
389
|
-
issues.push(`${path}.targetOutcome: unknown outcome`);
|
|
390
|
-
}
|
|
391
|
-
return;
|
|
392
|
-
case 'antigravity-killswitch':
|
|
393
|
-
keys(value, [...base, 'killswitch'], [], path, issues);
|
|
394
|
-
return;
|
|
395
|
-
case 'antigravity-dump':
|
|
396
|
-
keys(value, [...base, 'dump'], [], path, issues);
|
|
397
|
-
return;
|
|
398
|
-
case 'antigravity-logging':
|
|
399
|
-
keys(value, [...base, 'logLevel'], [], path, issues);
|
|
400
|
-
return;
|
|
401
|
-
default:
|
|
402
|
-
issues.push(`${path}.command: unknown command`);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
329
|
/** Unwraps the host's `{ output }` answer. */
|
|
406
330
|
function unwrap(raw, issues) {
|
|
407
331
|
if (!isRecord(raw)) {
|
|
@@ -449,9 +373,12 @@ export function parseGaStateAnswer(raw) {
|
|
|
449
373
|
'route',
|
|
450
374
|
'status',
|
|
451
375
|
'settings',
|
|
452
|
-
], [], 'output', issues);
|
|
376
|
+
], ['vaultHostStatus'], 'output', issues);
|
|
453
377
|
if (!isCursor(output.readSeq))
|
|
454
378
|
issues.push('output.readSeq: expected a count');
|
|
379
|
+
if (Object.hasOwn(output, 'vaultHostStatus') &&
|
|
380
|
+
output.vaultHostStatus !== 'Served by Thalamus')
|
|
381
|
+
issues.push('output.vaultHostStatus: expected the hosted vault status');
|
|
455
382
|
checkAccountsStatus(output.accountsStatus, 'output.accountsStatus', issues);
|
|
456
383
|
checkSettings(output.settings, 'output.settings', issues);
|
|
457
384
|
checkGeneration(output.generation, 'output.generation', issues);
|
|
@@ -509,7 +436,9 @@ export function parseGaApplyAnswer(raw) {
|
|
|
509
436
|
keys(output, ['version', 'kind', 'generation', 'scope', 'result'], [], 'output', issues);
|
|
510
437
|
checkGeneration(output.generation, 'output.generation', issues);
|
|
511
438
|
checkScope(output.scope, 'output.scope', issues);
|
|
512
|
-
|
|
439
|
+
const result = parseMenuApplyResult(output.result);
|
|
440
|
+
if (!result.ok)
|
|
441
|
+
issues.push(...result.issues);
|
|
513
442
|
return finish(output, issues);
|
|
514
443
|
}
|
|
515
444
|
// ── Location client ─────────────────────────────────────────────────────────
|
|
@@ -642,24 +571,6 @@ export function createGaLocationClient(options) {
|
|
|
642
571
|
};
|
|
643
572
|
}
|
|
644
573
|
// ── Menu over the native state ──────────────────────────────────────────────
|
|
645
|
-
/**
|
|
646
|
-
* GA notifications name only a dialog command, so this host builds the
|
|
647
|
-
* `/antigravity` menu itself from the latest `state` answer: the accounts
|
|
648
|
-
* with their opaque selectors and the location's settings, both read fresh
|
|
649
|
-
* for that answer. The shared drawer renders it like the OpenCode 1 menu.
|
|
650
|
-
* Each item and action id encodes what the action sends; an account is named
|
|
651
|
-
* only by its selector, never by position or `acct-<n>` id.
|
|
652
|
-
*/
|
|
653
|
-
const SECTION_FOR_COMMAND = {
|
|
654
|
-
'antigravity-account': 'accounts',
|
|
655
|
-
'antigravity-quota': 'quota',
|
|
656
|
-
'antigravity-killswitch': 'limits',
|
|
657
|
-
'antigravity-dump': 'diagnostics',
|
|
658
|
-
'antigravity-logging': 'diagnostics',
|
|
659
|
-
};
|
|
660
|
-
export function sectionForCommand(command) {
|
|
661
|
-
return SECTION_FOR_COMMAND[command];
|
|
662
|
-
}
|
|
663
574
|
const ACCOUNT_ITEM_PREFIX = 'account:';
|
|
664
575
|
function onOff(value) {
|
|
665
576
|
return value ? 'on' : 'off';
|
|
@@ -708,27 +619,34 @@ export function buildGaMenu(snapshot, now) {
|
|
|
708
619
|
use('select-active', 'Use for all models', 'Make this the current account.'),
|
|
709
620
|
use('select-claude', 'Use for Claude', 'Make this the current Claude account.'),
|
|
710
621
|
use('select-gemini', 'Use for Gemini', 'Make this the current Gemini account.'),
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
622
|
+
...(snapshot.vaultHostStatus ||
|
|
623
|
+
settings.selectionStrategy === 'vault'
|
|
624
|
+
? []
|
|
625
|
+
: [
|
|
626
|
+
{
|
|
627
|
+
id: 'remove',
|
|
628
|
+
label: 'Remove',
|
|
629
|
+
description: 'Delete this account from this machine.',
|
|
630
|
+
knobs: [],
|
|
631
|
+
confirm: {
|
|
632
|
+
message: `Remove ${account.label}? This cannot be undone.`,
|
|
633
|
+
irreversible: true,
|
|
634
|
+
},
|
|
635
|
+
},
|
|
636
|
+
]),
|
|
721
637
|
],
|
|
722
638
|
};
|
|
723
639
|
}),
|
|
724
|
-
actions:
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
640
|
+
actions: snapshot.vaultHostStatus || settings.selectionStrategy === 'vault'
|
|
641
|
+
? []
|
|
642
|
+
: [
|
|
643
|
+
{
|
|
644
|
+
id: 'add',
|
|
645
|
+
label: 'Add account',
|
|
646
|
+
description: 'Sign in with Google in your browser.',
|
|
647
|
+
knobs: [],
|
|
648
|
+
},
|
|
649
|
+
],
|
|
732
650
|
},
|
|
733
651
|
{
|
|
734
652
|
id: 'quota',
|
|
@@ -838,125 +756,121 @@ export function buildGaMenu(snapshot, now) {
|
|
|
838
756
|
return {
|
|
839
757
|
command: ANTIGRAVITY_MENU_COMMAND,
|
|
840
758
|
title: ANTIGRAVITY_MENU_TITLE,
|
|
841
|
-
sections
|
|
759
|
+
sections: snapshot.vaultHostStatus
|
|
760
|
+
? [
|
|
761
|
+
...sections,
|
|
762
|
+
{
|
|
763
|
+
id: 'vault',
|
|
764
|
+
slot: 'extra',
|
|
765
|
+
title: 'Vault',
|
|
766
|
+
lines: [snapshot.vaultHostStatus],
|
|
767
|
+
items: [],
|
|
768
|
+
actions: [],
|
|
769
|
+
},
|
|
770
|
+
]
|
|
771
|
+
: sections,
|
|
842
772
|
};
|
|
843
773
|
}
|
|
844
|
-
/**
|
|
774
|
+
/** A displayed choice is no longer present in the server-issued menu. */
|
|
845
775
|
export class GaMenuChoiceError extends Error {
|
|
846
776
|
constructor(message) {
|
|
847
777
|
super(message);
|
|
848
778
|
this.name = 'GaMenuChoiceError';
|
|
849
779
|
}
|
|
850
780
|
}
|
|
851
|
-
const TEXT_ACTIONS = {
|
|
852
|
-
'accounts/add': {
|
|
853
|
-
command: 'antigravity-account',
|
|
854
|
-
arguments: 'add-oauth-start',
|
|
855
|
-
},
|
|
856
|
-
'quota/refresh': { command: 'antigravity-quota', arguments: 'refresh' },
|
|
857
|
-
'limits/killswitch-on': {
|
|
858
|
-
command: 'antigravity-killswitch',
|
|
859
|
-
arguments: 'enabled=true',
|
|
860
|
-
},
|
|
861
|
-
'limits/killswitch-off': {
|
|
862
|
-
command: 'antigravity-killswitch',
|
|
863
|
-
arguments: 'enabled=false',
|
|
864
|
-
},
|
|
865
|
-
'diagnostics/dump-on': { command: 'antigravity-dump', arguments: 'on' },
|
|
866
|
-
'diagnostics/dump-off': { command: 'antigravity-dump', arguments: 'off' },
|
|
867
|
-
};
|
|
868
781
|
/**
|
|
869
|
-
*
|
|
870
|
-
*
|
|
871
|
-
*
|
|
872
|
-
*
|
|
782
|
+
* Keep the drawer's labels and order, but bind every choice to an action
|
|
783
|
+
* actually issued by the server. Snapshot selectors are display data, not
|
|
784
|
+
* shared-menu item ids. The bindings retain the server's exact item id even
|
|
785
|
+
* when the roster changes before a choice arrives.
|
|
873
786
|
*/
|
|
874
|
-
export function
|
|
875
|
-
const
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
: request.actionId === 'disable'
|
|
887
|
-
? { kind: 'disable', selector }
|
|
888
|
-
: request.actionId === 'remove'
|
|
889
|
-
? { kind: 'remove', selector }
|
|
890
|
-
: request.actionId === 'select-active'
|
|
891
|
-
? { kind: 'select', selector, target: 'active' }
|
|
892
|
-
: request.actionId === 'select-claude'
|
|
893
|
-
? { kind: 'select', selector, target: 'claude' }
|
|
894
|
-
: request.actionId === 'select-gemini'
|
|
895
|
-
? { kind: 'select', selector, target: 'gemini' }
|
|
896
|
-
: undefined;
|
|
897
|
-
if (!action)
|
|
898
|
-
throw new GaMenuChoiceError('Unknown account action.');
|
|
899
|
-
if (action.kind === 'remove' && request.confirmed !== true) {
|
|
900
|
-
throw new GaMenuChoiceError('Removing an account needs a confirmation.');
|
|
901
|
-
}
|
|
902
|
-
return { command: 'antigravity-account', action };
|
|
903
|
-
}
|
|
904
|
-
if (request.itemId !== undefined) {
|
|
905
|
-
throw new GaMenuChoiceError('Unknown menu entry.');
|
|
906
|
-
}
|
|
907
|
-
const fixed = TEXT_ACTIONS[key];
|
|
908
|
-
if (fixed)
|
|
909
|
-
return fixed;
|
|
910
|
-
if (key === 'limits/killswitch-minimum') {
|
|
911
|
-
const percent = request.values.percent;
|
|
912
|
-
if (typeof percent !== 'number' ||
|
|
913
|
-
!Number.isInteger(percent) ||
|
|
914
|
-
percent < 0 ||
|
|
915
|
-
percent > 100) {
|
|
916
|
-
throw new GaMenuChoiceError('The minimum must be a whole number from 0 to 100.');
|
|
917
|
-
}
|
|
787
|
+
export function presentGaMenu(snapshot, now, source) {
|
|
788
|
+
const bindings = new Map();
|
|
789
|
+
const key = (sectionId, itemId, actionId) => JSON.stringify([sectionId, itemId, actionId]);
|
|
790
|
+
const bind = (sectionId, itemId, display, action, values = (choice) => choice) => {
|
|
791
|
+
bindings.set(key(sectionId, itemId, display.id), (choice) => ({
|
|
792
|
+
command: source.command,
|
|
793
|
+
sectionId,
|
|
794
|
+
...(itemId === undefined ? {} : { itemId }),
|
|
795
|
+
actionId: action.id,
|
|
796
|
+
values: values(choice.values),
|
|
797
|
+
...(choice.confirmed ? { confirmed: true } : {}),
|
|
798
|
+
}));
|
|
918
799
|
return {
|
|
919
|
-
|
|
920
|
-
|
|
800
|
+
...display,
|
|
801
|
+
...(action.confirm ? { confirm: action.confirm } : {}),
|
|
921
802
|
};
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
803
|
+
};
|
|
804
|
+
const display = buildGaMenu(snapshot, now);
|
|
805
|
+
const sections = display.sections
|
|
806
|
+
.filter((section) => section.slot !== 'extra')
|
|
807
|
+
.flatMap((section) => {
|
|
808
|
+
const actual = source.sections.find((candidate) => candidate.id === section.id);
|
|
809
|
+
if (!actual)
|
|
810
|
+
return [];
|
|
811
|
+
const actions = section.actions.flatMap((action) => {
|
|
812
|
+
const id = section.id === 'limits'
|
|
813
|
+
? 'set'
|
|
814
|
+
: action.id === 'log-level'
|
|
815
|
+
? 'logging'
|
|
816
|
+
: action.id.startsWith('dump-')
|
|
817
|
+
? 'dump'
|
|
818
|
+
: action.id;
|
|
819
|
+
const offered = actual.actions.find((candidate) => candidate.id === id);
|
|
820
|
+
if (!offered)
|
|
821
|
+
return [];
|
|
822
|
+
const values = section.id !== 'limits'
|
|
823
|
+
? undefined
|
|
824
|
+
: action.id === 'killswitch-minimum'
|
|
825
|
+
? (input) => ({
|
|
826
|
+
minimumRemainingPercent: input.percent ?? null,
|
|
827
|
+
})
|
|
828
|
+
: () => ({ enabled: action.id === 'killswitch-on' });
|
|
829
|
+
return [bind(actual.id, undefined, action, offered, values)];
|
|
830
|
+
});
|
|
831
|
+
const items = actual.items.map((item) => {
|
|
832
|
+
const projected = section.items.find((candidate) => candidate.label === item.label);
|
|
833
|
+
if (!projected)
|
|
834
|
+
return { ...item, actions: [] };
|
|
835
|
+
return {
|
|
836
|
+
...projected,
|
|
837
|
+
id: item.id,
|
|
838
|
+
actions: projected.actions.flatMap((action) => {
|
|
839
|
+
const target = action.id.startsWith('select-')
|
|
840
|
+
? action.id.slice('select-'.length)
|
|
841
|
+
: undefined;
|
|
842
|
+
const offered = item.actions.find((candidate) => candidate.id === (target ? 'select' : action.id));
|
|
843
|
+
if (!offered)
|
|
844
|
+
return [];
|
|
845
|
+
return [
|
|
846
|
+
bind(actual.id, item.id, action, offered, target ? () => ({ target }) : undefined),
|
|
847
|
+
];
|
|
848
|
+
}),
|
|
849
|
+
};
|
|
850
|
+
});
|
|
851
|
+
return [{ ...section, items, actions }];
|
|
852
|
+
});
|
|
853
|
+
// Enrollment and hosted status remain the server's own sections, including
|
|
854
|
+
// their authority-dependent Connect/Disconnect actions and read-only host.
|
|
855
|
+
for (const section of source.sections.filter((candidate) => candidate.slot === 'extra')) {
|
|
856
|
+
sections.push({
|
|
857
|
+
...section,
|
|
858
|
+
actions: section.actions.map((action) => bind(section.id, undefined, action, action)),
|
|
859
|
+
items: section.items.map((item) => ({
|
|
860
|
+
...item,
|
|
861
|
+
actions: item.actions.map((action) => bind(section.id, item.id, action, action)),
|
|
862
|
+
})),
|
|
863
|
+
});
|
|
953
864
|
}
|
|
954
865
|
return {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
866
|
+
menu: { ...display, sections },
|
|
867
|
+
source,
|
|
868
|
+
request(choice) {
|
|
869
|
+
const resolve = bindings.get(key(choice.sectionId, choice.itemId, choice.actionId));
|
|
870
|
+
if (choice.command !== source.command || !resolve)
|
|
871
|
+
throw new GaMenuChoiceError('That action is no longer offered. Open the menu again.');
|
|
872
|
+
return resolve(choice);
|
|
873
|
+
},
|
|
960
874
|
};
|
|
961
875
|
}
|
|
962
876
|
// ── Dialogs ─────────────────────────────────────────────────────────────────
|
|
@@ -1143,7 +1057,7 @@ export function setupGaTui(context, options = {}) {
|
|
|
1143
1057
|
append: 'sidebar.content',
|
|
1144
1058
|
render: (input) => (_jsx(GaSidebar, { view: view, sessionID: input.sessionID, theme: () => context.theme, version: options.version ?? '', collapsed: collapse.collapsed, toggleCollapsed: collapse.toggle })),
|
|
1145
1059
|
});
|
|
1146
|
-
//
|
|
1060
|
+
// Sidebar readings and presentation are scoped to the menu's own session.
|
|
1147
1061
|
const latest = new Map();
|
|
1148
1062
|
const showSnapshot = (snapshot) => {
|
|
1149
1063
|
latest.set(scopeKey(snapshot.scope), snapshot);
|
|
@@ -1157,22 +1071,19 @@ export function setupGaTui(context, options = {}) {
|
|
|
1157
1071
|
});
|
|
1158
1072
|
};
|
|
1159
1073
|
/**
|
|
1160
|
-
* Pulls fresh state for `scope
|
|
1074
|
+
* Pulls fresh state for `scope`. Any
|
|
1161
1075
|
* notifications the pull carries are handled like a poll tick's.
|
|
1162
1076
|
*/
|
|
1163
|
-
const
|
|
1164
|
-
let fresh;
|
|
1077
|
+
const refresh = async (scope) => {
|
|
1165
1078
|
await pollGaOnce({
|
|
1166
1079
|
client,
|
|
1167
1080
|
scope: () => scope,
|
|
1168
1081
|
onSnapshot: (snapshot) => {
|
|
1169
|
-
fresh = snapshot;
|
|
1170
1082
|
showSnapshot(snapshot);
|
|
1171
1083
|
},
|
|
1172
1084
|
onNotification,
|
|
1173
1085
|
...(logger ? { logger } : {}),
|
|
1174
1086
|
});
|
|
1175
|
-
return fresh ? buildGaMenu(fresh, now()) : undefined;
|
|
1176
1087
|
};
|
|
1177
1088
|
const applyChoice = async (scope, request, shown) => {
|
|
1178
1089
|
const refused = async (text, code) => ({
|
|
@@ -1180,11 +1091,11 @@ export function setupGaTui(context, options = {}) {
|
|
|
1180
1091
|
ok: false,
|
|
1181
1092
|
text,
|
|
1182
1093
|
code,
|
|
1183
|
-
menu:
|
|
1094
|
+
menu: shown.source,
|
|
1184
1095
|
});
|
|
1185
1096
|
let body;
|
|
1186
1097
|
try {
|
|
1187
|
-
body =
|
|
1098
|
+
body = { request: shown.request(request) };
|
|
1188
1099
|
}
|
|
1189
1100
|
catch (error) {
|
|
1190
1101
|
if (error instanceof GaMenuChoiceError)
|
|
@@ -1200,22 +1111,25 @@ export function setupGaTui(context, options = {}) {
|
|
|
1200
1111
|
return refused(error.message, error.reason);
|
|
1201
1112
|
throw error;
|
|
1202
1113
|
}
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
const menu = (await freshMenu(scope)) ?? shown();
|
|
1206
|
-
return gaMenuResult(result, menu);
|
|
1114
|
+
await refresh(scope);
|
|
1115
|
+
return result;
|
|
1207
1116
|
};
|
|
1208
1117
|
function onNotification(notification, scope) {
|
|
1118
|
+
const payload = notification.payload;
|
|
1119
|
+
if ('notify' in payload) {
|
|
1120
|
+
ui.toast(payload.notify.message, payload.notify.kind);
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1209
1123
|
const snapshot = latest.get(scopeKey(scope));
|
|
1210
1124
|
if (!snapshot)
|
|
1211
1125
|
return;
|
|
1212
|
-
let shown =
|
|
1126
|
+
let shown = presentGaMenu(snapshot, now(), payload.menu);
|
|
1213
1127
|
void openAntigravityMenu({
|
|
1214
1128
|
ui,
|
|
1215
1129
|
apply: async (request) => {
|
|
1216
|
-
const result = await applyChoice(scope, request,
|
|
1217
|
-
shown = result.menu;
|
|
1218
|
-
return result;
|
|
1130
|
+
const result = await applyChoice(scope, request, shown);
|
|
1131
|
+
shown = presentGaMenu(latest.get(scopeKey(scope)) ?? snapshot, now(), result.menu);
|
|
1132
|
+
return { ...result, menu: shown.menu };
|
|
1219
1133
|
},
|
|
1220
1134
|
...(context.renderer?.copyToClipboardOSC52
|
|
1221
1135
|
? {
|
|
@@ -1223,8 +1137,7 @@ export function setupGaTui(context, options = {}) {
|
|
|
1223
1137
|
}
|
|
1224
1138
|
: {}),
|
|
1225
1139
|
onError: (message, detail) => logger?.warn(message, detail),
|
|
1226
|
-
|
|
1227
|
-
}, { command: ANTIGRAVITY_MENU_COMMAND, menu: shown }).catch((error) => {
|
|
1140
|
+
}, { command: ANTIGRAVITY_MENU_COMMAND, menu: shown.menu }).catch((error) => {
|
|
1228
1141
|
logger?.warn('menu-drawer-failed', {
|
|
1229
1142
|
error: error instanceof Error ? error.name : typeof error,
|
|
1230
1143
|
});
|