/** * Daemon Client * * CLI client for communicating with daemon servers * Sends commands via Unix socket / named pipe and receives results * Supports bidirectional prompts - daemon can request user input */ import { DaemonRequest } from './protocol.js'; export declare function captureConstructorEnvForPhoton(photonName: string, photonPath?: string): Record | undefined; /** * Error thrown when the daemon sends a shutdown signal during a request. * Callers can catch this to distinguish a graceful shutdown from a crash. */ export declare class DaemonShutdownError extends Error { constructor(reason?: string); } /** * Send command to daemon with auto-restart on connection failure. * Retries on connection errors (restart daemon + retry) and on transient * errors for read-only methods (retry without restart). */ export declare function sendCommand(photonName: string, method: string, args: Record, options?: { maxRetries?: number; photonPath?: string; sessionId?: string; instanceName?: string; targetInstance?: string; workingDir?: string; clientType?: DaemonRequest['clientType']; }): Promise; /** * Tell the daemon to reload a photon (re-compile and re-instantiate). * Called by Beam after hot-reload so the daemon's instance matches. */ export declare function reloadDaemonPhoton(photonName: string, photonPath: string, workingDir?: string): Promise; /** * Subscription options */ export interface SubscribeOptions { /** Last event timestamp for delta sync on reconnect */ lastEventId?: string; /** Handler for full sync signal (when client is stale beyond buffer window) */ onRefreshNeeded?: () => void; /** Auto-reconnect on connection drop (restarts daemon if needed) */ reconnect?: boolean; /** Max reconnect attempts (default: Infinity) */ maxReconnectAttempts?: number; /** Called when reconnection succeeds */ onReconnect?: () => void; } /** * Subscribe to a channel on a daemon * Returns an unsubscribe function */ export declare function subscribeChannel(photonName: string, channel: string, handler: (message: unknown, eventId?: string) => void, options?: SubscribeOptions & { workingDir?: string; }): Promise<() => void>; /** * Publish a message to a channel on a daemon */ export declare function publishToChannel(photonName: string, channel: string, message: unknown, workingDir?: string): Promise; /** * Acquire a distributed lock * Returns true if lock acquired, false if already held */ export declare function acquireLock(photonName: string, lockName: string, timeout?: number, workingDir?: string): Promise; /** * Release a distributed lock * Returns true if lock released, false if not held by this session */ export declare function releaseLock(photonName: string, lockName: string, workingDir?: string): Promise; /** * List all active locks */ export declare function listLocks(photonName: string): Promise>; /** * Assign a lock to a specific caller (identity-aware) * Unlike acquireLock which uses the session ID, this sets an explicit holder. */ export declare function assignLock(photonName: string, lockName: string, holder: string, timeout?: number, workingDir?: string): Promise; /** * Transfer a lock from one holder to another */ export declare function transferLock(photonName: string, lockName: string, fromHolder: string, toHolder: string, timeout?: number, workingDir?: string): Promise; /** * Release a lock held by a specific caller (identity-aware) */ export declare function releaseIdentityLock(photonName: string, lockName: string, holder: string, workingDir?: string): Promise; /** * Query who holds a specific lock */ export declare function queryLock(photonName: string, lockName: string): Promise<{ holder: string | null; acquiredAt?: number; expiresAt?: number; }>; /** * Schedule a recurring job */ export declare function scheduleJob(photonName: string, jobId: string, method: string, cron: string, args?: Record): Promise<{ scheduled: boolean; nextRun?: number; }>; /** * Unschedule a job */ export declare function unscheduleJob(photonName: string, jobId: string): Promise; /** * List all scheduled jobs */ export declare function listJobs(photonName: string): Promise>; /** Shape returned by the `ps` RPC — full observability snapshot. */ export interface PsSnapshot { active: Array<{ id: string; photon: string; method: string; cron: string; nextRun: number | null; lastRun: number | null; lastAttempt: number | null; lastStatus: 'success' | 'error' | null; lastError: string | null; consecutiveFailures: number; runCount: number; photonPath?: string; workingDir?: string; createdBy?: string; }>; declared: Array<{ key: string; photon: string; method: string; cron: string; requiredConfig: string[]; photonPath: string; workingDir?: string; active: boolean; }>; webhooks: Array<{ photon: string; route: string; method: string; workingDir?: string; }>; sessions: Array<{ photon: string; workingDir?: string; key: string; instanceCount: number; }>; suppressed?: Array<{ photon: string; method: string; suppressedAt: string; workingDir: string; }>; } export declare function fetchPsSnapshot(): Promise; export declare function enableSchedule(photonName: string, method: string, workingDir?: string): Promise; export declare function disableSchedule(photonName: string, method: string, workingDir?: string): Promise; export declare function pauseSchedule(photonName: string, method: string, workingDir?: string): Promise; export declare function resumeSchedule(photonName: string, method: string, workingDir?: string): Promise; export declare function addManualSchedule(photonName: string, method: string, cron: string, workingDir?: string): Promise; export interface ExecutionHistoryEntry { ts: number; jobId: string; method: string; durationMs: number; status: 'success' | 'error' | 'timeout'; errorMessage?: string; outputPreview?: string; } export interface ExecutionHistoryResponse { photon: string; method: string; entries: ExecutionHistoryEntry[]; } export declare function fetchExecutionHistory(photonName: string, method: string, opts?: { limit?: number; sinceTs?: number; workingDir?: string; }): Promise; /** * Ping daemon to check if it's responsive */ export declare function pingDaemon(photonName: string): Promise; /** * Query daemon health status (uptime, memory, sessions, etc.) */ export declare function queryDaemonStatus(): Promise<{ uptime: number; memoryMB: number; sessions: number; subscriptions: number; photonsLoaded: number; } | null>; /** * Get events since a specific timestamp for a channel * Used for explicit delta sync when client has missed events */ /** * Clear cached instances for a photon in a given workingDir. * Called by Beam when starting with a fresh workingDir to avoid stale in-memory state. */ export declare function clearInstances(photonName: string, workingDir?: string): Promise; export declare function getEventsSince(photonName: string, channel: string, lastEventId: string): Promise<{ events: Array<{ eventId: string; message: unknown; }>; refreshNeeded: boolean; }>; //# sourceMappingURL=client.d.ts.map