import type { Carte } from "./carte.js"; import type { UIAdapter } from "./ui-adapter.js"; export type PromptFormat = "markdown" | "xml" | "plain"; export interface GeneratePromptOptions { /** * Output serialisation. Defaults to `"markdown"`. XML tends to work slightly * better with Claude for structured content; markdown is the most portable * choice for GPT-family models. */ format?: PromptFormat; /** * Append a guide that tells the LLM how to structure its response (the * `{ layout, panels: [...] }` shape, the `{ $bind: "..." }` ref syntax, * the "respond with a single JSON code block" instruction). Defaults to * `true` because without it the LLM has to guess the wrapper shape and * usually guesses wrong. Set `false` if you supply your own format * instructions or use a structured-output mode. */ includePlanFormat?: boolean; /** * Restrict the prompt to a subset of carte entries by id. Ids absent * from the carte are silently skipped. RBAC still applies — the * effective set is `only ∩ rbac_allowed`. * * Useful for two-stage flows: a first LLM call picks relevant query ids * from a compact carte summary (see `generateCompactPrompt`), and the * second call gets a full prompt restricted to those ids. */ only?: ReadonlyArray; } export interface GenerateCompactPromptOptions { /** * Output serialisation. Defaults to `"markdown"`. Markdown is the natural * fit; xml and plain are provided for consistency with `generatePrompt`. */ format?: PromptFormat; } /** * Serialises the carte and UI carte into a system-prompt fragment the LLM * can reason about. Carte entries are filtered by `access(ctx)` *before* * serialisation, so the LLM only sees entries the current context may use. * * The prompt text is the framework's interface to the model — keep it stable. */ export declare function generatePrompt(carte: Carte, uiAdapter: UIAdapter, ctx: TCtx, options?: GeneratePromptOptions): Promise; /** * Generates a compact one-line-per-entry carte summary for use as a * first-stage LLM call that selects relevant entries before full prompt * generation. The output framing instructs the model to return ONLY a JSON * array of query ids. * * Carte entries are filtered by `access(ctx)` before serialisation, same * as `generatePrompt`. Entries that have an `access` predicate (and pass it * for the current context) are tagged `[restricted]` so the caller knows the * list shape may differ across roles. * * Components aren't part of the compact prompt — the first stage selects * queries; the second-stage `generatePrompt({ only })` handles components. * * @example * // Stage 1: identify relevant entries * const compact = await generateCompactPrompt(carte, ctx); * const ids = JSON.parse(await callLLM(compact + "\n\nUser: " + userMessage)); * * // Stage 2: full prompt for just those entries * const full = await generatePrompt(carte, uiAdapter, ctx, { only: ids }); * const plan = JSON.parse(await callLLM(full + "\n\nUser: " + userMessage)); * * // Validate and execute as normal * const parsed = parsePlan(plan, carte, uiAdapter, ctx); * const results = parsed.ok ? await executePlan(parsed.plan, carte) : []; */ export declare function generateCompactPrompt(carte: Carte, ctx: unknown, options?: GenerateCompactPromptOptions): Promise; //# sourceMappingURL=prompt.d.ts.map