/** * Minimal Coordinator for Multi-Chat v1 (ADR-0004) * * Three primitives: * 1. Lock Table - exclusive locks for resources * 2. Agent Registry - who's online and what they can do * 3. Event Log - append-only audit trail * * Design principles: * - Fail loud: lock conflicts return failure, don't queue * - File-based: YAML/JSONL in .decibel/coordinator/ * - Idempotent: re-locking same resource by same agent = OK * - Auto-cleanup: stale agents (120s) get locks released */ export interface Lock { resource: string; owner: string; acquired_at: string; expires_at: string; reason?: string; } export interface Agent { id: string; capabilities: string[]; status: 'active' | 'busy' | 'idle'; last_seen: string; current_task?: string; } export interface CoordEvent { ts: string; agent: string; action: string; resource?: string; reason?: string; details?: Record; } export interface CoordRegisterInput { agent_id: string; capabilities: string[]; project_id?: string; } export interface CoordRegisterOutput { agent_id: string; registered_at: string; capabilities: string[]; } export interface CoordHeartbeatInput { agent_id: string; current_task?: string; status?: 'active' | 'busy' | 'idle'; project_id?: string; } export interface CoordHeartbeatOutput { agent_id: string; last_seen: string; stale_agents: string[]; released_locks: string[]; } export interface CoordLockInput { agent_id: string; resource: string; reason?: string; project_id?: string; } export interface CoordLockOutput { acquired: boolean; resource: string; holder?: string; held_since?: string; expires_at?: string; } export interface CoordUnlockInput { agent_id: string; resource: string; project_id?: string; } export interface CoordUnlockOutput { released: boolean; resource: string; was_held_by?: string; } export interface CoordStatusInput { project_id?: string; } export interface CoordStatusOutput { agents: Agent[]; locks: Lock[]; stale_agents: string[]; } export interface CoordLogInput { project_id?: string; limit?: number; agent_id?: string; action?: string; } export interface CoordLogOutput { events: CoordEvent[]; total_count: number; } export type MessageStatus = 'pending' | 'acked' | 'completed'; export interface CoordMessage { id: string; from: string; to: string; intent: string; payload: Record; reply_to?: string; status: MessageStatus; created_at: string; acked_at?: string; completed_at?: string; result?: Record; expires_at: string; } export interface CoordSendInput { to: string; from: string; intent: string; payload: Record; reply_to?: string; ttl_ms?: number; project_id?: string; } export interface CoordSendOutput { message_id: string; to: string; from: string; intent: string; expires_at: string; } export interface CoordInboxInput { agent_id: string; status?: MessageStatus; limit?: number; project_id?: string; } export interface CoordInboxOutput { messages: CoordMessage[]; total: number; } export interface CoordAckInput { message_id: string; agent_id: string; result?: Record; project_id?: string; } export interface CoordAckOutput { message_id: string; status: MessageStatus; from: string; intent: string; } export interface CoordError { error: string; message: string; } declare function isCoordError(result: unknown): result is CoordError; export declare function coordRegister(input: CoordRegisterInput): Promise; export declare function coordHeartbeat(input: CoordHeartbeatInput): Promise; export declare function coordLock(input: CoordLockInput): Promise; export declare function coordUnlock(input: CoordUnlockInput): Promise; export declare function coordStatus(input: CoordStatusInput): Promise; export declare function coordLog(input: CoordLogInput): Promise; export declare function coordSend(input: CoordSendInput): Promise; export declare function coordInbox(input: CoordInboxInput): Promise; export declare function coordAck(input: CoordAckInput): Promise; export interface GcResult { expired_messages: number; expired_locks: number; projects_swept: number; } /** * Sweep expired coordinator state across one or more projects. * Called periodically by the daemon's GC interval. * * - Deletes message files past their `expires_at` * - Rewrites locks.yaml to remove expired locks * - Logs GC events to coordinator audit log */ export declare function coordGarbageCollect(projectIds: string[]): Promise; export { isCoordError }; //# sourceMappingURL=coordinator.d.ts.map