trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
39 lines • 1.53 kB
TypeScript
import type { SyncMessage } from './types.js';
import { type SyncRoomSnapshot } from './room-core.js';
export interface SyncRoomServerConnection {
peerId: string;
send(message: SyncMessage): void | Promise<void>;
}
export interface SyncRoomServerOptions {
roomId?: string;
roomName?: string;
/** Send a welcome snapshot when a peer connects. Default: true. */
welcomeSnapshot?: boolean;
welcomeSnapshotMaxOps?: number;
}
/**
* Framework-agnostic room server wrapping {@link SyncRoomCore}.
*
* Use from PartyKit, Node WebSocket servers, or tests. Routes inbound sync
* messages through the canonical room log and delivers responses to peers.
*/
export declare class SyncRoomServer {
private core;
private connections;
private welcomeSnapshot;
private welcomeSnapshotMaxOps;
constructor(opts?: SyncRoomServerOptions);
getRoomId(): string;
getOpCount(): number;
getOps(): import("../index.js").VcsOp[];
buildSnapshot(maxOps?: number): SyncRoomSnapshot;
/** Register a connected peer and optionally send a welcome snapshot. */
connect(conn: SyncRoomServerConnection): Promise<void>;
disconnect(peerId: string): void;
/** Route an inbound sync message from a peer. */
handleMessage(fromPeerId: string, message: SyncMessage): Promise<void>;
/** Push a tail snapshot to a peer without an inbound message. */
sendSnapshot(peerId: string, maxOps?: number): Promise<void>;
private deliverAll;
}
//# sourceMappingURL=sync-room-server.d.ts.map