@aragon-agent/cli 0.6.71 → 0.6.73
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/CHANGELOG.md +29 -0
- package/README.md +20 -0
- package/dist/account/config.d.ts +61 -0
- package/dist/account/config.js +83 -0
- package/dist/account/device-client.d.ts +113 -0
- package/dist/account/device-client.js +425 -0
- package/dist/account/format.d.ts +51 -0
- package/dist/account/format.js +102 -0
- package/dist/account/login-flow.d.ts +68 -0
- package/dist/account/login-flow.js +305 -0
- package/dist/account/session.d.ts +109 -0
- package/dist/account/session.js +109 -0
- package/dist/account/store.d.ts +86 -0
- package/dist/account/store.js +231 -0
- package/dist/app/App.js +397 -8
- package/dist/commands/account-command.d.ts +96 -0
- package/dist/commands/account-command.js +194 -0
- package/dist/commands/builtins.js +19 -0
- package/dist/commands/catalog.js +24 -0
- package/dist/config/app-paths.d.ts +15 -0
- package/dist/config/app-paths.js +17 -0
- package/package.json +3 -3
package/dist/app/App.js
CHANGED
|
@@ -43,6 +43,7 @@ import { boardDataFromRun, boardDataFromSnapshot, } from '@aragon-agent/tui/ui/l
|
|
|
43
43
|
import { isGovernancePosture, nextPosture, splitPosture, } from '@aragon-agent/tui/model/governance/posture';
|
|
44
44
|
import { GOVERN_INTRO_NOTICE, PLAN_APPROVED_TOAST, PLAN_GOVERN_INTRO_NOTICE, posturePendingToast, postureAppliedToast, stageRunningToast, } from '../governance/copy.js';
|
|
45
45
|
import { TodoPanel } from '@aragon-agent/tui/ui/TodoPanel';
|
|
46
|
+
import { liveSpinner } from '@aragon-agent/tui/ui/ActivityLine';
|
|
46
47
|
import { BottomStatusRow } from '@aragon-agent/tui/ui/BottomStatusRow';
|
|
47
48
|
// Only the updater's pure visibility predicate enters the status detail plan.
|
|
48
49
|
import { shouldRenderUpdateLine } from '@aragon-agent/tui/model/update/types';
|
|
@@ -69,6 +70,14 @@ import { useGovernanceRounds } from './use-governance-rounds.js';
|
|
|
69
70
|
// deferred arming and the banner. Same adapter shape as `use-team-mode` above.
|
|
70
71
|
import { redTeamToastTtlMs, useRedTeamMode, } from './use-redteam-mode.js';
|
|
71
72
|
import { RedTeamDisclaimerOverlay } from '@aragon-agent/tui/ui/overlays/RedTeamDisclaimerOverlay';
|
|
73
|
+
// THE SIGN-IN PANEL (`/login`, C6): pure presentation, four phases. Imported beside the waiver
|
|
74
|
+
// overlay because it is the same kind of surface - one Ink component the App drives from
|
|
75
|
+
// `state.overlay`.
|
|
76
|
+
import { LoginOverlay } from '@aragon-agent/tui/ui/overlays/LoginOverlay';
|
|
77
|
+
// THE ACCOUNT PANEL (`Ctrl+X` / `Alt+X` / `/account`, tui-account-identity-and-panel A5). Pure
|
|
78
|
+
// presentation, like the sign-in panel beside it: the credential is read HERE and handed down,
|
|
79
|
+
// because `tui` may not import `cli` (L1) and `<home>/account.json` is CLI territory.
|
|
80
|
+
import { AccountPanel } from '@aragon-agent/tui/ui/overlays/AccountPanel';
|
|
72
81
|
import { teamStatusFromView } from '@aragon-agent/tui/model/team/team-mode';
|
|
73
82
|
import { FORCED_NUDGE_GRACE_MS } from '@aragon-agent/tui/model/team/limits';
|
|
74
83
|
import { TeamWakeDriver } from '../host/team-wake-driver.js';
|
|
@@ -86,6 +95,16 @@ import { INDEX_SKILL_NAME, buildIndexConfirmSummary, hasProjectIndex, indexBuild
|
|
|
86
95
|
import { installConsoleBridge } from '@aragon-agent/tui/ui/console-bridge';
|
|
87
96
|
import { publishExitSnapshot } from '@aragon-agent/tui/ui/exit-snapshot';
|
|
88
97
|
import { publishSessionView } from './session-bridge.js';
|
|
98
|
+
// THE DEVICE-FLOW ACCOUNT LAYER (`/login`, `/logout`: C3-C6). The network state machine and the
|
|
99
|
+
// 0600 credential file live in `account/`; this file owns only the panel's four-phase state and
|
|
100
|
+
// the promise that drives it. `setAccountCommandPort` is how the two commands reach the App -
|
|
101
|
+
// `CommandContext` has no account field and `commands/registry.ts` is outside this work package.
|
|
102
|
+
import { setAccountCommandPort, startupAccountNotice, } from '../commands/account-command.js';
|
|
103
|
+
import { readAccountSnapshot, readAccountStatus, statusFromSnapshot, } from '../account/session.js';
|
|
104
|
+
import { clearAccount } from '../account/store.js';
|
|
105
|
+
import { formatIsoDate } from '../account/format.js';
|
|
106
|
+
import { startLogin } from '../account/login-flow.js';
|
|
107
|
+
import { getAccountPath } from '../config/app-paths.js';
|
|
89
108
|
import { OverlayFrame, overlayPageSize } from '@aragon-agent/tui/ui/layout/OverlayFrame';
|
|
90
109
|
import { helpRows } from '@aragon-agent/tui/ui/overlays/HelpOverlay';
|
|
91
110
|
import { ModelPicker } from '@aragon-agent/tui/ui/overlays/ModelPicker';
|
|
@@ -251,6 +270,52 @@ function firstUserText(entries) {
|
|
|
251
270
|
* shape of refusal as `tooSmall` - and the header keeps naming `Esc close`.
|
|
252
271
|
*/
|
|
253
272
|
const DECISION_OVERLAYS = new Set(['confirm', 'question', 'plan']);
|
|
273
|
+
/**
|
|
274
|
+
* How often the account watcher looks for a credential written by ANOTHER terminal
|
|
275
|
+
* (tui-account-identity-and-panel section 6.4 (5)).
|
|
276
|
+
*
|
|
277
|
+
* A MINUTE, NOT A FRAME. The thing that changes the dot on its own - the clock - is
|
|
278
|
+
* handled per frame by `classifyExpiry` (E-3), so this timer exists only for the FILE:
|
|
279
|
+
* `/login` or `/logout` typed in another window. 60s is the shortest interval that is
|
|
280
|
+
* invisible in a profile and still feels immediate to a person who just signed in
|
|
281
|
+
* somewhere else.
|
|
282
|
+
*/
|
|
283
|
+
const ACCOUNT_WATCH_MS = 60_000;
|
|
284
|
+
/**
|
|
285
|
+
* Whether two snapshots say the same thing, so the watcher can leave `state` alone.
|
|
286
|
+
*
|
|
287
|
+
* WITHOUT THIS the timer would repaint a streaming transcript 60 times an hour for
|
|
288
|
+
* nothing: a fresh object identity is a re-render of the whole App.
|
|
289
|
+
*/
|
|
290
|
+
function sameAccountSnapshot(a, b) {
|
|
291
|
+
if (a === null || b === null)
|
|
292
|
+
return a === b;
|
|
293
|
+
return a.username === b.username
|
|
294
|
+
&& a.email === b.email
|
|
295
|
+
&& a.userId === b.userId
|
|
296
|
+
&& a.tokenPrefix === b.tokenPrefix
|
|
297
|
+
&& a.baseUrl === b.baseUrl
|
|
298
|
+
&& a.issuedAt === b.issuedAt
|
|
299
|
+
&& a.expiresAt === b.expiresAt
|
|
300
|
+
&& a.accountPath === b.accountPath
|
|
301
|
+
&& a.scopes.join(',') === b.scopes.join(',');
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* `AccountState` minus `signed-out`: the identity row only exists while a credential
|
|
305
|
+
* does, so anything that is not `valid` or `expiring` draws as `expired`.
|
|
306
|
+
*/
|
|
307
|
+
function headerAccountState(state) {
|
|
308
|
+
return state === 'valid' || state === 'expiring' ? state : 'expired';
|
|
309
|
+
}
|
|
310
|
+
/** The panel before anything has been asked of the server (`/login` and every retry start here). */
|
|
311
|
+
const INITIAL_LOGIN_VIEW = {
|
|
312
|
+
phase: 'prompt',
|
|
313
|
+
link: '',
|
|
314
|
+
code: '',
|
|
315
|
+
elapsedSec: 0,
|
|
316
|
+
account: null,
|
|
317
|
+
message: '',
|
|
318
|
+
};
|
|
254
319
|
/** The LAST finished assistant message's text, or `null` — the source for memory `l`. */
|
|
255
320
|
function lastAssistantText(entries) {
|
|
256
321
|
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
@@ -1691,6 +1756,242 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
1691
1756
|
// --- Helpers -----------------------------------------------------------
|
|
1692
1757
|
const notify = (level, text) => dispatch({ type: 'notice', level, text });
|
|
1693
1758
|
const toast = (level, text) => dispatch({ type: 'pushToast', level, text });
|
|
1759
|
+
// --- Device-flow sign-in (`/login`, C5 / C6) -----------------------------
|
|
1760
|
+
//
|
|
1761
|
+
// THE FLOW IS NOT THE PANEL, and that separation is the whole design. `startLogin` is a
|
|
1762
|
+
// promise THIS component owns; `state.overlay === 'login'` only decides whether the panel is
|
|
1763
|
+
// on screen. So `Esc` hides the panel and the device poll keeps running (C6: "waiting Esc =
|
|
1764
|
+
// onClose, the flow does not stop"), and the outcome is announced from the promise's
|
|
1765
|
+
// continuation - which is the only place that still knows about it after a hide.
|
|
1766
|
+
const [loginView, setLoginView] = useState(INITIAL_LOGIN_VIEW);
|
|
1767
|
+
/** ONE FLOW AT A TIME: a second Enter must not start a second authorization. */
|
|
1768
|
+
const loginBusy = useRef(false);
|
|
1769
|
+
/** The abort handle, so UNMOUNTING stops a poll nobody can see. `Esc` never touches it. */
|
|
1770
|
+
const loginAbort = useRef(null);
|
|
1771
|
+
/** The startup-notice latch: spec 6.6 asks for ONE prompt per launch, not one per render. */
|
|
1772
|
+
const accountNoticeShown = useRef(false);
|
|
1773
|
+
/**
|
|
1774
|
+
* THE IDENTITY SNAPSHOT (tui-account-identity-and-panel D-1 / D-5).
|
|
1775
|
+
*
|
|
1776
|
+
* THIS IS THE STATE THE DATA CHAIN WAS MISSING. Before it, `App` read the credential
|
|
1777
|
+
* once at mount, turned the answer into a notice and threw the answer away, so no
|
|
1778
|
+
* render path could ever know who was signed in. The header row and the account panel
|
|
1779
|
+
* now read this one value.
|
|
1780
|
+
*
|
|
1781
|
+
* ITS SHAPE IS NOT `AccountStatus`: the panel needs `email` / `userId` / `scopes` /
|
|
1782
|
+
* `issuedAt`, and `readAccountStatus` is consumed by `/login` and its tests, so widening
|
|
1783
|
+
* that contract was not an option (D-5).
|
|
1784
|
+
*
|
|
1785
|
+
* `null` MEANS SIGNED OUT - and it means the frame spends not one extra cell.
|
|
1786
|
+
*/
|
|
1787
|
+
const [accountSnapshot, setAccountSnapshot] = useState(null);
|
|
1788
|
+
/** The panel's one-line answer to the last action (a refused sign-out, a fresh file). */
|
|
1789
|
+
const [accountNotice, setAccountNotice] = useState(null);
|
|
1790
|
+
/**
|
|
1791
|
+
* Re-read the credential. THE ONLY PLACE THAT TOUCHES THE DISK ON THIS SURFACE, and it
|
|
1792
|
+
* runs on five low-frequency events: mount, a finished sign-in, a sign-out, the panel's
|
|
1793
|
+
* `r`, and the once-a-minute watcher. Every frame after that is pure arithmetic.
|
|
1794
|
+
*/
|
|
1795
|
+
const refreshAccountSnapshot = () => {
|
|
1796
|
+
const next = readAccountSnapshot();
|
|
1797
|
+
setAccountSnapshot(next);
|
|
1798
|
+
return next;
|
|
1799
|
+
};
|
|
1800
|
+
/** `/login` and the panel's `prompt` phase: show the panel, ask the server nothing yet. */
|
|
1801
|
+
const openLoginPanel = () => {
|
|
1802
|
+
// A FLOW ALREADY IN FLIGHT IS NOT RESET. `/login` typed while the device poll is waiting
|
|
1803
|
+
// (a second terminal, a second thought) has to show the code that is still valid; dropping
|
|
1804
|
+
// back to `prompt` would hide it behind an Enter that `startLoginFlow` then refuses, and
|
|
1805
|
+
// the panel would look broken while the sign-in was in fact progressing.
|
|
1806
|
+
if (!loginBusy.current)
|
|
1807
|
+
setLoginView(INITIAL_LOGIN_VIEW);
|
|
1808
|
+
dispatch({ type: 'setOverlay', overlay: 'login' });
|
|
1809
|
+
};
|
|
1810
|
+
/**
|
|
1811
|
+
* The account panel, from every route that opens it (`Ctrl+X`, `Alt+X`, `/account`).
|
|
1812
|
+
*
|
|
1813
|
+
* ONE FUNCTION FOR THE THREE so they cannot disagree about the stale notice: opening
|
|
1814
|
+
* the panel always starts from a clean slate, exactly like the drawer starts from a
|
|
1815
|
+
* clean cursor.
|
|
1816
|
+
*/
|
|
1817
|
+
const openAccountPanel = () => {
|
|
1818
|
+
setAccountNotice(null);
|
|
1819
|
+
dispatch({ type: 'setOverlay', overlay: 'account' });
|
|
1820
|
+
};
|
|
1821
|
+
/**
|
|
1822
|
+
* Apply a finished flow: the success toast plus the durable transcript notice, or the
|
|
1823
|
+
* `error` phase carrying the account layer's own sentence.
|
|
1824
|
+
*
|
|
1825
|
+
* THE SUCCESS NOTICE IS DISPATCHED HERE RATHER THAN BY THE PANEL because `Esc` may have
|
|
1826
|
+
* hidden the panel minutes ago; a 20-day credential that quietly landed on disk is the one
|
|
1827
|
+
* outcome a user must not be able to miss.
|
|
1828
|
+
*/
|
|
1829
|
+
const settleLogin = (outcome) => {
|
|
1830
|
+
if (!mounted.current)
|
|
1831
|
+
return;
|
|
1832
|
+
if (!outcome.ok) {
|
|
1833
|
+
setLoginView((view) => ({ ...view, phase: 'error', message: outcome.message }));
|
|
1834
|
+
return;
|
|
1835
|
+
}
|
|
1836
|
+
const { username, expiresAt } = outcome.account;
|
|
1837
|
+
setLoginView({
|
|
1838
|
+
phase: 'success', link: '', code: '', elapsedSec: 0,
|
|
1839
|
+
account: { username, expiresAt }, message: '',
|
|
1840
|
+
});
|
|
1841
|
+
toast('success', `Signed in as ${username}.`);
|
|
1842
|
+
notify('info', `${username} signed in. The credential expires on ${formatIsoDate(expiresAt)}; ` +
|
|
1843
|
+
'run /login any time to renew it.');
|
|
1844
|
+
// THE IDENTITY ROW LANDS IN THIS FRAME (E-8). The success phase above is a toast that
|
|
1845
|
+
// expires and a panel the user can close; a RE-READ rather than `outcome.account` is
|
|
1846
|
+
// what makes "the header shows who I am" a statement about the disk rather than about
|
|
1847
|
+
// what the network answered - and it is the same entry point the other four events use.
|
|
1848
|
+
refreshAccountSnapshot();
|
|
1849
|
+
};
|
|
1850
|
+
/**
|
|
1851
|
+
* Run one device-flow login, DETACHED from the composer (the panel's Enter, and every retry).
|
|
1852
|
+
*
|
|
1853
|
+
* `waiting` IS SET BEFORE THE FIRST REQUEST on purpose: the panel must never sit on the
|
|
1854
|
+
* `prompt` phase (whose Enter is live) while a POST it already started is in flight, or a
|
|
1855
|
+
* second Enter would open a second authorization.
|
|
1856
|
+
*/
|
|
1857
|
+
const startLoginFlow = async () => {
|
|
1858
|
+
if (loginBusy.current) {
|
|
1859
|
+
toast('info', 'A sign-in is already in progress.');
|
|
1860
|
+
return;
|
|
1861
|
+
}
|
|
1862
|
+
loginBusy.current = true;
|
|
1863
|
+
const abort = new AbortController();
|
|
1864
|
+
loginAbort.current = abort;
|
|
1865
|
+
setLoginView({ ...INITIAL_LOGIN_VIEW, phase: 'waiting' });
|
|
1866
|
+
let outcome = null;
|
|
1867
|
+
try {
|
|
1868
|
+
outcome = await startLogin({
|
|
1869
|
+
signal: abort.signal,
|
|
1870
|
+
onCode: (code) => {
|
|
1871
|
+
if (!mounted.current)
|
|
1872
|
+
return;
|
|
1873
|
+
setLoginView({
|
|
1874
|
+
phase: 'waiting', link: code.link, code: code.code,
|
|
1875
|
+
elapsedSec: 0, account: null, message: '',
|
|
1876
|
+
});
|
|
1877
|
+
},
|
|
1878
|
+
// The flow's own clock: every poll iteration reports how long we have waited, so the
|
|
1879
|
+
// panel's seconds come from the same timer the polls are scheduled on.
|
|
1880
|
+
onProgress: ({ elapsedSec }) => {
|
|
1881
|
+
if (!mounted.current)
|
|
1882
|
+
return;
|
|
1883
|
+
setLoginView((view) => (view.phase === 'waiting' ? { ...view, elapsedSec } : view));
|
|
1884
|
+
},
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1887
|
+
catch (error) {
|
|
1888
|
+
// `startLogin` promises never to throw; this is the honest answer if that ever changes,
|
|
1889
|
+
// because a rejection here would otherwise vanish as an unhandled promise rejection.
|
|
1890
|
+
getLogger().warn('cli', 'account.login_threw', {
|
|
1891
|
+
reason: error instanceof Error ? error.name : 'unknown',
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
finally {
|
|
1895
|
+
loginBusy.current = false;
|
|
1896
|
+
loginAbort.current = null;
|
|
1897
|
+
}
|
|
1898
|
+
if (!mounted.current)
|
|
1899
|
+
return;
|
|
1900
|
+
if (outcome === null) {
|
|
1901
|
+
setLoginView((view) => ({
|
|
1902
|
+
...view,
|
|
1903
|
+
phase: 'error',
|
|
1904
|
+
message: 'Sign-in failed unexpectedly. Run /login to try again.',
|
|
1905
|
+
}));
|
|
1906
|
+
return;
|
|
1907
|
+
}
|
|
1908
|
+
settleLogin(outcome);
|
|
1909
|
+
};
|
|
1910
|
+
/**
|
|
1911
|
+
* Install the App's account port and contribute NO context fields.
|
|
1912
|
+
*
|
|
1913
|
+
* A SPREAD FOR ITS SIDE EFFECT, which is unusual enough to justify in place: `CommandContext`
|
|
1914
|
+
* has no account field and `commands/registry.ts` (where it is declared) is outside this work
|
|
1915
|
+
* package, so the two commands read the port from `commands/account-command.ts`'s own
|
|
1916
|
+
* registration seam instead. Installing it from `makeCtx` means the port always belongs to
|
|
1917
|
+
* the App that is dispatching the command, and a build that never builds a context
|
|
1918
|
+
* (headless, a sub-agent, a host double) leaves the commands on their honest "not available"
|
|
1919
|
+
* branch.
|
|
1920
|
+
*/
|
|
1921
|
+
/**
|
|
1922
|
+
* Delete the credential and re-read it - the ONE sign-out path, shared by `/logout` and
|
|
1923
|
+
* by the panel's `x`.
|
|
1924
|
+
*
|
|
1925
|
+
* NEVER OPTIMISTIC (review 9.7): `clearAccount` answers `false` when the filesystem
|
|
1926
|
+
* refused, and a header that dropped the name anyway would be describing a live 20-day
|
|
1927
|
+
* bearer token as gone. The re-read is what makes the row honest in both answers.
|
|
1928
|
+
*/
|
|
1929
|
+
const signOutAccount = () => {
|
|
1930
|
+
const hadCredential = readAccountStatus().state !== 'signed-out';
|
|
1931
|
+
const ok = clearAccount();
|
|
1932
|
+
refreshAccountSnapshot();
|
|
1933
|
+
return { ok, hadCredential };
|
|
1934
|
+
};
|
|
1935
|
+
/**
|
|
1936
|
+
* The panel's `x` (its SECOND press; the first only arms). The panel says what happened
|
|
1937
|
+
* on its own last row, because a toast would scroll away and `/logout`'s transcript
|
|
1938
|
+
* notice belongs to the command, not to a key.
|
|
1939
|
+
*/
|
|
1940
|
+
const handleAccountSignOut = () => {
|
|
1941
|
+
const result = signOutAccount();
|
|
1942
|
+
if (!result.ok) {
|
|
1943
|
+
setAccountNotice(`Sign-out failed: ${getAccountPath()} is still there. `
|
|
1944
|
+
+ 'Delete it by hand or fix its permissions.');
|
|
1945
|
+
return;
|
|
1946
|
+
}
|
|
1947
|
+
setAccountNotice(result.hadCredential
|
|
1948
|
+
? 'Signed out. The credential file is deleted.'
|
|
1949
|
+
: 'Not signed in - there was no credential to delete.');
|
|
1950
|
+
};
|
|
1951
|
+
const installAccountPort = () => {
|
|
1952
|
+
setAccountCommandPort({
|
|
1953
|
+
status: () => readAccountStatus(),
|
|
1954
|
+
accountPath: getAccountPath,
|
|
1955
|
+
openLogin: openLoginPanel,
|
|
1956
|
+
openAccount: openAccountPanel,
|
|
1957
|
+
signOut: () => signOutAccount(),
|
|
1958
|
+
});
|
|
1959
|
+
return {};
|
|
1960
|
+
};
|
|
1961
|
+
// THE ONE STARTUP LINE (spec 6.6): read the credential once, say ONE thing about it, and
|
|
1962
|
+
// stay completely silent for `signed-out` and `valid`. The latch is a ref rather than state
|
|
1963
|
+
// because a re-render must not replay it, and it is set BEFORE the read so nothing in the
|
|
1964
|
+
// account layer can turn this into a notice on every frame.
|
|
1965
|
+
useEffect(() => {
|
|
1966
|
+
if (accountNoticeShown.current)
|
|
1967
|
+
return;
|
|
1968
|
+
accountNoticeShown.current = true;
|
|
1969
|
+
// ONE READ, TWO USES (section 6.4 (1)): the snapshot feeds the identity row and the
|
|
1970
|
+
// panel, and the SAME snapshot's status feeds the one startup sentence. Reading twice
|
|
1971
|
+
// would be two chances to disagree about who is signed in and how long it lasts.
|
|
1972
|
+
const snapshot = refreshAccountSnapshot();
|
|
1973
|
+
const text = startupAccountNotice(statusFromSnapshot(snapshot));
|
|
1974
|
+
if (text !== null)
|
|
1975
|
+
notify('info', text);
|
|
1976
|
+
// Mount-only by design: `/login` and `/logout` report for themselves.
|
|
1977
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1978
|
+
}, []);
|
|
1979
|
+
// THE ONLY POLL, AND IT IS ONE READ A MINUTE (review 9.2). The clock is not polled: the
|
|
1980
|
+
// dot is re-derived per frame from `expiresAt`, so a credential that runs out mid-session
|
|
1981
|
+
// changes without a timer. What a timer is needed for is the FILE - `/login` or `/logout`
|
|
1982
|
+
// in another terminal - and that only repaints when the answer actually changed.
|
|
1983
|
+
useEffect(() => {
|
|
1984
|
+
const id = setInterval(() => {
|
|
1985
|
+
if (!mounted.current)
|
|
1986
|
+
return;
|
|
1987
|
+
const next = readAccountSnapshot();
|
|
1988
|
+
setAccountSnapshot((prev) => (sameAccountSnapshot(prev, next) ? prev : next));
|
|
1989
|
+
}, ACCOUNT_WATCH_MS);
|
|
1990
|
+
return () => clearInterval(id);
|
|
1991
|
+
}, []);
|
|
1992
|
+
// A poll nobody can see must not outlive the tree that could show it. This is the ONLY
|
|
1993
|
+
// abort: `Esc` deliberately leaves the flow running (C6).
|
|
1994
|
+
useEffect(() => () => loginAbort.current?.abort(), []);
|
|
1694
1995
|
// --- Quick prompt library: two one-shot channels and the store port ------
|
|
1695
1996
|
const refreshPromptLibrary = useCallback(() => setPromptLibrary(loadPromptLibrary()), []);
|
|
1696
1997
|
/**
|
|
@@ -2282,6 +2583,10 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
2282
2583
|
};
|
|
2283
2584
|
const invocationCardsOn = invocationCardsEnabled();
|
|
2284
2585
|
const makeCtx = (args) => ({
|
|
2586
|
+
// INSTALLED FIRST, BEFORE ANY FIELD IS READ, so `/login` and `/logout` can never run against
|
|
2587
|
+
// a port from a previous App instance. See `installAccountPort` for why this is a spread and
|
|
2588
|
+
// not a field on `CommandContext`.
|
|
2589
|
+
...installAccountPort(),
|
|
2285
2590
|
args,
|
|
2286
2591
|
invocationCards: invocationCardsOn,
|
|
2287
2592
|
requestCopy: copyCoordinator.requestCopy,
|
|
@@ -3146,6 +3451,36 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3146
3451
|
void executeSlashInput('/branch');
|
|
3147
3452
|
return;
|
|
3148
3453
|
}
|
|
3454
|
+
// Ctrl+X / Alt+X: THE ACCOUNT PANEL (tui-account-identity-and-panel A4).
|
|
3455
|
+
//
|
|
3456
|
+
// X AND NOT Y, AND THAT IS A CORRECTNESS DECISION RATHER THAN A MNEMONIC ONE. Ink
|
|
3457
|
+
// delivers Ctrl+Y as `input === 'y'` together with `key.ctrl === true`, and three
|
|
3458
|
+
// handlers in this repo act on a bare `y` - the approval dialog approves a MUTATING
|
|
3459
|
+
// tool, the prompt library deletes a page, the waiver signs itself - so `y` would pull
|
|
3460
|
+
// all three triggers on one keystroke. `gene.key` can also be configured to `ctrl+y`,
|
|
3461
|
+
// which takes the Alt twin out as well. `\x18` and `ESC x` are unbound repo-wide, and
|
|
3462
|
+
// the only two bare-`x` consumers are already ctrl/meta guarded.
|
|
3463
|
+
//
|
|
3464
|
+
// THE GUARD ORDER IS Ctrl+G'S EXACTLY: a second press closes the panel, a decision
|
|
3465
|
+
// overlay keeps the keyboard (it holds an unresolved promise to the agent, and the
|
|
3466
|
+
// Escape branch is the only path that settles one), and `tooSmall` is inert INSIDE
|
|
3467
|
+
// this branch - so "the key did nothing" stays distinguishable from "it never arrived".
|
|
3468
|
+
const isCtrlX = (key.ctrl && (input === 'x' || input === 'X')) || input === '\x18';
|
|
3469
|
+
const isAltX = (key.meta && !key.ctrl && (input === 'x' || input === 'X'))
|
|
3470
|
+
|| input === '\x1bx';
|
|
3471
|
+
if (isCtrlX || isAltX) {
|
|
3472
|
+
if (tooSmall)
|
|
3473
|
+
return;
|
|
3474
|
+
const openNow = stateRef.current.overlay;
|
|
3475
|
+
if (DECISION_OVERLAYS.has(openNow))
|
|
3476
|
+
return;
|
|
3477
|
+
if (openNow === 'account') {
|
|
3478
|
+
dispatch({ type: 'setOverlay', overlay: null });
|
|
3479
|
+
return;
|
|
3480
|
+
}
|
|
3481
|
+
openAccountPanel();
|
|
3482
|
+
return;
|
|
3483
|
+
}
|
|
3149
3484
|
if (tooSmall)
|
|
3150
3485
|
return;
|
|
3151
3486
|
// R-P1-7: the overlay branch MUST come before the transcript scroll branch
|
|
@@ -3171,7 +3506,11 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3171
3506
|
// The memory manager pages through `overlayScroll` too (agent-memory V-4).
|
|
3172
3507
|
|| overlay === 'memory'
|
|
3173
3508
|
// And so does the gene manager (gene-bank 12.2).
|
|
3174
|
-
|| overlay === 'gene'
|
|
3509
|
+
|| overlay === 'gene'
|
|
3510
|
+
// The account panel is a fixed list, so it has nothing to page - but PgDn in it must
|
|
3511
|
+
// not fall through to the transcript BEHIND it, which is the hole the governance
|
|
3512
|
+
// board had before it was named here.
|
|
3513
|
+
|| overlay === 'account';
|
|
3175
3514
|
if (key.pageUp) {
|
|
3176
3515
|
if (controlled)
|
|
3177
3516
|
setOverlayScroll((n) => Math.max(0, n - overlayPage));
|
|
@@ -3344,6 +3683,13 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3344
3683
|
const overlay = stateRef.current.overlay;
|
|
3345
3684
|
if (overlay === 'settings')
|
|
3346
3685
|
return;
|
|
3686
|
+
// THE SIGN-IN PANEL OWNS ITS `Esc` (C6). `App` steps aside rather than closing it here:
|
|
3687
|
+
// the panel's own handler calls `onClose`, which hides it and NOTHING ELSE. Closing it in
|
|
3688
|
+
// both places would be one state change twice, and it would put the abort handle within
|
|
3689
|
+
// reach of this branch - which is exactly the coupling C6 forbids (Esc must not stop the
|
|
3690
|
+
// device flow).
|
|
3691
|
+
if (overlay === 'login')
|
|
3692
|
+
return;
|
|
3347
3693
|
// THE MEMORY MANAGER OWNS ITS Esc, like settings: the editor's first Esc only ARMS the
|
|
3348
3694
|
// discard, and closing the overlay here as well would throw the half-typed note away on
|
|
3349
3695
|
// that first press (AC-31). Only when it is actually mounted: with no port nothing renders
|
|
@@ -3353,6 +3699,11 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3353
3699
|
// THE GENE MANAGER OWNS ITS Esc for the same reason: the editor's first Esc only arms the discard.
|
|
3354
3700
|
if (overlay === 'gene' && genePort)
|
|
3355
3701
|
return;
|
|
3702
|
+
// THE ACCOUNT PANEL OWNS ITS Esc, for the same shape of reason: the first Esc after `x`
|
|
3703
|
+
// has to CANCEL THE ARM, and a branch here that also closed the overlay would make the
|
|
3704
|
+
// sign-out confirmation impossible to cancel. `AccountPanel` decides; `App` steps aside.
|
|
3705
|
+
if (overlay === 'account')
|
|
3706
|
+
return;
|
|
3356
3707
|
// THE WAIVER'S `Esc` (4.3). App owns the key for the plan overlays and for this one, so
|
|
3357
3708
|
// declining and draining the queue happen in ONE place - the overlay registers no Escape
|
|
3358
3709
|
// handler of its own, and a second one would decline twice.
|
|
@@ -3564,6 +3915,8 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3564
3915
|
// 200 ms elapsed ticker already causes the render that re-reads this; an IDLE
|
|
3565
3916
|
// `/compact` has no ticker at all, which is what `compactionClock` is for.
|
|
3566
3917
|
const compactionLive = state.compactionEntryId !== undefined;
|
|
3918
|
+
const compacting = compactionLive || !!state.compaction?.inFlight;
|
|
3919
|
+
const footerActive = state.runPhase !== 'idle' || compacting;
|
|
3567
3920
|
if (running && runStartedAt.current === 0)
|
|
3568
3921
|
runStartedAt.current = Date.now();
|
|
3569
3922
|
if (!running && runStartedAt.current !== 0)
|
|
@@ -3697,15 +4050,37 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3697
4050
|
// mode already agreed; this makes the agreement a construction instead of a
|
|
3698
4051
|
// coincidence.
|
|
3699
4052
|
const headerCols = Math.max(1, frameBudget.composerCols);
|
|
4053
|
+
// ONE SNAPSHOT, TWO SURFACES (section 6.4): the header row and the panel read the same
|
|
4054
|
+
// state, and the only per-frame work is `classifyExpiry` on a timestamp - no file is
|
|
4055
|
+
// touched while tokens stream.
|
|
4056
|
+
const accountStatusNow = statusFromSnapshot(accountSnapshot, Date.now());
|
|
4057
|
+
// `signed-out` NEVER REACHES THE IDENTITY ROW: the row is what a non-null snapshot MEANS,
|
|
4058
|
+
// and drawing a hollow mark for "signed out" is exactly the cell E-2 refuses to spend.
|
|
4059
|
+
const headerAccount = accountSnapshot === null ? null : {
|
|
4060
|
+
username: accountSnapshot.username,
|
|
4061
|
+
state: headerAccountState(accountStatusNow.state),
|
|
4062
|
+
marks: { on: glyphs.keyOn, off: glyphs.keyOff },
|
|
4063
|
+
};
|
|
4064
|
+
// The panel's shape, without the token: `AccountPanelIdentity` has no field for one.
|
|
4065
|
+
const accountIdentity = accountSnapshot === null ? null : {
|
|
4066
|
+
username: accountSnapshot.username,
|
|
4067
|
+
email: accountSnapshot.email,
|
|
4068
|
+
userId: accountSnapshot.userId,
|
|
4069
|
+
scopes: accountSnapshot.scopes,
|
|
4070
|
+
tokenPrefix: accountSnapshot.tokenPrefix,
|
|
4071
|
+
baseUrl: accountSnapshot.baseUrl,
|
|
4072
|
+
issuedAt: accountSnapshot.issuedAt,
|
|
4073
|
+
expiresAt: accountSnapshot.expiresAt,
|
|
4074
|
+
};
|
|
3700
4075
|
const header = (_jsx(Header, { columns: headerCols,
|
|
3701
4076
|
// THE WORD MARK LIVES ON THE TAB NOW (S2b): the row draws the diamond alone,
|
|
3702
4077
|
// which is also what puts it at cell 0 over the composer's left border.
|
|
3703
|
-
brand: "glyph",
|
|
4078
|
+
brand: "glyph", activityGlyph: native && footerActive ? liveSpinner(reducedMotion, caps) : null,
|
|
3704
4079
|
// DERIVED IN EXACTLY ONE PLACE (0-3 (d)): both overlay slots render
|
|
3705
4080
|
// `overlayNode`, and both read this same three-state value from here.
|
|
3706
4081
|
panel: overlay === null ? 'none' : overlay === 'shortcuts' ? 'shortcuts' : 'other', scrolledLines: scrolledLines, taskSummary: state.taskSummary === null
|
|
3707
4082
|
? null
|
|
3708
|
-
: { text: state.taskSummary.text, tone: state.taskSummary.tone }, summaryEnabled: cfg.taskSummary?.enabled !== false, cwd: controller.getCwd(), provider: cfg.provider, model: cfg.model, hasKey: hasKey, variant: pickHeaderVariant(cols), theme: theme, caps: caps }));
|
|
4083
|
+
: { text: state.taskSummary.text, tone: state.taskSummary.tone }, summaryEnabled: cfg.taskSummary?.enabled !== false, cwd: controller.getCwd(), provider: cfg.provider, model: cfg.model, hasKey: hasKey, variant: pickHeaderVariant(cols), account: headerAccount, theme: theme, caps: caps }));
|
|
3709
4084
|
// The header and the opener are SLOTS OF THE SHELL, not printed bytes (D3/D4): at
|
|
3710
4085
|
// `H = rows - 1` a printed row is pushed off the screen by the very next frame, so
|
|
3711
4086
|
// `printBanner()` was a way of making the banner invisible. Neither is passed here.
|
|
@@ -3851,11 +4226,25 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3851
4226
|
// THE WAIVER (red-team-security-mode 4.3). Rendered from the reducer's overlay field like
|
|
3852
4227
|
// every other surface, so it cannot be open at the same time as a decision dialog - the
|
|
3853
4228
|
// requests that would have replaced it are queued in `queuedDecisions` instead (D-21).
|
|
3854
|
-
_jsx(RedTeamDisclaimerOverlay, { isActive: !tooSmall, cols: viewCols, maxRows: overlayMaxRows, theme: theme, caps: caps, onAccept: acceptRedTeamWaiver, onDecline: declineRedTeamWaiver })) : overlay === '
|
|
4229
|
+
_jsx(RedTeamDisclaimerOverlay, { isActive: !tooSmall, cols: viewCols, maxRows: overlayMaxRows, theme: theme, caps: caps, onAccept: acceptRedTeamWaiver, onDecline: declineRedTeamWaiver })) : overlay === 'account' ? (
|
|
4230
|
+
// THE BRANCH AND THE `Overlay` MEMBER SHIP TOGETHER (R-11), like `login` below: a
|
|
4231
|
+
// missing branch is not a type error, it is a SILENT BLANK FRAME behind a keyboard
|
|
4232
|
+
// that `active={overlay === null}` has already disabled.
|
|
4233
|
+
//
|
|
4234
|
+
// `onSignIn` is the EXISTING `openLoginPanel`, so the device flow is not re-implemented
|
|
4235
|
+
// here: the code still has to be shown, and `login` is the surface that shows it.
|
|
4236
|
+
_jsx(AccountPanel, { isActive: !tooSmall, cols: viewCols, maxRows: overlayMaxRows, theme: theme, caps: caps, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, identity: accountIdentity, state: accountStatusNow.state, daysLeft: accountStatusNow.daysLeft, accountPath: accountSnapshot === null ? getAccountPath() : accountSnapshot.accountPath, notice: accountNotice, onSignIn: openLoginPanel, onSignOut: handleAccountSignOut, onRefresh: () => { setAccountNotice(null); refreshAccountSnapshot(); }, onClose: () => dispatch({ type: 'setOverlay', overlay: null }) })) : overlay === 'login' ? (
|
|
4237
|
+
// THE SIGN-IN PANEL (C6). THE BRANCH AND THE `Overlay` MEMBER SHIP TOGETHER (R-11), like
|
|
4238
|
+
// `agents` and `governance` above: a missing branch is not a type error, it is a SILENT
|
|
4239
|
+
// BLANK FRAME behind a keyboard that `active={overlay === null}` has already disabled.
|
|
4240
|
+
//
|
|
4241
|
+
// `onStart` runs the flow; `onClose` HIDES the panel and nothing else - the device poll it
|
|
4242
|
+
// started keeps running and reports through `settleLogin`, which is why a success notice
|
|
4243
|
+
// can still arrive after the user pressed Esc.
|
|
4244
|
+
_jsx(LoginOverlay, { isActive: !tooSmall, phase: loginView.phase, link: loginView.link, code: loginView.code, elapsedSec: loginView.elapsedSec, ...(loginView.account === null ? {} : { account: loginView.account }), ...(loginView.message === '' ? {} : { message: loginView.message }), maxRows: overlayMaxRows, cols: viewCols, theme: theme, caps: caps, onStart: () => { void startLoginFlow(); }, onClose: () => dispatch({ type: 'setOverlay', overlay: null }) })) : overlay === 'confirm' && confirmState ? (_jsx(ConfirmDialog, { isActive: !tooSmall, state: confirmState, maxRows: overlayMaxRows, cols: viewCols, theme: theme, caps: caps, onClose: closeConfirm })) : overlay === 'question' && humanRequest?.kind === 'questions' ? (_jsx(QuestionOverlay, { isActive: !tooSmall, questions: humanRequest.questions, maxRows: overlayMaxRows, cols: viewCols, theme: theme, caps: caps, onSubmit: (answers) => resolveHuman({ kind: 'answers', answers, cancelled: false }), ...interviewProps })) : overlay === 'plan' && humanRequest?.kind === 'plan' ? (_jsx(PlanReviewOverlay, { isActive: !tooSmall, plan: humanRequest.plan, maxRows: overlayMaxRows, cols: viewCols, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, theme: theme, caps: caps, onVerdict: handlePlanVerdict })) : null;
|
|
3855
4245
|
const density = cfg.density;
|
|
3856
4246
|
const transcriptWindow = cfg.transcriptWindow ?? DEFAULT_TRANSCRIPT_WINDOW;
|
|
3857
|
-
|
|
3858
|
-
const viewReducedMotion = reducedMotion || running || state.runPhase === 'starting' || compactionLive;
|
|
4247
|
+
const viewReducedMotion = reducedMotion || running || footerActive;
|
|
3859
4248
|
// Assigned during render so `/perf` reads the CURRENT frame (see `perfRef`).
|
|
3860
4249
|
// `mountedEntries` is the same number `render-budget.test.tsx` asserts (AC-9).
|
|
3861
4250
|
perfRef.current = {
|
|
@@ -3964,7 +4353,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3964
4353
|
waitingForConfirmation: !!humanRequest || !!confirmState,
|
|
3965
4354
|
stopping: interruptGesture.current.phase === 'stopping',
|
|
3966
4355
|
interruptPhase: interruptGesture.current.phase,
|
|
3967
|
-
compacting
|
|
4356
|
+
compacting,
|
|
3968
4357
|
mode: state.posture, pendingMode: state.pendingPosture,
|
|
3969
4358
|
servicesActive: { live: liveServices }, ecoRung: governor.rung,
|
|
3970
4359
|
// THE STATUS-DETAIL ROW COUNTS LIKE THE ROSTER AND THE CHIP (A-1): this was the
|
|
@@ -4035,7 +4424,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
4035
4424
|
const rail = fullscreenRailVisible && state.todos ? (_jsx(TodoPanel, { snapshot: state.todos, width: railWidth, rows: railRows, running: running, reducedMotion: viewReducedMotion, theme: theme, caps: caps })) : null;
|
|
4036
4425
|
const viewport = (_jsxs(ScrollViewport, { active: overlay === null && !tooSmall, overlay: overlayNode, footer: _jsxs(_Fragment, { children: [team, _jsx(QueuePanel, { layout: queueLayout, theme: theme })] }), rail: rail, scrollbar: terminal?.scrollbar, resetKey: scrollResetKey, intent: scrollIntent, pinToBottomNonce: pinToBottomNonce, onScrolledLinesChange: setScrolledLines, onViewportShiftChange: onViewportShiftChange, onGeometryChange: onGeometryChange, geometryKey: `${rows}:${cols}:${viewportBudget}:${frameBudget.composerSlotRows}:${frameBudget.statusRows}:${contentCols}:${overlay}:${tooSmall}`, tailRowsRef: tailSink, hold: selectionHold, resumeMs: cfg.scrollResumeMs, showScrollIndicator: true, cols: contentCols, theme: theme, caps: caps, children: [opener, _jsx(TranscriptList, { entries: transcriptEntries, expandedToolIds: state.expandedToolIds, thinkingVisible: state.thinkingVisible, reducedMotion: viewReducedMotion, voice: voice, density: density, nowSec: nowSec, theme: theme, caps: caps, windowSize: transcriptWindow, cols: contentCols, heights: heights, mountedSink: mountedCount, tailSink: tailSink })] }));
|
|
4037
4426
|
const detailsNode = _jsx(BottomStatusRow, { plan: details, columns: viewCols, theme: theme });
|
|
4038
|
-
const statusNode = (_jsx(StatusBar, { columns: viewCols, speedKnown: speedKnown, ...feedbackProjection, interruptPhase: interruptGesture.current.phase, pendingSteering: state.pendingSteering, runPhase: state.runPhase, activeTool: state.activeTool, ...(wait ? { wait } : {}), runOutcome: state.runOutcome, reducedMotion: reducedMotion, ...(sessionId ? { sessionId } : {}), developerMode: state.developerMode, ...(kitChip ? { kit: kitChip } : {}), ...(memoryChip ? { memory: memoryChip } : {}), ...(geneChip && geneChip.show ? { gene: geneChip } : {}), ...(redTeam.view.available && redTeam.view.armed
|
|
4427
|
+
const statusNode = (_jsx(StatusBar, { columns: viewCols, speedKnown: speedKnown, ...feedbackProjection, interruptPhase: interruptGesture.current.phase, pendingSteering: state.pendingSteering, runPhase: state.runPhase, activeTool: state.activeTool, ...(wait ? { wait } : {}), runOutcome: state.runOutcome, reducedMotion: native || reducedMotion, ...(sessionId ? { sessionId } : {}), developerMode: state.developerMode, ...(kitChip ? { kit: kitChip } : {}), ...(memoryChip ? { memory: memoryChip } : {}), ...(geneChip && geneChip.show ? { gene: geneChip } : {}), ...(redTeam.view.available && redTeam.view.armed
|
|
4039
4428
|
? { redteam: { armed: redTeam.view.armed, paused: redTeam.view.paused } }
|
|
4040
4429
|
: {}), waitingForConfirmation: !!humanRequest || !!confirmState, stopping: interruptGesture.current.phase === 'stopping', interruptHint: interruptGesture.current.phase === 'stopping'
|
|
4041
4430
|
? 'Esc force-stop' : 'Esc x2 interrupt', model: cfg.model, provider: cfg.provider, usageTotal: state.usageTotal,
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/login`, `/logout` (C5) and `/account` (tui-account-identity-and-panel A7): the slash commands
|
|
3
|
+
* over the CLI's account layer.
|
|
4
|
+
*
|
|
5
|
+
* WHAT LIVES HERE AND WHY. The command body lives in its own module for the reason
|
|
6
|
+
* `agents-command.ts`, `kit-command.ts` and `queue-command.ts` record: `builtins.ts` is past the
|
|
7
|
+
* thousand-line guideline. The network and the credential file are NOT here either - they are
|
|
8
|
+
* `account/login-flow.ts` and `account/store.ts`; this module turns a status into transcript
|
|
9
|
+
* lines and asks the App to open the sign-in panel.
|
|
10
|
+
*
|
|
11
|
+
* THE PORT SEAM (`AccountCommandPort`), AND WHY IT IS A MODULE-LEVEL REGISTRATION rather than a
|
|
12
|
+
* field on `CommandContext`: this work package owns this file and `App.tsx` but NOT
|
|
13
|
+
* `commands/registry.ts`, where `CommandContext` is declared, and adding a required field to it
|
|
14
|
+
* would break the dozens of fixtures in this package that build the context by literal. The App
|
|
15
|
+
* installs the port from `makeCtx` and replaces it on every command run, so a stale App instance
|
|
16
|
+
* cannot outlive its own panel. With NO port installed the two commands answer honestly instead
|
|
17
|
+
* of throwing or reaching for the network - which is what a headless context, a sub-agent and a
|
|
18
|
+
* host double must get.
|
|
19
|
+
*
|
|
20
|
+
* ASCII ONLY - `commands/` is inside `glyphs.test.ts::inScope`, and these strings reach a
|
|
21
|
+
* legacy console.
|
|
22
|
+
*/
|
|
23
|
+
import type { CommandRegistry } from './registry.js';
|
|
24
|
+
import type { AccountStatus } from '../account/session.js';
|
|
25
|
+
/** C5, verbatim. `catalog.ts` and `BUILTIN_COMMAND_NAMES` carry the same bytes. */
|
|
26
|
+
export declare const LOGIN_DESCRIPTION = "Sign in with your aragonagent.com account (20 days); no args shows status";
|
|
27
|
+
/** C5, verbatim. */
|
|
28
|
+
export declare const LOGOUT_DESCRIPTION = "Sign out and delete the local account credential";
|
|
29
|
+
/**
|
|
30
|
+
* `/account` (tui-account-identity-and-panel A7). THE SAME BYTES live in
|
|
31
|
+
* `commands/catalog.ts` and in `docs/guide-doc/src/content/data/slash-commands.mjs`, and the
|
|
32
|
+
* guide's gate compares them character for character - a reworded copy is a red build, which
|
|
33
|
+
* is the only thing that keeps three surfaces honest.
|
|
34
|
+
*/
|
|
35
|
+
export declare const ACCOUNT_DESCRIPTION = "Open the account panel: who is signed in, the token expiry, sign in or sign out";
|
|
36
|
+
/** What `/logout` did. `ok: false` means the credential file is still there. */
|
|
37
|
+
export interface AccountSignOutResult {
|
|
38
|
+
readonly ok: boolean;
|
|
39
|
+
/** Whether a credential existed before the delete, so "nothing to do" is not "deleted". */
|
|
40
|
+
readonly hadCredential: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The App's side of the feature: read the credential, open the two panels, delete the credential.
|
|
44
|
+
*
|
|
45
|
+
* ONE METHOD PER USER INTENTION, because the command has to report each one truthfully: `status`
|
|
46
|
+
* is a read, `openLogin` starts a device flow the App owns (so `/login` returns before the person
|
|
47
|
+
* has touched their phone), `openAccount` opens the read-and-manage panel, and `signOut` must be
|
|
48
|
+
* able to answer "nothing to delete" as well as "still there, the filesystem refused".
|
|
49
|
+
*/
|
|
50
|
+
export interface AccountCommandPort {
|
|
51
|
+
/** Fresh read. The App reads the file, so `/login` never shows a cached credential. */
|
|
52
|
+
status(): AccountStatus;
|
|
53
|
+
/** Absolute path of `<home>/account.json`, for the reports below. */
|
|
54
|
+
accountPath(): string;
|
|
55
|
+
/** Open the four-phase panel and run `startLogin` in the background (C6). */
|
|
56
|
+
openLogin(): void;
|
|
57
|
+
/** Open the account panel - the same overlay `Ctrl+X` / `Alt+X` opens. */
|
|
58
|
+
openAccount(): void;
|
|
59
|
+
signOut(): AccountSignOutResult;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Install (or clear) the App's account port.
|
|
63
|
+
*
|
|
64
|
+
* CALLED FROM `App.tsx::makeCtx`, so the port always belongs to the App that is running the
|
|
65
|
+
* command. `null` removes it, which is how a test - or an App that unmounts - leaves the two
|
|
66
|
+
* commands answering the honest "not available" branch.
|
|
67
|
+
*/
|
|
68
|
+
export declare function setAccountCommandPort(port: AccountCommandPort | null): void;
|
|
69
|
+
/** The installed port, or `null` in a context that has none. */
|
|
70
|
+
export declare function getAccountCommandPort(): AccountCommandPort | null;
|
|
71
|
+
/**
|
|
72
|
+
* The report `/login` prints before it opens the panel: the state first, then the three facts a
|
|
73
|
+
* user can act on.
|
|
74
|
+
*
|
|
75
|
+
* THE TOKEN IS NEVER ONE OF THEM. `tokenPrefix` is what `account.json` already stores for
|
|
76
|
+
* exactly this purpose (`sha256` lives on the server; the prefix is the identifier a person
|
|
77
|
+
* recognises), and it is printed with a trailing `...` so nobody mistakes it for the secret.
|
|
78
|
+
* The full token is not reachable from `AccountStatus` at all, which is the structural half of
|
|
79
|
+
* "never show a plaintext token": this module has no API that could return one.
|
|
80
|
+
*/
|
|
81
|
+
export declare function accountStatusLines(status: AccountStatus, accountPath: string): string[];
|
|
82
|
+
/**
|
|
83
|
+
* The ONE startup line for the credential, or `null` when there is nothing to say (spec 6.6).
|
|
84
|
+
*
|
|
85
|
+
* `expiring` gets the account layer's own wording (it names the days left and `/login`);
|
|
86
|
+
* `expired` gets `describeExpiry`, because a credential that stopped working is not "expiring"
|
|
87
|
+
* and the user has to be told to sign in again rather than "renew". `signed-out` and `valid`
|
|
88
|
+
* stay completely silent: a terminal that greets a guest with a sign-in pitch on every launch is
|
|
89
|
+
* nagging, and the panel is one keystroke away.
|
|
90
|
+
*
|
|
91
|
+
* RETURNING A STRING RATHER THAN DISPATCHING keeps the "one notice per launch" rule in the App
|
|
92
|
+
* (a ref guard there) and lets this be asserted without mounting a terminal.
|
|
93
|
+
*/
|
|
94
|
+
export declare function startupAccountNotice(status: AccountStatus): string | null;
|
|
95
|
+
/** Register all three commands. Unconditional, so they can always explain a missing port. */
|
|
96
|
+
export declare function registerAccountCommands(registry: CommandRegistry): void;
|