export interface RoomMember { id: string; name: string; } export type RoomWriteErrorReason = "member_not_found" | "leader_not_member"; export declare class RoomWriteError extends Error { readonly reason: RoomWriteErrorReason; readonly name = "RoomWriteError"; constructor(reason: RoomWriteErrorReason, message: string); } export interface Room { id: string; name: string; memberIds: string[]; promptLeaderMemberId?: string; docsPath?: string; description?: string; createdAt: number; } import { type Database } from "../data/database.js"; import type { AttachmentLocation } from "../files/attachments.js"; export declare function slugifyRoomDocsPath(input: string): string; export declare function normalizeRoomDocsPath(input: string | null | undefined): string | undefined; /** Batch 7 P3: rooms no longer bind a cwd — attachment/artifact path policy * covers each room member's home directory and all their workspace roots. */ /** Member-owned local roots; workspace roots are authorized by the app host. */ export declare function memberAssetRoots(memberIds: Iterable): string[]; export declare function roomMemberAssetRoots(roomId: string): string[]; /** Asset roots for any chat scope: rooms use their roster; dm/mm use the participant members. */ export declare function chatScopeAssetRoots(scope: string): string[]; /** Create membership and leadership together from existing stable contact IDs. */ export declare function createRoom(name: string, memberIds: string[], opts?: { promptLeaderMemberId?: string; docsPath?: string | null; description?: string | null; }): Room; export declare function updateRoom(roomId: string, patch: { name?: string; description?: string | null; promptLeaderMemberId?: string | null; docsPath?: string | null; }): Room | null; export declare function getRoomMembers(roomId: string): RoomMember[]; export declare function resolveRoomMember(roomId: string, memberId: string): RoomMember | null; /** ⑤ A: room description (name + description) — product cap on every write. */ export declare const ROOM_DESCRIPTION_MAX_CHARS = 2000; /** Member↔member chat scopes involving `memberId` (⑤ B). */ export declare function listMmScopesForMember(memberId: string): string[]; /** * 0.20 invite: attach an existing global member to a room (by mem_ id). * Uses stable identity from the member registry and replaces relational membership. */ export declare function inviteRoomMember(roomId: string, memberId: string): { ok: true; member: RoomMember; } | { ok: false; error: string; code: "room_not_found" | "member_not_found" | "duplicate"; }; export declare function removeRoomMember(roomId: string, memberId: string): { ok: true; removed: RoomMember; } | { ok: false; error: string; }; /** Remove active membership while retaining imported historical snapshots. */ export declare function detachMemberFromConversations(memberId: string, db: Database): void; export interface ConversationMemberIdentity { id: string; name: string; } /** The application supplies current identity; conversations never query member tables. */ export declare function connectConversationMembers(read: (id: string, retained?: boolean) => ConversationMemberIdentity | null): () => void; export declare function conversationMember(id: string, retained?: boolean): ConversationMemberIdentity | null; /** Canonical serialized conversation source. */ /** Canonical conversation identity used by all new chat capabilities. Bare room * ids remain the storage key; public/source refs always use `room:`. */ export type ConversationIdentity = { kind: "room"; scopeId: string; roomId: string; } | { kind: "dm"; scopeId: string; memberId: string; } | { kind: "mm"; scopeId: string; memberIds: [string, string]; }; /** * Member↔member private chat scope (⑤ B, 2026-09-15): `mm:` + the two member ids * sorted and joined by a single dash. `mem_` appears exactly once per id in both * generations (legacy `mem_` ids keep their dashes; current ids are * `mem_`), so the pair splits at the second `mem_` occurrence; canonical * order is enforced on parse. */ export declare function mmScopeIdOf(memberA: string, memberB: string): string; /** Parse a `mm:` scope id into its canonical [memberA, memberB] pair, or null. */ export declare function parseMmScopeId(scope: string): [string, string] | null; export declare function isMmScopeId(scope: string): boolean; /** Parse only canonical public/source refs. */ export declare function parseConversation(value: string): ConversationIdentity | null; export declare function resolveConversation(value: string): ConversationIdentity | null; export declare function attachmentLocation(ref: ConversationIdentity): AttachmentLocation; /** Convert a canonical source or an internal bare room key to the database key. */ export declare function storageScopeId(value: string): string; /** Wide member-id check: recognizes legacy `mem_` and current `mem_` ids. */ export declare function isMemberId(id: string): boolean; /** Short chat id for a canonical scope ref; persists a minted id for mm scopes. */ export declare function chatShortId(scopeRef: string, db?: Database): string | null; /** Resolve a prompt/tool-facing chat reference to its canonical scope ref. * Accepts rm_ and dm_ short ids plus the legacy room:/dm:/mm: forms. */ export declare function resolveChatScope(value: string, db?: Database): string | null; /** Startup backfill: every persisted scope gets its short id. Idempotent by * construction — minted ids persist, deterministic ids recompute to the same * value, and an interrupted run simply fills the remainder next start. */ export declare function backfillScopeShortIds(db?: Database): number; export interface LegacyRoomImport { id: string; name: string; createdAt: number; cwd?: string; members?: string[]; globalMemberIds?: string[]; promptLeaderMemberId?: string; promptLeaderGlobalMemberId?: string; docsPath?: string; description?: string; ruleDocs?: string[]; roomMembers?: Array<{ id: string; name: string; sourceAgent: string; sourceMemberId?: string; avatar?: string; createdAt: number; updatedAt: number; migratedFrom?: { memberName: string; memberId?: string; }; config?: unknown; }>; memberOverrides?: Record; } export declare function ensureDmScope(memberId: string, db?: Database): string; export declare function ensureMmScope(memberA: string, memberB: string, db?: Database): string; /** Persist current room state without rewriting imported historical snapshots. */ export declare function storeRoom(room: Room, db?: Database): void; /** Import legacy labels and snapshots without making them active members. */ export declare function importLegacyRoom(room: LegacyRoomImport, db?: Database): void; export declare function getRoom(id: string, db?: Database): Room | null; export declare function listRooms(db?: Database): Room[]; export interface RoomSourceAssociation { roomId: string; roomName: string; sourceRefs: readonly string[]; historicalSourceKeys: readonly string[]; } /** Current-room-bounded, exact aliases for immutable historical source identity. */ export declare function listRoomSourceAssociations(db?: Database): RoomSourceAssociation[]; export declare function listMmScopes(db?: Database): string[]; export declare function storeMemberCursor(scopeId: string, actorKey: string, value: string | null, updatedAt?: number, db?: Database): void; export declare function deleteMemberCursor(scopeId: string, actorKey: string, db?: Database): void; /** Active membership is proven by IDs, never a historical display name. */ export declare function listRoomsForMember(memberId: string): Room[]; export type ScopeAccess = { kind: "room"; roomId: string; room: Room; } | { kind: "dm"; memberId: string; } | { kind: "mm"; memberIds: [string, string]; }; /** * Assert `memberId` may read `scopeId`. Returns the parsed target on success. * Throws Error with an explicit reason otherwise (not a member / not own DM / * unknown scope). Current rosters and explicit historical ID links are authoritative. */ export declare function assertMemberScopeAccess(memberId: string, scopeId: string): ScopeAccess; //# sourceMappingURL=conversations.d.ts.map