Interface: AskFunction()
Defined in: packages/core/src/core/elicitation/ask.ts:99
The ask type — both a callable function and a namespace.
This interface describes the shape of the ask export. TypeScript sees it as (message, fields) => Promise<AskResponse> with static methods .string(), .number(), .boolean(), .enum(), .redirect().
AskFunction<T>(message, fields): Promise<AskResponse<InferAskFields<T>>>;Defined in: packages/core/src/core/elicitation/ask.ts:121
Ask the user for structured input via a client-rendered form.
Fields are defined with ask.* descriptors — no raw JSON Schema. Return type is fully inferred from the field descriptors.
Type Parameters
| Type Parameter |
|---|
T extends Record<string, AskField<any>> |
Parameters
| Parameter | Type | Description |
|---|---|---|
message | string | Human-readable prompt shown to the user |
fields | T | Object of ask.* field descriptors |
Returns
Promise<AskResponse<InferAskFields<T>>>
AskResponse<T> with .accepted, .declined, .data
Throws
when called outside .interactive() context
Example
const prefs = await ask('Configure your account:', {
name: ask.string('Display name'),
plan: ask.enum(['free', 'pro'] as const, 'Plan'),
});Methods
boolean()
boolean(description?): AskBooleanField;Defined in: packages/core/src/core/elicitation/ask.ts:154
Create a boolean field descriptor.
Parameters
| Parameter | Type | Description |
|---|---|---|
description? | string | Human-readable label |
Returns
AskBooleanField for chaining
Example
`ask.boolean('Accept terms').default(true)`enum()
enum<V>(values, description?): AskEnumField<V>;Defined in: packages/core/src/core/elicitation/ask.ts:165
Create an enum field descriptor with type-safe literal union inference.
Type Parameters
| Type Parameter |
|---|
V extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
values | readonly [V, V] | Allowed values (as const for literal types) |
description? | string | Human-readable label |
Returns
AskEnumField<V>
AskEnumField<V> for chaining
Example
`ask.enum(['us-east-1', 'eu-west-1'] as const, 'Region')`number()
number(description?): AskNumberField;Defined in: packages/core/src/core/elicitation/ask.ts:144
Create a number field descriptor.
Parameters
| Parameter | Type | Description |
|---|---|---|
description? | string | Human-readable label |
Returns
AskNumberField with .min(), .max() chainable
Example
`ask.number('Team size').min(1).max(500)`redirect()
redirect(message, url): Promise<AskResponse<void>>;Defined in: packages/core/src/core/elicitation/ask.ts:184
Redirect the user to an external URL (OAuth, payment, credentials).
Use for sensitive operations that MUST NOT be handled via form fields.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | string | Explanation of why the redirect is needed |
url | string | The URL to open in the user's browser |
Returns
Promise<AskResponse<void>>
AskResponse<void> with .accepted / .declined
Throws
when called outside .interactive() context
Example
const auth = await ask.redirect('Authenticate with GitHub:', oauthUrl);
if (auth.declined) return f.error('CANCELLED', 'Auth cancelled');string()
string(description?): AskStringField;Defined in: packages/core/src/core/elicitation/ask.ts:134
Create a string field descriptor.
Parameters
| Parameter | Type | Description |
|---|---|---|
description? | string | Human-readable label |
Returns
AskStringField for chaining
Example
`ask.string('Your full name')`