setup-agent 0.0.1
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/README.md +38 -0
- package/bin/setup-agent.js +4 -0
- package/dist/cli.d.ts +64 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +636 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +9 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +26 -0
- package/dist/client.js.map +1 -0
- package/dist/host.d.ts +12 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +291 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/presets.d.ts +32 -0
- package/dist/presets.d.ts.map +1 -0
- package/dist/presets.js +175 -0
- package/dist/presets.js.map +1 -0
- package/dist/protocol.d.ts +289 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +184 -0
- package/dist/protocol.js.map +1 -0
- package/package.json +60 -0
- package/src/cli.ts +799 -0
- package/src/client.ts +35 -0
- package/src/host.ts +435 -0
- package/src/index.ts +26 -0
- package/src/presets.ts +185 -0
- package/src/protocol.ts +479 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# setup-agent
|
|
2
|
+
|
|
3
|
+
One checkout, shared live between the browser that opened it and the coding agent installing its products. The state is a Statewire host (`setup-agent/host`) served from a Cloudflare Durable Object (`apps/checkout-worker`); the CLI (`npx setup-agent <url>`) is a thin Statewire client the agent drives from its shell.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx setup-agent <url> # instructions plus the current checkout
|
|
7
|
+
npx setup-agent <url> stream # one JSON array of events per line; run it under a Monitor
|
|
8
|
+
npx setup-agent <url> wait start # wait for the user to click Begin plan in their browser
|
|
9
|
+
npx setup-agent <url> log "Sure, I will keep the existing chat route" # a reply, or something no question or step conveys
|
|
10
|
+
npx setup-agent <url> ask --preset llm-provider --only openai,anthropic --default openai
|
|
11
|
+
npx setup-agent <url> ask "Where should assistant-ui live?" --optional # keep working; the answer arrives on the stream
|
|
12
|
+
npx setup-agent <url> ask "Which integrations?" --choices slack,email --icons "slack=message,email=mail" # multi-select; answers ["slack","email"]
|
|
13
|
+
npx setup-agent <url> ask "Which package manager?" --choices pnpm,npm --icons "pnpm=package,npm=package" --single # the options exclude each other; answers "pnpm"
|
|
14
|
+
npx setup-agent <url> wait q1 # block only when nothing else can proceed
|
|
15
|
+
npx setup-agent <url> plan --file plan.md --wait # {"decision":"approve"} or {"decision":"revise","feedback":"..."}
|
|
16
|
+
npx setup-agent <url> add-step "Install the packages" --detail "pnpm add ..." --active # prints {"stepId":"s1"}
|
|
17
|
+
npx setup-agent <url> step s1 done --note "installed"
|
|
18
|
+
npx setup-agent <url> env q2 OPENAI_API_KEY --file .env.local # write the key behind a model answer without seeing it
|
|
19
|
+
npx setup-agent <url> done --summary "installed the thread and a chat route" --preview http://localhost:3000
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Phases
|
|
23
|
+
|
|
24
|
+
A checkout opens `waiting` with its products and nothing else: no steps, no questions. After connecting, the agent tells the user to return to their browser and click **Begin plan**. It keeps the stream running and blocks on `wait start`. The browser sends `checkout/begin-plan`, moving the checkout to `planning` and emitting `planning.started` on the stream. Questions and plan submissions are refused while waiting. When a product needs another one the project lacks, the agent proposes it with `ask "<why>" --product <slug>`; the browser, which owns the catalog, accepts with `checkout/add-product` (the product and its guide join `products`, the input answers `added`) or dismisses the input. In `planning`, the agent investigates the project, asks what the code does not decide, and proposes a markdown plan with `plan` carrying its findings. `log` is for replying to the user and for what no question or step conveys. The user approves the plan or asks for changes with feedback; every revision is kept. Approval moves the checkout to `installing`, where the agent declares its own steps with `add-step` and works through them with `step`. `add-step` and `step` are refused before approval. `done` marks the remaining steps done and proposes closing, with an optional `--summary` and an optional `--preview <url>` naming a dev server the agent left running; a preview must be an http(s) URL on localhost, and the browser offers to open it. `done` does not close. The browser shows the proposal with a close action that sends `checkout/finish`, and the stream prints `finished`. Until then the agent stays idle on the stream, because the user may send a follow-up message; after handling one it runs `done` again to renew the proposal.
|
|
25
|
+
|
|
26
|
+
The URL is the browser's link to its agent, not one checkout. A finished or cancelled checkout stays on the link, and the browser's next setup replaces it with a new `checkout/create` carrying a new `id`: the plans, steps, inputs and log start over, the agent's presence carries across when it is still connected, and the stream prints `checkout.created` with the new products. The agent keeps the stream running after `finished` or `cancelled` and blocks on `wait start`, which returns once the next checkout begins planning; a checkout already closed when the wait begins is skipped rather than reported.
|
|
27
|
+
|
|
28
|
+
## Inputs
|
|
29
|
+
|
|
30
|
+
Every input is `text`, `choice` or `model`. A choice carries `options` (`id`, `label`, `description`, `icon`, `variants`), an optional `default` and a `help` note the browser renders as a "help me choose" disclosure. The answer is the option id, `<option>:<variant>` when the option has variants (`langgraph:python`), or the user's own text when none of the options fit; the stream marks that answer `custom`. An agent's own choice is multi-select unless asked with `--single`: the user checks any number of options (none may have variants), and the answer is a JSON array of those entries, which `wait` and the stream print as an array and `status` holds as text. `--single` is for options that exclude each other (one framework, one model, yes or no) and answers one id. Every one of the agent's own options must carry an `icon` from the pack `OPTION_ICONS` exports (`--icons "slack=message,email=mail"`); the CLI refuses the question otherwise. A preset option carries a brand mark instead. Every answer may carry a `note` from the user. A model input lists providers as its options; the browser collects the provider, its API key, the model and an optional reasoning effort, and the answer is that object as JSON (`{"provider","model","reasoningEffort"?}`); the API key is deposited separately and only ever reaches the env file the agent names through `env`.
|
|
31
|
+
|
|
32
|
+
Three standard choices ship as presets (`setup-agent` exports `INPUT_PRESETS` and `presetInput`), so the browser and the CLI agree on their options and brand marks:
|
|
33
|
+
|
|
34
|
+
- `framework`: Vercel AI SDK, Mastra, LangGraph, each with its language.
|
|
35
|
+
- `llm-provider`: OpenAI, Anthropic, Google Gemini, OpenRouter, xAI, Mistral, DeepSeek, Groq, Fireworks AI; defaults to OpenAI. Rendered as the model picker (provider, key, model, reasoning effort).
|
|
36
|
+
- `project`: the React projects the agent found, passed as `--choices "apps/web=Next.js,apps/admin"`, ahead of a fixed "New project" option whose second pick is the meta framework. Answers a path, or `new:<next|vite|react-router|tanstack-start|expo>`.
|
|
37
|
+
|
|
38
|
+
`--only` restricts a preset to some of its options (a single id locks the choice in) and `--default` preselects one.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Checkout } from "./protocol.js";
|
|
3
|
+
import { CheckoutClient } from "./client.js";
|
|
4
|
+
//#region src/cli.d.ts
|
|
5
|
+
type Parsed = {
|
|
6
|
+
positional: string[];
|
|
7
|
+
flags: Map<string, string | true>;
|
|
8
|
+
};
|
|
9
|
+
/** The coding agent this process runs under, from the variables each one exports to its shell. */
|
|
10
|
+
declare const detectAgentKind: (env?: NodeJS.ProcessEnv) => string | undefined;
|
|
11
|
+
/** True when a person typed the command into a terminal rather than an agent running it from its shell. */
|
|
12
|
+
declare const isDirectInvocation: (env?: NodeJS.ProcessEnv, stdin?: {
|
|
13
|
+
isTTY?: boolean | undefined;
|
|
14
|
+
}, stdout?: {
|
|
15
|
+
isTTY?: boolean | undefined;
|
|
16
|
+
}) => boolean;
|
|
17
|
+
type StreamEvent = {
|
|
18
|
+
event: "planning.started";
|
|
19
|
+
} | {
|
|
20
|
+
event: "message.created";
|
|
21
|
+
messageId: string;
|
|
22
|
+
text: string;
|
|
23
|
+
} | {
|
|
24
|
+
event: "input.answered";
|
|
25
|
+
inputId: string;
|
|
26
|
+
prompt: string;
|
|
27
|
+
/** The entries of a multiple choice answer, else the answer text. */
|
|
28
|
+
answer: string | string[];
|
|
29
|
+
note?: string;
|
|
30
|
+
/** True when a choice answer is, or a multiple one contains, the user's own text rather than an option. */
|
|
31
|
+
custom?: true;
|
|
32
|
+
} | {
|
|
33
|
+
event: "input.dismissed";
|
|
34
|
+
inputId: string;
|
|
35
|
+
prompt: string;
|
|
36
|
+
} | {
|
|
37
|
+
event: "plan.approved";
|
|
38
|
+
revision: number;
|
|
39
|
+
} | {
|
|
40
|
+
event: "plan.changes-requested";
|
|
41
|
+
revision: number;
|
|
42
|
+
feedback: string;
|
|
43
|
+
} | {
|
|
44
|
+
event: "finished";
|
|
45
|
+
next: string;
|
|
46
|
+
} | {
|
|
47
|
+
event: "cancelled";
|
|
48
|
+
next: string;
|
|
49
|
+
} | {
|
|
50
|
+
event: "checkout.created";
|
|
51
|
+
products: string[];
|
|
52
|
+
};
|
|
53
|
+
declare const diffEvents: (before: Checkout.State, after: Checkout.State) => StreamEvent[];
|
|
54
|
+
/** Resolves once a checkout is planning or installing, or once the one being waited on is cancelled; a checkout already closed when the wait begins is over, so the wait is for the next one. */
|
|
55
|
+
declare const waitForStart: (client: Pick<CheckoutClient, "state" | "subscribe">) => Promise<Checkout.Status>;
|
|
56
|
+
declare const askSeed: (rest: readonly string[], flags: Parsed["flags"]) => Checkout.InputSeed & {
|
|
57
|
+
stepId?: string;
|
|
58
|
+
};
|
|
59
|
+
/** Sets `key=value` in dotenv text, replacing an existing line for the key. */
|
|
60
|
+
declare const upsertEnvLine: (content: string, key: string, value: string) => string;
|
|
61
|
+
declare const main: (argv: readonly string[]) => Promise<undefined>;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { askSeed, detectAgentKind, diffEvents, isDirectInvocation, main, upsertEnvLine, waitForStart };
|
|
64
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","names":[],"sources":["../src/cli.ts"],"mappings":";;;KAsGK;EAAW;EAAsB,OAAO;;;cA8ChC,kBAAmB,MAAK,OAAO;;cA2C/B,qBACX,MAAK,OAAO,YACZ;EAAS;GACT;EAAU;;KA8FP;EACC;;EACA;EAA0B;EAAmB;;EAE7C;EACA;EACA;;EAEA;EACA;;EAEA;;EAEA;EAA0B;EAAiB;;EAC3C;EAAwB;;EACxB;EAAiC;EAAkB;;EACnD;EAAmB;;EACnB;EAAoB;;EACpB;EAA2B;;cAKpB,aACX,QAAQ,SAAS,OACjB,OAAO,SAAS,UACf;;cAkHU,eACX,QAAQ,KAAK,2CAAsC,QAAA,SAAA;cAyExC,UACX,yBACA,OAAO,oBACN,SAAS;EAAc;;;cAoFb,gBAAiB,iBAAiB,aAAa;cA2B/C,OAAc,4BAAuB"}
|