/** * Server-side awareness state management for collaborative editing. * * Stores per-client awareness state (cursor positions, user info) in memory. * Clients POST their state and receive other clients' states via polling. * States expire after 30 seconds of no updates. * * Fast-path: when a client POSTs new awareness state, the server emits an * event on the awareness emitter so SSE-connected peers receive cursor moves * push-style instead of waiting for the next poll cycle. */ import { EventEmitter } from "node:events"; export interface AwarenessEntry { clientId: number; state: string; lastSeen: number; } export declare const AWARENESS_CHANGE_EVENT: "awareness-change"; export interface AwarenessChangeEvent { source: "awareness"; type: "awareness-change"; docId: string; /** Array of updated states for this document (all non-expired clients). */ states: Array<{ clientId: number; state: string; }>; /** Owner email for access-scoped delivery (taken from session if available). */ owner?: string; /** Org ID for org-scoped delivery. */ orgId?: string; /** Shareable resource type this awareness event belongs to, when known. */ resourceType?: string; /** Shareable resource id this awareness event belongs to, when known. */ resourceId?: string; } export interface AwarenessScope { owner?: string; orgId?: string; resourceType?: string; resourceId?: string; } export declare function getAwarenessEmitter(): EventEmitter; export declare function rememberAwarenessScope(docId: string, scope: AwarenessScope | undefined): void; export declare function emitAwarenessChange(docId: string, states: Array<{ clientId: number; state: string; }>, scope?: AwarenessScope): void; export declare function rememberAwarenessClear(docId: string, clientId: number, clearedAt?: number): void; export declare function forgetAwarenessClear(docId: string, clientId: number): void; export declare function getDocAwareness(docId: string): Map; export declare function cleanExpired(map: Map): void; /** * POST /_agent-native/collab/:docId/awareness * * Client sends its awareness state and receives other clients' states. * * Body: { clientId: number, state: string | null (JSON-encoded awareness state, or null to clear) } * Response: { states: Array<{ clientId: number, state: string }> } */ export declare const postAwareness: import("h3").EventHandlerWithFetch>; /** * GET /_agent-native/collab/:docId/users * * Returns the list of active users for a document (for presence bar). */ export declare const getActiveUsers: import("h3").EventHandlerWithFetch>; //# sourceMappingURL=awareness.d.ts.map