/**
 * Environment context (working directory + current date) delivered to the
 * model as an append-only, hidden user-role custom message instead of as
 * system prompt text (senpi#2093).
 *
 * A date or cwd line inside the system prompt rewrites the provider-visible
 * prefix every day and in every directory, so automatic prefix caches
 * (OpenAI, Anthropic, and the rest) miss the whole system prompt and
 * everything after it. Carrying the values in a message placed before the
 * next user turn keeps the system prompt byte-stable; a new message is
 * appended only when a value changes, and earlier ones are never rewritten.
 *
 * On the wire the message is the leading content block of the user message it
 * precedes (senpi#2118), so providers whose chat templates require strict
 * user/assistant alternation never see two consecutive user messages.
 */
import type { AgentMessage } from "@earendil-works/pi-agent-core";
import type { Message } from "@earendil-works/pi-ai";
import type { CustomMessage } from "./messages.ts";
export declare const ENVIRONMENT_CONTEXT_MESSAGE_TYPE = "environment-context";
export interface EnvironmentContext {
    /** Working directory with `/` separators. */
    cwd: string;
    /** UTC calendar date, `YYYY-MM-DD`. */
    currentDate: string;
}
export declare function resolveEnvironmentContext(cwd: string, now?: Date): EnvironmentContext;
export declare function formatEnvironmentContext(context: EnvironmentContext): string;
export declare function latestEnvironmentContext(messages: readonly AgentMessage[]): EnvironmentContext | undefined;
export declare function createEnvironmentContextMessage(context: EnvironmentContext, timestamp?: number): CustomMessage<EnvironmentContext>;
/**
 * A new environment context message when `current` differs from the latest
 * one in `messages` (or none is visible, e.g. a fresh session or a compaction
 * that summarized it away); `undefined` when the model already sees it.
 */
export declare function environmentContextMessageIfChanged(messages: readonly AgentMessage[], current: EnvironmentContext): CustomMessage<EnvironmentContext> | undefined;
/**
 * Merge each converted environment-context message into the user message that
 * immediately follows it, as that message's leading content block(s). One that
 * no user message follows stays a standalone user message. Conversion runs on
 * the persisted entries, so a resumed session produces the same bytes and a
 * sent user message never changes on later requests.
 */
export declare function foldEnvironmentContextIntoNextUserMessage(messages: readonly Message[], environmentMessages: ReadonlySet<Message>): Message[];
//# sourceMappingURL=environment-context.d.ts.map