import type { CallTargetStamp } from "../effective-path-target.js";
import type { AgentTool } from "../../internal/harness.js";
import type { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
import type { AutoModeDenialTracker } from "../auto-mode.js";
import { type LegModBus } from "../mods/stations.js";
import { type ApprovalParkNotResumable } from "../park-resumability.js";
import { type AskSourceIdentity, type OnAsk, type ToolCallRequest, type ToolPolicy } from "../tool-policy.js";
import { type DeferredAsk, type MarkerChannel } from "./deferred-ask.js";
import type { RunnerDeps } from "../types.js";
import type { CwdRef } from "../../tools/fs/fs-shared.js";
import type { AskLane, Prepared } from "./contracts.js";
import { type CallRiskAxes } from "../ask-origin.js";
import { type ToolRosterDeltaSeat } from "../tool-roster.js";
import { type ExistingTargetSeat } from "../existing-target.js";
import { type GrantBindingOf } from "../skill-grant-binding.js";
import { consumeInheritedAskGrant } from "./inherited-ask-grants.js";
import { type GrantReadRoot } from "./read-root-grant.js";
import type { ApprovalWordsSeat } from "../approval-words.js";
import type { EngineText } from "../../prompt-assembly/engine-text.js";
import type { createRuleOffersOf } from "./permission-rule-lanes.js";
import { type createCallGrantDoorOf, type SessionCallGrantStation } from "./session-call-grant-station.js";
export interface PrepareAskLaneInput {
    /** borrowed-readonly — the wiring-manifest phase's ONE activation predicate; false ⇒ this phase builds nothing and
     *  returns an absent lane. */
    gateMachineryActive: boolean;
    /** borrowed-readonly — prepare's abort seat; only `.signal` is read (composed into every per-call signal and bound
     *  onto the deny observer). Never aborted here. */
    abortController: {
        readonly signal: AbortSignal;
    };
    /** borrowed-readonly — the policy chain's effective policy, or undefined (then no `adjudicate` wrapper is built and
     *  the gate reads a missing policy as allow). Called at RUN time, per tool call, through the abort-bound wrapper. */
    effectivePolicy: ToolPolicy | undefined;
    /** borrowed-readonly — the per-leg-immutable durable budget snapshot stamped onto EVERY adjudicated request. Same
     *  object every call; the policy cannot write it back. */
    budgetSnapshot: NonNullable<ToolCallRequest["budget"]>;
    /** borrowed-readonly — the hand's live tracked cwd, or undefined (hands-less). Read per call at RUN time (`current`),
     *  never captured: the fs hand tools resolve their relative paths against this very ref. Not written here. */
    handsCwdRef: CwdRef | undefined;
    /** borrowed-readonly — the root the hand tools resolve root-relative spellings against, or undefined (hands-less). */
    handsRoot: string | undefined;
    /** borrowed-readonly — the leg's target-reading stamp ({@link CallTargetStamp}), or undefined (hands-less): the request a
     *  policy judges carries a reading of its own args. Called at RUN time; a seat with nothing to stamp answers undefined. */
    stampCallTarget: CallTargetStamp | undefined;
    /** borrowed-readonly — the run's advertised-writable-directory seat, or undefined (hands-less / nothing advertised). `roots` is read at RUN time, never captured: it is the fence's own admitted list and the write gate's exemption domain must be that same list. Not written here. */
    advertisedWritableDirs: Pick<AdvertisedWritableDirs, "roots"> | undefined;
    /** borrowed-readonly — the leg's ONE exempt root, stamped on every request a policy judges (`ToolCallRequest.exemptRoots`). */
    exemptRoots: readonly string[];
    /** borrowed-readonly — the shared mount roster; read at RUN time by the approval-preview projection (the dispatcher's
     *  resolution over whatever the roster holds when the ask is minted). Never mutated here. */
    tools: readonly AgentTool[];
    /** borrowed-mutable — the inherited-unavailable marker channel ({@link MarkerChannel}). Writer here: `resolveAskBound` consumes
     *  (`delete`) a marked call at its fail-closed intercept, its refusal reading each mark's binding against the bytes in front of
     *  it; the policy-chain phase records, the gate station sweeps. */
    inheritedUnavailableAsks: MarkerChannel;
    /** borrowed-mutable — the deferred questions ({@link DeferredAsk}). Writer here: `resolveAskBound`, on an `"unavailable"` answer. */
    deferredAskIdentities: Map<string, DeferredAsk>;
    /** borrowed-mutable — the duplicate-frame ask-grant record. Writer here: the grant-reuse consume half
     *  (`consumeInheritedAskGrant`); the policy-chain phase records, the gate station sweeps. */
    inheritedAskGrants: Parameters<typeof consumeInheritedAskGrant>[0];
    /** borrowed-readonly — the run's own approver seat (spec over deps), or undefined: the resolve target, the
     *  live-approver test the carry mint reads, and the grant-reuse identity law's approver. */
    onAsk: OnAsk | undefined;
    /** borrowed-mutable — the per-task human-review accumulator (`Prepared.humanReviewRef`). Writers here: every
     *  synchronous resolve that a person actually judged (count / totalWaitMs / gates push); runtask adds the durable
     *  resume latency. */
    humanReviewRef: Prepared["humanReviewRef"];
    /** borrowed-readonly — the injectable wall clock every human-time observable reads (`Prepared.now`). */
    now: () => number;
    /** borrowed-readonly — the policy-chain phase's rule-offer factory (the suggestion members the ask mint threads). */
    ruleOffersOf: ReturnType<typeof createRuleOffersOf>;
    /** borrowed-readonly — the policy-chain phase's Skill-card binding factory (`boundGrants` / `boundGrantDigest` on the ask). */
    grantBindingOf: GrantBindingOf;
    /** borrowed-readonly — the leg's one ask source (minted once by the driver; every ask mint site spreads it). */
    askSource: AskSourceIdentity;
    /** borrowed-readonly — the policy-chain phase's per-tool risk-axes projection (`riskAxes` on the ask). */
    riskAxesOf: (call: Pick<ToolCallRequest, "toolName" | "face">) => {
        riskAxes?: CallRiskAxes;
    };
    /** borrowed-readonly — the run's command sandbox side of a call on its args (`AskRequest.commandSandbox`; the call's plan read). */
    commandSandboxSideOf: (call: {
        readonly toolName: string;
        readonly toolCallId: string;
    }, args: unknown) => {
        commandSandbox?: "inside" | "outside";
    };
    /** borrowed-readonly — where a call to an A2A peer's skill goes (`AskRequest.destination`; the leg's declared peers read). */
    destinationOf: (toolName: string) => {
        destination?: import("../mcp-server-spec.js").AskDestination;
    };
    /** borrowed-mutable — the auto-mode denial tracker's live seat (undefined until an arming). Writer here: the carry mint
     *  arms the auto-deny window on it iff the seat about to be called is live (the tracker's one writer). */
    autoModeDenialTracking: {
        readonly current: AutoModeDenialTracker | undefined;
    };
    /** borrowed-readonly — the leg's own task id (`Prepared.taskId`; the late-settlement observer's tag). */
    hostTaskId: string;
    /** borrowed-readonly — the deployment seats this lane reports on, as a Pick over the SAME `deps` object (receiver
     *  preserved for `deps.onError?.()`): the late-settlement observer's notice/error sinks and the hook-crash notifier. */
    deps: Pick<RunnerDeps, "onNotice" | "onError">;
    /** borrowed-readonly — the acquired session id (the observer's tag, the hook-phase error tag). */
    sessionId: string;
    /** borrowed-readonly — the run's invocation id (the observer's tag). */
    runId: string;
    /** borrowed-readonly — the leg's mods bus (the deny observer raises `classic.PermissionDenied` on it). */
    modBus: LegModBus;
    /** borrowed-readonly — the leg's own failure lane (`onError`, phase `hook`, swallow-guarded): the adjudicate seat's report
     *  of a policy chain that threw. */
    notifyOwnHookCrash: (err: unknown) => void;
    /** borrowed-readonly — the hands phase's in-flight read-root widening (an approver's accepted `readRootGrant`), or undefined (hands-less). */
    grantReadRoot: GrantReadRoot | undefined;
    /** borrowed-readonly — the leg's carrier for the approving person's written words ({@link ApprovalWordsSeat}); every ask this lane puts to
     *  the run's approver is resolved with it, so an answer's `feedback` reaches the model (the lane that has none refuses it). */
    approvalWords: ApprovalWordsSeat;
    /** borrowed-readonly — the leg's live roster seat; `current` is read per ask (the row that decides whether the card carries
     *  the target's current state, {@link existingTargetCovers}). The same seat the park and inherited legs read. */
    toolRosterDeltas: Pick<ToolRosterDeltaSeat, "current">;
    /** borrowed-readonly — the run's card-target source, filled once the run's served-read judge exists; `current` is read
     *  per ask. Empty (hands-less) ⇒ a card in scope says `withheld` / `unavailable`. */
    existingTargetSeat: ExistingTargetSeat;
    /** borrowed-readonly — the driver's refusal fact `forcedGateNotResumable` (the leg fact's source word where it binds): `resolveAskBound`
     *  refuses every ask unconsulted, and the refusal names that source's way out. */
    forcedGateNotResumable: ApprovalParkNotResumable | false | undefined;
    /** borrowed-readonly — the run's engine text reading (its locale): the card's headline is minted in it. */
    engineText: EngineText;
    /** borrowed-readonly — the session call grant's door (the rule offers' own ladder) and the run's station, or undefined (no rule
     *  store, no session partition, a hands-less leg): the card's "allow this call for the rest of the session" is minted and
     *  settled here and only here. */
    sessionCallGrants?: {
        readonly door: ReturnType<typeof createCallGrantDoorOf>;
        readonly station: SessionCallGrantStation;
    };
    /** borrowed-readonly — the worker leg's manager station (`TaskSpec.managerApproves`), or undefined. */ managerStation?: ReturnType<typeof import("./manager-seat.js").createManagerStation> | undefined;
}
export interface PrepareAskLaneResult {
    /** owned — the lane, or undefined exactly when `gateMachineryActive` is false (then the suspend saga, the boundary
     *  parks, the park closure and the gate station are not built either — they key off this seat). */
    askLane: AskLane | undefined;
}
/** The M19 ask-lane phase body — prepareTask's in-stream ask stretch, verbatim (see the module header). */
export declare function prepareAskLane(input: PrepareAskLaneInput): PrepareAskLaneResult;
