/**
 * Collaborative Mode
 *
 * Multi-user collaboration features for Code Buddy:
 * - Shared sessions between users
 * - Real-time synchronization
 * - Presence indicators
 * - Conflict resolution
 * - Permission management
 */
import { EventEmitter } from 'events';
export interface User {
    id: string;
    name: string;
    email?: string;
    role: UserRole;
    color: string;
    cursor?: CursorPosition;
    lastActive: Date;
}
export type UserRole = 'owner' | 'editor' | 'viewer';
export interface CursorPosition {
    file: string;
    line: number;
    column: number;
}
export interface CollaborativeSession {
    id: string;
    name: string;
    ownerId: string;
    users: Map<string, User>;
    sharedContext: SharedContext;
    permissions: SessionPermissions;
    createdAt: Date;
    expiresAt?: Date;
}
export interface SharedContext {
    messages: SharedMessage[];
    files: Map<string, FileState>;
    variables: Map<string, unknown>;
}
export interface SharedMessage {
    id: string;
    userId: string;
    content: string;
    timestamp: Date;
    type: 'user' | 'assistant' | 'system';
}
export interface FileState {
    path: string;
    content: string;
    version: number;
    lastModifiedBy: string;
    lastModifiedAt: Date;
    locks: Map<string, FileLock>;
}
export interface FileLock {
    userId: string;
    region?: {
        start: number;
        end: number;
    };
    acquiredAt: Date;
    expiresAt: Date;
}
export interface SessionPermissions {
    allowEditing: boolean;
    allowExecution: boolean;
    allowFileOperations: boolean;
    requireApproval: boolean;
    maxUsers: number;
}
export interface CollaborationConfig {
    serverUrl?: string;
    port?: number;
    heartbeatInterval?: number;
    lockTimeout?: number;
    maxSessionDuration?: number;
}
export type CollaborationEvent = {
    type: 'user-joined';
    user: User;
} | {
    type: 'user-left';
    userId: string;
} | {
    type: 'cursor-moved';
    userId: string;
    position: CursorPosition;
} | {
    type: 'message-added';
    message: SharedMessage;
} | {
    type: 'file-changed';
    path: string;
    content: string;
    userId: string;
} | {
    type: 'file-locked';
    path: string;
    userId: string;
} | {
    type: 'file-unlocked';
    path: string;
    userId: string;
};
/**
 * Collaborative Session Manager
 */
export declare class CollaborativeSessionManager extends EventEmitter {
    private config;
    private sessions;
    private currentSession;
    private currentUser;
    constructor(config?: CollaborationConfig);
    createSession(name: string, user: Omit<User, 'id' | 'color' | 'lastActive' | 'role'>, permissions?: Partial<SessionPermissions>): CollaborativeSession;
    joinSession(sessionId: string, user: Omit<User, 'id' | 'color' | 'lastActive' | 'role'>): Promise<CollaborativeSession>;
    leaveSession(): void;
    addMessage(content: string, type?: SharedMessage['type']): SharedMessage;
    /**
     * Trim old messages from shared context to prevent memory leaks.
     * Uses a sliding window approach, keeping the most recent messages.
     */
    private trimMessages;
    /**
     * Get current message count and limit for monitoring
     */
    getMessageStats(): {
        count: number;
        max: number;
    } | null;
    updateCursor(position: CursorPosition): void;
    lockFile(path: string, region?: {
        start: number;
        end: number;
    }): boolean;
    unlockFile(path: string): boolean;
    updateFile(path: string, content: string): boolean;
    getCurrentSession(): CollaborativeSession | null;
    getCurrentUser(): User | null;
    getUsers(): User[];
    hasPermission(permission: keyof SessionPermissions): boolean;
    generateInviteLink(): string;
    private generateId;
    private assignColor;
    dispose(): void;
}
export declare function getCollaborationManager(config?: CollaborationConfig): CollaborativeSessionManager;
export declare function resetCollaborationManager(): void;
export default CollaborativeSessionManager;
