import { type LLMPromptConfigParams } from '../client/llmConfig.schema'; /** * A value a prompt variable may take at a call site. Numbers/booleans are * stringified during compile (matching `promptBuilder`); the union keeps the * generated `compile()` signatures ergonomic without widening to `unknown`. */ export type LLMVariableValue = string | number | boolean; export type LLMPromptKind = 'text' | 'chat'; /** * A role a chat-prompt message can carry. Mirrors the roles Langfuse chat * prompts use; the v2 client maps `system` to the provider's instructions slot * and `user`/`assistant` to the conversation, preserving the message structure * the prompt declares (plan ยง1.2 "prompt owns message structure"). */ export type LLMPromptMessageRole = 'system' | 'user' | 'assistant'; /** * One compiled chat-prompt message. `content` has had its `{{variables}}` * substituted already when it reaches a call site. */ export interface LLMPromptMessage { role: LLMPromptMessageRole; content: string; } /** * The config shape stored in the generated snapshot. `provider` is a plain * string here (not the `LLMProviders` enum) so the emitted JSON literal * type-checks without an enum cast; the runtime gate re-parses it through the * zod schema into the strict `LLMPromptConfig` before it is ever served. */ export interface LLMPromptConfigSnapshot { provider: string; model: string; params?: LLMPromptConfigParams; } /** * One prompt's build-time snapshot, emitted by `npm run langfuse:generate` into * the gitignored `langfusePrompts.generated.ts`. It is the outage fallback: the * runtime registry serves it whenever a live fetch or config validation fails. * Prompt variables are intentionally absent because their contract is owned by * application code. * * `fallbackText` is the body for a `text` prompt; `fallbackMessages` is the * role-tagged message list for a `chat` prompt. Exactly one is meaningful per * `kind`; the other is left empty so the snapshot stays a plain JSON literal. */ export interface LLMPromptSnapshotEntry { name: string; kind: LLMPromptKind; version: number; labels: string[]; fallbackText: string; fallbackMessages: LLMPromptMessage[]; config: LLMPromptConfigSnapshot; } export type LLMPromptSnapshot = Record;