import type { AgentMiddleware } from '../create-agent.js'; import type { Workspace } from '../workspace.js'; /** Where `filesystemContext()` reads and writes: a `Workspace` or a `Sandbox`, or anything with the same file methods. */ export type FilesystemContextSource = Pick & Partial>; /** Where large tool results go instead of the transcript. */ export interface ContextOffloadOptions { /** Results longer than this, in characters, are offloaded. Defaults to 20,000. */ overChars?: number; /** The directory they are written to, inside the source. Defaults to `.context`. */ directory?: string; /** How much of a result stays in the transcript as a preview, in characters. Defaults to 1,000. */ previewChars?: number; /** Tools whose results are never offloaded. Defaults to `read_file`, so reading one back cannot loop. */ exclude?: readonly string[]; } /** Options for `filesystemContext()`. */ export interface FilesystemContextOptions { /** Where files are read from and offloaded to. */ source: FilesystemContextSource; /** * Files whose contents the model sees on every call, after the system prompt: project * instructions such as `AGENTS.md`, conventions, a glossary. A missing file is skipped. */ include?: readonly string[]; /** Lists a directory after the files, so the model knows what exists without a tool call. Needs `listFiles`. */ listing?: { directory?: string; maxEntries?: number; }; /** The most characters of included files, together. Defaults to 32,000; the rest is cut. */ maxChars?: number; /** Writes large tool results to a file and leaves a preview and the path. Needs `writeFile`. */ offload?: ContextOffloadOptions | boolean; } /** * The filesystem as the agent's context: files in, large results out. * * Instruction files reach the model on every call without a tool call, read once per run and placed * right after the system prompt, so the prefix a provider caches stays the same. A tool result too * large for the context is written to a file instead, and the model reads a preview and a path it can * open with `read_file` when it needs the rest: the transcript stays small however much a tool * returns, and nothing is lost. */ export declare function filesystemContext(options: FilesystemContextOptions): AgentMiddleware;