/**
 * Team Collaboration System
 *
 * Features:
 * - Session sharing with team members
 * - Real-time collaboration
 * - Role-based permissions
 * - Session history and audit log
 * - Workspace synchronization
 *
 * Inspired by collaborative coding tools like VS Code Live Share.
 */
import { EventEmitter } from 'events';
export interface TeamMember {
    id: string;
    name: string;
    email: string;
    role: 'owner' | 'admin' | 'editor' | 'viewer';
    avatar?: string;
    status: 'online' | 'offline' | 'away';
    lastSeen: Date;
    permissions: Permission[];
}
export interface Permission {
    resource: string;
    actions: ('read' | 'write' | 'execute' | 'delete' | 'share')[];
}
export interface SharedSession {
    id: string;
    name: string;
    description?: string;
    owner: string;
    members: TeamMember[];
    createdAt: Date;
    updatedAt: Date;
    expiresAt?: Date;
    settings: SessionSettings;
    state: SessionState;
    auditLog: AuditEntry[];
}
export interface SessionSettings {
    allowAnonymous: boolean;
    requireApproval: boolean;
    maxMembers: number;
    autoExpire: boolean;
    expireAfterHours: number;
    allowFileEdits: boolean;
    allowTerminalAccess: boolean;
    allowCodeExecution: boolean;
    notifyOnJoin: boolean;
    notifyOnLeave: boolean;
    recordSession: boolean;
}
export interface SessionState {
    isActive: boolean;
    currentFile?: string;
    cursorPositions: Map<string, CursorPosition>;
    sharedContext: SharedContext;
    pendingChanges: PendingChange[];
}
export interface CursorPosition {
    memberId: string;
    file: string;
    line: number;
    column: number;
    selection?: {
        startLine: number;
        startColumn: number;
        endLine: number;
        endColumn: number;
    };
}
export interface SharedContext {
    conversationHistory: ConversationMessage[];
    sharedFiles: string[];
    pinnedMessages: string[];
    annotations: Annotation[];
}
export interface ConversationMessage {
    id: string;
    memberId: string;
    memberName: string;
    content: string;
    timestamp: Date;
    type: 'user' | 'assistant' | 'system';
    attachments?: string[];
}
export interface Annotation {
    id: string;
    memberId: string;
    file: string;
    line: number;
    content: string;
    createdAt: Date;
    resolved: boolean;
}
export interface PendingChange {
    id: string;
    memberId: string;
    type: 'file_edit' | 'file_create' | 'file_delete' | 'terminal_command';
    target: string;
    content?: string;
    timestamp: Date;
    status: 'pending' | 'approved' | 'rejected';
    approvedBy?: string;
}
export interface AuditEntry {
    id: string;
    timestamp: Date;
    memberId: string;
    memberName: string;
    action: string;
    details: Record<string, unknown>;
    ipAddress?: string;
}
export interface TeamSessionConfig {
    serverUrl?: string;
    enableEncryption: boolean;
    encryptionKey?: string;
    autoReconnect: boolean;
    reconnectInterval: number;
    heartbeatInterval: number;
    maxReconnectAttempts: number;
}
/**
 * Team Session Manager
 */
export declare class TeamSessionManager extends EventEmitter {
    private config;
    private currentSession;
    private currentMember;
    private ws;
    private reconnectAttempts;
    private heartbeatTimer;
    private sessionsDir;
    constructor(config?: Partial<TeamSessionConfig>);
    /**
     * Initialize the session manager
     */
    private initialize;
    /**
     * Load member profile from disk
     */
    private loadMemberProfile;
    /**
     * Create default member profile
     */
    private createDefaultProfile;
    /**
     * Generate unique ID
     */
    private generateId;
    /**
     * Generate session share code
     */
    private generateShareCode;
    /**
     * Create a new shared session
     */
    createSession(name: string, settings?: Partial<SessionSettings>): Promise<SharedSession>;
    /**
     * Join an existing session
     */
    joinSession(sessionId: string, _shareCode?: string): Promise<SharedSession | null>;
    /**
     * Leave current session
     */
    leaveSession(): Promise<void>;
    /**
     * Invite member to session
     */
    inviteMember(email: string, role?: TeamMember['role']): Promise<string>;
    /**
     * Update member role
     */
    updateMemberRole(memberId: string, newRole: TeamMember['role']): Promise<void>;
    /**
     * Remove member from session
     */
    removeMember(memberId: string): Promise<void>;
    /**
     * Share a message with the team
     */
    shareMessage(content: string, type?: 'user' | 'assistant'): Promise<void>;
    /**
     * Share a file with the team
     */
    shareFile(filePath: string): Promise<void>;
    /**
     * Add annotation to a file
     */
    addAnnotation(file: string, line: number, content: string): Promise<Annotation>;
    /**
     * Update cursor position
     */
    updateCursorPosition(file: string, line: number, column: number): void;
    /**
     * Submit a change for approval
     */
    submitChange(type: PendingChange['type'], target: string, content?: string): Promise<PendingChange>;
    /**
     * Approve a pending change
     */
    approveChange(changeId: string): Promise<void>;
    /**
     * Reject a pending change
     */
    rejectChange(changeId: string, reason?: string): Promise<void>;
    /**
     * Check if current member has permission
     */
    hasPermission(action: Permission['actions'][number]): boolean;
    /**
     * Add entry to audit log
     */
    private addAuditEntry;
    /**
     * Save session to disk
     */
    private saveSession;
    /**
     * Load session from disk
     */
    private loadSession;
    /**
     * Encrypt data
     */
    private encrypt;
    /**
     * Decrypt data
     */
    private decrypt;
    /**
     * Connect to WebSocket server for real-time updates
     */
    private connectWebSocket;
    /**
     * Disconnect WebSocket
     */
    private disconnectWebSocket;
    /**
     * Start heartbeat
     */
    private startHeartbeat;
    /**
     * Stop heartbeat
     */
    private stopHeartbeat;
    /**
     * Handle WebSocket message
     */
    private handleWebSocketMessage;
    /**
     * Broadcast update to all members
     */
    private broadcastUpdate;
    /**
     * Get current session
     */
    getCurrentSession(): SharedSession | null;
    /**
     * Get current member
     */
    getCurrentMember(): TeamMember | null;
    /**
     * List all sessions
     */
    listSessions(): Promise<SharedSession[]>;
    /**
     * Get session audit log
     */
    getAuditLog(): AuditEntry[];
    /**
     * Export session
     */
    exportSession(format?: 'json' | 'markdown'): Promise<string>;
    /**
     * Format session status
     */
    formatStatus(): string;
    /**
     * Dispose resources
     */
    dispose(): void;
}
export declare function getTeamSessionManager(config?: Partial<TeamSessionConfig>): TeamSessionManager;
export declare function resetTeamSessionManager(): void;
