import type { Context } from '@deepseek-ai/cordis'; import type { Session } from '@deepseek-ai/dsh-session'; import { type MirrorTransport } from '@khorsheed/dsh-local-agent'; /** The member tool names that start a Claude Code subagent (`Task` is the pre-2.x name). */ export declare const CLAUDE_SUBAGENT_TOOLS: ReadonlySet; /** Options for {@link ClaudeSubagentMirror}. */ export interface ClaudeSubagentMirrorOptions { readonly ctx: Context; /** The member's live dsh child session. */ readonly member: Session; /** The `claude-code` scoped home the member's CLI runs against (`CLAUDE_CONFIG_DIR`). */ readonly homeDir: string; /** How the member's rounds run: picks the harness's `unrecorded` declaration. */ readonly transport: MirrorTransport; /** The coalescing delay for liveness-driven tails (ms); default 250. */ readonly tailDelayMs?: number | undefined; /** How often open background subagents are re-read between rounds (ms); default 2000. */ readonly pollMs?: number | undefined; } type JsonObject = Record; /** * One member's Claude Code subagents, mirrored into grandchild sessions. * One instance lives as long as the member's CLI process can run subagents: * per live runtime (it outlives a round for background subagents), per exec * round otherwise. */ export declare class ClaudeSubagentMirror { private readonly options; private readonly calls; private readonly tails; private cliSessionId; private subagentsDir; private queue; private tailTimer; private pollTimer; private disposed; constructor(options: ClaudeSubagentMirrorOptions); /** The CLI session the member runs (the stream's init `session_id`). */ setCliSession(sessionId: string | undefined): void; /** Whether any subagent's execution is still open. */ get open(): boolean; private paired; /** * Observe one member stream-json event. The member's `Agent`/`Task` * tool_use registers a call; its tool_result marks the call answered (or * launched in the background); a subagent's own event (`parent_tool_use_id`) * is only the signal that a tail is due. Returns whether a tail is due. */ observe(event: JsonObject): boolean; /** Observe every line of a whole stream-json text (the exec path's settle read). */ observeStream(output: string): void; /** Coalesce a tail after a burst of stream events (the live path). */ schedule(): void; /** Discover new subagents, mirror new transcript lines, and close what is done. Serialized. */ tail(): Promise; /** * The member's round settled. Tail once more; a foreground subagent still * without its answer ends `cancelled` (the member stopped waiting). A * background subagent stays open unless `processExited` (the exec path's * one-shot), where it ends `done` when the meta says finished, else * `cancelled`. */ settleRound(options: { readonly processExited: boolean; }): Promise; /** * The member's CLI process is gone (reclaimed, crashed, retired): a * subagent still open can no longer finish. Its execution ends * `uncertain` after a last tail. */ lost(): Promise; /** Stop the timers (the owner is going away); open executions stay as written. */ dispose(): void; /** Wait for every queued pass (tests, and owners that must not outrun the writer). */ idle(): Promise; private enqueue; /** Re-read open background subagents between rounds (nothing else drives a tail then). */ private armPoll; /** One discover + tail + close pass. */ private pass; /** The member CLI session's `subagents/` directory (found by name: the cwd slug is lossy). */ private directory; /** Pair each unpaired member call with its subagent's meta (`toolUseId`). */ private discover; private metaFinished; /** Read the transcript's new complete lines into the tail's parser. */ private read; /** Fold one transcript line: the prompt is kept aside, the call content goes to the parser. */ private fold; /** Open the grandchild and its execution on first need. */ private ensureExecution; /** * Write the completed calls as steps. Live (`final` false), the last call * is held back (it may still grow a block) unless every tool in it has its * result, and a call with an unresulted tool holds the pass. `final` * writes everything; `interrupted` marks the cut-off last call. */ private write; private writeGroup; /** Flush the transcript and write the end record. */ private finish; } export {}; //# sourceMappingURL=subagent-mirror.d.ts.map