@sema-agent/core
Version:
Stateless, task-oriented AI agent core
52 lines (51 loc) • 2.84 kB
TypeScript
import type { AgentTool } from "../internal/harness-types.js";
import { type PromptProvider, type PromptTextDeclaration } from "../prompts/default.js";
import type { CompiledSection, CompiledSystemBlock, PromptRuntimeFacts } from "./types.js";
export interface AssembleInputs {
provider: PromptProvider;
/** True when the provider is the built-in defaultPromptProvider (checked FIRST — its stableSystem
* output contains the constitution anchors and would misroute through the M9 guard). */
isDefaultProvider: boolean;
userSystemPrompt?: string;
userAppendSystemPrompt?: string;
tools: AgentTool[];
facts: PromptRuntimeFacts;
mcpInstructionsBlock?: string;
memoryBlock?: string;
/** Renders the environment tail for a given date (leg-frozen; date_change re-render seam). */
buildEnvBlock: (date: string) => string | undefined;
/** The leg's frozen date — the initial render input (design/66 date_change). */
date: string;
modelGuidance?: string;
/** design/148 S1 — declarations compiled from a VERIFIED center prompt artifact (the adoption
* channel: core verifies the artifact, synthesizes these, and they ride the same mount loop as
* provider stableBlocks — same manifest/epoch/contentHash faces, zero new assembly machinery).
* Mounted ahead of provider declarations on every COMPOSED path; the provider-assembled
* pass-through path cannot mount them (operator-visible warn, never silent). */
centerDeclarations?: PromptTextDeclaration[];
/** Structured warning channel (maps to deps.onError with a phase). */
onWarn?: (message: string, phase: "prompt-constitution") => void;
}
export interface AssembledPrompt {
constitution: "core" | "replaced" | "provider-assembled";
/** design/148 S1: true ⇔ the supplied centerDeclarations were actually COMPILED into
* this prompt. The caller must never persist a center pin when this is false — a pin that claims
* an artifact the model never received is a durable lie (the assembled-identity pass-through path
* warns + false). */
centerMounted?: boolean;
/** Re-render the full prompt for a date. */
renderWithDate?: (date: string) => string;
/** The initially-rendered system prompt. */
systemPrompt: string;
/** The `prompt.assembled` block view (the id wordlist is a downstream contract). */
blocks: Array<{
id: string;
text: string;
}>;
/** Compiled IR of the last render — manifest v2 source. */
sections?: CompiledSection[];
/** S4: physical system blocks of the last render (sema-default: ONE block, text === systemPrompt —
* byte-identity). */
systemBlocks?: CompiledSystemBlock[];
}
export declare function assemblePrompt(inputs: AssembleInputs): AssembledPrompt;