trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
40 lines • 1.46 kB
TypeScript
/**
* PartyKit / Durable Object room handler for Trellis sync.
*
* Deploy as a PartyKit server module:
*
* import { createPartyKitRoomHandler } from 'trellis/sync/partykit-room';
* export default createPartyKitRoomHandler();
*
* Clients connect with `?peerId=<id>` (required) and optional `?token=`.
*/
/** Minimal PartyKit room surface (avoids a hard dependency on `partykit`). */
export interface PartyKitRoomLike {
id: string;
getConnection(id: string): PartyKitConnectionLike | undefined;
getConnections(): Iterable<PartyKitConnectionLike>;
}
export interface PartyKitConnectionLike {
id: string;
send(data: string): void;
close(code?: number, reason?: string): void;
}
export interface PartyKitRoomHandlerOptions {
welcomeSnapshot?: boolean;
welcomeSnapshotMaxOps?: number;
}
/**
* PartyKit `onConnect` / `onMessage` helpers backed by {@link SyncRoomServer}.
*/
export declare function createPartyKitRoomHandler(opts?: PartyKitRoomHandlerOptions): {
onConnect(connection: PartyKitConnectionLike, room: PartyKitRoomLike, request?: {
url?: string;
}): Promise<void>;
onMessage(message: string | ArrayBuffer, connection: PartyKitConnectionLike, room: PartyKitRoomLike, request?: {
url?: string;
}): Promise<void>;
onClose(connection: PartyKitConnectionLike, room: PartyKitRoomLike, request?: {
url?: string;
}): void;
};
//# sourceMappingURL=partykit-room.d.ts.map