/** * FluentPromptBuilder — Chainable Prompt Definition API * * Provides a builder-pattern alternative to the config-bag `definePrompt()`. * Follows the same architectural pattern as `FluentToolBuilder`. * * @example * ```typescript * const greet = f.prompt('greet') * .describe('Greet a user by name') * .input({ name: f.string() }) * .handler(async (ctx, { name }) => ({ * messages: [PromptMessage.user(`Hello ${name}!`)], * })); * ``` * * @module */ import { type ZodObject, type ZodRawShape } from 'zod'; import { type PromptBuilder, type PromptResult, type PromptParamsMap, type LoopbackContext } from './types.js'; import { type MiddlewareFn } from '../core/types.js'; /** * Chainable builder for MCP Prompts. * * Each setter returns `this` for chaining. Finalisation happens lazily * when the `PromptBuilder` interface methods are accessed — this means * you can pass a `FluentPromptBuilder` directly to `PromptRegistry.register()`. * * @typeParam TContext - Application context type (inherited from `initFusion`) * @typeParam TArgs - Inferred argument type from the schema */ export declare class FluentPromptBuilder = Record> implements PromptBuilder { private readonly _name; private _title?; private _description?; private _icons?; private _tags; private _middlewares; private _args?; private _hydrationTimeout?; private _handler?; /** @internal Cached delegate built on first access to PromptBuilder methods */ private _delegate; constructor(name: string); /** * Set a human-readable title for UI display. * * @param title - The prompt title * @returns `this` for chaining */ title(title: string): this; /** * Set the prompt description shown in the slash command palette. * * @param description - Human-readable description * @returns `this` for chaining */ describe(description: string): this; /** * Set icons for light/dark themes. * * @param icons - Icon paths for light and/or dark themes * @returns `this` for chaining */ icons(icons: { light?: string; dark?: string; }): this; /** * Set capability tags for selective exposure. * * @param tags - Tag strings for filtering * @returns `this` for chaining */ tags(...tags: string[]): this; /** * Define the input schema for prompt arguments. * * Accepts the same formats as `FluentToolBuilder.input()`: * - Fluent param descriptors (`f.string()`, `f.number()`, etc.) — zero imports * - Zod schema for power users * * @returns `this` for chaining * * @example * ```typescript * // Fluent descriptors (recommended — zero Zod imports) * f.prompt('greet') * .input({ name: f.string(), age: f.number().optional() }) * .handler(async (ctx, { name, age }) => ({ ... })); * * // Zod schema (advanced) * f.prompt('search') * .input(z.object({ query: z.string().min(1) })) * .handler(async (ctx, { query }) => ({ ... })); * ``` */ input(schema: ZodObject): FluentPromptBuilder['_output']>; input(params: PromptParamsMap): this; /** * Add middleware to the prompt's execution pipeline. * * Middleware runs in registration order around the handler * (same onion model as tool middleware). * * @param fns - Middleware functions * @returns `this` for chaining */ use(...fns: MiddlewareFn[]): this; /** * Set the maximum hydration time in milliseconds. * * If the handler doesn't complete within this time, * the framework returns a graceful SYSTEM ALERT. * * @param ms - Timeout in milliseconds * @returns `this` for chaining */ timeout(ms: number): this; /** * Set the hydration handler. * * This is the terminal method — after calling `.handler()`, * the builder is ready to be registered. * * @param fn - Handler function receiving `(ctx, args)` → `PromptResult` * @returns `this` for chaining * * @example * ```typescript * .handler(async (ctx, { name }) => ({ * messages: [PromptMessage.user(`Hello ${name}!`)], * })) * ``` */ handler(fn: (ctx: TContext & LoopbackContext, args: TArgs) => Promise): this; /** @internal Build the underlying PromptBuilder delegate lazily */ private _build; getName(): string; getDescription(): string | undefined; getTags(): string[]; hasMiddleware(): boolean; getHydrationTimeout(): number | undefined; buildPromptDefinition(): { name: string; description?: string; arguments?: Array<{ name: string; description?: string; required?: boolean; }>; }; execute(ctx: TContext, args: Record): Promise; } //# sourceMappingURL=FluentPromptBuilder.d.ts.map