(
prompts: PromptIO,
allModels: string[],
)
| 100 | * the dreamer is enabled. |
| 101 | */ |
| 102 | export async function runDreamerSetup( |
| 103 | prompts: PromptIO, |
| 104 | allModels: string[], |
| 105 | ): Promise<DreamerSetupResult> { |
| 106 | const model = await pickModel(prompts, allModels, "dreamer"); |
| 107 | prompts.log.success(`Dreamer model: ${model}`); |
| 108 | |
| 109 | const useDefaults = await prompts.confirm( |
| 110 | "Use recommended task schedules? (verify nightly; curate weekly; classify + retrospective daily; docs off)", |
| 111 | true, |
| 112 | ); |
| 113 | if (useDefaults) { |
| 114 | return { model }; |
| 115 | } |
| 116 | |
| 117 | const tasks: Record<string, { schedule: string }> = {}; |
| 118 | for (const task of CANONICAL_DREAM_TASKS) { |
| 119 | prompts.note(TASK_DESCRIPTIONS[task], task); |
| 120 | const choice = await prompts.selectOne( |
| 121 | `Schedule for "${task}"`, |
| 122 | scheduleOptions(DEFAULT_TASK_SCHEDULES[task]), |
| 123 | ); |
| 124 | let schedule: string; |
| 125 | if (choice === PRESET_CUSTOM) { |
| 126 | schedule = ( |
| 127 | await prompts.text("Enter a 5-field cron expression (empty to disable)", { |
| 128 | placeholder: "0 3 * * *", |
| 129 | validate: (value) => { |
| 130 | const v = value.trim(); |
| 131 | if (v === "") return undefined; // empty = disabled |
| 132 | return isValidCron(v) |
| 133 | ? undefined |
| 134 | : 'Invalid cron. Use 5 fields, e.g. "0 3 * * *".'; |
| 135 | }, |
| 136 | }) |
| 137 | ).trim(); |
| 138 | } else { |
| 139 | // value is "cron:<expr>" |
| 140 | schedule = choice.slice("cron:".length); |
| 141 | } |
| 142 | tasks[task] = { schedule }; |
| 143 | prompts.log.success(`${task}: ${schedule === "" ? "disabled" : schedule}`); |
| 144 | } |
| 145 | return { model, tasks }; |
| 146 | } |
no test coverage detected