@stateset/sandbox-cli 3.3.1 → 3.4.0

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +351 -1
  3. package/dist/client.d.ts +29 -1
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +10 -0
  6. package/dist/client.js.map +1 -1
  7. package/dist/commands/run.d.ts.map +1 -1
  8. package/dist/commands/run.js +48 -15
  9. package/dist/commands/run.js.map +1 -1
  10. package/dist/commands/sandbox.d.ts.map +1 -1
  11. package/dist/commands/sandbox.js +62 -16
  12. package/dist/commands/sandbox.js.map +1 -1
  13. package/dist/commands/swarm.d.ts +12 -0
  14. package/dist/commands/swarm.d.ts.map +1 -0
  15. package/dist/commands/swarm.js +288 -0
  16. package/dist/commands/swarm.js.map +1 -0
  17. package/dist/commands/terminal.d.ts +3 -1
  18. package/dist/commands/terminal.d.ts.map +1 -1
  19. package/dist/commands/terminal.js +58 -1
  20. package/dist/commands/terminal.js.map +1 -1
  21. package/dist/commands/workbench.d.ts +138 -0
  22. package/dist/commands/workbench.d.ts.map +1 -0
  23. package/dist/commands/workbench.js +531 -0
  24. package/dist/commands/workbench.js.map +1 -0
  25. package/dist/index.js +5 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/utils/swarm-plan.d.ts +69 -0
  28. package/dist/utils/swarm-plan.d.ts.map +1 -0
  29. package/dist/utils/swarm-plan.js +321 -0
  30. package/dist/utils/swarm-plan.js.map +1 -0
  31. package/dist/utils/template-create.d.ts +36 -0
  32. package/dist/utils/template-create.d.ts.map +1 -0
  33. package/dist/utils/template-create.js +116 -0
  34. package/dist/utils/template-create.js.map +1 -0
  35. package/dist/workbench/actions.d.ts +1 -1
  36. package/dist/workbench/actions.d.ts.map +1 -1
  37. package/dist/workbench/actions.js +1 -0
  38. package/dist/workbench/actions.js.map +1 -1
  39. package/dist/workbench/agents.d.ts +96 -0
  40. package/dist/workbench/agents.d.ts.map +1 -0
  41. package/dist/workbench/agents.js +370 -0
  42. package/dist/workbench/agents.js.map +1 -0
  43. package/dist/workbench/commands.d.ts.map +1 -1
  44. package/dist/workbench/commands.js +7 -1
  45. package/dist/workbench/commands.js.map +1 -1
  46. package/dist/workbench/model.d.ts +5 -1
  47. package/dist/workbench/model.d.ts.map +1 -1
  48. package/dist/workbench/model.js +15 -2
  49. package/dist/workbench/model.js.map +1 -1
  50. package/dist/workbench/terminal.d.ts +1 -1
  51. package/dist/workbench/terminal.d.ts.map +1 -1
  52. package/dist/workbench/terminal.js +108 -78
  53. package/dist/workbench/terminal.js.map +1 -1
  54. package/package.json +2 -2
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,E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,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,qDAAqD;AACrD,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;IACvD,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC"}
@@ -0,0 +1,69 @@
1
+ import type { CreateSwarmOptions } from '@stateset/sandbox-sdk';
2
+ /** The most tasks the API takes in one swarm. */
3
+ export declare const MAX_SWARM_TASKS = 50;
4
+ /** The most characters of a swarm's name and of a task's name, after trimming. */
5
+ export declare const MAX_NAME_LENGTH = 128;
6
+ /** The most characters of a swarm's goal, after trimming. */
7
+ export declare const MAX_GOAL_LENGTH = 16000;
8
+ /** The most characters of a task's objective, after trimming. */
9
+ export declare const MAX_OBJECTIVE_LENGTH = 16000;
10
+ /** The most characters of a task's id, which the API calls its key. */
11
+ export declare const MAX_TASK_ID_LENGTH = 64;
12
+ /** The most characters of `repository` and of `defaults`, each as JSON. */
13
+ export declare const MAX_SETTINGS_LENGTH = 16384;
14
+ /** The most problems one check lists; a closing line counts the others. */
15
+ export declare const MAX_PROBLEMS = 20;
16
+ /** The largest plan file that is read, in bytes: 4 MB. */
17
+ export declare const MAX_PLAN_BYTES: number;
18
+ /**
19
+ * Check a plan and build the body of `POST /swarms` from it, under the name
20
+ * the caller gives the swarm. Pure: reads nothing but its arguments, and
21
+ * never throws.
22
+ *
23
+ * `request` is null exactly when there are problems. They are listed in the
24
+ * order of a plan file (the name, the goal, `repository`, `defaults`, then
25
+ * the tasks one by one, then the cycles), each as one sentence that names
26
+ * its task: by its id, or by its place when the id is wrong or already
27
+ * another task's.
28
+ *
29
+ * The body has the name and the goal trimmed, `repository` and `defaults` as
30
+ * given when the plan has them, and of every task its id as `key`, its name
31
+ * trimmed, its objective as written and its dependencies once each. Nothing
32
+ * else of the plan is in it.
33
+ */
34
+ export declare function checkSwarmPlan(plan: unknown, name: string): {
35
+ request: CreateSwarmOptions | null;
36
+ problems: string[];
37
+ };
38
+ /**
39
+ * The name of the swarm of a plan, before it is checked. Pure.
40
+ *
41
+ * It is the name asked for, `options.name`, when there is one: an empty or
42
+ * a blank one is kept, and `checkSwarmPlan` reports it. Else it is the
43
+ * plan's own `name` when that is a string, empty or not. Else it is the name
44
+ * of the plan file, `options.file`, without its directory and without a
45
+ * closing `.json`, when a file is given. Else it is undefined, which
46
+ * `checkSwarmPlan` reports as a name that is missing.
47
+ *
48
+ * An empty file name is a file name: the name it gives is empty, not
49
+ * undefined. A file named exactly `.json` gives an empty name as well when
50
+ * it is given without a directory, and the name `.json` when it is given
51
+ * with one (`plans/.json`).
52
+ */
53
+ export declare function swarmPlanName(plan: unknown, options?: {
54
+ name?: string;
55
+ file?: string;
56
+ }): string | undefined;
57
+ /**
58
+ * Read a plan file and return the body of `POST /swarms` for it. The swarm's
59
+ * name is `options.name`, else the plan's own `name`, else the name of the
60
+ * file without `.json`: see `swarmPlanName`.
61
+ *
62
+ * Throws a `CliError` that names the file as it was given when the file is
63
+ * missing, cannot be read, is over `MAX_PLAN_BYTES`, is not JSON, or holds a
64
+ * plan with problems: then the message has one line per problem.
65
+ */
66
+ export declare function readSwarmPlan(file: string, options?: {
67
+ name?: string;
68
+ }): CreateSwarmOptions;
69
+ //# sourceMappingURL=swarm-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swarm-plan.d.ts","sourceRoot":"","sources":["../../src/utils/swarm-plan.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAIhE,iDAAiD;AACjD,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,kFAAkF;AAClF,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,6DAA6D;AAC7D,eAAO,MAAM,eAAe,QAAQ,CAAC;AACrC,iEAAiE;AACjE,eAAO,MAAM,oBAAoB,QAAQ,CAAC;AAC1C,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAC1C,2EAA2E;AAC3E,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,0DAA0D;AAC1D,eAAO,MAAM,cAAc,QAAkB,CAAC;AA6L9C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAGtH;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,GAAG,SAAS,CAI/G;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,kBAAkB,CAwC/F"}
@@ -0,0 +1,321 @@
1
+ /**
2
+ * Read a swarm plan file, check it, and turn it into the body of
3
+ * `POST /swarms` (docs/API_REFERENCE.md, "Swarms").
4
+ *
5
+ * A plan file is what examples/claude-agent/swarm-plan.mjs writes, and it is
6
+ * not the API's body. A plan task has `id` where the API has `key`. A plan
7
+ * has no name, and the API requires one. A plan may hold more than the API
8
+ * takes: more and longer tasks, and the fields `sandbox`, `union`,
9
+ * `max_local` and a task's `files`, which the API's strict schema refuses.
10
+ * Those fields are left out of the body. Everything else the API would
11
+ * refuse is found here first, so that all of it is named at once, by task.
12
+ *
13
+ * The limits are those of `CreateSwarmSchema` in
14
+ * controller/src/schemas/swarm.ts: that schema decides, and a limit that
15
+ * changes there changes here.
16
+ */
17
+ import { readFileSync, statSync } from 'node:fs';
18
+ import { basename } from 'node:path';
19
+ import { CliError } from './errors.js';
20
+ import { inertText, limitText } from '../workbench/text.js';
21
+ /** The most tasks the API takes in one swarm. */
22
+ export const MAX_SWARM_TASKS = 50;
23
+ /** The most characters of a swarm's name and of a task's name, after trimming. */
24
+ export const MAX_NAME_LENGTH = 128;
25
+ /** The most characters of a swarm's goal, after trimming. */
26
+ export const MAX_GOAL_LENGTH = 16000;
27
+ /** The most characters of a task's objective, after trimming. */
28
+ export const MAX_OBJECTIVE_LENGTH = 16000;
29
+ /** The most characters of a task's id, which the API calls its key. */
30
+ export const MAX_TASK_ID_LENGTH = 64;
31
+ /** The most characters of `repository` and of `defaults`, each as JSON. */
32
+ export const MAX_SETTINGS_LENGTH = 16_384;
33
+ /** The most problems one check lists; a closing line counts the others. */
34
+ export const MAX_PROBLEMS = 20;
35
+ /** The largest plan file that is read, in bytes: 4 MB. */
36
+ export const MAX_PLAN_BYTES = 4 * 1024 * 1024;
37
+ const KEBAB = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
38
+ const CONTROLS = /[\p{Cc}\p{Cs}]/u;
39
+ /** A message shows this much of a value that is wrong. */
40
+ const SHOWN_LENGTH = 80;
41
+ const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
42
+ const count = (n, noun) => `${n} ${noun}${n === 1 ? '' : 's'}`;
43
+ /** A value as JSON; undefined for one that has none (a function, a BigInt, an object that holds itself). */
44
+ function asJson(value) {
45
+ try {
46
+ return JSON.stringify(value);
47
+ }
48
+ catch {
49
+ return undefined;
50
+ }
51
+ }
52
+ /** A value that is wrong, as a message shows it: the start of its JSON, with nothing a terminal acts on. */
53
+ const shown = (value) => inertText(limitText(asJson(value) ?? typeof value, SHOWN_LENGTH));
54
+ /**
55
+ * What is wrong with a text of the plan, as the rest of a sentence that
56
+ * starts with what the text is; undefined when nothing is. The length is
57
+ * that of the trimmed text, which is what the API counts.
58
+ */
59
+ function textProblem(value, limit, banned) {
60
+ if (typeof value !== 'string') {
61
+ return `${value === undefined ? 'is missing' : `is ${shown(value)}`}; it is a string of 1 to ${limit} characters`;
62
+ }
63
+ const text = value.trim();
64
+ if (text.length === 0)
65
+ return `is empty; it has 1 to ${limit} characters`;
66
+ if (text.length > limit)
67
+ return `is ${text.length} characters long; the limit is ${limit}`;
68
+ if (banned === 'control' && CONTROLS.test(text))
69
+ return 'has a control character in it; it is one line of plain text';
70
+ if (banned === 'NUL' && text.includes('\0'))
71
+ return 'has a NUL character in it; every other character is allowed';
72
+ return undefined;
73
+ }
74
+ /** What is wrong with `repository` or `defaults`, in the same form; undefined when nothing is, or when it is left out. */
75
+ function settingsProblem(value) {
76
+ if (value === undefined)
77
+ return undefined;
78
+ const json = isObject(value) ? asJson(value) : undefined;
79
+ if (json === undefined)
80
+ return `is ${shown(value)}; it is a JSON object, or left out`;
81
+ if (json.length > MAX_SETTINGS_LENGTH)
82
+ return `is ${json.length} characters as JSON; the limit is ${MAX_SETTINGS_LENGTH}`;
83
+ // The schema's own test: it refuses the escape wherever the JSON has it.
84
+ if (json.includes('\\u0000'))
85
+ return 'has a NUL character (\\u0000) in it; every other character is allowed';
86
+ return undefined;
87
+ }
88
+ /** Every dependency cycle a depth-first walk meets, each as the ids along it, the first one repeated at the end. */
89
+ function cycles(edges) {
90
+ const state = new Map();
91
+ const path = [];
92
+ const found = [];
93
+ const visit = (id) => {
94
+ state.set(id, 'open');
95
+ path.push(id);
96
+ for (const next of edges.get(id) ?? []) {
97
+ if (state.get(next) === 'open')
98
+ found.push([...path.slice(path.indexOf(next)), next]);
99
+ else if (!state.has(next))
100
+ visit(next);
101
+ }
102
+ path.pop();
103
+ state.set(id, 'done');
104
+ };
105
+ for (const id of edges.keys())
106
+ if (!state.has(id))
107
+ visit(id);
108
+ return found;
109
+ }
110
+ /** What is wrong with the tasks, task by task in the plan's order, and after them the cycles of their dependencies. */
111
+ function taskProblems(tasks) {
112
+ const problems = [];
113
+ // Every id a task has, usable or not: a dependency on a task whose id is wrong is not one more problem.
114
+ const written = new Set(tasks.map((task) => (isObject(task) ? task.id : undefined)));
115
+ const first = new Map();
116
+ const edges = new Map();
117
+ // False once an id or a dependency is wrong: what the tasks then wait for is not known, so no cycle is looked for.
118
+ let sound = true;
119
+ for (let index = 0; index < tasks.length; index += 1) {
120
+ const task = tasks[index];
121
+ const place = `Task ${index + 1}`;
122
+ if (!isObject(task)) {
123
+ problems.push(`${place} is ${shown(task)}; a task is an object with id, name, objective and depends_on.`);
124
+ sound = false;
125
+ continue;
126
+ }
127
+ const { id } = task;
128
+ const holder = typeof id === 'string' ? first.get(id) : undefined;
129
+ let usable;
130
+ if (typeof id !== 'string' || !KEBAB.test(id)) {
131
+ problems.push(`${place}: id ${id === undefined ? 'is missing; it is' : `${shown(id)} is not`} `
132
+ + `kebab-case (lowercase letters and digits joined by single hyphens, at most ${MAX_TASK_ID_LENGTH} characters).`);
133
+ }
134
+ else if (id.length > MAX_TASK_ID_LENGTH) {
135
+ problems.push(`${place}: id is ${id.length} characters long; the limit is ${MAX_TASK_ID_LENGTH}.`);
136
+ }
137
+ else if (holder !== undefined) {
138
+ problems.push(`${place}: id "${id}" is already the id of task ${holder + 1}; every task has an id of its own.`);
139
+ }
140
+ else {
141
+ first.set(id, index);
142
+ usable = id;
143
+ }
144
+ // A task is named by its id only when the id tells it from every other task.
145
+ const label = usable === undefined ? place : `Task "${usable}"`;
146
+ for (const [field, limit, banned] of [['name', MAX_NAME_LENGTH, 'control'], ['objective', MAX_OBJECTIVE_LENGTH, 'NUL']]) {
147
+ const problem = textProblem(task[field], limit, banned);
148
+ if (problem !== undefined)
149
+ problems.push(`${label}: ${field} ${problem}.`);
150
+ }
151
+ const dependencies = task.depends_on === undefined ? [] : task.depends_on;
152
+ const before = problems.length;
153
+ const known = [];
154
+ if (!Array.isArray(dependencies)) {
155
+ problems.push(`${label}: depends_on is ${shown(dependencies)}; it is a list of task ids, or left out.`);
156
+ }
157
+ else {
158
+ for (const dependency of new Set(dependencies)) {
159
+ if (typeof dependency !== 'string') {
160
+ problems.push(`${label}: depends_on holds ${shown(dependency)}; it is a list of task ids.`);
161
+ }
162
+ else if (dependency === id) {
163
+ problems.push(`${label}: depends_on names ${shown(id)}, the task itself; a task depends on other tasks only.`);
164
+ }
165
+ else if (!written.has(dependency)) {
166
+ problems.push(`${label}: depends_on names ${shown(dependency)}, which is not the id of a task in this plan.`);
167
+ }
168
+ else {
169
+ known.push(dependency);
170
+ }
171
+ }
172
+ }
173
+ if (usable === undefined || problems.length > before)
174
+ sound = false;
175
+ else
176
+ edges.set(usable, known);
177
+ }
178
+ if (sound) {
179
+ for (const cycle of cycles(edges)) {
180
+ problems.push(`The dependencies form a cycle: ${cycle.join(' -> ')}; a task cannot wait, directly or not, for itself.`);
181
+ }
182
+ }
183
+ return problems;
184
+ }
185
+ /** `checkSwarmPlan` with every problem listed, however many there are. */
186
+ function inspectPlan(plan, name) {
187
+ if (!isObject(plan) || !Array.isArray(plan.tasks)) {
188
+ return { request: null, problems: ['A swarm plan is a JSON object with its list of tasks in `tasks`.'] };
189
+ }
190
+ const tasks = plan.tasks;
191
+ const problems = [];
192
+ const check = (subject, problem) => {
193
+ if (problem !== undefined)
194
+ problems.push(`${subject} ${problem}.`);
195
+ };
196
+ check("The swarm's name", textProblem(name, MAX_NAME_LENGTH, 'control'));
197
+ check("The plan's goal", textProblem(plan.goal, MAX_GOAL_LENGTH, 'NUL'));
198
+ check("The plan's repository", settingsProblem(plan.repository));
199
+ check("The plan's defaults", settingsProblem(plan.defaults));
200
+ if (tasks.length < 1 || tasks.length > MAX_SWARM_TASKS) {
201
+ // Too many to be a swarm at all: nothing is gained by listing what is wrong with each.
202
+ problems.push(`The plan has ${count(tasks.length, 'task')}; a swarm has 1 to ${MAX_SWARM_TASKS}.`);
203
+ }
204
+ else {
205
+ problems.push(...taskProblems(tasks));
206
+ }
207
+ if (problems.length > 0)
208
+ return { request: null, problems };
209
+ const request = {
210
+ name: name.trim(),
211
+ goal: plan.goal.trim(),
212
+ ...(plan.repository === undefined ? {} : { repository: plan.repository }),
213
+ ...(plan.defaults === undefined ? {} : { defaults: plan.defaults }),
214
+ tasks: tasks.map((task) => ({
215
+ key: task.id,
216
+ name: task.name.trim(),
217
+ objective: task.objective,
218
+ depends_on: [...new Set(task.depends_on ?? [])],
219
+ })),
220
+ };
221
+ return { request, problems };
222
+ }
223
+ /** At most `MAX_PROBLEMS` of the problems, and after them how many more there are. */
224
+ function listed(problems) {
225
+ if (problems.length <= MAX_PROBLEMS)
226
+ return problems;
227
+ const more = problems.length - MAX_PROBLEMS;
228
+ return [...problems.slice(0, MAX_PROBLEMS), `${count(more, 'more problem')} ${more === 1 ? 'is' : 'are'} not listed.`];
229
+ }
230
+ /**
231
+ * Check a plan and build the body of `POST /swarms` from it, under the name
232
+ * the caller gives the swarm. Pure: reads nothing but its arguments, and
233
+ * never throws.
234
+ *
235
+ * `request` is null exactly when there are problems. They are listed in the
236
+ * order of a plan file (the name, the goal, `repository`, `defaults`, then
237
+ * the tasks one by one, then the cycles), each as one sentence that names
238
+ * its task: by its id, or by its place when the id is wrong or already
239
+ * another task's.
240
+ *
241
+ * The body has the name and the goal trimmed, `repository` and `defaults` as
242
+ * given when the plan has them, and of every task its id as `key`, its name
243
+ * trimmed, its objective as written and its dependencies once each. Nothing
244
+ * else of the plan is in it.
245
+ */
246
+ export function checkSwarmPlan(plan, name) {
247
+ const { request, problems } = inspectPlan(plan, name);
248
+ return { request, problems: listed(problems) };
249
+ }
250
+ /**
251
+ * The name of the swarm of a plan, before it is checked. Pure.
252
+ *
253
+ * It is the name asked for, `options.name`, when there is one: an empty or
254
+ * a blank one is kept, and `checkSwarmPlan` reports it. Else it is the
255
+ * plan's own `name` when that is a string, empty or not. Else it is the name
256
+ * of the plan file, `options.file`, without its directory and without a
257
+ * closing `.json`, when a file is given. Else it is undefined, which
258
+ * `checkSwarmPlan` reports as a name that is missing.
259
+ *
260
+ * An empty file name is a file name: the name it gives is empty, not
261
+ * undefined. A file named exactly `.json` gives an empty name as well when
262
+ * it is given without a directory, and the name `.json` when it is given
263
+ * with one (`plans/.json`).
264
+ */
265
+ export function swarmPlanName(plan, options = {}) {
266
+ return options.name ?? (isObject(plan) && typeof plan.name === 'string'
267
+ ? plan.name
268
+ : options.file === undefined ? undefined : basename(options.file, '.json'));
269
+ }
270
+ /**
271
+ * Read a plan file and return the body of `POST /swarms` for it. The swarm's
272
+ * name is `options.name`, else the plan's own `name`, else the name of the
273
+ * file without `.json`: see `swarmPlanName`.
274
+ *
275
+ * Throws a `CliError` that names the file as it was given when the file is
276
+ * missing, cannot be read, is over `MAX_PLAN_BYTES`, is not JSON, or holds a
277
+ * plan with problems: then the message has one line per problem.
278
+ */
279
+ export function readSwarmPlan(file, options = {}) {
280
+ let text;
281
+ let size;
282
+ try {
283
+ // Asked before reading: a file over the limit is refused without being read, let alone parsed.
284
+ size = statSync(file).size;
285
+ if (size <= MAX_PLAN_BYTES) {
286
+ // Counted again once read: a pipe says it holds 0 bytes, whatever comes through it.
287
+ const bytes = readFileSync(file);
288
+ size = bytes.length;
289
+ if (size <= MAX_PLAN_BYTES)
290
+ text = bytes.toString('utf8');
291
+ }
292
+ }
293
+ catch (error) {
294
+ const { code, message } = error;
295
+ throw new CliError(code === 'ENOENT'
296
+ ? `Plan file "${file}" does not exist.`
297
+ : `Plan file "${file}" cannot be read: ${message}`);
298
+ }
299
+ if (text === undefined) {
300
+ throw new CliError(`Plan file "${file}" is ${size} bytes; a plan file is at most 4 MB (${MAX_PLAN_BYTES} bytes).`);
301
+ }
302
+ let plan;
303
+ try {
304
+ plan = JSON.parse(text);
305
+ }
306
+ catch (error) {
307
+ // The parser quotes the file, which may hold anything.
308
+ throw new CliError(`Plan file "${file}" is not JSON: ${inertText(error.message)}`);
309
+ }
310
+ // A string: there is a file, so at the least there is the name the file gives.
311
+ const name = swarmPlanName(plan, { name: options.name, file });
312
+ const { request, problems } = inspectPlan(plan, name);
313
+ if (request === null) {
314
+ throw new CliError([
315
+ `Plan file "${file}" has ${count(problems.length, 'problem')}:`,
316
+ ...listed(problems).map((problem) => `- ${problem}`),
317
+ ].join('\n'));
318
+ }
319
+ return request;
320
+ }
321
+ //# sourceMappingURL=swarm-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swarm-plan.js","sourceRoot":"","sources":["../../src/utils/swarm-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE5D,iDAAiD;AACjD,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,kFAAkF;AAClF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AACnC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AACrC,iEAAiE;AACjE,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAC1C,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAC1C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAC/B,0DAA0D;AAC1D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C,MAAM,KAA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AC;QACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,uDAAuD;QACvD,MAAM,IAAI,QAAQ,CAAC,cAAc,IAAI,kBAAkB,SAAS,CAAE,KAAe,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAChG,CAAC;IAED,+EAA+E;IAC/E,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,CAAW,CAAC;IACzE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,QAAQ,CAAC;YACjB,cAAc,IAAI,SAAS,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG;YAC/D,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC;SACrD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { SandboxInfo } from '@stateset/sandbox-sdk';
2
+ import type { CliClient } from '../client.js';
3
+ export interface CreateRequest {
4
+ /** The POST /sandbox/create fields, `template` among them when one was asked for. */
5
+ fields: Record<string, unknown>;
6
+ startupTimeoutMs: number;
7
+ /** False when `--startup-timeout` was left at its default; setup then gets its own time on top of it. */
8
+ startupTimeoutChosen: boolean;
9
+ /** Called before the template route is, with how long its answer is waited for. */
10
+ onSetup?: (waitMs: number) => void;
11
+ }
12
+ export interface CreatedSandbox {
13
+ sandbox: SandboxInfo;
14
+ /** Setup steps the API reported as failed, in its words. The sandbox exists all the same. */
15
+ setupWarnings: string[];
16
+ }
17
+ /** The 400 of POST /sandbox/create for a template that writes files or runs setup commands. */
18
+ export declare function needsTemplateRoute(error: unknown): boolean;
19
+ /** The template route's body for these create fields; throws, naming the flags, if it has no field for one. */
20
+ export declare function templateRouteFields(template: string, fields: Record<string, unknown>): Record<string, unknown>;
21
+ /**
22
+ * How long the template route's answer is waited for. Setup runs inside the
23
+ * request, so a `--startup-timeout` left at its default is given a setup
24
+ * command's time on top; one the caller chose is kept as the whole wait.
25
+ */
26
+ export declare function setupWaitMs(startupTimeoutMs: number, startupTimeoutChosen: boolean): number;
27
+ /** Create a sandbox, from the template route when the API asks for it. */
28
+ export declare function createSandbox(client: CliClient, request: CreateRequest): Promise<CreatedSandbox>;
29
+ /** Spinner text while the template route creates the sandbox and runs the template's setup. */
30
+ export declare function setupProgressText(template: string, waitMs: number): string;
31
+ /**
32
+ * Print the setup steps that failed, and what became of the sandbox, to
33
+ * stderr so stdout/JSON output stays clean.
34
+ */
35
+ export declare function printSetupFailure(warnings: string[], sandboxFate: string): void;
36
+ //# sourceMappingURL=template-create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-create.d.ts","sourceRoot":"","sources":["../../src/utils/template-create.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA6B9C,MAAM,WAAW,aAAa;IAC5B,qFAAqF;IACrF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,yGAAyG;IACzG,oBAAoB,EAAE,OAAO,CAAC;IAC9B,mFAAmF;IACnF,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,WAAW,CAAC;IACrB,6FAA6F;IAC7F,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,+FAA+F;AAC/F,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM1D;AAED,+GAA+G;AAC/G,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkB9G;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,gBAAgB,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,GAAG,MAAM,CAE3F;AAED,0EAA0E;AAC1E,wBAAsB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAuBtG;AAED,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAG1E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAM/E"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * `--template <id>` on `sandbox create` and `run`.
3
+ *
4
+ * POST /sandbox/create takes `template` for the templates that only pick an
5
+ * image and defaults. It refuses the ones that write files or run setup
6
+ * commands with a 400 naming POST /sandbox/create-from-template, the route
7
+ * that does both. GET /templates does not say which kind a template is (its
8
+ * list view leaves out `files` and `setup_commands`), so the create is sent
9
+ * first and the template route is used only on that refusal, which made no
10
+ * sandbox. Neither request is sent a second time by the CLI.
11
+ */
12
+ import chalk from 'chalk';
13
+ import { CliError, wrapError } from './errors.js';
14
+ /** What the API allows one setup command (TEMPLATE_SETUP_COMMAND_TIMEOUT_MS); no built-in template has more than one. */
15
+ const SETUP_COMMAND_TIMEOUT_MS = 300_000;
16
+ /** /sandbox/create fields the template route takes, under the name it takes them by. */
17
+ const TEMPLATE_ROUTE_FIELDS = {
18
+ timeout_seconds: 'timeout_seconds',
19
+ env: 'env',
20
+ cpus: 'override_cpus',
21
+ memory: 'override_memory',
22
+ image: 'image',
23
+ durable: 'durable',
24
+ resource_class: 'resource_class',
25
+ egress: 'egress',
26
+ budget: 'budget',
27
+ };
28
+ /** The flags behind the create fields the template route has no field for. */
29
+ const UNSUPPORTED_FLAGS = {
30
+ isolation: '--isolation',
31
+ desktop_os: '--desktop-os',
32
+ credentials: '--credential',
33
+ };
34
+ const unconfirmedHint = 'This CLI did not repeat the request. The sandbox may exist, with its setup still running: '
35
+ + 'inspect `stateset sandbox list` before creating again.';
36
+ /** The 400 of POST /sandbox/create for a template that writes files or runs setup commands. */
37
+ export function needsTemplateRoute(error) {
38
+ const refusal = error;
39
+ return refusal?.status === 400
40
+ && refusal.code === 'VALIDATION_ERROR'
41
+ && refusal.details?.field === 'template'
42
+ && String(refusal.message).includes('/sandbox/create-from-template');
43
+ }
44
+ /** The template route's body for these create fields; throws, naming the flags, if it has no field for one. */
45
+ export function templateRouteFields(template, fields) {
46
+ const body = {};
47
+ const unsupported = [];
48
+ for (const [key, value] of Object.entries(fields)) {
49
+ if (value === undefined || key === 'template')
50
+ continue;
51
+ const name = TEMPLATE_ROUTE_FIELDS[key];
52
+ if (name)
53
+ body[name] = value;
54
+ else
55
+ unsupported.push(UNSUPPORTED_FLAGS[key] ?? key);
56
+ }
57
+ if (unsupported.length > 0) {
58
+ throw new CliError(`${unsupported.join(', ')} cannot be used with template "${template}": it writes files or runs setup commands, `
59
+ + 'and POST /sandbox/create-from-template, which creates such a template, does not take '
60
+ + `${unsupported.length > 1 ? 'these options' : 'this option'}`, { hint: `No sandbox was created. Leave out ${unsupported.join(', ')}, or choose a template without setup.` });
61
+ }
62
+ return body;
63
+ }
64
+ /**
65
+ * How long the template route's answer is waited for. Setup runs inside the
66
+ * request, so a `--startup-timeout` left at its default is given a setup
67
+ * command's time on top; one the caller chose is kept as the whole wait.
68
+ */
69
+ export function setupWaitMs(startupTimeoutMs, startupTimeoutChosen) {
70
+ return startupTimeoutChosen ? startupTimeoutMs : startupTimeoutMs + SETUP_COMMAND_TIMEOUT_MS;
71
+ }
72
+ /** Create a sandbox, from the template route when the API asks for it. */
73
+ export async function createSandbox(client, request) {
74
+ const { fields, startupTimeoutMs } = request;
75
+ const template = fields.template;
76
+ try {
77
+ return { sandbox: await client.sandbox.create({ startupTimeoutMs, ...fields }), setupWarnings: [] };
78
+ }
79
+ catch (error) {
80
+ if (typeof template !== 'string' || !needsTemplateRoute(error))
81
+ throw error;
82
+ }
83
+ const body = templateRouteFields(template, fields);
84
+ const waitMs = setupWaitMs(startupTimeoutMs, request.startupTimeoutChosen);
85
+ request.onSetup?.(waitMs);
86
+ try {
87
+ const sandbox = await client.sandbox.createFromTemplate(template, { startupTimeoutMs: waitMs, ...body });
88
+ return { sandbox, setupWarnings: sandbox.warnings ?? [] };
89
+ }
90
+ catch (error) {
91
+ const failure = wrapError(error);
92
+ // A 4xx is a refusal. After a timeout, a dropped connection or a 5xx the
93
+ // sandbox may have been made.
94
+ const status = error?.status;
95
+ if (!(typeof status === 'number' && status >= 400 && status < 500))
96
+ failure.hint = unconfirmedHint;
97
+ throw failure;
98
+ }
99
+ }
100
+ /** Spinner text while the template route creates the sandbox and runs the template's setup. */
101
+ export function setupProgressText(template, waitMs) {
102
+ return `Creating sandbox and running the setup of template ${template} (its files and setup commands); `
103
+ + `waiting up to ${Math.round(waitMs / 1000)}s...`;
104
+ }
105
+ /**
106
+ * Print the setup steps that failed, and what became of the sandbox, to
107
+ * stderr so stdout/JSON output stays clean.
108
+ */
109
+ export function printSetupFailure(warnings, sandboxFate) {
110
+ console.error(chalk.yellow(`Template setup failed (${warnings.length}):`));
111
+ for (const warning of warnings) {
112
+ console.error(chalk.yellow(` - ${warning}`));
113
+ }
114
+ console.error(sandboxFate);
115
+ }
116
+ //# sourceMappingURL=template-create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-create.js","source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B;IACvE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,0BAA0B,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IAC3E,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAC7B,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { SandboxRow } from './model.js';
2
- export type ActionId = 'create' | 'execute' | 'interpret' | 'files' | 'history' | 'launch' | 'tasks' | 'delegate' | 'workers' | 'pause' | 'resume' | 'extend' | 'stop' | 'details' | 'overview' | 'activity' | 'connection' | 'refresh' | 'credits' | 'subscription' | 'help' | 'registry' | 'inputBatches';
2
+ export type ActionId = 'create' | 'execute' | 'interpret' | 'files' | 'history' | 'launch' | 'tasks' | 'delegate' | 'workers' | 'pause' | 'resume' | 'extend' | 'stop' | 'details' | 'overview' | 'activity' | 'connection' | 'refresh' | 'credits' | 'subscription' | 'help' | 'registry' | 'inputBatches' | 'agents';
3
3
  export interface WorkbenchAction {
4
4
  id: ActionId;
5
5
  label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/workbench/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAC9K,UAAU,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,cAAc,GAAG,MAAM,GAAG,UAAU,GA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