/** * Agent Call Context * * Assembles the complete system-message set for one provider call. Every * caller that talks to a model, the hosted cloud runtime, the project * runtime's internal agent runs, and the `agent()` factory, gathers its own * inputs and hands them here, so ordering, block tags, marker splitting, * deduplication, and skill rendering live in exactly one place. * * The module is pure: it performs no I/O and reads no ambient state. Callers * resolve instructions, project facts, skills, and environment facts, then * describe them; the module decides how they are laid out. * * Layout of the returned messages: * * 1. One cached system message holding only the instructions before the * runtime-context marker (or all instructions when the marker is absent). * 2. One optional uncached system message holding, in order, * ``, ``, any caller-supplied extra * blocks, `` or an `` * fallback, ``, and the instructions after the marker. * * Only the instructions are unconditional: each block appears only when the * caller supplied its input and the instructions do not already carry that tag * as a complete element, so message 2 can be absent and message 1 can be the * instructions alone. Callers compose in layers: the factory's output is later * re-composed by a project-runtime run, and skipping already-present elements * keeps that idempotent instead of repeating a project reference or catalog. * * @module */ import type { ChatSystemMessage } from "../../chat/types.js"; import type { AgentSystem } from "../types.js"; import type { RuntimeSkillDefinition } from "./skill-metadata.js"; /** Marker authored instructions use to place runtime blocks mid-prompt. */ export declare const DEFAULT_RUNTIME_AGENT_CONTEXT_MARKER = ""; /** Project the call runs against, rendered as the `` block. */ export type AgentCallProjectContext = { projectId: string; branchId?: string | null; }; /** Input payload for build agent call context. */ export type BuildAgentCallContextInput = { /** Agent instructions, optionally split by the runtime-context marker. */ instructions: AgentSystem; /** Marker that places runtime blocks mid-prompt. Defaults to the shared marker. */ runtimeContextMarker?: string; /** Steering text the host requires the agent to follow. */ projectInstructions?: string; /** Project reference and branch the run is scoped to. */ projectContext?: AgentCallProjectContext; /** Pre-rendered blocks appended after the project blocks (e.g. ``). */ extraBlocks?: readonly string[]; /** Skills the agent may load during the call. */ skills?: readonly RuntimeSkillDefinition[]; /** Host-supplied environment facts. */ environmentContext?: string; /** * Prompt-cache TTL for the static (Layer 0) system message. `"5m"` (default) * keeps the standard ephemeral breakpoint; `"1h"` extends it for interactive * multi-turn sessions. Gate this at the call site. Only set `"1h"` during * interactive run rendering where a second read is likely. Structured prompts * keep their latest four Anthropic breakpoints when the final breakpoint is * added. See RFC 0001. */ cacheTtl?: AgentCallCacheTtl; /** * Active Anthropic provider alias whose structured cache metadata participates * in TTL normalization. Defaults to the built-in `veryfront-cloud` alias. */ anthropicProviderAlias?: string; }; /** Supported prompt-cache TTLs for the cached static system message. */ export type AgentCallCacheTtl = "5m" | "1h"; /** Builds the shared project-context prompt block (project reference + branch). */ export declare function buildProjectContextPromptBlock(input: AgentCallProjectContext): string; /** Builds the project-instructions prompt block. */ export declare function buildProjectInstructionsPromptBlock(instructions: string): string; /** * Builds the layered system-message set for one provider call (RFC 0001). * * Layer 0 (cached, shared across runs): the agent prompt only, with nothing * project- or turn-specific. Its `cacheControl` breakpoint is the sole shared * cache key, so it must be byte-identical across projects. * * Dynamic tail (uncached): project context/instructions, extra blocks, the * skills catalog, and host environment facts. This includes everything that varies by * project, session, or turn. Kept out of the cached prefix so a fresh project * or session still reads the shared Layer 0 instead of paying full price. */ export declare function buildAgentCallContext(input: BuildAgentCallContextInput): ChatSystemMessage[]; /** Keeps the marker so another internal context composer can consume it. */ export declare function buildAgentCallContextPreservingRuntimeMarker(input: BuildAgentCallContextInput): ChatSystemMessage[]; //# sourceMappingURL=call-context.d.ts.map