/**
 * BuilderSession — ties a builder-of-builders workflow together.
 *
 * Models agent-builder's shape: Project → Chat → Edit → Ship → App →
 * AppAgent. Each layer is a Run (linked via parentRunId). The
 * framework-enforced invariants:
 *
 *   - One Project → many Chats; chatId scopes runs within a project.
 *   - One Chat = one builder Run with `layer='builder'`.
 *   - One Ship = one child Run with `layer='app-build'` + SandboxHarness.
 *   - One AppScenario = one grandchild Run with `layer='app-runtime'`.
 *
 * Consumers obtain a BuilderSession, call `startChat`, drive the
 * builder agent (emitting spans), and call `ship` / `runAppScenario`
 * as the workflow progresses. The session reconstructs itself from
 * trace data via `resume(store, projectId)`.
 */
import type { HarnessConfig, SandboxDriver, SandboxHarnessResult } from '../sandbox-harness';
import type { TestGradedRunResult, TestGradedScenario } from '../test-graded-scenario';
import { TraceEmitter } from '../trace/emitter';
import type { Run } from '../trace/schema';
import type { TraceStore } from '../trace/store';
export interface BuilderSessionInit {
    projectId: string;
    chatId?: string;
    /** Free-form: user's task description, project name, etc. Stored on the builder Run. */
    tags?: Record<string, string>;
}
export interface ShipOptions {
    harness: HarnessConfig;
    driver?: SandboxDriver;
    /** scenarioId of this app-build run. Defaults to `${projectId}/build`. */
    scenarioId?: string;
}
export interface RunAppScenarioOptions {
    scenario: TestGradedScenario;
    /** Harness driver override; defaults to the one the session was created with. */
    driver?: SandboxDriver;
}
export declare class BuilderSession {
    private store;
    private builderEmitter;
    readonly projectId: string;
    readonly chatId: string;
    private builderRunId?;
    private lastBuildRunId?;
    private defaultDriver?;
    constructor(store: TraceStore, init: BuilderSessionInit, driver?: SandboxDriver);
    /** Start the builder (L0) run for this chat. Returns the runId. */
    startChat(scenarioId?: string): Promise<string>;
    /** The emitter for builder-level spans (edits, LLM calls, tool invocations). */
    get emitter(): TraceEmitter;
    /**
     * Ship the project's generated app: run the sandbox harness as a child
     * Run (`layer='app-build'`). Returns the build result + runId.
     */
    ship(options: ShipOptions): Promise<{
        runId: string;
        result: SandboxHarnessResult;
    }>;
    /**
     * Run a domain scenario against the just-built app as a grandchild Run
     * (`layer='app-runtime'`). The `ship` call must precede this so the
     * parent is set correctly; if no build exists yet the session attaches
     * directly to the builder run (useful for prototypes).
     */
    runAppScenario(options: RunAppScenarioOptions): Promise<TestGradedRunResult>;
    /** Record an end-of-chat meta score (judge verdict on whether the builder
     *  served the user's intent). Accepts a numeric score + optional rationale. */
    recordMetaScore(score: number, rationale?: string): Promise<void>;
    /** Close the builder Run with a final outcome. */
    endChat(outcome: {
        pass: boolean;
        score?: number;
        notes?: string;
    }): Promise<void>;
    /**
     * Inline app-runtime run — for cases where the "scenario" isn't a
     * SWE-bench-style test suite but a live agent interaction (LLM chat,
     * domain flow). Returns an emitter bound to a fresh Run in the
     * `app-runtime` layer; caller emits spans inside and calls
     * `.endRun()` with the final verdict.
     */
    startAppRuntime(scenarioId: string): Promise<TraceEmitter>;
    /**
     * Lightweight "ship marker" — record an app-build Run with a caller-
     * provided verdict. Use when there isn't a sandbox harness to run but
     * you still want to mark the build state at publish time.
     */
    recordShipMarker(args: {
        pass: boolean;
        score: number;
        scenarioId?: string;
        notes?: string;
    }): Promise<string>;
    get lastBuildRunIdValue(): string | undefined;
    get builderRunIdValue(): string | undefined;
}
/**
 * Reconstruct the most recent BuilderSession state for a given project —
 * returns { builderRunId, lastBuildRunId, chatRuns }. For chat-first UIs
 * this is how a resumed session finds its place in the edit history.
 */
export declare function resumeBuilderSession(store: TraceStore, projectId: string): Promise<{
    projectId: string;
    chatRuns: Run[];
    lastBuilderRun?: Run;
    lastBuildRun?: Run;
    lastAppRuntimeRuns: Run[];
}>;
//# sourceMappingURL=builder-session.d.ts.map