import { getCliClient } from '../cli-client.js' import { waitForGeneration } from '../generate.js' import { generationRunningResult } from '../output.js' import { finishGeneration, startSpinner } from './generate.js' export interface GenerateInstallCommandOptions { cwd?: string baseUrl?: string } // Install the asset from a generation job. Block-and-polls for a bounded window (the command waits, // not the agent): installs on completion, fails loudly on error, or prints a note so the caller runs // it again to continue the same job. export async function generateInstallCommand( jobId: string, opts: GenerateInstallCommandOptions, ): Promise { const { client } = await getCliClient({ baseUrl: opts.baseUrl, requireAuth: true, }) const spinner = startSpinner('Generating asset') const message = await (async () => { const outcome = await waitForGeneration(client, jobId, { onProgress: (message) => { spinner.text = message }, }) return finishGeneration(client, outcome, { cwd: opts.cwd, spinner, stillRunning: generationRunningResult(jobId), }) })().finally(() => spinner.stop()) console.log(message) }