setup-agent 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["import { connectCheckout } from \"./client\";\nimport type { CheckoutClient } from \"./client\";\nimport { INPUT_PRESETS, isPresetId, presetInput } from \"./presets\";\nimport { spawn } from \"node:child_process\";\nimport { open, readFile } from \"node:fs/promises\";\nimport { createInterface } from \"node:readline/promises\";\nimport { resolve } from \"node:path\";\nimport {\n AGENT_HEARTBEAT_MS,\n OPTION_ICONS,\n classifyChoiceAnswer,\n currentPlan,\n isAgentPresent,\n isClosed,\n isOptionIcon,\n isValidModelAnswer,\n parseEntryPointOptions,\n parseMultipleAnswer,\n stepProgress,\n} from \"./protocol\";\nimport type { Checkout } from \"./protocol\";\n\nexport const HELP = `setup-agent <url> [command]\n\nCommands (the url always comes first):\n status Print the setup as JSON.\n stream Follow the setup: one JSON array of events per line.\n log <text> Send a message to the user: a reply, something no question or step conveys, or one wrap-up when finished.\n ack <message-id> Acknowledge a user message.\n ask <prompt> [--placeholder <text>] [--optional] [--step <step-id>] [--wait]\n Ask the user for a line of text.\n ask [prompt] --preset <framework|llm-provider> [--only <id,id>] [--choices <id=description,...>] [--default <id>] [--optional] [--step <step-id>] [--wait]\n Ask a standard question. --only restricts the options and leaves out --choices (one id locks it in); --default preselects one.\n \"framework\" answers \"<framework>:<language>\"; \"llm-provider\" answers JSON with provider, model and reasoningEffort; the key itself arrives through \"env\".\n ask <prompt> --choices <id,id,...> --icons <id=icon,...> [--single] [--default <id>] [--optional] [--step <step-id>] [--wait]\n Ask the user to pick from your own options; they may also type their own answer.\n The user checks any number of options and the answer is a JSON array of option ids (their own text is one entry).\n --single is for options that exclude each other (one framework, one model, yes or no); the answer is then one id.\n --icons is required and names an icon for every option, from: ${OPTION_ICONS.join(\", \")}.\n ask <prompt> --entry-points '<JSON array>' [--default <id>] [--optional] [--step <step-id>] [--wait]\n Ask where users should access the assistant. Each of 1–3 options has id, label, description and entryPoint {formFactor: modal|sidebar|full-page, placement, trigger, recommended?}. Answers one option id.\n wait start Block until the user clicks Begin plan in their browser; after a finished or cancelled setup, until the next one begins.\n wait <input-id> Block until the user answers or dismisses an input. A multi-select answer prints as an array.\n plan (<markdown> | --file <path>) [--wait]\n Propose the plan for the user to approve. --wait blocks until they decide.\n wait plan Block until the user approves the plan or asks for changes.\n env <input-id> <ENV_VAR> [--file <path>]\n Write the API key behind an answered llm-provider input to an env file (default .env.local) as ENV_VAR=<key>, without printing it.\n add-step <title> [--detail <text>] [--product <slug>] [--active]\n Declare a step of the install (after the plan is approved). Prints its id.\n step <step-id> <status> [--note <text>]\n Set a step to pending|active|done|skipped|blocked.\n done [--summary <text>] [--preview <url>]\n Mark every remaining step done and propose closing; the user closes it.\n`;\n\nexport const agentInstructions = (\n url: string,\n) => `You are the coding agent for a setup the user opened in their browser. The browser shows this setup live; every command below updates it. The user watches the browser, not this terminal: once setup begins, send questions through \"ask\" so the user can answer in their browser.\n\nFirst, start a persistent Monitor on\n npx setup-agent ${url} stream\nand keep it running: the browser shows you as connected only while it runs, and it is how answers reach you. The URL is the user's link to you from their browser, not one setup: it outlives this one, and their next setup arrives on the same stream. Each line is a JSON array of events: \"planning.started\", \"input.answered\" ({inputId, answer, note?}; answer is an array for a choice question not asked with --single), \"input.dismissed\", \"plan.approved\", \"plan.changes-requested\" ({feedback}), \"message.created\" ({messageId, text}), \"finished\", \"cancelled\", \"setup.created\" ({products}).\n\nThe user can message you at any time, including while a question is waiting. Read \"message.created\" events, acknowledge each with \"npx setup-agent ${url} ack <message-id>\", and reply using \"log\" with what you will do. Pending messages are replayed when the stream starts and listed in \"status\". A message is not an answer or plan approval; keep those decisions explicit.\n\n\"log\" is a message to the user, and the user reads every one: send it only to reply to their message, to tell them something no question or step conveys (a blocker, a deviation from the plan, a decision you made for them), or once as a wrap-up when the install is finished. Findings go in the plan, progress in step notes, questions in \"ask\"; do not narrate.\n\nBefore planning, check the current setup status. If it is \"waiting\", tell the user in your own conversation: \"I'm connected. Go back to your browser and click Begin plan. You can watch my progress, answer questions, and steer me there.\" Then run:\n npx setup-agent ${url} wait start\nKeep the stream running while you wait. Do not inspect the project, fetch guides, ask setup questions, or propose a plan until this command returns {\"ok\":true}. Only the user in the browser should start planning; never invoke the browser's start command yourself. \"planning.started\" also arrives on the stream. If the status is already \"planning\" or \"installing\", resume that phase without asking the user to begin again. If it is \"done\" or \"cancelled\", that setup is over: tell the user you are connected and waiting for their next setup, and run \"wait start\", which returns once the next one begins.\n\nThe remaining phases are plan, then install.\n\n1. Plan. Investigate only; change nothing yet. If the current directory is not an app to install into (a monorepo root, an empty folder, a library), ask where to install first:\n npx setup-agent ${url} ask \"Which project should I install into?\" --placeholder \"An absolute path to the app\" --wait\nRead the project: its app framework and package manager, the agent framework and model provider it already uses, where components live, any existing chat route. Fetch each product's \"guide\" URL from the setup below; it is the install reference. Ask for what the project does not decide, using the standard questions so the browser can render them well:\n npx setup-agent ${url} ask --preset framework\n npx setup-agent ${url} ask --preset llm-provider\nThe setup's products are starting names and guide references. Explore each product's setup instructions, then discover and plan any other relevant products or dependencies the app needs. Read /catalog.md on the guide URL’s origin to find related products and fetch their setup guides. The starting list does not restrict the implementation or require adding another product to the list. Include relevant additions in the plan for approval.\nWhen the setup puts an assistant in the app, ask how users should access it after discovering the actual app and before proposing the plan. Skip this question when no product's guide installs an assistant (a standalone library or service setup, for example). Use an entry-point question with only 1–3 sensible alternatives. Describe the actual app's pages, workflow and component placement, not generic placeholder copy. Recommend one clear fit when there is one; two options may use the same form factor in different places. Each option needs a stable id, label, contextual description and entryPoint {\"formFactor\":\"modal\"|\"sidebar\"|\"full-page\",\"placement\":\"where it appears\",\"trigger\":\"how users open it or navigate to it\",\"recommended\":true?}. Write the JSON array for this app and send it with:\n npx setup-agent ${url} ask \"Where should users access the assistant?\" --entry-points '<JSON array>' --wait\nMark a clear fit with \"recommended\":true rather than --default, so the user makes the pick. When you ask it, do not submit the plan before the user picks an entry point. Respect the selected placement and trigger in the plan and implementation. Do not ask for a new-versus-existing app setting; discover the app from its files and ask only for an install path when needed.\nSkip a preset the code already answers (a chat route on the AI SDK, a provider key in .env.local) and log why. Ask everything at once, keep investigating, and block with \"wait <input-id>\" only when nothing else can proceed. A framework answer is \"<framework>:<language>\", for example \"ai-sdk:typescript\". A model answer is JSON {\"provider\",\"model\",\"reasoningEffort\"?}. An answer may carry a \"note\" from the user; follow it. A choice answer that matches none of the options is the user's own text.\nThen write the plan as markdown and submit it:\n npx setup-agent ${url} plan --file <path> --wait\nUse these headings, each with bullets: \"## What I found\" (facts as \\`- **Label:** value\\`: app framework, package manager, agent framework, model provider and model, where components live), \"## What I will install\" (packages and files, one per bullet), \"## Steps\" (a numbered list, one line each), and \"## Open questions\" only if any remain. Keep it under 30 lines; no preamble. \"plan --wait\" prints {\"decision\":\"approve\"} or {\"decision\":\"revise\",\"feedback\":\"...\"}. On revise, address the feedback (ask again if you need to) and submit a new plan; repeat until approved. Do not change the project before approval: the setup refuses steps until then.\n\n2. Install. Declare the steps from your plan up front, in order:\n npx setup-agent ${url} add-step \"<title>\" --detail \"<one line>\"\nwhich prints the step id. Then work through them: \"step <id> active\" before, \"step <id> done --note '<one line on what you did>'\" after; \"skipped\" when the step is already satisfied, \"blocked\" when you cannot continue, saying why in --note. Add steps as the work reveals them. Ask when you need another decision or value (--choices for a pick, plain for text; --optional when you can proceed without an answer; --wait only when the answer is the very next thing you need). A choice question is multi-select: the user checks any number of your options, and the answer is an array of the ids they checked, plus their own text as an entry when they typed one. Pass --single only when the options exclude each other (one framework, one model, yes or no); the answer is then one id. Every option must carry an icon, given as --icons \"<id>=<icon>,...\" with the closest name from this pack: ${OPTION_ICONS.join(\", \")}. A question without an icon for each option is refused. Open inputs the user has not answered are listed under \"inputs\" in \"status\"; check them before asking again.\nThe API key behind a model answer is not in the answer and you never see it: pick the variable name the provider's SDK reads (OPENAI_API_KEY, ANTHROPIC_API_KEY, ...) and run\n npx setup-agent ${url} env <input-id> <ENV_VAR> --file .env.local\nwhich writes ENV_VAR=<key> into that file. Use the answer's model in the chat route and map reasoningEffort onto the provider's setting when it is set. Never invent a key or a model name.\n\nWhen every product is installed and verified, run\n npx setup-agent ${url} done --summary \"<one or two lines on what you installed and how to try it>\" --preview http://localhost:<port>\nBefore that, start the project's dev server in the background when the project has one, check that the page you changed loads, and pass the address as --preview (the page itself when it is not the root); leave the server running so the user can try the result. Omit --preview when there is nothing to open. This proposes closing the setup; only the user closes it. Do not stop the stream or exit: stay idle on it, because the user may follow up with a \"message.created\" event. Handle it, then run \"done\" again. The stream prints \"finished\" once the user closes the setup, and \"cancelled\" if they end it early. Keep the stream running after either: the user's next setup starts on this same URL and arrives as \"setup.created\" with its products. Run\n npx setup-agent ${url} wait start\nwhich returns once that setup begins, then run \"status\" for its products, guides and instructions and go through plan and install again. A \"setup.created\" event while you are still working means the user replaced this setup: drop what you were doing and start over the same way.\n`;\n\nexport const INSTRUCTIONS = agentInstructions;\n\ntype Parsed = { positional: string[]; flags: Map<string, string | true> };\n\nconst parseArgs = (argv: readonly string[]): Parsed => {\n const positional: string[] = [];\n const flags = new Map<string, string | true>();\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i]!;\n if (!arg.startsWith(\"--\")) {\n positional.push(arg);\n continue;\n }\n const name = arg.slice(2);\n const next = argv[i + 1];\n if (next !== undefined && !next.startsWith(\"--\")) {\n flags.set(name, next);\n i++;\n } else {\n flags.set(name, true);\n }\n }\n return { positional, flags };\n};\n\nconst flagText = (flags: Parsed[\"flags\"], name: string) => {\n const value = flags.get(name);\n return typeof value === \"string\" ? value : undefined;\n};\n\nconst fail = (message: string): never => {\n process.stderr.write(`setup-agent: ${message}\\n`);\n return process.exit(1);\n};\n\nconst print = (value: unknown) => {\n process.stdout.write(`${JSON.stringify(value)}\\n`);\n};\n\nconst AGENT_ENV: readonly [kind: string, variable: string][] = [\n [\"claude\", \"CLAUDECODE\"],\n [\"codex\", \"CODEX_SANDBOX\"],\n [\"codex\", \"CODEX_SANDBOX_NETWORK_DISABLED\"],\n [\"cursor\", \"CURSOR_AGENT\"],\n [\"gemini\", \"GEMINI_CLI\"],\n];\n\n/** The coding agent this process runs under, from the variables each one exports to its shell. */\nexport const detectAgentKind = (env: NodeJS.ProcessEnv = process.env) =>\n AGENT_ENV.find(([, variable]) => env[variable])?.[0];\n\ntype Launcher = {\n kind: string;\n name: string;\n command: string;\n args: (prompt: string) => string[];\n install: string;\n};\n\nconst LAUNCHERS: Launcher[] = [\n {\n kind: \"claude\",\n name: \"Claude Code\",\n command: \"claude\",\n args: (prompt) => [prompt],\n install: \"npm install -g @anthropic-ai/claude-code\",\n },\n {\n kind: \"codex\",\n name: \"Codex\",\n command: \"codex\",\n args: (prompt) => [prompt],\n install: \"npm install -g @openai/codex\",\n },\n {\n kind: \"cursor\",\n name: \"Cursor\",\n command: \"agent\",\n args: (prompt) => [prompt],\n install: \"curl https://cursor.com/install -fsS | bash\",\n },\n {\n kind: \"gemini\",\n name: \"Gemini CLI\",\n command: \"gemini\",\n args: (prompt) => [\"-i\", prompt],\n install: \"npm install -g @google/gemini-cli\",\n },\n];\n\n/** True when a person typed the command into a terminal rather than an agent running it from its shell. */\nexport const isDirectInvocation = (\n env: NodeJS.ProcessEnv = process.env,\n stdin: { isTTY?: boolean | undefined } = process.stdin,\n stdout: { isTTY?: boolean | undefined } = process.stdout,\n) =>\n detectAgentKind(env) === undefined &&\n stdin.isTTY === true &&\n stdout.isTTY === true;\n\nconst chooseLauncher = async () => {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n try {\n process.stdout.write(\n \"This command is meant for a coding agent, and none is running here.\\nStart one to do the install:\\n\",\n );\n LAUNCHERS.forEach((launcher, index) => {\n process.stdout.write(` ${index + 1}. ${launcher.name}\\n`);\n });\n while (true) {\n const answer = (\n await rl.question(\"Choose [1]: \").catch(() => process.exit(1))\n ).trim();\n if (answer === \"\") return LAUNCHERS[0]!;\n const byNumber = LAUNCHERS[Number(answer) - 1];\n if (byNumber) return byNumber;\n const byName = LAUNCHERS.find(\n (launcher) =>\n launcher.kind === answer.toLowerCase() ||\n launcher.name.toLowerCase() === answer.toLowerCase(),\n );\n if (byName) return byName;\n process.stdout.write(\"Enter a number from the list.\\n\");\n }\n } finally {\n rl.close();\n }\n};\n\nconst launchAgent = async (url: string) => {\n const launcher = await chooseLauncher();\n const prompt = `Run \\`npx setup-agent ${url}\\` and follow the instructions it prints.`;\n process.stdout.write(`\\nStarting ${launcher.name}...\\n\\n`);\n const child = spawn(launcher.command, launcher.args(prompt), {\n stdio: \"inherit\",\n });\n const code = await new Promise<number>((resolve) => {\n child.on(\"error\", (error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") {\n process.stderr.write(\n `${launcher.name} is not installed. Install it with:\\n ${launcher.install}\\nthen run this command again.\\n`,\n );\n } else {\n process.stderr.write(`${error.message}\\n`);\n }\n resolve(1);\n });\n child.on(\"exit\", (status) => resolve(status ?? 1));\n });\n process.exit(code);\n};\n\nconst requireState = (client: CheckoutClient): Checkout.State =>\n client.state ?? fail(\"the setup has no state\");\n\nconst summary = (state: Checkout.State) => {\n const plan = currentPlan(state);\n return {\n status: state.status,\n agentConnected: isAgentPresent(state),\n products: state.products,\n instructions: state.instructions,\n plan:\n plan === undefined\n ? null\n : {\n revision: plan.revision,\n status: plan.status,\n ...(plan.feedback !== undefined && { feedback: plan.feedback }),\n },\n progress: stepProgress(state),\n steps: state.steps,\n inputs: state.inputs,\n log: state.log.slice(-20),\n pendingMessages: state.log.filter(\n (entry) => entry.role === \"user\" && entry.acknowledgedAt === undefined,\n ),\n };\n};\n\nconst STEP_STATUSES: readonly Checkout.StepStatus[] = [\n \"pending\",\n \"active\",\n \"done\",\n \"skipped\",\n \"blocked\",\n];\n\ntype StreamEvent =\n | { event: \"planning.started\" }\n | { event: \"message.created\"; messageId: string; text: string }\n | {\n event: \"input.answered\";\n inputId: string;\n prompt: string;\n /** The entries of a multiple choice answer, else the answer text. */\n answer: string | string[];\n note?: string;\n /** True when a choice answer is, or a multiple one contains, the user's own text rather than an option. */\n custom?: true;\n }\n | { event: \"input.dismissed\"; inputId: string; prompt: string }\n | { event: \"plan.approved\"; revision: number }\n | { event: \"plan.changes-requested\"; revision: number; feedback: string }\n | { event: \"finished\"; next: string }\n | { event: \"cancelled\"; next: string }\n | { event: \"setup.created\"; products: string[] };\n\nconst STAY_CONNECTED =\n \"This setup is over, not your connection. Keep the stream running, tell the user you are connected and waiting for their next setup, and run wait start.\";\n\nexport const diffEvents = (\n before: Checkout.State,\n after: Checkout.State,\n): StreamEvent[] => {\n const events: StreamEvent[] = [];\n if (before.status === \"waiting\" && after.status === \"planning\") {\n events.push({ event: \"planning.started\" });\n }\n for (const entry of after.log) {\n if (\n entry.role === \"user\" &&\n entry.acknowledgedAt === undefined &&\n !before.log.some((previous) => previous.id === entry.id)\n ) {\n events.push({\n event: \"message.created\",\n messageId: entry.id,\n text: entry.text,\n });\n }\n }\n for (const input of after.inputs) {\n const previous = before.inputs.find(\n (candidate) => candidate.id === input.id,\n );\n if (previous?.status === input.status) continue;\n if (input.status === \"answered\") {\n const answer = input.answer ?? \"\";\n events.push({\n event: \"input.answered\",\n inputId: input.id,\n prompt: input.prompt,\n ...answerFields(input, answer),\n });\n } else if (input.status === \"dismissed\" && after.status !== \"cancelled\") {\n events.push({\n event: \"input.dismissed\",\n inputId: input.id,\n prompt: input.prompt,\n });\n }\n }\n for (const plan of after.plans) {\n const previous = before.plans.find(\n (candidate) => candidate.revision === plan.revision,\n );\n if (previous?.status === plan.status || plan.status === \"proposed\") {\n continue;\n }\n if (plan.status === \"approved\") {\n events.push({ event: \"plan.approved\", revision: plan.revision });\n } else {\n events.push({\n event: \"plan.changes-requested\",\n revision: plan.revision,\n feedback: plan.feedback ?? \"\",\n });\n }\n }\n if (before.status !== \"done\" && after.status === \"done\") {\n events.push({ event: \"finished\", next: STAY_CONNECTED });\n }\n if (before.status !== \"cancelled\" && after.status === \"cancelled\") {\n events.push({ event: \"cancelled\", next: STAY_CONNECTED });\n }\n if (after.id !== null && after.id !== before.id) {\n events.push({\n event: \"setup.created\",\n products: after.products.map((product) => product.slug),\n });\n }\n return events;\n};\n\nconst stream = async (client: CheckoutClient) => {\n let previous = requireState(client);\n let pending: StreamEvent[] = diffEvents({ ...previous, log: [] }, previous);\n let timer: ReturnType<typeof setTimeout> | null = null;\n const flush = () => {\n timer = null;\n if (pending.length === 0) return;\n print(pending);\n pending = [];\n };\n client.subscribe(() => {\n const next = client.state;\n if (next === undefined) return;\n pending.push(...diffEvents(previous, next));\n previous = next;\n if (pending.length > 0 && timer === null) timer = setTimeout(flush, 200);\n });\n flush();\n const kind = detectAgentKind();\n await client.commands[\"agent/hello\"]({\n cwd: process.cwd(),\n ...(kind !== undefined && { kind }),\n });\n const heartbeat = setInterval(() => {\n void client.commands[\"agent/heartbeat\"]().catch(() => {});\n }, AGENT_HEARTBEAT_MS);\n const stop = () => {\n clearInterval(heartbeat);\n flush();\n void client.commands[\"agent/bye\"]()\n .catch(() => {})\n .finally(() => {\n client.dispose();\n process.exit(0);\n });\n };\n process.on(\"SIGHUP\", stop);\n process.on(\"SIGINT\", stop);\n process.on(\"SIGTERM\", stop);\n await new Promise(() => {});\n};\n\n/** Resolves once a setup is planning or installing, or once the one being waited on is cancelled; a setup already closed when the wait begins is over, so the wait is for the next one. */\nexport const waitForStart = (\n client: Pick<CheckoutClient, \"state\" | \"subscribe\">,\n) =>\n new Promise<Checkout.Status>((resolve) => {\n let previous: Checkout.Status | undefined;\n const check = () => {\n const state = client.state;\n if (state === undefined) return;\n const started =\n state.status === \"planning\" || state.status === \"installing\";\n const ended = isClosed(state) && previous === \"waiting\";\n previous = state.status;\n if (!started && !ended) return;\n unsubscribe();\n resolve(state.status);\n };\n const unsubscribe = client.subscribe(check);\n check();\n });\n\nconst waitForInput = (client: CheckoutClient, inputId: string) =>\n new Promise<Checkout.Input>((resolve) => {\n const check = () => {\n const state = client.state;\n const input = state?.inputs.find((candidate) => candidate.id === inputId);\n if (!input) return;\n if (input.status !== \"open\" || state?.status === \"cancelled\") {\n unsubscribe();\n resolve(input);\n }\n };\n const unsubscribe = client.subscribe(check);\n check();\n });\n\nconst waitForPlan = (client: CheckoutClient, revision: number) =>\n new Promise<Checkout.Plan | undefined>((resolve) => {\n const check = () => {\n const state = client.state;\n const plan = state?.plans.find(\n (candidate) => candidate.revision === revision,\n );\n if (\n plan === undefined ||\n plan.status !== \"proposed\" ||\n state?.status === \"cancelled\"\n ) {\n unsubscribe();\n resolve(plan);\n }\n };\n const unsubscribe = client.subscribe(check);\n check();\n });\n\nconst decided = (plan: Checkout.Plan | undefined, state: Checkout.State) => {\n if (state.status === \"cancelled\") return { ok: false, status: \"cancelled\" };\n if (plan === undefined) return fail(\"the plan disappeared\");\n return plan.status === \"approved\"\n ? { ok: true, decision: \"approve\", revision: plan.revision }\n : {\n ok: true,\n decision: \"revise\",\n revision: plan.revision,\n feedback: plan.feedback ?? \"\",\n };\n};\n\nconst splitList = (value: string | undefined) =>\n value\n ?.split(\",\")\n .map((entry) => entry.trim())\n .filter(Boolean);\n\nexport const askSeed = (\n rest: readonly string[],\n flags: Parsed[\"flags\"],\n): Checkout.InputSeed & { stepId?: string } => {\n const stepId = flagText(flags, \"step\");\n const optional = flags.has(\"optional\");\n const fallback = flagText(flags, \"default\");\n if (flags.has(\"entry-points\")) {\n if (\n [\n \"preset\",\n \"product\",\n \"choices\",\n \"icons\",\n \"multiple\",\n \"single\",\n \"only\",\n \"placeholder\",\n ].some((flag) => flags.has(flag))\n )\n return fail(\n \"--entry-points cannot be combined with other input kinds, --multiple, --single or --only\",\n );\n const json = flagText(flags, \"entry-points\");\n let value: unknown;\n try {\n value = JSON.parse(json ?? \"\");\n } catch {\n return fail(\"--entry-points needs a JSON array of options\");\n }\n const options = parseEntryPointOptions(value);\n if (!options)\n return fail(\n \"--entry-points needs 1–3 unique options with id, label, description and entryPoint {formFactor, placement, trigger, recommended?}; at most one is recommended\",\n );\n if (\n fallback !== undefined &&\n !options.some((option) => option.id === fallback)\n )\n return fail(`no option \"${fallback}\" to default to`);\n const prompt =\n rest[0] ?? fail(\"usage: ask <prompt> --entry-points '<JSON array>'\");\n if (prompt.trim() === \"\")\n return fail(\"an entry-point prompt cannot be empty\");\n return {\n kind: \"entry-point\",\n prompt,\n options,\n ...(fallback !== undefined && { default: fallback }),\n optional,\n ...(stepId !== undefined && { stepId }),\n };\n }\n const preset = flagText(flags, \"preset\");\n if (preset !== undefined) {\n if (!isPresetId(preset)) {\n return fail(\n `unknown preset \"${preset}\"; use ${Object.keys(INPUT_PRESETS).join(\" or \")}`,\n );\n }\n const only = splitList(flagText(flags, \"only\"));\n const found = splitList(flagText(flags, \"choices\"))?.map((entry) => {\n const [id = \"\", ...description] = entry.split(\"=\");\n return description.length === 0\n ? { id }\n : { id, description: description.join(\"=\") };\n });\n try {\n const seed = presetInput(preset, {\n ...(only !== undefined && { only }),\n ...(found !== undefined && { found }),\n ...(fallback !== undefined && { default: fallback }),\n optional,\n ...(stepId !== undefined && { stepId }),\n });\n return rest[0] === undefined ? seed : { ...seed, prompt: rest[0] };\n } catch (error) {\n return fail(error instanceof Error ? error.message : String(error));\n }\n }\n const prompt = rest[0] ?? fail(\"usage: ask <prompt>\");\n const product = flagText(flags, \"product\");\n if (product !== undefined) {\n return {\n kind: \"product\",\n prompt,\n product,\n optional,\n ...(stepId !== undefined && { stepId }),\n };\n }\n const choices = splitList(flagText(flags, \"choices\"));\n if (choices !== undefined) {\n if (flags.has(\"single\") && flags.has(\"multiple\"))\n return fail(\"--single and --multiple exclude each other\");\n const icons = new Map<string, string>();\n for (const entry of splitList(flagText(flags, \"icons\")) ?? []) {\n const [id = \"\", icon = \"\"] = entry.split(\"=\", 2);\n if (!choices.includes(id))\n return fail(`no choice \"${id}\" to put an icon on`);\n if (!isOptionIcon(icon)) {\n return fail(\n `unknown icon \"${icon}\"; pick one of ${OPTION_ICONS.join(\", \")}`,\n );\n }\n icons.set(id, icon);\n }\n const missing = choices.filter((id) => !icons.has(id));\n if (missing.length > 0) {\n return fail(\n `every option needs an icon; ${missing.map((id) => `\"${id}\"`).join(\", \")} ${missing.length === 1 ? \"has\" : \"have\"} none. Pass --icons \"${choices.map((id) => `${id}=<icon>`).join(\",\")}\" with icons from: ${OPTION_ICONS.join(\", \")}`,\n );\n }\n return {\n kind: \"choice\",\n prompt,\n options: choices.map((id) => ({ id, label: id, icon: icons.get(id)! })),\n ...(!flags.has(\"single\") && { multiple: true }),\n ...(fallback !== undefined && { default: fallback }),\n optional,\n ...(stepId !== undefined && { stepId }),\n };\n }\n const placeholder = flagText(flags, \"placeholder\");\n return {\n prompt,\n ...(placeholder !== undefined && { placeholder }),\n optional,\n ...(stepId !== undefined && { stepId }),\n };\n};\n\nconst assertEnvKey = (key: string) => {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {\n throw new Error(`\"${key}\" is not an environment variable name`);\n }\n};\n\n/** Sets `key=value` in dotenv text, replacing an existing line for the key. */\nexport const upsertEnvLine = (content: string, key: string, value: string) => {\n assertEnvKey(key);\n const line = `${key}=${value}`;\n const lines = content === \"\" ? [] : content.replace(/\\n$/, \"\").split(\"\\n\");\n const index = lines.findIndex(\n (entry) =>\n /^(?:export\\s+)?([A-Za-z_][A-Za-z0-9_]*)\\s*=/.exec(entry)?.[1] === key,\n );\n if (index === -1) lines.push(line);\n else lines[index] = line;\n return `${lines.join(\"\\n\")}\\n`;\n};\n\n/**\n * Write the secret `take` returns to `file` under `key`, leaving the file\n * owner-only. The file is opened before `take` runs, because taking the\n * secret consumes it and an unwritable destination must fail while it is\n * still deposited; it is read after, so lines written meanwhile survive.\n */\nexport const writeEnvSecret = async (\n file: string,\n key: string,\n take: () => Promise<string>,\n) => {\n assertEnvKey(key);\n const handle = await open(file, \"a+\", 0o600);\n try {\n await handle.chmod(0o600);\n const value = await take();\n const current = await handle.readFile(\"utf8\");\n await handle.truncate(0);\n await handle.writeFile(upsertEnvLine(current, key, value));\n } finally {\n await handle.close();\n }\n};\n\nconst answerFields = (input: Checkout.Input, answer: string) => ({\n answer: (input.multiple && parseMultipleAnswer(answer)) || answer,\n ...(input.note !== undefined && { note: input.note }),\n ...(input.kind === \"choice\" &&\n classifyChoiceAnswer(input, answer) === \"custom\" && {\n custom: true as const,\n }),\n});\n\nconst answered = (input: Checkout.Input) => ({\n ok: true,\n inputId: input.id,\n status: input.status,\n ...(input.answer !== undefined && answerFields(input, input.answer)),\n});\n\nexport const main = async (argv: readonly string[]) => {\n const { positional, flags } = parseArgs(argv);\n const [first, command = \"intro\", ...rest] = positional;\n if (flags.has(\"help\") || flags.has(\"h\") || first === undefined) {\n process.stdout.write(HELP);\n return process.exit(first === undefined ? 1 : 0);\n }\n const url = first;\n if (command === \"intro\" && isDirectInvocation()) return launchAgent(url);\n\n const client = await connectCheckout(url).catch((error: unknown) =>\n fail(error instanceof Error ? error.message : String(error)),\n );\n const commands = client.commands;\n\n try {\n switch (command) {\n case \"intro\": {\n const kind = detectAgentKind();\n await commands[\"agent/intro\"]({\n ...(kind !== undefined && { kind }),\n }).catch(() => {});\n process.stdout.write(INSTRUCTIONS(url));\n process.stdout.write(\"\\nCurrent setup:\\n\");\n print(summary(requireState(client)));\n break;\n }\n case \"status\": {\n print(summary(requireState(client)));\n break;\n }\n case \"stream\": {\n await stream(client);\n break;\n }\n case \"step\": {\n const usage =\n \"usage: step <step-id> <pending|active|done|skipped|blocked>\";\n const stepId = rest[0] ?? fail(usage);\n const status = rest[1];\n if (!STEP_STATUSES.includes(status as Checkout.StepStatus)) fail(usage);\n const note = flagText(flags, \"note\");\n await commands[\"agent/step\"]({\n stepId,\n status: status as Checkout.StepStatus,\n ...(note !== undefined && { note }),\n });\n print({ ok: true, stepId, status });\n break;\n }\n case \"add-step\": {\n const title = rest[0] ?? fail(\"usage: add-step <title>\");\n const detail = flagText(flags, \"detail\");\n const product = flagText(flags, \"product\");\n const result = await commands[\"agent/add-step\"]({\n title,\n ...(detail !== undefined && { detail }),\n ...(product !== undefined && { product }),\n ...(flags.has(\"active\") && { active: true }),\n });\n print({ ok: true, ...result });\n break;\n }\n case \"plan\": {\n const file = flagText(flags, \"file\");\n const markdown =\n file !== undefined\n ? await readFile(resolve(file), \"utf8\").catch(() =>\n fail(`could not read ${file}`),\n )\n : (rest[0] ?? fail(\"usage: plan <markdown> | plan --file <path>\"));\n const { revision } = await commands[\"agent/plan\"]({ markdown });\n if (!flags.has(\"wait\")) {\n print({ ok: true, revision });\n break;\n }\n const plan = await waitForPlan(client, revision);\n print(decided(plan, requireState(client)));\n break;\n }\n case \"ask\": {\n const { inputId } = await commands[\"agent/ask\"](askSeed(rest, flags));\n if (!flags.has(\"wait\")) {\n print({ ok: true, inputId });\n break;\n }\n print(await waitForInput(client, inputId).then(answered));\n break;\n }\n case \"wait\": {\n const target =\n rest[0] ?? fail(\"usage: wait start | wait <input-id> | wait plan\");\n const state = requireState(client);\n if (target === \"start\") {\n const status = await waitForStart(client);\n print({\n ok: status === \"planning\" || status === \"installing\",\n status,\n });\n break;\n }\n if (target === \"plan\") {\n const plan = currentPlan(state) ?? fail(\"no plan has been proposed\");\n print(\n decided(\n await waitForPlan(client, plan.revision),\n requireState(client),\n ),\n );\n break;\n }\n if (!state.inputs.some((input) => input.id === target)) {\n fail(`no input \"${target}\"`);\n }\n print(await waitForInput(client, target).then(answered));\n break;\n }\n case \"env\": {\n const usage = \"usage: env <input-id> <ENV_VAR> [--file <path>]\";\n const inputId = rest[0] ?? fail(usage);\n const envKey = rest[1] ?? fail(usage);\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(envKey)) {\n fail(`\"${envKey}\" is not an environment variable name`);\n }\n const state = requireState(client);\n const input =\n state.inputs.find((candidate) => candidate.id === inputId) ??\n fail(`no input \"${inputId}\"`);\n const setupId = state.id ?? fail(\"the setup has not been created yet\");\n if (isClosed(state)) {\n fail(\"the setup is not open\");\n }\n if (input.status !== \"answered\") {\n fail(`input \"${inputId}\" is ${input.status}`);\n }\n if (\n input.kind !== \"model\" ||\n !isValidModelAnswer(input, input.answer ?? \"\")\n ) {\n fail(`input \"${inputId}\" is not an llm-provider answer`);\n }\n const file = resolve(flagText(flags, \"file\") ?? \".env.local\");\n await writeEnvSecret(file, envKey, async () => {\n const response = await fetch(\n `${url.replace(/\\/$/, \"\")}/secret/${encodeURIComponent(inputId)}?setup=${encodeURIComponent(setupId)}`,\n );\n if (response.status === 404) {\n fail(\n `the key for \"${inputId}\" was already taken or never deposited`,\n );\n }\n if (!response.ok) fail(`could not fetch the key: ${response.status}`);\n return response.text();\n });\n print({ ok: true, envKey, file });\n break;\n }\n case \"ack\": {\n const messageId = rest[0] ?? fail(\"usage: ack <message-id>\");\n await commands[\"agent/ack\"]({ messageId });\n print({ ok: true });\n break;\n }\n case \"log\": {\n const text = rest[0] ?? fail(\"usage: log <text>\");\n await commands[\"agent/log\"]({ text });\n print({ ok: true });\n break;\n }\n case \"done\": {\n const summary = flagText(flags, \"summary\");\n const preview = flagText(flags, \"preview\");\n await commands[\"agent/done\"]({\n ...(summary !== undefined && { summary }),\n ...(preview !== undefined && { preview }),\n });\n print({\n ok: true,\n status: \"proposed\",\n next: \"Keep the stream running and stay idle. The user closes the setup or sends a follow-up message.\",\n });\n break;\n }\n default:\n fail(`unknown command \"${command}\"\\n\\n${HELP}`);\n }\n } catch (error) {\n fail(error instanceof Error ? error.message : String(error));\n } finally {\n client.dispose();\n }\n};\n"],"mappings":";;;;;;;;AAsBA,MAAa,OAAO;;;;;;;;;;;;;;;;oGAgBgF,aAAa,KAAK,IAAI,EAAE;;;;;;;;;;;;;;;;;AAkB5H,MAAa,qBACX,QACG;;;oBAGe,IAAI;;;qJAG6H,IAAI;;;;;oBAKrI,IAAI;;;;;;oBAMJ,IAAI;;oBAEJ,IAAI;oBACJ,IAAI;;;oBAGJ,IAAI;;;;oBAIJ,IAAI;;;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B;IAC3D,MAAM,SAAS,YAAY,CAAC,EAAE,UAAU,CAAC;IACzC,MAAM,EAAE,IAAI,KAAK,CAAC;IAClB;GACF;GACA,KAAK,OAAO;IACV,MAAM,OAAO,KAAK,MAAM,KAAK,mBAAmB;IAChD,MAAM,SAAS,YAAY,CAAC,EAAE,KAAK,CAAC;IACpC,MAAM,EAAE,IAAI,KAAK,CAAC;IAClB;GACF;GACA,KAAK,QAAQ;IACX,MAAM,UAAU,SAAS,OAAO,SAAS;IACzC,MAAM,UAAU,SAAS,OAAO,SAAS;IACzC,MAAM,SAAS,aAAa,CAAC;KAC3B,GAAI,YAAY,KAAA,KAAa,EAAE,QAAQ;KACvC,GAAI,YAAY,KAAA,KAAa,EAAE,QAAQ;IACzC,CAAC;IACD,MAAM;KACJ,IAAI;KACJ,QAAQ;KACR,MAAM;IACR,CAAC;IACD;GACF;GACA,SACE,KAAK,oBAAoB,QAAQ,OAAO,MAAM;EAClD;CACF,SAAS,OAAO;EACd,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CAC7D,UAAU;EACR,OAAO,QAAQ;CACjB;AACF"}
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["import { connectCheckout } from \"./client\";\nimport type { CheckoutClient } from \"./client\";\nimport { INPUT_PRESETS, isPresetId, presetInput } from \"./presets\";\nimport { spawn } from \"node:child_process\";\nimport { createHash, randomBytes } from \"node:crypto\";\nimport { constants } from \"node:fs\";\nimport {\n chmod,\n lstat,\n mkdir,\n open,\n readFile,\n realpath,\n unlink,\n} from \"node:fs/promises\";\nimport { homedir, tmpdir, userInfo } from \"node:os\";\nimport { createInterface } from \"node:readline/promises\";\nimport { dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport {\n AGENT_HEARTBEAT_MS,\n OPTION_ICONS,\n classifyChoiceAnswer,\n currentPlan,\n isAgentPresent,\n isClosed,\n isLoopbackHostname,\n isOptionIcon,\n isValidModelAnswer,\n parseEntryPointOptions,\n parseMultipleAnswer,\n stepProgress,\n} from \"./protocol\";\nimport type { Checkout } from \"./protocol\";\n\nexport const HELP = `setup-agent <url> [command]\n\nCommands (the url always comes first):\n status Print the setup as JSON.\n stream Follow the setup: one JSON array of events per line.\n log <text> Send a message to the user: a reply, something no question or step conveys, or one wrap-up when finished.\n ack <message-id> Acknowledge a user message.\n ask <prompt> [--placeholder <text>] [--optional] [--step <step-id>] [--wait]\n Ask the user for a line of text.\n ask [prompt] --preset <framework|llm-provider> [--only <id,id>] [--choices <id=description,...>] [--default <id>] [--optional] [--step <step-id>] [--wait]\n Ask a standard question. --only restricts the options and leaves out --choices (one id locks it in); --default preselects one.\n \"framework\" answers \"<framework>:<language>\"; \"llm-provider\" answers JSON with provider, model and reasoningEffort; the key itself arrives through \"env\".\n ask <prompt> --choices <id,id,...> --icons <id=icon,...> [--single] [--default <id>] [--optional] [--step <step-id>] [--wait]\n Ask the user to pick from your own options; they may also type their own answer.\n The user checks any number of options and the answer is a JSON array of option ids (their own text is one entry).\n --single is for options that exclude each other (one framework, one model, yes or no); the answer is then one id.\n --icons is required and names an icon for every option, from: ${OPTION_ICONS.join(\", \")}.\n ask <prompt> --entry-points '<JSON array>' [--default <id>] [--optional] [--step <step-id>] [--wait]\n Ask where users should access the assistant. Each of 1–3 options has id, label, description and entryPoint {formFactor: modal|sidebar|full-page, placement, trigger, recommended?}. Answers one option id.\n wait start Block until the user clicks Begin plan in their browser; after a finished or cancelled setup, until the next one begins.\n wait <input-id> Block until the user answers or dismisses an input. A multi-select answer prints as an array.\n plan (<markdown> | --file <path>) [--wait]\n Propose the plan for the user to approve. --wait blocks until they decide.\n wait plan Block until the user approves the plan or asks for changes.\n env <input-id> <ENV_VAR> [--file <path>]\n Write the API key behind an answered llm-provider input to an env file (default .env.local) as ENV_VAR=<key>, without printing it.\n add-step <title> [--detail <text>] [--product <slug>] [--active]\n Declare a step of the install (after the plan is approved). Prints its id.\n step <step-id> <status> [--note <text>]\n Set a step to pending|active|done|skipped|blocked.\n done [--summary <text>] [--preview <url>]\n Mark every remaining step done and propose closing; the user closes it.\n`;\n\n/** Characters a setup URL may hold: an origin and a path, nothing a shell or a reader treats as more than an address. */\nconst SETUP_URL_PATTERN =\n /^https?:\\/\\/[A-Za-z0-9.-]+(?::[0-9]+)?(?:\\/[A-Za-z0-9._~%/-]*)?$|^http:\\/\\/\\[::1\\](?::[0-9]+)?(?:\\/[A-Za-z0-9._~%/-]*)?$/;\n\n/**\n * The normalized setup URL, or an error saying why it is refused. A setup URL\n * is printed into shell commands and the coding agent's prompt, and the API\n * key travels over it, so it must be https (http only on this machine), carry\n * no credentials, query or fragment, and hold only address characters.\n */\nexport const parseSetupUrl = (value: string): string => {\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n throw new Error(`\"${value}\" is not a URL`);\n }\n if (\n url.protocol !== \"https:\" &&\n !(url.protocol === \"http:\" && isLoopbackHostname(url.hostname))\n ) {\n throw new Error(\"the setup URL must use https (http only on localhost)\");\n }\n if (url.username !== \"\" || url.password !== \"\") {\n throw new Error(\"the setup URL must not carry credentials\");\n }\n if (\n url.search !== \"\" ||\n url.hash !== \"\" ||\n value.includes(\"?\") ||\n value.includes(\"#\")\n ) {\n throw new Error(\"the setup URL must not have a query or fragment\");\n }\n const href = url.href.replace(/\\/$/, \"\");\n if (!SETUP_URL_PATTERN.test(href)) {\n throw new Error(\"the setup URL has characters a setup URL does not use\");\n }\n return href;\n};\n\n/** `value` as one shell word, quoted only when it holds more than plain URL characters. */\nconst shellWord = (value: string) =>\n /^[A-Za-z0-9._~%/:@=+,-]+$/.test(value)\n ? value\n : `'${value.replaceAll(\"'\", `'\\\\''`)}'`;\n\nexport const agentInstructions = (setupUrl: string) => {\n const url = shellWord(setupUrl);\n return `You are the coding agent for a setup the user opened in their browser. The browser shows this setup live; every command below updates it. The user watches the browser, not this terminal: once setup begins, send questions through \"ask\" so the user can answer in their browser.\n\nFirst, start a persistent Monitor on\n npx setup-agent ${url} stream\nand keep it running: the browser shows you as connected only while it runs, and it is how answers reach you. The URL is the user's link to you from their browser, not one setup: it outlives this one, and their next setup arrives on the same stream. Each line is a JSON array of events: \"planning.started\", \"input.answered\" ({inputId, answer, note?}; answer is an array for a choice question not asked with --single), \"input.dismissed\", \"plan.approved\", \"plan.changes-requested\" ({feedback}), \"message.created\" ({messageId, text}), \"finished\", \"cancelled\", \"setup.created\" ({products}).\n\nThe user can message you at any time, including while a question is waiting. Read \"message.created\" events, acknowledge each with \"npx setup-agent ${url} ack <message-id>\", and reply using \"log\" with what you will do. Pending messages are replayed when the stream starts and listed in \"status\". A message is not an answer or plan approval; keep those decisions explicit.\n\n\"log\" is a message to the user, and the user reads every one: send it only to reply to their message, to tell them something no question or step conveys (a blocker, a deviation from the plan, a decision you made for them), or once as a wrap-up when the install is finished. Findings go in the plan, progress in step notes, questions in \"ask\"; do not narrate.\n\nBefore planning, check the current setup status. If it is \"waiting\", tell the user in your own conversation: \"I'm connected. Go back to your browser and click Begin plan. You can watch my progress, answer questions, and steer me there.\" Then run:\n npx setup-agent ${url} wait start\nKeep the stream running while you wait. Do not inspect the project, fetch guides, ask setup questions, or propose a plan until this command returns {\"ok\":true}. Only the user in the browser should start planning; never invoke the browser's start command yourself. \"planning.started\" also arrives on the stream. If the status is already \"planning\" or \"installing\", resume that phase without asking the user to begin again. If it is \"done\" or \"cancelled\", that setup is over: tell the user you are connected and waiting for their next setup, and run \"wait start\", which returns once the next one begins.\n\nThe remaining phases are plan, then install.\n\n1. Plan. Investigate only; change nothing yet. If the current directory is not an app to install into (a monorepo root, an empty folder, a library), ask where to install first:\n npx setup-agent ${url} ask \"Which project should I install into?\" --placeholder \"An absolute path to the app\" --wait\nRead the project: its app framework and package manager, the agent framework and model provider it already uses, where components live, any existing chat route. Fetch each product's \"guide\" URL from the setup below; it is the install reference. Ask for what the project does not decide, using the standard questions so the browser can render them well:\n npx setup-agent ${url} ask --preset framework\n npx setup-agent ${url} ask --preset llm-provider\nThe setup's products are starting names and guide references. Explore each product's setup instructions, then discover and plan any other relevant products or dependencies the app needs. Read /catalog.md on the guide URL’s origin to find related products and fetch their setup guides. The starting list does not restrict the implementation or require adding another product to the list. Include relevant additions in the plan for approval.\nWhen the setup puts an assistant in the app, ask how users should access it after discovering the actual app and before proposing the plan. Skip this question when no product's guide installs an assistant (a standalone library or service setup, for example). Use an entry-point question with only 1–3 sensible alternatives. Describe the actual app's pages, workflow and component placement, not generic placeholder copy. Recommend one clear fit when there is one; two options may use the same form factor in different places. Each option needs a stable id, label, contextual description and entryPoint {\"formFactor\":\"modal\"|\"sidebar\"|\"full-page\",\"placement\":\"where it appears\",\"trigger\":\"how users open it or navigate to it\",\"recommended\":true?}. Write the JSON array for this app and send it with:\n npx setup-agent ${url} ask \"Where should users access the assistant?\" --entry-points '<JSON array>' --wait\nMark a clear fit with \"recommended\":true rather than --default, so the user makes the pick. When you ask it, do not submit the plan before the user picks an entry point. Respect the selected placement and trigger in the plan and implementation. Do not ask for a new-versus-existing app setting; discover the app from its files and ask only for an install path when needed.\nSkip a preset the code already answers (a chat route on the AI SDK, a provider key in .env.local) and log why. Ask everything at once, keep investigating, and block with \"wait <input-id>\" only when nothing else can proceed. A framework answer is \"<framework>:<language>\", for example \"ai-sdk:typescript\". A model answer is JSON {\"provider\",\"model\",\"reasoningEffort\"?}. An answer may carry a \"note\" from the user; follow it. A choice answer that matches none of the options is the user's own text.\nThen write the plan as markdown and submit it:\n npx setup-agent ${url} plan --file <path> --wait\nUse these headings, each with bullets: \"## What I found\" (facts as \\`- **Label:** value\\`: app framework, package manager, agent framework, model provider and model, where components live), \"## What I will install\" (packages and files, one per bullet), \"## Steps\" (a numbered list, one line each), and \"## Open questions\" only if any remain. Keep it under 30 lines; no preamble. \"plan --wait\" prints {\"decision\":\"approve\"} or {\"decision\":\"revise\",\"feedback\":\"...\"}. On revise, address the feedback (ask again if you need to) and submit a new plan; repeat until approved. Do not change the project before approval: the setup refuses steps until then.\n\n2. Install. Declare the steps from your plan up front, in order:\n npx setup-agent ${url} add-step \"<title>\" --detail \"<one line>\"\nwhich prints the step id. Then work through them: \"step <id> active\" before, \"step <id> done --note '<one line on what you did>'\" after; \"skipped\" when the step is already satisfied, \"blocked\" when you cannot continue, saying why in --note. Add steps as the work reveals them. Ask when you need another decision or value (--choices for a pick, plain for text; --optional when you can proceed without an answer; --wait only when the answer is the very next thing you need). A choice question is multi-select: the user checks any number of your options, and the answer is an array of the ids they checked, plus their own text as an entry when they typed one. Pass --single only when the options exclude each other (one framework, one model, yes or no); the answer is then one id. Every option must carry an icon, given as --icons \"<id>=<icon>,...\" with the closest name from this pack: ${OPTION_ICONS.join(\", \")}. A question without an icon for each option is refused. Open inputs the user has not answered are listed under \"inputs\" in \"status\"; check them before asking again.\nThe API key behind a model answer is not in the answer and you never see it: pick the variable name the provider's SDK reads (OPENAI_API_KEY, ANTHROPIC_API_KEY, ...) and run\n npx setup-agent ${url} env <input-id> <ENV_VAR> --file .env.local\nwhich writes ENV_VAR=<key> into that file. Use the answer's model in the chat route and map reasoningEffort onto the provider's setting when it is set. Never invent a key or a model name.\n\nWhen every product is installed and verified, run\n npx setup-agent ${url} done --summary \"<one or two lines on what you installed and how to try it>\" --preview http://localhost:<port>\nBefore that, start the project's dev server in the background when the project has one, check that the page you changed loads, and pass the address as --preview (the page itself when it is not the root); leave the server running so the user can try the result. Omit --preview when there is nothing to open. This proposes closing the setup; only the user closes it. Do not stop the stream or exit: stay idle on it, because the user may follow up with a \"message.created\" event. Handle it, then run \"done\" again. The stream prints \"finished\" once the user closes the setup, and \"cancelled\" if they end it early. Keep the stream running after either: the user's next setup starts on this same URL and arrives as \"setup.created\" with its products. Run\n npx setup-agent ${url} wait start\nwhich returns once that setup begins, then run \"status\" for its products, guides and instructions and go through plan and install again. A \"setup.created\" event while you are still working means the user replaced this setup: drop what you were doing and start over the same way.\n`;\n};\n\nexport const INSTRUCTIONS = agentInstructions;\n\ntype Parsed = { positional: string[]; flags: Map<string, string | true> };\n\nconst parseArgs = (argv: readonly string[]): Parsed => {\n const positional: string[] = [];\n const flags = new Map<string, string | true>();\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i]!;\n if (!arg.startsWith(\"--\")) {\n positional.push(arg);\n continue;\n }\n const name = arg.slice(2);\n const next = argv[i + 1];\n if (next !== undefined && !next.startsWith(\"--\")) {\n flags.set(name, next);\n i++;\n } else {\n flags.set(name, true);\n }\n }\n return { positional, flags };\n};\n\nconst flagText = (flags: Parsed[\"flags\"], name: string) => {\n const value = flags.get(name);\n return typeof value === \"string\" ? value : undefined;\n};\n\nconst fail = (message: string): never => {\n process.stderr.write(`setup-agent: ${message}\\n`);\n return process.exit(1);\n};\n\nconst print = (value: unknown) => {\n process.stdout.write(`${JSON.stringify(value)}\\n`);\n};\n\nconst AGENT_ENV: readonly [kind: string, variable: string][] = [\n [\"claude\", \"CLAUDECODE\"],\n [\"codex\", \"CODEX_SANDBOX\"],\n [\"codex\", \"CODEX_SANDBOX_NETWORK_DISABLED\"],\n [\"cursor\", \"CURSOR_AGENT\"],\n [\"gemini\", \"GEMINI_CLI\"],\n];\n\n/** The coding agent this process runs under, from the variables each one exports to its shell. */\nexport const detectAgentKind = (env: NodeJS.ProcessEnv = process.env) =>\n AGENT_ENV.find(([, variable]) => env[variable])?.[0];\n\ntype Launcher = {\n kind: string;\n name: string;\n command: string;\n args: (prompt: string) => string[];\n install: string;\n};\n\nconst LAUNCHERS: Launcher[] = [\n {\n kind: \"claude\",\n name: \"Claude Code\",\n command: \"claude\",\n args: (prompt) => [prompt],\n install: \"npm install -g @anthropic-ai/claude-code\",\n },\n {\n kind: \"codex\",\n name: \"Codex\",\n command: \"codex\",\n args: (prompt) => [prompt],\n install: \"npm install -g @openai/codex\",\n },\n {\n kind: \"cursor\",\n name: \"Cursor\",\n command: \"agent\",\n args: (prompt) => [prompt],\n install: \"curl https://cursor.com/install -fsS | bash\",\n },\n {\n kind: \"gemini\",\n name: \"Gemini CLI\",\n command: \"gemini\",\n args: (prompt) => [\"-i\", prompt],\n install: \"npm install -g @google/gemini-cli\",\n },\n];\n\n/** True when a person typed the command into a terminal rather than an agent running it from its shell. */\nexport const isDirectInvocation = (\n env: NodeJS.ProcessEnv = process.env,\n stdin: { isTTY?: boolean | undefined } = process.stdin,\n stdout: { isTTY?: boolean | undefined } = process.stdout,\n) =>\n detectAgentKind(env) === undefined &&\n stdin.isTTY === true &&\n stdout.isTTY === true;\n\nconst chooseLauncher = async () => {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n try {\n process.stdout.write(\n \"This command is meant for a coding agent, and none is running here.\\nStart one to do the install:\\n\",\n );\n LAUNCHERS.forEach((launcher, index) => {\n process.stdout.write(` ${index + 1}. ${launcher.name}\\n`);\n });\n while (true) {\n const answer = (\n await rl.question(\"Choose [1]: \").catch(() => process.exit(1))\n ).trim();\n if (answer === \"\") return LAUNCHERS[0]!;\n const byNumber = LAUNCHERS[Number(answer) - 1];\n if (byNumber) return byNumber;\n const byName = LAUNCHERS.find(\n (launcher) =>\n launcher.kind === answer.toLowerCase() ||\n launcher.name.toLowerCase() === answer.toLowerCase(),\n );\n if (byName) return byName;\n process.stdout.write(\"Enter a number from the list.\\n\");\n }\n } finally {\n rl.close();\n }\n};\n\nconst launchAgent = async (url: string) => {\n const launcher = await chooseLauncher();\n const prompt = `Run \\`npx setup-agent ${shellWord(url)}\\` and follow the instructions it prints.`;\n process.stdout.write(`\\nStarting ${launcher.name}...\\n\\n`);\n const child = spawn(launcher.command, launcher.args(prompt), {\n stdio: \"inherit\",\n });\n const code = await new Promise<number>((resolve) => {\n child.on(\"error\", (error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") {\n process.stderr.write(\n `${launcher.name} is not installed. Install it with:\\n ${launcher.install}\\nthen run this command again.\\n`,\n );\n } else {\n process.stderr.write(`${error.message}\\n`);\n }\n resolve(1);\n });\n child.on(\"exit\", (status) => resolve(status ?? 1));\n });\n process.exit(code);\n};\n\nconst requireState = (client: CheckoutClient): Checkout.State =>\n client.state ?? fail(\"the setup has no state\");\n\nconst summary = (state: Checkout.State) => {\n const plan = currentPlan(state);\n return {\n status: state.status,\n agentConnected: isAgentPresent(state),\n products: state.products,\n instructions: state.instructions,\n plan:\n plan === undefined\n ? null\n : {\n revision: plan.revision,\n status: plan.status,\n ...(plan.feedback !== undefined && { feedback: plan.feedback }),\n },\n progress: stepProgress(state),\n steps: state.steps,\n inputs: state.inputs,\n log: state.log.slice(-20),\n pendingMessages: state.log.filter(\n (entry) => entry.role === \"user\" && entry.acknowledgedAt === undefined,\n ),\n };\n};\n\nconst STEP_STATUSES: readonly Checkout.StepStatus[] = [\n \"pending\",\n \"active\",\n \"done\",\n \"skipped\",\n \"blocked\",\n];\n\ntype StreamEvent =\n | { event: \"planning.started\" }\n | { event: \"message.created\"; messageId: string; text: string }\n | {\n event: \"input.answered\";\n inputId: string;\n prompt: string;\n /** The entries of a multiple choice answer, else the answer text. */\n answer: string | string[];\n note?: string;\n /** True when a choice answer is, or a multiple one contains, the user's own text rather than an option. */\n custom?: true;\n }\n | { event: \"input.dismissed\"; inputId: string; prompt: string }\n | { event: \"plan.approved\"; revision: number }\n | { event: \"plan.changes-requested\"; revision: number; feedback: string }\n | { event: \"finished\"; next: string }\n | { event: \"cancelled\"; next: string }\n | { event: \"setup.created\"; products: string[] };\n\nconst STAY_CONNECTED =\n \"This setup is over, not your connection. Keep the stream running, tell the user you are connected and waiting for their next setup, and run wait start.\";\n\nexport const diffEvents = (\n before: Checkout.State,\n after: Checkout.State,\n): StreamEvent[] => {\n const events: StreamEvent[] = [];\n if (before.status === \"waiting\" && after.status === \"planning\") {\n events.push({ event: \"planning.started\" });\n }\n for (const entry of after.log) {\n if (\n entry.role === \"user\" &&\n entry.acknowledgedAt === undefined &&\n !before.log.some((previous) => previous.id === entry.id)\n ) {\n events.push({\n event: \"message.created\",\n messageId: entry.id,\n text: entry.text,\n });\n }\n }\n for (const input of after.inputs) {\n const previous = before.inputs.find(\n (candidate) => candidate.id === input.id,\n );\n if (previous?.status === input.status) continue;\n if (input.status === \"answered\") {\n const answer = input.answer ?? \"\";\n events.push({\n event: \"input.answered\",\n inputId: input.id,\n prompt: input.prompt,\n ...answerFields(input, answer),\n });\n } else if (input.status === \"dismissed\" && after.status !== \"cancelled\") {\n events.push({\n event: \"input.dismissed\",\n inputId: input.id,\n prompt: input.prompt,\n });\n }\n }\n for (const plan of after.plans) {\n const previous = before.plans.find(\n (candidate) => candidate.revision === plan.revision,\n );\n if (previous?.status === plan.status || plan.status === \"proposed\") {\n continue;\n }\n if (plan.status === \"approved\") {\n events.push({ event: \"plan.approved\", revision: plan.revision });\n } else {\n events.push({\n event: \"plan.changes-requested\",\n revision: plan.revision,\n feedback: plan.feedback ?? \"\",\n });\n }\n }\n if (before.status !== \"done\" && after.status === \"done\") {\n events.push({ event: \"finished\", next: STAY_CONNECTED });\n }\n if (before.status !== \"cancelled\" && after.status === \"cancelled\") {\n events.push({ event: \"cancelled\", next: STAY_CONNECTED });\n }\n if (after.id !== null && after.id !== before.id) {\n events.push({\n event: \"setup.created\",\n products: after.products.map((product) => product.slug),\n });\n }\n return events;\n};\n\nconst stream = async (client: CheckoutClient) => {\n let previous = requireState(client);\n let pending: StreamEvent[] = diffEvents({ ...previous, log: [] }, previous);\n let timer: ReturnType<typeof setTimeout> | null = null;\n const flush = () => {\n timer = null;\n if (pending.length === 0) return;\n print(pending);\n pending = [];\n };\n client.subscribe(() => {\n const next = client.state;\n if (next === undefined) return;\n pending.push(...diffEvents(previous, next));\n previous = next;\n if (pending.length > 0 && timer === null) timer = setTimeout(flush, 200);\n });\n flush();\n const kind = detectAgentKind();\n await client.commands[\"agent/hello\"]({\n cwd: process.cwd(),\n ...(kind !== undefined && { kind }),\n });\n const heartbeat = setInterval(() => {\n void client.commands[\"agent/heartbeat\"]().catch(() => {});\n }, AGENT_HEARTBEAT_MS);\n const stop = () => {\n clearInterval(heartbeat);\n flush();\n void client.commands[\"agent/bye\"]()\n .catch(() => {})\n .finally(() => {\n client.dispose();\n process.exit(0);\n });\n };\n process.on(\"SIGHUP\", stop);\n process.on(\"SIGINT\", stop);\n process.on(\"SIGTERM\", stop);\n await new Promise(() => {});\n};\n\n/** Resolves once a setup is planning or installing, or once the one being waited on is cancelled; a setup already closed when the wait begins is over, so the wait is for the next one. */\nexport const waitForStart = (\n client: Pick<CheckoutClient, \"state\" | \"subscribe\">,\n) =>\n new Promise<Checkout.Status>((resolve) => {\n let previous: Checkout.Status | undefined;\n const check = () => {\n const state = client.state;\n if (state === undefined) return;\n const started =\n state.status === \"planning\" || state.status === \"installing\";\n const ended = isClosed(state) && previous === \"waiting\";\n previous = state.status;\n if (!started && !ended) return;\n unsubscribe();\n resolve(state.status);\n };\n const unsubscribe = client.subscribe(check);\n check();\n });\n\nconst waitForInput = (client: CheckoutClient, inputId: string) =>\n new Promise<Checkout.Input>((resolve) => {\n const check = () => {\n const state = client.state;\n const input = state?.inputs.find((candidate) => candidate.id === inputId);\n if (!input) return;\n if (input.status !== \"open\" || state?.status === \"cancelled\") {\n unsubscribe();\n resolve(input);\n }\n };\n const unsubscribe = client.subscribe(check);\n check();\n });\n\nconst waitForPlan = (client: CheckoutClient, revision: number) =>\n new Promise<Checkout.Plan | undefined>((resolve) => {\n const check = () => {\n const state = client.state;\n const plan = state?.plans.find(\n (candidate) => candidate.revision === revision,\n );\n if (\n plan === undefined ||\n plan.status !== \"proposed\" ||\n state?.status === \"cancelled\"\n ) {\n unsubscribe();\n resolve(plan);\n }\n };\n const unsubscribe = client.subscribe(check);\n check();\n });\n\nconst decided = (plan: Checkout.Plan | undefined, state: Checkout.State) => {\n if (state.status === \"cancelled\") return { ok: false, status: \"cancelled\" };\n if (plan === undefined) return fail(\"the plan disappeared\");\n return plan.status === \"approved\"\n ? { ok: true, decision: \"approve\", revision: plan.revision }\n : {\n ok: true,\n decision: \"revise\",\n revision: plan.revision,\n feedback: plan.feedback ?? \"\",\n };\n};\n\nconst splitList = (value: string | undefined) =>\n value\n ?.split(\",\")\n .map((entry) => entry.trim())\n .filter(Boolean);\n\nexport const askSeed = (\n rest: readonly string[],\n flags: Parsed[\"flags\"],\n): Checkout.InputSeed & { stepId?: string } => {\n const stepId = flagText(flags, \"step\");\n const optional = flags.has(\"optional\");\n const fallback = flagText(flags, \"default\");\n if (flags.has(\"entry-points\")) {\n if (\n [\n \"preset\",\n \"product\",\n \"choices\",\n \"icons\",\n \"multiple\",\n \"single\",\n \"only\",\n \"placeholder\",\n ].some((flag) => flags.has(flag))\n )\n return fail(\n \"--entry-points cannot be combined with other input kinds, --multiple, --single or --only\",\n );\n const json = flagText(flags, \"entry-points\");\n let value: unknown;\n try {\n value = JSON.parse(json ?? \"\");\n } catch {\n return fail(\"--entry-points needs a JSON array of options\");\n }\n const options = parseEntryPointOptions(value);\n if (!options)\n return fail(\n \"--entry-points needs 1–3 unique options with id, label, description and entryPoint {formFactor, placement, trigger, recommended?}; at most one is recommended\",\n );\n if (\n fallback !== undefined &&\n !options.some((option) => option.id === fallback)\n )\n return fail(`no option \"${fallback}\" to default to`);\n const prompt =\n rest[0] ?? fail(\"usage: ask <prompt> --entry-points '<JSON array>'\");\n if (prompt.trim() === \"\")\n return fail(\"an entry-point prompt cannot be empty\");\n return {\n kind: \"entry-point\",\n prompt,\n options,\n ...(fallback !== undefined && { default: fallback }),\n optional,\n ...(stepId !== undefined && { stepId }),\n };\n }\n const preset = flagText(flags, \"preset\");\n if (preset !== undefined) {\n if (!isPresetId(preset)) {\n return fail(\n `unknown preset \"${preset}\"; use ${Object.keys(INPUT_PRESETS).join(\" or \")}`,\n );\n }\n const only = splitList(flagText(flags, \"only\"));\n const found = splitList(flagText(flags, \"choices\"))?.map((entry) => {\n const [id = \"\", ...description] = entry.split(\"=\");\n return description.length === 0\n ? { id }\n : { id, description: description.join(\"=\") };\n });\n try {\n const seed = presetInput(preset, {\n ...(only !== undefined && { only }),\n ...(found !== undefined && { found }),\n ...(fallback !== undefined && { default: fallback }),\n optional,\n ...(stepId !== undefined && { stepId }),\n });\n return rest[0] === undefined ? seed : { ...seed, prompt: rest[0] };\n } catch (error) {\n return fail(error instanceof Error ? error.message : String(error));\n }\n }\n const prompt = rest[0] ?? fail(\"usage: ask <prompt>\");\n const product = flagText(flags, \"product\");\n if (product !== undefined) {\n return {\n kind: \"product\",\n prompt,\n product,\n optional,\n ...(stepId !== undefined && { stepId }),\n };\n }\n const choices = splitList(flagText(flags, \"choices\"));\n if (choices !== undefined) {\n if (flags.has(\"single\") && flags.has(\"multiple\"))\n return fail(\"--single and --multiple exclude each other\");\n const icons = new Map<string, string>();\n for (const entry of splitList(flagText(flags, \"icons\")) ?? []) {\n const [id = \"\", icon = \"\"] = entry.split(\"=\", 2);\n if (!choices.includes(id))\n return fail(`no choice \"${id}\" to put an icon on`);\n if (!isOptionIcon(icon)) {\n return fail(\n `unknown icon \"${icon}\"; pick one of ${OPTION_ICONS.join(\", \")}`,\n );\n }\n icons.set(id, icon);\n }\n const missing = choices.filter((id) => !icons.has(id));\n if (missing.length > 0) {\n return fail(\n `every option needs an icon; ${missing.map((id) => `\"${id}\"`).join(\", \")} ${missing.length === 1 ? \"has\" : \"have\"} none. Pass --icons \"${choices.map((id) => `${id}=<icon>`).join(\",\")}\" with icons from: ${OPTION_ICONS.join(\", \")}`,\n );\n }\n return {\n kind: \"choice\",\n prompt,\n options: choices.map((id) => ({ id, label: id, icon: icons.get(id)! })),\n ...(!flags.has(\"single\") && { multiple: true }),\n ...(fallback !== undefined && { default: fallback }),\n optional,\n ...(stepId !== undefined && { stepId }),\n };\n }\n const placeholder = flagText(flags, \"placeholder\");\n return {\n prompt,\n ...(placeholder !== undefined && { placeholder }),\n optional,\n ...(stepId !== undefined && { stepId }),\n };\n};\n\nconst assertEnvKey = (key: string) => {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {\n throw new Error(`\"${key}\" is not an environment variable name`);\n }\n};\n\n/** Sets `key=value` in dotenv text, replacing an existing line for the key. */\nexport const upsertEnvLine = (content: string, key: string, value: string) => {\n assertEnvKey(key);\n // A line break or other control character would end the line and let the\n // value write lines of its own.\n const isLineBreaking = (code: number) =>\n code < 0x20 ||\n (code >= 0x7f && code <= 0x9f) ||\n code === 0x2028 ||\n code === 0x2029;\n if ([...value].some((char) => isLineBreaking(char.charCodeAt(0)))) {\n throw new Error(`the value for ${key} must be a single line`);\n }\n const line = `${key}=${value}`;\n const lines = content === \"\" ? [] : content.replace(/\\n$/, \"\").split(\"\\n\");\n const index = lines.findIndex(\n (entry) =>\n /^(?:export\\s+)?([A-Za-z_][A-Za-z0-9_]*)\\s*=/.exec(entry)?.[1] === key,\n );\n if (index === -1) lines.push(line);\n else lines[index] = line;\n return `${lines.join(\"\\n\")}\\n`;\n};\n\n/**\n * Write the secret `take` returns to `file` under `key`, leaving the file\n * owner-only. The file is opened before `take` runs, because taking the\n * secret consumes it and an unwritable destination must fail while it is\n * still deposited; it is read after, so lines written meanwhile survive.\n */\nexport const writeEnvSecret = async (\n file: string,\n key: string,\n take: () => Promise<string>,\n projectRoot = process.cwd(),\n) => {\n assertEnvKey(key);\n try {\n if ((await lstat(file)).isSymbolicLink()) {\n throw new Error(\n `${file} is a symbolic link; pass --file with its target to write there`,\n );\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n }\n const projectRelative = relative(projectRoot, file);\n if (\n projectRelative !== \"..\" &&\n !projectRelative.startsWith(`..${sep}`) &&\n !isAbsolute(projectRelative)\n ) {\n const root = await realpath(projectRoot);\n const parent = await realpath(dirname(file));\n const parentRelative = relative(root, parent);\n if (\n parentRelative === \"..\" ||\n parentRelative.startsWith(`..${sep}`) ||\n isAbsolute(parentRelative)\n ) {\n throw new Error(`${file} has a parent directory outside the project`);\n }\n }\n const handle = await open(\n file,\n constants.O_RDWR |\n constants.O_APPEND |\n constants.O_CREAT |\n constants.O_NOFOLLOW,\n 0o600,\n ).catch((error: NodeJS.ErrnoException) => {\n if (error.code === \"ELOOP\")\n throw new Error(\n `${file} is a symbolic link; pass --file with its target to write there`,\n );\n throw error;\n });\n try {\n await handle.chmod(0o600);\n const value = await take();\n const current = await handle.readFile(\"utf8\");\n // Built before truncating, so a refused value leaves the file intact.\n const next = upsertEnvLine(current, key, value);\n await handle.truncate(0);\n await handle.writeFile(next);\n } finally {\n await handle.close();\n }\n};\n\nconst redeemKeyDirectories = () => {\n const stateHome =\n process.platform === \"win32\"\n ? process.env.LOCALAPPDATA || join(homedir(), \"AppData\", \"Local\")\n : process.env.XDG_STATE_HOME || join(homedir(), \".local\", \"state\");\n return [\n join(stateHome, \"setup-agent\"),\n join(\n tmpdir(),\n `setup-agent-${process.platform === \"win32\" ? userInfo().username : process.getuid!()}`,\n ),\n ];\n};\n\nconst checkRedeemKeyDirectory = async (directory: string) => {\n if (!isAbsolute(directory)) {\n throw new Error(\"state home must be an absolute path\");\n }\n const info = await lstat(directory);\n if (!info.isDirectory() || info.isSymbolicLink()) {\n throw new Error(\n `redeem key directory must not be a symbolic link: ${directory}`,\n );\n }\n if (process.platform !== \"win32\") {\n if (info.uid !== process.getuid!()) {\n throw new Error(\n `redeem key directory must be owned by the user: ${directory}`,\n );\n }\n if ((info.mode & 0o077) !== 0) await chmod(directory, 0o700);\n }\n};\n\nconst prepareRedeemKeyDirectory = async (directory: string) => {\n if (isAbsolute(directory)) {\n await mkdir(directory, { recursive: true, mode: 0o700 });\n }\n await checkRedeemKeyDirectory(directory);\n};\n\nconst saveRedeemKey = async (hash: string, key: string) => {\n let lastError: unknown;\n for (const directory of redeemKeyDirectories()) {\n const file = join(directory, `${hash}.key`);\n let created = false;\n try {\n await prepareRedeemKeyDirectory(directory);\n const handle = await open(\n file,\n constants.O_WRONLY |\n constants.O_CREAT |\n constants.O_EXCL |\n constants.O_NOFOLLOW,\n 0o600,\n );\n created = true;\n try {\n await handle.writeFile(key);\n } finally {\n await handle.close();\n }\n return file;\n } catch (error) {\n if (created) await unlink(file).catch(() => {});\n lastError = error;\n }\n }\n throw lastError;\n};\n\nconst readRedeemKey = async (hash: string) => {\n if (!/^[0-9a-f]{64}$/.test(hash)) return undefined;\n for (const directory of redeemKeyDirectories()) {\n try {\n await checkRedeemKeyDirectory(directory);\n const file = join(directory, `${hash}.key`);\n const handle = await open(\n file,\n constants.O_RDONLY | constants.O_NOFOLLOW,\n );\n try {\n const info = await handle.stat();\n if (\n !info.isFile() ||\n (process.platform !== \"win32\" && (info.mode & 0o077) !== 0)\n ) {\n throw new Error(\"redeem key file must be private and regular\");\n }\n const key = await handle.readFile(\"utf8\");\n if (createHash(\"sha256\").update(key).digest(\"hex\") === hash) {\n return { key, file };\n }\n } finally {\n await handle.close();\n }\n } catch {\n continue;\n }\n }\n return undefined;\n};\n\nconst answerFields = (input: Checkout.Input, answer: string) => ({\n answer: (input.multiple && parseMultipleAnswer(answer)) || answer,\n ...(input.note !== undefined && { note: input.note }),\n ...(input.kind === \"choice\" &&\n classifyChoiceAnswer(input, answer) === \"custom\" && {\n custom: true as const,\n }),\n});\n\nconst answered = (input: Checkout.Input) => ({\n ok: true,\n inputId: input.id,\n status: input.status,\n ...(input.answer !== undefined && answerFields(input, input.answer)),\n});\n\nexport const main = async (argv: readonly string[]) => {\n const { positional, flags } = parseArgs(argv);\n const [first, command = \"intro\", ...rest] = positional;\n if (flags.has(\"help\") || flags.has(\"h\") || first === undefined) {\n process.stdout.write(HELP);\n return process.exit(first === undefined ? 1 : 0);\n }\n let url: string;\n try {\n url = parseSetupUrl(first);\n } catch (error) {\n return fail(error instanceof Error ? error.message : String(error));\n }\n if (command === \"intro\" && isDirectInvocation()) return launchAgent(url);\n\n const client = await connectCheckout(url).catch((error: unknown) =>\n fail(error instanceof Error ? error.message : String(error)),\n );\n const commands = client.commands;\n\n try {\n switch (command) {\n case \"intro\": {\n const kind = detectAgentKind();\n await commands[\"agent/intro\"]({\n ...(kind !== undefined && { kind }),\n }).catch(() => {});\n process.stdout.write(INSTRUCTIONS(url));\n process.stdout.write(\"\\nCurrent setup:\\n\");\n print(summary(requireState(client)));\n break;\n }\n case \"status\": {\n print(summary(requireState(client)));\n break;\n }\n case \"stream\": {\n await stream(client);\n break;\n }\n case \"step\": {\n const usage =\n \"usage: step <step-id> <pending|active|done|skipped|blocked>\";\n const stepId = rest[0] ?? fail(usage);\n const status = rest[1];\n if (!STEP_STATUSES.includes(status as Checkout.StepStatus)) fail(usage);\n const note = flagText(flags, \"note\");\n await commands[\"agent/step\"]({\n stepId,\n status: status as Checkout.StepStatus,\n ...(note !== undefined && { note }),\n });\n print({ ok: true, stepId, status });\n break;\n }\n case \"add-step\": {\n const title = rest[0] ?? fail(\"usage: add-step <title>\");\n const detail = flagText(flags, \"detail\");\n const product = flagText(flags, \"product\");\n const result = await commands[\"agent/add-step\"]({\n title,\n ...(detail !== undefined && { detail }),\n ...(product !== undefined && { product }),\n ...(flags.has(\"active\") && { active: true }),\n });\n print({ ok: true, ...result });\n break;\n }\n case \"plan\": {\n const file = flagText(flags, \"file\");\n const markdown =\n file !== undefined\n ? await readFile(resolve(file), \"utf8\").catch(() =>\n fail(`could not read ${file}`),\n )\n : (rest[0] ?? fail(\"usage: plan <markdown> | plan --file <path>\"));\n const { revision } = await commands[\"agent/plan\"]({ markdown });\n if (!flags.has(\"wait\")) {\n print({ ok: true, revision });\n break;\n }\n const plan = await waitForPlan(client, revision);\n print(decided(plan, requireState(client)));\n break;\n }\n case \"ask\": {\n const seed = askSeed(rest, flags);\n const redeemKey =\n seed.kind === \"model\" ? randomBytes(32).toString(\"hex\") : undefined;\n const redeemKeyHash =\n redeemKey === undefined\n ? undefined\n : createHash(\"sha256\").update(redeemKey).digest(\"hex\");\n const keyFile =\n redeemKey === undefined || redeemKeyHash === undefined\n ? undefined\n : await saveRedeemKey(redeemKeyHash, redeemKey).catch(\n (error: unknown) =>\n fail(\n `could not store the model redeem key: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n let inputId: string;\n try {\n ({ inputId } = await commands[\"agent/ask\"]({\n ...seed,\n ...(redeemKeyHash !== undefined && { redeemKeyHash }),\n }));\n } catch (error) {\n if (keyFile !== undefined) await unlink(keyFile).catch(() => {});\n throw error;\n }\n if (!flags.has(\"wait\")) {\n print({ ok: true, inputId });\n break;\n }\n print(await waitForInput(client, inputId).then(answered));\n break;\n }\n case \"wait\": {\n const target =\n rest[0] ?? fail(\"usage: wait start | wait <input-id> | wait plan\");\n const state = requireState(client);\n if (target === \"start\") {\n const status = await waitForStart(client);\n print({\n ok: status === \"planning\" || status === \"installing\",\n status,\n });\n break;\n }\n if (target === \"plan\") {\n const plan = currentPlan(state) ?? fail(\"no plan has been proposed\");\n print(\n decided(\n await waitForPlan(client, plan.revision),\n requireState(client),\n ),\n );\n break;\n }\n if (!state.inputs.some((input) => input.id === target)) {\n fail(`no input \"${target}\"`);\n }\n print(await waitForInput(client, target).then(answered));\n break;\n }\n case \"env\": {\n const usage = \"usage: env <input-id> <ENV_VAR> [--file <path>]\";\n const inputId = rest[0] ?? fail(usage);\n const envKey = rest[1] ?? fail(usage);\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(envKey)) {\n fail(`\"${envKey}\" is not an environment variable name`);\n }\n const state = requireState(client);\n const input =\n state.inputs.find((candidate) => candidate.id === inputId) ??\n fail(`no input \"${inputId}\"`);\n const setupId = state.id ?? fail(\"the setup has not been created yet\");\n if (isClosed(state)) {\n fail(\"the setup is not open\");\n }\n if (input.status !== \"answered\") {\n fail(`input \"${inputId}\" is ${input.status}`);\n }\n if (\n input.kind !== \"model\" ||\n !isValidModelAnswer(input, input.answer ?? \"\")\n ) {\n fail(`input \"${inputId}\" is not an llm-provider answer`);\n }\n const storedKey =\n input.redeemKeyHash === undefined\n ? undefined\n : await readRedeemKey(input.redeemKeyHash);\n if (input.redeemKeyHash !== undefined && storedKey === undefined) {\n fail(`no local redeem key for \"${inputId}\"`);\n }\n const file = resolve(flagText(flags, \"file\") ?? \".env.local\");\n await writeEnvSecret(file, envKey, async () => {\n const secretUrl = new URL(url);\n if (\n secretUrl.protocol !== \"https:\" &&\n !(\n secretUrl.protocol === \"http:\" &&\n isLoopbackHostname(secretUrl.hostname)\n )\n ) {\n fail(\"the key is only fetched over https\");\n }\n const response = await fetch(\n `${url.replace(/\\/$/, \"\")}/secret/${encodeURIComponent(inputId)}?setup=${encodeURIComponent(setupId)}`,\n storedKey === undefined\n ? undefined\n : { headers: { \"Setup-Agent-Redeem-Key\": storedKey.key } },\n );\n if (response.status === 403) {\n fail(`redeem key rejected for \"${inputId}\"`);\n }\n if (response.status === 404) {\n fail(\n `the key for \"${inputId}\" was already taken or never deposited`,\n );\n }\n if (!response.ok) fail(`could not fetch the key: ${response.status}`);\n const key = await response.text();\n // An API key is one word of letters, digits and a few separators;\n // anything else could break out of the env line, be read differently\n // by dotenv, or run as shell syntax when the file is sourced.\n if (!/^[A-Za-z0-9._~+/=:@%,-]+$/.test(key)) {\n fail(\"the deposited key is not a valid API key\");\n }\n return key;\n });\n if (storedKey !== undefined) {\n await unlink(storedKey.file).catch((error: NodeJS.ErrnoException) => {\n if (error.code !== \"ENOENT\") {\n process.stderr.write(\n `warning: could not remove a redeem key: ${error.message}\\n`,\n );\n }\n });\n }\n print({ ok: true, envKey, file });\n break;\n }\n case \"ack\": {\n const messageId = rest[0] ?? fail(\"usage: ack <message-id>\");\n await commands[\"agent/ack\"]({ messageId });\n print({ ok: true });\n break;\n }\n case \"log\": {\n const text = rest[0] ?? fail(\"usage: log <text>\");\n await commands[\"agent/log\"]({ text });\n print({ ok: true });\n break;\n }\n case \"done\": {\n const summary = flagText(flags, \"summary\");\n const preview = flagText(flags, \"preview\");\n await commands[\"agent/done\"]({\n ...(summary !== undefined && { summary }),\n ...(preview !== undefined && { preview }),\n });\n print({\n ok: true,\n status: \"proposed\",\n next: \"Keep the stream running and stay idle. The user closes the setup or sends a follow-up message.\",\n });\n break;\n }\n default:\n fail(`unknown command \"${command}\"\\n\\n${HELP}`);\n }\n } catch (error) {\n fail(error instanceof Error ? error.message : String(error));\n } finally {\n client.dispose();\n }\n};\n"],"mappings":";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from "statewire";
2
- //#region src/client.ts
2
+ // src/client.ts
3
3
  /** Attach to a setup by its base URL and resolve once its state has arrived. */
4
4
  const connectCheckout = (url) => new Promise((resolve, reject) => {
5
5
  let settled = false;
@@ -28,7 +28,6 @@ const connectCheckout = (url) => new Promise((resolve, reject) => {
28
28
  const unsubscribe = client.subscribe(settle);
29
29
  settle();
30
30
  });
31
- //#endregion
32
31
  export { connectCheckout };
33
32
 
34
33
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAmB;AAsc3C,6EAA6E;AAC7E,eAAO,MAAM,YAAY,GAAI,WAAW,OAAO;;;;0BARrB,MAAM,IAAI;EASC,CAAC;AAEtC,YAAY,EAAE,QAAQ,EAAE,sBAAmB"}
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAmB;AAwd3C,6EAA6E;AAC7E,eAAO,MAAM,YAAY,GAAI,WAAW,OAAO;;;;0BARrB,MAAM,IAAI;EASC,CAAC;AAEtC,YAAY,EAAE,QAAQ,EAAE,sBAAmB"}
package/dist/host.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { classifyChoiceAnswer, currentPlan, initialCheckoutState, isAgentPresent, isClosed, isValidEntryPointAnswer, isValidEntryPointInput, isValidModelAnswer, parseEntryPointOptions, parsePreviewUrl } from "./protocol.js";
2
2
  import { resource } from "@assistant-ui/tap";
3
3
  import { StatewireReject, getStateHost, useStatewireCommands, useStatewireState } from "statewire/host";
4
- //#region src/host.ts
4
+ // src/host.ts
5
5
  const reject = (reason, message) => new StatewireReject(message, { payload: { reason } });
6
6
  const useCheckoutHost = (restored) => {
7
7
  const [state] = useStatewireState(() => {
@@ -47,6 +47,7 @@ const useCheckoutHost = (restored) => {
47
47
  };
48
48
  const ask = (seed) => {
49
49
  const kind = seed.kind ?? "text";
50
+ if (seed.redeemKeyHash !== void 0 && (kind !== "model" || !/^[0-9a-f]{64}$/.test(seed.redeemKeyHash))) throw reject("invalid-input", "invalid model redeem key hash");
50
51
  const options = kind === "entry-point" ? parseEntryPointOptions(seed.options) : seed.options;
51
52
  if (kind === "entry-point" && !isValidEntryPointInput(seed)) throw reject("invalid-input", "an entry-point input needs a prompt and 1–3 distinct options with descriptions, form factors, placements and triggers; at most one is recommended");
52
53
  if (kind === "product") {
@@ -73,6 +74,7 @@ const useCheckoutHost = (restored) => {
73
74
  ...kind === "product" && { product: seed.product },
74
75
  ...seed.default !== void 0 && { default: seed.default },
75
76
  ...seed.help !== void 0 && { help: seed.help },
77
+ ...seed.redeemKeyHash !== void 0 && { redeemKeyHash: seed.redeemKeyHash },
76
78
  optional: seed.optional ?? false,
77
79
  status: "open",
78
80
  ...stepId !== void 0 && { stepId },
@@ -181,6 +183,7 @@ const useCheckoutHost = (restored) => {
181
183
  requireOpen();
182
184
  const plan = currentPlan(state);
183
185
  if (plan === void 0) throw reject("no-plan", "the agent has not proposed a plan yet");
186
+ if (params.id !== void 0 && params.id !== state.id || params.revision !== void 0 && params.revision !== plan.revision) throw reject("stale-plan", "review the current setup plan before deciding");
184
187
  if (plan.status !== "proposed") throw reject("plan-decided", `the plan is already ${plan.status}`);
185
188
  if (params.decision === "approve") {
186
189
  plan.status = "approved";
@@ -292,7 +295,6 @@ const useCheckoutHost = (restored) => {
292
295
  };
293
296
  /** The setup statewire host; pass the durable object's restored snapshot. */
294
297
  const CheckoutHost = (restored) => resource(useCheckoutHost)(restored);
295
- //#endregion
296
298
  export { CheckoutHost };
297
299
 
298
300
  //# sourceMappingURL=host.js.map
package/dist/host.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"host.js","names":[],"sources":["../src/host.ts"],"sourcesContent":["import { resource } from \"@assistant-ui/tap\";\nimport {\n StatewireReject,\n getStateHost,\n useStatewireCommands,\n useStatewireState,\n} from \"statewire/host\";\nimport {\n classifyChoiceAnswer,\n currentPlan,\n initialCheckoutState,\n isAgentPresent,\n isClosed,\n isValidModelAnswer,\n isValidEntryPointAnswer,\n isValidEntryPointInput,\n parseEntryPointOptions,\n parsePreviewUrl,\n} from \"./protocol\";\nimport type { Checkout } from \"./protocol\";\n\nconst reject = (reason: Checkout.RejectionReason, message: string) =>\n new StatewireReject(message, { payload: { reason } });\n\nconst useCheckoutHost = (restored: unknown) => {\n const [state] = useStatewireState<Checkout.State>(() => {\n const initial = initialCheckoutState();\n if (restored === undefined) return initial;\n const snapshot = restored as Partial<Checkout.State>;\n if (snapshot.version !== 2) return initial;\n return {\n ...initial,\n ...snapshot,\n agent: { ...initial.agent, ...snapshot.agent },\n };\n });\n\n const requireOpen = () => {\n if (state.createdAt === null) {\n throw reject(\"not-created\", \"the setup has not been created yet\");\n }\n if (isClosed(state)) {\n throw reject(\"closed\", `the setup is ${state.status}`);\n }\n };\n\n const requireStarted = () => {\n requireOpen();\n if (state.status === \"waiting\") {\n throw reject(\n \"planning-not-started\",\n 'ask the user to return to their browser and click \"Begin plan\"; wait with \"wait start\"',\n );\n }\n };\n\n const requireInstalling = () => {\n requireOpen();\n if (state.status !== \"installing\") {\n throw reject(\n \"plan-required\",\n \"steps run once the user has approved a plan; submit one with plan\",\n );\n }\n };\n\n const findStep = (stepId: string) => {\n const step = state.steps.find((candidate) => candidate.id === stepId);\n if (!step) throw reject(\"unknown-step\", `no step \"${stepId}\"`);\n return step;\n };\n\n const findInput = (inputId: string) => {\n const input = state.inputs.find((candidate) => candidate.id === inputId);\n if (!input) throw reject(\"unknown-input\", `no input \"${inputId}\"`);\n if (input.status !== \"open\") {\n throw reject(\"input-closed\", `input \"${inputId}\" is ${input.status}`);\n }\n return input;\n };\n\n const touchAgent = () => {\n state.agent.lastSeenAt = Date.now();\n state.agent.connected = true;\n };\n\n const ask = (seed: Checkout.InputSeed & { stepId?: string }) => {\n const kind = seed.kind ?? \"text\";\n const options =\n kind === \"entry-point\"\n ? parseEntryPointOptions(seed.options)\n : seed.options;\n if (kind === \"entry-point\" && !isValidEntryPointInput(seed)) {\n throw reject(\n \"invalid-input\",\n \"an entry-point input needs a prompt and 1–3 distinct options with descriptions, form factors, placements and triggers; at most one is recommended\",\n );\n }\n if (kind === \"product\") {\n if (!seed.product) {\n throw reject(\"invalid-input\", \"a product input names a product\");\n }\n if (state.products.some((product) => product.slug === seed.product)) {\n throw reject(\n \"invalid-input\",\n `\"${seed.product}\" is already part of this setup`,\n );\n }\n } else if (kind !== \"text\" && !seed.options?.length) {\n throw reject(\"invalid-input\", `a ${kind} input needs options`);\n }\n if (\n seed.multiple &&\n (kind !== \"choice\" ||\n seed.options?.some((option) => option.variants?.length))\n ) {\n throw reject(\n \"invalid-input\",\n \"only a choice whose options have no variants accepts several answers\",\n );\n }\n const unique = (ids: readonly string[]) => new Set(ids).size === ids.length;\n if (\n !unique(seed.options?.map((option) => option.id) ?? []) ||\n seed.options?.some(\n (option) =>\n !unique(option.variants?.map((variant) => variant.id) ?? []),\n )\n ) {\n throw reject(\"invalid-input\", \"option and variant ids must be unique\");\n }\n if (\n seed.options?.some(\n (option) =>\n option.id.includes(\":\") ||\n option.variants?.some((variant) => variant.id.includes(\":\")),\n )\n ) {\n throw reject(\n \"invalid-input\",\n 'option and variant ids cannot contain \":\", which separates them in an answer',\n );\n }\n if (\n seed.default !== undefined &&\n !seed.options?.some((option) => option.id === seed.default)\n ) {\n throw reject(\n \"invalid-input\",\n `no option \"${seed.default}\" to default to`,\n );\n }\n if (seed.stepId !== undefined) findStep(seed.stepId);\n const id = `q${state.inputs.length + 1}`;\n const stepId =\n seed.stepId ?? state.steps.find((step) => step.status === \"active\")?.id;\n state.inputs.push({\n id,\n phase: state.status,\n kind,\n ...(seed.preset !== undefined && { preset: seed.preset }),\n prompt: seed.prompt,\n ...(seed.placeholder !== undefined && { placeholder: seed.placeholder }),\n ...(options !== undefined && { options }),\n ...(seed.multiple && { multiple: true }),\n ...(kind === \"product\" && { product: seed.product }),\n ...(seed.default !== undefined && { default: seed.default }),\n ...(seed.help !== undefined && { help: seed.help }),\n optional: seed.optional ?? false,\n status: \"open\",\n ...(stepId !== undefined && { stepId }),\n createdAt: Date.now(),\n });\n return { inputId: id };\n };\n\n const dismissOpenInputs = () => {\n for (const input of state.inputs) {\n if (input.status === \"open\") {\n input.status = \"dismissed\";\n input.answeredAt = Date.now();\n }\n }\n };\n\n const log = (text: string, stepId?: string) => {\n state.log.push({\n id: `l${state.log.length + 1}`,\n role: \"agent\",\n phase: state.status,\n at: Date.now(),\n text,\n ...(stepId !== undefined && { stepId }),\n });\n };\n\n const updateStep = (\n step: Checkout.Step,\n status: Checkout.StepStatus,\n note?: string,\n ) => {\n const changed = step.status !== status;\n step.status = status;\n if (note !== undefined) step.note = note;\n if (changed && (status === \"done\" || status === \"skipped\")) {\n log(\n `${status === \"done\" ? \"Completed\" : \"Skipped\"}: ${step.title}${step.note ? `\\n\\n${step.note}` : \"\"}`,\n step.id,\n );\n }\n };\n\n const commands = useStatewireCommands<Checkout.Commands>({\n \"checkout/create\": ({ id, products, instructions }) => {\n if (state.id === id) {\n throw reject(\"already-created\", \"the setup already exists\");\n }\n const fresh = initialCheckoutState();\n if (!isAgentPresent(state)) state.agent = fresh.agent;\n state.id = id;\n state.status = fresh.status;\n delete state.completion;\n state.plans = fresh.plans;\n state.steps = fresh.steps;\n state.inputs = fresh.inputs;\n state.log = fresh.log;\n state.createdAt = Date.now();\n state.instructions = instructions?.trim() ?? \"\";\n state.products = products.map((product) => ({\n slug: product.slug,\n name: product.name,\n ...(product.guide !== undefined && { guide: product.guide }),\n }));\n },\n \"checkout/begin-plan\": () => {\n requireOpen();\n if (state.status === \"waiting\") state.status = \"planning\";\n },\n \"checkout/answer\": ({ inputId, answer, note }) => {\n requireOpen();\n const input = findInput(inputId);\n if (\n input.kind === \"choice\" &&\n classifyChoiceAnswer(input, answer) === \"invalid\"\n ) {\n throw reject(\n \"invalid-answer\",\n input.multiple\n ? `\"${answer}\" is not a JSON array of option ids`\n : `\"${answer}\" names an option without a valid variant`,\n );\n }\n if (\n input.kind === \"entry-point\" &&\n !isValidEntryPointAnswer(input, answer)\n ) {\n throw reject(\"invalid-answer\", \"an entry-point answer is an option id\");\n }\n if (input.kind === \"model\" && !isValidModelAnswer(input, answer)) {\n throw reject(\n \"invalid-answer\",\n \"a model answer is JSON with provider and model\",\n );\n }\n if (input.kind === \"product\") {\n throw reject(\n \"invalid-answer\",\n \"a product input is answered with checkout/add-product\",\n );\n }\n if (input.kind === \"text\" && answer.trim() === \"\") {\n throw reject(\"invalid-answer\", \"an answer cannot be empty\");\n }\n input.status = \"answered\";\n input.answeredAt = Date.now();\n input.answer = answer;\n if (note !== undefined && note.trim() !== \"\") input.note = note.trim();\n },\n \"checkout/add-product\": ({ inputId, product }) => {\n requireOpen();\n const input = findInput(inputId);\n if (input.kind !== \"product\" || input.product !== product.slug) {\n throw reject(\n \"invalid-answer\",\n `input \"${inputId}\" does not propose \"${product.slug}\"`,\n );\n }\n if (!state.products.some((entry) => entry.slug === product.slug)) {\n state.products.push({\n slug: product.slug,\n name: product.name,\n ...(product.guide !== undefined && { guide: product.guide }),\n });\n }\n input.status = \"answered\";\n input.answer = \"added\";\n input.answeredAt = Date.now();\n },\n \"checkout/message\": ({ text }) => {\n requireOpen();\n if (text.trim() === \"\")\n throw reject(\"empty-message\", \"a message cannot be empty\");\n const stepId = state.steps.find((step) => step.status === \"active\")?.id;\n state.log.push({\n id: `l${state.log.length + 1}`,\n role: \"user\",\n phase: state.status,\n ...(stepId !== undefined && { stepId }),\n at: Date.now(),\n text: text.trim(),\n });\n },\n \"agent/ack\": ({ messageId }) => {\n requireOpen();\n const message = state.log.find(\n (entry) => entry.id === messageId && entry.role === \"user\",\n );\n if (!message)\n throw reject(\"unknown-message\", `no user message \"${messageId}\"`);\n message.acknowledgedAt ??= Date.now();\n },\n \"checkout/dismiss\": ({ inputId }) => {\n requireOpen();\n const input = findInput(inputId);\n input.status = \"dismissed\";\n input.answeredAt = Date.now();\n },\n \"checkout/plan\": (params) => {\n requireOpen();\n const plan = currentPlan(state);\n if (plan === undefined) {\n throw reject(\"no-plan\", \"the agent has not proposed a plan yet\");\n }\n if (plan.status !== \"proposed\") {\n throw reject(\"plan-decided\", `the plan is already ${plan.status}`);\n }\n if (params.decision === \"approve\") {\n plan.status = \"approved\";\n plan.decidedAt = Date.now();\n state.status = \"installing\";\n return;\n }\n if (params.feedback.trim() === \"\") {\n throw reject(\"feedback-required\", \"say what should change\");\n }\n plan.status = \"changes-requested\";\n plan.decidedAt = Date.now();\n plan.feedback = params.feedback.trim();\n },\n \"checkout/cancel\": ({ id } = {}) => {\n if (state.createdAt === null || isClosed(state)) return;\n if (id !== undefined && id !== state.id) return;\n state.status = \"cancelled\";\n dismissOpenInputs();\n },\n \"checkout/finish\": () => {\n requireOpen();\n if (state.completion === undefined) {\n throw reject(\n \"finish-not-proposed\",\n \"the agent has not proposed to finish yet\",\n );\n }\n dismissOpenInputs();\n state.status = \"done\";\n log(\"Setup complete.\");\n },\n \"agent/intro\": ({ kind } = {}) => {\n requireOpen();\n if (state.agent.introducedAt === null) {\n state.agent.introducedAt = Date.now();\n }\n if (kind !== undefined) state.agent.kind = kind;\n },\n \"agent/hello\": ({ cwd, kind } = {}) => {\n touchAgent();\n if (cwd !== undefined) state.agent.cwd = cwd;\n if (kind !== undefined) state.agent.kind = kind;\n },\n \"agent/heartbeat\": () => {\n touchAgent();\n },\n \"agent/bye\": () => {\n state.agent.connected = false;\n },\n \"agent/plan\": ({ markdown }) => {\n requireStarted();\n touchAgent();\n if (markdown.trim() === \"\") {\n throw reject(\"empty-plan\", \"the plan is empty\");\n }\n if (state.status === \"installing\") {\n throw reject(\"plan-decided\", \"the plan is already approved\");\n }\n const revision = state.plans.length + 1;\n state.plans.push({\n revision,\n markdown: markdown.trim(),\n status: \"proposed\",\n submittedAt: Date.now(),\n });\n return { revision };\n },\n \"agent/add-step\": ({ title, detail, product, active }) => {\n requireInstalling();\n if (product !== undefined && product.trim() === \"\") {\n throw reject(\n \"invalid-input\",\n \"a step's product identifier cannot be empty\",\n );\n }\n const id = `s${state.steps.length + 1}`;\n state.steps.push({\n id,\n title,\n ...(detail !== undefined && { detail }),\n status: active ? \"active\" : \"pending\",\n ...(product !== undefined && { product }),\n createdAt: Date.now(),\n });\n return { stepId: id };\n },\n \"agent/step\": ({ stepId, status, note }) => {\n requireInstalling();\n const step = findStep(stepId);\n updateStep(step, status, note);\n },\n \"agent/ask\": (seed) => {\n requireStarted();\n touchAgent();\n return ask(seed);\n },\n \"agent/log\": ({ text }) => {\n requireOpen();\n touchAgent();\n const stepId = state.steps.find((step) => step.status === \"active\")?.id;\n log(text, stepId);\n },\n \"agent/done\": ({ summary, preview } = {}) => {\n requireInstalling();\n const previewUrl = parsePreviewUrl(preview?.trim());\n if (preview !== undefined && !previewUrl) {\n throw reject(\n \"invalid-preview\",\n \"a preview is an http URL on localhost, such as http://localhost:3000\",\n );\n }\n touchAgent();\n for (const step of state.steps) {\n if (step.status === \"pending\" || step.status === \"active\") {\n updateStep(step, \"done\");\n }\n }\n log(summary?.trim() || \"Everything is installed.\");\n state.completion = {\n proposedAt: Date.now(),\n ...(previewUrl && { preview: previewUrl.href }),\n };\n },\n });\n\n const source = getStateHost(state)!;\n return {\n state,\n commands,\n snapshot: source.snapshot,\n subscribe: (listener: () => void) => {\n source.setOnChange(listener);\n return () => source.setOnChange(null);\n },\n };\n};\n\n/** The setup statewire host; pass the durable object's restored snapshot. */\nexport const CheckoutHost = (restored?: unknown) =>\n resource(useCheckoutHost)(restored);\n\nexport type { Checkout } from \"./protocol\";\n"],"mappings":";;;;AAqBA,MAAM,UAAU,QAAkC,YAChD,IAAI,gBAAgB,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAEtD,MAAM,mBAAmB,aAAsB;CAC7C,MAAM,CAAC,SAAS,wBAAwC;EACtD,MAAM,UAAU,qBAAqB;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IAAI,KAAK,WAAW,aAAa,KAAK,WAAW,UAC/C,WAAW,MAAM,MAAM;GAG3B,IAAI,SAAS,KAAK,KAAK,0BAA0B;GACjD,MAAM,aAAa;IACjB,YAAY,KAAK,IAAI;IACrB,GAAI,cAAc,EAAE,SAAS,WAAW,KAAK;GAC/C;EACF;CACF,CAAC;CAED,MAAM,SAAS,aAAa,KAAK;CACjC,OAAO;EACL;EACA;EACA,UAAU,OAAO;EACjB,YAAY,aAAyB;GACnC,OAAO,YAAY,QAAQ;GAC3B,aAAa,OAAO,YAAY,IAAI;EACtC;CACF;AACF;;AAGA,MAAa,gBAAgB,aAC3B,SAAS,eAAe,CAAC,CAAC,QAAQ"}
1
+ {"version":3,"file":"host.js","names":[],"sources":["../src/host.ts"],"sourcesContent":["import { resource } from \"@assistant-ui/tap\";\nimport {\n StatewireReject,\n getStateHost,\n useStatewireCommands,\n useStatewireState,\n} from \"statewire/host\";\nimport {\n classifyChoiceAnswer,\n currentPlan,\n initialCheckoutState,\n isAgentPresent,\n isClosed,\n isValidModelAnswer,\n isValidEntryPointAnswer,\n isValidEntryPointInput,\n parseEntryPointOptions,\n parsePreviewUrl,\n} from \"./protocol\";\nimport type { Checkout } from \"./protocol\";\n\nconst reject = (reason: Checkout.RejectionReason, message: string) =>\n new StatewireReject(message, { payload: { reason } });\n\nconst useCheckoutHost = (restored: unknown) => {\n const [state] = useStatewireState<Checkout.State>(() => {\n const initial = initialCheckoutState();\n if (restored === undefined) return initial;\n const snapshot = restored as Partial<Checkout.State>;\n if (snapshot.version !== 2) return initial;\n return {\n ...initial,\n ...snapshot,\n agent: { ...initial.agent, ...snapshot.agent },\n };\n });\n\n const requireOpen = () => {\n if (state.createdAt === null) {\n throw reject(\"not-created\", \"the setup has not been created yet\");\n }\n if (isClosed(state)) {\n throw reject(\"closed\", `the setup is ${state.status}`);\n }\n };\n\n const requireStarted = () => {\n requireOpen();\n if (state.status === \"waiting\") {\n throw reject(\n \"planning-not-started\",\n 'ask the user to return to their browser and click \"Begin plan\"; wait with \"wait start\"',\n );\n }\n };\n\n const requireInstalling = () => {\n requireOpen();\n if (state.status !== \"installing\") {\n throw reject(\n \"plan-required\",\n \"steps run once the user has approved a plan; submit one with plan\",\n );\n }\n };\n\n const findStep = (stepId: string) => {\n const step = state.steps.find((candidate) => candidate.id === stepId);\n if (!step) throw reject(\"unknown-step\", `no step \"${stepId}\"`);\n return step;\n };\n\n const findInput = (inputId: string) => {\n const input = state.inputs.find((candidate) => candidate.id === inputId);\n if (!input) throw reject(\"unknown-input\", `no input \"${inputId}\"`);\n if (input.status !== \"open\") {\n throw reject(\"input-closed\", `input \"${inputId}\" is ${input.status}`);\n }\n return input;\n };\n\n const touchAgent = () => {\n state.agent.lastSeenAt = Date.now();\n state.agent.connected = true;\n };\n\n const ask = (seed: Checkout.InputSeed & { stepId?: string }) => {\n const kind = seed.kind ?? \"text\";\n if (\n seed.redeemKeyHash !== undefined &&\n (kind !== \"model\" || !/^[0-9a-f]{64}$/.test(seed.redeemKeyHash))\n ) {\n throw reject(\"invalid-input\", \"invalid model redeem key hash\");\n }\n const options =\n kind === \"entry-point\"\n ? parseEntryPointOptions(seed.options)\n : seed.options;\n if (kind === \"entry-point\" && !isValidEntryPointInput(seed)) {\n throw reject(\n \"invalid-input\",\n \"an entry-point input needs a prompt and 1–3 distinct options with descriptions, form factors, placements and triggers; at most one is recommended\",\n );\n }\n if (kind === \"product\") {\n if (!seed.product) {\n throw reject(\"invalid-input\", \"a product input names a product\");\n }\n if (state.products.some((product) => product.slug === seed.product)) {\n throw reject(\n \"invalid-input\",\n `\"${seed.product}\" is already part of this setup`,\n );\n }\n } else if (kind !== \"text\" && !seed.options?.length) {\n throw reject(\"invalid-input\", `a ${kind} input needs options`);\n }\n if (\n seed.multiple &&\n (kind !== \"choice\" ||\n seed.options?.some((option) => option.variants?.length))\n ) {\n throw reject(\n \"invalid-input\",\n \"only a choice whose options have no variants accepts several answers\",\n );\n }\n const unique = (ids: readonly string[]) => new Set(ids).size === ids.length;\n if (\n !unique(seed.options?.map((option) => option.id) ?? []) ||\n seed.options?.some(\n (option) =>\n !unique(option.variants?.map((variant) => variant.id) ?? []),\n )\n ) {\n throw reject(\"invalid-input\", \"option and variant ids must be unique\");\n }\n if (\n seed.options?.some(\n (option) =>\n option.id.includes(\":\") ||\n option.variants?.some((variant) => variant.id.includes(\":\")),\n )\n ) {\n throw reject(\n \"invalid-input\",\n 'option and variant ids cannot contain \":\", which separates them in an answer',\n );\n }\n if (\n seed.default !== undefined &&\n !seed.options?.some((option) => option.id === seed.default)\n ) {\n throw reject(\n \"invalid-input\",\n `no option \"${seed.default}\" to default to`,\n );\n }\n if (seed.stepId !== undefined) findStep(seed.stepId);\n const id = `q${state.inputs.length + 1}`;\n const stepId =\n seed.stepId ?? state.steps.find((step) => step.status === \"active\")?.id;\n state.inputs.push({\n id,\n phase: state.status,\n kind,\n ...(seed.preset !== undefined && { preset: seed.preset }),\n prompt: seed.prompt,\n ...(seed.placeholder !== undefined && { placeholder: seed.placeholder }),\n ...(options !== undefined && { options }),\n ...(seed.multiple && { multiple: true }),\n ...(kind === \"product\" && { product: seed.product }),\n ...(seed.default !== undefined && { default: seed.default }),\n ...(seed.help !== undefined && { help: seed.help }),\n ...(seed.redeemKeyHash !== undefined && {\n redeemKeyHash: seed.redeemKeyHash,\n }),\n optional: seed.optional ?? false,\n status: \"open\",\n ...(stepId !== undefined && { stepId }),\n createdAt: Date.now(),\n });\n return { inputId: id };\n };\n\n const dismissOpenInputs = () => {\n for (const input of state.inputs) {\n if (input.status === \"open\") {\n input.status = \"dismissed\";\n input.answeredAt = Date.now();\n }\n }\n };\n\n const log = (text: string, stepId?: string) => {\n state.log.push({\n id: `l${state.log.length + 1}`,\n role: \"agent\",\n phase: state.status,\n at: Date.now(),\n text,\n ...(stepId !== undefined && { stepId }),\n });\n };\n\n const updateStep = (\n step: Checkout.Step,\n status: Checkout.StepStatus,\n note?: string,\n ) => {\n const changed = step.status !== status;\n step.status = status;\n if (note !== undefined) step.note = note;\n if (changed && (status === \"done\" || status === \"skipped\")) {\n log(\n `${status === \"done\" ? \"Completed\" : \"Skipped\"}: ${step.title}${step.note ? `\\n\\n${step.note}` : \"\"}`,\n step.id,\n );\n }\n };\n\n const commands = useStatewireCommands<Checkout.Commands>({\n \"checkout/create\": ({ id, products, instructions }) => {\n if (state.id === id) {\n throw reject(\"already-created\", \"the setup already exists\");\n }\n const fresh = initialCheckoutState();\n if (!isAgentPresent(state)) state.agent = fresh.agent;\n state.id = id;\n state.status = fresh.status;\n delete state.completion;\n state.plans = fresh.plans;\n state.steps = fresh.steps;\n state.inputs = fresh.inputs;\n state.log = fresh.log;\n state.createdAt = Date.now();\n state.instructions = instructions?.trim() ?? \"\";\n state.products = products.map((product) => ({\n slug: product.slug,\n name: product.name,\n ...(product.guide !== undefined && { guide: product.guide }),\n }));\n },\n \"checkout/begin-plan\": () => {\n requireOpen();\n if (state.status === \"waiting\") state.status = \"planning\";\n },\n \"checkout/answer\": ({ inputId, answer, note }) => {\n requireOpen();\n const input = findInput(inputId);\n if (\n input.kind === \"choice\" &&\n classifyChoiceAnswer(input, answer) === \"invalid\"\n ) {\n throw reject(\n \"invalid-answer\",\n input.multiple\n ? `\"${answer}\" is not a JSON array of option ids`\n : `\"${answer}\" names an option without a valid variant`,\n );\n }\n if (\n input.kind === \"entry-point\" &&\n !isValidEntryPointAnswer(input, answer)\n ) {\n throw reject(\"invalid-answer\", \"an entry-point answer is an option id\");\n }\n if (input.kind === \"model\" && !isValidModelAnswer(input, answer)) {\n throw reject(\n \"invalid-answer\",\n \"a model answer is JSON with provider and model\",\n );\n }\n if (input.kind === \"product\") {\n throw reject(\n \"invalid-answer\",\n \"a product input is answered with checkout/add-product\",\n );\n }\n if (input.kind === \"text\" && answer.trim() === \"\") {\n throw reject(\"invalid-answer\", \"an answer cannot be empty\");\n }\n input.status = \"answered\";\n input.answeredAt = Date.now();\n input.answer = answer;\n if (note !== undefined && note.trim() !== \"\") input.note = note.trim();\n },\n \"checkout/add-product\": ({ inputId, product }) => {\n requireOpen();\n const input = findInput(inputId);\n if (input.kind !== \"product\" || input.product !== product.slug) {\n throw reject(\n \"invalid-answer\",\n `input \"${inputId}\" does not propose \"${product.slug}\"`,\n );\n }\n if (!state.products.some((entry) => entry.slug === product.slug)) {\n state.products.push({\n slug: product.slug,\n name: product.name,\n ...(product.guide !== undefined && { guide: product.guide }),\n });\n }\n input.status = \"answered\";\n input.answer = \"added\";\n input.answeredAt = Date.now();\n },\n \"checkout/message\": ({ text }) => {\n requireOpen();\n if (text.trim() === \"\")\n throw reject(\"empty-message\", \"a message cannot be empty\");\n const stepId = state.steps.find((step) => step.status === \"active\")?.id;\n state.log.push({\n id: `l${state.log.length + 1}`,\n role: \"user\",\n phase: state.status,\n ...(stepId !== undefined && { stepId }),\n at: Date.now(),\n text: text.trim(),\n });\n },\n \"agent/ack\": ({ messageId }) => {\n requireOpen();\n const message = state.log.find(\n (entry) => entry.id === messageId && entry.role === \"user\",\n );\n if (!message)\n throw reject(\"unknown-message\", `no user message \"${messageId}\"`);\n message.acknowledgedAt ??= Date.now();\n },\n \"checkout/dismiss\": ({ inputId }) => {\n requireOpen();\n const input = findInput(inputId);\n input.status = \"dismissed\";\n input.answeredAt = Date.now();\n },\n \"checkout/plan\": (params) => {\n requireOpen();\n const plan = currentPlan(state);\n if (plan === undefined) {\n throw reject(\"no-plan\", \"the agent has not proposed a plan yet\");\n }\n if (\n (params.id !== undefined && params.id !== state.id) ||\n (params.revision !== undefined && params.revision !== plan.revision)\n ) {\n throw reject(\n \"stale-plan\",\n \"review the current setup plan before deciding\",\n );\n }\n if (plan.status !== \"proposed\") {\n throw reject(\"plan-decided\", `the plan is already ${plan.status}`);\n }\n if (params.decision === \"approve\") {\n plan.status = \"approved\";\n plan.decidedAt = Date.now();\n state.status = \"installing\";\n return;\n }\n if (params.feedback.trim() === \"\") {\n throw reject(\"feedback-required\", \"say what should change\");\n }\n plan.status = \"changes-requested\";\n plan.decidedAt = Date.now();\n plan.feedback = params.feedback.trim();\n },\n \"checkout/cancel\": ({ id } = {}) => {\n if (state.createdAt === null || isClosed(state)) return;\n if (id !== undefined && id !== state.id) return;\n state.status = \"cancelled\";\n dismissOpenInputs();\n },\n \"checkout/finish\": () => {\n requireOpen();\n if (state.completion === undefined) {\n throw reject(\n \"finish-not-proposed\",\n \"the agent has not proposed to finish yet\",\n );\n }\n dismissOpenInputs();\n state.status = \"done\";\n log(\"Setup complete.\");\n },\n \"agent/intro\": ({ kind } = {}) => {\n requireOpen();\n if (state.agent.introducedAt === null) {\n state.agent.introducedAt = Date.now();\n }\n if (kind !== undefined) state.agent.kind = kind;\n },\n \"agent/hello\": ({ cwd, kind } = {}) => {\n touchAgent();\n if (cwd !== undefined) state.agent.cwd = cwd;\n if (kind !== undefined) state.agent.kind = kind;\n },\n \"agent/heartbeat\": () => {\n touchAgent();\n },\n \"agent/bye\": () => {\n state.agent.connected = false;\n },\n \"agent/plan\": ({ markdown }) => {\n requireStarted();\n touchAgent();\n if (markdown.trim() === \"\") {\n throw reject(\"empty-plan\", \"the plan is empty\");\n }\n if (state.status === \"installing\") {\n throw reject(\"plan-decided\", \"the plan is already approved\");\n }\n const revision = state.plans.length + 1;\n state.plans.push({\n revision,\n markdown: markdown.trim(),\n status: \"proposed\",\n submittedAt: Date.now(),\n });\n return { revision };\n },\n \"agent/add-step\": ({ title, detail, product, active }) => {\n requireInstalling();\n if (product !== undefined && product.trim() === \"\") {\n throw reject(\n \"invalid-input\",\n \"a step's product identifier cannot be empty\",\n );\n }\n const id = `s${state.steps.length + 1}`;\n state.steps.push({\n id,\n title,\n ...(detail !== undefined && { detail }),\n status: active ? \"active\" : \"pending\",\n ...(product !== undefined && { product }),\n createdAt: Date.now(),\n });\n return { stepId: id };\n },\n \"agent/step\": ({ stepId, status, note }) => {\n requireInstalling();\n const step = findStep(stepId);\n updateStep(step, status, note);\n },\n \"agent/ask\": (seed) => {\n requireStarted();\n touchAgent();\n return ask(seed);\n },\n \"agent/log\": ({ text }) => {\n requireOpen();\n touchAgent();\n const stepId = state.steps.find((step) => step.status === \"active\")?.id;\n log(text, stepId);\n },\n \"agent/done\": ({ summary, preview } = {}) => {\n requireInstalling();\n const previewUrl = parsePreviewUrl(preview?.trim());\n if (preview !== undefined && !previewUrl) {\n throw reject(\n \"invalid-preview\",\n \"a preview is an http URL on localhost, such as http://localhost:3000\",\n );\n }\n touchAgent();\n for (const step of state.steps) {\n if (step.status === \"pending\" || step.status === \"active\") {\n updateStep(step, \"done\");\n }\n }\n log(summary?.trim() || \"Everything is installed.\");\n state.completion = {\n proposedAt: Date.now(),\n ...(previewUrl && { preview: previewUrl.href }),\n };\n },\n });\n\n const source = getStateHost(state)!;\n return {\n state,\n commands,\n snapshot: source.snapshot,\n subscribe: (listener: () => void) => {\n source.setOnChange(listener);\n return () => source.setOnChange(null);\n },\n };\n};\n\n/** The setup statewire host; pass the durable object's restored snapshot. */\nexport const CheckoutHost = (restored?: unknown) =>\n resource(useCheckoutHost)(restored);\n\nexport type { Checkout } from \"./protocol\";\n"],"mappings":";;;;AAqBA,MAAM,UAAU,QAAkC,YAChD,IAAI,gBAAgB,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAEtD,MAAM,mBAAmB,aAAsB;CAC7C,MAAM,CAAC,SAAS,wBAAwC;EACtD,MAAM,UAAU,qBAAqB;EACrC,IAAI,aAAa,KAAA,GAAW,OAAO;EACnC,MAAM,WAAW;EACjB,IAAI,SAAS,YAAY,GAAG,OAAO;EACnC,OAAO;GACL,GAAG;GACH,GAAG;GACH,OAAO;IAAE,GAAG,QAAQ;IAAO,GAAG,SAAS;GAAM;EAC/C;CACF,CAAC;CAED,MAAM,oBAAoB;EACxB,IAAI,MAAM,cAAc,MACtB,MAAM,OAAO,eAAe,oCAAoC;EAElE,IAAI,SAAS,KAAK,GAChB,MAAM,OAAO,UAAU,gBAAgB,MAAM,QAAQ;CAEzD;CAEA,MAAM,uBAAuB;EAC3B,YAA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,IAAI,SAAS,KAAK,KAAK,0BAA0B;GACjD,MAAM,aAAa;IACjB,YAAY,KAAK,IAAI;IACrB,GAAI,cAAc,EAAE,SAAS,WAAW,KAAK;GAC/C;EACF;CACF,CAAC;CAED,MAAM,SAAS,aAAa,KAAK;CACjC,OAAO;EACL;EACA;EACA,UAAU,OAAO;EACjB,YAAY,aAAyB;GACnC,OAAO,YAAY,QAAQ;GAC3B,aAAa,OAAO,YAAY,IAAI;EACtC;CACF;AACF;;AAGA,MAAa,gBAAgB,aAC3B,SAAS,eAAe,CAAC,CAAC,QAAQ"}
package/dist/presets.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/presets.ts
1
+ // src/presets.ts
2
2
  const TYPESCRIPT = {
3
3
  id: "typescript",
4
4
  label: "TypeScript"
@@ -170,7 +170,6 @@ const presetInput = (id, overrides = {}) => {
170
170
  ...overrides.stepId !== void 0 && { stepId: overrides.stepId }
171
171
  };
172
172
  };
173
- //#endregion
174
173
  export { INPUT_PRESETS, isPresetId, presetInput };
175
174
 
176
175
  //# sourceMappingURL=presets.js.map
@@ -86,6 +86,7 @@ export declare namespace Checkout {
86
86
  product?: string;
87
87
  default?: string;
88
88
  help?: InputHelp;
89
+ redeemKeyHash?: string;
89
90
  optional: boolean;
90
91
  status: InputStatus;
91
92
  answer?: string;
@@ -171,14 +172,20 @@ export declare namespace Checkout {
171
172
  product?: string;
172
173
  default?: string;
173
174
  help?: InputHelp;
175
+ redeemKeyHash?: string;
174
176
  optional?: boolean;
175
177
  };
176
178
  type PlanDecision = {
179
+ /** The setup the browser reviewed; omitted by legacy clients. */
180
+ id?: string;
181
+ /** The plan revision the browser reviewed; omitted by legacy clients. */
182
+ revision?: number;
183
+ } & ({
177
184
  decision: "approve";
178
185
  } | {
179
186
  decision: "revise";
180
187
  feedback: string;
181
- };
188
+ });
182
189
  type Commands = {
183
190
  "checkout/create": (params: {
184
191
  id: string;
@@ -251,7 +258,7 @@ export declare namespace Checkout {
251
258
  preview?: string;
252
259
  }) => void;
253
260
  };
254
- type RejectionReason = "already-created" | "not-created" | "closed" | "planning-not-started" | "plan-required" | "no-plan" | "plan-decided" | "finish-not-proposed" | "feedback-required" | "empty-plan" | "unknown-step" | "unknown-product" | "unknown-input" | "input-closed" | "invalid-input" | "invalid-answer" | "invalid-preview" | "empty-message" | "unknown-message";
261
+ type RejectionReason = "already-created" | "not-created" | "closed" | "planning-not-started" | "plan-required" | "no-plan" | "plan-decided" | "stale-plan" | "finish-not-proposed" | "feedback-required" | "empty-plan" | "unknown-step" | "unknown-product" | "unknown-input" | "input-closed" | "invalid-input" | "invalid-answer" | "invalid-preview" | "empty-message" | "unknown-message";
255
262
  }
256
263
  export declare const AGENT_PRESENCE_MS = 15000;
257
264
  export declare const AGENT_HEARTBEAT_MS = 5000;
@@ -267,6 +274,8 @@ export declare const followedUpSinceProposal: (state: Checkout.State) => boolean
267
274
  * machine's loopback interface. The browser opens it, so nothing else passes.
268
275
  */
269
276
  export declare const parsePreviewUrl: (value: string | undefined) => URL | undefined;
277
+ /** True for a hostname that names this machine. */
278
+ export declare const isLoopbackHostname: (hostname: string) => boolean;
270
279
  export declare const openInputs: (state: Checkout.State) => Checkout.Input[];
271
280
  /** The current plan revision, or `undefined` before the agent proposed one. */
272
281
  export declare const currentPlan: (state: Checkout.State) => Checkout.Plan | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,yBAAiB,QAAQ,CAAC;IACxB,KAAY,UAAU,GAClB,SAAS,GACT,QAAQ,GACR,MAAM,GACN,SAAS,GACT,SAAS,CAAC;IAEd,yEAAyE;IACzE,KAAY,IAAI,GAAG;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,UAAU,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,6DAA6D;QA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