import { type Agent } from "@earendil-works/pi-agent-core";
import type { DynamicSystemPromptPart } from "./dynamic-prompt/build.ts";
import type { ExtensionRunner } from "./extensions/runner.ts";
import type { BuildSystemPromptOptions, PromptCachePrefixRequestOptions, PromptCachePrefixResult, ServiceTier } from "./extensions/types.ts";
import type { ModelRuntime } from "./model-runtime.ts";
import { type PromptSizeInventory } from "./prompt-size-startup.ts";
export interface PromptCachePrefixSources {
    readonly agent: Agent;
    readonly runner: ExtensionRunner;
    readonly modelRuntime: ModelRuntime;
    /** Settles once the session start the prefix depends on (tools, discovered skills) has run. */
    readonly ready: Promise<void>;
    readonly sizesOnlyStartup?: boolean;
    readonly promptSizeInventory?: PromptSizeInventory;
    getServiceTier(): ServiceTier | undefined;
    getBaseSystemPrompt(): string;
    getBaseSystemPromptOptions(): BuildSystemPromptOptions;
    getBaseSystemPromptParts?(): readonly DynamicSystemPromptPart[];
}
export declare const PROMPT_STARTED_REASON = "a prompt started composing its turn before the prefix was built";
/**
 * The session's in-flight prefix builds (senpi#2115). A real turn's `before_agent_start`
 * must never run beside a preview pass, so the host cancels every build before it emits one.
 */
export declare class PromptCachePrefixBuilds {
    #private;
    build(sources: PromptCachePrefixSources, options?: PromptCachePrefixRequestOptions): Promise<PromptCachePrefixResult>;
    cancelAll(): void;
}
/**
 * Build the provider request prefix of the next user turn (senpi#2096). Each input comes
 * from the source the turn itself reads, so the prewarmed prefix is the turn's prefix:
 * - system prompt: the base prompt through a `before_agent_start` preview pass, which is
 *   what `AgentSession.prompt()` installs as `agent.state.systemPrompt`;
 * - tools: `agent.state.tools` (and `declaredTools`) through the agent loop's own
 *   `buildProviderContext`, so an allowed-tools model gets the same declared list and
 *   callable subset;
 * - reasoning, thinking selection/budgets, session id, and `onPayload`: the fields
 *   `Agent.createLoopConfig()` passes to the stream function;
 * - service tier: the session's effective tier, which the SDK stream function applies to
 *   the active model;
 * - auth, headers, `extraBody`, env, and the upstream model id: `ModelRuntime` resolves
 *   them exactly as it does before `streamSimple`.
 *
 * The preview pass runs only handlers registered `previewSafe` (senpi#2115): a handler that
 * never declared itself safe could consume one-shot state for a turn that does not exist,
 * so while one is registered the build is skipped before any handler runs.
 */
export declare function buildPromptCachePrefixRequest(sources: PromptCachePrefixSources, signal: AbortSignal, requestOptions?: PromptCachePrefixRequestOptions): Promise<PromptCachePrefixResult>;
//# sourceMappingURL=prompt-cache-prefix-request.d.ts.map