/**
 * RunLoop - The autonomous agent loop.
 *
 * Drives multi-turn agent runs by calling an LLM, running tool calls
 * via the sandboxed Bash instance, and repeating until a stop condition is met.
 *
 * Real-agent-runtime capabilities (A2):
 * - Typed self-correction: `result.observations` (A3) are forwarded in the
 *   tool payload so the LLM sees machine-readable failure codes, not just text.
 * - Self-healing: on a non-zero exit the AgenticHealer is consulted to suggest
 *   (and optionally apply) a correction before the next turn.
 * - Cross-turn memory: salient per-turn facts are persisted to (and loaded
 *   from) the ServiceContainer's AgentMemory store.
 * - Plan-mode enforcement: when mode is "plan", WRITE tools are gated (queued,
 *   not executed); read-only tools still run.
 *
 * Stop conditions:
 * - LLM returns `end_turn` (task complete)
 * - Token / turn / wall-clock budget exhausted
 * - AbortSignal triggered
 * - Unrecoverable error
 *
 * NOTE: All command invocations go through the sandboxed virtual Bash shell
 * (ag-bash in-memory interpreter), NOT through child_process or system shells.
 */
import type { Bash } from "../Bash.js";
import type { RunLoopConfig, RunLoopResult } from "./types.js";
export declare class RunLoop {
    private readonly bash;
    private readonly llm;
    private readonly config;
    private readonly budget;
    private readonly messages;
    private readonly tools;
    private readonly readOnlyTools;
    private readonly healerEnabled;
    private readonly healerAutoFix;
    private healer;
    private gatedToolCalls;
    private healingAttempts;
    constructor(bash: Bash, config: RunLoopConfig);
    /**
     * Run the agent loop with the given goal.
     * The loop calls the LLM, runs tool calls, and repeats until done.
     */
    run(goal: string): Promise<RunLoopResult>;
    private runTurn;
    /**
     * Determines whether a tool call is read-only (safe for parallel execution
     * AND permitted in plan mode). A tool is read-only when it is in the
     * configured `readOnlyTools` allowlist OR it is not a known write tool.
     */
    private isReadOnlyTool;
    /**
     * Whether a tool call must be GATED (blocked) under the current mode.
     * In "plan" mode, write tools are gated; read-only tools always run.
     */
    private isGated;
    /**
     * Execute tool calls with optimal parallelism:
     * - Single tool call: await directly (no Promise.all overhead)
     * - Multiple read-only tools: parallel via Promise.all
     * - Any write tool present: sequential execution (preserves state ordering)
     */
    private executeToolCalls;
    /** Times and invokes a single tool call, producing a ToolCallResult. */
    private runOne;
    /**
     * Invokes a tool call using the sandboxed ag-bash virtual shell.
     * This does NOT use child_process - it uses the in-memory Bash interpreter.
     *
     * Plan-mode: write tools are gated here (queued, never executed). The agent
     * receives a structured `gated: true` payload so it can plan accordingly.
     */
    private invokeToolCall;
    /**
     * Consults the AgenticHealer on a failed command. When autoFix is enabled the
     * healer may actively re-execute a corrected command on the shell (respecting
     * its own retry cap); otherwise it only produces a suggestion string. The
     * healer's own re-executions are bounded by its maxRetries and DO NOT bypass
     * the loop's budget checks (the loop re-checks budget on the next turn).
     */
    private attemptHealing;
    /** Lazily constructs the healer with config derived from RunLoopConfig. */
    private getHealer;
    /** Whether memory persistence is active for this run. */
    private get memoryEnabled();
    private get agentType();
    private get memoryScope();
    /**
     * Hydrates the AgentMemory store and injects prior salient facts into the
     * system context so the agent recalls past decisions across turns AND runs.
     */
    private loadMemoryContext;
    /** Persists one salient key/value fact (no-op when memory is disabled). */
    private persistMemory;
    /** Records a compact summary of a turn's tool outcomes. */
    private persistTurnMemory;
    private getDefaultTools;
}
