import type { Model } from "../../internal/llm.js";
import { type AutoModeDenialTracker } from "../auto-mode.js";
import { type SideQuerySpec } from "../side-query.js";
import type { RunnerDeps } from "../types.js";
import { type SideCallBook } from "./side-call-account.js";
import { type RequestObserver } from "./prefix-ledger.js";
import type { GateDeliveredCall } from "../unavailable-landing.js";
import { type OnAsk, type PermissionResult, type ResolvedAsk, type ToolCallRequest, type ToolPolicy } from "../tool-policy.js";
/** The seat a manager leg mints: whose loop decides (its leg's abort signal fires when that loop ends, before the leg settles and
 *  publishes its result) and which model judges. Only a seat {@link mintManagerSeat} made is read: an object of the same shape
 *  handed in through a host's internals is not a manager. */
export interface ManagerSeat {
    /** The manager leg's own abort signal: aborted at the end of its turn loop (normal end, cancel, timeout, park). */
    readonly managerSignal: AbortSignal;
    /** The manager leg's model, as its catalog identity: a worker on another model is not judged. */
    readonly model: ManagerModelIdentity;
}
/** A model's identity for the same-model test: provider, endpoint and id. */
export interface ManagerModelIdentity {
    readonly provider: string;
    readonly baseUrl: string;
    readonly id: string;
}
/** Mint the seat of a manager leg (see {@link ManagerSeat}). */
export declare function mintManagerSeat(managerSignal: AbortSignal, model: Pick<Model, "provider" | "baseUrl" | "id">): ManagerSeat;
/** The seat as the engine minted it, else `undefined` (a host-built look-alike, or nothing). */
export declare function mintedManagerSeat(v: unknown): ManagerSeat | undefined;
/** A model's identity for {@link ManagerModelIdentity}. */
export declare function identityOf(model: Pick<Model, "provider" | "baseUrl" | "id">): ManagerModelIdentity;
/** Whether two model identities name the same model. */
export declare function sameModel(a: ManagerModelIdentity, b: ManagerModelIdentity): boolean;
/** The judge's system prompt. Its opening sentence is fixed (a scripted model in the suite recognises the judge by it). */
export declare const MANAGER_JUDGE_SYSTEM: string;
/** The most bytes of rendered arguments a judgment is asked over: a longer call is not cut (a cut command can hide its tail) —
 *  it is not judged at all. */
export declare const MANAGER_JUDGE_MAX_CALL_BYTES: number;
/** The most characters of the assignment the judge is shown (cut with a trusted note). */
export declare const MANAGER_JUDGE_MAX_ASSIGNMENT_CHARS: number;
/** The judge's question for one call, or `undefined` when the call's arguments do not render within
 *  {@link MANAGER_JUDGE_MAX_CALL_BYTES} (not judged: the card goes on to the seat). */
export declare function managerJudgeQuestion(call: {
    readonly toolName: string;
    readonly args: unknown;
}, assignment: string, workerName: string | undefined): string | undefined;
/** The judge's three answers. */
export type ManagerVerdict = "allow" | "refuse" | "consult";
/** The judge's reply read: the whole reply, outer whitespace aside, is one well-formed tag, else `consult` (a tag inside prose is
 *  quoted, not answered). */
export declare function readManagerVerdict(reply: string): ManagerVerdict;
/** What the worker's model is told when the manager refused its call: a fixed sentence, no manager text. */
export declare const MANAGER_REFUSAL_SENTENCE = "Your manager declined this call. It did not run. Change your approach, or say in your report what you needed and why.";
/** What a worker leg hands its manager station: everything it reads is the leg's own, read at the call. */
export interface ManagerStationInput {
    /** The seat this leg inherited (a seat the engine minted; absent on a resumed leg, which reads none). */
    readonly seat: ManagerSeat;
    /** The leg's own approval seat. */
    readonly onAsk: OnAsk | undefined;
    /** Whether this leg's parks are mandated (the forced gate, or `durableApproval` with no live seat). */
    readonly durableMandate: boolean;
    /** The leg's model identity now. */
    readonly workerModel: () => ManagerModelIdentity;
    /** Whether a path the acceptEdits mode's own write gate would admit: the gate the mode uses, asked about an absolute path. */
    readonly acceptsEditAt: (absolutePath: string, req: ToolCallRequest, signal: AbortSignal) => Promise<boolean>;
    /** Whether `name` is an engine shell-face tool. */
    readonly isShellTool: (name: string) => boolean;
    /** Whether the call is a running extension's (`$.tool.call`), not the worker model's: its arguments are no model's words. */
    readonly requestedByExtension: (toolCallId: string) => boolean;
    /** One side call on the leg's model (booked on the leg, lane `manager`): the reply text, or `undefined` when it could not be had. */
    readonly ask: (system: string, question: string, signal: AbortSignal) => Promise<string | undefined>;
    /** The leg's own refusal count (count first, judge second). */
    readonly tracker: AutoModeDenialTracker;
    /** What the manager wrote when it dispatched this worker, and the worker's name. */
    readonly assignment: string;
    readonly workerName: string | undefined;
    readonly timeoutMs: number;
    readonly now: () => number;
}
/** The manager station: the settled resolution of `decision` for `req` when the manager answered it, else `undefined` (the card
 *  goes on, byte for byte, to the leg's own seat). */
export declare function createManagerStation(input: ManagerStationInput): (decision: PermissionResult, req: GateDeliveredCall, callSignal?: AbortSignal) => Promise<ResolvedAsk | undefined>;
/** The seat a leg hands the workers it spawns: its own, minted when it declares the switch and keeps a ledger; else the one it
 *  inherited — none on a resumed leg, which neither reads nor forwards an inherited seat. */
export declare function managerSeatForChildrenOf(leg: {
    readonly declares: boolean;
    readonly keepsLedger: boolean;
    readonly inherited: unknown;
    readonly resumed: boolean;
    readonly signal: AbortSignal;
    readonly model: Pick<Model, "provider" | "baseUrl" | "id">;
}): ManagerSeat | undefined;
/** The judge's reply cap: a verdict tag needs a handful of tokens; room is left for a model that writes a short preamble. */
export declare const MANAGER_JUDGE_MAX_OUTPUT_TOKENS = 1024;
/** A worker leg's manager station, or `undefined` when the leg holds no seat the engine minted (or resumes, and reads none). */
export declare function managerStationOfLeg(leg: {
    readonly inherited: unknown;
    readonly resumed: boolean;
    readonly onAsk: OnAsk | undefined;
    readonly forceDurableGate: boolean;
    readonly durableApprovalDeclared: boolean;
    readonly model: () => Model;
    readonly acceptEditsGate: ToolPolicy;
    /** The leg's mods bus: a running extension call on it is not the worker model's call. */
    readonly modBus: object;
    readonly assignment: unknown;
    readonly workerName: string | undefined;
    readonly deps: RunnerDeps;
    /** The leg's usage door (bound by the run body before any tool call): a judgment is booked on this leg, lane `manager`. */
    readonly sideCallBookRef: {
        readonly book?: SideCallBook;
    };
    readonly observeSideRequest: RequestObserver;
    readonly getApiKeyAndHeaders: SideQuerySpec["getApiKeyAndHeaders"];
    readonly now: () => number;
}): ReturnType<typeof createManagerStation> | undefined;
