import type { AgentTool } from "../../internal/harness.js";
import type { ToolFaceClass } from "../tool-face.js";
import type { Model } from "../../internal/llm.js";
import { assemblePrompt, type AssembledPrompt } from "../../prompt-assembly/assemble.js";
import { type CenterAdoption } from "../../prompt-assembly/artifact.js";
import { type RunPromptIdentity } from "../../prompt-assembly/epoch.js";
import type { HostForm, HostRole, PromptTraitName, RenderedLocale } from "../../prompt-assembly/catalog/schema.js";
import type { SourcedOverlay } from "../../prompt-assembly/overlay.js";
import { type EnvironmentFacts } from "../../prompts/default.js";
import { type LegModBus } from "../mods/stations.js";
import { type StoredSession } from "../session.js";
import type { RunnerDeps } from "../types.js";
import type { AnnounceOnceSink, Prepared, PrepareResume, PromptFeatureFlags, RunInternals } from "./contracts.js";
import { type PromptHashSalt } from "./session-hash-salt.js";
export interface PreparePromptAssemblyInput {
    /** borrowed-mutable — the acquired session. Read: `getPromptEpoch` (the stored record), `getBranch` (the freshness
     *  discriminator on the record-less arms). Writer here: `appendPromptEpoch`, the ONE record write of this leg (only
     *  when the run's identity differs from the stored record's) and, before the assembly, `appendCustomEntry` — the session's
     *  hash salt when the session holds none yet (`./session-hash-salt.ts`). The acquire phase and the run loop write it elsewhere. */
    session: Pick<StoredSession, "getPromptEpoch" | "getBranch" | "appendPromptEpoch" | "appendCustomEntry">;
    /** borrowed-readonly — the deployment seats: `promptSource` (the center artifact source, its candidate and its
     *  tri-state), `onError` (the assembly's warn channel). Receiver preserved. */
    deps: Pick<RunnerDeps, "promptSource" | "onError">;
    /** borrowed-readonly — the trusted spawn-side channel: the parent's center layer (`parentCenterArtifactDigest`,
     *  `parentCenterSourceRevision`), the top-level freshness facts (`parentTaskId`, `parentSessionId`) and the named-child
     *  fact the teammate flag reads (`explicitAgentName`). */
    internals: Pick<RunInternals, "parentCenterArtifactDigest" | "parentCenterSourceRevision" | "parentTaskId" | "parentSessionId" | "explicitAgentName"> | undefined;
    /** borrowed-readonly — the resume leg, or undefined; PRESENCE only (a resumed leg is never truly fresh). */
    resume: Pick<PrepareResume, "seed"> | undefined;
    /** borrowed-readonly — the request-body sugar's overlays (the task class's first contributions). */
    sugar: readonly SourcedOverlay[];
    /** borrowed-readonly — the host selector values (`promptRole` / `promptForm`). */
    host: {
        readonly role?: HostRole;
        readonly form?: HostForm;
    };
    /** borrowed-readonly — the run's binding (`TaskSpec.promptBinding`, validated), or undefined: a selector value. */
    binding: string | undefined;
    /** borrowed-readonly — the run's locale (`TaskSpec.promptLocale`, validated), or undefined (`canonical`): a selector value. */
    locale: RenderedLocale | undefined;
    /** borrowed-readonly — the leg's mods bus: `prompt.compose` collects the deploy and task seats' overlays. */
    modBus: LegModBus;
    /** borrowed-readonly — the run's abort signal (the compose raise ends with it). */
    signal?: AbortSignal;
    /** borrowed-readonly — the harness-context flags; `orchestrationEnabled` is re-derived against the post-exclusion roster
     *  at assembly. */
    featureFlags: PromptFeatureFlags;
    /** borrowed-readonly — the leg's deferred set (the defer classification's answer — the names that ship as placeholders);
     *  only `has("Workflow")` is read, for the orchestration section's deferred form. */
    deferred: ReadonlySet<string>;
    /** borrowed-readonly — what the valve left the model (the driver's one reading, `toolFaceClassOf`): a runtime fact of the assembly. */
    toolFace: ToolFaceClass;
    /** borrowed-readonly — the MCP instructions block, or undefined. */
    mcpInstructionsBlock: string | undefined;
    /** borrowed-readonly — the memory block as the assembly reads it (the recall paragraph already stripped when a
     *  retraction ran), or undefined. */
    memoryBlock: string | undefined;
    /** borrowed-readonly — the environment facts; `date` is the assembly's date, the block builder re-renders on a date change. */
    envFacts: EnvironmentFacts;
    /** borrowed-readonly — the run's effective prompt traits (a selector value of the assembly). */
    promptTraits: ReadonlySet<PromptTraitName>;
    /** borrowed-readonly — the session's shell-first judgment (session-prompt-seats.ts `shellFirstSessionOf`): the `shellFirstSession` fact,
     *  the same value the tool cards were mounted with. */
    shellFirstSession: boolean;
    /** borrowed-readonly — the leg announces a non-empty skills listing (`Prepared.skillsListing` with entries): exactly when the
     *  engine's own Skill tool is mounted, never for a caller tool that only shares the name. The `skillToolMounted` fact. */
    skillsAnnounced: boolean;
    /** borrowed-readonly — the run's ONE tool roster, read only: the assembly receives DETACHED copies, the audit and the
     *  manifest read it in place. Never mutated here. */
    tools: readonly AgentTool[];
    /** borrowed-readonly — the task model: `id` (the compose event's `model`). */
    model: Pick<Model, "id">;
    /** borrowed-readonly — the acquired session id (every operator line's attribution). */
    sessionId: string;
    /** borrowed-readonly — the once-per-session ledger's operator sink (the collision audit's two lines). */
    onceLedger: Pick<AnnounceOnceSink, "onError">;
}
export interface PreparePromptAssemblyResult {
    /** borrowed-mutable — the LIVE system prompt (an accessor cell over this phase's closure variable). Writers: this
     *  phase's `renderWithDate` (the date re-render, called by the listings phase's date_change seam); the turn-wiring
     *  phase's center candidate `apply` (the compaction-boundary change). Readers: the harness construction, the cache
     *  fingerprint, the turn snapshot's stable text, the prompt-overhead term. */
    systemPromptSeat: {
        current: string;
    };
    /** owned — the date re-render. Returns the new prompt and writes it into `systemPromptSeat`. */
    renderWithDate: ((date: string) => string) | undefined;
    /** owned — the physical block face of the assembled prompt (the harness's systemBlocks and the turn snapshot's
     *  layout groups). */
    systemBlocks: AssembledPrompt["systemBlocks"];
    /** borrowed-mutable — the composition manifest (`Prepared.promptManifest`). Writers after this phase: the tool-disclosure
     *  phase writes `toolDisclosure` and appends the search tool's row to `tools` (when deferred tools exist — the tool is built
     *  there, after this projection); the turn-wiring phase backfills `snapshot` and `lowering` once the final wire tool list exists. */
    promptManifest: Prepared["promptManifest"];
    /** owned — the run's identity inputs and the pinned center layer's provenance (`Prepared.promptIdentity`; the
     *  compaction-boundary candidate replaces it after a committed center change). */
    promptIdentity: RunPromptIdentity;
    /** owned — the re-invokable assemble-inputs BUILDER: the compaction-boundary candidate re-assembles with a new center
     *  layer through it (facts, tails and the run-frozen mods overlays identical; only the center class differs). */
    buildAssembleInputs: (center: CenterAdoption | undefined) => Parameters<typeof assemblePrompt>[0];
    /** owned — the identity inputs under another center layer (the compaction-boundary candidate's record). */
    identityFor: (center: CenterAdoption | undefined) => RunPromptIdentity;
    /** owned — whether this run adopts center candidates at its boundaries: a top-level run does; a child composes its
     *  parent's layer and never adopts one of its own. */
    adoptsCandidates: boolean;
    /** owned — the event templates this run's overlays replaced (`AssembledPrompt.eventCopy`): the run's engine text
     *  reading reads them through `Prepared.engineText`; the compaction-boundary candidate replaces them with its own. */
    eventCopy: ReadonlyMap<string, string>;
    /** borrowed-mutable — the LIVE center adoption (an accessor cell over this phase's closure variable), or undefined.
     *  Writers: this phase (the resolution arms); the turn-wiring phase's center candidate `apply` (the boundary change).
     *  Readers: the two late-bound ctx getters (inherited-gate, caps-and-workflow), the candidate's same-artifact test. */
    centerAdoptionRef: {
        current: CenterAdoption | undefined;
    };
    /** owned — the head's per-block digests as the session's epoch anchor keeps them (`PrefixHeadDigests.blocks`):
     *  unsalted, because the anchor compares across processes, and written only into the session's own store —
     *  never onto a trace (the trace's block hashes are the salted ones). */
    prefixHeadBlocks: Readonly<Record<string, string>>;
    /** owned — the session's hash salt and how far digests under it compare: the manifest's salted digests here, the turn
     *  snapshot's prompt digests and each request's head (the session's prefix ledger) are taken under it. Never on a trace. */
    promptHashSalt: PromptHashSalt;
}
/** The M13 phase body — prepareTask's prompt-assembly stretch (see the module header). */
export declare function preparePromptAssembly(input: PreparePromptAssemblyInput): Promise<PreparePromptAssemblyResult>;
