import type { BackendType } from './backends/types.js'; export interface AgentConfig { server: string; dir: string; name: string; /** User-defined display label. The operating-system hostname remains unchanged. */ deviceName?: string; password?: string; entra?: boolean; msentra?: boolean; entraClientId?: string; entraTenantId?: string; e2eKey?: string; /** Coding agent backend. Default 'claude'. Stage 1 only accepts 'claude' as an effective value. */ agent?: BackendType; msInternal?: boolean; /** User-level boot auto-start policy. Undefined migrates to enabled after health. */ autoStart?: boolean; /** Agent version that last completed the auto-start migration. */ autoStartMigratedVersion?: string; /** launchd migration/opt-out is written but takes effect at next login. */ autoStartPendingReload?: boolean; } export declare const CONFIG_DIR: string; export declare function loadConfig(): Partial; export declare function saveConfig(partial: Partial): void; export declare const MAX_DEVICE_NAME_LENGTH = 64; export declare function saveDeviceName(value: unknown): string; export declare function getConfigPath(): string; /** * Resolve final config: CLI flags > config file > defaults. * When ignoreConfigFile is true, skip reading ~/.agentlink/config.json * (used by --ephemeral to avoid inheriting production config). */ export declare function resolveConfig(cliOptions: Partial, ignoreConfigFile?: boolean): AgentConfig; /** * Convert a Uint8Array to a base64url-encoded string (URL-safe, no padding). */ export declare function encodeBase64Url(bytes: Uint8Array): string; /** * Decode a base64url-encoded string back to Uint8Array. */ export declare function decodeBase64Url(str: string): Uint8Array; /** * Get or create the E2E encryption key. * - Loads from config.json if it exists * - Generates a new 32-byte key if not found, persists to config.json * - In ephemeral mode (AGENTLINK_NO_STATE), generates in-memory only * Returns the raw 32-byte key as Uint8Array. */ export declare function getOrCreateE2EKey(ignoreConfigFile?: boolean): Uint8Array; export interface RuntimeState { pid?: number; /** Random identity for this exact process lifetime; protects against PID reuse. */ processInstanceId?: string; sessionId: string; sessionUrl: string; server: string; name: string; dir: string; startedAt: string; /** Coding agent backend used at start time. Stage 1: 'claude' only. */ agent?: BackendType; /** Immutable LaunchSpec snapshot consumed by the running daemon. */ launchSpecPath?: string; /** SHA-256 of the parsed immutable LaunchSpec consumed by the daemon. */ launchSpecDigest?: string; /** Authenticated loopback control endpoint owned by this exact process. */ controlPlane?: ControlPlaneDiscovery; /** Present only when the daemon was started through the stable version-store launcher. */ versionStore?: { active: true; selectedVersion: string; selectedIntegrity?: string; }; /** External upgrade job that selected and started this runtime. */ upgradeJobId?: string; /** Proof that the relay accepted a replacement for the preserved upgrade session. */ sessionRegistration?: { previousSessionId: string; sessionId: string; sessionUrlHash: string; registeredAt: string; }; } export interface ControlPlaneDiscovery { apiVersion: 1; host: '127.0.0.1'; port: number; token: string; capabilities: string[]; } export declare function saveRuntimeState(state: RuntimeState): void; export declare function loadRuntimeState(): RuntimeState | null; export declare function clearRuntimeState(): void; /** * Remove process-owned runtime fields while preserving session identity. * When expectedPid is provided, a replacement process that already published * its state wins and the stale process must not clear it. */ export declare function clearRuntimePid(expectedOwner?: number | { pid: number; processInstanceId: string; }): void; export declare function getLogDir(): string; /** Return today's date as YYYY-MM-DD for log file naming. */ export declare function getLogDate(): string; /** Delete log files older than `days` days from the log directory. */ export declare function cleanOldLogs(days?: number): void; export declare function killProcess(pid: number): boolean; export declare function forceKillProcess(pid: number): boolean; export declare function isProcessAlive(pid: number): boolean; export declare function getConversationModel(sessionId: string): string | null; export declare function setConversationModel(sessionId: string, model: string): void; export declare function clearConversationModel(sessionId: string): void; export declare function getConversationPermission(sessionId: string): string | null; export declare function setConversationPermission(sessionId: string, mode: string): void; export declare function clearConversationPermission(sessionId: string): void; /** * Resolve the Brain data directory. * Reads `brain_home` from ~/.brain/install.json; falls back to ~/BrainData. */ export declare function getBrainDataDir(): string; export interface PidFileInfo { pid: number; sessionUrl?: string; password?: string; } export declare function writePidFile(filePath: string, info: PidFileInfo): void; export declare function readPidFile(filePath: string): PidFileInfo | null;