@agentled/cli
Version:
CLI for Agentled — manage workflows, apps, and knowledge from the command line. Zero context-window cost for AI agents.
27 lines (26 loc) • 2.55 kB
TypeScript
/**
* Browser-based authentication for `agentled auth login`.
*
* 1. Starts a temporary HTTP server on localhost
* 2. Opens the browser to /cli/authorize?port=...&state=...
* 3. Waits for the callback with a signed JWT code
* 4. Exchanges the code for the raw API key via /api/cli/exchange
*
* Uses only Node.js built-ins (http, crypto, child_process).
*/
export interface BrowserLoginResult {
apiKey: string;
workspaceId: string;
workspaceName: string;
workspaceSlug?: string;
userId?: string;
userEmail?: string;
userName?: string;
isNewUser: boolean;
baseUrl: string;
}
export declare const SUCCESS_HTML = "\n<html>\n<head><meta charset=\"utf-8\"><title>Agentled CLI</title></head>\n<body style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; background: #f9fafb;\">\n<div style=\"text-align: center; padding: 2rem;\">\n <div style=\"width: 48px; height: 48px; margin: 0 auto 1rem; background: #d1fae5; border-radius: 50%; display: flex; align-items: center; justify-content: center;\">\n <svg width=\"24\" height=\"24\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"#059669\" stroke-width=\"2\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M5 13l4 4L19 7\"/></svg>\n </div>\n <h1 style=\"font-size: 1.25rem; font-weight: 600; color: #111827; margin: 0 0 0.5rem;\">Connected</h1>\n <p style=\"color: #6b7280; font-size: 0.875rem; margin: 0 0 1rem;\">You can close this tab and go back to your terminal — the CLI is connected and ready to use.</p>\n <div style=\"background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.75rem; text-align: left; max-width: 360px; margin: 0 auto; font-size: 0.8125rem; color: #374151;\">\n <strong style=\"color: #111827; display: block; margin-bottom: 0.25rem;\">Next step</strong>\n Return to your command line — your CLI session is now authenticated. Run <code style=\"background:#e5e7eb;padding:1px 4px;border-radius:3px;font-family:ui-monospace,Menlo,monospace;\">agentled auth status</code> to confirm.<br><br><strong style=\"color:#111827;\">Then restart your MCP client</strong> (Claude Code / Codex / Cursor) so it picks up this workspace — until you do, MCP tools stay on the previous workspace.\n </div>\n</div>\n</body>\n</html>";
/**
* Run the browser-based login flow.
*/
export declare function browserLogin(baseUrl: string): Promise<BrowserLoginResult>;