/** * Session system-prompt construction. * * Extracted verbatim from agent-session.ts (god-file decomposition). Owns the assembly of the * session's base system prompt from live session state — the active profile's situational soul, the * self-modification and autonomy guardrail blocks, the memory block, the loader's custom/append * prompts, and the per-tool snippet/guideline surface — into the {@link BuildSystemPromptOptions} * that the pure {@link buildSystemPrompt} renderer (core/system-prompt.ts, a different job: the * stateless string builder) consumes. Holds the last-built `_baseSystemPromptOptions` so a * before_agent_start extension hook can read it. Takes narrow accessor deps (each read fresh, since * several collaborators — tool registries, memory manager, extension runner — are reassigned across * the session lifecycle) rather than the whole AgentSession. */ import type { Extension } from "./extensions/types.ts"; import type { MemoryManager } from "./memory/memory-manager.ts"; import { type ModelCapabilityProfile } from "./model-capability.ts"; import type { ModelAdaptationRule } from "./models/adaptation-store.ts"; import type { ResourceLoader } from "./resource-loader.ts"; import type { SettingsManager } from "./settings-manager.ts"; import { type BuildSystemPromptOptions } from "./system-prompt.ts"; import { type ToolSelectionHint } from "./tool-selection/promotion.ts"; export interface SystemPromptBuilderDeps { /** The session's working directory (read fresh; base for self-modification source resolution). */ getCwd(): string; /** The session's settings manager — soul, self-modification, autonomy, and auto-learn settings. */ getSettingsManager(): SettingsManager; /** The session's resource loader — custom/append system prompts and agents files. */ getResourceLoader(): ResourceLoader; /** The session's memory manager — the static, frozen-per-session memory system-prompt block. */ getMemoryManager(): MemoryManager; /** Whether a tool name is currently registered on the session. */ hasTool(name: string): boolean; /** The one-line prompt snippet registered for a tool, if any. */ getToolPromptSnippet(name: string): string | undefined; /** The extra guideline bullets registered for a tool, if any. */ getToolPromptGuidelines(name: string): string[] | undefined; /** The standing tool-shape rules learned for the session's current model. */ getModelAdaptationRules(): readonly ModelAdaptationRule[]; /** * The evidence-gated tool-selection hints active for the session's current model (see * `tool-selection/promotion.ts` and `ToolSelectionController.getActiveHints`). Optional: a * session that has not wired a `ToolSelectionController` into this builder simply renders no * hint block, same as an empty list. Changes RARELY (only when the underlying evidence flips * which tool is promoted for an intent) — never per turn — so it does not threaten the * single-cached-system-prompt-block invariant (see system-prompt.ts). */ getToolSelectionHints?(): readonly ToolSelectionHint[]; /** The session's currently active extensions. */ getActiveExtensions(): ReadonlyArray; /** The authoritative profile used by tools, lanes, and stable prompt shaping. */ getModelCapabilityProfile(): ModelCapabilityProfile; /** Child/worker sessions never receive root autonomy or reflection instructions. */ isChildSession(): boolean; } export declare function collectSelfModificationSourceCandidates(settings: { sourcePath?: string; sourcePaths?: string[]; }): string[]; export declare class SystemPromptBuilder { private readonly deps; private _baseSystemPromptOptions; constructor(deps: SystemPromptBuilderDeps); /** The options used to render the last base prompt — read by a before_agent_start extension hook. */ getBaseSystemPromptOptions(): BuildSystemPromptOptions; /** Recheck the final prompt after extension and routed-turn overrides, immediately before use. */ enforceSystemPromptBudget(systemPrompt: string): string; normalizePromptSnippet(text: string | undefined): string | undefined; normalizePromptGuidelines(guidelines: string[] | undefined): string[]; /** * R6: the active profile's situational soul, wrapped so the model reads it as its identity for this * situation. Empty when no active profile defines a soul. */ private _buildSituationSoulPrompt; private _buildSelfModificationPrompt; private _buildStaticMemoryPrompt; private _buildModelAdaptationPrompt; /** The evidence-gated tool-selection hint block (see `getToolSelectionHints` on the deps). */ private _buildToolSelectionHintPrompt; private _buildToolApplicabilityPrompt; private _buildAutonomyPrompt; private _buildWorkLifecyclePrompt; private _buildDelegationPrompt; private _buildSystemPromptOptionsForToolNames; rebuildSystemPrompt(toolNames: string[]): string; /** * Build a system prompt for a specific tool surface WITHOUT touching the session's base prompt * state. Used for a router-swapped turn (G4): the routed model runs against a filtered tool set, * so it must also receive a system prompt whose tool guidelines/snippets match that filtered * surface — but the change is per-turn, so it must not mutate `_baseSystemPromptOptions` (which * later turns and extension events read). */ buildSystemPromptForToolNames(toolNames: string[]): string; } //# sourceMappingURL=system-prompt-builder.d.ts.map