/** * Fetch options for one live prompt read. Label and version are mutually * exclusive, mirroring `@mate-academy/prompt-client`'s `GetPromptOptions` / * `GetChatPromptOptions` shape so an implementation of `LLMGatewayPromptClient` * needs no adapter to satisfy this port structurally. The port never sets * prompt-client's `fallback` option: the gateway's own build-time snapshot is * the outage fallback, so a live-fetch fallback would be redundant. */ export interface LLMPromptFetchByLabelOptions { label?: string; version?: never; cacheTtlSeconds?: number; } export interface LLMPromptFetchByVersionOptions { version?: number; label?: never; cacheTtlSeconds?: number; } export type LLMPromptFetchOptions = LLMPromptFetchByLabelOptions | LLMPromptFetchByVersionOptions; /** * A live-fetched text prompt, shaped to match `@mate-academy/prompt-client`'s * `LLMPrompt` field-for-field (`prompt`, not `text`) so a prompt-client * instance satisfies `LLMGatewayPromptClient` without any adapter. */ export interface LLMFetchedTextPrompt { prompt: string; config: unknown; version: number; isFallback: boolean; } /** * `role` is a plain `string`, not a closed enum: this is an open port meant to * match any provider's message shape, not a gateway-owned closed set. A * provider's own enum-typed role (e.g. prompt-client's `LLMPromptMessageRoles`) * is assignable to `string`, so it satisfies this port; it would not be * assignable to a fresh string-literal union. */ export interface LLMFetchedChatMessage { role: string; content: string; } export interface LLMFetchedChatPrompt { messages: LLMFetchedChatMessage[]; config: unknown; version: number; isFallback: boolean; } /** * The runtime prompt port the gateway client depends on instead of a * Langfuse SDK client. `@mate-academy/prompt-client`'s `LLMPromptClient` * satisfies this structurally (its extra `listPrompts`/`getPromptRecord`/ * `shutdown` methods are simply unused here), so wiring it in at the * composition root needs no adapter layer. An implementation that throws on * failure is expected and handled: the runtime catches every rejection and * falls back to the build-time snapshot. */ export interface LLMGatewayPromptClient { getPrompt(name: string, options?: LLMPromptFetchOptions): Promise; getChatPrompt(name: string, options?: LLMPromptFetchOptions): Promise; }