/**
 * olam mcp list — List all MCP credentials from the vault.
 */
import pc from 'picocolors';
import { printError } from '../../output.js';
import { getMcpAuthClient } from './client.js';
export function registerMcpList(cmd) {
    cmd
        .command('list')
        .description('List all registered MCP credentials')
        .action(async () => {
        const client = getMcpAuthClient();
        let data;
        try {
            data = await client.status();
        }
        catch (err) {
            printError(`Could not reach mcp-auth service: ${err instanceof Error ? err.message : 'unknown error'}`);
            printError('Is mcp-auth running? (OLAM_MCP_AUTH_SERVICE_URL defaults to http://127.0.0.1:9998)');
            process.exitCode = 1;
            return;
        }
        const mcps = data.mcps ?? [];
        if (mcps.length === 0) {
            console.log(pc.dim('No MCP credentials registered.'));
            console.log(pc.dim('Add one with: olam mcp add <service>'));
            return;
        }
        const [c0, c1, c2, c3] = [16, 20, 10, 24];
        const header = [
            'SERVICE'.padEnd(c0),
            'LABEL'.padEnd(c1),
            'TYPE'.padEnd(c2),
            'ENV VAR'.padEnd(c3),
            'STATUS',
        ].join('  ');
        console.log(pc.dim(header));
        console.log(pc.dim('─'.repeat(header.length)));
        for (const m of mcps) {
            const status = !m.validated
                ? pc.yellow('unvalidated')
                : m.expired
                    ? pc.red('expired')
                    : pc.green('active');
            const row = [
                pc.cyan(m.service.padEnd(c0)),
                m.label.padEnd(c1).slice(0, c1),
                m.type.padEnd(c2),
                (m.envName ?? '—').padEnd(c3).slice(0, c3),
                status,
            ].join('  ');
            console.log(row);
        }
    });
}
//# sourceMappingURL=list.js.map