MCPcopy
hub / github.com/MiniMax-AI/cli / run

Function run

src/commands/auth/status.ts:21–81  ·  view source on GitHub ↗
(config: Config, _flags: GlobalFlags)

Source from the content-addressed store, hash-verified

19 'mmx auth status --output json',
20 ],
21 async run(config: Config, _flags: GlobalFlags) {
22 try {
23 const credential = await resolveCredential(config);
24 const format = detectOutputFormat(config.output);
25
26 if (format !== 'text') {
27 const result: Record<string, unknown> = {
28 method: credential.method,
29 source: credential.source,
30 };
31 if (credential.method === 'oauth') {
32 const creds = await loadCredentials();
33 if (creds) {
34 result.token_expires = creds.expires_at;
35 if (creds.account) result.account = creds.account;
36 }
37 } else {
38 result.key = maskToken(credential.token);
39 }
40 console.log(formatOutput(result, format));
41 return;
42 }
43
44 // Text format — rich output
45 console.log('Authentication Status:');
46 console.log(` Method: ${credential.method}`);
47 console.log(` Source: ${credential.source}`);
48
49 const token = credential.token;
50 console.log(` Key: ${maskToken(token)}`);
51
52 if (credential.method === 'oauth') {
53 const creds = await loadCredentials();
54 if (creds) {
55 if (creds.account) console.log(` Account: ${creds.account}`);
56 const expiresAt = new Date(creds.expires_at);
57 const minutesLeft = Math.round((expiresAt.getTime() - Date.now()) / 60000);
58 console.log(` Expires in: ${minutesLeft} minutes`);
59 }
60 }
61
62 // Fetch quota snapshot
63 process.stderr.write('Fetching quota snapshot...\n');
64 try {
65 const url = quotaEndpoint(config.baseUrl);
66 const quota = await requestJson<QuotaResponse>(config, { url, method: 'GET' });
67 renderQuotaTable(quota.model_remains || [], config);
68 } catch (e) {
69 console.log(` Quota fetch failed: ${(e as Error).message}`);
70 }
71
72 } catch {
73 const format = detectOutputFormat(config.output);
74 const result = {
75 authenticated: false,
76 message: 'Not authenticated.',
77 hint: 'Run: mmx auth login\nOr set $MINIMAX_API_KEY',
78 };

Callers

nothing calls this directly

Calls 7

resolveCredentialFunction · 0.90
detectOutputFormatFunction · 0.90
loadCredentialsFunction · 0.90
maskTokenFunction · 0.90
formatOutputFunction · 0.90
quotaEndpointFunction · 0.90
renderQuotaTableFunction · 0.90

Tested by

no test coverage detected