import { Effect, Option } from "effect"; import { Chat, Prompt } from "effect/unstable/ai"; import { SessionStore } from "../context/session.js"; import type { Event as ModelTelemetryEvent } from "../model/model-telemetry.js"; import { AgentError, ResumeMismatch } from "./agent-event.js"; import { type SuspensionCheckpoint } from "./agent-suspension.js"; /** * @experimental Session owns model-facing history; a Chat is its live view. * * The system message is derived from current instructions on every run, so it is never a Session * entry. These helpers are the single boundary between the two representations: entries hold * conversation only, and a Chat regains the derived system message whenever one is rebuilt. */ /** @experimental Drop the derived system message before conversation becomes durable state. */ export declare const conversationOnly: (prompt: Prompt.Prompt) => Prompt.Prompt; /** @experimental Restore a Session projection into a Chat by prepending the derived system message. */ export declare const withDerivedSystem: (input: { readonly system: string | undefined; readonly supplemental?: string | undefined; readonly projection: Prompt.Prompt; }) => Prompt.Prompt; /** * @experimental Seed a new Chat from the active Session path. * * A run continues its Session instead of starting empty, which is what makes a second turn carry the * first. Returns undefined when no Session is active or the caller supplied explicit history. */ export declare const seedFromSession: (input: { readonly activeSession: Option.Option; readonly suppliedHistory: Prompt.RawInput | undefined; }) => Effect.Effect, import("../context/session.js").SessionStoreError>; /** @experimental Build the Chat a run starts from, preferring an active Session over supplied history. */ export declare const initialChat: (input: { readonly sessionHistory: Option.Option; readonly suppliedHistory: Prompt.RawInput | undefined; readonly system: string | undefined; readonly supplemental?: string | undefined; }) => Effect.Effect; /** @internal Validate one resume request against the authoritative Session projection. */ declare const validateResume: (history: Prompt.Prompt, received: import("./agent-event.js").AgentSuspended) => Effect.Effect; /** @internal Helpers shared by Session-backed setup without widening the public package facade. */ export declare const SessionHistoryInternal: { validateResume: typeof validateResume; }; export declare const replayModelMessages: (input: { readonly activeSession: Option.Option; readonly sessionParentId: string; readonly system: string | undefined; readonly turn: number; readonly sessionError: (turn: number, error: import("../context/session.js").SessionStoreError) => AgentError; }) => Effect.Effect, AgentError>; /** @internal Rebuild a resume Chat from Session when no persisted Chat owns the live view. */ export declare const resumeChat: (input: { readonly persisted: Chat.Persisted | undefined; readonly activeSession: Option.Option; readonly suppliedHistory: Prompt.RawInput | undefined; }) => Effect.Effect; /** @internal Refresh a resumed Session Chat with the system message derived for this Run. */ export declare const refreshResumeSystem: (input: { readonly chat: Chat.Service | undefined; readonly activeSession: Option.Option; readonly system: string | undefined; readonly supplemental?: string | undefined; }) => Effect.Effect; /** * @experimental Reopen the delivery outbox for a recovered checkpoint. * * Checkpoint telemetry was already observed live and recorded by the host. Restoring it lets an * unacknowledged batch be retried, but re-emitting it would replay events the run log already holds * and read as a conflicting model call. */ export declare const restoreCheckpointTelemetry: (input: { readonly session: typeof SessionStore.Service; readonly undelivered: Array; }) => Effect.Effect; export {};