/** * Standalone connection management: ensure entity/world/room/participants. * Batch-first: ensureConnections does 4 batch operations (upsertEntities, upsertWorlds, * upsertRooms, createRoomParticipants per room); ensureConnection is a single-connection wrapper. * Use these directly with adapter, or via runtime.ensureConnection() which delegates here. * * WHY standalone + batch: Callers can ensure many connections in one go without going through * the runtime; batch APIs reduce DB round-trips. Safe to use from both Node and edge entry points. */ import type { IDatabaseAdapter } from "./types/database.js"; import type { JsonValue, UUID } from "./types/primitives.js"; import { ChannelType } from "./types/primitives.js"; export interface EnsureConnectionParams { agentId: UUID; entityId: UUID; roomId: UUID; roomName?: string; /** Required if messageServerId is not provided. */ worldId?: UUID; worldName?: string; userName?: string; name?: string; source: string; type?: ChannelType | string; channelId?: string; /** Raw connector server/guild id retained for exact destination binding. */ serverId?: string; messageServerId?: UUID; userId?: UUID; metadata?: Record; } export interface EnsureConnectionsParams { agentId: UUID; connections: EnsureConnectionParams[]; } export interface EnsureConnectionsResult { createdRoomParticipants: number; } /** Exposes per-adapter registry size for lifecycle regression tests. */ export declare function __getConnectionReconciliationRegistrySizeForTests(adapter: IDatabaseAdapter): number; /** * Batch: upsert entities, worlds, rooms; then add participants per room. * Uses 4 batch operations (upsertEntities, upsertWorlds, upsertRooms, createRoomParticipants per room). * WHY batch: Minimizes round-trips when syncing many connections (e.g. many users/rooms at once). */ export declare function ensureConnections(adapter: IDatabaseAdapter, params: EnsureConnectionsParams): Promise; /** * Single-connection wrapper around ensureConnections. * WHY: Convenience for the common case of ensuring one entity/room; runtime.ensureConnection() uses this. */ export declare function ensureConnection(adapter: IDatabaseAdapter, params: EnsureConnectionParams): Promise;