setup-agent 0.0.3 → 0.0.5
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/LICENSE +21 -0
- package/README.md +11 -5
- package/dist/cli.d.ts +51 -46
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +81 -22
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +3 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +12 -4
- package/dist/client.js.map +1 -1
- package/dist/host.d.ts +7 -9
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +82 -75
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/presets.d.ts +23 -25
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +4 -3
- package/dist/presets.js.map +1 -1
- package/dist/protocol.d.ts +279 -262
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +35 -4
- package/dist/protocol.js.map +1 -1
- package/package.json +20 -13
- package/src/cli.test.ts +615 -0
- package/src/cli.ts +118 -29
- package/src/client.test.ts +54 -0
- package/src/client.ts +12 -4
- package/src/host.test.ts +1030 -0
- package/src/host.ts +52 -9
- package/src/index.ts +3 -0
- package/src/presets.ts +4 -3
- package/src/protocol.test.ts +128 -0
- package/src/protocol.ts +103 -5
package/dist/protocol.d.ts
CHANGED
|
@@ -1,272 +1,287 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
createdAt: number;
|
|
14
|
-
};
|
|
15
|
-
type Product = {
|
|
16
|
-
slug: string;
|
|
17
|
-
name: string;
|
|
18
|
-
/** The install reference the agent fetches while planning. */
|
|
19
|
-
guide?: string;
|
|
20
|
-
};
|
|
21
|
-
type InputStatus = "open" | "answered" | "dismissed";
|
|
22
|
-
/**
|
|
23
|
-
* product: the agent proposes adding a product to this checkout, such as one
|
|
24
|
-
* another product depends on. The browser owns the catalog, so it answers
|
|
25
|
-
* with `checkout/add-product`; dismissing the input declines.
|
|
26
|
-
*/
|
|
27
|
-
type InputKind = "text" | "choice" | "model" | "product";
|
|
28
|
-
type ChoiceVariant = {
|
|
29
|
-
id: string;
|
|
30
|
-
label: string;
|
|
31
|
-
};
|
|
32
|
-
type ChoiceOption = {
|
|
33
|
-
id: string;
|
|
34
|
-
label: string;
|
|
35
|
-
description?: string;
|
|
36
|
-
/** A name from OPTION_ICONS, or the key of a brand mark on a preset option; unknown keys render without one. */
|
|
37
|
-
icon?: string;
|
|
38
|
-
/** A second pick under this option, such as the language of a framework. */
|
|
39
|
-
variants?: ChoiceVariant[];
|
|
40
|
-
};
|
|
41
|
-
/** A short nudge for users who need help choosing, with a longer guide to link to. */
|
|
42
|
-
type InputHelp = {
|
|
43
|
-
summary: string;
|
|
44
|
-
href?: string;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* The answer to a model input, stored as JSON text. The API key itself is
|
|
48
|
-
* never part of it: the browser deposits it with the checkout and the
|
|
49
|
-
* agent's `env` command writes it straight to a file.
|
|
50
|
-
*/
|
|
51
|
-
type ModelAnswer = {
|
|
52
|
-
provider: string;
|
|
53
|
-
model: string;
|
|
54
|
-
reasoningEffort?: "low" | "medium" | "high";
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* A choice answer is an option id, `<option>:<variant>` when the option has
|
|
58
|
-
* variants, or the user's own text when none of the options fit; a multiple
|
|
59
|
-
* choice answers a JSON array of those. A model answer is a JSON-encoded
|
|
60
|
-
* ModelAnswer whose provider is one of the options.
|
|
61
|
-
*/
|
|
62
|
-
type Input = {
|
|
63
|
-
phase: Status;
|
|
64
|
-
id: string;
|
|
65
|
-
kind: InputKind;
|
|
66
|
-
/** The standard input this was built from, when it was. */
|
|
67
|
-
preset?: string;
|
|
68
|
-
prompt: string;
|
|
69
|
-
placeholder?: string;
|
|
70
|
-
options?: ChoiceOption[];
|
|
71
|
-
/** The user may pick any number of options; the answer is a JSON array. */
|
|
72
|
-
multiple?: true;
|
|
73
|
-
/** The slug a product input proposes. */
|
|
74
|
-
product?: string;
|
|
75
|
-
default?: string;
|
|
76
|
-
help?: InputHelp;
|
|
77
|
-
optional: boolean;
|
|
78
|
-
status: InputStatus;
|
|
79
|
-
answer?: string;
|
|
80
|
-
/** A remark the user attached to the answer. */
|
|
81
|
-
note?: string;
|
|
82
|
-
stepId?: string;
|
|
83
|
-
createdAt: number;
|
|
84
|
-
answeredAt?: number;
|
|
85
|
-
};
|
|
86
|
-
type LogEntry = {
|
|
87
|
-
phase: Status;
|
|
88
|
-
id: string;
|
|
89
|
-
role: "agent" | "user";
|
|
90
|
-
acknowledgedAt?: number;
|
|
91
|
-
at: number;
|
|
92
|
-
text: string;
|
|
93
|
-
/** The step that was active when the line was posted; none while planning. */
|
|
94
|
-
stepId?: string;
|
|
95
|
-
};
|
|
96
|
-
type PlanStatus = "proposed" | "approved" | "changes-requested";
|
|
97
|
-
/** One revision of the agent's plan. Markdown the browser renders. */
|
|
98
|
-
type Plan = {
|
|
99
|
-
revision: number;
|
|
100
|
-
markdown: string;
|
|
101
|
-
status: PlanStatus;
|
|
102
|
-
submittedAt: number;
|
|
103
|
-
decidedAt?: number;
|
|
104
|
-
/** What the user asked to change, when they did. */
|
|
105
|
-
feedback?: string;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* waiting: no agent has joined. planning: the agent investigates and
|
|
109
|
-
* proposes a plan. installing: the plan is approved and steps run.
|
|
110
|
-
*/
|
|
111
|
-
type Status = "waiting" | "planning" | "installing" | "done" | "cancelled";
|
|
112
|
-
/**
|
|
113
|
-
* The agent's proposal to close the checkout. Only the user closes it, and
|
|
114
|
-
* they may keep messaging the agent instead; a later `done` renews it.
|
|
115
|
-
* `preview` is the loopback URL of a dev server the agent left running for
|
|
116
|
-
* the user to try before they close.
|
|
117
|
-
*/
|
|
118
|
-
type Completion = {
|
|
119
|
-
proposedAt: number;
|
|
120
|
-
preview?: string;
|
|
121
|
-
};
|
|
122
|
-
type State = {
|
|
123
|
-
version: 2;
|
|
124
|
-
/** The id the browser gave the current checkout; a create with another id replaces it on the same link. */
|
|
125
|
-
id: string | null;
|
|
126
|
-
status: Status;
|
|
127
|
-
completion?: Completion;
|
|
128
|
-
createdAt: number | null;
|
|
129
|
-
products: Product[];
|
|
130
|
-
instructions: string;
|
|
131
|
-
agent: {
|
|
132
|
-
lastSeenAt: number | null;
|
|
133
|
-
/** False once the agent's stream said goodbye; heartbeats set it again. */
|
|
134
|
-
connected: boolean;
|
|
135
|
-
cwd: string | null;
|
|
136
|
-
/** The coding agent that ran the command, as the CLI detected it from its environment. */
|
|
137
|
-
kind: string | null;
|
|
138
|
-
/** When the command was first run against this checkout, before the agent joined the stream. */
|
|
139
|
-
introducedAt: number | null;
|
|
1
|
+
export declare namespace Checkout {
|
|
2
|
+
type StepStatus = "pending" | "active" | "done" | "skipped" | "blocked";
|
|
3
|
+
/** A unit of install work the agent declared; the catalog seeds none. */
|
|
4
|
+
type Step = {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
detail?: string;
|
|
8
|
+
status: StepStatus;
|
|
9
|
+
note?: string;
|
|
10
|
+
/** The product this step belongs to, when the agent said. */
|
|
11
|
+
product?: string;
|
|
12
|
+
createdAt: number;
|
|
140
13
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
};
|
|
147
|
-
type ProductSeed = {
|
|
148
|
-
slug: string;
|
|
149
|
-
name: string;
|
|
150
|
-
guide?: string;
|
|
151
|
-
};
|
|
152
|
-
type InputSeed = {
|
|
153
|
-
kind?: InputKind;
|
|
154
|
-
preset?: string;
|
|
155
|
-
prompt: string;
|
|
156
|
-
placeholder?: string;
|
|
157
|
-
options?: ChoiceOption[];
|
|
158
|
-
multiple?: true;
|
|
159
|
-
product?: string;
|
|
160
|
-
default?: string;
|
|
161
|
-
help?: InputHelp;
|
|
162
|
-
optional?: boolean;
|
|
163
|
-
};
|
|
164
|
-
type PlanDecision = {
|
|
165
|
-
decision: "approve";
|
|
166
|
-
} | {
|
|
167
|
-
decision: "revise";
|
|
168
|
-
feedback: string;
|
|
169
|
-
};
|
|
170
|
-
type Commands = {
|
|
171
|
-
"checkout/create": (params: {
|
|
172
|
-
id: string;
|
|
173
|
-
products: ProductSeed[];
|
|
174
|
-
instructions?: string;
|
|
175
|
-
}) => void;
|
|
176
|
-
"checkout/begin-plan": () => void;
|
|
177
|
-
"checkout/answer": (params: {
|
|
178
|
-
inputId: string;
|
|
179
|
-
answer: string;
|
|
180
|
-
note?: string;
|
|
181
|
-
}) => void;
|
|
182
|
-
"checkout/add-product": (params: {
|
|
183
|
-
inputId: string;
|
|
184
|
-
product: ProductSeed;
|
|
185
|
-
}) => void;
|
|
186
|
-
"checkout/message": (params: {
|
|
187
|
-
text: string;
|
|
188
|
-
}) => void;
|
|
189
|
-
"agent/ack": (params: {
|
|
190
|
-
messageId: string;
|
|
191
|
-
}) => void;
|
|
192
|
-
"checkout/dismiss": (params: {
|
|
193
|
-
inputId: string;
|
|
194
|
-
}) => void;
|
|
195
|
-
"checkout/plan": (params: PlanDecision) => void;
|
|
196
|
-
"checkout/cancel": () => void;
|
|
197
|
-
"checkout/finish": () => void;
|
|
198
|
-
"agent/intro": (params: {
|
|
199
|
-
kind?: string;
|
|
200
|
-
}) => void;
|
|
201
|
-
"agent/hello": (params: {
|
|
202
|
-
cwd?: string;
|
|
203
|
-
kind?: string;
|
|
204
|
-
}) => void;
|
|
205
|
-
"agent/heartbeat": () => void;
|
|
206
|
-
"agent/bye": () => void;
|
|
207
|
-
"agent/plan": (params: {
|
|
208
|
-
markdown: string;
|
|
209
|
-
}) => {
|
|
210
|
-
revision: number;
|
|
14
|
+
type Product = {
|
|
15
|
+
slug: string;
|
|
16
|
+
name: string;
|
|
17
|
+
/** The install reference the agent fetches while planning. */
|
|
18
|
+
guide?: string;
|
|
211
19
|
};
|
|
212
|
-
"
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
20
|
+
type InputStatus = "open" | "answered" | "dismissed";
|
|
21
|
+
/**
|
|
22
|
+
* product: the agent proposes adding a product to this checkout, such as one
|
|
23
|
+
* another product depends on. The browser owns the catalog, so it answers
|
|
24
|
+
* with `checkout/add-product`; dismissing the input declines.
|
|
25
|
+
*/
|
|
26
|
+
type InputKind = "text" | "choice" | "model" | "product" | "entry-point";
|
|
27
|
+
type EntryPoint = {
|
|
28
|
+
formFactor: "modal" | "sidebar" | "full-page";
|
|
29
|
+
placement: string;
|
|
30
|
+
trigger: string;
|
|
31
|
+
recommended?: boolean;
|
|
220
32
|
};
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
"agent/ask": (params: InputSeed & {
|
|
227
|
-
stepId?: string;
|
|
228
|
-
}) => {
|
|
229
|
-
inputId: string;
|
|
33
|
+
type EntryPointOption = {
|
|
34
|
+
id: string;
|
|
35
|
+
label: string;
|
|
36
|
+
description: string;
|
|
37
|
+
entryPoint: EntryPoint;
|
|
230
38
|
};
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
39
|
+
type ChoiceVariant = {
|
|
40
|
+
id: string;
|
|
41
|
+
label: string;
|
|
42
|
+
};
|
|
43
|
+
type ChoiceOption = {
|
|
44
|
+
id: string;
|
|
45
|
+
label: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
/** A name from OPTION_ICONS, or the key of a brand mark on a preset option; unknown keys render without one. */
|
|
48
|
+
icon?: string;
|
|
49
|
+
/** A second pick under this option, such as the language of a framework. */
|
|
50
|
+
variants?: ChoiceVariant[];
|
|
51
|
+
entryPoint?: EntryPoint;
|
|
52
|
+
};
|
|
53
|
+
/** A short nudge for users who need help choosing, with a longer guide to link to. */
|
|
54
|
+
type InputHelp = {
|
|
55
|
+
summary: string;
|
|
56
|
+
href?: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* The answer to a model input, stored as JSON text. The API key itself is
|
|
60
|
+
* never part of it: the browser deposits it with the checkout and the
|
|
61
|
+
* agent's `env` command writes it straight to a file.
|
|
62
|
+
*/
|
|
63
|
+
type ModelAnswer = {
|
|
64
|
+
provider: string;
|
|
65
|
+
model: string;
|
|
66
|
+
reasoningEffort?: "low" | "medium" | "high";
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A choice answer is an option id, `<option>:<variant>` when the option has
|
|
70
|
+
* variants, or the user's own text when none of the options fit; a multiple
|
|
71
|
+
* choice answers a JSON array of those. A model answer is a JSON-encoded
|
|
72
|
+
* ModelAnswer whose provider is one of the options.
|
|
73
|
+
*/
|
|
74
|
+
type Input = {
|
|
75
|
+
phase: Status;
|
|
76
|
+
id: string;
|
|
77
|
+
kind: InputKind;
|
|
78
|
+
/** The standard input this was built from, when it was. */
|
|
79
|
+
preset?: string;
|
|
80
|
+
prompt: string;
|
|
81
|
+
placeholder?: string;
|
|
82
|
+
options?: ChoiceOption[];
|
|
83
|
+
/** The user may pick any number of options; the answer is a JSON array. */
|
|
84
|
+
multiple?: true;
|
|
85
|
+
/** The slug a product input proposes. */
|
|
86
|
+
product?: string;
|
|
87
|
+
default?: string;
|
|
88
|
+
help?: InputHelp;
|
|
89
|
+
optional: boolean;
|
|
90
|
+
status: InputStatus;
|
|
91
|
+
answer?: string;
|
|
92
|
+
/** A remark the user attached to the answer. */
|
|
93
|
+
note?: string;
|
|
94
|
+
stepId?: string;
|
|
95
|
+
createdAt: number;
|
|
96
|
+
answeredAt?: number;
|
|
97
|
+
};
|
|
98
|
+
type LogEntry = {
|
|
99
|
+
phase: Status;
|
|
100
|
+
id: string;
|
|
101
|
+
role: "agent" | "user";
|
|
102
|
+
acknowledgedAt?: number;
|
|
103
|
+
at: number;
|
|
104
|
+
text: string;
|
|
105
|
+
/** The step that was active when the line was posted; none while planning. */
|
|
106
|
+
stepId?: string;
|
|
107
|
+
};
|
|
108
|
+
type PlanStatus = "proposed" | "approved" | "changes-requested";
|
|
109
|
+
/** One revision of the agent's plan. Markdown the browser renders. */
|
|
110
|
+
type Plan = {
|
|
111
|
+
revision: number;
|
|
112
|
+
markdown: string;
|
|
113
|
+
status: PlanStatus;
|
|
114
|
+
submittedAt: number;
|
|
115
|
+
decidedAt?: number;
|
|
116
|
+
/** What the user asked to change, when they did. */
|
|
117
|
+
feedback?: string;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* waiting: no agent has joined. planning: the agent investigates and
|
|
121
|
+
* proposes a plan. installing: the plan is approved and steps run.
|
|
122
|
+
*/
|
|
123
|
+
type Status = "waiting" | "planning" | "installing" | "done" | "cancelled";
|
|
124
|
+
/**
|
|
125
|
+
* The agent's proposal to close the checkout. Only the user closes it, and
|
|
126
|
+
* they may keep messaging the agent instead; a later `done` renews it.
|
|
127
|
+
* `preview` is the loopback URL of a dev server the agent left running for
|
|
128
|
+
* the user to try before they close.
|
|
129
|
+
*/
|
|
130
|
+
type Completion = {
|
|
131
|
+
proposedAt: number;
|
|
132
|
+
preview?: string;
|
|
133
|
+
};
|
|
134
|
+
type State = {
|
|
135
|
+
version: 2;
|
|
136
|
+
/** The id the browser gave the current checkout; a create with another id replaces it on the same link. */
|
|
137
|
+
id: string | null;
|
|
138
|
+
status: Status;
|
|
139
|
+
completion?: Completion;
|
|
140
|
+
createdAt: number | null;
|
|
141
|
+
products: Product[];
|
|
142
|
+
instructions: string;
|
|
143
|
+
agent: {
|
|
144
|
+
lastSeenAt: number | null;
|
|
145
|
+
/** False once the agent's stream said goodbye; heartbeats set it again. */
|
|
146
|
+
connected: boolean;
|
|
147
|
+
cwd: string | null;
|
|
148
|
+
/** The coding agent that ran the command, as the CLI detected it from its environment. */
|
|
149
|
+
kind: string | null;
|
|
150
|
+
/** When the command was first run against this checkout, before the agent joined the stream. */
|
|
151
|
+
introducedAt: number | null;
|
|
152
|
+
};
|
|
153
|
+
/** Every revision in order; the last one is current. */
|
|
154
|
+
plans: Plan[];
|
|
155
|
+
steps: Step[];
|
|
156
|
+
inputs: Input[];
|
|
157
|
+
log: LogEntry[];
|
|
158
|
+
};
|
|
159
|
+
type ProductSeed = {
|
|
160
|
+
slug: string;
|
|
161
|
+
name: string;
|
|
162
|
+
guide?: string;
|
|
163
|
+
};
|
|
164
|
+
type InputSeed = {
|
|
165
|
+
kind?: InputKind;
|
|
166
|
+
preset?: string;
|
|
167
|
+
prompt: string;
|
|
168
|
+
placeholder?: string;
|
|
169
|
+
options?: ChoiceOption[];
|
|
170
|
+
multiple?: true;
|
|
171
|
+
product?: string;
|
|
172
|
+
default?: string;
|
|
173
|
+
help?: InputHelp;
|
|
174
|
+
optional?: boolean;
|
|
175
|
+
};
|
|
176
|
+
type PlanDecision = {
|
|
177
|
+
decision: "approve";
|
|
178
|
+
} | {
|
|
179
|
+
decision: "revise";
|
|
180
|
+
feedback: string;
|
|
181
|
+
};
|
|
182
|
+
type Commands = {
|
|
183
|
+
"checkout/create": (params: {
|
|
184
|
+
id: string;
|
|
185
|
+
products: ProductSeed[];
|
|
186
|
+
instructions?: string;
|
|
187
|
+
}) => void;
|
|
188
|
+
"checkout/begin-plan": () => void;
|
|
189
|
+
"checkout/answer": (params: {
|
|
190
|
+
inputId: string;
|
|
191
|
+
answer: string;
|
|
192
|
+
note?: string;
|
|
193
|
+
}) => void;
|
|
194
|
+
"checkout/add-product": (params: {
|
|
195
|
+
inputId: string;
|
|
196
|
+
product: ProductSeed;
|
|
197
|
+
}) => void;
|
|
198
|
+
"checkout/message": (params: {
|
|
199
|
+
text: string;
|
|
200
|
+
}) => void;
|
|
201
|
+
"agent/ack": (params: {
|
|
202
|
+
messageId: string;
|
|
203
|
+
}) => void;
|
|
204
|
+
"checkout/dismiss": (params: {
|
|
205
|
+
inputId: string;
|
|
206
|
+
}) => void;
|
|
207
|
+
"checkout/plan": (params: PlanDecision) => void;
|
|
208
|
+
/** A cancel that names another checkout than the current one is a no-op. */
|
|
209
|
+
"checkout/cancel": (params?: {
|
|
210
|
+
id?: string;
|
|
211
|
+
}) => void;
|
|
212
|
+
"checkout/finish": () => void;
|
|
213
|
+
"agent/intro": (params: {
|
|
214
|
+
kind?: string;
|
|
215
|
+
}) => void;
|
|
216
|
+
"agent/hello": (params: {
|
|
217
|
+
cwd?: string;
|
|
218
|
+
kind?: string;
|
|
219
|
+
}) => void;
|
|
220
|
+
"agent/heartbeat": () => void;
|
|
221
|
+
"agent/bye": () => void;
|
|
222
|
+
"agent/plan": (params: {
|
|
223
|
+
markdown: string;
|
|
224
|
+
}) => {
|
|
225
|
+
revision: number;
|
|
226
|
+
};
|
|
227
|
+
"agent/add-step": (params: {
|
|
228
|
+
title: string;
|
|
229
|
+
detail?: string;
|
|
230
|
+
product?: string;
|
|
231
|
+
/** Start the step in the same call. */
|
|
232
|
+
active?: boolean;
|
|
233
|
+
}) => {
|
|
234
|
+
stepId: string;
|
|
235
|
+
};
|
|
236
|
+
"agent/step": (params: {
|
|
237
|
+
stepId: string;
|
|
238
|
+
status: StepStatus;
|
|
239
|
+
note?: string;
|
|
240
|
+
}) => void;
|
|
241
|
+
"agent/ask": (params: InputSeed & {
|
|
242
|
+
stepId?: string;
|
|
243
|
+
}) => {
|
|
244
|
+
inputId: string;
|
|
245
|
+
};
|
|
246
|
+
"agent/log": (params: {
|
|
247
|
+
text: string;
|
|
248
|
+
}) => void;
|
|
249
|
+
"agent/done": (params?: {
|
|
250
|
+
summary?: string;
|
|
251
|
+
preview?: string;
|
|
252
|
+
}) => void;
|
|
253
|
+
};
|
|
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";
|
|
240
255
|
}
|
|
241
|
-
declare const AGENT_PRESENCE_MS = 15000;
|
|
242
|
-
declare const AGENT_HEARTBEAT_MS = 5000;
|
|
243
|
-
declare const initialCheckoutState: () => Checkout.State;
|
|
244
|
-
declare const isAgentPresent: (state: Checkout.State, now?: number) => boolean;
|
|
245
|
-
declare const isClosed: (state: Checkout.State) => boolean;
|
|
256
|
+
export declare const AGENT_PRESENCE_MS = 15000;
|
|
257
|
+
export declare const AGENT_HEARTBEAT_MS = 5000;
|
|
258
|
+
export declare const initialCheckoutState: () => Checkout.State;
|
|
259
|
+
export declare const isAgentPresent: (state: Checkout.State, now?: number) => boolean;
|
|
260
|
+
export declare const isClosed: (state: Checkout.State) => boolean;
|
|
246
261
|
/** True while the agent's proposal to close waits for the user. */
|
|
247
|
-
declare const finishProposed: (state: Checkout.State) => boolean;
|
|
248
|
-
/** True
|
|
249
|
-
declare const followedUpSinceProposal: (state: Checkout.State) => boolean;
|
|
262
|
+
export declare const finishProposed: (state: Checkout.State) => boolean;
|
|
263
|
+
/** True while a message the user sent after the agent proposed to close still waits for the agent. */
|
|
264
|
+
export declare const followedUpSinceProposal: (state: Checkout.State) => boolean;
|
|
250
265
|
/**
|
|
251
266
|
* The URL a preview names, or `undefined` unless it is an http(s) URL on this
|
|
252
267
|
* machine's loopback interface. The browser opens it, so nothing else passes.
|
|
253
268
|
*/
|
|
254
|
-
declare const parsePreviewUrl: (value: string | undefined) => URL | undefined;
|
|
255
|
-
declare const openInputs: (state: Checkout.State) => Checkout.Input[];
|
|
269
|
+
export declare const parsePreviewUrl: (value: string | undefined) => URL | undefined;
|
|
270
|
+
export declare const openInputs: (state: Checkout.State) => Checkout.Input[];
|
|
256
271
|
/** The current plan revision, or `undefined` before the agent proposed one. */
|
|
257
|
-
declare const currentPlan: (state: Checkout.State) => Checkout.Plan | undefined;
|
|
272
|
+
export declare const currentPlan: (state: Checkout.State) => Checkout.Plan | undefined;
|
|
258
273
|
/** True while a proposed plan waits for the user's decision. */
|
|
259
|
-
declare const planNeedsReview: (state: Checkout.State) => boolean;
|
|
274
|
+
export declare const planNeedsReview: (state: Checkout.State) => boolean;
|
|
260
275
|
/** The icons an agent can put on its own options, by name. */
|
|
261
|
-
declare const OPTION_ICONS: readonly ["code", "terminal", "braces", "git-branch", "package", "database", "server", "cloud", "globe", "monitor", "smartphone", "key", "lock", "shield", "brain", "sparkles", "bot", "workflow", "file", "folder", "book", "table", "image", "video", "mic", "speech", "paperclip", "message", "mail", "bell", "calendar", "clock", "user", "users", "settings", "wrench", "plug", "link", "palette", "search", "zap", "check", "question"];
|
|
262
|
-
type OptionIcon = (typeof OPTION_ICONS)[number];
|
|
263
|
-
declare const isOptionIcon: (value: string) => value is OptionIcon;
|
|
264
|
-
declare const parseChoiceAnswer: (answer: string) => {
|
|
265
|
-
|
|
266
|
-
|
|
276
|
+
export declare const OPTION_ICONS: readonly ["code", "terminal", "braces", "git-branch", "package", "database", "server", "cloud", "globe", "monitor", "smartphone", "key", "lock", "shield", "brain", "sparkles", "bot", "workflow", "file", "folder", "book", "table", "image", "video", "mic", "speech", "paperclip", "message", "mail", "bell", "calendar", "clock", "user", "users", "settings", "wrench", "plug", "link", "palette", "search", "zap", "check", "question"];
|
|
277
|
+
export type OptionIcon = (typeof OPTION_ICONS)[number];
|
|
278
|
+
export declare const isOptionIcon: (value: string) => value is OptionIcon;
|
|
279
|
+
export declare const parseChoiceAnswer: (answer: string) => {
|
|
280
|
+
variant?: string;
|
|
281
|
+
option: string;
|
|
267
282
|
};
|
|
268
283
|
/** The entries of a multiple choice answer, or `undefined` when the text is not a JSON array of strings. */
|
|
269
|
-
declare const parseMultipleAnswer: (answer: string) => string[] | undefined;
|
|
284
|
+
export declare const parseMultipleAnswer: (answer: string) => string[] | undefined;
|
|
270
285
|
type ChoiceAnswerKind = "option" | "custom" | "invalid";
|
|
271
286
|
/**
|
|
272
287
|
* "option" when `answer` names one of the input's options (with a variant
|
|
@@ -275,15 +290,17 @@ type ChoiceAnswerKind = "option" | "custom" | "invalid";
|
|
|
275
290
|
* multiple choice is classified entry by entry: "invalid" when any entry is
|
|
276
291
|
* or the array is empty, "custom" when any entry is the user's own text.
|
|
277
292
|
*/
|
|
278
|
-
declare const classifyChoiceAnswer: (input: Checkout.Input, answer: string) => ChoiceAnswerKind;
|
|
293
|
+
export declare const classifyChoiceAnswer: (input: Checkout.Input, answer: string) => ChoiceAnswerKind;
|
|
294
|
+
export declare const parseEntryPointOptions: (value: unknown) => Checkout.EntryPointOption[] | undefined;
|
|
295
|
+
export declare const isValidEntryPointInput: (input: Checkout.InputSeed) => boolean;
|
|
296
|
+
export declare const isValidEntryPointAnswer: (input: Checkout.Input, answer: string) => boolean;
|
|
279
297
|
/** The model answer an input holds, or `undefined` when the text is not one. */
|
|
280
|
-
declare const parseModelAnswer: (answer: string) => Checkout.ModelAnswer | undefined;
|
|
298
|
+
export declare const parseModelAnswer: (answer: string) => Checkout.ModelAnswer | undefined;
|
|
281
299
|
/** Whether `answer` is a model answer naming one of the input's providers. */
|
|
282
|
-
declare const isValidModelAnswer: (input: Checkout.Input, answer: string) => boolean;
|
|
283
|
-
declare const stepProgress: (state: Checkout.State) => {
|
|
284
|
-
|
|
285
|
-
|
|
300
|
+
export declare const isValidModelAnswer: (input: Checkout.Input, answer: string) => boolean;
|
|
301
|
+
export declare const stepProgress: (state: Checkout.State) => {
|
|
302
|
+
total: number;
|
|
303
|
+
done: number;
|
|
286
304
|
};
|
|
287
|
-
|
|
288
|
-
export { AGENT_HEARTBEAT_MS, AGENT_PRESENCE_MS, Checkout, OPTION_ICONS, OptionIcon, classifyChoiceAnswer, currentPlan, finishProposed, followedUpSinceProposal, initialCheckoutState, isAgentPresent, isClosed, isOptionIcon, isValidModelAnswer, openInputs, parseChoiceAnswer, parseModelAnswer, parseMultipleAnswer, parsePreviewUrl, planNeedsReview, stepProgress };
|
|
305
|
+
export {};
|
|
289
306
|
//# sourceMappingURL=protocol.d.ts.map
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","
|
|
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;QAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAEF,KAAY,OAAO,GAAG;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,8DAA8D;QAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IAEF,KAAY,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;IAE5D;;;;OAIG;IACH,KAAY,SAAS,GACjB,MAAM,GACN,QAAQ,GACR,OAAO,GACP,SAAS,GACT,aAAa,CAAC;IAElB,KAAY,UAAU,GAAG;QACvB,UAAU,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;QAC9C,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC;IAEF,KAAY,gBAAgB,GAAG;QAC7B,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CA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;AAiBxD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,QAAQ,CAAC,KAAK,EACrB,QAAQ,MAAM,KACb,gBAOF,CAAC;AAKF,eAAO,MAAM,sBAAsB,GACjC,OAAO,OAAO,KACb,QAAQ,CAAC,gBAAgB,EAAE,GAAG,SA6ChC,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,OAAO,QAAQ,CAAC,SAAS,YAW/D,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,OAAO,QAAQ,CAAC,KAAK,EACrB,QAAQ,MAAM,YACmD,CAAC;AASpE,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,KACb,QAAQ,CAAC,WAAW,GAAG,SAoBzB,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,GAAI,OAAO,QAAQ,CAAC,KAAK,EAAE,QAAQ,MAAM,YAMvE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,QAAQ,CAAC,KAAK;;;CAKhD,CAAC"}
|
package/dist/protocol.js
CHANGED
|
@@ -24,10 +24,10 @@ const isAgentPresent = (state, now = Date.now()) => state.agent.connected && sta
|
|
|
24
24
|
const isClosed = (state) => state.status === "done" || state.status === "cancelled";
|
|
25
25
|
/** True while the agent's proposal to close waits for the user. */
|
|
26
26
|
const finishProposed = (state) => !isClosed(state) && state.completion !== void 0;
|
|
27
|
-
/** True
|
|
27
|
+
/** True while a message the user sent after the agent proposed to close still waits for the agent. */
|
|
28
28
|
const followedUpSinceProposal = (state) => {
|
|
29
29
|
const proposedAt = state.completion?.proposedAt;
|
|
30
|
-
return proposedAt !== void 0 && state.log.some((entry) => entry.role === "user" && entry.at > proposedAt);
|
|
30
|
+
return proposedAt !== void 0 && state.log.some((entry) => entry.role === "user" && entry.at > proposedAt && entry.acknowledgedAt === void 0);
|
|
31
31
|
};
|
|
32
32
|
const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
|
|
33
33
|
"localhost",
|
|
@@ -103,7 +103,9 @@ const OPTION_ICONS = [
|
|
|
103
103
|
];
|
|
104
104
|
const isOptionIcon = (value) => OPTION_ICONS.includes(value);
|
|
105
105
|
const parseChoiceAnswer = (answer) => {
|
|
106
|
-
const
|
|
106
|
+
const parts = answer.split(":");
|
|
107
|
+
if (parts.length > 2) return { option: answer };
|
|
108
|
+
const [option = "", variant] = parts;
|
|
107
109
|
return {
|
|
108
110
|
option,
|
|
109
111
|
...variant !== void 0 && { variant }
|
|
@@ -141,6 +143,35 @@ const classifyChoiceAnswer = (input, answer) => {
|
|
|
141
143
|
if (kinds.includes("invalid")) return "invalid";
|
|
142
144
|
return kinds.includes("custom") ? "custom" : "option";
|
|
143
145
|
};
|
|
146
|
+
const isEntryPointText = (value, max) => typeof value === "string" && value.trim() !== "" && value.length <= max;
|
|
147
|
+
const parseEntryPointOptions = (value) => {
|
|
148
|
+
if (!Array.isArray(value) || value.length < 1 || value.length > 3) return void 0;
|
|
149
|
+
const options = [];
|
|
150
|
+
for (const candidate of value) {
|
|
151
|
+
if (typeof candidate !== "object" || candidate === null) return void 0;
|
|
152
|
+
const { id, label, description, entryPoint, variants } = candidate;
|
|
153
|
+
if (typeof id !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/.test(id) || options.some((option) => option.id === id) || !isEntryPointText(label, 160) || !isEntryPointText(description, 1e3) || variants !== void 0 || typeof entryPoint !== "object" || entryPoint === null) return void 0;
|
|
154
|
+
const { formFactor, placement, trigger, recommended } = entryPoint;
|
|
155
|
+
if (formFactor !== "modal" && formFactor !== "sidebar" && formFactor !== "full-page" || !isEntryPointText(placement, 400) || !isEntryPointText(trigger, 400) || recommended !== void 0 && typeof recommended !== "boolean") return void 0;
|
|
156
|
+
options.push({
|
|
157
|
+
id,
|
|
158
|
+
label,
|
|
159
|
+
description,
|
|
160
|
+
entryPoint: {
|
|
161
|
+
formFactor,
|
|
162
|
+
placement,
|
|
163
|
+
trigger,
|
|
164
|
+
...recommended !== void 0 && { recommended }
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return options.filter((option) => option.entryPoint.recommended).length <= 1 ? options : void 0;
|
|
169
|
+
};
|
|
170
|
+
const isValidEntryPointInput = (input) => {
|
|
171
|
+
const options = parseEntryPointOptions(input.options);
|
|
172
|
+
return input.kind === "entry-point" && isEntryPointText(input.prompt, 1e3) && options !== void 0 && input.multiple === void 0 && input.help === void 0 && (input.default === void 0 || options.some((option) => option.id === input.default));
|
|
173
|
+
};
|
|
174
|
+
const isValidEntryPointAnswer = (input, answer) => input.options?.some((option) => option.id === answer) ?? false;
|
|
144
175
|
const REASONING_EFFORTS = /* @__PURE__ */ new Set([
|
|
145
176
|
"low",
|
|
146
177
|
"medium",
|
|
@@ -179,6 +210,6 @@ const stepProgress = (state) => ({
|
|
|
179
210
|
done: state.steps.filter((step) => step.status === "done" || step.status === "skipped").length
|
|
180
211
|
});
|
|
181
212
|
//#endregion
|
|
182
|
-
export { AGENT_HEARTBEAT_MS, AGENT_PRESENCE_MS, OPTION_ICONS, classifyChoiceAnswer, currentPlan, finishProposed, followedUpSinceProposal, initialCheckoutState, isAgentPresent, isClosed, isOptionIcon, isValidModelAnswer, openInputs, parseChoiceAnswer, parseModelAnswer, parseMultipleAnswer, parsePreviewUrl, planNeedsReview, stepProgress };
|
|
213
|
+
export { AGENT_HEARTBEAT_MS, AGENT_PRESENCE_MS, OPTION_ICONS, classifyChoiceAnswer, currentPlan, finishProposed, followedUpSinceProposal, initialCheckoutState, isAgentPresent, isClosed, isOptionIcon, isValidEntryPointAnswer, isValidEntryPointInput, isValidModelAnswer, openInputs, parseChoiceAnswer, parseEntryPointOptions, parseModelAnswer, parseMultipleAnswer, parsePreviewUrl, planNeedsReview, stepProgress };
|
|
183
214
|
|
|
184
215
|
//# sourceMappingURL=protocol.js.map
|