@cortexkit/opencode-antigravity-auth 3.0.35 → 3.0.37
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 +6 -1
- package/dist/cli.js.map +2 -2
- package/dist/cli.meta.json +11 -11
- package/dist/index.js +12 -7
- package/dist/index.js.map +2 -2
- package/dist/index.meta.json +29 -13
- package/dist/server.js +624 -581
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/availability.d.ts +1 -0
- package/dist/src/common-auth-embedded/claustrum/availability.js +2 -0
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/claustrum/index.js +1 -1
- package/dist/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +51 -0
- package/dist/src/common-auth-embedded/routing-accessor/cache-policy.js +186 -0
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +2 -1
- package/dist/src/common-auth-embedded/routing-accessor/index.js +1 -0
- package/dist/src/common-auth-embedded/source-output.json +41 -25
- package/dist/src/ga/server/auth.js +1 -1
- package/dist/src/ga/server/auth.js.map +1 -1
- package/dist/src/ga/server/index.js +1 -1
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/ga/tui/host-ga.d.ts +21 -58
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +122 -230
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- 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 +88 -52
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/vault-custody.js +6 -6
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/src/setup.js +1 -1
- 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/availability.d.ts +1 -0
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +51 -0
- package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +2 -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/package.json +4 -4
- package/src/common-auth-embedded/claustrum/availability.d.ts +1 -0
- package/src/common-auth-embedded/claustrum/availability.js +2 -0
- package/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/src/common-auth-embedded/claustrum/index.js +1 -1
- package/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +51 -0
- package/src/common-auth-embedded/routing-accessor/cache-policy.js +186 -0
- package/src/common-auth-embedded/routing-accessor/index.d.ts +2 -1
- package/src/common-auth-embedded/routing-accessor/index.js +1 -0
- package/src/common-auth-embedded/source-output.json +41 -25
- package/src/tui-ga-compiled/host-ga.js +122 -238
- package/src/tui-ga-raw/host-ga.tsx +189 -306
|
@@ -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) {
|
|
@@ -479,7 +416,8 @@ export function parseGaApplyAnswer(raw) {
|
|
|
479
416
|
keys(output, ['version', 'kind', 'generation', 'scope', 'result'], [], 'output', issues);
|
|
480
417
|
checkGeneration(output.generation, 'output.generation', issues);
|
|
481
418
|
checkScope(output.scope, 'output.scope', issues);
|
|
482
|
-
|
|
419
|
+
const result = parseMenuApplyResult(output.result);
|
|
420
|
+
if (!result.ok) issues.push(...result.issues);
|
|
483
421
|
return finish(output, issues);
|
|
484
422
|
}
|
|
485
423
|
|
|
@@ -618,24 +556,6 @@ export function createGaLocationClient(options) {
|
|
|
618
556
|
|
|
619
557
|
// ── Menu over the native state ──────────────────────────────────────────────
|
|
620
558
|
|
|
621
|
-
/**
|
|
622
|
-
* GA notifications name only a dialog command, so this host builds the
|
|
623
|
-
* `/antigravity` menu itself from the latest `state` answer: the accounts
|
|
624
|
-
* with their opaque selectors and the location's settings, both read fresh
|
|
625
|
-
* for that answer. The shared drawer renders it like the OpenCode 1 menu.
|
|
626
|
-
* Each item and action id encodes what the action sends; an account is named
|
|
627
|
-
* only by its selector, never by position or `acct-<n>` id.
|
|
628
|
-
*/
|
|
629
|
-
const SECTION_FOR_COMMAND = {
|
|
630
|
-
'antigravity-account': 'accounts',
|
|
631
|
-
'antigravity-quota': 'quota',
|
|
632
|
-
'antigravity-killswitch': 'limits',
|
|
633
|
-
'antigravity-dump': 'diagnostics',
|
|
634
|
-
'antigravity-logging': 'diagnostics'
|
|
635
|
-
};
|
|
636
|
-
export function sectionForCommand(command) {
|
|
637
|
-
return SECTION_FOR_COMMAND[command];
|
|
638
|
-
}
|
|
639
559
|
const ACCOUNT_ITEM_PREFIX = 'account:';
|
|
640
560
|
function onOff(value) {
|
|
641
561
|
return value ? 'on' : 'off';
|
|
@@ -676,7 +596,7 @@ export function buildGaMenu(snapshot, now) {
|
|
|
676
596
|
id: `${ACCOUNT_ITEM_PREFIX}${account.selector}`,
|
|
677
597
|
label: account.label,
|
|
678
598
|
detail: `${projected.status} · ${projected.health}`,
|
|
679
|
-
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 ? [] : [{
|
|
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' ? [] : [{
|
|
680
600
|
id: 'remove',
|
|
681
601
|
label: 'Remove',
|
|
682
602
|
description: 'Delete this account from this machine.',
|
|
@@ -688,7 +608,7 @@ export function buildGaMenu(snapshot, now) {
|
|
|
688
608
|
}])]
|
|
689
609
|
};
|
|
690
610
|
}),
|
|
691
|
-
actions: snapshot.vaultHostStatus ? [] : [{
|
|
611
|
+
actions: snapshot.vaultHostStatus || settings.selectionStrategy === 'vault' ? [] : [{
|
|
692
612
|
id: 'add',
|
|
693
613
|
label: 'Add account',
|
|
694
614
|
description: 'Sign in with Google in your browser.',
|
|
@@ -781,145 +701,105 @@ export function buildGaMenu(snapshot, now) {
|
|
|
781
701
|
};
|
|
782
702
|
}
|
|
783
703
|
|
|
784
|
-
/**
|
|
704
|
+
/** A displayed choice is no longer present in the server-issued menu. */
|
|
785
705
|
export class GaMenuChoiceError extends Error {
|
|
786
706
|
constructor(message) {
|
|
787
707
|
super(message);
|
|
788
708
|
this.name = 'GaMenuChoiceError';
|
|
789
709
|
}
|
|
790
710
|
}
|
|
791
|
-
const TEXT_ACTIONS = {
|
|
792
|
-
'accounts/add': {
|
|
793
|
-
command: 'antigravity-account',
|
|
794
|
-
arguments: 'add-oauth-start'
|
|
795
|
-
},
|
|
796
|
-
'quota/refresh': {
|
|
797
|
-
command: 'antigravity-quota',
|
|
798
|
-
arguments: 'refresh'
|
|
799
|
-
},
|
|
800
|
-
'limits/killswitch-on': {
|
|
801
|
-
command: 'antigravity-killswitch',
|
|
802
|
-
arguments: 'enabled=true'
|
|
803
|
-
},
|
|
804
|
-
'limits/killswitch-off': {
|
|
805
|
-
command: 'antigravity-killswitch',
|
|
806
|
-
arguments: 'enabled=false'
|
|
807
|
-
},
|
|
808
|
-
'diagnostics/dump-on': {
|
|
809
|
-
command: 'antigravity-dump',
|
|
810
|
-
arguments: 'on'
|
|
811
|
-
},
|
|
812
|
-
'diagnostics/dump-off': {
|
|
813
|
-
command: 'antigravity-dump',
|
|
814
|
-
arguments: 'off'
|
|
815
|
-
}
|
|
816
|
-
};
|
|
817
|
-
|
|
818
711
|
/**
|
|
819
|
-
*
|
|
820
|
-
*
|
|
821
|
-
*
|
|
822
|
-
*
|
|
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.
|
|
823
716
|
*/
|
|
824
|
-
export function
|
|
825
|
-
const
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
} : request.actionId === 'remove' ? {
|
|
841
|
-
kind: 'remove',
|
|
842
|
-
selector
|
|
843
|
-
} : request.actionId === 'select-active' ? {
|
|
844
|
-
kind: 'select',
|
|
845
|
-
selector,
|
|
846
|
-
target: 'active'
|
|
847
|
-
} : request.actionId === 'select-claude' ? {
|
|
848
|
-
kind: 'select',
|
|
849
|
-
selector,
|
|
850
|
-
target: 'claude'
|
|
851
|
-
} : request.actionId === 'select-gemini' ? {
|
|
852
|
-
kind: 'select',
|
|
853
|
-
selector,
|
|
854
|
-
target: 'gemini'
|
|
855
|
-
} : undefined;
|
|
856
|
-
if (!action) throw new GaMenuChoiceError('Unknown account action.');
|
|
857
|
-
if (action.kind === 'remove' && request.confirmed !== true) {
|
|
858
|
-
throw new GaMenuChoiceError('Removing an account needs a confirmation.');
|
|
859
|
-
}
|
|
860
|
-
return {
|
|
861
|
-
command: 'antigravity-account',
|
|
862
|
-
action
|
|
863
|
-
};
|
|
864
|
-
}
|
|
865
|
-
if (request.itemId !== undefined) {
|
|
866
|
-
throw new GaMenuChoiceError('Unknown menu entry.');
|
|
867
|
-
}
|
|
868
|
-
const fixed = TEXT_ACTIONS[key];
|
|
869
|
-
if (fixed) return fixed;
|
|
870
|
-
if (key === 'limits/killswitch-minimum') {
|
|
871
|
-
const percent = request.values.percent;
|
|
872
|
-
if (typeof percent !== 'number' || !Number.isInteger(percent) || percent < 0 || percent > 100) {
|
|
873
|
-
throw new GaMenuChoiceError('The minimum must be a whole number from 0 to 100.');
|
|
874
|
-
}
|
|
875
|
-
return {
|
|
876
|
-
command: 'antigravity-killswitch',
|
|
877
|
-
arguments: `minimum_remaining_percent=${percent}`
|
|
878
|
-
};
|
|
879
|
-
}
|
|
880
|
-
if (key === 'diagnostics/log-level') {
|
|
881
|
-
const level = request.values.level;
|
|
882
|
-
if (!GA_LOG_LEVELS.includes(level)) {
|
|
883
|
-
throw new GaMenuChoiceError('Unknown log level.');
|
|
884
|
-
}
|
|
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
|
+
}));
|
|
885
733
|
return {
|
|
886
|
-
|
|
887
|
-
|
|
734
|
+
...display,
|
|
735
|
+
...(action.confirm ? {
|
|
736
|
+
confirm: action.confirm
|
|
737
|
+
} : {})
|
|
888
738
|
};
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
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
|
+
});
|
|
914
791
|
}
|
|
915
792
|
return {
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
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
|
+
}
|
|
923
803
|
};
|
|
924
804
|
}
|
|
925
805
|
|
|
@@ -1175,7 +1055,7 @@ export function setupGaTui(context, options = {}) {
|
|
|
1175
1055
|
})
|
|
1176
1056
|
});
|
|
1177
1057
|
|
|
1178
|
-
//
|
|
1058
|
+
// Sidebar readings and presentation are scoped to the menu's own session.
|
|
1179
1059
|
const latest = new Map();
|
|
1180
1060
|
const showSnapshot = snapshot => {
|
|
1181
1061
|
latest.set(scopeKey(snapshot.scope), snapshot);
|
|
@@ -1190,16 +1070,14 @@ export function setupGaTui(context, options = {}) {
|
|
|
1190
1070
|
};
|
|
1191
1071
|
|
|
1192
1072
|
/**
|
|
1193
|
-
* Pulls fresh state for `scope
|
|
1073
|
+
* Pulls fresh state for `scope`. Any
|
|
1194
1074
|
* notifications the pull carries are handled like a poll tick's.
|
|
1195
1075
|
*/
|
|
1196
|
-
const
|
|
1197
|
-
let fresh;
|
|
1076
|
+
const refresh = async scope => {
|
|
1198
1077
|
await pollGaOnce({
|
|
1199
1078
|
client,
|
|
1200
1079
|
scope: () => scope,
|
|
1201
1080
|
onSnapshot: snapshot => {
|
|
1202
|
-
fresh = snapshot;
|
|
1203
1081
|
showSnapshot(snapshot);
|
|
1204
1082
|
},
|
|
1205
1083
|
onNotification,
|
|
@@ -1207,7 +1085,6 @@ export function setupGaTui(context, options = {}) {
|
|
|
1207
1085
|
logger
|
|
1208
1086
|
} : {})
|
|
1209
1087
|
});
|
|
1210
|
-
return fresh ? buildGaMenu(fresh, now()) : undefined;
|
|
1211
1088
|
};
|
|
1212
1089
|
const applyChoice = async (scope, request, shown) => {
|
|
1213
1090
|
const refused = async (text, code) => ({
|
|
@@ -1215,11 +1092,13 @@ export function setupGaTui(context, options = {}) {
|
|
|
1215
1092
|
ok: false,
|
|
1216
1093
|
text,
|
|
1217
1094
|
code,
|
|
1218
|
-
menu:
|
|
1095
|
+
menu: shown.source
|
|
1219
1096
|
});
|
|
1220
1097
|
let body;
|
|
1221
1098
|
try {
|
|
1222
|
-
body =
|
|
1099
|
+
body = {
|
|
1100
|
+
request: shown.request(request)
|
|
1101
|
+
};
|
|
1223
1102
|
} catch (error) {
|
|
1224
1103
|
if (error instanceof GaMenuChoiceError) return refused(error.message, 'invalid-choice');
|
|
1225
1104
|
throw error;
|
|
@@ -1231,30 +1110,35 @@ export function setupGaTui(context, options = {}) {
|
|
|
1231
1110
|
if (error instanceof GaStaleError) return refused(error.message, error.reason);
|
|
1232
1111
|
throw error;
|
|
1233
1112
|
}
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
const menu = (await freshMenu(scope)) ?? shown();
|
|
1237
|
-
return gaMenuResult(result, menu);
|
|
1113
|
+
await refresh(scope);
|
|
1114
|
+
return result;
|
|
1238
1115
|
};
|
|
1239
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
|
+
}
|
|
1240
1122
|
const snapshot = latest.get(scopeKey(scope));
|
|
1241
1123
|
if (!snapshot) return;
|
|
1242
|
-
let shown =
|
|
1124
|
+
let shown = presentGaMenu(snapshot, now(), payload.menu);
|
|
1243
1125
|
void openAntigravityMenu({
|
|
1244
1126
|
ui,
|
|
1245
1127
|
apply: async request => {
|
|
1246
|
-
const result = await applyChoice(scope, request,
|
|
1247
|
-
shown = result.menu;
|
|
1248
|
-
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
|
+
};
|
|
1249
1134
|
},
|
|
1250
1135
|
...(context.renderer?.copyToClipboardOSC52 ? {
|
|
1251
1136
|
copy: text => context.renderer?.copyToClipboardOSC52?.(text) === true
|
|
1252
1137
|
} : {}),
|
|
1253
|
-
onError: (message, detail) => logger?.warn(message, detail)
|
|
1254
|
-
startSection: sectionForCommand(notification.command)
|
|
1138
|
+
onError: (message, detail) => logger?.warn(message, detail)
|
|
1255
1139
|
}, {
|
|
1256
1140
|
command: ANTIGRAVITY_MENU_COMMAND,
|
|
1257
|
-
menu: shown
|
|
1141
|
+
menu: shown.menu
|
|
1258
1142
|
}).catch(error => {
|
|
1259
1143
|
logger?.warn('menu-drawer-failed', {
|
|
1260
1144
|
error: error instanceof Error ? error.name : typeof error
|