/**
 * Task Type Taxonomy — CC-aligned sub-agent task state system.
 *
 * CC defines 7 task types for sub-agent dispatch. Each type has different:
 *   - Execution model (in-process, subprocess, remote)
 *   - Isolation level (shared, worktree, container)
 *   - Permission handling (interactive, coordinator, worker)
 *   - Tool access (full, restricted, read-only)
 *
 * Reference: claude-code src/tasks/types.ts
 */
/**
 * Sub-agent task types.
 *
 * PRODUCED today (have a real registration site):
 * - local_bash:   backgrounded shell command (BackgroundTaskManager.registerBashTask)
 * - local_agent:  backgrounded forked agent     (BackgroundTaskManager.startAgentTask)
 * - team_member:  long-lived team subprocess     (team-tool-service → registerExternalTask)
 * - dream:        memory consolidation           (runDream → taskStore.registerTask)
 *
 * PLANNED — declared for the TASK_PREFIX taxonomy + UI/protocol contract, but NO
 * producer exists yet. Do not assume these are created anywhere; wire a producer
 * before relying on them:
 * - remote_agent:    cloud sandbox (polling-based)
 * - local_workflow:  DAG/pipeline execution
 * - monitor_mcp:     MCP server monitoring agent
 *
 * Naming note: we deliberately diverge from upstream CC's `in_process_teammate`.
 * Our team members run as isolated SUBPROCESSES (AgentProcessManager) in their own
 * git worktrees, not AsyncLocalStorage in-process agents — so the honest name is
 * `team_member`. Keeps the `t` task-id prefix.
 */
export type TaskType = "local_bash" | "local_agent" | "remote_agent" | "team_member" | "local_workflow" | "monitor_mcp" | "dream";
/**
 * How a sub-agent is isolated from the parent execution.
 *
 * - shared: Same working directory, same filesystem (default fork)
 * - worktree: Git worktree checkout — separate branch, merges back
 * - container: Container sandbox (docker/remote)
 */
export type IsolationMode = "shared" | "worktree" | "container";
/**
 * Permission context for sub-agent execution.
 * Determines which PermissionChecker variant is used.
 *
 * CC reference: 3 permission handler variants
 * - interactive: User-facing agent, prompts for approval
 * - coordinator: Orchestrator agent, auto-approves most non-destructive ops
 * - worker: Headless worker, classifier-only (no user prompts)
 */
export type PermissionRole = "interactive" | "coordinator" | "worker";
/** Common state fields shared by all task types. */
export interface TaskStateBase {
    /** Unique task ID. */
    taskId: string;
    /** Task type discriminant. */
    type: TaskType;
    /** Human-readable label. */
    label: string;
    /** The permission role for this task's agent. */
    permissionRole: PermissionRole;
    /** Isolation mode. */
    isolation: IsolationMode;
    /** Current lifecycle state. */
    lifecycle: TaskLifecycle;
    /** Parent task ID (for nested sub-agents). */
    parentTaskId?: string;
    /** Execution depth (0 = root). */
    depth: number;
    /** Maximum turns before forced stop. */
    maxTurns: number;
    /** Token budget for this task. */
    tokenBudget: number;
    /** Start timestamp (ms). */
    startedAt: number;
    /** End timestamp (ms), set when completed/failed. */
    endedAt?: number;
    /** Final output (agent answer / command output tail), set on terminal lifecycle. */
    output?: string;
    /** Error message, set when lifecycle is failed. */
    error?: string;
}
export type TaskLifecycle = "pending" | "running" | "completed" | "failed" | "cancelled" | "timeout";
/** Local bash task — subprocess shell execution. */
export interface LocalBashTaskState extends TaskStateBase {
    type: "local_bash";
    command: string;
    cwd: string;
    pid?: number;
    /** Exit code, set when the process exits. */
    exitCode?: number;
    /** Path to the live output file (background tasks stream here). */
    outputPath?: string;
}
/** Local agent task — forked agent with its own tool loop. */
export interface LocalAgentTaskState extends TaskStateBase {
    type: "local_agent";
    agentName: string;
    systemPrompt: string;
    /** Restricted tool set (empty = inherit parent). */
    allowedTools: string[];
    /** Worktree branch name (if isolation === "worktree"). */
    worktreeBranch?: string;
}
/** Remote agent task — cloud sandbox execution. */
export interface RemoteAgentTaskState extends TaskStateBase {
    type: "remote_agent";
    /** Remote session/environment ID. */
    remoteSessionId: string;
    /** Polling endpoint for status checks. */
    pollEndpoint?: string;
}
/** Team member — long-lived collaborator subprocess in its own git worktree. */
export interface TeamMemberTaskState extends TaskStateBase {
    type: "team_member";
    /** Team this member belongs to. */
    teamName: string;
    /** Member's display name. */
    agentName: string;
    /** Stable member id (`team-<team>-<name>`) — routes team send / cancel. */
    memberId: string;
    /** Subprocess PID, once spawned. */
    pid?: number;
    /** Isolated git worktree path (when provisioned). */
    worktreePath?: string;
    /** Worktree branch name (for cleanup). */
    worktreeBranch?: string;
}
/** A single dream agent turn — text output + tool use count. */
export interface DreamTurn {
    text: string;
    toolUseCount: number;
}
/** Dream phase lifecycle — CC alignment. */
export type DreamPhase = "starting" | "updating" | "completed" | "failed";
/** Dream task — background memory consolidation agent (CC autoDream parity). */
export interface DreamTaskState extends TaskStateBase {
    type: "dream";
    sessionId: string;
    /** Current dream phase. */
    phase: DreamPhase;
    /** Number of sessions being reviewed. */
    sessionsReviewing: number;
    /** Memory files touched by the dream agent. */
    filesTouched: string[];
    /** Dream agent turn history (capped). */
    turns: DreamTurn[];
    /** Stashed lock mtime for rollback on failure. */
    priorLockMtime: number;
}
/** Placeholder for planned task types. */
export interface PlannedTaskState extends TaskStateBase {
    type: "local_workflow" | "monitor_mcp";
}
/** Union of all concrete task states. */
export type TaskState = LocalBashTaskState | LocalAgentTaskState | RemoteAgentTaskState | TeamMemberTaskState | DreamTaskState | PlannedTaskState;
/**
 * Filter available tools by permission role.
 *
 * @param role - The agent's permission role
 * @param availableTools - Full set of tool names
 * @returns Filtered tool names appropriate for the role
 */
export declare function filterToolsByRole(role: PermissionRole, availableTools: string[]): string[];
/** Create a new task state with defaults populated. */
export declare function createTaskState(overrides: Pick<TaskStateBase, "taskId" | "type" | "label"> & Partial<TaskStateBase>): TaskStateBase;
