/**
 * Glue between the task tool, the headless runner, and the registry.
 *
 * `runForeground` blocks the calling tool execute() and streams progress into
 * the registry so the TUI can render it. `startDetached` fires-and-forgets a
 * run for backgrounded tasks (or for transcript-based resumes), routing the
 * eventual result through `finishAndNotify` so the parent agent loop is told
 * exactly once via `notifyParent`.
 */
import type { ToolDefinition } from '../../../core/core-types.js';
import type { RuntimePermissionPolicy } from '../../../core/permission-policy.js';
import type { AgentDefinition } from '../../agent-definition.js';
import type { ExtensionContext } from '../../extensions/index.js';
import { type RegisteredTask, type TaskManager } from './manager.js';
import { type TaskSidechainArtifact } from './sidechain.js';
import { type TaskSubagentProgress, type TaskSubagentResult } from './types.js';
export type TaskParentNotifier = (notification: string, scopeId: string, displayText?: string) => void;
export interface TaskRunCoordinatorOptions {
    taskManager: TaskManager;
    scopeId?: string;
    agentId: string;
    agent: AgentDefinition;
    tools: readonly ToolDefinition[];
    context: ExtensionContext;
    taskCwd: string;
    permissionPolicy: RuntimePermissionPolicy;
    userMessageId?: string;
    sidechain?: TaskSidechainArtifact;
    timeoutMs: number;
    effectiveModel?: string;
    notifyParent?: TaskParentNotifier;
}
export interface StartDetachedTaskRunOptions {
    resumeFromSidechain?: boolean;
    abortController?: AbortController;
    useRegisteredRun?: boolean;
}
export interface RunForegroundTaskOptions {
    signal: AbortSignal;
    onProgress?: (progress: TaskSubagentProgress) => void;
}
export declare class TaskRunCoordinator {
    private readonly options;
    /** Construct a coordinator bound to a single subagent run scope. */
    constructor(options: TaskRunCoordinatorOptions);
    /** Run the subagent in the foreground, streaming progress and resolving with the final result. */
    runForeground(prompt: string, options: RunForegroundTaskOptions): Promise<TaskSubagentResult>;
    /** Fire-and-forget run that updates the registry and notifies the parent on completion. */
    startDetached(prompt: string, options?: StartDetachedTaskRunOptions): void;
    /** Finalize the currently registered run for this scope with the given result. */
    finishCurrent(result: TaskSubagentResult): RegisteredTask | undefined;
    /** Finalize a specific runId, deduct child usage, and return the registered task. */
    finishRun(runId: number, result: TaskSubagentResult): RegisteredTask | undefined;
    /** Finalize a run and emit a one-shot notification to the parent loop. */
    private finishAndNotify;
    /** Build the shared runner options used by both foreground and detached runs. */
    private baseRunOptions;
    /** Load prior messages from the sidechain transcript when resuming a backgrounded task. */
    private getInitialMessages;
    /** Resolve (or restart) the registered task entry for a detached run. */
    private getRegisteredRun;
    /** Look up the current registered task for this scope/agent, ignoring ambiguous matches. */
    private getCurrentRun;
    /** Forward subagent progress events into the shared TaskManager registry. */
    private updateProgress;
}
//# sourceMappingURL=lifecycle.d.ts.map