/** * PromptBuilderImpl — Internal Prompt Builder Implementation * * Implements the {@link PromptBuilder} interface for use by * `definePrompt()` and `PromptRegistry`. * * Responsibilities: * - Stores prompt metadata (name, description, tags, middleware) * - Compiles Zod schema from ParamsMap (or uses raw Zod) * - Validates flat schema constraint at construction time * - Builds MCP Prompt definition for `prompts/list` * - Delegates hydration to `PromptExecutionPipeline` * * @internal * @module */ import { type ZodObject, type ZodRawShape } from 'zod'; import { type PromptBuilder, type PromptResult, type PromptParamDef, type InferPromptArgs, type LoopbackContext } from './types.js'; import { type MiddlewareFn } from '../core/types.js'; export declare class PromptBuilderImpl implements PromptBuilder { private readonly _name; private readonly _title; private readonly _description; private readonly _icons; private readonly _tags; private readonly _middlewares; private readonly _schema; private readonly _handler; private readonly _hydrationTimeout; constructor(name: string, config: { title?: string; description?: string; icons?: { light?: string; dark?: string; }; tags?: string[]; middleware?: MiddlewareFn[]; schema?: ZodObject; handler: (ctx: TContext & LoopbackContext, args: Record) => Promise; hydrationTimeout?: number; }); getName(): string; getDescription(): string | undefined; getTags(): string[]; hasMiddleware(): boolean; getHydrationTimeout(): number | undefined; buildPromptDefinition(): { name: string; title?: string; description?: string; icons?: { light?: string; dark?: string; }; arguments?: Array<{ name: string; description?: string; required?: boolean; }>; }; execute(ctx: TContext, args: Record): Promise; } interface PromptConfigBase { title?: string; description?: string; icons?: { light?: string; dark?: string; }; tags?: string[]; middleware?: MiddlewareFn[]; hydrationTimeout?: number; } /** * Overload 1: Zod schema — full type inference via `z.infer<>` * * ```typescript * definePrompt('audit', { * args: z.object({ month: z.string(), strict: z.boolean() }), * handler: async (ctx, { month, strict }) => { ... } * // ^^^^^ ^^^^^^ ← fully typed! * }); * ``` */ export declare function definePrompt(name: string, config: PromptConfigBase & { args: ZodObject; handler: (ctx: TContext, args: ZodObject["_output"]) => Promise; }): PromptBuilder; /** * Overload 2: JSON-first descriptors — type inference via `InferPromptArgs<>` * * ```typescript * definePrompt('greet', { * args: { * name: { type: 'string', required: true }, * age: 'number', * } as const, * handler: async (ctx, { name, age }) => { ... } * // ^^^^ ^^^ ← name: string, age: number! * }); * ``` * * > 💡 Use `as const` on the args object for full literal type inference. */ export declare function definePrompt = Record>(name: string, config: PromptConfigBase & { args: T; handler: (ctx: TContext, args: InferPromptArgs) => Promise; }): PromptBuilder; export {}; //# sourceMappingURL=definePrompt.d.ts.map