export { CliCommandDef, CliDefinition, CliOptionDef, CliSubcommandDef, starkCliDefinition } from '@stark-o/shared'; /** * Browser CLI API Client * * Isomorphic API client that works in both Node.js and browser. * Mirrors the Node.js CLI's config.ts but uses browser-compatible storage. * @module @stark-o/browser-cli/config */ /** * Browser CLI configuration */ interface BrowserCliConfig { apiUrl: string; supabaseUrl: string; supabaseAnonKey: string; defaultNamespace: string; } /** * Browser credentials stored in localStorage or memory */ interface BrowserCredentials { accessToken: string; refreshToken?: string; expiresAt: string; userId: string; email: string; } /** * Load configuration from localStorage (or return defaults) */ declare function loadConfig(): BrowserCliConfig; /** * Save configuration to localStorage */ declare function saveConfig(config: Partial): void; /** * Load credentials from storage */ declare function loadCredentials(): BrowserCredentials | null; /** * Save credentials to storage */ declare function saveCredentials(credentials: BrowserCredentials): void; /** * Clear stored credentials */ declare function clearCredentials(): void; /** * Check if user is authenticated */ declare function isAuthenticated(): boolean; /** * Get the current access token */ declare function getAccessToken(): string | null; /** * Require authentication — throws if not authenticated */ declare function requireAuth(): BrowserCredentials; /** * Creates an authenticated HTTP client for API calls (browser-compatible using fetch) */ declare function createApiClient(config?: BrowserCliConfig): { get: (path: string) => Promise; post: (path: string, body?: unknown) => Promise; put: (path: string, body?: unknown) => Promise; patch: (path: string, body?: unknown) => Promise; delete: (path: string) => Promise; }; /** * Resolves a node name-or-UUID to a UUID. */ declare function resolveNodeId(nameOrId: string, api: ReturnType): Promise; /** * Browser CLI — Command Handlers * * Implements all Stark CLI command handlers for the browser environment. * These mirror the Node.js CLI handlers but use browser-compatible APIs. * @module @stark-o/browser-cli/handlers */ /** * Result from a command execution */ interface CommandResult { success: boolean; message?: string; data?: unknown; error?: string; } /** * Write callback for streaming command output */ type OutputWriter = (text: string) => void; /** * Execute a CLI command in the browser. * Parses args and dispatches to the appropriate handler. * * @param args - Arguments (e.g., ['pack', 'list']) * @param write - Output callback * @returns Command result */ declare function executeCommand(args: string[], write: OutputWriter): Promise; /** * Browser CLI Volume Operations * * Volume management using JSZip for cross-platform (Node.js + browser) archive handling. * @module @stark-o/browser-cli/volume */ /** * Downloads volume contents as a zip archive using JSZip. * Works in both Node.js and browser environments. * * @param volumeName - Name of the volume to download * @param nodeNameOrId - Node name or UUID * @returns Uint8Array containing the zip archive */ declare function downloadVolume(volumeName: string, nodeNameOrId: string): Promise; /** * Creates a zip archive of a specific path within a volume. * The archive is placed next to the last piece of the path. * * @param nodeNameOrId - Node name or UUID * @param volumeName - Name of the volume * @param archivePath - Path within the volume to archive * @returns Uint8Array containing the zip archive */ declare function archiveVolumePath(nodeNameOrId: string, volumeName: string, archivePath: string): Promise; /** * Browser CLI Agent * * Hooks into the browser runtime to create a node, * mirroring the Node.js CLI `node agent start` functionality. * @module @stark-o/browser-cli/agent */ /** * Options for starting a browser agent */ interface BrowserAgentStartOptions { /** Orchestrator WebSocket URL */ url: string; /** Node name */ name: string; /** Authentication token (optional if browser credentials exist) */ token?: string; /** Node labels */ labels?: Record; /** Heartbeat interval in ms */ heartbeatInterval?: number; /** Debug mode */ debug?: boolean; } /** * Browser node credentials */ interface BrowserNodeCredentials { accessToken: string; refreshToken: string; expiresAt: number; userId: string; } /** * Start a browser node agent. * This hooks into the browser runtime and creates another node * just like the Node.js version does. * * Dynamically imports @stark-o/browser-runtime to avoid build issues. * * @returns The created BrowserAgent instance */ declare function startBrowserAgent(options: BrowserAgentStartOptions): Promise; /** * Store browser agent credentials */ declare function storeBrowserCredentials(creds: BrowserNodeCredentials): Promise; /** * Load stored browser agent credentials */ declare function getBrowserCredentials(): Promise; export { type BrowserAgentStartOptions, type BrowserCliConfig, type BrowserCredentials, type BrowserNodeCredentials, type CommandResult, type OutputWriter, archiveVolumePath, clearCredentials, createApiClient, downloadVolume, executeCommand, getAccessToken, getBrowserCredentials, isAuthenticated, loadConfig, loadCredentials, requireAuth, resolveNodeId, saveConfig, saveCredentials, startBrowserAgent, storeBrowserCredentials };