Files
clawdbot/src/wizard/prompts.ts
2026-01-03 16:48:08 +01:00

53 lines
1.3 KiB
TypeScript

export type WizardSelectOption<T = string> = {
value: T;
label: string;
hint?: string;
};
export type WizardSelectParams<T = string> = {
message: string;
options: Array<WizardSelectOption<T>>;
initialValue?: T;
};
export type WizardMultiSelectParams<T = string> = {
message: string;
options: Array<WizardSelectOption<T>>;
initialValues?: T[];
};
export type WizardTextParams = {
message: string;
initialValue?: string;
placeholder?: string;
validate?: (value: string) => string | undefined;
};
export type WizardConfirmParams = {
message: string;
initialValue?: boolean;
};
export type WizardProgress = {
update: (message: string) => void;
stop: (message?: string) => void;
};
export type WizardPrompter = {
intro: (title: string) => Promise<void>;
outro: (message: string) => Promise<void>;
note: (message: string, title?: string) => Promise<void>;
select: <T>(params: WizardSelectParams<T>) => Promise<T>;
multiselect: <T>(params: WizardMultiSelectParams<T>) => Promise<T[]>;
text: (params: WizardTextParams) => Promise<string>;
confirm: (params: WizardConfirmParams) => Promise<boolean>;
progress: (label: string) => WizardProgress;
};
export class WizardCancelledError extends Error {
constructor(message = "wizard cancelled") {
super(message);
this.name = "WizardCancelledError";
}
}