/**
 * Session Registry
 *
 * Central registry for managing multi-agent sessions.
 * Enables inter-session communication and coordination.
 *
 * Inspired by OpenClaw's session tools system.
 */
import { EventEmitter } from 'events';
export type SessionKind = 'main' | 'channel' | 'cron' | 'hook' | 'spawn' | 'node';
export type SessionStatus = 'active' | 'idle' | 'completed' | 'error';
export interface SessionInfo {
    id: string;
    key: string;
    kind: SessionKind;
    agentId: string;
    status: SessionStatus;
    channelId?: string;
    peerId?: string;
    label?: string;
    parentSessionId?: string;
    createdAt: Date;
    lastActivityAt: Date;
    messageCount: number;
    model?: string;
    sandboxed: boolean;
}
export interface SessionMessage {
    id: string;
    sessionId: string;
    role: 'user' | 'assistant' | 'system' | 'tool';
    content: string;
    toolCalls?: Array<{
        id: string;
        name: string;
        arguments: Record<string, unknown>;
    }>;
    toolResult?: {
        toolCallId: string;
        result: unknown;
    };
    timestamp: Date;
    tokenCount?: number;
}
export interface SessionRegistryConfig {
    maxSessions: number;
    idleTimeoutMs: number;
    cleanupIntervalMs: number;
    defaultMaxRounds: number;
    persistPath: string;
}
export declare const DEFAULT_SESSION_REGISTRY_CONFIG: SessionRegistryConfig;
export declare class SessionRegistry extends EventEmitter {
    private config;
    private sessions;
    private sessionsByKey;
    private messages;
    private cleanupTimer;
    private pendingReplies;
    constructor(config?: Partial<SessionRegistryConfig>);
    start(): Promise<void>;
    stop(): Promise<void>;
    /**
     * Create a new session
     */
    createSession(params: {
        kind: SessionKind;
        agentId: string;
        channelId?: string;
        peerId?: string;
        label?: string;
        parentSessionId?: string;
        model?: string;
        sandboxed?: boolean;
    }): SessionInfo;
    /**
     * Get session by ID
     */
    getSession(sessionId: string): SessionInfo | undefined;
    /**
     * Get session by key
     */
    getSessionByKey(key: string): SessionInfo | undefined;
    /**
     * Update session status
     */
    updateSession(sessionId: string, updates: Partial<SessionInfo>): void;
    /**
     * Delete session
     */
    deleteSession(sessionId: string): boolean;
    /**
     * List sessions with filters
     */
    listSessions(params?: {
        kinds?: SessionKind[];
        limit?: number;
        activeMinutes?: number;
        agentId?: string;
    }): SessionInfo[];
    /**
     * Add message to session
     */
    addMessage(sessionId: string, message: Omit<SessionMessage, 'id' | 'timestamp'>): SessionMessage;
    /**
     * Get session history
     */
    getHistory(sessionId: string, params?: {
        limit?: number;
        includeTools?: boolean;
    }): SessionMessage[];
    /**
     * Send message to another session
     */
    sendToSession(sourceSessionId: string, targetKey: string, message: string, timeoutSeconds?: number): Promise<{
        success: boolean;
        response?: string;
        error?: string;
        fireAndForget: boolean;
    }>;
    /**
     * Reply to a pending message
     */
    replyToSession(replyId: string, response: string): boolean;
    /**
     * Spawn a sub-session
     */
    spawnSession(params: {
        parentSessionId: string;
        task: string;
        label?: string;
        agentId?: string;
        model?: string;
        allowedTools?: string[];
        context?: Record<string, unknown>;
    }): SessionInfo;
    private loadPersistedSessions;
    private persistSessions;
    private cleanupIdleSessions;
    private buildSessionKey;
    getStats(): {
        totalSessions: number;
        activeSessions: number;
        byKind: Record<SessionKind, number>;
        totalMessages: number;
    };
}
export declare function getSessionRegistry(config?: Partial<SessionRegistryConfig>): SessionRegistry;
export declare function resetSessionRegistry(): Promise<void>;
export default SessionRegistry;
