Function: definePrompt()
Call Signature
ts
function definePrompt<TContext, S>(name, config): PromptBuilder<TContext>;Defined in: packages/core/src/prompt/definePrompt.ts:187
Overload 1: Zod schema — full type inference via z.infer<>
typescript
definePrompt<AppContext>('audit', {
args: z.object({ month: z.string(), strict: z.boolean() }),
handler: async (ctx, { month, strict }) => { ... }
// ^^^^^ ^^^^^^ ← fully typed!
});Type Parameters
| Type Parameter | Default type |
|---|---|
TContext | void |
S extends ZodRawShape | ZodRawShape |
Parameters
| Parameter | Type |
|---|---|
name | string |
config | PromptConfigBase<TContext> & { args: ZodObject<S>; handler: (ctx, args) => Promise<PromptResult>; } |
Returns
PromptBuilder<TContext>
Call Signature
ts
function definePrompt<TContext, T>(name, config): PromptBuilder<TContext>;Defined in: packages/core/src/prompt/definePrompt.ts:211
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 conston the args object for full literal type inference.
Type Parameters
| Type Parameter | Default type |
|---|---|
TContext | void |
T extends Record<string, PromptParamDef> | Record<string, PromptParamDef> |
Parameters
| Parameter | Type |
|---|---|
name | string |
config | PromptConfigBase<TContext> & { args: T; handler: (ctx, args) => Promise<PromptResult>; } |
Returns
PromptBuilder<TContext>