import { type Message } from '../../../../types/message/index.js'; import type { IterationContext } from './context.js'; /** * Sentinel header identifying the single PINNED working-memory system message. * * The SDK finds + replaces the slot by this header every turn and uses the same * identity to re-pin it if compaction ever drops it (the OPAQUE survival guard * in `compaction.ts` — no host-format knowledge required). The host's rendered * block is stored verbatim AFTER this header; the SDK never parses it. */ export declare const WORKING_MEMORY_HEADER = "[WORKING MEMORY] Authoritative state for this conversation \u2014 you produced these."; /** * True when `content` is the pinned working-memory slot (header identity only). * Shared with `compaction.ts` so the survival guard re-pins by the SAME rule. */ export declare function isWorkingMemoryMessage(content: string | null | undefined): boolean; /** * Split the pinned slot out of a request's history. * * The slot keeps its place in the TURN's history, where compaction preserves * it. The REQUEST carries it as request-only context instead: a runtime * context message of kind `step-context`, after the history, holding the * slot's content verbatim under the same "runtime-generated; not a new user * request" label every other step-context message carries — so the header * begins the message's second line, not its first. The slot changes whenever a pin does, and a * driver that hoists system messages ahead of the conversation (one that * renders tools, then system, then messages) would otherwise invalidate the * cached conversation prefix on every such change. Every driver keeps * request-only context after history, and a caching driver ends its * breakpoint before it. * * Returns the input array unchanged, and no context, when there is no slot. */ export declare function splitWorkingMemoryForRequest(messages: readonly Message[]): { readonly history: readonly Message[]; readonly context?: Message; }; /** * Resolve the host's working-memory string and rewrite a single PINNED leading * system message in place. Insert-or-replace keyed by {@link WORKING_MEMORY_HEADER}; * an empty/blank string removes the slot. * * The slot is an EPHEMERAL system message placed as the LAST leading system * message (after the cached static + dynamic system messages), so it rides * inside the compaction-preserved leading-system run. That is its place in * the turn's HISTORY only: a request carries it as request-only context after * the history ({@link splitWorkingMemoryForRequest}), so a changed pin never * busts the cached conversation prefix. * * Failure-isolated (the `web-search` seam rule): a throwing/slow provider * degrades to "no refresh this turn" (keeps the prior slot), never breaks the * run. With no provider or tool-owned slot, the history is left unchanged. */ export declare function refreshWorkingMemory(ctx: IterationContext): Promise; //# sourceMappingURL=working-memory.d.ts.map