import { Context, Effect, Layer, Option, Schema } from "effect"; import { LanguageModel, Prompt } from "effect/unstable/ai"; import { type Entry } from "../context/session.js"; /** @experimental Default headroom kept for the next model response. */ export declare const DEFAULT_RESERVE_TOKENS = 16384; /** @experimental Default recent-session suffix target kept verbatim. */ export declare const DEFAULT_KEEP_RECENT_TOKENS = 20000; /** @experimental Fixed prompt used for dedicated summary calls. */ export declare const SUMMARY_TEMPLATE = "Summarize the conversation so another agent can continue seamlessly.\n\nUse Markdown with these sections:\n\n## Goal\n## Constraints\n## Progress\n### Done\n### In Progress\n### Blocked\n## Key Decisions\n## Next Steps\n## Critical Context\n\nDo not mention that context was compacted."; /** @experimental Structured checkpoint schema used by structuredSummary. */ export declare const AgentSummary: Schema.Struct<{ readonly goal: Schema.String; readonly facts: Schema.$Array; readonly decisions: Schema.$Array; readonly openQuestions: Schema.$Array; readonly toolFindings: Schema.$Array; }>; /** @experimental */ export type AgentSummary = typeof AgentSummary.Type; /** @experimental Token accounting for a compaction decision. */ export interface Usage { readonly contextTokens: number; readonly contextWindow: number; readonly reserveTokens: number; } /** @experimental What to keep verbatim and what the summary replaces. */ export interface Plan { readonly head: ReadonlyArray; readonly recent: ReadonlyArray; } /** @experimental Request passed to a compaction implementation. */ export interface Request { readonly compactionId: string; readonly agentName: string; readonly sessionId: string; readonly turn: number; readonly history: Prompt.Prompt; readonly prompt: Prompt.Prompt; readonly path?: ReadonlyArray; readonly usage: Usage; readonly overflow: boolean; readonly toolOutputMaxBytes?: number; } /** @experimental Wrap custom work after deciding to run; changed results must use this to join their lifecycle. */ export declare const withLifecycle: (request: Request) => (work: Effect.Effect, E, R>) => Effect.Effect, E, R>; /** @experimental Result from tool-output microcompaction. */ export interface MicrocompactResult { readonly _tag: "Microcompact"; readonly history: Prompt.Prompt; readonly prompt: Prompt.Prompt; } /** @experimental Result from summary checkpointing. */ export interface SummarizeResult { readonly _tag: "Summarize"; readonly history: Prompt.Prompt; readonly prompt: Prompt.Prompt; readonly summary: string; } /** @experimental Compaction result applied by the agent loop. */ export type Result = MicrocompactResult | SummarizeResult; /** @experimental Compaction strategy: decide, cut, summarize. */ export interface Strategy { readonly shouldCompact: (usage: Usage) => boolean; readonly cut: (entries: ReadonlyArray, keepRecentTokens: number) => Option.Option; readonly summarize: (plan: Plan, request: Request) => Effect.Effect; readonly toolOutputMaxBytes?: number; readonly keepRecentTokens?: number; } /** @experimental One independently composable compaction capability. */ export interface StrategyPart { readonly shouldCompact?: Strategy["shouldCompact"]; readonly cut?: Strategy["cut"]; readonly summarize?: Strategy["summarize"]; readonly toolOutputMaxBytes?: number; readonly keepRecentTokens?: number; } /** @experimental Compaction service boundary consulted by the loop. */ export interface Interface { readonly willCompact?: (input: { readonly usage: Usage; readonly overflow: boolean; }) => boolean; readonly maybeCompact: (request: Request) => Effect.Effect, CompactionError, LanguageModel.LanguageModel>; } declare const CompactionError_base: Schema.Class; }>, import("effect/Cause").YieldableError>; /** @experimental Compaction service failure. */ export declare class CompactionError extends CompactionError_base { } declare const Compaction_base: Context.ServiceClass; /** @experimental */ export declare class Compaction extends Compaction_base { } /** @experimental Options for the default compaction implementation. */ export interface DefaultOptions { readonly reserveTokens?: number; readonly keepRecentTokens?: number; readonly contextWindow?: number; readonly summaryModel?: Layer.Layer; readonly summaryPrompt?: string; } /** @experimental Options accepted by the Compaction layer. */ export interface LayerOptions extends DefaultOptions { readonly strategy?: Strategy; } /** @experimental Options for lossless tool-output bounding. */ export interface ToolOutputBoundOptions { readonly maxBytes: number; } /** @experimental Options for token-denominated recent retention. */ export interface KeepRecentOptions { readonly tokens: number; } /** @experimental Options for schema-validated structured summaries. */ export interface StructuredSummaryOptions { readonly objectName?: string; readonly summaryModel?: Layer.Layer; readonly summaryPrompt?: string; } /** @experimental The default two-stage compaction strategy. */ export declare const defaultStrategy: (options?: DefaultOptions) => Strategy; /** @experimental Compile ordered strategy parts onto a complete strategy. */ export declare const strategy: { (base?: Strategy): (parts: ReadonlyArray) => Strategy; (parts: ReadonlyArray, base?: Strategy): Strategy; }; /** @experimental Configure lossless successful-tool-result bounding. */ export declare const toolOutputBound: (options: ToolOutputBoundOptions) => StrategyPart; /** @experimental Configure the token target retained verbatim after a summary cut. */ export declare const keepRecent: (options: KeepRecentOptions) => StrategyPart; /** @experimental Summarize through Effect AI structured output and render a string checkpoint. */ export declare const structuredSummary: (options?: StructuredSummaryOptions) => StrategyPart; /** @experimental Build a compaction service from a strategy. */ export declare const make: { (options?: DefaultOptions): (compactionStrategy: Strategy) => Interface; (compactionStrategy: Strategy, options?: DefaultOptions): Interface; }; /** @experimental Layer wiring the default or provided strategy. */ export declare const layer: { (providedStrategy?: Strategy): (options?: LayerOptions) => Layer.Layer; (options?: LayerOptions, providedStrategy?: Strategy): Layer.Layer; }; /** @experimental Truncate-only compaction over `Tokenizer`. */ export declare const truncate: (maxTokens: number) => Interface; /** @experimental */ export declare const layerTest: (implementation: Interface) => Layer.Layer; export {};