/** * DiagnosticianPromptBuilder — transforms DiagnosticianContextPayload into PromptInput for OpenClaw agent. * * Phase: m6-03 * Requirements: DPB-01, DPB-02, DPB-03, DPB-04, DPB-05 * * ## Output Structure (DPB-06) * * PromptInput has explicit top-level fields (taskId, contextHash, diagnosisTarget, * conversationWindow, sourceRefs) plus nested `context: DiagnosticianContextPayload`. * * (Note: monolithic DiagnosticianPromptBuilder and buildDiagnosticProtocolInstruction have been deleted per PRI-373). */ import type { DiagnosticianContextPayload, HistoryQueryEntry, DiagnosisTarget } from './context-payload.js'; import type { OutputLanguage } from './language-directive.js'; /** Options for DiagnosticianPromptBuilder.buildPrompt() beyond the required payload. */ export interface BuildPromptOptions { /** Size limits to prevent token overflow (default: DEFAULT_PROMPT_BUILDER_LIMITS) */ limits?: PromptBuilderLimits; /** Output language directive (default: none) */ outputLanguage?: OutputLanguage; /** T-E (PRI-371): Inject core axiom grounding as PHASE 3.5 (default: false) */ coreGrounding?: boolean; /** PRI-468: Inject intent tension check as PHASE 3.6 (default: false) */ intentGrounding?: boolean; /** * PRI-468: INTENT.md reference to include in the prompt payload. * * When provided (along with `intentGrounding: true`), the `raw` content * is included in the prompt as `intentDoc.raw` so the LLM can reference * it. The `contentHash` is the lineage link for `intentTension.intentDocHash`. * * When absent, the prompt is byte-identical to the pre-PRI-468 prompt. */ intentDoc?: { readonly raw: string; readonly contentHash: string; readonly path: string; }; /** * Evidence First Attribution (Pain Diagnosis Persistence SPEC §2.2/§6). * Injected only when the `pain_diagnosis_persistence` flag is on; when * absent, the prompt is byte-identical to the pre-feature prompt. */ evidenceFirstAttribution?: boolean; } /** * PromptInput — the JSON message sent to openclaw agent via --message flag. * * Per DPB-06: Explicit top-level fields make LLM's job clearer and easier to validate. * The DiagnosticianContextPayload is nested under `context` for backward compatibility. * * @see DEFAULT_LIMITS for size constraints applied during buildPrompt() */ export interface PromptInput { /** Task being diagnosed */ taskId: string; /** Hash of the context for integrity verification */ contextHash: string; /** What to diagnose (pain event, failure mode, etc.) */ diagnosisTarget: DiagnosisTarget; /** * Conversation window summary (may be truncated if too large). * Full HistoryQueryEntry[] is available in context.conversationWindow; * this field may contain a condensed version for the LLM prompt. */ conversationWindow: HistoryQueryEntry[]; /** Source references for the diagnosis */ sourceRefs: string[]; /** Full DiagnosticianContextPayload for backward compatibility */ context: DiagnosticianContextPayload; /** Warnings added during truncation (e.g., conversationWindow entries removed) */ truncationWarnings?: string[]; /** * PRI-468: Optional INTENT.md reference for Stage A intent tension check. * * Present only when `intent_engineering` flag is on AND INTENT.md was * successfully read. The `raw` content is included verbatim (unescaped) * so the LLM can use it as a stable reference for judging intent tension. * The `contentHash` is the lineage link for `intentTension.intentDocHash`. * * When absent (flag off or read failed), the prompt is byte-identical to * the pre-PRI-468 prompt (EP-03: no silent fallback). */ intentDoc?: { readonly raw: string; readonly contentHash: string; readonly path: string; }; } /** Size limits for buildPrompt() to prevent token overflow. */ export interface PromptBuilderLimits { /** Maximum number of conversation entries (default: 30) */ maxConversationEntries: number; /** Maximum characters per entry text (default: 2000) */ maxEntryTextChars: number; /** Maximum total message characters (default: 80000) */ maxMessageChars: number; } export declare const DEFAULT_PROMPT_BUILDER_LIMITS: PromptBuilderLimits; /** * Build result — the JSON string to pass as --message argument. * * Per DPB-02: Output is ONLY JSON (no markdown, no file ops, no tool calls). * Per DPB-07 (as revised by PRI-633): the builder produces the base-layer * `systemPrompt` (role + protocol); the profile's configured systemPrompt * remains the append layer owned by the agent profile, and adapters own the * per-runtime placement (system channel for pi-ai paths, message channel for * the OpenClaw CLI path). */ export interface PromptBuildResult { /** JSON string — the exact value to pass as openclaw agent --message argument */ readonly message: string; /** The PromptInput object that was serialized to JSON */ readonly promptInput: PromptInput; /** PRI-633: base-layer system prompt (role + protocol instructions). */ readonly systemPrompt: string; } /** * Summarizes a conversation window for inclusion in the prompt. * DPB-04: Prompt includes conversationWindow summary. * * Default implementation returns entries as-is. * Subclasses or configuration can provide condensation logic. */ export declare function summarizeConversationWindow(entries: HistoryQueryEntry[]): HistoryQueryEntry[]; //# sourceMappingURL=diagnostician-prompt-builder.d.ts.map