/** * System-Prompt slot subflow builder * * Pattern: Builder (returns a FlowChart mountable via addSubFlowChartNext). * Role: Layer-3 context engineering; inside Layer-5 primitives * (LLMCall, Agent). Ported from v1's buildSystemPromptSubflow * to InjectionRecord + SlotComposition shape. * Emits: None directly. Writes to conventional scope keys; ContextRecorder * observes and emits context.* events. * * Minimal scope for Phase 3e: static prompt string OR a dynamic function * of the input. Full SystemPromptProvider / Skill / RAG integration * arrives in Phase 5. */ import type { FlowChart } from 'footprintjs'; /** * Function that produces the system prompt string given runtime scope * context. Receives the subflow's $getArgs() payload. */ export type SystemPromptFn = (args: SystemPromptSlotArgs) => string | Promise; /** * What the slot's `$getArgs()` carries. `instructions` is present only when * the Agent's `.configure()` resolved a per-run system prompt — the mount's * inputMapper omits the key entirely otherwise, so an unconfigured agent * seeds this subflow with exactly the state it always did. */ export interface SystemPromptSlotArgs { readonly userMessage?: string; readonly iteration?: number; readonly instructions?: string; } export interface SystemPromptSlotConfig { /** Static string OR a function. Empty string → no injection, empty slot. */ readonly prompt: string | SystemPromptFn; /** Budget cap (chars). Default: 4000. Set from the public door as * `contextBudget.systemPrompt` on `AgentOptions` / `LLMCallOptions`. */ readonly budgetCap?: number; /** * Where this prompt originated, recorded on the base InjectionRecord * (e.g. `"agent.system()"`). A function when the origin depends on the * run — an Agent with `.configure()` reports `Agent.configure()` on the * runs that actually overrode the prompt and `Agent.system()` on the rest, * so the context record names the real author rather than a build-time * guess. */ readonly reason?: string | ((args: SystemPromptSlotArgs) => string); } /** * Build the System-Prompt slot subflow. * * Mount with: * builder.addSubFlowChartNext(SUBFLOW_IDS.SYSTEM_PROMPT, buildSystemPromptSlot(cfg), 'System Prompt', { * inputMapper: (parent) => ({ userMessage: parent.userMessage, iteration: parent.iteration }), * outputMapper: (sf) => ({ systemPromptInjections: sf.systemPromptInjections }), * }) */ export declare function buildSystemPromptSlot(config: SystemPromptSlotConfig): FlowChart;