/**
 * ChildSessionMixin.ts — 子 agent 会话共享逻辑
 *
 * 向任意 session 类（ChatSession、RTCChatSession 等）注入子 agent 状态和方法。
 * 子 session 始终是通过 `sdk.aiChat.createSession()` 创建的文本型 ChatSession。
 *
 * ## 使用方式
 * ```ts
 * // 构造函数中：
 * initChildSessionState(this, options);
 *
 * // prototype 上（只需一次）：
 * Object.assign(MySession.prototype, childSessionMethods);
 * ```
 *
 * ## 宿主类要求
 * - `this.sdk` — KeepworkSDK 实例（需有 `.aiChat.createSession()`）
 * - `this.model` — 默认模型名称
 * - `this.options` — 会话选项（可含 `.enableTools`）
 * - `this._triggerImmediateCallback()` — **必须**在宿主类中覆盖实现
 */
/** 子任务对象 */
export interface ChildTask {
    id: string;
    task: string;
    description: string | null;
    tools: string[];
    maxIterations: number;
    systemPrompt: string | null;
    model: string | null;
    thinking: unknown;
    callbackMode: string;
    debounceSeconds: number;
    resolve: (value: unknown) => void;
    reject: (reason: unknown) => void;
    promise: Promise<unknown>;
}
/** 子 session 注册表条目 */
export interface ChildSessionEntry {
    session: ChildSessionHost;
    queue: ChildTask[];
    isRunning: boolean;
}
/** 待处理子 agent 结果 */
export interface PendingChildResult {
    agentName: string;
    taskId: string;
    taskSummary: string;
    result: unknown;
}
/** 子 agent 流式事件 */
export interface ChildStreamEvent {
    agentPath: string;
    agentName: string;
    taskId: string;
    type: 'message' | 'toolCall' | 'complete' | 'error' | string;
    content: unknown;
    fullResponse?: unknown;
}
/** 宿主 session 最小接口（避免循环引用） */
export interface ChildSessionHost {
    name?: string | null;
    parentSession?: ChildSessionHost | null;
    sdk?: unknown;
    aiChat?: {
        sdk?: unknown;
        createSession?: (opts: unknown) => ChildSessionHost;
    };
    model?: string;
    workspace?: string | null;
    sandbox?: unknown;
    options?: {
        enableTools?: string[];
        [key: string]: unknown;
    };
    customTools?: unknown[];
    enabledToolCategories?: string[];
    messages?: Array<{
        role: string;
        content: string;
    }>;
    _history?: unknown[];
    _childSessions: Record<string, ChildSessionEntry>;
    _pendingChildResults: PendingChildResult[];
    _debounceTimers: ReturnType<typeof setTimeout>[];
    _isSending: boolean;
    _lastSendOptions: Record<string, unknown>;
    _maxChildSessions: number;
    _depth: number;
    _maxDepth: number;
    onChildStream: ((event: ChildStreamEvent) => void) | null;
    _triggerImmediateCallback(): Promise<void>;
    send?: (msg: unknown, opts?: unknown) => Promise<unknown>;
    clear?: () => void;
}
/** initChildSessionState 选项 */
export interface ChildSessionInitOptions {
    name?: string;
    parentSession?: ChildSessionHost | null;
    onChildStream?: ((event: ChildStreamEvent) => void) | null;
    _depth?: number;
    _maxDepth?: number;
    [key: string]: unknown;
}
/** 生成 UUID v4（浏览器原生优先）。 */
export declare function _generateUUID(): string;
/**
 * 将值截断为可读摘要字符串，用于日志输出。
 * @param value     - 任意值
 * @param maxLength - 截断字符数（默认 180）
 */
export declare function _summarize(value: unknown, maxLength?: number): string;
/**
 * 在 session 实例上初始化子 agent 状态字段。
 * 在宿主类构造函数内调用。
 *
 * @param self    - session 实例（`this`）
 * @param options - 构造选项
 */
export declare function initChildSessionState(self: ChildSessionHost, options?: ChildSessionInitOptions): void;
/**
 * 要注入到宿主类 prototype 的子 agent 方法集。
 *
 * 宿主类最低要求：
 * - `this.sdk`（或 `this.aiChat`）——有 `.aiChat.createSession()`
 * - `this.model`——默认模型名
 * - `this.options`——选项（可含 `enableTools`）
 * - `this._triggerImmediateCallback()`——**必须在宿主类中覆盖**
 */
export declare const childSessionMethods: Partial<ChildSessionHost> & {
    createChildSession(name: string, options?: Record<string, unknown>): ChildSessionEntry;
    enqueueChildTask(name: string, task: string, tools?: string[], maxIterations?: number, systemPrompt?: string, extra?: Record<string, unknown>): Promise<unknown>;
    _processChildQueue(name: string): Promise<void>;
    _buildAgentPath(childName: string): string;
    _emitChildStream(event: ChildStreamEvent): void;
    _bubbleChildStream(event: ChildStreamEvent): void;
    _consumePendingChildResults(): PendingChildResult[];
    _handleChildCallback(mode: string, debounceSeconds?: number): void;
    _triggerImmediateCallback(): Promise<void>;
    _triggerDebounceCallback(seconds?: number): void;
    _cancelDebounceTimers(): void;
    getParentContext(messageCount?: number): {
        systemPrompt: string | null;
        recentMessages: unknown[];
        model?: string;
        workspace?: string | null;
    } | null;
    getChildSession(name: string): ChildSessionEntry | undefined;
    getChildSessionNames(): string[];
    _cleanupChildSessions(): void;
};
export { initChildSessionState as default };
//# sourceMappingURL=ChildSessionMixin.d.ts.map